dtable-ui-component 0.1.98 → 0.1.101

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.
@@ -28,7 +28,9 @@ var DurationFormatter = /*#__PURE__*/function (_React$Component) {
28
28
  var classname = cn('dtable-ui cell-formatter-container duration-formatter', containerClassName);
29
29
  return /*#__PURE__*/React.createElement("div", {
30
30
  className: classname
31
- }, getDurationDisplayString(value, format));
31
+ }, getDurationDisplayString(value, {
32
+ duration_format: format
33
+ }));
32
34
  }
33
35
  }]);
34
36
 
@@ -5,7 +5,8 @@ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
5
  import React from 'react';
6
6
  import isHotkey from 'is-hotkey';
7
7
  import { NUMBER_TYPES } from '../constants';
8
- import { getNumberDisplayString, formatStringToNumber, formatNumberString } from '../utils/value-format-utils';
8
+ import { getNumberDisplayString, formatStringToNumber, replaceNumberNotAllowInput } from '../utils/value-format-utils';
9
+ import { isMac } from '../utils/utils';
9
10
 
10
11
  var NumberEditor = /*#__PURE__*/function (_React$Component) {
11
12
  _inherits(NumberEditor, _React$Component);
@@ -51,12 +52,19 @@ var NumberEditor = /*#__PURE__*/function (_React$Component) {
51
52
  };
52
53
 
53
54
  _this.onChange = function (event) {
55
+ var data = _this.props.column.data; // data maybe 'null'
56
+
54
57
  var value = event.target.value.trim();
55
- value = formatNumberString(value, _this.dataFormat); // format the number in changing
58
+ var currency_symbol = null;
56
59
 
57
- if (value === _this.state.inputValue) {
58
- return;
59
- }
60
+ if (data && data.format === 'custom_currency') {
61
+ currency_symbol = data['currency_symbol'];
62
+ } //Prevent the repetition of periods bug in the Chinese input method of the Windows system
63
+
64
+
65
+ if (!isMac() && value.indexOf('.。') > -1) return;
66
+ value = replaceNumberNotAllowInput(value, _this.dataFormat, currency_symbol);
67
+ if (value === _this.state.inputValue) return;
60
68
 
61
69
  _this.setState({
62
70
  inputValue: value
@@ -122,6 +122,11 @@ var SimpleLongTextFormatter = /*#__PURE__*/function (_React$Component) {
122
122
  }
123
123
 
124
124
  _createClass(SimpleLongTextFormatter, [{
125
+ key: "componentWillUnmount",
126
+ value: function componentWillUnmount() {
127
+ this.clearTimer();
128
+ }
129
+ }, {
125
130
  key: "render",
126
131
  value: function render() {
127
132
  var _this2 = this;
@@ -9,7 +9,8 @@ var NUMBER_TYPES = {
9
9
  'PERCENT': 'percent',
10
10
  'YUAN': 'yuan',
11
11
  'EURO': 'euro',
12
- 'DOLLAR': 'dollar'
12
+ 'DOLLAR': 'dollar',
13
+ 'CUSTOM_CURRENCY': 'custom_currency'
13
14
  };
14
15
  var DATE_TYPES = {
15
16
  'D/M/YYYY': 'D/M/YYYY',
@@ -35,7 +36,10 @@ var DEFAULT_NUMBER_FORMAT = 'number';
35
36
  var DEFAULT_DATE_FORMAT = 'YYYY-MM-DD';
36
37
  var DURATION_FORMATS_MAP = {
37
38
  H_MM: 'h:mm',
38
- H_MM_SS: 'h:mm:ss'
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'
39
43
  };
40
44
  var DURATION_FORMATS = [{
41
45
  name: DURATION_FORMATS_MAP.H_MM,
@@ -44,6 +48,6 @@ var DURATION_FORMATS = [{
44
48
  name: DURATION_FORMATS_MAP.H_MM_SS,
45
49
  type: DURATION_FORMATS_MAP.H_MM_SS
46
50
  }];
47
- 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'), _DURATION_ZERO_DISPLA);
48
- 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), _DURATION_DECIMAL_DIG);
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);
49
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 };
package/lib/index.js CHANGED
@@ -4,7 +4,7 @@ export { default as toaster } from './toaster'; // Loading
4
4
  export { default as Loading } from './Loading';
5
5
  export { setLocale } from './lang'; // utils
6
6
 
7
- export { getDateDisplayString, getNumberDisplayString, formatStringToNumber, formatNumberString } from './utils/value-format-utils'; // formatter
7
+ export { getDateDisplayString, getNumberDisplayString, formatStringToNumber } from './utils/value-format-utils'; // formatter
8
8
 
9
9
  export { default as CheckboxFormatter } from './CheckboxFormatter';
10
10
  export { default as ImageFormatter } from './ImageFormatter';
@@ -1,3 +1,4 @@
1
+ import NP from './number-precision';
1
2
  export var debounce = function debounce(fn, wait) {
2
3
  var timeout = null;
3
4
  return function () {
@@ -22,4 +23,22 @@ export var throttle = function throttle(func, delay) {
22
23
  timer = setTimeout(func, remaining);
23
24
  }
24
25
  };
26
+ };
27
+ export var getFloatNumber = function getFloatNumber(data, format) {
28
+ if (!data && data !== 0) {
29
+ return null;
30
+ }
31
+
32
+ var newData = parseFloat(data.replace(/[^.-\d]/g, ''));
33
+
34
+ if (format === 'percent' && !isNaN(newData)) {
35
+ return NP.divide(newData, 100);
36
+ }
37
+
38
+ return isNaN(newData) ? null : newData;
39
+ };
40
+ export var isMac = function isMac() {
41
+ var platform = navigator.platform; // eslint-disable-next-line eqeqeq
42
+
43
+ return platform == 'Mac68K' || platform == 'MacPPC' || platform == 'Macintosh' || platform == 'MacIntel';
25
44
  };
@@ -2,6 +2,7 @@
2
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
+ import { getFloatNumber } from './utils';
5
6
  NP.enableBoundaryChecking(false);
6
7
  var _separatorMap = {
7
8
  'comma': ',',
@@ -9,6 +10,18 @@ var _separatorMap = {
9
10
  'no': '',
10
11
  'space': ' '
11
12
  };
13
+ /**
14
+ * @param {string} value
15
+ * e.g. removeZerosFromEnd('0.0100') // '0.01'
16
+ */
17
+
18
+ var removeZerosFromEnd = function removeZerosFromEnd(value) {
19
+ if (value.endsWith('0')) {
20
+ return value.replace(/(?:\.0*|(\.\d+?)0+)$/, '$1');
21
+ }
22
+
23
+ return value;
24
+ };
12
25
 
13
26
  var _toThousands = function _toThousands(num, isCurrency, formatData) {
14
27
  var _ref = formatData || {},
@@ -23,27 +36,53 @@ var _toThousands = function _toThousands(num, isCurrency, formatData) {
23
36
 
24
37
  var decimalString = _separatorMap[decimal];
25
38
  var thousandsString = _separatorMap[thousands];
39
+
40
+ if ((num + '').indexOf('e') > -1) {
41
+ if (num < 1 && num > -1) {
42
+ // 1.convert to non-scientific number
43
+ var numericString = num.toFixed(enable_precision ? precision : 8); // 2.remove 0 from end of the number which not set precision. e.g. 0.100000
44
+
45
+ if (!enable_precision) {
46
+ numericString = removeZerosFromEnd(numericString);
47
+ } // 3.remove minus from number which equal to 0. e.g. '-0.00'
48
+
49
+
50
+ if (parseFloat(numericString) === 0) {
51
+ return numericString.startsWith('-') ? numericString.substring(1) : numericString;
52
+ }
53
+
54
+ return numericString;
55
+ }
56
+
57
+ return num;
58
+ }
59
+
26
60
  var decimalDigits = enable_precision ? precision : _getDecimalDigits(num);
27
61
  var value = parseFloat(num.toFixed(decimalDigits));
28
- var integer = Math.trunc(value);
62
+ var isMinus = value < 0;
63
+ var integer = Math.trunc(value); // format decimal value
64
+
29
65
  var decimalValue = String(Math.abs(NP.minus(value, integer)).toFixed(decimalDigits)).slice(1);
30
66
 
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
- }
67
+ if (!enable_precision) {
68
+ decimalValue = removeZerosFromEnd(decimalValue);
69
+ }
37
70
 
38
- if (enable_precision) {
39
- decimalValue = precision === 0 ? '' : decimalValue.slice(0, precision + 1);
71
+ if (isCurrency) {
72
+ if (!enable_precision) {
73
+ if (decimalValue.length === 2) {
74
+ decimalValue = decimalValue.padEnd(3, '0');
75
+ } else {
76
+ decimalValue = (decimalValue.substring(0, 3) || '.').padEnd(3, '0');
77
+ }
40
78
  }
41
79
  }
42
80
 
43
- decimalValue = decimalValue.replace(/./, decimalString);
81
+ decimalValue = decimalValue.replace(/./, decimalString); // format integer value
82
+
44
83
  var result = [],
45
84
  counter = 0;
46
- integer = Object.is(integer, -0) ? ['-', '0'] : integer.toString().split('');
85
+ integer = Math.abs(integer).toString();
47
86
 
48
87
  for (var i = integer.length - 1; i >= 0; i--) {
49
88
  counter++;
@@ -54,7 +93,7 @@ var _toThousands = function _toThousands(num, isCurrency, formatData) {
54
93
  }
55
94
  }
56
95
 
57
- return result.join('') + decimalValue;
96
+ return (isMinus ? '-' : '') + result.join('') + decimalValue;
58
97
  };
59
98
 
60
99
  var _getDecimalDigits = function _getDecimalDigits(num) {
@@ -72,93 +111,148 @@ export var getNumberDisplayString = function getNumberDisplayString(value, forma
72
111
  var type = Object.prototype.toString.call(value);
73
112
 
74
113
  if (type !== '[object Number]') {
114
+ // return formula internal errors directly.
75
115
  if (type === '[object String]' && value.startsWith('#')) {
76
116
  return value;
77
117
  }
78
118
 
79
- return null;
119
+ return '';
80
120
  }
81
121
 
82
- if (isNaN(value) || value === Infinity || value === -Infinity || (value + '').indexOf('e') > -1) return value + '';
122
+ if (isNaN(value) || value === Infinity || value === -Infinity) return value + '';
83
123
 
84
124
  var _ref2 = formatData || {},
85
125
  _ref2$format = _ref2.format,
86
126
  format = _ref2$format === void 0 ? DEFAULT_NUMBER_FORMAT : _ref2$format;
87
127
 
88
128
  switch (format) {
89
- case 'number':
90
- return _toThousands(value, false, formatData);
129
+ case NUMBER_TYPES.NUMBER:
130
+ {
131
+ return _toThousands(value, false, formatData);
132
+ }
91
133
 
92
- case 'percent':
134
+ case NUMBER_TYPES.PERCENT:
93
135
  {
94
136
  return "".concat(_toThousands(Number.parseFloat((value * 100).toFixed(8)), false, formatData), "%");
95
137
  }
96
138
 
97
- case 'yuan':
98
- return "\uFFE5".concat(_toThousands(value, true, formatData));
139
+ case NUMBER_TYPES.YUAN:
140
+ {
141
+ return "\uFFE5".concat(_toThousands(value, true, formatData));
142
+ }
99
143
 
100
- case 'dollar':
101
- return "$".concat(_toThousands(value, true, formatData));
144
+ case NUMBER_TYPES.DOLLAR:
145
+ {
146
+ return "$".concat(_toThousands(value, true, formatData));
147
+ }
102
148
 
103
- case 'euro':
104
- return "\u20AC".concat(_toThousands(value, true, formatData));
149
+ case NUMBER_TYPES.EURO:
150
+ {
151
+ return "\u20AC".concat(_toThousands(value, true, formatData));
152
+ }
105
153
 
106
154
  case 'duration':
107
155
  {
108
- return getDurationDisplayString(value, formatData.duration_format);
156
+ return getDurationDisplayString(value, formatData);
157
+ }
158
+
159
+ case NUMBER_TYPES.CUSTOM_CURRENCY:
160
+ {
161
+ if (formatData.currency_symbol_position === 'after') {
162
+ return "".concat(_toThousands(value, true, formatData)).concat(formatData.currency_symbol || '');
163
+ } else {
164
+ return "".concat(formatData.currency_symbol || '').concat(_toThousands(value, true, formatData));
165
+ }
109
166
  }
110
167
 
111
168
  default:
112
169
  return '' + value;
113
170
  }
114
171
  };
115
- export var formatStringToNumber = function formatStringToNumber(value) {
116
- var isIncludePercent = value.indexOf('%') > -1;
117
- var newData = parseFloat(value.replace(/[^.-\d]/g, ''));
172
+ export var formatStringToNumber = function formatStringToNumber(numberString, formatData) {
173
+ var _ref3 = formatData || {},
174
+ format = _ref3.format,
175
+ decimal = _ref3.decimal,
176
+ thousands = _ref3.thousands,
177
+ enable_precision = _ref3.enable_precision,
178
+ precision = _ref3.precision;
179
+
180
+ var value = numberString;
181
+
182
+ if (decimal && thousands && decimal === 'comma') {
183
+ if (thousands === 'dot') {
184
+ value = value.replace(/,/, '@');
185
+ value = value.replace(/\./g, ',');
186
+ value = value.replace(/@/, '.');
187
+ } else {
188
+ value = value.replace(/\./g, '');
189
+ value = value.replace(/,/, '.');
190
+ }
191
+ }
192
+
193
+ value = getFloatNumber(value, format);
194
+
195
+ if (enable_precision && value) {
196
+ if (format === 'percent') {
197
+ precision += 2;
198
+ }
118
199
 
119
- if (isIncludePercent && !isNaN(newData)) {
120
- return newData / 100;
200
+ value = Number(parseFloat(value).toFixed(precision));
121
201
  }
122
202
 
123
- return isNaN(newData) ? '' : newData;
203
+ return value;
124
204
  };
125
- export var formatNumberString = function formatNumberString(value, format) {
126
- var formattedValue = '';
205
+ export var replaceNumberNotAllowInput = function replaceNumberNotAllowInput(value) {
206
+ var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_NUMBER_FORMAT;
207
+ var currency_symbol = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
208
+
209
+ if (!value) {
210
+ return '';
211
+ }
212
+
213
+ value = value.replace(/。/g, '.');
127
214
 
128
215
  switch (format) {
129
216
  case NUMBER_TYPES.NUMBER:
130
217
  case NUMBER_TYPES.NUMBER_WITH_COMMAS:
131
- formattedValue = value.replace(/[^.-\d,]/g, '');
132
- break;
218
+ {
219
+ return value.replace(/[^.-\d,]/g, '');
220
+ }
133
221
 
134
222
  case NUMBER_TYPES.PERCENT:
135
- formattedValue = value.replace(/[^.-\d,%]/g, '');
136
- break;
223
+ {
224
+ return value.replace(/[^.-\d,%]/g, '');
225
+ }
137
226
 
138
227
  case NUMBER_TYPES.YUAN:
139
- formattedValue = value.replace(/[^.-\d¥,]/g, '');
140
- break;
228
+ {
229
+ return value.replace(/[^.-\d¥¥,]/g, '');
230
+ }
141
231
 
142
232
  case NUMBER_TYPES.DOLLAR:
143
- formattedValue = value.replace(/[^.-\d$,]/g, '');
144
- break;
233
+ {
234
+ return value.replace(/[^.-\d$,]/g, '');
235
+ }
145
236
 
146
237
  case NUMBER_TYPES.EURO:
147
- formattedValue = value.replace(/[^.-\d€,]/g, '');
148
- break;
238
+ {
239
+ return value.replace(/[^.-\d€,]/g, '');
240
+ }
241
+
242
+ case NUMBER_TYPES.CUSTOM_CURRENCY:
243
+ {
244
+ // eslint-disable-next-line
245
+ var reg = new RegExp('[^.-\d' + currency_symbol + ',]', 'g');
246
+ return value.replace(reg, '');
247
+ }
149
248
 
150
249
  default:
151
- formattedValue = value.replace(/[^.-\d,]/g, '');
250
+ return value.replace(/[^.-\d,]/g, '');
152
251
  }
153
-
154
- return formattedValue;
155
252
  };
156
253
  export var getDateDisplayString = function getDateDisplayString(value, format) {
157
- var formattedValue = '';
158
-
159
- if (!value) {
160
- // value === '', value === undefine, value === null
161
- return formattedValue;
254
+ if (!value || typeof value !== 'string') {
255
+ return '';
162
256
  }
163
257
 
164
258
  var date = dayjs(value);
@@ -191,8 +285,46 @@ export var getDateDisplayString = function getDateDisplayString(value, format) {
191
285
  return date.format('YYYY-MM-DD');
192
286
  }
193
287
  };
194
- export var getDurationDisplayString = function getDurationDisplayString(value, duration_format) {
288
+
289
+ var _getMathRoundedDuration = function _getMathRoundedDuration(num, duration_format) {
290
+ var decimalDigits = DURATION_DECIMAL_DIGITS[duration_format];
291
+
292
+ if (decimalDigits < 1) {
293
+ return num;
294
+ }
295
+
296
+ var ratio = Math.pow(10, decimalDigits);
297
+ return Math.round(num * ratio) / ratio;
298
+ };
299
+
300
+ var _getDurationDecimalSuffix = function _getDurationDecimalSuffix(duration_format, decimal) {
301
+ if (duration_format === DURATION_FORMATS_MAP.H_MM_SS_S) {
302
+ return decimal === 0 ? '.0' : '';
303
+ } else if (duration_format === DURATION_FORMATS_MAP.H_MM_SS_SS) {
304
+ if (decimal === 0) {
305
+ return '.00';
306
+ } else if (decimal < 10) {
307
+ return '0';
308
+ }
309
+ } else if (duration_format === DURATION_FORMATS_MAP.H_MM_SS_SSS) {
310
+ if (decimal === 0) {
311
+ return '.000';
312
+ } else if (decimal < 10) {
313
+ return '00';
314
+ } else if (decimal < 100) {
315
+ return '0';
316
+ }
317
+ }
318
+
319
+ return '';
320
+ };
321
+
322
+ export var getDurationDisplayString = function getDurationDisplayString(value, data) {
195
323
  if (!value && value !== 0) return '';
324
+
325
+ var _ref4 = data || {},
326
+ duration_format = _ref4.duration_format;
327
+
196
328
  duration_format = duration_format || DURATION_FORMATS_MAP.H_MM;
197
329
 
198
330
  if (DURATION_FORMATS.findIndex(function (format) {
@@ -212,7 +344,7 @@ export var getDurationDisplayString = function getDurationDisplayString(value, d
212
344
  positiveValue = Math.round(positiveValue);
213
345
  }
214
346
 
215
- positiveValue = getMathRoundedDuration(positiveValue, duration_format);
347
+ positiveValue = _getMathRoundedDuration(positiveValue, duration_format);
216
348
  var decimalParts = (positiveValue + '').split('.');
217
349
  var decimalPartsLen = decimalParts.length;
218
350
  var decimal = 0;
@@ -223,7 +355,9 @@ export var getDurationDisplayString = function getDurationDisplayString(value, d
223
355
  }
224
356
 
225
357
  var decimalDigits = DURATION_DECIMAL_DIGITS[duration_format];
226
- var decimalSuffix = getDurationDecimalSuffix(duration_format, decimal);
358
+
359
+ var decimalSuffix = _getDurationDecimalSuffix(duration_format, decimal);
360
+
227
361
  var displayString = value < 0 ? '-' : '';
228
362
  var hours = parseInt(positiveValue / 3600);
229
363
  var minutes = parseInt((positiveValue - hours * 3600) / 60);
@@ -234,50 +368,11 @@ export var getDurationDisplayString = function getDurationDisplayString(value, d
234
368
  }
235
369
 
236
370
  var seconds = Number.parseFloat((positiveValue - hours * 3600 - minutes * 60).toFixed(decimalDigits));
237
-
238
- if (hours > 0) {
239
- displayString += "".concat(hours, ":");
240
- minutes = minutes > 9 ? minutes : "0".concat(minutes);
241
- }
242
-
371
+ minutes = minutes > 9 ? minutes : "0".concat(minutes);
243
372
  seconds = seconds > 9 ? seconds : "0".concat(seconds);
244
- displayString += "".concat(minutes, ":").concat(seconds).concat(decimalSuffix);
373
+ displayString += "".concat(hours, ":").concat(minutes, ":").concat(seconds).concat(decimalSuffix);
245
374
  return displayString;
246
375
  };
247
-
248
- var getMathRoundedDuration = function getMathRoundedDuration(num, duration_format) {
249
- var decimalDigits = DURATION_DECIMAL_DIGITS[duration_format];
250
-
251
- if (decimalDigits < 1) {
252
- return num;
253
- }
254
-
255
- var ratio = Math.pow(10, decimalDigits);
256
- return Math.round(num * ratio) / ratio;
257
- };
258
-
259
- var getDurationDecimalSuffix = function getDurationDecimalSuffix(duration_format, decimal) {
260
- if (duration_format === DURATION_FORMATS_MAP.H_MM_SS_S) {
261
- return decimal === 0 ? '.0' : '';
262
- } else if (duration_format === DURATION_FORMATS_MAP.H_MM_SS_SS) {
263
- if (decimal === 0) {
264
- return '.00';
265
- } else if (decimal < 10) {
266
- return '0';
267
- }
268
- } else if (duration_format === DURATION_FORMATS_MAP.H_MM_SS_SSS) {
269
- if (decimal === 0) {
270
- return '.000';
271
- } else if (decimal < 10) {
272
- return '00';
273
- } else if (decimal < 100) {
274
- return '0';
275
- }
276
- }
277
-
278
- return '';
279
- };
280
-
281
376
  export var getOptionName = function getOptionName(options, targetOptionID) {
282
377
  if (!targetOptionID || !options || !Array.isArray(options)) return null;
283
378
  var option = options.find(function (option) {
@@ -296,8 +391,8 @@ export var getMultipleOptionName = function getMultipleOptionName(options, cellV
296
391
  }).join(', ');
297
392
  };
298
393
  export var getLongtextDisplayString = function getLongtextDisplayString(value) {
299
- var _ref3 = value || {},
300
- text = _ref3.text;
394
+ var _ref5 = value || {},
395
+ text = _ref5.text;
301
396
 
302
397
  if (!text) {
303
398
  return null;
@@ -328,13 +423,13 @@ export var getCollaboratorsName = function getCollaboratorsName(collaborators, c
328
423
  return null;
329
424
  };
330
425
  export var getGeolocationDisplayString = function getGeolocationDisplayString(value, columnData) {
331
- var _ref4 = columnData || {},
332
- geo_format = _ref4.geo_format;
426
+ var _ref6 = columnData || {},
427
+ geo_format = _ref6.geo_format;
333
428
 
334
429
  var cellValue = value || {};
335
430
 
336
431
  if (!value) {
337
- return null;
432
+ return '';
338
433
  }
339
434
 
340
435
  if (geo_format === 'lng_lat' && value.lng && value.lat) {
@@ -361,9 +456,9 @@ export var getGeolocationDisplayString = function getGeolocationDisplayString(va
361
456
  return "".concat(province || '').concat(city || '').concat(district || '').concat(detail || '');
362
457
  };
363
458
  export var getFormulaDisplayString = function getFormulaDisplayString(cellValue, columnData) {
364
- var _ref5 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
365
- _ref5$collaborators = _ref5.collaborators,
366
- collaborators = _ref5$collaborators === void 0 ? [] : _ref5$collaborators;
459
+ var _ref7 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
460
+ _ref7$collaborators = _ref7.collaborators,
461
+ collaborators = _ref7$collaborators === void 0 ? [] : _ref7$collaborators;
367
462
 
368
463
  if (!columnData) {
369
464
  return null;
@@ -414,10 +509,10 @@ export var getFormulaDisplayString = function getFormulaDisplayString(cellValue,
414
509
  return cellValue;
415
510
  };
416
511
  export function getCellValueDisplayString(cellValue, type) {
417
- var _ref6 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
418
- data = _ref6.data,
419
- _ref6$collaborators = _ref6.collaborators,
420
- collaborators = _ref6$collaborators === void 0 ? [] : _ref6$collaborators;
512
+ var _ref8 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
513
+ data = _ref8.data,
514
+ _ref8$collaborators = _ref8.collaborators,
515
+ collaborators = _ref8$collaborators === void 0 ? [] : _ref8$collaborators;
421
516
 
422
517
  var newData = data || {};
423
518
 
@@ -461,9 +556,9 @@ export function getCellValueDisplayString(cellValue, type) {
461
556
 
462
557
  case CellType.DATE:
463
558
  {
464
- var _ref7 = newData || {},
465
- _ref7$format = _ref7.format,
466
- format = _ref7$format === void 0 ? DEFAULT_DATE_FORMAT : _ref7$format;
559
+ var _ref9 = newData || {},
560
+ _ref9$format = _ref9.format,
561
+ format = _ref9$format === void 0 ? DEFAULT_DATE_FORMAT : _ref9$format;
467
562
 
468
563
  return getDateDisplayString(cellValue, format);
469
564
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-ui-component",
3
- "version": "0.1.98",
3
+ "version": "0.1.101",
4
4
  "main": "./lib/index.js",
5
5
  "dependencies": {
6
6
  "@seafile/react-image-lightbox": "0.0.9",