@steveencues/starter-react-ui 1.0.0 → 1.0.1

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 (53) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/libs/aplicacion/contexts/index.d.ts +2 -0
  3. package/dist/libs/aplicacion/contexts/theme.context.d.ts +7 -0
  4. package/dist/libs/aplicacion/contexts/translate.context.d.ts +7 -0
  5. package/dist/libs/aplicacion/hooks/index.d.ts +3 -0
  6. package/dist/libs/aplicacion/hooks/use-language.d.ts +8 -0
  7. package/dist/libs/aplicacion/hooks/use-theme-preference.hook.d.ts +7 -0
  8. package/dist/libs/aplicacion/hooks/use-theme.d.ts +8 -0
  9. package/dist/libs/aplicacion/index.d.ts +5 -0
  10. package/dist/libs/aplicacion/providers/index.d.ts +2 -0
  11. package/dist/libs/aplicacion/providers/theme-provider.d.ts +9 -0
  12. package/dist/libs/aplicacion/providers/translate.provider.d.ts +8 -0
  13. package/dist/libs/aplicacion/services/encryption.service.d.ts +18 -0
  14. package/dist/libs/aplicacion/services/index.d.ts +1 -0
  15. package/dist/libs/aplicacion/utils/base64.util.d.ts +16 -0
  16. package/dist/libs/aplicacion/utils/crypto-api.util.d.ts +7 -0
  17. package/dist/libs/aplicacion/utils/index.d.ts +6 -0
  18. package/dist/libs/aplicacion/utils/storage-api.util.d.ts +7 -0
  19. package/dist/libs/aplicacion/utils/text-encoding.util.d.ts +16 -0
  20. package/dist/libs/aplicacion/utils/theme.utils.d.ts +26 -0
  21. package/dist/libs/aplicacion/utils/translation.utils.d.ts +64 -0
  22. package/dist/libs/components/Button/Button.d.ts +1 -0
  23. package/dist/libs/components/Button/button.types.d.ts +1 -0
  24. package/dist/libs/components/Button/index.d.ts +1 -0
  25. package/dist/libs/components/Card/Card.d.ts +1 -0
  26. package/dist/libs/components/Card/card.types.d.ts +1 -0
  27. package/dist/libs/components/Card/index.d.ts +1 -0
  28. package/dist/libs/components/Input/Input.d.ts +1 -0
  29. package/dist/libs/components/Input/index.d.ts +1 -0
  30. package/dist/libs/components/Input/input.types.d.ts +1 -0
  31. package/dist/libs/components/index.d.ts +1 -0
  32. package/dist/libs/components/styles/index.d.ts +1 -0
  33. package/dist/libs/domain/constants/encrypted-preference.constanst.d.ts +7 -0
  34. package/dist/libs/domain/constants/index.d.ts +3 -0
  35. package/dist/libs/domain/constants/theme-css-variable.const.d.ts +69 -0
  36. package/dist/libs/domain/constants/translation.constants.d.ts +1 -0
  37. package/dist/libs/domain/enums/index.d.ts +1 -0
  38. package/dist/libs/domain/enums/translation-regex.enum.d.ts +8 -0
  39. package/dist/libs/domain/index.d.ts +4 -0
  40. package/dist/libs/domain/interface/index.d.ts +2 -0
  41. package/dist/libs/domain/interface/theme.interface.d.ts +204 -0
  42. package/dist/libs/domain/interface/translation.interface.d.ts +56 -0
  43. package/dist/libs/domain/types/index.d.ts +3 -0
  44. package/dist/libs/domain/types/theme-name.types.d.ts +6 -0
  45. package/dist/libs/domain/types/theme.types.d.ts +64 -0
  46. package/dist/libs/domain/types/translation.types.d.ts +33 -0
  47. package/dist/libs/index.d.ts +4 -0
  48. package/dist/libs/infraestructura/index.d.ts +1 -0
  49. package/dist/libs/infraestructura/storage/encrypted-preference.storage.d.ts +19 -0
  50. package/dist/libs/infraestructura/storage/index.d.ts +3 -0
  51. package/dist/libs/infraestructura/storage/language-preference.storage.d.ts +18 -0
  52. package/dist/libs/infraestructura/storage/theme-preference.storage.d.ts +19 -0
  53. package/package.json +16 -4
