valtech-components 4.0.228 → 4.0.229

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 (27) hide show
  1. package/esm2022/lib/components/molecules/chat-composer/chat-composer.component.mjs +410 -0
  2. package/esm2022/lib/components/molecules/chat-input/chat-input.component.mjs +1 -9
  3. package/esm2022/lib/components/molecules/conversation-list-item/conversation-list-item.component.mjs +108 -0
  4. package/esm2022/lib/components/molecules/message-bubble/message-bubble.component.mjs +274 -191
  5. package/esm2022/lib/components/molecules/typing-indicator/typing-indicator.component.mjs +11 -12
  6. package/esm2022/lib/components/organisms/chat-window/chat-window.component.mjs +216 -203
  7. package/esm2022/lib/components/organisms/thread-panel/thread-panel.component.mjs +10 -10
  8. package/esm2022/lib/services/chat/conversation.service.mjs +37 -14
  9. package/esm2022/lib/services/chat/types.mjs +1 -1
  10. package/esm2022/lib/services/i18n/default-content.mjs +5 -1
  11. package/esm2022/lib/shared/utils/datetime.mjs +54 -1
  12. package/esm2022/lib/version.mjs +2 -2
  13. package/esm2022/public-api.mjs +4 -2
  14. package/fesm2022/valtech-components.mjs +1099 -428
  15. package/fesm2022/valtech-components.mjs.map +1 -1
  16. package/lib/components/molecules/chat-composer/chat-composer.component.d.ts +69 -0
  17. package/lib/components/molecules/conversation-list-item/conversation-list-item.component.d.ts +30 -0
  18. package/lib/components/molecules/message-bubble/message-bubble.component.d.ts +34 -32
  19. package/lib/components/molecules/typing-indicator/typing-indicator.component.d.ts +5 -4
  20. package/lib/components/organisms/chat-window/chat-window.component.d.ts +52 -56
  21. package/lib/services/chat/conversation.service.d.ts +12 -5
  22. package/lib/services/chat/types.d.ts +86 -52
  23. package/lib/shared/utils/datetime.d.ts +19 -0
  24. package/lib/version.d.ts +1 -1
  25. package/package.json +1 -1
  26. package/public-api.d.ts +3 -1
  27. package/src/lib/services/firebase/firebase-messaging-sw.js +70 -125
