@pushwoosh/dumb-components 1.1.225 → 1.1.226

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/WhatsAppPreview/WhatsAppPreview.d.ts +1 -1
  2. package/WhatsAppPreview/WhatsAppPreview.js +31 -92
  3. package/WhatsAppPreview/__tests__/attachment.test.js +17 -11
  4. package/WhatsAppPreview/components/WhatsAppAttachment/WhatsAppAttachment.js +41 -38
  5. package/WhatsAppPreview/components/WhatsAppAttachment/styles.d.ts +11 -30
  6. package/WhatsAppPreview/components/WhatsAppAttachment/styles.js +23 -30
  7. package/WhatsAppPreview/components/WhatsAppAttachment/types.d.ts +0 -5
  8. package/WhatsAppPreview/components/WhatsAppMessageBubble/WhatsAppMessageBubble.d.ts +1 -1
  9. package/WhatsAppPreview/components/WhatsAppMessageBubble/WhatsAppMessageBubble.js +14 -33
  10. package/WhatsAppPreview/components/WhatsAppMessageBubble/styles.d.ts +2 -16
  11. package/WhatsAppPreview/components/WhatsAppMessageBubble/styles.js +5 -33
  12. package/WhatsAppPreview/constants.d.ts +10 -40
  13. package/WhatsAppPreview/constants.js +11 -41
  14. package/WhatsAppPreview/helpers.d.ts +3 -1
  15. package/WhatsAppPreview/helpers.js +12 -4
  16. package/WhatsAppPreview/icons/index.d.ts +0 -10
  17. package/WhatsAppPreview/icons/index.js +1 -11
  18. package/WhatsAppPreview/index.d.ts +1 -1
  19. package/WhatsAppPreview/polyglot/messages_ar.js +2 -3
  20. package/WhatsAppPreview/polyglot/messages_bn.js +2 -3
  21. package/WhatsAppPreview/polyglot/messages_de.js +2 -3
  22. package/WhatsAppPreview/polyglot/messages_en.js +2 -3
  23. package/WhatsAppPreview/polyglot/messages_es.js +2 -3
  24. package/WhatsAppPreview/polyglot/messages_fr.js +2 -3
  25. package/WhatsAppPreview/polyglot/messages_he.js +2 -3
  26. package/WhatsAppPreview/polyglot/messages_hi.js +2 -3
  27. package/WhatsAppPreview/polyglot/messages_ja.js +2 -3
  28. package/WhatsAppPreview/polyglot/messages_ko.js +2 -3
  29. package/WhatsAppPreview/polyglot/messages_pt.js +2 -3
  30. package/WhatsAppPreview/polyglot/messages_ru.js +2 -3
  31. package/WhatsAppPreview/polyglot/messages_th.js +2 -3
  32. package/WhatsAppPreview/polyglot/messages_zh.js +2 -3
  33. package/WhatsAppPreview/polyglot/types.d.ts +3 -2
  34. package/WhatsAppPreview/styles.d.ts +21 -14
  35. package/WhatsAppPreview/styles.js +22 -19
  36. package/WhatsAppPreview/types.d.ts +11 -35
  37. package/index.d.ts +1 -1
  38. package/package.json +1 -1
  39. package/WhatsAppPreview/components/WhatsAppChatHeader/WhatsAppChatHeader.d.ts +0 -4
  40. package/WhatsAppPreview/components/WhatsAppChatHeader/WhatsAppChatHeader.js +0 -39
  41. package/WhatsAppPreview/components/WhatsAppChatHeader/index.d.ts +0 -1
  42. package/WhatsAppPreview/components/WhatsAppChatHeader/index.js +0 -1
  43. package/WhatsAppPreview/components/WhatsAppChatHeader/styles.d.ts +0 -47
  44. package/WhatsAppPreview/components/WhatsAppChatHeader/styles.js +0 -37
  45. package/WhatsAppPreview/components/WhatsAppChatHeader/types.d.ts +0 -10
  46. package/WhatsAppPreview/components/WhatsAppChatHeader/types.js +0 -1
  47. package/WhatsAppPreview/components/WhatsAppDateChip/WhatsAppDateChip.d.ts +0 -4
  48. package/WhatsAppPreview/components/WhatsAppDateChip/WhatsAppDateChip.js +0 -28
  49. package/WhatsAppPreview/components/WhatsAppDateChip/index.d.ts +0 -1
  50. package/WhatsAppPreview/components/WhatsAppDateChip/index.js +0 -1
  51. package/WhatsAppPreview/components/WhatsAppDateChip/styles.d.ts +0 -6
  52. package/WhatsAppPreview/components/WhatsAppDateChip/styles.js +0 -6
  53. package/WhatsAppPreview/components/WhatsAppDateChip/types.d.ts +0 -6
  54. package/WhatsAppPreview/components/WhatsAppDateChip/types.js +0 -1
  55. package/WhatsAppPreview/components/WhatsAppStatusBar/WhatsAppStatusBar.d.ts +0 -4
  56. package/WhatsAppPreview/components/WhatsAppStatusBar/WhatsAppStatusBar.js +0 -18
  57. package/WhatsAppPreview/components/WhatsAppStatusBar/index.d.ts +0 -1
  58. package/WhatsAppPreview/components/WhatsAppStatusBar/index.js +0 -1
  59. package/WhatsAppPreview/components/WhatsAppStatusBar/styles.d.ts +0 -69
  60. package/WhatsAppPreview/components/WhatsAppStatusBar/styles.js +0 -47
  61. package/WhatsAppPreview/components/WhatsAppStatusBar/types.d.ts +0 -5
  62. package/WhatsAppPreview/components/WhatsAppStatusBar/types.js +0 -1
  63. package/WhatsAppPreview/icons/WhatsAppAvatarIcon.svg +0 -1
  64. package/WhatsAppPreview/icons/WhatsAppBackIcon.svg +0 -1
  65. package/WhatsAppPreview/icons/WhatsAppBatteryIcon.svg +0 -1
  66. package/WhatsAppPreview/icons/WhatsAppCallIcon.svg +0 -1
  67. package/WhatsAppPreview/icons/WhatsAppMenuIcon.svg +0 -1
  68. package/WhatsAppPreview/icons/WhatsAppSignalIcon.svg +0 -1
  69. package/WhatsAppPreview/icons/WhatsAppTickIcon.svg +0 -1
  70. package/WhatsAppPreview/icons/WhatsAppTicksIcon.svg +0 -1
  71. package/WhatsAppPreview/icons/WhatsAppWallpaperPattern.svg +0 -1
  72. package/WhatsAppPreview/icons/WhatsAppWifiIcon.svg +0 -1
