@adatechnology/conversations-ui 0.19.1 → 0.21.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 CHANGED
@@ -569,3 +569,9 @@ pública e não mudam sem nova versão maior.
569
569
  `ConversationChannel` agora inclui `'app'` e `'portal'`. Quem tem um `switch` exaustivo sobre o tipo (sem
570
570
  `default`) passa a ter erro de compilação até tratar os dois novos valores. Quem só escreve o tipo não é
571
571
  afetado.
572
+
573
+ ## Seletor de data próprio (`renderDateInput`)
574
+
575
+ O filtro por período de `DocumentsWorkspace` usa `<input type="date">` por padrão. Passe
576
+ `renderDateInput` para usar o seletor do seu design system; recebe `{ label, value, onChange }`, com
577
+ valor `YYYY-MM-DD` ou vazio, e é chamado uma vez para a data inicial e outra para a final.
package/dist/index.d.ts CHANGED
@@ -881,6 +881,11 @@ interface ConversationContextEntry {
881
881
  value?: string | undefined;
882
882
  icon?: string;
883
883
  status?: ConversationContextStatus;
884
+ /**
885
+ * Opt-in: com valor preenchido, o valor vira um botão (foco, clique, toque). Serve ao host para
886
+ * abrir o texto inteiro quando o card trunca — o toque não mostra dica de hover.
887
+ */
888
+ onSelect?: () => void;
884
889
  }
885
890
  interface ConversationContextPanelLabels {
886
891
  title: string;
@@ -1118,12 +1123,22 @@ interface DocumentsWorkspaceProps {
1118
1123
  readonly classNames?: Partial<DocumentsWorkspaceClassNames>;
1119
1124
  /** Espelhar filtros e paginação na URL. Desligado em preview, onde não há rota de verdade. */
1120
1125
  readonly syncUrl?: boolean;
1126
+ /** Seletor de data do host para o recorte por período. Padrão: `<input type="date">`. */
1127
+ readonly renderDateInput?: RenderDateInput;
1128
+ }
1129
+ interface DateInputProps {
1130
+ readonly label: string;
1131
+ /** `YYYY-MM-DD` ou vazio. */
1132
+ readonly value: string;
1133
+ readonly onChange: (value: string) => void;
1121
1134
  }
1135
+ /** Troca o `<input type="date">` nativo pelo seletor de data do host. */
1136
+ type RenderDateInput = (props: DateInputProps) => ReactNode;
1122
1137
  interface DocumentsFiltersContext {
1123
1138
  readonly extra: Readonly<Record<string, string | number>>;
1124
1139
  readonly setExtra: (next: Readonly<Record<string, string | number>>) => void;
1125
1140
  }
1126
- declare function DocumentsWorkspace({ perPage: initialPerPage, perPageOptions, onOpenConversation, sources, categories, dateFilter, renderFilters, labels: labelsOverride, className, classNames, syncUrl, }: DocumentsWorkspaceProps): react.JSX.Element | null;
1141
+ declare function DocumentsWorkspace({ perPage: initialPerPage, perPageOptions, onOpenConversation, sources, categories, dateFilter, renderFilters, labels: labelsOverride, className, classNames, syncUrl, renderDateInput, }: DocumentsWorkspaceProps): react.JSX.Element | null;
1127
1142
 
1128
1143
  /**
1129
1144
  * Estado de listagem espelhado na URL — ordenação, filtros e paginação (regra `web.md` §7).
@@ -2397,4 +2412,4 @@ type QueuedAttachmentsListProps = {
2397
2412
  };
2398
2413
  declare function QueuedAttachmentsList({ items, statusOf, onRemove, onRetry, retryingKeys, getThumbnailUrl, labels, busy, }: QueuedAttachmentsListProps): react.JSX.Element | null;
2399
2414
 
2400
- 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 };
2415
+ 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 DateInputProps, 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 RenderDateInput, 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
@@ -2085,7 +2085,15 @@ function ConversationContextPanel({
2085
2085
  entry.value ? "text-gray-900 dark:text-gray-100" : "italic font-normal text-gray-400 dark:text-gray-500"
2086
2086
  ),
2087
2087
  "data-cv-tooltip": entry.value ?? labels.notCollected,
2088
- children: entry.value ?? labels.notCollected
2088
+ children: entry.value && entry.onSelect ? /* @__PURE__ */ jsx14(
2089
+ "button",
2090
+ {
2091
+ type: "button",
2092
+ onClick: entry.onSelect,
2093
+ className: "w-full cursor-pointer truncate rounded text-center font-semibold hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-blue-500",
2094
+ children: entry.value
2095
+ }
2096
+ ) : entry.value ?? labels.notCollected
2089
2097
  }
