valtech-components 2.0.496 → 2.0.498

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 (35) hide show
  1. package/esm2022/lib/components/molecules/language-selector/language-selector.component.mjs +23 -14
  2. package/esm2022/lib/components/molecules/language-selector/types.mjs +1 -1
  3. package/esm2022/lib/services/auth/auth.service.mjs +16 -3
  4. package/esm2022/lib/services/auth/types.mjs +1 -1
  5. package/esm2022/lib/services/firebase/analytics-types.mjs +7 -0
  6. package/esm2022/lib/services/firebase/types.mjs +1 -1
  7. package/esm2022/lib/services/i18n/config.mjs +50 -0
  8. package/esm2022/lib/services/i18n/i18n.service.mjs +196 -0
  9. package/esm2022/lib/services/i18n/index.mjs +9 -0
  10. package/esm2022/lib/services/i18n/translate.pipe.mjs +50 -0
  11. package/esm2022/lib/services/i18n/types.mjs +14 -0
  12. package/esm2022/lib/services/presets/config.mjs +46 -0
  13. package/esm2022/lib/services/presets/index.mjs +5 -0
  14. package/esm2022/lib/services/presets/preset.service.mjs +104 -0
  15. package/esm2022/lib/services/presets/types.mjs +2 -0
  16. package/esm2022/public-api.mjs +9 -1
  17. package/fesm2022/valtech-components.mjs +526 -54
  18. package/fesm2022/valtech-components.mjs.map +1 -1
  19. package/lib/components/molecules/language-selector/language-selector.component.d.ts +1 -4
  20. package/lib/components/molecules/language-selector/types.d.ts +7 -0
  21. package/lib/services/auth/auth.service.d.ts +4 -2
  22. package/lib/services/auth/types.d.ts +4 -0
  23. package/lib/services/firebase/analytics-types.d.ts +219 -0
  24. package/lib/services/firebase/types.d.ts +11 -0
  25. package/lib/services/i18n/config.d.ts +29 -0
  26. package/lib/services/i18n/i18n.service.d.ts +112 -0
  27. package/lib/services/i18n/index.d.ts +4 -0
  28. package/lib/services/i18n/translate.pipe.d.ts +36 -0
  29. package/lib/services/i18n/types.d.ts +59 -0
  30. package/lib/services/presets/config.d.ts +32 -0
  31. package/lib/services/presets/index.d.ts +3 -0
  32. package/lib/services/presets/preset.service.d.ts +69 -0
  33. package/lib/services/presets/types.d.ts +39 -0
  34. package/package.json +1 -1
  35. package/public-api.d.ts +2 -0
