From 374d649fde3bcd95d90f0983589e29af4cf08a9a Mon Sep 17 00:00:00 2001 From: Daniel Lebrecht Date: Wed, 23 Aug 2017 16:38:35 +0200 Subject: [PATCH 001/352] added inputs to transaction builder --- types/bitcoinjs-lib/index.d.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/types/bitcoinjs-lib/index.d.ts b/types/bitcoinjs-lib/index.d.ts index 986bb75e0b..20e7162ecf 100644 --- a/types/bitcoinjs-lib/index.d.ts +++ b/types/bitcoinjs-lib/index.d.ts @@ -206,6 +206,14 @@ export class Transaction { export class TransactionBuilder { constructor(network?: Network, maximumFeeRate?: number); + inputs: Array<{ pubKeys: Buffer[], + signatures: ECSignature[], + prevOutScript: Buffer, + prevOutType: string, + signType: string, + signScript: Buffer, + witness: boolean} >; + addInput(txhash: Buffer | string | Transaction, vout: number, sequence?: number, prevOutScript?: Buffer): number; addOutput(scriptPubKey: Buffer, value: number): number; From aafbcfd90bb6ff374842b5e370e3c08790fa0b46 Mon Sep 17 00:00:00 2001 From: Daniel Lebrecht Date: Tue, 3 Oct 2017 13:57:11 +0200 Subject: [PATCH 002/352] verify should return boolean, fixed inputs --- types/bitcoinjs-lib/bitcoinjs-lib-tests.ts | 2 +- types/bitcoinjs-lib/index.d.ts | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/types/bitcoinjs-lib/bitcoinjs-lib-tests.ts b/types/bitcoinjs-lib/bitcoinjs-lib-tests.ts index 549de76507..868659e6b6 100644 --- a/types/bitcoinjs-lib/bitcoinjs-lib-tests.ts +++ b/types/bitcoinjs-lib/bitcoinjs-lib-tests.ts @@ -53,7 +53,7 @@ describe('bitcoinjs-lib (basic)', () => { const tx = new bitcoin.TransactionBuilder(); tx.addInput('aa94ab02c182214f090e99a0d57021caffd0f195a81c24602b1028b130b63e31', 0); - tx.addOutput(Buffer.from('1Gokm82v6DmtwKEB8AiVhm82hyFSsEvBDK'), 15000); + tx.addOutput(Buffer.from('1Gokm82v6DmtwKEB8AiVhm82hyFSsEvBDK', 'utf8'), 15000); tx.sign(0, keyPair); // tslint:disable-next-line:max-line-length diff --git a/types/bitcoinjs-lib/index.d.ts b/types/bitcoinjs-lib/index.d.ts index 20e7162ecf..796758715d 100644 --- a/types/bitcoinjs-lib/index.d.ts +++ b/types/bitcoinjs-lib/index.d.ts @@ -132,7 +132,7 @@ export class HDNode { toBase58(): string; - verify(hash: Buffer, signature: ECSignature): Buffer; + verify(hash: Buffer, signature: ECSignature): boolean; static HIGHEST_BIT: number; @@ -204,15 +204,16 @@ export class Transaction { } export class TransactionBuilder { - constructor(network?: Network, maximumFeeRate?: number); - + tx: Transaction; inputs: Array<{ pubKeys: Buffer[], - signatures: ECSignature[], - prevOutScript: Buffer, - prevOutType: string, - signType: string, - signScript: Buffer, - witness: boolean} >; + signatures: Buffer[], + prevOutScript: Buffer, + prevOutType: string, + signType: string, + signScript: Buffer, + witness: boolean} >; + + constructor(network?: Network, maximumFeeRate?: number); addInput(txhash: Buffer | string | Transaction, vout: number, sequence?: number, prevOutScript?: Buffer): number; From 5f30e1c83d41fbe04f2d8ed2b9c3f25cdfef5e65 Mon Sep 17 00:00:00 2001 From: Daniel Lebrecht Date: Fri, 13 Oct 2017 17:11:27 +0200 Subject: [PATCH 003/352] added property private key (d) in ECPair class --- types/bitcoinjs-lib/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/bitcoinjs-lib/index.d.ts b/types/bitcoinjs-lib/index.d.ts index 796758715d..d33bc26e35 100644 --- a/types/bitcoinjs-lib/index.d.ts +++ b/types/bitcoinjs-lib/index.d.ts @@ -66,6 +66,8 @@ export class ECPair { constructor(d: null | undefined, Q: any, options?: { compressed?: boolean, network?: Network }); // Q should be ECPoint, but not sure how to define such type + d: BigInteger; + getAddress(): string; getNetwork(): Network; From 582327e65bef697883c2f27dceac2267e4aeb4ca Mon Sep 17 00:00:00 2001 From: dmayerdesign Date: Sun, 15 Oct 2017 14:44:29 -0400 Subject: [PATCH 004/352] Correct type-o in IOrder --- types/stripe-node/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/stripe-node/index.d.ts b/types/stripe-node/index.d.ts index 9bf45d3411..379fe4550a 100644 --- a/types/stripe-node/index.d.ts +++ b/types/stripe-node/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for stripe-node 4.7.0 +// Type definitions for stripe-node 4.7.1 // Project: https://github.com/stripe/stripe-node/ // Definitions by: William Johnston , Peter Harris , Sampson Oliver // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -2338,7 +2338,7 @@ declare namespace StripeNode { /** * The timestamps at which the order status was updated */ - status_transactions: { + status_transitions: { canceled: number; fulfiled: number; paid: number; From c6343d34d85acebc46c81e6187cf86c3623b958e Mon Sep 17 00:00:00 2001 From: pr1st0n Date: Thu, 19 Oct 2017 22:06:32 +0300 Subject: [PATCH 005/352] Added definitions for clusterize.js --- types/clusterize.js/clusterize.js-tests.ts | 19 +++++++++++ types/clusterize.js/index.d.ts | 39 ++++++++++++++++++++++ types/clusterize.js/tsconfig.json | 23 +++++++++++++ types/clusterize.js/tslint.json | 1 + 4 files changed, 82 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..e7e8359185 --- /dev/null +++ b/types/clusterize.js/clusterize.js-tests.ts @@ -0,0 +1,19 @@ +import Clusterize = require('clusterize.js'); + +const clusterize = new Clusterize({ contentId: '', scrollId: '' }); + +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..31b4f072ca --- /dev/null +++ b/types/clusterize.js/index.d.ts @@ -0,0 +1,39 @@ +// Type definitions for clusterize.js 0.17 +// Project: https://github.com/NeXTs/Clusterize.js +// Definitions by: My Self +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare class Clusterize { + constructor(options: ClusterizeOptions); + + 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; +} + +interface ClusterizeOptions { + 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?: ClusterizeCallbacks; +} + +interface ClusterizeCallbacks { + clusterWillChange?(cb: () => any): any; + clusterChanged?(cb: () => any): any; + scrollingProgress?(cb: (progress: number) => any): any; +} + +export = Clusterize; diff --git a/types/clusterize.js/tsconfig.json b/types/clusterize.js/tsconfig.json new file mode 100644 index 0000000000..319aca3588 --- /dev/null +++ b/types/clusterize.js/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": false, + "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" } From d1daeda3b26820c140a33a68c62335cdd4456dc1 Mon Sep 17 00:00:00 2001 From: pr1st0n Date: Thu, 19 Oct 2017 22:28:55 +0300 Subject: [PATCH 006/352] Fixed definitions author. --- types/clusterize.js/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/clusterize.js/index.d.ts b/types/clusterize.js/index.d.ts index 31b4f072ca..beda96d79d 100644 --- a/types/clusterize.js/index.d.ts +++ b/types/clusterize.js/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for clusterize.js 0.17 // Project: https://github.com/NeXTs/Clusterize.js -// Definitions by: My Self +// Definitions by: Pr1st0n // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare class Clusterize { From 64b1289e185646ffffb2e23f3292dbbe19ebb09e Mon Sep 17 00:00:00 2001 From: pr1st0n Date: Fri, 20 Oct 2017 11:23:51 +0300 Subject: [PATCH 007/352] Review fixes. --- types/clusterize.js/clusterize.js-tests.ts | 3 +- types/clusterize.js/index.d.ts | 38 ++++++++++++---------- types/clusterize.js/tsconfig.json | 2 +- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/types/clusterize.js/clusterize.js-tests.ts b/types/clusterize.js/clusterize.js-tests.ts index e7e8359185..acbfbc36f8 100644 --- a/types/clusterize.js/clusterize.js-tests.ts +++ b/types/clusterize.js/clusterize.js-tests.ts @@ -1,6 +1,7 @@ import Clusterize = require('clusterize.js'); -const clusterize = new Clusterize({ contentId: '', scrollId: '' }); +const options: Clusterize.Options = { contentId: '', scrollId: '' }; +const clusterize = new Clusterize(options); clusterize.append(['
  • ']); diff --git a/types/clusterize.js/index.d.ts b/types/clusterize.js/index.d.ts index beda96d79d..2d0e169c38 100644 --- a/types/clusterize.js/index.d.ts +++ b/types/clusterize.js/index.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare class Clusterize { - constructor(options: ClusterizeOptions); + constructor(options: Clusterize.Options); destroy(clean?: boolean): void; refresh(force?: boolean): void; @@ -16,24 +16,26 @@ declare class Clusterize { prepend(rows: string[]): void; } -interface ClusterizeOptions { - 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?: ClusterizeCallbacks; -} +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 ClusterizeCallbacks { - clusterWillChange?(cb: () => any): any; - clusterChanged?(cb: () => any): any; - scrollingProgress?(cb: (progress: number) => any): any; + interface Callbacks { + clusterWillChange?(cb: () => any): void; + clusterChanged?(cb: () => any): void; + scrollingProgress?(cb: (progress: number) => any): void; + } } export = Clusterize; diff --git a/types/clusterize.js/tsconfig.json b/types/clusterize.js/tsconfig.json index 319aca3588..10ca5c2a1a 100644 --- a/types/clusterize.js/tsconfig.json +++ b/types/clusterize.js/tsconfig.json @@ -7,7 +7,7 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, - "strictFunctionTypes": false, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" From 67a8a0fd9151c27321ef932ebae6622f4b6452b0 Mon Sep 17 00:00:00 2001 From: pr1st0n Date: Fri, 20 Oct 2017 17:21:20 +0300 Subject: [PATCH 008/352] Review fix. --- types/clusterize.js/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/clusterize.js/index.d.ts b/types/clusterize.js/index.d.ts index 2d0e169c38..7c549761d6 100644 --- a/types/clusterize.js/index.d.ts +++ b/types/clusterize.js/index.d.ts @@ -32,9 +32,9 @@ declare namespace Clusterize { } interface Callbacks { - clusterWillChange?(cb: () => any): void; - clusterChanged?(cb: () => any): void; - scrollingProgress?(cb: (progress: number) => any): void; + clusterWillChange?(cb: () => void): void; + clusterChanged?(cb: () => void): void; + scrollingProgress?(cb: (progress: number) => void): void; } } From e670e0731cad74822fb9f7329f2f4dead346e7c5 Mon Sep 17 00:00:00 2001 From: rlindgren Date: Fri, 20 Oct 2017 12:01:00 -0400 Subject: [PATCH 009/352] Fix doWhilst, doUntil definitions and tests --- types/async/index.d.ts | 4 ++-- types/async/test/index.ts | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/types/async/index.d.ts b/types/async/index.d.ts index 80f2888a8b..7c32079086 100644 --- a/types/async/index.d.ts +++ b/types/async/index.d.ts @@ -174,9 +174,9 @@ export function parallel(tasks: Dictionary>, callback? export function parallelLimit(tasks: Array>, limit: number, callback?: AsyncResultArrayCallback): void; export function parallelLimit(tasks: Dictionary>, limit: number, callback?: AsyncResultObjectCallback): void; export function whilst(test: () => boolean, fn: AsyncVoidFunction, callback: ErrorCallback): void; -export function doWhilst(fn: AsyncVoidFunction, test: () => boolean, callback: ErrorCallback): void; +export function doWhilst(fn: AsyncVoidFunction, test: (result?: any) => boolean, callback: ErrorCallback): void; export function until(test: () => boolean, fn: AsyncVoidFunction, callback: ErrorCallback): void; -export function doUntil(fn: AsyncVoidFunction, test: () => boolean, callback: ErrorCallback): void; +export function doUntil(fn: AsyncVoidFunction, test: (result?: any) => boolean, callback: ErrorCallback): void; export function during(test: (testCallback : AsyncBooleanResultCallback) => void, fn: AsyncVoidFunction, callback: ErrorCallback): void; export function doDuring(fn: AsyncVoidFunction, test: (testCallback: AsyncBooleanResultCallback) => void, callback: ErrorCallback): void; export function forever(next: (next : ErrorCallback) => void, errBack: ErrorCallback) : void; diff --git a/types/async/test/index.ts b/types/async/test/index.ts index 821ccd0650..3c6c2f5dfe 100644 --- a/types/async/test/index.ts +++ b/types/async/test/index.ts @@ -239,16 +239,16 @@ async.parallelLimit({ function whileFn(callback: any) { - count++; - setTimeout(callback, 1000); + setTimeout(() => callback(null, ++count), 1000); } function whileTest() { return count < 5; } +function doWhileTest(count: number) { return count < 5; } var count = 0; async.whilst(whileTest, whileFn, function (err) { }); async.until(whileTest, whileFn, function (err) { }); -async.doWhilst(whileFn, whileTest, function (err) { }); -async.doUntil(whileFn, whileTest, function (err) { }); +async.doWhilst(whileFn, doWhileTest, function (err) { }); +async.doUntil(whileFn, doWhileTest, function (err) { }); async.during(function (testCallback) { testCallback(new Error(), false); }, function (callback) { callback() }, function (error) { console.log(error) }); async.doDuring(function (callback) { callback() }, function (testCallback) { testCallback(new Error(), false); }, function (error) { console.log(error) }); From 9e4fd891d59ca3f6ef012619fb332e20e2cd2e09 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Sat, 21 Oct 2017 10:51:01 +0200 Subject: [PATCH 010/352] fix(webpack): `MultiCompiler` extends `Tapable` https://github.com/webpack/webpack/blob/69e0844028950e1316fb4ed9f4ac4593ecc205b3/lib/MultiCompiler.js#L12 --- types/webpack/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/webpack/index.d.ts b/types/webpack/index.d.ts index b99f489cec..b4e6cbfded 100644 --- a/types/webpack/index.d.ts +++ b/types/webpack/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for webpack 3.0 +// Type definitions for webpack 3.8 // Project: https://github.com/webpack/webpack // Definitions by: Qubo // Benjamin Lim @@ -613,7 +613,7 @@ declare namespace webpack { } } - abstract class MultiCompiler implements ICompiler { + abstract class MultiCompiler extends Tapable implements ICompiler { run(handler: MultiCompiler.Handler): void; watch(watchOptions: MultiCompiler.WatchOptions, handler: MultiCompiler.Handler): MultiWatching; } From 346ab192169a93f3ed5e9615a75724152f41157f Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Sun, 22 Oct 2017 15:30:27 +0200 Subject: [PATCH 011/352] webpack: add update API --- types/webpack/index.d.ts | 52 +++++++++++++++---- types/webpack/webpack-tests.ts | 93 ++++++++++++++++++---------------- 2 files changed, 91 insertions(+), 54 deletions(-) diff --git a/types/webpack/index.d.ts b/types/webpack/index.d.ts index b4e6cbfded..aa7c221825 100644 --- a/types/webpack/index.d.ts +++ b/types/webpack/index.d.ts @@ -98,6 +98,8 @@ declare namespace webpack { stats?: Options.Stats; /** Performance options */ performance?: Options.Performance; + /** Limit the number of parallel processed modules. Can be used to fine tune performance or to get more reliable profiling results */ + parallelism?: number; } interface Entry { @@ -167,6 +169,8 @@ declare namespace webpack { * */ libraryTarget?: 'var' | 'this' | 'commonjs' | 'commonjs2' | 'amd' | 'umd' | 'window' | 'assign' | 'jsonp'; + /** Configure which module or modules will be exposed via the `libraryTarget` */ + libraryExport?: string | string[]; /** If output.libraryTarget is set to umd and output.library is set, setting this to true will name the AMD module. */ umdNamedDefine?: boolean; /** Prefixes every line of the source in the bundle with this string. */ @@ -181,7 +185,7 @@ declare namespace webpack { /** A array of applied post loaders. */ postLoaders?: Rule[]; /** A RegExp or an array of RegExps. Don’t parse files matching. */ - noParse?: RegExp | RegExp[]; + noParse?: RegExp | RegExp[] | ((content: string) => boolean); unknownContextRequest?: string; unknownContextRecursive?: boolean; unknownContextRegExp?: RegExp; @@ -420,7 +424,7 @@ declare namespace webpack { type ConditionSpec = TestConditionSpec | OrConditionSpec | AndConditionSpec | NotConditionSpec; // tslint:disable-next-line:no-empty-interface - interface ConditionArray extends Array {} + interface ConditionArray extends Array { } type Condition = string | RegExp | ((absPath: string) => boolean) | ConditionSpec | ConditionArray; interface OldLoader { @@ -663,6 +667,8 @@ declare namespace webpack { assetsSort?: string; /** Add information about cached (not built) modules */ cached?: boolean; + /** Show cached assets (setting this to `false` only shows emitted files) */ + cachedAssets?: true, /** Add children information */ children?: boolean; /** Add built modules information to chunk information */ @@ -675,16 +681,32 @@ declare namespace webpack { chunksSort?: string; /** Context directory for request shortening */ context?: string; - /** Add details to errors (like resolving log) */ - errorDetails?: boolean; + /** Display the distance from the entry point for each module */ + depth?: false; + /** Display the entry points with the corresponding bundles */ + entrypoints?: boolean; + /** Add --env information */ + env?: boolean; /** Add errors */ errors?: boolean; + /** Add details to errors (like resolving log) */ + errorDetails?: boolean; + /** Exclude assets from being displayed in stats */ + excludeAssets?: StatsExcludeFilter; + /** Exclude modules from being displayed in stats */ + excludeModules?: StatsExcludeFilter; + /** See excludeModules */ + exclude?: StatsExcludeFilter; /** Add the hash of the compilation */ hash?: boolean; + /** Set the maximum number of modules to be shown */ + maxModules?: number; /** Add built modules information */ modules?: boolean; /** Sort the modules by a field */ modulesSort?: string; + /** Show dependencies and origin of warnings/errors */ + moduleTrace?: number; /** Add public path information */ publicPath?: boolean; /** Add information about the reasons why modules are included */ @@ -697,10 +719,20 @@ declare namespace webpack { version?: boolean; /** Add warnings */ warnings?: boolean; + /** Show which exports of a module are used */ + usedExports?: boolean; + /** Filter warnings to be shown */ + warningsFilter?: string | RegExp | (string | RegExp)[] | ((warning: string) => boolean); + /** Show performance hint when file size exceeds `performance.maxAssetSize` */ + performance?: boolean; + /** Show the exports of the modules */ + providedExports?: boolean; } type ToJsonOptions = Preset | ToJsonOptionsObject; + type StatsExcludeFilter = string | string[] | RegExp | RegExp[] | ((assetName: string) => boolean) | ((assetName: string) => boolean)[]; + interface ToStringOptionsObject extends ToJsonOptionsObject { /** `webpack --colors` equivalent */ colors?: boolean; @@ -735,7 +767,7 @@ declare namespace webpack { } class DefinePlugin extends Plugin { - constructor(definitions: {[key: string]: any}); + constructor(definitions: { [key: string]: any }); } class DllPlugin extends Plugin { @@ -861,7 +893,7 @@ declare namespace webpack { } class NamedChunksPlugin extends Plugin { - constructor(nameResolver?: (chunk: any) => string | null ); + constructor(nameResolver?: (chunk: any) => string | null); } class NoEmitOnErrorsPlugin extends Plugin { @@ -888,11 +920,11 @@ declare namespace webpack { } class EnvironmentPlugin extends Plugin { - constructor(envs: string[] | {[key: string]: any}); + constructor(envs: string[] | { [key: string]: any }); } class ProvidePlugin extends Plugin { - constructor(definitions: {[key: string]: any}); + constructor(definitions: { [key: string]: any }); } class SourceMapDevToolPlugin extends Plugin { @@ -926,7 +958,7 @@ declare namespace webpack { } namespace optimize { - class ModuleConcatenationPlugin extends Plugin {} + class ModuleConcatenationPlugin extends Plugin { } class AggressiveMergingPlugin extends Plugin { constructor(options?: AggressiveMergingPlugin.Options); } @@ -1280,7 +1312,7 @@ declare namespace webpack { * @param content * @param sourceMap */ - emitFile(name: string, content: Buffer|string, sourceMap: any): void; + emitFile(name: string, content: Buffer | string, sourceMap: any): void; /** * Access to the compilation's inputFileSystem property. diff --git a/types/webpack/webpack-tests.ts b/types/webpack/webpack-tests.ts index 09405f3271..fa24368546 100644 --- a/types/webpack/webpack-tests.ts +++ b/types/webpack/webpack-tests.ts @@ -116,10 +116,10 @@ configuration = { ] }; -configuration = { +configuration = { entry: { a: "./a", b: "./b" }, output: { filename: "[name].js" }, - plugins: [ new webpack.optimize.CommonsChunkPlugin({ name: "init.js" }) ] + plugins: [new webpack.optimize.CommonsChunkPlugin({ name: "init.js" })] }; // @@ -451,8 +451,8 @@ plugin = new webpack.LoaderOptionsPlugin({ debug: true }); plugin = new webpack.EnvironmentPlugin(['a', 'b']); -plugin = new webpack.EnvironmentPlugin({a: true, b: 'c'}); -plugin = new webpack.ProgressPlugin((percent: number, message: string) => {}); +plugin = new webpack.EnvironmentPlugin({ a: true, b: 'c' }); +plugin = new webpack.ProgressPlugin((percent: number, message: string) => { }); plugin = new webpack.HashedModuleIdsPlugin(); plugin = new webpack.HashedModuleIdsPlugin({ hashFunction: 'sha256', @@ -531,8 +531,11 @@ webpack({ source: true, timings: true, version: true, - warnings: true + warnings: true, + warningsFilter: ["filter", /filter/], + excludeAssets: ["filter", "excluded"] }); + if (jsonStats.errors.length > 0) return handleSoftErrors(jsonStats.errors); if (jsonStats.warnings.length > 0) @@ -542,7 +545,7 @@ webpack({ declare const fs: any; -compiler = webpack({ }); +compiler = webpack({}); compiler.outputFileSystem = fs; compiler.run((err, stats) => { // ... @@ -567,47 +570,49 @@ rule = { configuration = { module: { rules: [ - { oneOf: [ - { - test: { - and: [ - /a.\.js$/, - /b\.js$/ - ] - }, - loader: "./loader?first" - }, - { - test: [ - require.resolve("./a"), - require.resolve("./c"), - ], - issuer: require.resolve("./b"), - use: [ - "./loader?second-1", - { - loader: "./loader", - options: "second-2" + { + oneOf: [ + { + test: { + and: [ + /a.\.js$/, + /b\.js$/ + ] }, - { - loader: "./loader", - options: { - get: () => "second-3" - } - } - ] - }, - { - test: { - or: [ + loader: "./loader?first" + }, + { + test: [ require.resolve("./a"), require.resolve("./c"), + ], + issuer: require.resolve("./b"), + use: [ + "./loader?second-1", + { + loader: "./loader", + options: "second-2" + }, + { + loader: "./loader", + options: { + get: () => "second-3" + } + } ] }, - loader: "./loader", - options: "third" - } - ]} + { + test: { + or: [ + require.resolve("./a"), + require.resolve("./c"), + ] + }, + loader: "./loader", + options: "third" + } + ] + } ] } }; @@ -638,7 +643,7 @@ function loader(this: webpack.loader.LoaderContext, source: string | Buffer, sou this.addDependency(''); - this.resolve('context', 'request', ( err: Error, result: string) => {}); + this.resolve('context', 'request', (err: Error, result: string) => { }); this.emitWarning('warning message'); this.emitWarning(new Error('warning message')); @@ -650,6 +655,6 @@ function loader(this: webpack.loader.LoaderContext, source: string | Buffer, sou } (loader as webpack.loader.Loader).raw = true; -(loader as webpack.loader.Loader).pitch = (remainingRequest: string, precedingRequest: string, data: any) => {}; +(loader as webpack.loader.Loader).pitch = (remainingRequest: string, precedingRequest: string, data: any) => { }; const loaderRef: webpack.loader.Loader = loader; console.log(loaderRef.raw === true); From 418ccd2c0c1a3499f0ae494979c0ba7be7aec732 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Sun, 22 Oct 2017 15:31:12 +0200 Subject: [PATCH 012/352] webpack: update header --- types/webpack/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/webpack/index.d.ts b/types/webpack/index.d.ts index aa7c221825..228ade7521 100644 --- a/types/webpack/index.d.ts +++ b/types/webpack/index.d.ts @@ -7,6 +7,7 @@ // Mohsen Azimi // Jonathan Creamer // Ahmed T. Ali +// Alan Agius // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// From 0a5138eb79adaa63172df3e82176cf87c8a60708 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Sun, 22 Oct 2017 15:36:43 +0200 Subject: [PATCH 013/352] webpack: fix lint issues --- types/webpack/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/webpack/index.d.ts b/types/webpack/index.d.ts index 228ade7521..d13311d7bb 100644 --- a/types/webpack/index.d.ts +++ b/types/webpack/index.d.ts @@ -669,7 +669,7 @@ declare namespace webpack { /** Add information about cached (not built) modules */ cached?: boolean; /** Show cached assets (setting this to `false` only shows emitted files) */ - cachedAssets?: true, + cachedAssets?: true; /** Add children information */ children?: boolean; /** Add built modules information to chunk information */ @@ -723,7 +723,7 @@ declare namespace webpack { /** Show which exports of a module are used */ usedExports?: boolean; /** Filter warnings to be shown */ - warningsFilter?: string | RegExp | (string | RegExp)[] | ((warning: string) => boolean); + warningsFilter?: string | RegExp | Array | ((warning: string) => boolean); /** Show performance hint when file size exceeds `performance.maxAssetSize` */ performance?: boolean; /** Show the exports of the modules */ @@ -732,7 +732,7 @@ declare namespace webpack { type ToJsonOptions = Preset | ToJsonOptionsObject; - type StatsExcludeFilter = string | string[] | RegExp | RegExp[] | ((assetName: string) => boolean) | ((assetName: string) => boolean)[]; + type StatsExcludeFilter = string | string[] | RegExp | RegExp[] | ((assetName: string) => boolean) | Array<(assetName: string) => boolean>; interface ToStringOptionsObject extends ToJsonOptionsObject { /** `webpack --colors` equivalent */ From f3feb4be94cfca69999d1889f43319804eb79399 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Sun, 22 Oct 2017 15:39:02 +0200 Subject: [PATCH 014/352] webpack: update `warningsFilter` --- types/webpack/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/webpack/index.d.ts b/types/webpack/index.d.ts index d13311d7bb..2ab37cba87 100644 --- a/types/webpack/index.d.ts +++ b/types/webpack/index.d.ts @@ -723,7 +723,7 @@ declare namespace webpack { /** Show which exports of a module are used */ usedExports?: boolean; /** Filter warnings to be shown */ - warningsFilter?: string | RegExp | Array | ((warning: string) => boolean); + warningsFilter?: string | string[] | RegExp | RegExp[] | ((warning: string) => boolean); /** Show performance hint when file size exceeds `performance.maxAssetSize` */ performance?: boolean; /** Show the exports of the modules */ From 0937f4ba44051ee31cae3b1378b9e03713a675c1 Mon Sep 17 00:00:00 2001 From: Curtis Maddalozzo Date: Sun, 22 Oct 2017 15:58:22 +0100 Subject: [PATCH 015/352] Add generics to memoize, partial, and once --- types/ramda/index.d.ts | 3 +++ types/ramda/ramda-tests.ts | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/types/ramda/index.d.ts b/types/ramda/index.d.ts index 776c074b73..4d1835f193 100644 --- a/types/ramda/index.d.ts +++ b/types/ramda/index.d.ts @@ -1000,6 +1000,7 @@ declare namespace R { * additional call to fn; instead, the cached result for that set of arguments will be returned. */ memoize(fn: (...a: any[]) => any): (...a: any[]) => any; + memoize(fn: (...a: any[]) => T): (...a: any[]) => T; /** * Create a new object with the own properties of a @@ -1159,6 +1160,7 @@ declare namespace R { * returned in subsequent invocations. */ once(fn: (...a: any[]) => any): (...a: any[]) => any; + once(fn: (...a: any[]) => T): (...a: any[]) => T; /** * A function that returns the first truthy of two arguments otherwise the last argument. Note that this is @@ -1192,6 +1194,7 @@ declare namespace R { * original function's arguments list. In some libraries this function is named `applyLeft`. */ partial(fn: (...a: any[]) => any, ...args: any[]): (...a: any[]) => any; + partial(fn: (...a: any[]) => T, ...args: any[]): (...a: any[]) => T; /** * Accepts as its arguments a function and any number of values and returns a function that, diff --git a/types/ramda/ramda-tests.ts b/types/ramda/ramda-tests.ts index 973edf29e3..9258db6ab0 100644 --- a/types/ramda/ramda-tests.ts +++ b/types/ramda/ramda-tests.ts @@ -261,11 +261,11 @@ R.times(i, 5); })(); (() => { - function multiply(a: number, b: number) { + function multiply(a: number, b: number): number { return a * b; } - const double = R.partial(multiply, 2); + const double = R.partial(multiply, 2); double(2); // => 4 function greet(salutation: string, title: string, firstName: string, lastName: string) { @@ -300,12 +300,20 @@ R.times(i, 5); // Note that argument order matters memoTrackedAdd(2, 1); // => 3 numberOfCalls; // => 3 + + function stringLength(str: string): number { + return str.length; + } + const memoStringLength = R.memoize(stringLength); + const isLong = memoStringLength('short') > 10; // false })(); (() => { const addOneOnce = R.once((x: number) => x + 1); addOneOnce(10); // => 11 addOneOnce(addOneOnce(50)); // => 11 + + const str = R.once(() => 'test')(); })(); (() => { From 7669a801824b96e7d39711ca9a1b9c5bb7a74871 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Sch=C3=BCrmann?= Date: Mon, 18 Sep 2017 10:30:08 +0200 Subject: [PATCH 016/352] Ramda: Tighten type signature for `append` The Ramda documentation clearly states that the element to append an the elements in the list should have the same type. The previous type definition unnecessarily weakened type safety. For example this error could not be detected by TypeScript: interface A { id: number } const list: A[] = [] R.append({idd: 2}, list) Which seems ridiculous. If one wanted an intersection type, one could explicity define it to be used for the list/element type. Additionally, the function `prepend` already is as strict as this proposal, that should probably be consistent. I also deleted a redundant line. --- types/ramda/index.d.ts | 5 ++--- types/ramda/ramda-tests.ts | 4 ---- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/types/ramda/index.d.ts b/types/ramda/index.d.ts index 776c074b73..f13b0d20ec 100644 --- a/types/ramda/index.d.ts +++ b/types/ramda/index.d.ts @@ -225,9 +225,8 @@ declare namespace R { /** * Returns a new list containing the contents of the given list, followed by the given element. */ - append(el: U): (list: T[]) => Array<(T & U)>; - append(el: U, list: T[]): Array<(T & U)>; - append(el: T, list: string): Array; + append(el: T, list: T[]): T[]; + append(el: T): (list: T[]) => T[]; /** * Applies function fn to the argument list args. This is useful for creating a fixed-arity function from diff --git a/types/ramda/ramda-tests.ts b/types/ramda/ramda-tests.ts index 973edf29e3..76e378fdb5 100644 --- a/types/ramda/ramda-tests.ts +++ b/types/ramda/ramda-tests.ts @@ -442,10 +442,6 @@ R.times(i, 5); R.append("tests", ["write", "more"]); // => ['write', 'more', 'tests'] R.append("tests")(["write", "more"]); // => ['write', 'more', 'tests'] R.append("tests", []); // => ['tests'] - R.append(["tests"], ["write", "more"]); // => ['write', 'more', ['tests']] - R.append(["tests"], ["write", "more"]); // => ['write', 'more', ['tests']] - R.append(["tests"])(["write", "more"]); // => ['write', 'more', ['tests']] - R.append(["tests"])(["write", "more"]); // => ['write', 'more', ['tests']] }; () => { From 5c52119b92e2b6dc70cf2b3a577a1c0f7776d377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Rada?= Date: Mon, 23 Oct 2017 11:58:24 +0200 Subject: [PATCH 017/352] Update DropdownItem.d.ts Missing toggle option in props --- types/reactstrap/lib/DropdownItem.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/reactstrap/lib/DropdownItem.d.ts b/types/reactstrap/lib/DropdownItem.d.ts index 6fae837041..063b59cf0c 100644 --- a/types/reactstrap/lib/DropdownItem.d.ts +++ b/types/reactstrap/lib/DropdownItem.d.ts @@ -9,6 +9,7 @@ interface Props { className?: string; cssModule?: CSSModule; href?: string; + toggle?: boolean; } declare var DropdownItem: React.StatelessComponent; From 6fb077d3e6c38d0bde5012462c22975c4da18cd9 Mon Sep 17 00:00:00 2001 From: rlindgren Date: Mon, 23 Oct 2017 10:07:19 -0400 Subject: [PATCH 018/352] iteratee should be of type AsyncFunction --- types/async/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/async/index.d.ts b/types/async/index.d.ts index 7c32079086..c94c8058c2 100644 --- a/types/async/index.d.ts +++ b/types/async/index.d.ts @@ -174,9 +174,9 @@ export function parallel(tasks: Dictionary>, callback? export function parallelLimit(tasks: Array>, limit: number, callback?: AsyncResultArrayCallback): void; export function parallelLimit(tasks: Dictionary>, limit: number, callback?: AsyncResultObjectCallback): void; export function whilst(test: () => boolean, fn: AsyncVoidFunction, callback: ErrorCallback): void; -export function doWhilst(fn: AsyncVoidFunction, test: (result?: any) => boolean, callback: ErrorCallback): void; +export function doWhilst(fn: AsyncFunction, test: (result?: any) => boolean, callback: ErrorCallback): void; export function until(test: () => boolean, fn: AsyncVoidFunction, callback: ErrorCallback): void; -export function doUntil(fn: AsyncVoidFunction, test: (result?: any) => boolean, callback: ErrorCallback): void; +export function doUntil(fn: AsyncFunction, test: (result?: any) => boolean, callback: ErrorCallback): void; export function during(test: (testCallback : AsyncBooleanResultCallback) => void, fn: AsyncVoidFunction, callback: ErrorCallback): void; export function doDuring(fn: AsyncVoidFunction, test: (testCallback: AsyncBooleanResultCallback) => void, callback: ErrorCallback): void; export function forever(next: (next : ErrorCallback) => void, errBack: ErrorCallback) : void; From 126eac680e28d66b64925cadbead2b3ad9ce49ae Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Tue, 24 Oct 2017 07:45:49 +0200 Subject: [PATCH 019/352] webpack: fix lint issues and remove some deprecated stuff --- types/webpack-stream/index.d.ts | 7 --- types/webpack/index.d.ts | 91 ++------------------------------- 2 files changed, 3 insertions(+), 95 deletions(-) diff --git a/types/webpack-stream/index.d.ts b/types/webpack-stream/index.d.ts index d5cb6186ee..74ff6aef7f 100644 --- a/types/webpack-stream/index.d.ts +++ b/types/webpack-stream/index.d.ts @@ -9,13 +9,6 @@ import * as webpack from 'webpack'; export = webpackStream; -/** - * Run webpack with the specified configuration and webpack instance - * - * @param {webpack.Configuration} config - Webpack configuration - * @param {webpack} wp - A webpack object - * @param {webpack.Compiler.Handler} callback - A callback with the webpack stats and error objects. - */ declare function webpackStream( config?: webpack.Configuration, wp?: typeof webpack, diff --git a/types/webpack/index.d.ts b/types/webpack/index.d.ts index 2ab37cba87..e9323cd4b1 100644 --- a/types/webpack/index.d.ts +++ b/types/webpack/index.d.ts @@ -210,7 +210,7 @@ declare namespace webpack { } type Module = OldModule | NewModule; - interface NewResolve { + interface Resolve { /** * A list of directories to resolve modules from. * @@ -307,71 +307,7 @@ declare namespace webpack { symlinks?: boolean; } - interface OldResolve { - /** Replace modules by other modules or paths. */ - alias?: { [key: string]: string; }; - /** - * The directory (absolute path) that contains your modules. - * May also be an array of directories. - * This setting should be used to add individual directories to the search path. - * - * @deprecated Replaced by `modules` in webpack 2. - */ - root?: string | string[]; - /** - * An array of directory names to be resolved to the current directory as well as its ancestors, and searched for modules. - * This functions similarly to how node finds “node_modules” directories. - * For example, if the value is ["mydir"], webpack will look in “./mydir”, “../mydir”, “../../mydir”, etc. - * - * @deprecated Replaced by `modules` in webpack 2. - */ - modulesDirectories?: string[]; - /** - * A directory (or array of directories absolute paths), - * in which webpack should look for modules that weren’t found in resolve.root or resolve.modulesDirectories. - * - * @deprecated Replaced by `modules` in webpack 2. - */ - fallback?: string | string[]; - /** - * An array of extensions that should be used to resolve modules. - * For example, in order to discover CoffeeScript files, your array should contain the string ".coffee". - */ - extensions?: string[]; - /** - * Check these fields in the package.json for suitable files. - * - * @deprecated Replaced by `mainFields` in webpack 2. - */ - packageMains?: Array; - - /** - * Check this field in the package.json for an object. Key-value-pairs are threaded as aliasing according to this spec - * - * @deprecated Replaced by `aliasFields` in webpack 2. - */ - packageAlias?: Array; - - /** - * Enable aggressive but unsafe caching for the resolving of a part of your files. - * Changes to cached paths may cause failure (in rare cases). An array of RegExps, only a RegExp or true (all files) is expected. - * If the resolved path matches, it’ll be cached. - * - * @deprecated Split into `unsafeCache` and `cachePredicate` in webpack 2. - */ - unsafeCache?: RegExp | RegExp[] | boolean; - } - - type Resolve = OldResolve | NewResolve; - - interface OldResolveLoader extends OldResolve { - /** It describes alternatives for the module name that are tried. - * @deprecated Replaced by `moduleExtensions` in webpack 2. - */ - moduleTemplates?: string[]; - } - - interface NewResolveLoader extends NewResolve { + interface ResolveLoader extends Resolve { /** * List of strings to append to a loader's name when trying to resolve it. */ @@ -380,8 +316,6 @@ declare namespace webpack { enforceModuleExtension?: boolean; } - type ResolveLoader = OldResolveLoader | NewResolveLoader; - type ExternalsElement = string | RegExp | ExternalsObjectElement | ExternalsFunctionElement; interface ExternalsObjectElement { @@ -723,7 +657,7 @@ declare namespace webpack { /** Show which exports of a module are used */ usedExports?: boolean; /** Filter warnings to be shown */ - warningsFilter?: string | string[] | RegExp | RegExp[] | ((warning: string) => boolean); + warningsFilter?: string | RegExp | Array | ((warning: string) => boolean); /** Show performance hint when file size exceeds `performance.maxAssetSize` */ performance?: boolean; /** Show the exports of the modules */ @@ -1091,9 +1025,6 @@ declare namespace webpack { * They only care for metadata. The pitch method on the loaders is called from left to right before the loaders are called (from right to left). * If a loader delivers a result in the pitch method the process turns around and skips the remaining loaders, * continuing with the calls to the more left loaders. data can be passed between pitch and normal call. - * @param remainingRequest - * @param precedingRequest - * @param data */ pitch?(remainingRequest: string, precedingRequest: string, data: any): any | undefined; @@ -1198,13 +1129,11 @@ declare namespace webpack { /** * Emit a warning. - * @param message */ emitWarning(message: string | Error): void; /** * Emit a error. - * @param message */ emitError(message: string | Error): void; @@ -1212,24 +1141,16 @@ declare namespace webpack { * Execute some code fragment like a module. * * Don't use require(this.resourcePath), use this function to make loaders chainable! - * - * @param code - * @param filename */ exec(code: string, filename: string): any; /** * Resolve a request like a require expression. - * @param context - * @param request - * @param callback */ resolve(context: string, request: string, callback: (err: Error, result: string) => void): any; /** * Resolve a request like a require expression. - * @param context - * @param request */ resolveSync(context: string, request: string): string; @@ -1237,7 +1158,6 @@ declare namespace webpack { * Adds a file as dependency of the loader result in order to make them watchable. * For example, html-loader uses this technique as it finds src and src-set attributes. * Then, it sets the url's for those attributes as dependencies of the html file that is parsed. - * @param file */ addDependency(file: string): void; @@ -1245,13 +1165,11 @@ declare namespace webpack { * Adds a file as dependency of the loader result in order to make them watchable. * For example, html-loader uses this technique as it finds src and src-set attributes. * Then, it sets the url's for those attributes as dependencies of the html file that is parsed. - * @param file */ dependency(file: string): void; /** * Add a directory as dependency of the loader result. - * @param directory */ addContextDependency(directory: string): void; @@ -1309,9 +1227,6 @@ declare namespace webpack { /** * Emit a file. This is webpack-specific. - * @param name - * @param content - * @param sourceMap */ emitFile(name: string, content: Buffer | string, sourceMap: any): void; From 7907550eec395490795f831e7cc313f97cc77c48 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Tue, 24 Oct 2017 07:49:45 +0200 Subject: [PATCH 020/352] webpack: fix tests --- types/webpack/webpack-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/webpack/webpack-tests.ts b/types/webpack/webpack-tests.ts index fa24368546..0816416c2c 100644 --- a/types/webpack/webpack-tests.ts +++ b/types/webpack/webpack-tests.ts @@ -234,7 +234,7 @@ configuration = { configuration = { resolve: { - root: __dirname + modules: [__dirname] } }; From 25f6e77505eb95bff2ce5d7c2552e65385929982 Mon Sep 17 00:00:00 2001 From: Kewei Li Date: Tue, 24 Oct 2017 16:55:04 -0700 Subject: [PATCH 021/352] adding Service.Store namespace --- types/winrt-uwp/index.d.ts | 588 +++++++++++++++++++++++++++++++++++++ 1 file changed, 588 insertions(+) diff --git a/types/winrt-uwp/index.d.ts b/types/winrt-uwp/index.d.ts index 02490e6010..ada414474d 100644 --- a/types/winrt-uwp/index.d.ts +++ b/types/winrt-uwp/index.d.ts @@ -48901,6 +48901,594 @@ declare namespace Windows { namespace LocalSearch { } } + + /** Provides types and members you can use to access and manage Windows Store-related data for the current app. */ + namespace Store { + /** Defines values that represent the status of an request that is related to a consumable add-on. */ + enum StoreConsumableStatus { + /** The request did not succeed because the remaining balance of the consumable add-on is too low. */ + insufficentQuantity = 1, + /** The request did not succeed because of a network connectivity error. */ + networkError = 2, + /** The request did not succeed because of a server error returned by the Windows Store. */ + serverError = 3, + /** The request succeeded. */ + succeeded = 0, + } + + /** Defines values that represent the state of a package download or installation request. */ + enum StorePackageUpdateState { + /** The download or installation of the package updates was canceled. */ + canceled = 4, + /** The package updates have finished downloading or installing. */ + completed = 3, + /** The package updates are being deployed to the device. */ + deploying = 2, + /** The package updates are being downloaded. */ + downloading = 1, + /** The download or installation of the package updates did not succeed because the device does not have enough battery power. */ + errorLowBattery = 6, + /** The download did not succeed because a Wi-Fi connection is recommended to download the package updates. */ + errorWiFiRecommended = 7, + /** The download did not succeed because a Wi-Fi connection is required to download the package updates. */ + errorWiFiRequired = 8, + /** An unknown error occurred. */ + otherError = 5, + /** The download of the package updates has not started. */ + pending = 0, + } + + /** Defines values that represent the units of a trial period or billing period for a subscription. */ + enum StoreDurationUnit { + /** The period is defined in days. */ + day = 2, + /** The period is defined in hours. */ + hour = 1, + /** The period is defined in minutes. */ + minute = 0, + /** The period is defined in months. */ + month = 4, + /** The period is defined in weeks. */ + week = 3, + /** The period is defined in years. */ + year = 5, + } + + /** Defines values that represent the status of a request to purchase an app or add-on. */ + enum StorePurchaseStatus { + /** The current user has already purchased the specified app or add-on. */ + alreadyPurchased = 1, + /** The purchase request did not succeed because of a network connectivity error. */ + networkError = 3, + /** The purchase request did not succeed. */ + notPurchased = 2, + /** The purchase request did not succeed because of a server error returned by the Windows Store. */ + serverError = 4, + /** The purchase request succeeded. */ + succeeded = 0, + } + + /** Provides status info for a package that is associated with a download or installation request. */ + interface StorePackageUpdateStatus { + /** The number of bytes that have been downloaded. */ + packageBytesDownloaded: number; + /** The download (or download and install) progress of the current package, represented by a value from 0.0 to 1.0. When you use RequestDownloadStorePackageUpdatesAsync to download packages, this value increases from 0.0 to 1.0 during the download of each package. When you use RequestDownloadAndInstallStorePackageUpdatesAsync to download and install packages in a single operation, this value increases from 0.0 to 0.8 during the download of each package, and then it increases from 0.8 to 1.0 during the install phase. */ + packageDownloadProgress: number; + /** The size of the package that is being downloaded, in bytes. This is an estimate, and it might change during the download process. */ + packageDownloadSizeInBytes: number; + /** The family name of the package that is being downloaded or installed. */ + packageFamilyName: string; + /** A StorePackageUpdateState value that indicates the state of the package that is being downloaded or installed. */ + packageUpdateState: StorePackageUpdateState; + /** The current progress of all package downloads in the request, represented by a value from 0.0 to 1.0. */ + totalDownloadProgress: number; + } + + /** Provides response data for a request to acquire a downloadable content (DLC) package license. */ + abstract class StoreAcquireLicenseResult { + /** Gets the error code for the request, if the operation encountered an error. */ + extendedError: WinRTError; + /** Gets an object that represents the downloadable content (DLC) package license. */ + storePackageLicense: StorePackageLicense; + } + + /** Provides license info for the current app, including licenses for products that are offered by the app. */ + abstract class StoreAppLicense { + /** Gets the collection of licenses for add-ons that can be used offline (typically durable add-ons), for which the user has entitlements to use. This property does not include licenses for consumable add-ons. */ + addOnLicenses: Windows.Foundation.Collections.IMapView; + /** Gets the expiration date and time for the app license. */ + expirationDate: Date; + /** Gets complete license data in JSON format. */ + extendedJsonData: string; + /** Gets a value that indicates whether the license is active. */ + isActive: boolean; + /** Gets a value that indicates whether the license is a trial license. */ + isTrial: boolean; + /** Gets a value that indicates whether the current user has an entitlement for the usage-limited trial that is associated with this app license. */ + isTrialOwnedByThisUser: boolean; + /** Gets the Store ID of the licensed app SKU from the Windows Store catalog. */ + skuStoreId: string; + /** Gets the remaining time for the usage-limited trial that is associated with this app license. */ + trialTimeRemaining: number; + /** Gets a unique ID that identifies the combination of the current user and the usage-limited trial that is associated with this app license. */ + trialUniqueId: string; + } + + /** Represents a specific instance of a product SKU that can be purchased. */ + abstract class StoreAvailability { + /** Gets the end date for the current SKU availability. */ + endDate: Date; + /** Gets complete data for the current SKU availability from the Store in JSON format. */ + extendedJsonData: string; + /** Gets price info for the current SKU availability, including the base price, current price, and sale info. */ + price: StorePrice; + /** + * Requests the purchase of the current SKU availability and displays the UI that is used to complete the transaction via the Windows Store. + * @return An asynchronous operation that, on successful completion, returns a StorePurchaseResult object that provides status and error info about the purchase. + */ + requestPurchaseAsync(): Windows.Foundation.IPromiseWithIAsyncOperation; + /** + * Requests the purchase of the current SKU availability and displays the UI that is used to complete the transaction via the Windows Store. This method provides the option to specify additional details for a specific offer within a large catalog of products that are represented by a single listing in the Windows Store, including the product name to display to the user during the purchase. + * @param {StorePurchaseProperties} storePurchaseProperties An object that specifies additional info for the purchase request, including the product name to display to the user during the purchase. + * @return An asynchronous operation that, on successful completion, returns a StorePurchaseResult object that provides status and error info about the purchase. + */ + requestPurchaseAsync(storePurchaseProperties: StorePurchaseProperties): Windows.Foundation.IPromiseWithIAsyncOperation; + /** Gets the Store ID of the current SKU availability from the Windows Store catalog. */ + storeId: string; + } + + /** Provides additional data for a product SKU that the user has an entitlement to use. */ + abstract class StoreCollectionData { + /** Gets the date on which the product SKU was acquired. */ + acquiredDate: Date; + /** Gets the promotion campaign ID that is associated with the product SKU. */ + campaignId: string; + /** Gets the developer offer ID that is associated with the product SKU. */ + developerOfferId: string; + /** Gets the end date of the trial for the product SKU, if the SKU is a trial version or a durable add-on that expires after a set duration. */ + endDate: Date; + /** Gets complete collection data for the product SKU in JSON format. */ + extendedJsonData: string; + /** Gets a value that indicates whether the product SKU is a trial version. */ + isTrial: boolean; + /** Gets the start date of the trial for the product SKU, if the SKU is a trial version or a durable add-on that expires after a set duration. */ + startDate: Date; + /** Gets the remaining trial time for the product SKU. */ + trialTimeRemaining: number; + } + + /** Provides response data for a request that involves a consumable add-on for the current app. */ + abstract class StoreConsumableResult { + /** Gets the remaining balance for the consumable add-on. */ + balanceRemaining: number; + /** Gets the error code for the request, if the operation encountered an error. */ + extendedError: WinRTError; + /** Gets the status of the request. */ + status: StoreConsumableStatus; + /** Gets the tracking ID that was submitted with the ReportConsumableFulfillmentAsync request. */ + trackingId: string; + } + + /** Provides members you can use to access and manage Windows Store-related data for the current app. For example, you can use members of this class to get Windows Store listing and license info for the current app, purchase the current app or products that are offered by the app, or download and install package updates for the app. */ + abstract class StoreContext { + /** + * Acquires a license for the specified downloadable content (DLC) package for the current app. + * @param optionalPackage The DLC package for which to acquire a license. + * @return An asynchronous operation that, on successful completion, returns a StoreAcquireLicenseResult object that contains the license. + */ + acquireStoreLicenseForOptionalPackageAsync(optionalPackage: Windows.ApplicationModel.Package): Windows.Foundation.IPromiseWithIAsyncOperation; + /** + * Gets Store product details for the app or add-on that is associated with the specified package. + * @param productKinds An array of strings that specify the types of Store products that might be associated with the package. For a list of the supported string values, see the ProductKind property. + * @param package A Package that represents the package for which you want to get the corresponding Store product details. + * @return An asynchronous operation that, on successful completion, returns a StoreProductResult object. Use the Product property of this object to access a StoreProduct that contains Store product details for the specified package. + */ + findStoreProductForPackageAsync(productKinds: Windows.Foundation.Collections.IIterable, package: Windows.ApplicationModel.Package): Windows.Foundation.IPromiseWithIAsyncOperation; + /** + * Gets the collection of packages for the current app that have updates available for download from the Windows Store, including optional packages for the app (also called downloadable content or DLC). + * @return An asynchronous operation that, on successful completion, returns a collection of StorePackageUpdate objects that represent the packages that have updates available. + */ + getAppAndOptionalStorePackageUpdatesAsync(): Windows.Foundation.IPromiseWithIAsyncOperation; + /** + * Gets license info for the current app, including licenses for add-ons for the current app. + * @return An asynchronous operation that, on successful completion, returns a StoreAppLicense object that contains license info for the current app, including add-on licenses. + */ + getAppLicenseAsync(): Windows.Foundation.IPromiseWithIAsyncOperation; + /** + * Gets the list of products that can be purchased from within the current app. + * @param productKinds An array of strings that specify the types of products you want to get. For a list of the supported string values, see the ProductKind property. + * @return An asynchronous operation that, on successful completion, returns a StoreProductQueryResult that provides access to the associated products and relevant error info. + */ + getAssociatedStoreProductsAsync(productKinds: Windows.Foundation.Collections.IIterable): Windows.Foundation.IPromiseWithIAsyncOperation; + /** + * Gets the list of products that can be purchased from within the current app. This method supports paging to return the results. + * @param productKinds An array of strings that specify the types of products you want to get. For a list of the supported string values, see the ProductKind property. + * @param maxItemsToRetrievePerPage The maximum number of products to return in each page of results. + * @return An asynchronous operation that, on successful completion, returns a StoreProductPagedQueryResult that provides access to the associated products, relevant error info, and the next page of results. + */ + getAssociatedStoreProductsWithPagingAsync(productKinds: Windows.Foundation.Collections.IIterable, maxItemsToRetrievePerPage: number): Windows.Foundation.IPromiseWithIAsyncOperation; + /** + * Gets the remaining balance for the specified consumable add-on for the current app. + * @param productStoreId The Store ID for the add-on (as provided by the StoreId property of the StoreProduct that represents the add-on). + * @return An asynchronous operation that, on successful completion, returns a StoreConsumableResult that provides the remaining balance and other info. + */ + getConsumableBalanceRemainingAsync(productStoreId: string): Windows.Foundation.IPromiseWithIAsyncOperation; + /** + * Retrieves a Windows Store collections ID key that can be used to query for product entitlements or to consume product entitlements that are owned by the current user. + * @param serviceTicket An Azure Active Directory access token that identifies the publisher of the current app. For more information about generating this token, see Manage product entitlements from a service. + * @param publisherUserId An anonymous ID that identifies the current user in the context of services that are managed by the publisher of the current app. If the publisher maintains anonymous user IDs for use in their services, they can use this parameter to correlate these user IDs with the calls they make to Windows Store services. This parameter is optional. + * @return An asynchronous operation that, on successful completion, returns the collections ID key for the current user. This key is valid for 90 days. + */ + getCustomerCollectionsIdAsync(serviceTicket: string, publisherUserId?: string): Windows.Foundation.IPromiseWithIAsyncOperation; + /** + * Retrieves a Windows Store purchase ID key that can be used to grant entitlements for free products on behalf of the current user. + * @param serviceTicket An Azure Active Directory access token that identifies the publisher of the current app. For more information about generating this token, see Manage product entitlements from a service. + * @param publisherUserId An anonymous ID that identifies the current user in the context of services that are managed by the publisher of the current app. If the publisher maintains anonymous user IDs for use in their services, they can use this parameter to correlate these user IDs with the calls they make to Windows Store services. This parameter is optional. + * @return An asynchronous operation that, on successful completion, returns the purchase ID key for the current user. This key is valid for 90 days. + */ + getCustomerPurchaseIdAsync(serviceTicket: string, publisherUserId?: string): Windows.Foundation.IPromiseWithIAsyncOperation; + /** + * Gets a StoreContext object that can be used to access and manage Windows Store-related data for the current user in the context of the current app. + * @return An object that you can use to access and manage Windows Store-related data for the current user. + */ + static getDefault(): StoreContext; + /** + * Gets a StoreContext object that can be used to access and manage Windows Store-related data for the specified user in the context of the current app. + * @param user An object that identifies the user whose Windows Store-related data you want to access and manage. + * @return An object that you can use to access and manage Windows Store-related data for the specified user. + */ + static getForUser(user: Windows.System.User): StoreContext; + /** + * Gets Windows Store listing info for the current app and provides access to a method that you can use to purchase the app for the current user. + * @return An asynchronous operation that, on successful completion, returns a StoreProductResult object that contains Windows Store listing info for the current app and any relevant error info. + */ + getStoreProductForCurrentAppAsync(): Windows.Foundation.IPromiseWithIAsyncOperation; + /** + * Gets Windows Store listing info for the specified products that can be purchased from within the current app. + * @param productKinds An array of strings that specify the types of products for which you want to retrieve listing info. For a list of the supported string values, see the ProductKind property. + * @param storeIds An array of the Store ID strings for the products for which you want to retrieve listing info. + * @return An asynchronous operation that, on successful completion, returns a StoreProductQueryResult object that contains Windows Store listing info for the specified products and any relevant error info. + */ + getStoreProductsAsync(productKinds: Windows.Foundation.Collections.IIterable, storeIds: Windows.Foundation.Collections.IIterable): Windows.Foundation.IPromiseWithIAsyncOperation; + /** + * Gets Windows Store info for the add-ons of the current app for which the user has entitlements to use. + * @param productKinds An array of strings that specify the types of add-ons for which you want to retrieve listing info. For a list of the supported string values, see the ProductKind property. + * @return An asynchronous operation that, on successful completion, returns a StoreProductQueryResult object that contains Windows Store listing info for the add-ons of the current app for which the user has entitlements to use. + */ + getUserCollectionAsync(productKinds: Windows.Foundation.Collections.IIterable): Windows.Foundation.IPromiseWithIAsyncOperation; + /** + * Gets Windows Store info for the add-ons of the current app for which the user has entitlements to use. This method supports paging to return the results. + * @param productKinds An array of strings that specify the types of add-ons for which you want to retrieve listing info. For a list of the supported string values, see the ProductKind property. + * @param maxItemsToRetrievePerPage The maximum number of add-ons to return in each page of results. + * @return An asynchronous operation that, on successful completion, returns a StoreProductPagedQueryResult object that provides access to the Windows Store listing info for the add-ons of the current app for which the user has entitlements to use, as well as the next page of results. + */ + getUserCollectionWithPagingAsync(productKinds: Windows.Foundation.Collections.IIterable, maxItemsToRetrievePerPage: number): Windows.Foundation.IPromiseWithIAsyncOperation; + /** Raised when the status of the app's license changes (for example, the trial period has expired or the user has purchased the full version of the app). */ + onofflinelicenseschanged: Windows.Foundation.TypedEventHandler; + /** + * Reports a consumable add-on for the current app as fulfilled in the Windows Store. + * @param productStoreId The Store ID of the consumable add-on that you want to report as fulfilled. + * @param quantity The number of units of the consumable add-on that you want to report as fulfilled. For a Store-managed consumable (that is, a consumable where Microsoft keeps track of the balance), specify the number of units that have been consumed. For a developer-managed consumable (that is, a consumable where the developer keeps track of the balance), specify 1. + * @param trackingId A developer-supplied GUID that identifies the specific transaction that the fulfillment operation is associated with for tracking purposes. For more information, see the remarks. + * @return An asynchronous operation that, on successful completion, returns a StoreConsumableResult object that contains info about the fulfillment operation, such as the remaining balance of add-on units. + */ + reportConsumableFulfillmentAsync(productStoreId: string, quantity: number, trackingId: string): Windows.Foundation.IPromiseWithIAsyncOperation; + /** + * Downloads and installs the specified downloadable content (DLC) packages for the current app from the Windows Store. + * @param storeIds The product IDs of the add-on packages to install. + * @return An object that the caller can observe to track progress and completion for the operation. On successful completion, the result is a StorePackageUpdateResult object that provides info about the package updates. + */ + requestDownloadAndInstallStorePackagesAsync(storeIds: Windows.Foundation.Collections.IIterable): Windows.Foundation.IPromiseWithIAsyncOperationWithProgress; + /** + * Downloads and installs the specified package updates for the current app from the Windows Store. + * @param storePackageUpdates The set of StorePackageUpdate objects that represent the updated packages to download and install. + * @return An object that the caller can observe to track progress and completion for the operation. On successful completion, the result is a StorePackageUpdateResult object that provides info about the package updates. + */ + requestDownloadAndInstallStorePackageUpdatesAsync(storePackageUpdates: Windows.Foundation.Collections.IIterable): Windows.Foundation.IPromiseWithIAsyncOperationWithProgress; + /** + * Downloads the specified package updates for the current app from the Windows Store. + * @param storePackageUpdates The set of StorePackageUpdate objects that represent the updated packages to download. + * @return An object that the caller can observe to track progress and completion for the operation. On successful completion, the result is a StorePackageUpdateResult object that provides info about the package updates. + */ + requestDownloadStorePackageUpdatesAsync(storePackageUpdates: Windows.Foundation.Collections.IIterable): Windows.Foundation.IPromiseWithIAsyncOperationWithProgress; + /** + * Requests the purchase for the specified app or add-on and displays the UI that is used to complete the transaction via the Windows Store. + * @param storeId The Store ID of the app or the add-on that you want to purchase for the current user. + * @return An asynchronous operation that, on successful completion, returns a StorePurchaseResult object that provides status and error info about the purchase. + */ + requestPurchaseAsync(storeId: string): Windows.Foundation.IPromiseWithIAsyncOperation; + /** + * Requests the purchase for the specified app or add-on and displays the UI that is used to complete the transaction via the Windows Store. This method provides the option to specify additional details for a specific offer within a large catalog of products that are represented by a single listing in the Windows Store, including the product name to display to the user during the purchase. + * @param storeId The Store ID of the app or the add-on that you want to purchase for the current user. + * @param storePurchaseProperties An object that specifies additional info for the purchase request, including the product name to display to the user during the purchase. + * @return An asynchronous operation that, on successful completion, returns a StorePurchaseResult object that provides status and error info about the purchase. + */ + requestPurchaseAsync(storeId: string, storePurchaseProperties: StorePurchaseProperties): Windows.Foundation.IPromiseWithIAsyncOperation; + /** Gets an object that provides info about the current user. */ + user: Windows.System.User; + } + + /** Represents an image that is associated with a product listing in the Windows Store. */ + abstract class StoreImage { + /** Gets the caption for the image. */ + caption: string; + /** Gets the height of the image, in pixels. */ + height: number; + /** Gets the tag for the image. */ + imagePurposeTag: string; + /** Gets the URI of the image. */ + uri: Windows.Foundation.Uri; + /** Gets the width of the image, in pixels. */ + width: number; + } + + /** Provides license info for an add-on that is associated with the current app. */ + abstract class StoreLicense { + /** Gets the expiration date and time for the add-on license. */ + expirationDate: Date; + /** Gets complete license data in JSON format. */ + extendedJsonData: string; + /** Gets in the product ID for the add-on. */ + inAppOfferToken: string; + /** Gets a value that indicates whether the add-on license is active. */ + isActive: boolean; + /** Gets the Store ID of the licensed add-on SKU from the Windows Store catalog. */ + skuStoreId: string; + } + + /** Provides license info for a downloadable content (DLC) package for the current app. */ + abstract class StorePackageLicense { + /** Closes and releases any resources used by this StorePackageLicense. */ + close(): void; + /** Gets a value that indicates whether the license is valid. */ + isValid: boolean; + /** Raised when user no longer has rights to the license on the current device (for example, the user has acquired the license on a different device). */ + onlicenselost: Windows.Foundation.TypedEventHandler; + /** Gets the downloadable content (DLC) package that is associated with the license. */ + package: Windows.ApplicationModel.Package; + /** Releases the license for the downloadable content (DLC) package. */ + releaseLicense(): void; + } + + /** Provides info about a package for the current app that has an update available for download from the Windows Store. */ + abstract class StorePackageUpdate { + /** Gets a value that indicates whether the package that has an update available for download from the Windows Store is a mandatory package, as specified by the developer in the Windows Dev Center dashboard. */ + mandatory: boolean; + /** Gets the package that has an update available for download from the Windows Store. */ + package: Windows.ApplicationModel.Package; + } + + /** Provides info about a completed package update request for the current app. */ + abstract class StorePackageUpdateResult { + /** Gets the state of the completed package update request. */ + overallState: StorePackageUpdateState; + /** Gets info about the status of each of the package updates that are associated with the completed request. */ + storePackageUpdateStatuses: Windows.Foundation.Collections.IVectorView; + } + + /** Contains pricing info for a product listing in the Windows Store. */ + abstract class StorePrice { + /** Gets the ISO 4217 currency code for the market of the current user. */ + currencyCode: string; + /** Gets the base price for the product with the appropriate formatting for the market of the current user. */ + formattedBasePrice: string; + /** Gets the purchase price for the product with the appropriate formatting for the market of the current user. */ + formattedPrice: string; + /** Gets the recurring price for the product with the appropriate formatting for the market of the current user, if recurring billing is enabled for this product. */ + formattedRecurrencePrice: string; + /** Gets a value that indicates whether the product is on sale. */ + isOnSale: boolean; + /** Gets the end date for the sale period for the product, if the product is on sale. */ + saleEndDate: Date; + } + + /** Represents a product that is available in the Windows Store. */ + abstract class StoreProduct { + /** Gets the product description from the Windows Store listing. */ + description: string; + /** Gets complete data for the product from the Store in JSON format. */ + extendedJsonData: string; + /** + * Indicates whether any SKU of this product is installed on the current device. This method is intended to be used for products that have downloadable content (DLC). + * @return An asynchronous operation that, on successful completion, returns true if a SKU of this product is installed on the current device; otherwise, false. + */ + getIsAnySkuInstalledAsync(): Windows.Foundation.IPromiseWithIAsyncOperation; + /** Gets a value that indicates whether the product has optional downloadable content (DLC). */ + hasDigitalDownload: boolean; + /** Gets the images from the Windows Store listing for the product. */ + images: Windows.Foundation.Collections.IVectorView; + /** Gets the product ID for this product, if the current StoreProduct represents an add-on. */ + inAppOfferToken: string; + /** Gets a value that indicates whether the current user has an entitlement to use the default SKU of the product. */ + isInUserCollection: boolean; + /** Gets the keywords that are associated with the product in the Windows Dev Center dashboard. This property only applies to StoreProduct objects that represent add-ons. These strings correspond to the value of the Keywords field in the properties page for the add-on in the Windows Dev Center dashboard. */ + keywords: Windows.Foundation.Collections.IVectorView; + /** Gets the language for the data in the Windows Store listing for the product. */ + language: string; + /** Gets the URI to the Windows Store listing for the product. */ + linkUri: Windows.Foundation.Uri; + /** Gets the price for the default SKU and availability for the product. */ + price: StorePrice; + /** Gets the type of the product. These values are currently supported: Application, Game, Consumable, UnmanagedConsumable, and Durable. */ + productKind: string; + /** + * Requests the purchase of the default SKU and availability for the product and displays the UI that is used to complete the transaction via the Windows Store. + * @return An asynchronous operation that, on successful completion, returns a StorePurchaseResult object that provides status and error info about the purchase. + */ + requestPurchaseAsync(): Windows.Foundation.IPromiseWithIAsyncOperation; + /** + * Requests the purchase of the default SKU and availability for the product and displays the UI that is used to complete the transaction via the Windows Store. This method provides the option to specify additional details for a specific offer within a large catalog of products that are represented by a single listing in the Windows Store, including the product name to display to the user during the purchase. + * @param storePurchaseProperties An object that specifies additional info for the purchase request, including the product name to display to the user during the purchase. + * @return An asynchronous operation that, on successful completion, returns a StorePurchaseResult object that provides status and error info about the purchase. + */ + requestPurchaseAsync(storePurchaseProperties: StorePurchaseProperties): Windows.Foundation.IPromiseWithIAsyncOperation; + /** Gets the list of available SKUs for the product. */ + skus: Windows.Foundation.Collections.IVectorView; + /** Gets the Store ID for this product. */ + storeId: string; + /** Gets the product title from the Windows Store listing. */ + title: string; + /** Gets the videos from the Windows Store listing for the product. */ + videos: Windows.Foundation.Collections.IVectorView; + } + + /** Provides response data for a paged request to retrieve details about products that can be purchased from within the current app. */ + abstract class StoreProductPagedQueryResult { + /** Gets the error code for the request, if the operation encountered an error. */ + extendedError: WinRTError; + /** + * Returns the next page of results. To determine if there are more pages of results, use the HasMoreResults property. + * @return An asynchronous operation that, on successful completion, returns a StoreProductPagedQueryResult object that provides the next page of results. + */ + getNextAsync(): Windows.Foundation.IPromiseWithIAsyncOperation; + /** Gets a value that indicates whether there are additional pages of results. To get the next page of results, use the GetNextAsync method. */ + hasMoreResults: boolean; + /** Gets the collection of products returned by the request. */ + products: Windows.Foundation.Collections.IMapView; + } + + /** Provides response data for a request to retrieve details about products that can be purchased from within the current app. */ + abstract class StoreProductQueryResult { + /** Gets the error code for the request, if the operation encountered an error. */ + extendedError: WinRTError; + /** Gets the collection of products returned by the request. */ + products: Windows.Foundation.Collections.IMapView; + } + + /** Provides response data for a request to retrieve details about the current app. */ + abstract class StoreProductResult { + /** Gets the error code for the request, if the operation encountered an error. */ + extendedError: WinRTError; + /** Gets info about the current app. */ + product: StoreProduct; + } + + /** Contains additional details that you can pass to a purchase request for a product, including the product name to display to the user during the purchase. */ + class StorePurchaseProperties { + /** Initializes a new instance of the StorePurchaseProperties class. */ + constructor(); + /** Initializes a new instance of the StorePurchaseProperties class. This overload provides the option to specify the product name that is displayed to the user during the purchase. + * @param name The product name that is displayed to the user during the purchase. + */ + constructor(name: string); + /** Gets or sets a JSON-formatted string that contains extended data to pass with the purchase request to the Windows Store. */ + extendedJsonData: string; + /** Gets or sets the product name that is displayed to the user during the purchase. The specified name appears in the title bar of the purchase UI. */ + name: string; + } + + /** Provides response data for a request to purchase an app or product that is offered by the app. */ + abstract class StorePurchaseResult { + /** Gets the error code for the purchase request, if the operation encountered an error. */ + extendedError: WinRTError; + /** Gets the status of the purchase request. */ + status: StorePurchaseStatus; + } + + /** Provides a helper method that can be used to send requests to the Windows Store for operations that do not yet have a corresponding API available in the Windows SDK. */ + abstract class StoreRequestHelper { + /** + * Sends the specified request to the Windows Store with the provided context and parameters. + * @param context An object that specifies the user for which to perform the operation. If your app is a single-user app (that is, it runs only in the context of the user that launched the app), use the StoreContext.GetDefault method to get a StoreContext object that you can use to send a request that operates in the context of the user. If your app is a multi-user app, use the StoreContext.GetForUser method to get a StoreContext object that you can use to send a request that operates in the context of a specific user. + * @param requestKind A value that identifies the request that you want to send to the Windows Store. + * @param parametersAsJson A JSON-formatted string that contains the arguments to pass to the request. + * @return An asynchronous operation that, on successful completion, returns a StoreSendRequestResult object that provides status and error info about the request. + */ + sendRequestAsync(context: StoreContext, requestKind: number, parametersAsJson: string): Windows.Foundation.IPromiseWithIAsyncOperation; + } + + /** Provides response data for a request that is sent to the Windows Store. */ + abstract class StoreSendRequestResult { + /** Gets the error code for the request, if the operation encountered an error. */ + extendedError: WinRTError; + /** Gets the HTTP status code for the request. */ + httpStatusCode: Windows.Web.Http.HttpStatusCode; + /** Gets the response data for the request. */ + response: string; + } + + /** Provides info for a SKU of a product in the Windows Store. */ + abstract class StoreSku { + /** Gets the availabilities for the current product SKU. Each product SKU can have one or more availabilities that have different prices. */ + availabilities: Windows.Foundation.Collections.IVectorView; + /** Gets the list of Store IDs for the apps or add-ons that are bundled with this product SKU. */ + bundledSkus: Windows.Foundation.Collections.IVectorView; + /** Gets additional data for the current product SKU, if the user has an entitlement to use the SKU. */ + collectionData: StoreCollectionData; + /** Gets the custom developer data string (also called a tag) that contains custom information about the add-on that this product SKU represents. This string corresponds to the value of the Custom developer data field in the properties page for the add-on in the Windows Dev Center dashboard. */ + customDeveloperData: string; + /** Gets the product SKU description from the Windows Store listing. */ + description: string; + /** Gets complete data for the current product SKU from the Store in JSON format. */ + extendedJsonData: string; + /** + * Indicates whether this product SKU is installed on the current device. + * @return An asynchronous operation that, on successful completion, returns true if this product SKU is installed on the current device; otherwise, false. + */ + getIsInstalledAsync(): Windows.Foundation.IPromiseWithIAsyncOperation; + /** Gets the images from the Windows Store listing for the product SKU. */ + images: Windows.Foundation.Collections.IVectorView; + /** Gets a value that indicates whether the current user has an entitlement to use the current product SKU. */ + isInUserCollection: boolean; + /** Gets a value that indicates whether the current product SKU is a subscription with recurring billing. For more information about the subscription, see the SubscriptionInfo property. */ + isSubscription: boolean; + /** Gets a value that indicates whether the current product SKU is a trial SKU. */ + isTrial: boolean; + /** Gets the language for the data in the Windows Store listing for the product SKU. */ + language: string; + /** Gets the price of the default availability for this product SKU. */ + price: StorePrice; + /** + * Requests the purchase of the product SKU and displays the UI that is used to complete the transaction via the Windows Store. + * @return An asynchronous operation that, on successful completion, returns a StorePurchaseResult object that provides status and error info about the purchase. + */ + requestPurchaseAsync(): Windows.Foundation.IPromiseWithIAsyncOperation; + /** + * Requests the purchase of the product SKU and displays the UI that is used to complete the transaction via the Windows Store. This method provides the option to specify additional details for a specific offer within a large catalog of products that are represented by a single listing in the Windows Store, including the product name to display to the user during the purchase. + * @param storePurchaseProperties An object that specifies additional info for the purchase request, including the product name to display to the user during the purchase. + * @return An asynchronous operation that, on successful completion, returns a StorePurchaseResult object that provides status and error info about the purchase. + */ + requestPurchaseAsync(storePurchaseProperties: StorePurchaseProperties): Windows.Foundation.IPromiseWithIAsyncOperation; + /** Gets the Store ID of this product SKU. */ + storeId: string; + /** Gets subscription information for this product SKU, if this product SKU is a subscription with recurring billing. To determine whether this product SKU is a subscription, use the IsSubscription property. */ + subscriptionInfo: StoreSubscriptionInfo; + /** Gets the product SKU title from the Windows Store listing. */ + title: string; + /** Gets the videos from the Windows Store listing for the product SKU. */ + videos: Windows.Foundation.Collections.IVectorView; + } + + /** Provides subscription info for a product SKU that represents a subscription with recurring billing. */ + abstract class StoreSubscriptionInfo { + /** Gets the duration of the billing period for a subscription, in the units specified by the BillingPeriodUnit property. */ + billingPeriod: number; + /** Gets the units of the billing period for a subscription. */ + billingPeriodUnit: StoreDurationUnit; + /** Gets a value that indicates whether the subscription contains a trial period. */ + hasTrialPeriod: boolean; + /** Gets the duration of the trial period for the subscription, in the units specified by the TrialPeriodUnit property. To determine whether the subscription has a trial period, use the HasTrialPeriod property. */ + trialPeriod: number; + /** Gets the units of the trial period for the subscription. */ + trialPeriodUnit: StoreDurationUnit; + } + + /** Represents a video that is associated with a product listing in the Windows Store. */ + abstract class StoreVideo { + /** Gets the caption for the video. */ + caption: string; + /** Gets the height of the video, in pixels. */ + height: number; + /** Gets the preview image that is displayed for the video. */ + previewImage: StoreImage; + /** Gets the URI of the video. */ + uri: Windows.Foundation.Uri; + /** Gets the tag for the video. */ + videoPurposeTag: string; + /** Gets the width of the video, in pixels. */ + width: number; + } + } } /** Provides classes for managing files, folders, and application settings. */ namespace Storage { From e9f19bb876bc919e0e7830395d3f39c01d762fb1 Mon Sep 17 00:00:00 2001 From: Tom Crockett Date: Tue, 24 Oct 2017 17:33:43 -0700 Subject: [PATCH 022/352] Make component constructor props non-optional --- types/react/index.d.ts | 10 +++++----- types/react/test/index.ts | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/types/react/index.d.ts b/types/react/index.d.ts index 77356b922b..7711ba8749 100644 --- a/types/react/index.d.ts +++ b/types/react/index.d.ts @@ -277,7 +277,7 @@ declare namespace React { // tslint:disable-next-line:no-empty-interface interface Component

    extends ComponentLifecycle { } class Component { - constructor(props?: P, context?: any); + constructor(props: P, context?: any); // Disabling unified-signatures to have separate overloads. It's easier to understand this way. // tslint:disable:unified-signatures @@ -327,7 +327,7 @@ declare namespace React { } interface ComponentClass

    { - new (props?: P, context?: any): Component; + new (props: P, context?: any): Component; propTypes?: ValidationMap

    ; contextTypes?: ValidationMap; childContextTypes?: ValidationMap; @@ -336,7 +336,7 @@ declare namespace React { } interface ClassicComponentClass

    extends ComponentClass

    { - new (props?: P, context?: any): ClassicComponent; + new (props: P, context?: any): ClassicComponent; getDefaultProps?(): P; } @@ -347,8 +347,8 @@ declare namespace React { */ type ClassType, C extends ComponentClass

    > = C & - (new (props?: P, context?: any) => T) & - (new (props?: P, context?: any) => { props: P }); + (new (props: P, context?: any) => T) & + (new (props: P, context?: any) => { props: P }); // // Component Specs and Lifecycle diff --git a/types/react/test/index.ts b/types/react/test/index.ts index b9eea759e7..49ce7c697c 100644 --- a/types/react/test/index.ts +++ b/types/react/test/index.ts @@ -262,7 +262,7 @@ class RefComponent extends React.Component { } } -let componentRef: RefComponent | null = new RefComponent(); +let componentRef: RefComponent | null = new RefComponent({}); RefComponent.create({ ref: "componentRef" }); // type of c should be inferred RefComponent.create({ ref: c => componentRef = c }); @@ -609,8 +609,8 @@ if (TestUtils.isElementOfType(emptyElement2, StatelessComponent)) { if (TestUtils.isDOMComponent(container)) { container.getAttribute("className"); -} else if (TestUtils.isCompositeComponent(new ModernComponent())) { - new ModernComponent().props; +} else if (TestUtils.isCompositeComponent(new ModernComponent({ hello: 'hi', foo: 3 }))) { + new ModernComponent({ hello: 'hi', foo: 3 }).props; } // From 73216e2ef23df02103e94adf636d8e71f1bc7d9c Mon Sep 17 00:00:00 2001 From: Tom Crockett Date: Tue, 24 Oct 2017 21:42:28 -0700 Subject: [PATCH 023/352] Propagate non-optional props change to dependent libraries --- types/draft-js/draft-js-tests.tsx | 16 ++++++++++++---- types/jasmine-enzyme/jasmine-enzyme-tests.tsx | 2 +- .../material-ui-pagination-tests.tsx | 2 +- types/material-ui/material-ui-tests.tsx | 2 +- .../react-datepicker/react-datepicker-tests.tsx | 2 +- types/react-dom/test-utils/index.d.ts | 2 +- types/react-lazyload/react-lazyload-tests.tsx | 2 +- .../react-native-material-kit-tests.tsx | 4 ++-- .../react-native-material-ui-tests.tsx | 2 +- .../react-native-modalbox-tests.tsx | 2 +- .../react-native-tab-navigator-tests.tsx | 2 +- .../react-native-vector-icons-tests.tsx | 6 +++--- types/react-onclickoutside/index.d.ts | 2 +- types/react-onsenui/react-onsenui-tests.tsx | 2 +- .../react-redux-toastr-tests.ts | 2 +- .../react-sortable-hoc-tests.tsx | 2 +- types/react-swf/react-swf-tests.ts | 10 ++++++---- 17 files changed, 36 insertions(+), 26 deletions(-) diff --git a/types/draft-js/draft-js-tests.tsx b/types/draft-js/draft-js-tests.tsx index dae23b90ef..87172d9471 100644 --- a/types/draft-js/draft-js-tests.tsx +++ b/types/draft-js/draft-js-tests.tsx @@ -30,7 +30,7 @@ type SyntheticKeyboardEvent = React.KeyboardEvent<{}>; class RichEditorExample extends React.Component<{}, { editorState: EditorState }> { constructor() { - super(); + super({}); const sampleMarkup = 'Bold text, Italic text

    ' + @@ -182,9 +182,17 @@ function getBlockStyle(block: ContentBlock) { } } -class StyleButton extends React.Component<{key: string, active: boolean, label: string, onToggle: (blockType: string) => void, style: string}> { - constructor() { - super(); +interface Props { + key: string + active: boolean + label: string + onToggle: (blockType: string) => void + style: string +} + +class StyleButton extends React.Component { + constructor(props: Props) { + super(props); } onToggle: (event: Event) => void = (event: Event) => { diff --git a/types/jasmine-enzyme/jasmine-enzyme-tests.tsx b/types/jasmine-enzyme/jasmine-enzyme-tests.tsx index 53ee972ed3..6246618d86 100644 --- a/types/jasmine-enzyme/jasmine-enzyme-tests.tsx +++ b/types/jasmine-enzyme/jasmine-enzyme-tests.tsx @@ -254,7 +254,7 @@ describe('toHaveRef', () => { describe('toHaveState', () => { class Fixture extends React.Component { constructor() { - super(); + super({}); this.state = { foo: false, }; diff --git a/types/material-ui-pagination/material-ui-pagination-tests.tsx b/types/material-ui-pagination/material-ui-pagination-tests.tsx index 09246a2646..a7f85d8184 100644 --- a/types/material-ui-pagination/material-ui-pagination-tests.tsx +++ b/types/material-ui-pagination/material-ui-pagination-tests.tsx @@ -18,7 +18,7 @@ interface PagerState { class Pager extends React.Component<{}, PagerState> { constructor() { - super(); + super({}); this.state = { pageIndex: 0 }; diff --git a/types/material-ui/material-ui-tests.tsx b/types/material-ui/material-ui-tests.tsx index 1034d47cad..84b13d2072 100644 --- a/types/material-ui/material-ui-tests.tsx +++ b/types/material-ui/material-ui-tests.tsx @@ -7002,7 +7002,7 @@ class BottomNavigationExample extends Component<{}, { index?: number }> { constructor() { - super(); + super({}); this.state = { index: 0 }; diff --git a/types/react-datepicker/react-datepicker-tests.tsx b/types/react-datepicker/react-datepicker-tests.tsx index 5a29b38149..a92446371d 100644 --- a/types/react-datepicker/react-datepicker-tests.tsx +++ b/types/react-datepicker/react-datepicker-tests.tsx @@ -4,7 +4,7 @@ import DatePicker from 'react-datepicker'; class ReactDatePicker extends React.Component<{}, { startDate: moment.Moment; displayName: string; }> { constructor(props: {}) { - super(); + super(props); this.state = { startDate: moment(), displayName: 'Example' diff --git a/types/react-dom/test-utils/index.d.ts b/types/react-dom/test-utils/index.d.ts index 05362460d4..caa5605ef5 100644 --- a/types/react-dom/test-utils/index.d.ts +++ b/types/react-dom/test-utils/index.d.ts @@ -59,7 +59,7 @@ export interface SyntheticEventData extends OptionalEventProperties { export type EventSimulator = (element: Element | Component, eventData?: SyntheticEventData) => void; export interface MockedComponentClass { - new (): any; + new (props: {}): any; } export interface ShallowRenderer { diff --git a/types/react-lazyload/react-lazyload-tests.tsx b/types/react-lazyload/react-lazyload-tests.tsx index e6f0f9bc81..f673652ef5 100644 --- a/types/react-lazyload/react-lazyload-tests.tsx +++ b/types/react-lazyload/react-lazyload-tests.tsx @@ -7,7 +7,7 @@ interface State { class Normal extends React.Component<{}, State> { constructor() { - super(); + super({}); const arr: string[] = []; for (let i = 0; i < 200; i++) { arr.push(`${i}`); diff --git a/types/react-native-material-kit/react-native-material-kit-tests.tsx b/types/react-native-material-kit/react-native-material-kit-tests.tsx index 4cb415d791..e26abfe5fc 100644 --- a/types/react-native-material-kit/react-native-material-kit-tests.tsx +++ b/types/react-native-material-kit/react-native-material-kit-tests.tsx @@ -141,7 +141,7 @@ class MKRadioButtonTest extends React.Component { radioGroup: MKRadioButton.Group; constructor() { - super(); + super(null); this.radioGroup = new MKRadioButton.Group(); setTheme({radioStyle: { @@ -165,7 +165,7 @@ class MKRadioButtonTest extends React.Component { /// Checkbox class MKCheckboxTest extends React.Component { constructor() { - super(); + super(null); setTheme({checkboxStyle: { fillColor: MKColor.Teal, diff --git a/types/react-native-material-ui/react-native-material-ui-tests.tsx b/types/react-native-material-ui/react-native-material-ui-tests.tsx index 4f875c59a3..4acb9db12e 100644 --- a/types/react-native-material-ui/react-native-material-ui-tests.tsx +++ b/types/react-native-material-ui/react-native-material-ui-tests.tsx @@ -68,7 +68,7 @@ const DialogExample = () => class BottomNavigationExample extends React.Component { constructor() { - super(); + super(null); this.state = { active: 'today' diff --git a/types/react-native-modalbox/react-native-modalbox-tests.tsx b/types/react-native-modalbox/react-native-modalbox-tests.tsx index c8ae1785e7..6a167791f4 100644 --- a/types/react-native-modalbox/react-native-modalbox-tests.tsx +++ b/types/react-native-modalbox/react-native-modalbox-tests.tsx @@ -24,7 +24,7 @@ class Example extends React.Component<{}, State> { modal6: Modal; constructor() { - super(); + super({}); this.state = { isOpen: false, diff --git a/types/react-native-tab-navigator/react-native-tab-navigator-tests.tsx b/types/react-native-tab-navigator/react-native-tab-navigator-tests.tsx index d343a7b84e..18a6ae62ba 100644 --- a/types/react-native-tab-navigator/react-native-tab-navigator-tests.tsx +++ b/types/react-native-tab-navigator/react-native-tab-navigator-tests.tsx @@ -10,7 +10,7 @@ const tabBarImage = 'https://assets-cdn.github.com/images/modules/logos_page/Git class TabTest extends React.Component { constructor() { - super(); + super({}); this.state = { selectedTab: 'home' diff --git a/types/react-native-vector-icons/react-native-vector-icons-tests.tsx b/types/react-native-vector-icons/react-native-vector-icons-tests.tsx index b6adf8d8c6..4e1fe13e8a 100644 --- a/types/react-native-vector-icons/react-native-vector-icons-tests.tsx +++ b/types/react-native-vector-icons/react-native-vector-icons-tests.tsx @@ -43,9 +43,9 @@ class Example extends React.Component { } } -class TabTest extends React.Component { +class TabTest extends React.Component<{}, { selectedTab: string }> { constructor() { - super(); + super({}); this.state = { selectedTab: 'tab1' @@ -85,7 +85,7 @@ class TabTest extends React.Component { class TestCustomIcon extends React.Component { constructor() { - super(); + super({}); } handleButton() { diff --git a/types/react-onclickoutside/index.d.ts b/types/react-onclickoutside/index.d.ts index b342e98529..ad61a418a0 100644 --- a/types/react-onclickoutside/index.d.ts +++ b/types/react-onclickoutside/index.d.ts @@ -26,7 +26,7 @@ export interface OnClickOutProps { export type ComponentConstructor

    = React.ComponentClass

    | React.StatelessComponent

    ; export interface ClickOutComponentClass

    extends React.ComponentClass

    { - new (props?: P, context?: any): React.Component & HandleClickOutside; + new (props: P, context?: any): React.Component & HandleClickOutside; } export default function OnClickOut

    ( diff --git a/types/react-onsenui/react-onsenui-tests.tsx b/types/react-onsenui/react-onsenui-tests.tsx index 33c3e7943c..c3c9486e88 100644 --- a/types/react-onsenui/react-onsenui-tests.tsx +++ b/types/react-onsenui/react-onsenui-tests.tsx @@ -9,7 +9,7 @@ class AppState { interface AppProps {} // tslint:disable-line no-empty-interface export class App extends React.Component { - constructor(props?: AppProps) { + constructor(props: AppProps) { super(props); this.state = new AppState(); } diff --git a/types/react-redux-toastr/react-redux-toastr-tests.ts b/types/react-redux-toastr/react-redux-toastr-tests.ts index f675bf5c78..ac49d2dcdd 100644 --- a/types/react-redux-toastr/react-redux-toastr-tests.ts +++ b/types/react-redux-toastr/react-redux-toastr-tests.ts @@ -18,7 +18,7 @@ function test() { toastr.confirm("Test", { onOk: callback, onCancel: callback }); toastr.error("Error", "Error message"); toastr.info("Info", "Info test", { timeOut: 1000, removeOnHover: true, onShowComplete: callback }); - toastr.success("Test", "Test message", { component: new React.Component() }); + toastr.success("Test", "Test message", { component: new React.Component({}) }); } test(); diff --git a/types/react-sortable-hoc/react-sortable-hoc-tests.tsx b/types/react-sortable-hoc/react-sortable-hoc-tests.tsx index af742734bf..db08db3e0e 100644 --- a/types/react-sortable-hoc/react-sortable-hoc-tests.tsx +++ b/types/react-sortable-hoc/react-sortable-hoc-tests.tsx @@ -50,7 +50,7 @@ class SortableComponent extends React.Component<{}, SortableComponentState> { } public constructor() { - super(); + super({}); this.state = { items: ['Item 1', 'Item 2', 'Item 3', 'Item 4', 'Item 5', 'Item 6'], axis: 'x' diff --git a/types/react-swf/react-swf-tests.ts b/types/react-swf/react-swf-tests.ts index 11c79c9940..ff42eed6f0 100644 --- a/types/react-swf/react-swf-tests.ts +++ b/types/react-swf/react-swf-tests.ts @@ -1,6 +1,8 @@ var version = ReactSWF.getFPVersion(); var isFPVersionSupported = ReactSWF.isFPVersionSupported('5'); -var reactSWF = new ReactSWF(); -reactSWF.props = { - src:'',pluginspage:'',width:20,height:20 -} +var reactSWF = new ReactSWF({ + src:'', + pluginspage:'', + width:20, + height:20, +}); From 59daf53c63d8485f3207e88bd5dcbf3b2ed9531b Mon Sep 17 00:00:00 2001 From: Alec Hill Date: Tue, 24 Oct 2017 13:41:09 +0000 Subject: [PATCH 024/352] Updated react-responsive types to v3.0 - also addresses issue https://github.com/DefinitelyTyped/DefinitelyTyped/issues/20656 --- types/react-responsive/index.d.ts | 143 ++++++++++-------- .../react-responsive-tests.tsx | 101 ++++++++++++- types/react-responsive/tsconfig.json | 7 +- types/react-responsive/tslint.json | 3 + types/react-responsive/v1/index.d.ts | 65 ++++++++ .../v1/react-responsive-tests.tsx | 42 +++++ types/react-responsive/v1/tsconfig.json | 33 ++++ 7 files changed, 328 insertions(+), 66 deletions(-) create mode 100644 types/react-responsive/tslint.json create mode 100644 types/react-responsive/v1/index.d.ts create mode 100644 types/react-responsive/v1/react-responsive-tests.tsx create mode 100644 types/react-responsive/v1/tsconfig.json diff --git a/types/react-responsive/index.d.ts b/types/react-responsive/index.d.ts index 2b9a37839f..dde02d8dae 100644 --- a/types/react-responsive/index.d.ts +++ b/types/react-responsive/index.d.ts @@ -1,65 +1,90 @@ -// Type definitions for react-responsive 1.1.3 +// Type definitions for react-responsive 3.0 // Project: https://github.com/contra/react-responsive // Definitions by: Alexey Svetliakov +// Alec Hill +// Javier Gonzalez // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.4 -declare module "react-responsive" { - import * as React from "react"; - - namespace MediaQuery { - export interface MediaQueryProps { - query?: string; - // matchers - orientation?: "portrait" | "landscape"; - scan?: "progressive" | "interlace"; - aspectRatio?: string; - deviceAspectRatio?: string; - height?: number | string; - deviceHeight?: number | string; - width?: number | string; - deviceWidth?: number | string; - color?: boolean; - colorIndex?: boolean; - monochrome?: boolean; - resolution?: number | string; - // types - minAspectRatio?: string; - maxAspectRatio?: string; - minDeviceAspectRatio?: string; - maxDeviceAspectRatio?: string; - minHeight?: number | string; - maxHeight?: number | string; - minDeviceHeight?: number | string; - maxDeviceHeight?: number | string; - minDeviceWidth?: number | string; - maxDeviceWidth?: number | string; - minWidth?: number | string; - maxWidth?: number | string; - minColor?: number; - maxColor?: number; - minColorIndex?: number; - maxColorIndex?: number; - minMonochrome?: number; - maxMonochrome?: number; - minResolution?: number | string; - maxResolution?: number | string; - // types - all?: boolean; - grid?: boolean; - aural?: boolean; - braille?: boolean; - handheld?: boolean; - print?: boolean; - projection?: boolean; - screen?: boolean; - tty?: boolean; - tv?: boolean; - embossed?: boolean; - } - } - - class MediaQuery extends React.Component { } - export = MediaQuery; +import * as React from "react"; +export interface MediaQueryTypes { + all?: boolean; + grid?: boolean; + aural?: boolean; + braille?: boolean; + handheld?: boolean; + print?: boolean; + projection?: boolean; + screen?: boolean; + tty?: boolean; + tv?: boolean; + embossed?: boolean; } + +export type MediaQueryType = keyof MediaQueryTypes; + +export interface MediaQueryMatchers { + aspectRatio?: string; + deviceAspectRatio?: string; + height?: number | string; + deviceHeight?: number | string; + width?: number | string; + deviceWidth?: number | string; + color?: boolean; + colorIndex?: boolean; + monochrome?: boolean; + resolution?: number | string; + orientation?: 'portrait' | 'landscape'; + scan?: 'progressive' | 'interlace'; + type?: MediaQueryType; +} + +export interface MediaQueryFeatures extends MediaQueryMatchers { + minAspectRatio?: string; + maxAspectRatio?: string; + + minDeviceAspectRatio?: string; + maxDeviceAspectRatio?: string; + + minHeight?: number | string; + maxHeight?: number | string; + + minDeviceHeight?: number | string; + maxDeviceHeight?: number | string; + + minWidth?: number | string; + maxWidth?: number | string; + + minDeviceWidth?: number | string; + maxDeviceWidth?: number | string; + + minColor?: number; + maxColor?: number; + + minColorIndex?: number; + maxColorIndex?: number; + + minMonochrome?: number; + maxMonochrome?: number; + + minResolution?: number | string; + maxResolution?: number | string; +} + +export interface MediaQueryAllQueryable extends MediaQueryFeatures, MediaQueryTypes {} + +export interface MediaQueryProps extends MediaQueryAllQueryable { + component?: string | React.SFC | React.ClassType | React.ComponentClass; + query?: string; + style?: React.CSSProperties; + className?: string; + children?: React.ReactNode | ((matches: boolean) => React.ReactNode); + values?: Partial; + onBeforeChange?: (matches: boolean) => void; + onChange?: (matches: boolean) => void; +} + +declare class MediaQuery extends React.Component { } +export function toQuery(matchers: Partial): string; +export default MediaQuery; diff --git a/types/react-responsive/react-responsive-tests.tsx b/types/react-responsive/react-responsive-tests.tsx index 28f8f39c30..3445a8d1cf 100644 --- a/types/react-responsive/react-responsive-tests.tsx +++ b/types/react-responsive/react-responsive-tests.tsx @@ -1,7 +1,9 @@ import * as React from "react"; -import * as MediaQuery from "react-responsive"; +import MediaQuery, { + toQuery +} from "react-responsive"; -class Test extends React.Component { +class QueryTests extends React.Component { render() { return (

    @@ -37,6 +39,99 @@ class Test extends React.Component {
    - ) + ); } } + +const ChildrenPropTest: React.SFC = ({ children }) => ; + +class PropsTests extends React.Component { + render() { + return ( +
    + +
  • Item 1
  • +
  • Item 2
  • +
    + +
  • Item 1
  • +
  • Item 2
  • +
    + +
  • Item 1
  • +
  • Item 2
  • +
    + +
    Wrapped
    +
    Content
    +
    + + uppercase me! + + + Values supplied for SSR + +
    + ); + } +} + +class FunctionChildrenTest extends React.Component { + render() { + return ( + + {(matches: boolean) => { + if (matches) { + return
    Media query matches!
    ; + } else { + return
    Media query does not match!
    ; + } + }} +
    + ); + } +} + +class CallbackTest extends React.Component { + onBeforeChange = (matches: boolean): void => { + if (matches) { + // do something + } + } + + onChange = (matches: boolean): void => { + if (matches) { + // do something else + } + } + + render() { + return ( + + Media query matches! + + ); + } +} + +const queryStrTest: string = toQuery({ + type: 'print', + screen: true, + minHeight: 666 +}); diff --git a/types/react-responsive/tsconfig.json b/types/react-responsive/tsconfig.json index 61a49072b7..294f0c8cde 100644 --- a/types/react-responsive/tsconfig.json +++ b/types/react-responsive/tsconfig.json @@ -2,12 +2,11 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6", - "dom" + "es6" ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ @@ -22,4 +21,4 @@ "index.d.ts", "react-responsive-tests.tsx" ] -} \ No newline at end of file +} diff --git a/types/react-responsive/tslint.json b/types/react-responsive/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/react-responsive/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/react-responsive/v1/index.d.ts b/types/react-responsive/v1/index.d.ts new file mode 100644 index 0000000000..2b9a37839f --- /dev/null +++ b/types/react-responsive/v1/index.d.ts @@ -0,0 +1,65 @@ +// Type definitions for react-responsive 1.1.3 +// Project: https://github.com/contra/react-responsive +// Definitions by: Alexey Svetliakov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +declare module "react-responsive" { + import * as React from "react"; + + namespace MediaQuery { + export interface MediaQueryProps { + query?: string; + // matchers + orientation?: "portrait" | "landscape"; + scan?: "progressive" | "interlace"; + aspectRatio?: string; + deviceAspectRatio?: string; + height?: number | string; + deviceHeight?: number | string; + width?: number | string; + deviceWidth?: number | string; + color?: boolean; + colorIndex?: boolean; + monochrome?: boolean; + resolution?: number | string; + // types + minAspectRatio?: string; + maxAspectRatio?: string; + minDeviceAspectRatio?: string; + maxDeviceAspectRatio?: string; + minHeight?: number | string; + maxHeight?: number | string; + minDeviceHeight?: number | string; + maxDeviceHeight?: number | string; + minDeviceWidth?: number | string; + maxDeviceWidth?: number | string; + minWidth?: number | string; + maxWidth?: number | string; + minColor?: number; + maxColor?: number; + minColorIndex?: number; + maxColorIndex?: number; + minMonochrome?: number; + maxMonochrome?: number; + minResolution?: number | string; + maxResolution?: number | string; + // types + all?: boolean; + grid?: boolean; + aural?: boolean; + braille?: boolean; + handheld?: boolean; + print?: boolean; + projection?: boolean; + screen?: boolean; + tty?: boolean; + tv?: boolean; + embossed?: boolean; + } + } + + class MediaQuery extends React.Component { } + export = MediaQuery; + +} diff --git a/types/react-responsive/v1/react-responsive-tests.tsx b/types/react-responsive/v1/react-responsive-tests.tsx new file mode 100644 index 0000000000..28f8f39c30 --- /dev/null +++ b/types/react-responsive/v1/react-responsive-tests.tsx @@ -0,0 +1,42 @@ +import * as React from "react"; +import * as MediaQuery from "react-responsive"; + +class Test extends React.Component { + render() { + return ( +
    +
    Device Test!
    + +
    You are a desktop or laptop
    + +
    You also have a huge screen
    +
    + +
    You are sized like a tablet or mobile phone though
    +
    +
    + +
    You are a tablet or mobile phone
    +
    + +
    You are portrait
    +
    + +
    You are landscape
    +
    + +
    You are retina
    +
    + +
    You are a desktop or laptop
    + +
    You also have a huge screen
    +
    + +
    You are sized like a tablet or mobile phone though
    +
    +
    +
    + ) + } +} diff --git a/types/react-responsive/v1/tsconfig.json b/types/react-responsive/v1/tsconfig.json new file mode 100644 index 0000000000..774fd47a00 --- /dev/null +++ b/types/react-responsive/v1/tsconfig.json @@ -0,0 +1,33 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "types": [], + "paths": { + "react-responsive": [ + "react-responsive/v1" + ], + "react-responsive/*": [ + "react-responsive/v1/*" + ] + }, + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react" + }, + "files": [ + "index.d.ts", + "react-responsive-tests.tsx" + ] +} From 5846c7a080bc00658fcff6665552f245a1b53d8f Mon Sep 17 00:00:00 2001 From: Janeene Beeforth Date: Mon, 16 Oct 2017 00:04:46 +1100 Subject: [PATCH 025/352] Update to react-bootstrap-table version 4.0.6 * Add v2 directory with the previous 2.8 types. * Updated onCellEdit test to match library functionality. The onCellEdit function was altered in version 2.4.3 to require returning the final cell value from the function. This permits altering the value before it gets saved. * Many options were missing, or their values were out of date. * Add a lot of new tests based on example code in react-bootstrap-table. * Remove the rule overrides in tslint for version 4.0.6 * Remove newly-forbidden @type & @memberof JSDoc tags. --- types/react-bootstrap-table/index.d.ts | 2610 ++++++++++++++--- .../react-bootstrap-table-tests.tsx | 1397 ++++++++- types/react-bootstrap-table/tslint.json | 9 +- types/react-bootstrap-table/v2/index.d.ts | 758 +++++ .../v2/react-bootstrap-table-tests.tsx | 175 ++ types/react-bootstrap-table/v2/tsconfig.json | 30 + types/react-bootstrap-table/v2/tslint.json | 10 + 7 files changed, 4607 insertions(+), 382 deletions(-) create mode 100644 types/react-bootstrap-table/v2/index.d.ts create mode 100644 types/react-bootstrap-table/v2/react-bootstrap-table-tests.tsx create mode 100644 types/react-bootstrap-table/v2/tsconfig.json create mode 100644 types/react-bootstrap-table/v2/tslint.json diff --git a/types/react-bootstrap-table/index.d.ts b/types/react-bootstrap-table/index.d.ts index 66f3f8786a..fc48ef0009 100644 --- a/types/react-bootstrap-table/index.d.ts +++ b/types/react-bootstrap-table/index.d.ts @@ -1,66 +1,207 @@ -// Type definitions for react-bootstrap-table 2.6 +// Type definitions for react-bootstrap-table 4.0 // Project: https://github.com/AllenFang/react-bootstrap-table -// Definitions by: Frank Laub , Aleksander Lode , Josué Us +// Definitions by: Frank Laub , +// Aleksander Lode , +// Josué Us +// Janeene Beeforth // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -/// - // documentation taken from http://allenfang.github.io/react-bootstrap-table/docs.html -import { ComponentClass, Props, ReactElement } from 'react'; -import { EventEmitter } from 'events'; +import { Component, CSSProperties, Props, ReactElement, SyntheticEvent } from 'react'; + +/** + * Row Keys type. Used as the unique primary index for a row. + * This should be either a string or a number. + */ +export type RowKey = T; + +/** + * Cell value type. + */ +export type Cell = T; + +/** + * Row type. This should be an object. + */ +export type Row = T; + +/** + * Table scroll position. + */ +export type ScrollPosition = 'Top' | 'Bottom'; + +/** + * Row selection mode. Single selection = 'radio', multiple selection = 'checkbox'. + */ +export type SelectRowMode = 'none' | 'radio' | 'checkbox'; + +/** + * Sort Order values. 'asc' = ascending, 'desc' = descending. + */ +export type SortOrder = 'asc' | 'desc'; + +/** + * Type of selection for cell editing. + */ +export type CellEditClickMode = 'none' | 'click' | 'dbclick'; + +/** + * Tell react-bootstrap-table how to trigger expanding by clicking on 'row' or 'column' level. + * If the value is 'column', by default all the columns are expandable. If you want to specify some columns as + * unexpandable, check expandable. + * Default is 'row'. + */ +export type ExpandBy = 'row' | 'column'; + +/** + * Used to specify whether a dropdown button should use 'dropup' mode or 'dropdown' mode. + * Default is usually 'dropdown'. + */ +export type DropDirection = 'dropdown' | 'dropup'; + +/** + * List of valid filter types. + * Note: ArrayFilter can only be used as part of the FilterData passed to the BootstrapTable.handleFilterData + * function. It is NOT valid for use when specifying a filter to the TableHeaderColumn filter properties. + */ +export type FilterType = + | 'TextFilter' + | 'RegexFilter' + | 'SelectFilter' + | 'NumberFilter' + | 'DateFilter' + | 'CustomFilter' + | 'ArrayFilter'; + +/** + * Filter conditions that can be used with TextFilter/SelectFilter/RegexFilter filters. + */ +export type FilterCondition = 'eq' | 'like'; + +/** + * Filter comparators used for NumberFilter/DateFilter filters + */ +export type FilterComparator = '=' | '<' | '<=' | '>' | '>=' | '!='; + +/** + * Element type to use for editing a particular column's cells. + */ +export type EditCellType = 'textarea' | 'select' | 'checkbox' | 'datetime'; + +/** + * Position to show the Pagination Panel. Options are above the table ('top'), below the table ('bottom'), or both + * above and below the table ('both'). + */ +export type PaginationPostion = 'top' | 'bottom' | 'both'; + +/** + * Result type for validation when editing. + */ +export type EditValidatorType = 'success' | 'error'; + +/** + * Used to specify the text alignment for a column. + */ +export type DataAlignType = 'left' | 'center' | 'right' | 'start' | 'end'; + +/** + * Boostrap version number. + */ +export type BootstrapVersion = '3' | '4'; + +/** + * CSV Field types supported. + */ +export type CSVFieldType = 'string' | 'number'; + +/** + * Custom attributes for a column/cell/etc. + * Example: { 'data-attr': 'test' } + */ +export interface CustomAttrs { + [attrKey: string]: string | number | boolean; +} + +/** + * Size per page list definition + */ +export type SizePerPageList = number[] | Array<{ text: string, value: number }>; /** * Interface spec for sepcifying functionality to handle remotely * * Consult [documentation](https://allenfang.github.io/react-bootstrap-table/docs.html#remote) * for more info - * */ export interface RemoteObjSpec { - /** If set, cell edits will be handled remotely */ + /** + * If set, cell edits will be handled remotely + */ cellEdit?: boolean; - /** If set insertions will be handled remotely */ + /** + * If set insertions will be handled remotely + */ insertRow?: boolean; - /** If set deletion will be handled remotely */ + /** + * If set deletion will be handled remotely + */ dropRow?: boolean; - /** If set filters will be handled remotely */ + /** + * If set filters will be handled remotely + */ filter?: boolean; - /** If set search will be handled remotely */ + /** + * If set search will be handled remotely + */ search?: boolean; - /** If set, exporting CSV will be handled remotely */ + /** + * If set, exporting CSV will be handled remotely + */ exportCSV?: boolean; - /** If set sorting will be handled remotely */ + /** + * If set sorting will be handled remotely + */ sort?: boolean; - /** If set pagination will be handled remotely */ + /** + * If set pagination will be handled remotely + */ pagination?: boolean; } export interface BootstrapTableProps extends Props { /** - * Set version='4' to use bootstrap@4, else bootstrap@3 is used. + * Bootstrap version to use, values include '3' or '4'. Defaults to '3'. */ - version?: string; + version?: BootstrapVersion; /** * Use data to specify the data that you want to display on table. */ - data: any[]; + data: Array>; /** - * If set, data is remote (use also fetchInfo) + * Normally, react-bootstrap-table handles all the data sorting/filtering/pagination/etc itself internally. + * If this is true, you need to handle all of those manually outside the table. By default it is false. + * This is used mostly with an external/central data store, for example Redux or a database that returns + * already filtered/sorted/paged data. + * + * If a function given, which means you can choose which functionality should be handled with remote or not.Currently, + * we have following functionality you can control: sort, pagination, cellEdit, insertRow, dropRow, filter, search, + * exportCSV. */ - remote?: ((remobeObj: RemoteObjSpec) => RemoteObjSpec) | boolean; // Updated to support ^3.0.0 + remote?: boolean | ((remobeObj: RemoteObjSpec) => RemoteObjSpec); /** * Use keyField to tell table which column is unique. This is same as isKey in - * Tips: You need choose one configuration to set key field: keyField or isKey in + * Tips: react-bootstrap-table support data manipulation(CRUD) so that we need to fetch correct row by a unique column. + * You need choose one of configuration to set the key field: isKey or keyField in . */ keyField?: string; /** - * Use height to set the height of table, default is 100%. + * Use height to set the height of table, default is 100%. The string needs to have a unit, e.g. 'px', '%'. */ height?: string; /** - * Set the max column width (pixels) + * Set the maximum height of table. You need give a string with an unit(px) value like height. */ maxHeight?: string; /** @@ -88,19 +229,19 @@ export interface BootstrapTableProps extends Props { * If a string given, means the value will be presented as the row class. * If a function given, will pass rowData and rowIndex as params and should return string for presenting class. for examples: * @example - * function trClassFormat(rowData,rowIndex){ - * return rowIndex%2==0?"tr-odd":"tr-even"; //return a class name. - * } + * function trClassFormat(rowData,rowIndex) { + * return rowIndex % 2 == 0 ? "tr-odd" : "tr-even"; // return a class name. + * } */ - trClassName?: string | ((rowData: any, rowIndex: number) => string); + trClassName?: string | ((rowData: Row, rowIndex: number) => string); /** * Enable row insertion by setting insertRow to true, default is false. - * If you enable row insertion, there's a button on the upper left side of table. + * If you enable row insertion, there's a button on the upper left side of table. */ insertRow?: boolean; /** * Enable row deletion by setting deleteRow to true, default is false. - * If you enable row deletion, there's a button on the upper left side of table. + * If you enable row deletion, there's a button on the upper left side of table. */ deleteRow?: boolean; /** @@ -118,8 +259,8 @@ export interface BootstrapTableProps extends Props { */ searchPlaceholder?: string; /** - * Enable strict search, default is false. - * More info here: https://github.com/AllenFang/react-bootstrap-table/issues/1199 + * Strict search. Set this flag to apply search terms so that only rows that contain ALL terms are included in the + * search results. */ strictSearch?: boolean; /** @@ -130,15 +271,101 @@ export interface BootstrapTableProps extends Props { multiColumnSearch?: boolean; /** * Enable export csv function, default is false. - * If you enable, there's a button on the upper left side of table. + * If you enable, there's a button on the upper left side of table. */ exportCSV?: boolean; /** * Set CSV filename (e.g. items.csv). Default is spreadsheet.csv */ - csvFileName?: () => string | string; + csvFileName?: string | (() => string); /** - * Enable row selection on table. selectRow accept an object which have the following properties + * If true, it will hide the pagination if there is only one page, default is false. + */ + ignoreSinglePage?: boolean; + /** + * Specify a fix position for the vertical bar if it exist. Available is a number or Top and Bottom + */ + scrollTop?: number | ScrollPosition; + /** + * Add css styles to the react-bs-table-container class. + * For example: containerStyle={ { background: '#00ff00' } } + */ + containerStyle?: CSSProperties; + /** + * Add css styles to the react-bs-table class. + */ + tableStyle?: CSSProperties; + /** + * Add css styles to the react-bs-container-header class. + */ + headerStyle?: CSSProperties; + /** + * Add css styles to the react-bs-container-body class. + */ + bodyStyle?: CSSProperties; + /** + * Add your own class names on the react-bs-table-container class + */ + containerClass?: string; + /** + * Add your own class names on the react-bs-table class + */ + tableContainerClass?: string; + /** + * Add your own class names on the react-bs-container-header class + */ + headerContainerClass?: string; + /** + * Add your own class names on the react-bs-container-body class + */ + bodyContainerClass?: string; + /** + * react-bootstrap-table separate two table element as header and body. + * The tableHeaderClass is for the table element in the header + */ + tableHeaderClass?: string; + /** + * react-bootstrap-table separate two table element as header and body. + * The tableBodyClass is for the table element in the body + */ + tableBodyClass?: string; + /** + * Tell react-bootstrap-table which rows are able to expand. This prop accepts + * a callback function and is suppose to be return an Array of row keys. + * expandableRow is always used with expandComponent, both of props are enable + * the expand row functionality on table. + */ + expandableRow?(row: Row): boolean; + /** + * Tell react-bootstrap-table what's content should be rendered in the expanding + * content. This props accept a callback function and is suppose to be return JSX + * or String. + * expandComponent is always used with expandableRow, both of props are enable + * the expand row functionality on table. + */ + expandComponent?(row: Row): string | ReactElement; + /** + * Assign some alternative options for expand row feature, expandColumnOptions + * only have four available property currently. + */ + expandColumnOptions?: ExpandColumnOptions; + /** + * Enable the multi sort on table and the number value is means max number of sorting column. + */ + multiColumnSort?: number; + /** + * This prop will enable/disable the keyboard navigation cell by cell on table. This is new + * feature from 3.0.0. Default is false. You can have a basic and simple keyboard navigation + * feature on table by enabling keyBoardNav on BootstrapTable. For the usage of keyboard + * navigation is you can click any cell to focus in or use ⬅ ⬆ ⬇ ➡ to natigate the cell. + * + * But if you want more advance features for keyboard navigation or to integrate with cell + * editing, expand row or selection row, you may get interested to see how they work well + * together: In the advance cases, you need to configure keyBoardNav as an object. + */ + keyBoardNav?: boolean | KeyboardNavigation; + /** + * Enable row selection on table. SelectRow accept an object. */ selectRow?: SelectRow; /** @@ -149,51 +376,119 @@ export interface BootstrapTableProps extends Props { * For some options setting on this component, you can set the options attribute and give an object which contain following properties */ options?: Options; + /** + * Used to specify the total number of rows (matching current filter/sort/size per page) in a remote data source. + * Documented in examples, but missing from the main docs. Essential for remote data pagination calculations. + */ fetchInfo?: FetchInfo; - printable?: boolean; - tableStyle?: any; - containerStyle?: any; - headerStyle?: any; - bodyStyle?: any; - ignoreSinglePage?: boolean; - containerClass?: string; - tableContainerClass?: string; - headerContainerClass?: string; - bodyContainerClass?: string; - expandableRow?: (row: any) => boolean; - expandComponent?: (row: any) => any; + /** + * Automatically collapses open rows when doing a sort/filter/search action if those options have been specified. + * Is an object with three possible fields: sort, filter, search. Each field is a flag to specify whether that + * action type should cause expanded rows to close. All three fields default to false. + */ + autoCollapse?: { + sort?: boolean; + filter?: boolean; + search?: boolean; + }; + /** + * Set a style to be used for the table rows. + */ + trStyle?: CSSProperties; + /** + * Disable the automatic tabIndex for navigating between cells. This can be useful if you have a page with multiple + * tables on the page, to stop the tab moving to another table. Default is false. + */ + withoutTabIndex?: boolean; + /** + * Disable writing the header row when exporting to a CSV file. + */ + excludeCSVHeader?: boolean; + /** + * Add a footer to the table. + */ + footer?: boolean; + /** + * Data for the table footer. Format is an array of footer rows, each containing an array of column footer data. + */ + footerData?: FooterData[][]; + /** + * Table footer custom class + */ + tableFooterClass?: string; } -export type SelectRowMode = 'none' | 'radio' | 'checkbox'; +/** + * Footer Data for a column. + */ +export interface FooterData { + /** + * Title to display for the column footer + */ + label: string; + /** + * Index for the column that this footer belongs to + */ + columnIndex: number; + /** + * Text alignment for the data in this footer. + */ + align?: DataAlignType; + /** + * Formatting function for the data in this footer. Used to be able to do things like sum the contents of this + * column in the table so that the footer can be used for totals, etc. + * + * The output value from the formatter function will be used instead of the label if the formatter function is + * defined. + */ + formatter?(tableData: Array>): string | number | ReactElement; +} export interface SelectRow { /** - * For specifing the selection is single(radio) or multiple(checkbox). + * Specify whether the selection column uses single(radio) or multiple(checkbox) selection modes. Required. */ mode: SelectRowMode; /** - * Click the row will trigger selection on that row if enable clickToSelect, default is false. + * If true, clicking the row will trigger selection on that row, default is false. */ clickToSelect?: boolean; /** - * If true, click the row will trigger selection on that row and also trigger cell editing if you enabled cell edit. Default is false. + * If true, clicking the row will trigger selection on that row and also trigger cell editing if you enabled cell edit. Default is false. */ clickToSelectAndEditCell?: boolean; /** - * You can assign the background color of row which be selected. + * If true, clicking the row will trigger expanding the row. Default is false. */ - bgColor?: string; + clickToExpand?: boolean; /** - * You can assign the class name of row which be selected. + * You can assign the background color of row which be selected. + * If your requirement is much complex, you can assign a function to bgColor that + * returns a css color string. */ - className?: string; + bgColor?: string | ((row: Row, isSelect: boolean) => string); + /** + * You can change the width of the selection column by columnWidth (include units). + */ + columnWidth?: string; + /** + * You can assign the class name of selected rows. This can either be a string, or a function that takes two + * arguments: row and isSelect. + * `row`: The current row data. + * `isSelect`: Flag indicating whether this particular row is selected. + */ + className?: string | ((row: Row, isSelect: boolean) => string); /** * Give an array data to perform which rows you want to be selected when table loading. - * The content of array should be the rowkey which you want to be selected. + * The content of array should be the rowkeys for the rows that you want to be selected. */ - selected?: string[] | number[]; + selected?: Array>; /** - * if true, the radio/checkbox column will be hide. + * Provide a list of unselectable row keys. + */ + unselectable?: Array>; + /** + * If true, the radio/checkbox column will be hidden. * You can enable this attribute if you enable clickToSelect and you don't want to show the selection column. */ hideSelectColumn?: boolean; @@ -203,282 +498,635 @@ export interface SelectRow { showOnlySelected?: boolean; /** * Accept a custom callback function, if a row be selected or unselected, this function will be called. - * This callback function taking three arguments row, isSelected and event: - * `row`: is the row data which you wanted to select or unselect. - * `isSelected`: it's a boolean value means "whether or not that row will be selected?". - * `event`: The event target object. - * If return value of this (function) is false, the select or deselect action will not be applied. + * This callback function takes four arguments: row, isSelected, event, and rowIndex: + * `row`: is the row data which you wanted to select or unselect. + * `isSelected`: it's a boolean value means "whether or not that row will be selected?". + * `event`: The event target object. + * `rowIndex`: the index number for the row. + * If the return value of this (function) is false, the select or deselect action will not be applied. */ - onSelect?: (row: any, isSelected: boolean, event: any) => boolean; + onSelect?(row: Row, isSelected: boolean, event: any, rowIndex: number): boolean | void; /** - * Accept a custom callback function, if click select all checkbox, this function will be called. - * This callback function taking two arguments isSelected and currentSelectedAndDisplayData: - * `isSelected`: it's a boolean value means "whether or not that row will be selected?". - * `currentSelectedAndDisplayData`: If pagination enabled, this result is the data which in a page. In contrast, this is all data in table. - * If return value of this function is false, the select all or deselect all action will not be applied. + * Accept a custom callback function, if click select all checkbox, this function will be called. This callback + * function taking two arguments: isSelected, rows. + * isSelectedis a boolean value which means "whether or not that row will be selected?". + * rows is the rows which be selected or unselected. + * + * Tips: + * If the return value of this function is false, the select all or deselect all action will not be applied. + * If return value of this function is an array of rowkeys, this array will be applied as selection row when + * select all triggers. It's useful when you have a validation to filter some rows on selecting all. */ - onSelectAll?: (isSelected: boolean, currentSelectedAndDisplayData: any) => boolean; - + onSelectAll?(isSelected: boolean, rows: Array>): boolean | Array>; /** - * Provide a list of unselectable row keys. + * Function that returns a component to customize the display of the selection checkbox or radio button with. */ - unselectable?: number[]; + customComponent?(props: CustomSelectProps): string | ReactElement; + /** + * Only unselect visible rows. + */ + onlyUnselectVisible?: boolean; } -export type CellEditClickMode = 'none' | 'click' | 'dbclick'; - +/** + * react-bootstrap-table supports cell editing. When you enable this feature, react-bootstrap-table will make + * the target cell editable by either clicking or dbclicking (depending on the properties you set). + */ export interface CellEdit { /** - * To spectify which condition will trigger cell editing.(click or dbclick) + * Spectify which condition will trigger cell editing.(click or dbclick). Required. */ mode: CellEditClickMode; /** - * Enable blurToSave will trigger a saving event on cell when mouse blur on the input field. Default is false. + * Enabling blurToSave will trigger a saving event on the cell when the input field becomes deselected. Default is false. * In the default condition, you need to press ENTER to save the cell. */ blurToSave?: boolean; /** - * Accept a custom callback function, before cell saving, this function will be called. - * This callback function taking three arguments:row, cellName and cellValue - * It's necessary to return a bool value which whether apply this cell editing. + * Enabling blurToEscape will result in a cell edit being cancelled when the user clicks outside the table during + * editing. + * Default is false. */ - beforeSaveCell?: (row: any, cellName: string, cellValue: any) => boolean; + blurToEscape?: boolean; + /** + * nonEditableRows tell react-bootstrap-table which rows should not be edited on all of the columns. Briefly, its a row level limitation + * Please assign a callback function, and this function is supposed to be return an array of row keys. + */ + nonEditableRows?(): Array>; + /** + * Accept a custom callback function, before cell saving, this function will be called. + * This callback function takes four arguments: row, cellName, cellValue and done. + * `row`: the row data to be saved. + * `cellName`: the column dataField cell name that has been modified. + * `cellValue`: the new cell value. + * `done`: a callback function to use if this is an async operation, to indicate if the save data is valid. + * If your validation is async, for example: you want to pop a confirm dialog for user to confim in this case, + * react-bootstrap-table pass a callback function to you. You are supposed to call this callback function with a + * bool value to perfom if it is valid or not in addition, you should return 1 from the main function to tell + * react-bootstrap-table that this is a async operation. + */ + beforeSaveCell?(row: Row, cellName: string, cellValue: Cell, done: (isValid: boolean) => void): boolean | 1; /** * Accept a custom callback function, after cell saving, this function will be called. - * This callback function taking three arguments:row, cellName and cellValue + * This callback function takes three arguments: row, cellName and cellValue */ - afterSaveCell?: (row: any, cellName: string, cellValue: any) => void; + afterSaveCell?(row: Row, cellName: string, cellValue: Cell): void; } -export type SortOrder = 'asc' | 'desc'; - +/** + * Main Options for the Bootstrap Table. + */ export interface Options { /** - * Manage sort field by yourself + * Provide the name of the column that should be sorted by. + * If multi-column sort is active, this is an array of columns. */ - sortName?: string; + sortName?: string | string[]; /** - * Manage sort order by yourself + * Specify whether the sort should be ascending or descending. + * If multi-column sort is active, this is an array of sortOrder items. */ - sortOrder?: SortOrder; + sortOrder?: SortOrder | SortOrder[]; /** - * Assign a default sort field. + * Specify the default sort column. + * Note: when using cleanSort(), this default sort column will be restored. */ defaultSortName?: string; /** - * Assign a default sort ordering. + * Assign a default sort order. + * Note: when using cleanSort(), this default sort order will be restored. */ defaultSortOrder?: SortOrder; /** - * False to disable sort indicator on header column, default is true. + * Set to false to disable sort indicators on header columns, default is true. */ sortIndicator?: boolean; /** - * Change the displaying text on table if data is empty. + * Assign a callback function which will be called after triggering sorting. + * This function takes two argument: `sortName` and `sortOrder`. + * `sortName`: The sort column name, or array of column names if multi-column sort is active. + * `sortOrder`: The sort ordering, or array of ordering if multi-column sort is active. + */ + onSortChange?: + | ((sortName: string, sortOrder: SortOrder) => void) + | ((sortName: ReadonlyArray, sortOrder: ReadonlyArray) => void); + /** + * Change the text displayed on the table if data is empty. */ noDataText?: string | ReactElement; + /** + * If true, this hides the noDataText on the table when the tableis empty. Default is false. + */ + withoutNoDataText?: boolean; /** * A delay for trigger search after a keyup (millisecond) */ searchDelayTime?: number; /** - * A custom text on export csv button - */ - exportCSVText?: string; - /** - * Default is false, if true means you want to ignore any editable configuration when row insert. - */ - ignoreEditable?: boolean; - /** - * Only work on enable search. If true, there will be a button beside search input field for clear search field text. + * Only work on enable search. If true, there will be a button beside the search input field + * that will empty the field when clicked. */ clearSearch?: boolean; /** - * Assign a callback function which will be called after table update. + * Set the default search condition. */ - afterTableComplete?: Function; + defaultSearch?: string; + /** + * Assign a callback function which will be called when search text changes. This function takes + * three argument: + * `searchText`: the text from the search field. + * `colInfos`: Array of column settings (e.g. filterFormatted, etc). + * `multiColumnSearch`: True if multiple column search is enabled. + * In most cases, you only need to use searchText. This function usually used for remote searching. + */ + onSearchChange?(searchText: string, colInfos: ReadonlyArray, multiColumnSearch: boolean): void; + /** + * Assign a callback function which will be called after triggering searching. + * This function takes two argument: search and result. + * `search`: The search text from the user. + * `result`: The results after searching (array of rows that matched the search). + */ + afterSearch?(search: string, result: ReadonlyArray>): void; + /** + * Default is false, if true means you want to ignore any editable columns when creating the insert form. + */ + ignoreEditable?: boolean; + /** + * Assign a callback function that will be called after table updates. + */ + afterTableComplete?(): void; /** * Assign a callback function which will be called after row delete. - * This function taking one argument: rowKeys, which means the row key you dropped. + * This function takes two arguments: + * `rowKeys`: which means the row keys for the deleted rows + * `rows`: the array of row data that was deleted. */ - afterDeleteRow?: (rowKeys: string[]) => void; + afterDeleteRow?(rowKeys: Array>, rows: Array>): void; /** - * Assign a callback function which will be called after row insert. - * This function taking one argument: row, which means the whole row data you added. + * Assign a callback function which will be called after inserting a row. + * This function takes one argument: row, which means the whole row data you added. */ - afterInsertRow?: (row: any) => void; + afterInsertRow?(row: Row): void; /** - * Customize the text of previouse page button + * Assign a callback function which will be called after triggering column filtering. + * This function takes two arguments: filterConds and result. + * `filterConds`: It's an array object which contain all column filter conditions. + * `result`: The results after filtering. + * + * This function only work when you enable columnFilter on or define + * a filter on . */ - prePage?: string; + afterColumnFilter?(filterConds: ReadonlyArray, result: ReadonlyArray>): void; /** - * Customize the text of next page button + * Assign a callback function which will be called when a row is added. This function + * takes three arguments: + * `row`: which represents the new row data + * `colInfos`: Array of Column Descriptions for the table. + * `errorCallback`: Function to call to provide an async error message if the Add fails. + * The function should either return a string immediately, or return false and then return a string through the + * error callback function later. */ - nextPage?: string; + onAddRow?(row: Row, colInfo: ReadonlyArray, errorCallback: (message: string) => void): string | boolean; /** - * Customize the text of first page button + * Assign a callback function which will be called when a filter condition changes. + * This function takes one argument: filterObj which is an object which take dataField + * as object key and the value is the filter condition. */ - firstPage?: string; + onFilterChange?(filterObject: FilterData): void; /** - * Customize the text of last page button + * Assign a callback function which will be called when the export csv button is clicked. + * In this function, you need to return an array of rows to be exported. */ - lastPage?: string; + onExportToCSV?(): Array>; + /** + * Assign a callback function which will be called when a row been deleted. + * This function takes two arguments: + * `rowKeys`: keys for the rows to be deleted. + * `rows`: row data for the rows to be deleted. + */ + onDeleteRow?(rowKeys: Array>, rows: Array>): void; + /** + * Assign a callback function which will be called after a row click. + * This function takes three arguments: + * `row`: which is the row data that was clicked on. + * `columnIndex`: index of the column that was clicked on. + * `rowIndex`: index of the row that was clicked on. + */ + onRowClick?(row: Row, columnIndex: number, rowIndex: number): void; + /** + * Assign a callback function which will be called after a row double click. + * This function takes one argument: row which is the row data that was double clicked on. + */ + onRowDoubleClick?(row: Row): void; + /** + * Assign a callback function which will be called when mouse enters the table. + */ + onMouseEnter?(): void; + /** + * Assign a callback function which will be called when mouse leaves the table. + */ + onMouseLeave?(): void; + /** + * Assign a callback function which will be called when the mouse enters a row in table. + * This function takes two arguments: + * `row`: the row data the mouse entered + * `e`: the mouse event data + */ + onRowMouseOver?(row: Row, e: React.MouseEvent): void; + /** + * Assign a callback function which will be called when mouse leaves a row in table. + * This function takes two arguments: + * `row`: the row data the mouse entered + * `e`: the mouse event data + */ + onRowMouseOut?(row: Row, e: React.MouseEvent): void; + /** + * Assign a callback function which will be called when deleting a row. + * It gives you a chance to customize your confirmation for row deletion. + * This function takes two argument: next and rowKeys: + * `next`: If you confirm the delete, call next() to continue the process. + * `rowKeys` Is the row keys to be deleted, you can call the `next` function to apply this deletion. + */ + handleConfirmDeleteRow?(next: () => void, rowKeys: Array>): void; + /** + * Customize the text of previouse page button. + * If using the default pagination panel, this should be a string to use for the button label. + * If creating a custom pagination panel, this is passed to the panel and can be of any type desired. + */ + prePage?: any; + /** + * Customize the text of next page button. + * If using the default pagination panel, this should be a string to use for the button label. + * If creating a custom pagination panel, this is passed to the panel and can be of any type desired. + */ + nextPage?: any; + /** + * Customize the text of first page button. + * If using the default pagination panel, this should be a string to use for the button label. + * If creating a custom pagination panel, this is passed to the panel and can be of any type desired. + */ + firstPage?: any; + /** + * Customize the text of last page button. + * If using the default pagination panel, this should be a string to use for the button label. + * If creating a custom pagination panel, this is passed to the panel and can be of any type desired. + */ + lastPage?: any; /** * Accept a number, which means the page you want to show as default. */ page?: number; /** * You can change the dropdown list for size per page if you enable pagination. + * Default is [10, 25, 30, 50]. */ - sizePerPageList?: number[]; + sizePerPageList?: SizePerPageList; /** - * Means the size per page you want to locate as default. + * Current chosen size per page. */ sizePerPage?: number; /** - * To define the pagination bar length, default is 5. + * Number of page buttons to show on the pagination bar, default is 5. + * i.e. previous 2 pages + current page + next two pages = 5. */ paginationSize?: number; /** - * To define where to start counting the pages. + * Hide the dropdown list for size per page, default is false. + */ + hideSizePerPage?: boolean; + /** + * Display a short text showing the total number of rows and current lines displayed, + * default is false. If you want to customize this short text, you can give a function + * and this function take three arguments: + * `start`: Current start index + * `to`: Current end index + * `total`: The total data volume. + */ + paginationShowsTotal?: boolean | ((start: number, to: number, total: number) => string | ReactElement); + /** + * Allows you to modify where to start counting the pages, e.g. to set the first page number to 0. + * Default is 1. */ pageStartIndex?: number; /** * Assign a callback function which will be called after page changed. - * This function taking two argument: page and sizePerPage. - * `page`: Current page. - * `sizePerPage`: The data size which in one page. + * This function takes two argument: page and sizePerPage. + * `page`: New page number + * `sizePerPage`: The number of rows to display in one page. */ - onPageChange?: (page: number, sizePerPage: number) => void; + onPageChange?(page: number, sizePerPage: number): void; /** - * Assign a callback function which will be called after size per page dropdown changed. - * This function taking one argument: sizePerPage. - * `sizePerPage`: The data size which in one page. + * Assign a callback function which will be called after the size per page (number of rows per page) + * has been changed. + * This function takes one argument: sizePerPage. + * `sizePerPage`: The new number of rows to display in one page. */ - onSizePerPageList?: (sizePerPage: number) => void; + onSizePerPageList?(sizePerPage: number): void; /** - * Assign a callback function which will be called after trigger sorting. - * This function taking two argument: `sortName` and `sortOrde`r. - * `sortName`: The sort column name - * `sortOrder`: The sort ordering. + * Default is false. If true, the pagination list will be hidden when there is only one page. */ - onSortChange?: (sortName: string, sortOrder: SortOrder) => void; + hidePageListOnlyOnePage?: boolean; /** - * Assign a callback function which will be called after trigger searching. - * This function taking two argument: search and result. - * `search`: The search text which user input. - * `result`: The results after searching. - */ - afterSearch?: (search: string, result: any) => void; - /** - * Assign a callback function which will be called after trigger column filtering. - * This function taking two argument: filterConds and result. - * `filterConds`: It's an array object which contain all column filter conditions. - * `result`: The results after filtering. - */ - afterColumnFilter?: (filterConds: any[], result: any) => void; - /** - * Assign a callback function which will be called after a row click. - * This function taking one argument: row which is the row data which you click on. - */ - onRowClick?: (row: any) => void; - /** - * Assign a callback function which will be called after a row double click. - * This function taking one argument: row which is the row data which you double click on. - */ - onRowDoubleClick?: (row: any) => void; - /** - * Background color on expanded rows. + * Background color on expanded rows (css color value). */ expandRowBgColor?: string; /** - * Assign a callback function which will be called when mouse enter into the table. + * Tell react-bootstrap-table how to trigger expanding by clicking on 'row' or 'column' level. + * If the value is 'column', by default all the columns are expandable. If you want to specify some columns as + * unexpandable, check expandable. + * Default is 'row'. */ - onMouseEnter?: Function; + expandBy?: ExpandBy; /** - * Assign a callback function which will be called when mouse leave from the table. + * Customize the text on the insert button. */ - onMouseLeave?: Function; - /** - * Assign a callback function which will be called when mouse over a row in table. - * This function taking one argument: row which is the row data which mouse over. - */ - onRowMouseOver?: Function; - /** - * Assign a callback function which will be called when mouse leave from a row in table. - * This function taking one argument: row which is the row data which mouse out. - */ - onRowMouseOut?: Function; - - /** - * Assign a callback function which will be called when row dropping. - * It give you a chance to customize your confirmation for row deletion. - * This function taking two argument: next and rowKeys: - * `next`: If you confirm to drop row, call next() to continue the process - * `rowKeys` is the row keys which been deleted, you can call next function to apply this deletion. - */ - handleConfirmDeleteRow?: (next: Function, rowKeys: any[]) => void; - paginationShowsTotal?: boolean | ((start: number, to: number, total: number) => ReactElement); - onSearchChange?: Function; - onAddRow?: Function; - onExportToCSV?: Function; - insertText?: string; + /** + * Customize the text on the delete button. + */ deleteText?: string; + /** + * Customize the text on the save button in the insert modal. + */ saveText?: string; + /** + * Customize the text on the close button in the insert modal. + */ closeText?: string; - // Customization properties /** - * Callback function to be called when a cell is modified - * - * https://allenfang.github.io/react-bootstrap-table/example.html#remote - * + * Customize the text on the export csv button */ - onCellEdit?: (row: any, field: string, value: any) => any; + exportCSVText?: string; /** - * Callback function to be called when filter changing - * - * https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/remote/remote-store-filtering.js#L67 - * + * You can do something before the toastr pop or even disable the toastr!! + * Returning false or void will not trigger the toastr. + * If you want the toastr popup, you should return true always. + * Inputs match the EditValidatorObject.notification field types. */ - onFilterChange?: (filterObj: any) => any; + beforeShowError?(type: EditValidatorType, msg: string, title: string): boolean | void; /** - * Callback function which will be called when a row will be deleted - * - * https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/remote/remote-store-delete-row.js#L27 - * + * Default is true. If false, during printing the toolbar is hidden. */ - onDeleteRow?: (rows: any) => any; + printToolBar?: boolean; /** - * A callback which will be called after page changed - * - * https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/remote/remote-store-paging.js#L30 - * + * ToolBar is the area on the top of table, it contain the search panel, buttons for data manipulation. + * After v3.0.0, you can custom all the components in the ToolBar also itself too. + * Give a toolBar in options props and toolBar only accept a function and a JSX returned value is necessary. */ - onpageChange?: (page: any, sizePerPage: number) => any; + toolBar?(props: ToolBarProps): ReactElement; + /** + * Button group which contain the insert, drop, show only select and export CSV buttons, these button all + * grouped as btn-group class in bootstrap. This is a chance that you can custom this button group. + * Give a btnGroup in options props and btnGroup only accept a function and a JSX returned value is necessary. + * This lets you customize just the left-hand-side of the toolbar if desired. + */ + btnGroup?(props: ButtonGroupProps): ReactElement; + /** + * It's available to customize the insert button by configuring insertBtn in options props, insertBtn only + * accept a function and a JSX returned value is necessary. This function will take one argument: onClick. + * + * The default `InsertButton` component is also exported as a component, so that you can use it as the base + * for your custom component. + */ + insertBtn?(onClick: (e: React.MouseEvent) => void): ReactElement; + /** + * It's available to customize delete button by configuring deleteBtn in options props, deleteBtn onl) => void): ReactElement; + /** + * It's available to customize the export csv button by configuring exportCSVBtn in options props, exportCSVBtn only + * accept a function and a JSX returned value is necessary. This function will take one argument: onClick. + * + * The default `ExportCSVButton` component is also exported as a component, so that you can use it as the base + * for your custom component. + */ + exportCSVBtn?(onClick: (e: React.MouseEvent) => void): ReactElement; + /** + * It's available to custom select only toggle button by configuring showSelectedOnlyBtn in options props. + * showSelectedOnlyBtn only accept a function and a JSX returned value is necessary. + * This function will take two argument: onClick and showSelected. + * + * The default `ShowSelectedOnlyButton` component is also exported as a component, so that you can use it as + * the base for your custom component. + */ + showSelectedOnlyBtn?(onClick: (e: React.MouseEvent) => void, showSelected: boolean): ReactElement; + /** + * You can custom the whole search panel(right side) by searchPanel in options props. searchPanel only accept + * a function and a JSX returned value is necessary. This function will take one argument: props, that contains: + * `searchField`: the default search field component + * `clearBtn`: the default clear button component + * `defaultValue`: the default text for the search field + * `placeholder`: the default placeholder text for the search field + * `clearBtnClick`: the callback function to use when the clear search button is clicked + * `search`: the callback function for triggering the search, which takes the search text as an input. + */ + searchPanel?(props: SearchPanelProps): ReactElement; + /** + * You can custom the search input field only by searchField in options props. searchField only accept a + * function and a JSX returned value is necessary. + * + * The default `SearchField` component is also exported as a component, so that you can use it as the base for + * your custom component. + */ + searchField?(props: SearchFieldProps): ReactElement & SearchFieldInterface>; + /** + * You can custom the clear button for search field by giving clearSearchBtn in options props. + * clearSearchBtn only accept a function and a JSX returned value is necessary. + * + * The default `ClearSearchButton` component is also exported as a component, so that you can use it as the + * base for your own custom component. + */ + clearSearchBtn?(onClick: (e: React.MouseEvent) => void): ReactElement; + /** + * You can customize everything in the insert modal via options.insertModal and we give you the event + * callback, props and some informations: onModalClose, onSave, columns, validateState, ignoreEditable + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/custom/insert-modal/custom-insert-modal.js + */ + insertModal?( + onModalClose: () => void, + onSave: (row: Row) => void, + columns: ReadonlyArray, + validateState: { [dataField: string]: string }, + ignoreEditable: boolean + ): ReactElement; + /** + * You can customize the body of the insert modal via options.insertModalBody and we give you the following + * arguments: columns, validateState {[fieldname]: errorMsg}, ignoreEditable + * + * Note: There is no exported Insert Modal Body component - if you are customising this, you need to create your + * own body component. That component needs to implement a `getFieldValue` method that returns the new row data. It + * will be called by react-bootstrap-table when the save button is clicked in the insert modal window. + */ + insertModalBody?( + columns: ReadonlyArray, + validateState: { [dataField: string]: string }, + ignoreEditable: boolean + ): React.ReactElement & ModalBodyInterface>; + /** + * It's available to custom the header of insert modal by configuring options.insertModalHeader. It only accepts + * a function and a JSX returned value is necessary. This function will take two arguments: closeModal and save. + * `closeModal`: callback function to trigger closing the modal window. + * `save`: callback function to trigger saving the new row data. + * + * The default `InsertModalHeader` component is also exported as a component, so that you can use it as the base + * for your own custom component. + */ + insertModalHeader?(closeModal: () => void, save: () => void): ReactElement; + /** + * It's available to custom the footer of insert modal by configuring options.insertModalFooter. It only accepts + * a function and a JSX returned value is necessary. This function will take two arguments: closeModal and save. + * `closeModal`: callback function to trigger closing the modal window. + * `save`: callback function to trigger saving the new row data. + * + * The default `InsertModalFooter` component is also exported as a component, so that you can use it as the base + * for your own custom component. + */ + insertModalFooter?(closeModal: () => void, save: () => void): ReactElement; + /** + * Function to customize all of components for pagination, including the sizePerPage dropdown and the + * pagination list. + */ + paginationPanel?(props: PaginationPanelProps): ReactElement; + /** + * Function to customize the sizePerPage dropdown. + */ + sizePerPageDropDown?(props: SizePerPageFunctionProps): ReactElement; + /** + * Location for the pagination panel to be displayed. Options are 'top' (above the table), 'bottom' + * (below the table) and 'both' (above and below the table). + */ + paginationPosition?: PaginationPostion; + /** + * Callback when the value in a cell has been modified. It accepts a function that takes three arguments: + * `row`: row that is being edited. + * `fieldName`: column dataField for the cell being edited. + * `value`: new value for the cell. + * The function allows you to make further modifications to the cell value prior to it being saved. You need to + * return the final cell value to use. + */ + onCellEdit?(row: Row, fieldName: string, value: Cell): Cell; + /** + * Custom message to show when the InsertModal save fails validation. + * Default message is 'Form validate errors, please checking!' + */ + insertFailIndicator?: string; + /** + * Function to verify that a key being generated in the Insert Modal is a valid key. + * If the key fails validation, return a string error message. + * If the key is ok, return void. + */ + isValidKey?(key: RowKey): string | void; + /** + * Ability to disable the BOM in the exported CSV file. + * BOM = prepend BOM for UTF-8 XML and text/* types(including HTML) when saving the file. + */ + noAutoBOM?: boolean; + /** + * Custom class to use for the expanded content section of an expanded row. This can either be a string, or a + * function that returns a string and takes three arguments: row, rowIndex, isExpanding. + * `row`: the row expanding/collapsing. + * `rowIndex`: index number of the row. + * `isExpanding`: boolean flag specifying whether the field is expanding or collapsing. + */ + expandBodyClass?: string | ((row: Row, rowIndex: number, isExpanding: boolean) => string); + /** + * Custom class to use for the row itself for an expanded row when it has been expanded. This can either be a + * string, or a function that returns a string and takes two arguments: row and rowIndex. + * `row`: the expanded row. + * `rowIndex`: index number of the row. + */ + expandParentClass?: string | ((row: Row, rowIndex: number) => string); + /** + * Customize the field separator in a CSV export file. Default is ','. + */ + exportCSVSeparator?: string; + /** + * Set a function to be called when expanding or collapsing a row. This function takes two arguments: rowKey + * and isExpand. + * `rowKey`: dataField key for the row that is expanding or collapsing. + * `isExpand`: True if the row is expanding, false if it is collapsing. + */ + onExpand?(rowKey: RowKey, isExpand: boolean): void; + /** + * Specify that only one row should be able to be expanded at the same time. + */ + onlyOneExpanding?: boolean; + /** + * Customize the tooltip text shown when hovering over the prePage button. + */ + prePageTitle?: string; + /** + * Customize the tooltip text shown when hovering over the nextPage button. + */ + nextPageTitle?: string; + /** + * Customize the tooltip text shown when hovering over the firstPage button. + */ + firstPageTitle?: string; + /** + * Customize the tooltip text shown when hovering over the lastPage button. + */ + lastPageTitle?: string; + /** + * Provide an array of expanded rows for the table. + */ + expanding?: Array>; + /** + * Flag to indicate that the table should keep the SizePerPage dropdown open if the table rerenders without any + * user interaction. + */ + keepSizePerPageState?: boolean; + /** + * Flag to indicate that the table should always show next/previous buttons even when there is not next/previous + * page. + */ + alwaysShowAllBtns?: boolean; + /** + * Flag to indicate whether there should be buttons for First and Last page. + */ + withFirstAndLast?: boolean; } -interface FetchInfo { - dataTotalSize?: number; +/** + * Properties for data where only a portion of the data is loaded into the table at one time (i.e. remote data). + */ +export interface FetchInfo { + /** + * Total number of rows that match the current table filter/search properties. + */ + dataTotalSize: number; } -export interface BootstrapTable extends ComponentClass { +/** + * BootstrapTable class definition. + */ +export class BootstrapTable extends Component { /** - * Call this function to insert an new row to table. + * Call this function to insert a new row to table. */ - handleAddRow(row: any): void; + handleAddRow(row: Row): void; /** - * Call this function to insert an new row as first row on table. + * Call this function to insert a new row as the first row in the table. */ - handleAddRowAtBegin(row: any): void; + handleAddRowAtBegin(row: Row): void; /** - * Call this function to drop rows in table. + * Call this function to drop/delete rows from the table. */ - handleDropRow(rowKeys: any[]): void; + handleDropRow(rowKeys: Array>): void; /** * Call this function to do column filtering on table. + * @example: + * // Filtering passing an array of values + * this.refs.table.handleFilterData({ + * name: { type: 'ArrayFilter', value: ['Item name 3', 'Item name 4'] }, + * price: { type: 'ArrayFilter', value: [2100, 2104] } + * }); */ - handleFilterData(filter: any): void; + handleFilterData(filter: FilterData): void; /** * Call this function with search text for fully searching. */ @@ -486,262 +1134,1512 @@ export interface BootstrapTable extends ComponentClass { /** * Call this function to sort table. */ - handleSort(order: SortOrder, field: string): void; + handleSort(order: SortOrder, dataField: string): void; /** * Call this function to get the page by a rowkey */ - getPageByRowKey(rowKey: string): any; + getPageByRowKey(rowKey: RowKey): number; /** * Call this function to export table as csv. */ handleExportCSV(): void; /** - * Clean all the selection state on table. + * Reset the sort options to the defaults. Documented in examples but missing from main options list. + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/sort/clean-sorted-table.js + */ + cleanSort(): void; + /** + * Deselect all rows in the table. */ cleanSelected(): void; + /** + * Call reset to clean all the status on the table currently (sort, editing, filtering, search). + */ + reset(): void; } -interface BootstrapTable extends ComponentClass { } -declare const BootstrapTable: BootstrapTable; -export type DataAlignType = 'left' | 'center' | 'right' | 'start' | 'end'; export interface TableHeaderColumnProps extends Props { /** - * The field of data you want to show on column. + * The field of data you want to show on column. This is used throughout react-bootstrap-table as the column field + * name. */ dataField?: string; /** - * Use isKey to tell table which column is unique. This is same as keyField in - * Tips: You need choose one configuration to set key field: isKey or keyField in + * Use isKey to tell table which column is unique. This is same as the keyField in + * Tips: You need choose one configuration to set key field: isKey or the keyField in */ isKey?: boolean; /** - * Set the column width. ex: 150, it's means 150px + * Set the column width, including the units. e.g. '10%' or '150px' */ width?: string; /** - * Set align in column, value is left, center, right, start and end. + * Set the text alignment in the column, possible values are 'left', 'center', 'right', 'start' and 'end'. */ dataAlign?: DataAlignType; - /** * Alignment of text in the column header. + * Tip: If you don't set the headerAlign, it will default to the setting for dataAlign. */ headerAlign?: DataAlignType; /** - * True to enable table sorting. Default is disabled. + * True to enable table sorting on this column. Default is disabled. */ dataSort?: boolean; - /** - * Default search string. - */ - defaultSearch?: string; /** * Allow user to render a custom sort caret. You should give a function and should return a JSX. - * This function taking one arguments: order which present the sort order currently. + * This function takes two arguments: order and fieldName. + * `direction`: the current sort order. + * `fieldName`: the dataField name of the field currently being sorted. */ - caretRender?: Function; - /** - * Give an Object like following to able to customize your own editing component. - * This Object should contain these two property: - * getElement(REQUIRED): Accept a callback function and take two arguments: onUpdate and props. - * customEditorParameters: Another extra data for custom cell edit component. - */ - customEditor?: { getElement: (onUpdate: any, props: any) => ReactElement, customEditorParameters?: object }; + caretRender?(direction: SortOrder | null, fieldName: string): string | ReactElement; /** * To customize the column. This callback function should return a String or a React Component. - * In addition, this function taking two argument: cell and row. + * In addition, this function taking four argument: cell, row, formatExtraData, rowIdx. + * The formatExtraData will be the value which you assign it on */ - dataFormat?: (cell: any, row: any, formatExtraData?: any) => string | ReactElement; + dataFormat?(cell: Cell, row: Row, formatExtraData: any, rowIndex: number): string | ReactElement; /** - * To to enable search or filter data on formatting. Default is false + * It's useful with dataFormat, you can give any data you want to be passed to the formatter. + */ + formatExtraData?: any; + /** + * Allow you to add your custom attributes on TD element. + * Example: tdAttr={ { 'data-attr': 'test' } } + */ + tdAttr?: CustomAttrs; + /** + * Allow you to add your custom style object on TD element. + */ + tdStyle?: CSSProperties; + /** + * Allow you to add your custom style object on TH element. + */ + thStyle?: CSSProperties; + /** + * When true, the column will filter using the value returned by the column's formatter. + * When false (default), the column will filter using the pre-formatted value. */ filterFormatted?: boolean; /** - * True to hide column. + * Return the value you want to be filtered on that column. + * It's useful if your column data is an object. + * @example: (cell, row) => cell.fieldOne; + * @see: https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/manipulation/search-format-table.js + */ + filterValue?(cell: Cell, row: Row): any; + /** + * Customize the cell content when exporting to a CSV file. This function takes two argument: cell, row. + */ + csvFormat?(cell: Cell, row: Row): string; + /** + * Customize the column header text for the column when exporting to a CSV file. + */ + csvHeader?: string; + /** + * It's usually used with csvFormat, and it's same as formatExtraData. + * You can give any additional data you want to be passed to the csvFormat function. + */ + csvFormatExtraData?: any; + /** + * Set to true to hide the column. Default is false. Often used to hide rowKey columns that are required to + * identify a row but that do not need to be visible. */ hidden?: boolean; /** - * True to hide from insert dialog + * Used to specify whether a column will be exported to csv. + * + * If true, the column will be included in the export. This is usually used with hidden columns, as those are not + * exported by default. + * + * If false, the column will be excluded from the csv export. + */ + export?: boolean; + /** + * Usually used with Options.expandBy. + * You can assign which columns will trigger a row expansion or not. + * If false, clicking on a row inside this column will not cause the row to expand. + */ + expandable?: boolean; + /** + * Set this to true to hide this column on insert modal. Default is false. + * + * This is often used together with autoValue for auto-generated columns like row keys. */ hiddenOnInsert?: boolean; /** - * True to hide the dropdown for sizePerPage. + * It only work for enabling insertRow and be assign on rowKey column. If true, the value of rowkey will be + * generated automatically after a row insertion. If a function given, you can customize the value by yourself and + * remember to return the value for the cell from the function. */ - hideSizePerPage?: boolean; + autovalue?: boolean | (() => Cell); /** * False to disable search functionality on column, default is true. */ searchable?: boolean; /** - * Give a customize function for data sorting. - * This function taking four arguments: a, b, order, sortField, extraData + * Show the title on each column in the data section of the table. + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/column/column-title-table.js */ - sortFunc?: (a: any, b: any, order: SortOrder, sortField: any, extraData: any) => number; + columnTitle?: boolean | string | ((cell: Cell, row: Row, rowIndex: number, colIndex: number) => string); /** - * It's a extra data for custom sort function, if defined, this data will be pass as fifth argument in sortFunc. + * Show the title on each column in the header section of the table, default is true. + */ + headerTitle?: boolean; + /** + * If the children of TableHeaderColumn is a JSX or Object, we prefer to add this prop to describe this column with + * a pure text(String). It will be used on the placeholder or tips in the filter, search field or insert field etc. + */ + headerText?: string; + /** + * Give a custom callback function for data sorting. + * This function takes five arguments: a, b, order, sortField, extraData + * The extraData value is the data from the sortFuncExtraData. + */ + sortFunc?(a: Cell, b: Cell, order: SortOrder, sortField: string, extraData: any): number; + /** + * Extra data for the custom sort function. If defined, this data will be passed as fifth argument in sortFunc. */ sortFuncExtraData?: any; /** * Add custom css class on table header column, this attribute only accept String or Function. - * If Function, it taking four arguments: cell, row, rowIndex, columnIndex. + * If Function, it takes four arguments: cell, row, rowIndex, columnIndex. * In addition, this function should return a String which is the class name you want to add on. */ - className?: string | ((cell: any, row: any, rowIndex: number, columnIndex: number) => string); + className?: string | ((cell: Cell, row: Row, rowIndex: number, columnIndex: number) => string); /** * Add custom css class on table body column, this attribute only accept String or Function. * If Function, it taking four arguments: cell, row, rowIndex, columnIndex. * In addition, this function should return a String which is the class name you want to add on. */ - columnClassName?: String | ((cell: any, row: any, rowIndex: number, columnIndex: number) => string); + columnClassName?: string | ((cell: Cell, row: Row, rowIndex: number, columnIndex: number) => string); /** - * Add True to set column editable, false is non-editable. If give Object, - * you can do more customization when editing cell. This object have following properties: - * @example - * { - * type: //edit type, avaiable value is textarea, select, checkbox - * validator: //give function for validation and taking only one "cell value" as argument. This function should return Bool. - * options:{ - * values: //values means data in select or checkbox.If checkbox, use ':'(colon) to separate value, ex: Y:N - * } - * } + * Add custom css class on editing cell, if assign a callback function, you are supposed to return a String for class name */ - editable?: boolean | Editable; + editColumnClassName?: string | ((cell: Cell, row: Row) => string); /** - * It only work when you enable insertRow and be assign on rowKey column. - * If true, the row key will be generated automatically after a row insertion. + * Add custom css class for invalid editing cell, if assign a callback function, you are supposed to return a String for class name */ - autoValue?: boolean; + invalidEditColumnClassName?: string | ((cell: Cell, row: Row) => string); + /** + * boolean: Add True to set column editable, false is non-editable. + * function: You have ability to control the editable level on cell instead of column level. For this + * callback function, you are supposed to be return a bool value to decide this cell editable or not + * This callback accepts four arguments: cell, row, rowIndex, columnIndex. + * object: @see Editable interface. + */ + editable?: boolean | Editable | ((cell: Cell, row: Row, rowIndex: number, columnIndex: number) => boolean | string | EditValidatorObject); + /** + * Give an Object like following to able to customize your own editing component. + * This Object should contain these two property: + * getElement(REQUIRED): Accept a callback function and take two arguments: onUpdate and props. + * customEditorParameters: Additional data for custom cell edit component. + */ + customEditor?: CustomEditor; /** * To Enable a column filter within header column. - * This feature support a lots of filter type and condition. Please check example - * Following is the format for filter + * This feature support a lots of filter types and conditions. */ filter?: Filter; - - onSort?: Function; - /** - * Header for column in generated CSV file - */ - csvHeader?: string; - csvFormat?: Function; - columnTitle?: boolean; - sort?: SortOrder; - formatExtraData?: any; - - /** - * Row in the header on which this header column present. + * This is always used together with rowSpan and colSpan, to create multi-row/multi-column headers. + * Row is the header row on which this header column present. */ row?: number; - /** * Indicates how many rows this column takes. * Default: 1 */ rowSpan?: number; - /** * Indicates how many columns this column takes. * Default: 1 */ colSpan?: number; - /** - * Return the value you want to be filtered on that column. - * It's useful if your column data is an object. + * Specify the field type to use when exporting this column to CSV. Available types are 'number' and 'string'. + * Defaults to 'string'. */ - filterValue?: Function; - + csvFieldType?: CSVFieldType; /** - * Allow you to add your custom attributes on TD element. + * Set the column class name for the actively filtered column. Can be either a string, or a function that takes two + * parameters: order and dataField. + * `order`: current sort order for the column. + * `dataField`: current column's dataField. + * This allows you to specify a different className depending on whether the current dataField is being sorted 'asc' + * or 'desc'. + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/sort/sort-style-table.js#L36-L37 */ - tdAttr?: object; - + sortHeaderColumnClassName?: string | ((order: SortOrder, dataField: string) => string); /** - * Allow you to add your custom style object on TD element. + * Specify custom tdAttrs to use for a cell that is being edited within this column. */ - tdStyle?: object; - + editTdAttr?: CustomAttrs; /** - * Allow you to add your custom style object on TH element. + * Custom insert editor element. This is a function to generate a custom edit element to display in the InsertModal + * form. The function takes five arguments: column, attr, editorClass, ignoreEditable, defaultValue. + * `column`: column information given to the insert modal. + * `attr`: EditableAttrs from the TableHeader.editable object options. + * `editorClass`: className to apply to the editor component. + * `ignoreEditable`: boolean flag indicating whether editable fields should be ignored in the insert modal + * `defaultValue`: the default value to use for this cell. + * The function should return either a JSX element for the field, or false to default back to the standard edit + * element. */ - thStyle?: object; + customInsertEditor?: { + getElement( + column: InsertModalColumnDescription, + attr: EditableAttrs, + editorClass: string, + ignoreEditable: boolean, + defaultValue: Cell + ): ReactElement | boolean; + }; + /** + * Support specifying that the column should start sorting with the 'asc' option. + */ + defaultASC?: boolean; } -export interface Editable { - type?: string; // edit type, avaiable value is textarea, select, checkbox - /** - * Function for validation and taking only one "cell value" as argument. This function should return Bool. - */ - validator?: (cell: any) => boolean; - /** - * @example - * { - * values: //values means data in select or checkbox. If checkbox, use ':'(colon) to separate value, ex: Y:N - * } - */ - options?: any; +/** + * Editable Attributes. Poorly documented, but used when creating custom editor components. + */ +export interface EditableAttrs { /** - * Configuration for the textarea editable type + * Placeholder text to use for the cell editor field. + */ + placeholder?: string; + /** + * Function to pass a reference to the input editor field. + */ + ref?(ref: any): any; + /** + * Callback for onKeyDown. + */ + onKeyDown?(): void; + /** + * Callback for on cell blur. + */ + onBlur?(): void; +} + +/** + * Editable Select option values + */ +export type EditSelectOptionValue = + | Array<{ text: string; value: string; }> + | string[] + | number[]; + +/** + * Editable Checkbox option values. This should be a string with the true/false value separated by a colon. + * e.g. "Yes:No" + */ +export type EditCheckboxOptionValue = string; + +/** + * Object to use to customize the properties for an editable column. + */ +export interface Editable { + /** + * Edit field type, avaiable value is 'textarea', 'select', 'checkbox' and 'datetime' + */ + type?: EditCellType; + /** + * Class name to use for the editor component. + */ + className?: string; + /** + * Number of columns to display for a text area component. */ cols?: number; + /** + * Number of rows to display for a text area component. + */ rows?: number; + /** + * Used to specify a field that can be modified in the insert modal when adding a new row, but cannot be edited + * inside the table after the row has been inserted. + */ + readOnly?: boolean; + /** + * CSS Style to use for the editor component. + */ + style?: CSSProperties; + /** + * Validation function for the column. It takes the new "cell value" as argument. This function should return + * a boolean true/false for isValid, or an EditValidatorObject (so that an error message can be provided). + */ + validator?(cell: Cell, row: Row): boolean | string | EditValidatorObject; + /** + * Data in a select or checkbox. If a checkbox, use a string with a ':'(colon) to separate the two values, ex: Y:N + * The callback function can be used to customize the select options based on other field values within the row. + * If the array is an array of objects, the fields 'text' can be used for the display text and 'value' to specify + * the option's value. + */ + options?: { + values: + | EditSelectOptionValue + | EditCheckboxOptionValue + | ((row: Row) => EditCheckboxOptionValue | EditSelectOptionValue); + }; + /** + * Default value to show in the edit field in the Insert Modal for this column. + */ + defaultValue?: Cell; + /** + * @deprecated Use placeholder inside the attrs field instead. + * Text to display as placeholder text in the editor component. + */ + placeholder?: string; + /** + * Additional attributes for the editor component. + */ + attrs?: EditableAttrs; } + export type SetFilterCallback = (targetValue: any) => boolean; export interface ApplyFilterParameter { callback: SetFilterCallback; } -export type FilterType = 'TextFilter' | 'RegexFilter' | 'SelectFilter' | 'NumberFilter' | 'DateFilter' | 'CustomFilter'; -export interface Filter { +/** + * Text filter type. + */ +export interface TextFilter { /** - * "TextFilter"||"SelectFilter"||"NumberFilter"||"DateFilter"||"RegexFilter"||"YOUR_CUSTOM_FILTER" + * Filter type must be 'TextFilter'. */ - type?: FilterType; + type: 'TextFilter'; /** - * Default value on filter. If type is NumberFilter or DateFilter, this value will like { number||date: xxx, comparator: '>' } - */ - defaultValue?: any; - /** - * Assign a millisecond for delay when trigger filtering, default is 500. + * Delay time in milliseconds after the last key press prior to applying the filter. Defaults to 500ms. */ delay?: number; /** - * Only work on TextFilter. Assign the placeholder text on text and regex filter + * Placeholder text to show in the filter. */ - placeholder?: string | RegExp; + placeholder?: string; /** - * Only work on NumberFilter. Accept an array which conatin the filter condition, like: ['<','>','='] + * Condition. Can be 'eq' (exactly equal) or 'like' (contains the given string). Defaults to 'like'. */ - numberComparators?: string[]; - - /** - * Options for the filter. - */ - options?: any; - - /** - * Comparison condition for the NumberFilter - */ - condition?: string; - - /** - * Get element which represent filter. - */ - getElement?: (filterHandler: (parameters?: ApplyFilterParameter) => void, filterParameters: any) => JSX.Element; - - /** - * Parameters for custom filter - */ - customFilterParameters?: any; + condition?: FilterCondition; + /** + * Default value for the text filter. Defaults to '' + */ + defaultValue?: string; + /** + * CSS Style to use for the select filter. + */ + style?: CSSProperties; } -export interface TableHeaderColumn extends ComponentClass { } -declare const TableHeaderColumn: TableHeaderColumn; - -declare class TableDataSet extends EventEmitter { - constructor(data: any); - setData(data: any): void; - clear(): void; - getData(): any; +export interface SelectFilterOptionsType { + [value: string]: string | number | boolean; + [value: number]: string | number | boolean; } + +/** + * Select filter type + */ +export interface SelectFilter { + /** + * Filter type must be 'SelectFilter' + */ + type: 'SelectFilter'; + /** + * Placeholder text to show in the filter. + */ + selectText?: string; + /** + * Options for the filter select. + */ + options: SelectFilterOptionsType; + /** + * Condition. Can be 'eq' (exactly equal) or 'like' (contains the given string). Defaults to 'like'. + */ + condition?: FilterCondition; + /** + * Default value for the select filter. + */ + defaultValue?: string | number | boolean; + /** + * CSS Style to use for the select filter. + */ + style?: CSSProperties; + /** + * Disable the empty option in the dropdown filter. + */ + withoutEmptyOption?: boolean; +} + +/** + * Regex filter type + */ +export interface RegexFilter { + /** + * Filter type must be 'RegexFilter' + */ + type: 'RegexFilter'; + /** + * Delay time in milliseconds after the last key press prior to applying the filter. Defaults to 500ms. + */ + delay?: number; + /** + * Placeholder text to show in the filter. + */ + placeholder?: string; + /** + * Default value + */ + defaultValue?: string; + /** + * CSS Style to use for the select filter. + */ + style?: CSSProperties; +} + +/** + * Number filter type + */ +export interface NumberFilter { + /** + * Filter type must be 'NumberFilter' + */ + type: 'NumberFilter'; + /** + * Delay time in milliseconds after the last key press prior to applying the filter. Defaults to 500ms. + */ + delay?: number; + /** + * Placeholder text to show in the filter. + */ + placeholder?: string; + /** + * Number filter comparators + */ + numberComparators?: FilterComparator[]; + /** + * Default value for the filter. + */ + defaultValue?: { + /** + * Number value. + */ + number: number; + /** + * Comparator value. + */ + comparator: FilterComparator; + }; + /** + * If this is a select number field, disable the empty option in the dropdown. + */ + withoutEmptyOption?: boolean; + /** + * Specify that the comparator field MUST have a comparator selected. + */ + withoutEmptyComparatorOption?: boolean; + /** + * Specify that the value field MUST have a number value specified. + */ + withoutEmptyNumberOption?: boolean; + /** + * List of number options that can be selected, if the number field is a select dropdown instead of a text edit. + */ + options?: number[]; + /** + * CSS Style to use for the select filter. + */ + style?: { + number: CSSProperties; + comparator: CSSProperties; + }; +} + +/** + * Date filter type + */ +export interface DateFilter { + /** + * Filter type must be 'DateFilter' + */ + type: 'DateFilter'; + /** + * Delay time in milliseconds after the last key press prior to applying the filter. Defaults to 500ms. + */ + delay?: number; + /** + * Date filter comparators + */ + dateComparators?: FilterComparator[]; + /** + * Default value for the filter. + */ + defaultValue?: { + /** + * Date value. String values will be automatically converted to dates. + */ + date: Date | string; + /** + * Comparator value. + */ + comparator: FilterComparator; + }; + /** + * CSS Style to use for the select filter. + */ + style?: { + date: CSSProperties; + comparator: CSSProperties; + }; +} + +/** + * Custom filter type. + */ +export interface CustomFilter { + /** + * Type must be 'CustomFilter' + */ + type: 'CustomFilter'; + /** + * Function to generate the filter component + */ + getElement( + filterHandler: (parameters?: ApplyFilterParameter) => void, + customFilterParameters: object + ): ReactElement; + /** + * Custom filter parameters to be passed to the generator function + */ + customFilterParameters: object; +} + +/** + * Collection of filter types. + */ +export type Filter = TextFilter | SelectFilter | RegexFilter | NumberFilter | DateFilter | CustomFilter; + +/** + * The "value" type for a number filter + */ +export interface NumberFilterValue { + number: number; + comparator: FilterComparator; +} + +/** + * The "value" type for a date filter. + */ +export interface DateFilterValue { + date: Date | string; + comparator: FilterComparator; +} + +/** + * Text Filter's data object. + */ +export interface TextFilterData { + type: 'TextFilter'; + value: string; +} + +/** + * Select Filter's data object. + */ +export interface SelectFilterData { + type: 'SelectFilter'; + value: string; +} + +/** + * Regex Filter's data object. + */ +export interface RegexFilterData { + type: 'RegexFilter'; + value: string; +} + +/** + * Number Filter's data object. + */ +export interface NumberFilterData { + type: 'NumberFilter'; + value: NumberFilterValue; +} + +/** + * Date Filter's data object. + */ +export interface DateFilterData { + type: 'DateFilter'; + value: DateFilterValue; +} + +/** + * Data object returned for an array filter. + */ +export interface ArrayFilterData { + type: 'ArrayFilter'; + value: string[] | number[]; +} + +/** + * Valid types for the "value" field inside a filter's data object. + */ +export type FilterValueData = string | number | string[] | number[] | DateFilterValue | NumberFilterValue; + +/** + * Combined types of filter data objects. + */ +export type FilterValue = + | TextFilterData + | SelectFilterData + | RegexFilterData + | NumberFilterData + | DateFilterData + | ArrayFilterData; + +/** + * Filter object that can be passed to BootstrapTableFilter.handleFilterData function. + */ +export interface FilterData { + [dataField: string]: FilterValue; +} + +/** + * TableHeaderColumn class definition. + */ +export class TableHeaderColumn extends Component { + /** + * Function to reset the filter on this column to the default values. + */ + cleanFiltered(): void; + /** + * Apply a filter value. + */ + applyFilter(value: FilterValueData): void; +} + +/** + * Customize the options for Keyboard Navigation. + */ +export interface KeyboardNavigation { + /** + * Return a style object which will be applied on the navigating cell. + */ + customStyle?: CSSProperties; + /** + * Set to false to disable click to navigate, usually user wants to click to select row instead of navigation. + */ + clickToNav?: boolean; + /** + * Return a style object which will be applied on the both of navigating and editing cell. + */ + customStyleOnEditCell?: CSSProperties; + /** + * When set to true, pressing ENTER will begin to edit the cell if cellEdit is also enabled. + */ + enterToEdit?: boolean; + /** + * When set to true, pressing ENTER will expand or collapse the current row. + */ + enterToExpand?: boolean; +} + +/** + * Input properties for the expandColumnComponent function when customising the expand indicator. + */ +export interface ExpandColumnComponentProps { + /** + * True if the current row is able to be expanded. + */ + isExpandableRow: boolean; + /** + * True if the current row is currently expanded. + */ + isExpanded: boolean; +} + +/** + * Customize the options for expand row feature. + */ +export interface ExpandColumnOptions { + /** + * Will enable an indicator column at first column if true. Default is false. + */ + expandColumnVisible?: boolean; + /** + * a callback function to customize the appearance of the indicator column. + */ + expandColumnComponent?(props: ExpandColumnComponentProps): string | ReactElement; + /** + * set the width of indicator column. + */ + columnWidth?: number | string; + /** + * If both an indicator column and a selection column are displaying, this specifies whether the indicator column + * should be shown first. Default is true, false will move the expand indicator column after selection column. + */ + expandColumnBeforeSelectColumn?: boolean; +} + +/** + * Properties provided in the callback to create a custom component for the selection column radio/checkboxes + */ +export interface CustomSelectProps { + /** + * What type of selection should be used? Values are 'radio' (single) or 'checkbox' (multiple). + */ + type: SelectRowMode; + /** + * True if the current row being drawn is selected. + */ + checked: boolean; + /** + * True if the current row being drawn is not permitted to be selected. + */ + disabled: boolean; + /** + * Callback that should be used when someone selects the current row. + * `event`: the current event target + * `rowIndex`: the index of the current row being toggled. + */ + onChange(event: any, rowIndex: string | number): void; + /** + * Index for the row currently being rendered. + * If the rowIndex is 'Header', it means this rendering is for header selection column. + */ + rowIndex: number | string; + /** + * The indeterminate flag is used to indicate that there are some rows selected, but it is neither all rows nor + * no rows. As far as the select all checkbox is concerned, it is neither true nor false. + */ + indeterminate: boolean; +} + +/** + * Details of the column settings, provided to the Options.onSearchChange callback function. + * The values for these settings come from the properties for a column. + * + * Note: the list of options is poorly documented. This list comes from double-checking the + * react-bootstrap-table source code to check what properties actually get passed to the + * onSearchChange callback function. + */ +export interface ColumnDescription { + /** + * Name of the column. + * Comes from TableHeader.dataField property. + */ + name: string; + /** + * Column text alignment setting + * Comes from TableHeader.dataAlign property. + */ + align: DataAlignType; + /** + * Column sorting setting. If true, the column can be used to sort the data. + * Comes from TableHeader.dataSort property. + */ + sort: boolean; + /** + * Column data format function. + * Comes from TableHeader.dataFormat property. + */ + format(cell: Cell, row: Row, formatExtraData: any, rowIndex: number): string | ReactElement; + /** + * The formatExtraData setting for the column. + * Comes from TableHeader.formatExtraData property. + */ + formatExtraData: any; + /** + * Whether data should be filtered based on the formatted value, or the raw data value. + * Comes from TableHeader.filterFormatted property. + */ + filterFormatted: boolean; + /** + * Filter function for the column. + * Comes from TableHeader.filterValue property. + */ + filterValue(cell: Cell, row: Row): any; + /** + * Setting for whether the data in this column can be edited. + * Comes from TableHeader.editable property. + */ + editable: boolean | Editable | ((cell: Cell, row: Row, rowIndex: number, columnIndex: number) => boolean | string | EditValidatorObject); + /** + * Custom editor settings to use when editing the data in this column. + * Comes from TableHeader.customEditor property. + */ + customEditor: CustomEditor; + /** + * Flag to indicate whether this column should be visible or not. + * Comes from TableHeader.hidden property. + */ + hidden: boolean; + /** + * Flag to indicate whether this column should be hidden on the insert modal. + * Comes from TableHeader.hiddenOnInsert property. + */ + hiddenOnInsert: boolean; + /** + * Flag to indicate whether the data in this column should be included in a search. + * Comes from TableHeader.searchable property. + */ + searchable: boolean; + /** + * Custom className setting for this column. + * Comes from TableHeader.columnClassName property. + */ + className: string | ((cell: Cell, row: Row, rowIndex: number, columnIndex: number) => string); + /** + * Custom className setting for this column when a cell in the column is being edited. + * Comes from TableHeader.editColumnClassName property. + */ + editClassName: string | ((cell: Cell, row: Row) => string); + /** + * Custom className setting for this column when a cell in the column contains invalid data. + * Comes from TableHeader.invalidEditColumnClassName property. + */ + invalidEditColumnClassName: string | ((cell: Cell, row: Row) => string); + /** + * Custom title to display for this column. + * Comes from TableHeader.columnTitle property. + */ + columnTitle: boolean; + /** + * Width setting for this column. + * Comes from TableHeader.width property. + */ + width: string; + /** + * Custom header value/component/children to use for this column. + * Comes from TableHeader.headerText || TableHeader.children properties. + */ + text: string | number | boolean | ReactElement; + /** + * Custom sort function to use for this column. + * Comes from TableHeader.sortFunc property. + */ + sortFunc(a: any, b: any, order: SortOrder, sortField: string, extraData: any): number; + /** + * Extra data to be provided to the search function for this column. + * Comes from TableHeader.sortFuncExtraData property. + */ + sortFuncExtraData: any; + /** + * Flag to indicate whether this column should be included in a CSV export. + * Comes from TableHeader.export property. + */ + export: boolean; + /** + * Flag to indicate whether this column is expandable. + * Comes from TableHeader.expandable property. + */ + expandable: boolean; + /** + * Custom attributes (e.g. {'data-attr': 'test'}) to be applied to cells in this column. + * Comes from TableHeader.tdAttr property. + */ + attrs: CustomAttrs; + /** + * Custom attributes (e.g. {'data-attr': 'test'}) to use for cells that are being edited in this column. + * Comes from TableHeader.editTdAttr property. + */ + editAttrs: CustomAttrs; + /** + * CSS style properties to use for cells in this column. + * Comes from TableHeader.tdStyle property. + */ + style: CSSProperties; +} + +/** + * Props provided to the Options.toolBar callback function for creating a custom toolbar. + */ +export interface ToolBarProps { + /** + * Rendered components to use in the toolbar. + */ + components: ButtonGroupProps & { + /** + * Search panel component. + */ + searchPanel: ReactElement; + /** + * Button group components. + */ + btnGroup: ReactElement; // button groups JSX + /** + * The individual search field. + */ + searchField: ReactElement; // search field JSX + /** + * The button to clear the search field. + */ + clearBtn: ReactElement; // clear search field JSX + }; + /** + * Event callbacks to use with a custom toolbar. + */ + event: { + /** + * Callback to activate the insert row modal window. + */ + openInsertModal(): void; + /** + * Callback to close the insert row modal window. + */ + closeInsertModal(): void; + /** + * Callback to delete selected row(s) from the table. + */ + dropRow(): void; + /** + * Callback to toggle between showing all rows and showing only selected rows. + */ + showOnlyToogle(): void; + /** + * Callback to export the table to a CSV file. + */ + exportCSV(): void; + /** + * Callback to apply a search. + */ + search(): void; + }; +} + +/** + * Left-hand side Button elements (used when customizing the toolbar). + */ +export interface ButtonGroupProps { + /** + * Export to CSV button. + */ + exportCSVBtn: ReactElement; + /** + * Insert button (to add a row). + */ + insertBtn: ReactElement; + /** + * Delete button. + */ + deleteBtn: ReactElement; + /** + * Toggle button to switch between showing all rows and showing selected rows only. + */ + showSelectedOnlyBtn: ReactElement; +} + +/** + * Properties that are given to the Options.searchPanel callback function. + */ +export interface SearchPanelProps { + /** + * Default search field component. + */ + searchField: ReactElement; + /** + * Default clear search field button component. + */ + clearBtn: ReactElement; + /** + * The default search text. + */ + defaultValue: string; + /** + * The placeholder text for the search field. + */ + placeholder: string; + /** + * A callback to trigger the clear search field event. + */ + clearBtnClick(): void; + /** + * A callback to trigger a search, takes the search text as an input. + */ + search(searchText: string): void; +} + +/** + * Properties passed as props to the Options.paginationPanel function when generating a custom pagination panel. + */ +export interface PaginationPanelProps { + /** + * Current page number + */ + currPage: number; + /** + * Current number of rows to show per page + */ + sizePerPage: number; + /** + * Choices for size per page dropdown component + */ + sizePerPageList: SizePerPageList; + /** + * Index number for the first page of data. + * Comes from Options.pageStartIndex. + */ + pageStartIndex: number; + /** + * Callback function to use to change page. + */ + changePage(pageNum: number): void; + /** + * Callback function to trigger the toggle on sizePerPage dropdown button + */ + toggleDropDown(): void; + /** + * Callback function to use to set a new size per page. + */ + changeSizePerPage(sizePerPage: number): void; + /** + * The basic components for the pagination panel, provided here so that you have the option to use some of them + * if you don't want to customize all of them. + */ + components: { + /** + * Text/element to display when displaying the total number of rows. + */ + totalText: string | ReactElement; + /** + * Default sizePerPageDropdown component. + */ + sizePerPageDropDown: SizePerPageDropDown; + /** + * The default list of page change buttons. + */ + pageList: HTMLUListElement; + }; +} + +/** + * Properties given to the Options.sizePerPageDropDown function used to generate a custom sizePerPage component to + * render in the pagination panel. + */ +export interface SizePerPageFunctionProps { + /** + * Flag to indicate that the sizePerPage dropdown should currently be 'open'. + */ + open: boolean; + /** + * Flag indicating that the sizePerPage dropdown should be hidden. + */ + hideSizePerPage: boolean; + /** + * Current size per page as a string value. + */ + currSizePerPage: string; + /** + * Array of the size per page options to display in the dropdown. + */ + sizePerPageList: SizePerPageList; + /** + * On-click toggle function callback to open/close the size per page dropdown list. + */ + toggleDropDown(): void; + /** + * Callback function to use to change the current size per page. + */ + changeSizePerPage(newSizePerPage: number): void; +} + +/** + * Custom Editor Props passed to the getElement function in the TableHeader.customEditor object. + */ +export interface CustomEditorProps extends EditableAttrs { + /** + * The row data for the cell being edited. + */ + row: Row; + /** + * Default value for the editor cell. + */ + defaultValue: Cell; + /** + * Contents of the customEditorParameters object. + */ + [parameterName: string]: any; +} + +/** + * Object to provide a custom editor component to use for a table column. + * @see: https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/cell-edit/custom-cell-edit-table.js + */ +export interface CustomEditor { + /** + * Required. Function to use to create the custom cell editor. Takes two parameters: + * `onUpdate`: callback function to call to update the value inside the cell. + * `props`: + */ + getElement(onUpdate: (updatedCell: Cell) => void, props: CustomEditorProps): ReactElement; + /** + * Additional parameters to pass to the getElement function inside the props argument. + */ + customEditorParameters?: object; +} + +/** + * Validation object that can be returned from cell editing validation. + */ +export interface EditValidatorObject { + /** + * Boolean flag indicating whether the cell value is valid. + */ + isValid: boolean; + /** + * Notification object providing details on the validation result. + */ + notification: { + /** + * One of 'success' or 'error' + */ + type: EditValidatorType; + /** + * A text message explaining the validation result. + */ + msg: string; + /** + * A text title explaining the validation result. + */ + title: string; + }; +} + +/** + * Properties that can be passed to the InsertButton, DeleteButton, ExportCSVButton and ClearSearchButton + * components. + */ +export interface ButtonProps { + /** + * Label for the button + */ + btnText?: string; + /** + * Bootstrap css style class for the button, e.g. 'btn-warning' + */ + btnContextual?: string; + /** + * Custom class for the button + */ + className?: string; + /** + * Glyphicon glyph string for the button, e.g. 'glyphicon-edit' + */ + btnGlyphicon?: string; + /** + * Function to be called to activate the normal onClick functionality for this button. + */ + onClick?(e: React.MouseEvent): void; +} + +/** + * Properties that can be passed to the ShowSelectedOnlyButton component. + */ +export interface ShowSelectedButtonProps { + /** + * Label for when clicking the button will toggle the table back into "show all rows" mode. + */ + showAllText?: string; + /** + * Label for when clicking the button will toggle the table into "show only selected rows" mode. + */ + showOnlySelectText?: string; + /** + * Bootstrap css style class for the button, e.g. 'btn-warning' + */ + btnContextual?: string; + /** + * Custom class for the button + */ + className?: string; + /** + * Glyphicon glyph string for the button, e.g. 'glyphicon-edit' + */ + btnGlyphicon?: string; + /** + * Function to be called to activate the normal onClick functionality for this button. + */ + onClick?(e: React.MouseEvent): void; +} + +/** + * Properties that can be passed to the SearchField component. + */ +export interface SearchFieldProps { + /** + * Custom css class name + */ + className?: string; + /** + * Default value for the search field + */ + defaultValue?: string; + /** + * Placeholder text for the search field + */ + placeholder?: string; + /** + * callback funciton to call when a key is released + */ + onKeyUp?(e: React.KeyboardEvent): void; +} + +/** + * Interface that must be implemented for a custom search field component. + */ +export interface SearchFieldInterface { + /** + * getValue should return the current search text. + */ + getValue(): string; + /** + * setValue should update the current search text to the given value. + */ + setValue(search: string): void; +} + +/** + * Modal Column data passed to Options.insertModal and Options.insertModalBody. + */ +export interface InsertModalColumnDescription { + /** + * Flag to indicate that this is the key field for the column. It is only present if there is more than + * one column in the table. + * Comes from TableHeader.isKey field. + */ + isKey?: boolean; + /** + * Header text/element for the column. + * Comes from TableHeader.headerText or TableHeader.children. + */ + name: string | ReactElement; + /** + * Field name for the column data. + * Comes from TableHeader.dataField. + */ + field: string; // children.props.dataField, + /** + * Flag to indicate whether this column is editable. + * Comes from TableHeader.editable. + */ + editable: boolean | Editable | ((cell: Cell, row: Row, rowIndex: number, columnIndex: number) => boolean | string | EditValidatorObject); + /** + * Custom element to use for the Insert field element. + * Comes from TableHeader.customInsertEditor. + */ + customInsertEditor( + column: InsertModalColumnDescription, + attr: EditableAttrs, + editorClass: string, + ignoreEditable: boolean, + defaultValue: Cell + ): ReactElement | boolean; + /** + * Flag to indicate whether this column should be hidden on the Insert Modal page. + * Comes from TableHeader.hiddenOnInsert. + */ + hiddenOnInsert: boolean; // children.props.hiddenOnInsert, + /** + * Flag to indicate whether the table should check that a key does not already exist. + * Comes from TableHeader.keyValidator. + */ + keyValidator: boolean; // children.props.keyValidator + /** + * Flag to indicate that the field should be auto-generated rather than edited. It is only present if there is more + * than one column in the table. + * Comes from TableHeader.autoValue. + */ + autoValue?: boolean; + /** + * Format function for the field. It is only present if there is more than one column in the table. Value is either + * 'false', meaning that there is no format function present, or a wrapper function that returns the formatted string + * content for the field using the TableHeader.dataFormat function to generate that string. + * + * Based on from TableHeader.dataFormat, but is applied as a wrapper function around that function. + */ + format?: boolean | ((cell: Cell) => string); +} + +/** + * Properties that can be passed to the InsertModalHeader component. + */ +export interface InsertModalHeaderProps { + /** + * Header class name. + */ + className?: string; + /** + * Title to display in the header. + */ + title?: string; + /** + * Callback function to call prior to closing the Insert Modal window. + */ + beforeClose?(e: SyntheticEvent): void; + /** + * Callback function to call to close the Insert Modal window. + */ + onModalClose?(closeModal: () => void): void; + /** + * Set to true to hide the close button. Default is false. + */ + hideClose?: boolean; + /** + * Bootstrap version. + */ + version?: BootstrapVersion; +} + +/** + * Properties that can be passed to the InsertModalFooter component. + */ +export interface InsertModalFooterProps { + /** + * Header class name. + */ + className?: string; + /** + * Text to display on the Save button + */ + saveBtnText?: string; + /** + * Text to display on the Close button + */ + closeBtnText?: string; + /** + * Bootstrap css class name for the close button, example: 'btn-warning' + */ + closeBtnContextual?: string; + /** + * Bootstrap css class name for the save button, example: 'btn-success' + */ + saveBtnContextual?: string; + /** + * Custom class name for the close button. + */ + closeBtnClass?: string; + /** + * Custom class name for the save button. + */ + saveBtnClass?: string; + /** + * Callback function to call prior to closing the Insert Modal window. + */ + beforeClose?(e: SyntheticEvent): void; + /** + * Callback function to call to close the Insert Modal window. + */ + onModalClose?(closeModal: () => void): void; + /** + * Callback function to be called prior to saving the new row. + */ + beforeSave?(e: SyntheticEvent): void; + /** + * Callback function to be called to save the new row. + */ + onSave?(save: () => void): void; +} + +/** + * Interface that must be implemented by a custom insert modal body component. + */ +export interface ModalBodyInterface { + /** + * The required getFieldValue method that must be implemented on a customized insert modal body that returns the + * new row data when the save button is clicked in the modal window. + */ + getFieldValue(): Row; +} + +/** + * Properties that can be given to the SizePerPageDropDown component. + */ +export interface SizePerPageDropDownProps { + /** + * Custom class name to use for the component. + */ + className?: string; + /** + * Bootstrap css style class for the button, e.g. 'btn-warning' + */ + btnContextual?: string; + /** + * Whether the button menu should 'dropup' or 'dropdown'. + */ + variation?: DropDirection; + /** + * Callback function that should be triggered when the user clicks on the dropdown button. + */ + onClick?(toggleDropDown: () => void): void; + /** + * Current size per page + */ + currSizePerPage?: string; + /** + * Size Per Page options list + */ + options?: number[] | Array<{ text: string, value: number }>; + /** + * Flag to indicate that the dropdown is open + */ + open?: boolean; + /** + * Flag to indicate that the dropdown is currently hidden + */ + hidden?: boolean; +} + +/** + * Default InsertButton component. Can be used to create custom toolbars, etc. + */ +export class InsertButton extends Component {} + +/** + * Default DeleteButton component. Can be used to create custom toolbars, etc. + */ +export class DeleteButton extends Component {} + +/** + * Default ExportCSVButton component. Can be used to create custom toolbars, etc. + */ +export class ExportCSVButton extends Component {} + +/** + * Default ShowSelectedOnlyButton component for toggling between showing all rows or only + * selected rows. Can be used to create custom toolbars, etc. + */ +export class ShowSelectedOnlyButton extends Component {} + +/** + * Default SearchField component. Can be used to create custom toolbars, etc. + */ +export class SearchField extends Component implements SearchFieldInterface { + getValue(): string; + setValue(search: string): void; +} + +/** + * Default ClearSearchButton component. Can be used to create custom toolbars, etc. + */ +export class ClearSearchButton extends Component {} + +/** + * Default header component used for the Insert modal. Can be used to customize the + * insert row modal form. + */ +export class InsertModalHeader extends Component {} + +/** + * Default footer component used for the Insert modal. Can be used to customize the + * insert row modal form. + */ +export class InsertModalFooter extends Component {} + +/** + * Default size per page component used in the pagination row. Can be used to customize + * the size per page dropdown. + */ +export class SizePerPageDropDown extends Component {} diff --git a/types/react-bootstrap-table/react-bootstrap-table-tests.tsx b/types/react-bootstrap-table/react-bootstrap-table-tests.tsx index c8f25dfa56..524c036423 100644 --- a/types/react-bootstrap-table/react-bootstrap-table-tests.tsx +++ b/types/react-bootstrap-table/react-bootstrap-table-tests.tsx @@ -1,8 +1,43 @@ import * as React from 'react'; import { render } from 'react-dom'; -import { BootstrapTable, TableHeaderColumn, ApplyFilterParameter, Filter } from 'react-bootstrap-table'; +import { + ApplyFilterParameter, + BootstrapTable, + ButtonGroupProps, + Cell, + CellEdit, + ColumnDescription, + CustomSelectProps, + DeleteButton, + EditableAttrs, + EditValidatorObject, + ExpandColumnComponentProps, + ExpandColumnOptions, + ExportCSVButton, + Filter, + FilterData, + FooterData, + InsertButton, + InsertModalColumnDescription, + InsertModalFooter, + InsertModalHeader, + ModalBodyInterface, + Options, + PaginationPanelProps, + SearchField, + SearchFieldInterface, + SearchFieldProps, + SearchPanelProps, + SelectRow, + ShowSelectedOnlyButton, + SizePerPageDropDown, + SortOrder, + TableHeaderColumn, + ToolBarProps +} from 'react-bootstrap-table'; -const products = [{ +interface Product { id: number; name: string; price: number; } +const products: Product[] = [{ id: 1, name: "Item name 1", price: 100 @@ -32,7 +67,8 @@ const qualityType = { 2: 'unknown' }; -function enumFormatter(cell: any, row: any, enumObject: any) { +function enumFormatter(cell: any, row: any, enumObject: any, rowIndex: number) { + console.log(`The row index: ${rowIndex}`); return enumObject[cell]; } @@ -91,7 +127,7 @@ class RemoteProps extends React.Component { return remoteObj; }} options={{ - onCellEdit: (row: any, fieldName: string, value: any) => { console.info(row); } + onCellEdit: (row: any, fieldName: string, value: any) => { console.info(row); return value; } }} > Product ID @@ -145,27 +181,20 @@ const thStyleExample = Product Price ; -// Adopted from https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/column-header-span/column-header-span-complex.js -export default class ColumnHeaderSpanComplex extends React.Component { +/** + * Adopted from https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/column-header-span/column-header-span-complex.js + */ +class ColumnHeaderSpanComplex extends React.Component { render() { - const selectRow = { - mode: 'checkbox', - bgColor: 'rgb(238, 193, 213)' - }; - - const cellEdit = { - mode: 'click', - blurToSave: true - }; + const options: Options = { exportCSVSeparator: '##' }; return ( - + ID Product name price Coupon - In stock + In stock Customer name order @@ -173,3 +202,1335 @@ export default class ColumnHeaderSpanComplex extends React.Component { ); } } + +/** + * Pagination options + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/pagination/custom-pagination-table.js + */ +class PaginationTable extends React.Component { + sizePerPageListChange = (sizePerPage: number) => { + alert(`sizePerPage: ${sizePerPage}`); + } + + onPageChange = (page: number, sizePerPage: number) => { + alert(`page: ${page}, sizePerPage: ${sizePerPage}`); + } + + renderShowsTotal = (start: number, to: number, total: number) => { + return ( +

    + From {start} to {to}, totals is {total}  (its a customize text) +

    + ); + } + + render() { + const options: Options = { + onPageChange: this.onPageChange, + onSizePerPageList: this.sizePerPageListChange, + page: 2, // which page you want to show as default + sizePerPageList: [{ + text: '5', value: 5 + }, { + text: '10', value: 10 + }, { + text: 'All', value: products.length + }], // you can change the dropdown list for size per page + sizePerPage: 5, // which size per page you want to locate as default + pageStartIndex: 0, // where to start counting the pages + paginationSize: 3, // the pagination bar size. + prePage: 'Prev', // Previous page button text + nextPage: 'Next', // Next page button text + firstPage: 'First', // First page button text + lastPage: 'Last', // Last page button text + prePageTitle: 'Go to previous', // Previous page button title + nextPageTitle: 'Go to next', // Next page button title + firstPageTitle: 'Go to first', // First page button title + lastPageTitle: 'Go to Last', // Last page button title + paginationShowsTotal: this.renderShowsTotal, // Accept bool or function + paginationPosition: 'top', // default is bottom, top and both is all available + keepSizePerPageState: true, // default is false, enable will keep sizePerPage dropdown state(open/clode) when external rerender happened + hideSizePerPage: true, // You can hide the dropdown for sizePerPage + alwaysShowAllBtns: true, // Always show next and previous button + withFirstAndLast: false, // Hide the going to First and Last page button + hidePageListOnlyOnePage: true // Hide the page list if only one page. + }; + + return ( + + Product ID + Product Name + Product Price + + ); + } +} + +/** + * Adopted from https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/cell-edit/blur-to-escape-table.js + */ +class BlurToEscapeTable extends React.Component { + render() { + const cellEditProp: CellEdit = { + mode: 'click', + blurToEscape: true + }; + + return ( + + Product ID + Product Name + Product Price + + ); + } +} + +/** + * Cell classnames, row saving hooks. + * @see https://githum.com/AllenFang/react-bootstrap-table/blob/master/examples/js/cell-edit/cell-edit-classname.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/cell-edit/cell-edit-hook-table.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/manipulation/insert-row-table.js + */ +class EditCellClassNameTable extends React.Component { + jobNameValidator = (value: string) => { + const response: EditValidatorObject = { isValid: true, notification: { type: 'success', msg: '', title: '' } }; + if (!value) { + response.isValid = false; + response.notification.type = 'error'; + response.notification.msg = 'Value must be inserted'; + response.notification.title = 'Requested Value'; + } else if (value.length < 10) { + response.isValid = false; + response.notification.type = 'error'; + response.notification.msg = 'Value must have 10+ characters'; + response.notification.title = 'Invalid Value'; + } + return response; + } + + jobStatusValidator = (value: string) => { + const nan = isNaN(parseInt(value, 10)); + if (nan) { + return 'Job Status must be a integer!'; + } + return true; + } + + invalidJobStatus = (cell: string, row: any) => { + console.log(`${cell} at row id: ${row.id} fails on editing`); + return 'invalid-jobstatus-class'; + } + + editingJobStatus = (cell: string, row: any) => { + console.log(`${cell} at row id: ${row.id} in current editing`); + return 'editing-jobstatus-class'; + } + + onBeforeSaveCellAsync = (row: any, cellName: string, cellValue: any, done: (ok: boolean) => void): boolean | 1 => { + setTimeout(() => { + done(false); // it's not ok to save :( + }, 3000); + return 1; // return 1 === async operation. + } + + onAfterSaveCell(row: any, cellName: string, cellValue: any) { + alert(`Save cell ${cellName} with value ${cellValue}`); + let rowStr = ''; + for (const prop in row) { + rowStr += `${prop}: ${row[prop]}\n`; + } + alert('The whole row :\n' + rowStr); + } + + onAfterInsertRow = (row: any) => { + let newRowStr = ''; + + for (const prop in row) { + newRowStr += `${prop}: ${row[prop]} \n`; + } + alert('The new row is:\n ' + newRowStr); + } + + render() { + const cellEditProp: CellEdit = { + mode: 'dbclick', + blurToSave: true, + beforeSaveCell: this.onBeforeSaveCellAsync, + afterSaveCell: this.onAfterSaveCell + }; + const options: Options = { + afterInsertRow: this.onAfterInsertRow // A hook for after insert rows + }; + const jobs = [ + { id: 1, status: '200', name: 'Item name 1', type: 'B', active: 'N' }, + { id: 2, status: '200', name: 'Item name 2', type: 'B', active: 'Y' } + ]; + const jobTypes = ['A', 'B', 'C', 'D']; + + return ( + + Job ID + Job Status + Job Name + Job Type + Active + + ); + } +} + +/** + * Multiple field sorting, filtering, searching and clearing + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/manipulation/filter-table.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/manipulation/multi-search-table.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/manipulation/search-clear-table.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/manipulation/strict-multi-search-table.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/remote/remote-store-search.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/sort/custom-caret-sort-table.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/sort/custom-sort-table.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/sort/sort-style-table.js + */ +class MultiSortAndFiltering extends React.Component { + tableRef: BootstrapTable | null; + idRef: TableHeaderColumn | null; + state = { data: products }; + + onSortChange = (name: string, order: SortOrder) => { + console.log(`Next sort = ${name}:${order}`); + } + + cleanSort = () => { this.tableRef.cleanSort(); }; + + cleanSelected = () => { this.tableRef.cleanSelected(); }; + + onFilterChange = (filter: FilterData) => { + Object.keys(filter).forEach((column) => { + console.log(`Filtering ${column}: ${JSON.stringify(filter[column])}`); + }); + } + + cleanFilters = () => { this.idRef.cleanFiltered(); }; + + afterColumnFilter = (filterConds: ReadonlyArray, result: ReadonlyArray) => { + console.log('Filter Conditions: '); + filterConds.forEach((filterCond: FilterData) => { + Object.keys(filterCond).forEach((fieldName: string) => + console.log(`Filter column = ${fieldName}, Filter value = ${filterCond[fieldName]}`)); + }); + console.log('Result is:'); + for (const resultItem of result) { + console.log(`Product: ${resultItem.id}, ${resultItem.name}, ${resultItem.price}`); + } + } + + onSearchChange = (searchText: string, colInfos: ReadonlyArray, multiColumnSearch: boolean) => { + this.setState({ data: products.filter((product) => product.name = searchText) }); + } + + afterSearch = (searchText: string, result: ReadonlyArray) => { + console.log(`Your search text is ${searchText}`); + console.log('Result is:'); + for (const resultItem of result) { + console.log(`Product: ${resultItem.id}, ${resultItem.name}, ${resultItem.price}`); + } + } + + getNameCaret = (direction: SortOrder | null, fieldName: string) => + (direction === 'asc') + ? ( up) + : (direction === 'desc') + ? ( down) + : ( up/down) + + revertSortFunc = (a: Product, b: Product, order: SortOrder) => + (order === 'desc') ? a.price - b.price : b.price - a.price + + customSortStyle = (order: SortOrder, dataField: string) => + (order === 'desc') ? 'sort-desc' : 'sort-asc' + + render() { + const options: Options = { + onSortChange: this.onSortChange, + onFilterChange: this.onFilterChange, + noDataText: 'This is custom text for empty data', + withoutNoDataText: false, + afterColumnFilter: this.afterColumnFilter, + onSearchChange: this.onSearchChange, + afterSearch: this.afterSearch, + clearSearch: true, + sortIndicator: true + }; + return ( +
    + + + Product ID + Product Name + =', '<=', '='] }}>Product Price + +
    + ); + } +} + +/** + * Sort with extra data. + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/sort/custom-sort-with-extra-data-table.js + */ +class CustomSortWithExtraDataTable extends React.Component { + sortByName = (a: any, b: any, order: SortOrder, field: string, enumObject: any) => { + if (order === 'desc') { + if (enumObject[a[field]] > enumObject[b[field]]) { + return -1; + } else if (enumObject[a[field]] < enumObject[b[field]]) { + return 1; + } + return 0; + } + if (enumObject[a[field]] < enumObject[b[field]]) { + return -1; + } else if (enumObject[a[field]] > enumObject[b[field]]) { + return 1; + } + return 0; + } + + render() { + return ( + + Product ID + Product Name + + Product Quality + + ); + } +} + +/** + * Render custom pagination with provided SizePerPageDropDown component. + */ +class CustomPagination extends React.Component { + renderPagination = (props: PaginationPanelProps) => ( +
    + +
    + + + +
    +
    + ) + + render() { + const options: Options = { + paginationPanel: this.renderPagination + }; + + return ( + + + + + + ); + } +} + +/** + * Customize the entire insert modal. + * Adapted from https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/custom/insert-modal/custom-insert-modal.js + */ +class CustomModal extends React.Component { + handleSaveBtnClick = (columns: ReadonlyArray, onSave: (row: any) => void) => { + const newRow: {[field: string]: string} = {}; + columns.forEach((column, i) => { + newRow[column.field] = (this.refs[column.field] as HTMLInputElement).value; + }, this); + onSave(newRow); + } + + createCustomModal = ( + onModalClose: () => void, + onSave: (row: any) => void, + columns: ReadonlyArray, + validateState: { [dataField: string]: string }, + ignoreEditable: boolean + ) => ( +
    +

    Custom Insert Modal

    +
    + { + columns.map((column, i) => { + const { + editable, + format, + field, + name, + hiddenOnInsert + } = column; + + if (hiddenOnInsert) { + return null; + } + const error = validateState[field] ? + ({validateState[field]}) : + null; + return ( +
    + + + {error} +
    + ); + }) + } +
    +
    + + +
    +
    + ) + + render() { + const options: Options = { + insertModal: this.createCustomModal + }; + return ( + + Product ID + Product Name + Product Price + + ); + } +} + +/** + * Custom Insert Modal Fields, both as a custom component and as custom fields. + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/custom/insert-modal/custom-insert-modal-field.js + */ +class SalesRadioField extends React.Component<{editorClass: string, ignoreEditable: boolean}> { + yes: HTMLInputElement | null; + no: HTMLInputElement | null; + + getFieldValue = () => { + return this.yes.checked ? 'Yes' : 'No'; + } + + render() { + return ( +
    + + +
    + ); + } +} +class CustomInsertModalFieldTable extends React.Component { + customKeyField = ( + column: InsertModalColumnDescription, + attr: EditableAttrs, + editorClass: string, + ignoreEditable: boolean + ) => { + const seqId = products.length; + return ( + + ); + } + + customNameField = ( + column: InsertModalColumnDescription, + attr: EditableAttrs, + editorClass: string, + ignoreEditable: boolean, + defaultValue: any) => { + const fruits = ['banana', 'apple', 'orange', 'tomato', 'strawberries']; + return ( + + ); + } + + customSaleField = ( + column: InsertModalColumnDescription, + attr: EditableAttrs, + editorClass: string, + ignoreEditable: boolean, + defaultValue: any) => { + return ( + + ); + } + + render() { + return ( + + Product ID + Product Name + On Sales? + Product Price + + ); + } +} + +/** + * Custom modal header, body & footer. + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/custom/insert-modal/default-custom-insert-modal-header.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/custom/insert-modal/custom-insert-modal-body.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/custom/insert-modal/default-custom-insert-modal-footer.js + */ +interface MyCustomBodyProps { + columns: ReadonlyArray; + validateState: { [dataField: string]: string }; + ignoreEditable: boolean; +} +class MyCustomBody extends React.Component implements ModalBodyInterface { + getFieldValue() { + const newRow: {[field: string]: string} = {}; + this.props.columns.forEach((column, i) => { + newRow[column.field] = (this.refs[column.field] as HTMLInputElement).value; + }, this); + return newRow; + } + + render() { + const { columns, validateState } = this.props; + return ( +
    +

    Custom body

    +
    + { + this.props.columns.map((column, i) => { + const { + editable, + format, + field, + name, + hiddenOnInsert + } = column; + + if (hiddenOnInsert) { + return null; + } + const error = validateState[field] ? + ({validateState[field]}) : + null; + return ( +
    + + + {error} +
    + ); + }) + } +
    +
    + ); + } +} +class DefaultCustomInsertModalHeaderFooterTable extends React.Component { + createCustomModalFooter = (closeModal: () => void, save: () => void) => { + return ( + {}} + beforeSave={(e) => {}} + onModalClose={closeModal} + onSave={save} /> + ); + } + + createCustomModalHeader = (closeModal: () => void, save: () => void) => { + return ( + { }} + onModalClose={closeModal} + hideClose={true} /> + ); + } + + createCustomModalBody = ( + columns: ReadonlyArray, + validateState: { [dataField: string]: string }, + ignoreEditable: boolean + ) => ( + + ) + + render() { + const options: Options = { + insertModalFooter: this.createCustomModalFooter, + insertModalHeader: this.createCustomModalHeader, + insertModalBody: this.createCustomModalBody + }; + return ( + + Product ID + Product Name + Product Price + + ); + } +} + +/** + * Custom Toolbar, including Search Panel & Buttons, and custom delete confirmation. + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/custom/toolbar/custom-button-group.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/custom/toolbar/custom-toolbar-1.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/custom/search/default-custom-search-field.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/custom/search/custom-search-panel-1.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/custom/search/fully-custom-search-field.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/custom/insert-button/default-custom-insert-button.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/custom/delete-button/default-custom-delete-button.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/custom/csv-button/default-custom-csv-button.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/manipulation/del-row-custom-confirm.js + */ +class MySearchField extends React.Component implements SearchFieldInterface { + field: SearchField | null; + + getValue() { + return this.field.getValue(); + } + + setValue(search: string) { + this.field.setValue(search); + } + + render() { + const { ...rest} = this.props; + return ( + { this.field = node; }} + /> + ); + } +} +class CustomButtonGroup extends React.Component { + createInsertButton = (onClick: (e: React.MouseEvent<{}>) => void) => ( + + ) + + createDeleteButton = (onClick: (e: React.MouseEvent<{}>) => void) => ( + + ) + + createExportCSVButton = (onClick: (e: React.MouseEvent<{}>) => void) => ( + + ) + + createShowSelectedOnlyButton = (onClick: (e: React.MouseEvent<{}>) => void, showSelected: boolean) => ( + + ) + + createCustomButtonGroup = (props: ButtonGroupProps) => ( +
    + {props.showSelectedOnlyBtn} + {props.exportCSVBtn} + {props.insertBtn} + {props.deleteBtn} + +
    + ) + + createCustomSearchField = (props: SearchFieldProps) => ( + + ) + + createCustomClearSearch = (onClick: (e: React.MouseEvent<{}>) => void) => ( + + ) + + createCustomSearchPanel = (props: SearchPanelProps) => ( +
    +
    + + {props.clearBtn} + +
    + {props.searchField} +
    + ) + + createCustomToolBar = (props: ToolBarProps) => { + return ( +
    + {props.components.btnGroup} +
    + {props.components.searchPanel} +
    +
    + ); + } + + customConfirm = (next: () => void, dropRowKeys: ReadonlyArray) => { + const dropRowKeysStr = dropRowKeys.join(','); + if (confirm(`(It's a custom confirm)Are you sure you want to delete ${dropRowKeysStr}?`)) { + next(); + } + } + + render() { + const selectRow: SelectRow = { + mode: 'checkbox', + showOnlySelected: true + }; + const options: Options = { + insertBtn: this.createInsertButton, + deleteBtn: this.createDeleteButton, + exportCSVBtn: this.createExportCSVButton, + showSelectedOnlyBtn: this.createShowSelectedOnlyButton, + btnGroup: this.createCustomButtonGroup, + clearSearch: true, + clearSearchBtn: this.createCustomClearSearch, + searchField: this.createCustomSearchField, + searchPanel: this.createCustomSearchPanel, + toolBar: this.createCustomToolBar, + searchDelayTime: 3000, + handleConfirmDeleteRow: this.customConfirm + }; + return ( + + Product ID + Product Name + Product Price + + ); + } +} + +/** + * Expanding Rows & Selection + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/expandRow/expand-row-by-column.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/expandRow/expand-row-with-selection.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/expandRow/custom-expand-indicator.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/expandRow/custom-expand-class.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/expandRow/auto-collapse.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/expandRow/manage-expanding.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/selection/all-select.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/selection/custom-multi-select-table.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/selection/default-select-table.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/selection/select-bgcolor-dynamic-table.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/selection/select-filter-table.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/selection/select-hook-table.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/selection/select-row-class-table.js + */ +class ExpandRowExample extends React.Component<{}, {expanding: number[]}> { + isExpandableRow = (row: any) => row.id === 2; + + expandComponent = (row: any) => ( +
    You expanded the row.
    + ) + + expandColumnComponent = ({ isExpandableRow, isExpanded }: ExpandColumnComponentProps) => { + const content = isExpandableRow + ? (isExpanded ? '(-)' : '(+)') + : ' '; + return ( +
    {content}
    + ); + } + + handleExpand = (rowKey: number, isExpand: boolean) => { + if (isExpand) { + this.setState({ expanding: [...this.state.expanding] }); + } else { + this.setState({ expanding: [...this.state.expanding.filter(id => id !== rowKey)] }); + } + } + + onSelectAll = (isSelected: boolean) => (isSelected) ? products.map(row => row.id) : []; + + onSelect = (row: Product, isSelected: boolean, e: React.MouseEvent, rowIndex: number) => { + const rowStr = `id: "${row.id}", name: ${row.name}, price: ${row.price}`; + console.log(e); + alert(`Selected: ${isSelected}, rowIndex: ${rowIndex}, row: ${rowStr}`); + } + + customMultiSelect = (props: CustomSelectProps) => ( +
    + props.onChange(e, props.rowIndex)} + ref={input => { + if (input) { + input.indeterminate = props.indeterminate; + } + }} /> + +
    + ) + + selectedRowClass = (row: Product, isSelect: boolean) => + (isSelect) + ? ((row.id >= 3) ? 'bigger-than-three-select-row' : 'less-than-three-select-row') + : '' + + render() { + const options: Options = { + expandRowBgColor: 'rgb(242, 255, 163)', + expandBy: 'column', + onlyOneExpanding: true, + expanding: this.state.expanding, + onExpand: this.handleExpand, + expandParentClass: 'custom-expand-parent', + expandBodyClass: (row, rowIndex, isExpanding) => { + return (!isExpanding) + ? 'current-is-hidden' + : (rowIndex > 1) + ? 'custom-expand-body-1' + : 'custom-expand-body-0'; + } + }; + const selectRow: SelectRow = { + mode: 'checkbox', + bgColor: (row: Product, isSelect: boolean) => + (isSelect) + ? ((row.id < 2) ? 'blue' : ((row.id < 4) ? 'red' : 'yellow')) + : null, + clickToSelect: true, // click to select, default is false + clickToExpand: true, // click to expand row, default is false + onSelect: this.onSelect, + onSelectAll: this.onSelectAll, + customComponent: this.customMultiSelect, + hideSelectColumn: false, + selected: [0, 2], + showOnlySelected: true, + onlyUnselectVisible: true, + className: this.selectedRowClass, + columnWidth: '60px', + unselectable: [1, 3] + }; + const expandColumnOptions: ExpandColumnOptions = { + expandColumnVisible: true, + expandColumnBeforeSelectColumn: false, + expandColumnComponent: this.expandColumnComponent, + columnWidth: 50 + }; + return ( + + Product ID + Product Name + Product Price + + ); + } +} + +/** + * Table mouse enter/leave events + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/others/mouse-event-table.js + */ +class MouseEventTable extends React.Component { + render() { + const options: Options = { + onMouseLeave: () => { console.log('mouse left table'); }, + onMouseEnter: () => { console.log('mouse entered table'); }, + onRowMouseOut: (row: any, e: React.MouseEvent<{}>) => { + console.log(e); + console.log('mouse left row ' + row.id); + }, + onRowMouseOver: (row: any, e: React.MouseEvent<{}>) => { + console.log(e); + console.log('mouse entered row ' + row.id); + } + }; + + return ( + + Product ID + Product Name + Product Price + + ); + } +} + +/** + * Hidden on insert modal with async row error callback & read-only field + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/advance/hide-on-insert-table.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/advance/insert-error-handle-table.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/advance/validator-table-read-only.js + */ +class HideOnInsertTable extends React.Component { + handleAddRowWithASyncError = (row: any, colInfo: ReadonlyArray, errorCallback: (msg: string) => void) => { + setTimeout(() => { + errorCallback('Sorry, There\'s some error happend'); + }, 5000); + return false; + } + render() { + const jobs = [ + { id: 1, status: '200', name: 'Item name 1', type: 'B', active: 'N' }, + { id: 2, status: '200', name: 'Item name 2', type: 'B', active: 'Y' } + ]; + const jobTypes = ['A', 'B', 'C', 'D']; + const options: Options = { + onAddRow: this.handleAddRowWithASyncError + }; + return ( + + Job ID + Job Name + Job Type + Active + + ); + } +} + +/** + * Edit field types + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/advance/edit-type-table.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/advance/insert-default-value-table.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/advance/insert-error-handle-table.js + */ +class EditTypeTable extends React.Component { + formatType = (cell: any) => `TYPE_${cell}`; + + jobTypes = (row: any) => (row.id > 2) ? ['A', 'B'] : ['B', 'C', 'D', 'E']; + + handleAddRowWithSyncError = () => { + return 'Sorry, There\'s some error happend'; + } + + render() { + const jobTypes = [ + { value: 'A', text: 'TYPE_A' }, + { value: 'B', text: 'TYPE_B' }, + { value: 'C', text: 'TYPE_C' }, + { value: 'D', text: 'TYPE_D' } + ]; + const jobs = [ + { id: 1, name: 'Item name 1', type1: 'A', type2: 'B', active: 'N', datetime: '2001-12-28T14:57:00' }, + { id: 2, name: 'Item name 2', type1: 'A', type2: 'B', active: 'Y', datetime: '2002-12-28T14:57:00' } + ]; + const attrs = { + rows: 10, + onKeyDown: () => { console.log('keydown event trigger'); } + }; + const cellEditProp: CellEdit = { + mode: 'click', + blurToSave: true + }; + const options: Options = { + onAddRow: this.handleAddRowWithSyncError + }; + return ( + + Job ID + Job Name + Job Type1 + Job Type2 + Active + Date Time + + ); + } +} + +/** + * React component format for column. + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/column-format/react-column-format-table.js + */ +class ActiveFormatter extends React.Component<{ active: boolean }> { + render() { + return ( + + ); + } +} + +export default class ReactColumnFormatTable extends React.Component { + activeFormatter = (cell: boolean, row: any) => (); + render() { + const jobs = [ + { id: 1, name: 'Item name 1', type1: 'A', type2: 'B', active: 'N', datetime: '2001-12-28T14:57:00' }, + { id: 2, name: 'Item name 2', type1: 'A', type2: 'B', active: 'Y', datetime: '2002-12-28T14:57:00' } + ]; + return ( + + + Job Name + Active + + ); + } +} + +/** + * Format Extra Data + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/column-format/extra-data-column-format-table.js + */ +class ExtraDataColumnFormatTable extends React.Component { + enumFormatter = (cell: number, row: any, enumObject: {[id: number]: string}) => enumObject[cell]; + render() { + const qualityType = { + 0: 'good', + 1: 'bad', + 2: 'unknown' + }; + const inStockStatus = { + 1: 'yes', + 2: 'no' + }; + return ( + + Product ID + Product Name + Product Quality + Product Stock Status + + ); + } +} + +/** + * Column titles + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/column/column-title-table.js + */ +class ColumnAlignTable extends React.Component { + customTitle = (cell: number, row: any, rowIndex: number, colIndex: number) => `${row.name} for ${cell}`; + + render() { + const options: Options = { + exportCSVText: 'my_export', + insertText: 'my_insert', + deleteText: 'my_delete', + saveText: 'my_save', + closeText: 'my_close' + }; + return ( + + Product ID + Product Name + Product Price + + ); + } +} + +/** + * Table Footer + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/footer/footer-table.js + */ +class FooterTable extends React.Component { + render() { + const footerData: FooterData[][] = [ + [ + { label: 'Total', columnIndex: 0 }, + { + label: 'Total value', + columnIndex: 2, + align: 'right', + formatter: (tableData: Array<{price: number}>) => { + let label = 0; + for (let i = 0, tableDataLen = tableData.length; i < tableDataLen; i++) { + label += tableData[i].price; + } + return ( + {label} + ); + } + } + ] + ]; + + return ( +
    + + Product ID + Product Name + Product Price + +
    + ); + } +} + +/** + * Keyboard navigation + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/keyboard-nav/custom-style-nav-table.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/keyboard-nav/custom-style-nav-with-cell-edit-table.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/keyboard-nav/disable-click-to-nav-table.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/keyboard-nav/enter-to-edit-with-nav-table.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/keyboard-nav/nav-with-expand-table.js + */ +class CustomStyleNavTable extends React.Component { + customStyle = (cell: any, row: any) => { + return { + backgroundColor: 'red' + }; + } + + render() { + const cellEdit: CellEdit = { + mode: 'click', + blurToSave: true + }; + const keyBoardNav = { + customStyleOnEditCell: this.customStyle, + customStyle: this.customStyle, + clickToNav: false, + enterToEdit: true, + enterToExpand: false + }; + return ( + + Product ID + Product Name + Product Price + + ); + } +} + +/** + * Table body styles + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/style/inline-style-table.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/style/table-class-table.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/style/td-class-string-table.js + */ +class TrClassStringTable extends React.Component { + render() { + return ( + + Product ID + Product Name + Product Price + + ); + } +} + +/** + * Table styles set by functions. + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/style/td-class-function-table.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/style/tr-class-function-table.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/style/tr-style-table.js + */ +class TrClassFunctionTable extends React.Component { + headerColumnClassNameFormat = () => 'th-string-example'; + + columnClassNameFormat = (fieldValue: string | number, row: Product, rowIdx: number, colIdx: number) => + rowIdx % 2 === 0 ? 'td-column-function-even-example' : 'td-column-function-odd-example' + + trClassFormat = (rowData: ReadonlyArray, rIndex: number) => + rIndex % 3 === 0 ? 'tr-function-example' : '' + + trStyle = (row: Product, rowIndex: number) => ({ backgroundColor: '#FFFAFA' }); + + render() { + return ( + + Product ID + Product Name + Product Price + + ); + } +} + +/** + * Filter types. + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/column-filter/all-filters.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/column-filter/date-filter-programmatically.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/column-filter/number-filter-programmatically.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/column-filter/regex-filter-programmatically.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/column-filter/select-filter-programmatically.js + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/column-filter/text-filter-programmatically.js + */ +class AllFilters extends React.Component { + name1: TableHeaderColumn | null; + name2: TableHeaderColumn | null; + quality: TableHeaderColumn | null; + price: TableHeaderColumn | null; + satisfaction: TableHeaderColumn | null; + inStockDate: TableHeaderColumn | null; + + handlerClickCleanFiltered = () => { + this.name1.cleanFiltered(); + this.name2.cleanFiltered(); + this.quality.cleanFiltered(); + this.price.cleanFiltered(); + this.satisfaction.cleanFiltered(); + this.inStockDate.cleanFiltered(); + } + + applyFiltersProgramatically = () => { + this.name1.applyFilter('Item 1'); + this.name2.applyFilter('[name]'); + this.quality.applyFilter(1); + this.price.applyFilter({ + number: 10.5, + comparator: '<=' + }); + this.satisfaction.applyFilter({ + number: 2, + comparator: '>' + }); + this.inStockDate.applyFilter({ + date: new Date(2015, 0, 1), + comparator: '=' + }); + } + + dateFormatter = (cell: Date, row: any) => { + if (typeof cell !== 'object') { + cell = new Date(cell); + } + + return `${('0' + cell.getDate()).slice(-2)}/${('0' + (cell.getMonth() + 1)).slice(-2)}/${cell.getFullYear()}`; + } + + render() { + const satisfaction = [0, 1, 2, 3, 4, 5]; + const qualityType = { + 0: 'good', + 1: 'bad', + 2: 'unknown' + }; + return ( + + + Product ID +
    clear filters +
    + { this.name1 = node; }} dataField='name' filter={{ type: 'TextFilter', placeholder: 'Please enter a value' }}>Product Name + { this.name2 = node; }} dataField='name' filter={{ type: 'RegexFilter', placeholder: 'Please enter a regex' }}>Product Name + < TableHeaderColumn ref={(node) => { this.quality = node; }} dataField='quality' filter={{ type: 'SelectFilter', options: qualityType }} + dataFormat={enumFormatter} formatExtraData={qualityType}>Product Quality
    + { this.price = node; }} dataField='price' filter={{ type: 'NumberFilter', delay: 1000 }}>Product Price + < TableHeaderColumn ref= {(node) => { this.satisfaction = node; }} dataField='satisfaction' filter={{ type: 'NumberFilter', options: satisfaction }}>Buyer Satisfaction
    + < TableHeaderColumn ref= {(node) => { this.inStockDate = node; }} dataField='inStockDate' filter={{ type: 'DateFilter' }} dataFormat={this.dateFormatter}>In Stock From
    +
    + ); + } +} + +/** + * Set Array filter programatically + * @see https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/column-filter/array-filter-programmatically.js + */ +class ProgrammaticallyArrayFilter extends React.Component { + table: BootstrapTable | null; + + /* Filtering passing an array of values */ + handleBtnClick = () => { + this.table.handleFilterData({ + name: { type: 'ArrayFilter', value: ['Item name 3', 'Item name 4'] }, + price: { type: 'ArrayFilter', value: [2100, 2104] } + }); + } + + render() { + return ( +
    + + { this.table = node; }} data={products}> + Product ID + Product Name + Product Price + +
    + ); + } +} diff --git a/types/react-bootstrap-table/tslint.json b/types/react-bootstrap-table/tslint.json index bf0a68ff4e..6fafe521cb 100644 --- a/types/react-bootstrap-table/tslint.json +++ b/types/react-bootstrap-table/tslint.json @@ -1,10 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - // TODO - "ban-types": false, - "prefer-method-signature": false, - "strict-export-declare-modifiers": false, - "no-empty-interface": false - } + "extends": "dtslint/dt.json" } diff --git a/types/react-bootstrap-table/v2/index.d.ts b/types/react-bootstrap-table/v2/index.d.ts new file mode 100644 index 0000000000..11c0f7f943 --- /dev/null +++ b/types/react-bootstrap-table/v2/index.d.ts @@ -0,0 +1,758 @@ +// Type definitions for react-bootstrap-table 2.6 +// Project: https://github.com/AllenFang/react-bootstrap-table +// Definitions by: Frank Laub , Aleksander Lode , Josué Us +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/// + +// documentation taken from http://allenfang.github.io/react-bootstrap-table/docs.html + +import { ComponentClass, Props, ReactElement } from 'react'; +import { EventEmitter } from 'events'; + +/** + * Interface spec for sepcifying functionality to handle remotely + * + * Consult [documentation](https://allenfang.github.io/react-bootstrap-table/docs.html#remote) + * for more info + */ +export interface RemoteObjSpec { + /** + * If set, cell edits will be handled remotely + */ + cellEdit?: boolean; + /** + * If set insertions will be handled remotely + */ + insertRow?: boolean; + /** + * If set deletion will be handled remotely + */ + dropRow?: boolean; + /** + * If set filters will be handled remotely + */ + filter?: boolean; + /** + * If set search will be handled remotely + */ + search?: boolean; + /** + * If set, exporting CSV will be handled remotely + */ + exportCSV?: boolean; + /** + * If set sorting will be handled remotely + */ + sort?: boolean; + /** + * If set pagination will be handled remotely + */ + pagination?: boolean; +} + +export interface BootstrapTableProps extends Props { + /** + * Set version='4' to use bootstrap@4, else bootstrap@3 is used. + */ + version?: string; + /** + * Use data to specify the data that you want to display on table. + */ + data: any[]; + /** + * If set, data is remote (use also fetchInfo) + */ + remote?: ((remobeObj: RemoteObjSpec) => RemoteObjSpec) | boolean; // Updated to support ^3.0.0 + /** + * Use keyField to tell table which column is unique. This is same as isKey in + * Tips: You need choose one configuration to set key field: keyField or isKey in + */ + keyField?: string; + /** + * Use height to set the height of table, default is 100%. + */ + height?: string; + /** + * Set the max column width (pixels) + */ + maxHeight?: string; + /** + * Enable striped by setting striped to true. Same as Bootstrap table class .table-striped, default is false. + */ + striped?: boolean; + /** + * Enable hover by setting hover to true. Same as Bootstrap table class .table-hover, default is false. + */ + hover?: boolean; + /** + * Enable condensed by setting condensed to true. Same as Bootstrap table class .table-condensed, default is false. + */ + condensed?: boolean; + /** + * Become a borderless table by setting bordered to false, default is true. + */ + bordered?: boolean; + /** + * Enable pagination by setting pagination to true, default is false. + */ + pagination?: boolean; + /** + * Assign the class name of row(tr). This attribute accept a string or function and function is a better way to do more customization. + * If a string given, means the value will be presented as the row class. + * If a function given, will pass rowData and rowIndex as params and should return string for presenting class. for examples: + * @example + * function trClassFormat(rowData,rowIndex){ + * return rowIndex%2==0?"tr-odd":"tr-even"; //return a class name. + * } + */ + trClassName?: string | ((rowData: any, rowIndex: number) => string); + /** + * Enable row insertion by setting insertRow to true, default is false. + * If you enable row insertion, there's a button on the upper left side of table. + */ + insertRow?: boolean; + /** + * Enable row deletion by setting deleteRow to true, default is false. + * If you enable row deletion, there's a button on the upper left side of table. + */ + deleteRow?: boolean; + /** + * Enable column filter by setting columnFilter to true, default is false. + * If enabled, there're input text field per column under the table, user can input your filter condition by each column. + */ + columnFilter?: boolean; + /** + * Enable search by setting search to true, default is false. + * If enabled, there is a on the upper left side of the table. The default place holder is Search + */ + search?: boolean; + /** + * Set searchPlaceholder to change the placeholder in search field, default is Search. + */ + searchPlaceholder?: string; + /** + * Enable strict search, default is false. + * More info here: https://github.com/AllenFang/react-bootstrap-table/issues/1199 + */ + strictSearch?: boolean; + /** + * Enable multi search by multiColumnSearch, default is false. + * If you want to use multi search, you must enable search at first. + * Tips: Use space to delimited search text. EX: 3 4, which means match all 3 or 4 datas in table. + */ + multiColumnSearch?: boolean; + /** + * Enable export csv function, default is false. + * If you enable, there's a button on the upper left side of table. + */ + exportCSV?: boolean; + /** + * Set CSV filename (e.g. items.csv). Default is spreadsheet.csv + */ + csvFileName?: () => string | string; + /** + * Enable row selection on table. selectRow accept an object which have the following properties + */ + selectRow?: SelectRow; + /** + * Enable cell editing on table. cellEdit accept an object which have the following properties + */ + cellEdit?: CellEdit; + /** + * For some options setting on this component, you can set the options attribute and give an object which contain following properties + */ + options?: Options; + fetchInfo?: FetchInfo; + printable?: boolean; + tableStyle?: any; + containerStyle?: any; + headerStyle?: any; + bodyStyle?: any; + ignoreSinglePage?: boolean; + containerClass?: string; + tableContainerClass?: string; + headerContainerClass?: string; + bodyContainerClass?: string; + expandableRow?: (row: any) => boolean; + expandComponent?: (row: any) => any; +} + +export type SelectRowMode = 'none' | 'radio' | 'checkbox'; + +export interface SelectRow { + /** + * For specifing the selection is single(radio) or multiple(checkbox). + */ + mode: SelectRowMode; + /** + * Click the row will trigger selection on that row if enable clickToSelect, default is false. + */ + clickToSelect?: boolean; + /** + * If true, click the row will trigger selection on that row and also trigger cell editing if you enabled cell edit. Default is false. + */ + clickToSelectAndEditCell?: boolean; + /** + * You can assign the background color of row which be selected. + */ + bgColor?: string; + /** + * You can assign the class name of row which be selected. + */ + className?: string; + /** + * Give an array data to perform which rows you want to be selected when table loading. + * The content of array should be the rowkey which you want to be selected. + */ + selected?: string[] | number[]; + /** + * if true, the radio/checkbox column will be hide. + * You can enable this attribute if you enable clickToSelect and you don't want to show the selection column. + */ + hideSelectColumn?: boolean; + /** + * Default is false, if enabled, there will be a button on top of table for toggling selected rows only. + */ + showOnlySelected?: boolean; + /** + * Accept a custom callback function, if a row be selected or unselected, this function will be called. + * This callback function taking three arguments row, isSelected and event: + * `row`: is the row data which you wanted to select or unselect. + * `isSelected`: it's a boolean value means "whether or not that row will be selected?". + * `event`: The event target object. + * If return value of this (function) is false, the select or deselect action will not be applied. + */ + onSelect?: (row: any, isSelected: boolean, event: any) => boolean; + /** + * Accept a custom callback function, if click select all checkbox, this function will be called. + * This callback function taking two arguments isSelected and currentSelectedAndDisplayData: + * `isSelected`: it's a boolean value means "whether or not that row will be selected?". + * `currentSelectedAndDisplayData`: If pagination enabled, this result is the data which in a page. In contrast, this is all data in table. + * If return value of this function is false, the select all or deselect all action will not be applied. + */ + onSelectAll?: (isSelected: boolean, currentSelectedAndDisplayData: any) => boolean; + + /** + * Provide a list of unselectable row keys. + */ + unselectable?: number[]; +} + +export type CellEditClickMode = 'none' | 'click' | 'dbclick'; + +export interface CellEdit { + /** + * To spectify which condition will trigger cell editing.(click or dbclick) + */ + mode: CellEditClickMode; + /** + * Enable blurToSave will trigger a saving event on cell when mouse blur on the input field. Default is false. + * In the default condition, you need to press ENTER to save the cell. + */ + blurToSave?: boolean; + /** + * Accept a custom callback function, before cell saving, this function will be called. + * This callback function taking three arguments:row, cellName and cellValue + * It's necessary to return a bool value which whether apply this cell editing. + */ + beforeSaveCell?: (row: any, cellName: string, cellValue: any) => boolean; + /** + * Accept a custom callback function, after cell saving, this function will be called. + * This callback function taking three arguments:row, cellName and cellValue + */ + afterSaveCell?: (row: any, cellName: string, cellValue: any) => void; +} + +export type SortOrder = 'asc' | 'desc'; + +export interface Options { + /** + * Manage sort field by yourself + */ + sortName?: string; + /** + * Manage sort order by yourself + */ + sortOrder?: SortOrder; + /** + * Assign a default sort field. + */ + defaultSortName?: string; + /** + * Assign a default sort ordering. + */ + defaultSortOrder?: SortOrder; + /** + * False to disable sort indicator on header column, default is true. + */ + sortIndicator?: boolean; + /** + * Change the displaying text on table if data is empty. + */ + noDataText?: string | ReactElement; + /** + * A delay for trigger search after a keyup (millisecond) + */ + searchDelayTime?: number; + /** + * A custom text on export csv button + */ + exportCSVText?: string; + /** + * Default is false, if true means you want to ignore any editable configuration when row insert. + */ + ignoreEditable?: boolean; + /** + * Only work on enable search. If true, there will be a button beside search input field for clear search field text. + */ + clearSearch?: boolean; + /** + * Assign a callback function which will be called after table update. + */ + afterTableComplete?: Function; + /** + * Assign a callback function which will be called after row delete. + * This function taking one argument: rowKeys, which means the row key you dropped. + */ + afterDeleteRow?: (rowKeys: string[]) => void; + /** + * Assign a callback function which will be called after row insert. + * This function taking one argument: row, which means the whole row data you added. + */ + afterInsertRow?: (row: any) => void; + /** + * Customize the text of previouse page button + */ + prePage?: string; + /** + * Customize the text of next page button + */ + nextPage?: string; + /** + * Customize the text of first page button + */ + firstPage?: string; + /** + * Customize the text of last page button + */ + lastPage?: string; + /** + * Accept a number, which means the page you want to show as default. + */ + page?: number; + /** + * You can change the dropdown list for size per page if you enable pagination. + */ + sizePerPageList?: number[]; + /** + * Means the size per page you want to locate as default. + */ + sizePerPage?: number; + /** + * To define the pagination bar length, default is 5. + */ + paginationSize?: number; + /** + * To define where to start counting the pages. + */ + pageStartIndex?: number; + /** + * Assign a callback function which will be called after page changed. + * This function taking two argument: page and sizePerPage. + * `page`: Current page. + * `sizePerPage`: The data size which in one page. + */ + onPageChange?: (page: number, sizePerPage: number) => void; + /** + * Assign a callback function which will be called after size per page dropdown changed. + * This function taking one argument: sizePerPage. + * `sizePerPage`: The data size which in one page. + */ + onSizePerPageList?: (sizePerPage: number) => void; + /** + * Assign a callback function which will be called after trigger sorting. + * This function taking two argument: `sortName` and `sortOrde`r. + * `sortName`: The sort column name + * `sortOrder`: The sort ordering. + */ + onSortChange?: (sortName: string, sortOrder: SortOrder) => void; + /** + * Assign a callback function which will be called after trigger searching. + * This function taking two argument: search and result. + * `search`: The search text which user input. + * `result`: The results after searching. + */ + afterSearch?: (search: string, result: any) => void; + /** + * Assign a callback function which will be called after trigger column filtering. + * This function taking two argument: filterConds and result. + * `filterConds`: It's an array object which contain all column filter conditions. + * `result`: The results after filtering. + */ + afterColumnFilter?: (filterConds: any[], result: any) => void; + /** + * Assign a callback function which will be called after a row click. + * This function taking one argument: row which is the row data which you click on. + */ + onRowClick?: (row: any) => void; + /** + * Assign a callback function which will be called after a row double click. + * This function taking one argument: row which is the row data which you double click on. + */ + onRowDoubleClick?: (row: any) => void; + /** + * Background color on expanded rows. + */ + expandRowBgColor?: string; + /** + * Assign a callback function which will be called when mouse enter into the table. + */ + onMouseEnter?: Function; + /** + * Assign a callback function which will be called when mouse leave from the table. + */ + onMouseLeave?: Function; + /** + * Assign a callback function which will be called when mouse over a row in table. + * This function taking one argument: row which is the row data which mouse over. + */ + onRowMouseOver?: Function; + /** + * Assign a callback function which will be called when mouse leave from a row in table. + * This function taking one argument: row which is the row data which mouse out. + */ + onRowMouseOut?: Function; + + /** + * Assign a callback function which will be called when row dropping. + * It give you a chance to customize your confirmation for row deletion. + * This function taking two argument: next and rowKeys: + * `next`: If you confirm to drop row, call next() to continue the process + * `rowKeys` is the row keys which been deleted, you can call next function to apply this deletion. + */ + handleConfirmDeleteRow?: (next: Function, rowKeys: any[]) => void; + paginationShowsTotal?: boolean | ((start: number, to: number, total: number) => string | ReactElement); + onSearchChange?: Function; + onAddRow?: Function; + onExportToCSV?: Function; + + insertText?: string; + deleteText?: string; + saveText?: string; + closeText?: string; + // Customization properties + /** + * Callback function to be called when a cell is modified + * + * https://allenfang.github.io/react-bootstrap-table/example.html#remote + */ + onCellEdit?: (row: any, field: string, value: any) => any; + /** + * Callback function to be called when filter changing + * + * https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/remote/remote-store-filtering.js#L67 + */ + onFilterChange?: (filterObj: any) => any; + /** + * Callback function which will be called when a row will be deleted + * + * https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/remote/remote-store-delete-row.js#L27 + */ + onDeleteRow?: (rows: any) => any; + /** + * A callback which will be called after page changed + * + * https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/remote/remote-store-paging.js#L30 + */ + onpageChange?: (page: any, sizePerPage: number) => any; +} + +interface FetchInfo { + dataTotalSize?: number; +} + +export interface BootstrapTable extends ComponentClass { + /** + * Call this function to insert an new row to table. + */ + handleAddRow(row: any): void; + /** + * Call this function to insert an new row as first row on table. + */ + handleAddRowAtBegin(row: any): void; + /** + * Call this function to drop rows in table. + */ + handleDropRow(rowKeys: any[]): void; + /** + * Call this function to do column filtering on table. + */ + handleFilterData(filter: any): void; + /** + * Call this function with search text for fully searching. + */ + handleSearch(search: string): void; + /** + * Call this function to sort table. + */ + handleSort(order: SortOrder, field: string): void; + /** + * Call this function to get the page by a rowkey + */ + getPageByRowKey(rowKey: string): any; + /** + * Call this function to export table as csv. + */ + handleExportCSV(): void; + /** + * Clean all the selection state on table. + */ + cleanSelected(): void; +} +interface BootstrapTable extends ComponentClass { } +declare const BootstrapTable: BootstrapTable; +export type DataAlignType = 'left' | 'center' | 'right' | 'start' | 'end'; + +export interface TableHeaderColumnProps extends Props { + /** + * The field of data you want to show on column. + */ + dataField?: string; + /** + * Use isKey to tell table which column is unique. This is same as keyField in + * Tips: You need choose one configuration to set key field: isKey or keyField in + */ + isKey?: boolean; + /** + * Set the column width. ex: 150, it's means 150px + */ + width?: string; + /** + * Set align in column, value is left, center, right, start and end. + */ + dataAlign?: DataAlignType; + + /** + * Alignment of text in the column header. + */ + headerAlign?: DataAlignType; + /** + * True to enable table sorting. Default is disabled. + */ + dataSort?: boolean; + /** + * Default search string. + */ + defaultSearch?: string; + /** + * Allow user to render a custom sort caret. You should give a function and should return a JSX. + * This function taking one arguments: order which present the sort order currently. + */ + caretRender?: Function; + /** + * Give an Object like following to able to customize your own editing component. + * This Object should contain these two property: + * getElement(REQUIRED): Accept a callback function and take two arguments: onUpdate and props. + * customEditorParameters: Another extra data for custom cell edit component. + */ + customEditor?: { getElement: (onUpdate: any, props: any) => ReactElement, customEditorParameters?: object }; + /** + * To customize the column. This callback function should return a String or a React Component. + * In addition, this function taking two argument: cell and row. + */ + dataFormat?: (cell: any, row: any, formatExtraData?: any) => string | ReactElement; + /** + * To to enable search or filter data on formatting. Default is false + */ + filterFormatted?: boolean; + /** + * True to hide column. + */ + hidden?: boolean; + /** + * True to hide from insert dialog + */ + hiddenOnInsert?: boolean; + /** + * True to hide the dropdown for sizePerPage. + */ + hideSizePerPage?: boolean; + /** + * False to disable search functionality on column, default is true. + */ + searchable?: boolean; + /** + * Give a customize function for data sorting. + * This function taking four arguments: a, b, order, sortField, extraData + */ + sortFunc?: (a: any, b: any, order: SortOrder, sortField: any, extraData: any) => number; + /** + * It's a extra data for custom sort function, if defined, this data will be pass as fifth argument in sortFunc. + */ + sortFuncExtraData?: any; + /** + * Add custom css class on table header column, this attribute only accept String or Function. + * If Function, it taking four arguments: cell, row, rowIndex, columnIndex. + * In addition, this function should return a String which is the class name you want to add on. + */ + className?: string | ((cell: any, row: any, rowIndex: number, columnIndex: number) => string); + /** + * Add custom css class on table body column, this attribute only accept String or Function. + * If Function, it taking four arguments: cell, row, rowIndex, columnIndex. + * In addition, this function should return a String which is the class name you want to add on. + */ + columnClassName?: String | ((cell: any, row: any, rowIndex: number, columnIndex: number) => string); + /** + * Add True to set column editable, false is non-editable. If give Object, + * you can do more customization when editing cell. This object have following properties: + * @example + * { + * type: //edit type, avaiable value is textarea, select, checkbox + * validator: //give function for validation and taking only one "cell value" as argument. This function should return Bool. + * options:{ + * values: //values means data in select or checkbox.If checkbox, use ':'(colon) to separate value, ex: Y:N + * } + * } + */ + editable?: boolean | Editable; + /** + * It only work when you enable insertRow and be assign on rowKey column. + * If true, the row key will be generated automatically after a row insertion. + */ + autoValue?: boolean; + /** + * To Enable a column filter within header column. + * This feature support a lots of filter type and condition. Please check example + * Following is the format for filter + */ + filter?: Filter; + + onSort?: Function; + + /** + * Header for column in generated CSV file + */ + csvHeader?: string; + csvFormat?: Function; + columnTitle?: boolean; + sort?: SortOrder; + formatExtraData?: any; + + /** + * Row in the header on which this header column present. + */ + row?: number; + + /** + * Indicates how many rows this column takes. + * Default: 1 + */ + rowSpan?: number; + + /** + * Indicates how many columns this column takes. + * Default: 1 + */ + colSpan?: number; + + /** + * Return the value you want to be filtered on that column. + * It's useful if your column data is an object. + */ + filterValue?: Function; + + /** + * Allow you to add your custom attributes on TD element. + */ + tdAttr?: object; + + /** + * Allow you to add your custom style object on TD element. + */ + tdStyle?: object; + + /** + * Allow you to add your custom style object on TH element. + */ + thStyle?: object; +} +export interface Editable { + type?: string; // edit type, avaiable value is textarea, select, checkbox + /** + * Function for validation and taking only one "cell value" as argument. This function should return Bool. + */ + validator?: (cell: any) => boolean; + /** + * @example + * { + * values: //values means data in select or checkbox. If checkbox, use ':'(colon) to separate value, ex: Y:N + * } + */ + options?: any; + + /** + * Configuration for the textarea editable type + */ + cols?: number; + rows?: number; +} +export type SetFilterCallback = (targetValue: any) => boolean; +export interface ApplyFilterParameter { + callback: SetFilterCallback; +} + +export type FilterType = 'TextFilter' | 'RegexFilter' | 'SelectFilter' | 'NumberFilter' | 'DateFilter' | 'CustomFilter'; +export interface Filter { + /** + * "TextFilter"||"SelectFilter"||"NumberFilter"||"DateFilter"||"RegexFilter"||"YOUR_CUSTOM_FILTER" + */ + type?: FilterType; + /** + * Default value on filter. If type is NumberFilter or DateFilter, this value will like { number||date: xxx, comparator: '>' } + */ + defaultValue?: any; + /** + * Assign a millisecond for delay when trigger filtering, default is 500. + */ + delay?: number; + /** + * Only work on TextFilter. Assign the placeholder text on text and regex filter + */ + placeholder?: string | RegExp; + /** + * Only work on NumberFilter. Accept an array which conatin the filter condition, like: ['<','>','='] + */ + numberComparators?: string[]; + + /** + * Options for the filter. + */ + options?: any; + + /** + * Comparison condition for the NumberFilter + */ + condition?: string; + + /** + * Get element which represent filter. + */ + getElement?: (filterHandler: (parameters?: ApplyFilterParameter) => void, filterParameters: any) => JSX.Element; + + /** + * Parameters for custom filter + */ + customFilterParameters?: any; +} + +export interface TableHeaderColumn extends ComponentClass { } +declare const TableHeaderColumn: TableHeaderColumn; + +declare class TableDataSet extends EventEmitter { + constructor(data: any); + setData(data: any): void; + clear(): void; + getData(): any; +} diff --git a/types/react-bootstrap-table/v2/react-bootstrap-table-tests.tsx b/types/react-bootstrap-table/v2/react-bootstrap-table-tests.tsx new file mode 100644 index 0000000000..c8f25dfa56 --- /dev/null +++ b/types/react-bootstrap-table/v2/react-bootstrap-table-tests.tsx @@ -0,0 +1,175 @@ +import * as React from 'react'; +import { render } from 'react-dom'; +import { BootstrapTable, TableHeaderColumn, ApplyFilterParameter, Filter } from 'react-bootstrap-table'; + +const products = [{ + id: 1, + name: "Item name 1", + price: 100 +}, { + id: 2, + name: "Item name 2", + price: 100 +}]; + +// It's a data format example. +function priceFormatter(cell: any, row: any) { + return ' ' + cell; +} + +render( + + Product ID + Product Name + Product Price + , + document.getElementById("app") +); + +const qualityType = { + 0: 'good', + 1: 'bad', + 2: 'unknown' +}; + +function enumFormatter(cell: any, row: any, enumObject: any) { + return enumObject[cell]; +} + +class SelectFilterWithDefaultValue extends React.Component { + render() { + return ( + + Product ID + Product Name + Product Quality + + ); + } +} + +class TextFilterWithCondition extends React.Component { + render() { + return ( + + Product ID + Product Name + Product Price + + ); + } +} + +function getCustomFilter(filterHandler: (parameters?: ApplyFilterParameter) => void, customFilterParameters: any) { + return ( +
    + ); +} + +class CustomFilter extends React.Component { + render() { + const filter: Filter = { type: 'CustomFilter', getElement: getCustomFilter, customFilterParameters: { textOK: 'yes', textNOK: 'no' } }; + return ( + + Product ID + Product Name + Product Is In Stock + + ); + } +} + +class RemoteProps extends React.Component { + render() { + const filter: Filter = { type: 'CustomFilter', getElement: getCustomFilter, customFilterParameters: { textOK: 'yes', textNOK: 'no' } }; + return ( + { + remoteObj.cellEdit = true; + return remoteObj; + }} + options={{ + onCellEdit: (row: any, fieldName: string, value: any) => { console.info(row); } + }} + > + Product ID + Product Name + Product Is In Stock + + ); + } +} + +class RemoteBool extends React.Component { + render() { + const filter: Filter = { type: 'CustomFilter', getElement: getCustomFilter, customFilterParameters: { textOK: 'yes', textNOK: 'no' } }; + return ( + + Product ID + Product Name + Product Is In Stock + + ); + } +} + +/** + * See http://allenfang.github.io/react-bootstrap-table/docs.html#tdAttr + */ +const tdAttrExample = + Product ID + Product Name + Product Price +; + +/** + * See http://allenfang.github.io/react-bootstrap-table/docs.html#tdStyle + */ +const tdStyleExample = + Product ID + Product Name + Product Price +; + +/** + * See http://allenfang.github.io/react-bootstrap-table/docs.html#thStyle + */ +const thStyleExample = + Product ID + Product Name + Product Price +; + +// Adopted from https://github.com/AllenFang/react-bootstrap-table/blob/master/examples/js/column-header-span/column-header-span-complex.js +export default class ColumnHeaderSpanComplex extends React.Component { + render() { + const selectRow = { + mode: 'checkbox', + bgColor: 'rgb(238, 193, 213)' + }; + + const cellEdit = { + mode: 'click', + blurToSave: true + }; + return ( + + ID + Product + name + price + Coupon + In stock + Customer + name + order + + ); + } +} diff --git a/types/react-bootstrap-table/v2/tsconfig.json b/types/react-bootstrap-table/v2/tsconfig.json new file mode 100644 index 0000000000..eee5850865 --- /dev/null +++ b/types/react-bootstrap-table/v2/tsconfig.json @@ -0,0 +1,30 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "paths": { + "react-bootstrap-table": [ + "react-bootstrap-table/v2" + ] + }, + "baseUrl": "../../", + "jsx": "react", + "typeRoots": [ + "../../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-bootstrap-table-tests.tsx" + ] +} diff --git a/types/react-bootstrap-table/v2/tslint.json b/types/react-bootstrap-table/v2/tslint.json new file mode 100644 index 0000000000..bf0a68ff4e --- /dev/null +++ b/types/react-bootstrap-table/v2/tslint.json @@ -0,0 +1,10 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + // TODO + "ban-types": false, + "prefer-method-signature": false, + "strict-export-declare-modifiers": false, + "no-empty-interface": false + } + } From ed43ece3e55c8b435298c99fc57971fd6bbc842d Mon Sep 17 00:00:00 2001 From: pr1st0n Date: Wed, 25 Oct 2017 17:46:59 +0300 Subject: [PATCH 026/352] Added execCommand and isReadOnly CodeMirror.Editor functions. --- types/codemirror/index.d.ts | 6 ++++++ types/codemirror/test/index.ts | 3 +++ 2 files changed, 9 insertions(+) diff --git a/types/codemirror/index.d.ts b/types/codemirror/index.d.ts index 4bf1844114..cfcbd9d5b3 100644 --- a/types/codemirror/index.d.ts +++ b/types/codemirror/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/marijnh/CodeMirror // Definitions by: mihailik // nrbernard +// Pr1st0n // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export = CodeMirror; @@ -336,6 +337,11 @@ declare namespace CodeMirror { "subtract" Reduce the indentation of the line. */ indentLine(line: number, dir?: string): void; + /** Tells you whether the editor's content can be edited by the user. */ + isReadOnly(): boolean; + + /** Runs the command with the given name on the editor. */ + execCommand(name: string): void; /** Give the editor focus. */ focus(): void; diff --git a/types/codemirror/test/index.ts b/types/codemirror/test/index.ts index e283abe974..39c601f159 100644 --- a/types/codemirror/test/index.ts +++ b/types/codemirror/test/index.ts @@ -68,3 +68,6 @@ myCodeMirror.on( ); CodeMirror.registerHelper("lint", "javascript", {}); + +myCodeMirror.isReadOnly(); +myCodeMirror.execCommand('selectAll'); From 540eb0e5870cc47394abb8082048ed85d22e009c Mon Sep 17 00:00:00 2001 From: Homa Wong Date: Wed, 25 Oct 2017 14:44:10 -0700 Subject: [PATCH 027/352] Update index.d.ts --- types/lodash/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/lodash/index.d.ts b/types/lodash/index.d.ts index f1685af04f..b0e4f6848d 100644 --- a/types/lodash/index.d.ts +++ b/types/lodash/index.d.ts @@ -9515,7 +9515,7 @@ declare namespace _ { * @param value The value to check. * @return Returns true if value is correctly classified, else false. */ - isFunction(value?: any): value is ((...args: any[]) => any) | Function; + isFunction(value?: any): value is (...args: any[]) => any; } interface LoDashImplicitWrapper { From 1eba1a5d753fb3f0ea47b2e4cbfc00fe1b221d34 Mon Sep 17 00:00:00 2001 From: Daniel Lebrecht Date: Thu, 26 Oct 2017 02:06:45 +0200 Subject: [PATCH 028/352] builder addOutput now takes Buffer | string nullData.output.encode Buffer fixing bugs according to @bobrosoft --- types/bitcoinjs-lib/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/bitcoinjs-lib/index.d.ts b/types/bitcoinjs-lib/index.d.ts index d33bc26e35..50fdc498e6 100644 --- a/types/bitcoinjs-lib/index.d.ts +++ b/types/bitcoinjs-lib/index.d.ts @@ -219,7 +219,7 @@ export class TransactionBuilder { addInput(txhash: Buffer | string | Transaction, vout: number, sequence?: number, prevOutScript?: Buffer): number; - addOutput(scriptPubKey: Buffer, value: number): number; + addOutput(scriptPubKey: Buffer | string, value: number): number; build(): Transaction; @@ -537,7 +537,7 @@ export namespace script { output: { check(script: Buffer): boolean; decode(buffer: Buffer): Buffer; - encode(data: Buffer[]): Buffer; + encode(data: Buffer): Buffer; }; }; } From 30ae02db23ac3c98efdcb48096a2dfb9a2081c54 Mon Sep 17 00:00:00 2001 From: segayuu Date: Thu, 26 Oct 2017 10:23:22 +0900 Subject: [PATCH 029/352] cleanup lint error: no-redundant-undefined --- types/bluebird/index.d.ts | 4 ++-- types/bluebird/tslint.json | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/types/bluebird/index.d.ts b/types/bluebird/index.d.ts index 49bd5e3808..9046d082fb 100644 --- a/types/bluebird/index.d.ts +++ b/types/bluebird/index.d.ts @@ -55,7 +55,7 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { * Alias `.caught();` for compatibility with earlier ECMAScript version. */ catch(onReject: (error: any) => R | PromiseLike): Bluebird; - catch(onReject?: ((error: any) => U | PromiseLike) | undefined | null): Bluebird; + catch(onReject: ((error: any) => U | PromiseLike) | undefined | null): Bluebird; /** * This extends `.catch` to work more like catch-clauses in languages like Java or C#. Instead of manually checking `instanceof` or `.name === "SomeError"`, you may specify a number of error constructors which are eligible for this catch handler. The catch handler that is first met that has eligible constructors specified, is the one that will be called. @@ -195,7 +195,7 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { * Alias `.caught();` for compatibility with earlier ECMAScript version. */ caught(onReject: (error: any) => R | PromiseLike): Bluebird; - caught(onReject?: ((error: any) => U | PromiseLike) | undefined | null): Bluebird; + caught(onReject: ((error: any) => U | PromiseLike) | undefined | null): Bluebird; /** * This extends `.catch` to work more like catch-clauses in languages like Java or C#. Instead of manually checking `instanceof` or `.name === "SomeError"`, you may specify a number of error constructors which are eligible for this catch handler. The catch handler that is first met that has eligible constructors specified, is the one that will be called. diff --git a/types/bluebird/tslint.json b/types/bluebird/tslint.json index 85497e648a..fa9263f910 100644 --- a/types/bluebird/tslint.json +++ b/types/bluebird/tslint.json @@ -2,7 +2,6 @@ "extends": "dtslint/dt.json", "rules": { "max-line-length": [true, 490], - "no-redundant-undefined": false, "no-unnecessary-generics": false, "prefer-const": false } From a670727a3721d3db44a20c3091454508fdcba2b1 Mon Sep 17 00:00:00 2001 From: Edward Sammut Alessi Date: Thu, 26 Oct 2017 17:56:50 +0200 Subject: [PATCH 030/352] Add typings for leo/args --- types/args/args-tests.ts | 67 +++++++++++++++++++++++++++++++ types/args/index.d.ts | 87 ++++++++++++++++++++++++++++++++++++++++ types/args/tsconfig.json | 22 ++++++++++ types/args/tslint.json | 1 + 4 files changed, 177 insertions(+) create mode 100644 types/args/args-tests.ts create mode 100644 types/args/index.d.ts create mode 100644 types/args/tsconfig.json create mode 100644 types/args/tslint.json diff --git a/types/args/args-tests.ts b/types/args/args-tests.ts new file mode 100644 index 0000000000..3430288cd3 --- /dev/null +++ b/types/args/args-tests.ts @@ -0,0 +1,67 @@ +import * as args from "args"; + +args + .option("opt1", "desc") + .option("opt2", "desc", false, (value: any): any => value) + .options([ + { + name: 'opt3', + description: 'desc', + defaultValue: 1, + init: (value: any) => { }, + }, + { + name: 'opt4', + description: 'desc', + }, + ]) + .command("cm1", "desc") + .command("cm2", "desc", (value: any): void => { }, ['a']) + .example("ex1", "desc") + .examples([ + { + usage: "ex2", + description: "desc", + }, + ]); + +args.parse(['~/bin/node', '~/dir', 'arg', '--param'], { + help: true, + name: "name", + version: true, + usageFilter: (a: any): any => a, + value: "value", + mri: { + args: ['a'], + alias: { + a: "b", + c: ['d'], + }, + boolean: ['wat'], + default: { + foo: 'bar', + }, + string: ['zulu'], + unknown: (param: string): boolean => true, + }, + minimist: { + string: ['string'], + boolean: ['string'], + alias: { + bar: 'foo', + foo: ['bar1', 'bar2'], + }, + default: { + foo: 'bar', + }, + stopEarly: true, + "--": false, + unknown: (param: string): boolean => true, + }, + mainColor: "yellow", + subColor: "dim" +}); + +args.showHelp(); + +const x: string = args.sub[0]; diff --git a/types/args/index.d.ts b/types/args/index.d.ts new file mode 100644 index 0000000000..4e77da737b --- /dev/null +++ b/types/args/index.d.ts @@ -0,0 +1,87 @@ +declare var args: Args.API; +export = args; + +declare namespace Args { + export interface IMriUnknownFunction { + (param: string): boolean + } + + export interface IMinimistUnknownFunction { + (param: string): boolean + } + + export interface IMriArguments { + args?: string[]; + alias?: { + [key: string]: string | string[] + }; + boolean?: string | string[]; + default?: { + [key: string]: any + }; + string?: string | string[]; + unknown?: IMriUnknownFunction; + } + + export interface IMinimistArguments { + string?: string | string[]; + boolean?: boolean | string | string[]; + alias?: { + [key: string]: string | string[] + }; + default?: { + [key: string]: any + }; + stopEarly?: boolean; + "--"?: boolean; + unknown?: IMinimistUnknownFunction; + } + + export interface IOptionInitFunction { + (value: any): any; + } + + export interface ICommandInitFunction { + (name: string, sub: {}[], options: {}[]): void; + } + + export interface IUsageFilterFunction { + (output: any): any; + } + + export interface IConfiguration { + help?: boolean; + name?: string; + version?: boolean; + usageFilter?: IUsageFilterFunction; + value?: string; + mri: IMriArguments; + minimist?: IMinimistArguments; + mainColor: string | string[]; + subColor: string | string[]; + } + + export interface IOption { + name: string; + description: string; + init?: IOptionInitFunction; + defaultValue?: any; + } + + export interface IExample { + usage: string; + description: string; + } + + export interface API { + sub: string[]; + + option(name: string | [string, string], description: string, defaultValue?: any, init?: IOptionInitFunction): API; + options(list: IOption[]): API; + command(name: string, description: string, init?: ICommandInitFunction, aliases?: string[]): API; + example(usage: string, description: string): API; + examples(list: IExample[]): API; + parse(argv: string[], options?: IConfiguration): { [key: string]: any }; + showHelp(): void; + } +} diff --git a/types/args/tsconfig.json b/types/args/tsconfig.json new file mode 100644 index 0000000000..ccc4d54297 --- /dev/null +++ b/types/args/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "args-tests.ts" + ] +} diff --git a/types/args/tslint.json b/types/args/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/args/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 17e36b8576cddb120ed2e5c974c1619a24de6870 Mon Sep 17 00:00:00 2001 From: Edward Sammut Alessi Date: Thu, 26 Oct 2017 18:46:27 +0200 Subject: [PATCH 031/352] Updates to follow guidelines --- types/args/index.d.ts | 142 ++++++++++++++++++--------------------- types/args/tsconfig.json | 3 +- 2 files changed, 68 insertions(+), 77 deletions(-) diff --git a/types/args/index.d.ts b/types/args/index.d.ts index 4e77da737b..b6048d2c5f 100644 --- a/types/args/index.d.ts +++ b/types/args/index.d.ts @@ -1,87 +1,77 @@ -declare var args: Args.API; +// Type definitions for args 3.0 +// Project: https://github.com/leo/args#readme +// Definitions by: Slessi +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + export = args; -declare namespace Args { - export interface IMriUnknownFunction { - (param: string): boolean - } +declare namespace args { + let sub: string[]; - export interface IMinimistUnknownFunction { - (param: string): boolean - } + function option(name: string | [string, string], description: string, defaultValue?: any, init?: OptionInitFunction): typeof args; + function options(list: Option[]): typeof args; + function command(name: string, description: string, init?: CommandInitFunction, aliases?: string[]): typeof args; + function example(usage: string, description: string): typeof args; + function examples(list: Example[]): typeof args; + function parse(argv: string[], options?: ConfigurationOptions): { [key: string]: any }; + function showHelp(): void; +} - export interface IMriArguments { - args?: string[]; - alias?: { - [key: string]: string | string[] - }; - boolean?: string | string[]; - default?: { - [key: string]: any - }; - string?: string | string[]; - unknown?: IMriUnknownFunction; - } +type MriUnknownFunction = (param: string) => boolean; +type MinimistUnknownFunction = (param: string) => boolean; - export interface IMinimistArguments { - string?: string | string[]; - boolean?: boolean | string | string[]; - alias?: { - [key: string]: string | string[] - }; - default?: { - [key: string]: any - }; - stopEarly?: boolean; - "--"?: boolean; - unknown?: IMinimistUnknownFunction; - } +type OptionInitFunction = (value: any) => any; +type CommandInitFunction = (name: string, sub: string[], options: ConfigurationOptions) => void; +type UsageFilterFunction = (output: any) => any; - export interface IOptionInitFunction { - (value: any): any; - } +interface MriOptions { + args?: string[]; + alias?: { + [key: string]: string | string[] + }; + boolean?: string | string[]; + default?: { + [key: string]: any + }; + string?: string | string[]; + unknown?: MriUnknownFunction; +} - export interface ICommandInitFunction { - (name: string, sub: {}[], options: {}[]): void; - } +interface MinimistOptions { + string?: string | string[]; + boolean?: boolean | string | string[]; + alias?: { + [key: string]: string | string[] + }; + default?: { + [key: string]: any + }; + stopEarly?: boolean; + "--"?: boolean; + unknown?: MinimistUnknownFunction; +} - export interface IUsageFilterFunction { - (output: any): any; - } +interface ConfigurationOptions { + help?: boolean; + name?: string; + version?: boolean; + usageFilter?: UsageFilterFunction; + value?: string; + mri: MriOptions; + minimist?: MinimistOptions; + mainColor: string | string[]; + subColor: string | string[]; +} - export interface IConfiguration { - help?: boolean; - name?: string; - version?: boolean; - usageFilter?: IUsageFilterFunction; - value?: string; - mri: IMriArguments; - minimist?: IMinimistArguments; - mainColor: string | string[]; - subColor: string | string[]; - } +interface Option { + name: string; + description: string; + init?: OptionInitFunction; + defaultValue?: any; +} - export interface IOption { - name: string; - description: string; - init?: IOptionInitFunction; - defaultValue?: any; - } - - export interface IExample { - usage: string; - description: string; - } - - export interface API { - sub: string[]; - - option(name: string | [string, string], description: string, defaultValue?: any, init?: IOptionInitFunction): API; - options(list: IOption[]): API; - command(name: string, description: string, init?: ICommandInitFunction, aliases?: string[]): API; - example(usage: string, description: string): API; - examples(list: IExample[]): API; - parse(argv: string[], options?: IConfiguration): { [key: string]: any }; - showHelp(): void; - } +interface Example { + usage: string; + description: string; } diff --git a/types/args/tsconfig.json b/types/args/tsconfig.json index ccc4d54297..d287417769 100644 --- a/types/args/tsconfig.json +++ b/types/args/tsconfig.json @@ -7,6 +7,7 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" @@ -19,4 +20,4 @@ "index.d.ts", "args-tests.ts" ] -} +} \ No newline at end of file From e030d2140c5216ca5824fec7aa78ecf9656c7f7c Mon Sep 17 00:00:00 2001 From: cwmoo740 Date: Thu, 26 Oct 2017 13:38:50 -0400 Subject: [PATCH 032/352] react-autosuggest change theme to allow inline styles --- types/react-autosuggest/index.d.ts | 22 +++++-------------- .../react-autosuggest-tests.tsx | 3 ++- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/types/react-autosuggest/index.d.ts b/types/react-autosuggest/index.d.ts index 9205f63d4c..2d0034fd46 100644 --- a/types/react-autosuggest/index.d.ts +++ b/types/react-autosuggest/index.d.ts @@ -9,6 +9,7 @@ // TypeScript Version: 2.3 import * as React from 'react'; + declare class Autosuggest extends React.Component {} export = Autosuggest; @@ -57,22 +58,11 @@ declare namespace Autosuggest { method: 'click' | 'enter'; } - interface Theme { - container?: string; - containerOpen?: string; - input?: string; - inputOpen?: string; - inputFocused?: string; - suggestionsContainer?: string; - suggestionsContainerOpen?: string; - suggestionsList?: string; - suggestion?: string; - suggestionFirst?: string; - suggestionHighlighted?: string; - sectionContainer?: string; - sectionContainerFirst?: string; - sectionTitle?: string; - } + type ThemeKey = 'container' | 'containerOpen' | 'input' | 'inputOpen' | 'inputFocused' | 'suggestionsContainer' | + 'suggestionsContainerOpen' | 'suggestionsList' | 'suggestion' | 'suggestionFirst' | 'suggestionHighlighted' | + 'sectionContainer' | 'sectionContainerFirst' | 'sectionTitle'; + + type Theme = Partial>; interface AutosuggestProps extends React.Props { suggestions: any[]; diff --git a/types/react-autosuggest/react-autosuggest-tests.tsx b/types/react-autosuggest/react-autosuggest-tests.tsx index c67a5c72ad..23841519e4 100644 --- a/types/react-autosuggest/react-autosuggest-tests.tsx +++ b/types/react-autosuggest/react-autosuggest-tests.tsx @@ -85,7 +85,8 @@ export class ReactAutosuggestBasicTest extends React.Component { const theme = { input: 'themed-input-class', container: 'themed-container-class', - suggestionFocused: 'active' + suggestionFocused: 'active', + sectionTitle: { color: 'blue' } }; return Date: Thu, 26 Oct 2017 12:25:08 -0700 Subject: [PATCH 033/352] express-serve-static-core: Restore compatibility with ts2.1 (#21044) --- types/body-parser/index.d.ts | 2 +- types/express-rate-limit/index.d.ts | 2 +- types/express-serve-static-core/index.d.ts | 17 +++++++---------- types/express-session/index.d.ts | 2 +- types/express/express-tests.ts | 7 +++---- types/express/index.d.ts | 9 ++------- types/i18n/index.d.ts | 2 +- types/koa-morgan/index.d.ts | 2 +- types/morgan/index.d.ts | 2 +- types/multer/index.d.ts | 2 +- types/oauth2-server/index.d.ts | 2 +- types/optics-agent/index.d.ts | 2 +- types/passport-oauth2/index.d.ts | 2 +- types/passport-saml/index.d.ts | 2 +- types/swagger-node-runner/index.d.ts | 2 +- 15 files changed, 24 insertions(+), 33 deletions(-) diff --git a/types/body-parser/index.d.ts b/types/body-parser/index.d.ts index 497f3c8dc7..b4943e8023 100644 --- a/types/body-parser/index.d.ts +++ b/types/body-parser/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/expressjs/body-parser // Definitions by: Santi Albo , Vilic Vane , Jonathan Häberle , Gevik Babakhani , Tomasz Łaziuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.1 /// diff --git a/types/express-rate-limit/index.d.ts b/types/express-rate-limit/index.d.ts index cb0d16ec61..fe8d8e4284 100644 --- a/types/express-rate-limit/index.d.ts +++ b/types/express-rate-limit/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/nfriedly/express-rate-limit // Definitions by: Cyril Schumacher , makepost // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.1 import express = require("express"); diff --git a/types/express-serve-static-core/index.d.ts b/types/express-serve-static-core/index.d.ts index 6d8b771e58..b0e463306d 100644 --- a/types/express-serve-static-core/index.d.ts +++ b/types/express-serve-static-core/index.d.ts @@ -2,6 +2,8 @@ // Project: http://expressjs.com // Definitions by: Boris Yankov , Michał Lytek , Kacper Polak // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + // This extracts the core definitions from express to prevent a circular dependency between express and serve-static /// @@ -174,12 +176,7 @@ interface RequestRanges extends Array { type: string; } interface Errback { (err: Error): void; } -interface Request< - Body = any, - Query = any, - Params = any, - Cookies = any -> extends http.IncomingMessage, Express.Request { +interface Request extends http.IncomingMessage, Express.Request { /** * Return request header. @@ -440,14 +437,14 @@ interface Request< xhr: boolean; //body: { username: string; password: string; remember: boolean; title: string; }; - body: Body; + body: any; //cookies: { string; remember: boolean; }; - cookies: Cookies; + cookies: any; method: string; - params: Params; + params: any; /** * Clear cookie `name`. @@ -457,7 +454,7 @@ interface Request< */ clearCookie(name: string, options?: any): Response; - query: Query; + query: any; route: any; diff --git a/types/express-session/index.d.ts b/types/express-session/index.d.ts index 8c5faa7873..be289b9940 100644 --- a/types/express-session/index.d.ts +++ b/types/express-session/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Hiroki Horiuchi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Definitions by: Jacob Bogers diff --git a/types/express/express-tests.ts b/types/express/express-tests.ts index d578a24886..0c1081b49b 100644 --- a/types/express/express-tests.ts +++ b/types/express/express-tests.ts @@ -17,10 +17,9 @@ namespace express_tests { next(); }); - app.use((err: any, req: express.Request<{ hello: string; }>, res: express.Response, next: express.NextFunction) => { - console.log(req.body.hello); - console.error(err); - next(err); + app.use((err: any, req: express.Request, res: express.Response, next: express.NextFunction) => { + console.error(err); + next(err); }); app.get('/', (req, res) => { diff --git a/types/express/index.d.ts b/types/express/index.d.ts index 66bf4180c8..59f60e92df 100644 --- a/types/express/index.d.ts +++ b/types/express/index.d.ts @@ -2,7 +2,7 @@ // Project: http://expressjs.com // Definitions by: Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.2 /* =================== USAGE =================== @@ -76,12 +76,7 @@ declare namespace e { interface IRouterMatcher extends core.IRouterMatcher { } interface MediaType extends core.MediaType { } interface NextFunction extends core.NextFunction { } - interface Request< - Body = any, - Query = any, - Params = any, - Cookies = any - > extends core.Request { } + interface Request extends core.Request { } interface RequestHandler extends core.RequestHandler { } interface RequestParamHandler extends core.RequestParamHandler { } export interface Response extends core.Response { } diff --git a/types/i18n/index.d.ts b/types/i18n/index.d.ts index 0ddc39ffbf..6ed7e9fb8a 100644 --- a/types/i18n/index.d.ts +++ b/types/i18n/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Maxime LUCE // FindQ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.1 declare namespace i18n { interface ConfigurationOptions { diff --git a/types/koa-morgan/index.d.ts b/types/koa-morgan/index.d.ts index f52baa788c..b4be38122b 100644 --- a/types/koa-morgan/index.d.ts +++ b/types/koa-morgan/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/koa-modules/morgan // Definitions by: Vesa Poikajärvi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.1 import { IncomingMessage, ServerResponse } from 'http'; import * as Koa from 'koa'; diff --git a/types/morgan/index.d.ts b/types/morgan/index.d.ts index 1558f24ee4..097758465a 100644 --- a/types/morgan/index.d.ts +++ b/types/morgan/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: James Roland Cabresos // Paolo Scanferla // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.2 import express = require('express'); diff --git a/types/multer/index.d.ts b/types/multer/index.d.ts index 5c300a5585..d6e73f9ddf 100644 --- a/types/multer/index.d.ts +++ b/types/multer/index.d.ts @@ -6,7 +6,7 @@ // Michael Ledin // HyunSeob Lee // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.1 import * as express from 'express'; diff --git a/types/oauth2-server/index.d.ts b/types/oauth2-server/index.d.ts index 93e3e9398b..44d158690a 100644 --- a/types/oauth2-server/index.d.ts +++ b/types/oauth2-server/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Robbie Van Gorkom , // Charles Irick // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.1 import { Request, RequestHandler } from "express"; diff --git a/types/optics-agent/index.d.ts b/types/optics-agent/index.d.ts index 496437994f..b4c171bdd8 100644 --- a/types/optics-agent/index.d.ts +++ b/types/optics-agent/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/apollostack/optics-agent-js#readme // Definitions by: Crevil // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.1 import { GraphQLSchema } from "graphql"; import { Request, Response } from "express"; diff --git a/types/passport-oauth2/index.d.ts b/types/passport-oauth2/index.d.ts index 09facb2ef7..6be0c6ad44 100644 --- a/types/passport-oauth2/index.d.ts +++ b/types/passport-oauth2/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/jaredhanson/passport-oauth2#readme // Definitions by: Pasi Eronen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.2 import { Request } from 'express'; import { Strategy } from 'passport'; diff --git a/types/passport-saml/index.d.ts b/types/passport-saml/index.d.ts index e93869ca87..930a05dbfe 100644 --- a/types/passport-saml/index.d.ts +++ b/types/passport-saml/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/bergie/passport-saml // Definitions by: Chris Barth // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.1 import passport = require('passport'); import express = require('express'); diff --git a/types/swagger-node-runner/index.d.ts b/types/swagger-node-runner/index.d.ts index 89af13679d..92ee7919dd 100644 --- a/types/swagger-node-runner/index.d.ts +++ b/types/swagger-node-runner/index.d.ts @@ -2,7 +2,7 @@ // Project: https://www.npmjs.com/package/swagger-node-runner // Definitions by: Michael Mrowetz // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.2 /* =================== USAGE =================== From 11ac6579bcb8bfb74e4af61660b206c67dd1833c Mon Sep 17 00:00:00 2001 From: Marc-Andre Roy Date: Thu, 26 Oct 2017 16:44:04 -0400 Subject: [PATCH 034/352] Add typings for guid npm package. --- types/guid/guid-tests.ts | 5 +++++ types/guid/index.d.ts | 38 ++++++++++++++++++++++++++++++++++++++ types/guid/tsconfig.json | 22 ++++++++++++++++++++++ types/guid/tslint.json | 1 + 4 files changed, 66 insertions(+) create mode 100644 types/guid/guid-tests.ts create mode 100644 types/guid/index.d.ts create mode 100644 types/guid/tsconfig.json create mode 100644 types/guid/tslint.json diff --git a/types/guid/guid-tests.ts b/types/guid/guid-tests.ts new file mode 100644 index 0000000000..cb5008d2a2 --- /dev/null +++ b/types/guid/guid-tests.ts @@ -0,0 +1,5 @@ +import guid = require('guid'); + +const newRawGuid: string = guid.raw(); +const isAGuid: boolean = guid.isGuid(newRawGuid); +const newGuidObject: object = guid.create(); diff --git a/types/guid/index.d.ts b/types/guid/index.d.ts new file mode 100644 index 0000000000..210a1f9584 --- /dev/null +++ b/types/guid/index.d.ts @@ -0,0 +1,38 @@ +// Type definitions for guid 1.0 +// Project: https://github.com/dandean/guid +// Definitions by: Marc-Andre Roy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** Declaration file generated by dts-gen */ + +export = guid; + +declare function guid(guid: string | guid): any; + +declare namespace guid { + const EMPTY: string; + + const prototype: { + }; + + function create(): object; + + function isGuid(value: string): boolean; + + function raw(): string; + + namespace create { + const prototype: { + }; + } + + namespace isGuid { + const prototype: { + }; + } + + namespace raw { + const prototype: { + }; + } +} diff --git a/types/guid/tsconfig.json b/types/guid/tsconfig.json new file mode 100644 index 0000000000..5d335b8f70 --- /dev/null +++ b/types/guid/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "guid-tests.ts" + ] +} diff --git a/types/guid/tslint.json b/types/guid/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/guid/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From ff0e6eb19af0d2b7f22c064f1f08cd126595f8b3 Mon Sep 17 00:00:00 2001 From: Jacob Copeland Date: Thu, 26 Oct 2017 23:52:51 -0400 Subject: [PATCH 035/352] Updated type definitions for email-templates for v3.1 --- .../email-templates/email-templates-tests.ts | 37 +--- types/email-templates/index.d.ts | 204 ++++++------------ 2 files changed, 79 insertions(+), 162 deletions(-) diff --git a/types/email-templates/email-templates-tests.ts b/types/email-templates/email-templates-tests.ts index 3c4493402c..c36852de31 100644 --- a/types/email-templates/email-templates-tests.ts +++ b/types/email-templates/email-templates-tests.ts @@ -1,29 +1,14 @@ -import EmailTemplates = require('email-templates'); +import * as Email from 'email-templates'; -const EmailTemplate = EmailTemplates.EmailTemplate; -const template = new EmailTemplate("./"); -const templateWithOptions = new EmailTemplate('./', {disableJuice: true, sassOptions: {}, juiceOptions: {}}); -const users = [ - { - email: 'pappa.pizza@spaghetti.com', - name: { - first: 'Pappa', - last: 'Pizza' - } +const email = new Email.EmailTemplate({ + message: { + from: 'Test@tesitng.com' }, - { - email: 'mister.geppetto@spaghetti.com', - name: { - first: 'Mister', - last: 'Geppetto' - } - } -]; + transport: { + jsonTransport: true + }} +); -const templates = users.map((user) => { - return template.render(user) - .then((results) => { - const {html, subject, text} = results; - return html; - }); -}); +email.juiceResources('

    bob

    '); +email.render('mars/html.pug', {name: 'elon'}); +email.send({template: 'mars', message: {to: 'elon@spacex.com'}, locals: {name: 'Elon'}}); diff --git a/types/email-templates/index.d.ts b/types/email-templates/index.d.ts index d76c23aed3..bb6a3321c7 100644 --- a/types/email-templates/index.d.ts +++ b/types/email-templates/index.d.ts @@ -1,152 +1,84 @@ -// Type definitions for node-email-templates 2.6 +// Type definitions for node-email-templates 3.1 // Project: https://github.com/niftylettuce/node-email-templates // Definitions by: Cyril Schumacher // Matus Gura +// Jacob Copeland // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/** - * @summary Interface for result of email template. - * @interface - */ -interface EmailTemplateResults { +export interface EmailConfig { /** - * @summary HTML result. - * @type {string} + * The message */ - html: string; - + message: any; /** - * @summary Text result. - * @type {string} + * The nodemailer Transport created via nodemailer.createTransport */ - text: string; - + transport: any; /** - * @summary Subject result. - * @type {string} + * The email template directory and engine information */ - subject: string; + views?: any; + /** + * Do you really want to send, false for test or development + */ + send?: boolean; + /** + * Preview the email + */ + preview?: boolean; + /** + * Set to object to configure and Enable + */ + i18n?: any; + /** + * Pass a custom render function if necessary + */ + render?: { view: string, locals: any }; + /** + * + */ + htmlToText?: any; + /** + * + */ + juice?: boolean; + /** + * + */ + juiceResources?: any; } -/** - * @summary Callback signature. - */ -type EmailTemplateCallback = (err: any, results: EmailTemplateResults) => void; - -/** - * @summary Interface for email-template options - * @interface - */ -interface EmailTemplateOptions { - disableJuice?: boolean; - juiceOptions?: any; - sassOptions?: any; -} - -declare module "email-templates" { +export interface EmailOptions { /** - * @summary Email template class. - * @class + * The template name */ - class EmailTemplate { - /** - * @summary Constructor. - * @param {string} templateDir The template directory. - */ - constructor(templateDir: string, options?: EmailTemplateOptions); - - /** - * @summary Render a single template. - * @param locals The template variables. - * @param locale The language code. - */ - render(locals: any, locale?: string): Promise; - - /** - * @summary Render a single template. - * @param callback The callback function. - */ - render(callback: EmailTemplateCallback): void; - - /** - * @summary Render a single template. - * @param locals The template variables. - * @param callback The callback function. - */ - render(locals: any, callback: EmailTemplateCallback): void; - - /** - * @summary Render a single template. - * @param locals The template variables. - * @param locale The language code. - * @param callback The callback function. - */ - render(locals: any, locale: string, callback: EmailTemplateCallback): void; - - /** - * @summary Render text - * @param locals The template variables. - * @param locale The language code. - */ - renderText(locals: any, locale?: string): Promise; - - /** - * @summary Render text - * @param locals The template variables. - * @param callback The language code. - */ - renderText(locals: any, callback: EmailTemplateCallback): void; - - /** - * @summary Render text - * @param locals The template variables. - * @param locale The language code. - * @param callback The language code. - */ - renderText(locals: any, locale: string, callback: EmailTemplateCallback): void; - - /** - * @summary Render subject - * @param locals The template variables. - * @param locale The language code. - */ - renderSubject(locals: any, locale?: string): Promise; - - /** - * @summary Render subject - * @param locals The template variables. - * @param callback The language code. - */ - renderSubject(locals: any, callback: EmailTemplateCallback): void; - - /** - * @summary Render subject - * @param locals The template variables. - * @param locale The language code. - * @param callback The language code. - */ - renderSubject(locals: any, locale: string, callback: EmailTemplateCallback): void; - - /** - * @summary Render HTML - * @param locals The template variables. - * @param locale The language code. - */ - renderHtml(locals: any, locale?: string): Promise; - - /** - * @summary Render HTML - * @param locals The template variables. - * @param callback The language code. - */ - renderHtml(locals: any, callback: EmailTemplateCallback): void; - - /** - * @summary Render HTML - * @param locals The template variables. - * @param locale The language code. - * @param callback The language code. - */ - renderHtml(locals: any, locale: string, callback: EmailTemplateCallback): void; - } + template: string; + /** + * Nodemailer Message + */ + message: any; + /** + * The Template Variables + */ + locals: any; +} + +export class EmailTemplate { + constructor(config: EmailConfig); + + /** + * shorthand use of `juiceResources` with the config + * mainly for custom renders like from a database). + */ + juiceResources(html: string): Promise ; + + /** + * Render the Email, Used by send, but can be called by itself. + */ + render(view: string, locals: any): Promise; + + /** + * Send the Email. + */ + send(options: EmailOptions): any; } From aef155f339f6c8e446cf1245440041a3d01afc3c Mon Sep 17 00:00:00 2001 From: Vlad Rindevich Date: Fri, 27 Oct 2017 12:10:26 +0700 Subject: [PATCH 036/352] feat(react-tabs): export props for every component --- types/react-tabs/index.d.ts | 83 +++++++++++----------------- types/react-tabs/react-tabs-tests.ts | 16 +++++- 2 files changed, 46 insertions(+), 53 deletions(-) diff --git a/types/react-tabs/index.d.ts b/types/react-tabs/index.d.ts index 02344cf8b1..a4a528046a 100644 --- a/types/react-tabs/index.d.ts +++ b/types/react-tabs/index.d.ts @@ -6,59 +6,38 @@ import * as React from 'react'; -export as namespace ReactTabs; - -declare namespace ReactTabs { - - interface TabsProps { - className?: string | Array | { [name: string]: boolean; }; - defaultFocus?: boolean; - defaultIndex?: number; - disabledTabClassName?: string; - forceRenderTabPanel?: boolean; - onSelect?: (index: number, last: number, event: Event) => boolean | void; - selectedIndex?: number; - selectedTabClassName?: string; - selectedTabPanelClassName?: string; - } - - interface Tabs extends React.ComponentClass {} - - interface TabListProps { - className?: string | Array | { [name: string]: boolean; }; - } - - interface TabList extends React.ComponentClass {} - - interface TabProps { - className?: string | Array | { [name: string]: boolean; }; - disabled?: boolean; - disabledClassName?: string; - selectedClassName?: string; - } - - interface Tab extends React.ComponentClass {} - - interface TabPanelProps { - className?: string | Array | { [name: string]: boolean; }; - forceRender?: boolean; - selectedClassName?: string; - } - - interface TabPanel extends React.ComponentClass {} +export interface TabsProps { + className?: string | Array | { [name: string]: boolean; }; + defaultFocus?: boolean; + defaultIndex?: number; + disabledTabClassName?: string; + forceRenderTabPanel?: boolean; + onSelect?: (index: number, last: number, event: Event) => boolean | void; + selectedIndex?: number; + selectedTabClassName?: string; + selectedTabPanelClassName?: string; } -declare const Tabs: ReactTabs.Tabs; -declare const TabList: ReactTabs.TabList; -declare const Tab: ReactTabs.Tab; -declare const TabPanel: ReactTabs.TabPanel; +export interface TabListProps { + className?: string | Array | { [name: string]: boolean; }; +} -declare function resetIdCounter(): void; +export interface TabProps { + className?: string | Array | { [name: string]: boolean; }; + disabled?: boolean; + disabledClassName?: string; + selectedClassName?: string; +} -export { - Tabs, - TabList, - Tab, - TabPanel, - resetIdCounter -}; +export interface TabPanelProps { + className?: string | Array | { [name: string]: boolean; }; + forceRender?: boolean; + selectedClassName?: string; +} + +export declare class Tabs extends React.Component {} +export declare class TabList extends React.Component {} +export declare class Tab extends React.Component {} +export declare class TabPanel extends React.Component {} + +export declare function resetIdCounter(): void; diff --git a/types/react-tabs/react-tabs-tests.ts b/types/react-tabs/react-tabs-tests.ts index f726780dcb..a7b86de6e0 100644 --- a/types/react-tabs/react-tabs-tests.ts +++ b/types/react-tabs/react-tabs-tests.ts @@ -1,9 +1,23 @@ import * as React from "react"; import * as ReactDOM from "react-dom"; -import { Tabs, TabList, Tab, TabPanel, resetIdCounter } from "react-tabs"; +import { + Tabs, + TabsProps, + TabList, + TabListProps, + Tab, + TabProps, + TabPanel, + TabPanelProps, + resetIdCounter } from "react-tabs"; resetIdCounter(); +interface TestTabProps extends TabProps {} +interface TestTabListProps extends TabListProps {} +interface TestTabPanelProps extends TabPanelProps {} +interface TestTabsProps extends TabsProps {} + class TestApp extends React.Component { onSelect = (index: number, last: number, event: Event) => { console.log("selected tab: " + index.toString()); From a83743d071bcad41dee30cfa07ffc7f59c116699 Mon Sep 17 00:00:00 2001 From: segayuu Date: Fri, 27 Oct 2017 14:25:44 +0900 Subject: [PATCH 037/352] [WIP] cleanup lint error: max-line-length(490->280) --- types/bluebird/index.d.ts | 282 +++++++++++++++++++++++++++++-------- types/bluebird/tslint.json | 2 +- 2 files changed, 223 insertions(+), 61 deletions(-) diff --git a/types/bluebird/index.d.ts b/types/bluebird/index.d.ts index 9046d082fb..ba7a8bd172 100644 --- a/types/bluebird/index.d.ts +++ b/types/bluebird/index.d.ts @@ -43,14 +43,21 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { constructor(callback: (resolve: (thenableOrResult?: R | PromiseLike) => void, reject: (error?: any) => void, onCancel?: (callback: () => void) => void) => void); /** - * Promises/A+ `.then()`. Returns a new promise chained from this promise. The new promise will be rejected or resolved dedefer on the passed `fulfilledHandler`, `rejectedHandler` and the state of this promise. + * Promises/A+ `.then()`. Returns a new promise chained from this promise. + * + * The new promise will be rejected or resolved dedefer on the passed `fulfilledHandler`, `rejectedHandler` and the state of this promise. */ // Based on PromiseLike.then, but returns a Bluebird instance. then(onFulfill?: (value: R) => U | PromiseLike, onReject?: (error: any) => U | PromiseLike): Bluebird; // For simpler signature help. - then(onfulfilled?: ((value: R) => TResult1 | PromiseLike) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | null): Bluebird; + then( + onfulfilled?: ((value: R) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: any) => TResult2 | PromiseLike) | null + ): Bluebird; /** - * This is a catch-all exception handler, shortcut for calling `.then(null, handler)` on this promise. Any exception happening in a `.then`-chain will propagate to nearest `.catch` handler. + * This is a catch-all exception handler, shortcut for calling `.then(null, handler)` on this promise. + * + * Any exception happening in a `.then`-chain will propagate to nearest `.catch` handler. * * Alias `.caught();` for compatibility with earlier ECMAScript version. */ @@ -58,9 +65,15 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { catch(onReject: ((error: any) => U | PromiseLike) | undefined | null): Bluebird; /** - * This extends `.catch` to work more like catch-clauses in languages like Java or C#. Instead of manually checking `instanceof` or `.name === "SomeError"`, you may specify a number of error constructors which are eligible for this catch handler. The catch handler that is first met that has eligible constructors specified, is the one that will be called. + * This extends `.catch` to work more like catch-clauses in languages like Java or C#. * - * This method also supports predicate-based filters. If you pass a predicate function instead of an error constructor, the predicate will receive the error as an argument. The return result of the predicate will be used determine whether the error handler should be called. + * Instead of manually checking `instanceof` or `.name === "SomeError"`, + * you may specify a number of error constructors which are eligible for this catch handler. + * The catch handler that is first met that has eligible constructors specified, is the one that will be called. + * + * This method also supports predicate-based filters. + * If you pass a predicate function instead of an error constructor, the predicate will receive the error as an argument. + * The return result of the predicate will be used determine whether the error handler should be called. * * Alias `.caught();` for compatibility with earlier ECMAScript version. */ @@ -190,7 +203,9 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { ): Bluebird; /** - * This is a catch-all exception handler, shortcut for calling `.then(null, handler)` on this promise. Any exception happening in a `.then`-chain will propagate to nearest `.catch` handler. + * This is a catch-all exception handler, shortcut for calling `.then(null, handler)` on this promise. + * + * Any exception happening in a `.then`-chain will propagate to nearest `.catch` handler. * * Alias `.caught();` for compatibility with earlier ECMAScript version. */ @@ -198,9 +213,13 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { caught(onReject: ((error: any) => U | PromiseLike) | undefined | null): Bluebird; /** - * This extends `.catch` to work more like catch-clauses in languages like Java or C#. Instead of manually checking `instanceof` or `.name === "SomeError"`, you may specify a number of error constructors which are eligible for this catch handler. The catch handler that is first met that has eligible constructors specified, is the one that will be called. + * This extends `.catch` to work more like catch-clauses in languages like Java or C#. * - * This method also supports predicate-based filters. If you pass a predicate function instead of an error constructor, the predicate will receive the error as an argument. The return result of the predicate will be used determine whether the error handler should be called. + * Instead of manually checking `instanceof` or `.name === "SomeError"`, you may specify a number of error constructors which are eligible for this catch handler. + * The catch handler that is first met that has eligible constructors specified, is the one that will be called. + * + * This method also supports predicate-based filters. If you pass a predicate function instead of an error constructor, the predicate will receive the error as an argument. + * The return result of the predicate will be used determine whether the error handler should be called. * * Alias `.caught();` for compatibility with earlier ECMAScript version. */ @@ -335,7 +354,9 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { error(onReject: (reason: any) => U | PromiseLike): Bluebird; /** - * Pass a handler that will be called regardless of this promise's fate. Returns a new promise chained from this promise. There are special semantics for `.finally()` in that the final value cannot be modified from the handler. + * Pass a handler that will be called regardless of this promise's fate. Returns a new promise chained from this promise. + * + * There are special semantics for `.finally()` in that the final value cannot be modified from the handler. * * Alias `.lastly();` for compatibility with earlier ECMAScript version. */ @@ -344,7 +365,9 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { lastly(handler: () => U | PromiseLike): Bluebird; /** - * Create a promise that follows this promise, but is bound to the given `thisArg` value. A bound promise will call its handlers with the bound value set to `this`. Additionally promises derived from a bound promise will also be bound promises with the same `thisArg` binding as the original promise. + * Create a promise that follows this promise, but is bound to the given `thisArg` value. A bound promise will call its handlers with the bound value set to `this`. + * + * Additionally promises derived from a bound promise will also be bound promises with the same `thisArg` binding as the original promise. */ bind(thisArg: any): Bluebird; @@ -409,7 +432,11 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { timeout(ms: number, message?: string | Error): Bluebird; /** - * Register a node-style callback on this promise. When this promise is is either fulfilled or rejected, the node callback will be called back with the node.js convention where error reason is the first argument and success value is the second argument. The error argument will be `null` in case of success. + * Register a node-style callback on this promise. + * + * When this promise is is either fulfilled or rejected, + * the node callback will be called back with the node.js convention where error reason is the first argument and success value is the second argument. + * The error argument will be `null` in case of success. * If the `callback` argument is not a function, this method does not do anything. */ nodeify(callback: (err: any, value?: R) => void, options?: Bluebird.SpreadOption): this; @@ -694,7 +721,8 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { /** * Start the chain of promises with `Promise.try`. Any synchronous exceptions will be turned into rejections on the returned promise. * - * Note about second argument: if it's specifically a true array, its values become respective arguments for the function call. Otherwise it is passed as is as the first argument for the function call. + * Note about second argument: if it's specifically a true array, its values become respective arguments for the function call. + * Otherwise it is passed as is as the first argument for the function call. * * Alias for `attempt();` for compatibility with earlier ECMAScript version. */ @@ -702,7 +730,8 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { static attempt(fn: () => R | PromiseLike): Bluebird; /** - * Returns a new function that wraps the given function `fn`. The new function will always return a promise that is fulfilled with the original functions return values or rejected with thrown exceptions from the original function. + * Returns a new function that wraps the given function `fn`. + * The new function will always return a promise that is fulfilled with the original functions return values or rejected with thrown exceptions from the original function. * This method is convenient when a function can sometimes return synchronously or throw synchronously. */ static method(fn: (arg1: A1) => R | PromiseLike): (arg1: A1) => Bluebird; @@ -729,7 +758,10 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { static defer(): Bluebird.Resolver; /** - * Cast the given `value` to a trusted promise. If `value` is already a trusted `Promise`, it is returned as is. If `value` is not a thenable, a fulfilled is: Promise returned with `value` as its fulfillment value. If `value` is a thenable (Promise-like object, like those returned by jQuery's `$.ajax`), returns a trusted that: Promise assimilates the state of the thenable. + * Cast the given `value` to a trusted promise. + * + * If `value` is already a trusted `Promise`, it is returned as is. If `value` is not a thenable, a fulfilled is: Promise returned with `value` as its fulfillment value. + * If `value` is a thenable (Promise-like object, like those returned by jQuery's `$.ajax`), returns a trusted that: Promise assimilates the state of the thenable. */ static cast(value: R | PromiseLike): Bluebird; @@ -744,7 +776,10 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { static is(value: any): boolean; /** - * Call this right after the library is loaded to enabled long stack traces. Long stack traces cannot be disabled after being enabled, and cannot be enabled after promises have already been created. Long stack traces imply a substantial performance penalty, around 4-5x for throughput and 0.5x for latency. + * Call this right after the library is loaded to enabled long stack traces. + * + * Long stack traces cannot be disabled after being enabled, and cannot be enabled after promises have already been created. + * Long stack traces imply a substantial performance penalty, around 4-5x for throughput and 0.5x for latency. */ static longStackTraces(): void; @@ -757,24 +792,49 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { static delay(ms: number): Bluebird; /** - * Returns a function that will wrap the given `nodeFunction`. Instead of taking a callback, the returned function will return a promise whose fate is decided by the callback behavior of the given node function. The node function should conform to node.js convention of accepting a callback as last argument and calling that callback with error as the first argument and success value on the second argument. + * Returns a function that will wrap the given `nodeFunction`. + * + * Instead of taking a callback, the returned function will return a promise whose fate is decided by the callback behavior of the given node function. + * The node function should conform to node.js convention of accepting a callback as last argument and + * calling that callback with error as the first argument and success value on the second argument. * * If the `nodeFunction` calls its callback with multiple success values, the fulfillment value will be an array of them. * * If you pass a `receiver`, the `nodeFunction` will be called as a method on the `receiver`. */ - static promisify(func: (callback: (err: any, result?: T) => void) => void, options?: Bluebird.PromisifyOptions): () => Bluebird; - static promisify(func: (arg1: A1, callback: (err: any, result?: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1) => Bluebird; - static promisify(func: (arg1: A1, arg2: A2, callback: (err: any, result?: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1, arg2: A2) => Bluebird; - static promisify(func: (arg1: A1, arg2: A2, arg3: A3, callback: (err: any, result?: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1, arg2: A2, arg3: A3) => Bluebird; - static promisify(func: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, callback: (err: any, result?: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1, arg2: A2, arg3: A3, arg4: A4) => Bluebird; - static promisify(func: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5, callback: (err: any, result?: T) => void) => void, options?: Bluebird.PromisifyOptions): (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => Bluebird; + static promisify( + func: (callback: (err: any, result?: T) => void) => void, + options?: Bluebird.PromisifyOptions + ): () => Bluebird; + static promisify( + func: (arg1: A1, callback: (err: any, result?: T) => void) => void, + options?: Bluebird.PromisifyOptions + ): (arg1: A1) => Bluebird; + static promisify( + func: (arg1: A1, arg2: A2, callback: (err: any, result?: T) => void) => void, + options?: Bluebird.PromisifyOptions + ): (arg1: A1, arg2: A2) => Bluebird; + static promisify( + func: (arg1: A1, arg2: A2, arg3: A3, callback: (err: any, result?: T) => void) => void, + options?: Bluebird.PromisifyOptions + ): (arg1: A1, arg2: A2, arg3: A3) => Bluebird; + static promisify( + func: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, callback: (err: any, result?: T) => void) => void, + options?: Bluebird.PromisifyOptions + ): (arg1: A1, arg2: A2, arg3: A3, arg4: A4) => Bluebird; + static promisify( + func: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5, callback: (err: any, result?: T) => void) => void, + options?: Bluebird.PromisifyOptions + ): (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => Bluebird; static promisify(nodeFunction: (...args: any[]) => void, options?: Bluebird.PromisifyOptions): (...args: any[]) => Bluebird; /** - * Promisifies the entire object by going through the object's properties and creating an async equivalent of each function on the object and its prototype chain. The promisified method name will be the original method name postfixed with `Async`. Returns the input object. + * Promisifies the entire object by going through the object's properties and creating an async equivalent of each function on the object and its prototype chain. * - * Note that the original methods on the object are not overwritten but new methods are created with the `Async`-postfix. For example, if you `promisifyAll()` the node.js `fs` object use `fs.statAsync()` to call the promisified `stat` method. + * The promisified method name will be the original method name postfixed with `Async`. Returns the input object. + * + * Note that the original methods on the object are not overwritten but new methods are created with the `Async`-postfix. For example, + * if you `promisifyAll()` the node.js `fs` object use `fs.statAsync()` to call the promisified `stat` method. */ // TODO how to model promisifyAll? static promisifyAll(target: T, options?: Bluebird.PromisifyAllOptions): T; @@ -788,19 +848,49 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { static fromCallback(resolver: (callback: (err: any, result?: T) => void) => void, options?: Bluebird.FromNodeOptions): Bluebird; /** - * Returns a function that can use `yield` to run asynchronous code synchronously. This feature requires the support of generators which are drafted in the next version of the language. Node version greater than `0.11.2` is required and needs to be executed with the `--harmony-generators` (or `--harmony`) command-line switch. + * Returns a function that can use `yield` to run asynchronous code synchronously. + * + * This feature requires the support of generators which are drafted in the next version of the language. + * Node version greater than `0.11.2` is required and needs to be executed with the `--harmony-generators` (or `--harmony`) command-line switch. */ // TODO: After https://github.com/Microsoft/TypeScript/issues/2983 is implemented, we can use // the return type propagation of generators to automatically infer the return type T. - static coroutine(generatorFunction: () => IterableIterator, options?: Bluebird.CoroutineOptions): () => Bluebird; - static coroutine(generatorFunction: (a1: A1) => IterableIterator, options?: Bluebird.CoroutineOptions): (a1: A1) => Bluebird; - static coroutine(generatorFunction: (a1: A1, a2: A2) => IterableIterator, options?: Bluebird.CoroutineOptions): (a1: A1, a2: A2) => Bluebird; - static coroutine(generatorFunction: (a1: A1, a2: A2, a3: A3) => IterableIterator, options?: Bluebird.CoroutineOptions): (a1: A1, a2: A2, a3: A3) => Bluebird; - static coroutine(generatorFunction: (a1: A1, a2: A2, a3: A3, a4: A4) => IterableIterator, options?: Bluebird.CoroutineOptions): (a1: A1, a2: A2, a3: A3, a4: A4) => Bluebird; - static coroutine(generatorFunction: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5) => IterableIterator, options?: Bluebird.CoroutineOptions): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5) => Bluebird; - static coroutine(generatorFunction: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6) => IterableIterator, options?: Bluebird.CoroutineOptions): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6) => Bluebird; - static coroutine(generatorFunction: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7) => IterableIterator, options?: Bluebird.CoroutineOptions): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7) => Bluebird; - static coroutine(generatorFunction: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8) => IterableIterator, options?: Bluebird.CoroutineOptions): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8) => Bluebird; + static coroutine( + generatorFunction: () => IterableIterator, + options?: Bluebird.CoroutineOptions + ): () => Bluebird; + static coroutine( + generatorFunction: (a1: A1) => IterableIterator, + options?: Bluebird.CoroutineOptions + ): (a1: A1) => Bluebird; + static coroutine( + generatorFunction: (a1: A1, a2: A2) => IterableIterator, + options?: Bluebird.CoroutineOptions + ): (a1: A1, a2: A2) => Bluebird; + static coroutine( + generatorFunction: (a1: A1, a2: A2, a3: A3) => IterableIterator, + options?: Bluebird.CoroutineOptions + ): (a1: A1, a2: A2, a3: A3) => Bluebird; + static coroutine( + generatorFunction: (a1: A1, a2: A2, a3: A3, a4: A4) => IterableIterator, + options?: Bluebird.CoroutineOptions + ): (a1: A1, a2: A2, a3: A3, a4: A4) => Bluebird; + static coroutine( + generatorFunction: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5) => IterableIterator, + options?: Bluebird.CoroutineOptions + ): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5) => Bluebird; + static coroutine( + generatorFunction: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6) => IterableIterator, + options?: Bluebird.CoroutineOptions + ): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6) => Bluebird; + static coroutine( + generatorFunction: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7) => IterableIterator, + options?: Bluebird.CoroutineOptions + ): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7) => Bluebird; + static coroutine( + generatorFunction: (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8) => IterableIterator, + options?: Bluebird.CoroutineOptions + ): (a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8) => Bluebird; /** * Add `handler` as the handler to call when there is a possibly unhandled rejection. The default handler logs the error stack to stderr or `console.error` in browsers. @@ -820,7 +910,9 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { static onPossiblyUnhandledRejection(handler?: (error: Error, promise: Bluebird) => void): void; /** - * Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled when all the items in the array are fulfilled. The promise's fulfillment value is an array with fulfillment values at respective positions to the original array. If any promise in the array rejects, the returned promise is rejected with the rejection reason. + * Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled when all the items in the array are fulfilled. + * The promise's fulfillment value is an array with fulfillment values at respective positions to the original array. + * If any promise in the array rejects, the returned promise is rejected with the rejection reason. */ // TODO enable more overloads // array with promises of different types @@ -833,9 +925,13 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { static all(values: PromiseLike | R>> | Iterable | R>): Bluebird; /** - * Like ``Promise.all`` but for object properties instead of array items. Returns a promise that is fulfilled when all the properties of the object are fulfilled. The promise's fulfillment value is an object with fulfillment values at respective keys to the original object. If any promise in the object rejects, the returned promise is rejected with the rejection reason. + * Like ``Promise.all`` but for object properties instead of array items. Returns a promise that is fulfilled when all the properties of the object are fulfilled. * - * If `object` is a trusted `Promise`, then it will be treated as a promise for object rather than for its properties. All other objects are treated for their properties as is returned by `Object.keys` - the object's own enumerable properties. + * The promise's fulfillment value is an object with fulfillment values at respective keys to the original object. + * If any promise in the object rejects, the returned promise is rejected with the rejection reason. + * + * If `object` is a trusted `Promise`, then it will be treated as a promise for object rather than for its properties. + * All other objects are treated for their properties as is returned by `Object.keys` - the object's own enumerable properties. * * *The original object is not modified.* */ @@ -859,7 +955,8 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { static race(values: PromiseLike | R>> | Iterable | R>): Bluebird; /** - * Initiate a competetive race between multiple promises or values (values will become immediately fulfilled promises). When `count` amount of promises have been fulfilled, the returned promise is fulfilled with an array that contains the fulfillment values of the winners in order of resolution. + * Initiate a competetive race between multiple promises or values (values will become immediately fulfilled promises). + * When `count` amount of promises have been fulfilled, the returned promise is fulfilled with an array that contains the fulfillment values of the winners in order of resolution. * * If too many promises are rejected so that the promise can never become fulfilled, it will be immediately rejected with an array of rejection reasons in the order they were thrown in. * @@ -874,60 +971,112 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { * ) -> Promise * For coordinating multiple concurrent discrete promises. * - * Note: In 1.x and 0.x Promise.join used to be a Promise.all that took the values in as arguments instead in an array. This behavior has been deprecated but is still supported partially - when the last argument is an immediate function value the new semantics will apply + * Note: In 1.x and 0.x Promise.join used to be a Promise.all that took the values in as arguments instead in an array. + * This behavior has been deprecated but is still supported partially - when the last argument is an immediate function value the new semantics will apply */ - static join(arg1: A1 | PromiseLike, handler: (arg1: A1) => R | PromiseLike): Bluebird; - static join(arg1: A1 | PromiseLike, arg2: A2 | PromiseLike, handler: (arg1: A1, arg2: A2) => R | PromiseLike): Bluebird; - static join(arg1: A1 | PromiseLike, arg2: A2 | PromiseLike, arg3: A3 | PromiseLike, handler: (arg1: A1, arg2: A2, arg3: A3) => R | PromiseLike): Bluebird; - static join(arg1: A1 | PromiseLike, arg2: A2 | PromiseLike, arg3: A3 | PromiseLike, arg4: A4 | PromiseLike, handler: (arg1: A1, arg2: A2, arg3: A3, arg4: A4) => R | PromiseLike): Bluebird; - static join(arg1: A1 | PromiseLike, arg2: A2 | PromiseLike, arg3: A3 | PromiseLike, arg4: A4 | PromiseLike, arg5: A5 | PromiseLike, handler: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => R | PromiseLike): Bluebird; + static join( + arg1: A1 | PromiseLike, + handler: (arg1: A1) => R | PromiseLike + ): Bluebird; + static join( + arg1: A1 | PromiseLike, + arg2: A2 | PromiseLike, + handler: (arg1: A1, arg2: A2) => R | PromiseLike + ): Bluebird; + static join( + arg1: A1 | PromiseLike, + arg2: A2 | PromiseLike, + arg3: A3 | PromiseLike, + handler: (arg1: A1, arg2: A2, arg3: A3) => R | PromiseLike + ): Bluebird; + static join( + arg1: A1 | PromiseLike, + arg2: A2 | PromiseLike, + arg3: A3 | PromiseLike, + arg4: A4 | PromiseLike, + handler: (arg1: A1, arg2: A2, arg3: A3, arg4: A4) => R | PromiseLike + ): Bluebird; + static join( + arg1: A1 | PromiseLike, + arg2: A2 | PromiseLike, + arg3: A3 | PromiseLike, + arg4: A4 | PromiseLike, + arg5: A5 | PromiseLike, + handler: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => R | PromiseLike + ): Bluebird; // variadic array /** @deprecated use .all instead */ static join(...values: Array>): Bluebird; /** - * Map an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `mapper` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well. + * Map an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `mapper` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. + * If any promise in the input array is rejected the returned promise is rejected as well. * * If the `mapper` function returns promises or thenables, the returned promise will wait for all the mapped results to be resolved as well. * * *The original array is not modified.* */ - static map(values: PromiseLike | R>> | Iterable | R>, mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike, options?: Bluebird.ConcurrencyOption): Bluebird; + static map( + values: PromiseLike | R>> | Iterable | R>, + mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike, + options?: Bluebird.ConcurrencyOption + ): Bluebird; /** - * Reduce an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `reducer` function with the signature `(total, current, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well. + * Reduce an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `reducer` function with the signature `(total, current, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. + * If any promise in the input array is rejected the returned promise is rejected as well. * * If the reducer function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration. * - * *The original array is not modified. If no `intialValue` is given and the array doesn't contain at least 2 items, the callback will not be called and `undefined` is returned. If `initialValue` is given and the array doesn't have at least 1 item, `initialValue` is returned.* + * *The original array is not modified. If no `intialValue` is given and the array doesn't contain at least 2 items, the callback will not be called and `undefined` is returned. + * If `initialValue` is given and the array doesn't have at least 1 item, `initialValue` is returned.* */ - static reduce(values: PromiseLike | R>> | Iterable | R>, reducer: (total: U, current: R, index: number, arrayLength: number) => U | PromiseLike, initialValue?: U): Bluebird; + static reduce( + values: PromiseLike | R>> | Iterable | R>, + reducer: (total: U, current: R, index: number, arrayLength: number) => U | PromiseLike, + initialValue?: U + ): Bluebird; /** - * Filter an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `filterer` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well. + * Filter an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `filterer` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. + * If any promise in the input array is rejected the returned promise is rejected as well. * * The return values from the filtered functions are coerced to booleans, with the exception of promises and thenables which are awaited for their eventual result. * * *The original array is not modified. */ - static filter(values: PromiseLike | R>> | Iterable | R>, filterer: (item: R, index: number, arrayLength: number) => boolean | PromiseLike, option?: Bluebird.ConcurrencyOption): Bluebird; + static filter( + values: PromiseLike | R>> | Iterable | R>, + filterer: (item: R, index: number, arrayLength: number) => boolean | PromiseLike, + option?: Bluebird.ConcurrencyOption + ): Bluebird; /** - * Iterate over an array, or a promise of an array, which contains promises (or a mix of promises and values) with the given iterator function with the signature (item, index, value) where item is the resolved value of a respective promise in the input array. Iteration happens serially. If any promise in the input array is rejected the returned promise is rejected as well. + * Iterate over an array, or a promise of an array, which contains promises (or a mix of promises and values) with the given iterator function with the signature (item, index, value) where item is the resolved value of a respective promise in the input array. + * Iteration happens serially. If any promise in the input array is rejected the returned promise is rejected as well. * - * Resolves to the original array unmodified, this method is meant to be used for side effects. If the iterator function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration. + * Resolves to the original array unmodified, this method is meant to be used for side effects. + * If the iterator function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration. */ - static each(values: PromiseLike | R>> | Iterable | R>, iterator: (item: R, index: number, arrayLength: number) => U | PromiseLike): Bluebird; + static each( + values: PromiseLike | R>> | Iterable | R>, + iterator: (item: R, index: number, arrayLength: number) => U | PromiseLike + ): Bluebird; /** * Given an Iterable(arrays are Iterable), or a promise of an Iterable, which produces promises (or a mix of promises and values), iterate over all the values in the Iterable into an array and iterate over the array serially, in-order. * - * Returns a promise for an array that contains the values returned by the iterator function in their respective positions. The iterator won't be called for an item until its previous item, and the promise returned by the iterator for that item are fulfilled. This results in a mapSeries kind of utility but it can also be used simply as a side effect iterator similar to Array#forEach. + * Returns a promise for an array that contains the values returned by the iterator function in their respective positions. + * The iterator won't be called for an item until its previous item, and the promise returned by the iterator for that item are fulfilled. + * This results in a mapSeries kind of utility but it can also be used simply as a side effect iterator similar to Array#forEach. * * If any promise in the input array is rejected or any promise returned by the iterator function is rejected, the result will be rejected as well. */ - static mapSeries(values: PromiseLike | R>> | Iterable | R>, iterator: (item: R, index: number, arrayLength: number) => U | PromiseLike): Bluebird; + static mapSeries( + values: PromiseLike | R>> | Iterable | R>, + iterator: (item: R, index: number, arrayLength: number) => U | PromiseLike + ): Bluebird; /** * A meta method used to specify the disposer method that cleans up a resource when using `Promise.using`. @@ -946,9 +1095,21 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { * will be called when the promise returned by the callback passed to using has settled. The disposer is * necessary because there is no standard interface in node for disposing resources. */ - static using(disposer: Bluebird.Disposer, executor: (transaction: R) => PromiseLike): Bluebird; - static using(disposer: Bluebird.Disposer, disposer2: Bluebird.Disposer, executor: (transaction1: R1, transaction2: R2) => PromiseLike): Bluebird; - static using(disposer: Bluebird.Disposer, disposer2: Bluebird.Disposer, disposer3: Bluebird.Disposer, executor: (transaction1: R1, transaction2: R2, transaction3: R3) => PromiseLike): Bluebird; + static using( + disposer: Bluebird.Disposer, + executor: (transaction: R) => PromiseLike + ): Bluebird; + static using( + disposer: Bluebird.Disposer, + disposer2: Bluebird.Disposer, + executor: (transaction1: R1, transaction2: R2 + ) => PromiseLike): Bluebird; + static using( + disposer: Bluebird.Disposer, + disposer2: Bluebird.Disposer, + disposer3: Bluebird.Disposer, + executor: (transaction1: R1, transaction2: R2, transaction3: R3) => PromiseLike + ): Bluebird; /** * Configure long stack traces, warnings, monitoring and cancellation. @@ -1083,7 +1244,8 @@ declare namespace Bluebird { reject(reason: any): void; /** - * Gives you a callback representation of the `PromiseResolver`. Note that this is not a method but a property. The callback accepts error object in first argument and success values on the 2nd parameter and the rest, I.E. node js conventions. + * Gives you a callback representation of the `PromiseResolver`. Note that this is not a method but a property. + * The callback accepts error object in first argument and success values on the 2nd parameter and the rest, I.E. node js conventions. * * If the the callback is called with multiple success values, the resolver fullfills its promise with an array of the values. */ diff --git a/types/bluebird/tslint.json b/types/bluebird/tslint.json index fa9263f910..6abaaba4e3 100644 --- a/types/bluebird/tslint.json +++ b/types/bluebird/tslint.json @@ -1,7 +1,7 @@ { "extends": "dtslint/dt.json", "rules": { - "max-line-length": [true, 490], + "max-line-length": [true, 280], "no-unnecessary-generics": false, "prefer-const": false } From 73890010c2ec5ace2f8ea4c681192ea9db324291 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Fri, 27 Oct 2017 07:57:57 +0200 Subject: [PATCH 038/352] webpack: `moduleTrace` should be a `boolean` --- types/webpack/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/webpack/index.d.ts b/types/webpack/index.d.ts index 819016f70d..31383129d7 100644 --- a/types/webpack/index.d.ts +++ b/types/webpack/index.d.ts @@ -642,7 +642,7 @@ declare namespace webpack { /** Sort the modules by a field */ modulesSort?: string; /** Show dependencies and origin of warnings/errors */ - moduleTrace?: number; + moduleTrace?: boolean; /** Add public path information */ publicPath?: boolean; /** Add information about the reasons why modules are included */ From a33c9d1eed8c65f2ad47ec120c4387d04084493d Mon Sep 17 00:00:00 2001 From: Edward Sammut Alessi Date: Fri, 27 Oct 2017 10:09:58 +0200 Subject: [PATCH 039/352] Fix lint warnings --- types/args/index.d.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/types/args/index.d.ts b/types/args/index.d.ts index b6048d2c5f..43e1f86e85 100644 --- a/types/args/index.d.ts +++ b/types/args/index.d.ts @@ -2,20 +2,20 @@ // Project: https://github.com/leo/args#readme // Definitions by: Slessi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 -export = args; +declare const c: args; +export = c; -declare namespace args { - let sub: string[]; +interface args { + sub: string[]; - function option(name: string | [string, string], description: string, defaultValue?: any, init?: OptionInitFunction): typeof args; - function options(list: Option[]): typeof args; - function command(name: string, description: string, init?: CommandInitFunction, aliases?: string[]): typeof args; - function example(usage: string, description: string): typeof args; - function examples(list: Example[]): typeof args; - function parse(argv: string[], options?: ConfigurationOptions): { [key: string]: any }; - function showHelp(): void; + option(name: string | [string, string], description: string, defaultValue?: any, init?: OptionInitFunction): args; + options(list: Option[]): args; + command(name: string, description: string, init?: CommandInitFunction, aliases?: string[]): args; + example(usage: string, description: string): args; + examples(list: Example[]): args; + parse(argv: string[], options?: ConfigurationOptions): { [key: string]: any }; + showHelp(): void; } type MriUnknownFunction = (param: string) => boolean; From 54c6d449f27fc5a629cf24cebeeed00e4f7c2c5f Mon Sep 17 00:00:00 2001 From: Sverre Johansen Date: Fri, 27 Oct 2017 11:23:19 +0200 Subject: [PATCH 040/352] Added missing getItemLayout prop to SectionList --- types/react-native/index.d.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 2dcec3f6eb..58af56a5ac 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -3743,6 +3743,18 @@ export interface SectionListProperties extends ScrollViewProperties { */ extraData?: any + /** + * `getItemLayout` is an optional optimization that lets us skip measurement of dynamic + * content if you know the height of items a priori. getItemLayout is the most efficient, + * and is easy to use if you have fixed height items, for example: + * ``` + * getItemLayout={(data, index) => ( + * {length: ITEM_HEIGHT, offset: ITEM_HEIGHT * index, index} + * )} + * ``` + */ + getItemLayout?: (data: SectionListData[] | null, index: number) => {length: number, offset: number, index: number} + /** * How many items to render in the initial batch */ From 677ca9aa2856d426755c1846cadd9b5da3a876a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kov=C3=A1cs=20Vince?= Date: Fri, 27 Oct 2017 13:10:41 +0200 Subject: [PATCH 041/352] vue-scroll accepts elements too not just string for container and elements --- types/vue-scrollto/index.d.ts | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/types/vue-scrollto/index.d.ts b/types/vue-scrollto/index.d.ts index 5ca330d646..c9e056b261 100644 --- a/types/vue-scrollto/index.d.ts +++ b/types/vue-scrollto/index.d.ts @@ -9,10 +9,10 @@ import { PluginFunction } from "vue"; declare namespace VueScrollTo { interface Options { // The element you want to scroll to. - el?: string; - element?: string; + el?: string | Element; + element?: string | Element; // The container that has to be scrolled. Default: body - container?: string; + container?: string | Element; // The duration (in milliseconds) of the scrolling animation. Default: 500 duration?: number; // The easing to be used when animating. Default: ease @@ -31,17 +31,25 @@ declare namespace VueScrollTo { // Whether or not we want scrolling on the y axis. Default: true y?: boolean; } + + interface VueStatic { + (options: VueScrollTo.Options): void; + + (element: string | Element, options?: VueScrollTo.Options): void; + + (element: string | Element, duration: number, options?: VueScrollTo.Options): void; + } } declare class VueScrollTo { static install: PluginFunction; - scrollTo(element: string | HTMLElement, options?: VueScrollTo.Options): void; + scrollTo: VueScrollTo.VueStatic; } -declare module "vue/types/vue" { +declare module 'vue/types/vue' { interface Vue { - $scrollTo: typeof VueScrollTo.prototype.scrollTo; + $scrollTo: VueScrollTo.VueStatic; } } From 088e63ab57e84f4eb505ff7ad9616829104681a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kov=C3=A1cs=20Vince?= Date: Fri, 27 Oct 2017 14:28:16 +0200 Subject: [PATCH 042/352] Remove qualifier is unnecessary since 'VueScrollTo' is in scope. --- types/vue-scrollto/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/vue-scrollto/index.d.ts b/types/vue-scrollto/index.d.ts index c9e056b261..d3a7ec7efb 100644 --- a/types/vue-scrollto/index.d.ts +++ b/types/vue-scrollto/index.d.ts @@ -33,11 +33,11 @@ declare namespace VueScrollTo { } interface VueStatic { - (options: VueScrollTo.Options): void; + (options: Options): void; - (element: string | Element, options?: VueScrollTo.Options): void; + (element: string | Element, options?: Options): void; - (element: string | Element, duration: number, options?: VueScrollTo.Options): void; + (element: string | Element, duration: number, options?: Options): void; } } From 7758f8bcb995a8d9f841cde4c02500663804c06f Mon Sep 17 00:00:00 2001 From: Edward Sammut Alessi Date: Fri, 27 Oct 2017 15:07:11 +0200 Subject: [PATCH 043/352] Fix name for option type --- types/args/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/args/index.d.ts b/types/args/index.d.ts index 43e1f86e85..2ef8b1eb88 100644 --- a/types/args/index.d.ts +++ b/types/args/index.d.ts @@ -65,7 +65,7 @@ interface ConfigurationOptions { } interface Option { - name: string; + name: [string, string]; description: string; init?: OptionInitFunction; defaultValue?: any; From 5a1c6ddc309df5bc64a11d1a9d0a9723b7da826b Mon Sep 17 00:00:00 2001 From: Marc-Andre Roy Date: Fri, 27 Oct 2017 09:21:06 -0400 Subject: [PATCH 044/352] Improve tests, types, and whatnot --- types/guid/guid-tests.ts | 19 ++++++++++++++++--- types/guid/index.d.ts | 5 ++--- types/guid/tsconfig.json | 1 + 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/types/guid/guid-tests.ts b/types/guid/guid-tests.ts index cb5008d2a2..52e0a738d1 100644 --- a/types/guid/guid-tests.ts +++ b/types/guid/guid-tests.ts @@ -1,5 +1,18 @@ import guid = require('guid'); -const newRawGuid: string = guid.raw(); -const isAGuid: boolean = guid.isGuid(newRawGuid); -const newGuidObject: object = guid.create(); +// $ExpectType object +guid.create(); + +// $ExpectType string +guid.raw(); + +const newRawGuid = guid.raw(); + +// $ExpectType boolean +guid.isGuid(newRawGuid); + +// $ExpectType string +guid.EMPTY; + +// $ExpectType object +guid(guid.create()); diff --git a/types/guid/index.d.ts b/types/guid/index.d.ts index 210a1f9584..9d1c6b2ea2 100644 --- a/types/guid/index.d.ts +++ b/types/guid/index.d.ts @@ -2,12 +2,11 @@ // Project: https://github.com/dandean/guid // Definitions by: Marc-Andre Roy // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -/** Declaration file generated by dts-gen */ +// TypeScript Version: 2.2 export = guid; -declare function guid(guid: string | guid): any; +declare function guid(guid: object): object; declare namespace guid { const EMPTY: string; diff --git a/types/guid/tsconfig.json b/types/guid/tsconfig.json index 5d335b8f70..17563577fd 100644 --- a/types/guid/tsconfig.json +++ b/types/guid/tsconfig.json @@ -7,6 +7,7 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" From e65cb3ba52b39d5afc9be6a6bd7d0258ea6adfef Mon Sep 17 00:00:00 2001 From: rlindgren Date: Fri, 27 Oct 2017 11:34:52 -0400 Subject: [PATCH 045/352] iteratee callback and test fn define variable number of parameters type T --- types/async/index.d.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/types/async/index.d.ts b/types/async/index.d.ts index c94c8058c2..f1b38e8130 100644 --- a/types/async/index.d.ts +++ b/types/async/index.d.ts @@ -15,6 +15,7 @@ export interface AsyncResultArrayCallback { (err?: E, results?: (T | undef export interface AsyncResultObjectCallback { (err: E | undefined, results: Dictionary): void; } export interface AsyncFunction { (callback: (err?: E, result?: T) => void): void; } +export interface AsyncFunctionEx { (callback: (err?: E, ...results: T[]) => void): void; } export interface AsyncIterator { (item: T, callback: ErrorCallback): void; } export interface AsyncForEachOfIterator { (item: T, key: number|string, callback: ErrorCallback): void; } export interface AsyncResultIterator { (item: T, callback: AsyncResultCallback): void; } @@ -174,9 +175,9 @@ export function parallel(tasks: Dictionary>, callback? export function parallelLimit(tasks: Array>, limit: number, callback?: AsyncResultArrayCallback): void; export function parallelLimit(tasks: Dictionary>, limit: number, callback?: AsyncResultObjectCallback): void; export function whilst(test: () => boolean, fn: AsyncVoidFunction, callback: ErrorCallback): void; -export function doWhilst(fn: AsyncFunction, test: (result?: any) => boolean, callback: ErrorCallback): void; +export function doWhilst(fn: AsyncFunctionEx, test: (...results: T[]) => boolean, callback: ErrorCallback): void; export function until(test: () => boolean, fn: AsyncVoidFunction, callback: ErrorCallback): void; -export function doUntil(fn: AsyncFunction, test: (result?: any) => boolean, callback: ErrorCallback): void; +export function doUntil(fn: AsyncFunctionEx, test: (...results: T[]) => boolean, callback: ErrorCallback): void; export function during(test: (testCallback : AsyncBooleanResultCallback) => void, fn: AsyncVoidFunction, callback: ErrorCallback): void; export function doDuring(fn: AsyncVoidFunction, test: (testCallback: AsyncBooleanResultCallback) => void, callback: ErrorCallback): void; export function forever(next: (next : ErrorCallback) => void, errBack: ErrorCallback) : void; From 055cf34ca936e62d61639eadd77026ec51281eea Mon Sep 17 00:00:00 2001 From: rlindgren Date: Fri, 27 Oct 2017 11:35:10 -0400 Subject: [PATCH 046/352] fix lint --- types/async/test/explicit.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/async/test/explicit.ts b/types/async/test/explicit.ts index b9ea9c84ed..0c0e1a44ee 100644 --- a/types/async/test/explicit.ts +++ b/types/async/test/explicit.ts @@ -47,13 +47,13 @@ interface NumberCallback { (err?: Error, result?: number): void; } interface AsyncNumberGetter { (callback: NumberCallback): void; } var taskDict: Lookup = { - one: function(callback){ - setTimeout(function(){ + one: function(callback) { + setTimeout(function() { callback(undefined, 1); }, 200); }, - two: function(callback){ - setTimeout(function(){ + two: function(callback) { + setTimeout(function() { callback(undefined, 2); }, 100); } From 11f8e487721b37bd11c1fc41a8f2fdbde6573e8f Mon Sep 17 00:00:00 2001 From: Bel Date: Fri, 27 Oct 2017 11:13:39 -0700 Subject: [PATCH 047/352] Add exports to other non default interfaces for Field props (#20964) --- types/redux-form/lib/Field.d.ts | 13 ++++++++----- types/redux-form/redux-form-tests.tsx | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/types/redux-form/lib/Field.d.ts b/types/redux-form/lib/Field.d.ts index 8020763db4..9acba639c6 100644 --- a/types/redux-form/lib/Field.d.ts +++ b/types/redux-form/lib/Field.d.ts @@ -16,15 +16,15 @@ export type Formatter = (value: any, name: string) => any; export type Parser = (value: any, name: string) => any; export type Validator = (value: any, allValues?: any, props?: any) => any; -interface EventHandler { +export interface EventHandler { (event: Event): void; } -interface EventOrValueHandler extends EventHandler { +export interface EventOrValueHandler extends EventHandler { (value: any): void; } -interface CommonFieldProps { +export interface CommonFieldProps { name: string; onBlur: EventOrValueHandler>; onChange: EventOrValueHandler>; @@ -33,7 +33,7 @@ interface CommonFieldProps { onFocus: EventHandler>; } -interface BaseFieldProps

    extends Partial { +export interface BaseFieldProps

    extends Partial { name: string; component?: ComponentType

    | "input" | "select" | "textarea", format?: Formatter | null; @@ -53,7 +53,10 @@ export interface GenericField

    extends Component & P> { getRenderedComponent(): Component; } -type GenericFieldHTMLAttributes = InputHTMLAttributes | SelectHTMLAttributes | TextareaHTMLAttributes; +export type GenericFieldHTMLAttributes = + InputHTMLAttributes | + SelectHTMLAttributes | + TextareaHTMLAttributes; export class Field

    extends Component & P> implements GenericField

    { dirty: boolean; diff --git a/types/redux-form/redux-form-tests.tsx b/types/redux-form/redux-form-tests.tsx index dba9b95633..cde07c264c 100644 --- a/types/redux-form/redux-form-tests.tsx +++ b/types/redux-form/redux-form-tests.tsx @@ -14,6 +14,7 @@ import { WrappedFieldProps, Fields, GenericFields, + BaseFieldProps, WrappedFieldsProps, FieldArray, GenericFieldArray, From 4982aa760999364738299817b29c13556f845742 Mon Sep 17 00:00:00 2001 From: Daphne Date: Fri, 27 Oct 2017 20:14:17 +0200 Subject: [PATCH 048/352] react-data-grid: update index.d.ts to make grouping example work (#21037) * Update index.d.ts Types that are missing for this example to work with Typescript: http://adazzle.github.io/react-data-grid/examples.html#/grouping * Added a test for OnRowExpandToggle and enableDragAndDrop and exported the required type --- types/react-data-grid/index.d.ts | 33 +++++++++++++++++++ .../react-data-grid/react-data-grid-tests.tsx | 9 +++++ 2 files changed, 42 insertions(+) diff --git a/types/react-data-grid/index.d.ts b/types/react-data-grid/index.d.ts index d09784acb6..3e79703242 100644 --- a/types/react-data-grid/index.d.ts +++ b/types/react-data-grid/index.d.ts @@ -161,6 +161,13 @@ declare namespace AdazzleReactDataGrid { * @default false */ enableCellSelect?: boolean + + /** + * Enables cells to be dragged and dropped + * @default false + */ + enableDragAndDrop?: boolean + /** * Called when a cell is selected. * @param coordinates The row and column indices of the selected cell. @@ -198,6 +205,13 @@ declare namespace AdazzleReactDataGrid { * @param row object behind the row */ onRowClick?: (rowIdx : number, row : object) => void + + /** + * An event function called when a row is expanded with the toggle + * @param props OnRowExpandToggle object + */ + onRowExpandToggle?: (props: OnRowExpandToggle ) => void + /** * Responsible for returning an Array of values that can be used for filtering * a column that is column.filterable and using a column.filterRenderer that @@ -419,6 +433,24 @@ declare namespace AdazzleReactDataGrid { action: 'cellUpdate' | 'cellDrag' | 'columnFill' | 'copyPaste' } + /** + * Information about the row toggler + */ + interface OnRowExpandToggle { + /** + * The name of the column group the row is in + */ + columnGroupName: string + /** + * The name of the expanded row + */ + name: string + /** + * If it should expand or not + */ + shouldExpand: boolean + } + /** * Some filter to be applied to the grid's contents */ @@ -455,6 +487,7 @@ declare namespace AdazzleReactDataGrid { export import DragHandleDoubleClickEvent = AdazzleReactDataGrid.DragHandleDoubleClickEvent; export import CellCopyPasteEvent = AdazzleReactDataGrid.CellCopyPasteEvent; export import GridRowsUpdatedEvent = AdazzleReactDataGrid.GridRowsUpdatedEvent; + export import OnRowExpandToggle = AdazzleReactDataGrid.OnRowExpandToggle; // Actual classes exposed on module.exports /** diff --git a/types/react-data-grid/react-data-grid-tests.tsx b/types/react-data-grid/react-data-grid-tests.tsx index 6d5ff3b4da..1b42af7ae6 100644 --- a/types/react-data-grid/react-data-grid-tests.tsx +++ b/types/react-data-grid/react-data-grid-tests.tsx @@ -249,6 +249,13 @@ class Example extends React.Component { this.setState({rows: rows}); } + onRowExpandToggle = ({ columnGroupName, name, shouldExpand }:ReactDataGrid.OnRowExpandToggle ) => { + let expandedRows = Object.assign({}, this.state.expandedRows); + expandedRows[columnGroupName] = Object.assign({}, expandedRows[columnGroupName]); + expandedRows[columnGroupName][name] = {isExpanded: shouldExpand}; + this.setState({expandedRows: expandedRows}); + } + onRowClick(rowIdx:number, row: Object) { // Do nothing, just test that it accepts an event } @@ -300,10 +307,12 @@ class Example extends React.Component { } enableRowSelect={true} rowHeight={50} From 5dbba088ed6ba5fea960d027ec3627204185b36f Mon Sep 17 00:00:00 2001 From: Daniel Cottone Date: Fri, 27 Oct 2017 14:56:52 -0500 Subject: [PATCH 049/352] updating custom authorizer event --- types/aws-lambda/aws-lambda-tests.ts | 64 ++++++++++++++++------------ types/aws-lambda/index.d.ts | 55 +++++++++++++----------- 2 files changed, 67 insertions(+), 52 deletions(-) diff --git a/types/aws-lambda/aws-lambda-tests.ts b/types/aws-lambda/aws-lambda-tests.ts index 4e404fcd55..c2eb8da77e 100644 --- a/types/aws-lambda/aws-lambda-tests.ts +++ b/types/aws-lambda/aws-lambda-tests.ts @@ -4,6 +4,7 @@ var anyObj: any = { abc: 123 }; var num: number = 5; var error: Error = new Error(); var b: boolean = true; +var apiGwEvtReqCtx: AWSLambda.APIGatewayEventRequestContext; var apiGwEvt: AWSLambda.APIGatewayEvent; var customAuthorizerEvt: AWSLambda.CustomAuthorizerEvent; var clientCtx: AWSLambda.ClientContext; @@ -22,33 +23,33 @@ var snsEvtRec: AWSLambda.SNSEventRecord; var snsMsg: AWSLambda.SNSMessage; var snsMsgAttr: AWSLambda.SNSMessageAttribute; var snsMsgAttrs: AWSLambda.SNSMessageAttributes; -var S3EvtRec: AWSLambda.S3EventRecord = { +var S3EvtRec: AWSLambda.S3EventRecord = { eventVersion: '2.0', eventSource: 'aws:s3', awsRegion: 'us-east-1', eventTime: '1970-01-01T00:00:00.000Z', eventName: 'ObjectCreated:Put', - userIdentity: { + userIdentity: { principalId: 'AIDAJDPLRKLG7UEXAMPLE' }, - requestParameters:{ + requestParameters:{ sourceIPAddress: '127.0.0.1' }, - responseElements: { + responseElements: { 'x-amz-request-id': 'C3D13FE58DE4C810', 'x-amz-id-2': 'FMyUVURIY8/IgAtTv8xRjskZQpcIZ9KG4V5Wp6S7S/JRWeUWerMUE5JgHvANOjpD' }, - s3: { + s3: { s3SchemaVersion: '1.0', configurationId: 'testConfigRule', - bucket: { + bucket: { name: 'mybucket', - ownerIdentity: { + ownerIdentity: { principalId: 'A3NL1KOZZKExample' }, arn: 'arn:aws:s3:::mybucket' }, - object: { + object: { key: 'HappyFace.jpg', size: 1024, eTag: 'd41d8cd98f00b204e9800998ecf8427e', @@ -65,6 +66,27 @@ var cognitoUserPoolEvent: AWSLambda.CognitoUserPoolEvent; var cloudformationCustomResourceEvent: AWSLambda.CloudFormationCustomResourceEvent; var cloudformationCustomResourceResponse: AWSLambda.CloudFormationCustomResourceResponse; +/* API Gateway Event request context */ +str = apiGwEvtReqCtx.accountId; +str = apiGwEvtReqCtx.apiId; +str = apiGwEvtReqCtx.httpMethod; +str = apiGwEvtReqCtx.identity.accessKey; +str = apiGwEvtReqCtx.identity.accountId; +str = apiGwEvtReqCtx.identity.apiKey; +str = apiGwEvtReqCtx.identity.caller; +str = apiGwEvtReqCtx.identity.cognitoAuthenticationProvider; +str = apiGwEvtReqCtx.identity.cognitoAuthenticationType; +str = apiGwEvtReqCtx.identity.cognitoIdentityId; +str = apiGwEvtReqCtx.identity.cognitoIdentityPoolId; +str = apiGwEvtReqCtx.identity.sourceIp; +str = apiGwEvtReqCtx.identity.user; +str = apiGwEvtReqCtx.identity.userAgent; +str = apiGwEvtReqCtx.identity.userArn; +str = apiGwEvtReqCtx.stage; +str = apiGwEvtReqCtx.requestId; +str = apiGwEvtReqCtx.resourceId; +str = apiGwEvtReqCtx.resourcePath; + /* API Gateway Event */ str = apiGwEvt.body; str = apiGwEvt.headers["example"]; @@ -74,31 +96,17 @@ str = apiGwEvt.path; str = apiGwEvt.pathParameters["example"]; str = apiGwEvt.queryStringParameters["example"]; str = apiGwEvt.stageVariables["example"]; -str = apiGwEvt.requestContext.accountId; -str = apiGwEvt.requestContext.apiId; -str = apiGwEvt.requestContext.httpMethod; -str = apiGwEvt.requestContext.identity.accessKey; -str = apiGwEvt.requestContext.identity.accountId; -str = apiGwEvt.requestContext.identity.apiKey; -str = apiGwEvt.requestContext.identity.caller; -str = apiGwEvt.requestContext.identity.cognitoAuthenticationProvider; -str = apiGwEvt.requestContext.identity.cognitoAuthenticationType; -str = apiGwEvt.requestContext.identity.cognitoIdentityId; -str = apiGwEvt.requestContext.identity.cognitoIdentityPoolId; -str = apiGwEvt.requestContext.identity.sourceIp; -str = apiGwEvt.requestContext.identity.user; -str = apiGwEvt.requestContext.identity.userAgent; -str = apiGwEvt.requestContext.identity.userArn; -str = apiGwEvt.requestContext.stage; -str = apiGwEvt.requestContext.requestId; -str = apiGwEvt.requestContext.resourceId; -str = apiGwEvt.requestContext.resourcePath; +apiGwEvtReqCtx = apiGwEvt.requestContext; str = apiGwEvt.resource; /* API Gateway CustomAuthorizer Event */ str = customAuthorizerEvt.type; -str = customAuthorizerEvt.authorizationToken; str = customAuthorizerEvt.methodArn; +str = customAuthorizerEvt.authorizationToken; +str = apiGwEvt.pathParameters["example"]; +str = apiGwEvt.queryStringParameters["example"]; +str = apiGwEvt.stageVariables["example"]; +apiGwEvtReqCtx = apiGwEvt.requestContext; /* SNS Event */ snsEvtRecs = snsEvt.Records; diff --git a/types/aws-lambda/index.d.ts b/types/aws-lambda/index.d.ts index b1ca69405b..bbe8be54e3 100644 --- a/types/aws-lambda/index.d.ts +++ b/types/aws-lambda/index.d.ts @@ -11,6 +11,31 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 +// API Gateway "event" request context +interface APIGatewayEventRequestContext { + accountId: string; + apiId: string; + httpMethod: string; + identity: { + accessKey: string | null; + accountId: string | null; + apiKey: string | null; + caller: string | null; + cognitoAuthenticationProvider: string | null; + cognitoAuthenticationType: string | null; + cognitoIdentityId: string | null; + cognitoIdentityPoolId: string | null; + sourceIp: string; + user: string | null; + userAgent: string | null; + userArn: string | null; + }, + stage: string; + requestId: string; + resourceId: string; + resourcePath: string; +} + // API Gateway "event" interface APIGatewayEvent { body: string | null; @@ -21,37 +46,19 @@ interface APIGatewayEvent { pathParameters: { [name: string]: string } | null; queryStringParameters: { [name: string]: string } | null; stageVariables: { [name: string]: string } | null; - requestContext: { - accountId: string; - apiId: string; - httpMethod: string; - identity: { - accessKey: string | null; - accountId: string | null; - apiKey: string | null; - caller: string | null; - cognitoAuthenticationProvider: string | null; - cognitoAuthenticationType: string | null; - cognitoIdentityId: string | null; - cognitoIdentityPoolId: string | null; - sourceIp: string; - user: string | null; - userAgent: string | null; - userArn: string | null; - }, - stage: string; - requestId: string; - resourceId: string; - resourcePath: string; - }; + requestContext: APIGatewayEventRequestContext; resource: string; } // API Gateway CustomAuthorizer "event" interface CustomAuthorizerEvent { type: string; - authorizationToken: string; methodArn: string; + authorizationToken?: string; + headers?: { [name: string]: string }; + pathParameters?: { [name: string]: string } | null; + queryStringParameters?: { [name: string]: string } | null; + requestContext?: APIGatewayEventRequestContext; } // SNS "event" From 19ab2f184e4a78d3713d723d927ae8789710b0f6 Mon Sep 17 00:00:00 2001 From: Daniel Cottone Date: Fri, 27 Oct 2017 14:58:35 -0500 Subject: [PATCH 050/352] adding contact info --- types/aws-lambda/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/aws-lambda/index.d.ts b/types/aws-lambda/index.d.ts index bbe8be54e3..523aafd41f 100644 --- a/types/aws-lambda/index.d.ts +++ b/types/aws-lambda/index.d.ts @@ -8,6 +8,7 @@ // Yoriki Yamaguchi // wwwy3y3 // Ishaan Malhi +// Daniel Cottone // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 From 19c7df4d0c86673700b5849a99f16f18e443f1ed Mon Sep 17 00:00:00 2001 From: pdeva Date: Fri, 27 Oct 2017 15:00:25 -0700 Subject: [PATCH 051/352] Update DropdownToggle.d.ts --- types/react-bootstrap/lib/DropdownToggle.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/react-bootstrap/lib/DropdownToggle.d.ts b/types/react-bootstrap/lib/DropdownToggle.d.ts index e5655c22f8..d166c5ae25 100644 --- a/types/react-bootstrap/lib/DropdownToggle.d.ts +++ b/types/react-bootstrap/lib/DropdownToggle.d.ts @@ -9,6 +9,7 @@ declare namespace DropdownToggle { useAnchor?: boolean; bsClass?:string; // Added since v0.30.0 bsStyle?:string; + bsSize?:string; } } declare class DropdownToggle extends React.Component { } From 0c6218ec00d5b5ff06306c0e4d9b883d2ede0775 Mon Sep 17 00:00:00 2001 From: Jacob Date: Fri, 27 Oct 2017 18:44:08 -0400 Subject: [PATCH 052/352] Updated for proper module export After reading today about module export and having a problem importing the definition, I updated to declare namespace and export. now import * as Email from 'email-templates' works with const email = new Email(etc) --- types/email-templates/index.d.ts | 36 +++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/types/email-templates/index.d.ts b/types/email-templates/index.d.ts index bb6a3321c7..12dceb181d 100644 --- a/types/email-templates/index.d.ts +++ b/types/email-templates/index.d.ts @@ -5,7 +5,7 @@ // Jacob Copeland // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -export interface EmailConfig { +interface EmailConfig { /** * The message */ @@ -48,7 +48,7 @@ export interface EmailConfig { juiceResources?: any; } -export interface EmailOptions { +interface EmailOptions { /** * The template name */ @@ -63,22 +63,42 @@ export interface EmailOptions { locals: any; } -export class EmailTemplate { +declare class EmailTemplate { constructor(config: EmailConfig); - /** * shorthand use of `juiceResources` with the config * mainly for custom renders like from a database). */ juiceResources(html: string): Promise ; - /** - * Render the Email, Used by send, but can be called by itself. + * + * @param view The Html pug to render + * @param locals The template Variables */ render(view: string, locals: any): Promise; - /** - * Send the Email. + * Send the Email */ send(options: EmailOptions): any; } + +declare namespace EmailTemplate { + /** + * shorthand use of `juiceResources` with the config + * mainly for custom renders like from a database). + */ + function juiceResources(html: string): Promise ; + + /** + * + * @param view The Html pug to render + * @param locals The template Variables + */ + function render(view: string, locals: any): Promise; + + /** + * Send the Email + */ + function send(options: EmailOptions): any; +} +export = EmailTemplate; From c6e432c71466572e2fedd3a35d56adfa985ab230 Mon Sep 17 00:00:00 2001 From: Jacob Date: Fri, 27 Oct 2017 18:46:11 -0400 Subject: [PATCH 053/352] Updated test to reflect module export Correctly fixed the definition to use import * as Email from 'email-templates' --- types/email-templates/email-templates-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/email-templates/email-templates-tests.ts b/types/email-templates/email-templates-tests.ts index c36852de31..d16d0c0620 100644 --- a/types/email-templates/email-templates-tests.ts +++ b/types/email-templates/email-templates-tests.ts @@ -1,6 +1,6 @@ import * as Email from 'email-templates'; -const email = new Email.EmailTemplate({ +const email = new Email({ message: { from: 'Test@tesitng.com' }, From 0a804aff1a4b75eeac09806ef6188101af406f27 Mon Sep 17 00:00:00 2001 From: Sarun Intaralawan Date: Sat, 28 Oct 2017 06:46:55 +0700 Subject: [PATCH 054/352] croppie: use correct return type on result method (#21083) --- types/croppie/index.d.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/types/croppie/index.d.ts b/types/croppie/index.d.ts index ec4626aa7f..e2e207db4c 100644 --- a/types/croppie/index.d.ts +++ b/types/croppie/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/Foliotek/Croppie // Definitions by: Connor Peet // dklmuc +// Sarun Intaralawan // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export default class Croppie { @@ -15,10 +16,10 @@ export default class Croppie { useCanvas?: boolean, }): Promise; - result(options: ResultOptions & { type: 'base64' }): Promise; + result(options: ResultOptions & { type: 'base64' | 'canvas' }): Promise; result(options: ResultOptions & { type: 'html' }): Promise; result(options: ResultOptions & { type: 'blob' }): Promise; - result(options: ResultOptions & { type: 'canvas' }): Promise; + result(options: ResultOptions & { type: 'rawcanvas' }): Promise; result(options?: ResultOptions): Promise; rotate(degrees: 90 | 180 | 270 | -90 | -180 | -270): void; From c6ecf40346e151af0583e9a66ecc05f337c88b75 Mon Sep 17 00:00:00 2001 From: John Woodruff Date: Fri, 27 Oct 2017 17:47:32 -0600 Subject: [PATCH 055/352] Add DataOptions interface and methods that take options as a param (#21082) --- .../electron-json-storage-tests.ts | 31 ++++++++++++++++++- types/electron-json-storage/index.d.ts | 18 ++++++++--- 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/types/electron-json-storage/electron-json-storage-tests.ts b/types/electron-json-storage/electron-json-storage-tests.ts index 07d8461bed..2429f6a95f 100644 --- a/types/electron-json-storage/electron-json-storage-tests.ts +++ b/types/electron-json-storage/electron-json-storage-tests.ts @@ -2,8 +2,9 @@ import electron = require('electron'); import storage = require('electron-json-storage'); const DATA_PATH = '~/Downloads'; +const NEW_DATA_PATH = `${DATA_PATH}/new-data-path`; -console.log(storage.DEFAULT_DATA_PATH.length); +console.log(storage.getDefaultDataPath().length); storage.setDataPath(DATA_PATH); console.log(DATA_PATH.length); @@ -12,31 +13,59 @@ console.log(storage.getDataPath().length); storage.set('foo', { foo: 'bar' }, (err: any) => { }); storage.set('bar', { foo: 'bar' }, (err: any) => { }); +storage.set('baz', { foo: 'bar' }, {dataPath: NEW_DATA_PATH}, (err: any) => { }); storage.get('foo', (err: any, data: object) => { console.log(JSON.stringify(data)); }); +storage.get('baz', {dataPath: NEW_DATA_PATH}, (err: any, data: object) => { + console.log(JSON.stringify(data)); +}); + storage.getMany(['foo', 'bar'], (err: any, data: object) => { console.log(JSON.stringify(data)); }); +storage.getMany(['baz'], {dataPath: NEW_DATA_PATH}, (err: any, data: object) => { + console.log(JSON.stringify(data)); +}); storage.getAll((err: any, data: object) => { console.log(JSON.stringify(data)); }); +storage.getAll({dataPath: NEW_DATA_PATH}, (err: any, data: object) => { + console.log(JSON.stringify(data)); +}); + storage.has('foo', (err: any, hasKey: boolean) => { console.log("hasKey?: %s", hasKey); }); +storage.has('baz', {dataPath: NEW_DATA_PATH}, (err: any, hasKey: boolean) => { + console.log("hasKey?: %s", hasKey); +}); + storage.keys((err: any, keys: string[]) => { console.log(keys); }); +storage.keys({dataPath: NEW_DATA_PATH}, (err: any, keys: string[]) => { + console.log(keys); +}); + storage.remove("foo", (err: any) => { console.log(err); }); +storage.remove("baz", {dataPath: NEW_DATA_PATH}, (err: any) => { + console.log(err); +}); + storage.clear((err: any) => { console.log(err); }); + +storage.clear({dataPath: NEW_DATA_PATH}, (err: any) => { + console.log(err); +}); diff --git a/types/electron-json-storage/index.d.ts b/types/electron-json-storage/index.d.ts index cafa6c4171..75d6cf3983 100644 --- a/types/electron-json-storage/index.d.ts +++ b/types/electron-json-storage/index.d.ts @@ -1,18 +1,28 @@ -// Type definitions for electron-json-storage 3.1 +// Type definitions for electron-json-storage 4.0 // Project: https://github.com/electron-userland/electron-json-storage // Definitions by: Sam Saint-Pettersen , -// nrlquaker +// nrlquaker , +// John Woodruff // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 -export const DEFAULT_DATA_PATH: string; -export function setDataPath(directory: string): void; +export interface DataOptions { dataPath: string; } +export function getDefaultDataPath(): string; +export function setDataPath(directory?: string): void; export function getDataPath(): string; export function get(key: string, callback: (error: any, data: object) => void): void; +export function get(key: string, options: DataOptions, callback: (error: any, data: object) => void): void; export function getMany(keys: ReadonlyArray, callback: (error: any, data: object) => void): void; +export function getMany(keys: ReadonlyArray, options: DataOptions, callback: (error: any, data: object) => void): void; export function getAll(callback: (error: any, data: object) => void): void; +export function getAll(options: DataOptions, callback: (error: any, data: object) => void): void; export function set(key: string, json: object, callback: (error: any) => void): void; +export function set(key: string, json: object, options: DataOptions, callback: (error: any) => void): void; export function has(key: string, callback: (error: any, hasKey: boolean) => void): void; +export function has(key: string, options: DataOptions, callback: (error: any, hasKey: boolean) => void): void; export function keys(callback: (error: any, keys: string[]) => void): void; +export function keys(options: DataOptions, callback: (error: any, keys: string[]) => void): void; export function remove(key: string, callback: (error: any) => void): void; +export function remove(key: string, options: DataOptions, callback: (error: any) => void): void; export function clear(callback: (error: any) => void): void; +export function clear(options: DataOptions, callback: (error: any) => void): void; From 6c483277a46069b5457fda9aff001b1c61fbf6b6 Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Fri, 27 Oct 2017 19:51:13 -0400 Subject: [PATCH 056/352] Fix/Add Universal Analytics Tracker and Model to google.analytics (#21077) * Updates the UniversalAnalytics.Tracker interface so it matches the specification in Google's documentation (https://developers.google.com/analytics/devguides/collection/analyticsjs/tracker-object-reference). * Adds a UniversalAnalytics.Model interface, as described in Google's documentation (https://developers.google.com/analytics/devguides/collection/analyticsjs/model-object-reference). * Adds my name to the list of contributors for google.analytics. * Fixes lint issues. --- .../google.analytics-tests.ts | 37 ++++++++++++++++--- types/google.analytics/index.d.ts | 19 ++++++---- 2 files changed, 43 insertions(+), 13 deletions(-) diff --git a/types/google.analytics/google.analytics-tests.ts b/types/google.analytics/google.analytics-tests.ts index 945f967dc9..5256f636c7 100644 --- a/types/google.analytics/google.analytics-tests.ts +++ b/types/google.analytics/google.analytics-tests.ts @@ -41,14 +41,39 @@ describe('UniversalAnalytics', () => { }); it('should excercise Tracker APIs', () => { const tracker: UniversalAnalytics.Tracker = ga.create('UA-65432-1', 'auto'); - const aString: string = tracker.get('aString'); - const aNumber: number = tracker.get('aNumber'); - const anObject: {} = tracker.get<{}>('anObject'); + + tracker.get('fieldName'); + + tracker.set('aString', 'aString'); + tracker.set('aNumber', 1); + tracker.set('anObject', {}); + tracker.set({ + several: 'values', + at: 'once' + }); + tracker.send('pageview'); + tracker.send('pageview', '/some-path'); tracker.send('pageview', {some: 'details'}); - tracker.set('aString', aString); - tracker.set('aNumber', aNumber); - tracker.set('anObject', anObject); + }); + + it('should exercise Model APIs', () => { + const tracker: UniversalAnalytics.Tracker = ga.create('UA-65432-1', 'auto'); + + tracker.set('sendHitTask', (gaHitModel: UniversalAnalytics.Model) => { + gaHitModel.get('hitPayload'); + + gaHitModel.set('hitCallback', () => console.log('hit sent'), true); + gaHitModel.set('hitCallback', () => console.log('hit sent')); + gaHitModel.set({ + hitPayload: 'a=1&b=2', + otherField: 3 + }); + gaHitModel.set({ + hitPayload: 'a=1&b=2', + otherField: 3 + }, null, false); + }); }); }); diff --git a/types/google.analytics/index.d.ts b/types/google.analytics/index.d.ts index c6d188d1cb..b0412a362f 100644 --- a/types/google.analytics/index.d.ts +++ b/types/google.analytics/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Google Analytics (Classic and Universal) // Project: https://developers.google.com/analytics/devguides/collection/gajs/, https://developers.google.com/analytics/devguides/collection/analyticsjs/method-reference -// Definitions by: Ronnie Haakon Hegelund , Pat Kujawa +// Definitions by: Ronnie Haakon Hegelund , Pat Kujawa , Tyler Murphy // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare class Tracker { @@ -620,12 +620,17 @@ declare namespace UniversalAnalytics { } interface Tracker { - get(fieldName: string): T; - send(hitType: string, opt_fieldObject?: {}): void; - set(fieldName: string, value: string): void; - set(fieldName: string, value: {}): void; - set(fieldName: string, value: number): void; - set(fieldName: string, value: boolean): void; + get(fieldName: string): any; + set(fieldName: string, fieldValue: any): void; + set(fieldsObject: {}): void; + send(hitType: string, ...fields: any[]): void; + send(hitType: string, fieldsObject: {}): void; + } + + interface Model { + get(fieldName: string): any; + set(fieldName: string, fieldValue: any, temporary?: boolean): void; + set(fields: {}, fieldValue?: null, temporary?: boolean): void; } } From 627dc0c3bda3a1ea17f2ad867bb3597e68897f29 Mon Sep 17 00:00:00 2001 From: Yury Abaitov Date: Sat, 28 Oct 2017 02:52:59 +0300 Subject: [PATCH 057/352] easeljs stageGL support (#21025) * stageGL support * fix * fixes --- types/easeljs/index.d.ts | 73 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 72 insertions(+), 1 deletion(-) diff --git a/types/easeljs/index.d.ts b/types/easeljs/index.d.ts index d47f631728..462c9f04cf 100644 --- a/types/easeljs/index.d.ts +++ b/types/easeljs/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for EaselJS 0.8.0 +// Type definitions for EaselJS 1.0.0 // Project: http://www.createjs.com/#!/EaselJS // Definitions by: Pedro Ferreira , Chris Smith // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -53,6 +53,22 @@ declare namespace createjs { clone(): Bitmap; } + export class BitmapCache { + constructor(); + + // properties + cacheID: number; + + // methods + static getFilterBounds(target: DisplayObject, output?: Rectangle): Rectangle; + toString(): string; + define(target: DisplayObject, x: number, y: number, width: number, height: number, scale?: number): void; + update(compositeOperation?: string): void; + release(): void; + getCacheDataURL(): string; + draw(ctx: CanvasRenderingContext2D): boolean; + } + export class ScaleBitmap extends DisplayObject { constructor(imageOrUrl: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | Object | string, scale9Grid: Rectangle); @@ -211,6 +227,7 @@ declare namespace createjs { // properties alpha: number; + bitmapCache: BitmapCache; cacheCanvas: HTMLCanvasElement | Object; cacheID: number; compositeOperation: string; @@ -924,6 +941,60 @@ declare namespace createjs { } + interface IStageGLOptions { + preserveBuffer?: boolean; + antialias?: boolean; + transparent?: boolean; + premultiply?: boolean; + autoPurge?: number; + } + + export class StageGL extends Stage { + constructor(canvas: HTMLCanvasElement | string | Object, options?: IStageGLOptions); + + // properties + static VERTEX_PROPERTY_COUNT: number; + static INDICIES_PER_CARD: number; + static DEFAULT_MAX_BATCH_SIZE: number; + static WEBGL_MAX_INDEX_NUM: number; + static UV_RECT: number; + static COVER_VERT: Float32Array; + static COVER_UV: Float32Array; + static COVER_UV_FLIP: Float32Array; + static REGULAR_VARYING_HEADER: string; + static REGULAR_VERTEX_HEADER: string; + static REGULAR_FRAGMENT_HEADER: string; + static REGULAR_VERTEX_BODY: string; + static REGULAR_FRAGMENT_BODY: string; + static REGULAR_FRAG_COLOR_NORMAL: string; + static REGULAR_FRAG_COLOR_PREMULTIPLY: string; + static PARTICLE_VERTEX_BODY: string; + static PARTICLE_FRAGMENT_BODY: string; + static COVER_VARYING_HEADER: string; + static COVER_VERTEX_HEADER: string; + static COVER_FRAGMENT_HEADER: string; + static COVER_VERTEX_BODY: string; + static COVER_FRAGMENT_BODY: string; + isWebGL: boolean; + autoPurge: number; + vocalDebug: boolean; + + // methods + static buildUVRects(spritesheet: SpriteSheet, target?: number, onlyTarget?: boolean): Object; + static isWebGLActive(ctx: CanvasRenderingContext2D): boolean; + cacheDraw(target: DisplayObject, filters: Filter[], manager: BitmapCache): boolean; + getBaseTexture(w?: number, h?: number): WebGLTexture | null; + getFilterShader(filter: Filter | Object): WebGLProgram; + getRenderBufferTexture (w: number, h: number): WebGLTexture; + getTargetRenderTexture (target: DisplayObject, w: number, h: number): Object; + protectTextureSlot(id: number, lock?: boolean): void; + purgeTextures(count?: number): void; + releaseTexture(item: DisplayObject | WebGLTexture | HTMLImageElement | HTMLCanvasElement): void; + setTextureParams(gl: WebGLRenderingContext, isPOT?: boolean): void; + updateSimultaneousTextureCount(count?: number): void; + updateViewport(width: number, height: number): void; + } + export class Text extends DisplayObject { constructor(text?: string, font?: string, color?: string); From c3a393c3d4dd799b8343fd91427adebc5790a06a Mon Sep 17 00:00:00 2001 From: Li Jinyao Date: Sat, 28 Oct 2017 07:54:18 +0800 Subject: [PATCH 058/352] [cheerio] add firstChild attribute to CheerioElement (#20829) * add firstChild attribute in CheerioElement * add credit --- types/cheerio/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/cheerio/index.d.ts b/types/cheerio/index.d.ts index 2037e83c7a..93f30e8a9f 100644 --- a/types/cheerio/index.d.ts +++ b/types/cheerio/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Cheerio v0.22.0 // Project: https://github.com/cheeriojs/cheerio -// Definitions by: Bret Little , VILIC VANE , Wayne Maurer , Umar Nizamani +// Definitions by: Bret Little , VILIC VANE , Wayne Maurer , Umar Nizamani , LiJinyao // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped interface Cheerio { @@ -255,6 +255,7 @@ interface CheerioElement { children: CheerioElement[]; childNodes: CheerioElement[]; lastChild: CheerioElement; + firstChild: CheerioElement; next: CheerioElement; nextSibling: CheerioElement; prev: CheerioElement; From 0c3c44e043ebf9a7bbd227bdb728e9fe20f51bce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Flor=C3=AAncio?= Date: Sat, 28 Oct 2017 00:55:00 +0100 Subject: [PATCH 059/352] return type of runQuery should be a promise (#21073) Fix for https://github.com/DefinitelyTyped/DefinitelyTyped/issues/20724 --- types/google-cloud__datastore/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/google-cloud__datastore/index.d.ts b/types/google-cloud__datastore/index.d.ts index 6eee49ba50..a8e64839e6 100644 --- a/types/google-cloud__datastore/index.d.ts +++ b/types/google-cloud__datastore/index.d.ts @@ -223,7 +223,7 @@ declare module '@google-cloud/datastore/request' { runQuery(query: Query, options: QueryOptions, callback: QueryCallback): void; runQuery(query: Query, callback: QueryCallback): void; - runQuery(query: Query, options?: QueryOptions): QueryResult; + runQuery(query: Query, options?: QueryOptions): Promise; runQueryStream(query: Query, options?: QueryOptions): NodeJS.ReadableStream; From 2b447c65580ca1686c58388865b14ae557ebfbe4 Mon Sep 17 00:00:00 2001 From: wittwert Date: Sat, 28 Oct 2017 01:55:18 +0200 Subject: [PATCH 060/352] Allow separators in toolbarGroups configuration. (#21075) --- types/ckeditor/ckeditor-tests.ts | 17 +++++++++++++++++ types/ckeditor/index.d.ts | 3 ++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/types/ckeditor/ckeditor-tests.ts b/types/ckeditor/ckeditor-tests.ts index b6471ddab6..dd0ec92164 100644 --- a/types/ckeditor/ckeditor-tests.ts +++ b/types/ckeditor/ckeditor-tests.ts @@ -52,6 +52,23 @@ function test_config() { [ 'list', 'indent', 'blocks', 'align', 'bidi' ], ], }; + var config3: CKEDITOR.config = { + toolbarGroups: [ + { name: 'clipboard', groups: [ 'clipboard', 'undo' ] }, + { name: 'editing', groups: [ 'find', 'selection', 'spellchecker', 'editing' ] }, + { name: 'links', groups: [ 'links' ] }, + { name: 'insert', groups: [ 'insert' ] }, + { name: 'tools', groups: [ 'tools' ] }, + { name: 'document', groups: [ 'mode' ] }, + { name: 'about', groups: [ 'about' ] }, + '/', + { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] }, + { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'paragraph' ] }, + '/', + { name: 'styles', groups: [ 'styles' ] }, + { name: 'colors', groups: [ 'colors' ] }, + ], + } } function test_dom_comment() { diff --git a/types/ckeditor/index.d.ts b/types/ckeditor/index.d.ts index 24ff341b38..c61dd9c467 100644 --- a/types/ckeditor/index.d.ts +++ b/types/ckeditor/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for CKEditor // Project: http://ckeditor.com/ // Definitions by: Ondrej Sevcik +// Thomas Wittwer // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // WORK-IN-PROGRESS: Any contribution support welcomed. @@ -814,7 +815,7 @@ declare namespace CKEDITOR { toolbar?: string | (string | string[])[]; toolbarCanCollapse?: boolean; toolbarGroupCycling?: boolean; - toolbarGroups?: toolbarGroups[]; + toolbarGroups?: (toolbarGroups | string)[]; toolbarLocation?: string; toolbarStartupExpanded?: boolean; From bbe1bc92cf076fbd5d2ead01f2a273d9af444428 Mon Sep 17 00:00:00 2001 From: Tom Wanzek Date: Fri, 27 Oct 2017 19:56:16 -0400 Subject: [PATCH 061/352] [d3-zoom] Minor Version 1.7 (#21052) * [FEATURE] Add `constrain(...)` method * [DOC] Fix spelling error in JSDoc comment for `clickDistance(...)` * [CHORE] Bump minor version number --- types/d3-zoom/d3-zoom-tests.ts | 20 ++++++++++++++++++++ types/d3-zoom/index.d.ts | 19 ++++++++++++++++--- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/types/d3-zoom/d3-zoom-tests.ts b/types/d3-zoom/d3-zoom-tests.ts index 8ff3f566f5..669b4af8ff 100644 --- a/types/d3-zoom/d3-zoom-tests.ts +++ b/types/d3-zoom/d3-zoom-tests.ts @@ -121,6 +121,26 @@ let svgZoom: d3Zoom.ZoomBehavior; svgZoom = d3Zoom.zoom(); +// constrain() ------------------------------------------------------------- + +// chainable +svgZoom = svgZoom.constrain((transform, extent, translateExtent) => { + const t: d3Zoom.ZoomTransform = transform; + const ve: [[number, number], [number, number]] = extent; + const te: [[number, number], [number, number]] = translateExtent; + const dx0 = t.invertX(ve[0][0]) - te[0][0]; + const dx1 = t.invertX(ve[1][0]) - te[1][0]; + const dy0 = transform.invertY(ve[0][1]) - te[0][1]; + const dy1 = transform.invertY(ve[1][1]) - te[1][1]; + return t.translate( + dx1 > dx0 ? (dx0 + dx1) / 2 : Math.min(0, dx0) || Math.max(0, dx1), + dy1 > dy0 ? (dy0 + dy1) / 2 : Math.min(0, dy0) || Math.max(0, dy1) + ); +}); + +let constraintFn: (transform: d3Zoom.ZoomTransform, extent: [[number, number], [number, number]], translateExtent: [[number, number], [number, number]]) => d3Zoom.ZoomTransform; +constraintFn = svgZoom.constrain(); + // filter() ---------------------------------------------------------------- // chainable diff --git a/types/d3-zoom/index.d.ts b/types/d3-zoom/index.d.ts index 1ca39261a5..cf9b1ac89d 100644 --- a/types/d3-zoom/index.d.ts +++ b/types/d3-zoom/index.d.ts @@ -1,9 +1,9 @@ -// Type definitions for d3JS d3-zoom module 1.6 +// Type definitions for d3JS d3-zoom module 1.7 // Project: https://github.com/d3/d3-zoom/ // Definitions by: Tom Wanzek , Alex Ford , Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// Last module patch version validated against: 1.6.0 +// Last module patch version validated against: 1.7.0 import { ArrayLike, Selection, TransitionLike, ValueFn } from 'd3-selection'; import { ZoomView, ZoomInterpolator } from 'd3-interpolate'; @@ -499,6 +499,19 @@ export interface ZoomBehavior, k: ValueFn): void; + /** + * Returns the current constraint function. + * The default implementation attempts to ensure that the viewport extent does not go outside the translate extent. + */ + constrain(): (transform: ZoomTransform, extent: [[number, number], [number, number]], translateExtent: [[number, number], [number, number]]) => ZoomTransform; + /** + * Sets the transform constraint function to the specified function and returns the zoom behavior. + * + * @param constraint A constraint function which returns a transform given the current transform, viewport extent and translate extent. + * The default implementation attempts to ensure that the viewport extent does not go outside the translate extent. + */ + constrain(constraint: ((transform: ZoomTransform, extent: [[number, number], [number, number]], translateExtent: [[number, number], [number, number]]) => ZoomTransform)): this; + /** * Returns the current filter function. */ @@ -647,7 +660,7 @@ export interface ZoomBehavior Date: Sat, 28 Oct 2017 01:57:55 +0200 Subject: [PATCH 062/352] emscripten: ccall and cwrap returnType type can also be null (#21071) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html > For a void function this can be null (note: the JavaScript null value, not a string containing the word “null”). --- types/emscripten/emscripten-tests.ts | 2 ++ types/emscripten/index.d.ts | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/types/emscripten/emscripten-tests.ts b/types/emscripten/emscripten-tests.ts index 153ea6b5de..627efba590 100644 --- a/types/emscripten/emscripten-tests.ts +++ b/types/emscripten/emscripten-tests.ts @@ -18,6 +18,7 @@ function ModuleTest(): void { Module.print = function(text) { alert('stdout: ' + text) }; var int_sqrt = Module.cwrap('int_sqrt', 'number', ['number']) + int_sqrt = Module.cwrap('int_sqrt', null, ['number']) int_sqrt(12) int_sqrt(28) @@ -27,6 +28,7 @@ function ModuleTest(): void { var x = Module.getValue(buf, 'i32') + 123; Module.HEAPU8.set(myTypedArray, buf); Module.ccall('my_function', 'number', ['number'], [buf]); + Module.ccall('my_function', null, ['number'], [buf]); Module._free(buf); Module.destroy({}); } diff --git a/types/emscripten/index.d.ts b/types/emscripten/index.d.ts index 14260dd9d4..4db8ac4925 100644 --- a/types/emscripten/index.d.ts +++ b/types/emscripten/index.d.ts @@ -40,8 +40,8 @@ declare namespace Module { var Runtime: any; - function ccall(ident: string, returnType: string, argTypes: string[], args: any[]): any; - function cwrap(ident: string, returnType: string, argTypes: string[]): any; + function ccall(ident: string, returnType: string | null, argTypes: string[], args: any[]): any; + function cwrap(ident: string, returnType: string | null, argTypes: string[]): any; function setValue(ptr: number, value: any, type: string, noSafe?: boolean): void; function getValue(ptr: number, type: string, noSafe?: boolean): number; From fc5404090d0469ea75714c302ae82d8c378d6202 Mon Sep 17 00:00:00 2001 From: Sergey Slipchenko Date: Sat, 28 Oct 2017 02:58:37 +0300 Subject: [PATCH 063/352] Change escape-string-regexp export to const (#21062) --- types/escape-string-regexp/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/escape-string-regexp/index.d.ts b/types/escape-string-regexp/index.d.ts index 1ef18aedb1..7a52a312b1 100644 --- a/types/escape-string-regexp/index.d.ts +++ b/types/escape-string-regexp/index.d.ts @@ -1,10 +1,11 @@ // Type definitions for escape-string-regexp // Project: https://github.com/sindresorhus/escape-string-regexp // Definitions by: kruncher +// faergeek // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare function escapeStringRegexp(str: string): string; +declare const escapeStringRegexp: (str: string) => string; export = escapeStringRegexp; From aeba5ae6852893d7c53e683c6b625bac3fa54ae4 Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Scheffer <31517030+carlosscheffer@users.noreply.github.com> Date: Fri, 27 Oct 2017 22:01:17 -0200 Subject: [PATCH 064/352] [passport-jwt] Fix the missing secretOrKeyProvider (#20615) * Fix the missing secretOrKeyProvider In passport-jwt v3.0.0 it has dynamic secretOrKey support, but has not been implemented so far in DefinitelyTyped. This commit corrects this. * Update index.d.ts --- types/passport-jwt/index.d.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/types/passport-jwt/index.d.ts b/types/passport-jwt/index.d.ts index f1c87c40ed..c300276fe2 100644 --- a/types/passport-jwt/index.d.ts +++ b/types/passport-jwt/index.d.ts @@ -1,8 +1,9 @@ -// Type definitions for passport-jwt 2.0 +// Type definitions for passport-jwt 3.0 // Project: https://github.com/themikenicholson/passport-jwt // Definitions by: TANAKA Koichi // Alex Young // David Ng +// Carlos Eduardo Scheffer // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -15,7 +16,8 @@ export declare class Strategy extends PassportStrategy { } export interface StrategyOptions { - secretOrKey: string | Buffer; + secretOrKey?: string | Buffer; + secretOrKeyProvider?: any; jwtFromRequest: JwtFromRequestFunction; issuer?: string; audience?: string; From e533e6944b2565ecd3e920d9210c72ff60cf5cda Mon Sep 17 00:00:00 2001 From: Georgiy Razumkov Date: Sat, 28 Oct 2017 05:02:23 +0500 Subject: [PATCH 065/352] add option dictFileSizeUnits (#20997) --- types/dropzone/dropzone-tests.ts | 1 + types/dropzone/index.d.ts | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/types/dropzone/dropzone-tests.ts b/types/dropzone/dropzone-tests.ts index 53cedba333..4abc3a6223 100644 --- a/types/dropzone/dropzone-tests.ts +++ b/types/dropzone/dropzone-tests.ts @@ -56,6 +56,7 @@ const dropzoneWithOptions = new Dropzone(".test", { dictRemoveFile: "", dictRemoveFileConfirmation: "", dictMaxFilesExceeded: "", + dictFileSizeUnits: { tb: "", gb: "", mb: "", kb: "", b: "" }, accept: (file: Dropzone.DropzoneFile, done: (error?: string | Error) => void) => { if (file.accepted) { diff --git a/types/dropzone/index.d.ts b/types/dropzone/index.d.ts index f809f84227..0295afbed2 100644 --- a/types/dropzone/index.d.ts +++ b/types/dropzone/index.d.ts @@ -26,6 +26,14 @@ declare namespace Dropzone { accepted: boolean; xhr?: XMLHttpRequest; } + + export interface DropzoneDictFileSizeUnits { + tb?: string; + gb?: string; + mb?: string; + kb?: string; + b?: string; + } export interface DropzoneOptions { url?: string; @@ -72,6 +80,7 @@ declare namespace Dropzone { dictRemoveFile?: string; dictRemoveFileConfirmation?: string; dictMaxFilesExceeded?: string; + dictFileSizeUnits?: DropzoneDictFileSizeUnits; accept?(file: DropzoneFile, done: (error?: string | Error) => void): void; init?(): void; From f6f55fae8377fbf7f8275632757de358cc9a95b4 Mon Sep 17 00:00:00 2001 From: pdeva Date: Fri, 27 Oct 2017 17:02:34 -0700 Subject: [PATCH 066/352] Update index.d.ts for react-redux (#20848) * Update index.d.ts for react-redux known issue described in comments * minor * update --- types/react-redux/index.d.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/types/react-redux/index.d.ts b/types/react-redux/index.d.ts index 203ce7f791..38c880ba3b 100644 --- a/types/react-redux/index.d.ts +++ b/types/react-redux/index.d.ts @@ -7,9 +7,17 @@ // Frank Tan // Nicholas Boll // Dibyo Majumdar +// Prashant Deva // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 - + +// Known Issue: +// There is a known issue in TypeScript, which doesn't allow decorators to change the signature of the classes +// they are decorating. Due to this, if you are using @connect() decorator in your code, +// you will see a bunch of errors from TypeScript. The current workaround is to use connect() as a function call on +// a separate line instead of as a decorator. Discussed in this github issue: +// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/20796 + import * as React from 'react'; import * as Redux from 'redux'; From e0baf3e2f3de8b3be7c4821c78a79ef82ceef64c Mon Sep 17 00:00:00 2001 From: Bateast2 Date: Sat, 28 Oct 2017 02:03:00 +0200 Subject: [PATCH 067/352] Updated types for angulartics 1.4 (#20657) * Updated types for angulartics 1.4 * add support for AMD/Require & UMD module --- types/angulartics/angulartics-tests.ts | 2 +- types/angulartics/index.d.ts | 49 ++++++++++++++++++++------ 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/types/angulartics/angulartics-tests.ts b/types/angulartics/angulartics-tests.ts index 5a5660a3f8..a130ec64b2 100644 --- a/types/angulartics/angulartics-tests.ts +++ b/types/angulartics/angulartics-tests.ts @@ -1,5 +1,5 @@ import * as angular from 'angular'; -import { angulartics } from 'angulartics'; +import * as angulartics from 'angulartics'; namespace Analytics { angular.module("angulartics.app", ["angulartics"]) diff --git a/types/angulartics/index.d.ts b/types/angulartics/index.d.ts index 0d9ba1f17f..e1b36bc210 100644 --- a/types/angulartics/index.d.ts +++ b/types/angulartics/index.d.ts @@ -1,11 +1,14 @@ -// Type definitions for Angulartics 1.3 +// Type definitions for Angulartics 1.4 // Project: http://luisfarzati.github.io/angulartics/ // Definitions by: Steven Fan +// Bateast2 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 import * as angular from 'angular'; +export = angulartics;//AMD/Require module support +export as namespace angulartics;//UMD module support declare namespace angulartics { interface IAngularticsStatic { @@ -13,41 +16,67 @@ declare namespace angulartics { } interface IAnalyticsService { - eventTrack(eventName: string, properties?: any): any; - getOptOut(): boolean; pageTrack(path: string, location?: angular.ILocationService): any; + eventTrack(eventName: string, properties?: any): any; + exceptionTrack(error: any, cause: string): any; + transactionTrack: any; setAlias(alias: string): any; - setOptOut(value: boolean): void; setUsername(username: string): any; - setUserProperties(properties: any): any; - setSuperProperties(properties: any): any; + setUserProperties(userProperties: any): any; + setUserPropertiesOnce(userProperties: any): any; + setSuperProperties(superProperties: any): any; + setSuperPropertiesOnce(superProperties: any): any; + incrementProperty(property: string, value?: any): any; + userTimings(properties: any): any; + clearCookies: any; + + getOptOut(): boolean; + setOptOut(value: boolean): void; } interface IAnalyticsServiceProvider extends angular.IServiceProvider { virtualPageviews(value: boolean): void; + trackStates(value: boolean): void; + trackRoutes(value: boolean): void; excludeRoutes(value: string[]): void; + queryKeysWhitelist(keys: string[]): void + queryKeysBlacklist(keys: string[]): void firstPageview(value: boolean): void; withBase(value: boolean): void; withAutoBase(value: boolean): void; - developerMode(value: boolean): void; trackExceptions(value: boolean): void; - trackRoutes(value: boolean): void; - trackStates(value: boolean): void; + developerMode(value: boolean): void; registerPageTrack(callback: (path: string, location?: angular.ILocationService) => any): void; registerEventTrack(callback: (eventName: string, properties?: any) => any): void; + registerTransactionTrack(callback: any): void; registerSetAlias(callback: (alias: string) => any): void; registerSetUsername(callback: (username: string) => any): void; registerSetUserProperties(callback: (userProperties: any) => any): void; + registerSetUserPropertiesOnce(callback: (userProperties: any) => any): void; registerSetSuperProperties(callback: (superProperties: any) => any): void; + registerSetSuperPropertiesOnce(callback: (superProperties: any) => any): void; + registerIncrementProperty(callback: (property: string, value?: any) => any): void; + registerUserTimings(callback: (properties: any) => any): void; + registerClearCookies(callback: any): void; settings: { pageTracking: { autoTrackingVirtualPages: boolean, autoTrackingFirstPage: boolean, + trackRelativePath: boolean, + trackRoutes: boolean, + trackStates: boolean, + autoBasePath: boolean, basePath: string, - autoBasePath: boolean + excludedRoutes: string[], + queryKeysWhitelisted: string[], + queryKeysBlacklisted: string[] }, + eventTracking: {}, + bufferFlushDelay: number, + trackExceptions: boolean, + optOut: boolean, developerMode: boolean }; } From 1587233ac6ea747217a63a573f3da2839b6d7c0b Mon Sep 17 00:00:00 2001 From: Dolan Date: Sat, 28 Oct 2017 01:18:02 +0100 Subject: [PATCH 068/352] Binary parser typings (#21041) * Initial commit * Add strict function type check --- types/binary-parser/binary-parser-tests.ts | 95 +++++++++++++ types/binary-parser/index.d.ts | 147 +++++++++++++++++++++ types/binary-parser/tsconfig.json | 23 ++++ types/binary-parser/tslint.json | 1 + 4 files changed, 266 insertions(+) create mode 100644 types/binary-parser/binary-parser-tests.ts create mode 100644 types/binary-parser/index.d.ts create mode 100644 types/binary-parser/tsconfig.json create mode 100644 types/binary-parser/tslint.json diff --git a/types/binary-parser/binary-parser-tests.ts b/types/binary-parser/binary-parser-tests.ts new file mode 100644 index 0000000000..d0d09e5ef7 --- /dev/null +++ b/types/binary-parser/binary-parser-tests.ts @@ -0,0 +1,95 @@ +import { Parser } from "binary-parser"; + +// Build an IP packet header Parser +const ipHeader = new Parser() + .endianess('big') + .bit4('version') + .bit4('headerLength') + .uint8('tos') + .uint16('packetLength') + .uint16('id') + .bit3('offset') + .bit13('fragOffset') + .uint8('ttl') + .uint8('protocol') + .uint16('checksum') + .array('src', { + type: 'uint8', + length: 4 + }) + .array('dst', { + type: 'uint8', + length: 4 + }); + +// Prepare buffer to parse. +const buf = new Buffer('450002c5939900002c06ef98adc24f6c850186d1', 'hex'); + +// Parse buffer and show result +ipHeader.parse(buf); + +const parser2 = new Parser() + // Signed 32-bit integer (little endian) + .int32le('a') + // Unsigned 8-bit integer + .uint8('b') + // Signed 16-bit integer (big endian) + .int16be('c'); + +const parser3 = new Parser() + // 32-bit floating value (big endian) + .floatbe('a') + // 64-bit floating value (little endian) + .doublele('b'); + +const parser4 = new Parser() + // Statically sized array + .array('data', { + type: 'int32', + length: 8 + }) + + // Dynamically sized array (references another variable) + .uint8('dataLength') + .array('data2', { + type: 'int32', + length: 'dataLength' + }) + + // Dynamically sized array (with some calculation) + .array('data3', { + type: 'int32', + length: () => 4 // other fields are available through this + }) + + // Statically sized array + .array('data4', { + type: 'int32', + lengthInBytes: 16 + }) + + // Dynamically sized array (references another variable) + .uint8('dataLengthInBytes') + .array('data5', { + type: 'int32', + lengthInBytes: 'dataLengthInBytes' + }) + + // Dynamically sized array (with some calculation) + .array('data6', { + type: 'int32', + lengthInBytes: () => 4, // other fields are available through this + }) + + // Dynamically sized array (with stop-check on parsed item) + .array('data7', { + type: 'int32', + readUntil: (item, buffer) => true // stop when specific item is parsed. buffer can be used to perform a read-ahead. + }); + +const parser5 = new Parser() + .array('ipv4', { + type: 'uint8', + length: '4', + formatter: (arr) => { } + }); diff --git a/types/binary-parser/index.d.ts b/types/binary-parser/index.d.ts new file mode 100644 index 0000000000..657996bd8d --- /dev/null +++ b/types/binary-parser/index.d.ts @@ -0,0 +1,147 @@ +// Type definitions for binary-parser 1.3 +// Project: https://github.com/keichi/binary-parser +// Definitions by: Benjamin Riggs , Dolan Miu +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +export interface Parser { + parse(buffer: Buffer, callback?: (err?: Error, result?: any) => void): Parser.Parsed; + + create(constructorFunction: ObjectConstructor): Parser; + + int8(name: string, options?: Parser.Options): Parser; + uint8(name: string, options?: Parser.Options): Parser; + + int16(name: string, options?: Parser.Options): Parser; + uint16(name: string, options?: Parser.Options): Parser; + int16le(name: string, options?: Parser.Options): Parser; + int16be(name: string, options?: Parser.Options): Parser; + uint16le(name: string, options?: Parser.Options): Parser; + uint16be(name: string, options?: Parser.Options): Parser; + + int32(name: string, options?: Parser.Options): Parser; + uint32(name: string, options?: Parser.Options): Parser; + int32le(name: string, options?: Parser.Options): Parser; + int32be(name: string, options?: Parser.Options): Parser; + uint32le(name: string, options?: Parser.Options): Parser; + uint32be(name: string, options?: Parser.Options): Parser; + + bit1(name: string, options?: Parser.Options): Parser; + bit2(name: string, options?: Parser.Options): Parser; + bit3(name: string, options?: Parser.Options): Parser; + bit4(name: string, options?: Parser.Options): Parser; + bit5(name: string, options?: Parser.Options): Parser; + bit6(name: string, options?: Parser.Options): Parser; + bit7(name: string, options?: Parser.Options): Parser; + bit8(name: string, options?: Parser.Options): Parser; + bit9(name: string, options?: Parser.Options): Parser; + bit10(name: string, options?: Parser.Options): Parser; + bit11(name: string, options?: Parser.Options): Parser; + bit12(name: string, options?: Parser.Options): Parser; + bit13(name: string, options?: Parser.Options): Parser; + bit14(name: string, options?: Parser.Options): Parser; + bit15(name: string, options?: Parser.Options): Parser; + bit16(name: string, options?: Parser.Options): Parser; + bit17(name: string, options?: Parser.Options): Parser; + bit18(name: string, options?: Parser.Options): Parser; + bit19(name: string, options?: Parser.Options): Parser; + bit20(name: string, options?: Parser.Options): Parser; + bit21(name: string, options?: Parser.Options): Parser; + bit22(name: string, options?: Parser.Options): Parser; + bit23(name: string, options?: Parser.Options): Parser; + bit24(name: string, options?: Parser.Options): Parser; + bit25(name: string, options?: Parser.Options): Parser; + bit26(name: string, options?: Parser.Options): Parser; + bit27(name: string, options?: Parser.Options): Parser; + bit28(name: string, options?: Parser.Options): Parser; + bit29(name: string, options?: Parser.Options): Parser; + bit30(name: string, options?: Parser.Options): Parser; + bit31(name: string, options?: Parser.Options): Parser; + bit32(name: string, options?: Parser.Options): Parser; + + float(name: string, options?: Parser.Options): Parser; + floatle(name: string, options?: Parser.Options): Parser; + floatbe(name: string, options?: Parser.Options): Parser; + + double(name: string, options?: Parser.Options): Parser; + doublele(name: string, options?: Parser.Options): Parser; + doublebe(name: string, options?: Parser.Options): Parser; + + string(name: string, options?: Parser.StringOptions): Parser; + + buffer(name: string, options: Parser.BufferOptions): Parser; + + array(name: string, options: Parser.ArrayOptions): Parser; + + choice(name: string, options: Parser.ChoiceOptions): Parser; + + nest(name: string, options: Parser.NestOptions): Parser; + + skip(length: number): Parser; + + endianess(endianess: Parser.Endianness): Parser; /* [sic] */ + + namely(alias: string): Parser; + + compile(): void; + + getCode(): string; +} + +export interface ParserConstructor { + new(): Parser; +} + +export const Parser: ParserConstructor; + +export namespace Parser { + type Data = number | string | Array | Parsed | Buffer; + interface Parsed { + [name: string]: Data; + } + + interface Options { + formatter?: ((value: Data) => any); + assert?: string | number | ((value: Data) => boolean); + } + + interface StringOptions extends Options { + encoding?: string; + length?: number | string | ((this: Parsed) => number); + zeroTerminated?: boolean; + greedy?: boolean; + stripNull?: boolean; + } + + interface BufferOptions extends Options { + clone?: boolean; + length?: number | string | ((this: Parsed) => number); + readUntil?: string | ((item: number, buffer: Buffer) => boolean); + } + + interface ArrayOptions extends Options { + type: string | Parser; + length?: number | string | ((this: Parsed) => number); + lengthInBytes?: number | string | ((this: Parsed) => number); + readUntil?: string | ((item: number, buffer: Buffer) => boolean); + } + + interface ChoiceOptions extends Options { + tag: string | ((this: Parsed) => number); + choices: { [item: number]: Parser | string }; + defaultChoice?: Parser | string; + } + + interface NestOptions extends Options { + type: Parser | string; + } + + type Endianness = + 'little' | + 'big'; + + interface Context { + [name: string]: Parsed; + } +} diff --git a/types/binary-parser/tsconfig.json b/types/binary-parser/tsconfig.json new file mode 100644 index 0000000000..cb361f52c5 --- /dev/null +++ b/types/binary-parser/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", + "binary-parser-tests.ts" + ] +} diff --git a/types/binary-parser/tslint.json b/types/binary-parser/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/binary-parser/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 2b67b8a4e3f3c9721ce786799255979e2e66edb3 Mon Sep 17 00:00:00 2001 From: Yasunori Ohoka Date: Sat, 28 Oct 2017 09:18:25 +0900 Subject: [PATCH 069/352] =?UTF-8?q?Add=20=E2=80=98moji=E2=80=99=20types=20?= =?UTF-8?q?(#21019)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add ‘moji’ types * moji: Fix tsconfig * moji: Fix tslint * moji: Fix tslint --- types/moji/index.d.ts | 32 ++++++++++++++++++++++++++++++++ types/moji/moji-tests.ts | 23 +++++++++++++++++++++++ types/moji/tsconfig.json | 24 ++++++++++++++++++++++++ types/moji/tslint.json | 1 + 4 files changed, 80 insertions(+) create mode 100644 types/moji/index.d.ts create mode 100644 types/moji/moji-tests.ts create mode 100644 types/moji/tsconfig.json create mode 100644 types/moji/tslint.json diff --git a/types/moji/index.d.ts b/types/moji/index.d.ts new file mode 100644 index 0000000000..ae45f6ac26 --- /dev/null +++ b/types/moji/index.d.ts @@ -0,0 +1,32 @@ +// Type definitions for moji 0.5 +// Project: https://github.com/niwaringo/moji +// Definitions by: Yasunori Ohoka +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +declare namespace moji { + type Mojisyu = "ZE" | "HE" | "ZS" | "HS" | "HG" | "KK" | "ZK" | "HK"; + + interface MojisyuRange { + start: number; + end: number; + } + + interface MojisyuRegExp { + regexp: RegExp; + list: string[]; + } + + interface Moji { + convert(beforeType: Mojisyu, afterType: Mojisyu): Moji; + trim(): Moji; + filter(type: Mojisyu): Moji; + reject(type: Mojisyu): Moji; + toString(): string; + } + + function addMojisyu(type: string, mojisyu: MojisyuRange | MojisyuRegExp): void; +} + +declare function moji(moji: string): moji.Moji; +export = moji; diff --git a/types/moji/moji-tests.ts b/types/moji/moji-tests.ts new file mode 100644 index 0000000000..05be3e43c1 --- /dev/null +++ b/types/moji/moji-tests.ts @@ -0,0 +1,23 @@ +import moji = require('moji'); + +moji('ABCD01234').convert('ZE', 'HE').toString(); +moji('ABCD01234').convert('HE', 'ZE').toString(); +// tslint:disable-next-line:no-irregular-whitespace +moji(' ').convert('ZS', 'HS').toString(); +moji('あいうえお').convert('HG', 'KK').toString(); +moji('アイウエオ').convert('KK', 'HG').toString(); +moji('アイウエオ').convert('ZK', 'HK').toString(); +moji('アイウエオ').convert('HK', 'ZK').toString(); +moji('アイウエオ').convert('HK', 'ZK').convert('KK', 'HG').toString(); + +moji(' アイウエオ ').trim().toString(); + +moji('abcあいうアイウ123').filter('HG').toString(); + +moji('abcあいうアイウ123').reject('HG').toString(); + +moji.addMojisyu('ZE', { start: 0xff01, end: 0xff5e }); +moji.addMojisyu('HK', { + regexp: /([\uff66-\uff9c]\uff9e)|([\uff8a-\uff8e]\uff9f)|([\uff61-\uff9f])/g, + list: ["。", "「", "」"] +}); diff --git a/types/moji/tsconfig.json b/types/moji/tsconfig.json new file mode 100644 index 0000000000..a6b2e51f26 --- /dev/null +++ b/types/moji/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "moji-tests.ts" + ] +} diff --git a/types/moji/tslint.json b/types/moji/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/moji/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 160b4e5701e125dedc56a1e0676551fb6cb5c541 Mon Sep 17 00:00:00 2001 From: pheromonez Date: Sat, 28 Oct 2017 11:18:58 +1100 Subject: [PATCH 070/352] Added definitions for @google-cloud/pubsub (#21057) * Added definitions for @google-cloud/pubsub * Changed Project as requested by review comments --- .../google-cloud__pubsub-tests.ts | 578 ++++++++++++++++++ types/google-cloud__pubsub/index.d.ts | 344 +++++++++++ types/google-cloud__pubsub/tsconfig.json | 28 + types/google-cloud__pubsub/tslint.json | 1 + 4 files changed, 951 insertions(+) create mode 100644 types/google-cloud__pubsub/google-cloud__pubsub-tests.ts create mode 100644 types/google-cloud__pubsub/index.d.ts create mode 100644 types/google-cloud__pubsub/tsconfig.json create mode 100644 types/google-cloud__pubsub/tslint.json diff --git a/types/google-cloud__pubsub/google-cloud__pubsub-tests.ts b/types/google-cloud__pubsub/google-cloud__pubsub-tests.ts new file mode 100644 index 0000000000..7a9b9905c2 --- /dev/null +++ b/types/google-cloud__pubsub/google-cloud__pubsub-tests.ts @@ -0,0 +1,578 @@ +import * as PubSub from '@google-cloud/pubsub'; + +// AUTHOR NOTES: We use the examples directly from the library documentation +// where possible. If there is a problem with a given example (e.g. undocumented +// feature or option), we make a note of it and provide an alternative example +// call instead. + +/////////////////////////////////////////////////////////////////////////////// +// PUBSUB +/////////////////////////////////////////////////////////////////////////////// +{ + let pubsub: PubSub.PubSub; + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub?method=PubSub + // When running on Google Cloud Platform: + pubsub = PubSub(); + // When running elsewhere: + pubsub = PubSub({ + projectId: 'grape-spaceship-123', + keyFilename: '/path/to/keyfile.json', + }); + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub?method=createSubscription + // Subscribe to a topic: + pubsub.createSubscription('messageCenter', 'newMessages', (err, subscription, apiResponse) => { }); + // Customize the subscription: + // NOTE: ackDeadline, as given in the example, is undocumented, so create a subscription only with the KNOWN options + pubsub.createSubscription('messageCenter', 'newMessages', { + retainAckedMessages: true, + }, (err, subscription, apiResponse) => { }); + // If the callback is omitted, we'll return a Promise. + pubsub.createSubscription('messageCenter', 'newMessages').then((data) => { + const subscription = data[0]; + const apiResponse = data[1]; + }); + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub?method=createTopic + // Create topic with callback + pubsub.createTopic('my-new-topic', (err, topic, apiResponse) => { + if (!err) { + // The topic was created successfully. + } + }); + // If the callback is omitted, we'll return a Promise. + pubsub.createTopic('my-new-topic').then((data) => { + const topic = data[0]; + const apiResponse = data[1]; + }); + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub?method=getSnapshots + // Get snapshots: + pubsub.getSnapshots((err, snapshots) => { + if (!err) { + // snapshots is an array of Snapshot objects. + } + }); + // If the callback is omitted, we'll return a Promise. + pubsub.getSnapshots().then((data) => { + const snapshots = data[0]; + }); + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub?method=getSnapshotsStream + // Get snapshots stream + pubsub.getSnapshotsStream() + .on('error', console.error) + .on('data', (snapshot) => { + // snapshot is a Snapshot object. + }) + .on('end', () => { + // All snapshots retrieved. + }); + // If you anticipate many results, you can end a stream early to prevent unnecessary processing and API requests. + // NOTE: this had to be modified to work around the 'this' keyword as used in the example + { + const stream = pubsub.getSnapshotsStream(); + stream.on('data', (snapshot) => { + stream.end(); + }); + } + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub?method=getSubscriptions + // Get subscriptions: + pubsub.getSubscriptions((err, subscriptions) => { + if (!err) { + // subscriptions is an array of Subscription objects. + } + }); + // If the callback is omitted, we'll return a Promise. + pubsub.getSubscriptions().then((data) => { + const subscriptions = data[0]; + }); + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub?method=getSubscriptionsStream + // Get subscriptions stream + pubsub.getSubscriptionsStream() + .on('error', console.error) + .on('data', (subscription) => { + // subscription is a Subscription object. + }) + .on('end', () => { + // All subscriptions retrieved. + }); + // If you anticipate many results, you can end a stream early to prevent unnecessary processing and API requests. + // Note: this had to be modified to work around the 'this' keyword as used in the example. + { + const stream = pubsub.getSubscriptionsStream(); + stream.on('data', (subscription) => { + stream.end(); + }); + } + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub?method=getTopics + // Get topics: + pubsub.getTopics((err, topics) => { + if (!err) { + // topics is an array of Topic objects. + } + }); + // Customize the query: + pubsub.getTopics({ + pageSize: 3 + }, (err, topics) => { }); + // If the callback is omitted, we'll return a Promise. + pubsub.getTopics().then((data) => { + const topics = data[0]; + }); + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub?method=getTopicsStream + // Get topics stream: + pubsub.getTopicsStream() + .on('error', console.error) + .on('data', (topic) => { + // topic is a Topic object. + }) + .on('end', () => { + // All topics retrieved. + }); + // If you anticipate many results, you can end a stream early to prevent unnecessary processing and API requests. + // Note: this had to be modified to work around the 'this' keyword as used in the example. + { + const stream = pubsub.getTopicsStream(); + stream.on('data', (topic) => { + stream.end(); + }); + } + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub?method=snapshot + // Snapshot: + { + const snapshot = pubsub.snapshot('my-snapshot'); + } + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub?method=subscription + // Subscription: + { + const subscription = pubsub.subscription('my-subscription'); + + // Register a listener for `message` events. + subscription.on('message', (message) => { + // Called every time a message is received. + // message.id = ID of the message. + // message.ackId = ID used to acknowledge the message receival. + // message.data = Contents of the message. + // message.attributes = Attributes of the message. + // message.publishTime = Timestamp when Pub/Sub received the message. + }); + } + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub?method=topic + // Topic: + { + const topic = pubsub.topic('my-topic'); + } +} + +/////////////////////////////////////////////////////////////////////////////// +// PUBLISHER +/////////////////////////////////////////////////////////////////////////////// +{ + const pubsub = PubSub(); + const topic = pubsub.topic('my-topic'); + const publisher = topic.publisher(); + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/publisher?method=publish + // Publish: + publisher.publish(new Buffer('Hello, world!'), (err, messageId) => { + if (err) { + // Error handling omitted. + } + }); + // Optionally you can provide an object containing attributes for the message. + publisher.publish(new Buffer('Hello, world!'), { key: 'value' }, (err, messageId) => { + if (err) { + // Error handling omitted. + } + }); +} + +/////////////////////////////////////////////////////////////////////////////// +// SNAPSHOT +/////////////////////////////////////////////////////////////////////////////// +{ + const pubsub = PubSub(); + const subscription = pubsub.subscription('my-subscription'); + + // There are two type of snapshots; the ones obtained from subscription.createSnapshot() have more functionality + const snapshot = pubsub.snapshot('my-snapshot'); + const snapshotFromSubscription = subscription.snapshot('my-snapshot'); + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/snapshot?method=create + // Note: Only available to snapshots created via methods of Subscription + // Create snapshot + snapshotFromSubscription.create('my-snapshot', (err, snapshot, apiResponse) => { + if (!err) { + // The snapshot was created successfully. + } + }); + // If the callback is omitted, we'll return a Promise. + snapshotFromSubscription.create('my-snapshot').then((data) => { + const snapshot = data[0]; + const apiResponse = data[1]; + }); + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/snapshot?method=delete + // Delete the snapshot + snapshot.delete((err, apiResponse) => { }); + // If the callback is omitted, we'll return a Promise. + snapshot.delete().then((data) => { + const apiResponse = data[0]; + }); + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/snapshot?method=seek + // Note: Only available to snapshots created via methods of Subscription + // Seek: + snapshotFromSubscription.seek((err, apiResponse) => { }); + // If the callback is omitted, we'll return a Promise. + snapshotFromSubscription.seek().then((data) => { + const apiResponse = data[0]; + }); +} + +/////////////////////////////////////////////////////////////////////////////// +// SUBSCRIPTION +/////////////////////////////////////////////////////////////////////////////// +{ + const pubsub = PubSub(); + const topic = pubsub.topic('my-topic'); + const subscription = topic.subscription('my-subscription'); + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/subscription?method=close + // Close: + subscription.close((err) => { + if (err) { + // Error handling omitted. + } + }); + // If the callback is omitted, we'll return a Promise. + subscription.close().then(() => { }); + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/subscription?method=createSnapshot + // Create snapshot: + subscription.createSnapshot('my-snapshot', (err, snapshot, apiResponse) => { + if (!err) { + // The snapshot was created successfully. + } + }); + // If the callback is omitted, we'll return a Promise. + subscription.createSnapshot('my-snapshot').then((data) => { + const snapshot = data[0]; + const apiResponse = data[1]; + }); + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/subscription?method=delete + // Delete: + subscription.delete((err, apiResponse) => { }); + // If the callback is omitted, we'll return a Promise. + subscription.delete().then((data) => { + const apiResponse = data[0]; + }); + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/subscription?method=exists + // Exists: + subscription.exists((err, exists) => { }); + // If the callback is omitted, we'll return a Promise. + subscription.exists().then((data) => { + const exists = data[0]; + }); + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/subscription?method=get + // Get: + subscription.get((err, subscription, apiResponse) => { + // The `subscription` data has been populated. + }); + // If the callback is omitted, we'll return a Promise. + subscription.get().then((data) => { + const subscription = data[0]; + const apiResponse = data[1]; + }); + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/subscription?method=getMetadata + // Get metadata: + subscription.getMetadata((err, apiResponse) => { + if (err) { + // Error handling omitted. + } + }); + // If the callback is omitted, we'll return a Promise. + subscription.getMetadata().then((data) => { + const apiResponse = data[0]; + }); + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/subscription?method=modifyPushConfig + // Modify push config: + // Note: Had to modify the code to force typings + { + const pushConfig: PubSub.Subscription.PushConfig = { + pushEndpoint: 'https://mydomain.com/push', + attributes: { + 'x-goog-version': 'v1', + } + }; + subscription.modifyPushConfig(pushConfig, (err, apiResponse) => { + if (err) { + // Error handling omitted. + } + }); + // If the callback is omitted, we'll return a Promise. + subscription.modifyPushConfig(pushConfig).then((data) => { + const apiResponse = data[0]; + }); + } + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/subscription?method=seek + // Seek: + { + const callback: PubSub.Subscription.SeekCallback = (err, resp) => { + if (!err) { + // Seek was successful. + } + }; + subscription.seek('my-snapshot', callback); + // Alternatively, to specify a certain point in time, you can provide a Date object. + subscription.seek(new Date('October 21 2015'), callback); + } + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/subscription?method=setMetadata + { + const metadata = { + key: 'value' + }; + + // Set metadata + subscription.setMetadata(metadata, (err, apiResponse) => { + if (err) { + // Error handling omitted. + } + }); + // If the callback is omitted, we'll return a Promise. + subscription.setMetadata(metadata).then((data) => { + const apiResponse = data[0]; + }); + } + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/subscription?method=snapshot + // Snapshot: + subscription.snapshot('my-snapshot'); +} + +/////////////////////////////////////////////////////////////////////////////// +// TOPIC +/////////////////////////////////////////////////////////////////////////////// +{ + const pubsub = PubSub(); + const topic = pubsub.topic('my-topic'); + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/topic?method=create + // Create: + topic.create((err, topic, apiResponse) => { + if (!err) { + // The topic was created successfully. + } + }); + // If the callback is omitted, we'll return a Promise. + topic.create().then((data) => { + const topic = data[0]; + const apiResponse = data[1]; + }); + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/topic?method=createSubscription + { + const callback: PubSub.Topic.CreateSubscriptionCallback = (err, subscription, apiResponse) => { }; + + // Without specifying any options. + topic.createSubscription('newMessages', callback); + + // With options. + // Note: ackDeadline not documented, so we use a different option + topic.createSubscription('newMessages', { + // ackDeadline: 90000 // 90 seconds + retainAckedMessages: true, + }, callback); + + // If the callback is omitted, we'll return a Promise. + topic.createSubscription('newMessages').then((data) => { + const subscription = data[0]; + const apiResponse = data[1]; + }); + } + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/topic?method=delete + // Delete: + topic.delete((err, apiResponse) => { }); + // If the callback is omitted, we'll return a Promise. + topic.delete().then((data) => { + const apiResponse = data[0]; + }); + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/topic?method=exists + // Exists: + topic.exists((err, exists) => { }); + // If the callback is omitted, we'll return a Promise. + topic.exists().then((data) => { + const exists = data[0]; + }); + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/topic?method=get + // Get: + topic.get((err, topic, apiResponse) => { + // The `topic` data has been populated. + }); + // If the callback is omitted, we'll return a Promise. + topic.get().then((data) => { + const topic = data[0]; + const apiResponse = data[1]; + }); + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/topic?method=getMetadata + // Get metadata + topic.getMetadata((err, apiResponse) => { }); + // If the callback is omitted, we'll return a Promise. + topic.getMetadata().then((data) => { + const apiResponse = data[0]; + }); + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/topic?method=getSubscriptions + // Get subscriptions: + // Note: Modified so that the callback is a constant + { + const callback: PubSub.Topic.GetSubscriptionsCallback = (err, subscriptions) => { + // subscriptions is an array of `Subscription` objects. + }; + + topic.getSubscriptions(callback); + + // Customize the query. + topic.getSubscriptions({ + pageSize: 3 + }, callback); + + // If the callback is omitted, we'll return a Promise. + topic.getSubscriptions().then((data) => { + const subscriptions = data[0]; + }); + } + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/topic?method=getSubscriptionsStream + // Get subscriptions stream: + topic.getSubscriptionsStream() + .on('error', console.error) + .on('data', (subscription) => { + // subscription is a Subscription object. + }) + .on('end', () => { + // All subscriptions retrieved. + }); + // If you anticipate many results, you can end a stream early to prevent unnecessary processing and API requests. + { + const stream = topic.getSubscriptionsStream(); + stream.on('data', (subscription) => { + stream.end(); + }); + } + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/topic?method=publisher + topic.publisher().publish(new Buffer('Hello, world!'), (err, messageId) => { + if (err) { + // Error handling omitted. + } + }); + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/topic?method=subscription + // Register a listener for `message` events. + topic.subscription('my-subscription').on('message', (message) => { + // Called every time a message is received. + // message.id = ID of the message. + // message.ackId = ID used to acknowledge the message receival. + // message.data = Contents of the message. + // message.attributes = Attributes of the message. + // message.publishTime = Timestamp when Pub/Sub received the message. + }); +} + +/////////////////////////////////////////////////////////////////////////////// +// IAM +/////////////////////////////////////////////////////////////////////////////// +{ + const pubsub = PubSub(); + const topic = pubsub.topic('my-topic'); + const subscription = topic.subscription('my-subscription'); + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/subscription?method=iam.getPolicy + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/topic?method=iam.getPolicy + // Get policy: + topic.iam.getPolicy((err, policy, apiResponse) => { }); + subscription.iam.getPolicy((err, policy, apiResponse) => { }); + // If the callback is omitted, we'll return a Promise. + topic.iam.getPolicy().then((data) => { + const policy = data[0]; + const apiResponse = data[1]; + }); + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/subscription?method=iam.setPolicy + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/topic?method=iam.setPolicy + { + const myPolicy = { + bindings: [ + { + role: 'roles/pubsub.subscriber', + members: ['serviceAccount:myotherproject@appspot.gserviceaccount.com'] + } + ] + }; + + // Set policy: + topic.iam.setPolicy(myPolicy, (err, policy, apiResponse) => { }); + subscription.iam.setPolicy(myPolicy, (err, policy, apiResponse) => { }); + + // If the callback is omitted, we'll return a Promise. + topic.iam.setPolicy(myPolicy).then((data) => { + const policy = data[0]; + const apiResponse = data[1]; + }); + } + + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/subscription?method=iam.testPermissions + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/topic?method=iam.testPermissions + { + const test = 'pubsub.topics.update'; + + // Test permission + topic.iam.testPermissions(test, (err, permissions, apiResponse) => { + console.log(permissions); + // { + // "pubsub.topics.update": true + // } + }); + + // Test several permissions at once. + const tests = [ + 'pubsub.subscriptions.consume', + 'pubsub.subscriptions.update' + ]; + + subscription.iam.testPermissions(tests, (err, permissions) => { + console.log(permissions); + // { + // "pubsub.subscriptions.consume": true, + // "pubsub.subscriptions.update": false + // } + }); + + // If the callback is omitted, we'll return a Promise. + topic.iam.testPermissions(test).then((data) => { + const permissions = data[0]; + const apiResponse = data[1]; + }); + } +} diff --git a/types/google-cloud__pubsub/index.d.ts b/types/google-cloud__pubsub/index.d.ts new file mode 100644 index 0000000000..7c9014b7d3 --- /dev/null +++ b/types/google-cloud__pubsub/index.d.ts @@ -0,0 +1,344 @@ +// Type definitions for @google-cloud/pubsub 0.14 +// Project: https://github.com/GoogleCloudPlatform/google-cloud-node/tree/master/packages/pubsub +// Definitions by: Paul Huynh +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +/// +import { EventEmitter } from "events"; +import { Duplex } from "stream"; + +declare namespace PubSub { + // TODO write definitions for the for v1 + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/v1 + function v1(config?: GCloudConfiguration): any; + + interface GCloudConfiguration { + projectId?: string; + keyFilename?: string; + email?: string; + credentials?: { + client_email?: string; + private_key?: string + }; + autoRetry?: boolean; + maxRetries?: number; + promise?: any; + } + + interface PubSub { + createSubscription(topic: Topic | string, name: string, options?: PubSub.CreateSubscriptionOptions): Promise; + createSubscription(topic: Topic | string, name: string, callback: PubSub.CreateSubscriptionCallback): void; + createSubscription(topic: Topic | string, name: string, options: PubSub.CreateSubscriptionOptions, callback: PubSub.CreateSubscriptionCallback): void; + + createTopic(name: string, gaxOpts?: GAX.CallOptions): Promise; + createTopic(name: string, callback: PubSub.CreateTopicCallback): void; + createTopic(name: string, gaxOpts: GAX.CallOptions, callback: PubSub.CreateTopicCallback): void; + + getSnapshots(options?: PubSub.GetSnapshotsOptions): Promise; + getSnapshots(callback: PubSub.GetSnapshotsCallback): void; + getSnapshots(options: PubSub.GetSnapshotsOptions, callback: PubSub.GetSnapshotsCallback): void; + + getSnapshotsStream(options?: PubSub.GetSnapshotsOptions): Duplex; + + getSubscriptions(options?: PubSub.GetSubscriptionsOptions): Promise; + getSubscriptions(callback: PubSub.GetSubscriptionsCallback): void; + getSubscriptions(options: PubSub.GetSubscriptionsOptions, callback: PubSub.GetSubscriptionsCallback): void; + + getSubscriptionsStream(options?: PubSub.GetSubscriptionsOptions): Duplex; + + getTopics(query?: PubSub.GetTopicsQuery): Promise; + getTopics(callback: PubSub.GetTopicsCallback): void; + getTopics(query: PubSub.GetTopicsQuery, callback: PubSub.GetTopicsCallback): void; + + getTopicsStream(query?: PubSub.GetTopicsQuery): Duplex; + + snapshot(name: string): Snapshot; + + subscription(name: string, options?: PubSub.SubscriptionOptions): Subscription; + + topic(name: string): Topic; + } + namespace PubSub { + interface CreateSubscriptionOptions { + flowControl?: { + maxBytes?: number; + maxMessages?: number; + }; + gaxOpts?: GAX.CallOptions; + messageRetentionDuration?: number | Date; + pushEndpoint?: string; + retainAckedMessages?: boolean; + } + type CreateSubscriptionCallback = (err: Error | null, subscription: Subscription, apiResponse: object) => void; + + type CreateTopicCallback = (err: Error | null, topic: Topic, apiResponse: object) => void; + + interface GetSnapshotsOptions { + autoPaginate?: boolean; + gaxOpts?: GAX.CallOptions; + pageSize?: number; + pageToken?: string; + } + type GetSnapshotsCallback = (err: Error | null, snapshots: Snapshot[]) => void; + + interface GetSubscriptionsOptions { + autoPaginate?: boolean; + gaxOpts?: GAX.CallOptions; + pageSize?: number; + pageToken?: string; + topic?: Topic | string; + } + type GetSubscriptionsCallback = (err: Error | null, subscriptions: Subscription[], apiResponse: object) => void; + + interface GetTopicsQuery { + autoPaginate?: boolean; + gaxOpts?: GAX.CallOptions; + pageSize?: number; + pageToken?: string; + } + type GetTopicsCallback = (err: Error | null, topics: Topic[], apiResponse: object) => void; + + interface SubscriptionOptions { + flowControl?: { + maxBytes?: number; + maxMessages?: number; + }; + maxConnections?: number; + } + } + + interface Publisher { + publish(data: Buffer, callback: Publisher.PublishCallback): void; + publish(data: Buffer, attributes: object, callback: Publisher.PublishCallback): void; + publish(data: Buffer, attributes?: object): Promise; + } + namespace Publisher { + type PublishCallback = (error: Error | null, messageId: string) => void; + } + + interface Snapshot { + delete(): Promise; + delete(callback: Snapshot.DeleteCallback): void; + } + interface SnapshotFromSubscription extends Snapshot { + create(name: string): Promise; + create(name: string, callback: Snapshot.CreateCallback): void; + + seek(): Promise; + seek(callback: Snapshot.SeekCallback): void; + } + namespace Snapshot { + type DeleteCallback = (err: Error | null, apiResponse: object) => void; + + type CreateCallback = (err: Error | null, snapshot: Snapshot, apiResponse: object) => void; + + type SeekCallback = (err: Error | null, apiResponse: object) => void; + } + + interface Subscription extends EventEmitter { + close(): Promise; + close(callback: Subscription.CloseCallback): void; + + createSnapshot(name: string, gaxOpts?: GAX.CallOptions): Promise; + createSnapshot(name: string, callback: Subscription.CreateSnapshotCallback): void; + createSnapshot(name: string, gaxOpts: GAX.CallOptions, callback: Subscription.CreateSnapshotCallback): void; + + delete(gaxOpts?: GAX.CallOptions): Promise; + delete(callback: Subscription.DeleteCallback): void; + delete(gaxOpts: GAX.CallOptions, callback: Subscription.DeleteCallback): void; + + exists(): Promise; + exists(callback: Subscription.ExistsCallback): void; + + get(gaxOpts?: GAX.CallOptions): Promise; // TODO: only expose autoCreate + // NOTE: The following are not documented, but are possible signatures base on the source code + get(callback: Subscription.GetCallback): void; + get(gaxOpts: GAX.CallOptions, callback: Subscription.GetCallback): void; + + getMetadata(gaxOpts?: GAX.CallOptions): Promise; + getMetadata(callback: Subscription.GetMetadataCallback): void; + getMetadata(gaxOpts: GAX.CallOptions, callback: Subscription.GetMetadataCallback): void; + + iam: IAM; + + modifyPushConfig(config: Subscription.PushConfig, gaxOpts?: GAX.CallOptions): Promise; + modifyPushConfig(config: Subscription.PushConfig, callback: Subscription.ModifyPushConfigCallback): void; + modifyPushConfig(config: Subscription.PushConfig, gaxOpts: GAX.CallOptions, callback: Subscription.ModifyPushConfigCallback): void; + + seek(snapshot: string | Date, callback: Subscription.SeekCallback): void; + seek(snapshot: string | Date, gaxOpts: GAX.CallOptions, callback: Subscription.SeekCallback): void; + + setMetadata(metadata: object, gaxOpts?: GAX.CallOptions): Promise; + setMetadata(metadata: object, callback: Subscription.SetMetadataCallback): void; + setMetadata(metadata: object, gaxOpts: GAX.CallOptions, callback: Subscription.SetMetadataCallback): void; + + snapshot(name: string): SnapshotFromSubscription; + } + namespace Subscription { + type CloseCallback = (err: Error | null) => void; + + type CreateSnapshotCallback = (err: Error | null, snapshot: SnapshotFromSubscription, apiResponse: object) => void; + + type DeleteCallback = (err: Error | null, apiResponse: object) => void; + + type ExistsCallback = (err: Error | null, exists: boolean) => void; + + type GetCallback = (err: Error | null, subscription: Subscription, apiResponse: object) => void; + + type GetMetadataCallback = (err: Error | null, apiResponse: object) => void; + + interface PushConfig { + pushEndpoint?: string; + // https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions#pushconfig + attributes?: PushConfigAttributes; + } + interface PushConfigAttributes { + 'x-goog-version': 'v1beta' | 'v1' | 'v1beta2'; + } + type ModifyPushConfigCallback = (err: Error | null, apiResponse: object) => void; + + type SeekCallback = (err: Error | null, apiResponse: object) => void; + + type SetMetadataCallback = (err: Error | null, apiResponse: object) => void; + } + + interface Topic { + create(gaxOpts?: GAX.CallOptions): Promise; + create(callback: Topic.CreateCallback): void; + create(gaxOpts: GAX.CallOptions, callback: Topic.CreateCallback): void; + + createSubscription(nameOrOptions?: string | Topic.CreateSubscriptionOptions): Promise; + createSubscription(name: string, options: Topic.CreateSubscriptionOptions): Promise; + createSubscription(callback: Topic.CreateSubscriptionCallback): void; + createSubscription(nameOrOptions: string | Topic.CreateSubscriptionOptions, callback: Topic.CreateSubscriptionCallback): void; + createSubscription(name: string, options: Topic.CreateSubscriptionOptions, callback: Topic.CreateSubscriptionCallback): void; + + delete(gaxOpts?: GAX.CallOptions): Promise; + delete(callback: Topic.DeleteCallback): void; + delete(gaxOpts: GAX.CallOptions, callback: Topic.DeleteCallback): void; + + exists(): Promise; + exists(callback: Topic.ExistsCallback): void; + + // NOTE: The documentation in the link is incomplete; the function takes a callback + // as second argument (in the source): + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/topic?method=get + get(gaxOpts?: GAX.CallOptions): Promise; + get(callback: Topic.GetCallback): void; + get(gaxOpts: GAX.CallOptions, callback: Topic.GetCallback): void; + + getMetadata(gaxOpts?: GAX.CallOptions): Promise; + getMetadata(callback: Topic.GetMetadataCallback): void; + getMetadata(gaxOpts: GAX.CallOptions, callback: Topic.GetMetadataCallback): void; + + getSubscriptions(options?: Topic.GetSubscriptionsOptions): Promise; + getSubscriptions(callback: Topic.GetSubscriptionsCallback): void; + getSubscriptions(options: Topic.GetSubscriptionsOptions, callback: Topic.GetSubscriptionsCallback): void; + + // Note: The documention lists the parameter as 'query', when it probably should be 'options'. + getSubscriptionsStream(options?: Topic.GetSubscriptionsOptions): Duplex; + + iam: IAM; + + publisher(options?: Topic.PublisherOptions): Publisher; + + subscription(name: string, options?: Topic.SubscriptionOptions): Subscription; + } + namespace Topic { + type CreateCallback = PubSub.CreateTopicCallback; + + type CreateSubscriptionOptions = PubSub.CreateSubscriptionOptions; + type CreateSubscriptionCallback = PubSub.CreateSubscriptionCallback; + + // Note: This is not fully documented in the link; browse the source code to find the callback parameters + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/topic?method=delete + type DeleteCallback = (err: Error | null, apiResponse: object) => void; + + type ExistsCallback = (err: Error | null, exists: boolean) => void; + + // Note: This is not fully documented in the link; browse the source code to find the callback parameters + // https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/0.14.1/pubsub/topic?method=get + type GetCallback = (err: Error | null, topic: Topic, apiResponse: object) => void; + + type GetMetadataCallback = (err: Error | null, apiResponse: object) => void; + + // Options are SLIGHTLY different to PubSub.getSubscriptions(...), so we can't just reuse it + interface GetSubscriptionsOptions { + autoPaginate?: boolean; + gaxOpts?: GAX.CallOptions; + pageSize?: number; + pageToken?: string; + } + // Callback signature also slightly different to PubSub.getSubscriptions(callback), so we can't just reuse it + type GetSubscriptionsCallback = (err: Error | null, subscriptions: Subscription[]) => void; + + interface PublisherOptions { + batching?: { + maxBytes?: number; + maxMessages?: number; + maxMilliseconds?: number; + }; + } + + type SubscriptionOptions = PubSub.SubscriptionOptions; + } + + // Allow this interface to start with 'I', since it's an acronym! + // tslint:disable-next-line interface-name + interface IAM { + getPolicy(): Promise; + getPolicy(callback: IAM.GetPolicyCallback): void; + + setPolicy(policy: IAM.Policy): Promise; + setPolicy(policy: IAM.Policy, callback: IAM.SetPolicyCallback): void; + + testPermissions(permissions: string | string[]): Promise; + testPermissions(permissions: string | string[], callback: IAM.TestPermissionsCallback): void; + } + namespace IAM { + type GetPolicyCallback = (err: Error | null, policy: Policy, apiResponse: object) => void; + + type SetPolicyCallback = (err: Error | null, policy: Policy, apiResponse: object) => void; + + type TestPermissionsCallback = (err: Error | null, permissions: string | string[], apiResponse: object) => void; + + interface Policy { + bindings?: any[]; + rules?: object[]; + etag?: string; + } + } + + namespace GAX { + /** https://googleapis.github.io/gax-nodejs/global.html#CallOptions */ + interface CallOptions { + timeout?: number; + retry?: RetryOptions; + autoPaginate?: boolean; + pageToken?: object; + isBundling?: boolean; + longrunning?: BackoffSettings; + promise?: PromiseConstructor; // FIXME Unsure if this is the correct type; remove this comment if it is + } + + /** https://googleapis.github.io/gax-nodejs/global.html#RetryOptions */ + interface RetryOptions { + retryCodes: string[]; + backoffSettings: BackoffSettings; + } + + /** https://googleapis.github.io/gax-nodejs/global.html#BackoffSettings */ + interface BackoffSettings { + initialRetryDelayMillis: number; + retryDelayMultiplier: number; + maxRetryDelayMillis: number; + initialRpcTimeoutMillis: number; + maxRpcTimeoutMillis: number; + totalTimeoutMillis: number; + } + } +} + +declare function PubSub(config?: PubSub.GCloudConfiguration): PubSub.PubSub; +export = PubSub; diff --git a/types/google-cloud__pubsub/tsconfig.json b/types/google-cloud__pubsub/tsconfig.json new file mode 100644 index 0000000000..f71eb2a331 --- /dev/null +++ b/types/google-cloud__pubsub/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "paths": { + "@google-cloud/pubsub": [ + "google-cloud__pubsub" + ] + }, + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "google-cloud__pubsub-tests.ts" + ] +} \ No newline at end of file diff --git a/types/google-cloud__pubsub/tslint.json b/types/google-cloud__pubsub/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/google-cloud__pubsub/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From e0c06b3b7170b18bf71e0d8dae17ddaffec6443e Mon Sep 17 00:00:00 2001 From: Vasya Aksyonov Date: Sat, 28 Oct 2017 03:23:12 +0300 Subject: [PATCH 071/352] Fixing react-ga .ga() signature (#20438) * Fixing react-ga ga signature * Adding additional overload --- types/react-ga/index.d.ts | 5 +++-- types/react-ga/react-ga-tests.ts | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/types/react-ga/index.d.ts b/types/react-ga/index.d.ts index 83d7a7218e..56d9715ed1 100644 --- a/types/react-ga/index.d.ts +++ b/types/react-ga/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for react-ga 2.1 // Project: https://github.com/react-ga/react-ga -// Definitions by: Tim Aldridge +// Definitions by: Tim Aldridge , Vasya Aksyonov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export interface EventArgs { @@ -54,7 +54,8 @@ export interface OutboundLinkArgs { } export function initialize(trackingCode: string, options?: InitializeOptions): void; -export function ga(): any; +export function ga(): (...args: any[]) => any; +export function ga(...args: any[]): any; export function set(fieldsObject: FieldsObject): void; export function send(fieldsObject: FieldsObject): void; export function pageview(path: string): void; diff --git a/types/react-ga/react-ga-tests.ts b/types/react-ga/react-ga-tests.ts index dbc1d0970c..9e1ba7b23b 100644 --- a/types/react-ga/react-ga-tests.ts +++ b/types/react-ga/react-ga-tests.ts @@ -63,6 +63,12 @@ describe("Testing react-ga v2.1.2", () => { it("Able to make ga calls", () => { ga.ga(); }); + it("Able to make ga calls with any arguments", () => { + ga.ga("create", "UA-65432-1", "auto", "trackerName"); + }); + it("Able to make returned ga calls with any arguments", () => { + ga.ga()("create", "UA-65432-1", "auto", "trackerName"); + }); it("Able to make send calls", () => { const fieldObject: ga.FieldsObject = { page: '/users' From b8206423625f9170dc39869249d78eab6bec4872 Mon Sep 17 00:00:00 2001 From: Daniel Earwicker Date: Sat, 28 Oct 2017 01:24:45 +0100 Subject: [PATCH 072/352] react-router-dom - Added missing location property to NavLinkProps (#20793) * Added missing location property to NavLinkProps See https://reacttraining.com/react-router/web/api/NavLink * Version 4.2 --- types/react-router-dom/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/react-router-dom/index.d.ts b/types/react-router-dom/index.d.ts index c9555834a9..bb8a010d8d 100644 --- a/types/react-router-dom/index.d.ts +++ b/types/react-router-dom/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for React Router 4.0 +// Type definitions for React Router 4.2 // Project: https://github.com/ReactTraining/react-router // Definitions by: Tanguy Krotoff // Huy Nguyen @@ -52,5 +52,6 @@ export interface NavLinkProps extends LinkProps { exact?: boolean; strict?: boolean; isActive?

    (match: match

    , location: H.Location): boolean; + location?: H.Location; } export class NavLink extends React.Component {} From 3f6568d6e1bd6495b9442a82152819b3ddf34fa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Mosmann?= Date: Sat, 28 Oct 2017 01:29:27 +0100 Subject: [PATCH 073/352] [react-mdl] Change DOMAttributes generic type from Textfield to HTMLInputElement (#20649) Textfield redirect all DOMAttributes to the input component inside of it. The typings should match it --- types/react-mdl/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/react-mdl/index.d.ts b/types/react-mdl/index.d.ts index d157987929..33dccccd07 100644 --- a/types/react-mdl/index.d.ts +++ b/types/react-mdl/index.d.ts @@ -584,7 +584,7 @@ declare namespace __ReactMDL { class Tabs extends __MDLComponent { } - interface TextfieldProps extends MDLHTMLAttributes, React.DOMAttributes { + interface TextfieldProps extends MDLHTMLAttributes, React.DOMAttributes { label: string; disabled?: boolean; error?: React.ReactNode; @@ -594,7 +594,7 @@ declare namespace __ReactMDL { id?: string; inputClassName?: string; maxRows?: number; - onChange?: React.FormEventHandler; + onChange?: React.FormEventHandler; pattern?: string; required?: boolean; rows?: number; From 1fda81f987e9858a578546fc1b6021e30d99ce22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Einar=20Nor=C3=B0fj=C3=B6r=C3=B0?= Date: Sat, 28 Oct 2017 00:29:55 +0000 Subject: [PATCH 074/352] Fixes crossfilter bisect method (#20642) * Fixes crossfilter bisect method Crossfilters bisect methods second argument should be of the type returned by the accessor * Update crossfilter-tests.ts * fix tests --- types/crossfilter/crossfilter-tests.ts | 8 ++++---- types/crossfilter/index.d.ts | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/types/crossfilter/crossfilter-tests.ts b/types/crossfilter/crossfilter-tests.ts index 813ddae2b9..5d9981b6d1 100644 --- a/types/crossfilter/crossfilter-tests.ts +++ b/types/crossfilter/crossfilter-tests.ts @@ -118,10 +118,10 @@ var types = paymentCountByType.all(); paymentsByTotal.dispose(); crossfilter.bisect([], null, 0, 0); -var bisectBy = crossfilter.bisect.by(t => t); -bisectBy([], null, 0, 0); -bisectBy.left([], null, 0, 0); -bisectBy.right([], null, 0, 0); +var bisectBy = crossfilter.bisect.by<{value: string}, string>(t => t.value); +bisectBy([{value: 'a'}, {value: 'b'}], 'c', 0, 0); // 2 +bisectBy.left([], 'string', 0, 0); // 0 +bisectBy.right([], 'string', 0, 0); // 0 crossfilter.heap([], 0, 0); var heapBy = crossfilter.heap.by(t => t); diff --git a/types/crossfilter/index.d.ts b/types/crossfilter/index.d.ts index ed888f6959..a009e920dd 100644 --- a/types/crossfilter/index.d.ts +++ b/types/crossfilter/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for CrossFilter // Project: https://github.com/square/crossfilter -// Definitions by: Schmulik Raskin , Izaak Baker +// Definitions by: Schmulik Raskin , Izaak Baker , Einar Norðfjörð // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace CrossFilter { @@ -15,7 +15,7 @@ declare namespace CrossFilter { permute(array: T[], index: number[]): T[]; bisect: { (array: T[], value: T, lo: number, hi: number): number; - by(value: Selector): Bisector; + by(accessor: (x: T)=> U): Bisector; } heap: { (array: T[], lo: number, hi: number): T[]; @@ -36,13 +36,13 @@ declare namespace CrossFilter { } } - export interface Bisection { - (array: T[], value: T, lo: number, hi: number): number; + export interface Bisection { + (array: T[], value: U, lo: number, hi: number): number; } - export interface Bisector extends Bisection { - left: Bisection - right: Bisection + export interface Bisector extends Bisection { + left: Bisection + right: Bisection } export interface Heap { From 084ca6f60c7b6e99082dbd4375db2df576e50fcc Mon Sep 17 00:00:00 2001 From: Cassey Lottman Date: Fri, 27 Oct 2017 19:31:34 -0500 Subject: [PATCH 075/352] Underscore typings missing IterateePropertyShorthand on uniq (#20537) * missing comment * missing comment * add iteratee property shorthand for uniq in underscore * undo bad commit --- types/underscore/index.d.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/types/underscore/index.d.ts b/types/underscore/index.d.ts index 2803c89b96..8ef77dff02 100644 --- a/types/underscore/index.d.ts +++ b/types/underscore/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Underscore 1.8 // Project: http://underscorejs.org/ -// Definitions by: Boris Yankov , Josh Baldwin , Christopher Currens +// Definitions by: Boris Yankov , Josh Baldwin , Christopher Currens , Cassey Lottman // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare var _: _.UnderscoreStatic; @@ -920,7 +920,7 @@ declare module _ { **/ uniq( array: _.List, - iterator?: _.ListIterator, + iterator?: _.ListIterator | _.IterateePropertyShorthand, context?: any): T[]; /** @@ -937,7 +937,7 @@ declare module _ { unique( array: _.List, isSorted?: boolean, - iterator?: _.ListIterator, + iterator?: _.ListIterator | _.IterateePropertyShorthand, context?: any): T[]; @@ -4512,7 +4512,7 @@ declare module _ { * Wrapped type `any[]`. * @see _.uniq **/ - uniq(isSorted?: boolean, iterator?: _.ListIterator): T[]; + uniq(isSorted?: boolean, iterator?: _.ListIterator | _.IterateePropertyShorthand): T[]; /** * Wrapped type `any[]`. @@ -5472,23 +5472,23 @@ declare module _ { * Wrapped type `any[]`. * @see _.uniq **/ - uniq(isSorted?: boolean, iterator?: _.ListIterator): _Chain; + uniq(isSorted?: boolean, iterator?: _.ListIterator | _.IterateePropertyShorthand): _Chain; /** * Wrapped type `any[]`. * @see _.uniq **/ - uniq(iterator?: _.ListIterator, context?: any): _Chain; + uniq(iterator?: _.ListIterator | _.IterateePropertyShorthand, context?: any): _Chain; /** * @see _.uniq **/ - unique(isSorted?: boolean, iterator?: _.ListIterator): _Chain; + unique(isSorted?: boolean, iterator?: _.ListIterator | _.IterateePropertyShorthand): _Chain; /** * @see _.uniq **/ - unique(iterator?: _.ListIterator, context?: any): _Chain; + unique(iterator?: _.ListIterator | _.IterateePropertyShorthand, context?: any): _Chain; /** * Wrapped type `any[][]`. From cc2072646562721329de7e97a8e33b2b1a9660df Mon Sep 17 00:00:00 2001 From: Eric Eslinger Date: Fri, 27 Oct 2017 17:32:40 -0700 Subject: [PATCH 076/352] The db field in Redis's ClientOptions interface should be a number, not a string. (#20504) * this parameter should probably be a number * undid the prettier reformat * other modules send strings --- types/redis/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/redis/index.d.ts b/types/redis/index.d.ts index 13b7cbeb45..5f7e1d1e10 100644 --- a/types/redis/index.d.ts +++ b/types/redis/index.d.ts @@ -41,7 +41,7 @@ export interface ClientOpts { retry_unfulfilled_commands?: boolean; auth_pass?: string; password?: string; - db?: string; + db?: string | number; family?: string; rename_commands?: { [command: string]: string }; tls?: any; From fa5088af4d7070b83f1858853b90a80f5cf4c763 Mon Sep 17 00:00:00 2001 From: Gilberto Stankiewicz Date: Fri, 27 Oct 2017 17:37:36 -0700 Subject: [PATCH 077/352] Declare chrome.declarativeContent.onPageChanged, chrome.declarativeContent.ShowPageAction, chrome.declarativeContent.PageStateMatcher (#20797) --- types/chrome/index.d.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/types/chrome/index.d.ts b/types/chrome/index.d.ts index ca7b35bf0e..0b6e1fd6e4 100644 --- a/types/chrome/index.d.ts +++ b/types/chrome/index.d.ts @@ -1426,8 +1426,7 @@ declare namespace chrome.declarativeContent { ports?: (number | number[])[]; } - /** Matches the state of a web page by various criteria. */ - interface PageStateMatcher { + class PageStateMatcherProperties { /** Optional. Filters URLs for various criteria. See event filtering. All criteria are case sensitive. */ pageUrl?: PageStateUrlDetails; /** Optional. Matches if all of the CSS selectors in the array match displayed elements in a frame with the same origin as the page's main frame. All selectors in this array must be compound selectors to speed up matching. Note that listing hundreds of CSS selectors or CSS selectors that match hundreds of times per page can still slow down web sites. */ @@ -1439,6 +1438,19 @@ declare namespace chrome.declarativeContent { */ isBookmarked?: boolean; } + + /** Matches the state of a web page by various criteria. */ + class PageStateMatcher { + constructor(options: PageStateMatcherProperties); + } + + /** Declarative event action that shows the extension's page action while the corresponding conditions are met. */ + class ShowPageAction {} + + /** Provides the Declarative Event API consisting of addRules, removeRules, and getRules. */ + interface PageChangedEvent extends chrome.events.Event<() => void> {} + + var onPageChanged: PageChangedEvent; } //////////////////// @@ -5126,7 +5138,7 @@ declare namespace chrome.runtime { actions?: { type: string; }[]; - conditions?: chrome.declarativeContent.PageStateMatcher[] + conditions?: chrome.declarativeContent.PageStateMatcherProperties[] }[]; externally_connectable?: { ids?: string[]; From 8c4d9e234d34e29b2e5f20a41e24ee4b5091805f Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Fri, 27 Oct 2017 20:38:42 -0400 Subject: [PATCH 078/352] [meteor/server-render] Sink methods are optional (#20747) * ServiceConfiguration types added * New usage of publishComposite added to meteor-publish-composite * meteor/underscore added * [meteor/server-render] Sink methods are optional --- types/meteor/server-render.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/meteor/server-render.d.ts b/types/meteor/server-render.d.ts index cbf814ed61..1695142ee4 100644 --- a/types/meteor/server-render.d.ts +++ b/types/meteor/server-render.d.ts @@ -7,10 +7,10 @@ declare module "meteor/server-render" { body?: string; htmlById?: { [key: string]: string }; maybeMadeChanges?: boolean; - appendToHead(html: string): void; - appendToBody(html: string): void; - appendToElementById(id: string, html: string): void; - renderIntoElementById(id: string, html: string): void; + appendToHead?(html: string): void; + appendToBody?(html: string): void; + appendToElementById?(id: string, html: string): void; + renderIntoElementById?(id: string, html: string): void; } function onPageLoad(sink: Sink): Promise | any; } From ceda0b6a499f3e588c9046807a332425bbd4bd8e Mon Sep 17 00:00:00 2001 From: Bernd Date: Sat, 28 Oct 2017 02:39:01 +0200 Subject: [PATCH 079/352] add types for H.map.render.RenderEngine (#20711) --- types/heremaps/heremaps-tests.ts | 13 ++ types/heremaps/index.d.ts | 261 +++++++++++++++++++++++++++++++ 2 files changed, 274 insertions(+) diff --git a/types/heremaps/heremaps-tests.ts b/types/heremaps/heremaps-tests.ts index 0856cd2616..9e92b92d72 100644 --- a/types/heremaps/heremaps-tests.ts +++ b/types/heremaps/heremaps-tests.ts @@ -179,3 +179,16 @@ pixelProjection.rescale(12); const point = pixelProjection.geoToPixel({ lat: 53, lng: 12 }); pixelProjection.xyToGeo(point.x, point.y); + +const engine = map.getEngine(); +engine.getAnimationDuration(); +engine.setAnimationDuration(1000); + +engine.getAnimationEase(); +engine.setAnimationEase(H.util.animation.ease.EASE_IN_QUAD); + +const engineListener = (e: Event) => { + console.log(e); +}; +engine.addEventListener('tap', engineListener); +engine.removeEventListener('tap', engineListener); diff --git a/types/heremaps/index.d.ts b/types/heremaps/index.d.ts index 0bda913919..8b68f11278 100644 --- a/types/heremaps/index.d.ts +++ b/types/heremaps/index.d.ts @@ -264,6 +264,12 @@ declare namespace H { * @param opt_scope {Object=} - An optional scope to call the callback in. */ addOnDisposeCallback(callback: () => void, opt_scope?: {}): void; + + /** + * This returns the map's render engine + * @return {H.map.render.p2d.RenderEngine} - map render engine + */ + getEngine(): H.map.render.p2d.RenderEngine; } namespace Map { @@ -3606,6 +3612,261 @@ declare namespace H { } } } + + namespace render { + /** + * This is an abstract class representing a render engine. Render engines are used to render the geographical position from a view model on the + * screen (viewport element). The rendered result may be different for different engines, because every engine uses its own capabilities and + * specific implementation to present the current view model data in best possible way. For example, 2D engines create a two-dimensional flat + * map composed of tiles, while 3D engines can generate panoramas displaying the same coordinates as a 'street view'. + */ + class RenderEngine extends H.util.EventTarget { + /** + * Constructor + * @param viewPort {H.map.ViewPort} - An object representing the map viewport + * @param viewModel {H.map.ViewModel} - An object representing a view of the map + * @param dataModel {H.map.DataModel} - An object encapsulating the data to be rendered on the map (layers and objects) + * @param options {H.map.render.RenderEngine.Options} - An object containing the render engine initialization options + */ + constructor(viewPort: H.map.ViewPort, viewModel: H.map.ViewModel, dataModel: H.map.DataModel, options: H.map.render.RenderEngine.Options); + + /** + * This method adds a listener for a specific event. + * Note that to prevent potential memory leaks, you must either call removeEventListener or dispose on the given object when you no longer need it. + * @param type {string} - The name of the event + * @param handler {!Function} - An event handler function + * @param opt_capture {boolean=} - true indicates that the method should listen in the capture phase (bubble otherwise) + * @param opt_scope {Object=} - An object defining the scope for the handler function + */ + addEventListener(type: string, handler: (evt: Event) => void, opt_capture?: boolean, opt_scope?: {}): void; + + /** + * This method removes a previously added listener from the EventTarget instance. + * @param type {string} - The name of the event + * @param handler {!Function} - A previously added event handler + * @param opt_capture {boolean=} - true indicates that the method should listen in the capture phase (bubble otherwise) + * @param opt_scope {Object=} - An object defining the scope for the handler function + */ + removeEventListener(type: string, handler: (evt: Event) => void, opt_capture?: boolean, opt_scope?: {}): void; + + /** + * This method dispatches an event on the EventTarget object. + * @param evt {H.util.Event|string} - An object representing the event or a string with the event name + */ + dispatchEvent(evt: H.util.Event | string): void; + + /** + * This method removes listeners from the given object. Classes that extend EventTarget may need to override this method in order to remove + * references to DOM Elements and additional listeners. + */ + dispose(): void; + + /** + * This method adds a callback which is triggered when the EventTarget object is being disposed. + * @param callback {!Function} - The callback function. + * @param opt_scope {Object=} - An optional scope for the callback function + */ + addOnDisposeCallback(callback: () => void, opt_scope?: {}): void; + } + + namespace RenderEngine { + /** + * An object containing the render engine initialization options + */ + interface Options { + [key: string]: string; + } + + /** + * This object defines the modifiers to use for H.map.ViewPort#startInteraction. + */ + enum InteractionModifiers { + /** changes zoom level during the interaction */ + ZOOM, + /** changes map center during the interaction */ + HEADING, + /** changes heading angle during the interaction */ + TILT, + /** changes tilt angle during the interaction */ + INCLINE, + /** changes incline angle during the interaction */ + COORD, + } + } + + /** + * The rendering states of the layer. + */ + enum RenderState { + /** + * Data loading/processing is still in progress, but there is nothing to render. In this state rendering engine might go to sleep mode after + * certain amount of time to prevent draining of battery on the user device. + */ + PENDING, + /** Data rendering or animation is in progress. */ + ACTIVE, + /** Data rendering or animation is done. */ + DONE, + } + + /** + * An object containing rendering parameters. + */ + interface RenderingParams { + /** + * The geographical area to render. Note that it is not the same as visible viewport. Specified bounds also include H.Map.Options#margin and + * optionally an additional margin in case of DOM node rendering for a better rendering experience. + * @type {H.geo.Rect} + */ + bounds: H.geo.Rect; + + /** + * The zoom level to render the data for. + * @type {number} + */ + zoom: number; + + /** + * The coordinates of the screen center in CSS pixels. + * @type {H.math.Point} + */ + screenCenter: H.math.Point; + + /** + * The coordinates relative to the screen center where the rendering has the highest priority. If the layer has to request and/or process data + * asynchronously, it's recommended to prioritize the rendering close to this center. + * @type {H.math.Point} + */ + priorityCenter: H.math.Point; + + /** + * The pixel projection to use to project geographical coordinates into screen coordinates and vice versa. + * @type {H.geo.PixelProjection} + */ + projection: H.geo.PixelProjection; + + /** + * Indicates whether only cached data should be considered. + * @type {boolean} + */ + cacheOnly: boolean; + + /** + * The size of the area to render. + * @type {H.math.Size} + */ + size: H.math.Size; + + /** + * The pixelRatio to use for over-sampling in cases of high-resolution displays. + * See https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio. + * @type {number} + */ + pixelRatio: number; + } + + /** + * Contains functionality specific to 2D map rendering. + */ + namespace p2d { + /** + * This class implements a map render engine. It presents a geographic location (camera data from a view model) and renders all map layers in + * the order in which they are provided in a single 2D canvas element. + */ + class RenderEngine extends H.map.render.RenderEngine { + /** + * Constructor + * @param viewPort {H.map.ViewPort} - An object representing the map viewport + * @param viewModel {H.map.ViewModel} - An object representing a view of the map + * @param dataModel {H.map.DataModel} - An object encapsulating the data to be rendered on the map (layers and objects) + * @param options {H.map.render.RenderEngine.Options} - An object containing the render engine initialization options + */ + constructor(viewPort: H.map.ViewPort, viewModel: H.map.ViewModel, dataModel: H.map.DataModel, options: H.map.render.RenderEngine.Options); + + /** + * This method sets the length (duration) for all animations run by the render engine in milliseconds. + * @param duration {number} - A value indicating the duration of animations in milliseconds + */ + setAnimationDuration(duration: number): void; + + /** + * This method retrieves the current setting indicating the length of animations (duration) run by the the render engine in milliseconds. + * @return {number} + */ + getAnimationDuration(): number; + + /** + * This method sets a value indicating the easing to apply to animations run by the render engine. + * @param easeFunction {Function(number)} - A function that alters the progress ratio of an animation. It receives an argument indicating + * animation progress as a numeric value in the range between 0 and 1 and must return a numeric value in the same range. + */ + setAnimationEase(easeFunction: (progress: number) => number): void; + + /** + * This method retrieves the current setting representing the easing to be applied to animations. + * @return {Function(number) => number} - A numeric value in the range 0 to 1 + */ + getAnimationEase(): (progress: number) => number; + + /** + * This method resets animation settings on the render engine to defaults. + * Duration is set to 300ms and easing to H.util.animation.ease.EASE_OUT_QUAD. + */ + resetAnimationDefaults(): void; + + /** + * This method adds a listener for a specific event. + * Note that to prevent potential memory leaks, you must either call removeEventListener or dispose on the given object when you no longer need it. + * @param type {string} - The name of the event + * @param handler {!Function} - An event handler function + * @param opt_capture {boolean=} - true indicates that the method should listen in the capture phase (bubble otherwise) + * @param opt_scope {Object=} - An object defining the scope for the handler function + */ + addEventListener(type: string, handler: (evt: Event) => void, opt_capture?: boolean, opt_scope?: {}): void; + + /** + * This method removes a previously added listener from the EventTarget instance. + * @param type {string} - The name of the event + * @param handler {!Function} - A previously added event handler + * @param opt_capture {boolean=} - true indicates that the method should listen in the capture phase (bubble otherwise) + * @param opt_scope {Object=} - An object defining the scope for the handler function + */ + removeEventListener(type: string, handler: (evt: Event) => void, opt_capture?: boolean, opt_scope?: {}): void; + + /** + * This method dispatches an event on the EventTarget object. + * @param evt {H.util.Event|string} - An object representing the event or a string with the event name + */ + dispatchEvent(evt: H.util.Event | string): void; + + /** + * This method removes listeners from the given object. Classes that extend EventTarget may need to override this method in order to remove + * references to DOM Elements and additional listeners. + */ + dispose(): void; + + /** + * This method adds a callback which is triggered when the EventTarget object is being disposed. + * @param callback {!Function} - The callback function. + * @param opt_scope {Object=} - An optional scope for the callback function + */ + addOnDisposeCallback(callback: () => void, opt_scope?: {}): void; + } + + namespace RenderEngine { + interface Options { + /** Object describes how many cached zoom levels should be used as a base map background while base map tiles are */ + renderBaseBackground?: {}; + + /** The pixelRatio to use for over-sampling in cases of high-resolution displays */ + pixelRatio: number; + + /** optional */ + enableSubpixelRendering?: boolean; + } + } + } + } } /***** mapevents *****/ From f7f81bced2ae4efc9a8398e62a2f3a33651d775e Mon Sep 17 00:00:00 2001 From: b-szypelow Date: Sat, 28 Oct 2017 02:39:47 +0200 Subject: [PATCH 080/352] Reactstrap: Introduce typings for v5.0 (#20696) * reactstrap: Create v4 subfolder * reactstrap@5: change getRef to innerRef --- types/reactstrap/index.d.ts | 2 +- types/reactstrap/lib/Button.d.ts | 2 +- types/reactstrap/lib/CardLink.d.ts | 2 +- types/reactstrap/lib/Form.d.ts | 2 +- types/reactstrap/lib/Input.d.ts | 2 +- types/reactstrap/lib/NavLink.d.ts | 2 +- types/reactstrap/reactstrap-tests.tsx | 2 +- types/reactstrap/v4/index.d.ts | 87 + types/reactstrap/v4/lib/Alert.d.ts | 19 + types/reactstrap/v4/lib/Badge.d.ts | 12 + types/reactstrap/v4/lib/Breadcrumb.d.ts | 10 + types/reactstrap/v4/lib/BreadcrumbItem.d.ts | 15 + types/reactstrap/v4/lib/Button.d.ts | 21 + types/reactstrap/v4/lib/ButtonDropdown.d.ts | 12 + types/reactstrap/v4/lib/ButtonGroup.d.ts | 14 + types/reactstrap/v4/lib/ButtonToolbar.d.ts | 12 + types/reactstrap/v4/lib/Card.d.ts | 16 + types/reactstrap/v4/lib/CardBlock.d.ts | 11 + types/reactstrap/v4/lib/CardBody.d.ts | 10 + types/reactstrap/v4/lib/CardColumns.d.ts | 10 + types/reactstrap/v4/lib/CardDeck.d.ts | 10 + types/reactstrap/v4/lib/CardFooter.d.ts | 10 + types/reactstrap/v4/lib/CardGroup.d.ts | 10 + types/reactstrap/v4/lib/CardHeader.d.ts | 10 + types/reactstrap/v4/lib/CardImg.d.ts | 16 + types/reactstrap/v4/lib/CardImgOverlay.d.ts | 10 + types/reactstrap/v4/lib/CardLink.d.ts | 12 + types/reactstrap/v4/lib/CardSubtitle.d.ts | 10 + types/reactstrap/v4/lib/CardText.d.ts | 10 + types/reactstrap/v4/lib/CardTitle.d.ts | 10 + types/reactstrap/v4/lib/Col.d.ts | 24 + types/reactstrap/v4/lib/Collapse.d.ts | 18 + types/reactstrap/v4/lib/Container.d.ts | 11 + types/reactstrap/v4/lib/Dropdown.d.ts | 22 + types/reactstrap/v4/lib/DropdownItem.d.ts | 15 + types/reactstrap/v4/lib/DropdownMenu.d.ts | 11 + types/reactstrap/v4/lib/DropdownToggle.d.ts | 19 + types/reactstrap/v4/lib/Fade.d.ts | 20 + types/reactstrap/v4/lib/Form.d.ts | 12 + types/reactstrap/v4/lib/FormFeedback.d.ts | 10 + types/reactstrap/v4/lib/FormGroup.d.ts | 14 + types/reactstrap/v4/lib/FormText.d.ts | 12 + types/reactstrap/v4/lib/Input.d.ts | 52 + types/reactstrap/v4/lib/InputGroup.d.ts | 11 + types/reactstrap/v4/lib/InputGroupAddon.d.ts | 10 + types/reactstrap/v4/lib/InputGroupButton.d.ts | 13 + types/reactstrap/v4/lib/Jumbotron.d.ts | 11 + types/reactstrap/v4/lib/Label.d.ts | 26 + types/reactstrap/v4/lib/ListGroup.d.ts | 11 + types/reactstrap/v4/lib/ListGroupItem.d.ts | 17 + .../v4/lib/ListGroupItemHeading.d.ts | 10 + .../reactstrap/v4/lib/ListGroupItemText.d.ts | 10 + types/reactstrap/v4/lib/Media.d.ts | 21 + types/reactstrap/v4/lib/Modal.d.ts | 23 + types/reactstrap/v4/lib/ModalBody.d.ts | 10 + types/reactstrap/v4/lib/ModalFooter.d.ts | 10 + types/reactstrap/v4/lib/ModalHeader.d.ts | 12 + types/reactstrap/v4/lib/Nav.d.ts | 17 + types/reactstrap/v4/lib/NavDropdown.d.ts | 12 + types/reactstrap/v4/lib/NavItem.d.ts | 10 + types/reactstrap/v4/lib/NavLink.d.ts | 15 + types/reactstrap/v4/lib/Navbar.d.ts | 20 + types/reactstrap/v4/lib/NavbarBrand.d.ts | 10 + types/reactstrap/v4/lib/NavbarToggler.d.ts | 13 + types/reactstrap/v4/lib/Pagination.d.ts | 10 + types/reactstrap/v4/lib/PaginationItem.d.ts | 12 + types/reactstrap/v4/lib/PaginationLink.d.ts | 13 + types/reactstrap/v4/lib/Popover.d.ts | 34 + types/reactstrap/v4/lib/PopoverContent.d.ts | 10 + types/reactstrap/v4/lib/PopoverTitle.d.ts | 10 + types/reactstrap/v4/lib/Progress.d.ts | 18 + types/reactstrap/v4/lib/Row.d.ts | 11 + types/reactstrap/v4/lib/TabContent.d.ts | 11 + types/reactstrap/v4/lib/TabPane.d.ts | 11 + types/reactstrap/v4/lib/Table.d.ts | 18 + types/reactstrap/v4/lib/Tag.d.ts | 12 + types/reactstrap/v4/lib/TetherContent.d.ts | 18 + types/reactstrap/v4/lib/Tooltip.d.ts | 43 + types/reactstrap/v4/lib/Uncontrolled.d.ts | 29 + types/reactstrap/v4/reactstrap-tests.tsx | 3502 +++++++++++++++++ types/reactstrap/v4/tsconfig.json | 28 + types/reactstrap/v4/tslint.json | 1 + 82 files changed, 4687 insertions(+), 7 deletions(-) create mode 100644 types/reactstrap/v4/index.d.ts create mode 100644 types/reactstrap/v4/lib/Alert.d.ts create mode 100644 types/reactstrap/v4/lib/Badge.d.ts create mode 100644 types/reactstrap/v4/lib/Breadcrumb.d.ts create mode 100644 types/reactstrap/v4/lib/BreadcrumbItem.d.ts create mode 100644 types/reactstrap/v4/lib/Button.d.ts create mode 100644 types/reactstrap/v4/lib/ButtonDropdown.d.ts create mode 100644 types/reactstrap/v4/lib/ButtonGroup.d.ts create mode 100644 types/reactstrap/v4/lib/ButtonToolbar.d.ts create mode 100644 types/reactstrap/v4/lib/Card.d.ts create mode 100644 types/reactstrap/v4/lib/CardBlock.d.ts create mode 100644 types/reactstrap/v4/lib/CardBody.d.ts create mode 100644 types/reactstrap/v4/lib/CardColumns.d.ts create mode 100644 types/reactstrap/v4/lib/CardDeck.d.ts create mode 100644 types/reactstrap/v4/lib/CardFooter.d.ts create mode 100644 types/reactstrap/v4/lib/CardGroup.d.ts create mode 100644 types/reactstrap/v4/lib/CardHeader.d.ts create mode 100644 types/reactstrap/v4/lib/CardImg.d.ts create mode 100644 types/reactstrap/v4/lib/CardImgOverlay.d.ts create mode 100644 types/reactstrap/v4/lib/CardLink.d.ts create mode 100644 types/reactstrap/v4/lib/CardSubtitle.d.ts create mode 100644 types/reactstrap/v4/lib/CardText.d.ts create mode 100644 types/reactstrap/v4/lib/CardTitle.d.ts create mode 100644 types/reactstrap/v4/lib/Col.d.ts create mode 100644 types/reactstrap/v4/lib/Collapse.d.ts create mode 100644 types/reactstrap/v4/lib/Container.d.ts create mode 100644 types/reactstrap/v4/lib/Dropdown.d.ts create mode 100644 types/reactstrap/v4/lib/DropdownItem.d.ts create mode 100644 types/reactstrap/v4/lib/DropdownMenu.d.ts create mode 100644 types/reactstrap/v4/lib/DropdownToggle.d.ts create mode 100644 types/reactstrap/v4/lib/Fade.d.ts create mode 100644 types/reactstrap/v4/lib/Form.d.ts create mode 100644 types/reactstrap/v4/lib/FormFeedback.d.ts create mode 100644 types/reactstrap/v4/lib/FormGroup.d.ts create mode 100644 types/reactstrap/v4/lib/FormText.d.ts create mode 100644 types/reactstrap/v4/lib/Input.d.ts create mode 100644 types/reactstrap/v4/lib/InputGroup.d.ts create mode 100644 types/reactstrap/v4/lib/InputGroupAddon.d.ts create mode 100644 types/reactstrap/v4/lib/InputGroupButton.d.ts create mode 100644 types/reactstrap/v4/lib/Jumbotron.d.ts create mode 100644 types/reactstrap/v4/lib/Label.d.ts create mode 100644 types/reactstrap/v4/lib/ListGroup.d.ts create mode 100644 types/reactstrap/v4/lib/ListGroupItem.d.ts create mode 100644 types/reactstrap/v4/lib/ListGroupItemHeading.d.ts create mode 100644 types/reactstrap/v4/lib/ListGroupItemText.d.ts create mode 100644 types/reactstrap/v4/lib/Media.d.ts create mode 100644 types/reactstrap/v4/lib/Modal.d.ts create mode 100644 types/reactstrap/v4/lib/ModalBody.d.ts create mode 100644 types/reactstrap/v4/lib/ModalFooter.d.ts create mode 100644 types/reactstrap/v4/lib/ModalHeader.d.ts create mode 100644 types/reactstrap/v4/lib/Nav.d.ts create mode 100644 types/reactstrap/v4/lib/NavDropdown.d.ts create mode 100644 types/reactstrap/v4/lib/NavItem.d.ts create mode 100644 types/reactstrap/v4/lib/NavLink.d.ts create mode 100644 types/reactstrap/v4/lib/Navbar.d.ts create mode 100644 types/reactstrap/v4/lib/NavbarBrand.d.ts create mode 100644 types/reactstrap/v4/lib/NavbarToggler.d.ts create mode 100644 types/reactstrap/v4/lib/Pagination.d.ts create mode 100644 types/reactstrap/v4/lib/PaginationItem.d.ts create mode 100644 types/reactstrap/v4/lib/PaginationLink.d.ts create mode 100644 types/reactstrap/v4/lib/Popover.d.ts create mode 100644 types/reactstrap/v4/lib/PopoverContent.d.ts create mode 100644 types/reactstrap/v4/lib/PopoverTitle.d.ts create mode 100644 types/reactstrap/v4/lib/Progress.d.ts create mode 100644 types/reactstrap/v4/lib/Row.d.ts create mode 100644 types/reactstrap/v4/lib/TabContent.d.ts create mode 100644 types/reactstrap/v4/lib/TabPane.d.ts create mode 100644 types/reactstrap/v4/lib/Table.d.ts create mode 100644 types/reactstrap/v4/lib/Tag.d.ts create mode 100644 types/reactstrap/v4/lib/TetherContent.d.ts create mode 100644 types/reactstrap/v4/lib/Tooltip.d.ts create mode 100644 types/reactstrap/v4/lib/Uncontrolled.d.ts create mode 100644 types/reactstrap/v4/reactstrap-tests.tsx create mode 100644 types/reactstrap/v4/tsconfig.json create mode 100644 types/reactstrap/v4/tslint.json diff --git a/types/reactstrap/index.d.ts b/types/reactstrap/index.d.ts index 81d4cec5bd..f484e15c25 100644 --- a/types/reactstrap/index.d.ts +++ b/types/reactstrap/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for reactstrap 4.6 +// Type definitions for reactstrap 5.0 // Project: https://github.com/reactstrap/reactstrap#readme // Definitions by: Ali Hammad Baig , Marco Falkenberg , Danilo Barros , Fábio Paiva // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped diff --git a/types/reactstrap/lib/Button.d.ts b/types/reactstrap/lib/Button.d.ts index e6ec222c14..fc2f34e4bb 100644 --- a/types/reactstrap/lib/Button.d.ts +++ b/types/reactstrap/lib/Button.d.ts @@ -7,7 +7,7 @@ interface Props extends React.HTMLProps { color?: string; disabled?: boolean; tag?: React.ReactType; - getRef?: string | ((instance: HTMLButtonElement) => any); + innerRef?: string | ((instance: HTMLButtonElement) => any); onClick?: React.MouseEventHandler; size?: any; diff --git a/types/reactstrap/lib/CardLink.d.ts b/types/reactstrap/lib/CardLink.d.ts index 3edf6b24f8..8c722a0102 100644 --- a/types/reactstrap/lib/CardLink.d.ts +++ b/types/reactstrap/lib/CardLink.d.ts @@ -2,7 +2,7 @@ import { CSSModule } from '../index'; interface Props { tag?: React.ReactType; - getRef?: string | ((instance: HTMLButtonElement) => any); + innerRef?: string | ((instance: HTMLButtonElement) => any); className?: string; cssModule?: CSSModule; href?: string; diff --git a/types/reactstrap/lib/Form.d.ts b/types/reactstrap/lib/Form.d.ts index dd06a2f855..a3f872d413 100644 --- a/types/reactstrap/lib/Form.d.ts +++ b/types/reactstrap/lib/Form.d.ts @@ -3,7 +3,7 @@ import { CSSModule } from '../index'; interface Props extends React.HTMLProps { inline?: boolean; tag?: React.ReactType; - getRef?: string | ((instance: HTMLButtonElement) => any); + innerRef?: string | ((instance: HTMLButtonElement) => any); className?: string; cssModule?: CSSModule; } diff --git a/types/reactstrap/lib/Input.d.ts b/types/reactstrap/lib/Input.d.ts index 541016ca02..eb82296e39 100644 --- a/types/reactstrap/lib/Input.d.ts +++ b/types/reactstrap/lib/Input.d.ts @@ -39,7 +39,7 @@ interface InputProps extends Intermediate { state?: string; valid?: boolean; tag?: React.ReactType; - getRef?: string | ((instance: HTMLInputElement) => any); + innerRef?: string | ((instance: HTMLInputElement) => any); static?: boolean; addon?: boolean; className?: string; diff --git a/types/reactstrap/lib/NavLink.d.ts b/types/reactstrap/lib/NavLink.d.ts index 2871fad72e..a72ff56fdf 100644 --- a/types/reactstrap/lib/NavLink.d.ts +++ b/types/reactstrap/lib/NavLink.d.ts @@ -2,7 +2,7 @@ import { CSSModule } from '../index'; interface Props extends React.HTMLProps { tag?: React.ReactType; - getRef?: string | ((instance: HTMLButtonElement) => any); + innerRef?: string | ((instance: HTMLButtonElement) => any); disabled?: boolean; active?: boolean; className?: string; diff --git a/types/reactstrap/reactstrap-tests.tsx b/types/reactstrap/reactstrap-tests.tsx index b094d4d019..4886d712eb 100644 --- a/types/reactstrap/reactstrap-tests.tsx +++ b/types/reactstrap/reactstrap-tests.tsx @@ -3302,7 +3302,7 @@ class Example107 extends React.Component { private input: HTMLInputElement; render() { - return { this.input = input; }} />; + return { this.input = input; }} />; } } diff --git a/types/reactstrap/v4/index.d.ts b/types/reactstrap/v4/index.d.ts new file mode 100644 index 0000000000..81d4cec5bd --- /dev/null +++ b/types/reactstrap/v4/index.d.ts @@ -0,0 +1,87 @@ +// Type definitions for reactstrap 4.6 +// Project: https://github.com/reactstrap/reactstrap#readme +// Definitions by: Ali Hammad Baig , Marco Falkenberg , Danilo Barros , Fábio Paiva +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +export interface CSSModule { + [className: string]: string; +} + +export { default as Alert } from './lib/Alert'; +export { default as Badge } from './lib/Badge'; +export { default as Breadcrumb } from './lib/Breadcrumb'; +export { default as BreadcrumbItem } from './lib/BreadcrumbItem'; +export { default as Button } from './lib/Button'; +export { default as ButtonDropdown } from './lib/ButtonDropdown'; +export { default as ButtonGroup } from './lib/ButtonGroup'; +export { default as ButtonToolbar } from './lib/ButtonToolbar'; +export { default as Card } from './lib/Card'; +export { default as CardBody } from './lib/CardBody'; +export { default as CardBlock } from './lib/CardBlock'; +export { default as CardColumns } from './lib/CardColumns'; +export { default as CardDeck } from './lib/CardDeck'; +export { default as CardFooter } from './lib/CardFooter'; +export { default as CardGroup } from './lib/CardGroup'; +export { default as CardHeader } from './lib/CardHeader'; +export { default as CardImg } from './lib/CardImg'; +export { default as CardImgOverlay } from './lib/CardImgOverlay'; +export { default as CardLink } from './lib/CardLink'; +export { default as CardSubtitle } from './lib/CardSubtitle'; +export { default as CardText } from './lib/CardText'; +export { default as CardTitle } from './lib/CardTitle'; +export { default as Col } from './lib/Col'; +export { default as Collapse } from './lib/Collapse'; +export { default as Container } from './lib/Container'; +export { default as Dropdown } from './lib/Dropdown'; +export { default as DropdownItem } from './lib/DropdownItem'; +export { default as DropdownMenu } from './lib/DropdownMenu'; +export { default as DropdownToggle } from './lib/DropdownToggle'; +export { default as Fade } from './lib/Fade'; +export { default as Form } from './lib/Form'; +export { default as FormFeedback } from './lib/FormFeedback'; +export { default as FormGroup } from './lib/FormGroup'; +export { default as FormText } from './lib/FormText'; +export { default as Input } from './lib/Input'; +export { default as InputGroup } from './lib/InputGroup'; +export { default as InputGroupAddon } from './lib/InputGroupAddon'; +export { default as InputGroupButton } from './lib/InputGroupButton'; +export { default as Jumbotron } from './lib/Jumbotron'; +export { default as Label } from './lib/Label'; +export { default as ListGroup } from './lib/ListGroup'; +export { default as ListGroupItem } from './lib/ListGroupItem'; +export { default as ListGroupItemHeading } from './lib/ListGroupItemHeading'; +export { default as ListGroupItemText } from './lib/ListGroupItemText'; +export { default as Media } from './lib/Media'; +export { default as Modal } from './lib/Modal'; +export { default as ModalBody } from './lib/ModalBody'; +export { default as ModalFooter } from './lib/ModalFooter'; +export { default as ModalHeader } from './lib/ModalHeader'; +export { default as Nav } from './lib/Nav'; +export { default as Navbar } from './lib/Navbar'; +export { default as NavbarBrand } from './lib/NavbarBrand'; +export { default as NavbarToggler } from './lib/NavbarToggler'; +export { default as NavDropdown } from './lib/NavDropdown'; +export { default as NavItem } from './lib/NavItem'; +export { default as NavLink } from './lib/NavLink'; +export { default as Pagination } from './lib/Pagination'; +export { default as PaginationItem } from './lib/PaginationItem'; +export { default as PaginationLink } from './lib/PaginationLink'; +export { default as Popover } from './lib/Popover'; +export { default as PopoverContent } from './lib/PopoverContent'; +export { default as PopoverTitle } from './lib/PopoverTitle'; +export { default as Progress } from './lib/Progress'; +export { default as Row } from './lib/Row'; +export { default as TabContent } from './lib/TabContent'; +export { default as Table } from './lib/Table'; +export { default as TabPane } from './lib/TabPane'; +export { default as Tag } from './lib/Tag'; +export { default as TetherContent } from './lib/TetherContent'; +export { default as Tooltip } from './lib/Tooltip'; +export { + UncontrolledAlert, + UncontrolledButtonDropdown, + UncontrolledDropdown, + UncontrolledNavDropdown, + UncontrolledTooltip +} from './lib/Uncontrolled'; diff --git a/types/reactstrap/v4/lib/Alert.d.ts b/types/reactstrap/v4/lib/Alert.d.ts new file mode 100644 index 0000000000..e29d62cb0d --- /dev/null +++ b/types/reactstrap/v4/lib/Alert.d.ts @@ -0,0 +1,19 @@ +import { CSSModule } from '../index'; + +export interface UncontrolledProps { + className?: string; + cssModule?: CSSModule; + color?: string; + tag?: React.ReactType; + transitionAppearTimeout?: number; + transitionEnterTimeout?: number; + transitionLeaveTimeout?: number; +} + +interface Props extends UncontrolledProps { + isOpen?: boolean; + toggle?: () => void; +} + +declare var Alert: React.StatelessComponent; +export default Alert; diff --git a/types/reactstrap/v4/lib/Badge.d.ts b/types/reactstrap/v4/lib/Badge.d.ts new file mode 100644 index 0000000000..51f72e39d3 --- /dev/null +++ b/types/reactstrap/v4/lib/Badge.d.ts @@ -0,0 +1,12 @@ +import { CSSModule } from '../index'; + +interface Props { + color?: string; + pill?: boolean; + tag?: React.ReactType; + className?: string; + cssModule?: CSSModule; +} + +declare var Badge: React.StatelessComponent; +export default Badge; diff --git a/types/reactstrap/v4/lib/Breadcrumb.d.ts b/types/reactstrap/v4/lib/Breadcrumb.d.ts new file mode 100644 index 0000000000..54f581288c --- /dev/null +++ b/types/reactstrap/v4/lib/Breadcrumb.d.ts @@ -0,0 +1,10 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: string; + className?: string; + cssModule?: CSSModule; +} + +declare var Breadcrumb: React.StatelessComponent; +export default Breadcrumb; diff --git a/types/reactstrap/v4/lib/BreadcrumbItem.d.ts b/types/reactstrap/v4/lib/BreadcrumbItem.d.ts new file mode 100644 index 0000000000..0277305b21 --- /dev/null +++ b/types/reactstrap/v4/lib/BreadcrumbItem.d.ts @@ -0,0 +1,15 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: React.ReactType; + active?: boolean; + className?: string; + cssModule?: CSSModule; + // if a is passed as a string + // this could be href + [others: string]: any; +} + +declare var BreadcrumbItem: React.StatelessComponent; +export default BreadcrumbItem; + diff --git a/types/reactstrap/v4/lib/Button.d.ts b/types/reactstrap/v4/lib/Button.d.ts new file mode 100644 index 0000000000..e6ec222c14 --- /dev/null +++ b/types/reactstrap/v4/lib/Button.d.ts @@ -0,0 +1,21 @@ +import { CSSModule } from '../index'; + +interface Props extends React.HTMLProps { + outline?: boolean; + active?: boolean; + block?: boolean; + color?: string; + disabled?: boolean; + tag?: React.ReactType; + getRef?: string | ((instance: HTMLButtonElement) => any); + + onClick?: React.MouseEventHandler; + size?: any; + id?: string; + style?: React.CSSProperties; + + cssModule?: CSSModule; +} + +declare var Button: React.StatelessComponent; +export default Button; diff --git a/types/reactstrap/v4/lib/ButtonDropdown.d.ts b/types/reactstrap/v4/lib/ButtonDropdown.d.ts new file mode 100644 index 0000000000..9ab54c7502 --- /dev/null +++ b/types/reactstrap/v4/lib/ButtonDropdown.d.ts @@ -0,0 +1,12 @@ +import { + UncontrolledProps as DropdownUncontrolledProps, + Props as DropdownProps +} from './Dropdown'; + +// tslint:disable-next-line +export interface UncontrolledProps extends DropdownUncontrolledProps { } +// tslint:disable-next-line +interface Props extends DropdownProps { } + +declare var ButtonDropdown: React.StatelessComponent; +export default ButtonDropdown; \ No newline at end of file diff --git a/types/reactstrap/v4/lib/ButtonGroup.d.ts b/types/reactstrap/v4/lib/ButtonGroup.d.ts new file mode 100644 index 0000000000..d807ea33cf --- /dev/null +++ b/types/reactstrap/v4/lib/ButtonGroup.d.ts @@ -0,0 +1,14 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: React.ReactType; + 'aria-label'?: string; + className?: string; + cssModule?: CSSModule; + role?: string; + size?: string; + vertical?: boolean; +} + +declare var ButtonGroup: React.StatelessComponent; +export default ButtonGroup; diff --git a/types/reactstrap/v4/lib/ButtonToolbar.d.ts b/types/reactstrap/v4/lib/ButtonToolbar.d.ts new file mode 100644 index 0000000000..fea31dd5d5 --- /dev/null +++ b/types/reactstrap/v4/lib/ButtonToolbar.d.ts @@ -0,0 +1,12 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: React.ReactType; + 'aria-label'?: string; + className?: string; + cssModule?: CSSModule; + role?: string; +} + +declare var ButtonToolbar: React.StatelessComponent; +export default ButtonToolbar; diff --git a/types/reactstrap/v4/lib/Card.d.ts b/types/reactstrap/v4/lib/Card.d.ts new file mode 100644 index 0000000000..0dbde7f879 --- /dev/null +++ b/types/reactstrap/v4/lib/Card.d.ts @@ -0,0 +1,16 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: React.ReactType; + inverse?: boolean; + color?: string; + block?: boolean; + outline?: boolean; + className?: string; + cssModule?: CSSModule; + style?: React.CSSProperties; +} + +declare var Card: React.StatelessComponent; +export default Card; + diff --git a/types/reactstrap/v4/lib/CardBlock.d.ts b/types/reactstrap/v4/lib/CardBlock.d.ts new file mode 100644 index 0000000000..0aa31a63a7 --- /dev/null +++ b/types/reactstrap/v4/lib/CardBlock.d.ts @@ -0,0 +1,11 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: React.ReactType; + className?: string; + cssModule?: CSSModule; +} + +declare var CardBlock: React.StatelessComponent; +export default CardBlock; + diff --git a/types/reactstrap/v4/lib/CardBody.d.ts b/types/reactstrap/v4/lib/CardBody.d.ts new file mode 100644 index 0000000000..2b94e52ea8 --- /dev/null +++ b/types/reactstrap/v4/lib/CardBody.d.ts @@ -0,0 +1,10 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: React.ReactType; + className?: string; + cssModule?: CSSModule; +} + +declare var CardBody: React.StatelessComponent; +export default CardBody; diff --git a/types/reactstrap/v4/lib/CardColumns.d.ts b/types/reactstrap/v4/lib/CardColumns.d.ts new file mode 100644 index 0000000000..0cc1a80a1a --- /dev/null +++ b/types/reactstrap/v4/lib/CardColumns.d.ts @@ -0,0 +1,10 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: React.ReactType; + className?: string; + cssModule?: CSSModule; +} + +declare var CardColumns: React.StatelessComponent; +export default CardColumns; diff --git a/types/reactstrap/v4/lib/CardDeck.d.ts b/types/reactstrap/v4/lib/CardDeck.d.ts new file mode 100644 index 0000000000..1a5882aa54 --- /dev/null +++ b/types/reactstrap/v4/lib/CardDeck.d.ts @@ -0,0 +1,10 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: React.ReactType; + className?: string; + cssModule?: CSSModule; +} + +declare var CardDeck: React.StatelessComponent; +export default CardDeck; diff --git a/types/reactstrap/v4/lib/CardFooter.d.ts b/types/reactstrap/v4/lib/CardFooter.d.ts new file mode 100644 index 0000000000..0956cb06c9 --- /dev/null +++ b/types/reactstrap/v4/lib/CardFooter.d.ts @@ -0,0 +1,10 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: React.ReactType; + className?: string; + cssModule?: CSSModule; +} + +declare var CardFooter: React.StatelessComponent; +export default CardFooter; diff --git a/types/reactstrap/v4/lib/CardGroup.d.ts b/types/reactstrap/v4/lib/CardGroup.d.ts new file mode 100644 index 0000000000..5c0a0a1ab1 --- /dev/null +++ b/types/reactstrap/v4/lib/CardGroup.d.ts @@ -0,0 +1,10 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: React.ReactType; + className?: string; + cssModule?: CSSModule; +} + +declare var CardGroup: React.StatelessComponent; +export default CardGroup; diff --git a/types/reactstrap/v4/lib/CardHeader.d.ts b/types/reactstrap/v4/lib/CardHeader.d.ts new file mode 100644 index 0000000000..f063057c92 --- /dev/null +++ b/types/reactstrap/v4/lib/CardHeader.d.ts @@ -0,0 +1,10 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: React.ReactType; + className?: string; + cssModule?: CSSModule; +} + +declare var CardHeader: React.StatelessComponent; +export default CardHeader; diff --git a/types/reactstrap/v4/lib/CardImg.d.ts b/types/reactstrap/v4/lib/CardImg.d.ts new file mode 100644 index 0000000000..1c3fee274b --- /dev/null +++ b/types/reactstrap/v4/lib/CardImg.d.ts @@ -0,0 +1,16 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: React.ReactType; + top?: boolean; + bottom?: boolean; + className?: string; + cssModule?: CSSModule; + src?: string; + width?: string; + height?: string; + alt?: string; +} + +declare var CardImg: React.StatelessComponent; +export default CardImg; diff --git a/types/reactstrap/v4/lib/CardImgOverlay.d.ts b/types/reactstrap/v4/lib/CardImgOverlay.d.ts new file mode 100644 index 0000000000..05519847b2 --- /dev/null +++ b/types/reactstrap/v4/lib/CardImgOverlay.d.ts @@ -0,0 +1,10 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: React.ReactType; + className?: string; + cssModule?: CSSModule; +} + +declare var CardImgOverlay: React.StatelessComponent; +export default CardImgOverlay; diff --git a/types/reactstrap/v4/lib/CardLink.d.ts b/types/reactstrap/v4/lib/CardLink.d.ts new file mode 100644 index 0000000000..3edf6b24f8 --- /dev/null +++ b/types/reactstrap/v4/lib/CardLink.d.ts @@ -0,0 +1,12 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: React.ReactType; + getRef?: string | ((instance: HTMLButtonElement) => any); + className?: string; + cssModule?: CSSModule; + href?: string; +} + +declare var CardLink: React.StatelessComponent; +export default CardLink; diff --git a/types/reactstrap/v4/lib/CardSubtitle.d.ts b/types/reactstrap/v4/lib/CardSubtitle.d.ts new file mode 100644 index 0000000000..bfacd4e794 --- /dev/null +++ b/types/reactstrap/v4/lib/CardSubtitle.d.ts @@ -0,0 +1,10 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: React.ReactType; + className?: string; + cssModule?: CSSModule; +} + +declare var CardSubtitle: React.StatelessComponent; +export default CardSubtitle; diff --git a/types/reactstrap/v4/lib/CardText.d.ts b/types/reactstrap/v4/lib/CardText.d.ts new file mode 100644 index 0000000000..13177fba67 --- /dev/null +++ b/types/reactstrap/v4/lib/CardText.d.ts @@ -0,0 +1,10 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: React.ReactType; + className?: string; + cssModule?: CSSModule; +} + +declare var CardText: React.StatelessComponent; +export default CardText; diff --git a/types/reactstrap/v4/lib/CardTitle.d.ts b/types/reactstrap/v4/lib/CardTitle.d.ts new file mode 100644 index 0000000000..2843800a4e --- /dev/null +++ b/types/reactstrap/v4/lib/CardTitle.d.ts @@ -0,0 +1,10 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: React.ReactType; + className?: string; + cssModule?: CSSModule; +} + +declare var CardTitle: React.StatelessComponent; +export default CardTitle; diff --git a/types/reactstrap/v4/lib/Col.d.ts b/types/reactstrap/v4/lib/Col.d.ts new file mode 100644 index 0000000000..a2ea76d607 --- /dev/null +++ b/types/reactstrap/v4/lib/Col.d.ts @@ -0,0 +1,24 @@ +export type ColumnProps + = string + | boolean + | number + | { + size?: boolean | number | string + push?: string | number + pull?: string | number + offset?: string | number + }; + +interface Props extends React.HTMLProps { + xs?: ColumnProps; + sm?: ColumnProps; + md?: ColumnProps; + lg?: ColumnProps; + xl?: ColumnProps; + + //custom widths + widths?: string[]; +} + +declare var Col: React.StatelessComponent; +export default Col; diff --git a/types/reactstrap/v4/lib/Collapse.d.ts b/types/reactstrap/v4/lib/Collapse.d.ts new file mode 100644 index 0000000000..50160bbcf6 --- /dev/null +++ b/types/reactstrap/v4/lib/Collapse.d.ts @@ -0,0 +1,18 @@ +import { CSSModule } from '../index'; + +interface Props extends React.HTMLProps { + isOpen?: boolean; + classNames?: string; + cssModule?: CSSModule; + tag?: React.ReactType; + navbar?: boolean; + delay?: { + show: number + hide: number + }; + onOpened?: () => void; + onClosed?: () => void; +} + +declare var Collapse: React.StatelessComponent; +export default Collapse; diff --git a/types/reactstrap/v4/lib/Container.d.ts b/types/reactstrap/v4/lib/Container.d.ts new file mode 100644 index 0000000000..f49951ba26 --- /dev/null +++ b/types/reactstrap/v4/lib/Container.d.ts @@ -0,0 +1,11 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: React.ReactType; + fluid?: boolean; + className?: string; + cssModule?: CSSModule; +} + +declare var Container: React.StatelessComponent; +export default Container; diff --git a/types/reactstrap/v4/lib/Dropdown.d.ts b/types/reactstrap/v4/lib/Dropdown.d.ts new file mode 100644 index 0000000000..19d1500cbe --- /dev/null +++ b/types/reactstrap/v4/lib/Dropdown.d.ts @@ -0,0 +1,22 @@ +/// + +import { CSSModule } from '../index'; + +export interface UncontrolledProps { + isOpen?: boolean; + toggle?: () => void; + className?: string; + cssModule?: CSSModule; +} + +export interface Props extends UncontrolledProps { + disabled?: boolean; + dropup?: boolean; + group?: boolean; + size?: string; + tag?: React.ReactType; + tether?: boolean | Tether.ITetherOptions; +} + +declare var Dropdown: React.StatelessComponent; +export default Dropdown; diff --git a/types/reactstrap/v4/lib/DropdownItem.d.ts b/types/reactstrap/v4/lib/DropdownItem.d.ts new file mode 100644 index 0000000000..6fae837041 --- /dev/null +++ b/types/reactstrap/v4/lib/DropdownItem.d.ts @@ -0,0 +1,15 @@ +import { CSSModule } from '../index'; + +interface Props { + disabled?: boolean; + divider?: boolean; + tag?: React.ReactType; + header?: boolean; + onClick?: (event: React.MouseEvent) => void; + className?: string; + cssModule?: CSSModule; + href?: string; +} + +declare var DropdownItem: React.StatelessComponent; +export default DropdownItem; diff --git a/types/reactstrap/v4/lib/DropdownMenu.d.ts b/types/reactstrap/v4/lib/DropdownMenu.d.ts new file mode 100644 index 0000000000..7fae41b04b --- /dev/null +++ b/types/reactstrap/v4/lib/DropdownMenu.d.ts @@ -0,0 +1,11 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: React.ReactType; + right?: boolean; + className?: string; + cssModule?: CSSModule; +} + +declare var DropdownMenu: React.StatelessComponent; +export default DropdownMenu; diff --git a/types/reactstrap/v4/lib/DropdownToggle.d.ts b/types/reactstrap/v4/lib/DropdownToggle.d.ts new file mode 100644 index 0000000000..5ef49db71f --- /dev/null +++ b/types/reactstrap/v4/lib/DropdownToggle.d.ts @@ -0,0 +1,19 @@ +import { CSSModule } from '../index'; + +interface Props { + caret?: boolean; + className?: string; + cssModule?: CSSModule; + disabled?: boolean; + onClick?: React.MouseEventHandler; + 'data-toggle'?: string; + 'aria-haspopup'?: boolean; + split?: boolean; + tag?: React.ReactType; + nav?: boolean; + color?: string; + size?: string; +} + +declare var DropdownToggle: React.StatelessComponent; +export default DropdownToggle; diff --git a/types/reactstrap/v4/lib/Fade.d.ts b/types/reactstrap/v4/lib/Fade.d.ts new file mode 100644 index 0000000000..30862d2e17 --- /dev/null +++ b/types/reactstrap/v4/lib/Fade.d.ts @@ -0,0 +1,20 @@ +import { CSSModule } from '../index'; + +interface Props { + baseClass?: string; + baseClassIn?: string; + tag?: React.ReactType; + className?: string; + cssModule?: CSSModule; + transitionAppearTimeout?: number; + transitionEnterTimeout?: number; + transitionLeaveTimeout?: number; + transitionAppear?: boolean; + transitionEnter?: boolean; + transitionLeave?: boolean; + onLeave?: () => void; + onEnter?: () => void; +} + +declare var Fade: React.StatelessComponent; +export default Fade; diff --git a/types/reactstrap/v4/lib/Form.d.ts b/types/reactstrap/v4/lib/Form.d.ts new file mode 100644 index 0000000000..dd06a2f855 --- /dev/null +++ b/types/reactstrap/v4/lib/Form.d.ts @@ -0,0 +1,12 @@ +import { CSSModule } from '../index'; + +interface Props extends React.HTMLProps { + inline?: boolean; + tag?: React.ReactType; + getRef?: string | ((instance: HTMLButtonElement) => any); + className?: string; + cssModule?: CSSModule; +} + +declare var Form: React.StatelessComponent; +export default Form; diff --git a/types/reactstrap/v4/lib/FormFeedback.d.ts b/types/reactstrap/v4/lib/FormFeedback.d.ts new file mode 100644 index 0000000000..7fde21b062 --- /dev/null +++ b/types/reactstrap/v4/lib/FormFeedback.d.ts @@ -0,0 +1,10 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: string; + className?: string; + cssModule?: CSSModule; +} + +declare var FormFeedback: React.StatelessComponent; +export default FormFeedback; diff --git a/types/reactstrap/v4/lib/FormGroup.d.ts b/types/reactstrap/v4/lib/FormGroup.d.ts new file mode 100644 index 0000000000..6031ff2f75 --- /dev/null +++ b/types/reactstrap/v4/lib/FormGroup.d.ts @@ -0,0 +1,14 @@ +import { CSSModule } from '../index'; + +interface Props extends React.HTMLProps { + row?: boolean; + check?: boolean; + disabled?: boolean; + tag?: React.ReactType; + color?: string; + className?: string; + cssModule?: CSSModule; +} + +declare var FormGroup: React.StatelessComponent; +export default FormGroup; diff --git a/types/reactstrap/v4/lib/FormText.d.ts b/types/reactstrap/v4/lib/FormText.d.ts new file mode 100644 index 0000000000..3cfab3511e --- /dev/null +++ b/types/reactstrap/v4/lib/FormText.d.ts @@ -0,0 +1,12 @@ +import { CSSModule } from '../index'; + +interface Props { + inline?: boolean; + tag?: React.ReactType; + color?: string; + className?: string; + cssModule?: CSSModule; +} + +declare var FormText: React.StatelessComponent; +export default FormText; diff --git a/types/reactstrap/v4/lib/Input.d.ts b/types/reactstrap/v4/lib/Input.d.ts new file mode 100644 index 0000000000..541016ca02 --- /dev/null +++ b/types/reactstrap/v4/lib/Input.d.ts @@ -0,0 +1,52 @@ +import { CSSModule } from '../index'; + +type InputType = + | 'text' + | 'email' + | 'select' + | 'file' + | 'radio' + | 'checkbox' + | 'textarea' + | 'button' + | 'reset' + | 'submit' + | 'date' + | 'datetime-local' + | 'hidden' + | 'image' + | 'month' + | 'number' + | 'range' + | 'search' + | 'tel' + | 'url' + | 'week' + | 'password' + | 'datetime' + | 'time' + | 'color'; + +// Intermediate interface to "redefine" the type of size to string +// size:number => size:any => size:string +interface Intermediate extends React.InputHTMLAttributes { + size?: any; +} + +interface InputProps extends Intermediate { + type?: InputType; + size?: string; + state?: string; + valid?: boolean; + tag?: React.ReactType; + getRef?: string | ((instance: HTMLInputElement) => any); + static?: boolean; + addon?: boolean; + className?: string; + cssModule?: CSSModule; + // We don't have the property 'static' here because 'static' is a reserved keyword in TypeScript + // Maybe reactstrap will support an 'isStatic' alias in the future +} + +declare var Input: React.StatelessComponent; +export default Input; diff --git a/types/reactstrap/v4/lib/InputGroup.d.ts b/types/reactstrap/v4/lib/InputGroup.d.ts new file mode 100644 index 0000000000..2de95edc94 --- /dev/null +++ b/types/reactstrap/v4/lib/InputGroup.d.ts @@ -0,0 +1,11 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: React.ReactType; + size?: string; + className?: string; + cssModule?: CSSModule; +} + +declare var InputGroup: React.StatelessComponent; +export default InputGroup; diff --git a/types/reactstrap/v4/lib/InputGroupAddon.d.ts b/types/reactstrap/v4/lib/InputGroupAddon.d.ts new file mode 100644 index 0000000000..a98eb5d821 --- /dev/null +++ b/types/reactstrap/v4/lib/InputGroupAddon.d.ts @@ -0,0 +1,10 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: React.ReactType; + className?: string; + cssModule?: CSSModule; +} + +declare var InputGroupAddon: React.StatelessComponent; +export default InputGroupAddon; diff --git a/types/reactstrap/v4/lib/InputGroupButton.d.ts b/types/reactstrap/v4/lib/InputGroupButton.d.ts new file mode 100644 index 0000000000..fa7cb1995a --- /dev/null +++ b/types/reactstrap/v4/lib/InputGroupButton.d.ts @@ -0,0 +1,13 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: React.ReactType; + groupClassName?: string; + groupAttributes?: any; + className?: string; + cssModule?: CSSModule; + color?: string; +} + +declare var InputGroupButton: React.StatelessComponent; +export default InputGroupButton; diff --git a/types/reactstrap/v4/lib/Jumbotron.d.ts b/types/reactstrap/v4/lib/Jumbotron.d.ts new file mode 100644 index 0000000000..cc1f65c956 --- /dev/null +++ b/types/reactstrap/v4/lib/Jumbotron.d.ts @@ -0,0 +1,11 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: React.ReactType; + fluid?: boolean; + className?: string; + cssModule?: CSSModule; +} + +declare var Jumbotron: React.StatelessComponent; +export default Jumbotron; diff --git a/types/reactstrap/v4/lib/Label.d.ts b/types/reactstrap/v4/lib/Label.d.ts new file mode 100644 index 0000000000..eb496d90a3 --- /dev/null +++ b/types/reactstrap/v4/lib/Label.d.ts @@ -0,0 +1,26 @@ +import { CSSModule } from '../index'; +import { ColumnProps } from './Col'; + +interface Intermediate extends React.LabelHTMLAttributes { + size?: any; +} + +interface Props extends Intermediate { + hidden?: boolean; + check?: boolean; + inline?: boolean; + disabled?: boolean; + size?: string; + for?: string; + tag?: string; + className?: string; + cssModule?: CSSModule; + xs?: ColumnProps; + sm?: ColumnProps; + md?: ColumnProps; + lg?: ColumnProps; + xl?: ColumnProps; +} + +declare var Label: React.StatelessComponent; +export default Label; diff --git a/types/reactstrap/v4/lib/ListGroup.d.ts b/types/reactstrap/v4/lib/ListGroup.d.ts new file mode 100644 index 0000000000..861c7a1d06 --- /dev/null +++ b/types/reactstrap/v4/lib/ListGroup.d.ts @@ -0,0 +1,11 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: React.ReactType; + flush?: boolean; + className?: string; + cssModule?: CSSModule; +} + +declare var ListGroup: React.StatelessComponent; +export default ListGroup; diff --git a/types/reactstrap/v4/lib/ListGroupItem.d.ts b/types/reactstrap/v4/lib/ListGroupItem.d.ts new file mode 100644 index 0000000000..b2241998dc --- /dev/null +++ b/types/reactstrap/v4/lib/ListGroupItem.d.ts @@ -0,0 +1,17 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: React.ReactType; + active?: boolean; + disabled?: boolean; + color?: string; + action?: boolean; + className?: string; + cssModule?: CSSModule; + href?: string; + + onClick?: React.MouseEventHandler; +} + +declare var ListGroupItem: React.StatelessComponent; +export default ListGroupItem; diff --git a/types/reactstrap/v4/lib/ListGroupItemHeading.d.ts b/types/reactstrap/v4/lib/ListGroupItemHeading.d.ts new file mode 100644 index 0000000000..869a6b2708 --- /dev/null +++ b/types/reactstrap/v4/lib/ListGroupItemHeading.d.ts @@ -0,0 +1,10 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: React.ReactType; + className?: string; + cssModule?: CSSModule; +} + +declare var ListGroupItemHeading: React.StatelessComponent; +export default ListGroupItemHeading; diff --git a/types/reactstrap/v4/lib/ListGroupItemText.d.ts b/types/reactstrap/v4/lib/ListGroupItemText.d.ts new file mode 100644 index 0000000000..df263f30d8 --- /dev/null +++ b/types/reactstrap/v4/lib/ListGroupItemText.d.ts @@ -0,0 +1,10 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: React.ReactType; + className?: string; + cssModule?: CSSModule; +} + +declare var ListGroupItemText: React.StatelessComponent; +export default ListGroupItemText; diff --git a/types/reactstrap/v4/lib/Media.d.ts b/types/reactstrap/v4/lib/Media.d.ts new file mode 100644 index 0000000000..c5408d85d7 --- /dev/null +++ b/types/reactstrap/v4/lib/Media.d.ts @@ -0,0 +1,21 @@ +import { CSSModule } from '../index'; + +interface Props { + body?: boolean; + bottom?: boolean; + className?: string; + cssModule?: CSSModule; + heading?: boolean; + left?: boolean; + list?: boolean; + middle?: boolean; + object?: boolean; + right?: boolean; + tag?: React.ReactType; + top?: boolean; + href?: string; + alt?: string; +} + +declare var Media: React.StatelessComponent; +export default Media; diff --git a/types/reactstrap/v4/lib/Modal.d.ts b/types/reactstrap/v4/lib/Modal.d.ts new file mode 100644 index 0000000000..1e239fbe12 --- /dev/null +++ b/types/reactstrap/v4/lib/Modal.d.ts @@ -0,0 +1,23 @@ +import { CSSModule } from '../index'; + +interface Props { + isOpen?: boolean; + autoFocus?: boolean; + size?: string; + toggle?: () => void; + keyboard?: boolean; + backdrop?: boolean | 'static'; + onEnter?: () => void; + onExit?: () => void; + className?: string; + cssModule?: CSSModule; + wrapClassName?: string; + modalClassName?: string; + backdropClassName?: string; + contentClassName?: string; + zIndex?: number | string; + fade?: boolean; +} + +declare var Modal: React.StatelessComponent; +export default Modal; diff --git a/types/reactstrap/v4/lib/ModalBody.d.ts b/types/reactstrap/v4/lib/ModalBody.d.ts new file mode 100644 index 0000000000..98933b2fc2 --- /dev/null +++ b/types/reactstrap/v4/lib/ModalBody.d.ts @@ -0,0 +1,10 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: React.ReactType; + className?: string; + cssModule?: CSSModule; +} + +declare var ModalBody: React.StatelessComponent; +export default ModalBody; diff --git a/types/reactstrap/v4/lib/ModalFooter.d.ts b/types/reactstrap/v4/lib/ModalFooter.d.ts new file mode 100644 index 0000000000..84b3da7ec8 --- /dev/null +++ b/types/reactstrap/v4/lib/ModalFooter.d.ts @@ -0,0 +1,10 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: React.ReactType; + className?: string; + cssModule?: CSSModule; +} + +declare var ModalFooter: React.StatelessComponent; +export default ModalFooter; diff --git a/types/reactstrap/v4/lib/ModalHeader.d.ts b/types/reactstrap/v4/lib/ModalHeader.d.ts new file mode 100644 index 0000000000..494c9685a3 --- /dev/null +++ b/types/reactstrap/v4/lib/ModalHeader.d.ts @@ -0,0 +1,12 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: React.ReactType; + className?: string; + cssModule?: CSSModule; + wrapTag?: React.ReactType; + toggle?: () => void; +} + +declare var ModalHeader: React.StatelessComponent; +export default ModalHeader; diff --git a/types/reactstrap/v4/lib/Nav.d.ts b/types/reactstrap/v4/lib/Nav.d.ts new file mode 100644 index 0000000000..c646e94304 --- /dev/null +++ b/types/reactstrap/v4/lib/Nav.d.ts @@ -0,0 +1,17 @@ +import { CSSModule } from '../index'; + +interface Props extends React.HTMLProps { + inline?: boolean; + disabled?: boolean; + tabs?: boolean; + pills?: boolean; + stacked?: boolean; + navbar?: boolean; + tag?: React.ReactType; + className?: string; + cssModule?: CSSModule; + vertical?: boolean; +} + +declare var Nav: React.StatelessComponent; +export default Nav; diff --git a/types/reactstrap/v4/lib/NavDropdown.d.ts b/types/reactstrap/v4/lib/NavDropdown.d.ts new file mode 100644 index 0000000000..6b480d495a --- /dev/null +++ b/types/reactstrap/v4/lib/NavDropdown.d.ts @@ -0,0 +1,12 @@ +import { + UncontrolledProps as DropdownUncontrolledProps, + Props as DropdownProps +} from './Dropdown'; + +// tslint:disable-next-line +export interface UncontrolledProps extends DropdownUncontrolledProps { } +// tslint:disable-next-line +interface Props extends DropdownProps { } + +declare var NavDropdown: React.StatelessComponent; +export default NavDropdown; \ No newline at end of file diff --git a/types/reactstrap/v4/lib/NavItem.d.ts b/types/reactstrap/v4/lib/NavItem.d.ts new file mode 100644 index 0000000000..db19f92c56 --- /dev/null +++ b/types/reactstrap/v4/lib/NavItem.d.ts @@ -0,0 +1,10 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: React.ReactType; + className?: string; + cssModule?: CSSModule; +} + +declare var NavItem: React.StatelessComponent; +export default NavItem; diff --git a/types/reactstrap/v4/lib/NavLink.d.ts b/types/reactstrap/v4/lib/NavLink.d.ts new file mode 100644 index 0000000000..2871fad72e --- /dev/null +++ b/types/reactstrap/v4/lib/NavLink.d.ts @@ -0,0 +1,15 @@ +import { CSSModule } from '../index'; + +interface Props extends React.HTMLProps { + tag?: React.ReactType; + getRef?: string | ((instance: HTMLButtonElement) => any); + disabled?: boolean; + active?: boolean; + className?: string; + cssModule?: CSSModule; + onClick?: React.MouseEventHandler; + href?: string; +} + +declare var NavLink: React.StatelessComponent; +export default NavLink; diff --git a/types/reactstrap/v4/lib/Navbar.d.ts b/types/reactstrap/v4/lib/Navbar.d.ts new file mode 100644 index 0000000000..58f9235140 --- /dev/null +++ b/types/reactstrap/v4/lib/Navbar.d.ts @@ -0,0 +1,20 @@ +import { CSSModule } from '../index'; + +interface Props { + light?: boolean; + dark?: boolean; + inverse?: boolean; + full?: boolean; + fixed?: string; + sticky?: string; + color?: string; + role?: string; + tag?: React.ReactType; + className?: string; + cssModule?: CSSModule; + toggleable?: boolean | string; + expand?: boolean | string; +} + +declare var Navbar: React.StatelessComponent; +export default Navbar; diff --git a/types/reactstrap/v4/lib/NavbarBrand.d.ts b/types/reactstrap/v4/lib/NavbarBrand.d.ts new file mode 100644 index 0000000000..3748a2903f --- /dev/null +++ b/types/reactstrap/v4/lib/NavbarBrand.d.ts @@ -0,0 +1,10 @@ +import { CSSModule } from '../index'; + +interface Props extends React.HTMLProps { + tag?: React.ReactType; + className?: string; + cssModule?: CSSModule; +} + +declare var NavbarBrand: React.StatelessComponent; +export default NavbarBrand; diff --git a/types/reactstrap/v4/lib/NavbarToggler.d.ts b/types/reactstrap/v4/lib/NavbarToggler.d.ts new file mode 100644 index 0000000000..282eeaa672 --- /dev/null +++ b/types/reactstrap/v4/lib/NavbarToggler.d.ts @@ -0,0 +1,13 @@ +import { CSSModule } from '../index'; + +interface Props extends React.HTMLProps { + tag?: React.ReactType; + type?: string; + className?: string; + cssModule?: CSSModule; + right?: boolean; + left?: boolean; +} + +declare var NavbarToggler: React.StatelessComponent; +export default NavbarToggler; diff --git a/types/reactstrap/v4/lib/Pagination.d.ts b/types/reactstrap/v4/lib/Pagination.d.ts new file mode 100644 index 0000000000..a34401be35 --- /dev/null +++ b/types/reactstrap/v4/lib/Pagination.d.ts @@ -0,0 +1,10 @@ +import { CSSModule } from '../index'; + +interface Props { + className?: string; + cssModule?: CSSModule; + size?: string; +} + +declare var Pagination: React.StatelessComponent; +export default Pagination; diff --git a/types/reactstrap/v4/lib/PaginationItem.d.ts b/types/reactstrap/v4/lib/PaginationItem.d.ts new file mode 100644 index 0000000000..183a7e9d84 --- /dev/null +++ b/types/reactstrap/v4/lib/PaginationItem.d.ts @@ -0,0 +1,12 @@ +import { CSSModule } from '../index'; + +interface Props { + className?: string; + cssModule?: CSSModule; + active?: boolean; + disabled?: boolean; + tag?: React.ReactType; +} + +declare var PaginationItem: React.StatelessComponent; +export default PaginationItem; diff --git a/types/reactstrap/v4/lib/PaginationLink.d.ts b/types/reactstrap/v4/lib/PaginationLink.d.ts new file mode 100644 index 0000000000..16e194578d --- /dev/null +++ b/types/reactstrap/v4/lib/PaginationLink.d.ts @@ -0,0 +1,13 @@ +import { CSSModule } from '../index'; + +interface Props extends React.HTMLProps { + 'aria-label'?: string; + className?: string; + cssModule?: CSSModule; + next?: boolean; + previous?: boolean; + tag?: React.ReactType; +} + +declare var PaginationLink: React.StatelessComponent; +export default PaginationLink; diff --git a/types/reactstrap/v4/lib/Popover.d.ts b/types/reactstrap/v4/lib/Popover.d.ts new file mode 100644 index 0000000000..b779a33ede --- /dev/null +++ b/types/reactstrap/v4/lib/Popover.d.ts @@ -0,0 +1,34 @@ +/// + +import { CSSModule } from '../index'; + +type Placement + = 'top' + | 'bottom' + | 'left' + | 'right' + | 'top left' + | 'top center' + | 'top right' + | 'right top' + | 'right middle' + | 'right bottom' + | 'bottom right' + | 'bottom center' + | 'bottom left' + | 'left top' + | 'left middle' + | 'left bottom'; + +interface Props { + placement?: Placement; + target: string; + isOpen?: boolean; + tether?: Tether.ITetherOptions; + className?: string; + cssModule?: CSSModule; + toggle?: () => void; +} + +declare var Popover: React.StatelessComponent; +export default Popover; diff --git a/types/reactstrap/v4/lib/PopoverContent.d.ts b/types/reactstrap/v4/lib/PopoverContent.d.ts new file mode 100644 index 0000000000..cac45d14cb --- /dev/null +++ b/types/reactstrap/v4/lib/PopoverContent.d.ts @@ -0,0 +1,10 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: React.ReactType; + className?: string; + cssModule?: CSSModule; +} + +declare var PopoverContent: React.StatelessComponent; +export default PopoverContent; diff --git a/types/reactstrap/v4/lib/PopoverTitle.d.ts b/types/reactstrap/v4/lib/PopoverTitle.d.ts new file mode 100644 index 0000000000..796de02658 --- /dev/null +++ b/types/reactstrap/v4/lib/PopoverTitle.d.ts @@ -0,0 +1,10 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: React.ReactType; + className?: string; + cssModule?: CSSModule; +} + +declare var PopoverTitle: React.StatelessComponent; +export default PopoverTitle; diff --git a/types/reactstrap/v4/lib/Progress.d.ts b/types/reactstrap/v4/lib/Progress.d.ts new file mode 100644 index 0000000000..09c4304373 --- /dev/null +++ b/types/reactstrap/v4/lib/Progress.d.ts @@ -0,0 +1,18 @@ +import { CSSModule } from '../index'; + +interface Props { + bar?: boolean; + multi?: boolean; + tag?: string; + value?: string | number; + max?: string | number; + animated?: boolean; + striped?: boolean; + color?: string; + className?: string; + cssModule?: CSSModule; + barClassName?: string; +} + +declare var Progress: React.StatelessComponent; +export default Progress; diff --git a/types/reactstrap/v4/lib/Row.d.ts b/types/reactstrap/v4/lib/Row.d.ts new file mode 100644 index 0000000000..1ffbb9f7e6 --- /dev/null +++ b/types/reactstrap/v4/lib/Row.d.ts @@ -0,0 +1,11 @@ +import { CSSModule } from '../index'; + +interface Props extends React.HTMLProps< HTMLElement> { + className?: string; + cssModule?: CSSModule; + tag?: React.ReactType; + noGutters?: boolean; +} + +declare var Row: React.StatelessComponent; +export default Row; diff --git a/types/reactstrap/v4/lib/TabContent.d.ts b/types/reactstrap/v4/lib/TabContent.d.ts new file mode 100644 index 0000000000..af6feec078 --- /dev/null +++ b/types/reactstrap/v4/lib/TabContent.d.ts @@ -0,0 +1,11 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: React.ReactType; + activeTab?: number | string; + className?: string; + cssModule?: CSSModule; +} + +declare var TabContent: React.StatelessComponent; +export default TabContent; diff --git a/types/reactstrap/v4/lib/TabPane.d.ts b/types/reactstrap/v4/lib/TabPane.d.ts new file mode 100644 index 0000000000..9eead420be --- /dev/null +++ b/types/reactstrap/v4/lib/TabPane.d.ts @@ -0,0 +1,11 @@ +import { CSSModule } from '../index'; + +interface Props { + tag?: React.ReactType; + className?: string; + cssModule?: CSSModule; + tabId?: number | string; +} + +declare var TabPane: React.StatelessComponent; +export default TabPane; diff --git a/types/reactstrap/v4/lib/Table.d.ts b/types/reactstrap/v4/lib/Table.d.ts new file mode 100644 index 0000000000..ec8bfc43fd --- /dev/null +++ b/types/reactstrap/v4/lib/Table.d.ts @@ -0,0 +1,18 @@ +import { CSSModule } from '../index'; + +interface Props { + className?: string; + cssModule?: CSSModule; + size?: string; + bordered?: boolean; + striped?: boolean; + inverse?: boolean; + hover?: boolean; + reflow?: boolean; + responsive?: boolean; + tag?: React.ReactType; + responsiveTag?: React.ReactType; +} + +declare var Table: React.StatelessComponent; +export default Table; diff --git a/types/reactstrap/v4/lib/Tag.d.ts b/types/reactstrap/v4/lib/Tag.d.ts new file mode 100644 index 0000000000..7dce8876f2 --- /dev/null +++ b/types/reactstrap/v4/lib/Tag.d.ts @@ -0,0 +1,12 @@ +import { CSSModule } from '../index'; + +interface Props { + color?: string; + pill?: boolean; + tag?: React.ReactType; + className?: string; + cssModule?: CSSModule; +} + +declare var Tag: React.StatelessComponent; +export default Tag; diff --git a/types/reactstrap/v4/lib/TetherContent.d.ts b/types/reactstrap/v4/lib/TetherContent.d.ts new file mode 100644 index 0000000000..cbc22373e3 --- /dev/null +++ b/types/reactstrap/v4/lib/TetherContent.d.ts @@ -0,0 +1,18 @@ +/// + +import { CSSModule } from '../index'; + +interface Props { + className?: string; + cssModule?: CSSModule; + arrow?: string; + disabled?: boolean; + isOpen: boolean; + toggle: () => void; + tether: Tether.ITetherOptions; + tetherRef?: (tether: Tether) => void; + style?: React.CSSProperties; +} + +declare var TetherContent: React.StatelessComponent; +export default TetherContent; diff --git a/types/reactstrap/v4/lib/Tooltip.d.ts b/types/reactstrap/v4/lib/Tooltip.d.ts new file mode 100644 index 0000000000..9dba615084 --- /dev/null +++ b/types/reactstrap/v4/lib/Tooltip.d.ts @@ -0,0 +1,43 @@ +/// + +import { CSSModule } from '../index'; + +type Placement + = 'top' + | 'bottom' + | 'left' + | 'right' + | 'top left' + | 'top center' + | 'top right' + | 'right top' + | 'right middle' + | 'right bottom' + | 'bottom right' + | 'bottom center' + | 'bottom left' + | 'left top' + | 'left middle' + | 'left bottom'; + +export interface UncontrolledProps { + placement?: Placement; + target: string; + disabled?: boolean; + tether?: Tether.ITetherOptions; + tetherRef?: (tether: Tether) => void; + className?: string; + cssModule?: CSSModule; + autohide?: boolean; + delay?: number | { show: number, hide: number }; +} + +interface Props extends UncontrolledProps { + toggle?: () => void; + isOpen?: boolean; +} + + + +declare var Tooltip: React.StatelessComponent; +export default Tooltip; diff --git a/types/reactstrap/v4/lib/Uncontrolled.d.ts b/types/reactstrap/v4/lib/Uncontrolled.d.ts new file mode 100644 index 0000000000..151ee012d3 --- /dev/null +++ b/types/reactstrap/v4/lib/Uncontrolled.d.ts @@ -0,0 +1,29 @@ +import { + UncontrolledProps as AlertUncontrolledProps +} from './Alert'; +import { + UncontrolledProps as ButtonDropdownUncontrolledProps +} from './ButtonDropdown'; +import { + UncontrolledProps as DropdownUncontrolledProps +} from './Dropdown'; +import { + UncontrolledProps as NavDropdownUncontrolledProps +} from './NavDropdown'; +import { + UncontrolledProps as TooltipUncontrolledProps +} from './Tooltip'; + +declare var UncontrolledAlert: React.StatelessComponent; +declare var UncontrolledButtonDropdown: React.StatelessComponent; +declare var UncontrolledDropdown: React.StatelessComponent; +declare var UncontrolledNavDropdown: React.StatelessComponent; +declare var UncontrolledTooltip: React.StatelessComponent; + +export { + UncontrolledAlert, + UncontrolledButtonDropdown, + UncontrolledDropdown, + UncontrolledNavDropdown, + UncontrolledTooltip +} \ No newline at end of file diff --git a/types/reactstrap/v4/reactstrap-tests.tsx b/types/reactstrap/v4/reactstrap-tests.tsx new file mode 100644 index 0000000000..b094d4d019 --- /dev/null +++ b/types/reactstrap/v4/reactstrap-tests.tsx @@ -0,0 +1,3502 @@ +import * as React from 'react'; +import { + Alert, + UncontrolledAlert, + Badge, + Breadcrumb, + BreadcrumbItem, + Button, + ButtonDropdown, + ButtonGroup, + ButtonToolbar, + Dropdown, + DropdownItem, + DropdownMenu, + DropdownToggle, + Card, + CardBody, + CardBlock, + CardColumns, + CardDeck, + CardFooter, + CardGroup, + CardHeader, + CardImg, + CardImgOverlay, + CardLink, + CardSubtitle, + CardText, + CardTitle, + Row, + Col, + Container, + Collapse, + Fade, + Form, + FormFeedback, + FormGroup, + FormText, + Input, + InputGroup, + InputGroupAddon, + InputGroupButton, + Pagination, + Label, + ListGroup, + ListGroupItem, + ListGroupItemHeading, + ListGroupItemText, + ModalFooter, + Modal, + ModalBody, + ModalHeader, + Jumbotron, + Media, + Nav, + Navbar, + NavbarBrand, + NavbarToggler, + NavDropdown, + NavItem, + NavLink, + PaginationItem, + PaginationLink, + Popover, + PopoverContent, + PopoverTitle, + Progress, + TabPane, + UncontrolledButtonDropdown, + UncontrolledDropdown, + UncontrolledNavDropdown, + UncontrolledTooltip, + TabContent, + Table, + Tag, + TetherContent, + Tooltip +} from 'reactstrap'; + +// --------------- Alert +const Examplea = (props: any) => { + return ( +

    + + Well done! You successfully read this important alert message. + + + Heads up! This alert needs your attention, but it's not super important. + + + Warning! Better check yourself, you're not looking too good. + + + Oh snap! Change a few things up and try submitting again. + +
    + ); +}; + +class AlertExample extends React.Component { + constructor(props: any) { + super(props); + + this.state = { + visible: true + }; + } + + onDismiss = () => { + this.setState({ visible: false }); + } + + render() { + return ( + + I am an alert and I can be dismissed! + + ); + } +} + +function AlertExample1() { + return ( + + I am an alert and I can be dismissed! + + ); +} + +// --------------- Badge +class Example2 extends React.Component { + render() { + return ( +
    +

    Heading New

    +

    Heading New

    +

    Heading New

    +

    Heading New

    +
    Heading New
    +
    Heading New
    +
    + ); + } +} + +export class Example3 extends React.Component { + render() { + return ( +
    + default + primary + success + info + warning + danger +
    + ); + } +} + +class Example4 extends React.Component { + render() { + return ( +
    + default{' '} + primary{' '} + success{' '} + info{' '} + warning{' '} + danger +
    + ); + } +} + +// ------------- Breadcrumbs +const Example5 = (props: any) => { + return ( +
    + + Home + + + Home + Library + + + Home + Library + Data + +
    + ); +}; + +const Example6 = (props: any) => { + return ( +
    + + Home + Library + Data + Bootstrap + +
    + ); +}; + +// ------------- Buttons +class Example7 extends React.Component { + render() { + return ( +
    + {' '} + {' '} + {' '} + {' '} + {' '} + {' '} + +
    + ); + } +} + +class Example8 extends React.Component { + render() { + return ( +
    + {' '} + {' '} + {' '} + {' '} + {' '} + +
    + ); + } +} + +const Example9 = ( +
    + {' '} + +
    +); + +const Example10 = ( +
    + {' '} + +
    +); + +const Example11 = ( +
    + + +
    +); + +const Example12 = ( +
    + {' '} + +
    +); + +const Example13 = ( +
    + {' '} + +
    +); + +class Example14 extends React.Component { + constructor(props: any) { + super(props); + + this.state = { cSelected: [] }; + + this.onRadioBtnClick = this.onRadioBtnClick.bind(this); + this.onCheckboxBtnClick = this.onCheckboxBtnClick.bind(this); + } + + onRadioBtnClick(rSelected: number) { + this.setState({ rSelected }); + } + + onCheckboxBtnClick(selected: number) { + const index = this.state.cSelected.indexOf(selected); + if (index < 0) { + this.state.cSelected.push(selected); + } else { + this.state.cSelected.splice(index, 1); + } + this.setState({ cSelected: [...this.state.cSelected] }); + } + + render() { + return ( +
    +
    Radio Buttons
    + + + + + +

    Selected: {this.state.rSelected}

    + +
    Checkbox Buttons
    + + + + + +

    Selected: {JSON.stringify(this.state.cSelected)}

    +
    + ); + } +} + +// ------------- Button Dropdown +class Example15 extends React.Component { + constructor(props: any) { + super(props); + + this.toggle = this.toggle.bind(this); + this.state = { + dropdownOpen: false + }; + } + + toggle() { + this.setState({ + dropdownOpen: !this.state.dropdownOpen + }); + } + + render() { + return ( + + + Button Dropdown + + + Header + Action + Another Action + + { + // something happens here + }}>Another Action + + + ); + } +} + +const Example16 = ( + true}> + + Text + + + Header + Action + Another Action + + Another Action + + +); + +const Example17 = (props: any) => ( + true}> + + + + Header + Action + Another Action + + Another Action + + +); + +const Example18 = ( +
    + true}> + + Large Button + + + Another Action + Another Action + + + + true}> + + Small Button + + + Another Action + Another Action + + +
    +); + +const Example19 = ( + true} dropup> + + Dropup + + + Another Action + Another Action + + +); + +// --------------- ButtonGroup +class Example20 extends React.Component { + render() { + return ( + + {' '} + {' '} + + + ); + } +} + +class Example21 extends React.Component { + render() { + return ( + + + + + + + + + + + + + + + + + ); + } +} + +const Example22 = (props: any) => ( +
    + + + + + + + + + + + + + + + + + +
    +); + +const Example23 = (props: any) => ( + + + + true}> + + Dropdown + + + Dropdown Link + Dropdown Link + + + +); + +const Example24 = (props: any) => ( + + + + true}> + + Dropdown + + + Dropdown Link + Dropdown Link + + + +); + +// ------------------ Cards +const Example25 = (props: any) => { + return ( +
    + + + + Card title + Card subtitle + Some quick example text to build on the card title and make up the bulk of the card's content. + + + +
    + ); +}; + +const Example26 = (props: any) => { + return ( +
    + + + Card title + Card subtitle + + Card image cap + + Some quick example text to build on the card title and make up the bulk of the card's content. + Card Link + Another Link + + +
    + ); +}; + +const Example27 = (props: any) => { + return ( + + + + Special Title Treatment + With supporting text below as a natural lead-in to additional content. + + + + + + Special Title Treatment + With supporting text below as a natural lead-in to additional content. + + + + + ); +}; + +const Example28 = (props: any) => { + return ( +
    + + Special Title Treatment + With supporting text below as a natural lead-in to additional content. + + + + Special Title Treatment + With supporting text below as a natural lead-in to additional content. + + + + Special Title Treatment + With supporting text below as a natural lead-in to additional content. + + +
    + ); +}; + +const Example29 = (props: any) => { + return ( +
    + + Header + + Special Title Treatment + With supporting text below as a natural lead-in to additional content. + + + Footer + + + + Featured + + Special Title Treatment + With supporting text below as a natural lead-in to additional content. + + + Footer + +
    + ); +}; + +const Example30 = (props: any) => { + return ( +
    + + + + Card Title + This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer. + + Last updated 3 mins ago + + + + + + Card Title + This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer. + + Last updated 3 mins ago + + + + +
    + ); +}; + +const Example31 = (props: any) => { + return ( +
    + + + + Card Title + This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer. + + Last updated 3 mins ago + + + +
    + ); +}; + +const Example32 = (props: any) => { + return ( +
    + + Special Title Treatment + With supporting text below as a natural lead-in to additional content. + + + + Special Title Treatment + With supporting text below as a natural lead-in to additional content. + + + + Special Title Treatment + With supporting text below as a natural lead-in to additional content. + + + + Special Title Treatment + With supporting text below as a natural lead-in to additional content. + + + + Special Title Treatment + With supporting text below as a natural lead-in to additional content. + + + + Special Title Treatment + With supporting text below as a natural lead-in to additional content. + + +
    + ); +}; + +const Example33 = (props: any) => { + return ( +
    + + Special Title Treatment + With supporting text below as a natural lead-in to additional content. + + + + Special Title Treatment + With supporting text below as a natural lead-in to additional content. + + + + Special Title Treatment + With supporting text below as a natural lead-in to additional content. + + + + Special Title Treatment + With supporting text below as a natural lead-in to additional content. + + + + Special Title Treatment + With supporting text below as a natural lead-in to additional content. + + + + Special Title Treatment + With supporting text below as a natural lead-in to additional content. + + +
    + ); +}; + +const Example34 = (props: any) => { + return ( + + + + + Card title + Card subtitle + This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer. + + + + + + + Card title + Card subtitle + This card has supporting text below as a natural lead-in to additional content. + + + + + + + Card title + Card subtitle + + This is a wider card with supporting text below as a natural lead-in to additional content. This + card has even longer content than the first to show that equal height action. + + + + + + ); +}; + +const Example35 = (props: any) => { + return ( + + + + + Card title + Card subtitle + This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer. + + + + + + + Card title + Card subtitle + This card has supporting text below as a natural lead-in to additional content. + + + + + + + Card title + Card subtitle + + This is a wider card with supporting text below as a natural lead-in to additional content. This card has + even longer content than the first to show that equal height action. + + + + + + ); +}; + +const Example36 = (props: any) => { + return ( + + + + + Card title + Card subtitle + This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer. + + + + + + + + + Card title + Card subtitle + This card has supporting text below as a natural lead-in to additional content. + + + + + Special Title Treatment + With supporting text below as a natural lead-in to additional content. + + + + + + Card title + Card subtitle + + This is a wider card with supporting text below as a natural lead-in to additional content. This card + has even longer content than the first to show that equal height action. + + + + + + Special Title Treatment + With supporting text below as a natural lead-in to additional content. + + + + ); +}; + +// ------------------ Collapse + +class Example37 extends React.Component { + constructor(props: any) { + super(props); + this.toggle = this.toggle.bind(this); + this.state = { collapse: false }; + } + + toggle() { + this.setState({ collapse: !this.state.collapse }); + } + + render() { + return ( +
    + + + + + Anim pariatur cliche reprehenderit, + enim eiusmod high life accusamus terry richardson ad squid. Nihil + anim keffiyeh helvetica, craft beer labore wes anderson cred + nesciunt sapiente ea proident. + + + +
    + ); + } +} + +class Example38 extends React.Component { + constructor(props: any) { + super(props); + this.onOpened = this.onOpened.bind(this); + this.onClosed = this.onClosed.bind(this); + this.toggle = this.toggle.bind(this); + this.state = { collapse: false, status: 'Closed' }; + } + + onOpened() { + this.setState({ ...this.state, status: 'Opened' }); + } + + onClosed() { + this.setState({ ...this.state, status: 'Closed' }); + } + + toggle() { + const status = !this.state.collapse ? 'Opening...' : 'Closing...'; + this.setState({ collapse: !this.state.collapse, status }); + } + + render() { + return ( +
    + +
    Current state: {this.state.status}
    + + + + Anim pariatur cliche reprehenderit, + enim eiusmod high life accusamus terry richardson ad squid. Nihil + anim keffiyeh helvetica, craft beer labore wes anderson cred + nesciunt sapiente ea proident. + + + +
    + ); + } +} + +// ------- Dropdown + +class Example39 extends React.Component { + constructor(props: any) { + super(props); + + this.toggle = this.toggle.bind(this); + this.state = { + dropdownOpen: false + }; + } + + toggle() { + this.setState({ + dropdownOpen: !this.state.dropdownOpen + }); + } + + render() { + return ( + + + Dropdown + + + Header + Action + Another Action + + Another Action + + + ); + } +} + +const Example40 = (props: any) => ( + false}> + + Dropdown + + + Header + Action + Another Action + + Another Action + + +); + +const Example41 = (props: any) => ( + Header +); + +const Example42 = (props: any) => ( +
    + + Action + Action + true}> + asdfasd + sadfas + + + true}> + sadfasd + sadf + + + true}> + asdf + sasdfsdf + + +
    +); + +class Example43 extends React.Component { + constructor(props: any) { + super(props); + + this.toggle = this.toggle.bind(this); + this.state = { + dropdownOpen: false + }; + } + + toggle() { + this.setState({ + dropdownOpen: !this.state.dropdownOpen + }); + } + + render() { + return ( + + + Custom Dropdown Content + + +
    Custom dropdown item
    +
    Custom dropdown item
    +
    Custom dropdown item
    +
    Custom dropdown item
    +
    +
    + ); + } +} + +function Example44() { + return ( + + + Dropdown + + + Header + Action + Another Action + + Another Action + + + ); +} + +// ------------------ Form +class Example45 extends React.Component { + render() { + return ( +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This is some placeholder block-level help text for the above input. + It's a bit lighter and easily wraps to a new line. + + + + Radio Buttons + + + + + + + + + + + + + + +
    + ); + } +} + +class Example46 extends React.Component { + render() { + return ( +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This is some placeholder block-level help text for the above input. + It's a bit lighter and easily wraps to a new line. + + + + + Radio Buttons + + + + + + + + + + + + + + + + + + + + + + + + + +
    + ); + } +} + +class Example47 extends React.Component { + render() { + return ( +
    + + {' '} + + + {' '} + + {' '} + + + {' '} + +
    + ); + } +} + +class Example48 extends React.Component { + render() { + return ( +
    + + + + Success! You did it! + Example help text that remains unchanged. + + + + + Whoops, check your formatting and try again. + Example help text that remains unchanged. + + + + + Oh noes! that name is already taken + Example help text that remains unchanged. + +
    + ); + } +} + +class Example49 extends React.Component { + render() { + return ( +
    + + + Some static value + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This is some placeholder block-level help text for the above input. + It's a bit lighter and easily wraps to a new line. + + + + + + + + +
    + ); + } +} + +class Example50 extends React.Component { + render() { + return ( +
    + + + + + + + + + + + + +
    + ); + } +} + +class Example51 extends React.Component { + render() { + return ( +
    + + + + + {' '} + + + + + {' '} + +
    + ); + } +} + +const Example52 = (props: any) => { + return ( +
    + + @ + + +
    + + + + + + +
    + + + @example.com + +
    + + $ + $ + + $ + $ + +
    + + $ + + .00 + +
    + ); +}; + +const Example53 = (props: any) => { + return ( +
    + + To the Left! + + +
    + + + To the Right! + +
    + + To the Left! + + To the Right! + +
    + ); +}; + +const Example54 = (props: any) => { + return ( +
    + + @lg + + +
    + + @normal + + +
    + + @sm + + +
    + ); +}; + +const Example55 = (props: any) => { + return ( +
    + + + + +
    + + + + +
    + + + + + +
    + ); +}; + +const Example56 = (props: any) => { + return ( +
    + + @lg + + +
    + + @normal + + +
    + + @sm + + +
    + ); +}; + +const Example57 = (props: any) => { + return ( +
    + + + + +
    + + + + +
    + + + + + +
    + ); +}; + +const Example58 = (props: any) => { + return ( +
    + + To the Left! + + +
    + + + To the Right! + +
    + + To the Left! + + To the Right! + +
    + ); +}; + +const Example59 = (props: any) => { + return ( +
    + +

    Hello, world!

    +

    This is a simple hero unit, a simple Jumbotron-style component for calling extra attention to featured content or information.

    +
    +

    It uses utility classes for typgraphy and spacing to space content out within the larger container.

    +

    + +

    +
    +
    + ); +}; + +const Example60 = (props: any) => { + return ( +
    + + +

    Fluid jumbotron

    +

    This is a modified jumbotron that occupies the entire horizontal space of its parent.

    +
    +
    +
    + ); +}; + +class Example61 extends React.Component { + render() { + return ( + + + .col + + + .col + .col + .col + .col + + + .col-3 + .col-auto - variable width content + .col-3 + + + .col-6 + .col-6 + + + .col-6 .col-sm-4 + .col-6 .col-sm-4 + .col .col-sm-4 + + + .col .col-sm-6 .col-sm-push-2 .col-sm-pull-2 .col-sm-offset-2 + + + .col .col-sm-12 .col-md-6 .col-md-offset-3 + + + .col .col-sm .col-sm-offset-1 + .col .col-sm .col-sm-offset-1 + + + ); + } +} + +class Example62 extends React.Component { + render() { + return ( + + Cras justo odio + Dapibus ac facilisis in + Morbi leo risus + Porta ac consectetur ac + Vestibulum at eros + + ); + } +} + +class Example63 extends React.Component { + render() { + return ( + + Cras justo odio 14 + Dapibus ac facilisis in 2 + Morbi leo risus 1 + + ); + } +} + +class Example64 extends React.Component { + render() { + return ( + + Cras justo odio + Dapibus ac facilisis in + Morbi leo risus + Porta ac consectetur ac + Vestibulum at eros + + ); + } +} + +class Example65 extends React.Component { + render() { + return ( +
    +

    Anchors

    +

    Be sure to not use the standard .btn classes here.

    + + Cras justo odio + Dapibus ac facilisis in + Morbi leo risus + Porta ac consectetur ac + Vestibulum at eros + +

    +

    Buttons

    + + Cras justo odio + Dapibus ac facilisis in + Morbi leo risus + Porta ac consectetur ac + Vestibulum at eros + +
    + ); + } +} + +class Example66 extends React.Component { + render() { + return ( + + Cras justo odio + Dapibus ac facilisis in + Morbi leo risus + Porta ac consectetur ac + + ); + } +} + +class Example67 extends React.Component { + render() { + return ( + + + List group item heading + + Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit. + + + + List group item heading + + Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit. + + + + List group item heading + + Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit. + + + + ); + } +} + +// ------------- Media +const Example68 = () => { + return ( + + + + + + + Media heading + + Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus + odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. + Donec lacinia congue felis in faucibus. + + + ); +}; + +const Example69 = () => { + return ( + + + + + + + Media heading + + Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus + odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate fringilla. + Donec lacinia congue felis in faucibus. + + + + + + + Nested media heading + + Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras + purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate + fringilla. Donec lacinia congue felis in faucibus. + + + + + ); +}; + +const Example70 = () => { + return ( +
    + + + + + + + Top aligned media + + Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras + purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate + fringilla. Donec lacinia congue felis in faucibus. + + + + + + + + + Middle aligned media + + Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras + purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate + fringilla. Donec lacinia congue felis in faucibus. + + + + + + + + + Bottom aligned media + + Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras + purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate + fringilla. Donec lacinia congue felis in faucibus. + + +
    + ); +}; + +const Example71 = () => { + return ( + + + + + + + + Media heading + + Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras + purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate + fringilla. Donec lacinia congue felis in faucibus. + + + + + + + Nested media heading + + Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. + Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi + vulputate fringilla. Donec lacinia congue felis in faucibus. + + + + + + + Nested media heading + + Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. + Cras purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi + vulputate fringilla. Donec lacinia congue felis in faucibus. + + + + + + + + + + + Nested media heading + + Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras + purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate + fringilla. Donec lacinia congue felis in faucibus. + + + + + + + + Media heading + + Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras + purus odio, vestibulum in vulputate at, tempus viverra turpis. Fusce condimentum nunc ac nisi vulputate + fringilla. Donec lacinia congue felis in faucibus. + + + + + + + ); +}; + +// --------------- Modal +class ModalExample72 extends React.Component { + constructor(props: any) { + super(props); + this.state = { + modal: false + }; + + this.toggle = this.toggle.bind(this); + } + + toggle() { + this.setState({ + modal: !this.state.modal + }); + } + + render() { + return ( +
    + + + Modal title + + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et + dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex + ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat + nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit + anim id est laborum. + + + {' '} + + + +
    + ); + } +} + +class ModalExample73 extends React.Component { + constructor(props: any) { + super(props); + this.state = { + modal: false, + backdrop: true + }; + + this.toggle = this.toggle.bind(this); + this.changeBackdrop = this.changeBackdrop.bind(this); + } + + toggle() { + this.setState({ + modal: !this.state.modal + }); + } + + changeBackdrop(e: React.ChangeEvent) { + let value = e.target.value; + if (value !== 'static') { + value = JSON.parse(value); + } + this.setState({ backdrop: value }); + } + + render() { + return ( +
    +
    e.preventDefault()}> + + {' '} + + + + + + + {' '} + +
    + + Modal title + + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et + dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip + ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu + fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt + mollit anim id est laborum. + + + {' '} + + + +
    + ); + } +} + +class ModalExample74 extends React.Component { + constructor(props: any) { + super(props); + this.state = { + modal: false, + nestedModal: false, + }; + + this.toggle = this.toggle.bind(this); + this.toggleNested = this.toggleNested.bind(this); + } + + toggle() { + this.setState({ + modal: !this.state.modal + }); + } + + toggleNested() { + this.setState({ + nestedModal: !this.state.nestedModal + }); + } + + render() { + return ( +
    + + + Modal title + + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et + dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex + ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu + fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt + mollit anim id est laborum. +
    + + + Nested Modal title + Stuff and things + + {' '} + + + +
    + + {' '} + + +
    +
    + ); + } +} + +class Example75 extends React.Component { + constructor(props: any) { + super(props); + + this.toggle = this.toggle.bind(this); + this.state = { + isOpen: false + }; + } + toggle() { + this.setState({ + isOpen: !this.state.isOpen + }); + } + render() { + return ( +
    + + + reactstrap + + + + +
    + ); + } +} + +class Example76 extends React.Component { + constructor(props: any) { + super(props); + + this.toggleNavbar = this.toggleNavbar.bind(this); + this.state = { + collapsed: true + }; + } + + toggleNavbar() { + this.setState({ + collapsed: !this.state.collapsed + }); + } + render() { + return ( +
    + + + + reactstrap + + + +
    + ); + } +} + +class Example77 extends React.Component { + render() { + return ( +
    +

    List Based

    + +
    +

    Link Based

    + +
    + ); + } +} + +class Example78 extends React.Component { + render() { + return ( +
    +

    List Based

    + +
    +

    Link based

    + +
    + ); + } +} + +class Example79 extends React.Component { + constructor(props: any) { + super(props); + + this.toggle = this.toggle.bind(this); + this.state = { + dropdownOpen: false + }; + } + + toggle() { + this.setState({ + dropdownOpen: !this.state.dropdownOpen + }); + } + + render() { + return ( +
    + +
    + ); + } +} + +class Example80 extends React.Component { + constructor(props: any) { + super(props); + + this.toggle = this.toggle.bind(this); + this.state = { + dropdownOpen: false + }; + } + + toggle() { + this.setState({ + dropdownOpen: !this.state.dropdownOpen + }); + } + + render() { + return ( +
    + +
    + ); + } +} + +// ----------- Pagination +class Example81 extends React.Component { + render() { + return ( + + + + + + + 1 + + + + + 2 + + + + + 3 + + + + + 4 + + + + + 5 + + + + + + + ); + } +} + +class Example82 extends React.Component { + render() { + return ( + + + + + + + 1 + + + + + 2 + + + + + 3 + + + + + 4 + + + + + 5 + + + + + + + ); + } +} + +class Example83 extends React.Component { + render() { + return ( + + + + + + + 1 + + + + + 2 + + + + + 3 + + + + + + + ); + } +} + +class Example84 extends React.Component { + render() { + return ( + + + + + + + 1 + + + + + 2 + + + + + 3 + + + + + + + ); + } +} + +// ------------------------- Popover +class Example85 extends React.Component { + constructor(props: any) { + super(props); + + this.toggle = this.toggle.bind(this); + this.state = { + popoverOpen: false + }; + } + + toggle() { + this.setState({ + popoverOpen: !this.state.popoverOpen + }); + } + + render() { + return ( +
    + + + Popover Title + Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. + +
    + ); + } +} + +class PopoverItem extends React.Component { + constructor(props: any) { + super(props); + + this.toggle = this.toggle.bind(this); + this.state = { + popoverOpen: false + }; + } + + toggle() { + this.setState({ + popoverOpen: !this.state.popoverOpen + }); + } + + render() { + return ( + + + + Popover Title + Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. + + + ); + } +} + +class PopoverExampleMulti extends React.Component}> { + constructor(props: any) { + super(props); + + this.state = { + popovers: [ + { + placement: 'top', + text: 'Top' + }, + { + placement: 'bottom', + text: 'Bottom' + }, + { + placement: 'left', + text: 'Left' + }, + { + placement: 'right', + text: 'Right' + } + ] + }; + } + + render() { + return ( +
    + {this.state.popovers.map((popover, i) => { + return ; + })} +
    + ); + } +} + +// ------------------------- Progress + +const Example86 = (props: any) => { + return ( +
    +
    0%
    + +
    25%
    + +
    50%
    + +
    75%
    + +
    100%
    + +
    Multiple bars
    + + + + + + + +
    + ); +}; + +const Example87 = (props: any) => { + return ( +
    + + + + + +
    + ); +}; + +const Example88 = (props: any) => { + return ( +
    + 25% + 1/2 + You're almost there! + You did it! + + Meh + Wow! + Cool + 20% + !! + +
    + ); +}; + +const Example89 = (props: any) => { + return ( +
    + + + + + + + + + + + +
    + ); +}; + +const Example90 = (props: any) => { + return ( +
    + + + + + + + + + + + +
    + ); +}; + +const Example91 = (props: any) => { + return ( +
    +
    Plain
    + + + + + + + +
    With Labels
    + + Meh + Wow! + 25% + LOOK OUT!! + +
    Stripes and Animations
    + + Stripes + Animated Stripes + Plain + +
    + ); +}; + +const Example92 = (props: any) => { + return ( +
    +
    1 of 5
    + +
    50 of 135
    + +
    75 of 111
    + +
    463 of 500
    + + +
    Various (40) of 55
    + + 5 + 15 + 10 + 10 + +
    + ); +}; + +// --------------- Table +class Example93 extends React.Component { + render() { + return ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    #First NameLast NameUsername
    1MarkOtto@mdo
    2JacobThornton@fat
    3Larrythe Bird@twitter
    + ); + } +} + +class Example94 extends React.Component { + render() { + return ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    #First NameLast NameUsername
    1MarkOtto@mdo
    2JacobThornton@fat
    3Larrythe Bird@twitter
    + ); + } +} + +class Example95 extends React.Component { + render() { + return ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    #First NameLast NameUsername
    1MarkOtto@mdo
    2JacobThornton@fat
    3Larrythe Bird@twitter
    + ); + } +} + +class Example96 extends React.Component { + render() { + return ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    #First NameLast NameUsername
    1MarkOtto@mdo
    2JacobThornton@fat
    3Larrythe Bird@twitter
    + ); + } +} + +class Example97 extends React.Component { + render() { + return ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    #First NameLast NameUsername
    1MarkOtto@mdo
    2JacobThornton@fat
    3Larrythe Bird@twitter
    + ); + } +} + +class Example98 extends React.Component { + render() { + return ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    #First NameLast NameUsername
    1MarkOtto@mdo
    2JacobThornton@fat
    3Larrythe Bird@twitter
    + ); + } +} + +class Example99 extends React.Component { + render() { + return ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    #Table headingTable headingTable headingTable headingTable headingTable heading
    1Table cellTable cellTable cellTable cellTable cellTable cell
    2Table cellTable cellTable cellTable cellTable cellTable cell
    3Table cellTable cellTable cellTable cellTable cellTable cell
    + ); + } +} + +class Example100 extends React.Component { + render() { + return ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    #Table headingTable headingTable headingTable headingTable headingTable heading
    1Table cellTable cellTable cellTable cellTable cellTable cell
    2Table cellTable cellTable cellTable cellTable cellTable cell
    3Table cellTable cellTable cellTable cellTable cellTable cell
    + ); + } +} + +class Example101 extends React.Component { + constructor(props: any) { + super(props); + + this.toggle = this.toggle.bind(this); + this.state = { + activeTab: '1' + }; + } + + toggle(tab: string) { + if (this.state.activeTab !== tab) { + this.setState({ + activeTab: tab + }); + } + } + render() { + return ( +
    + + + + + +

    Tab 1 Contents

    + +
    +
    + + + + + Special Title Treatment + With supporting text below as a natural lead-in to additional content. + + + + + + Special Title Treatment + With supporting text below as a natural lead-in to additional content. + + + + + +
    +
    + ); + } +} + +class Example102 extends React.Component { + constructor(props: any) { + super(props); + + this.toggle = this.toggle.bind(this); + this.state = { + tooltipOpen: false + }; + } + + toggle() { + this.setState({ + tooltipOpen: !this.state.tooltipOpen + }); + } + + render() { + return ( +
    +

    Somewhere in here is a tooltip.

    + + Hello world! + +
    + ); + } +} + +class Example103 extends React.Component { + constructor(props: any) { + super(props); + + this.toggle = this.toggle.bind(this); + this.state = { + tooltipOpen: false + }; + } + + toggle() { + this.setState({ + tooltipOpen: !this.state.tooltipOpen + }); + } + + render() { + return ( +
    +

    Sometimes you need to allow users to select text within a tooltip.

    + + Try to select this text! + +
    + ); + } +} + +class TooltipItem extends React.Component { + constructor(props: any) { + super(props); + + this.toggle = this.toggle.bind(this); + this.state = { + tooltipOpen: false + }; + } + + toggle() { + this.setState({ + tooltipOpen: !this.state.tooltipOpen + }); + } + + render() { + return ( + + + + Tooltip Content! + + + ); + } +} + +class TooltipExampleMulti extends React.Component { + constructor(props: any) { + super(props); + + this.state = { + tooltips: [ + { + placement: 'top', + text: 'Top' + }, + { + placement: 'bottom', + text: 'Bottom' + }, + { + placement: 'left', + text: 'Left' + }, + { + placement: 'right', + text: 'Right' + } + ] + }; + } + + render() { + return ( +
    + {this.state.tooltips.map((tooltip: {placement: string; text: string; }, i: number) => { + return ; + })} +
    + ); + } +} + +function Example() { + return ( +
    +

    Somewhere in here is a tooltip.

    + + Hello world! + +
    + ); +} + +function Example104() { + const props = { + className: 'my-input', + style: { + borderColor: 'black', + } + }; + + return ( + + + + + + + + ); +} + +function Example105() { + return ( + + + + +
    + Item +
    +
    +
    + ); +} + +function Example106() { + return ( + + ); +} + +const CSSModuleExample = (props: any) => { + const cssModule = { + btn: 'hash' + }; + + return ( + + ); +}; + +class Example107 extends React.Component { + private input: HTMLInputElement; + + render() { + return { this.input = input; }} />; + } +} + +class Example108 extends React.Component { + constructor(props: any) { + super(props); + + this.toggle = this.toggle.bind(this); + this.state = { + isOpen: false + }; + } + toggle() { + this.setState({ + isOpen: !this.state.isOpen + }); + } + render() { + return ( +
    + + + reactstrap + + + + +
    + ); + } +} + +class Example109 extends React.Component { + constructor(props: any) { + super(props); + + this.toggle = this.toggle.bind(this); + this.state = { + isOpen: false + }; + } + toggle() { + this.setState({ + isOpen: !this.state.isOpen + }); + } + render() { + return ( +
    + + + reactstrap + + + + +
    + ); + } +} + +class Example110 extends React.Component { + constructor(props: any) { + super(props); + + this.toggle = this.toggle.bind(this); + this.state = { + isOpen: false + }; + } + toggle() { + this.setState({ + isOpen: !this.state.isOpen + }); + } + render() { + return ( +
    + + + reactstrap + + + + +
    + ); + } +} + +class Example111 extends React.Component { + constructor(props: any) { + super(props); + + this.toggle = this.toggle.bind(this); + this.state = { + isOpen: false + }; + } + toggle() { + this.setState({ + isOpen: !this.state.isOpen + }); + } + render() { + return ( +
    + + + reactstrap + + + + +
    + ); + } +} + +class Example112 extends React.Component { + constructor(props: any) { + super(props); + + this.toggle = this.toggle.bind(this); + this.state = { + isOpen: false + }; + } + toggle() { + this.setState({ + isOpen: !this.state.isOpen + }); + } + render() { + return ( +
    + + + reactstrap + + + + +
    + ); + } +} + +const Example113 = (props: any) => { + return ( +
    + + + Anim pariatur cliche reprehenderit, + enim eiusmod high life accusamus terry richardson ad squid. Nihil + anim keffiyeh helvetica, craft beer labore wes anderson cred + nesciunt sapiente ea proident. + + +
    + ); + }; diff --git a/types/reactstrap/v4/tsconfig.json b/types/reactstrap/v4/tsconfig.json new file mode 100644 index 0000000000..73578a9178 --- /dev/null +++ b/types/reactstrap/v4/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "jsx": "react", + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "paths": { + "reactstrap": ["reactstrap/v4"] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "reactstrap-tests.tsx" + ] +} \ No newline at end of file diff --git a/types/reactstrap/v4/tslint.json b/types/reactstrap/v4/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/reactstrap/v4/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 1417a41506f312c6904ac95f3ee320ed65e917a3 Mon Sep 17 00:00:00 2001 From: cwmoo740 Date: Fri, 27 Oct 2017 20:43:19 -0400 Subject: [PATCH 081/352] react-autosuggest: expand themekey to allow any string keys --- types/react-autosuggest/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-autosuggest/index.d.ts b/types/react-autosuggest/index.d.ts index 2d0034fd46..b1f080efe5 100644 --- a/types/react-autosuggest/index.d.ts +++ b/types/react-autosuggest/index.d.ts @@ -62,7 +62,7 @@ declare namespace Autosuggest { 'suggestionsContainerOpen' | 'suggestionsList' | 'suggestion' | 'suggestionFirst' | 'suggestionHighlighted' | 'sectionContainer' | 'sectionContainerFirst' | 'sectionTitle'; - type Theme = Partial>; + type Theme = Record | Partial>; interface AutosuggestProps extends React.Props { suggestions: any[]; From 9f478ae4cc1ec875a3fadca87882fd25babb0540 Mon Sep 17 00:00:00 2001 From: jessezhang91 Date: Fri, 27 Oct 2017 23:40:56 -0400 Subject: [PATCH 082/352] [mock-knex] add types for mock-knex --- types/mock-knex/index.d.ts | 79 ++++++++++++++++++++++++++++++ types/mock-knex/mock-knex-tests.ts | 29 +++++++++++ types/mock-knex/tsconfig.json | 23 +++++++++ types/mock-knex/tslint.json | 1 + 4 files changed, 132 insertions(+) create mode 100644 types/mock-knex/index.d.ts create mode 100644 types/mock-knex/mock-knex-tests.ts create mode 100644 types/mock-knex/tsconfig.json create mode 100644 types/mock-knex/tslint.json diff --git a/types/mock-knex/index.d.ts b/types/mock-knex/index.d.ts new file mode 100644 index 0000000000..5633000ab9 --- /dev/null +++ b/types/mock-knex/index.d.ts @@ -0,0 +1,79 @@ +// Type definitions for mock-knex 0.3 +// Project: https://github.com/colonyamerican/mock-knex +// Definitions by: Jesse Zhang +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +/// + +import * as Knex from "knex"; +import { EventEmitter } from "events"; + +/** + * Attaches mocked client to knex instance + * + * @param knex initialized knex client + */ +export function mock(knex: Knex): void; + +/** + * Detaches mocked client from knex instance + * + * @param knex initialized knex client + */ +export function unmock(knex: Knex): void; + +/** + * Returns query Tracker instance + */ +export function getTracker(): Tracker; + +/** + * The tracker enables you to catch and respond to queries that occur during testing, see Test for more examples. + */ +export interface Tracker extends EventEmitter { + /** + * Enables query tracking mock on mocked knex client + */ + install(): void; + + /** + * Disables query tracking mock on mocked knex client. Also resets 'step' counter. + */ + uninstall(): void; + + /** + * Add event listener for 'query' event. It gets esecuted for each query that should end up in database. + * Instead of this callback gets executed and its up to you to assert queries and mock database responses. + * + * @param callback A function that gets executed on 'query' event. + */ + on(event: 'query', callback: (query: QueryDetails, step: number) => void): this; +} + +/** + * The object containing query details that is being sent to knex database dialect on query execution. + * Object properties signature matches with knex toSQL() output with additional method returns(values). + */ +export interface QueryDetails extends Knex.Sql { + /** + * Function that needs to be called to mock database query result for knex. + * + * @param error The Error, string or instance of Error, which represents why the result was rejected + */ + reject(error: Error | string): void; + + /** + * Function that needs to be called to mock database query result for knex. + * + * @param values An array of mock data to be returned by database. For Bookshelf this is mostly array of objects. Knex could return any type of data. + */ + response(values: any[], options?: QueryDetailsResponseOption): void; +} + +export interface QueryDetailsResponseOption { + /** + * Is this a stream response, defaults to false + */ + stream: boolean; +} diff --git a/types/mock-knex/mock-knex-tests.ts b/types/mock-knex/mock-knex-tests.ts new file mode 100644 index 0000000000..ec4ef0024e --- /dev/null +++ b/types/mock-knex/mock-knex-tests.ts @@ -0,0 +1,29 @@ +import * as knex from "knex"; +import * as mockDb from "mock-knex"; + +const db = knex({ + client: 'sqlite' +}); + +mockDb.mock(db); + +const tracker = mockDb.getTracker(); +tracker.install(); +tracker.on('query', (query, step) => { + if (query.method === "first" || step === 1) { + query.response([{ + a: 1 + }, { + a: 2 + }, { + a: 3 + }], { + stream: false + }); + } else { + query.reject(new Error("bad query")); + } +}); +tracker.uninstall(); + +mockDb.unmock(db); diff --git a/types/mock-knex/tsconfig.json b/types/mock-knex/tsconfig.json new file mode 100644 index 0000000000..427ad9f843 --- /dev/null +++ b/types/mock-knex/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", + "mock-knex-tests.ts" + ] +} diff --git a/types/mock-knex/tslint.json b/types/mock-knex/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/mock-knex/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From b58290d346b44d0e1b0199a3aa9d4b96b63af328 Mon Sep 17 00:00:00 2001 From: Ondrej Sevcik Date: Sat, 28 Oct 2017 09:40:55 +0200 Subject: [PATCH 083/352] Remove myself from maintainer list I don't have time to maintain it anymore and also I haven't used CKEditor typings for more than 2y now. --- types/ckeditor/index.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/types/ckeditor/index.d.ts b/types/ckeditor/index.d.ts index c61dd9c467..150bc7e7a6 100644 --- a/types/ckeditor/index.d.ts +++ b/types/ckeditor/index.d.ts @@ -1,7 +1,6 @@ // Type definitions for CKEditor // Project: http://ckeditor.com/ -// Definitions by: Ondrej Sevcik -// Thomas Wittwer +// Definitions by: Thomas Wittwer // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // WORK-IN-PROGRESS: Any contribution support welcomed. From 8f9739685b4dc06c2b1c85bd8148d2299fead924 Mon Sep 17 00:00:00 2001 From: Edward Sammut Alessi Date: Sat, 28 Oct 2017 20:35:52 +0200 Subject: [PATCH 084/352] Move types only used once inline --- types/args/index.d.ts | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/types/args/index.d.ts b/types/args/index.d.ts index 2ef8b1eb88..70b784564d 100644 --- a/types/args/index.d.ts +++ b/types/args/index.d.ts @@ -11,19 +11,14 @@ interface args { option(name: string | [string, string], description: string, defaultValue?: any, init?: OptionInitFunction): args; options(list: Option[]): args; - command(name: string, description: string, init?: CommandInitFunction, aliases?: string[]): args; + command(name: string, description: string, init?: (name: string, sub: string[], options: ConfigurationOptions) => void, aliases?: string[]): args; example(usage: string, description: string): args; examples(list: Example[]): args; parse(argv: string[], options?: ConfigurationOptions): { [key: string]: any }; showHelp(): void; } -type MriUnknownFunction = (param: string) => boolean; -type MinimistUnknownFunction = (param: string) => boolean; - type OptionInitFunction = (value: any) => any; -type CommandInitFunction = (name: string, sub: string[], options: ConfigurationOptions) => void; -type UsageFilterFunction = (output: any) => any; interface MriOptions { args?: string[]; @@ -35,7 +30,7 @@ interface MriOptions { [key: string]: any }; string?: string | string[]; - unknown?: MriUnknownFunction; + unknown?: (param: string) => boolean; } interface MinimistOptions { @@ -49,14 +44,14 @@ interface MinimistOptions { }; stopEarly?: boolean; "--"?: boolean; - unknown?: MinimistUnknownFunction; + unknown?: (param: string) => boolean; } interface ConfigurationOptions { help?: boolean; name?: string; version?: boolean; - usageFilter?: UsageFilterFunction; + usageFilter?: (output: any) => any; value?: string; mri: MriOptions; minimist?: MinimistOptions; @@ -65,7 +60,7 @@ interface ConfigurationOptions { } interface Option { - name: [string, string]; + name: string | [string, string]; description: string; init?: OptionInitFunction; defaultValue?: any; From da80f707e2058ed18305461c61bdea1e30860e11 Mon Sep 17 00:00:00 2001 From: Samson Keung Date: Sat, 28 Oct 2017 14:17:43 -0700 Subject: [PATCH 085/352] add typing for endsWith --- types/ramda/index.d.ts | 8 ++++++++ types/ramda/ramda-tests.ts | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/types/ramda/index.d.ts b/types/ramda/index.d.ts index f0c95c7a8c..a2a3b426d4 100644 --- a/types/ramda/index.d.ts +++ b/types/ramda/index.d.ts @@ -553,6 +553,14 @@ declare namespace R { */ empty(x: T): T; + /** + * Checks if a list ends with the provided values + */ + endsWith(a: string, list: string): boolean; + endsWith(a: string): (list: string) => boolean; + endsWith(a: T | T[], list: T[]): boolean; + endsWith(a: T | T[]): (list: T[]) => boolean; + /** * Takes a function and two values in its domain and returns true if the values map to the same value in the * codomain; false otherwise. diff --git a/types/ramda/ramda-tests.ts b/types/ramda/ramda-tests.ts index 2ce8bae2ca..699792feec 100644 --- a/types/ramda/ramda-tests.ts +++ b/types/ramda/ramda-tests.ts @@ -2241,6 +2241,15 @@ class Rectangle { R.isEmpty({a: 1}); // => false }; +() => { + R.endsWith("c", "abc"); // => true + R.endsWith("c")("abc"); // => true + R.endsWith(3, [1, 2, 3]); // => true + R.endsWith(3)([1, 2, 3]); // => true + R.endsWith([3], [1, 2, 3]); // => true + R.endsWith([3])([1, 2, 3]); // => true +}; + () => { R.not(true); // => false R.not(false); // => true From b0d60e347dc336fc6ed0f095fdfa0b5577cb78fb Mon Sep 17 00:00:00 2001 From: Samson Keung Date: Sat, 28 Oct 2017 14:22:59 -0700 Subject: [PATCH 086/352] up version --- types/ramda/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/ramda/index.d.ts b/types/ramda/index.d.ts index a2a3b426d4..8187eb59f2 100644 --- a/types/ramda/index.d.ts +++ b/types/ramda/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for ramda 0.24 +// Type definitions for ramda 0.25 // Project: https://github.com/donnut/typescript-ramda // Definitions by: Erwin Poeze // Matt DeKrey From ba33e49fa7c46ede875a031965855da569b2339c Mon Sep 17 00:00:00 2001 From: Liam Goodacre Date: Sun, 1 Oct 2017 11:36:00 +0100 Subject: [PATCH 087/352] Remove myself from ramda contributors --- types/ramda/index.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/ramda/index.d.ts b/types/ramda/index.d.ts index f0c95c7a8c..b65b21eaa2 100644 --- a/types/ramda/index.d.ts +++ b/types/ramda/index.d.ts @@ -2,7 +2,6 @@ // Project: https://github.com/donnut/typescript-ramda // Definitions by: Erwin Poeze // Matt DeKrey -// Liam Goodacre // Matt Dziuban // Stephen King // Alejandro Fernandez Haro From bc39d3d32046c106fcf866e1766045c7632939ff Mon Sep 17 00:00:00 2001 From: Winslow Dalpe Date: Sat, 28 Oct 2017 15:51:36 -0700 Subject: [PATCH 088/352] Adding typings for moment-holiday PR upstream to add typings in the library has been open for a while without feedback. Adding the typings here until that PR changes state. --- types/moment-holiday/index.d.ts | 71 +++++++++++ types/moment-holiday/moment-holiday-tests.ts | 126 +++++++++++++++++++ types/moment-holiday/package.json | 6 + types/moment-holiday/tsconfig.json | 23 ++++ types/moment-holiday/tslint.json | 1 + 5 files changed, 227 insertions(+) create mode 100644 types/moment-holiday/index.d.ts create mode 100644 types/moment-holiday/moment-holiday-tests.ts create mode 100644 types/moment-holiday/package.json create mode 100644 types/moment-holiday/tsconfig.json create mode 100644 types/moment-holiday/tslint.json diff --git a/types/moment-holiday/index.d.ts b/types/moment-holiday/index.d.ts new file mode 100644 index 0000000000..fffe81ed73 --- /dev/null +++ b/types/moment-holiday/index.d.ts @@ -0,0 +1,71 @@ +// Type definitions for moment-holiday 1.5 +// Project: https://github.com/kodie/moment-holiday +// Definitions by: Robert Winslow Dalpe +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import * as moment from 'moment'; + +declare module 'moment' { + interface Moment extends Object { + holiday( + holidays?: string[] | string, + adjust?: boolean): Moment | false | { [holidayName: string]: Moment }; + + holidays( + holidays?: string[] | string, + adjust?: boolean): Moment | false | { [holidayName: string]: Moment }; + + isHoliday( + holidays?: string[] | string | null, + adjust?: boolean): boolean | string | string[]; + + previousHoliday(count?: number, adjust?: boolean): Moment[] | Moment; + + previousHolidays(count?: number, adjust?: boolean): Moment[] | Moment; + + nextHoliday(count?: number, adjust?: boolean): Moment[] | Moment; + + nextHolidays(count?: number, adjust?: boolean): Moment[] | Moment; + + holidaysBetween(m: Moment, adjust?: boolean): Moment[] | false; + } + + interface HolidayDefinition { + date: string; + keywords?: string[]; + keywords_y?: string[]; + keywords_n?: string[]; + regions?: string[]; + regions_n?: string[]; + } + + interface HolidaysMapping { + [holidayName: string]: HolidayDefinition; + } + + interface Holidays { + active: HolidaysMapping; + active_last: HolidaysMapping; + } + + interface HolidayModifier { + set( + holidays: HolidaysMapping | string | string[], + specifics?: any): HolidayModifier; + + add( + holidays: HolidaysMapping | string, + specifics?: any): HolidayModifier; + + remove(holidays: string | string[]): HolidayModifier; + + undo(): HolidayModifier; + + load(locales: string | string[]): HolidayModifier; + + extendParser(parserFunc: (m: Moment, date: string) => Moment | Moment[] | false | void): HolidayModifier; + } + + let holidays: Holidays; + let modifyHolidays: HolidayModifier; +} diff --git a/types/moment-holiday/moment-holiday-tests.ts b/types/moment-holiday/moment-holiday-tests.ts new file mode 100644 index 0000000000..d6d0941f38 --- /dev/null +++ b/types/moment-holiday/moment-holiday-tests.ts @@ -0,0 +1,126 @@ +import * as moment from 'moment'; + +let holidayResult: moment.Moment | false | { [holidayName: string]: moment.Moment }; +holidayResult = moment().holiday([]); +holidayResult = moment().holiday([], false); +holidayResult = moment().holiday([], true); +holidayResult = moment().holiday('string'); +holidayResult = moment().holiday('string', false); +holidayResult = moment().holiday('string', true); +holidayResult = moment().holiday(['array', 'of', 'strings']); +holidayResult = moment().holiday(['array', 'of', 'strings'], false); +holidayResult = moment().holiday(['array', 'of', 'strings'], true); + +holidayResult = moment().holidays([]); +holidayResult = moment().holidays([], false); +holidayResult = moment().holidays([], true); +holidayResult = moment().holidays('string'); +holidayResult = moment().holidays('string', false); +holidayResult = moment().holidays('string', true); +holidayResult = moment().holidays(['array', 'of', 'strings']); +holidayResult = moment().holidays(['array', 'of', 'strings'], false); +holidayResult = moment().holidays(['array', 'of', 'strings'], true); + +let isHolidayResult: boolean | string | string[]; +isHolidayResult = moment().isHoliday(); +isHolidayResult = moment().isHoliday([]); +isHolidayResult = moment().isHoliday([], false); +isHolidayResult = moment().isHoliday([], true); +isHolidayResult = moment().isHoliday(['array', 'of', 'strings']); +isHolidayResult = moment().isHoliday(['array', 'of', 'strings'], false); +isHolidayResult = moment().isHoliday(['array', 'of', 'strings'], true); +isHolidayResult = moment().isHoliday('string'); +isHolidayResult = moment().isHoliday('string', false); +isHolidayResult = moment().isHoliday('string', true); +isHolidayResult = moment().isHoliday(null); +isHolidayResult = moment().isHoliday(null, false); +isHolidayResult = moment().isHoliday(null, true); + +let previousHolidayResult: moment.Moment[] | moment.Moment; +previousHolidayResult = moment().previousHoliday(); +previousHolidayResult = moment().previousHoliday(1); +previousHolidayResult = moment().previousHoliday(1, false); +previousHolidayResult = moment().previousHoliday(1, true); +previousHolidayResult = moment().previousHolidays(); +previousHolidayResult = moment().previousHolidays(1); +previousHolidayResult = moment().previousHolidays(1, false); +previousHolidayResult = moment().previousHolidays(1, true); + +let nextHolidayResult: moment.Moment[] | moment.Moment; +nextHolidayResult = moment().nextHoliday(); +nextHolidayResult = moment().nextHoliday(1); +nextHolidayResult = moment().nextHoliday(1, false); +nextHolidayResult = moment().nextHoliday(1, true); +nextHolidayResult = moment().nextHolidays(); +nextHolidayResult = moment().nextHolidays(1); +nextHolidayResult = moment().nextHolidays(1, false); +nextHolidayResult = moment().nextHolidays(1, true); + +let holidaysBetweenResult: moment.Moment[] | false; +holidaysBetweenResult = moment().holidaysBetween(moment()); +holidaysBetweenResult = moment().holidaysBetween(moment(), false); +holidaysBetweenResult = moment().holidaysBetween(moment(), true); + +let holidayDefinition: moment.HolidayDefinition = { + date: 'string' +}; +holidayDefinition = { + date: 'string', + keywords: ['array'], +}; +holidayDefinition = { + date: 'string', + keywords: ['array'], + keywords_n: ['array'], +}; +holidayDefinition = { + date: 'string', + keywords: ['array'], + keywords_n: ['array'], + keywords_y: ['array'], +}; +holidayDefinition = { + date: 'string', + keywords: ['array'], + keywords_n: ['array'], + keywords_y: ['array'], + regions: ['array'], +}; +holidayDefinition = { + date: 'string', + keywords: ['array'], + keywords_n: ['array'], + keywords_y: ['array'], + regions: ['array'], + regions_n: ['array'] +}; + +const holidays: moment.Holidays = moment.holidays; +let activeHolidays: moment.HolidaysMapping = moment.holidays.active; +activeHolidays = { + 'Some holiday name': holidayDefinition +}; + +let lastActiveHolidays: moment.HolidaysMapping = moment.holidays.active_last; +lastActiveHolidays = { + 'Some holiday name': holidayDefinition +}; + +let holidayModifier: moment.HolidayModifier = moment.modifyHolidays; +holidayModifier = holidayModifier.set('string'); +holidayModifier = holidayModifier.set(['array']); +holidayModifier = holidayModifier.set(activeHolidays); +holidayModifier = holidayModifier.set('string', {}); +holidayModifier = holidayModifier.set(['array'], {}); +holidayModifier = holidayModifier.set(activeHolidays, {}); +holidayModifier = holidayModifier.add(activeHolidays); +holidayModifier = holidayModifier.add('string'); +holidayModifier = holidayModifier.add(activeHolidays, {}); +holidayModifier = holidayModifier.add('string', {}); +holidayModifier = holidayModifier.remove('string'); +holidayModifier = holidayModifier.remove(['array']); +holidayModifier = holidayModifier.undo(); +holidayModifier = holidayModifier.load('string'); +holidayModifier = holidayModifier.load(['string']); +holidayModifier = holidayModifier.extendParser((m: moment.Moment, d: string): moment.Moment | moment.Moment[] | false | void => { +}); diff --git a/types/moment-holiday/package.json b/types/moment-holiday/package.json new file mode 100644 index 0000000000..4c7554a28e --- /dev/null +++ b/types/moment-holiday/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "moment": ">=2.0.0" + } +} diff --git a/types/moment-holiday/tsconfig.json b/types/moment-holiday/tsconfig.json new file mode 100644 index 0000000000..d03f37e12c --- /dev/null +++ b/types/moment-holiday/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", + "moment-holiday-tests.ts" + ] +} diff --git a/types/moment-holiday/tslint.json b/types/moment-holiday/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/moment-holiday/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 893b0c790c8ea24c1080fe6da1f52d62a08704d9 Mon Sep 17 00:00:00 2001 From: Homa Wong Date: Sat, 28 Oct 2017 16:58:34 -0700 Subject: [PATCH 089/352] Update index.d.ts --- types/lodash/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/lodash/index.d.ts b/types/lodash/index.d.ts index b0e4f6848d..b8d83d27b3 100644 --- a/types/lodash/index.d.ts +++ b/types/lodash/index.d.ts @@ -9515,7 +9515,7 @@ declare namespace _ { * @param value The value to check. * @return Returns true if value is correctly classified, else false. */ - isFunction(value?: any): value is (...args: any[]) => any; + isFunction(value?: F): value is F; } interface LoDashImplicitWrapper { From 11526a8ca01e8a9489a5f1824afe8823a2d73b3a Mon Sep 17 00:00:00 2001 From: Homa Wong Date: Sat, 28 Oct 2017 19:33:56 -0700 Subject: [PATCH 090/352] Update index.d.ts --- types/lodash/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/lodash/index.d.ts b/types/lodash/index.d.ts index b8d83d27b3..b0e4f6848d 100644 --- a/types/lodash/index.d.ts +++ b/types/lodash/index.d.ts @@ -9515,7 +9515,7 @@ declare namespace _ { * @param value The value to check. * @return Returns true if value is correctly classified, else false. */ - isFunction(value?: F): value is F; + isFunction(value?: any): value is (...args: any[]) => any; } interface LoDashImplicitWrapper { From 8c196e90dfb50a6e3429fc7c615cbb6798a42073 Mon Sep 17 00:00:00 2001 From: Jacob Date: Sat, 28 Oct 2017 23:00:37 -0400 Subject: [PATCH 091/352] Updated per Reviewer Request changed import statement per reviewer's request. --- types/email-templates/email-templates-tests.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/types/email-templates/email-templates-tests.ts b/types/email-templates/email-templates-tests.ts index d16d0c0620..20401cb83e 100644 --- a/types/email-templates/email-templates-tests.ts +++ b/types/email-templates/email-templates-tests.ts @@ -1,6 +1,7 @@ -import * as Email from 'email-templates'; +import EmailTemplates = require('email-templates'); -const email = new Email({ + +const email = new EmailTemplates({ message: { from: 'Test@tesitng.com' }, From 239b0857a586c97f033ef958af851175f9888e23 Mon Sep 17 00:00:00 2001 From: Jacob Date: Sat, 28 Oct 2017 23:08:10 -0400 Subject: [PATCH 092/352] Removed extra whitespace Not sure how an extra line showed up. This should be good now for linting. --- types/email-templates/email-templates-tests.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/types/email-templates/email-templates-tests.ts b/types/email-templates/email-templates-tests.ts index 20401cb83e..a3311d6e81 100644 --- a/types/email-templates/email-templates-tests.ts +++ b/types/email-templates/email-templates-tests.ts @@ -1,6 +1,5 @@ import EmailTemplates = require('email-templates'); - const email = new EmailTemplates({ message: { from: 'Test@tesitng.com' From cce915c86c661f6a61417e695d075247302c20bc Mon Sep 17 00:00:00 2001 From: Jasper Roloff Date: Sun, 29 Oct 2017 18:58:03 +0100 Subject: [PATCH 093/352] updates umzug types to support custom resolver --- types/umzug/index.d.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/types/umzug/index.d.ts b/types/umzug/index.d.ts index 0954170b71..634c247bd4 100644 --- a/types/umzug/index.d.ts +++ b/types/umzug/index.d.ts @@ -28,6 +28,16 @@ declare namespace umzug { */ wrap?: (fn: T) => T; + /** + * A function that maps a file path to a migration object in the form + * { up: Function, down: Function }. The default for this is to require(...) + * the file as javascript, but you can use this to transpile TypeScript, + * read raw sql etc. + * See https://github.com/sequelize/umzug/tree/master/test/fixtures + * for examples. + */ + customResolver?(path: string): { up: () => Promise, down?: () => Promise }; + } interface JSONStorageOptions { From 3688a1f75d2c3516c6843195524d577cac6d59f1 Mon Sep 17 00:00:00 2001 From: Al Tabayoyon Date: Sun, 29 Oct 2017 20:36:45 -0700 Subject: [PATCH 094/352] Updates types/jsbn: index.d.ts and jsbn-tests.ts Issue: Error in @types/jsbn Typescript declarations file. Symptom: After installing typescript, jsbn and @types/jsbn in a project, creation of a Typescript file that import of BigInteger with import {BigInteger} from 'jsbn'; results in TS2306: File node_modules/@types/jsbn/index.d.ts is not a module. Resolution: In @types/jsbn/index.d.ts, replace line declare namespace jsbn { with declare module 'jsbn' { Additional Notes: When using current @types/jsbn as is, using Webstorm's "quickfix" to resolve a reference to BigInteger example: const bi = new BigInteger('2', 16); may result in adding import BigInteger = jsbn.BigInteger; which will work with local builds but if it becomes a published npm package (lets call it zzz), a browser-side application (e.g. Angular) importing package zzz will result in a JavaScript runtime error as it is unable to resolve 'jsbn.BigInteger'. --- types/jsbn/index.d.ts | 2 +- types/jsbn/jsbn-tests.ts | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/types/jsbn/index.d.ts b/types/jsbn/index.d.ts index cde50e0df2..2614718b81 100644 --- a/types/jsbn/index.d.ts +++ b/types/jsbn/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Eugene Chernyshov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare namespace jsbn { +declare module 'jsbn' { interface RandomGenerator { nextBytes(bytes: number[]): void; diff --git a/types/jsbn/jsbn-tests.ts b/types/jsbn/jsbn-tests.ts index 76088a32b6..eb5959173f 100644 --- a/types/jsbn/jsbn-tests.ts +++ b/types/jsbn/jsbn-tests.ts @@ -1,16 +1,15 @@ - -var BigInteger = jsbn.BigInteger; +import {BigInteger} from 'jsbn'; // constructor tests var x = new BigInteger("AABB", 16); x = new BigInteger("75643564363473453456342378564387956906736546456235345"); // method tests -var isBigInteger: jsbn.BigInteger; +var isBigInteger: BigInteger; var isNumber: number; var isBoolean: boolean; var isString: string; -var isDivmod: jsbn.BigInteger[]; +var isDivmod: BigInteger[]; var isByteArray: number[]; x.copyTo(x); From 18c2cdb543cd978058627e12f90a54c31125830e Mon Sep 17 00:00:00 2001 From: Cameron Crothers Date: Mon, 30 Oct 2017 14:50:37 +1100 Subject: [PATCH 095/352] Support ldapjs change as per docs --- types/ldapjs/index.d.ts | 4 ++++ types/ldapjs/ldapjs-tests.ts | 11 +++++++++++ types/ldapjs/tsconfig.json | 3 +-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/types/ldapjs/index.d.ts b/types/ldapjs/index.d.ts index 0afbf16046..8034add042 100644 --- a/types/ldapjs/index.d.ts +++ b/types/ldapjs/index.d.ts @@ -71,6 +71,10 @@ export interface Change { }; } +export var Change: { + new(change: Change): Change; +} + export interface SearchCallBack { (error: Error, result: EventEmitter): void; } diff --git a/types/ldapjs/ldapjs-tests.ts b/types/ldapjs/ldapjs-tests.ts index 6b2d879142..ec106fd29a 100644 --- a/types/ldapjs/ldapjs-tests.ts +++ b/types/ldapjs/ldapjs-tests.ts @@ -18,3 +18,14 @@ let opts: ldap.SearchOptions = { client.search('o=example', opts, (err: Error, res: NodeJS.EventEmitter): void => { // nothing }); + +let change = new ldap.Change({ + operation: 'add', + modification: { + pets: ['cat', 'dog'] + } +}); + +client.modify('cn=foo, o=example', change, function(err) { + // nothing +}); diff --git a/types/ldapjs/tsconfig.json b/types/ldapjs/tsconfig.json index 1f1d5bafc9..1f4da0daf0 100644 --- a/types/ldapjs/tsconfig.json +++ b/types/ldapjs/tsconfig.json @@ -7,7 +7,6 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": false, - "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" @@ -20,4 +19,4 @@ "index.d.ts", "ldapjs-tests.ts" ] -} \ No newline at end of file +} From 7f4e260887ab697741f776f9963038bf8433b169 Mon Sep 17 00:00:00 2001 From: Al Tabayoyon Date: Sun, 29 Oct 2017 20:57:45 -0700 Subject: [PATCH 096/352] Updated version from v1.2 to v1.3.0 --- types/jsbn/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/jsbn/index.d.ts b/types/jsbn/index.d.ts index 2614718b81..5941b48c0e 100644 --- a/types/jsbn/index.d.ts +++ b/types/jsbn/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for jsbn v1.2 +// Type definitions for jsbn v1.3.0 // Project: http://www-cs-students.stanford.edu/%7Etjw/jsbn/ // Definitions by: Eugene Chernyshov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 87400f8dce2f15283d6c7d344569012369a5cb33 Mon Sep 17 00:00:00 2001 From: Cameron Crothers Date: Mon, 30 Oct 2017 15:30:07 +1100 Subject: [PATCH 097/352] Put strictFunctionTypes back --- types/ldapjs/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/types/ldapjs/tsconfig.json b/types/ldapjs/tsconfig.json index 1f4da0daf0..a0df7615fd 100644 --- a/types/ldapjs/tsconfig.json +++ b/types/ldapjs/tsconfig.json @@ -7,6 +7,7 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": false, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" From 175347f17b064b99d21dd55a2f55e456c6ef3252 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kov=C3=A1cs=20Vince?= Date: Mon, 30 Oct 2017 08:50:03 +0100 Subject: [PATCH 098/352] Remove white space between coresponding methods --- types/vue-scrollto/index.d.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/types/vue-scrollto/index.d.ts b/types/vue-scrollto/index.d.ts index d3a7ec7efb..47371283d9 100644 --- a/types/vue-scrollto/index.d.ts +++ b/types/vue-scrollto/index.d.ts @@ -34,9 +34,7 @@ declare namespace VueScrollTo { interface VueStatic { (options: Options): void; - (element: string | Element, options?: Options): void; - (element: string | Element, duration: number, options?: Options): void; } } From e3a0447a5ddaef2d4106e7be8c4a7af74d0db2f1 Mon Sep 17 00:00:00 2001 From: Damian Senn Date: Mon, 30 Oct 2017 10:27:06 +0100 Subject: [PATCH 099/352] Add missing options to selectize config --- types/selectize/index.d.ts | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/types/selectize/index.d.ts b/types/selectize/index.d.ts index 449d09ce52..c441137558 100644 --- a/types/selectize/index.d.ts +++ b/types/selectize/index.d.ts @@ -11,6 +11,11 @@ declare namespace Selectize { // General // ------------------------------------------------------------------------------------------------------------ + /** + * An array of the initial selected values. By default this is populated from the original input element. + */ + items?: T[]; + /** * The string to separate items by. This option is only used when Selectize is instantiated from a * element. @@ -94,6 +99,13 @@ declare namespace Selectize { */ hideSelected?: boolean; + /** + * If true, the dropdown will be closed after a selection is made. + * + * Default: false + */ + closeAfterSelect?: boolean; + /** * If true, Selectize will treat any options with a "" value like normal. This defaults to false to * accomodate the common