@trii/components 3.1.12 → 3.1.13

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/dist/index.d.ts CHANGED
@@ -572,6 +572,23 @@ declare class PanelErrorBoundary extends Component<PanelErrorBoundaryProps, Pane
572
572
  render(): ReactNode;
573
573
  }
574
574
 
575
+ /**
576
+ * Contrato de entrada del sidebar (docs/CONTRATO_CHATDETAILSSIDEBAR.md).
577
+ * El container del host resuelve estos valores desde Redux; el árbol interno
578
+ * los consume desde acá en lugar de tocar el store del host. Al migrar el
579
+ * sidebar a @trii/components, este context viaja con él tal cual.
580
+ */
581
+ interface SidebarApiConfig {
582
+ /** Raíz de la API (ej: https://agent-api.trii.app/api/v1), sin servicio ni spaceId. */
583
+ baseUrl: string;
584
+ spaceId: string;
585
+ }
586
+ /** When supplied, the host owns loading and supplies the entity through props. */
587
+ interface SidebarEntityLoad {
588
+ status: 'idle' | 'loading' | 'succeeded' | 'rejected';
589
+ error?: string | null;
590
+ retry: () => Promise<void> | void;
591
+ }
575
592
  /**
576
593
  * Integración con un inbox de chat. Es opcional: sin ella el sidebar funciona
577
594
  * en "modo ficha" (sin GroupData, sin abrir conversaciones, sin iniciar una
@@ -591,6 +608,53 @@ interface SidebarChatIntegration {
591
608
  /** El usuario salió del grupo: el host cierra/limpia la conversación. */
592
609
  onGroupLeft: (conversationId: string) => void;
593
610
  }
