@sixbell-telco/sdk 1.0.3 → 1.1.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.
- package/CHANGELOG.md +44 -0
- package/README.md +44 -0
- package/_index.css +52 -25
- package/components/avatar/src/avatar.component.d.ts +40 -26
- package/components/button/src/button.component.d.ts +2 -2
- package/components/dropdown/dropdown-chevron/dropdown-chevron.component.d.ts +39 -0
- package/components/dropdown/dropdown-content/dropdown-content.component.d.ts +41 -0
- package/components/dropdown/dropdown-group/dropdown-group.component.d.ts +9 -0
- package/components/dropdown/dropdown-item/dropdown-item.component.d.ts +23 -12
- package/components/dropdown/dropdown-item-checkbox/dropdown-item-checkbox.component.d.ts +49 -0
- package/components/dropdown/dropdown-item-radio/dropdown-item-radio.component.d.ts +53 -0
- package/components/dropdown/dropdown-label/dropdown-label.component.d.ts +17 -0
- package/components/dropdown/dropdown-separator/dropdown-separator.component.d.ts +21 -0
- package/components/dropdown/dropdown-trigger/dropdown-trigger.component.d.ts +121 -0
- package/components/dropdown/public-api.d.ts +9 -0
- package/components/dropdown/src/dropdown.component.d.ts +20 -174
- package/components/dropdown/src/services/dropdown.service.d.ts +22 -0
- package/components/dropdown-menu/bar/dropdown-menu-bar/dropdown-menu-bar.component.d.ts +22 -0
- package/components/dropdown-menu/bar/dropdown-menu-bar-content/dropdown-menu-bar-content.component.d.ts +64 -0
- package/components/dropdown-menu/bar/dropdown-menu-bar-item/dropdown-menu-bar-item.component.d.ts +37 -0
- package/components/dropdown-menu/bar/dropdown-menu-bar-item-checkbox/dropdown-menu-bar-item-checkbox.component.d.ts +54 -0
- package/components/dropdown-menu/bar/dropdown-menu-bar-item-radio/dropdown-menu-bar-item-radio.component.d.ts +58 -0
- package/components/dropdown-menu/bar/dropdown-menu-bar-label/dropdown-menu-bar-label.component.d.ts +16 -0
- package/components/dropdown-menu/bar/dropdown-menu-bar-separator/dropdown-menu-bar-separator.component.d.ts +16 -0
- package/components/dropdown-menu/bar/dropdown-menu-bar-sub-trigger/dropdown-menu-bar-sub-trigger.component.d.ts +29 -0
- package/components/dropdown-menu/bar/dropdown-menu-bar-trigger/dropdown-menu-bar-trigger.component.d.ts +50 -0
- package/components/dropdown-menu/bar/index.d.ts +5 -0
- package/components/dropdown-menu/bar/public-api.d.ts +9 -0
- package/components/dropdown-menu/context/dropdown-context-menu-trigger/dropdown-context-menu-trigger.component.d.ts +23 -0
- package/components/dropdown-menu/context/index.d.ts +5 -0
- package/components/dropdown-menu/context/public-api.d.ts +1 -0
- package/components/dropdown-menu/dropdown-menu-chevron/dropdown-menu-chevron.component.d.ts +43 -0
- package/components/dropdown-menu/index.d.ts +5 -0
- package/components/dropdown-menu/public-api.d.ts +13 -0
- package/components/dropdown-menu/src/directives/dropdown-menu.directive.d.ts +40 -0
- package/components/dropdown-menu/src/dropdown-menu/dropdown-menu.component.d.ts +9 -0
- package/components/dropdown-menu/src/dropdown-menu-content/dropdown-menu-content.component.d.ts +40 -0
- package/components/dropdown-menu/src/dropdown-menu-group/dropdown-menu-group.component.d.ts +8 -0
- package/components/dropdown-menu/src/dropdown-menu-item/dropdown-menu-item.component.d.ts +38 -0
- package/components/dropdown-menu/src/dropdown-menu-label/dropdown-menu-label.component.d.ts +16 -0
- package/components/dropdown-menu/src/dropdown-menu-separator/dropdown-menu-separator.component.d.ts +16 -0
- package/components/dropdown-menu/src/dropdown-menu-sub/dropdown-menu-sub.component.d.ts +8 -0
- package/components/dropdown-menu/src/dropdown-menu-sub-content/dropdown-menu-sub-content.component.d.ts +31 -0
- package/components/dropdown-menu/src/dropdown-menu-sub-trigger/dropdown-menu-sub-trigger.component.d.ts +18 -0
- package/components/dropdown-menu/src/dropdown-menu-trigger/dropdown-menu-trigger.component.d.ts +19 -0
- package/components/dropdown-menu/src/services/dropdown-menu.service.d.ts +22 -0
- package/fesm2022/sixbell-telco-sdk-components-avatar.mjs +75 -39
- package/fesm2022/sixbell-telco-sdk-components-avatar.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-button.mjs +1 -0
- package/fesm2022/sixbell-telco-sdk-components-button.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-dropdown-menu-bar.mjs +529 -0
- package/fesm2022/sixbell-telco-sdk-components-dropdown-menu-bar.mjs.map +1 -0
- package/fesm2022/sixbell-telco-sdk-components-dropdown-menu-context.mjs +52 -0
- package/fesm2022/sixbell-telco-sdk-components-dropdown-menu-context.mjs.map +1 -0
- package/fesm2022/sixbell-telco-sdk-components-dropdown-menu.mjs +539 -0
- package/fesm2022/sixbell-telco-sdk-components-dropdown-menu.mjs.map +1 -0
- package/fesm2022/sixbell-telco-sdk-components-dropdown.mjs +592 -213
- package/fesm2022/sixbell-telco-sdk-components-dropdown.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-combobox.mjs +2 -2
- package/fesm2022/sixbell-telco-sdk-components-forms-combobox.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-select.mjs +2 -2
- package/fesm2022/sixbell-telco-sdk-components-forms-select.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-product-card.mjs +1 -1
- package/fesm2022/sixbell-telco-sdk-components-product-card.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-utils-theme.mjs +139 -0
- package/fesm2022/sixbell-telco-sdk-utils-theme.mjs.map +1 -0
- package/fesm2022/sixbell-telco-sdk-utils-translation.mjs +183 -0
- package/fesm2022/sixbell-telco-sdk-utils-translation.mjs.map +1 -0
- package/package.json +21 -1
- package/sixbell-telco-sdk-1.1.0.tgz +0 -0
- package/utils/theme/index.d.ts +5 -0
- package/utils/theme/public-api.d.ts +1 -0
- package/utils/theme/src/theme.service.d.ts +55 -0
- package/utils/translation/index.d.ts +5 -0
- package/utils/translation/public-api.d.ts +1 -0
- package/utils/translation/src/translation.service.d.ts +112 -0
- package/sixbell-telco-sdk-1.0.3.tgz +0 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { DOCUMENT } from '@angular/common';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { InjectionToken, inject, Injectable } from '@angular/core';
|
|
4
|
+
import { TranslateService } from '@ngx-translate/core';
|
|
5
|
+
|
|
6
|
+
// Default language configuration - can be overridden
|
|
7
|
+
const DEFAULT_LANGUAGES = [
|
|
8
|
+
{ code: 'en', name: 'English' },
|
|
9
|
+
{ code: 'es', name: 'Español' },
|
|
10
|
+
{ code: 'pt', name: 'Português' },
|
|
11
|
+
];
|
|
12
|
+
const DEFAULT_LANGUAGE_CODE = 'en';
|
|
13
|
+
// Injection tokens for dependency injection
|
|
14
|
+
const AVAILABLE_LANGUAGES = new InjectionToken('Available Languages');
|
|
15
|
+
const DEFAULT_LANG = new InjectionToken('Default Language');
|
|
16
|
+
const LOCALIZATION_LOCAL_STORAGE_KEY = 'language';
|
|
17
|
+
/**
|
|
18
|
+
* Utility function to extend default languages with additional ones
|
|
19
|
+
*
|
|
20
|
+
* @param additionalLanguages - Languages to add to the default set
|
|
21
|
+
* @returns Combined array of default + additional languages
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* const extendedLanguages = extendDefaultLanguages([
|
|
25
|
+
* { code: 'fr', name: 'Français' },
|
|
26
|
+
* { code: 'de', name: 'Deutsch' }
|
|
27
|
+
* ]);
|
|
28
|
+
*/
|
|
29
|
+
function extendDefaultLanguages(additionalLanguages) {
|
|
30
|
+
return [...DEFAULT_LANGUAGES, ...additionalLanguages];
|
|
31
|
+
}
|
|
32
|
+
class TranslationService {
|
|
33
|
+
translate = inject(TranslateService);
|
|
34
|
+
document = inject(DOCUMENT);
|
|
35
|
+
defaultLanguage = DEFAULT_LANGUAGE_CODE;
|
|
36
|
+
languages = DEFAULT_LANGUAGES;
|
|
37
|
+
constructor() {
|
|
38
|
+
this.translate.setDefaultLang(this.defaultLanguage);
|
|
39
|
+
const currentLang = this.getCurrentLanguage();
|
|
40
|
+
this.setLanguage(currentLang);
|
|
41
|
+
// Ensure HTML lang attribute is set on initial load
|
|
42
|
+
this.document.documentElement.lang = currentLang;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Initialize the translation service with available languages
|
|
46
|
+
*/
|
|
47
|
+
init(langs, defaultLang, availableLanguages) {
|
|
48
|
+
if (defaultLang) {
|
|
49
|
+
this.defaultLanguage = defaultLang;
|
|
50
|
+
this.translate.setDefaultLang(defaultLang);
|
|
51
|
+
}
|
|
52
|
+
if (availableLanguages) {
|
|
53
|
+
this.languages = availableLanguages;
|
|
54
|
+
}
|
|
55
|
+
if (langs) {
|
|
56
|
+
this.loadTranslations(langs);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
// Use language codes from available languages
|
|
60
|
+
const languageCodes = this.languages.map((lang) => lang.code);
|
|
61
|
+
this.loadTranslations(languageCodes);
|
|
62
|
+
}
|
|
63
|
+
const currentLang = this.getCurrentLanguage();
|
|
64
|
+
this.setLanguage(currentLang);
|
|
65
|
+
} /**
|
|
66
|
+
* Load available translations
|
|
67
|
+
*/
|
|
68
|
+
loadTranslations(langs) {
|
|
69
|
+
this.translate.addLangs(langs);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Set the current language and persist to localStorage
|
|
73
|
+
* Also updates the HTML lang attribute for accessibility and SEO
|
|
74
|
+
*/
|
|
75
|
+
setLanguage(lang) {
|
|
76
|
+
if (lang) {
|
|
77
|
+
this.translate.use(lang);
|
|
78
|
+
localStorage.setItem(LOCALIZATION_LOCAL_STORAGE_KEY, lang);
|
|
79
|
+
// Update HTML lang attribute for accessibility and SEO
|
|
80
|
+
this.document.documentElement.lang = lang;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Get the current language from localStorage or default
|
|
85
|
+
*/
|
|
86
|
+
getCurrentLanguage() {
|
|
87
|
+
return localStorage.getItem(LOCALIZATION_LOCAL_STORAGE_KEY) ?? this.translate.getDefaultLang();
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Get the current HTML lang attribute
|
|
91
|
+
*/
|
|
92
|
+
getCurrentHtmlLanguage() {
|
|
93
|
+
return this.document.documentElement.lang || this.defaultLanguage;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Get available languages
|
|
97
|
+
*/
|
|
98
|
+
getAvailableLanguages() {
|
|
99
|
+
return this.translate.getLangs();
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Get default language
|
|
103
|
+
*/
|
|
104
|
+
getDefaultLanguage() {
|
|
105
|
+
return this.defaultLanguage;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Instantly translate a key with optional parameters
|
|
109
|
+
*/
|
|
110
|
+
instant(key, params) {
|
|
111
|
+
if (params) {
|
|
112
|
+
return this.translate.instant(key, params);
|
|
113
|
+
}
|
|
114
|
+
return this.translate.instant(key);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Get observable translation for a key
|
|
118
|
+
*/
|
|
119
|
+
get(key, params) {
|
|
120
|
+
if (params) {
|
|
121
|
+
return this.translate.get(key, params);
|
|
122
|
+
}
|
|
123
|
+
return this.translate.get(key);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Get stream of translations for a key
|
|
127
|
+
*/
|
|
128
|
+
stream(key, params) {
|
|
129
|
+
if (params) {
|
|
130
|
+
return this.translate.stream(key, params);
|
|
131
|
+
}
|
|
132
|
+
return this.translate.stream(key);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Get available languages configuration
|
|
136
|
+
*/
|
|
137
|
+
getAvailableLanguagesConfig() {
|
|
138
|
+
return this.languages;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Get available language codes
|
|
142
|
+
*/
|
|
143
|
+
getAvailableLanguageCodes() {
|
|
144
|
+
return this.languages.map((lang) => lang.code);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Get language configuration by code
|
|
148
|
+
*/
|
|
149
|
+
getLanguageByCode(code) {
|
|
150
|
+
return this.languages.find((lang) => lang.code === code);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Get language display name by code
|
|
154
|
+
*/
|
|
155
|
+
getLanguageDisplayName(code) {
|
|
156
|
+
const language = this.getLanguageByCode(code);
|
|
157
|
+
return language ? language.name : code.toUpperCase();
|
|
158
|
+
}
|
|
159
|
+
// Implementation
|
|
160
|
+
static createLanguageProviders(options) {
|
|
161
|
+
const languages = options?.languages ?? DEFAULT_LANGUAGES;
|
|
162
|
+
const defaultLang = options?.defaultLang ?? DEFAULT_LANGUAGE_CODE;
|
|
163
|
+
return [
|
|
164
|
+
{ provide: AVAILABLE_LANGUAGES, useValue: languages },
|
|
165
|
+
{ provide: DEFAULT_LANG, useValue: defaultLang },
|
|
166
|
+
];
|
|
167
|
+
}
|
|
168
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: TranslationService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
169
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: TranslationService, providedIn: 'root' });
|
|
170
|
+
}
|
|
171
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: TranslationService, decorators: [{
|
|
172
|
+
type: Injectable,
|
|
173
|
+
args: [{
|
|
174
|
+
providedIn: 'root',
|
|
175
|
+
}]
|
|
176
|
+
}], ctorParameters: () => [] });
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Generated bundle index. Do not edit.
|
|
180
|
+
*/
|
|
181
|
+
|
|
182
|
+
export { AVAILABLE_LANGUAGES, DEFAULT_LANG, DEFAULT_LANGUAGES, DEFAULT_LANGUAGE_CODE, TranslationService, extendDefaultLanguages };
|
|
183
|
+
//# sourceMappingURL=sixbell-telco-sdk-utils-translation.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sixbell-telco-sdk-utils-translation.mjs","sources":["../../../projects/sdk/utils/translation/src/translation.service.ts","../../../projects/sdk/utils/translation/sixbell-telco-sdk-utils-translation.ts"],"sourcesContent":["import { DOCUMENT } from '@angular/common';\nimport { inject, Injectable, InjectionToken } from '@angular/core';\nimport { TranslateService } from '@ngx-translate/core';\n\nexport interface Language {\n\tcode: string;\n\tname: string;\n}\n\nexport interface Locale {\n\tlang: string;\n\tdata: object;\n}\n\n// Default language configuration - can be overridden\nexport const DEFAULT_LANGUAGES: Language[] = [\n\t{ code: 'en', name: 'English' },\n\t{ code: 'es', name: 'Español' },\n\t{ code: 'pt', name: 'Português' },\n];\n\nexport const DEFAULT_LANGUAGE_CODE = 'en';\n\n// Injection tokens for dependency injection\nexport const AVAILABLE_LANGUAGES = new InjectionToken<Language[]>('Available Languages');\nexport const DEFAULT_LANG = new InjectionToken<string>('Default Language');\n\nconst LOCALIZATION_LOCAL_STORAGE_KEY = 'language';\n\n/**\n * Utility function to extend default languages with additional ones\n *\n * @param additionalLanguages - Languages to add to the default set\n * @returns Combined array of default + additional languages\n *\n * @example\n * const extendedLanguages = extendDefaultLanguages([\n * { code: 'fr', name: 'Français' },\n * { code: 'de', name: 'Deutsch' }\n * ]);\n */\nexport function extendDefaultLanguages(additionalLanguages: Language[]): Language[] {\n\treturn [...DEFAULT_LANGUAGES, ...additionalLanguages];\n}\n\n@Injectable({\n\tprovidedIn: 'root',\n})\nexport class TranslationService {\n\tprivate readonly translate = inject(TranslateService);\n\tprivate readonly document = inject(DOCUMENT);\n\tprivate defaultLanguage = DEFAULT_LANGUAGE_CODE;\n\tprivate languages: Language[] = DEFAULT_LANGUAGES;\n\n\tconstructor() {\n\t\tthis.translate.setDefaultLang(this.defaultLanguage);\n\n\t\tconst currentLang = this.getCurrentLanguage();\n\t\tthis.setLanguage(currentLang);\n\n\t\t// Ensure HTML lang attribute is set on initial load\n\t\tthis.document.documentElement.lang = currentLang;\n\t}\n\n\t/**\n\t * Initialize the translation service with available languages\n\t */\n\tinit(langs?: string[], defaultLang?: string, availableLanguages?: Language[]): void {\n\t\tif (defaultLang) {\n\t\t\tthis.defaultLanguage = defaultLang;\n\t\t\tthis.translate.setDefaultLang(defaultLang);\n\t\t}\n\n\t\tif (availableLanguages) {\n\t\t\tthis.languages = availableLanguages;\n\t\t}\n\n\t\tif (langs) {\n\t\t\tthis.loadTranslations(langs);\n\t\t} else {\n\t\t\t// Use language codes from available languages\n\t\t\tconst languageCodes = this.languages.map((lang) => lang.code);\n\t\t\tthis.loadTranslations(languageCodes);\n\t\t}\n\n\t\tconst currentLang = this.getCurrentLanguage();\n\t\tthis.setLanguage(currentLang);\n\t} /**\n\t * Load available translations\n\t */\n\tloadTranslations(langs: string[]): void {\n\t\tthis.translate.addLangs(langs);\n\t}\n\n\t/**\n\t * Set the current language and persist to localStorage\n\t * Also updates the HTML lang attribute for accessibility and SEO\n\t */\n\tsetLanguage(lang: string): void {\n\t\tif (lang) {\n\t\t\tthis.translate.use(lang);\n\t\t\tlocalStorage.setItem(LOCALIZATION_LOCAL_STORAGE_KEY, lang);\n\n\t\t\t// Update HTML lang attribute for accessibility and SEO\n\t\t\tthis.document.documentElement.lang = lang;\n\t\t}\n\t}\n\n\t/**\n\t * Get the current language from localStorage or default\n\t */\n\tgetCurrentLanguage(): string {\n\t\treturn localStorage.getItem(LOCALIZATION_LOCAL_STORAGE_KEY) ?? this.translate.getDefaultLang();\n\t}\n\n\t/**\n\t * Get the current HTML lang attribute\n\t */\n\tgetCurrentHtmlLanguage(): string {\n\t\treturn this.document.documentElement.lang || this.defaultLanguage;\n\t}\n\n\t/**\n\t * Get available languages\n\t */\n\tgetAvailableLanguages(): string[] {\n\t\treturn this.translate.getLangs();\n\t}\n\n\t/**\n\t * Get default language\n\t */\n\tgetDefaultLanguage(): string {\n\t\treturn this.defaultLanguage;\n\t}\n\n\t/**\n\t * Instantly translate a key with optional parameters\n\t */\n\tinstant(key: string, params?: object | undefined): string {\n\t\tif (params) {\n\t\t\treturn this.translate.instant(key, params);\n\t\t}\n\n\t\treturn this.translate.instant(key);\n\t}\n\n\t/**\n\t * Get observable translation for a key\n\t */\n\tget(key: string, params?: object | undefined) {\n\t\tif (params) {\n\t\t\treturn this.translate.get(key, params);\n\t\t}\n\n\t\treturn this.translate.get(key);\n\t}\n\n\t/**\n\t * Get stream of translations for a key\n\t */\n\tstream(key: string, params?: object | undefined) {\n\t\tif (params) {\n\t\t\treturn this.translate.stream(key, params);\n\t\t}\n\n\t\treturn this.translate.stream(key);\n\t}\n\n\t/**\n\t * Get available languages configuration\n\t */\n\tgetAvailableLanguagesConfig(): Language[] {\n\t\treturn this.languages;\n\t}\n\n\t/**\n\t * Get available language codes\n\t */\n\tgetAvailableLanguageCodes(): string[] {\n\t\treturn this.languages.map((lang) => lang.code);\n\t}\n\n\t/**\n\t * Get language configuration by code\n\t */\n\tgetLanguageByCode(code: string): Language | undefined {\n\t\treturn this.languages.find((lang) => lang.code === code);\n\t}\n\n\t/**\n\t * Get language display name by code\n\t */\n\tgetLanguageDisplayName(code: string): string {\n\t\tconst language = this.getLanguageByCode(code);\n\t\treturn language ? language.name : code.toUpperCase();\n\t}\n\n\t/**\n\t * Static utility to create provider configuration for apps with type-safe overloads\n\t */\n\n\t// Overload 1: No parameters - use all defaults\n\tstatic createLanguageProviders(): Array<{ provide: InjectionToken<unknown>; useValue: unknown }>;\n\n\t// Overload 2: Only default language specified - use default languages\n\tstatic createLanguageProviders(options: {\n\t\tdefaultLang: (typeof DEFAULT_LANGUAGES)[number]['code'];\n\t}): Array<{ provide: InjectionToken<unknown>; useValue: unknown }>;\n\n\t// Overload 3: Custom languages - defaultLang gets IntelliSense from provided languages\n\tstatic createLanguageProviders<T extends readonly Language[]>(options: {\n\t\tlanguages: T;\n\t\tdefaultLang?: T[number]['code'];\n\t}): Array<{ provide: InjectionToken<unknown>; useValue: unknown }>;\n\n\t// Implementation\n\tstatic createLanguageProviders<T extends readonly Language[]>(options?: {\n\t\tlanguages?: T;\n\t\tdefaultLang?: T[number]['code'] | (typeof DEFAULT_LANGUAGES)[number]['code'];\n\t}) {\n\t\tconst languages = options?.languages ?? DEFAULT_LANGUAGES;\n\t\tconst defaultLang = options?.defaultLang ?? DEFAULT_LANGUAGE_CODE;\n\n\t\treturn [\n\t\t\t{ provide: AVAILABLE_LANGUAGES, useValue: languages },\n\t\t\t{ provide: DEFAULT_LANG, useValue: defaultLang },\n\t\t];\n\t}\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAcA;AACa,MAAA,iBAAiB,GAAe;AAC5C,IAAA,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE;AAC/B,IAAA,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE;AAC/B,IAAA,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE;;AAG3B,MAAM,qBAAqB,GAAG;AAErC;MACa,mBAAmB,GAAG,IAAI,cAAc,CAAa,qBAAqB;MAC1E,YAAY,GAAG,IAAI,cAAc,CAAS,kBAAkB;AAEzE,MAAM,8BAA8B,GAAG,UAAU;AAEjD;;;;;;;;;;;AAWG;AACG,SAAU,sBAAsB,CAAC,mBAA+B,EAAA;AACrE,IAAA,OAAO,CAAC,GAAG,iBAAiB,EAAE,GAAG,mBAAmB,CAAC;AACtD;MAKa,kBAAkB,CAAA;AACb,IAAA,SAAS,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACpC,IAAA,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IACpC,eAAe,GAAG,qBAAqB;IACvC,SAAS,GAAe,iBAAiB;AAEjD,IAAA,WAAA,GAAA;QACC,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,eAAe,CAAC;AAEnD,QAAA,MAAM,WAAW,GAAG,IAAI,CAAC,kBAAkB,EAAE;AA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S,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC;;AAGzD;;AAEG;AACH,IAAA,sBAAsB,CAAC,IAAY,EAAA;QAClC,MAAM,QAAQ,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC;AAC7C,QAAA,OAAO,QAAQ,GAAG,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE;;;IAsBrD,OAAO,uBAAuB,CAAgC,OAG7D,EAAA;AACA,QAAA,MAAM,SAAS,GAAG,OAAO,EAAE,SAAS,IAAI,iBAAiB;AACzD,QAAA,MAAM,WAAW,GAAG,OAAO,EAAE,WAAW,IAAI,qBAAqB;QAEjE,OAAO;AACN,YAAA,EAAE,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,SAAS,EAAE;AACrD,YAAA,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE;SAChD;;uGAnLU,kBAAkB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAAlB,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,kBAAkB,cAFlB,MAAM,EAAA,CAAA;;2FAEN,kBAAkB,EAAA,UAAA,EAAA,CAAA;kBAH9B,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACX,oBAAA,UAAU,EAAE,MAAM;AAClB,iBAAA;;;AC/CD;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sixbell-telco/sdk",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "A collection of reusable components designed for use in Sixbell Telco Angular projects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sixbell",
|
|
@@ -78,6 +78,10 @@
|
|
|
78
78
|
"types": "./components/dropdown/index.d.ts",
|
|
79
79
|
"default": "./fesm2022/sixbell-telco-sdk-components-dropdown.mjs"
|
|
80
80
|
},
|
|
81
|
+
"./components/dropdown-menu": {
|
|
82
|
+
"types": "./components/dropdown-menu/index.d.ts",
|
|
83
|
+
"default": "./fesm2022/sixbell-telco-sdk-components-dropdown-menu.mjs"
|
|
84
|
+
},
|
|
81
85
|
"./components/dual-list": {
|
|
82
86
|
"types": "./components/dual-list/index.d.ts",
|
|
83
87
|
"default": "./fesm2022/sixbell-telco-sdk-components-dual-list.mjs"
|
|
@@ -138,6 +142,22 @@
|
|
|
138
142
|
"types": "./utils/cn/index.d.ts",
|
|
139
143
|
"default": "./fesm2022/sixbell-telco-sdk-utils-cn.mjs"
|
|
140
144
|
},
|
|
145
|
+
"./utils/theme": {
|
|
146
|
+
"types": "./utils/theme/index.d.ts",
|
|
147
|
+
"default": "./fesm2022/sixbell-telco-sdk-utils-theme.mjs"
|
|
148
|
+
},
|
|
149
|
+
"./utils/translation": {
|
|
150
|
+
"types": "./utils/translation/index.d.ts",
|
|
151
|
+
"default": "./fesm2022/sixbell-telco-sdk-utils-translation.mjs"
|
|
152
|
+
},
|
|
153
|
+
"./components/dropdown-menu/bar": {
|
|
154
|
+
"types": "./components/dropdown-menu/bar/index.d.ts",
|
|
155
|
+
"default": "./fesm2022/sixbell-telco-sdk-components-dropdown-menu-bar.mjs"
|
|
156
|
+
},
|
|
157
|
+
"./components/dropdown-menu/context": {
|
|
158
|
+
"types": "./components/dropdown-menu/context/index.d.ts",
|
|
159
|
+
"default": "./fesm2022/sixbell-telco-sdk-components-dropdown-menu-context.mjs"
|
|
160
|
+
},
|
|
141
161
|
"./components/forms/checkbox": {
|
|
142
162
|
"types": "./components/forms/checkbox/index.d.ts",
|
|
143
163
|
"default": "./fesm2022/sixbell-telco-sdk-components-forms-checkbox.mjs"
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './src/theme.service';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { RendererFactory2 } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export type ThemeScheme = 'system' | 'light' | 'dark';
|
|
4
|
+
export interface ThemeConfig {
|
|
5
|
+
availableThemes?: string[];
|
|
6
|
+
defaultTheme?: string;
|
|
7
|
+
defaultScheme?: ThemeScheme;
|
|
8
|
+
}
|
|
9
|
+
export declare class ThemeService {
|
|
10
|
+
private readonly rendererFactory;
|
|
11
|
+
private readonly document;
|
|
12
|
+
private readonly renderer;
|
|
13
|
+
private readonly fixedSchemes;
|
|
14
|
+
private config;
|
|
15
|
+
selectedTheme: import("@angular/core").WritableSignal<string>;
|
|
16
|
+
selectedScheme: import("@angular/core").WritableSignal<ThemeScheme>;
|
|
17
|
+
finalTheme: import("@angular/core").Signal<string>;
|
|
18
|
+
constructor(rendererFactory: RendererFactory2, document: Document);
|
|
19
|
+
/**
|
|
20
|
+
* Initialize the theme service with custom configuration
|
|
21
|
+
*/
|
|
22
|
+
configure(config: Partial<ThemeConfig>): void;
|
|
23
|
+
/**
|
|
24
|
+
* Initialize theme from localStorage and apply it immediately
|
|
25
|
+
* Call this as early as possible in your app
|
|
26
|
+
*/
|
|
27
|
+
initializeTheme(): void;
|
|
28
|
+
/**
|
|
29
|
+
* Apply the current theme to the document
|
|
30
|
+
*/
|
|
31
|
+
private applyTheme;
|
|
32
|
+
/**
|
|
33
|
+
* Update theme and persist to localStorage
|
|
34
|
+
*/
|
|
35
|
+
updateTheme(theme: string): void;
|
|
36
|
+
/**
|
|
37
|
+
* Update scheme and persist to localStorage
|
|
38
|
+
*/
|
|
39
|
+
updateScheme(scheme: ThemeScheme): void;
|
|
40
|
+
/**
|
|
41
|
+
* Get available themes
|
|
42
|
+
*/
|
|
43
|
+
getAvailableThemes(): string[];
|
|
44
|
+
/**
|
|
45
|
+
* Get available schemes
|
|
46
|
+
*/
|
|
47
|
+
getAvailableSchemes(): readonly ThemeScheme[];
|
|
48
|
+
/**
|
|
49
|
+
* Initialize theme before Angular boots
|
|
50
|
+
* This should be called in main.ts before bootstrapApplication
|
|
51
|
+
*/
|
|
52
|
+
static init(config?: ThemeConfig): void;
|
|
53
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ThemeService, never>;
|
|
54
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<ThemeService>;
|
|
55
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './src/translation.service';
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export interface Language {
|
|
4
|
+
code: string;
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
7
|
+
export interface Locale {
|
|
8
|
+
lang: string;
|
|
9
|
+
data: object;
|
|
10
|
+
}
|
|
11
|
+
export declare const DEFAULT_LANGUAGES: Language[];
|
|
12
|
+
export declare const DEFAULT_LANGUAGE_CODE = "en";
|
|
13
|
+
export declare const AVAILABLE_LANGUAGES: InjectionToken<Language[]>;
|
|
14
|
+
export declare const DEFAULT_LANG: InjectionToken<string>;
|
|
15
|
+
/**
|
|
16
|
+
* Utility function to extend default languages with additional ones
|
|
17
|
+
*
|
|
18
|
+
* @param additionalLanguages - Languages to add to the default set
|
|
19
|
+
* @returns Combined array of default + additional languages
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* const extendedLanguages = extendDefaultLanguages([
|
|
23
|
+
* { code: 'fr', name: 'Français' },
|
|
24
|
+
* { code: 'de', name: 'Deutsch' }
|
|
25
|
+
* ]);
|
|
26
|
+
*/
|
|
27
|
+
export declare function extendDefaultLanguages(additionalLanguages: Language[]): Language[];
|
|
28
|
+
export declare class TranslationService {
|
|
29
|
+
private readonly translate;
|
|
30
|
+
private readonly document;
|
|
31
|
+
private defaultLanguage;
|
|
32
|
+
private languages;
|
|
33
|
+
constructor();
|
|
34
|
+
/**
|
|
35
|
+
* Initialize the translation service with available languages
|
|
36
|
+
*/
|
|
37
|
+
init(langs?: string[], defaultLang?: string, availableLanguages?: Language[]): void; /**
|
|
38
|
+
* Load available translations
|
|
39
|
+
*/
|
|
40
|
+
loadTranslations(langs: string[]): void;
|
|
41
|
+
/**
|
|
42
|
+
* Set the current language and persist to localStorage
|
|
43
|
+
* Also updates the HTML lang attribute for accessibility and SEO
|
|
44
|
+
*/
|
|
45
|
+
setLanguage(lang: string): void;
|
|
46
|
+
/**
|
|
47
|
+
* Get the current language from localStorage or default
|
|
48
|
+
*/
|
|
49
|
+
getCurrentLanguage(): string;
|
|
50
|
+
/**
|
|
51
|
+
* Get the current HTML lang attribute
|
|
52
|
+
*/
|
|
53
|
+
getCurrentHtmlLanguage(): string;
|
|
54
|
+
/**
|
|
55
|
+
* Get available languages
|
|
56
|
+
*/
|
|
57
|
+
getAvailableLanguages(): string[];
|
|
58
|
+
/**
|
|
59
|
+
* Get default language
|
|
60
|
+
*/
|
|
61
|
+
getDefaultLanguage(): string;
|
|
62
|
+
/**
|
|
63
|
+
* Instantly translate a key with optional parameters
|
|
64
|
+
*/
|
|
65
|
+
instant(key: string, params?: object | undefined): string;
|
|
66
|
+
/**
|
|
67
|
+
* Get observable translation for a key
|
|
68
|
+
*/
|
|
69
|
+
get(key: string, params?: object | undefined): import("rxjs").Observable<any>;
|
|
70
|
+
/**
|
|
71
|
+
* Get stream of translations for a key
|
|
72
|
+
*/
|
|
73
|
+
stream(key: string, params?: object | undefined): import("rxjs").Observable<any>;
|
|
74
|
+
/**
|
|
75
|
+
* Get available languages configuration
|
|
76
|
+
*/
|
|
77
|
+
getAvailableLanguagesConfig(): Language[];
|
|
78
|
+
/**
|
|
79
|
+
* Get available language codes
|
|
80
|
+
*/
|
|
81
|
+
getAvailableLanguageCodes(): string[];
|
|
82
|
+
/**
|
|
83
|
+
* Get language configuration by code
|
|
84
|
+
*/
|
|
85
|
+
getLanguageByCode(code: string): Language | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* Get language display name by code
|
|
88
|
+
*/
|
|
89
|
+
getLanguageDisplayName(code: string): string;
|
|
90
|
+
/**
|
|
91
|
+
* Static utility to create provider configuration for apps with type-safe overloads
|
|
92
|
+
*/
|
|
93
|
+
static createLanguageProviders(): Array<{
|
|
94
|
+
provide: InjectionToken<unknown>;
|
|
95
|
+
useValue: unknown;
|
|
96
|
+
}>;
|
|
97
|
+
static createLanguageProviders(options: {
|
|
98
|
+
defaultLang: (typeof DEFAULT_LANGUAGES)[number]['code'];
|
|
99
|
+
}): Array<{
|
|
100
|
+
provide: InjectionToken<unknown>;
|
|
101
|
+
useValue: unknown;
|
|
102
|
+
}>;
|
|
103
|
+
static createLanguageProviders<T extends readonly Language[]>(options: {
|
|
104
|
+
languages: T;
|
|
105
|
+
defaultLang?: T[number]['code'];
|
|
106
|
+
}): Array<{
|
|
107
|
+
provide: InjectionToken<unknown>;
|
|
108
|
+
useValue: unknown;
|
|
109
|
+
}>;
|
|
110
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TranslationService, never>;
|
|
111
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<TranslationService>;
|
|
112
|
+
}
|
|
Binary file
|