dtable-ui-component 0.1.79-beta → 0.1.82-beta
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/es/app.css +20 -0
- package/es/app.js +91 -0
- package/es/assets/images/avatar/default_avatar.png +0 -0
- package/es/assets/images/file/192/excel.png +0 -0
- package/es/assets/images/file/192/file.png +0 -0
- package/es/assets/images/file/192/music.png +0 -0
- package/es/assets/images/file/192/pdf.png +0 -0
- package/es/assets/images/file/192/pic.png +0 -0
- package/es/assets/images/file/192/ppt.png +0 -0
- package/es/assets/images/file/192/txt.png +0 -0
- package/es/assets/images/file/192/video.png +0 -0
- package/es/assets/images/file/192/word.png +0 -0
- package/es/assets/images/file/24/excel.png +0 -0
- package/es/assets/images/file/24/file.png +0 -0
- package/es/assets/images/file/24/music.png +0 -0
- package/es/assets/images/file/24/pdf.png +0 -0
- package/es/assets/images/file/24/pic.png +0 -0
- package/es/assets/images/file/24/ppt.png +0 -0
- package/es/assets/images/file/24/txt.png +0 -0
- package/es/assets/images/file/24/video.png +0 -0
- package/es/assets/images/file/24/word.png +0 -0
- package/es/assets/images/folder/folder-192.png +0 -0
- package/es/assets/images/folder/folder-24.png +0 -0
- package/es/components/cell-editor/checkbox-editor.js +104 -0
- package/es/components/cell-editor/collaborator-editor.js +236 -0
- package/es/components/cell-editor/date-editor.js +151 -0
- package/es/components/cell-editor/index.js +9 -0
- package/es/components/cell-editor/link-editor.js +303 -0
- package/es/components/cell-editor/multiple-select-editor.js +237 -0
- package/es/components/cell-editor/number-editor.js +154 -0
- package/es/components/cell-editor/single-select-editor.js +202 -0
- package/es/components/cell-editor/text-editor.js +122 -0
- package/es/components/cell-editor-dialog/pc-file-editor-dialog.js +46 -0
- package/es/components/cell-editor-dialog/pc-files-addition/index.js +0 -0
- package/es/components/cell-editor-dialog/pc-files-addition/pc-file-uploaded-item.js +0 -0
- package/es/components/cell-editor-dialog/pc-files-preview/index.js +0 -0
- package/es/components/cell-editor-dialog/pc-files-preview/pc-file-item-preview.js +0 -0
- package/es/components/cell-editor-popover/mb-collaborator-editor-popover.js +177 -0
- package/es/components/cell-editor-popover/mb-date-editor-popover.js +245 -0
- package/es/components/cell-editor-popover/mb-link-editor-popover.js +170 -0
- package/es/components/cell-editor-popover/mb-select-editor-popover.js +230 -0
- package/es/components/cell-editor-popover/pc-collaborator-editor-popover.js +109 -0
- package/es/components/cell-editor-popover/pc-date-editor-popover.js +142 -0
- package/es/components/cell-editor-popover/pc-link-editor-popover.js +114 -0
- package/es/components/cell-editor-popover/pc-select-editor-popover.js +143 -0
- package/es/components/cell-factory/cell-formatter-factory.js +25 -0
- package/es/components/cell-formatter/auto-number-formatter.js +35 -0
- package/es/components/cell-formatter/button-formatter.js +55 -0
- package/es/components/cell-formatter/checkbox-formatter.js +44 -0
- package/es/components/cell-formatter/collaborator-formatter.js +91 -0
- package/es/components/cell-formatter/creator-formatter.js +87 -0
- package/es/components/cell-formatter/ctime-formatter.js +57 -0
- package/es/components/cell-formatter/date-formatter.js +59 -0
- package/es/components/cell-formatter/duration-formatter.js +37 -0
- package/es/components/cell-formatter/email-formatter.js +35 -0
- package/es/components/cell-formatter/file-formatter.js +63 -0
- package/es/components/cell-formatter/formatter-config.js +31 -0
- package/es/components/cell-formatter/formula-formatter.js +164 -0
- package/es/components/cell-formatter/geolocation-formatter.js +52 -0
- package/es/components/cell-formatter/image-formatter.js +153 -0
- package/es/components/cell-formatter/index.js +27 -0
- package/es/components/cell-formatter/last-modifier-formatter.js +87 -0
- package/es/components/cell-formatter/link-formatter.js +144 -0
- package/es/components/cell-formatter/long-text-formatter.js +106 -0
- package/es/components/cell-formatter/mtime-formatter.js +57 -0
- package/es/components/cell-formatter/multiple-select-formatter.js +69 -0
- package/es/components/cell-formatter/number-formatter.js +46 -0
- package/es/components/cell-formatter/rate-formatter.js +79 -0
- package/es/components/cell-formatter/single-select-formatter.js +69 -0
- package/es/components/cell-formatter/text-formatter.js +55 -0
- package/es/components/cell-formatter/url-formatter.js +35 -0
- package/es/components/cell-formatter/widgets/file-item-formatter.js +50 -0
- package/es/components/cell-formatter/widgets/image-previewer-lightbox.js +119 -0
- package/es/components/common/collaborator-item.js +63 -0
- package/es/components/common/edit-editor-button.js +56 -0
- package/es/components/common/images-lazy-load.js +150 -0
- package/es/components/common/link-editor-option.js +113 -0
- package/es/components/common/mobile/mb-editor-header.js +48 -0
- package/es/components/common/modal-portal.js +44 -0
- package/es/components/common/select-editor-option.js +106 -0
- package/es/components/common/select-item.js +58 -0
- package/es/components/file-uploader/index.js +53 -0
- package/es/components/loading.js +7 -0
- package/es/components/toast/alert.js +150 -0
- package/es/components/toast/index.js +3 -0
- package/es/components/toast/toast.js +179 -0
- package/es/components/toast/toastManager.js +170 -0
- package/es/components/toast/toaster.js +76 -0
- package/es/constants/cell-types.js +25 -0
- package/es/constants/index.js +48 -0
- package/es/css/cell-editor.css +614 -0
- package/es/css/cell-formatter.css +241 -0
- package/es/css/custom-rc-calendar.css +118 -0
- package/es/css/image-previewer-ligntbox.css +87 -0
- package/es/css/loading.css +54 -0
- package/es/index.js +6 -0
- package/es/lang/index.js +50 -0
- package/es/locals/de.js +2 -0
- package/es/locals/en.js +17 -0
- package/es/locals/fr.js +2 -0
- package/es/locals/zh-CN.js +17 -0
- package/es/utils/cell-value-validator.js +32 -0
- package/es/utils/column-utils.js +7 -0
- package/es/utils/editor-utils.js +71 -0
- package/es/utils/normalize-long-text-value.js +68 -0
- package/es/utils/number-precision.js +163 -0
- package/es/utils/utils.js +116 -0
- package/es/utils/value-format-utils.js +495 -0
- package/lib/CTimeFormatter/index.js +2 -2
- package/lib/DateEditor/index.js +2 -2
- package/lib/DateEditor/mb-date-editor-popover/index.js +9 -9
- package/lib/DateEditor/pc-date-editor-popover.js +3 -3
- package/lib/MTimeFormatter/index.js +2 -2
- package/lib/RateFormatter/index.js +4 -2
- package/lib/TextFormatter/index.js +4 -2
- package/lib/utils/value-format-utils.js +2 -2
- package/package.json +5 -5
|
@@ -0,0 +1,495 @@
|
|
|
1
|
+
import moment from 'moment';
|
|
2
|
+
import NP from './number-precision';
|
|
3
|
+
import { NUMBER_TYPES, DEFAULT_NUMBER_FORMAT, DURATION_FORMATS_MAP, DURATION_FORMATS, DURATION_ZERO_DISPLAY, DURATION_DECIMAL_DIGITS, FORMULA_RESULT_TYPE, COLLABORATOR_COLUMN_TYPES, ARRAY_FORMAL_COLUMNS_TYPES, DEFAULT_DATE_FORMAT } from '../constants';
|
|
4
|
+
import * as CellType from '../constants/cell-types';
|
|
5
|
+
NP.enableBoundaryChecking(false);
|
|
6
|
+
var _separatorMap = {
|
|
7
|
+
'comma': ',',
|
|
8
|
+
'dot': '.',
|
|
9
|
+
'no': '',
|
|
10
|
+
'space': ' '
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
var _toThousands = function _toThousands(num, isCurrency, formatData) {
|
|
14
|
+
var _ref = formatData || {},
|
|
15
|
+
_ref$decimal = _ref.decimal,
|
|
16
|
+
decimal = _ref$decimal === void 0 ? 'dot' : _ref$decimal,
|
|
17
|
+
_ref$thousands = _ref.thousands,
|
|
18
|
+
thousands = _ref$thousands === void 0 ? 'no' : _ref$thousands,
|
|
19
|
+
_ref$precision = _ref.precision,
|
|
20
|
+
precision = _ref$precision === void 0 ? 2 : _ref$precision,
|
|
21
|
+
_ref$enable_precision = _ref.enable_precision,
|
|
22
|
+
enable_precision = _ref$enable_precision === void 0 ? false : _ref$enable_precision;
|
|
23
|
+
|
|
24
|
+
var decimalString = _separatorMap[decimal];
|
|
25
|
+
var thousandsString = _separatorMap[thousands];
|
|
26
|
+
var decimalDigits = enable_precision ? precision : _getDecimalDigits(num);
|
|
27
|
+
var value = parseFloat(num.toFixed(decimalDigits));
|
|
28
|
+
var integer = Math.trunc(value);
|
|
29
|
+
var decimalValue = String(Math.abs(NP.minus(value, integer)).toFixed(decimalDigits)).slice(1);
|
|
30
|
+
|
|
31
|
+
if (isCurrency) {
|
|
32
|
+
if (decimalValue.length === 2) {
|
|
33
|
+
decimalValue = decimalValue.padEnd(3, '0');
|
|
34
|
+
} else {
|
|
35
|
+
decimalValue = (decimalValue.substring(0, 3) || '.').padEnd(3, '0');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (enable_precision) {
|
|
39
|
+
decimalValue = precision === 0 ? '' : decimalValue.slice(0, precision + 1);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
decimalValue = decimalValue.replace(/./, decimalString);
|
|
44
|
+
var result = [],
|
|
45
|
+
counter = 0;
|
|
46
|
+
integer = Object.is(integer, -0) ? ['-', '0'] : integer.toString().split('');
|
|
47
|
+
|
|
48
|
+
for (var i = integer.length - 1; i >= 0; i--) {
|
|
49
|
+
counter++;
|
|
50
|
+
result.unshift(integer[i]);
|
|
51
|
+
|
|
52
|
+
if (!(counter % 3) && i !== 0) {
|
|
53
|
+
result.unshift(thousandsString);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return result.join('') + decimalValue;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
var _getDecimalDigits = function _getDecimalDigits(num) {
|
|
61
|
+
if (Number.isInteger(num)) {
|
|
62
|
+
return 0;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
var valueArr = (num + '').split('.');
|
|
66
|
+
var digitsLength = valueArr[1] ? valueArr[1].length : 8;
|
|
67
|
+
return digitsLength > 8 ? 8 : digitsLength;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export var getNumberDisplayString = function getNumberDisplayString(value, formatData) {
|
|
71
|
+
// formatData: old version maybe 'null'
|
|
72
|
+
var type = Object.prototype.toString.call(value);
|
|
73
|
+
|
|
74
|
+
if (type !== '[object Number]') {
|
|
75
|
+
if (type === '[object String]' && value.startsWith('#')) {
|
|
76
|
+
return value;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (isNaN(value) || value === Infinity || value === -Infinity || (value + '').indexOf('e') > -1) return value + '';
|
|
83
|
+
|
|
84
|
+
var _ref2 = formatData || {},
|
|
85
|
+
_ref2$format = _ref2.format,
|
|
86
|
+
format = _ref2$format === void 0 ? DEFAULT_NUMBER_FORMAT : _ref2$format;
|
|
87
|
+
|
|
88
|
+
switch (format) {
|
|
89
|
+
case 'number':
|
|
90
|
+
return _toThousands(value, false, formatData);
|
|
91
|
+
|
|
92
|
+
case 'percent':
|
|
93
|
+
{
|
|
94
|
+
return "".concat(_toThousands(Number.parseFloat((value * 100).toFixed(8)), false, formatData), "%");
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
case 'yuan':
|
|
98
|
+
return "\uFFE5".concat(_toThousands(value, true, formatData));
|
|
99
|
+
|
|
100
|
+
case 'dollar':
|
|
101
|
+
return "$".concat(_toThousands(value, true, formatData));
|
|
102
|
+
|
|
103
|
+
case 'euro':
|
|
104
|
+
return "\u20AC".concat(_toThousands(value, true, formatData));
|
|
105
|
+
|
|
106
|
+
case 'duration':
|
|
107
|
+
{
|
|
108
|
+
return getDurationDisplayString(value, formatData.duration_format);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
default:
|
|
112
|
+
return '' + value;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
export var formatStringToNumber = function formatStringToNumber(value) {
|
|
116
|
+
var isIncludePercent = value.indexOf('%') > -1;
|
|
117
|
+
var newData = parseFloat(value.replace(/[^.-\d]/g, ''));
|
|
118
|
+
|
|
119
|
+
if (isIncludePercent && !isNaN(newData)) {
|
|
120
|
+
return newData / 100;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return isNaN(newData) ? '' : newData;
|
|
124
|
+
};
|
|
125
|
+
export var formatNumberString = function formatNumberString(value, format) {
|
|
126
|
+
var formattedValue = '';
|
|
127
|
+
|
|
128
|
+
switch (format) {
|
|
129
|
+
case NUMBER_TYPES.NUMBER:
|
|
130
|
+
case NUMBER_TYPES.NUMBER_WITH_COMMAS:
|
|
131
|
+
formattedValue = value.replace(/[^.-\d,]/g, '');
|
|
132
|
+
break;
|
|
133
|
+
|
|
134
|
+
case NUMBER_TYPES.PERCENT:
|
|
135
|
+
formattedValue = value.replace(/[^.-\d,%]/g, '');
|
|
136
|
+
break;
|
|
137
|
+
|
|
138
|
+
case NUMBER_TYPES.YUAN:
|
|
139
|
+
formattedValue = value.replace(/[^.-\d¥,]/g, '');
|
|
140
|
+
break;
|
|
141
|
+
|
|
142
|
+
case NUMBER_TYPES.DOLLAR:
|
|
143
|
+
formattedValue = value.replace(/[^.-\d$,]/g, '');
|
|
144
|
+
break;
|
|
145
|
+
|
|
146
|
+
case NUMBER_TYPES.EURO:
|
|
147
|
+
formattedValue = value.replace(/[^.-\d€,]/g, '');
|
|
148
|
+
break;
|
|
149
|
+
|
|
150
|
+
default:
|
|
151
|
+
formattedValue = value.replace(/[^.-\d,]/g, '');
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return formattedValue;
|
|
155
|
+
};
|
|
156
|
+
export var getDateDisplayString = function getDateDisplayString(value, format) {
|
|
157
|
+
var formattedValue = '';
|
|
158
|
+
|
|
159
|
+
if (!value) {
|
|
160
|
+
// value === '', value === undefine, value === null
|
|
161
|
+
return formattedValue;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
var date = moment(value);
|
|
165
|
+
if (!date.isValid()) return value;
|
|
166
|
+
|
|
167
|
+
switch (format) {
|
|
168
|
+
case 'D/M/YYYY':
|
|
169
|
+
case 'DD/MM/YYYY':
|
|
170
|
+
var formatValue = date.format('YYYY-MM-DD');
|
|
171
|
+
var formatValueList = formatValue.split('-');
|
|
172
|
+
return "".concat(formatValueList[2], "/").concat(formatValueList[1], "/").concat(formatValueList[0]);
|
|
173
|
+
|
|
174
|
+
case 'D/M/YYYY HH:mm':
|
|
175
|
+
case 'DD/MM/YYYY HH:mm':
|
|
176
|
+
var formatValues = date.format('YYYY-MM-DD HH:mm');
|
|
177
|
+
var formatValuesList = formatValues.split(' ');
|
|
178
|
+
var formatDateList = formatValuesList[0].split('-');
|
|
179
|
+
return "".concat(formatDateList[2], "/").concat(formatDateList[1], "/").concat(formatDateList[0], " ").concat(formatValuesList[1]);
|
|
180
|
+
|
|
181
|
+
case 'M/D/YYYY':
|
|
182
|
+
return date.format('M/D/YYYY');
|
|
183
|
+
|
|
184
|
+
case 'M/D/YYYY HH:mm':
|
|
185
|
+
return date.format('M/D/YYYY HH:mm');
|
|
186
|
+
|
|
187
|
+
case 'YYYY-MM-DD':
|
|
188
|
+
return date.format('YYYY-MM-DD');
|
|
189
|
+
|
|
190
|
+
case 'YYYY-MM-DD HH:mm':
|
|
191
|
+
return date.format('YYYY-MM-DD HH:mm');
|
|
192
|
+
|
|
193
|
+
default:
|
|
194
|
+
return value;
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
export var getDurationDisplayString = function getDurationDisplayString(value, duration_format) {
|
|
198
|
+
if (!value && value !== 0) return '';
|
|
199
|
+
duration_format = duration_format || DURATION_FORMATS_MAP.H_MM;
|
|
200
|
+
|
|
201
|
+
if (DURATION_FORMATS.findIndex(function (format) {
|
|
202
|
+
return format.type === duration_format;
|
|
203
|
+
}) < 0) {
|
|
204
|
+
return '';
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (value === 0) {
|
|
208
|
+
return DURATION_ZERO_DISPLAY[duration_format];
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
var includeDecimal = duration_format.indexOf('.') > -1;
|
|
212
|
+
var positiveValue = Math.abs(value);
|
|
213
|
+
|
|
214
|
+
if (!includeDecimal) {
|
|
215
|
+
positiveValue = Math.round(positiveValue);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
positiveValue = getMathRoundedDuration(positiveValue, duration_format);
|
|
219
|
+
var decimalParts = (positiveValue + '').split('.');
|
|
220
|
+
var decimalPartsLen = decimalParts.length;
|
|
221
|
+
var decimal = 0;
|
|
222
|
+
|
|
223
|
+
if (decimalPartsLen > 1) {
|
|
224
|
+
decimal = decimalParts[decimalPartsLen - 1];
|
|
225
|
+
decimal = decimal ? decimal - 0 : 0;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
var decimalDigits = DURATION_DECIMAL_DIGITS[duration_format];
|
|
229
|
+
var decimalSuffix = getDurationDecimalSuffix(duration_format, decimal);
|
|
230
|
+
var displayString = value < 0 ? '-' : '';
|
|
231
|
+
var hours = parseInt(positiveValue / 3600);
|
|
232
|
+
var minutes = parseInt((positiveValue - hours * 3600) / 60);
|
|
233
|
+
|
|
234
|
+
if (duration_format === DURATION_FORMATS_MAP.H_MM) {
|
|
235
|
+
displayString += "".concat(hours, ":").concat(minutes > 9 ? minutes : '0' + minutes);
|
|
236
|
+
return displayString;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
var seconds = Number.parseFloat((positiveValue - hours * 3600 - minutes * 60).toFixed(decimalDigits));
|
|
240
|
+
|
|
241
|
+
if (hours > 0) {
|
|
242
|
+
displayString += "".concat(hours, ":");
|
|
243
|
+
minutes = minutes > 9 ? minutes : "0".concat(minutes);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
seconds = seconds > 9 ? seconds : "0".concat(seconds);
|
|
247
|
+
displayString += "".concat(minutes, ":").concat(seconds).concat(decimalSuffix);
|
|
248
|
+
return displayString;
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
var getMathRoundedDuration = function getMathRoundedDuration(num, duration_format) {
|
|
252
|
+
var decimalDigits = DURATION_DECIMAL_DIGITS[duration_format];
|
|
253
|
+
|
|
254
|
+
if (decimalDigits < 1) {
|
|
255
|
+
return num;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
var ratio = Math.pow(10, decimalDigits);
|
|
259
|
+
return Math.round(num * ratio) / ratio;
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
var getDurationDecimalSuffix = function getDurationDecimalSuffix(duration_format, decimal) {
|
|
263
|
+
if (duration_format === DURATION_FORMATS_MAP.H_MM_SS_S) {
|
|
264
|
+
return decimal === 0 ? '.0' : '';
|
|
265
|
+
} else if (duration_format === DURATION_FORMATS_MAP.H_MM_SS_SS) {
|
|
266
|
+
if (decimal === 0) {
|
|
267
|
+
return '.00';
|
|
268
|
+
} else if (decimal < 10) {
|
|
269
|
+
return '0';
|
|
270
|
+
}
|
|
271
|
+
} else if (duration_format === DURATION_FORMATS_MAP.H_MM_SS_SSS) {
|
|
272
|
+
if (decimal === 0) {
|
|
273
|
+
return '.000';
|
|
274
|
+
} else if (decimal < 10) {
|
|
275
|
+
return '00';
|
|
276
|
+
} else if (decimal < 100) {
|
|
277
|
+
return '0';
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return '';
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
export var getOptionName = function getOptionName(options, targetOptionID) {
|
|
285
|
+
if (!targetOptionID || !options || !Array.isArray(options)) return null;
|
|
286
|
+
var option = options.find(function (option) {
|
|
287
|
+
return option.id === targetOptionID;
|
|
288
|
+
});
|
|
289
|
+
return option ? option.name : null;
|
|
290
|
+
};
|
|
291
|
+
export var getMultipleOptionName = function getMultipleOptionName(options, cellVal) {
|
|
292
|
+
if (!cellVal || !options || !Array.isArray(options)) return null;
|
|
293
|
+
var selectedOptions = options.filter(function (option) {
|
|
294
|
+
return cellVal.includes(option.id);
|
|
295
|
+
});
|
|
296
|
+
if (selectedOptions.length === 0) return null;
|
|
297
|
+
return selectedOptions.map(function (option) {
|
|
298
|
+
return option.name;
|
|
299
|
+
}).join(', ');
|
|
300
|
+
};
|
|
301
|
+
export var getLongtextDisplayString = function getLongtextDisplayString(value) {
|
|
302
|
+
var _ref3 = value || {},
|
|
303
|
+
text = _ref3.text;
|
|
304
|
+
|
|
305
|
+
if (!text) {
|
|
306
|
+
return null;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
return text;
|
|
310
|
+
};
|
|
311
|
+
export var getCollaboratorsName = function getCollaboratorsName(collaborators, cellVal) {
|
|
312
|
+
if (cellVal) {
|
|
313
|
+
var collaboratorsName = [];
|
|
314
|
+
cellVal.forEach(function (v) {
|
|
315
|
+
var collaborator = collaborators.find(function (c) {
|
|
316
|
+
return c.email === v;
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
if (collaborator) {
|
|
320
|
+
collaboratorsName.push(collaborator.name);
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
if (collaboratorsName.length === 0) {
|
|
325
|
+
return null;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
return collaboratorsName.join(', ');
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
return null;
|
|
332
|
+
};
|
|
333
|
+
export var getGeolocationDisplayString = function getGeolocationDisplayString(value, columnData) {
|
|
334
|
+
var _ref4 = columnData || {},
|
|
335
|
+
geo_format = _ref4.geo_format;
|
|
336
|
+
|
|
337
|
+
var cellValue = value || {};
|
|
338
|
+
|
|
339
|
+
if (!value) {
|
|
340
|
+
return null;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
if (geo_format === 'lng_lat' && value.lng && value.lat) {
|
|
344
|
+
return "".concat(cellValue.lng, ", ").concat(cellValue.lat);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
if (geo_format === 'country_region' && cellValue.country_region) {
|
|
348
|
+
return value.country_region || '';
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
var province = cellValue.province,
|
|
352
|
+
city = cellValue.city,
|
|
353
|
+
district = cellValue.district,
|
|
354
|
+
detail = cellValue.detail;
|
|
355
|
+
|
|
356
|
+
if (geo_format === 'province') {
|
|
357
|
+
return "".concat(province || '');
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
if (geo_format === 'province_city') {
|
|
361
|
+
return "".concat(province || '').concat(city || '');
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
return "".concat(province || '').concat(city || '').concat(district || '').concat(detail || '');
|
|
365
|
+
};
|
|
366
|
+
export var getFormulaDisplayString = function getFormulaDisplayString(cellValue, columnData) {
|
|
367
|
+
var _ref5 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
368
|
+
_ref5$collaborators = _ref5.collaborators,
|
|
369
|
+
collaborators = _ref5$collaborators === void 0 ? [] : _ref5$collaborators;
|
|
370
|
+
|
|
371
|
+
if (!columnData) {
|
|
372
|
+
return null;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
var result_type = columnData.result_type;
|
|
376
|
+
|
|
377
|
+
if (result_type === FORMULA_RESULT_TYPE.NUMBER) {
|
|
378
|
+
return getNumberDisplayString(cellValue, columnData);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
if (result_type === FORMULA_RESULT_TYPE.DATE) {
|
|
382
|
+
var format = columnData.format;
|
|
383
|
+
return getDateDisplayString(cellValue, format);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
if (result_type === FORMULA_RESULT_TYPE.ARRAY) {
|
|
387
|
+
var array_type = columnData.array_type,
|
|
388
|
+
array_data = columnData.array_data;
|
|
389
|
+
|
|
390
|
+
if (!array_type) {
|
|
391
|
+
return null;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
if (COLLABORATOR_COLUMN_TYPES.includes(array_type)) {
|
|
395
|
+
return cellValue;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
if (ARRAY_FORMAL_COLUMNS_TYPES.indexOf(array_type) < 0 && Array.isArray(cellValue)) {
|
|
399
|
+
return cellValue.map(function (val) {
|
|
400
|
+
return getCellValueDisplayString(val, array_type, {
|
|
401
|
+
data: array_data,
|
|
402
|
+
collaborators: collaborators
|
|
403
|
+
});
|
|
404
|
+
}).join(', ');
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
return getCellValueDisplayString(cellValue, array_type, {
|
|
408
|
+
data: array_data,
|
|
409
|
+
collaborators: collaborators
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
if (Object.prototype.toString.call(cellValue) === '[object Boolean]') {
|
|
414
|
+
return cellValue + '';
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
return cellValue;
|
|
418
|
+
};
|
|
419
|
+
export function getCellValueDisplayString(cellValue, type) {
|
|
420
|
+
var _ref6 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
421
|
+
data = _ref6.data,
|
|
422
|
+
_ref6$collaborators = _ref6.collaborators,
|
|
423
|
+
collaborators = _ref6$collaborators === void 0 ? [] : _ref6$collaborators;
|
|
424
|
+
|
|
425
|
+
var newData = data || {};
|
|
426
|
+
|
|
427
|
+
switch (type) {
|
|
428
|
+
case CellType.GEOLOCATION:
|
|
429
|
+
{
|
|
430
|
+
return getGeolocationDisplayString(cellValue, data);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
case CellType.SINGLE_SELECT:
|
|
434
|
+
{
|
|
435
|
+
if (!data) return '';
|
|
436
|
+
var options = newData.options;
|
|
437
|
+
return getOptionName(options, cellValue);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
case CellType.MULTIPLE_SELECT:
|
|
441
|
+
{
|
|
442
|
+
if (!data) return '';
|
|
443
|
+
var _options = newData.options;
|
|
444
|
+
return getMultipleOptionName(_options, cellValue);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
case CellType.FORMULA:
|
|
448
|
+
case CellType.LINK_FORMULA:
|
|
449
|
+
{
|
|
450
|
+
return getFormulaDisplayString(cellValue, newData, {
|
|
451
|
+
collaborators: collaborators
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
case CellType.LONG_TEXT:
|
|
456
|
+
{
|
|
457
|
+
return getLongtextDisplayString(cellValue);
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
case CellType.NUMBER:
|
|
461
|
+
{
|
|
462
|
+
return getNumberDisplayString(cellValue, newData);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
case CellType.DATE:
|
|
466
|
+
{
|
|
467
|
+
var _ref7 = newData || {},
|
|
468
|
+
_ref7$format = _ref7.format,
|
|
469
|
+
format = _ref7$format === void 0 ? DEFAULT_DATE_FORMAT : _ref7$format;
|
|
470
|
+
|
|
471
|
+
return getDateDisplayString(cellValue, format);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
case CellType.CREATOR:
|
|
475
|
+
case CellType.LAST_MODIFIER:
|
|
476
|
+
{
|
|
477
|
+
return cellValue === 'anonymous' ? cellValue : getCollaboratorsName(collaborators, [cellValue]);
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
case CellType.COLLABORATOR:
|
|
481
|
+
{
|
|
482
|
+
return getCollaboratorsName(collaborators, cellValue);
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
case CellType.DURATION:
|
|
486
|
+
{
|
|
487
|
+
return getDurationDisplayString(cellValue, data);
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
default:
|
|
491
|
+
{
|
|
492
|
+
return cellValue ? cellValue + '' : '';
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}
|
|
@@ -4,7 +4,7 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
|
4
4
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import cn from 'astro-classname';
|
|
7
|
-
import
|
|
7
|
+
import dayjs from 'dayjs';
|
|
8
8
|
import './index.css';
|
|
9
9
|
|
|
10
10
|
var CTimeFormatter = /*#__PURE__*/function (_React$Component) {
|
|
@@ -24,7 +24,7 @@ var CTimeFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
24
24
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
25
25
|
|
|
26
26
|
_this.formatDate = function (date) {
|
|
27
|
-
return
|
|
27
|
+
return dayjs(date).format('YYYY-MM-DD HH:mm:ss');
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
return _this;
|
package/lib/DateEditor/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
|
4
4
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
5
|
import React, { Fragment } from 'react';
|
|
6
6
|
import MediaQuery from 'react-responsive';
|
|
7
|
-
import
|
|
7
|
+
import dayjs from 'dayjs';
|
|
8
8
|
import { getDateDisplayString } from '../utils/value-format-utils';
|
|
9
9
|
import PCDateEditorPopover from './pc-date-editor-popover';
|
|
10
10
|
import MBDateEditorPopover from './mb-date-editor-popover';
|
|
@@ -81,7 +81,7 @@ var DateEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
81
81
|
var _this$props = this.props,
|
|
82
82
|
value = _this$props.value,
|
|
83
83
|
lang = _this$props.lang;
|
|
84
|
-
|
|
84
|
+
dayjs.locale(lang);
|
|
85
85
|
var dateFormat = this.getDateFormat();
|
|
86
86
|
this.setState({
|
|
87
87
|
isDateInit: true,
|
|
@@ -4,7 +4,7 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
|
4
4
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { DatePicker } from 'antd-mobile';
|
|
7
|
-
import
|
|
7
|
+
import dayjs from 'dayjs';
|
|
8
8
|
import Calendar from '@seafile/seafile-calendar';
|
|
9
9
|
import * as SeaDatePicker from '@seafile/seafile-calendar/lib/Picker';
|
|
10
10
|
import { getLocale } from '../../lang';
|
|
@@ -35,19 +35,19 @@ var DateEditorPopover = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
35
35
|
var _this$props = _this.props,
|
|
36
36
|
dateFormat = _this$props.dateFormat,
|
|
37
37
|
showHourAndMinute = _this$props.showHourAndMinute;
|
|
38
|
-
var newValue =
|
|
38
|
+
var newValue = dayjs(date);
|
|
39
39
|
|
|
40
40
|
if (showHourAndMinute) {
|
|
41
41
|
var datePickerValue = _this.state.datePickerValue;
|
|
42
42
|
var HM = datePickerValue.format('HH:mm');
|
|
43
43
|
var format = dateFormat.split(' ')[0]; // 'YYYY-MM-DD HH:mm'
|
|
44
44
|
|
|
45
|
-
var newDate =
|
|
46
|
-
newValue =
|
|
45
|
+
var newDate = dayjs(date).format(format) + ' ' + HM;
|
|
46
|
+
newValue = dayjs(newDate);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
_this.setState({
|
|
50
|
-
datePickerValue:
|
|
50
|
+
datePickerValue: dayjs(date)
|
|
51
51
|
});
|
|
52
52
|
|
|
53
53
|
_this.props.onValueChanged(newValue.format(dateFormat));
|
|
@@ -59,8 +59,8 @@ var DateEditorPopover = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
59
59
|
var format = dateFormat.split(' ')[0]; // 'YYYY-MM-DD HH:mm'
|
|
60
60
|
|
|
61
61
|
var YMD = datePickerValue.format(format);
|
|
62
|
-
var newDate = YMD + ' ' +
|
|
63
|
-
var newValue =
|
|
62
|
+
var newDate = YMD + ' ' + dayjs(time).format('HH:mm');
|
|
63
|
+
var newValue = dayjs(newDate);
|
|
64
64
|
|
|
65
65
|
_this.setState({
|
|
66
66
|
datePickerValue: newValue
|
|
@@ -110,7 +110,7 @@ var DateEditorPopover = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
110
110
|
var _this$props2 = _this.props,
|
|
111
111
|
dateFormat = _this$props2.dateFormat,
|
|
112
112
|
lang = _this$props2.lang;
|
|
113
|
-
var defaultValue =
|
|
113
|
+
var defaultValue = dayjs().clone();
|
|
114
114
|
return /*#__PURE__*/React.createElement(Calendar, {
|
|
115
115
|
locale: initDateEditorLanguage(lang),
|
|
116
116
|
format: dateFormat,
|
|
@@ -165,7 +165,7 @@ var DateEditorPopover = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
165
165
|
|
|
166
166
|
_this.state = {
|
|
167
167
|
open: true,
|
|
168
|
-
datePickerValue: props.value ?
|
|
168
|
+
datePickerValue: props.value ? dayjs(props.value) : dayjs().clone()
|
|
169
169
|
};
|
|
170
170
|
_this.calendarContainerRef = React.createRef();
|
|
171
171
|
return _this;
|
|
@@ -3,7 +3,7 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
|
3
3
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
4
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
5
|
import React from 'react';
|
|
6
|
-
import
|
|
6
|
+
import dayjs from 'dayjs';
|
|
7
7
|
import DatePicker from '@seafile/seafile-calendar/lib/Picker';
|
|
8
8
|
import Calendar from '@seafile/seafile-calendar';
|
|
9
9
|
import { initDateEditorLanguage } from '../utils/editor-utils';
|
|
@@ -69,7 +69,7 @@ var PCDateEditorPopover = /*#__PURE__*/function (_React$Component) {
|
|
|
69
69
|
dateFormat = _this$props.dateFormat,
|
|
70
70
|
showHourAndMinute = _this$props.showHourAndMinute,
|
|
71
71
|
lang = _this$props.lang;
|
|
72
|
-
var defaultValue =
|
|
72
|
+
var defaultValue = dayjs().clone();
|
|
73
73
|
return /*#__PURE__*/React.createElement(Calendar, {
|
|
74
74
|
locale: initDateEditorLanguage(lang),
|
|
75
75
|
style: {
|
|
@@ -87,7 +87,7 @@ var PCDateEditorPopover = /*#__PURE__*/function (_React$Component) {
|
|
|
87
87
|
|
|
88
88
|
_this.state = {
|
|
89
89
|
open: true,
|
|
90
|
-
datePickerValue: props.value ?
|
|
90
|
+
datePickerValue: props.value ? dayjs(props.value) : null
|
|
91
91
|
};
|
|
92
92
|
_this.calendarContainerRef = React.createRef();
|
|
93
93
|
return _this;
|
|
@@ -4,7 +4,7 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
|
4
4
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import cn from 'astro-classname';
|
|
7
|
-
import
|
|
7
|
+
import dayjs from 'dayjs';
|
|
8
8
|
import './index.css';
|
|
9
9
|
|
|
10
10
|
var MTimeFormatter = /*#__PURE__*/function (_React$Component) {
|
|
@@ -24,7 +24,7 @@ var MTimeFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
24
24
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
25
25
|
|
|
26
26
|
_this.formatDate = function (date) {
|
|
27
|
-
return
|
|
27
|
+
return dayjs(date).format('YYYY-MM-DD HH:mm:ss');
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
return _this;
|
|
@@ -31,7 +31,9 @@ var RateFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
31
31
|
_ref$rate_max_number = _ref.rate_max_number,
|
|
32
32
|
rate_max_number = _ref$rate_max_number === void 0 ? 5 : _ref$rate_max_number,
|
|
33
33
|
_ref$rate_style_color = _ref.rate_style_color,
|
|
34
|
-
rate_style_color = _ref$rate_style_color === void 0 ? '#e5e5e5' : _ref$rate_style_color
|
|
34
|
+
rate_style_color = _ref$rate_style_color === void 0 ? '#e5e5e5' : _ref$rate_style_color,
|
|
35
|
+
_ref$rate_style_type = _ref.rate_style_type,
|
|
36
|
+
rate_style_type = _ref$rate_style_type === void 0 ? 'dtable-icon-rate' : _ref$rate_style_type;
|
|
35
37
|
|
|
36
38
|
var validValue = Math.min(rate_max_number, value);
|
|
37
39
|
var rateList = [];
|
|
@@ -39,7 +41,7 @@ var RateFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
39
41
|
for (var i = 0; i < validValue; i++) {
|
|
40
42
|
rateList.push( /*#__PURE__*/React.createElement("i", {
|
|
41
43
|
key: "dtable-ui-component-rate-".concat(i),
|
|
42
|
-
className: "dtable-font
|
|
44
|
+
className: "dtable-font ".concat(rate_style_type),
|
|
43
45
|
style: {
|
|
44
46
|
color: rate_style_color || '#e5e5e5'
|
|
45
47
|
}
|
|
@@ -44,9 +44,11 @@ var TextFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
44
44
|
containerClassName = _this$props.containerClassName,
|
|
45
45
|
value = _this$props.value;
|
|
46
46
|
var classname = cn('dtable-ui cell-formatter-container text-formatter', containerClassName);
|
|
47
|
+
var formattedValue = this.getFormattedValue(value);
|
|
47
48
|
return /*#__PURE__*/React.createElement("div", {
|
|
48
|
-
className: classname
|
|
49
|
-
|
|
49
|
+
className: classname,
|
|
50
|
+
title: formattedValue
|
|
51
|
+
}, formattedValue);
|
|
50
52
|
}
|
|
51
53
|
}]);
|
|
52
54
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable no-case-declarations */
|
|
2
|
-
import
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
3
|
import NP from './number-precision';
|
|
4
4
|
import { CellType, NUMBER_TYPES, DEFAULT_NUMBER_FORMAT, DURATION_FORMATS_MAP, DURATION_FORMATS, DURATION_ZERO_DISPLAY, DURATION_DECIMAL_DIGITS, FORMULA_RESULT_TYPE, COLLABORATOR_COLUMN_TYPES, ARRAY_FORMAL_COLUMNS_TYPES, DEFAULT_DATE_FORMAT } from '../constants';
|
|
5
5
|
NP.enableBoundaryChecking(false);
|
|
@@ -161,7 +161,7 @@ export var getDateDisplayString = function getDateDisplayString(value, format) {
|
|
|
161
161
|
return formattedValue;
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
var date =
|
|
164
|
+
var date = dayjs(value);
|
|
165
165
|
if (!date.isValid()) return value;
|
|
166
166
|
|
|
167
167
|
switch (format) {
|