|
| 1 | +// Type definitions for Angular JS 1.1.5+ (ui.router module) |
| 2 | +// Project: https://github.com/angular-ui/ui-router |
| 3 | +// Definitions by: Michel Salib <https://github.com/michelsalib> |
| 4 | +// Definitions: https://github.com/borisyankov/DefinitelyTyped |
| 5 | + |
| 6 | +declare module ng.ui { |
| 7 | + |
| 8 | + interface IState { |
| 9 | + name?: string; |
| 10 | + template?: string; |
| 11 | + templateUrl?: any; // string || () => string |
| 12 | + templateProvider?: any; // () => string || IPromise<string> |
| 13 | + controller?: any; |
| 14 | + controllerAs?: string; |
| 15 | + controllerProvider?: any; |
| 16 | + resolve?: {}; |
| 17 | + url?: string; |
| 18 | + params?: any[]; |
| 19 | + views?: {}; |
| 20 | + abstract?: boolean; |
| 21 | + onEnter?: (...args: any[]) => void; |
| 22 | + onExit?: (...args: any[]) => void; |
| 23 | + data?: any; |
| 24 | + } |
| 25 | + |
| 26 | + interface ITypedState<T> { |
| 27 | + name?: string; |
| 28 | + template?: string; |
| 29 | + templateUrl?: string; |
| 30 | + templateProvider?: () => string; |
| 31 | + controller?: any; |
| 32 | + controllerAs?: string; |
| 33 | + controllerProvider?: any; |
| 34 | + resolve?: {}; |
| 35 | + url?: string; |
| 36 | + params?: any[]; |
| 37 | + views?: {}; |
| 38 | + abstract?: boolean; |
| 39 | + onEnter?: (...args: any[]) => void; |
| 40 | + onExit?: (...args: any[]) => void; |
| 41 | + data?: T; |
| 42 | + } |
| 43 | + |
| 44 | + interface IStateProvider extends IServiceProvider { |
| 45 | + state(name: string, config: IState): IStateProvider; |
| 46 | + state(config: IState): IStateProvider; |
| 47 | + decorator(name?: string, decorator?: (state: IState, parent: Function) => any): any; |
| 48 | + } |
| 49 | + |
| 50 | + interface IUrlMatcher { |
| 51 | + concat(pattern: string): IUrlMatcher; |
| 52 | + exec(path: string, searchParams: {}): {}; |
| 53 | + parameters(): string[]; |
| 54 | + format(values: {}): string; |
| 55 | + } |
| 56 | + |
| 57 | + interface IUrlMatcherFactory { |
| 58 | + compile(pattern: string): IUrlMatcher; |
| 59 | + isMatcher(o: any): boolean; |
| 60 | + } |
| 61 | + |
| 62 | + interface IUrlRouterProvider extends IServiceProvider { |
| 63 | + when(whenPath: RegExp, handler: Function): IUrlRouterProvider; |
| 64 | + when(whenPath: RegExp, handler: any[]): IUrlRouterProvider; |
| 65 | + when(whenPath: RegExp, toPath: string): IUrlRouterProvider; |
| 66 | + when(whenPath: IUrlMatcher, hanlder: Function): IUrlRouterProvider; |
| 67 | + when(whenPath: IUrlMatcher, handler: any[]): IUrlRouterProvider; |
| 68 | + when(whenPath: IUrlMatcher, toPath: string): IUrlRouterProvider; |
| 69 | + when(whenPath: string, handler: Function): IUrlRouterProvider; |
| 70 | + when(whenPath: string, handler: any[]): IUrlRouterProvider; |
| 71 | + when(whenPath: string, toPath: string): IUrlRouterProvider; |
| 72 | + otherwise(handler: Function): IUrlRouterProvider; |
| 73 | + otherwise(handler: any[]): IUrlRouterProvider; |
| 74 | + otherwise(path: string): IUrlRouterProvider; |
| 75 | + rule(handler: Function): IUrlRouterProvider; |
| 76 | + rule(handler: any[]): IUrlRouterProvider; |
| 77 | + } |
| 78 | + |
| 79 | + interface IStateOptions { |
| 80 | + location?: any; |
| 81 | + inherit?: boolean; |
| 82 | + relative?: IState; |
| 83 | + notify?: boolean; |
| 84 | + } |
| 85 | + |
| 86 | + interface IHrefOptions { |
| 87 | + lossy?: boolean; |
| 88 | + inherit?: boolean; |
| 89 | + relative?: IState; |
| 90 | + absolute?: boolean; |
| 91 | + } |
| 92 | + |
| 93 | + interface IStateService { |
| 94 | + go(to: string, params?: {}, options?: IStateOptions): IPromise<any>; |
| 95 | + transitionTo(state: string, params?: {}, updateLocation?: boolean): void; |
| 96 | + transitionTo(state: string, params?: {}, options?: IStateOptions): void; |
| 97 | + includes(state: string, params?: {}): boolean; |
| 98 | + is(state:string, params?: {}): boolean; |
| 99 | + is(state: IState, params?: {}): boolean; |
| 100 | + href(state: IState, params?: {}, options?: IHrefOptions): string; |
| 101 | + href(state: string, params?: {}, options?: IHrefOptions): string; |
| 102 | + get(state: string): IState; |
| 103 | + get(): IState[]; |
| 104 | + current: IState; |
| 105 | + params: any; |
| 106 | + reload(): void; |
| 107 | + } |
| 108 | + |
| 109 | + interface IStateParamsService { |
| 110 | + [key: string]: any; |
| 111 | + } |
| 112 | + |
| 113 | + interface IStateParams { |
| 114 | + [key: string]: any; |
| 115 | + } |
| 116 | + |
| 117 | + interface IUrlRouterService { |
| 118 | + /* |
| 119 | + * Triggers an update; the same update that happens when the address bar |
| 120 | + * url changes, aka $locationChangeSuccess. |
| 121 | + * |
| 122 | + * This method is useful when you need to use preventDefault() on the |
| 123 | + * $locationChangeSuccess event, perform some custom logic (route protection, |
| 124 | + * auth, config, redirection, etc) and then finally proceed with the transition |
| 125 | + * by calling $urlRouter.sync(). |
| 126 | + * |
| 127 | + */ |
| 128 | + sync(): void; |
| 129 | + } |
| 130 | + |
| 131 | + interface IUiViewScrollProvider { |
| 132 | + /* |
| 133 | + * Reverts back to using the core $anchorScroll service for scrolling |
| 134 | + * based on the url anchor. |
| 135 | + */ |
| 136 | + useAnchorScroll(): void; |
| 137 | + } |
| 138 | +} |
0 commit comments