@@ -10,18 +10,15 @@ export declare class LanguageSelectorComponent implements OnInit {
10
10
  /**
11
11
  * Event emitted when the language selection changes.
12
12
  * Emits the selected language code.
13
- * Note: Page will reload after this event.
14
13
  */
15
14
  languageChange: EventEmitter<string>;
16
15
  /** Popover selector configuration */
17
16
  popoverProps: PopoverSelectorMetadata;
18
- private localeService;
17
+ private i18n;
19
18
  /** Default language display names */
20
19
  private readonly defaultLanguageNames;
21
20
  /** Default flag icons for languages */
22
21
  private readonly defaultLanguageFlags;
23
- /** Available languages */
24
- private readonly availableLanguages;
25
22
  constructor();
26
23
  ngOnInit(): void;
27
24
  private initializePopoverProps;
@@ -49,4 +49,11 @@ export interface LanguageSelectorMetadata {
49
49
  disabled?: boolean;
50
50
  /** Custom display names for languages */
51
51
  customLanguageNames?: Record<string, string>;
52
+ /**
53
+ * Force page reload on language change.
54
+ * By default (false), language changes are reactive without reload.
55
+ * Set to true for legacy behavior or if reactive updates don't work.
56
+ * @default false
57
+ */
58
+ forceReload?: boolean;
52
59
  }
@@ -8,6 +8,7 @@ import { AuthStorageService } from './storage.service';
8
8
  import { AuthSyncService } from './sync.service';
9
9
  import { SigninRequest, SigninResponse, SignupRequest, SignupResponse, VerifyEmailRequest, VerifyEmailResponse, ResendCodeRequest, ResendCodeResponse, MFAVerifyResponse, RefreshResponse, GetPermissionsResponse, GetProfileResponse, UpdateProfileRequest, UpdateProfileResponse, MFASetupResponse, MFAConfirmResponse, MFADisableResponse, ForgotPasswordRequest, ForgotPasswordResponse, ResetPasswordRequest, ResetPasswordResponse, SwitchOrgResponse, MFAMethod, AuthError, ValtechAuthConfig, EnableNotificationsResult, NotificationPermissionState, RegisterDeviceResult, TOTPSetupResponse, TOTPVerifySetupResponse, TOTPDisableResponse, RegenerateBackupCodesResponse, BackupCodesCountResponse } from './types';
10
10
  import { FirebaseService, MessagingService } from '../firebase';
11
+ import { I18nService } from '../i18n';
11
12
  import * as i0 from "@angular/core";
12
13
  /**
13
14
  * Servicio principal de autenticación.
@@ -41,9 +42,10 @@ export declare class AuthService implements OnDestroy {
41
42
  private syncService;
42
43
  private firebaseService;
43
44
  private messagingService;
45
+ private i18nService;
44
46
  private refreshTimerId;
45
47
  private syncSubscription;
46
- constructor(config: ValtechAuthConfig, http: HttpClient, router: Router, stateService: AuthStateService, tokenService: TokenService, storageService: AuthStorageService, syncService: AuthSyncService, firebaseService: FirebaseService, messagingService: MessagingService | null);
48
+ constructor(config: ValtechAuthConfig, http: HttpClient, router: Router, stateService: AuthStateService, tokenService: TokenService, storageService: AuthStorageService, syncService: AuthSyncService, firebaseService: FirebaseService, messagingService: MessagingService | null, i18nService: I18nService | null);
47
49
  /** Estado completo de autenticación */
48
50
  readonly state: import("@angular/core").Signal<import("./types").AuthState>;
49
51
  /** Usuario está autenticado */
@@ -275,6 +277,6 @@ export declare class AuthService implements OnDestroy {
275
277
  * Detecta información de la plataforma del dispositivo.
276
278
  */
277
279
  private detectPlatformInfo;
278
- static ɵfac: i0.ɵɵFactoryDeclaration<AuthService, [null, null, null, null, null, null, null, null, { optional: true; }]>;
280
+ static ɵfac: i0.ɵɵFactoryDeclaration<AuthService, [null, null, null, null, null, null, null, null, { optional: true; }, { optional: true; }]>;
279
281
  static ɵprov: i0.ɵɵInjectableDeclaration<AuthService>;
280
282
  }
@@ -249,6 +249,8 @@ export interface SigninResponse {
249
249
  isNewDevice?: boolean;
250
250
  /** ID del dispositivo usado para el login */
251
251
  deviceId?: string;
252
+ /** Idioma preferido del usuario (para sincronizar con i18n) */
253
+ language?: string;
252
254
  }
253
255
  /**
254
256
  * Request para verificar MFA.
@@ -269,6 +271,8 @@ export interface MFAVerifyResponse {
269
271
  tokenType: string;
270
272
  roles?: string[];
271
273
  permissions?: string[];
274
+ /** Idioma preferido del usuario (para sincronizar con i18n) */
275
+ language?: string;
272
276
  }
