forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
navigation.d.ts
1190 lines (1165 loc) · 43.1 KB
/
navigation.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Type definitions for Navigation 1.3.0
// Project: http://grahammendick.github.io/navigation/
// Definitions by: Graham Mendick <https://github.com/grahammendick>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module 'navigation' {
export = Navigation;
}
declare module Navigation {
/**
* Defines a contract a class must implement in order to represent a
* logical grouping of child State elements. Navigating across different
* dialogs will initialise the crumb trail
*/
interface IDialog<TState, TStates> {
/**
* Gets the State children
*/
states: TStates;
/**
* Gets the state to navigate to if the Key is passed as an action
* parameter to the StateController
*/
initial: TState;
/**
* Gets the key, unique across dialogs, which is passed as the action
* parameter to the StateController when navigating
*/
key: string;
/**
* Gets the textual description of the dialog
*/
title?: string;
/**
* Gets the additional dialog attributes
*/
[extras: string]: any;
}
/**
* Defines a contract a class must implement in order to configure state
* information. A child of a Dialog element, it represents the endpoint of
* a navigation
*/
interface IState<TTransitions> {
/**
* Gets the Transition children
*/
transitions?: TTransitions;
/**
* Gets the key, unique within a Parent, used by Dialog and Transition
* elements to specify navigation configuration
*/
key: string;
/**
* Gets the default NavigationData for this State
*/
defaults?: any;
/**
* Gets the default NavigationData Types for this State
*/
defaultTypes?: any;
/**
* Gets the textual description of the state
*/
title?: string;
/**
* Gets the route Url patterns
*/
route: string | string[];
/**
* Gets a value that indicates whether to maintain crumb trail
* information e.g PreviousState. This can be used together with Route
* to produce user friendly Urls
*/
trackCrumbTrail?: boolean;
/**
* Gets a value that indicates whether NavigationData Types are
* preserved when navigating
*/
trackTypes?: boolean;
/**
* Gets the additional state attributes
*/
[extras: string]: any;
}
/**
* Defines a contract a class must implement in order to configure
* transition information. A child of a State element it represents a
* possible navigation from its Parent to a sibling State
*/
interface ITransition<TState> {
/**
* Gets the state to navigate to if the Key is passed as an action
* parameter to the StateController
*/
to: TState;
/**
* Gets the key, unique within a Parent, which is passed as the action
* parameter to the StateController when navigating
*/
key: string;
}
/**
* Configures dialog information. Represents a logical grouping of child
* State elements. Navigating across different dialogs will initialise the
* crumb trail
*/
class Dialog implements IDialog<State, { [index: string]: State; }> {
/**
* Gets the State children by index
*/
_states: State[];
/**
* Gets the State children
*/
states: {
[index: string]: State;
};
/**
* Gets the number of the dialog
*/
index: number;
/**
* Gets the state to navigate to if the Key is passed as an action
* parameter to the StateController
*/
initial: State;
/**
* Gets the key, unique across dialogs, which is passed as the action
* parameter to the StateController when navigating
*/
key: string;
/**
* Gets the textual description of the dialog
*/
title: string;
}
/**
* Configures state information. A child of a Dialog element, it
* represents the endpoint of a navigation
*/
class State implements IState<{ [index: string]: Transition; }> {
/**
* Gets the Transition children by index
*/
_transitions: Transition[];
/**
* Gets the Transition children
*/
transitions: {
[index: string]: Transition;
};
/**
* Gets the parent Dialog configuration item
*/
parent: Dialog;
/**
* Gets the number of the state within its Parent
*/
index: number;
/**
* Gets the unique identifier for this State
*/
id: string;
/**
* Gets the key, unique within a Parent, used by Dialog and Transition
* elements to specify navigation configuration
*/
key: string;
/**
* Gets the default NavigationData for this State
*/
defaults: any;
/**
* Gets the default NavigationData Types for this State
*/
defaultTypes: any;
/**
* Gets the formatted default NavigationData for this State
*/
formattedDefaults: any;
/**
* Gets the textual description of the state
*/
title: string;
/**
* Gets the route Url patterns
*/
route: string | string[];
/**
* Gets a value that indicates whether to maintain crumb trail
* information e.g PreviousState. This can be used together with Route
* to produce user friendly Urls
*/
trackCrumbTrail: boolean;
/**
* Gets a value that indicates whether NavigationData Types are
* preserved when navigating
*/
trackTypes: boolean;
/**
* Gets or sets the IStateHandler responsible for building and parsing
* navigation links to this State
*/
stateHandler: IStateHandler;
/**
* Called on the old State (this is not the same as the previous
* State) before navigating to a different State
* @param state The new State
* @param data The new NavigationData
* @param url The new target location
* @param unload The function to call to continue to navigate
* @param history A value indicating whether browser history was used
*/
unloading: (state: State, data: any, url: string, unload: () => void, history?: boolean) => void;
/**
* Called on the old State (this is not the same as the previous
* State) after navigating to a different State
*/
dispose: () => void;
/**
* Called on the current State after navigating to it
* @param data The current NavigationData
* @param asyncData The data passed asynchronously while navigating
*/
navigated: (data: any, asyncData?: any) => void;
/**
* Called on the new State before navigating to it
* @param data The new NavigationData
* @param url The new target location
* @param navigate The function to call to continue to navigate
* @param history A value indicating whether browser history was used
*/
navigating: (data: any, url: string, navigate: (asyncData?: any) => void, history?: boolean) => void;
}
/**
* Configures transition information. A child of a State element it
* represents a possible navigation from its Parent to a sibling State
*/
class Transition implements ITransition<State> {
/**
* Gets the state to navigate to if the Key is passed as an action
* parameter to the StateController
*/
to: State;
/**
* Gets the parent State configuration item
*/
parent: State;
/**
* Gets the number of the transition within its Parent
*/
index: number;
/**
* Gets the key, unique within a Parent, which is passed as the action
* parameter to the StateController when navigating
*/
key: string;
}
/**
* Provides static access to the Dialog, State and Transition configuration
*/
class StateInfoConfig {
/**
* Gets a collection of Dialog information, by index, with their child
* State information and grandchild Transition information
*/
static _dialogs: Dialog[];
/**
* Gets a collection of Dialog information with their child State
* information and grandchild Transition information
*/
static dialogs: {
[index: string]: Dialog;
};
/**
* Builds the Dialog, State and Transition configuration
* @param dialogs A collection of Dialog information with their child
* State information and grandchild Transition information
*/
static build(dialogs: IDialog<string, IState<ITransition<string>[]>[]>[]): void;
}
/**
* Determines the effect on browser history after a successful navigation
*/
enum HistoryAction {
/**
* Creates a new browser history entry
*/
Add = 0,
/**
* Changes the current browser history entry
*/
Replace = 1,
/**
* Leaves browser history unchanged
*/
None = 2,
}
/**
* Defines a contract a class must implement in order to manage the browser
* Url
*/
interface IHistoryManager {
/**
* Gets or sets a value indicating whether to disable browser history
*/
disabled: boolean;
/**
* Registers browser history event listeners
*/
init(): any;
/**
* Adds browser history
* @param state The State navigated to
* @param url The current url
*/
addHistory(state: State, url: string): void;
/**
* Adds browser history
* @param state The State navigated to
* @param url The current url
* @param replace A value indicating whether to replace the current
* browser history entry
*/
addHistory(state: State, url: string, replace: boolean): void;
/**
* Gets the current location
*/
getCurrentUrl(): string;
/**
* Gets an Href from the url
*/
getHref(url: string): string;
/**
* Gets a Url from the anchor
*/
getUrl(anchor: HTMLAnchorElement): string;
}
/**
* Manages history using the browser Url's hash. If used in a browser
* without the hashchange event or outside of a browser environment, then
* history is disabled
*/
class HashHistoryManager implements IHistoryManager {
/**
* Gets or sets a value indicating whether to disable browser history.
* Set to true if used in a browser without the hashchange event or
* outside of a browser environment
*/
disabled: boolean;
/**
* Gets or sets a value indicating whether to use '#' in place of '?'
* in Urls. Set to true for Internet explorer 6 and 7 support
*/
replaceQueryIdentifier: boolean;
/**
* Registers a listener for the hashchange event
*/
init(): void;
/**
* Sets the browser Url's hash to the url
* @param state The State navigated to
* @param url The current url
*/
addHistory(state: State, url: string): void;
/**
* Sets the browser Url's hash to the url
* @param state The State navigated to
* @param url The current url
* @param replace A value indicating whether to replace the current
* browser history entry
*/
addHistory(state: State, url: string, replace: boolean): void;
/**
* Gets the current location
*/
getCurrentUrl(): string;
/**
* Gets an Href from the url
*/
getHref(url: string): string;
/**
* Gets a Url from the anchor
*/
getUrl(anchor: HTMLAnchorElement): string;
}
/**
* Manages history using the HTML5 history api. If used in a browser
* without the HTML5 history api or outside of a browser environment, then
* history is disabled
*/
class HTML5HistoryManager implements IHistoryManager {
/**
* Gets or sets a value indicating whether to disable browser history.
* Set to true if used in a browser without the HTML5 history api or
* outside of a browser environment
*/
disabled: boolean;
/**
* Registers a listener for the popstate event
*/
init(): void;
/**
* Sets the browser Url to the url using pushState
* @param state The State navigated to
* @param url The current url
*/
addHistory(state: State, url: string): void;
/**
* Sets the browser Url to the url using pushState
* @param state The State navigated to
* @param url The current url
* @param replace A value indicating whether to replace the current
* browser history entry
*/
addHistory(state: State, url: string, replace: boolean): void;
/**
* Gets the current location
*/
getCurrentUrl(): string;
/**
* Gets an Href from the url
*/
getHref(url: string): string;
/**
* Gets a Url from the anchor
*/
getUrl(anchor: HTMLAnchorElement): string;
}
/**
* Provides the base functionality for crumb trail persistence mechanisms
*/
class CrumbTrailPersister {
/**
* Overridden by derived classes to return the persisted crumb trail
* @param crumbTrail The key, returned from the save function, to
* identify the persisted crumb trail
* @returns The crumb trail holding navigation and data information
*/
load(crumbTrail: string): string;
/**
* Overridden by derived classes to persist the crumb trail
* @param crumbTrail The crumb trail holding navigation and data
* information
* @returns The key to be passed to load function for crumb trail
* retrieval
*/
save(crumbTrail: string): string;
}
/**
* Persists crumb trails, over a specified length, in localStorage.
* Prevents the creation of unmanageably long Urls. If used in a browser
* without localStorage or outside of a browser environment, then in memory
* storage is used
*/
class StorageCrumbTrailPersister extends CrumbTrailPersister {
/**
* Initializes a new instance of the StorageCrumbTrailPersister class
* with a maxLength of 500, historySize of 100 and localStorage as the
* storage mechanism
*/
constructor();
/**
* Initializes a new instance of the StorageCrumbTrailPersister class
* with a historySize of 100 and localStorage as the storage mechanism
* @param maxLength The length above which any crumb trail will be
* stored in localStorage
*/
constructor(maxLength: number);
/**
* Initializes a new instance of the StorageCrumbTrailPersister class
* with localStorage as the storage mechanism
* @param maxLength The length above which any crumb trail will be
* stored in localStorage
* @param historySize The maximum number of crumb trails that will be
* held at any one time in localStorage
*/
constructor(maxLength: number, historySize: number);
/**
* Initializes a new instance of the StorageCrumbTrailPersister class
* @param maxLength The length above which any crumb trail will be
* stored in the storage
* @param historySize The maximum number of crumb trails that will be
* held at any one time in the storage
* @param storage The storage mechanism
*/
constructor(maxLength: number, historySize: number, storage: Storage);
/**
* Uses the crumbTrail parameter to determine whether to retrieve the
* crumb trail from storage. If retrieved from storage it may be null
* @param Key generated by the save function
* @returns Either the crumbTrail or the one retrieved value from
* storage; can be null if retrieved from storage
*/
load(crumbTrail: string): string;
/**
* If the crumbTrail is not over the maxLength it is returned.
* Otherwise the crumbTrail is stored in storage using a short key,
* unique within a given storage session. Also expunges old items from
* storage, if the historySize is breached when a new item is added
* @param crumbTrail The crumb trail to persist
* @returns crumbTrail or short, generated key pointing at crumbTrail
*/
save(crumbTrail: string): string;
}
/**
* Defines a contract a class must implement in order to build and parse
* navigation links
*/
interface IStateHandler {
/**
* Gets a link that navigates to the state passing the data
* @param state The State to navigate to
* @param data The data to pass when navigating
* @returns The navigation link
*/
getNavigationLink(state: State, data: any): string;
/**
* Gets a link that navigates to the state passing the data
* @param state The State to navigate to
* @param data The data to pass when navigating
* @param queryStringData The query string array data
* @returns The navigation link
*/
getNavigationLink(state: State, data: any, queryStringData: { [index: string]: string[]; }): string;
/**
* Navigates to the url
* @param oldState The current State
* @param state The State to navigate to
* @param url The target location
*/
navigateLink(oldState: State, state: State, url: string): void;
/**
* Gets the data parsed from the url
* @param state The State navigated to
* @param url The current url
* @returns The navigation data
*/
getNavigationData(state: State, url: string): any;
/**
* Gets the data parsed from the url
* @param state The State navigated to
* @param url The current url
* @param queryStringData Stores query string keys
* @returns The navigation data
*/
getNavigationData(state: State, url: string, queryStringData: any): any;
/**
* Encodes the Url value
* @param state The State navigated to
* @param key The key of the navigation data item
* @param val The Url value of the navigation data item
* @param queryString A value indicating the Url value's location
*/
urlEncode?(state: State, key: string, val: string, queryString: boolean): string;
/**
* Decodes the Url value
* @param state The State navigated to
* @param key The key of the navigation data item
* @param val The Url value of the navigation data item
* @param queryString A value indicating the Url value's location
*/
urlDecode?(state: State, key: string, val: string, queryString: boolean): string;
/**
* Truncates the crumb trail
* @param The State navigated to
* @param The Crumb collection representing the crumb trail
* @returns Truncated crumb trail
*/
truncateCrumbTrail(state: State, crumbs: Crumb[]): Crumb[];
}
/**
* Represents one piece of the crumb trail and holds the information need
* to return to and recreate the State as previously visited. In a single
* crumb trail no two crumbs can have the same State but all must have the
* same Dialog
*/
class Crumb {
/**
* Gets the Context Data held at the time of navigating away from this
* State
*/
data: any;
/**
* Gets the configuration information associated with this navigation
*/
state: State;
/**
* Gets a value indicating whether the Crumb is the last in the crumb
* trail
*/
last: boolean;
/**
* Gets the State Title
*/
title: string;
/**
* Gets the hyperlink navigation to return to the State and pass the
* associated Data
*/
navigationLink: string;
/**
* Initializes a new instance of the Crumb class
* @param data The Context Data held at the time of navigating away
* from this State
* @param state The configuration information associated with this
* navigation
* @param link The hyperlink navigation to return to the State and pass
* the associated Data
* @param last A value indicating whether the Crumb is the last in the
* crumb trail
*/
constructor(data: any, state: State, link: string, last: boolean);
}
/**
* Provides access to the Navigation Settings configuration
*/
class NavigationSettings {
/**
* Gets or sets the builder and parser of State routes
*/
router: IRouter;
/**
* Gets or sets the manager of the browser Url
*/
historyManager: IHistoryManager;
/**
* Gets or sets the crumb trail persistence mechanism
*/
crumbTrailPersister: CrumbTrailPersister;
/**
* Gets or sets the key that identifies the StateId
*/
stateIdKey: string;
/**
* Gets or sets the key that identifies the PreviousStateId
*/
previousStateIdKey: string;
/**
* Gets or sets the key that identifies the ReturnData
*/
returnDataKey: string;
/**
* Gets or sets the key that identifies the CrumbTrail
*/
crumbTrailKey: string;
/**
* Gets or sets the application path
*/
applicationPath: string;
/**
* Gets or sets a value indicating whether the PreviousStateId and
* ReturnData should be part of the CrumbTrail
*/
combineCrumbTrail: boolean;
/**
* Gets or sets a value indicating whether to track PreviousData when
* navigating back or refreshing and combineCrumbTrail is false
*/
trackAllPreviousData: boolean;
/**
* Gets or sets a value indicating whether arrays should be stored in
* a single query string parameter
*/
combineArray: boolean;
}
/**
* Provides static properties for accessing context sensitive navigation
* information. Holds the current State and NavigationData. Also holds the
* previous State (this is not the same as the previous Crumb)
*/
class StateContext {
/**
* Gets the last State displayed before the current State
*/
static oldState: State;
/**
* Gets the parent of the OldState property
*/
static oldDialog: Dialog;
/**
* Gets the NavigationData for the last displayed State
*/
static oldData: any;
/**
* Gets the State navigated away from to reach the current State
*/
static previousState: State;
/**
* Gets the parent of the PreviousState property
*/
static previousDialog: Dialog;
/**
* Gets the NavigationData for the navigated away from State
*/
static previousData: any;
/**
* Gets the current State
*/
static state: State;
/**
* Gets the parent of the State property
*/
static dialog: Dialog;
/**
* Gets the NavigationData for the current State
*/
static data: any;
/**
* Gets the current Url
*/
static url: string;
/**
* Gets or sets the current title
*/
static title: string;
/**
* Combines the data with all the current NavigationData
* @param The data to add to the current NavigationData
* @returns The combined data
*/
static includeCurrentData(data: any): any;
/**
* Combines the data with a subset of the current NavigationData
* @param The data to add to the current NavigationData
* @returns The combined data
*/
static includeCurrentData(data: any, keys: string[]): any;
/**
* Removes all items from the NavigationData
*/
static clear(): void;
/**
* Removes a single item from the NavigationData
* @param The key of the item to remove
*/
static clear(key: string): void;
}
/**
* Manages all navigation. These can be forward using an action parameter;
* backward via a Crumb; or refreshing the current State
*/
class StateController {
/**
* Gets a Crumb collection representing the crumb trail, ordered oldest
* Crumb first
*/
static crumbs: Crumb[];
/**
* Sets the Context Data with the data returned from the current
* State's IStateHandler
* @param state The current State
* @param url The current Url
*/
static setStateContext(state: State, url: string): void;
/**
* Clears the Context Data
*/
static clearStateContext(): void;
/**
* Registers a navigate event listener
* @param handler The navigate event listener
*/
static onNavigate(handler: (oldState: State, state: State, data: any) => void): void;
/**
* Unregisters a navigate event listener
* @param handler The navigate event listener
*/
static offNavigate(handler: (oldState: State, state: State, data: any) => void): void;
/**
* Navigates to a State. Depending on the action will either navigate
* to the 'to' State of a Transition or the 'initial' State of a
* Dialog. It passes no NavigationData
* @param action The key of a child Transition or the key of a Dialog
* @throws action does not match the key of a child Transition or the
* key of a Dialog; or there is NavigationData that cannot be converted
* to a String
* @throws A mandatory route parameter has not been supplied a value
*/
static navigate(action: string): void;
/**
* Navigates to a State. Depending on the action will either navigate
* to the 'to' State of a Transition or the 'initial' State of a
* Dialog
* @param action The key of a child Transition or the key of a Dialog
* @param toData The NavigationData to be passed to the next State and
* stored in the StateContext
* @throws action does not match the key of a child Transition or the
* key of a Dialog; or there is NavigationData that cannot be converted
* to a String
* @throws A mandatory route parameter has not been supplied a value
*/
static navigate(action: string, toData: any): void;
/**
* Navigates to a State. Depending on the action will either navigate
* to the 'to' State of a Transition or the 'initial' State of a
* Dialog
* @param action The key of a child Transition or the key of a Dialog
* @param toData The NavigationData to be passed to the next State and
* stored in the StateContext
* @param A value determining the effect on browser history
* @throws action does not match the key of a child Transition or the
* key of a Dialog; or there is NavigationData that cannot be converted
* to a String
* @throws A mandatory route parameter has not been supplied a value
*/
static navigate(action: string, toData: any, historyAction: HistoryAction): void;
/**
* Gets a Url to navigate to a State. Depending on the action will
* either navigate to the 'to' State of a Transition or the 'initial'
* State of a Dialog. It passes no NavigationData
* @param action The key of a child Transition or the key of a Dialog
* @returns Url that will navigate to State specified in the action
* @throws action does not match the key of a child Transition or the
* key of a Dialog; or there is NavigationData that cannot be converted
* to a String
*/
static getNavigationLink(action: string): string;
/**
* Gets a Url to navigate to a State. Depending on the action will
* either navigate to the 'to' State of a Transition or the 'initial'
* State of a Dialog
* @param action The key of a child Transition or the key of a Dialog
* @param toData The NavigationData to be passed to the next State and
* stored in the StateContext
* @returns Url that will navigate to State specified in the action
* @throws action does not match the key of a child Transition or the
* key of a Dialog; or there is NavigationData that cannot be converted
* to a String
*/
static getNavigationLink(action: string, toData: any): string;
/**
* Determines if the distance specified is within the bounds of the
* crumb trail represented by the Crumbs collection
*/
static canNavigateBack(distance: number): boolean;
/**
* Navigates back to the Crumb contained in the crumb trail,
* represented by the Crumbs collection, as specified by the distance.
* In the crumb trail no two crumbs can have the same State but all
* must have the same Dialog
* @param distance Starting at 1, the number of Crumb steps to go back
* @throws canNavigateBack returns false for this distance
* @throws A mandatory route parameter has not been supplied a value
*/
static navigateBack(distance: number): void;
/**
* Navigates back to the Crumb contained in the crumb trail,
* represented by the Crumbs collection, as specified by the distance.
* In the crumb trail no two crumbs can have the same State but all
* must have the same Dialog
* @param distance Starting at 1, the number of Crumb steps to go back
* @param A value determining the effect on browser history
* @throws canNavigateBack returns false for this distance
* @throws A mandatory route parameter has not been supplied a value
*/
static navigateBack(distance: number, historyAction: HistoryAction): void;
/**
* Gets a Url to navigate to a Crumb contained in the crumb trail,
* represented by the Crumbs collection, as specified by the distance.
* In the crumb trail no two crumbs can have the same State but all
* must have the same Dialog
* @param distance Starting at 1, the number of Crumb steps to go back
* @throws canNavigateBack returns false for this distance
*/
static getNavigationBackLink(distance: number): string;
/**
* Navigates to the current State passing no NavigationData
* @throws A mandatory route parameter has not been supplied a value
*/
static refresh(): void;
/**
* Navigates to the current State
* @param toData The NavigationData to be passed to the current State
* and stored in the StateContext
* @throws There is NavigationData that cannot be converted to a String
* @throws A mandatory route parameter has not been supplied a value
*/
static refresh(toData: any): void;
/**
* Navigates to the current State
* @param toData The NavigationData to be passed to the current State
* and stored in the StateContext
* @param A value determining the effect on browser history
* @throws There is NavigationData that cannot be converted to a String
* @throws A mandatory route parameter has not been supplied a value
*/
static refresh(toData: any, historyAction: HistoryAction): void;
/**
* Gets a Url to navigate to the current State passing no
* NavigationData
*/
static getRefreshLink(): string;
/**
* Gets a Url to navigate to the current State
* @param toData The NavigationData to be passed to the current State
* and stored in the StateContext
* @returns Url that will navigate to the current State
* @throws There is NavigationData that cannot be converted to a String
*/
static getRefreshLink(toData: any): string;
/**
* Navigates to the url
* @param url The target location
*/
static navigateLink(url: string): void;
/**
* Navigates to the url
* @param url The target location
* @param history A value indicating whether browser history was used
*/
static navigateLink(url: string, history: boolean): void;
/**
* Navigates to the url
* @param url The target location
* @param history A value indicating whether browser history was used
* @param A value determining the effect on browser history
*/
static navigateLink(url: string, history: boolean, historyAction: HistoryAction): void;
/**
* Gets the next State. Depending on the action will either return the
* 'to' State of a Transition or the 'initial' State of a Dialog
* @param action The key of a child Transition or the key of a Dialog
* @throws action does not match the key of a child Transition or the
* key of a Dialog
*/
static getNextState(action: string): State;
}
/**
* Implementation of IStateHandler that builds and parses navigation links
*/
class StateHandler implements IStateHandler {
/**
* Gets a link that navigates to the state passing the data
* @param state The State to navigate to
* @param data The data to pass when navigating
* @returns The navigation link
*/
getNavigationLink(state: State, data: any): string;
/**
* Gets a link that navigates to the state passing the data
* @param state The State to navigate to
* @param data The data to pass when navigating
* @param queryStringData The query string array data
* @returns The navigation link
*/
getNavigationLink(state: State, data: any, queryStringData: { [index: string]: string[]; }): string;
/**
* Navigates to the url
* @param oldState The current State
* @param state The State to navigate to
* @param url The target location
*/
navigateLink(oldState: State, state: State, url: string): void;
/**
* Gets the data parsed from the url
* @param state The State navigated to
* @param url The current url
* @returns The navigation data
*/
getNavigationData(state: State, url: string): any;
/**
* Gets the data parsed from the url
* @param state The State navigated to
* @param url The current url
* @param queryStringData Stores query string keys
* @returns The navigation data
*/
getNavigationData(state: State, url: string, queryStringData: any): any;
/**
* Encodes the Url value
* @param state The State navigated to
* @param key The key of the navigation data item
* @param val The Url value of the navigation data item
* @param queryString A value indicating the Url value's location
*/
urlEncode(state: State, key: string, val: string, queryString: boolean): string;
/**
* Decodes the Url value
* @param state The State navigated to
* @param key The key of the navigation data item