@pushwoosh/dumb-components 1.1.227 → 1.1.228
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/WhatsAppPreview/WhatsAppPreview.js +41 -22
- package/WhatsAppPreview/__tests__/WhatsAppAttachment.test.d.ts +1 -0
- package/WhatsAppPreview/__tests__/WhatsAppAttachment.test.js +53 -0
- package/WhatsAppPreview/__tests__/WhatsAppPreview.test.d.ts +1 -0
- package/WhatsAppPreview/__tests__/WhatsAppPreview.test.js +55 -0
- package/WhatsAppPreview/components/WhatsAppAttachment/WhatsAppAttachment.js +25 -6
- package/WhatsAppPreview/components/WhatsAppAttachment/styles.d.ts +22 -1
- package/WhatsAppPreview/components/WhatsAppAttachment/styles.js +24 -11
- package/WhatsAppPreview/components/WhatsAppMessageContent/WhatsAppMessageContent.d.ts +4 -0
- package/WhatsAppPreview/components/{WhatsAppMessageBubble/WhatsAppMessageBubble.js → WhatsAppMessageContent/WhatsAppMessageContent.js} +6 -7
- package/WhatsAppPreview/components/WhatsAppMessageContent/index.d.ts +1 -0
- package/WhatsAppPreview/components/WhatsAppMessageContent/index.js +1 -0
- package/WhatsAppPreview/components/{WhatsAppMessageBubble → WhatsAppMessageContent}/styles.d.ts +1 -1
- package/WhatsAppPreview/components/WhatsAppMessageContent/styles.js +6 -0
- package/WhatsAppPreview/components/WhatsAppMessageContent/types.d.ts +6 -0
- package/WhatsAppPreview/constants.d.ts +13 -6
- package/WhatsAppPreview/constants.js +13 -6
- package/WhatsAppPreview/polyglot/messages_ar.js +4 -0
- package/WhatsAppPreview/polyglot/messages_bn.js +4 -0
- package/WhatsAppPreview/polyglot/messages_de.js +4 -0
- package/WhatsAppPreview/polyglot/messages_en.js +4 -0
- package/WhatsAppPreview/polyglot/messages_es.js +4 -0
- package/WhatsAppPreview/polyglot/messages_fr.js +4 -0
- package/WhatsAppPreview/polyglot/messages_he.js +4 -0
- package/WhatsAppPreview/polyglot/messages_hi.js +4 -0
- package/WhatsAppPreview/polyglot/messages_ja.js +4 -0
- package/WhatsAppPreview/polyglot/messages_ko.js +4 -0
- package/WhatsAppPreview/polyglot/messages_pt.js +4 -0
- package/WhatsAppPreview/polyglot/messages_ru.js +4 -0
- package/WhatsAppPreview/polyglot/messages_th.js +4 -0
- package/WhatsAppPreview/polyglot/messages_zh.js +4 -0
- package/WhatsAppPreview/polyglot/types.d.ts +4 -0
- package/WhatsAppPreview/styles.d.ts +79 -9
- package/WhatsAppPreview/styles.js +60 -15
- package/WhatsAppPreview/types.d.ts +4 -0
- package/package.json +1 -1
- package/WhatsAppPreview/components/WhatsAppMessageBubble/WhatsAppMessageBubble.d.ts +0 -4
- package/WhatsAppPreview/components/WhatsAppMessageBubble/index.d.ts +0 -1
- package/WhatsAppPreview/components/WhatsAppMessageBubble/index.js +0 -1
- package/WhatsAppPreview/components/WhatsAppMessageBubble/styles.js +0 -6
- package/WhatsAppPreview/components/WhatsAppMessageBubble/types.d.ts +0 -6
- /package/WhatsAppPreview/components/{WhatsAppMessageBubble → WhatsAppMessageContent}/types.js +0 -0
|
@@ -1,43 +1,62 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Color
|
|
3
|
-
import { Horizontal } from '@pushwoosh/kit-helpers';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { Color } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { Horizontal, Vertical } from '@pushwoosh/kit-helpers';
|
|
4
|
+
import { CloseIcon, WhatsappIcon } from '@pushwoosh/kit-icons';
|
|
5
|
+
import { WhatsAppMessageContent } from './components/WhatsAppMessageContent';
|
|
6
|
+
import { WHATSAPP_CARD_PADDING } from './constants';
|
|
6
7
|
import { isMessageDrawable } from './helpers';
|
|
7
8
|
import { Lang } from './polyglot';
|
|
8
|
-
import {
|
|
9
|
+
import { AppBar, AppName, Card, MissedGlyph, MissedHint, MissedRow, MissedTitle, PreviewText } from './styles';
|
|
9
10
|
import { Spinner } from '../Spinner';
|
|
10
11
|
/** Renders a WhatsApp message the way the recipient sees it, WhatsApp markup and attachments included. */
|
|
11
12
|
export function WhatsAppPreview(props) {
|
|
12
13
|
const {
|
|
13
14
|
message,
|
|
14
15
|
emptyText,
|
|
15
|
-
isLoading = false
|
|
16
|
+
isLoading = false,
|
|
17
|
+
applicationName,
|
|
18
|
+
isContentMissing = false
|
|
16
19
|
} = props;
|
|
17
|
-
const isDrawable = message !== undefined && isMessageDrawable(message);
|
|
18
|
-
return _jsxs(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
const isDrawable = !isContentMissing && message !== undefined && isMessageDrawable(message);
|
|
21
|
+
return _jsxs(Card, {
|
|
22
|
+
children: [applicationName && _jsxs(AppBar, {
|
|
23
|
+
children: [_jsx(WhatsappIcon, {
|
|
24
|
+
size: "small",
|
|
25
|
+
view: "filled"
|
|
26
|
+
}), _jsx(AppName, {
|
|
27
|
+
children: applicationName
|
|
28
|
+
})]
|
|
29
|
+
}), isLoading && _jsx(Horizontal, {
|
|
25
30
|
"$alignItems": "center",
|
|
26
31
|
"$justifyContent": "center",
|
|
27
|
-
"$padding":
|
|
32
|
+
"$padding": WHATSAPP_CARD_PADDING,
|
|
28
33
|
children: _jsx(Spinner, {
|
|
29
34
|
color: Color.LOCKED,
|
|
30
35
|
size: "medium"
|
|
31
36
|
})
|
|
32
|
-
}), !isLoading &&
|
|
33
|
-
children: _jsx(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
children: emptyText ?? _jsx(Lang, {
|
|
37
|
-
message: "DUMB.WHATSAPP_PREVIEW.EMPTY"
|
|
37
|
+
}), !isLoading && isContentMissing && _jsxs(MissedRow, {
|
|
38
|
+
children: [_jsx(MissedGlyph, {
|
|
39
|
+
children: _jsx(CloseIcon, {
|
|
40
|
+
size: "medium"
|
|
38
41
|
})
|
|
42
|
+
}), _jsxs(Vertical, {
|
|
43
|
+
children: [_jsx(MissedTitle, {
|
|
44
|
+
children: _jsx(Lang, {
|
|
45
|
+
message: "DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_TITLE"
|
|
46
|
+
})
|
|
47
|
+
}), _jsx(MissedHint, {
|
|
48
|
+
children: _jsx(Lang, {
|
|
49
|
+
message: "DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_HINT"
|
|
50
|
+
})
|
|
51
|
+
})]
|
|
52
|
+
})]
|
|
53
|
+
}), !isLoading && !isContentMissing && !isDrawable && _jsx(PreviewText, {
|
|
54
|
+
"$color": Color.LOCKED,
|
|
55
|
+
"$ellipsis": true,
|
|
56
|
+
children: emptyText ?? _jsx(Lang, {
|
|
57
|
+
message: "DUMB.WHATSAPP_PREVIEW.EMPTY"
|
|
39
58
|
})
|
|
40
|
-
}), !isLoading && isDrawable && _jsx(
|
|
59
|
+
}), !isLoading && isDrawable && _jsx(WhatsAppMessageContent, {
|
|
41
60
|
message: message
|
|
42
61
|
})]
|
|
43
62
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
3
|
+
import { WhatsAppAttachment } from '../components/WhatsAppAttachment';
|
|
4
|
+
const IMAGE = {
|
|
5
|
+
name: 'promo.jpg',
|
|
6
|
+
source: 'https://example.invalid/promo.jpg',
|
|
7
|
+
kind: 'image'
|
|
8
|
+
};
|
|
9
|
+
describe('WhatsAppAttachment', () => {
|
|
10
|
+
it('labels a loading image without leaking the file name', () => {
|
|
11
|
+
render(_jsx(WhatsAppAttachment, {
|
|
12
|
+
attachment: IMAGE
|
|
13
|
+
}));
|
|
14
|
+
const image = screen.getByRole('img');
|
|
15
|
+
expect(image).toHaveAttribute('alt', 'Attached image');
|
|
16
|
+
expect(image.getAttribute('alt')).not.toContain('promo.jpg');
|
|
17
|
+
});
|
|
18
|
+
it('drops the image for the placeholder once the source fails', () => {
|
|
19
|
+
render(_jsx(WhatsAppAttachment, {
|
|
20
|
+
attachment: IMAGE
|
|
21
|
+
}));
|
|
22
|
+
fireEvent.error(screen.getByRole('img'));
|
|
23
|
+
expect(screen.queryByRole('img')).not.toBeInTheDocument();
|
|
24
|
+
});
|
|
25
|
+
it('retries a corrected source instead of keeping the placeholder', () => {
|
|
26
|
+
const {
|
|
27
|
+
rerender
|
|
28
|
+
} = render(_jsx(WhatsAppAttachment, {
|
|
29
|
+
attachment: IMAGE
|
|
30
|
+
}));
|
|
31
|
+
fireEvent.error(screen.getByRole('img'));
|
|
32
|
+
rerender(_jsx(WhatsAppAttachment, {
|
|
33
|
+
attachment: {
|
|
34
|
+
...IMAGE,
|
|
35
|
+
source: 'https://example.invalid/fixed.jpg'
|
|
36
|
+
}
|
|
37
|
+
}));
|
|
38
|
+
expect(screen.getByRole('img')).toHaveAttribute('src', 'https://example.invalid/fixed.jpg');
|
|
39
|
+
});
|
|
40
|
+
it('hides an unreachable document poster but keeps the card', () => {
|
|
41
|
+
render(_jsx(WhatsAppAttachment, {
|
|
42
|
+
attachment: {
|
|
43
|
+
name: 'Price list.pdf',
|
|
44
|
+
source: 'https://example.invalid/price.pdf',
|
|
45
|
+
kind: 'document',
|
|
46
|
+
thumbnailSource: 'https://example.invalid/poster.jpg'
|
|
47
|
+
}
|
|
48
|
+
}));
|
|
49
|
+
fireEvent.error(screen.getByRole('img'));
|
|
50
|
+
expect(screen.queryByRole('img')).not.toBeInTheDocument();
|
|
51
|
+
expect(screen.getByText('Price list.pdf')).toBeInTheDocument();
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { WhatsAppPreview } from '../WhatsAppPreview';
|
|
4
|
+
describe('WhatsAppPreview', () => {
|
|
5
|
+
it('heads the card with the application it sends from', () => {
|
|
6
|
+
const {
|
|
7
|
+
container
|
|
8
|
+
} = render(_jsx(WhatsAppPreview, {
|
|
9
|
+
applicationName: "The canary",
|
|
10
|
+
message: {
|
|
11
|
+
text: 'Hi'
|
|
12
|
+
}
|
|
13
|
+
}));
|
|
14
|
+
expect(screen.getByText('The canary')).toBeInTheDocument();
|
|
15
|
+
expect(container.querySelector('svg')).toBeInTheDocument();
|
|
16
|
+
});
|
|
17
|
+
it('keeps the header on the empty card', () => {
|
|
18
|
+
render(_jsx(WhatsAppPreview, {
|
|
19
|
+
applicationName: "The canary",
|
|
20
|
+
emptyText: "Nothing yet"
|
|
21
|
+
}));
|
|
22
|
+
expect(screen.getByText('The canary')).toBeInTheDocument();
|
|
23
|
+
expect(screen.getByText('Nothing yet')).toBeInTheDocument();
|
|
24
|
+
});
|
|
25
|
+
it('draws no header without an application', () => {
|
|
26
|
+
const {
|
|
27
|
+
container
|
|
28
|
+
} = render(_jsx(WhatsAppPreview, {
|
|
29
|
+
message: {
|
|
30
|
+
text: 'Hi'
|
|
31
|
+
}
|
|
32
|
+
}));
|
|
33
|
+
expect(container.querySelector('svg')).not.toBeInTheDocument();
|
|
34
|
+
expect(screen.getByText('Hi')).toBeInTheDocument();
|
|
35
|
+
});
|
|
36
|
+
it('replaces the message with the unavailable-content row', () => {
|
|
37
|
+
render(_jsx(WhatsAppPreview, {
|
|
38
|
+
isContentMissing: true,
|
|
39
|
+
message: {
|
|
40
|
+
text: 'Stale promo'
|
|
41
|
+
}
|
|
42
|
+
}));
|
|
43
|
+
expect(screen.getByText('Content missed')).toBeInTheDocument();
|
|
44
|
+
expect(screen.getByText('Might be old data or deleted presets')).toBeInTheDocument();
|
|
45
|
+
expect(screen.queryByText('Stale promo')).not.toBeInTheDocument();
|
|
46
|
+
});
|
|
47
|
+
it('keeps the application header above the unavailable-content row', () => {
|
|
48
|
+
render(_jsx(WhatsAppPreview, {
|
|
49
|
+
applicationName: "The canary",
|
|
50
|
+
isContentMissing: true
|
|
51
|
+
}));
|
|
52
|
+
expect(screen.getByText('The canary')).toBeInTheDocument();
|
|
53
|
+
expect(screen.getByText('Content missed')).toBeInTheDocument();
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useState } from 'react';
|
|
2
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
3
3
|
import { Color } from '@pushwoosh/kit-constants';
|
|
4
4
|
import { Columns, Vertical } from '@pushwoosh/kit-helpers';
|
|
5
|
-
import {
|
|
5
|
+
import { ImageIcon } from '@pushwoosh/kit-icons';
|
|
6
|
+
import { DocumentBox, DocumentGlyph, DocumentThumbnail, MediaBox, MediaDuration, MediaFallback, MediaOverlay, PlayButton, PlayGlyph } from './styles';
|
|
6
7
|
import { formatAttachmentDuration, formatAttachmentSize, getAttachmentExtension, resolveAttachmentKind, toVideoPosterSource } from '../../helpers';
|
|
7
8
|
import { WhatsAppDocumentIcon, WhatsAppPlayIcon, WhatsAppVideoIcon } from '../../icons';
|
|
8
9
|
import { useLang } from '../../polyglot';
|
|
@@ -22,8 +23,11 @@ export function WhatsAppAttachment(props) {
|
|
|
22
23
|
} = attachment;
|
|
23
24
|
const lang = useLang();
|
|
24
25
|
const [readDuration, setReadDuration] = useState(null);
|
|
26
|
+
const [hasFailed, setHasFailed] = useState(false);
|
|
25
27
|
const kind = resolveAttachmentKind(attachment);
|
|
26
28
|
const extension = getAttachmentExtension(attachment);
|
|
29
|
+
useEffect(() => setHasFailed(false), [source, thumbnailSource]);
|
|
30
|
+
const handleError = useCallback(() => setHasFailed(true), []);
|
|
27
31
|
const handleLoadedMetadata = useCallback(event => {
|
|
28
32
|
const {
|
|
29
33
|
duration: length
|
|
@@ -36,9 +40,12 @@ export function WhatsAppAttachment(props) {
|
|
|
36
40
|
count: pageCount
|
|
37
41
|
}), size === undefined ? '' : formatAttachmentSize(size), extension].filter(Boolean);
|
|
38
42
|
return _jsxs(DocumentBox, {
|
|
39
|
-
children: [thumbnailSource && _jsx(DocumentThumbnail, {
|
|
40
|
-
alt:
|
|
41
|
-
|
|
43
|
+
children: [thumbnailSource && !hasFailed && _jsx(DocumentThumbnail, {
|
|
44
|
+
alt: lang({
|
|
45
|
+
message: 'DUMB.WHATSAPP_PREVIEW.DOCUMENT_ALT'
|
|
46
|
+
}),
|
|
47
|
+
src: thumbnailSource,
|
|
48
|
+
onError: handleError
|
|
42
49
|
}), _jsxs(Columns, {
|
|
43
50
|
"$alignItems": "center",
|
|
44
51
|
"$gap": 10,
|
|
@@ -63,16 +70,28 @@ export function WhatsAppAttachment(props) {
|
|
|
63
70
|
}
|
|
64
71
|
const length = duration ?? readDuration;
|
|
65
72
|
const isVideo = kind === 'video';
|
|
73
|
+
if (hasFailed) {
|
|
74
|
+
return _jsx(MediaFallback, {
|
|
75
|
+
children: _jsx(ImageIcon, {
|
|
76
|
+
size: "medium",
|
|
77
|
+
view: "lined"
|
|
78
|
+
})
|
|
79
|
+
});
|
|
80
|
+
}
|
|
66
81
|
return _jsxs(MediaBox, {
|
|
67
82
|
"$hasOverlay": isVideo,
|
|
68
83
|
children: [isVideo && !thumbnailSource ? _jsx("video", {
|
|
69
84
|
muted: true,
|
|
70
85
|
playsInline: true,
|
|
86
|
+
onError: handleError,
|
|
71
87
|
onLoadedMetadata: handleLoadedMetadata,
|
|
72
88
|
preload: "metadata",
|
|
73
89
|
src: toVideoPosterSource(source)
|
|
74
90
|
}) : _jsx("img", {
|
|
75
|
-
alt:
|
|
91
|
+
alt: lang({
|
|
92
|
+
message: 'DUMB.WHATSAPP_PREVIEW.IMAGE_ALT'
|
|
93
|
+
}),
|
|
94
|
+
onError: handleError,
|
|
76
95
|
src: thumbnailSource ?? source
|
|
77
96
|
}), isVideo && _jsx(PlayButton, {
|
|
78
97
|
children: _jsx(PlayGlyph, {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Color } from '@pushwoosh/kit-constants';
|
|
1
2
|
export declare const MediaBox: import("styled-components").StyledComponent<"div", any, import("@pushwoosh/kit-helpers/styled-helpers").CommonBoxProps & {
|
|
2
3
|
$alignContent?: import("@pushwoosh/kit-helpers/styled-helpers").AlignContentValue | undefined;
|
|
3
4
|
$alignItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue | undefined;
|
|
@@ -11,12 +12,32 @@ export declare const MediaBox: import("styled-components").StyledComponent<"div"
|
|
|
11
12
|
$gridAutoFlow: string;
|
|
12
13
|
} & {
|
|
13
14
|
$position: string;
|
|
15
|
+
$alignContent: string;
|
|
14
16
|
$bgColor: "#0B141A";
|
|
15
17
|
$borderRadius: number;
|
|
16
18
|
$justifyItems: string;
|
|
17
19
|
} & {
|
|
18
20
|
$hasOverlay: boolean;
|
|
19
|
-
}, "$gridAutoFlow" | "$bgColor" | "$borderRadius" | "$position" | "$justifyItems">;
|
|
21
|
+
}, "$gridAutoFlow" | "$bgColor" | "$borderRadius" | "$position" | "$alignContent" | "$justifyItems">;
|
|
22
|
+
export declare const MediaFallback: import("styled-components").StyledComponent<"div", any, import("@pushwoosh/kit-helpers/styled-helpers").CommonBoxProps & {
|
|
23
|
+
$alignContent?: import("@pushwoosh/kit-helpers/styled-helpers").AlignContentValue | undefined;
|
|
24
|
+
$alignItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue | undefined;
|
|
25
|
+
$gap?: import("@pushwoosh/kit-helpers/styled-helpers").StrNum | undefined;
|
|
26
|
+
$justifyContent?: import("@pushwoosh/kit-helpers/styled-helpers").JustifyContentValue | undefined;
|
|
27
|
+
} & {
|
|
28
|
+
$gridAutoFlow?: "row" | "column" | "dense" | "row dense" | "column dense" | undefined;
|
|
29
|
+
$justifyItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue | undefined;
|
|
30
|
+
$placeItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue | undefined;
|
|
31
|
+
} & {
|
|
32
|
+
$gridAutoFlow: string;
|
|
33
|
+
} & {
|
|
34
|
+
$alignContent: string;
|
|
35
|
+
$justifyItems: string;
|
|
36
|
+
$bgColor: Color;
|
|
37
|
+
$borderRadius: number;
|
|
38
|
+
$height: number;
|
|
39
|
+
$width: string;
|
|
40
|
+
}, "$gridAutoFlow" | "$bgColor" | "$borderRadius" | "$height" | "$width" | "$alignContent" | "$justifyItems">;
|
|
20
41
|
export declare const PlayButton: import("styled-components").StyledComponent<"div", any, import("@pushwoosh/kit-helpers/styled-helpers").CommonBoxProps & {
|
|
21
42
|
$alignContent?: import("@pushwoosh/kit-helpers/styled-helpers").AlignContentValue | undefined;
|
|
22
43
|
$alignItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue | undefined;
|
|
@@ -1,18 +1,31 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
|
+
import { Color } from '@pushwoosh/kit-constants';
|
|
2
3
|
import { Horizontal, Vertical } from '@pushwoosh/kit-helpers';
|
|
3
4
|
import { Text } from '@pushwoosh/kit-typography';
|
|
4
|
-
import { WHATSAPP_COLOR, WHATSAPP_MEDIA_MAX_HEIGHT, WHATSAPP_MEDIA_MIN_HEIGHT, WHATSAPP_MEDIA_RADIUS } from '../../constants';
|
|
5
|
+
import { WHATSAPP_COLOR, WHATSAPP_MEDIA_FALLBACK_HEIGHT, WHATSAPP_MEDIA_MAX_HEIGHT, WHATSAPP_MEDIA_MIN_HEIGHT, WHATSAPP_MEDIA_RADIUS } from '../../constants';
|
|
5
6
|
export const MediaBox = styled(Vertical).attrs({
|
|
6
7
|
$position: 'relative',
|
|
8
|
+
$alignContent: 'center',
|
|
7
9
|
$bgColor: WHATSAPP_COLOR.MEDIA_BACKDROP,
|
|
8
10
|
$borderRadius: WHATSAPP_MEDIA_RADIUS,
|
|
9
|
-
$justifyItems: '
|
|
11
|
+
$justifyItems: 'center'
|
|
10
12
|
}).withConfig({
|
|
11
13
|
displayName: "MediaBox",
|
|
12
14
|
componentId: "sc-1uezfps-0"
|
|
13
|
-
})(["overflow:hidden;width:
|
|
15
|
+
})(["overflow:hidden;width:100%;", " img,video{display:block;width:auto;height:auto;max-width:100%;max-height:", "px;}"], ({
|
|
14
16
|
$hasOverlay
|
|
15
|
-
}) => $hasOverlay ? `min-height: ${WHATSAPP_MEDIA_MIN_HEIGHT}px;` : '');
|
|
17
|
+
}) => $hasOverlay ? `min-height: ${WHATSAPP_MEDIA_MIN_HEIGHT}px;` : '', WHATSAPP_MEDIA_MAX_HEIGHT);
|
|
18
|
+
export const MediaFallback = styled(Vertical).attrs({
|
|
19
|
+
$alignContent: 'center',
|
|
20
|
+
$justifyItems: 'center',
|
|
21
|
+
$bgColor: Color.FROZEN,
|
|
22
|
+
$borderRadius: WHATSAPP_MEDIA_RADIUS,
|
|
23
|
+
$height: WHATSAPP_MEDIA_FALLBACK_HEIGHT,
|
|
24
|
+
$width: '100%'
|
|
25
|
+
}).withConfig({
|
|
26
|
+
displayName: "MediaFallback",
|
|
27
|
+
componentId: "sc-1uezfps-1"
|
|
28
|
+
})(["color:", ";svg{display:block;}"], Color.LOCKED);
|
|
16
29
|
export const PlayButton = styled(Horizontal).attrs({
|
|
17
30
|
$alignItems: 'center',
|
|
18
31
|
$justifyContent: 'center',
|
|
@@ -20,7 +33,7 @@ export const PlayButton = styled(Horizontal).attrs({
|
|
|
20
33
|
$inset: 0
|
|
21
34
|
}).withConfig({
|
|
22
35
|
displayName: "PlayButton",
|
|
23
|
-
componentId: "sc-1uezfps-
|
|
36
|
+
componentId: "sc-1uezfps-2"
|
|
24
37
|
})(["pointer-events:none;"]);
|
|
25
38
|
export const PlayGlyph = styled(Horizontal).attrs({
|
|
26
39
|
$alignItems: 'center',
|
|
@@ -31,7 +44,7 @@ export const PlayGlyph = styled(Horizontal).attrs({
|
|
|
31
44
|
$bgColor: WHATSAPP_COLOR.PLAY_BUTTON
|
|
32
45
|
}).withConfig({
|
|
33
46
|
displayName: "PlayGlyph",
|
|
34
|
-
componentId: "sc-1uezfps-
|
|
47
|
+
componentId: "sc-1uezfps-3"
|
|
35
48
|
})(["color:", ";svg{display:block;margin-left:3px;}"], WHATSAPP_COLOR.PLAY_GLYPH);
|
|
36
49
|
export const MediaOverlay = styled(Horizontal).attrs({
|
|
37
50
|
$alignItems: 'end',
|
|
@@ -43,14 +56,14 @@ export const MediaOverlay = styled(Horizontal).attrs({
|
|
|
43
56
|
}
|
|
44
57
|
}).withConfig({
|
|
45
58
|
displayName: "MediaOverlay",
|
|
46
|
-
componentId: "sc-1uezfps-
|
|
59
|
+
componentId: "sc-1uezfps-4"
|
|
47
60
|
})(["position:absolute;right:0;bottom:0;left:0;max-height:100%;overflow:hidden;background:linear-gradient(to top,", ",transparent);pointer-events:none;"], WHATSAPP_COLOR.MEDIA_SCRIM);
|
|
48
61
|
export const MediaDuration = styled(Text).attrs({
|
|
49
62
|
$variant: 'footnote',
|
|
50
63
|
$color: WHATSAPP_COLOR.MEDIA_META
|
|
51
64
|
}).withConfig({
|
|
52
65
|
displayName: "MediaDuration",
|
|
53
|
-
componentId: "sc-1uezfps-
|
|
66
|
+
componentId: "sc-1uezfps-5"
|
|
54
67
|
})(["display:inline-flex;align-items:center;gap:4px;svg{display:block;}"]);
|
|
55
68
|
export const DocumentBox = styled(Vertical).attrs({
|
|
56
69
|
$bgColor: WHATSAPP_COLOR.DOCUMENT_CARD,
|
|
@@ -58,13 +71,13 @@ export const DocumentBox = styled(Vertical).attrs({
|
|
|
58
71
|
$width: '100%'
|
|
59
72
|
}).withConfig({
|
|
60
73
|
displayName: "DocumentBox",
|
|
61
|
-
componentId: "sc-1uezfps-
|
|
74
|
+
componentId: "sc-1uezfps-6"
|
|
62
75
|
})(["overflow:hidden;"]);
|
|
63
76
|
export const DocumentThumbnail = styled.img.withConfig({
|
|
64
77
|
displayName: "DocumentThumbnail",
|
|
65
|
-
componentId: "sc-1uezfps-
|
|
78
|
+
componentId: "sc-1uezfps-7"
|
|
66
79
|
})(["display:block;width:100%;max-height:", "px;object-fit:cover;"], WHATSAPP_MEDIA_MAX_HEIGHT);
|
|
67
80
|
export const DocumentGlyph = styled(Horizontal).withConfig({
|
|
68
81
|
displayName: "DocumentGlyph",
|
|
69
|
-
componentId: "sc-1uezfps-
|
|
82
|
+
componentId: "sc-1uezfps-8"
|
|
70
83
|
})(["color:", ";svg{display:block;}"], WHATSAPP_COLOR.DOCUMENT_GLYPH);
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { MessageText } from './styles';
|
|
3
3
|
import { drawableAttachments } from '../../helpers';
|
|
4
|
-
import { Bubble } from '../../styles';
|
|
5
4
|
import { WhatsAppAttachment } from '../WhatsAppAttachment';
|
|
6
5
|
import { WhatsAppFormattedText } from '../WhatsAppFormattedText';
|
|
7
|
-
/**
|
|
8
|
-
export function
|
|
6
|
+
/** Card body: attachments on top, message text underneath. */
|
|
7
|
+
export function WhatsAppMessageContent(props) {
|
|
9
8
|
const {
|
|
10
9
|
message
|
|
11
10
|
} = props;
|
|
@@ -15,10 +14,10 @@ export function WhatsAppMessageBubble(props) {
|
|
|
15
14
|
} = message;
|
|
16
15
|
const hasBody = Boolean(text || content);
|
|
17
16
|
const attachments = drawableAttachments(message);
|
|
18
|
-
return _jsxs(
|
|
17
|
+
return _jsxs(_Fragment, {
|
|
19
18
|
children: [attachments.map((attachment, index) => _jsx(WhatsAppAttachment, {
|
|
20
19
|
attachment: attachment
|
|
21
|
-
}, `${attachment.name}:${attachment.source}:${String(index)}`)), hasBody && _jsx(
|
|
20
|
+
}, `${attachment.name}:${attachment.source}:${String(index)}`)), hasBody && _jsx(MessageText, {
|
|
22
21
|
children: content ?? _jsx(WhatsAppFormattedText, {
|
|
23
22
|
text: text
|
|
24
23
|
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WhatsAppMessageContent } from './WhatsAppMessageContent';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WhatsAppMessageContent } from './WhatsAppMessageContent';
|
package/WhatsAppPreview/components/{WhatsAppMessageBubble → WhatsAppMessageContent}/styles.d.ts
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const MessageText: import("styled-components").StyledComponent<"span", any, {
|
|
2
2
|
$color?: string | undefined;
|
|
3
3
|
$uppercase?: boolean | undefined;
|
|
4
4
|
$ellipsis?: boolean | undefined;
|
|
@@ -10,15 +10,22 @@ export declare const WHATSAPP_COLOR: {
|
|
|
10
10
|
readonly DOCUMENT_GLYPH: "#8696A0";
|
|
11
11
|
readonly OUTGOING_BUBBLE: "#D9FDD3";
|
|
12
12
|
};
|
|
13
|
-
/**
|
|
14
|
-
export declare const
|
|
15
|
-
export declare const
|
|
16
|
-
export declare const
|
|
17
|
-
export declare const
|
|
13
|
+
/** Card geometry from the design: 280px of content inside a 12px padding and a 1px border, border-box. */
|
|
14
|
+
export declare const WHATSAPP_CARD_WIDTH = 306;
|
|
15
|
+
export declare const WHATSAPP_CARD_PADDING = 12;
|
|
16
|
+
export declare const WHATSAPP_APP_BAR_GAP = 6;
|
|
17
|
+
export declare const WHATSAPP_APP_BAR_PADDING: {
|
|
18
|
+
vertical: number;
|
|
19
|
+
horizontal: number;
|
|
20
|
+
};
|
|
21
|
+
export declare const WHATSAPP_MISSED_GLYPH_SIZE = 40;
|
|
22
|
+
export declare const WHATSAPP_MISSED_GAP = 12;
|
|
18
23
|
export declare const WHATSAPP_MEDIA_MAX_HEIGHT = 320;
|
|
19
|
-
/**
|
|
24
|
+
/** Play button and duration badge need room, so the video frame — not the poster — never draws shorter. */
|
|
20
25
|
export declare const WHATSAPP_MEDIA_MIN_HEIGHT = 48;
|
|
21
26
|
export declare const WHATSAPP_MEDIA_RADIUS = 4;
|
|
27
|
+
/** Unreachable media keeps the bubble at its full width instead of collapsing to a broken-image glyph. */
|
|
28
|
+
export declare const WHATSAPP_MEDIA_FALLBACK_HEIGHT = 160;
|
|
22
29
|
export declare const WHATSAPP_ATTACHMENT_EXTENSIONS: {
|
|
23
30
|
readonly image: string[];
|
|
24
31
|
readonly video: string[];
|
|
@@ -10,15 +10,22 @@ export const WHATSAPP_COLOR = {
|
|
|
10
10
|
DOCUMENT_GLYPH: '#8696A0',
|
|
11
11
|
OUTGOING_BUBBLE: '#D9FDD3'
|
|
12
12
|
};
|
|
13
|
-
/**
|
|
14
|
-
export const
|
|
15
|
-
export const
|
|
16
|
-
export const
|
|
17
|
-
export const
|
|
13
|
+
/** Card geometry from the design: 280px of content inside a 12px padding and a 1px border, border-box. */
|
|
14
|
+
export const WHATSAPP_CARD_WIDTH = 306;
|
|
15
|
+
export const WHATSAPP_CARD_PADDING = 12;
|
|
16
|
+
export const WHATSAPP_APP_BAR_GAP = 6;
|
|
17
|
+
export const WHATSAPP_APP_BAR_PADDING = {
|
|
18
|
+
vertical: 8,
|
|
19
|
+
horizontal: 12
|
|
20
|
+
};
|
|
21
|
+
export const WHATSAPP_MISSED_GLYPH_SIZE = 40;
|
|
22
|
+
export const WHATSAPP_MISSED_GAP = 12;
|
|
18
23
|
export const WHATSAPP_MEDIA_MAX_HEIGHT = 320;
|
|
19
|
-
/**
|
|
24
|
+
/** Play button and duration badge need room, so the video frame — not the poster — never draws shorter. */
|
|
20
25
|
export const WHATSAPP_MEDIA_MIN_HEIGHT = 48;
|
|
21
26
|
export const WHATSAPP_MEDIA_RADIUS = 4;
|
|
27
|
+
/** Unreachable media keeps the bubble at its full width instead of collapsing to a broken-image glyph. */
|
|
28
|
+
export const WHATSAPP_MEDIA_FALLBACK_HEIGHT = 160;
|
|
22
29
|
const IMAGE_EXTENSIONS = ['jpg', 'jpeg', 'png', 'gif', 'webp'];
|
|
23
30
|
const VIDEO_EXTENSIONS = ['mp4', 'mov', 'webm', '3gp'];
|
|
24
31
|
export const WHATSAPP_ATTACHMENT_EXTENSIONS = {
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export const messages = {
|
|
2
2
|
'DUMB.WHATSAPP_PREVIEW.DOCUMENT_PAGES': '{{count}} صفحة',
|
|
3
|
+
'DUMB.WHATSAPP_PREVIEW.DOCUMENT_ALT': 'معاينة المستند',
|
|
4
|
+
'DUMB.WHATSAPP_PREVIEW.IMAGE_ALT': 'صورة مرفقة',
|
|
5
|
+
'DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_TITLE': 'المحتوى غير متوفر',
|
|
6
|
+
'DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_HINT': 'قد تكون بيانات قديمة أو قوالب محذوفة',
|
|
3
7
|
'DUMB.WHATSAPP_PREVIEW.EMPTY': 'الرسالة فارغة…'
|
|
4
8
|
};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export const messages = {
|
|
2
2
|
'DUMB.WHATSAPP_PREVIEW.DOCUMENT_PAGES': '{{count}}টি পৃষ্ঠা',
|
|
3
|
+
'DUMB.WHATSAPP_PREVIEW.DOCUMENT_ALT': 'ডকুমেন্ট প্রিভিউ',
|
|
4
|
+
'DUMB.WHATSAPP_PREVIEW.IMAGE_ALT': 'সংযুক্ত ছবি',
|
|
5
|
+
'DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_TITLE': 'কন্টেন্ট পাওয়া যায়নি',
|
|
6
|
+
'DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_HINT': 'সম্ভবত এটি পুরোনো ডেটা বা মুছে ফেলা প্রিসেট',
|
|
3
7
|
'DUMB.WHATSAPP_PREVIEW.EMPTY': 'বার্তাটি খালি…'
|
|
4
8
|
};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export const messages = {
|
|
2
2
|
'DUMB.WHATSAPP_PREVIEW.DOCUMENT_PAGES': '{{count}} {{count | pluralize: "Seite", "Seiten"}}',
|
|
3
|
+
'DUMB.WHATSAPP_PREVIEW.DOCUMENT_ALT': 'Dokumentvorschau',
|
|
4
|
+
'DUMB.WHATSAPP_PREVIEW.IMAGE_ALT': 'Angehängtes Bild',
|
|
5
|
+
'DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_TITLE': 'Inhalt fehlt',
|
|
6
|
+
'DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_HINT': 'Möglicherweise alte Daten oder gelöschte Vorlagen',
|
|
3
7
|
'DUMB.WHATSAPP_PREVIEW.EMPTY': 'Die Nachricht ist leer…'
|
|
4
8
|
};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export const messages = {
|
|
2
2
|
'DUMB.WHATSAPP_PREVIEW.DOCUMENT_PAGES': '{{count}} {{count | pluralize: "page", "pages"}}',
|
|
3
|
+
'DUMB.WHATSAPP_PREVIEW.DOCUMENT_ALT': 'Document preview',
|
|
4
|
+
'DUMB.WHATSAPP_PREVIEW.IMAGE_ALT': 'Attached image',
|
|
5
|
+
'DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_TITLE': 'Content missed',
|
|
6
|
+
'DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_HINT': 'Might be old data or deleted presets',
|
|
3
7
|
'DUMB.WHATSAPP_PREVIEW.EMPTY': 'Message is empty…'
|
|
4
8
|
};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export const messages = {
|
|
2
2
|
'DUMB.WHATSAPP_PREVIEW.DOCUMENT_PAGES': '{{count}} {{count | pluralize: "página", "páginas"}}',
|
|
3
|
+
'DUMB.WHATSAPP_PREVIEW.DOCUMENT_ALT': 'Vista previa del documento',
|
|
4
|
+
'DUMB.WHATSAPP_PREVIEW.IMAGE_ALT': 'Imagen adjunta',
|
|
5
|
+
'DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_TITLE': 'Contenido no disponible',
|
|
6
|
+
'DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_HINT': 'Puede tratarse de datos antiguos o plantillas eliminadas',
|
|
3
7
|
'DUMB.WHATSAPP_PREVIEW.EMPTY': 'El mensaje está vacío…'
|
|
4
8
|
};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export const messages = {
|
|
2
2
|
'DUMB.WHATSAPP_PREVIEW.DOCUMENT_PAGES': '{{count}} {{count | pluralize: "page", "pages"}}',
|
|
3
|
+
'DUMB.WHATSAPP_PREVIEW.DOCUMENT_ALT': 'Aperçu du document',
|
|
4
|
+
'DUMB.WHATSAPP_PREVIEW.IMAGE_ALT': 'Image jointe',
|
|
5
|
+
'DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_TITLE': 'Contenu indisponible',
|
|
6
|
+
'DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_HINT': 'Il s’agit peut-être d’anciennes données ou de modèles supprimés',
|
|
3
7
|
'DUMB.WHATSAPP_PREVIEW.EMPTY': 'Le message est vide…'
|
|
4
8
|
};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export const messages = {
|
|
2
2
|
'DUMB.WHATSAPP_PREVIEW.DOCUMENT_PAGES': '{{count}} עמודים',
|
|
3
|
+
'DUMB.WHATSAPP_PREVIEW.DOCUMENT_ALT': 'תצוגה מקדימה של המסמך',
|
|
4
|
+
'DUMB.WHATSAPP_PREVIEW.IMAGE_ALT': 'תמונה מצורפת',
|
|
5
|
+
'DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_TITLE': 'התוכן אינו זמין',
|
|
6
|
+
'DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_HINT': 'ייתכן שמדובר בנתונים ישנים או בתבניות שנמחקו',
|
|
3
7
|
'DUMB.WHATSAPP_PREVIEW.EMPTY': 'ההודעה ריקה…'
|
|
4
8
|
};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export const messages = {
|
|
2
2
|
'DUMB.WHATSAPP_PREVIEW.DOCUMENT_PAGES': '{{count}} पृष्ठ',
|
|
3
|
+
'DUMB.WHATSAPP_PREVIEW.DOCUMENT_ALT': 'दस्तावेज़ पूर्वावलोकन',
|
|
4
|
+
'DUMB.WHATSAPP_PREVIEW.IMAGE_ALT': 'संलग्न छवि',
|
|
5
|
+
'DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_TITLE': 'कॉन्टेंट उपलब्ध नहीं',
|
|
6
|
+
'DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_HINT': 'हो सकता है कि यह पुराना डेटा या हटाए गए प्रीसेट हों',
|
|
3
7
|
'DUMB.WHATSAPP_PREVIEW.EMPTY': 'संदेश खाली है…'
|
|
4
8
|
};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export const messages = {
|
|
2
2
|
'DUMB.WHATSAPP_PREVIEW.DOCUMENT_PAGES': '{{count}} ページ',
|
|
3
|
+
'DUMB.WHATSAPP_PREVIEW.DOCUMENT_ALT': 'ドキュメントのプレビュー',
|
|
4
|
+
'DUMB.WHATSAPP_PREVIEW.IMAGE_ALT': '添付画像',
|
|
5
|
+
'DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_TITLE': 'コンテンツがありません',
|
|
6
|
+
'DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_HINT': '古いデータか削除されたプリセットの可能性があります',
|
|
3
7
|
'DUMB.WHATSAPP_PREVIEW.EMPTY': 'メッセージが空です…'
|
|
4
8
|
};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export const messages = {
|
|
2
2
|
'DUMB.WHATSAPP_PREVIEW.DOCUMENT_PAGES': '{{count}}페이지',
|
|
3
|
+
'DUMB.WHATSAPP_PREVIEW.DOCUMENT_ALT': '문서 미리보기',
|
|
4
|
+
'DUMB.WHATSAPP_PREVIEW.IMAGE_ALT': '첨부된 이미지',
|
|
5
|
+
'DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_TITLE': '콘텐츠를 찾을 수 없음',
|
|
6
|
+
'DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_HINT': '오래된 데이터이거나 삭제된 프리셋일 수 있습니다',
|
|
3
7
|
'DUMB.WHATSAPP_PREVIEW.EMPTY': '메시지가 비어 있습니다…'
|
|
4
8
|
};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export const messages = {
|
|
2
2
|
'DUMB.WHATSAPP_PREVIEW.DOCUMENT_PAGES': '{{count}} {{count | pluralize: "página", "páginas"}}',
|
|
3
|
+
'DUMB.WHATSAPP_PREVIEW.DOCUMENT_ALT': 'Pré-visualização do documento',
|
|
4
|
+
'DUMB.WHATSAPP_PREVIEW.IMAGE_ALT': 'Imagem anexada',
|
|
5
|
+
'DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_TITLE': 'Conteúdo indisponível',
|
|
6
|
+
'DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_HINT': 'Podem ser dados antigos ou modelos excluídos',
|
|
3
7
|
'DUMB.WHATSAPP_PREVIEW.EMPTY': 'A mensagem está vazia…'
|
|
4
8
|
};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export const messages = {
|
|
2
2
|
'DUMB.WHATSAPP_PREVIEW.DOCUMENT_PAGES': '{{count}} {{count | pluralize: "страница", "страницы", "страниц"}}',
|
|
3
|
+
'DUMB.WHATSAPP_PREVIEW.DOCUMENT_ALT': 'Превью документа',
|
|
4
|
+
'DUMB.WHATSAPP_PREVIEW.IMAGE_ALT': 'Вложенное изображение',
|
|
5
|
+
'DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_TITLE': 'Контент недоступен',
|
|
6
|
+
'DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_HINT': 'Возможно, это старые данные или удалённые пресеты',
|
|
3
7
|
'DUMB.WHATSAPP_PREVIEW.EMPTY': 'Сообщение пустое…'
|
|
4
8
|
};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export const messages = {
|
|
2
2
|
'DUMB.WHATSAPP_PREVIEW.DOCUMENT_PAGES': '{{count}} หน้า',
|
|
3
|
+
'DUMB.WHATSAPP_PREVIEW.DOCUMENT_ALT': 'ตัวอย่างเอกสาร',
|
|
4
|
+
'DUMB.WHATSAPP_PREVIEW.IMAGE_ALT': 'รูปภาพที่แนบ',
|
|
5
|
+
'DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_TITLE': 'ไม่พบเนื้อหา',
|
|
6
|
+
'DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_HINT': 'อาจเป็นข้อมูลเก่าหรือพรีเซ็ตที่ถูกลบ',
|
|
3
7
|
'DUMB.WHATSAPP_PREVIEW.EMPTY': 'ข้อความว่างเปล่า…'
|
|
4
8
|
};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export const messages = {
|
|
2
2
|
'DUMB.WHATSAPP_PREVIEW.DOCUMENT_PAGES': '{{count}} 页',
|
|
3
|
+
'DUMB.WHATSAPP_PREVIEW.DOCUMENT_ALT': '文档预览',
|
|
4
|
+
'DUMB.WHATSAPP_PREVIEW.IMAGE_ALT': '附件图片',
|
|
5
|
+
'DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_TITLE': '内容不可用',
|
|
6
|
+
'DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_HINT': '可能是旧数据或已删除的模板',
|
|
3
7
|
'DUMB.WHATSAPP_PREVIEW.EMPTY': '消息为空…'
|
|
4
8
|
};
|
|
@@ -3,5 +3,9 @@ export type WhatsAppPreviewMessages = {
|
|
|
3
3
|
'DUMB.WHATSAPP_PREVIEW.DOCUMENT_PAGES': {
|
|
4
4
|
count: number;
|
|
5
5
|
};
|
|
6
|
+
'DUMB.WHATSAPP_PREVIEW.DOCUMENT_ALT': NoParams;
|
|
7
|
+
'DUMB.WHATSAPP_PREVIEW.IMAGE_ALT': NoParams;
|
|
8
|
+
'DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_TITLE': NoParams;
|
|
9
|
+
'DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_HINT': NoParams;
|
|
6
10
|
'DUMB.WHATSAPP_PREVIEW.EMPTY': NoParams;
|
|
7
11
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Color, ShapeRadius } from '@pushwoosh/kit-constants';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const Card: import("styled-components").StyledComponent<"div", any, import("@pushwoosh/kit-helpers/styled-helpers").CommonBoxProps & {
|
|
3
3
|
$alignContent?: import("@pushwoosh/kit-helpers/styled-helpers").AlignContentValue | undefined;
|
|
4
4
|
$alignItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue | undefined;
|
|
5
5
|
$gap?: import("@pushwoosh/kit-helpers/styled-helpers").StrNum | undefined;
|
|
@@ -10,8 +10,67 @@ export declare const Backdrop: import("styled-components").StyledComponent<"div"
|
|
|
10
10
|
$placeItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue | undefined;
|
|
11
11
|
} & {
|
|
12
12
|
$gridAutoFlow: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
13
|
+
} & {
|
|
14
|
+
$alignContent: string;
|
|
15
|
+
$bgColor: Color;
|
|
16
|
+
$border: string;
|
|
17
|
+
$borderRadius: ShapeRadius;
|
|
18
|
+
$gap: number;
|
|
19
|
+
$padding: number;
|
|
20
|
+
$width: number;
|
|
21
|
+
}, "$gridAutoFlow" | "$bgColor" | "$border" | "$borderRadius" | "$padding" | "$width" | "$alignContent" | "$gap">;
|
|
22
|
+
export declare const PreviewText: import("styled-components").StyledComponent<"span", any, {
|
|
23
|
+
$color?: string | undefined;
|
|
24
|
+
$uppercase?: boolean | undefined;
|
|
25
|
+
$ellipsis?: boolean | undefined;
|
|
26
|
+
$variant?: import("@pushwoosh/kit-typography").TypographyVariant | undefined;
|
|
27
|
+
}, never>;
|
|
28
|
+
export declare const AppBar: import("styled-components").StyledComponent<"div", any, import("@pushwoosh/kit-helpers/styled-helpers").CommonBoxProps & {
|
|
29
|
+
$alignContent?: import("@pushwoosh/kit-helpers/styled-helpers").AlignContentValue | undefined;
|
|
30
|
+
$alignItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue | undefined;
|
|
31
|
+
$gap?: import("@pushwoosh/kit-helpers/styled-helpers").StrNum | undefined;
|
|
32
|
+
$justifyContent?: import("@pushwoosh/kit-helpers/styled-helpers").JustifyContentValue | undefined;
|
|
33
|
+
} & {
|
|
34
|
+
$gridAutoFlow?: "row" | "column" | "dense" | "row dense" | "column dense" | undefined;
|
|
35
|
+
$justifyItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue | undefined;
|
|
36
|
+
$placeItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue | undefined;
|
|
37
|
+
} & {
|
|
38
|
+
$gridAutoFlow: string;
|
|
39
|
+
} & {
|
|
40
|
+
$alignItems: string;
|
|
41
|
+
$justifyContent: string;
|
|
42
|
+
$gap: number;
|
|
43
|
+
$padding: {
|
|
44
|
+
vertical: number;
|
|
45
|
+
horizontal: number;
|
|
46
|
+
};
|
|
47
|
+
}, "$gridAutoFlow" | "$padding" | "$alignItems" | "$gap" | "$justifyContent">;
|
|
48
|
+
export declare const AppName: import("styled-components").StyledComponent<"span", any, {
|
|
49
|
+
$color?: string | undefined;
|
|
50
|
+
$uppercase?: boolean | undefined;
|
|
51
|
+
$ellipsis?: boolean | undefined;
|
|
52
|
+
$variant?: import("@pushwoosh/kit-typography").TypographyVariant | undefined;
|
|
53
|
+
} & {
|
|
54
|
+
$color: Color;
|
|
55
|
+
$ellipsis: boolean;
|
|
56
|
+
}, "$color" | "$ellipsis">;
|
|
57
|
+
export declare const MissedRow: import("styled-components").StyledComponent<"div", any, import("@pushwoosh/kit-helpers/styled-helpers").CommonBoxProps & {
|
|
58
|
+
$alignContent?: import("@pushwoosh/kit-helpers/styled-helpers").AlignContentValue | undefined;
|
|
59
|
+
$alignItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue | undefined;
|
|
60
|
+
$gap?: import("@pushwoosh/kit-helpers/styled-helpers").StrNum | undefined;
|
|
61
|
+
$justifyContent?: import("@pushwoosh/kit-helpers/styled-helpers").JustifyContentValue | undefined;
|
|
62
|
+
} & {
|
|
63
|
+
$gridAutoFlow?: "row" | "column" | "dense" | "row dense" | "column dense" | undefined;
|
|
64
|
+
$justifyItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue | undefined;
|
|
65
|
+
$placeItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue | undefined;
|
|
66
|
+
} & {
|
|
67
|
+
$sizes: import("@pushwoosh/kit-helpers/styled-helpers").StrNum;
|
|
68
|
+
} & {
|
|
69
|
+
$alignItems: string;
|
|
70
|
+
$gap: number;
|
|
71
|
+
$sizes: string;
|
|
72
|
+
}, "$alignItems" | "$gap" | "$sizes">;
|
|
73
|
+
export declare const MissedGlyph: import("styled-components").StyledComponent<"div", any, import("@pushwoosh/kit-helpers/styled-helpers").CommonBoxProps & {
|
|
15
74
|
$alignContent?: import("@pushwoosh/kit-helpers/styled-helpers").AlignContentValue | undefined;
|
|
16
75
|
$alignItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue | undefined;
|
|
17
76
|
$gap?: import("@pushwoosh/kit-helpers/styled-helpers").StrNum | undefined;
|
|
@@ -23,16 +82,27 @@ export declare const Bubble: import("styled-components").StyledComponent<"div",
|
|
|
23
82
|
} & {
|
|
24
83
|
$gridAutoFlow: string;
|
|
25
84
|
} & {
|
|
85
|
+
$alignItems: string;
|
|
86
|
+
$justifyContent: string;
|
|
26
87
|
$bgColor: Color;
|
|
27
|
-
$border: string;
|
|
28
88
|
$borderRadius: ShapeRadius;
|
|
29
|
-
$gap: number;
|
|
30
|
-
$padding: number;
|
|
31
89
|
$width: number;
|
|
32
|
-
|
|
33
|
-
|
|
90
|
+
$height: number;
|
|
91
|
+
}, "$gridAutoFlow" | "$bgColor" | "$borderRadius" | "$height" | "$width" | "$alignItems" | "$justifyContent">;
|
|
92
|
+
export declare const MissedTitle: import("styled-components").StyledComponent<"span", any, {
|
|
34
93
|
$color?: string | undefined;
|
|
35
94
|
$uppercase?: boolean | undefined;
|
|
36
95
|
$ellipsis?: boolean | undefined;
|
|
37
96
|
$variant?: import("@pushwoosh/kit-typography").TypographyVariant | undefined;
|
|
38
|
-
}
|
|
97
|
+
} & {
|
|
98
|
+
$color: Color;
|
|
99
|
+
$ellipsis: boolean;
|
|
100
|
+
}, "$color" | "$ellipsis">;
|
|
101
|
+
export declare const MissedHint: import("styled-components").StyledComponent<"span", any, {
|
|
102
|
+
$color?: string | undefined;
|
|
103
|
+
$uppercase?: boolean | undefined;
|
|
104
|
+
$ellipsis?: boolean | undefined;
|
|
105
|
+
$variant?: import("@pushwoosh/kit-typography").TypographyVariant | undefined;
|
|
106
|
+
} & {
|
|
107
|
+
$color: Color;
|
|
108
|
+
}, "$color">;
|
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
import styled from 'styled-components';
|
|
2
|
-
import { Color, Shadow, ShapeRadius } from '@pushwoosh/kit-constants';
|
|
3
|
-
import { Vertical } from '@pushwoosh/kit-helpers';
|
|
2
|
+
import { Color, FontFamily, FontSize, FontWeight, Shadow, ShapeRadius } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { Columns, Horizontal, Vertical } from '@pushwoosh/kit-helpers';
|
|
4
4
|
import { Text } from '@pushwoosh/kit-typography';
|
|
5
|
-
import {
|
|
6
|
-
export const
|
|
7
|
-
|
|
8
|
-
componentId: "sc-15y0kbp-0"
|
|
9
|
-
})(["-webkit-font-smoothing:antialiased;&,*{box-sizing:border-box;}"]);
|
|
10
|
-
export const Bubble = styled(Vertical).attrs({
|
|
5
|
+
import { WHATSAPP_APP_BAR_GAP, WHATSAPP_APP_BAR_PADDING, WHATSAPP_CARD_PADDING, WHATSAPP_CARD_WIDTH, WHATSAPP_MISSED_GAP, WHATSAPP_MISSED_GLYPH_SIZE } from './constants';
|
|
6
|
+
export const Card = styled(Vertical).attrs({
|
|
7
|
+
$alignContent: 'start',
|
|
11
8
|
$bgColor: Color.CLEAR,
|
|
12
9
|
$border: `1px solid ${Color.DIVIDER}`,
|
|
13
10
|
$borderRadius: ShapeRadius.SECTION,
|
|
14
|
-
$gap:
|
|
15
|
-
$padding:
|
|
16
|
-
$width:
|
|
11
|
+
$gap: WHATSAPP_CARD_PADDING,
|
|
12
|
+
$padding: WHATSAPP_CARD_PADDING,
|
|
13
|
+
$width: WHATSAPP_CARD_WIDTH
|
|
17
14
|
}).withConfig({
|
|
18
|
-
displayName: "
|
|
19
|
-
componentId: "sc-15y0kbp-
|
|
20
|
-
})(["box-shadow:", ";overflow-wrap:anywhere;"], Shadow.LARGE);
|
|
15
|
+
displayName: "Card",
|
|
16
|
+
componentId: "sc-15y0kbp-0"
|
|
17
|
+
})(["-webkit-font-smoothing:antialiased;box-shadow:", ";overflow-wrap:anywhere;&,*{box-sizing:border-box;}"], Shadow.LARGE);
|
|
21
18
|
// styled-components merges attrs OVER incoming props, so a plain object here would
|
|
22
19
|
// silently clobber every call-site `$color`; the callback keeps MAIN as a default only.
|
|
23
20
|
export const PreviewText = styled(Text).attrs(props => ({
|
|
@@ -25,5 +22,53 @@ export const PreviewText = styled(Text).attrs(props => ({
|
|
|
25
22
|
$color: props.$color ?? Color.MAIN
|
|
26
23
|
})).withConfig({
|
|
27
24
|
displayName: "PreviewText",
|
|
25
|
+
componentId: "sc-15y0kbp-1"
|
|
26
|
+
})(["overflow:hidden;line-height:18px;text-overflow:ellipsis;"]);
|
|
27
|
+
export const AppBar = styled(Horizontal).attrs({
|
|
28
|
+
$alignItems: 'center',
|
|
29
|
+
$justifyContent: 'start',
|
|
30
|
+
$gap: WHATSAPP_APP_BAR_GAP,
|
|
31
|
+
$padding: WHATSAPP_APP_BAR_PADDING
|
|
32
|
+
}).withConfig({
|
|
33
|
+
displayName: "AppBar",
|
|
28
34
|
componentId: "sc-15y0kbp-2"
|
|
29
|
-
})(["
|
|
35
|
+
})(["margin:-", "px -", "px 0;border-bottom:1px solid ", ";color:", ";svg{display:block;}"], WHATSAPP_CARD_PADDING, WHATSAPP_CARD_PADDING, Color.DIVIDER, Color.SUCCESS);
|
|
36
|
+
export const AppName = styled(Text).attrs({
|
|
37
|
+
$color: Color.MAIN,
|
|
38
|
+
$ellipsis: true
|
|
39
|
+
}).withConfig({
|
|
40
|
+
displayName: "AppName",
|
|
41
|
+
componentId: "sc-15y0kbp-3"
|
|
42
|
+
})(["overflow:hidden;font-family:", ";font-size:", ";font-style:normal;font-weight:", ";line-height:18px;text-overflow:ellipsis;"], FontFamily.MAIN, FontSize.SMALL, FontWeight.MEDIUM);
|
|
43
|
+
export const MissedRow = styled(Columns).attrs({
|
|
44
|
+
$alignItems: 'center',
|
|
45
|
+
$gap: WHATSAPP_MISSED_GAP,
|
|
46
|
+
$sizes: `${WHATSAPP_MISSED_GLYPH_SIZE}px minmax(0, 1fr)`
|
|
47
|
+
}).withConfig({
|
|
48
|
+
displayName: "MissedRow",
|
|
49
|
+
componentId: "sc-15y0kbp-4"
|
|
50
|
+
})([""]);
|
|
51
|
+
export const MissedGlyph = styled(Horizontal).attrs({
|
|
52
|
+
$alignItems: 'center',
|
|
53
|
+
$justifyContent: 'center',
|
|
54
|
+
$bgColor: Color.FROZEN,
|
|
55
|
+
$borderRadius: ShapeRadius.SECTION,
|
|
56
|
+
$width: WHATSAPP_MISSED_GLYPH_SIZE,
|
|
57
|
+
$height: WHATSAPP_MISSED_GLYPH_SIZE
|
|
58
|
+
}).withConfig({
|
|
59
|
+
displayName: "MissedGlyph",
|
|
60
|
+
componentId: "sc-15y0kbp-5"
|
|
61
|
+
})(["color:", ";svg{display:block;}"], Color.LOCKED);
|
|
62
|
+
export const MissedTitle = styled(Text).attrs({
|
|
63
|
+
$color: Color.MAIN,
|
|
64
|
+
$ellipsis: true
|
|
65
|
+
}).withConfig({
|
|
66
|
+
displayName: "MissedTitle",
|
|
67
|
+
componentId: "sc-15y0kbp-6"
|
|
68
|
+
})(["overflow:hidden;font-family:", ";font-size:", ";font-weight:", ";line-height:18px;text-overflow:ellipsis;"], FontFamily.MAIN, FontSize.SMALL, FontWeight.MEDIUM);
|
|
69
|
+
export const MissedHint = styled(Text).attrs({
|
|
70
|
+
$color: Color.LOCKED
|
|
71
|
+
}).withConfig({
|
|
72
|
+
displayName: "MissedHint",
|
|
73
|
+
componentId: "sc-15y0kbp-7"
|
|
74
|
+
})(["font-family:", ";font-size:", ";font-weight:", ";line-height:18px;"], FontFamily.MAIN, FontSize.SMALL, FontWeight.REGULAR);
|
|
@@ -37,4 +37,8 @@ export interface WhatsAppPreviewProps {
|
|
|
37
37
|
emptyText?: ReactNode;
|
|
38
38
|
/** Show the loading placeholder instead of the messages. */
|
|
39
39
|
isLoading?: boolean;
|
|
40
|
+
/** Application the message is sent from; drawn as the card header, which is skipped without it. */
|
|
41
|
+
applicationName?: string;
|
|
42
|
+
/** Draw the unavailable-content row instead of the message: the address is stale or invalid. */
|
|
43
|
+
isContentMissing?: boolean;
|
|
40
44
|
}
|
package/package.json
CHANGED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { type ReactElement } from 'react';
|
|
2
|
-
import type { WhatsAppMessageBubbleProps } from './types';
|
|
3
|
-
/** Single chat bubble: attachments on top, message body underneath. */
|
|
4
|
-
export declare function WhatsAppMessageBubble(props: WhatsAppMessageBubbleProps): ReactElement;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { WhatsAppMessageBubble } from './WhatsAppMessageBubble';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { WhatsAppMessageBubble } from './WhatsAppMessageBubble';
|
/package/WhatsAppPreview/components/{WhatsAppMessageBubble → WhatsAppMessageContent}/types.js
RENAMED
|
File without changes
|