@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.
Files changed (37) hide show
  1. package/README.md +8 -0
  2. package/assets/Appearance/dark/mode/dotDarkMode.module.css +10 -0
  3. package/assets/Appearance/dark/themes/blue/blueDarkDotTheme.module.css +6 -0
  4. package/assets/Appearance/dark/themes/green/greenDarkDotTheme.module.css +6 -0
  5. package/assets/Appearance/dark/themes/orange/orangeDarkDotTheme.module.css +6 -0
  6. package/assets/Appearance/dark/themes/red/redDarkDotTheme.module.css +6 -0
  7. package/assets/Appearance/dark/themes/yellow/yellowDarkDotTheme.module.css +6 -0
  8. package/assets/Appearance/default/mode/dotDefaultMode.module.css +10 -0
  9. package/assets/Appearance/default/themes/blue/blueDefaultDotTheme.module.css +6 -0
  10. package/assets/Appearance/default/themes/green/greenDefaultDotTheme.module.css +6 -0
  11. package/assets/Appearance/default/themes/orange/orangeDefaultDotTheme.module.css +6 -0
  12. package/assets/Appearance/default/themes/red/redDefaultDotTheme.module.css +6 -0
  13. package/assets/Appearance/default/themes/yellow/yellowDefaultDotTheme.module.css +6 -0
  14. package/assets/Appearance/pureDark/mode/dotPureDarkMode.module.css +10 -0
  15. package/assets/Appearance/pureDark/themes/blue/bluePureDarkDotTheme.module.css +6 -0
  16. package/assets/Appearance/pureDark/themes/green/greenPureDarkDotTheme.module.css +6 -0
  17. package/assets/Appearance/pureDark/themes/orange/orangePureDarkDotTheme.module.css +6 -0
  18. package/assets/Appearance/pureDark/themes/red/redPureDarkDotTheme.module.css +6 -0
  19. package/assets/Appearance/pureDark/themes/yellow/yellowPureDarkDotTheme.module.css +6 -0
  20. package/es/AttachmentViewer/Attachment.js +17 -0
  21. package/es/AttachmentViewer/AttachmentImage.js +85 -0
  22. package/es/AttachmentViewer/AttachmentViewer.js +562 -0
  23. package/es/AttachmentViewer/AttachmentViewer.module.css +346 -0
  24. package/es/AttachmentViewer/utils.js +107 -0
  25. package/es/common/dot_animation.module.css +27 -0
  26. package/es/common/dot_common.module.css +4 -0
  27. package/es/form/fields/TextEditor/TextEditor.js +4 -1
  28. package/images/audio_thumbnail.png +0 -0
  29. package/lib/AttachmentViewer/Attachment.js +28 -0
  30. package/lib/AttachmentViewer/AttachmentImage.js +129 -0
  31. package/lib/AttachmentViewer/AttachmentViewer.js +645 -0
  32. package/lib/AttachmentViewer/AttachmentViewer.module.css +346 -0
  33. package/lib/AttachmentViewer/utils.js +134 -0
  34. package/lib/common/dot_animation.module.css +27 -0
  35. package/lib/common/dot_common.module.css +4 -0
  36. package/lib/form/fields/TextEditor/TextEditor.js +4 -1
  37. package/package.json +7 -7
