dtable-ui-component 0.3.2-alpha4 → 0.3.2-alpha5
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/lib/ButtonFormatter/index.js +2 -16
- package/lib/RowExpandFormatter/index.css +7 -0
- package/lib/{editor-formatter.js → RowExpandFormatter/index.js} +143 -112
- 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 +26 -0
- package/lib/RowExpandLinkFormatter/index.js +174 -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.js +3 -2
- package/lib/common/modal-portal.js +44 -0
- package/lib/data/dtable-value.js +7 -0
- package/lib/index.js +4 -1
- package/lib/locals/en.js +1 -0
- package/lib/locals/zh-CN.js +1 -0
- package/package.json +1 -1
|
@@ -23,25 +23,11 @@ var ButtonFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
23
23
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
24
24
|
|
|
25
25
|
_this.handleClick = function () {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
url_address = _this$props$data.url_address;
|
|
29
|
-
|
|
30
|
-
if (button_type === 'open_url' && url_address) {
|
|
31
|
-
_this.openUrlLink(url_address);
|
|
26
|
+
if (_this.props.onClickButton) {
|
|
27
|
+
_this.props.onClickButton(_this.props.data);
|
|
32
28
|
}
|
|
33
29
|
};
|
|
34
30
|
|
|
35
|
-
_this.openUrlLink = function (url) {
|
|
36
|
-
var a = document.createElement('a');
|
|
37
|
-
document.body.appendChild(a);
|
|
38
|
-
a.href = url;
|
|
39
|
-
a.target = '_blank';
|
|
40
|
-
a.rel = 'noopener noreferrer';
|
|
41
|
-
a.click();
|
|
42
|
-
document.body.removeChild(a);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
31
|
return _this;
|
|
46
32
|
}
|
|
47
33
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
1
2
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
3
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
4
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
@@ -8,51 +9,86 @@ var _emptyTypeMap;
|
|
|
8
9
|
|
|
9
10
|
import React, { Fragment } from 'react';
|
|
10
11
|
import { CellType } from 'dtable-store';
|
|
11
|
-
import { TextFormatter, NumberFormatter, CheckboxFormatter, DateFormatter, SingleSelectFormatter, MultipleSelectFormatter, CollaboratorFormatter, SimpleLongTextFormatter, GeolocationFormatter,
|
|
12
|
-
|
|
13
|
-
} from './index';
|
|
14
|
-
import { COLLABORATORS } from './data/dtable-value';
|
|
12
|
+
import { TextFormatter, NumberFormatter, CheckboxFormatter, DateFormatter, SingleSelectFormatter, MultipleSelectFormatter, CollaboratorFormatter, SimpleLongTextFormatter, GeolocationFormatter, CTimeFormatter, CreatorFormatter, LastModifierFormatter, MTimeFormatter, AutoNumberFormatter, UrlFormatter, EmailFormatter, DurationFormatter, RateFormatter, ButtonFormatter, RowExpandImageFormatter, RowExpandFileFormatter, RowExpandLinkFormatter } from '../index';
|
|
13
|
+
import './index.css';
|
|
15
14
|
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.DURATION, true), _defineProperty(_emptyTypeMap, CellType.IMAGE, true), _defineProperty(_emptyTypeMap, CellType.FILE, true), _emptyTypeMap);
|
|
16
15
|
|
|
17
|
-
var noop = function noop() {};
|
|
18
|
-
|
|
19
16
|
var EditorFormatter = /*#__PURE__*/function (_React$Component) {
|
|
20
17
|
_inherits(EditorFormatter, _React$Component);
|
|
21
18
|
|
|
22
19
|
var _super = _createSuper(EditorFormatter);
|
|
23
20
|
|
|
24
|
-
function EditorFormatter(
|
|
21
|
+
function EditorFormatter(_props) {
|
|
25
22
|
var _this;
|
|
26
23
|
|
|
27
24
|
_classCallCheck(this, EditorFormatter);
|
|
28
25
|
|
|
29
|
-
_this = _super.call(this,
|
|
26
|
+
_this = _super.call(this, _props);
|
|
30
27
|
|
|
31
|
-
_this.
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
_this.updateCollaborators = function () {
|
|
29
|
+
_this.setState({
|
|
30
|
+
collaborators: _this.getCollaborator()
|
|
34
31
|
});
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
_this.calculateCollaboratorData = function (props) {
|
|
35
|
+
var row = props.row,
|
|
36
|
+
column = props.column;
|
|
37
|
+
|
|
38
|
+
if (column.type === CellType.CREATOR || column.type === CellType.LAST_MODIFIER) {
|
|
39
|
+
var email = row[column.name];
|
|
40
|
+
|
|
41
|
+
_this.loadCollaborator(email);
|
|
42
|
+
} else if (column.type === CellType.COLLABORATOR) {
|
|
43
|
+
var emails = row[column.name];
|
|
44
|
+
|
|
45
|
+
if (Array.isArray(emails)) {
|
|
46
|
+
emails.forEach(function (email) {
|
|
47
|
+
_this.loadCollaborator(email);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
_this.getCollaborator = function () {
|
|
54
|
+
var _this$props = _this.props,
|
|
55
|
+
context = _this$props.context,
|
|
56
|
+
collaborators = _this$props.collaborators;
|
|
35
57
|
|
|
36
|
-
if (
|
|
37
|
-
|
|
58
|
+
if (context && context.getCollaboratorsFromCache) {
|
|
59
|
+
return context.getCollaboratorsFromCache();
|
|
38
60
|
}
|
|
39
61
|
|
|
40
|
-
return
|
|
62
|
+
return collaborators || [];
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
_this.loadCollaborator = function (email) {
|
|
66
|
+
var context = _this.props.context;
|
|
67
|
+
|
|
68
|
+
if (context && context.loadCollaborator) {
|
|
69
|
+
context.loadCollaborator(email);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
_this.renderEmpty = function () {
|
|
74
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
75
|
+
className: "row-cell-empty"
|
|
76
|
+
});
|
|
41
77
|
};
|
|
42
78
|
|
|
43
79
|
_this.renderFormatter = function () {
|
|
44
|
-
var _this$
|
|
45
|
-
column = _this$
|
|
46
|
-
row = _this$
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
80
|
+
var _this$props2 = _this.props,
|
|
81
|
+
column = _this$props2.column,
|
|
82
|
+
row = _this$props2.row,
|
|
83
|
+
className = _this$props2.className;
|
|
84
|
+
var _column = column,
|
|
85
|
+
columnType = _column.type;
|
|
50
86
|
var collaborators = _this.state.collaborators;
|
|
51
87
|
var containerClassName = "dtable-".concat(columnType, "-formatter ").concat(className || '');
|
|
52
|
-
var cellValue = row[column.key];
|
|
88
|
+
var cellValue = row[column.key] || row[column.name];
|
|
53
89
|
|
|
54
90
|
if (!cellValue && emptyTypeMap[columnType]) {
|
|
55
|
-
return _this.
|
|
91
|
+
return _this.renderEmpty();
|
|
56
92
|
}
|
|
57
93
|
|
|
58
94
|
switch (columnType) {
|
|
@@ -67,7 +103,7 @@ var EditorFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
67
103
|
case CellType.COLLABORATOR:
|
|
68
104
|
{
|
|
69
105
|
if (!cellValue || cellValue.length === 0) {
|
|
70
|
-
return _this.
|
|
106
|
+
return _this.renderEmpty();
|
|
71
107
|
}
|
|
72
108
|
|
|
73
109
|
var collaboratorFormatter = /*#__PURE__*/React.createElement(CollaboratorFormatter, {
|
|
@@ -80,124 +116,87 @@ var EditorFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
80
116
|
|
|
81
117
|
case CellType.LONG_TEXT:
|
|
82
118
|
{
|
|
83
|
-
|
|
119
|
+
return /*#__PURE__*/React.createElement(SimpleLongTextFormatter, {
|
|
84
120
|
value: cellValue,
|
|
85
121
|
containerClassName: containerClassName
|
|
86
122
|
});
|
|
87
|
-
|
|
88
|
-
if (!cellValue) {
|
|
89
|
-
longTextFormatter = _this.renderEmptyFormatter();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return longTextFormatter;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
case CellType.IMAGE:
|
|
96
|
-
{
|
|
97
|
-
var imageFormatter = /*#__PURE__*/React.createElement(ImageFormatter, {
|
|
98
|
-
value: cellValue
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
if (!cellValue || cellValue.length === 0) {
|
|
102
|
-
imageFormatter = _this.renderEmptyFormatter();
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return imageFormatter;
|
|
106
123
|
}
|
|
107
124
|
|
|
108
125
|
case CellType.GEOLOCATION:
|
|
109
126
|
{
|
|
110
|
-
|
|
127
|
+
return /*#__PURE__*/React.createElement(GeolocationFormatter, {
|
|
111
128
|
value: cellValue,
|
|
112
129
|
data: column.data,
|
|
113
130
|
containerClassName: containerClassName
|
|
114
131
|
});
|
|
115
|
-
|
|
116
|
-
if (!cellValue) {
|
|
117
|
-
geolocationFormatter = _this.renderEmptyFormatter();
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
return geolocationFormatter;
|
|
121
132
|
}
|
|
122
133
|
|
|
123
134
|
case CellType.NUMBER:
|
|
124
135
|
{
|
|
125
|
-
|
|
136
|
+
if (!cellValue && cellValue !== 0) {
|
|
137
|
+
return _this.renderEmpty();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return /*#__PURE__*/React.createElement(NumberFormatter, {
|
|
126
141
|
value: cellValue,
|
|
127
142
|
data: column.data,
|
|
128
143
|
containerClassName: containerClassName
|
|
129
144
|
});
|
|
130
|
-
|
|
131
|
-
if (!cellValue) {
|
|
132
|
-
numberFormatter = _this.renderEmptyFormatter();
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
return numberFormatter;
|
|
136
145
|
}
|
|
137
146
|
|
|
138
147
|
case CellType.DATE:
|
|
139
148
|
{
|
|
140
|
-
|
|
149
|
+
return /*#__PURE__*/React.createElement(DateFormatter, {
|
|
141
150
|
value: cellValue,
|
|
142
151
|
format: column.data.format,
|
|
143
152
|
containerClassName: containerClassName
|
|
144
153
|
});
|
|
145
|
-
|
|
146
|
-
if (!cellValue) {
|
|
147
|
-
dateFormatter = _this.renderEmptyFormatter();
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return dateFormatter;
|
|
151
154
|
}
|
|
152
155
|
|
|
153
156
|
case CellType.MULTIPLE_SELECT:
|
|
154
157
|
{
|
|
158
|
+
if (!cellValue || cellValue.length === 0) {
|
|
159
|
+
return _this.renderEmpty();
|
|
160
|
+
}
|
|
161
|
+
|
|
155
162
|
var options = column.data ? column.data.options : [];
|
|
156
|
-
|
|
163
|
+
return /*#__PURE__*/React.createElement(MultipleSelectFormatter, {
|
|
157
164
|
value: cellValue,
|
|
158
165
|
options: options,
|
|
159
166
|
containerClassName: containerClassName
|
|
160
167
|
});
|
|
161
|
-
|
|
162
|
-
if (!cellValue || cellValue.length === 0) {
|
|
163
|
-
multipleSelectFormatter = _this.renderEmptyFormatter();
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
return multipleSelectFormatter;
|
|
167
168
|
}
|
|
168
169
|
|
|
169
170
|
case CellType.SINGLE_SELECT:
|
|
170
171
|
{
|
|
171
172
|
var _options = column.data ? column.data.options : [];
|
|
172
173
|
|
|
173
|
-
|
|
174
|
+
return /*#__PURE__*/React.createElement(SingleSelectFormatter, {
|
|
174
175
|
value: cellValue,
|
|
175
176
|
options: _options,
|
|
176
177
|
containerClassName: containerClassName
|
|
177
178
|
});
|
|
178
|
-
|
|
179
|
-
if (!cellValue) {
|
|
180
|
-
singleSelectFormatter = _this.renderEmptyFormatter();
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return singleSelectFormatter;
|
|
184
179
|
}
|
|
185
180
|
|
|
186
181
|
case CellType.FILE:
|
|
187
182
|
{
|
|
188
|
-
|
|
183
|
+
return /*#__PURE__*/React.createElement(RowExpandFileFormatter, {
|
|
189
184
|
value: cellValue,
|
|
190
185
|
column: column,
|
|
191
|
-
downloadFile:
|
|
192
|
-
deleteFile:
|
|
193
|
-
readOnly: false
|
|
186
|
+
downloadFile: _this.props.downloadFile,
|
|
187
|
+
deleteFile: _this.props.deleteFile
|
|
194
188
|
});
|
|
189
|
+
}
|
|
195
190
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
191
|
+
case CellType.IMAGE:
|
|
192
|
+
{
|
|
193
|
+
return /*#__PURE__*/React.createElement(RowExpandImageFormatter, {
|
|
194
|
+
value: cellValue,
|
|
195
|
+
column: column,
|
|
196
|
+
downloadFile: _this.props.downloadFile,
|
|
197
|
+
deleteFile: _this.props.deleteFile,
|
|
198
|
+
onRotateImage: _this.props.onRotateImage
|
|
199
|
+
});
|
|
201
200
|
}
|
|
202
201
|
|
|
203
202
|
case CellType.CHECKBOX:
|
|
@@ -215,7 +214,7 @@ var EditorFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
215
214
|
});
|
|
216
215
|
|
|
217
216
|
if (!row._ctime) {
|
|
218
|
-
cTimeFormatter = _this.
|
|
217
|
+
cTimeFormatter = _this.renderEmpty();
|
|
219
218
|
}
|
|
220
219
|
|
|
221
220
|
return cTimeFormatter;
|
|
@@ -229,7 +228,7 @@ var EditorFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
229
228
|
});
|
|
230
229
|
|
|
231
230
|
if (!row._mtime) {
|
|
232
|
-
mTimeFormatter = _this.
|
|
231
|
+
mTimeFormatter = _this.renderEmpty();
|
|
233
232
|
}
|
|
234
233
|
|
|
235
234
|
return mTimeFormatter;
|
|
@@ -237,7 +236,7 @@ var EditorFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
237
236
|
|
|
238
237
|
case CellType.CREATOR:
|
|
239
238
|
{
|
|
240
|
-
if (!cellValue) return _this.
|
|
239
|
+
if (!cellValue) return _this.renderEmpty();
|
|
241
240
|
var creatorFormatter = /*#__PURE__*/React.createElement(CreatorFormatter, {
|
|
242
241
|
collaborators: collaborators,
|
|
243
242
|
value: cellValue,
|
|
@@ -248,7 +247,7 @@ var EditorFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
248
247
|
|
|
249
248
|
case CellType.LAST_MODIFIER:
|
|
250
249
|
{
|
|
251
|
-
if (!cellValue) return _this.
|
|
250
|
+
if (!cellValue) return _this.renderEmpty();
|
|
252
251
|
var lastModifierFormatter = /*#__PURE__*/React.createElement(LastModifierFormatter, {
|
|
253
252
|
collaborators: collaborators,
|
|
254
253
|
value: cellValue,
|
|
@@ -266,7 +265,7 @@ var EditorFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
266
265
|
});
|
|
267
266
|
|
|
268
267
|
if (!cellValue) {
|
|
269
|
-
textFormatter = _this.
|
|
268
|
+
textFormatter = _this.renderEmpty();
|
|
270
269
|
}
|
|
271
270
|
|
|
272
271
|
return textFormatter;
|
|
@@ -274,16 +273,36 @@ var EditorFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
274
273
|
|
|
275
274
|
case CellType.LINK:
|
|
276
275
|
{
|
|
277
|
-
|
|
278
|
-
|
|
276
|
+
// handle link column do not have column.data.display_column
|
|
277
|
+
var _column2 = column,
|
|
278
|
+
data = _column2.data;
|
|
279
|
+
var display_column_key = data.display_column_key,
|
|
280
|
+
array_type = data.array_type,
|
|
281
|
+
array_data = data.array_data;
|
|
282
|
+
|
|
283
|
+
if (!data.display_column) {
|
|
284
|
+
column = _objectSpread(_objectSpread({}, column), {}, {
|
|
285
|
+
data: _objectSpread(_objectSpread({}, data), {}, {
|
|
286
|
+
display_column: {
|
|
287
|
+
key: display_column_key || '0000',
|
|
288
|
+
type: array_type || CellType.TEXT,
|
|
289
|
+
data: array_data || null
|
|
290
|
+
}
|
|
291
|
+
})
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
if (!Array.isArray(cellValue) || cellValue.length === 0) {
|
|
296
|
+
return _this.renderEmpty();
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
return /*#__PURE__*/React.createElement(RowExpandLinkFormatter, {
|
|
279
300
|
value: cellValue,
|
|
280
301
|
column: column,
|
|
281
302
|
collaborators: collaborators,
|
|
282
|
-
containerClassName:
|
|
283
|
-
|
|
284
|
-
getOptionColors: _this.props.getOptionColors
|
|
285
|
-
getUserCommonInfo: function getUserCommonInfo() {},
|
|
286
|
-
CellType: CellType
|
|
303
|
+
containerClassName: containerClassName,
|
|
304
|
+
renderEmpty: _this.renderEmpty,
|
|
305
|
+
getOptionColors: _this.props.getOptionColors
|
|
287
306
|
});
|
|
288
307
|
}
|
|
289
308
|
|
|
@@ -331,18 +350,11 @@ var EditorFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
331
350
|
|
|
332
351
|
case CellType.BUTTON:
|
|
333
352
|
{
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
containerClassName: containerClassName
|
|
353
|
+
return /*#__PURE__*/React.createElement(ButtonFormatter, {
|
|
354
|
+
data: column.data,
|
|
355
|
+
containerClassName: containerClassName,
|
|
356
|
+
onClickButton: _this.props.onClickButton
|
|
339
357
|
});
|
|
340
|
-
|
|
341
|
-
if (!data.button_name) {
|
|
342
|
-
buttonFormatter = _this.renderEmptyFormatter();
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
return buttonFormatter;
|
|
346
358
|
}
|
|
347
359
|
|
|
348
360
|
default:
|
|
@@ -351,12 +363,31 @@ var EditorFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
351
363
|
};
|
|
352
364
|
|
|
353
365
|
_this.state = {
|
|
354
|
-
collaborators:
|
|
366
|
+
collaborators: _this.getCollaborator()
|
|
355
367
|
};
|
|
356
368
|
return _this;
|
|
357
369
|
}
|
|
358
370
|
|
|
359
371
|
_createClass(EditorFormatter, [{
|
|
372
|
+
key: "componentDidMount",
|
|
373
|
+
value: function componentDidMount() {
|
|
374
|
+
this.calculateCollaboratorData(this.props);
|
|
375
|
+
|
|
376
|
+
if (this.props.eventBus) {
|
|
377
|
+
this.listenCollaboratorsUpdated = this.props.eventBus.subscribe('collaborators-updated', this.updateCollaborators);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}, {
|
|
381
|
+
key: "componentWillReceiveProps",
|
|
382
|
+
value: function componentWillReceiveProps(nextProps) {
|
|
383
|
+
this.calculateCollaboratorData(nextProps);
|
|
384
|
+
}
|
|
385
|
+
}, {
|
|
386
|
+
key: "componentWillUnmount",
|
|
387
|
+
value: function componentWillUnmount() {
|
|
388
|
+
this.listenCollaboratorsUpdated();
|
|
389
|
+
}
|
|
390
|
+
}, {
|
|
360
391
|
key: "render",
|
|
361
392
|
value: function render() {
|
|
362
393
|
return /*#__PURE__*/React.createElement(Fragment, null, this.renderFormatter());
|
|
@@ -366,4 +397,4 @@ var EditorFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
366
397
|
return EditorFormatter;
|
|
367
398
|
}(React.Component);
|
|
368
399
|
|
|
369
|
-
export default
|
|
400
|
+
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,.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 };
|