@adatechnology/conversations-ui 0.15.1 → 0.17.0

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 (39) hide show
  1. package/README.md +23 -0
  2. package/dist/{ConversationSimulatorPanel-P6eqTSAO.d.ts → ConversationSimulatorPanel-DSVIch04.d.ts} +3 -1
  3. package/dist/{chunk-Y326LLEP.js → chunk-7OLYCCLX.js} +1 -1
  4. package/dist/{chunk-WCZNIJ3M.js → chunk-Z7U22M3K.js} +7 -0
  5. package/dist/flows/index.d.ts +90 -7
  6. package/dist/flows/index.js +1151 -455
  7. package/dist/index.d.ts +36 -5
  8. package/dist/index.js +88 -23
  9. package/dist/participant/index.js +1 -1
  10. package/dist/preview/index.d.ts +13 -29
  11. package/dist/preview/index.js +2 -2
  12. package/package.json +2 -2
  13. package/src/flows/FlowKeywordRoutesField.tsx +105 -0
  14. package/src/flows/FlowLegend.tsx +2 -2
  15. package/src/flows/FlowNodeCard.tsx +39 -10
  16. package/src/flows/FlowNodePanel.tsx +34 -10
  17. package/src/flows/FlowPalette.tsx +25 -2
  18. package/src/flows/FlowPossibleNextField.tsx +89 -0
  19. package/src/flows/FlowRunnerFields.tsx +321 -0
  20. package/src/flows/FlowWhatsAppPreview.tsx +39 -6
  21. package/src/flows/flowCanvasModel.test.ts +3 -2
  22. package/src/flows/flowCanvasModel.ts +28 -1
  23. package/src/flows/flowEditorOps.ts +41 -4
  24. package/src/flows/flowGraph.ts +124 -21
  25. package/src/flows/flowPanelStyles.ts +11 -0
  26. package/src/flows/flowPossibleNext.test.ts +70 -0
  27. package/src/flows/flowRunnerEditor.test.ts +116 -0
  28. package/src/flows/labels.ts +116 -2
  29. package/src/index.ts +2 -1
  30. package/src/lib/phone.test.ts +20 -0
  31. package/src/lib/phone.ts +13 -0
  32. package/src/preview/createPreviewBridgeClient.test.ts +23 -0
  33. package/src/preview/createPreviewBridgeClient.ts +13 -8
  34. package/src/preview/createPreviewWebhookClient.ts +2 -0
  35. package/src/workspace/ConversationPane.tsx +13 -2
  36. package/src/workspace/ConversationsWorkspace.tsx +117 -18
  37. package/src/workspace/index.ts +1 -0
  38. package/src/workspace/labels.ts +2 -0
  39. package/src/workspace/workspaceTestContactDom.test.tsx +96 -0
package/dist/index.d.ts CHANGED
@@ -2,8 +2,8 @@ import * as react from 'react';
2
2
  import react__default, { ReactNode, CSSProperties, UIEvent, FormEvent, RefObject, KeyboardEvent } from 'react';
3
3
  import { M as MessagePayload, I as InteractiveSelection, a as MessageTranscription, C as ConversationChannel, e as InteractivePayload, f as ConversationsFeatures, Q as QuickReply$1, T as TranscriptionMode, g as QueuedAttachment, b as QuickReplyInput, c as QuickReplyAttachment, h as ConversationVariable, i as ChannelFilter, j as ChannelFilterOption } from './quickReply.types-DzWH3NYV.js';
4
4
  export { k as CHANNEL_CAPABILITIES, l as CHANNEL_FILTER_ALL, m as CONVERSATION_CHANNEL, n as ChannelCapabilities, d as ConversationsTheme, o as ConversationsUIConfig, D as DEFAULT_CONVERSATION_CHANNEL, F as FormatContactHandleParams, H as HANDLE_KIND, p as HandleKind, q as InteractiveOption, r as InteractiveSection, s as QUICK_REPLY_ATTACHMENT_LIMIT, R as REOPEN_MECHANISM, t as ReopenMechanism, S as StoredAttachmentSendResult, u as TranscriptionStatus, v as capabilitiesOf, w as channelFiltersFor, x as contactFlag, y as formatContactHandle } from './quickReply.types-DzWH3NYV.js';
5
- import { R as ResolveMediaUrl, C as ConversationSummary, L as ListConversationsParams, b as ConversationsApi, S as SSEProvider, Q as ListDocumentsParams, d as ConversationDocument, U as ConversationTemplate, k as ConversationSimulatorClient, m as ConversationSimulatorPanelLabels, P as PreviewUploadedMedia } from './ConversationSimulatorPanel-P6eqTSAO.js';
6
- export { A as AudioRecorderButton, g as AudioRecorderButtonLabels, h as AudioRecorderButtonProps, V as CompanyDocument, W as CompanyDocumentPage, X as ConversationDocumentPage, a as ConversationEventSource, c as ConversationPage, D as DEFAULT_AUDIO_RECORDER_BUTTON_LABELS, Y as MediaRenderer, Z as MediaRendererProps, y as SendSimulatorMediaParams, z as SimulatorMediaKind } from './ConversationSimulatorPanel-P6eqTSAO.js';
5
+ import { R as ResolveMediaUrl, C as ConversationSummary, L as ListConversationsParams, b as ConversationsApi, S as SSEProvider, Q as ListDocumentsParams, d as ConversationDocument, U as ConversationTemplate, j as ConversationSimulatorClient, l as ConversationSimulatorPanelLabels, P as PreviewUploadedMedia } from './ConversationSimulatorPanel-DSVIch04.js';
6
+ export { A as AudioRecorderButton, f as AudioRecorderButtonLabels, g as AudioRecorderButtonProps, V as CompanyDocument, W as CompanyDocumentPage, X as ConversationDocumentPage, a as ConversationEventSource, c as ConversationPage, D as DEFAULT_AUDIO_RECORDER_BUTTON_LABELS, Y as MediaRenderer, Z as MediaRendererProps, y as SendSimulatorMediaParams, z as SimulatorMediaKind } from './ConversationSimulatorPanel-DSVIch04.js';
7
7
  import { ChannelCapability } from '@adatechnology/conversation-contracts';
8
8
  export { ChannelCapability } from '@adatechnology/conversation-contracts';
9
9
  import '@adatechnology/meta-whatsapp-contracts/testing';
@@ -1818,6 +1818,13 @@ declare const WHATSAPP_MARKER_BY_ACTION: {
1818
1818
  readonly monospace: "```";
1819
1819
  };
1820
1820
 
1821
+ /** Rótulo do número de teste do simulador, no lugar de uma máscara de telefone que não existe. */
1822
+ declare const TEST_CONTACT_LABEL = "Contato de teste";
1823
+ /**
1824
+ * Nenhum código de país começa com 0, então um número só de dígitos começando com 0 não é telefone
1825
+ * de verdade: é o contato de teste do simulador. Formatá-lo como telefone inventa um DDD.
1826
+ */
1827
+ declare function isTestContactNumber(number: string): boolean;
1821
1828
  declare function formatPhone(number: string): string;
1822
1829
  declare function phoneInitials(number: string): string;
1823
1830
 
