@capillarytech/creatives-library 9.0.44 → 9.0.45
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/ViberCarouselPreviewCards.js +127 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/ViberPreviewContent.js +106 -15
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +139 -1
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_viberCarouselPreviewCards.scss +133 -0
- package/v2Components/CommonTestAndPreview/constants.js +2 -0
- package/v2Components/CommonTestAndPreview/index.js +240 -26
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/ViberPreviewContent.test.js +364 -0
- package/v2Components/CommonTestAndPreview/tests/utils.test.js +49 -0
- package/v2Components/CommonTestAndPreview/utils.js +20 -0
- package/v2Containers/Templates/_templates.scss +180 -2
- package/v2Containers/Templates/index.js +97 -10
- package/v2Containers/Viber/constants.js +21 -0
- package/v2Containers/Viber/index.js +719 -49
- package/v2Containers/Viber/index.scss +175 -0
- package/v2Containers/Viber/messages.js +121 -0
- package/v2Containers/Viber/tests/index.test.js +80 -0
|
@@ -73,6 +73,7 @@ import * as ebillActions from '../Ebill/actions';
|
|
|
73
73
|
import * as emailActions from '../Email/actions';
|
|
74
74
|
import * as lineActions from '../Line/Container/actions';
|
|
75
75
|
import * as viberActions from '../Viber/actions';
|
|
76
|
+
import { VIBER_MEDIA_TYPES } from '../Viber/constants';
|
|
76
77
|
import * as facebookActions from '../Facebook/actions';
|
|
77
78
|
import * as whatsappActions from '../Whatsapp/actions';
|
|
78
79
|
import * as rcsActions from '../Rcs/actions';
|
|
@@ -1399,6 +1400,11 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1399
1400
|
const image = viberContent.image || {};
|
|
1400
1401
|
const video = viberContent.video || {};
|
|
1401
1402
|
const button = viberContent.button || {};
|
|
1403
|
+
const messageType = viberContent.type || '';
|
|
1404
|
+
const cardsRaw = viberContent.cards;
|
|
1405
|
+
const cards = Array.isArray(cardsRaw) ? cardsRaw : [];
|
|
1406
|
+
const isCarousel =
|
|
1407
|
+
messageType === VIBER_MEDIA_TYPES.CAROUSEL || cards.length > 0;
|
|
1402
1408
|
|
|
1403
1409
|
const viberPreview = {
|
|
1404
1410
|
messageContent: text,
|
|
@@ -1416,14 +1422,39 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1416
1422
|
};
|
|
1417
1423
|
}
|
|
1418
1424
|
|
|
1425
|
+
if (isCarousel) {
|
|
1426
|
+
viberPreview.type = VIBER_MEDIA_TYPES.CAROUSEL;
|
|
1427
|
+
viberPreview.cards = cards.map((card) => ({
|
|
1428
|
+
text: card?.text || '',
|
|
1429
|
+
mediaUrl: card?.mediaUrl || '',
|
|
1430
|
+
buttons: (card?.buttons || []).map((btn) => ({
|
|
1431
|
+
title: btn?.title || '',
|
|
1432
|
+
action: btn?.action || '',
|
|
1433
|
+
})),
|
|
1434
|
+
}));
|
|
1435
|
+
viberPreview.showCarouselEditorPreview = true;
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1419
1438
|
// Extract account name
|
|
1420
1439
|
const accountName = get(template, 'definition.accountName', '');
|
|
1421
1440
|
|
|
1422
1441
|
// Return Viber content object (same as Viber/index.js getTemplateContent)
|
|
1423
1442
|
return {
|
|
1424
1443
|
viberPreviewContent: viberPreview,
|
|
1425
|
-
accountName: accountName
|
|
1426
|
-
brandName: accountName
|
|
1444
|
+
accountName: accountName || '',
|
|
1445
|
+
brandName: accountName || '',
|
|
1446
|
+
messageContent: text,
|
|
1447
|
+
...(isCarousel && {
|
|
1448
|
+
type: VIBER_MEDIA_TYPES.CAROUSEL,
|
|
1449
|
+
cards: viberPreview.cards,
|
|
1450
|
+
}),
|
|
1451
|
+
...(!isCarousel && !isEmpty(button) && button.text && (button.url || viberContent.buttonURL) && {
|
|
1452
|
+
button: {
|
|
1453
|
+
text: button.text,
|
|
1454
|
+
url: button.url || viberContent.buttonURL || '',
|
|
1455
|
+
},
|
|
1456
|
+
}),
|
|
1457
|
+
buttonURL: button.url || viberContent.buttonURL || '',
|
|
1427
1458
|
};
|
|
1428
1459
|
}
|
|
1429
1460
|
|
|
@@ -2436,10 +2467,59 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2436
2467
|
image = {},
|
|
2437
2468
|
button = {},
|
|
2438
2469
|
video = {},
|
|
2470
|
+
type = '',
|
|
2471
|
+
cards = [],
|
|
2439
2472
|
} = {},
|
|
2440
2473
|
} = {},
|
|
2441
2474
|
} = template.versions.base;
|
|
2475
|
+
const isViberCarousel = type === VIBER_MEDIA_TYPES.CAROUSEL;
|
|
2442
2476
|
templateData.content = text;
|
|
2477
|
+
if (isViberCarousel) {
|
|
2478
|
+
const previewCards = Array.isArray(cards) ? cards.slice(0, 1) : [];
|
|
2479
|
+
// Bypass CapCustomCard Viber Meta + line-clamp (clips title/buttons for tall images).
|
|
2480
|
+
// Parent class `viber-carousel-static` scopes listing styles in _templates.scss.
|
|
2481
|
+
// cardType hits the default content path; keep VIBER for channel card styles.
|
|
2482
|
+
templateData.cardType = 'VIBER_CAROUSEL_PREVIEW';
|
|
2483
|
+
templateData.className = 'viber-carousel-static VIBER';
|
|
2484
|
+
templateData.content = (
|
|
2485
|
+
<CapRow vertical className="content">
|
|
2486
|
+
<CapRow className="message-box">
|
|
2487
|
+
<CapLabel type="label1" className="message">
|
|
2488
|
+
{text}
|
|
2489
|
+
</CapLabel>
|
|
2490
|
+
</CapRow>
|
|
2491
|
+
<CapRow className="cards">
|
|
2492
|
+
{previewCards?.map((card, cardIdx) => (
|
|
2493
|
+
<CapRow vertical className="card" key={`viber-carousel-static-card-${cardIdx}`}>
|
|
2494
|
+
{card?.mediaUrl ? (
|
|
2495
|
+
<CapImage src={card.mediaUrl} className="image" />
|
|
2496
|
+
) : (
|
|
2497
|
+
<CapRow className="image-placeholder" />
|
|
2498
|
+
)}
|
|
2499
|
+
<CapLabel type="label1" className="text">
|
|
2500
|
+
{card?.text}
|
|
2501
|
+
</CapLabel>
|
|
2502
|
+
<CapRow vertical className="buttons">
|
|
2503
|
+
{(Array.isArray(card?.buttons) && card.buttons.length
|
|
2504
|
+
? card.buttons
|
|
2505
|
+
: [{}, {}]
|
|
2506
|
+
).slice(0, 2).map((carouselButton, btnIdx) => (
|
|
2507
|
+
<CapLabel
|
|
2508
|
+
key={`viber-carousel-static-btn-${cardIdx}-${btnIdx}`}
|
|
2509
|
+
type="label1"
|
|
2510
|
+
className={`button${btnIdx === 1 ? ' button-secondary' : ''}`}
|
|
2511
|
+
>
|
|
2512
|
+
{(carouselButton?.title || '').trim()}
|
|
2513
|
+
</CapLabel>
|
|
2514
|
+
))}
|
|
2515
|
+
</CapRow>
|
|
2516
|
+
</CapRow>
|
|
2517
|
+
))}
|
|
2518
|
+
</CapRow>
|
|
2519
|
+
</CapRow>
|
|
2520
|
+
);
|
|
2521
|
+
break;
|
|
2522
|
+
}
|
|
2443
2523
|
if (!isEmpty(image)) {
|
|
2444
2524
|
const { url = '' } = image;
|
|
2445
2525
|
templateData.url = url;
|
|
@@ -5107,15 +5187,22 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
5107
5187
|
? this.props.Templates.selectedWhatsappAccount.name
|
|
5108
5188
|
: null
|
|
5109
5189
|
}
|
|
5110
|
-
// Pass formData for
|
|
5190
|
+
// Pass formData for tag extraction (EMAIL/SMS use nested formData; VIBER uses content object)
|
|
5111
5191
|
formData={
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
|
|
5192
|
+
(() => {
|
|
5193
|
+
const previewContent = this.state.testAndPreviewContent;
|
|
5194
|
+
const channelUpper = this.state.channel?.toUpperCase();
|
|
5195
|
+
if (!previewContent || typeof previewContent !== 'object') {
|
|
5196
|
+
return null;
|
|
5197
|
+
}
|
|
5198
|
+
if ([EMAIL, SMS].includes(channelUpper)) {
|
|
5199
|
+
return previewContent.formData || null;
|
|
5200
|
+
}
|
|
5201
|
+
if (channelUpper === VIBER) {
|
|
5202
|
+
return previewContent;
|
|
5203
|
+
}
|
|
5204
|
+
return null;
|
|
5205
|
+
})()
|
|
5119
5206
|
}
|
|
5120
5207
|
/>
|
|
5121
5208
|
)}
|
|
@@ -47,7 +47,24 @@ export const VIBER_MEDIA_TYPES = {
|
|
|
47
47
|
TEXT: 'TEXT',
|
|
48
48
|
IMAGE: 'IMAGE',
|
|
49
49
|
VIDEO: 'VIDEO',
|
|
50
|
+
CAROUSEL: 'CAROUSEL',
|
|
50
51
|
};
|
|
52
|
+
export const VIBER_CAROUSEL_MIN_CARDS = 2;
|
|
53
|
+
export const VIBER_CAROUSEL_MAX_CARDS = 5;
|
|
54
|
+
export const VIBER_CAROUSEL_MAX_BUTTONS = 2;
|
|
55
|
+
export const VIBER_CAROUSEL_CARD_TITLE_MIN_LENGTH = 2;
|
|
56
|
+
export const VIBER_CAROUSEL_CARD_TITLE_MAX_LENGTH = 38;
|
|
57
|
+
export const VIBER_CAROUSEL_FIRST_BUTTON_TITLE_MAX_LENGTH = 10;
|
|
58
|
+
export const VIBER_CAROUSEL_SECOND_BUTTON_TITLE_MAX_LENGTH = 12;
|
|
59
|
+
export const VIBER_CAROUSEL_BUTTON_URL_MAX_LENGTH = 1000;
|
|
60
|
+
export const STATIC_URL = 'STATIC_URL';
|
|
61
|
+
export const DYNAMIC_URL = 'DYNAMIC_URL';
|
|
62
|
+
/** Recommended / validated carousel image height in pixels (passed to image upload). */
|
|
63
|
+
export const VIBER_CAROUSEL_IMG_HEIGHT = 600;
|
|
64
|
+
/** Recommended / validated carousel image width in pixels (passed to image upload). */
|
|
65
|
+
export const VIBER_CAROUSEL_IMG_WIDTH = 696;
|
|
66
|
+
/** Maximum carousel image file size (bytes). 10_000_000 ≈ 10 MB (decimal). */
|
|
67
|
+
export const VIBER_CAROUSEL_IMG_SIZE = 10000000;
|
|
51
68
|
export const ALLOWED_IMAGE_EXTENSIONS_REGEX_VIBER = /\.(jpe?g|png)$/i;
|
|
52
69
|
export const ALLOWED_EXTENSIONS_VIDEO_REGEX_VIBER = /\.(mp4|3gp|m4v|mov)$/i;
|
|
53
70
|
export const NONE = 'NONE';
|
|
@@ -69,6 +86,10 @@ export const mediaRadioOptions = [
|
|
|
69
86
|
value: VIBER_MEDIA_TYPES.VIDEO,
|
|
70
87
|
label: <FormattedMessage {...messages.mediaVideo} />,
|
|
71
88
|
},
|
|
89
|
+
{
|
|
90
|
+
value: VIBER_MEDIA_TYPES.CAROUSEL,
|
|
91
|
+
label: <FormattedMessage {...messages.mediaCarousel} />,
|
|
92
|
+
},
|
|
72
93
|
];
|
|
73
94
|
|
|
74
95
|
export const buttonRadioOptions = [
|