dtable-ui-component 0.3.4 → 0.3.6-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/lib/AutoNumberFormatter/index.js +2 -2
  2. package/lib/ButtonFormatter/index.js +2 -2
  3. package/lib/CTimeFormatter/index.js +2 -2
  4. package/lib/CheckboxFormatter/index.js +2 -2
  5. package/lib/CollaboratorFormatter/index.js +2 -2
  6. package/lib/CreatorFormatter/index.js +2 -2
  7. package/lib/DTableSearchInput/index.js +2 -2
  8. package/lib/DateEditor/index.js +1 -1
  9. package/lib/DateFormatter/index.js +5 -17
  10. package/lib/DigitalSignFormatter/index.js +2 -2
  11. package/lib/DurationFormatter/index.js +3 -3
  12. package/lib/EmailFormatter/index.js +2 -2
  13. package/lib/FileFormatter/index.js +2 -2
  14. package/lib/FormulaFormatter/index.js +25 -7
  15. package/lib/FormulaFormatter/utils.js +91 -0
  16. package/lib/GeolocationFormatter/index.js +11 -6
  17. package/lib/HtmlLongTextFormatter/index.js +2 -2
  18. package/lib/ImageFormatter/images-lazy-load.js +1 -1
  19. package/lib/ImageFormatter/index.js +2 -2
  20. package/lib/ImagePreviewerLightbox/index.js +3 -3
  21. package/lib/LastModifierFormatter/index.js +2 -2
  22. package/lib/LinkEditor/index.js +1 -1
  23. package/lib/LinkFormatter/index.js +7 -8
  24. package/lib/MTimeFormatter/index.js +2 -2
  25. package/lib/MultipleSelectFormatter/index.js +2 -2
  26. package/lib/NumberEditor/index.js +1 -1
  27. package/lib/NumberFormatter/index.js +3 -3
  28. package/lib/RateFormatter/index.js +2 -2
  29. package/lib/RowExpandFormatter/index.js +7 -5
  30. package/lib/RowExpandLinkFormatter/collaborator-item-formatter.js +2 -6
  31. package/lib/RowExpandLinkFormatter/value-display-utils.js +10 -398
  32. package/lib/SimpleLongTextFormatter/index.js +2 -2
  33. package/lib/SingleSelectFormatter/index.js +2 -2
  34. package/lib/TextFormatter/index.js +2 -2
  35. package/lib/UrlFormatter/index.js +2 -2
  36. package/lib/constants/index.js +2 -33
  37. package/lib/data/dtable-value.js +1 -6
  38. package/lib/index.js +1 -3
  39. package/lib/utils/utils.js +0 -14
  40. package/package.json +4 -4
  41. package/lib/RowExpandLinkFormatter/column-data-constants.js +0 -20
  42. package/lib/RowExpandLinkFormatter/date-utils.js +0 -127
  43. package/lib/RowExpandLinkFormatter/formula-constants.js +0 -9
  44. package/lib/RowExpandLinkFormatter/number-precision.js +0 -116
  45. package/lib/constants/cell-types.js +0 -29
  46. package/lib/utils/number-precision.js +0 -164
  47. package/lib/utils/value-format-utils.js +0 -587
@@ -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 cn from 'astro-classname';
6
+ import classnames from 'classnames';
7
7
  import SelectItem from '../SelectItem';
8
8
  import './index.css';
9
9
 