@@ -1,17 +1,5 @@
1
- /** Colours of the replicated WhatsApp chat UI; they are WhatsApp's, not Pushwoosh design tokens. */
1
+ /** Colours of the replicated WhatsApp bubble; they are WhatsApp's, not Pushwoosh design tokens. */
2
2
  export declare const WHATSAPP_COLOR: {
3
- readonly DEVICE_SHELL: "#DFE2E5";
4
- readonly DEVICE_EDGE: "#C7CCD1";
5
- readonly SCREEN: "#EFE7DE";
6
- readonly HEADER: "#F6F3EF";
7
- readonly HEADER_BORDER: "#DAD5CF";
8
- readonly ISLAND: "#2B2F33";
9
- readonly STATUS_BAR: "#0B0C0D";
10
- readonly TITLE: "#111B21";
11
- readonly SUBTITLE: "#667781";
12
- readonly ACTION: "#3B4A54";
13
- readonly AVATAR: "#CFD6DB";
14
- readonly AVATAR_GLYPH: "#FFFFFF";
15
3
  readonly INCOMING_BUBBLE: "#FFFFFF";
16
4
  readonly MEDIA_BACKDROP: "#0B141A";
17
5
  readonly MEDIA_META: "#FFFFFF";
@@ -19,36 +7,18 @@ export declare const WHATSAPP_COLOR: {
19
7
  readonly PLAY_BUTTON: "rgba(255, 255, 255, 0.85)";
20
8
  readonly PLAY_GLYPH: "#111B21";
21
9
  readonly DOCUMENT_CARD: "#F5F6F6";
22
- readonly DOCUMENT_PDF: "#E7554B";
23
- readonly DOCUMENT_TEXT: "#2E7CD6";
24
- readonly DOCUMENT_GENERIC: "#8696A0";
10
+ readonly DOCUMENT_GLYPH: "#8696A0";
25
11
  readonly OUTGOING_BUBBLE: "#D9FDD3";
26
- readonly BUBBLE_TEXT: "#111B21";
27
- readonly BUBBLE_META: "#667781";
28
- readonly BUBBLE_SHADOW: "rgba(11, 20, 26, 0.13)";
29
- readonly READ_TICK: "#53BDEB";
30
- readonly DATE_CHIP_TEXT: "#54656F";
31
- readonly WALLPAPER_INK: "#D8CCBD";
32
12
  };
33
- export declare const WHATSAPP_PREVIEW_WIDTH = 340;
34
- export declare const WHATSAPP_PREVIEW_HEIGHT = 640;
35
- export declare const WHATSAPP_DEVICE_PADDING = 5;
36
- export declare const WHATSAPP_DEVICE_BORDER = 1;
37
- export declare const WHATSAPP_SCREEN_WIDTH: number;
38
- /** Status bar geometry at {@link WHATSAPP_SCREEN_WIDTH}; a narrower device gets the same layout scaled down. */
39
- export declare const WHATSAPP_STATUS_BAR: {
40
- readonly HEIGHT: 44;
41
- readonly PADDING_LEFT: 28;
42
- readonly PADDING_RIGHT: 22;
43
- readonly CLOCK_FONT_SIZE: 14;
44
- readonly ISLAND_WIDTH: 92;
45
- readonly ISLAND_HEIGHT: 26;
46
- readonly ISLAND_TOP: 8;
47
- readonly INDICATOR_GAP: 5;
48
- readonly INDICATOR_HEIGHT: 12;
49
- };
50
- export declare const WHATSAPP_STATUS_BAR_TIME = "12:02";
13
+ /** Bubble geometry from the design: 280px of content inside a 12px padding and a 1px border, border-box. */
14
+ export declare const WHATSAPP_BUBBLE_WIDTH = 306;
15
+ export declare const WHATSAPP_BUBBLE_PADDING = 12;
16
+ export declare const WHATSAPP_BACKDROP_PADDING = 24;
17
+ export declare const WHATSAPP_BACKDROP_WIDTH: number;
51
18
  export declare const WHATSAPP_MEDIA_MAX_HEIGHT = 320;
19
+ /** A tiny or very wide file still has to fit the duration badge, so media never draws thinner than this. */
20
+ export declare const WHATSAPP_MEDIA_MIN_HEIGHT = 48;
21
+ export declare const WHATSAPP_MEDIA_RADIUS = 4;
52
22
  export declare const WHATSAPP_ATTACHMENT_EXTENSIONS: {
53
23
  readonly image: string[];
54
24
  readonly video: string[];
@@ -1,17 +1,5 @@
1
- /** Colours of the replicated WhatsApp chat UI; they are WhatsApp's, not Pushwoosh design tokens. */
1
+ /** Colours of the replicated WhatsApp bubble; they are WhatsApp's, not Pushwoosh design tokens. */
2
2
  export const WHATSAPP_COLOR = {
3
- DEVICE_SHELL: '#DFE2E5',
4
- DEVICE_EDGE: '#C7CCD1',
5
- SCREEN: '#EFE7DE',
6
- HEADER: '#F6F3EF',
7
- HEADER_BORDER: '#DAD5CF',
8
- ISLAND: '#2B2F33',
9
- STATUS_BAR: '#0B0C0D',
10
- TITLE: '#111B21',
11
- SUBTITLE: '#667781',
12
- ACTION: '#3B4A54',
13
- AVATAR: '#CFD6DB',
14
- AVATAR_GLYPH: '#FFFFFF',
15
3
  INCOMING_BUBBLE: '#FFFFFF',
16
4
  MEDIA_BACKDROP: '#0B141A',
17
5
  MEDIA_META: '#FFFFFF',
@@ -19,36 +7,18 @@ export const WHATSAPP_COLOR = {
19
7
  PLAY_BUTTON: 'rgba(255, 255, 255, 0.85)',
20
8
  PLAY_GLYPH: '#111B21',
21
9
  DOCUMENT_CARD: '#F5F6F6',
22
- DOCUMENT_PDF: '#E7554B',
23
- DOCUMENT_TEXT: '#2E7CD6',
24
- DOCUMENT_GENERIC: '#8696A0',
25
- OUTGOING_BUBBLE: '#D9FDD3',
26
- BUBBLE_TEXT: '#111B21',
27
- BUBBLE_META: '#667781',
28
- BUBBLE_SHADOW: 'rgba(11, 20, 26, 0.13)',
29
- READ_TICK: '#53BDEB',
30
- DATE_CHIP_TEXT: '#54656F',
31
- WALLPAPER_INK: '#D8CCBD'
10
+ DOCUMENT_GLYPH: '#8696A0',
11
+ OUTGOING_BUBBLE: '#D9FDD3'
32
12
  };
33
- export const WHATSAPP_PREVIEW_WIDTH = 340;
34
- export const WHATSAPP_PREVIEW_HEIGHT = 640;
35
- export const WHATSAPP_DEVICE_PADDING = 5;
36
- export const WHATSAPP_DEVICE_BORDER = 1;
37
- export const WHATSAPP_SCREEN_WIDTH = WHATSAPP_PREVIEW_WIDTH - (WHATSAPP_DEVICE_PADDING + WHATSAPP_DEVICE_BORDER) * 2;
38
- /** Status bar geometry at {@link WHATSAPP_SCREEN_WIDTH}; a narrower device gets the same layout scaled down. */
39
- export const WHATSAPP_STATUS_BAR = {
40
- HEIGHT: 44,
41
- PADDING_LEFT: 28,
42
- PADDING_RIGHT: 22,
43
- CLOCK_FONT_SIZE: 14,
44
- ISLAND_WIDTH: 92,
45
- ISLAND_HEIGHT: 26,
46
- ISLAND_TOP: 8,
47
- INDICATOR_GAP: 5,
48
- INDICATOR_HEIGHT: 12
49
- };
50
- export const WHATSAPP_STATUS_BAR_TIME = '12:02';
13
+ /** Bubble geometry from the design: 280px of content inside a 12px padding and a 1px border, border-box. */
14
+ export const WHATSAPP_BUBBLE_WIDTH = 306;
15
+ export const WHATSAPP_BUBBLE_PADDING = 12;
16
+ export const WHATSAPP_BACKDROP_PADDING = 24;
17
+ export const WHATSAPP_BACKDROP_WIDTH = WHATSAPP_BUBBLE_WIDTH + WHATSAPP_BACKDROP_PADDING * 2;
51
18
  export const WHATSAPP_MEDIA_MAX_HEIGHT = 320;
19
+ /** A tiny or very wide file still has to fit the duration badge, so media never draws thinner than this. */
20
+ export const WHATSAPP_MEDIA_MIN_HEIGHT = 48;
21
+ export const WHATSAPP_MEDIA_RADIUS = 4;
52
22
  const IMAGE_EXTENSIONS = ['jpg', 'jpeg', 'png', 'gif', 'webp'];
53
23
  const VIDEO_EXTENSIONS = ['mp4', 'mov', 'webm', '3gp'];
54
24
  export const WHATSAPP_ATTACHMENT_EXTENSIONS = {
@@ -2,12 +2,14 @@ import type { WhatsAppTextNode } from './components/WhatsAppFormattedText/types'
2
2
  import type { WhatsAppAttachment, WhatsAppAttachmentKind, WhatsAppMessage } from './types';
3
3
  /** Splits WhatsApp markup (`*bold*`, `_italic_`, `~strike~`, backtick monospace) into a render tree. */
4
4
  export declare function parseWhatsAppMarkup(text: string): WhatsAppTextNode[];
5
- /** Extension of the attached file, lowercase and without the dot; empty when the name carries none. */
5
+ /** File type shown on a document card: the name extension, or the MIME subtype when the name carries none. */
6
6
  export declare function getAttachmentExtension(attachment: WhatsAppAttachment): string;
7
7
  /** Picks how the attachment is drawn: explicit `kind` first, then the MIME type, then the extension. */
8
8
  export declare function resolveAttachmentKind(attachment: WhatsAppAttachment): WhatsAppAttachmentKind;
9
9
  /** Whether the message has anything to show; a bubble with neither body nor file content is not drawn at all. */
10
10
  export declare function isMessageDrawable(message: WhatsAppMessage): boolean;
11
+ /** Attachments that have something to render; a file without a source is skipped. */
12
+ export declare function drawableAttachments(message: WhatsAppMessage): WhatsAppAttachment[];
11
13
  /** File size the way WhatsApp writes it on a document card: `912 B`, `68 kB`, `1.4 MB`. */
12
14
  export declare function formatAttachmentSize(size: number): string;
13
15
  /** Video length as the `m:ss` badge of a WhatsApp video bubble. */
@@ -55,13 +55,17 @@ export function parseWhatsAppMarkup(text) {
55
55
  flush();
56
56
  return nodes;
57
57
  }
58
- /** Extension of the attached file, lowercase and without the dot; empty when the name carries none. */
58
+ /** File type shown on a document card: the name extension, or the MIME subtype when the name carries none. */
59
59
  export function getAttachmentExtension(attachment) {
60
60
  const {
61
- name
61
+ name,
62
+ mimeType = ''
62
63
  } = attachment;
63
64
  const dot = name.lastIndexOf('.');
64
- return dot > 0 ? name.slice(dot + 1).toLowerCase() : '';
65
+ if (dot > 0) {
66
+ return name.slice(dot + 1).toLowerCase();
67
+ }
68
+ return mimeType.split('/')[1]?.toLowerCase() || '';
65
69
  }
66
70
  /** Picks how the attachment is drawn: explicit `kind` first, then the MIME type, then the extension. */
67
71
  export function resolveAttachmentKind(attachment) {
@@ -86,7 +90,11 @@ export function resolveAttachmentKind(attachment) {
86
90
  }
87
91
  /** Whether the message has anything to show; a bubble with neither body nor file content is not drawn at all. */
88
92
  export function isMessageDrawable(message) {
89
- return Boolean(message.text || message.content || message.attachment?.source);
93
+ return Boolean(message.text || message.content || drawableAttachments(message).length);
94
+ }
95
+ /** Attachments that have something to render; a file without a source is skipped. */
96
+ export function drawableAttachments(message) {
97
+ return (message.attachments || []).filter(attachment => attachment.source);
90
98
  }
91
99
  /** File size the way WhatsApp writes it on a document card: `912 B`, `68 kB`, `1.4 MB`. */
92
100
  export function formatAttachmentSize(size) {
@@ -1,13 +1,3 @@
1
- export { default as WhatsAppAvatarIcon } from './WhatsAppAvatarIcon.svg';
2
- export { default as WhatsAppBackIcon } from './WhatsAppBackIcon.svg';
3
- export { default as WhatsAppBatteryIcon } from './WhatsAppBatteryIcon.svg';
4
- export { default as WhatsAppCallIcon } from './WhatsAppCallIcon.svg';
5
1
  export { default as WhatsAppDocumentIcon } from './WhatsAppDocumentIcon.svg';
6
- export { default as WhatsAppMenuIcon } from './WhatsAppMenuIcon.svg';
7
2
  export { default as WhatsAppPlayIcon } from './WhatsAppPlayIcon.svg';
8
- export { default as WhatsAppSignalIcon } from './WhatsAppSignalIcon.svg';
9
- export { default as WhatsAppTickIcon } from './WhatsAppTickIcon.svg';
10
- export { default as WhatsAppTicksIcon } from './WhatsAppTicksIcon.svg';
11
3
  export { default as WhatsAppVideoIcon } from './WhatsAppVideoIcon.svg';
12
- export { default as WhatsAppWallpaperPattern } from './WhatsAppWallpaperPattern.svg';
13
- export { default as WhatsAppWifiIcon } from './WhatsAppWifiIcon.svg';
@@ -1,13 +1,3 @@
1
- export { default as WhatsAppAvatarIcon } from './WhatsAppAvatarIcon.svg';
2
- export { default as WhatsAppBackIcon } from './WhatsAppBackIcon.svg';
3
- export { default as WhatsAppBatteryIcon } from './WhatsAppBatteryIcon.svg';
4
- export { default as WhatsAppCallIcon } from './WhatsAppCallIcon.svg';
5
1
  export { default as WhatsAppDocumentIcon } from './WhatsAppDocumentIcon.svg';
6
- export { default as WhatsAppMenuIcon } from './WhatsAppMenuIcon.svg';
7
2
  export { default as WhatsAppPlayIcon } from './WhatsAppPlayIcon.svg';
8
- export { default as WhatsAppSignalIcon } from './WhatsAppSignalIcon.svg';
9
- export { default as WhatsAppTickIcon } from './WhatsAppTickIcon.svg';
10
- export { default as WhatsAppTicksIcon } from './WhatsAppTicksIcon.svg';
11
- export { default as WhatsAppVideoIcon } from './WhatsAppVideoIcon.svg';
12
- export { default as WhatsAppWallpaperPattern } from './WhatsAppWallpaperPattern.svg';
13
- export { default as WhatsAppWifiIcon } from './WhatsAppWifiIcon.svg';
3
+ export { default as WhatsAppVideoIcon } from './WhatsAppVideoIcon.svg';
@@ -1,2 +1,2 @@
1
1
  export { WhatsAppPreview } from './WhatsAppPreview';
2
- export type { WhatsAppAttachment, WhatsAppAttachmentKind, WhatsAppMessage, WhatsAppMessageDirection, WhatsAppMessageStatus, WhatsAppPreviewProps, } from './types';
2
+ export type { WhatsAppAttachment, WhatsAppAttachmentKind, WhatsAppMessage, WhatsAppPreviewProps, } from './types';
@@ -1,5 +1,4 @@
1
1
  export const messages = {
2
- 'DUMB.WHATSAPP_PREVIEW.BUSINESS_ACCOUNT': 'حساب أعمال',
3
- 'DUMB.WHATSAPP_PREVIEW.EMPTY': 'الرسالة فارغة…',
4
- 'DUMB.WHATSAPP_PREVIEW.TODAY': 'اليوم'
2
+ 'DUMB.WHATSAPP_PREVIEW.DOCUMENT_PAGES': '{{count}} صفحة',
3
+ 'DUMB.WHATSAPP_PREVIEW.EMPTY': 'الرسالة فارغة…'
5
4
  };
@@ -1,5 +1,4 @@
1
1
  export const messages = {
2
- 'DUMB.WHATSAPP_PREVIEW.BUSINESS_ACCOUNT': 'ব্যবসায়িক অ্যাকাউন্ট',
3
- 'DUMB.WHATSAPP_PREVIEW.EMPTY': 'বার্তাটি খালি…',
4
- 'DUMB.WHATSAPP_PREVIEW.TODAY': 'আজ'
2
+ 'DUMB.WHATSAPP_PREVIEW.DOCUMENT_PAGES': '{{count}}টি পৃষ্ঠা',
3
+ 'DUMB.WHATSAPP_PREVIEW.EMPTY': 'বার্তাটি খালি…'
5
4
  };
@@ -1,5 +1,4 @@
1
1
  export const messages = {
2
- 'DUMB.WHATSAPP_PREVIEW.BUSINESS_ACCOUNT': 'Unternehmenskonto',
3
- 'DUMB.WHATSAPP_PREVIEW.EMPTY': 'Die Nachricht ist leer…',
4
- 'DUMB.WHATSAPP_PREVIEW.TODAY': 'Heute'
2
+ 'DUMB.WHATSAPP_PREVIEW.DOCUMENT_PAGES': '{{count}} {{count | pluralize: "Seite", "Seiten"}}',
3
+ 'DUMB.WHATSAPP_PREVIEW.EMPTY': 'Die Nachricht ist leer…'
5
4
  };
@@ -1,5 +1,4 @@
1
1
  export const messages = {
2
- 'DUMB.WHATSAPP_PREVIEW.BUSINESS_ACCOUNT': 'Business account',
3
- 'DUMB.WHATSAPP_PREVIEW.EMPTY': 'Message is empty…',
4
- 'DUMB.WHATSAPP_PREVIEW.TODAY': 'Today'
2
+ 'DUMB.WHATSAPP_PREVIEW.DOCUMENT_PAGES': '{{count}} {{count | pluralize: "page", "pages"}}',
3
+ 'DUMB.WHATSAPP_PREVIEW.EMPTY': 'Message is empty…'
5
4
  };
@@ -1,5 +1,4 @@
1
1
  export const messages = {
2
- 'DUMB.WHATSAPP_PREVIEW.BUSINESS_ACCOUNT': 'Cuenta de empresa',
3
- 'DUMB.WHATSAPP_PREVIEW.EMPTY': 'El mensaje está vacío…',
4
- 'DUMB.WHATSAPP_PREVIEW.TODAY': 'Hoy'
2
+ 'DUMB.WHATSAPP_PREVIEW.DOCUMENT_PAGES': '{{count}} {{count | pluralize: "página", "páginas"}}',
3
+ 'DUMB.WHATSAPP_PREVIEW.EMPTY': 'El mensaje está vacío…'
5
4
  };
@@ -1,5 +1,4 @@
1
1
  export const messages = {
2
- 'DUMB.WHATSAPP_PREVIEW.BUSINESS_ACCOUNT': 'Compte professionnel',
3
- 'DUMB.WHATSAPP_PREVIEW.EMPTY': 'Le message est vide…',
4
- 'DUMB.WHATSAPP_PREVIEW.TODAY': 'Aujourd’hui'
2
+ 'DUMB.WHATSAPP_PREVIEW.DOCUMENT_PAGES': '{{count}} {{count | pluralize: "page", "pages"}}',
3
+ 'DUMB.WHATSAPP_PREVIEW.EMPTY': 'Le message est vide…'
5
4
  };
@@ -1,5 +1,4 @@
1
1
  export const messages = {
2
- 'DUMB.WHATSAPP_PREVIEW.BUSINESS_ACCOUNT': 'חשבון עסקי',
3
- 'DUMB.WHATSAPP_PREVIEW.EMPTY': 'ההודעה ריקה…',
4
- 'DUMB.WHATSAPP_PREVIEW.TODAY': 'היום'
2
+ 'DUMB.WHATSAPP_PREVIEW.DOCUMENT_PAGES': '{{count}} עמודים',
3
+ 'DUMB.WHATSAPP_PREVIEW.EMPTY': 'ההודעה ריקה…'
5
4
  };
@@ -1,5 +1,4 @@
1
1
  export const messages = {
2
- 'DUMB.WHATSAPP_PREVIEW.BUSINESS_ACCOUNT': 'व्यवसाय खाता',
3
- 'DUMB.WHATSAPP_PREVIEW.EMPTY': 'संदेश खाली है…',
4
- 'DUMB.WHATSAPP_PREVIEW.TODAY': 'आज'
2
+ 'DUMB.WHATSAPP_PREVIEW.DOCUMENT_PAGES': '{{count}} पृष्ठ',
3
+ 'DUMB.WHATSAPP_PREVIEW.EMPTY': 'संदेश खाली है…'
5
4
  };
@@ -1,5 +1,4 @@
1
1
  export const messages = {
2
- 'DUMB.WHATSAPP_PREVIEW.BUSINESS_ACCOUNT': 'ビジネスアカウント',
3
- 'DUMB.WHATSAPP_PREVIEW.EMPTY': 'メッセージが空です…',
4
- 'DUMB.WHATSAPP_PREVIEW.TODAY': '今日'
2
+ 'DUMB.WHATSAPP_PREVIEW.DOCUMENT_PAGES': '{{count}} ページ',
3
+ 'DUMB.WHATSAPP_PREVIEW.EMPTY': 'メッセージが空です…'
5
4
  };
@@ -1,5 +1,4 @@
1
1
  export const messages = {
2
- 'DUMB.WHATSAPP_PREVIEW.BUSINESS_ACCOUNT': '비즈니스 계정',
3
- 'DUMB.WHATSAPP_PREVIEW.EMPTY': '메시지가 비어 있습니다…',
4
- 'DUMB.WHATSAPP_PREVIEW.TODAY': '오늘'
2
+ 'DUMB.WHATSAPP_PREVIEW.DOCUMENT_PAGES': '{{count}}페이지',
3
+ 'DUMB.WHATSAPP_PREVIEW.EMPTY': '메시지가 비어 있습니다…'
5
4
  };
@@ -1,5 +1,4 @@
1
1
  export const messages = {
2
- 'DUMB.WHATSAPP_PREVIEW.BUSINESS_ACCOUNT': 'Conta comercial',
3
- 'DUMB.WHATSAPP_PREVIEW.EMPTY': 'A mensagem está vazia…',
4
- 'DUMB.WHATSAPP_PREVIEW.TODAY': 'Hoje'
2
+ 'DUMB.WHATSAPP_PREVIEW.DOCUMENT_PAGES': '{{count}} {{count | pluralize: "página", "páginas"}}',
3
+ 'DUMB.WHATSAPP_PREVIEW.EMPTY': 'A mensagem está vazia…'
5
4
  };
@@ -1,5 +1,4 @@
1
1
  export const messages = {
2
- 'DUMB.WHATSAPP_PREVIEW.BUSINESS_ACCOUNT': 'Бизнес-аккаунт',
3
- 'DUMB.WHATSAPP_PREVIEW.EMPTY': 'Сообщение пустое…',
4
- 'DUMB.WHATSAPP_PREVIEW.TODAY': 'Сегодня'
2
+ 'DUMB.WHATSAPP_PREVIEW.DOCUMENT_PAGES': '{{count}} {{count | pluralize: "страница", "страницы", "страниц"}}',
3
+ 'DUMB.WHATSAPP_PREVIEW.EMPTY': 'Сообщение пустое…'
5
4
  };
@@ -1,5 +1,4 @@
1
1
  export const messages = {
2
- 'DUMB.WHATSAPP_PREVIEW.BUSINESS_ACCOUNT': 'บัญชีธุรกิจ',
3
- 'DUMB.WHATSAPP_PREVIEW.EMPTY': 'ข้อความว่างเปล่า…',
4
- 'DUMB.WHATSAPP_PREVIEW.TODAY': 'วันนี้'
2
+ 'DUMB.WHATSAPP_PREVIEW.DOCUMENT_PAGES': '{{count}} หน้า',
3
+ 'DUMB.WHATSAPP_PREVIEW.EMPTY': 'ข้อความว่างเปล่า…'
5
4
  };
@@ -1,5 +1,4 @@
1
1
  export const messages = {
2
- 'DUMB.WHATSAPP_PREVIEW.BUSINESS_ACCOUNT': '商业账号',
3
- 'DUMB.WHATSAPP_PREVIEW.EMPTY': '消息为空…',
4
- 'DUMB.WHATSAPP_PREVIEW.TODAY': '今天'
2
+ 'DUMB.WHATSAPP_PREVIEW.DOCUMENT_PAGES': '{{count}} 页',
3
+ 'DUMB.WHATSAPP_PREVIEW.EMPTY': '消息为空…'
5
4
  };
@@ -1,6 +1,7 @@
1
1
  import type { NoParams } from '../../polyglot';
2
2
  export type WhatsAppPreviewMessages = {
3
- 'DUMB.WHATSAPP_PREVIEW.BUSINESS_ACCOUNT': NoParams;
3
+ 'DUMB.WHATSAPP_PREVIEW.DOCUMENT_PAGES': {
4
+ count: number;
5
+ };
4
6
  'DUMB.WHATSAPP_PREVIEW.EMPTY': NoParams;
5
- 'DUMB.WHATSAPP_PREVIEW.TODAY': NoParams;
6
7
  };
@@ -1,4 +1,5 @@
1
- export declare const DeviceBox: import("styled-components").StyledComponent<"div", any, import("@pushwoosh/kit-helpers/styled-helpers").CommonBoxProps & {
1
+ import { Color, ShapeRadius } from '@pushwoosh/kit-constants';
2
+ export declare const Backdrop: import("styled-components").StyledComponent<"div", any, import("@pushwoosh/kit-helpers/styled-helpers").CommonBoxProps & {
2
3
  $alignContent?: import("@pushwoosh/kit-helpers/styled-helpers").AlignContentValue | undefined;
3
4
  $alignItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue | undefined;
4
5
  $gap?: import("@pushwoosh/kit-helpers/styled-helpers").StrNum | undefined;
@@ -8,15 +9,9 @@ export declare const DeviceBox: import("styled-components").StyledComponent<"div
8
9
  $justifyItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue | undefined;
9
10
  $placeItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue | undefined;
10
11
  } & {
11
- $sizes: import("@pushwoosh/kit-helpers/styled-helpers").StrNum;
12
- } & {
13
- $sizes: string;
14
- $padding: number;
15
- $borderRadius: number;
16
- $bgColor: "#DFE2E5";
17
- $border: string;
18
- }, "$bgColor" | "$border" | "$borderRadius" | "$padding" | "$sizes">;
19
- export declare const WallpaperLayer: import("styled-components").StyledComponent<"div", any, import("@pushwoosh/kit-helpers/styled-helpers").CommonBoxProps & {
12
+ $gridAutoFlow: string;
13
+ }, "$gridAutoFlow">;
14
+ export declare const Bubble: import("styled-components").StyledComponent<"div", any, import("@pushwoosh/kit-helpers/styled-helpers").CommonBoxProps & {
20
15
  $alignContent?: import("@pushwoosh/kit-helpers/styled-helpers").AlignContentValue | undefined;
21
16
  $alignItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue | undefined;
22
17
  $gap?: import("@pushwoosh/kit-helpers/styled-helpers").StrNum | undefined;
@@ -28,7 +23,19 @@ export declare const WallpaperLayer: import("styled-components").StyledComponent
28
23
  } & {
29
24
  $gridAutoFlow: string;
30
25
  } & {
31
- $position: string;
32
- $inset: number;
33
- }, "$gridAutoFlow" | "$inset" | "$position">;
34
- export declare const WallpaperImage: import("styled-components").StyledComponent<"img", any, {}, never>;
26
+ $bgColor: Color;
27
+ $border: string;
28
+ $borderRadius: ShapeRadius;
29
+ $gap: number;
30
+ $padding: number;
31
+ $width: number;
32
+ }, "$gridAutoFlow" | "$bgColor" | "$border" | "$borderRadius" | "$padding" | "$width" | "$gap">;
33
+ export declare const PreviewText: import("styled-components").StyledComponent<"span", any, {
34
+ $color?: string | undefined;
35
+ $uppercase?: boolean | undefined;
36
+ $ellipsis?: boolean | undefined;
37
+ $variant?: import("@pushwoosh/kit-typography").TypographyVariant | undefined;
38
+ } & {
39
+ $variant: "footnote";
40
+ $color: Color;
41
+ }, "$color" | "$variant">;
@@ -1,24 +1,27 @@
1
1
  import styled from 'styled-components';
2
- import { Rows, Vertical } from '@pushwoosh/kit-helpers';
3
- import { WHATSAPP_COLOR, WHATSAPP_DEVICE_BORDER, WHATSAPP_DEVICE_PADDING } from './constants';
4
- export const DeviceBox = styled(Rows).attrs({
5
- $sizes: 'minmax(0, 1fr)',
6
- $padding: WHATSAPP_DEVICE_PADDING,
7
- $borderRadius: 44,
8
- $bgColor: WHATSAPP_COLOR.DEVICE_SHELL,
9
- $border: `${WHATSAPP_DEVICE_BORDER}px solid ${WHATSAPP_COLOR.DEVICE_EDGE}`
10
- }).withConfig({
11
- displayName: "DeviceBox",
2
+ import { Color, Shadow, ShapeRadius } from '@pushwoosh/kit-constants';
3
+ import { Vertical } from '@pushwoosh/kit-helpers';
4
+ import { Text } from '@pushwoosh/kit-typography';
5
+ import { WHATSAPP_BUBBLE_PADDING, WHATSAPP_BUBBLE_WIDTH } from './constants';
6
+ export const Backdrop = styled(Vertical).withConfig({
7
+ displayName: "Backdrop",
12
8
  componentId: "sc-15y0kbp-0"
13
- })(["-webkit-font-smoothing:antialiased;*{box-sizing:border-box;}"]);
14
- export const WallpaperLayer = styled(Vertical).attrs({
15
- $position: 'absolute',
16
- $inset: 0
9
+ })(["-webkit-font-smoothing:antialiased;&,*{box-sizing:border-box;}"]);
10
+ export const Bubble = styled(Vertical).attrs({
11
+ $bgColor: Color.CLEAR,
12
+ $border: `1px solid ${Color.DIVIDER}`,
13
+ $borderRadius: ShapeRadius.SECTION,
14
+ $gap: WHATSAPP_BUBBLE_PADDING,
15
+ $padding: WHATSAPP_BUBBLE_PADDING,
16
+ $width: WHATSAPP_BUBBLE_WIDTH
17
17
  }).withConfig({
18
- displayName: "WallpaperLayer",
18
+ displayName: "Bubble",
19
19
  componentId: "sc-15y0kbp-1"
20
- })(["color:", ";opacity:0.5;pointer-events:none;svg{display:block;width:100%;height:100%;}"], WHATSAPP_COLOR.WALLPAPER_INK);
21
- export const WallpaperImage = styled.img.withConfig({
22
- displayName: "WallpaperImage",
20
+ })(["box-shadow:", ";overflow-wrap:anywhere;"], Shadow.LARGE);
21
+ export const PreviewText = styled(Text).attrs({
22
+ $variant: 'footnote',
23
+ $color: Color.MAIN
24
+ }).withConfig({
25
+ displayName: "PreviewText",
23
26
  componentId: "sc-15y0kbp-2"
24
- })(["width:100%;height:100%;object-fit:cover;"]);
27
+ })(["overflow:hidden;line-height:18px;text-overflow:ellipsis;"]);
@@ -1,8 +1,4 @@
1
1
  import type { ReactNode } from 'react';
2
- /** Who sent the message: `outgoing` is the phone owner (green, right), `incoming` is the business (white, left). */
3
- export type WhatsAppMessageDirection = 'incoming' | 'outgoing';
4
- /** Delivery state drawn as ticks next to an outgoing message's time. */
5
- export type WhatsAppMessageStatus = 'sent' | 'delivered' | 'read';
6
2
  /** How WhatsApp draws an attachment: media fills the bubble, a document becomes a card inside it. */
7
3
  export type WhatsAppAttachmentKind = 'image' | 'video' | 'document';
8
4
  /** File attached to a {@link WhatsAppMessage}. */
@@ -19,46 +15,26 @@ export interface WhatsAppAttachment {
19
15
  kind?: WhatsAppAttachmentKind;
20
16
  /** Video length in seconds; read from the file itself when omitted. */
21
17
  duration?: number;
18
+ /** Ready-made poster — a document's first page or a video frame — drawn instead of decoding the file itself. */
19
+ thumbnailSource?: string;
20
+ /** Page count of the document, shown in the meta line before the size. */
21
+ pageCount?: number;
22
22
  }
23
- /** One chat bubble of {@link WhatsAppPreview}. */
23
+ /** The message drawn by {@link WhatsAppPreview}. */
24
24
  export interface WhatsAppMessage {
25
- /** Stable key when the list is re-ordered or edited. */
26
- id?: string;
27
- /** Bubble side and colour. */
28
- direction: WhatsAppMessageDirection;
29
25
  /** Message body; WhatsApp markup (`*bold*`, `_italic_`, `~strike~`, `` `mono` ``) is rendered. */
30
26
  text?: string;
31
27
  /** Custom body rendered instead of `text` — e.g. an inline editor for the welcome message. */
32
28
  content?: ReactNode;
33
- /** File shown above the text, the way WhatsApp renders images, videos and documents. */
34
- attachment?: WhatsAppAttachment;
35
- /** Time stamp inside the bubble. */
36
- time?: string;
37
- /** Tick state; ignored for incoming messages. */
38
- status?: WhatsAppMessageStatus;
29
+ /** Files shown above the text, in order, the way WhatsApp renders images, videos and documents. */
30
+ attachments?: WhatsAppAttachment[];
39
31
  }
40
32
  /** Props of {@link WhatsAppPreview}. */
41
33
  export interface WhatsAppPreviewProps {
42
- /** Chat messages, oldest first. */
43
- messages?: WhatsAppMessage[];
44
- /** Business name in the chat header. */
45
- contactName?: string;
46
- /** Caption under the name; defaults to the localized "Business account". */
47
- contactSubtitle?: string;
48
- /** Business avatar URL; a placeholder glyph is drawn when absent. */
49
- avatarUrl?: string;
50
- /** Date separator above the first message; hide it with an empty string. */
51
- dateLabel?: string;
52
- /** Clock in the device status bar. */
53
- statusBarTime?: string;
54
- /** Chat wallpaper URL replacing the built-in pattern. */
55
- wallpaperUrl?: string;
56
- /** Text shown on the wallpaper while the chat has no messages. */
34
+ /** Message to draw; the placeholder is shown while it has neither body nor files. */
35
+ message?: WhatsAppMessage;
36
+ /** Text shown while the card has no message to draw. */
57
37
  emptyText?: ReactNode;
58
- /** CSS width of the device. */
59
- width?: string | number;
60
- /** CSS height of the device. */
61
- height?: string | number;
62
- /** Show the loading placeholder instead of the chat. */
38
+ /** Show the loading placeholder instead of the messages. */
63
39
  isLoading?: boolean;
64
40
  }
package/index.d.ts CHANGED
@@ -36,7 +36,7 @@ export { EmailTemplatePreview, NoEmailTemplatePreview, replaceLocalization, repl
36
36
  export { PushPreview } from './PushPreview';
37
37
  export { InboxPreview, resolveInboxLayout, MAX_CAROUSEL_SLIDES, type InboxLayoutType, type InboxPreviewPlatform, type InboxPreviewContent, type InboxPreviewProps, type InboxPreviewSlide, } from './InboxPreview';
38
38
  export { WhatsAppPreview } from './WhatsAppPreview';
39
- export type { WhatsAppAttachment, WhatsAppAttachmentKind, WhatsAppMessage, WhatsAppMessageDirection, WhatsAppMessageStatus, WhatsAppPreviewProps, } from './WhatsAppPreview';
39
+ export type { WhatsAppAttachment, WhatsAppAttachmentKind, WhatsAppMessage, WhatsAppPreviewProps, } from './WhatsAppPreview';
40
40
  export { Toast, ToastProvider, useToast } from './Toast';
41
41
  export { AutosizeInput, PageHeader, PageHeaderEditable } from './PageHeader';
42
42
  export { ExportResult } from './ExportResult';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/dumb-components",
3
- "version": "1.1.225",
3
+ "version": "1.1.226",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
@@ -1,4 +0,0 @@
1
- import { type ReactElement } from 'react';
2
- import type { WhatsAppChatHeaderProps } from './types';
3
- /** Chat screen header of the previewed conversation. */
4
- export declare function WhatsAppChatHeader(props: WhatsAppChatHeaderProps): ReactElement;
@@ -1,39 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Horizontal, Vertical } from '@pushwoosh/kit-helpers';
3
- import { Text } from '@pushwoosh/kit-typography';
4
- import { HeaderAvatar, HeaderAvatarImage, HeaderBox } from './styles';
5
- import { WHATSAPP_COLOR } from '../../constants';
6
- import { WhatsAppAvatarIcon, WhatsAppBackIcon, WhatsAppCallIcon, WhatsAppMenuIcon } from '../../icons';
7
- /** Chat screen header of the previewed conversation. */
8
- export function WhatsAppChatHeader(props) {
9
- const {
10
- name,
11
- subtitle,
12
- avatarUrl
13
- } = props;
14
- return _jsxs(HeaderBox, {
15
- children: [_jsx(WhatsAppBackIcon, {}), _jsx(HeaderAvatar, {
16
- children: avatarUrl ? _jsx(HeaderAvatarImage, {
17
- alt: name,
18
- src: avatarUrl
19
- }) : _jsx(WhatsAppAvatarIcon, {})
20
- }), _jsxs(Vertical, {
21
- "$minWidth": 0,
22
- children: [_jsx(Text, {
23
- "$color": WHATSAPP_COLOR.TITLE,
24
- "$ellipsis": true,
25
- "$variant": "h4",
26
- children: name
27
- }), _jsx(Text, {
28
- "$color": WHATSAPP_COLOR.SUBTITLE,
29
- "$ellipsis": true,
30
- "$variant": "footnote",
31
- children: subtitle
32
- })]
33
- }), _jsxs(Horizontal, {
34
- "$alignItems": "center",
35
- "$gap": 14,
36
- children: [_jsx(WhatsAppCallIcon, {}), _jsx(WhatsAppMenuIcon, {})]
37
- })]
38
- });
39
- }
@@ -1 +0,0 @@
1
- export { WhatsAppChatHeader } from './WhatsAppChatHeader';
@@ -1 +0,0 @@
1
- export { WhatsAppChatHeader } from './WhatsAppChatHeader';