@pushwoosh/dumb-components 1.1.209 → 1.1.211
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/RadioCard/RadioCard.d.ts +1 -1
- package/RadioCard/RadioCard.js +2 -2
- package/RadioCard/types.d.ts +1 -1
- package/WhatsAppPreview/WhatsAppPreview.d.ts +4 -0
- package/WhatsAppPreview/WhatsAppPreview.js +103 -0
- package/WhatsAppPreview/__tests__/parseWhatsAppMarkup.test.d.ts +1 -0
- package/WhatsAppPreview/__tests__/parseWhatsAppMarkup.test.js +59 -0
- package/WhatsAppPreview/components/WhatsAppChatHeader/WhatsAppChatHeader.d.ts +4 -0
- package/WhatsAppPreview/components/WhatsAppChatHeader/WhatsAppChatHeader.js +39 -0
- package/WhatsAppPreview/components/WhatsAppChatHeader/index.d.ts +1 -0
- package/WhatsAppPreview/components/WhatsAppChatHeader/index.js +1 -0
- package/WhatsAppPreview/components/WhatsAppChatHeader/styles.d.ts +47 -0
- package/WhatsAppPreview/components/WhatsAppChatHeader/styles.js +37 -0
- package/WhatsAppPreview/components/WhatsAppChatHeader/types.d.ts +10 -0
- package/WhatsAppPreview/components/WhatsAppChatHeader/types.js +1 -0
- package/WhatsAppPreview/components/WhatsAppDateChip/WhatsAppDateChip.d.ts +4 -0
- package/WhatsAppPreview/components/WhatsAppDateChip/WhatsAppDateChip.js +28 -0
- package/WhatsAppPreview/components/WhatsAppDateChip/index.d.ts +1 -0
- package/WhatsAppPreview/components/WhatsAppDateChip/index.js +1 -0
- package/WhatsAppPreview/components/WhatsAppDateChip/styles.d.ts +6 -0
- package/WhatsAppPreview/components/WhatsAppDateChip/styles.js +6 -0
- package/WhatsAppPreview/components/WhatsAppDateChip/types.d.ts +6 -0
- package/WhatsAppPreview/components/WhatsAppDateChip/types.js +1 -0
- package/WhatsAppPreview/components/WhatsAppFormattedText/WhatsAppFormattedText.d.ts +4 -0
- package/WhatsAppPreview/components/WhatsAppFormattedText/WhatsAppFormattedText.js +39 -0
- package/WhatsAppPreview/components/WhatsAppFormattedText/index.d.ts +1 -0
- package/WhatsAppPreview/components/WhatsAppFormattedText/index.js +1 -0
- package/WhatsAppPreview/components/WhatsAppFormattedText/types.d.ts +16 -0
- package/WhatsAppPreview/components/WhatsAppFormattedText/types.js +1 -0
- package/WhatsAppPreview/components/WhatsAppMessageBubble/WhatsAppMessageBubble.d.ts +4 -0
- package/WhatsAppPreview/components/WhatsAppMessageBubble/WhatsAppMessageBubble.js +34 -0
- package/WhatsAppPreview/components/WhatsAppMessageBubble/index.d.ts +1 -0
- package/WhatsAppPreview/components/WhatsAppMessageBubble/index.js +1 -0
- package/WhatsAppPreview/components/WhatsAppMessageBubble/styles.d.ts +23 -0
- package/WhatsAppPreview/components/WhatsAppMessageBubble/styles.js +25 -0
- package/WhatsAppPreview/components/WhatsAppMessageBubble/types.d.ts +6 -0
- package/WhatsAppPreview/components/WhatsAppMessageBubble/types.js +1 -0
- package/WhatsAppPreview/components/WhatsAppStatusBar/WhatsAppStatusBar.d.ts +4 -0
- package/WhatsAppPreview/components/WhatsAppStatusBar/WhatsAppStatusBar.js +37 -0
- package/WhatsAppPreview/components/WhatsAppStatusBar/index.d.ts +1 -0
- package/WhatsAppPreview/components/WhatsAppStatusBar/index.js +1 -0
- package/WhatsAppPreview/components/WhatsAppStatusBar/styles.d.ts +15 -0
- package/WhatsAppPreview/components/WhatsAppStatusBar/styles.js +10 -0
- package/WhatsAppPreview/components/WhatsAppStatusBar/types.d.ts +5 -0
- package/WhatsAppPreview/components/WhatsAppStatusBar/types.js +1 -0
- package/WhatsAppPreview/constants.d.ts +26 -0
- package/WhatsAppPreview/constants.js +26 -0
- package/WhatsAppPreview/helpers.d.ts +3 -0
- package/WhatsAppPreview/helpers.js +56 -0
- package/WhatsAppPreview/icons/WhatsAppAvatarIcon.svg +1 -0
- package/WhatsAppPreview/icons/WhatsAppBackIcon.svg +1 -0
- package/WhatsAppPreview/icons/WhatsAppBatteryIcon.svg +1 -0
- package/WhatsAppPreview/icons/WhatsAppCallIcon.svg +1 -0
- package/WhatsAppPreview/icons/WhatsAppMenuIcon.svg +1 -0
- package/WhatsAppPreview/icons/WhatsAppSignalIcon.svg +1 -0
- package/WhatsAppPreview/icons/WhatsAppTickIcon.svg +1 -0
- package/WhatsAppPreview/icons/WhatsAppTicksIcon.svg +1 -0
- package/WhatsAppPreview/icons/WhatsAppWallpaperPattern.svg +1 -0
- package/WhatsAppPreview/icons/WhatsAppWifiIcon.svg +1 -0
- package/WhatsAppPreview/icons/index.d.ts +10 -0
- package/WhatsAppPreview/icons/index.js +10 -0
- package/WhatsAppPreview/index.d.ts +2 -0
- package/WhatsAppPreview/index.js +1 -0
- package/WhatsAppPreview/polyglot/index.d.ts +2 -0
- package/WhatsAppPreview/polyglot/index.js +34 -0
- package/WhatsAppPreview/polyglot/messages_ar.d.ts +3 -0
- package/WhatsAppPreview/polyglot/messages_ar.js +5 -0
- package/WhatsAppPreview/polyglot/messages_bn.d.ts +3 -0
- package/WhatsAppPreview/polyglot/messages_bn.js +5 -0
- package/WhatsAppPreview/polyglot/messages_de.d.ts +3 -0
- package/WhatsAppPreview/polyglot/messages_de.js +5 -0
- package/WhatsAppPreview/polyglot/messages_en.d.ts +3 -0
- package/WhatsAppPreview/polyglot/messages_en.js +5 -0
- package/WhatsAppPreview/polyglot/messages_es.d.ts +3 -0
- package/WhatsAppPreview/polyglot/messages_es.js +5 -0
- package/WhatsAppPreview/polyglot/messages_fr.d.ts +3 -0
- package/WhatsAppPreview/polyglot/messages_fr.js +5 -0
- package/WhatsAppPreview/polyglot/messages_he.d.ts +3 -0
- package/WhatsAppPreview/polyglot/messages_he.js +5 -0
- package/WhatsAppPreview/polyglot/messages_hi.d.ts +3 -0
- package/WhatsAppPreview/polyglot/messages_hi.js +5 -0
- package/WhatsAppPreview/polyglot/messages_ja.d.ts +3 -0
- package/WhatsAppPreview/polyglot/messages_ja.js +5 -0
- package/WhatsAppPreview/polyglot/messages_ko.d.ts +3 -0
- package/WhatsAppPreview/polyglot/messages_ko.js +5 -0
- package/WhatsAppPreview/polyglot/messages_pt.d.ts +3 -0
- package/WhatsAppPreview/polyglot/messages_pt.js +5 -0
- package/WhatsAppPreview/polyglot/messages_ru.d.ts +3 -0
- package/WhatsAppPreview/polyglot/messages_ru.js +5 -0
- package/WhatsAppPreview/polyglot/messages_th.d.ts +3 -0
- package/WhatsAppPreview/polyglot/messages_th.js +5 -0
- package/WhatsAppPreview/polyglot/messages_zh.d.ts +3 -0
- package/WhatsAppPreview/polyglot/messages_zh.js +5 -0
- package/WhatsAppPreview/polyglot/types.d.ts +6 -0
- package/WhatsAppPreview/polyglot/types.js +1 -0
- package/WhatsAppPreview/styles.d.ts +34 -0
- package/WhatsAppPreview/styles.js +24 -0
- package/WhatsAppPreview/types.d.ts +45 -0
- package/WhatsAppPreview/types.js +1 -0
- package/index.d.ts +2 -0
- package/index.js +1 -0
- package/package.json +1 -1
package/RadioCard/RadioCard.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ReactElement } from 'react';
|
|
2
2
|
import type { RadioCardProps } from './types';
|
|
3
3
|
/**
|
|
4
|
-
* Selectable card with a title, description and a radio indicator — a richer
|
|
4
|
+
* Selectable card with a title, optional description and a radio indicator — a richer
|
|
5
5
|
* alternative to {@link Radio} for choosing one option among cards.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
package/RadioCard/RadioCard.js
CHANGED
|
@@ -4,7 +4,7 @@ import { H4, Paragraph } from '@pushwoosh/kit-typography';
|
|
|
4
4
|
import { Radio } from '../Radio';
|
|
5
5
|
import { RootBox } from './styled';
|
|
6
6
|
/**
|
|
7
|
-
* Selectable card with a title, description and a radio indicator — a richer
|
|
7
|
+
* Selectable card with a title, optional description and a radio indicator — a richer
|
|
8
8
|
* alternative to {@link Radio} for choosing one option among cards.
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
@@ -32,7 +32,7 @@ export function RadioCard(props) {
|
|
|
32
32
|
}), _jsx(Radio, {
|
|
33
33
|
isChecked: isActive
|
|
34
34
|
})]
|
|
35
|
-
}), _jsx(Paragraph, {
|
|
35
|
+
}), description && _jsx(Paragraph, {
|
|
36
36
|
children: description
|
|
37
37
|
})]
|
|
38
38
|
}), children]
|
package/RadioCard/types.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export interface RadioCardProps {
|
|
|
4
4
|
/** Card heading. */
|
|
5
5
|
title: string;
|
|
6
6
|
/** Supporting text under the title. */
|
|
7
|
-
description
|
|
7
|
+
description?: string;
|
|
8
8
|
/** CSS width of the card (default `"262px"`). */
|
|
9
9
|
width?: string | number;
|
|
10
10
|
/** Whether this card is the selected one (drives the radio + active styling). */
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type ReactElement } from 'react';
|
|
2
|
+
import type { WhatsAppPreviewProps } from './types';
|
|
3
|
+
/** Renders a WhatsApp conversation the way the recipient sees it, WhatsApp markup included. */
|
|
4
|
+
export declare function WhatsAppPreview(props: WhatsAppPreviewProps): ReactElement;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Color } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { Horizontal, Rows, Vertical } from '@pushwoosh/kit-helpers';
|
|
4
|
+
import { Text } from '@pushwoosh/kit-typography';
|
|
5
|
+
import { WhatsAppChatHeader } from './components/WhatsAppChatHeader';
|
|
6
|
+
import { WhatsAppDateChip } from './components/WhatsAppDateChip';
|
|
7
|
+
import { WhatsAppMessageBubble } from './components/WhatsAppMessageBubble';
|
|
8
|
+
import { WhatsAppStatusBar } from './components/WhatsAppStatusBar';
|
|
9
|
+
import { WHATSAPP_COLOR, WHATSAPP_PREVIEW_HEIGHT, WHATSAPP_PREVIEW_WIDTH, WHATSAPP_STATUS_BAR_TIME } from './constants';
|
|
10
|
+
import { WhatsAppWallpaperPattern } from './icons';
|
|
11
|
+
import { Lang } from './polyglot';
|
|
12
|
+
import { DeviceBox, WallpaperImage, WallpaperLayer } from './styles';
|
|
13
|
+
import { Spinner } from '../Spinner';
|
|
14
|
+
/** Renders a WhatsApp conversation the way the recipient sees it, WhatsApp markup included. */
|
|
15
|
+
export function WhatsAppPreview(props) {
|
|
16
|
+
const {
|
|
17
|
+
messages = [],
|
|
18
|
+
contactName = '',
|
|
19
|
+
contactSubtitle,
|
|
20
|
+
avatarUrl,
|
|
21
|
+
dateLabel,
|
|
22
|
+
statusBarTime = WHATSAPP_STATUS_BAR_TIME,
|
|
23
|
+
wallpaperUrl,
|
|
24
|
+
emptyText,
|
|
25
|
+
width = WHATSAPP_PREVIEW_WIDTH,
|
|
26
|
+
height = WHATSAPP_PREVIEW_HEIGHT,
|
|
27
|
+
isLoading = false
|
|
28
|
+
} = props;
|
|
29
|
+
const separator = dateLabel === undefined ? _jsx(Lang, {
|
|
30
|
+
message: "DUMB.WHATSAPP_PREVIEW.TODAY"
|
|
31
|
+
}) : dateLabel;
|
|
32
|
+
return _jsx(DeviceBox, {
|
|
33
|
+
"$height": height,
|
|
34
|
+
"$width": width,
|
|
35
|
+
children: _jsxs(Rows, {
|
|
36
|
+
"$bgColor": WHATSAPP_COLOR.HEADER,
|
|
37
|
+
"$borderRadius": 39,
|
|
38
|
+
"$overflow": "hidden",
|
|
39
|
+
"$sizes": "auto auto minmax(0, 1fr)",
|
|
40
|
+
children: [_jsx(WhatsAppStatusBar, {
|
|
41
|
+
time: statusBarTime
|
|
42
|
+
}), _jsx(WhatsAppChatHeader, {
|
|
43
|
+
avatarUrl: avatarUrl,
|
|
44
|
+
name: contactName,
|
|
45
|
+
subtitle: contactSubtitle ?? _jsx(Lang, {
|
|
46
|
+
message: "DUMB.WHATSAPP_PREVIEW.BUSINESS_ACCOUNT"
|
|
47
|
+
})
|
|
48
|
+
}), _jsxs(Vertical, {
|
|
49
|
+
"$bgColor": WHATSAPP_COLOR.SCREEN,
|
|
50
|
+
"$overflow": "hidden",
|
|
51
|
+
"$position": "relative",
|
|
52
|
+
children: [_jsx(WallpaperLayer, {
|
|
53
|
+
children: wallpaperUrl ? _jsx(WallpaperImage, {
|
|
54
|
+
alt: "",
|
|
55
|
+
src: wallpaperUrl
|
|
56
|
+
}) : _jsx(WhatsAppWallpaperPattern, {})
|
|
57
|
+
}), isLoading && _jsx(Horizontal, {
|
|
58
|
+
"$alignItems": "center",
|
|
59
|
+
"$inset": 0,
|
|
60
|
+
"$justifyContent": "center",
|
|
61
|
+
"$position": "absolute",
|
|
62
|
+
children: _jsx(Spinner, {
|
|
63
|
+
color: Color.LOCKED,
|
|
64
|
+
size: "medium"
|
|
65
|
+
})
|
|
66
|
+
}), !isLoading && messages.length === 0 && _jsx(Horizontal, {
|
|
67
|
+
"$alignItems": "center",
|
|
68
|
+
"$inset": 0,
|
|
69
|
+
"$justifyContent": "center",
|
|
70
|
+
"$padding": 24,
|
|
71
|
+
"$position": "absolute",
|
|
72
|
+
children: _jsx(Text, {
|
|
73
|
+
"$color": WHATSAPP_COLOR.SUBTITLE,
|
|
74
|
+
"$variant": "footnote",
|
|
75
|
+
children: emptyText ?? _jsx(Lang, {
|
|
76
|
+
message: "DUMB.WHATSAPP_PREVIEW.EMPTY"
|
|
77
|
+
})
|
|
78
|
+
})
|
|
79
|
+
}), !isLoading && messages.length > 0 && _jsx(Vertical, {
|
|
80
|
+
"$inset": 0,
|
|
81
|
+
"$overflowY": "auto",
|
|
82
|
+
"$position": "absolute",
|
|
83
|
+
children: _jsxs(Vertical, {
|
|
84
|
+
"$alignContent": "start",
|
|
85
|
+
"$gap": 8,
|
|
86
|
+
"$minHeight": "100%",
|
|
87
|
+
"$padding": {
|
|
88
|
+
top: 12,
|
|
89
|
+
right: 9,
|
|
90
|
+
bottom: 16,
|
|
91
|
+
left: 9
|
|
92
|
+
},
|
|
93
|
+
children: [separator && _jsx(WhatsAppDateChip, {
|
|
94
|
+
children: separator
|
|
95
|
+
}), messages.map((message, index) => _jsx(WhatsAppMessageBubble, {
|
|
96
|
+
message: message
|
|
97
|
+
}, message.id ?? index))]
|
|
98
|
+
})
|
|
99
|
+
})]
|
|
100
|
+
})]
|
|
101
|
+
})
|
|
102
|
+
});
|
|
103
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { parseWhatsAppMarkup } from '../helpers';
|
|
2
|
+
describe('parseWhatsAppMarkup', () => {
|
|
3
|
+
it('keeps plain text as a single node', () => {
|
|
4
|
+
expect(parseWhatsAppMarkup('Hi there')).toEqual([{
|
|
5
|
+
text: 'Hi there'
|
|
6
|
+
}]);
|
|
7
|
+
});
|
|
8
|
+
it('marks bold, italic and strikethrough runs', () => {
|
|
9
|
+
expect(parseWhatsAppMarkup('*a* _b_ ~c~')).toEqual([{
|
|
10
|
+
style: 'bold',
|
|
11
|
+
children: [{
|
|
12
|
+
text: 'a'
|
|
13
|
+
}]
|
|
14
|
+
}, {
|
|
15
|
+
text: ' '
|
|
16
|
+
}, {
|
|
17
|
+
style: 'italic',
|
|
18
|
+
children: [{
|
|
19
|
+
text: 'b'
|
|
20
|
+
}]
|
|
21
|
+
}, {
|
|
22
|
+
text: ' '
|
|
23
|
+
}, {
|
|
24
|
+
style: 'strike',
|
|
25
|
+
children: [{
|
|
26
|
+
text: 'c'
|
|
27
|
+
}]
|
|
28
|
+
}]);
|
|
29
|
+
});
|
|
30
|
+
it('nests styles', () => {
|
|
31
|
+
expect(parseWhatsAppMarkup('*bold _both_*')).toEqual([{
|
|
32
|
+
style: 'bold',
|
|
33
|
+
children: [{
|
|
34
|
+
text: 'bold '
|
|
35
|
+
}, {
|
|
36
|
+
style: 'italic',
|
|
37
|
+
children: [{
|
|
38
|
+
text: 'both'
|
|
39
|
+
}]
|
|
40
|
+
}]
|
|
41
|
+
}]);
|
|
42
|
+
});
|
|
43
|
+
it('keeps monospace content literal', () => {
|
|
44
|
+
expect(parseWhatsAppMarkup('```*raw*```')).toEqual([{
|
|
45
|
+
style: 'mono',
|
|
46
|
+
children: [{
|
|
47
|
+
text: '*raw*'
|
|
48
|
+
}]
|
|
49
|
+
}]);
|
|
50
|
+
});
|
|
51
|
+
it('leaves unpaired and empty markers as text', () => {
|
|
52
|
+
expect(parseWhatsAppMarkup('2 * 3 = 6')).toEqual([{
|
|
53
|
+
text: '2 * 3 = 6'
|
|
54
|
+
}]);
|
|
55
|
+
expect(parseWhatsAppMarkup('**')).toEqual([{
|
|
56
|
+
text: '**'
|
|
57
|
+
}]);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WhatsAppChatHeader } from './WhatsAppChatHeader';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WhatsAppChatHeader } from './WhatsAppChatHeader';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export declare const HeaderBox: import("styled-components").StyledComponent<"div", any, import("@pushwoosh/kit-helpers/styled-helpers").CommonBoxProps & {
|
|
2
|
+
$alignContent?: import("@pushwoosh/kit-helpers/styled-helpers").AlignContentValue | undefined;
|
|
3
|
+
$alignItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue | undefined;
|
|
4
|
+
$gap?: import("@pushwoosh/kit-helpers/styled-helpers").StrNum | undefined;
|
|
5
|
+
$justifyContent?: import("@pushwoosh/kit-helpers/styled-helpers").JustifyContentValue | undefined;
|
|
6
|
+
} & {
|
|
7
|
+
$gridAutoFlow?: "row" | "column" | "dense" | "row dense" | "column dense" | undefined;
|
|
8
|
+
$justifyItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue | undefined;
|
|
9
|
+
$placeItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue | undefined;
|
|
10
|
+
} & {
|
|
11
|
+
$sizes: import("@pushwoosh/kit-helpers/styled-helpers").StrNum;
|
|
12
|
+
} & {
|
|
13
|
+
$alignItems: string;
|
|
14
|
+
$gap: number;
|
|
15
|
+
$sizes: string;
|
|
16
|
+
$padding: {
|
|
17
|
+
top: number;
|
|
18
|
+
right: number;
|
|
19
|
+
bottom: number;
|
|
20
|
+
left: number;
|
|
21
|
+
};
|
|
22
|
+
$bgColor: "#F6F3EF";
|
|
23
|
+
$border: {
|
|
24
|
+
bottom: string;
|
|
25
|
+
};
|
|
26
|
+
}, "$bgColor" | "$border" | "$padding" | "$alignItems" | "$gap" | "$sizes">;
|
|
27
|
+
export declare const HeaderAvatar: import("styled-components").StyledComponent<"div", any, import("@pushwoosh/kit-helpers/styled-helpers").CommonBoxProps & {
|
|
28
|
+
$alignContent?: import("@pushwoosh/kit-helpers/styled-helpers").AlignContentValue | undefined;
|
|
29
|
+
$alignItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue | undefined;
|
|
30
|
+
$gap?: import("@pushwoosh/kit-helpers/styled-helpers").StrNum | undefined;
|
|
31
|
+
$justifyContent?: import("@pushwoosh/kit-helpers/styled-helpers").JustifyContentValue | undefined;
|
|
32
|
+
} & {
|
|
33
|
+
$gridAutoFlow?: "row" | "column" | "dense" | "row dense" | "column dense" | undefined;
|
|
34
|
+
$justifyItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue | undefined;
|
|
35
|
+
$placeItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue | undefined;
|
|
36
|
+
} & {
|
|
37
|
+
$gridAutoFlow: string;
|
|
38
|
+
} & {
|
|
39
|
+
$alignItems: string;
|
|
40
|
+
$justifyContent: string;
|
|
41
|
+
$width: number;
|
|
42
|
+
$height: number;
|
|
43
|
+
$borderRadius: string;
|
|
44
|
+
$overflow: string;
|
|
45
|
+
$bgColor: "#CFD6DB";
|
|
46
|
+
}, "$gridAutoFlow" | "$bgColor" | "$borderRadius" | "$height" | "$overflow" | "$width" | "$alignItems" | "$justifyContent">;
|
|
47
|
+
export declare const HeaderAvatarImage: import("styled-components").StyledComponent<"img", any, {}, never>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { Columns, Horizontal } from '@pushwoosh/kit-helpers';
|
|
3
|
+
import { WHATSAPP_COLOR } from '../../constants';
|
|
4
|
+
export const HeaderBox = styled(Columns).attrs({
|
|
5
|
+
$alignItems: 'center',
|
|
6
|
+
$gap: 10,
|
|
7
|
+
$sizes: 'auto auto minmax(0, 1fr) auto',
|
|
8
|
+
$padding: {
|
|
9
|
+
top: 6,
|
|
10
|
+
right: 14,
|
|
11
|
+
bottom: 10,
|
|
12
|
+
left: 14
|
|
13
|
+
},
|
|
14
|
+
$bgColor: WHATSAPP_COLOR.HEADER,
|
|
15
|
+
$border: {
|
|
16
|
+
bottom: `1px solid ${WHATSAPP_COLOR.HEADER_BORDER}`
|
|
17
|
+
}
|
|
18
|
+
}).withConfig({
|
|
19
|
+
displayName: "HeaderBox",
|
|
20
|
+
componentId: "sc-7fu7hq-0"
|
|
21
|
+
})(["color:", ";svg{display:block;}"], WHATSAPP_COLOR.ACTION);
|
|
22
|
+
export const HeaderAvatar = styled(Horizontal).attrs({
|
|
23
|
+
$alignItems: 'center',
|
|
24
|
+
$justifyContent: 'center',
|
|
25
|
+
$width: 34,
|
|
26
|
+
$height: 34,
|
|
27
|
+
$borderRadius: '50%',
|
|
28
|
+
$overflow: 'hidden',
|
|
29
|
+
$bgColor: WHATSAPP_COLOR.AVATAR
|
|
30
|
+
}).withConfig({
|
|
31
|
+
displayName: "HeaderAvatar",
|
|
32
|
+
componentId: "sc-7fu7hq-1"
|
|
33
|
+
})(["color:", ";"], WHATSAPP_COLOR.AVATAR_GLYPH);
|
|
34
|
+
export const HeaderAvatarImage = styled.img.withConfig({
|
|
35
|
+
displayName: "HeaderAvatarImage",
|
|
36
|
+
componentId: "sc-7fu7hq-2"
|
|
37
|
+
})(["width:100%;height:100%;object-fit:cover;"]);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
/** Props of {@link WhatsAppChatHeader}. */
|
|
3
|
+
export interface WhatsAppChatHeaderProps {
|
|
4
|
+
/** Business name. */
|
|
5
|
+
name: string;
|
|
6
|
+
/** Caption under the name. */
|
|
7
|
+
subtitle: ReactNode;
|
|
8
|
+
/** Avatar image URL; a glyph is drawn when absent. */
|
|
9
|
+
avatarUrl?: string;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ShapeRadius } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { Horizontal, Vertical } from '@pushwoosh/kit-helpers';
|
|
4
|
+
import { DateChipText } from './styles';
|
|
5
|
+
import { WHATSAPP_COLOR } from '../../constants';
|
|
6
|
+
/** Date separator drawn above the first message of a day. */
|
|
7
|
+
export function WhatsAppDateChip(props) {
|
|
8
|
+
const {
|
|
9
|
+
children
|
|
10
|
+
} = props;
|
|
11
|
+
return _jsx(Horizontal, {
|
|
12
|
+
"$justifyContent": "center",
|
|
13
|
+
children: _jsx(Vertical, {
|
|
14
|
+
"$bgColor": WHATSAPP_COLOR.INCOMING_BUBBLE,
|
|
15
|
+
"$borderRadius": ShapeRadius.SECTION,
|
|
16
|
+
"$boxShadow": `0 1px 0.5px ${WHATSAPP_COLOR.BUBBLE_SHADOW}`,
|
|
17
|
+
"$padding": {
|
|
18
|
+
vertical: 5,
|
|
19
|
+
horizontal: 12
|
|
20
|
+
},
|
|
21
|
+
children: _jsx(DateChipText, {
|
|
22
|
+
"$color": WHATSAPP_COLOR.DATE_CHIP_TEXT,
|
|
23
|
+
"$variant": "footnote",
|
|
24
|
+
children: children
|
|
25
|
+
})
|
|
26
|
+
})
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WhatsAppDateChip } from './WhatsAppDateChip';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WhatsAppDateChip } from './WhatsAppDateChip';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const DateChipText: import("styled-components").StyledComponent<"span", any, {
|
|
2
|
+
$color?: string | undefined;
|
|
3
|
+
$uppercase?: boolean | undefined;
|
|
4
|
+
$ellipsis?: boolean | undefined;
|
|
5
|
+
$variant?: import("@pushwoosh/kit-typography").TypographyVariant | undefined;
|
|
6
|
+
}, never>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { Text } from '@pushwoosh/kit-typography';
|
|
3
|
+
export const DateChipText = styled(Text).withConfig({
|
|
4
|
+
displayName: "DateChipText",
|
|
5
|
+
componentId: "sc-1n9qlgp-0"
|
|
6
|
+
})(["display:block;&::first-letter{text-transform:uppercase;}"]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment } from 'react';
|
|
3
|
+
import { Text } from '@pushwoosh/kit-typography';
|
|
4
|
+
import { parseWhatsAppMarkup } from '../../helpers';
|
|
5
|
+
const TAGS = {
|
|
6
|
+
bold: 'b',
|
|
7
|
+
italic: 'i',
|
|
8
|
+
strike: 's'
|
|
9
|
+
};
|
|
10
|
+
function renderNodes(nodes) {
|
|
11
|
+
return nodes.map((node, index) => {
|
|
12
|
+
const key = `${index}-${node.style || 'text'}`;
|
|
13
|
+
if (!node.style) {
|
|
14
|
+
return _jsx(Fragment, {
|
|
15
|
+
children: node.text
|
|
16
|
+
}, key);
|
|
17
|
+
}
|
|
18
|
+
if (node.style === 'mono') {
|
|
19
|
+
return _jsx(Text, {
|
|
20
|
+
"$variant": "code",
|
|
21
|
+
as: "code",
|
|
22
|
+
children: renderNodes(node.children || [])
|
|
23
|
+
}, key);
|
|
24
|
+
}
|
|
25
|
+
const Tag = TAGS[node.style];
|
|
26
|
+
return _jsx(Tag, {
|
|
27
|
+
children: renderNodes(node.children || [])
|
|
28
|
+
}, key);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/** Renders message text with WhatsApp inline markup applied. */
|
|
32
|
+
export function WhatsAppFormattedText(props) {
|
|
33
|
+
const {
|
|
34
|
+
text
|
|
35
|
+
} = props;
|
|
36
|
+
return _jsx(_Fragment, {
|
|
37
|
+
children: renderNodes(parseWhatsAppMarkup(text))
|
|
38
|
+
});
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WhatsAppFormattedText } from './WhatsAppFormattedText';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WhatsAppFormattedText } from './WhatsAppFormattedText';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Inline style WhatsApp markup can apply to a text run. */
|
|
2
|
+
export type WhatsAppTextStyle = 'bold' | 'italic' | 'strike' | 'mono';
|
|
3
|
+
/** Node of the tree produced by `parseWhatsAppMarkup`. */
|
|
4
|
+
export interface WhatsAppTextNode {
|
|
5
|
+
/** Style applied to `children`; absent on a plain text run. */
|
|
6
|
+
style?: WhatsAppTextStyle;
|
|
7
|
+
/** Literal text of a leaf node. */
|
|
8
|
+
text?: string;
|
|
9
|
+
/** Nested runs of a styled node. */
|
|
10
|
+
children?: WhatsAppTextNode[];
|
|
11
|
+
}
|
|
12
|
+
/** Props of {@link WhatsAppFormattedText}. */
|
|
13
|
+
export interface WhatsAppFormattedTextProps {
|
|
14
|
+
/** Raw message text with WhatsApp markup. */
|
|
15
|
+
text: string;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type ReactElement } from 'react';
|
|
2
|
+
import type { WhatsAppMessageBubbleProps } from './types';
|
|
3
|
+
/** Single chat bubble: body, time and — for outgoing messages — the delivery ticks. */
|
|
4
|
+
export declare function WhatsAppMessageBubble(props: WhatsAppMessageBubbleProps): ReactElement;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Columns } from '@pushwoosh/kit-helpers';
|
|
3
|
+
import { BubbleBox, BubbleMeta, BubbleText } from './styles';
|
|
4
|
+
import { WhatsAppTickIcon, WhatsAppTicksIcon } from '../../icons';
|
|
5
|
+
import { WhatsAppFormattedText } from '../WhatsAppFormattedText';
|
|
6
|
+
/** Single chat bubble: body, time and — for outgoing messages — the delivery ticks. */
|
|
7
|
+
export function WhatsAppMessageBubble(props) {
|
|
8
|
+
const {
|
|
9
|
+
message
|
|
10
|
+
} = props;
|
|
11
|
+
const {
|
|
12
|
+
direction,
|
|
13
|
+
text = '',
|
|
14
|
+
content,
|
|
15
|
+
time,
|
|
16
|
+
status
|
|
17
|
+
} = message;
|
|
18
|
+
const showTicks = direction === 'outgoing' && Boolean(status);
|
|
19
|
+
return _jsx(Columns, {
|
|
20
|
+
"$justifyItems": direction === 'outgoing' ? 'end' : 'start',
|
|
21
|
+
"$sizes": "minmax(0, 1fr)",
|
|
22
|
+
children: _jsxs(BubbleBox, {
|
|
23
|
+
"$direction": direction,
|
|
24
|
+
children: [_jsx(BubbleText, {
|
|
25
|
+
children: content ?? _jsx(WhatsAppFormattedText, {
|
|
26
|
+
text: text
|
|
27
|
+
})
|
|
28
|
+
}), (time || showTicks) && _jsxs(BubbleMeta, {
|
|
29
|
+
"$read": showTicks && status === 'read',
|
|
30
|
+
children: [time, showTicks && status === 'sent' && _jsx(WhatsAppTickIcon, {}), showTicks && status !== 'sent' && _jsx(WhatsAppTicksIcon, {})]
|
|
31
|
+
})]
|
|
32
|
+
})
|
|
33
|
+
});
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WhatsAppMessageBubble } from './WhatsAppMessageBubble';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WhatsAppMessageBubble } from './WhatsAppMessageBubble';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { WhatsAppMessageDirection } from '../../types';
|
|
2
|
+
export declare const BubbleBox: import("styled-components").StyledComponent<"div", any, {
|
|
3
|
+
$direction: WhatsAppMessageDirection;
|
|
4
|
+
}, never>;
|
|
5
|
+
export declare const BubbleText: import("styled-components").StyledComponent<"span", any, {
|
|
6
|
+
$color?: string | undefined;
|
|
7
|
+
$uppercase?: boolean | undefined;
|
|
8
|
+
$ellipsis?: boolean | undefined;
|
|
9
|
+
$variant?: import("@pushwoosh/kit-typography").TypographyVariant | undefined;
|
|
10
|
+
} & {
|
|
11
|
+
$color: "#111B21";
|
|
12
|
+
}, "$color">;
|
|
13
|
+
export declare const BubbleMeta: import("styled-components").StyledComponent<"span", any, {
|
|
14
|
+
$color?: string | undefined;
|
|
15
|
+
$uppercase?: boolean | undefined;
|
|
16
|
+
$ellipsis?: boolean | undefined;
|
|
17
|
+
$variant?: import("@pushwoosh/kit-typography").TypographyVariant | undefined;
|
|
18
|
+
} & {
|
|
19
|
+
$variant: "footnote";
|
|
20
|
+
$color: "#667781";
|
|
21
|
+
} & {
|
|
22
|
+
$read: boolean;
|
|
23
|
+
}, "$color" | "$variant">;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
|
+
import { ShapeRadius } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { Text } from '@pushwoosh/kit-typography';
|
|
4
|
+
import { WHATSAPP_COLOR } from '../../constants';
|
|
5
|
+
export const BubbleBox = styled.div.withConfig({
|
|
6
|
+
displayName: "BubbleBox",
|
|
7
|
+
componentId: "sc-va3yjo-0"
|
|
8
|
+
})(["display:flow-root;max-width:82%;padding:6px 8px 7px;box-shadow:0 1px 0.5px ", ";overflow-wrap:anywhere;", ""], WHATSAPP_COLOR.BUBBLE_SHADOW, ({
|
|
9
|
+
$direction
|
|
10
|
+
}) => $direction === 'outgoing' ? css(["border-radius:", " 2px ", " ", ";background:", ";"], ShapeRadius.SECTION, ShapeRadius.SECTION, ShapeRadius.SECTION, WHATSAPP_COLOR.OUTGOING_BUBBLE) : css(["border-radius:2px ", " ", " ", ";background:", ";"], ShapeRadius.SECTION, ShapeRadius.SECTION, ShapeRadius.SECTION, WHATSAPP_COLOR.INCOMING_BUBBLE));
|
|
11
|
+
export const BubbleText = styled(Text).attrs({
|
|
12
|
+
$color: WHATSAPP_COLOR.BUBBLE_TEXT
|
|
13
|
+
}).withConfig({
|
|
14
|
+
displayName: "BubbleText",
|
|
15
|
+
componentId: "sc-va3yjo-1"
|
|
16
|
+
})(["white-space:pre-wrap;"]);
|
|
17
|
+
export const BubbleMeta = styled(Text).attrs({
|
|
18
|
+
$variant: 'footnote',
|
|
19
|
+
$color: WHATSAPP_COLOR.BUBBLE_META
|
|
20
|
+
}).withConfig({
|
|
21
|
+
displayName: "BubbleMeta",
|
|
22
|
+
componentId: "sc-va3yjo-2"
|
|
23
|
+
})(["display:inline-flex;align-items:center;gap:3px;float:right;margin:6px 0 -2px 8px;svg{display:block;color:", ";}"], ({
|
|
24
|
+
$read
|
|
25
|
+
}) => $read ? WHATSAPP_COLOR.READ_TICK : WHATSAPP_COLOR.BUBBLE_META);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type ReactElement } from 'react';
|
|
2
|
+
import type { WhatsAppStatusBarProps } from './types';
|
|
3
|
+
/** iOS status bar of the previewed device: clock, dynamic island and the signal indicators. */
|
|
4
|
+
export declare function WhatsAppStatusBar(props: WhatsAppStatusBarProps): ReactElement;
|