@sixbell-telco/sdk 1.0.3 → 1.2.0

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.
Files changed (103) hide show
  1. package/CHANGELOG.md +102 -0
  2. package/README.md +641 -163
  3. package/_index.css +85 -28
  4. package/components/avatar/src/avatar.component.d.ts +40 -26
  5. package/components/badge/src/badge.component.d.ts +0 -4
  6. package/components/button/src/button.component.d.ts +2 -2
  7. package/components/dialog/dialog-actions/dialog-actions.component.d.ts +8 -0
  8. package/components/dialog/dialog-content/dialog-content.component.d.ts +5 -0
  9. package/components/dialog/dialog-sub-title/dialog-sub-title.component.d.ts +5 -0
  10. package/components/dialog/dialog-title/dialog-title.component.d.ts +5 -0
  11. package/components/dialog/index.d.ts +5 -0
  12. package/components/dialog/public-api.d.ts +5 -0
  13. package/components/dialog/src/dialog.component.d.ts +132 -0
  14. package/components/dropdown/dropdown-chevron/dropdown-chevron.component.d.ts +39 -0
  15. package/components/dropdown/dropdown-content/dropdown-content.component.d.ts +41 -0
  16. package/components/dropdown/dropdown-group/dropdown-group.component.d.ts +9 -0
  17. package/components/dropdown/dropdown-item/dropdown-item.component.d.ts +23 -12
  18. package/components/dropdown/dropdown-item-checkbox/dropdown-item-checkbox.component.d.ts +49 -0
  19. package/components/dropdown/dropdown-item-radio/dropdown-item-radio.component.d.ts +53 -0
  20. package/components/dropdown/dropdown-label/dropdown-label.component.d.ts +17 -0
  21. package/components/dropdown/dropdown-separator/dropdown-separator.component.d.ts +21 -0
  22. package/components/dropdown/dropdown-trigger/dropdown-trigger.component.d.ts +121 -0
  23. package/components/dropdown/public-api.d.ts +9 -0
  24. package/components/dropdown/src/dropdown.component.d.ts +20 -174
  25. package/components/dropdown/src/services/dropdown.service.d.ts +22 -0
  26. package/components/dropdown-menu/bar/dropdown-menu-bar/dropdown-menu-bar.component.d.ts +22 -0
  27. package/components/dropdown-menu/bar/dropdown-menu-bar-content/dropdown-menu-bar-content.component.d.ts +64 -0
  28. package/components/dropdown-menu/bar/dropdown-menu-bar-item/dropdown-menu-bar-item.component.d.ts +37 -0
  29. package/components/dropdown-menu/bar/dropdown-menu-bar-item-checkbox/dropdown-menu-bar-item-checkbox.component.d.ts +54 -0
  30. package/components/dropdown-menu/bar/dropdown-menu-bar-item-radio/dropdown-menu-bar-item-radio.component.d.ts +58 -0
  31. package/components/dropdown-menu/bar/dropdown-menu-bar-label/dropdown-menu-bar-label.component.d.ts +16 -0
  32. package/components/dropdown-menu/bar/dropdown-menu-bar-separator/dropdown-menu-bar-separator.component.d.ts +16 -0
  33. package/components/dropdown-menu/bar/dropdown-menu-bar-sub-trigger/dropdown-menu-bar-sub-trigger.component.d.ts +29 -0
  34. package/components/dropdown-menu/bar/dropdown-menu-bar-trigger/dropdown-menu-bar-trigger.component.d.ts +50 -0
  35. package/components/dropdown-menu/bar/index.d.ts +5 -0
  36. package/components/dropdown-menu/bar/public-api.d.ts +9 -0
  37. package/components/dropdown-menu/context/dropdown-context-menu-trigger/dropdown-context-menu-trigger.component.d.ts +23 -0
  38. package/components/dropdown-menu/context/index.d.ts +5 -0
  39. package/components/dropdown-menu/context/public-api.d.ts +1 -0
  40. package/components/dropdown-menu/dropdown-menu-chevron/dropdown-menu-chevron.component.d.ts +43 -0
  41. package/components/dropdown-menu/index.d.ts +5 -0
  42. package/components/dropdown-menu/public-api.d.ts +13 -0
  43. package/components/dropdown-menu/src/directives/dropdown-menu.directive.d.ts +40 -0
  44. package/components/dropdown-menu/src/dropdown-menu/dropdown-menu.component.d.ts +9 -0
  45. package/components/dropdown-menu/src/dropdown-menu-content/dropdown-menu-content.component.d.ts +40 -0
  46. package/components/dropdown-menu/src/dropdown-menu-group/dropdown-menu-group.component.d.ts +8 -0
  47. package/components/dropdown-menu/src/dropdown-menu-item/dropdown-menu-item.component.d.ts +38 -0
  48. package/components/dropdown-menu/src/dropdown-menu-label/dropdown-menu-label.component.d.ts +16 -0
  49. package/components/dropdown-menu/src/dropdown-menu-separator/dropdown-menu-separator.component.d.ts +16 -0
  50. package/components/dropdown-menu/src/dropdown-menu-sub/dropdown-menu-sub.component.d.ts +8 -0
  51. package/components/dropdown-menu/src/dropdown-menu-sub-content/dropdown-menu-sub-content.component.d.ts +31 -0
  52. package/components/dropdown-menu/src/dropdown-menu-sub-trigger/dropdown-menu-sub-trigger.component.d.ts +18 -0
  53. package/components/dropdown-menu/src/dropdown-menu-trigger/dropdown-menu-trigger.component.d.ts +19 -0
  54. package/components/dropdown-menu/src/services/dropdown-menu.service.d.ts +22 -0
  55. package/directives/auto-focus/src/autofocus.directive.d.ts +3 -3
  56. package/fesm2022/sixbell-telco-sdk-components-avatar.mjs +75 -39
  57. package/fesm2022/sixbell-telco-sdk-components-avatar.mjs.map +1 -1
  58. package/fesm2022/sixbell-telco-sdk-components-badge.mjs +1 -1
  59. package/fesm2022/sixbell-telco-sdk-components-badge.mjs.map +1 -1
  60. package/fesm2022/sixbell-telco-sdk-components-button.mjs +1 -0
  61. package/fesm2022/sixbell-telco-sdk-components-button.mjs.map +1 -1
  62. package/fesm2022/sixbell-telco-sdk-components-dialog.mjs +305 -0
  63. package/fesm2022/sixbell-telco-sdk-components-dialog.mjs.map +1 -0
  64. package/fesm2022/sixbell-telco-sdk-components-dropdown-menu-bar.mjs +529 -0
  65. package/fesm2022/sixbell-telco-sdk-components-dropdown-menu-bar.mjs.map +1 -0
  66. package/fesm2022/sixbell-telco-sdk-components-dropdown-menu-context.mjs +52 -0
  67. package/fesm2022/sixbell-telco-sdk-components-dropdown-menu-context.mjs.map +1 -0
  68. package/fesm2022/sixbell-telco-sdk-components-dropdown-menu.mjs +539 -0
  69. package/fesm2022/sixbell-telco-sdk-components-dropdown-menu.mjs.map +1 -0
  70. package/fesm2022/sixbell-telco-sdk-components-dropdown.mjs +592 -213
  71. package/fesm2022/sixbell-telco-sdk-components-dropdown.mjs.map +1 -1
  72. package/fesm2022/sixbell-telco-sdk-components-forms-combobox.mjs +5 -2
  73. package/fesm2022/sixbell-telco-sdk-components-forms-combobox.mjs.map +1 -1
  74. package/fesm2022/sixbell-telco-sdk-components-forms-select.mjs +2 -2
  75. package/fesm2022/sixbell-telco-sdk-components-forms-select.mjs.map +1 -1
  76. package/fesm2022/sixbell-telco-sdk-components-product-card.mjs +1 -1
  77. package/fesm2022/sixbell-telco-sdk-components-product-card.mjs.map +1 -1
  78. package/fesm2022/sixbell-telco-sdk-components-toast.mjs +2 -2
  79. package/fesm2022/sixbell-telco-sdk-components-toast.mjs.map +1 -1
  80. package/fesm2022/sixbell-telco-sdk-directives-auto-focus.mjs +3 -3
  81. package/fesm2022/sixbell-telco-sdk-directives-auto-focus.mjs.map +1 -1
  82. package/fesm2022/sixbell-telco-sdk-utils-theme.mjs +295 -0
  83. package/fesm2022/sixbell-telco-sdk-utils-theme.mjs.map +1 -0
  84. package/fesm2022/sixbell-telco-sdk-utils-translation.mjs +332 -0
  85. package/fesm2022/sixbell-telco-sdk-utils-translation.mjs.map +1 -0
  86. package/package.json +29 -9
  87. package/sixbell-telco-sdk-1.2.0.tgz +0 -0
  88. package/utils/theme/README.md +185 -0
  89. package/{components/modal → utils/theme}/index.d.ts +1 -1
  90. package/utils/theme/public-api.d.ts +1 -0
  91. package/utils/theme/src/theme.service.d.ts +206 -0
  92. package/utils/translation/README.md +274 -0
  93. package/utils/translation/index.d.ts +5 -0
  94. package/utils/translation/public-api.d.ts +5 -0
  95. package/utils/translation/src/translation.service.d.ts +197 -0
  96. package/components/modal/modal-actions/modal-actions.component.d.ts +0 -8
  97. package/components/modal/modal-content/modal-content.component.d.ts +0 -5
  98. package/components/modal/modal-title/modal-title.component.d.ts +0 -5
  99. package/components/modal/public-api.d.ts +0 -4
  100. package/components/modal/src/modal.component.d.ts +0 -102
  101. package/fesm2022/sixbell-telco-sdk-components-modal.mjs +0 -202
  102. package/fesm2022/sixbell-telco-sdk-components-modal.mjs.map +0 -1
  103. package/sixbell-telco-sdk-1.0.3.tgz +0 -0
