valtech-components 4.0.27 → 4.0.29

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 (25) hide show
  1. package/esm2022/lib/components/organisms/account-view/account-view.component.mjs +34 -30
  2. package/esm2022/lib/components/organisms/change-password-modal/change-password-modal.component.mjs +3 -3
  3. package/esm2022/lib/components/organisms/create-org-modal/create-org-modal.component.mjs +91 -65
  4. package/esm2022/lib/components/organisms/delete-account-modal/delete-account-modal.component.mjs +106 -84
  5. package/esm2022/lib/components/organisms/login/login.component.mjs +11 -4
  6. package/esm2022/lib/components/organisms/login/types.mjs +23 -1
  7. package/esm2022/lib/components/organisms/organization-view/organization-view.component.mjs +16 -3
  8. package/esm2022/lib/components/organisms/permissions-view/permissions-modal.component.mjs +70 -0
  9. package/esm2022/lib/components/organisms/permissions-view/permissions-view.component.mjs +16 -5
  10. package/esm2022/lib/version.mjs +2 -2
  11. package/esm2022/public-api.mjs +2 -1
  12. package/fesm2022/valtech-components.mjs +1125 -956
  13. package/fesm2022/valtech-components.mjs.map +1 -1
  14. package/lib/components/organisms/account-view/account-view.component.d.ts +3 -0
  15. package/lib/components/organisms/create-org-modal/create-org-modal.component.d.ts +8 -8
  16. package/lib/components/organisms/delete-account-modal/delete-account-modal.component.d.ts +7 -8
  17. package/lib/components/organisms/login/login.component.d.ts +6 -0
  18. package/lib/components/organisms/login/types.d.ts +12 -0
  19. package/lib/components/organisms/organization-view/organization-view.component.d.ts +1 -0
  20. package/lib/components/organisms/permissions-view/permissions-modal.component.d.ts +13 -0
  21. package/lib/components/organisms/permissions-view/permissions-view.component.d.ts +9 -2
  22. package/lib/version.d.ts +1 -1
  23. package/package.json +1 -1
  24. package/public-api.d.ts +1 -0
  25. package/src/lib/services/firebase/firebase-messaging-sw.js +145 -0
