@adatechnology/notification-ui 0.2.1 → 0.3.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
@@ -631,12 +631,7 @@ function StatusIcons() {
631
631
  ] })
632
632
  ] });
633
633
  }
634
- function Phone({
635
- children,
636
- os,
637
- tone,
638
- time
639
- }) {
634
+ function Phone({ children, os, tone, time }) {
640
635
  const android = os === "android";
641
636
  const classes = ["adn-preview-phone", `adn-preview-phone--${android ? "android" : "ios"}`];
642
637
  if (tone === "dark") classes.push("adn-preview-phone--dark");
@@ -697,13 +692,15 @@ var ICON = {
697
692
  forward: "M15 17h5V7M20 7l-7 7M4 17v-3a6 6 0 0 1 6-6h10",
698
693
  replyAll: "M7 17H3V9M3 9l5 5M11 17H8V9M8 9l5 5M20 17v-3a6 6 0 0 0-6-6H8",
699
694
  chevron: "m6 9 6 6 6-6",
695
+ file: "M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8zM14 3v5h5",
700
696
  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
697
  };
702
698
  function EmailDesktop({
703
699
  rendered,
704
700
  emailHtml,
705
701
  senderName,
706
- labels
702
+ labels,
703
+ attachment
707
704
  }) {
708
705
  return /* @__PURE__ */ jsxs9("div", { className: "adn-preview-browser", children: [
709
706
  /* @__PURE__ */ jsxs9("div", { className: "adn-preview-browser__bar", children: [
@@ -777,7 +774,8 @@ function EmailDesktop({
777
774
  /* @__PURE__ */ jsx9(Icon, { d: ICON.more, size: 15 })
778
775
  ] })
779
776
  ] }),
780
- /* @__PURE__ */ jsx9(MailBody, { html: emailHtml, text: rendered.body })
777
+ /* @__PURE__ */ jsx9(MailBody, { html: emailHtml, text: rendered.body }),
778
+ attachment ? /* @__PURE__ */ jsx9(AttachmentCard, { attachment, block: "adn-preview-attachment--mail" }) : null
781
779
  ] })
782
780
  ] })
783
781
  ] })
