@zohodesk/dot 1.0.0-beta.217 → 1.0.0-beta.218
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 +4 -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/es/AttachmentViewer/Attachment.js +17 -0
- package/es/AttachmentViewer/AttachmentImage.js +85 -0
- package/es/AttachmentViewer/AttachmentViewer.js +530 -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/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 +613 -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/package.json +15 -13
|
@@ -0,0 +1,613 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
|
|
14
|
+
var _Layout = require("@zohodesk/components/lib/Layout");
|
|
15
|
+
|
|
16
|
+
var _Icon = _interopRequireDefault(require("@zohodesk/icons/lib/Icon"));
|
|
17
|
+
|
|
18
|
+
var _Avatar = _interopRequireDefault(require("@zohodesk/components/lib/Avatar/Avatar"));
|
|
19
|
+
|
|
20
|
+
var _CustomResponsive = require("@zohodesk/components/lib/Responsive/CustomResponsive");
|
|
21
|
+
|
|
22
|
+
var _IdProvider = require("@zohodesk/components/lib/Provider/IdProvider");
|
|
23
|
+
|
|
24
|
+
var _AttachmentImage = _interopRequireDefault(require("./AttachmentImage"));
|
|
25
|
+
|
|
26
|
+
var _Link = _interopRequireDefault(require("../Link/Link"));
|
|
27
|
+
|
|
28
|
+
var _IconButton = _interopRequireDefault(require("../IconButton/IconButton"));
|
|
29
|
+
|
|
30
|
+
var _FreezeLayer = _interopRequireDefault(require("../FreezeLayer/FreezeLayer"));
|
|
31
|
+
|
|
32
|
+
var _Attachment = require("./Attachment");
|
|
33
|
+
|
|
34
|
+
var _AttachmentViewerModule = _interopRequireDefault(require("./AttachmentViewer.module.css"));
|
|
35
|
+
|
|
36
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
37
|
+
|
|
38
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
39
|
+
|
|
40
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
41
|
+
|
|
42
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
43
|
+
|
|
44
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
45
|
+
|
|
46
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
47
|
+
|
|
48
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
49
|
+
|
|
50
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
51
|
+
|
|
52
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
53
|
+
|
|
54
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
55
|
+
|
|
56
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
57
|
+
|
|
58
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
59
|
+
|
|
60
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
61
|
+
|
|
62
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
63
|
+
|
|
64
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
65
|
+
|
|
66
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
67
|
+
|
|
68
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
69
|
+
|
|
70
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
71
|
+
|
|
72
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
73
|
+
|
|
74
|
+
var AttachmentViewer = /*#__PURE__*/function (_Component) {
|
|
75
|
+
_inherits(AttachmentViewer, _Component);
|
|
76
|
+
|
|
77
|
+
var _super = _createSuper(AttachmentViewer);
|
|
78
|
+
|
|
79
|
+
function AttachmentViewer(props) {
|
|
80
|
+
var _this;
|
|
81
|
+
|
|
82
|
+
_classCallCheck(this, AttachmentViewer);
|
|
83
|
+
|
|
84
|
+
_this = _super.call(this, props);
|
|
85
|
+
_this.state = {
|
|
86
|
+
isPViewListOpen: !!(_this.props.previewObj && _this.props.previewObj.previewData),
|
|
87
|
+
selectedIndex: _this.props.previewObj.selectedIndex,
|
|
88
|
+
isZoomed: false,
|
|
89
|
+
data: _this.props.previewObj ? _this.props.previewObj.previewData : [],
|
|
90
|
+
dataList: _this.getUpdateDataList({
|
|
91
|
+
index: _this.props.previewObj.selectedIndex,
|
|
92
|
+
data: _this.props.previewObj ? _this.props.previewObj.previewData : [],
|
|
93
|
+
dataList: []
|
|
94
|
+
})
|
|
95
|
+
};
|
|
96
|
+
_this.togglePViewList = _this.togglePViewList.bind(_assertThisInitialized(_this));
|
|
97
|
+
_this.changeSelectedIndex = _this.changeSelectedIndex.bind(_assertThisInitialized(_this));
|
|
98
|
+
_this.closeAttachmentViewer = _this.closeAttachmentViewer.bind(_assertThisInitialized(_this));
|
|
99
|
+
_this.responsiveFunc = _this.responsiveFunc.bind(_assertThisInitialized(_this));
|
|
100
|
+
_this.zoomIn = _this.zoomIn.bind(_assertThisInitialized(_this));
|
|
101
|
+
_this.zoomOut = _this.zoomOut.bind(_assertThisInitialized(_this));
|
|
102
|
+
_this.imgPreviewView = _this.imgPreviewView.bind(_assertThisInitialized(_this));
|
|
103
|
+
_this.getNextId = (0, _IdProvider.getUniqueId)(_assertThisInitialized(_this));
|
|
104
|
+
_this.getUpdateDataList = _this.getUpdateDataList.bind(_assertThisInitialized(_this));
|
|
105
|
+
_this.zoomMaintain = _this.zoomMaintain.bind(_assertThisInitialized(_this));
|
|
106
|
+
return _this;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
_createClass(AttachmentViewer, [{
|
|
110
|
+
key: "togglePViewList",
|
|
111
|
+
value: function togglePViewList() {
|
|
112
|
+
var _this2 = this;
|
|
113
|
+
|
|
114
|
+
this.setState(function (prevState) {
|
|
115
|
+
return {
|
|
116
|
+
isPViewListOpen: !prevState.isPViewListOpen
|
|
117
|
+
};
|
|
118
|
+
}, function () {
|
|
119
|
+
_this2.focusSelectedImg(_this2.state.selectedIndex);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}, {
|
|
123
|
+
key: "zoomOut",
|
|
124
|
+
value: function zoomOut(ele) {
|
|
125
|
+
this.setState({
|
|
126
|
+
isZoomed: false
|
|
127
|
+
});
|
|
128
|
+
var img = document.getElementById("img".concat(ele));
|
|
129
|
+
|
|
130
|
+
if (img) {
|
|
131
|
+
img.classList.remove(_AttachmentViewerModule["default"].zoomedImg);
|
|
132
|
+
img.classList.add(_AttachmentViewerModule["default"].normalImg);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}, {
|
|
136
|
+
key: "zoomIn",
|
|
137
|
+
value: function zoomIn(event, ele) {
|
|
138
|
+
var moveToPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
139
|
+
this.setState({
|
|
140
|
+
isZoomed: true
|
|
141
|
+
});
|
|
142
|
+
var img = document.getElementById("img".concat(ele));
|
|
143
|
+
var ratio = 95;
|
|
144
|
+
var imgContainer, imgUnits, imgSize, imgRatio, imgContainerUnits, imgContainerPosition;
|
|
145
|
+
|
|
146
|
+
if (moveToPosition) {
|
|
147
|
+
imgContainer = document.getElementById("imgBox".concat(ele));
|
|
148
|
+
imgUnits = img.getBoundingClientRect();
|
|
149
|
+
imgSize = {
|
|
150
|
+
height: img.naturalHeight,
|
|
151
|
+
width: img.naturalWidth
|
|
152
|
+
};
|
|
153
|
+
imgRatio = {
|
|
154
|
+
height: Math.floor(imgSize.height / imgUnits.height / 100 * ratio),
|
|
155
|
+
width: Math.floor(imgSize.width / imgUnits.width / 100 * ratio)
|
|
156
|
+
};
|
|
157
|
+
imgContainerUnits = imgContainer.getBoundingClientRect();
|
|
158
|
+
imgContainerPosition = imgContainer ? {
|
|
159
|
+
top: imgContainerUnits.top,
|
|
160
|
+
left: imgContainerUnits.left
|
|
161
|
+
} : {
|
|
162
|
+
top: 0,
|
|
163
|
+
left: 0
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (img) {
|
|
168
|
+
img.classList.remove(_AttachmentViewerModule["default"].normalImg);
|
|
169
|
+
img.classList.add(_AttachmentViewerModule["default"].zoomedImg);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (moveToPosition) {
|
|
173
|
+
imgContainer.scrollLeft = (event.pageX - imgContainerPosition.left - imgUnits.left) * imgRatio.width;
|
|
174
|
+
imgContainer.scrollTop = (event.pageY - imgContainerPosition.top - imgUnits.top) * imgRatio.height;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}, {
|
|
178
|
+
key: "zoomMaintain",
|
|
179
|
+
value: function zoomMaintain(selectedIndex) {
|
|
180
|
+
var isZoomed = this.state.isZoomed;
|
|
181
|
+
isZoomed ? this.zoomIn({}, selectedIndex) : this.zoomOut(selectedIndex);
|
|
182
|
+
}
|
|
183
|
+
}, {
|
|
184
|
+
key: "getUpdateDataList",
|
|
185
|
+
value: function getUpdateDataList(_ref) {
|
|
186
|
+
var index = _ref.index,
|
|
187
|
+
data = _ref.data,
|
|
188
|
+
dataList = _ref.dataList;
|
|
189
|
+
data = data || this.state.data;
|
|
190
|
+
dataList = dataList || this.state.dataList;
|
|
191
|
+
|
|
192
|
+
var finalDataList = _toConsumableArray(dataList);
|
|
193
|
+
|
|
194
|
+
if (index >= finalDataList.length) {
|
|
195
|
+
for (var i = dataList.length; i <= index; i++) {
|
|
196
|
+
finalDataList.push(data.slice(i)[0]);
|
|
197
|
+
}
|
|
198
|
+
} else if (index + 1 === finalDataList.length && index + 1 < data.length) {
|
|
199
|
+
finalDataList.push(data.slice(index + 1)[0]);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return finalDataList;
|
|
203
|
+
}
|
|
204
|
+
}, {
|
|
205
|
+
key: "updateDataList",
|
|
206
|
+
value: function updateDataList(index) {
|
|
207
|
+
this.setState({
|
|
208
|
+
dataList: this.getUpdateDataList({
|
|
209
|
+
index: index
|
|
210
|
+
})
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}, {
|
|
214
|
+
key: "changeSelectedIndex",
|
|
215
|
+
value: function changeSelectedIndex(index) {
|
|
216
|
+
var _this3 = this;
|
|
217
|
+
|
|
218
|
+
var _this$state = this.state,
|
|
219
|
+
data = _this$state.data,
|
|
220
|
+
selectedIndex = _this$state.selectedIndex;
|
|
221
|
+
var maintainZoom = this.props.maintainZoom;
|
|
222
|
+
maintainZoom ? this.zoomMaintain(index) : this.zoomOut(selectedIndex);
|
|
223
|
+
|
|
224
|
+
if (index <= data.length - 1) {
|
|
225
|
+
this.updateDataList(index);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
this.setState({
|
|
229
|
+
selectedIndex: index
|
|
230
|
+
}, function () {
|
|
231
|
+
_this3.focusSelectedImg(index);
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
}, {
|
|
235
|
+
key: "focusSelectedImg",
|
|
236
|
+
value: function focusSelectedImg(index) {
|
|
237
|
+
var ele = this["img_".concat(index)];
|
|
238
|
+
|
|
239
|
+
if (ele) {
|
|
240
|
+
var cont = this.imgListCont;
|
|
241
|
+
cont.scrollLeft = ele.offsetLeft;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}, {
|
|
245
|
+
key: "closeAttachmentViewer",
|
|
246
|
+
value: function closeAttachmentViewer() {
|
|
247
|
+
this.setState({
|
|
248
|
+
isPViewListOpen: false,
|
|
249
|
+
isZoomed: false
|
|
250
|
+
});
|
|
251
|
+
this.props.hideAttachmentViewer();
|
|
252
|
+
}
|
|
253
|
+
}, {
|
|
254
|
+
key: "responsiveFunc",
|
|
255
|
+
value: function responsiveFunc(_ref2) {
|
|
256
|
+
var mediaQueryOR = _ref2.mediaQueryOR;
|
|
257
|
+
return {
|
|
258
|
+
uptoTablet: mediaQueryOR([{
|
|
259
|
+
maxWidth: 768
|
|
260
|
+
}])
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
}, {
|
|
264
|
+
key: "imgPreviewView",
|
|
265
|
+
value: function imgPreviewView() {
|
|
266
|
+
var _this4 = this;
|
|
267
|
+
|
|
268
|
+
var _this$state2 = this.state,
|
|
269
|
+
dataList = _this$state2.dataList,
|
|
270
|
+
selectedIndex = _this$state2.selectedIndex,
|
|
271
|
+
isZoomed = _this$state2.isZoomed;
|
|
272
|
+
var maintainZoom = this.props.maintainZoom;
|
|
273
|
+
|
|
274
|
+
var getImgStyle = function getImgStyle(i) {
|
|
275
|
+
var position;
|
|
276
|
+
|
|
277
|
+
if (selectedIndex < i) {
|
|
278
|
+
position = (i - selectedIndex) * 100;
|
|
279
|
+
return {
|
|
280
|
+
transform: "translateX(".concat(parseInt(position), "%)"),
|
|
281
|
+
opacity: "0"
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
if (i === selectedIndex) {
|
|
286
|
+
return {
|
|
287
|
+
transform: "translateX(0%)",
|
|
288
|
+
opacity: "1"
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
position = (selectedIndex - i) * 100 * -1;
|
|
293
|
+
return {
|
|
294
|
+
transform: "translateX(".concat(parseInt(position), "%)"),
|
|
295
|
+
opacity: "0"
|
|
296
|
+
};
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
return dataList.length && dataList.map(function () {
|
|
300
|
+
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
301
|
+
var i = arguments.length > 1 ? arguments[1] : undefined;
|
|
302
|
+
var selectedImgUrl = data.viewUrl;
|
|
303
|
+
return /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
304
|
+
className: _AttachmentViewerModule["default"].imgBox,
|
|
305
|
+
id: "imgBox".concat(i),
|
|
306
|
+
key: i,
|
|
307
|
+
alignBox: "row",
|
|
308
|
+
align: "both",
|
|
309
|
+
style: getImgStyle(i)
|
|
310
|
+
}, /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
|
|
311
|
+
className: _AttachmentViewerModule["default"].imgRef,
|
|
312
|
+
id: "imgPreviewRef".concat(i)
|
|
313
|
+
}, (0, _Attachment.isAudioFile)(data.name) ? selectedIndex == i ? /*#__PURE__*/_react["default"].createElement("video", {
|
|
314
|
+
autoPlay: true,
|
|
315
|
+
controls: true,
|
|
316
|
+
className: _AttachmentViewerModule["default"].zoomIn
|
|
317
|
+
}, /*#__PURE__*/_react["default"].createElement("source", {
|
|
318
|
+
src: data.viewUrl,
|
|
319
|
+
type: "audio/".concat((0, _Attachment.getExtensionFromFileName)(data.name))
|
|
320
|
+
})) : null : /*#__PURE__*/_react["default"].createElement(_AttachmentImage["default"], {
|
|
321
|
+
className: "".concat(_AttachmentViewerModule["default"].img, " ").concat(selectedIndex == i && maintainZoom ? isZoomed ? _AttachmentViewerModule["default"].zoomedImg : _AttachmentViewerModule["default"].normalImg : ""),
|
|
322
|
+
src: selectedImgUrl,
|
|
323
|
+
onClick: isZoomed ? _this4.zoomOut.bind(_this4, i) : function (e) {
|
|
324
|
+
_this4.zoomIn(e, i, true);
|
|
325
|
+
},
|
|
326
|
+
alt: "Preview",
|
|
327
|
+
dataId: "attachViewed",
|
|
328
|
+
id: "img".concat(i),
|
|
329
|
+
isImage: true,
|
|
330
|
+
isCover: false
|
|
331
|
+
})));
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
}, {
|
|
335
|
+
key: "render",
|
|
336
|
+
value: function render() {
|
|
337
|
+
var _this5 = this;
|
|
338
|
+
|
|
339
|
+
var _this$state3 = this.state,
|
|
340
|
+
isPViewListOpen = _this$state3.isPViewListOpen,
|
|
341
|
+
selectedIndex = _this$state3.selectedIndex,
|
|
342
|
+
data = _this$state3.data,
|
|
343
|
+
isZoomed = _this$state3.isZoomed;
|
|
344
|
+
var _this$props = this.props,
|
|
345
|
+
responsiveId = _this$props.responsiveId,
|
|
346
|
+
needDownload = _this$props.needDownload,
|
|
347
|
+
i18nKeys = _this$props.i18nKeys;
|
|
348
|
+
var totalLen = data.length;
|
|
349
|
+
var selectedAttachment = data[selectedIndex] || {};
|
|
350
|
+
var selectedImgUrl = selectedAttachment.viewUrl;
|
|
351
|
+
var downloadUrl = selectedAttachment.downloadUrl;
|
|
352
|
+
var authorHref;
|
|
353
|
+
var authorName;
|
|
354
|
+
|
|
355
|
+
var _ref3 = data[selectedIndex] ? data[selectedIndex] : null,
|
|
356
|
+
author = _ref3.author;
|
|
357
|
+
|
|
358
|
+
if (author) {
|
|
359
|
+
authorHref = author.href;
|
|
360
|
+
authorName = author.name;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
var ariaId = this.getNextId();
|
|
364
|
+
return /*#__PURE__*/_react["default"].createElement(_FreezeLayer["default"], {
|
|
365
|
+
isActive: true
|
|
366
|
+
}, /*#__PURE__*/_react["default"].createElement(_CustomResponsive.ResponsiveReceiver, {
|
|
367
|
+
responsiveId: responsiveId,
|
|
368
|
+
query: this.responsiveFunc
|
|
369
|
+
}, function (_ref4) {
|
|
370
|
+
var uptoTablet = _ref4.uptoTablet;
|
|
371
|
+
return /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
372
|
+
scroll: "none",
|
|
373
|
+
"data-scroll-palette": "dark"
|
|
374
|
+
}, /*#__PURE__*/_react["default"].createElement(_Layout.Box, null, /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
375
|
+
alignBox: "row",
|
|
376
|
+
className: _AttachmentViewerModule["default"].header,
|
|
377
|
+
align: "between",
|
|
378
|
+
tabindex: "0"
|
|
379
|
+
}, /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
|
|
380
|
+
shrink: true,
|
|
381
|
+
className: _AttachmentViewerModule["default"].title,
|
|
382
|
+
"data-title": selectedAttachment.name,
|
|
383
|
+
dataId: "attachName",
|
|
384
|
+
id: ariaId
|
|
385
|
+
}, selectedAttachment.name), /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
|
|
386
|
+
flexible: true,
|
|
387
|
+
className: _AttachmentViewerModule["default"].count,
|
|
388
|
+
dataId: "attachCountContainer"
|
|
389
|
+
}, selectedIndex + 1, "/", totalLen), /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
|
|
390
|
+
className: uptoTablet ? _AttachmentViewerModule["default"].mbleMenuBar : _AttachmentViewerModule["default"].menuBar
|
|
391
|
+
}, /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
392
|
+
isInline: true,
|
|
393
|
+
alignBox: uptoTablet ? "column-reverse" : "row",
|
|
394
|
+
align: uptoTablet ? "bottom" : "center",
|
|
395
|
+
wrap: "wrap",
|
|
396
|
+
isCover: false
|
|
397
|
+
}, isZoomed ? /*#__PURE__*/_react["default"].createElement("div", {
|
|
398
|
+
className: uptoTablet ? _AttachmentViewerModule["default"].mobileMenu : _AttachmentViewerModule["default"].menu,
|
|
399
|
+
onClick: _this5.zoomOut.bind(_this5, selectedIndex),
|
|
400
|
+
"data-id": "zoomOut",
|
|
401
|
+
"data-title": i18nKeys.zoomOutText
|
|
402
|
+
}, /*#__PURE__*/_react["default"].createElement(_IconButton["default"], {
|
|
403
|
+
iconName: "ZD-GN-zoomOut",
|
|
404
|
+
className: _AttachmentViewerModule["default"].menuIcon,
|
|
405
|
+
iconSize: "16",
|
|
406
|
+
hoverType: "border",
|
|
407
|
+
a11y: {
|
|
408
|
+
ariaLabel: i18nKeys.zoomOutText
|
|
409
|
+
}
|
|
410
|
+
})) : /*#__PURE__*/_react["default"].createElement("div", {
|
|
411
|
+
className: uptoTablet ? _AttachmentViewerModule["default"].mobileMenu : _AttachmentViewerModule["default"].menu,
|
|
412
|
+
onClick: function onClick(e) {
|
|
413
|
+
return _this5.zoomIn(e, selectedIndex);
|
|
414
|
+
},
|
|
415
|
+
"data-id": "zoomIn",
|
|
416
|
+
"data-title": i18nKeys.zoomInText
|
|
417
|
+
}, /*#__PURE__*/_react["default"].createElement(_IconButton["default"], {
|
|
418
|
+
iconName: "ZD-GN-zoomIn",
|
|
419
|
+
className: _AttachmentViewerModule["default"].menuIcon,
|
|
420
|
+
iconSize: "16",
|
|
421
|
+
hoverType: "border",
|
|
422
|
+
a11y: {
|
|
423
|
+
ariaLabel: i18nKeys.zoomInText
|
|
424
|
+
}
|
|
425
|
+
})), /*#__PURE__*/_react["default"].createElement("div", {
|
|
426
|
+
className: uptoTablet ? _AttachmentViewerModule["default"].mobileMenu : _AttachmentViewerModule["default"].menu
|
|
427
|
+
}, /*#__PURE__*/_react["default"].createElement(_Link["default"], {
|
|
428
|
+
href: selectedImgUrl,
|
|
429
|
+
target: "_blank",
|
|
430
|
+
dataId: "newTabAttach",
|
|
431
|
+
title: i18nKeys.newTabText
|
|
432
|
+
}, /*#__PURE__*/_react["default"].createElement(_IconButton["default"], {
|
|
433
|
+
iconName: "ZD-GN-newLink",
|
|
434
|
+
className: _AttachmentViewerModule["default"].menuIcon,
|
|
435
|
+
iconSize: "16",
|
|
436
|
+
hoverType: "border",
|
|
437
|
+
needButtonTag: false,
|
|
438
|
+
a11y: {
|
|
439
|
+
ariaLabel: i18nKeys.newTabText
|
|
440
|
+
}
|
|
441
|
+
}))), needDownload ? /*#__PURE__*/_react["default"].createElement("div", {
|
|
442
|
+
className: uptoTablet ? _AttachmentViewerModule["default"].mobileMenu : _AttachmentViewerModule["default"].menu
|
|
443
|
+
}, /*#__PURE__*/_react["default"].createElement(_Link["default"], {
|
|
444
|
+
href: downloadUrl,
|
|
445
|
+
target: "_parent",
|
|
446
|
+
hasReload: true,
|
|
447
|
+
download: true,
|
|
448
|
+
title: i18nKeys.downloadText
|
|
449
|
+
}, /*#__PURE__*/_react["default"].createElement(_IconButton["default"], {
|
|
450
|
+
iconName: "ZD-GN-download",
|
|
451
|
+
className: _AttachmentViewerModule["default"].menuIcon,
|
|
452
|
+
iconSize: "16",
|
|
453
|
+
hoverType: "border",
|
|
454
|
+
needButtonTag: false,
|
|
455
|
+
a11y: {
|
|
456
|
+
ariaLabel: i18nKeys.downloadText
|
|
457
|
+
}
|
|
458
|
+
}))) : null, /*#__PURE__*/_react["default"].createElement("div", {
|
|
459
|
+
className: uptoTablet ? _AttachmentViewerModule["default"].mobileMenu : _AttachmentViewerModule["default"].menu,
|
|
460
|
+
onClick: _this5.closeAttachmentViewer,
|
|
461
|
+
"data-id": "closeAttach",
|
|
462
|
+
"data-title": i18nKeys.closeText
|
|
463
|
+
}, /*#__PURE__*/_react["default"].createElement(_IconButton["default"], {
|
|
464
|
+
iconName: "ZD-cross",
|
|
465
|
+
iconSize: "15",
|
|
466
|
+
hoverType: "border",
|
|
467
|
+
className: _AttachmentViewerModule["default"].menuIcon,
|
|
468
|
+
a11y: {
|
|
469
|
+
ariaLabel: i18nKeys.closeText
|
|
470
|
+
},
|
|
471
|
+
title: i18nKeys.closeText
|
|
472
|
+
})))))), /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
|
|
473
|
+
flexible: true,
|
|
474
|
+
role: "toolbar",
|
|
475
|
+
tabindex: "0"
|
|
476
|
+
}, /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
477
|
+
alignBox: "row"
|
|
478
|
+
}, /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
|
|
479
|
+
className: "".concat(_AttachmentViewerModule["default"].arrowBox, " ").concat(uptoTablet ? _AttachmentViewerModule["default"].mbleArrowBox : _AttachmentViewerModule["default"].nrmlArrowBox, " ").concat(selectedIndex === 0 ? _AttachmentViewerModule["default"].hidden : ""),
|
|
480
|
+
onClick: _this5.changeSelectedIndex.bind(_this5, selectedIndex - 1),
|
|
481
|
+
"data-title": i18nKeys.previousText,
|
|
482
|
+
"data-title-position": "left"
|
|
483
|
+
}, /*#__PURE__*/_react["default"].createElement("button", {
|
|
484
|
+
className: _AttachmentViewerModule["default"].btn,
|
|
485
|
+
"aria-label": i18nKeys.previousText
|
|
486
|
+
}, /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
|
|
487
|
+
name: "ZD-arrowLeft3",
|
|
488
|
+
iconClass: _AttachmentViewerModule["default"].arrow,
|
|
489
|
+
dataId: "leftAttachNav",
|
|
490
|
+
isBold: true
|
|
491
|
+
}))), /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
|
|
492
|
+
className: _AttachmentViewerModule["default"].previewBox,
|
|
493
|
+
role: "option",
|
|
494
|
+
tabindex: "0",
|
|
495
|
+
"aria-describedby": ariaId,
|
|
496
|
+
isShrink: false,
|
|
497
|
+
eleRef: _this5.setImgBoxRef,
|
|
498
|
+
scroll: "both",
|
|
499
|
+
flexible: true
|
|
500
|
+
}, _this5.imgPreviewView()), /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
|
|
501
|
+
className: "".concat(_AttachmentViewerModule["default"].arrowBox, " ").concat(uptoTablet ? _AttachmentViewerModule["default"].mbleArrowBox : _AttachmentViewerModule["default"].nrmlArrowBox, " ").concat(totalLen === selectedIndex + 1 ? _AttachmentViewerModule["default"].hidden : ""),
|
|
502
|
+
onClick: _this5.changeSelectedIndex.bind(_this5, selectedIndex + 1),
|
|
503
|
+
"data-title": i18nKeys.nextText,
|
|
504
|
+
"data-title-position": "right"
|
|
505
|
+
}, /*#__PURE__*/_react["default"].createElement("button", {
|
|
506
|
+
className: _AttachmentViewerModule["default"].btn,
|
|
507
|
+
"aria-label": i18nKeys.nextText
|
|
508
|
+
}, /*#__PURE__*/_react["default"].createElement(_Icon["default"], {
|
|
509
|
+
name: "ZD-arrowRight3",
|
|
510
|
+
iconClass: _AttachmentViewerModule["default"].arrow,
|
|
511
|
+
dataId: "rightAttachNav",
|
|
512
|
+
isBold: true
|
|
513
|
+
}))))), /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
|
|
514
|
+
className: "".concat(_AttachmentViewerModule["default"].footer, " ").concat(isPViewListOpen && totalLen !== 1 ? _AttachmentViewerModule["default"].footerHeight : _AttachmentViewerModule["default"].footerHide, " ")
|
|
515
|
+
}, /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
516
|
+
align: "vertical",
|
|
517
|
+
alignBox: "row",
|
|
518
|
+
className: _AttachmentViewerModule["default"].footerHeight
|
|
519
|
+
}, author && /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
|
|
520
|
+
className: _AttachmentViewerModule["default"].author
|
|
521
|
+
}, /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
522
|
+
alignBox: "row",
|
|
523
|
+
align: "both"
|
|
524
|
+
}, /*#__PURE__*/_react["default"].createElement(_Avatar["default"], {
|
|
525
|
+
name: authorName,
|
|
526
|
+
size: "xmedium",
|
|
527
|
+
src: authorHref,
|
|
528
|
+
palette: "info"
|
|
529
|
+
}), /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
|
|
530
|
+
flexible: true,
|
|
531
|
+
className: _AttachmentViewerModule["default"].authorName,
|
|
532
|
+
"data-title": authorName
|
|
533
|
+
}, authorName))), /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
|
|
534
|
+
flexible: true
|
|
535
|
+
}, /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
|
|
536
|
+
align: "vertical",
|
|
537
|
+
alignBox: "row",
|
|
538
|
+
scroll: "horizontal",
|
|
539
|
+
eleRef: function eleRef(el) {
|
|
540
|
+
return _this5.imgListCont = el;
|
|
541
|
+
},
|
|
542
|
+
className: _AttachmentViewerModule["default"].listContainer
|
|
543
|
+
}, data.map(function (item, index) {
|
|
544
|
+
var name = item.name,
|
|
545
|
+
viewUrl = item.viewUrl;
|
|
546
|
+
var isAudio = (0, _Attachment.isAudioFile)(name);
|
|
547
|
+
return /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
|
|
548
|
+
className: "".concat(_AttachmentViewerModule["default"].imgItem, " ").concat(index === selectedIndex ? _AttachmentViewerModule["default"].selected : "", " ").concat(isAudio ? _AttachmentViewerModule["default"].isAudio : ""),
|
|
549
|
+
key: index,
|
|
550
|
+
onClick: _this5.changeSelectedIndex.bind(_this5, index),
|
|
551
|
+
eleRef: function eleRef(el) {
|
|
552
|
+
return _this5["img_".concat(index)] = el;
|
|
553
|
+
},
|
|
554
|
+
dataId: "attachPreviewList",
|
|
555
|
+
"data-title": name
|
|
556
|
+
}, /*#__PURE__*/_react["default"].createElement(_AttachmentImage["default"], {
|
|
557
|
+
src: viewUrl,
|
|
558
|
+
size: "small",
|
|
559
|
+
alt: name,
|
|
560
|
+
className: _AttachmentViewerModule["default"].image,
|
|
561
|
+
isImage: !isAudio
|
|
562
|
+
}));
|
|
563
|
+
}))))), totalLen !== 1 && /*#__PURE__*/_react["default"].createElement(_IconButton["default"], {
|
|
564
|
+
dataId: "attachToggle",
|
|
565
|
+
onClick: _this5.togglePViewList,
|
|
566
|
+
iconName: "ZD-GN-hideTab",
|
|
567
|
+
iconSize: "14",
|
|
568
|
+
hoverType: "border",
|
|
569
|
+
iconClass: "".concat(_AttachmentViewerModule["default"].thumpIcon, " ").concat(isPViewListOpen ? _AttachmentViewerModule["default"].thumpIconActive : ""),
|
|
570
|
+
className: _AttachmentViewerModule["default"].button,
|
|
571
|
+
a11y: {
|
|
572
|
+
ariaLabel: i18nKeys.hideText
|
|
573
|
+
},
|
|
574
|
+
title: isPViewListOpen ? i18nKeys.hideText : i18nKeys.showText
|
|
575
|
+
}));
|
|
576
|
+
}));
|
|
577
|
+
}
|
|
578
|
+
}]);
|
|
579
|
+
|
|
580
|
+
return AttachmentViewer;
|
|
581
|
+
}(_react.Component);
|
|
582
|
+
|
|
583
|
+
exports["default"] = AttachmentViewer;
|
|
584
|
+
AttachmentViewer.propTypes = {
|
|
585
|
+
hideAttachmentViewer: _propTypes["default"].func,
|
|
586
|
+
i18nKeys: _propTypes["default"].shape({
|
|
587
|
+
nextText: _propTypes["default"].string,
|
|
588
|
+
previousText: _propTypes["default"].string,
|
|
589
|
+
zoomOutText: _propTypes["default"].string,
|
|
590
|
+
zoomInText: _propTypes["default"].string,
|
|
591
|
+
newTabText: _propTypes["default"].string,
|
|
592
|
+
downloadText: _propTypes["default"].string,
|
|
593
|
+
closeText: _propTypes["default"].string,
|
|
594
|
+
hideText: _propTypes["default"].string,
|
|
595
|
+
showText: _propTypes["default"].string
|
|
596
|
+
}),
|
|
597
|
+
needDownload: _propTypes["default"].string,
|
|
598
|
+
previewObj: _propTypes["default"].object,
|
|
599
|
+
responsiveId: _propTypes["default"].string,
|
|
600
|
+
maintainZoom: _propTypes["default"].bool
|
|
601
|
+
};
|
|
602
|
+
AttachmentViewer.defaultProps = {
|
|
603
|
+
responsiveId: "Helmet",
|
|
604
|
+
needDownload: true,
|
|
605
|
+
i18nKeys: {},
|
|
606
|
+
maintainZoom: false
|
|
607
|
+
};
|
|
608
|
+
|
|
609
|
+
if (false) {
|
|
610
|
+
AttachmentViewer.docs = {
|
|
611
|
+
componentGroup: "Molecule"
|
|
612
|
+
};
|
|
613
|
+
}
|