@capillarytech/creatives-library 9.0.49 → 9.0.50-alpha.1
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 +179 -1
- package/v2Containers/Templates/index.js +97 -10
- package/v2Containers/Viber/constants.js +21 -0
- package/v2Containers/Viber/index.js +711 -43
- package/v2Containers/Viber/index.scss +175 -0
- package/v2Containers/Viber/messages.js +121 -0
- package/v2Containers/Viber/tests/index.test.js +80 -0
- package/v2Containers/Whatsapp/index.js +1 -1
|
@@ -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';
|
|
@@ -1405,6 +1406,11 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1405
1406
|
const image = viberContent.image || {};
|
|
1406
1407
|
const video = viberContent.video || {};
|
|
1407
1408
|
const button = viberContent.button || {};
|
|
1409
|
+
const messageType = viberContent.type || '';
|
|
1410
|
+
const cardsRaw = viberContent.cards;
|
|
1411
|
+
const cards = Array.isArray(cardsRaw) ? cardsRaw : [];
|
|
1412
|
+
const isCarousel =
|
|
1413
|
+
messageType === VIBER_MEDIA_TYPES.CAROUSEL || cards.length > 0;
|
|
1408
1414
|
|
|
1409
1415
|
const viberPreview = {
|
|
1410
1416
|
messageContent: text,
|
|
@@ -1422,14 +1428,39 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1422
1428
|
};
|
|
1423
1429
|
}
|
|
1424
1430
|
|
|
1431
|
+
if (isCarousel) {
|
|
1432
|
+
viberPreview.type = VIBER_MEDIA_TYPES.CAROUSEL;
|
|
1433
|
+
viberPreview.cards = cards.map((card) => ({
|
|
1434
|
+
text: card?.text || '',
|
|
1435
|
+
mediaUrl: card?.mediaUrl || '',
|
|
1436
|
+
buttons: (card?.buttons || []).map((btn) => ({
|
|
1437
|
+
title: btn?.title || '',
|
|
1438
|
+
action: btn?.action || '',
|
|
1439
|
+
})),
|
|
1440
|
+
}));
|
|
1441
|
+
viberPreview.showCarouselEditorPreview = true;
|
|
1442
|
+
}
|
|
1443
|
+
|
|
1425
1444
|
// Extract account name
|
|
1426
1445
|
const accountName = get(template, 'definition.accountName', '');
|
|
1427
1446
|
|
|
1428
1447
|
// Return Viber content object (same as Viber/index.js getTemplateContent)
|
|
1429
1448
|
return {
|
|
1430
1449
|
viberPreviewContent: viberPreview,
|
|
1431
|
-
accountName: accountName
|
|
1432
|
-
brandName: accountName
|
|
1450
|
+
accountName: accountName || '',
|
|
1451
|
+
brandName: accountName || '',
|
|
1452
|
+
messageContent: text,
|
|
1453
|
+
...(isCarousel && {
|
|
1454
|
+
type: VIBER_MEDIA_TYPES.CAROUSEL,
|
|
1455
|
+
cards: viberPreview.cards,
|
|
1456
|
+
}),
|
|
1457
|
+
...(!isCarousel && !isEmpty(button) && button.text && (button.url || viberContent.buttonURL) && {
|
|
1458
|
+
button: {
|
|
1459
|
+
text: button.text,
|
|
1460
|
+
url: button.url || viberContent.buttonURL || '',
|
|
1461
|
+
},
|
|
1462
|
+
}),
|
|
1463
|
+
buttonURL: button.url || viberContent.buttonURL || '',
|
|
1433
1464
|
};
|
|
1434
1465
|
}
|
|
1435
1466
|
|
|
@@ -2469,10 +2500,59 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2469
2500
|
image = {},
|
|
2470
2501
|
button = {},
|
|
2471
2502
|
video = {},
|
|
2503
|
+
type = '',
|
|
2504
|
+
cards = [],
|
|
2472
2505
|
} = {},
|
|
2473
2506
|
} = {},
|
|
2474
2507
|
} = template.versions.base;
|
|
2508
|
+
const isViberCarousel = type === VIBER_MEDIA_TYPES.CAROUSEL;
|
|
2475
2509
|
templateData.content = text;
|
|
2510
|
+
if (isViberCarousel) {
|
|
2511
|
+
const previewCards = Array.isArray(cards) ? cards.slice(0, 1) : [];
|
|
2512
|
+
// Bypass CapCustomCard Viber Meta + line-clamp (clips title/buttons for tall images).
|
|
2513
|
+
// Parent class `viber-carousel-static` scopes listing styles in _templates.scss.
|
|
2514
|
+
// cardType hits the default content path; keep VIBER for channel card styles.
|
|
2515
|
+
templateData.cardType = 'VIBER_CAROUSEL_PREVIEW';
|
|
2516
|
+
templateData.className = 'viber-carousel-static VIBER';
|
|
2517
|
+
templateData.content = (
|
|
2518
|
+
<CapRow vertical className="content">
|
|
2519
|
+
<CapRow className="message-box">
|
|
2520
|
+
<CapLabel type="label1" className="message">
|
|
2521
|
+
{text}
|
|
2522
|
+
</CapLabel>
|
|
2523
|
+
</CapRow>
|
|
2524
|
+
<CapRow className="cards">
|
|
2525
|
+
{previewCards?.map((card, cardIdx) => (
|
|
2526
|
+
<CapRow vertical className="card" key={`viber-carousel-static-card-${cardIdx}`}>
|
|
2527
|
+
{card?.mediaUrl ? (
|
|
2528
|
+
<CapImage src={card.mediaUrl} className="image" />
|
|
2529
|
+
) : (
|
|
2530
|
+
<CapRow className="image-placeholder" />
|
|
2531
|
+
)}
|
|
2532
|
+
<CapLabel type="label1" className="text">
|
|
2533
|
+
{card?.text}
|
|
2534
|
+
</CapLabel>
|
|
2535
|
+
<CapRow vertical className="buttons">
|
|
2536
|
+
{(Array.isArray(card?.buttons) && card.buttons.length
|
|
2537
|
+
? card.buttons
|
|
2538
|
+
: [{}, {}]
|
|
2539
|
+
).slice(0, 2).map((carouselButton, btnIdx) => (
|
|
2540
|
+
<CapLabel
|
|
2541
|
+
key={`viber-carousel-static-btn-${cardIdx}-${btnIdx}`}
|
|
2542
|
+
type="label1"
|
|
2543
|
+
className={`button${btnIdx === 1 ? ' button-secondary' : ''}`}
|
|
2544
|
+
>
|
|
2545
|
+
{(carouselButton?.title || '').trim()}
|
|
2546
|
+
</CapLabel>
|
|
2547
|
+
))}
|
|
2548
|
+
</CapRow>
|
|
2549
|
+
</CapRow>
|
|
2550
|
+
))}
|
|
2551
|
+
</CapRow>
|
|
2552
|
+
</CapRow>
|
|
2553
|
+
);
|
|
2554
|
+
break;
|
|
2555
|
+
}
|
|
2476
2556
|
if (!isEmpty(image)) {
|
|
2477
2557
|
const { url = '' } = image;
|
|
2478
2558
|
templateData.url = url;
|
|
@@ -5143,15 +5223,22 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
5143
5223
|
? this.props.Templates.selectedWhatsappAccount.name
|
|
5144
5224
|
: null
|
|
5145
5225
|
}
|
|
5146
|
-
// Pass formData for
|
|
5226
|
+
// Pass formData for tag extraction (EMAIL/SMS use nested formData; VIBER uses content object)
|
|
5147
5227
|
formData={
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5228
|
+
(() => {
|
|
5229
|
+
const previewContent = this.state.testAndPreviewContent;
|
|
5230
|
+
const channelUpper = this.state.channel?.toUpperCase();
|
|
5231
|
+
if (!previewContent || typeof previewContent !== 'object') {
|
|
5232
|
+
return null;
|
|
5233
|
+
}
|
|
5234
|
+
if ([EMAIL, SMS].includes(channelUpper)) {
|
|
5235
|
+
return previewContent.formData || null;
|
|
5236
|
+
}
|
|
5237
|
+
if (channelUpper === VIBER) {
|
|
5238
|
+
return previewContent;
|
|
5239
|
+
}
|
|
5240
|
+
return null;
|
|
5241
|
+
})()
|
|
5155
5242
|
}
|
|
5156
5243
|
/>
|
|
5157
5244
|
)}
|
|
@@ -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 = [
|