dtable-ui-component 0.3.2-alpha4 → 0.3.2-alpha6
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 +73 -0
- package/lib/RowExpandFormatter/index.js +426 -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 +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
- package/lib/editor-formatter.js +0 -369
package/lib/editor-formatter.js
DELETED
|
@@ -1,369 +0,0 @@
|
|
|
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 _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
6
|
-
|
|
7
|
-
var _emptyTypeMap;
|
|
8
|
-
|
|
9
|
-
import React, { Fragment } from 'react';
|
|
10
|
-
import { CellType } from 'dtable-store';
|
|
11
|
-
import { TextFormatter, NumberFormatter, CheckboxFormatter, DateFormatter, SingleSelectFormatter, MultipleSelectFormatter, CollaboratorFormatter, SimpleLongTextFormatter, GeolocationFormatter, LinkFormatter, CTimeFormatter, CreatorFormatter, LastModifierFormatter, MTimeFormatter, AutoNumberFormatter, UrlFormatter, EmailFormatter, DurationFormatter, RateFormatter, ButtonFormatter, ImageFormatter, RowExpandFileFormatter // LongTextFormatter,
|
|
12
|
-
// FormulaFormatter,
|
|
13
|
-
} from './index';
|
|
14
|
-
import { COLLABORATORS } from './data/dtable-value';
|
|
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.DURATION, true), _defineProperty(_emptyTypeMap, CellType.IMAGE, true), _defineProperty(_emptyTypeMap, CellType.FILE, true), _emptyTypeMap);
|
|
16
|
-
|
|
17
|
-
var noop = function noop() {};
|
|
18
|
-
|
|
19
|
-
var EditorFormatter = /*#__PURE__*/function (_React$Component) {
|
|
20
|
-
_inherits(EditorFormatter, _React$Component);
|
|
21
|
-
|
|
22
|
-
var _super = _createSuper(EditorFormatter);
|
|
23
|
-
|
|
24
|
-
function EditorFormatter(props) {
|
|
25
|
-
var _this;
|
|
26
|
-
|
|
27
|
-
_classCallCheck(this, EditorFormatter);
|
|
28
|
-
|
|
29
|
-
_this = _super.call(this, props);
|
|
30
|
-
|
|
31
|
-
_this.renderEmptyFormatter = function () {
|
|
32
|
-
var emptyFormatter = /*#__PURE__*/React.createElement("span", {
|
|
33
|
-
className: "row-cell-empty d-inline-block"
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
if (_this.props.type === 'row_title') {
|
|
37
|
-
emptyFormatter = /*#__PURE__*/React.createElement("span", null, "\u672A\u547D\u540D\u884C");
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return emptyFormatter;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
_this.renderFormatter = function () {
|
|
44
|
-
var _this$props = _this.props,
|
|
45
|
-
column = _this$props.column,
|
|
46
|
-
row = _this$props.row,
|
|
47
|
-
CellType = _this$props.CellType,
|
|
48
|
-
className = _this$props.className;
|
|
49
|
-
var columnType = column.type;
|
|
50
|
-
var collaborators = _this.state.collaborators;
|
|
51
|
-
var containerClassName = "dtable-".concat(columnType, "-formatter ").concat(className || '');
|
|
52
|
-
var cellValue = row[column.key];
|
|
53
|
-
|
|
54
|
-
if (!cellValue && emptyTypeMap[columnType]) {
|
|
55
|
-
return _this.renderEmptyFormatter();
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
switch (columnType) {
|
|
59
|
-
case CellType.TEXT:
|
|
60
|
-
{
|
|
61
|
-
return /*#__PURE__*/React.createElement(TextFormatter, {
|
|
62
|
-
value: cellValue,
|
|
63
|
-
containerClassName: containerClassName
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
case CellType.COLLABORATOR:
|
|
68
|
-
{
|
|
69
|
-
if (!cellValue || cellValue.length === 0) {
|
|
70
|
-
return _this.renderEmptyFormatter();
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
var collaboratorFormatter = /*#__PURE__*/React.createElement(CollaboratorFormatter, {
|
|
74
|
-
value: cellValue,
|
|
75
|
-
collaborators: collaborators,
|
|
76
|
-
containerClassName: containerClassName
|
|
77
|
-
});
|
|
78
|
-
return collaboratorFormatter;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
case CellType.LONG_TEXT:
|
|
82
|
-
{
|
|
83
|
-
var longTextFormatter = /*#__PURE__*/React.createElement(SimpleLongTextFormatter, {
|
|
84
|
-
value: cellValue,
|
|
85
|
-
containerClassName: containerClassName
|
|
86
|
-
});
|
|
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
|
-
}
|
|
107
|
-
|
|
108
|
-
case CellType.GEOLOCATION:
|
|
109
|
-
{
|
|
110
|
-
var geolocationFormatter = /*#__PURE__*/React.createElement(GeolocationFormatter, {
|
|
111
|
-
value: cellValue,
|
|
112
|
-
data: column.data,
|
|
113
|
-
containerClassName: containerClassName
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
if (!cellValue) {
|
|
117
|
-
geolocationFormatter = _this.renderEmptyFormatter();
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
return geolocationFormatter;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
case CellType.NUMBER:
|
|
124
|
-
{
|
|
125
|
-
var numberFormatter = /*#__PURE__*/React.createElement(NumberFormatter, {
|
|
126
|
-
value: cellValue,
|
|
127
|
-
data: column.data,
|
|
128
|
-
containerClassName: containerClassName
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
if (!cellValue) {
|
|
132
|
-
numberFormatter = _this.renderEmptyFormatter();
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
return numberFormatter;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
case CellType.DATE:
|
|
139
|
-
{
|
|
140
|
-
var dateFormatter = /*#__PURE__*/React.createElement(DateFormatter, {
|
|
141
|
-
value: cellValue,
|
|
142
|
-
format: column.data.format,
|
|
143
|
-
containerClassName: containerClassName
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
if (!cellValue) {
|
|
147
|
-
dateFormatter = _this.renderEmptyFormatter();
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
return dateFormatter;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
case CellType.MULTIPLE_SELECT:
|
|
154
|
-
{
|
|
155
|
-
var options = column.data ? column.data.options : [];
|
|
156
|
-
var multipleSelectFormatter = /*#__PURE__*/React.createElement(MultipleSelectFormatter, {
|
|
157
|
-
value: cellValue,
|
|
158
|
-
options: options,
|
|
159
|
-
containerClassName: containerClassName
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
if (!cellValue || cellValue.length === 0) {
|
|
163
|
-
multipleSelectFormatter = _this.renderEmptyFormatter();
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
return multipleSelectFormatter;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
case CellType.SINGLE_SELECT:
|
|
170
|
-
{
|
|
171
|
-
var _options = column.data ? column.data.options : [];
|
|
172
|
-
|
|
173
|
-
var singleSelectFormatter = /*#__PURE__*/React.createElement(SingleSelectFormatter, {
|
|
174
|
-
value: cellValue,
|
|
175
|
-
options: _options,
|
|
176
|
-
containerClassName: containerClassName
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
if (!cellValue) {
|
|
180
|
-
singleSelectFormatter = _this.renderEmptyFormatter();
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return singleSelectFormatter;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
case CellType.FILE:
|
|
187
|
-
{
|
|
188
|
-
var fileFormatter = /*#__PURE__*/React.createElement(RowExpandFileFormatter, {
|
|
189
|
-
value: cellValue,
|
|
190
|
-
column: column,
|
|
191
|
-
downloadFile: noop,
|
|
192
|
-
deleteFile: noop,
|
|
193
|
-
readOnly: false
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
if (!cellValue || cellValue.length === 0) {
|
|
197
|
-
fileFormatter = _this.renderEmptyFormatter();
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return fileFormatter;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
case CellType.CHECKBOX:
|
|
204
|
-
{
|
|
205
|
-
return /*#__PURE__*/React.createElement(CheckboxFormatter, {
|
|
206
|
-
value: cellValue
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
case CellType.CTIME:
|
|
211
|
-
{
|
|
212
|
-
var cTimeFormatter = /*#__PURE__*/React.createElement(CTimeFormatter, {
|
|
213
|
-
value: row._ctime,
|
|
214
|
-
containerClassName: containerClassName
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
if (!row._ctime) {
|
|
218
|
-
cTimeFormatter = _this.renderEmptyFormatter();
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
return cTimeFormatter;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
case CellType.MTIME:
|
|
225
|
-
{
|
|
226
|
-
var mTimeFormatter = /*#__PURE__*/React.createElement(MTimeFormatter, {
|
|
227
|
-
value: row._mtime,
|
|
228
|
-
containerClassName: containerClassName
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
if (!row._mtime) {
|
|
232
|
-
mTimeFormatter = _this.renderEmptyFormatter();
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
return mTimeFormatter;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
case CellType.CREATOR:
|
|
239
|
-
{
|
|
240
|
-
if (!cellValue) return _this.renderEmptyFormatter();
|
|
241
|
-
var creatorFormatter = /*#__PURE__*/React.createElement(CreatorFormatter, {
|
|
242
|
-
collaborators: collaborators,
|
|
243
|
-
value: cellValue,
|
|
244
|
-
containerClassName: containerClassName
|
|
245
|
-
});
|
|
246
|
-
return creatorFormatter;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
case CellType.LAST_MODIFIER:
|
|
250
|
-
{
|
|
251
|
-
if (!cellValue) return _this.renderEmptyFormatter();
|
|
252
|
-
var lastModifierFormatter = /*#__PURE__*/React.createElement(LastModifierFormatter, {
|
|
253
|
-
collaborators: collaborators,
|
|
254
|
-
value: cellValue,
|
|
255
|
-
containerClassName: containerClassName
|
|
256
|
-
});
|
|
257
|
-
return lastModifierFormatter;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
case CellType.FORMULA:
|
|
261
|
-
case CellType.LINK_FORMULA:
|
|
262
|
-
{
|
|
263
|
-
var textFormatter = /*#__PURE__*/React.createElement(TextFormatter, {
|
|
264
|
-
value: cellValue,
|
|
265
|
-
containerClassName: containerClassName
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
if (!cellValue) {
|
|
269
|
-
textFormatter = _this.renderEmptyFormatter();
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
return textFormatter;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
case CellType.LINK:
|
|
276
|
-
{
|
|
277
|
-
if (!Array.isArray(cellValue) || cellValue.length === 0) return _this.renderEmptyFormatter();
|
|
278
|
-
return /*#__PURE__*/React.createElement(LinkFormatter, {
|
|
279
|
-
value: cellValue,
|
|
280
|
-
column: column,
|
|
281
|
-
collaborators: collaborators,
|
|
282
|
-
containerClassName: 'map-app-link-formatter',
|
|
283
|
-
renderEmptyFormatter: _this.renderEmptyFormatter,
|
|
284
|
-
getOptionColors: _this.props.getOptionColors,
|
|
285
|
-
getUserCommonInfo: function getUserCommonInfo() {},
|
|
286
|
-
CellType: CellType
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
case CellType.AUTO_NUMBER:
|
|
291
|
-
{
|
|
292
|
-
return /*#__PURE__*/React.createElement(AutoNumberFormatter, {
|
|
293
|
-
value: cellValue,
|
|
294
|
-
containerClassName: containerClassName
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
case CellType.URL:
|
|
299
|
-
{
|
|
300
|
-
return /*#__PURE__*/React.createElement(UrlFormatter, {
|
|
301
|
-
value: cellValue,
|
|
302
|
-
containerClassName: containerClassName
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
case CellType.EMAIL:
|
|
307
|
-
{
|
|
308
|
-
return /*#__PURE__*/React.createElement(EmailFormatter, {
|
|
309
|
-
value: cellValue,
|
|
310
|
-
containerClassName: containerClassName
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
case CellType.DURATION:
|
|
315
|
-
{
|
|
316
|
-
return /*#__PURE__*/React.createElement(DurationFormatter, {
|
|
317
|
-
value: cellValue,
|
|
318
|
-
format: column.data.duration_format,
|
|
319
|
-
containerClassName: containerClassName
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
case CellType.RATE:
|
|
324
|
-
{
|
|
325
|
-
return /*#__PURE__*/React.createElement(RateFormatter, {
|
|
326
|
-
value: cellValue,
|
|
327
|
-
data: column.data,
|
|
328
|
-
containerClassName: containerClassName
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
case CellType.BUTTON:
|
|
333
|
-
{
|
|
334
|
-
var _column$data = column.data,
|
|
335
|
-
data = _column$data === void 0 ? {} : _column$data;
|
|
336
|
-
var buttonFormatter = /*#__PURE__*/React.createElement(ButtonFormatter, {
|
|
337
|
-
data: data,
|
|
338
|
-
containerClassName: containerClassName
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
if (!data.button_name) {
|
|
342
|
-
buttonFormatter = _this.renderEmptyFormatter();
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
return buttonFormatter;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
default:
|
|
349
|
-
return null;
|
|
350
|
-
}
|
|
351
|
-
};
|
|
352
|
-
|
|
353
|
-
_this.state = {
|
|
354
|
-
collaborators: COLLABORATORS
|
|
355
|
-
};
|
|
356
|
-
return _this;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
_createClass(EditorFormatter, [{
|
|
360
|
-
key: "render",
|
|
361
|
-
value: function render() {
|
|
362
|
-
return /*#__PURE__*/React.createElement(Fragment, null, this.renderFormatter());
|
|
363
|
-
}
|
|
364
|
-
}]);
|
|
365
|
-
|
|
366
|
-
return EditorFormatter;
|
|
367
|
-
}(React.Component);
|
|
368
|
-
|
|
369
|
-
export default EditorFormatter;
|