2090
2098
  )
2091
2099
  ]
@@ -2393,7 +2401,8 @@ function DocumentsWorkspace({
2393
2401
  labels: labelsOverride,
2394
2402
  className,
2395
2403
  classNames,
2396
- syncUrl = true
2404
+ syncUrl = true,
2405
+ renderDateInput
2397
2406
  }) {
2398
2407
  const labels = { ...DEFAULT_DOCUMENTS_WORKSPACE_LABELS, ...labelsOverride };
2399
2408
  const context = useConversations();
@@ -2461,7 +2470,20 @@ function DocumentsWorkspace({
2461
2470
  return () => {
2462
2471
  active = false;
2463
2472
  };
2464
- }, [fetchAll, debouncedSearch, source, category, startDate, endDate, sortField, sortDirection, page, perPage, extraKey, reloadToken]);
2473
+ }, [
2474
+ fetchAll,
2475
+ debouncedSearch,
2476
+ source,
2477
+ category,
2478
+ startDate,
2479
+ endDate,
2480
+ sortField,
2481
+ sortDirection,
2482
+ page,
2483
+ perPage,
2484
+ extraKey,
2485
+ reloadToken
2486
+ ]);
2465
2487
  useEffect7(() => {
2466
2488
  setPage(1);
2467
2489
  setSelectedIds(/* @__PURE__ */ new Set());
@@ -2566,7 +2588,10 @@ function DocumentsWorkspace({
2566
2588
  onChange: setCategory
2567
2589
  }
2568
2590
  ) : null,
2569
- dateFilter ? /* @__PURE__ */ jsxs14(Fragment5, { children: [
2591
+ dateFilter ? /* @__PURE__ */ jsx17(Fragment5, { children: renderDateInput ? /* @__PURE__ */ jsxs14(Fragment5, { children: [
2592
+ renderDateInput({ label: labels.startDate, value: startDate, onChange: setStartDate }),
2593
+ renderDateInput({ label: labels.endDate, value: endDate, onChange: setEndDate })
2594
+ ] }) : /* @__PURE__ */ jsxs14(Fragment5, { children: [
2570
2595
  /* @__PURE__ */ jsx17(
2571
2596
  "input",
2572
2597
  {
@@ -2587,12 +2612,22 @@ function DocumentsWorkspace({
2587
2612
  className: "rounded-md border border-gray-300 px-2 py-2 text-xs dark:border-gray-700 dark:bg-gray-900"
2588
2613
  }
2589
2614
  )
2590
- ] }) : null,
2615
+ ] }) }) : null,
2591
2616
  renderFilters?.({ extra, setExtra }),
2592
- hasFilters ? /* @__PURE__ */ jsxs14("button", { "data-cv-tooltip": labels.clearFilters, "aria-label": labels.clearFilters, type: "button", onClick: clearFilters, className: "cv-header-action inline-flex items-center gap-1", children: [
2593
- /* @__PURE__ */ jsx17(X3, { size: 12, "aria-hidden": "true" }),
2594
- labels.clearFilters
2595
- ] }) : null,
2617
+ hasFilters ? /* @__PURE__ */ jsxs14(
2618
+ "button",
2619
+ {
2620
+ "data-cv-tooltip": labels.clearFilters,
2621
+ "aria-label": labels.clearFilters,
2622
+ type: "button",
2623
+ onClick: clearFilters,
2624
+ className: "cv-header-action inline-flex items-center gap-1",
2625
+ children: [
2626
+ /* @__PURE__ */ jsx17(X3, { size: 12, "aria-hidden": "true" }),
2627
+ labels.clearFilters
2628
+ ]
2629
+ }
2630
+ ) : null,
2596
2631
  uploadDocument ? /* @__PURE__ */ jsxs14(Fragment5, { children: [
2597
2632
  /* @__PURE__ */ jsx17(
2598
2633
  "input",
@@ -2655,7 +2690,8 @@ function DocumentsWorkspace({
2655
2690
  "aria-label": labels.bulkRemove(selectedIds.size),
2656
2691
  type: "button",
2657
2692
  onClick: () => {
2658
- if (window.confirm(labels.bulkRemoveConfirm(selectedIds.size))) void handleRemove(Array.from(selectedIds));
2693
+ if (window.confirm(labels.bulkRemoveConfirm(selectedIds.size)))
2694
+ void handleRemove(Array.from(selectedIds));
2659
2695
  },
2660
2696
  disabled: busy,
2661
2697
  className: "cv-header-action cv-header-action--danger inline-flex items-center gap-1 disabled:opacity-40",
@@ -2683,12 +2719,71 @@ function DocumentsWorkspace({
2683
2719
  className: "cursor-pointer rounded border-gray-300 text-blue-600 dark:border-gray-600"
2684
2720
  }
2685
2721
  ) }) : null,
2686
- /* @__PURE__ */ jsx17(SortableHead, { label: labels.columnFilename, field: "filename", activeField: sortField, direction, onSort: toggleSort }),
2687
- /* @__PURE__ */ jsx17(SortableHead, { label: labels.columnContact, field: "conversationId", activeField: sortField, direction, onSort: toggleSort, className: "hidden sm:table-cell" }),
2688
- /* @__PURE__ */ jsx17(SortableHead, { label: labels.columnType, field: "mimeType", activeField: sortField, direction, onSort: toggleSort, className: "hidden md:table-cell" }),
2689
- /* @__PURE__ */ jsx17(SortableHead, { label: labels.columnSize, field: "sizeBytes", activeField: sortField, direction, onSort: toggleSort, className: "hidden lg:table-cell" }),
2690
- /* @__PURE__ */ jsx17(SortableHead, { label: labels.columnSource, field: "source", activeField: sortField, direction, onSort: toggleSort, className: "hidden lg:table-cell" }),
2691
- /* @__PURE__ */ jsx17(SortableHead, { label: labels.columnDate, field: "linkedAt", activeField: sortField, direction, onSort: toggleSort, className: "hidden xl:table-cell" }),
2722
+ /* @__PURE__ */ jsx17(
2723
+ SortableHead,
2724
+ {
2725
+ label: labels.columnFilename,
2726
+ field: "filename",
2727
+ activeField: sortField,
2728
+ direction,
2729
+ onSort: toggleSort
2730
+ }
2731
+ ),
2732
+ /* @__PURE__ */ jsx17(
2733
+ SortableHead,
2734
+ {
2735
+ label: labels.columnContact,
2736
+ field: "conversationId",
2737
+ activeField: sortField,
2738
+ direction,
2739
+ onSort: toggleSort,
2740
+ className: "hidden sm:table-cell"
2741
+ }
2742
+ ),
2743
+ /* @__PURE__ */ jsx17(
2744
+ SortableHead,
2745
+ {
2746
+ label: labels.columnType,
2747
+ field: "mimeType",
2748
+ activeField: sortField,
2749
+ direction,
2750
+ onSort: toggleSort,
2751
+ className: "hidden md:table-cell"
2752
+ }
2753
+ ),
2754
+ /* @__PURE__ */ jsx17(
2755
+ SortableHead,
2756
+ {
2757
+ label: labels.columnSize,
2758
+ field: "sizeBytes",
2759
+ activeField: sortField,
2760
+ direction,
2761
+ onSort: toggleSort,
2762
+ className: "hidden lg:table-cell"
2763
+ }
2764
+ ),
2765
+ /* @__PURE__ */ jsx17(
2766
+ SortableHead,
2767
+ {
2768
+ label: labels.columnSource,
2769
+ field: "source",
2770
+ activeField: sortField,
2771
+ direction,
2772
+ onSort: toggleSort,
2773
+ className: "hidden lg:table-cell"
2774
+ }
2775
+ ),
2776
+ /* @__PURE__ */ jsx17(
2777
+ SortableHead,
2778
+ {
2779
+ label: labels.columnDate,
2780
+ field: "linkedAt",
2781
+ activeField: sortField,
2782
+ direction,
2783
+ onSort: toggleSort,
2784
+ className: "hidden xl:table-cell"
2785
+ }
2786
+ ),
2692
2787
  /* @__PURE__ */ jsx17("th", { scope: "col", className: "px-3 py-2 text-left text-xs font-medium", children: labels.columnActions })
2693
2788
  ] }) }),
2694
2789
  /* @__PURE__ */ jsx17("tbody", { children: documents.map((document2) => /* @__PURE__ */ jsxs14("tr", { className: classNames?.row, children: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adatechnology/conversations-ui",
3
- "version": "0.19.1",
3
+ "version": "0.21.0",
4
4
  "description": "WhatsApp conversation UI components — parametrizável por endpoint, tema e feature flags",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -0,0 +1,24 @@
1
+ import { describe, expect, it } from 'bun:test'
2
+ import { renderToStaticMarkup } from 'react-dom/server'
3
+
4
+ import { ConversationContextPanel } from './ConversationContextPanel'
5
+
6
+ const noop = () => {}
7
+
8
+ describe('ConversationContextPanel onSelect', () => {
9
+ it('vira botão só no card preenchido que declara onSelect', () => {
10
+ const markup = renderToStaticMarkup(
11
+ <ConversationContextPanel
12
+ defaultOpen
13
+ entries={[
14
+ { key: 'items', label: 'Itens', value: '2x Pudim, 1x Café', onSelect: noop },
15
+ { key: 'code', label: 'Código', value: 'PED-1' },
16
+ { key: 'time', label: 'Horário', onSelect: noop },
17
+ ]}
18
+ />,
19
+ )
20
+
21
+ expect(markup.match(/<button type="button" class="w-full/g)?.length).toBe(1)
22
+ expect(markup).toContain('data-cv-tooltip="2x Pudim, 1x Café"')
23
+ })
24
+ })
@@ -29,6 +29,11 @@ export interface ConversationContextEntry {
29
29
  value?: string | undefined
30
30
  icon?: string
31
31
  status?: ConversationContextStatus
32
+ /**
33
+ * Opt-in: com valor preenchido, o valor vira um botão (foco, clique, toque). Serve ao host para
34
+ * abrir o texto inteiro quando o card trunca — o toque não mostra dica de hover.
35
+ */
36
+ onSelect?: () => void
32
37
  }
33
38
 
34
39
  export interface ConversationContextPanelLabels {
@@ -265,7 +270,17 @@ export function ConversationContextPanel({
265
270
  )}
266
271
  data-cv-tooltip={entry.value ?? labels.notCollected}
267
272
  >
268
- {entry.value ?? labels.notCollected}
273
+ {entry.value && entry.onSelect ? (
274
+ <button
275
+ type="button"
276
+ onClick={entry.onSelect}
277
+ className="w-full cursor-pointer truncate rounded text-center font-semibold hover:underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-blue-500"
278
+ >
279
+ {entry.value}
280
+ </button>
281
+ ) : (
282
+ (entry.value ?? labels.notCollected)
283
+ )}
269
284
  </dd>
270
285
  </div>
271
286
  )
@@ -65,8 +65,20 @@ export interface DocumentsWorkspaceProps {
65
65
  readonly classNames?: Partial<DocumentsWorkspaceClassNames>
66
66
  /** Espelhar filtros e paginação na URL. Desligado em preview, onde não há rota de verdade. */
67
67
  readonly syncUrl?: boolean
68
+ /** Seletor de data do host para o recorte por período. Padrão: `<input type="date">`. */
69
+ readonly renderDateInput?: RenderDateInput
68
70
  }
69
71
 
72
+ export interface DateInputProps {
73
+ readonly label: string
74
+ /** `YYYY-MM-DD` ou vazio. */
75
+ readonly value: string
76
+ readonly onChange: (value: string) => void
77
+ }
78
+
79
+ /** Troca o `<input type="date">` nativo pelo seletor de data do host. */
80
+ export type RenderDateInput = (props: DateInputProps) => ReactNode
81
+
70
82
  export interface DocumentsFiltersContext {
71
83
  readonly extra: Readonly<Record<string, string | number>>
72
84
  readonly setExtra: (next: Readonly<Record<string, string | number>>) => void
@@ -84,6 +96,7 @@ export function DocumentsWorkspace({
84
96
  className,
85
97
  classNames,
86
98
  syncUrl = true,
99
+ renderDateInput,
87
100
  }: DocumentsWorkspaceProps) {
88
101
  const labels = { ...DEFAULT_DOCUMENTS_WORKSPACE_LABELS, ...labelsOverride }
89
102
  const context = useConversations()
@@ -172,14 +185,25 @@ export function DocumentsWorkspace({
172
185
  }
173
186
  // `extraKey` no lugar de `extra`: o objeto é remontado a cada render do host e a identidade
174
187
  // sozinha dispararia a busca em loop.
175
-
176
- }, [fetchAll, debouncedSearch, source, category, startDate, endDate, sortField, sortDirection, page, perPage, extraKey, reloadToken])
188
+ }, [
189
+ fetchAll,
190
+ debouncedSearch,
191
+ source,
192
+ category,
193
+ startDate,
194
+ endDate,
195
+ sortField,
196
+ sortDirection,
197
+ page,
198
+ perPage,
199
+ extraKey,
200
+ reloadToken,
201
+ ])
177
202
 
178
203
  // Trocar de filtro mantendo a página 7 mostra "nenhum resultado" com dados existindo na página 1.
179
204
  useEffect(() => {
180
205
  setPage(1)
181
206
  setSelectedIds(new Set())
182
-
183
207
  }, [debouncedSearch, source, category, startDate, endDate, perPage, extraKey])
184
208
 
185
209
  function toggleSort(field: string): void {
@@ -298,27 +322,42 @@ export function DocumentsWorkspace({
298
322
 
299
323
  {dateFilter ? (
300
324
  <>
301
- <input
302
- type="date"
303
- value={startDate}
304
- onChange={(event) => setStartDate(event.target.value)}
305
- aria-label={labels.startDate}
306
- className="rounded-md border border-gray-300 px-2 py-2 text-xs dark:border-gray-700 dark:bg-gray-900"
307
- />
308
- <input
309
- type="date"
310
- value={endDate}
311
- onChange={(event) => setEndDate(event.target.value)}
312
- aria-label={labels.endDate}
313
- className="rounded-md border border-gray-300 px-2 py-2 text-xs dark:border-gray-700 dark:bg-gray-900"
314
- />
325
+ {renderDateInput ? (
326
+ <>
327
+ {renderDateInput({ label: labels.startDate, value: startDate, onChange: setStartDate })}
328
+ {renderDateInput({ label: labels.endDate, value: endDate, onChange: setEndDate })}
329
+ </>
330
+ ) : (
331
+ <>
332
+ <input
333
+ type="date"
334
+ value={startDate}
335
+ onChange={(event) => setStartDate(event.target.value)}
336
+ aria-label={labels.startDate}
337
+ className="rounded-md border border-gray-300 px-2 py-2 text-xs dark:border-gray-700 dark:bg-gray-900"
338
+ />
339
+ <input
340
+ type="date"
341
+ value={endDate}
342
+ onChange={(event) => setEndDate(event.target.value)}
343
+ aria-label={labels.endDate}
344
+ className="rounded-md border border-gray-300 px-2 py-2 text-xs dark:border-gray-700 dark:bg-gray-900"
345
+ />
346
+ </>
347
+ )}
315
348
  </>
316
349
  ) : null}
317
350
 
318
351
  {renderFilters?.({ extra, setExtra })}
319
352
 
320
353
  {hasFilters ? (
321
- <button data-cv-tooltip={labels.clearFilters} aria-label={labels.clearFilters} type="button" onClick={clearFilters} className="cv-header-action inline-flex items-center gap-1">
354
+ <button
355
+ data-cv-tooltip={labels.clearFilters}
356
+ aria-label={labels.clearFilters}
357
+ type="button"
358
+ onClick={clearFilters}
359
+ className="cv-header-action inline-flex items-center gap-1"
360
+ >
322
361
  <X size={12} aria-hidden="true" />
323
362
  {labels.clearFilters}
324
363
  </button>
@@ -366,7 +405,8 @@ export function DocumentsWorkspace({
366
405
  >
367
406
  {downloadArchive ? (
368
407
  <button
369
- data-cv-tooltip={labels.bulkDownloadZip} aria-label={labels.bulkDownloadZip}
408
+ data-cv-tooltip={labels.bulkDownloadZip}
409
+ aria-label={labels.bulkDownloadZip}
370
410
  type="button"
371
411
  onClick={() => void handleDownloadArchive()}
372
412
  disabled={busy}
@@ -378,10 +418,12 @@ export function DocumentsWorkspace({
378
418
  ) : null}
379
419
  {removeDocument ? (
380
420
  <button
381
- data-cv-tooltip={labels.bulkRemove(selectedIds.size)} aria-label={labels.bulkRemove(selectedIds.size)}
421
+ data-cv-tooltip={labels.bulkRemove(selectedIds.size)}
422
+ aria-label={labels.bulkRemove(selectedIds.size)}
382
423
  type="button"
383
424
  onClick={() => {
384
- if (window.confirm(labels.bulkRemoveConfirm(selectedIds.size))) void handleRemove(Array.from(selectedIds))
425
+ if (window.confirm(labels.bulkRemoveConfirm(selectedIds.size)))
426
+ void handleRemove(Array.from(selectedIds))
385
427
  }}
386
428
  disabled={busy}
387
429
  className="cv-header-action cv-header-action--danger inline-flex items-center gap-1 disabled:opacity-40"
@@ -415,12 +457,53 @@ export function DocumentsWorkspace({
415
457
  />
416
458
  </th>
417
459
  ) : null}
418
- <SortableHead label={labels.columnFilename} field="filename" activeField={sortField} direction={direction} onSort={toggleSort} />
419
- <SortableHead label={labels.columnContact} field="conversationId" activeField={sortField} direction={direction} onSort={toggleSort} className="hidden sm:table-cell" />
420
- <SortableHead label={labels.columnType} field="mimeType" activeField={sortField} direction={direction} onSort={toggleSort} className="hidden md:table-cell" />
421
- <SortableHead label={labels.columnSize} field="sizeBytes" activeField={sortField} direction={direction} onSort={toggleSort} className="hidden lg:table-cell" />
422
- <SortableHead label={labels.columnSource} field="source" activeField={sortField} direction={direction} onSort={toggleSort} className="hidden lg:table-cell" />
423
- <SortableHead label={labels.columnDate} field="linkedAt" activeField={sortField} direction={direction} onSort={toggleSort} className="hidden xl:table-cell" />
460
+ <SortableHead
461
+ label={labels.columnFilename}
462
+ field="filename"
463
+ activeField={sortField}
464
+ direction={direction}
465
+ onSort={toggleSort}
466
+ />
467
+ <SortableHead
468
+ label={labels.columnContact}
469
+ field="conversationId"
470
+ activeField={sortField}
471
+ direction={direction}
472
+ onSort={toggleSort}
473
+ className="hidden sm:table-cell"
474
+ />
475
+ <SortableHead
476
+ label={labels.columnType}
477
+ field="mimeType"
478
+ activeField={sortField}
479
+ direction={direction}
480
+ onSort={toggleSort}
481
+ className="hidden md:table-cell"
482
+ />
483
+ <SortableHead
484
+ label={labels.columnSize}
485
+ field="sizeBytes"
486
+ activeField={sortField}
487
+ direction={direction}
488
+ onSort={toggleSort}
489
+ className="hidden lg:table-cell"
490
+ />
491
+ <SortableHead
492
+ label={labels.columnSource}
493
+ field="source"
494
+ activeField={sortField}
495
+ direction={direction}
496
+ onSort={toggleSort}
497
+ className="hidden lg:table-cell"
498
+ />
499
+ <SortableHead
500
+ label={labels.columnDate}
501
+ field="linkedAt"
502
+ activeField={sortField}
503
+ direction={direction}
504
+ onSort={toggleSort}
505
+ className="hidden xl:table-cell"
506
+ />
424
507
  <th scope="col" className="px-3 py-2 text-left text-xs font-medium">
425
508
  {labels.columnActions}
426
509
  </th>
@@ -457,14 +540,17 @@ export function DocumentsWorkspace({
457
540
  <button
458
541
  type="button"
459
542
  onClick={() => onOpenConversation(document.conversationId)}
460
- data-cv-tooltip={labels.openConversation} aria-label={labels.openConversation}
543
+ data-cv-tooltip={labels.openConversation}
544
+ aria-label={labels.openConversation}
461
545
  className="cv-header-action inline-flex items-center gap-1"
462
546
  >
463
547
  <MessageSquare size={12} aria-hidden="true" />
464
548
  {document.contactName ?? formatPhone(document.conversationId)}
465
549
  </button>
466
550
  ) : (
467
- <span className="text-xs text-gray-500">{document.contactName ?? formatPhone(document.conversationId)}</span>
551
+ <span className="text-xs text-gray-500">
552
+ {document.contactName ?? formatPhone(document.conversationId)}
553
+ </span>
468
554
  )}
469
555
  </td>
470
556
 
@@ -475,11 +561,15 @@ export function DocumentsWorkspace({
475
561
  <td className="hidden px-3 py-2 md:table-cell" data-cv-tooltip={document.mimeType}>
476
562
  <span className="cv-type-tag">{documentTypeLabel(document.filename, document.mimeType)}</span>
477
563
  </td>
478
- <td className="hidden whitespace-nowrap px-3 py-2 text-xs lg:table-cell">{formatFileSize(document.sizeBytes)}</td>
564
+ <td className="hidden whitespace-nowrap px-3 py-2 text-xs lg:table-cell">
565
+ {formatFileSize(document.sizeBytes)}
566
+ </td>
479
567
  <td className="hidden whitespace-nowrap px-3 py-2 text-xs lg:table-cell">
480
568
  {labels.sourceLabels[document.source] ?? document.source}
481
569
  </td>
482
- <td className="hidden whitespace-nowrap px-3 py-2 text-xs xl:table-cell">{formatDateTime(document.linkedAt)}</td>
570
+ <td className="hidden whitespace-nowrap px-3 py-2 text-xs xl:table-cell">
571
+ {formatDateTime(document.linkedAt)}
572
+ </td>
483
573
 
484
574
  <td className="px-3 py-2">
485
575
  <div className="flex gap-1">
@@ -3,6 +3,8 @@ export type {
3
3
  DocumentsWorkspaceProps,
4
4
  DocumentsWorkspaceClassNames,
5
5
  DocumentsFiltersContext,
6
+ DateInputProps,
7
+ RenderDateInput,
6
8
  } from './DocumentsWorkspace'
7
9
  export { DEFAULT_DOCUMENTS_WORKSPACE_LABELS } from './labels'
8
10
  export type { DocumentsWorkspaceLabels } from './labels'
package/src/index.ts CHANGED
@@ -108,6 +108,8 @@ export type {
108
108
  DocumentsWorkspaceLabels,
109
109
  DocumentsWorkspaceClassNames,
110
110
  DocumentsFiltersContext,
111
+ DateInputProps,
112
+ RenderDateInput,
111
113
  } from './documents'
112
114
  export { SortableHead, MultiSelectFilter, BulkActionBar, ListingPagination } from './listing'
113
115
  export type {