@zohodesk/dot 1.0.0-temp-213 → 1.0.0-temp-215
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/.cli/propValidation_report.html +1 -1
- package/README.md +8 -0
- package/assets/Appearance/dark/mode/Dot_DarkMode.module.css +7 -7
- package/assets/Appearance/dark/themes/blue/blue_DotCTA_DarkModifyCategory.module.css +13 -0
- package/assets/Appearance/dark/themes/green/green_DotCTA_DarkModifyCategory.module.css +13 -0
- package/assets/Appearance/dark/themes/orange/orange_DotCTA_DarkModifyCategory.module.css +13 -0
- package/assets/Appearance/dark/themes/red/red_DotCTA_DarkModifyCategory.module.css +13 -0
- package/assets/Appearance/dark/themes/yellow/yellow_DotCTA_DarkModifyCategory.module.css +13 -0
- package/assets/Appearance/light/mode/Dot_LightMode.module.css +13 -13
- package/assets/Appearance/light/themes/blue/blue_DotCTA_LightModifyCategory.module.css +13 -0
- package/assets/Appearance/light/themes/green/green_DotCTA_LightModifyCategory.module.css +13 -0
- package/assets/Appearance/light/themes/orange/orange_DotCTA_LightModifyCategory.module.css +13 -0
- package/assets/Appearance/light/themes/red/red_DotCTA_LightModifyCategory.module.css +13 -0
- package/assets/Appearance/light/themes/yellow/yellow_DotCTA_LightModifyCategory.module.css +13 -0
- package/assets/Appearance/pureDark/mode/Dot_PureDarkMode.module.css +5 -5
- package/assets/Appearance/pureDark/themes/blue/blue_DotCTA_PureDarkModifyCategory.module.css +13 -0
- package/assets/Appearance/pureDark/themes/green/green_DotCTA_PureDarkModifyCategory.module.css +13 -0
- package/assets/Appearance/pureDark/themes/orange/orange_DotCTA_PureDarkModifyCategory.module.css +13 -0
- package/assets/Appearance/pureDark/themes/red/red_DotCTA_PureDarkModifyCategory.module.css +13 -0
- package/assets/Appearance/pureDark/themes/yellow/yellow_DotCTA_PureDarkModifyCategory.module.css +13 -0
- package/es/Attachment/Attachment.module.css +7 -3
- package/es/AttachmentViewer/Attachment.js +106 -1
- package/es/AttachmentViewer/AttachmentViewer.js +114 -28
- package/es/AttachmentViewer/AttachmentViewer.module.css +32 -9
- package/es/AttachmentViewer/__tests__/__snapshots__/AttachmentViewer.spec.js.snap +15 -16
- package/es/AttachmentViewer/props/defaultProps.js +1 -1
- package/es/AttachmentViewer/props/propTypes.js +9 -1
- package/es/AttachmentViewer/utils.js +98 -13
- package/es/form/fields/Fields.module.css +3 -0
- package/es/form/fields/RadioField/RadioField.js +1 -1
- package/es/lookup/Lookup/Lookup.js +2 -1
- package/es/lookup/Lookup/Lookup.module.css +6 -1
- package/es/lookup/Lookup/props/propTypes.js +1 -0
- package/es/utils/General.js +23 -1
- package/lib/Attachment/Attachment.module.css +7 -3
- package/lib/AttachmentViewer/Attachment.js +109 -1
- package/lib/AttachmentViewer/AttachmentViewer.js +121 -25
- package/lib/AttachmentViewer/AttachmentViewer.module.css +32 -9
- package/lib/AttachmentViewer/__tests__/__snapshots__/AttachmentViewer.spec.js.snap +15 -16
- package/lib/AttachmentViewer/props/defaultProps.js +1 -1
- package/lib/AttachmentViewer/props/propTypes.js +9 -1
- package/lib/AttachmentViewer/utils.js +102 -8
- package/lib/form/fields/Fields.module.css +3 -0
- package/lib/form/fields/RadioField/RadioField.js +1 -1
- package/lib/lookup/Lookup/Lookup.js +2 -1
- package/lib/lookup/Lookup/Lookup.module.css +6 -1
- package/lib/lookup/Lookup/props/propTypes.js +1 -0
- package/lib/utils/General.js +25 -1
- package/package.json +12 -13
- package/result.json +1 -0
- package/unittest/index.html +45 -0
- package/es/common/dot_common.module.css +0 -4
- package/lib/common/dot_common.module.css +0 -4
|
@@ -5,16 +5,17 @@ import { Container, Box } from '@zohodesk/components/lib/Layout';
|
|
|
5
5
|
import { Icon } from '@zohodesk/icons';
|
|
6
6
|
import Avatar from '@zohodesk/components/lib/Avatar/Avatar';
|
|
7
7
|
import { ResponsiveReceiver } from '@zohodesk/components/lib/Responsive/CustomResponsive';
|
|
8
|
+
import Typography from '@zohodesk/components/lib/Typography/Typography';
|
|
8
9
|
import { getUniqueId } from '@zohodesk/components/lib/Provider/IdProvider';
|
|
10
|
+
import Button from '@zohodesk/components/es/Button/Button';
|
|
9
11
|
import AttachmentImage from "./AttachmentImage";
|
|
10
12
|
import Link from "../Link/Link";
|
|
11
13
|
import IconButton from "../IconButton/IconButton";
|
|
12
14
|
import FreezeLayer from "../FreezeLayer/FreezeLayer";
|
|
13
|
-
import {
|
|
15
|
+
import { getExtensionFromFileName, getAttachmentIconDetails } from "./Attachment";
|
|
14
16
|
import { shallowDiff } from "../utils/General";
|
|
17
|
+
import { checkFileSourcesValidation, FILE_EXTENSIONS } from "./utils";
|
|
15
18
|
import style from "./AttachmentViewer.module.css";
|
|
16
|
-
import { checkFileSourcesValidation } from "./utils";
|
|
17
|
-
import audioThumbNail from "../../images/audio_thumbnail.png";
|
|
18
19
|
export default class AttachmentViewer extends Component {
|
|
19
20
|
constructor(props) {
|
|
20
21
|
super(props);
|
|
@@ -43,6 +44,26 @@ export default class AttachmentViewer extends Component {
|
|
|
43
44
|
this.getUpdateDataList = this.getUpdateDataList.bind(this);
|
|
44
45
|
this.zoomMaintain = this.zoomMaintain.bind(this);
|
|
45
46
|
this.handleMenuValidation = this.handleMenuValidation.bind(this);
|
|
47
|
+
this.getPreviewIconData = this.getPreviewIconData.bind(this);
|
|
48
|
+
this.renderIframe = this.renderIframe.bind(this);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
isImageFileType(fileName) {
|
|
52
|
+
const extension = (getExtensionFromFileName(fileName) || '').toLowerCase();
|
|
53
|
+
if (!extension) return false;
|
|
54
|
+
return FILE_EXTENSIONS.image.map(ext => ext.toLowerCase()).includes(extension);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
isVideoFileType(fileName) {
|
|
58
|
+
const extension = (getExtensionFromFileName(fileName) || '').toLowerCase();
|
|
59
|
+
if (!extension) return false;
|
|
60
|
+
return FILE_EXTENSIONS.video.map(ext => ext.toLowerCase()).includes(extension);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
isAudioFileType(fileName) {
|
|
64
|
+
const extension = (getExtensionFromFileName(fileName) || '').toLowerCase();
|
|
65
|
+
if (!extension) return false;
|
|
66
|
+
return FILE_EXTENSIONS.audio.map(ext => ext.toLowerCase()).includes(extension);
|
|
46
67
|
}
|
|
47
68
|
|
|
48
69
|
componentDidMount() {
|
|
@@ -87,13 +108,19 @@ export default class AttachmentViewer extends Component {
|
|
|
87
108
|
data,
|
|
88
109
|
selectedIndex
|
|
89
110
|
} = this.state;
|
|
111
|
+
const {
|
|
112
|
+
allowedPreviewExtensionsData
|
|
113
|
+
} = this.props;
|
|
90
114
|
const selectedAttachment = data[selectedIndex] || {};
|
|
91
|
-
const selectedAttachmentViewUrl = selectedAttachment.viewUrl;
|
|
92
|
-
|
|
115
|
+
const selectedAttachmentViewUrl = selectedAttachment.viewUrl; // const selectedAttachmentDownloadUrl = selectedAttachment.downloadUrl;
|
|
116
|
+
|
|
93
117
|
const selectedAttachmentName = selectedAttachment.name;
|
|
118
|
+
const selectedAttachmentPreviewUrl = selectedAttachment.previewurl;
|
|
94
119
|
checkFileSourcesValidation({
|
|
95
120
|
fileName: selectedAttachmentName,
|
|
96
|
-
viewURL: selectedAttachmentViewUrl
|
|
121
|
+
viewURL: selectedAttachmentViewUrl,
|
|
122
|
+
previewUrl: selectedAttachmentPreviewUrl,
|
|
123
|
+
allowedPreviewExtensionsData
|
|
97
124
|
}).then(fileSourceValidation => {
|
|
98
125
|
const {
|
|
99
126
|
isViewURLValid,
|
|
@@ -250,7 +277,37 @@ export default class AttachmentViewer extends Component {
|
|
|
250
277
|
};
|
|
251
278
|
}
|
|
252
279
|
|
|
253
|
-
|
|
280
|
+
getPreviewIconData(name, size, dataId) {
|
|
281
|
+
const fileUnknown = {
|
|
282
|
+
iconName: 'ZD-GN-fileUnknown',
|
|
283
|
+
iconSize: '40'
|
|
284
|
+
};
|
|
285
|
+
const fileIconName = getAttachmentIconDetails(name);
|
|
286
|
+
const fileDetails = name ? {
|
|
287
|
+
iconName: fileIconName,
|
|
288
|
+
iconSize: size
|
|
289
|
+
} : fileUnknown;
|
|
290
|
+
const {
|
|
291
|
+
iconName,
|
|
292
|
+
iconSize
|
|
293
|
+
} = fileDetails;
|
|
294
|
+
return /*#__PURE__*/React.createElement(Icon, {
|
|
295
|
+
iconClass: style.prevFooterIcon,
|
|
296
|
+
name: iconName,
|
|
297
|
+
size: iconSize,
|
|
298
|
+
"data-id": dataId
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
renderIframe(previewurl) {
|
|
303
|
+
return /*#__PURE__*/React.createElement("iframe", {
|
|
304
|
+
src: previewurl,
|
|
305
|
+
className: style.previewFrame,
|
|
306
|
+
...this.props.customProps.iframeProps
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
imgPreviewView(downloadUrl) {
|
|
254
311
|
var _this = this;
|
|
255
312
|
|
|
256
313
|
const {
|
|
@@ -262,7 +319,9 @@ export default class AttachmentViewer extends Component {
|
|
|
262
319
|
} = this.state;
|
|
263
320
|
const {
|
|
264
321
|
maintainZoom,
|
|
265
|
-
dataId
|
|
322
|
+
dataId,
|
|
323
|
+
i18nKeys,
|
|
324
|
+
renderUnSupportedElement
|
|
266
325
|
} = this.props;
|
|
267
326
|
|
|
268
327
|
const getImgStyle = i => {
|
|
@@ -299,17 +358,25 @@ export default class AttachmentViewer extends Component {
|
|
|
299
358
|
children,
|
|
300
359
|
dataId = 'attachViewer',
|
|
301
360
|
customClass = {},
|
|
302
|
-
customProps = {}
|
|
361
|
+
customProps = {},
|
|
362
|
+
previewurl,
|
|
363
|
+
type
|
|
303
364
|
} = data;
|
|
304
365
|
const {
|
|
305
366
|
audioProps = {},
|
|
306
|
-
imageProps = {}
|
|
367
|
+
imageProps = {},
|
|
368
|
+
videoProps = {}
|
|
307
369
|
} = customProps;
|
|
308
370
|
const {
|
|
309
371
|
customImageClass = '',
|
|
310
372
|
customChildrenClass = ''
|
|
311
373
|
} = customClass;
|
|
312
374
|
const retainZoom = canZoom && selectedIndex == i && maintainZoom;
|
|
375
|
+
const extension = getExtensionFromFileName(name);
|
|
376
|
+
const {
|
|
377
|
+
previewUnsupportedText = "Preview not available for the selected file type.",
|
|
378
|
+
downloadText = "Download"
|
|
379
|
+
} = i18nKeys;
|
|
313
380
|
return /*#__PURE__*/React.createElement(Container, {
|
|
314
381
|
className: style.imgBox,
|
|
315
382
|
id: `imgBox${i}`,
|
|
@@ -320,32 +387,52 @@ export default class AttachmentViewer extends Component {
|
|
|
320
387
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
321
388
|
className: style.imgRef,
|
|
322
389
|
id: `imgPreviewRef${i}`
|
|
323
|
-
},
|
|
324
|
-
|
|
390
|
+
}, selectedIndex == i && /*#__PURE__*/React.createElement(React.Fragment, null, _this.isAudioFileType(name) ? /*#__PURE__*/React.createElement("audio", {
|
|
391
|
+
controls: true,
|
|
392
|
+
className: style.zoomIn,
|
|
393
|
+
"data-id": `${dataId}_audioPreview`,
|
|
394
|
+
"data-test-id": `${dataId}_audioPreview`,
|
|
395
|
+
...audioProps
|
|
396
|
+
}, /*#__PURE__*/React.createElement("source", {
|
|
397
|
+
src: previewurl || viewUrl,
|
|
398
|
+
type: `audio/${extension}`
|
|
399
|
+
})) : _this.isVideoFileType(name) ? /*#__PURE__*/React.createElement("video", {
|
|
325
400
|
controls: true,
|
|
326
401
|
className: style.zoomIn,
|
|
327
402
|
"data-id": `${dataId}_videoPreview`,
|
|
328
403
|
"data-test-id": `${dataId}_videoPreview`,
|
|
329
|
-
...
|
|
404
|
+
...videoProps
|
|
330
405
|
}, /*#__PURE__*/React.createElement("source", {
|
|
331
406
|
src: viewUrl,
|
|
332
|
-
type: `
|
|
333
|
-
})) :
|
|
407
|
+
type: `video/${extension}`
|
|
408
|
+
})) : _this.isImageFileType(name) || children ? /*#__PURE__*/React.createElement(AttachmentImage, {
|
|
334
409
|
customClass: {
|
|
335
|
-
customImageClass: `${style.img} ${style.altText}
|
|
336
|
-
${canZoom || retainZoom ? isZoomed ? `${style.zoomedImg} ${style.zoomOutCursor}` : `${style.normalImg} ${style.zoomInCursor}` : ''} ${customImageClass}`,
|
|
410
|
+
customImageClass: `${style.img} ${style.altText} ${canZoom || retainZoom ? isZoomed ? `${style.zoomedImg} ${style.zoomOutCursor}` : `${style.normalImg} ${style.zoomInCursor}` : ''} ${customImageClass}`,
|
|
337
411
|
customChildrenClass
|
|
338
412
|
},
|
|
339
413
|
src: viewUrl,
|
|
340
|
-
onClick: isPreviewAttachmentValid ? isZoomed ? _this.zoomOut.bind(_this, i) : e =>
|
|
341
|
-
_this.zoomIn(e, i, true);
|
|
342
|
-
} : undefined,
|
|
414
|
+
onClick: isPreviewAttachmentValid ? isZoomed ? _this.zoomOut.bind(_this, i) : e => _this.zoomIn(e, i, true) : undefined,
|
|
343
415
|
alt: name,
|
|
344
416
|
dataId: dataId,
|
|
345
417
|
id: `img${i}`,
|
|
346
418
|
isCover: false,
|
|
347
419
|
...imageProps
|
|
348
|
-
}, children)))
|
|
420
|
+
}, children) : type === "document" && previewurl != null ? _this.renderIframe(previewurl) : typeof renderUnSupportedElement === 'function' ? renderUnSupportedElement(data) : /*#__PURE__*/React.createElement("div", {
|
|
421
|
+
className: style.previewNone
|
|
422
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
423
|
+
className: style.fileTypeImg
|
|
424
|
+
}, _this.getPreviewIconData(name, '70')), /*#__PURE__*/React.createElement(Typography, {
|
|
425
|
+
$ui_size: "20",
|
|
426
|
+
$ui_weight: "semibold"
|
|
427
|
+
}, previewUnsupportedText), downloadUrl ? /*#__PURE__*/React.createElement(Link, {
|
|
428
|
+
href: downloadUrl,
|
|
429
|
+
className: style.downloadLink,
|
|
430
|
+
hasReload: true,
|
|
431
|
+
download: true
|
|
432
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
433
|
+
palette: "primaryFilled",
|
|
434
|
+
text: downloadText
|
|
435
|
+
})) : null))));
|
|
349
436
|
});
|
|
350
437
|
}
|
|
351
438
|
|
|
@@ -371,7 +458,7 @@ export default class AttachmentViewer extends Component {
|
|
|
371
458
|
} = customProps;
|
|
372
459
|
const totalLen = data.length;
|
|
373
460
|
const selectedAttachment = data[selectedIndex] || {};
|
|
374
|
-
const selectedImgUrl = selectedAttachment.viewUrl;
|
|
461
|
+
const selectedImgUrl = selectedAttachment.previewurl || selectedAttachment.viewUrl;
|
|
375
462
|
const downloadUrl = selectedAttachment.downloadUrl;
|
|
376
463
|
let authorHref;
|
|
377
464
|
let authorName;
|
|
@@ -526,7 +613,7 @@ export default class AttachmentViewer extends Component {
|
|
|
526
613
|
eleRef: this.setImgBoxRef,
|
|
527
614
|
scroll: "both",
|
|
528
615
|
flexible: true
|
|
529
|
-
}, this.imgPreviewView()), /*#__PURE__*/React.createElement(Box, {
|
|
616
|
+
}, this.imgPreviewView(downloadUrl)), /*#__PURE__*/React.createElement(Box, {
|
|
530
617
|
className: `${style.arrowBox} ${uptoTablet ? style.mbleArrowBox : style.nrmlArrowBox} ${totalLen === selectedIndex + 1 ? style.hidden : ''}`,
|
|
531
618
|
onClick: this.changeSelectedIndex.bind(this, selectedIndex + 1),
|
|
532
619
|
"data-title": i18nKeys.nextText,
|
|
@@ -582,20 +669,19 @@ export default class AttachmentViewer extends Component {
|
|
|
582
669
|
let {
|
|
583
670
|
thumbnail
|
|
584
671
|
} = item;
|
|
672
|
+
const isImageFileType = this.isImageFileType(name) || thumbnail;
|
|
585
673
|
const {
|
|
586
674
|
customImageClass = '',
|
|
587
675
|
customChildrenClass = ''
|
|
588
676
|
} = customClass;
|
|
589
|
-
thumbnail = isAudioFile(name) ? thumbnail || audioThumbNail : thumbnail; //fallback thumbnail for audio
|
|
590
|
-
|
|
591
677
|
return /*#__PURE__*/React.createElement(Box, {
|
|
592
|
-
className: `${style.imgItem} ${index === selectedIndex ? style.selected : ''}`,
|
|
678
|
+
className: `${style.imgItem} ${index === selectedIndex ? style.selected : ''} ${isImageFileType ? '' : style.previewIconDiv}`,
|
|
593
679
|
key: index,
|
|
594
680
|
onClick: this.changeSelectedIndex.bind(this, index),
|
|
595
681
|
eleRef: el => this[`img_${index}`] = el,
|
|
596
682
|
dataId: "attachPreviewList",
|
|
597
683
|
"data-title": name
|
|
598
|
-
}, /*#__PURE__*/React.createElement(AttachmentImage, {
|
|
684
|
+
}, isImageFileType || children ? /*#__PURE__*/React.createElement(AttachmentImage, {
|
|
599
685
|
src: thumbnail || viewUrl,
|
|
600
686
|
size: "small",
|
|
601
687
|
alt: name,
|
|
@@ -605,7 +691,7 @@ export default class AttachmentViewer extends Component {
|
|
|
605
691
|
},
|
|
606
692
|
dataId: dataId,
|
|
607
693
|
...customProps
|
|
608
|
-
}, children));
|
|
694
|
+
}, children) : this.getPreviewIconData(name, '40'));
|
|
609
695
|
}))))), totalLen !== 1 && /*#__PURE__*/React.createElement(IconButton, {
|
|
610
696
|
dataId: "attachToggle",
|
|
611
697
|
onClick: this.togglePViewList,
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
font-size: var(--zd_font_size22) ;
|
|
80
80
|
height: var(--zd_size38) ;
|
|
81
81
|
width: var(--zd_size38) ;
|
|
82
|
-
line-height: 1.
|
|
82
|
+
line-height: 1.6;
|
|
83
83
|
border-radius: 50%;
|
|
84
84
|
cursor: pointer;
|
|
85
85
|
}
|
|
@@ -230,14 +230,10 @@
|
|
|
230
230
|
transform: rotateX(0deg);
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
-
.
|
|
234
|
-
|
|
235
|
-
width:
|
|
236
|
-
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
.isAudio .image {
|
|
240
|
-
opacity: 0;
|
|
233
|
+
.previewFrame {
|
|
234
|
+
height: 100% ;
|
|
235
|
+
width: 100% ;
|
|
236
|
+
border: 0;
|
|
241
237
|
}
|
|
242
238
|
|
|
243
239
|
.video {
|
|
@@ -362,4 +358,31 @@
|
|
|
362
358
|
background-color: var(--dot_mirror);
|
|
363
359
|
border: 0;
|
|
364
360
|
cursor: pointer;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
.fileTypeImg {
|
|
364
|
+
margin-bottom: var(--zd_size30) ;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
.previewNone {
|
|
368
|
+
color: var(--zdt_attachmentviewer_title_text);
|
|
369
|
+
max-width: 70% ;
|
|
370
|
+
text-align: center;
|
|
371
|
+
margin: auto ;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
.downloadLink {
|
|
375
|
+
display: inline-block;
|
|
376
|
+
padding-top: var(--zd_size15) ;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
.previewIconDiv {
|
|
380
|
+
width: var(--zd_size60) ;
|
|
381
|
+
composes: dflex from '~@zohodesk/components/lib/common/common.module.css';
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
.prevFooterIcon {
|
|
385
|
+
color: var(--zdt_attachmentviewer_title_text);
|
|
386
|
+
padding: var(--zd_size2) ;
|
|
387
|
+
margin: auto ;
|
|
365
388
|
}
|
|
@@ -237,7 +237,7 @@ exports[`AttachmentViewer rendering the when isActive is true 1`] = `
|
|
|
237
237
|
data-test-id="containerComponent"
|
|
238
238
|
>
|
|
239
239
|
<div
|
|
240
|
-
class="imgItem selected
|
|
240
|
+
class="imgItem selected shrinkOff"
|
|
241
241
|
data-id="attachPreviewList"
|
|
242
242
|
data-selector-id="box"
|
|
243
243
|
data-test-id="attachPreviewList"
|
|
@@ -254,7 +254,7 @@ exports[`AttachmentViewer rendering the when isActive is true 1`] = `
|
|
|
254
254
|
</div>
|
|
255
255
|
</div>
|
|
256
256
|
<div
|
|
257
|
-
class="imgItem
|
|
257
|
+
class="imgItem shrinkOff"
|
|
258
258
|
data-id="attachPreviewList"
|
|
259
259
|
data-selector-id="box"
|
|
260
260
|
data-test-id="attachPreviewList"
|
|
@@ -271,7 +271,7 @@ exports[`AttachmentViewer rendering the when isActive is true 1`] = `
|
|
|
271
271
|
</div>
|
|
272
272
|
</div>
|
|
273
273
|
<div
|
|
274
|
-
class="imgItem
|
|
274
|
+
class="imgItem shrinkOff"
|
|
275
275
|
data-id="attachPreviewList"
|
|
276
276
|
data-selector-id="box"
|
|
277
277
|
data-test-id="attachPreviewList"
|
|
@@ -288,7 +288,7 @@ exports[`AttachmentViewer rendering the when isActive is true 1`] = `
|
|
|
288
288
|
</div>
|
|
289
289
|
</div>
|
|
290
290
|
<div
|
|
291
|
-
class="imgItem
|
|
291
|
+
class="imgItem shrinkOff"
|
|
292
292
|
data-id="attachPreviewList"
|
|
293
293
|
data-selector-id="box"
|
|
294
294
|
data-test-id="attachPreviewList"
|
|
@@ -305,7 +305,7 @@ exports[`AttachmentViewer rendering the when isActive is true 1`] = `
|
|
|
305
305
|
</div>
|
|
306
306
|
</div>
|
|
307
307
|
<div
|
|
308
|
-
class="imgItem
|
|
308
|
+
class="imgItem shrinkOff"
|
|
309
309
|
data-id="attachPreviewList"
|
|
310
310
|
data-selector-id="box"
|
|
311
311
|
data-test-id="attachPreviewList"
|
|
@@ -322,7 +322,7 @@ exports[`AttachmentViewer rendering the when isActive is true 1`] = `
|
|
|
322
322
|
</div>
|
|
323
323
|
</div>
|
|
324
324
|
<div
|
|
325
|
-
class="imgItem
|
|
325
|
+
class="imgItem shrinkOff"
|
|
326
326
|
data-id="attachPreviewList"
|
|
327
327
|
data-selector-id="box"
|
|
328
328
|
data-test-id="attachPreviewList"
|
|
@@ -339,21 +339,20 @@ exports[`AttachmentViewer rendering the when isActive is true 1`] = `
|
|
|
339
339
|
</div>
|
|
340
340
|
</div>
|
|
341
341
|
<div
|
|
342
|
-
class="imgItem shrinkOff"
|
|
342
|
+
class="imgItem previewIconDiv shrinkOff"
|
|
343
343
|
data-id="attachPreviewList"
|
|
344
344
|
data-selector-id="box"
|
|
345
345
|
data-test-id="attachPreviewList"
|
|
346
346
|
data-title="slack5.mp3"
|
|
347
347
|
>
|
|
348
|
-
<
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
data-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
</div>
|
|
348
|
+
<i
|
|
349
|
+
aria-hidden="true"
|
|
350
|
+
class="zd_font_icons basic icon-fileMp3 prevFooterIcon "
|
|
351
|
+
data-id="fontIcon"
|
|
352
|
+
data-selector-id="fontIcon"
|
|
353
|
+
data-test-id="fontIcon"
|
|
354
|
+
style="--zd-iconfont-size: var(--zd_font_size40);"
|
|
355
|
+
/>
|
|
357
356
|
</div>
|
|
358
357
|
</div>
|
|
359
358
|
</div>
|
|
@@ -8,9 +8,9 @@ export const AttachmentImage_defaultProps = {
|
|
|
8
8
|
export const AttachmentViewer_defaultProps = {
|
|
9
9
|
responsiveId: "Helmet",
|
|
10
10
|
needDownload: true,
|
|
11
|
-
i18nKeys: {},
|
|
12
11
|
maintainZoom: false,
|
|
13
12
|
isActive: false,
|
|
14
13
|
dataId: 'AttachmentViewer',
|
|
14
|
+
i18nKeys: {},
|
|
15
15
|
customProps: {}
|
|
16
16
|
};
|
|
@@ -26,7 +26,8 @@ export const AttachmentViewer_propTypes = {
|
|
|
26
26
|
downloadText: PropTypes.string,
|
|
27
27
|
closeText: PropTypes.string,
|
|
28
28
|
hideText: PropTypes.string,
|
|
29
|
-
showText: PropTypes.string
|
|
29
|
+
showText: PropTypes.string,
|
|
30
|
+
previewUnsupportedText: PropTypes.string
|
|
30
31
|
}),
|
|
31
32
|
needDownload: PropTypes.string,
|
|
32
33
|
previewObj: PropTypes.object,
|
|
@@ -34,6 +35,13 @@ export const AttachmentViewer_propTypes = {
|
|
|
34
35
|
maintainZoom: PropTypes.bool,
|
|
35
36
|
isActive: PropTypes.bool,
|
|
36
37
|
dataId: PropTypes.string,
|
|
38
|
+
allowedPreviewExtensionsData: PropTypes.shape({
|
|
39
|
+
audio: PropTypes.arrayOf(PropTypes.string),
|
|
40
|
+
video: PropTypes.arrayOf(PropTypes.string),
|
|
41
|
+
image: PropTypes.arrayOf(PropTypes.string),
|
|
42
|
+
document: PropTypes.arrayOf(PropTypes.string)
|
|
43
|
+
}),
|
|
44
|
+
renderUnSupportedElement: PropTypes.func,
|
|
37
45
|
customProps: PropTypes.shape({
|
|
38
46
|
avatarProps: PropTypes.exact(AvatarProps)
|
|
39
47
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getExtensionFromFileName } from "./Attachment";
|
|
2
2
|
export class Zoom {
|
|
3
3
|
constructor() {
|
|
4
4
|
const matrix = [1, 0, 0, 1, 0, 0]; // current view transform
|
|
@@ -120,6 +120,16 @@ export function checkImageValidity(src) {
|
|
|
120
120
|
};
|
|
121
121
|
});
|
|
122
122
|
}
|
|
123
|
+
export function checkVideoUrlValidity(url) {
|
|
124
|
+
return new Promise(resolve => {
|
|
125
|
+
const video = document.createElement('video');
|
|
126
|
+
video.src = url;
|
|
127
|
+
|
|
128
|
+
video.oncanplaythrough = () => resolve(true);
|
|
129
|
+
|
|
130
|
+
video.onerror = () => resolve(false);
|
|
131
|
+
});
|
|
132
|
+
}
|
|
123
133
|
export function checkAudioUrlValidity(url) {
|
|
124
134
|
return new Promise(resolve => {
|
|
125
135
|
const audio = new Audio(url);
|
|
@@ -134,23 +144,98 @@ export function checkAudioUrlValidity(url) {
|
|
|
134
144
|
});
|
|
135
145
|
}
|
|
136
146
|
;
|
|
147
|
+
export function isValidDocument(url) {
|
|
148
|
+
if (!url) {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
export const FILE_EXTENSIONS = {
|
|
155
|
+
audio: ['mp3', 'wav', 'wma', 'aac', 'm4r', 'm4a', 'flac', 'aiff', 'alac', 'ogg', 'opus', 'amr', 'mid', 'midi'],
|
|
156
|
+
video: ['mp4', 'mkv', 'mov', 'mpeg', 'mpg', 'flv', 'wmv', 'avi', 'webm', 'ogv', 'm4v', '3gp', '3g2'],
|
|
157
|
+
document: ['doc', 'docx', 'docm', 'dot', 'dotx', 'dotm', 'odt', 'rtf', 'txt', 'md', 'pages', 'xls', 'xlsx', 'xlsm', 'xlsb', 'csv', 'tsv', 'ods', 'sxc', 'numbers', 'ppt', 'pptx', 'pps', 'ppsx', 'pot', 'potx', 'odp', 'sxi', 'key', 'pdf', 'xml', 'json', 'yaml', 'yml', 'log', 'eml', 'msg'],
|
|
158
|
+
image: ['jpeg', 'jpg', 'png', 'apng', 'gif', 'bmp', 'dib', 'tiff', 'tif', 'ico', 'svg', 'webp', 'heic', 'heif', 'jfif', 'pjpeg', 'pjp', 'avif']
|
|
159
|
+
};
|
|
160
|
+
export const SUPPORTED_FILE_EXTENSIONS = {
|
|
161
|
+
image: ['jpeg', 'jpg', 'png', 'apng', 'gif', 'bmp', 'tiff', 'tif', 'ico', 'svg', 'heic', 'webp'],
|
|
162
|
+
doc: ['txt'],
|
|
163
|
+
pdf: ['pdf'],
|
|
164
|
+
html: ['html', 'htm', 'xhtml'],
|
|
165
|
+
ppt: ['ppt', 'pps', 'odp', 'sxi', 'pptx', 'ppsx', 'pot', 'potx', 'key'],
|
|
166
|
+
zip: ['rar', 'jar', 'zip'],
|
|
167
|
+
word: ['doc', 'docx', 'sxw', 'odt', 'docm', 'dot', 'dotm', 'dotx', 'rtf', 'pages'],
|
|
168
|
+
xml: ['xml'],
|
|
169
|
+
sheet: ['xls', 'xlsx', 'xlsm', 'xlsb', 'sxc', 'ods', 'csv', 'tsv', 'numbers'],
|
|
170
|
+
audio: ['mp3', 'wav', 'wma', 'aac', 'm4r', 'ogg', 'opus'],
|
|
171
|
+
video: ['mp4', 'mkv', 'mov', 'mpeg', 'flv', 'wmv', 'avi', 'webm', 'ogv'],
|
|
172
|
+
mail: ['eml', 'msg'],
|
|
173
|
+
linux: ['sh', 'bin'],
|
|
174
|
+
css: ['css'],
|
|
175
|
+
exe: ['exe'],
|
|
176
|
+
event: ['ics']
|
|
177
|
+
};
|
|
137
178
|
export function checkFileSourcesValidation(_ref) {
|
|
138
179
|
let {
|
|
139
180
|
fileName,
|
|
140
|
-
viewURL
|
|
181
|
+
viewURL,
|
|
182
|
+
previewUrl,
|
|
183
|
+
allowedPreviewExtensionsData
|
|
141
184
|
} = _ref;
|
|
185
|
+
const extension = (getExtensionFromFileName(fileName) || '').toLowerCase();
|
|
142
186
|
|
|
143
|
-
if (
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
isViewURLValid: isURLValid,
|
|
187
|
+
if (!extension) {
|
|
188
|
+
return Promise.resolve({
|
|
189
|
+
isViewURLValid: false,
|
|
147
190
|
canZoom: false
|
|
148
|
-
})
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const extensionSource = allowedPreviewExtensionsData || FILE_EXTENSIONS;
|
|
195
|
+
|
|
196
|
+
const fileExtensionValidation = type => {
|
|
197
|
+
const list = extensionSource[type];
|
|
198
|
+
if (!Array.isArray(list)) return false;
|
|
199
|
+
return list.map(e => e.toLowerCase()).includes(extension);
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
if (fileExtensionValidation('audio')) {
|
|
203
|
+
return checkAudioUrlValidity(viewURL).then(isURLValid => {
|
|
204
|
+
return {
|
|
205
|
+
isViewURLValid: isURLValid,
|
|
206
|
+
canZoom: false
|
|
207
|
+
};
|
|
208
|
+
});
|
|
155
209
|
}
|
|
210
|
+
|
|
211
|
+
if (fileExtensionValidation('video')) {
|
|
212
|
+
return checkVideoUrlValidity(viewURL).then(isURLValid => {
|
|
213
|
+
return {
|
|
214
|
+
isViewURLValid: isURLValid,
|
|
215
|
+
canZoom: false
|
|
216
|
+
};
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (fileExtensionValidation('document')) {
|
|
221
|
+
const isValid = isValidDocument(previewUrl, fileName);
|
|
222
|
+
return Promise.resolve({
|
|
223
|
+
isViewURLValid: isValid,
|
|
224
|
+
canZoom: false
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (fileExtensionValidation('image')) {
|
|
229
|
+
return checkImageValidity(viewURL).then(isURLValid => {
|
|
230
|
+
return {
|
|
231
|
+
isViewURLValid: isURLValid,
|
|
232
|
+
canZoom: isURLValid
|
|
233
|
+
};
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return Promise.resolve({
|
|
238
|
+
isViewURLValid: false,
|
|
239
|
+
canZoom: false
|
|
240
|
+
});
|
|
156
241
|
}
|
|
@@ -121,7 +121,7 @@ export default class RadioField extends PureComponent {
|
|
|
121
121
|
dataId: isDisabled ? `${dataId}_label_disabled` : isMandatory ? `${dataId}_label_mandatory` : `${dataId}_label`,
|
|
122
122
|
...LabelProps
|
|
123
123
|
}), /*#__PURE__*/React.createElement("div", {
|
|
124
|
-
className: `${style.fieldContainer} ${isBoxStyle ? style.radiosWrapper : ''} ${labelName ? style.fieldMargin_medium : ''} ${style.radioContainer}`
|
|
124
|
+
className: `${style.fieldContainer} ${isBoxStyle ? style.radiosWrapper : ''} ${labelName ? isBoxStyle ? style.fieldMargin_large : style.fieldMargin_medium : ''} ${style.radioContainer}`
|
|
125
125
|
}, options.map((option, index) => {
|
|
126
126
|
let {
|
|
127
127
|
text,
|
|
@@ -56,6 +56,7 @@ export default class Lookup extends Component {
|
|
|
56
56
|
needFocusScope,
|
|
57
57
|
customProps,
|
|
58
58
|
isMinHeight,
|
|
59
|
+
containerClass,
|
|
59
60
|
lookupClass
|
|
60
61
|
} = this.props;
|
|
61
62
|
const {
|
|
@@ -93,7 +94,7 @@ export default class Lookup extends Component {
|
|
|
93
94
|
}, /*#__PURE__*/React.createElement(Container, {
|
|
94
95
|
"data-drag-container": "true",
|
|
95
96
|
isCover: false,
|
|
96
|
-
className: isMinHeight ?
|
|
97
|
+
className: `${isMinHeight ? style.wrapper : style.coverwrap} ${style.containerWidth} ${containerClass}`
|
|
97
98
|
}, children));
|
|
98
99
|
return /*#__PURE__*/React.createElement(FreezeLayer, {
|
|
99
100
|
align: "horizontal",
|
|
@@ -19,6 +19,10 @@
|
|
|
19
19
|
margin: auto ;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
.containerWidth {
|
|
23
|
+
width: 100% ;
|
|
24
|
+
}
|
|
25
|
+
|
|
22
26
|
/* Size */
|
|
23
27
|
.smallSize {
|
|
24
28
|
max-width: var(--zd_size470) ;
|
|
@@ -35,10 +39,11 @@
|
|
|
35
39
|
.largeSize {
|
|
36
40
|
max-width: 70% ;
|
|
37
41
|
}
|
|
42
|
+
|
|
38
43
|
.xlargeSize {
|
|
39
44
|
max-width: 80% ;
|
|
40
45
|
}
|
|
41
46
|
|
|
42
47
|
.fullSize {
|
|
43
48
|
max-width: 90% ;
|
|
44
|
-
}
|
|
49
|
+
}
|
package/es/utils/General.js
CHANGED
|
@@ -43,4 +43,26 @@ export function formatPhoneUrl(phone) {
|
|
|
43
43
|
|
|
44
44
|
return phone;
|
|
45
45
|
}
|
|
46
|
-
export const DUMMY_OBJECT = Object.freeze({});
|
|
46
|
+
export const DUMMY_OBJECT = Object.freeze({});
|
|
47
|
+
export function getBrowserWithVersion() {
|
|
48
|
+
const userAgent = navigator.userAgent;
|
|
49
|
+
let tempMatch;
|
|
50
|
+
let browserMatch = userAgent.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*([\d\.]+)/i) || [];
|
|
51
|
+
|
|
52
|
+
if (userAgent.toLowerCase().indexOf('edge') !== -1) {
|
|
53
|
+
return userAgent.substring(userAgent.toLowerCase().indexOf('edge'));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (/trident/i.test(browserMatch[1])) {
|
|
57
|
+
tempMatch = /\brv[ :]+(\d+(\.\d+)?)/g.exec(userAgent) || [];
|
|
58
|
+
return `IE ${tempMatch[1] || ''}`;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
browserMatch = browserMatch[2] ? [browserMatch[1], browserMatch[2]] : [navigator.appName, navigator.appVersion, '-?'];
|
|
62
|
+
|
|
63
|
+
if ((tempMatch = userAgent.match(/version\/([\.\d]+)/i)) !== null) {
|
|
64
|
+
browserMatch[2] = tempMatch[1];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return browserMatch.join(' ');
|
|
68
|
+
}
|