@@ -0,0 +1,346 @@
1
+ .header {
2
+ height: var(--zd_size40);
3
+ position: relative;
4
+ z-index: 1;
5
+ composes: alignVertical from '~@zohodesk/components/lib/common/common.module.css';
6
+ background-color: var(--zdt_attachmentviewer_header_bg);
7
+ padding: 0 var(--zd_size15);
8
+ border-bottom: 1px solid var(--zdt_attachmentviewer_header_border);
9
+ }
10
+
11
+ .title {
12
+ max-width: 50%;
13
+ composes: dotted from '~@zohodesk/components/lib/common/common.module.css';
14
+ }
15
+
16
+ [dir=ltr] .title {
17
+ padding-right: var(--zd_size15);
18
+ }
19
+
20
+ [dir=rtl] .title {
21
+ padding-left: var(--zd_size15);
22
+ }
23
+
24
+ .count {
25
+ position: absolute;
26
+ composes: xMiddle from '~@zohodesk/components/lib/common/common.module.css';
27
+ padding: 0 var(--zd_size10);
28
+ }
29
+
30
+ .title,
31
+ .count {
32
+ color: var(--zdt_attachmentviewer_title_text);
33
+ font-size: var(--zd_font_size15);
34
+ }
35
+
36
+ [dir=ltr] .menuBar {
37
+ padding-left: var(--zd_size5);
38
+ }
39
+
40
+ [dir=rtl] .menuBar {
41
+ padding-right: var(--zd_size5);
42
+ }
43
+
44
+ .mbleMenuBar {
45
+ align-self: baseline;
46
+ margin-top: var(--zd_size8);
47
+ }
48
+
49
+ [dir=ltr] .menu+.menu {
50
+ margin-left: var(--zd_size22);
51
+ }
52
+
53
+ [dir=rtl] .menu+.menu {
54
+ margin-right: var(--zd_size22);
55
+ }
56
+
57
+ .mobileMenu+.mobileMenu {
58
+ margin-bottom: var(--zd_size22);
59
+ }
60
+
61
+ .menuIcon {
62
+ --iconColor: var(--zdt_attachmentviewer_title_text);
63
+ }
64
+
65
+ .nrmlArrowBox {
66
+ width: var(--zd_size80);
67
+ }
68
+
69
+ .mbleArrowBox {
70
+ width: var(--zd_size50);
71
+ }
72
+
73
+ .arrowBox:hover {
74
+ background-color: var(--zdt_attachmentviewer_arrow_bg_hover);
75
+ }
76
+
77
+ .arrow {
78
+ color: var(--zdt_attachmentviewer_title_text);
79
+ font-size: var(--zd_font_size22);
80
+ height: var(--zd_size38);
81
+ width: var(--zd_size38);
82
+ line-height: var(--zd_size36);
83
+ border-radius: 50%;
84
+ cursor: pointer;
85
+ }
86
+
87
+ .preview {
88
+ composes: posrel from '~@zohodesk/components/lib/common/common.module.css';
89
+ text-align: center;
90
+ margin: var(--zd_size20) 0;
91
+ }
92
+
93
+ .zoomIn {
94
+ max-height: 100%;
95
+ max-width: 90%;
96
+ position: absolute;
97
+ composes: middleBoth from '~@zohodesk/components/lib/common/common.module.css';
98
+ }
99
+
100
+ .zoomOut {
101
+ cursor: zoom-out;
102
+ }
103
+
104
+ .button {
105
+ position: absolute;
106
+ bottom: var(--zd_size23);
107
+ z-index: 3;
108
+ border: 1px solid var(--zdt_attachmentviewer_button_border);
109
+ }
110
+
111
+ [dir=ltr] .button {
112
+ right: var(--zd_size20);
113
+ }
114
+
115
+ [dir=rtl] .button {
116
+ left: var(--zd_size20);
117
+ }
118
+
119
+ .visible {
120
+ visibility: visible;
121
+ }
122
+
123
+ .hidden {
124
+ visibility: hidden;
125
+ }
126
+
127
+ .footer {
128
+ width: 100%;
129
+ overflow: hidden;
130
+ transition: height var(--zd_transition3);
131
+ background-color: var(--zdt_attachmentviewer_footer_bg);
132
+ }
133
+
134
+ .footerHeight {
135
+ height: var(--zd_size75);
136
+ }
137
+
138
+ .footerHide {
139
+ height: 0;
140
+ }
141
+
142
+ .listContainer {
143
+ padding: 0 var(--zd_size18);
144
+ }
145
+
146
+ .imgItem {
147
+ height: var(--zd_size60);
148
+ min-width: var(--zd_size40);
149
+ position: relative;
150
+ transition: border var(--zd_transition3);
151
+ border-width: 2px;
152
+ border-style: solid;
153
+ border-color: var(--dot_mirror);
154
+ border-radius: 3px;
155
+ padding: var(--zd_size2);
156
+ }
157
+
158
+ .imgItem:hover {
159
+ border-color: var(--zdt_attachmentviewer_hover_border);
160
+ }
161
+
162
+ [dir=ltr] .imgItem+.imgItem {
163
+ margin-left: var(--zd_size12);
164
+ }
165
+
166
+ [dir=rtl] .imgItem+.imgItem {
167
+ margin-right: var(--zd_size12);
168
+ }
169
+
170
+ .image {
171
+ cursor: pointer;
172
+ }
173
+
174
+ .selected, .selected:hover {
175
+ border-color: var(--zdt_attachmentviewer_selected_border);
176
+ }
177
+
178
+ .selected::after {
179
+ content: '';
180
+ position: absolute;
181
+ top: 0;
182
+ width: 100%;
183
+ height: 100%;
184
+ opacity: 0.3;
185
+ background-color: var(--zdt_attachmentviewer_selected_after_bg);
186
+ box-shadow: 0 0 4px 2px var(--zdt_attachmentviewer_selected_box_shadow) inset;
187
+ }
188
+
189
+ [dir=ltr] .selected::after {
190
+ left: 0;
191
+ }
192
+
193
+ [dir=rtl] .selected::after {
194
+ right: 0;
195
+ }
196
+
197
+ .zoomIcon {
198
+ font-size: var(--zd_font_size15);
199
+ }
200
+
201
+ .newTabIcon {
202
+ font-size: var(--zd_font_size12);
203
+ }
204
+
205
+ .appIcon {
206
+ font-size: var(--zd_font_size9);
207
+ }
208
+
209
+ .thumpIcon {
210
+ color: var(--zdt_attachmentviewer_title_text);
211
+ transition: transform var(--zd_transition3);
212
+ transform: rotateX(180deg);
213
+ }
214
+
215
+ .thumpIconActive {
216
+ transform: rotateX(0deg);
217
+ }
218
+
219
+ .isAudio {
220
+ composes: audioImage from '../common/dot_common.module.css';
221
+ width: var(--zd_size100);
222
+ background-size: 100% 100%;
223
+ }
224
+
225
+ .isAudio .image {
226
+ opacity: 0;
227
+ }
228
+
229
+ .video {
230
+ position: absolute;
231
+ top: 0;
232
+ bottom: 0;
233
+ margin: auto;
234
+ }
235
+
236
+ [dir=ltr] .video {
237
+ left: 0;
238
+ right: 0;
239
+ }
240
+
241
+ [dir=rtl] .video {
242
+ right: 0;
243
+ left: 0;
244
+ }
245
+
246
+ .imgBox {
247
+ position: absolute;
248
+ transition: var(--zd_transition3) ease-in-out;
249
+ opacity: 0;
250
+ overflow: auto;
251
+ }
252
+
253
+ .imgBox>img {
254
+ object-fit: contain;
255
+ }
256
+
257
+ .imgRef {
258
+ width: 100%;
259
+ height: 100%;
260
+ max-width: 100%;
261
+ max-height: 100%;
262
+ composes: dflex from '~@zohodesk/components/lib/common/common.module.css';
263
+ }
264
+
265
+ .img {
266
+ transition: var(--zd_transition3) ease-in-out;
267
+ margin: auto;
268
+ cursor: zoom-in;
269
+ }
270
+
271
+ .imgRef .normalImg {
272
+ max-width: inherit;
273
+ max-height: inherit;
274
+ cursor: zoom-in;
275
+ }
276
+
277
+ .imgRef .zoomedImg {
278
+ max-width: initial;
279
+ max-height: initial;
280
+ cursor: zoom-out;
281
+ }
282
+
283
+ .previewBox {
284
+ position: relative;
285
+ overflow: hidden;
286
+ }
287
+
288
+ .spinLoad {
289
+ position: absolute;
290
+ composes: middleBoth from '~@zohodesk/components/lib/common/common.module.css';
291
+ height: var(--zd_font_size18);
292
+ width: var(--zd_font_size18);
293
+ }
294
+
295
+ .loader {
296
+ height: 100%;
297
+ width: 100%;
298
+ composes: rotate from '../common/dot_animation.module.css';
299
+ composes: infinite from '~@zohodesk/components/lib/common/animation.module.css';
300
+ border: 2px solid var(--zdt_attachmentviewer_loader_border);
301
+ border-top-color: var(--zdt_attachmentviewer_loader_border_top);
302
+ border-radius: 50%;
303
+ }
304
+
305
+ [dir=ltr] .loader {
306
+ animation-duration: var(--zd_transition8);
307
+ animation-timing-function: linear;
308
+ }
309
+
310
+ [dir=rtl] .loader {
311
+ animation-duration: var(--zd_transition8);
312
+ animation-timing-function: linear;
313
+ }
314
+
315
+ .hide {
316
+ opacity: 0;
317
+ visibility: hidden;
318
+ }
319
+
320
+ .author {
321
+ max-width: var(--zd_size200);
322
+ }
323
+
324
+ [dir=ltr] .author {
325
+ padding-left: var(--zd_size15);
326
+ }
327
+
328
+ [dir=rtl] .author {
329
+ padding-right: var(--zd_size15);
330
+ }
331
+
332
+ .authorName {
333
+ font-size: var(--zd_font_size15);
334
+ color: var(--zdt_attachmentviewer_title_text);
335
+ composes: dotted from '~@zohodesk/components/lib/common/common.module.css';
336
+ margin: 0 var(--zd_size10);
337
+ }
338
+
339
+ .btn {
340
+ height: 100%;
341
+ width: 100%;
342
+ background-color: var(--dot_mirror);
343
+ border: 0;
344
+ cursor: pointer;
345
+ }
346
+
@@ -0,0 +1,107 @@
1
+ export class Zoom {
2
+ constructor() {
3
+ const matrix = [1, 0, 0, 1, 0, 0]; // current view transform
4
+
5
+ this.m = matrix; // alias
6
+
7
+ this.scale = 1; // current scale
8
+
9
+ this.pos = {
10
+ x: 0,
11
+ y: 0
12
+ }; // current position of origin
13
+
14
+ this.dirty = true;
15
+ }
16
+
17
+ applyTo(el) {
18
+ const {
19
+ dirty,
20
+ m
21
+ } = this;
22
+
23
+ if (dirty) {
24
+ this.update();
25
+ }
26
+
27
+ el.style.transform = `matrix(${m[0]},${m[1]},${m[2]},${m[3]},${m[4]},${m[5]})`;
28
+ el.style.transformOrigin = '0 0';
29
+ }
30
+
31
+ update() {
32
+ // m[4], m[5] - need to set transforms based on positions. Currently set to 0 to zoom based on center
33
+ const {
34
+ m,
35
+ scale,
36
+ pos
37
+ } = this;
38
+ this.dirty = false;
39
+ m[3] = m[0] = scale;
40
+ m[2] = m[1] = 0;
41
+ m[4] = pos.x;
42
+ m[5] = pos.y;
43
+ }
44
+
45
+ pan(amount) {
46
+ if (this.dirty) {
47
+ this.update();
48
+ }
49
+
50
+ this.pos.x += amount.x;
51
+ this.pos.y += amount.y;
52
+ this.dirty = true;
53
+ }
54
+
55
+ scaleAt(at, amount) {
56
+ // at in screen coords
57
+ const {
58
+ dirty,
59
+ pos
60
+ } = this;
61
+
62
+ if (dirty) {
63
+ this.update();
64
+ }
65
+
66
+ this.scale *= amount;
67
+ this.pos.x = at.x - (at.x - pos.x) * amount;
68
+ this.pos.y = at.y - (at.y - pos.y) * amount;
69
+ this.dirty = true;
70
+ }
71
+
72
+ }
73
+ ;
74
+ export class ZoomEvent {
75
+ constructor() {
76
+ this.pos = [];
77
+ }
78
+
79
+ on(dir, ele, zoom, event) {
80
+ if (dir === 'in') {
81
+ const x = event.pageX - ele.width / 2;
82
+ const y = event.pageY - ele.height / 2;
83
+ this.pos.push({
84
+ x,
85
+ y
86
+ });
87
+ zoom.scaleAt({
88
+ x,
89
+ y
90
+ }, 1.6);
91
+ zoom.applyTo(ele);
92
+ } else if (this.pos.length) {
93
+ const {
94
+ x,
95
+ y
96
+ } = this.pos.pop();
97
+ zoom.scaleAt({
98
+ x,
99
+ y
100
+ }, 1 / 1.6);
101
+ zoom.applyTo(ele);
102
+ }
103
+
104
+ event.preventDefault();
105
+ }
106
+
107
+ }
@@ -0,0 +1,27 @@
1
+
2
+ [dir=ltr] .rotate{
3
+ animation-name: rotate-ltr ;
4
+ }
5
+ [dir=rtl] .rotate{
6
+ animation-name: rotate-rtl ;
7
+ }
8
+
9
+ @keyframes rotate-ltr {
10
+ from {
11
+ transform: rotate(0);
12
+ }
13
+
14
+ to {
15
+ transform: rotate(360deg);
16
+ }
17
+ }
18
+
19
+ @keyframes rotate-rtl {
20
+ from {
21
+ transform: rotate(0);
22
+ }
23
+
24
+ to {
25
+ transform: rotate(-360deg);
26
+ }
27
+ }
@@ -0,0 +1,4 @@
1
+ .audioImage {
2
+ background-image: url('../../images/audio_thumbnail.png');
3
+ background-repeat: no-repeat;
4
+ }
@@ -54,6 +54,7 @@ export default class TextEditor extends Component {
54
54
  needEditorFocus = true,
55
55
  handleDropUpload,
56
56
  fontFamily,
57
+ fontSize,
57
58
  initCallback,
58
59
  handleAlertMessage,
59
60
  needInlineAttachment
@@ -92,7 +93,7 @@ export default class TextEditor extends Component {
92
93
  }
93
94
 
94
95
  defaultObj = Object.assign(defaultObj, editorOptions);
95
- ZohoDeskEditor_Init.init(editorMode, fontFamily, initCallback);
96
+ ZohoDeskEditor_Init.init(editorMode, fontFamily, initCallback, fontSize);
96
97
  ZohoDeskEditor.create && ZohoDeskEditor.create(defaultObj);
97
98
  }
