dtable-ui-component 0.3.2 → 0.3.4
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/assets/dtable-font/dtable-font.eot +0 -0
- package/assets/dtable-font/dtable-font.svg +319 -11
- package/assets/dtable-font/dtable-font.ttf +0 -0
- package/assets/dtable-font/dtable-font.woff +0 -0
- package/assets/dtable-font/dtable-font.woff2 +0 -0
- package/assets/dtable-font.css +630 -14
- package/lib/ButtonFormatter/index.js +2 -6
- package/lib/DTableCustomizeCollaboratorSelect/index.css +1 -1
- package/lib/FileFormatter/index.js +3 -2
- package/lib/FileItemFormatter/index.js +1 -1
- package/lib/ImageFormatter/images-lazy-load.js +11 -15
- package/lib/RowExpandFileFormatter/index.css +72 -0
- package/lib/RowExpandFileFormatter/index.js +59 -0
- package/lib/RowExpandFileFormatter/row-expand-file-item-formatter.js +125 -0
- package/lib/RowExpandFormatter/index.css +73 -0
- package/lib/RowExpandFormatter/index.js +439 -0
- package/lib/RowExpandImageFormatter/index.css +79 -0
- package/lib/RowExpandImageFormatter/index.js +127 -0
- package/lib/RowExpandImageFormatter/row-expand-image-item-formatter.js +128 -0
- package/lib/RowExpandImageFormatter/utils.js +7 -0
- package/lib/RowExpandLinkFormatter/collaborator-item-formatter.js +164 -0
- package/lib/RowExpandLinkFormatter/column-data-constants.js +20 -0
- package/lib/RowExpandLinkFormatter/date-utils.js +127 -0
- package/lib/RowExpandLinkFormatter/formula-constants.js +9 -0
- package/lib/RowExpandLinkFormatter/index.css +25 -0
- package/lib/RowExpandLinkFormatter/index.js +170 -0
- package/lib/RowExpandLinkFormatter/number-precision.js +116 -0
- package/lib/RowExpandLinkFormatter/utils.js +58 -0
- package/lib/RowExpandLinkFormatter/value-display-utils.js +401 -0
- package/lib/common/delete-tip.css +16 -0
- package/lib/common/delete-tip.js +84 -0
- package/lib/common/modal-portal.js +44 -0
- package/lib/constants/cell-types.js +5 -1
- package/lib/data/dtable-value.js +2731 -0
- package/lib/index.js +7 -1
- package/lib/lang/index.js +1 -1
- package/lib/locals/en.js +17 -13
- package/lib/locals/zh-CN.js +16 -12
- package/package.json +3 -1
|
@@ -0,0 +1,439 @@
|
|
|
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 } 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) {
|
|
278
|
+
return _this.renderEmpty();
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return /*#__PURE__*/React.createElement(TextFormatter, {
|
|
282
|
+
value: cellValue,
|
|
283
|
+
containerClassName: containerClassName
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
case CellType.LINK:
|
|
288
|
+
{
|
|
289
|
+
// handle link column do not have column.data.display_column
|
|
290
|
+
var _column2 = column,
|
|
291
|
+
data = _column2.data;
|
|
292
|
+
var display_column_key = data.display_column_key,
|
|
293
|
+
array_type = data.array_type,
|
|
294
|
+
array_data = data.array_data;
|
|
295
|
+
|
|
296
|
+
if (!data.display_column) {
|
|
297
|
+
column = _objectSpread(_objectSpread({}, column), {}, {
|
|
298
|
+
data: _objectSpread(_objectSpread({}, data), {}, {
|
|
299
|
+
display_column: {
|
|
300
|
+
key: display_column_key || '0000',
|
|
301
|
+
type: array_type || CellType.TEXT,
|
|
302
|
+
data: array_data || null
|
|
303
|
+
}
|
|
304
|
+
})
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
if (!Array.isArray(cellValue) || cellValue.length === 0) {
|
|
309
|
+
return _this.renderEmpty();
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
return /*#__PURE__*/React.createElement(RowExpandLinkFormatter, {
|
|
313
|
+
value: cellValue,
|
|
314
|
+
column: column,
|
|
315
|
+
collaborators: collaborators,
|
|
316
|
+
containerClassName: containerClassName,
|
|
317
|
+
renderEmpty: _this.renderEmpty
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
case CellType.AUTO_NUMBER:
|
|
322
|
+
{
|
|
323
|
+
return /*#__PURE__*/React.createElement(AutoNumberFormatter, {
|
|
324
|
+
value: cellValue,
|
|
325
|
+
containerClassName: containerClassName
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
case CellType.URL:
|
|
330
|
+
{
|
|
331
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
332
|
+
className: "form-control d-flex align-items-center w-100"
|
|
333
|
+
}, /*#__PURE__*/React.createElement(UrlFormatter, {
|
|
334
|
+
value: cellValue,
|
|
335
|
+
containerClassName: containerClassName
|
|
336
|
+
}));
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
case CellType.EMAIL:
|
|
340
|
+
{
|
|
341
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
342
|
+
className: "form-control d-flex align-items-center w-100"
|
|
343
|
+
}, /*#__PURE__*/React.createElement(EmailFormatter, {
|
|
344
|
+
value: cellValue,
|
|
345
|
+
containerClassName: containerClassName
|
|
346
|
+
}));
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
case CellType.DURATION:
|
|
350
|
+
{
|
|
351
|
+
if (!cellValue && cellValue !== 0) {
|
|
352
|
+
return _this.renderEmpty();
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
356
|
+
className: "form-control d-flex align-items-center w-100"
|
|
357
|
+
}, /*#__PURE__*/React.createElement(DurationFormatter, {
|
|
358
|
+
value: cellValue,
|
|
359
|
+
format: column.data.duration_format,
|
|
360
|
+
containerClassName: containerClassName
|
|
361
|
+
}));
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
case CellType.RATE:
|
|
365
|
+
{
|
|
366
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
367
|
+
className: "form-control d-flex align-items-center w-100"
|
|
368
|
+
}, /*#__PURE__*/React.createElement(RateFormatter, {
|
|
369
|
+
value: cellValue,
|
|
370
|
+
data: column.data,
|
|
371
|
+
containerClassName: containerClassName
|
|
372
|
+
}));
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
case CellType.BUTTON:
|
|
376
|
+
{
|
|
377
|
+
return /*#__PURE__*/React.createElement(ButtonFormatter, {
|
|
378
|
+
data: column.data,
|
|
379
|
+
containerClassName: containerClassName,
|
|
380
|
+
onClickButton: _this.props.onClickButton
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
case CellType.DIGITAL_SIGN:
|
|
385
|
+
{
|
|
386
|
+
return /*#__PURE__*/React.createElement(DigitalSignFormatter, {
|
|
387
|
+
value: cellValue,
|
|
388
|
+
containerClassName: containerClassName,
|
|
389
|
+
config: _this.props.config
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
default:
|
|
394
|
+
return null;
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
_this.state = {
|
|
399
|
+
collaborators: _this.getCollaborator()
|
|
400
|
+
};
|
|
401
|
+
return _this;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
_createClass(EditorFormatter, [{
|
|
405
|
+
key: "componentDidMount",
|
|
406
|
+
value: function componentDidMount() {
|
|
407
|
+
this.calculateCollaboratorData(this.props);
|
|
408
|
+
|
|
409
|
+
if (this.props.eventBus) {
|
|
410
|
+
this.listenCollaboratorsUpdated = this.props.eventBus.subscribe('collaborators-updated', this.updateCollaborators);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}, {
|
|
414
|
+
key: "componentWillReceiveProps",
|
|
415
|
+
value: function componentWillReceiveProps(nextProps) {
|
|
416
|
+
this.calculateCollaboratorData(nextProps);
|
|
417
|
+
}
|
|
418
|
+
}, {
|
|
419
|
+
key: "componentWillUnmount",
|
|
420
|
+
value: function componentWillUnmount() {
|
|
421
|
+
this.listenCollaboratorsUpdated();
|
|
422
|
+
}
|
|
423
|
+
}, {
|
|
424
|
+
key: "render",
|
|
425
|
+
value: function render() {
|
|
426
|
+
var className = this.props.className;
|
|
427
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
428
|
+
className: classnames('dtable-ui dtable-row-expand-formatter', _defineProperty({}, className, className))
|
|
429
|
+
}, this.renderFormatter());
|
|
430
|
+
}
|
|
431
|
+
}]);
|
|
432
|
+
|
|
433
|
+
return EditorFormatter;
|
|
434
|
+
}(React.Component);
|
|
435
|
+
|
|
436
|
+
EditorFormatter.defaultProps = {
|
|
437
|
+
className: ''
|
|
438
|
+
};
|
|
439
|
+
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 };
|