@ngrdt/router 0.0.8 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +229 -28
- package/esm2022/lib/rdt-route/rdt-angular-route.mjs +11 -3
- package/esm2022/lib/rdt-route/rdt-route-builder.mjs +5 -1
- package/esm2022/lib/rdt-route/rdt-route.mjs +100 -14
- package/esm2022/lib/rdt-route/utils.mjs +15 -2
- package/esm2022/lib/services/rdt-router.service.mjs +3 -2
- package/fesm2022/ngrdt-router.mjs +127 -15
- package/fesm2022/ngrdt-router.mjs.map +1 -1
- package/lib/rdt-route/rdt-route-builder.d.ts +2 -0
- package/lib/rdt-route/rdt-route.d.ts +91 -4
- package/lib/rdt-route/utils.d.ts +8 -0
- package/lib/services/rdt-router.service.d.ts +5 -4
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ParamMapping, ParamTypeMap } from './utils';
|
|
2
|
-
import { Params } from '@angular/router';
|
|
3
|
-
import { RdtAngularRoute } from './rdt-angular-route';
|
|
4
1
|
import { Injector } from '@angular/core';
|
|
2
|
+
import { Data, Params } from '@angular/router';
|
|
3
|
+
import { RdtAngularRoute } from './rdt-angular-route';
|
|
4
|
+
import { ParamMapping, ParamTypeMap, RdtReadonlyParameters } from './utils';
|
|
5
5
|
export declare function ALWAYS_TRUE(): boolean;
|
|
6
6
|
export declare class RdtRoute<T extends object = any> {
|
|
7
7
|
protected orderedParams: string[];
|
|
@@ -11,6 +11,7 @@ export declare class RdtRoute<T extends object = any> {
|
|
|
11
11
|
protected _staticParams: Partial<T>;
|
|
12
12
|
protected _queryParams: Params;
|
|
13
13
|
protected _stateParams: Params;
|
|
14
|
+
protected _data: Data;
|
|
14
15
|
protected _name: string;
|
|
15
16
|
protected _path: string;
|
|
16
17
|
protected _parent: RdtRoute | null;
|
|
@@ -18,33 +19,119 @@ export declare class RdtRoute<T extends object = any> {
|
|
|
18
19
|
protected _entryDisabled: boolean;
|
|
19
20
|
protected _canBeEntered: () => boolean;
|
|
20
21
|
private _absoluteRegex?;
|
|
22
|
+
/**
|
|
23
|
+
* Map of parameters and their types.
|
|
24
|
+
*/
|
|
21
25
|
get paramMap(): Readonly<ParamTypeMap<T>>;
|
|
26
|
+
/**
|
|
27
|
+
* Human readable name for display in breadcrumbs, title, etc.
|
|
28
|
+
*/
|
|
22
29
|
get name(): string;
|
|
30
|
+
/**
|
|
31
|
+
* Path of the route relative to parent route.
|
|
32
|
+
*/
|
|
23
33
|
get path(): string;
|
|
34
|
+
/**
|
|
35
|
+
* Parent route.
|
|
36
|
+
*/
|
|
24
37
|
get parent(): RdtRoute<any> | null;
|
|
38
|
+
/**
|
|
39
|
+
* Child routes.
|
|
40
|
+
*/
|
|
25
41
|
get children(): RdtRoute<any>[];
|
|
42
|
+
/**
|
|
43
|
+
* Absolute path of parent route or '/' if there is no parent.
|
|
44
|
+
* Hostname excluded.
|
|
45
|
+
*/
|
|
26
46
|
get basePath(): string;
|
|
47
|
+
/**
|
|
48
|
+
* Absolute path of the route. Hostname excluded.
|
|
49
|
+
*/
|
|
27
50
|
get absolutePath(): string;
|
|
51
|
+
/**
|
|
52
|
+
* Regular expression route path relative to parent route.
|
|
53
|
+
* Hostname excluded.
|
|
54
|
+
*/
|
|
28
55
|
get regex(): RegExp;
|
|
56
|
+
/**
|
|
57
|
+
* Regular expression to match only this route (not children
|
|
58
|
+
* or parent routes). Hostname excluded.
|
|
59
|
+
*/
|
|
29
60
|
get absoluteRegex(): RegExp;
|
|
61
|
+
/**
|
|
62
|
+
* Denotes disabled route entry.
|
|
63
|
+
* If true, route should have no NgModule
|
|
64
|
+
* or component and only serves as virtual module
|
|
65
|
+
* for breadcrumb.
|
|
66
|
+
*/
|
|
30
67
|
get entryDisabled(): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Statically set state params used when navigating to this instance.
|
|
70
|
+
*/
|
|
31
71
|
get stateParams(): Params;
|
|
72
|
+
/**
|
|
73
|
+
* Statically set query params used when navigating to this instance.
|
|
74
|
+
*/
|
|
32
75
|
get queryParams(): Params;
|
|
76
|
+
/**
|
|
77
|
+
* @param url Absolute path to test.
|
|
78
|
+
* @returns True if url matches this route.
|
|
79
|
+
*/
|
|
33
80
|
testUrl(url: string): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Statically set parameters used when navigating to this instance.
|
|
83
|
+
*/
|
|
34
84
|
get staticParams(): Partial<T>;
|
|
35
85
|
get hasCanBeEnteredGuard(): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Data that is passed to Angular route definition.
|
|
88
|
+
*/
|
|
89
|
+
get data(): Data;
|
|
90
|
+
/**
|
|
91
|
+
* Meta guard that is used by [rdtRouterLink] and RdtMenu
|
|
92
|
+
* to determine if route can be entered.
|
|
93
|
+
* @param injector Environment or custom injector.
|
|
94
|
+
* @returns True if route can be entered.
|
|
95
|
+
*/
|
|
36
96
|
canBeEntered(injector?: Injector): boolean;
|
|
37
|
-
|
|
97
|
+
/**
|
|
98
|
+
* Extracts url parameters from absolute path for this path and each parent.
|
|
99
|
+
*/
|
|
100
|
+
parseAbsoluteUrl(url: string): RdtReadonlyParameters | null;
|
|
38
101
|
private fill;
|
|
102
|
+
/**
|
|
103
|
+
* Fills parameters in path with values from paramMap.
|
|
104
|
+
* Use withStaticParams() beforehand in case parent paths contain parameters.
|
|
105
|
+
* @param paramMap Must contain all parameters for this route.
|
|
106
|
+
* @returns Absolute path.
|
|
107
|
+
*/
|
|
39
108
|
createAbsoluteUrl(paramMap?: Partial<T>): string;
|
|
40
109
|
createRelativeUrl(paramMap?: Partial<T>): string;
|
|
41
110
|
private createUrl;
|
|
42
111
|
toAngularRoute(): RdtAngularRoute<T>;
|
|
112
|
+
/**
|
|
113
|
+
* Provides static mapping for parameter names tableName -> urlName.
|
|
114
|
+
* Returns new instance of RdtRoute<T> that is clone of
|
|
115
|
+
* this route and its parents (NOT children).
|
|
116
|
+
* @returns Clone of this route with mapped parameter names.
|
|
117
|
+
*/
|
|
43
118
|
withParamMappings(mappings: ParamMapping[]): RdtRoute<T>;
|
|
119
|
+
/**
|
|
120
|
+
* Sets static parameters for this route.
|
|
121
|
+
* @param params Static parameters for this route.
|
|
122
|
+
* @returns Clone of this with static parameters set.
|
|
123
|
+
*/
|
|
44
124
|
withStaticParams(params: T): RdtRoute<T>;
|
|
45
125
|
withStaticParams<T2 extends object>(route: RdtRoute<T>, params: T2): RdtRoute<T>;
|
|
46
126
|
withQueryParams(queryParams: Params): RdtRoute<T>;
|
|
47
127
|
withStateParams(stateParams: Params): RdtRoute<T>;
|
|
128
|
+
/**
|
|
129
|
+
* @returns Partial of object that only contains properties necessary to create this route.
|
|
130
|
+
*/
|
|
48
131
|
extractRouteParams(row: T): Partial<T>;
|
|
132
|
+
/**
|
|
133
|
+
* @returns New instance of RdtRoute<T> that is clone of
|
|
134
|
+
* this route and its parents (NOT children).
|
|
135
|
+
*/
|
|
49
136
|
clone(): RdtRoute<T>;
|
|
50
137
|
}
|
package/lib/rdt-route/utils.d.ts
CHANGED
|
@@ -11,3 +11,11 @@ export interface StaticRouteParams {
|
|
|
11
11
|
}
|
|
12
12
|
export type RdtRedirectReturnType = string | void | undefined;
|
|
13
13
|
export type RdtRedirectFn = (currentPath: string, targetPath: string, targetRoute: RdtRoute) => RdtRedirectReturnType;
|
|
14
|
+
export declare class RdtReadonlyParameters {
|
|
15
|
+
protected readonly params: StaticRouteParams;
|
|
16
|
+
constructor(params?: StaticRouteParams);
|
|
17
|
+
get<T extends object>(route: RdtRoute<T>): Partial<T> | null;
|
|
18
|
+
}
|
|
19
|
+
export declare class RdtParameters extends RdtReadonlyParameters {
|
|
20
|
+
set<T extends object>(route: RdtRoute<T>, params: Partial<T>): void;
|
|
21
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NavigationEnd, Params } from '@angular/router';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { RdtRoute } from '../rdt-route/rdt-route';
|
|
4
|
+
import { RdtReadonlyParameters } from '../rdt-route/utils';
|
|
4
5
|
import * as i0 from "@angular/core";
|
|
5
6
|
export interface RdtNavigateParams {
|
|
6
7
|
state?: Params;
|
|
@@ -17,11 +18,11 @@ export declare class RdtRouterService {
|
|
|
17
18
|
get currentUrl(): string | null;
|
|
18
19
|
parsePreviousUrl(): {
|
|
19
20
|
route: RdtRoute<any>;
|
|
20
|
-
params:
|
|
21
|
+
params: RdtReadonlyParameters;
|
|
21
22
|
} | null;
|
|
22
23
|
parseCurrentUrl(): {
|
|
23
24
|
route: RdtRoute<any>;
|
|
24
|
-
params:
|
|
25
|
+
params: RdtReadonlyParameters;
|
|
25
26
|
} | null;
|
|
26
27
|
readonly navigationEnd$: Observable<NavigationEnd>;
|
|
27
28
|
readonly nextNavigationEnd$: Observable<NavigationEnd>;
|
|
@@ -30,10 +31,10 @@ export declare class RdtRouterService {
|
|
|
30
31
|
navigateHome(params?: RdtNavigateParams): Promise<boolean>;
|
|
31
32
|
parseAbsoluteUrl(url?: string): {
|
|
32
33
|
route: RdtRoute<any>;
|
|
33
|
-
params:
|
|
34
|
+
params: RdtReadonlyParameters;
|
|
34
35
|
} | null;
|
|
35
36
|
navigateBack(params?: RdtNavigateParams): Promise<boolean> | null;
|
|
36
|
-
extractAllParams(currentRoute?: RdtRoute):
|
|
37
|
+
extractAllParams(currentRoute?: RdtRoute): RdtReadonlyParameters | null;
|
|
37
38
|
isParentOfCurrentLocation(route: RdtRoute): boolean;
|
|
38
39
|
removeQueryParams(...paramNames: string[]): void;
|
|
39
40
|
static ɵfac: i0.ɵɵFactoryDeclaration<RdtRouterService, never>;
|