@pushwoosh/dumb-components 4.11.0 → 4.12.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.
- package/ChatPreview/ChatPreview.js +4 -2
- package/ChatPreview/components/NativeMessage/NativeMessage.js +6 -4
- package/ChatPreview/components/NativeMessage/types.d.ts +2 -0
- package/ChatPreview/helpers.d.ts +2 -0
- package/ChatPreview/helpers.js +5 -0
- package/ChatPreview/types.d.ts +2 -0
- package/package.json +1 -1
|
@@ -12,7 +12,8 @@ export function ChatPreview(props) {
|
|
|
12
12
|
content,
|
|
13
13
|
status,
|
|
14
14
|
issues,
|
|
15
|
-
senderName
|
|
15
|
+
senderName,
|
|
16
|
+
name
|
|
16
17
|
} = props;
|
|
17
18
|
const look = CHAT_CHANNELS[channel];
|
|
18
19
|
const view = viewOf(channel, status);
|
|
@@ -25,7 +26,8 @@ export function ChatPreview(props) {
|
|
|
25
26
|
content: delivered,
|
|
26
27
|
dropped: dropped,
|
|
27
28
|
look: look,
|
|
28
|
-
rcs: channel === 'rcs' ? content.rcs : undefined
|
|
29
|
+
rcs: channel === 'rcs' ? content.rcs : undefined,
|
|
30
|
+
name: name
|
|
29
31
|
});
|
|
30
32
|
return _jsxs(Screen, {
|
|
31
33
|
"$skin": look.skin,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { Carousel, FlexBox } from './styles';
|
|
3
|
-
import {
|
|
3
|
+
import { altTextOf, cardsOf } from '../../helpers';
|
|
4
4
|
import { Lang } from '../../polyglot';
|
|
5
5
|
import { ChatCardView } from '../ChatCardView';
|
|
6
6
|
import { ChatText } from '../ChatText';
|
|
@@ -14,18 +14,20 @@ export function NativeMessage(props) {
|
|
|
14
14
|
content,
|
|
15
15
|
look,
|
|
16
16
|
dropped,
|
|
17
|
-
rcs
|
|
17
|
+
rcs,
|
|
18
|
+
name
|
|
18
19
|
} = props;
|
|
19
20
|
const cards = cardsOf(content);
|
|
20
21
|
if (content.type === 'custom_flex') {
|
|
22
|
+
const altText = altTextOf(content, name);
|
|
21
23
|
return _jsxs(FlexBox, {
|
|
22
24
|
children: [_jsx("strong", {
|
|
23
25
|
children: _jsx(Lang, {
|
|
24
26
|
message: "DUMB.CHAT_PREVIEW.FLEX"
|
|
25
27
|
})
|
|
26
|
-
}),
|
|
28
|
+
}), altText && _jsx(ChatText, {
|
|
27
29
|
markup: look.markup,
|
|
28
|
-
text:
|
|
30
|
+
text: altText
|
|
29
31
|
})]
|
|
30
32
|
});
|
|
31
33
|
}
|
package/ChatPreview/helpers.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export type ChatView = 'native'
|
|
|
8
8
|
export declare function viewOf(channel: ChatChannel, status: ChatCompatibility | undefined): ChatView;
|
|
9
9
|
/** Text the channel receives when it cannot render the content type. */
|
|
10
10
|
export declare function fallbackTextOf(content: ChatContent): string;
|
|
11
|
+
/** LINE's Flex alt text, as the backend builds it: the message or first card text, else the fallback, else the preset name. */
|
|
12
|
+
export declare function altTextOf(content: ChatContent, name?: string): string;
|
|
11
13
|
/** Buttons drawn below the bubble text: quick replies, call-to-action links and phone numbers. */
|
|
12
14
|
export declare function bubbleButtonsOf(content: ChatContent): ChatButton[];
|
|
13
15
|
/** Cards of a card or carousel message; a plain card is a one-slide carousel. */
|
package/ChatPreview/helpers.js
CHANGED
|
@@ -13,6 +13,11 @@ export function viewOf(channel, status) {
|
|
|
13
13
|
export function fallbackTextOf(content) {
|
|
14
14
|
return content.fallback || content.body || '';
|
|
15
15
|
}
|
|
16
|
+
/** LINE's Flex alt text, as the backend builds it: the message or first card text, else the fallback, else the preset name. */
|
|
17
|
+
export function altTextOf(content, name = '') {
|
|
18
|
+
const card = content.cards?.[0];
|
|
19
|
+
return content.body || card?.title || card?.body || content.fallback || name;
|
|
20
|
+
}
|
|
16
21
|
/** Buttons drawn below the bubble text: quick replies, call-to-action links and phone numbers. */
|
|
17
22
|
export function bubbleButtonsOf(content) {
|
|
18
23
|
return content.type === 'quick_reply' || content.type === 'call_to_action' ? content.buttons ?? [] : [];
|
package/ChatPreview/types.d.ts
CHANGED