valtech-components 2.0.1031 → 2.0.1033
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2022/lib/components/molecules/date-input/date-input.component.mjs +9 -3
- package/esm2022/lib/components/organisms/field-list/field-list.component.mjs +239 -0
- package/esm2022/lib/components/organisms/field-list/field-list.i18n.mjs +17 -0
- package/esm2022/lib/components/organisms/field-list/types.mjs +9 -0
- package/esm2022/lib/version.mjs +2 -2
- package/esm2022/public-api.mjs +3 -1
- package/fesm2022/valtech-components.mjs +264 -4
- package/fesm2022/valtech-components.mjs.map +1 -1
- package/lib/components/organisms/field-list/field-list.component.d.ts +55 -0
- package/lib/components/organisms/field-list/field-list.i18n.d.ts +6 -0
- package/lib/components/organisms/field-list/types.d.ts +52 -0
- package/lib/version.d.ts +1 -1
- package/package.json +1 -1
- package/public-api.d.ts +2 -0
- package/src/lib/services/firebase/firebase-messaging-sw.js +0 -145
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { EventEmitter, OnChanges, SimpleChanges } from '@angular/core';
|
|
2
|
+
import { FieldListColumn, FieldListItem, FieldListMetadata } from './types';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* `val-field-list` — editor de listas de campos repetibles (premios, rondas,
|
|
6
|
+
* integrantes, etc.). Cada ítem es una **card** con sus campos apilados y un botón
|
|
7
|
+
* para quitarla; al pie un botón "Agregar". Mobile-first (1 columna), escala a
|
|
8
|
+
* varias columnas por fila en pantallas anchas.
|
|
9
|
+
*
|
|
10
|
+
* Maneja su propio estado interno y emite el array completo en cada cambio
|
|
11
|
+
* (`itemsChange`). Patrón object-first (`@Input() props`). Auto-registra i18n
|
|
12
|
+
* (namespace `FieldList`) para los labels por defecto (agregar/quitar/vacío).
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* <val-field-list
|
|
16
|
+
* [props]="{
|
|
17
|
+
* fields: [
|
|
18
|
+
* { name: 'nombre', label: 'Nombre' },
|
|
19
|
+
* { name: 'descripcion', label: 'Descripción' }
|
|
20
|
+
* ],
|
|
21
|
+
* items: premios,
|
|
22
|
+
* itemLabel: 'Premio {n}',
|
|
23
|
+
* addLabel: 'Agregar premio'
|
|
24
|
+
* }"
|
|
25
|
+
* (itemsChange)="premios = $event" />
|
|
26
|
+
*/
|
|
27
|
+
export declare class FieldListComponent implements OnChanges {
|
|
28
|
+
private i18n;
|
|
29
|
+
constructor();
|
|
30
|
+
/** Props object-first. */
|
|
31
|
+
props: FieldListMetadata;
|
|
32
|
+
/** Emite el array completo de ítems en cada add/remove/edición. */
|
|
33
|
+
itemsChange: EventEmitter<FieldListItem[]>;
|
|
34
|
+
/** Estado interno de las filas (se siembra desde props.items). */
|
|
35
|
+
private readonly rowsSig;
|
|
36
|
+
readonly rows: import("@angular/core").Signal<FieldListItem[]>;
|
|
37
|
+
readonly fields: import("@angular/core").Signal<FieldListColumn[]>;
|
|
38
|
+
readonly itemLabel: import("@angular/core").Signal<string>;
|
|
39
|
+
readonly addIcon: import("@angular/core").Signal<string>;
|
|
40
|
+
readonly addText: import("@angular/core").Signal<string>;
|
|
41
|
+
readonly removeText: import("@angular/core").Signal<string>;
|
|
42
|
+
readonly emptyText: import("@angular/core").Signal<string>;
|
|
43
|
+
/** Puede agregar si no se alcanzó el máximo. */
|
|
44
|
+
readonly canAdd: import("@angular/core").Signal<boolean>;
|
|
45
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
46
|
+
private t;
|
|
47
|
+
/** Reemplaza `{n}` por el número de fila (1-based) en el rótulo de la card. */
|
|
48
|
+
rowLabel(template: string, index: number): string;
|
|
49
|
+
addRow(): void;
|
|
50
|
+
removeRow(index: number): void;
|
|
51
|
+
updateField(index: number, field: FieldListColumn, value: string | number): void;
|
|
52
|
+
private emit;
|
|
53
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<FieldListComponent, never>;
|
|
54
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<FieldListComponent, "val-field-list", never, { "props": { "alias": "props"; "required": false; }; }, { "itemsChange": "itemsChange"; }, never, never, true, never>;
|
|
55
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { LanguagesContent } from '../../../services/i18n/types';
|
|
2
|
+
/**
|
|
3
|
+
* Defaults i18n (es/en) embebidos en `val-field-list`. Auto-registrados en el
|
|
4
|
+
* namespace `FieldList` si el consumer no lo proveyó (anti key-faltante).
|
|
5
|
+
*/
|
|
6
|
+
export declare const FIELD_LIST_I18N: LanguagesContent;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tipos de `val-field-list` — editor de listas de campos repetibles.
|
|
3
|
+
*
|
|
4
|
+
* Cada ítem de la lista es un registro (`FieldListItem`) con las claves definidas
|
|
5
|
+
* en `fields`. El componente maneja su propio estado y emite el array completo en
|
|
6
|
+
* cada cambio (`itemsChange`). Patrón object-first (`@Input() props`).
|
|
7
|
+
*/
|
|
8
|
+
/** Tipo de input soportado por una columna del field-list. */
|
|
9
|
+
export type FieldListInputType = 'text' | 'number';
|
|
10
|
+
/** Definición de un campo (columna) de cada fila. */
|
|
11
|
+
export interface FieldListColumn {
|
|
12
|
+
/** Clave del campo en el registro de la fila. */
|
|
13
|
+
name: string;
|
|
14
|
+
/** Label visible arriba del input. */
|
|
15
|
+
label: string;
|
|
16
|
+
/** Placeholder del input. */
|
|
17
|
+
placeholder?: string;
|
|
18
|
+
/** Tipo de input (default `text`). */
|
|
19
|
+
type?: FieldListInputType;
|
|
20
|
+
/** `inputmode` del input (ej. `numeric` para montos/órdenes). */
|
|
21
|
+
inputmode?: string;
|
|
22
|
+
/** Largo máximo (solo `text`). */
|
|
23
|
+
maxlength?: number;
|
|
24
|
+
/** Mínimo (solo `number`). */
|
|
25
|
+
min?: number;
|
|
26
|
+
}
|
|
27
|
+
/** Un ítem de la lista: registro clave→valor según `fields`. */
|
|
28
|
+
export type FieldListItem = Record<string, string | number>;
|
|
29
|
+
/** Props (object-first) de `val-field-list`. */
|
|
30
|
+
export interface FieldListMetadata {
|
|
31
|
+
/** Esquema de campos de cada fila. */
|
|
32
|
+
fields: FieldListColumn[];
|
|
33
|
+
/** Valor inicial de la lista (se clona al estado interno). */
|
|
34
|
+
items?: FieldListItem[];
|
|
35
|
+
/** Texto del botón "Agregar" (default i18n). */
|
|
36
|
+
addLabel?: string;
|
|
37
|
+
/** Texto/aria del botón quitar (default i18n). */
|
|
38
|
+
removeLabel?: string;
|
|
39
|
+
/** Hint mostrado cuando la lista está vacía (default i18n). */
|
|
40
|
+
emptyText?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Template del rótulo de cada card: `{n}` se reemplaza por el número de fila
|
|
43
|
+
* (1-based). Ej. `"Premio {n}"`. Si se omite, la card no muestra rótulo.
|
|
44
|
+
*/
|
|
45
|
+
itemLabel?: string;
|
|
46
|
+
/** Mínimo de filas (no se puede bajar de acá). Default 0. */
|
|
47
|
+
min?: number;
|
|
48
|
+
/** Máximo de filas (oculta "Agregar" al alcanzarlo). Default sin límite. */
|
|
49
|
+
max?: number;
|
|
50
|
+
/** Ionicon del botón agregar (default `add-outline`). */
|
|
51
|
+
addIcon?: string;
|
|
52
|
+
}
|
package/lib/version.d.ts
CHANGED
package/package.json
CHANGED
package/public-api.d.ts
CHANGED
|
@@ -308,6 +308,8 @@ export * from './lib/components/organisms/invite-member-modal/invite-member-moda
|
|
|
308
308
|
export * from './lib/components/organisms/member-detail-modal/member-detail-modal.component';
|
|
309
309
|
export * from './lib/components/organisms/member-detail-modal/types';
|
|
310
310
|
export * from './lib/components/organisms/member-import-modal/member-import-modal.component';
|
|
311
|
+
export * from './lib/components/organisms/field-list/field-list.component';
|
|
312
|
+
export * from './lib/components/organisms/field-list/types';
|
|
311
313
|
export * from './lib/components/organisms/api-keys-modal/api-keys-modal.component';
|
|
312
314
|
export * from './lib/components/organisms/api-key-create-modal/api-key-create-modal.component';
|
|
313
315
|
export * from './lib/components/organisms/api-keys-view/api-keys-view.component';
|
|
@@ -1,145 +0,0 @@
|
|
|
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
|
-
}
|