@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.
@@ -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 { cardsOf, fallbackTextOf } from '../../helpers';
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
- }), fallbackTextOf(content) && _jsx(ChatText, {
28
+ }), altText && _jsx(ChatText, {
27
29
  markup: look.markup,
28
- text: fallbackTextOf(content)
30
+ text: altText
29
31
  })]
30
32
  });
31
33
  }
@@ -4,4 +4,6 @@ import type { ChatPartProps } from '../types';
4
4
  export type NativeMessageProps = ChatPartProps & {
5
5
  /** RCS card layout, passed only on RCS. */
6
6
  rcs?: ChatRcsLayout;
7
+ /** Preset name, the Flex alt text when the message carries no text. */
8
+ name?: string;
7
9
  };
@@ -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. */
@@ -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 ?? [] : [];
@@ -131,4 +131,6 @@ export interface ChatPreviewProps {
131
131
  issues?: ChatIssue[];
132
132
  /** Sender shown in the chat header. */
133
133
  senderName?: string;
134
+ /** Preset name: LINE's Flex alt text when the message carries no text. */
135
+ name?: string;
134
136
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/dumb-components",
3
- "version": "4.11.0",
3
+ "version": "4.12.0",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",