dtable-ui-component 0.3.2 → 0.3.4-alpha1

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 (65) hide show
  1. package/assets/dtable-font/dtable-font.eot +0 -0
  2. package/assets/dtable-font/dtable-font.svg +319 -11
  3. package/assets/dtable-font/dtable-font.ttf +0 -0
  4. package/assets/dtable-font/dtable-font.woff +0 -0
  5. package/assets/dtable-font/dtable-font.woff2 +0 -0
  6. package/assets/dtable-font.css +630 -14
  7. package/lib/AutoNumberFormatter/index.js +2 -2
  8. package/lib/ButtonFormatter/index.js +4 -8
  9. package/lib/CTimeFormatter/index.js +2 -2
  10. package/lib/CheckboxFormatter/index.js +2 -2
  11. package/lib/CollaboratorFormatter/index.js +2 -2
  12. package/lib/CreatorFormatter/index.js +2 -2
  13. package/lib/DTableCustomizeCollaboratorSelect/index.css +1 -1
  14. package/lib/DTableSearchInput/index.js +2 -2
  15. package/lib/DateFormatter/index.js +2 -2
  16. package/lib/DigitalSignFormatter/index.js +2 -2
  17. package/lib/DurationFormatter/index.js +2 -2
  18. package/lib/EmailFormatter/index.js +2 -2
  19. package/lib/FileFormatter/index.js +4 -3
  20. package/lib/FileItemFormatter/index.js +1 -1
  21. package/lib/FormulaFormatter/index.js +24 -5
  22. package/lib/FormulaFormatter/utils.js +91 -0
  23. package/lib/GeolocationFormatter/index.js +2 -2
  24. package/lib/HtmlLongTextFormatter/index.js +2 -2
  25. package/lib/ImageFormatter/images-lazy-load.js +12 -16
  26. package/lib/ImageFormatter/index.js +2 -2
  27. package/lib/ImagePreviewerLightbox/index.js +3 -3
  28. package/lib/LastModifierFormatter/index.js +2 -2
  29. package/lib/LinkFormatter/index.js +4 -4
  30. package/lib/MTimeFormatter/index.js +2 -2
  31. package/lib/MultipleSelectFormatter/index.js +2 -2
  32. package/lib/NumberFormatter/index.js +2 -2
  33. package/lib/RateFormatter/index.js +2 -2
  34. package/lib/RowExpandFileFormatter/index.css +72 -0
  35. package/lib/RowExpandFileFormatter/index.js +59 -0
  36. package/lib/RowExpandFileFormatter/row-expand-file-item-formatter.js +125 -0
  37. package/lib/RowExpandFormatter/index.css +73 -0
  38. package/lib/RowExpandFormatter/index.js +441 -0
  39. package/lib/RowExpandImageFormatter/index.css +79 -0
  40. package/lib/RowExpandImageFormatter/index.js +127 -0
  41. package/lib/RowExpandImageFormatter/row-expand-image-item-formatter.js +128 -0
  42. package/lib/RowExpandImageFormatter/utils.js +7 -0
  43. package/lib/RowExpandLinkFormatter/collaborator-item-formatter.js +164 -0
  44. package/lib/RowExpandLinkFormatter/column-data-constants.js +20 -0
  45. package/lib/RowExpandLinkFormatter/date-utils.js +127 -0
  46. package/lib/RowExpandLinkFormatter/formula-constants.js +9 -0
  47. package/lib/RowExpandLinkFormatter/index.css +25 -0
  48. package/lib/RowExpandLinkFormatter/index.js +170 -0
  49. package/lib/RowExpandLinkFormatter/number-precision.js +116 -0
  50. package/lib/RowExpandLinkFormatter/utils.js +58 -0
  51. package/lib/RowExpandLinkFormatter/value-display-utils.js +401 -0
  52. package/lib/SimpleLongTextFormatter/index.js +2 -2
  53. package/lib/SingleSelectFormatter/index.js +2 -2
  54. package/lib/TextFormatter/index.js +2 -2
  55. package/lib/UrlFormatter/index.js +2 -2
  56. package/lib/common/delete-tip.css +16 -0
  57. package/lib/common/delete-tip.js +84 -0
  58. package/lib/common/modal-portal.js +44 -0
  59. package/lib/constants/cell-types.js +5 -1
  60. package/lib/data/dtable-value.js +2731 -0
  61. package/lib/index.js +7 -1
  62. package/lib/lang/index.js +1 -1
  63. package/lib/locals/en.js +17 -13
  64. package/lib/locals/zh-CN.js +16 -12
  65. package/package.json +5 -4
