valtech-components 4.0.4 → 4.0.6

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 (57) hide show
  1. package/esm2022/lib/components/atoms/button/button.component.mjs +15 -5
  2. package/esm2022/lib/components/atoms/fab/fab.component.mjs +8 -18
  3. package/esm2022/lib/components/atoms/horizontal-scroll/horizontal-scroll.component.mjs +5 -7
  4. package/esm2022/lib/components/atoms/progress-bar/progress-bar.component.mjs +3 -1
  5. package/esm2022/lib/components/atoms/progress-bar/types.mjs +1 -1
  6. package/esm2022/lib/components/molecules/accordion/accordion.component.mjs +4 -6
  7. package/esm2022/lib/components/molecules/action-card/action-card.component.mjs +5 -5
  8. package/esm2022/lib/components/molecules/breadcrumb/breadcrumb.component.mjs +5 -5
  9. package/esm2022/lib/components/molecules/card/card.component.mjs +19 -9
  10. package/esm2022/lib/components/molecules/chip-group/chip-group.component.mjs +21 -13
  11. package/esm2022/lib/components/molecules/code-display/code-display.component.mjs +5 -5
  12. package/esm2022/lib/components/molecules/comment/comment.component.mjs +29 -56
  13. package/esm2022/lib/components/molecules/content-loader/content-loader.component.mjs +13 -3
  14. package/esm2022/lib/components/molecules/date-picker/date-picker.component.mjs +7 -15
  15. package/esm2022/lib/components/molecules/date-range-input/date-range-input.component.mjs +6 -10
  16. package/esm2022/lib/components/molecules/docs-code-example/docs-code-example.component.mjs +13 -5
  17. package/esm2022/lib/components/molecules/docs-nav-links/docs-nav-links.component.mjs +7 -13
  18. package/esm2022/lib/components/molecules/docs-search/docs-search.component.mjs +12 -28
  19. package/esm2022/lib/components/molecules/features-list/features-list.component.mjs +5 -5
  20. package/esm2022/lib/components/molecules/feedback-form/feedback-form.component.mjs +5 -5
  21. package/esm2022/lib/components/molecules/file-input/file-input.component.mjs +9 -3
  22. package/esm2022/lib/components/molecules/glow-card/glow-card.component.mjs +17 -15
  23. package/esm2022/lib/components/molecules/language-selector/language-selector.component.mjs +7 -5
  24. package/esm2022/lib/components/molecules/link/link.component.mjs +3 -3
  25. package/esm2022/lib/components/molecules/media-object/media-object.component.mjs +3 -3
  26. package/esm2022/lib/components/molecules/metric-card/metric-card.component.mjs +5 -3
  27. package/esm2022/lib/components/molecules/password-input/password-input.component.mjs +11 -3
  28. package/esm2022/lib/components/molecules/pill/pill.component.mjs +7 -7
  29. package/esm2022/lib/components/molecules/popover-selector/popover-selector.component.mjs +7 -7
  30. package/esm2022/lib/components/molecules/segment-control/segment-control.component.mjs +3 -3
  31. package/esm2022/lib/components/molecules/select-search/select-search.component.mjs +15 -3
  32. package/esm2022/lib/components/molecules/share-buttons/share-buttons.component.mjs +3 -1
  33. package/esm2022/lib/components/molecules/stats-card/stats-card.component.mjs +5 -5
  34. package/esm2022/lib/components/molecules/stepper/stepper.component.mjs +11 -13
  35. package/esm2022/lib/components/molecules/tabs/tabs.component.mjs +4 -6
  36. package/esm2022/lib/components/molecules/ticket-card/ticket-card.component.mjs +3 -3
  37. package/esm2022/lib/components/organisms/banner/types.mjs +1 -1
  38. package/esm2022/lib/components/organisms/cookie-banner/cookie-banner.component.mjs +3 -1
  39. package/esm2022/lib/components/organisms/cookie-banner/types.mjs +1 -1
  40. package/esm2022/lib/components/organisms/data-table/data-table.component.mjs +11 -7
  41. package/esm2022/lib/components/organisms/login/login.component.mjs +3 -3
  42. package/esm2022/lib/services/icons.service.mjs +3 -2
  43. package/esm2022/lib/services/page-state/page-state.i18n.mjs +19 -0
  44. package/esm2022/lib/services/page-state/page-state.mjs +101 -0
  45. package/esm2022/lib/version.mjs +2 -2
  46. package/esm2022/public-api.mjs +4 -1
  47. package/fesm2022/valtech-components.mjs +405 -279
  48. package/fesm2022/valtech-components.mjs.map +1 -1
  49. package/lib/components/atoms/progress-bar/types.d.ts +2 -0
  50. package/lib/components/organisms/banner/types.d.ts +1 -1
  51. package/lib/components/organisms/cookie-banner/types.d.ts +2 -0
  52. package/lib/services/page-state/page-state.d.ts +74 -0
  53. package/lib/services/page-state/page-state.i18n.d.ts +6 -0
  54. package/lib/version.d.ts +1 -1
  55. package/package.json +1 -1
  56. package/public-api.d.ts +1 -0
  57. package/src/lib/services/firebase/firebase-messaging-sw.js +145 -0
