@pushwoosh/dumb-components 4.13.1 → 4.14.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.
@@ -3,7 +3,7 @@ import { Color } from '@pushwoosh/kit-constants';
3
3
  import { Horizontal, Vertical } from '@pushwoosh/kit-helpers';
4
4
  import { CloseIcon, WhatsappIcon } from '@pushwoosh/kit-icons';
5
5
  import { WhatsAppMessageContent } from './components/WhatsAppMessageContent';
6
- import { WHATSAPP_CARD_PADDING } from './constants';
6
+ import { WHATSAPP_CARD_PADDING, WHATSAPP_CARD_WIDTH } from './constants';
7
7
  import { isMessageDrawable } from './helpers';
8
8
  import { Lang } from './polyglot';
9
9
  import { AppBar, AppName, Backdrop, Card, MissedGlyph, MissedHint, MissedRow, MissedTitle, PreviewText } from './styles';
@@ -15,51 +15,54 @@ export function WhatsAppPreview(props) {
15
15
  emptyText,
16
16
  isLoading = false,
17
17
  applicationName,
18
- isContentMissing = false
18
+ isContentMissing = false,
19
+ width
19
20
  } = props;
20
21
  const isDrawable = !isContentMissing && message !== undefined && isMessageDrawable(message);
21
- return _jsx(Backdrop, {
22
- children: _jsxs(Card, {
23
- children: [applicationName && _jsxs(AppBar, {
24
- children: [_jsx(WhatsappIcon, {
25
- size: "small",
26
- view: "filled"
27
- }), _jsx(AppName, {
28
- children: applicationName
29
- })]
30
- }), isLoading && _jsx(Horizontal, {
31
- "$alignItems": "center",
32
- "$justifyContent": "center",
33
- "$padding": WHATSAPP_CARD_PADDING,
34
- children: _jsx(Spinner, {
35
- color: Color.LOCKED,
22
+ const card = _jsxs(Card, {
23
+ "$width": width ?? WHATSAPP_CARD_WIDTH,
24
+ children: [applicationName && _jsxs(AppBar, {
25
+ children: [_jsx(WhatsappIcon, {
26
+ size: "small",
27
+ view: "filled"
28
+ }), _jsx(AppName, {
29
+ children: applicationName
30
+ })]
31
+ }), isLoading && _jsx(Horizontal, {
32
+ "$alignItems": "center",
33
+ "$justifyContent": "center",
34
+ "$padding": WHATSAPP_CARD_PADDING,
35
+ children: _jsx(Spinner, {
36
+ color: Color.LOCKED,
37
+ size: "medium"
38
+ })
39
+ }), !isLoading && isContentMissing && _jsxs(MissedRow, {
40
+ children: [_jsx(MissedGlyph, {
41
+ children: _jsx(CloseIcon, {
36
42
  size: "medium"
37
43
  })
38
- }), !isLoading && isContentMissing && _jsxs(MissedRow, {
39
- children: [_jsx(MissedGlyph, {
40
- children: _jsx(CloseIcon, {
41
- size: "medium"
44
+ }), _jsxs(Vertical, {
45
+ children: [_jsx(MissedTitle, {
46
+ children: _jsx(Lang, {
47
+ message: "DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_TITLE"
48
+ })
49
+ }), _jsx(MissedHint, {
50
+ children: _jsx(Lang, {
51
+ message: "DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_HINT"
42
52
  })
43
- }), _jsxs(Vertical, {
44
- children: [_jsx(MissedTitle, {
45
- children: _jsx(Lang, {
46
- message: "DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_TITLE"
47
- })
48
- }), _jsx(MissedHint, {
49
- children: _jsx(Lang, {
50
- message: "DUMB.WHATSAPP_PREVIEW.CONTENT_MISSED_HINT"
51
- })
52
- })]
53
53
  })]
54
- }), !isLoading && !isContentMissing && !isDrawable && _jsx(PreviewText, {
55
- "$color": Color.LOCKED,
56
- "$ellipsis": true,
57
- children: emptyText ?? _jsx(Lang, {
58
- message: "DUMB.WHATSAPP_PREVIEW.EMPTY"
59
- })
60
- }), !isLoading && isDrawable && _jsx(WhatsAppMessageContent, {
61
- message: message
62
54
  })]
63
- })
55
+ }), !isLoading && !isContentMissing && !isDrawable && _jsx(PreviewText, {
56
+ "$color": Color.LOCKED,
57
+ "$ellipsis": true,
58
+ children: emptyText ?? _jsx(Lang, {
59
+ message: "DUMB.WHATSAPP_PREVIEW.EMPTY"
60
+ })
61
+ }), !isLoading && isDrawable && _jsx(WhatsAppMessageContent, {
62
+ message: message
63
+ })]
64
64
  });
65
+ return width === undefined ? _jsx(Backdrop, {
66
+ children: card
67
+ }) : card;
65
68
  }
@@ -2,7 +2,7 @@ import styled from 'styled-components';
2
2
  import { Color, FontFamily, FontSize, FontWeight, Shadow, ShapeRadius } from '@pushwoosh/kit-constants';
3
3
  import { Columns, Horizontal, Vertical } from '@pushwoosh/kit-helpers';
4
4
  import { Text } from '@pushwoosh/kit-typography';
5
- import { WHATSAPP_APP_BAR_GAP, WHATSAPP_BACKDROP_PADDING, WHATSAPP_BACKDROP_WIDTH, WHATSAPP_APP_BAR_PADDING, WHATSAPP_CARD_PADDING, WHATSAPP_CARD_WIDTH, WHATSAPP_MISSED_GAP, WHATSAPP_MISSED_GLYPH_SIZE } from './constants';
5
+ import { WHATSAPP_APP_BAR_GAP, WHATSAPP_BACKDROP_PADDING, WHATSAPP_BACKDROP_WIDTH, WHATSAPP_APP_BAR_PADDING, WHATSAPP_CARD_PADDING, WHATSAPP_MISSED_GAP, WHATSAPP_MISSED_GLYPH_SIZE } from './constants';
6
6
  export const Backdrop = styled(Vertical).attrs({
7
7
  $alignContent: 'start',
8
8
  $justifyItems: 'center',
@@ -20,12 +20,11 @@ export const Card = styled(Vertical).attrs({
20
20
  $border: `1px solid ${Color.DIVIDER}`,
21
21
  $borderRadius: ShapeRadius.SECTION,
22
22
  $gap: WHATSAPP_CARD_PADDING,
23
- $padding: WHATSAPP_CARD_PADDING,
24
- $width: WHATSAPP_CARD_WIDTH
23
+ $padding: WHATSAPP_CARD_PADDING
25
24
  }).withConfig({
26
25
  displayName: "Card",
27
26
  componentId: "sc-15y0kbp-1"
28
- })(["box-shadow:", ";overflow-wrap:anywhere;"], Shadow.LARGE);
27
+ })(["box-sizing:border-box;box-shadow:", ";overflow-wrap:anywhere;"], Shadow.LARGE);
29
28
  // styled-components merges attrs OVER incoming props, so a plain object here would
30
29
  // silently clobber every call-site `$color`; the callback keeps MAIN as a default only.
31
30
  export const PreviewText = styled(Text).attrs(props => ({
@@ -41,4 +41,6 @@ export interface WhatsAppPreviewProps {
41
41
  applicationName?: string;
42
42
  /** Draw the unavailable-content row instead of the message: the address is stale or invalid. */
43
43
  isContentMissing?: boolean;
44
+ /** CSS width of the card; when set, the card is drawn bare on the caller's background, without its own backdrop. */
45
+ width?: string | number;
44
46
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/dumb-components",
3
- "version": "4.13.1",
3
+ "version": "4.14.0",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
@@ -47,7 +47,7 @@
47
47
  "@lezer/highlight": "^1.2.1",
48
48
  "@pushwoosh/kit-constants": "^3.1.1",
49
49
  "@pushwoosh/kit-helpers": "^4.17.1",
50
- "@pushwoosh/kit-icons": "^2.3.15",
50
+ "@pushwoosh/kit-icons": "^3.0.1",
51
51
  "@pushwoosh/kit-typography": "^2.1.1",
52
52
  "@tippyjs/react": "^4.2.6",
53
53
  "@uiw/codemirror-themes": "^4.23.8",