@adatechnology/notification-ui 0.2.1 → 0.4.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/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { D as DEFAULT_LOCALE, N as NOTIFICATION_QUERY_KEYS, a as NotificationContextValue, b as NotificationLocale, c as NotificationMessages, d as NotificationProvider, e as NotificationProviderProps, f as NotificationTheme, S as SORT_DIRECTIONS, g as SortDirection, T as TEMPLATE_COLUMNS, h as TEMPLATE_SORT_FIELDS, i as TEMPLATE_VIEWS, j as TemplateColumn, k as TemplateDraft, l as TemplateDraftField, m as TemplatePreviewFrame, n as TemplateSort, o as TemplateSortField, p as TemplateView, U as UseCategoryPoliciesResult, q as UseNotificationStreamOptions, r as UseNotificationsOptions, s as UseTemplateEditorParams, t as UseTemplateEditorResult, u as flattenNotificationPages, v as formatNotificationTime, w as formatNotificationTimestamp, x as resolveMessages, y as useCategoryPolicies, z as useDeactivateTemplate, A as useDeleteNotification, B as useMarkAllAsRead, C as useMarkAsRead, E as useNotificationContext, F as useNotificationStream, G as useNotifications, H as usePreferences, I as useRestoreTemplateDefault, J as useTemplateEditor, K as useTemplateVariables, L as useTemplates, M as useUnreadCount, O as useUpdatePreferences, P as useUpsertTemplate } from './headless-03_gfBEI.js';
2
2
  import * as react from 'react';
3
3
  import { ReactNode } from 'react';
4
- import { NotificationSummary, NotificationTemplate } from '@adatechnology/notification-contracts';
4
+ import { NotificationSummary, NotificationTemplate, RenderedTemplatePreview } from '@adatechnology/notification-contracts';
5
5
  import '@adatechnology/notification-client';
6
6
  import '@tanstack/react-query';
7
7
 
@@ -228,6 +228,50 @@ type MessageBodyFieldProps = {
228
228
  };
229
229
  declare function MessageBodyField({ value, rows, onChange, onSelect, onFocus, labelOf }: MessageBodyFieldProps): react.JSX.Element;
230
230
 
