From a9b7384eb475599db9afe5b31b97a0d160922d01 Mon Sep 17 00:00:00 2001 From: benliddicott Date: Sat, 15 Aug 2015 11:26:16 +0100 Subject: [PATCH 001/146] static-eval.d.ts --- static-eval/static-eval.d.ts | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 static-eval/static-eval.d.ts diff --git a/static-eval/static-eval.d.ts b/static-eval/static-eval.d.ts new file mode 100644 index 000000000..61db0b405 --- /dev/null +++ b/static-eval/static-eval.d.ts @@ -0,0 +1,4 @@ +declare module 'static-eval' { + function evaluate(ast, vars: { [name: string]: any }); + export =evaluate; +} From 989e5e7ada29f8e9e36460bc528875f008893226 Mon Sep 17 00:00:00 2001 From: Calvin Fernandez Date: Thu, 27 Aug 2015 17:43:24 -0400 Subject: [PATCH 002/146] add placholder parameter to work with codemirror placeholder addon --- codemirror/codemirror.d.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/codemirror/codemirror.d.ts b/codemirror/codemirror.d.ts index 06361684d..9bf5f3394 100644 --- a/codemirror/codemirror.d.ts +++ b/codemirror/codemirror.d.ts @@ -787,7 +787,10 @@ declare module CodeMirror { viewportMargin?: number; /** Optional lint configuration to be used in conjunction with CodeMirror's linter addon. */ - lint?: boolean | LintOptions; + lint?: boolean | LintOptions; + + /** Optional value to be used in conduction with CodeMirror’s placeholder add-on. */ + placeholder?: string; } interface TextMarkerOptions { From 1a61d12d8d63514e1f1d3fcedf44b2384780c302 Mon Sep 17 00:00:00 2001 From: "Ciuca, Alexandru" Date: Thu, 3 Sep 2015 15:56:47 +0300 Subject: [PATCH 003/146] angular.d.ts - type safety for $controller --- angularjs/angular.d.ts | 5 +++-- bardjs/bardjs-tests.ts | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index d183167b5..dc7f5dae8 100644 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -1230,8 +1230,9 @@ declare module angular { /////////////////////////////////////////////////////////////////////////// interface IControllerService { // Although the documentation doesn't state this, locals are optional - (controllerConstructor: Function, locals?: any, bindToController?: any): any; - (controllerName: string, locals?: any, bindToController?: any): any; + (controllerConstructor: new (...args: any[]) => T, locals?: any, bindToController?: any): T; + (controllerConstructor: Function, locals?: any, bindToController?: any): T; + (controllerName: string, locals?: any, bindToController?: any): T; } interface IControllerProvider extends IServiceProvider { diff --git a/bardjs/bardjs-tests.ts b/bardjs/bardjs-tests.ts index 71671b23e..312b06496 100644 --- a/bardjs/bardjs-tests.ts +++ b/bardjs/bardjs-tests.ts @@ -232,7 +232,7 @@ module bardTests { _default: $q.when([]) }); - controller = $controller('MyController'); + controller = $controller('MyController'); $rootScope.$apply(); }); } @@ -264,7 +264,7 @@ module bardTests { _default: $q.when([]) }); - controller = $controller('MyController'); + controller = $controller('MyController'); $rootScope.$apply(); }); From 037e1e8c614a80b903d555327e9f80f63c6f5a1c Mon Sep 17 00:00:00 2001 From: Sebastian Coetzee Date: Fri, 4 Sep 2015 16:49:08 +0200 Subject: [PATCH 004/146] Update mithril.d.ts Updates mithril typing definitions. Adds some API functionality that was not there previously. --- mithril/mithril.d.ts | 48 +++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/mithril/mithril.d.ts b/mithril/mithril.d.ts index e01dbcc02..3cd0e21e4 100644 --- a/mithril/mithril.d.ts +++ b/mithril/mithril.d.ts @@ -8,19 +8,15 @@ interface MithrilStatic { (selector: string, attributes: Object, children?: any): MithrilVirtualElement; (selector: string, children?: any): MithrilVirtualElement; - prop(value?: T): (value?: T) => T; - prop(promise: MithrilPromise): MithrilPromiseProperty; + prop(value?: T): (value?: T) => T; + prop(promise: MithrilPromise): MithrilPromiseProperty; withAttr(property: string, callback: (value: any) => void): (e: Event) => any; module(rootElement: Node, module: MithrilModule): void; trust(html: string): String; render(rootElement: Element, children?: any): void; render(rootElement: HTMLDocument, children?: any): void; redraw: MithrilRedraw; - route(rootElement: Element, defaultRoute: string, routes: { [key: string]: MithrilModule }): void; - route(rootElement: HTMLDocument, defaultRoute: string, routes: { [key: string]: MithrilModule }): void; - route(path: string, params?: any, shouldReplaceHistory?: boolean): void; - route(): string; - route(element: Element, isInitialized: boolean): void; + route: MithrilRoute; request(options: MithrilXHROptions): MithrilPromise; deferred(): MithrilDeferred; sync(promises: MithrilPromise[]): MithrilPromise; @@ -28,6 +24,22 @@ interface MithrilStatic { endComputation(): void; } +interface MithrilRoute { + (rootElement: Element, defaultRoute: string, routes: { [key: string]: MithrilModule }): void; + (rootElement: HTMLDocument, defaultRoute: string, routes: { [key: string]: MithrilModule }): void; + (path: string, params?: any, shouldReplaceHistory?: boolean): void; + (element: Element, isInitialized: boolean): void; + (): string; + mode: string; + param: MithrilParam; + buildQueryString(data: Object): string; + parseQueryString(queryString: string): Object; +} + +interface MithrilParam { + (param: string): string; +} + interface MithrilRedraw { (): void; strategy: (value?: string) => string; @@ -40,26 +52,26 @@ interface MithrilVirtualElement { } interface MithrilModule { - controller: Function; - view: (controller?: any) => MithrilVirtualElement; + controller: Function; + view: (controller?: any) => MithrilVirtualElement; } interface MithrilDeferred { - resolve(value?: T): void; - reject(value?: any): void; - promise: MithrilPromise; + resolve(value?: T): void; + reject(value?: any): void; + promise: MithrilPromise; } interface MithrilPromise { - (value?: T): T; - then(successCallback?: (value: T) => R, errorCallback?: (value: any) => any): MithrilPromise; - then(successCallback?: (value: T) => MithrilPromise, errorCallback?: (value: any) => any): MithrilPromise; + (value?: T): T; + then(successCallback?: (value: T) => R, errorCallback?: (value: any) => any): MithrilPromise; + then(successCallback?: (value: T) => MithrilPromise, errorCallback?: (value: any) => any): MithrilPromise; } interface MithrilPromiseProperty extends MithrilPromise { - (): T; - (value: T): T; - toJSON(): T; + (): T; + (value: T): T; + toJSON(): T; } interface MithrilXHROptions { From 3c3c84e2158e0dc026c00549be973e49ac024d33 Mon Sep 17 00:00:00 2001 From: Martin McWhorter Date: Wed, 9 Sep 2015 18:07:21 +0100 Subject: [PATCH 005/146] Angulartics Settings Provider Add setting which can be set directly through provider. Use case: you want to strip off the slash in the basePath -- using the settings in the provider allows you to modify the basePath as you like. --- angulartics/angulartics-tests.ts | 2 ++ angulartics/angulartics.d.ts | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/angulartics/angulartics-tests.ts b/angulartics/angulartics-tests.ts index cc816a2ab..4e2a57cca 100644 --- a/angulartics/angulartics-tests.ts +++ b/angulartics/angulartics-tests.ts @@ -20,6 +20,8 @@ module Analytics { $analyticsProvider.registerPageTrack((path: string, locationObj: ng.ILocationService) => { console.log("viewed " + path); }); + + $analyticsProvider.settings.pageTracking.basePath = "/my/base/path"; }]); } diff --git a/angulartics/angulartics.d.ts b/angulartics/angulartics.d.ts index 8c8957569..bb7caa5ac 100644 --- a/angulartics/angulartics.d.ts +++ b/angulartics/angulartics.d.ts @@ -33,6 +33,16 @@ declare module Angulartics { registerSetUsername(callback: (username: string) => any): void registerSetUserProperties(callback: (userProperties: any) => any): void registerSetSuperProperties(callback: (superProperties: any) => any): void + + settings: { + pageTracking: { + autoTrackingVirtualPages: boolean, + autoTrackingFirstPage: boolean, + basePath: string, + autoBasePath: boolean + }, + developerMode: boolean + } } } From 02f03824f17d974d2517f5fbb39540e351c6b7d3 Mon Sep 17 00:00:00 2001 From: Pavel Bakshy Date: Thu, 10 Sep 2015 17:47:36 +0300 Subject: [PATCH 006/146] ko.plus: Replaced Callback type with Function --- ko.plus/ko.plus-tests.ts | 2 ++ ko.plus/ko.plus.d.ts | 10 ++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ko.plus/ko.plus-tests.ts b/ko.plus/ko.plus-tests.ts index 992332e2b..7dd1053b2 100644 --- a/ko.plus/ko.plus-tests.ts +++ b/ko.plus/ko.plus-tests.ts @@ -43,6 +43,8 @@ function CommandTests() { action: () => { return "Hello cmd4"; } }); + // initialize command with action with typed argument + var cmd5 = ko.command((message: string) => { return message; }); // test execute the command cmd1(); diff --git a/ko.plus/ko.plus.d.ts b/ko.plus/ko.plus.d.ts index 65301aa7c..dacf6121f 100644 --- a/ko.plus/ko.plus.d.ts +++ b/ko.plus/ko.plus.d.ts @@ -23,7 +23,7 @@ // interface KnockoutStatic { // create a command - two overloads - command: (param: KoPlus.Callback | KoPlus.CommandOptions) => KoPlus.Command; + command: (param: Function | KoPlus.CommandOptions) => KoPlus.Command; editable: KoPlus.EditableStatic; editableArray: KoPlus.EditableArrayStatic; @@ -60,8 +60,6 @@ interface KnockoutBindingHandlers { // namespace for ko.plus types // declare module KoPlus { - // predefine a callback type - export type Callback = () => void; //#region Command types @@ -91,9 +89,9 @@ declare module KoPlus { fail: (callback: (error: string) => void) => Command; - always: (callback: Callback) => Command; + always: (callback: Function) => Command; - then: (resolve: Callback, reject: Callback) => Command; + then: (resolve: Function, reject: Function) => Command; } // @@ -102,7 +100,7 @@ declare module KoPlus { // export interface CommandOptions { // [required] sets the command action method - action: Callback; + action: Function; // [optional] function to determine if command can be executed canExecute?: () => boolean; From c5db2d4088aeae2d695d96d416141dd944533459 Mon Sep 17 00:00:00 2001 From: cstefan Date: Tue, 15 Sep 2015 11:50:36 +0200 Subject: [PATCH 007/146] Update chrome-app.d.ts Added missing removeListener WindowEvent --- chrome/chrome-app.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/chrome/chrome-app.d.ts b/chrome/chrome-app.d.ts index 5cfa0fbce..f75f7dca6 100644 --- a/chrome/chrome-app.d.ts +++ b/chrome/chrome-app.d.ts @@ -138,6 +138,7 @@ declare module chrome.app.window { interface WindowEvent { addListener(callback: () => void): void; + removeListener(callback: () => void): void; } var onBoundsChanged: WindowEvent; From 59a842d0ba16e44e8f471b3cf1164806d637c879 Mon Sep 17 00:00:00 2001 From: Alexander Rusakov Date: Tue, 15 Sep 2015 15:24:25 +0300 Subject: [PATCH 008/146] whatwg-fetch uses strings and enums --- whatwg-fetch/whatwg-fetch-tests.ts | 8 +++++++- whatwg-fetch/whatwg-fetch.d.ts | 16 ++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/whatwg-fetch/whatwg-fetch-tests.ts b/whatwg-fetch/whatwg-fetch-tests.ts index 5248f5d1d..a7ba5d05c 100644 --- a/whatwg-fetch/whatwg-fetch-tests.ts +++ b/whatwg-fetch/whatwg-fetch-tests.ts @@ -6,7 +6,10 @@ function test_fetchUrlWithOptions() { headers.append("Content-Type", "application/json"); var requestOptions: RequestInit = { method: "POST", - headers: headers + headers: headers, + mode: 'same-origin', + credentials: 'omit', + cache: 'default' }; handlePromise(window.fetch("http://www.andlabs.net/html5/uCOR.php", requestOptions)); } @@ -27,6 +30,9 @@ function test_fetchUrl() { function handlePromise(promise: Promise) { promise.then((response) => { + if (response.type === 'basis') { + // for test only + } return response.text(); }).then((text) => { console.log(text); diff --git a/whatwg-fetch/whatwg-fetch.d.ts b/whatwg-fetch/whatwg-fetch.d.ts index 9efd039b4..f98fb5985 100644 --- a/whatwg-fetch/whatwg-fetch.d.ts +++ b/whatwg-fetch/whatwg-fetch.d.ts @@ -10,20 +10,20 @@ declare class Request { method: string; url: string; headers: Headers; - context: RequestContext; + context: string|RequestContext; referrer: string; - mode: RequestMode; - credentials: RequestCredentials; - cache: RequestCache; + mode: string|RequestMode; + credentials: string|RequestCredentials; + cache: string|RequestCache; } interface RequestInit { method?: string; headers?: HeaderInit|{ [index: string]: string }; body?: BodyInit; - mode?: RequestMode; - credentials?: RequestCredentials; - cache?: RequestCache; + mode?: string|RequestMode; + credentials?: string|RequestCredentials; + cache?: string|RequestCache; } declare enum RequestContext { @@ -58,7 +58,7 @@ declare class Response extends Body { constructor(body?: BodyInit, init?: ResponseInit); error(): Response; redirect(url: string, status: number): Response; - type: ResponseType; + type: string|ResponseType; url: string; status: number; ok: boolean; From 813a3c7490049f6e66f63969a213aa902addb7a3 Mon Sep 17 00:00:00 2001 From: Shiak1 Date: Wed, 16 Sep 2015 19:07:05 -0400 Subject: [PATCH 009/146] Added formData to Options interface Fix issue #5787 --- request/request.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/request/request.d.ts b/request/request.d.ts index e261d3615..5332aa90a 100644 --- a/request/request.d.ts +++ b/request/request.d.ts @@ -62,6 +62,7 @@ declare module 'request' { uri?: string; callback?: (error: any, response: http.IncomingMessage, body: any) => void; jar?: any; // CookieJar + formData: any; // Object form?: any; // Object or string auth?: AuthOptions; oauth?: OAuthOptions; From b17b669edff5f7e05c8f054e004f78f00161300f Mon Sep 17 00:00:00 2001 From: David Pfeffer Date: Wed, 16 Sep 2015 19:17:42 -0400 Subject: [PATCH 010/146] Exposes ScopeScheduler to TypeScript --- rx-angular/rx.angular.d.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/rx-angular/rx.angular.d.ts b/rx-angular/rx.angular.d.ts index e2d0ec8c5..413abf30b 100644 --- a/rx-angular/rx.angular.d.ts +++ b/rx-angular/rx.angular.d.ts @@ -12,6 +12,16 @@ declare module Rx { interface IObservable { safeApply($scope: ng.IScope, callback: (data: any) => void): Rx.Observable; } + + export interface ScopeScheduler extends IScheduler { + constructor(scope: ng.IScope); + } + + export interface ScopeSchedulerStatic extends SchedulerStatic { + new ($scope: angular.IScope): ScopeScheduler; + } + + export var ScopeScheduler: ScopeSchedulerStatic; } declare module rx.angular { From 0592895e0431d2f290a1330d0d78fd9cb4ece1e7 Mon Sep 17 00:00:00 2001 From: robert-voica Date: Thu, 17 Sep 2015 13:41:05 +0300 Subject: [PATCH 011/146] Updated bootstrap-notify to v3.1.3 --- bootstrap-notify/bootstrap-notify-test.ts | 51 ++++++++++ bootstrap-notify/bootstrap-notify.d.ts | 109 ++++++++++------------ 2 files changed, 101 insertions(+), 59 deletions(-) create mode 100644 bootstrap-notify/bootstrap-notify-test.ts diff --git a/bootstrap-notify/bootstrap-notify-test.ts b/bootstrap-notify/bootstrap-notify-test.ts new file mode 100644 index 000000000..09e1dba1e --- /dev/null +++ b/bootstrap-notify/bootstrap-notify-test.ts @@ -0,0 +1,51 @@ +/// +/// + +//Test for bootstrap-notify v3.1.3 + +$.notify({ + // options + icon: 'glyphicon glyphicon-warning-sign', + title: 'Bootstrap notify', + message: 'Turning standard Bootstrap alerts into "notify" like notifications', + url: 'https://github.com/mouse0270/bootstrap-notify', + target: '_blank' +},{ + // settings + element: 'body', + position: null, + type: "info", + allow_dismiss: true, + newest_on_top: false, + showProgressbar: false, + placement: { + from: "top", + align: "right" + }, + offset: 20, + spacing: 10, + z_index: 1031, + delay: 5000, + timer: 1000, + url_target: '_blank', + mouse_over: null, + animate: { + enter: 'animated fadeInDown', + exit: 'animated fadeOutUp' + }, + onShow: null, + onShown: null, + onClose: null, + onClosed: null, + icon_type: 'class', + template: '' +}); \ No newline at end of file diff --git a/bootstrap-notify/bootstrap-notify.d.ts b/bootstrap-notify/bootstrap-notify.d.ts index 2159aa21a..556bf6137 100644 --- a/bootstrap-notify/bootstrap-notify.d.ts +++ b/bootstrap-notify/bootstrap-notify.d.ts @@ -1,68 +1,59 @@ -// Type definitions for bootstrap-notify -// Project: https://github.com/Nijikokun/bootstrap-notify -// Definitions by: Blake Niemyjski -// Definitions: https://github.com/borisyankov/DefinitelyTyped +// Type definitions for bootstrap-notify v3.1.3 -/// +/// -interface NotifyOptions { - /** - Alert style, omit alert- from style name. - @param {string} type - */ - type?: string; - /** - Allow alert to be closable through a close icon. - @param {boolean} closable - */ - closable?: boolean; - /** - Alert transition, pretty sure only fade is supported, you can try others if you wish. - @param {string} transition - */ - transition?: string; - /** - Fade alert out after a certain delay (in ms) - @param {string} fadeOut - */ - fadeOut?: NotifyFadeOutSettings; - /** - Text to show on alert, you can use either html or text. HTML will override text. - @param {MessageOptions} message - */ - message?: MessageOptions; - /** - Called before alert closes. - @param {function} onClose - */ - onClose?: () => void; - /** - Called after alert closes. - @param {function} onClosed - */ - onClosed?: () => void; +/* tslint:disable: interface-name no-any */ + +interface JQueryStatic { + /* tslint:enable: interface-name */ + notify(message: string): INotifyReturn; + notify(opts: INotifyOptions, settings?: INotifySettings): INotifyReturn; + notifyDefaults(settings: INotifySettings): void; + notifyClose(): void; + notifyClose(command: string): void; } -interface NotifyFadeOutSettings { - enabled?: boolean; - delay?: number; +interface INotifyOptions { + message: string; + title?: string; + icon?: string; + url?: string; + target?: string; } -interface MessageOptions { - html?: string; - text?: string; +interface INotifySettings { + element?: string; + position?: string; + type?: string; + allow_dismiss?: boolean; + allow_duplicates?: boolean; + newest_on_top?: boolean; + showProgressbar?: boolean; + placement?: { + from?: string; + align?: string; + }; + offset?: number; + spacing?: number; + z_index?: number; + delay?: number; + timer?: number; + url_target?: string; + mouse_over?: string; + animate?: { + enter?: string; + exit?: string; + }; + onShow?: () => void; + onShown?: () => void; + onClose?: () => void; + onClosed?: () => void; + icon_type?: string; + template?: string; } -interface Notification { - show(); - hide(); -} - -interface JQuery { - /** - Creates a notification instance with default options. - @constructor - @param {NotifyOptions} options - */ - notify(options: NotifyOptions): Notification; +interface INotifyReturn { + $ele: JQueryStatic; + close: () => void; + update: (command: string, update: any) => void; } \ No newline at end of file From 79b6ebd0e9eb25625379fe1e1e19ac939283475d Mon Sep 17 00:00:00 2001 From: robert-voica Date: Thu, 17 Sep 2015 13:55:26 +0300 Subject: [PATCH 012/146] Repaired header --- bootstrap-notify/bootstrap-notify-test.ts | 1 + bootstrap-notify/bootstrap-notify.d.ts | 3 +++ 2 files changed, 4 insertions(+) diff --git a/bootstrap-notify/bootstrap-notify-test.ts b/bootstrap-notify/bootstrap-notify-test.ts index 09e1dba1e..a71a83557 100644 --- a/bootstrap-notify/bootstrap-notify-test.ts +++ b/bootstrap-notify/bootstrap-notify-test.ts @@ -2,6 +2,7 @@ /// //Test for bootstrap-notify v3.1.3 +//Copied example directly from Bootstrap-notify site $.notify({ // options diff --git a/bootstrap-notify/bootstrap-notify.d.ts b/bootstrap-notify/bootstrap-notify.d.ts index 556bf6137..dc08354d9 100644 --- a/bootstrap-notify/bootstrap-notify.d.ts +++ b/bootstrap-notify/bootstrap-notify.d.ts @@ -1,4 +1,7 @@ // Type definitions for bootstrap-notify v3.1.3 +// Project: http://bootstrap-notify.remabledesigns.com/ +// Definitions by: Robert McIntosh , Robert Voica +// Definitions: https://github.com/borisyankov/DefinitelyTyped /// From 87d055979089cb5c498672d63ef6e1a8f725b6e9 Mon Sep 17 00:00:00 2001 From: benliddicott Date: Thu, 17 Sep 2015 14:18:23 +0100 Subject: [PATCH 013/146] EJS Typing --- ejs/ejs-tests.ts | 4 +++ ejs/ejs.d.ts | 91 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 ejs/ejs-tests.ts create mode 100644 ejs/ejs.d.ts diff --git a/ejs/ejs-tests.ts b/ejs/ejs-tests.ts new file mode 100644 index 000000000..fd03dd1e0 --- /dev/null +++ b/ejs/ejs-tests.ts @@ -0,0 +1,4 @@ +/// +import ejs = require("ejs"); +var people = ['geddy', 'neil', 'alex']; +var html = ejs.render('<%= people.join(", "); %>', { people: people }); diff --git a/ejs/ejs.d.ts b/ejs/ejs.d.ts new file mode 100644 index 000000000..95ca168c3 --- /dev/null +++ b/ejs/ejs.d.ts @@ -0,0 +1,91 @@ +// Type definitions for ejs.js v2.3.3 +// Project: http://ejs.co/ +// Definitions by: Ben Liddicott +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +declare module "ejs" { + module Ejs { + type Data = { [name: string]: any }; + type Dependencies = string[]; + var cache: Cache; + var localsName: string; + function resolveInclude(name: string, filename: string): string; + function compile(template: string, opts?: Options): (TemplateFunction); + function render(template: string, data?: Data, opts?: Options): string; + function renderFile(path: string, data?: Data, opts?: Options, cb?: Function): any;// TODO RenderFileCallback return type + function clearCache(): any; + + function TemplateFunction(data: Data): any; + interface TemplateFunction { + dependencies: Dependencies; + } + interface Options { + cache?: any; + filename?: string; + context?: any; + compileDebug?: boolean; + client?: boolean; + delimiter?: string; + debug?: any; + _with?: boolean; + } + class Template { + constructor(text: string, opts: Options); + opts: Options; + templateText: string; + mode: string; + truncate: boolean; + currentLine: number; + source: string; + dependencies: Dependencies; + createRegex(): RegExp; + compile(): TemplateFunction; + generateSource(): any; + parseTemplateText(): string[]; + scanLine(line: string): any; + + } + module Template { + interface MODES { + EVAL: string; + ESCAPED: string; + RAW: string; + COMMENT: string; + LITERAL: string; + } + } + function escapeRegexChars(s: string): string; + function escapeXML(markup: string): string; + function shallowCopy(to: T1, fro: any): T1; + interface Cache { + _data: { [name: string]: any }; + set(key: string, val: any); + get(key: string): any; + } + var cache: Cache; + function resolve(from1: string, to: string): string; + function resolve(from1: string, from2: string, to: string): string; + function resolve(from1: string, from2: string, from3: string, to: string): string; + function resolve(from1: string, from2: string, from3: string, from4: string, to: string): string; + function resolve(from1: string, from2: string, from3: string, from4: string, from5: string, to: string): string; + function resolve(from1: string, from2: string, from3: string, from4: string, from5: string, from6: string, to: string): string; + function resolve(from1: string, from2: string, from3: string, from4: string, from5: string, from6: string, from7: string, to: string): string; + function resolve(from1: string, from2: string, from3: string, from4: string, from5: string, from6: string, from7: string, from8: string, to: string): string; + function resolve(from1: string, from2: string, from3: string, from4: string, from5: string, from6: string, from7: string, from8: string, from9: string, to: string): string; + function resolve(...args: string[]): string; + function normalize(path: string): string; + function isAbsolute(path: string): boolean; + function join(...args: string[]): string; + function relative(from: string, to: string): string; + var sep: string; + var delimiter: string; + function dirname(path: string): string; + function basename(path: string): string; + function extname(path: string): string; + function filter(xs: any, f: any): any; // TODO WHUT? + + + } + export = Ejs; +} \ No newline at end of file From d2f21a1d08fe25cbcb2ddf2b27f57a688391cb9c Mon Sep 17 00:00:00 2001 From: benliddicott Date: Sat, 15 Aug 2015 11:26:16 +0100 Subject: [PATCH 014/146] static-eval.d.ts --- static-eval/static-eval.d.ts | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 static-eval/static-eval.d.ts diff --git a/static-eval/static-eval.d.ts b/static-eval/static-eval.d.ts new file mode 100644 index 000000000..61db0b405 --- /dev/null +++ b/static-eval/static-eval.d.ts @@ -0,0 +1,4 @@ +declare module 'static-eval' { + function evaluate(ast, vars: { [name: string]: any }); + export =evaluate; +} From 89456dbce061106c41a01549ae703f0be8c27f98 Mon Sep 17 00:00:00 2001 From: benliddicott Date: Thu, 17 Sep 2015 14:18:23 +0100 Subject: [PATCH 015/146] EJS Typing --- ejs/ejs-tests.ts | 4 +++ ejs/ejs.d.ts | 91 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 ejs/ejs-tests.ts create mode 100644 ejs/ejs.d.ts diff --git a/ejs/ejs-tests.ts b/ejs/ejs-tests.ts new file mode 100644 index 000000000..fd03dd1e0 --- /dev/null +++ b/ejs/ejs-tests.ts @@ -0,0 +1,4 @@ +/// +import ejs = require("ejs"); +var people = ['geddy', 'neil', 'alex']; +var html = ejs.render('<%= people.join(", "); %>', { people: people }); diff --git a/ejs/ejs.d.ts b/ejs/ejs.d.ts new file mode 100644 index 000000000..95ca168c3 --- /dev/null +++ b/ejs/ejs.d.ts @@ -0,0 +1,91 @@ +// Type definitions for ejs.js v2.3.3 +// Project: http://ejs.co/ +// Definitions by: Ben Liddicott +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +declare module "ejs" { + module Ejs { + type Data = { [name: string]: any }; + type Dependencies = string[]; + var cache: Cache; + var localsName: string; + function resolveInclude(name: string, filename: string): string; + function compile(template: string, opts?: Options): (TemplateFunction); + function render(template: string, data?: Data, opts?: Options): string; + function renderFile(path: string, data?: Data, opts?: Options, cb?: Function): any;// TODO RenderFileCallback return type + function clearCache(): any; + + function TemplateFunction(data: Data): any; + interface TemplateFunction { + dependencies: Dependencies; + } + interface Options { + cache?: any; + filename?: string; + context?: any; + compileDebug?: boolean; + client?: boolean; + delimiter?: string; + debug?: any; + _with?: boolean; + } + class Template { + constructor(text: string, opts: Options); + opts: Options; + templateText: string; + mode: string; + truncate: boolean; + currentLine: number; + source: string; + dependencies: Dependencies; + createRegex(): RegExp; + compile(): TemplateFunction; + generateSource(): any; + parseTemplateText(): string[]; + scanLine(line: string): any; + + } + module Template { + interface MODES { + EVAL: string; + ESCAPED: string; + RAW: string; + COMMENT: string; + LITERAL: string; + } + } + function escapeRegexChars(s: string): string; + function escapeXML(markup: string): string; + function shallowCopy(to: T1, fro: any): T1; + interface Cache { + _data: { [name: string]: any }; + set(key: string, val: any); + get(key: string): any; + } + var cache: Cache; + function resolve(from1: string, to: string): string; + function resolve(from1: string, from2: string, to: string): string; + function resolve(from1: string, from2: string, from3: string, to: string): string; + function resolve(from1: string, from2: string, from3: string, from4: string, to: string): string; + function resolve(from1: string, from2: string, from3: string, from4: string, from5: string, to: string): string; + function resolve(from1: string, from2: string, from3: string, from4: string, from5: string, from6: string, to: string): string; + function resolve(from1: string, from2: string, from3: string, from4: string, from5: string, from6: string, from7: string, to: string): string; + function resolve(from1: string, from2: string, from3: string, from4: string, from5: string, from6: string, from7: string, from8: string, to: string): string; + function resolve(from1: string, from2: string, from3: string, from4: string, from5: string, from6: string, from7: string, from8: string, from9: string, to: string): string; + function resolve(...args: string[]): string; + function normalize(path: string): string; + function isAbsolute(path: string): boolean; + function join(...args: string[]): string; + function relative(from: string, to: string): string; + var sep: string; + var delimiter: string; + function dirname(path: string): string; + function basename(path: string): string; + function extname(path: string): string; + function filter(xs: any, f: any): any; // TODO WHUT? + + + } + export = Ejs; +} \ No newline at end of file From 8b36b63838077369de2eea584136c991bfb09393 Mon Sep 17 00:00:00 2001 From: benliddicott Date: Thu, 17 Sep 2015 15:46:41 +0100 Subject: [PATCH 016/146] add static-eval --- static-eval/static-eval-tests.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 static-eval/static-eval-tests.ts diff --git a/static-eval/static-eval-tests.ts b/static-eval/static-eval-tests.ts new file mode 100644 index 000000000..5657a8c62 --- /dev/null +++ b/static-eval/static-eval-tests.ts @@ -0,0 +1,14 @@ +/// +/// + +import evaluate = require('static-eval'); +import parse = require('../esprima/esprima').parse; + +var src = '[1,2,3+4*10+n,foo(3+5),obj[""+"x"].y]'; +var ast = parse(src).body[0].expression; + +console.log(evaluate(ast, { + n: 6, + foo: function (x) { return x * 100 }, + obj: { x: { y: 555 } } +})); \ No newline at end of file From d464f5a4e10431a5f47e89666c933ff7a72d8313 Mon Sep 17 00:00:00 2001 From: benliddicott Date: Thu, 17 Sep 2015 15:51:30 +0100 Subject: [PATCH 017/146] Updated header --- static-eval/static-eval.d.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/static-eval/static-eval.d.ts b/static-eval/static-eval.d.ts index 61db0b405..bb3461ad6 100644 --- a/static-eval/static-eval.d.ts +++ b/static-eval/static-eval.d.ts @@ -1,4 +1,10 @@ -declare module 'static-eval' { +// Type definitions for static-eval v0.2.4 +// Project: https://github.com/substack/static-eval +// Definitions by: Ben Liddicott +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +declare module 'static-eval' { function evaluate(ast, vars: { [name: string]: any }); export =evaluate; } From 94526e4c370faeea4bf14ff83998ff75f00e802d Mon Sep 17 00:00:00 2001 From: mfrantz Date: Tue, 4 Aug 2015 20:47:41 -0700 Subject: [PATCH 018/146] Update libxmljs for v0.14.2 --- libxmljs/libxmljs-tests.ts | 2 +- libxmljs/libxmljs.d.ts | 51 ++++++++++++++++++++------------------ 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/libxmljs/libxmljs-tests.ts b/libxmljs/libxmljs-tests.ts index bf73a6d98..fbc862818 100644 --- a/libxmljs/libxmljs-tests.ts +++ b/libxmljs/libxmljs-tests.ts @@ -10,7 +10,7 @@ var xml = '' + 'with content!' + ''; -var xmlDoc = libxmljs.parseXmlString(xml); +var xmlDoc = libxmljs.parseXml(xml); // xpath queries var gchild = xmlDoc.get('//grandchild'); diff --git a/libxmljs/libxmljs.d.ts b/libxmljs/libxmljs.d.ts index bb0f5ba29..045e43f10 100644 --- a/libxmljs/libxmljs.d.ts +++ b/libxmljs/libxmljs.d.ts @@ -1,9 +1,16 @@ -// Type definitions for Libxmljs +// Type definitions for Libxmljs v0.14.2 // Project: https://github.com/polotek/libxmljs // Definitions by: François de Campredon // Definitions: https://github.com/borisyankov/DefinitelyTyped +/// + declare module "libxmljs" { + + import events = require('events'); + + export function parseXml(source:string):XMLDocument; + export function parseHtml(source:string):HTMLDocument; export function parseXmlString(source:string):XMLDocument; export function parseHtmlString(source:string):HTMLDocument; @@ -20,6 +27,8 @@ declare module "libxmljs" { node(name:string, content:string):Element; root():Element; toString():string; + validate(xsdDoc:XMLDocument): boolean; + validationErrors: XmlError[]; version():Number; } @@ -34,25 +43,25 @@ declare module "libxmljs" { name(newName:string):void; text():string; attr(name:string):string; - attr(attr:Attribute); + attr(attr:Attribute):void; attr(attrObject:{[key:string]:string;}):void; attrs():Attribute[]; parent():Element; doc():XMLDocument; child(idx:number):Element; childNodes():Element[]; - addChild(child:Element); + addChild(child:Element):Element; nextSibling():Element; nextElement():Element; addNextSibling(siblingNode:Element):Element; prevSibling():Element; prevElement():Element; - addPrevSibling(siblingNode:Element); + addPrevSibling(siblingNode:Element):Element; find(xpath:string):Element[]; find(xpath:string, ns_uri:string):Element[]; get(xpath:string, ns_uri:string):Element; find(xpath:string, namespaces:{[key:string]:string;}):Element[]; - get(xpath, ns_uri:{[key:string]:string;}):Element; + get(xpath:string, ns_uri:{[key:string]:string;}):Element; defineNamespace(href:string):Namespace; defineNamespace(prefix:string, href:string):Namespace; namespace():Namespace; @@ -84,28 +93,22 @@ declare module "libxmljs" { prefix():string; } - export class SaxParser { + export class SaxParser extends events.EventEmitter { parseString(source:string):boolean; - addListener(event: string, listener: Function); - on(event: string, listener: Function): any; - once(event: string, listener: Function): void; - removeListener(event: string, listener: Function): void; - removeAllListener(event: string): void; - setMaxListeners(n: number): void; - listeners(event: string): { Function; }[]; - emit(event: string, arg1?: any, arg2?: any): void; } - export class SaxPushParser { + export class SaxPushParser extends events.EventEmitter { push(source:string):boolean; - addListener(event: string, listener: Function); - on(event: string, listener: Function): any; - once(event: string, listener: Function): void; - removeListener(event: string, listener: Function): void; - removeAllListener(event: string): void; - setMaxListeners(n: number): void; - listeners(event: string): { Function; }[]; - emit(event: string, arg1?: any, arg2?: any): void; } -} \ No newline at end of file + + export interface XmlError { + domain: number; + code: number; + message: string; + level: number; + file?: string; + column: number; + line: number; + } +} From c67995d1ecb4edb372d251ba09b69e1998d72191 Mon Sep 17 00:00:00 2001 From: Moes Date: Fri, 18 Sep 2015 13:28:05 +1000 Subject: [PATCH 019/146] Update jquery.fileuploade.d.ts --- jquery.fileupload/jquery.fileupload.d.ts | 33 +++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/jquery.fileupload/jquery.fileupload.d.ts b/jquery.fileupload/jquery.fileupload.d.ts index 8c9e93737..69821b0ed 100644 --- a/jquery.fileupload/jquery.fileupload.d.ts +++ b/jquery.fileupload/jquery.fileupload.d.ts @@ -204,6 +204,35 @@ interface JQueryFileInputOptions { contentType?: string; cache?: boolean; + timeout?: number; + + active?: Function; + progress?: Function; + send?: Function; + + // Other callbacks: + submit?: Function; + done?: Function; + fail?: Function; + always?: Function; + progressall?: Function; + start?: Function; + stop?: Function; + change?: Function; + paste?: Function; + drop?: Function; + dragover?: Function; + chunksend?: Function; + chunkdone?: Function; + chunkfail?: Function; + chunkalways?: Function; + + // Others + url?: string; + files?: any; + + // Cross-site XMLHttpRequest file uploads + xhrFields?: any; } @@ -213,7 +242,9 @@ interface JQueryFileUpload extends JQuery { interface JQuery { // Interface to the main method of jQuery File Upload - fileupload(settings: JQueryFileInputOptions): JQueryFileUpload; + fileupload(settings: JQueryFileInputOptions | string): JQueryFileUpload; + fileupload(action:string, settings: JQueryFileInputOptions | string): JQueryFileUpload; + fileupload(action: string, message:string, settings: JQueryFileInputOptions | string): JQueryFileUpload; } interface JQuerySupport { From 66c111fb9e51dd4572cf99ba7b21d184cd411f75 Mon Sep 17 00:00:00 2001 From: Dan Lewi Harkestad Date: Fri, 18 Sep 2015 07:05:53 +0200 Subject: [PATCH 020/146] The pointPlacement property was inconsistent. The property is of type string | number now. It was updated some places, but not all. Also added some missing properties for pie charts. --- highcharts/highcharts.d.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/highcharts/highcharts.d.ts b/highcharts/highcharts.d.ts index f654b9749..cb48604e3 100644 --- a/highcharts/highcharts.d.ts +++ b/highcharts/highcharts.d.ts @@ -659,7 +659,7 @@ interface HighchartsBarChart { }; pointInterval?: number; pointPadding?: number; - pointPlacement?: string; // null, "on", "between" + pointPlacement?: string | number; // null, "on", "between" pointRange?: number; pointStart?: number; pointWidth?: number; @@ -864,7 +864,7 @@ interface HighchartsLineChart { events: HighchartsPointEvents; }; pointInterval?: number; - pointPlacement?: string; // null, "on", "between" + pointPlacement?: string | number; // null, "on", "between" pointStart?: number; selected?: boolean; shadow?: boolean | HighchartsShadow; @@ -888,25 +888,29 @@ interface HighchartsPieChart { borderColor?: string; borderWidth?: number; center?: string[]; - color?: string; + colors?: string; cursor?: string; dataLabels?: HighchartsDataLabels; + depth?: number; enableMouseTracking?: boolean; + endAngle?: number; events?: HighchartsPlotEvents; + getExtremesFromAll?: boolean; id?: string; ignoreHiddenPoint?: boolean; innerSize?: number | string; lineWidth?: number; marker?: HighchartsMarker; + minSize?: number; point?: { events: HighchartsPointEvents; }; - pointPlacement?: string; // null, "on", "between" selected?: boolean; shadow?: boolean | HighchartsShadow; showInLegend?: boolean; size?: number | string; slicedOffset?: number; + startAngle?: number; states?: { hover: HighchartsAreaStates; }; @@ -942,7 +946,7 @@ interface HighchartsScatterChart { events: HighchartsPointEvents; }; pointInterval?: number; - pointPlacement?: string; // null, "on", "between" + pointPlacement?: string | number; // null, "on", "between" pointStart?: number; selected?: boolean; shadow?: boolean | HighchartsShadow; @@ -993,7 +997,7 @@ interface HighchartsSeriesChart { events: HighchartsPointEvents; }; pointInterval?: number; - pointPlacement?: string; // null, "on", "between" + pointPlacement?: string | number; // null, "on", "between" pointStart?: number; selected?: boolean; shadow?: boolean | HighchartsShadow; From 16dc2cea12e9a9bc45fbb4244436c7b38374476d Mon Sep 17 00:00:00 2001 From: Dave Keen Date: Fri, 18 Sep 2015 12:43:32 +0200 Subject: [PATCH 021/146] Added missing strokeMiterLimit to SVG attributes --- react/react.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/react/react.d.ts b/react/react.d.ts index 54d13d5eb..cb217c8fe 100644 --- a/react/react.d.ts +++ b/react/react.d.ts @@ -568,6 +568,7 @@ declare namespace __React { stroke?: string; strokeDasharray?: string; strokeLinecap?: string; + strokeMiterlimit?: string; strokeOpacity?: number | string; strokeWidth?: number | string; textAnchor?: string; @@ -1365,6 +1366,7 @@ declare module "react/addons" { stroke?: string; strokeDasharray?: string; strokeLinecap?: string; + strokeMiterlimit?: string; strokeOpacity?: number | string; strokeWidth?: number | string; textAnchor?: string; From d80194e8f36b9c9955948af53460ca8005842828 Mon Sep 17 00:00:00 2001 From: Kuniwak Date: Fri, 18 Sep 2015 21:34:31 +0900 Subject: [PATCH 022/146] Check returned values --- faker/faker-tests.ts | 273 ++++++++++++++++++++++--------------------- 1 file changed, 143 insertions(+), 130 deletions(-) diff --git a/faker/faker-tests.ts b/faker/faker-tests.ts index 94cb3b30a..324ca4835 100644 --- a/faker/faker-tests.ts +++ b/faker/faker-tests.ts @@ -2,155 +2,168 @@ import faker = require('faker'); -faker.address.zipCode(); -faker.address.zipCode('###'); -faker.address.city(); -faker.address.city(0); -faker.address.cityPrefix(); -faker.address.citySuffix(); -faker.address.streetName(); -faker.address.streetAddress(); -faker.address.streetAddress(false);; -faker.address.streetSuffix(); -faker.address.streetPrefix(); -faker.address.secondaryAddress(); -faker.address.county(); -faker.address.country(); -faker.address.countryCode(); -faker.address.state(); -faker.address.state(false); -faker.address.stateAbbr(); -faker.address.latitude(); -faker.address.longitude(); +let resultStr: string; +let resultBool: boolean; +let resultNum: number; +let resultStrArr: string[]; +let resultDate: Date; -faker.commerce.color(); -faker.commerce.department(); -faker.commerce.productName(); -faker.commerce.price(); -faker.commerce.price(0, 0, 0, '#'); -faker.commerce.productAdjective(); -faker.commerce.productMaterial(); -faker.commerce.product(); +resultStr = faker.address.zipCode(); +resultStr = faker.address.zipCode('###'); +resultStr = faker.address.city(); +resultStr = faker.address.city(0); +resultStr = faker.address.cityPrefix(); +resultStr = faker.address.citySuffix(); +resultStr = faker.address.streetName(); +resultStr = faker.address.streetAddress(); +resultStr = faker.address.streetAddress(false);; +resultStr = faker.address.streetSuffix(); +resultStr = faker.address.streetPrefix(); +resultStr = faker.address.secondaryAddress(); +resultStr = faker.address.county(); +resultStr = faker.address.country(); +resultStr = faker.address.countryCode(); +resultStr = faker.address.state(); +resultStr = faker.address.state(false); +resultStr = faker.address.stateAbbr(); +resultStr = faker.address.latitude(); +resultStr = faker.address.longitude(); -faker.company.suffixes(); -faker.company.companyName(); -faker.company.companyName(0); -faker.company.companySuffix(); -faker.company.catchPhrase(); -faker.company.bs(); -faker.company.catchPhraseAdjective(); -faker.company.catchPhraseDescriptor(); -faker.company.catchPhraseNoun(); -faker.company.bsAdjective(); -faker.company.bsBuzz(); -faker.company.bsNoun(); +resultStr = faker.commerce.color(); +resultStr = faker.commerce.department(); +resultStr = faker.commerce.productName(); +resultStr = faker.commerce.price(); +resultStr = faker.commerce.price(0, 0, 0, '#'); +resultStr = faker.commerce.productAdjective(); +resultStr = faker.commerce.productMaterial(); +resultStr = faker.commerce.product(); -faker.date.past(); -faker.date.future(); -faker.date.between('foo', 'bar'); -faker.date.between(new Date(), new Date()); -faker.date.recent(); -faker.date.recent(100); -faker.date.month(); -faker.date.month({ +resultStrArr = faker.company.suffixes(); +resultStr = faker.company.companyName(); +resultStr = faker.company.companyName(0); +resultStr = faker.company.companySuffix(); +resultStr = faker.company.catchPhrase(); +resultStr = faker.company.bs(); +resultStr = faker.company.catchPhraseAdjective(); +resultStr = faker.company.catchPhraseDescriptor(); +resultStr = faker.company.catchPhraseNoun(); +resultStr = faker.company.bsAdjective(); +resultStr = faker.company.bsBuzz(); +resultStr = faker.company.bsNoun(); + +resultDate = faker.date.past(); +resultDate = faker.date.future(); +resultDate = faker.date.between('foo', 'bar'); +resultDate = faker.date.between(new Date(), new Date()); +resultDate = faker.date.recent(); +resultDate = faker.date.recent(100); +resultStr = faker.date.month(); +resultStr = faker.date.month({ abbr: true, context: true }); -faker.date.weekday(); -faker.date.weekday({ +resultStr = faker.date.weekday(); +resultStr = faker.date.weekday({ abbr: true, context: true }); -faker.finance.account(); -faker.finance.account(0); -faker.finance.accountName(); -faker.finance.mask(); -faker.finance.mask(0, false, false); -faker.finance.amount(); -faker.finance.amount(0, 0, 0, '#'); -faker.finance.transactionType(); -faker.finance.currencyCode(); -faker.finance.currencyName(); -faker.finance.currencySymbol(); +resultStr = faker.finance.account(); +resultStr = faker.finance.account(0); +resultStr = faker.finance.accountName(); +resultStr = faker.finance.mask(); +resultStr = faker.finance.mask(0, false, false); +resultStr = faker.finance.amount(); +resultStr = faker.finance.amount(0, 0, 0, '#'); +resultStr = faker.finance.transactionType(); +resultStr = faker.finance.currencyCode(); +resultStr = faker.finance.currencyName(); +resultStr = faker.finance.currencySymbol(); -faker.hacker.abbreviation(); -faker.hacker.adjective(); -faker.hacker.noun(); -faker.hacker.verb(); -faker.hacker.ingverb(); -faker.hacker.phrase(); +resultStr = faker.hacker.abbreviation(); +resultStr = faker.hacker.adjective(); +resultStr = faker.hacker.noun(); +resultStr = faker.hacker.verb(); +resultStr = faker.hacker.ingverb(); +resultStr = faker.hacker.phrase(); -faker.helpers.randomize(); -faker.helpers.randomize([1,2,3,4]); -faker.helpers.randomize(['foo', 'bar', 'quux']); -faker.helpers.slugify('foo bar quux'); -faker.helpers.replaceSymbolWithNumber('foo# bar#'); -faker.helpers.replaceSymbols('foo# bar? quux#'); -faker.helpers.shuffle(['foo', 'bar', 'quux']); -faker.helpers.mustache('{{foo}}{{bar}}', {foo: 'x', bar: 'y'}); -faker.helpers.createCard(); -faker.helpers.contextualCard(); -faker.helpers.userCard(); +resultStr = faker.helpers.randomize(); +resultNum = faker.helpers.randomize([1,2,3,4]); +resultStr = faker.helpers.randomize(['foo', 'bar', 'quux']); +resultStr = faker.helpers.slugify('foo bar quux'); +resultStr = faker.helpers.replaceSymbolWithNumber('foo# bar#'); +resultStr = faker.helpers.replaceSymbols('foo# bar? quux#'); +resultStrArr = faker.helpers.shuffle(['foo', 'bar', 'quux']); +resultStr = faker.helpers.mustache('{{foo}}{{bar}}', {foo: 'x', bar: 'y'}); -faker.internet.avatar(); -faker.internet.email(); -faker.internet.email('foo', 'bar', 'quux'); -faker.internet.protocol(); -faker.internet.url(); -faker.internet.domainName(); -faker.internet.domainSuffix(); -faker.internet.domainWord(); -faker.internet.ip(); -faker.internet.userAgent(); -faker.internet.color(); -faker.internet.color(0, 0, 0); -faker.internet.mac(); -faker.internet.password(); -faker.internet.password(0, false, '#', 'foo'); +const card = faker.helpers.createCard(); +resultStr = card.name; +resultStr = card.address.streetA; +const contextualCard = faker.helpers.contextualCard(); +resultStr = contextualCard.name; +resultStr = contextualCard.address.suite; +const userCard = faker.helpers.userCard(); +resultStr = userCard.name; +resultStr = userCard.address.suite; -faker.lorem.words(); -faker.lorem.words(0); -faker.lorem.sentence(); -faker.lorem.sentence(0, 0); -faker.lorem.sentences(); -faker.lorem.sentences(0); -faker.lorem.paragraph(); -faker.lorem.paragraph(0); -faker.lorem.paragraphs(); -faker.lorem.paragraphs(0, ''); +resultStr = faker.internet.avatar(); +resultStr = faker.internet.email(); +resultStr = faker.internet.email('foo', 'bar', 'quux'); +resultStr = faker.internet.protocol(); +resultStr = faker.internet.url(); +resultStr = faker.internet.domainName(); +resultStr = faker.internet.domainSuffix(); +resultStr = faker.internet.domainWord(); +resultStr = faker.internet.ip(); +resultStr = faker.internet.userAgent(); +resultStr = faker.internet.color(); +resultStr = faker.internet.color(0, 0, 0); +resultStr = faker.internet.mac(); +resultStr = faker.internet.password(); +resultStr = faker.internet.password(0, false, '#', 'foo'); -faker.name.firstName(); -faker.name.firstName(0); -faker.name.lastName(); -faker.name.lastName(0); -faker.name.findName(); -faker.name.findName('', '', 0); -faker.name.jobTitle(); -faker.name.prefix(); -faker.name.suffix(); -faker.name.title(); -faker.name.jobDescriptor(); -faker.name.jobArea(); -faker.name.jobType(); +resultStrArr = faker.lorem.words(); +resultStrArr = faker.lorem.words(0); +resultStr = faker.lorem.sentence(); +resultStr = faker.lorem.sentence(0, 0); +resultStr = faker.lorem.sentences(); +resultStr = faker.lorem.sentences(0); +resultStr = faker.lorem.paragraph(); +resultStr = faker.lorem.paragraph(0); +resultStr = faker.lorem.paragraphs(); +resultStr = faker.lorem.paragraphs(0, ''); -faker.phone.phoneNumber(); -faker.phone.phoneNumber('#'); -faker.phone.phoneNumberFormat(); +resultStr = faker.name.firstName(); +resultStr = faker.name.firstName(0); +resultStr = faker.name.lastName(); +resultStr = faker.name.lastName(0); +resultStr = faker.name.findName(); +resultStr = faker.name.findName('', '', 0); +resultStr = faker.name.jobTitle(); +resultStr = faker.name.prefix(); +resultStr = faker.name.suffix(); +resultStr = faker.name.title(); +resultStr = faker.name.jobDescriptor(); +resultStr = faker.name.jobArea(); +resultStr = faker.name.jobType(); + +resultStr = faker.phone.phoneNumber(); +resultStr = faker.phone.phoneNumber('#'); +resultStr = faker.phone.phoneNumberFormat(); // https://github.com/Marak/faker.js/blob/master/lib/phone_number.js#L9-L13 -faker.phone.phoneNumberFormat(0); -faker.phone.phoneFormats(); +resultStr = faker.phone.phoneNumberFormat(0); +resultStr = faker.phone.phoneFormats(); -faker.random.number(); -faker.random.number(0); -faker.random.number({ +resultNum = faker.random.number(); +resultNum = faker.random.number(0); +resultNum = faker.random.number({ min: 0, max: 0, precision: 0 }); -faker.random.arrayElement(); -faker.random.arrayElement(['foo', 'bar', 'quux']) -faker.random.objectElement(); -faker.random.objectElement({foo: 'bar', field: 'foo'}); -faker.random.uuid(); -faker.random.boolean(); \ No newline at end of file +resultStr = faker.random.arrayElement(); +resultStr = faker.random.arrayElement(['foo', 'bar', 'quux']) +resultStr = faker.random.objectElement(); +resultStr = faker.random.objectElement({foo: 'bar', field: 'foo'}); +resultStr = faker.random.uuid(); +resultBool = faker.random.boolean(); From ad28dfc40bb80209cc4f058f526d465d01dc5e81 Mon Sep 17 00:00:00 2001 From: Kuniwak Date: Fri, 18 Sep 2015 21:36:26 +0900 Subject: [PATCH 023/146] Should support locales --- faker/faker-tests.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/faker/faker-tests.ts b/faker/faker-tests.ts index 324ca4835..db953fd83 100644 --- a/faker/faker-tests.ts +++ b/faker/faker-tests.ts @@ -1,13 +1,14 @@ /// -import faker = require('faker'); - let resultStr: string; let resultBool: boolean; let resultNum: number; let resultStrArr: string[]; let resultDate: Date; +import faker = require('faker'); +faker.locale = 'en'; + resultStr = faker.address.zipCode(); resultStr = faker.address.zipCode('###'); resultStr = faker.address.city(); @@ -167,3 +168,6 @@ resultStr = faker.random.objectElement(); resultStr = faker.random.objectElement({foo: 'bar', field: 'foo'}); resultStr = faker.random.uuid(); resultBool = faker.random.boolean(); + +import fakerEn = require('faker/locale/en'); +resultStr = faker.name.firstName(); From 9f88f346020904666a38bb97e76cfa7469f5becf Mon Sep 17 00:00:00 2001 From: Kuniwak Date: Fri, 18 Sep 2015 21:37:32 +0900 Subject: [PATCH 024/146] Make test pass --- faker/faker.d.ts | 590 +++++++++++++++++++++++++++++------------------ 1 file changed, 365 insertions(+), 225 deletions(-) diff --git a/faker/faker.d.ts b/faker/faker.d.ts index b337c093e..6397dd993 100644 --- a/faker/faker.d.ts +++ b/faker/faker.d.ts @@ -1,58 +1,223 @@ // Type definitions for faker // Project: http://marak.com/faker.js/ -// Definitions by: Bas Pennings +// Definitions by: Bas Pennings , Yuki Kokubun // Definitions: https://github.com/borisyankov/DefinitelyTyped +declare var fakerStatic: Faker.FakerStatic; + declare module Faker { + interface FakerStatic { + locale: string; + + address: { + zipCode(format?: string): string; + city(format?: number): string; + cityPrefix(): string; + citySuffix(): string; + streetName(): string; + streetAddress(useFullAddress?: boolean): string; + streetSuffix(): string; + streetPrefix(): string; + secondaryAddress(): string; + county(): string; + country(): string; + countryCode(): string; + state(useAbbr?: boolean): string; + stateAbbr(): string; + latitude(): string; + longitude(): string; + }; + + commerce: { + color(): string; + department(): string; + productName(): string; + price(min?: number, max?: number, dec?: number, symbol?: string): string; + productAdjective(): string; + productMaterial(): string; + product(): string; + }; + + company: { + suffixes(): string[]; + companyName(format?: number): string; + companySuffix(): string; + catchPhrase(): string; + bs(): string; + catchPhraseAdjective(): string; + catchPhraseDescriptor(): string; + catchPhraseNoun(): string; + bsAdjective(): string; + bsBuzz(): string; + bsNoun(): string; + }; + + date: { + past(years?: number, refDate?: string|Date): Date; + future(years?: number, refDate?: string|Date): Date; + between(from: string|number|Date, to: string|Date): Date; + recent(days?: number): Date; + month(options?: { abbr?: boolean, context?: boolean }): string; + weekday(options?: { abbr?: boolean, context?: boolean }): string; + }; + + fake(str: string): string; + + finance: { + account(length?: number): string; + accountName(): string; + mask(length?: number, parens?: boolean, elipsis?: boolean): string; + amount(min?:number, max?: number, dec?: number, symbol?: string): string; + transactionType(): string; + currencyCode(): string; + currencyName(): string; + currencySymbol(): string; + }; + + hacker: { + abbreviation(): string; + adjective(): string; + noun(): string; + verb(): string; + ingverb(): string; + phrase(): string; + }; + + helpers: { + randomize(array: T[]): T; + randomize(): string; + slugify(string?: string): string; + replaceSymbolWithNumber(string?: string, symbol?: string): string; + replaceSymbols(string?: string): string; + shuffle(o: T[]): T[]; + shuffle(): string[]; + mustache(str: string, data: { [key: string]: string|((substring: string, ...args: any[]) => string) }): string; + createCard(): Faker.Card; + contextualCard(): Faker.ContextualCard; + userCard(): Faker.UserCard; + createTransaction(): Faker.Transaction; + }; + + + image: { + image(): string; + avatar(): string; + imageUrl(width?: number, height?: number, category?: string): string; + abstract(width?: number, height?: number): string; + animals(width?: number, height?: number): string; + business(width?: number, height?: number): string; + cats(width?: number, height?: number): string; + city(width?: number, height?: number): string; + food(width?: number, height?: number): string; + nightlife(width?: number, height?: number): string; + fashion(width?: number, height?: number): string; + people(width?: number, height?: number): string; + nature(width?: number, height?: number): string; + sports(width?: number, height?: number): string; + technics(width?: number, height?: number): string; + transport(width?: number, height?: number): string; + }; + + internet: { + avatar(): string; + email(firstName?: string, lastName?: string, provider?: string): string; + userName(firstName?: string, lastName?: string): string; + protocol(): string; + url(): string; + domainName(): string; + domainSuffix(): string; + domainWord(): string; + ip(): string; + userAgent(): string; + color(baseRed255?: number, baseGreen255?: number, baseBlue255?: number): string; + mac(): string; + password(len?: number, memorable?: boolean, pattern?: string|RegExp, prefix?: string): string; + }; + + lorem: { + words(num?: number): string[]; + sentence(wordCount?: number, range?: number): string; + sentences(sentenceCount?: number): string; + paragraph(sentenceCount?: number): string; + paragraphs(paragraphCount?: number, separator?: string): string; + }; + + name: { + firstName(gender?: number): string; + lastName(gender?: number): string; + findName(firstName?: string, lastName?: string, gender?: number): string; + jobTitle(): string; + prefix(): string; + suffix(): string; + title(): string; + jobDescriptor(): string; + jobArea(): string; + jobType(): string; + }; + + phone: { + phoneNumber(format?: string): string; + phoneNumberFormat(phoneFormatsArrayIndex?: number): string; + phoneFormats(): string; + }; + + random: { + number(max: number): number; + number(options?: { min?: number, max?: number, precision?: number }): number; + arrayElement(): string; + arrayElement(array: T[]): T; + objectElement(object?: { [key: string]: any }, field?: "key"): string; + objectElement(object?: { [key: string]: T }, field?: any): T; + uuid(): string; + boolean(): boolean; + }; + } + + interface Card { + name: string; + username: string; + email: string; + address: FullAddress; + phone: string; + website: string; + company: Company; + posts: Post[]; + accountHistory: string[]; + } + + interface FullAddress { + streetA: string; + streetB: string; + streetC: string; + streetD: string; + city: string; + state: string; + county: string; + zipcode: string; + geo: Geo; + } + + interface Geo { + lat: string; + lng: string; + } + + interface Company { + name: string; + catchPhrase: string; + bs: string; + } + interface Post { words: string; sentence: string; sentences: string; paragraph: string; } - - interface Address { - street: string; - suite: string; - city: string; - zipcode: string; - geo: { - lat: string; - lon: string - } - } - - interface Transaction { - amount: number, - date: Date, - business: string, - name: string, - type: string, - account: string - } - - interface Company { - name: string; - catchPhrase: string; - bs: string; - } - - interface Card { - name: string; - username: string; - email: string; - address: Address; - phone: string, - website: string, - company: Company; - posts: Post[], - accountHistory: Transaction[] - } - + interface ContextualCard { name: string; username: string; - avatar: string; email: string; dob: Date; phone: string; @@ -60,7 +225,16 @@ declare module Faker { website: string; company: Company; } - + + interface Address { + street: string; + suite: string; + city: string; + state: string; + zipcode: string; + geo: Geo; + } + interface UserCard { name: string; username: string; @@ -70,191 +244,157 @@ declare module Faker { website: string; company: Company; } - - interface AddressGenerators { - zipCode(format?: string): string; - city(format?: number): string; - cityPrefix(): string; - citySuffix(): string; - streetName(): string; - streetAddress(useFullAddress?: boolean): string; - streetSuffix(): string; - streetPrefix(): string; - secondaryAddress(): string; - county(): string; - country(): string; - countryCode(): string; - state(useAbbr?: boolean): string; - stateAbbr(): string; - latitude(): string; - longitude(): string; + + interface Transaction { + amount: string; + date: Date; + business: string; + name: string; + type: string; + account: string; } - - interface CommerceGenerators { - color(): string; - department(): string; - productName(): string; - price(min?: number, max?: number, dec?: number, symbol?: string): string; - productAdjective(): string; - productMaterial(): string; - product(): string; - } - - interface CompanyGenerators { - suffixes(): string[]; - companyName(format?: number): string; - companySuffix(): string; - catchPhrase(): string; - bs(): string; - catchPhraseAdjective(): string; - catchPhraseDescriptor(): string; - catchPhraseNoun(): string; - bsAdjective(): string; - bsBuzz(): string; - bsNoun(): string; - } - - interface DateGenerators { - past(years?: number, refDate?: Date|string): Date; - future(years?: number, refDate?: Date|string): Date; - between(from: Date|string, to: Date|string): Date; - recent(days?: number): Date; - month(options?: { - abbr?: boolean, - context?: boolean - }): string; - weekday(options?: { - abbr?: boolean, - context?: boolean - }): string; - } - - interface FinanceGenerators { - account(length?: number): string; - accountName(): string; - mask(length?: number, parens?: boolean, elipsis?: boolean): string; - amount(min?: number, max?: number, dec?: number, symbol?: string): string; - transactionType(): string; - currencyCode(): string; - currencyName(): string; - currencySymbol(): string; - } - - interface HackerGenerators { - abbreviation(): string; - adjective(): string; - noun(): string; - verb(): string; - ingverb(): string; - phrase(): string; - } - - interface Helpers { - randomize(array?: Array): T; - slugify(str: string): string; - replaceSymbolWithNumber(s: string, symbol?: string): string; - replaceSymbols(str: string): string; - shuffle(array: Array): Array; - mustache(str: string, data: Object): string; - createCard(): Card; - contextualCard(): Card; - userCard(): UserCard; - createTransaction(): Transaction; - } - - interface ImageGenerators { - image(): string; - avator(): string; - imageUrl(width?: number, height?: number, category?: string): string; - abstract(width?: number, height?: number): string; - animals(width?: number, height?: number): string; - business(width?: number, height?: number): string; - cats(width?: number, height?: number): string; - city(width?: number, height?: number): string; - food(width?: number, height?: number): string; - nightlife(width?: number, height?: number): string; - fashion(width?: number, height?: number): string; - people(width?: number, height?: number): string; - nature(width?: number, height?: number): string; - sports(width?: number, height?: number): string; - technics(width?: number, height?: number): string; - transport(width?: number, height?: number): string; - } - - interface InternetGenerators { - avatar(): string; - email(firstName?: string, lastName?: string, provider?: string): string; - userName(firstName?: string, lastName?: string): string; - protocol(): string; - url(): string; - domainName(): string; - domainSuffix(): string; - domainWord(): string; - ip(): string; - userAgent(): string; - color(baseRed255?: number, baseGreen255?: number, baseBlue255?: number): string; - mac(): string; - password(len?: number, memorable?: boolean, pattern?: string, prefix?: string): string; - } - - interface LoremGenerators { - words(num?: number): string[]; - sentence(wordCount?: number, range?: number): string; - sentences(sentenceCount?: number): string; - paragraph(sentenceCount?: number): string; - paragraphs(paragraphCount?: number, separator?: string): string; - } - - interface NameGenerators { - firstName(gender?: number): string; - lastName(gender?: number): string; - findName(firstName?: string, lastName?: string, gender?: number): string; - jobTitle(): string; - prefix(): string; - suffix(): string; - title(): string; - jobDescriptor(): string; - jobArea(): string; - jobType(): string; - } - - interface PhoneGenerators { - phoneNumber(format?: string): string; - // https://github.com/Marak/faker.js/blob/master/lib/phone_number.js#L9-L13 - phoneNumberFormat(phoneFormatsArrayIndex?: number): string; - phoneFormats(): string; - } - - interface RandomGenerators { - number(max: number): number; - number(options?: { - min?: number, - max?: number, - precision?: number - }): number; - arrayElement(array?: Array): T; - objectElement(object?: Object, field?: string): any; - uuid(): string; - boolean(): boolean; - } } declare module "faker" { - var faker: { - address: Faker.AddressGenerators; - commerce: Faker.CommerceGenerators; - company: Faker.CompanyGenerators; - date: Faker.DateGenerators; - finance: Faker.FinanceGenerators; - hacker: Faker.HackerGenerators; - helpers: Faker.Helpers; - image: Faker.ImageGenerators; - internet: Faker.InternetGenerators; - lorem: Faker.LoremGenerators; - name: Faker.NameGenerators; - phone: Faker.PhoneGenerators; - random: Faker.RandomGenerators; - } - - export = faker; + export = fakerStatic; +} + +declare module "faker/locale/de" { + export = fakerStatic; +} + +declare module "faker/locale/de_AT" { + export = fakerStatic; +} + +declare module "faker/locale/de_CH" { + export = fakerStatic; +} + +declare module "faker/locale/el_GR" { + export = fakerStatic; +} + +declare module "faker/locale/en" { + export = fakerStatic; +} + +declare module "faker/locale/en_AU" { + export = fakerStatic; +} + +declare module "faker/locale/en_BORK" { + export = fakerStatic; +} + +declare module "faker/locale/en_CA" { + export = fakerStatic; +} + +declare module "faker/locale/en_GB" { + export = fakerStatic; +} + +declare module "faker/locale/en_IE" { + export = fakerStatic; +} + +declare module "faker/locale/en_IND" { + export = fakerStatic; +} + +declare module "faker/locale/en_US" { + export = fakerStatic; +} + +declare module "faker/locale/en_au_ocker" { + export = fakerStatic; +} + +declare module "faker/locale/es" { + export = fakerStatic; +} + +declare module "faker/locale/es_MX" { + export = fakerStatic; +} + +declare module "faker/locale/fa" { + export = fakerStatic; +} + +declare module "faker/locale/fr" { + export = fakerStatic; +} + +declare module "faker/locale/fr_CA" { + export = fakerStatic; +} + +declare module "faker/locale/ge" { + export = fakerStatic; +} + +declare module "faker/locale/it" { + export = fakerStatic; +} + +declare module "faker/locale/ja" { + export = fakerStatic; +} + +declare module "faker/locale/ko" { + export = fakerStatic; +} + +declare module "faker/locale/nb_NO" { + export = fakerStatic; +} + +declare module "faker/locale/nep" { + export = fakerStatic; +} + +declare module "faker/locale/nl" { + export = fakerStatic; +} + +declare module "faker/locale/pl" { + export = fakerStatic; +} + +declare module "faker/locale/pt_BR" { + export = fakerStatic; +} + +declare module "faker/locale/ru" { + export = fakerStatic; +} + +declare module "faker/locale/sk" { + export = fakerStatic; +} + +declare module "faker/locale/sv" { + export = fakerStatic; +} + +declare module "faker/locale/tr" { + export = fakerStatic; +} + +declare module "faker/locale/uk" { + export = fakerStatic; +} + +declare module "faker/locale/vi" { + export = fakerStatic; +} + +declare module "faker/locale/zh_CN" { + export = fakerStatic; +} + +declare module "faker/locale/zh_TW" { + export = fakerStatic; } From 46816bd92d248381a145c7a32b9e204dd68491e7 Mon Sep 17 00:00:00 2001 From: Robert Imig Date: Fri, 18 Sep 2015 14:05:27 -0400 Subject: [PATCH 025/146] Leaflet: Add LeafletLayersControlEvent --- leaflet/leaflet-tests.ts | 5 +++++ leaflet/leaflet.d.ts | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/leaflet/leaflet-tests.ts b/leaflet/leaflet-tests.ts index 6bec7e217..830fd9102 100755 --- a/leaflet/leaflet-tests.ts +++ b/leaflet/leaflet-tests.ts @@ -148,6 +148,11 @@ map.closePopup(); map.addControl(L.control.attribution({position: 'bottomright'})); map.removeControl(L.control.attribution({ position: 'bottomright' })); +L.control.layers({'Base': layer}).addTo(map); +map.on('baseLayerChange', function(e: L.LeafletLayersControlEvent) { + alert(e.name); +}); + map.latLngToLayerPoint(map.layerPointToLatLng(L.point(0, 0))); map.latLngToContainerPoint(map.containerPointToLatLng(L.point(0, 0))); map.containerPointToLayerPoint(L.point(0, 0)); diff --git a/leaflet/leaflet.d.ts b/leaflet/leaflet.d.ts index 56d702485..56db245a3 100755 --- a/leaflet/leaflet.d.ts +++ b/leaflet/leaflet.d.ts @@ -1835,6 +1835,22 @@ declare module L { } } +declare module L { + + export interface LeafletLayersControlEvent extends LeafletEvent { + + /** + * The layer that was added or removed. + */ + layer: ILayer; + + /** + * The name of the layer that was added or removed. + */ + name: string; + } +} + declare module L { export interface LeafletLocationEvent extends LeafletEvent { From 8b6c5fc20e38c0d925a08e0364896da7634b2174 Mon Sep 17 00:00:00 2001 From: Stephen Lautier Date: Fri, 18 Sep 2015 21:23:42 +0200 Subject: [PATCH 026/146] angular-cookies - added options + minor improvements --- angularjs/angular-cookies.d.ts | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/angularjs/angular-cookies.d.ts b/angularjs/angular-cookies.d.ts index e34518b8a..617b9f793 100644 --- a/angularjs/angular-cookies.d.ts +++ b/angularjs/angular-cookies.d.ts @@ -16,6 +16,30 @@ declare module "angular-cookies" { */ declare module angular.cookies { + /** + * Cookies options + * see https://docs.angularjs.org/api/ngCookies/provider/$cookiesProvider#defaults + */ + interface ICookiesOptions { + /** + * The cookie will be available only for this path and its sub-paths. By default, this would be the URL that appears in your base tag. + */ + path?: string; + /** + * The cookie will be available only for this domain and its sub-domains. + * For obvious security reasons the user agent will not accept the cookie if the current domain is not a sub domain or equals to the requested domain. + */ + domain?: string; + /** + * String of the form "Wdy, DD Mon YYYY HH:MM:SS GMT" or a Date object indicating the exact date/time this cookie will expire. + */ + expires?: string|Date; + /** + * The cookie will be available only in secured connection. + */ + secure?: boolean; + } + /** * CookieService * see http://docs.angularjs.org/api/ngCookies.$cookies @@ -31,10 +55,11 @@ declare module angular.cookies { interface ICookiesService { get(key: string): string; getObject(key: string): any; + getObject(key: string): T; getAll(): any; - put(key: string, value: string, options?: any): void; - putObject(key: string, value: any, options?: any): void; - remove(key: string, options?: any): void; + put(key: string, value: string, options?: ICookiesOptions): void; + putObject(key: string, value: any, options?: ICookiesOptions): void; + remove(key: string, options?: ICookiesOptions): void; } /** From 78cd9fb0e0c9575b32f437c4624fadd54fdcf86a Mon Sep 17 00:00:00 2001 From: Nathan Brown Date: Sat, 19 Sep 2015 19:56:35 -0700 Subject: [PATCH 027/146] New definitions for material-ui. --- material-ui/material-ui-tests.ts | 220 ++++ material-ui/material-ui-tests.tsx | 488 ++++++++ material-ui/material-ui.d.ts | 1913 +++++++++++++++++++++++++++++ 3 files changed, 2621 insertions(+) create mode 100644 material-ui/material-ui-tests.ts create mode 100644 material-ui/material-ui-tests.tsx create mode 100644 material-ui/material-ui.d.ts diff --git a/material-ui/material-ui-tests.ts b/material-ui/material-ui-tests.ts new file mode 100644 index 000000000..3b8b34702 --- /dev/null +++ b/material-ui/material-ui-tests.ts @@ -0,0 +1,220 @@ +// This tests React components, so it is most natural to write the test as a .TSX file, +// however the DefinitelyTyped test runner only accepts .TS files. To convert: +// 1. Save in Visual Studio or otherwise use TSC to save as a "material-ui-tests.js" file. +// 2. Copy the "material-ui-tests.tsx" file to "material-ui-tests.ts". +// 3. Copy the body of "MaterialUiTests.prototype.render = function ()" in "material-ui-tsets.js" +// and replace the body of render() in "material-ui-tests.ts". +// 4. Correct some missing information: +// a. Find "var element;" and change to "let element: React.ReactElement;". +// b. Replace "this.linkState(" with "this.linkState(". +// c. Add generic type help for the Component Property to the remaining errors on +// React.createElement, for example, add "<__MaterialUI.DialogProp>". + +/// +/// + +import * as React from "react/addons"; +import mui = require("material-ui"); +import Colors = require("material-ui/lib/styles/colors"); +import AppBar = require("material-ui/lib/app-bar"); +import IconButton = require("material-ui/lib/icon-button"); +import FlatButton = require("material-ui/lib/flat-button"); +import Avatar = require("material-ui/lib/avatar"); +import FontIcon = require("material-ui/lib/font-icon"); +import Typography = require("material-ui/lib/styles/typography"); +import RaisedButton = require("material-ui/lib/raised-button"); +import FloatingActionButton = require("material-ui/lib/floating-action-button"); +import Card = require("material-ui/lib/card/card"); +import CardHeader = require("material-ui/lib/card/card-header"); +import CardText = require("material-ui/lib/card/card-text"); +import CardActions = require("material-ui/lib/card/card-actions"); +import Dialog = require("material-ui/lib/dialog"); +import DropDownMenu = require("material-ui/lib/drop-down-menu"); +import RadioButtonGroup = require("material-ui/lib/radio-button-group"); +import RadioButton = require("material-ui/lib/radio-button"); +import Toggle = require("material-ui/lib/toggle"); +import TextField = require("material-ui/lib/text-field"); +import SelectField = require("material-ui/lib/select-field"); +import IconMenu = require("material-ui/lib/menus/icon-menu"); +import Menu = require('material-ui/lib/menus/menu'); +import MenuItem = require('material-ui/lib/menus/menu-item'); +import MenuDivider = require('material-ui/lib/menus/menu-divider'); + +import NavigationClose = require("material-ui/lib/svg-icon"); // TODO: Should actually import the actual "material-ui/lib/svg-icons/navigation/close", but they aren't defined yet. +import FileFolder = require("material-ui/lib/svg-icon"); // TODO: Should actually import the actual "material-ui/lib/svg-icons/file/folder", but they aren't defined yet. +import ToggleStar = require("material-ui/lib/svg-icon"); // TODO: Should actually import the actual "material-ui/lib/svg-icons/toggle/star", but they aren't defined yet. +import ActionGrade = require("material-ui/lib/svg-icon"); // TODO: Should actually import the actual "material-ui/lib/svg-icons/action/grade", but they aren't defined yet. +import ToggleStarBorder = require("material-ui/lib/svg-icon"); // TODO: Should actually import the actual "material-ui/lib/svg-icons/toggle/star-border", but they aren't defined yet. +import ArrowDropRight = require("material-ui/lib/svg-icon"); // TODO: Should actually import the actual "material-ui/lib/svg-icons/toggle/star-border", but they aren't defined yet. + +class MaterialUiTests extends React.Component<{}, {}> implements React.LinkedStateMixin { + + // injected with mixin + linkState: (key: string) => React.ReactLink; + dialog: mui.Dialog; + //dialog2: Dialog; // can't get type directly from require("material-ui/lib/dialog"); + + private touchTapEventHandler(e: __MaterialUI.TouchTapEvent) { + this.dialog.show(); + //this.dialog2.show(); + } + private formEventHandler(e: React.FormEvent) { + } + private selectFieldChangeHandler(e: __MaterialUI.TouchTapEvent, si: number, mi: any) { + } + + render() { + // "http://material-ui.com/#/customization/themes" + var ThemeManager = new mui.Styles.ThemeManager(); + ThemeManager.setTheme(ThemeManager.types.LIGHT); + ThemeManager.setTheme(ThemeManager.types.DARK); + var muiTheme = ThemeManager.getCurrentTheme(); + ThemeManager.setComponentThemes({ + toggle: { + thumbOnColor: "#00bcd4", + trackOnColor: "LightCyan", + } + }); + // "http://material-ui.com/#/customization/inline-styles" + var Checkbox = mui.Checkbox; + let element: React.ReactElement; + element = React.createElement(Checkbox, {"id": "checkboxId1", "name": "checkboxName1", "value": "checkboxValue1", "label": "went for a run today", "style": { + width: '50%', + margin: '0 auto' + }, "iconStyle": { + fill: '#FF4081' + }}); + element = React.createElement(Checkbox, { + id: "checkboxId1", name: "checkboxName1", value: "checkboxValue1", label: "went for a run today", style: { + width: '50%', + margin: '0 auto' + }, iconStyle: { + fill: '#FF4081' + } + }); + // "http://material-ui.com/#/customization/colors" + ThemeManager.setComponentThemes({ + toggle: { + thumbOnColor: Colors.cyan200, + thumbOffColor: Colors.grey400, + } + }); + // "http://material-ui.com/#/components/appbar" + element = React.createElement(AppBar, {"title": "Title", "iconClassNameRight": "muidocs-icon-navigation-expand-more"}); + element = React.createElement(AppBar, {"title": "Title", "iconElementLeft": React.createElement(IconButton, null, React.createElement(NavigationClose, null)), "iconElementRight": React.createElement(FlatButton, {"label": "Save"})}); + // "http://material-ui.com/#/components/avatars" + //image avatar + element = React.createElement(Avatar, {"src": "images/uxceo-128.jpg"}); + //SvgIcon avatar + element = React.createElement(Avatar, {"icon": React.createElement(FileFolder, null)}); + //SvgIcon avatar with custom colors + element = React.createElement(Avatar, {"icon": React.createElement(FileFolder, null), "color": Colors.orange200, "backgroundColor": Colors.pink400}); + //FontIcon avatar + element = React.createElement(Avatar, {"icon": React.createElement(FontIcon, {"className": "muidocs-icon-communication-voicemail"})}); + //FontIcon avatar with custom colors + element = React.createElement(Avatar, {"icon": React.createElement(FontIcon, {"className": "muidocs-icon-communication-voicemail"}), "color": Colors.blue300, "backgroundColor": Colors.indigo900}); + //Letter avatar + element = React.createElement(Avatar, null, "A"); + //Letter avatar with custom colors + element = React.createElement(Avatar, {"color": Colors.deepOrange300, "backgroundColor": Colors.purple500}); + // "http://material-ui.com/#/components/buttons" + element = React.createElement(FlatButton, {"linkButton": true, "href": "https://github.com/callemall/material-ui", "secondary": true, "label": "GitHub"}, React.createElement(FontIcon, {"style": { color: Typography.textFullWhite }, "className": "muidocs-icon-custom-github"})); + element = React.createElement(RaisedButton, {"linkButton": true, "href": "https://github.com/callemall/material-ui", "secondary": true, "label": "GitHub"}, React.createElement(FontIcon, {"style": { color: Typography.textFullWhite }, "className": "muidocs-icon-custom-github"})); + element = React.createElement(FloatingActionButton, {"secondary": true, "mini": true, "linkButton": true, "href": "https://github.com/callemall/material-ui"}, React.createElement(ToggleStar, null)); + // "http://material-ui.com/#/components/cards" + element = React.createElement(Card, {"initiallyExpanded": true}, React.createElement(CardHeader, {"title": "Title", "subtitle": "Subtitle", "avatar": React.createElement(Avatar, {"style": { color: 'red' }}, "A"), "showExpandableButton": true}), React.createElement(CardText, {"expandable": true}, "Lorem ipsum dolor sit amet, consectetur adipiscing elit."), React.createElement(CardActions, {"expandable": true}, React.createElement(FlatButton, {"label": "Action1"}), React.createElement(FlatButton, {"label": "Action2"})), React.createElement(CardText, {"expandable": true}, "Lorem ipsum dolor sit amet, consectetur adipiscing elit.")); + // "http://material-ui.com/#/components/date-picker" + // "http://material-ui.com/#/components/dialog" + var standardActions = [ + { text: 'Cancel' }, + { text: 'Submit', onTouchTap: this.touchTapEventHandler, ref: 'submit' } + ]; + element = React.createElement<__MaterialUI.DialogProp>(Dialog, {"title": "Dialog With Standard Actions", "actions": standardActions, "actionFocus": "submit", "modal": true}, "The actions in this window are created from the json that's passed in."); + //Custom Actions + var customActions = [ + React.createElement(FlatButton, {"label": "Cancel", "secondary": true, "onTouchTap": this.touchTapEventHandler}), + React.createElement(FlatButton, {"label": "Submit", "primary": true, "onTouchTap": this.touchTapEventHandler}) + ]; + element = React.createElement(Dialog, {"title": "Dialog With Custom Actions", "actions": customActions, "modal": false, "autoDetectWindowHeight": true, "autoScrollBodyContent": true}, "The actions in this window were passed in as an array of react objects."); + // "http://material-ui.com/#/components/dropdown-menu" + var menuItems = [ + { payload: '1', text: 'Never' }, + { payload: '2', text: 'Every Night' }, + { payload: '3', text: 'Weeknights' }, + { payload: '4', text: 'Weekends' }, + { payload: '5', text: 'Weekly' }, + ]; + element = React.createElement(DropDownMenu, {"menuItems": menuItems}); + // "http://material-ui.com/#/components/icons" + element = React.createElement(FontIcon, {"className": "material-icons", "color": Colors.red500}, " home"); + // "http://material-ui.com/#/components/icon-buttons" + //Method 1: muidocs-icon-github is defined in a style sheet. + element = React.createElement(IconButton, {"iconClassName": "muidocs-icon-custom-github", "tooltip": "GitHub"}); + //Method 2: ActionGrade is a component created using mui.SvgIcon. + element = React.createElement(IconButton, {"tooltip": "Star", "touch": true}, React.createElement(ActionGrade, null)); + //Method 3: Manually creating a mui.FontIcon component within IconButton + element = React.createElement(IconButton, {"tooltip": "Sort", "disabled": true}, React.createElement(FontIcon, {"className": "muidocs-icon-custom-sort"})); + //Method 4: Using Google material-icons + element = React.createElement(IconButton, {"iconClassName": "material-icons", "tooltipPosition": "bottom-center", "tooltip": "Sky"}, "settings_system_daydream"); + // "http://material-ui.com/#/components/icon-menus" + element = React.createElement(IconMenu, {"iconButtonElement": React.createElement(IconButton, null)}, React.createElement(MenuItem, {"primaryText": "Refresh"}), React.createElement(MenuItem, {"primaryText": "Send feedback"}), React.createElement(MenuItem, {"primaryText": "Settings"}), React.createElement(MenuItem, {"primaryText": "Help"}), React.createElement(MenuItem, {"primaryText": "Sign out"})); + // "http://material-ui.com/#/components/left-nav" + // "http://material-ui.com/#/components/lists" + // "http://material-ui.com/#/components/menus" + element = React.createElement(Menu, null, React.createElement(MenuItem, {"primaryText": "Maps"}), React.createElement(MenuItem, {"primaryText": "Books"}), React.createElement(MenuItem, {"primaryText": "Flights"}), React.createElement(MenuItem, {"primaryText": "Apps"})); + element = React.createElement(Menu, {"desktop": true, "width": 320}, React.createElement(MenuItem, {"primaryText": "Bold", "secondaryText": "⌘B"}), React.createElement(MenuItem, {"primaryText": "Italic", "secondaryText": "⌘I"}), React.createElement(MenuItem, {"primaryText": "Underline", "secondaryText": "⌘U"}), React.createElement(MenuItem, {"primaryText": "Strikethrough", "secondaryText": "Alt+Shift+5"}), React.createElement(MenuItem, {"primaryText": "Superscript", "secondaryText": "⌘."}), React.createElement(MenuItem, {"primaryText": "Subscript", "secondaryText": "⌘,"}), React.createElement(MenuDivider, null), React.createElement(MenuItem, {"primaryText": "Paragraph styles", "rightIcon": React.createElement(ArrowDropRight, null)}), React.createElement(MenuItem, {"primaryText": "Align", "rightIcon": React.createElement(ArrowDropRight, null)}), React.createElement(MenuItem, {"primaryText": "Line spacing", "rightIcon": React.createElement(ArrowDropRight, null)}), React.createElement(MenuItem, {"primaryText": "Numbered list", "rightIcon": React.createElement(ArrowDropRight, null)}), React.createElement(MenuItem, {"primaryText": "List options", "rightIcon": React.createElement(ArrowDropRight, null)}), React.createElement(MenuDivider, null), React.createElement(MenuItem, {"primaryText": "Clear formatting", "secondaryText": "⌘/"})); + // "http://material-ui.com/#/components/paper" + // "http://material-ui.com/#/components/progress" + // "http://material-ui.com/#/components/refresh-indicator" + // "http://material-ui.com/#/components/sliders" + // "http://material-ui.com/#/components/switches" + element = React.createElement(Checkbox, {"name": "checkboxName2", "value": "checkboxValue2", "label": "fed the dog", "defaultChecked": true}); + element = React.createElement(Checkbox, {"name": "checkboxName3", "value": "checkboxValue3", "label": "built a house on the moon", "disabled": true}); + element = React.createElement<__MaterialUI.CheckboxProp>(Checkbox, {"name": "checkboxName4", "value": "checkboxValue4", "checkedIcon": React.createElement(ToggleStar, null), "unCheckedIcon": React.createElement(ToggleStarBorder, null), "label": "custom icon"}); + element = React.createElement(RadioButtonGroup, {"name": "shipSpeed", "defaultSelected": "not_light"}, React.createElement(RadioButton, {"value": "light", "label": "prepare for light speed", "style": { marginBottom: 16 }}), ";", React.createElement(RadioButton, {"value": "not_light", "label": "light speed too slow", "style": { marginBottom: 16 }}), ";", React.createElement(RadioButton, {"value": "ludicrous", "label": "go to ludicrous speed", "style": { marginBottom: 16 }, "disabled": true})); + element = React.createElement(Toggle, {"name": "toggleName1", "value": "toggleValue1", "label": "activate thrusters"}); + element = React.createElement(Toggle, {"name": "toggleName2", "value": "toggleValue2", "label": "auto-pilot", "defaultToggled": true}); + element = React.createElement(Toggle, {"name": "toggleName3", "value": "toggleValue3", "label": "initiate self-destruct sequence", "disabled": true}); + // "http://material-ui.com/#/components/snackbar" + // "http://material-ui.com/#/components/table" + // "http://material-ui.com/#/components/tabs" + // "http://material-ui.com/#/components/text-fields" + element = React.createElement(TextField, {"hintText": "Hint Text"}); + element = React.createElement(TextField, {"hintText": "Hint Text", "defaultValue": "Default Value"}); + element = React.createElement(TextField, {"hintText": "Hint Text", "value": "value", "underlineStyle": { borderColor: Colors.green500 }, "onChange": this.formEventHandler}); + element = React.createElement(TextField, {"hintText": "Custom Underline Focus Color", "underlineFocusStyle": { borderColor: Colors.amber900 }}); + element = React.createElement(TextField, {"hintText": "Hint Text", "valueLink": this.linkState('valueLinkValue')}); + element = React.createElement(TextField, {"hintText": "Hint Text (MultiLine)", "multiLine": true}); + element = React.createElement(TextField, {"hintText": "The hint text can be as long as you want, it will wrap.", "multiLine": true}); + element = React.createElement(TextField, {"hintText": "Hint Text", "errorText": "The error text can be as long as you want, it will wrap."}); + element = React.createElement(TextField, {"hintText": "Hint Text", "errorText": "error text", "onChange": this.formEventHandler}); + element = React.createElement(TextField, {"hintText": "Hint Text (custom error color)", "errorText": "error text", "errorStyle": { color: 'orange' }, "onChange": this.formEventHandler, "defaultValue": "Custom error color"}); + element = React.createElement(TextField, {"hintText": "Disabled Hint Text", "disabled": true}); + element = React.createElement(TextField, {"hintText": "Disabled Hint Text", "disabled": true, "defaultValue": "Disabled With Value"}); + //Select Fields + var arbitraryArrayMenuItems = [ + { + id: 0, + name: "zero", + }, + ]; + element = React.createElement(SelectField, {"value": 0, "onChange": this.selectFieldChangeHandler, "hintText": "Hint Text", "menuItems": menuItems}); + element = React.createElement(SelectField, {"valueLink": this.linkState('selectValueLinkValue'), "floatingLabelText": "Float Label Text", "valueMember": "id", "displayMember": "name", "menuItems": arbitraryArrayMenuItems}); + element = React.createElement(SelectField, {"valueLink": this.linkState('selectValueLinkValue2'), "floatingLabelText": "Float Custom Label Text", "floatingLabelStyle": { color: "red" }, "valueMember": "id", "displayMember": "name", "menuItems": arbitraryArrayMenuItems}); + element = React.createElement(SelectField, {"value": 0, "onChange": this.selectFieldChangeHandler, "menuItems": arbitraryArrayMenuItems}); + //Floating Hint Text Labels + element = React.createElement(TextField, {"hintText": "Hint Text", "floatingLabelText": "Floating Label Text"}); + element = React.createElement(TextField, {"hintText": "Hint Text", "defaultValue": "Default Value", "floatingLabelText": "Floating Label Text"}); + element = React.createElement(TextField, {"hintText": "Hint Text", "floatingLabelText": "Floating Label Text", "value": "value", "onChange": this.formEventHandler}); + element = React.createElement(TextField, {"hintText": "Hint Text", "floatingLabelText": "Floating Label Text", "valueLink": this.linkState('floatingValueLinkValue')}); + element = React.createElement(TextField, {"hintText": "Hint Text (MultiLine)", "floatingLabelText": "Floating Label Text", "multiLine": true}); + element = React.createElement(TextField, {"hintText": "Hint Text", "errorText": "floating text", "floatingLabelText": "Floating Label Text", "onChange": this.formEventHandler}); + element = React.createElement(TextField, {"hintText": "Hint Text", "errorText": "error text", "defaultValue": "abc", "floatingLabelText": "Floating Label Text", "onChange": this.formEventHandler}); + element = React.createElement(TextField, {"hintText": "Disabled Hint Text", "disabled": true, "floatingLabelText": "Floating Label Text"}); + element = React.createElement(TextField, {"hintText": "Disabled Hint Text", "disabled": true, "defaultValue": "Disabled With Value", "floatingLabelText": "Floating Label Text"}); + element = React.createElement(TextField, {"hintText": "Password Field", "floatingLabelText": "Password", "type": "password"}); + // "http://material-ui.com/#/components/time-picker" + // "http://material-ui.com/#/components/toolbars" + return element; + } +} \ No newline at end of file diff --git a/material-ui/material-ui-tests.tsx b/material-ui/material-ui-tests.tsx new file mode 100644 index 000000000..accae0d71 --- /dev/null +++ b/material-ui/material-ui-tests.tsx @@ -0,0 +1,488 @@ +// This tests React components, so it is most natural to write the test as a .TSX file, +// however the DefinitelyTyped test runner only accepts .TS files. To convert: +// 1. Save in Visual Studio or otherwise use TSC to save as a "material-ui-tests.js" file. +// 2. Copy the "material-ui-tests.tsx" file to "material-ui-tests.ts". +// 3. Copy the body of "MaterialUiTests.prototype.render = function ()" in "material-ui-tsets.js" +// and replace the body of render() in "material-ui-tests.ts". +// 4. Correct some missing information: +// a. Find "var element;" and change to "let element: React.ReactElement;". +// b. Replace "this.linkState(" with "this.linkState(". +// c. Add generic type help for the Component Property to the remaining errors on +// React.createElement, for example, add "<__MaterialUI.DialogProp>". + +/// +/// + +import * as React from "react/addons"; +import mui = require("material-ui"); +import Colors = require("material-ui/lib/styles/colors"); +import AppBar = require("material-ui/lib/app-bar"); +import IconButton = require("material-ui/lib/icon-button"); +import FlatButton = require("material-ui/lib/flat-button"); +import Avatar = require("material-ui/lib/avatar"); +import FontIcon = require("material-ui/lib/font-icon"); +import Typography = require("material-ui/lib/styles/typography"); +import RaisedButton = require("material-ui/lib/raised-button"); +import FloatingActionButton = require("material-ui/lib/floating-action-button"); +import Card = require("material-ui/lib/card/card"); +import CardHeader = require("material-ui/lib/card/card-header"); +import CardText = require("material-ui/lib/card/card-text"); +import CardActions = require("material-ui/lib/card/card-actions"); +import Dialog = require("material-ui/lib/dialog"); +import DropDownMenu = require("material-ui/lib/drop-down-menu"); +import RadioButtonGroup = require("material-ui/lib/radio-button-group"); +import RadioButton = require("material-ui/lib/radio-button"); +import Toggle = require("material-ui/lib/toggle"); +import TextField = require("material-ui/lib/text-field"); +import SelectField = require("material-ui/lib/select-field"); +import IconMenu = require("material-ui/lib/menus/icon-menu"); +import Menu = require('material-ui/lib/menus/menu'); +import MenuItem = require('material-ui/lib/menus/menu-item'); +import MenuDivider = require('material-ui/lib/menus/menu-divider'); + +import NavigationClose = require("material-ui/lib/svg-icon"); // TODO: Should actually import the actual "material-ui/lib/svg-icons/navigation/close", but they aren't defined yet. +import FileFolder = require("material-ui/lib/svg-icon"); // TODO: Should actually import the actual "material-ui/lib/svg-icons/file/folder", but they aren't defined yet. +import ToggleStar = require("material-ui/lib/svg-icon"); // TODO: Should actually import the actual "material-ui/lib/svg-icons/toggle/star", but they aren't defined yet. +import ActionGrade = require("material-ui/lib/svg-icon"); // TODO: Should actually import the actual "material-ui/lib/svg-icons/action/grade", but they aren't defined yet. +import ToggleStarBorder = require("material-ui/lib/svg-icon"); // TODO: Should actually import the actual "material-ui/lib/svg-icons/toggle/star-border", but they aren't defined yet. +import ArrowDropRight = require("material-ui/lib/svg-icon"); // TODO: Should actually import the actual "material-ui/lib/svg-icons/toggle/star-border", but they aren't defined yet. + +class MaterialUiTests extends React.Component<{}, {}> implements React.LinkedStateMixin { + + // injected with mixin + linkState: (key: string) => React.ReactLink; + dialog: mui.Dialog; + //dialog2: Dialog; // can't get type directly from require("material-ui/lib/dialog"); + + private touchTapEventHandler(e: __MaterialUI.TouchTapEvent) { + this.dialog.show(); + //this.dialog2.show(); + } + private formEventHandler(e: React.FormEvent) { + } + private selectFieldChangeHandler(e: __MaterialUI.TouchTapEvent, si: number, mi: any) { + } + + render() { + + // "http://material-ui.com/#/customization/themes" + let ThemeManager = new mui.Styles.ThemeManager(); + ThemeManager.setTheme(ThemeManager.types.LIGHT); + ThemeManager.setTheme(ThemeManager.types.DARK); + let muiTheme: __MaterialUI.Styles.CustomTheme = ThemeManager.getCurrentTheme(); + ThemeManager.setComponentThemes({ + toggle: { + thumbOnColor: "#00bcd4", + trackOnColor: "LightCyan", + } + }); + + // "http://material-ui.com/#/customization/inline-styles" + let Checkbox = mui.Checkbox; + let element: React.ReactElement; + element = + element = React.createElement<__MaterialUI.CheckboxProp>(Checkbox, { + id: "checkboxId1", name: "checkboxName1", value: "checkboxValue1", label: "went for a run today", style: { + width: '50%', + margin: '0 auto' + }, iconStyle: { + fill: '#FF4081' + } + }); + + // "http://material-ui.com/#/customization/colors" + ThemeManager.setComponentThemes({ + toggle: { + thumbOnColor: Colors.cyan200, + thumbOffColor: Colors.grey400, + } + }); + + // "http://material-ui.com/#/components/appbar" + element = + element = } + iconElementRight={} />; + + // "http://material-ui.com/#/components/avatars" + //image avatar + element = ; + //SvgIcon avatar + element = } />; + //SvgIcon avatar with custom colors + element = } + color={Colors.orange200} + backgroundColor={Colors.pink400} />; + //FontIcon avatar + element = + } />; + //FontIcon avatar with custom colors + element = } + color={Colors.blue300} + backgroundColor={Colors.indigo900} />; + //Letter avatar + element = A; + //Letter avatar with custom colors + element = + + + + // "http://material-ui.com/#/components/buttons" + element = + + ; + element = + + ; + element = + + ; + + // "http://material-ui.com/#/components/cards" + element = + A} + showExpandableButton={true}> + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. + + + + + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. + + ; + + // "http://material-ui.com/#/components/date-picker" + + + // "http://material-ui.com/#/components/dialog" + let standardActions = [ + { text: 'Cancel' }, + { text: 'Submit', onTouchTap: this.touchTapEventHandler, ref: 'submit' } + ]; + + element = + The actions in this window are created from the json that's passed in. + ; + + //Custom Actions + let customActions = [ + , + + ]; + + element = + The actions in this window were passed in as an array of react objects. + ; + + + // "http://material-ui.com/#/components/dropdown-menu" + let menuItems = [ + { payload: '1', text: 'Never' }, + { payload: '2', text: 'Every Night' }, + { payload: '3', text: 'Weeknights' }, + { payload: '4', text: 'Weekends' }, + { payload: '5', text: 'Weekly' }, + ]; + element = ; + + // "http://material-ui.com/#/components/icons" + element = home; + + // "http://material-ui.com/#/components/icon-buttons" + //Method 1: muidocs-icon-github is defined in a style sheet. + element = ; + //Method 2: ActionGrade is a component created using mui.SvgIcon. + element = + + ; + //Method 3: Manually creating a mui.FontIcon component within IconButton + element = + + ; + //Method 4: Using Google material-icons + element = settings_system_daydream; + + // "http://material-ui.com/#/components/icon-menus" + element = }> + + + + + + ; + + // "http://material-ui.com/#/components/left-nav" + + + // "http://material-ui.com/#/components/lists" + + + // "http://material-ui.com/#/components/menus" + element = + + + + + ; + element = + + + + + + + + } /> + } /> + } /> + } /> + } /> + + + ; + + // "http://material-ui.com/#/components/paper" + + + // "http://material-ui.com/#/components/progress" + + + // "http://material-ui.com/#/components/refresh-indicator" + + + // "http://material-ui.com/#/components/sliders" + + + // "http://material-ui.com/#/components/switches" + element = ; + element = ; + element = } + unCheckedIcon={} + label="custom icon" />; + + element = + ; + ; + + ; + + element = ; + + element = ; + + element = ; + + // "http://material-ui.com/#/components/snackbar" + + + // "http://material-ui.com/#/components/table" + + + // "http://material-ui.com/#/components/tabs" + + + // "http://material-ui.com/#/components/text-fields" + element = ; + element = ; + element = ; + element = ; + element = ('valueLinkValue') } />; + element = ; + element = ; + element = ; + element = ; + element = ; + element = ; + element = ; + + //Select Fields + let arbitraryArrayMenuItems = [ + { + id: 0, + name: "zero", + }, + ]; + element = ; + element = ; + element = ; + element = ; + + //Floating Hint Text Labels + element = ; + element = ; + element = ; + element = ('floatingValueLinkValue') } />; + element = ; + element = ; + element = ; + element = ; + element = ; + element = ; + + + // "http://material-ui.com/#/components/time-picker" + + + // "http://material-ui.com/#/components/toolbars" + + return element; + } +} \ No newline at end of file diff --git a/material-ui/material-ui.d.ts b/material-ui/material-ui.d.ts new file mode 100644 index 000000000..85afdb2bc --- /dev/null +++ b/material-ui/material-ui.d.ts @@ -0,0 +1,1913 @@ +// Type definitions for material-ui v0.11.1 +// Project: https://github.com/callemall/material-ui +// Definitions by: Nathan Brown +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "material-ui" { + // The reason for exporting the namespace types (__MaterialUI.*) is to also export the type for casting variable. + + export import AppBar = __MaterialUI.AppBar; // require('material-ui/lib/app-bar'); + export import AppCanvas = __MaterialUI.AppCanvas; // require('material-ui/lib/app-canvas'); + export import Avatar = __MaterialUI.Avatar; // require('material-ui/lib/avatar'); + export import BeforeAfterWrapper = __MaterialUI.BeforeAfterWrapper; // require('material-ui/lib/before-after-wrapper'); + export import Card = __MaterialUI.Card.Card; // require('material-ui/lib/card/card'); + export import CardActions = __MaterialUI.Card.CardActions; // require('material-ui/lib/card/card-actions'); + export import CardExpandable = __MaterialUI.Card.CardExpandable; // require('material-ui/lib/card/card-expandable'); + export import CardHeader = __MaterialUI.Card.CardHeader; // require('material-ui/lib/card/card-header'); + export import CardMedia = __MaterialUI.Card.CardMedia; // require('material-ui/lib/card/card-media'); + export import CardText = __MaterialUI.Card.CardText; // require('material-ui/lib/card/card-text'); + export import CardTitle = __MaterialUI.Card.CardTitle; // require('material-ui/lib/card/card-title'); + export import Checkbox = __MaterialUI.Checkbox; // require('material-ui/lib/checkbox'); + export import CircularProgress = __MaterialUI.CircularProgress; // require('material-ui/lib/circular-progress'); + export import ClearFix = __MaterialUI.ClearFix; // require('material-ui/lib/clearfix'); + export import DatePicker = __MaterialUI.DatePicker.DatePicker; // require('material-ui/lib/date-picker/date-picker'); + export import DatePickerDialog = __MaterialUI.DatePicker.DatePickerDialog; // require('material-ui/lib/date-picker/date-picker-dialog'); + export import DialogAction = __MaterialUI.DialogAction; // type definition + export import Dialog = __MaterialUI.Dialog // require('material-ui/lib/dialog'); + export import DropDownIcon = __MaterialUI.DropDownIcon; // require('material-ui/lib/drop-down-icon'); + export import DropDownMenu = __MaterialUI.DropDownMenu; // require('material-ui/lib/drop-down-menu'); + export import EnhancedButton = __MaterialUI.EnhancedButton; // require('material-ui/lib/enhanced-button'); + export import FlatButton = __MaterialUI.FlatButton; // require('material-ui/lib/flat-button'); + export import FloatingActionButton = __MaterialUI.FloatingActionButton; // require('material-ui/lib/floating-action-button'); + export import FontIcon = __MaterialUI.FontIcon; // require('material-ui/lib/font-icon'); + export import IconButton = __MaterialUI.IconButton; // require('material-ui/lib/icon-button'); + export import IconMenu = __MaterialUI.Menus.IconMenu; // require('material-ui/lib/menus/icon-menu'); + export import LeftNav = __MaterialUI.LeftNav; // require('material-ui/lib/left-nav'); + export import LinearProgress = __MaterialUI.LinearProgress; // require('material-ui/lib/linear-progress'); + export import List = __MaterialUI.Lists.List; // require('material-ui/lib/lists/list'); + export import ListDivider = __MaterialUI.Lists.ListDivider; // require('material-ui/lib/lists/list-divider'); + export import ListItem = __MaterialUI.Lists.ListItem; // require('material-ui/lib/lists/list-item'); + export import Menu = __MaterialUI.Menu.Menu; // require('material-ui/lib/menu/menu'); + export import MenuItem = __MaterialUI.Menu.MenuItem; // require('material-ui/lib/menu/menu-item'); + export import Mixins = __MaterialUI.Mixins; // require('material-ui/lib/mixins/'); + export import Overlay = __MaterialUI.Overlay; // require('material-ui/lib/overlay'); + export import Paper = __MaterialUI.Paper; // require('material-ui/lib/paper'); + export import RadioButton = __MaterialUI.RadioButton; // require('material-ui/lib/radio-button'); + export import RadioButtonGroup = __MaterialUI.RadioButtonGroup; // require('material-ui/lib/radio-button-group'); + export import RaisedButton = __MaterialUI.RaisedButton; // require('material-ui/lib/raised-button'); + export import RefreshIndicator = __MaterialUI.RefreshIndicator; // require('material-ui/lib/refresh-indicator'); + export import Ripples = __MaterialUI.Ripples; // require('material-ui/lib/ripples/'); + export import SelectField = __MaterialUI.SelectField; // require('material-ui/lib/select-field'); + export import Slider = __MaterialUI.Slider; // require('material-ui/lib/slider'); + export import SvgIcon = __MaterialUI.SvgIcon; // require('material-ui/lib/svg-icon'); + + import NavigationMenu = require('material-ui/lib/svg-icons/navigation/menu'); + import NavigationChevronLeft = require('material-ui/lib/svg-icons/navigation/chevron-left'); + import NavigationChevronRight = require('material-ui/lib/svg-icons/navigation/chevron-right'); + export var Icons: { + NavigationMenu: __MaterialUI.NavigationMenu; + NavigationChevronLeft: __MaterialUI.NavigationChevronLeft; + NavigationChevronRight: __MaterialUI.NavigationChevronRight; + }; + + export import Styles = __MaterialUI.Styles; // require('material-ui/lib/styles/'); + export import Snackbar = __MaterialUI.Snackbar; // require('material-ui/lib/snackbar'); + export import Tab = __MaterialUI.Tabs.Tab; // require('material-ui/lib/tabs/tab'); + export import Tabs = __MaterialUI.Tabs.Tabs; // require('material-ui/lib/tabs/tabs'); + export import Table = __MaterialUI.Table.Table; // require('material-ui/lib/table/table'); + export import TableBody = __MaterialUI.Table.TableBody; // require('material-ui/lib/table/table-body'); + export import TableFooter = __MaterialUI.Table.TableFooter; // require('material-ui/lib/table/table-footer'); + export import TableHeader = __MaterialUI.Table.TableHeader; // require('material-ui/lib/table/table-header'); + export import TableHeaderColumn = __MaterialUI.Table.TableHeaderColumn; // require('material-ui/lib/table/table-header-column'); + export import TableRow = __MaterialUI.Table.TableRow; // require('material-ui/lib/table/table-row'); + export import TableRowColumn = __MaterialUI.Table.TableRowColumn; // require('material-ui/lib/table/table-row-column'); + export import Theme = __MaterialUI.Theme; // require('material-ui/lib/theme'); + export import Toggle = __MaterialUI.Toggle; // require('material-ui/lib/toggle'); + export import TimePicker = __MaterialUI.TimePicker; // require('material-ui/lib/time-picker'); + export import TextField = __MaterialUI.TextField; // require('material-ui/lib/text-field'); + export import Toolbar = __MaterialUI.Toolbar.Toolbar; // require('material-ui/lib/toolbar/toolbar'); + export import ToolbarGroup = __MaterialUI.Toolbar.ToolbarGroup; // require('material-ui/lib/toolbar/toolbar-group'); + export import ToolbarSeparator = __MaterialUI.Toolbar.ToolbarSeparator; // require('material-ui/lib/toolbar/toolbar-separator'); + export import ToolbarTitle = __MaterialUI.Toolbar.ToolbarTitle; // require('material-ui/lib/toolbar/toolbar-title'); + export import Tooltip = __MaterialUI.Tooltip; // require('material-ui/lib/tooltip'); + export import Utils = __MaterialUI.Utils; // require('material-ui/lib/utils/'); +} + +declare namespace __MaterialUI { + import React = __React; + + // ReactLink is from "react/addons" + interface ReactLink { + value: T; + requestChange(newValue: T): void; + } + + // What's common between React.TouchEvent and React.MouseEvent + interface TouchTapEvent extends React.SyntheticEvent { + altKey: boolean; + ctrlKey: boolean; + getModifierState(key: string): boolean; + metaKey: boolean; + shiftKey: boolean; + } + + // What's common between React.TouchEventHandler and React.MouseEventHandler + interface TouchTapEventHandler extends React.EventHandler { } + + // more specific than React.HTMLAttributes + + interface AppBarProp extends React.Props> { + ref?: string | ((component: AppBar) => any); + + iconClassNameLeft?: string; + iconClassNameRight?: string; + iconElementLeft?: React.ReactElement; + iconElementRight?: React.ReactElement; + iconStyleRight?: string; + style?: React.CSSProperties; + showMenuIconButton?: boolean; + title?: any; + zDepth?: number; + + onLeftIconButtonTouchTap?: TouchTapEventHandler; + onRightIconButtonTouchTap?: TouchTapEventHandler; + } + export class AppBar extends React.Component{ + } + + interface AppCanvasProp extends React.Props { + ref?: string | ((component: AppCanvas) => any); + + } + export class AppCanvas extends React.Component { + } + + interface AvatarProp extends React.Props { + ref?: string | ((component: AvatarProp) => any); + + icon?: React.ReactElement; + backgroundColor?: string; + color?: string; + size?: number; + src?: string; + style?: React.CSSProperties; + } + export class Avatar extends React.Component { + } + + interface BeforeAfterWrapperProp extends React.Props { + ref?: string | ((component: BeforeAfterWrapper) => any); + + } + export class BeforeAfterWrapper extends React.Component { + } + + namespace Card { + + interface CardProp extends React.Props { + ref?: string | ((component: Card) => any); + + initiallyExpanded?: boolean; + onExpandedChange?: (isExpanded: boolean) => void; + style?: React.CSSProperties; + } + export class Card extends React.Component { + } + + interface CardActionsProp extends React.Props { + ref?: string | ((component: CardActions) => any); + + expandable?: boolean; + showExpandableButton?: boolean; + } + export class CardActions extends React.Component { + } + + interface CardExpandableProp extends React.Props { + ref?: string | ((component: CardExpandable) => any); + + onExpanding: (isExpanded: boolean) => void; + expanded: boolean; + } + export class CardExpandable extends React.Component { + } + + interface CardHeaderProp extends React.Props { + ref?: string | ((component: CardHeader) => any); + + expandable?: boolean; + showExpandableButton?: boolean; + title?: string | React.ReactElement; + titleColor?: string; + titleStyle?: React.CSSProperties; + subtitle?: string | React.ReactElement; + subtitleColor?: string; + subtitleStyle?: React.CSSProperties; + textStyle?: React.CSSProperties; + style?: React.CSSProperties; + avatar: React.ReactElement | string; + } + export class CardHeader extends React.Component { + } + + interface CardMediaProp extends React.Props { + ref?: string | ((component: CardMedia) => any); + + expandable?: boolean; + overlay?: React.ReactElement; + overlayStyle?: React.CSSProperties; + overlayContainerStyle?: React.CSSProperties; + overlayContentStyle?: React.CSSProperties; + mediaStyle?: React.CSSProperties; + style?: React.CSSProperties; + } + export class CardMedia extends React.Component { + } + + interface CardTextProp extends React.Props { + ref?: string | ((component: CardText) => any); + + expandable?: boolean; + color?: string; + style?: React.CSSProperties; + } + export class CardText extends React.Component { + } + + interface CardTitleProp extends React.Props { + ref?: string | ((component: CardTitle) => any); + + expandable?: boolean; + showExpandableButton?: boolean; + title?: string | React.ReactElement; + titleColor?: string; + titleStyle?: React.CSSProperties; + subtitle?: string | React.ReactElement; + subtitleColor?: string; + subtitleStyle?: React.CSSProperties; + textStyle?: React.CSSProperties; + style?: React.CSSProperties; + } + export class CardTitle extends React.Component { + } + } + + // what's not commonly overridden by Checkbox, RadioButton, or Toggle + interface CommonEnhancedSwitchProp extends React.HTMLAttributesBase { + // is root element + id?: string; + iconStyle?: React.CSSProperties; + labelStyle?: React.CSSProperties; + rippleStyle?: React.CSSProperties; + thumbStyle?: React.CSSProperties; + trackStyle?: React.CSSProperties; + name?: string; + value?: string; + label?: string; + required?: boolean; + disabled?: boolean; + defaultSwitched?: boolean; + disableFocusRipple?: boolean; + disableTouchRipple?: boolean; + } + + interface EnhancedSwitchProp extends CommonEnhancedSwitchProp { + // is root element + inputType: string; + switchElement: React.ReactElement; + onParentShouldUpdate: (isInputChecked: boolean) => void; + switched: boolean; + rippleColor?: string; + onSwitch?: (e: React.MouseEvent, isInputChecked: boolean) => void; + labelPosition?: string; + } + export class EnhancedSwitch extends React.Component { + isSwitched(): boolean; + setSwitched(newSwitchedValue: boolean): void; + getValue(): any; + isKeyboardFocused(): boolean; + } + + interface CheckboxProp extends CommonEnhancedSwitchProp { + // is root element + ref?: string | ((component: Checkbox) => any); + + checkedIcon?: React.ReactElement<{ style?: React.CSSProperties }>; // Normally an SvgIcon + defaultChecked?: boolean; + iconStyle?: React.CSSProperties; + label?: string; + labelStyle?: React.CSSProperties; + labelPosition?: string; + style?: React.CSSProperties; + checked?: boolean; + unCheckedIcon?: React.ReactElement<{ style?: React.CSSProperties }>; // Normally an SvgIcon + + disabled?: boolean; + valueLink?: ReactLink; + checkedLink?: ReactLink; + + onCheck?: (event: React.MouseEvent, checked: boolean) => void; + } + export class Checkbox extends React.Component { + isChecked(): void; + setChecked(newCheckedValue: boolean): void; + } + + interface CircularProgressProp extends React.Props { + ref?: string | ((component: CircularProgress) => any); + + } + export class CircularProgress extends React.Component { + } + + interface ClearFixProp extends React.Props { + ref?: string | ((component: ClearFix) => any); + + } + export class ClearFix extends React.Component { + } + + namespace DatePicker { + interface DatePickerProp extends React.Props { + ref?: string | ((component: DatePicker) => any); + + } + export class DatePicker extends React.Component { + } + + interface DatePickerDialogProp extends React.Props { + ref?: string | ((component: DatePickerDialog) => any); + + } + export class DatePickerDialog extends React.Component { + } + } + + export interface DialogAction { + text: string; + ref?: string; + + onTouchTap?: TouchTapEventHandler; + onClick?: React.MouseEventHandler; + } + interface DialogProp extends React.Props { + ref?: string | ((component: Dialog) => any); + + actions?: Array>; + actionFocus?: string; + contentClassName?: string; + contentInnerStyle?: React.CSSProperties; + contentStyle?: React.CSSProperties; + modal?: boolean; + openImmediately?: boolean; + title?: any; + autoDetectWindowHeight?: boolean; + autoScrollBodyContent?: boolean; + + onDismiss?: () => void; + onShow?: () => void; + } + export class Dialog extends React.Component { + dismiss(): void; + show(): void; + } + + interface DropDownIconProp extends React.Props { + ref?: string | ((component: DropDownIcon) => any); + + } + export class DropDownIcon extends React.Component { + } + + interface DropDownMenuProp extends React.Props { + ref?: string | ((component: DropDownMenu) => any); + + displayMember?: string; + valueMember?: string; + autoWidth?: boolean; + menuItems?: Array<{ text: string, payload: string } | {}>; + menuItemStyle?: React.CSSProperties[]; + selectedIndex?: number; + underlineStyle?: React.CSSProperties; + iconStyle?: React.CSSProperties; + labelStyle?: React.CSSProperties; + style?: React.CSSProperties; + disabled?: boolean; + valueLink?: ReactLink; + value?: number; + + onChange?: (e: TouchTapEvent, selectedIndex: number, menuItem: any) => void; + } + export class DropDownMenu extends React.Component { + } + + // non generally overridden elements of EnhancedButton + interface SharedEnhancedButtonProp extends React.HTMLAttributesBase { + containerElement?: string | React.ReactElement; + disabled?: boolean; + disableFocusRipple?: boolean; + disableKeyboardFocus?: boolean; + disableTouchRipple?: boolean; + keyboardFocused?: boolean; + linkButton?: boolean; + focusRippleColor?: string; + focusRippleOpacity?: number; + touchRippleOpacity?: number; + tabIndex?: number; + + onBlur?: React.FocusEventHandler; + onFocus?: React.FocusEventHandler; + onKeyDown?: React.KeyboardEventHandler; + onKeyUp?: React.KeyboardEventHandler; + onMouseEnter?: React.MouseEventHandler; + onMouseLeave?: React.MouseEventHandler; + onTouchStart?: React.TouchEventHandler; + onTouchEnd?: React.TouchEventHandler; + onTouchTap?: TouchTapEventHandler; + } + + interface EnhancedButtonProp extends SharedEnhancedButtonProp { + ref?: string | ((component: EnhancedButton) => any); + + onKeyboardFocus?: (e: React.FocusEvent, isKeyboardFocused: boolean) => void; + touchRippleColor?: string; + focusRippleColor?: string; + style?: React.CSSProperties; + } + export class EnhancedButton extends React.Component { + } + + interface FlatButtonProp extends SharedEnhancedButtonProp { + ref?: string | ((component: FlatButton) => any); + + hoverColor?: string; + label?: string; + labelPosition?: string; + labelStyle?: React.CSSProperties; + linkButton?: boolean; + primary?: boolean; + secondary?: boolean; + rippleColor?: string; + style?: React.CSSProperties; + + onKeyboardFocus?: (e: React.KeyboardEvent, isKeyboardFocused: boolean) => void; + } + export class FlatButton extends React.Component { + } + + interface FloatingActionButtonProp extends SharedEnhancedButtonProp { + ref?: string | ((component: FloatingActionButton) => any); + + backgroundColor?: string; + disabled?: boolean; + disabledColor?: string; + iconClassName?: string; + iconStyle?: React.CSSProperties; + mini?: boolean; + secondary?: boolean; + style?: React.CSSProperties; + } + export class FloatingActionButton extends React.Component { + } + + interface FontIconProp extends React.Props { + ref?: string | ((component: FontIcon) => any); + + color?: string; + hoverColor?: string; + onMouseLeave?: React.MouseEventHandler; + onMouseEnter?: React.MouseEventHandler; + style?: React.CSSProperties; + className?: string; + } + export class FontIcon extends React.Component { + } + + interface IconButtonProp extends SharedEnhancedButtonProp { + ref?: string | ((component: IconButton) => any); + + iconClassName?: string; + iconStyle?: React.CSSProperties; + style?: React.CSSProperties; + tooltip?: string; + tooltipPosition?: string; + tooltipStyles?: React.CSSProperties; + touch?: boolean; + + onBlur?: React.FocusEventHandler; + onFocus?: React.FocusEventHandler; + } + export class IconButton extends React.Component { + } + + interface LeftNavProp extends React.Props { + ref?: string | ((component: LeftNav) => any); + + } + export class LeftNav extends React.Component { + } + + interface LinearProgressProp extends React.Props { + ref?: string | ((component: LinearProgress) => any); + + } + export class LinearProgress extends React.Component { + } + + namespace Lists { + interface ListProp extends React.Props { + ref?: string | ((component: List) => any); + + } + export class List extends React.Component { + } + + interface ListDividerProp extends React.Props { + ref?: string | ((component: ListDivider) => any); + + } + export class ListDivider extends React.Component { + } + + interface ListItemProp extends React.Props { + ref?: string | ((component: ListItem) => any); + + } + export class ListItem extends React.Component { + } + } + + namespace Menu { + interface MenuProp extends React.Props { + ref?: string | ((component: Menu) => any); + + } + export class Menu extends React.Component { + } + + interface MenuItemProp extends React.Props { + ref?: string | ((component: MenuItem) => any); + + } + export class MenuItem extends React.Component { + } + } + + export namespace Mixins { + interface ClickAwayable extends React.Mixin { + } + var ClickAwayable: ClickAwayable + + interface WindowListenable extends React.Mixin { + } + var WindowListenable: WindowListenable; + + interface StylePropable extends React.Mixin { + } + var StylePropable: StylePropable + + interface StyleResizable extends React.Mixin { + } + var StyleResizable: StyleResizable + } + + interface OverlayProp extends React.Props { + ref?: string | ((component: Overlay) => any); + + } + export class Overlay extends React.Component { + } + + interface PaperProp extends React.Props { + ref?: string | ((component: Paper) => any); + + } + export class Paper extends React.Component { + } + + interface RadioButtonProp extends CommonEnhancedSwitchProp { + // is root element + ref?: string | ((component: RadioButton) => any); + + defaultChecked?: boolean; + iconStyle?: React.CSSProperties; + label?: string; + labelStyle?: React.CSSProperties; + labelPosition?: string; + style?: React.CSSProperties; + value?: string; + } + export class RadioButton extends React.Component { + } + + interface RadioButtonGroupProp extends React.Props { + ref?: string | ((component: RadioButtonGroup) => any); + + defaultSelected?: string; + labelPosition?: string; + name: string; + style?: React.CSSProperties; + valueSelected?: string; + + onChange?: (e: React.FormEvent, selected: string) => void; + } + export class RadioButtonGroup extends React.Component { + getSelectedValue(): string; + setSelectedValue(newSelectionValue: string): void; + clearValue(): void; + } + + interface RaisedButtonProp extends SharedEnhancedButtonProp { + ref?: string | ((component: RaisedButton) => any); + + className?: string; + disabled?: boolean; + label?: string; + primary?: boolean; + secondary?: boolean; + labelStyle?: React.CSSProperties; + backgroundColor?: string; + labelColor?: string; + disabledBackgroundColor?: string; + disabledLabelColor?: string; + fullWidth?: boolean; + } + export class RaisedButton extends React.Component { + } + + interface RefreshIndicatorProp extends React.Props { + ref?: string | ((component: RefreshIndicator) => any); + + } + export class RefreshIndicator extends React.Component { + } + + export interface Ripples { + } + + interface SelectFieldProp extends React.Props { + ref?: string | ((component: SelectField) => any); + + // passed to TextField + errorStyle?: React.CSSProperties; + errorText?: string; + floatingLabelText?: string; + floatingLabelStyle?: React.CSSProperties; + fullWidth?: boolean; + hintText?: string | React.ReactElement; + + // passed to DropDownMenu + displayMember?: string; + valueMember?: string; + autoWidth?: boolean; + menuItems?: Array<{ text: string, payload: string } | {}>; + menuItemStyle?: React.CSSProperties[]; + selectedIndex?: number; + underlineStyle?: React.CSSProperties; + iconStyle?: React.CSSProperties; + labelStyle?: React.CSSProperties; + style?: React.CSSProperties; + disabled?: boolean; + valueLink?: ReactLink; + value?: number; + + onChange?: (e: TouchTapEvent, selectedIndex: number, menuItem: any) => void; + + // own properties + selectFieldRoot?: string; + } + export class SelectField extends React.Component { + } + + interface SliderProp extends React.Props { + ref?: string | ((component: Slider) => any); + + } + export class Slider extends React.Component { + } + + interface SvgIconProp extends React.Props { + ref?: string | ((component: SvgIcon) => any); + + } + export class SvgIcon extends React.Component { + } + + interface NavigationMenuProp extends React.Props { + ref?: string | ((component: NavigationMenu) => any); + + } + export class NavigationMenu extends React.Component { + } + + interface NavigationChevronLeftProp extends React.Props { + ref?: string | ((component: NavigationChevronLeft) => any); + + } + export class NavigationChevronLeft extends React.Component { + } + + interface NavigationChevronRightProp extends React.Props { + ref?: string | ((component: NavigationChevronRight) => any); + + } + export class NavigationChevronRight extends React.Component { + } + + export namespace Styles { + interface AutoPrefixProp extends React.Props { + ref?: string | ((component: AutoPrefix) => any); + + } + export class AutoPrefix extends React.Component { + } + interface Spacing { + iconSize?: number; + + desktopGutter?: number; + desktopGutterMore?: number; + desktopGutterLess?: number; + desktopGutterMini?: number; + desktopKeylineIncrement?: number; + desktopDropDownMenuItemHeight?: number; + desktopDropDownMenuFontSize?: number; + desktopLeftNavMenuItemHeight?: number; + desktopSubheaderHeight?: number; + desktopToolbarHeight?: number; + } + interface ThemePalette { + primary1Color?: string, + primary2Color?: string, + primary3Color?: string, + accent1Color?: string, + accent2Color?: string, + accent3Color?: string, + textColor?: string, + canvasColor?: string, + borderColor?: string, + disabledColor?: string + } + interface Theme { + appBar?: { + color?: string, + textColor?: string, + height?: number + }, + button?: { + height?: number, + minWidth?: number, + iconButtonSize?: number + }, + checkbox?: { + boxColor?: string, + checkedColor?: string, + requiredColor?: string, + disabledColor?: string, + labelColor?: string, + labelDisabledColor?: string + }, + datePicker?: { + color?: string, + textColor?: string, + calendarTextColor?: string, + selectColor?: string, + selectTextColor?: string, + }, + dropDownMenu?: { + accentColor?: string, + }, + flatButton?: { + color?: string, + textColor?: string, + primaryTextColor?: string, + secondaryTextColor?: string, + disabledColor?: string + }, + floatingActionButton?: { + buttonSize?: number, + miniSize?: number, + color?: string, + iconColor?: string, + secondaryColor?: string, + secondaryIconColor?: string, + disabledColor?: string, + disabledTextColor?: string + }, + leftNav?: { + width?: number, + color?: string, + }, + menu?: { + backgroundColor?: string, + containerBackgroundColor?: string, + }, + menuItem?: { + dataHeight?: number, + height?: number, + hoverColor?: string, + padding?: number, + selectedTextColor?: string, + }, + menuSubheader?: { + padding?: number, + borderColor?: string, + textColor?: string, + }, + paper?: { + backgroundColor?: string, + }, + radioButton?: { + borderColor?: string, + backgroundColor?: string, + checkedColor?: string, + requiredColor?: string, + disabledColor?: string, + size?: number, + labelColor?: string, + labelDisabledColor?: string + }, + raisedButton?: { + color?: string, + textColor?: string, + primaryColor?: string, + primaryTextColor?: string, + secondaryColor?: string, + secondaryTextColor?: string, + disabledColor?: string, + disabledTextColor?: string + }, + slider?: { + trackSize?: number, + trackColor?: string, + trackColorSelected?: string, + handleSize?: number, + handleSizeActive?: number, + handleSizeDisabled?: number, + handleColorZero?: string, + handleFillColor?: string, + selectionColor?: string, + rippleColor?: string, + }, + snackbar?: { + textColor?: string, + backgroundColor?: string, + actionColor?: string, + }, + toggle?: { + thumbOnColor?: string, + thumbOffColor?: string, + thumbDisabledColor?: string, + thumbRequiredColor?: string, + trackOnColor?: string, + trackOffColor?: string, + trackDisabledColor?: string, + trackRequiredColor?: string, + labelColor?: string, + labelDisabledColor?: string + }, + toolbar?: { + backgroundColor?: string, + height?: number, + titleFontSize?: number, + iconColor?: string, + separatorColor?: string, + menuHoverColor?: string, + } + } + interface CustomTheme { + getPalette(): ThemePalette; + getComponentThemes(palette: ThemePalette, spacing: Spacing): Theme; + } + + export class ThemeManager { + spacing: Spacing; + palette: ThemePalette; + component: any; + types: { + LIGHT: CustomTheme; + DARK: CustomTheme; + }; + + getCurrentTheme(): CustomTheme; + setTheme(newTheme: CustomTheme): void; + setSpacing(newSpacing: Spacing): void; + setPalette(newPalette: ThemePalette): void; + setComponentThemes(overrides: Theme): void; + } + + interface TransitionsProp extends React.Props { + ref?: string | ((component: Transitions) => any); + + } + export class Transitions extends React.Component { + } + + export class Typography { + textFullBlack:string; + textDarkBlack: string; + textLightBlack: string; + textMinBlack: string; + textFullWhite: string; + textDarkWhite: string; + textLightWhite: string; + + // font weight + fontWeightLight: number; + fontWeightNormal: number; + fontWeightMedium: number; + + fontStyleButtonFontSize: number; + } + } + + interface SnackbarProp extends React.Props { + ref?: string | ((component: Snackbar) => any); + + } + export class Snackbar extends React.Component { + } + + namespace Tabs { + interface TabProp extends React.Props { + ref?: string | ((component: Tab) => any); + + label?: string; + value?: string; + + onActive?: (tab: Tab) => void; + } + export class Tab extends React.Component { + } + + interface TabsProp extends React.Props { + ref?: string | ((component: Tabs) => any); + + contentContainerStyle?: React.CSSProperties; + initialSelectedIndex?: number; + inkBarStyle?: React.CSSProperties; + style?: React.CSSProperties; + tabItemContainerStyle?: React.CSSProperties; + value?: string | number; + + onChange?: (value: string | number, e: React.FormEvent, tab: Tab) => void; + } + export class Tabs extends React.Component { + } + } + + namespace Table { + interface TableProp extends React.Props { + ref?: string | ((component: Table) => any); + + } + export class Table extends React.Component { + } + + interface TableBodyProp extends React.Props { + ref?: string | ((component: TableBody) => any); + + } + export class TableBody extends React.Component { + } + + interface TableFooterProp extends React.Props { + ref?: string | ((component: TableFooter) => any); + + } + export class TableFooter extends React.Component { + } + + interface TableHeaderProp extends React.Props { + ref?: string | ((component: TableHeader) => any); + + } + export class TableHeader extends React.Component { + } + + interface TableHeaderColumnProp extends React.Props { + ref?: string | ((component: TableHeaderColumn) => any); + + } + export class TableHeaderColumn extends React.Component { + } + + interface TableRowProp extends React.Props { + ref?: string | ((component: TableRow) => any); + + } + export class TableRow extends React.Component { + } + + interface TableRowColumnProp extends React.Props { + ref?: string | ((component: TableRowColumn) => any); + + } + export class TableRowColumn extends React.Component { + } + } + + interface ThemeProp extends React.Props { + ref?: string | ((component: Theme) => any); + + theme: Styles.CustomTheme; + } + export class Theme extends React.Component { + static theme(customTheme: Styles.CustomTheme):

(Component: React.ComponentClass

) => React.ComponentClass

; + } + + interface ToggleProp extends CommonEnhancedSwitchProp { + // is root element + ref?: string | ((component: Toggle) => any); + + elementStyle?: React.CSSProperties; + labelStyle?: React.CSSProperties; + onToggle?: (e: React.MouseEvent, isInputChecked: boolean) => void; + toggled?: boolean; + defaultToggled?: boolean; + } + export class Toggle extends React.Component { + isToggled(): boolean; + setToggled(newToggledValue: boolean): void; + } + + interface TimePickerProp extends React.Props { + ref?: string | ((component: TimePicker) => any); + + } + export class TimePicker extends React.Component { + } + + interface TextFieldProp extends React.Props { + ref?: string | ((component: TextField) => any); + + errorStyle?: React.CSSProperties; + errorText?: string; + floatingLabelText?: string; + floatingLabelStyle?: React.CSSProperties; + fullWidth?: boolean; + hintText?: string | React.ReactElement; + id?: string; + inputStyle?: React.CSSProperties; + multiLine?: boolean; + onEnterKeyDown?: () => void; + style?: React.CSSProperties; + rows?: number, + underlineStyle?: React.CSSProperties; + underlineFocusStyle?: React.CSSProperties; + type?: string; + + disabled?: boolean; + isRtl?: boolean; + value?: string; + defaultValue?: string; + valueLink?: ReactLink; + + onBlur?: React.FocusEventHandler; + onChange?: React.FormEventHandler; + onFocus?: React.FocusEventHandler; + onKeyDown?: React.KeyboardEventHandler; + } + export class TextField extends React.Component { + blur(): void; + clearValue(): void; + focus(): void; + getValue(): string; + setErrorText(newErrorText: string): void; + setValue(newValue: string): void; + } + + namespace Toolbar { + interface ToolbarProp extends React.Props { + ref?: string | ((component: Toolbar) => any); + + } + export class Toolbar extends React.Component { + } + + interface ToolbarGroupProp extends React.Props { + ref?: string | ((component: ToolbarGroup) => any); + + } + export class ToolbarGroup extends React.Component { + } + + interface ToolbarSeparatorProp extends React.Props { + ref?: string | ((component: ToolbarSeparator) => any); + + } + export class ToolbarSeparator extends React.Component { + } + + interface ToolbarTitleProp extends React.Props { + ref?: string | ((component: ToolbarTitle) => any); + + } + export class ToolbarTitle extends React.Component { + } + } + + interface TooltipProp extends React.Props { + ref?: string | ((component: Tooltip) => any); + + } + export class Tooltip extends React.Component { + } + + export namespace Utils { + interface ColorManipulator { + fade(color: string, amount: number): string; + darken(color: string, amount: number): string; + contrastRatio(background: string, foreground: string): string; + contrastRatioLevel(background: string, foreground: string): any; + } + + interface CssEvent { + transitionEndEventName(): string; + animationEndEventName(): string; + onTransitionEnd(el: Element, callback: (e: Event) => any): void; + onAnimationEnd(el: Element, callback: (e: Event) => any): void; + } + + interface Dom { + isDescendant(parent: Element, child: Element): boolean; + offset(el: Element): { top: number, left: number }; + getStyleAttributeAsNumber(el: Element, attr: string): number; + addClass(el: Element, className: string): void; + removeClass(el: Element, className: string): void; + hasClass(el: Element, className: string): boolean; + toggleClass(el: Element, className: string): void; + forceRedraw(el: Element): void; + withoutTransition(el: Element, callback: () => any): void; + } + + interface Events { + once(el: Element, type: string, callback: (e: Event) => any): void; + on(el: Element, type: string, callback: (e: Event) => any): void; + off(el: Element, type: string, callback: (e: Event) => any): void; + isKeyboard(e: Event): boolean; + } + + function Extend(base: T, override: S1): (T & S1); + + interface ImmutabilityHelper { + merge(base: {}, ...args: {}[]): any; + mergeItem(obj: {}, key: string, newValueObject: {}): any; + push(array: T[], obj: T): T[]; + shift(array: T[]): T[]; + } + + interface KeyLine { + Desktop: { + GUTTER: number; + GUTTER_LESS: number; + INCREMENT: number; + MENU_ITEM_HEIGHT: number; + }; + + getIncrementalDim(dim: number): number; + } + + interface UniqueId { + generate(): string; + } + + interface Styles { + mergeAndPrefix(base: {}, ...args: {}[]): any; + } + } + + // New menus available only through requiring directly to the end file + namespace Menus { + interface IconMenuProp extends React.Props { + ref?: string | ((component: IconMenu) => any); + + closeOnItemTouchTap?: boolean; + desktop?: boolean; + iconButtonElement?: React.ReactElement; + openDirection?: string; + menuStyle?: React.CSSProperties; + multiple?: boolean; + value?: string | Array; + width?: string | number; + touchTapCloseDelay?: number; + + onItemTouchTap?: (e: TouchTapEvent, item: React.ReactElement) => void; + onChange?: (e: React.FormEvent, value: string | Array) => void; + } + export class IconMenu extends React.Component { + } + + interface MenuProp extends React.Props

{ + animated?: boolean; + autoWidth?: boolean; + desktop?: boolean; + listStyle?: React.CSSProperties; + maxHeight?: number; + multiple?: boolean; + openDirection?: string; + value?: string | Array; + width?: string | number; + zDepth?: number; + } + export class Menu extends React.Component{ + } + + interface MenuItemProp extends React.Props { + checked?: boolean; + desktop?: boolean; + disabled?: boolean; + innerDivStyle?: React.CSSProperties; + insetChildren?: boolean; + leftIcon?: React.ReactElement; + primaryText?: string | React.ReactElement; + rightIcon?: React.ReactElement; + secondaryText?: string | React.ReactElement; + value?: string; + + onEscKeyDown?: React.KeyboardEventHandler; + onItemTouchTap?: (e: TouchTapEvent, item: React.ReactElement) => void; + onChange?: (e: React.FormEvent, value: string) => void; + } + export class MenuItem extends React.Component{ + } + + interface MenuDividerProp extends React.Props { + inset?: boolean; + style?: React.CSSProperties; + } + export class MenuDivider extends React.Component{ + } + } +} // __MaterialUI + +declare module 'material-ui/lib/app-bar' { + export = __MaterialUI.AppBar; +} + +declare module 'material-ui/lib/app-canvas' { + export = __MaterialUI.AppCanvas; +} + +declare module 'material-ui/lib/avatar' { + export = __MaterialUI.Avatar; +} + +declare module 'material-ui/lib/before-after-wrapper' { + export = __MaterialUI.BeforeAfterWrapper; +} + +declare module 'material-ui/lib/card/card' { + export = __MaterialUI.Card.Card; +} + +declare module 'material-ui/lib/card/card-actions' { + export = __MaterialUI.Card.CardActions; +} + +declare module 'material-ui/lib/card/card-expandable' { + export = __MaterialUI.Card.CardExpandable; +} + +declare module 'material-ui/lib/card/card-header' { + export = __MaterialUI.Card.CardHeader; +} + +declare module 'material-ui/lib/card/card-media' { + export = __MaterialUI.Card.CardMedia; +} + +declare module 'material-ui/lib/card/card-text' { + export = __MaterialUI.Card.CardText; +} + +declare module 'material-ui/lib/card/card-title' { + export = __MaterialUI.Card.CardTitle; +} + +declare module 'material-ui/lib/checkbox' { + export = __MaterialUI.Checkbox; +} + +declare module 'material-ui/lib/circular-progress' { + export = __MaterialUI.CircularProgress; +} + +declare module 'material-ui/lib/clearfix' { + export = __MaterialUI.ClearFix; +} + +declare module 'material-ui/lib/date-picker/date-picker' { + export = __MaterialUI.DatePicker.DatePicker; +} + +declare module 'material-ui/lib/date-picker/date-picker-dialog' { + export = __MaterialUI.DatePicker.DatePickerDialog; +} + +declare module 'material-ui/lib/dialog' { + export = __MaterialUI.Dialog; +} + +declare module 'material-ui/lib/drop-down-icon' { + export = __MaterialUI.DropDownIcon; +} + +declare module 'material-ui/lib/drop-down-menu' { + export = __MaterialUI.DropDownMenu; +} + +declare module 'material-ui/lib/enhanced-button' { + export = __MaterialUI.EnhancedButton; +} + +declare module 'material-ui/lib/flat-button' { + export = __MaterialUI.FlatButton; +} + +declare module 'material-ui/lib/floating-action-button' { + export = __MaterialUI.FloatingActionButton; +} + +declare module 'material-ui/lib/font-icon' { + export = __MaterialUI.FontIcon; +} + +declare module 'material-ui/lib/icon-button' { + export = __MaterialUI.IconButton; +} + +declare module 'material-ui/lib/left-nav' { + export = __MaterialUI.LeftNav; +} + +declare module 'material-ui/lib/linear-progress' { + export = __MaterialUI.LinearProgress; +} + +declare module 'material-ui/lib/lists/list' { + export = __MaterialUI.Lists.List; +} + +declare module 'material-ui/lib/lists/list-divider' { + export = __MaterialUI.Lists.ListDivider; +} + +declare module 'material-ui/lib/lists/list-item' { + export = __MaterialUI.Lists.ListItem; +} + +declare module 'material-ui/lib/menu/menu' { + export = __MaterialUI.Menu.Menu; +} + +declare module 'material-ui/lib/menu/menu-item' { + export = __MaterialUI.Menu.MenuItem; +} + +declare module 'material-ui/lib/mixins/' { + export import ClickAwayable = __MaterialUI.Mixins.ClickAwayable; // require('material-ui/lib/mixins/click-awayable'); + export import WindowListenable = __MaterialUI.Mixins.WindowListenable; // require('material-ui/lib/mixins/window-listenable'); + export import StylePropable = __MaterialUI.Mixins.StylePropable; // require('material-ui/lib/mixins/style-propable'); + export import StyleResizable = __MaterialUI.Mixins.StyleResizable; // require('material-ui/lib/mixins/style-resizable'); +} + +declare module 'material-ui/lib/mixins/click-awayable' { + export = __MaterialUI.Mixins.ClickAwayable; +} + +declare module 'material-ui/lib/mixins/window-listenable' { + export = __MaterialUI.Mixins.WindowListenable; +} + +declare module 'material-ui/lib/mixins/style-propable' { + export = __MaterialUI.Mixins.StylePropable; +} + +declare module 'material-ui/lib/mixins/style-resizable' { + export = __MaterialUI.Mixins.StyleResizable; +} + +declare module 'material-ui/lib/overlay' { + export = __MaterialUI.Overlay; +} + +declare module 'material-ui/lib/paper' { + export = __MaterialUI.Paper; +} + +declare module 'material-ui/lib/radio-button' { + export = __MaterialUI.RadioButton; +} + +declare module 'material-ui/lib/radio-button-group' { + export = __MaterialUI.RadioButtonGroup; +} + +declare module 'material-ui/lib/raised-button' { + export = __MaterialUI.RaisedButton; +} + +declare module 'material-ui/lib/refresh-indicator' { + export = __MaterialUI.RefreshIndicator; +} + +declare module 'material-ui/lib/ripples/' { + var Ripples: __MaterialUI.Ripples; + export = Ripples; +} + +declare module 'material-ui/lib/select-field' { + export = __MaterialUI.SelectField; +} + +declare module 'material-ui/lib/slider' { + export = __MaterialUI.Slider; +} + +declare module 'material-ui/lib/svg-icon' { + export = __MaterialUI.SvgIcon; +} + +declare module 'material-ui/lib/svg-icons/navigation/menu' { + export = __MaterialUI.NavigationMenu; +} + +declare module 'material-ui/lib/svg-icons/navigation/chevron-left' { + export = __MaterialUI.NavigationChevronLeft; +} + +declare module 'material-ui/lib/svg-icons/navigation/chevron-right' { + export = __MaterialUI.NavigationChevronRight; +} + +declare module 'material-ui/lib/styles/' { + export import AutoPrefix = __MaterialUI.Styles.AutoPrefix; // require('material-ui/lib/styles/auto-prefix'); + export import Colors = require('material-ui/lib/styles/colors'); + export import Spacing = __MaterialUI.Styles.Spacing; // require('material-ui/lib/styles/spacing'); + export import ThemeManager = __MaterialUI.Styles.ThemeManager; // require('material-ui/lib/styles/theme-manager'); + export import Transitions = __MaterialUI.Styles.Transitions; // require('material-ui/lib/styles/transitions'); + export import Typography = __MaterialUI.Styles.Typography; // require('material-ui/lib/styles/typography'); +} + +declare module 'material-ui/lib/styles/auto-prefix' { + export = __MaterialUI.Styles.AutoPrefix; +} + +declare module 'material-ui/lib/styles/spacing' { + var Spacing: __MaterialUI.Styles.Spacing; + export = Spacing; +} + +declare module 'material-ui/lib/styles/theme-manager' { + export = __MaterialUI.Styles.ThemeManager; +} + +declare module 'material-ui/lib/styles/transitions' { + export = __MaterialUI.Styles.Transitions; +} + +declare module 'material-ui/lib/styles/typography' { + export = new __MaterialUI.Styles.Typography(); +} + +declare module 'material-ui/lib/snackbar' { + export = __MaterialUI.Snackbar; +} + +declare module 'material-ui/lib/tabs/tab' { + export = __MaterialUI.Tabs.Tab; +} + +declare module 'material-ui/lib/tabs/tabs' { + export = __MaterialUI.Tabs.Tabs; +} + +declare module 'material-ui/lib/table/table' { + export = __MaterialUI.Table.Table; +} + +declare module 'material-ui/lib/table/table-body' { + export = __MaterialUI.Table.TableBody; +} + +declare module 'material-ui/lib/table/table-footer' { + export = __MaterialUI.Table.TableFooter; +} + +declare module 'material-ui/lib/table/table-header' { + export = __MaterialUI.Table.TableHeader; +} + +declare module 'material-ui/lib/table/table-header-column' { + export = __MaterialUI.Table.TableHeaderColumn; +} + +declare module 'material-ui/lib/table/table-row' { + export = __MaterialUI.Table.TableRow; +} + +declare module 'material-ui/lib/table/table-row-column' { + export = __MaterialUI.Table.TableRowColumn; +} + +declare module 'material-ui/lib/theme' { + export = __MaterialUI.Theme; +} + +declare module 'material-ui/lib/toggle' { + export = __MaterialUI.Toggle; +} + +declare module 'material-ui/lib/time-picker' { + export = __MaterialUI.TimePicker; +} + +declare module 'material-ui/lib/text-field' { + export = __MaterialUI.TextField; +} + +declare module 'material-ui/lib/toolbar/toolbar' { + export = __MaterialUI.Toolbar.Toolbar; +} + +declare module 'material-ui/lib/toolbar/toolbar-group' { + export = __MaterialUI.Toolbar.ToolbarGroup; +} + +declare module 'material-ui/lib/toolbar/toolbar-separator' { + export = __MaterialUI.Toolbar.ToolbarSeparator; +} + +declare module 'material-ui/lib/toolbar/toolbar-title' { + export = __MaterialUI.Toolbar.ToolbarTitle; +} + +declare module 'material-ui/lib/tooltip' { + export = __MaterialUI.Tooltip; +} + +declare module 'material-ui/lib/utils/' { + export import ColorManipulator = __MaterialUI.Utils.ColorManipulator; // require('material-ui/lib/utils/color-manipulator'); + export import CssEvent = __MaterialUI.Utils.CssEvent; // require('material-ui/lib/utils/css-event'); + export import Dom = __MaterialUI.Utils.Dom; // require('material-ui/lib/utils/dom'); + export import Events = __MaterialUI.Utils.Events; // require('material-ui/lib/utils/events'); + export import Extend = __MaterialUI.Utils.Extend; // require('material-ui/lib/utils/extend'); + export import ImmutabilityHelper = __MaterialUI.Utils.ImmutabilityHelper; // require('material-ui/lib/utils/immutability-helper'); + export import KeyCode = require('material-ui/lib/utils/key-code'); + export import KeyLine = __MaterialUI.Utils.KeyLine; // require('material-ui/lib/utils/key-line'); + export import UniqueId = __MaterialUI.Utils.UniqueId; // require('material-ui/lib/utils/unique-id'); + export import Styles = __MaterialUI.Utils.Styles; // require('material-ui/lib/utils/styles'); +} + +declare module 'material-ui/lib/utils/color-manipulator' { + let ColorManipulator: __MaterialUI.Utils.ColorManipulator; + export = ColorManipulator; +} + +declare module 'material-ui/lib/utils/css-event' { + let CssEvent: __MaterialUI.Utils.CssEvent; + export = CssEvent; +} + +declare module 'material-ui/lib/utils/dom' { + let Dom: __MaterialUI.Utils.Dom; + export = Dom; +} + +declare module 'material-ui/lib/utils/events' { + let Events: __MaterialUI.Utils.Events; + export = Events; +} + +declare module 'material-ui/lib/utils/extend' { + export = __MaterialUI.Utils.Extend; +} + +declare module 'material-ui/lib/utils/immutability-helper' { + let ImmutabilityHelper: __MaterialUI.Utils.ImmutabilityHelper; + export = ImmutabilityHelper; +} + +declare module 'material-ui/lib/utils/key-code' { + export = { + DOWN: 40, + ESC: 27, + ENTER: 13, + LEFT: 37, + RIGHT: 39, + SPACE: 32, + TAB: 9, + UP: 38, + } +} + +declare module 'material-ui/lib/utils/key-line' { + let KeyLine: __MaterialUI.Utils.KeyLine; + export = KeyLine; +} + +declare module 'material-ui/lib/utils/unique-id' { + let UniqueId: __MaterialUI.Utils.UniqueId; + export = UniqueId; +} + +declare module 'material-ui/lib/utils/styles' { + let Styles: __MaterialUI.Utils.Styles; + export = Styles; +} + +declare module "material-ui/lib/menus/icon-menu" { + export = __MaterialUI.Menus.IconMenu; +} + +declare module "material-ui/lib/menus/menu" { + export = __MaterialUI.Menus.Menu; +} + +declare module "material-ui/lib/menus/menu-item" { + export = __MaterialUI.Menus.MenuItem; +} + +declare module "material-ui/lib/menus/menu-divider" { + export = __MaterialUI.Menus.MenuDivider; +} + +declare module "material-ui/lib/styles/colors" { + export var red50: string; + export var red100: string; + export var red200: string; + export var red300: string; + export var red400: string; + export var red500: string; + export var red600: string; + export var red700: string; + export var red800: string; + export var red900: string; + export var redA100: string; + export var redA200: string; + export var redA400: string; + export var redA700: string; + + export var pink50: string; + export var pink100: string; + export var pink200: string; + export var pink300: string; + export var pink400: string; + export var pink500: string; + export var pink600: string; + export var pink700: string; + export var pink800: string; + export var pink900: string; + export var pinkA100: string; + export var pinkA200: string; + export var pinkA400: string; + export var pinkA700: string; + + export var purple50: string; + export var purple100: string; + export var purple200: string; + export var purple300: string; + export var purple400: string; + export var purple500: string; + export var purple600: string; + export var purple700: string; + export var purple800: string; + export var purple900: string; + export var purpleA100: string; + export var purpleA200: string; + export var purpleA400: string; + export var purpleA700: string; + + export var deepPurple50: string; + export var deepPurple100: string; + export var deepPurple200: string; + export var deepPurple300: string; + export var deepPurple400: string; + export var deepPurple500: string; + export var deepPurple600: string; + export var deepPurple700: string; + export var deepPurple800: string; + export var deepPurple900: string; + export var deepPurpleA100: string; + export var deepPurpleA200: string; + export var deepPurpleA400: string; + export var deepPurpleA700: string; + + export var indigo50: string; + export var indigo100: string; + export var indigo200: string; + export var indigo300: string; + export var indigo400: string; + export var indigo500: string; + export var indigo600: string; + export var indigo700: string; + export var indigo800: string; + export var indigo900: string; + export var indigoA100: string; + export var indigoA200: string; + export var indigoA400: string; + export var indigoA700: string; + + export var blue50: string; + export var blue100: string; + export var blue200: string; + export var blue300: string; + export var blue400: string; + export var blue500: string; + export var blue600: string; + export var blue700: string; + export var blue800: string; + export var blue900: string; + export var blueA100: string; + export var blueA200: string; + export var blueA400: string; + export var blueA700: string; + + export var lightBlue50: string; + export var lightBlue100: string; + export var lightBlue200: string; + export var lightBlue300: string; + export var lightBlue400: string; + export var lightBlue500: string; + export var lightBlue600: string; + export var lightBlue700: string; + export var lightBlue800: string; + export var lightBlue900: string; + export var lightBlueA100: string; + export var lightBlueA200: string; + export var lightBlueA400: string; + export var lightBlueA700: string; + + export var cyan50: string; + export var cyan100: string; + export var cyan200: string; + export var cyan300: string; + export var cyan400: string; + export var cyan500: string; + export var cyan600: string; + export var cyan700: string; + export var cyan800: string; + export var cyan900: string; + export var cyanA100: string; + export var cyanA200: string; + export var cyanA400: string; + export var cyanA700: string; + + export var teal50: string; + export var teal100: string; + export var teal200: string; + export var teal300: string; + export var teal400: string; + export var teal500: string; + export var teal600: string; + export var teal700: string; + export var teal800: string; + export var teal900: string; + export var tealA100: string; + export var tealA200: string; + export var tealA400: string; + export var tealA700: string; + + export var green50: string; + export var green100: string; + export var green200: string; + export var green300: string; + export var green400: string; + export var green500: string; + export var green600: string; + export var green700: string; + export var green800: string; + export var green900: string; + export var greenA100: string; + export var greenA200: string; + export var greenA400: string; + export var greenA700: string; + + export var lightGreen50: string; + export var lightGreen100: string; + export var lightGreen200: string; + export var lightGreen300: string; + export var lightGreen400: string; + export var lightGreen500: string; + export var lightGreen600: string; + export var lightGreen700: string; + export var lightGreen800: string; + export var lightGreen900: string; + export var lightGreenA100: string; + export var lightGreenA200: string; + export var lightGreenA400: string; + export var lightGreenA700: string; + + export var lime50: string; + export var lime100: string; + export var lime200: string; + export var lime300: string; + export var lime400: string; + export var lime500: string; + export var lime600: string; + export var lime700: string; + export var lime800: string; + export var lime900: string; + export var limeA100: string; + export var limeA200: string; + export var limeA400: string; + export var limeA700: string; + + export var yellow50: string; + export var yellow100: string; + export var yellow200: string; + export var yellow300: string; + export var yellow400: string; + export var yellow500: string; + export var yellow600: string; + export var yellow700: string; + export var yellow800: string; + export var yellow900: string; + export var yellowA100: string; + export var yellowA200: string; + export var yellowA400: string; + export var yellowA700: string; + + export var amber50: string; + export var amber100: string; + export var amber200: string; + export var amber300: string; + export var amber400: string; + export var amber500: string; + export var amber600: string; + export var amber700: string; + export var amber800: string; + export var amber900: string; + export var amberA100: string; + export var amberA200: string; + export var amberA400: string; + export var amberA700: string; + + export var orange50: string; + export var orange100: string; + export var orange200: string; + export var orange300: string; + export var orange400: string; + export var orange500: string; + export var orange600: string; + export var orange700: string; + export var orange800: string; + export var orange900: string; + export var orangeA100: string; + export var orangeA200: string; + export var orangeA400: string; + export var orangeA700: string; + + export var deepOrange50: string; + export var deepOrange100: string; + export var deepOrange200: string; + export var deepOrange300: string; + export var deepOrange400: string; + export var deepOrange500: string; + export var deepOrange600: string; + export var deepOrange700: string; + export var deepOrange800: string; + export var deepOrange900: string; + export var deepOrangeA100: string; + export var deepOrangeA200: string; + export var deepOrangeA400: string; + export var deepOrangeA700: string; + + export var brown50: string; + export var brown100: string; + export var brown200: string; + export var brown300: string; + export var brown400: string; + export var brown500: string; + export var brown600: string; + export var brown700: string; + export var brown800: string; + export var brown900: string; + + export var blueGrey50: string; + export var blueGrey100: string; + export var blueGrey200: string; + export var blueGrey300: string; + export var blueGrey400: string; + export var blueGrey500: string; + export var blueGrey600: string; + export var blueGrey700: string; + export var blueGrey800: string; + export var blueGrey900: string; + + export var grey50: string; + export var grey100: string; + export var grey200: string; + export var grey300: string; + export var grey400: string; + export var grey500: string; + export var grey600: string; + export var grey700: string; + export var grey800: string; + export var grey900: string; + + export var black: string; + export var white: string; + + export var transparent: string; + export var fullBlack: string; + export var darkBlack: string; + export var lightBlack: string; + export var minBlack: string; + export var faintBlack: string; + export var fullWhite: string; + export var darkWhite: string; + export var lightWhite: string; +} \ No newline at end of file From c28d8e3fa29a75891d974df06fa47716161c8ccc Mon Sep 17 00:00:00 2001 From: Vyacheslav Mostovoy Date: Sun, 20 Sep 2015 10:20:30 +0500 Subject: [PATCH 028/146] change IAnimateService methods signature --- angularjs/angular.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index dac88280d..a220ddde4 100644 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -1718,11 +1718,11 @@ declare module angular { // see http://docs.angularjs.org/api/ng.$animate /////////////////////////////////////////////////////////////////////// interface IAnimateService { - addClass(element: JQuery, className: string, done?: Function): IPromise; + addClass(element: JQuery, className: string, options?: animate.IAnimationOptions): IPromise; enter(element: JQuery, parent: JQuery, after: JQuery, done?: Function): void; leave(element: JQuery, done?: Function): void; move(element: JQuery, parent: JQuery, after: JQuery, done?: Function): void; - removeClass(element: JQuery, className: string, done?: Function): void; + removeClass(element: JQuery, className: string, options?: animate.IAnimationOptions): void; } /////////////////////////////////////////////////////////////////////////// From 48ebe18575ae99d3a4f072a64116d605b92c1431 Mon Sep 17 00:00:00 2001 From: MugeSo Date: Thu, 18 Jun 2015 13:59:27 +0900 Subject: [PATCH 029/146] added definition for swaggerize-express --- swaggerize-express/swaggerize-express.d.ts | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 swaggerize-express/swaggerize-express.d.ts diff --git a/swaggerize-express/swaggerize-express.d.ts b/swaggerize-express/swaggerize-express.d.ts new file mode 100644 index 000000000..ee7f5ca88 --- /dev/null +++ b/swaggerize-express/swaggerize-express.d.ts @@ -0,0 +1,45 @@ +// Type definitions for swaggerize-express 4.x +// Project: https://github.com/krakenjs/swaggerize-express +// Definitions by: TANAKA Koichi + +/* =================== USAGE =================== + + import express = require('express'); + import swaggerize = require('swaggerize-express'); + var app = express(); + app.use(swaggerize({ + api: require('./api.json'), + docspath: '/api-docs', + handlers: './handlers' + }); + + =============================================== */ + +declare module "swaggerize-express" { + import express = require('express'); + function swaggerize(options: swaggerize.Options): express.RequestHandler; + + module swaggerize { + export interface ISwaggerApiDefinition { + swagger: string + host: string + } + + export interface Options { + api: ISwaggerApiDefinition + docspath: String + handlers: String + } + + export interface IConfig { + api: ISwaggerApiDefinition + routes: express.IRoute[] + } + + export interface SwaggerizedExpress extends express.Express { + swagger: IConfig + } + } + + export = swaggerize; +} From 1ac058191fad638d0ae43922a3717deca5cc24bb Mon Sep 17 00:00:00 2001 From: MugeSo Date: Wed, 19 Aug 2015 11:22:48 +0900 Subject: [PATCH 030/146] Add definitions for swaggerize-express --- .../swaggerize-express-tests.ts | 24 ++ swaggerize-express/swaggerize-express.d.ts | 254 +++++++++++++++++- 2 files changed, 273 insertions(+), 5 deletions(-) create mode 100644 swaggerize-express/swaggerize-express-tests.ts diff --git a/swaggerize-express/swaggerize-express-tests.ts b/swaggerize-express/swaggerize-express-tests.ts new file mode 100644 index 000000000..100856618 --- /dev/null +++ b/swaggerize-express/swaggerize-express-tests.ts @@ -0,0 +1,24 @@ +import http = require('http'); +import express = require('express'); +import swaggerize = require('swaggerize-express'); + +var app = express(); +app.use(swaggerize({ + api: { + swagger: "2.0", + host: "localhost:8080", + info: { + title: "swaggerize-express.d.ts test", + version: "1" + }, + paths: { + + } + }, + docspath: '/api-docs', + handlers: './handlers' +})); + +var server = app.listen(18888, 'localhost', function () { + (app).swagger.api.host = server.address().address + ':' + server.address().port; +}); diff --git a/swaggerize-express/swaggerize-express.d.ts b/swaggerize-express/swaggerize-express.d.ts index ee7f5ca88..0f62b1088 100644 --- a/swaggerize-express/swaggerize-express.d.ts +++ b/swaggerize-express/swaggerize-express.d.ts @@ -1,6 +1,7 @@ // Type definitions for swaggerize-express 4.x // Project: https://github.com/krakenjs/swaggerize-express // Definitions by: TANAKA Koichi +// Definitions: https://github.com/borisyankov/DefinitelyTyped /* =================== USAGE =================== @@ -15,24 +16,225 @@ =============================================== */ +/// + declare module "swaggerize-express" { import express = require('express'); function swaggerize(options: swaggerize.Options): express.RequestHandler; module swaggerize { - export interface ISwaggerApiDefinition { - swagger: string - host: string + export module Swagger { + export interface ApiDefinition { + swagger: string + info: InfoObject + host?: string + basePath?: string + schemes?: string[] + consumes?: MimeTypes + produces?: MimeTypes + paths: PathsObject + definitions?: DefinitionsObject + parameters?: ParametersDefinitionsObject + responses?: ResponsesDefinitionsObject + securityDefinitions?: SecurityDefinitionsObject + security?: SecurityRequirementObject[] + tags?: TagObject[] + externalDocs?: ExternalDocumentationObject + } + + type MimeTypes = string[] + + export interface InfoObject { + title: string + description?: string + termsOfService?: string + contact?: ContactObject + license?: LicenseObject + version: string + } + + export interface ContactObject { + name?: string + url?: string + email?: string + } + + export interface LicenseObject { + name: string + url?: string + } + + export interface PathsObject { + [index: string]: PathItemObject|any + } + + export interface PathItemObject { + $ref?: string + get?: OperationObject + put?: OperationObject + post?: OperationObject + 'delete'?: OperationObject + options?: OperationObject + head?: OperationObject + patch?: OperationObject + parameters?: Parameters + } + + export interface OperationObject { + tags?: string[] + summary?: string + description?: string + externalDocs?: ExternalDocumentationObject + operationId?: string + consumes?: MimeTypes + produces?: MimeTypes + parameters?: Parameters + responses: ResponsesObject + schemes?: string[] + deprecated?: boolean + security?: SecurityRequirementObject[] + } + + export interface DefinitionsObject { + [index: string]: SchemaObject + } + + export interface ResponsesObject { + [index: string]: Response|any + 'default': Response + } + + type Response = ResponseObject|ReferenceObject + + export interface ResponsesDefinitionsObject { + [index: string]: ResponseObject + } + + export interface ResponseObject { + description: string + schema?: SchemaObject + headers?: HeadersObject + examples?: ExampleObject + } + + export interface HeadersObject { + [index: string]: HeaderObject + } + + export interface HeaderObject extends ItemsObject { + } + + export interface ExampleObject { + [index: string]: any + } + + export interface SecurityDefinitionsObject { + [index: string]: SecuritySchemeObject + } + + export interface SecuritySchemeObject { + type: string + description?: string + name: string + 'in': string + flow: string + authorizationUrl: string + tokenUrl: string + scopes: ScopesObject + } + + export interface ScopesObject { + [index: string]: any + } + + export interface SecurityRequirementObject { + [index: string]: string[] + } + + export interface TagObject { + name: string + description?: string + externalDocs?: ExternalDocumentationObject + } + + export interface ItemsObject { + type: string + format?: string + items?: ItemsObject + collectionFormat?: string + 'default'?: any + maximum?: number + exclusiveMaximum: boolean + minimum?: number + exclusiveMinimum?: boolean + maxLength?: number + minLength?: number + pattern?: string + maxItems?: number + minItems?: number + uniqueItems?: boolean + 'enum'?: any[] + multipleOf?: number + } + + export interface ParametersDefinitionsObject { + [index: string]: ParameterObject + } + + type Parameters = (ParameterObject|ReferenceObject)[] + + export interface ParameterObject { + name: string + 'in': string + description?: string + required?: boolean + } + + export interface InBodyParameterObject extends ParameterObject { + schema: SchemaObject + } + + export interface GeneralParameterObject extends ParameterObject, ItemsObject { + allowEmptyValue?: boolean + } + + export interface ReferenceObject { + $ref: string + } + + export interface ExternalDocumentationObject { + [index: string]: any + description?: string + url: string + } + + export interface SchemaObject extends IJsonSchema { + [index: string]: any + discriminator?: string + readOnly?: boolean + xml?: XMLObject + externalDocs: ExternalDocumentationObject + example: any + } + + export interface XMLObject { + [index: string]: any + name?: string + namespace?: string + prefix?: string + attribute?: boolean + wrapped?: boolean + } } export interface Options { - api: ISwaggerApiDefinition + api: Swagger.ApiDefinition docspath: String handlers: String } export interface IConfig { - api: ISwaggerApiDefinition + api: Swagger.ApiDefinition routes: express.IRoute[] } @@ -41,5 +243,47 @@ declare module "swaggerize-express" { } } + interface IJsonSchema { + id?: string + $schema?: string + title?: string + description?: string + multipleOf?: number + maximum?: number + exclusiveMaximum?: boolean + minimum?: number + exclusiveMinimum?: boolean + maxLength?: number + minLength?: number + pattern?: string + additionalItems?: boolean | IJsonSchema + items?: IJsonSchema | IJsonSchema[] + maxItems?: number + minItems?: number + uniqueItems?: boolean + maxProperties?: number + minProperties?: number + required?: string[] + additionalProperties?: boolean | IJsonSchema + definitions?: { + [name: string]: IJsonSchema + } + properties?: { + [name: string]: IJsonSchema + } + patternProperties?: { + [name: string]: IJsonSchema + } + dependencies?: { + [name: string]: IJsonSchema | string[] + } + 'enum'?: any[] + type?: string | string[] + allOf?: IJsonSchema[] + anyOf?: IJsonSchema[] + oneOf?: IJsonSchema[] + not?: IJsonSchema + } + export = swaggerize; } From 548d64f9337d44dc2e71999745ba0029ac7b2f94 Mon Sep 17 00:00:00 2001 From: Alex Ford Date: Sun, 20 Sep 2015 08:29:31 -0400 Subject: [PATCH 031/146] [#5751] Add d3.time.format.utc.multi --- d3/d3-tests.ts | 13 +++++++++++++ d3/d3.d.ts | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/d3/d3-tests.ts b/d3/d3-tests.ts index 414a2346e..98888dde7 100644 --- a/d3/d3-tests.ts +++ b/d3/d3-tests.ts @@ -2693,3 +2693,16 @@ function testD3MutlieTimeFormat() { ["%Y", function() { return true; }] ]); } + +function testMultiUtcFormat() { + var format = d3.time.format.utc.multi([ + [".%L", function(d) { return d.getMilliseconds(); }], + [":%S", function(d) { return d.getSeconds(); }], + ["%I:%M", function(d) { return d.getMinutes(); }], + ["%I %p", function(d) { return d.getHours(); }], + ["%a %d", function(d) { return d.getDay() && d.getDate() != 1; }], + ["%b %d", function(d) { return d.getDate() != 1; }], + ["%B", function(d) { return d.getMonth(); }], + ["%Y", function() { return true; }] + ]); +} \ No newline at end of file diff --git a/d3/d3.d.ts b/d3/d3.d.ts index 2d1b20c3b..fbeca365e 100644 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -1802,6 +1802,10 @@ declare module d3 { export module format { export function multi(formats: Array<[string, (d: Date) => boolean|number]>): Format; export function utc(specifier: string): Format; + module utc { + export function multi(formats: Array<[string, (d: Date) => boolean|number]>): Format; + } + export var iso: Format; } From 1e26d4855170e319db0db0c70612c3fe1f357ff6 Mon Sep 17 00:00:00 2001 From: Kaur Kuut Date: Thu, 17 Sep 2015 17:56:38 +0300 Subject: [PATCH 032/146] Added definitions for Featherlight v1.3.4. --- featherlight/featherlight-tests.ts | 169 +++++++++++++++++++++++++++++ featherlight/featherlight.d.ts | 114 +++++++++++++++++++ 2 files changed, 283 insertions(+) create mode 100644 featherlight/featherlight-tests.ts create mode 100644 featherlight/featherlight.d.ts diff --git a/featherlight/featherlight-tests.ts b/featherlight/featherlight-tests.ts new file mode 100644 index 000000000..ed74a201e --- /dev/null +++ b/featherlight/featherlight-tests.ts @@ -0,0 +1,169 @@ +// Tests by: Kaur Kuut + +/// +/// + +// Every option as default +var defaultOptions = { + namespace: 'featherlight', + targetAttr: 'data-featherlight', + variant: null as string, + resetCss: false, + background: null as string, + openTrigger: 'click', + closeTrigger: 'click', + filter: null as string, + root: 'body', + openSpeed: 250, + closeSpeed: 250, + closeOnClick: 'background', + closeOnEsc: true, + closeIcon: '✕', + loading: '', + persist: false, + otherClose: null as string, + beforeOpen: $.noop, + beforeContent: $.noop, + beforeClose: $.noop, + afterOpen: $.noop, + afterContent: $.noop, + afterClose: $.noop, + onKeyUp: $.noop, + onResize: $.noop, + type: null as string, + contentFilters: ['jquery', 'image', 'html', 'ajax', 'iframe', 'text'] +}; + +// Every option changed +var changedOptions = { + namespace: 'foo', + targetAttr: 'foo', + variant: 'foo', + resetCss: true, + background: '
', + openTrigger: 'focus', + closeTrigger: 'blur', + filter: 'foo', + root: 'foo', + openSpeed: 'fast', + closeSpeed: 'fast', + closeOnClick: false, + closeOnEsc: false, + closeIcon: 'foo', + loading: 'foo', + persist: 'shared', + otherClose: 'foo', + beforeOpen: (e: JQueryEventObject) => false, + beforeContent: (e: JQueryEventObject) => false, + beforeClose: (e: JQueryEventObject) => false, + afterOpen: (e: JQueryEventObject) => false, + afterContent: (e: JQueryEventObject) => false, + afterClose: (e: JQueryEventObject) => false, + onKeyUp: (e: JQueryEventObject) => false, + onResize: (e: JQueryEventObject) => false, + type: 'text' +}; + +// Turn off auto bind +$.featherlight.autoBind = false; + +// Change some defaults +$.featherlight.defaults.namespace = 'foo'; +$.featherlight.defaults.openSpeed = 500; +$.featherlight.defaults.persist = true; +$.featherlight.defaults.text = 'foo'; + +// Do the simplest manual bind +$('#id').featherlight(); + +// Bind #id to open #fl +$('#id').featherlight('#fl'); + +// Bind #id to open #fl with persistance +$('#id').featherlight('#fl', {persist: true}); + +// Bind #id to open jQuery object +$('#id').featherlight($('Foo!')); + +// Bind #id to open jQuery object with persistance +$('#id').featherlight($('Foo!'), {persist: true}); + +// Bind #id to open #fl with every option set to default +$('#id').featherlight('#fl', defaultOptions); + +// Bind #id to open jQuery object with every option set to default +$('#id').featherlight($('Foo!'), defaultOptions); + +// Bind #id to open #fl with every option changed +$('#id').featherlight('#fl', changedOptions); + +// Bind #id to open jQuery object with every option changed +$('#id').featherlight($('Foo!'), changedOptions); + +// Open the default +$.featherlight(); +new $.featherlight; + +// Open just text +$.featherlight({text: 'Foo!'}).open(); +new $.featherlight({text: 'Foo!'}).open(); + +// Open #fl, and close it +$.featherlight('#fl').close(); +new $.featherlight('#fl').close(); + +// Open #fl with persistance, and close it +$.featherlight('#fl', {persist: true}).close(); +new $.featherlight('#fl', {persist: true}).close(); + +// Open jQuery object, and close it +$.featherlight($('Foo!')).close(); +new $.featherlight($('Foo!')).close(); + +// Open jQuery object with persistance, and close it +$.featherlight($('Foo!'), {persist: true}).close(); +new $.featherlight($('Foo!'), {persist: true}).close(); + +// Open #fl with every option set to default, and close it +$.featherlight('#fl', defaultOptions).close(); +new $.featherlight('#fl', defaultOptions).close(); + +// Open jQuery object with every option set to default, and close it +$.featherlight($('Foo!'), defaultOptions).close(); +new $.featherlight($('Foo!'), defaultOptions).close(); + +// Open #fl with every option changed, and close it +$.featherlight('#fl', changedOptions).close(); +new $.featherlight('#fl', changedOptions).close(); + +// Open jQuery object with every option changed, and close it +$.featherlight($('Foo!'), changedOptions).close(); +new $.featherlight($('Foo!'), changedOptions).close(); + +// Define a custom content filter +// Note: Unfortunately $.featherlight.contentFilters.feed = .. doesn't seem to work +$.featherlight.contentFilters['feed'] = { + regex: /^feed:/, + process: function(url: string) { return $('Loading...'); } +}; + +// Close the currently open fl +$.featherlight.close(); + +// Get all the opened fls and close the first +$.featherlight.opened()[0].close(); + +// Get the currently opened fl +var fl = $.featherlight.current(); + +// .. and close it +fl.close(); + +// .. and open it once more +fl.open(); + +// .. and edit its namespace +fl.namespace = 'foo'; + +// .. and add a special event handler +fl.afterClose = (e: JQueryEventObject) => false; diff --git a/featherlight/featherlight.d.ts b/featherlight/featherlight.d.ts new file mode 100644 index 000000000..ad4c1d1c2 --- /dev/null +++ b/featherlight/featherlight.d.ts @@ -0,0 +1,114 @@ +// Type definitions for Featherlight v1.3.4 +// Project: https://noelboss.github.io/featherlight/ +// Definitions by: Kaur Kuut +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module Featherlight { + interface Config { + namespace?: string; + targetAttr?: string; + variant?: string; + resetCss?: boolean; + background?: string; + openTrigger?: string; + closeTrigger?: string; + filter?: string; + root?: string; + openSpeed?: number | string; + closeSpeed?: number | string; + closeOnClick?: boolean | string; + closeOnEsc?: boolean; + closeIcon?: string; + loading?: string; + persist?: boolean | string; + otherClose?: string; + beforeOpen?: (event: JQueryEventObject) => any; + beforeContent?: (event: JQueryEventObject) => any; + beforeClose?: (event: JQueryEventObject) => any; + afterOpen?: (event: JQueryEventObject) => any; + afterContent?: (event: JQueryEventObject) => any; + afterClose?: (event: JQueryEventObject) => any; + onKeyUp?: (event: JQueryEventObject) => any; + onResize?: (event: JQueryEventObject) => any; + type?: string; + contentFilters?: any; + jquery?: JQuery; + image?: string; + html?: string; + ajax?: string; + text?: string; + } + + interface ContentFilter { + regex?: RegExp; + test?(data: JQuery | string): boolean; + process?(data: JQuery | string): JQuery | JQueryPromise; + } + + interface ContentFilters { + [name: string]: ContentFilter; + } + + interface Featherlight extends Config { + target: JQuery | string; + $instance: JQuery; + $content: JQuery; + + setup(target: JQuery, config?: Config): Featherlight; + setup(target: string, config?: Config): Featherlight; + setup(config: Config): Featherlight; + setup(): Featherlight; + + getContent(): JQuery | JQueryPromise; + setContent($content: JQuery): Featherlight; + setContent($content: JQueryPromise): Featherlight; + open(event?: JQueryEventObject): JQueryPromise; + close(event?: JQueryEventObject): JQueryPromise; + } + + interface FeatherlightStatic { + ($content: JQuery, config?: Config): Featherlight; + ($content: string, config?: Config): Featherlight; + (config: Config): Featherlight; + (): Featherlight; + + new($content: JQuery, config?: Config): Featherlight; + new($content: string, config?: Config): Featherlight; + new(config: Config): Featherlight; + new(): Featherlight; + + attach($source: JQuery, $content: JQuery, config?: Config): JQuery; + attach($source: JQuery, $content: string, config?: Config): JQuery; + attach($source: JQuery, config: Config): JQuery; + attach($source: JQuery): JQuery; + + id: number; + autoBind: boolean | string; + defaults: Config; + contentFilters: ContentFilters; + functionAttributes: string[]; + + readElementConfig(element: HTMLElement, namespace: string): any; + extend(child: any, defaults: any): any; + current(): Featherlight; + opened(): Featherlight[]; + close(): JQueryPromise; + } + + interface JQueryExtension { + ($content: JQuery, config?: Config): JQuery; + ($content: string, config?: Config): JQuery; + (config: Config): JQuery; + (): JQuery; + } +} + +interface JQueryStatic { + featherlight: Featherlight.FeatherlightStatic; +} + +interface JQuery { + featherlight: Featherlight.JQueryExtension; +} From ccd32787a2aed5f876693b2c8d7100d1daba4782 Mon Sep 17 00:00:00 2001 From: Stephen Lautier Date: Sun, 20 Sep 2015 17:46:57 +0200 Subject: [PATCH 033/146] wrapped comments around 80-100 chars as suggested --- angularjs/angular-cookies.d.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/angularjs/angular-cookies.d.ts b/angularjs/angular-cookies.d.ts index 617b9f793..25efc42de 100644 --- a/angularjs/angular-cookies.d.ts +++ b/angularjs/angular-cookies.d.ts @@ -22,16 +22,19 @@ declare module angular.cookies { */ interface ICookiesOptions { /** - * The cookie will be available only for this path and its sub-paths. By default, this would be the URL that appears in your base tag. + * The cookie will be available only for this path and its sub-paths. + * By default, this would be the URL that appears in your base tag. */ path?: string; /** - * The cookie will be available only for this domain and its sub-domains. - * For obvious security reasons the user agent will not accept the cookie if the current domain is not a sub domain or equals to the requested domain. + * The cookie will be available only for this domain and its sub-domains. + * For obvious security reasons the user agent will not accept the cookie if the + * current domain is not a sub domain or equals to the requested domain. */ domain?: string; /** - * String of the form "Wdy, DD Mon YYYY HH:MM:SS GMT" or a Date object indicating the exact date/time this cookie will expire. + * String of the form "Wdy, DD Mon YYYY HH:MM:SS GMT" or a Date object + * indicating the exact date/time this cookie will expire. */ expires?: string|Date; /** From 48c9d444f3b51ca8078b01e835a94ad88ffb0102 Mon Sep 17 00:00:00 2001 From: Shiak1 Date: Sun, 20 Sep 2015 13:37:55 -0400 Subject: [PATCH 034/146] Update request.d.ts Make formData optional. --- request/request.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/request/request.d.ts b/request/request.d.ts index 5332aa90a..7fb7e9470 100644 --- a/request/request.d.ts +++ b/request/request.d.ts @@ -62,7 +62,7 @@ declare module 'request' { uri?: string; callback?: (error: any, response: http.IncomingMessage, body: any) => void; jar?: any; // CookieJar - formData: any; // Object + formData?: any; // Object form?: any; // Object or string auth?: AuthOptions; oauth?: OAuthOptions; From f38b15bc38f64e98950f3610dc7fca221e4ddec8 Mon Sep 17 00:00:00 2001 From: Lukas Sembera Date: Sun, 20 Sep 2015 19:43:16 +0200 Subject: [PATCH 035/146] Add missing headers() function to restangular's IResponse --- restangular/restangular-tests.ts | 3 ++- restangular/restangular.d.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/restangular/restangular-tests.ts b/restangular/restangular-tests.ts index 33c46a421..9b5a9c30b 100644 --- a/restangular/restangular-tests.ts +++ b/restangular/restangular-tests.ts @@ -92,7 +92,8 @@ myApp.controller('TestCtrl', ( Restangular.setMethodOverriders(["put", "patch"]); Restangular.setErrorInterceptor(function (response) { - console.error('' + response.status + ' ' + response.data); + let location: string = response.headers('Location'); + console.error('' + response.status + ' ' + response.data + ' ' + location); }); Restangular.setRequestSuffix('.json'); diff --git a/restangular/restangular.d.ts b/restangular/restangular.d.ts index bce357482..b09e4affd 100644 --- a/restangular/restangular.d.ts +++ b/restangular/restangular.d.ts @@ -43,6 +43,7 @@ declare module restangular { interface IResponse { status: number; data: any; + headers(name: string): string; config: { method: string; url: string; From 83d234fe327c81d97df0eb1979aa934ac0d3f30a Mon Sep 17 00:00:00 2001 From: Dan Lewi Harkestad Date: Sun, 20 Sep 2015 23:47:10 +0200 Subject: [PATCH 036/146] HighchartsPieChart.colors is a string array. --- highcharts/highcharts.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/highcharts/highcharts.d.ts b/highcharts/highcharts.d.ts index cb48604e3..0e2be306c 100644 --- a/highcharts/highcharts.d.ts +++ b/highcharts/highcharts.d.ts @@ -888,7 +888,7 @@ interface HighchartsPieChart { borderColor?: string; borderWidth?: number; center?: string[]; - colors?: string; + colors?: string[]; cursor?: string; dataLabels?: HighchartsDataLabels; depth?: number; From 54704912913599ebcee49266d18e35169b546147 Mon Sep 17 00:00:00 2001 From: Nathan Brown Date: Sun, 20 Sep 2015 16:44:13 -0700 Subject: [PATCH 037/146] material-ui: Export interfaces more directly through typed variables. Include Colors in main module. --- material-ui/material-ui.d.ts | 673 ++++++++++++++++++----------------- 1 file changed, 356 insertions(+), 317 deletions(-) diff --git a/material-ui/material-ui.d.ts b/material-ui/material-ui.d.ts index 85afdb2bc..673435c24 100644 --- a/material-ui/material-ui.d.ts +++ b/material-ui/material-ui.d.ts @@ -24,7 +24,6 @@ declare module "material-ui" { export import ClearFix = __MaterialUI.ClearFix; // require('material-ui/lib/clearfix'); export import DatePicker = __MaterialUI.DatePicker.DatePicker; // require('material-ui/lib/date-picker/date-picker'); export import DatePickerDialog = __MaterialUI.DatePicker.DatePickerDialog; // require('material-ui/lib/date-picker/date-picker-dialog'); - export import DialogAction = __MaterialUI.DialogAction; // type definition export import Dialog = __MaterialUI.Dialog // require('material-ui/lib/dialog'); export import DropDownIcon = __MaterialUI.DropDownIcon; // require('material-ui/lib/drop-down-icon'); export import DropDownMenu = __MaterialUI.DropDownMenu; // require('material-ui/lib/drop-down-menu'); @@ -83,11 +82,16 @@ declare module "material-ui" { export import ToolbarTitle = __MaterialUI.Toolbar.ToolbarTitle; // require('material-ui/lib/toolbar/toolbar-title'); export import Tooltip = __MaterialUI.Tooltip; // require('material-ui/lib/tooltip'); export import Utils = __MaterialUI.Utils; // require('material-ui/lib/utils/'); + + // export type definitions + export import TouchTapEvent = __MaterialUI.TouchTapEvent; + export import TouchTapEventHandler = __MaterialUI.TouchTapEventHandler; + export import DialogAction = __MaterialUI.DialogAction; } declare namespace __MaterialUI { import React = __React; - + // ReactLink is from "react/addons" interface ReactLink { value: T; @@ -634,12 +638,32 @@ declare namespace __MaterialUI { export class RefreshIndicator extends React.Component { } - export interface Ripples { + namespace Ripples { + interface CircleRippleProp extends React.Props { + ref?: string | ((component: CircleRipple) => any); + + } + export class CircleRipple extends React.Component { + } + + interface FocusRippleProp extends React.Props { + ref?: string | ((component: FocusRipple) => any); + + } + export class FocusRipple extends React.Component { + } + + interface TouchRippleProp extends React.Props { + ref?: string | ((component: TouchRipple) => any); + + } + export class TouchRipple extends React.Component { + } } interface SelectFieldProp extends React.Props { ref?: string | ((component: SelectField) => any); - + // passed to TextField errorStyle?: React.CSSProperties; errorText?: string; @@ -707,12 +731,14 @@ declare namespace __MaterialUI { } export namespace Styles { - interface AutoPrefixProp extends React.Props { - ref?: string | ((component: AutoPrefix) => any); + interface AutoPrefix { + all(styles: any): any; + set(style: any, key: string, value: string | number): void; + single(key: string): string; + singleHyphened(key: string): string; + } + export var AutoPrefix: AutoPrefix; - } - export class AutoPrefix extends React.Component { - } interface Spacing { iconSize?: number; @@ -887,14 +913,15 @@ declare namespace __MaterialUI { setComponentThemes(overrides: Theme): void; } - interface TransitionsProp extends React.Props { - ref?: string | ((component: Transitions) => any); - - } - export class Transitions extends React.Component { + interface Transitions { + easeOut(duration?: string, property?: string | string[], delay?: string, easeFunction?: string): string; + create(duration?: string, property?: string, delay?: string, easeFunction?: string): string; + easeOutFunction: string; + easeInOutFunction: string; } + export var Transitions: Transitions; - export class Typography { + class TypographyClass { textFullBlack:string; textDarkBlack: string; textLightBlack: string; @@ -910,6 +937,7 @@ declare namespace __MaterialUI { fontStyleButtonFontSize: number; } + export var Typography: TypographyClass; } interface SnackbarProp extends React.Props { @@ -1112,6 +1140,7 @@ declare namespace __MaterialUI { contrastRatio(background: string, foreground: string): string; contrastRatioLevel(background: string, foreground: string): any; } + export var ColorManipulator: ColorManipulator; interface CssEvent { transitionEndEventName(): string; @@ -1119,6 +1148,7 @@ declare namespace __MaterialUI { onTransitionEnd(el: Element, callback: (e: Event) => any): void; onAnimationEnd(el: Element, callback: (e: Event) => any): void; } + export var CssEvent: CssEvent; interface Dom { isDescendant(parent: Element, child: Element): boolean; @@ -1131,6 +1161,7 @@ declare namespace __MaterialUI { forceRedraw(el: Element): void; withoutTransition(el: Element, callback: () => any): void; } + export var Dom: Dom; interface Events { once(el: Element, type: string, callback: (e: Event) => any): void; @@ -1138,6 +1169,7 @@ declare namespace __MaterialUI { off(el: Element, type: string, callback: (e: Event) => any): void; isKeyboard(e: Event): boolean; } + export var Events: Events; function Extend(base: T, override: S1): (T & S1); @@ -1147,6 +1179,19 @@ declare namespace __MaterialUI { push(array: T[], obj: T): T[]; shift(array: T[]): T[]; } + export var ImmutabilityHelper: ImmutabilityHelper; + + interface KeyCode { + DOWN: number; + ESC: number; + ENTER: number; + LEFT: number; + RIGHT: number; + SPACE: number; + TAB: number; + UP: number; + } + var KeyCode: KeyCode; interface KeyLine { Desktop: { @@ -1158,14 +1203,17 @@ declare namespace __MaterialUI { getIncrementalDim(dim: number): number; } + export var KeyLine: KeyLine; interface UniqueId { generate(): string; } + export var UniqueId: UniqueId; interface Styles { mergeAndPrefix(base: {}, ...args: {}[]): any; } + export var Styles: Styles; } // New menus available only through requiring directly to the end file @@ -1404,8 +1452,9 @@ declare module 'material-ui/lib/refresh-indicator' { } declare module 'material-ui/lib/ripples/' { - var Ripples: __MaterialUI.Ripples; - export = Ripples; + export import CircleRipple = __MaterialUI.Ripples.CircleRipple; + export import FocusRipple = __MaterialUI.Ripples.FocusRipple; + export import TouchRipple = __MaterialUI.Ripples.TouchRipple; } declare module 'material-ui/lib/select-field' { @@ -1434,8 +1483,8 @@ declare module 'material-ui/lib/svg-icons/navigation/chevron-right' { declare module 'material-ui/lib/styles/' { export import AutoPrefix = __MaterialUI.Styles.AutoPrefix; // require('material-ui/lib/styles/auto-prefix'); - export import Colors = require('material-ui/lib/styles/colors'); - export import Spacing = __MaterialUI.Styles.Spacing; // require('material-ui/lib/styles/spacing'); + export import Colors = __MaterialUI.Styles.Colors; // require('material-ui/lib/styles/colors'); + export import Spacing = require('material-ui/lib/styles/spacing'); export import ThemeManager = __MaterialUI.Styles.ThemeManager; // require('material-ui/lib/styles/theme-manager'); export import Transitions = __MaterialUI.Styles.Transitions; // require('material-ui/lib/styles/transitions'); export import Typography = __MaterialUI.Styles.Typography; // require('material-ui/lib/styles/typography'); @@ -1459,7 +1508,7 @@ declare module 'material-ui/lib/styles/transitions' { } declare module 'material-ui/lib/styles/typography' { - export = new __MaterialUI.Styles.Typography(); + export = __MaterialUI.Styles.Typography; } declare module 'material-ui/lib/snackbar' { @@ -1545,30 +1594,26 @@ declare module 'material-ui/lib/utils/' { export import Events = __MaterialUI.Utils.Events; // require('material-ui/lib/utils/events'); export import Extend = __MaterialUI.Utils.Extend; // require('material-ui/lib/utils/extend'); export import ImmutabilityHelper = __MaterialUI.Utils.ImmutabilityHelper; // require('material-ui/lib/utils/immutability-helper'); - export import KeyCode = require('material-ui/lib/utils/key-code'); + export import KeyCode = __MaterialUI.Utils.KeyCode; // require('material-ui/lib/utils/key-code'); export import KeyLine = __MaterialUI.Utils.KeyLine; // require('material-ui/lib/utils/key-line'); export import UniqueId = __MaterialUI.Utils.UniqueId; // require('material-ui/lib/utils/unique-id'); export import Styles = __MaterialUI.Utils.Styles; // require('material-ui/lib/utils/styles'); } declare module 'material-ui/lib/utils/color-manipulator' { - let ColorManipulator: __MaterialUI.Utils.ColorManipulator; - export = ColorManipulator; + export = __MaterialUI.Utils.ColorManipulator; } declare module 'material-ui/lib/utils/css-event' { - let CssEvent: __MaterialUI.Utils.CssEvent; - export = CssEvent; + export = __MaterialUI.Utils.CssEvent; } declare module 'material-ui/lib/utils/dom' { - let Dom: __MaterialUI.Utils.Dom; - export = Dom; + export = __MaterialUI.Utils.Dom; } declare module 'material-ui/lib/utils/events' { - let Events: __MaterialUI.Utils.Events; - export = Events; + export = __MaterialUI.Utils.Events; } declare module 'material-ui/lib/utils/extend' { @@ -1576,338 +1621,332 @@ declare module 'material-ui/lib/utils/extend' { } declare module 'material-ui/lib/utils/immutability-helper' { - let ImmutabilityHelper: __MaterialUI.Utils.ImmutabilityHelper; - export = ImmutabilityHelper; + export = __MaterialUI.Utils.ImmutabilityHelper; } declare module 'material-ui/lib/utils/key-code' { - export = { - DOWN: 40, - ESC: 27, - ENTER: 13, - LEFT: 37, - RIGHT: 39, - SPACE: 32, - TAB: 9, - UP: 38, - } + export = __MaterialUI.Utils.KeyCode; } declare module 'material-ui/lib/utils/key-line' { - let KeyLine: __MaterialUI.Utils.KeyLine; - export = KeyLine; + export = __MaterialUI.Utils.KeyLine; } declare module 'material-ui/lib/utils/unique-id' { - let UniqueId: __MaterialUI.Utils.UniqueId; - export = UniqueId; + export = __MaterialUI.Utils.UniqueId; } declare module 'material-ui/lib/utils/styles' { - let Styles: __MaterialUI.Utils.Styles; - export = Styles; + export = __MaterialUI.Utils.Styles; } declare module "material-ui/lib/menus/icon-menu" { - export = __MaterialUI.Menus.IconMenu; + export = __MaterialUI.Menus.IconMenu; } declare module "material-ui/lib/menus/menu" { - export = __MaterialUI.Menus.Menu; + export = __MaterialUI.Menus.Menu; } declare module "material-ui/lib/menus/menu-item" { - export = __MaterialUI.Menus.MenuItem; + export = __MaterialUI.Menus.MenuItem; } declare module "material-ui/lib/menus/menu-divider" { - export = __MaterialUI.Menus.MenuDivider; + export = __MaterialUI.Menus.MenuDivider; } declare module "material-ui/lib/styles/colors" { - export var red50: string; - export var red100: string; - export var red200: string; - export var red300: string; - export var red400: string; - export var red500: string; - export var red600: string; - export var red700: string; - export var red800: string; - export var red900: string; - export var redA100: string; - export var redA200: string; - export var redA400: string; - export var redA700: string; + export = __MaterialUI.Styles.Colors; +} - export var pink50: string; - export var pink100: string; - export var pink200: string; - export var pink300: string; - export var pink400: string; - export var pink500: string; - export var pink600: string; - export var pink700: string; - export var pink800: string; - export var pink900: string; - export var pinkA100: string; - export var pinkA200: string; - export var pinkA400: string; - export var pinkA700: string; +declare namespace __MaterialUI.Styles { + interface Colors { + red50: string; + red100: string; + red200: string; + red300: string; + red400: string; + red500: string; + red600: string; + red700: string; + red800: string; + red900: string; + redA100: string; + redA200: string; + redA400: string; + redA700: string; - export var purple50: string; - export var purple100: string; - export var purple200: string; - export var purple300: string; - export var purple400: string; - export var purple500: string; - export var purple600: string; - export var purple700: string; - export var purple800: string; - export var purple900: string; - export var purpleA100: string; - export var purpleA200: string; - export var purpleA400: string; - export var purpleA700: string; + pink50: string; + pink100: string; + pink200: string; + pink300: string; + pink400: string; + pink500: string; + pink600: string; + pink700: string; + pink800: string; + pink900: string; + pinkA100: string; + pinkA200: string; + pinkA400: string; + pinkA700: string; - export var deepPurple50: string; - export var deepPurple100: string; - export var deepPurple200: string; - export var deepPurple300: string; - export var deepPurple400: string; - export var deepPurple500: string; - export var deepPurple600: string; - export var deepPurple700: string; - export var deepPurple800: string; - export var deepPurple900: string; - export var deepPurpleA100: string; - export var deepPurpleA200: string; - export var deepPurpleA400: string; - export var deepPurpleA700: string; + purple50: string; + purple100: string; + purple200: string; + purple300: string; + purple400: string; + purple500: string; + purple600: string; + purple700: string; + purple800: string; + purple900: string; + purpleA100: string; + purpleA200: string; + purpleA400: string; + purpleA700: string; - export var indigo50: string; - export var indigo100: string; - export var indigo200: string; - export var indigo300: string; - export var indigo400: string; - export var indigo500: string; - export var indigo600: string; - export var indigo700: string; - export var indigo800: string; - export var indigo900: string; - export var indigoA100: string; - export var indigoA200: string; - export var indigoA400: string; - export var indigoA700: string; + deepPurple50: string; + deepPurple100: string; + deepPurple200: string; + deepPurple300: string; + deepPurple400: string; + deepPurple500: string; + deepPurple600: string; + deepPurple700: string; + deepPurple800: string; + deepPurple900: string; + deepPurpleA100: string; + deepPurpleA200: string; + deepPurpleA400: string; + deepPurpleA700: string; - export var blue50: string; - export var blue100: string; - export var blue200: string; - export var blue300: string; - export var blue400: string; - export var blue500: string; - export var blue600: string; - export var blue700: string; - export var blue800: string; - export var blue900: string; - export var blueA100: string; - export var blueA200: string; - export var blueA400: string; - export var blueA700: string; + indigo50: string; + indigo100: string; + indigo200: string; + indigo300: string; + indigo400: string; + indigo500: string; + indigo600: string; + indigo700: string; + indigo800: string; + indigo900: string; + indigoA100: string; + indigoA200: string; + indigoA400: string; + indigoA700: string; - export var lightBlue50: string; - export var lightBlue100: string; - export var lightBlue200: string; - export var lightBlue300: string; - export var lightBlue400: string; - export var lightBlue500: string; - export var lightBlue600: string; - export var lightBlue700: string; - export var lightBlue800: string; - export var lightBlue900: string; - export var lightBlueA100: string; - export var lightBlueA200: string; - export var lightBlueA400: string; - export var lightBlueA700: string; + blue50: string; + blue100: string; + blue200: string; + blue300: string; + blue400: string; + blue500: string; + blue600: string; + blue700: string; + blue800: string; + blue900: string; + blueA100: string; + blueA200: string; + blueA400: string; + blueA700: string; - export var cyan50: string; - export var cyan100: string; - export var cyan200: string; - export var cyan300: string; - export var cyan400: string; - export var cyan500: string; - export var cyan600: string; - export var cyan700: string; - export var cyan800: string; - export var cyan900: string; - export var cyanA100: string; - export var cyanA200: string; - export var cyanA400: string; - export var cyanA700: string; + lightBlue50: string; + lightBlue100: string; + lightBlue200: string; + lightBlue300: string; + lightBlue400: string; + lightBlue500: string; + lightBlue600: string; + lightBlue700: string; + lightBlue800: string; + lightBlue900: string; + lightBlueA100: string; + lightBlueA200: string; + lightBlueA400: string; + lightBlueA700: string; - export var teal50: string; - export var teal100: string; - export var teal200: string; - export var teal300: string; - export var teal400: string; - export var teal500: string; - export var teal600: string; - export var teal700: string; - export var teal800: string; - export var teal900: string; - export var tealA100: string; - export var tealA200: string; - export var tealA400: string; - export var tealA700: string; + cyan50: string; + cyan100: string; + cyan200: string; + cyan300: string; + cyan400: string; + cyan500: string; + cyan600: string; + cyan700: string; + cyan800: string; + cyan900: string; + cyanA100: string; + cyanA200: string; + cyanA400: string; + cyanA700: string; - export var green50: string; - export var green100: string; - export var green200: string; - export var green300: string; - export var green400: string; - export var green500: string; - export var green600: string; - export var green700: string; - export var green800: string; - export var green900: string; - export var greenA100: string; - export var greenA200: string; - export var greenA400: string; - export var greenA700: string; + teal50: string; + teal100: string; + teal200: string; + teal300: string; + teal400: string; + teal500: string; + teal600: string; + teal700: string; + teal800: string; + teal900: string; + tealA100: string; + tealA200: string; + tealA400: string; + tealA700: string; - export var lightGreen50: string; - export var lightGreen100: string; - export var lightGreen200: string; - export var lightGreen300: string; - export var lightGreen400: string; - export var lightGreen500: string; - export var lightGreen600: string; - export var lightGreen700: string; - export var lightGreen800: string; - export var lightGreen900: string; - export var lightGreenA100: string; - export var lightGreenA200: string; - export var lightGreenA400: string; - export var lightGreenA700: string; + green50: string; + green100: string; + green200: string; + green300: string; + green400: string; + green500: string; + green600: string; + green700: string; + green800: string; + green900: string; + greenA100: string; + greenA200: string; + greenA400: string; + greenA700: string; - export var lime50: string; - export var lime100: string; - export var lime200: string; - export var lime300: string; - export var lime400: string; - export var lime500: string; - export var lime600: string; - export var lime700: string; - export var lime800: string; - export var lime900: string; - export var limeA100: string; - export var limeA200: string; - export var limeA400: string; - export var limeA700: string; + lightGreen50: string; + lightGreen100: string; + lightGreen200: string; + lightGreen300: string; + lightGreen400: string; + lightGreen500: string; + lightGreen600: string; + lightGreen700: string; + lightGreen800: string; + lightGreen900: string; + lightGreenA100: string; + lightGreenA200: string; + lightGreenA400: string; + lightGreenA700: string; - export var yellow50: string; - export var yellow100: string; - export var yellow200: string; - export var yellow300: string; - export var yellow400: string; - export var yellow500: string; - export var yellow600: string; - export var yellow700: string; - export var yellow800: string; - export var yellow900: string; - export var yellowA100: string; - export var yellowA200: string; - export var yellowA400: string; - export var yellowA700: string; + lime50: string; + lime100: string; + lime200: string; + lime300: string; + lime400: string; + lime500: string; + lime600: string; + lime700: string; + lime800: string; + lime900: string; + limeA100: string; + limeA200: string; + limeA400: string; + limeA700: string; - export var amber50: string; - export var amber100: string; - export var amber200: string; - export var amber300: string; - export var amber400: string; - export var amber500: string; - export var amber600: string; - export var amber700: string; - export var amber800: string; - export var amber900: string; - export var amberA100: string; - export var amberA200: string; - export var amberA400: string; - export var amberA700: string; + yellow50: string; + yellow100: string; + yellow200: string; + yellow300: string; + yellow400: string; + yellow500: string; + yellow600: string; + yellow700: string; + yellow800: string; + yellow900: string; + yellowA100: string; + yellowA200: string; + yellowA400: string; + yellowA700: string; - export var orange50: string; - export var orange100: string; - export var orange200: string; - export var orange300: string; - export var orange400: string; - export var orange500: string; - export var orange600: string; - export var orange700: string; - export var orange800: string; - export var orange900: string; - export var orangeA100: string; - export var orangeA200: string; - export var orangeA400: string; - export var orangeA700: string; + amber50: string; + amber100: string; + amber200: string; + amber300: string; + amber400: string; + amber500: string; + amber600: string; + amber700: string; + amber800: string; + amber900: string; + amberA100: string; + amberA200: string; + amberA400: string; + amberA700: string; - export var deepOrange50: string; - export var deepOrange100: string; - export var deepOrange200: string; - export var deepOrange300: string; - export var deepOrange400: string; - export var deepOrange500: string; - export var deepOrange600: string; - export var deepOrange700: string; - export var deepOrange800: string; - export var deepOrange900: string; - export var deepOrangeA100: string; - export var deepOrangeA200: string; - export var deepOrangeA400: string; - export var deepOrangeA700: string; + orange50: string; + orange100: string; + orange200: string; + orange300: string; + orange400: string; + orange500: string; + orange600: string; + orange700: string; + orange800: string; + orange900: string; + orangeA100: string; + orangeA200: string; + orangeA400: string; + orangeA700: string; - export var brown50: string; - export var brown100: string; - export var brown200: string; - export var brown300: string; - export var brown400: string; - export var brown500: string; - export var brown600: string; - export var brown700: string; - export var brown800: string; - export var brown900: string; + deepOrange50: string; + deepOrange100: string; + deepOrange200: string; + deepOrange300: string; + deepOrange400: string; + deepOrange500: string; + deepOrange600: string; + deepOrange700: string; + deepOrange800: string; + deepOrange900: string; + deepOrangeA100: string; + deepOrangeA200: string; + deepOrangeA400: string; + deepOrangeA700: string; - export var blueGrey50: string; - export var blueGrey100: string; - export var blueGrey200: string; - export var blueGrey300: string; - export var blueGrey400: string; - export var blueGrey500: string; - export var blueGrey600: string; - export var blueGrey700: string; - export var blueGrey800: string; - export var blueGrey900: string; + brown50: string; + brown100: string; + brown200: string; + brown300: string; + brown400: string; + brown500: string; + brown600: string; + brown700: string; + brown800: string; + brown900: string; - export var grey50: string; - export var grey100: string; - export var grey200: string; - export var grey300: string; - export var grey400: string; - export var grey500: string; - export var grey600: string; - export var grey700: string; - export var grey800: string; - export var grey900: string; + blueGrey50: string; + blueGrey100: string; + blueGrey200: string; + blueGrey300: string; + blueGrey400: string; + blueGrey500: string; + blueGrey600: string; + blueGrey700: string; + blueGrey800: string; + blueGrey900: string; - export var black: string; - export var white: string; + grey50: string; + grey100: string; + grey200: string; + grey300: string; + grey400: string; + grey500: string; + grey600: string; + grey700: string; + grey800: string; + grey900: string; - export var transparent: string; - export var fullBlack: string; - export var darkBlack: string; - export var lightBlack: string; - export var minBlack: string; - export var faintBlack: string; - export var fullWhite: string; - export var darkWhite: string; - export var lightWhite: string; -} \ No newline at end of file + black: string; + white: string; + + transparent: string; + fullBlack: string; + darkBlack: string; + lightBlack: string; + minBlack: string; + faintBlack: string; + fullWhite: string; + darkWhite: string; + lightWhite: string; + } + export var Colors: Colors; +} From d3ba5a24d7aea88ff5818ee08f7e4925230f2c1e Mon Sep 17 00:00:00 2001 From: David Pfeffer Date: Sun, 20 Sep 2015 20:20:31 -0400 Subject: [PATCH 038/146] Fixed constructor implicit return type issue --- rx-angular/rx.angular.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rx-angular/rx.angular.d.ts b/rx-angular/rx.angular.d.ts index 413abf30b..9e76a95b6 100644 --- a/rx-angular/rx.angular.d.ts +++ b/rx-angular/rx.angular.d.ts @@ -14,7 +14,7 @@ declare module Rx { } export interface ScopeScheduler extends IScheduler { - constructor(scope: ng.IScope); + constructor(scope: ng.IScope) : ScopeScheduler; } export interface ScopeSchedulerStatic extends SchedulerStatic { From b37e3a26f02cda49f9a06f1b47efbeb8c064b865 Mon Sep 17 00:00:00 2001 From: MugeSo Date: Mon, 21 Sep 2015 10:49:23 +0900 Subject: [PATCH 039/146] swaggerize-express: add the reference to d.ts for test --- swaggerize-express/swaggerize-express-tests.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/swaggerize-express/swaggerize-express-tests.ts b/swaggerize-express/swaggerize-express-tests.ts index 100856618..03a0807ef 100644 --- a/swaggerize-express/swaggerize-express-tests.ts +++ b/swaggerize-express/swaggerize-express-tests.ts @@ -1,3 +1,4 @@ +/// import http = require('http'); import express = require('express'); import swaggerize = require('swaggerize-express'); From d9e56a56392e5cde59b516e214e3a4a08dab7fac Mon Sep 17 00:00:00 2001 From: progre Date: Mon, 21 Sep 2015 12:17:18 +0900 Subject: [PATCH 040/146] Remove unused reference --- node-notifier/node-notifier.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/node-notifier/node-notifier.d.ts b/node-notifier/node-notifier.d.ts index d003001a3..9e612453e 100644 --- a/node-notifier/node-notifier.d.ts +++ b/node-notifier/node-notifier.d.ts @@ -3,7 +3,6 @@ // Definitions by: Qubo // Definitions: https://github.com/borisyankov/DefinitelyTyped -/// /// declare module "node-notifier" { From 8302f8f839f4aaea8548f795760e56013e525b21 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 21 Sep 2015 08:56:07 +0500 Subject: [PATCH 041/146] Remove IAnimateService in angular.d.ts --- angularjs/angular-animate.d.ts | 2 +- angularjs/angular.d.ts | 12 ------------ 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/angularjs/angular-animate.d.ts b/angularjs/angular-animate.d.ts index 35fe10ca9..babc752b2 100644 --- a/angularjs/angular-animate.d.ts +++ b/angularjs/angular-animate.d.ts @@ -26,7 +26,7 @@ declare module angular.animate { * AnimateService * see http://docs.angularjs.org/api/ngAnimate/service/$animate */ - interface IAnimateService extends angular.IAnimateService { + interface IAnimateService { /** * Globally enables / disables animations. * diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index a220ddde4..118ebae20 100644 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -1713,18 +1713,6 @@ declare module angular { inheritedData(key?: string): any; } - /////////////////////////////////////////////////////////////////////// - // AnimateService - // see http://docs.angularjs.org/api/ng.$animate - /////////////////////////////////////////////////////////////////////// - interface IAnimateService { - addClass(element: JQuery, className: string, options?: animate.IAnimationOptions): IPromise; - enter(element: JQuery, parent: JQuery, after: JQuery, done?: Function): void; - leave(element: JQuery, done?: Function): void; - move(element: JQuery, parent: JQuery, after: JQuery, done?: Function): void; - removeClass(element: JQuery, className: string, options?: animate.IAnimationOptions): void; - } - /////////////////////////////////////////////////////////////////////////// // AUTO module (angular.js) /////////////////////////////////////////////////////////////////////////// From f8c20ee00f60c4fd3f07da9ccb416ba9b7f0842e Mon Sep 17 00:00:00 2001 From: tkqubo Date: Mon, 21 Sep 2015 14:36:42 +0900 Subject: [PATCH 042/146] Add redux-action-utils --- .../redux-action-utils-tests.ts | 62 +++++++++++++++++++ redux-action-utils/redux-action-utils.d.ts | 37 +++++++++++ 2 files changed, 99 insertions(+) create mode 100644 redux-action-utils/redux-action-utils-tests.ts create mode 100644 redux-action-utils/redux-action-utils.d.ts diff --git a/redux-action-utils/redux-action-utils-tests.ts b/redux-action-utils/redux-action-utils-tests.ts new file mode 100644 index 000000000..d3994a153 --- /dev/null +++ b/redux-action-utils/redux-action-utils-tests.ts @@ -0,0 +1,62 @@ +/// +/// + +import { actionCreator, optionsActionCreator } from 'redux-action-utils'; +import { Action, ActionCreator } from 'redux-action-utils'; + +let types = { + ADD_LESSON: 'ADD_LESSON', + IMPORT_LESSONS: 'IMPORT_LESSONS', + UPDATE_LESSON: 'UPDATE_LESSON' +}; +var type: string; + +export default { + addLesson: actionCreator(types.ADD_LESSON), + importLessons: actionCreator(types.IMPORT_LESSONS, 'lessons'), + updateLesson: optionsActionCreator(types.UPDATE_LESSON, 'id', 'update') +}; + +var ac = actionCreator(types.ADD_LESSON); +var action: Action = ac(); +type = action.type; + + +class ImportLesson { + lessons: string[]; +} + +const importLessonAction = actionCreator(types.IMPORT_LESSONS, 'lessons'); +var importLesson = importLessonAction(['lesson 1', 'lesson 2']); +// → {type: 'IMPORT_LESSONS', lessons: ['lesson 1', 'lesson 2']} + +var lessons: string[] = importLesson.lessons; +type = importLesson.type; + + +class UpdateLesson { + id: number; + update: { + text: string + } +} + +const updateLessonAction = optionsActionCreator(types.UPDATE_LESSON, 'id', 'update'); +let updateLesson = updateLessonAction({ + id: 1, + update: { + text: '## Lesson 1' + } +}); +/* → + { + type: 'UPDATE_LESSON', + id: 1, + update: { + text: '## Lesson 1' + } + } + */ + +let id: number = updateLesson.id; +type = updateLesson.type; diff --git a/redux-action-utils/redux-action-utils.d.ts b/redux-action-utils/redux-action-utils.d.ts new file mode 100644 index 000000000..8e565902d --- /dev/null +++ b/redux-action-utils/redux-action-utils.d.ts @@ -0,0 +1,37 @@ +// Type definitions for redux-action-utils 2.0.0 +// Project: https://github.com/insin/redux-action-utils +// Definitions by: Qubo +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "redux-action-utils" { + export interface Action { + type: string; + } + + export interface ActionCreator { + (...data: any[]): Action & T; + } + + export interface OptionsActionCreator { + (data: T): Action & T; + } + + /** + * Creates an action creator which will create an action object with the given type. + */ + export function actionCreator(type: string, ...props: string[]): ActionCreator; + /** + * Creates an action creator which will create an action object with the given type. + */ + export function actionCreator(type: string, props: string[]): ActionCreator; + + /** + * Creates an action creator which takes a single object argument and adds its properties to the action object. + */ + export function optionsActionCreator(type: string, ...props: string[]): OptionsActionCreator; + /** + * Creates an action creator which takes a single object argument and adds its properties to the action object. + */ + export function optionsActionCreator(type: string, props: string[]): OptionsActionCreator; +} + From bb370b898e6a1528c5959932b4e238a574f22869 Mon Sep 17 00:00:00 2001 From: Geir Sagberg Date: Mon, 21 Sep 2015 11:40:10 +0200 Subject: [PATCH 043/146] Add declaration for 'js-cookie' Supports e.g. `import Cookies = require('js-cookie')` for CommonJS. --- js-cookie/js-cookie.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/js-cookie/js-cookie.d.ts b/js-cookie/js-cookie.d.ts index fc3e95c02..7fc1a5125 100644 --- a/js-cookie/js-cookie.d.ts +++ b/js-cookie/js-cookie.d.ts @@ -90,3 +90,7 @@ declare module Cookies { } declare var Cookies: Cookies.CookiesStatic; + +declare module 'js-cookie' { + export = Cookies; +} From fcd91d68c8a4a72b5732c7ec5dc04010f888f89f Mon Sep 17 00:00:00 2001 From: benliddicott Date: Mon, 21 Sep 2015 11:37:37 +0100 Subject: [PATCH 044/146] Adding Ejs and static-eval --- ejs/ejs.d.ts | 4 ++-- static-eval/static-eval-tests.ts | 11 +++++++---- static-eval/static-eval.d.ts | 8 +++++++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/ejs/ejs.d.ts b/ejs/ejs.d.ts index 95ca168c3..56e755a46 100644 --- a/ejs/ejs.d.ts +++ b/ejs/ejs.d.ts @@ -5,7 +5,7 @@ declare module "ejs" { - module Ejs { + namespace Ejs { type Data = { [name: string]: any }; type Dependencies = string[]; var cache: Cache; @@ -60,7 +60,7 @@ declare module "ejs" { function shallowCopy(to: T1, fro: any): T1; interface Cache { _data: { [name: string]: any }; - set(key: string, val: any); + set(key: string, val: any): any; get(key: string): any; } var cache: Cache; diff --git a/static-eval/static-eval-tests.ts b/static-eval/static-eval-tests.ts index 5657a8c62..fe42c3d4d 100644 --- a/static-eval/static-eval-tests.ts +++ b/static-eval/static-eval-tests.ts @@ -1,14 +1,17 @@ -/// /// +/// import evaluate = require('static-eval'); -import parse = require('../esprima/esprima').parse; +import esprima = require('esprima'); +var parse = esprima.parse; + var src = '[1,2,3+4*10+n,foo(3+5),obj[""+"x"].y]'; -var ast = parse(src).body[0].expression; + +var ast = ((parse(src).body[0])).expression; console.log(evaluate(ast, { n: 6, - foo: function (x) { return x * 100 }, + foo: function (x: number) { return x * 100 }, obj: { x: { y: 555 } } })); \ No newline at end of file diff --git a/static-eval/static-eval.d.ts b/static-eval/static-eval.d.ts index bb3461ad6..e44294c27 100644 --- a/static-eval/static-eval.d.ts +++ b/static-eval/static-eval.d.ts @@ -3,8 +3,14 @@ // Definitions by: Ben Liddicott // Definitions: https://github.com/borisyankov/DefinitelyTyped +/// declare module 'static-eval' { - function evaluate(ast, vars: { [name: string]: any }); + /** + * Evaluates the given ESTree.Expression, with the given named variables in place. + * @param ast [ESTree.Expression] An esprima expression derived from parse.body[].expression + * @param vars Named variables, objects or functions which may be referenced in the expression. + */ + function evaluate(ast : ESTree.Expression, vars: { [name: string]: any }): any; export =evaluate; } From 50972e00188534dc26a03540c7da9b001d4574da Mon Sep 17 00:00:00 2001 From: Stefan Schacherl Date: Mon, 21 Sep 2015 15:52:43 +0200 Subject: [PATCH 045/146] Added definitions for rest-io --- rest-io/rest-io-tests.ts | 18 +++++ rest-io/rest-io.d.ts | 148 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 166 insertions(+) create mode 100644 rest-io/rest-io-tests.ts create mode 100644 rest-io/rest-io.d.ts diff --git a/rest-io/rest-io-tests.ts b/rest-io/rest-io-tests.ts new file mode 100644 index 000000000..5f558b77a --- /dev/null +++ b/rest-io/rest-io-tests.ts @@ -0,0 +1,18 @@ +/// + +import express = require('express'); +import restIO = require('rest-io'); +import mongoose = require('mongoose'); + +var app = express(); + +// register the express app with rest.io +restIO.restIO(app, { + resources: __dirname + '/resources' +}); + +mongoose.connect('mongodb://localhost:27017/test'); +app.listen(3000, function () { + console.log('Server has started under port: 3000'); +}); +module.exports = app; \ No newline at end of file diff --git a/rest-io/rest-io.d.ts b/rest-io/rest-io.d.ts new file mode 100644 index 000000000..a2dac465b --- /dev/null +++ b/rest-io/rest-io.d.ts @@ -0,0 +1,148 @@ +// Type definitions for rest-io 4.0 +// Project: https://github.com/EnoF/rest-io +// Definitions by: Andy Tang , Stefan Schacherl +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + + +declare module 'rest-io' { +import {Router, Application, Response, Request} from 'express'; + +import {Mongoose, Schema, Model, Document, Types, Promise} from 'mongoose'; + + function restIO(app: Application, config?: IRestIOConfig): RestIO; + + export interface RestIO { + resource: ResourceModule + } + + export interface IRestIOConfig { + resources: string; + db?: Mongoose; + } + + export interface ResourceModule { + Resource: Resource; + AuthorizedResource: AuthorizedResource; + authorizedResource: AuthorizedResourceModule; + UserResource: UserResource; + SubResource: SubResource; + } + + export class Resource { + baseUrl: string; + url: string; + parameterizedUrl: string; + model: Model; + resDef: IResource; + parentResource: Resource; + router: Router; + app: Application; + db: Mongoose; + paramId: string; + parentRef: string; + populate: string; + + constructor(resDef: IResource); + + createModel(resDef: IResource): Model; + + toClassName(name: string): string; + + setupRoutes(): void; + + getAll(req: Request, res: Response): void; + + buildParentSearch(req: Request): any; + + getById(req: Request, res: Response): void; + + create(req: Request, res: Response): void; + + update(req: Request, res: Response): void; + + del(req: Request, res: Response): void; + + errorHandler(err: Error, res: Response): void; + } + + export interface IResource { + name: string; + model: any; + parentRef?: string; + populate?: string; + plural?: string; + parentResource?: Resource; + } + + export interface AuthorizedResourceModule { + AuthorizedResource: AuthorizedResource + ROLES: Roles + } + + export interface Roles { + USER: string; + SUPER_USER: string; + MODERATOR: string; + ADMIN: string; + } + + export class AuthorizedResource extends Resource { + methodAccess: IMethodAccess; + + maxDays: number; + + permissions: IMethodAccess; + + isTokenExpired(createdAt: Date): boolean; + + getRoles(id: string): Promise; + + hasAuthorizedRole(roles: Array, authorizedRoles: Array): boolean; + + hasAccessRightsDefined(req: Request, authorizedRoles: Array): boolean; + + isAuthorized(req: Request, authorizedRoles: Array): boolean; + + sendUnauthorized(error: Error, res: Response): void; + } + + export interface IMethodAccess { + getAll: Array; + getById: Array; + create: Array; + update: Array; + del: Array; + } + + export class UserResource extends AuthorizedResource { + ensureBaseUserModel(model: any): void; + + createRoleModel(): void; + + isSelf(req: Request): boolean; + + login(req: Request, res: Response): void; + } + + export class SubResource extends Resource { + constructor(resDef: ISubResource); + + createProjectionQuery(req: Request): any; + + createPullQuery(req: Request): any; + + createFindQuery(req: Request): any; + + createSubUpdateQuery(req: Request): any; + } + + export interface ISubResource { + name: string; + plural?: string; + parentResource: Resource; + populate?: string; + } +} \ No newline at end of file From 9722f15c2a19adefc196ac19abf1b3d691003375 Mon Sep 17 00:00:00 2001 From: Dan Lewi Harkestad Date: Mon, 21 Sep 2015 16:03:37 +0200 Subject: [PATCH 046/146] Added missing properties in HighchartsChartOptions and HighchartsLegendOptions. See http://api.highcharts.com/highcharts#chart and http://api.highcharts.com/highcharts#legend. --- highcharts/highcharts.d.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/highcharts/highcharts.d.ts b/highcharts/highcharts.d.ts index f654b9749..aec8cacc6 100644 --- a/highcharts/highcharts.d.ts +++ b/highcharts/highcharts.d.ts @@ -217,8 +217,11 @@ interface HighchartsChartOptions { marginLeft?: number; marginRight?: number; marginTop?: number; - plotBackGroundColor?: string | HighchartsGradient; - plotBackGroundImage?: string; + panKey?: string; + panning?: number; + pinchType?: string; + plotBackgroundColor?: string | HighchartsGradient; + plotBackgroundImage?: string; plotBorderColor?: string; plotBorderWidth?: number; plotShadow?: boolean | HighchartsShadow; @@ -229,6 +232,7 @@ interface HighchartsChartOptions { selectionMarkerFill?: string; shadow?: boolean | HighchartsShadow; showAxes?: boolean; + spacing?: number[]; spacingBottom?: number; spacingLeft?: number; spacingRight?: number; @@ -352,6 +356,11 @@ interface HighchartsLegendNavigationOptions { style?: HighchartsCSSObject; } +interface HighchartsLegendTitleOptions { + style?: HighchartsCSSObject; + text?: string; +} + interface HighchartsLegendOptions { align?: string; backgroundColor?: string | HighchartsGradient; @@ -360,6 +369,7 @@ interface HighchartsLegendOptions { borderWidth?: number; enabled?: boolean; floating?: boolean; + itemDistance?: number; itemHiddenStyle?: HighchartsCSSObject; itemHoverStyle?: HighchartsCSSObject; itemMarginBottom?: number; @@ -368,19 +378,21 @@ interface HighchartsLegendOptions { itemWidth?: number; labelFormatter?: () => string; layout?: string; - lineHeight?: string; + lineHeight?: number; margin?: number; maxHeight?: number; navigation?: HighchartsLegendNavigationOptions; padding?: number; reversed?: boolean; rtl?: boolean; - verticalAlign?: string; shadow?: boolean | HighchartsShadow; style?: HighchartsCSSObject; + symbolHeight?: number; symbolPadding?: number; symbolWidth?: number; + title?: HighchartsLegendTitleOptions; useHTML?: boolean; + verticalAlign?: string; width?: number; x?: number; y?: number; From 8948c081972dc1be560f1f4b71225f9a75358dbe Mon Sep 17 00:00:00 2001 From: Arthur Langereis Date: Mon, 21 Sep 2015 16:35:45 +0200 Subject: [PATCH 047/146] WebGL 1.0 extensions (beyond TS 1.6.2 stdlib) --- webgl-ext/webgl-ext-tests.ts | 102 +++++++++++++++++ webgl-ext/webgl-ext.d.ts | 214 +++++++++++++++++++++++++++++++++++ 2 files changed, 316 insertions(+) create mode 100644 webgl-ext/webgl-ext-tests.ts create mode 100644 webgl-ext/webgl-ext.d.ts diff --git a/webgl-ext/webgl-ext-tests.ts b/webgl-ext/webgl-ext-tests.ts new file mode 100644 index 000000000..9ddcd22f9 --- /dev/null +++ b/webgl-ext/webgl-ext-tests.ts @@ -0,0 +1,102 @@ +/// + +var canvas = document.createElement("canvas"); +var gl = canvas.getContext("webgl"); +var ext: any; +var t: any; + +if (ext = gl.getExtension("ANGLE_instanced_arrays")) { + t = ext.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE; +} + +if (ext = gl.getExtension("EXT_blend_minmax")) { + t = ext.MIN_EXT; +} + +if (ext = gl.getExtension("EXT_color_buffer_half_float")) { + t = ext.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT; +} + +if (ext = gl.getExtension("EXT_frag_depth")) { + // no fields +} + +if (ext = gl.getExtension("EXT_sRGB")) { + t = ext.SRGB8_ALPHA8_EXT; +} + +if (ext = gl.getExtension("EXT_shader_texture_lod")) { + // no fields +} + +if (ext = gl.getExtension("EXT_texture_filter_anisotropic")) { + t = ext.MAX_TEXTURE_MAX_ANISOTROPY_EXT; +} + +if (ext = gl.getExtension("OES_element_index_uint")) { + // no fields +} + +if (ext = gl.getExtension("OES_standard_derivatives")) { + t = ext.FRAGMENT_SHADER_DERIVATIVE_HINT_OES; +} + +if (ext = gl.getExtension("OES_texture_float")) { + // no fields +} + +if (ext = gl.getExtension("OES_texture_float_linear")) { + // no fields +} + +if (ext = gl.getExtension("OES_texture_half_float")) { + t = ext.HALF_FLOAT_OES; +} + +if (ext = gl.getExtension("OES_texture_half_float_linear")) { + // no fields +} + +if (ext = gl.getExtension("OES_vertex_array_object")) { + t = ext.createVertexArrayOES; // just get fn ref, don't call +} + +if (ext = gl.getExtension("WEBGL_color_buffer_float")) { + t = ext.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT; +} + +if (ext = gl.getExtension("WEBGL_compressed_texture_atc")) { + t = ext.COMPRESSED_RGB_ATC_WEBGL; +} + +if (ext = gl.getExtension("WEBGL_compressed_texture_etc1")) { + t = ext.COMPRESSED_RGB_ETC1_WEBGL; +} + +if (ext = gl.getExtension("WEBGL_compressed_texture_pvrtc")) { + t = ext.COMPRESSED_RGB_PVRTC_4BPPV1_IMG; +} + +if (ext = gl.getExtension("WEBGL_compressed_texture_s3tc")) { + t = ext.COMPRESSED_RGBA_S3TC_DXT5_EXT; +} + +if (ext = gl.getExtension("WEBGL_debug_renderer_info")) { + t = ext.UNMASKED_VENDOR_WEBGL; +} + +if (ext = gl.getExtension("WEBGL_debug_shaders")) { + t = ext.getTranslatedShaderSource; // just get fn ref, don't call +} + +if (ext = gl.getExtension("WEBGL_depth_texture")) { + t = ext.UNSIGNED_INT_24_8_WEBGL; +} + +if (ext = gl.getExtension("WEBGL_draw_buffers")) { + t = ext.MAX_COLOR_ATTACHMENTS_WEBGL; +} + +if (ext = gl.getExtension("WEBGL_lose_context")) { + t = ext.loseContext; // just get fn ref, don't call +} diff --git a/webgl-ext/webgl-ext.d.ts b/webgl-ext/webgl-ext.d.ts new file mode 100644 index 000000000..c6a8cb34a --- /dev/null +++ b/webgl-ext/webgl-ext.d.ts @@ -0,0 +1,214 @@ +// Type definitions for WebGL Extensions +// Project: http://webgl.org/ +// Definitions by: Arthur Langereis +// Definitions: https://github.com/borisyankov/DefinitelyTyped/webgl-ext + +// These definitions go beyond those already defined in TS 1.6.2 stdlib +// All non-draft WebGL 1.0 extensions and prefixed extension names are +// covered. + +interface HTMLCanvasElement { + getContext(contextId: "webgl"): WebGLRenderingContext; +} + +interface WebGLRenderingContext { + getExtension(name: "ANGLE_instanced_arrays"): ANGLEInstancedArrays; + + getExtension(name: "EXT_blend_minmax"): EXTBlendMinMax; + getExtension(name: "EXT_color_buffer_half_float"): EXTColorBufferHalfFloat; + getExtension(name: "EXT_frag_depth"): EXTFragDepth; + getExtension(name: "EXT_sRGB"): EXTsRGB; + getExtension(name: "EXT_shader_texture_lod"): EXTShaderTextureLOD; + getExtension(name: "EXT_texture_filter_anisotropic"): EXTTextureFilterAnisotropic; + + getExtension(name: "OES_element_index_uint"): OESElementIndexUint; + getExtension(name: "OES_standard_derivatives"): OESStandardDerivatives; + getExtension(name: "OES_texture_float"): OESTextureFloat; + getExtension(name: "OES_texture_float_linear"): OESTextureFloatLinear; + getExtension(name: "OES_texture_half_float"): OESTextureHalfFloat; + getExtension(name: "OES_texture_half_float_linear"): OESTextureHalfFloatLinear; + getExtension(name: "OES_vertex_array_object"): OESVertexArrayObject; + + getExtension(name: "WEBGL_color_buffer_float"): WebGLColorBufferFloat; + getExtension(name: "WEBGL_compressed_texture_atc"): WebGLCompressedTextureATC; + getExtension(name: "WEBGL_compressed_texture_etc1"): WebGLCompressedTextureETC1; + getExtension(name: "WEBGL_compressed_texture_pvrtc"): WebGLCompressedTexturePVRTC; + getExtension(name: "WEBGL_compressed_texture_s3tc"): WebGLCompressedTextureS3TC; + getExtension(name: "WEBGL_debug_renderer_info"): WebGLDebugRendererInfo; + getExtension(name: "WEBGL_debug_shaders"): WebGLDebugShaders; + getExtension(name: "WEBGL_depth_texture"): WebGLDepthTexture; + getExtension(name: "WEBGL_draw_buffers"): WebGLDrawBuffers; + getExtension(name: "WEBGL_lose_context"): WebGLLoseContext; + + // Prefixed versions appearing in the wild as per September 2015 + + getExtension(name: "WEBKIT_EXT_texture_filter_anisotropic"): EXTTextureFilterAnisotropic; + getExtension(name: "WEBKIT_WEBGL_compressed_texture_atc"): WebGLCompressedTextureATC; + getExtension(name: "WEBKIT_WEBGL_compressed_texture_pvrtc"): WebGLCompressedTexturePVRTC; + getExtension(name: "WEBKIT_WEBGL_compressed_texture_s3tc"): WebGLCompressedTextureS3TC; + getExtension(name: "WEBKIT_WEBGL_depth_texture"): WebGLDepthTexture; + getExtension(name: "WEBKIT_WEBGL_lose_context"): WebGLLoseContext; + + getExtension(name: "MOZ_WEBGL_compressed_texture_s3tc"): WebGLCompressedTextureS3TC; + getExtension(name: "MOZ_WEBGL_depth_texture"): WebGLDepthTexture; + getExtension(name: "MOZ_WEBGL_lose_context"): WebGLLoseContext; +} + +interface ANGLEInstancedArrays { + VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE: number; + + drawArraysInstancedANGLE(mode: number, first: number, count: number, primcount: number): void; + drawElementsInstancedANGLE(mode: number, count: number, type: number, offset: number, primcount: number): void; + vertexAttribDivisorANGLE(index: number, divisor: number): void; +} + +interface EXTBlendMinMax { + MIN_EXT: number; + MAX_EXT: number; +} + +interface EXTColorBufferHalfFloat { + RGBA16F_EXT: number; + RGB16F_EXT: number; + FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT: number; + UNSIGNED_NORMALIZED_EXT: number; +} + +interface EXTFragDepth { +} + +interface EXTsRGB { + SRGB_EXT: number; + SRGB_ALPHA_EXT: number; + SRGB8_ALPHA8_EXT: number; + FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT: number; +} + +interface EXTShaderTextureLOD { +} + +interface EXTTextureFilterAnisotropic { + TEXTURE_MAX_ANISOTROPY_EXT: number; + MAX_TEXTURE_MAX_ANISOTROPY_EXT: number; +} + +interface OESElementIndexUint { +} + +interface OESStandardDerivatives { + FRAGMENT_SHADER_DERIVATIVE_HINT_OES: number; +} + +interface OESTextureFloat { +} + +interface OESTextureFloatLinear { +} + +interface OESTextureHalfFloat { + HALF_FLOAT_OES: number; +} + +interface OESTextureHalfFloatLinear { +} + +interface WebGLVertexArrayObjectOES extends WebGLObject { +} + +interface OESVertexArrayObject { + VERTEX_ARRAY_BINDING_OES: number; + + createVertexArrayOES(): WebGLVertexArrayObjectOES; + deleteVertexArrayOES(arrayObject: WebGLVertexArrayObjectOES): void; + isVertexArrayOES(arrayObject: WebGLVertexArrayObjectOES): boolean; + bindVertexArrayOES(arrayObject: WebGLVertexArrayObjectOES): void; +} + +interface WebGLColorBufferFloat { + RGBA32F_EXT: number; + FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT: number; + UNSIGNED_NORMALIZED_EXT: number; +} + +interface WebGLCompressedTextureATC { + COMPRESSED_RGB_ATC_WEBGL: number; + COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: number; + COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: number; +} + +interface WebGLCompressedTextureETC1 { + COMPRESSED_RGB_ETC1_WEBGL: number; +} + +interface WebGLCompressedTexturePVRTC { + COMPRESSED_RGB_PVRTC_4BPPV1_IMG: number; + COMPRESSED_RGB_PVRTC_2BPPV1_IMG: number; + COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: number; + COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: number; +} + +interface WebGLCompressedTextureS3TC { + COMPRESSED_RGB_S3TC_DXT1_EXT: number; + COMPRESSED_RGBA_S3TC_DXT1_EXT: number; + COMPRESSED_RGBA_S3TC_DXT3_EXT: number; + COMPRESSED_RGBA_S3TC_DXT5_EXT: number; +} + +interface WebGLDebugRendererInfo { + UNMASKED_VENDOR_WEBGL: number; + UNMASKED_RENDERER_WEBGL: number; +} + +interface WebGLDebugShaders { + getTranslatedShaderSource(shader: WebGLShader): string; +} + +interface WebGLDepthTexture { + UNSIGNED_INT_24_8_WEBGL: number; +} + +interface WebGLDrawBuffers { + COLOR_ATTACHMENT0_WEBGL: number; + COLOR_ATTACHMENT1_WEBGL: number; + COLOR_ATTACHMENT2_WEBGL: number; + COLOR_ATTACHMENT3_WEBGL: number; + COLOR_ATTACHMENT4_WEBGL: number; + COLOR_ATTACHMENT5_WEBGL: number; + COLOR_ATTACHMENT6_WEBGL: number; + COLOR_ATTACHMENT7_WEBGL: number; + COLOR_ATTACHMENT8_WEBGL: number; + COLOR_ATTACHMENT9_WEBGL: number; + COLOR_ATTACHMENT10_WEBGL: number; + COLOR_ATTACHMENT11_WEBGL: number; + COLOR_ATTACHMENT12_WEBGL: number; + COLOR_ATTACHMENT13_WEBGL: number; + COLOR_ATTACHMENT14_WEBGL: number; + COLOR_ATTACHMENT15_WEBGL: number; + + DRAW_BUFFER0_WEBGL: number; + DRAW_BUFFER1_WEBGL: number; + DRAW_BUFFER2_WEBGL: number; + DRAW_BUFFER3_WEBGL: number; + DRAW_BUFFER4_WEBGL: number; + DRAW_BUFFER5_WEBGL: number; + DRAW_BUFFER6_WEBGL: number; + DRAW_BUFFER7_WEBGL: number; + DRAW_BUFFER8_WEBGL: number; + DRAW_BUFFER9_WEBGL: number; + DRAW_BUFFER10_WEBGL: number; + DRAW_BUFFER11_WEBGL: number; + DRAW_BUFFER12_WEBGL: number; + DRAW_BUFFER13_WEBGL: number; + DRAW_BUFFER14_WEBGL: number; + DRAW_BUFFER15_WEBGL: number; + + MAX_COLOR_ATTACHMENTS_WEBGL: number; + MAX_DRAW_BUFFERS_WEBGL: number; + + drawBuffersWEBGL(buffers: number[]): void; +} + +interface WebGLLoseContext { + loseContext(): void; + restoreContext(): void; +} From 02e0f2fdc7f48c16650196bde8b7c20f737d72ee Mon Sep 17 00:00:00 2001 From: robert-voica Date: Mon, 21 Sep 2015 17:40:37 +0300 Subject: [PATCH 048/146] Resolved problems with interfaces' name and mentioned the original author too --- bootstrap-notify/bootstrap-notify.d.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/bootstrap-notify/bootstrap-notify.d.ts b/bootstrap-notify/bootstrap-notify.d.ts index dc08354d9..9962150e5 100644 --- a/bootstrap-notify/bootstrap-notify.d.ts +++ b/bootstrap-notify/bootstrap-notify.d.ts @@ -1,6 +1,8 @@ // Type definitions for bootstrap-notify v3.1.3 // Project: http://bootstrap-notify.remabledesigns.com/ -// Definitions by: Robert McIntosh , Robert Voica +// Definitions by: Blake Niemyjski , +// Robert McIntosh , +// Robert Voica // Definitions: https://github.com/borisyankov/DefinitelyTyped /// @@ -9,14 +11,14 @@ interface JQueryStatic { /* tslint:enable: interface-name */ - notify(message: string): INotifyReturn; - notify(opts: INotifyOptions, settings?: INotifySettings): INotifyReturn; - notifyDefaults(settings: INotifySettings): void; + notify(message: string): NotifyReturn; + notify(opts: NotifyOptions, settings?: NotifySettings): NotifyReturn; + notifyDefaults(settings: NotifySettings): void; notifyClose(): void; notifyClose(command: string): void; } -interface INotifyOptions { +interface NotifyOptions { message: string; title?: string; icon?: string; @@ -24,7 +26,7 @@ interface INotifyOptions { target?: string; } -interface INotifySettings { +interface NotifySettings { element?: string; position?: string; type?: string; @@ -55,7 +57,7 @@ interface INotifySettings { template?: string; } -interface INotifyReturn { +interface NotifyReturn { $ele: JQueryStatic; close: () => void; update: (command: string, update: any) => void; From 2e34170fa74ba6439af996f8a3096fe9aef61fc6 Mon Sep 17 00:00:00 2001 From: robert-voica Date: Mon, 21 Sep 2015 17:44:00 +0300 Subject: [PATCH 049/146] Removed new lines between names --- bootstrap-notify/bootstrap-notify.d.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bootstrap-notify/bootstrap-notify.d.ts b/bootstrap-notify/bootstrap-notify.d.ts index 9962150e5..39a627d54 100644 --- a/bootstrap-notify/bootstrap-notify.d.ts +++ b/bootstrap-notify/bootstrap-notify.d.ts @@ -1,8 +1,6 @@ // Type definitions for bootstrap-notify v3.1.3 // Project: http://bootstrap-notify.remabledesigns.com/ -// Definitions by: Blake Niemyjski , -// Robert McIntosh , -// Robert Voica +// Definitions by: Blake Niemyjski , Robert McIntosh , Robert Voica // Definitions: https://github.com/borisyankov/DefinitelyTyped /// From 056a2c38f5822903eadf7cc4acf566765681229b Mon Sep 17 00:00:00 2001 From: Tyler Brinkley Date: Mon, 21 Sep 2015 09:46:07 -0500 Subject: [PATCH 050/146] Add JQuery focusin and focusout overload typings See http://api.jquery.com/focusin/ and http://api.jquery.com/focusout/ --- jquery/jquery.d.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index d7688f187..3641af850 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -1998,6 +1998,10 @@ interface JQuery { */ focus(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Trigger the "focusin" event on an element. + */ + focusin(): JQuery; /** * Bind an event handler to the "focusin" JavaScript event * @@ -2012,6 +2016,10 @@ interface JQuery { */ focusin(eventData: Object, handler: (eventObject: JQueryEventObject) => any): JQuery; + /** + * Trigger the "focusout" event on an element. + */ + focusout(): JQuery; /** * Bind an event handler to the "focusout" JavaScript event * From 9443438c83b59d29b768e1035e7a2d7275c36f6a Mon Sep 17 00:00:00 2001 From: robert-voica Date: Mon, 21 Sep 2015 17:47:32 +0300 Subject: [PATCH 051/146] Removed tab --- bootstrap-notify/bootstrap-notify.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap-notify/bootstrap-notify.d.ts b/bootstrap-notify/bootstrap-notify.d.ts index 39a627d54..52e0cb472 100644 --- a/bootstrap-notify/bootstrap-notify.d.ts +++ b/bootstrap-notify/bootstrap-notify.d.ts @@ -1,6 +1,6 @@ // Type definitions for bootstrap-notify v3.1.3 // Project: http://bootstrap-notify.remabledesigns.com/ -// Definitions by: Blake Niemyjski , Robert McIntosh , Robert Voica +// Definitions by: Blake Niemyjski , Robert McIntosh , Robert Voica // Definitions: https://github.com/borisyankov/DefinitelyTyped /// From c5c929c4fb3383db5f4d78bba5e5fce81279b8a8 Mon Sep 17 00:00:00 2001 From: rhysd Date: Tue, 22 Sep 2015 00:38:55 +0900 Subject: [PATCH 052/146] fix isEnabled() method --- auto-launch/auto-launch-tests.ts | 9 ++++++++- auto-launch/auto-launch.d.ts | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/auto-launch/auto-launch-tests.ts b/auto-launch/auto-launch-tests.ts index 735985624..24d6aad14 100644 --- a/auto-launch/auto-launch-tests.ts +++ b/auto-launch/auto-launch-tests.ts @@ -14,4 +14,11 @@ var a2 = new AutoLaunch({ a1.enable(); a2.disable(); -var enabled: boolean = a1.isEnabled(); + +a1.isEnabled(function(enabled: boolean) { + if (enabled) { + return; + } + + a1.enable(function(err){ console.log(err.message); }); +}); diff --git a/auto-launch/auto-launch.d.ts b/auto-launch/auto-launch.d.ts index c208d10fd..0b277c79f 100644 --- a/auto-launch/auto-launch.d.ts +++ b/auto-launch/auto-launch.d.ts @@ -32,7 +32,7 @@ declare class AutoLaunch { /** * Returns if auto start up is enabled */ - isEnabled(callback?: (err: Error) => void): boolean; + isEnabled(callback: (enabled: boolean) => void): void; } declare module "auto-launch" { From 09d00974493060a4eec0ce0442e8e6c45878bae3 Mon Sep 17 00:00:00 2001 From: Shiak1 Date: Mon, 21 Sep 2015 14:11:48 -0400 Subject: [PATCH 053/146] Update AuthOptions interface. Missing bearer token https://github.com/request/request#http-authentication --- request/request.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/request/request.d.ts b/request/request.d.ts index a4507a6e2..a4c10a832 100644 --- a/request/request.d.ts +++ b/request/request.d.ts @@ -141,6 +141,7 @@ declare module 'request' { pass?: string; password?: string; sendImmediately?: boolean; + bearer?: string; } export interface OAuthOptions { From 7e75883306561985274aa815194106ad6361c68e Mon Sep 17 00:00:00 2001 From: Michel Weststrate Date: Tue, 22 Sep 2015 09:15:39 +0200 Subject: [PATCH 054/146] added tests and typings for mobservable and mobservable-react packages --- mobservable-react/mobservable-react-tests.ts | 58 ++++++ .../mobservable-react-tests.ts.tscparams | 1 + mobservable-react/mobservable-react.d.ts | 16 ++ mobservable/mobservable-tests.ts | 57 ++++++ mobservable/mobservable-tests.ts.tscparams | 1 + mobservable/mobservable.d.ts | 189 ++++++++++++++++++ 6 files changed, 322 insertions(+) create mode 100644 mobservable-react/mobservable-react-tests.ts create mode 100644 mobservable-react/mobservable-react-tests.ts.tscparams create mode 100644 mobservable-react/mobservable-react.d.ts create mode 100644 mobservable/mobservable-tests.ts create mode 100644 mobservable/mobservable-tests.ts.tscparams create mode 100644 mobservable/mobservable.d.ts diff --git a/mobservable-react/mobservable-react-tests.ts b/mobservable-react/mobservable-react-tests.ts new file mode 100644 index 000000000..7bda00cf4 --- /dev/null +++ b/mobservable-react/mobservable-react-tests.ts @@ -0,0 +1,58 @@ +/// +/// + +import {reactiveComponent} from 'mobservable-react'; + +{ + let c1 = reactiveComponent(React.createClass({ + getDefaultProps() { + return { + test: "hi" + }; + }, + + render: function() { + return React.createElement("div"); + } + })); + + let c1Factory = React.createFactory(c1); + React.render(c1Factory({ + test: "hello" + }), null); +} + +@reactiveComponent +class TestComponent extends React.Component<{ test: string },{}> { + render() { + return React.createElement("div"); + } +} + +{ + let c2Factory = React.createFactory(TestComponent); + React.render(c2Factory({ + test: "hello" + }) , null); +} + +{ + var c3 = reactiveComponent((props: { test: string }) => React.createElement("div")); + var c3Factory = React.createFactory(c3); //without JSX + React.render(c3Factory({ + test: "hello" + }), null); +} + + +class TestComponent2 extends React.Component<{ test: string },{}> { + render() { + return React.createElement("div"); + } +} +{ + let c4Factory = React.createFactory(reactiveComponent(TestComponent2)); + React.render(c4Factory({ + test: "hello" + }) , null); +} \ No newline at end of file diff --git a/mobservable-react/mobservable-react-tests.ts.tscparams b/mobservable-react/mobservable-react-tests.ts.tscparams new file mode 100644 index 000000000..3f1358357 --- /dev/null +++ b/mobservable-react/mobservable-react-tests.ts.tscparams @@ -0,0 +1 @@ +--noImplicitAny --module commonjs --target es5 --experimentalDecorators \ No newline at end of file diff --git a/mobservable-react/mobservable-react.d.ts b/mobservable-react/mobservable-react.d.ts new file mode 100644 index 000000000..34ecd78f8 --- /dev/null +++ b/mobservable-react/mobservable-react.d.ts @@ -0,0 +1,16 @@ +// Type definitions for mobservable v0.1.8 +// Project: https://github.com/mweststrate/mobservable-react +// Definitions by: Michel Weststrate +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "mobservable-react" { + /** + * Turns a React component or stateless render function into a reactive component. + */ + export function reactiveComponent

(clazz: React.ClassicComponentClass

): React.ClassicComponentClass

; + export function reactiveComponent

(clazz: React.ComponentClass

): React.ComponentClass

; + export function reactiveComponent

(clazz: React.ComponentClass

): void; // for decorator + export function reactiveComponent

(renderFunction: (props: P) => React.ReactElement): React.ClassicComponentClass

; +} \ No newline at end of file diff --git a/mobservable/mobservable-tests.ts b/mobservable/mobservable-tests.ts new file mode 100644 index 000000000..2966128fe --- /dev/null +++ b/mobservable/mobservable-tests.ts @@ -0,0 +1,57 @@ +/// +import mobservable = require('mobservable'); +import {observable} from "mobservable"; + +var v = mobservable(3); +v.observe(() => {}); + +var a = mobservable([1,2,3]); + +class Order { + @observable price:number = 3; + @observable amount:number = 2; + @observable orders:string[] = []; + + @observable get total() { + return this.amount * this.price * (1 + this.orders.length); + } +} + +export function testObservable() { + var a = mobservable(3); + var b = mobservable(() => a() * 2); +} + +export function testAnnotations() { + var order1totals:number[] = []; + var order1 = new Order(); + var order2 = new Order(); + + var disposer = mobservable.observe(() => { + order1totals.push(order1.total) + }); + + order2.price = 4; + order1.amount = 1; + + order2.orders.push('bla'); + + order1.orders.splice(0,0,'boe', 'hoi'); + + disposer(); + order1.orders.pop(); +}; + +export function testTyping() { + var ar:Mobservable.IObservableArray = mobservable.makeReactive([1,2]); + ar.observe((d:Mobservable.IArrayChange|Mobservable.IArraySplice) => { + console.log(d.type); + }); + + var ar2:Mobservable.IObservableArray = mobservable([1,2]); + ar2.observe((d:Mobservable.IArrayChange|Mobservable.IArraySplice) => { + console.log(d.type); + }); + + var x:Mobservable.IObservableValue = mobservable(3); +} \ No newline at end of file diff --git a/mobservable/mobservable-tests.ts.tscparams b/mobservable/mobservable-tests.ts.tscparams new file mode 100644 index 000000000..77f208cc0 --- /dev/null +++ b/mobservable/mobservable-tests.ts.tscparams @@ -0,0 +1 @@ +--noImplicitAny --module commonjs --target es5 --experimentalDecorators diff --git a/mobservable/mobservable.d.ts b/mobservable/mobservable.d.ts new file mode 100644 index 000000000..d98c34454 --- /dev/null +++ b/mobservable/mobservable.d.ts @@ -0,0 +1,189 @@ +// Type definitions for mobservable v0.6.10 +// Project: https://mweststrate.github.io/mobservable +// Definitions by: Michel Weststrate +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +interface _IMobservableStatic { + /** + * Turns an object, array or function into a reactive structure. + * @param value the value which should become observable. + */ + makeReactive: IMakeReactive; + + /** + * Extends an object with reactive capabilities. + * @param target the object to which reactive properties should be added + * @param properties the properties that should be added and made reactive + * @returns targer + */ + extendReactive(target: Object, properties: Object):Object; + + /** + * Returns true if the provided value is reactive. + * @param value object, function or array + * @param propertyName if propertyName is specified, checkes whether value.propertyName is reactive. + */ + isReactive(value: any, propertyName?:string): boolean; + + /** + * Can be used in combination with makeReactive / extendReactive. + * Enforces that a reference to 'value' is stored as property, + * but that 'value' itself is not turned into something reactive. + * Future assignments to the same property will inherit this behavior. + * @param value initial value of the reactive property that is being defined. + */ + asReference(value: any):{value:T}; + + /** + * ES6 / Typescript decorator which can to make class properties and getter functions reactive. + */ + observable(target: Object, key: string):any; // decorator / annotation + + /** + * Creates a reactive view and keeps it alive, so that the view is always + * updated if one of the dependencies changes, even when the view is not further used by something else. + * @param func The reactive view + * @param scope (optional) + * @returns disposer function, which can be used to stop the view from being updated in the future. + */ + observe(func: Mobservable.Lambda, scope?: any): Mobservable.Lambda; + + /** + * Deprecated, use mobservable.observe instead. + */ + sideEffect(func: Mobservable.Lambda, scope?: any): Mobservable.Lambda; + + /** + * Similar to 'observer', observes the given predicate until it returns true. + * Once it returns true, the 'effect' function is invoked an the observation is cancelled. + * @param predicate + * @param effect + * @param scope (optional) + * @returns disposer function to prematurely end the observer. + */ + observeUntil(predicate: ()=>boolean, effect: Mobservable.Lambda, scope?: any): Mobservable.Lambda; + + /** + * During a transaction no views are updated until the end of the transaction. + * The transaction will be run synchronously nonetheless. + * @param action a function that updates some reactive state + * @returns any value that was returned by the 'action' parameter. + */ + transaction(action: ()=>T): T; + + /** + * Converts a reactive structure into a non-reactive structure. + * Basically a deep-clone. + */ + toJSON(value: T): T; + + /** + * Sets the reporting level Defaults to 1. Use 0 for production or 2 for increased verbosity. + */ + logLevel: number; // 0 = production, 1 = development, 2 = debugging + + extras: { + getDependencyTree(thing:any, property?:string): Mobservable.IDependencyTree; + + getObserverTree(thing:any, property?:string): Mobservable.IObserverTree; + + trackTransitions(extensive?:boolean, onReport?:(lines:Mobservable.ITransitionEvent) => void) : Mobservable.Lambda; + } +} + +interface IMakeReactive { + (value: T[], opts?: Mobservable.IMakeReactiveOptions): Mobservable.IObservableArray; + (value: ()=>T, opts?: Mobservable.IMakeReactiveOptions): Mobservable.IObservableValue; + (value: T, opts?: Mobservable.IMakeReactiveOptions): Mobservable.IObservableValue; + (value: Object, opts?: Mobservable.IMakeReactiveOptions): T; +} + +interface IMobservableStatic extends _IMobservableStatic, IMakeReactive { +} + +declare module Mobservable { + interface IMakeReactiveOptions { + as?: string /* "auto" | "reference" | TODO: see #8 "structure" */ + scope?: Object, + context?: Object, + recurse?: boolean; + name?: string; + // protected: boolean TODO: see #9 + } + + export interface IContextInfoStruct { + object: Object; + name: string; + } + + export type IContextInfo = IContextInfoStruct | string; + + interface Lambda { + (): void; + name?: string; + } + + interface IObservable { + observe(callback: (...args: any[])=>void, fireImmediately?: boolean): Lambda; + } + + interface IObservableValue extends IObservable { + (): T; + (value: T):void; + observe(callback: (newValue: T, oldValue: T)=>void, fireImmediately?: boolean): Lambda; + } + + interface IObservableArray extends IObservable, Array { + spliceWithArray(index: number, deleteCount?: number, newItems?: T[]): T[]; + observe(listener: (changeData: IArrayChange|IArraySplice)=>void, fireImmediately?: boolean): Lambda; + clear(): T[]; + replace(newItems: T[]): T[]; + find(predicate: (item: T,index: number,array: IObservableArray)=>boolean,thisArg?: any,fromIndex?: number): T; + remove(value: T): boolean; + } + + interface IArrayChange { + type: string; // Always: 'update' + object: IObservableArray; + index: number; + oldValue: T; + } + + interface IArraySplice { + type: string; // Always: 'splice' + object: IObservableArray; + index: number; + removed: T[]; + addedCount: number; + } + + interface IDependencyTree { + id: number; + name: string; + context: any; + dependencies?: IDependencyTree[]; + } + + interface IObserverTree { + id: number; + name: string; + context: any; + observers?: IObserverTree[]; + listeners?: number; // amount of functions manually attached using an .observe method + } + + interface ITransitionEvent { + id: number; + name: string; + context: Object; + state: string; + changed: boolean; + newValue: string; + } +} + +declare module "mobservable" { + var m : IMobservableStatic; + export = m; +} \ No newline at end of file From f2fd8100a8380fd7c202c215b15c5da1e338cc86 Mon Sep 17 00:00:00 2001 From: Michel Weststrate Date: Tue, 22 Sep 2015 10:47:33 +0200 Subject: [PATCH 055/146] made sure tests / typings succeed on typescript 1.6.2 --- mobservable-react/mobservable-react-tests.ts | 5 ++++- mobservable-react/mobservable-react.d.ts | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mobservable-react/mobservable-react-tests.ts b/mobservable-react/mobservable-react-tests.ts index 7bda00cf4..7b39dbb7f 100644 --- a/mobservable-react/mobservable-react-tests.ts +++ b/mobservable-react/mobservable-react-tests.ts @@ -51,7 +51,10 @@ class TestComponent2 extends React.Component<{ test: string },{}> { } } { - let c4Factory = React.createFactory(reactiveComponent(TestComponent2)); + // Does not work properly in typescript 1.6.2 without cast :'( + // Argument of type 'typeof TestComponent2 | void' is not assignable to parameter of type 'ComponentClass<{ test: string; }>'. + // Type 'void' is not assignable to type 'ComponentClass<{ test: string; }>'. + let c4Factory = React.createFactory(> reactiveComponent(TestComponent2)); React.render(c4Factory({ test: "hello" }) , null); diff --git a/mobservable-react/mobservable-react.d.ts b/mobservable-react/mobservable-react.d.ts index 34ecd78f8..f42627a85 100644 --- a/mobservable-react/mobservable-react.d.ts +++ b/mobservable-react/mobservable-react.d.ts @@ -11,6 +11,6 @@ declare module "mobservable-react" { */ export function reactiveComponent

(clazz: React.ClassicComponentClass

): React.ClassicComponentClass

; export function reactiveComponent

(clazz: React.ComponentClass

): React.ComponentClass

; - export function reactiveComponent

(clazz: React.ComponentClass

): void; // for decorator + export function reactiveComponent>(target: TFunction): TFunction | void; // decorator signature export function reactiveComponent

(renderFunction: (props: P) => React.ReactElement): React.ClassicComponentClass

; } \ No newline at end of file From 4203263ac27708e2e3237eab04bab5fd37ed14c3 Mon Sep 17 00:00:00 2001 From: tkqubo Date: Tue, 22 Sep 2015 17:54:29 +0900 Subject: [PATCH 056/146] Add restful.js --- restful.js/restful.js-tests.ts | 198 ++++++++++++++++++++++++++ restful.js/restful.js.d.ts | 245 +++++++++++++++++++++++++++++++++ 2 files changed, 443 insertions(+) create mode 100644 restful.js/restful.js-tests.ts create mode 100644 restful.js/restful.js.d.ts diff --git a/restful.js/restful.js-tests.ts b/restful.js/restful.js-tests.ts new file mode 100644 index 000000000..80f3bd187 --- /dev/null +++ b/restful.js/restful.js-tests.ts @@ -0,0 +1,198 @@ +/// + +import restful, { + Api, MemberResponse, CollectionResponse, ResponseBody, CollectionEndpoint, MemberEndpoint, +} from 'restful.js'; + +class Article { + title: string; + body: string; +} +class Comment { + body: string; +} +class Author { + name: string; +} + +var api: Api; + +api = restful('api.example.com'); + +// +// Usage +// + +api = restful('api.example.com') + .header('AuthToken', 'test') // set global header + .prefixUrl('v1') + .protocol('https') + .port(8080); +// resource now targets `https://api.example.com:8080/v1` + + +var articlesCollection = api.all('articles'); // http://api.example.com/articles +var articleMember = api.one('articles', 1); // http://api.example.com/articles/1 +var articleMember = api.one('articles', 1); // http://api.example.com/articles/1 +var commentsCollection = articleMember.all('comments'); // http://api.example.com/articles/1/comments + +var articleMember = api.oneUrl('articles', 'http://custom.url/article?id=1'); // http://custom.url/article?id=1 +var articlesCollection = api.allUrl('articles', 'http://custom.url/article/list'); // http://custom.url/article/list + +articleMember = api.one('articles', 1); // http://api.example.com/articles/1 +articleMember.get().then((response: MemberResponse

) => { + var articleEntity = response.body(); + + var article = articleEntity.data(); + console.log(article.title); // hello, world! +}); + +commentsCollection = articleMember.all('comments'); // http://api.example.com/articles/1/comments +commentsCollection.getAll().then((response: CollectionResponse) => { + var commentEntities = response.body(); + + commentEntities.forEach((commentEntity: ResponseBody) => { + var comment = commentEntity.data(); + console.log(comment.body); + }) +}); + +// fetch http://api.example.com/articles/1/comments/4 +articleMember = api.one('articles', 1); +let commentMember = articleMember.one('comments', 4); +commentMember.get().then((response) => { + // +}); +// equivalent to +commentsCollection = articleMember.all('comments'); +commentsCollection.get(4).then((response) => { + // +}); + +// +// Entity Data +// + +var articleCollection = api.all('articles'); // http://api.example.com/articles + +// http://api.example.com/articles/1 +api.one('articles', 1).get().then((response: MemberResponse
) => { + var articleEntity = response.body(); + + // if the server response was { id: 1, title: 'test', body: 'hello' } + var article = articleEntity.data(); + article.title; // returns `test` + article.body; // returns `hello` + // You can also edit it + article.title = 'test2'; + // Finally you can easily update it or delete it + articleEntity.save(); // will perform a PUT request + articleEntity.remove(); // will perform a DELETE request +}, (response: any) => { + // The reponse code is not >= 200 and < 400 + throw new Error('Invalid response'); +}); + +articleMember = api.one('articles', 1); // http://api.example.com/articles/1 +commentMember = articleMember.one('comments', 3); // http://api.example.com/articles/1/comments/3 +commentMember.get() + .then((response: MemberResponse) => { + var commentEntity = response.body(); + + // You can also call `all` and `one` on an entity + return commentEntity.all('authors').getAll(); // http://api.example.com/articles/1/comments/3/authors +}).then((response: CollectionResponse) => { + var authorEntities = response.body(); + + authorEntities.forEach((authorEntity: ResponseBody) => { + var author = authorEntity.data(); + console.log(author.name); + }); +}); + +// configure the api +api.header('AuthToken', 'test'); + +articlesCollection = api.all('articles'); +articlesCollection.get(1); // will send the `AuthToken` header +// You can configure articlesCollection, too +articlesCollection.header('foo', 'bar'); + +//TODO: The line below was written in README.md but actually incorrect invocation, hence commented out +//articlesCollection.one('comments', 1).get(); // will send both the AuthToken and foo headers + + +// http://api.example.com/articles/1/comments/2/authors +let authorsCollection = api.one('articles', 1).one('comments', 2).all('authors'); +authorsCollection.getAll().then(function(authorEntities) { /* */ }); +authorsCollection.get(1).then(function(authorEntity) { /* */ }); + + +// +// Interceptors +// + +var resource: Api; + +resource.addRequestInterceptor((data: any, headers: any, method: string, url: string) => { + // to edit the headers, just edit the headers object + + // You always must return the data object + return data; +}); + +resource.addFullRequestInterceptor(function(params, headers, data, method, url) { + //... + + // all args had been modified + return { + params: params, + headers: headers, + data: data, + method: method, + url: url + }; + + // just return modified arguments + return { + headers: headers, + data: data + }; +}); + +resource.addFullResponseInterceptor(function(data, headers, method, url) { + // all args had been modified (method and url is read only) + return { + headers: headers, + data: data + }; + + // just return modified arguments + return { + headers: headers + }; +}); + +// +// Response methods +// + +// http://api.example.com/articles/1/comments/2 +commentMember = api.one('articles', 1).one('comments', 2); +commentMember.get().then(function(response) { + let commentEntity = response.body(); + commentEntity.save(); + commentEntity.remove(); +}); + +// +// Error Handling +// + +commentMember = resource.one('articles', 1).one('comments', 2); +commentMember + .get() + .then(function(commentEntity) { /* */ }) + .catch(function(err) { + // deal with the error +}); diff --git a/restful.js/restful.js.d.ts b/restful.js/restful.js.d.ts new file mode 100644 index 000000000..2d62f113c --- /dev/null +++ b/restful.js/restful.js.d.ts @@ -0,0 +1,245 @@ +// Type definitions for restful.js 0.6.2 +// Project: https://github.com/marmelab/restful.js +// Definitions by: Qubo +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "restful.js" { + export interface Headers { + [key: string]: any + } + + export interface Api extends Endpoint { + all(name: string): CollectionEndpoint; + allUrl(name: string, url: string): CollectionEndpoint; + one(name: string, id: any): MemberEndpoint; + oneUrl(name: string, url: string): MemberEndpoint; + protocol(protocol: string): Api; + protocol(): string; + baseUrl(protocol: string): Api; + baseUrl(): string; + port(port: number): Api; + port(): number; + prefixUrl(prefix: string): Api; + prefixUrl(): string; + customUrl(url: string): Api; + customUrl(): string; + } + + export interface MemberEndpoint extends Endpoint { + /** + * Target a child collection name. + * @param name + */ + all(name: string): CollectionEndpoint; + allUrl(name: string, url: string): CollectionEndpoint; + /** + * Target a child member in a collection name. + * @param name + * @param id + */ + one(name: string, id: any): MemberEndpoint; + oneUrl(name: string, url: string): MemberEndpoint; + /** + * Get a member. Returns a promise with an entity. + * @param params + * @param headers + */ + get(params?: any, headers?: Headers): Promise>; + /** + * Update a member. Returns a promise with the response. + * @param data + * @param headers + */ + put(data: any, headers?: Headers): Promise>; + /** + * Delete a member. Returns a promise with the response. + * @param data + * @param headers + */ + delete(data?: any, headers?: Headers): Promise>; + /** + * Patch a member. Returns a promise with the response. + * @param data + * @param headers + */ + patch(data: any, headers?: Headers): Promise>; + /** + * Perform a HEAD request on a member. Returns a promise with the response. + * @param headers + */ + head(headers?: any): Promise>; + customUrl(url: string): MemberEndpoint; + customUrl(): string; + } + + export interface CollectionEndpoint extends Endpoint { + /** + * Get a member in a collection. Returns a promise with an entity. + * @param id + */ + get(id: any, params?: any, headers?: Headers): Promise>; + /** + * Get a full collection. Returns a promise with an array of entities. + */ + getAll(params?: any, headers?: Headers): Promise>; + /** + * Create a member in a collection. Returns a promise with the response. + */ + post(data: any, headers?: Headers): Promise>; + /** + * Update a member in a collection. Returns a promise with the response. + * @param id + * @param data + * @param headers + */ + put(id: any, data: any, headers?: Headers): Promise>; + /** + * Delete a member in a collection. Returns a promise with the response. + * @param id + * @param data + * @param headers + */ + delete(id: any, data?: any, headers?: Headers): Promise>; + /** + * Patch a member in a collection. Returns a promise with the response. + * @param id + * @param data + * @param headers + */ + patch(id: any, data: any, headers?: Headers): Promise>; + /** + * Perform a HEAD request on a member in a collection. Returns a promise with the response. + * @param id + * @param headers + */ + head(id: any, headers?: Headers): Promise>; + } + + export interface Endpoint { + /** + * Get the url. + */ + url(): string; + /** + * Add a response interceptor. You can only alter data and headers. + */ + addResponseInterceptor(interceptor: ResponseInterceptor): Self; + responseInterceptors(): ResponseInterceptor[]; + /** + * Add a request interceptor. + */ + addRequestInterceptor(interceptor: RequestInterceptor): Self; + requestInterceptors(): RequestInterceptor[]; + /** + * Add a full response interceptor. You can alter data and headers. + */ + addFullResponseInterceptor(interceptor: ResponseInterceptor): Self; + fullResponseInterceptors(): ResponseInterceptor[]; + /** + * Add a full request interceptor. You can alter params, headers, data, method and url. + */ + addFullRequestInterceptor(interceptor: FullRequestInterceptor): Self; + fullRequestInterceptors(): FullRequestInterceptor[]; + /** + * Add a header. + * @param name + * @param value + */ + header(name: string, value: any): Self; + headers(): Headers; + } + + export interface MemberResponse extends ResponseBase { + (): { + data: T; + headers: Headers; + status: number; + statusText: string; + } + body(): ResponseBody; + } + + export interface CollectionResponse extends ResponseBase { + (): { + data: T[]; + headers: Headers; + status: number; + statusText: string; + } + body(): ResponseBody[]; + } + + export interface ResponseBase { + status(): number; + headers(): Headers; + config(): any; + } + + export interface ResponseBody { + /** + * Get the JS object unserialized from the response body (which must be in JSON) + */ + data(): T; + (): T; + /** + * Query a collection child of the entity. + * @param entity + */ + all(entity: string): CollectionEndpoint; + /** + * Query a member child of the entity. + * @param entity + * @param id + */ + one(entity: string, id: any): MemberEndpoint; + /** + * Update the member link to the entity. Returns a promise with the response. + * @param headers + */ + save(headers?: Headers): void; + /** + * Delete the member link to the entity. Returns a promise with the response. + */ + remove(headers?: Headers): void; + /** + * Get the entity url. + */ + url(): string; + /** + * Get the id of the entity. + */ + id(): any; + } + + export interface RequestInterceptor { + (data: any, headers: Headers, method: string, url: string): any; + } + + export interface FullRequestInterceptor { + (params: any, headers: Headers, data: any, method: string, url: string): FullRequestInterceptorReturnValue; + } + + export interface FullRequestInterceptorReturnValue { + params?: any; + headers?: Headers; + data?: any; + method?: string; + url?: string; + } + + export interface ResponseInterceptor { + (data: any, headers: Headers, method: string, url: string): ResponseInterceptorReturnValue; + } + + export interface ResponseInterceptorReturnValue { + headers?: Headers; + data?: any; + method?: string; + url?: string; + } + + export default function restful(endpoint: string): Api; +} + From d70546472ac72f8768ab3cd8aae9631043d28183 Mon Sep 17 00:00:00 2001 From: Aya Morisawa Date: Tue, 22 Sep 2015 18:13:35 +0900 Subject: [PATCH 057/146] Not use es6-promise in kefir.d.ts --- kefir/kefir-tests.ts | 4 ++-- kefir/kefir.d.ts | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/kefir/kefir-tests.ts b/kefir/kefir-tests.ts index c423a3dfe..a0d0a9618 100644 --- a/kefir/kefir-tests.ts +++ b/kefir/kefir-tests.ts @@ -48,7 +48,7 @@ import { Observable, ObservablePool, Stream, Property, Event, Emitter } from 'ke { let property01: Property = Kefir.constant(1); let property02: Property = Kefir.constantError(1); - let property03: Property = Kefir.fromPromise(new Promise(fulfill => fulfill(1))); + //let property03: Property = Kefir.fromPromise(new Promise(fulfill => fulfill(1))); } // Convert observables @@ -69,7 +69,7 @@ import { Observable, ObservablePool, Stream, Property, Event, Emitter } from 'ke Kefir.sequentially(1000, [1, 2]).offAny(event => console.log('event:', event)); Kefir.sequentially(1000, [1, 2]).log('my stream'); Kefir.sequentially(1000, [1, 2]).offLog('my stream'); - Kefir.sequentially(1000, [1, 2]).toPromise().then(x => console.log('fulfilled with:', x)); + Kefir.sequentially(1000, [1, 2]).toPromise().then((x: number) => console.log('fulfilled with:', x)); } // Modify an observable diff --git a/kefir/kefir.d.ts b/kefir/kefir.d.ts index 6a9544a7c..9e3303f01 100644 --- a/kefir/kefir.d.ts +++ b/kefir/kefir.d.ts @@ -4,9 +4,9 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped /// -/// declare module "kefir" { + export interface Observable { // Subscribe / add side effects onValue(callback: (value: T) => void): void; @@ -19,7 +19,7 @@ declare module "kefir" { offAny(callback: (event: Event) => void): void; log(name?: string): void; offLog(name?: string): void; - toPromise(PromiseConstructor?: typeof Promise): Promise; + toPromise(PromiseConstructor?: any): any; } export interface Stream extends Observable { @@ -163,7 +163,7 @@ declare module "kefir" { // Create a property export function constant(value: T): Property; export function constantError(error: T): Property; - export function fromPromise(promise: Promise): Property; + export function fromPromise(promise: any): Property; // Combine observables export function combine(obss: Observable[], passiveObss: Observable[], combinator?: (...values: T[]) => U): Observable; From c85b07a4d191bbcd9ab0c3c4fd570fa84d8874b1 Mon Sep 17 00:00:00 2001 From: MatejQ Date: Fri, 18 Sep 2015 17:07:42 +0200 Subject: [PATCH 058/146] Added missing on.sortChanged --- ui-grid/ui-grid.d.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ui-grid/ui-grid.d.ts b/ui-grid/ui-grid.d.ts index 16f2e1fde..27e2e1fff 100644 --- a/ui-grid/ui-grid.d.ts +++ b/ui-grid/ui-grid.d.ts @@ -998,6 +998,12 @@ declare module uiGrid { * @param {rowsVisibleChangedHandler} handler callback */ rowsVisibleChanged: (scope: ng.IScope, handler: rowsVisibleChangedHandler) => void; + /** + * is raised after the sort criteria on one or more columns has changed + * @param {ng.IScope} scope Grid scope + * @param {rowsVisibleChangedHandler} handler callback + */ + sortChanged: (scope: ng.IScope, handler: sortChangedHandler) => void; /** * is raised when scroll begins. Is throttled, so won't be raised too frequently * @param {ng.IScope} scope Grid scope @@ -1068,6 +1074,15 @@ declare module uiGrid { (scrollEvent: JQueryMouseEventObject): void; } + export interface sortChangedHandler { + /** + * Sort change event callback + * @param {IGridInstance} grid instance + * @param {IGridColumn} array of gridColumns that have sorting on them, sorted in priority order + */ + (grid: IGridInstance, columns: IGridColumn[]): void; + } + export module cellNav { /** * Column Definitions for cellNav feature, these are available to be set using the ui-grid @@ -1128,6 +1143,7 @@ declare module uiGrid { * Brings the specified row and column into view, and sets focus to that cell * @param {any} rowEntity gridOptions.data[] array instance to make visible and set focus * @param {IColumnDef} colDef Column definition to make visible and set focus + * @returns {ng.IPromise} a promise that is resolved after any scrolling is finished */ scrollToFocus(rowEntity: any, colDef: IColumnDef): ng.IPromise; From cb7020a0564c613855354a5265485287675b5bde Mon Sep 17 00:00:00 2001 From: MatejQ Date: Tue, 22 Sep 2015 13:22:37 +0200 Subject: [PATCH 059/146] Fixed incorrect IGridOptions.rowEquality() signature --- ui-grid/ui-grid.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui-grid/ui-grid.d.ts b/ui-grid/ui-grid.d.ts index 27e2e1fff..3a58fdfa4 100644 --- a/ui-grid/ui-grid.d.ts +++ b/ui-grid/ui-grid.d.ts @@ -809,10 +809,10 @@ declare module uiGrid { /** * By default, rows are compared using object equality. This option can be overridden * to compare on any data item property or function - * @param {IGridRow} entityA First Data Item to compare - * @param {IGridRow} entityB Second Data Item to compare + * @param {any} entityA First Data Item to compare + * @param {any} entityB Second Data Item to compare */ - rowEquality?(entityA: IGridRow, entityB: IGridRow): boolean; + rowEquality?(entityA: any, entityB: any): boolean; /** * This function is used to get and, if necessary, set the value uniquely identifying this row * (i.e. if an identity is not present it will set one). From b0b6e9ea4941f04b4039b25054e5057abbf533e9 Mon Sep 17 00:00:00 2001 From: MatejQ Date: Tue, 22 Sep 2015 13:26:36 +0200 Subject: [PATCH 060/146] Revert "Added missing on.sortChanged" This reverts commit c85b07a4d191bbcd9ab0c3c4fd570fa84d8874b1. --- ui-grid/ui-grid.d.ts | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/ui-grid/ui-grid.d.ts b/ui-grid/ui-grid.d.ts index 3a58fdfa4..ece964280 100644 --- a/ui-grid/ui-grid.d.ts +++ b/ui-grid/ui-grid.d.ts @@ -998,12 +998,6 @@ declare module uiGrid { * @param {rowsVisibleChangedHandler} handler callback */ rowsVisibleChanged: (scope: ng.IScope, handler: rowsVisibleChangedHandler) => void; - /** - * is raised after the sort criteria on one or more columns has changed - * @param {ng.IScope} scope Grid scope - * @param {rowsVisibleChangedHandler} handler callback - */ - sortChanged: (scope: ng.IScope, handler: sortChangedHandler) => void; /** * is raised when scroll begins. Is throttled, so won't be raised too frequently * @param {ng.IScope} scope Grid scope @@ -1074,15 +1068,6 @@ declare module uiGrid { (scrollEvent: JQueryMouseEventObject): void; } - export interface sortChangedHandler { - /** - * Sort change event callback - * @param {IGridInstance} grid instance - * @param {IGridColumn} array of gridColumns that have sorting on them, sorted in priority order - */ - (grid: IGridInstance, columns: IGridColumn[]): void; - } - export module cellNav { /** * Column Definitions for cellNav feature, these are available to be set using the ui-grid @@ -1143,7 +1128,6 @@ declare module uiGrid { * Brings the specified row and column into view, and sets focus to that cell * @param {any} rowEntity gridOptions.data[] array instance to make visible and set focus * @param {IColumnDef} colDef Column definition to make visible and set focus - * @returns {ng.IPromise} a promise that is resolved after any scrolling is finished */ scrollToFocus(rowEntity: any, colDef: IColumnDef): ng.IPromise; From fe92aa252c8e90161de9d1a4430814fdaf4cae02 Mon Sep 17 00:00:00 2001 From: rushi216 Date: Tue, 22 Sep 2015 17:05:34 +0530 Subject: [PATCH 061/146] added extraPlugins property on configuration object --- ckeditor/ckeditor.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/ckeditor/ckeditor.d.ts b/ckeditor/ckeditor.d.ts index 3bb90c760..37e609484 100644 --- a/ckeditor/ckeditor.d.ts +++ b/ckeditor/ckeditor.d.ts @@ -572,6 +572,7 @@ declare module CKEDITOR { colorButton_colors?: string; startupFocus?: boolean; on?: any; + extraPlugins?: string; } From 312592e8fb2ff554c4010b6303d894a370104cde Mon Sep 17 00:00:00 2001 From: Nelson Lamprecht Date: Tue, 22 Sep 2015 07:23:19 -0500 Subject: [PATCH 062/146] Updated SharePoint.d.ts with correct type of boolean instead of number for showMaximized of IDialogOptions,DialogOptions https://msdn.microsoft.com/en-us/library/ff410058(v=office.14).aspx --- sharepoint/SharePoint.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sharepoint/SharePoint.d.ts b/sharepoint/SharePoint.d.ts index 2981718eb..181c40491 100644 --- a/sharepoint/SharePoint.d.ts +++ b/sharepoint/SharePoint.d.ts @@ -7159,7 +7159,7 @@ declare module SP { /** Y coordinate of the dialog box. */ y?: number; /** The dialog will be maximized when shown. */ - showMaximized?: number; + showMaximized?: boolean; /** url of the page which is shown in the modal dialog. You should use either html or url attribute, but not both. */ url?: string; /** specifies if close button should be shown on the dialog */ @@ -7191,7 +7191,7 @@ declare module SP { /** Y coordinate of the dialog box. */ y: number; /** The dialog will be maximized when shown. */ - showMaximized: number; + showMaximized: boolean; /** url of the page which is shown in the modal dialog. You should use either html or url attribute, but not both. */ url: string; /** specifies if close button should be shown on the dialog */ From 2cb8fd4638231efd24929f99d56372bdb57d337b Mon Sep 17 00:00:00 2001 From: Paulo Cesar Date: Tue, 22 Sep 2015 09:35:19 -0300 Subject: [PATCH 063/146] update for 1.6 --- express-jwt/express-jwt.d.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/express-jwt/express-jwt.d.ts b/express-jwt/express-jwt.d.ts index 615afd2ac..77f296b1f 100644 --- a/express-jwt/express-jwt.d.ts +++ b/express-jwt/express-jwt.d.ts @@ -12,12 +12,22 @@ declare module "express-jwt" { function jwt(options: jwt.Options): jwt.RequestHandler; + interface IDoneCallback { + (err: Error, result: T): void; + } + + type ICallback = (req: express.Request, payload: T, done: IDoneCallback) => void; + module jwt { export interface Options { - secret: string; + secret: string|ICallback; userProperty?: string; skip?: string[]; credentialsRequired?: boolean; + isRevoked?: boolean; + requestProperty?: string; + getToken?: ICallback; + [property: string]: any; } export interface RequestHandler extends express.RequestHandler { unless?: typeof unless; From ae656fbca140033ed13c12e536cd6a2f66d4ed69 Mon Sep 17 00:00:00 2001 From: Nicola Sanitate Date: Tue, 22 Sep 2015 14:38:08 +0200 Subject: [PATCH 064/146] Fix typo in DropzoneOptions interface --- dropzone/dropzone.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dropzone/dropzone.d.ts b/dropzone/dropzone.d.ts index 50dd433e3..93f9ca25b 100644 --- a/dropzone/dropzone.d.ts +++ b/dropzone/dropzone.d.ts @@ -41,7 +41,7 @@ interface DropzoneOptions { filesizeBase?: number; maxFiles?: number; params?: {}; - headers?: {}, + headers?: {}; clickable?: boolean|string|HTMLElement|(string|HTMLElement)[]; ignoreHiddenFiles?: boolean; acceptedFiles?: string; From 01e5a67adccfe86516432c18f79e52788440de00 Mon Sep 17 00:00:00 2001 From: Paulo Cesar Date: Tue, 22 Sep 2015 10:10:05 -0300 Subject: [PATCH 065/146] missing non-optional email, fixes for 1.6 --- mailcheck/mailcheck.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/mailcheck/mailcheck.d.ts b/mailcheck/mailcheck.d.ts index 64b5f93c4..66d90ba0c 100644 --- a/mailcheck/mailcheck.d.ts +++ b/mailcheck/mailcheck.d.ts @@ -46,6 +46,7 @@ declare module MailcheckModule { } export interface IOptions { + email: string; domains?: string[]; secondLevelDomains?: string[]; topLevelDomains?: string[]; From 63e8414266d3d547cf50220628acb96ab1e7efa3 Mon Sep 17 00:00:00 2001 From: Paulo Cesar Date: Tue, 22 Sep 2015 10:11:13 -0300 Subject: [PATCH 066/146] update test --- mailcheck/mailcheck-tests.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mailcheck/mailcheck-tests.ts b/mailcheck/mailcheck-tests.ts index 4a5caa12a..b3152b1d9 100644 --- a/mailcheck/mailcheck-tests.ts +++ b/mailcheck/mailcheck-tests.ts @@ -14,6 +14,7 @@ var superStringDistance = function(string1: string, string2: string): number { $('#email').on('blur', function() { $(this).mailcheck({ + email: 'nonoptional@example.com', domains: domains, // optional secondLevelDomains: secondLevelDomains, // optional topLevelDomains: topLevelDomains, // optional @@ -28,6 +29,7 @@ $('#email').on('blur', function() { }); Mailcheck.run({ + email: 'nonoptional@example.com', domains: domains, // optional secondLevelDomains: secondLevelDomains, // optional topLevelDomains: topLevelDomains, // optional @@ -41,6 +43,7 @@ Mailcheck.run({ }); MC.run({ + email: 'nonoptional@example.com', domains: domains, // optional secondLevelDomains: secondLevelDomains, // optional topLevelDomains: topLevelDomains, // optional From cf9511a8320fdfd3e9bea65618e2cef5f559d319 Mon Sep 17 00:00:00 2001 From: use-strict Date: Tue, 22 Sep 2015 17:35:28 +0300 Subject: [PATCH 067/146] Update material-ui.d.ts --- material-ui/material-ui.d.ts | 608 +++++++++++++++++++++-------------- 1 file changed, 361 insertions(+), 247 deletions(-) diff --git a/material-ui/material-ui.d.ts b/material-ui/material-ui.d.ts index 673435c24..b57778864 100644 --- a/material-ui/material-ui.d.ts +++ b/material-ui/material-ui.d.ts @@ -72,10 +72,10 @@ declare module "material-ui" { export import TableHeaderColumn = __MaterialUI.Table.TableHeaderColumn; // require('material-ui/lib/table/table-header-column'); export import TableRow = __MaterialUI.Table.TableRow; // require('material-ui/lib/table/table-row'); export import TableRowColumn = __MaterialUI.Table.TableRowColumn; // require('material-ui/lib/table/table-row-column'); - export import Theme = __MaterialUI.Theme; // require('material-ui/lib/theme'); - export import Toggle = __MaterialUI.Toggle; // require('material-ui/lib/toggle'); - export import TimePicker = __MaterialUI.TimePicker; // require('material-ui/lib/time-picker'); export import TextField = __MaterialUI.TextField; // require('material-ui/lib/text-field'); + export import Theme = __MaterialUI.Theme; // require('material-ui/lib/theme'); + export import TimePicker = __MaterialUI.TimePicker; // require('material-ui/lib/time-picker'); + export import Toggle = __MaterialUI.Toggle; // require('material-ui/lib/toggle'); export import Toolbar = __MaterialUI.Toolbar.Toolbar; // require('material-ui/lib/toolbar/toolbar'); export import ToolbarGroup = __MaterialUI.Toolbar.ToolbarGroup; // require('material-ui/lib/toolbar/toolbar-group'); export import ToolbarSeparator = __MaterialUI.Toolbar.ToolbarSeparator; // require('material-ui/lib/toolbar/toolbar-separator'); @@ -84,9 +84,9 @@ declare module "material-ui" { export import Utils = __MaterialUI.Utils; // require('material-ui/lib/utils/'); // export type definitions + export import DialogAction = __MaterialUI.DialogAction; export import TouchTapEvent = __MaterialUI.TouchTapEvent; export import TouchTapEventHandler = __MaterialUI.TouchTapEventHandler; - export import DialogAction = __MaterialUI.DialogAction; } declare namespace __MaterialUI { @@ -112,9 +112,7 @@ declare namespace __MaterialUI { // more specific than React.HTMLAttributes - interface AppBarProp extends React.Props> { - ref?: string | ((component: AppBar) => any); - + interface AppBarProp extends React.Props { iconClassNameLeft?: string; iconClassNameRight?: string; iconElementLeft?: React.ReactElement; @@ -122,25 +120,22 @@ declare namespace __MaterialUI { iconStyleRight?: string; style?: React.CSSProperties; showMenuIconButton?: boolean; - title?: any; + title?: React.ReactNode; zDepth?: number; onLeftIconButtonTouchTap?: TouchTapEventHandler; onRightIconButtonTouchTap?: TouchTapEventHandler; } - export class AppBar extends React.Component{ + export class AppBar extends React.Component{ } - interface AppCanvasProp extends React.Props { - ref?: string | ((component: AppCanvas) => any); - + interface AppCanvasProp extends React.Prop { + } - export class AppCanvas extends React.Component { + export class AppCanvas extends React.Component { } interface AvatarProp extends React.Props { - ref?: string | ((component: AvatarProp) => any); - icon?: React.ReactElement; backgroundColor?: string; color?: string; @@ -148,21 +143,23 @@ declare namespace __MaterialUI { src?: string; style?: React.CSSProperties; } - export class Avatar extends React.Component { + export class Avatar extends React.Component { } interface BeforeAfterWrapperProp extends React.Props { - ref?: string | ((component: BeforeAfterWrapper) => any); - + beforeStyle?: React.CSSProperties; + afterStyle?: React.CSSProperties; + beforeElementType?: string; + afterElementType?: string; + elementType?: string; } - export class BeforeAfterWrapper extends React.Component { + export class BeforeAfterWrapper extends React.Component { } namespace Card { interface CardProp extends React.Props { - ref?: string | ((component: Card) => any); - + expandable?: boolean; initiallyExpanded?: boolean; onExpandedChange?: (isExpanded: boolean) => void; style?: React.CSSProperties; @@ -171,26 +168,20 @@ declare namespace __MaterialUI { } interface CardActionsProp extends React.Props { - ref?: string | ((component: CardActions) => any); - expandable?: boolean; showExpandableButton?: boolean; } - export class CardActions extends React.Component { + export class CardActions extends React.Component { } interface CardExpandableProp extends React.Props { - ref?: string | ((component: CardExpandable) => any); - - onExpanding: (isExpanded: boolean) => void; - expanded: boolean; + onExpanding?: (isExpanded: boolean) => void; + expanded?: boolean; } - export class CardExpandable extends React.Component { + export class CardExpandable extends React.Component { } interface CardHeaderProp extends React.Props { - ref?: string | ((component: CardHeader) => any); - expandable?: boolean; showExpandableButton?: boolean; title?: string | React.ReactElement; @@ -203,36 +194,30 @@ declare namespace __MaterialUI { style?: React.CSSProperties; avatar: React.ReactElement | string; } - export class CardHeader extends React.Component { + export class CardHeader extends React.Component { } interface CardMediaProp extends React.Props { - ref?: string | ((component: CardMedia) => any); - expandable?: boolean; - overlay?: React.ReactElement; + overlay?: React.ReactNode; overlayStyle?: React.CSSProperties; overlayContainerStyle?: React.CSSProperties; overlayContentStyle?: React.CSSProperties; mediaStyle?: React.CSSProperties; style?: React.CSSProperties; } - export class CardMedia extends React.Component { + export class CardMedia extends React.Component { } interface CardTextProp extends React.Props { - ref?: string | ((component: CardText) => any); - expandable?: boolean; color?: string; style?: React.CSSProperties; } - export class CardText extends React.Component { + export class CardText extends React.Component { } interface CardTitleProp extends React.Props { - ref?: string | ((component: CardTitle) => any); - expandable?: boolean; showExpandableButton?: boolean; title?: string | React.ReactElement; @@ -244,7 +229,7 @@ declare namespace __MaterialUI { textStyle?: React.CSSProperties; style?: React.CSSProperties; } - export class CardTitle extends React.Component { + export class CardTitle extends React.Component { } } @@ -277,7 +262,7 @@ declare namespace __MaterialUI { onSwitch?: (e: React.MouseEvent, isInputChecked: boolean) => void; labelPosition?: string; } - export class EnhancedSwitch extends React.Component { + export class EnhancedSwitch extends React.Component { isSwitched(): boolean; setSwitched(newSwitchedValue: boolean): void; getValue(): any; @@ -286,8 +271,6 @@ declare namespace __MaterialUI { interface CheckboxProp extends CommonEnhancedSwitchProp { // is root element - ref?: string | ((component: Checkbox) => any); - checkedIcon?: React.ReactElement<{ style?: React.CSSProperties }>; // Normally an SvgIcon defaultChecked?: boolean; iconStyle?: React.CSSProperties; @@ -304,38 +287,64 @@ declare namespace __MaterialUI { onCheck?: (event: React.MouseEvent, checked: boolean) => void; } - export class Checkbox extends React.Component { + export class Checkbox extends React.Component { isChecked(): void; setChecked(newCheckedValue: boolean): void; } interface CircularProgressProp extends React.Props { - ref?: string | ((component: CircularProgress) => any); + mode?: string; + value?: number; + min?: number; + max?: number; + size?: number; + color?: string; + innerStyle?: React.CSSProperties; } - export class CircularProgress extends React.Component { + export class CircularProgress extends React.Component { } interface ClearFixProp extends React.Props { - ref?: string | ((component: ClearFix) => any); - } - export class ClearFix extends React.Component { + export class ClearFix extends React.Component { } namespace DatePicker { interface DatePickerProp extends React.Props { - ref?: string | ((component: DatePicker) => any); - + autoOk?: boolean; + defaultDate?: Date; + formatDate?: string; + hideToolbarYearChange?: boolean; + maxDate?: Date; + minDate?: Date; + mode?: string; + onDismiss?: Function; + //TODO: typeof e? + onChange?: (e: any, d: Date): void; + onFocus?: React.FocusEventHandler; + onShow?: Function; + onTouchTap?: React.TouchEventHandler; + shouldDisableDate?: (day: Date) => boolean; + showYearSelector?: boolean; + textFieldStyle?: React.CSSProperties; } - export class DatePicker extends React.Component { + export class DatePicker extends React.Component { } interface DatePickerDialogProp extends React.Props { - ref?: string | ((component: DatePickerDialog) => any); - + disableYearSelection?: boolean; + initialDate?: Date; + maxDate?: Date; + minDate?: Date; + onAccept?: (d: Date) => void; + onClickAway?: Function; + onDismiss?: Function; + onShow?: Function; + shouldDisableDate?: (day: Date) => boolean; + showYearSelector?: boolean; } - export class DatePickerDialog extends React.Component { + export class DatePickerDialog extends React.Component { } } @@ -347,42 +356,45 @@ declare namespace __MaterialUI { onClick?: React.MouseEventHandler; } interface DialogProp extends React.Props { - ref?: string | ((component: Dialog) => any); - actions?: Array>; actionFocus?: string; + autoDetectWindowHeight?: boolean; + autoScrollBodyContent?: boolean; + bodyStyle?: React.CSSProperties; contentClassName?: string; contentInnerStyle?: React.CSSProperties; contentStyle?: React.CSSProperties; modal?: boolean; openImmediately?: boolean; - title?: any; - autoDetectWindowHeight?: boolean; - autoScrollBodyContent?: boolean; + repositionOnUpdate?: boolean; + title?: React.ReactNode; - onDismiss?: () => void; - onShow?: () => void; + onClickAway?: Function; + onDismiss?: Function; + onShow?: Function; } - export class Dialog extends React.Component { + export class Dialog extends React.Component { dismiss(): void; show(): void; } interface DropDownIconProp extends React.Props { - ref?: string | ((component: DropDownIcon) => any); - + onChange?: Menu.ChangeHandler; + menuItems: Menu.MenuItemProp[]; + closeOnMenuItemTouchTap?: boolean; + iconStyle?: React.CSSProperties; + iconClassName?: string; + iconLigature?: string; } - export class DropDownIcon extends React.Component { + export class DropDownIcon extends React.Component { } interface DropDownMenuProp extends React.Props { - ref?: string | ((component: DropDownMenu) => any); - displayMember?: string; valueMember?: string; autoWidth?: boolean; - menuItems?: Array<{ text: string, payload: string } | {}>; - menuItemStyle?: React.CSSProperties[]; + menuItems: Menu.MenuItemProp[]; + menuItemStyle?: React.CSSProperties; selectedIndex?: number; underlineStyle?: React.CSSProperties; iconStyle?: React.CSSProperties; @@ -392,13 +404,14 @@ declare namespace __MaterialUI { valueLink?: ReactLink; value?: number; - onChange?: (e: TouchTapEvent, selectedIndex: number, menuItem: any) => void; + onChange?: Menu.ChangeHandler; } - export class DropDownMenu extends React.Component { + export class DropDownMenu extends React.Component { } // non generally overridden elements of EnhancedButton interface SharedEnhancedButtonProp extends React.HTMLAttributesBase { + centerRipple?: boolean; containerElement?: string | React.ReactElement; disabled?: boolean; disableFocusRipple?: boolean; @@ -413,6 +426,7 @@ declare namespace __MaterialUI { onBlur?: React.FocusEventHandler; onFocus?: React.FocusEventHandler; + onKeyboardFocus?: (e: React.FocusEvent, isKeyboardFocused: boolean) => void; onKeyDown?: React.KeyboardEventHandler; onKeyUp?: React.KeyboardEventHandler; onMouseEnter?: React.MouseEventHandler; @@ -423,19 +437,14 @@ declare namespace __MaterialUI { } interface EnhancedButtonProp extends SharedEnhancedButtonProp { - ref?: string | ((component: EnhancedButton) => any); - - onKeyboardFocus?: (e: React.FocusEvent, isKeyboardFocused: boolean) => void; touchRippleColor?: string; focusRippleColor?: string; style?: React.CSSProperties; } - export class EnhancedButton extends React.Component { + export class EnhancedButton extends React.Component { } interface FlatButtonProp extends SharedEnhancedButtonProp { - ref?: string | ((component: FlatButton) => any); - hoverColor?: string; label?: string; labelPosition?: string; @@ -448,12 +457,10 @@ declare namespace __MaterialUI { onKeyboardFocus?: (e: React.KeyboardEvent, isKeyboardFocused: boolean) => void; } - export class FlatButton extends React.Component { + export class FlatButton extends React.Component { } interface FloatingActionButtonProp extends SharedEnhancedButtonProp { - ref?: string | ((component: FloatingActionButton) => any); - backgroundColor?: string; disabled?: boolean; disabledColor?: string; @@ -463,12 +470,10 @@ declare namespace __MaterialUI { secondary?: boolean; style?: React.CSSProperties; } - export class FloatingActionButton extends React.Component { + export class FloatingActionButton extends React.Component { } interface FontIconProp extends React.Props { - ref?: string | ((component: FontIcon) => any); - color?: string; hoverColor?: string; onMouseLeave?: React.MouseEventHandler; @@ -476,12 +481,10 @@ declare namespace __MaterialUI { style?: React.CSSProperties; className?: string; } - export class FontIcon extends React.Component { + export class FontIcon extends React.Component { } interface IconButtonProp extends SharedEnhancedButtonProp { - ref?: string | ((component: IconButton) => any); - iconClassName?: string; iconStyle?: React.CSSProperties; style?: React.CSSProperties; @@ -493,66 +496,116 @@ declare namespace __MaterialUI { onBlur?: React.FocusEventHandler; onFocus?: React.FocusEventHandler; } - export class IconButton extends React.Component { + export class IconButton extends React.Component { } interface LeftNavProp extends React.Props { - ref?: string | ((component: LeftNav) => any); - + disableSwipeToOpen?: boolean; + docked?: boolean; + header?: React.ReactElement; + menuItems: Menu.MenuItemProp[]; + onChange?: Menu.ChangeHandler; + onNavOpen?: Function; + onNavClose?: Function; + openRight?: Boolean; + selectedIndex?: number; + menuItemClassName?: string; + menuItemClassNameSubheader?: string; + menuItemClassNameLink?: string; } - export class LeftNav extends React.Component { + export class LeftNav extends React.Component { } interface LinearProgressProp extends React.Props { - ref?: string | ((component: LinearProgress) => any); - + mode?: string; + value?: number; + min?: number; + max?: number; } - export class LinearProgress extends React.Component { + export class LinearProgress extends React.Component { } namespace Lists { interface ListProp extends React.Props { - ref?: string | ((component: List) => any); - + insetSubheader?: boolean; + subheader?: string; + subheaderStyle?: React.CSSProperties; + zDepth?: number; } - export class List extends React.Component { + export class List extends React.Component { } interface ListDividerProp extends React.Props { - ref?: string | ((component: ListDivider) => any); - + inset?: boolean; } - export class ListDivider extends React.Component { + export class ListDivider extends React.Component { } interface ListItemProp extends React.Props { - ref?: string | ((component: ListItem) => any); - + autoGenerateNestedIndicator?: boolean; + disableKeyboardFocus?: boolean; + initiallyOpen?: boolean; + innerDivStyle?: React.CSSProperties; + insetChildren?: boolean; + innerStyle?: React.CSSProperties; + leftAvatar?: React.ReactElement; + leftCheckbox?: React.ReactElement; + leftIcon?: React.ReactElement; + nestedLevel?: number; + nestedItems?: React.ReactElement[]; + onKeyboardFocus?: React.FocusEventHandler; + onNestedListToggle?: (item: ListItem) => void; + rightAvatar?: React.ReactElement; + rightIcon?: React.ReactElement; + rightIconButton?: React.ReactElement; + rightToggle?: React.ReactElement; + primaryText?: React.ReactNode; + secondaryText?: React.ReactNode; + secondaryTextLines?: number; } - export class ListItem extends React.Component { + export class ListItem extends React.Component { } } namespace Menu { - interface MenuProp extends React.Props { - ref?: string | ((component: Menu) => any); - + interface ChangeHandler { + (e: TouchTapEvent, key: number, payload: MenuItemProp): void; } - export class Menu extends React.Component { + interface MenuProp extends React.Props { + index: number; + text?: string; + menuItems: MenuItemProp[]; + zDepth?: number; + active?: boolean; + onItemTap?: ChangeHandler; + menuItemStyle?: React.CSSProperties; + } + export class Menu extends React.Component { } interface MenuItemProp extends React.Props { - ref?: string | ((component: MenuItem) => any); - + index: number; + iconClassName?: string; + iconRightClassName?: string; + iconStyle?: React.CSSProperties; + iconRightStyle?: React.CSSProperties; + attribute?: string; + number?: string; + data?: string; + toggle?: boolean; + onTouchTap?: (e: React.MouseEvent, key: number): void; + onToggle?: (e: React.MouseEvent, key: number, toggled: boolean): void; + selected?: boolean; + active?: boolean; } - export class MenuItem extends React.Component { + export class MenuItem extends React.Component { } } export namespace Mixins { interface ClickAwayable extends React.Mixin { } - var ClickAwayable: ClickAwayable + var ClickAwayable: ClickAwayable; interface WindowListenable extends React.Mixin { } @@ -568,23 +621,24 @@ declare namespace __MaterialUI { } interface OverlayProp extends React.Props { - ref?: string | ((component: Overlay) => any); - + autoLockScrolling?: boolean; + show?: boolean; + transitionEnabled?: boolean; } - export class Overlay extends React.Component { + export class Overlay extends React.Component { } interface PaperProp extends React.Props { - ref?: string | ((component: Paper) => any); - + circle?: boolean; + rounded?: boolean; + transitionEnabled?: boolean; + zDepth?: number; } - export class Paper extends React.Component { + export class Paper extends React.Component { } interface RadioButtonProp extends CommonEnhancedSwitchProp { // is root element - ref?: string | ((component: RadioButton) => any); - defaultChecked?: boolean; iconStyle?: React.CSSProperties; label?: string; @@ -592,13 +646,13 @@ declare namespace __MaterialUI { labelPosition?: string; style?: React.CSSProperties; value?: string; + + onChane: (e: React.FormEvent, selected: string) => void; } - export class RadioButton extends React.Component { + export class RadioButton extends React.Component { } interface RadioButtonGroupProp extends React.Props { - ref?: string | ((component: RadioButtonGroup) => any); - defaultSelected?: string; labelPosition?: string; name: string; @@ -607,15 +661,13 @@ declare namespace __MaterialUI { onChange?: (e: React.FormEvent, selected: string) => void; } - export class RadioButtonGroup extends React.Component { + export class RadioButtonGroup extends React.Component { getSelectedValue(): string; setSelectedValue(newSelectionValue: string): void; clearValue(): void; } interface RaisedButtonProp extends SharedEnhancedButtonProp { - ref?: string | ((component: RaisedButton) => any); - className?: string; disabled?: boolean; label?: string; @@ -628,42 +680,46 @@ declare namespace __MaterialUI { disabledLabelColor?: string; fullWidth?: boolean; } - export class RaisedButton extends React.Component { + export class RaisedButton extends React.Component { } interface RefreshIndicatorProp extends React.Props { - ref?: string | ((component: RefreshIndicator) => any); - + left: number; + percentage?: number; + size?: number; + status?: string; + top: number; } - export class RefreshIndicator extends React.Component { + export class RefreshIndicator extends React.Component { } namespace Ripples { interface CircleRippleProp extends React.Props { - ref?: string | ((component: CircleRipple) => any); - + color?: string; + opacity?: number; } - export class CircleRipple extends React.Component { + export class CircleRipple extends React.Component { } interface FocusRippleProp extends React.Props { - ref?: string | ((component: FocusRipple) => any); - + color?: string; + innerStyle?: React.CSSProperties; + opacity?: number; + show?: boolean; } - export class FocusRipple extends React.Component { + export class FocusRipple extends React.Component { } interface TouchRippleProp extends React.Props { - ref?: string | ((component: TouchRipple) => any); - + centerRipple?: boolean; + color?: string; + opacity?: number; } - export class TouchRipple extends React.Component { + export class TouchRipple extends React.Component { } } interface SelectFieldProp extends React.Props { - ref?: string | ((component: SelectField) => any); - // passed to TextField errorStyle?: React.CSSProperties; errorText?: string; @@ -676,8 +732,8 @@ declare namespace __MaterialUI { displayMember?: string; valueMember?: string; autoWidth?: boolean; - menuItems?: Array<{ text: string, payload: string } | {}>; - menuItemStyle?: React.CSSProperties[]; + menuItems: Array<{ text: string, payload: string } | {}>; + menuItemStyle?: React.CSSProperties; selectedIndex?: number; underlineStyle?: React.CSSProperties; iconStyle?: React.CSSProperties; @@ -688,52 +744,60 @@ declare namespace __MaterialUI { value?: number; onChange?: (e: TouchTapEvent, selectedIndex: number, menuItem: any) => void; + onEnterKeyDown?: React.KeyboardEventHandler; // own properties selectFieldRoot?: string; + multiLine?: boolean; + type?: string; + rows?: number; + inputStyle?: React.CSSProperties; + autoWidth?: boolean; } - export class SelectField extends React.Component { + export class SelectField extends React.Component { } interface SliderProp extends React.Props { - ref?: string | ((component: Slider) => any); - + name: string; + defaultValue?: number; + description?: string; + error?: string; + max?: number; + min?: number; + required?: boolean; + step?: number; + value?: number; } - export class Slider extends React.Component { + export class Slider extends React.Component { } interface SvgIconProp extends React.Props { - ref?: string | ((component: SvgIcon) => any); - + color?: string; + hoverColor?: string; + viewBox?: string; } - export class SvgIcon extends React.Component { + export class SvgIcon extends React.Component { } interface NavigationMenuProp extends React.Props { - ref?: string | ((component: NavigationMenu) => any); - } - export class NavigationMenu extends React.Component { + export class NavigationMenu extends React.Component { } interface NavigationChevronLeftProp extends React.Props { - ref?: string | ((component: NavigationChevronLeft) => any); - } - export class NavigationChevronLeft extends React.Component { + export class NavigationChevronLeft extends React.Component { } interface NavigationChevronRightProp extends React.Props { - ref?: string | ((component: NavigationChevronRight) => any); - } - export class NavigationChevronRight extends React.Component { + export class NavigationChevronRight extends React.Component { } export namespace Styles { interface AutoPrefix { - all(styles: any): any; - set(style: any, key: string, value: string | number): void; + all(styles: React.CSSProperties): React.CSSProperties; + set(style: React.CSSProperties, key: string, value: string | number): void; single(key: string): string; singleHyphened(key: string): string; } @@ -893,24 +957,31 @@ declare namespace __MaterialUI { } } interface CustomTheme { + spacing?: Spacing; + contentFontFamily?: string; getPalette(): ThemePalette; getComponentThemes(palette: ThemePalette, spacing: Spacing): Theme; } export class ThemeManager { + static: boolean; spacing: Spacing; palette: ThemePalette; - component: any; + component: Theme; + contentFontFamily: string; + template: CustomTheme; types: { LIGHT: CustomTheme; DARK: CustomTheme; }; - getCurrentTheme(): CustomTheme; + getCurrentTheme(): ThemeManager; + setContentFontFamily(newContentFontFamily: string): void; setTheme(newTheme: CustomTheme): void; setSpacing(newSpacing: Spacing): void; setPalette(newPalette: ThemePalette): void; setComponentThemes(overrides: Theme): void; + setIsRtl(isRtl: boolean): void; } interface Transitions { @@ -921,7 +992,7 @@ declare namespace __MaterialUI { } export var Transitions: Transitions; - class TypographyClass { + interface Typography { textFullBlack:string; textDarkBlack: string; textLightBlack: string; @@ -937,107 +1008,147 @@ declare namespace __MaterialUI { fontStyleButtonFontSize: number; } - export var Typography: TypographyClass; + export var Typography: Typography; } interface SnackbarProp extends React.Props { - ref?: string | ((component: Snackbar) => any); - + message: string; + action?: string; + autoHideDuration?: number; + onActionTouchTap?: React.TouchEventHandler; + onShow?: Function; + onDismiss?: Function; + openOnMount?: boolean; } - export class Snackbar extends React.Component { + export class Snackbar extends React.Component { } namespace Tabs { interface TabProp extends React.Props { - ref?: string | ((component: Tab) => any); - label?: string; value?: string; - - onActive?: (tab: Tab) => void; + + handleTouchTap?: React.TouchEventHandler; + selected?: boolean; + width?: string; } - export class Tab extends React.Component { + export class Tab extends React.Component { } interface TabsProp extends React.Props { - ref?: string | ((component: Tabs) => any); - contentContainerStyle?: React.CSSProperties; initialSelectedIndex?: number; inkBarStyle?: React.CSSProperties; style?: React.CSSProperties; tabItemContainerStyle?: React.CSSProperties; + tabWidth?: number; value?: string | number; + onActive?: (tab: Tab) => void; onChange?: (value: string | number, e: React.FormEvent, tab: Tab) => void; } - export class Tabs extends React.Component { + export class Tabs extends React.Component { } } namespace Table { interface TableProp extends React.Props
{ - ref?: string | ((component: Table) => any); - + allRowsSelected?: boolean; + fixedFooter?: boolean; + fixedHeader?: boolean; + height?: string; + multiSelectable?: boolean; + onCellClick?: (row: number, column: number) => void; + onCellHover?: (row: number, column: number) => void; + onCellHoverExit?: (row: number, column: number) => void; + onRowHover?: (row: number) => void; + onRowHoverExit?: (row: number) => void; + onRowSelection?: (selectedRows: number[])=> void; + selectable?: boolean; } - export class Table extends React.Component { + export class Table extends React.Component { } interface TableBodyProp extends React.Props { - ref?: string | ((component: TableBody) => any); - + allRowsSelected?: boolean; + deselectOnClickaway?: boolean; + displayRowCheckbox?: boolean; + multiSelectable?: boolean; + onCellClick?: (row: number, column: number) => void; + onCellHover?: (row: number, column: number) => void; + onCellHoverExit?: (row: number, column: number) => void; + onRowHover?: (row: number) => void; + onRowHoverExit?: (row: number) => void; + onRowSelection?: (selectedRows: number[])=> void; + preScanRows?: boolean; + selectable?: boolean; + showRowHover?: boolean; + stripedRows?: boolean; } - export class TableBody extends React.Component { + export class TableBody extends React.Component { } interface TableFooterProp extends React.Props { - ref?: string | ((component: TableFooter) => any); - + adjustForCheckbox?: boolean; } - export class TableFooter extends React.Component { + export class TableFooter extends React.Component { } interface TableHeaderProp extends React.Props { - ref?: string | ((component: TableHeader) => any); - + adjustForCheckbox?: boolean; + displaySelectAll?: boolean; + enableSelectAll?: boolean; + onSelectAll?: (event: React.MouseEvent) => void;; + selectAllSelected?: boolean; } - export class TableHeader extends React.Component { + export class TableHeader extends React.Component { } interface TableHeaderColumnProp extends React.Props { - ref?: string | ((component: TableHeaderColumn) => any); - + columnNumber?: number; + onClick?: (e: React.MouseEvent, column: number): void;; + tooltip?: string; + tooltipStyle?: React.CSSProperties; } - export class TableHeaderColumn extends React.Component { + export class TableHeaderColumn extends React.Component { } interface TableRowProp extends React.Props { - ref?: string | ((component: TableRow) => any); - + displayBorder?: boolean; + hoverable?: boolean; + onCellClick?: (e: React.MouseEvent, row: number, column: number): void; + onCellHover?: (e: React.MouseEvent, row: number, column: number): void; + onCellHoverExit?: (e: React.MouseEvent, row: number, column: number): void; + onRowClick?: (e: React.MouseEvent, row: number): void; + onRowHover?: (e: React.MouseEvent, row: number): void; + onRowHoverExit?: (e: React.MouseEvent, row: number): void; + rowNumber?: number; + selectable?: boolean; + selected?: boolean; + striped?: boolean; } - export class TableRow extends React.Component { + export class TableRow extends React.Component { } interface TableRowColumnProp extends React.Props { - ref?: string | ((component: TableRowColumn) => any); - + columnNumber?: number; + hoverable?: boolean; + onHover?: (e: React.MouseEvent, column: number): void;; + onHoverExit?: (e: React.MouseEvent, column: number): void;; } - export class TableRowColumn extends React.Component { + export class TableRowColumn extends React.Component { } } interface ThemeProp extends React.Props { - ref?: string | ((component: Theme) => any); - theme: Styles.CustomTheme; } - export class Theme extends React.Component { + export class Theme extends React.Component { static theme(customTheme: Styles.CustomTheme):

(Component: React.ComponentClass

) => React.ComponentClass

; } interface ToggleProp extends CommonEnhancedSwitchProp { // is root element - ref?: string | ((component: Toggle) => any); elementStyle?: React.CSSProperties; labelStyle?: React.CSSProperties; @@ -1045,21 +1156,22 @@ declare namespace __MaterialUI { toggled?: boolean; defaultToggled?: boolean; } - export class Toggle extends React.Component { + export class Toggle extends React.Component { isToggled(): boolean; setToggled(newToggledValue: boolean): void; } interface TimePickerProp extends React.Props { - ref?: string | ((component: TimePicker) => any); - + defaultTime?: Date; + format?: string; + pedantic?: boolean; + onShow?: Function; + onDismiss?: Function; } - export class TimePicker extends React.Component { + export class TimePicker extends React.Component { } interface TextFieldProp extends React.Props { - ref?: string | ((component: TextField) => any); - errorStyle?: React.CSSProperties; errorText?: string; floatingLabelText?: string; @@ -1069,11 +1181,12 @@ declare namespace __MaterialUI { id?: string; inputStyle?: React.CSSProperties; multiLine?: boolean; - onEnterKeyDown?: () => void; + onEnterKeyDown?: React.KeyboardEventHandler; style?: React.CSSProperties; rows?: number, underlineStyle?: React.CSSProperties; underlineFocusStyle?: React.CSSProperties; + underlineDisabledStyle?: React.CSSProperties; type?: string; disabled?: boolean; @@ -1087,7 +1200,7 @@ declare namespace __MaterialUI { onFocus?: React.FocusEventHandler; onKeyDown?: React.KeyboardEventHandler; } - export class TextField extends React.Component { + export class TextField extends React.Component { blur(): void; clearValue(): void; focus(): void; @@ -1098,75 +1211,77 @@ declare namespace __MaterialUI { namespace Toolbar { interface ToolbarProp extends React.Props { - ref?: string | ((component: Toolbar) => any); - } - export class Toolbar extends React.Component { + export class Toolbar extends React.Component { } interface ToolbarGroupProp extends React.Props { - ref?: string | ((component: ToolbarGroup) => any); - + float?: string; } - export class ToolbarGroup extends React.Component { + export class ToolbarGroup extends React.Component { } interface ToolbarSeparatorProp extends React.Props { - ref?: string | ((component: ToolbarSeparator) => any); - } - export class ToolbarSeparator extends React.Component { + export class ToolbarSeparator extends React.Component { } interface ToolbarTitleProp extends React.Props { - ref?: string | ((component: ToolbarTitle) => any); - + text?: string; } - export class ToolbarTitle extends React.Component { + export class ToolbarTitle extends React.Component { } } interface TooltipProp extends React.Props { - ref?: string | ((component: Tooltip) => any); - + label: string; + show?: boolean; + touch?: boolean; + verticalPosition?: string; + horizontalPosition?: string; } - export class Tooltip extends React.Component { + export class Tooltip extends React.Component { } export namespace Utils { + interface ContrastLevel { + range: [number, number]; + color: string; + } interface ColorManipulator { - fade(color: string, amount: number): string; - darken(color: string, amount: number): string; - contrastRatio(background: string, foreground: string): string; - contrastRatioLevel(background: string, foreground: string): any; + fade(color: string, amount: string|number): string; + lighten(color: string, amount: string|number): string; + darken(color: string, amount: string|number): string; + contrastRatio(background: string, foreground: string): number; + contrastRatioLevel(background: string, foreground: string): ContrastLevel; } export var ColorManipulator: ColorManipulator; interface CssEvent { transitionEndEventName(): string; animationEndEventName(): string; - onTransitionEnd(el: Element, callback: (e: Event) => any): void; - onAnimationEnd(el: Element, callback: (e: Event) => any): void; + onTransitionEnd(el: Element, callback: () => void): void; + onAnimationEnd(el: Element, callback: () => void): void; } export var CssEvent: CssEvent; interface Dom { - isDescendant(parent: Element, child: Element): boolean; + isDescendant(parent: Node, child: Node): boolean; offset(el: Element): { top: number, left: number }; - getStyleAttributeAsNumber(el: Element, attr: string): number; + getStyleAttributeAsNumber(el: HTMLElement, attr: string): number; addClass(el: Element, className: string): void; removeClass(el: Element, className: string): void; hasClass(el: Element, className: string): boolean; toggleClass(el: Element, className: string): void; - forceRedraw(el: Element): void; - withoutTransition(el: Element, callback: () => any): void; + forceRedraw(el: HTMLElement): void; + withoutTransition(el: HTMLElement, callback: () => void): void; } export var Dom: Dom; interface Events { - once(el: Element, type: string, callback: (e: Event) => any): void; - on(el: Element, type: string, callback: (e: Event) => any): void; - off(el: Element, type: string, callback: (e: Event) => any): void; + once(el: Element, type: string, callback: EventListener): void; + on(el: Element, type: string, callback: EventListener): void; + off(el: Element, type: string, callback: EventListener): void; isKeyboard(e: Event): boolean; } export var Events: Events; @@ -1174,10 +1289,10 @@ declare namespace __MaterialUI { function Extend(base: T, override: S1): (T & S1); interface ImmutabilityHelper { - merge(base: {}, ...args: {}[]): any; - mergeItem(obj: {}, key: string, newValueObject: {}): any; - push(array: T[], obj: T): T[]; - shift(array: T[]): T[]; + merge(base: any, ...args: any[]): any; + mergeItem(obj: any, key: any, newValueObject: any: any; + push(array: any[], obj: any): any; + shift(array: any[]): any; } export var ImmutabilityHelper: ImmutabilityHelper; @@ -1211,7 +1326,7 @@ declare namespace __MaterialUI { export var UniqueId: UniqueId; interface Styles { - mergeAndPrefix(base: {}, ...args: {}[]): any; + mergeAndPrefix(base: any, ...args: any[]): React.CSSProperties; } export var Styles: Styles; } @@ -1219,11 +1334,9 @@ declare namespace __MaterialUI { // New menus available only through requiring directly to the end file namespace Menus { interface IconMenuProp extends React.Props { - ref?: string | ((component: IconMenu) => any); - closeOnItemTouchTap?: boolean; desktop?: boolean; - iconButtonElement?: React.ReactElement; + iconButtonElement: React.ReactElement; openDirection?: string; menuStyle?: React.CSSProperties; multiple?: boolean; @@ -1231,10 +1344,11 @@ declare namespace __MaterialUI { width?: string | number; touchTapCloseDelay?: number; + onKeyboardFocus?: React.FocusEventHandler; onItemTouchTap?: (e: TouchTapEvent, item: React.ReactElement) => void; onChange?: (e: React.FormEvent, value: string | Array) => void; } - export class IconMenu extends React.Component { + export class IconMenu extends React.Component { } interface MenuProp extends React.Props

{ From c3a4bd1aae40d1a1a42c4628610538b1edb033f1 Mon Sep 17 00:00:00 2001 From: "Ciuca, Alexandru" Date: Tue, 22 Sep 2015 17:39:21 +0300 Subject: [PATCH 068/146] Syntax fixes --- material-ui/material-ui.d.ts | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/material-ui/material-ui.d.ts b/material-ui/material-ui.d.ts index b57778864..3c582d924 100644 --- a/material-ui/material-ui.d.ts +++ b/material-ui/material-ui.d.ts @@ -129,7 +129,7 @@ declare namespace __MaterialUI { export class AppBar extends React.Component{ } - interface AppCanvasProp extends React.Prop { + interface AppCanvasProp extends React.Props { } export class AppCanvas extends React.Component { @@ -321,7 +321,7 @@ declare namespace __MaterialUI { mode?: string; onDismiss?: Function; //TODO: typeof e? - onChange?: (e: any, d: Date): void; + onChange?: (e: any, d: Date) => void; onFocus?: React.FocusEventHandler; onShow?: Function; onTouchTap?: React.TouchEventHandler; @@ -454,8 +454,6 @@ declare namespace __MaterialUI { secondary?: boolean; rippleColor?: string; style?: React.CSSProperties; - - onKeyboardFocus?: (e: React.KeyboardEvent, isKeyboardFocused: boolean) => void; } export class FlatButton extends React.Component { } @@ -593,8 +591,8 @@ declare namespace __MaterialUI { number?: string; data?: string; toggle?: boolean; - onTouchTap?: (e: React.MouseEvent, key: number): void; - onToggle?: (e: React.MouseEvent, key: number, toggled: boolean): void; + onTouchTap?: (e: React.MouseEvent, key: number) => void; + onToggle?: (e: React.MouseEvent, key: number, toggled: boolean) => void; selected?: boolean; active?: boolean; } @@ -752,7 +750,6 @@ declare namespace __MaterialUI { type?: string; rows?: number; inputStyle?: React.CSSProperties; - autoWidth?: boolean; } export class SelectField extends React.Component { } @@ -1098,7 +1095,7 @@ declare namespace __MaterialUI { adjustForCheckbox?: boolean; displaySelectAll?: boolean; enableSelectAll?: boolean; - onSelectAll?: (event: React.MouseEvent) => void;; + onSelectAll?: (event: React.MouseEvent) => void; selectAllSelected?: boolean; } export class TableHeader extends React.Component { @@ -1106,7 +1103,7 @@ declare namespace __MaterialUI { interface TableHeaderColumnProp extends React.Props { columnNumber?: number; - onClick?: (e: React.MouseEvent, column: number): void;; + onClick?: (e: React.MouseEvent, column: number) => void; tooltip?: string; tooltipStyle?: React.CSSProperties; } @@ -1116,12 +1113,12 @@ declare namespace __MaterialUI { interface TableRowProp extends React.Props { displayBorder?: boolean; hoverable?: boolean; - onCellClick?: (e: React.MouseEvent, row: number, column: number): void; - onCellHover?: (e: React.MouseEvent, row: number, column: number): void; - onCellHoverExit?: (e: React.MouseEvent, row: number, column: number): void; - onRowClick?: (e: React.MouseEvent, row: number): void; - onRowHover?: (e: React.MouseEvent, row: number): void; - onRowHoverExit?: (e: React.MouseEvent, row: number): void; + onCellClick?: (e: React.MouseEvent, row: number, column: number) => void; + onCellHover?: (e: React.MouseEvent, row: number, column: number) => void; + onCellHoverExit?: (e: React.MouseEvent, row: number, column: number) => void; + onRowClick?: (e: React.MouseEvent, row: number) => void; + onRowHover?: (e: React.MouseEvent, row: number) => void; + onRowHoverExit?: (e: React.MouseEvent, row: number) => void; rowNumber?: number; selectable?: boolean; selected?: boolean; @@ -1133,8 +1130,8 @@ declare namespace __MaterialUI { interface TableRowColumnProp extends React.Props { columnNumber?: number; hoverable?: boolean; - onHover?: (e: React.MouseEvent, column: number): void;; - onHoverExit?: (e: React.MouseEvent, column: number): void;; + onHover?: (e: React.MouseEvent, column: number) => void; + onHoverExit?: (e: React.MouseEvent, column: number) => void; } export class TableRowColumn extends React.Component { } @@ -1290,7 +1287,7 @@ declare namespace __MaterialUI { interface ImmutabilityHelper { merge(base: any, ...args: any[]): any; - mergeItem(obj: any, key: any, newValueObject: any: any; + mergeItem(obj: any, key: any, newValueObject: any): any; push(array: any[], obj: any): any; shift(array: any[]): any; } From 7d9da92919eacfa606d9db7ff88d7dc050fca043 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aldo=20Rom=C3=A1n=20Nure=C3=B1a?= Date: Tue, 22 Sep 2015 13:05:34 -0500 Subject: [PATCH 069/146] Bugfix ionic.d.ts Ionic typings will not compile due to syntax error. Fixed in this commit. --- ionic/ionic.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ionic/ionic.d.ts b/ionic/ionic.d.ts index b1b215217..1b2e3265e 100644 --- a/ionic/ionic.d.ts +++ b/ionic/ionic.d.ts @@ -205,7 +205,7 @@ declare module ionic { scrollBy(left: number, top: number, shouldAnimate?: boolean): void; zoomTo(level: number, animate?: boolean, originLeft?: number, originTop?: number): void; zoomBy(factor: number, animate?: boolean, originLeft?: number, originTop?: number): void; - getScrollPosition(): {left: number, top: number}; + getScrollPosition(): {left: number; top: number}; anchorScroll(shouldAnimate?: boolean): void; freezeScroll(shouldFreeze?: boolean): boolean; freezeAllScrolls(shouldFreeze?: boolean): boolean; From 56b5eef102426106de4bd383ff5abedf6a93523c Mon Sep 17 00:00:00 2001 From: Nathan Brown Date: Tue, 22 Sep 2015 13:48:49 -0700 Subject: [PATCH 070/146] Clean up pull-request, keep tests passing. --- material-ui/material-ui-tests.ts | 4 +- material-ui/material-ui-tests.tsx | 2 +- material-ui/material-ui.d.ts | 117 +++++++++++++++++++----------- 3 files changed, 78 insertions(+), 45 deletions(-) diff --git a/material-ui/material-ui-tests.ts b/material-ui/material-ui-tests.ts index 3b8b34702..25a8e8bbe 100644 --- a/material-ui/material-ui-tests.ts +++ b/material-ui/material-ui-tests.ts @@ -137,7 +137,7 @@ class MaterialUiTests extends React.Component<{}, {}> implements React.LinkedSta ]; element = React.createElement(Dialog, {"title": "Dialog With Custom Actions", "actions": customActions, "modal": false, "autoDetectWindowHeight": true, "autoScrollBodyContent": true}, "The actions in this window were passed in as an array of react objects."); // "http://material-ui.com/#/components/dropdown-menu" - var menuItems = [ + var menuItems: __MaterialUI.Menu.MenuItemRequest[] = [ { payload: '1', text: 'Never' }, { payload: '2', text: 'Every Night' }, { payload: '3', text: 'Weeknights' }, @@ -192,7 +192,7 @@ class MaterialUiTests extends React.Component<{}, {}> implements React.LinkedSta element = React.createElement(TextField, {"hintText": "Disabled Hint Text", "disabled": true}); element = React.createElement(TextField, {"hintText": "Disabled Hint Text", "disabled": true, "defaultValue": "Disabled With Value"}); //Select Fields - var arbitraryArrayMenuItems = [ + var arbitraryArrayMenuItems: __MaterialUI.Menu.MenuItemRequest[] = [ { id: 0, name: "zero", diff --git a/material-ui/material-ui-tests.tsx b/material-ui/material-ui-tests.tsx index accae0d71..aa95efc1e 100644 --- a/material-ui/material-ui-tests.tsx +++ b/material-ui/material-ui-tests.tsx @@ -69,7 +69,7 @@ class MaterialUiTests extends React.Component<{}, {}> implements React.LinkedSta let ThemeManager = new mui.Styles.ThemeManager(); ThemeManager.setTheme(ThemeManager.types.LIGHT); ThemeManager.setTheme(ThemeManager.types.DARK); - let muiTheme: __MaterialUI.Styles.CustomTheme = ThemeManager.getCurrentTheme(); + let muiTheme = ThemeManager.getCurrentTheme(); ThemeManager.setComponentThemes({ toggle: { thumbOnColor: "#00bcd4", diff --git a/material-ui/material-ui.d.ts b/material-ui/material-ui.d.ts index 3c582d924..662b6c606 100644 --- a/material-ui/material-ui.d.ts +++ b/material-ui/material-ui.d.ts @@ -72,10 +72,10 @@ declare module "material-ui" { export import TableHeaderColumn = __MaterialUI.Table.TableHeaderColumn; // require('material-ui/lib/table/table-header-column'); export import TableRow = __MaterialUI.Table.TableRow; // require('material-ui/lib/table/table-row'); export import TableRowColumn = __MaterialUI.Table.TableRowColumn; // require('material-ui/lib/table/table-row-column'); - export import TextField = __MaterialUI.TextField; // require('material-ui/lib/text-field'); export import Theme = __MaterialUI.Theme; // require('material-ui/lib/theme'); - export import TimePicker = __MaterialUI.TimePicker; // require('material-ui/lib/time-picker'); export import Toggle = __MaterialUI.Toggle; // require('material-ui/lib/toggle'); + export import TimePicker = __MaterialUI.TimePicker; // require('material-ui/lib/time-picker'); + export import TextField = __MaterialUI.TextField; // require('material-ui/lib/text-field'); export import Toolbar = __MaterialUI.Toolbar.Toolbar; // require('material-ui/lib/toolbar/toolbar'); export import ToolbarGroup = __MaterialUI.Toolbar.ToolbarGroup; // require('material-ui/lib/toolbar/toolbar-group'); export import ToolbarSeparator = __MaterialUI.Toolbar.ToolbarSeparator; // require('material-ui/lib/toolbar/toolbar-separator'); @@ -84,9 +84,9 @@ declare module "material-ui" { export import Utils = __MaterialUI.Utils; // require('material-ui/lib/utils/'); // export type definitions - export import DialogAction = __MaterialUI.DialogAction; export import TouchTapEvent = __MaterialUI.TouchTapEvent; export import TouchTapEventHandler = __MaterialUI.TouchTapEventHandler; + export import DialogAction = __MaterialUI.DialogAction; } declare namespace __MaterialUI { @@ -130,7 +130,6 @@ declare namespace __MaterialUI { } interface AppCanvasProp extends React.Props { - } export class AppCanvas extends React.Component { } @@ -164,7 +163,7 @@ declare namespace __MaterialUI { onExpandedChange?: (isExpanded: boolean) => void; style?: React.CSSProperties; } - export class Card extends React.Component { + export class Card extends React.Component { } interface CardActionsProp extends React.Props { @@ -319,11 +318,13 @@ declare namespace __MaterialUI { maxDate?: Date; minDate?: Date; mode?: string; - onDismiss?: Function; - //TODO: typeof e? + onDismiss?: () => void; + + // e is always null onChange?: (e: any, d: Date) => void; + onFocus?: React.FocusEventHandler; - onShow?: Function; + onShow?: () => void; onTouchTap?: React.TouchEventHandler; shouldDisableDate?: (day: Date) => boolean; showYearSelector?: boolean; @@ -338,9 +339,9 @@ declare namespace __MaterialUI { maxDate?: Date; minDate?: Date; onAccept?: (d: Date) => void; - onClickAway?: Function; - onDismiss?: Function; - onShow?: Function; + onClickAway?: () => void; + onDismiss?: () => void; + onShow?: () => void; shouldDisableDate?: (day: Date) => boolean; showYearSelector?: boolean; } @@ -369,9 +370,9 @@ declare namespace __MaterialUI { repositionOnUpdate?: boolean; title?: React.ReactNode; - onClickAway?: Function; - onDismiss?: Function; - onShow?: Function; + onClickAway?: () => void; + onDismiss?: () => void; + onShow?: () => void; } export class Dialog extends React.Component { dismiss(): void; @@ -379,12 +380,13 @@ declare namespace __MaterialUI { } interface DropDownIconProp extends React.Props { - onChange?: Menu.ChangeHandler; - menuItems: Menu.MenuItemProp[]; + menuItems: Menu.MenuItemRequest[]; closeOnMenuItemTouchTap?: boolean; iconStyle?: React.CSSProperties; iconClassName?: string; iconLigature?: string; + + onChange?: Menu.ItemTapEventHandler; } export class DropDownIcon extends React.Component { } @@ -393,7 +395,7 @@ declare namespace __MaterialUI { displayMember?: string; valueMember?: string; autoWidth?: boolean; - menuItems: Menu.MenuItemProp[]; + menuItems: Menu.MenuItemRequest[]; menuItemStyle?: React.CSSProperties; selectedIndex?: number; underlineStyle?: React.CSSProperties; @@ -404,7 +406,7 @@ declare namespace __MaterialUI { valueLink?: ReactLink; value?: number; - onChange?: Menu.ChangeHandler; + onChange?: Menu.ItemTapEventHandler; } export class DropDownMenu extends React.Component { } @@ -501,10 +503,10 @@ declare namespace __MaterialUI { disableSwipeToOpen?: boolean; docked?: boolean; header?: React.ReactElement; - menuItems: Menu.MenuItemProp[]; - onChange?: Menu.ChangeHandler; - onNavOpen?: Function; - onNavClose?: Function; + menuItems: Menu.MenuItemRequest[]; + onChange?: Menu.ItemTapEventHandler; + onNavOpen?: () => void; + onNavClose?: () => void; openRight?: Boolean; selectedIndex?: number; menuItemClassName?: string; @@ -565,17 +567,41 @@ declare namespace __MaterialUI { } } + // Old menu implementation. Being replaced by new "menus". namespace Menu { - interface ChangeHandler { - (e: TouchTapEvent, key: number, payload: MenuItemProp): void; + interface ItemTapEventHandler { + (e: TouchTapEvent, index: number, menuItem: MenuItemRequest): void; } + + // almost extends MenuItemProp, but certain required items are generated in Menu and not passed here. + interface MenuItemRequest extends React.Props { + // use value from MenuItem.Types.* + type?: string; + + text?: string; + data?: string; + payload?: string; + icon?: React.ReactElement; + attribute?: string; + number?: string; + toggle?: boolean; + onTouchTap?: TouchTapEventHandler; + isDisabled?: boolean; + + // for MenuItems.Types.NESTED + items?: MenuItemRequest[]; + + // for custom text or payloads + [propertyName: string]: any; + } + interface MenuProp extends React.Props { index: number; text?: string; - menuItems: MenuItemProp[]; + menuItems: MenuItemRequest[]; zDepth?: number; active?: boolean; - onItemTap?: ChangeHandler; + onItemTap?: ItemTapEventHandler; menuItemStyle?: React.CSSProperties; } export class Menu extends React.Component { @@ -583,6 +609,7 @@ declare namespace __MaterialUI { interface MenuItemProp extends React.Props { index: number; + icon?: React.ReactElement; iconClassName?: string; iconRightClassName?: string; iconStyle?: React.CSSProperties; @@ -597,6 +624,7 @@ declare namespace __MaterialUI { active?: boolean; } export class MenuItem extends React.Component { + static Types: { LINK: string, SUBHEADER: string, NESTED: string, } } } @@ -645,7 +673,7 @@ declare namespace __MaterialUI { style?: React.CSSProperties; value?: string; - onChane: (e: React.FormEvent, selected: string) => void; + onCheck?: (e: React.FormEvent, selected: string) => void; } export class RadioButton extends React.Component { } @@ -730,7 +758,7 @@ declare namespace __MaterialUI { displayMember?: string; valueMember?: string; autoWidth?: boolean; - menuItems: Array<{ text: string, payload: string } | {}>; + menuItems: Menu.MenuItemRequest[]; menuItemStyle?: React.CSSProperties; selectedIndex?: number; underlineStyle?: React.CSSProperties; @@ -741,7 +769,7 @@ declare namespace __MaterialUI { valueLink?: ReactLink; value?: number; - onChange?: (e: TouchTapEvent, selectedIndex: number, menuItem: any) => void; + onChange?: Menu.ItemTapEventHandler; onEnterKeyDown?: React.KeyboardEventHandler; // own properties @@ -1013,8 +1041,8 @@ declare namespace __MaterialUI { action?: string; autoHideDuration?: number; onActionTouchTap?: React.TouchEventHandler; - onShow?: Function; - onDismiss?: Function; + onShow?: () => void; + onDismiss?: () => void; openOnMount?: boolean; } export class Snackbar extends React.Component { @@ -1024,10 +1052,13 @@ declare namespace __MaterialUI { interface TabProp extends React.Props { label?: string; value?: string; - - handleTouchTap?: React.TouchEventHandler; selected?: boolean; width?: string; + + // Called by Tabs component + onActive?: (tab: Tab) => void; + + onTouchTap?: (value: string, e: TouchTapEvent, tab: Tab) => void; } export class Tab extends React.Component { } @@ -1041,7 +1072,6 @@ declare namespace __MaterialUI { tabWidth?: number; value?: string | number; - onActive?: (tab: Tab) => void; onChange?: (value: string | number, e: React.FormEvent, tab: Tab) => void; } export class Tabs extends React.Component { @@ -1162,8 +1192,11 @@ declare namespace __MaterialUI { defaultTime?: Date; format?: string; pedantic?: boolean; - onShow?: Function; - onDismiss?: Function; + onFocus?: React.FocusEventHandler; + onTouchTap?: TouchTapEventHandler; + onChange?: (e: any, time: Date) => void; + onShow?: () => void; + onDismiss?: () => void; } export class TimePicker extends React.Component { } @@ -1288,8 +1321,8 @@ declare namespace __MaterialUI { interface ImmutabilityHelper { merge(base: any, ...args: any[]): any; mergeItem(obj: any, key: any, newValueObject: any): any; - push(array: any[], obj: any): any; - shift(array: any[]): any; + push(array: any[], obj: any): any[]; + shift(array: any[]): any[]; } export var ImmutabilityHelper: ImmutabilityHelper; @@ -1360,7 +1393,7 @@ declare namespace __MaterialUI { width?: string | number; zDepth?: number; } - export class Menu extends React.Component{ + export class Menu extends React.Component{ } interface MenuItemProp extends React.Props { @@ -1372,21 +1405,21 @@ declare namespace __MaterialUI { leftIcon?: React.ReactElement; primaryText?: string | React.ReactElement; rightIcon?: React.ReactElement; - secondaryText?: string | React.ReactElement; + secondaryText?: React.ReactNode; value?: string; onEscKeyDown?: React.KeyboardEventHandler; onItemTouchTap?: (e: TouchTapEvent, item: React.ReactElement) => void; onChange?: (e: React.FormEvent, value: string) => void; } - export class MenuItem extends React.Component{ + export class MenuItem extends React.Component{ } interface MenuDividerProp extends React.Props { inset?: boolean; style?: React.CSSProperties; } - export class MenuDivider extends React.Component{ + export class MenuDivider extends React.Component{ } } } // __MaterialUI From 072817135e046c9893eb9db4b89a56f8962da338 Mon Sep 17 00:00:00 2001 From: Nathan Brown Date: Tue, 22 Sep 2015 14:20:53 -0700 Subject: [PATCH 071/146] Convert all *Prop to *Props. --- material-ui/material-ui-tests.ts | 6 +- material-ui/material-ui-tests.tsx | 4 +- material-ui/material-ui.d.ts | 288 +++++++++++++++--------------- 3 files changed, 149 insertions(+), 149 deletions(-) diff --git a/material-ui/material-ui-tests.ts b/material-ui/material-ui-tests.ts index 25a8e8bbe..7df5f5960 100644 --- a/material-ui/material-ui-tests.ts +++ b/material-ui/material-ui-tests.ts @@ -8,7 +8,7 @@ // a. Find "var element;" and change to "let element: React.ReactElement;". // b. Replace "this.linkState(" with "this.linkState(". // c. Add generic type help for the Component Property to the remaining errors on -// React.createElement, for example, add "<__MaterialUI.DialogProp>". +// React.createElement, for example, add "<__MaterialUI.DialogProps>". /// /// @@ -129,7 +129,7 @@ class MaterialUiTests extends React.Component<{}, {}> implements React.LinkedSta { text: 'Cancel' }, { text: 'Submit', onTouchTap: this.touchTapEventHandler, ref: 'submit' } ]; - element = React.createElement<__MaterialUI.DialogProp>(Dialog, {"title": "Dialog With Standard Actions", "actions": standardActions, "actionFocus": "submit", "modal": true}, "The actions in this window are created from the json that's passed in."); + element = React.createElement<__MaterialUI.DialogProps>(Dialog, {"title": "Dialog With Standard Actions", "actions": standardActions, "actionFocus": "submit", "modal": true}, "The actions in this window are created from the json that's passed in."); //Custom Actions var customActions = [ React.createElement(FlatButton, {"label": "Cancel", "secondary": true, "onTouchTap": this.touchTapEventHandler}), @@ -170,7 +170,7 @@ class MaterialUiTests extends React.Component<{}, {}> implements React.LinkedSta // "http://material-ui.com/#/components/switches" element = React.createElement(Checkbox, {"name": "checkboxName2", "value": "checkboxValue2", "label": "fed the dog", "defaultChecked": true}); element = React.createElement(Checkbox, {"name": "checkboxName3", "value": "checkboxValue3", "label": "built a house on the moon", "disabled": true}); - element = React.createElement<__MaterialUI.CheckboxProp>(Checkbox, {"name": "checkboxName4", "value": "checkboxValue4", "checkedIcon": React.createElement(ToggleStar, null), "unCheckedIcon": React.createElement(ToggleStarBorder, null), "label": "custom icon"}); + element = React.createElement<__MaterialUI.CheckboxProps>(Checkbox, {"name": "checkboxName4", "value": "checkboxValue4", "checkedIcon": React.createElement(ToggleStar, null), "unCheckedIcon": React.createElement(ToggleStarBorder, null), "label": "custom icon"}); element = React.createElement(RadioButtonGroup, {"name": "shipSpeed", "defaultSelected": "not_light"}, React.createElement(RadioButton, {"value": "light", "label": "prepare for light speed", "style": { marginBottom: 16 }}), ";", React.createElement(RadioButton, {"value": "not_light", "label": "light speed too slow", "style": { marginBottom: 16 }}), ";", React.createElement(RadioButton, {"value": "ludicrous", "label": "go to ludicrous speed", "style": { marginBottom: 16 }, "disabled": true})); element = React.createElement(Toggle, {"name": "toggleName1", "value": "toggleValue1", "label": "activate thrusters"}); element = React.createElement(Toggle, {"name": "toggleName2", "value": "toggleValue2", "label": "auto-pilot", "defaultToggled": true}); diff --git a/material-ui/material-ui-tests.tsx b/material-ui/material-ui-tests.tsx index aa95efc1e..fb32aac5e 100644 --- a/material-ui/material-ui-tests.tsx +++ b/material-ui/material-ui-tests.tsx @@ -8,7 +8,7 @@ // a. Find "var element;" and change to "let element: React.ReactElement;". // b. Replace "this.linkState(" with "this.linkState(". // c. Add generic type help for the Component Property to the remaining errors on -// React.createElement, for example, add "<__MaterialUI.DialogProp>". +// React.createElement, for example, add "<__MaterialUI.DialogProps>". /// /// @@ -92,7 +92,7 @@ class MaterialUiTests extends React.Component<{}, {}> implements React.LinkedSta iconStyle={{ fill: '#FF4081' }}/> - element = React.createElement<__MaterialUI.CheckboxProp>(Checkbox, { + element = React.createElement<__MaterialUI.CheckboxProps>(Checkbox, { id: "checkboxId1", name: "checkboxName1", value: "checkboxValue1", label: "went for a run today", style: { width: '50%', margin: '0 auto' diff --git a/material-ui/material-ui.d.ts b/material-ui/material-ui.d.ts index 662b6c606..c5c37ee91 100644 --- a/material-ui/material-ui.d.ts +++ b/material-ui/material-ui.d.ts @@ -112,7 +112,7 @@ declare namespace __MaterialUI { // more specific than React.HTMLAttributes - interface AppBarProp extends React.Props { + interface AppBarProps extends React.Props { iconClassNameLeft?: string; iconClassNameRight?: string; iconElementLeft?: React.ReactElement; @@ -126,15 +126,15 @@ declare namespace __MaterialUI { onLeftIconButtonTouchTap?: TouchTapEventHandler; onRightIconButtonTouchTap?: TouchTapEventHandler; } - export class AppBar extends React.Component{ + export class AppBar extends React.Component{ } - interface AppCanvasProp extends React.Props { + interface AppCanvasProps extends React.Props { } - export class AppCanvas extends React.Component { + export class AppCanvas extends React.Component { } - interface AvatarProp extends React.Props { + interface AvatarProps extends React.Props { icon?: React.ReactElement; backgroundColor?: string; color?: string; @@ -142,45 +142,45 @@ declare namespace __MaterialUI { src?: string; style?: React.CSSProperties; } - export class Avatar extends React.Component { + export class Avatar extends React.Component { } - interface BeforeAfterWrapperProp extends React.Props { + interface BeforeAfterWrapperProps extends React.Props { beforeStyle?: React.CSSProperties; afterStyle?: React.CSSProperties; beforeElementType?: string; afterElementType?: string; elementType?: string; } - export class BeforeAfterWrapper extends React.Component { + export class BeforeAfterWrapper extends React.Component { } namespace Card { - interface CardProp extends React.Props { + interface CardProps extends React.Props { expandable?: boolean; initiallyExpanded?: boolean; onExpandedChange?: (isExpanded: boolean) => void; style?: React.CSSProperties; } - export class Card extends React.Component { + export class Card extends React.Component { } - interface CardActionsProp extends React.Props { + interface CardActionsProps extends React.Props { expandable?: boolean; showExpandableButton?: boolean; } - export class CardActions extends React.Component { + export class CardActions extends React.Component { } - interface CardExpandableProp extends React.Props { + interface CardExpandableProps extends React.Props { onExpanding?: (isExpanded: boolean) => void; expanded?: boolean; } - export class CardExpandable extends React.Component { + export class CardExpandable extends React.Component { } - interface CardHeaderProp extends React.Props { + interface CardHeaderProps extends React.Props { expandable?: boolean; showExpandableButton?: boolean; title?: string | React.ReactElement; @@ -193,10 +193,10 @@ declare namespace __MaterialUI { style?: React.CSSProperties; avatar: React.ReactElement | string; } - export class CardHeader extends React.Component { + export class CardHeader extends React.Component { } - interface CardMediaProp extends React.Props { + interface CardMediaProps extends React.Props { expandable?: boolean; overlay?: React.ReactNode; overlayStyle?: React.CSSProperties; @@ -205,18 +205,18 @@ declare namespace __MaterialUI { mediaStyle?: React.CSSProperties; style?: React.CSSProperties; } - export class CardMedia extends React.Component { + export class CardMedia extends React.Component { } - interface CardTextProp extends React.Props { + interface CardTextProps extends React.Props { expandable?: boolean; color?: string; style?: React.CSSProperties; } - export class CardText extends React.Component { + export class CardText extends React.Component { } - interface CardTitleProp extends React.Props { + interface CardTitleProps extends React.Props { expandable?: boolean; showExpandableButton?: boolean; title?: string | React.ReactElement; @@ -228,12 +228,12 @@ declare namespace __MaterialUI { textStyle?: React.CSSProperties; style?: React.CSSProperties; } - export class CardTitle extends React.Component { + export class CardTitle extends React.Component { } } // what's not commonly overridden by Checkbox, RadioButton, or Toggle - interface CommonEnhancedSwitchProp extends React.HTMLAttributesBase { + interface CommonEnhancedSwitchProps extends React.HTMLAttributesBase { // is root element id?: string; iconStyle?: React.CSSProperties; @@ -251,7 +251,7 @@ declare namespace __MaterialUI { disableTouchRipple?: boolean; } - interface EnhancedSwitchProp extends CommonEnhancedSwitchProp { + interface EnhancedSwitchProps extends CommonEnhancedSwitchProps { // is root element inputType: string; switchElement: React.ReactElement; @@ -261,14 +261,14 @@ declare namespace __MaterialUI { onSwitch?: (e: React.MouseEvent, isInputChecked: boolean) => void; labelPosition?: string; } - export class EnhancedSwitch extends React.Component { + export class EnhancedSwitch extends React.Component { isSwitched(): boolean; setSwitched(newSwitchedValue: boolean): void; getValue(): any; isKeyboardFocused(): boolean; } - interface CheckboxProp extends CommonEnhancedSwitchProp { + interface CheckboxProps extends CommonEnhancedSwitchProps { // is root element checkedIcon?: React.ReactElement<{ style?: React.CSSProperties }>; // Normally an SvgIcon defaultChecked?: boolean; @@ -286,12 +286,12 @@ declare namespace __MaterialUI { onCheck?: (event: React.MouseEvent, checked: boolean) => void; } - export class Checkbox extends React.Component { + export class Checkbox extends React.Component { isChecked(): void; setChecked(newCheckedValue: boolean): void; } - interface CircularProgressProp extends React.Props { + interface CircularProgressProps extends React.Props { mode?: string; value?: number; min?: number; @@ -301,16 +301,16 @@ declare namespace __MaterialUI { innerStyle?: React.CSSProperties; } - export class CircularProgress extends React.Component { + export class CircularProgress extends React.Component { } - interface ClearFixProp extends React.Props { + interface ClearFixProps extends React.Props { } - export class ClearFix extends React.Component { + export class ClearFix extends React.Component { } namespace DatePicker { - interface DatePickerProp extends React.Props { + interface DatePickerProps extends React.Props { autoOk?: boolean; defaultDate?: Date; formatDate?: string; @@ -330,10 +330,10 @@ declare namespace __MaterialUI { showYearSelector?: boolean; textFieldStyle?: React.CSSProperties; } - export class DatePicker extends React.Component { + export class DatePicker extends React.Component { } - interface DatePickerDialogProp extends React.Props { + interface DatePickerDialogProps extends React.Props { disableYearSelection?: boolean; initialDate?: Date; maxDate?: Date; @@ -345,7 +345,7 @@ declare namespace __MaterialUI { shouldDisableDate?: (day: Date) => boolean; showYearSelector?: boolean; } - export class DatePickerDialog extends React.Component { + export class DatePickerDialog extends React.Component { } } @@ -356,7 +356,7 @@ declare namespace __MaterialUI { onTouchTap?: TouchTapEventHandler; onClick?: React.MouseEventHandler; } - interface DialogProp extends React.Props { + interface DialogProps extends React.Props { actions?: Array>; actionFocus?: string; autoDetectWindowHeight?: boolean; @@ -374,12 +374,12 @@ declare namespace __MaterialUI { onDismiss?: () => void; onShow?: () => void; } - export class Dialog extends React.Component { + export class Dialog extends React.Component { dismiss(): void; show(): void; } - interface DropDownIconProp extends React.Props { + interface DropDownIconProps extends React.Props { menuItems: Menu.MenuItemRequest[]; closeOnMenuItemTouchTap?: boolean; iconStyle?: React.CSSProperties; @@ -388,10 +388,10 @@ declare namespace __MaterialUI { onChange?: Menu.ItemTapEventHandler; } - export class DropDownIcon extends React.Component { + export class DropDownIcon extends React.Component { } - interface DropDownMenuProp extends React.Props { + interface DropDownMenuProps extends React.Props { displayMember?: string; valueMember?: string; autoWidth?: boolean; @@ -408,11 +408,11 @@ declare namespace __MaterialUI { onChange?: Menu.ItemTapEventHandler; } - export class DropDownMenu extends React.Component { + export class DropDownMenu extends React.Component { } // non generally overridden elements of EnhancedButton - interface SharedEnhancedButtonProp extends React.HTMLAttributesBase { + interface SharedEnhancedButtonProps extends React.HTMLAttributesBase { centerRipple?: boolean; containerElement?: string | React.ReactElement; disabled?: boolean; @@ -438,15 +438,15 @@ declare namespace __MaterialUI { onTouchTap?: TouchTapEventHandler; } - interface EnhancedButtonProp extends SharedEnhancedButtonProp { + interface EnhancedButtonProps extends SharedEnhancedButtonProps { touchRippleColor?: string; focusRippleColor?: string; style?: React.CSSProperties; } - export class EnhancedButton extends React.Component { + export class EnhancedButton extends React.Component { } - interface FlatButtonProp extends SharedEnhancedButtonProp { + interface FlatButtonProps extends SharedEnhancedButtonProps { hoverColor?: string; label?: string; labelPosition?: string; @@ -457,10 +457,10 @@ declare namespace __MaterialUI { rippleColor?: string; style?: React.CSSProperties; } - export class FlatButton extends React.Component { + export class FlatButton extends React.Component { } - interface FloatingActionButtonProp extends SharedEnhancedButtonProp { + interface FloatingActionButtonProps extends SharedEnhancedButtonProps { backgroundColor?: string; disabled?: boolean; disabledColor?: string; @@ -470,10 +470,10 @@ declare namespace __MaterialUI { secondary?: boolean; style?: React.CSSProperties; } - export class FloatingActionButton extends React.Component { + export class FloatingActionButton extends React.Component { } - interface FontIconProp extends React.Props { + interface FontIconProps extends React.Props { color?: string; hoverColor?: string; onMouseLeave?: React.MouseEventHandler; @@ -481,10 +481,10 @@ declare namespace __MaterialUI { style?: React.CSSProperties; className?: string; } - export class FontIcon extends React.Component { + export class FontIcon extends React.Component { } - interface IconButtonProp extends SharedEnhancedButtonProp { + interface IconButtonProps extends SharedEnhancedButtonProps { iconClassName?: string; iconStyle?: React.CSSProperties; style?: React.CSSProperties; @@ -496,10 +496,10 @@ declare namespace __MaterialUI { onBlur?: React.FocusEventHandler; onFocus?: React.FocusEventHandler; } - export class IconButton extends React.Component { + export class IconButton extends React.Component { } - interface LeftNavProp extends React.Props { + interface LeftNavProps extends React.Props { disableSwipeToOpen?: boolean; docked?: boolean; header?: React.ReactElement; @@ -513,35 +513,35 @@ declare namespace __MaterialUI { menuItemClassNameSubheader?: string; menuItemClassNameLink?: string; } - export class LeftNav extends React.Component { + export class LeftNav extends React.Component { } - interface LinearProgressProp extends React.Props { + interface LinearProgressProps extends React.Props { mode?: string; value?: number; min?: number; max?: number; } - export class LinearProgress extends React.Component { + export class LinearProgress extends React.Component { } namespace Lists { - interface ListProp extends React.Props { + interface ListProps extends React.Props { insetSubheader?: boolean; subheader?: string; subheaderStyle?: React.CSSProperties; zDepth?: number; } - export class List extends React.Component { + export class List extends React.Component { } - interface ListDividerProp extends React.Props { + interface ListDividerProps extends React.Props { inset?: boolean; } - export class ListDivider extends React.Component { + export class ListDivider extends React.Component { } - interface ListItemProp extends React.Props { + interface ListItemProps extends React.Props { autoGenerateNestedIndicator?: boolean; disableKeyboardFocus?: boolean; initiallyOpen?: boolean; @@ -563,7 +563,7 @@ declare namespace __MaterialUI { secondaryText?: React.ReactNode; secondaryTextLines?: number; } - export class ListItem extends React.Component { + export class ListItem extends React.Component { } } @@ -573,7 +573,7 @@ declare namespace __MaterialUI { (e: TouchTapEvent, index: number, menuItem: MenuItemRequest): void; } - // almost extends MenuItemProp, but certain required items are generated in Menu and not passed here. + // almost extends MenuItemProps, but certain required items are generated in Menu and not passed here. interface MenuItemRequest extends React.Props { // use value from MenuItem.Types.* type?: string; @@ -595,7 +595,7 @@ declare namespace __MaterialUI { [propertyName: string]: any; } - interface MenuProp extends React.Props { + interface MenuProps extends React.Props { index: number; text?: string; menuItems: MenuItemRequest[]; @@ -604,10 +604,10 @@ declare namespace __MaterialUI { onItemTap?: ItemTapEventHandler; menuItemStyle?: React.CSSProperties; } - export class Menu extends React.Component { + export class Menu extends React.Component { } - interface MenuItemProp extends React.Props { + interface MenuItemProps extends React.Props { index: number; icon?: React.ReactElement; iconClassName?: string; @@ -623,7 +623,7 @@ declare namespace __MaterialUI { selected?: boolean; active?: boolean; } - export class MenuItem extends React.Component { + export class MenuItem extends React.Component { static Types: { LINK: string, SUBHEADER: string, NESTED: string, } } } @@ -646,24 +646,24 @@ declare namespace __MaterialUI { var StyleResizable: StyleResizable } - interface OverlayProp extends React.Props { + interface OverlayProps extends React.Props { autoLockScrolling?: boolean; show?: boolean; transitionEnabled?: boolean; } - export class Overlay extends React.Component { + export class Overlay extends React.Component { } - interface PaperProp extends React.Props { + interface PaperProps extends React.Props { circle?: boolean; rounded?: boolean; transitionEnabled?: boolean; zDepth?: number; } - export class Paper extends React.Component { + export class Paper extends React.Component { } - interface RadioButtonProp extends CommonEnhancedSwitchProp { + interface RadioButtonProps extends CommonEnhancedSwitchProps { // is root element defaultChecked?: boolean; iconStyle?: React.CSSProperties; @@ -675,10 +675,10 @@ declare namespace __MaterialUI { onCheck?: (e: React.FormEvent, selected: string) => void; } - export class RadioButton extends React.Component { + export class RadioButton extends React.Component { } - interface RadioButtonGroupProp extends React.Props { + interface RadioButtonGroupProps extends React.Props { defaultSelected?: string; labelPosition?: string; name: string; @@ -687,13 +687,13 @@ declare namespace __MaterialUI { onChange?: (e: React.FormEvent, selected: string) => void; } - export class RadioButtonGroup extends React.Component { + export class RadioButtonGroup extends React.Component { getSelectedValue(): string; setSelectedValue(newSelectionValue: string): void; clearValue(): void; } - interface RaisedButtonProp extends SharedEnhancedButtonProp { + interface RaisedButtonProps extends SharedEnhancedButtonProps { className?: string; disabled?: boolean; label?: string; @@ -706,46 +706,46 @@ declare namespace __MaterialUI { disabledLabelColor?: string; fullWidth?: boolean; } - export class RaisedButton extends React.Component { + export class RaisedButton extends React.Component { } - interface RefreshIndicatorProp extends React.Props { + interface RefreshIndicatorProps extends React.Props { left: number; percentage?: number; size?: number; status?: string; top: number; } - export class RefreshIndicator extends React.Component { + export class RefreshIndicator extends React.Component { } namespace Ripples { - interface CircleRippleProp extends React.Props { + interface CircleRippleProps extends React.Props { color?: string; opacity?: number; } - export class CircleRipple extends React.Component { + export class CircleRipple extends React.Component { } - interface FocusRippleProp extends React.Props { + interface FocusRippleProps extends React.Props { color?: string; innerStyle?: React.CSSProperties; opacity?: number; show?: boolean; } - export class FocusRipple extends React.Component { + export class FocusRipple extends React.Component { } - interface TouchRippleProp extends React.Props { + interface TouchRippleProps extends React.Props { centerRipple?: boolean; color?: string; opacity?: number; } - export class TouchRipple extends React.Component { + export class TouchRipple extends React.Component { } } - interface SelectFieldProp extends React.Props { + interface SelectFieldProps extends React.Props { // passed to TextField errorStyle?: React.CSSProperties; errorText?: string; @@ -779,10 +779,10 @@ declare namespace __MaterialUI { rows?: number; inputStyle?: React.CSSProperties; } - export class SelectField extends React.Component { + export class SelectField extends React.Component { } - interface SliderProp extends React.Props { + interface SliderProps extends React.Props { name: string; defaultValue?: number; description?: string; @@ -793,30 +793,30 @@ declare namespace __MaterialUI { step?: number; value?: number; } - export class Slider extends React.Component { + export class Slider extends React.Component { } - interface SvgIconProp extends React.Props { + interface SvgIconProps extends React.Props { color?: string; hoverColor?: string; viewBox?: string; } - export class SvgIcon extends React.Component { + export class SvgIcon extends React.Component { } - interface NavigationMenuProp extends React.Props { + interface NavigationMenuProps extends React.Props { } - export class NavigationMenu extends React.Component { + export class NavigationMenu extends React.Component { } - interface NavigationChevronLeftProp extends React.Props { + interface NavigationChevronLeftProps extends React.Props { } - export class NavigationChevronLeft extends React.Component { + export class NavigationChevronLeft extends React.Component { } - interface NavigationChevronRightProp extends React.Props { + interface NavigationChevronRightProps extends React.Props { } - export class NavigationChevronRight extends React.Component { + export class NavigationChevronRight extends React.Component { } export namespace Styles { @@ -1036,7 +1036,7 @@ declare namespace __MaterialUI { export var Typography: Typography; } - interface SnackbarProp extends React.Props { + interface SnackbarProps extends React.Props { message: string; action?: string; autoHideDuration?: number; @@ -1045,11 +1045,11 @@ declare namespace __MaterialUI { onDismiss?: () => void; openOnMount?: boolean; } - export class Snackbar extends React.Component { + export class Snackbar extends React.Component { } namespace Tabs { - interface TabProp extends React.Props { + interface TabProps extends React.Props { label?: string; value?: string; selected?: boolean; @@ -1060,10 +1060,10 @@ declare namespace __MaterialUI { onTouchTap?: (value: string, e: TouchTapEvent, tab: Tab) => void; } - export class Tab extends React.Component { + export class Tab extends React.Component { } - interface TabsProp extends React.Props { + interface TabsProps extends React.Props { contentContainerStyle?: React.CSSProperties; initialSelectedIndex?: number; inkBarStyle?: React.CSSProperties; @@ -1074,12 +1074,12 @@ declare namespace __MaterialUI { onChange?: (value: string | number, e: React.FormEvent, tab: Tab) => void; } - export class Tabs extends React.Component { + export class Tabs extends React.Component { } } namespace Table { - interface TableProp extends React.Props
{ + interface TableProps extends React.Props
{ allRowsSelected?: boolean; fixedFooter?: boolean; fixedHeader?: boolean; @@ -1093,10 +1093,10 @@ declare namespace __MaterialUI { onRowSelection?: (selectedRows: number[])=> void; selectable?: boolean; } - export class Table extends React.Component { + export class Table extends React.Component { } - interface TableBodyProp extends React.Props { + interface TableBodyProps extends React.Props { allRowsSelected?: boolean; deselectOnClickaway?: boolean; displayRowCheckbox?: boolean; @@ -1112,35 +1112,35 @@ declare namespace __MaterialUI { showRowHover?: boolean; stripedRows?: boolean; } - export class TableBody extends React.Component { + export class TableBody extends React.Component { } - interface TableFooterProp extends React.Props { + interface TableFooterProps extends React.Props { adjustForCheckbox?: boolean; } - export class TableFooter extends React.Component { + export class TableFooter extends React.Component { } - interface TableHeaderProp extends React.Props { + interface TableHeaderProps extends React.Props { adjustForCheckbox?: boolean; displaySelectAll?: boolean; enableSelectAll?: boolean; onSelectAll?: (event: React.MouseEvent) => void; selectAllSelected?: boolean; } - export class TableHeader extends React.Component { + export class TableHeader extends React.Component { } - interface TableHeaderColumnProp extends React.Props { + interface TableHeaderColumnProps extends React.Props { columnNumber?: number; onClick?: (e: React.MouseEvent, column: number) => void; tooltip?: string; tooltipStyle?: React.CSSProperties; } - export class TableHeaderColumn extends React.Component { + export class TableHeaderColumn extends React.Component { } - interface TableRowProp extends React.Props { + interface TableRowProps extends React.Props { displayBorder?: boolean; hoverable?: boolean; onCellClick?: (e: React.MouseEvent, row: number, column: number) => void; @@ -1154,27 +1154,27 @@ declare namespace __MaterialUI { selected?: boolean; striped?: boolean; } - export class TableRow extends React.Component { + export class TableRow extends React.Component { } - interface TableRowColumnProp extends React.Props { + interface TableRowColumnProps extends React.Props { columnNumber?: number; hoverable?: boolean; onHover?: (e: React.MouseEvent, column: number) => void; onHoverExit?: (e: React.MouseEvent, column: number) => void; } - export class TableRowColumn extends React.Component { + export class TableRowColumn extends React.Component { } } - interface ThemeProp extends React.Props { + interface ThemeProps extends React.Props { theme: Styles.CustomTheme; } - export class Theme extends React.Component { + export class Theme extends React.Component { static theme(customTheme: Styles.CustomTheme):

(Component: React.ComponentClass

) => React.ComponentClass

; } - interface ToggleProp extends CommonEnhancedSwitchProp { + interface ToggleProps extends CommonEnhancedSwitchProps { // is root element elementStyle?: React.CSSProperties; @@ -1183,12 +1183,12 @@ declare namespace __MaterialUI { toggled?: boolean; defaultToggled?: boolean; } - export class Toggle extends React.Component { + export class Toggle extends React.Component { isToggled(): boolean; setToggled(newToggledValue: boolean): void; } - interface TimePickerProp extends React.Props { + interface TimePickerProps extends React.Props { defaultTime?: Date; format?: string; pedantic?: boolean; @@ -1198,10 +1198,10 @@ declare namespace __MaterialUI { onShow?: () => void; onDismiss?: () => void; } - export class TimePicker extends React.Component { + export class TimePicker extends React.Component { } - interface TextFieldProp extends React.Props { + interface TextFieldProps extends React.Props { errorStyle?: React.CSSProperties; errorText?: string; floatingLabelText?: string; @@ -1230,7 +1230,7 @@ declare namespace __MaterialUI { onFocus?: React.FocusEventHandler; onKeyDown?: React.KeyboardEventHandler; } - export class TextField extends React.Component { + export class TextField extends React.Component { blur(): void; clearValue(): void; focus(): void; @@ -1240,37 +1240,37 @@ declare namespace __MaterialUI { } namespace Toolbar { - interface ToolbarProp extends React.Props { + interface ToolbarProps extends React.Props { } - export class Toolbar extends React.Component { + export class Toolbar extends React.Component { } - interface ToolbarGroupProp extends React.Props { + interface ToolbarGroupProps extends React.Props { float?: string; } - export class ToolbarGroup extends React.Component { + export class ToolbarGroup extends React.Component { } - interface ToolbarSeparatorProp extends React.Props { + interface ToolbarSeparatorProps extends React.Props { } - export class ToolbarSeparator extends React.Component { + export class ToolbarSeparator extends React.Component { } - interface ToolbarTitleProp extends React.Props { + interface ToolbarTitleProps extends React.Props { text?: string; } - export class ToolbarTitle extends React.Component { + export class ToolbarTitle extends React.Component { } } - interface TooltipProp extends React.Props { + interface TooltipProps extends React.Props { label: string; show?: boolean; touch?: boolean; verticalPosition?: string; horizontalPosition?: string; } - export class Tooltip extends React.Component { + export class Tooltip extends React.Component { } export namespace Utils { @@ -1363,10 +1363,10 @@ declare namespace __MaterialUI { // New menus available only through requiring directly to the end file namespace Menus { - interface IconMenuProp extends React.Props { + interface IconMenuProps extends React.Props { closeOnItemTouchTap?: boolean; desktop?: boolean; - iconButtonElement: React.ReactElement; + iconButtonElement: React.ReactElement; openDirection?: string; menuStyle?: React.CSSProperties; multiple?: boolean; @@ -1378,10 +1378,10 @@ declare namespace __MaterialUI { onItemTouchTap?: (e: TouchTapEvent, item: React.ReactElement) => void; onChange?: (e: React.FormEvent, value: string | Array) => void; } - export class IconMenu extends React.Component { + export class IconMenu extends React.Component { } - interface MenuProp extends React.Props

{ + interface MenuProps extends React.Props { animated?: boolean; autoWidth?: boolean; desktop?: boolean; @@ -1393,10 +1393,10 @@ declare namespace __MaterialUI { width?: string | number; zDepth?: number; } - export class Menu extends React.Component{ + export class Menu extends React.Component{ } - interface MenuItemProp extends React.Props { + interface MenuItemProps extends React.Props { checked?: boolean; desktop?: boolean; disabled?: boolean; @@ -1412,14 +1412,14 @@ declare namespace __MaterialUI { onItemTouchTap?: (e: TouchTapEvent, item: React.ReactElement) => void; onChange?: (e: React.FormEvent, value: string) => void; } - export class MenuItem extends React.Component{ + export class MenuItem extends React.Component{ } - interface MenuDividerProp extends React.Props { + interface MenuDividerProps extends React.Props { inset?: boolean; style?: React.CSSProperties; } - export class MenuDivider extends React.Component{ + export class MenuDivider extends React.Component{ } } } // __MaterialUI From 575688ac47132a364a99d8c6ca7fed979e94ada8 Mon Sep 17 00:00:00 2001 From: Nathan Brown Date: Tue, 22 Sep 2015 15:17:41 -0700 Subject: [PATCH 072/146] Now that .TSX files are tested, remove redundant .TS file. --- material-ui/material-ui-tests.ts | 220 ------------------------------ material-ui/material-ui-tests.tsx | 12 -- 2 files changed, 232 deletions(-) delete mode 100644 material-ui/material-ui-tests.ts diff --git a/material-ui/material-ui-tests.ts b/material-ui/material-ui-tests.ts deleted file mode 100644 index 7df5f5960..000000000 --- a/material-ui/material-ui-tests.ts +++ /dev/null @@ -1,220 +0,0 @@ -// This tests React components, so it is most natural to write the test as a .TSX file, -// however the DefinitelyTyped test runner only accepts .TS files. To convert: -// 1. Save in Visual Studio or otherwise use TSC to save as a "material-ui-tests.js" file. -// 2. Copy the "material-ui-tests.tsx" file to "material-ui-tests.ts". -// 3. Copy the body of "MaterialUiTests.prototype.render = function ()" in "material-ui-tsets.js" -// and replace the body of render() in "material-ui-tests.ts". -// 4. Correct some missing information: -// a. Find "var element;" and change to "let element: React.ReactElement;". -// b. Replace "this.linkState(" with "this.linkState(". -// c. Add generic type help for the Component Property to the remaining errors on -// React.createElement, for example, add "<__MaterialUI.DialogProps>". - -/// -/// - -import * as React from "react/addons"; -import mui = require("material-ui"); -import Colors = require("material-ui/lib/styles/colors"); -import AppBar = require("material-ui/lib/app-bar"); -import IconButton = require("material-ui/lib/icon-button"); -import FlatButton = require("material-ui/lib/flat-button"); -import Avatar = require("material-ui/lib/avatar"); -import FontIcon = require("material-ui/lib/font-icon"); -import Typography = require("material-ui/lib/styles/typography"); -import RaisedButton = require("material-ui/lib/raised-button"); -import FloatingActionButton = require("material-ui/lib/floating-action-button"); -import Card = require("material-ui/lib/card/card"); -import CardHeader = require("material-ui/lib/card/card-header"); -import CardText = require("material-ui/lib/card/card-text"); -import CardActions = require("material-ui/lib/card/card-actions"); -import Dialog = require("material-ui/lib/dialog"); -import DropDownMenu = require("material-ui/lib/drop-down-menu"); -import RadioButtonGroup = require("material-ui/lib/radio-button-group"); -import RadioButton = require("material-ui/lib/radio-button"); -import Toggle = require("material-ui/lib/toggle"); -import TextField = require("material-ui/lib/text-field"); -import SelectField = require("material-ui/lib/select-field"); -import IconMenu = require("material-ui/lib/menus/icon-menu"); -import Menu = require('material-ui/lib/menus/menu'); -import MenuItem = require('material-ui/lib/menus/menu-item'); -import MenuDivider = require('material-ui/lib/menus/menu-divider'); - -import NavigationClose = require("material-ui/lib/svg-icon"); // TODO: Should actually import the actual "material-ui/lib/svg-icons/navigation/close", but they aren't defined yet. -import FileFolder = require("material-ui/lib/svg-icon"); // TODO: Should actually import the actual "material-ui/lib/svg-icons/file/folder", but they aren't defined yet. -import ToggleStar = require("material-ui/lib/svg-icon"); // TODO: Should actually import the actual "material-ui/lib/svg-icons/toggle/star", but they aren't defined yet. -import ActionGrade = require("material-ui/lib/svg-icon"); // TODO: Should actually import the actual "material-ui/lib/svg-icons/action/grade", but they aren't defined yet. -import ToggleStarBorder = require("material-ui/lib/svg-icon"); // TODO: Should actually import the actual "material-ui/lib/svg-icons/toggle/star-border", but they aren't defined yet. -import ArrowDropRight = require("material-ui/lib/svg-icon"); // TODO: Should actually import the actual "material-ui/lib/svg-icons/toggle/star-border", but they aren't defined yet. - -class MaterialUiTests extends React.Component<{}, {}> implements React.LinkedStateMixin { - - // injected with mixin - linkState: (key: string) => React.ReactLink; - dialog: mui.Dialog; - //dialog2: Dialog; // can't get type directly from require("material-ui/lib/dialog"); - - private touchTapEventHandler(e: __MaterialUI.TouchTapEvent) { - this.dialog.show(); - //this.dialog2.show(); - } - private formEventHandler(e: React.FormEvent) { - } - private selectFieldChangeHandler(e: __MaterialUI.TouchTapEvent, si: number, mi: any) { - } - - render() { - // "http://material-ui.com/#/customization/themes" - var ThemeManager = new mui.Styles.ThemeManager(); - ThemeManager.setTheme(ThemeManager.types.LIGHT); - ThemeManager.setTheme(ThemeManager.types.DARK); - var muiTheme = ThemeManager.getCurrentTheme(); - ThemeManager.setComponentThemes({ - toggle: { - thumbOnColor: "#00bcd4", - trackOnColor: "LightCyan", - } - }); - // "http://material-ui.com/#/customization/inline-styles" - var Checkbox = mui.Checkbox; - let element: React.ReactElement; - element = React.createElement(Checkbox, {"id": "checkboxId1", "name": "checkboxName1", "value": "checkboxValue1", "label": "went for a run today", "style": { - width: '50%', - margin: '0 auto' - }, "iconStyle": { - fill: '#FF4081' - }}); - element = React.createElement(Checkbox, { - id: "checkboxId1", name: "checkboxName1", value: "checkboxValue1", label: "went for a run today", style: { - width: '50%', - margin: '0 auto' - }, iconStyle: { - fill: '#FF4081' - } - }); - // "http://material-ui.com/#/customization/colors" - ThemeManager.setComponentThemes({ - toggle: { - thumbOnColor: Colors.cyan200, - thumbOffColor: Colors.grey400, - } - }); - // "http://material-ui.com/#/components/appbar" - element = React.createElement(AppBar, {"title": "Title", "iconClassNameRight": "muidocs-icon-navigation-expand-more"}); - element = React.createElement(AppBar, {"title": "Title", "iconElementLeft": React.createElement(IconButton, null, React.createElement(NavigationClose, null)), "iconElementRight": React.createElement(FlatButton, {"label": "Save"})}); - // "http://material-ui.com/#/components/avatars" - //image avatar - element = React.createElement(Avatar, {"src": "images/uxceo-128.jpg"}); - //SvgIcon avatar - element = React.createElement(Avatar, {"icon": React.createElement(FileFolder, null)}); - //SvgIcon avatar with custom colors - element = React.createElement(Avatar, {"icon": React.createElement(FileFolder, null), "color": Colors.orange200, "backgroundColor": Colors.pink400}); - //FontIcon avatar - element = React.createElement(Avatar, {"icon": React.createElement(FontIcon, {"className": "muidocs-icon-communication-voicemail"})}); - //FontIcon avatar with custom colors - element = React.createElement(Avatar, {"icon": React.createElement(FontIcon, {"className": "muidocs-icon-communication-voicemail"}), "color": Colors.blue300, "backgroundColor": Colors.indigo900}); - //Letter avatar - element = React.createElement(Avatar, null, "A"); - //Letter avatar with custom colors - element = React.createElement(Avatar, {"color": Colors.deepOrange300, "backgroundColor": Colors.purple500}); - // "http://material-ui.com/#/components/buttons" - element = React.createElement(FlatButton, {"linkButton": true, "href": "https://github.com/callemall/material-ui", "secondary": true, "label": "GitHub"}, React.createElement(FontIcon, {"style": { color: Typography.textFullWhite }, "className": "muidocs-icon-custom-github"})); - element = React.createElement(RaisedButton, {"linkButton": true, "href": "https://github.com/callemall/material-ui", "secondary": true, "label": "GitHub"}, React.createElement(FontIcon, {"style": { color: Typography.textFullWhite }, "className": "muidocs-icon-custom-github"})); - element = React.createElement(FloatingActionButton, {"secondary": true, "mini": true, "linkButton": true, "href": "https://github.com/callemall/material-ui"}, React.createElement(ToggleStar, null)); - // "http://material-ui.com/#/components/cards" - element = React.createElement(Card, {"initiallyExpanded": true}, React.createElement(CardHeader, {"title": "Title", "subtitle": "Subtitle", "avatar": React.createElement(Avatar, {"style": { color: 'red' }}, "A"), "showExpandableButton": true}), React.createElement(CardText, {"expandable": true}, "Lorem ipsum dolor sit amet, consectetur adipiscing elit."), React.createElement(CardActions, {"expandable": true}, React.createElement(FlatButton, {"label": "Action1"}), React.createElement(FlatButton, {"label": "Action2"})), React.createElement(CardText, {"expandable": true}, "Lorem ipsum dolor sit amet, consectetur adipiscing elit.")); - // "http://material-ui.com/#/components/date-picker" - // "http://material-ui.com/#/components/dialog" - var standardActions = [ - { text: 'Cancel' }, - { text: 'Submit', onTouchTap: this.touchTapEventHandler, ref: 'submit' } - ]; - element = React.createElement<__MaterialUI.DialogProps>(Dialog, {"title": "Dialog With Standard Actions", "actions": standardActions, "actionFocus": "submit", "modal": true}, "The actions in this window are created from the json that's passed in."); - //Custom Actions - var customActions = [ - React.createElement(FlatButton, {"label": "Cancel", "secondary": true, "onTouchTap": this.touchTapEventHandler}), - React.createElement(FlatButton, {"label": "Submit", "primary": true, "onTouchTap": this.touchTapEventHandler}) - ]; - element = React.createElement(Dialog, {"title": "Dialog With Custom Actions", "actions": customActions, "modal": false, "autoDetectWindowHeight": true, "autoScrollBodyContent": true}, "The actions in this window were passed in as an array of react objects."); - // "http://material-ui.com/#/components/dropdown-menu" - var menuItems: __MaterialUI.Menu.MenuItemRequest[] = [ - { payload: '1', text: 'Never' }, - { payload: '2', text: 'Every Night' }, - { payload: '3', text: 'Weeknights' }, - { payload: '4', text: 'Weekends' }, - { payload: '5', text: 'Weekly' }, - ]; - element = React.createElement(DropDownMenu, {"menuItems": menuItems}); - // "http://material-ui.com/#/components/icons" - element = React.createElement(FontIcon, {"className": "material-icons", "color": Colors.red500}, " home"); - // "http://material-ui.com/#/components/icon-buttons" - //Method 1: muidocs-icon-github is defined in a style sheet. - element = React.createElement(IconButton, {"iconClassName": "muidocs-icon-custom-github", "tooltip": "GitHub"}); - //Method 2: ActionGrade is a component created using mui.SvgIcon. - element = React.createElement(IconButton, {"tooltip": "Star", "touch": true}, React.createElement(ActionGrade, null)); - //Method 3: Manually creating a mui.FontIcon component within IconButton - element = React.createElement(IconButton, {"tooltip": "Sort", "disabled": true}, React.createElement(FontIcon, {"className": "muidocs-icon-custom-sort"})); - //Method 4: Using Google material-icons - element = React.createElement(IconButton, {"iconClassName": "material-icons", "tooltipPosition": "bottom-center", "tooltip": "Sky"}, "settings_system_daydream"); - // "http://material-ui.com/#/components/icon-menus" - element = React.createElement(IconMenu, {"iconButtonElement": React.createElement(IconButton, null)}, React.createElement(MenuItem, {"primaryText": "Refresh"}), React.createElement(MenuItem, {"primaryText": "Send feedback"}), React.createElement(MenuItem, {"primaryText": "Settings"}), React.createElement(MenuItem, {"primaryText": "Help"}), React.createElement(MenuItem, {"primaryText": "Sign out"})); - // "http://material-ui.com/#/components/left-nav" - // "http://material-ui.com/#/components/lists" - // "http://material-ui.com/#/components/menus" - element = React.createElement(Menu, null, React.createElement(MenuItem, {"primaryText": "Maps"}), React.createElement(MenuItem, {"primaryText": "Books"}), React.createElement(MenuItem, {"primaryText": "Flights"}), React.createElement(MenuItem, {"primaryText": "Apps"})); - element = React.createElement(Menu, {"desktop": true, "width": 320}, React.createElement(MenuItem, {"primaryText": "Bold", "secondaryText": "⌘B"}), React.createElement(MenuItem, {"primaryText": "Italic", "secondaryText": "⌘I"}), React.createElement(MenuItem, {"primaryText": "Underline", "secondaryText": "⌘U"}), React.createElement(MenuItem, {"primaryText": "Strikethrough", "secondaryText": "Alt+Shift+5"}), React.createElement(MenuItem, {"primaryText": "Superscript", "secondaryText": "⌘."}), React.createElement(MenuItem, {"primaryText": "Subscript", "secondaryText": "⌘,"}), React.createElement(MenuDivider, null), React.createElement(MenuItem, {"primaryText": "Paragraph styles", "rightIcon": React.createElement(ArrowDropRight, null)}), React.createElement(MenuItem, {"primaryText": "Align", "rightIcon": React.createElement(ArrowDropRight, null)}), React.createElement(MenuItem, {"primaryText": "Line spacing", "rightIcon": React.createElement(ArrowDropRight, null)}), React.createElement(MenuItem, {"primaryText": "Numbered list", "rightIcon": React.createElement(ArrowDropRight, null)}), React.createElement(MenuItem, {"primaryText": "List options", "rightIcon": React.createElement(ArrowDropRight, null)}), React.createElement(MenuDivider, null), React.createElement(MenuItem, {"primaryText": "Clear formatting", "secondaryText": "⌘/"})); - // "http://material-ui.com/#/components/paper" - // "http://material-ui.com/#/components/progress" - // "http://material-ui.com/#/components/refresh-indicator" - // "http://material-ui.com/#/components/sliders" - // "http://material-ui.com/#/components/switches" - element = React.createElement(Checkbox, {"name": "checkboxName2", "value": "checkboxValue2", "label": "fed the dog", "defaultChecked": true}); - element = React.createElement(Checkbox, {"name": "checkboxName3", "value": "checkboxValue3", "label": "built a house on the moon", "disabled": true}); - element = React.createElement<__MaterialUI.CheckboxProps>(Checkbox, {"name": "checkboxName4", "value": "checkboxValue4", "checkedIcon": React.createElement(ToggleStar, null), "unCheckedIcon": React.createElement(ToggleStarBorder, null), "label": "custom icon"}); - element = React.createElement(RadioButtonGroup, {"name": "shipSpeed", "defaultSelected": "not_light"}, React.createElement(RadioButton, {"value": "light", "label": "prepare for light speed", "style": { marginBottom: 16 }}), ";", React.createElement(RadioButton, {"value": "not_light", "label": "light speed too slow", "style": { marginBottom: 16 }}), ";", React.createElement(RadioButton, {"value": "ludicrous", "label": "go to ludicrous speed", "style": { marginBottom: 16 }, "disabled": true})); - element = React.createElement(Toggle, {"name": "toggleName1", "value": "toggleValue1", "label": "activate thrusters"}); - element = React.createElement(Toggle, {"name": "toggleName2", "value": "toggleValue2", "label": "auto-pilot", "defaultToggled": true}); - element = React.createElement(Toggle, {"name": "toggleName3", "value": "toggleValue3", "label": "initiate self-destruct sequence", "disabled": true}); - // "http://material-ui.com/#/components/snackbar" - // "http://material-ui.com/#/components/table" - // "http://material-ui.com/#/components/tabs" - // "http://material-ui.com/#/components/text-fields" - element = React.createElement(TextField, {"hintText": "Hint Text"}); - element = React.createElement(TextField, {"hintText": "Hint Text", "defaultValue": "Default Value"}); - element = React.createElement(TextField, {"hintText": "Hint Text", "value": "value", "underlineStyle": { borderColor: Colors.green500 }, "onChange": this.formEventHandler}); - element = React.createElement(TextField, {"hintText": "Custom Underline Focus Color", "underlineFocusStyle": { borderColor: Colors.amber900 }}); - element = React.createElement(TextField, {"hintText": "Hint Text", "valueLink": this.linkState('valueLinkValue')}); - element = React.createElement(TextField, {"hintText": "Hint Text (MultiLine)", "multiLine": true}); - element = React.createElement(TextField, {"hintText": "The hint text can be as long as you want, it will wrap.", "multiLine": true}); - element = React.createElement(TextField, {"hintText": "Hint Text", "errorText": "The error text can be as long as you want, it will wrap."}); - element = React.createElement(TextField, {"hintText": "Hint Text", "errorText": "error text", "onChange": this.formEventHandler}); - element = React.createElement(TextField, {"hintText": "Hint Text (custom error color)", "errorText": "error text", "errorStyle": { color: 'orange' }, "onChange": this.formEventHandler, "defaultValue": "Custom error color"}); - element = React.createElement(TextField, {"hintText": "Disabled Hint Text", "disabled": true}); - element = React.createElement(TextField, {"hintText": "Disabled Hint Text", "disabled": true, "defaultValue": "Disabled With Value"}); - //Select Fields - var arbitraryArrayMenuItems: __MaterialUI.Menu.MenuItemRequest[] = [ - { - id: 0, - name: "zero", - }, - ]; - element = React.createElement(SelectField, {"value": 0, "onChange": this.selectFieldChangeHandler, "hintText": "Hint Text", "menuItems": menuItems}); - element = React.createElement(SelectField, {"valueLink": this.linkState('selectValueLinkValue'), "floatingLabelText": "Float Label Text", "valueMember": "id", "displayMember": "name", "menuItems": arbitraryArrayMenuItems}); - element = React.createElement(SelectField, {"valueLink": this.linkState('selectValueLinkValue2'), "floatingLabelText": "Float Custom Label Text", "floatingLabelStyle": { color: "red" }, "valueMember": "id", "displayMember": "name", "menuItems": arbitraryArrayMenuItems}); - element = React.createElement(SelectField, {"value": 0, "onChange": this.selectFieldChangeHandler, "menuItems": arbitraryArrayMenuItems}); - //Floating Hint Text Labels - element = React.createElement(TextField, {"hintText": "Hint Text", "floatingLabelText": "Floating Label Text"}); - element = React.createElement(TextField, {"hintText": "Hint Text", "defaultValue": "Default Value", "floatingLabelText": "Floating Label Text"}); - element = React.createElement(TextField, {"hintText": "Hint Text", "floatingLabelText": "Floating Label Text", "value": "value", "onChange": this.formEventHandler}); - element = React.createElement(TextField, {"hintText": "Hint Text", "floatingLabelText": "Floating Label Text", "valueLink": this.linkState('floatingValueLinkValue')}); - element = React.createElement(TextField, {"hintText": "Hint Text (MultiLine)", "floatingLabelText": "Floating Label Text", "multiLine": true}); - element = React.createElement(TextField, {"hintText": "Hint Text", "errorText": "floating text", "floatingLabelText": "Floating Label Text", "onChange": this.formEventHandler}); - element = React.createElement(TextField, {"hintText": "Hint Text", "errorText": "error text", "defaultValue": "abc", "floatingLabelText": "Floating Label Text", "onChange": this.formEventHandler}); - element = React.createElement(TextField, {"hintText": "Disabled Hint Text", "disabled": true, "floatingLabelText": "Floating Label Text"}); - element = React.createElement(TextField, {"hintText": "Disabled Hint Text", "disabled": true, "defaultValue": "Disabled With Value", "floatingLabelText": "Floating Label Text"}); - element = React.createElement(TextField, {"hintText": "Password Field", "floatingLabelText": "Password", "type": "password"}); - // "http://material-ui.com/#/components/time-picker" - // "http://material-ui.com/#/components/toolbars" - return element; - } -} \ No newline at end of file diff --git a/material-ui/material-ui-tests.tsx b/material-ui/material-ui-tests.tsx index fb32aac5e..eed734d95 100644 --- a/material-ui/material-ui-tests.tsx +++ b/material-ui/material-ui-tests.tsx @@ -1,15 +1,3 @@ -// This tests React components, so it is most natural to write the test as a .TSX file, -// however the DefinitelyTyped test runner only accepts .TS files. To convert: -// 1. Save in Visual Studio or otherwise use TSC to save as a "material-ui-tests.js" file. -// 2. Copy the "material-ui-tests.tsx" file to "material-ui-tests.ts". -// 3. Copy the body of "MaterialUiTests.prototype.render = function ()" in "material-ui-tsets.js" -// and replace the body of render() in "material-ui-tests.ts". -// 4. Correct some missing information: -// a. Find "var element;" and change to "let element: React.ReactElement;". -// b. Replace "this.linkState(" with "this.linkState(". -// c. Add generic type help for the Component Property to the remaining errors on -// React.createElement, for example, add "<__MaterialUI.DialogProps>". - /// /// From 73d4a4660b3cf57cacb22629f1c6260273f6ebad Mon Sep 17 00:00:00 2001 From: hansrwindhoff Date: Tue, 22 Sep 2015 22:02:13 -0600 Subject: [PATCH 073/146] Update node.d.ts --- node/node.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/node/node.d.ts b/node/node.d.ts index 7498e401f..2dfa0fc2b 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -1772,6 +1772,7 @@ declare module "util" { export function isDate(object: any): boolean; export function isError(object: any): boolean; export function inherits(constructor: any, superConstructor: any): void; + export function debuglog(key:string): (msg:string,...param: any[])=>void; } declare module "assert" { From 67e5a7613cf81cc50aa844473c9b84f3bf3502cd Mon Sep 17 00:00:00 2001 From: rushi216 Date: Wed, 23 Sep 2015 10:23:51 +0530 Subject: [PATCH 074/146] added height, toolbarlocation, readonly properties in config object --- ckeditor/ckeditor.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ckeditor/ckeditor.d.ts b/ckeditor/ckeditor.d.ts index 37e609484..a8f268074 100644 --- a/ckeditor/ckeditor.d.ts +++ b/ckeditor/ckeditor.d.ts @@ -573,6 +573,9 @@ declare module CKEDITOR { startupFocus?: boolean; on?: any; extraPlugins?: string; + height?: string | number; + toolbarLocation?: string; + readOnly?: boolean; } From 4087da1722026728c2741331b8fe57337cbb9a4b Mon Sep 17 00:00:00 2001 From: Adam Roderick Date: Tue, 22 Sep 2015 23:11:07 -0600 Subject: [PATCH 075/146] Update diff.d.ts JsDiff can now diff javascript objects with the "diffJson" function. --- diff/diff.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/diff/diff.d.ts b/diff/diff.d.ts index 9ccbb10a8..f5c2cc48f 100644 --- a/diff/diff.d.ts +++ b/diff/diff.d.ts @@ -39,6 +39,8 @@ declare module JsDiff { function diffWordsWithSpace(oldStr:string, newStr:string):IDiffResult[]; + function diffJson(oldObj: Object, newObj: Object): IDiffResult[]; + function diffLines(oldStr:string, newStr:string):IDiffResult[]; function diffCss(oldStr:string, newStr:string):IDiffResult[]; From 6268433bd9d984fd544e1d2a05d5f77074fb747b Mon Sep 17 00:00:00 2001 From: Sixin Li Date: Wed, 23 Sep 2015 03:03:15 -0400 Subject: [PATCH 076/146] add configuration typing for matchBrackets addon --- codemirror/codemirror-matchbrackets-tests.ts | 4 ++++ codemirror/codemirror-matchbrackets.d.ts | 13 +++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 codemirror/codemirror-matchbrackets-tests.ts create mode 100644 codemirror/codemirror-matchbrackets.d.ts diff --git a/codemirror/codemirror-matchbrackets-tests.ts b/codemirror/codemirror-matchbrackets-tests.ts new file mode 100644 index 000000000..2189612c0 --- /dev/null +++ b/codemirror/codemirror-matchbrackets-tests.ts @@ -0,0 +1,4 @@ +/// +/// + +var myCodeMirror: CodeMirror.Editor = CodeMirror(document.body, { matchBrackets: true }); diff --git a/codemirror/codemirror-matchbrackets.d.ts b/codemirror/codemirror-matchbrackets.d.ts new file mode 100644 index 000000000..13241a5a3 --- /dev/null +++ b/codemirror/codemirror-matchbrackets.d.ts @@ -0,0 +1,13 @@ +// Type definitions for CodeMirror +// Project: https://github.com/marijnh/CodeMirror +// Definitions by: Sixin Li +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// See docs https://codemirror.net/doc/manual.html#addon_matchbrackets + +declare module CodeMirror { + interface EditorConfiguration { + // when set to true, causes matching brackets to be highlighted whenever the cursor is next to them + matchBrackets?: boolean; + } +} From 4ed63e242a5ec3f714e9eb0cad5fad5573e21ac8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Nguyen?= Date: Wed, 23 Sep 2015 09:51:38 +0200 Subject: [PATCH 077/146] Added definitions and tests for DocumentDB Server Side JavaScript SDK Test samples taken from: - http://dl.windowsazure.com/documentDB/jsserverdocs/Collection.html - https://github.com/Azure/azure-documentdb-js-server/tree/master/samples --- documentdb-server/documentdb-server-tests.ts | 1016 ++++++++++++++++++ documentdb-server/documentdb-server.d.ts | 541 ++++++++++ 2 files changed, 1557 insertions(+) create mode 100644 documentdb-server/documentdb-server-tests.ts create mode 100644 documentdb-server/documentdb-server.d.ts diff --git a/documentdb-server/documentdb-server-tests.ts b/documentdb-server/documentdb-server-tests.ts new file mode 100644 index 000000000..722fdbec5 --- /dev/null +++ b/documentdb-server/documentdb-server-tests.ts @@ -0,0 +1,1016 @@ +/// + +// Samples taken from http://dl.windowsazure.com/documentDB/jsserverdocs/Collection.html +function chain() { + var name: string = "John"; + var result: IQueryResponse = __.chain() + .filter(function (doc: any) { return doc.name == name; }) + .map(function (doc: any) { return { name: doc.name, age: doc.age }; }) + .value(); + if (!result.isAccepted) throw new Error("The call was not accepted"); +} +function filter() { + // Example 1: get documents(people) with age < 30. + var result: IQueryResponse = __.filter(function (doc: any) { return doc.age < 30; }); + if (!result.isAccepted) throw new Error("The call was not accepted"); + // Example 2: get documents (people) with age < 30 and select only name. + var result: IQueryResponse = __.chain() + .filter(function (doc: any) { return doc.age < 30; }) + .pluck("name") + .value(); + if (!result.isAccepted) throw new Error("The call was not accepted"); + // Example 3: get document (person) with id = 1 and delete it. + var result: IQueryResponse = __.filter(function (doc: any) { return doc.id === 1; }, function (err: IFeedCallbackError, feed: Array, options: IFeedCallbackOptions) { + if (err) throw err; + if (!__.deleteDocument(feed[0].getSelfLink())) throw new Error("deleteDocument was not accepted"); + }); + if (!result.isAccepted) throw new Error("The call was not accepted"); +} +function flatten() { + // Get documents (people) with age < 30, select tags (an array property) + // and flatten the result into one array for all documents. + var result: IQueryResponse = __.chain() + .filter(function (doc: any) { return doc.age < 30; }) + .map(function (doc: any) { return doc.tags; }) + .flatten() + .value(); + if (!result.isAccepted) throw new Error("The call was not accepted"); +} +function map() { + // Example 1: select only name and age for each document (person). + var result: IQueryResponse = __.map(function (doc: any) { return { name: doc.name, age: doc.age }; }); + if (!result.isAccepted) throw new Error("The call was not accepted"); + // Example 2: select name and age for each document (person), and return only people with age < 30. + var result: IQueryResponse = __.chain() + .map(function (doc: any) { return { name: doc.name, age: doc.age }; }) + .filter(function (doc: any) { return doc.age < 30; }) + .value(); + if (!result.isAccepted) throw new Error("The call was not accepted"); +} +function pluck() { + // Get documents (people) with age < 30 and select only name. + var result: IQueryResponse = __.chain() + .filter(function (doc: any) { return doc.age < 30; }) + .pluck("name") + .value(); + if (!result.isAccepted) throw new Error("The call was not accepted"); +} +function sortBy() { + // Example 1: sort documents (people) by age + var result: IQueryResponse = __.sortBy(function (doc: any) { return doc.age; }) + if (!result.isAccepted) throw new Error("The call was not accepted"); + // Example 2: sortBy in a chain by name + var result: IQueryResponse = __.chain() + .filter(function (doc: any) { return doc.age < 30; }) + .sortBy(function (doc: any) { return doc.name; }) + .value(); + if (!result.isAccepted) throw new Error("The call was not accepted"); +} +function sortByDescending() { + // Example 1: sort documents (people) by age in descending order + var result: IQueryResponse = __.sortByDescending(function (doc: any) { return doc.age; }) + if (!result.isAccepted) throw new Error("The call was not accepted"); + // Example 2: sortBy in a chain by name in descending order + var result: IQueryResponse = __.chain() + .filter(function (doc: any) { return doc.age < 30; }) + .sortByDescending(function (doc: any) { return doc.name; }) + .value(); + if (!result.isAccepted) throw new Error("The call was not accepted"); +} +function value() { + // Example 1: use defaults: the result goes to the response body. + var result: IQueryResponse = __.chain() + .filter(function (doc: any) { return doc.name == "John"; }) + .pluck("age") + .value(); + if (!result.isAccepted) throw new Error("The call was not accepted"); + // Example 2: use options and callback. + function usingOptionsAndCallback (continuationToken: string) { + var result = __.chain() + .filter(function (doc: any) { return doc.name == "John"; }) + .pluck("age") + .value({ continuation: continuationToken }, function (err: IFeedCallbackError, feed: Array, options: IFeedCallbackOptions) { + if (err) throw err; + __.response.setBody({ + result: feed, + continuation: options.continuation + }); + }); + if (!result.isAccepted) throw new Error("The call was not accepted"); + } +} + +// Samples taken from https://github.com/Azure/azure-documentdb-js-server/tree/master/samples +/** +* This script called as stored procedure to import lots of documents in one batch. +* The script sets response body to the number of docs imported and is called multiple times +* by the client until total number of docs desired by the client is imported. +* @param {Object[]} docs - Array of documents to import. +*/ +function bulkImport(docs: Array) { + var collection: ICollection = getContext().getCollection(); + var collectionLink: string = collection.getSelfLink(); + + // The count of imported docs, also used as current doc index. + var count: number = 0; + + // Validate input. + if (!docs) throw new Error("The array is undefined or null."); + + var docsLength: number = docs.length; + if (docsLength == 0) { + getContext().getResponse().setBody(0); + return; + } + + // Call the CRUD API to create a document. + tryCreate(docs[count], callback); + + // Note that there are 2 exit conditions: + // 1) The createDocument request was not accepted. + // In this case the callback will not be called, we just call setBody and we are done. + // 2) The callback was called docs.length times. + // In this case all documents were created and we don't need to call tryCreate anymore. Just call setBody and we are done. + function tryCreate(doc: Object, callback: (err: IRequestCallbackError, doc: Object, options: IRequestCallbackOptions) => void): void { + var isAccepted = collection.createDocument(collectionLink, doc, callback); + + // If the request was accepted, callback will be called. + // Otherwise report current count back to the client, + // which will call the script again with remaining set of docs. + // This condition will happen when this stored procedure has been running too long + // and is about to get cancelled by the server. This will allow the calling client + // to resume this batch from the point we got to before isAccepted was set to false + if (!isAccepted) getContext().getResponse().setBody(count); + } + + // This is called when collection.createDocument is done and the document has been persisted. + function callback(err: IRequestCallbackError, doc: Object, options: IRequestCallbackOptions) { + if (err) throw err; + + // One more document has been inserted, increment the count. + count++; + + if (count >= docsLength) { + // If we have created all documents, we are done. Just set the response. + getContext().getResponse().setBody(count); + } else { + // Create next document. + tryCreate(docs[count], callback); + } + } +} + +/** +* This is executed as stored procedure to count the number of docs in the collection. +* To avoid script timeout on the server when there are lots of documents (100K+), the script executed in batches, +* each batch counts docs to some number and returns continuation token. +* The script is run multiple times, starting from empty continuation, +* then using continuation returned by last invocation script until continuation returned by the script is null/empty string. +* +* @param {String} filterQuery - Optional filter for query (e.g. "SELECT * FROM docs WHERE docs.category = 'food'"). +* @param {String} continuationToken - The continuation token passed by request, continue counting from this token. +*/ +function count(filterQuery: string, continuationToken: string) { + var collection: ICollection = getContext().getCollection(); + var maxResult: number = 25; // MAX number of docs to process in one batch, when reached, return to client/request continuation. + // intentionally set low to demonstrate the concept. This can be much higher. Try experimenting. + // We've had it in to the high thousands before seeing the stored proceudre timing out. + + // The number of documents counted. + var result: number = 0; + + tryQuery(continuationToken); + + // Helper method to check for max result and call query. + function tryQuery(nextContinuationToken: string) { + var responseOptions: Object = { continuation: nextContinuationToken, pageSize: maxResult }; + + // In case the server is running this script for long time/near timeout, it would return false, + // in this case we set the response to current continuation token, + // and the client will run this script again starting from this continuation. + // When the client calls this script 1st time, is passes empty continuation token. + if (result >= maxResult || !query(responseOptions)) { + setBody(nextContinuationToken); + } + } + + function query(responseOptions: IFeedOptions) { + // For empty query string, use readDocuments rather than queryDocuments -- it's faster as doesn't need to process the query. + return (filterQuery && filterQuery.length) ? + collection.queryDocuments(collection.getSelfLink(), filterQuery, responseOptions, onReadDocuments) : + collection.readDocuments(collection.getSelfLink(), responseOptions, onReadDocuments); + } + + // This is callback is called from collection.queryDocuments/readDocuments. + function onReadDocuments(err: IFeedCallbackError, docFeed: Array, responseOptions: IFeedCallbackOptions) { + if (err) { + throw 'Error while reading document: ' + err; + } + + // Increament the number of documents counted so far. + result += docFeed.length; + + // If there is continuation, call query again with it, + // otherwise we are done, in which case set continuation to null. + if (responseOptions.continuation) { + tryQuery(responseOptions.continuation); + } else { + setBody(null); + } + } + + // Set response body: use an object the client is expecting (2 properties: result and continuationToken). + function setBody(continuationToken: string) { + var body: Object = { count: result, continuationToken: continuationToken }; + getContext().getResponse().setBody(body); + } +} + +/** +* This is run as stored procedure and does the following: +* - create ordered result set (result) which is an array sorted by orderByFieldName parameter. +* - call collection.queryDocuments. +* - in the callback for each document, insert into an array (result) +* - in the end, sort the resulting array and return it to the client +* +* Important notes: +* - The resulting record set could be too large to fit into one response +* - To walk around that, we setBody by one element and catch the REQUEST_ENTITY_TOO_LARGE exception. +* When we get the exception, return resulting set to the client with continuation token +* to continue from item index specified by this token. +* - Note that when continuation is called, it will be different transaction +* +* @param {String} filterQuery - Optional filter for query. +* @param {String} orderByFieldName - The name of the field to order by resulting set. +* @param {String} continuationToken - The continuation token passed by request, continue counting from this token. +*/ +function orderBy(filterQuery: string, orderByFieldName: string, continuationToken: number) { + // HTTP error codes sent to our callback funciton by DocDB server. + var ErrorCode: any = { + REQUEST_ENTITY_TOO_LARGE: 413, + } + + var collection: ICollection = getContext().getCollection(); + var collectionLink: string = collection.getSelfLink(); + var result: Array = new Array(); + + tryQuery({}); + + function tryQuery(options: IFeedOptions) { + var isAccepted: boolean = (filterQuery && filterQuery.length) ? + collection.queryDocuments(collectionLink, filterQuery, options, callback) : + collection.readDocuments(collectionLink, options, callback) + + if (!isAccepted) throw new Error("Source dataset is too large to complete the operation."); + } + + /** + * queryDocuments callback. + * @param {Error} err - Error object in case of error/exception. + * @param {Array} queryFeed - array containing results of the query. + * @param {ResponseOptions} responseOptions. + */ + function callback(err: IFeedCallbackError, queryFeed: Array, responseOptions: IFeedCallbackOptions) { + if (err) { + throw err; + } + + // Iterate over document feed and store documents into the result array. + queryFeed.forEach(function (element: any, index: number, array: Array) { + result[result.length] = element; + }); + + if (responseOptions.continuation) { + // If there is continuation, call query again providing continuation token. + tryQuery({ continuation: responseOptions.continuation }); + } else { + // We are done with querying/got all results. Sort the results and return from the script. + result.sort(compare); + + fillResponse(); + } + } + + // Compare two objects(documents) using field specified by the orderByFieldName parameter. + // Return 0 if equal, -1 if less, 1 if greater. + function compare(x: any, y: any) { + if (x[orderByFieldName] == y[orderByFieldName]) return 0; + else if (x[orderByFieldName] < y[orderByFieldName]) return -1; + return 1; + } + + // This is called in the very end on an already sorted array. + // Sort the results and set the response body. + function fillResponse() { + // Main script is called with continuationToken which is the index of 1st item to start result batch from. + // Slice the result array and discard the beginning. From now on use the 'continuationResult' var. + var continuationResult: Array = result; + if (continuationToken) continuationResult = result.slice(continuationToken); + else continuationToken = 0; + + // Get/initialize the response. + var response: IResponse = getContext().getResponse(); + response.setBody(null); + + // Take care of response body getting too large: + // Set Response iterating by one element. When we fail due to MAX response size, return to the client requesting continuation. + var i = 0; + for (; i < continuationResult.length; ++i) { + try { + // Note: setBody is very expensive vs appendBody, use appendBody with simple approximation JSON.stringify(element). + response.appendBody(JSON.stringify(continuationResult[i])); + } catch (ex) { + if (!ex.number == ErrorCode.REQUEST_ENTITY_TOO_LARGE) throw ex; + break; + } + } + + // Now next batch to return to client has i elements. + // Slice the continuationResult if needed and discard the end. + var partialResult: Array = continuationResult; + var newContinuation: string = null; + if (i < continuationResult.length) { + partialResult = continuationResult.slice(0, i); + } + + // Finally, set response body. + response.setBody({ result: result, continuation: newContinuation }); + } +} + + +/** +* This is run as stored procedure and does the following: +* - get 1st document in the collection, convert to JSON, prepend string specified by the prefix parameter +* and set response to the result of that. +* +* @param {String} prefix - The string to prepend to the 1st document in collection. +*/ +function simple(prefix: string) { + var collection: ICollection = getContext().getCollection(); + + // Query documents and take 1st item. + var isAccepted: boolean = collection.queryDocuments( + collection.getSelfLink(), + 'SELECT * FROM root r', + function (err: IFeedCallbackError, feed: Array, options: IFeedCallbackOptions) { + if (err) throw err; + + // Check the feed and if it's empty, set the body to 'no docs found', + // Otherwise just take 1st element from the feed. + if (!feed || !feed.length) getContext().getResponse().setBody("no docs found"); + else getContext().getResponse().setBody(prefix + JSON.stringify(feed[0])); + }); + + if (!isAccepted) throw new Error("The query wasn't accepted by the server. Try again/use continuation token between API and script."); +} + +/** + * A DocumentDB stored procedure that bulk deletes documents for a given query.
+ * Note: You may need to execute this sproc multiple times (depending whether the sproc is able to delete every document within the execution timeout limit). + * + * @function + * @param {string} query - A query that provides the documents to be deleted (e.g. "SELECT * FROM c WHERE c.founded_year = 2008") + * @returns {Object.} Returns an object with the two properties:
+ * deleted - contains a count of documents deleted
+ * continuation - a boolean whether you should execute the sproc again (true if there are more documents to delete; false otherwise). + */ +function bulkDeleteSproc(query: string) { + var collection: ICollection = getContext().getCollection(); + var collectionLink: string = collection.getSelfLink(); + var response: IResponse = getContext().getResponse(); + var responseBody: any = { + deleted: 0, + continuation: true + }; + + // Validate input. + if (!query) throw new Error("The query is undefined or null."); + + tryQueryAndDelete(); + + // Recursively runs the query w/ support for continuation tokens. + // Calls tryDelete(documents) as soon as the query returns documents. + function tryQueryAndDelete(continuation?: string) { + var requestOptions: IFeedOptions = { continuation: continuation }; + + var isAccepted: boolean = collection.queryDocuments(collectionLink, query, requestOptions, function (err: IFeedCallbackError, retrievedDocs: Array, responseOptions: IFeedCallbackOptions) { + if (err) throw err; + + if (retrievedDocs.length > 0) { + // Begin deleting documents as soon as documents are returned form the query results. + // tryDelete() resumes querying after deleting; no need to page through continuation tokens. + // - this is to prioritize writes over reads given timeout constraints. + tryDelete(retrievedDocs); + } else if (responseOptions.continuation) { + // Else if the query came back empty, but with a continuation token; repeat the query w/ the token. + tryQueryAndDelete(responseOptions.continuation); + } else { + // Else if there are no more documents and no continuation token - we are finished deleting documents. + responseBody.continuation = false; + response.setBody(responseBody); + } + }); + + // If we hit execution bounds - return continuation: true. + if (!isAccepted) { + response.setBody(responseBody); + } + } + + // Recursively deletes documents passed in as an array argument. + // Attempts to query for more on empty array. + function tryDelete(documents: Array) { + if (documents.length > 0) { + // Delete the first document in the array. + var isAccepted: boolean = collection.deleteDocument(documents[0]._self, {}, function (err, responseOptions) { + if (err) throw err; + + responseBody.deleted++; + documents.shift(); + // Delete the next document in the array. + tryDelete(documents); + }); + + // If we hit execution bounds - return continuation: true. + if (!isAccepted) { + response.setBody(responseBody); + } + } else { + // If the document array is empty, query for more documents. + tryQueryAndDelete(); + } + } +} + +/** + * A DocumentDB stored procedure that updates a document by id, using a similar syntax to MongoDB's update operator.
+ *
+ * The following operations are supported:
+ *
+ * Field Operators:
+ *
    + *
  • $inc - Increments the value of the field by the specified amount.
  • + *
  • $mul - Multiplies the value of the field by the specified amount.
  • + *
  • $rename - Renames a field.
  • + *
  • $set - Sets the value of a field in a document.
  • + *
  • $unset - Removes the specified field from a document.
  • + *
  • $min - Only updates the field if the specified value is less than the existing field value.
  • + *
  • $max - Only updates the field if the specified value is greater than the existing field value.
  • + *
  • $currentDate - Sets the value of a field to current date as a Unix Epoch.
  • + *
+ *
+ * Array Operators:
+ *
    + *
  • $addToSet - Adds elements to an array only if they do not already exist in the set.
  • + *
  • $pop - Removes the first or last item of an array.
  • + *
  • $push - Adds an item to an array.
  • + *
+ *
+ * Note: Performing multiple operations on the same field may yield unexpected results.
+ * + * @example
+ * updateSproc("foo", {$inc: {counter: 1}}); + * + * @example + * updateSproc("bar", {$set: {message: "Hello World"}, $currentDate: {messageDate: ""}}); + * + * @function + * @param {string} id - The id for your document. + * @param {object} update - the modifications to apply. + * @returns {object} the updated document. + */ +function updateSproc(id: string, update: Object) { + var collection: ICollection = getContext().getCollection(); + var collectionLink: string = collection.getSelfLink(); + var response: IResponse = getContext().getResponse(); + + // Validate input. + if (!id) throw new Error("The id is undefined or null."); + if (!update) throw new Error("The update is undefined or null."); + + tryQueryAndUpdate(); + + // Recursively queries for a document by id w/ support for continuation tokens. + // Calls tryUpdate(document) as soon as the query returns a document. + function tryQueryAndUpdate(continuation?: string) { + var query: IParameterizedQuery = { query: "select * from root r where r.id = @id", parameters: [{ name: "@id", value: id }] }; + var requestOptions: IFeedOptions = { continuation: continuation }; + + var isAccepted: boolean = collection.queryDocuments(collectionLink, query, requestOptions, function (err: IFeedCallbackError, documents: Array, responseOptions: IFeedCallbackOptions) { + if (err) throw err; + + if (documents.length > 0) { + // If the document is found, update it. + // There is no need to check for a continuation token since we are querying for a single document. + tryUpdate(documents[0]); + } else if (responseOptions.continuation) { + // Else if the query came back empty, but with a continuation token; repeat the query w/ the token. + // It is highly unlikely for this to happen when performing a query by id; but is included to serve as an example for larger queries. + tryQueryAndUpdate(responseOptions.continuation); + } else { + // Else a document with the given id does not exist.. + throw new Error("Document not found."); + } + }); + + // If we hit execution bounds - throw an exception. + // This is highly unlikely given that this is a query by id; but is included to serve as an example for larger queries. + if (!isAccepted) { + throw new Error("The stored procedure timed out."); + } + } + + // Updates the supplied document according to the update object passed in to the sproc. + function tryUpdate(document: IDocumentMeta) { + + // DocumentDB supports optimistic concurrency control via HTTP ETag. + var requestOptions: IReplaceOptions = { etag: document._etag }; + + // Update operators. + inc(document, update); + mul(document, update); + rename(document, update); + set(document, update); + unset(document, update); + min(document, update); + max(document, update); + currentDate(document, update); + addToSet(document, update); + pop(document, update); + push(document, update); + + // Update the document. + var isAccepted: boolean = collection.replaceDocument(document._self, document, requestOptions, function (err, updatedDocument, responseOptions) { + if (err) throw err; + + // If we have successfully updated the document - return it in the response body. + response.setBody(updatedDocument); + }); + + // If we hit execution bounds - throw an exception. + if (!isAccepted) { + throw new Error("The stored procedure timed out."); + } + } + + // Operator implementations. + // The $inc operator increments the value of a field by a specified amount. + function inc(document: any, update: any) { + var fields: Array, i: number; + + if (update.$inc) { + fields = Object.keys(update.$inc); + for (i = 0; i < fields.length; i++) { + if (isNaN(update.$inc[fields[i]])) { + // Validate the field; throw an exception if it is not a number (can't increment by NaN). + throw new Error("Bad $inc parameter - value must be a number") + } else if (document[fields[i]]) { + // If the field exists, increment it by the given amount. + document[fields[i]] += update.$inc[fields[i]]; + } else { + // Otherwise set the field to the given amount. + document[fields[i]] = update.$inc[fields[i]]; + } + } + } + } + + // The $mul operator multiplies the value of the field by the specified amount. + function mul(document: any, update: any) { + var fields: Array, i: number; + + if (update.$mul) { + fields = Object.keys(update.$mul); + for (i = 0; i < fields.length; i++) { + if (isNaN(update.$mul[fields[i]])) { + // Validate the field; throw an exception if it is not a number (can't multiply by NaN). + throw new Error("Bad $mul parameter - value must be a number") + } else if (document[fields[i]]) { + // If the field exists, multiply it by the given amount. + document[fields[i]] *= update.$mul[fields[i]]; + } else { + // Otherwise set the field to 0. + document[fields[i]] = 0; + } + } + } + } + + // The $rename operator renames a field. + function rename(document: any, update: any) { + var fields: Array, i: number, existingFieldName: string, newFieldName: string; + + if (update.$rename) { + fields = Object.keys(update.$rename); + for (i = 0; i < fields.length; i++) { + existingFieldName = fields[i]; + newFieldName = update.$rename[fields[i]]; + + if (existingFieldName == newFieldName) { + throw new Error("Bad $rename parameter: The new field name must differ from the existing field name.") + } else if (document[existingFieldName]) { + // If the field exists, set/overwrite the new field name and unset the existing field name. + document[newFieldName] = document[existingFieldName]; + delete document[existingFieldName]; + } else { + // Otherwise this is a noop. + } + } + } + } + + // The $set operator sets the value of a field. + function set(document: any, update: any) { + var fields: Array, i: number; + + if (update.$set) { + fields = Object.keys(update.$set); + for (i = 0; i < fields.length; i++) { + document[fields[i]] = update.$set[fields[i]]; + } + } + } + + // The $unset operator removes the specified field. + function unset(document: any, update: any) { + var fields: Array, i: number; + + if (update.$unset) { + fields = Object.keys(update.$unset); + for (i = 0; i < fields.length; i++) { + delete document[fields[i]]; + } + } + } + + // The $min operator only updates the field if the specified value is less than the existing field value. + function min(document: any, update: any) { + var fields: Array, i: number; + + if (update.$min) { + fields = Object.keys(update.$min); + for (i = 0; i < fields.length; i++) { + if (update.$min[fields[i]] < document[fields[i]]) { + document[fields[i]] = update.$min[fields[i]]; + } + } + } + } + + // The $max operator only updates the field if the specified value is greater than the existing field value. + function max(document: any, update: any) { + var fields: Array, i: number; + + if (update.$max) { + fields = Object.keys(update.$max); + for (i = 0; i < fields.length; i++) { + if (update.$max[fields[i]] > document[fields[i]]) { + document[fields[i]] = update.$max[fields[i]]; + } + } + } + } + + // The $currentDate operator sets the value of a field to current date as a POSIX epoch. + function currentDate(document: any, update: any) { + var currentDate: Date = new Date(); + var fields: Array, i: number; + + if (update.$currentDate) { + fields = Object.keys(update.$currentDate); + for (i = 0; i < fields.length; i++) { + // ECMAScript's Date.getTime() returns milliseconds, where as POSIX epoch are in seconds. + document[fields[i]] = Math.round(currentDate.getTime() / 1000); + } + } + } + + // The $addToSet operator adds elements to an array only if they do not already exist in the set. + function addToSet(document: any, update: any) { + var fields: Array, i: number; + + if (update.$addToSet) { + fields = Object.keys(update.$addToSet); + + for (i = 0; i < fields.length; i++) { + if (!Array.isArray(document[fields[i]])) { + // Validate the document field; throw an exception if it is not an array. + throw new Error("Bad $addToSet parameter - field in document must be an array.") + } else if (document[fields[i]].indexOf(update.$addToSet[fields[i]]) === -1) { + // Add the element if it doesn't already exist in the array. + document[fields[i]].push(update.$addToSet[fields[i]]); + } + } + } + } + + // The $pop operator removes the first or last item of an array. + // Pass $pop a value of -1 to remove the first element of an array and 1 to remove the last element in an array. + function pop(document: any, update: any) { + var fields: Array, i: number; + + if (update.$pop) { + fields = Object.keys(update.$pop); + + for (i = 0; i < fields.length; i++) { + if (!Array.isArray(document[fields[i]])) { + // Validate the document field; throw an exception if it is not an array. + throw new Error("Bad $pop parameter - field in document must be an array.") + } else if (update.$pop[fields[i]] < 0) { + // Remove the first element from the array if it's less than 0 (be flexible). + document[fields[i]].shift(); + } else { + // Otherwise, remove the last element from the array (have 0 default to javascript's pop()). + document[fields[i]].pop(); + } + } + } + } + + // The $push operator adds an item to an array. + function push(document: any, update: any) { + var fields: Array, i: number; + + if (update.$push) { + fields = Object.keys(update.$push); + + for (i = 0; i < fields.length; i++) { + if (!Array.isArray(document[fields[i]])) { + // Validate the document field; throw an exception if it is not an array. + throw new Error("Bad $push parameter - field in document must be an array.") + } else { + // Push the element in to the array. + document[fields[i]].push(update.$push[fields[i]]); + } + } + } + } +} + +/** + * A DocumentDB stored procedure that upserts a given document (insert new or update if present) using its id property.
+ * This implementation tries to create, and if the create fails then query for the document with the specified document's id, then replace it. + * Use this sproc if creates are more common than replaces, otherwise use "upsertOptimizedForReplace" + * + * @function + * @param {Object} document - A document that should be upserted into this collection. + * @returns {Object.} Returns an object with the property:
+ * op - created (or) replaced. + */ +function upsert(document: IDocumentMeta) { + var context: IContext = getContext(); + var collection: ICollection = context.getCollection(); + var collectionLink: string = collection.getSelfLink(); + var response: IResponse = context.getResponse(); + var errorCodes: any = { CONFLICT: 409 }; + + // Not checking for existence of document.id for compatibility with createDocument. + if (!document) throw new Error("The document is undefined or null."); + + tryCreate(document, callback); + + function tryCreate(doc: IDocumentMeta, callback: (err: IRequestCallbackError, obj: any, options: IRequestCallbackOptions) => void) { + var isAccepted: boolean = collection.createDocument(collectionLink, doc, callback); + if (!isAccepted) throw new Error("Unable to schedule create document"); + response.setBody({ "op": "created" }); + } + + // To replace the document, first issue a query to find it and then call replace. + function tryReplace(doc: IDocumentMeta, callback: (err: IRequestCallbackError, obj: any, options: IRequestCallbackOptions) => void) { + retrieveDoc(doc, null, function (retrievedDocs: Array) { + var isAccepted: boolean = collection.replaceDocument(retrievedDocs[0]._self, doc, callback); + if (!isAccepted) throw new Error("Unable to schedule replace document"); + response.setBody({ "op": "replaced" }); + }); + } + + function retrieveDoc(doc: IDocumentMeta, continuation: string, callback: Function) { + var query: IParameterizedQuery = { query: "select * from root r where r.id = @id", parameters: [{ name: "@id", value: doc.id }] }; + var requestOptions: IFeedOptions = { continuation: continuation }; + var isAccepted: boolean = collection.queryDocuments(collectionLink, query, requestOptions, function (err: IFeedCallbackError, retrievedDocs: Array, responseOptions: IFeedCallbackOptions) { + if (err) throw err; + + if (retrievedDocs.length > 0) { + callback(retrievedDocs); + } else if (responseOptions.continuation) { + // Conservative check for continuation. Not expected to hit in practice for the "id query" + retrieveDoc(doc, responseOptions.continuation, callback); + } else { + throw new Error("Error in retrieving document: " + doc.id); + } + }); + if (!isAccepted) throw new Error("Unable to query documents"); + } + + // This is called when collection.createDocument is done in order to + // process the result. + function callback(err: IRequestCallbackError, doc: any, options: IRequestCallbackOptions) { + if (err) { + // Replace the document if status code is 409 and upsert is enabled + if (err.number == errorCodes.CONFLICT) { + return tryReplace(document, callback); + } else { + throw err; + } + } + } +} + +/** + * A DocumentDB stored procedure that upserts a given document (insert new or update if present) using its id property.
+ * This implementation queries for the document's id, and creates if absent and replaces if found. + * Use this sproc if replaces are more common than creates, otherwise use "upsert" + * + * @function + * @param {Object} document - A document that should be upserted into this collection. + * @returns {Object.} Returns an object with the property:
+ * op - created (or) replaced. + */ +function upsertOptimizedForReplace(document: any) { + var context: IContext = getContext(); + var collection: ICollection = context.getCollection(); + var collectionLink: string = collection.getSelfLink(); + var response: IResponse = context.getResponse(); + + // Not checking for existence of document.id for compatibility with createDocument. + if (!document) throw new Error("The document is undefined or null."); + + retrieveDoc(document, null, callback); + + function retrieveDoc(doc: IDocumentMeta, continuation: string, callback: (err: IRequestCallbackError, obj: any, options: IRequestCallbackOptions) => void) { + var query: IParameterizedQuery = { query: "select * from root r where r.id = @id", parameters: [{ name: "@id", value: doc.id }] }; + var requestOptions: IFeedOptions = { continuation: continuation }; + var isAccepted: boolean = collection.queryDocuments(collectionLink, query, requestOptions, function (err: IFeedCallbackError, retrievedDocs: Array, responseOptions: IFeedCallbackOptions) { + if (err) throw err; + if (retrievedDocs.length > 0) { + tryReplace(retrievedDocs[0], doc, callback); + } else if (responseOptions.continuation) { + // Conservative check for continuation. Not expected to hit in practice for the "id query". + retrieveDoc(doc, responseOptions.continuation, callback); + } else { + tryCreate(doc, callback); + } + }); + if (!isAccepted) throw new Error("Unable to query documents"); + } + + function tryCreate(doc: any, callback: (err: IRequestCallbackError, obj: any, options: IRequestCallbackOptions) => void) { + var isAccepted = collection.createDocument(collectionLink, doc, callback); + if (!isAccepted) throw new Error("Unable to schedule create document"); + response.setBody({ "op": "created" }); + } + + function tryReplace(docToReplace: IDocumentMeta, docContent: any, callback: (err: IRequestCallbackError, obj: any, options: IRequestCallbackOptions) => void) { + var isAccepted = collection.replaceDocument(docToReplace._self, docContent, callback); + if (!isAccepted) throw new Error("Unable to schedule replace document"); + response.setBody({ "op": "replaced" }); + } + + function callback(err: IRequestCallbackError, obj: any, options: IRequestCallbackOptions): void { + if (err) throw err; + } +} + +/** +* This script runs as a pre-trigger when a document is inserted: +* for each inserted document, validate/canonicalize document.weekday and create field document.createdTime. +*/ +function validateClass() { + var collection: ICollection = getContext().getCollection(); + var collectionLink: string = collection.getSelfLink(); + var doc: any = getContext().getRequest().getBody(); + + // Validate/canonicalize the data. + doc.weekday = canonicalizeWeekDay(doc.weekday); + + // Insert auto-created field 'createdTime'. + doc.createdTime = new Date(); + + // Update the request -- this is what is going to be inserted. + getContext().getRequest().setBody(doc); + + function canonicalizeWeekDay(day: string) { + // Simple input validation. + if (!day || !day.length || day.length < 3) throw new Error("Bad input: " + day); + + // Try to see if we can canonicalize the day. + var days: Array = ["Monday", "Tuesday", "Wednesday", "Friday", "Saturday", "Sunday"]; + var fullDay: string; + days.forEach(function (x: string) { + if (day.substring(0, 3).toLowerCase() == x.substring(0, 3).toLowerCase()) fullDay = x; + }); + if (fullDay) return fullDay; + + // Couldn't get the weekday from input. Throw. + throw new Error("Bad weekday: " + day); + } +} + +/** +* This script runs as a trigger: +* for each inserted document, look at document.size and update aggregate properties of metadata document: minSize, maxSize, totalSize. +*/ +function updateMetadata() { + // HTTP error codes sent to our callback funciton by DocDB server. + var ErrorCode: any = { + RETRY_WITH: 449, + } + + var collection: ICollection = getContext().getCollection(); + var collectionLink: string = collection.getSelfLink(); + + // Get the document from request (the script runs as trigger, thus the input comes in request). + var doc: any = getContext().getRequest().getBody(); + + // Check the doc (ignore docs with invalid/zero size and metaDoc itself) and call updateMetadata. + if (!doc.isMetadata && doc.size != undefined && doc.size > 0) { + getAndUpdateMetadata(); + } + + function getAndUpdateMetadata() { + // Get the meta document. We keep it in the same collection. it's the only doc that has .isMetadata = true. + var isAccepted: boolean = collection.queryDocuments(collectionLink, 'SELECT * FROM root r WHERE r.isMetadata = true', function (err: IFeedCallbackError, feed: Array, options: IFeedCallbackOptions) { + if (err) throw err; + if (!feed || !feed.length) throw new Error("Failed to find the metadata document."); + + // The metadata document. + var metaDoc: any = feed[0]; + + // Update metaDoc.minSize: + // for 1st document use doc.Size, for all the rest see if it's less than last min. + if (metaDoc.minSize == 0) metaDoc.minSize = doc.size; + else metaDoc.minSize = Math.min(metaDoc.minSize, doc.size); + + // Update metaDoc.maxSize. + metaDoc.maxSize = Math.max(metaDoc.maxSize, doc.size); + + // Update metaDoc.totalSize. + metaDoc.totalSize += doc.size; + + // Update/replace the metadata document in the store. + var isAccepted: boolean = collection.replaceDocument(metaDoc._self, metaDoc, function (err: IRequestCallbackError) { + if (err) throw err; + // Note: in case concurrent updates causes conflict with ErrorCode.RETRY_WITH, we can't read the meta again + // and update again because due to Snapshot isolation we will read same exact version (we are in same transaction). + // We have to take care of that on the client side. + }); + if (!isAccepted) throw new Error("The call replaceDocument(metaDoc) returned false."); + }); + if (!isAccepted) throw new Error("The call queryDocuments for metaDoc returned false."); + } +} + +/** + * This script is meant to run as a pre-trigger to enforce the uniqueness of the "name" property. + */ + +function validateName() { + var collection: ICollection = getContext().getCollection(); + var request: IRequest = getContext().getRequest(); + var docToCreate: any = request.getBody(); + + // Reject documents that do not have a name property by throwing an exception. + if (!docToCreate.name) { + throw new Error('Document must include a "name" property.'); + } + + lookForDuplicates(); + + function lookForDuplicates(continuation?: string) { + var query: IParameterizedQuery = { + query: 'SELECT * FROM myCollection c WHERE c.name = @name', + parameters: [{ + name: '@name', + value: docToCreate.name + }] + }; + var requestOptions: IFeedOptions = { + continuation: continuation + }; + + var isAccepted: boolean = collection.queryDocuments(collection.getSelfLink(), query, requestOptions, + function (err: IFeedCallbackError, results: Array, responseOptions: IFeedCallbackOptions) { + if (err) { + throw new Error('Error querying for documents with duplicate names: ' + err.body); + } + if (results.length > 0) { + // At least one document with name exists. + throw new Error('Document with the name, ' + docToCreate.name + ', already exists: ' + JSON.stringify(results[0])); + } else if (responseOptions.continuation) { + // Else if the query came back empty, but with a continuation token; repeat the query w/ the token. + // This is highly unlikely; but is included to serve as an example for larger queries. + lookForDuplicates(responseOptions.continuation); + } else { + // Success, no duplicates found! Do nothing. + } + } + ); + + // If we hit execution bounds - throw an exception. + // This is highly unlikely; but is included to serve as an example for more complex operations. + if (!isAccepted) { + throw new Error('Timeout querying for document with duplicate name.'); + } + } +} diff --git a/documentdb-server/documentdb-server.d.ts b/documentdb-server/documentdb-server.d.ts new file mode 100644 index 000000000..0d902d1f0 --- /dev/null +++ b/documentdb-server/documentdb-server.d.ts @@ -0,0 +1,541 @@ +// Type definitions for DocumentDB server side JavaScript SDK +// Project: http://dl.windowsazure.com/documentDB/jsserverdocs +// Definitions by: François Nguyen +// Definitions: https://github.com/borisyankov/DefinitelyTyped/documentdb-server + +/** The Context object provides access to all operations that can be performed on DocumentDB data, as well as access to the request and response objects. */ +interface IContext { + /** Gets the collection object. */ + getCollection(): ICollection; + /** Gets the request object. */ + getRequest(): IRequest; + /** + * Gets the response object. + * Note: this is not available in pre-triggers. + */ + getResponse(): IResponse; +} + +/** + * The __ object can be used as a shortcut to the Collection and Context objects. + * It derives from the ICollection object via prototype and defines request and response properties + * which are shortcuts to getContext().getRequest() and getContext().getResponse(). + */ +interface I__Object extends ICollection { + /** Alias for getContext().getRequest() */ + request: IRequest; + /** Alias for getContext().getResponse() */ + response: IResponse; +} + +interface IQueryAPI { + /** + * Execute a filter on the input stream of documents, resulting in a subset of the input stream that matches the given filter. + * When filter is called by itself, the input document stream is the set of all documents in the current document collection. When used in a chained call, the input document stream is the set of documents returned from the previous query function. + * @param predicate The predicate function for a filter query, which acts as a truth test of whether a document should be filtered or not. + * @param options Optional query options. Should not be used in a chained call. + * @param callback Optional callback for the operation. If no callback is provided, any error in the operation will be thrown and the result document set will be written to the Response body. Should not be used in a chained call. + */ + filter(predicate: (document: Object) => boolean, + options?: IFeedOptions, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; + filter(predicate: (document: Object) => boolean, + options?: IFeedOptions, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; + /** + * Produce a new set of documents by mapping/projecting the properties of the documents in the input document stream through the given mapping predicate. + * When map is called by itself, the input document stream is the set of all documents in the current document collection. When used in a chained call, the input document stream is the set of documents returned from the previous query function. + * @param predicate The predicate function for a map/projection, which maps the input document's properties into a new document object. + * @param options Optional query options. Should not be used in a chained call. + * @param callback Optional callback for the operation. If no callback is provided, any error in the operation will be thrown and the result document set will be written to the Response body. Should not be used in a chained call. + */ + map(predicate: (document: Object) => Object, + options?: IFeedOptions, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; + map(predicate: (document: Object) => Object, + options?: IFeedOptions, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; + /** + * Produce a new set of documents by extracting a single property from each document in the input document stream. This is equivalent to a map call that projects only propertyName. + * When pluck is called by itself, the input document stream is the set of all documents in the current document collection. When used in a chained call, the input document stream is the set of documents returned from the previous query function. + * @param propertyName Name of the property to pluck from all documents in the current collection + * @param options Optional query options. Should not be used in a chained call. + * @param callback Optional callback for the operation. If no callback is provided, any error in the operation will be thrown and the result document set will be written to the Response body. Should not be used in a chained call. + */ + pluck(propertyName: string, + options?: IFeedOptions, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; + pluck(propertyName: string, + options?: IFeedOptions, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; + /** + * Flatten nested arrays from each document in the input document stream. + * When flatten is called by itself, the input document stream is the set of all documents in the current document collection. When used in a chained call, the input document stream is the set of documents returned from the previous query function. + * @param isShallow If true, flattens only the first level of nested arrays (false by default) + * @param options Optional query options. Should not be used in a chained call. + * @param callback Optional callback for the operation. If no callback is provided, any error in the operation will be thrown and the result document set will be written to the Response body. Should not be used in a chained call. + */ + flatten(isShallow?: boolean, + options?: IFeedOptions, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; + flatten(isShallow?: boolean, + options?: IFeedOptions, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; + /** + * Produce a new set of documents by sorting the documents in the input document stream in ascending order using the given predicate. + * When sortBy is called by itself, the input document stream is the set of all documents in the current document collection. When used in a chained call, the input document stream is the set of documents returned from the previous query function. + * @param predicate Predicate function defining the property to sort by. + * @param options Optional query options. Should not be used in a chained call. + * @param Optional callback for the operation. If no callback is provided, any error in the operation will be thrown and the result document set will be written to the Response body. Should not be used in a chained call. + */ + sortBy(predicate: (document: Object) => string, + options?: IFeedOptions, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; + sortBy(predicate: (document: Object) => number, + options?: IFeedOptions, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; + sortBy(predicate: (document: Object) => string, + options?: IFeedOptions, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; + sortBy(predicate: (document: Object) => number, + options?: IFeedOptions, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; + /** + * Produce a new set of documents by sorting the documents in the input document stream in descending order using the given predicate. + * When sortByDescending is called by itself, the input document stream is the set of all documents in the current document collection. When used in a chained call, the input document stream is the set of documents returned from the previous query function. + * @param predicate Predicate function defining the property to sort by. + * @param options Optional query options. Should not be used in a chained call. + * @param callback Optional callback for the operation. If no callback is provided, any error in the operation will be thrown and the result document set will be written to the Response body. Should not be used in a chained call. + */ + sortByDescending(predicate: (document: Object) => string, + options?: IFeedOptions, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; + sortByDescending(predicate: (document: Object) => number, + options?: IFeedOptions, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; + sortByDescending(predicate: (document: Object) => string, + options?: IFeedOptions, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; + sortByDescending(predicate: (document: Object) => number, + options?: IFeedOptions, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; + /** + * Terminating call for a chained query. Should be used in conjunction with the opening chain call to perform chained queries. + * When value is called, the query is queued for execution with the given options and callback. + * @param options Optional query options for the entire chained call. + * @param callback Optional callback for the operation. If no callback is provided, any error in the operation will be thrown and the result document set will be written to the Response body. + */ + value(options?: IFeedOptions, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; + value(options?: IFeedOptions, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): IQueryResponse; +} + +/** + * Stored procedures and triggers are registered for a particular collection. The Collection object supports create, read, update and delete (CRUD) and query operations on documents and attachments in the current collection. + * All collection operations are completed asynchronously. You can provide a callback to handle the result of the operation, and to perform error handling if necessary. + * Stored procedures and triggers are executed in a time-limited manner. Long-running stored procedures and triggers are defensively timed out and all transactions performed are rolled back. + * We stop queuing collection operations if the stored procedure is close to timing out. You can inspect the boolean return value of all collection operations to see if an operation was not queued and handle this situation gracefully. + */ +interface ICollection extends IQueryAPI { + /** Opening call to start a chained query. Should be used in conjunction with the closing value call to perform chained queries. */ + chain(): IQueryResponse; + + /** + * Create an attachment for the document. + * @param documentLink resource link of the collection under which the document will be created + * @param body metadata that defines the attachment media like media, contentType. It can include any other properties as part of the metedata. + * @param options optional create options + * @param callback optional callback for the operation. If no callback is provided, any error in the operation will be thrown. + */ + createAttachment(documentLink: string, + body: IAttachment, + options?: ICreateOptions, + callback?: (error: IRequestCallbackError, resources: Object, options: IRequestCallbackOptions) => void): boolean; + + /** + * Create a document under the collection. + * @param collectionLink resource link of the collection under which the document will be created + * @param body of the document. The "id" property is required and will be generated automatically if not provided (this behaviour can be overriden using the CreateOptions). Any other properties can be added. + * @param optional create options + * @param optional callback for the operation. If no callback is provided, any error in the operation will be thrown. + */ + createDocument(collectionLink: string, + body: Object, + options?: ICreateOptions, + callback?: (error: IRequestCallbackError, resources: Object, options: IRequestCallbackOptions) => void): boolean; + + /** + * Delete an attachment. + * @param attachmentLink resource link of the attachment to be deleted + * @param options optional delete options. + * @param callback optional callback for the operation. If no callback is provided, any error in the operation will be thrown. + */ + deleteAttachment(attachmentLink: string, + options?: IDeleteOptions, + callback?: (error: IRequestCallbackError, resources: Object, options: IRequestCallbackOptions) => void): boolean; + + /** + * Delete a document. + * @param documentLink resource link of the document to delete + * @param options optional delete options + * @param callback optional callback for the operation. If no callback is provided, any error in the operation will be thrown. + */ + deleteDocument(documentLink: string, + options?: IDeleteOptions, + callback?: (error: IRequestCallbackError, resources: Object, options: IRequestCallbackOptions) => void): boolean; + + /** Get alt link (name-based link) of current collection. */ + getAltLink(): string; + + /** Get self link of current collection. */ + getSelfLink(): string; + + /** + * Execute a SQL query on the attachments for the document. + * @param documentLink resource link of the document whose attachments are being queried + * @param query SQL query string. This can also be a JSON object to pass in a parameterized query along with the values. + * @param options optional query options + * @param callback optional callback for the operation. If no callback is provided, any error in the operation will be thrown. + */ + queryAttachments(documentLink: string, + query: string, + options?: IFeedOptions, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): boolean; + queryAttachments(documentLink: string, + query: IParameterizedQuery, + options?: IFeedOptions, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): boolean; + + /** + * Execute a SQL query on the documents of the collection. + * @param collectionLink resource link of the collection whose documents are being queried + * @param filterQuery SQL query string. This can also be a JSON object to pass in a parameterized query along with the values. + * @param options optional query options. + * @param callback optional callback for the operation. If no callback is provided, any error in the operation will be thrown. + */ + queryDocuments(collectionLink: string, + filterQuery: string, + options?: IFeedOptions, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): boolean; + queryDocuments(collectionLink: string, + filterQuery: string, + options?: IFeedOptions, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): boolean; + queryDocuments(collectionLink: string, + filterQuery: IParameterizedQuery, + options?: IFeedOptions, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): boolean; + queryDocuments(collectionLink: string, + filterQuery: IParameterizedQuery, + options?: IFeedOptions, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): boolean; + + /** + * Read an Attachment. + * @param attachmenLink resource link of the attachment to read + * @param options optional read options + * @param callback optional callback for the operation. If no callback is provided, any error in the operation will be thrown. + */ + readAttachment(attachmenLink: string, + options?: IReadOptions, + callback?: (error: IRequestCallbackError, resources: Object, options: IRequestCallbackOptions) => void): boolean; + + /** + * Get all attachments for the document. + * @param documentLink resource link of the document whose attachments are being read + * @param options optional read feed options + * @param callback optional callback for the operation. If no callback is provided, any error in the operation will be thrown. + */ + readAttachments(documentLink: string, + options?: IFeedOptions, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): boolean; + + /** + * Read a document. + * @param documentLink resource link of the document to read + * @param options optional read options + * @param callback optional callback for the operation. If no callback is provided, any error in the operation will be thrown. + */ + readDocument(documentLink: string, + options?: IReadOptions, + callback?: (error: IRequestCallbackError, resources: Object, options: IRequestCallbackOptions) => void): boolean; + readDocument(documentLink: string, + options?: IReadOptions, + callback?: (error: IRequestCallbackError, resources: T, options: IRequestCallbackOptions) => void): boolean; + + /** + * Get all documents for the collection. + * @param collectionLink resource link of the collection whose documents are being read + * @param options optional read feed options + * @param callback optional callback for the operation. If no callback is provided, any error in the operation will be thrown. + */ + readDocuments(collectionLink: string, + options?: IFeedOptions, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): boolean; + readDocuments(collectionLink: string, + options?: IFeedOptions, + callback?: (error: IFeedCallbackError, resources: Array, options: IFeedCallbackOptions) => void): boolean; + + /** + * Replace an attachment. + * @param attachmentLink resource link of the attachment to be replaced + * @param attachment new attachment body + * @param options optional replace options + * @param callback optional callback for the operation. If no callback is provided, any error in the operation will be thrown. + */ + replaceAttachment(attachmentLink: string, + attachment: Object, + options?: IReplaceOptions, + callback?: (error: IRequestCallbackError, resources: Object, options: IRequestCallbackOptions) => void): boolean; + + /** + * Replace a document. + * @param documentLink resource link of the document + * @param document new document body + * @param options optional replace options + * @param callback optional callback for the operation. If no callback is provided, any error in the operation will be thrown. + */ + replaceDocument(documentLink: string, + document: Object, + options?: IReplaceOptions, + callback?: (error: IRequestCallbackError, resources: Object, options: IRequestCallbackOptions) => void): boolean; +} + +/** Options associated with a create operation. */ +interface ICreateOptions { + /** Specifies indexing directives. */ + indexAction?: string; + /** Disables automatic generation of "id" field of the document to be created (if it is not provided) */ + disableAutomaticIdGeneration?: string; +} + +/** Options associated with a delete operation. */ +interface IDeleteOptions { + /** + * The entity tag associated with the resource. + * This is matched with the persisted resource before deletion. + */ + etag?: string; +} + +/** Will contain error information if an error occurs, undefined otherwise. */ +interface IFeedCallbackError { + /** The HTTP response code corresponding to the error. */ + number: number; + /** A string containing the error information. */ + body: string; +} + +/** Information associated with the response to the operation. */ +interface IFeedCallbackOptions { + /** Opaque token for continuing the read feed or query. */ + continuation: string; + /** Comma delimited string containing the collection's current quota metrics (storage, number of stored procedure, triggers and UDFs) after completion of the operation. */ + currentCollectionSizeInMB: string; + /** Comma delimited string containing the collection's maximum quota metrics (storage, number of stored procedure, triggers and UDFs). */ + maxCollectionSizeInMB: string; +} + +/** Options associated with a read feed or query operation. */ +interface IFeedOptions { + /** + * Max number of items to be returned in the enumeration operation. + * Value is 100 by default + */ + pageSize?: number; + /** Opaque token for continuing the enumeration. */ + continuation?: string; + /** Allow scan on the queries which couldn't be served as indexing was opted out on the requested paths (only for queryDocuments() and queryAttachments()) */ + enableScan?: boolean; + /** Allow order by with low precision (only for queryDocuments(), sortBy() and sortByDescending()) */ + enableLowPrecisionOrderBy?: boolean; +} + +/** + * Object returned from a query function, namely chain, filter, map, pluck, flatten, or value. + * If the query is part of a chained call, then this object can be used to chain further queries until the final terminating value call. + */ +interface IQueryResponse extends IQueryAPI { + /** True if the query has been queued, false if it is not queued because of a pending timeout. */ + isAccepted: boolean; +} + +/** Options associated with a read operation. */ +interface IReadOptions { + /** The conditional HTTP method ifNoneMatch value. */ + ifNoneMatch?: string; +} + +/** Options associated with a replace operation. */ +interface IReplaceOptions { + /** Specifies indexing directives. */ + indexAction?: string; + /** + * The entity tag associated with the resource. + * This is matched with the persisted resource before deletion. + */ + etag?: string; +} + +/** Will contain error information if an error occurs, undefined otherwise. */ +interface IRequestCallbackError { + /** The HTTP response code corresponding to the error. */ + number: number; + /** A string containing the error information. */ + body: string; +} + +/** Information associated with the response to the operation. */ +interface IRequestCallbackOptions { + /** Comma delimited string containing the collection's current quota metrics (storage, number of stored procedure, triggers and UDFs) after completion of the operation. */ + currentCollectionSizeInMB: string; + /** Comma delimited string containing the collection's maximum quota metrics (storage, number of stored procedure, triggers and UDFs). */ + maxCollectionSizeInMB: string; + /** Set to true if the requested resource has not been modified compared to the provided ETag in the ifNoneMatch parameter for a read request. */ + notModified: boolean; +} + +interface IAttachment extends Object { + /** MIME contentType of the attachment */ + contentType: string; + /** media link associated with the attachment content */ + media: string; +} + +interface IDocumentMeta extends Object { + id: string; + _self: string; + _ts: string; + _rid?: string; + _etag?: string; + _attachments?: string; +} + +/** + * The Request object represents the request message that was sent to the server. This includes information about HTTP headers and the body of the HTTP request sent to the server. + * For triggers, the request represents the operation that is executing when the trigger is run. For example, if the trigger is being run ("triggered") on the creation of a document, then + * the request body contains the JSON body of the document to be created. This can be accessed through the request object and (as JSON) can be natively consumed in JavaScript. + * For stored procedures, the request contains information about the request sent to execute the stored procedure. + */ +interface IRequest { + /** + * Gets the request body. + */ + getBody(): Object; + getBody(): T; + /** + * Gets a specified request header value. + * @param key the name of the header to retrieve + */ + getValue(key: string): string; + /** + * Sets the request body. + * Note: this can be only used in a pre-trigger to overwrite the existing request body. + * The overwritten request body will then be used in the operation associated with this pre-trigger. + * @param value the value to set in the request body + */ + setBody(value: string): void; + setBody(value: Object): void; + /** + * Sets a specified request header value. + * Note: this method cannot be used to create new headers. + * @param key the name of the header + * @param value the value of the header + */ + setValue(key: string, value: string): void; + + appendBody(value: string): void; + appendBody(value: Object): void; +} + +/** + * The Response object represents the response message that will be sent from the server in response to the requested operation. This includes information about the HTTP headers and body of the response from the server. + * The Response object is not present in pre-triggers because they are run before the response is generated. + * For post-triggers, the response represents the operation that was executed before the trigger. For example, if the post-trigger is being run ("triggered") after the creation of a document, then + * the response body contains the JSON body of the document that was created. This can be accessed through the response object and (as JSON) can be natively consumed in JavaScript. + * For stored procedures, the response can be manipulated to send output back to the client-side. + * Note: this object not available in pre-triggers + */ +interface IResponse { + /** + * Gets the response body. + */ + getBody(): Object; + getBody(): T; + /** + * Gets a maximum quota allowed for the resource associated with a post-trigger + * Note: this method is only available in post-triggers + */ + getMaxResourceQuota(): string; + /** + * Gets a current quota usage for the resource associated with a post-trigger + * Note: this method is only available in post-triggers + */ + getResourceQuotaCurrentUsage(): string; + /** + * Gets a specified response header value. + * @param key the name of the header to retrieve + */ + getValue(key: string): string; + /** + * Sets the response body. + * Note: This cannot be done in pre-triggers. + * In post-triggers, the response body is already set with the requested resource and will be overwritten with this call. + * In stored procedures, this call can be used to set the response message body as output to the calling client. + */ + setBody(value: string): void; + setBody(value: Object): void; + /** + * Sets a specified response header value. + * Note: this method cannot be used to create new headers. + * @param key the name of the header + * @param value the value of the header + */ + getValue(key: string, value: string): void; + + appendBody(value: string): void; + appendBody(value: Object): void; +} + +/** Can be used as the query parameter in queryAttachments and queryDocuments. */ +interface IParameterizedQuery { + /** SQL query string. */ + query: string; + /** Parameters */ + parameters: Array; +} + +/** Parameter interface for parameterized queries */ +interface IQueryParam { + /** Name to use in the query */ + name: string; + /** Value of the parameter */ + value: string; +} + +/** List of error codes returned by database operations in the RequestCallback and FeedCallback. See the corresponding error message for more details. */ +interface IErrorCodes { + // Client error + /** (400) Request failed due to bad inputs **/ + BadRequest: number; + /** (403) Request was denied access to the resource **/ + Forbidden: number; + /** (404) Request tried to access a resource which doesn't exist **/ + NotFound: number; + /** (409) Resource with the specified id already exists **/ + Conflict: number; + /** (412) Conditions specified in the request options were not met **/ + PreconditionFailed: number; + /** (413) Request failed because it was too large **/ + RequestEntityTooLarge: number; + /** (449) Request conflicted with the current state of a resource and must be retried from a new transaction from the client side **/ + RetryWith: number; + // Server error + /** (500) Server encountered an unexpected error in processing the request **/ + InternalServerError: number; +} + +declare function getContext(): IContext; +declare var __: I__Object; +declare var ErrorCodes: IErrorCodes; \ No newline at end of file From 05fae006b52d2ed72b8d1f239d78c348290fe7ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Nguyen?= Date: Wed, 23 Sep 2015 11:28:03 +0200 Subject: [PATCH 078/146] Removed appendBody() appendBody() is an undocumented method --- documentdb-server/documentdb-server.d.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/documentdb-server/documentdb-server.d.ts b/documentdb-server/documentdb-server.d.ts index 0d902d1f0..225a1a0cc 100644 --- a/documentdb-server/documentdb-server.d.ts +++ b/documentdb-server/documentdb-server.d.ts @@ -1,7 +1,7 @@ // Type definitions for DocumentDB server side JavaScript SDK // Project: http://dl.windowsazure.com/documentDB/jsserverdocs -// Definitions by: François Nguyen -// Definitions: https://github.com/borisyankov/DefinitelyTyped/documentdb-server +// Definitions by: François Nguyen +// Definitions: https://github.com/borisyankov/DefinitelyTyped /** The Context object provides access to all operations that can be performed on DocumentDB data, as well as access to the request and response objects. */ interface IContext { @@ -444,9 +444,6 @@ interface IRequest { * @param value the value of the header */ setValue(key: string, value: string): void; - - appendBody(value: string): void; - appendBody(value: Object): void; } /** From d12ff571bfed8c3412ba60cf3c8c2927acff41a4 Mon Sep 17 00:00:00 2001 From: tkqubo Date: Tue, 22 Sep 2015 18:42:55 +0900 Subject: [PATCH 079/146] Add webpack --- webpack/webpack-tests.ts | 47 +++++++++++++++++++++++++++++++++++ webpack/webpack.d.ts | 53 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 webpack/webpack-tests.ts create mode 100644 webpack/webpack.d.ts diff --git a/webpack/webpack-tests.ts b/webpack/webpack-tests.ts new file mode 100644 index 000000000..bd3de95a2 --- /dev/null +++ b/webpack/webpack-tests.ts @@ -0,0 +1,47 @@ +/// + +import webpack from 'webpack'; +//import webpack = require('webpack'); + +var configuration: webpack.Configuration; +var loader: webpack.Loader; +var plugin: webpack.Plugin; + +// +// https://webpack.github.io/docs/using-loaders.html +// + +configuration = { + module: { + loaders: [ + { test: /\.jade$/, loader: "jade" }, + // => "jade" loader is used for ".jade" files + + { test: /\.css$/, loader: "style!css" }, + // => "style" and "css" loader is used for ".css" files + // Alternative syntax: + { test: /\.css$/, loaders: ["style", "css"] }, + ] + } +}; + +loader = { test: /\.png$/, loader: "url-loader?mimetype=image/png" }; + +loader = { + test: /\.png$/, + loader: "url-loader", + query: { mimetype: "image/png" } +}; + +// +// https://webpack.github.io/docs/using-plugins.html +// + +configuration = { + plugins: [ + new webpack.ResolverPlugin([ + new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin("bower.json", ["main"]) + ], ["normal", "loader"]) + ] +}; + diff --git a/webpack/webpack.d.ts b/webpack/webpack.d.ts new file mode 100644 index 000000000..c8381e7e4 --- /dev/null +++ b/webpack/webpack.d.ts @@ -0,0 +1,53 @@ +// Type definitions for webpack +// Project: https://github.com/webpack/webpack +// Definitions by: Qubo +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "webpack" { + namespace webpack { + interface Configuration { + module?: Module; + plugins?: Plugin[]; + } + + interface Module { + loaders?: Loader[]; + } + + interface Loader { + test: RegExp; + loader?: string; + loaders?: string[]; + query?: { + [name: string]: any; + } + } + + interface Plugin { + } + + interface ResolverPlugin extends Plugin { + } + + interface ResolverPluginStatic { + new(plugins: Plugin[], files: string[]): ResolverPlugin; + DirectoryDescriptionFilePlugin: DirectoryDescriptionFilePluginStatic; + } + + interface DirectoryDescriptionFilePlugin extends Plugin { + } + + interface DirectoryDescriptionFilePluginStatic { + new(file: string, files: string[]): DirectoryDescriptionFilePlugin; + } + + interface Webpack { + ResolverPlugin: ResolverPluginStatic; + } + } + + var webpack: webpack.Webpack; + + export default webpack; +} + From d0336ac5118ba8f1f0602b8eed78c2cc9f118cbb Mon Sep 17 00:00:00 2001 From: tkqubo Date: Tue, 22 Sep 2015 19:35:45 +0900 Subject: [PATCH 080/146] Add more typings to webpack --- webpack/webpack-tests.ts | 202 +++++++++++++++++++++++++++++++++++++++ webpack/webpack.d.ts | 36 ++++++- 2 files changed, 237 insertions(+), 1 deletion(-) diff --git a/webpack/webpack-tests.ts b/webpack/webpack-tests.ts index bd3de95a2..a99905088 100644 --- a/webpack/webpack-tests.ts +++ b/webpack/webpack-tests.ts @@ -6,6 +6,7 @@ import webpack from 'webpack'; var configuration: webpack.Configuration; var loader: webpack.Loader; var plugin: webpack.Plugin; +declare var __dirname: string; // // https://webpack.github.io/docs/using-loaders.html @@ -45,3 +46,204 @@ configuration = { ] }; +// +// http://webpack.github.io/docs/tutorials/getting-started/ +// + +configuration = { + entry: "./entry.js", + output: { + path: __dirname, + filename: "bundle.js" + }, + module: { + loaders: [ + { test: /\.css$/, loader: "style!css" } + ] + } +}; + +// +// https://webpack.github.io/docs/code-splitting.html +// + +configuration = { + entry: { + app: "./app.js", + vendor: ["jquery", "underscore"], + }, + output: { + filename: "bundle.js" + }, + plugins: [ + new webpack.optimize.CommonsChunkPlugin(/* chunkName= */"vendor", /* filename= */"vendor.bundle.js") + ] +}; + +configuration = { + entry: { a: "./a", b: "./b" }, + output: { filename: "[name].js" }, + plugins: [ new webpack.optimize.CommonsChunkPlugin("init.js") ] +}; + +// +// https://webpack.github.io/docs/stylesheets.html +// + +configuration = { + // ... + module: { + loaders: [ + { test: /\.css$/, loader: "style-loader!css-loader" } + ] + } +}; + +class ExtractTextPlugin implements webpack.Plugin { + static extract(...loaders: string[]): string { return null; } + constructor(...args: any[]) {} +} + +configuration = { + // The standard entry point and output config + entry: { + posts: "./posts", + post: "./post", + about: "./about" + }, + output: { + filename: "[name].js", + chunkFilename: "[id].js" + }, + module: { + loaders: [ + // Extract css files + { + test: /\.css$/, + loader: ExtractTextPlugin.extract("style-loader", "css-loader") + }, + // Optionally extract less files + // or any other compile-to-css language + { + test: /\.less$/, + loader: ExtractTextPlugin.extract("style-loader", "css-loader!less-loader") + } + // You could also use other loaders the same way. I. e. the autoprefixer-loader + ] + }, + // Use the plugin to specify the resulting filename (and add needed behavior to the compiler) + plugins: [ + new ExtractTextPlugin("[name].css") + ] +}; + +configuration = { + // ... + plugins: [ + new ExtractTextPlugin("style.css", { + allChunks: true + }) + ] +}; + +configuration = { + // ... + plugins: [ + new webpack.optimize.CommonsChunkPlugin("commons", "commons.js"), + new ExtractTextPlugin("[name].css") + ] +}; + +// +// https://webpack.github.io/docs/optimization.html +// + +configuration = { + entry: { + p1: "./page1", + p2: "./page2", + p3: "./page3" + }, + output: { + filename: "[name].entry.chunk.js" + } +}; + +let CommonsChunkPlugin = webpack.optimize.CommonsChunkPlugin; +configuration = { + entry: { + p1: "./page1", + p2: "./page2", + p3: "./page3" + }, + output: { + filename: "[name].entry.chunk.js" + }, + plugins: [ + new CommonsChunkPlugin("commons.chunk.js") + ] +}; + +configuration = { + entry: { + p1: "./page1", + p2: "./page2", + p3: "./page3", + ap1: "./admin/page1", + ap2: "./admin/page2" + }, + output: { + filename: "[name].js" + }, + plugins: [ + new CommonsChunkPlugin("admin-commons.js", ["ap1", "ap2"]), + new CommonsChunkPlugin("commons.js", ["p1", "p2", "admin-commons.js"]) + ] +}; +//
Increment the property "counter" by 1 in the document where id = "foo".Set the property "message" to "Hello World" and the "messageDate" to the current date in the document where id = "bar".