@@ -789,7 +787,8 @@ function EmailMobile({
789
787
  emailHtml,
790
788
  senderName,
791
789
  os,
792
- labels
790
+ labels,
791
+ attachment
793
792
  }) {
794
793
  return /* @__PURE__ */ jsxs9(Phone, { os, time: labels.time, children: [
795
794
  /* @__PURE__ */ jsxs9("div", { className: "adn-preview-mailapp__actions", children: [
@@ -818,6 +817,7 @@ function EmailMobile({
818
817
  /* @__PURE__ */ jsx9("span", { className: "adn-preview-mail__from-actions", children: /* @__PURE__ */ jsx9(Icon, { d: ICON.star, size: 17 }) })
819
818
  ] }),
820
819
  /* @__PURE__ */ jsx9(MailBody, { html: emailHtml, text: rendered.body }),
820
+ attachment ? /* @__PURE__ */ jsx9(AttachmentCard, { attachment, block: "adn-preview-attachment--mail" }) : null,
821
821
  /* @__PURE__ */ jsxs9("div", { className: "adn-preview-mail__reply", children: [
822
822
  /* @__PURE__ */ jsxs9("span", { className: "adn-preview-mail__reply-button", children: [
823
823
  /* @__PURE__ */ jsx9(Icon, { d: ICON.reply, size: 14 }),
@@ -839,7 +839,8 @@ function WhatsAppPreview({
839
839
  rendered,
840
840
  labels,
841
841
  os,
842
- senderName
842
+ senderName,
843
+ attachment
843
844
  }) {
844
845
  return /* @__PURE__ */ jsxs9(Phone, { os, time: labels.time, children: [
845
846
  /* @__PURE__ */ jsxs9("div", { className: "adn-preview-wa__header", children: [
@@ -858,6 +859,7 @@ function WhatsAppPreview({
858
859
  /* @__PURE__ */ jsxs9("div", { className: "adn-preview-wa", children: [
859
860
  /* @__PURE__ */ jsx9("div", { className: "adn-preview-wa__day", children: labels.today }),
860
861
  /* @__PURE__ */ jsxs9("div", { className: "adn-preview-wa__bubble", children: [
862
+ attachment ? /* @__PURE__ */ jsx9(AttachmentCard, { attachment, block: "adn-preview-attachment--wa" }) : null,
861
863
  /* @__PURE__ */ jsx9("div", { className: "adn-preview-wa__text", children: rendered.body }),
862
864
  /* @__PURE__ */ jsx9("div", { className: "adn-preview-wa__time", children: labels.now })
863
865
  ] })
@@ -900,6 +902,15 @@ function InboxPreview({ rendered }) {
900
902
  ] })
901
903
  ] });
902
904
  }
905
+ function AttachmentCard({ attachment, block }) {
906
+ return /* @__PURE__ */ jsxs9("div", { className: `adn-preview-attachment ${block}`, children: [
907
+ /* @__PURE__ */ jsx9(Icon, { d: ICON.file, size: 18 }),
908
+ /* @__PURE__ */ jsxs9("span", { className: "adn-preview-attachment__text", children: [
909
+ /* @__PURE__ */ jsx9("span", { className: "adn-preview-attachment__name", children: attachment.name }),
910
+ attachment.detail ? /* @__PURE__ */ jsx9("span", { className: "adn-preview-attachment__detail", children: attachment.detail }) : null
911
+ ] })
912
+ ] });
913
+ }
903
914
  function MailBody({ html, text }) {
904
915
  if (!html) return /* @__PURE__ */ jsx9("div", { className: "adn-preview-mail__body", children: text });
905
916
  return /* @__PURE__ */ jsx9(
@@ -912,17 +923,44 @@ function MailBody({ html, text }) {
912
923
  }
913
924
  );
914
925
  }
915
- function TemplatePreview({ channel, viewport, rendered, emailHtml, senderName, labels }) {
926
+ function TemplatePreview({
927
+ channel,
928
+ viewport,
929
+ rendered,
930
+ emailHtml,
931
+ senderName,
932
+ attachment,
933
+ labels
934
+ }) {
916
935
  const sender = senderName ?? rendered.title.slice(0, 1).toUpperCase();
917
936
  if (channel === "whatsapp") {
918
- return /* @__PURE__ */ jsx9(WhatsAppPreview, { rendered, labels, os: viewport, senderName: sender });
937
+ return /* @__PURE__ */ jsx9(WhatsAppPreview, { rendered, labels, os: viewport, senderName: sender, attachment });
919
938
  }
920
939
  if (channel === "sms") return /* @__PURE__ */ jsx9(SmsPreview, { rendered, os: viewport, labels });
921
940
  if (channel === "push") {
922
941
  return /* @__PURE__ */ jsx9(PushPreview, { rendered, senderName: sender, labels, os: viewport });
923
942
  }
924
943
  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 });
944
+ return viewport === "browser" ? /* @__PURE__ */ jsx9(
945
+ EmailDesktop,
946
+ {
947
+ rendered,
948
+ emailHtml,
949
+ senderName: sender,
950
+ labels,
951
+ attachment
952
+ }
953
+ ) : /* @__PURE__ */ jsx9(
954
+ EmailMobile,
955
+ {
956
+ rendered,
957
+ emailHtml,
958
+ senderName: sender,
959
+ os: viewport,
960
+ labels,
961
+ attachment
962
+ }
963
+ );
926
964
  }
927
965
 
928
966
  // src/components/NotificationSettingsWorkspace.tsx
@@ -1480,6 +1518,7 @@ export {
1480
1518
  TEMPLATE_COLUMNS,
1481
1519
  TEMPLATE_SORT_FIELDS,
1482
1520
  TEMPLATE_VIEWS,
1521
+ TemplatePreview,
1483
1522
  applyMark,
1484
1523
  flattenNotificationPages,
1485
1524
  formatNotificationTime,