231
+ type TemplatePreviewProps = {
232
+ readonly channel: string;
233
+ readonly viewport: string;
234
+ readonly rendered: RenderedTemplatePreview;
235
+ /**
236
+ * O documento de e-mail COMPLETO, já com a moldura da marca em volta do corpo. Vem do produto:
237
+ * o pacote não conhece logo, cartão de usuário nem rodapé. Ausente, o corpo aparece como texto.
238
+ */
239
+ readonly emailHtml?: string;
240
+ /** Nome do produto, para o cabeçalho do e-mail e o do push. O pacote não sabe de quem é a marca. */
241
+ readonly senderName?: string;
242
+ /**
243
+ * Arquivo que segue com a mensagem (ex.: o PDF do boleto). Aparece como cartão de documento no
244
+ * balão do WhatsApp e como chip no fim do e-mail. O nome e o tamanho vêm do produto.
245
+ */
246
+ readonly attachment?: PreviewAttachment;
247
+ /** Os textos da moldura. Nada aqui é hardcoded — nem "para você", nem "agora" (web.md §6). */
248
+ readonly labels: PreviewLabels;
249
+ };
250
+ type PreviewAttachment = {
251
+ readonly name: string;
252
+ /** Já formatado pelo produto (ex.: "4,4 KB · PDF"). Ausente, só o nome. */
253
+ readonly detail?: string;
254
+ };
255
+ type PreviewLabels = {
256
+ readonly to: string;
257
+ readonly now: string;
258
+ readonly mailbox: string;
259
+ /** Hora da barra de status do aparelho. */
260
+ readonly time: string;
261
+ readonly address: string;
262
+ readonly counter: string;
263
+ readonly folder: string;
264
+ readonly senderAddress: string;
265
+ readonly unsubscribe: string;
266
+ readonly online: string;
267
+ readonly today: string;
268
+ readonly compose: string;
269
+ readonly reply: string;
270
+ readonly forward: string;
271
+ readonly replyAll: string;
272
+ };
273
+ declare function TemplatePreview({ channel, viewport, rendered, emailHtml, senderName, attachment, labels, }: TemplatePreviewProps): react.JSX.Element;
274
+
231
275
  /**
232
276
  * Copyright (c) 2026 Ada Technology. MIT License.
233
277
  *
@@ -315,4 +359,4 @@ declare function insertAt({ text, insertion, selectionStart, selectionEnd, }: {
315
359
  readonly selectionEnd: number;
316
360
  }): ApplyMarkResult;
317
361
 
318
- export { HTML_TOKEN, HtmlCodeField, type HtmlCodeFieldProblem, type HtmlCodeFieldProps, type HtmlToken, type HtmlTokenKind, MESSAGE_EMOJI, MESSAGE_FORMAT, MESSAGE_FORMAT_MARKS, MessageBodyField, type MessageBodyFieldProps, type MessageFormat, type MessageFormatMark, MessageToolbar, type MessageToolbarProps, NotificationBell, type NotificationBellProps, type NotificationCategoryOption, type NotificationChannelOption, NotificationItem, type NotificationItemProps, NotificationList, type NotificationListProps, NotificationSettingsWorkspace, type NotificationSettingsWorkspaceProps, NotificationsWorkspace, type NotificationsWorkspaceProps, PreferencesPanel, type PreferencesPanelProps, applyMark, insertAt, tokenizeHtml };
362
+ export { HTML_TOKEN, HtmlCodeField, type HtmlCodeFieldProblem, type HtmlCodeFieldProps, type HtmlToken, type HtmlTokenKind, MESSAGE_EMOJI, MESSAGE_FORMAT, MESSAGE_FORMAT_MARKS, MessageBodyField, type MessageBodyFieldProps, type MessageFormat, type MessageFormatMark, MessageToolbar, type MessageToolbarProps, NotificationBell, type NotificationBellProps, type NotificationCategoryOption, type NotificationChannelOption, NotificationItem, type NotificationItemProps, NotificationList, type NotificationListProps, NotificationSettingsWorkspace, type NotificationSettingsWorkspaceProps, NotificationsWorkspace, type NotificationsWorkspaceProps, PreferencesPanel, type PreferencesPanelProps, type PreviewAttachment, type PreviewLabels, TemplatePreview, type TemplatePreviewProps, applyMark, insertAt, tokenizeHtml };
package/dist/index.js CHANGED
@@ -611,6 +611,7 @@ function MessageBodyField({ value, rows = 5, onChange, onSelect, onFocus, labelO
611
611
  }
612
612
 
613
613
  // src/components/TemplatePreview.tsx
614
+ import { parseWhatsAppFormatting } from "@adatechnology/conversations-ui";
614
615
  import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
615
616
  function StatusIcons() {
616
617
  return /* @__PURE__ */ jsxs9("span", { className: "adn-preview-status__icons", children: [
@@ -631,12 +632,7 @@ function StatusIcons() {
631
632
  ] })
632
633
  ] });
633
634
  }
