@pushwoosh/dumb-components 4.5.1 → 4.6.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.
Files changed (133) hide show
  1. package/ChatPreview/ChatPreview.d.ts +4 -0
  2. package/ChatPreview/ChatPreview.js +65 -0
  3. package/ChatPreview/components/ChatCardView/ChatCardView.d.ts +4 -0
  4. package/ChatPreview/components/ChatCardView/ChatCardView.js +61 -0
  5. package/ChatPreview/components/ChatCardView/index.d.ts +1 -0
  6. package/ChatPreview/components/ChatCardView/index.js +1 -0
  7. package/ChatPreview/components/ChatCardView/styles.d.ts +24 -0
  8. package/ChatPreview/components/ChatCardView/styles.js +40 -0
  9. package/ChatPreview/components/ChatCardView/types.d.ts +15 -0
  10. package/ChatPreview/components/ChatMediaView/ChatMediaView.d.ts +4 -0
  11. package/ChatPreview/components/ChatMediaView/ChatMediaView.js +49 -0
  12. package/ChatPreview/components/ChatMediaView/index.d.ts +1 -0
  13. package/ChatPreview/components/ChatMediaView/index.js +1 -0
  14. package/ChatPreview/components/ChatMediaView/styles.d.ts +13 -0
  15. package/ChatPreview/components/ChatMediaView/styles.js +18 -0
  16. package/ChatPreview/components/ChatMediaView/types.d.ts +8 -0
  17. package/ChatPreview/components/ChatMediaView/types.js +1 -0
  18. package/ChatPreview/components/ChatText/ChatText.d.ts +4 -0
  19. package/ChatPreview/components/ChatText/ChatText.js +18 -0
  20. package/ChatPreview/components/ChatText/index.d.ts +1 -0
  21. package/ChatPreview/components/ChatText/index.js +1 -0
  22. package/ChatPreview/components/ChatText/types.d.ts +8 -0
  23. package/ChatPreview/components/ChatText/types.js +1 -0
  24. package/ChatPreview/components/Deliverable/Deliverable.d.ts +4 -0
  25. package/ChatPreview/components/Deliverable/Deliverable.js +25 -0
  26. package/ChatPreview/components/Deliverable/index.d.ts +1 -0
  27. package/ChatPreview/components/Deliverable/index.js +1 -0
  28. package/ChatPreview/components/Deliverable/styles.d.ts +6 -0
  29. package/ChatPreview/components/Deliverable/styles.js +10 -0
  30. package/ChatPreview/components/Deliverable/types.d.ts +8 -0
  31. package/ChatPreview/components/Deliverable/types.js +1 -0
  32. package/ChatPreview/components/ListSheet/ListSheet.d.ts +4 -0
  33. package/ChatPreview/components/ListSheet/ListSheet.js +27 -0
  34. package/ChatPreview/components/ListSheet/index.d.ts +1 -0
  35. package/ChatPreview/components/ListSheet/index.js +1 -0
  36. package/ChatPreview/components/ListSheet/styles.d.ts +13 -0
  37. package/ChatPreview/components/ListSheet/styles.js +20 -0
  38. package/ChatPreview/components/ListSheet/types.d.ts +9 -0
  39. package/ChatPreview/components/ListSheet/types.js +1 -0
  40. package/ChatPreview/components/MessageBubble/MessageBubble.d.ts +4 -0
  41. package/ChatPreview/components/MessageBubble/MessageBubble.js +67 -0
  42. package/ChatPreview/components/MessageBubble/index.d.ts +1 -0
  43. package/ChatPreview/components/MessageBubble/index.js +1 -0
  44. package/ChatPreview/components/MessageBubble/styles.d.ts +7 -0
  45. package/ChatPreview/components/MessageBubble/styles.js +11 -0
  46. package/ChatPreview/components/MessageBubble/types.d.ts +3 -0
  47. package/ChatPreview/components/MessageBubble/types.js +1 -0
  48. package/ChatPreview/components/NativeMessage/NativeMessage.d.ts +4 -0
  49. package/ChatPreview/components/NativeMessage/NativeMessage.js +55 -0
  50. package/ChatPreview/components/NativeMessage/index.d.ts +1 -0
  51. package/ChatPreview/components/NativeMessage/index.js +1 -0
  52. package/ChatPreview/components/NativeMessage/styles.d.ts +6 -0
  53. package/ChatPreview/components/NativeMessage/styles.js +11 -0
  54. package/ChatPreview/components/NativeMessage/types.d.ts +7 -0
  55. package/ChatPreview/components/NativeMessage/types.js +1 -0
  56. package/ChatPreview/components/ReplyChips/ReplyChips.d.ts +4 -0
  57. package/ChatPreview/components/ReplyChips/ReplyChips.js +18 -0
  58. package/ChatPreview/components/ReplyChips/index.d.ts +1 -0
  59. package/ChatPreview/components/ReplyChips/index.js +1 -0
  60. package/ChatPreview/components/ReplyChips/styles.d.ts +7 -0
  61. package/ChatPreview/components/ReplyChips/styles.js +15 -0
  62. package/ChatPreview/components/ReplyChips/types.d.ts +3 -0
  63. package/ChatPreview/components/ReplyChips/types.js +1 -0
  64. package/ChatPreview/components/StatusNotice/StatusNotice.d.ts +4 -0
  65. package/ChatPreview/components/StatusNotice/StatusNotice.js +44 -0
  66. package/ChatPreview/components/StatusNotice/index.d.ts +2 -0
  67. package/ChatPreview/components/StatusNotice/index.js +2 -0
  68. package/ChatPreview/components/StatusNotice/styles.d.ts +15 -0
  69. package/ChatPreview/components/StatusNotice/styles.js +22 -0
  70. package/ChatPreview/components/StatusNotice/types.d.ts +9 -0
  71. package/ChatPreview/components/StatusNotice/types.js +1 -0
  72. package/ChatPreview/components/index.d.ts +4 -0
  73. package/ChatPreview/components/index.js +3 -0
  74. package/ChatPreview/components/types.d.ts +13 -0
  75. package/ChatPreview/components/types.js +1 -0
  76. package/ChatPreview/constants.d.ts +47 -0
  77. package/ChatPreview/constants.js +89 -0
  78. package/ChatPreview/helpers.d.ts +22 -0
  79. package/ChatPreview/helpers.js +57 -0
  80. package/ChatPreview/index.d.ts +2 -0
  81. package/ChatPreview/index.js +1 -0
  82. package/ChatPreview/polyglot/index.d.ts +2 -0
  83. package/ChatPreview/polyglot/index.js +34 -0
  84. package/ChatPreview/polyglot/messages_ar.d.ts +3 -0
  85. package/ChatPreview/polyglot/messages_ar.js +14 -0
  86. package/ChatPreview/polyglot/messages_bn.d.ts +3 -0
  87. package/ChatPreview/polyglot/messages_bn.js +14 -0
  88. package/ChatPreview/polyglot/messages_de.d.ts +3 -0
  89. package/ChatPreview/polyglot/messages_de.js +14 -0
  90. package/ChatPreview/polyglot/messages_en.d.ts +3 -0
  91. package/ChatPreview/polyglot/messages_en.js +14 -0
  92. package/ChatPreview/polyglot/messages_es.d.ts +3 -0
  93. package/ChatPreview/polyglot/messages_es.js +14 -0
  94. package/ChatPreview/polyglot/messages_fr.d.ts +3 -0
  95. package/ChatPreview/polyglot/messages_fr.js +14 -0
  96. package/ChatPreview/polyglot/messages_he.d.ts +3 -0
  97. package/ChatPreview/polyglot/messages_he.js +14 -0
  98. package/ChatPreview/polyglot/messages_hi.d.ts +3 -0
  99. package/ChatPreview/polyglot/messages_hi.js +14 -0
  100. package/ChatPreview/polyglot/messages_ja.d.ts +3 -0
  101. package/ChatPreview/polyglot/messages_ja.js +14 -0
  102. package/ChatPreview/polyglot/messages_ko.d.ts +3 -0
  103. package/ChatPreview/polyglot/messages_ko.js +14 -0
  104. package/ChatPreview/polyglot/messages_pt.d.ts +3 -0
  105. package/ChatPreview/polyglot/messages_pt.js +14 -0
  106. package/ChatPreview/polyglot/messages_ru.d.ts +3 -0
  107. package/ChatPreview/polyglot/messages_ru.js +14 -0
  108. package/ChatPreview/polyglot/messages_th.d.ts +3 -0
  109. package/ChatPreview/polyglot/messages_th.js +14 -0
  110. package/ChatPreview/polyglot/messages_zh.d.ts +3 -0
  111. package/ChatPreview/polyglot/messages_zh.js +14 -0
  112. package/ChatPreview/polyglot/types.d.ts +17 -0
  113. package/ChatPreview/polyglot/types.js +1 -0
  114. package/ChatPreview/styles.d.ts +33 -0
  115. package/ChatPreview/styles.js +54 -0
  116. package/ChatPreview/types.d.ts +134 -0
  117. package/ChatPreview/types.js +1 -0
  118. package/WhatsAppPreview/components/WhatsAppMessageContent/WhatsAppMessageContent.js +1 -1
  119. package/WhatsAppPreview/helpers.d.ts +0 -3
  120. package/WhatsAppPreview/helpers.js +0 -56
  121. package/index.d.ts +2 -0
  122. package/index.js +1 -0
  123. package/package.json +1 -1
  124. package/{WhatsAppPreview/components/WhatsAppFormattedText → shared/whatsAppMarkup}/WhatsAppFormattedText.js +2 -2
  125. package/shared/whatsAppMarkup/index.d.ts +3 -0
  126. package/{WhatsAppPreview/components/WhatsAppFormattedText/index.d.ts → shared/whatsAppMarkup/index.js} +1 -0
  127. package/shared/whatsAppMarkup/parse.d.ts +3 -0
  128. package/shared/whatsAppMarkup/parse.js +56 -0
  129. package/shared/whatsAppMarkup/types.js +1 -0
  130. package/WhatsAppPreview/components/WhatsAppFormattedText/index.js +0 -1
  131. /package/{WhatsAppPreview/components/WhatsAppFormattedText → ChatPreview/components/ChatCardView}/types.js +0 -0
  132. /package/{WhatsAppPreview/components/WhatsAppFormattedText → shared/whatsAppMarkup}/WhatsAppFormattedText.d.ts +0 -0
  133. /package/{WhatsAppPreview/components/WhatsAppFormattedText → shared/whatsAppMarkup}/types.d.ts +0 -0
