@pushwoosh/dumb-components 4.5.1 → 4.7.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 (159) 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/Modal/components/ModalName/ModalName.d.ts +4 -0
  119. package/Modal/components/ModalName/ModalName.js +151 -0
  120. package/Modal/components/ModalName/index.d.ts +2 -0
  121. package/Modal/components/ModalName/index.js +1 -0
  122. package/Modal/components/ModalName/types.d.ts +39 -0
  123. package/Modal/components/ModalName/types.js +1 -0
  124. package/Modal/index.d.ts +1 -0
  125. package/Modal/index.js +1 -0
  126. package/Modal/polyglot/messages_ar.js +1 -0
  127. package/Modal/polyglot/messages_bn.js +1 -0
  128. package/Modal/polyglot/messages_de.js +1 -0
  129. package/Modal/polyglot/messages_en.js +1 -0
  130. package/Modal/polyglot/messages_es.js +1 -0
  131. package/Modal/polyglot/messages_fr.js +1 -0
  132. package/Modal/polyglot/messages_he.js +1 -0
  133. package/Modal/polyglot/messages_hi.js +1 -0
  134. package/Modal/polyglot/messages_ja.js +1 -0
  135. package/Modal/polyglot/messages_ko.js +1 -0
  136. package/Modal/polyglot/messages_pt.js +1 -0
  137. package/Modal/polyglot/messages_ru.js +1 -0
  138. package/Modal/polyglot/messages_th.js +1 -0
  139. package/Modal/polyglot/messages_zh.js +1 -0
  140. package/Modal/polyglot/types.d.ts +1 -0
  141. package/PageHeader/components/Rename/Rename.d.ts +1 -1
  142. package/PageHeader/components/Rename/Rename.js +1 -1
  143. package/WhatsAppPreview/components/WhatsAppMessageContent/WhatsAppMessageContent.js +1 -1
  144. package/WhatsAppPreview/helpers.d.ts +0 -3
  145. package/WhatsAppPreview/helpers.js +0 -56
  146. package/index.d.ts +3 -1
  147. package/index.js +2 -1
  148. package/native/Input.js +3 -1
  149. package/package.json +1 -1
  150. package/{WhatsAppPreview/components/WhatsAppFormattedText → shared/whatsAppMarkup}/WhatsAppFormattedText.js +2 -2
  151. package/shared/whatsAppMarkup/index.d.ts +3 -0
  152. package/{WhatsAppPreview/components/WhatsAppFormattedText/index.d.ts → shared/whatsAppMarkup/index.js} +1 -0
  153. package/shared/whatsAppMarkup/parse.d.ts +3 -0
  154. package/shared/whatsAppMarkup/parse.js +56 -0
  155. package/shared/whatsAppMarkup/types.js +1 -0
  156. package/WhatsAppPreview/components/WhatsAppFormattedText/index.js +0 -1
  157. /package/{WhatsAppPreview/components/WhatsAppFormattedText → ChatPreview/components/ChatCardView}/types.js +0 -0
  158. /package/{WhatsAppPreview/components/WhatsAppFormattedText → shared/whatsAppMarkup}/WhatsAppFormattedText.d.ts +0 -0
  159. /package/{WhatsAppPreview/components/WhatsAppFormattedText → shared/whatsAppMarkup}/types.d.ts +0 -0