634
- function Phone({
635
- children,
636
- os,
637
- tone,
638
- time
639
- }) {
635
+ function Phone({ children, os, tone, time }) {
640
636
  const android = os === "android";
641
637
  const classes = ["adn-preview-phone", `adn-preview-phone--${android ? "android" : "ios"}`];
642
638
  if (tone === "dark") classes.push("adn-preview-phone--dark");
@@ -697,13 +693,15 @@ var ICON = {
697
693
  forward: "M15 17h5V7M20 7l-7 7M4 17v-3a6 6 0 0 1 6-6h10",
698
694
  replyAll: "M7 17H3V9M3 9l5 5M11 17H8V9M8 9l5 5M20 17v-3a6 6 0 0 0-6-6H8",
699
695
  chevron: "m6 9 6 6 6-6",
696
+ file: "M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8zM14 3v5h5",
700
697
  settings: "M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6M19 12a7 7 0 0 0-.1-1l2-1.5-2-3.4-2.3 1a7 7 0 0 0-1.7-1L14.5 3h-4l-.4 2.6a7 7 0 0 0-1.7 1l-2.3-1-2 3.4L6.1 11a7 7 0 0 0 0 2l-2 1.5 2 3.4 2.3-1a7 7 0 0 0 1.7 1l.4 2.6h4l.4-2.6a7 7 0 0 0 1.7-1l2.3 1 2-3.4-2-1.5c.1-.3.1-.7.1-1"
701
698
  };
702
699
  function EmailDesktop({
703
700
  rendered,
704
701
  emailHtml,
705
702
  senderName,
706
- labels
703
+ labels,
704
+ attachment
707
705
  }) {
708
706
  return /* @__PURE__ */ jsxs9("div", { className: "adn-preview-browser", children: [
709
707
  /* @__PURE__ */ jsxs9("div", { className: "adn-preview-browser__bar", children: [
@@ -777,7 +775,8 @@ function EmailDesktop({
777
775
  /* @__PURE__ */ jsx9(Icon, { d: ICON.more, size: 15 })
778
776
  ] })
779
777
  ] }),
780
- /* @__PURE__ */ jsx9(MailBody, { html: emailHtml, text: rendered.body })
778
+ /* @__PURE__ */ jsx9(MailBody, { html: emailHtml, text: rendered.body }),
779
+ attachment ? /* @__PURE__ */ jsx9(AttachmentCard, { attachment, block: "adn-preview-attachment--mail" }) : null
781
780
  ] })
782
781
  ] })
783
782
  ] })
