@@ -3,125 +3,21 @@ import {
3
3
extend , defaults , copy , equalForKeys , forEach , find , prop ,
4
4
propEq , ancestors , noop , isDefined , isObject , isString , values
5
5
} from "../common/common" ;
6
- import { Queue } from "../common/queue" ;
7
- import { IServiceProviderFactory , IPromise } from "angular" ;
6
+ import { Queue } from "../common/module" ;
8
7
8
+ import { IServiceProviderFactory , IPromise } from "angular" ;
9
9
import { StateService , StateDeclaration , StateOrName , HrefOptions , ViewDeclaration } from "./interface" ;
10
- import { Glob , StateQueueManager , StateBuilder , StateMatcher , TargetState } from "./module" ;
11
-
12
10
import { ITransitionService , TransitionOptions , TreeChanges } from "../transition/interface" ;
13
- import { Transition , RejectFactory , defaultTransOpts } from "../transition/module " ;
11
+ import { RawParams , ParamsOrArray } from "../params/interface " ;
14
12
13
+ import { Glob , StateQueueManager , StateBuilder , StateMatcher , State , TargetState } from "./module" ;
14
+ import { Transition , RejectFactory , defaultTransOpts } from "../transition/module" ;
15
15
import { PathFactory , Node } from "../path/module" ;
16
-
17
- import { RawParams , ParamsOrArray } from "../params/interface" ;
18
16
import { TransitionManager } from "./hooks/transitionManager" ;
19
-
20
17
import { paramTypes , Param , Type , StateParams } from "../params/module" ;
21
-
22
18
import { UrlMatcher } from "../url/urlMatcher" ;
23
19
import { ViewConfig } from "../view/view" ;
24
20
25
- /**
26
- * @ngdoc object
27
- * @name ui.router.state.type:State
28
- *
29
- * @description
30
- * Definition object for states. Includes methods for manipulating the state heirarchy.
31
- *
32
- * @param {Object } config A configuration object hash that includes the results of user-supplied
33
- * values, as well as values from `StateBuilder`.
34
- *
35
- * @returns {Object } Returns a new `State` object.
36
- */
37
- export class State {
38
-
39
- public parent : State ;
40
- public name : string ;
41
- public abstract : boolean ;
42
- public resolve : { [ key : string ] : Function ; } ;
43
- public resolvePolicy : any ;
44
- public url : UrlMatcher ;
45
- public params : { [ key : string ] : Param } ;
46
- public views : { [ key : string ] : ViewDeclaration ; } ;
47
- public self : StateDeclaration ;
48
- public navigable : State ;
49
- public path : State [ ] ;
50
- public data : any ;
51
- public includes : ( name : string ) => boolean ;
52
-
53
- constructor ( config ?: StateDeclaration ) {
54
- extend ( this , config ) ;
55
- // Object.freeze(this);
56
- }
57
-
58
- /**
59
- * @ngdoc function
60
- * @name ui.router.state.type:State#is
61
- * @methodOf ui.router.state.type:State
62
- *
63
- * @description
64
- * Compares the identity of the state against the passed value, which is either an object
65
- * reference to the actual `State` instance, the original definition object passed to
66
- * `$stateProvider.state()`, or the fully-qualified name.
67
- *
68
- * @param {Object } ref Can be one of (a) a `State` instance, (b) an object that was passed
69
- * into `$stateProvider.state()`, (c) the fully-qualified name of a state as a string.
70
- * @returns {boolean } Returns `true` if `ref` matches the current `State` instance.
71
- */
72
- is ( ref : State | StateDeclaration | string ) : boolean {
73
- return this === ref || this . self === ref || this . fqn ( ) === ref ;
74
- }
75
-
76
- /**
77
- * @ngdoc function
78
- * @name ui.router.state.type:State#fqn
79
- * @methodOf ui.router.state.type:State
80
- *
81
- * @description
82
- * Returns the fully-qualified name of the state, based on its current position in the tree.
83
- *
84
- * @returns {string } Returns a dot-separated name of the state.
85
- */
86
- fqn ( ) : string {
87
- if ( ! this . parent || ! ( this . parent instanceof this . constructor ) ) return this . name ;
88
- let name = this . parent . fqn ( ) ;
89
- return name ? name + "." + this . name : this . name ;
90
- }
91
-
92
- /**
93
- * @ngdoc function
94
- * @name ui.router.state.type:State#root
95
- * @methodOf ui.router.state.type:State
96
- *
97
- * @description
98
- * Returns the root node of this state's tree.
99
- *
100
- * @returns {State } The root of this state's tree.
101
- */
102
- root ( ) : State {
103
- return this . parent && this . parent . root ( ) || this ;
104
- }
105
-
106
- parameters ( opts ?) : Param [ ] {
107
- opts = defaults ( opts , { inherit : true } ) ;
108
- var inherited = opts . inherit && this . parent && this . parent . parameters ( ) || [ ] ;
109
- return inherited . concat ( values ( this . params ) ) ;
110
- }
111
-
112
- parameter ( id : string , opts : any = { } ) : Param {
113
- return (
114
- this . url && this . url . parameter ( id , opts ) ||
115
- find ( values ( this . params ) , propEq ( 'id' , id ) ) ||
116
- opts . inherit && this . parent && this . parent . parameter ( id )
117
- ) ;
118
- }
119
-
120
- toString ( ) {
121
- return this . fqn ( ) ;
122
- }
123
- }
124
-
125
21
/**
126
22
* @ngdoc object
127
23
* @name ui.router.state.$stateProvider
0 commit comments