@pushwoosh/dumb-components 1.1.221 → 1.1.222
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/InboxPreview/InboxPreview.d.ts +13 -0
- package/InboxPreview/InboxPreview.js +82 -0
- package/InboxPreview/__tests__/helpers.test.d.ts +1 -0
- package/InboxPreview/__tests__/helpers.test.js +201 -0
- package/InboxPreview/components/InboxAndroidCell/InboxAndroidCell.d.ts +4 -0
- package/InboxPreview/components/InboxAndroidCell/InboxAndroidCell.js +70 -0
- package/InboxPreview/components/InboxAndroidCell/index.d.ts +1 -0
- package/InboxPreview/components/InboxAndroidCell/index.js +1 -0
- package/InboxPreview/components/InboxCellAvatar/InboxCellAvatar.d.ts +4 -0
- package/InboxPreview/components/InboxCellAvatar/InboxCellAvatar.js +48 -0
- package/InboxPreview/components/InboxCellAvatar/index.d.ts +1 -0
- package/InboxPreview/components/InboxCellAvatar/index.js +1 -0
- package/InboxPreview/components/InboxCellAvatar/styles.d.ts +1 -0
- package/InboxPreview/components/InboxCellAvatar/styles.js +5 -0
- package/InboxPreview/components/InboxCellAvatar/types.d.ts +10 -0
- package/InboxPreview/components/InboxCellAvatar/types.js +1 -0
- package/InboxPreview/components/InboxCellCarousel/InboxCellCarousel.d.ts +4 -0
- package/InboxPreview/components/InboxCellCarousel/InboxCellCarousel.js +53 -0
- package/InboxPreview/components/InboxCellCarousel/index.d.ts +1 -0
- package/InboxPreview/components/InboxCellCarousel/index.js +1 -0
- package/InboxPreview/components/InboxCellCarousel/styles.d.ts +29 -0
- package/InboxPreview/components/InboxCellCarousel/styles.js +24 -0
- package/InboxPreview/components/InboxCellCarousel/types.d.ts +8 -0
- package/InboxPreview/components/InboxCellCarousel/types.js +1 -0
- package/InboxPreview/components/InboxCellMedia/InboxCellMedia.d.ts +4 -0
- package/InboxPreview/components/InboxCellMedia/InboxCellMedia.js +26 -0
- package/InboxPreview/components/InboxCellMedia/index.d.ts +1 -0
- package/InboxPreview/components/InboxCellMedia/index.js +1 -0
- package/InboxPreview/components/InboxCellMedia/types.d.ts +12 -0
- package/InboxPreview/components/InboxCellMedia/types.js +1 -0
- package/InboxPreview/components/InboxIOSCell/InboxIOSCell.d.ts +4 -0
- package/InboxPreview/components/InboxIOSCell/InboxIOSCell.js +125 -0
- package/InboxPreview/components/InboxIOSCell/index.d.ts +1 -0
- package/InboxPreview/components/InboxIOSCell/index.js +1 -0
- package/InboxPreview/components/InboxWebCell/InboxWebCell.d.ts +4 -0
- package/InboxPreview/components/InboxWebCell/InboxWebCell.js +83 -0
- package/InboxPreview/components/InboxWebCell/index.d.ts +1 -0
- package/InboxPreview/components/InboxWebCell/index.js +1 -0
- package/InboxPreview/constants.d.ts +14 -0
- package/InboxPreview/constants.js +30 -0
- package/InboxPreview/helpers.d.ts +29 -0
- package/InboxPreview/helpers.js +75 -0
- package/InboxPreview/index.d.ts +4 -0
- package/InboxPreview/index.js +3 -0
- package/InboxPreview/polyglot/index.d.ts +2 -0
- package/InboxPreview/polyglot/index.js +34 -0
- package/InboxPreview/polyglot/messages_ar.d.ts +3 -0
- package/InboxPreview/polyglot/messages_ar.js +4 -0
- package/InboxPreview/polyglot/messages_bn.d.ts +3 -0
- package/InboxPreview/polyglot/messages_bn.js +4 -0
- package/InboxPreview/polyglot/messages_de.d.ts +3 -0
- package/InboxPreview/polyglot/messages_de.js +4 -0
- package/InboxPreview/polyglot/messages_en.d.ts +3 -0
- package/InboxPreview/polyglot/messages_en.js +4 -0
- package/InboxPreview/polyglot/messages_es.d.ts +3 -0
- package/InboxPreview/polyglot/messages_es.js +4 -0
- package/InboxPreview/polyglot/messages_fr.d.ts +3 -0
- package/InboxPreview/polyglot/messages_fr.js +4 -0
- package/InboxPreview/polyglot/messages_he.d.ts +3 -0
- package/InboxPreview/polyglot/messages_he.js +4 -0
- package/InboxPreview/polyglot/messages_hi.d.ts +3 -0
- package/InboxPreview/polyglot/messages_hi.js +4 -0
- package/InboxPreview/polyglot/messages_ja.d.ts +3 -0
- package/InboxPreview/polyglot/messages_ja.js +4 -0
- package/InboxPreview/polyglot/messages_ko.d.ts +3 -0
- package/InboxPreview/polyglot/messages_ko.js +4 -0
- package/InboxPreview/polyglot/messages_pt.d.ts +3 -0
- package/InboxPreview/polyglot/messages_pt.js +4 -0
- package/InboxPreview/polyglot/messages_ru.d.ts +3 -0
- package/InboxPreview/polyglot/messages_ru.js +4 -0
- package/InboxPreview/polyglot/messages_th.d.ts +3 -0
- package/InboxPreview/polyglot/messages_th.js +4 -0
- package/InboxPreview/polyglot/messages_zh.d.ts +3 -0
- package/InboxPreview/polyglot/messages_zh.js +4 -0
- package/InboxPreview/polyglot/types.d.ts +5 -0
- package/InboxPreview/polyglot/types.js +1 -0
- package/InboxPreview/styles.d.ts +25 -0
- package/InboxPreview/styles.js +21 -0
- package/InboxPreview/types.d.ts +74 -0
- package/InboxPreview/types.js +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Color, ShapeRadius } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { FlexContainer, Vertical } from '@pushwoosh/kit-helpers';
|
|
4
|
+
import { Text } from '@pushwoosh/kit-typography';
|
|
5
|
+
import { INBOX_CARD_EDGE_SHADOW, INBOX_UNREAD_DOT_SIZE } from '../../constants';
|
|
6
|
+
import { ClampText } from '../../styles';
|
|
7
|
+
import { InboxCellAvatar } from '../InboxCellAvatar';
|
|
8
|
+
import { InboxCellMedia } from '../InboxCellMedia';
|
|
9
|
+
/** iOS inbox cell: a rounded card, with the texts on a plate below the media in the media layouts. */
|
|
10
|
+
export function InboxIOSCell(props) {
|
|
11
|
+
const {
|
|
12
|
+
content,
|
|
13
|
+
layout,
|
|
14
|
+
isEmpty,
|
|
15
|
+
title,
|
|
16
|
+
body,
|
|
17
|
+
dateLabel,
|
|
18
|
+
unread
|
|
19
|
+
} = props;
|
|
20
|
+
const texts = _jsxs(Vertical, {
|
|
21
|
+
"$flex": 1,
|
|
22
|
+
"$gap": 2,
|
|
23
|
+
"$minWidth": 0,
|
|
24
|
+
children: [_jsxs(FlexContainer, {
|
|
25
|
+
"$alignItems": "center",
|
|
26
|
+
children: [_jsx(Text, {
|
|
27
|
+
"$color": Color.MAIN,
|
|
28
|
+
"$ellipsis": true,
|
|
29
|
+
"$variant": "h5",
|
|
30
|
+
children: title
|
|
31
|
+
}), _jsx(Vertical, {
|
|
32
|
+
"$flex": 1,
|
|
33
|
+
"$minWidth": 4
|
|
34
|
+
}), _jsx(Text, {
|
|
35
|
+
"$color": Color.LOCKED,
|
|
36
|
+
"$ellipsis": true,
|
|
37
|
+
"$variant": "footnote",
|
|
38
|
+
children: dateLabel
|
|
39
|
+
})]
|
|
40
|
+
}), !!body && _jsx(ClampText, {
|
|
41
|
+
"$clamp": layout === 'classic' ? 3 : undefined,
|
|
42
|
+
"$color": Color.LOCKED,
|
|
43
|
+
"$variant": "footnote",
|
|
44
|
+
children: body
|
|
45
|
+
})]
|
|
46
|
+
});
|
|
47
|
+
if (layout === 'classic') {
|
|
48
|
+
return _jsxs(FlexContainer, {
|
|
49
|
+
"$alignItems": "center",
|
|
50
|
+
"$bgColor": Color.CLEAR,
|
|
51
|
+
"$borderRadius": ShapeRadius.SECTION,
|
|
52
|
+
"$boxShadow": INBOX_CARD_EDGE_SHADOW,
|
|
53
|
+
"$gap": 8,
|
|
54
|
+
"$padding": {
|
|
55
|
+
top: 16,
|
|
56
|
+
right: 16,
|
|
57
|
+
bottom: 16,
|
|
58
|
+
left: 18
|
|
59
|
+
},
|
|
60
|
+
children: [unread && _jsx(Vertical, {
|
|
61
|
+
"$bgColor": Color.BRIGHT,
|
|
62
|
+
"$borderRadius": "50%",
|
|
63
|
+
"$height": INBOX_UNREAD_DOT_SIZE,
|
|
64
|
+
"$shrink": 0,
|
|
65
|
+
"$width": INBOX_UNREAD_DOT_SIZE
|
|
66
|
+
}), _jsx(InboxCellAvatar, {
|
|
67
|
+
content: content,
|
|
68
|
+
isEmpty: isEmpty,
|
|
69
|
+
platform: "ios"
|
|
70
|
+
}), texts]
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
const media = _jsx(InboxCellMedia, {
|
|
74
|
+
content: content,
|
|
75
|
+
isEmpty: isEmpty,
|
|
76
|
+
layout: layout
|
|
77
|
+
});
|
|
78
|
+
if (layout === 'banner') {
|
|
79
|
+
return _jsx(Vertical, {
|
|
80
|
+
"$bgColor": Color.CLEAR,
|
|
81
|
+
"$borderRadius": ShapeRadius.SECTION,
|
|
82
|
+
"$boxShadow": INBOX_CARD_EDGE_SHADOW,
|
|
83
|
+
"$gap": 5,
|
|
84
|
+
"$padding": 5,
|
|
85
|
+
children: _jsxs(Vertical, {
|
|
86
|
+
"$position": "relative",
|
|
87
|
+
children: [media, unread && _jsx(Vertical, {
|
|
88
|
+
"$bgColor": Color.BRIGHT,
|
|
89
|
+
"$borderRadius": "50%",
|
|
90
|
+
"$height": INBOX_UNREAD_DOT_SIZE,
|
|
91
|
+
"$left": 10,
|
|
92
|
+
"$position": "absolute",
|
|
93
|
+
"$shrink": 0,
|
|
94
|
+
"$top": 10,
|
|
95
|
+
"$width": INBOX_UNREAD_DOT_SIZE
|
|
96
|
+
})]
|
|
97
|
+
})
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
return _jsxs(Vertical, {
|
|
101
|
+
"$bgColor": Color.CLEAR,
|
|
102
|
+
"$borderRadius": ShapeRadius.SECTION,
|
|
103
|
+
"$boxShadow": INBOX_CARD_EDGE_SHADOW,
|
|
104
|
+
"$gap": 5,
|
|
105
|
+
"$padding": 5,
|
|
106
|
+
children: [media, _jsxs(FlexContainer, {
|
|
107
|
+
"$alignItems": "start",
|
|
108
|
+
"$bgColor": Color.FROZEN,
|
|
109
|
+
"$border": `1px solid ${Color.SOFT_LIGHT}`,
|
|
110
|
+
"$borderRadius": ShapeRadius.SECTION,
|
|
111
|
+
"$gap": 4,
|
|
112
|
+
"$padding": 8,
|
|
113
|
+
children: [unread && _jsx(Vertical, {
|
|
114
|
+
"$bgColor": Color.BRIGHT,
|
|
115
|
+
"$borderRadius": "50%",
|
|
116
|
+
"$height": INBOX_UNREAD_DOT_SIZE,
|
|
117
|
+
"$margin": {
|
|
118
|
+
top: 3.5
|
|
119
|
+
},
|
|
120
|
+
"$shrink": 0,
|
|
121
|
+
"$width": INBOX_UNREAD_DOT_SIZE
|
|
122
|
+
}), texts]
|
|
123
|
+
})]
|
|
124
|
+
});
|
|
125
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { InboxIOSCell } from './InboxIOSCell';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { InboxIOSCell } from './InboxIOSCell';
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Color } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { FlexContainer, Horizontal, Vertical } from '@pushwoosh/kit-helpers';
|
|
4
|
+
import { CloseIcon } from '@pushwoosh/kit-icons';
|
|
5
|
+
import { Text } from '@pushwoosh/kit-typography';
|
|
6
|
+
import { INBOX_UNREAD_DOT_SIZE } from '../../constants';
|
|
7
|
+
import { ClampText } from '../../styles';
|
|
8
|
+
import { InboxCellAvatar } from '../InboxCellAvatar';
|
|
9
|
+
import { InboxCellMedia } from '../InboxCellMedia';
|
|
10
|
+
/** Web widget cell: a dismissable card with the date under the texts. */
|
|
11
|
+
export function InboxWebCell(props) {
|
|
12
|
+
const {
|
|
13
|
+
content,
|
|
14
|
+
layout,
|
|
15
|
+
isEmpty,
|
|
16
|
+
title,
|
|
17
|
+
body,
|
|
18
|
+
dateLabel,
|
|
19
|
+
unread
|
|
20
|
+
} = props;
|
|
21
|
+
const texts = _jsxs(Vertical, {
|
|
22
|
+
"$flex": 1,
|
|
23
|
+
"$gap": 4,
|
|
24
|
+
"$minWidth": 0,
|
|
25
|
+
children: [_jsxs(FlexContainer, {
|
|
26
|
+
"$alignItems": "center",
|
|
27
|
+
"$gap": 6,
|
|
28
|
+
children: [_jsx(Text, {
|
|
29
|
+
"$color": Color.MAIN,
|
|
30
|
+
"$ellipsis": true,
|
|
31
|
+
"$variant": "h5",
|
|
32
|
+
children: title
|
|
33
|
+
}), unread && _jsx(Vertical, {
|
|
34
|
+
"$bgColor": Color.BRIGHT,
|
|
35
|
+
"$borderRadius": "50%",
|
|
36
|
+
"$height": INBOX_UNREAD_DOT_SIZE,
|
|
37
|
+
"$shrink": 0,
|
|
38
|
+
"$width": INBOX_UNREAD_DOT_SIZE
|
|
39
|
+
})]
|
|
40
|
+
}), !!body && _jsx(ClampText, {
|
|
41
|
+
"$color": Color.MAIN,
|
|
42
|
+
"$variant": "footnote",
|
|
43
|
+
children: body
|
|
44
|
+
}), _jsx(Text, {
|
|
45
|
+
"$color": Color.LOCKED,
|
|
46
|
+
"$ellipsis": true,
|
|
47
|
+
"$variant": "footnote",
|
|
48
|
+
children: dateLabel
|
|
49
|
+
})]
|
|
50
|
+
});
|
|
51
|
+
return _jsxs(Vertical, {
|
|
52
|
+
"$bgColor": Color.CLEAR,
|
|
53
|
+
"$gap": 12,
|
|
54
|
+
"$padding": 16,
|
|
55
|
+
"$position": "relative",
|
|
56
|
+
children: [_jsx(Horizontal, {
|
|
57
|
+
"$alignItems": "center",
|
|
58
|
+
"$justifyContent": "center",
|
|
59
|
+
"$position": "absolute",
|
|
60
|
+
"$right": 6,
|
|
61
|
+
"$top": 6,
|
|
62
|
+
children: _jsx(CloseIcon, {
|
|
63
|
+
color: Color.LOCKED,
|
|
64
|
+
size: "small"
|
|
65
|
+
})
|
|
66
|
+
}), layout === 'classic' ? _jsxs(FlexContainer, {
|
|
67
|
+
"$alignItems": "start",
|
|
68
|
+
"$gap": 14,
|
|
69
|
+
children: [_jsx(InboxCellAvatar, {
|
|
70
|
+
content: content,
|
|
71
|
+
isEmpty: isEmpty,
|
|
72
|
+
platform: "web"
|
|
73
|
+
}), texts]
|
|
74
|
+
}) : _jsxs(_Fragment, {
|
|
75
|
+
children: [_jsx(InboxCellMedia, {
|
|
76
|
+
content: content,
|
|
77
|
+
dotsOnImage: true,
|
|
78
|
+
isEmpty: isEmpty,
|
|
79
|
+
layout: layout
|
|
80
|
+
}), layout !== 'banner' && texts]
|
|
81
|
+
})]
|
|
82
|
+
});
|
|
83
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { InboxWebCell } from './InboxWebCell';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { InboxWebCell } from './InboxWebCell';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { InboxAvatarShape, InboxLayoutType, InboxPreviewPlatform } from './types';
|
|
2
|
+
/** The SDK renders at most this many carousel slides and silently drops the rest. */
|
|
3
|
+
export declare const MAX_CAROUSEL_SLIDES = 5;
|
|
4
|
+
/** Layouts the SDK knows; anything else falls back to the heuristic. */
|
|
5
|
+
export declare const KNOWN_LAYOUTS: readonly InboxLayoutType[];
|
|
6
|
+
export declare const INBOX_PREVIEW_MIN_WIDTH = 240;
|
|
7
|
+
export declare const INBOX_PREVIEW_MAX_WIDTH = 350;
|
|
8
|
+
export declare const INBOX_PREVIEW_SKELETON_HEIGHT = 56;
|
|
9
|
+
export declare const INBOX_UNREAD_DOT_SIZE = 6;
|
|
10
|
+
/** Card edge of the iOS cells and the scrim under a slide caption — chrome the design tokens do not cover. */
|
|
11
|
+
export declare const INBOX_CARD_EDGE_SHADOW = "inset -1px -1px 1px 0 rgba(0, 0, 0, 0.09), inset 1px 1px 1px 0 rgba(0, 0, 0, 0.09)";
|
|
12
|
+
export declare const INBOX_SLIDE_SCRIM = "rgba(0, 0, 0, 0.45)";
|
|
13
|
+
/** Icon geometry per platform: each SDK draws the inbox icon at its own size and initial size. */
|
|
14
|
+
export declare const INBOX_AVATAR: Record<InboxPreviewPlatform, InboxAvatarShape>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ShapeRadius } from '@pushwoosh/kit-constants';
|
|
2
|
+
/** The SDK renders at most this many carousel slides and silently drops the rest. */
|
|
3
|
+
export const MAX_CAROUSEL_SLIDES = 5;
|
|
4
|
+
/** Layouts the SDK knows; anything else falls back to the heuristic. */
|
|
5
|
+
export const KNOWN_LAYOUTS = ['classic', 'captioned', 'banner', 'carousel'];
|
|
6
|
+
export const INBOX_PREVIEW_MIN_WIDTH = 240;
|
|
7
|
+
export const INBOX_PREVIEW_MAX_WIDTH = 350;
|
|
8
|
+
export const INBOX_PREVIEW_SKELETON_HEIGHT = 56;
|
|
9
|
+
export const INBOX_UNREAD_DOT_SIZE = 6;
|
|
10
|
+
/** Card edge of the iOS cells and the scrim under a slide caption — chrome the design tokens do not cover. */
|
|
11
|
+
export const INBOX_CARD_EDGE_SHADOW = 'inset -1px -1px 1px 0 rgba(0, 0, 0, 0.09), inset 1px 1px 1px 0 rgba(0, 0, 0, 0.09)';
|
|
12
|
+
export const INBOX_SLIDE_SCRIM = 'rgba(0, 0, 0, 0.45)';
|
|
13
|
+
/** Icon geometry per platform: each SDK draws the inbox icon at its own size and initial size. */
|
|
14
|
+
export const INBOX_AVATAR = {
|
|
15
|
+
ios: {
|
|
16
|
+
size: 30,
|
|
17
|
+
radius: '50%',
|
|
18
|
+
initialVariant: 'h5'
|
|
19
|
+
},
|
|
20
|
+
android: {
|
|
21
|
+
size: 40,
|
|
22
|
+
radius: ShapeRadius.SECTION,
|
|
23
|
+
initialVariant: 'h4'
|
|
24
|
+
},
|
|
25
|
+
web: {
|
|
26
|
+
size: 52,
|
|
27
|
+
radius: ShapeRadius.SECTION,
|
|
28
|
+
initialVariant: 'h3'
|
|
29
|
+
}
|
|
30
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { InboxLayoutType, InboxPreviewContent, InboxPreviewSlide } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Picks the content to render: an explicit `content` wins, otherwise the
|
|
4
|
+
* `language` entry of `localizedContent` with default/en/first fallbacks.
|
|
5
|
+
*/
|
|
6
|
+
export declare const getPreviewContent: (content?: InboxPreviewContent | null, localizedContent?: Record<string, InboxPreviewContent>, language?: string) => InboxPreviewContent | null;
|
|
7
|
+
/** Keeps the slides the SDK would render: ones with an image, at most {@link MAX_CAROUSEL_SLIDES}. */
|
|
8
|
+
export declare const getValidSlides: (slides?: InboxPreviewSlide[]) => InboxPreviewSlide[];
|
|
9
|
+
/** Hero image of the banner/captioned layouts: the banner with the icon as fallback, like the SDK. */
|
|
10
|
+
export declare const getHeroUrl: (content: InboxPreviewContent) => string;
|
|
11
|
+
/**
|
|
12
|
+
* Resolves the layout the SDK would actually draw: the requested one when it can render,
|
|
13
|
+
* the SDK heuristic for unknown/absent layouts, and the classic degradation otherwise.
|
|
14
|
+
*/
|
|
15
|
+
export declare const resolveInboxLayout: (content: InboxPreviewContent) => InboxLayoutType;
|
|
16
|
+
/** True when the content has nothing to render yet, so the preview shows the layout placeholder. */
|
|
17
|
+
export declare const isEmptyContent: (content: InboxPreviewContent) => boolean;
|
|
18
|
+
/** The layout whose placeholder an empty preview shows: the requested one when known, else classic. */
|
|
19
|
+
export declare const getEmptyLayout: (content: InboxPreviewContent) => InboxLayoutType;
|
|
20
|
+
/**
|
|
21
|
+
* Title/body pair a cell renders: for the classic layout the body stands in for
|
|
22
|
+
* a missing title, like in the SDK.
|
|
23
|
+
*/
|
|
24
|
+
export declare const getPreviewTexts: (content: InboxPreviewContent, layout: InboxLayoutType) => {
|
|
25
|
+
title: string;
|
|
26
|
+
body: string;
|
|
27
|
+
};
|
|
28
|
+
/** The colored-initial fallback the SDK draws when classic has no icon. */
|
|
29
|
+
export declare const getIconInitial: (content: InboxPreviewContent) => string;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { KNOWN_LAYOUTS, MAX_CAROUSEL_SLIDES } from './constants';
|
|
2
|
+
/**
|
|
3
|
+
* Picks the content to render: an explicit `content` wins, otherwise the
|
|
4
|
+
* `language` entry of `localizedContent` with default/en/first fallbacks.
|
|
5
|
+
*/
|
|
6
|
+
export const getPreviewContent = (content, localizedContent, language) => {
|
|
7
|
+
if (content) {
|
|
8
|
+
return content;
|
|
9
|
+
}
|
|
10
|
+
if (!localizedContent || Object.keys(localizedContent).length === 0) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
if (language && localizedContent[language]) {
|
|
14
|
+
return localizedContent[language];
|
|
15
|
+
}
|
|
16
|
+
return localizedContent.default || localizedContent.en || localizedContent[Object.keys(localizedContent)[0]];
|
|
17
|
+
};
|
|
18
|
+
/** Keeps the slides the SDK would render: ones with an image, at most {@link MAX_CAROUSEL_SLIDES}. */
|
|
19
|
+
export const getValidSlides = slides => (slides || []).filter(slide => !!slide.imageUrl).slice(0, MAX_CAROUSEL_SLIDES);
|
|
20
|
+
/** Hero image of the banner/captioned layouts: the banner with the icon as fallback, like the SDK. */
|
|
21
|
+
export const getHeroUrl = content => content.bannerUrl || content.iconUrl || '';
|
|
22
|
+
/**
|
|
23
|
+
* Resolves the layout the SDK would actually draw: the requested one when it can render,
|
|
24
|
+
* the SDK heuristic for unknown/absent layouts, and the classic degradation otherwise.
|
|
25
|
+
*/
|
|
26
|
+
export const resolveInboxLayout = content => {
|
|
27
|
+
const hasTitle = !!content.title;
|
|
28
|
+
const hasBody = !!content.body;
|
|
29
|
+
const hero = getHeroUrl(content);
|
|
30
|
+
let requested = content.layoutType;
|
|
31
|
+
if (!KNOWN_LAYOUTS.includes(requested)) {
|
|
32
|
+
if (hero && !hasTitle) {
|
|
33
|
+
requested = 'banner';
|
|
34
|
+
} else if (hero && hasTitle && hasBody) {
|
|
35
|
+
requested = 'captioned';
|
|
36
|
+
} else {
|
|
37
|
+
requested = 'classic';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
switch (requested) {
|
|
41
|
+
case 'banner':
|
|
42
|
+
return hero ? 'banner' : 'classic';
|
|
43
|
+
case 'captioned':
|
|
44
|
+
return hero && hasTitle && hasBody ? 'captioned' : 'classic';
|
|
45
|
+
case 'carousel':
|
|
46
|
+
return hasTitle && hasBody && getValidSlides(content.carousel).length > 0 ? 'carousel' : 'classic';
|
|
47
|
+
default:
|
|
48
|
+
return 'classic';
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
/** True when the content has nothing to render yet, so the preview shows the layout placeholder. */
|
|
52
|
+
export const isEmptyContent = content => !content.title && !content.body && !content.iconUrl && !content.bannerUrl && getValidSlides(content.carousel).length === 0;
|
|
53
|
+
/** The layout whose placeholder an empty preview shows: the requested one when known, else classic. */
|
|
54
|
+
export const getEmptyLayout = content => {
|
|
55
|
+
const requested = content.layoutType;
|
|
56
|
+
return KNOWN_LAYOUTS.includes(requested) ? requested : 'classic';
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Title/body pair a cell renders: for the classic layout the body stands in for
|
|
60
|
+
* a missing title, like in the SDK.
|
|
61
|
+
*/
|
|
62
|
+
export const getPreviewTexts = (content, layout) => {
|
|
63
|
+
if (layout === 'classic') {
|
|
64
|
+
return {
|
|
65
|
+
title: content.title || content.body || '',
|
|
66
|
+
body: content.title && content.body || ''
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
title: content.title || '',
|
|
71
|
+
body: content.body || ''
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
/** The colored-initial fallback the SDK draws when classic has no icon. */
|
|
75
|
+
export const getIconInitial = content => (content.title || content.body || '?').trim().charAt(0).toUpperCase() || '?';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { InboxPreview } from './InboxPreview';
|
|
2
|
+
export { resolveInboxLayout } from './helpers';
|
|
3
|
+
export { MAX_CAROUSEL_SLIDES } from './constants';
|
|
4
|
+
export type { InboxLayoutType, InboxPreviewPlatform, InboxPreviewContent, InboxPreviewProps, InboxPreviewSlide, } from './types';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { messages as ar } from './messages_ar';
|
|
2
|
+
import { messages as bn } from './messages_bn';
|
|
3
|
+
import { messages as de } from './messages_de';
|
|
4
|
+
import { messages as en } from './messages_en';
|
|
5
|
+
import { messages as es } from './messages_es';
|
|
6
|
+
import { messages as fr } from './messages_fr';
|
|
7
|
+
import { messages as he } from './messages_he';
|
|
8
|
+
import { messages as hi } from './messages_hi';
|
|
9
|
+
import { messages as ja } from './messages_ja';
|
|
10
|
+
import { messages as ko } from './messages_ko';
|
|
11
|
+
import { messages as pt } from './messages_pt';
|
|
12
|
+
import { messages as ru } from './messages_ru';
|
|
13
|
+
import { messages as th } from './messages_th';
|
|
14
|
+
import { messages as zh } from './messages_zh';
|
|
15
|
+
import { createLang } from '../../polyglot';
|
|
16
|
+
export const {
|
|
17
|
+
Lang,
|
|
18
|
+
useLang
|
|
19
|
+
} = createLang({
|
|
20
|
+
ar,
|
|
21
|
+
bn,
|
|
22
|
+
de,
|
|
23
|
+
en,
|
|
24
|
+
es,
|
|
25
|
+
fr,
|
|
26
|
+
he,
|
|
27
|
+
hi,
|
|
28
|
+
ja,
|
|
29
|
+
ko,
|
|
30
|
+
pt,
|
|
31
|
+
ru,
|
|
32
|
+
th,
|
|
33
|
+
zh
|
|
34
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ShapeRadius } from '@pushwoosh/kit-constants';
|
|
2
|
+
export declare const HeroImage: import("styled-components").StyledComponent<"img", any, {}, never>;
|
|
3
|
+
export declare const EmptyHero: import("styled-components").StyledComponent<"div", any, import("@pushwoosh/kit-helpers/styled-helpers").CommonBoxProps & {
|
|
4
|
+
$alignContent?: import("@pushwoosh/kit-helpers/styled-helpers").AlignContentValue | undefined;
|
|
5
|
+
$alignItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue | undefined;
|
|
6
|
+
$gap?: import("@pushwoosh/kit-helpers/styled-helpers").StrNum | undefined;
|
|
7
|
+
$justifyContent?: import("@pushwoosh/kit-helpers/styled-helpers").JustifyContentValue | undefined;
|
|
8
|
+
} & {
|
|
9
|
+
$gridAutoFlow?: "row" | "column" | "dense" | "row dense" | "column dense" | undefined;
|
|
10
|
+
$justifyItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue | undefined;
|
|
11
|
+
$placeItems?: import("@pushwoosh/kit-helpers/styled-helpers").ItemAlignmentValue | undefined;
|
|
12
|
+
} & {
|
|
13
|
+
$gridAutoFlow: string;
|
|
14
|
+
} & {
|
|
15
|
+
$borderRadius: ShapeRadius;
|
|
16
|
+
$shrink: number;
|
|
17
|
+
}, "$gridAutoFlow" | "$borderRadius" | "$shrink">;
|
|
18
|
+
export declare const ClampText: import("styled-components").StyledComponent<"span", any, {
|
|
19
|
+
$color?: string | undefined;
|
|
20
|
+
$uppercase?: boolean | undefined;
|
|
21
|
+
$ellipsis?: boolean | undefined;
|
|
22
|
+
$variant?: import("@pushwoosh/kit-typography").TypographyVariant | undefined;
|
|
23
|
+
} & {
|
|
24
|
+
$clamp?: number;
|
|
25
|
+
}, never>;
|