From fe5fc9d015731d3272b900196462bad1baedc393 Mon Sep 17 00:00:00 2001 From: Robert Baker Date: Mon, 6 Jul 2015 11:41:34 -0700 Subject: [PATCH 1/5] Updated DialogService to support chained method config --- angular-material/angular-material.d.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/angular-material/angular-material.d.ts b/angular-material/angular-material.d.ts index 1383b0beb..50862aa3e 100644 --- a/angular-material/angular-material.d.ts +++ b/angular-material/angular-material.d.ts @@ -31,6 +31,24 @@ declare module angular.material { content(content: string): T; ok(ok: string): T; theme(theme: string): T; + templateUrl(templateUrl?: string); + template(template?: string); + targetEvent(targetEvent?: MouseEvent); + scope(scope?: angular.IScope); // default: new child scope + preserveScope(preserveScope?: boolean); // default: false + disableParentScroll(disableParentScroll?: boolean); // default: true + hasBackdrop(hasBackdrop?: boolean); // default: true + clickOutsideToClose(clickOutsideToClose?: boolean); // default: false + escapeToClose(escapeToClose?: boolean); // default: true + focusOnOpen(focusOnOpen?: boolean); // default: true + controller(controller?: string|Function); + locals(locals?: {[index: string]: any}); + bindToController(bindToController?: boolean); // default: false + resolve(resolve?: {[index: string]: angular.IPromise}) + controllerAs(controllerAs?: string); + parent(parent?: string|Element|JQuery); // default: root node + onComplete(onComplete?: Function); + ariaLabel(ariaLabel: string); } interface MDAlertDialog extends MDPresetDialog { From c34d4676728e3e94fd087f71c027a758d1a0f755 Mon Sep 17 00:00:00 2001 From: Robert Baker Date: Tue, 7 Jul 2015 16:45:24 -0700 Subject: [PATCH 2/5] Updated IconProvider Renamed interfaces to remove the MD prefix with I, to match angular interface names. --- angular-material/angular-material.d.ts | 106 +++++++++++++------------ 1 file changed, 54 insertions(+), 52 deletions(-) diff --git a/angular-material/angular-material.d.ts b/angular-material/angular-material.d.ts index 50862aa3e..6390981c3 100644 --- a/angular-material/angular-material.d.ts +++ b/angular-material/angular-material.d.ts @@ -1,12 +1,13 @@ -// Type definitions for Angular Material 0.9.0-rc1+ (angular.material module) +// Type definitions for Angular Material 0.10.1-rc1+ (angular.material module) // Project: https://github.com/angular/material // Definitions by: Matt Traynham +// Definitions by: Robert Baker // Definitions: https://github.com/borisyankov/DefinitelyTyped /// declare module angular.material { - interface MDBottomSheetOptions { + interface IBottomSheetOptions { templateUrl?: string; template?: string; scope?: angular.IScope; // default: new child scope @@ -20,13 +21,13 @@ declare module angular.material { disableParentScroll?: boolean; // default: true } - interface MDBottomSheetService { - show(options: MDBottomSheetOptions): angular.IPromise; + interface IBottomSheetService { + show(options: IBottomSheetOptions): angular.IPromise; hide(response?: any): void; cancel(response?: any): void; } - interface MDPresetDialog { + interface IPresetDialog { title(title: string): T; content(content: string): T; ok(ok: string): T; @@ -51,14 +52,14 @@ declare module angular.material { ariaLabel(ariaLabel: string); } - interface MDAlertDialog extends MDPresetDialog { + interface IAlertDialog extends IPresetDialog { } - interface MDConfirmDialog extends MDPresetDialog { - cancel(cancel: string): MDConfirmDialog; + interface IConfirmDialog extends IPresetDialog { + cancel(cancel: string): IConfirmDialog; } - interface MDDialogOptions { + interface IDialogOptions { templateUrl?: string; template?: string; targetEvent?: MouseEvent; @@ -78,30 +79,31 @@ declare module angular.material { onComplete?: Function; } - interface MDDialogService { - show(dialog: MDDialogOptions|MDAlertDialog|MDConfirmDialog): angular.IPromise; - confirm(): MDConfirmDialog; - alert(): MDAlertDialog; + interface IDialogService { + show(dialog: IDialogOptions|IAlertDialog|IConfirmDialog): angular.IPromise; + confirm(): IConfirmDialog; + alert(): IAlertDialog; hide(response?: any): void; cancel(response?: any): void; } - interface MDIcon { + interface IIcon { (id: string): angular.IPromise; // id is a unique ID or URL } - interface MDIconProvider { - icon(id: string, url: string, iconSize?: string): MDIconProvider; // iconSize default: '24px' - iconSet(id: string, url: string, iconSize?: string): MDIconProvider; // iconSize default: '24px' - defaultIconSet(url: string, iconSize?: string): MDIconProvider; // iconSize default: '24px' - defaultIconSize(iconSize: string): MDIconProvider; // default: '24px' + interface IIconProvider { + icon(id: string, url: string, viewBoxSize?: number): IIconProvider; // viewBoxSize default: 24 + iconSet(id: string, url: string, viewBoxSize?: number): IIconProvider; // viewBoxSize default: 24 + defaultIconSet(url: string, viewBoxSize?: number): IIconProvider; // viewBoxSize default: 24 + defaultViewBoxSize(viewBoxSize: number): IIconProvider; // default: 24 + defaultFontSet(name: string): IIconProvider; } - interface MDMedia { + interface IMedia { (media: string): boolean; } - interface MDSidenavObject { + interface ISidenavObject { toggle(): angular.IPromise; open(): angular.IPromise; close(): angular.IPromise; @@ -109,11 +111,11 @@ declare module angular.material { isLockedOpen(): boolean; } - interface MDSidenavService { - (component: string): MDSidenavObject; + interface ISidenavService { + (component: string): ISidenavObject; } - interface MDToastPreset { + interface IToastPreset { content(content: string): T; action(action: string): T; highlightAction(highlightAction: boolean): T; @@ -123,10 +125,10 @@ declare module angular.material { position(position: string): T; } - interface MDSimpleToastPreset extends MDToastPreset { + interface ISimpleToastPreset extends IToastPreset { } - interface MDToastOptions { + interface IToastOptions { templateUrl?: string; template?: string; scope?: angular.IScope; // default: new child scope @@ -141,17 +143,17 @@ declare module angular.material { parent?: string|Element|JQuery; // default: root node } - interface MDToastService { - show(optionsOrPreset: MDToastOptions|MDToastPreset): angular.IPromise; + interface IToastService { + show(optionsOrPreset: IToastOptions|IToastPreset): angular.IPromise; showSimple(): angular.IPromise; - simple(): MDSimpleToastPreset; - build(): MDToastPreset; + simple(): ISimpleToastPreset; + build(): IToastPreset; updateContent(): void; hide(response?: any): void; cancel(response?: any): void; } - interface MDPalette { + interface IPalette { 0?: string; 50?: string; 100?: string; @@ -172,26 +174,26 @@ declare module angular.material { contrastLightColors?: string|string[]; } - interface MDThemeHues { + interface IThemeHues { default?: string; 'hue-1'?: string; 'hue-2'?: string; 'hue-3'?: string; } - interface MDThemePalette { + interface IThemePalette { name: string; - hues: MDThemeHues; + hues: IThemeHues; } - interface MDThemeColors { - accent: MDThemePalette; - background: MDThemePalette; - primary: MDThemePalette; - warn: MDThemePalette; + interface IThemeColors { + accent: IThemePalette; + background: IThemePalette; + primary: IThemePalette; + warn: IThemePalette; } - interface MDThemeGrayScalePalette { + interface IThemeGrayScalePalette { 1: string; 2: string; 3: string; @@ -199,23 +201,23 @@ declare module angular.material { name: string; } - interface MDTheme { + interface ITheme { name: string; isDark: boolean; - colors: MDThemeColors; - foregroundPalette: MDThemeGrayScalePalette; + colors: IThemeColors; + foregroundPalette: IThemeGrayScalePalette; foregroundShadow: string; - accentPalette(name: string, hues?: MDThemeHues): MDTheme; - primaryPalette(name: string, hues?: MDThemeHues): MDTheme; - warnPalette(name: string, hues?: MDThemeHues): MDTheme; - backgroundPalette(name: string, hues?: MDThemeHues): MDTheme; - dark(isDark?: boolean): MDTheme; + accentPalette(name: string, hues?: IThemeHues): ITheme; + primaryPalette(name: string, hues?: IThemeHues): ITheme; + warnPalette(name: string, hues?: IThemeHues): ITheme; + backgroundPalette(name: string, hues?: IThemeHues): ITheme; + dark(isDark?: boolean): ITheme; } - interface MDThemingProvider { - theme(name: string, inheritFrom?: string): MDTheme; - definePalette(name: string, palette: MDPalette): MDThemingProvider; - extendPalette(name: string, palette: MDPalette): MDPalette; + interface IThemingProvider { + theme(name: string, inheritFrom?: string): ITheme; + definePalette(name: string, palette: IPalette): IThemingProvider; + extendPalette(name: string, palette: IPalette): IPalette; setDefaultTheme(theme: string): void; alwaysWatchTheme(alwaysWatch: boolean): void; } From 329ed16b58bc93944008d9eb5d0b8108cda296a3 Mon Sep 17 00:00:00 2001 From: Robert Baker Date: Tue, 7 Jul 2015 16:49:25 -0700 Subject: [PATCH 3/5] fixed test, versioned old file. --- angular-material/angular-material-0.9.0.d.ts | 204 +++++++++++++++++++ angular-material/angular-material-tests.ts | 22 +- 2 files changed, 215 insertions(+), 11 deletions(-) create mode 100644 angular-material/angular-material-0.9.0.d.ts diff --git a/angular-material/angular-material-0.9.0.d.ts b/angular-material/angular-material-0.9.0.d.ts new file mode 100644 index 000000000..06c1ecf25 --- /dev/null +++ b/angular-material/angular-material-0.9.0.d.ts @@ -0,0 +1,204 @@ +// Type definitions for Angular Material 0.9.0-rc1+ (angular.material module) +// Project: https://github.com/angular/material +// Definitions by: Matt Traynham +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +declare module angular.material { + + interface MDBottomSheetOptions { + templateUrl?: string; + template?: string; + scope?: angular.IScope; // default: new child scope + preserveScope?: boolean; // default: false + controller?: string|Function; + locals?: {[index: string]: any}; + targetEvent?: MouseEvent; + resolve?: {[index: string]: angular.IPromise} + controllerAs?: string; + parent?: string|Element|JQuery; // default: root node + disableParentScroll?: boolean; // default: true + } + + interface MDBottomSheetService { + show(options: MDBottomSheetOptions): angular.IPromise; + hide(response?: any): void; + cancel(response?: any): void; + } + + interface MDPresetDialog { + title(title: string): T; + content(content: string): T; + ok(ok: string): T; + theme(theme: string): T; + } + + interface MDAlertDialog extends MDPresetDialog { + } + + interface MDConfirmDialog extends MDPresetDialog { + cancel(cancel: string): MDConfirmDialog; + } + + interface MDDialogOptions { + templateUrl?: string; + template?: string; + targetEvent?: MouseEvent; + scope?: angular.IScope; // default: new child scope + preserveScope?: boolean; // default: false + disableParentScroll?: boolean; // default: true + hasBackdrop?: boolean // default: true + clickOutsideToClose?: boolean; // default: false + escapeToClose?: boolean; // default: true + focusOnOpen?: boolean; // default: true + controller?: string|Function; + locals?: {[index: string]: any}; + bindToController?: boolean; // default: false + resolve?: {[index: string]: angular.IPromise} + controllerAs?: string; + parent?: string|Element|JQuery; // default: root node + onComplete?: Function; + } + + interface MDDialogService { + show(dialog: MDDialogOptions|MDAlertDialog|MDConfirmDialog): angular.IPromise; + confirm(): MDConfirmDialog; + alert(): MDAlertDialog; + hide(response?: any): void; + cancel(response?: any): void; + } + + interface MDIcon { + (id: string): angular.IPromise; // id is a unique ID or URL + } + + interface MDIconProvider { + icon(id: string, url: string, iconSize?: string): MDIconProvider; // iconSize default: '24px' + iconSet(id: string, url: string, iconSize?: string): MDIconProvider; // iconSize default: '24px' + defaultIconSet(url: string, iconSize?: string): MDIconProvider; // iconSize default: '24px' + defaultIconSize(iconSize: string): MDIconProvider; // default: '24px' + } + + interface MDMedia { + (media: string): boolean; + } + + interface MDSidenavObject { + toggle(): angular.IPromise; + open(): angular.IPromise; + close(): angular.IPromise; + isOpen(): boolean; + isLockedOpen(): boolean; + } + + interface MDSidenavService { + (component: string): MDSidenavObject; + } + + interface MDToastPreset { + content(content: string): T; + action(action: string): T; + highlightAction(highlightAction: boolean): T; + capsule(capsule: boolean): T; + theme(theme: string): T; + hideDelay(delay: number): T; + position(position: string): T; + } + + interface MDSimpleToastPreset extends MDToastPreset { + } + + interface MDToastOptions { + templateUrl?: string; + template?: string; + scope?: angular.IScope; // default: new child scope + preserveScope?: boolean; // default: false + hideDelay?: number; // default (ms): 3000 + position?: string; // any combination of 'bottom'/'left'/'top'/'right'/'fit'; default: 'bottom left' + controller?: string|Function; + locals?: {[index: string]: any}; + bindToController?: boolean; // default: false + resolve?: {[index: string]: angular.IPromise} + controllerAs?: string; + parent?: string|Element|JQuery; // default: root node + } + + interface MDToastService { + show(optionsOrPreset: MDToastOptions|MDToastPreset): angular.IPromise; + showSimple(): angular.IPromise; + simple(): MDSimpleToastPreset; + build(): MDToastPreset; + updateContent(): void; + hide(response?: any): void; + cancel(response?: any): void; + } + + interface MDPalette { + 0?: string; + 50?: string; + 100?: string; + 200?: string; + 300?: string; + 400?: string; + 500?: string; + 600?: string; + 700?: string; + 800?: string; + 900?: string; + A100?: string; + A200?: string; + A400?: string; + A700?: string; + contrastDefaultColor?: string; + contrastDarkColors?: string; + contrastStrongLightColors?: string; + } + + interface MDThemeHues { + default?: string; + 'hue-1'?: string; + 'hue-2'?: string; + 'hue-3'?: string; + } + + interface MDThemePalette { + name: string; + hues: MDThemeHues; + } + + interface MDThemeColors { + accent: MDThemePalette; + background: MDThemePalette; + primary: MDThemePalette; + warn: MDThemePalette; + } + + interface MDThemeGrayScalePalette { + 1: string; + 2: string; + 3: string; + 4: string; + name: string; + } + + interface MDTheme { + name: string; + isDark: boolean; + colors: MDThemeColors; + foregroundPalette: MDThemeGrayScalePalette; + foregroundShadow: string; + accentPalette(name: string, hues?: MDThemeHues): MDTheme; + primaryPalette(name: string, hues?: MDThemeHues): MDTheme; + warnPalette(name: string, hues?: MDThemeHues): MDTheme; + backgroundPalette(name: string, hues?: MDThemeHues): MDTheme; + dark(isDark?: boolean): MDTheme; + } + + interface MDThemingProvider { + theme(name: string, inheritFrom?: string): MDTheme; + definePalette(name: string, palette: MDPalette): MDThemingProvider; + extendPalette(name: string, palette: MDPalette): MDPalette; + setDefaultTheme(theme: string): void; + alwaysWatchTheme(alwaysWatch: boolean): void; + } +} diff --git a/angular-material/angular-material-tests.ts b/angular-material/angular-material-tests.ts index ae091c805..238d906db 100644 --- a/angular-material/angular-material-tests.ts +++ b/angular-material/angular-material-tests.ts @@ -3,11 +3,11 @@ var myApp = angular.module('testModule', ['ngMaterial']); myApp.config(( - $mdThemingProvider: ng.material.MDThemingProvider, - $mdIconProvider: ng.material.MDIconProvider) => { + $mdThemingProvider: ng.material.IThemingProvider, + $mdIconProvider: ng.material.IIconProvider) => { $mdThemingProvider.alwaysWatchTheme(true); - var neonRedMap: ng.material.MDPalette = $mdThemingProvider.extendPalette('red', { + var neonRedMap: ng.material.IPalette = $mdThemingProvider.extendPalette('red', { '500': 'ff0000' }); // Register the new color palette map with the name neonRed @@ -27,7 +27,7 @@ myApp.config(( .icon('work:chair', 'my/app/chair.svg'); // Register icon in a specific set }); -myApp.controller('BottomSheetController', ($scope: ng.IScope, $mdBottomSheet: ng.material.MDBottomSheetService) => { +myApp.controller('BottomSheetController', ($scope: ng.IScope, $mdBottomSheet: ng.material.IBottomSheetService) => { $scope['openBottomSheet'] = () => { $mdBottomSheet.show({ template: 'Hello!' @@ -37,7 +37,7 @@ myApp.controller('BottomSheetController', ($scope: ng.IScope, $mdBottomSheet: ng $scope['cancelBottomSheet'] = $mdBottomSheet.cancel.bind($mdBottomSheet, 'cancel'); }); -myApp.controller('DialogController', ($scope: ng.IScope, $mdDialog: ng.material.MDDialogService) => { +myApp.controller('DialogController', ($scope: ng.IScope, $mdDialog: ng.material.IDialogService) => { $scope['openDialog'] = () => { $mdDialog.show({ template: 'Hello!' @@ -55,8 +55,8 @@ myApp.controller('DialogController', ($scope: ng.IScope, $mdDialog: ng.material. class IconDirective implements ng.IDirective { - private $mdIcon: ng.material.MDIcon; - constructor($mdIcon: ng.material.MDIcon) { + private $mdIcon: ng.material.IIcon; + constructor($mdIcon: ng.material.IIcon) { this.$mdIcon = $mdIcon; } @@ -69,9 +69,9 @@ class IconDirective implements ng.IDirective { }); } } -myApp.directive('icon-directive', ($mdIcon: ng.material.MDIcon) => new IconDirective($mdIcon)); +myApp.directive('icon-directive', ($mdIcon: ng.material.IIcon) => new IconDirective($mdIcon)); -myApp.controller('MediaController', ($scope: ng.IScope, $mdMedia: ng.material.MDMedia) => { +myApp.controller('MediaController', ($scope: ng.IScope, $mdMedia: ng.material.IMedia) => { $scope.$watch(() => $mdMedia('lg'), (big: boolean) => { $scope['bigScreen'] = big; }); @@ -80,7 +80,7 @@ myApp.controller('MediaController', ($scope: ng.IScope, $mdMedia: ng.material.MD $scope['anotherCustom'] = $mdMedia('max-width: 300px'); }); -myApp.controller('SidenavController', ($scope: ng.IScope, $mdSidenav: ng.material.MDSidenavService) => { +myApp.controller('SidenavController', ($scope: ng.IScope, $mdSidenav: ng.material.ISidenavService) => { var componentId = 'left'; $scope['toggle'] = () => $mdSidenav(componentId).toggle(); $scope['open'] = () => $mdSidenav(componentId).open(); @@ -89,6 +89,6 @@ myApp.controller('SidenavController', ($scope: ng.IScope, $mdSidenav: ng.materia $scope['isLockedOpen'] = $mdSidenav(componentId).isLockedOpen(); }); -myApp.controller('ToastController', ($scope: ng.IScope, $mdToast: ng.material.MDToastService) => { +myApp.controller('ToastController', ($scope: ng.IScope, $mdToast: ng.material.IToastService) => { $scope['openToast'] = () => $mdToast.show($mdToast.simple().content('Hello!')); }); \ No newline at end of file From d805bec7a9678825a7954ca6bf4146df16e929cb Mon Sep 17 00:00:00 2001 From: Robert Baker Date: Tue, 7 Jul 2015 16:55:02 -0700 Subject: [PATCH 4/5] added return types. --- angular-material/angular-material.d.ts | 39 +++++++++++++------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/angular-material/angular-material.d.ts b/angular-material/angular-material.d.ts index 6390981c3..21ff5a3fc 100644 --- a/angular-material/angular-material.d.ts +++ b/angular-material/angular-material.d.ts @@ -1,7 +1,6 @@ // Type definitions for Angular Material 0.10.1-rc1+ (angular.material module) // Project: https://github.com/angular/material -// Definitions by: Matt Traynham -// Definitions by: Robert Baker +// Definitions by: Matt Traynham and Robert Baker // Definitions: https://github.com/borisyankov/DefinitelyTyped /// @@ -32,24 +31,24 @@ declare module angular.material { content(content: string): T; ok(ok: string): T; theme(theme: string): T; - templateUrl(templateUrl?: string); - template(template?: string); - targetEvent(targetEvent?: MouseEvent); - scope(scope?: angular.IScope); // default: new child scope - preserveScope(preserveScope?: boolean); // default: false - disableParentScroll(disableParentScroll?: boolean); // default: true - hasBackdrop(hasBackdrop?: boolean); // default: true - clickOutsideToClose(clickOutsideToClose?: boolean); // default: false - escapeToClose(escapeToClose?: boolean); // default: true - focusOnOpen(focusOnOpen?: boolean); // default: true - controller(controller?: string|Function); - locals(locals?: {[index: string]: any}); - bindToController(bindToController?: boolean); // default: false - resolve(resolve?: {[index: string]: angular.IPromise}) - controllerAs(controllerAs?: string); - parent(parent?: string|Element|JQuery); // default: root node - onComplete(onComplete?: Function); - ariaLabel(ariaLabel: string); + templateUrl(templateUrl?: string): T; + template(template?: string): T; + targetEvent(targetEvent?: MouseEvent): T; + scope(scope?: angular.IScope): T; // default: new child scope + preserveScope(preserveScope?: boolean): T; // default: false + disableParentScroll(disableParentScroll?: boolean): T; // default: true + hasBackdrop(hasBackdrop?: boolean): T; // default: true + clickOutsideToClose(clickOutsideToClose?: boolean): T; // default: false + escapeToClose(escapeToClose?: boolean): T; // default: true + focusOnOpen(focusOnOpen?: boolean): T; // default: true + controller(controller?: string|Function): T; + locals(locals?: {[index: string]: any}): T; + bindToController(bindToController?: boolean): T; // default: false + resolve(resolve?: {[index: string]: angular.IPromise}): T; + controllerAs(controllerAs?: string): T; + parent(parent?: string|Element|JQuery): T; // default: root node + onComplete(onComplete?: Function): T; + ariaLabel(ariaLabel: string): T; } interface IAlertDialog extends IPresetDialog { From 3580621879a48268033571e3615466715052bb03 Mon Sep 17 00:00:00 2001 From: Robert Baker Date: Tue, 7 Jul 2015 16:56:45 -0700 Subject: [PATCH 5/5] fix header --- angular-material/angular-material.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angular-material/angular-material.d.ts b/angular-material/angular-material.d.ts index 21ff5a3fc..17f8328e1 100644 --- a/angular-material/angular-material.d.ts +++ b/angular-material/angular-material.d.ts @@ -1,6 +1,6 @@ // Type definitions for Angular Material 0.10.1-rc1+ (angular.material module) // Project: https://github.com/angular/material -// Definitions by: Matt Traynham and Robert Baker +// Definitions by: Matt Traynham // Definitions: https://github.com/borisyankov/DefinitelyTyped ///