@capillarytech/creatives-library 6.7.1 → 6.8.0

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.
Files changed (85) hide show
  1. package/assets/line-image-placeholder.svg +14 -0
  2. package/assets/line.png +0 -0
  3. package/assets/smiley-placeholder.svg +11 -0
  4. package/components/TemplatePreview/index.js +185 -8
  5. package/index.js +3 -3
  6. package/package.json +1 -1
  7. package/routes.js +2 -2
  8. package/services/api.js +3 -0
  9. package/styles/vendor/semantic/src/definitions/modules/accordion.less +219 -219
  10. package/v2Components/TemplatePreview/WechatRichmediaTemplatePreview/index.js +1 -1
  11. package/v2Components/TemplatePreview/assets/images/WECHAT_5x.png +0 -0
  12. package/v2Components/TemplatePreview/index.js +164 -12
  13. package/v2Components/TemplatePreview/messages.js +8 -0
  14. package/v2Containers/CreativesContainer/SlideBoxContent.js +51 -17
  15. package/v2Containers/CreativesContainer/index.js +23 -17
  16. package/v2Containers/Line/Container/Drawer/index.js +93 -0
  17. package/v2Containers/Line/Container/Image/constants.js +3 -0
  18. package/v2Containers/Line/Container/Image/index.js +460 -0
  19. package/v2Containers/Line/Container/Image/messages.js +86 -0
  20. package/v2Containers/Line/Container/Image/style.js +32 -0
  21. package/v2Containers/Line/Container/ImageMap/assets/hover/custom.png +0 -0
  22. package/v2Containers/Line/Container/ImageMap/assets/hover/templateEight.png +0 -0
  23. package/v2Containers/Line/Container/ImageMap/assets/hover/templateFive.png +0 -0
  24. package/v2Containers/Line/Container/ImageMap/assets/hover/templateFour.png +0 -0
  25. package/v2Containers/Line/Container/ImageMap/assets/hover/templateOne.png +0 -0
  26. package/v2Containers/Line/Container/ImageMap/assets/hover/templateSeven.png +0 -0
  27. package/v2Containers/Line/Container/ImageMap/assets/hover/templateSix.png +0 -0
  28. package/v2Containers/Line/Container/ImageMap/assets/hover/templateThree.png +0 -0
  29. package/v2Containers/Line/Container/ImageMap/assets/hover/templateTwo.png +0 -0
  30. package/v2Containers/Line/Container/ImageMap/assets/selected/custom.png +0 -0
  31. package/v2Containers/Line/Container/ImageMap/assets/selected/templateEight.png +0 -0
  32. package/v2Containers/Line/Container/ImageMap/assets/selected/templateFive.png +0 -0
  33. package/v2Containers/Line/Container/ImageMap/assets/selected/templateFour.png +0 -0
  34. package/v2Containers/Line/Container/ImageMap/assets/selected/templateOne.png +0 -0
  35. package/v2Containers/Line/Container/ImageMap/assets/selected/templateSeven.png +0 -0
  36. package/v2Containers/Line/Container/ImageMap/assets/selected/templateSix.png +0 -0
  37. package/v2Containers/Line/Container/ImageMap/assets/selected/templateThree.png +0 -0
  38. package/v2Containers/Line/Container/ImageMap/assets/selected/templateTwo.png +0 -0
  39. package/v2Containers/Line/Container/ImageMap/assets/templates/custom.png +0 -0
  40. package/v2Containers/Line/Container/ImageMap/assets/templates/templateEight.png +0 -0
  41. package/v2Containers/Line/Container/ImageMap/assets/templates/templateFive.png +0 -0
  42. package/v2Containers/Line/Container/ImageMap/assets/templates/templateFour.png +0 -0
  43. package/v2Containers/Line/Container/ImageMap/assets/templates/templateOne.png +0 -0
  44. package/v2Containers/Line/Container/ImageMap/assets/templates/templateSeven.png +0 -0
  45. package/v2Containers/Line/Container/ImageMap/assets/templates/templateSix.png +0 -0
  46. package/v2Containers/Line/Container/ImageMap/assets/templates/templateThree.png +0 -0
  47. package/v2Containers/Line/Container/ImageMap/assets/templates/templateTwo.png +0 -0
  48. package/v2Containers/Line/Container/ImageMap/assets/templates_with_alphabets/custom.png +0 -0
  49. package/v2Containers/Line/Container/ImageMap/assets/templates_with_alphabets/templateEight.png +0 -0
  50. package/v2Containers/Line/Container/ImageMap/assets/templates_with_alphabets/templateFive.png +0 -0
  51. package/v2Containers/Line/Container/ImageMap/assets/templates_with_alphabets/templateFour.png +0 -0
  52. package/v2Containers/Line/Container/ImageMap/assets/templates_with_alphabets/templateOne.png +0 -0
  53. package/v2Containers/Line/Container/ImageMap/assets/templates_with_alphabets/templateSeven.png +0 -0
  54. package/v2Containers/Line/Container/ImageMap/assets/templates_with_alphabets/templateSix.png +0 -0
  55. package/v2Containers/Line/Container/ImageMap/assets/templates_with_alphabets/templateThree.png +0 -0
  56. package/v2Containers/Line/Container/ImageMap/assets/templates_with_alphabets/templateTwo.png +0 -0
  57. package/v2Containers/Line/Container/ImageMap/constants.js +19 -0
  58. package/v2Containers/Line/Container/ImageMap/index.js +603 -0
  59. package/v2Containers/Line/Container/ImageMap/messages.js +126 -0
  60. package/v2Containers/Line/Container/ImageMap/style.js +94 -0
  61. package/v2Containers/Line/Container/ImageMap/templates.json +195 -0
  62. package/v2Containers/Line/Container/Sticker/index.js +224 -0
  63. package/v2Containers/Line/Container/Sticker/messages.js +34 -0
  64. package/v2Containers/Line/Container/Sticker/style.js +36 -0
  65. package/v2Containers/Line/Container/Sticker/utils.js +68 -0
  66. package/v2Containers/Line/Container/Text/index.js +338 -0
  67. package/v2Containers/Line/Container/Text/messages.js +74 -0
  68. package/v2Containers/Line/Container/Text/style.js +37 -0
  69. package/v2Containers/Line/Container/Wrapper/index.js +152 -0
  70. package/v2Containers/Line/Container/Wrapper/messages.js +46 -0
  71. package/v2Containers/Line/Container/Wrapper/style.js +44 -0
  72. package/v2Containers/Line/Container/Wrapper/utils.js +67 -0
  73. package/v2Containers/Line/Container/_lineCreate.scss +108 -0
  74. package/v2Containers/Line/Container/actions.js +99 -0
  75. package/v2Containers/Line/Container/constants.js +48 -0
  76. package/v2Containers/Line/Container/index.js +581 -0
  77. package/v2Containers/Line/Container/messages.js +66 -0
  78. package/v2Containers/Line/Container/reducer.js +103 -0
  79. package/v2Containers/Line/Container/sagas.js +137 -0
  80. package/v2Containers/Line/Container/selectors.js +30 -0
  81. package/v2Containers/Line/Container/style.js +57 -0
  82. package/v2Containers/Line/Create/index.js +1 -1
  83. package/v2Containers/Templates/index.js +40 -22
  84. package/v2Containers/Templates/messages.js +8 -0
  85. package/v2Containers/TemplatesV2/index.js +13 -0