@@ -0,0 +1,295 @@
1
+ import { DOCUMENT } from '@angular/common';
2
+ import * as i0 from '@angular/core';
3
+ import { InjectionToken, inject, signal, computed, Inject, Optional, Injectable, provideAppInitializer } from '@angular/core';
4
+ import { TranslationService } from '@sixbell-telco/sdk/utils/translation';
5
+
6
+ // Default base theme - always available unless excluded
7
+ const DEFAULT_BASE_THEME = 'sixbell_telco';
8
+ const DEFAULT_THEMES = [DEFAULT_BASE_THEME];
9
+ const DEFAULT_THEME_CODES = [DEFAULT_BASE_THEME];
10
+ // Injection tokens for dependency injection
11
+ const THEME_CONFIG_TOKEN = new InjectionToken('Theme Configuration');
12
+ // LocalStorage keys
13
+ const THEME_SELECTED_THEME_KEY = 'selectedTheme';
14
+ const THEME_SELECTED_SCHEME_KEY = 'selectedScheme';
15
+ class ThemeService {
16
+ rendererFactory;
17
+ document;
18
+ themeConfig;
19
+ translationService = inject(TranslationService);
20
+ renderer;
21
+ initialized = false;
22
+ // Default configuration - can be overridden by provider
23
+ config = {
24
+ availableThemes: [DEFAULT_BASE_THEME],
25
+ defaultTheme: DEFAULT_BASE_THEME,
26
+ defaultScheme: 'system',
27
+ };
28
+ // Reactive signals
29
+ selectedTheme = signal(this.config.defaultTheme);
30
+ selectedScheme = signal(this.config.defaultScheme);
31
+ /**
32
+ * Get the actual resolved scheme ('light' or 'dark') regardless of user selection.
33
+ * This is useful for conditional rendering where you need to know the actual
34
+ * light/dark state, even when the user has selected 'system' preference.
35
+ */
36
+ resolvedScheme = computed(() => {
37
+ const scheme = this.selectedScheme();
38
+ if (scheme === 'system') {
39
+ // Resolve system preference to actual light/dark
40
+ const prefersDark = typeof window !== 'undefined' && window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
41
+ return prefersDark ? 'dark' : 'light';
42
+ }
43
+ return scheme; // Return 'light' or 'dark' directly
44
+ });
45
+ /**
46
+ * Convenient computed signal that returns true when the current resolved scheme is 'dark'.
47
+ */
48
+ isDarkTheme = computed(() => this.resolvedScheme() === 'dark');
49
+ // Computed final theme
50
+ finalTheme = computed(() => {
51
+ const theme = this.selectedTheme();
52
+ const resolvedScheme = this.resolvedScheme();
53
+ return `${theme}__${resolvedScheme}`;
54
+ });
55
+ constructor(rendererFactory, document, themeConfig) {
56
+ this.rendererFactory = rendererFactory;
57
+ this.document = document;
58
+ this.themeConfig = themeConfig;
59
+ this.renderer = this.rendererFactory.createRenderer(null, null);
60
+ // Configure with provided config or defaults
61
+ if (themeConfig) {
62
+ this.configure(themeConfig);
63
+ }
64
+ else {
65
+ // Initialize with defaults immediately
66
+ this.initializeFromStorage();
67
+ this.applyTheme();
68
+ this.initialized = true;
69
+ }
70
+ }
71
+ /**
72
+ * Configure and initialize the theme service (used by provider)
73
+ */
74
+ configure(config = {}) {
75
+ // Start with default base theme (sixbell_telco)
76
+ let availableThemes = [DEFAULT_BASE_THEME];
77
+ // Handle additional themes
78
+ if (config.additionalThemes) {
79
+ availableThemes = [DEFAULT_BASE_THEME, ...config.additionalThemes];
80
+ }
81
+ // Apply theme exclusions if specified
82
+ if (config.excludeThemes) {
83
+ const excludeThemeNames = config.excludeThemes;
84
+ availableThemes = availableThemes.filter((theme) => !excludeThemeNames.includes(theme));
85
+ }
86
+ // Remove duplicates
87
+ availableThemes = [...new Set(availableThemes)];
88
+ // Determine default theme
89
+ const defaultTheme = config.defaultTheme || (availableThemes.includes(DEFAULT_BASE_THEME) ? DEFAULT_BASE_THEME : availableThemes[0]);
90
+ // Update configuration
91
+ this.config = {
92
+ availableThemes,
93
+ defaultTheme,
94
+ defaultScheme: config.defaultScheme || this.config.defaultScheme,
95
+ };
96
+ // Validate defaultTheme is in available themes
97
+ if (!this.config.availableThemes.includes(this.config.defaultTheme)) {
98
+ console.warn(`ThemeService: defaultTheme '${this.config.defaultTheme}' not in availableThemes, using '${this.config.availableThemes[0] || DEFAULT_BASE_THEME}'`);
99
+ this.config.defaultTheme = this.config.availableThemes[0] || DEFAULT_BASE_THEME;
100
+ }
101
+ // Update signal defaults
102
+ this.selectedTheme.set(this.config.defaultTheme);
103
+ this.selectedScheme.set(this.config.defaultScheme);
104
+ // Initialize from storage (will override defaults if values exist)
105
+ this.initializeFromStorage();
106
+ this.applyTheme();
107
+ this.initialized = true;
108
+ }
109
+ /**
110
+ * Initialize theme from localStorage and apply it immediately
111
+ */
112
+ initializeFromStorage() {
113
+ // Safety checks for browser environment
114
+ if (typeof window === 'undefined' || typeof localStorage === 'undefined') {
115
+ console.warn('ThemeService: Browser environment not available, using defaults');
116
+ return;
117
+ }
118
+ try {
119
+ // Get saved theme or use default
120
+ const savedTheme = localStorage.getItem(THEME_SELECTED_THEME_KEY);
121
+ const currentTheme = savedTheme && this.config.availableThemes.includes(savedTheme) ? savedTheme : this.config.defaultTheme;
122
+ // Get saved scheme or use default
123
+ const savedScheme = localStorage.getItem(THEME_SELECTED_SCHEME_KEY);
124
+ const currentScheme = savedScheme && ['system', 'light', 'dark'].includes(savedScheme) ? savedScheme : this.config.defaultScheme;
125
+ // Update signals
126
+ this.selectedTheme.set(currentTheme);
127
+ this.selectedScheme.set(currentScheme);
128
+ }
129
+ catch (error) {
130
+ console.error('ThemeService: Failed to initialize from storage:', error);
131
+ }
132
+ }
133
+ /**
134
+ * Apply the current theme to the document
135
+ */
136
+ applyTheme() {
137
+ const finalTheme = this.finalTheme();
138
+ // Set the theme attribute on the body
139
+ this.renderer.setAttribute(this.document.body, 'data-theme', finalTheme);
140
+ // Persist to localStorage
141
+ if (typeof localStorage !== 'undefined') {
142
+ localStorage.setItem(THEME_SELECTED_THEME_KEY, this.selectedTheme());
143
+ localStorage.setItem(THEME_SELECTED_SCHEME_KEY, this.selectedScheme());
144
+ }
145
+ }
146
+ /**
147
+ * Set the current theme
148
+ */
149
+ setTheme(theme) {
150
+ if (theme && this.config.availableThemes.includes(theme)) {
151
+ this.selectedTheme.set(theme);
152
+ this.applyTheme();
153
+ }
154
+ else {
155
+ console.warn(`ThemeService: Theme '${theme}' not available, using default '${this.config.defaultTheme}'`);
156
+ }
157
+ }
158
+ /**
159
+ * Set the current color scheme
160
+ */
161
+ setScheme(scheme) {
162
+ if (scheme && ['system', 'light', 'dark'].includes(scheme)) {
163
+ this.selectedScheme.set(scheme);
164
+ this.applyTheme();
165
+ }
166
+ else {
167
+ console.warn(`ThemeService: Scheme '${scheme}' not valid, using default '${this.config.defaultScheme}'`);
168
+ }
169
+ }
170
+ /**
171
+ * Get available themes
172
+ */
173
+ getAvailableThemes() {
174
+ return this.config.availableThemes;
175
+ }
176
+ /**
177
+ * Get available schemes
178
+ */
179
+ getAvailableSchemes() {
180
+ return ['system', 'light', 'dark'];
181
+ }
182
+ /**
183
+ * Get default theme
184
+ */
185
+ getDefaultTheme() {
186
+ return this.config.defaultTheme;
187
+ }
188
+ /**
189
+ * Get default scheme
190
+ */
191
+ getDefaultScheme() {
192
+ return this.config.defaultScheme;
193
+ }
194
+ /**
195
+ * Get localized scheme name by code using translations
196
+ * This automatically returns the localized name based on the current language
197
+ */
198
+ getLocalizedSchemeName(scheme) {
199
+ const translationKey = `sdk.theme.schemes.${scheme}`;
200
+ const translatedName = this.translationService.instant(translationKey);
201
+ if (translatedName && translatedName !== translationKey) {
202
+ return translatedName;
203
+ }
204
+ return scheme.charAt(0).toUpperCase() + scheme.slice(1);
205
+ }
206
+ /**
207
+ * Get localized theme name by code using translations
208
+ * This automatically returns the localized name based on the current language
209
+ */
210
+ getLocalizedThemeName(theme) {
211
+ const translationKey = `sdk.theme.themes.${theme}`;
212
+ const translatedName = this.translationService.instant(translationKey);
213
+ if (translatedName && translatedName !== translationKey) {
214
+ return translatedName;
215
+ }
216
+ return theme.replace(/_/g, ' ').replace(/\b\w/g, (l) => l.toUpperCase());
217
+ }
218
+ /**
219
+ * Force initialization method for MFE environments
220
+ */
221
+ init() {
222
+ // This method just ensures the service is instantiated and initialized
223
+ this.getAvailableThemes(); // Trigger any lazy initialization
224
+ }
225
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: ThemeService, deps: [{ token: i0.RendererFactory2 }, { token: DOCUMENT }, { token: THEME_CONFIG_TOKEN, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
226
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: ThemeService, providedIn: 'root' });
227
+ }
228
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: ThemeService, decorators: [{
229
+ type: Injectable,
230
+ args: [{
231
+ providedIn: 'root',
232
+ }]
233
+ }], ctorParameters: () => [{ type: i0.RendererFactory2 }, { type: Document, decorators: [{
234
+ type: Inject,
235
+ args: [DOCUMENT]
236
+ }] }, { type: undefined, decorators: [{
237
+ type: Inject,
238
+ args: [THEME_CONFIG_TOKEN]
239
+ }, {
240
+ type: Optional
241
+ }] }] });
242
+ /**
243
+ * Provider function for theme configuration in Angular applications
244
+ * This provides the theme configuration through dependency injection
245
+ *
246
+ * @param config Optional theme configuration
247
+ * @returns Provider array that configures theme service
248
+ *
249
+ * @example
250
+ * ```typescript
251
+ * // app.config.ts
252
+ * import { provideTheme } from '@sixbell-telco/sdk/utils/theme';
253
+ *
254
+ * export const appConfig: ApplicationConfig = {
255
+ * providers: [
256
+ * provideRouter(routes),
257
+ *
258
+ * // Basic usage - sixbell_telco always available
259
+ * provideTheme({
260
+ * defaultScheme: 'light',
261
+ * defaultTheme: 'sixbell_telco' // IntelliSense: 'sixbell_telco'
262
+ * }),
263
+ *
264
+ * // With additional themes
265
+ * provideTheme({
266
+ * additionalThemes: ['wom', 'custom'] as const,
267
+ * defaultTheme: 'custom', // IntelliSense: 'sixbell_telco' | string
268
+ * excludeThemes: ['wom'] as const, // IntelliSense: 'sixbell_telco' | string
269
+ * defaultScheme: 'system'
270
+ * }),
271
+ *
272
+ * // ... other providers
273
+ * ],
274
+ * };
275
+ * ```
276
+ */
277
+ // Single overload that provides IntelliSense for all cases
278
+ function provideTheme(config) {
279
+ return [
280
+ {
281
+ provide: THEME_CONFIG_TOKEN,
282
+ // Pass through original object so literal tuple types survive for IDE IntelliSense
283
+ useValue: (config || {}),
284
+ },
285
+ // Automatically initialize theme service for MFE compatibility
286
+ provideAppInitializer(() => inject(ThemeService).init()),
287
+ ];
288
+ }
289
+
290
+ /**
291
+ * Generated bundle index. Do not edit.
292
+ */
293
+
294
+ export { DEFAULT_BASE_THEME, DEFAULT_THEMES, DEFAULT_THEME_CODES, THEME_CONFIG_TOKEN, ThemeService, provideTheme };
295
+ //# sourceMappingURL=sixbell-telco-sdk-utils-theme.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sixbell-telco-sdk-utils-theme.mjs","sources":["../../../projects/sdk/utils/theme/src/theme.service.ts","../../../projects/sdk/utils/theme/sixbell-telco-sdk-utils-theme.ts"],"sourcesContent":["import { DOCUMENT } from '@angular/common';\nimport {\n\tcomputed,\n\tEnvironmentProviders,\n\tInject,\n\tinject,\n\tInjectable,\n\tInjectionToken,\n\tOptional,\n\tprovideAppInitializer,\n\tProvider,\n\tRenderer2,\n\tRendererFactory2,\n\tsignal,\n} from '@angular/core';\nimport { TranslationService } from '@sixbell-telco/sdk/utils/translation';\n\nexport type ThemeScheme = 'system' | 'light' | 'dark';\nexport type ResolvedThemeScheme = 'light' | 'dark';\n\n// Default base theme - always available unless excluded\nexport const DEFAULT_BASE_THEME = 'sixbell_telco';\nexport const DEFAULT_THEMES = [DEFAULT_BASE_THEME] as const;\nexport const DEFAULT_THEME_CODES = [DEFAULT_BASE_THEME] as const;\nexport type DefaultThemeCode = (typeof DEFAULT_THEME_CODES)[number];\n\n// Helper type to extract theme codes from additional themes arrays\ntype ExtractThemeCode<T> = T extends readonly (infer U)[] ? U : never;\n\n/**\n * Base theme configuration interface without additional themes\n * Provides IntelliSense for the default base theme (sixbell_telco)\n */\nexport interface ThemeConfigWithoutAdditionalThemes {\n\t/**\n\t * Default theme code (base theme: sixbell_telco)\n\t * @example 'sixbell_telco'\n\t */\n\tdefaultTheme?: DefaultThemeCode;\n\t/**\n\t * Themes to exclude from the available set (base theme: sixbell_telco)\n\t * @example ['sixbell_telco'] to exclude the default theme\n\t */\n\texcludeThemes?: readonly DefaultThemeCode[];\n\t/**\n\t * Default color scheme preference\n\t * @example 'system' | 'light' | 'dark'\n\t */\n\tdefaultScheme?: ThemeScheme;\n}\n\n/**\n * Theme configuration interface with additional themes providing IntelliSense\n */\nexport interface ThemeConfigWithAdditionalThemes<T extends readonly string[]> {\n\t/**\n\t * Additional themes to make available beyond the default base theme (sixbell_telco)\n\t * When you add themes here, they become available in defaultTheme and excludeThemes\n\t * @example ['custom', 'dark_mode', 'high_contrast']\n\t */\n\tadditionalThemes: T;\n\t/**\n\t * Default theme code\n\t * IntelliSense includes: base theme (sixbell_telco) + any additionalThemes you specified above\n\t * @example 'sixbell_telco'\n\t */\n\tdefaultTheme?: DefaultThemeCode | ExtractThemeCode<T>;\n\t/**\n\t * Themes to exclude from the available set\n\t * IntelliSense includes: base theme (sixbell_telco) + any additionalThemes you specified above\n\t * @example ['sixbell_telco'] to exclude the default theme\n\t */\n\texcludeThemes?: readonly (DefaultThemeCode | ExtractThemeCode<T>)[];\n\t/**\n\t * Default color scheme preference\n\t * @example 'system' | 'light' | 'dark'\n\t */\n\tdefaultScheme?: ThemeScheme;\n}\n\n/**\n * Main theme configuration interface (generic version)\n * Always provides IntelliSense for at least the base theme (sixbell_telco)\n */\nexport interface ThemeConfig {\n\t/**\n\t * Additional themes to make available beyond the default base theme (sixbell_telco)\n\t * When you add themes here, they become available in defaultTheme and excludeThemes\n\t * @example ['custom', 'dark_mode', 'high_contrast']\n\t */\n\tadditionalThemes?: readonly string[];\n\t/**\n\t * Default theme code\n\t * Always includes base theme (sixbell_telco), plus any additionalThemes you specify\n\t * @example 'sixbell_telco'\n\t */\n\tdefaultTheme?: string;\n\t/**\n\t * Themes to exclude from the available set\n\t * Always includes base theme (sixbell_telco), plus any additionalThemes you specify\n\t * @example ['sixbell_telco'] to exclude the default theme\n\t */\n\texcludeThemes?: readonly string[];\n\t/**\n\t * Default color scheme preference\n\t * @example 'system' | 'light' | 'dark'\n\t */\n\tdefaultScheme?: ThemeScheme;\n}\n\n// Injection tokens for dependency injection\nexport const THEME_CONFIG_TOKEN = new InjectionToken<ThemeConfig>('Theme Configuration');\n\n// LocalStorage keys\nconst THEME_SELECTED_THEME_KEY = 'selectedTheme';\nconst THEME_SELECTED_SCHEME_KEY = 'selectedScheme';\n\n@Injectable({\n\tprovidedIn: 'root',\n})\nexport class ThemeService {\n\tpublic readonly translationService = inject(TranslationService);\n\tprivate readonly renderer: Renderer2;\n\tprivate initialized = false;\n\n\t// Default configuration - can be overridden by provider\n\tprivate config: {\n\t\tavailableThemes: string[];\n\t\tdefaultTheme: string;\n\t\tdefaultScheme: ThemeScheme;\n\t} = {\n\t\tavailableThemes: [DEFAULT_BASE_THEME],\n\t\tdefaultTheme: DEFAULT_BASE_THEME,\n\t\tdefaultScheme: 'system',\n\t};\n\n\t// Reactive signals\n\tpublic selectedTheme = signal<string>(this.config.defaultTheme);\n\tpublic selectedScheme = signal<ThemeScheme>(this.config.defaultScheme);\n\n\t/**\n\t * Get the actual resolved scheme ('light' or 'dark') regardless of user selection.\n\t * This is useful for conditional rendering where you need to know the actual\n\t * light/dark state, even when the user has selected 'system' preference.\n\t */\n\tpublic resolvedScheme = computed(() => {\n\t\tconst scheme = this.selectedScheme();\n\n\t\tif (scheme === 'system') {\n\t\t\t// Resolve system preference to actual light/dark\n\t\t\tconst prefersDark = typeof window !== 'undefined' && window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;\n\t\t\treturn prefersDark ? 'dark' : 'light';\n\t\t}\n\n\t\treturn scheme; // Return 'light' or 'dark' directly\n\t});\n\n\t/**\n\t * Convenient computed signal that returns true when the current resolved scheme is 'dark'.\n\t */\n\tpublic isDarkTheme = computed(() => this.resolvedScheme() === 'dark');\n\n\t// Computed final theme\n\tpublic finalTheme = computed(() => {\n\t\tconst theme = this.selectedTheme();\n\t\tconst resolvedScheme = this.resolvedScheme();\n\t\treturn `${theme}__${resolvedScheme}`;\n\t});\n\n\tconstructor(\n\t\tprivate readonly rendererFactory: RendererFactory2,\n\t\t@Inject(DOCUMENT) private readonly document: Document,\n\t\t@Inject(THEME_CONFIG_TOKEN) @Optional() private readonly themeConfig?: ThemeConfig,\n\t) {\n\t\tthis.renderer = this.rendererFactory.createRenderer(null, null);\n\n\t\t// Configure with provided config or defaults\n\t\tif (themeConfig) {\n\t\t\tthis.configure(themeConfig);\n\t\t} else {\n\t\t\t// Initialize with defaults immediately\n\t\t\tthis.initializeFromStorage();\n\t\t\tthis.applyTheme();\n\t\t\tthis.initialized = true;\n\t\t}\n\t}\n\n\t/**\n\t * Configure and initialize the theme service (used by provider)\n\t */\n\tpublic configure(config: ThemeConfig = {}): void {\n\t\t// Start with default base theme (sixbell_telco)\n\t\tlet availableThemes = [DEFAULT_BASE_THEME];\n\n\t\t// Handle additional themes\n\t\tif (config.additionalThemes) {\n\t\t\tavailableThemes = [DEFAULT_BASE_THEME, ...config.additionalThemes];\n\t\t}\n\n\t\t// Apply theme exclusions if specified\n\t\tif (config.excludeThemes) {\n\t\t\tconst excludeThemeNames = config.excludeThemes;\n\t\t\tavailableThemes = availableThemes.filter((theme) => !excludeThemeNames.includes(theme));\n\t\t}\n\n\t\t// Remove duplicates\n\t\tavailableThemes = [...new Set(availableThemes)];\n\n\t\t// Determine default theme\n\t\tconst defaultTheme = config.defaultTheme || (availableThemes.includes(DEFAULT_BASE_THEME) ? DEFAULT_BASE_THEME : availableThemes[0]);\n\n\t\t// Update configuration\n\t\tthis.config = {\n\t\t\tavailableThemes,\n\t\t\tdefaultTheme,\n\t\t\tdefaultScheme: config.defaultScheme || this.config.defaultScheme,\n\t\t};\n\n\t\t// Validate defaultTheme is in available themes\n\t\tif (!this.config.availableThemes.includes(this.config.defaultTheme)) {\n\t\t\tconsole.warn(\n\t\t\t\t`ThemeService: defaultTheme '${this.config.defaultTheme}' not in availableThemes, using '${this.config.availableThemes[0] || DEFAULT_BASE_THEME}'`,\n\t\t\t);\n\t\t\tthis.config.defaultTheme = this.config.availableThemes[0] || DEFAULT_BASE_THEME;\n\t\t}\n\n\t\t// Update signal defaults\n\t\tthis.selectedTheme.set(this.config.defaultTheme);\n\t\tthis.selectedScheme.set(this.config.defaultScheme);\n\n\t\t// Initialize from storage (will override defaults if values exist)\n\t\tthis.initializeFromStorage();\n\t\tthis.applyTheme();\n\t\tthis.initialized = true;\n\t}\n\n\t/**\n\t * Initialize theme from localStorage and apply it immediately\n\t */\n\tprivate initializeFromStorage(): void {\n\t\t// Safety checks for browser environment\n\t\tif (typeof window === 'undefined' || typeof localStorage === 'undefined') {\n\t\t\tconsole.warn('ThemeService: Browser environment not available, using defaults');\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\t// Get saved theme or use default\n\t\t\tconst savedTheme = localStorage.getItem(THEME_SELECTED_THEME_KEY);\n\t\t\tconst currentTheme = savedTheme && this.config.availableThemes.includes(savedTheme) ? savedTheme : this.config.defaultTheme;\n\n\t\t\t// Get saved scheme or use default\n\t\t\tconst savedScheme = localStorage.getItem(THEME_SELECTED_SCHEME_KEY) as ThemeScheme;\n\t\t\tconst currentScheme = savedScheme && ['system', 'light', 'dark'].includes(savedScheme) ? savedScheme : this.config.defaultScheme;\n\n\t\t\t// Update signals\n\t\t\tthis.selectedTheme.set(currentTheme);\n\t\t\tthis.selectedScheme.set(currentScheme);\n\t\t} catch (error) {\n\t\t\tconsole.error('ThemeService: Failed to initialize from storage:', error);\n\t\t}\n\t}\n\n\t/**\n\t * Apply the current theme to the document\n\t */\n\tprivate applyTheme(): void {\n\t\tconst finalTheme = this.finalTheme();\n\n\t\t// Set the theme attribute on the body\n\t\tthis.renderer.setAttribute(this.document.body, 'data-theme', finalTheme);\n\n\t\t// Persist to localStorage\n\t\tif (typeof localStorage !== 'undefined') {\n\t\t\tlocalStorage.setItem(THEME_SELECTED_THEME_KEY, this.selectedTheme());\n\t\t\tlocalStorage.setItem(THEME_SELECTED_SCHEME_KEY, this.selectedScheme());\n\t\t}\n\t}\n\n\t/**\n\t * Set the current theme\n\t */\n\tsetTheme(theme: string): void {\n\t\tif (theme && this.config.availableThemes.includes(theme)) {\n\t\t\tthis.selectedTheme.set(theme);\n\t\t\tthis.applyTheme();\n\t\t} else {\n\t\t\tconsole.warn(`ThemeService: Theme '${theme}' not available, using default '${this.config.defaultTheme}'`);\n\t\t}\n\t}\n\n\t/**\n\t * Set the current color scheme\n\t */\n\tsetScheme(scheme: ThemeScheme): void {\n\t\tif (scheme && ['system', 'light', 'dark'].includes(scheme)) {\n\t\t\tthis.selectedScheme.set(scheme);\n\t\t\tthis.applyTheme();\n\t\t} else {\n\t\t\tconsole.warn(`ThemeService: Scheme '${scheme}' not valid, using default '${this.config.defaultScheme}'`);\n\t\t}\n\t}\n\n\t/**\n\t * Get available themes\n\t */\n\tgetAvailableThemes(): string[] {\n\t\treturn this.config.availableThemes;\n\t}\n\n\t/**\n\t * Get available schemes\n\t */\n\tgetAvailableSchemes(): ThemeScheme[] {\n\t\treturn ['system', 'light', 'dark'];\n\t}\n\n\t/**\n\t * Get default theme\n\t */\n\tgetDefaultTheme(): string {\n\t\treturn this.config.defaultTheme;\n\t}\n\n\t/**\n\t * Get default scheme\n\t */\n\tgetDefaultScheme(): ThemeScheme {\n\t\treturn this.config.defaultScheme;\n\t}\n\n\t/**\n\t * Get localized scheme name by code using translations\n\t * This automatically returns the localized name based on the current language\n\t */\n\tgetLocalizedSchemeName(scheme: string): string {\n\t\tconst translationKey = `sdk.theme.schemes.${scheme}`;\n\t\tconst translatedName = this.translationService.instant(translationKey);\n\n\t\tif (translatedName && translatedName !== translationKey) {\n\t\t\treturn translatedName;\n\t\t}\n\n\t\treturn scheme.charAt(0).toUpperCase() + scheme.slice(1);\n\t}\n\n\t/**\n\t * Get localized theme name by code using translations\n\t * This automatically returns the localized name based on the current language\n\t */\n\tgetLocalizedThemeName(theme: string): string {\n\t\tconst translationKey = `sdk.theme.themes.${theme}`;\n\t\tconst translatedName = this.translationService.instant(translationKey);\n\n\t\tif (translatedName && translatedName !== translationKey) {\n\t\t\treturn translatedName;\n\t\t}\n\n\t\treturn theme.replace(/_/g, ' ').replace(/\\b\\w/g, (l) => l.toUpperCase());\n\t}\n\n\t/**\n\t * Force initialization method for MFE environments\n\t */\n\tpublic init(): void {\n\t\t// This method just ensures the service is instantiated and initialized\n\t\tthis.getAvailableThemes(); // Trigger any lazy initialization\n\t}\n}\n\n// --- IntelliSense Friendly Config Types ---\n// We keep the original specialized interfaces and add a helper union that preserves literal types.\ntype ThemeConfigInput<T extends readonly string[] = readonly string[]> = ThemeConfigWithoutAdditionalThemes | ThemeConfigWithAdditionalThemes<T>;\n\n/**\n * Provider function for theme configuration in Angular applications\n * This provides the theme configuration through dependency injection\n *\n * @param config Optional theme configuration\n * @returns Provider array that configures theme service\n *\n * @example\n * ```typescript\n * // app.config.ts\n * import { provideTheme } from '@sixbell-telco/sdk/utils/theme';\n *\n * export const appConfig: ApplicationConfig = {\n * providers: [\n * provideRouter(routes),\n *\n * // Basic usage - sixbell_telco always available\n * provideTheme({\n * defaultScheme: 'light',\n * defaultTheme: 'sixbell_telco' // IntelliSense: 'sixbell_telco'\n * }),\n *\n * // With additional themes\n * provideTheme({\n * additionalThemes: ['wom', 'custom'] as const,\n * defaultTheme: 'custom', // IntelliSense: 'sixbell_telco' | string\n * excludeThemes: ['wom'] as const, // IntelliSense: 'sixbell_telco' | string\n * defaultScheme: 'system'\n * }),\n *\n * // ... other providers\n * ],\n * };\n * ```\n */\n// Single overload that provides IntelliSense for all cases\nexport function provideTheme<const T extends readonly string[] = []>(config?: {\n\tadditionalThemes?: T;\n\tdefaultTheme?: T extends readonly [string, ...string[]] ? DefaultThemeCode | ExtractThemeCode<T> : DefaultThemeCode;\n\texcludeThemes?: T extends readonly [string, ...string[]] ? readonly (DefaultThemeCode | ExtractThemeCode<T>)[] : readonly DefaultThemeCode[];\n\tdefaultScheme?: ThemeScheme;\n}): (Provider | EnvironmentProviders)[] {\n\treturn [\n\t\t{\n\t\t\tprovide: THEME_CONFIG_TOKEN,\n\t\t\t// Pass through original object so literal tuple types survive for IDE IntelliSense\n\t\t\tuseValue: (config || {}) as ThemeConfig,\n\t\t},\n\t\t// Automatically initialize theme service for MFE compatibility\n\t\tprovideAppInitializer(() => inject(ThemeService).init()),\n\t];\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAoBA;AACO,MAAM,kBAAkB,GAAG;AACrB,MAAA,cAAc,GAAG,CAAC,kBAAkB;AACpC,MAAA,mBAAmB,GAAG,CAAC,kBAAkB;AAuFtD;MACa,kBAAkB,GAAG,IAAI,cAAc,CAAc,qBAAqB;AAEvF;AACA,MAAM,wBAAwB,GAAG,eAAe;AAChD,MAAM,yBAAyB,GAAG,gBAAgB;MAKrC,YAAY,CAAA;AAkDN,IAAA,eAAA;AACkB,IAAA,QAAA;AACsB,IAAA,WAAA;AAnD1C,IAAA,kBAAkB,GAAG,MAAM,CAAC,kBAAkB,CAAC;AAC9C,IAAA,QAAQ;IACjB,WAAW,GAAG,KAAK;;AAGnB,IAAA,MAAM,GAIV;QACH,eAAe,EAAE,CAAC,kBAAkB,CAAC;AACrC,QAAA,YAAY,EAAE,kBAAkB;AAChC,QAAA,aAAa,EAAE,QAAQ;KACvB;;IAGM,aAAa,GAAG,MAAM,CAAS,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC;IACxD,cAAc,GAAG,MAAM,CAAc,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC;AAEtE;;;;AAIG;AACI,IAAA,cAAc,GAAG,QAAQ,CAAC,MAAK;AACrC,QAAA,MAAM,MAAM,GAAG,IAAI,CAAC,cAAc,EAAE;AAEpC,QAAA,IAAI,MAAM,KAAK,QAAQ,EAAE;;AAExB,YAAA,MAAM,WAAW,GAAG,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,UAAU,IAAI,MA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AE,MAAM;AAClB,iBAAA;;0BAoDE,MAAM;2BAAC,QAAQ;;0BACf,MAAM;2BAAC,kBAAkB;;0BAAG;;AA0M/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCG;AACH;AACM,SAAU,YAAY,CAAyC,MAKpE,EAAA;IACA,OAAO;AACN,QAAA;AACC,YAAA,OAAO,EAAE,kBAAkB;;AAE3B,YAAA,QAAQ,GAAG,MAAM,IAAI,EAAE,CAAgB;AACvC,SAAA;;QAED,qBAAqB,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC,CAAC,IAAI,EAAE,CAAC;KACxD;AACF;;ACzaA;;AAEG;;;;"}
@@ -0,0 +1,332 @@
1
+ import { DOCUMENT } from '@angular/common';
2
+ import { HttpBackend, HttpClient } from '@angular/common/http';
3
+ export { HttpBackend } from '@angular/common/http';
4
+ import * as i0 from '@angular/core';
5
+ import { InjectionToken, inject, Optional, Inject, Injectable, provideAppInitializer } from '@angular/core';
6
+ import { TranslateService, TranslateLoader, provideTranslateService, MissingTranslationHandler } from '@ngx-translate/core';
7
+ export { FakeMissingTranslationHandler, MissingTranslationHandler, TranslateCompiler, TranslateDefaultParser, TranslateDirective, TranslateFakeCompiler, TranslateLoader, TranslateModule, TranslateParser, TranslatePipe, TranslateService, TranslateStore, provideTranslateService } from '@ngx-translate/core';
8
+ import { TranslateHttpLoader } from '@ngx-translate/http-loader';
9
+ export { TranslateHttpLoader } from '@ngx-translate/http-loader';
10
+ import { MultiTranslateHttpLoader } from 'ngx-translate-multi-http-loader';
11
+ export { MultiTranslateHttpLoader } from 'ngx-translate-multi-http-loader';
12
+
13
+ /**
14
+ * Helper function to create a language definition with full type safety and IntelliSense
15
+ */
16
+ function createLanguage(config) {
17
+ return {
18
+ code: config.code,
19
+ name: config.name,
20
+ };
21
+ }
22
+ // Default base languages - always available
23
+ const DEFAULT_LANGUAGES = [
24
+ { code: 'en', name: 'English' },
25
+ { code: 'es', name: 'Español' },
26
+ { code: 'pt', name: 'Português' },
27
+ ];
28
+ const DEFAULT_LANGUAGE_CODE = 'en';
29
+ // Export language codes for IntelliSense
30
+ const DEFAULT_LANGUAGE_CODES = ['en', 'es', 'pt'];
31
+ // Custom missing translation handler to show keys instead of falling back to default language
32
+ class PlaceholderMissingTranslationHandler {
33
+ handle(params) {
34
+ // Return the translation key as placeholder to make missing translations visible
35
+ return params.key;
36
+ }
37
+ }
38
+ // Injection tokens for dependency injection
39
+ const TRANSLATION_CONFIG_TOKEN = new InjectionToken('Translation Configuration');
40
+ const LOCALIZATION_LOCAL_STORAGE_KEY = 'language';
41
+ /**
42
+ * Factory function to create HTTP loader for translations with custom paths
43
+ */
44
+ function HttpLoaderFactory(http) {
45
+ return new TranslateHttpLoader(http, './assets/i18n/', '.json');
46
+ }
47
+ /**
48
+ * Factory function to create multi-path HTTP loader for translations
49
+ */
50
+ function MultiPathHttpLoaderFactory(httpBackend, paths) {
51
+ return new MultiTranslateHttpLoader(httpBackend, paths);
52
+ }
53
+ /**
54
+ * Utility function to extend default languages with additional ones
55
+ */
56
+ function extendDefaultLanguages(additionalLanguages) {
57
+ return [...DEFAULT_LANGUAGES, ...additionalLanguages];
58
+ }
59
+ class TranslationService {
60
+ translationConfig;
61
+ translate = inject(TranslateService);
62
+ document = inject(DOCUMENT);
63
+ initialized = false;
64
+ // Default configuration - can be overridden by provider
65
+ config = {
66
+ availableLanguages: [...DEFAULT_LANGUAGES],
67
+ defaultLang: DEFAULT_LANGUAGE_CODE,
68
+ translationPaths: ['/assets/i18n/'],
69
+ };
70
+ constructor(translationConfig) {
71
+ this.translationConfig = translationConfig;
72
+ // Configure with provided config or defaults
73
+ if (translationConfig) {
74
+ this.configure(translationConfig);
75
+ }
76
+ else {
77
+ // Initialize with defaults immediately
78
+ this.initializeFromStorage();
79
+ this.applyLanguage();
80
+ this.initialized = true;
81
+ }
82
+ }
83
+ /**
84
+ * Configure and initialize the translation service (used by provider)
85
+ */
86
+ configure(config = {}) {
87
+ // Start with default base languages (en, es, pt)
88
+ let availableLanguages = [...DEFAULT_LANGUAGES];
89
+ // Handle additional languages
90
+ if (config.additionalLanguages) {
91
+ availableLanguages = [...DEFAULT_LANGUAGES, ...config.additionalLanguages];
92
+ }
93
+ // Apply language exclusions if specified
94
+ if (config.excludeLanguages) {
95
+ const excludeCodes = config.excludeLanguages;
96
+ availableLanguages = availableLanguages.filter((lang) => !excludeCodes.includes(lang.code));
97
+ }
98
+ // Determine default language
99
+ const defaultLang = config.defaultLang || DEFAULT_LANGUAGE_CODE;
100
+ // Update configuration
101
+ this.config = {
102
+ availableLanguages,
103
+ defaultLang,
104
+ translationPaths: config.translationPaths || this.config.translationPaths,
105
+ };
106
+ // Validate defaultLang is in available languages
107
+ const availableCodes = this.config.availableLanguages.map((lang) => lang.code);
108
+ if (!availableCodes.includes(this.config.defaultLang)) {
109
+ console.warn(`TranslationService: defaultLang '${this.config.defaultLang}' not in availableLanguages, using '${availableCodes[0] || DEFAULT_LANGUAGE_CODE}'`);
110
+ this.config.defaultLang = availableCodes[0] || DEFAULT_LANGUAGE_CODE;
111
+ }
112
+ // If this is called after constructor (provider case), re-initialize with new config
113
+ if (this.initialized) {
114
+ this.initializeFromStorage();
115
+ }
116
+ else {
117
+ this.initializeFromStorage();
118
+ this.initialized = true;
119
+ }
120
+ }
121
+ /**
122
+ * Initialize translation from localStorage and apply it immediately
123
+ */
124
+ initializeFromStorage() {
125
+ // Safety checks for browser environment
126
+ if (typeof window === 'undefined' || typeof localStorage === 'undefined') {
127
+ console.warn('TranslationService: Browser environment not available, using defaults');
128
+ this.applyLanguage();
129
+ return;
130
+ }
131
+ try {
132
+ // Set up translate service with available languages
133
+ this.translate.setDefaultLang(this.config.defaultLang);
134
+ // Load available translations
135
+ const languageCodes = this.config.availableLanguages.map((lang) => lang.code);
136
+ this.translate.addLangs(languageCodes);
137
+ // Get current language from storage or use default
138
+ const savedLang = localStorage.getItem(LOCALIZATION_LOCAL_STORAGE_KEY);
139
+ const currentLang = savedLang && languageCodes.includes(savedLang) ? savedLang : this.config.defaultLang;
140
+ // Apply language immediately
141
+ this.applyLanguage(currentLang);
142
+ }
143
+ catch (error) {
144
+ console.error('TranslationService: Failed to initialize from storage:', error);
145
+ this.applyLanguage();
146
+ }
147
+ }
148
+ /**
149
+ * Apply the current language to the translate service and document
150
+ */
151
+ applyLanguage(lang) {
152
+ const targetLang = lang || this.config.defaultLang;
153
+ // Set the language in translate service
154
+ this.translate.use(targetLang);
155
+ // Update HTML lang attribute for accessibility and SEO
156
+ this.document.documentElement.lang = targetLang;
157
+ // Persist to localStorage
158
+ if (typeof localStorage !== 'undefined') {
159
+ localStorage.setItem(LOCALIZATION_LOCAL_STORAGE_KEY, targetLang);
160
+ }
161
+ }
162
+ /**
163
+ * Set the current language and persist to localStorage
164
+ */
165
+ setLanguage(lang) {
166
+ if (lang) {
167
+ // Validate language is available
168
+ const availableCodes = this.config.availableLanguages.map((l) => l.code);
169
+ if (!availableCodes.includes(lang)) {
170
+ console.warn(`TranslationService: Language '${lang}' not available, using default '${this.config.defaultLang}'`);
171
+ lang = this.config.defaultLang;
172
+ }
173
+ this.applyLanguage(lang);
174
+ }
175
+ }
176
+ /**
177
+ * Get the current language from localStorage or default
178
+ */
179
+ getCurrentLanguage() {
180
+ if (typeof localStorage === 'undefined') {
181
+ return this.config.defaultLang;
182
+ }
183
+ const saved = localStorage.getItem(LOCALIZATION_LOCAL_STORAGE_KEY);
184
+ const availableCodes = this.config.availableLanguages.map((l) => l.code);
185
+ return saved && availableCodes.includes(saved) ? saved : this.config.defaultLang;
186
+ }
187
+ /**
188
+ * Get the current HTML lang attribute
189
+ */
190
+ getCurrentHtmlLanguage() {
191
+ return this.document.documentElement.lang || this.config.defaultLang;
192
+ }
193
+ /**
194
+ * Get available languages
195
+ */
196
+ getAvailableLanguages() {
197
+ return this.translate.getLangs();
198
+ }
199
+ /**
200
+ * Get default language
201
+ */
202
+ getDefaultLanguage() {
203
+ return this.config.defaultLang;
204
+ }
205
+ /**
206
+ * Instantly translate a key with optional parameters
207
+ */
208
+ instant(key, params) {
209
+ if (params) {
210
+ return this.translate.instant(key, params);
211
+ }
212
+ return this.translate.instant(key);
213
+ }
214
+ /**
215
+ * Get observable translation for a key
216
+ */
217
+ get(key, params) {
218
+ if (params) {
219
+ return this.translate.get(key, params);
220
+ }
221
+ return this.translate.get(key);
222
+ }
223
+ /**
224
+ * Get stream of translations for a key
225
+ */
226
+ stream(key, params) {
227
+ if (params) {
228
+ return this.translate.stream(key, params);
229
+ }
230
+ return this.translate.stream(key);
231
+ }
232
+ /**
233
+ * Get available languages configuration
234
+ */
235
+ getAvailableLanguagesConfig() {
236
+ return this.config.availableLanguages;
237
+ }
238
+ /**
239
+ * Get available language codes
240
+ */
241
+ getAvailableLanguageCodes() {
242
+ return this.config.availableLanguages.map((lang) => lang.code);
243
+ }
244
+ /**
245
+ * Get language configuration by code
246
+ */
247
+ getLanguageByCode(code) {
248
+ return this.config.availableLanguages.find((lang) => lang.code === code);
249
+ }
250
+ /**
251
+ * Get language display name by code
252
+ */
253
+ getLanguageDisplayName(code) {
254
+ const language = this.getLanguageByCode(code);
255
+ return language ? language.name : code.toUpperCase();
256
+ }
257
+ /**
258
+ * Get localized language name by code using translations
259
+ * This automatically returns the localized name based on the current language
260
+ */
261
+ getLocalizedLanguageName(code) {
262
+ const translationKey = `sdk.language.languages.${code}`;
263
+ const translatedName = this.translate.instant(translationKey);
264
+ if (translatedName && translatedName !== translationKey) {
265
+ return translatedName;
266
+ }
267
+ const language = this.getLanguageByCode(code);
268
+ return language ? language.name : code.toUpperCase();
269
+ }
270
+ /**
271
+ * Force initialization method for MFE environments
272
+ */
273
+ init() {
274
+ // This method just ensures the service is instantiated and initialized
275
+ this.getAvailableLanguagesConfig(); // Trigger any lazy initialization
276
+ }
277
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: TranslationService, deps: [{ token: TRANSLATION_CONFIG_TOKEN, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
278
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: TranslationService, providedIn: 'root' });
279
+ }
280
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: TranslationService, decorators: [{
281
+ type: Injectable,
282
+ args: [{
283
+ providedIn: 'root',
284
+ }]
285
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
286
+ type: Optional
287
+ }, {
288
+ type: Inject,
289
+ args: [TRANSLATION_CONFIG_TOKEN]
290
+ }] }] });
291
+ // Implementation
292
+ function provideTranslation(config) {
293
+ // Determine which loader to use based on configuration
294
+ const loaderProvider = config?.translationPaths && config.translationPaths.length > 0
295
+ ? {
296
+ provide: TranslateLoader,
297
+ useFactory: (httpBackend) => MultiPathHttpLoaderFactory(httpBackend, config.translationPaths),
298
+ deps: [HttpBackend],
299
+ }
300
+ : {
301
+ provide: TranslateLoader,
302
+ useFactory: HttpLoaderFactory,
303
+ deps: [HttpClient],
304
+ };
305
+ return [
306
+ // Provide the complete ngx-translate setup with appropriate loader and missing translation handler
307
+ provideTranslateService({
308
+ loader: loaderProvider,
309
+ missingTranslationHandler: {
310
+ provide: MissingTranslationHandler,
311
+ useClass: PlaceholderMissingTranslationHandler,
312
+ },
313
+ useDefaultLang: false, // Don't fall back to default language, use missing translation handler instead
314
+ }),
315
+ // Provide our translation configuration
316
+ {
317
+ provide: TRANSLATION_CONFIG_TOKEN,
318
+ useValue: config || {},
319
+ },
320
+ // Automatically initialize translation service for MFE compatibility
321
+ provideAppInitializer(() => inject(TranslationService).init()),
322
+ ];
323
+ }
324
+
325
+ // Export our translation service and types
326
+
327
+ /**
328
+ * Generated bundle index. Do not edit.
329
+ */
330
+
331
+ export { DEFAULT_LANGUAGES, DEFAULT_LANGUAGE_CODE, DEFAULT_LANGUAGE_CODES, HttpLoaderFactory, MultiPathHttpLoaderFactory, PlaceholderMissingTranslationHandler, TRANSLATION_CONFIG_TOKEN, TranslationService, createLanguage, extendDefaultLanguages, provideTranslation };
332
+ //# sourceMappingURL=sixbell-telco-sdk-utils-translation.mjs.map