@@ -0,0 +1 @@
1
+ export * from './libs';
@@ -0,0 +1,2 @@
1
+ export * from './translate.context';
2
+ export * from './theme.context';
@@ -0,0 +1,7 @@
1
+ import { IThemeContextValue } from '../../domain';
2
+ /**
3
+ * @description Contexto interno del sistema de temas.
4
+ * @author Steveen Cues
5
+ * @version 1.0.0
6
+ */
7
+ export declare const ThemeContext: import('react').Context<IThemeContextValue | null>;
@@ -0,0 +1,7 @@
1
+ import { ILanguageContextValue } from '../../domain';
2
+ /**
3
+ * @description Contexto interno de traducciones de la libreria.
4
+ * @author Steveen Cues
5
+ * @version 1.0.0
6
+ */
7
+ export declare const TranslateContext: import('react').Context<ILanguageContextValue | null>;
@@ -0,0 +1,3 @@
1
+ export * from './use-language';
2
+ export * from './use-theme';
3
+ export * from './use-theme-preference.hook';
@@ -0,0 +1,8 @@
1
+ import { ILanguageContextValue } from '../../domain';
2
+ /**
3
+ * @description Obtiene el idioma actual y la funcion de traduccion.
4
+ * Requiere que el componente este dentro de TranslateProvider.
5
+ * @author Steveen Cues
6
+ * @version 1.0.0
7
+ */
8
+ export declare function useLanguage(): ILanguageContextValue;
@@ -0,0 +1,7 @@
1
+ import { ThemePreferenceConfiguration, ThemePreferenceResult } from '../../domain';
2
+ /**
3
+ * @description Manages the selected theme and its encrypted persistence lifecycle.
4
+ * @author Steveen Cues
5
+ * @version 3.0.0
6
+ */
7
+ export declare function useThemePreference(inputConfiguration: ThemePreferenceConfiguration): ThemePreferenceResult;
@@ -0,0 +1,8 @@
1
+ import { IThemeContextValue } from '../../domain';
2
+ /**
3
+ * @description Obtiene el tema activo, los temas disponibles y
4
+ * la funcion para cambiar de tema.
5
+ * @author Steveen Cues
6
+ * @version 1.0.0
7
+ */
8
+ export declare function useTheme(): IThemeContextValue;
@@ -0,0 +1,5 @@
1
+ export * from './contexts';
2
+ export * from './hooks';
3
+ export * from './providers';
4
+ export * from './utils';
5
+ export * from './services';
@@ -0,0 +1,2 @@
1
+ export * from './translate.provider';
2
+ export * from './theme-provider';
@@ -0,0 +1,9 @@
1
+ import { IThemeProviderProps } from '../../domain';
2
+ import { JSX } from 'react';
3
+ /**
4
+ * @description Provides the active theme and allows theme changes.
5
+ * Restores and persists the encrypted theme preference.
6
+ * @author Steveen Cues
7
+ * @version 4.0.0
8
+ */
9
+ export declare function ThemeProvider({ themes, initialTheme, themeEncryptionKey, children, }: IThemeProviderProps): JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { JSX } from 'react';
2
+ import { ITranslateProviderProps } from '../../domain';
3
+ /**
4
+ * @description Provides the active language and translation functions.
5
+ * @author Steveen Cues
6
+ * @version 4.0.0
7
+ */
8
+ export declare function TranslateProvider({ translations, initialLanguage, fallbackLanguage, languageEncryptionKey, children, }: ITranslateProviderProps): JSX.Element;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @description Encrypts text using AES-GCM.
3
+ * @param value Text to encrypt.
4
+ * @param secret Encryption secret.
5
+ * @returns Encoded encrypted value or undefined when unavailable.
6
+ * @author Steveen Cues
7
+ * @version 2.0.0
8
+ */
9
+ export declare function encryptText(value: string, secret: string): Promise<string | undefined>;
10
+ /**
11
+ * @description Decrypts an AES-GCM encrypted value.
12
+ * @param value Encoded initialization vector and ciphertext.
13
+ * @param secret Encryption secret.
14
+ * @returns Original text or undefined if decryption fails.
15
+ * @author Steveen Cues
16
+ * @version 2.0.0
17
+ */
18
+ export declare function decryptText(value: string, secret: string): Promise<string | undefined>;
@@ -0,0 +1 @@
1
+ export * from './encryption.service';
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @description Encodes bytes into Base64.
3
+ * @param bytes Bytes to encode.
4
+ * @returns Base64 string.
5
+ * @author Steveen Cues
6
+ * @version 1.0.0
7
+ */
8
+ export declare function encodeBase64(bytes: Uint8Array): string;
9
+ /**
10
+ * @description Decodes Base64 into bytes.
11
+ * @param value Base64 string.
12
+ * @returns Decoded bytes.
13
+ * @author Steveen Cues
14
+ * @version 1.0.0
15
+ */
16
+ export declare function decodeBase64(value: string): Uint8Array<ArrayBuffer>;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @description Obtains the cryptographic API when available.
3
+ * @returns Cryptographic API or undefined if unavailable.
4
+ * @author Steveen Cues
5
+ * @version 1.0.0
6
+ */
7
+ export declare function getCryptoApi(): Crypto | undefined;
@@ -0,0 +1,6 @@
1
+ export * from './translation.utils';
2
+ export * from './theme.utils';
3
+ export * from './crypto-api.util';
4
+ export * from './storage-api.util';
5
+ export * from './text-encoding.util';
6
+ export * from './base64.util';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @description Obtains localStorage when available.
3
+ * @returns Browser storage or undefined if unavailable.
4
+ * @author Steveen Cues
5
+ * @version 1.0.0
6
+ */
7
+ export declare function getLocalStorage(): Storage | undefined;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @description Encodes text into UTF-8 bytes.
3
+ * @param value Text to encode.
4
+ * @returns Encoded bytes.
5
+ * @author Steveen Cues
6
+ * @version 1.0.0
7
+ */
8
+ export declare function encodeText(value: string): Uint8Array<ArrayBuffer>;
9
+ /**
10
+ * @description Decodes UTF-8 bytes into text.
11
+ * @param value Encoded bytes.
12
+ * @returns Decoded text.
13
+ * @author Steveen Cues
14
+ * @version 1.0.0
15
+ */
16
+ export declare function decodeText(value: ArrayBuffer): string;
@@ -0,0 +1,26 @@
1
+ import { AppTheme, ThemeCssVariables, ThemeName } from '../../domain';
2
+ /**
3
+ * @description Resuelve el tema inicial solicitado o utiliza el primero registrado.
4
+ * @author Steveen Cues
5
+ * @version 1.0.0
6
+ */
7
+ export declare function resolveInitialTheme(themes: readonly AppTheme[], initialTheme: ThemeName): AppTheme;
8
+ /**
9
+ * @description Resuelve el tema activo o recupera uno disponible.
10
+ * @author Steveen Cues
11
+ * @version 1.0.0
12
+ */
13
+ export declare function resolveActiveTheme(themes: readonly AppTheme[], selectedTheme: ThemeName, initialTheme: ThemeName): AppTheme;
14
+ /**
15
+ * @description Valida que el tema solicitado este registrado.
16
+ * @throws {Error} Cuando el tema no esta registrado.
17
+ * @author Steveen Cues
18
+ * @version 1.0.0
19
+ */
20
+ export declare function assertThemeExists(themes: readonly AppTheme[], themeName: ThemeName): void;
21
+ /**
22
+ * @description Genera todas las variables CSS a partir de los tokens del tema.
23
+ * @author Steveen Cues
24
+ * @version 1.3.0
25
+ */
26
+ export declare function createThemeVariables(theme: AppTheme): ThemeCssVariables;
@@ -0,0 +1,64 @@
1
+ import { TranslationCatalog, TranslationDictionary, TranslationParams } from '../../domain';
2
+ /**
3
+ * @description Obtiene el idioma inicial disponible, priorizando el
4
+ * idioma solicitado, el idioma de respaldo y el primer idioma registrado.
5
+ * @param translations Catalogo de traducciones.
6
+ * @param initialLanguage Idioma solicitado inicialmente.
7
+ * @param fallbackLanguage Idioma de respaldo.
8
+ * @returns Codigo del idioma inicial disponible.
9
+ * @throws Error cuando el catalogo esta vacio.
10
+ * @author Steveen Cues
11
+ * @version 2.0.0
12
+ */
13
+ export declare function resolveInitialLanguage(translations: TranslationCatalog, initialLanguage: string, fallbackLanguage: string): string;
14
+ /**
15
+ * @description Resuelve el idioma seleccionado y utiliza el idioma
16
+ * inicial, el respaldo o el primer idioma disponible si es necesario.
17
+ * @param translations Catalogo de traducciones.
18
+ * @param selectedLanguage Idioma seleccionado actualmente.
19
+ * @param initialLanguage Idioma inicial configurado.
20
+ * @param fallbackLanguage Idioma de respaldo.
21
+ * @returns Codigo del idioma activo.
22
+ * @author Steveen Cues
23
+ * @version 2.0.0
24
+ */
25
+ export declare function resolveActiveLanguage(translations: TranslationCatalog, selectedLanguage: string, initialLanguage: string, fallbackLanguage: string): string;
26
+ /**
27
+ * @description Valida que un idioma este registrado en el catalogo.
28
+ * @param translations Catalogo de traducciones.
29
+ * @param language Codigo del idioma que se desea validar.
30
+ * @returns No devuelve ningun valor.
31
+ * @throws Error cuando el idioma no esta disponible.
32
+ * @author Steveen Cues
33
+ * @version 2.0.0
34
+ */
35
+ export declare function assertLanguageExists(translations: TranslationCatalog, language: string): void;
36
+ /**
37
+ * @description Busca una traduccion dentro de un diccionario.
38
+ * @param dictionary Diccionario del idioma.
39
+ * @param key Clave con notacion de puntos.
40
+ * @returns Traduccion encontrada o undefined.
41
+ * @author Steveen Cues
42
+ * @version 2.0.0
43
+ */
44
+ export declare function findTranslation(dictionary: TranslationDictionary | undefined, key: string): string | undefined;
45
+ /**
46
+ * @description Sustituye los marcadores {{name}} usando los parametros.
47
+ * @param message Mensaje que se desea interpolar.
48
+ * @param params Valores disponibles para la interpolacion.
49
+ * @returns Mensaje con los parametros sustituidos.
50
+ * @author Steveen Cues
51
+ * @version 2.0.0
52
+ */
53
+ export declare function interpolateTranslation(message: string, params?: TranslationParams): string;
54
+ /**
55
+ * @description Traduce un mensaje aplicando respaldo e interpolacion.
56
+ * @param currentDictionary Diccionario del idioma activo.
57
+ * @param fallbackDictionary Diccionario del idioma de respaldo.
58
+ * @param key Clave de traduccion.
59
+ * @param params Parametros de interpolacion.
60
+ * @returns Mensaje final traducido e interpolado.
61
+ * @author Steveen Cues
62
+ * @version 2.0.0
63
+ */
64
+ export declare function translateMessage(currentDictionary: TranslationDictionary | undefined, fallbackDictionary: TranslationDictionary | undefined, key: string, params?: TranslationParams): string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ export declare const AES_GCM_ALGORITHM = "AES-GCM";
2
+ export declare const AES_GCM_IV_LENGTH = 12;
3
+ export declare const SHA_256_ALGORITHM = "SHA-256";
4
+ export declare const RAW_KEY_FORMAT = "raw";
5
+ export declare const STORAGE_VALUE_SEPARATOR = ".";
6
+ export declare const KEY_USAGES: KeyUsage[];
7
+ export declare const ENCRYPTED_VALUE_PART_COUNT = 2;
@@ -0,0 +1,3 @@
1
+ export * from './translation.constants';
2
+ export * from './encrypted-preference.constanst';
3
+ export * from './theme-css-variable.const';
@@ -0,0 +1,69 @@
1
+ /**
2
+ * @description Define los nombres de las variables CSS de la libreria.
3
+ * @author Steveen Cues
4
+ * @version 1.0.0
5
+ */
6
+ export declare const ThemeCssVariable: {
7
+ readonly SURFACE_BACKGROUND: "--rui-surface-background";
8
+ readonly SURFACE_SURFACE: "--rui-surface-surface";
9
+ readonly SURFACE_SURFACE_ELEVATED: "--rui-surface-surface-elevated";
10
+ readonly SURFACE_SURFACE_HOVER: "--rui-surface-surface-hover";
11
+ readonly SURFACE_SURFACE_ACTIVE: "--rui-surface-surface-active";
12
+ readonly SURFACE_SURFACE_DISABLED: "--rui-surface-surface-disabled";
13
+ readonly TEXT_PRIMARY: "--rui-text-primary";
14
+ readonly TEXT_SECONDARY: "--rui-text-secondary";
15
+ readonly TEXT_MUTED: "--rui-text-muted";
16
+ readonly TEXT_DISABLED: "--rui-text-disabled";
17
+ readonly TEXT_INVERSE: "--rui-text-inverse";
18
+ readonly TEXT_LINK: "--rui-text-link";
19
+ readonly TEXT_LINK_HOVER: "--rui-text-link-hover";
20
+ readonly BRAND_PRIMARY: "--rui-brand-primary";
21
+ readonly BRAND_PRIMARY_HOVER: "--rui-brand-primary-hover";
22
+ readonly BRAND_PRIMARY_ACTIVE: "--rui-brand-primary-active";
23
+ readonly BRAND_PRIMARY_CONTRAST: "--rui-brand-primary-contrast";
24
+ readonly BRAND_SECONDARY: "--rui-brand-secondary";
25
+ readonly BRAND_SECONDARY_HOVER: "--rui-brand-secondary-hover";
26
+ readonly BRAND_SECONDARY_ACTIVE: "--rui-brand-secondary-active";
27
+ readonly BRAND_SECONDARY_CONTRAST: "--rui-brand-secondary-contrast";
28
+ readonly BRAND_ACCENT: "--rui-brand-accent";
29
+ readonly BRAND_ACCENT_HOVER: "--rui-brand-accent-hover";
30
+ readonly BRAND_ACCENT_CONTRAST: "--rui-brand-accent-contrast";
31
+ readonly STATE_SUCCESS: "--rui-state-success";
32
+ readonly STATE_SUCCESS_BACKGROUND: "--rui-state-success-background";
33
+ readonly STATE_WARNING: "--rui-state-warning";
34
+ readonly STATE_WARNING_BACKGROUND: "--rui-state-warning-background";
35
+ readonly STATE_ERROR: "--rui-state-error";
36
+ readonly STATE_ERROR_BACKGROUND: "--rui-state-error-background";
37
+ readonly STATE_INFO: "--rui-state-info";
38
+ readonly STATE_INFO_BACKGROUND: "--rui-state-info-background";
39
+ readonly BORDER_DEFAULT: "--rui-border-default";
40
+ readonly BORDER_SUBTLE: "--rui-border-subtle";
41
+ readonly BORDER_STRONG: "--rui-border-strong";
42
+ readonly BORDER_FOCUS: "--rui-border-focus";
43
+ readonly BORDER_HOVER: "--rui-border-hover";
44
+ readonly BORDER_ACTIVE: "--rui-border-active";
45
+ readonly BORDER_DISABLED: "--rui-border-disabled";
46
+ readonly SHADOW_COLOR: "--rui-shadow-color";
47
+ readonly SHADOW_SUBTLE: "--rui-shadow-subtle";
48
+ readonly SHADOW_SMALL: "--rui-shadow-small";
49
+ readonly SHADOW_MEDIUM: "--rui-shadow-medium";
50
+ readonly SHADOW_LARGE: "--rui-shadow-large";
51
+ readonly SHADOW_GLOW: "--rui-shadow-glow";
52
+ readonly EFFECTS_OVERLAY: "--rui-effects-overlay";
53
+ readonly EFFECTS_BACKDROP: "--rui-effects-backdrop";
54
+ readonly EFFECTS_BLUR: "--rui-effects-blur";
55
+ readonly EFFECTS_BLUR_STRONG: "--rui-effects-blur-strong";
56
+ readonly EFFECTS_GLASS_BACKGROUND: "--rui-effects-glass-background";
57
+ readonly EFFECTS_GLASS_BORDER: "--rui-effects-glass-border";
58
+ readonly TYPOGRAPHY_HEADING_PRIMARY: "--rui-typography-heading-primary";
59
+ readonly TYPOGRAPHY_HEADING_SECONDARY: "--rui-typography-heading-secondary";
60
+ readonly TYPOGRAPHY_HEADING_MUTED: "--rui-typography-heading-muted";
61
+ readonly TYPOGRAPHY_BODY_PRIMARY: "--rui-typography-body-primary";
62
+ readonly TYPOGRAPHY_BODY_SECONDARY: "--rui-typography-body-secondary";
63
+ readonly TYPOGRAPHY_BODY_MUTED: "--rui-typography-body-muted";
64
+ readonly TYPOGRAPHY_LABEL_PRIMARY: "--rui-typography-label-primary";
65
+ readonly TYPOGRAPHY_LABEL_SECONDARY: "--rui-typography-label-secondary";
66
+ readonly TYPOGRAPHY_LABEL_MUTED: "--rui-typography-label-muted";
67
+ readonly TYPOGRAPHY_BUTTON_PRIMARY: "--rui-typography-button-primary";
68
+ readonly TYPOGRAPHY_BUTTON_SECONDARY: "--rui-typography-button-secondary";
69
+ };
@@ -0,0 +1 @@
1
+ export declare const GLOBAL_REGEX_FLAG = "g";
@@ -0,0 +1 @@
1
+ export * from './translation-regex.enum';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @description Expresiones regulares reutilizables para traducciones.
3
+ * @author Steveen Cues
4
+ * @version 2.0.0
5
+ */
6
+ export declare const TranslationRegex: Readonly<{
7
+ INTERPOLATION_PLACEHOLDER: string;
8
+ }>;
@@ -0,0 +1,4 @@
1
+ export * from './types';
2
+ export * from './interface';
3
+ export * from './enums';
4
+ export * from './constants';
@@ -0,0 +1,2 @@
1
+ export * from './translation.interface';
2
+ export * from './theme.interface';
@@ -0,0 +1,204 @@
1
+ import { ThemeName } from '..';
2
+ import { ReactNode } from 'react';
3
+ /**
4
+ * @description Contrato publico del contexto de temas.
5
+ * @author Steveen Cues
6
+ * @version 1.0.0
7
+ */
8
+ export interface IThemeContextValue {
9
+ readonly theme: AppTheme;
10
+ readonly themeName: ThemeName;
11
+ readonly themes: readonly AppTheme[];
12
+ readonly setTheme: (theme: ThemeName) => void;
13
+ }
14
+ /**
15
+ * @description Propiedades del proveedor de temas.
16
+ * @author Steveen Cues
17
+ * @version 1.0.0
18
+ */
19
+ export interface IThemeProviderProps {
20
+ readonly themes: readonly AppTheme[];
21
+ readonly initialTheme: ThemeName;
22
+ readonly themeEncryptionKey: string;
23
+ readonly children: ReactNode;
24
+ }
25
+ /**
26
+ * @description Colores del contenido textual.
27
+ * @author Steveen Cues
28
+ * @version 1.0.0
29
+ */
30
+ export interface ThemeTextColors {
31
+ readonly primary: string;
32
+ readonly secondary: string;
33
+ readonly muted: string;
34
+ readonly disabled: string;
35
+ readonly inverse: string;
36
+ readonly link: string;
37
+ readonly linkHover: string;
38
+ }
39
+ /**
40
+ * @description Colores utilizados por las superficies.
41
+ * @author Steveen Cues
42
+ * @version 1.0.0
43
+ */
44
+ export interface ThemeSurfaceColors {
45
+ readonly background: string;
46
+ readonly surface: string;
47
+ readonly surfaceElevated: string;
48
+ readonly surfaceHover: string;
49
+ readonly surfaceActive: string;
50
+ readonly surfaceDisabled: string;
51
+ }
52
+ /**
53
+ * @description Colores de los estados semanticos.
54
+ * @author Steveen Cues
55
+ * @version 1.0.0
56
+ */
57
+ export interface ThemeStateColors {
58
+ readonly success: string;
59
+ readonly successBackground: string;
60
+ readonly warning: string;
61
+ readonly warningBackground: string;
62
+ readonly error: string;
63
+ readonly errorBackground: string;
64
+ readonly info: string;
65
+ readonly infoBackground: string;
66
+ }
67
+ /**
68
+ * @description Colores de identidad visual de la aplicacion.
69
+ * @author Steveen Cues
70
+ * @version 1.0.0
71
+ */
72
+ export interface ThemeBrandColors {
73
+ readonly primary: string;
74
+ readonly primaryHover: string;
75
+ readonly primaryActive: string;
76
+ readonly primaryContrast: string;
77
+ readonly secondary: string;
78
+ readonly secondaryHover: string;
79
+ readonly secondaryActive: string;
80
+ readonly secondaryContrast: string;
81
+ readonly accent: string;
82
+ readonly accentHover: string;
83
+ readonly accentContrast: string;
84
+ }
85
+ /**
86
+ * @description Colores para bordes e indicadores de interaccion.
87
+ * @author Steveen Cues
88
+ * @version 1.0.0
89
+ */
90
+ export interface ThemeBorderColors {
91
+ readonly default: string;
92
+ readonly subtle: string;
93
+ readonly strong: string;
94
+ readonly focus: string;
95
+ readonly hover: string;
96
+ readonly active: string;
97
+ readonly disabled: string;
98
+ }
99
+ /**
100
+ * @description Configuracion de las sombras.
101
+ * @author Steveen Cues
102
+ * @version 1.0.0
103
+ */
104
+ export interface ThemeShadowColors {
105
+ readonly color: string;
106
+ readonly subtle: string;
107
+ readonly small: string;
108
+ readonly medium: string;
109
+ readonly large: string;
110
+ readonly glow: string;
111
+ }
112
+ /**
113
+ * @description Configuracion de efectos visuales.
114
+ * @author Steveen Cues
115
+ * @version 1.0.0
116
+ */
117
+ export interface ThemeEffects {
118
+ readonly overlay: string;
119
+ readonly backdrop: string;
120
+ readonly blur: string;
121
+ readonly blurStrong: string;
122
+ readonly glassBackground: string;
123
+ readonly glassBorder: string;
124
+ }
125
+ /**
126
+ * @description Configuracion tipografica del tema.
127
+ * Sus valores pueden representar colores o tokens CSS.
128
+ * @author Steveen Cues
129
+ * @version 1.0.0
130
+ */
131
+ export interface ThemeTypography {
132
+ readonly heading: {
133
+ readonly primary: string;
134
+ readonly secondary: string;
135
+ readonly muted: string;
136
+ };
137
+ readonly body: {
138
+ readonly primary: string;
139
+ readonly secondary: string;
140
+ readonly muted: string;
141
+ };
142
+ readonly label: {
143
+ readonly primary: string;
144
+ readonly secondary: string;
145
+ readonly muted: string;
146
+ };
147
+ readonly button: {
148
+ readonly primary: string;
149
+ readonly secondary: string;
150
+ };
151
+ }
152
+ /**
153
+ * @description Paleta completa de tokens visuales del tema.
154
+ * @author Steveen Cues
155
+ * @version 1.0.0
156
+ */
157
+ export interface ThemeColors {
158
+ readonly surface: ThemeSurfaceColors;
159
+ readonly text: ThemeTextColors;
160
+ readonly brand: ThemeBrandColors;
161
+ readonly state: ThemeStateColors;
162
+ readonly border: ThemeBorderColors;
163
+ readonly shadow: ThemeShadowColors;
164
+ readonly effects: ThemeEffects;
165
+ readonly typography: ThemeTypography;
166
+ }
167
+ /**
168
+ * @description Configuracion visual completa de un tema.
169
+ * @author Steveen Cues
170
+ * @version 1.0.0
171
+ */
172
+ export interface AppTheme {
173
+ readonly name: ThemeName;
174
+ readonly colors: ThemeColors;
175
+ }
176
+ /**
177
+ * @description Defines the configuration required to manage theme preferences.
178
+ * @author Steveen Cues
179
+ * @version 1.0.0
180
+ */
181
+ export interface ThemePreferenceConfiguration {
182
+ readonly themes: IThemeProviderProps["themes"];
183
+ readonly initialTheme: IThemeProviderProps["initialTheme"];
184
+ readonly themeEncryptionKey: IThemeProviderProps["themeEncryptionKey"];
185
+ }
186
+ /**
187
+ * @description Represents the current theme preference state and its configuration.
188
+ * @author Steveen Cues
189
+ * @version 1.0.0
190
+ */
191
+ export interface ThemePreferenceState extends ThemePreferenceConfiguration {
192
+ readonly themeName: ThemeName;
193
+ readonly isLoaded: boolean;
194
+ }
195
+ /**
196
+ * @description Defines the result returned by the theme preference hook.
197
+ * @author Steveen Cues
198
+ * @version 1.0.0
199
+ */
200
+ export interface ThemePreferenceResult {
201
+ readonly themeName: ThemeName;
202
+ readonly isPreferenceLoaded: boolean;
203
+ readonly setThemeName: (nextTheme: ThemeName) => void;
204
+ }
@@ -0,0 +1,56 @@
1
+ import { TranslationCatalog, TranslationParams } from '../..';
2
+ import { ReactNode } from 'react';
3
+ /**
4
+ * @description Estado publico del contexto de traducciones.
5
+ * @author Steveen Cues
6
+ * @version 1.0.0
7
+ */
8
+ export interface ILanguageContextValue {
9
+ readonly language: string;
10
+ readonly languages: readonly string[];
11
+ readonly setLanguage: (language: string) => void;
12
+ readonly t: (key: string, params?: TranslationParams) => string;
13
+ }
14
+ /**
15
+ * @description Propiedades del proveedor de traducciones.
16
+ * @author Steveen Cues
17
+ * @version 1.0.0
18
+ */
19
+ export interface ITranslateProviderProps {
20
+ readonly translations: TranslationCatalog;
21
+ readonly initialLanguage: string;
22
+ readonly fallbackLanguage?: string;
23
+ readonly children: ReactNode;
24
+ readonly languageEncryptionKey: string;
25
+ }
26
+ /**
27
+ * @description Defines the configuration required to manage language preferences.
28
+ * @author Steveen Cues
29
+ * @version 1.0.0
30
+ */
31
+ export interface LanguagePreferenceConfiguration {
32
+ readonly translations: ITranslateProviderProps["translations"];
33
+ readonly initialLanguage: ITranslateProviderProps["initialLanguage"];
34
+ readonly fallbackLanguage: string;
35
+ readonly languageEncryptionKey: ITranslateProviderProps["languageEncryptionKey"];
36
+ readonly languages: readonly string[];
37
+ }
38
+ /**
39
+ * @description Represents the current language preference state and configuration.
40
+ * @author Steveen Cues
41
+ * @version 1.0.0
42
+ */
43
+ export interface LanguagePreferenceState extends LanguagePreferenceConfiguration {
44
+ readonly selectedLanguage: string;
45
+ readonly isLoaded: boolean;
46
+ }
47
+ /**
48
+ * @description Defines the result returned by the language preference hook.
49
+ * @author Steveen Cues
50
+ * @version 1.0.0
51
+ */
52
+ export interface LanguagePreferenceResult {
53
+ readonly language: string;
54
+ readonly isLoaded: boolean;
55
+ readonly setLanguage: (language: string) => void;
56
+ }
@@ -0,0 +1,3 @@
1
+ export * from './translation.types';
2
+ export * from './theme.types';
3
+ export * from './theme-name.types';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @description Identificadores de los temas disponibles.
3
+ * @author Steveen Cues
4
+ * @version 1.0.0
5
+ */
6
+ export type ThemeName = "light" | "dark" | "magenta" | "semi-dark";
@@ -0,0 +1,64 @@
1
+ import { ThemePreferenceState } from '..';
2
+ import { CSSProperties, Dispatch, SetStateAction } from 'react';
3
+ /**
4
+ * @description Defines custom CSS variables supported by the library.
5
+ * @author Steveen Cues
6
+ * @version 1.0.0
7
+ */
8
+ export type ThemeCssVariables = CSSProperties & {
9
+ [property: `--rui-${string}`]: string;
10
+ };
11
+ /**
12
+ * @description Defines CSS variables for surface colors.
13
+ * @author Steveen Cues
14
+ * @version 1.0.0
15
+ */
16
+ export type SurfaceVariables = Pick<ThemeCssVariables, "--rui-surface-background" | "--rui-surface-surface" | "--rui-surface-surface-elevated" | "--rui-surface-surface-hover" | "--rui-surface-surface-active" | "--rui-surface-surface-disabled">;
17
+ /**
18
+ * @description Defines CSS variables for text colors.
19
+ * @author Steveen Cues
20
+ * @version 1.0.0
21
+ */
22
+ export type TextVariables = Pick<ThemeCssVariables, "--rui-text-primary" | "--rui-text-secondary" | "--rui-text-muted" | "--rui-text-disabled" | "--rui-text-inverse" | "--rui-text-link" | "--rui-text-link-hover">;
23
+ /**
24
+ * @description Defines CSS variables for brand colors.
25
+ * @author Steveen Cues
26
+ * @version 1.0.0
27
+ */
28
+ export type BrandVariables = Pick<ThemeCssVariables, "--rui-brand-primary" | "--rui-brand-primary-hover" | "--rui-brand-primary-active" | "--rui-brand-primary-contrast" | "--rui-brand-secondary" | "--rui-brand-secondary-hover" | "--rui-brand-secondary-active" | "--rui-brand-secondary-contrast" | "--rui-brand-accent" | "--rui-brand-accent-hover" | "--rui-brand-accent-contrast">;
29
+ /**
30
+ * @description Defines CSS variables for status colors.
31
+ * @author Steveen Cues
32
+ * @version 1.0.0
33
+ */
34
+ export type StateVariables = Pick<ThemeCssVariables, "--rui-state-success" | "--rui-state-success-background" | "--rui-state-warning" | "--rui-state-warning-background" | "--rui-state-error" | "--rui-state-error-background" | "--rui-state-info" | "--rui-state-info-background">;
35
+ /**
36
+ * @description Defines CSS variables for border styles and colors.
37
+ * @author Steveen Cues
38
+ * @version 1.0.0
39
+ */
40
+ export type BorderVariables = Pick<ThemeCssVariables, "--rui-border-default" | "--rui-border-subtle" | "--rui-border-strong" | "--rui-border-focus" | "--rui-border-hover" | "--rui-border-active" | "--rui-border-disabled">;
41
+ /**
42
+ * @description Defines CSS variables for shadows.
43
+ * @author Steveen Cues
44
+ * @version 1.0.0
45
+ */
46
+ export type ShadowVariables = Pick<ThemeCssVariables, "--rui-shadow-color" | "--rui-shadow-subtle" | "--rui-shadow-small" | "--rui-shadow-medium" | "--rui-shadow-large" | "--rui-shadow-glow">;
47
+ /**
48
+ * @description Defines CSS variables for visual effects.
49
+ * @author Steveen Cues
50
+ * @version 1.0.0
51
+ */
52
+ export type EffectVariables = Pick<ThemeCssVariables, "--rui-effects-overlay" | "--rui-effects-backdrop" | "--rui-effects-blur" | "--rui-effects-blur-strong" | "--rui-effects-glass-background" | "--rui-effects-glass-border">;
53
+ /**
54
+ * @description Defines CSS variables for typography colors.
55
+ * @author Steveen Cues
56
+ * @version 1.0.0
57
+ */
58
+ export type TypographyVariables = Pick<ThemeCssVariables, "--rui-typography-heading-primary" | "--rui-typography-heading-secondary" | "--rui-typography-heading-muted" | "--rui-typography-body-primary" | "--rui-typography-body-secondary" | "--rui-typography-body-muted" | "--rui-typography-label-primary" | "--rui-typography-label-secondary" | "--rui-typography-label-muted" | "--rui-typography-button-primary" | "--rui-typography-button-secondary">;
59
+ /**
60
+ * @description Defines the React state dispatcher for theme preference updates.
61
+ * @author Steveen Cues
62
+ * @version 1.0.0
63
+ */
64
+ export type SetThemePreferenceState = Dispatch<SetStateAction<ThemePreferenceState>>;
@@ -0,0 +1,33 @@
1
+ import { LanguagePreferenceState } from '..';
2
+ /**
3
+ * @description Valores admitidos en un catalogo de traducciones.
4
+ * @author Steveen Cues
5
+ * @version 1.0.0
6
+ */
7
+ export type TranslationValue = string | TranslationDictionary;
8
+ /**
9
+ * @description Diccionario de traducciones que admite claves anidadas.
10
+ * @author Steveen Cues
11
+ * @version 1.0.0
12
+ */
13
+ export interface TranslationDictionary {
14
+ readonly [key: string]: TranslationValue;
15
+ }
16
+ /**
17
+ * @description Catalogo de traducciones identificado por idioma.
18
+ * @author Steveen Cues
19
+ * @version 1.0.0
20
+ */
21
+ export type TranslationCatalog = Readonly<Record<string, TranslationDictionary>>;
22
+ /**
23
+ * @description Parametros para interpolar variables en una traduccion.
24
+ * @author Steveen Cues
25
+ * @version 1.0.0
26
+ */
27
+ export type TranslationParams = Readonly<Record<string, string | number>>;
28
+ /**
29
+ * @description Defines the React state dispatcher for language preference updates.
30
+ * @author Steveen Cues
31
+ * @version 1.0.0
32
+ */
33
+ export type SetLanguagePreferenceState = React.Dispatch<React.SetStateAction<LanguagePreferenceState>>;
@@ -0,0 +1,4 @@
1
+ export * from './aplicacion';
2
+ export * from './components';
3
+ export * from './domain';
4
+ export * from './infraestructura';
@@ -0,0 +1 @@
1
+ export * from './storage';
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @description Encrypts and saves a preference in localStorage.
3
+ * @param storageKey Storage key.
4
+ * @param value Value to store.
5
+ * @param encryptionKey Encryption secret.
6
+ * @returns Promise resolved after the save attempt.
7
+ * @author Steveen Cues
8
+ * @version 3.0.0
9
+ */
10
+ export declare function saveEncryptedPreference(storageKey: string, value: string, encryptionKey: string): Promise<void>;
11
+ /**
12
+ * @description Loads and decrypts a preference from localStorage.
13
+ * @param storageKey Storage key.
14
+ * @param encryptionKey Encryption secret.
15
+ * @returns Decrypted preference or undefined when unavailable.
16
+ * @author Steveen Cues
17
+ * @version 3.0.0
18
+ */
19
+ export declare function loadEncryptedPreference(storageKey: string, encryptionKey: string): Promise<string | undefined>;
@@ -0,0 +1,3 @@
1
+ export * from './encrypted-preference.storage';
2
+ export * from './language-preference.storage';
3
+ export * from './theme-preference.storage';
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @description Guarda el idioma activo de forma cifrada.
3
+ * @param language Codigo del idioma activo.
4
+ * @param encryptionKey Clave de cifrado proporcionada por el consumidor.
5
+ * @returns Promesa completada al finalizar el intento de guardado.
6
+ * @author Steveen Cues
7
+ * @version 1.0.0
8
+ */
9
+ export declare function saveLanguagePreference(language: string, encryptionKey: string): Promise<void>;
10
+ /**
11
+ * @description Recupera el idioma guardado y verifica que siga disponible.
12
+ * @param availableLanguages Idiomas admitidos por el proyecto.
13
+ * @param encryptionKey Clave de cifrado proporcionada por el consumidor.
14
+ * @returns Idioma recuperado o undefined si no existe o no es valido.
15
+ * @author Steveen Cues
16
+ * @version 1.0.0
17
+ */
18
+ export declare function loadLanguagePreference(availableLanguages: readonly string[], encryptionKey: string): Promise<string | undefined>;
@@ -0,0 +1,19 @@
1
+ import { AppTheme, ThemeName } from '../../domain';
2
+ /**
3
+ * @description Guarda el nombre del tema activo de forma cifrada.
4
+ * @param themeName Nombre del tema.
5
+ * @param encryptionKey Clave de cifrado proporcionada por el consumidor.
6
+ * @returns Promesa completada al finalizar el intento de guardado.
7
+ * @author Steveen Cues
8
+ * @version 1.0.0
9
+ */
10
+ export declare function saveThemePreference(themeName: ThemeName, encryptionKey: string): Promise<void>;
11
+ /**
12
+ * @description Recupera el tema guardado si existe entre los temas admitidos.
13
+ * @param themes Temas definidos por el proyecto consumidor.
14
+ * @param encryptionKey Clave de cifrado proporcionada por el consumidor.
15
+ * @returns Nombre del tema recuperado o undefined.
16
+ * @author Steveen Cues
17
+ * @version 1.0.0
18
+ */
19
+ export declare function loadThemePreference(themes: readonly AppTheme[], encryptionKey: string): Promise<ThemeName | undefined>;
package/package.json CHANGED
@@ -1,10 +1,21 @@
1
1
  {
2
2
  "name": "@steveencues/starter-react-ui",
3
+ "version": "1.0.1",
3
4
  "private": false,
4
- "version": "1.0.0",
5
5
  "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "require": "./dist/index.cjs"
14
+ }
15
+ },
6
16
  "files": [
7
- "dist"
17
+ "dist",
18
+ "README.md"
8
19
  ],
9
20
  "scripts": {
10
21
  "lint": "eslint .",
@@ -42,6 +53,7 @@
42
53
  "vite": "^8.3.0"
43
54
  },
44
55
  "peerDependencies": {
45
- "react": "^18.2.0 || ^19.0.0"
56
+ "react": "^18.2.0 || ^19.0.0",
57
+ "react-dom": "^18.2.0 || ^19.0.0"
46
58
  }
47
- }
59
+ }