@@ -0,0 +1,4 @@
1
+ import { type ReactElement } from 'react';
2
+ import type { ChatPreviewProps } from './types';
3
+ /** Renders a rich chat message the way the recipient sees it in RCS, WhatsApp, Messenger or LINE. */
4
+ export declare function ChatPreview(props: ChatPreviewProps): ReactElement;
@@ -0,0 +1,65 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { PlatformLogoIcon } from '@pushwoosh/kit-icons';
3
+ import { ChatText, NativeMessage, NoFallback, StatusNotice } from './components';
4
+ import { CHAT_CHANNELS } from './constants';
5
+ import { droppedPathsOf, errorsOf, fallbackTextOf, hasNativeContent, viewOf } from './helpers';
6
+ import { Lang } from './polyglot';
7
+ import { BlockedMessage, Bubble, EmptyText, Header, Screen, Thread } from './styles';
8
+ /** Renders a rich chat message the way the recipient sees it in RCS, WhatsApp, Messenger or LINE. */
9
+ export function ChatPreview(props) {
10
+ const {
11
+ channel,
12
+ content,
13
+ status,
14
+ issues,
15
+ senderName
16
+ } = props;
17
+ const look = CHAT_CHANNELS[channel];
18
+ const view = viewOf(channel, status);
19
+ const dropped = droppedPathsOf(issues);
20
+ const fallbackText = fallbackTextOf(content);
21
+ const drawable = view === 'fallback' ? Boolean(fallbackText) : hasNativeContent(content);
22
+ const native = _jsx(NativeMessage, {
23
+ channel: channel,
24
+ content: content,
25
+ dropped: dropped,
26
+ look: look,
27
+ rcs: channel === 'rcs' ? content.rcs : undefined
28
+ });
29
+ return _jsxs(Screen, {
30
+ "$skin": look.skin,
31
+ "data-channel": channel,
32
+ children: [_jsxs(Header, {
33
+ "$skin": look.skin,
34
+ children: [_jsx(PlatformLogoIcon, {
35
+ size: "medium",
36
+ type: look.icon
37
+ }), senderName ?? _jsx(Lang, {
38
+ message: "DUMB.CHAT_PREVIEW.SENDER"
39
+ })]
40
+ }), _jsxs(Thread, {
41
+ "data-view": view,
42
+ children: [view !== 'native' && _jsx(StatusNotice, {
43
+ errors: errorsOf(issues),
44
+ view: view
45
+ }), view === 'fallback' && !drawable && _jsx(NoFallback, {
46
+ children: _jsx(Lang, {
47
+ message: "DUMB.CHAT_PREVIEW.NO_FALLBACK"
48
+ })
49
+ }), view !== 'fallback' && !drawable && _jsx(EmptyText, {
50
+ children: _jsx(Lang, {
51
+ message: "DUMB.CHAT_PREVIEW.EMPTY"
52
+ })
53
+ }), drawable && view === 'fallback' && _jsx(Bubble, {
54
+ "$skin": look.skin,
55
+ children: _jsx(ChatText, {
56
+ markup: look.markup,
57
+ text: fallbackText
58
+ })
59
+ }), drawable && (view === 'native' || view === 'session') && native, drawable && view === 'blocked' && _jsx(BlockedMessage, {
60
+ "data-testid": "chat-blocked",
61
+ children: native
62
+ })]
63
+ })]
64
+ });
65
+ }
@@ -0,0 +1,4 @@
1
+ import { type ReactElement } from 'react';
2
+ import type { ChatCardViewProps } from './types';
3
+ /** One rich card: media, title, text and footer, buttons at the bottom; RCS honours its card layout. */
4
+ export declare function ChatCardView(props: ChatCardViewProps): ReactElement;
@@ -0,0 +1,61 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { CardBody, CardButton, CardButtons, CardFrame, CardTitle, Thumbnail } from './styles';
3
+ import { RCS_MEDIA_HEIGHT } from '../../constants';
4
+ import { rcsLayoutOf } from '../../helpers';
5
+ import { Footer } from '../../styles';
6
+ import { ChatMediaView } from '../ChatMediaView';
7
+ import { ChatText } from '../ChatText';
8
+ import { Deliverable } from '../Deliverable';
9
+ /** One rich card: media, title, text and footer, buttons at the bottom; RCS honours its card layout. */
10
+ export function ChatCardView(props) {
11
+ const {
12
+ card,
13
+ look,
14
+ rcs,
15
+ path,
16
+ dropped
17
+ } = props;
18
+ const layout = rcs ? rcsLayoutOf(rcs) : null;
19
+ const horizontal = layout?.orientation === 'HORIZONTAL';
20
+ const mediaHeight = layout && !horizontal ? RCS_MEDIA_HEIGHT[layout.height] : undefined;
21
+ const isDropped = field => dropped.has(`${path}.${field}`);
22
+ return _jsxs(CardFrame, {
23
+ "$horizontal": horizontal,
24
+ "$skin": look.skin,
25
+ "$thumbnailRight": layout?.thumbnailAlignment === 'RIGHT',
26
+ "data-orientation": layout?.orientation,
27
+ "data-testid": "chat-card",
28
+ children: [card.media && _jsx(Thumbnail, {
29
+ "$horizontal": horizontal,
30
+ children: _jsx(ChatMediaView, {
31
+ height: mediaHeight,
32
+ media: card.media
33
+ })
34
+ }), (card.title || card.body || card.footer) && _jsxs(CardBody, {
35
+ children: [card.title && _jsx(Deliverable, {
36
+ dropped: isDropped('title'),
37
+ children: _jsx(CardTitle, {
38
+ children: _jsx(ChatText, {
39
+ markup: look.markup,
40
+ text: card.title
41
+ })
42
+ })
43
+ }), card.body && _jsx("div", {
44
+ children: _jsx(ChatText, {
45
+ markup: look.markup,
46
+ text: card.body
47
+ })
48
+ }), card.footer && _jsx(Deliverable, {
49
+ dropped: isDropped('footer'),
50
+ children: _jsx(Footer, {
51
+ children: card.footer
52
+ })
53
+ })]
54
+ }), Boolean(card.buttons?.length) && _jsx(CardButtons, {
55
+ children: card.buttons?.map(button => _jsx(CardButton, {
56
+ "$skin": look.skin,
57
+ children: button.title
58
+ }, button.id))
59
+ })]
60
+ });
61
+ }
@@ -0,0 +1 @@
1
+ export { ChatCardView } from './ChatCardView';
@@ -0,0 +1 @@
1
+ export { ChatCardView } from './ChatCardView';
@@ -0,0 +1,24 @@
1
+ import { type Skinned } from '../../styles';
2
+ export declare const CardFrame: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Merged<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
3
+ style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
4
+ }, Skinned & {
5
+ $horizontal: boolean;
6
+ $thumbnailRight: boolean;
7
+ }>> & string;
8
+ export declare const Thumbnail: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Merged<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
9
+ style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
10
+ }, {
11
+ $horizontal: boolean;
12
+ }>> & string;
13
+ export declare const CardBody: import("styled-components/dist/types").IStyledComponentBase<"web", Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
14
+ style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
15
+ }> & string;
16
+ export declare const CardTitle: import("styled-components/dist/types").IStyledComponentBase<"web", Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
17
+ style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
18
+ }> & string;
19
+ export declare const CardButtons: import("styled-components/dist/types").IStyledComponentBase<"web", Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
20
+ style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
21
+ }> & string;
22
+ export declare const CardButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Merged<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
23
+ style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
24
+ }, Skinned>> & string;
@@ -0,0 +1,40 @@
1
+ import styled from 'styled-components';
2
+ import { Color, FontWeight } from '@pushwoosh/kit-constants';
3
+ import { CHAT_BUBBLE_PADDING, CHAT_CARD_WIDTH, RCS_THUMBNAIL_SHARE } from '../../constants';
4
+ import { action, surface } from '../../styles';
5
+ export const CardFrame = styled.div.withConfig({
6
+ displayName: "CardFrame",
7
+ componentId: "sc-19fjpk-0"
8
+ })(["", " flex:0 0 auto;flex-direction:", ";flex-wrap:", ";width:", "px;border:1px solid ", ";"], surface, ({
9
+ $horizontal,
10
+ $thumbnailRight
11
+ }) => {
12
+ if (!$horizontal) {
13
+ return 'column';
14
+ }
15
+ return $thumbnailRight ? 'row-reverse' : 'row';
16
+ }, ({
17
+ $horizontal
18
+ }) => $horizontal ? 'wrap' : 'nowrap', CHAT_CARD_WIDTH, Color.DIVIDER);
19
+ export const Thumbnail = styled.div.withConfig({
20
+ displayName: "Thumbnail",
21
+ componentId: "sc-19fjpk-1"
22
+ })(["flex:0 0 ", ";"], ({
23
+ $horizontal
24
+ }) => $horizontal ? `${RCS_THUMBNAIL_SHARE * 100}%` : 'auto');
25
+ export const CardBody = styled.div.withConfig({
26
+ displayName: "CardBody",
27
+ componentId: "sc-19fjpk-2"
28
+ })(["display:flex;flex:1 1 0;flex-direction:column;gap:4px;min-width:0;padding:", "px ", "px;"], CHAT_BUBBLE_PADDING.vertical, CHAT_BUBBLE_PADDING.horizontal);
29
+ export const CardTitle = styled.div.withConfig({
30
+ displayName: "CardTitle",
31
+ componentId: "sc-19fjpk-3"
32
+ })(["font-weight:", ";"], FontWeight.BOLD);
33
+ export const CardButtons = styled.div.withConfig({
34
+ displayName: "CardButtons",
35
+ componentId: "sc-19fjpk-4"
36
+ })(["flex:1 0 100%;"]);
37
+ export const CardButton = styled.div.withConfig({
38
+ displayName: "CardButton",
39
+ componentId: "sc-19fjpk-5"
40
+ })(["", " border-top-color:", ";"], action, Color.DIVIDER);
@@ -0,0 +1,15 @@
1
+ import type { ChatChannelLook } from '../../constants';
2
+ import type { ChatCard, ChatRcsLayout } from '../../types';
3
+ /** Props of {@link ChatCardView}. */
4
+ export type ChatCardViewProps = {
5
+ /** Card to draw. */
6
+ card: ChatCard;
7
+ /** Look of the channel. */
8
+ look: ChatChannelLook;
9
+ /** RCS layout; set only for RCS, the other chats have one card shape. */
10
+ rcs?: ChatRcsLayout;
11
+ /** Content path of the card, e.g. `cards[1]`. */
12
+ path: string;
13
+ /** Content paths the channel drops. */
14
+ dropped: Set<string>;
15
+ };
@@ -0,0 +1,4 @@
1
+ import { type ReactElement } from 'react';
2
+ import type { ChatMediaViewProps } from './types';
3
+ /** Draws an image, a video poster, a document or an audio row. */
4
+ export declare function ChatMediaView(props: ChatMediaViewProps): ReactElement;
@@ -0,0 +1,49 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { AttachmentIcon, DocumentIcon, PlayRoundIcon } from '@pushwoosh/kit-icons';
3
+ import { FileRow, MediaImage, MediaPlaceholder } from './styles';
4
+ import { DynamicContentText } from '../../../shared/dynamicContent';
5
+ import { CHAT_MEDIA_HEIGHT } from '../../constants';
6
+ import { Lang, useLang } from '../../polyglot';
7
+ const hasToken = url => url.includes('{');
8
+ /** Draws an image, a video poster, a document or an audio row. */
9
+ export function ChatMediaView(props) {
10
+ const {
11
+ media,
12
+ height = CHAT_MEDIA_HEIGHT
13
+ } = props;
14
+ const lang = useLang();
15
+ if (media.kind === 'document' || media.kind === 'audio') {
16
+ return _jsxs(FileRow, {
17
+ children: [media.kind === 'document' ? _jsx(DocumentIcon, {
18
+ size: "medium",
19
+ view: "lined"
20
+ }) : _jsx(AttachmentIcon, {
21
+ size: "medium",
22
+ view: "lined"
23
+ }), _jsx(Lang, {
24
+ message: media.kind === 'document' ? 'DUMB.CHAT_PREVIEW.DOCUMENT' : 'DUMB.CHAT_PREVIEW.AUDIO'
25
+ })]
26
+ });
27
+ }
28
+ const poster = media.kind === 'video' ? media.preview_url : media.url;
29
+ if (!poster || hasToken(poster)) {
30
+ return _jsx(MediaPlaceholder, {
31
+ "$height": height,
32
+ "data-testid": "chat-media",
33
+ children: media.kind === 'video' ? _jsx(PlayRoundIcon, {
34
+ size: "medium",
35
+ view: "filled"
36
+ }) : _jsx(DynamicContentText, {
37
+ children: media.url
38
+ })
39
+ });
40
+ }
41
+ return _jsx(MediaImage, {
42
+ "$height": height,
43
+ alt: lang({
44
+ message: 'DUMB.CHAT_PREVIEW.IMAGE_ALT'
45
+ }),
46
+ "data-testid": "chat-media",
47
+ src: poster
48
+ });
49
+ }
@@ -0,0 +1 @@
1
+ export { ChatMediaView } from './ChatMediaView';
@@ -0,0 +1 @@
1
+ export { ChatMediaView } from './ChatMediaView';
@@ -0,0 +1,13 @@
1
+ type Sized = {
2
+ $height: number;
3
+ };
4
+ export declare const MediaImage: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Merged<Omit<import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "style"> & {
5
+ style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
6
+ }, Sized>> & string;
7
+ export declare const MediaPlaceholder: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Merged<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
8
+ style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
9
+ }, Sized>> & string;
10
+ export declare const FileRow: import("styled-components/dist/types").IStyledComponentBase<"web", Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
11
+ style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
12
+ }> & string;
13
+ export {};
@@ -0,0 +1,18 @@
1
+ import styled, { css } from 'styled-components';
2
+ import { Color, FontSize, ShapeRadius } from '@pushwoosh/kit-constants';
3
+ import { CHAT_GAP } from '../../constants';
4
+ const mediaBox = css(["display:flex;flex:0 0 auto;align-items:center;justify-content:center;width:100%;height:", "px;border-radius:", ";object-fit:cover;background:", ";color:", ";font-size:", ";"], ({
5
+ $height
6
+ }) => $height, ShapeRadius.SECTION, Color.SOFT_LIGHT, Color.LOCKED, FontSize.SMALL);
7
+ export const MediaImage = styled.img.withConfig({
8
+ displayName: "MediaImage",
9
+ componentId: "sc-17o40y-0"
10
+ })(["", ""], mediaBox);
11
+ export const MediaPlaceholder = styled.div.withConfig({
12
+ displayName: "MediaPlaceholder",
13
+ componentId: "sc-17o40y-1"
14
+ })(["", ""], mediaBox);
15
+ export const FileRow = styled.div.withConfig({
16
+ displayName: "FileRow",
17
+ componentId: "sc-17o40y-2"
18
+ })(["display:flex;gap:", "px;align-items:center;padding:", "px;border-radius:", ";background:", ";font-size:", ";"], CHAT_GAP, CHAT_GAP, ShapeRadius.SECTION, Color.SOFT_LIGHT, FontSize.SMALL);
@@ -0,0 +1,8 @@
1
+ import type { ChatMedia } from '../../types';
2
+ /** Props of {@link ChatMediaView}. */
3
+ export type ChatMediaViewProps = {
4
+ /** Media to draw. */
5
+ media: ChatMedia;
6
+ /** Frame height in px; the default chat media height when omitted. */
7
+ height?: number;
8
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import { type ReactElement } from 'react';
2
+ import type { ChatTextProps } from './types';
3
+ /** Message text with personalization tokens as chips; WhatsApp markup is applied on WhatsApp. */
4
+ export declare function ChatText(props: ChatTextProps): ReactElement;
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { DynamicContentText } from '../../../shared/dynamicContent';
3
+ import { WhatsAppFormattedText } from '../../../shared/whatsAppMarkup';
4
+ /** Message text with personalization tokens as chips; WhatsApp markup is applied on WhatsApp. */
5
+ export function ChatText(props) {
6
+ const {
7
+ markup,
8
+ text
9
+ } = props;
10
+ if (markup === 'whatsapp') {
11
+ return _jsx(WhatsAppFormattedText, {
12
+ text: text
13
+ });
14
+ }
15
+ return _jsx(DynamicContentText, {
16
+ children: text
17
+ });
18
+ }
@@ -0,0 +1 @@
1
+ export { ChatText } from './ChatText';
@@ -0,0 +1 @@
1
+ export { ChatText } from './ChatText';
@@ -0,0 +1,8 @@
1
+ import type { ChatChannelLook } from '../../constants';
2
+ /** Props of {@link ChatText}. */
3
+ export type ChatTextProps = {
4
+ /** Markup rules of the channel. */
5
+ markup: ChatChannelLook['markup'];
6
+ /** Text with personalization tokens. */
7
+ text: string;
8
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import { type ReactElement } from 'react';
2
+ import type { DeliverableProps } from './types';
3
+ /** Draws a field as is, or dimmed with a "not delivered" mark when the channel drops it. */
4
+ export declare function Deliverable(props: DeliverableProps): ReactElement;
@@ -0,0 +1,25 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { DroppedField, DroppedTag } from './styles';
3
+ import { Lang } from '../../polyglot';
4
+ /** Draws a field as is, or dimmed with a "not delivered" mark when the channel drops it. */
5
+ export function Deliverable(props) {
6
+ const {
7
+ dropped,
8
+ children
9
+ } = props;
10
+ if (!dropped) {
11
+ return _jsx(_Fragment, {
12
+ children: children
13
+ });
14
+ }
15
+ return _jsxs("div", {
16
+ "data-dropped": "true",
17
+ children: [_jsx(DroppedField, {
18
+ children: children
19
+ }), _jsx(DroppedTag, {
20
+ children: _jsx(Lang, {
21
+ message: "DUMB.CHAT_PREVIEW.NOT_DELIVERED"
22
+ })
23
+ })]
24
+ });
25
+ }
@@ -0,0 +1 @@
1
+ export { Deliverable } from './Deliverable';
@@ -0,0 +1 @@
1
+ export { Deliverable } from './Deliverable';
@@ -0,0 +1,6 @@
1
+ export declare const DroppedField: import("styled-components/dist/types").IStyledComponentBase<"web", Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
2
+ style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
3
+ }> & string;
4
+ export declare const DroppedTag: import("styled-components/dist/types").IStyledComponentBase<"web", Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
5
+ style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
6
+ }> & string;
@@ -0,0 +1,10 @@
1
+ import styled from 'styled-components';
2
+ import { Color, FontSize, FontWeight } from '@pushwoosh/kit-constants';
3
+ export const DroppedField = styled.div.withConfig({
4
+ displayName: "DroppedField",
5
+ componentId: "sc-rsezkh-0"
6
+ })(["opacity:0.45;text-decoration:line-through;"]);
7
+ export const DroppedTag = styled.div.withConfig({
8
+ displayName: "DroppedTag",
9
+ componentId: "sc-rsezkh-1"
10
+ })(["color:", ";font-size:", ";font-weight:", ";text-decoration:none;"], Color.WARNING, FontSize.SMALL, FontWeight.MEDIUM);
@@ -0,0 +1,8 @@
1
+ import type { ReactNode } from 'react';
2
+ /** Props of {@link Deliverable}. */
3
+ export type DeliverableProps = {
4
+ /** The channel drops this field. */
5
+ dropped: boolean;
6
+ /** The field as drawn. */
7
+ children: ReactNode;
8
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import { type ReactElement } from 'react';
2
+ import type { ListSheetProps } from './types';
3
+ /** Rows of a list picker as the recipient sees them after tapping the list button. */
4
+ export declare function ListSheet(props: ListSheetProps): ReactElement | null;
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Row, RowDescription, RowTitle, Sheet } from './styles';
3
+ import { ChatText } from '../ChatText';
4
+ /** Rows of a list picker as the recipient sees them after tapping the list button. */
5
+ export function ListSheet(props) {
6
+ const {
7
+ list,
8
+ look
9
+ } = props;
10
+ if (!list.items.length) {
11
+ return null;
12
+ }
13
+ return _jsx(Sheet, {
14
+ "$skin": look.skin,
15
+ "data-testid": "chat-list-sheet",
16
+ children: list.items.map(item => _jsxs(Row, {
17
+ children: [_jsx(RowTitle, {
18
+ children: _jsx(ChatText, {
19
+ markup: look.markup,
20
+ text: item.title
21
+ })
22
+ }), item.description && _jsx(RowDescription, {
23
+ children: item.description
24
+ })]
25
+ }, item.id))
26
+ });
27
+ }
@@ -0,0 +1 @@
1
+ export { ListSheet } from './ListSheet';
@@ -0,0 +1 @@
1
+ export { ListSheet } from './ListSheet';
@@ -0,0 +1,13 @@
1
+ import { type Skinned } from '../../styles';
2
+ export declare const Sheet: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Merged<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
3
+ style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
4
+ }, Skinned>> & string;
5
+ export declare const Row: import("styled-components/dist/types").IStyledComponentBase<"web", Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
6
+ style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
7
+ }> & string;
8
+ export declare const RowTitle: import("styled-components/dist/types").IStyledComponentBase<"web", Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
9
+ style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
10
+ }> & string;
11
+ export declare const RowDescription: import("styled-components/dist/types").IStyledComponentBase<"web", Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
12
+ style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
13
+ }> & string;
@@ -0,0 +1,20 @@
1
+ import styled from 'styled-components';
2
+ import { Color, FontSize, FontWeight } from '@pushwoosh/kit-constants';
3
+ import { CHAT_BUBBLE_MAX_WIDTH, CHAT_BUBBLE_PADDING } from '../../constants';
4
+ import { surface } from '../../styles';
5
+ export const Sheet = styled.div.withConfig({
6
+ displayName: "Sheet",
7
+ componentId: "sc-1aa4x11-0"
8
+ })(["", " width:", "px;"], surface, CHAT_BUBBLE_MAX_WIDTH);
9
+ export const Row = styled.div.withConfig({
10
+ displayName: "Row",
11
+ componentId: "sc-1aa4x11-1"
12
+ })(["padding:", "px ", "px;& + &{border-top:1px solid ", ";}"], CHAT_BUBBLE_PADDING.vertical, CHAT_BUBBLE_PADDING.horizontal, Color.DIVIDER);
13
+ export const RowTitle = styled.div.withConfig({
14
+ displayName: "RowTitle",
15
+ componentId: "sc-1aa4x11-2"
16
+ })(["font-weight:", ";"], FontWeight.MEDIUM);
17
+ export const RowDescription = styled.div.withConfig({
18
+ displayName: "RowDescription",
19
+ componentId: "sc-1aa4x11-3"
20
+ })(["color:", ";font-size:", ";"], Color.LOCKED, FontSize.SMALL);
@@ -0,0 +1,9 @@
1
+ import type { ChatChannelLook } from '../../constants';
2
+ import type { ChatList } from '../../types';
3
+ /** Props of {@link ListSheet}. */
4
+ export type ListSheetProps = {
5
+ /** List whose rows are drawn. */
6
+ list: ChatList;
7
+ /** Look of the channel. */
8
+ look: ChatChannelLook;
9
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import { type ReactElement } from 'react';
2
+ import type { MessageBubbleProps } from './types';
3
+ /** The text bubble: header, media, body and footer, with in-bubble buttons and the list button. */
4
+ export declare function MessageBubble(props: MessageBubbleProps): ReactElement | null;
@@ -0,0 +1,67 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ListIcon } from '@pushwoosh/kit-icons';
3
+ import { InlineButton, InlineButtons } from './styles';
4
+ import { bubbleButtonsOf } from '../../helpers';
5
+ import { Bubble, Footer, HeaderText } from '../../styles';
6
+ import { ChatMediaView } from '../ChatMediaView';
7
+ import { ChatText } from '../ChatText';
8
+ import { Deliverable } from '../Deliverable';
9
+ /** The text bubble: header, media, body and footer, with in-bubble buttons and the list button. */
10
+ export function MessageBubble(props) {
11
+ const {
12
+ content,
13
+ look,
14
+ dropped
15
+ } = props;
16
+ const inlineButtons = look.repliesInsideBubble || content.type === 'call_to_action' ? bubbleButtonsOf(content) : [];
17
+ const headerMedia = content.header?.media?.url ? content.header.media : undefined;
18
+ const media = content.type === 'media' && content.media?.url ? content.media : undefined;
19
+ const headerText = headerMedia ? undefined : content.header?.text;
20
+ const hasText = Boolean(headerText || content.body || content.footer);
21
+ if (!media && !headerMedia && !hasText && !inlineButtons.length && !content.list) {
22
+ return null;
23
+ }
24
+ return _jsxs(Bubble, {
25
+ "$skin": look.skin,
26
+ children: [headerMedia && _jsx(Deliverable, {
27
+ dropped: dropped.has('header'),
28
+ children: _jsx(ChatMediaView, {
29
+ media: headerMedia
30
+ })
31
+ }), media && _jsx(ChatMediaView, {
32
+ media: media
33
+ }), headerText && _jsx(Deliverable, {
34
+ dropped: dropped.has('header'),
35
+ children: _jsx(HeaderText, {
36
+ children: _jsx(ChatText, {
37
+ markup: look.markup,
38
+ text: headerText
39
+ })
40
+ })
41
+ }), content.body && _jsx(Deliverable, {
42
+ dropped: dropped.has('body'),
43
+ children: _jsx("div", {
44
+ children: _jsx(ChatText, {
45
+ markup: look.markup,
46
+ text: content.body
47
+ })
48
+ })
49
+ }), content.footer && _jsx(Deliverable, {
50
+ dropped: dropped.has('footer'),
51
+ children: _jsx(Footer, {
52
+ children: content.footer
53
+ })
54
+ }), (inlineButtons.length > 0 || content.list) && _jsxs(InlineButtons, {
55
+ children: [inlineButtons.map(button => _jsx(InlineButton, {
56
+ "$skin": look.skin,
57
+ children: button.title
58
+ }, button.id)), content.list && _jsxs(InlineButton, {
59
+ "$skin": look.skin,
60
+ children: [_jsx(ListIcon, {
61
+ size: "small",
62
+ view: "lined"
63
+ }), ' ', content.list.button_text]
64
+ })]
65
+ })]
66
+ });
67
+ }
@@ -0,0 +1 @@
1
+ export { MessageBubble } from './MessageBubble';
@@ -0,0 +1 @@
1
+ export { MessageBubble } from './MessageBubble';