@filip.mazev/blocks 1.2.17 → 1.2.19
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/fesm2022/filip.mazev-blocks-navigation.mjs +81 -40
- package/fesm2022/filip.mazev-blocks-navigation.mjs.map +1 -1
- package/fesm2022/filip.mazev-blocks.mjs +1 -1
- package/fesm2022/filip.mazev-blocks.mjs.map +1 -1
- package/package.json +1 -1
- package/types/filip.mazev-blocks-navigation.d.ts +3 -7
- package/types/filip.mazev-blocks.d.ts +1 -1
|
@@ -23,21 +23,32 @@ class NavigationService {
|
|
|
23
23
|
this.i18n?.version?.();
|
|
24
24
|
return this.extractRoutes(this.router.config);
|
|
25
25
|
}, ...(ngDevMode ? [{ debugName: "routes" }] : /* istanbul ignore next */ []));
|
|
26
|
+
baseRoute = computed(() => {
|
|
27
|
+
const viewableRoutes = this.routes();
|
|
28
|
+
const primaryPrefix = this.routeBase();
|
|
29
|
+
let firstFoundRoot;
|
|
30
|
+
const findRootRoute = (items) => {
|
|
31
|
+
for (const item of items) {
|
|
32
|
+
if (item.data?.root) {
|
|
33
|
+
if (!firstFoundRoot) {
|
|
34
|
+
firstFoundRoot = item.route;
|
|
35
|
+
}
|
|
36
|
+
if (primaryPrefix && item.route.startsWith(primaryPrefix)) {
|
|
37
|
+
return item.route;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (item.children?.length) {
|
|
41
|
+
const childRoot = findRootRoute(item.children);
|
|
42
|
+
if (childRoot)
|
|
43
|
+
return childRoot;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return undefined;
|
|
47
|
+
};
|
|
48
|
+
const perfectMatch = findRootRoute(viewableRoutes);
|
|
49
|
+
return perfectMatch ?? firstFoundRoot ?? primaryPrefix;
|
|
50
|
+
}, ...(ngDevMode ? [{ debugName: "baseRoute" }] : /* istanbul ignore next */ []));
|
|
26
51
|
menu = computed(() => this.buildMenu(this.routes()), ...(ngDevMode ? [{ debugName: "menu" }] : /* istanbul ignore next */ []));
|
|
27
|
-
sections = computed(() => {
|
|
28
|
-
const sections = this.config?.sections ?? [];
|
|
29
|
-
const menu = this.menu();
|
|
30
|
-
if (!sections.length) {
|
|
31
|
-
return [{ id: 'default', items: menu }];
|
|
32
|
-
}
|
|
33
|
-
return sections
|
|
34
|
-
.map(section => ({
|
|
35
|
-
...section,
|
|
36
|
-
items: menu.filter(item => (item.section ?? 'default') === section.id),
|
|
37
|
-
}))
|
|
38
|
-
.filter(section => section.items.length > 0)
|
|
39
|
-
.sort((a, b) => (a.order ?? Number.POSITIVE_INFINITY) - (b.order ?? Number.POSITIVE_INFINITY));
|
|
40
|
-
}, ...(ngDevMode ? [{ debugName: "sections" }] : /* istanbul ignore next */ []));
|
|
41
52
|
constructor() {
|
|
42
53
|
this.updateCurrent();
|
|
43
54
|
this.router.events
|
|
@@ -86,39 +97,57 @@ class NavigationService {
|
|
|
86
97
|
icon: nav.icon,
|
|
87
98
|
section: nav.section,
|
|
88
99
|
visible: nav.visible ? nav.visible() : true,
|
|
89
|
-
data: nav
|
|
100
|
+
data: nav,
|
|
101
|
+
children
|
|
90
102
|
};
|
|
91
103
|
items.push(item);
|
|
92
104
|
}
|
|
93
105
|
return this.sortNavigationItems(items);
|
|
94
106
|
}
|
|
95
107
|
resolveCurrent(root) {
|
|
96
|
-
const breadcrumbs = [];
|
|
97
108
|
let currentNode = root;
|
|
98
|
-
let
|
|
109
|
+
let finalSnapshot;
|
|
99
110
|
while (currentNode) {
|
|
100
111
|
const next = currentNode.children.find(child => child.outlet === 'primary') ?? null;
|
|
101
|
-
if (!next)
|
|
112
|
+
if (!next) {
|
|
113
|
+
finalSnapshot = currentNode;
|
|
102
114
|
break;
|
|
103
|
-
const nav = next.routeConfig?.data?.['nav'];
|
|
104
|
-
const url = this.urlFromSnapshot(next);
|
|
105
|
-
if (nav && !nav.hidden) {
|
|
106
|
-
const breadcrumbLabel = this.resolveNavText(nav, 'breadcrumb', next) ?? this.resolveNavText(nav, 'label', next);
|
|
107
|
-
if (breadcrumbLabel) {
|
|
108
|
-
breadcrumbs.push({ label: breadcrumbLabel, route: url });
|
|
109
|
-
}
|
|
110
|
-
current = {
|
|
111
|
-
id: url,
|
|
112
|
-
route: url,
|
|
113
|
-
label: this.resolveNavText(nav, 'label', next) ?? '',
|
|
114
|
-
icon: nav.icon,
|
|
115
|
-
section: nav.section,
|
|
116
|
-
visible: nav.visible ? nav.visible() : true,
|
|
117
|
-
data: nav
|
|
118
|
-
};
|
|
119
115
|
}
|
|
120
116
|
currentNode = next;
|
|
121
117
|
}
|
|
118
|
+
if (!finalSnapshot)
|
|
119
|
+
return { breadcrumbs: [] };
|
|
120
|
+
const urlSegments = finalSnapshot.pathFromRoot
|
|
121
|
+
.flatMap(s => s.url.map(u => u.path))
|
|
122
|
+
.filter(Boolean);
|
|
123
|
+
const breadcrumbs = [];
|
|
124
|
+
const allItems = this.flattenRoutes(this.routes());
|
|
125
|
+
let currentUrl = '';
|
|
126
|
+
for (const segment of urlSegments) {
|
|
127
|
+
currentUrl += '/' + segment;
|
|
128
|
+
const matchingItem = this.matchRouteToUrl(allItems, currentUrl);
|
|
129
|
+
if (matchingItem && matchingItem.data && !matchingItem.data.hidden) {
|
|
130
|
+
const label = this.resolveNavText(matchingItem.data, 'breadcrumb', finalSnapshot)
|
|
131
|
+
?? this.resolveNavText(matchingItem.data, 'label', finalSnapshot);
|
|
132
|
+
if (label && breadcrumbs[breadcrumbs.length - 1]?.label !== label) {
|
|
133
|
+
breadcrumbs.push({ label, route: currentUrl });
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
const leafNav = finalSnapshot.routeConfig?.data?.['nav'];
|
|
138
|
+
const fullUrl = '/' + urlSegments.join('/');
|
|
139
|
+
let current;
|
|
140
|
+
if (leafNav && !leafNav.hidden) {
|
|
141
|
+
current = {
|
|
142
|
+
id: fullUrl,
|
|
143
|
+
route: fullUrl,
|
|
144
|
+
label: this.resolveNavText(leafNav, 'label', finalSnapshot) ?? '',
|
|
145
|
+
icon: leafNav.icon,
|
|
146
|
+
section: leafNav.section,
|
|
147
|
+
visible: leafNav.visible ? leafNav.visible() : true,
|
|
148
|
+
data: leafNav
|
|
149
|
+
};
|
|
150
|
+
}
|
|
122
151
|
return { current, breadcrumbs };
|
|
123
152
|
}
|
|
124
153
|
buildMenu(items) {
|
|
@@ -162,12 +191,24 @@ class NavigationService {
|
|
|
162
191
|
}
|
|
163
192
|
return undefined;
|
|
164
193
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
194
|
+
matchRouteToUrl(items, url) {
|
|
195
|
+
const exactMatch = items.find(i => i.route === url);
|
|
196
|
+
if (exactMatch)
|
|
197
|
+
return exactMatch;
|
|
198
|
+
return items.find(i => {
|
|
199
|
+
if (!i.route.includes(':'))
|
|
200
|
+
return false;
|
|
201
|
+
const routeRegex = new RegExp('^' + i.route.replace(/:[^\s/]+/g, '([^/]+)') + '$');
|
|
202
|
+
return routeRegex.test(url);
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
flattenRoutes(items) {
|
|
206
|
+
return items.reduce((acc, item) => {
|
|
207
|
+
acc.push(item);
|
|
208
|
+
if (item.children)
|
|
209
|
+
acc.push(...this.flattenRoutes(item.children));
|
|
210
|
+
return acc;
|
|
211
|
+
}, []);
|
|
171
212
|
}
|
|
172
213
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: NavigationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
173
214
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: NavigationService, providedIn: 'root' });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filip.mazev-blocks-navigation.mjs","sources":["../../../projects/blocks/navigation/tokens/navigation-config.token.ts","../../../projects/blocks/navigation/tokens/navigation-i18n.token.ts","../../../projects/blocks/navigation/tokens/navigation-access-adapter.token.ts","../../../projects/blocks/navigation/services/navigation.service.ts","../../../projects/blocks/navigation/helpers/navigation-functions.ts","../../../projects/blocks/navigation/public-api.ts","../../../projects/blocks/navigation/filip.mazev-blocks-navigation.ts"],"sourcesContent":["import { InjectionToken } from \"@angular/core\";\nimport { INavigationConfig } from \"../interfaces/inavigation-config.interface\";\n\nexport const NAVIGATION_CONFIG = new InjectionToken<INavigationConfig>('NAVIGATION_CONFIG');","import { InjectionToken } from \"@angular/core\";\nimport { INavigationI18nAdapter } from \"../interfaces/inavigation-i18n-adapter.interface\";\n\nexport const NAVIGATION_I18N = new InjectionToken<INavigationI18nAdapter>('NAVIGATION_I18N');","import { InjectionToken } from \"@angular/core\";\nimport { INavigationAccessAdapter } from \"../interfaces/inavigation-access-adapter.interface\";\n\nexport const NAVIGATION_ACCESS_ADAPTER = new InjectionToken<INavigationAccessAdapter>('NAVIGATION_ACCESS_ADAPTER');","import { computed, inject, Injectable, Signal, signal } from \"@angular/core\";\nimport { ActivatedRouteSnapshot, NavigationEnd, Router, Routes } from \"@angular/router\";\nimport { NAVIGATION_CONFIG } from \"../tokens/navigation-config.token\";\nimport { IResolvedNavigation } from \"../interfaces/iresolved-navigation.interface\";\nimport { filter } from \"rxjs\";\nimport { IBreadcrumbItem } from \"../interfaces/ibreadcrumb-item.interface\";\nimport { INavMeta } from \"../interfaces/inav-meta.interface\";\nimport { INavigationItem } from \"../interfaces/inavigation-item.interface\";\nimport { NAVIGATION_I18N } from \"../tokens/navigation-i18n.token\";\nimport { NAVIGATION_ACCESS_ADAPTER } from \"../tokens/navigation-access-adapter.token\";\n\n@Injectable({ providedIn: 'root' })\nexport class NavigationService {\n private readonly router = inject(Router);\n private readonly config = inject(NAVIGATION_CONFIG, { optional: true });\n private readonly i18n = inject(NAVIGATION_I18N, { optional: true });\n private readonly accessAdapter = inject(NAVIGATION_ACCESS_ADAPTER, { optional: true });\n\n private readonly _current = signal<IResolvedNavigation>({ breadcrumbs: [] });\n public readonly current = this._current.asReadonly();\n\n public readonly routeBase = computed<string | undefined>(() => {\n return this.accessAdapter?.resolveBaseRoute();\n });\n\n public readonly routes: Signal<INavigationItem[]> = computed(() => {\n this.i18n?.version?.();\n return this.extractRoutes(this.router.config);\n });\n\n public readonly menu = computed(() => this.buildMenu(this.routes()));\n\n public readonly sections = computed(() => {\n const sections = this.config?.sections ?? [];\n const menu = this.menu();\n\n if(!sections.length) {\n return [{ id: 'default', items: menu }];\n }\n\n return sections\n .map(section => ({\n ...section,\n items: menu.filter(item => (item.section ?? 'default') === section.id),\n }))\n .filter(section => section.items.length > 0)\n .sort((a, b) => (a.order ?? Number.POSITIVE_INFINITY) - (b.order ?? Number.POSITIVE_INFINITY));\n });\n\n constructor() {\n this.updateCurrent();\n\n this.router.events\n .pipe(filter((e): e is NavigationEnd => e instanceof NavigationEnd))\n .subscribe(() => this.updateCurrent());\n }\n\n public navigateBack(): void {\n const breadcrumbs = this.current().breadcrumbs;\n \n if (breadcrumbs.length > 1) {\n const previousBreadcrumb = breadcrumbs[breadcrumbs.length - 2];\n this.router.navigateByUrl(previousBreadcrumb.route);\n } else {\n this.router.navigateByUrl(this.routeBase() ?? '/');\n }\n }\n\n //#region Helpers\n\n private updateCurrent(): void {\n this._current.set(\n this.resolveCurrent(this.router.routerState.snapshot.root)\n );\n }\n\n private extractRoutes(routes: Routes, parentSegment: string[] = []): INavigationItem[] {\n const items: INavigationItem[] = [];\n\n for(const route of routes) {\n if(route.redirectTo) continue;\n\n if (this.accessAdapter && !this.accessAdapter.canAccessMenu(route.data ?? {})) {\n continue;\n }\n\n const ownPath = route.path ?? '';\n \n const fullSegments = ownPath \n ? [...parentSegment, ownPath] \n : [...parentSegment];\n\n const fullRoute = '/' + fullSegments.filter(Boolean).join('/');\n\n const children = route.children?.length\n ? this.extractRoutes(route.children, fullSegments)\n : [];\n \n const nav = route.data?.['nav'] as INavMeta | undefined;\n\n if(!nav) {\n items.push(...children);\n continue;\n }\n\n const item = {\n id: fullRoute,\n route: fullRoute,\n label: this.resolveNavText(nav, 'label') ?? '',\n icon: nav.icon,\n section: nav.section,\n visible: nav.visible ? nav.visible() : true,\n data: nav\n };\n\n items.push(item);\n }\n\n return this.sortNavigationItems(items);\n }\n\n private resolveCurrent(root: ActivatedRouteSnapshot): IResolvedNavigation {\n const breadcrumbs: IBreadcrumbItem[] = [];\n let currentNode: ActivatedRouteSnapshot | null = root;\n let current: INavigationItem | undefined;\n\n while (currentNode) {\n const next: ActivatedRouteSnapshot | null = currentNode.children.find(child => child.outlet === 'primary') ?? null;\n if(!next) break;\n\n const nav = next.routeConfig?.data?.['nav'] as INavMeta | undefined;\n const url = this.urlFromSnapshot(next);\n\n if(nav && !nav.hidden) {\n const breadcrumbLabel = this.resolveNavText(nav, 'breadcrumb', next) ?? this.resolveNavText(nav, 'label', next);\n if(breadcrumbLabel) {\n breadcrumbs.push({ label: breadcrumbLabel, route: url });\n }\n\n current = {\n id: url,\n route: url,\n label: this.resolveNavText(nav, 'label', next) ?? '',\n icon: nav.icon,\n section: nav.section,\n visible: nav.visible ? nav.visible() : true,\n data: nav\n }\n }\n\n currentNode = next;\n }\n\n return { current, breadcrumbs };\n }\n\n private buildMenu(items: INavigationItem[]): INavigationItem[] {\n return items\n .map((item): INavigationItem | null => {\n const children = this.buildMenu(item.children ?? []);\n const includeSelf = item.visible && item.data?.menu !== false;\n\n if (!includeSelf && !children.length) {\n return null;\n }\n\n return {\n ...item,\n children\n };\n }) \n .filter((item): item is INavigationItem => item !== null);\n }\n\n private sortNavigationItems(items: INavigationItem[]): INavigationItem[] {\n const customSort = this.config?.sortItems;\n\n return [...items].sort((a, b) => {\n if(customSort) {\n return customSort(a, b);\n }\n\n const orderA = a.data?.order ?? Number.POSITIVE_INFINITY;\n const orderB = b.data?.order ?? Number.POSITIVE_INFINITY;\n\n if(orderA !== orderB) return orderA - orderB;\n return a.label.localeCompare(b.label);\n });\n }\n\n private resolveNavText(\n nav: INavMeta,\n kind: 'label' | 'breadcrumb',\n snapshot?: ActivatedRouteSnapshot\n ): string | undefined {\n const directValue = kind === 'label' ? nav.label : nav.breadcrumb;\n const key = kind === 'label' ? nav.labelKey : nav.breadcrumbKey;\n\n if(directValue) {\n return typeof directValue === 'function'\n ? directValue({ snapshot: snapshot! })\n : directValue;\n }\n\n if(key) {\n return this.i18n?.translate(key, { route: snapshot });\n }\n\n return undefined;\n }\n\n private urlFromSnapshot(snapshot: ActivatedRouteSnapshot): string {\n return (\n '/' +\n snapshot.pathFromRoot\n .flatMap(s => s.url.map(u => u.path))\n .filter(Boolean)\n .join('/')\n );\n }\n\n //#endregion\n}","import { INavMeta } from \"@navigation/interfaces/inav-meta.interface\";\nimport { INavigationConfig } from \"../interfaces/inavigation-config.interface\";\nimport { NAVIGATION_CONFIG } from \"../tokens/navigation-config.token\";\nimport { Route } from \"@angular/router\";\n\nexport function provideNavigation(config: INavigationConfig) {\n return [\n {\n provide: NAVIGATION_CONFIG,\n useValue: config\n }\n ];\n};\n\nexport function withNav(route: Route, nav: INavMeta): Route {\n const existingNav = (route.data?.['nav'] as INavMeta | undefined) ?? {};\n\n return {\n ...route,\n data: {\n ...(route.data ?? {}),\n nav: {\n ...existingNav,\n ...nav\n }\n }\n };\n}","/*\n * Public API Surface of modal\n */\n\nexport * from './services/navigation.service';\n\nexport * from './interfaces/ibreadcrumb-item.interface';\nexport * from './interfaces/inav-context.interface';\nexport * from './interfaces/inav-meta.interface';\nexport * from './interfaces/inav-route-data.interface';\nexport * from './interfaces/inavigation-access-adapter.interface';\nexport * from './interfaces/inavigation-config.interface';\nexport * from './interfaces/inavigation-i18n-adapter.interface';\nexport * from './interfaces/inavigation-item.interface';\nexport * from './interfaces/inavigation-section-config.interface';\nexport * from './interfaces/iresolved-navigation.interface';\n\nexport * from './tokens/navigation-config.token';\nexport * from './tokens/navigation-i18n.token';\nexport * from './tokens/navigation-access-adapter.token';\n\nexport * from './help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jB,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,iBAAiB,cADJ,MAAM,EAAA,CAAA;;2FACnB,iBAAiB,EAAA,UAAA,EAAA,CAAA;kBAD7B,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;ACN5B,SAAU,iBAAiB,CAAC,MAAyB,EAAA;IACzD,OAAO;AACL,QAAA;AACE,YAAA,OAAO,EAAE,iBAAiB;AAC1B,YAAA,QAAQ,EAAE;AACX;KACF;AACH;AAAC;AAEK,SAAU,OAAO,CAAC,KAAY,EAAE,GAAa,EAAA;IACjD,MAAM,WAAW,GAAI,KAAK,CAAC,IAAI,GAAG,KAAK,CAA0B,IAAI,EAAE;IAEvE,OAAO;AACL,QAAA,GAAG,KAAK;AACR,QAAA,IAAI,EAAE;AACJ,YAAA,IAAI,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC;AACrB,YAAA,GAAG,EAAE;AACH,gBAAA,GAAG,WAAW;AACd,gBAAA,GAAG;AACJ;AACF;KACF;AACH;;AC3BA;;AAEG;;ACFH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"filip.mazev-blocks-navigation.mjs","sources":["../../../projects/blocks/navigation/tokens/navigation-config.token.ts","../../../projects/blocks/navigation/tokens/navigation-i18n.token.ts","../../../projects/blocks/navigation/tokens/navigation-access-adapter.token.ts","../../../projects/blocks/navigation/services/navigation.service.ts","../../../projects/blocks/navigation/helpers/navigation-functions.ts","../../../projects/blocks/navigation/public-api.ts","../../../projects/blocks/navigation/filip.mazev-blocks-navigation.ts"],"sourcesContent":["import { InjectionToken } from \"@angular/core\";\nimport { INavigationConfig } from \"../interfaces/inavigation-config.interface\";\n\nexport const NAVIGATION_CONFIG = new InjectionToken<INavigationConfig>('NAVIGATION_CONFIG');","import { InjectionToken } from \"@angular/core\";\nimport { INavigationI18nAdapter } from \"../interfaces/inavigation-i18n-adapter.interface\";\n\nexport const NAVIGATION_I18N = new InjectionToken<INavigationI18nAdapter>('NAVIGATION_I18N');","import { InjectionToken } from \"@angular/core\";\nimport { INavigationAccessAdapter } from \"../interfaces/inavigation-access-adapter.interface\";\n\nexport const NAVIGATION_ACCESS_ADAPTER = new InjectionToken<INavigationAccessAdapter>('NAVIGATION_ACCESS_ADAPTER');","import { computed, inject, Injectable, Signal, signal } from \"@angular/core\";\nimport { ActivatedRouteSnapshot, NavigationEnd, Router, Routes } from \"@angular/router\";\nimport { NAVIGATION_CONFIG } from \"../tokens/navigation-config.token\";\nimport { IResolvedNavigation } from \"../interfaces/iresolved-navigation.interface\";\nimport { filter } from \"rxjs\";\nimport { IBreadcrumbItem } from \"../interfaces/ibreadcrumb-item.interface\";\nimport { INavMeta } from \"../interfaces/inav-meta.interface\";\nimport { INavigationItem } from \"../interfaces/inavigation-item.interface\";\nimport { NAVIGATION_I18N } from \"../tokens/navigation-i18n.token\";\nimport { NAVIGATION_ACCESS_ADAPTER } from \"../tokens/navigation-access-adapter.token\";\n\n@Injectable({ providedIn: 'root' })\nexport class NavigationService {\n private readonly router = inject(Router);\n private readonly config = inject(NAVIGATION_CONFIG, { optional: true });\n private readonly i18n = inject(NAVIGATION_I18N, { optional: true });\n private readonly accessAdapter = inject(NAVIGATION_ACCESS_ADAPTER, { optional: true });\n\n private readonly _current = signal<IResolvedNavigation>({ breadcrumbs: [] });\n public readonly current = this._current.asReadonly();\n\n public readonly routeBase = computed<string | undefined>(() => {\n return this.accessAdapter?.resolveBaseRoute();\n });\n\n public readonly routes: Signal<INavigationItem[]> = computed(() => {\n this.i18n?.version?.();\n return this.extractRoutes(this.router.config);\n });\n\n public readonly baseRoute = computed<string | undefined>(() => {\n const viewableRoutes = this.routes();\n \n const primaryPrefix = this.routeBase(); \n\n let firstFoundRoot: string | undefined;\n\n const findRootRoute = (items: INavigationItem[]): string | undefined => {\n for (const item of items) {\n if (item.data?.root) {\n if (!firstFoundRoot) {\n firstFoundRoot = item.route;\n }\n\n if (primaryPrefix && item.route.startsWith(primaryPrefix)) {\n return item.route;\n }\n }\n \n if (item.children?.length) {\n const childRoot = findRootRoute(item.children);\n if (childRoot) return childRoot;\n }\n }\n return undefined;\n };\n\n const perfectMatch = findRootRoute(viewableRoutes);\n\n return perfectMatch ?? firstFoundRoot ?? primaryPrefix;\n });\n\n public readonly menu = computed(() => this.buildMenu(this.routes()));\n\n constructor() {\n this.updateCurrent();\n\n this.router.events\n .pipe(filter((e): e is NavigationEnd => e instanceof NavigationEnd))\n .subscribe(() => this.updateCurrent());\n }\n\n public navigateBack(): void {\n const breadcrumbs = this.current().breadcrumbs;\n \n if (breadcrumbs.length > 1) {\n const previousBreadcrumb = breadcrumbs[breadcrumbs.length - 2];\n this.router.navigateByUrl(previousBreadcrumb.route);\n } else {\n this.router.navigateByUrl(this.routeBase() ?? '/');\n }\n }\n\n //#region Helpers\n\n private updateCurrent(): void {\n this._current.set(\n this.resolveCurrent(this.router.routerState.snapshot.root)\n );\n }\n\n private extractRoutes(routes: Routes, parentSegment: string[] = []): INavigationItem[] {\n const items: INavigationItem[] = [];\n\n for(const route of routes) {\n if(route.redirectTo) continue;\n\n if (this.accessAdapter && !this.accessAdapter.canAccessMenu(route.data ?? {})) {\n continue;\n }\n\n const ownPath = route.path ?? '';\n \n const fullSegments = ownPath \n ? [...parentSegment, ownPath] \n : [...parentSegment];\n\n const fullRoute = '/' + fullSegments.filter(Boolean).join('/');\n\n const children = route.children?.length\n ? this.extractRoutes(route.children, fullSegments)\n : [];\n \n const nav = route.data?.['nav'] as INavMeta | undefined;\n\n if(!nav) {\n items.push(...children);\n continue;\n }\n\n const item = {\n id: fullRoute,\n route: fullRoute,\n label: this.resolveNavText(nav, 'label') ?? '',\n icon: nav.icon,\n section: nav.section,\n visible: nav.visible ? nav.visible() : true,\n data: nav,\n children\n };\n\n items.push(item);\n }\n\n return this.sortNavigationItems(items);\n }\n\n private resolveCurrent(root: ActivatedRouteSnapshot): IResolvedNavigation {\n let currentNode: ActivatedRouteSnapshot | null = root;\n let finalSnapshot: ActivatedRouteSnapshot | undefined;\n\n while (currentNode) {\n const next: ActivatedRouteSnapshot | null = currentNode.children.find(child => child.outlet === 'primary') ?? null;\n if (!next) {\n finalSnapshot = currentNode;\n break;\n }\n currentNode = next;\n }\n\n if (!finalSnapshot) return { breadcrumbs: [] };\n\n const urlSegments = finalSnapshot.pathFromRoot\n .flatMap(s => s.url.map(u => u.path))\n .filter(Boolean);\n\n const breadcrumbs: IBreadcrumbItem[] = [];\n const allItems = this.flattenRoutes(this.routes());\n let currentUrl = '';\n\n for (const segment of urlSegments) {\n currentUrl += '/' + segment;\n \n const matchingItem = this.matchRouteToUrl(allItems, currentUrl);\n\n if (matchingItem && matchingItem.data && !matchingItem.data.hidden) {\n const label = this.resolveNavText(matchingItem.data, 'breadcrumb', finalSnapshot) \n ?? this.resolveNavText(matchingItem.data, 'label', finalSnapshot);\n \n if (label && breadcrumbs[breadcrumbs.length - 1]?.label !== label) {\n breadcrumbs.push({ label, route: currentUrl });\n }\n }\n }\n\n const leafNav = finalSnapshot.routeConfig?.data?.['nav'] as INavMeta | undefined;\n const fullUrl = '/' + urlSegments.join('/');\n \n let current: INavigationItem | undefined;\n\n if (leafNav && !leafNav.hidden) {\n current = {\n id: fullUrl,\n route: fullUrl,\n label: this.resolveNavText(leafNav, 'label', finalSnapshot) ?? '',\n icon: leafNav.icon,\n section: leafNav.section,\n visible: leafNav.visible ? leafNav.visible() : true,\n data: leafNav\n };\n }\n\n return { current, breadcrumbs };\n }\n\n private buildMenu(items: INavigationItem[]): INavigationItem[] {\n return items\n .map((item): INavigationItem | null => {\n const children = this.buildMenu(item.children ?? []);\n const includeSelf = item.visible && item.data?.menu !== false;\n\n if (!includeSelf && !children.length) {\n return null;\n }\n\n return {\n ...item,\n children\n };\n }) \n .filter((item): item is INavigationItem => item !== null);\n }\n\n private sortNavigationItems(items: INavigationItem[]): INavigationItem[] {\n const customSort = this.config?.sortItems;\n\n return [...items].sort((a, b) => {\n if(customSort) {\n return customSort(a, b);\n }\n\n const orderA = a.data?.order ?? Number.POSITIVE_INFINITY;\n const orderB = b.data?.order ?? Number.POSITIVE_INFINITY;\n\n if(orderA !== orderB) return orderA - orderB;\n return a.label.localeCompare(b.label);\n });\n }\n\n private resolveNavText(\n nav: INavMeta,\n kind: 'label' | 'breadcrumb',\n snapshot?: ActivatedRouteSnapshot\n ): string | undefined {\n const directValue = kind === 'label' ? nav.label : nav.breadcrumb;\n const key = kind === 'label' ? nav.labelKey : nav.breadcrumbKey;\n\n if(directValue) {\n return typeof directValue === 'function'\n ? directValue({ snapshot: snapshot! })\n : directValue;\n }\n\n if(key) {\n return this.i18n?.translate(key, { route: snapshot });\n }\n\n return undefined;\n }\n\n private matchRouteToUrl(items: INavigationItem[], url: string): INavigationItem | undefined {\n const exactMatch = items.find(i => i.route === url);\n if (exactMatch) return exactMatch;\n\n return items.find(i => {\n if (!i.route.includes(':')) return false;\n const routeRegex = new RegExp('^' + i.route.replace(/:[^\\s/]+/g, '([^/]+)') + '$');\n return routeRegex.test(url);\n });\n }\n\n private flattenRoutes(items: INavigationItem[]): INavigationItem[] {\n return items.reduce((acc, item) => {\n acc.push(item);\n if (item.children) acc.push(...this.flattenRoutes(item.children));\n return acc;\n }, [] as INavigationItem[]);\n }\n\n //#endregion\n}","import { INavMeta } from \"@navigation/interfaces/inav-meta.interface\";\nimport { INavigationConfig } from \"../interfaces/inavigation-config.interface\";\nimport { NAVIGATION_CONFIG } from \"../tokens/navigation-config.token\";\nimport { Route } from \"@angular/router\";\n\nexport function provideNavigation(config: INavigationConfig) {\n return [\n {\n provide: NAVIGATION_CONFIG,\n useValue: config\n }\n ];\n};\n\nexport function withNav(route: Route, nav: INavMeta): Route {\n const existingNav = (route.data?.['nav'] as INavMeta | undefined) ?? {};\n\n return {\n ...route,\n data: {\n ...(route.data ?? {}),\n nav: {\n ...existingNav,\n ...nav\n }\n }\n };\n}","/*\n * Public API Surface of modal\n */\n\nexport * from './services/navigation.service';\n\nexport * from './interfaces/ibreadcrumb-item.interface';\nexport * from './interfaces/inav-context.interface';\nexport * from './interfaces/inav-meta.interface';\nexport * from './interfaces/inav-route-data.interface';\nexport * from './interfaces/inavigation-access-adapter.interface';\nexport * from './interfaces/inavigation-config.interface';\nexport * from './interfaces/inavigation-i18n-adapter.interface';\nexport * from './interfaces/inavigation-item.interface';\nexport * from './interfaces/inavigation-section-config.interface';\nexport * from './interfaces/iresolved-navigation.interface';\n\nexport * from './tokens/navigation-config.token';\nexport * from './tokens/navigation-i18n.token';\nexport * from './tokens/navigation-access-adapter.token';\n\nexport * from './helpers/navigation-functions';","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;MAGa,iBAAiB,GAAG,IAAI,cAAc,CAAoB,mBAAmB;;MCA7E,eAAe,GAAG,IAAI,cAAc,CAAyB,iBAAiB;;MCA9E,yBAAyB,GAAG,IAAI,cAAc,CAA2B,2BAA2B;;MCSpG,iBAAiB,CAAA;AACX,IAAA,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IACvB,MAAM,GAAG,MAAM,CAAC,iBAAiB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACtD,IAAI,GAAG,MAAM,CAAC,eAAe,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAClD,aAAa,GAAG,MAAM,CAAC,yBAAyB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAErE,QAAQ,GAAG,MAAM,CAAsB,EAAE,WAAW,EAAE,EAAE,EAAE,EAAA,IAAA,SAAA,GAAA,CAAA,EAAA,SAAA,EAAA,UAAA,EAAA,CAAA,8BAAA,EAAA,CAAA,CAAC;AAC5D,IAAA,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE;AAEpC,IAAA,SAAS,GAAG,QAAQ,CAAqB,MAAK;AA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M,WAAW,GAAI,KAAK,CAAC,IAAI,GAAG,KAAK,CAA0B,IAAI,EAAE;IAEvE,OAAO;AACL,QAAA,GAAG,KAAK;AACR,QAAA,IAAI,EAAE;AACJ,YAAA,IAAI,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC;AACrB,YAAA,GAAG,EAAE;AACH,gBAAA,GAAG,WAAW;AACd,gBAAA,GAAG;AACJ;AACF;KACF;AACH;;AC3BA;;AAEG;;ACFH;;AAEG;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filip.mazev-blocks.mjs","sources":["../../../projects/blocks/src/public-api.ts","../../../projects/blocks/src/filip.mazev-blocks.ts"],"sourcesContent":["/* * Public API Surface of blocks\n * This file is auto-generated. Do not edit directly.\n */\n\nexport const BLOCKS_VERSION = '1.2.
|
|
1
|
+
{"version":3,"file":"filip.mazev-blocks.mjs","sources":["../../../projects/blocks/src/public-api.ts","../../../projects/blocks/src/filip.mazev-blocks.ts"],"sourcesContent":["/* * Public API Surface of blocks\n * This file is auto-generated. Do not edit directly.\n */\n\nexport const BLOCKS_VERSION = '1.2.18';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"AAAA;;AAEG;AAEI,MAAM,cAAc,GAAG;;ACJ9B;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -52,13 +52,8 @@ declare class NavigationService {
|
|
|
52
52
|
readonly current: Signal<IResolvedNavigation>;
|
|
53
53
|
readonly routeBase: Signal<string | undefined>;
|
|
54
54
|
readonly routes: Signal<INavigationItem[]>;
|
|
55
|
+
readonly baseRoute: Signal<string | undefined>;
|
|
55
56
|
readonly menu: Signal<INavigationItem[]>;
|
|
56
|
-
readonly sections: Signal<{
|
|
57
|
-
items: INavigationItem[];
|
|
58
|
-
id: string;
|
|
59
|
-
title?: string;
|
|
60
|
-
order?: number;
|
|
61
|
-
}[]>;
|
|
62
57
|
constructor();
|
|
63
58
|
navigateBack(): void;
|
|
64
59
|
private updateCurrent;
|
|
@@ -67,7 +62,8 @@ declare class NavigationService {
|
|
|
67
62
|
private buildMenu;
|
|
68
63
|
private sortNavigationItems;
|
|
69
64
|
private resolveNavText;
|
|
70
|
-
private
|
|
65
|
+
private matchRouteToUrl;
|
|
66
|
+
private flattenRoutes;
|
|
71
67
|
static ɵfac: i0.ɵɵFactoryDeclaration<NavigationService, never>;
|
|
72
68
|
static ɵprov: i0.ɵɵInjectableDeclaration<NavigationService>;
|
|
73
69
|
}
|