@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.
- package/CHANGELOG.md +102 -0
- package/README.md +641 -163
- package/_index.css +85 -28
- package/components/avatar/src/avatar.component.d.ts +40 -26
- package/components/badge/src/badge.component.d.ts +0 -4
- package/components/button/src/button.component.d.ts +2 -2
- package/components/dialog/dialog-actions/dialog-actions.component.d.ts +8 -0
- package/components/dialog/dialog-content/dialog-content.component.d.ts +5 -0
- package/components/dialog/dialog-sub-title/dialog-sub-title.component.d.ts +5 -0
- package/components/dialog/dialog-title/dialog-title.component.d.ts +5 -0
- package/components/dialog/index.d.ts +5 -0
- package/components/dialog/public-api.d.ts +5 -0
- package/components/dialog/src/dialog.component.d.ts +132 -0
- 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/directives/auto-focus/src/autofocus.directive.d.ts +3 -3
- 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-badge.mjs +1 -1
- package/fesm2022/sixbell-telco-sdk-components-badge.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-dialog.mjs +305 -0
- package/fesm2022/sixbell-telco-sdk-components-dialog.mjs.map +1 -0
- 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 +5 -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-components-toast.mjs +2 -2
- package/fesm2022/sixbell-telco-sdk-components-toast.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-directives-auto-focus.mjs +3 -3
- package/fesm2022/sixbell-telco-sdk-directives-auto-focus.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-utils-theme.mjs +295 -0
- package/fesm2022/sixbell-telco-sdk-utils-theme.mjs.map +1 -0
- package/fesm2022/sixbell-telco-sdk-utils-translation.mjs +332 -0
- package/fesm2022/sixbell-telco-sdk-utils-translation.mjs.map +1 -0
- package/package.json +29 -9
- package/sixbell-telco-sdk-1.2.0.tgz +0 -0
- package/utils/theme/README.md +185 -0
- package/{components/modal → utils/theme}/index.d.ts +1 -1
- package/utils/theme/public-api.d.ts +1 -0
- package/utils/theme/src/theme.service.d.ts +206 -0
- package/utils/translation/README.md +274 -0
- package/utils/translation/index.d.ts +5 -0
- package/utils/translation/public-api.d.ts +5 -0
- package/utils/translation/src/translation.service.d.ts +197 -0
- package/components/modal/modal-actions/modal-actions.component.d.ts +0 -8
- package/components/modal/modal-content/modal-content.component.d.ts +0 -5
- package/components/modal/modal-title/modal-title.component.d.ts +0 -5
- package/components/modal/public-api.d.ts +0 -4
- package/components/modal/src/modal.component.d.ts +0 -102
- package/fesm2022/sixbell-telco-sdk-components-modal.mjs +0 -202
- package/fesm2022/sixbell-telco-sdk-components-modal.mjs.map +0 -1
- package/sixbell-telco-sdk-1.0.3.tgz +0 -0
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
# Translation Service
|
|
2
|
+
|
|
3
|
+
A modern Angular service for internationalization using ngx-translate with TypeScript IntelliSense support.
|
|
4
|
+
|
|
5
|
+
## What it does
|
|
6
|
+
|
|
7
|
+
The Translation Service provides:
|
|
8
|
+
|
|
9
|
+
- **Internationalization** with ngx-translate integration
|
|
10
|
+
- **TypeScript IntelliSense** for language codes and translation keys
|
|
11
|
+
- **Reactive translation** using Angular signals
|
|
12
|
+
- **Flexible configuration** for additional languages and exclusions
|
|
13
|
+
- **Provider-based setup** for Angular applications
|
|
14
|
+
|
|
15
|
+
## How to use
|
|
16
|
+
|
|
17
|
+
### Basic setup
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
// app.config.ts
|
|
21
|
+
import { provideTranslation } from '@sixbell-telco/sdk/utils/translation';
|
|
22
|
+
|
|
23
|
+
export const appConfig: ApplicationConfig = {
|
|
24
|
+
providers: [
|
|
25
|
+
provideTranslation({
|
|
26
|
+
defaultLang: 'es', // IntelliSense: 'en' | 'es' | 'pt'
|
|
27
|
+
excludeLanguages: ['pt'], // IntelliSense: 'en' | 'es' | 'pt'
|
|
28
|
+
}),
|
|
29
|
+
],
|
|
30
|
+
};
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### With additional languages
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
// app.config.ts
|
|
37
|
+
import { provideTranslation } from '@sixbell-telco/sdk/utils/translation';
|
|
38
|
+
|
|
39
|
+
export const appConfig: ApplicationConfig = {
|
|
40
|
+
providers: [
|
|
41
|
+
provideTranslation({
|
|
42
|
+
additionalLanguages: [
|
|
43
|
+
{ code: 'de', name: 'Deutsch' },
|
|
44
|
+
{ code: 'fr', name: 'Français' },
|
|
45
|
+
{ code: 'it', name: 'Italiano' },
|
|
46
|
+
],
|
|
47
|
+
defaultLang: 'de', // IntelliSense: 'en' | 'es' | 'pt' | 'de' | 'fr' | 'it'
|
|
48
|
+
excludeLanguages: ['pt', 'it'], // IntelliSense: all available languages
|
|
49
|
+
translationPaths: ['/assets/i18n/', '/assets/i18n/sdk/'],
|
|
50
|
+
}),
|
|
51
|
+
],
|
|
52
|
+
};
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Using in components
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
// component.ts
|
|
59
|
+
import { TranslationService } from '@sixbell-telco/sdk/utils/translation';
|
|
60
|
+
|
|
61
|
+
@Component({
|
|
62
|
+
template: `
|
|
63
|
+
<div>
|
|
64
|
+
<p>{{ 'common.welcome' | translate }}</p>
|
|
65
|
+
<p>Current language: {{ translation.getCurrentLanguage() }}</p>
|
|
66
|
+
|
|
67
|
+
<select (change)="changeLanguage($event.target.value)">
|
|
68
|
+
@for (lang of translation.getAvailableLanguagesConfig(); track lang.code) {
|
|
69
|
+
<option [value]="lang.code">{{ lang.name }}</option>
|
|
70
|
+
}
|
|
71
|
+
</select>
|
|
72
|
+
</div>
|
|
73
|
+
`,
|
|
74
|
+
})
|
|
75
|
+
export class MyComponent {
|
|
76
|
+
translation = inject(TranslationService);
|
|
77
|
+
|
|
78
|
+
changeLanguage(langCode: string) {
|
|
79
|
+
this.translation.setLanguage(langCode);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
translateMessage(key: string, params?: any) {
|
|
83
|
+
return this.translation.instant(key, params);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Reactive translations in templates
|
|
89
|
+
|
|
90
|
+
```html
|
|
91
|
+
<!-- Direct translation with ngx-translate pipe -->
|
|
92
|
+
<p>{{ 'common.welcome' | translate }}</p>
|
|
93
|
+
|
|
94
|
+
<!-- Translation with parameters -->
|
|
95
|
+
<p>{{ 'common.greeting' | translate: { name: userName } }}</p>
|
|
96
|
+
|
|
97
|
+
<!-- Async translation -->
|
|
98
|
+
<p>{{ translation.get('common.message') | async }}</p>
|
|
99
|
+
|
|
100
|
+
<!-- Conditional content based on language -->
|
|
101
|
+
@if (translation.getCurrentLanguage() === 'es') {
|
|
102
|
+
<p>Contenido en español</p>
|
|
103
|
+
} @else {
|
|
104
|
+
<p>Content in other language</p>
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Key features
|
|
109
|
+
|
|
110
|
+
- **Signal-based reactivity** - Modern Angular reactive patterns
|
|
111
|
+
- **IntelliSense support** - Full TypeScript autocomplete for language codes
|
|
112
|
+
- **Flexible configuration** - Add languages, exclude unwanted ones
|
|
113
|
+
- **Provider pattern** - Clean Angular dependency injection setup
|
|
114
|
+
- **Automatic persistence** - Saves user preferences to localStorage
|
|
115
|
+
- **ngx-translate integration** - Full compatibility with existing translation workflows
|
|
116
|
+
|
|
117
|
+
## Default languages
|
|
118
|
+
|
|
119
|
+
- `en` (English) - Always available unless excluded
|
|
120
|
+
- `es` (Spanish) - Always available unless excluded
|
|
121
|
+
- `pt` (Portuguese) - Always available unless excluded
|
|
122
|
+
|
|
123
|
+
You can add more languages using `additionalLanguages` or exclude default ones using `excludeLanguages`.
|
|
124
|
+
|
|
125
|
+
## Translation methods
|
|
126
|
+
|
|
127
|
+
The service provides convenient methods for translations:
|
|
128
|
+
|
|
129
|
+
- `instant(key: string, params?: any)` - Get immediate translation
|
|
130
|
+
- `get(key: string, params?: any)` - Get translation as Observable
|
|
131
|
+
- `stream(key: string, params?: any)` - Get translation stream that updates on language changes
|
|
132
|
+
- `setLanguage(langCode: string)` - Change current language
|
|
133
|
+
- `getCurrentLanguage()` - Get current language code
|
|
134
|
+
- `getDefaultLanguage()` - Get default language code
|
|
135
|
+
- `getAvailableLanguagesConfig()` - Get all available language definitions
|
|
136
|
+
- `getAvailableLanguageCodes()` - Get array of available language codes
|
|
137
|
+
- `getLanguageByCode(code: string)` - Get language definition by code
|
|
138
|
+
- `getLanguageDisplayName(code: string)` - Get display name for language code
|
|
139
|
+
|
|
140
|
+
## Configuration options
|
|
141
|
+
|
|
142
|
+
| Property | Type | Description |
|
|
143
|
+
| --------------------- | ------------------------------- | ------------------------------------------------------------------- |
|
|
144
|
+
| `additionalLanguages` | `readonly LanguageDefinition[]` | Additional languages beyond the defaults |
|
|
145
|
+
| `defaultLang` | `string` | Default language to use (with IntelliSense for available languages) |
|
|
146
|
+
| `excludeLanguages` | `readonly string[]` | Languages to exclude from available languages |
|
|
147
|
+
| `translationPaths` | `string[]` | Custom paths for translation files (default: `['/assets/i18n/']`) |
|
|
148
|
+
|
|
149
|
+
## Language definition interface
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
interface LanguageDefinition {
|
|
153
|
+
code: string; // Language code (e.g., 'en', 'es', 'de')
|
|
154
|
+
name: string; // Display name (e.g., 'English', 'Español', 'Deutsch')
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Translation file structure
|
|
159
|
+
|
|
160
|
+
Place your translation files in `/assets/i18n/` with the following structure:
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
src/
|
|
164
|
+
assets/
|
|
165
|
+
i18n/
|
|
166
|
+
en.json
|
|
167
|
+
es.json
|
|
168
|
+
pt.json
|
|
169
|
+
de.json // if using additional languages
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Example translation file (`en.json`):
|
|
173
|
+
|
|
174
|
+
```json
|
|
175
|
+
{
|
|
176
|
+
"common": {
|
|
177
|
+
"welcome": "Welcome",
|
|
178
|
+
"greeting": "Hello {{name}}!",
|
|
179
|
+
"message": "This is a message"
|
|
180
|
+
},
|
|
181
|
+
"navigation": {
|
|
182
|
+
"home": "Home",
|
|
183
|
+
"about": "About",
|
|
184
|
+
"contact": "Contact"
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Advanced usage
|
|
190
|
+
|
|
191
|
+
### Custom translation paths
|
|
192
|
+
|
|
193
|
+
```typescript
|
|
194
|
+
provideTranslation({
|
|
195
|
+
translationPaths: [
|
|
196
|
+
'/assets/i18n/', // Main translations
|
|
197
|
+
'/assets/i18n/modules/', // Module-specific translations
|
|
198
|
+
'/assets/i18n/sdk/', // SDK translations
|
|
199
|
+
],
|
|
200
|
+
});
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Programmatic language detection
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
@Component({...})
|
|
207
|
+
export class LanguageDetectorComponent {
|
|
208
|
+
translation = inject(TranslationService);
|
|
209
|
+
|
|
210
|
+
ngOnInit() {
|
|
211
|
+
// Detect browser language
|
|
212
|
+
const browserLang = navigator.language.split('-')[0];
|
|
213
|
+
const availableCodes = this.translation.getAvailableLanguageCodes();
|
|
214
|
+
|
|
215
|
+
if (availableCodes.includes(browserLang)) {
|
|
216
|
+
this.translation.setLanguage(browserLang);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Reactive language switching
|
|
223
|
+
|
|
224
|
+
```typescript
|
|
225
|
+
@Component({
|
|
226
|
+
template: `
|
|
227
|
+
<div class="language-switcher">
|
|
228
|
+
@for (lang of availableLanguages; track lang.code) {
|
|
229
|
+
<button [class.active]="lang.code === currentLanguage" (click)="switchLanguage(lang.code)">
|
|
230
|
+
{{ lang.name }}
|
|
231
|
+
</button>
|
|
232
|
+
}
|
|
233
|
+
</div>
|
|
234
|
+
`,
|
|
235
|
+
})
|
|
236
|
+
export class LanguageSwitcherComponent {
|
|
237
|
+
translation = inject(TranslationService);
|
|
238
|
+
|
|
239
|
+
availableLanguages = this.translation.getAvailableLanguagesConfig();
|
|
240
|
+
currentLanguage = this.translation.getCurrentLanguage();
|
|
241
|
+
|
|
242
|
+
switchLanguage(langCode: string) {
|
|
243
|
+
this.translation.setLanguage(langCode);
|
|
244
|
+
this.currentLanguage = this.translation.getCurrentLanguage();
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## What's included automatically
|
|
250
|
+
|
|
251
|
+
The `provideTranslation()` provider automatically configures:
|
|
252
|
+
|
|
253
|
+
- ✅ `TranslateService` from `@ngx-translate/core`
|
|
254
|
+
- ✅ `TranslateHttpLoader` with configurable paths
|
|
255
|
+
- ✅ All necessary ngx-translate providers
|
|
256
|
+
- ✅ Automatic service initialization for MFE compatibility
|
|
257
|
+
- ✅ Browser environment safety checks
|
|
258
|
+
|
|
259
|
+
## Available components
|
|
260
|
+
|
|
261
|
+
All useful ngx-translate components are automatically available for import:
|
|
262
|
+
|
|
263
|
+
```typescript
|
|
264
|
+
import {
|
|
265
|
+
TranslatePipe,
|
|
266
|
+
TranslateDirective,
|
|
267
|
+
TranslateService,
|
|
268
|
+
// ... all other ngx-translate exports
|
|
269
|
+
} from '@sixbell-telco/sdk/utils/translation';
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## Language persistence
|
|
273
|
+
|
|
274
|
+
User language preferences are automatically saved to localStorage and restored on app initialization. No additional setup required.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export * from './src/translation.service';
|
|
2
|
+
export { DefaultLangChangeEvent, FakeMissingTranslationHandler, LangChangeEvent, MissingTranslationHandler, TranslateCompiler, TranslateDefaultParser, TranslateDirective, TranslateFakeCompiler, TranslateLoader, TranslateModule, TranslateParser, TranslatePipe, TranslateService, TranslateStore, TranslationChangeEvent, provideTranslateService, } from '@ngx-translate/core';
|
|
3
|
+
export { TranslateHttpLoader } from '@ngx-translate/http-loader';
|
|
4
|
+
export { MultiTranslateHttpLoader } from 'ngx-translate-multi-http-loader';
|
|
5
|
+
export { HttpBackend } from '@angular/common/http';
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { HttpBackend, HttpClient } from '@angular/common/http';
|
|
2
|
+
import { EnvironmentProviders, InjectionToken, Provider } from '@angular/core';
|
|
3
|
+
import { MissingTranslationHandler, MissingTranslationHandlerParams } from '@ngx-translate/core';
|
|
4
|
+
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
|
|
5
|
+
import { MultiTranslateHttpLoader } from 'ngx-translate-multi-http-loader';
|
|
6
|
+
import * as i0 from "@angular/core";
|
|
7
|
+
/**
|
|
8
|
+
* Language definition interface
|
|
9
|
+
*/
|
|
10
|
+
export interface LanguageDefinition {
|
|
11
|
+
/** Language code (ISO 639-1 format recommended) */
|
|
12
|
+
code: string;
|
|
13
|
+
/** Display name for the language */
|
|
14
|
+
name: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Helper function to create a language definition with full type safety and IntelliSense
|
|
18
|
+
*/
|
|
19
|
+
export declare function createLanguage(config: LanguageDefinition): LanguageDefinition;
|
|
20
|
+
export declare const DEFAULT_LANGUAGES: readonly LanguageDefinition[];
|
|
21
|
+
export declare const DEFAULT_LANGUAGE_CODE = "en";
|
|
22
|
+
export declare const DEFAULT_LANGUAGE_CODES: readonly ["en", "es", "pt"];
|
|
23
|
+
export type DefaultLanguageCode = (typeof DEFAULT_LANGUAGE_CODES)[number];
|
|
24
|
+
type ExtractLanguageCode<T> = T extends readonly (infer U)[] ? (U extends LanguageDefinition ? U['code'] : never) : never;
|
|
25
|
+
export declare class PlaceholderMissingTranslationHandler implements MissingTranslationHandler {
|
|
26
|
+
handle(params: MissingTranslationHandlerParams): string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Main translation configuration interface
|
|
30
|
+
*/
|
|
31
|
+
export interface TranslationConfig {
|
|
32
|
+
/**
|
|
33
|
+
* Additional languages to make available beyond the default base languages (en, es, pt)
|
|
34
|
+
* When you add languages here, they become available in defaultLang and excludeLanguages
|
|
35
|
+
* @example [{ code: 'de', name: 'Deutsch' }, { code: 'fr', name: 'Français' }]
|
|
36
|
+
*/
|
|
37
|
+
additionalLanguages?: readonly LanguageDefinition[];
|
|
38
|
+
/**
|
|
39
|
+
* Languages to exclude from the available set
|
|
40
|
+
* IntelliSense includes: base languages (en, es, pt) + any additionalLanguages you specified above
|
|
41
|
+
* @example ['pt'] to exclude Portuguese
|
|
42
|
+
*/
|
|
43
|
+
excludeLanguages?: readonly string[];
|
|
44
|
+
/**
|
|
45
|
+
* Default language code
|
|
46
|
+
* IntelliSense includes: base languages (en, es, pt) + any additionalLanguages you specified above
|
|
47
|
+
* @example 'en'
|
|
48
|
+
*/
|
|
49
|
+
defaultLang?: string;
|
|
50
|
+
/** Translation file paths */
|
|
51
|
+
translationPaths?: string[];
|
|
52
|
+
}
|
|
53
|
+
export declare const TRANSLATION_CONFIG_TOKEN: InjectionToken<TranslationConfig>;
|
|
54
|
+
/**
|
|
55
|
+
* Factory function to create HTTP loader for translations with custom paths
|
|
56
|
+
*/
|
|
57
|
+
export declare function HttpLoaderFactory(http: HttpClient): TranslateHttpLoader;
|
|
58
|
+
/**
|
|
59
|
+
* Factory function to create multi-path HTTP loader for translations
|
|
60
|
+
*/
|
|
61
|
+
export declare function MultiPathHttpLoaderFactory(httpBackend: HttpBackend, paths: string[]): MultiTranslateHttpLoader;
|
|
62
|
+
/**
|
|
63
|
+
* Utility function to extend default languages with additional ones
|
|
64
|
+
*/
|
|
65
|
+
export declare function extendDefaultLanguages(additionalLanguages: LanguageDefinition[]): LanguageDefinition[];
|
|
66
|
+
export declare class TranslationService {
|
|
67
|
+
private readonly translationConfig?;
|
|
68
|
+
private readonly translate;
|
|
69
|
+
private readonly document;
|
|
70
|
+
private initialized;
|
|
71
|
+
private config;
|
|
72
|
+
constructor(translationConfig?: TranslationConfig | undefined);
|
|
73
|
+
/**
|
|
74
|
+
* Configure and initialize the translation service (used by provider)
|
|
75
|
+
*/
|
|
76
|
+
configure(config?: TranslationConfig): void;
|
|
77
|
+
/**
|
|
78
|
+
* Initialize translation from localStorage and apply it immediately
|
|
79
|
+
*/
|
|
80
|
+
private initializeFromStorage;
|
|
81
|
+
/**
|
|
82
|
+
* Apply the current language to the translate service and document
|
|
83
|
+
*/
|
|
84
|
+
private applyLanguage;
|
|
85
|
+
/**
|
|
86
|
+
* Set the current language and persist to localStorage
|
|
87
|
+
*/
|
|
88
|
+
setLanguage(lang: string): void;
|
|
89
|
+
/**
|
|
90
|
+
* Get the current language from localStorage or default
|
|
91
|
+
*/
|
|
92
|
+
getCurrentLanguage(): string;
|
|
93
|
+
/**
|
|
94
|
+
* Get the current HTML lang attribute
|
|
95
|
+
*/
|
|
96
|
+
getCurrentHtmlLanguage(): string;
|
|
97
|
+
/**
|
|
98
|
+
* Get available languages
|
|
99
|
+
*/
|
|
100
|
+
getAvailableLanguages(): string[];
|
|
101
|
+
/**
|
|
102
|
+
* Get default language
|
|
103
|
+
*/
|
|
104
|
+
getDefaultLanguage(): string;
|
|
105
|
+
/**
|
|
106
|
+
* Instantly translate a key with optional parameters
|
|
107
|
+
*/
|
|
108
|
+
instant(key: string, params?: object | undefined): string;
|
|
109
|
+
/**
|
|
110
|
+
* Get observable translation for a key
|
|
111
|
+
*/
|
|
112
|
+
get(key: string, params?: object | undefined): import("rxjs").Observable<any>;
|
|
113
|
+
/**
|
|
114
|
+
* Get stream of translations for a key
|
|
115
|
+
*/
|
|
116
|
+
stream(key: string, params?: object | undefined): import("rxjs").Observable<any>;
|
|
117
|
+
/**
|
|
118
|
+
* Get available languages configuration
|
|
119
|
+
*/
|
|
120
|
+
getAvailableLanguagesConfig(): LanguageDefinition[];
|
|
121
|
+
/**
|
|
122
|
+
* Get available language codes
|
|
123
|
+
*/
|
|
124
|
+
getAvailableLanguageCodes(): string[];
|
|
125
|
+
/**
|
|
126
|
+
* Get language configuration by code
|
|
127
|
+
*/
|
|
128
|
+
getLanguageByCode(code: string): LanguageDefinition | undefined;
|
|
129
|
+
/**
|
|
130
|
+
* Get language display name by code
|
|
131
|
+
*/
|
|
132
|
+
getLanguageDisplayName(code: string): string;
|
|
133
|
+
/**
|
|
134
|
+
* Get localized language name by code using translations
|
|
135
|
+
* This automatically returns the localized name based on the current language
|
|
136
|
+
*/
|
|
137
|
+
getLocalizedLanguageName(code: string): string;
|
|
138
|
+
/**
|
|
139
|
+
* Force initialization method for MFE environments
|
|
140
|
+
*/
|
|
141
|
+
init(): void;
|
|
142
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TranslationService, [{ optional: true; }]>;
|
|
143
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<TranslationService>;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Provider function for translation configuration in Angular applications
|
|
147
|
+
* This provides the translation configuration through dependency injection
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* ```typescript
|
|
151
|
+
* // Basic usage - only default languages available (en, es, pt)
|
|
152
|
+
* provideTranslation({
|
|
153
|
+
* defaultLang: 'es' // IntelliSense shows: 'en', 'es', 'pt'
|
|
154
|
+
* }),
|
|
155
|
+
*
|
|
156
|
+
* // With additional languages - IntelliSense includes base + additional languages
|
|
157
|
+
* provideTranslation({
|
|
158
|
+
* additionalLanguages: [
|
|
159
|
+
* { code: 'de', name: 'Deutsch' },
|
|
160
|
+
* { code: 'fr', name: 'Français' }
|
|
161
|
+
* ] as const,
|
|
162
|
+
* defaultLang: 'de', // IntelliSense shows: 'en', 'es', 'pt', 'de', 'fr'
|
|
163
|
+
* excludeLanguages: ['pt'] as const // IntelliSense shows: 'en', 'es', 'pt', 'de', 'fr'
|
|
164
|
+
* })
|
|
165
|
+
* ```
|
|
166
|
+
*/
|
|
167
|
+
export declare function provideTranslation(): (Provider | EnvironmentProviders)[];
|
|
168
|
+
export declare function provideTranslation(config: {
|
|
169
|
+
/**
|
|
170
|
+
* Default language code (from base languages: en, es, pt)
|
|
171
|
+
*/
|
|
172
|
+
defaultLang?: DefaultLanguageCode;
|
|
173
|
+
/**
|
|
174
|
+
* Languages to exclude from the default base languages (en, es, pt)
|
|
175
|
+
*/
|
|
176
|
+
excludeLanguages?: readonly DefaultLanguageCode[];
|
|
177
|
+
/** Translation file paths */
|
|
178
|
+
translationPaths?: string[];
|
|
179
|
+
additionalLanguages?: never;
|
|
180
|
+
}): (Provider | EnvironmentProviders)[];
|
|
181
|
+
export declare function provideTranslation<const T extends readonly LanguageDefinition[]>(config: {
|
|
182
|
+
/**
|
|
183
|
+
* Additional languages to make available beyond the default base languages (en, es, pt)
|
|
184
|
+
*/
|
|
185
|
+
additionalLanguages: T;
|
|
186
|
+
/**
|
|
187
|
+
* Default language code (includes both base and additional languages)
|
|
188
|
+
*/
|
|
189
|
+
defaultLang?: DefaultLanguageCode | ExtractLanguageCode<T>;
|
|
190
|
+
/**
|
|
191
|
+
* Languages to exclude from the available set (includes both base and additional languages)
|
|
192
|
+
*/
|
|
193
|
+
excludeLanguages?: readonly (DefaultLanguageCode | ExtractLanguageCode<T>)[];
|
|
194
|
+
/** Translation file paths */
|
|
195
|
+
translationPaths?: string[];
|
|
196
|
+
}): (Provider | EnvironmentProviders)[];
|
|
197
|
+
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import * as i0 from "@angular/core";
|
|
2
|
-
export type ModalActionsAligmentProps = 'left' | 'right' | 'center';
|
|
3
|
-
export declare class ModalActionsComponent {
|
|
4
|
-
alignment: import("@angular/core").InputSignal<ModalActionsAligmentProps>;
|
|
5
|
-
componentClass: import("@angular/core").Signal<string>;
|
|
6
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<ModalActionsComponent, never>;
|
|
7
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<ModalActionsComponent, "st-modal-actions", never, { "alignment": { "alias": "alignment"; "required": false; "isSignal": true; }; }, {}, never, ["*"], true, never>;
|
|
8
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import * as i0 from "@angular/core";
|
|
2
|
-
export declare class ModalContentComponent {
|
|
3
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<ModalContentComponent, never>;
|
|
4
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<ModalContentComponent, "st-modal-content", never, {}, {}, never, ["*"], true, never>;
|
|
5
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import * as i0 from "@angular/core";
|
|
2
|
-
export declare class ModalTitleComponent {
|
|
3
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<ModalTitleComponent, never>;
|
|
4
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<ModalTitleComponent, "st-modal-title", never, {}, {}, never, ["*"], true, never>;
|
|
5
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { ElementRef } from '@angular/core';
|
|
2
|
-
import * as i0 from "@angular/core";
|
|
3
|
-
/**
|
|
4
|
-
* CSS class generator for modal component variants
|
|
5
|
-
* @internal
|
|
6
|
-
*/
|
|
7
|
-
export declare const modalComponent: (props?: ({
|
|
8
|
-
width?: "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | null | undefined;
|
|
9
|
-
aligment?: "center" | "top" | "bottom" | "start" | "end" | null | undefined;
|
|
10
|
-
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
11
|
-
/** Possible width values for the modal component */
|
|
12
|
-
export type ModalWidthProps = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' | '5xl' | null | undefined;
|
|
13
|
-
/** Possible vertical alignment values for the modal component */
|
|
14
|
-
export type ModalAlignmentProps = 'top' | 'center' | 'bottom' | 'start' | 'end' | null | undefined;
|
|
15
|
-
/** Configuration properties for the modal component */
|
|
16
|
-
export type ModalProps = {
|
|
17
|
-
width?: ModalWidthProps;
|
|
18
|
-
alignment?: ModalAlignmentProps;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* A customizable modal dialog component with Tailwind CSS integration
|
|
22
|
-
*
|
|
23
|
-
* @remarks
|
|
24
|
-
* Uses Angular's signal-based inputs and outputs for reactive state management.
|
|
25
|
-
* Supports various sizes and vertical alignments through input properties.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```html
|
|
29
|
-
* <st-modal
|
|
30
|
-
* modalId="confirmDialog"
|
|
31
|
-
* [(opened)]="isOpen"
|
|
32
|
-
* width="lg"
|
|
33
|
-
* alignment="top"
|
|
34
|
-
* (close)="handleClose()"
|
|
35
|
-
* (clickOutside)="handleClickOustide()"
|
|
36
|
-
* />
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
export declare class ModalComponent {
|
|
40
|
-
/**
|
|
41
|
-
* Specifies the maximum width of the modal content
|
|
42
|
-
* @defaultValue 'md'
|
|
43
|
-
*/
|
|
44
|
-
width: import("@angular/core").InputSignal<ModalWidthProps>;
|
|
45
|
-
/**
|
|
46
|
-
* Controls the vertical positioning of the modal
|
|
47
|
-
* @defaultValue 'center'
|
|
48
|
-
*/
|
|
49
|
-
alignment: import("@angular/core").InputSignal<ModalAlignmentProps>;
|
|
50
|
-
/** Required unique identifier for the modal dialog */
|
|
51
|
-
modalId: import("@angular/core").InputSignal<string>;
|
|
52
|
-
/** Event emitted when clicking outside the modal content */
|
|
53
|
-
clickOutside: import("@angular/core").OutputEmitterRef<void>;
|
|
54
|
-
/** Event emitted when the modal closes */
|
|
55
|
-
closed: import("@angular/core").OutputEmitterRef<void>;
|
|
56
|
-
/** @internal Icon reference for close button */
|
|
57
|
-
iconClose: string;
|
|
58
|
-
/** @internal Reference to the underlying dialog element */
|
|
59
|
-
dialog: import("@angular/core").Signal<ElementRef<HTMLDialogElement> | undefined>;
|
|
60
|
-
/**
|
|
61
|
-
* Controls the visibility state of the modal
|
|
62
|
-
* Supports two-way binding via Angular's model
|
|
63
|
-
*/
|
|
64
|
-
opened: import("@angular/core").ModelSignal<boolean>;
|
|
65
|
-
/** @internal Handles open/close state changes */
|
|
66
|
-
openedEffect: import("@angular/core").EffectRef;
|
|
67
|
-
/**
|
|
68
|
-
* Computes CSS classes for modal content based on current configuration
|
|
69
|
-
* @returns Combined Tailwind classes string
|
|
70
|
-
* @internal
|
|
71
|
-
*/
|
|
72
|
-
componentClass: import("@angular/core").Signal<string>;
|
|
73
|
-
/**
|
|
74
|
-
* Computes CSS classes for modal overlay positioning
|
|
75
|
-
* @returns Combined positioning classes string
|
|
76
|
-
* @internal
|
|
77
|
-
*/
|
|
78
|
-
modalClass: import("@angular/core").Signal<string>;
|
|
79
|
-
/** @internal Opens the native dialog element */
|
|
80
|
-
handleOpen(): void;
|
|
81
|
-
/** @internal Closes the native dialog element */
|
|
82
|
-
handleClose(): void;
|
|
83
|
-
/**
|
|
84
|
-
* Public method to close the modal and emit close event
|
|
85
|
-
* Can be called directly from parent components
|
|
86
|
-
*/
|
|
87
|
-
handleCloseClick(): void;
|
|
88
|
-
/**
|
|
89
|
-
* Handles cancel events from the dialog element
|
|
90
|
-
* @param event - Native dialog cancel event
|
|
91
|
-
* @internal
|
|
92
|
-
*/
|
|
93
|
-
handleCancelClick(event: Event): void;
|
|
94
|
-
/**
|
|
95
|
-
* Handles click events outside the modal content
|
|
96
|
-
* @param event - Native mouse event
|
|
97
|
-
* @internal
|
|
98
|
-
*/
|
|
99
|
-
handleClickOutside(event: Event): void;
|
|
100
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<ModalComponent, never>;
|
|
101
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<ModalComponent, "st-modal", never, { "width": { "alias": "width"; "required": false; "isSignal": true; }; "alignment": { "alias": "alignment"; "required": false; "isSignal": true; }; "modalId": { "alias": "modalId"; "required": true; "isSignal": true; }; "opened": { "alias": "opened"; "required": false; "isSignal": true; }; }, { "clickOutside": "clickOutside"; "closed": "closed"; "opened": "openedChange"; }, never, ["st-modal-title", "st-modal-content", "st-modal-actions"], true, never>;
|
|
102
|
-
}
|