611
+ interface SidebarProps {
612
+ api: SidebarApiConfig;
613
+ contactId: string | null;
614
+ entityType: 'contact' | 'business';
615
+ /**
616
+ * false cuando el host no pasó `chat`: los callbacks de abajo son no-ops y la
617
+ * UI que depende del inbox se deshabilita.
618
+ */
619
+ hasChatIntegration: boolean;
620
+ /**
621
+ * Ficha ya resuelta por el host, si la tiene: solo siembra el estado inicial
622
+ * para que no parpadee. Con entityLoad es la entidad controlada; sin él se refetchea.
623
+ */
624
+ initialEntity?: IContact | IBusiness | null;
625
+ entityLoad?: SidebarEntityLoad;
626
+ /** Conversación seleccionada en el host, si hay (tab conversaciones, GroupData). */
627
+ conversation: IConversation | null;
628
+ /** Para el EditContactModal embebido (búsqueda de direcciones). */
629
+ googleMapsApiKey?: string;
630
+ /**
631
+ * Navegación del anfitrión. Sin ella se usa window.location.assign: los
632
+ * destinos son rutas de otro microfront, no internas del sidebar.
633
+ */
634
+ navigate?: (path: string) => void;
635
+ /** Ticket que se está viendo en el host: el tab Tickets lo lista marcado y sin click. */
636
+ currentTicketId?: string;
637
+ /**
638
+ * Abrir un ticket del contacto. Sin ella el tab Tickets navega a
639
+ * /a/tickets/detail/{id} con `navigate` (o window.location.assign).
640
+ */
641
+ onOpenTicket?: (ticketId: string) => void;
642
+ /** Abrir/cambiar a una conversación del contacto en el inbox. */
643
+ onOpenConversation: (conversation: IConversation) => Promise<void> | void;
644
+ /** Navegar/scrollear a un mensaje en el body del chat. */
645
+ onNavigateToMessage: (messageId: string) => void;
646
+ /**
647
+ * El contacto/empresa cambió (edición, convert, etc.): el host sincroniza su
648
+ * estado. Es no-op si el host no la pasó.
649
+ */
650
+ onEntityUpdated: (entity: IContact | IBusiness) => void;
651
+ /** La conversación cambió (grupo WA editado): el host sincroniza Redux + Dexie. */
652
+ onConversationUpdated: (conversation: IConversation) => void;
653
+ /** El usuario salió del grupo: el host cierra/limpia la conversación. */
654
+ onGroupLeft: (conversationId: string) => void;
655
+ /** "Chatear por este canal/dirección": arma el composer del host. */
656
+ onStartConversation: (target: StartConversationTarget) => void;
657
+ }
594
658
  interface StartConversationTarget {
595
659
  channelType: ChannelType;
596
660
  addressId: string;
@@ -599,6 +663,8 @@ interface StartConversationTarget {
599
663
  }
600
664
 
601
665
  interface ChatDetailsSidebarBaseProps {
666
+ /** Controlled loading: entity/initialEntity updates are consumed without an automatic fetch. */
667
+ entityLoad?: SidebarProps['entityLoad'];
602
668
  /** Raíz de la API (ej: https://agent-api.trii.app/api/v1), sin servicio ni spaceId. */
603
669
  baseUrl: string;
604
670
  spaceId: string;
@@ -1,6 +1,8 @@
1
- import { SidebarChatIntegration, StartConversationTarget } from './context/SidebarPropsContext';
1
+ import { SidebarChatIntegration, SidebarProps, StartConversationTarget } from './context/SidebarPropsContext';
2
2
  import { IContact, IBusiness } from '@trii/types/dist/Contacts';
3
3
  interface ChatDetailsSidebarBaseProps {
4
+ /** Controlled loading: entity/initialEntity updates are consumed without an automatic fetch. */
5
+ entityLoad?: SidebarProps['entityLoad'];
4
6
  /** Raíz de la API (ej: https://agent-api.trii.app/api/v1), sin servicio ni spaceId. */
5
7
  baseUrl: string;
6
8
  spaceId: string;
@@ -5,6 +5,7 @@ import { IBusiness, IContact } from '@trii/types/dist/Contacts';
5
5
  * (contactInfo, showSkeleton, contactInfoError, onRetryContactInfo); ahora el
6
6
  * sidebar la fetchea con el contactId + entityType del contrato. El host puede
7
7
  * sembrarla con initialEntity para que no haya parpadeo cuando ya la tiene.
8
+ * Con entityLoad, el host controla la ficha, su carga y los reintentos.
8
9
  */
9
10
  export type EntityStatus = 'idle' | 'loading' | 'succeeded' | 'rejected';
10
11
  export interface SidebarEntityValue {
@@ -13,6 +13,12 @@ export interface SidebarApiConfig {
13
13
  baseUrl: string;
14
14
  spaceId: string;
15
15
  }
16
+ /** When supplied, the host owns loading and supplies the entity through props. */
17
+ export interface SidebarEntityLoad {
18
+ status: 'idle' | 'loading' | 'succeeded' | 'rejected';
19
+ error?: string | null;
20
+ retry: () => Promise<void> | void;
21
+ }
16
22
  /**
17
23
  * Integración con un inbox de chat. Es opcional: sin ella el sidebar funciona
18
24
  * en "modo ficha" (sin GroupData, sin abrir conversaciones, sin iniciar una
@@ -43,9 +49,10 @@ export interface SidebarProps {
43
49
  hasChatIntegration: boolean;
44
50
  /**
45
51
  * Ficha ya resuelta por el host, si la tiene: solo siembra el estado inicial
46
- * para que no parpadee. El sidebar la fetchea igual (SidebarEntityContext).
52
+ * para que no parpadee. Con entityLoad es la entidad controlada; sin él se refetchea.
47
53
  */
48
54
  initialEntity?: IContact | IBusiness | null;
55
+ entityLoad?: SidebarEntityLoad;
49
56
  /** Conversación seleccionada en el host, si hay (tab conversaciones, GroupData). */
50
57
  conversation: IConversation | null;
51
58
  /** Para el EditContactModal embebido (búsqueda de direcciones). */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trii/components",
3
- "version": "3.1.12",
3
+ "version": "3.1.13",
4
4
  "description": "Trii components package",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",