@ngrdt/router 0.0.23 → 0.0.24

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/index.d.ts CHANGED
@@ -1,12 +1,13 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { Type, Injector, InjectionToken, OnInit, OnChanges, SimpleChanges, DestroyRef } from '@angular/core';
3
3
  import * as i1 from '@angular/router';
4
- import { LoadChildrenCallback, Route, ResolveFn, CanActivateFn, CanDeactivateFn, CanActivateChildFn, RunGuardsAndResolvers, Params, Data, NavigationEnd, IsActiveMatchOptions, Router } from '@angular/router';
4
+ import { LoadChildrenCallback, Route, ResolveFn, CanActivateFn, CanDeactivateFn, CanActivateChildFn, RunGuardsAndResolvers, Data, Params, NavigationEnd, IsActiveMatchOptions, Router } from '@angular/router';
5
5
  import { Observable } from 'rxjs';
6
6
 
7
7
  declare class RdtAngularRoute<T extends object> {
8
8
  private route;
9
9
  private children;
10
+ private loadComponent?;
10
11
  private loadChildren?;
11
12
  private component?;
12
13
  private providers;
@@ -18,6 +19,7 @@ declare class RdtAngularRoute<T extends object> {
18
19
  private data?;
19
20
  constructor(route: RdtRoute<T>);
20
21
  provide(...providers: Type<unknown>[]): this;
22
+ withLazyComponent(callback: LoadComponentCallback): this;
21
23
  withModule(callback: LoadChildrenCallback): this;
22
24
  /**
23
25
  * @deprecated Use withModule() instead.
@@ -47,24 +49,34 @@ declare class RdtAngularRoute<T extends object> {
47
49
  private checkChildrenMatch;
48
50
  }
49
51
 
50
- declare function ALWAYS_TRUE(): boolean;
51
- declare class RdtRoute<T extends object = any> {
52
- protected orderedParams: string[];
52
+ declare class RdtRouteBase<T extends object> {
53
+ protected _orderedParams: string[];
53
54
  protected _paramMap: ParamTypeMap<T>;
54
55
  protected _regex: RegExp | null;
55
- protected paramMappings: ParamMapping[];
56
- protected _staticParams: Partial<T>;
57
- protected _queryParams: Params;
58
- protected _stateParams: Params;
59
- protected _data: Data;
56
+ protected _paramMappings: ParamMapping[];
60
57
  protected _name: string;
61
58
  protected _path: string;
62
59
  protected _parent: RdtRoute | null;
63
60
  protected _children: RdtRoute[];
64
61
  protected _entryDisabled: boolean;
65
62
  protected _canBeEntered: () => boolean;
66
- protected _built: boolean;
67
- private _absoluteRegex?;
63
+ protected _data: Data;
64
+ /**
65
+ * Data that is passed to Angular route definition.
66
+ */
67
+ get data(): Data;
68
+ /**
69
+ * Regular expression route path relative to parent route.
70
+ * Hostname excluded.
71
+ */
72
+ get regex(): RegExp | null;
73
+ /**
74
+ * Denotes disabled route entry.
75
+ * If true, route should have no NgModule
76
+ * or component and only serves as virtual module
77
+ * for breadcrumb.
78
+ */
79
+ get entryDisabled(): boolean;
68
80
  /**
69
81
  * Map of parameters and their types.
70
82
  */
@@ -85,6 +97,87 @@ declare class RdtRoute<T extends object = any> {
85
97
  * Child routes.
86
98
  */
87
99
  get children(): RdtRoute<any>[];
100
+ }
101
+
102
+ declare class RdtRouteBuilder<T extends object = any> extends RdtRouteBase<T> {
103
+ get canBeEntered(): () => boolean;
104
+ get orderedParams(): string[];
105
+ get paramMappings(): ParamMapping[];
106
+ /**
107
+ * CanBeEntered function is synchronous function which
108
+ * lets framework hide menu buttons and disable links.
109
+ * Function is run in environment injection context, so
110
+ * you can inject global services, tokens, etc.
111
+ * @param fn
112
+ */
113
+ withCanBeEntered(fn: () => boolean): this;
114
+ /**
115
+ * @deprecated Use withCanBeEntered() instead.
116
+ */
117
+ setCanBeEntered(fn: () => boolean): this;
118
+ /**
119
+ * Entry disabled route will generate disabled breadcrumb.
120
+ * It should not have any component nor module added to it.
121
+ * @param value
122
+ * @returns
123
+ */
124
+ withEntryDisabled(value?: boolean): this;
125
+ /**
126
+ * @deprecated Use withEntryDisabled() instead.
127
+ */
128
+ setEntryDisabled(value?: boolean): this;
129
+ /**
130
+ * Sets path relative to parent. It is defined the same way as Angular route path including parameters.
131
+ * You need to call setParam() for each parameter you use in the path.
132
+ */
133
+ withPath(path: string): this;
134
+ /**
135
+ * @deprecated Use withPath() instead.
136
+ */
137
+ setPath(path: string): this;
138
+ /**
139
+ * Sets Angular route data.
140
+ * @param data Angular route data object. Breadcrumb key is merged into it.
141
+ */
142
+ withData(data: Data): this;
143
+ /**
144
+ * @deprecated Use withData() instead.
145
+ */
146
+ setData(data: Data): this;
147
+ /**
148
+ * Defines parameter type and lets framework parse it.
149
+ * @param paramName
150
+ * @param type
151
+ */
152
+ withParam(paramName: keyof T, type: 'string' | 'number'): this;
153
+ /**
154
+ * @deprecated Use withParam() instead.
155
+ */
156
+ setParam(paramName: keyof T, type: 'string' | 'number'): this;
157
+ /**
158
+ * Sets name to display in breadcrumb, etc.
159
+ */
160
+ withName(name: string): this;
161
+ /**
162
+ * @deprecated Use withName() instead.
163
+ */
164
+ setName(name: string): this;
165
+ /**
166
+ * Call .build() on children before you call this method!
167
+ */
168
+ withChildren(...children: RdtRoute[]): this;
169
+ /**
170
+ * @deprecated Use withChildren() instead.
171
+ */
172
+ setChildren(...children: RdtRoute[]): this;
173
+ build(): RdtRoute<T>;
174
+ }
175
+
176
+ declare class RdtRoute<T extends object = any> extends RdtRouteBase<T> {
177
+ private _absoluteRegex?;
178
+ protected _staticParams: Partial<T>;
179
+ protected _queryParams: Params;
180
+ protected _stateParams: Params;
88
181
  /**
89
182
  * Absolute path of parent route or '/' if there is no parent.
90
183
  * Hostname excluded.
@@ -94,23 +187,11 @@ declare class RdtRoute<T extends object = any> {
94
187
  * Absolute path of the route. Hostname excluded.
95
188
  */
96
189
  get absolutePath(): string;
97
- /**
98
- * Regular expression route path relative to parent route.
99
- * Hostname excluded.
100
- */
101
- get regex(): RegExp | null;
102
190
  /**
103
191
  * Regular expression to match only this route (not children
104
192
  * or parent routes). Hostname excluded.
105
193
  */
106
194
  get absoluteRegex(): RegExp;
107
- /**
108
- * Denotes disabled route entry.
109
- * If true, route should have no NgModule
110
- * or component and only serves as virtual module
111
- * for breadcrumb.
112
- */
113
- get entryDisabled(): boolean;
114
195
  /**
115
196
  * Statically set state params used when navigating to this instance.
116
197
  */
@@ -129,10 +210,6 @@ declare class RdtRoute<T extends object = any> {
129
210
  */
130
211
  get staticParams(): Partial<T>;
131
212
  get hasCanBeEnteredGuard(): boolean;
132
- /**
133
- * Data that is passed to Angular route definition.
134
- */
135
- get data(): Data;
136
213
  /**
137
214
  * Meta guard that is used by [rdtRouterLink] and RdtMenu
138
215
  * to determine if route can be entered.
@@ -180,6 +257,9 @@ declare class RdtRoute<T extends object = any> {
180
257
  * this route and its parents (NOT children).
181
258
  */
182
259
  clone(): RdtRoute<T>;
260
+ private setRegex;
261
+ static fromBuilder<T extends object>(builder: RdtRouteBuilder<T>): RdtRoute<T>;
262
+ private static readonly groups;
183
263
  }
184
264
 
185
265
  type ParamTypeMap<T> = {
@@ -199,6 +279,7 @@ declare class RdtReadonlyParameters {
199
279
  constructor(params?: StaticRouteParams);
200
280
  get<T extends object>(route: RdtRoute<T>): Partial<T> | null;
201
281
  }
282
+ type LoadComponentCallback = Route['loadComponent'];
202
283
 
203
284
  /**
204
285
  * Injection token that defines behavior when route cannot be entered (canBeEntered returns false).
@@ -277,79 +358,6 @@ declare enum RdtNavigationSource {
277
358
  BREADCRUMB = "breadcrumb"
278
359
  }
279
360
 
280
- declare class RdtRouteBuilder<T extends object = any> extends RdtRoute<T> {
281
- /**
282
- * CanBeEntered function is synchronous function which
283
- * lets framework hide menu buttons and disable links.
284
- * Function is run in environment injection context, so
285
- * you can inject global services, tokens, etc.
286
- * @param fn
287
- */
288
- withCanBeEntered(fn: () => boolean): this;
289
- /**
290
- * @deprecated Use withCanBeEntered() instead.
291
- */
292
- setCanBeEntered(fn: () => boolean): this;
293
- /**
294
- * Entry disabled route will generate disabled breadcrumb.
295
- * It should not have any component nor module added to it.
296
- * @param value
297
- * @returns
298
- */
299
- withEntryDisabled(value?: boolean): this;
300
- /**
301
- * @deprecated Use withEntryDisabled() instead.
302
- */
303
- setEntryDisabled(value?: boolean): this;
304
- /**
305
- * Sets path relative to parent. It is defined the same way as Angular route path including parameters.
306
- * You need to call setParam() for each parameter you use in the path.
307
- */
308
- withPath(path: string): this;
309
- /**
310
- * @deprecated Use withPath() instead.
311
- */
312
- setPath(path: string): this;
313
- /**
314
- * Sets Angular route data.
315
- * @param data Angular route data object. Breadcrumb key is merged into it.
316
- */
317
- withData(data: Data): this;
318
- /**
319
- * @deprecated Use withData() instead.
320
- */
321
- setData(data: Data): this;
322
- /**
323
- * Defines parameter type and lets framework parse it.
324
- * @param paramName
325
- * @param type
326
- */
327
- withParam(paramName: keyof T, type: 'string' | 'number'): this;
328
- /**
329
- * @deprecated Use withParam() instead.
330
- */
331
- setParam(paramName: keyof T, type: 'string' | 'number'): this;
332
- /**
333
- * Sets name to display in breadcrumb, etc.
334
- */
335
- withName(name: string): this;
336
- /**
337
- * @deprecated Use withName() instead.
338
- */
339
- setName(name: string): this;
340
- /**
341
- * Call .build() on children before you call this method!
342
- */
343
- withChildren(...children: RdtRoute[]): this;
344
- /**
345
- * @deprecated Use withChildren() instead.
346
- */
347
- setChildren(...children: RdtRoute[]): this;
348
- build(): RdtRoute<T>;
349
- private setRegex;
350
- private static readonly groups;
351
- }
352
-
353
361
  /**
354
362
  * Directive that appends class to host if any of the watched routes is active.
355
363
  */
@@ -430,5 +438,5 @@ declare class GlobalRouteGuardService {
430
438
 
431
439
  declare const preventDataLossGuardFn: CanDeactivateFn<any>;
432
440
 
433
- export { ALWAYS_TRUE, GlobalRouteGuardService, PERMISSION_DISABLED_KEY, RDT_CANNOT_BE_ENTERED_PROVIDER, RDT_CONFIRM_DATA_LOSS_SERVICE, RDT_ROUTES_PROVIDER, RdtAngularRoute, RdtAnyRouteActiveDirective, RdtBackLinkDirective, RdtConfirmDataLossService, RdtConfirmDataLossServiceAlert, RdtNavigationSource, RdtRoute, RdtRouteBuilder, RdtRouterLinkDirective, RdtRouterService, preventDataLossGuardFn };
441
+ export { GlobalRouteGuardService, PERMISSION_DISABLED_KEY, RDT_CANNOT_BE_ENTERED_PROVIDER, RDT_CONFIRM_DATA_LOSS_SERVICE, RDT_ROUTES_PROVIDER, RdtAngularRoute, RdtAnyRouteActiveDirective, RdtBackLinkDirective, RdtConfirmDataLossService, RdtConfirmDataLossServiceAlert, RdtNavigationSource, RdtRoute, RdtRouteBuilder, RdtRouterLinkDirective, RdtRouterService, preventDataLossGuardFn };
434
442
  export type { RdtNavigateExtras };
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@ngrdt/router",
3
- "version": "0.0.23",
3
+ "version": "0.0.24",
4
4
  "peerDependencies": {
5
5
  "@angular/common": ">=18.2.0",
6
6
  "@angular/core": ">=18.2.0",
7
7
  "@angular/router": ">=18.2.0",
8
8
  "rxjs": ">=7.0.0",
9
- "@ngrdt/utils": "^0.0.23",
10
- "@ngrdt/core": "^0.0.23",
11
- "@ngrdt/button": "^0.0.23"
9
+ "@ngrdt/utils": "^0.0.24",
10
+ "@ngrdt/core": "^0.0.24",
11
+ "@ngrdt/button": "^0.0.24"
12
12
  },
13
13
  "sideEffects": false,
14
14
  "module": "fesm2022/ngrdt-router.mjs",