98
99
  }
@@ -405,6 +406,7 @@ TextEditor.defaultProps = {
405
406
  type: 'large',
406
407
  changeEditorContent: false,
407
408
  fontFamily: 'Lato',
409
+ fontSize: '16',
408
410
  shouldUpdateContent: true,
409
411
  i18nKeys: {},
410
412
  needInlineAttachment: false,
@@ -421,6 +423,7 @@ TextEditor.propTypes = {
421
423
  editorMode: PropTypes.string,
422
424
  editorOptions: PropTypes.object,
423
425
  fontFamily: PropTypes.oneOf(['Lato', 'Roboto', 'Puvi']),
426
+ fontSize: PropTypes.string,
424
427
  getRef: PropTypes.func,
425
428
  handleAlertMessage: PropTypes.func,
426
429
  handleDropUpload: PropTypes.func,
Binary file
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getExtensionFromFileName = getExtensionFromFileName;
7
+ exports.isAudioFile = isAudioFile;
8
+ exports.isBrowserSupportedFile = isBrowserSupportedFile;
9
+ var UNASSIGNED = 'Unassigned';
10
+ var BROWSER_SUPPORTED_FILES = ['pdf', 'text', 'txt', 'css', 'jpg', 'jpeg', 'gif', 'png', 'bmp', 'ico', 'sh', 'mp3', 'wav', 'ogg'];
11
+
12
+ function isAudioFile(fileName) {
13
+ var extension = getExtensionFromFileName(fileName);
14
+ return /mp3|wav|ogg/i.test(extension);
15
+ }
16
+
17
+ function getExtensionFromFileName(fileName) {
18
+ if (fileName && fileName.indexOf(".") !== -1) {
19
+ return fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length).toLowerCase();
20
+ }
21
+
22
+ return "";
23
+ }
24
+
25
+ function isBrowserSupportedFile(fileName) {
26
+ var extension = getExtensionFromFileName(fileName);
27
+ return BROWSER_SUPPORTED_FILES.indexOf(extension) !== -1;
28
+ }
@@ -0,0 +1,129 @@
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 _Image = _interopRequireDefault(require("../Image/Image"));
15
+
16
+ var _AttachmentViewerModule = _interopRequireDefault(require("./AttachmentViewer.module.css"));
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
19
+
20
+ 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); }
21
+
22
+ 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; }
23
+
24
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
25
+
26
+ 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); } }
27
+
28
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
29
+
30
+ 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); }
31
+
32
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
33
+
34
+ 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); }; }
35
+
36
+ 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); }
37
+
38
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
39
+
40
+ 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; } }
41
+
42
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
43
+
44
+ var AttachmentImage = /*#__PURE__*/function (_Component) {
45
+ _inherits(AttachmentImage, _Component);
46
+
47
+ var _super = _createSuper(AttachmentImage);
48
+
49
+ function AttachmentImage(props) {
50
+ var _this;
51
+
52
+ _classCallCheck(this, AttachmentImage);
53
+
54
+ _this = _super.call(this, props);
55
+ _this.imageEle = /*#__PURE__*/_react["default"].createRef();
56
+ _this.state = {
57
+ isLoading: true
58
+ };
59
+ _this.imgLoad = _this.imgLoad.bind(_assertThisInitialized(_this));
60
+ return _this;
61
+ }
62
+
63
+ _createClass(AttachmentImage, [{
64
+ key: "componentDidMount",
65
+ value: function componentDidMount() {
66
+ var isImage = this.props.isImage;
67
+
68
+ if (isImage) {
69
+ var image = this.imageEle.current;
70
+ image.addEventListener('load', this.imgLoad);
71
+ } else {
72
+ this.setState({
73
+ isLoading: false
74
+ });
75
+ }
76
+ }
77
+ }, {
78
+ key: "imgLoad",
79
+ value: function imgLoad() {
80
+ this.setState({
81
+ isLoading: false
82
+ });
83
+ var onLoad = this.props.onLoad;
84
+ onLoad && onLoad();
85
+ }
86
+ }, {
87
+ key: "render",
88
+ value: function render() {
89
+ var _this$props = this.props,
90
+ src = _this$props.src,
91
+ onClick = _this$props.onClick,
92
+ alt = _this$props.alt,
93
+ dataId = _this$props.dataId,
94
+ id = _this$props.id,
95
+ className = _this$props.className,
96
+ isCover = _this$props.isCover;
97
+ var isLoading = this.state.isLoading;
98
+ return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, isLoading ? /*#__PURE__*/_react["default"].createElement("div", {
99
+ className: "".concat(_AttachmentViewerModule["default"].spinLoad)
100
+ }, /*#__PURE__*/_react["default"].createElement("div", {
101
+ className: _AttachmentViewerModule["default"].loader
102
+ })) : null, /*#__PURE__*/_react["default"].createElement(_Image["default"], {
103
+ htmlId: id,
104
+ eleRef: this.imageEle,
105
+ dataId: dataId,
106
+ src: src,
107
+ onClick: onClick,
108
+ className: "".concat(isLoading ? _AttachmentViewerModule["default"].hide : '', " ").concat(className),
109
+ alt: alt,
110
+ isCover: isCover
111
+ }));
112
+ }
113
+ }]);
114
+
115
+ return AttachmentImage;
116
+ }(_react.Component);
117
+
118
+ exports["default"] = AttachmentImage;
119
+ AttachmentImage.propTypes = {
120
+ alt: _propTypes["default"].string,
121
+ className: _propTypes["default"].string,
122
+ dataId: _propTypes["default"].string,
123
+ id: _propTypes["default"].string,
124
+ isCover: _propTypes["default"].bool,
125
+ isImage: _propTypes["default"].string,
126
+ onClick: _propTypes["default"].func,
127
+ onLoad: _propTypes["default"].func,
128
+ src: _propTypes["default"].string
129
+ };