@adatechnology/conversations-ui 0.16.0 → 0.18.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.
- package/README.md +23 -0
- package/dist/{chunk-Y326LLEP.js → chunk-7OLYCCLX.js} +1 -1
- package/dist/{chunk-WCZNIJ3M.js → chunk-Z7U22M3K.js} +7 -0
- package/dist/flows/index.d.ts +52 -6
- package/dist/flows/index.js +470 -245
- package/dist/index.d.ts +77 -3
- package/dist/index.js +148 -23
- package/dist/participant/index.js +1 -1
- package/dist/preview/index.js +2 -2
- package/package.json +2 -2
- package/src/flows/FlowNodeCard.tsx +17 -7
- package/src/flows/FlowNodePanel.tsx +10 -0
- package/src/flows/FlowPossibleNextField.tsx +89 -0
- package/src/flows/FlowRunnerFields.tsx +70 -16
- package/src/flows/FlowsWorkspace.tsx +8 -2
- package/src/flows/flowCanvasModel.ts +16 -1
- package/src/flows/flowEditorOps.ts +19 -2
- package/src/flows/flowGraph.ts +108 -11
- package/src/flows/flowLabelValidation.test.ts +92 -0
- package/src/flows/flowPossibleNext.test.ts +70 -0
- package/src/flows/index.ts +3 -0
- package/src/flows/labels.ts +39 -1
- package/src/index.ts +11 -1
- package/src/lib/phone.test.ts +20 -0
- package/src/lib/phone.ts +13 -0
- package/src/quickReplies/createMetaWhatsAppQuickRepliesClient.test.ts +113 -0
- package/src/quickReplies/createMetaWhatsAppQuickRepliesClient.ts +111 -0
- package/src/workspace/ConversationPane.tsx +13 -2
- package/src/workspace/ConversationsWorkspace.tsx +117 -18
- package/src/workspace/index.ts +1 -0
- package/src/workspace/labels.ts +2 -0
- package/src/workspace/workspaceTestContactDom.test.tsx +96 -0
package/dist/index.d.ts
CHANGED
|
@@ -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
|
|
|
@@ -1956,6 +1963,49 @@ type QuickRepliesPickerProps = {
|
|
|
1956
1963
|
*/
|
|
1957
1964
|
declare function QuickRepliesPicker({ id, items, search, highlightedIndex, isLoading, hasError, onHover, onSelect, labels, className, ownSearch, variables, hasAttachmentsCapability, }: QuickRepliesPickerProps): react.JSX.Element;
|
|
1958
1965
|
|
|
1966
|
+
/**
|
|
1967
|
+
* Copyright (c) 2026 Ada Technology. MIT License.
|
|
1968
|
+
*
|
|
1969
|
+
* Porta de respostas rápidas pronta para as rotas de `createMetaWhatsAppQuickReplyRoutes`
|
|
1970
|
+
* (`@adatechnology/meta-whatsapp-module`). O resultado se espalha em `ConversationsApi` e satisfaz
|
|
1971
|
+
* `QuickRepliesWorkspaceApi`; sem ele cada host reescrevia a mesma ponte — e errava o envelope.
|
|
1972
|
+
*
|
|
1973
|
+
* Só texto: anexos de resposta rápida não existem no módulo, então não há `uploadQuickReplyAttachment`
|
|
1974
|
+
* e as telas não oferecem a seção de anexos.
|
|
1975
|
+
*/
|
|
1976
|
+
|
|
1977
|
+
type CreateMetaWhatsAppQuickRepliesClientParams = {
|
|
1978
|
+
/** Onde o host montou as rotas, ex.: `/v1/whatsapp`. Sem barra no fim; `/quick-replies` é acrescentado. */
|
|
1979
|
+
readonly baseUrl: string;
|
|
1980
|
+
/** Cabeçalhos por requisição (o `Authorization` do host). Chamado a cada request. */
|
|
1981
|
+
readonly getHeaders?: () => Record<string, string> | Promise<Record<string, string>>;
|
|
1982
|
+
readonly fetch?: typeof fetch;
|
|
1983
|
+
};
|
|
1984
|
+
type MetaWhatsAppQuickRepliesClient = {
|
|
1985
|
+
readonly listQuickReplies: (params?: {
|
|
1986
|
+
search?: string;
|
|
1987
|
+
}) => Promise<QuickReply$1[]>;
|
|
1988
|
+
readonly createQuickReply: (input: QuickReplyInput) => Promise<QuickReply$1>;
|
|
1989
|
+
readonly updateQuickReply: (id: string, input: QuickReplyInput) => Promise<QuickReply$1>;
|
|
1990
|
+
readonly deleteQuickReply: (id: string) => Promise<void>;
|
|
1991
|
+
};
|
|
1992
|
+
type QuickRepliesApiErrorDetail = {
|
|
1993
|
+
readonly field: string;
|
|
1994
|
+
readonly message: string;
|
|
1995
|
+
};
|
|
1996
|
+
/**
|
|
1997
|
+
* Erro da API com `code` estável e `details` no formato que o `QuickRepliesWorkspace` lê
|
|
1998
|
+
* (`{ field, message }`): a validação do módulo devolve `issues[{ path, message }]`, traduzido aqui
|
|
1999
|
+
* para o erro aparecer no campo certo do formulário.
|
|
2000
|
+
*/
|
|
2001
|
+
declare class QuickRepliesApiError extends Error {
|
|
2002
|
+
readonly status: number;
|
|
2003
|
+
readonly code: string;
|
|
2004
|
+
readonly details: readonly QuickRepliesApiErrorDetail[];
|
|
2005
|
+
constructor(message: string, status: number, code: string, details?: readonly QuickRepliesApiErrorDetail[]);
|
|
2006
|
+
}
|
|
2007
|
+
declare function createMetaWhatsAppQuickRepliesClient(params: CreateMetaWhatsAppQuickRepliesClientParams): MetaWhatsAppQuickRepliesClient;
|
|
2008
|
+
|
|
1959
2009
|
declare function normalizeForSearch(value: string): string;
|
|
1960
2010
|
type FilterQuickRepliesParams = {
|
|
1961
2011
|
readonly quickReplies: readonly QuickReply$1[];
|
|
@@ -1992,6 +2042,7 @@ interface ConversationsWorkspaceLabels {
|
|
|
1992
2042
|
readonly selectAll: string;
|
|
1993
2043
|
readonly emptyList: string;
|
|
1994
2044
|
readonly emptyDetail: string;
|
|
2045
|
+
readonly newTestContact: string;
|
|
1995
2046
|
readonly bulkSelected: (count: number) => string;
|
|
1996
2047
|
readonly bulkClear: string;
|
|
1997
2048
|
readonly bulkFinalize: string;
|
|
@@ -2127,6 +2178,17 @@ type SimulatorTransportParams = {
|
|
|
2127
2178
|
* site, o cliente das rotas do widget.
|
|
2128
2179
|
*/
|
|
2129
2180
|
type SimulatorTransportFactory = (params: SimulatorTransportParams) => ConversationSimulatorClient;
|
|
2181
|
+
/**
|
|
2182
|
+
* Contato de teste que o host cria para abrir o simulador sem conversa selecionada. `handle` é o
|
|
2183
|
+
* identificador no canal (no WhatsApp, um número de teste começando com `0`, que nenhum país usa).
|
|
2184
|
+
*/
|
|
2185
|
+
type SimulatorTestContact = {
|
|
2186
|
+
readonly handle: string;
|
|
2187
|
+
/** Ausente = WhatsApp. */
|
|
2188
|
+
readonly channel?: ConversationChannel;
|
|
2189
|
+
/** Id da conversa quando o host já o conhece. Ausente, usa `handle` e o transcript começa vazio. */
|
|
2190
|
+
readonly conversationId?: string;
|
|
2191
|
+
};
|
|
2130
2192
|
interface ConversationsWorkspaceSimulator {
|
|
2131
2193
|
/**
|
|
2132
2194
|
* Um transporte por canal — o workspace monta o painel com o da conversa selecionada.
|
|
@@ -2158,6 +2220,14 @@ interface ConversationsWorkspaceSimulator {
|
|
|
2158
2220
|
readonly uploadMedia?: (file: File) => Promise<PreviewUploadedMedia>;
|
|
2159
2221
|
/** Recarrega o transcript a cada N ms. Serve a host sem stream. */
|
|
2160
2222
|
readonly pollIntervalMs?: number;
|
|
2223
|
+
/**
|
|
2224
|
+
* Liga "Novo contato de teste" no cabeçalho da página: o host devolve o contato e o simulador
|
|
2225
|
+
* abre sem conversa selecionada. Quando a conversa dele aparece na lista, ela é selecionada.
|
|
2226
|
+
* Ausente, o simulador só abre sobre uma conversa existente.
|
|
2227
|
+
*/
|
|
2228
|
+
readonly createTestContact?: () => SimulatorTestContact | Promise<SimulatorTestContact>;
|
|
2229
|
+
/** Rótulo do botão de novo contato. Padrão: "Novo contato de teste". */
|
|
2230
|
+
readonly newContactLabel?: string;
|
|
2161
2231
|
}
|
|
2162
2232
|
interface ConversationsWorkspaceProps {
|
|
2163
2233
|
readonly labels?: Partial<ConversationsWorkspaceLabels>;
|
|
@@ -2201,6 +2271,8 @@ interface ConversationsWorkspaceProps {
|
|
|
2201
2271
|
/** Nota de voz. Ausente, o microfone não aparece. */
|
|
2202
2272
|
readonly onRecordAudio?: (conversation: ConversationSummary, file: File) => Promise<void>;
|
|
2203
2273
|
readonly contextEntriesOf?: (context: Record<string, unknown> | undefined) => readonly ConversationContextEntry[];
|
|
2274
|
+
/** Vocabulário do painel de contexto (`title`, `empty`, `notCollected`...). */
|
|
2275
|
+
readonly contextLabels?: Partial<ConversationContextPanelLabels>;
|
|
2204
2276
|
readonly onAttach?: (conversation: ConversationSummary, file: File) => Promise<void>;
|
|
2205
2277
|
readonly extraUtilitiesFor?: (conversation: ConversationSummary) => readonly ConversationHeaderUtility[];
|
|
2206
2278
|
readonly renderFilters?: (inbox: UseConversationsInboxResult) => ReactNode;
|
|
@@ -2213,7 +2285,7 @@ interface ConversationsWorkspaceProps {
|
|
|
2213
2285
|
readonly signInHref?: string;
|
|
2214
2286
|
readonly className?: string;
|
|
2215
2287
|
}
|
|
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;
|
|
2288
|
+
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
2289
|
|
|
2218
2290
|
interface ConversationPaneProps {
|
|
2219
2291
|
readonly conversation: ConversationSummary;
|
|
@@ -2228,6 +2300,8 @@ interface ConversationPaneProps {
|
|
|
2228
2300
|
readonly extraUtilities?: readonly ConversationHeaderUtility[];
|
|
2229
2301
|
/** Traduz o contexto cru do produto nas linhas do painel. Ausente, o painel não aparece. */
|
|
2230
2302
|
readonly contextEntriesOf?: (context: Record<string, unknown> | undefined) => readonly ConversationContextEntry[];
|
|
2303
|
+
/** Vocabulário do painel de contexto (`title`, `empty`, `notCollected`...). */
|
|
2304
|
+
readonly contextLabels?: Partial<ConversationContextPanelLabels>;
|
|
2231
2305
|
readonly quickReplies?: readonly QuickReply[];
|
|
2232
2306
|
/**
|
|
2233
2307
|
* Recebe o contexto junto porque o dado que interessa à variável (o nome que o bot perguntou,
|
|
@@ -2285,7 +2359,7 @@ interface ConversationPaneProps {
|
|
|
2285
2359
|
/** Grava e envia nota de voz. Ausente, o microfone não aparece. */
|
|
2286
2360
|
readonly onRecordAudio?: (file: File) => Promise<void>;
|
|
2287
2361
|
}
|
|
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;
|
|
2362
|
+
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
2363
|
|
|
2290
2364
|
interface ConversationsInboxListProps {
|
|
2291
2365
|
readonly inbox: UseConversationsInboxResult;
|
|
@@ -2322,4 +2396,4 @@ type QueuedAttachmentsListProps = {
|
|
|
2322
2396
|
};
|
|
2323
2397
|
declare function QueuedAttachmentsList({ items, statusOf, onRemove, onRetry, retryingKeys, getThumbnailUrl, labels, busy, }: QueuedAttachmentsListProps): react.JSX.Element | null;
|
|
2324
2398
|
|
|
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 };
|
|
2399
|
+
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, type CreateMetaWhatsAppQuickRepliesClientParams, 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, type MetaWhatsAppQuickRepliesClient, MultiSelectFilter, type MultiSelectFilterProps, NARROW_MAX_WIDTH_PX, type OutgoingItems, QueuedAttachment, QueuedAttachmentsList, QuickRepliesApiError, type QuickRepliesApiErrorDetail, 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, createMetaWhatsAppQuickRepliesClient, 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-
|
|
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-
|
|
101
|
+
} from "./chunk-Z7U22M3K.js";
|
|
100
102
|
|
|
101
103
|
// src/RichMessageComposer.tsx
|
|
102
104
|
import {
|
|
@@ -5553,9 +5555,67 @@ function QuickRepliesWorkspace({
|
|
|
5553
5555
|
] });
|
|
5554
5556
|
}
|
|
5555
5557
|
|
|
5558
|
+
// src/quickReplies/createMetaWhatsAppQuickRepliesClient.ts
|
|
5559
|
+
var QuickRepliesApiError = class extends Error {
|
|
5560
|
+
constructor(message, status, code, details = []) {
|
|
5561
|
+
super(message);
|
|
5562
|
+
this.status = status;
|
|
5563
|
+
this.code = code;
|
|
5564
|
+
this.details = details;
|
|
5565
|
+
this.name = "QuickRepliesApiError";
|
|
5566
|
+
}
|
|
5567
|
+
};
|
|
5568
|
+
async function toApiError(response) {
|
|
5569
|
+
const body = await response.json().catch(() => void 0);
|
|
5570
|
+
const details = (body?.error?.issues ?? []).flatMap(
|
|
5571
|
+
(issue) => issue.path && issue.message ? [{ field: issue.path, message: issue.message }] : []
|
|
5572
|
+
);
|
|
5573
|
+
return new QuickRepliesApiError(
|
|
5574
|
+
body?.error?.message ?? `Falha na API de respostas r\xE1pidas (${response.status})`,
|
|
5575
|
+
response.status,
|
|
5576
|
+
body?.error?.code ?? "HTTP_ERROR",
|
|
5577
|
+
details
|
|
5578
|
+
);
|
|
5579
|
+
}
|
|
5580
|
+
function toBody(input) {
|
|
5581
|
+
return { title: input.title, shortcut: input.shortcut, body: input.body };
|
|
5582
|
+
}
|
|
5583
|
+
function createMetaWhatsAppQuickRepliesClient(params) {
|
|
5584
|
+
const fetchImpl = params.fetch ?? globalThis.fetch.bind(globalThis);
|
|
5585
|
+
const collectionUrl = `${params.baseUrl}/quick-replies`;
|
|
5586
|
+
async function request(url, method, json) {
|
|
5587
|
+
const headers = { ...await params.getHeaders?.() };
|
|
5588
|
+
if (json !== void 0) headers["content-type"] = "application/json";
|
|
5589
|
+
const response = await fetchImpl(url, {
|
|
5590
|
+
method,
|
|
5591
|
+
headers,
|
|
5592
|
+
...json === void 0 ? {} : { body: JSON.stringify(json) }
|
|
5593
|
+
});
|
|
5594
|
+
if (!response.ok) throw await toApiError(response);
|
|
5595
|
+
return response;
|
|
5596
|
+
}
|
|
5597
|
+
async function requestData(url, method, json) {
|
|
5598
|
+
const response = await request(url, method, json);
|
|
5599
|
+
return (await response.json()).data;
|
|
5600
|
+
}
|
|
5601
|
+
const itemUrl = (id) => `${collectionUrl}/${encodeURIComponent(id)}`;
|
|
5602
|
+
return {
|
|
5603
|
+
listQuickReplies: (listParams) => {
|
|
5604
|
+
const search = listParams?.search?.trim();
|
|
5605
|
+
const query = search ? `?${new URLSearchParams({ search }).toString()}` : "";
|
|
5606
|
+
return requestData(`${collectionUrl}${query}`, "GET");
|
|
5607
|
+
},
|
|
5608
|
+
createQuickReply: (input) => requestData(collectionUrl, "POST", toBody(input)),
|
|
5609
|
+
updateQuickReply: (id, input) => requestData(itemUrl(id), "PUT", toBody(input)),
|
|
5610
|
+
deleteQuickReply: async (id) => {
|
|
5611
|
+
await request(itemUrl(id), "DELETE");
|
|
5612
|
+
}
|
|
5613
|
+
};
|
|
5614
|
+
}
|
|
5615
|
+
|
|
5556
5616
|
// src/workspace/ConversationsWorkspace.tsx
|
|
5557
5617
|
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";
|
|
5618
|
+
import { Check as Check2, CheckCheck, FlaskConical, Hourglass as Hourglass2, Mail as Mail2, MessagesSquare, UserPlus } from "lucide-react";
|
|
5559
5619
|
|
|
5560
5620
|
// src/workspace/BulkTemplateModal.tsx
|
|
5561
5621
|
import { useEffect as useEffect15, useMemo as useMemo5, useState as useState20 } from "react";
|
|
@@ -6111,6 +6171,7 @@ function ConversationPane({
|
|
|
6111
6171
|
onBack,
|
|
6112
6172
|
extraUtilities,
|
|
6113
6173
|
contextEntriesOf,
|
|
6174
|
+
contextLabels,
|
|
6114
6175
|
quickReplies,
|
|
6115
6176
|
quickReplyVariablesFor,
|
|
6116
6177
|
flowLabel,
|
|
@@ -6277,7 +6338,14 @@ function ConversationPane({
|
|
|
6277
6338
|
...extraUtilities ? { extraUtilities } : {}
|
|
6278
6339
|
}
|
|
6279
6340
|
),
|
|
6280
|
-
contextEntries && contextEntries.length > 0 || flowLabel ? /* @__PURE__ */ jsx32(
|
|
6341
|
+
contextEntries && contextEntries.length > 0 || flowLabel ? /* @__PURE__ */ jsx32(
|
|
6342
|
+
ConversationContextPanel,
|
|
6343
|
+
{
|
|
6344
|
+
entries: contextEntries ?? [],
|
|
6345
|
+
...flowLabel ? { flowLabel } : {},
|
|
6346
|
+
...contextLabels ? { labels: contextLabels } : {}
|
|
6347
|
+
}
|
|
6348
|
+
) : null,
|
|
6281
6349
|
/* @__PURE__ */ jsx32(ConversationDocumentsPanel, { conversationId: conversation.id, open: documentsOpen }),
|
|
6282
6350
|
renderAboveTranscript?.(conversation, conversationContext),
|
|
6283
6351
|
/* @__PURE__ */ jsxs28(
|
|
@@ -6600,6 +6668,7 @@ var DEFAULT_CONVERSATIONS_WORKSPACE_LABELS = {
|
|
|
6600
6668
|
selectAll: "Selecionar todas",
|
|
6601
6669
|
emptyList: "Nenhuma conversa encontrada.",
|
|
6602
6670
|
emptyDetail: "Selecione uma conversa.",
|
|
6671
|
+
newTestContact: "Novo contato de teste",
|
|
6603
6672
|
bulkSelected: (count) => `${count} selecionada${count === 1 ? "" : "s"}`,
|
|
6604
6673
|
bulkClear: "Limpar sele\xE7\xE3o",
|
|
6605
6674
|
bulkFinalize: "Finalizar",
|
|
@@ -6819,6 +6888,9 @@ function useConversationsInbox(params = {}) {
|
|
|
6819
6888
|
|
|
6820
6889
|
// src/workspace/ConversationsWorkspace.tsx
|
|
6821
6890
|
import { Fragment as Fragment8, jsx as jsx34, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
6891
|
+
function handleOf(conversation) {
|
|
6892
|
+
return conversation.contactId ?? conversation.whatsappNumber;
|
|
6893
|
+
}
|
|
6822
6894
|
function ConversationsWorkspace({
|
|
6823
6895
|
labels: labelsOverride,
|
|
6824
6896
|
filters,
|
|
@@ -6841,6 +6913,7 @@ function ConversationsWorkspace({
|
|
|
6841
6913
|
onSendAttachments,
|
|
6842
6914
|
onRecordAudio,
|
|
6843
6915
|
contextEntriesOf,
|
|
6916
|
+
contextLabels,
|
|
6844
6917
|
onAttach,
|
|
6845
6918
|
extraUtilitiesFor,
|
|
6846
6919
|
renderFilters,
|
|
@@ -6860,32 +6933,65 @@ function ConversationsWorkspace({
|
|
|
6860
6933
|
...serverPaginated ? { serverPaginated } : {}
|
|
6861
6934
|
});
|
|
6862
6935
|
const [simulatorOpen, setSimulatorOpen] = useState26(false);
|
|
6936
|
+
const [testContact, setTestContact] = useState26(void 0);
|
|
6863
6937
|
const [templateModalOpen, setTemplateModalOpen] = useState26(false);
|
|
6864
6938
|
const [openedFromLink, setOpenedFromLink] = useState26(void 0);
|
|
6865
6939
|
useEffect20(() => {
|
|
6866
6940
|
const link = initialConversationId ?? initialWhatsappNumber;
|
|
6867
6941
|
if (!link || openedFromLink === link) return;
|
|
6868
|
-
const
|
|
6942
|
+
const target2 = inbox.conversations.find(
|
|
6869
6943
|
(conversation) => conversation.id === initialConversationId || conversation.whatsappNumber === initialWhatsappNumber
|
|
6870
6944
|
);
|
|
6871
|
-
if (!
|
|
6872
|
-
inbox.selectConversation(
|
|
6945
|
+
if (!target2) return;
|
|
6946
|
+
inbox.selectConversation(target2.id);
|
|
6873
6947
|
setOpenedFromLink(link);
|
|
6874
6948
|
}, [initialConversationId, initialWhatsappNumber, openedFromLink, inbox]);
|
|
6875
6949
|
const selected = inbox.selectedConversation;
|
|
6950
|
+
useEffect20(() => {
|
|
6951
|
+
if (!testContact) return;
|
|
6952
|
+
const created = inbox.conversations.find((conversation) => handleOf(conversation) === testContact.handle);
|
|
6953
|
+
if (!created) return;
|
|
6954
|
+
inbox.selectConversation(created.id);
|
|
6955
|
+
setTestContact(void 0);
|
|
6956
|
+
}, [testContact, inbox]);
|
|
6876
6957
|
const conversations = useConversations();
|
|
6877
|
-
const
|
|
6878
|
-
|
|
6879
|
-
|
|
6958
|
+
const target = selected ? {
|
|
6959
|
+
key: selected.id,
|
|
6960
|
+
conversationId: selected.id,
|
|
6961
|
+
channel: selected.channel ?? DEFAULT_CONVERSATION_CHANNEL,
|
|
6962
|
+
handle: handleOf(selected),
|
|
6963
|
+
persisted: true
|
|
6964
|
+
} : testContact ? {
|
|
6965
|
+
key: `test-contact:${testContact.handle}`,
|
|
6966
|
+
// Sem id conhecido, o próprio identificador: é a chave do stream por conversa (`conv:<número>`).
|
|
6967
|
+
conversationId: testContact.conversationId ?? testContact.handle,
|
|
6968
|
+
channel: testContact.channel ?? DEFAULT_CONVERSATION_CHANNEL,
|
|
6969
|
+
handle: testContact.handle,
|
|
6970
|
+
persisted: testContact.conversationId !== void 0
|
|
6971
|
+
} : void 0;
|
|
6972
|
+
const channel = target?.channel ?? DEFAULT_CONVERSATION_CHANNEL;
|
|
6973
|
+
const targetConversationId = target?.conversationId;
|
|
6974
|
+
const handle = target?.handle ?? "";
|
|
6880
6975
|
const transport = simulator?.transports?.[channel];
|
|
6881
|
-
const
|
|
6882
|
-
|
|
6883
|
-
);
|
|
6884
|
-
const
|
|
6976
|
+
const simulatorAvailable = Boolean(simulator && (simulator.enabled ?? true));
|
|
6977
|
+
const simulatorEnabled = simulatorAvailable && Boolean(simulator?.render ?? transport);
|
|
6978
|
+
const showSimulator = simulatorEnabled && simulatorOpen && Boolean(target);
|
|
6979
|
+
const canCreateTestContact = simulatorAvailable && Boolean(simulator?.createTestContact);
|
|
6885
6980
|
const simulatorClient = useMemo7(
|
|
6886
|
-
() => transport &&
|
|
6887
|
-
[transport,
|
|
6981
|
+
() => transport && targetConversationId !== void 0 ? transport({ conversationId: targetConversationId, channel, handle }) : void 0,
|
|
6982
|
+
[transport, targetConversationId, channel, handle]
|
|
6888
6983
|
);
|
|
6984
|
+
async function handleCreateTestContact() {
|
|
6985
|
+
const contact = await simulator?.createTestContact?.();
|
|
6986
|
+
if (!contact) return;
|
|
6987
|
+
inbox.clearSelection();
|
|
6988
|
+
setTestContact(contact);
|
|
6989
|
+
setSimulatorOpen(true);
|
|
6990
|
+
}
|
|
6991
|
+
function closeSimulator() {
|
|
6992
|
+
setSimulatorOpen(false);
|
|
6993
|
+
setTestContact(void 0);
|
|
6994
|
+
}
|
|
6889
6995
|
const paneUtilities = useMemo7(() => {
|
|
6890
6996
|
if (!selected) return void 0;
|
|
6891
6997
|
const fromProduct = extraUtilitiesFor?.(selected) ?? [];
|
|
@@ -6987,6 +7093,20 @@ function ConversationsWorkspace({
|
|
|
6987
7093
|
]
|
|
6988
7094
|
}
|
|
6989
7095
|
) : null,
|
|
7096
|
+
canCreateTestContact ? /* @__PURE__ */ jsxs30(
|
|
7097
|
+
"button",
|
|
7098
|
+
{
|
|
7099
|
+
type: "button",
|
|
7100
|
+
onClick: () => void handleCreateTestContact(),
|
|
7101
|
+
"data-cv-tooltip": simulator?.newContactLabel ?? labels.newTestContact,
|
|
7102
|
+
"aria-label": simulator?.newContactLabel ?? labels.newTestContact,
|
|
7103
|
+
className: "cv-workspace-toggle",
|
|
7104
|
+
children: [
|
|
7105
|
+
/* @__PURE__ */ jsx34(UserPlus, { size: ICON_SIZE_ACTION, "aria-hidden": "true" }),
|
|
7106
|
+
/* @__PURE__ */ jsx34("span", { className: "cv-only-wide", children: simulator?.newContactLabel ?? labels.newTestContact })
|
|
7107
|
+
]
|
|
7108
|
+
}
|
|
7109
|
+
) : null,
|
|
6990
7110
|
renderHeaderActions?.(inbox)
|
|
6991
7111
|
] })
|
|
6992
7112
|
] }),
|
|
@@ -7001,7 +7121,7 @@ function ConversationsWorkspace({
|
|
|
7001
7121
|
"div",
|
|
7002
7122
|
{
|
|
7003
7123
|
className: `cv-workspace-grid${showSimulator ? " cv-workspace-grid--with-simulator" : ""}`,
|
|
7004
|
-
"data-detail": selected ? "open" : "closed",
|
|
7124
|
+
"data-detail": selected || showSimulator ? "open" : "closed",
|
|
7005
7125
|
children: [
|
|
7006
7126
|
/* @__PURE__ */ jsx34(
|
|
7007
7127
|
ConversationsInboxList,
|
|
@@ -7040,16 +7160,17 @@ function ConversationsWorkspace({
|
|
|
7040
7160
|
onBack: inbox.clearSelection,
|
|
7041
7161
|
...paneUtilities ? { extraUtilities: paneUtilities } : {},
|
|
7042
7162
|
...contextEntriesOf ? { contextEntriesOf } : {},
|
|
7163
|
+
...contextLabels ? { contextLabels } : {},
|
|
7043
7164
|
...quickReplies ? { quickReplies } : {},
|
|
7044
7165
|
...quickReplyVariablesFor ? { quickReplyVariablesFor } : {},
|
|
7045
7166
|
...renderAboveTranscript ? { renderAboveTranscript } : {},
|
|
7046
7167
|
...onAttach ? { onAttach: (file) => onAttach(selected, file) } : {}
|
|
7047
7168
|
}
|
|
7048
7169
|
) : /* @__PURE__ */ jsx34("p", { className: "cv-workspace-empty", children: labels.emptyDetail }) }),
|
|
7049
|
-
showSimulator &&
|
|
7170
|
+
showSimulator && target ? (
|
|
7050
7171
|
// `min-height:0` junto do `min-width:0`: sem isso a linha do grid cresce com o conteúdo do
|
|
7051
7172
|
// 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:
|
|
7173
|
+
/* @__PURE__ */ jsx34("div", { className: "cv-workspace-simulator", children: simulator?.render ? simulator.render({ conversationId: target.conversationId, channel, close: closeSimulator }) : simulatorClient && conversations ? (
|
|
7053
7174
|
// `key` pela conversa: trocar de contato sem remontar deixaria o transcript e o campo
|
|
7054
7175
|
// de texto do contato anterior na tela.
|
|
7055
7176
|
/* @__PURE__ */ jsx34(
|
|
@@ -7057,16 +7178,16 @@ function ConversationsWorkspace({
|
|
|
7057
7178
|
{
|
|
7058
7179
|
client: simulatorClient,
|
|
7059
7180
|
sse: conversations.sse,
|
|
7060
|
-
conversationId:
|
|
7181
|
+
conversationId: target.conversationId,
|
|
7061
7182
|
channel,
|
|
7062
7183
|
displayHandle: formatContactHandle({ handle, channel }),
|
|
7063
|
-
loadMessages: (conversationId) => conversations.api.fetchMessages(conversationId),
|
|
7064
|
-
onClose:
|
|
7184
|
+
loadMessages: (conversationId) => target.persisted ? conversations.api.fetchMessages(conversationId) : Promise.resolve([]),
|
|
7185
|
+
onClose: closeSimulator,
|
|
7065
7186
|
...simulator?.labels ? { labels: simulator.labels } : {},
|
|
7066
7187
|
...simulator?.uploadMedia ? { uploadMedia: simulator.uploadMedia } : {},
|
|
7067
7188
|
...simulator?.pollIntervalMs ? { pollIntervalMs: simulator.pollIntervalMs } : {}
|
|
7068
7189
|
},
|
|
7069
|
-
|
|
7190
|
+
target.key
|
|
7070
7191
|
)
|
|
7071
7192
|
) : null })
|
|
7072
7193
|
) : null
|
|
@@ -7158,6 +7279,7 @@ export {
|
|
|
7158
7279
|
NARROW_MAX_WIDTH_PX,
|
|
7159
7280
|
QUICK_REPLY_ATTACHMENT_LIMIT,
|
|
7160
7281
|
QueuedAttachmentsList,
|
|
7282
|
+
QuickRepliesApiError,
|
|
7161
7283
|
QuickRepliesPicker,
|
|
7162
7284
|
QuickRepliesWorkspace,
|
|
7163
7285
|
REOPEN_MECHANISM,
|
|
@@ -7170,6 +7292,7 @@ export {
|
|
|
7170
7292
|
SortableHead,
|
|
7171
7293
|
StatusTicks,
|
|
7172
7294
|
TEMPLATE_SETTINGS_TAB,
|
|
7295
|
+
TEST_CONTACT_LABEL,
|
|
7173
7296
|
TOOLTIP_ATTRIBUTE,
|
|
7174
7297
|
ToastProvider,
|
|
7175
7298
|
TooltipLayer,
|
|
@@ -7192,6 +7315,7 @@ export {
|
|
|
7192
7315
|
channelFiltersFor,
|
|
7193
7316
|
contactFlag,
|
|
7194
7317
|
createMediaUrlResolver,
|
|
7318
|
+
createMetaWhatsAppQuickRepliesClient,
|
|
7195
7319
|
downloadTextFile,
|
|
7196
7320
|
filterQuickReplies,
|
|
7197
7321
|
formatContactHandle,
|
|
@@ -7204,6 +7328,7 @@ export {
|
|
|
7204
7328
|
htmlToWA,
|
|
7205
7329
|
isReplyOverdue,
|
|
7206
7330
|
isSameDay,
|
|
7331
|
+
isTestContactNumber,
|
|
7207
7332
|
isWindowBlocking,
|
|
7208
7333
|
normalizeForSearch,
|
|
7209
7334
|
parseWhatsAppFormatting,
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
formatTimestamp,
|
|
13
13
|
isSameDay,
|
|
14
14
|
resolveRecordingFormat
|
|
15
|
-
} from "../chunk-
|
|
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";
|
package/dist/preview/index.js
CHANGED
|
@@ -16,9 +16,9 @@ import {
|
|
|
16
16
|
mediaTypeOf,
|
|
17
17
|
simulatorPanelLabelsOf,
|
|
18
18
|
toConversationSimulatorClient
|
|
19
|
-
} from "../chunk-
|
|
19
|
+
} from "../chunk-7OLYCCLX.js";
|
|
20
20
|
import "../chunk-PJNR6UMN.js";
|
|
21
|
-
import "../chunk-
|
|
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.
|
|
3
|
+
"version": "0.18.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.
|
|
39
|
+
"@adatechnology/meta-whatsapp-contracts": "0.10.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@xyflow/react": "^12",
|
|
@@ -16,8 +16,8 @@ import {
|
|
|
16
16
|
type LucideIcon,
|
|
17
17
|
ListChecks,
|
|
18
18
|
} from 'lucide-react'
|
|
19
|
-
import { DEFAULT_FLOW_EDITOR_LABELS, type FlowEditorLabels } from './labels'
|
|
20
|
-
import { isPassThroughAction, keywordHandle, type FlowNodeData, type GraphIssue } from './flowGraph'
|
|
19
|
+
import { DEFAULT_FLOW_EDITOR_LABELS, OPTIONAL_RUNNER_FIELD_LABEL_DEFAULTS, type FlowEditorLabels } from './labels'
|
|
20
|
+
import { isPassThroughAction, keywordHandle, possibleNextHandle, type FlowNodeData, type GraphIssue } from './flowGraph'
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Diâmetro dos pontos de ligação.
|
|
@@ -130,9 +130,19 @@ function selfLoopHandles(node: FlowNodeData): Set<string> {
|
|
|
130
130
|
function sourceRows(node: FlowNodeData, labels: FlowEditorLabels): SourceRowSpec[] {
|
|
131
131
|
// Ação de passagem tem saída; ação terminal, não — ver `isPassThroughAction`.
|
|
132
132
|
if (node.type === 'action') {
|
|
133
|
-
|
|
133
|
+
const rowLabel =
|
|
134
|
+
labels.runnerFields?.possibleNextRowLabel ?? OPTIONAL_RUNNER_FIELD_LABEL_DEFAULTS.possibleNextRowLabel
|
|
135
|
+
// Destinos que a action pode devolver: linha própria, com o visual esmaecido do "caso contrário".
|
|
136
|
+
const possibleRows = (node.possibleNext ?? []).map((target) => ({
|
|
137
|
+
id: possibleNextHandle(target),
|
|
138
|
+
label: `${rowLabel}: ${target}`,
|
|
139
|
+
isDefault: true,
|
|
140
|
+
isSelfLoop: target === node.id,
|
|
141
|
+
}))
|
|
142
|
+
const nextRows = isPassThroughAction(node)
|
|
134
143
|
? [{ id: 'next', label: labels.nodePanel.nextRowLabel, isDefault: false, isSelfLoop: false }]
|
|
135
144
|
: []
|
|
145
|
+
return [...nextRows, ...possibleRows]
|
|
136
146
|
}
|
|
137
147
|
|
|
138
148
|
const loops = selfLoopHandles(node)
|
|
@@ -296,7 +306,9 @@ export function FlowNodeCard({ data }: NodeProps) {
|
|
|
296
306
|
<div className="flex items-center justify-between gap-2">
|
|
297
307
|
<span className="flex items-center gap-1.5 uppercase tracking-wide font-semibold text-gray-500 dark:text-gray-400 text-xs">
|
|
298
308
|
<Icon size={12} strokeWidth={2.5} />
|
|
299
|
-
{isStart &&
|
|
309
|
+
{isStart && (
|
|
310
|
+
<span className="h-1.5 w-1.5 rounded-full bg-emerald-500" data-cv-tooltip={labels.startNodeTooltip} />
|
|
311
|
+
)}
|
|
300
312
|
{labels.legend[node.type] ?? DEFAULT_FLOW_EDITOR_LABELS.legend.dynamic_choice}
|
|
301
313
|
</span>
|
|
302
314
|
<div className="flex items-center gap-1">
|
|
@@ -340,9 +352,7 @@ export function FlowNodeCard({ data }: NodeProps) {
|
|
|
340
352
|
addLabel={labels.quickAdd.fromHandle}
|
|
341
353
|
isSelfLoop={row.isSelfLoop}
|
|
342
354
|
selfLoopLabel={labels.legendPanel.selfLoop}
|
|
343
|
-
{...(onQuickAdd
|
|
344
|
-
? { onQuickAdd: (params) => onQuickAdd({ nodeId: node.id, ...params }) }
|
|
345
|
-
: {})}
|
|
355
|
+
{...(onQuickAdd ? { onQuickAdd: (params) => onQuickAdd({ nodeId: node.id, ...params }) } : {})}
|
|
346
356
|
/>
|
|
347
357
|
))}
|
|
348
358
|
</div>
|
|
@@ -4,6 +4,7 @@ import { FlowWhatsAppPreview } from './FlowWhatsAppPreview'
|
|
|
4
4
|
import { nodeLabel } from './FlowNodeCard'
|
|
5
5
|
import { CROSS_FLOW_PREFIX, CONDITION_OPERATORS, BUILT_IN_ACTION_KINDS, isPassThroughAction as passesThrough } from './flowGraph'
|
|
6
6
|
import { DEFAULT_FLOW_EDITOR_LABELS, DEFAULT_FLOW_RUNNER_FIELD_LABELS, type FlowEditorLabels } from './labels'
|
|
7
|
+
import { FlowPossibleNextField } from './FlowPossibleNextField'
|
|
7
8
|
import { FlowRunnerFields } from './FlowRunnerFields'
|
|
8
9
|
import type { FlowGraphData, FlowNodeData, GraphIssue } from './flowGraph'
|
|
9
10
|
import { PANEL_FIELD_CLASSNAME } from './flowPanelStyles'
|
|
@@ -401,6 +402,15 @@ export function FlowNodePanel({
|
|
|
401
402
|
/>
|
|
402
403
|
)}
|
|
403
404
|
|
|
405
|
+
{isAction && draft.actionKind && (
|
|
406
|
+
<FlowPossibleNextField
|
|
407
|
+
draft={draft}
|
|
408
|
+
onDraftChange={setDraft}
|
|
409
|
+
renderTargetOptions={nextNodeOptions}
|
|
410
|
+
labels={labels.runnerFields ?? DEFAULT_FLOW_RUNNER_FIELD_LABELS}
|
|
411
|
+
/>
|
|
412
|
+
)}
|
|
413
|
+
|
|
404
414
|
{/* Ação de passagem também escolhe destino: sem isto, o material era enviado e a conversa
|
|
405
415
|
parava ali, sem caminho para o atendimento. Ação terminal continua sem o campo. */}
|
|
406
416
|
{(!isAction || isPassThroughAction) && (
|