@lukfel/ng-scaffold 22.0.6 → 22.1.2
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 +48 -1
- package/fesm2022/lukfel-ng-scaffold.mjs +180 -4
- package/fesm2022/lukfel-ng-scaffold.mjs.map +1 -1
- package/package.json +1 -1
- package/types/lukfel-ng-scaffold.d.ts +105 -3
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _angular_core from '@angular/core';
|
|
2
|
-
import { InjectionToken, EnvironmentProviders, ElementRef, TemplateRef, Type } from '@angular/core';
|
|
2
|
+
import { InjectionToken, EnvironmentProviders, ElementRef, TemplateRef, Type, Signal } from '@angular/core';
|
|
3
3
|
import { ComponentType, ComponentPortal, TemplatePortal } from '@angular/cdk/portal';
|
|
4
4
|
import { CdkDragDrop } from '@angular/cdk/drag-drop';
|
|
5
5
|
import { MatCheckboxChange } from '@angular/material/checkbox';
|
|
@@ -115,9 +115,36 @@ interface HeaderInputConfig {
|
|
|
115
115
|
autoFocus?: boolean;
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
+
interface TranslationConfig {
|
|
119
|
+
/**
|
|
120
|
+
* Available locales, e.g. `['de', 'en', 'fr']`. Drives the language picker and
|
|
121
|
+
* the browser-language detection on startup.
|
|
122
|
+
*/
|
|
123
|
+
locales: string[];
|
|
124
|
+
/**
|
|
125
|
+
* Locale used when the requested one is unknown or fails to load, and
|
|
126
|
+
* deep-merged under the active locale so keys missing from a partial locale
|
|
127
|
+
* resolve to its text instead of rendering blank, e.g. `'en'`.
|
|
128
|
+
*/
|
|
129
|
+
fallbackLocale: string;
|
|
130
|
+
/**
|
|
131
|
+
* Base path the `<locale>.json` files are served from.
|
|
132
|
+
*
|
|
133
|
+
* @default 'assets/i18n/'
|
|
134
|
+
*/
|
|
135
|
+
path?: string;
|
|
136
|
+
/**
|
|
137
|
+
* Persist the active locale in the LocalStorage and restore it on startup.
|
|
138
|
+
*
|
|
139
|
+
* @default true
|
|
140
|
+
*/
|
|
141
|
+
persist?: boolean;
|
|
142
|
+
}
|
|
143
|
+
|
|
118
144
|
interface ScaffoldLibraryConfig {
|
|
119
145
|
production?: boolean;
|
|
120
146
|
debugging?: boolean;
|
|
147
|
+
language?: TranslationConfig;
|
|
121
148
|
}
|
|
122
149
|
|
|
123
150
|
interface ListItem {
|
|
@@ -204,6 +231,17 @@ interface SeoConfig {
|
|
|
204
231
|
autoTrim?: boolean;
|
|
205
232
|
}
|
|
206
233
|
|
|
234
|
+
/**
|
|
235
|
+
* Recursive shape of a loaded translation JSON file.
|
|
236
|
+
*
|
|
237
|
+
* The library stays intentionally loose here: each consuming app owns its own
|
|
238
|
+
* strongly-typed `TransMap` interface and reads the service through
|
|
239
|
+
* `TranslationService.transMapAs<AppTransMap>()` to keep full type-safety.
|
|
240
|
+
*/
|
|
241
|
+
type TransMap = {
|
|
242
|
+
[key: string]: string | TransMap;
|
|
243
|
+
};
|
|
244
|
+
|
|
207
245
|
declare const CONFIG: InjectionToken<ScaffoldLibraryConfig>;
|
|
208
246
|
declare function provideScaffold(config?: ScaffoldLibraryConfig): EnvironmentProviders;
|
|
209
247
|
|
|
@@ -630,6 +668,70 @@ declare class ThemeService {
|
|
|
630
668
|
static ɵprov: _angular_core.ɵɵInjectableDeclaration<ThemeService>;
|
|
631
669
|
}
|
|
632
670
|
|
|
671
|
+
/**
|
|
672
|
+
* Runtime translation service that switches between per-locale JSON files.
|
|
673
|
+
*
|
|
674
|
+
* Configure it through `provideScaffold({ language: { ... } })`. Each app keeps
|
|
675
|
+
* its own strongly-typed `TransMap` interface and reads the labels via
|
|
676
|
+
* {@link TranslationService.transMapAs}.
|
|
677
|
+
*/
|
|
678
|
+
declare class TranslationService {
|
|
679
|
+
private readonly http;
|
|
680
|
+
private readonly document;
|
|
681
|
+
private readonly platformId;
|
|
682
|
+
private readonly storage;
|
|
683
|
+
private readonly logger;
|
|
684
|
+
private readonly config;
|
|
685
|
+
private readonly STORAGE_KEY;
|
|
686
|
+
/** In-memory cache of raw (un-merged) locale files, keyed by locale. */
|
|
687
|
+
private readonly cache;
|
|
688
|
+
/** Distinct empty seed so `transMap$` can suppress the pre-load emission. */
|
|
689
|
+
private readonly EMPTY;
|
|
690
|
+
private readonly _locale;
|
|
691
|
+
private readonly _transMap;
|
|
692
|
+
private readonly _loading;
|
|
693
|
+
/** The active locale, e.g. `'de'`. */
|
|
694
|
+
readonly locale: Signal<string>;
|
|
695
|
+
/** Labels for the active locale (with fallback keys merged in). */
|
|
696
|
+
readonly transMap: Signal<TransMap>;
|
|
697
|
+
/** `true` while a locale file is being fetched. */
|
|
698
|
+
readonly loading: Signal<boolean>;
|
|
699
|
+
/** All configured locales — drives a language picker. */
|
|
700
|
+
readonly locales: readonly string[];
|
|
701
|
+
/** Observable interop for `| async` templates and rxjs consumers. */
|
|
702
|
+
readonly locale$: Observable<string>;
|
|
703
|
+
readonly transMap$: Observable<TransMap>;
|
|
704
|
+
readonly loading$: Observable<boolean>;
|
|
705
|
+
constructor();
|
|
706
|
+
/**
|
|
707
|
+
* Typed signal accessor: reads the active labels as the app's own `TransMap`
|
|
708
|
+
* shape, preserving compile-time key checking. Emits `{}` until the first load.
|
|
709
|
+
*/
|
|
710
|
+
transMapAs<T>(): Signal<T>;
|
|
711
|
+
/**
|
|
712
|
+
* Typed observable accessor: like {@link transMapAs} but as a stream that only
|
|
713
|
+
* emits once translations are loaded (never the empty seed) — matching a
|
|
714
|
+
* `null`/`undefined`-until-loaded consumption pattern.
|
|
715
|
+
*/
|
|
716
|
+
transMapStream<T>(): Observable<T>;
|
|
717
|
+
/**
|
|
718
|
+
* Switch the active locale. Unknown locales fall back to `fallbackLocale`.
|
|
719
|
+
* Persistence is governed by the `persist` config option.
|
|
720
|
+
*
|
|
721
|
+
* @param locale target locale (must be one of the configured `locales`)
|
|
722
|
+
*/
|
|
723
|
+
setLocale(locale: string): Promise<void>;
|
|
724
|
+
private applyLocale;
|
|
725
|
+
private init;
|
|
726
|
+
private detectLocale;
|
|
727
|
+
private loadTranslations;
|
|
728
|
+
private fetchLocale;
|
|
729
|
+
private setHtmlLangAttribute;
|
|
730
|
+
private resolveConfig;
|
|
731
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<TranslationService, never>;
|
|
732
|
+
static ɵprov: _angular_core.ɵɵInjectableDeclaration<TranslationService>;
|
|
733
|
+
}
|
|
734
|
+
|
|
633
735
|
declare class ScaffoldLoadingInterceptor implements HttpInterceptor {
|
|
634
736
|
libraryConfig: ScaffoldLibraryConfig | null;
|
|
635
737
|
private scaffoldService;
|
|
@@ -642,5 +744,5 @@ declare class ScaffoldLoadingInterceptor implements HttpInterceptor {
|
|
|
642
744
|
static ɵprov: _angular_core.ɵɵInjectableDeclaration<ScaffoldLoadingInterceptor>;
|
|
643
745
|
}
|
|
644
746
|
|
|
645
|
-
export { BreakpointService, CONFIG, ColorPickerComponent, DialogService, FileUploadComponent, ListComponent, ListItemAvatarDirective, ListItemButtonsDirective, ListItemSubtitleDirective, ListItemTitleDirective, LocalStorageService, Logger, NotificationComponent, OverlayService, PlaceholderComponent, RouterService, ScaffoldComponent, ScaffoldLoadingInterceptor, ScaffoldService, SeoService, SnackbarService, ThemeService, provideScaffold };
|
|
646
|
-
export type { BottomBarConfig, Button, ConfirmDialogConfig, ContentTitleCardConfig, DrawerConfig, FloatingButtonConfig, FooterConfig, HeaderConfig, HeaderInputConfig, HeaderResponsiveConfig, ListConfig, ListHeader, ListItem, LoadingOverlayConfig, MenuButton, NavbarConfig, NavigationLink, PlaceholderConfig, ScaffoldConfig, ScaffoldLibraryConfig, SeoConfig };
|
|
747
|
+
export { BreakpointService, CONFIG, ColorPickerComponent, DialogService, FileUploadComponent, ListComponent, ListItemAvatarDirective, ListItemButtonsDirective, ListItemSubtitleDirective, ListItemTitleDirective, LocalStorageService, Logger, NotificationComponent, OverlayService, PlaceholderComponent, RouterService, ScaffoldComponent, ScaffoldLoadingInterceptor, ScaffoldService, SeoService, SnackbarService, ThemeService, TranslationService, provideScaffold };
|
|
748
|
+
export type { BottomBarConfig, Button, ConfirmDialogConfig, ContentTitleCardConfig, DrawerConfig, FloatingButtonConfig, FooterConfig, HeaderConfig, HeaderInputConfig, HeaderResponsiveConfig, ListConfig, ListHeader, ListItem, LoadingOverlayConfig, MenuButton, NavbarConfig, NavigationLink, PlaceholderConfig, ScaffoldConfig, ScaffoldLibraryConfig, SeoConfig, TransMap, TranslationConfig };
|