@@ -42,6 +42,8 @@ export declare class AccountViewComponent {
42
42
  readonly orgsLoading: import("@angular/core").WritableSignal<boolean>;
43
43
  private readonly orgsError;
44
44
  readonly orgsErrorState: import("@angular/core").Signal<EmptyStateMetadata>;
45
+ readonly createOrgOpen: import("@angular/core").WritableSignal<boolean>;
46
+ readonly deleteAccountOpen: import("@angular/core").WritableSignal<boolean>;
45
47
  readonly pendingInvites: import("@angular/core").WritableSignal<PendingInvitation[]>;
46
48
  readonly pendingInvitesLoading: import("@angular/core").WritableSignal<boolean>;
47
49
  readonly inviteAccepting: import("@angular/core").WritableSignal<string>;
@@ -76,6 +78,7 @@ export declare class AccountViewComponent {
76
78
  onDeleteAccount(): void;
77
79
  onManageOrg(): void;
78
80
  onNewOrg(): void;
81
+ onOrgCreated(newOrg: Organization): void;
79
82
  onMoreInfo(): void;
80
83
  onLogout(): void;
81
84
  private loadPendingInvites;
@@ -1,4 +1,4 @@
1
- import { WritableSignal } from '@angular/core';
1
+ import { EventEmitter, WritableSignal } from '@angular/core';
2
2
  import { FormMetadata, FormSubmit } from '../../types';
3
3
  import { Organization } from '../../../services/org/types';
4
4
  import * as i0 from "@angular/core";
@@ -25,21 +25,21 @@ export declare class CreateOrgModalComponent {
25
25
  private orgSwitch;
26
26
  private toast;
27
27
  private errors;
28
- /** Inyectado por `ModalService.open` — referencia para cerrar desde dentro. */
29
- _modalRef?: {
30
- dismiss: (data?: unknown, role?: string) => void;
31
- };
32
- /** Callback tras crear la org (pasado por `componentProps`). */
33
- onSuccess?: (newOrg: Organization) => void;
34
28
  /** Namespace i18n con que la vista resuelve sus textos. */
35
29
  i18nNamespace: string;
30
+ private _isOpen;
31
+ set isOpen(value: boolean);
32
+ get isOpen(): boolean;
33
+ dismissed: EventEmitter<void>;
34
+ created: EventEmitter<Organization>;
36
35
  private readonly _busy;
37
36
  readonly formMeta: WritableSignal<FormMetadata>;
38
37
  constructor();
39
38
  onSubmit(event: FormSubmit): Promise<void>;
40
39
  dismiss(): void;
40
+ close(): void;
41
41
  private buildFormMeta;
42
42
  t(key: string): string;
43
43
  static ɵfac: i0.ɵɵFactoryDeclaration<CreateOrgModalComponent, never>;
44
- static ɵcmp: i0.ɵɵComponentDeclaration<CreateOrgModalComponent, "val-create-org-modal", never, { "_modalRef": { "alias": "_modalRef"; "required": false; }; "onSuccess": { "alias": "onSuccess"; "required": false; }; "i18nNamespace": { "alias": "i18nNamespace"; "required": false; }; }, {}, never, never, true, never>;
44
+ static ɵcmp: i0.ɵɵComponentDeclaration<CreateOrgModalComponent, "val-create-org-modal", never, { "i18nNamespace": { "alias": "i18nNamespace"; "required": false; }; "isOpen": { "alias": "isOpen"; "required": false; }; }, { "dismissed": "dismissed"; "created": "created"; }, never, never, true, never>;
45
45
  }
@@ -1,4 +1,4 @@
1
- import { OnInit } from '@angular/core';
1
+ import { EventEmitter } from '@angular/core';
2
2
  import { ComponentState, FormMetadata, FormSubmit } from '../../types';
3
3
  import * as i0 from "@angular/core";
4
4
  /**
@@ -19,22 +19,21 @@ import * as i0 from "@angular/core";
19
19
  * Auto-registra sus defaults i18n (es/en) en el constructor si el consumer no
20
20
  * proveyó el namespace `Settings.DeleteAccount`.
21
21
  */
22
- export declare class DeleteAccountModalComponent implements OnInit {
22
+ export declare class DeleteAccountModalComponent {
23
23
  private auth;
24
24
  private errors;
25
25
  private i18n;
26
26
  private toast;
27
- /** Inyectado por `ModalService.open` — referencia para cerrar desde dentro. */
28
- _modalRef?: {
29
- dismiss: (data?: unknown, role?: string) => void;
30
- };
31
27
  /** Namespace i18n con que la vista resuelve sus textos. */
32
28
  i18nNamespace: string;
29
+ private _isOpen;
30
+ set isOpen(value: boolean);
31
+ get isOpen(): boolean;
32
+ dismissed: EventEmitter<void>;
33
33
  readonly hasPassword: import("@angular/core").WritableSignal<boolean>;
34
34
  readonly codeSent: import("@angular/core").WritableSignal<boolean>;
35
35
  readonly formState: import("@angular/core").WritableSignal<ComponentState>;
36
36
  constructor();
37
- ngOnInit(): void;
38
37
  t: (key: string) => string;
39
38
  private submitBtn;
40
39
  readonly passwordFormProps: import("@angular/core").Signal<FormMetadata>;
@@ -46,5 +45,5 @@ export declare class DeleteAccountModalComponent implements OnInit {
46
45
  onResendCode(): Promise<void>;
47
46
  onCodeSubmit(event: FormSubmit): Promise<void>;
48
47
  static ɵfac: i0.ɵɵFactoryDeclaration<DeleteAccountModalComponent, never>;
49
- static ɵcmp: i0.ɵɵComponentDeclaration<DeleteAccountModalComponent, "val-delete-account-modal", never, { "_modalRef": { "alias": "_modalRef"; "required": false; }; "i18nNamespace": { "alias": "i18nNamespace"; "required": false; }; }, {}, never, never, true, never>;
48
+ static ɵcmp: i0.ɵɵComponentDeclaration<DeleteAccountModalComponent, "val-delete-account-modal", never, { "i18nNamespace": { "alias": "i18nNamespace"; "required": false; }; "isOpen": { "alias": "isOpen"; "required": false; }; }, { "dismissed": "dismissed"; }, never, never, true, never>;
50
49
  }
@@ -1,6 +1,7 @@
1
1
  import { EventEmitter, OnDestroy } from '@angular/core';
2
2
  import { AuthService } from '../../../services/auth';
3
3
  import { FormMetadata, FormSubmit } from '../../types';
4
+ import { ImageMetadata } from '../../atoms/image/types';
4
5
  import { LoginMetadata, LoginSuccessEvent, LoginErrorEvent, MFARequiredEvent } from './types';
5
6
  import * as i0 from "@angular/core";
6
7
  export declare class LoginComponent implements OnDestroy {
@@ -35,6 +36,11 @@ export declare class LoginComponent implements OnDestroy {
35
36
  resendCooldown: number;
36
37
  resetResendCooldown: number;
37
38
  get config(): Required<Omit<LoginMetadata, 'logo' | 'legal' | 'redirectOnSuccess'>> & LoginMetadata;
39
+ /**
40
+ * Logo a renderizar arriba del form. Si el consumer no pasa `logo`, cae al
41
+ * default de marca del factory (`--main-logo` por app). Ver DEFAULT_LOGIN_LOGO.
42
+ */
43
+ get resolvedLogo(): ImageMetadata;
38
44
  private _loginFormState;
39
45
  private _registerFormState;
40
46
  private _verifyFormState;
@@ -68,3 +68,15 @@ export interface MFARequiredEvent {
68
68
  * Default values for LoginMetadata
69
69
  */
70
70
  export declare const LOGIN_DEFAULTS: Required<Omit<LoginMetadata, 'logo' | 'legal' | 'redirectOnSuccess'>>;
71
+ /**
72
+ * Logo por defecto de la card de login cuando el consumer no pasa `logo`.
73
+ *
74
+ * Usa el token CSS `--main-logo` (resuelto por `val-image` vía `var(--main-logo)`),
75
+ * que cada app del factory define en su `theme/variables.scss` con su logo de
76
+ * marca (incluye variante dark). Así el login muestra SIEMPRE el logo de la app
77
+ * sin acoplar la lib a una marca concreta — es el estándar del factory.
78
+ *
79
+ * Una app puede override pasando su propio `logo` en `LoginMetadata` (ej.
80
+ * showcase usa un mark propio `terminal.svg`).
81
+ */
82
+ export declare const DEFAULT_LOGIN_LOGO: ImageMetadata;
@@ -56,6 +56,7 @@ export declare class OrganizationViewComponent {
56
56
  readonly org: import("@angular/core").WritableSignal<Organization>;
57
57
  readonly loading: import("@angular/core").WritableSignal<boolean>;
58
58
  readonly leaving: import("@angular/core").WritableSignal<boolean>;
59
+ readonly permissionsOpen: import("@angular/core").WritableSignal<boolean>;
59
60
  private readonly orgLoadError;
60
61
  readonly orgErrorState: import("@angular/core").Signal<EmptyStateMetadata>;
61
62
  readonly members: import("@angular/core").WritableSignal<MemberDetail[]>;
@@ -0,0 +1,13 @@
1
+ import { EventEmitter } from '@angular/core';
2
+ import { PermissionsViewConfig } from './types';
3
+ import * as i0 from "@angular/core";
4
+ export declare class PermissionsModalComponent {
5
+ private i18n;
6
+ isOpen: boolean;
7
+ config?: PermissionsViewConfig;
8
+ dismissed: EventEmitter<void>;
9
+ close(): void;
10
+ t(key: string): string;
11
+ static ɵfac: i0.ɵɵFactoryDeclaration<PermissionsModalComponent, never>;
12
+ static ɵcmp: i0.ɵɵComponentDeclaration<PermissionsModalComponent, "val-permissions-modal", never, { "isOpen": { "alias": "isOpen"; "required": false; }; "config": { "alias": "config"; "required": false; }; }, { "dismissed": "dismissed"; }, never, never, true, never>;
13
+ }
@@ -1,3 +1,4 @@
1
+ import { OnInit } from '@angular/core';
1
2
  import { ButtonMetadata } from '../../types';
2
3
  import { PermissionsViewConfig } from './types';
3
4
  import * as i0 from "@angular/core";
@@ -35,7 +36,7 @@ interface RoleView {
35
36
  * sus defaults i18n (es/en) si el consumer no proveyó el namespace (default
36
37
  * `Settings.Permissions`).
37
38
  */
38
- export declare class PermissionsViewComponent {
39
+ export declare class PermissionsViewComponent implements OnInit {
39
40
  private i18n;
40
41
  private orgService;
41
42
  private catalog;
@@ -48,6 +49,11 @@ export declare class PermissionsViewComponent {
48
49
  * `resolvedConfig` mergea con los defaults — `@Input` gana sobre route data.
49
50
  */
50
51
  config?: PermissionsViewConfig;
52
+ /**
53
+ * Cuando `true`, la vista está embebida en un modal — suprime el back-header
54
+ * (lo gestiona el modal padre). Default `false` (uso como ruta).
55
+ */
56
+ isModal: boolean;
51
57
  readonly resolvedConfig: import("@angular/core").Signal<Required<PermissionsViewConfig>>;
52
58
  /** Namespace i18n resuelto (capturado para llamadas no-reactivas). */
53
59
  private get ns();
@@ -59,12 +65,13 @@ export declare class PermissionsViewComponent {
59
65
  readonly activeOrgId: import("@angular/core").Signal<string>;
60
66
  readonly retryButtonProps: import("@angular/core").Signal<Partial<ButtonMetadata>>;
61
67
  constructor();
68
+ ngOnInit(): void;
62
69
  load(): void;
63
70
  private buildRoleView;
64
71
  protected tt(key: string): string;
65
72
  appLabel(appId: string): string;
66
73
  roleLabel(name: string): string;
67
74
  static ɵfac: i0.ɵɵFactoryDeclaration<PermissionsViewComponent, never>;
68
- static ɵcmp: i0.ɵɵComponentDeclaration<PermissionsViewComponent, "val-permissions-view", never, { "config": { "alias": "config"; "required": false; }; }, {}, never, never, true, never>;
75
+ static ɵcmp: i0.ɵɵComponentDeclaration<PermissionsViewComponent, "val-permissions-view", never, { "config": { "alias": "config"; "required": false; }; "isModal": { "alias": "isModal"; "required": false; }; }, {}, never, never, true, never>;
69
76
  }
70
77
  export {};
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.27";
5
+ export declare const VERSION = "4.0.29";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "valtech-components",
3
- "version": "4.0.27",
3
+ "version": "4.0.29",
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
@@ -290,6 +290,7 @@ export * from './lib/components/organisms/notifications-view/notifications.route
290
290
  export * from './lib/components/organisms/notification-preferences-view/notification-preferences-view.component';
291
291
  export * from './lib/components/organisms/notification-preferences-view/types';
292
292
  export * from './lib/components/organisms/notification-preferences-view/notification-preferences.routes';
293
+ export * from './lib/components/organisms/permissions-view/permissions-modal.component';
293
294
  export * from './lib/components/organisms/permissions-view/permissions-view.component';
294
295
  export * from './lib/components/organisms/permissions-view/types';
295
296
  export * from './lib/components/organisms/permissions-view/permissions.routes';
@@ -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
+ }