@@ -0,0 +1,19 @@
1
+ export const LINE_ASSET_WIDTH = 1040;
2
+ export const LINE_ASSET_HEIGHT = 1040;
3
+ export const LINE_CUSTOM_ASSET_HEIGHT_MIN = 520;
4
+ export const LINE_CUSTOM_ASSET_HEIGHT_MAX= 1040;
5
+ export const DEFAULT_ASSET_TYPE = 'default';
6
+ export const CUSTOM_ASSET_TYPE = 'custom';
7
+ export const DEFAULT_TEMPLATES = [
8
+ "templateOne",
9
+ "templateTwo",
10
+ "templateThree",
11
+ "templateFour",
12
+ "templateFive",
13
+ "templateSix",
14
+ "templateSeven",
15
+ "templateEight"
16
+ ];
17
+ export const CUSTOM_TEMPLATES = [
18
+ "custom"
19
+ ];
@@ -0,0 +1,603 @@
1
+ import React, { useState, useEffect, useReducer } from 'react';
2
+ import { injectIntl, FormattedMessage } from 'react-intl';
3
+ import get from 'lodash/get';
4
+ import CapInput from '@capillarytech/cap-ui-library/CapInput';
5
+ import CapUploader from '@capillarytech/cap-ui-library/CapUploader';
6
+ import CapHeading from '@capillarytech/cap-ui-library/CapHeading';
7
+ import CapHeader from '@capillarytech/cap-ui-library/CapHeader';
8
+ import CapButton from '@capillarytech/cap-ui-library/CapButton';
9
+ import CapDrawer from '@capillarytech/cap-ui-library/CapDrawer';
10
+ import CapLabel from '@capillarytech/cap-ui-library/CapLabel';
11
+ import CapImage from '@capillarytech/cap-ui-library/CapImage';
12
+ import CapColumn from '@capillarytech/cap-ui-library/CapColumn';
13
+ import CapRow from '@capillarytech/cap-ui-library/CapRow';
14
+ import CapIcon from '@capillarytech/cap-ui-library/CapIcon';
15
+ import CapDivider from '@capillarytech/cap-ui-library/CapDivider';
16
+ import CapError from '@capillarytech/cap-ui-library/CapError';
17
+ import CapRadioGroup from '@capillarytech/cap-ui-library/CapRadioGroup';
18
+ import { CAP_SPACE_12, CAP_SPACE_16, CAP_SPACE_20, CAP_SPACE_28, CAP_SPACE_08, FONT_COLOR_05, FONT_WEIGHT_MEDIUM } from '@capillarytech/cap-ui-library/styled/variables';
19
+ import Gallery from '../../../Assets/Gallery';
20
+ import style from './style';
21
+ import withStyles from '../../../../hoc/withStyles';
22
+ import TEMPLATES_JSON from './templates.json';
23
+ import { isUrl } from '../Wrapper/utils'
24
+ import LineDrawer from '../Drawer';
25
+ import messages from './messages';
26
+ import {
27
+ LINE_ASSET_WIDTH,
28
+ LINE_ASSET_HEIGHT,
29
+ LINE_IMG_SIZE,
30
+ CUSTOM_ASSET_TYPE,
31
+ DEFAULT_ASSET_TYPE,
32
+ DEFAULT_TEMPLATES,
33
+ CUSTOM_TEMPLATES,
34
+ LINE_CUSTOM_ASSET_HEIGHT_MIN,
35
+ LINE_CUSTOM_ASSET_HEIGHT_MAX
36
+ } from './constants';
37
+ import {
38
+ IMAGE_MAP
39
+ } from '../constants';
40
+
41
+ const { CapIconAvatar } = CapIcon;
42
+
43
+ export const LineImageMap = ({
44
+ className,
45
+ id,
46
+ intl: { formatMessage },
47
+ isFullMode,
48
+ inheritedTitleStyle,
49
+ supportedExtensions,
50
+ actions = {},
51
+ Line,
52
+ index,
53
+ updateMessageState,
54
+ content,
55
+ activeKey,
56
+ Templates,
57
+ getAllTemplates
58
+ }) => {
59
+ if (activeKey !== IMAGE_MAP) {
60
+ return null;
61
+ }
62
+
63
+ //base image
64
+ const [imageSrc, updateImageSrc] = useState('');
65
+ //selected template
66
+ const [imageMapTemplate, updateImageMapTemplate] = useState();
67
+ //action links
68
+ const [actionLinks, updateActionLinks] = useState({});
69
+ //base size
70
+ const [baseSize, updateBaseSize] = useState({});
71
+ //template name
72
+ const [messageTitle, updateMessageTitle] = useState('');
73
+ //asset type
74
+ const [assetType, updateAssetType] = useState(DEFAULT_ASSET_TYPE);
75
+
76
+ const [isCreateNew, updateCreateNew] = useState(isFullMode);
77
+ const [errorMessageTitle, updateErrorMessageTitle] = useState(false);
78
+ const [isDrawerRequired, updateDrawerRequirement] = useState(false);
79
+ const [isImage, updateImageStatus] = useState(false);
80
+ const [isImageError, updateImageErrorMessage] = useState(false);
81
+ const [templateSchema, updateTemplateSchema] = useState([]);
82
+ const [isTemplateDrawerRequired, updateTemplateDrawerRequirement] = useState(false);
83
+
84
+ useEffect(() => {
85
+ const { messageTitle = '',
86
+ type,
87
+ baseUrl,
88
+ baseSize = {},
89
+ selectedTemplate,
90
+ assetType,
91
+ actionLinks
92
+ } = content;
93
+ if ( baseUrl && type === IMAGE_MAP) {
94
+ updateImageStatus(true);
95
+ updateCreateNew(true);
96
+ updateImageSrc(baseUrl);
97
+ updateMessageTitle(messageTitle);
98
+ updateImageMapTemplate(selectedTemplate);
99
+ updateAssetType(assetType);
100
+ updateActionLinks(actionLinks);
101
+ updateTemplateSchema(TEMPLATES_JSON[selectedTemplate]);
102
+ updateBaseSize(baseSize);
103
+ }
104
+ }, [content]);
105
+
106
+ useEffect(() => {
107
+ if (imageSrc && (isFullMode ? messageTitle: true) && imageMapTemplate && actionLinks) {
108
+ updateMessageState({
109
+ isError: !imageSrc || !(isFullMode ? messageTitle : true) || !imageMapTemplate || (isImageError && errorMessageTitle),
110
+ baseUrl: imageSrc,
111
+ messageTitle,
112
+ index,
113
+ type: IMAGE_MAP,
114
+ messageType: 'actions',
115
+ baseSize,
116
+ messageContent: getActions(),
117
+ selectedTemplate: imageMapTemplate,
118
+ assetType,
119
+ actionLinks
120
+ });
121
+ }
122
+ }, [errorMessageTitle, imageSrc, messageTitle, isImageError, imageMapTemplate, actionLinks, assetType, isImage, templateSchema]);
123
+
124
+ useEffect(() => {
125
+ const imgSrc = get(Line, 'uploadedAssetData', false);
126
+ if (imgSrc && typeof imgSrc !== 'object') {
127
+ updateImageSrc(imgSrc.slice(0, -5));
128
+ updateImageStatus(true);
129
+ actions.clearAsset()
130
+ }
131
+ }, [Line]);
132
+
133
+ const getActions = () => {
134
+ const actionsMap = [];
135
+ const isCustom = assetType === CUSTOM_ASSET_TYPE;
136
+ console.log("getActions", templateSchema)
137
+ templateSchema.forEach(template => {
138
+ let { label, errorMessage, ...rest } = template;
139
+ const linkUri = actionLinks[label];
140
+ if(isCustom) {
141
+ rest = {...rest, ...baseSize};
142
+ }
143
+ console.log("getActions", linkUri, template, label, actionLinks, actionLinks[label])
144
+ if(linkUri) {
145
+ actionsMap.push({
146
+ type: 'uri',
147
+ linkUri,
148
+ area: rest
149
+ });
150
+ }
151
+ });
152
+ return actionsMap;
153
+ }
154
+
155
+ const submitAction = (data, incorrectFile) => {
156
+ const {
157
+ file: {
158
+ size,
159
+ },
160
+ fileParams: {
161
+ height,
162
+ width,
163
+ },
164
+ type,
165
+ } = data;
166
+ const validWidth = width === LINE_ASSET_WIDTH;
167
+ const validHeight = assetType === CUSTOM_ASSET_TYPE ? ( LINE_CUSTOM_ASSET_HEIGHT_MIN <= height && height <= LINE_CUSTOM_ASSET_HEIGHT_MAX) : height === LINE_ASSET_HEIGHT;
168
+ if (incorrectFile || size > LINE_IMG_SIZE || !validWidth || !validHeight) {
169
+ updateImageErrorMessage(formatMessage(messages.lineImageMapIncorrectSize))
170
+ } else {
171
+ updateImageErrorMessage('')
172
+ data.fileParams.isGeneratePreview = true;
173
+ updateBaseSize({
174
+ height,
175
+ width
176
+ });
177
+ actions.uploadAsset(
178
+ data.file,
179
+ data.type,
180
+ data.fileParams,
181
+ );
182
+ }
183
+ }
184
+
185
+ const onTextTitleChange = ({ target: { value } }) => {
186
+ updateMessageTitle(value);
187
+ let errorMessage = false;
188
+ if (value === '') {
189
+ errorMessage = formatMessage(messages.emptyTitleErrorMessage);
190
+ }
191
+ updateErrorMessageTitle(errorMessage);
192
+ }
193
+
194
+ const uploadImages = (e, {files}) => {
195
+ if (e) {
196
+ e.preventDefault();
197
+ }
198
+ const _URL = window.URL || window.webkitURL;
199
+ let incorrectFile = false;
200
+ const file = files[0];
201
+ if (supportedExtensions) {
202
+ const allowedExtensions = /(\.bmp|\.jpeg|\.png|\.gif|\.jpg)$/i;
203
+ if (!allowedExtensions.exec(file.name)) {
204
+ incorrectFile = true;
205
+ }
206
+ }
207
+ const img = new Image();
208
+ img.src = _URL.createObjectURL(file);
209
+ img.onload = () => {
210
+ const fileParams = {
211
+ width: img.width,
212
+ height: img.height,
213
+ };
214
+ submitAction({file, type: 'line', fileParams}, incorrectFile);
215
+ };
216
+ if (e) {
217
+ const event = e;
218
+ event.target.value = null;
219
+ }
220
+ };
221
+
222
+ const changeAssetType = (event) => {
223
+ event.stopPropagation();
224
+ updateAssetType(event.target.value);
225
+ }
226
+
227
+ const getDrawerContent = () => {
228
+ return (
229
+ <>
230
+ <CapRadioGroup
231
+ defaultValue={DEFAULT_ASSET_TYPE}
232
+ value={assetType}
233
+ onChange={changeAssetType}
234
+ style={{fontWeight: FONT_WEIGHT_MEDIUM}}
235
+ options={[
236
+ {
237
+ label: 'Square',
238
+ value: DEFAULT_ASSET_TYPE
239
+ },
240
+ {
241
+ label: 'Custom',
242
+ value: CUSTOM_ASSET_TYPE
243
+ }
244
+ ]}
245
+ />
246
+ <CapLabel type="label1" style={{paddingTop: CAP_SPACE_12}}>
247
+ {
248
+ assetType === DEFAULT_ASSET_TYPE ? formatMessage(messages.squareAssetDesc) : formatMessage(messages.customAssetDesc)
249
+ }
250
+ </CapLabel>
251
+ <CapRow>
252
+ {getTemplatesSelection()}
253
+ </CapRow>
254
+ </>
255
+ );
256
+ }
257
+
258
+ const getTemplatesSelection = () => {
259
+ const isDefaultAssetType = assetType === DEFAULT_ASSET_TYPE ;
260
+ const templatesList = isDefaultAssetType ? DEFAULT_TEMPLATES : CUSTOM_TEMPLATES;
261
+ return (
262
+ <>
263
+ {templatesList.map(template => {
264
+ const imageSrc = imageMapTemplate === template ? require(`./assets/selected/${template}.png`) : require(`./assets/templates/${template}.png`);
265
+ return (
266
+ <CapColumn span={12} key={template}>
267
+ <CapButton
268
+ type="flat"
269
+ style={{ padding: 0, marginTop: CAP_SPACE_12, marginRight: CAP_SPACE_16, height: 'auto' }}
270
+ onClick={() => changeImageMapTemplate(template)}
271
+ >
272
+ <CapImage
273
+ src={imageSrc}
274
+ rest={{
275
+ height: isDefaultAssetType ? 260 : 520,
276
+ width: 260,
277
+ onMouseOut: e => (e.currentTarget.src = imageSrc),
278
+ onMouseOver: e => (e.currentTarget.src = require(`./assets/hover/${template}.png`))
279
+ }}
280
+ />
281
+ </CapButton>
282
+ </CapColumn>
283
+ );
284
+ })}
285
+ </>
286
+ )
287
+ }
288
+
289
+ const capUploaderCustomRequest = (uploadData) => {
290
+ uploadImages(undefined, {files: [uploadData.file]});
291
+ }
292
+
293
+ const changeImageMapTemplate = (template) => {
294
+ updateImageMapTemplate(template);
295
+ updateTemplateSchema(TEMPLATES_JSON[template]);
296
+ setDrawerVisibility(false);
297
+ }
298
+
299
+ const setDrawerVisibility = (drawervisibleFlag) => updateDrawerRequirement(drawervisibleFlag);
300
+
301
+ const onSelectTemplateClick = (event) => {
302
+ event.stopPropagation();
303
+ setDrawerVisibility(true);
304
+ }
305
+
306
+ const onReUpload = () => {
307
+ updateImageStatus(false);
308
+ updateImageSrc('');
309
+ }
310
+
311
+ const getImageSection = (isImage) => {
312
+ if (!isImage) {
313
+ return (
314
+ <>
315
+ <CapUploader.CapDragger
316
+ customRequest={(data) => capUploaderCustomRequest(data)}
317
+ className="form-builder-dragger"
318
+ disabled={!imageMapTemplate}
319
+ >
320
+ <CapHeading className="dragger-title" type="h7">
321
+ <FormattedMessage {...messages.dragAndDrop} />
322
+ </CapHeading>
323
+ <CapHeading className="dragger-or" type="label6">
324
+ <FormattedMessage {...messages.or} />
325
+ </CapHeading>
326
+ <CapButton className="dragger-button" type="secondary" style={{marginRight: CAP_SPACE_08}}>
327
+ <FormattedMessage {...messages.uploadComputer} />
328
+ </CapButton>
329
+ </CapUploader.CapDragger>
330
+ <CapLabel type="label9" style={{marginTop: CAP_SPACE_12 }}>
331
+ {formatMessage(messages.imageDimenstionDescription, {dimensions: assetType === DEFAULT_ASSET_TYPE ? '1040 X 1040 px' : '1040 X 520 - 2040 px'})}
332
+ </CapLabel>
333
+ <CapDivider />
334
+ </>);
335
+ }
336
+ return (
337
+ <>
338
+ <CapImage className="base-image-preview" src={`${imageSrc}/1040`} />
339
+ <CapLabel type="label9" style={{marginTop: CAP_SPACE_12 }}>
340
+ {formatMessage(messages.imageDimenstionDescription, {dimensions: assetType === DEFAULT_ASSET_TYPE ? '1040 X 1040 px' : '1040 X 520 - 2040 px'})}
341
+ </CapLabel>
342
+ <CapDivider />
343
+ </>
344
+ );
345
+ }
346
+
347
+ const templatePreviewLayout = () => {
348
+ return (
349
+ <>
350
+ <div className="imagemap-preview-container">
351
+ {
352
+ !imageMapTemplate && <CapLabel type="label11" className="select-template-desc">
353
+ <FormattedMessage {...messages.selectTemplateDesc} />
354
+ </CapLabel>
355
+ }
356
+ {
357
+ imageMapTemplate && <CapImage className="template-preview" src={require(`./assets/templates_with_alphabets/${imageMapTemplate}.png`)} />
358
+ }
359
+ {
360
+ imageSrc && <CapImage className="image-preview" src={`${imageSrc}/1040`} width={122} height={122}/>
361
+ }
362
+ </div>
363
+ <CapButton
364
+ className="select-template"
365
+ type="secondary"
366
+ style={{width: '122px', padding: '0px'}}
367
+ onClick={onSelectTemplateClick}
368
+ >
369
+ <FormattedMessage {...messages.textMessageSelectTemplate} />
370
+ </CapButton>
371
+ </>
372
+ );
373
+ }
374
+
375
+ const changeLinkUrls = (value, label, index) => {
376
+ console.log("changeLinkUrls", value, label, index)
377
+ if(!isUrl(value) && value !== "") {
378
+ templateSchema[index].errorMessage = formatMessage(messages.validUrl);
379
+ updateTemplateSchema(templateSchema);
380
+ } else {
381
+ templateSchema[index].errorMessage = '';
382
+ updateTemplateSchema(templateSchema);
383
+ }
384
+ actionLinks[label] = value;
385
+ updateActionLinks({...actionLinks});
386
+ }
387
+
388
+ const setNewContent = () => updateCreateNew(true);
389
+
390
+ const templateLinksLayout = () => {
391
+ return (
392
+ <>
393
+ <CapHeader
394
+ size="label1"
395
+ title={formatMessage(messages.linkUrl)}
396
+ description={formatMessage(messages.linkDescription)}
397
+ />
398
+ {templateSchema.map((templateDetails, index) => {
399
+ const { label, errorMessage = '' } = templateDetails;
400
+ return (
401
+ <CapInput
402
+ inline
403
+ label={<CapIconAvatar text={label} width={CAP_SPACE_28} height={CAP_SPACE_28} style={{borderRadius: CAP_SPACE_28}} />}
404
+ labelPosition="left"
405
+ id={`templateLinks${label}`}
406
+ onChange={(event) => changeLinkUrls(event.target.value, label, index)}
407
+ errorMessage={errorMessage}
408
+ defaultValue={actionLinks[label]}
409
+ className="template-links"
410
+ placeholder={formatMessage(messages.linkUrl)}
411
+ />
412
+ )
413
+ })}
414
+ </>
415
+ );
416
+ }
417
+
418
+ const getLineImageMapDrawerContent = () => {
419
+ const lineTextTemplates = Templates.templates;
420
+ if (!lineTextTemplates) {
421
+ return null;
422
+ }
423
+
424
+ const cardDataList = [];
425
+ lineTextTemplates.forEach(template => {
426
+ let templateData = {};
427
+ const {
428
+ content: {
429
+ messages: [{
430
+ baseUrl = '',
431
+ }] = [{}],
432
+ } = {},
433
+ } = template.versions.base;
434
+ templateData.url = baseUrl;
435
+ templateData.title = template.name;
436
+ templateData.key = template.name;
437
+ templateData.hoverOption = (
438
+ <CapButton onClick={() => onTemplateSelection(template)}>
439
+ <FormattedMessage {...messages.select} />
440
+ </CapButton>
441
+ );
442
+ if (baseUrl) {
443
+ cardDataList.push(templateData);
444
+ }
445
+ });
446
+ return (
447
+ <>
448
+ <CapHeading type="h3" className="drawer-head">
449
+ {formatMessage(messages.lineTemplateImageMap)}
450
+ </CapHeading>
451
+ <LineDrawer
452
+ getAllTemplates={getAllTemplates}
453
+ cardDataList={cardDataList}
454
+ isDrawer={isTemplateDrawerRequired}
455
+ searchPlaceholder={formatMessage(messages.searchImageMaps)}
456
+ />
457
+ </>
458
+ );
459
+ };
460
+
461
+ const onTemplateSelection = (template) => {
462
+ const baseUrl = get(template, 'versions.base.content.messages[0].baseUrl', '');
463
+ const baseSize = get(template, 'versions.base.content.messages[0].baseSize', '');
464
+ const selectedTemplate = get(template, 'definition.selectedTemplate', '');
465
+ const assetType = get(template, 'definition.assetType', '');
466
+ const actionLinks = get(template, 'definition.actionLinks', {});
467
+ updateImageStatus(true);
468
+ updateCreateNew(true);
469
+ updateImageSrc(baseUrl);
470
+ updateBaseSize(baseSize);
471
+ updateImageMapTemplate(selectedTemplate);
472
+ updateAssetType(assetType);
473
+ updateActionLinks(actionLinks);
474
+ updateTemplateSchema(TEMPLATES_JSON[selectedTemplate]);
475
+ updateTemplateDrawerRequirement(false);
476
+ }
477
+
478
+ const onSelectTemplate = (event) => {
479
+ event.stopPropagation();
480
+ updateTemplateDrawerRequirement(true);
481
+ }
482
+
483
+ const getLineImageMapSection = () => {
484
+ if(isCreateNew) {
485
+ return (
486
+ <>
487
+ <CapHeader
488
+ title={formatMessage(messages.richMsgHeader)}
489
+ description={formatMessage(messages.richMsgDesc)}
490
+ size="label1"
491
+ />
492
+ <CapRow className="imagemap-container">
493
+ <CapColumn span={8}>
494
+ {templatePreviewLayout()}
495
+ </CapColumn>
496
+ <CapColumn span={16}>
497
+ {isImage &&
498
+ <CapButton
499
+ className="dragger-button"
500
+ type="flat"
501
+ style={{ top:'-12px', position: 'absolute', right: 0, color: FONT_COLOR_05 }}
502
+ onClick={onReUpload}
503
+ >
504
+ <FormattedMessage {...messages.imageReUpload} />
505
+ </CapButton>}
506
+ <CapHeading type="h4">{formatMessage(messages.uploadImageLabel)}</CapHeading>
507
+ <CapLabel type="label1" style={{paddingTop: CAP_SPACE_12, paddingBottom: CAP_SPACE_08}}>{formatMessage(messages.uploadImageDesc)}</CapLabel>
508
+ <CapError key={`${id}-with-label`}>{isImageError}</CapError>
509
+ <form encType="multipart/form-data" id={`${id}_form`}>
510
+ <input
511
+ key={`${id}_imgFile`}
512
+ style={{ display: 'none'}}
513
+ id="fileName"
514
+ type="file"
515
+ onChange={(e) => uploadImages(e, {files: e.target.files})}
516
+ accept={supportedExtensions ? supportedExtensions : "image/*"}
517
+ />
518
+ {getImageSection(isImage)}
519
+ <CapDrawer
520
+ content={getDrawerContent()}
521
+ title="Select image template - Rich message"
522
+ visible={isDrawerRequired}
523
+ width={620}
524
+ onClose={() => updateDrawerRequirement(false)}
525
+ />
526
+ </form>
527
+ {imageMapTemplate && templateLinksLayout()}
528
+ </CapColumn>
529
+ </CapRow>
530
+ </>
531
+ )
532
+ } else {
533
+ return (
534
+ <div className="form-builder-dragger" style={{
535
+ textAlign: 'center',
536
+ border: '2px dashed lightgrey',
537
+ minHeight: 120,
538
+ padding: 60
539
+ }}>
540
+ <CapHeader
541
+ className="choice-title"
542
+ size="regular"
543
+ title={formatMessage(messages.textMessageAddLabel)}
544
+ style={{ marginBottom: 12 }}
545
+ />
546
+
547
+ <CapButton
548
+ className="create-button"
549
+ type="secondary"
550
+ style={{marginRight: CAP_SPACE_08}}
551
+ onClick={setNewContent}
552
+ >
553
+ <FormattedMessage {...messages.textMessageCreateNew} />
554
+ </CapButton>
555
+
556
+ <CapHeading className="" type="label6" style={{ display: 'inline-block' }}>
557
+ <FormattedMessage {...messages.textMessageORLabel} />
558
+ </CapHeading>
559
+
560
+ <CapButton
561
+ className="dragger-button"
562
+ type="secondary"
563
+ style={{marginLeft: CAP_SPACE_08}}
564
+ onClick={onSelectTemplate}
565
+ >
566
+ <FormattedMessage {...messages.textMessageSelectTemplate} />
567
+ </CapButton>
568
+ </div>);
569
+ }
570
+ }
571
+
572
+ return (
573
+ <div className={className}>
574
+ {
575
+ isFullMode
576
+ ? (
577
+ <CapInput
578
+ id={`${id}_input`}
579
+ onChange={onTextTitleChange}
580
+ errorMessage={errorMessageTitle}
581
+ className="image-template-title"
582
+ style={inheritedTitleStyle || {}}
583
+ placeholder={formatMessage(messages.textMessageTitlePlaceholder)}
584
+ defaultValue={messageTitle || ''}
585
+ value={messageTitle || ''}
586
+ size="default"
587
+ label={formatMessage(messages.textMessageTitleLabel)}
588
+ />
589
+ )
590
+ : null
591
+ }
592
+ {getLineImageMapSection()}
593
+ <CapDrawer
594
+ content={getLineImageMapDrawerContent()}
595
+ visible={isTemplateDrawerRequired}
596
+ width={624}
597
+ onClose={() => updateTemplateDrawerRequirement(false)}
598
+ />
599
+ </div>
600
+ )
601
+ }
602
+
603
+ export default injectIntl(withStyles(LineImageMap, style));