273
277
  /**
274
278
  * Request para refrescar token.
@@ -0,0 +1,219 @@
1
+ /**
2
+ * Analytics Types
3
+ *
4
+ * Tipos e interfaces para el servicio de Firebase Analytics (GA4).
5
+ */
6
+ /**
7
+ * Configuración de Analytics para ValtechFirebaseConfig
8
+ */
9
+ export interface AnalyticsConfig {
10
+ /** Habilitar tracking automático de page views via Router (default: true) */
11
+ enablePageViewTracking?: boolean;
12
+ /** Habilitar tracking automático de errores via ErrorHandler (default: false) */
13
+ enableErrorTracking?: boolean;
14
+ /** Habilitar integración con auth para userId y userProperties (default: true) */
15
+ enableAuthIntegration?: boolean;
16
+ /** Modo debug: no envía a Firebase, logea a consola (default: false en prod) */
17
+ debugMode?: boolean;
18
+ /** Rutas a excluir del page view tracking (regex patterns) */
19
+ excludeRoutes?: string[];
20
+ /** Consent mode inicial (GDPR) */
21
+ defaultConsent?: ConsentSettings;
22
+ /** Clave de localStorage para persistir consent (default: 'analytics_consent') */
23
+ consentStorageKey?: string;
24
+ /** Propiedades de usuario por defecto */
25
+ defaultUserProperties?: Record<string, string>;
26
+ /** Prefijo para eventos custom (ej: 'myapp_') */
27
+ eventPrefix?: string;
28
+ /** Sampling rate (0.0 - 1.0) para reducir volumen (default: 1.0) */
29
+ samplingRate?: number;
30
+ }
31
+ /**
32
+ * Settings de consentimiento GDPR
33
+ */
34
+ export interface ConsentSettings {
35
+ /** Permite recolección de analytics */
36
+ analytics?: boolean;
37
+ /** Permite personalización de ads */
38
+ advertising?: boolean;
39
+ /** Permite funcionalidad */
40
+ functionality?: boolean;
41
+ /** Permite seguridad */
42
+ security?: boolean;
43
+ }
44
+ /**
45
+ * Estado completo de consentimiento
46
+ */
47
+ export interface ConsentState {
48
+ /** Settings actuales */
49
+ settings: ConsentSettings;
50
+ /** Timestamp de la última actualización */
51
+ updatedAt: Date | null;
52
+ /** Si el usuario ha tomado una decisión explícita */
53
+ hasDecided: boolean;
54
+ }
55
+ /**
56
+ * Nombres de eventos GA4 recomendados + customs
57
+ */
58
+ export type AnalyticsEventName = 'add_payment_info' | 'add_shipping_info' | 'add_to_cart' | 'add_to_wishlist' | 'begin_checkout' | 'purchase' | 'refund' | 'remove_from_cart' | 'view_cart' | 'view_item' | 'view_item_list' | 'generate_lead' | 'login' | 'page_view' | 'screen_view' | 'search' | 'select_content' | 'select_item' | 'select_promotion' | 'share' | 'sign_up' | 'view_promotion' | 'feature_used' | 'preference_changed' | 'onboarding_step' | 'error_occurred' | 'performance_metric' | string;
59
+ /**
60
+ * Parámetros tipados por evento
61
+ */
62
+ export interface AnalyticsEventParams {
63
+ add_to_cart: {
64
+ item_id: string;
65
+ item_name?: string;
66
+ value?: number;
67
+ currency?: string;
68
+ quantity?: number;
69
+ };
70
+ purchase: {
71
+ transaction_id: string;
72
+ value: number;
73
+ currency?: string;
74
+ items?: AnalyticsItem[];
75
+ tax?: number;
76
+ shipping?: number;
77
+ };
78
+ begin_checkout: {
79
+ value?: number;
80
+ currency?: string;
81
+ items?: AnalyticsItem[];
82
+ };
83
+ view_item: {
84
+ item_id: string;
85
+ item_name?: string;
86
+ value?: number;
87
+ currency?: string;
88
+ };
89
+ remove_from_cart: {
90
+ item_id: string;
91
+ item_name?: string;
92
+ value?: number;
93
+ };
94
+ login: {
95
+ method?: string;
96
+ };
97
+ sign_up: {
98
+ method?: string;
99
+ };
100
+ search: {
101
+ search_term: string;
102
+ };
103
+ share: {
104
+ content_type?: string;
105
+ item_id?: string;
106
+ method?: string;
107
+ };
108
+ select_content: {
109
+ content_type: string;
110
+ item_id?: string;
111
+ };
112
+ page_view: {
113
+ page_path?: string;
114
+ page_title?: string;
115
+ page_location?: string;
116
+ };
117
+ screen_view: {
118
+ screen_name: string;
119
+ screen_class?: string;
120
+ };
121
+ feature_used: {
122
+ feature_name: string;
123
+ feature_category?: string;
124
+ };
125
+ preference_changed: {
126
+ preference_name: string;
127
+ old_value?: string;
128
+ new_value?: string;
129
+ };
130
+ onboarding_step: {
131
+ step_number: number;
132
+ step_name?: string;
133
+ };
134
+ error_occurred: {
135
+ error_type: string;
136
+ error_message?: string;
137
+ error_stack?: string;
138
+ context?: string;
139
+ };
140
+ performance_metric: {
141
+ metric_name: string;
142
+ value: number;
143
+ unit?: string;
144
+ };
145
+ [key: string]: Record<string, unknown> | undefined;
146
+ }
147
+ /**
148
+ * Item para eventos de ecommerce
149
+ */
150
+ export interface AnalyticsItem {
151
+ /** ID único del item */
152
+ item_id: string;
153
+ /** Nombre del item */
154
+ item_name: string;
155
+ /** Categoría principal */
156
+ item_category?: string;
157
+ /** Subcategorías */
158
+ item_category2?: string;
159
+ item_category3?: string;
160
+ /** Marca */
161
+ item_brand?: string;
162
+ /** Variante (ej: color, talla) */
163
+ item_variant?: string;
164
+ /** Precio unitario */
165
+ price?: number;
166
+ /** Cantidad */
167
+ quantity?: number;
168
+ /** Moneda ISO 4217 */
169
+ currency?: string;
170
+ /** Posición en lista */
171
+ index?: number;
172
+ /** Cupón aplicado */
173
+ coupon?: string;
174
+ }
175
+ /**
176
+ * Tipo de evento de debug
177
+ */
178
+ export type DebugEventType = 'event' | 'page_view' | 'screen_view' | 'user_property' | 'error' | 'consent' | 'timing';
179
+ /**
180
+ * Evento de debug (solo en debug mode)
181
+ */
182
+ export interface AnalyticsDebugEvent {
183
+ /** Timestamp del evento */
184
+ timestamp: Date;
185
+ /** Tipo de evento */
186
+ type: DebugEventType;
187
+ /** Nombre del evento */
188
+ name: string;
189
+ /** Parámetros del evento */
190
+ params?: Record<string, unknown>;
191
+ /** Si fue enviado a Firebase (false en debug mode) */
192
+ sent: boolean;
193
+ }
194
+ /**
195
+ * Métrica de timing/performance
196
+ */
197
+ export interface TimingMetric {
198
+ /** Nombre de la métrica */
199
+ name: string;
200
+ /** Valor en milisegundos */
201
+ valueMs: number;
202
+ /** Categoría (ej: 'api', 'render', 'load') */
203
+ category?: string;
204
+ /** Parámetros adicionales */
205
+ params?: Record<string, string>;
206
+ }
207
+ /**
208
+ * Propiedades de usuario para segmentación
209
+ */
210
+ export interface UserProperties {
211
+ /** Idioma preferido */
212
+ preferred_language?: string;
213
+ /** Nivel de suscripción */
214
+ subscription_tier?: string;
215
+ /** Organización activa (multi-tenant) */
216
+ active_organization?: string;
217
+ /** Propiedades custom */
218
+ [key: string]: string | number | boolean | undefined;
219
+ }
@@ -4,6 +4,7 @@
4
4
  * Tipos e interfaces para la integración de Firebase en valtech-components.
