@ngrdt/router 0.0.17 → 0.0.18
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 +254 -254
- package/fesm2022/ngrdt-router.mjs +90 -23
- package/fesm2022/ngrdt-router.mjs.map +1 -1
- package/index.d.ts +416 -12
- package/package.json +1 -3
- package/esm2022/index.mjs +0 -13
- package/esm2022/lib/directives/rdt-any-route-active.directive.mjs +0 -126
- package/esm2022/lib/directives/rdt-router-link.directive.mjs +0 -69
- package/esm2022/lib/guards/global-route-guard.service.mjs +0 -51
- package/esm2022/lib/guards/prevent-data-loss.guard.mjs +0 -7
- package/esm2022/lib/rdt-route/constants.mjs +0 -5
- package/esm2022/lib/rdt-route/rdt-angular-route.mjs +0 -196
- package/esm2022/lib/rdt-route/rdt-route-builder.mjs +0 -112
- package/esm2022/lib/rdt-route/rdt-route.mjs +0 -308
- package/esm2022/lib/rdt-route/utils.mjs +0 -15
- package/esm2022/lib/services/rdt-cannot-be-entered.token.mjs +0 -7
- package/esm2022/lib/services/rdt-confirm-data-loss.service.mjs +0 -11
- package/esm2022/lib/services/rdt-router.service.mjs +0 -161
- package/esm2022/lib/services/rdt-routes.token.mjs +0 -3
- package/esm2022/ngrdt-router.mjs +0 -5
- package/lib/directives/rdt-any-route-active.directive.d.ts +0 -34
- package/lib/directives/rdt-router-link.directive.d.ts +0 -23
- package/lib/guards/global-route-guard.service.d.ts +0 -10
- package/lib/guards/prevent-data-loss.guard.d.ts +0 -2
- package/lib/rdt-route/constants.d.ts +0 -3
- package/lib/rdt-route/rdt-angular-route.d.ts +0 -29
- package/lib/rdt-route/rdt-route-builder.d.ts +0 -46
- package/lib/rdt-route/rdt-route.d.ts +0 -138
- package/lib/rdt-route/utils.d.ts +0 -21
- package/lib/services/rdt-cannot-be-entered.token.d.ts +0 -7
- package/lib/services/rdt-confirm-data-loss.service.d.ts +0 -9
- package/lib/services/rdt-router.service.d.ts +0 -61
- package/lib/services/rdt-routes.token.d.ts +0 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, inject, Injectable, EnvironmentInjector, runInInjectionContext, DestroyRef, Renderer2, ElementRef,
|
|
2
|
+
import { InjectionToken, inject, Injectable, EnvironmentInjector, runInInjectionContext, DestroyRef, Renderer2, ElementRef, Input, Directive, booleanAttribute } from '@angular/core';
|
|
3
3
|
import { defer, of, filter, take } from 'rxjs';
|
|
4
4
|
import { Location, PlatformLocation } from '@angular/common';
|
|
5
5
|
import * as i1 from '@angular/router';
|
|
@@ -183,10 +183,10 @@ class RdtRouterService {
|
|
|
183
183
|
const regex = new RegExp(`[?&](${paramNames.join('|')})=[^&]*`, 'g');
|
|
184
184
|
return history.replaceState(history.state, '', location.pathname + location.search.replace(regex, '').replace(/^&/, '?'));
|
|
185
185
|
}
|
|
186
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
187
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
186
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: RdtRouterService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
187
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: RdtRouterService, providedIn: 'root' });
|
|
188
188
|
}
|
|
189
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
189
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: RdtRouterService, decorators: [{
|
|
190
190
|
type: Injectable,
|
|
191
191
|
args: [{
|
|
192
192
|
providedIn: 'root',
|
|
@@ -218,18 +218,37 @@ class RdtAngularRoute {
|
|
|
218
218
|
this.providers.push(...providers);
|
|
219
219
|
return this;
|
|
220
220
|
}
|
|
221
|
+
withModule(callback) {
|
|
222
|
+
this.loadChildren = callback;
|
|
223
|
+
return this;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* @deprecated Use withModule() instead.
|
|
227
|
+
*/
|
|
221
228
|
setModule(callback) {
|
|
222
229
|
this.loadChildren = callback;
|
|
223
230
|
return this;
|
|
224
231
|
}
|
|
225
|
-
|
|
232
|
+
withComponent(comp) {
|
|
226
233
|
this.component = comp;
|
|
227
234
|
return this;
|
|
228
235
|
}
|
|
229
|
-
|
|
236
|
+
/**
|
|
237
|
+
* @deprecated Use withComponent() instead.
|
|
238
|
+
*/
|
|
239
|
+
setComponent(comp) {
|
|
240
|
+
return this.withComponent(comp);
|
|
241
|
+
}
|
|
242
|
+
withChildren(...routes) {
|
|
230
243
|
this.children = routes;
|
|
231
244
|
return this;
|
|
232
245
|
}
|
|
246
|
+
/**
|
|
247
|
+
* @deprecated Use withChildren() instead.
|
|
248
|
+
*/
|
|
249
|
+
setChildren(...routes) {
|
|
250
|
+
return this.withChildren(...routes);
|
|
251
|
+
}
|
|
233
252
|
addResolve(paramName, resolver) {
|
|
234
253
|
this.resolvers[paramName] = resolver;
|
|
235
254
|
return this;
|
|
@@ -246,10 +265,16 @@ class RdtAngularRoute {
|
|
|
246
265
|
this.canActivateChild.push(...fns);
|
|
247
266
|
return this;
|
|
248
267
|
}
|
|
249
|
-
|
|
268
|
+
withRunGuardsAndResolvers(value) {
|
|
250
269
|
this.runGuardsAndResolvers = value;
|
|
251
270
|
return this;
|
|
252
271
|
}
|
|
272
|
+
/**
|
|
273
|
+
* @deprecated Use withRunGuardsAndResolvers() instead.
|
|
274
|
+
*/
|
|
275
|
+
setRunGuardsAndResolvers(value) {
|
|
276
|
+
return this.withRunGuardsAndResolvers(value);
|
|
277
|
+
}
|
|
253
278
|
build() {
|
|
254
279
|
this.checkChildrenMatch();
|
|
255
280
|
let res = {
|
|
@@ -702,25 +727,37 @@ class RdtRouteBuilder extends RdtRoute {
|
|
|
702
727
|
* you can inject global services, tokens, etc.
|
|
703
728
|
* @param fn
|
|
704
729
|
*/
|
|
705
|
-
|
|
730
|
+
withCanBeEntered(fn) {
|
|
706
731
|
this._canBeEntered = fn;
|
|
707
732
|
return this;
|
|
708
733
|
}
|
|
734
|
+
/**
|
|
735
|
+
* @deprecated Use withCanBeEntered() instead.
|
|
736
|
+
*/
|
|
737
|
+
setCanBeEntered(fn) {
|
|
738
|
+
return this.withCanBeEntered(fn);
|
|
739
|
+
}
|
|
709
740
|
/**
|
|
710
741
|
* Entry disabled route will generate disabled breadcrumb.
|
|
711
742
|
* It should not have any component nor module added to it.
|
|
712
743
|
* @param value
|
|
713
744
|
* @returns
|
|
714
745
|
*/
|
|
715
|
-
|
|
746
|
+
withEntryDisabled(value = true) {
|
|
716
747
|
this._entryDisabled = value;
|
|
717
748
|
return this;
|
|
718
749
|
}
|
|
750
|
+
/**
|
|
751
|
+
* @deprecated Use withEntryDisabled() instead.
|
|
752
|
+
*/
|
|
753
|
+
setEntryDisabled(value = true) {
|
|
754
|
+
return this.withEntryDisabled(value);
|
|
755
|
+
}
|
|
719
756
|
/**
|
|
720
757
|
* Sets path relative to parent. It is defined the same way as Angular route path including parameters.
|
|
721
758
|
* You need to call setParam() for each parameter you use in the path.
|
|
722
759
|
*/
|
|
723
|
-
|
|
760
|
+
withPath(path) {
|
|
724
761
|
this._path = path;
|
|
725
762
|
const s = path.split('/');
|
|
726
763
|
const params = [];
|
|
@@ -738,40 +775,70 @@ class RdtRouteBuilder extends RdtRoute {
|
|
|
738
775
|
this.orderedParams = params;
|
|
739
776
|
return this;
|
|
740
777
|
}
|
|
778
|
+
/**
|
|
779
|
+
* @deprecated Use withPath() instead.
|
|
780
|
+
*/
|
|
781
|
+
setPath(path) {
|
|
782
|
+
return this.withPath(path);
|
|
783
|
+
}
|
|
741
784
|
/**
|
|
742
785
|
* Sets Angular route data.
|
|
743
786
|
* @param data Angular route data object. Breadcrumb key is merged into it.
|
|
744
787
|
*/
|
|
745
|
-
|
|
788
|
+
withData(data) {
|
|
746
789
|
this._data = data;
|
|
747
790
|
return this;
|
|
748
791
|
}
|
|
792
|
+
/**
|
|
793
|
+
* @deprecated Use withData() instead.
|
|
794
|
+
*/
|
|
795
|
+
setData(data) {
|
|
796
|
+
return this.withData(data);
|
|
797
|
+
}
|
|
749
798
|
/**
|
|
750
799
|
* Defines parameter type and lets framework parse it.
|
|
751
800
|
* @param paramName
|
|
752
801
|
* @param type
|
|
753
802
|
*/
|
|
754
|
-
|
|
803
|
+
withParam(paramName, type) {
|
|
755
804
|
this._paramMap[paramName] = type;
|
|
756
805
|
return this;
|
|
757
806
|
}
|
|
807
|
+
/**
|
|
808
|
+
* @deprecated Use withParam() instead.
|
|
809
|
+
*/
|
|
810
|
+
setParam(paramName, type) {
|
|
811
|
+
return this.withParam(paramName, type);
|
|
812
|
+
}
|
|
758
813
|
/**
|
|
759
814
|
* Sets name to display in breadcrumb, etc.
|
|
760
815
|
*/
|
|
761
|
-
|
|
816
|
+
withName(name) {
|
|
762
817
|
this._name = name;
|
|
763
818
|
return this;
|
|
764
819
|
}
|
|
820
|
+
/**
|
|
821
|
+
* @deprecated Use withName() instead.
|
|
822
|
+
*/
|
|
823
|
+
setName(name) {
|
|
824
|
+
return this.withName(name);
|
|
825
|
+
}
|
|
765
826
|
/**
|
|
766
827
|
* Call .build() on children before you call this method!
|
|
767
828
|
*/
|
|
768
|
-
|
|
829
|
+
withChildren(...children) {
|
|
769
830
|
this._children = children;
|
|
770
831
|
for (const child of children) {
|
|
771
832
|
child._parent = this;
|
|
772
833
|
}
|
|
773
834
|
return this;
|
|
774
835
|
}
|
|
836
|
+
/**
|
|
837
|
+
* @deprecated Use withChildren() instead.
|
|
838
|
+
*/
|
|
839
|
+
setChildren(...children) {
|
|
840
|
+
return this.withChildren(...children);
|
|
841
|
+
}
|
|
775
842
|
build() {
|
|
776
843
|
if (typeof this._path !== 'string') {
|
|
777
844
|
throw new Error('Please provide path for route. Empty string is acceptable.');
|
|
@@ -903,10 +970,10 @@ class RdtAnyRouteActiveDirective {
|
|
|
903
970
|
return input;
|
|
904
971
|
}
|
|
905
972
|
}
|
|
906
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
907
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
973
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: RdtAnyRouteActiveDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
974
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.1.7", type: RdtAnyRouteActiveDirective, isStandalone: true, selector: "[rdtAnyRouteActive]", inputs: { anyRouteActive: ["rdtAnyRouteActive", "anyRouteActive"], watchedRoutes: "watchedRoutes", anyRouteActiveOptions: "anyRouteActiveOptions", ariaCurrentWhenActive: "ariaCurrentWhenActive" }, providers: [RouterModule], usesOnChanges: true, ngImport: i0 });
|
|
908
975
|
}
|
|
909
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
976
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: RdtAnyRouteActiveDirective, decorators: [{
|
|
910
977
|
type: Directive,
|
|
911
978
|
args: [{
|
|
912
979
|
selector: '[rdtAnyRouteActive]',
|
|
@@ -958,10 +1025,10 @@ class RdtRouterLinkDirective {
|
|
|
958
1025
|
this.routerLinkRef.routerLink = null;
|
|
959
1026
|
this.routerLinkRef.ngOnChanges({});
|
|
960
1027
|
}
|
|
961
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
962
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "16.1.0", version: "
|
|
1028
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: RdtRouterLinkDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1029
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "16.1.0", version: "20.1.7", type: RdtRouterLinkDirective, isStandalone: true, selector: "[rdtRouterLink]", inputs: { route: ["rdtRouterLink", "route"], target: "target", params: "params", queryParams: "queryParams", stateParams: "stateParams", disabled: ["disabled", "disabled", booleanAttribute] }, usesOnChanges: true, hostDirectives: [{ directive: i1.RouterLink, inputs: ["target", "target"] }], ngImport: i0 });
|
|
963
1030
|
}
|
|
964
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1031
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: RdtRouterLinkDirective, decorators: [{
|
|
965
1032
|
type: Directive,
|
|
966
1033
|
args: [{
|
|
967
1034
|
selector: '[rdtRouterLink]',
|
|
@@ -1032,10 +1099,10 @@ class GlobalRouteGuardService {
|
|
|
1032
1099
|
canDeactivateGuards.push(preventDataLossGuardFn);
|
|
1033
1100
|
}
|
|
1034
1101
|
}
|
|
1035
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1036
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
1102
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: GlobalRouteGuardService, deps: [{ token: i1.Router }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1103
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: GlobalRouteGuardService, providedIn: 'root' });
|
|
1037
1104
|
}
|
|
1038
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1105
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: GlobalRouteGuardService, decorators: [{
|
|
1039
1106
|
type: Injectable,
|
|
1040
1107
|
args: [{ providedIn: 'root' }]
|
|
1041
1108
|
}], ctorParameters: () => [{ type: i1.Router }] });
|