@capillarytech/creatives-library 8.0.353-alpha.1 → 8.0.353-alpha.2
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/package.json +1 -1
- package/v2Components/CommonTestAndPreview/UnifiedPreview/ViberPreviewContent.js +9 -108
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +0 -93
- package/v2Components/CommonTestAndPreview/index.js +7 -47
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/ViberPreviewContent.test.js +0 -364
- package/v2Components/FormBuilder/index.js +48 -10
- package/v2Containers/CreativesContainer/index.js +61 -25
- package/v2Containers/Email/index.js +33 -2
- package/v2Containers/Templates/_templates.scss +0 -76
- package/v2Containers/Templates/index.js +0 -73
- package/v2Containers/Viber/constants.js +0 -19
- package/v2Containers/Viber/index.js +46 -664
- package/v2Containers/Viber/index.scss +0 -148
- package/v2Containers/Viber/messages.js +0 -116
package/package.json
CHANGED
|
@@ -14,14 +14,7 @@ import CapSpin from '@capillarytech/cap-ui-library/CapSpin';
|
|
|
14
14
|
import CapImage from '@capillarytech/cap-ui-library/CapImage';
|
|
15
15
|
import CapTooltip from '@capillarytech/cap-ui-library/CapTooltip';
|
|
16
16
|
import CapRow from '@capillarytech/cap-ui-library/CapRow';
|
|
17
|
-
import {
|
|
18
|
-
ANDROID,
|
|
19
|
-
IOS,
|
|
20
|
-
ANDROID_DEVICE_NAME,
|
|
21
|
-
IOS_DEVICE_NAME,
|
|
22
|
-
VIBER_ACCOUNT_NAME,
|
|
23
|
-
MEDIA_TYPE_CAROUSEL,
|
|
24
|
-
} from '../constants';
|
|
17
|
+
import { ANDROID, IOS, ANDROID_DEVICE_NAME, IOS_DEVICE_NAME, VIBER_ACCOUNT_NAME } from '../constants';
|
|
25
18
|
import messages from '../messages';
|
|
26
19
|
import videoPlay from '../../../assets/videoPlay.svg';
|
|
27
20
|
|
|
@@ -50,34 +43,7 @@ const ViberPreviewContent = ({
|
|
|
50
43
|
imageURL = '',
|
|
51
44
|
videoParams = {},
|
|
52
45
|
buttonText = '',
|
|
53
|
-
type = '',
|
|
54
|
-
cards = [],
|
|
55
|
-
showCarouselEditorPreview = false,
|
|
56
46
|
} = viberContent;
|
|
57
|
-
const hasCarouselContent = type === MEDIA_TYPE_CAROUSEL;
|
|
58
|
-
|
|
59
|
-
const cardHasMeaningfulContent = (card) => {
|
|
60
|
-
if (!card || typeof card !== 'object') return false;
|
|
61
|
-
if ((card.text || '').trim()) return true;
|
|
62
|
-
if ((card.mediaUrl || '').trim()) return true;
|
|
63
|
-
const buttons = card.buttons || [];
|
|
64
|
-
return buttons.some((button) => (button?.title || '').trim());
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const hasMeaningfulCarousel =
|
|
68
|
-
hasCarouselContent &&
|
|
69
|
-
Array.isArray(cards) &&
|
|
70
|
-
cards.length > 0 &&
|
|
71
|
-
cards.some(cardHasMeaningfulContent);
|
|
72
|
-
|
|
73
|
-
const showCarouselInPreview =
|
|
74
|
-
hasCarouselContent && (Boolean(showCarouselEditorPreview) || hasMeaningfulCarousel);
|
|
75
|
-
|
|
76
|
-
const previewCarouselCards =
|
|
77
|
-
hasCarouselContent && Array.isArray(cards) && cards.length ? cards : hasCarouselContent ? [{}] : [];
|
|
78
|
-
|
|
79
|
-
const trimmedMessageContent = (messageContent || '').trim();
|
|
80
|
-
const trimmedButtonText = (buttonText || '').trim();
|
|
81
47
|
|
|
82
48
|
// Get account name (first letter for icon)
|
|
83
49
|
const accountIcon = (accountName || brandName || 'V')[0]?.toUpperCase();
|
|
@@ -133,15 +99,8 @@ const ViberPreviewContent = ({
|
|
|
133
99
|
);
|
|
134
100
|
}
|
|
135
101
|
|
|
136
|
-
// Check if there's any content to display
|
|
137
|
-
const hasContent =
|
|
138
|
-
trimmedMessageContent
|
|
139
|
-
|| (imageURL || '').trim()
|
|
140
|
-
|| videoParams?.viberVideoSrc
|
|
141
|
-
|| trimmedButtonText
|
|
142
|
-
|| hasMeaningfulCarousel
|
|
143
|
-
|| (hasCarouselContent && showCarouselEditorPreview)
|
|
144
|
-
);
|
|
102
|
+
// Check if there's any content to display
|
|
103
|
+
const hasContent = messageContent || imageURL || videoParams?.viberVideoSrc || buttonText;
|
|
145
104
|
|
|
146
105
|
// Render normal Viber preview
|
|
147
106
|
return (
|
|
@@ -170,21 +129,19 @@ const ViberPreviewContent = ({
|
|
|
170
129
|
{/* Brand Name Display (from TemplatePreview line 1136) */}
|
|
171
130
|
<CapRow className="msg-container viber-preview">
|
|
172
131
|
{/* Account Icon (from TemplatePreview line 1146-1160) */}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
</CapRow>
|
|
177
|
-
)}
|
|
132
|
+
<CapRow className="viber-account-icon">
|
|
133
|
+
{accountIcon}
|
|
134
|
+
</CapRow>
|
|
178
135
|
|
|
179
136
|
{/* Message Bubble (from TemplatePreview line 1161-1223) */}
|
|
180
137
|
<CapRow className="message-pop align-left viber-message-pop">
|
|
181
138
|
{/* Text Viber preview */}
|
|
182
|
-
{
|
|
139
|
+
{messageContent && (
|
|
183
140
|
<CapLabel type="label15" className="viber-message-text">{messageContent}</CapLabel>
|
|
184
141
|
)}
|
|
185
142
|
|
|
186
143
|
{/* Image Viber preview */}
|
|
187
|
-
{
|
|
144
|
+
{imageURL && (
|
|
188
145
|
<CapImage
|
|
189
146
|
src={imageURL}
|
|
190
147
|
className="viber-image-preview"
|
|
@@ -214,59 +171,13 @@ const ViberPreviewContent = ({
|
|
|
214
171
|
)}
|
|
215
172
|
|
|
216
173
|
{/* Button Viber preview */}
|
|
217
|
-
{
|
|
174
|
+
{buttonText && (
|
|
218
175
|
<CapLabel className="viber-button-base">
|
|
219
176
|
<p className="viber-button-card-text">
|
|
220
177
|
{buttonText}
|
|
221
178
|
</p>
|
|
222
179
|
</CapLabel>
|
|
223
180
|
)}
|
|
224
|
-
{/* Carousel Viber preview */}
|
|
225
|
-
{showCarouselInPreview && (
|
|
226
|
-
<>
|
|
227
|
-
<CapRow className="viber-carousel-message-box">
|
|
228
|
-
{trimmedMessageContent ? (
|
|
229
|
-
<CapLabel type="label15" className="viber-carousel-message-box-text">
|
|
230
|
-
{messageContent}
|
|
231
|
-
</CapLabel>
|
|
232
|
-
) : (
|
|
233
|
-
<CapRow className="viber-carousel-message-box-placeholder" />
|
|
234
|
-
)}
|
|
235
|
-
</CapRow>
|
|
236
|
-
<CapRow className="viber-carousel-preview-scroll">
|
|
237
|
-
{previewCarouselCards?.map((card, index) => (
|
|
238
|
-
<CapRow className="viber-carousel-preview-card" key={`viber-carousel-preview-card-${index}`}>
|
|
239
|
-
{(card?.mediaUrl || '').trim() ? (
|
|
240
|
-
<CapImage
|
|
241
|
-
src={card?.mediaUrl}
|
|
242
|
-
className="viber-carousel-preview-image"
|
|
243
|
-
alt="Viber carousel card"
|
|
244
|
-
/>
|
|
245
|
-
) : (
|
|
246
|
-
<CapRow className="viber-carousel-preview-image-placeholder" />
|
|
247
|
-
)}
|
|
248
|
-
{(card?.text || '').trim() ? (
|
|
249
|
-
<CapLabel type="label15" className="viber-carousel-preview-text">
|
|
250
|
-
{card?.text}
|
|
251
|
-
</CapLabel>
|
|
252
|
-
) : (
|
|
253
|
-
<CapLabel type="label15" className="viber-carousel-preview-text-placeholder" />
|
|
254
|
-
)}
|
|
255
|
-
{(card?.buttons?.filter((cardButton) => (cardButton?.title || '').trim()) ?? [])
|
|
256
|
-
.slice(0, 2)
|
|
257
|
-
.map((cardButton, btnIndex) => (
|
|
258
|
-
<CapLabel
|
|
259
|
-
className={`viber-carousel-preview-button ${btnIndex === 1 ? 'viber-carousel-preview-button-secondary' : ''}`}
|
|
260
|
-
key={`viber-carousel-preview-btn-${index}-${btnIndex}-${(cardButton?.title || '').trim()}`}
|
|
261
|
-
>
|
|
262
|
-
{(cardButton?.title || '').trim()}
|
|
263
|
-
</CapLabel>
|
|
264
|
-
))}
|
|
265
|
-
</CapRow>
|
|
266
|
-
))}
|
|
267
|
-
</CapRow>
|
|
268
|
-
</>
|
|
269
|
-
)}
|
|
270
181
|
<CapLabel type="label1" className="viber-timestamp">
|
|
271
182
|
{timestamp}
|
|
272
183
|
</CapLabel>
|
|
@@ -303,16 +214,6 @@ ViberPreviewContent.propTypes = {
|
|
|
303
214
|
viberVideoPreviewImg: PropTypes.string,
|
|
304
215
|
}),
|
|
305
216
|
buttonText: PropTypes.string,
|
|
306
|
-
type: PropTypes.string,
|
|
307
|
-
cards: PropTypes.arrayOf(PropTypes.shape({
|
|
308
|
-
text: PropTypes.string,
|
|
309
|
-
mediaUrl: PropTypes.string,
|
|
310
|
-
buttons: PropTypes.arrayOf(PropTypes.shape({
|
|
311
|
-
title: PropTypes.string,
|
|
312
|
-
action: PropTypes.string,
|
|
313
|
-
})),
|
|
314
|
-
})),
|
|
315
|
-
showCarouselEditorPreview: PropTypes.bool,
|
|
316
217
|
}),
|
|
317
218
|
}),
|
|
318
219
|
device: PropTypes.oneOf([ANDROID, IOS]),
|
|
@@ -2240,99 +2240,6 @@
|
|
|
2240
2240
|
}
|
|
2241
2241
|
}
|
|
2242
2242
|
|
|
2243
|
-
.viber-carousel-preview-scroll {
|
|
2244
|
-
margin-top: $CAP_SPACE_08;
|
|
2245
|
-
display: flex;
|
|
2246
|
-
overflow-x: auto;
|
|
2247
|
-
gap: $CAP_SPACE_08;
|
|
2248
|
-
white-space: nowrap;
|
|
2249
|
-
scrollbar-width: none;
|
|
2250
|
-
|
|
2251
|
-
&::-webkit-scrollbar {
|
|
2252
|
-
display: none;
|
|
2253
|
-
}
|
|
2254
|
-
|
|
2255
|
-
.viber-carousel-preview-card {
|
|
2256
|
-
min-width: 8.75rem;
|
|
2257
|
-
background: $CAP_WHITE;
|
|
2258
|
-
border-radius: $CAP_SPACE_04;
|
|
2259
|
-
padding: $CAP_SPACE_06;
|
|
2260
|
-
display: flex;
|
|
2261
|
-
flex-direction: column;
|
|
2262
|
-
gap: $CAP_SPACE_04;
|
|
2263
|
-
|
|
2264
|
-
.viber-carousel-preview-image {
|
|
2265
|
-
width: 100%;
|
|
2266
|
-
height: 5.357rem;
|
|
2267
|
-
object-fit: cover;
|
|
2268
|
-
border-radius: $CAP_SPACE_04;
|
|
2269
|
-
}
|
|
2270
|
-
|
|
2271
|
-
.viber-carousel-preview-image-placeholder {
|
|
2272
|
-
width: 100%;
|
|
2273
|
-
height: 5.357rem;
|
|
2274
|
-
border-radius: $CAP_SPACE_04;
|
|
2275
|
-
background: $CAP_G07;
|
|
2276
|
-
}
|
|
2277
|
-
|
|
2278
|
-
.viber-carousel-preview-text {
|
|
2279
|
-
color: $CAP_G01;
|
|
2280
|
-
line-height: 1.3;
|
|
2281
|
-
white-space: normal;
|
|
2282
|
-
}
|
|
2283
|
-
|
|
2284
|
-
.viber-carousel-preview-text-placeholder {
|
|
2285
|
-
width: 100%;
|
|
2286
|
-
height: 0.875rem;
|
|
2287
|
-
border-radius: $CAP_SPACE_04;
|
|
2288
|
-
background: $CAP_G07;
|
|
2289
|
-
min-height: 0.875rem;
|
|
2290
|
-
}
|
|
2291
|
-
|
|
2292
|
-
.viber-carousel-preview-button {
|
|
2293
|
-
color: $CAP_WHITE;
|
|
2294
|
-
background: $CAP_PURPLE01;
|
|
2295
|
-
border-radius: $CAP_SPACE_12;
|
|
2296
|
-
text-align: center;
|
|
2297
|
-
padding: 0.179rem $CAP_SPACE_08;
|
|
2298
|
-
white-space: normal;
|
|
2299
|
-
min-height: 1rem;
|
|
2300
|
-
}
|
|
2301
|
-
|
|
2302
|
-
.viber-carousel-preview-button-secondary {
|
|
2303
|
-
color: $CAP_PURPLE01;
|
|
2304
|
-
background: $CAP_WHITE;
|
|
2305
|
-
border: 1px solid $CAP_PURPLE01;
|
|
2306
|
-
}
|
|
2307
|
-
}
|
|
2308
|
-
}
|
|
2309
|
-
|
|
2310
|
-
.viber-carousel-message-box {
|
|
2311
|
-
width: 100%;
|
|
2312
|
-
height: 2.25rem;
|
|
2313
|
-
border-radius: $CAP_SPACE_04;
|
|
2314
|
-
background: $CAP_WHITE;
|
|
2315
|
-
margin-top: $CAP_SPACE_08;
|
|
2316
|
-
padding: 0 $CAP_SPACE_08;
|
|
2317
|
-
display: flex;
|
|
2318
|
-
align-items: center;
|
|
2319
|
-
}
|
|
2320
|
-
|
|
2321
|
-
.viber-carousel-message-box-text {
|
|
2322
|
-
color: $CAP_G01;
|
|
2323
|
-
white-space: nowrap;
|
|
2324
|
-
overflow: hidden;
|
|
2325
|
-
text-overflow: ellipsis;
|
|
2326
|
-
width: 100%;
|
|
2327
|
-
}
|
|
2328
|
-
|
|
2329
|
-
.viber-carousel-message-box-placeholder {
|
|
2330
|
-
width: 100%;
|
|
2331
|
-
height: 0.875rem;
|
|
2332
|
-
border-radius: $CAP_SPACE_04;
|
|
2333
|
-
background: $CAP_G07;
|
|
2334
|
-
}
|
|
2335
|
-
|
|
2336
2243
|
.empty-placeholder {
|
|
2337
2244
|
height: $CAP_SPACE_08;
|
|
2338
2245
|
}
|
|
@@ -1554,8 +1554,6 @@ const CommonTestAndPreview = (props) => {
|
|
|
1554
1554
|
let imageData = null;
|
|
1555
1555
|
let videoData = null;
|
|
1556
1556
|
let buttonData = null;
|
|
1557
|
-
let cardsData = [];
|
|
1558
|
-
let messageType = '';
|
|
1559
1557
|
let accountId = null;
|
|
1560
1558
|
let accountDetails = null;
|
|
1561
1559
|
let scenarioKey = '';
|
|
@@ -1570,8 +1568,6 @@ const CommonTestAndPreview = (props) => {
|
|
|
1570
1568
|
imageData = formDataObj.image || null;
|
|
1571
1569
|
videoData = formDataObj.video || null;
|
|
1572
1570
|
buttonData = formDataObj.button || null;
|
|
1573
|
-
cardsData = formDataObj.cards || [];
|
|
1574
|
-
messageType = formDataObj.type || '';
|
|
1575
1571
|
accountId = formDataObj.accountId || null;
|
|
1576
1572
|
accountDetails = formDataObj.accountDetails || null;
|
|
1577
1573
|
scenarioKey = formDataObj.scenarioKey || VIBER_API_SCENARIO_KEY;
|
|
@@ -1598,8 +1594,6 @@ const CommonTestAndPreview = (props) => {
|
|
|
1598
1594
|
url: formDataObj?.buttonURL || '',
|
|
1599
1595
|
};
|
|
1600
1596
|
}
|
|
1601
|
-
cardsData = viberPreview.cards || formDataObj?.cards || [];
|
|
1602
|
-
messageType = viberPreview.type || formDataObj?.type || '';
|
|
1603
1597
|
// Extract account info from parent formDataObj if available
|
|
1604
1598
|
accountId = formDataObj.accountId || null;
|
|
1605
1599
|
accountDetails = formDataObj.accountDetails || null;
|
|
@@ -1642,10 +1636,6 @@ const CommonTestAndPreview = (props) => {
|
|
|
1642
1636
|
text: messageText,
|
|
1643
1637
|
};
|
|
1644
1638
|
|
|
1645
|
-
if (messageType === CHANNELS.VIBER) {
|
|
1646
|
-
messageType = '';
|
|
1647
|
-
}
|
|
1648
|
-
|
|
1649
1639
|
// Add image if present
|
|
1650
1640
|
if (imageData && imageData.url) {
|
|
1651
1641
|
viberContent.image = {
|
|
@@ -1674,19 +1664,6 @@ const CommonTestAndPreview = (props) => {
|
|
|
1674
1664
|
}
|
|
1675
1665
|
}
|
|
1676
1666
|
|
|
1677
|
-
if (messageType === MEDIA_TYPE_CAROUSEL || (Array.isArray(cardsData) && cardsData.length)) {
|
|
1678
|
-
viberContent.type = MEDIA_TYPE_CAROUSEL;
|
|
1679
|
-
viberContent.cards = (cardsData || []).map((card) => ({
|
|
1680
|
-
text: card?.text || '',
|
|
1681
|
-
mediaUrl: card?.mediaUrl || '',
|
|
1682
|
-
buttons: (card?.buttons || []).map((button) => ({
|
|
1683
|
-
title: button?.title || '',
|
|
1684
|
-
action: button?.action || '',
|
|
1685
|
-
})),
|
|
1686
|
-
}));
|
|
1687
|
-
delete viberContent.button;
|
|
1688
|
-
}
|
|
1689
|
-
|
|
1690
1667
|
// Resolve tags in text if custom values are provided
|
|
1691
1668
|
if (customValuesObj && Object.keys(customValuesObj).length > 0 && viberContent.text) {
|
|
1692
1669
|
viberContent.text = resolveTagsInText(viberContent.text, customValuesObj);
|
|
@@ -2033,13 +2010,6 @@ const CommonTestAndPreview = (props) => {
|
|
|
2033
2010
|
// Only use previewDataHtml if preview call was made
|
|
2034
2011
|
if (hasPreviewCallBeenMade && previewDataHtml?.resolvedBody) {
|
|
2035
2012
|
resolvedContent = previewDataHtml.resolvedBody;
|
|
2036
|
-
if (typeof resolvedContent === 'string') {
|
|
2037
|
-
try {
|
|
2038
|
-
resolvedContent = JSON.parse(resolvedContent);
|
|
2039
|
-
} catch (e) {
|
|
2040
|
-
resolvedContent = null;
|
|
2041
|
-
}
|
|
2042
|
-
}
|
|
2043
2013
|
}
|
|
2044
2014
|
|
|
2045
2015
|
// Parse content if it's a string
|
|
@@ -2051,25 +2021,15 @@ const CommonTestAndPreview = (props) => {
|
|
|
2051
2021
|
parsedViberContent = {};
|
|
2052
2022
|
}
|
|
2053
2023
|
}
|
|
2054
|
-
//
|
|
2024
|
+
// Use resolvedContent if available (from preview call), otherwise use raw content
|
|
2055
2025
|
if (resolvedContent && typeof resolvedContent === 'object') {
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
viberPreviewContent: {
|
|
2061
|
-
...base.viberPreviewContent,
|
|
2062
|
-
...resolvedContent.viberPreviewContent,
|
|
2063
|
-
...(resolvedContent.messageContent != null && typeof resolvedContent.messageContent === 'string'
|
|
2064
|
-
? { messageContent: resolvedContent.messageContent }
|
|
2065
|
-
: {}),
|
|
2066
|
-
},
|
|
2067
|
-
};
|
|
2068
|
-
if (base.accountName && !contentObj.accountName) {
|
|
2069
|
-
contentObj.accountName = base.accountName;
|
|
2026
|
+
contentObj = { ...resolvedContent };
|
|
2027
|
+
// Merge in accountName and brandName from raw content if not in resolvedContent
|
|
2028
|
+
if (parsedViberContent?.accountName && !contentObj.accountName) {
|
|
2029
|
+
contentObj.accountName = parsedViberContent.accountName;
|
|
2070
2030
|
}
|
|
2071
|
-
if (
|
|
2072
|
-
contentObj.brandName =
|
|
2031
|
+
if (parsedViberContent?.brandName && !contentObj.brandName) {
|
|
2032
|
+
contentObj.brandName = parsedViberContent.brandName;
|
|
2073
2033
|
}
|
|
2074
2034
|
} else {
|
|
2075
2035
|
// Use raw content if no preview call was made or resolvedContent is not available
|