@@ -16,4 +16,6 @@ export interface ProgressBarMetadata {
16
16
  buffer: number;
17
17
  type: 'determinate' | 'indeterminate';
18
18
  rounded: boolean;
19
+ /** Accessible label for screen readers (aria-label). Defaults to 'Progreso'. */
20
+ label?: string;
19
21
  }
@@ -18,7 +18,7 @@ import { TitleBlockMetada } from '../../molecules/title-block/types';
18
18
  export type BannerMetadata = {
19
19
  token?: string;
20
20
  image?: string;
21
- color: Color;
21
+ color?: Color;
22
22
  bordered: boolean;
23
23
  closable: boolean;
24
24
  mode: 'row' | 'column' | 'hybrid' | 'center';
@@ -19,6 +19,8 @@ export type CookieBannerPosition = 'bottom' | 'top';
19
19
  export interface CookieBannerMetadata {
20
20
  /** Whether the banner is shown. Parent toggles based on `hasDecided`. */
21
21
  visible: boolean;
22
+ /** Accessible label for the dialog (aria-label). Defaults to 'Aviso de cookies'. */
23
+ ariaLabel?: string;
22
24
  /** Where the banner anchors. Default `'bottom'`. */
23
25
  position?: CookieBannerPosition;
24
26
  /** Short title above the message (optional). */
@@ -0,0 +1,74 @@
1
+ /**
2
+ * createPageState — helper estándar para el patrón loading/error/data de una
3
+ * página con datos remotos (HTTP o Firestore one-shot).
4
+ *
5
+ * Encapsula el boilerplate repetido en cada vista:
6
+ * - `loading` signal (true mientras carga o recarga).
7
+ * - `loadError` signal (el error crudo o null).
8
+ * - `errorState` computed que convierte el error a `EmptyStateMetadata` listo
9
+ * para `<val-empty-state>`, reactivo al idioma.
10
+ * - `reload()` function que re-ejecuta el `loader` async.
11
+ *
12
+ * El caller controla el template; `createPageState` solo maneja el estado:
13
+ *
14
+ * ```ts
15
+ * readonly page = createPageState(
16
+ * this.i18n,
17
+ * async () => {
18
+ * const res = await firstValueFrom(this.svc.getData());
19
+ * this.items.set(res.items);
20
+ * },
21
+ * { errorTitle: () => this.t('errorTitle'), retryLabel: () => this.t('retry') }
22
+ * );
23
+ * ```
24
+ *
25
+ * Template:
26
+ * ```html
27
+ * @if (page.loading()) { <val-skeleton-layout [props]="{ preset: 'list' }" /> }
28
+ * @else if (page.errorState(); as e) { <val-empty-state [props]="e" /> }
29
+ * @else { <!-- content --> }
30
+ * ```
31
+ *
32
+ * El helper llama a `reload()` automáticamente al construirse (carga inicial),
33
+ * igual que el patrón clásico `void this.load()` en el constructor.
34
+ * Para deshabilitar la carga automática, pasar `{ autoLoad: false }`.
35
+ *
36
+ * Para pull-to-refresh usar `connectPageRefresh(() => page.reload())` como siempre.
37
+ */
38
+ import { EmptyStateMetadata } from '../../components/molecules/empty-state/types';
39
+ import { I18nService } from '../i18n';
40
+ /** Labels i18n para el empty-state de error. Funciones para ser reactivas. */
41
+ export interface PageStateLabels {
42
+ errorTitle?: () => string;
43
+ offlineTitle?: () => string;
44
+ offlineHint?: () => string;
45
+ retryLabel?: () => string;
46
+ /** Descripción del error (default: mensaje del backend). */
47
+ errorDescription?: (err: unknown) => string;
48
+ }
49
+ /** Objeto retornado por `createPageState`. */
50
+ export interface PageState {
51
+ /** true mientras el loader está en curso. */
52
+ readonly loading: () => boolean;
53
+ /** Error crudo del último intento (null si fue exitoso). */
54
+ readonly loadError: () => unknown | null;
55
+ /**
56
+ * Props para `<val-empty-state>` — null si no hay error.
57
+ * Reactivo al idioma (llama `i18n.lang()` internamente).
58
+ */
59
+ readonly errorState: () => EmptyStateMetadata | null;
60
+ /** Re-ejecuta el loader (sets loading=true, limpia error). */
61
+ reload(): Promise<void>;
62
+ }
63
+ /**
64
+ * Crea el estado de carga de una página.
65
+ *
66
+ * @param i18n - `I18nService` inyectado en la page (para reactividad al idioma).
67
+ * @param loader - función async que carga los datos y los siembra en signals
68
+ * propias de la page. Si lanza, el error se captura en `loadError`.
69
+ * @param labels - labels i18n opcionales. Si se omiten usa defaults genéricos.
70
+ * @param options - `autoLoad`: si false no carga al construirse (default true).
71
+ */
72
+ export declare function createPageState(i18n: I18nService, loader: () => Promise<void>, labels?: PageStateLabels, options?: {
73
+ autoLoad?: boolean;
74
+ }): PageState;
@@ -0,0 +1,6 @@
1
+ import { LanguagesContent } from '../i18n/types';
2
+ /**
3
+ * Defaults i18n embebidos en `createPageState`. Namespace `PageState`.
4
+ * Auto-registrados la primera vez que se llama al helper.
5
+ */
6
+ export declare const PAGE_STATE_I18N: LanguagesContent;
package/lib/version.d.ts CHANGED
@@ -2,4 +2,4 @@
2
2
  * Current version of valtech-components.
3
3
  * This is automatically updated during the publish process.
4
4
  */
5
- export declare const VERSION = "4.0.4";
5
+ export declare const VERSION = "4.0.6";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "valtech-components",
3
- "version": "4.0.4",
3
+ "version": "4.0.6",
4
4
  "private": false,
5
5
  "bin": {
6
6
  "valtech-firebase-config": "./src/lib/services/firebase/scripts/generate-sw-config.js"
package/public-api.d.ts CHANGED
@@ -369,6 +369,7 @@ export * from './lib/services/network-status';
369
369
  export * from './lib/components/molecules/network-banner/network-banner.component';
370
370
  export * from './lib/services/page-refresh/page-refresh.service';
371
371
  export * from './lib/services/refreshable-stream';
372
+ export * from './lib/services/page-state/page-state';
372
373
  export * from './lib/services/app-config';
373
374
  export * from './lib/services/app-version';
374
375
  export * from './lib/services/presets';
@@ -0,0 +1,145 @@
1
+ /**
2
+ * Firebase Messaging Service Worker
3
+ *
4
+ * Service Worker estático para Firebase Cloud Messaging.
5
+ * Carga la configuración dinámicamente desde /firebase-config.js.
6
+ *
7
+ * CONFIGURACIÓN:
8
+ * 1. Crea firebase.config.json con tu configuración de Firebase
9
+ * 2. Ejecuta: npm run generate:firebase-config
10
+ * Esto genera /firebase-config.js con: self.FIREBASE_CONFIG = {...}
11
+ * 3. Agrega este SW y firebase-config.js a los assets de angular.json
12
+ *
13
+ * Ver README.md para documentación completa.
14
+ */
15
+
16
+ // Importar Firebase scripts
17
+ importScripts('https://www.gstatic.com/firebasejs/10.7.0/firebase-app-compat.js');
18
+ importScripts('https://www.gstatic.com/firebasejs/10.7.0/firebase-messaging-compat.js');
19
+
20
+ // Importar configuración desde archivo externo (generado en build)
21
+ // Este archivo define: self.FIREBASE_CONFIG = { ... }
22
+ try {
23
+ importScripts('/firebase-config.js');
24
+ } catch (e) {
25
+ console.error('[SW] No se pudo cargar firebase-config.js:', e);
26
+ }
27
+
28
+ // Verificar que la configuración existe
29
+ if (!self.FIREBASE_CONFIG) {
30
+ console.error('[SW] FIREBASE_CONFIG no está definido.');
31
+ console.error('[SW] Ejecuta: npm run generate:firebase-config');
32
+ } else {
33
+ // Inicializar Firebase
34
+ firebase.initializeApp(self.FIREBASE_CONFIG);
35
+
36
+ // Obtener instancia de messaging
37
+ const messaging = firebase.messaging();
38
+
39
+ /**
40
+ * Handler para mensajes en background.
41
+ */
42
+ messaging.onBackgroundMessage((payload) => {
43
+ console.log('[SW] Mensaje recibido en background:', payload);
44
+
45
+ // Web push usa mensajes data-only (sin bloque `notification`) para que el
46
+ // navegador NO auto-muestre una notificación duplicada — el SW es el único
47
+ // que la pinta. Title/body/icon llegan dentro de `data`. Se mantiene el
48
+ // fallback a `payload.notification` por compatibilidad con mensajes
49
+ // legacy o nativos que sí traen el bloque.
50
+ const data = payload.data || {};
51
+ const notificationTitle =
52
+ payload.notification?.title || data.title || 'Nueva notificación';
53
+ const notificationBody = payload.notification?.body || data.body || '';
54
+ const notificationIcon =
55
+ payload.notification?.icon || data.icon || '/assets/icon/favicon.ico';
56
+
57
+ const notificationOptions = {
58
+ body: notificationBody,
59
+ icon: notificationIcon,
60
+ image: payload.notification?.image,
61
+ badge: '/assets/icon/badge.png',
62
+ tag: payload.messageId || data.messageId || 'default',
63
+ data: {
64
+ ...data,
65
+ messageId: payload.messageId || data.messageId,
66
+ title: notificationTitle,
67
+ body: notificationBody,
68
+ },
69
+ vibrate: [200, 100, 200],
70
+ requireInteraction: data.require_interaction === 'true',
71
+ };
72
+
73
+ return self.registration.showNotification(notificationTitle, notificationOptions);
74
+ });
75
+
76
+ /**
77
+ * Handler para clicks en notificaciones.
78
+ */
79
+ self.addEventListener('notificationclick', (event) => {
80
+ console.log('[SW] Click en notificación:', event);
81
+ event.notification.close();
82
+
83
+ const data = event.notification.data || {};
84
+ let targetUrl = '/';
85
+
86
+ if (data.route) {
87
+ targetUrl = data.route;
88
+ } else if (data.url) {
89
+ targetUrl = data.url;
90
+ }
91
+
92
+ if (data.query_params) {
93
+ const separator = targetUrl.includes('?') ? '&' : '?';
94
+ targetUrl += separator + data.query_params;
95
+ }
96
+
97
+ const notificationPayload = {
98
+ type: 'NOTIFICATION_CLICK',
99
+ notification: {
100
+ title: data.title,
101
+ body: data.body,
102
+ data: data,
103
+ messageId: data.messageId,
104
+ },
105
+ };
106
+
107
+ event.waitUntil(
108
+ clients
109
+ .matchAll({ type: 'window', includeUncontrolled: true })
110
+ .then((clientList) => {
111
+ // Siempre enviar postMessage para que la app pueda reaccionar
112
+ for (const client of clientList) {
113
+ client.postMessage(notificationPayload);
114
+ }
115
+
116
+ // Navegar si hay route o url
117
+ if (targetUrl !== '/') {
118
+ for (const client of clientList) {
119
+ if ('navigate' in client) {
120
+ return client.navigate(targetUrl).then((c) => c?.focus());
121
+ }
122
+ }
123
+ // Si no hay cliente abierto, abrir nueva ventana
124
+ if (clients.openWindow) {
125
+ return clients.openWindow(targetUrl);
126
+ }
127
+ }
128
+
129
+ // Solo hacer focus si no hay navegación
130
+ for (const client of clientList) {
131
+ if ('focus' in client) {
132
+ return client.focus();
133
+ }
134
+ }
135
+ if (clients.openWindow) {
136
+ return clients.openWindow('/');
137
+ }
138
+ })
139
+ );
140
+ });
141
+
142
+ self.addEventListener('notificationclose', (event) => {
143
+ console.log('[SW] Notificación cerrada:', event.notification.tag);
144
+ });
145
+ }