@capillarytech/creatives-library 7.12.44 → 7.12.46
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/config/app.js +0 -1
- package/package.json +1 -1
- package/v2Containers/Cap/tests/index.test.js +2 -2
- package/v2Containers/CreativesContainer/SlideBoxContent.js +8 -7
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +30 -20
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +303 -12
- package/v2Containers/Line/Container/ImageCarousel/Content.js +15 -29
- package/v2Containers/Line/Container/ImageCarousel/constants.js +3 -0
- package/v2Containers/Line/Container/ImageCarousel/index.js +24 -35
- package/v2Containers/Line/Container/ImageCarousel/messages.js +4 -0
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +9851 -0
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +21113 -0
- package/v2Containers/Line/Container/ImageCarousel/tests/content.test.js +71 -0
- package/v2Containers/Line/Container/ImageCarousel/tests/index.test.js +58 -0
- package/v2Containers/Line/Container/ImageCarousel/tests/mockData.js +1322 -0
- package/v2Containers/Line/Container/ImageCarousel/tests/utils.test.js +13 -0
- package/v2Containers/Line/Container/ImageCarousel/utils.js +12 -0
- package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +84451 -0
- package/v2Containers/Line/Container/Wrapper/tests/index.test.js +58 -0
- package/v2Containers/Line/Container/Wrapper/tests/mockData.js +171 -0
- package/v2Containers/Line/Container/index.js +2 -0
- package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +59589 -0
- package/v2Containers/Line/Container/tests/index.test.js +105 -0
- package/v2Containers/Line/Container/tests/mockData.js +1334 -0
- package/v2Containers/Templates/constants.js +1 -1
- package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +381 -1
- package/v2Containers/Templates/tests/index.test.js +7 -1
- package/v2Containers/mockdata.js +68 -11
|
@@ -18,7 +18,7 @@ import { CAP_SPACE_12, CAP_SPACE_08, FONT_COLOR_05, CAP_WHITE, FONT_COLOR_01, CA
|
|
|
18
18
|
import Gallery from '../../../Assets/Gallery';
|
|
19
19
|
import style from './style';
|
|
20
20
|
import withStyles from '../../../../hoc/withStyles';
|
|
21
|
-
|
|
21
|
+
import { calculateAspectRatio } from './utils';
|
|
22
22
|
import messages from './messages';
|
|
23
23
|
import {
|
|
24
24
|
LINE_IMG_HEIGHT,
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
URL_ACTION_TYPE,
|
|
29
29
|
TEXT_ACTION_TYPE,
|
|
30
30
|
MAX_ACTION_LABEL_LENGTH,
|
|
31
|
+
CAROUSEL,
|
|
31
32
|
} from './constants';
|
|
32
33
|
|
|
33
34
|
export const LineImageCarouselContent = ({
|
|
@@ -64,7 +65,7 @@ export const LineImageCarouselContent = ({
|
|
|
64
65
|
actionLabel = '',
|
|
65
66
|
actionContent = '',
|
|
66
67
|
} = content;
|
|
67
|
-
if (type ===
|
|
68
|
+
if (type === CAROUSEL) {
|
|
68
69
|
updateImageStatus(!!originalContentUrl);
|
|
69
70
|
updateImageSrc(originalContentUrl);
|
|
70
71
|
updateActionType(selectedActionType);
|
|
@@ -86,7 +87,7 @@ export const LineImageCarouselContent = ({
|
|
|
86
87
|
actionContentErrorMessage,
|
|
87
88
|
actionLabelErrorMessage,
|
|
88
89
|
index,
|
|
89
|
-
type:
|
|
90
|
+
type: CAROUSEL,
|
|
90
91
|
messageType: 'originalContentUrl',
|
|
91
92
|
});
|
|
92
93
|
}
|
|
@@ -128,7 +129,7 @@ export const LineImageCarouselContent = ({
|
|
|
128
129
|
actionContentErrorMessage,
|
|
129
130
|
actionLabelErrorMessage,
|
|
130
131
|
index,
|
|
131
|
-
type:
|
|
132
|
+
type: CAROUSEL,
|
|
132
133
|
messageType: 'originalContentUrl',
|
|
133
134
|
});
|
|
134
135
|
}
|
|
@@ -149,8 +150,7 @@ export const LineImageCarouselContent = ({
|
|
|
149
150
|
updateImageErrorMessage(formatMessage(messages.lineImageIncorrectSize));
|
|
150
151
|
} else {
|
|
151
152
|
updateImageErrorMessage('');
|
|
152
|
-
|
|
153
|
-
updateAspectRatio(aspectRatio1);
|
|
153
|
+
updateAspectRatio(calculateAspectRatio(width, height));
|
|
154
154
|
actions.uploadAsset(
|
|
155
155
|
data.file,
|
|
156
156
|
data.type,
|
|
@@ -158,20 +158,7 @@ export const LineImageCarouselContent = ({
|
|
|
158
158
|
`ImageCarousel${index}`,
|
|
159
159
|
);
|
|
160
160
|
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
const calculateGCD = (width, height) => {
|
|
164
|
-
while (height !== 0 ) {
|
|
165
|
-
let reminder = width % height;
|
|
166
|
-
width = height;
|
|
167
|
-
height = reminder;
|
|
168
|
-
}
|
|
169
|
-
return Math.abs(width);
|
|
170
161
|
};
|
|
171
|
-
const calculateAspectRatio = (width, height) => {
|
|
172
|
-
const absValue = calculateGCD(width, height);
|
|
173
|
-
return `${width / absValue}:${height / absValue}`;
|
|
174
|
-
}
|
|
175
162
|
|
|
176
163
|
const uploadImages = (e, { files }) => {
|
|
177
164
|
if (e) {
|
|
@@ -262,7 +249,7 @@ export const LineImageCarouselContent = ({
|
|
|
262
249
|
actionContentErrorMessage,
|
|
263
250
|
actionLabelErrorMessage,
|
|
264
251
|
index,
|
|
265
|
-
type:
|
|
252
|
+
type: CAROUSEL,
|
|
266
253
|
messageType: 'originalContentUrl',
|
|
267
254
|
});
|
|
268
255
|
}
|
|
@@ -294,7 +281,7 @@ export const LineImageCarouselContent = ({
|
|
|
294
281
|
</CapButton>
|
|
295
282
|
</CapUploader.CapDragger>
|
|
296
283
|
<CapHeading type="h6" style={{ marginTop: CAP_SPACE_12 }}>
|
|
297
|
-
<FormattedMessage {...messages.
|
|
284
|
+
<FormattedMessage {...messages.imageDimenstionDesc} />
|
|
298
285
|
</CapHeading>
|
|
299
286
|
</>);
|
|
300
287
|
}
|
|
@@ -322,11 +309,10 @@ export const LineImageCarouselContent = ({
|
|
|
322
309
|
const imageHeight = get(imageTemplate, 'metaInfo.height');
|
|
323
310
|
const imageWidth = get(imageTemplate, 'metaInfo.width');
|
|
324
311
|
const imageSize = get(imageTemplate, 'metaInfo.file_size');
|
|
325
|
-
const
|
|
312
|
+
const calculatedAspectRatio = calculateAspectRatio(imageWidth, imageHeight);
|
|
326
313
|
updateDrawerRequirement(false);
|
|
327
314
|
if (
|
|
328
315
|
!ALLOWED_EXTENSIONS_REGEX.test(image)
|
|
329
|
-
// || imageHeight / imageWidth !== 1
|
|
330
316
|
|| imageHeight > LINE_IMG_HEIGHT
|
|
331
317
|
|| imageWidth > LINE_IMG_WIDTH
|
|
332
318
|
|| imageSize > LINE_IMG_SIZE
|
|
@@ -336,19 +322,19 @@ export const LineImageCarouselContent = ({
|
|
|
336
322
|
updateImageErrorMessage('');
|
|
337
323
|
updateImageStatus(true);
|
|
338
324
|
updateImageSrc(image);
|
|
339
|
-
updateAspectRatio(
|
|
325
|
+
updateAspectRatio(calculatedAspectRatio);
|
|
340
326
|
updateCarouselMessageState({
|
|
341
327
|
activeIndex,
|
|
342
328
|
isError: !image || isImageError,
|
|
343
329
|
originalContentUrl: image,
|
|
344
|
-
aspectRatio:
|
|
330
|
+
aspectRatio: calculatedAspectRatio,
|
|
345
331
|
selectedActionType,
|
|
346
332
|
actionContent,
|
|
347
333
|
actionLabel,
|
|
348
334
|
actionContentErrorMessage,
|
|
349
335
|
actionLabelErrorMessage,
|
|
350
336
|
index,
|
|
351
|
-
type:
|
|
337
|
+
type: CAROUSEL,
|
|
352
338
|
messageType: 'originalContentUrl',
|
|
353
339
|
});
|
|
354
340
|
}
|
|
@@ -409,7 +395,7 @@ export const LineImageCarouselContent = ({
|
|
|
409
395
|
actionContentErrorMessage,
|
|
410
396
|
actionLabelErrorMessage,
|
|
411
397
|
index,
|
|
412
|
-
type:
|
|
398
|
+
type: CAROUSEL,
|
|
413
399
|
messageType: 'originalContentUrl',
|
|
414
400
|
});
|
|
415
401
|
}
|
|
@@ -427,7 +413,7 @@ export const LineImageCarouselContent = ({
|
|
|
427
413
|
actionContentErrorMessage,
|
|
428
414
|
actionLabelErrorMessage,
|
|
429
415
|
index,
|
|
430
|
-
type:
|
|
416
|
+
type: CAROUSEL,
|
|
431
417
|
messageType: 'originalContentUrl',
|
|
432
418
|
});
|
|
433
419
|
}
|
|
@@ -458,7 +444,7 @@ export const LineImageCarouselContent = ({
|
|
|
458
444
|
actionContentErrorMessage,
|
|
459
445
|
actionLabelErrorMessage,
|
|
460
446
|
index,
|
|
461
|
-
type:
|
|
447
|
+
type: CAROUSEL,
|
|
462
448
|
messageType: 'originalContentUrl',
|
|
463
449
|
});
|
|
464
450
|
}
|
|
@@ -8,3 +8,6 @@ export const MESSAGE_ACTION_TYPE = 'message';
|
|
|
8
8
|
export const URL_ACTION_TYPE = 'uri';
|
|
9
9
|
export const MAX_ACTION_LABEL_LENGTH = 12;
|
|
10
10
|
export const MAX_ALLOWED_TITLE_LENGTH = 100;
|
|
11
|
+
export const CAROUSEL = 'carousel';
|
|
12
|
+
export const FLEX = 'flex';
|
|
13
|
+
export const TEMPLATE = 'template';
|
|
@@ -25,6 +25,9 @@ import {
|
|
|
25
25
|
MESSAGE_ACTION_TYPE,
|
|
26
26
|
URL_ACTION_TYPE,
|
|
27
27
|
MAX_ALLOWED_TITLE_LENGTH,
|
|
28
|
+
FLEX,
|
|
29
|
+
CAROUSEL,
|
|
30
|
+
TEMPLATE,
|
|
28
31
|
} from './constants';
|
|
29
32
|
|
|
30
33
|
export const LineImageCarousel = (props) => {
|
|
@@ -44,7 +47,7 @@ export const LineImageCarousel = (props) => {
|
|
|
44
47
|
getAllTemplates,
|
|
45
48
|
} = props;
|
|
46
49
|
|
|
47
|
-
if (activeKey !==
|
|
50
|
+
if (activeKey !== FLEX) {
|
|
48
51
|
return null;
|
|
49
52
|
}
|
|
50
53
|
|
|
@@ -55,7 +58,7 @@ export const LineImageCarousel = (props) => {
|
|
|
55
58
|
originalContentUrl: '',
|
|
56
59
|
aspectRatio: '',
|
|
57
60
|
previewImageUrl: '',
|
|
58
|
-
type:
|
|
61
|
+
type: CAROUSEL,
|
|
59
62
|
};
|
|
60
63
|
|
|
61
64
|
const [carouselImages, updateCarouselImage] = useState([defaultCarouselContent]);
|
|
@@ -70,7 +73,7 @@ export const LineImageCarousel = (props) => {
|
|
|
70
73
|
|
|
71
74
|
useEffect(() => {
|
|
72
75
|
const { messageTitle = '', type, template, altText } = content;
|
|
73
|
-
if (
|
|
76
|
+
if ([TEMPLATE, FLEX].includes(type)) {
|
|
74
77
|
updateCreateNew(!isFullMode ? !!template : true);
|
|
75
78
|
if (messageTitle) {
|
|
76
79
|
updateTextMessageTitle(messageTitle);
|
|
@@ -80,10 +83,9 @@ export const LineImageCarousel = (props) => {
|
|
|
80
83
|
}
|
|
81
84
|
if (template) {
|
|
82
85
|
const validCarouselImages = [];
|
|
83
|
-
if (template
|
|
86
|
+
if (template?.type === CAROUSEL) {
|
|
84
87
|
const { contents = [] } = template;
|
|
85
|
-
|
|
86
|
-
contents.forEach((content = {}, index1) => {
|
|
88
|
+
contents.forEach((content = {}, index) => {
|
|
87
89
|
const {
|
|
88
90
|
footer: {
|
|
89
91
|
contents: [{
|
|
@@ -101,19 +103,17 @@ export const LineImageCarousel = (props) => {
|
|
|
101
103
|
} = {},
|
|
102
104
|
} = content || {};
|
|
103
105
|
validCarouselImages.push({
|
|
104
|
-
activeIndex:
|
|
106
|
+
activeIndex: index,
|
|
105
107
|
originalContentUrl: url,
|
|
106
108
|
aspectRatio,
|
|
107
109
|
selectedActionType: buttonType ? (buttonType === MESSAGE_ACTION_TYPE ? TEXT_ACTION_TYPE : URL_ACTION_TYPE) : '',
|
|
108
110
|
actionContent: text || uri,
|
|
109
111
|
actionLabel: label,
|
|
110
|
-
type:
|
|
112
|
+
type: CAROUSEL,
|
|
111
113
|
});
|
|
112
114
|
})
|
|
113
|
-
}
|
|
114
115
|
} else {
|
|
115
|
-
const { columns } = template;
|
|
116
|
-
if (columns && columns.length) {
|
|
116
|
+
const { columns = [] } = template;
|
|
117
117
|
columns.forEach((column = {}, index) => {
|
|
118
118
|
const {
|
|
119
119
|
action: {
|
|
@@ -133,10 +133,9 @@ export const LineImageCarousel = (props) => {
|
|
|
133
133
|
actionContent: text || uri,
|
|
134
134
|
actionLabel: label,
|
|
135
135
|
aspectRatio,
|
|
136
|
-
type:
|
|
136
|
+
type: CAROUSEL,
|
|
137
137
|
});
|
|
138
138
|
})
|
|
139
|
-
}
|
|
140
139
|
}
|
|
141
140
|
updateCarouselImage(validCarouselImages);
|
|
142
141
|
}
|
|
@@ -176,7 +175,7 @@ export const LineImageCarousel = (props) => {
|
|
|
176
175
|
isError: isErrorIndex !== undefined && isErrorIndex !== false,
|
|
177
176
|
messageTitle: existingMessageTitle,
|
|
178
177
|
altText: existingTitle,
|
|
179
|
-
type:
|
|
178
|
+
type: FLEX,
|
|
180
179
|
index,
|
|
181
180
|
}
|
|
182
181
|
|
|
@@ -392,17 +391,9 @@ export const LineImageCarousel = (props) => {
|
|
|
392
391
|
if(!imageCarouselTemplate && imageCarouselContents) {
|
|
393
392
|
isNewLineFormat = true;
|
|
394
393
|
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
templateData.key = template.name;
|
|
399
|
-
|
|
400
|
-
} else {
|
|
401
|
-
templateData.url = (imageCarouselTemplate ? get(imageCarouselTemplate, 'columns.0.imageUrl', '') : '');
|
|
402
|
-
templateData.title = template.name;
|
|
403
|
-
templateData.key = template.name;
|
|
404
|
-
}
|
|
405
|
-
|
|
394
|
+
templateData.url = get(imageCarouselContents, 'contents.0.hero.url', '') || get(imageCarouselTemplate, 'columns.0.imageUrl', '');
|
|
395
|
+
templateData.title = template.name;
|
|
396
|
+
templateData.key = template.name;
|
|
406
397
|
templateData.hoverOption = (
|
|
407
398
|
<CapButton onClick={() => onTemplateSelection(template)}>
|
|
408
399
|
<FormattedMessage {...messages.select} />
|
|
@@ -435,19 +426,18 @@ export const LineImageCarousel = (props) => {
|
|
|
435
426
|
|
|
436
427
|
const onTemplateSelection = (templateData) => {
|
|
437
428
|
const template = get(templateData, 'versions.base.content.messages[0].template', {});
|
|
438
|
-
const
|
|
429
|
+
const contents = get(templateData, 'versions.base.content.messages[0].contents', {});
|
|
439
430
|
const altText = get(templateData, 'versions.base.content.messages[0].altText', '');
|
|
440
431
|
let isNewLineFormat = false;
|
|
441
432
|
const validCarouselImages = [];
|
|
442
433
|
|
|
443
|
-
if (!isEmpty(
|
|
434
|
+
if (!isEmpty(contents) && isEmpty(template)) {
|
|
444
435
|
isNewLineFormat = true;
|
|
445
436
|
}
|
|
446
437
|
if (isNewLineFormat) {
|
|
447
|
-
const { contents = [] } =
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
contents.forEach((content = {}, index1) => {
|
|
438
|
+
const { contents : flexContents = [] } = contents;
|
|
439
|
+
|
|
440
|
+
flexContents.forEach((content = {}, index) => {
|
|
451
441
|
const {
|
|
452
442
|
footer: {
|
|
453
443
|
contents: [{
|
|
@@ -465,16 +455,15 @@ export const LineImageCarousel = (props) => {
|
|
|
465
455
|
} = {},
|
|
466
456
|
} = content || {};
|
|
467
457
|
validCarouselImages.push({
|
|
468
|
-
activeIndex:
|
|
458
|
+
activeIndex: index,
|
|
469
459
|
originalContentUrl: url,
|
|
470
460
|
aspectRatio,
|
|
471
461
|
selectedActionType: buttonType ? (buttonType === MESSAGE_ACTION_TYPE ? TEXT_ACTION_TYPE : URL_ACTION_TYPE) : '',
|
|
472
462
|
actionContent: text || uri,
|
|
473
463
|
actionLabel: label,
|
|
474
|
-
type:
|
|
464
|
+
type: CAROUSEL,
|
|
475
465
|
});
|
|
476
466
|
})
|
|
477
|
-
}
|
|
478
467
|
|
|
479
468
|
} else {
|
|
480
469
|
const { columns } = template;
|
|
@@ -496,7 +485,7 @@ export const LineImageCarousel = (props) => {
|
|
|
496
485
|
selectedActionType: type ? (type === MESSAGE_ACTION_TYPE ? TEXT_ACTION_TYPE : URL_ACTION_TYPE) : '',
|
|
497
486
|
actionContent: text || uri,
|
|
498
487
|
actionLabel: label,
|
|
499
|
-
type:
|
|
488
|
+
type: CAROUSEL,
|
|
500
489
|
});
|
|
501
490
|
})
|
|
502
491
|
|
|
@@ -37,6 +37,10 @@ export default defineMessages({
|
|
|
37
37
|
},
|
|
38
38
|
"imageDimenstionDescription": {
|
|
39
39
|
id: `${scope}.imageDimenstionDescription`,
|
|
40
|
+
defaultMessage: 'Format: JPEG, PNG Aspect ratio: 1:1 Dimensions: 1024px x 1024px Size: 1 MB',
|
|
41
|
+
},
|
|
42
|
+
"imageDimenstionDesc": {
|
|
43
|
+
id: `${scope}.imageDimenstionDesc`,
|
|
40
44
|
defaultMessage: 'Format: JPEG, PNG Dimensions: 1024px x 1024px Size: 1 MB',
|
|
41
45
|
},
|
|
42
46
|
"imageReUpload": {
|