@@ -49,7 +49,7 @@ var MultipleSelectFormatter = /*#__PURE__*/function (_React$PureComponent) {
49
49
  var _this$props2 = this.props,
50
50
  value = _this$props2.value,
51
51
  containerClassName = _this$props2.containerClassName;
52
- var classname = cn('dtable-ui cell-formatter-container multiple-select-formatter', containerClassName);
52
+ var classname = classnames('dtable-ui cell-formatter-container multiple-select-formatter', containerClassName);
53
53
 
54
54
  if (!value || Array.isArray(value) && value.length === 0) {
55
55
  return /*#__PURE__*/React.createElement("div", {
@@ -4,8 +4,8 @@ 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 isHotkey from 'is-hotkey';
7
+ import { getNumberDisplayString, formatStringToNumber, replaceNumberNotAllowInput } from '@seafile/dtable-utils';
7
8
  import { NUMBER_TYPES } from '../constants';
8
- import { getNumberDisplayString, formatStringToNumber, replaceNumberNotAllowInput } from '../utils/value-format-utils';
9
9
  import { isMac } from '../utils/utils';
10
10
 
11
11
  var NumberEditor = /*#__PURE__*/function (_React$Component) {
@@ -3,8 +3,8 @@ 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 cn from 'astro-classname';
7
- import { getNumberDisplayString } from '../utils/value-format-utils';
6
+ import classnames from 'classnames';
7
+ import { getNumberDisplayString } from '@seafile/dtable-utils';
8
8
  import './index.css';
9
9
 
10
10
  var NumberFormatter = /*#__PURE__*/function (_React$Component) {
@@ -25,7 +25,7 @@ var NumberFormatter = /*#__PURE__*/function (_React$Component) {
25
25
  number = _this$props.value,
26
26
  data = _this$props.data,
27
27
  containerClassName = _this$props.containerClassName;
28
- var classname = cn('dtable-ui cell-formatter-container number-formatter', containerClassName);
28
+ var classname = classnames('dtable-ui cell-formatter-container number-formatter', containerClassName);
29
29
 
30
30
  if (number || number === 0) {
31
31
  number = getNumberDisplayString(number, data);
@@ -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 cn from 'astro-classname';
6
+ import classnames from 'classnames';
7
7
  import './index.css';
8
8
 
9
9
  var RateFormatter = /*#__PURE__*/function (_React$Component) {
@@ -60,7 +60,7 @@ var RateFormatter = /*#__PURE__*/function (_React$Component) {
60
60
  var _this$props2 = this.props,
61
61
  number = _this$props2.value,
62
62
  containerClassName = _this$props2.containerClassName;
63
- var className = cn('dtable-ui cell-formatter-container rate-formatter', containerClassName);
63
+ var className = classnames('dtable-ui cell-formatter-container rate-formatter', containerClassName);
64
64
  if (!number) return null;
65
65
  var rateList = this.getRateList();
66
66
  return /*#__PURE__*/React.createElement("div", {
@@ -9,7 +9,7 @@ var _emptyTypeMap;
9
9
 
10
10
  import React from 'react';
11
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';
12
+ import { TextFormatter, NumberFormatter, CheckboxFormatter, DateFormatter, SingleSelectFormatter, MultipleSelectFormatter, CollaboratorFormatter, LongTextFormatter, GeolocationFormatter, CTimeFormatter, CreatorFormatter, LastModifierFormatter, MTimeFormatter, AutoNumberFormatter, UrlFormatter, EmailFormatter, DurationFormatter, RateFormatter, ButtonFormatter, RowExpandImageFormatter, RowExpandFileFormatter, RowExpandLinkFormatter, DigitalSignFormatter, FormulaFormatter } from '../index';
13
13
  import { CellType } from '../constants';
14
14
  import './index.css';
15
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);
@@ -274,12 +274,14 @@ var EditorFormatter = /*#__PURE__*/function (_React$Component) {
274
274
  case CellType.FORMULA:
275
275
  case CellType.LINK_FORMULA:
276
276
  {
277
- if (!cellValue && cellValue !== 0) {
277
+ if (!cellValue && cellValue !== 0 && cellValue !== false) {
278
278
  return _this.renderEmpty();
279
279
  }
280
280
 
281
- return /*#__PURE__*/React.createElement(TextFormatter, {
281
+ return /*#__PURE__*/React.createElement(FormulaFormatter, {
282
282
  value: cellValue,
283
+ column: column,
284
+ collaborators: collaborators,
283
285
  containerClassName: containerClassName
284
286
  });
285
287
  }
@@ -411,8 +413,8 @@ var EditorFormatter = /*#__PURE__*/function (_React$Component) {
411
413
  }
412
414
  }
413
415
  }, {
414
- key: "componentWillReceiveProps",
415
- value: function componentWillReceiveProps(nextProps) {
416
+ key: "UNSAFE_componentWillReceiveProps",
417
+ value: function UNSAFE_componentWillReceiveProps(nextProps) {
416
418
  this.calculateCollaboratorData(nextProps);
417
419
  }
418
420
  }, {
@@ -3,6 +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, { Component } from 'react';
6
+ import { isValidEmail } from '@seafile/dtable-utils';
6
7
  import CollaboratorItem from '../CollaboratorItem';
7
8
 
8
9
  var CollaboratorItemFormatter = /*#__PURE__*/function (_Component) {
@@ -17,11 +18,6 @@ var CollaboratorItemFormatter = /*#__PURE__*/function (_Component) {
17
18
 
18
19
  _this = _super.call(this, _props);
19
20
 
20
- _this.isValidEmail = function (email) {
21
- var reg = /^[A-Za-zd]+([-_.][A-Za-zd]+)*@([A-Za-zd]+[-.])+[A-Za-zd]{2,6}$/;
22
- return reg.test(email);
23
- };
24
-
25
21
  _this.calculateCollaboratorData = function (props) {
26
22
  var _this$props = _this.props,
27
23
  context = _this$props.context,
@@ -85,7 +81,7 @@ var CollaboratorItemFormatter = /*#__PURE__*/function (_Component) {
85
81
  return;
86
82
  }
87
83
 
88
- if (!_this.isValidEmail(cellValue)) {
84
+ if (!isValidEmail(cellValue)) {
89
85
  collaborator = {
90
86
  name: cellValue,
91
87
  avatar_url: defaultAvatarUrl
@@ -1,401 +1,13 @@
1
- import { CellType } from '../constants';
2
- import { isArrayFormalColumn } from './utils';
3
- import NP from './number-precision';
4
- import DateUtils from './date-utils';
5
- import { DURATION_FORMATS_MAP, DURATION_FORMATS, DURATION_ZERO_DISPLAY, DURATION_DECIMAL_DIGITS } from './column-data-constants';
6
- import { FORMULA_RESULT_TYPE } from './formula-constants';
7
- NP.enableBoundaryChecking(false);
8
- var DEFAULT_NUMBER_FORMAT = 'number';
9
- var COLLABORATOR_COLUMN_TYPES = [CellType.COLLABORATOR, CellType.CREATOR, CellType.LAST_MODIFIER];
1
+ import { CellType, getCellValueDisplayString } from '@seafile/dtable-utils';
10
2
  var DOWNLOAD_NAME_COLUMN_TYPES = [CellType.TEXT, CellType.NUMBER, CellType.DATE, CellType.COLLABORATOR, CellType.CREATOR, CellType.AUTO_NUMBER];
11
- var _separatorMap = {
12
- 'comma': ',',
13
- 'dot': '.',
14
- 'no': '',
15
- 'space': ' '
16
- };
17
-
18
- var _toThousands = function _toThousands(num, isCurrency, formatData) {
19
- var _ref = formatData || {},
20
- _ref$decimal = _ref.decimal,
21
- decimal = _ref$decimal === void 0 ? 'dot' : _ref$decimal,
22
- _ref$thousands = _ref.thousands,
23
- thousands = _ref$thousands === void 0 ? 'no' : _ref$thousands,
24
- _ref$precision = _ref.precision,
25
- precision = _ref$precision === void 0 ? 2 : _ref$precision,
26
- _ref$enable_precision = _ref.enable_precision,
27
- enable_precision = _ref$enable_precision === void 0 ? false : _ref$enable_precision;
28
-
29
- var decimalString = _separatorMap[decimal];
30
- var thousandsString = _separatorMap[thousands];
31
-
32
- if ((num + '').indexOf('e') > -1) {
33
- if (num < 1 && num > -1) {
34
- var _decimalDigits = enable_precision ? precision : 8;
35
-
36
- return num.toFixed(_decimalDigits);
37
- }
38
-
39
- return num;
40
- }
41
-
42
- var decimalDigits = enable_precision ? precision : _getDecimalDigits(num);
43
- var value = parseFloat(num.toFixed(decimalDigits));
44
- var isMinus = value < 0;
45
- var integer = Math.trunc(value); // format decimal value
46
-
47
- var decimalValue = String(Math.abs(NP.minus(value, integer)).toFixed(decimalDigits)).slice(1);
48
-
49
- if (isCurrency) {
50
- if (!enable_precision) {
51
- if (decimalValue.length === 2) {
52
- decimalValue = decimalValue.padEnd(3, '0');
53
- } else {
54
- decimalValue = (decimalValue.substring(0, 3) || '.').padEnd(3, '0');
55
- }
56
- }
57
- }
58
-
59
- decimalValue = decimalValue.replace(/./, decimalString); // format integer value
60
-
61
- var result = [],
62
- counter = 0;
63
- integer = Math.abs(integer).toString();
64
-
65
- for (var i = integer.length - 1; i >= 0; i--) {
66
- counter++;
67
- result.unshift(integer[i]);
68
-
69
- if (!(counter % 3) && i !== 0) {
70
- result.unshift(thousandsString);
71
- }
72
- }
73
-
74
- return (isMinus ? '-' : '') + result.join('') + decimalValue;
75
- };
76
-
77
- var _getDecimalDigits = function _getDecimalDigits(num) {
78
- if (Number.isInteger(num)) {
79
- return 0;
80
- }
81
-
82
- var valueArr = (num + '').split('.');
83
- var digitsLength = valueArr[1] ? valueArr[1].length : 8;
84
- return digitsLength > 8 ? 8 : digitsLength;
85
- };
86
-
87
- export var getNumberDisplayString = function getNumberDisplayString(value, formatData) {
88
- // formatData: old version maybe 'null'
89
- var type = Object.prototype.toString.call(value);
90
-
91
- if (type !== '[object Number]') {
92
- if (type === '[object String]' && value.startsWith('#')) {
93
- return value;
94
- }
95
-
96
- return null;
97
- }
98
-
99
- if (isNaN(value) || value === Infinity || value === -Infinity) return value + '';
100
-
101
- var _ref2 = formatData || {},
102
- _ref2$format = _ref2.format,
103
- format = _ref2$format === void 0 ? DEFAULT_NUMBER_FORMAT : _ref2$format;
104
-
105
- switch (format) {
106
- case 'number':
107
- return _toThousands(value, false, formatData);
108
-
109
- case 'percent':
110
- {
111
- return "".concat(_toThousands(Number.parseFloat((value * 100).toFixed(8)), false, formatData), "%");
112
- }
113
-
114
- case 'yuan':
115
- return "\uFFE5".concat(_toThousands(value, true, formatData));
116
-
117
- case 'dollar':
118
- return "$".concat(_toThousands(value, true, formatData));
119
-
120
- case 'euro':
121
- return "\u20AC".concat(_toThousands(value, true, formatData));
122
-
123
- case 'custom_currency':
124
- {
125
- return "".concat(formatData.currency_symbol || '').concat(_toThousands(value, true, formatData));
126
- }
127
-
128
- default:
129
- return '' + value;
130
- }
131
- };
132
-
133
- var getCollaboratorsName = function getCollaboratorsName(value, collaborators) {
134
- if (Array.isArray(value) && value.length > 0 && Array.isArray(collaborators)) {
135
- var collaboratorsName = [];
136
- value.forEach(function (item) {
137
- var collaborator = collaborators.find(function (c) {
138
- return c.email === item;
139
- });
140
-
141
- if (collaborator) {
142
- collaboratorsName.push(collaborator.name);
143
- }
144
- });
145
- return collaboratorsName.join(',');
146
- }
147
-
148
- return '';
149
- };
150
-
151
- var getOptionName = function getOptionName(options, targetOptionID) {
152
- if (!targetOptionID || !options || !Array.isArray(options)) return null;
153
- var option = options.find(function (option) {
154
- return option.id === targetOptionID;
155
- });
156
- return option ? option.name : null;
157
- };
158
-
159
- export var getMultipleOptionName = function getMultipleOptionName(options, cellVal) {
160
- if (!cellVal || !options || !Array.isArray(options)) return null;
161
- var selectedOptions = options.filter(function (option) {
162
- return cellVal.includes(option.id);
163
- });
164
- if (selectedOptions.length === 0) return null;
165
- return selectedOptions.map(function (option) {
166
- return option.name;
167
- }).join(', ');
168
- };
169
-
170
- var getLongtextDisplayString = function getLongtextDisplayString(value) {
171
- var _ref3 = value || {},
172
- text = _ref3.text;
173
-
174
- if (!text) {
175
- return null;
176
- }
177
-
178
- return text;
179
- };
180
-
181
3
  export var getCellDisplayValue = function getCellDisplayValue(record, column, collaborators) {
182
- var type = column.type,
183
- data = column.data,
184
- key = column.key;
185
- if (!DOWNLOAD_NAME_COLUMN_TYPES.includes(type)) return '';
186
- var cellValue = record[key];
187
-
188
- switch (type) {
189
- case CellType.NUMBER:
190
- {
191
- return getNumberDisplayString(cellValue, data);
192
- }
193
-
194
- case CellType.DATE:
195
- {
196
- if (!cellValue || typeof cellValue !== 'string') return '';
197
-
198
- var _ref4 = data || {},
199
- format = _ref4.format;
200
-
201
- return DateUtils.format(cellValue, format);
202
- }
203
-
204
- case CellType.COLLABORATOR:
205
- {
206
- if (!Array.isArray(cellValue)) return '';
207
- return getCollaboratorsName(cellValue, collaborators);
208
- }
209
-
210
- case CellType.CREATOR:
211
- case CellType.LAST_MODIFIER:
212
- {
213
- if (!cellValue) return '';
214
- if (cellValue === 'anonymous') return cellValue;
215
- return getCollaboratorsName([cellValue], collaborators);
216
- }
217
-
218
- case CellType.SINGLE_SELECT:
219
- {
220
- if (!data) return '';
221
- var options = data.options;
222
- return getOptionName(options, cellValue);
223
- }
224
-
225
- case CellType.MULTIPLE_SELECT:
226
- {
227
- if (!data) return '';
228
-
229
- var _data$options = data.options,
230
- _options = _data$options === void 0 ? [] : _data$options;
231
-
232
- return getMultipleOptionName(_options, cellValue);
233
- }
234
-
235
- case CellType.FORMULA:
236
- case CellType.LINK_FORMULA:
237
- {
238
- return getFormulaDisplayString(cellValue, data, collaborators);
239
- }
240
-
241
- case CellType.LONG_TEXT:
242
- {
243
- return getLongtextDisplayString(cellValue);
244
- }
245
-
246
- case CellType.DURATION:
247
- {
248
- return getDurationDisplayString(cellValue, data);
249
- }
250
-
251
- case CellType.CTIME:
252
- case CellType.MTIME:
253
- {
254
- return DateUtils.format(cellValue.replace('T', ' ').replace('Z', ''), 'YYYY-MM-DD HH:MM:SS');
255
- }
256
-
257
- default:
258
- {
259
- return cellValue ? cellValue + '' : '';
260
- }
261
- }
262
- };
263
-
264
- var getFormulaDisplayString = function getFormulaDisplayString(cellValue, columnData, collaborators) {
265
- if (!columnData) return null;
266
- var result_type = columnData.result_type;
267
-
268
- if (result_type === FORMULA_RESULT_TYPE.NUMBER) {
269
- return getNumberDisplayString(cellValue, columnData);
270
- }
271
-
272
- if (result_type === FORMULA_RESULT_TYPE.DATE) {
273
- var format = columnData.format;
274
- return DateUtils.format(cellValue, format);
275
- }
276
-
277
- if (result_type === FORMULA_RESULT_TYPE.ARRAY) {
278
- var array_type = columnData.array_type,
279
- array_data = columnData.array_data;
280
-
281
- if (!array_type) {
282
- return null;
283
- }
284
-
285
- if (COLLABORATOR_COLUMN_TYPES.includes(array_type)) {
286
- return cellValue;
287
- }
288
-
289
- if (isArrayFormalColumn(array_type) && Array.isArray(cellValue)) {
290
- return cellValue.map(function (val) {
291
- return getCellDisplayValue({
292
- 'FORMULA_ARRAY': val
293
- }, {
294
- type: 'array_type',
295
- key: 'FORMULA_ARRAY',
296
- data: array_data
297
- }, collaborators);
298
- }).join(', ');
299
- }
300
-
301
- return getCellDisplayValue({
302
- 'FORMULA_ARRAY': cellValue
303
- }, {
304
- type: 'array_type',
305
- key: 'FORMULA_ARRAY',
306
- data: array_data
307
- }, collaborators);
308
- }
309
-
310
- if (Object.prototype.toString.call(cellValue) === '[object Boolean]') {
311
- return cellValue + '';
312
- }
313
-
314
- return cellValue;
315
- };
316
-
317
- function getMathRoundedDuration(num, duration_format) {
318
- var decimalDigits = DURATION_DECIMAL_DIGITS[duration_format];
319
-
320
- if (decimalDigits < 1) {
321
- return num;
322
- }
323
-
324
- var ratio = Math.pow(10, decimalDigits);
325
- return Math.round(num * ratio) / ratio;
326
- }
327
-
328
- function getDurationDecimalSuffix(duration_format, decimal) {
329
- if (duration_format === DURATION_FORMATS_MAP.H_MM_SS_S) {
330
- return decimal === 0 ? '.0' : '';
331
- } else if (duration_format === DURATION_FORMATS_MAP.H_MM_SS_SS) {
332
- if (decimal === 0) {
333
- return '.00';
334
- } else if (decimal < 10) {
335
- return '0';
336
- }
337
- } else if (duration_format === DURATION_FORMATS_MAP.H_MM_SS_SSS) {
338
- if (decimal === 0) {
339
- return '.000';
340
- } else if (decimal < 10) {
341
- return '00';
342
- } else if (decimal < 100) {
343
- return '0';
344
- }
345
- }
346
-
347
- return '';
348
- }
349
-
350
- export var getDurationDisplayString = function getDurationDisplayString(value, data) {
351
- if (!value && value !== 0) return '';
352
-
353
- var _ref5 = data || {},
354
- duration_format = _ref5.duration_format;
355
-
356
- duration_format = duration_format || DURATION_FORMATS_MAP.H_MM;
357
-
358
- if (DURATION_FORMATS.findIndex(function (format) {
359
- return format.type === duration_format;
360
- }) < 0) {
361
- return '';
362
- }
363
-
364
- if (value === 0) {
365
- return DURATION_ZERO_DISPLAY[duration_format];
366
- }
367
-
368
- var includeDecimal = duration_format.indexOf('.') > -1;
369
- var positiveValue = Math.abs(value);
370
-
371
- if (!includeDecimal) {
372
- positiveValue = Math.round(positiveValue);
373
- }
374
-
375
- positiveValue = getMathRoundedDuration(positiveValue, duration_format);
376
- var decimalParts = (positiveValue + '').split('.');
377
- var decimalPartsLen = decimalParts.length;
378
- var decimal = 0;
379
-
380
- if (decimalPartsLen > 1) {
381
- decimal = decimalParts[decimalPartsLen - 1];
382
- decimal = decimal ? decimal - 0 : 0;
383
- }
384
-
385
- var decimalDigits = DURATION_DECIMAL_DIGITS[duration_format];
386
- var decimalSuffix = getDurationDecimalSuffix(duration_format, decimal);
387
- var displayString = value < 0 ? '-' : '';
388
- var hours = parseInt(positiveValue / 3600);
389
- var minutes = parseInt((positiveValue - hours * 3600) / 60);
390
-
391
- if (duration_format === DURATION_FORMATS_MAP.H_MM) {
392
- displayString += "".concat(hours, ":").concat(minutes > 9 ? minutes : '0' + minutes);
393
- return displayString;
394
- }
395
-
396
- var seconds = Number.parseFloat((positiveValue - hours * 3600 - minutes * 60).toFixed(decimalDigits));
397
- minutes = minutes > 9 ? minutes : "0".concat(minutes);
398
- seconds = seconds > 9 ? seconds : "0".concat(seconds);
399
- displayString += "".concat(hours, ":").concat(minutes, ":").concat(seconds).concat(decimalSuffix);
400
- return displayString;
4
+ if (!column || !DOWNLOAD_NAME_COLUMN_TYPES.includes(column.type)) return '';
5
+ var key = column.key,
6
+ type = column.type,
7
+ data = column.data;
8
+ return getCellValueDisplayString(record, type, key, {
9
+ data: data,
10
+ collaborators: collaborators,
11
+ geolocationHyphen: ' '
12
+ });
401
13
  };
@@ -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 cn from 'astro-classname';
6
+ import classnames from 'classnames';
7
7
  import getPreviewContent from './normalize-long-text-value';
8
8
  import LongTextPreview from './widgets/LongTextPreview';
9
9
  import ModalPortal from '../ModalPortal';
@@ -133,7 +133,7 @@ var SimpleLongTextFormatter = /*#__PURE__*/function (_React$Component) {
133
133
 
134
134
  var isPreview = this.state.isPreview;
135
135
  var containerClassName = this.props.containerClassName;
136
- var className = cn('dtable-ui cell-formatter-container long-text-formatter', containerClassName);
136
+ var className = classnames('dtable-ui cell-formatter-container long-text-formatter', containerClassName);
137
137
  var value = this.translateValue();
138
138
  return /*#__PURE__*/React.createElement("div", {
139
139
  className: className,
@@ -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 cn from 'astro-classname';
6
+ import classnames from 'classnames';
7
7
  import SelectItem from '../SelectItem';
8
8
  import './index.css';
9
9
 
@@ -49,7 +49,7 @@ var SingleSelectFormatter = /*#__PURE__*/function (_React$PureComponent) {
49
49
  var _this$props2 = this.props,
50
50
  containerClassName = _this$props2.containerClassName,
51
51
  value = _this$props2.value;
52
- var classname = cn('dtable-ui cell-formatter-container single-select-formatter', containerClassName);
52
+ var classname = classnames('dtable-ui cell-formatter-container single-select-formatter', containerClassName);
53
53
  return /*#__PURE__*/React.createElement("div", {
54
54
  className: classname
55
55
  }, value ? this.getOption() : '');
@@ -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 cn from 'astro-classname';
6
+ import classnames from 'classnames';
7
7
  import './index.css';
8
8
 
9
9
  var TextFormatter = /*#__PURE__*/function (_React$Component) {
@@ -43,7 +43,7 @@ var TextFormatter = /*#__PURE__*/function (_React$Component) {
43
43
  var _this$props = this.props,
44
44
  containerClassName = _this$props.containerClassName,
45
45
  value = _this$props.value;
46
- var classname = cn('dtable-ui cell-formatter-container text-formatter', containerClassName);
46
+ var classname = classnames('dtable-ui cell-formatter-container text-formatter', containerClassName);
47
47
  var formattedValue = this.getFormattedValue(value);
48
48
  return /*#__PURE__*/React.createElement("div", {
49
49
  className: classname,
@@ -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 cn from 'astro-classname';
6
+ import classnames from 'classnames';
7
7
  import './index.css';
8
8
 
9
9
  var UrlFormatter = /*#__PURE__*/function (_React$Component) {
@@ -23,7 +23,7 @@ var UrlFormatter = /*#__PURE__*/function (_React$Component) {
23
23
  var _this$props = this.props,
24
24
  containerClassName = _this$props.containerClassName,
25
25
  value = _this$props.value;
26
- var classname = cn('dtable-ui cell-formatter-container url-formatter', containerClassName);
26
+ var classname = classnames('dtable-ui cell-formatter-container url-formatter', containerClassName);
27
27
  return /*#__PURE__*/React.createElement("div", {
28
28
  className: classname
29
29
  }, value);
@@ -1,8 +1,4 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
-
3
- var _DURATION_ZERO_DISPLA, _DURATION_DECIMAL_DIG;
4
-
5
- import * as CellType from './cell-types';
1
+ import { CellType, FORMULA_RESULT_TYPE } from '@seafile/dtable-utils';
6
2
  var NUMBER_TYPES = {
7
3
  'NUMBER': 'number',
8
4
  'NUMBER_WITH_COMMAS': 'number-with-commas',
@@ -20,34 +16,7 @@ var DATE_TYPES = {
20
16
  'YYYY-MM-DD': 'YYYY-MM-DD',
21
17
  'YYYY-MM-DD HH:mm': 'YYYY-MM-DD HH:mm'
22
18
  };
23
- var FORMULA_RESULT_TYPE = {
24
- NUMBER: 'number',
25
- STRING: 'string',
26
- DATE: 'date',
27
- BOOL: 'bool',
28
- ARRAY: 'array'
29
- };
30
19
  var SIMPLE_CELL_COLUMNS = [CellType.TEXT, CellType.NUMBER, CellType.DATE, CellType.CTIME, CellType.MTIME, CellType.GEOLOCATION, CellType.AUTO_NUMBER, CellType.URL, CellType.EMAIL, CellType.DURATION, CellType.CHECKBOX, CellType.RATE];
31
20
  var ARRAY_FORMAL_COLUMNS = [CellType.IMAGE, CellType.FILE, CellType.MULTIPLE_SELECT, CellType.COLLABORATOR];
32
21
  var SIMPLE_CELL_FORMULA_RESULTS = [FORMULA_RESULT_TYPE.NUMBER, FORMULA_RESULT_TYPE.STRING, FORMULA_RESULT_TYPE.DATE, FORMULA_RESULT_TYPE.BOOL];
33
- var COLLABORATOR_COLUMN_TYPES = [CellType.COLLABORATOR, CellType.CREATOR, CellType.LAST_MODIFIER];
34
- var ARRAY_FORMAL_COLUMNS_TYPES = [CellType.IMAGE, CellType.FILE, CellType.MULTIPLE_SELECT, CellType.COLLABORATOR];
35
- var DEFAULT_NUMBER_FORMAT = 'number';
36
- var DEFAULT_DATE_FORMAT = 'YYYY-MM-DD';
37
- var DURATION_FORMATS_MAP = {
38
- H_MM: 'h:mm',
39
- H_MM_SS: 'h:mm:ss',
40
- H_MM_SS_S: 'h:mm:ss.s',
41
- H_MM_SS_SS: 'h:mm:ss.ss',
42
- H_MM_SS_SSS: 'h:mm:ss.sss'
43
- };
44
- var DURATION_FORMATS = [{
45
- name: DURATION_FORMATS_MAP.H_MM,
46
- type: DURATION_FORMATS_MAP.H_MM
47
- }, {
48
- name: DURATION_FORMATS_MAP.H_MM_SS,
49
- type: DURATION_FORMATS_MAP.H_MM_SS
50
- }];
51
- var DURATION_ZERO_DISPLAY = (_DURATION_ZERO_DISPLA = {}, _defineProperty(_DURATION_ZERO_DISPLA, DURATION_FORMATS_MAP.H_MM, '0:00'), _defineProperty(_DURATION_ZERO_DISPLA, DURATION_FORMATS_MAP.H_MM_SS, '0:00'), _defineProperty(_DURATION_ZERO_DISPLA, DURATION_FORMATS_MAP.H_MM_SS_S, '0:00.0'), _defineProperty(_DURATION_ZERO_DISPLA, DURATION_FORMATS_MAP.H_MM_SS_SS, '0:00.00'), _defineProperty(_DURATION_ZERO_DISPLA, DURATION_FORMATS_MAP.H_MM_SS_SSS, '0:00.000'), _DURATION_ZERO_DISPLA);
52
- var DURATION_DECIMAL_DIGITS = (_DURATION_DECIMAL_DIG = {}, _defineProperty(_DURATION_DECIMAL_DIG, DURATION_FORMATS_MAP.H_MM, 0), _defineProperty(_DURATION_DECIMAL_DIG, DURATION_FORMATS_MAP.H_MM_SS, 0), _defineProperty(_DURATION_DECIMAL_DIG, DURATION_FORMATS_MAP.H_MM_SS_S, 1), _defineProperty(_DURATION_DECIMAL_DIG, DURATION_FORMATS_MAP.H_MM_SS_SS, 2), _defineProperty(_DURATION_DECIMAL_DIG, DURATION_FORMATS_MAP.H_MM_SS_SSS, 3), _DURATION_DECIMAL_DIG);
53
- export { CellType, NUMBER_TYPES, DATE_TYPES, FORMULA_RESULT_TYPE, SIMPLE_CELL_COLUMNS, ARRAY_FORMAL_COLUMNS, SIMPLE_CELL_FORMULA_RESULTS, COLLABORATOR_COLUMN_TYPES, ARRAY_FORMAL_COLUMNS_TYPES, DEFAULT_NUMBER_FORMAT, DEFAULT_DATE_FORMAT, DURATION_FORMATS_MAP, DURATION_FORMATS, DURATION_ZERO_DISPLAY, DURATION_DECIMAL_DIGITS };
22
+ export { CellType, NUMBER_TYPES, DATE_TYPES, FORMULA_RESULT_TYPE, SIMPLE_CELL_COLUMNS, ARRAY_FORMAL_COLUMNS, SIMPLE_CELL_FORMULA_RESULTS };