@@ -0,0 +1,7 @@
1
+ import { type Skinned } from '../../styles';
2
+ export declare const InlineButtons: import("styled-components/dist/types").IStyledComponentBase<"web", Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
3
+ style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
4
+ }> & string;
5
+ export declare const InlineButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Merged<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
6
+ style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
7
+ }, Skinned>> & string;
@@ -0,0 +1,11 @@
1
+ import styled from 'styled-components';
2
+ import { CHAT_BUBBLE_PADDING } from '../../constants';
3
+ import { action } from '../../styles';
4
+ export const InlineButtons = styled.div.withConfig({
5
+ displayName: "InlineButtons",
6
+ componentId: "sc-1md0nso-0"
7
+ })(["display:flex;flex-direction:column;margin:2px -", "px -", "px;"], CHAT_BUBBLE_PADDING.horizontal, CHAT_BUBBLE_PADDING.vertical);
8
+ export const InlineButton = styled.div.withConfig({
9
+ displayName: "InlineButton",
10
+ componentId: "sc-1md0nso-1"
11
+ })(["", ""], action);
@@ -0,0 +1,3 @@
1
+ import type { ChatPartProps } from '../types';
2
+ /** Props of {@link MessageBubble}. */
3
+ export type MessageBubbleProps = ChatPartProps;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import { type ReactElement } from 'react';
2
+ import type { NativeMessageProps } from './types';
3
+ /** The message drawn the way the channel renders it natively. */
4
+ export declare function NativeMessage(props: NativeMessageProps): ReactElement;
@@ -0,0 +1,55 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { Carousel, FlexBox } from './styles';
3
+ import { cardsOf, fallbackTextOf } from '../../helpers';
4
+ import { Lang } from '../../polyglot';
5
+ import { ChatCardView } from '../ChatCardView';
6
+ import { ChatText } from '../ChatText';
7
+ import { ListSheet } from '../ListSheet';
8
+ import { MessageBubble } from '../MessageBubble';
9
+ import { ReplyChips } from '../ReplyChips';
10
+ /** The message drawn the way the channel renders it natively. */
11
+ export function NativeMessage(props) {
12
+ const {
13
+ channel,
14
+ content,
15
+ look,
16
+ dropped,
17
+ rcs
18
+ } = props;
19
+ const cards = cardsOf(content);
20
+ if (content.type === 'custom_flex') {
21
+ return _jsxs(FlexBox, {
22
+ children: [_jsx("strong", {
23
+ children: _jsx(Lang, {
24
+ message: "DUMB.CHAT_PREVIEW.FLEX"
25
+ })
26
+ }), fallbackTextOf(content) && _jsx(ChatText, {
27
+ markup: look.markup,
28
+ text: fallbackTextOf(content)
29
+ })]
30
+ });
31
+ }
32
+ return _jsxs(_Fragment, {
33
+ children: [content.type !== 'card' && _jsx(MessageBubble, {
34
+ channel: channel,
35
+ content: content,
36
+ dropped: dropped,
37
+ look: look
38
+ }), content.type === 'list_picker' && content.list && _jsx(ListSheet, {
39
+ list: content.list,
40
+ look: look
41
+ }), cards.length > 0 && _jsx(Carousel, {
42
+ "data-testid": "chat-carousel",
43
+ children: cards.map((card, index) => _jsx(ChatCardView, {
44
+ card: card,
45
+ dropped: dropped,
46
+ look: look,
47
+ path: `cards[${String(index)}]`,
48
+ rcs: rcs
49
+ }, `${card.title ?? ''}:${card.media?.url ?? ''}:${String(index)}`))
50
+ }), _jsx(ReplyChips, {
51
+ content: content,
52
+ look: look
53
+ })]
54
+ });
55
+ }
@@ -0,0 +1 @@
1
+ export { NativeMessage } from './NativeMessage';
@@ -0,0 +1 @@
1
+ export { NativeMessage } from './NativeMessage';
@@ -0,0 +1,6 @@
1
+ export declare const Carousel: 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 FlexBox: 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,11 @@
1
+ import styled from 'styled-components';
2
+ import { Color, FontSize } from '@pushwoosh/kit-constants';
3
+ import { CHAT_BUBBLE_RADIUS, CHAT_CARD_WIDTH, CHAT_GAP } from '../../constants';
4
+ export const Carousel = styled.div.withConfig({
5
+ displayName: "Carousel",
6
+ componentId: "sc-1c28n9d-0"
7
+ })(["display:flex;gap:", "px;align-items:flex-start;max-width:100%;padding-bottom:4px;overflow-x:auto;"], CHAT_GAP);
8
+ export const FlexBox = styled.div.withConfig({
9
+ displayName: "FlexBox",
10
+ componentId: "sc-1c28n9d-1"
11
+ })(["display:flex;flex-direction:column;gap:4px;width:", "px;padding:12px;border:1px dashed ", ";border-radius:", "px;background:", ";color:", ";font-size:", ";"], CHAT_CARD_WIDTH, Color.LOCKED, CHAT_BUBBLE_RADIUS, Color.CLEAR, Color.MAIN, FontSize.SMALL);
@@ -0,0 +1,7 @@
1
+ import type { ChatRcsLayout } from '../../types';
2
+ import type { ChatPartProps } from '../types';
3
+ /** Props of {@link NativeMessage}. */
4
+ export type NativeMessageProps = ChatPartProps & {
5
+ /** RCS card layout, passed only on RCS. */
6
+ rcs?: ChatRcsLayout;
7
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import { type ReactElement } from 'react';
2
+ import type { ReplyChipsProps } from './types';
3
+ /** Quick replies drawn as chips under the message, for the chats that do not put them in the bubble. */
4
+ export declare function ReplyChips(props: ReplyChipsProps): ReactElement | null;
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Chip, Chips } from './styles';
3
+ /** Quick replies drawn as chips under the message, for the chats that do not put them in the bubble. */
4
+ export function ReplyChips(props) {
5
+ const {
6
+ content,
7
+ look
8
+ } = props;
9
+ if (content.type !== 'quick_reply' || look.repliesInsideBubble || !content.buttons?.length) {
10
+ return null;
11
+ }
12
+ return _jsx(Chips, {
13
+ children: content.buttons.map(button => _jsx(Chip, {
14
+ "$skin": look.skin,
15
+ children: button.title
16
+ }, button.id))
17
+ });
18
+ }
@@ -0,0 +1 @@
1
+ export { ReplyChips } from './ReplyChips';
@@ -0,0 +1 @@
1
+ export { ReplyChips } from './ReplyChips';
@@ -0,0 +1,7 @@
1
+ import type { Skinned } from '../../styles';
2
+ export declare const Chips: import("styled-components/dist/types").IStyledComponentBase<"web", Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
3
+ style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
4
+ }> & string;
5
+ export declare const Chip: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Merged<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
6
+ style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
7
+ }, Skinned>> & string;
@@ -0,0 +1,15 @@
1
+ import styled from 'styled-components';
2
+ import { Color, FontSize, FontWeight } from '@pushwoosh/kit-constants';
3
+ import { CHAT_CHIP_RADIUS, CHAT_SCREEN_WIDTH, CHAT_SMALL_GAP, CHAT_THREAD_PADDING } from '../../constants';
4
+ export const Chips = styled.div.withConfig({
5
+ displayName: "Chips",
6
+ componentId: "sc-oglekn-0"
7
+ })(["display:flex;flex-wrap:wrap;gap:", "px;max-width:", "px;"], CHAT_SMALL_GAP, CHAT_SCREEN_WIDTH - CHAT_THREAD_PADDING * 2);
8
+ export const Chip = styled.div.withConfig({
9
+ displayName: "Chip",
10
+ componentId: "sc-oglekn-1"
11
+ })(["padding:", "px 12px;border:1px solid ", ";border-radius:", "px;background:", ";color:", ";font-size:", ";font-weight:", ";"], CHAT_SMALL_GAP, ({
12
+ $skin
13
+ }) => $skin.chipBorder, CHAT_CHIP_RADIUS, Color.CLEAR, ({
14
+ $skin
15
+ }) => $skin.accent, FontSize.SMALL, FontWeight.MEDIUM);
@@ -0,0 +1,3 @@
1
+ import type { ChatPartProps } from '../types';
2
+ /** Props of {@link ReplyChips}. */
3
+ export type ReplyChipsProps = Pick<ChatPartProps, 'content' | 'look'>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import { type ReactElement } from 'react';
2
+ import type { StatusNoticeProps } from './types';
3
+ /** Badge over a message the channel does not deliver as drawn; a blocked one lists its errors. */
4
+ export declare function StatusNotice(props: StatusNoticeProps): ReactElement;
@@ -0,0 +1,44 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { IssueLine, Notice, NoticeTitle } from './styles';
3
+ import { CHAT_MAX_LISTED_ISSUES } from '../../constants';
4
+ import { Lang } from '../../polyglot';
5
+ const NOTICE = {
6
+ session: {
7
+ tone: 'warning',
8
+ message: 'DUMB.CHAT_PREVIEW.SESSION_ONLY'
9
+ },
10
+ fallback: {
11
+ tone: 'warning',
12
+ message: 'DUMB.CHAT_PREVIEW.FALLBACK_PARTIAL'
13
+ },
14
+ blocked: {
15
+ tone: 'danger',
16
+ message: 'DUMB.CHAT_PREVIEW.FALLBACK_INCOMPATIBLE'
17
+ }
18
+ };
19
+ /** Badge over a message the channel does not deliver as drawn; a blocked one lists its errors. */
20
+ export function StatusNotice(props) {
21
+ const {
22
+ view,
23
+ errors
24
+ } = props;
25
+ const {
26
+ tone,
27
+ message
28
+ } = NOTICE[view];
29
+ const listed = view === 'blocked' ? errors.slice(0, CHAT_MAX_LISTED_ISSUES) : [];
30
+ return _jsxs(Notice, {
31
+ "$tone": tone,
32
+ "data-testid": "chat-status-notice",
33
+ children: [_jsx(NoticeTitle, {
34
+ children: _jsx(Lang, {
35
+ message: message
36
+ })
37
+ }), listed.map(issue => _jsx(IssueLine, {
38
+ children: issue.path ? `${issue.path}: ${issue.code}` : issue.code
39
+ }, `${issue.path}:${issue.code}`)), errors.length > listed.length && view === 'blocked' && _jsx(Lang, {
40
+ count: errors.length - listed.length,
41
+ message: "DUMB.CHAT_PREVIEW.MORE_ISSUES"
42
+ })]
43
+ });
44
+ }
@@ -0,0 +1,2 @@
1
+ export { StatusNotice } from './StatusNotice';
2
+ export { NoFallback } from './styles';
@@ -0,0 +1,2 @@
1
+ export { StatusNotice } from './StatusNotice';
2
+ export { NoFallback } from './styles';
@@ -0,0 +1,15 @@
1
+ export type NoticeTone = 'warning' | 'danger';
2
+ export declare const Notice: 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
+ }, {
5
+ $tone: NoticeTone;
6
+ }>> & string;
7
+ export declare const NoticeTitle: import("styled-components/dist/types").IStyledComponentBase<"web", Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "style"> & {
8
+ style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
9
+ }> & string;
10
+ export declare const IssueLine: import("styled-components/dist/types").IStyledComponentBase<"web", Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, "style"> & {
11
+ style?: import("react").CSSProperties | import("styled-components/dist/types").CSSPropertiesWithVars | undefined;
12
+ }> & string;
13
+ export declare const NoFallback: 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;
@@ -0,0 +1,22 @@
1
+ import styled from 'styled-components';
2
+ import { Color, FontSize, FontWeight, ShapeRadius } from '@pushwoosh/kit-constants';
3
+ export const Notice = styled.div.withConfig({
4
+ displayName: "Notice",
5
+ componentId: "sc-ifm2q0-0"
6
+ })(["display:flex;flex-direction:column;gap:2px;padding:2px 8px;border-radius:", ";background:", ";color:", ";font-size:", ";"], ShapeRadius.CONTROL, ({
7
+ $tone
8
+ }) => $tone === 'warning' ? Color.WARNING_LIGHT : Color.DANGER_LIGHT, ({
9
+ $tone
10
+ }) => $tone === 'warning' ? Color.WARNING : Color.DANGER, FontSize.SMALL);
11
+ export const NoticeTitle = styled.div.withConfig({
12
+ displayName: "NoticeTitle",
13
+ componentId: "sc-ifm2q0-1"
14
+ })(["font-weight:", ";"], FontWeight.MEDIUM);
15
+ export const IssueLine = styled.code.withConfig({
16
+ displayName: "IssueLine",
17
+ componentId: "sc-ifm2q0-2"
18
+ })(["font-size:", ";"], FontSize.SMALL);
19
+ export const NoFallback = styled.div.withConfig({
20
+ displayName: "NoFallback",
21
+ componentId: "sc-ifm2q0-3"
22
+ })(["color:", ";font-size:", ";font-weight:", ";"], Color.DANGER, FontSize.SMALL, FontWeight.MEDIUM);
@@ -0,0 +1,9 @@
1
+ import type { ChatView } from '../../helpers';
2
+ import type { ChatIssue } from '../../types';
3
+ /** Props of {@link StatusNotice}. */
4
+ export type StatusNoticeProps = {
5
+ /** What the recipient gets. */
6
+ view: Exclude<ChatView, 'native'>;
7
+ /** Validator errors listed under a blocked message. */
8
+ errors: ChatIssue[];
9
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export { NativeMessage } from './NativeMessage';
2
+ export { NoFallback, StatusNotice } from './StatusNotice';
3
+ export { ChatText } from './ChatText';
4
+ export type { ChatPartProps } from './types';
@@ -0,0 +1,3 @@
1
+ export { NativeMessage } from './NativeMessage';
2
+ export { NoFallback, StatusNotice } from './StatusNotice';
3
+ export { ChatText } from './ChatText';
@@ -0,0 +1,13 @@
1
+ import type { ChatChannelLook } from '../constants';
2
+ import type { ChatChannel, ChatContent } from '../types';
3
+ /** What every part of the drawn message needs to know. */
4
+ export type ChatPartProps = {
5
+ /** Channel whose look is replicated. */
6
+ channel: ChatChannel;
7
+ /** Message to draw. */
8
+ content: ChatContent;
9
+ /** Look of the channel. */
10
+ look: ChatChannelLook;
11
+ /** Content paths the channel drops. */
12
+ dropped: Set<string>;
13
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,47 @@
1
+ import type { ChatChannel, ChatRcsHeight, ChatRcsOrientation, ChatRcsThumbnailAlignment } from './types';
2
+ /** Colours of a replicated chat app; they are the channel's, not Pushwoosh design tokens. */
3
+ export type ChatSkin = {
4
+ headerBackground: string;
5
+ headerText: string;
6
+ chatBackground: string;
7
+ bubble: string;
8
+ bubbleText: string;
9
+ accent: string;
10
+ chipBorder: string;
11
+ };
12
+ /** Everything that differs between the replicated chat apps. */
13
+ export type ChatChannelLook = {
14
+ skin: ChatSkin;
15
+ icon: 'sms' | 'whatsapp' | 'messenger' | 'line';
16
+ /** WhatsApp draws quick replies inside the bubble; the other chats draw them as chips under it. */
17
+ repliesInsideBubble: boolean;
18
+ /** WhatsApp applies its `*bold*`/`_italic_` markup; the other chats show the text as typed. */
19
+ markup: 'whatsapp' | 'plain';
20
+ };
21
+ export declare const CHAT_CHANNELS: Record<ChatChannel, ChatChannelLook>;
22
+ export declare const CHAT_SCREEN_WIDTH = 320;
23
+ export declare const CHAT_SCREEN_HEIGHT = 560;
24
+ export declare const CHAT_SCREEN_RADIUS = 24;
25
+ export declare const CHAT_THREAD_PADDING = 12;
26
+ export declare const CHAT_BUBBLE_MAX_WIDTH = 260;
27
+ export declare const CHAT_BUBBLE_RADIUS = 12;
28
+ export declare const CHAT_BUBBLE_PADDING: {
29
+ vertical: number;
30
+ horizontal: number;
31
+ };
32
+ export declare const CHAT_CARD_WIDTH = 220;
33
+ export declare const CHAT_MEDIA_HEIGHT = 140;
34
+ export declare const CHAT_GAP = 8;
35
+ export declare const CHAT_SMALL_GAP = 6;
36
+ export declare const CHAT_CHIP_RADIUS = 16;
37
+ /** Shown issues are capped so a broken message does not push the preview off screen. */
38
+ export declare const CHAT_MAX_LISTED_ISSUES = 3;
39
+ /** RCS rich card media heights from the RBM spec: 112, 168 and 264 dp. */
40
+ export declare const RCS_MEDIA_HEIGHT: Record<ChatRcsHeight, number>;
41
+ /** Share of a horizontal RCS card the thumbnail takes. */
42
+ export declare const RCS_THUMBNAIL_SHARE = 0.4;
43
+ export declare const RCS_DEFAULT_LAYOUT: {
44
+ orientation: ChatRcsOrientation;
45
+ height: ChatRcsHeight;
46
+ thumbnailAlignment: ChatRcsThumbnailAlignment;
47
+ };
@@ -0,0 +1,89 @@
1
+ import { WHATSAPP_COLOR } from '../WhatsAppPreview/constants';
2
+ export const CHAT_CHANNELS = {
3
+ whatsapp: {
4
+ skin: {
5
+ headerBackground: '#008069',
6
+ headerText: '#FFFFFF',
7
+ chatBackground: '#EFEAE2',
8
+ bubble: WHATSAPP_COLOR.INCOMING_BUBBLE,
9
+ bubbleText: '#111B21',
10
+ accent: '#027EB5',
11
+ chipBorder: '#E9EDEF'
12
+ },
13
+ icon: 'whatsapp',
14
+ repliesInsideBubble: true,
15
+ markup: 'whatsapp'
16
+ },
17
+ rcs: {
18
+ skin: {
19
+ headerBackground: '#FFFFFF',
20
+ headerText: '#1F1F1F',
21
+ chatBackground: '#FFFFFF',
22
+ bubble: '#E9EEF6',
23
+ bubbleText: '#1F1F1F',
24
+ accent: '#0B57D0',
25
+ chipBorder: '#C4C7C5'
26
+ },
27
+ icon: 'sms',
28
+ repliesInsideBubble: false,
29
+ markup: 'plain'
30
+ },
31
+ fbmessenger: {
32
+ skin: {
33
+ headerBackground: '#FFFFFF',
34
+ headerText: '#050505',
35
+ chatBackground: '#FFFFFF',
36
+ bubble: '#F0F0F0',
37
+ bubbleText: '#050505',
38
+ accent: '#0084FF',
39
+ chipBorder: '#0084FF'
40
+ },
41
+ icon: 'messenger',
42
+ repliesInsideBubble: false,
43
+ markup: 'plain'
44
+ },
45
+ line: {
46
+ skin: {
47
+ headerBackground: '#06C755',
48
+ headerText: '#FFFFFF',
49
+ chatBackground: '#8CABD9',
50
+ bubble: '#FFFFFF',
51
+ bubbleText: '#111111',
52
+ accent: '#06C755',
53
+ chipBorder: '#06C755'
54
+ },
55
+ icon: 'line',
56
+ repliesInsideBubble: false,
57
+ markup: 'plain'
58
+ }
59
+ };
60
+ export const CHAT_SCREEN_WIDTH = 320;
61
+ export const CHAT_SCREEN_HEIGHT = 560;
62
+ export const CHAT_SCREEN_RADIUS = 24;
63
+ export const CHAT_THREAD_PADDING = 12;
64
+ export const CHAT_BUBBLE_MAX_WIDTH = 260;
65
+ export const CHAT_BUBBLE_RADIUS = 12;
66
+ export const CHAT_BUBBLE_PADDING = {
67
+ vertical: 8,
68
+ horizontal: 10
69
+ };
70
+ export const CHAT_CARD_WIDTH = 220;
71
+ export const CHAT_MEDIA_HEIGHT = 140;
72
+ export const CHAT_GAP = 8;
73
+ export const CHAT_SMALL_GAP = 6;
74
+ export const CHAT_CHIP_RADIUS = 16;
75
+ /** Shown issues are capped so a broken message does not push the preview off screen. */
76
+ export const CHAT_MAX_LISTED_ISSUES = 3;
77
+ /** RCS rich card media heights from the RBM spec: 112, 168 and 264 dp. */
78
+ export const RCS_MEDIA_HEIGHT = {
79
+ SHORT: 112,
80
+ MEDIUM: 168,
81
+ TALL: 264
82
+ };
83
+ /** Share of a horizontal RCS card the thumbnail takes. */
84
+ export const RCS_THUMBNAIL_SHARE = 0.4;
85
+ export const RCS_DEFAULT_LAYOUT = {
86
+ orientation: 'VERTICAL',
87
+ height: 'MEDIUM',
88
+ thumbnailAlignment: 'LEFT'
89
+ };
@@ -0,0 +1,22 @@
1
+ import { RCS_DEFAULT_LAYOUT } from './constants';
2
+ import type { ChatButton, ChatCard, ChatChannel, ChatCompatibility, ChatContent, ChatHeader, ChatIssue, ChatRcsLayout } from './types';
3
+ /** What the preview draws for a channel status. */
4
+ export type ChatView = 'native'
5
+ /** WhatsApp: the template does not fit, the 24h session message does. */
6
+ | 'session' | 'fallback' | 'blocked';
7
+ /** Maps a compatibility status to what the recipient actually gets. */
8
+ export declare function viewOf(channel: ChatChannel, status: ChatCompatibility | undefined): ChatView;
9
+ /** Text the channel receives when it cannot render the content type. */
10
+ export declare function fallbackTextOf(content: ChatContent): string;
11
+ /** Buttons drawn below the bubble text: quick replies, call-to-action links and phone numbers. */
12
+ export declare function bubbleButtonsOf(content: ChatContent): ChatButton[];
13
+ /** Cards of a card or carousel message; a plain card is a one-slide carousel. */
14
+ export declare function cardsOf(content: ChatContent): ChatCard[];
15
+ export declare function hasHeader(header: ChatHeader | undefined): boolean;
16
+ /** Whether the native message has anything to draw; a card message draws only its card. */
17
+ export declare function hasNativeContent(content: ChatContent): boolean;
18
+ /** Content paths the channel drops; the preview marks them as not delivered. */
19
+ export declare function droppedPathsOf(issues: ChatIssue[] | undefined): Set<string>;
20
+ export declare function errorsOf(issues: ChatIssue[] | undefined): ChatIssue[];
21
+ /** RCS card layout with the Twilio defaults filled in. */
22
+ export declare function rcsLayoutOf(layout: ChatRcsLayout | undefined): typeof RCS_DEFAULT_LAYOUT;
@@ -0,0 +1,57 @@
1
+ import { RCS_DEFAULT_LAYOUT } from './constants';
2
+ /** Maps a compatibility status to what the recipient actually gets. */
3
+ export function viewOf(channel, status) {
4
+ if (status === 'incompatible') {
5
+ return 'blocked';
6
+ }
7
+ if (status === 'partial') {
8
+ return channel === 'whatsapp' ? 'session' : 'fallback';
9
+ }
10
+ return 'native';
11
+ }
12
+ /** Text the channel receives when it cannot render the content type. */
13
+ export function fallbackTextOf(content) {
14
+ return content.fallback || content.body || '';
15
+ }
16
+ /** Buttons drawn below the bubble text: quick replies, call-to-action links and phone numbers. */
17
+ export function bubbleButtonsOf(content) {
18
+ return content.type === 'quick_reply' || content.type === 'call_to_action' ? content.buttons ?? [] : [];
19
+ }
20
+ /** Cards of a card or carousel message; a plain card is a one-slide carousel. */
21
+ export function cardsOf(content) {
22
+ if (content.type === 'card') {
23
+ return content.cards?.slice(0, 1) ?? [];
24
+ }
25
+ return content.type === 'carousel' ? content.cards ?? [] : [];
26
+ }
27
+ export function hasHeader(header) {
28
+ return Boolean(header?.text || header?.media?.url);
29
+ }
30
+ function hasCardContent(card) {
31
+ return Boolean(card.media?.url || card.title || card.body || card.footer || card.buttons?.length);
32
+ }
33
+ /** Whether the native message has anything to draw; a card message draws only its card. */
34
+ export function hasNativeContent(content) {
35
+ if (content.type === 'custom_flex') {
36
+ return true;
37
+ }
38
+ if (content.type === 'card') {
39
+ return cardsOf(content).some(hasCardContent);
40
+ }
41
+ return Boolean(content.body || content.footer || content.media?.url || hasHeader(content.header) || cardsOf(content).some(hasCardContent) || content.list || content.buttons?.length);
42
+ }
43
+ /** Content paths the channel drops; the preview marks them as not delivered. */
44
+ export function droppedPathsOf(issues) {
45
+ return new Set((issues ?? []).filter(issue => issue.code === 'field_dropped').map(issue => issue.path));
46
+ }
47
+ export function errorsOf(issues) {
48
+ return (issues ?? []).filter(issue => issue.severity === 'error');
49
+ }
50
+ /** RCS card layout with the Twilio defaults filled in. */
51
+ export function rcsLayoutOf(layout) {
52
+ return {
53
+ orientation: layout?.orientation ?? RCS_DEFAULT_LAYOUT.orientation,
54
+ height: layout?.height ?? RCS_DEFAULT_LAYOUT.height,
55
+ thumbnailAlignment: layout?.thumbnail_alignment ?? RCS_DEFAULT_LAYOUT.thumbnailAlignment
56
+ };
57
+ }
@@ -0,0 +1,2 @@
1
+ export { ChatPreview } from './ChatPreview';
2
+ export type { ChatButton, ChatButtonKind, ChatCard, ChatChannel, ChatCompatibility, ChatContent, ChatContentType, ChatHeader, ChatIssue, ChatIssueSeverity, ChatList, ChatListItem, ChatMedia, ChatMediaKind, ChatPreviewProps, ChatRcsHeight, ChatRcsLayout, ChatRcsOrientation, ChatRcsThumbnailAlignment, } from './types';
@@ -0,0 +1 @@
1
+ export { ChatPreview } from './ChatPreview';
@@ -0,0 +1,2 @@
1
+ import { type ChatPreviewMessages } from './types';
2
+ export declare const Lang: import("react").FC<import("../../polyglot").LangProps<ChatPreviewMessages>>, useLang: () => (props: import("../../polyglot").LangProps<ChatPreviewMessages>) => string;
@@ -0,0 +1,34 @@
1
+ import { messages as ar } from './messages_ar';
2
+ import { messages as bn } from './messages_bn';
3
+ import { messages as de } from './messages_de';
4
+ import { messages as en } from './messages_en';
5
+ import { messages as es } from './messages_es';
6
+ import { messages as fr } from './messages_fr';
7
+ import { messages as he } from './messages_he';
8
+ import { messages as hi } from './messages_hi';
9
+ import { messages as ja } from './messages_ja';
10
+ import { messages as ko } from './messages_ko';
11
+ import { messages as pt } from './messages_pt';
12
+ import { messages as ru } from './messages_ru';
13
+ import { messages as th } from './messages_th';
14
+ import { messages as zh } from './messages_zh';
15
+ import { createLang } from '../../polyglot';
16
+ export const {
17
+ Lang,
18
+ useLang
19
+ } = createLang({
20
+ ar,
21
+ bn,
22
+ de,
23
+ en,
24
+ es,
25
+ fr,
26
+ he,
27
+ hi,
28
+ ja,
29
+ ko,
30
+ pt,
31
+ ru,
32
+ th,
33
+ zh
34
+ });
@@ -0,0 +1,3 @@
1
+ import { type ChatPreviewMessages } from './types';
2
+ import type { LangMessages } from '../../polyglot';
3
+ export declare const messages: LangMessages<ChatPreviewMessages>;
@@ -0,0 +1,14 @@
1
+ export const messages = {
2
+ 'DUMB.CHAT_PREVIEW.FALLBACK_PARTIAL': 'مدعوم جزئيًا — يُرسل النص البديل',
3
+ 'DUMB.CHAT_PREVIEW.FALLBACK_INCOMPATIBLE': 'يحتوي على أخطاء — لن يُرسل',
4
+ 'DUMB.CHAT_PREVIEW.SESSION_ONLY': 'يُرسل فقط ضمن نافذة الـ 24 ساعة',
5
+ 'DUMB.CHAT_PREVIEW.NO_FALLBACK': 'لا يوجد نص بديل — لن يُرسل شيء',
6
+ 'DUMB.CHAT_PREVIEW.NOT_DELIVERED': 'لا يتم تسليمه',
7
+ 'DUMB.CHAT_PREVIEW.MORE_ISSUES': '+{{count}} مشكلات أخرى',
8
+ 'DUMB.CHAT_PREVIEW.FLEX': 'رسالة LINE Flex',
9
+ 'DUMB.CHAT_PREVIEW.EMPTY': 'الرسالة فارغة…',
10
+ 'DUMB.CHAT_PREVIEW.SENDER': 'علامتك التجارية',
11
+ 'DUMB.CHAT_PREVIEW.DOCUMENT': 'مستند',
12
+ 'DUMB.CHAT_PREVIEW.AUDIO': 'رسالة صوتية',
13
+ 'DUMB.CHAT_PREVIEW.IMAGE_ALT': 'صورة مرفقة'
14
+ };
@@ -0,0 +1,3 @@
1
+ import { type ChatPreviewMessages } from './types';
2
+ import type { LangMessages } from '../../polyglot';
3
+ export declare const messages: LangMessages<ChatPreviewMessages>;