5
5
  * Todos los modelos de Firestore deben extender FirestoreDocument.
6
6
  */
7
+ import type { AnalyticsConfig } from './analytics-types';
7
8
  /**
8
9
  * Configuración de Firebase (valores de firebaseConfig)
9
10
  */
@@ -72,6 +73,16 @@ export interface ValtechFirebaseConfig {
72
73
  * Default: false
73
74
  */
74
75
  debugMessagePersistence?: boolean;
76
+ /**
77
+ * Habilitar Firebase Analytics / GA4 (default: false).
78
+ * Requiere measurementId en firebase config.
79
+ */
80
+ enableAnalytics?: boolean;
81
+ /**
82
+ * Configuración detallada de Analytics.
83
+ * Solo aplica si enableAnalytics es true.
84
+ */
85
+ analyticsConfig?: AnalyticsConfig;
75
86
  }
76
87
  /**
77
88
  * Interface base para todos los documentos de Firestore.
@@ -0,0 +1,29 @@
1
+ import { EnvironmentProviders } from '@angular/core';
2
+ import { I18nConfig } from './types';
3
+ /**
4
+ * Configura el sistema de internacionalización de Valtech Components.
5
+ *
6
+ * @param config Configuración de i18n
7
+ * @returns Providers para agregar en app.config.ts
8
+ *
9
+ * @example
10
+ * // app.config.ts
11
+ * import { provideValtechI18n } from 'valtech-components';
12
+ * import { GLOBAL_CONTENT } from './i18n/_global';
13
+ * import { LOGIN_CONTENT } from './i18n/login.i18n';
14
+ *
15
+ * export const appConfig: ApplicationConfig = {
16
+ * providers: [
17
+ * provideValtechI18n({
18
+ * defaultLanguage: 'es',
19
+ * supportedLanguages: ['es', 'en'],
20
+ * detectBrowserLanguage: true,
21
+ * content: {
22
+ * '_global': GLOBAL_CONTENT,
23
+ * 'Login': LOGIN_CONTENT,
24
+ * }
25
+ * }),
26
+ * ]
27
+ * };
28
+ */
29
+ export declare function provideValtechI18n(config?: I18nConfig): EnvironmentProviders;
@@ -0,0 +1,112 @@
1
+ import { I18nLang, LanguagesContent, ContentStore } from './types';
2
+ import * as i0 from "@angular/core";
3
+ /**
4
+ * Servicio de internacionalización basado en Angular Signals.
5
+ *
6
+ * Características:
7
+ * - Sin RxJS: usa Signals para evitar memory leaks y congelamiento
8
+ * - Namespace-based: organiza traducciones por contexto
9
+ * - Fallback multi-nivel: namespace → _global → placeholder
10
+ * - Interpolación: soporta {variable} en textos
11
+ *
12
+ * @example
13
+ * // En un componente
14
+ * i18n = inject(I18nService);
15
+ *
16
+ * // Obtener texto
17
+ * const title = this.i18n.t('title', 'Login');
18
+ *
19
+ * // Con interpolación
20
+ * const welcome = this.i18n.t('welcome', 'Login', { name: 'Juan' });
21
+ *
22
+ * // Cambiar idioma
23
+ * this.i18n.setLanguage('en');
24
+ */
25
+ export declare class I18nService {
26
+ private readonly _lang;
27
+ private readonly _content;
28
+ private readonly _supportedLanguages;
29
+ readonly lang: import("@angular/core").Signal<I18nLang>;
30
+ readonly supportedLanguages: import("@angular/core").Signal<I18nLang[]>;
31
+ readonly isSpanish: import("@angular/core").Signal<boolean>;
32
+ readonly isEnglish: import("@angular/core").Signal<boolean>;
33
+ constructor();
34
+ /**
35
+ * Obtiene texto traducido (alias corto de getText)
36
+ *
37
+ * @param key Clave del texto
38
+ * @param namespace Namespace (default: '_global')
39
+ * @param data Variables para interpolación
40
+ * @returns Texto traducido o placeholder [namespace.key]
41
+ *
42
+ * @example
43
+ * i18n.t('submit'); // busca en _global
44
+ * i18n.t('title', 'Login'); // busca en Login
45
+ * i18n.t('welcome', 'Login', {name}); // con interpolación
46
+ */
47
+ t(key: string, namespace?: string, data?: Record<string, string>): string;
48
+ /**
49
+ * Obtiene texto traducido
50
+ *
51
+ * Fallback order:
52
+ * 1. content[namespace][lang][key]
53
+ * 2. content['_global'][lang][key]
54
+ * 3. "[namespace.key]" (placeholder)
55
+ */
56
+ getText(key: string, namespace?: string, data?: Record<string, string>): string;
57
+ /**
58
+ * Cambia el idioma de la aplicación
59
+ *
60
+ * @param lang Nuevo idioma
61
+ * @param forceReload Si true, recarga la página (fallback si reactividad falla)
62
+ */
63
+ setLanguage(lang: I18nLang, forceReload?: boolean): void;
64
+ /**
65
+ * Registra contenido de traducciones para un namespace
66
+ *
67
+ * @param namespace Nombre del namespace
68
+ * @param content Contenido de traducciones
69
+ *
70
+ * @example
71
+ * i18n.registerContent('Login', {
72
+ * es: { title: 'Iniciar sesión' },
73
+ * en: { title: 'Sign in' }
74
+ * });
75
+ */
76
+ registerContent(namespace: string, content: LanguagesContent): void;
77
+ /**
78
+ * Registra múltiples namespaces de una vez
79
+ *
80
+ * @param contentStore Objeto con namespaces como keys
81
+ */
82
+ registerContentBulk(contentStore: ContentStore): void;
83
+ /**
84
+ * Configura los idiomas soportados
85
+ */
86
+ setI18nLanguages(languages: I18nLang[]): void;
87
+ /**
88
+ * Obtiene todos los namespaces registrados
89
+ */
90
+ getNamespaces(): string[];
91
+ /**
92
+ * Verifica si un namespace tiene traducciones
93
+ */
94
+ hasNamespace(namespace: string): boolean;
95
+ /**
96
+ * Carga idioma guardado en localStorage o detecta del navegador
97
+ */
98
+ private loadStoredLanguage;
99
+ /**
100
+ * Valida si un idioma está soportado
101
+ */
102
+ private isValidLanguage;
103
+ /**
104
+ * Reemplaza {variable} en texto con valores de data
105
+ *
106
+ * @example
107
+ * interpolate('Hola {name}', { name: 'Juan' }) // 'Hola Juan'
108
+ */
109
+ private interpolate;
110
+ static ɵfac: i0.ɵɵFactoryDeclaration<I18nService, never>;
111
+ static ɵprov: i0.ɵɵInjectableDeclaration<I18nService>;
112
+ }
@@ -0,0 +1,4 @@
1
+ export { I18nLang, LanguagesContent, ContentStore, I18nConfig, LANG_STORAGE_KEY, } from './types';
2
+ export { I18nService } from './i18n.service';
3
+ export { TranslatePipe } from './translate.pipe';
4
+ export { provideValtechI18n } from './config';
@@ -0,0 +1,36 @@
1
+ import { PipeTransform } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ /**
4
+ * Pipe de traducción para templates.
5
+ *
6
+ * NOTA: Es impure para detectar cambios de idioma.
7
+ * El costo es mínimo porque I18nService usa Signals internamente.
8
+ *
9
+ * @example
10
+ * <!-- Busca en _global -->
11
+ * {{ 'submit' | t }}
12
+ *
13
+ * <!-- Busca en namespace específico -->
14
+ * {{ 'title' | t:'Login' }}
15
+ *
16
+ * <!-- Con interpolación -->
17
+ * {{ 'welcome' | t:'Login':{ name: userName } }}
18
+ *
19
+ * <!-- En atributos -->
20
+ * <val-button [label]="'submit' | t"></val-button>
21
+ * <val-input [label]="'email' | t:'Login'"></val-input>
22
+ */
23
+ export declare class TranslatePipe implements PipeTransform {
24
+ private readonly i18n;
25
+ /**
26
+ * Transforma una key de traducción a su valor
27
+ *
28
+ * @param key Clave del texto
29
+ * @param namespace Namespace opcional (default: '_global')
30
+ * @param data Variables para interpolación opcional
31
+ * @returns Texto traducido
32
+ */
33
+ transform(key: string, namespace?: string, data?: Record<string, string>): string;
34
+ static ɵfac: i0.ɵɵFactoryDeclaration<TranslatePipe, never>;
35
+ static ɵpipe: i0.ɵɵPipeDeclaration<TranslatePipe, "t", true>;
36
+ }
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Idiomas soportados por el sistema i18n
3
+ */
4
+ export type I18nLang = 'es' | 'en' | 'pt' | 'fr' | 'de';
5
+ /**
6
+ * Contenido de traducciones para un namespace
7
+ *
8
+ * @example
9
+ * const loginContent: LanguagesContent = {
10
+ * es: { title: 'Iniciar sesión', submit: 'Entrar' },
11
+ * en: { title: 'Sign in', submit: 'Sign in' }
12
+ * };
13
+ */
14
+ export type LanguagesContent = {
15
+ [lang in I18nLang]?: Record<string, string>;
16
+ };
17
+ /**
18
+ * Almacén de contenido por namespace
19
+ *
20
+ * @example
21
+ * {
22
+ * '_global': { es: {...}, en: {...} },
23
+ * 'Login': { es: {...}, en: {...} },
24
+ * 'Profile': { es: {...}, en: {...} }
25
+ * }
26
+ */
27
+ export type ContentStore = Record<string, LanguagesContent>;
28
+ /**
29
+ * Configuración para provideValtechI18n()
30
+ */
31
+ export interface I18nConfig {
32
+ /**
33
+ * Idioma por defecto si no hay preferencia guardada
34
+ * @default 'es'
35
+ */
36
+ defaultLanguage?: I18nLang;
37
+ /**
38
+ * Lista de idiomas habilitados en la app
39
+ * @default ['es', 'en']
40
+ */
41
+ supportedLanguages?: I18nLang[];
42
+ /**
43
+ * Detectar idioma del navegador al iniciar
44
+ * @default true
45
+ */
46
+ detectBrowserLanguage?: boolean;
47
+ /**
48
+ * Contenido inicial de traducciones por namespace
49
+ */
50
+ content?: ContentStore;
51
+ }
52
+ /**
53
+ * Valores por defecto de configuración
54
+ */
55
+ export declare const DEFAULT_I18N_CONFIG: Required<I18nConfig>;
56
+ /**
57
+ * Clave para persistir idioma en localStorage
58
+ */
59
+ export declare const LANG_STORAGE_KEY = "app_lang";
@@ -0,0 +1,32 @@
1
+ import { EnvironmentProviders } from '@angular/core';
2
+ import { PresetConfig } from './types';
3
+ /**
4
+ * Configura el sistema de presets de Valtech Components.
5
+ *
6
+ * @param presets Configuración de presets por componente
7
+ * @returns Providers para agregar en app.config.ts
8
+ *
9
+ * @example
10
+ * // app.config.ts
11
+ * import { provideValtechPresets } from 'valtech-components';
12
+ *
13
+ * export const appConfig: ApplicationConfig = {
14
+ * providers: [
15
+ * provideValtechPresets({
16
+ * button: {
17
+ * 'primary-action': { size: 'large', color: 'primary', fill: 'solid' },
18
+ * 'secondary': { size: 'medium', color: 'secondary', fill: 'outline' },
19
+ * 'danger': { size: 'medium', color: 'danger', fill: 'solid' },
20
+ * },
21
+ * card: {
22
+ * 'feature': { variant: 'elevated', padding: 'large' },
23
+ * 'compact': { variant: 'flat', padding: 'small' },
24
+ * },
25
+ * input: {
26
+ * 'form-field': { size: 'medium', fill: 'outline', labelPosition: 'floating' },
27
+ * }
28
+ * }),
29
+ * ]
30
+ * };
31
+ */
32
+ export declare function provideValtechPresets(presets: PresetConfig): EnvironmentProviders;
@@ -0,0 +1,3 @@
1
+ export { PresetConfig, ComponentPresets, PresetsOptions } from './types';
2
+ export { PresetService } from './preset.service';
3
+ export { provideValtechPresets } from './config';
@@ -0,0 +1,69 @@
1
+ import { PresetConfig, ComponentPresets } from './types';
2
+ import * as i0 from "@angular/core";
3
+ /**
4
+ * Servicio para gestionar presets de componentes.
5
+ *
6
+ * Los presets permiten definir configuraciones reutilizables
7
+ * de componentes (tamaño, color, variante, etc.) que se pueden
8
+ * aplicar con un nombre semántico.
9
+ *
10
+ * @example
11
+ * // En un componente
12
+ * presets = inject(PresetService);
13
+ *
14
+ * // Obtener preset
15
+ * const buttonProps = this.presets.get<ButtonMetadata>('button', 'primary-action');
16
+ * // { size: 'large', color: 'primary', fill: 'solid' }
17
+ */
18
+ export declare class PresetService {
19
+ private readonly _presets;
20
+ /**
21
+ * Obtiene un preset específico para un componente
22
+ *
23
+ * @param component Tipo de componente (ej: 'button', 'card', 'input')
24
+ * @param presetName Nombre del preset (ej: 'primary-action', 'compact')
25
+ * @returns Propiedades del preset o objeto vacío si no existe
26
+ *
27
+ * @example
28
+ * // Obtener preset de botón
29
+ * const props = presets.get<ButtonMetadata>('button', 'primary-action');
30
+ *
31
+ * // Usar en componente
32
+ * <val-button [props]="props"></val-button>
33
+ */
34
+ get<T extends Record<string, unknown>>(component: string, presetName: string): Partial<T>;
35
+ /**
36
+ * Verifica si existe un preset
37
+ */
38
+ has(component: string, presetName: string): boolean;
39
+ /**
40
+ * Registra presets de la aplicación
41
+ *
42
+ * @param presets Configuración de presets
43
+ *
44
+ * @example
45
+ * presets.registerPresets({
46
+ * button: {
47
+ * 'primary-action': { size: 'large', color: 'primary' },
48
+ * },
49
+ * card: {
50
+ * 'feature': { variant: 'elevated' },
51
+ * }
52
+ * });
53
+ */
54
+ registerPresets(presets: PresetConfig): void;
55
+ /**
56
+ * Agrega presets para un componente específico (merge con existentes)
57
+ */
58
+ registerComponentPresets(component: string, presets: ComponentPresets): void;
59
+ /**
60
+ * Obtiene todos los nombres de presets para un componente
61
+ */
62
+ getPresetNames(component: string): string[];
63
+ /**
64
+ * Obtiene todos los componentes con presets registrados
65
+ */
66
+ getRegisteredComponents(): string[];
67
+ static ɵfac: i0.ɵɵFactoryDeclaration<PresetService, never>;
68
+ static ɵprov: i0.ɵɵInjectableDeclaration<PresetService>;
69
+ }