valtech-components 2.0.276 → 2.0.278

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 (26) hide show
  1. package/README.md +149 -6
  2. package/esm2022/lib/components/_examples/global-content-example-content.mjs +23 -0
  3. package/esm2022/lib/components/_examples/global-content-example.component.mjs +504 -0
  4. package/esm2022/lib/components/_examples/reactive-content-example-content.mjs +43 -0
  5. package/esm2022/lib/components/_examples/reactive-content-example.component.mjs +347 -0
  6. package/esm2022/lib/components/atoms/text/text.component.mjs +143 -15
  7. package/esm2022/lib/components/atoms/text/types.mjs +1 -1
  8. package/esm2022/lib/services/content.service.mjs +327 -0
  9. package/esm2022/lib/services/icons.service.mjs +3 -2
  10. package/esm2022/lib/services/lang-provider/content.mjs +136 -1
  11. package/esm2022/lib/services/lang-provider/lang-provider.service.mjs +118 -8
  12. package/esm2022/lib/shared/utils/content.mjs +186 -0
  13. package/esm2022/public-api.mjs +11 -5
  14. package/fesm2022/valtech-components.mjs +2938 -1359
  15. package/fesm2022/valtech-components.mjs.map +1 -1
  16. package/lib/components/_examples/global-content-example-content.d.ts +9 -0
  17. package/lib/components/_examples/global-content-example.component.d.ts +73 -0
  18. package/lib/components/_examples/reactive-content-example-content.d.ts +32 -0
  19. package/lib/components/_examples/reactive-content-example.component.d.ts +47 -0
  20. package/lib/components/atoms/text/text.component.d.ts +57 -8
  21. package/lib/components/atoms/text/types.d.ts +26 -5
  22. package/lib/services/content.service.d.ts +296 -0
  23. package/lib/services/lang-provider/lang-provider.service.d.ts +87 -7
  24. package/lib/shared/utils/content.d.ts +199 -0
  25. package/package.json +1 -1
  26. package/public-api.d.ts +9 -4
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Content configuration for the Global Content Example component.
3
+ *
4
+ * This demonstrates component-specific content that works alongside
5
+ * global content to create a comprehensive content management system.
6
+ */
7
+ import { TextContent } from '../../services/lang-provider/types';
8
+ declare const _default: TextContent;
9
+ export default _default;
@@ -0,0 +1,73 @@
1
+ import { TextMetadata } from '../atoms/text/types';
2
+ import * as i0 from "@angular/core";
3
+ /**
4
+ * Comprehensive example demonstrating global content usage.
5
+ *
6
+ * This component shows:
7
+ * 1. Global button texts
8
+ * 2. Global state messages
9
+ * 3. Global confirmations with interpolation
10
+ * 4. Mixing global and component-specific content
11
+ * 5. Language switching
12
+ */
13
+ export declare class GlobalContentExampleComponent {
14
+ private content;
15
+ private componentContent;
16
+ formData: {
17
+ name: string;
18
+ email: string;
19
+ message: string;
20
+ };
21
+ actionPerformed: boolean;
22
+ titleProps: TextMetadata;
23
+ languageLabel: TextMetadata;
24
+ componentDescriptionProps: TextMetadata;
25
+ saveButton$: import("rxjs").Observable<string>;
26
+ editButton$: import("rxjs").Observable<string>;
27
+ deleteButton$: import("rxjs").Observable<string>;
28
+ cancelButton$: import("rxjs").Observable<string>;
29
+ backButton$: import("rxjs").Observable<string>;
30
+ nextButton$: import("rxjs").Observable<string>;
31
+ okButton$: import("rxjs").Observable<string>;
32
+ closeButton$: import("rxjs").Observable<string>;
33
+ addButton$: import("rxjs").Observable<string>;
34
+ removeButton$: import("rxjs").Observable<string>;
35
+ searchButton$: import("rxjs").Observable<string>;
36
+ filterButton$: import("rxjs").Observable<string>;
37
+ sortButton$: import("rxjs").Observable<string>;
38
+ refreshButton$: import("rxjs").Observable<string>;
39
+ loadingText$: import("rxjs").Observable<string>;
40
+ successText$: import("rxjs").Observable<string>;
41
+ errorText$: import("rxjs").Observable<string>;
42
+ warningText$: import("rxjs").Observable<string>;
43
+ infoText$: import("rxjs").Observable<string>;
44
+ noDataText$: import("rxjs").Observable<string>;
45
+ requiredText$: import("rxjs").Observable<string>;
46
+ optionalText$: import("rxjs").Observable<string>;
47
+ searchPlaceholder$: import("rxjs").Observable<string>;
48
+ deleteConfirmation$: import("rxjs").Observable<string>;
49
+ areYouSureText$: import("rxjs").Observable<string>;
50
+ unsavedChangesText$: import("rxjs").Observable<string>;
51
+ /**
52
+ * Set language
53
+ */
54
+ setLanguage(lang: 'es' | 'en'): void;
55
+ /**
56
+ * Perform an action to demonstrate status messages
57
+ */
58
+ performAction(): void;
59
+ /**
60
+ * Cancel action
61
+ */
62
+ cancelAction(): void;
63
+ /**
64
+ * Example of synchronous global content access
65
+ */
66
+ getOkTextSync(): string;
67
+ /**
68
+ * Example of synchronous global content access using getText
69
+ */
70
+ getCancelTextSync(): string;
71
+ static ɵfac: i0.ɵɵFactoryDeclaration<GlobalContentExampleComponent, never>;
72
+ static ɵcmp: i0.ɵɵComponentDeclaration<GlobalContentExampleComponent, "val-global-content-example", never, {}, {}, never, never, true, never>;
73
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Example content configuration for demonstrating the reactive content system.
3
+ *
4
+ * This file shows how to structure content for components that use the reactive
5
+ * language system with the new fromContent pattern.
6
+ */
7
+ import { TextContent } from '../../services/lang-provider/types';
8
+ declare const _default: TextContent;
9
+ export default _default;
10
+ /**
11
+ * Type-safe content keys for the example component.
12
+ * Use this interface to ensure type safety when accessing content keys.
13
+ */
14
+ export interface ExampleComponentContentKeys {
15
+ title: string;
16
+ subtitle: string;
17
+ description: string;
18
+ greeting: string;
19
+ welcomeMessage: string;
20
+ dynamicText: string;
21
+ buttonText: string;
22
+ loadingText: string;
23
+ errorMessage: string;
24
+ successMessage: string;
25
+ confirmDialog: string;
26
+ cancelButton: string;
27
+ acceptButton: string;
28
+ }
29
+ /**
30
+ * Utility type for getting content keys with type safety.
31
+ */
32
+ export type ExampleContentKey = keyof ExampleComponentContentKeys;
@@ -0,0 +1,47 @@
1
+ import { OnInit } from '@angular/core';
2
+ import { Observable } from 'rxjs';
3
+ import { ContentService } from '../../services/content.service';
4
+ import { LangOption } from '../../services/lang-provider/types';
5
+ import { TextMetadata } from '../atoms/text/types';
6
+ import * as i0 from "@angular/core";
7
+ export declare class ReactiveContentExampleComponent implements OnInit {
8
+ content: ContentService;
9
+ componentContent: {
10
+ get: (key: string, options?: {
11
+ fallback?: string;
12
+ interpolation?: Record<string, string | number>;
13
+ }) => Observable<string>;
14
+ getWithInterpolation: (key: string, interpolation: Record<string, string | number>, fallback?: string) => Observable<string>;
15
+ getMultiple: (keys: string[]) => Observable<Record<string, string>>;
16
+ getText: (key: string, fallback?: string) => string;
17
+ hasContent: (key: string) => boolean;
18
+ };
19
+ currentLanguage$: Observable<LangOption>;
20
+ buttonText$: Observable<string>;
21
+ saveButton$: Observable<string>;
22
+ cancelButton$: Observable<string>;
23
+ deleteButton$: Observable<string>;
24
+ okButton$: Observable<string>;
25
+ deleteConfirmationText$: Observable<string>;
26
+ loadingText$: Observable<string>;
27
+ showConfirmation: boolean;
28
+ titleProps: TextMetadata;
29
+ greetingProps: TextMetadata;
30
+ multipleContent$: Observable<Record<string, string>>;
31
+ constructor();
32
+ ngOnInit(): void;
33
+ /**
34
+ * Toggle between Spanish and English
35
+ */
36
+ toggleLanguage(): void;
37
+ /**
38
+ * Show delete confirmation dialog
39
+ */
40
+ showDeleteConfirmation(): void;
41
+ /**
42
+ * Hide delete confirmation dialog
43
+ */
44
+ hideDeleteConfirmation(): void;
45
+ static ɵfac: i0.ɵɵFactoryDeclaration<ReactiveContentExampleComponent, never>;
46
+ static ɵcmp: i0.ɵɵComponentDeclaration<ReactiveContentExampleComponent, "val-reactive-content-example", never, {}, {}, never, never, true, never>;
47
+ }
@@ -1,18 +1,67 @@
1
- import { OnInit } from '@angular/core';
2
- import { TextMetadata } from './types';
1
+ import { OnDestroy, OnInit } from '@angular/core';
2
+ import { Observable } from 'rxjs';
3
+ import { ContentService } from '../../../services/content.service';
4
+ import { TextContentConfig, TextMetadata } from './types';
3
5
  import * as i0 from "@angular/core";
4
- export declare class TextComponent implements OnInit {
6
+ export declare class TextComponent implements OnInit, OnDestroy {
7
+ private contentService;
5
8
  /**
6
9
  * Text configuration object.
7
10
  * @type {TextMetadata}
8
- * @property content - The text to display.
9
- * @property color - The text color (Ionic color string).
10
- * @property size - The text size ('small' | 'medium' | 'large' | 'xlarge').
11
- * @property bold - Whether the text is bold.
11
+ *
12
+ * For static content:
13
+ * @property content - The text to display (takes precedence over reactive content)
14
+ *
15
+ * For reactive content:
16
+ * @property contentKey - The content key to retrieve from language service
17
+ * @property contentClass - The component class name for content lookup
18
+ * @property contentFallback - Optional fallback text if content is not found
19
+ * @property contentInterpolation - Optional values to interpolate into content
20
+ *
21
+ * For styling:
22
+ * @property color - The text color (Ionic color string)
23
+ * @property size - The text size ('small' | 'medium' | 'large' | 'xlarge')
24
+ * @property bold - Whether the text is bold
12
25
  */
13
26
  props: TextMetadata;
14
- constructor();
27
+ /**
28
+ * Observable that provides the content to display.
29
+ * This will be either static content or reactive content from the language service.
30
+ */
31
+ displayContent$: Observable<string>;
32
+ private subscription;
33
+ constructor(contentService: ContentService);
15
34
  ngOnInit(): void;
35
+ ngOnDestroy(): void;
36
+ /**
37
+ * Set up the content observable based on the props configuration.
38
+ * Priority: static content > reactive content with interpolation > reactive content
39
+ */
40
+ private setupDisplayContent;
16
41
  static ɵfac: i0.ɵɵFactoryDeclaration<TextComponent, never>;
17
42
  static ɵcmp: i0.ɵɵComponentDeclaration<TextComponent, "val-text", never, { "props": { "alias": "props"; "required": false; }; }, {}, never, never, true, never>;
18
43
  }
44
+ /**
45
+ * Helper function to create reactive text props from content configuration.
46
+ * This provides a convenient way to create val-text props with reactive content.
47
+ *
48
+ * @param contentConfig - Content configuration
49
+ * @param styleConfig - Optional style configuration
50
+ * @returns Partial TextMetadata with content properties set
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * // In component
55
+ * titleProps: TextMetadata = {
56
+ * ...createTextProps({
57
+ * contentKey: 'title',
58
+ * contentClass: 'HeaderComponent'
59
+ * }, {
60
+ * color: 'primary',
61
+ * size: 'large',
62
+ * bold: true
63
+ * })
64
+ * };
65
+ * ```
66
+ */
67
+ export declare function createTextProps(contentConfig: TextContentConfig, styleConfig?: Partial<Pick<TextMetadata, 'color' | 'size' | 'bold'>>): Partial<TextMetadata>;
@@ -2,14 +2,35 @@ import { Color } from '@ionic/core';
2
2
  /**
3
3
  * Props for val-text component.
4
4
  *
5
- * @property content - The text to display.
6
- * @property color - The text color (Ionic color string).
7
- * @property size - The text size ('small' | 'medium' | 'large' | 'xlarge').
8
- * @property bold - Whether the text is bold.
5
+ * The component supports both static content and reactive content from the language service.
6
+ * Use either `content` for static text or `contentKey` + `contentClass` for reactive text.
7
+ *
8
+ * @property content - Static text to display (takes precedence over contentKey)
9
+ * @property contentKey - Key for dynamic content from language service
10
+ * @property contentClass - Component class name for content lookup (required with contentKey)
11
+ * @property contentFallback - Fallback text if contentKey is not found
12
+ * @property contentInterpolation - Values to interpolate into the content string
13
+ * @property color - The text color (Ionic color string)
14
+ * @property size - The text size ('small' | 'medium' | 'large' | 'xlarge')
15
+ * @property bold - Whether the text is bold
9
16
  */
10
17
  export interface TextMetadata {
11
18
  size: 'small' | 'medium' | 'large' | 'xlarge';
12
19
  color: Color;
13
- content: string;
20
+ content?: string;
14
21
  bold: boolean;
22
+ contentKey?: string;
23
+ contentClass?: string;
24
+ contentFallback?: string;
25
+ contentInterpolation?: Record<string, string | number>;
26
+ }
27
+ /**
28
+ * Configuration for reactive content in val-text component.
29
+ * Use this interface when you only need to specify content-related properties.
30
+ */
31
+ export interface TextContentConfig {
32
+ contentKey: string;
33
+ contentClass: string;
34
+ contentFallback?: string;
35
+ contentInterpolation?: Record<string, string | number>;
15
36
  }
@@ -0,0 +1,296 @@
1
+ import { Observable } from 'rxjs';
2
+ import { ContentConfig, InterpolatedContentConfig } from '../shared/utils/content';
3
+ import { LangService } from './lang-provider/lang-provider.service';
4
+ import { LangOption } from './lang-provider/types';
5
+ import * as i0 from "@angular/core";
6
+ /**
7
+ * ContentService - High-level reactive content management service.
8
+ *
9
+ * This service provides a clean, convenient API for reactive content management
10
+ * without requiring direct interaction with LangService. It acts as a facade
11
+ * that simplifies the most common content operations.
12
+ *
13
+ * @example Basic usage:
14
+ * ```typescript
15
+ * @Component({})
16
+ * export class MyComponent {
17
+ * content = inject(ContentService);
18
+ *
19
+ * title$ = this.content.fromContent({
20
+ * className: 'MyComponent',
21
+ * key: 'title'
22
+ * });
23
+ *
24
+ * constructor() {}
25
+ * }
26
+ * ```
27
+ */
28
+ export declare class ContentService {
29
+ private langService;
30
+ constructor(langService: LangService);
31
+ /**
32
+ * Get current language as an observable stream.
33
+ * Emits whenever the language changes.
34
+ */
35
+ get currentLang$(): Observable<LangOption>;
36
+ /**
37
+ * Get current language synchronously.
38
+ */
39
+ get currentLang(): LangOption;
40
+ /**
41
+ * Set the current language.
42
+ * This will trigger updates in all reactive content.
43
+ *
44
+ * @param lang - The language to set
45
+ */
46
+ setLang(lang: LangOption): void;
47
+ /**
48
+ * Create a reactive content observable from a content key.
49
+ * This is the primary method for reactive content with unified support
50
+ * for both simple content and content with interpolation.
51
+ *
52
+ * @param config - Content configuration with optional interpolation. If className is omitted, searches in global content.
53
+ * @returns Observable that emits the content string and updates on language change
54
+ *
55
+ * @example Simple global content:
56
+ * ```typescript
57
+ * // Searches in global content (no className needed)
58
+ * okButton$ = this.content.fromContent({
59
+ * key: 'ok',
60
+ * fallback: 'OK'
61
+ * });
62
+ * ```
63
+ *
64
+ * @example Component-specific content:
65
+ * ```typescript
66
+ * title$ = this.content.fromContent({
67
+ * className: 'HeaderComponent',
68
+ * key: 'title',
69
+ * fallback: 'Default Title'
70
+ * });
71
+ * ```
72
+ *
73
+ * @example Content with interpolation:
74
+ * ```typescript
75
+ * // Global content with interpolation
76
+ * confirmation$ = this.content.fromContent({
77
+ * key: 'deleteConfirmation',
78
+ * interpolation: { itemName: 'archivo' }
79
+ * });
80
+ *
81
+ * // Component content with interpolation
82
+ * greeting$ = this.content.fromContent({
83
+ * className: 'WelcomeComponent',
84
+ * key: 'greeting',
85
+ * interpolation: { name: 'John', count: 5 }
86
+ * });
87
+ * ```
88
+ */
89
+ fromContent(config: ContentConfig): Observable<string>;
90
+ /**
91
+ * Create a reactive content observable with interpolation support.
92
+ *
93
+ * @deprecated Use fromContent() with interpolation property instead.
94
+ * This method is kept for backward compatibility.
95
+ *
96
+ * @param config - Interpolated content configuration. If className is omitted, searches in global content.
97
+ * @returns Observable that emits the interpolated content string
98
+ *
99
+ * @example Migration:
100
+ * ```typescript
101
+ * // OLD (deprecated):
102
+ * greeting$ = this.content.fromContentWithInterpolation({
103
+ * className: 'WelcomeComponent',
104
+ * key: 'greeting',
105
+ * interpolation: { name: 'John', count: 5 }
106
+ * });
107
+ *
108
+ * // NEW (recommended):
109
+ * greeting$ = this.content.fromContent({
110
+ * className: 'WelcomeComponent',
111
+ * key: 'greeting',
112
+ * interpolation: { name: 'John', count: 5 }
113
+ * });
114
+ * ```
115
+ */
116
+ fromContentWithInterpolation(config: InterpolatedContentConfig | Omit<InterpolatedContentConfig, 'className'>): Observable<string>;
117
+ /**
118
+ * Create multiple reactive content observables at once.
119
+ * Useful when a component needs several content strings.
120
+ *
121
+ * @param className - The component class name
122
+ * @param keys - Array of content keys to retrieve
123
+ * @returns Observable that emits an object with all requested content
124
+ *
125
+ * @example
126
+ * ```typescript
127
+ * content$ = this.content.fromMultipleContent('FormComponent', [
128
+ * 'title', 'submitButton', 'cancelButton'
129
+ * ]);
130
+ *
131
+ * // In template
132
+ * <ng-container *ngIf="content$ | async as content">
133
+ * <h2>{{ content['title'] }}</h2>
134
+ * <button>{{ content['submitButton'] }}</button>
135
+ * <button>{{ content['cancelButton'] }}</button>
136
+ * </ng-container>
137
+ * ```
138
+ */
139
+ fromMultipleContent(className: string, keys: string[]): Observable<Record<string, string>>;
140
+ /**
141
+ * Get a single content string synchronously for the current language.
142
+ *
143
+ * @param className - The component class name. If omitted, searches in global content.
144
+ * @param key - The text key
145
+ * @param fallback - Optional fallback text if key is not found
146
+ * @returns The text string or fallback
147
+ *
148
+ * @example Component-specific:
149
+ * ```typescript
150
+ * const title = this.content.getText('MyComponent', 'title');
151
+ * ```
152
+ *
153
+ * @example Global content:
154
+ * ```typescript
155
+ * const okText = this.content.getText('ok'); // First parameter is the key
156
+ * // or more explicitly:
157
+ * const okText = this.content.getGlobalText('ok');
158
+ * ```
159
+ */
160
+ getText(className: string, key?: string, fallback?: string): string;
161
+ getText(key: string, fallback?: string): string;
162
+ /**
163
+ * Get a single global content string synchronously.
164
+ * This is a convenience method that's equivalent to getText(key, fallback).
165
+ *
166
+ * @param key - The text key
167
+ * @param fallback - Optional fallback text if key is not found
168
+ * @returns The text string or fallback
169
+ *
170
+ * @example
171
+ * ```typescript
172
+ * const okText = this.content.getGlobalText('ok');
173
+ * const cancelText = this.content.getGlobalText('cancel', 'Cancel');
174
+ * ```
175
+ */
176
+ getGlobalText(key: string, fallback?: string): string;
177
+ /**
178
+ * Check if a content key exists for a component.
179
+ *
180
+ * @param className - The component class name
181
+ * @param key - The text key
182
+ * @returns True if the key exists in any language
183
+ *
184
+ * @example
185
+ * ```typescript
186
+ * if (this.content.hasContent('MyComponent', 'optionalText')) {
187
+ * // Show optional content
188
+ * }
189
+ * ```
190
+ */
191
+ hasContent(className: string, key: string): boolean;
192
+ /**
193
+ * Helper function to interpolate values into a content string.
194
+ * Useful for processing content strings manually.
195
+ *
196
+ * @param content - The content string with placeholders
197
+ * @param values - Object with values to interpolate
198
+ * @returns The interpolated string
199
+ *
200
+ * @example
201
+ * ```typescript
202
+ * const result = this.content.interpolate("Hello {name}!", { name: "World" });
203
+ * // Returns: "Hello World!"
204
+ * ```
205
+ */
206
+ interpolate(content: string, values?: Record<string, string | number>): string;
207
+ /**
208
+ * Create a content helper bound to a specific component class.
209
+ * This provides a scoped API for components that need multiple content strings.
210
+ *
211
+ * @param className - The component class name
212
+ * @returns Content helper with methods scoped to the class
213
+ *
214
+ * @example
215
+ * ```typescript
216
+ * export class MyComponent {
217
+ * private contentHelper = this.content.createHelper('MyComponent');
218
+ *
219
+ * ngOnInit() {
220
+ * this.title$ = this.contentHelper.get('title');
221
+ * this.allContent$ = this.contentHelper.getMultiple(['title', 'description']);
222
+ * }
223
+ *
224
+ * constructor(private content: ContentService) {}
225
+ * }
226
+ * ```
227
+ */
228
+ createHelper(className: string): {
229
+ get(key: string, fallback?: string): Observable<string>;
230
+ getMultiple(keys: string[]): Observable<Record<string, string>>;
231
+ getWithInterpolation(key: string, interpolation: Record<string, string | number>, fallback?: string): Observable<string>;
232
+ getText(key: string, fallback?: string): string;
233
+ hasContent(key: string): boolean;
234
+ };
235
+ /**
236
+ * Create a scoped content service for a specific component class.
237
+ * This provides an even more convenient API for components with many content needs.
238
+ *
239
+ * @param className - The component class name
240
+ * @returns Scoped content service
241
+ *
242
+ * @example
243
+ * ```typescript
244
+ * export class MyComponent {
245
+ * private content = inject(ContentService).forComponent('MyComponent');
246
+ *
247
+ * // Simple content
248
+ * title$ = this.content.get('title');
249
+ *
250
+ * // Content with interpolation
251
+ * greeting$ = this.content.get('greeting', {
252
+ * interpolation: { name: 'John' }
253
+ * });
254
+ *
255
+ * // Content with fallback
256
+ * subtitle$ = this.content.get('subtitle', {
257
+ * fallback: 'Default Subtitle'
258
+ * });
259
+ *
260
+ * // Multiple texts
261
+ * allTexts$ = this.content.getMultiple(['title', 'subtitle', 'description']);
262
+ *
263
+ * constructor() {}
264
+ * }
265
+ * ```
266
+ */
267
+ forComponent(className: string): {
268
+ /**
269
+ * Get a single content string reactively for this component.
270
+ * Supports optional interpolation.
271
+ */
272
+ get: (key: string, options?: {
273
+ fallback?: string;
274
+ interpolation?: Record<string, string | number>;
275
+ }) => Observable<string>;
276
+ /**
277
+ * Get content with interpolation for this component.
278
+ * @deprecated Use get() with interpolation option instead.
279
+ */
280
+ getWithInterpolation: (key: string, interpolation: Record<string, string | number>, fallback?: string) => Observable<string>;
281
+ /**
282
+ * Get multiple content strings for this component.
283
+ */
284
+ getMultiple: (keys: string[]) => Observable<Record<string, string>>;
285
+ /**
286
+ * Get a single content string synchronously for this component.
287
+ */
288
+ getText: (key: string, fallback?: string) => string;
289
+ /**
290
+ * Check if a content key exists for this component.
291
+ */
292
+ hasContent: (key: string) => boolean;
293
+ };
294
+ static ɵfac: i0.ɵɵFactoryDeclaration<ContentService, never>;
295
+ static ɵprov: i0.ɵɵInjectableDeclaration<ContentService>;
296
+ }
@@ -1,15 +1,95 @@
1
- import { BehaviorSubject } from 'rxjs';
2
- import { Provider } from './content';
3
- import { LangOption, LanguageText } from './types';
1
+ import { Observable } from 'rxjs';
4
2
  import { ValtechConfig } from '../types';
3
+ import { LangOption, LanguageText } from './types';
5
4
  import * as i0 from "@angular/core";
5
+ /**
6
+ * LangService - Reactive language and content management service.
7
+ *
8
+ * This service provides reactive content management with Observable-based language switching.
9
+ * Components can subscribe to content changes and automatically update when the language changes.
10
+ *
11
+ * @example Basic usage:
12
+ * ```typescript
13
+ * constructor(private langService: LangService) {}
14
+ *
15
+ * // Get current language
16
+ * const currentLang = this.langService.currentLang;
17
+ *
18
+ * // Subscribe to language changes
19
+ * this.langService.currentLang$.subscribe(lang => console.log('Language changed:', lang));
20
+ *
21
+ * // Get static text
22
+ * const text = this.langService.getText('ComponentName', 'textKey');
23
+ *
24
+ * // Get reactive text
25
+ * const text$ = this.langService.getContent('ComponentName', 'textKey');
26
+ * ```
27
+ */
6
28
  export declare class LangService {
7
- content: Provider;
8
- default: LangOption;
9
- selectedLang: BehaviorSubject<LangOption>;
10
- config: ValtechConfig;
29
+ private content;
30
+ private default;
31
+ private selectedLang;
32
+ private config;
11
33
  constructor(config: ValtechConfig);
34
+ /**
35
+ * Observable that emits the current language whenever it changes.
36
+ * Use this to react to language changes in components.
37
+ */
38
+ get currentLang$(): Observable<LangOption>;
39
+ /**
40
+ * Get the current language synchronously.
41
+ */
42
+ get currentLang(): LangOption;
43
+ /**
44
+ * Set the current language and persist it to local storage.
45
+ * This will trigger updates in all components subscribed to reactive content.
46
+ *
47
+ * @param lang - The language to set
48
+ */
49
+ setLang(lang: LangOption): void;
50
+ /**
51
+ * Get all text content for a component class (legacy method for compatibility).
52
+ *
53
+ * @param className - The component class name
54
+ * @returns The language text object for the current language
55
+ * @deprecated Use getText() or getContent() for better type safety
56
+ */
12
57
  Text(className: string): LanguageText;
58
+ /**
59
+ * Get a specific text value synchronously for the current language.
60
+ *
61
+ * @param className - The component class name
62
+ * @param key - The text key
63
+ * @param fallback - Optional fallback text if key is not found
64
+ * @returns The text string or fallback
65
+ */
66
+ getText(className: string, key: string, fallback?: string): string;
67
+ /**
68
+ * Get a reactive Observable for a specific text key that updates when language changes.
69
+ * This is the recommended method for components that need reactive content.
70
+ *
71
+ * @param className - The component class name
72
+ * @param key - The text key
73
+ * @param fallback - Optional fallback text if key is not found
74
+ * @returns Observable that emits the text string whenever language changes
75
+ */
76
+ getContent(className: string, key: string, fallback?: string): Observable<string>;
77
+ /**
78
+ * Get reactive content for multiple keys at once.
79
+ *
80
+ * @param className - The component class name
81
+ * @param keys - Array of text keys to retrieve
82
+ * @returns Observable that emits an object with all requested keys
83
+ */
84
+ getMultipleContent(className: string, keys: string[]): Observable<Record<string, string>>;
85
+ /**
86
+ * Check if a content key exists for a component.
87
+ *
88
+ * @param className - The component class name
89
+ * @param key - The text key
90
+ * @returns True if the key exists in any language
91
+ */
92
+ hasContent(className: string, key: string): boolean;
13
93
  get Lang(): LangOption;
14
94
  set Lang(lang: LangOption);
15
95
  static ɵfac: i0.ɵɵFactoryDeclaration<LangService, never>;