@@ -0,0 +1,69 @@
1
+ import { OnDestroy } from '@angular/core';
2
+ import { MessageReplyTo } from '../../../services/chat/types';
3
+ import * as i0 from "@angular/core";
4
+ interface PendingAttachment {
5
+ id: number;
6
+ file: File;
7
+ url?: string;
8
+ isImage: boolean;
9
+ }
10
+ /**
11
+ * val-chat-composer — barra de redacción de chat moderna (signal inputs).
12
+ *
13
+ * Pill con: adjuntar (+), textarea auto-grow, y mic/enviar (mic cuando está vacío,
14
+ * enviar cuando hay texto o adjuntos). Los adjuntos (botón + / pegar imagen) se
15
+ * acumulan como PREVIEW (miniaturas) y se emiten por `(attach)` recién al ENVIAR
16
+ * — no se van solos al chat. Audio grabado se emite directo al parar.
17
+ * No incluye picker de emoji: el teclado del sistema ya lo trae.
18
+ */
19
+ export declare class ChatComposerComponent implements OnDestroy {
20
+ private i18n;
21
+ readonly placeholder: import("@angular/core").InputSignal<string>;
22
+ readonly disabled: import("@angular/core").InputSignal<boolean>;
23
+ readonly maxLength: import("@angular/core").InputSignal<number>;
24
+ readonly replyingTo: import("@angular/core").InputSignal<MessageReplyTo>;
25
+ readonly showAttach: import("@angular/core").InputSignal<boolean>;
26
+ readonly showMic: import("@angular/core").InputSignal<boolean>;
27
+ readonly send: import("@angular/core").OutputEmitterRef<string>;
28
+ readonly typing: import("@angular/core").OutputEmitterRef<void>;
29
+ readonly attach: import("@angular/core").OutputEmitterRef<File>;
30
+ readonly voice: import("@angular/core").OutputEmitterRef<void>;
31
+ readonly cancelReply: import("@angular/core").OutputEmitterRef<void>;
32
+ protected readonly body: import("@angular/core").WritableSignal<string>;
33
+ protected readonly pending: import("@angular/core").WritableSignal<PendingAttachment[]>;
34
+ private pendingId;
35
+ protected readonly recording: import("@angular/core").WritableSignal<boolean>;
36
+ private readonly recSeconds;
37
+ private recorder?;
38
+ private recStream?;
39
+ private recChunks;
40
+ private recTimer?;
41
+ protected readonly recTimeLabel: import("@angular/core").Signal<string>;
42
+ private lastTypingEmit;
43
+ constructor();
44
+ protected readonly canSend: import("@angular/core").Signal<boolean>;
45
+ protected readonly placeholderText: import("@angular/core").Signal<string>;
46
+ protected onInput(event: Event): void;
47
+ protected onKeydown(event: KeyboardEvent): void;
48
+ protected onSend(): void;
49
+ protected onFile(event: Event): void;
50
+ /** Pegar imagen desde el portapapeles (captura de pantalla, copiar imagen). */
51
+ protected onPaste(event: ClipboardEvent): void;
52
+ private addPending;
53
+ protected removePending(id: number): void;
54
+ /**
55
+ * Emite typing como máximo 1 vez cada 2s. performance.now es seguro en runtime.
56
+ */
57
+ private emitTypingDebounced;
58
+ /** Selecciona un mimeType de audio soportado por el navegador. */
59
+ private pickAudioMime;
60
+ protected startRecording(): Promise<void>;
61
+ protected stopAndSend(): void;
62
+ protected cancelRecording(): void;
63
+ private cleanupRecording;
64
+ ngOnDestroy(): void;
65
+ t(key: string): string;
66
+ static ɵfac: i0.ɵɵFactoryDeclaration<ChatComposerComponent, never>;
67
+ static ɵcmp: i0.ɵɵComponentDeclaration<ChatComposerComponent, "val-chat-composer", never, { "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "maxLength": { "alias": "maxLength"; "required": false; "isSignal": true; }; "replyingTo": { "alias": "replyingTo"; "required": false; "isSignal": true; }; "showAttach": { "alias": "showAttach"; "required": false; "isSignal": true; }; "showMic": { "alias": "showMic"; "required": false; "isSignal": true; }; }, { "send": "send"; "typing": "typing"; "attach": "attach"; "voice": "voice"; "cancelReply": "cancelReply"; }, never, never, true, never>;
68
+ }
69
+ export {};
@@ -0,0 +1,30 @@
1
+ import * as i0 from "@angular/core";
2
+ /**
3
+ * val-conversation-list-item — fila de lista de conversaciones estilo
4
+ * Telegram/WhatsApp: avatar (imagen o iniciales), nombre + hora relativa,
5
+ * preview del último mensaje + badge de no-leídos. Signal inputs, dark-safe.
6
+ *
7
+ * @example
8
+ * <val-conversation-list-item
9
+ * [name]="conv.name"
10
+ * [lastMessage]="conv.lastMsgPreview"
11
+ * [timestamp]="conv.lastMsgAt"
12
+ * [unreadCount]="conv.unread"
13
+ * (select)="open(conv.convId)" />
14
+ */
15
+ export declare class ConversationListItemComponent {
16
+ private i18n;
17
+ readonly name: import("@angular/core").InputSignal<string>;
18
+ readonly avatarUrl: import("@angular/core").InputSignal<string>;
19
+ readonly lastMessage: import("@angular/core").InputSignal<string>;
20
+ readonly timestamp: import("@angular/core").InputSignal<string | Date>;
21
+ readonly unreadCount: import("@angular/core").InputSignal<number>;
22
+ readonly locale: import("@angular/core").InputSignal<string>;
23
+ readonly select: import("@angular/core").OutputEmitterRef<void>;
24
+ constructor();
25
+ protected readonly initials: import("@angular/core").Signal<string>;
26
+ protected readonly timeLabel: import("@angular/core").Signal<string>;
27
+ protected emptyText(): string;
28
+ static ɵfac: i0.ɵɵFactoryDeclaration<ConversationListItemComponent, never>;
29
+ static ɵcmp: i0.ɵɵComponentDeclaration<ConversationListItemComponent, "val-conversation-list-item", never, { "name": { "alias": "name"; "required": false; "isSignal": true; }; "avatarUrl": { "alias": "avatarUrl"; "required": false; "isSignal": true; }; "lastMessage": { "alias": "lastMessage"; "required": false; "isSignal": true; }; "timestamp": { "alias": "timestamp"; "required": false; "isSignal": true; }; "unreadCount": { "alias": "unreadCount"; "required": false; "isSignal": true; }; "locale": { "alias": "locale"; "required": false; "isSignal": true; }; }, { "select": "select"; }, never, never, true, never>;
30
+ }
@@ -1,40 +1,42 @@
1
- import { EventEmitter, OnInit } from '@angular/core';
2
- import { I18nService } from '../../../services/i18n';
3
- import { MessageBubbleMetadata, MessageReactionClickEvent, MessageReplyClickEvent, MessageDeleteClickEvent, MessageEditClickEvent } from './types';
4
- import { MessageReaction } from '../../../services/chat/types';
1
+ import { MessageBubbleMetadata } from './types';
5
2
  import * as i0 from "@angular/core";
3
+ /** Acción disparada desde una burbuja. Un solo output tipado en vez de 4. */
4
+ export interface MessageBubbleAction {
5
+ type: 'reply' | 'edit' | 'delete' | 'react';
6
+ msgId: string;
7
+ /** Token del emoji, solo para type 'react'. */
8
+ token?: string;
9
+ }
6
10
  /**
7
- * val-message-bubble
11
+ * val-message-bubble — burbuja de mensaje presentacional (signal inputs).
8
12
  *
9
- * Burbuja de mensaje para el chat. Alineada a la derecha si isMine, a la izquierda si no.
10
- * Muestra nombre del emisor, cuerpo, timestamp, estado de envio, reacciones y acciones.
11
- * Si el mensaje fue eliminado muestra un texto en gris sin acciones.
13
+ * Sin lógica de negocio: el contenedor (`val-chat-window`) decide agrupación y
14
+ * pasa flags (showAvatar/showName/tail). Las acciones (responder/editar/borrar/
15
+ * reaccionar) NO están siempre visibles: se revelan en hover (desktop) o al tocar
16
+ * la burbuja (móvil), y se emiten por un único `(action)` tipado.
12
17
  *
13
- * @example
14
- * <val-message-bubble
15
- * [props]="msg"
16
- * (reactionClick)="onReaction($event)"
17
- * (replyClick)="onReply($event)"
18
- * (deleteClick)="onDelete($event)"
19
- * />
18
+ * Read receipts estilo WhatsApp: sending → reloj, sent → ✓, delivered/read → ✓✓
19
+ * (read en color), failed → alerta.
20
20
  */
21
- export declare class MessageBubbleComponent implements OnInit {
22
- protected i18n: I18nService;
23
- props: MessageBubbleMetadata;
24
- reactionClick: EventEmitter<MessageReactionClickEvent>;
25
- replyClick: EventEmitter<MessageReplyClickEvent>;
26
- deleteClick: EventEmitter<MessageDeleteClickEvent>;
27
- editClick: EventEmitter<MessageEditClickEvent>;
21
+ export declare class MessageBubbleComponent {
22
+ private i18n;
23
+ readonly msg: import("@angular/core").InputSignal<MessageBubbleMetadata>;
24
+ readonly showAvatar: import("@angular/core").InputSignal<boolean>;
25
+ readonly showName: import("@angular/core").InputSignal<boolean>;
26
+ readonly tail: import("@angular/core").InputSignal<boolean>;
27
+ readonly locale: import("@angular/core").InputSignal<string>;
28
+ readonly action: import("@angular/core").OutputEmitterRef<MessageBubbleAction>;
29
+ protected readonly actionsOpen: import("@angular/core").WritableSignal<boolean>;
28
30
  constructor();
29
- ngOnInit(): void;
30
- deletedText(): string;
31
- editedLabel(): string;
32
- formatTime(date: Date): string;
33
- statusIcon(): string;
34
- onReactionClick(reaction: MessageReaction): void;
35
- onReplyClick(): void;
36
- onDeleteClick(): void;
37
- onEditClick(): void;
31
+ protected readonly time: import("@angular/core").Signal<string>;
32
+ protected readonly initials: import("@angular/core").Signal<string>;
33
+ protected readonly imageAttachments: import("@angular/core").Signal<import("valtech-components").MessageAttachment[]>;
34
+ protected readonly audioAttachments: import("@angular/core").Signal<import("valtech-components").MessageAttachment[]>;
35
+ protected readonly fileAttachments: import("@angular/core").Signal<import("valtech-components").MessageAttachment[]>;
36
+ protected readonly statusIcon: import("@angular/core").Signal<"time-outline" | "alert-circle" | "checkmark-done" | "checkmark">;
37
+ protected toggleActions(): void;
38
+ protected emit(type: MessageBubbleAction['type'], token?: string): void;
39
+ t(key: string): string;
38
40
  static ɵfac: i0.ɵɵFactoryDeclaration<MessageBubbleComponent, never>;
39
- static ɵcmp: i0.ɵɵComponentDeclaration<MessageBubbleComponent, "val-message-bubble", never, { "props": { "alias": "props"; "required": false; }; }, { "reactionClick": "reactionClick"; "replyClick": "replyClick"; "deleteClick": "deleteClick"; "editClick": "editClick"; }, never, never, true, never>;
41
+ static ɵcmp: i0.ɵɵComponentDeclaration<MessageBubbleComponent, "val-message-bubble", never, { "msg": { "alias": "msg"; "required": true; "isSignal": true; }; "showAvatar": { "alias": "showAvatar"; "required": false; "isSignal": true; }; "showName": { "alias": "showName"; "required": false; "isSignal": true; }; "tail": { "alias": "tail"; "required": false; "isSignal": true; }; "locale": { "alias": "locale"; "required": false; "isSignal": true; }; }, { "action": "action"; }, never, never, true, never>;
40
42
  }
@@ -3,17 +3,18 @@ import * as i0 from "@angular/core";
3
3
  /**
4
4
  * val-typing-indicator
5
5
  *
6
- * Muestra quienes estan escribiendo en el chat con animacion de tres puntos.
7
- * Se oculta automaticamente si typingUsers esta vacio.
6
+ * Muestra quienes estan escribiendo con animacion de tres puntos. Se oculta
7
+ * si `typingUsers` esta vacio. Usa signal input para que `typingText` (computed)
8
+ * recompute al cambiar la lista.
8
9
  *
9
10
  * @example
10
11
  * <val-typing-indicator [typingUsers]="['Maria', 'Carlos']" />
11
12
  */
12
13
  export declare class TypingIndicatorComponent {
13
14
  protected i18n: I18nService;
14
- typingUsers: string[];
15
+ readonly typingUsers: import("@angular/core").InputSignal<string[]>;
15
16
  constructor();
16
17
  protected typingText: import("@angular/core").Signal<string>;
17
18
  static ɵfac: i0.ɵɵFactoryDeclaration<TypingIndicatorComponent, never>;
18
- static ɵcmp: i0.ɵɵComponentDeclaration<TypingIndicatorComponent, "val-typing-indicator", never, { "typingUsers": { "alias": "typingUsers"; "required": false; }; }, {}, never, never, true, never>;
19
+ static ɵcmp: i0.ɵɵComponentDeclaration<TypingIndicatorComponent, "val-typing-indicator", never, { "typingUsers": { "alias": "typingUsers"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
19
20
  }
@@ -1,68 +1,64 @@
1
- import { EventEmitter, OnChanges, OnDestroy, SimpleChanges, AfterViewChecked, AfterViewInit } from '@angular/core';
2
- import { I18nService } from '../../../services/i18n';
3
- import { MessageBubbleMetadata, MessageReactionClickEvent } from '../../molecules/message-bubble/types';
1
+ import { MessageReplyTo } from '../../../services/chat/types';
2
+ import { MessageBubbleAction } from '../../molecules/message-bubble/message-bubble.component';
3
+ import { MessageBubbleMetadata } from '../../molecules/message-bubble/types';
4
4
  import * as i0 from "@angular/core";
5
- /** Estructura interna para agrupar mensajes por fecha. */
6
- interface MessageGroup {
7
- dateLabel: string;
8
- messages: MessageBubbleMetadata[];
9
- }
5
+ type ChatRow = {
6
+ kind: 'date';
7
+ id: string;
8
+ label: string;
9
+ } | {
10
+ kind: 'msg';
11
+ id: string;
12
+ msg: MessageBubbleMetadata;
13
+ showName: boolean;
14
+ showAvatar: boolean;
15
+ tail: boolean;
16
+ };
10
17
  /**
11
- * val-chat-window
18
+ * val-chat-window — ventana de chat completa (signal inputs).
12
19
  *
13
- * Ventana de chat completa. Muestra la lista de mensajes agrupados por fecha,
14
- * el indicador de escritura, el input de mensaje (solo si isOpen) y un banner
15
- * cuando la conversacion esta cerrada. Auto-scroll al ultimo mensaje cuando
16
- * llegan mensajes nuevos.
20
+ * Agrupa mensajes consecutivos del mismo emisor y por día (separadores sticky),
21
+ * muestra avatar/nombre solo en los bordes del grupo, scroll-to-bottom inteligente
22
+ * (auto-scroll si estás abajo, pill "mensajes nuevos" si estás leyendo arriba),
23
+ * composer moderno con contexto de respuesta, y typing indicator.
17
24
  *
18
- * @example
19
- * <val-chat-window
20
- * [convId]="conv.id"
21
- * [messages]="messages()"
22
- * [currentUserId]="userId"
23
- * [isOpen]="conv.status === 'open'"
24
- * [typingUsers]="typingUsers()"
25
- * (sendMessage)="onSend($event)"
26
- * (reactionClick)="onReaction($event)"
27
- * />
25
+ * API pública estable (consumida por thread-panel y showcase): inputs convId,
26
+ * messages, currentUserId, isOpen, typingUsers, isLoading; outputs sendMessage,
27
+ * loadMore, reactionClick, deleteMessage, replyTo (+ editMessage/attach/voice nuevos).
28
28
  */
29
- export declare class ChatWindowComponent implements OnChanges, AfterViewInit, AfterViewChecked, OnDestroy {
30
- protected i18n: I18nService;
31
- convId: string;
32
- messages: MessageBubbleMetadata[];
33
- participants: string[];
34
- currentUserId: string;
35
- isOpen: boolean;
36
- typingUsers: string[];
37
- isLoading: boolean;
38
- sendMessage: EventEmitter<string>;
39
- loadMore: EventEmitter<void>;
40
- reactionClick: EventEmitter<{
29
+ export declare class ChatWindowComponent {
30
+ private i18n;
31
+ readonly convId: import("@angular/core").InputSignal<string>;
32
+ readonly messages: import("@angular/core").InputSignal<MessageBubbleMetadata[]>;
33
+ readonly currentUserId: import("@angular/core").InputSignal<string>;
34
+ readonly isOpen: import("@angular/core").InputSignal<boolean>;
35
+ readonly typingUsers: import("@angular/core").InputSignal<string[]>;
36
+ readonly isLoading: import("@angular/core").InputSignal<boolean>;
37
+ readonly sendMessage: import("@angular/core").OutputEmitterRef<string>;
38
+ readonly loadMore: import("@angular/core").OutputEmitterRef<void>;
39
+ readonly reactionClick: import("@angular/core").OutputEmitterRef<{
41
40
  msgId: string;
42
41
  token: string;
43
42
  }>;
44
- deleteMessage: EventEmitter<string>;
45
- replyTo: EventEmitter<string>;
46
- private messagesListRef?;
47
- private chatWindowElRef?;
48
- private prevMessageCount;
49
- private shouldScrollToBottom;
50
- private vvListener?;
43
+ readonly deleteMessage: import("@angular/core").OutputEmitterRef<string>;
44
+ readonly replyTo: import("@angular/core").OutputEmitterRef<string>;
45
+ readonly editMessage: import("@angular/core").OutputEmitterRef<string>;
46
+ readonly typing: import("@angular/core").OutputEmitterRef<void>;
47
+ readonly attach: import("@angular/core").OutputEmitterRef<File>;
48
+ readonly voice: import("@angular/core").OutputEmitterRef<void>;
49
+ private readonly msgsEl;
50
+ protected readonly replyingTo: import("@angular/core").WritableSignal<MessageReplyTo>;
51
+ protected readonly atBottom: import("@angular/core").WritableSignal<boolean>;
52
+ protected readonly hasNew: import("@angular/core").WritableSignal<boolean>;
53
+ protected readonly locale: import("@angular/core").Signal<"es-CL" | "en-US">;
51
54
  constructor();
52
- ngAfterViewInit(): void;
53
- ngOnDestroy(): void;
54
- ngOnChanges(changes: SimpleChanges): void;
55
- ngAfterViewChecked(): void;
56
- private adjustToKeyboard;
57
- protected messageGroups: import("@angular/core").Signal<MessageGroup[]>;
58
- protected closedText: import("@angular/core").Signal<string>;
59
- protected loadingText: import("@angular/core").Signal<string>;
60
- protected onReactionClick(event: MessageReactionClickEvent): void;
61
- protected onEditClick(_msgId: string): void;
62
- protected onTyping(): void;
63
- private scrollToBottom;
64
- private formatDateLabel;
55
+ protected readonly rows: import("@angular/core").Signal<ChatRow[]>;
56
+ protected onScroll(): void;
57
+ protected scrollToBottom(smooth: boolean): void;
58
+ protected onSend(body: string): void;
59
+ protected onAction(event: MessageBubbleAction): void;
60
+ t(key: string): string;
65
61
  static ɵfac: i0.ɵɵFactoryDeclaration<ChatWindowComponent, never>;
66
- static ɵcmp: i0.ɵɵComponentDeclaration<ChatWindowComponent, "val-chat-window", never, { "convId": { "alias": "convId"; "required": false; }; "messages": { "alias": "messages"; "required": false; }; "participants": { "alias": "participants"; "required": false; }; "currentUserId": { "alias": "currentUserId"; "required": false; }; "isOpen": { "alias": "isOpen"; "required": false; }; "typingUsers": { "alias": "typingUsers"; "required": false; }; "isLoading": { "alias": "isLoading"; "required": false; }; }, { "sendMessage": "sendMessage"; "loadMore": "loadMore"; "reactionClick": "reactionClick"; "deleteMessage": "deleteMessage"; "replyTo": "replyTo"; }, never, never, true, never>;
62
+ static ɵcmp: i0.ɵɵComponentDeclaration<ChatWindowComponent, "val-chat-window", never, { "convId": { "alias": "convId"; "required": false; "isSignal": true; }; "messages": { "alias": "messages"; "required": false; "isSignal": true; }; "currentUserId": { "alias": "currentUserId"; "required": false; "isSignal": true; }; "isOpen": { "alias": "isOpen"; "required": false; "isSignal": true; }; "typingUsers": { "alias": "typingUsers"; "required": false; "isSignal": true; }; "isLoading": { "alias": "isLoading"; "required": false; "isSignal": true; }; }, { "sendMessage": "sendMessage"; "loadMore": "loadMore"; "reactionClick": "reactionClick"; "deleteMessage": "deleteMessage"; "replyTo": "replyTo"; "editMessage": "editMessage"; "typing": "typing"; "attach": "attach"; "voice": "voice"; }, never, never, true, never>;
67
63
  }
68
64
  export {};
@@ -1,5 +1,5 @@
1
1
  import { Observable } from 'rxjs';
2
- import { Conversation, ConversationType, CreateConversationRequest, ListConversationsResponse, Message, UpdateConversationRequest } from './types';
2
+ import { Conversation, ConversationType, CreateConversationRequest, ListConversationsResponse, Message, MessageAttachment, UpdateConversationRequest } from './types';
3
3
  import * as i0 from "@angular/core";
4
4
  /**
5
5
  * ConversationService
@@ -33,12 +33,17 @@ export declare class ConversationService {
33
33
  private get baseUrl();
34
34
  /**
35
35
  * Crea una nueva conversacion.
36
+ * El backend responde con un envelope { operationId, conversation } — lo
37
+ * desenvolvemos para devolver la Conversation directa.
36
38
  */
37
39
  createConversation(req: CreateConversationRequest): Observable<Conversation>;
38
40
  /**
39
- * Obtiene o crea una conversacion asociada a una entidad (post, request, etc.).
41
+ * Obtiene o crea una conversacion asociada a una entidad (post, request, org, etc.).
40
42
  * Usa el patron upsert del backend: si ya existe una conversacion para esa entidad,
41
43
  * la devuelve; si no, la crea.
44
+ *
45
+ * El backend espera { entityRef: { type, id }, type } y responde con un envelope
46
+ * { operationId, conversation, created }.
42
47
  */
43
48
  getOrCreateForEntity(entityType: string, entityId: string, type?: ConversationType): Observable<Conversation>;
44
49
  /**
@@ -50,7 +55,7 @@ export declare class ConversationService {
50
55
  */
51
56
  getConversation(convId: string): Observable<Conversation>;
52
57
  /**
53
- * Actualiza el titulo o estado de una conversacion.
58
+ * Actualiza el nombre o settings de una conversacion.
54
59
  */
55
60
  updateConversation(convId: string, req: UpdateConversationRequest): Observable<Conversation>;
56
61
  /**
@@ -70,9 +75,11 @@ export declare class ConversationService {
70
75
  */
71
76
  removeParticipant(convId: string, userId: string): Observable<void>;
72
77
  /**
73
- * Envia un mensaje a una conversacion.
78
+ * Envia un mensaje a una conversacion, opcionalmente con adjuntos.
79
+ * El backend espera `attachments: { url, type, name, size }[]` (key `type` = MIME),
80
+ * mientras que el front usa `mimeType` — se mapea aqui.
74
81
  */
75
- sendMessage(convId: string, body: string): Observable<Message>;
82
+ sendMessage(convId: string, body: string, attachments?: MessageAttachment[]): Observable<Message>;
76
83
  /**
77
84
  * Elimina (marca como eliminado) un mensaje.
78
85
  */
@@ -7,50 +7,75 @@
7
7
  * /apps/{appId}/orgs/{orgId}/conversations/{convId}/typing/{userId}
8
8
  */
9
9
  import { FirestoreDocument } from '../firebase/types';
10
- /** Tipo de conversacion. */
11
- export type ConversationType = 'direct' | 'group' | 'entity';
12
- /** Estado de una conversacion. */
13
- export type ConversationStatus = 'open' | 'closed';
14
- /** Participante de una conversacion. */
15
- export interface ConversationParticipant {
16
- /** ID del usuario. */
17
- userId: string;
18
- /** Nombre visible del usuario. */
19
- displayName: string;
20
- /** URL del avatar del usuario (opcional). */
21
- avatarUrl?: string;
22
- /** Fecha en que se unio a la conversacion. */
23
- joinedAt: Date;
24
- /** Ultimo mensaje leido por este participante. */
25
- lastReadMsgId?: string;
10
+ /**
11
+ * Tipo de conversacion. Debe coincidir con el backend (services/conversation):
12
+ * thread = comentarios en entidad · group = canal grupal · dm = 1:1 directo.
13
+ */
14
+ export type ConversationType = 'thread' | 'group' | 'dm';
15
+ /** Visibilidad de una conversacion (quien puede unirse). */
16
+ export type ConvVisibility = 'org' | 'private' | 'public' | '';
17
+ /** Vinculo de la conversacion con una entidad del dominio. */
18
+ export interface EntityRef {
19
+ /** Tipo de entidad ('post' | 'request' | 'org' | 'custom', etc.). */
20
+ type: string;
21
+ /** ID de la entidad. */
22
+ id: string;
26
23
  }
27
- /** Documento de conversacion en Firestore. */
28
- export interface Conversation extends FirestoreDocument {
24
+ /** Configuracion de la conversacion. */
25
+ export interface ConvSettings {
26
+ /** Si la conversacion esta abierta para enviar mensajes. */
27
+ isOpen: boolean;
28
+ /** Quien puede unirse. */
29
+ visibility: ConvVisibility;
30
+ /** Si admite participantes anonimos. */
31
+ allowAnonymous: boolean;
32
+ /** Si requiere membresia de la org. */
33
+ requireMembership: boolean;
34
+ /** Maximo de participantes (0 = sin limite). */
35
+ maxParticipants: number;
36
+ }
37
+ /**
38
+ * Documento de conversacion. Refleja el contrato del backend
39
+ * (services/conversation/types.go) — la fuente de verdad es DynamoDB y el doc se
40
+ * proyecta a Firestore para las reglas de membresia. Por eso los campos son
41
+ * `convId`/`name`/`participants: string[]` y NO el shape antiguo.
42
+ */
43
+ export interface Conversation {
44
+ /** ID de la conversacion. */
45
+ convId: string;
29
46
  /** Tipo de conversacion. */
30
47
  type: ConversationType;
31
- /** Estado de la conversacion. */
32
- status: ConversationStatus;
33
- /** Participantes. */
34
- participants: ConversationParticipant[];
35
- /** Tipo de entidad asociada (para tipo entity). */
36
- entityType?: string;
37
- /** ID de la entidad asociada. */
38
- entityId?: string;
39
- /** Titulo de la conversacion (para grupos). */
40
- title?: string;
41
- /** ID del ultimo mensaje. */
42
- lastMsgId?: string;
43
- /** Texto del ultimo mensaje (preview). */
44
- lastMsgBody?: string;
45
- /** Fecha del ultimo mensaje. */
46
- lastMsgAt?: Date;
47
- /** Conteo de mensajes no leidos por userId. */
48
- unreadCount?: Record<string, number>;
48
+ /** ID de la app. */
49
+ appId: string;
50
+ /** ID de la org. */
51
+ orgId: string;
52
+ /** Nombre de la conversacion (para grupos). */
53
+ name?: string;
54
+ /** Entidad asociada (para tipo thread). */
55
+ entityRef?: EntityRef;
56
+ /** IDs de los participantes. */
57
+ participants: string[];
58
+ /** Configuracion. */
59
+ settings: ConvSettings;
60
+ /** ID del usuario que la creo. */
61
+ createdBy: string;
62
+ /** Fecha de creacion (ISO string). */
63
+ createdAt: string;
64
+ /** Fecha de ultima actualizacion (ISO string). */
65
+ updatedAt: string;
66
+ /** Fecha del ultimo mensaje (ISO string). */
67
+ lastMsgAt?: string;
68
+ /** Preview del ultimo mensaje. */
69
+ lastMsgPreview?: string;
49
70
  }
50
71
  /** Tipo de mensaje. */
51
72
  export type MessageType = 'text' | 'image' | 'file' | 'system';
52
- /** Estado de envio del mensaje. */
53
- export type MessageStatus = 'sending' | 'sent' | 'failed';
73
+ /**
74
+ * Estado de envio/entrega de un mensaje (para read receipts estilo WhatsApp):
75
+ * sending → reloj · sent → ✓ · delivered → ✓✓ gris · read → ✓✓ primary · failed → alerta.
76
+ * El backend hoy solo emite hasta `sent`; los demas estan soportados para el futuro.
77
+ */
78
+ export type MessageStatus = 'sending' | 'sent' | 'delivered' | 'read' | 'failed';
54
79
  /** Archivo adjunto en un mensaje. */
55
80
  export interface MessageAttachment {
56
81
  /** Nombre del archivo. */
@@ -118,28 +143,37 @@ export interface TypingDocument extends FirestoreDocument {
118
143
  export interface CreateConversationRequest {
119
144
  /** Tipo de conversacion. */
120
145
  type: ConversationType;
121
- /** IDs de los participantes iniciales. */
122
- participantIds?: string[];
123
- /** Para tipo entity: tipo de la entidad. */
124
- entityType?: string;
125
- /** Para tipo entity: ID de la entidad. */
126
- entityId?: string;
127
- /** Titulo (para grupos). */
128
- title?: string;
146
+ /** Nombre (para grupos). */
147
+ name?: string;
148
+ /** Entidad asociada (para tipo thread). */
149
+ entityRef?: EntityRef;
150
+ /** IDs de los participantes iniciales (ademas del creador). */
151
+ participants?: string[];
152
+ /** Configuracion inicial. */
153
+ settings?: Partial<ConvSettings>;
129
154
  }
130
155
  /** Request para actualizar una conversacion. */
131
156
  export interface UpdateConversationRequest {
132
- /** Nuevo titulo (opcional). */
133
- title?: string;
134
- /** Nuevo estado (opcional). */
135
- status?: ConversationStatus;
157
+ /** Nuevo nombre (opcional). */
158
+ name?: string;
159
+ /** Nueva configuracion (opcional). */
160
+ settings?: Partial<ConvSettings>;
161
+ }
162
+ /** Response que envuelve una sola conversacion (create / get / update / get-or-create). */
163
+ export interface ConversationResponse {
164
+ /** ID de operacion para tracing. */
165
+ operationId: string;
166
+ /** La conversacion. */
167
+ conversation: Conversation;
168
+ /** Si fue creada en esta llamada (solo get-or-create). */
169
+ created?: boolean;
136
170
  }
137
171
  /** Response de listado de conversaciones. */
138
172
  export interface ListConversationsResponse {
173
+ /** ID de operacion para tracing. */
174
+ operationId: string;
139
175
  /** Lista de conversaciones. */
140
176
  conversations: Conversation[];
141
177
  /** Cursor para paginacion. */
142
178
  nextCursor?: string;
143
- /** Si hay mas paginas. */
144
- hasMore: boolean;
145
179
  }
@@ -19,3 +19,22 @@ export type TimeOfDayKey = 'goodMorning' | 'goodAfternoon' | 'goodEvening';
19
19
  * const text = i18n.t(key); // 'Buenos días' | 'Buenas tardes' | 'Buenas noches'
20
20
  */
21
21
  export declare function getTimeOfDayKey(date?: Date): TimeOfDayKey;
22
+ /** Hora corta local, ej. "14:05". */
23
+ export declare function formatClockTime(value: Date | string | undefined | null, locale?: string): string;
24
+ /**
25
+ * Etiqueta corta para listas de conversaciones (estilo Telegram/WhatsApp):
26
+ * hoy → hora ("14:05"), ayer → label `yesterday`, esta semana → día de semana,
27
+ * más viejo → fecha corta. `labels.today/yesterday` se inyectan ya traducidos.
28
+ */
29
+ export declare function formatRelativeTime(value: Date | string | undefined | null, locale?: string, labels?: {
30
+ today?: string;
31
+ yesterday?: string;
32
+ }): string;
33
+ /**
34
+ * Etiqueta para separadores de fecha dentro de un chat: "Hoy" / "Ayer" /
35
+ * fecha larga ("12 de junio de 2026"). `labels.today/yesterday` ya traducidos.
36
+ */
37
+ export declare function formatDateSeparator(value: Date | string | undefined | null, locale?: string, labels?: {
38
+ today?: string;
39
+ yesterday?: string;
40
+ }): string;
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.228";
5
+ export declare const VERSION = "4.0.229";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "valtech-components",
3
- "version": "4.0.228",
3
+ "version": "4.0.229",
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
@@ -474,10 +474,12 @@ export { ConversationService } from './lib/services/chat/conversation.service';
474
474
  export { provideValtechChat, VALTECH_CHAT_CONFIG } from './lib/services/chat/config';
475
475
  export type { ValtechChatConfig } from './lib/services/chat/config';
476
476
  export * from './lib/services/chat/types';
477
- export { MessageBubbleComponent } from './lib/components/molecules/message-bubble/message-bubble.component';
477
+ export { MessageBubbleComponent, type MessageBubbleAction, } from './lib/components/molecules/message-bubble/message-bubble.component';
478
478
  export * from './lib/components/molecules/message-bubble/types';
479
479
  export { ChatInputComponent } from './lib/components/molecules/chat-input/chat-input.component';
480
480
  export * from './lib/components/molecules/chat-input/types';
481
+ export { ChatComposerComponent } from './lib/components/molecules/chat-composer/chat-composer.component';
482
+ export { ConversationListItemComponent } from './lib/components/molecules/conversation-list-item/conversation-list-item.component';
481
483
  export { TypingIndicatorComponent } from './lib/components/molecules/typing-indicator/typing-indicator.component';
482
484
  export { ChatWindowComponent } from './lib/components/organisms/chat-window/chat-window.component';
483
485
  export * from './lib/components/organisms/chat-window/types';