@@ -789,7 +788,8 @@ function EmailMobile({
789
788
  emailHtml,
790
789
  senderName,
791
790
  os,
792
- labels
791
+ labels,
792
+ attachment
793
793
  }) {
794
794
  return /* @__PURE__ */ jsxs9(Phone, { os, time: labels.time, children: [
795
795
  /* @__PURE__ */ jsxs9("div", { className: "adn-preview-mailapp__actions", children: [
@@ -818,6 +818,7 @@ function EmailMobile({
818
818
  /* @__PURE__ */ jsx9("span", { className: "adn-preview-mail__from-actions", children: /* @__PURE__ */ jsx9(Icon, { d: ICON.star, size: 17 }) })
819
819
  ] }),
820
820
  /* @__PURE__ */ jsx9(MailBody, { html: emailHtml, text: rendered.body }),
821
+ attachment ? /* @__PURE__ */ jsx9(AttachmentCard, { attachment, block: "adn-preview-attachment--mail" }) : null,
821
822
  /* @__PURE__ */ jsxs9("div", { className: "adn-preview-mail__reply", children: [
822
823
  /* @__PURE__ */ jsxs9("span", { className: "adn-preview-mail__reply-button", children: [
823
824
  /* @__PURE__ */ jsx9(Icon, { d: ICON.reply, size: 14 }),
@@ -839,7 +840,8 @@ function WhatsAppPreview({
839
840
  rendered,
840
841
  labels,
841
842
  os,
842
- senderName
843
+ senderName,
844
+ attachment
843
845
  }) {
844
846
  return /* @__PURE__ */ jsxs9(Phone, { os, time: labels.time, children: [
845
847
  /* @__PURE__ */ jsxs9("div", { className: "adn-preview-wa__header", children: [
@@ -858,7 +860,8 @@ function WhatsAppPreview({
858
860
  /* @__PURE__ */ jsxs9("div", { className: "adn-preview-wa", children: [
859
861
  /* @__PURE__ */ jsx9("div", { className: "adn-preview-wa__day", children: labels.today }),
860
862
  /* @__PURE__ */ jsxs9("div", { className: "adn-preview-wa__bubble", children: [
861
- /* @__PURE__ */ jsx9("div", { className: "adn-preview-wa__text", children: rendered.body }),
863
+ attachment ? /* @__PURE__ */ jsx9(AttachmentCard, { attachment, block: "adn-preview-attachment--wa" }) : null,
864
+ /* @__PURE__ */ jsx9("div", { className: "adn-preview-wa__text", children: parseWhatsAppFormatting(rendered.body) }),
862
865
  /* @__PURE__ */ jsx9("div", { className: "adn-preview-wa__time", children: labels.now })
863
866
  ] })
864
867
  ] }),
@@ -900,6 +903,15 @@ function InboxPreview({ rendered }) {
900
903
  ] })
901
904
  ] });
902
905
  }
906
+ function AttachmentCard({ attachment, block }) {
907
+ return /* @__PURE__ */ jsxs9("div", { className: `adn-preview-attachment ${block}`, children: [
908
+ /* @__PURE__ */ jsx9(Icon, { d: ICON.file, size: 18 }),
909
+ /* @__PURE__ */ jsxs9("span", { className: "adn-preview-attachment__text", children: [
910
+ /* @__PURE__ */ jsx9("span", { className: "adn-preview-attachment__name", children: attachment.name }),
911
+ attachment.detail ? /* @__PURE__ */ jsx9("span", { className: "adn-preview-attachment__detail", children: attachment.detail }) : null
912
+ ] })
913
+ ] });
914
+ }
903
915
  function MailBody({ html, text }) {
904
916
  if (!html) return /* @__PURE__ */ jsx9("div", { className: "adn-preview-mail__body", children: text });
905
917
  return /* @__PURE__ */ jsx9(
@@ -912,17 +924,44 @@ function MailBody({ html, text }) {
912
924
  }
913
925
  );
914
926
  }
915
- function TemplatePreview({ channel, viewport, rendered, emailHtml, senderName, labels }) {
927
+ function TemplatePreview({
928
+ channel,
929
+ viewport,
930
+ rendered,
931
+ emailHtml,
932
+ senderName,
933
+ attachment,
934
+ labels
935
+ }) {
916
936
  const sender = senderName ?? rendered.title.slice(0, 1).toUpperCase();
917
937
  if (channel === "whatsapp") {
918
- return /* @__PURE__ */ jsx9(WhatsAppPreview, { rendered, labels, os: viewport, senderName: sender });
938
+ return /* @__PURE__ */ jsx9(WhatsAppPreview, { rendered, labels, os: viewport, senderName: sender, attachment });
919
939
  }
920
940
  if (channel === "sms") return /* @__PURE__ */ jsx9(SmsPreview, { rendered, os: viewport, labels });
921
941
  if (channel === "push") {
922
942
  return /* @__PURE__ */ jsx9(PushPreview, { rendered, senderName: sender, labels, os: viewport });
923
943
  }
924
944
  if (channel === "inbox") return /* @__PURE__ */ jsx9(InboxPreview, { rendered });
925
- return viewport === "browser" ? /* @__PURE__ */ jsx9(EmailDesktop, { rendered, emailHtml, senderName: sender, labels }) : /* @__PURE__ */ jsx9(EmailMobile, { rendered, emailHtml, senderName: sender, os: viewport, labels });
945
+ return viewport === "browser" ? /* @__PURE__ */ jsx9(
946
+ EmailDesktop,
947
+ {
948
+ rendered,
949
+ emailHtml,
950
+ senderName: sender,
951
+ labels,
952
+ attachment
953
+ }
954
+ ) : /* @__PURE__ */ jsx9(
955
+ EmailMobile,
956
+ {
957
+ rendered,
958
+ emailHtml,
959
+ senderName: sender,
960
+ os: viewport,
961
+ labels,
962
+ attachment
963
+ }
964
+ );
926
965
  }
927
966
 
928
967
  // src/components/NotificationSettingsWorkspace.tsx
@@ -1480,6 +1519,7 @@ export {
1480
1519
  TEMPLATE_COLUMNS,
1481
1520
  TEMPLATE_SORT_FIELDS,
1482
1521
  TEMPLATE_VIEWS,
1522
+ TemplatePreview,
1483
1523
  applyMark,
1484
1524
  flattenNotificationPages,
1485
1525
  formatNotificationTime,