@@ -1992,6 +1999,7 @@ interface ConversationsWorkspaceLabels {
1992
1999
  readonly selectAll: string;
1993
2000
  readonly emptyList: string;
1994
2001
  readonly emptyDetail: string;
2002
+ readonly newTestContact: string;
1995
2003
  readonly bulkSelected: (count: number) => string;
1996
2004
  readonly bulkClear: string;
1997
2005
  readonly bulkFinalize: string;
@@ -2127,6 +2135,17 @@ type SimulatorTransportParams = {
2127
2135
  * site, o cliente das rotas do widget.
2128
2136
  */
2129
2137
  type SimulatorTransportFactory = (params: SimulatorTransportParams) => ConversationSimulatorClient;
2138
+ /**
2139
+ * Contato de teste que o host cria para abrir o simulador sem conversa selecionada. `handle` é o
2140
+ * identificador no canal (no WhatsApp, um número de teste começando com `0`, que nenhum país usa).
2141
+ */
2142
+ type SimulatorTestContact = {
2143
+ readonly handle: string;
2144
+ /** Ausente = WhatsApp. */
2145
+ readonly channel?: ConversationChannel;
2146
+ /** Id da conversa quando o host já o conhece. Ausente, usa `handle` e o transcript começa vazio. */
2147
+ readonly conversationId?: string;
2148
+ };
2130
2149
  interface ConversationsWorkspaceSimulator {
2131
2150
  /**
2132
2151
  * Um transporte por canal — o workspace monta o painel com o da conversa selecionada.
@@ -2158,6 +2177,14 @@ interface ConversationsWorkspaceSimulator {
2158
2177
  readonly uploadMedia?: (file: File) => Promise<PreviewUploadedMedia>;
2159
2178
  /** Recarrega o transcript a cada N ms. Serve a host sem stream. */
2160
2179
  readonly pollIntervalMs?: number;
2180
+ /**
2181
+ * Liga "Novo contato de teste" no cabeçalho da página: o host devolve o contato e o simulador
2182
+ * abre sem conversa selecionada. Quando a conversa dele aparece na lista, ela é selecionada.
2183
+ * Ausente, o simulador só abre sobre uma conversa existente.
2184
+ */
2185
+ readonly createTestContact?: () => SimulatorTestContact | Promise<SimulatorTestContact>;
2186
+ /** Rótulo do botão de novo contato. Padrão: "Novo contato de teste". */
2187
+ readonly newContactLabel?: string;
2161
2188
  }
2162
2189
  interface ConversationsWorkspaceProps {
2163
2190
  readonly labels?: Partial<ConversationsWorkspaceLabels>;
@@ -2201,6 +2228,8 @@ interface ConversationsWorkspaceProps {
2201
2228
  /** Nota de voz. Ausente, o microfone não aparece. */
2202
2229
  readonly onRecordAudio?: (conversation: ConversationSummary, file: File) => Promise<void>;
2203
2230
  readonly contextEntriesOf?: (context: Record<string, unknown> | undefined) => readonly ConversationContextEntry[];
2231
+ /** Vocabulário do painel de contexto (`title`, `empty`, `notCollected`...). */
2232
+ readonly contextLabels?: Partial<ConversationContextPanelLabels>;
2204
2233
  readonly onAttach?: (conversation: ConversationSummary, file: File) => Promise<void>;
2205
2234
  readonly extraUtilitiesFor?: (conversation: ConversationSummary) => readonly ConversationHeaderUtility[];
2206
2235
  readonly renderFilters?: (inbox: UseConversationsInboxResult) => ReactNode;
@@ -2213,7 +2242,7 @@ interface ConversationsWorkspaceProps {
2213
2242
  readonly signInHref?: string;
2214
2243
  readonly className?: string;
2215
2244
  }
2216
- declare function ConversationsWorkspace({ labels: labelsOverride, filters, perPage, markReadOnOpen, serverPaginated, initialConversationId, initialWhatsappNumber, simulator, quickReplies, quickReplyVariablesFor, flowLabelOf, onDownload, requireTakeoverToReply, messageSelection, initialComposerText, composer, composerVariablesFor, conversationVariablesFor, onSendAttachments, onRecordAudio, contextEntriesOf, onAttach, extraUtilitiesFor, renderFilters, renderBulkActions, renderRow, renderAboveTranscript, renderHeaderActions, onSendTemplateToSelected, signInHref, className, }: ConversationsWorkspaceProps): react.JSX.Element;
2245
+ declare function ConversationsWorkspace({ labels: labelsOverride, filters, perPage, markReadOnOpen, serverPaginated, initialConversationId, initialWhatsappNumber, simulator, quickReplies, quickReplyVariablesFor, flowLabelOf, onDownload, requireTakeoverToReply, messageSelection, initialComposerText, composer, composerVariablesFor, conversationVariablesFor, onSendAttachments, onRecordAudio, contextEntriesOf, contextLabels, onAttach, extraUtilitiesFor, renderFilters, renderBulkActions, renderRow, renderAboveTranscript, renderHeaderActions, onSendTemplateToSelected, signInHref, className, }: ConversationsWorkspaceProps): react.JSX.Element;
2217
2246
 
2218
2247
  interface ConversationPaneProps {
2219
2248
  readonly conversation: ConversationSummary;
@@ -2228,6 +2257,8 @@ interface ConversationPaneProps {
2228
2257
  readonly extraUtilities?: readonly ConversationHeaderUtility[];
2229
2258
  /** Traduz o contexto cru do produto nas linhas do painel. Ausente, o painel não aparece. */
2230
2259
  readonly contextEntriesOf?: (context: Record<string, unknown> | undefined) => readonly ConversationContextEntry[];
2260
+ /** Vocabulário do painel de contexto (`title`, `empty`, `notCollected`...). */
2261
+ readonly contextLabels?: Partial<ConversationContextPanelLabels>;
2231
2262
  readonly quickReplies?: readonly QuickReply[];
2232
2263
  /**
2233
2264
  * Recebe o contexto junto porque o dado que interessa à variável (o nome que o bot perguntou,
@@ -2285,7 +2316,7 @@ interface ConversationPaneProps {
2285
2316
  /** Grava e envia nota de voz. Ausente, o microfone não aparece. */
2286
2317
  readonly onRecordAudio?: (file: File) => Promise<void>;
2287
2318
  }
2288
- declare function ConversationPane({ conversation, now, busy, labels, onTakeover, onReturnToBot, onFinish, onBack, extraUtilities, contextEntriesOf, quickReplies, quickReplyVariablesFor, flowLabel, onDownload, requireTakeoverToReply, messageSelection, initialComposerText, renderAboveTranscript, onAttach, composer, composerVariablesFor, conversationVariablesFor, onSendAttachments, onRecordAudio, }: ConversationPaneProps): react.JSX.Element;
2319
+ declare function ConversationPane({ conversation, now, busy, labels, onTakeover, onReturnToBot, onFinish, onBack, extraUtilities, contextEntriesOf, contextLabels, quickReplies, quickReplyVariablesFor, flowLabel, onDownload, requireTakeoverToReply, messageSelection, initialComposerText, renderAboveTranscript, onAttach, composer, composerVariablesFor, conversationVariablesFor, onSendAttachments, onRecordAudio, }: ConversationPaneProps): react.JSX.Element;
2289
2320
 
2290
2321
  interface ConversationsInboxListProps {
2291
2322
  readonly inbox: UseConversationsInboxResult;
@@ -2322,4 +2353,4 @@ type QueuedAttachmentsListProps = {
2322
2353
  };
2323
2354
  declare function QueuedAttachmentsList({ items, statusOf, onRemove, onRetry, retryingKeys, getThumbnailUrl, labels, busy, }: QueuedAttachmentsListProps): react.JSX.Element | null;
2324
2355
 
2325
- export { type AsyncResourceState, type AttachmentFileRejection, AudioPlayer, type AudioPlayerProps, AudioTranscription, type AudioTranscriptionProps, Avatar, type AvatarLabels, type AvatarProps, type BotMessages, type BuildTranscriptTextParams, BulkActionBar, type BulkActionBarProps, CHANNEL_BRAND_COLOR, CONVERSATIONS_PER_PAGE, CONVERSATION_WINDOW, ChannelFilter, ChannelFilterOption, ChannelIcon, type ChannelIconProps, ConversationChannel, type ConversationContextEntry, ConversationContextPanel, type ConversationContextPanelClassNames, type ConversationContextPanelLabels, type ConversationContextPanelProps, type ConversationContextStatus, ConversationDocument, ConversationDocumentsPanel, type ConversationDocumentsPanelClassNames, type ConversationDocumentsPanelLabels, type ConversationDocumentsPanelProps, ConversationHeader, type ConversationHeaderClassNames, type ConversationHeaderLabels, type ConversationHeaderProps, type ConversationHeaderUtility, ConversationListItem, type ConversationListItemLabels, type ConversationListItemProps, type ConversationLocales, ConversationLocalesProvider, type ConversationLocalesProviderProps, ConversationPane, type ConversationPaneProps, type ConversationRealtimeHandler, ConversationRow, type ConversationRowClassNames, type ConversationRowProps, ConversationSimulatorClient, ConversationSummary, ConversationTemplate, ConversationVariable, ConversationWallpaper, type ConversationWallpaperProps, type ConversationWindow, ConversationsApi, ConversationsFeatures, ConversationsInboxList, type ConversationsInboxListProps, ConversationsProvider, ConversationsWorkspace, type ConversationsWorkspaceLabels, type ConversationsWorkspaceProps, type ConversationsWorkspaceSimulator, DEFAULT_ACCEPTED_FILE_TYPES, DEFAULT_AVATAR_LABELS, DEFAULT_CONVERSATIONS_WORKSPACE_LABELS, DEFAULT_CONVERSATION_CONTEXT_LABELS, DEFAULT_CONVERSATION_DOCUMENTS_LABELS, DEFAULT_CONVERSATION_HEADER_LABELS, DEFAULT_CONVERSATION_LIST_ITEM_LABELS, DEFAULT_DARK_MODE_TOGGLE_LABELS, DEFAULT_DOCUMENTS_LIBRARY_LABELS, DEFAULT_DOCUMENTS_WORKSPACE_LABELS, DEFAULT_EMOJI_PICKER_LABELS, DEFAULT_INTERACTIVE_MESSAGE_LABELS, DEFAULT_LIGHTBOX_LABELS, DEFAULT_MAX_ATTACHMENT_SIZE_BYTES, DEFAULT_MAX_RECORDING_MILLISECONDS, DEFAULT_MESSAGE_COMPOSER_LABELS, DEFAULT_QUICK_REPLIES_PICKER_LABELS, DEFAULT_QUICK_REPLIES_WORKSPACE_LABELS, DEFAULT_RICH_COMPOSER_TOOLTIPS, DEFAULT_TEMPLATES_SETTINGS_LABELS, DEFAULT_WHATSAPP_MESSAGE_EDITOR_LABELS, DEFAULT_WINDOW_EXPIRED_LABELS, DOCUMENT_SOURCE_FILTER, DarkModeToggle, type DarkModeToggleLabels, type DarkModeToggleProps, DateDivider, type DateDividerClassNames, type DateDividerProps, type DocumentSourceFilter, type DocumentsFiltersContext, DocumentsLibrary, type DocumentsLibraryClassNames, type DocumentsLibraryLabels, type DocumentsLibraryProps, DocumentsWorkspace, type DocumentsWorkspaceClassNames, type DocumentsWorkspaceLabels, type DocumentsWorkspaceProps, EMOJI_CATEGORIES, type EmojiCategory, type EmojiEntry, EmojiPicker, type EmojiPickerLabels, type EmojiPickerProps, FileIcon, type FileIconProps, type FilterOption, type FilterQuickRepliesParams, InteractiveMessage, type InteractiveMessageLabels, type InteractiveMessageProps, InteractivePayload, InteractiveSelection, Lightbox, type LightboxLabels, type LightboxProps, ListConversationsParams, ListDocumentsParams, ListingPagination, type ListingPaginationProps, type MatchSegment, type MaxAttachmentSizeBytes, MessageBubble, type MessageBubbleProps, MessageComposer, type MessageComposerClassNames, type MessageComposerLabels, type MessageComposerProps, MessagePayload, MessageTail, MessageText, type MessageTextProps, MessageTimestamp, MessageTranscription, MessagesWorkspace, type MessagesWorkspaceApi, type MessagesWorkspaceLabels, type MessagesWorkspaceProps, type MessagesWorkspaceTemplateRole, MultiSelectFilter, type MultiSelectFilterProps, NARROW_MAX_WIDTH_PX, type OutgoingItems, QueuedAttachment, QueuedAttachmentsList, QuickRepliesPicker, type QuickRepliesPickerLabels, type QuickRepliesPickerProps, QuickRepliesWorkspace, type QuickRepliesWorkspaceLabels, type QuickRepliesWorkspaceProps, type QuickReply, QuickReplyAttachment, QuickReplyInput, REPLY_LATENCY, REPLY_LATENCY_CRITICAL_HOURS, REPLY_LATENCY_LATE_HOURS, RICH_COMPOSER_ACTION, type ReplyLatency, type ReplyLatencyParams, ResolveMediaUrl, type RichComposerAction, type RichComposerQuickReply, type RichComposerTooltips, type RichComposerVariable, RichMessageComposer, type RichMessageComposerHandle, type RichMessageComposerProps, SSEProvider, QuickReply$1 as SavedQuickReply, SimpleEmojiPicker, type SimpleEmojiPickerProps, type SimulatorTransportFactory, type SimulatorTransportParams, type SortDirection, SortableHead, type SortableHeadProps, StatusTicks, type StatusTicksProps, TEMPLATE_SETTINGS_TAB, TOOLTIP_ATTRIBUTE, type TemplateSettings, type TemplateSettingsTab, ToastProvider, TooltipLayer, type TopicItem, TopicsForm, type TopicsFormLabels, type TopicsFormProps, TranscriptionMode, type TranscriptionSettings, TranscriptionSettingsForm, type TranscriptionSettingsFormLabels, type TranscriptionSettingsFormProps, type UrlStateOptions, type UseConversationActionsResult, type UseConversationContextResult, type UseConversationDocumentsParams, type UseConversationDocumentsResult, type UseConversationListParams, type UseConversationListResult, type UseConversationMessagesResult, type UseConversationsInboxParams, type UseConversationsInboxResult, type UseInboxActionsResult, type UseScrollToLatestMessageParams, type UseScrollToLatestMessageResult, type UseWaitingNotificationsLabels, type UseWaitingNotificationsParams, type UseWaitingNotificationsResult, type ValidateAttachmentFilesResult, WHATSAPP_MARKER_BY_ACTION, WINDOW_FILTERS, WelcomeFarewellForm, type WelcomeFarewellFormLabels, type WelcomeFarewellFormProps, WhatsAppCreateTemplateForm, type WhatsAppCreateTemplateFormLabels, type WhatsAppCreateTemplateFormProps, type WhatsAppCreateTemplateResult, type WhatsAppCreateTemplateState, WhatsAppMessageEditor, type WhatsAppMessageEditorLabels, type WhatsAppMessageEditorProps, WhatsAppMessagePreview, type WhatsAppMessagePreviewProps, type WhatsAppTemplateHeaderType, WhatsAppTemplateSettingsForm, type WhatsAppTemplateSettingsFormLabels, type WhatsAppTemplateSettingsFormProps, type WhatsAppTemplateSummary, type WhatsAppTemplateVariableSuggestion, WhatsAppTemplatesSettings, type WhatsAppTemplatesSettingsLabels, type WhatsAppTemplatesSettingsProps, WindowExpiredNotice, type WindowExpiredNoticeLabels, type WindowExpiredNoticeProps, type WindowOfParams, applyQuickReplyVariables, buildTranscriptFilename, buildTranscriptText, channelCapabilityFor, createMediaUrlResolver, downloadTextFile, filterQuickReplies, formatDateTime, formatFileSize, formatPhone, formatStalledFor, formatTimestamp, highlightMatch, htmlToWA, isReplyOverdue, isSameDay, isWindowBlocking, normalizeForSearch, parseWhatsAppFormatting, phoneInitials, queuedAttachmentsFromQuickReply, replyLatencyOf, resolveMaxAttachmentSizeBytes, resolveQuickReply, searchEmojis, toast, useConversationActions, useConversationContext, useConversationDocuments, useConversationList, useConversationLocales, useConversationMessages, useConversationRealtime, useConversations, useConversationsInbox, useDarkMode, useDebouncedValue, useGlobalRealtime, useInboxActions, useIsDarkTheme, useIsNarrow, useScrollToLatestMessage, useToast, useUrlArrayState, useUrlNumberState, useUrlStringState, useWaitingNotifications, waToHTML, waToHTMLInline, windowOf };
2356
+ export { type AsyncResourceState, type AttachmentFileRejection, AudioPlayer, type AudioPlayerProps, AudioTranscription, type AudioTranscriptionProps, Avatar, type AvatarLabels, type AvatarProps, type BotMessages, type BuildTranscriptTextParams, BulkActionBar, type BulkActionBarProps, CHANNEL_BRAND_COLOR, CONVERSATIONS_PER_PAGE, CONVERSATION_WINDOW, ChannelFilter, ChannelFilterOption, ChannelIcon, type ChannelIconProps, ConversationChannel, type ConversationContextEntry, ConversationContextPanel, type ConversationContextPanelClassNames, type ConversationContextPanelLabels, type ConversationContextPanelProps, type ConversationContextStatus, ConversationDocument, ConversationDocumentsPanel, type ConversationDocumentsPanelClassNames, type ConversationDocumentsPanelLabels, type ConversationDocumentsPanelProps, ConversationHeader, type ConversationHeaderClassNames, type ConversationHeaderLabels, type ConversationHeaderProps, type ConversationHeaderUtility, ConversationListItem, type ConversationListItemLabels, type ConversationListItemProps, type ConversationLocales, ConversationLocalesProvider, type ConversationLocalesProviderProps, ConversationPane, type ConversationPaneProps, type ConversationRealtimeHandler, ConversationRow, type ConversationRowClassNames, type ConversationRowProps, ConversationSimulatorClient, ConversationSummary, ConversationTemplate, ConversationVariable, ConversationWallpaper, type ConversationWallpaperProps, type ConversationWindow, ConversationsApi, ConversationsFeatures, ConversationsInboxList, type ConversationsInboxListProps, ConversationsProvider, ConversationsWorkspace, type ConversationsWorkspaceLabels, type ConversationsWorkspaceProps, type ConversationsWorkspaceSimulator, DEFAULT_ACCEPTED_FILE_TYPES, DEFAULT_AVATAR_LABELS, DEFAULT_CONVERSATIONS_WORKSPACE_LABELS, DEFAULT_CONVERSATION_CONTEXT_LABELS, DEFAULT_CONVERSATION_DOCUMENTS_LABELS, DEFAULT_CONVERSATION_HEADER_LABELS, DEFAULT_CONVERSATION_LIST_ITEM_LABELS, DEFAULT_DARK_MODE_TOGGLE_LABELS, DEFAULT_DOCUMENTS_LIBRARY_LABELS, DEFAULT_DOCUMENTS_WORKSPACE_LABELS, DEFAULT_EMOJI_PICKER_LABELS, DEFAULT_INTERACTIVE_MESSAGE_LABELS, DEFAULT_LIGHTBOX_LABELS, DEFAULT_MAX_ATTACHMENT_SIZE_BYTES, DEFAULT_MAX_RECORDING_MILLISECONDS, DEFAULT_MESSAGE_COMPOSER_LABELS, DEFAULT_QUICK_REPLIES_PICKER_LABELS, DEFAULT_QUICK_REPLIES_WORKSPACE_LABELS, DEFAULT_RICH_COMPOSER_TOOLTIPS, DEFAULT_TEMPLATES_SETTINGS_LABELS, DEFAULT_WHATSAPP_MESSAGE_EDITOR_LABELS, DEFAULT_WINDOW_EXPIRED_LABELS, DOCUMENT_SOURCE_FILTER, DarkModeToggle, type DarkModeToggleLabels, type DarkModeToggleProps, DateDivider, type DateDividerClassNames, type DateDividerProps, type DocumentSourceFilter, type DocumentsFiltersContext, DocumentsLibrary, type DocumentsLibraryClassNames, type DocumentsLibraryLabels, type DocumentsLibraryProps, DocumentsWorkspace, type DocumentsWorkspaceClassNames, type DocumentsWorkspaceLabels, type DocumentsWorkspaceProps, EMOJI_CATEGORIES, type EmojiCategory, type EmojiEntry, EmojiPicker, type EmojiPickerLabels, type EmojiPickerProps, FileIcon, type FileIconProps, type FilterOption, type FilterQuickRepliesParams, InteractiveMessage, type InteractiveMessageLabels, type InteractiveMessageProps, InteractivePayload, InteractiveSelection, Lightbox, type LightboxLabels, type LightboxProps, ListConversationsParams, ListDocumentsParams, ListingPagination, type ListingPaginationProps, type MatchSegment, type MaxAttachmentSizeBytes, MessageBubble, type MessageBubbleProps, MessageComposer, type MessageComposerClassNames, type MessageComposerLabels, type MessageComposerProps, MessagePayload, MessageTail, MessageText, type MessageTextProps, MessageTimestamp, MessageTranscription, MessagesWorkspace, type MessagesWorkspaceApi, type MessagesWorkspaceLabels, type MessagesWorkspaceProps, type MessagesWorkspaceTemplateRole, MultiSelectFilter, type MultiSelectFilterProps, NARROW_MAX_WIDTH_PX, type OutgoingItems, QueuedAttachment, QueuedAttachmentsList, QuickRepliesPicker, type QuickRepliesPickerLabels, type QuickRepliesPickerProps, QuickRepliesWorkspace, type QuickRepliesWorkspaceLabels, type QuickRepliesWorkspaceProps, type QuickReply, QuickReplyAttachment, QuickReplyInput, REPLY_LATENCY, REPLY_LATENCY_CRITICAL_HOURS, REPLY_LATENCY_LATE_HOURS, RICH_COMPOSER_ACTION, type ReplyLatency, type ReplyLatencyParams, ResolveMediaUrl, type RichComposerAction, type RichComposerQuickReply, type RichComposerTooltips, type RichComposerVariable, RichMessageComposer, type RichMessageComposerHandle, type RichMessageComposerProps, SSEProvider, QuickReply$1 as SavedQuickReply, SimpleEmojiPicker, type SimpleEmojiPickerProps, type SimulatorTestContact, type SimulatorTransportFactory, type SimulatorTransportParams, type SortDirection, SortableHead, type SortableHeadProps, StatusTicks, type StatusTicksProps, TEMPLATE_SETTINGS_TAB, TEST_CONTACT_LABEL, TOOLTIP_ATTRIBUTE, type TemplateSettings, type TemplateSettingsTab, ToastProvider, TooltipLayer, type TopicItem, TopicsForm, type TopicsFormLabels, type TopicsFormProps, TranscriptionMode, type TranscriptionSettings, TranscriptionSettingsForm, type TranscriptionSettingsFormLabels, type TranscriptionSettingsFormProps, type UrlStateOptions, type UseConversationActionsResult, type UseConversationContextResult, type UseConversationDocumentsParams, type UseConversationDocumentsResult, type UseConversationListParams, type UseConversationListResult, type UseConversationMessagesResult, type UseConversationsInboxParams, type UseConversationsInboxResult, type UseInboxActionsResult, type UseScrollToLatestMessageParams, type UseScrollToLatestMessageResult, type UseWaitingNotificationsLabels, type UseWaitingNotificationsParams, type UseWaitingNotificationsResult, type ValidateAttachmentFilesResult, WHATSAPP_MARKER_BY_ACTION, WINDOW_FILTERS, WelcomeFarewellForm, type WelcomeFarewellFormLabels, type WelcomeFarewellFormProps, WhatsAppCreateTemplateForm, type WhatsAppCreateTemplateFormLabels, type WhatsAppCreateTemplateFormProps, type WhatsAppCreateTemplateResult, type WhatsAppCreateTemplateState, WhatsAppMessageEditor, type WhatsAppMessageEditorLabels, type WhatsAppMessageEditorProps, WhatsAppMessagePreview, type WhatsAppMessagePreviewProps, type WhatsAppTemplateHeaderType, WhatsAppTemplateSettingsForm, type WhatsAppTemplateSettingsFormLabels, type WhatsAppTemplateSettingsFormProps, type WhatsAppTemplateSummary, type WhatsAppTemplateVariableSuggestion, WhatsAppTemplatesSettings, type WhatsAppTemplatesSettingsLabels, type WhatsAppTemplatesSettingsProps, WindowExpiredNotice, type WindowExpiredNoticeLabels, type WindowExpiredNoticeProps, type WindowOfParams, applyQuickReplyVariables, buildTranscriptFilename, buildTranscriptText, channelCapabilityFor, createMediaUrlResolver, downloadTextFile, filterQuickReplies, formatDateTime, formatFileSize, formatPhone, formatStalledFor, formatTimestamp, highlightMatch, htmlToWA, isReplyOverdue, isSameDay, isTestContactNumber, isWindowBlocking, normalizeForSearch, parseWhatsAppFormatting, phoneInitials, queuedAttachmentsFromQuickReply, replyLatencyOf, resolveMaxAttachmentSizeBytes, resolveQuickReply, searchEmojis, toast, useConversationActions, useConversationContext, useConversationDocuments, useConversationList, useConversationLocales, useConversationMessages, useConversationRealtime, useConversations, useConversationsInbox, useDarkMode, useDebouncedValue, useGlobalRealtime, useInboxActions, useIsDarkTheme, useIsNarrow, useScrollToLatestMessage, useToast, useUrlArrayState, useUrlNumberState, useUrlStringState, useWaitingNotifications, waToHTML, waToHTMLInline, windowOf };
package/dist/index.js CHANGED
@@ -65,7 +65,7 @@ import {
65
65
  useConversationLocales,
66
66
  useConversations,
67
67
  useQuickRepliesPicker
68
- } from "./chunk-Y326LLEP.js";
68
+ } from "./chunk-7OLYCCLX.js";
69
69
  import {
70
70
  ZERO_WIDTH_SPACE,
71
71
  cn,
@@ -85,6 +85,7 @@ import {
85
85
  HANDLE_KIND,
86
86
  REOPEN_MECHANISM,
87
87
  StatusTicks,
88
+ TEST_CONTACT_LABEL,
88
89
  capabilitiesOf,
89
90
  channelCapabilityFor,
90
91
  channelFiltersFor,
@@ -95,8 +96,9 @@ import {
95
96
  formatPhone,
96
97
  formatTimestamp,
97
98
  isSameDay,
99
+ isTestContactNumber,
98
100
  phoneInitials
99
- } from "./chunk-WCZNIJ3M.js";
101
+ } from "./chunk-Z7U22M3K.js";
100
102
 
101
103
  // src/RichMessageComposer.tsx
102
104
  import {
@@ -5555,7 +5557,7 @@ function QuickRepliesWorkspace({
5555
5557
 
5556
5558
  // src/workspace/ConversationsWorkspace.tsx
5557
5559
  import { useEffect as useEffect20, useMemo as useMemo7, useState as useState26 } from "react";
5558
- import { Check as Check2, CheckCheck, FlaskConical, Hourglass as Hourglass2, Mail as Mail2, MessagesSquare } from "lucide-react";
5560
+ import { Check as Check2, CheckCheck, FlaskConical, Hourglass as Hourglass2, Mail as Mail2, MessagesSquare, UserPlus } from "lucide-react";
5559
5561
 
5560
5562
  // src/workspace/BulkTemplateModal.tsx
5561
5563
  import { useEffect as useEffect15, useMemo as useMemo5, useState as useState20 } from "react";
@@ -6111,6 +6113,7 @@ function ConversationPane({
6111
6113
  onBack,
6112
6114
  extraUtilities,
6113
6115
  contextEntriesOf,
6116
+ contextLabels,
6114
6117
  quickReplies,
6115
6118
  quickReplyVariablesFor,
6116
6119
  flowLabel,
@@ -6277,7 +6280,14 @@ function ConversationPane({
6277
6280
  ...extraUtilities ? { extraUtilities } : {}
6278
6281
  }
6279
6282
  ),
6280
- contextEntries && contextEntries.length > 0 || flowLabel ? /* @__PURE__ */ jsx32(ConversationContextPanel, { entries: contextEntries ?? [], ...flowLabel ? { flowLabel } : {} }) : null,
6283
+ contextEntries && contextEntries.length > 0 || flowLabel ? /* @__PURE__ */ jsx32(
6284
+ ConversationContextPanel,
6285
+ {
6286
+ entries: contextEntries ?? [],
6287
+ ...flowLabel ? { flowLabel } : {},
6288
+ ...contextLabels ? { labels: contextLabels } : {}
6289
+ }
6290
+ ) : null,
6281
6291
  /* @__PURE__ */ jsx32(ConversationDocumentsPanel, { conversationId: conversation.id, open: documentsOpen }),
6282
6292
  renderAboveTranscript?.(conversation, conversationContext),
6283
6293
  /* @__PURE__ */ jsxs28(
@@ -6600,6 +6610,7 @@ var DEFAULT_CONVERSATIONS_WORKSPACE_LABELS = {
6600
6610
  selectAll: "Selecionar todas",
6601
6611
  emptyList: "Nenhuma conversa encontrada.",
6602
6612
  emptyDetail: "Selecione uma conversa.",
6613
+ newTestContact: "Novo contato de teste",
6603
6614
  bulkSelected: (count) => `${count} selecionada${count === 1 ? "" : "s"}`,
6604
6615
  bulkClear: "Limpar sele\xE7\xE3o",
6605
6616
  bulkFinalize: "Finalizar",
@@ -6819,6 +6830,9 @@ function useConversationsInbox(params = {}) {
6819
6830
 
6820
6831
  // src/workspace/ConversationsWorkspace.tsx
6821
6832
  import { Fragment as Fragment8, jsx as jsx34, jsxs as jsxs30 } from "react/jsx-runtime";
6833
+ function handleOf(conversation) {
6834
+ return conversation.contactId ?? conversation.whatsappNumber;
6835
+ }
6822
6836
  function ConversationsWorkspace({
6823
6837
  labels: labelsOverride,
6824
6838
  filters,
@@ -6841,6 +6855,7 @@ function ConversationsWorkspace({
6841
6855
  onSendAttachments,
6842
6856
  onRecordAudio,
6843
6857
  contextEntriesOf,
6858
+ contextLabels,
6844
6859
  onAttach,
6845
6860
  extraUtilitiesFor,
6846
6861
  renderFilters,
@@ -6860,32 +6875,65 @@ function ConversationsWorkspace({
6860
6875
  ...serverPaginated ? { serverPaginated } : {}
6861
6876
  });
6862
6877
  const [simulatorOpen, setSimulatorOpen] = useState26(false);
6878
+ const [testContact, setTestContact] = useState26(void 0);
6863
6879
  const [templateModalOpen, setTemplateModalOpen] = useState26(false);
6864
6880
  const [openedFromLink, setOpenedFromLink] = useState26(void 0);
6865
6881
  useEffect20(() => {
6866
6882
  const link = initialConversationId ?? initialWhatsappNumber;
6867
6883
  if (!link || openedFromLink === link) return;
6868
- const target = inbox.conversations.find(
6884
+ const target2 = inbox.conversations.find(
6869
6885
  (conversation) => conversation.id === initialConversationId || conversation.whatsappNumber === initialWhatsappNumber
6870
6886
  );
6871
- if (!target) return;
6872
- inbox.selectConversation(target.id);
6887
+ if (!target2) return;
6888
+ inbox.selectConversation(target2.id);
6873
6889
  setOpenedFromLink(link);
6874
6890
  }, [initialConversationId, initialWhatsappNumber, openedFromLink, inbox]);
6875
6891
  const selected = inbox.selectedConversation;
6892
+ useEffect20(() => {
6893
+ if (!testContact) return;
6894
+ const created = inbox.conversations.find((conversation) => handleOf(conversation) === testContact.handle);
6895
+ if (!created) return;
6896
+ inbox.selectConversation(created.id);
6897
+ setTestContact(void 0);
6898
+ }, [testContact, inbox]);
6876
6899
  const conversations = useConversations();
6877
- const selectedId = selected?.id;
6878
- const channel = selected?.channel ?? DEFAULT_CONVERSATION_CHANNEL;
6879
- const handle = selected ? selected.contactId ?? selected.whatsappNumber : "";
6900
+ const target = selected ? {
6901
+ key: selected.id,
6902
+ conversationId: selected.id,
6903
+ channel: selected.channel ?? DEFAULT_CONVERSATION_CHANNEL,
6904
+ handle: handleOf(selected),
6905
+ persisted: true
6906
+ } : testContact ? {
6907
+ key: `test-contact:${testContact.handle}`,
6908
+ // Sem id conhecido, o próprio identificador: é a chave do stream por conversa (`conv:<número>`).
6909
+ conversationId: testContact.conversationId ?? testContact.handle,
6910
+ channel: testContact.channel ?? DEFAULT_CONVERSATION_CHANNEL,
6911
+ handle: testContact.handle,
6912
+ persisted: testContact.conversationId !== void 0
6913
+ } : void 0;
6914
+ const channel = target?.channel ?? DEFAULT_CONVERSATION_CHANNEL;
6915
+ const targetConversationId = target?.conversationId;
6916
+ const handle = target?.handle ?? "";
6880
6917
  const transport = simulator?.transports?.[channel];
6881
- const simulatorEnabled = Boolean(
6882
- simulator && (simulator.enabled ?? true) && (simulator.render ?? transport)
6883
- );
6884
- const showSimulator = simulatorEnabled && simulatorOpen && Boolean(selected);
6918
+ const simulatorAvailable = Boolean(simulator && (simulator.enabled ?? true));
6919
+ const simulatorEnabled = simulatorAvailable && Boolean(simulator?.render ?? transport);
6920
+ const showSimulator = simulatorEnabled && simulatorOpen && Boolean(target);
6921
+ const canCreateTestContact = simulatorAvailable && Boolean(simulator?.createTestContact);
6885
6922
  const simulatorClient = useMemo7(
6886
- () => transport && selectedId ? transport({ conversationId: selectedId, channel, handle }) : void 0,
6887
- [transport, selectedId, channel, handle]
6923
+ () => transport && targetConversationId !== void 0 ? transport({ conversationId: targetConversationId, channel, handle }) : void 0,
6924
+ [transport, targetConversationId, channel, handle]
6888
6925
  );
6926
+ async function handleCreateTestContact() {
6927
+ const contact = await simulator?.createTestContact?.();
6928
+ if (!contact) return;
6929
+ inbox.clearSelection();
6930
+ setTestContact(contact);
6931
+ setSimulatorOpen(true);
6932
+ }
6933
+ function closeSimulator() {
6934
+ setSimulatorOpen(false);
6935
+ setTestContact(void 0);
6936
+ }
6889
6937
  const paneUtilities = useMemo7(() => {
6890
6938
  if (!selected) return void 0;
6891
6939
  const fromProduct = extraUtilitiesFor?.(selected) ?? [];
@@ -6987,6 +7035,20 @@ function ConversationsWorkspace({
6987
7035
  ]
6988
7036
  }
6989
7037
  ) : null,
7038
+ canCreateTestContact ? /* @__PURE__ */ jsxs30(
7039
+ "button",
7040
+ {
7041
+ type: "button",
7042
+ onClick: () => void handleCreateTestContact(),
7043
+ "data-cv-tooltip": simulator?.newContactLabel ?? labels.newTestContact,
7044
+ "aria-label": simulator?.newContactLabel ?? labels.newTestContact,
7045
+ className: "cv-workspace-toggle",
7046
+ children: [
7047
+ /* @__PURE__ */ jsx34(UserPlus, { size: ICON_SIZE_ACTION, "aria-hidden": "true" }),
7048
+ /* @__PURE__ */ jsx34("span", { className: "cv-only-wide", children: simulator?.newContactLabel ?? labels.newTestContact })
7049
+ ]
7050
+ }
7051
+ ) : null,
6990
7052
  renderHeaderActions?.(inbox)
6991
7053
  ] })
6992
7054
  ] }),
@@ -7001,7 +7063,7 @@ function ConversationsWorkspace({
7001
7063
  "div",
7002
7064
  {
7003
7065
  className: `cv-workspace-grid${showSimulator ? " cv-workspace-grid--with-simulator" : ""}`,
7004
- "data-detail": selected ? "open" : "closed",
7066
+ "data-detail": selected || showSimulator ? "open" : "closed",
7005
7067
  children: [
7006
7068
  /* @__PURE__ */ jsx34(
7007
7069
  ConversationsInboxList,
@@ -7040,16 +7102,17 @@ function ConversationsWorkspace({
7040
7102
  onBack: inbox.clearSelection,
7041
7103
  ...paneUtilities ? { extraUtilities: paneUtilities } : {},
7042
7104
  ...contextEntriesOf ? { contextEntriesOf } : {},
7105
+ ...contextLabels ? { contextLabels } : {},
7043
7106
  ...quickReplies ? { quickReplies } : {},
7044
7107
  ...quickReplyVariablesFor ? { quickReplyVariablesFor } : {},
7045
7108
  ...renderAboveTranscript ? { renderAboveTranscript } : {},
7046
7109
  ...onAttach ? { onAttach: (file) => onAttach(selected, file) } : {}
7047
7110
  }
7048
7111
  ) : /* @__PURE__ */ jsx34("p", { className: "cv-workspace-empty", children: labels.emptyDetail }) }),
7049
- showSimulator && selected ? (
7112
+ showSimulator && target ? (
7050
7113
  // `min-height:0` junto do `min-width:0`: sem isso a linha do grid cresce com o conteúdo do
7051
7114
  // painel, o scroll interno nunca ativa e quem rola passa a ser a página inteira.
7052
- /* @__PURE__ */ jsx34("div", { className: "cv-workspace-simulator", children: simulator?.render ? simulator.render({ conversationId: selected.id, channel, close: () => setSimulatorOpen(false) }) : simulatorClient && conversations ? (
7115
+ /* @__PURE__ */ jsx34("div", { className: "cv-workspace-simulator", children: simulator?.render ? simulator.render({ conversationId: target.conversationId, channel, close: closeSimulator }) : simulatorClient && conversations ? (
7053
7116
  // `key` pela conversa: trocar de contato sem remontar deixaria o transcript e o campo
7054
7117
  // de texto do contato anterior na tela.
7055
7118
  /* @__PURE__ */ jsx34(
@@ -7057,16 +7120,16 @@ function ConversationsWorkspace({
7057
7120
  {
7058
7121
  client: simulatorClient,
7059
7122
  sse: conversations.sse,
7060
- conversationId: selected.id,
7123
+ conversationId: target.conversationId,
7061
7124
  channel,
7062
7125
  displayHandle: formatContactHandle({ handle, channel }),
7063
- loadMessages: (conversationId) => conversations.api.fetchMessages(conversationId),
7064
- onClose: () => setSimulatorOpen(false),
7126
+ loadMessages: (conversationId) => target.persisted ? conversations.api.fetchMessages(conversationId) : Promise.resolve([]),
7127
+ onClose: closeSimulator,
7065
7128
  ...simulator?.labels ? { labels: simulator.labels } : {},
7066
7129
  ...simulator?.uploadMedia ? { uploadMedia: simulator.uploadMedia } : {},
7067
7130
  ...simulator?.pollIntervalMs ? { pollIntervalMs: simulator.pollIntervalMs } : {}
7068
7131
  },
7069
- selected.id
7132
+ target.key
7070
7133
  )
7071
7134
  ) : null })
7072
7135
  ) : null
@@ -7170,6 +7233,7 @@ export {
7170
7233
  SortableHead,
7171
7234
  StatusTicks,
7172
7235
  TEMPLATE_SETTINGS_TAB,
7236
+ TEST_CONTACT_LABEL,
7173
7237
  TOOLTIP_ATTRIBUTE,
7174
7238
  ToastProvider,
7175
7239
  TooltipLayer,
@@ -7204,6 +7268,7 @@ export {
7204
7268
  htmlToWA,
7205
7269
  isReplyOverdue,
7206
7270
  isSameDay,
7271
+ isTestContactNumber,
7207
7272
  isWindowBlocking,
7208
7273
  normalizeForSearch,
7209
7274
  parseWhatsAppFormatting,
@@ -12,7 +12,7 @@ import {
12
12
  formatTimestamp,
13
13
  isSameDay,
14
14
  resolveRecordingFormat
15
- } from "../chunk-WCZNIJ3M.js";
15
+ } from "../chunk-Z7U22M3K.js";
16
16
 
17
17
  // src/participant/ParticipantConversationsScreen.tsx
18
18
  import { useMemo as useMemo7, useReducer as useReducer6, useRef as useRef23, useState as useState18 } from "react";
@@ -1,7 +1,8 @@
1
1
  import { M as MessagePayload } from '../quickReply.types-DzWH3NYV.js';
2
- import { C as ConversationSummary, a as ConversationEventSource, b as ConversationsApi, L as ListConversationsParams, c as ConversationPage, S as SSEProvider, d as ConversationDocument, e as SendPreviewMediaParams, P as PreviewUploadedMedia, f as PreviewWebhookClient, R as ResolveMediaUrl } from '../ConversationSimulatorPanel-P6eqTSAO.js';
3
- export { A as AudioRecorderButton, g as AudioRecorderButtonLabels, h as AudioRecorderButtonProps, i as ConversationPreview, j as ConversationPreviewProps, k as ConversationSimulatorClient, l as ConversationSimulatorPanel, m as ConversationSimulatorPanelLabels, n as ConversationSimulatorPanelProps, o as CreatePreviewMediaUploaderParams, p as CreatePreviewWebhookClientParams, D as DEFAULT_AUDIO_RECORDER_BUTTON_LABELS, q as DEFAULT_CONVERSATION_SIMULATOR_PANEL_LABELS, r as DEFAULT_MEDIA_UPLOAD_PATH, s as PreviewInProductionError, t as PreviewMediaUploadRejectedError, u as PreviewMediaUploadRequest, v as PreviewUploadedMedia, w as PreviewWebhookRejectedError, x as SIMULATOR_FILE_MEDIA_KINDS, y as SendSimulatorMediaParams, z as SimulatorMediaKind, T as ToSimulatorClientParams, B as acceptsMediaKind, E as assertPreviewEnvironment, F as createPreviewMediaPoster, G as createPreviewMediaUploader, H as createPreviewWebhookClient, I as isConversationSimulatorClient, J as mediaKindOf, K as mediaTypeOf, M as signPreviewPayload, N as simulatorPanelLabelsOf, O as toConversationSimulatorClient } from '../ConversationSimulatorPanel-P6eqTSAO.js';
4
- import { InteractiveReplyOption } from '@adatechnology/meta-whatsapp-contracts/testing';
2
+ import { C as ConversationSummary, a as ConversationEventSource, b as ConversationsApi, L as ListConversationsParams, c as ConversationPage, S as SSEProvider, d as ConversationDocument, P as PreviewUploadedMedia, e as PreviewWebhookClient, R as ResolveMediaUrl } from '../ConversationSimulatorPanel-DSVIch04.js';
3
+ export { A as AudioRecorderButton, f as AudioRecorderButtonLabels, g as AudioRecorderButtonProps, h as ConversationPreview, i as ConversationPreviewProps, j as ConversationSimulatorClient, k as ConversationSimulatorPanel, l as ConversationSimulatorPanelLabels, m as ConversationSimulatorPanelProps, n as CreatePreviewMediaUploaderParams, o as CreatePreviewWebhookClientParams, D as DEFAULT_AUDIO_RECORDER_BUTTON_LABELS, p as DEFAULT_CONVERSATION_SIMULATOR_PANEL_LABELS, q as DEFAULT_MEDIA_UPLOAD_PATH, r as PreviewInProductionError, s as PreviewMediaUploadRejectedError, t as PreviewMediaUploadRequest, u as PreviewUploadedMedia, v as PreviewWebhookRejectedError, w as SIMULATOR_FILE_MEDIA_KINDS, x as SendPreviewMediaParams, y as SendSimulatorMediaParams, z as SimulatorMediaKind, T as ToSimulatorClientParams, B as acceptsMediaKind, E as assertPreviewEnvironment, F as createPreviewMediaPoster, G as createPreviewMediaUploader, H as createPreviewWebhookClient, I as isConversationSimulatorClient, J as mediaKindOf, K as mediaTypeOf, M as signPreviewPayload, N as simulatorPanelLabelsOf, O as toConversationSimulatorClient } from '../ConversationSimulatorPanel-DSVIch04.js';
4
+ import { PreviewInboundCommand } from '@adatechnology/meta-whatsapp-contracts/testing';
5
+ export { PreviewInboundCommand } from '@adatechnology/meta-whatsapp-contracts/testing';
5
6
  import * as react from 'react';
6
7
  export { PREVIEW_MEDIA_ID_PREFIX } from '@adatechnology/meta-whatsapp-contracts';
7
8
  import '@adatechnology/conversation-contracts';
@@ -132,37 +133,20 @@ declare const PREVIEW_DOCUMENTS: Readonly<Record<string, readonly ConversationDo
132
133
  * porque token, cookie e cabeçalho de sessão são do produto, não da biblioteca.
133
134
  */
134
135
 
135
- /**
136
- * Comando semântico entregue ao host. É deliberadamente o QUE o cliente fez, não o payload da Meta:
137
- * se o navegador mandasse o payload pronto, a rota viraria um injetor de webhook arbitrário para
138
- * quem tivesse sessão. Mandando a intenção, o servidor é quem escolhe a forma.
139
- */
140
- type PreviewInboundCommand = {
141
- readonly kind: 'text';
142
- readonly from: string;
143
- readonly text: string;
144
- } | {
145
- readonly kind: 'buttonReply';
146
- readonly from: string;
147
- readonly reply: InteractiveReplyOption;
148
- } | {
149
- readonly kind: 'listReply';
150
- readonly from: string;
151
- readonly reply: InteractiveReplyOption;
152
- } | {
153
- readonly kind: 'audio';
154
- readonly from: string;
155
- readonly mediaId: string;
156
- } | ({
157
- readonly kind: 'media';
158
- readonly from: string;
159
- } & SendPreviewMediaParams);
160
136
  type SendPreviewInboundCommand = (command: PreviewInboundCommand) => Promise<void>;
161
137
  declare class PreviewBridgeRejectedError extends Error {
162
138
  readonly status: number;
163
139
  constructor(status: number);
164
140
  }
165
141
  type CreatePreviewBridgeClientParams = {
142
+ /**
143
+ * Número do contato simulado, usado como veio — trocar o número abre outra conversa.
144
+ *
145
+ * Contato de simulador sem chamar a Meta é opt-in nas DUAS pontas: aqui
146
+ * `from: DEFAULT_PREVIEW_CONTACT` (começa com `0`, que nenhum número real usa) e, no servidor,
147
+ * `features.previewContacts: true`. Só um dos lados ligado não serve: sem a flag, o servidor tentaria
148
+ * responder pela Meta a um número que não existe.
149
+ */
166
150
  readonly from: string;
167
151
  /**
168
152
  * Entrega o comando. Use quando o host já tem um cliente HTTP com sessão, interceptors e refresh
@@ -286,4 +270,4 @@ type MediaTypesPreviewProps = {
286
270
  };
287
271
  declare function MediaTypesPreview({ conversationId, className, }: MediaTypesPreviewProps): react.JSX.Element;
288
272
 
289
- export { type AppendMessageParams, type CreateMockConversationsApiParams, type CreateMockSSEProviderParams, type CreatePreviewBridgeClientParams, type CreatePreviewStoreParams, DEFAULT_PREVIEW_SCRIPT, GLOBAL_CHANNEL, type ListConversationsFilters, MEDIA_TYPES_CONVERSATION_ID, MediaTypesPreview, type MediaTypesPreviewProps, type MockEventSource, PREVIEW_CONVERSATIONS, PREVIEW_DOCUMENTS, PREVIEW_FILE_SAMPLES, PREVIEW_MESSAGES, PreviewBridgeRejectedError, type PreviewEmission, type PreviewInboundCommand, type PreviewScriptStep, type PreviewStore, type PreviewStoreListener, PreviewWebhookClient, type SendPreviewInboundCommand, SendPreviewMediaParams, type SetModeParams, type StartPreviewScriptParams, conversationChannel, createMockConversationsApi, createMockEventSource, createMockSSEProvider, createPreviewBridgeClient, createPreviewMediaResolver, createPreviewStore, previewFileBase64, previewFileUrl, resolvePreviewFileSample, startPreviewScript };
273
+ export { type AppendMessageParams, type CreateMockConversationsApiParams, type CreateMockSSEProviderParams, type CreatePreviewBridgeClientParams, type CreatePreviewStoreParams, DEFAULT_PREVIEW_SCRIPT, GLOBAL_CHANNEL, type ListConversationsFilters, MEDIA_TYPES_CONVERSATION_ID, MediaTypesPreview, type MediaTypesPreviewProps, type MockEventSource, PREVIEW_CONVERSATIONS, PREVIEW_DOCUMENTS, PREVIEW_FILE_SAMPLES, PREVIEW_MESSAGES, PreviewBridgeRejectedError, type PreviewEmission, type PreviewScriptStep, type PreviewStore, type PreviewStoreListener, PreviewWebhookClient, type SendPreviewInboundCommand, type SetModeParams, type StartPreviewScriptParams, conversationChannel, createMockConversationsApi, createMockEventSource, createMockSSEProvider, createPreviewBridgeClient, createPreviewMediaResolver, createPreviewStore, previewFileBase64, previewFileUrl, resolvePreviewFileSample, startPreviewScript };
@@ -16,9 +16,9 @@ import {
16
16
  mediaTypeOf,
17
17
  simulatorPanelLabelsOf,
18
18
  toConversationSimulatorClient
19
- } from "../chunk-Y326LLEP.js";
19
+ } from "../chunk-7OLYCCLX.js";
20
20
  import "../chunk-PJNR6UMN.js";
21
- import "../chunk-WCZNIJ3M.js";
21
+ import "../chunk-Z7U22M3K.js";
22
22
 
23
23
  // src/preview/previewStore.ts
24
24
  var GLOBAL_CHANNEL = "global";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adatechnology/conversations-ui",
3
- "version": "0.15.1",
3
+ "version": "0.17.0",
4
4
  "description": "WhatsApp conversation UI components — parametrizável por endpoint, tema e feature flags",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -36,7 +36,7 @@
36
36
  "lucide-react": "^1.21.0",
37
37
  "tailwind-merge": "^3.6.0",
38
38
  "@adatechnology/conversation-contracts": "0.7.0",
39
- "@adatechnology/meta-whatsapp-contracts": "0.7.0"
39
+ "@adatechnology/meta-whatsapp-contracts": "0.9.0"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "@xyflow/react": "^12",
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Copyright (c) 2026 Ada Technology. MIT License.
3
+ *
4
+ * Rotas por palavra-chave (`next.byKeyword`): texto livre que contém a palavra leva ao destino.
5
+ */
6
+
7
+ import type { ReactNode } from 'react'
8
+ import { Plus, Trash2 } from 'lucide-react'
9
+ import type { FlowNodeData } from './flowGraph'
10
+ import type { FlowRunnerFieldLabels } from './labels'
11
+ import { PANEL_FIELD_CLASSNAME, PANEL_HINT_CLASSNAME, PANEL_LABEL_CLASSNAME } from './flowPanelStyles'
12
+
13
+ export type FlowKeywordRoutesFieldProps = {
14
+ draft: FlowNodeData
15
+ onDraftChange: (update: (previous: FlowNodeData) => FlowNodeData) => void
16
+ renderTargetOptions: () => ReactNode
17
+ labels: FlowRunnerFieldLabels
18
+ }
19
+
20
+ function withRoutes(node: FlowNodeData, routes: [string, string][]): FlowNodeData {
21
+ const current: Exclude<FlowNodeData['next'], string | undefined> =
22
+ typeof node.next === 'object' && node.next ? node.next : { byAnswer: {}, default: node.next ?? '' }
23
+ const rest = { ...current }
24
+ delete rest.byKeyword
25
+ return { ...node, next: routes.length > 0 ? { ...rest, byKeyword: Object.fromEntries(routes) } : rest }
26
+ }
27
+
28
+ export function FlowKeywordRoutesField({
29
+ draft,
30
+ onDraftChange,
31
+ renderTargetOptions,
32
+ labels,
33
+ }: FlowKeywordRoutesFieldProps) {
34
+ const routes: [string, string][] =
35
+ typeof draft.next === 'object' && draft.next?.byKeyword ? Object.entries(draft.next.byKeyword) : []
36
+
37
+ function updateRoute(index: number, field: 0 | 1, value: string) {
38
+ const next = routes.map((route, routeIndex): [string, string] => {
39
+ if (routeIndex !== index) return route
40
+ return field === 0 ? [value, route[1]] : [route[0], value]
41
+ })
42
+ onDraftChange((previous) => withRoutes(previous, next))
43
+ }
44
+
45
+ function addRoute() {
46
+ onDraftChange((previous) => withRoutes(previous, [...routes, [labels.keywordPlaceholder, '']]))
47
+ }
48
+
49
+ function removeRoute(index: number) {
50
+ onDraftChange((previous) =>
51
+ withRoutes(
52
+ previous,
53
+ routes.filter((_, routeIndex) => routeIndex !== index),
54
+ ),
55
+ )
56
+ }
57
+
58
+ return (
59
+ <div>
60
+ <div className="flex items-center justify-between">
61
+ <label className={PANEL_LABEL_CLASSNAME}>{labels.keywordRoutes}</label>
62
+ <button
63
+ type="button"
64
+ data-cv-tooltip={labels.addKeywordRoute}
65
+ aria-label={labels.addKeywordRoute}
66
+ onClick={addRoute}
67
+ className="text-xs text-blue-600 hover:underline flex items-center gap-1"
68
+ >
69
+ <Plus size={12} aria-hidden="true" /> {labels.addKeywordRoute}
70
+ </button>
71
+ </div>
72
+ <p className={PANEL_HINT_CLASSNAME}>{labels.keywordRoutesHint}</p>
73
+ <div className="space-y-2 mt-1">
74
+ {routes.map(([keyword, target], index) => (
75
+ <div key={index} className="flex items-center gap-2">
76
+ <input
77
+ value={keyword}
78
+ aria-label={labels.keywordRoutes}
79
+ onChange={(event) => updateRoute(index, 0, event.target.value)}
80
+ className={`w-28 ${PANEL_FIELD_CLASSNAME}`}
81
+ />
82
+ <select
83
+ value={target}
84
+ aria-label={labels.keywordRoutes}
85
+ onChange={(event) => updateRoute(index, 1, event.target.value)}
86
+ className={`flex-1 ${PANEL_FIELD_CLASSNAME}`}
87
+ >
88
+ <option value="">—</option>
89
+ {renderTargetOptions()}
90
+ </select>
91
+ <button
92
+ type="button"
93
+ data-cv-tooltip={labels.removeKeywordRoute}
94
+ aria-label={labels.removeKeywordRoute}
95
+ onClick={() => removeRoute(index)}
96
+ className="text-gray-400 hover:text-red-600"
97
+ >
98
+ <Trash2 size={14} aria-hidden="true" />
99
+ </button>
100
+ </div>
101
+ ))}
102
+ </div>
103
+ </div>
104
+ )
105
+ }
@@ -17,7 +17,7 @@
17
17
  import { useState } from 'react'
18
18
  import { ChevronDown, ChevronUp, RotateCcw } from 'lucide-react'
19
19
 
20
- import type { FlowEditorLabels } from './labels'
20
+ import { DEFAULT_FLOW_EDITOR_LABELS, type FlowEditorLabels } from './labels'
21
21
  import type { FlowNodeType } from './flowGraph'
22
22
 
23
23
  export type FlowLegendEdgeSample = {
@@ -88,7 +88,7 @@ export function FlowLegend({ labels, edgeSamples, nodeSwatches }: FlowLegendProp
88
88
  <li key={swatch.type} className="flex items-center gap-2">
89
89
  <span className={`h-3 w-5 shrink-0 rounded border-2 ${swatch.className}`} aria-hidden="true" />
90
90
  <span className="text-[11px] leading-tight text-gray-600 dark:text-gray-300">
91
- {labels.legend[swatch.type]}
91
+ {labels.legend[swatch.type] ?? DEFAULT_FLOW_EDITOR_LABELS.legend.dynamic_choice}
92
92
  </span>
93
93
  </li>
94
94
  ))}