@zohodesk/dot 1.0.0-temp-72 → 1.0.0-temp-75
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/README.md +8 -0
- package/assets/Appearance/dark/mode/dotDarkMode.module.css +10 -0
- package/assets/Appearance/dark/themes/blue/blueDarkDotTheme.module.css +6 -0
- package/assets/Appearance/dark/themes/green/greenDarkDotTheme.module.css +6 -0
- package/assets/Appearance/dark/themes/orange/orangeDarkDotTheme.module.css +6 -0
- package/assets/Appearance/dark/themes/red/redDarkDotTheme.module.css +6 -0
- package/assets/Appearance/dark/themes/yellow/yellowDarkDotTheme.module.css +6 -0
- package/assets/Appearance/default/mode/dotDefaultMode.module.css +10 -0
- package/assets/Appearance/default/themes/blue/blueDefaultDotTheme.module.css +6 -0
- package/assets/Appearance/default/themes/green/greenDefaultDotTheme.module.css +6 -0
- package/assets/Appearance/default/themes/orange/orangeDefaultDotTheme.module.css +6 -0
- package/assets/Appearance/default/themes/red/redDefaultDotTheme.module.css +6 -0
- package/assets/Appearance/default/themes/yellow/yellowDefaultDotTheme.module.css +6 -0
- package/assets/Appearance/pureDark/mode/dotPureDarkMode.module.css +10 -0
- package/assets/Appearance/pureDark/themes/blue/bluePureDarkDotTheme.module.css +6 -0
- package/assets/Appearance/pureDark/themes/green/greenPureDarkDotTheme.module.css +6 -0
- package/assets/Appearance/pureDark/themes/orange/orangePureDarkDotTheme.module.css +6 -0
- package/assets/Appearance/pureDark/themes/red/redPureDarkDotTheme.module.css +6 -0
- package/assets/Appearance/pureDark/themes/yellow/yellowPureDarkDotTheme.module.css +6 -0
- package/es/AttachmentViewer/Attachment.js +17 -0
- package/es/AttachmentViewer/AttachmentImage.js +85 -0
- package/es/AttachmentViewer/AttachmentViewer.js +562 -0
- package/es/AttachmentViewer/AttachmentViewer.module.css +346 -0
- package/es/AttachmentViewer/utils.js +107 -0
- package/es/common/dot_animation.module.css +27 -0
- package/es/common/dot_common.module.css +4 -0
- package/es/form/fields/TextEditor/TextEditor.js +4 -1
- package/images/audio_thumbnail.png +0 -0
- package/lib/AttachmentViewer/Attachment.js +28 -0
- package/lib/AttachmentViewer/AttachmentImage.js +129 -0
- package/lib/AttachmentViewer/AttachmentViewer.js +645 -0
- package/lib/AttachmentViewer/AttachmentViewer.module.css +346 -0
- package/lib/AttachmentViewer/utils.js +134 -0
- package/lib/common/dot_animation.module.css +27 -0
- package/lib/common/dot_common.module.css +4 -0
- package/lib/form/fields/TextEditor/TextEditor.js +4 -1
- package/package.json +7 -7
|
@@ -0,0 +1,562 @@
|
|
|
1
|
+
import React, { Component } from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import { Container, Box } from "@zohodesk/components/lib/Layout";
|
|
4
|
+
import Icon from "@zohodesk/icons/lib/Icon";
|
|
5
|
+
import Avatar from "@zohodesk/components/lib/Avatar/Avatar";
|
|
6
|
+
import { ResponsiveReceiver } from "@zohodesk/components/lib/Responsive/CustomResponsive";
|
|
7
|
+
import { getUniqueId } from "@zohodesk/components/lib/Provider/IdProvider";
|
|
8
|
+
import AttachmentImage from "./AttachmentImage";
|
|
9
|
+
import Link from "../Link/Link";
|
|
10
|
+
import IconButton from "../IconButton/IconButton";
|
|
11
|
+
import FreezeLayer from "../FreezeLayer/FreezeLayer";
|
|
12
|
+
import { isAudioFile, getExtensionFromFileName } from "./Attachment";
|
|
13
|
+
import { shallowDiff } from '../utils/General';
|
|
14
|
+
import style from "./AttachmentViewer.module.css";
|
|
15
|
+
export default class AttachmentViewer extends Component {
|
|
16
|
+
constructor(props) {
|
|
17
|
+
super(props);
|
|
18
|
+
this.state = {
|
|
19
|
+
isPViewListOpen: !!(this.props.previewObj && this.props.previewObj.previewData),
|
|
20
|
+
selectedIndex: this.props.previewObj.selectedIndex,
|
|
21
|
+
isZoomed: false,
|
|
22
|
+
data: this.props.previewObj ? this.props.previewObj.previewData : [],
|
|
23
|
+
dataList: this.getUpdateDataList({
|
|
24
|
+
index: this.props.previewObj.selectedIndex,
|
|
25
|
+
data: this.props.previewObj ? this.props.previewObj.previewData : [],
|
|
26
|
+
dataList: []
|
|
27
|
+
})
|
|
28
|
+
};
|
|
29
|
+
this.togglePViewList = this.togglePViewList.bind(this);
|
|
30
|
+
this.changeSelectedIndex = this.changeSelectedIndex.bind(this);
|
|
31
|
+
this.closeAttachmentViewer = this.closeAttachmentViewer.bind(this);
|
|
32
|
+
this.responsiveFunc = this.responsiveFunc.bind(this);
|
|
33
|
+
this.zoomIn = this.zoomIn.bind(this);
|
|
34
|
+
this.zoomOut = this.zoomOut.bind(this);
|
|
35
|
+
this.imgPreviewView = this.imgPreviewView.bind(this);
|
|
36
|
+
this.getNextId = getUniqueId(this);
|
|
37
|
+
this.getUpdateDataList = this.getUpdateDataList.bind(this);
|
|
38
|
+
this.zoomMaintain = this.zoomMaintain.bind(this);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
componentDidUpdate(prevProps) {
|
|
42
|
+
let {
|
|
43
|
+
previewObj
|
|
44
|
+
} = this.props;
|
|
45
|
+
let indexChanged = previewObj.selectedIndex != prevProps.previewObj.selectedIndex;
|
|
46
|
+
|
|
47
|
+
if (previewObj.previewData.length != prevProps.previewObj.previewData.length || indexChanged) {
|
|
48
|
+
let objChanged = previewObj.previewData.some((value, index) => {
|
|
49
|
+
return shallowDiff(value, prevProps.previewObj[index]);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
if (objChanged || indexChanged) {
|
|
53
|
+
this.setState({
|
|
54
|
+
selectedIndex: previewObj.selectedIndex,
|
|
55
|
+
data: previewObj ? previewObj.previewData : [],
|
|
56
|
+
dataList: this.getUpdateDataList({
|
|
57
|
+
index: previewObj.selectedIndex,
|
|
58
|
+
data: previewObj ? previewObj.previewData : [],
|
|
59
|
+
dataList: []
|
|
60
|
+
}),
|
|
61
|
+
isPViewListOpen: !!(this.props.previewObj && this.props.previewObj.previewData)
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
togglePViewList() {
|
|
68
|
+
this.setState(prevState => ({
|
|
69
|
+
isPViewListOpen: !prevState.isPViewListOpen
|
|
70
|
+
}), () => {
|
|
71
|
+
this.focusSelectedImg(this.state.selectedIndex);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
zoomOut(ele) {
|
|
76
|
+
this.setState({
|
|
77
|
+
isZoomed: false
|
|
78
|
+
});
|
|
79
|
+
const img = document.getElementById(`img${ele}`);
|
|
80
|
+
|
|
81
|
+
if (img) {
|
|
82
|
+
img.classList.remove(style.zoomedImg);
|
|
83
|
+
img.classList.add(style.normalImg);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
zoomIn(event, ele) {
|
|
88
|
+
let moveToPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
89
|
+
this.setState({
|
|
90
|
+
isZoomed: true
|
|
91
|
+
});
|
|
92
|
+
const img = document.getElementById(`img${ele}`);
|
|
93
|
+
const ratio = 95;
|
|
94
|
+
let imgContainer, imgUnits, imgSize, imgRatio, imgContainerUnits, imgContainerPosition;
|
|
95
|
+
|
|
96
|
+
if (moveToPosition) {
|
|
97
|
+
imgContainer = document.getElementById(`imgBox${ele}`);
|
|
98
|
+
imgUnits = img.getBoundingClientRect();
|
|
99
|
+
imgSize = {
|
|
100
|
+
height: img.naturalHeight,
|
|
101
|
+
width: img.naturalWidth
|
|
102
|
+
};
|
|
103
|
+
imgRatio = {
|
|
104
|
+
height: Math.floor(imgSize.height / imgUnits.height / 100 * ratio),
|
|
105
|
+
width: Math.floor(imgSize.width / imgUnits.width / 100 * ratio)
|
|
106
|
+
};
|
|
107
|
+
imgContainerUnits = imgContainer.getBoundingClientRect();
|
|
108
|
+
imgContainerPosition = imgContainer ? {
|
|
109
|
+
top: imgContainerUnits.top,
|
|
110
|
+
left: imgContainerUnits.left
|
|
111
|
+
} : {
|
|
112
|
+
top: 0,
|
|
113
|
+
left: 0
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (img) {
|
|
118
|
+
img.classList.remove(style.normalImg);
|
|
119
|
+
img.classList.add(style.zoomedImg);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (moveToPosition) {
|
|
123
|
+
imgContainer.scrollLeft = (event.pageX - imgContainerPosition.left - imgUnits.left) * imgRatio.width;
|
|
124
|
+
imgContainer.scrollTop = (event.pageY - imgContainerPosition.top - imgUnits.top) * imgRatio.height;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
zoomMaintain(selectedIndex) {
|
|
129
|
+
let {
|
|
130
|
+
isZoomed
|
|
131
|
+
} = this.state;
|
|
132
|
+
isZoomed ? this.zoomIn({}, selectedIndex) : this.zoomOut(selectedIndex);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
getUpdateDataList(_ref) {
|
|
136
|
+
let {
|
|
137
|
+
index,
|
|
138
|
+
data,
|
|
139
|
+
dataList
|
|
140
|
+
} = _ref;
|
|
141
|
+
data = data || this.state.data;
|
|
142
|
+
dataList = dataList || this.state.dataList;
|
|
143
|
+
const finalDataList = [...dataList];
|
|
144
|
+
|
|
145
|
+
if (index >= finalDataList.length) {
|
|
146
|
+
for (let i = dataList.length; i <= index; i++) {
|
|
147
|
+
finalDataList.push(data.slice(i)[0]);
|
|
148
|
+
}
|
|
149
|
+
} else if (index + 1 === finalDataList.length && index + 1 < data.length) {
|
|
150
|
+
finalDataList.push(data.slice(index + 1)[0]);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return finalDataList;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
updateDataList(index) {
|
|
157
|
+
this.setState({
|
|
158
|
+
dataList: this.getUpdateDataList({
|
|
159
|
+
index
|
|
160
|
+
})
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
changeSelectedIndex(index) {
|
|
165
|
+
const {
|
|
166
|
+
data,
|
|
167
|
+
selectedIndex
|
|
168
|
+
} = this.state;
|
|
169
|
+
const {
|
|
170
|
+
maintainZoom
|
|
171
|
+
} = this.props;
|
|
172
|
+
maintainZoom ? this.zoomMaintain(index) : this.zoomOut(selectedIndex);
|
|
173
|
+
|
|
174
|
+
if (index <= data.length - 1) {
|
|
175
|
+
this.updateDataList(index);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
this.setState({
|
|
179
|
+
selectedIndex: index
|
|
180
|
+
}, () => {
|
|
181
|
+
this.focusSelectedImg(index);
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
focusSelectedImg(index) {
|
|
186
|
+
const ele = this[`img_${index}`];
|
|
187
|
+
|
|
188
|
+
if (ele) {
|
|
189
|
+
const cont = this.imgListCont;
|
|
190
|
+
cont.scrollLeft = ele.offsetLeft;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
closeAttachmentViewer() {
|
|
195
|
+
this.setState({
|
|
196
|
+
isPViewListOpen: false,
|
|
197
|
+
isZoomed: false
|
|
198
|
+
});
|
|
199
|
+
this.props.hideAttachmentViewer();
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
responsiveFunc(_ref2) {
|
|
203
|
+
let {
|
|
204
|
+
mediaQueryOR
|
|
205
|
+
} = _ref2;
|
|
206
|
+
return {
|
|
207
|
+
uptoTablet: mediaQueryOR([{
|
|
208
|
+
maxWidth: 768
|
|
209
|
+
}])
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
imgPreviewView() {
|
|
214
|
+
var _this = this;
|
|
215
|
+
|
|
216
|
+
const {
|
|
217
|
+
dataList,
|
|
218
|
+
selectedIndex,
|
|
219
|
+
isZoomed
|
|
220
|
+
} = this.state;
|
|
221
|
+
const {
|
|
222
|
+
maintainZoom
|
|
223
|
+
} = this.props;
|
|
224
|
+
|
|
225
|
+
const getImgStyle = i => {
|
|
226
|
+
let position;
|
|
227
|
+
|
|
228
|
+
if (selectedIndex < i) {
|
|
229
|
+
position = (i - selectedIndex) * 100;
|
|
230
|
+
return {
|
|
231
|
+
transform: `translateX(${parseInt(position)}%)`,
|
|
232
|
+
opacity: "0"
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (i === selectedIndex) {
|
|
237
|
+
return {
|
|
238
|
+
transform: "translateX(0%)",
|
|
239
|
+
opacity: "1"
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
position = (selectedIndex - i) * 100 * -1;
|
|
244
|
+
return {
|
|
245
|
+
transform: `translateX(${parseInt(position)}%)`,
|
|
246
|
+
opacity: "0"
|
|
247
|
+
};
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
return dataList.length && dataList.map(function () {
|
|
251
|
+
let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
252
|
+
let i = arguments.length > 1 ? arguments[1] : undefined;
|
|
253
|
+
const selectedImgUrl = data.viewUrl;
|
|
254
|
+
return /*#__PURE__*/React.createElement(Container, {
|
|
255
|
+
className: style.imgBox,
|
|
256
|
+
id: `imgBox${i}`,
|
|
257
|
+
key: i,
|
|
258
|
+
alignBox: "row",
|
|
259
|
+
align: "both",
|
|
260
|
+
style: getImgStyle(i)
|
|
261
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
262
|
+
className: style.imgRef,
|
|
263
|
+
id: `imgPreviewRef${i}`
|
|
264
|
+
}, isAudioFile(data.name) ? selectedIndex == i ? /*#__PURE__*/React.createElement("video", {
|
|
265
|
+
autoPlay: true,
|
|
266
|
+
controls: true,
|
|
267
|
+
className: style.zoomIn
|
|
268
|
+
}, /*#__PURE__*/React.createElement("source", {
|
|
269
|
+
src: data.viewUrl,
|
|
270
|
+
type: `audio/${getExtensionFromFileName(data.name)}`
|
|
271
|
+
})) : null : /*#__PURE__*/React.createElement(AttachmentImage, {
|
|
272
|
+
className: `${style.img} ${selectedIndex == i && maintainZoom ? isZoomed ? style.zoomedImg : style.normalImg : ""}`,
|
|
273
|
+
src: selectedImgUrl,
|
|
274
|
+
onClick: isZoomed ? _this.zoomOut.bind(_this, i) : e => {
|
|
275
|
+
_this.zoomIn(e, i, true);
|
|
276
|
+
},
|
|
277
|
+
alt: "Preview",
|
|
278
|
+
dataId: "attachViewed",
|
|
279
|
+
id: `img${i}`,
|
|
280
|
+
isImage: true,
|
|
281
|
+
isCover: false
|
|
282
|
+
})));
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
render() {
|
|
287
|
+
const {
|
|
288
|
+
isPViewListOpen,
|
|
289
|
+
selectedIndex,
|
|
290
|
+
data,
|
|
291
|
+
isZoomed
|
|
292
|
+
} = this.state;
|
|
293
|
+
const {
|
|
294
|
+
responsiveId,
|
|
295
|
+
needDownload,
|
|
296
|
+
i18nKeys,
|
|
297
|
+
isActive
|
|
298
|
+
} = this.props;
|
|
299
|
+
const totalLen = data.length;
|
|
300
|
+
const selectedAttachment = data[selectedIndex] || {};
|
|
301
|
+
const selectedImgUrl = selectedAttachment.viewUrl;
|
|
302
|
+
const downloadUrl = selectedAttachment.downloadUrl;
|
|
303
|
+
let authorHref;
|
|
304
|
+
let authorName;
|
|
305
|
+
const {
|
|
306
|
+
author
|
|
307
|
+
} = data[selectedIndex] ? data[selectedIndex] : {};
|
|
308
|
+
|
|
309
|
+
if (author) {
|
|
310
|
+
authorHref = author.href;
|
|
311
|
+
authorName = author.name;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
const ariaId = this.getNextId();
|
|
315
|
+
return /*#__PURE__*/React.createElement(FreezeLayer, {
|
|
316
|
+
isActive: isActive && totalLen >= 1,
|
|
317
|
+
palette: "dark",
|
|
318
|
+
animationName: "expand"
|
|
319
|
+
}, /*#__PURE__*/React.createElement(ResponsiveReceiver, {
|
|
320
|
+
responsiveId: responsiveId,
|
|
321
|
+
query: this.responsiveFunc
|
|
322
|
+
}, _ref3 => {
|
|
323
|
+
let {
|
|
324
|
+
uptoTablet
|
|
325
|
+
} = _ref3;
|
|
326
|
+
return /*#__PURE__*/React.createElement(Container, {
|
|
327
|
+
scroll: "none",
|
|
328
|
+
"data-scroll-palette": "dark"
|
|
329
|
+
}, /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Container, {
|
|
330
|
+
alignBox: "row",
|
|
331
|
+
className: style.header,
|
|
332
|
+
align: "between",
|
|
333
|
+
tabindex: "0"
|
|
334
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
335
|
+
shrink: true,
|
|
336
|
+
className: style.title,
|
|
337
|
+
"data-title": selectedAttachment.name,
|
|
338
|
+
dataId: "attachName",
|
|
339
|
+
id: ariaId
|
|
340
|
+
}, selectedAttachment.name), /*#__PURE__*/React.createElement(Box, {
|
|
341
|
+
flexible: true,
|
|
342
|
+
className: style.count,
|
|
343
|
+
dataId: "attachCountContainer"
|
|
344
|
+
}, selectedIndex + 1, "/", totalLen), /*#__PURE__*/React.createElement(Box, {
|
|
345
|
+
className: uptoTablet ? style.mbleMenuBar : style.menuBar
|
|
346
|
+
}, /*#__PURE__*/React.createElement(Container, {
|
|
347
|
+
isInline: true,
|
|
348
|
+
alignBox: uptoTablet ? "column-reverse" : "row",
|
|
349
|
+
align: uptoTablet ? "bottom" : "center",
|
|
350
|
+
wrap: "wrap",
|
|
351
|
+
isCover: false
|
|
352
|
+
}, isZoomed ? /*#__PURE__*/React.createElement("div", {
|
|
353
|
+
className: uptoTablet ? style.mobileMenu : style.menu,
|
|
354
|
+
onClick: this.zoomOut.bind(this, selectedIndex),
|
|
355
|
+
"data-id": "zoomOut",
|
|
356
|
+
"data-title": i18nKeys.zoomOutText
|
|
357
|
+
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
358
|
+
iconName: "ZD-GN-zoomOut",
|
|
359
|
+
className: style.menuIcon,
|
|
360
|
+
iconSize: "16",
|
|
361
|
+
hoverType: "border",
|
|
362
|
+
a11y: {
|
|
363
|
+
ariaLabel: i18nKeys.zoomOutText
|
|
364
|
+
}
|
|
365
|
+
})) : /*#__PURE__*/React.createElement("div", {
|
|
366
|
+
className: uptoTablet ? style.mobileMenu : style.menu,
|
|
367
|
+
onClick: e => this.zoomIn(e, selectedIndex),
|
|
368
|
+
"data-id": "zoomIn",
|
|
369
|
+
"data-title": i18nKeys.zoomInText
|
|
370
|
+
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
371
|
+
iconName: "ZD-GN-zoomIn",
|
|
372
|
+
className: style.menuIcon,
|
|
373
|
+
iconSize: "16",
|
|
374
|
+
hoverType: "border",
|
|
375
|
+
a11y: {
|
|
376
|
+
ariaLabel: i18nKeys.zoomInText
|
|
377
|
+
}
|
|
378
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
379
|
+
className: uptoTablet ? style.mobileMenu : style.menu
|
|
380
|
+
}, /*#__PURE__*/React.createElement(Link, {
|
|
381
|
+
href: selectedImgUrl,
|
|
382
|
+
target: "_blank",
|
|
383
|
+
dataId: "newTabAttach",
|
|
384
|
+
title: i18nKeys.newTabText
|
|
385
|
+
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
386
|
+
iconName: "ZD-GN-newLink",
|
|
387
|
+
className: style.menuIcon,
|
|
388
|
+
iconSize: "16",
|
|
389
|
+
hoverType: "border",
|
|
390
|
+
needButtonTag: false,
|
|
391
|
+
a11y: {
|
|
392
|
+
ariaLabel: i18nKeys.newTabText
|
|
393
|
+
}
|
|
394
|
+
}))), needDownload ? /*#__PURE__*/React.createElement("div", {
|
|
395
|
+
className: uptoTablet ? style.mobileMenu : style.menu
|
|
396
|
+
}, /*#__PURE__*/React.createElement(Link, {
|
|
397
|
+
href: downloadUrl,
|
|
398
|
+
target: "_parent",
|
|
399
|
+
hasReload: true,
|
|
400
|
+
download: true,
|
|
401
|
+
title: i18nKeys.downloadText
|
|
402
|
+
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
403
|
+
iconName: "ZD-GN-download",
|
|
404
|
+
className: style.menuIcon,
|
|
405
|
+
iconSize: "16",
|
|
406
|
+
hoverType: "border",
|
|
407
|
+
needButtonTag: false,
|
|
408
|
+
a11y: {
|
|
409
|
+
ariaLabel: i18nKeys.downloadText
|
|
410
|
+
}
|
|
411
|
+
}))) : null, /*#__PURE__*/React.createElement("div", {
|
|
412
|
+
className: uptoTablet ? style.mobileMenu : style.menu,
|
|
413
|
+
onClick: this.closeAttachmentViewer,
|
|
414
|
+
"data-id": "closeAttach",
|
|
415
|
+
"data-title": i18nKeys.closeText
|
|
416
|
+
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
417
|
+
iconName: "ZD-cross",
|
|
418
|
+
iconSize: "15",
|
|
419
|
+
hoverType: "border",
|
|
420
|
+
className: style.menuIcon,
|
|
421
|
+
a11y: {
|
|
422
|
+
ariaLabel: i18nKeys.closeText
|
|
423
|
+
},
|
|
424
|
+
title: i18nKeys.closeText
|
|
425
|
+
})))))), /*#__PURE__*/React.createElement(Box, {
|
|
426
|
+
flexible: true,
|
|
427
|
+
role: "toolbar",
|
|
428
|
+
tabindex: "0"
|
|
429
|
+
}, /*#__PURE__*/React.createElement(Container, {
|
|
430
|
+
alignBox: "row"
|
|
431
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
432
|
+
className: `${style.arrowBox} ${uptoTablet ? style.mbleArrowBox : style.nrmlArrowBox} ${selectedIndex === 0 ? style.hidden : ""}`,
|
|
433
|
+
onClick: this.changeSelectedIndex.bind(this, selectedIndex - 1),
|
|
434
|
+
"data-title": i18nKeys.previousText,
|
|
435
|
+
"data-title-position": "left"
|
|
436
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
437
|
+
className: style.btn,
|
|
438
|
+
"aria-label": i18nKeys.previousText
|
|
439
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
440
|
+
name: "ZD-arrowLeft3",
|
|
441
|
+
iconClass: style.arrow,
|
|
442
|
+
dataId: "leftAttachNav",
|
|
443
|
+
isBold: true
|
|
444
|
+
}))), /*#__PURE__*/React.createElement(Box, {
|
|
445
|
+
className: style.previewBox,
|
|
446
|
+
role: "option",
|
|
447
|
+
tabindex: "0",
|
|
448
|
+
"aria-describedby": ariaId,
|
|
449
|
+
isShrink: false,
|
|
450
|
+
eleRef: this.setImgBoxRef,
|
|
451
|
+
scroll: "both",
|
|
452
|
+
flexible: true
|
|
453
|
+
}, this.imgPreviewView()), /*#__PURE__*/React.createElement(Box, {
|
|
454
|
+
className: `${style.arrowBox} ${uptoTablet ? style.mbleArrowBox : style.nrmlArrowBox} ${totalLen === selectedIndex + 1 ? style.hidden : ""}`,
|
|
455
|
+
onClick: this.changeSelectedIndex.bind(this, selectedIndex + 1),
|
|
456
|
+
"data-title": i18nKeys.nextText,
|
|
457
|
+
"data-title-position": "right"
|
|
458
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
459
|
+
className: style.btn,
|
|
460
|
+
"aria-label": i18nKeys.nextText
|
|
461
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
462
|
+
name: "ZD-arrowRight3",
|
|
463
|
+
iconClass: style.arrow,
|
|
464
|
+
dataId: "rightAttachNav",
|
|
465
|
+
isBold: true
|
|
466
|
+
}))))), /*#__PURE__*/React.createElement(Box, {
|
|
467
|
+
className: `${style.footer} ${isPViewListOpen && totalLen !== 1 ? style.footerHeight : style.footerHide} `
|
|
468
|
+
}, /*#__PURE__*/React.createElement(Container, {
|
|
469
|
+
align: "vertical",
|
|
470
|
+
alignBox: "row",
|
|
471
|
+
className: style.footerHeight
|
|
472
|
+
}, author && /*#__PURE__*/React.createElement(Box, {
|
|
473
|
+
className: style.author
|
|
474
|
+
}, /*#__PURE__*/React.createElement(Container, {
|
|
475
|
+
alignBox: "row",
|
|
476
|
+
align: "both"
|
|
477
|
+
}, /*#__PURE__*/React.createElement(Avatar, {
|
|
478
|
+
name: authorName,
|
|
479
|
+
size: "xmedium",
|
|
480
|
+
src: authorHref,
|
|
481
|
+
palette: "info"
|
|
482
|
+
}), /*#__PURE__*/React.createElement(Box, {
|
|
483
|
+
flexible: true,
|
|
484
|
+
className: style.authorName,
|
|
485
|
+
"data-title": authorName
|
|
486
|
+
}, authorName))), /*#__PURE__*/React.createElement(Box, {
|
|
487
|
+
flexible: true
|
|
488
|
+
}, /*#__PURE__*/React.createElement(Container, {
|
|
489
|
+
align: "vertical",
|
|
490
|
+
alignBox: "row",
|
|
491
|
+
scroll: "horizontal",
|
|
492
|
+
eleRef: el => this.imgListCont = el,
|
|
493
|
+
className: style.listContainer
|
|
494
|
+
}, data.map((item, index) => {
|
|
495
|
+
const {
|
|
496
|
+
name,
|
|
497
|
+
viewUrl
|
|
498
|
+
} = item;
|
|
499
|
+
const isAudio = isAudioFile(name);
|
|
500
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
501
|
+
className: `${style.imgItem} ${index === selectedIndex ? style.selected : ""} ${isAudio ? style.isAudio : ""}`,
|
|
502
|
+
key: index,
|
|
503
|
+
onClick: this.changeSelectedIndex.bind(this, index),
|
|
504
|
+
eleRef: el => this[`img_${index}`] = el,
|
|
505
|
+
dataId: "attachPreviewList",
|
|
506
|
+
"data-title": name
|
|
507
|
+
}, /*#__PURE__*/React.createElement(AttachmentImage, {
|
|
508
|
+
src: viewUrl,
|
|
509
|
+
size: "small",
|
|
510
|
+
alt: name,
|
|
511
|
+
className: style.image,
|
|
512
|
+
isImage: !isAudio
|
|
513
|
+
}));
|
|
514
|
+
}))))), totalLen !== 1 && /*#__PURE__*/React.createElement(IconButton, {
|
|
515
|
+
dataId: "attachToggle",
|
|
516
|
+
onClick: this.togglePViewList,
|
|
517
|
+
iconName: "ZD-GN-hideTab",
|
|
518
|
+
iconSize: "14",
|
|
519
|
+
hoverType: "border",
|
|
520
|
+
iconClass: `${style.thumpIcon} ${isPViewListOpen ? style.thumpIconActive : ""}`,
|
|
521
|
+
className: style.button,
|
|
522
|
+
a11y: {
|
|
523
|
+
ariaLabel: i18nKeys.hideText
|
|
524
|
+
},
|
|
525
|
+
title: isPViewListOpen ? i18nKeys.hideText : i18nKeys.showText
|
|
526
|
+
}));
|
|
527
|
+
}));
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
}
|
|
531
|
+
AttachmentViewer.propTypes = {
|
|
532
|
+
hideAttachmentViewer: PropTypes.func,
|
|
533
|
+
i18nKeys: PropTypes.shape({
|
|
534
|
+
nextText: PropTypes.string,
|
|
535
|
+
previousText: PropTypes.string,
|
|
536
|
+
zoomOutText: PropTypes.string,
|
|
537
|
+
zoomInText: PropTypes.string,
|
|
538
|
+
newTabText: PropTypes.string,
|
|
539
|
+
downloadText: PropTypes.string,
|
|
540
|
+
closeText: PropTypes.string,
|
|
541
|
+
hideText: PropTypes.string,
|
|
542
|
+
showText: PropTypes.string
|
|
543
|
+
}),
|
|
544
|
+
needDownload: PropTypes.string,
|
|
545
|
+
previewObj: PropTypes.object,
|
|
546
|
+
responsiveId: PropTypes.string,
|
|
547
|
+
maintainZoom: PropTypes.bool,
|
|
548
|
+
isActive: PropTypes.bool
|
|
549
|
+
};
|
|
550
|
+
AttachmentViewer.defaultProps = {
|
|
551
|
+
responsiveId: "Helmet",
|
|
552
|
+
needDownload: true,
|
|
553
|
+
i18nKeys: {},
|
|
554
|
+
maintainZoom: false,
|
|
555
|
+
isActive: false
|
|
556
|
+
};
|
|
557
|
+
|
|
558
|
+
if (false) {
|
|
559
|
+
AttachmentViewer.docs = {
|
|
560
|
+
componentGroup: "Molecule"
|
|
561
|
+
};
|
|
562
|
+
}
|