@@ -0,0 +1,441 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
4
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
5
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
7
+
8
+ var _emptyTypeMap;
9
+
10
+ import React from 'react';
11
+ import classnames from 'classnames';
12
+ import { TextFormatter, NumberFormatter, CheckboxFormatter, DateFormatter, SingleSelectFormatter, MultipleSelectFormatter, CollaboratorFormatter, LongTextFormatter, GeolocationFormatter, CTimeFormatter, CreatorFormatter, LastModifierFormatter, MTimeFormatter, AutoNumberFormatter, UrlFormatter, EmailFormatter, DurationFormatter, RateFormatter, ButtonFormatter, RowExpandImageFormatter, RowExpandFileFormatter, RowExpandLinkFormatter, DigitalSignFormatter, FormulaFormatter } from '../index';
13
+ import { CellType } from '../constants';
14
+ import './index.css';
15
+ var emptyTypeMap = (_emptyTypeMap = {}, _defineProperty(_emptyTypeMap, CellType.TEXT, true), _defineProperty(_emptyTypeMap, CellType.LONG_TEXT, true), _defineProperty(_emptyTypeMap, CellType.GEOLOCATION, true), _defineProperty(_emptyTypeMap, CellType.SINGLE_SELECT, true), _defineProperty(_emptyTypeMap, CellType.MULTIPLE_SELECT, true), _defineProperty(_emptyTypeMap, CellType.CTIME, true), _defineProperty(_emptyTypeMap, CellType.MTIME, true), _defineProperty(_emptyTypeMap, CellType.DATE, true), _defineProperty(_emptyTypeMap, CellType.AUTO_NUMBER, true), _defineProperty(_emptyTypeMap, CellType.URL, true), _defineProperty(_emptyTypeMap, CellType.EMAIL, true), _defineProperty(_emptyTypeMap, CellType.IMAGE, true), _defineProperty(_emptyTypeMap, CellType.FILE, true), _defineProperty(_emptyTypeMap, CellType.CREATOR, true), _defineProperty(_emptyTypeMap, CellType.LAST_MODIFIER, true), _emptyTypeMap);
16
+
17
+ var EditorFormatter = /*#__PURE__*/function (_React$Component) {
18
+ _inherits(EditorFormatter, _React$Component);
19
+
20
+ var _super = _createSuper(EditorFormatter);
21
+
22
+ function EditorFormatter(_props) {
23
+ var _this;
24
+
25
+ _classCallCheck(this, EditorFormatter);
26
+
27
+ _this = _super.call(this, _props);
28
+
29
+ _this.updateCollaborators = function () {
30
+ _this.setState({
31
+ collaborators: _this.getCollaborator()
32
+ });
33
+ };
34
+
35
+ _this.calculateCollaboratorData = function (props) {
36
+ var row = props.row,
37
+ column = props.column;
38
+
39
+ if (column.type === CellType.CREATOR || column.type === CellType.LAST_MODIFIER) {
40
+ var email = row[column.name];
41
+
42
+ _this.loadCollaborator(email);
43
+ } else if (column.type === CellType.COLLABORATOR) {
44
+ var emails = row[column.name];
45
+
46
+ if (Array.isArray(emails)) {
47
+ emails.forEach(function (email) {
48
+ _this.loadCollaborator(email);
49
+ });
50
+ }
51
+ }
52
+ };
53
+
54
+ _this.getCollaborator = function () {
55
+ var _this$props = _this.props,
56
+ context = _this$props.context,
57
+ collaborators = _this$props.collaborators;
58
+
59
+ if (context && context.getCollaboratorsFromCache) {
60
+ return context.getCollaboratorsFromCache();
61
+ }
62
+
63
+ return collaborators || [];
64
+ };
65
+
66
+ _this.loadCollaborator = function (email) {
67
+ var context = _this.props.context;
68
+
69
+ if (context && context.loadCollaborator) {
70
+ context.loadCollaborator(email);
71
+ }
72
+ };
73
+
74
+ _this.renderEmpty = function () {
75
+ return /*#__PURE__*/React.createElement("span", {
76
+ className: "row-cell-empty"
77
+ });
78
+ };
79
+
80
+ _this.renderFormatter = function () {
81
+ var _this$props2 = _this.props,
82
+ column = _this$props2.column,
83
+ row = _this$props2.row,
84
+ className = _this$props2.className;
85
+ var _column = column,
86
+ columnType = _column.type;
87
+ var collaborators = _this.state.collaborators;
88
+ var containerClassName = "dtable-".concat(columnType, "-formatter ").concat(className || '');
89
+ var cellValue = row[column.key] || row[column.name];
90
+
91
+ if (!cellValue && emptyTypeMap[columnType]) {
92
+ return _this.renderEmpty();
93
+ }
94
+
95
+ switch (columnType) {
96
+ case CellType.TEXT:
97
+ {
98
+ return /*#__PURE__*/React.createElement("div", {
99
+ className: "form-control d-flex align-items-center w-100"
100
+ }, /*#__PURE__*/React.createElement(TextFormatter, {
101
+ value: cellValue,
102
+ containerClassName: containerClassName
103
+ }));
104
+ }
105
+
106
+ case CellType.COLLABORATOR:
107
+ {
108
+ if (!cellValue || cellValue.length === 0) {
109
+ return _this.renderEmpty();
110
+ }
111
+
112
+ return /*#__PURE__*/React.createElement("div", {
113
+ className: "form-control d-flex align-items-center w-100 h-auto"
114
+ }, /*#__PURE__*/React.createElement(CollaboratorFormatter, {
115
+ value: cellValue,
116
+ collaborators: collaborators,
117
+ containerClassName: containerClassName
118
+ }));
119
+ }
120
+
121
+ case CellType.LONG_TEXT:
122
+ {
123
+ return /*#__PURE__*/React.createElement("div", {
124
+ className: "longtext-formatter-container"
125
+ }, /*#__PURE__*/React.createElement(LongTextFormatter, {
126
+ value: cellValue,
127
+ containerClassName: containerClassName,
128
+ isSample: false
129
+ }));
130
+ }
131
+
132
+ case CellType.GEOLOCATION:
133
+ {
134
+ return /*#__PURE__*/React.createElement("div", {
135
+ className: "geolocation-formatter-container"
136
+ }, /*#__PURE__*/React.createElement(GeolocationFormatter, {
137
+ value: cellValue,
138
+ data: column.data,
139
+ containerClassName: containerClassName
140
+ }));
141
+ }
142
+
143
+ case CellType.NUMBER:
144
+ {
145
+ if (!cellValue && cellValue !== 0) {
146
+ return _this.renderEmpty();
147
+ }
148
+
149
+ return /*#__PURE__*/React.createElement("div", {
150
+ className: "form-control d-flex align-items-center w-100"
151
+ }, /*#__PURE__*/React.createElement(NumberFormatter, {
152
+ value: cellValue,
153
+ data: column.data,
154
+ containerClassName: containerClassName
155
+ }));
156
+ }
157
+
158
+ case CellType.DATE:
159
+ {
160
+ return /*#__PURE__*/React.createElement("div", {
161
+ className: "form-control d-flex align-items-center w-100"
162
+ }, /*#__PURE__*/React.createElement(DateFormatter, {
163
+ value: cellValue,
164
+ format: column.data.format,
165
+ containerClassName: containerClassName
166
+ }));
167
+ }
168
+
169
+ case CellType.CTIME:
170
+ {
171
+ if (!row._ctime) {
172
+ return _this.renderEmpty();
173
+ }
174
+
175
+ return /*#__PURE__*/React.createElement("div", {
176
+ className: "form-control d-flex align-items-center w-100"
177
+ }, /*#__PURE__*/React.createElement(CTimeFormatter, {
178
+ value: row._ctime,
179
+ containerClassName: containerClassName
180
+ }));
181
+ }
182
+
183
+ case CellType.MTIME:
184
+ {
185
+ if (!row._mtime) {
186
+ return _this.renderEmpty();
187
+ }
188
+
189
+ return /*#__PURE__*/React.createElement("div", {
190
+ className: "form-control d-flex align-items-center w-100"
191
+ }, /*#__PURE__*/React.createElement(MTimeFormatter, {
192
+ value: row._mtime,
193
+ containerClassName: containerClassName
194
+ }));
195
+ }
196
+
197
+ case CellType.MULTIPLE_SELECT:
198
+ {
199
+ if (!cellValue || cellValue.length === 0) {
200
+ return _this.renderEmpty();
201
+ }
202
+
203
+ var options = column.data ? column.data.options : [];
204
+ return /*#__PURE__*/React.createElement("div", {
205
+ className: "form-control d-flex align-items-center w-100 h-auto"
206
+ }, /*#__PURE__*/React.createElement(MultipleSelectFormatter, {
207
+ value: cellValue,
208
+ options: options,
209
+ containerClassName: containerClassName
210
+ }));
211
+ }
212
+
213
+ case CellType.SINGLE_SELECT:
214
+ {
215
+ var _options = column.data ? column.data.options : [];
216
+
217
+ return /*#__PURE__*/React.createElement("div", {
218
+ className: "form-control d-flex align-items-center w-100"
219
+ }, /*#__PURE__*/React.createElement(SingleSelectFormatter, {
220
+ value: cellValue,
221
+ options: _options,
222
+ containerClassName: containerClassName
223
+ }));
224
+ }
225
+
226
+ case CellType.FILE:
227
+ {
228
+ return /*#__PURE__*/React.createElement(RowExpandFileFormatter, {
229
+ value: cellValue,
230
+ column: column,
231
+ downloadFile: _this.props.downloadFile,
232
+ deleteFile: _this.props.deleteFile
233
+ });
234
+ }
235
+
236
+ case CellType.IMAGE:
237
+ {
238
+ return /*#__PURE__*/React.createElement(RowExpandImageFormatter, {
239
+ value: cellValue,
240
+ column: column,
241
+ downloadImage: _this.props.downloadImage,
242
+ deleteFile: _this.props.deleteFile,
243
+ onRotateImage: _this.props.onRotateImage
244
+ });
245
+ }
246
+
247
+ case CellType.CHECKBOX:
248
+ {
249
+ return /*#__PURE__*/React.createElement("div", {
250
+ className: "checkbox-formatter-container"
251
+ }, /*#__PURE__*/React.createElement(CheckboxFormatter, {
252
+ value: cellValue
253
+ }));
254
+ }
255
+
256
+ case CellType.CREATOR:
257
+ {
258
+ return /*#__PURE__*/React.createElement(CreatorFormatter, {
259
+ collaborators: collaborators,
260
+ value: cellValue,
261
+ containerClassName: containerClassName
262
+ });
263
+ }
264
+
265
+ case CellType.LAST_MODIFIER:
266
+ {
267
+ return /*#__PURE__*/React.createElement(LastModifierFormatter, {
268
+ collaborators: collaborators,
269
+ value: cellValue,
270
+ containerClassName: containerClassName
271
+ });
272
+ }
273
+
274
+ case CellType.FORMULA:
275
+ case CellType.LINK_FORMULA:
276
+ {
277
+ if (!cellValue && cellValue !== 0 && cellValue !== false) {
278
+ return _this.renderEmpty();
279
+ }
280
+
281
+ return /*#__PURE__*/React.createElement(FormulaFormatter, {
282
+ value: cellValue,
283
+ column: column,
284
+ collaborators: collaborators,
285
+ containerClassName: containerClassName
286
+ });
287
+ }
288
+
289
+ case CellType.LINK:
290
+ {
291
+ // handle link column do not have column.data.display_column
292
+ var _column2 = column,
293
+ data = _column2.data;
294
+ var display_column_key = data.display_column_key,
295
+ array_type = data.array_type,
296
+ array_data = data.array_data;
297
+
298
+ if (!data.display_column) {
299
+ column = _objectSpread(_objectSpread({}, column), {}, {
300
+ data: _objectSpread(_objectSpread({}, data), {}, {
301
+ display_column: {
302
+ key: display_column_key || '0000',
303
+ type: array_type || CellType.TEXT,
304
+ data: array_data || null
305
+ }
306
+ })
307
+ });
308
+ }
309
+
310
+ if (!Array.isArray(cellValue) || cellValue.length === 0) {
311
+ return _this.renderEmpty();
312
+ }
313
+
314
+ return /*#__PURE__*/React.createElement(RowExpandLinkFormatter, {
315
+ value: cellValue,
316
+ column: column,
317
+ collaborators: collaborators,
318
+ containerClassName: containerClassName,
319
+ renderEmpty: _this.renderEmpty
320
+ });
321
+ }
322
+
323
+ case CellType.AUTO_NUMBER:
324
+ {
325
+ return /*#__PURE__*/React.createElement(AutoNumberFormatter, {
326
+ value: cellValue,
327
+ containerClassName: containerClassName
328
+ });
329
+ }
330
+
331
+ case CellType.URL:
332
+ {
333
+ return /*#__PURE__*/React.createElement("div", {
334
+ className: "form-control d-flex align-items-center w-100"
335
+ }, /*#__PURE__*/React.createElement(UrlFormatter, {
336
+ value: cellValue,
337
+ containerClassName: containerClassName
338
+ }));
339
+ }
340
+
341
+ case CellType.EMAIL:
342
+ {
343
+ return /*#__PURE__*/React.createElement("div", {
344
+ className: "form-control d-flex align-items-center w-100"
345
+ }, /*#__PURE__*/React.createElement(EmailFormatter, {
346
+ value: cellValue,
347
+ containerClassName: containerClassName
348
+ }));
349
+ }
350
+
351
+ case CellType.DURATION:
352
+ {
353
+ if (!cellValue && cellValue !== 0) {
354
+ return _this.renderEmpty();
355
+ }
356
+
357
+ return /*#__PURE__*/React.createElement("div", {
358
+ className: "form-control d-flex align-items-center w-100"
359
+ }, /*#__PURE__*/React.createElement(DurationFormatter, {
360
+ value: cellValue,
361
+ format: column.data.duration_format,
362
+ containerClassName: containerClassName
363
+ }));
364
+ }
365
+
366
+ case CellType.RATE:
367
+ {
368
+ return /*#__PURE__*/React.createElement("div", {
369
+ className: "form-control d-flex align-items-center w-100"
370
+ }, /*#__PURE__*/React.createElement(RateFormatter, {
371
+ value: cellValue,
372
+ data: column.data,
373
+ containerClassName: containerClassName
374
+ }));
375
+ }
376
+
377
+ case CellType.BUTTON:
378
+ {
379
+ return /*#__PURE__*/React.createElement(ButtonFormatter, {
380
+ data: column.data,
381
+ containerClassName: containerClassName,
382
+ onClickButton: _this.props.onClickButton
383
+ });
384
+ }
385
+
386
+ case CellType.DIGITAL_SIGN:
387
+ {
388
+ return /*#__PURE__*/React.createElement(DigitalSignFormatter, {
389
+ value: cellValue,
390
+ containerClassName: containerClassName,
391
+ config: _this.props.config
392
+ });
393
+ }
394
+
395
+ default:
396
+ return null;
397
+ }
398
+ };
399
+
400
+ _this.state = {
401
+ collaborators: _this.getCollaborator()
402
+ };
403
+ return _this;
404
+ }
405
+
406
+ _createClass(EditorFormatter, [{
407
+ key: "componentDidMount",
408
+ value: function componentDidMount() {
409
+ this.calculateCollaboratorData(this.props);
410
+
411
+ if (this.props.eventBus) {
412
+ this.listenCollaboratorsUpdated = this.props.eventBus.subscribe('collaborators-updated', this.updateCollaborators);
413
+ }
414
+ }
415
+ }, {
416
+ key: "UNSAFE_componentWillReceiveProps",
417
+ value: function UNSAFE_componentWillReceiveProps(nextProps) {
418
+ this.calculateCollaboratorData(nextProps);
419
+ }
420
+ }, {
421
+ key: "componentWillUnmount",
422
+ value: function componentWillUnmount() {
423
+ this.listenCollaboratorsUpdated();
424
+ }
425
+ }, {
426
+ key: "render",
427
+ value: function render() {
428
+ var className = this.props.className;
429
+ return /*#__PURE__*/React.createElement("div", {
430
+ className: classnames('dtable-ui dtable-row-expand-formatter', _defineProperty({}, className, className))
431
+ }, this.renderFormatter());
432
+ }
433
+ }]);
434
+
435
+ return EditorFormatter;
436
+ }(React.Component);
437
+
438
+ EditorFormatter.defaultProps = {
439
+ className: ''
440
+ };
441
+ export { EditorFormatter as default };
@@ -0,0 +1,79 @@
1
+ @import url('../css/cell-formatter.css');
2
+
3
+ .dtable-ui.row-expand-image-formatter {
4
+ display: flex;
5
+ flex-wrap: wrap;
6
+ justify-content: flex-start;
7
+ width: 550px;
8
+ }
9
+
10
+ .dtable-ui.row-expand-image-formatter .row-expand-item-image {
11
+ height: 100px;
12
+ width: 100px;
13
+ border: 2px solid #ededed;
14
+ border-radius: 4px;
15
+ cursor: pointer;
16
+ display: flex;
17
+ align-items: center;
18
+ justify-content: center;
19
+ margin: 5px;
20
+ position: relative;
21
+ }
22
+
23
+ .dtable-ui.row-expand-image-formatter .row-expand-item-image:nth-child(5n + 1) {
24
+ margin-left: 0;
25
+ }
26
+
27
+ .dtable-ui.row-expand-image-formatter .row-expand-item-image:hover {
28
+ border-color: #c9c9c9;
29
+ }
30
+
31
+ .dtable-ui.row-expand-image-formatter .row-expand-item-image .dtable-image-icons-choice {
32
+ height: 20px;
33
+ width: 100%;
34
+ top: 0;
35
+ position: absolute;
36
+ color: #fff;
37
+ display: none;
38
+ padding: 0 3px;
39
+ justify-content: flex-end;
40
+ align-items: center;
41
+ }
42
+
43
+ .dtable-ui.row-expand-image-formatter .row-expand-item-image:hover .dtable-image-icons-choice {
44
+ display: flex;
45
+ }
46
+
47
+ .dtable-ui.row-expand-image-formatter .row-expand-item-image .dtable-image-icons-choice .image-icon {
48
+ height: 16px;
49
+ width: 16px;
50
+ border-radius: 50%;
51
+ background: rgba(0, 0, 0, 0.5);
52
+ color: #fff;
53
+ cursor: pointer;
54
+ display: flex;
55
+ justify-content: center;
56
+ align-items: center;
57
+ }
58
+
59
+ .dtable-ui.row-expand-image-formatter .row-expand-item-image .dtable-image-icons-choice .image-icon:nth-child(2) {
60
+ margin-left: 5px;
61
+ }
62
+
63
+ .dtable-ui.row-expand-image-formatter .row-expand-item-image .dtable-image-icons-choice .image-icon .dtable-font {
64
+ font-size: 12px;
65
+ transform: scale(.7);
66
+ }
67
+
68
+ .dtable-ui.row-expand-image-formatter .row-expand-item-image img {
69
+ display: block;
70
+ max-width: 96px;
71
+ max-height: 96px;
72
+ border-radius: 4px;
73
+ }
74
+
75
+ .tooltip-inner {
76
+ font-weight: lighter;
77
+ text-align: justify;
78
+ background-color: #303133;
79
+ }
@@ -0,0 +1,127 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
4
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
+ import React, { Fragment } from 'react';
6
+ import classnames from 'classnames';
7
+ import RowExpandImageImageFormatter from './row-expand-image-item-formatter';
8
+ import ImagePreviewerLightbox from '../ImagePreviewerLightbox';
9
+ import './index.css';
10
+
11
+ var RowExpandImageFormatter = /*#__PURE__*/function (_React$Component) {
12
+ _inherits(RowExpandImageFormatter, _React$Component);
13
+
14
+ var _super = _createSuper(RowExpandImageFormatter);
15
+
16
+ function RowExpandImageFormatter(props) {
17
+ var _this;
18
+
19
+ _classCallCheck(this, RowExpandImageFormatter);
20
+
21
+ _this = _super.call(this, props);
22
+
23
+ _this.onImageClick = function (index) {
24
+ _this.setState({
25
+ isPreviewImage: true,
26
+ previewImageIndex: index
27
+ });
28
+ };
29
+
30
+ _this.closeImagePopup = function () {
31
+ if (_this.props.onCloseCallback) {
32
+ _this.props.onCloseCallback();
33
+ }
34
+
35
+ _this.setState({
36
+ isPreviewImage: false,
37
+ previewImageIndex: -1
38
+ });
39
+ };
40
+
41
+ _this.movePrev = function () {
42
+ var images = _this.props.value;
43
+
44
+ _this.setState(function (prevState) {
45
+ return {
46
+ previewImageIndex: (prevState.previewImageIndex + images.length - 1) % images.length
47
+ };
48
+ });
49
+ };
50
+
51
+ _this.moveNext = function () {
52
+ var images = _this.props.value;
53
+
54
+ _this.setState(function (prevState) {
55
+ return {
56
+ previewImageIndex: (prevState.previewImageIndex + 1) % images.length
57
+ };
58
+ });
59
+ };
60
+
61
+ _this.state = {
62
+ isPreviewImage: false,
63
+ previewImageIndex: -1
64
+ };
65
+ return _this;
66
+ }
67
+
68
+ _createClass(RowExpandImageFormatter, [{
69
+ key: "render",
70
+ value: function render() {
71
+ var _this2 = this;
72
+
73
+ var _this$props = this.props,
74
+ value = _this$props.value,
75
+ server = _this$props.server,
76
+ containerClassName = _this$props.containerClassName,
77
+ readOnly = _this$props.readOnly,
78
+ column = _this$props.column,
79
+ downloadImage = _this$props.downloadImage;
80
+ var _this$state = this.state,
81
+ isPreviewImage = _this$state.isPreviewImage,
82
+ previewImageIndex = _this$state.previewImageIndex;
83
+
84
+ if (!Array.isArray(value) || value.length === 0) {
85
+ return null;
86
+ }
87
+
88
+ return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
89
+ className: classnames('dtable-ui cell-formatter-container row-expand-image-formatter', containerClassName)
90
+ }, value.map(function (item, index) {
91
+ return /*#__PURE__*/React.createElement(RowExpandImageImageFormatter, {
92
+ url: item,
93
+ key: index,
94
+ index: index,
95
+ column: column,
96
+ downloadFile: downloadImage,
97
+ deleteFile: _this2.props.deleteFile,
98
+ readOnly: readOnly,
99
+ onImageClick: _this2.onImageClick
100
+ });
101
+ })), isPreviewImage && /*#__PURE__*/React.createElement(ImagePreviewerLightbox, {
102
+ imageItems: value,
103
+ imageIndex: previewImageIndex,
104
+ closeImagePopup: this.closeImagePopup,
105
+ moveToPrevImage: this.movePrev,
106
+ moveToNextImage: this.moveNext,
107
+ deleteImage: this.props.deleteFile,
108
+ downloadImage: downloadImage,
109
+ onRotateImage: this.props.rotateImage,
110
+ readOnly: readOnly,
111
+ server: server,
112
+ moveToPrevRowImage: this.props.moveToPrevRowImage,
113
+ moveToNextRowImage: this.props.moveToNextRowImage
114
+ }));
115
+ }
116
+ }]);
117
+
118
+ return RowExpandImageFormatter;
119
+ }(React.Component);
120
+
121
+ RowExpandImageFormatter.defaultProps = {
122
+ readOnly: true,
123
+ value: [],
124
+ server: '',
125
+ containerClassName: ''
126
+ };
127
+ export { RowExpandImageFormatter as default };