@lucca-front/ng 19.2.7-rc.1 → 19.2.8-rc.1
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.
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, Injectable, Inject, NgModule } from '@angular/core';
|
|
2
|
+
import { InjectionToken, Injectable, Inject, NgModule, inject } from '@angular/core';
|
|
3
3
|
import * as i1 from '@angular/router';
|
|
4
4
|
import { ActivationEnd, RouterModule, TitleStrategy } from '@angular/router';
|
|
5
5
|
import { BehaviorSubject, combineLatest, of } from 'rxjs';
|
|
6
6
|
import { switchMap, map, filter, distinctUntilChanged, tap } from 'rxjs/operators';
|
|
7
7
|
import * as i2 from '@angular/platform-browser';
|
|
8
|
+
import { Title } from '@angular/platform-browser';
|
|
8
9
|
|
|
9
10
|
const LU_TITLE_TRANSLATE_SERVICE = new InjectionToken('LU_TITLE_TRANSLATE_SERVICE');
|
|
10
11
|
|
|
@@ -72,13 +73,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
|
|
|
72
73
|
}]
|
|
73
74
|
}] });
|
|
74
75
|
|
|
75
|
-
const APP_TITLE = new InjectionToken('APP_TITLE');
|
|
76
|
+
const ɵAPP_TITLE = new InjectionToken('APP_TITLE');
|
|
77
|
+
/**
|
|
78
|
+
* @deprecated Use `provideLuTitleStrategy` instead.
|
|
79
|
+
*/
|
|
80
|
+
const APP_TITLE = ɵAPP_TITLE;
|
|
76
81
|
class LuTitleStrategy extends TitleStrategy {
|
|
77
|
-
constructor(
|
|
82
|
+
constructor() {
|
|
78
83
|
super();
|
|
79
|
-
this.title =
|
|
80
|
-
this.translateService =
|
|
81
|
-
this.appTitle =
|
|
84
|
+
this.title = inject(Title);
|
|
85
|
+
this.translateService = inject(LU_TITLE_TRANSLATE_SERVICE, { optional: true });
|
|
86
|
+
this.appTitle = inject(ɵAPP_TITLE);
|
|
82
87
|
this.titlePartsSubject = new BehaviorSubject(['Lucca']);
|
|
83
88
|
this.titleParts$ = this.titlePartsSubject.asObservable();
|
|
84
89
|
this.title$ = this.titleParts$.pipe(switchMap((titleParts) => combineLatest(titleParts.map((part) => (typeof part === 'string' ? of(part) : part)))), map((parts) => parts.join(TitleSeparator)), distinctUntilChanged());
|
|
@@ -89,9 +94,9 @@ class LuTitleStrategy extends TitleStrategy {
|
|
|
89
94
|
const pageTitles = this.#getPageTitleParts(routerState.root).reverse();
|
|
90
95
|
const translatedPageTitles = uniqTitle(pageTitles)
|
|
91
96
|
.filter(({ title }) => title !== '')
|
|
92
|
-
.map(({ title, params }) => this.translateService.translate(title, params));
|
|
97
|
+
.map(({ title, params }) => (this.translateService ? this.translateService.translate(title, params) : title));
|
|
93
98
|
// Add the name app and 'Lucca' at the end of the title
|
|
94
|
-
const titleParts = [...translatedPageTitles, this.
|
|
99
|
+
const titleParts = [...translatedPageTitles, this.appTitle, 'Lucca'].filter((x) => !!x);
|
|
95
100
|
this.titlePartsSubject.next(titleParts);
|
|
96
101
|
}
|
|
97
102
|
prependTitle(title) {
|
|
@@ -107,26 +112,30 @@ class LuTitleStrategy extends TitleStrategy {
|
|
|
107
112
|
};
|
|
108
113
|
return snapshot.firstChild ? [pageTitle, ...this.#getPageTitleParts(snapshot.firstChild)] : [pageTitle];
|
|
109
114
|
}
|
|
110
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: LuTitleStrategy, deps: [
|
|
115
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: LuTitleStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
111
116
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: LuTitleStrategy, providedIn: 'root' }); }
|
|
112
117
|
}
|
|
113
118
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: LuTitleStrategy, decorators: [{
|
|
114
119
|
type: Injectable,
|
|
115
120
|
args: [{ providedIn: 'root' }]
|
|
116
|
-
}], ctorParameters: () => [
|
|
117
|
-
type: Inject,
|
|
118
|
-
args: [LU_TITLE_TRANSLATE_SERVICE]
|
|
119
|
-
}] }, { type: undefined, decorators: [{
|
|
120
|
-
type: Inject,
|
|
121
|
-
args: [APP_TITLE]
|
|
122
|
-
}] }] });
|
|
121
|
+
}], ctorParameters: () => [] });
|
|
123
122
|
function uniqTitle(titleParts) {
|
|
124
123
|
return titleParts.filter(({ title }, index) => titleParts.findIndex((pageTitle) => pageTitle.title === title) === index);
|
|
125
124
|
}
|
|
125
|
+
function provideLuTitleStrategy(options) {
|
|
126
|
+
const providers = [{ provide: TitleStrategy, useClass: LuTitleStrategy }];
|
|
127
|
+
if (options.appTitle) {
|
|
128
|
+
providers.push({ provide: ɵAPP_TITLE, useFactory: options.appTitle });
|
|
129
|
+
}
|
|
130
|
+
if (options.translateService) {
|
|
131
|
+
providers.push({ provide: LU_TITLE_TRANSLATE_SERVICE, useFactory: options.translateService });
|
|
132
|
+
}
|
|
133
|
+
return providers;
|
|
134
|
+
}
|
|
126
135
|
|
|
127
136
|
/**
|
|
128
137
|
* Generated bundle index. Do not edit.
|
|
129
138
|
*/
|
|
130
139
|
|
|
131
|
-
export { APP_TITLE, LU_TITLE_TRANSLATE_SERVICE, LuTitleModule, LuTitleService, LuTitleStrategy, TitleSeparator };
|
|
140
|
+
export { APP_TITLE, LU_TITLE_TRANSLATE_SERVICE, LuTitleModule, LuTitleService, LuTitleStrategy, TitleSeparator, provideLuTitleStrategy, ɵAPP_TITLE };
|
|
132
141
|
//# sourceMappingURL=lucca-front-ng-title.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lucca-front-ng-title.mjs","sources":["../../../packages/ng/title/title-translate.service.ts","../../../packages/ng/title/title.model.ts","../../../packages/ng/title/title.service.ts","../../../packages/ng/title/title.module.ts","../../../packages/ng/title/title.strategy.ts","../../../packages/ng/title/lucca-front-ng-title.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\nexport const LU_TITLE_TRANSLATE_SERVICE = new InjectionToken<ILuTitleTranslateService>('LU_TITLE_TRANSLATE_SERVICE');\n\nexport interface ILuTitleTranslateService {\n\ttranslate(key: string, args?: Record<string, unknown>): string;\n}\n","export type PageTitle = { title: string; params?: { [param: string]: string } };\nexport const TitleSeparator = ' – ';\n","import { Inject, Injectable } from '@angular/core';\nimport { Title } from '@angular/platform-browser';\nimport { ActivatedRouteSnapshot, ActivationEnd, Router } from '@angular/router';\nimport { BehaviorSubject, combineLatest, ObservableInput, of } from 'rxjs';\nimport { distinctUntilChanged, filter, map, switchMap, tap } from 'rxjs/operators';\nimport { ILuTitleTranslateService, LU_TITLE_TRANSLATE_SERVICE } from './title-translate.service';\nimport { PageTitle, TitleSeparator } from './title.model';\n\n/**\n * @deprecated use Title strategy instead\n */\n@Injectable()\nexport class LuTitleService {\n\tprivate titlePartsSubject = new BehaviorSubject<Array<string | ObservableInput<string>>>(['Lucca']);\n\ttitleParts$ = this.titlePartsSubject.asObservable();\n\ttitle$ = this.titleParts$.pipe(\n\t\tswitchMap((titleParts) => combineLatest(titleParts.map((part) => (typeof part === 'string' ? of(part) : part)))),\n\t\tmap((parts) => parts.join(TitleSeparator)),\n\t);\n\n\tconstructor(\n\t\tprivate router: Router,\n\t\tprivate title: Title,\n\t\t@Inject(LU_TITLE_TRANSLATE_SERVICE) private translateService: ILuTitleTranslateService,\n\t) {}\n\n\tinit(applicationNameTranslationKey: string) {\n\t\tthis.router.events\n\t\t\t.pipe(\n\t\t\t\tfilter((event) => {\n\t\t\t\t\treturn event instanceof ActivationEnd && event.snapshot.children.length === 0;\n\t\t\t\t}),\n\t\t\t\tmap((event: ActivationEnd) => getPageTitleParts(event.snapshot)),\n\t\t\t\tmap((titleParts) => uniqTitle(titleParts)),\n\t\t\t\tmap((titleParts) => titleParts.filter(({ title }) => title !== '').map(({ title, params }) => this.translateService.translate(title, params))),\n\t\t\t\tmap((titleParts: Array<string>) => [...titleParts, this.translateService.translate(applicationNameTranslationKey, {}), 'Lucca'].filter((x) => !!x)),\n\t\t\t\tdistinctUntilChanged(),\n\t\t\t\ttap((titleParts) => this.titlePartsSubject.next(titleParts)),\n\t\t\t)\n\t\t\t.subscribe();\n\n\t\tthis.title$.pipe(tap((title) => this.title.setTitle(title))).subscribe();\n\t}\n\n\tprependTitle(title: string | ObservableInput<string>) {\n\t\tthis.titlePartsSubject.next([title, ...this.titlePartsSubject.value]);\n\t}\n\n\toverrideFirstTitlePart(title: string | ObservableInput<string>) {\n\t\tthis.titlePartsSubject.next([title, ...this.titlePartsSubject.value.slice(1)]);\n\t}\n}\n\nfunction getPageTitleParts(snapshot: ActivatedRouteSnapshot): Array<PageTitle> {\n\tconst pageTitle: PageTitle = {\n\t\ttitle: (snapshot.data?.['title'] || '') as string,\n\t\tparams: { ...snapshot.params, ...snapshot.data },\n\t};\n\treturn snapshot.parent ? [pageTitle, ...getPageTitleParts(snapshot.parent)] : [pageTitle];\n}\n\nfunction uniqTitle(titleParts: Array<PageTitle>): Array<PageTitle> {\n\treturn titleParts.filter(({ title }, index) => titleParts.findIndex((pageTitle) => pageTitle.title === title) === index);\n}\n","import { NgModule } from '@angular/core';\nimport { RouterModule } from '@angular/router';\nimport { LuTitleService } from './title.service';\n\n/**\n * @deprecated use title streatgy instead\n */\n@NgModule({\n\timports: [RouterModule],\n\tproviders: [LuTitleService],\n})\nexport class LuTitleModule {}\n","import { Inject, Injectable, InjectionToken } from '@angular/core';\nimport { Title } from '@angular/platform-browser';\nimport { ActivatedRouteSnapshot, RouterStateSnapshot, TitleStrategy } from '@angular/router';\nimport { BehaviorSubject, combineLatest, ObservableInput, of } from 'rxjs';\nimport { distinctUntilChanged, map, switchMap, tap } from 'rxjs/operators';\nimport { ILuTitleTranslateService, LU_TITLE_TRANSLATE_SERVICE } from './title-translate.service';\nimport { PageTitle, TitleSeparator } from './title.model';\n\nexport const APP_TITLE = new InjectionToken('APP_TITLE');\n\n@Injectable({ providedIn: 'root' })\nexport class LuTitleStrategy extends TitleStrategy {\n\tprivate titlePartsSubject = new BehaviorSubject<Array<string | ObservableInput<string>>>(['Lucca']);\n\ttitleParts$ = this.titlePartsSubject.asObservable();\n\ttitle$ = this.titleParts$.pipe(\n\t\tswitchMap((titleParts) => combineLatest(titleParts.map((part) => (typeof part === 'string' ? of(part) : part)))),\n\t\tmap((parts) => parts.join(TitleSeparator)),\n\t\tdistinctUntilChanged(),\n\t);\n\tconstructor(\n\t\tprivate title: Title,\n\t\t@Inject(LU_TITLE_TRANSLATE_SERVICE) private translateService: ILuTitleTranslateService,\n\t\t@Inject(APP_TITLE) private appTitle: string,\n\t) {\n\t\tsuper();\n\t\tthis.title$.pipe(tap((title) => this.title.setTitle(title))).subscribe();\n\t}\n\n\toverride updateTitle(routerState: RouterStateSnapshot) {\n\t\t// Title page is display from child to root\n\t\tconst pageTitles = this.#getPageTitleParts(routerState.root).reverse();\n\t\tconst translatedPageTitles = uniqTitle(pageTitles)\n\t\t\t.filter(({ title }) => title !== '')\n\t\t\t.map(({ title, params }) => this.translateService.translate(title, params));\n\t\t// Add the name app and 'Lucca' at the end of the title\n\t\tconst titleParts = [...translatedPageTitles, this.translateService.translate(this.appTitle), 'Lucca'].filter((x) => !!x);\n\t\tthis.titlePartsSubject.next(titleParts);\n\t}\n\n\tprependTitle(title: string | ObservableInput<string>) {\n\t\tthis.titlePartsSubject.next([title, ...this.titlePartsSubject.value]);\n\t}\n\n\toverrideFirstTitlePart(title: string | ObservableInput<string>) {\n\t\tthis.titlePartsSubject.next([title, ...this.titlePartsSubject.value.slice(1)]);\n\t}\n\n\t#getPageTitleParts(snapshot: ActivatedRouteSnapshot): Array<PageTitle> {\n\t\tconst pageTitle: PageTitle = {\n\t\t\ttitle: this.getResolvedTitleForRoute(snapshot) as string,\n\t\t\tparams: { ...snapshot.params, ...snapshot.data },\n\t\t};\n\t\treturn snapshot.firstChild ? [pageTitle, ...this.#getPageTitleParts(snapshot.firstChild)] : [pageTitle];\n\t}\n}\n\nfunction uniqTitle(titleParts: Array<PageTitle>): Array<PageTitle> {\n\treturn titleParts.filter(({ title }, index) => titleParts.findIndex((pageTitle) => pageTitle.title === title) === index);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["uniqTitle","i1"],"mappings":";;;;;;;;MAEa,0BAA0B,GAAG,IAAI,cAAc,CAA2B,4BAA4B;;ACD5G,MAAM,cAAc,GAAG;;ACO9B;;AAEG;MAEU,cAAc,CAAA;AAQ1B,IAAA,WAAA,CACS,MAAc,EACd,KAAY,EACwB,gBAA0C,EAAA;QAF9E,IAAM,CAAA,MAAA,GAAN,MAAM;QACN,IAAK,CAAA,KAAA,GAAL,KAAK;QAC+B,IAAgB,CAAA,gBAAA,GAAhB,gBAAgB;QAVrD,IAAiB,CAAA,iBAAA,GAAG,IAAI,eAAe,CAA0C,CAAC,OAAO,CAAC,CAAC;AACnG,QAAA,IAAA,CAAA,WAAW,GAAG,IAAI,CAAC,iBAAiB,CAAC,YAAY,EAAE;AACnD,QAAA,IAAA,CAAA,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAC7B,SAAS,CAAC,CAAC,UAAU,KAAK,aAAa,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,MAAM,OAAO,IAAI,KAAK,QAAQ,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,EAChH,GAAG,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAC1C;;AAQD,IAAA,IAAI,CAAC,6BAAqC,EAAA;QACzC,IAAI,CAAC,MAAM,CAAC;AACV,aAAA,IAAI,CACJ,MAAM,CAAC,CAAC,KAAK,KA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C,KAAK,KAAK,KAAK,CAAC,KAAK,KAAK,CAAC;AACzH;;AC1DA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"lucca-front-ng-title.mjs","sources":["../../../packages/ng/title/title-translate.service.ts","../../../packages/ng/title/title.model.ts","../../../packages/ng/title/title.service.ts","../../../packages/ng/title/title.module.ts","../../../packages/ng/title/title.strategy.ts","../../../packages/ng/title/lucca-front-ng-title.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\nimport { Observable } from 'rxjs';\n\nexport const LU_TITLE_TRANSLATE_SERVICE = new InjectionToken<ILuTitleTranslateService>('LU_TITLE_TRANSLATE_SERVICE');\n\nexport interface ILuTitleTranslateService {\n\ttranslate(key: string, args?: Record<string, unknown>): string | Observable<string>;\n}\n","export type PageTitle = { title: string; params?: { [param: string]: string } };\nexport const TitleSeparator = ' – ';\n","import { Inject, Injectable } from '@angular/core';\nimport { Title } from '@angular/platform-browser';\nimport { ActivatedRouteSnapshot, ActivationEnd, Router } from '@angular/router';\nimport { BehaviorSubject, combineLatest, ObservableInput, of } from 'rxjs';\nimport { distinctUntilChanged, filter, map, switchMap, tap } from 'rxjs/operators';\nimport { ILuTitleTranslateService, LU_TITLE_TRANSLATE_SERVICE } from './title-translate.service';\nimport { PageTitle, TitleSeparator } from './title.model';\n\n/**\n * @deprecated use Title strategy instead\n */\n@Injectable()\nexport class LuTitleService {\n\tprivate titlePartsSubject = new BehaviorSubject<Array<string | ObservableInput<string>>>(['Lucca']);\n\ttitleParts$ = this.titlePartsSubject.asObservable();\n\ttitle$ = this.titleParts$.pipe(\n\t\tswitchMap((titleParts) => combineLatest(titleParts.map((part) => (typeof part === 'string' ? of(part) : part)))),\n\t\tmap((parts) => parts.join(TitleSeparator)),\n\t);\n\n\tconstructor(\n\t\tprivate router: Router,\n\t\tprivate title: Title,\n\t\t@Inject(LU_TITLE_TRANSLATE_SERVICE) private translateService: ILuTitleTranslateService,\n\t) {}\n\n\tinit(applicationNameTranslationKey: string) {\n\t\tthis.router.events\n\t\t\t.pipe(\n\t\t\t\tfilter((event) => {\n\t\t\t\t\treturn event instanceof ActivationEnd && event.snapshot.children.length === 0;\n\t\t\t\t}),\n\t\t\t\tmap((event: ActivationEnd) => getPageTitleParts(event.snapshot)),\n\t\t\t\tmap((titleParts) => uniqTitle(titleParts)),\n\t\t\t\tmap((titleParts) => titleParts.filter(({ title }) => title !== '').map(({ title, params }) => this.translateService.translate(title, params))),\n\t\t\t\tmap((titleParts: Array<string>) => [...titleParts, this.translateService.translate(applicationNameTranslationKey, {}), 'Lucca'].filter((x) => !!x)),\n\t\t\t\tdistinctUntilChanged(),\n\t\t\t\ttap((titleParts) => this.titlePartsSubject.next(titleParts)),\n\t\t\t)\n\t\t\t.subscribe();\n\n\t\tthis.title$.pipe(tap((title) => this.title.setTitle(title))).subscribe();\n\t}\n\n\tprependTitle(title: string | ObservableInput<string>) {\n\t\tthis.titlePartsSubject.next([title, ...this.titlePartsSubject.value]);\n\t}\n\n\toverrideFirstTitlePart(title: string | ObservableInput<string>) {\n\t\tthis.titlePartsSubject.next([title, ...this.titlePartsSubject.value.slice(1)]);\n\t}\n}\n\nfunction getPageTitleParts(snapshot: ActivatedRouteSnapshot): Array<PageTitle> {\n\tconst pageTitle: PageTitle = {\n\t\ttitle: (snapshot.data?.['title'] || '') as string,\n\t\tparams: { ...snapshot.params, ...snapshot.data },\n\t};\n\treturn snapshot.parent ? [pageTitle, ...getPageTitleParts(snapshot.parent)] : [pageTitle];\n}\n\nfunction uniqTitle(titleParts: Array<PageTitle>): Array<PageTitle> {\n\treturn titleParts.filter(({ title }, index) => titleParts.findIndex((pageTitle) => pageTitle.title === title) === index);\n}\n","import { NgModule } from '@angular/core';\nimport { RouterModule } from '@angular/router';\nimport { LuTitleService } from './title.service';\n\n/**\n * @deprecated use title streatgy instead\n */\n@NgModule({\n\timports: [RouterModule],\n\tproviders: [LuTitleService],\n})\nexport class LuTitleModule {}\n","import { inject, Injectable, InjectionToken, Provider } from '@angular/core';\nimport { Title } from '@angular/platform-browser';\nimport { ActivatedRouteSnapshot, RouterStateSnapshot, TitleStrategy } from '@angular/router';\nimport { BehaviorSubject, combineLatest, Observable, ObservableInput, of } from 'rxjs';\nimport { distinctUntilChanged, map, switchMap, tap } from 'rxjs/operators';\nimport { ILuTitleTranslateService, LU_TITLE_TRANSLATE_SERVICE } from './title-translate.service';\nimport { PageTitle, TitleSeparator } from './title.model';\n\nexport const ɵAPP_TITLE = new InjectionToken<string | Observable<string>>('APP_TITLE');\n\n/**\n * @deprecated Use `provideLuTitleStrategy` instead.\n */\nexport const APP_TITLE = ɵAPP_TITLE;\n\n@Injectable({ providedIn: 'root' })\nexport class LuTitleStrategy extends TitleStrategy {\n\tprivate title = inject(Title);\n\tprivate translateService = inject<ILuTitleTranslateService>(LU_TITLE_TRANSLATE_SERVICE, { optional: true });\n\tprivate appTitle = inject(ɵAPP_TITLE);\n\n\tprivate titlePartsSubject = new BehaviorSubject<Array<string | ObservableInput<string>>>(['Lucca']);\n\ttitleParts$ = this.titlePartsSubject.asObservable();\n\ttitle$ = this.titleParts$.pipe(\n\t\tswitchMap((titleParts) => combineLatest(titleParts.map((part) => (typeof part === 'string' ? of(part) : part)))),\n\t\tmap((parts) => parts.join(TitleSeparator)),\n\t\tdistinctUntilChanged(),\n\t);\n\tconstructor() {\n\t\tsuper();\n\t\tthis.title$.pipe(tap((title) => this.title.setTitle(title))).subscribe();\n\t}\n\n\toverride updateTitle(routerState: RouterStateSnapshot) {\n\t\t// Title page is display from child to root\n\t\tconst pageTitles = this.#getPageTitleParts(routerState.root).reverse();\n\t\tconst translatedPageTitles = uniqTitle(pageTitles)\n\t\t\t.filter(({ title }) => title !== '')\n\t\t\t.map(({ title, params }) => (this.translateService ? this.translateService.translate(title, params) : title));\n\t\t// Add the name app and 'Lucca' at the end of the title\n\t\tconst titleParts = [...translatedPageTitles, this.appTitle, 'Lucca'].filter((x) => !!x);\n\t\tthis.titlePartsSubject.next(titleParts);\n\t}\n\n\tprependTitle(title: string | ObservableInput<string>) {\n\t\tthis.titlePartsSubject.next([title, ...this.titlePartsSubject.value]);\n\t}\n\n\toverrideFirstTitlePart(title: string | ObservableInput<string>) {\n\t\tthis.titlePartsSubject.next([title, ...this.titlePartsSubject.value.slice(1)]);\n\t}\n\n\t#getPageTitleParts(snapshot: ActivatedRouteSnapshot): Array<PageTitle> {\n\t\tconst pageTitle: PageTitle = {\n\t\t\ttitle: this.getResolvedTitleForRoute(snapshot) as string,\n\t\t\tparams: { ...snapshot.params, ...snapshot.data },\n\t\t};\n\t\treturn snapshot.firstChild ? [pageTitle, ...this.#getPageTitleParts(snapshot.firstChild)] : [pageTitle];\n\t}\n}\n\nfunction uniqTitle(titleParts: Array<PageTitle>): Array<PageTitle> {\n\treturn titleParts.filter(({ title }, index) => titleParts.findIndex((pageTitle) => pageTitle.title === title) === index);\n}\n\nexport interface LuTitleStrategyOptions {\n\tappTitle?: () => string | Observable<string>;\n\ttranslateService?: () => ILuTitleTranslateService;\n}\n\nexport function provideLuTitleStrategy(options: LuTitleStrategyOptions): Provider[] {\n\tconst providers: Provider[] = [{ provide: TitleStrategy, useClass: LuTitleStrategy }];\n\n\tif (options.appTitle) {\n\t\tproviders.push({ provide: ɵAPP_TITLE, useFactory: options.appTitle });\n\t}\n\tif (options.translateService) {\n\t\tproviders.push({ provide: LU_TITLE_TRANSLATE_SERVICE, useFactory: options.translateService });\n\t}\n\n\treturn providers;\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["uniqTitle"],"mappings":";;;;;;;;;MAGa,0BAA0B,GAAG,IAAI,cAAc,CAA2B,4BAA4B;;ACF5G,MAAM,cAAc,GAAG;;ACO9B;;AAEG;MAEU,cAAc,CAAA;AAQ1B,IAAA,WAAA,CACS,MAAc,EACd,KAAY,EACwB,gBAA0C,EAAA;QAF9E,IAAM,CAAA,MAAA,GAAN,MAAM;QACN,IAAK,CAAA,KAAA,GAAL,KAAK;QAC+B,IAAgB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.8-rc.1",
|
|
4
4
|
"description": "A library of icons made by the team @Lucca",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"@angular/common": "^19.0.0",
|
|
27
27
|
"@angular/core": "^19.0.0",
|
|
28
28
|
"@angular/cdk": "^19.0.0",
|
|
29
|
-
"@lucca-front/icons": "19.2.
|
|
30
|
-
"@lucca-front/scss": "19.2.
|
|
29
|
+
"@lucca-front/icons": "19.2.8-rc.1",
|
|
30
|
+
"@lucca-front/scss": "19.2.8-rc.1",
|
|
31
31
|
"isomorphic-dompurify": "^2.17.0",
|
|
32
32
|
"date-fns": "^3.6.0",
|
|
33
33
|
"rxjs": "^7.8.0"
|
|
@@ -49,34 +49,34 @@
|
|
|
49
49
|
"types": "./a11y/index.d.ts",
|
|
50
50
|
"default": "./fesm2022/lucca-front-ng-a11y.mjs"
|
|
51
51
|
},
|
|
52
|
+
"./button": {
|
|
53
|
+
"types": "./button/index.d.ts",
|
|
54
|
+
"default": "./fesm2022/lucca-front-ng-button.mjs"
|
|
55
|
+
},
|
|
52
56
|
"./animations": {
|
|
53
57
|
"types": "./animations/index.d.ts",
|
|
54
58
|
"default": "./fesm2022/lucca-front-ng-animations.mjs"
|
|
55
59
|
},
|
|
56
|
-
"./api": {
|
|
57
|
-
"types": "./api/index.d.ts",
|
|
58
|
-
"default": "./fesm2022/lucca-front-ng-api.mjs"
|
|
59
|
-
},
|
|
60
60
|
"./callout": {
|
|
61
61
|
"types": "./callout/index.d.ts",
|
|
62
62
|
"default": "./fesm2022/lucca-front-ng-callout.mjs"
|
|
63
63
|
},
|
|
64
|
-
"./
|
|
65
|
-
"types": "./
|
|
66
|
-
"default": "./fesm2022/lucca-front-ng-
|
|
64
|
+
"./comment": {
|
|
65
|
+
"types": "./comment/index.d.ts",
|
|
66
|
+
"default": "./fesm2022/lucca-front-ng-comment.mjs"
|
|
67
67
|
},
|
|
68
68
|
"./chip": {
|
|
69
69
|
"types": "./chip/index.d.ts",
|
|
70
70
|
"default": "./fesm2022/lucca-front-ng-chip.mjs"
|
|
71
71
|
},
|
|
72
|
-
"./comment": {
|
|
73
|
-
"types": "./comment/index.d.ts",
|
|
74
|
-
"default": "./fesm2022/lucca-front-ng-comment.mjs"
|
|
75
|
-
},
|
|
76
72
|
"./core": {
|
|
77
73
|
"types": "./core/index.d.ts",
|
|
78
74
|
"default": "./fesm2022/lucca-front-ng-core.mjs"
|
|
79
75
|
},
|
|
76
|
+
"./api": {
|
|
77
|
+
"types": "./api/index.d.ts",
|
|
78
|
+
"default": "./fesm2022/lucca-front-ng-api.mjs"
|
|
79
|
+
},
|
|
80
80
|
"./core-select": {
|
|
81
81
|
"types": "./core-select/index.d.ts",
|
|
82
82
|
"default": "./fesm2022/lucca-front-ng-core-select.mjs"
|
|
@@ -93,14 +93,14 @@
|
|
|
93
93
|
"types": "./department/index.d.ts",
|
|
94
94
|
"default": "./fesm2022/lucca-front-ng-department.mjs"
|
|
95
95
|
},
|
|
96
|
-
"./divider": {
|
|
97
|
-
"types": "./divider/index.d.ts",
|
|
98
|
-
"default": "./fesm2022/lucca-front-ng-divider.mjs"
|
|
99
|
-
},
|
|
100
96
|
"./dialog": {
|
|
101
97
|
"types": "./dialog/index.d.ts",
|
|
102
98
|
"default": "./fesm2022/lucca-front-ng-dialog.mjs"
|
|
103
99
|
},
|
|
100
|
+
"./divider": {
|
|
101
|
+
"types": "./divider/index.d.ts",
|
|
102
|
+
"default": "./fesm2022/lucca-front-ng-divider.mjs"
|
|
103
|
+
},
|
|
104
104
|
"./dropdown": {
|
|
105
105
|
"types": "./dropdown/index.d.ts",
|
|
106
106
|
"default": "./fesm2022/lucca-front-ng-dropdown.mjs"
|
|
@@ -121,14 +121,14 @@
|
|
|
121
121
|
"types": "./filter-pills/index.d.ts",
|
|
122
122
|
"default": "./fesm2022/lucca-front-ng-filter-pills.mjs"
|
|
123
123
|
},
|
|
124
|
-
"./formly": {
|
|
125
|
-
"types": "./formly/index.d.ts",
|
|
126
|
-
"default": "./fesm2022/lucca-front-ng-formly.mjs"
|
|
127
|
-
},
|
|
128
124
|
"./form-field": {
|
|
129
125
|
"types": "./form-field/index.d.ts",
|
|
130
126
|
"default": "./fesm2022/lucca-front-ng-form-field.mjs"
|
|
131
127
|
},
|
|
128
|
+
"./formly": {
|
|
129
|
+
"types": "./formly/index.d.ts",
|
|
130
|
+
"default": "./fesm2022/lucca-front-ng-formly.mjs"
|
|
131
|
+
},
|
|
132
132
|
"./forms": {
|
|
133
133
|
"types": "./forms/index.d.ts",
|
|
134
134
|
"default": "./fesm2022/lucca-front-ng-forms.mjs"
|
package/title/README.md
CHANGED
|
@@ -6,20 +6,20 @@ Add `title` properties in your routes config:
|
|
|
6
6
|
|
|
7
7
|
```typescript
|
|
8
8
|
const routes: Routes = [
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
9
|
+
{
|
|
10
|
+
path: '',
|
|
11
|
+
data: {
|
|
12
|
+
title: 'Parent title',
|
|
13
|
+
},
|
|
14
|
+
children: [
|
|
15
|
+
{
|
|
16
|
+
path: ':requestId',
|
|
17
|
+
data: {
|
|
18
|
+
title: 'Sub route title',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
23
|
];
|
|
24
24
|
```
|
|
25
25
|
|
|
@@ -27,26 +27,26 @@ The service should now be able to collect all `title` properties defined for the
|
|
|
27
27
|
|
|
28
28
|
ex: `Sub route title - Parent title - YourAppName - Lucca`
|
|
29
29
|
|
|
30
|
-
For dynamic titles, the `prependTitle` method from `
|
|
30
|
+
For dynamic titles, the `prependTitle` method from `LuTitleStrategy` enables you to add a custom title.
|
|
31
31
|
In a component, you could do the following:
|
|
32
32
|
|
|
33
33
|
```typescript
|
|
34
34
|
const userName: string = this.userService.getCurrentUser();
|
|
35
|
-
this.
|
|
35
|
+
this.luTitleStrategy.prependTitle(userName);
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
You can also replace the first fragment using:
|
|
39
39
|
|
|
40
40
|
```typescript
|
|
41
41
|
const userName: string = this.userService.getOtherUser();
|
|
42
|
-
this.
|
|
42
|
+
this.luTitleStrategy.overrideFirstTitlePart(userName);
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
Both `prependTitle` and `overrideFirstTitlePart` can also be called using `Observable<string>` :
|
|
46
46
|
|
|
47
47
|
```typescript
|
|
48
48
|
const selectedUser$ = this.userStore.selected$;
|
|
49
|
-
this.
|
|
49
|
+
this.luTitleStrategy.prependTitle(selectedUser$);
|
|
50
50
|
```
|
|
51
51
|
|
|
52
52
|
## Quickstart
|
|
@@ -55,8 +55,14 @@ You will need to:
|
|
|
55
55
|
|
|
56
56
|
- Install `@lucca-front/ng`
|
|
57
57
|
- Create a service (`YourAppNameTranslateService`) that implements the `ILuTitleTranslateService`
|
|
58
|
-
-
|
|
59
|
-
|
|
58
|
+
- Call `provideLuTitleStrategy` in your `app.module.ts` / `app.config.ts`
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
provideLuTitleStrategy({
|
|
62
|
+
appName: () => 'YourAppName',
|
|
63
|
+
translateService: () => inject(YourAppNameTranslateService),
|
|
64
|
+
}),
|
|
65
|
+
```
|
|
60
66
|
|
|
61
67
|
### Let's start by creating the service
|
|
62
68
|
|
|
@@ -69,10 +75,10 @@ You should end up with the following if you are using `ngx-translate`:
|
|
|
69
75
|
```typescript
|
|
70
76
|
@Injectable({ providedIn: 'root' })
|
|
71
77
|
export class CoreRhTranslateService implements ILuTitleTranslateService {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
78
|
+
constructor(private translateService: TranslateService) {}
|
|
79
|
+
translate(key: string, args: unknown): string {
|
|
80
|
+
return this.translateService.instant(key, args);
|
|
81
|
+
}
|
|
76
82
|
}
|
|
77
83
|
```
|
|
78
84
|
|
|
@@ -81,34 +87,22 @@ or if you are using `transloco`:
|
|
|
81
87
|
```typescript
|
|
82
88
|
@Injectable({ providedIn: 'root' })
|
|
83
89
|
export class CoreRhTranslateService implements ILuTitleTranslateService {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
90
|
+
constructor(private translateService: TranslocoService) {}
|
|
91
|
+
translate(key: string, args: HashMap): string {
|
|
92
|
+
return this.translateService.translate(key, args);
|
|
93
|
+
}
|
|
88
94
|
}
|
|
89
95
|
```
|
|
90
96
|
|
|
91
97
|
### Adapt `app.module.ts` config
|
|
92
98
|
|
|
93
|
-
|
|
99
|
+
In the `app.module.ts`, you need to call `provideLuTitleStrategy` in the `providers` array:
|
|
94
100
|
|
|
95
101
|
```typescript
|
|
96
102
|
@NgModule({
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
provide: LU_TITLE_TRANSLATE_SERVICE,
|
|
103
|
-
useExisting: YourAppNameTranslateService
|
|
104
|
-
}
|
|
105
|
-
]
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
### Init the `LuTitleService`
|
|
109
|
-
|
|
110
|
-
In the the `app.component.ts`, init the LuTitleService by passing the name of you app:
|
|
111
|
-
|
|
112
|
-
```typescript
|
|
113
|
-
this.luTitleService.init('**YourAppName**');
|
|
103
|
+
providers: [
|
|
104
|
+
provideLuTitleStrategy({ translateService: () => inject(YourAppNameTranslateService) }),
|
|
105
|
+
]
|
|
106
|
+
})
|
|
107
|
+
export class AppModule {}
|
|
114
108
|
```
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
2
3
|
export declare const LU_TITLE_TRANSLATE_SERVICE: InjectionToken<ILuTitleTranslateService>;
|
|
3
4
|
export interface ILuTitleTranslateService {
|
|
4
|
-
translate(key: string, args?: Record<string, unknown>): string
|
|
5
|
+
translate(key: string, args?: Record<string, unknown>): string | Observable<string>;
|
|
5
6
|
}
|
|
@@ -1,22 +1,30 @@
|
|
|
1
|
-
import { InjectionToken } from '@angular/core';
|
|
2
|
-
import { Title } from '@angular/platform-browser';
|
|
1
|
+
import { InjectionToken, Provider } from '@angular/core';
|
|
3
2
|
import { RouterStateSnapshot, TitleStrategy } from '@angular/router';
|
|
4
|
-
import { ObservableInput } from 'rxjs';
|
|
3
|
+
import { Observable, ObservableInput } from 'rxjs';
|
|
5
4
|
import { ILuTitleTranslateService } from './title-translate.service';
|
|
6
5
|
import * as i0 from "@angular/core";
|
|
7
|
-
export declare const APP_TITLE: InjectionToken<
|
|
6
|
+
export declare const ɵAPP_TITLE: InjectionToken<string | Observable<string>>;
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated Use `provideLuTitleStrategy` instead.
|
|
9
|
+
*/
|
|
10
|
+
export declare const APP_TITLE: InjectionToken<string | Observable<string>>;
|
|
8
11
|
export declare class LuTitleStrategy extends TitleStrategy {
|
|
9
12
|
#private;
|
|
10
13
|
private title;
|
|
11
14
|
private translateService;
|
|
12
15
|
private appTitle;
|
|
13
16
|
private titlePartsSubject;
|
|
14
|
-
titleParts$:
|
|
15
|
-
title$:
|
|
16
|
-
constructor(
|
|
17
|
+
titleParts$: Observable<(string | ObservableInput<string>)[]>;
|
|
18
|
+
title$: Observable<string>;
|
|
19
|
+
constructor();
|
|
17
20
|
updateTitle(routerState: RouterStateSnapshot): void;
|
|
18
21
|
prependTitle(title: string | ObservableInput<string>): void;
|
|
19
22
|
overrideFirstTitlePart(title: string | ObservableInput<string>): void;
|
|
20
23
|
static ɵfac: i0.ɵɵFactoryDeclaration<LuTitleStrategy, never>;
|
|
21
24
|
static ɵprov: i0.ɵɵInjectableDeclaration<LuTitleStrategy>;
|
|
22
25
|
}
|
|
26
|
+
export interface LuTitleStrategyOptions {
|
|
27
|
+
appTitle?: () => string | Observable<string>;
|
|
28
|
+
translateService?: () => ILuTitleTranslateService;
|
|
29
|
+
}
|
|
30
|
+
export declare function provideLuTitleStrategy(options: LuTitleStrategyOptions): Provider[];
|