dtable-utils 0.0.3-beta.1 → 0.0.3

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 (152) hide show
  1. package/README.md +2 -30
  2. package/dist/index.js +1 -1
  3. package/es/cell-value-get/cell-value.js +19 -227
  4. package/es/cell-value-get/collaborator.js +3 -9
  5. package/es/cell-value-get/digital-sign.js +1 -1
  6. package/es/cell-value-get/duration.js +1 -1
  7. package/es/cell-value-get/geolocation.js +5 -29
  8. package/es/cell-value-get/long-text.js +1 -1
  9. package/es/cell-value-get/number.js +18 -42
  10. package/es/cell-value-get/option.js +7 -17
  11. package/es/cell-value-set/number.js +1 -53
  12. package/es/column/{core.js → common.js} +14 -2
  13. package/es/column/date.js +1 -1
  14. package/es/column/number.js +1 -1
  15. package/es/common.js +10 -9
  16. package/es/constants/column.js +2 -127
  17. package/es/constants/filter/index.js +1 -5
  18. package/es/date.js +1 -1
  19. package/es/index.js +10 -62
  20. package/es/validate/filter.js +1 -1
  21. package/lib/cell-value-get/cell-value.js +18 -231
  22. package/lib/cell-value-get/collaborator.js +2 -9
  23. package/lib/cell-value-get/digital-sign.js +1 -1
  24. package/lib/cell-value-get/duration.js +1 -0
  25. package/lib/cell-value-get/geolocation.js +5 -30
  26. package/lib/cell-value-get/long-text.js +1 -1
  27. package/lib/cell-value-get/number.js +17 -42
  28. package/lib/cell-value-get/option.js +6 -18
  29. package/lib/cell-value-set/number.js +0 -53
  30. package/lib/column/{core.js → common.js} +14 -1
  31. package/lib/column/date.js +2 -2
  32. package/lib/column/number.js +3 -3
  33. package/lib/common.js +11 -13
  34. package/lib/constants/column.js +1 -134
  35. package/lib/constants/filter/index.js +0 -5
  36. package/lib/index.js +8 -176
  37. package/lib/validate/filter.js +3 -3
  38. package/package.json +3 -5
  39. package/es/cell-value-get/rate.js +0 -6
  40. package/es/cell-value-set/date.js +0 -20
  41. package/es/color/gradient-color.js +0 -100
  42. package/es/column/color.js +0 -415
  43. package/es/column/option.js +0 -115
  44. package/es/constants/color.js +0 -16
  45. package/es/constants/column-permission.js +0 -7
  46. package/es/constants/grid-header.js +0 -6
  47. package/es/constants/group.js +0 -23
  48. package/es/constants/limit.js +0 -3
  49. package/es/constants/reg.js +0 -4
  50. package/es/constants/row-color.js +0 -11
  51. package/es/constants/sort.js +0 -11
  52. package/es/filter/core.js +0 -287
  53. package/es/filter/filter-column/array.js +0 -82
  54. package/es/filter/filter-column/checkbox.js +0 -8
  55. package/es/filter/filter-column/collaborator.js +0 -67
  56. package/es/filter/filter-column/creator.js +0 -50
  57. package/es/filter/filter-column/date.js +0 -59
  58. package/es/filter/filter-column/digital-sign.js +0 -26
  59. package/es/filter/filter-column/file.js +0 -24
  60. package/es/filter/filter-column/formula.js +0 -49
  61. package/es/filter/filter-column/geolocation.js +0 -53
  62. package/es/filter/filter-column/link.js +0 -12
  63. package/es/filter/filter-column/long-text.js +0 -25
  64. package/es/filter/filter-column/multiple-select.js +0 -60
  65. package/es/filter/filter-column/number.js +0 -93
  66. package/es/filter/filter-column/single-select.js +0 -41
  67. package/es/filter/filter-column/text.js +0 -55
  68. package/es/filter/filter-row.js +0 -198
  69. package/es/group/core.js +0 -107
  70. package/es/group/group-row.js +0 -366
  71. package/es/link/core.js +0 -78
  72. package/es/number.js +0 -13
  73. package/es/row/color.js +0 -278
  74. package/es/row/core.js +0 -161
  75. package/es/sort/core.js +0 -32
  76. package/es/sort/sort-column/array.js +0 -63
  77. package/es/sort/sort-column/checkbox.js +0 -15
  78. package/es/sort/sort-column/collaborator.js +0 -9
  79. package/es/sort/sort-column/date.js +0 -25
  80. package/es/sort/sort-column/formula.js +0 -40
  81. package/es/sort/sort-column/link.js +0 -23
  82. package/es/sort/sort-column/multiple-select.js +0 -45
  83. package/es/sort/sort-column/number.js +0 -18
  84. package/es/sort/sort-column/single-select.js +0 -22
  85. package/es/sort/sort-column/text.js +0 -47
  86. package/es/sort/sort-row.js +0 -126
  87. package/es/table/column.js +0 -27
  88. package/es/table/core.js +0 -14
  89. package/es/table/index.js +0 -14
  90. package/es/table/row.js +0 -25
  91. package/es/validate/geolocation.js +0 -5
  92. package/es/view/core.js +0 -135
  93. package/es/view/formula.js +0 -143
  94. package/es/view/group.js +0 -32
  95. package/es/view/summaries.js +0 -179
  96. package/lib/cell-value-get/rate.js +0 -10
  97. package/lib/cell-value-set/date.js +0 -24
  98. package/lib/color/gradient-color.js +0 -110
  99. package/lib/column/color.js +0 -424
  100. package/lib/column/option.js +0 -123
  101. package/lib/constants/color.js +0 -20
  102. package/lib/constants/column-permission.js +0 -11
  103. package/lib/constants/grid-header.js +0 -10
  104. package/lib/constants/group.js +0 -36
  105. package/lib/constants/limit.js +0 -7
  106. package/lib/constants/reg.js +0 -9
  107. package/lib/constants/row-color.js +0 -17
  108. package/lib/constants/sort.js +0 -18
  109. package/lib/filter/core.js +0 -301
  110. package/lib/filter/filter-column/array.js +0 -86
  111. package/lib/filter/filter-column/checkbox.js +0 -12
  112. package/lib/filter/filter-column/collaborator.js +0 -75
  113. package/lib/filter/filter-column/creator.js +0 -54
  114. package/lib/filter/filter-column/date.js +0 -63
  115. package/lib/filter/filter-column/digital-sign.js +0 -30
  116. package/lib/filter/filter-column/file.js +0 -28
  117. package/lib/filter/filter-column/formula.js +0 -53
  118. package/lib/filter/filter-column/geolocation.js +0 -57
  119. package/lib/filter/filter-column/link.js +0 -16
  120. package/lib/filter/filter-column/long-text.js +0 -29
  121. package/lib/filter/filter-column/multiple-select.js +0 -68
  122. package/lib/filter/filter-column/number.js +0 -97
  123. package/lib/filter/filter-column/single-select.js +0 -45
  124. package/lib/filter/filter-column/text.js +0 -59
  125. package/lib/filter/filter-row.js +0 -204
  126. package/lib/group/core.js +0 -117
  127. package/lib/group/group-row.js +0 -377
  128. package/lib/link/core.js +0 -90
  129. package/lib/number.js +0 -18
  130. package/lib/row/color.js +0 -286
  131. package/lib/row/core.js +0 -170
  132. package/lib/sort/core.js +0 -37
  133. package/lib/sort/sort-column/array.js +0 -67
  134. package/lib/sort/sort-column/checkbox.js +0 -19
  135. package/lib/sort/sort-column/collaborator.js +0 -13
  136. package/lib/sort/sort-column/date.js +0 -29
  137. package/lib/sort/sort-column/formula.js +0 -44
  138. package/lib/sort/sort-column/link.js +0 -27
  139. package/lib/sort/sort-column/multiple-select.js +0 -50
  140. package/lib/sort/sort-column/number.js +0 -22
  141. package/lib/sort/sort-column/single-select.js +0 -26
  142. package/lib/sort/sort-column/text.js +0 -52
  143. package/lib/sort/sort-row.js +0 -136
  144. package/lib/table/column.js +0 -32
  145. package/lib/table/core.js +0 -18
  146. package/lib/table/index.js +0 -18
  147. package/lib/table/row.js +0 -30
  148. package/lib/validate/geolocation.js +0 -9
  149. package/lib/view/core.js +0 -144
  150. package/lib/view/formula.js +0 -150
  151. package/lib/view/group.js +0 -36
  152. package/lib/view/summaries.js +0 -185
@@ -5,7 +5,7 @@ import { CellType } from '../constants/cell-type.js';
5
5
  import { COLLABORATOR_COLUMN_TYPES } from '../constants/column.js';
6
6
  import { FORMULA_COLUMN_TYPES_MAP, FORMULA_RESULT_TYPE } from '../constants/formula.js';
7
7
  import { FILTER_ERR_MSG } from '../constants/filter/index.js';
8
- import { getColumnOptions } from '../column/option.js';
8
+ import { getColumnOptions } from '../column/common.js';
9
9
  import { isDateColumn } from '../column/date.js';
10
10
  import { FILTER_PREDICATE_TYPE } from '../constants/filter/filter-predicate.js';
11
11
  import { FILTER_TERM_MODIFIER_TYPE } from '../constants/filter/filter-modifier.js';
@@ -2,7 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var _defineProperty = require('@babel/runtime/helpers/defineProperty');
5
+ var cellType = require('../constants/cell-type.js');
6
+ var column = require('../constants/column.js');
7
+ var formula = require('../constants/formula.js');
6
8
  var date$1 = require('../date.js');
7
9
  var collaborator = require('./collaborator.js');
8
10
  var date = require('./date.js');
@@ -12,63 +14,8 @@ var geolocation = require('./geolocation.js');
12
14
  var longText = require('./long-text.js');
13
15
  var number = require('./number.js');
14
16
  var option = require('./option.js');
15
- var cellType = require('../constants/cell-type.js');
16
- var column = require('../constants/column.js');
17
- var formula = require('../constants/formula.js');
18
-
19
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
20
-
21
- var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
22
17
 
23
18
  var ARRAY_VALUE_COLUMN_TYPES = [cellType.CellType.IMAGE, cellType.CellType.FILE, cellType.CellType.MULTIPLE_SELECT, cellType.CellType.COLLABORATOR];
24
- var _getArrayColumnCellValue = function _getArrayColumnCellValue(cellValue, column, _ref) {
25
- var collaborators = _ref.collaborators,
26
- isArchiveView = _ref.isArchiveView;
27
- if (!cellValue || !Array.isArray(cellValue) || cellValue.length === 0) {
28
- return '';
29
- }
30
- var key = column.key,
31
- data = column.data;
32
- var _ref2 = data || {},
33
- array_type = _ref2.array_type,
34
- array_data = _ref2.array_data;
35
- var newColumn = {
36
- key: key,
37
- type: array_type,
38
- data: array_data
39
- };
40
- // cellValue itself is an array
41
- if ([cellType.CellType.FILE, cellType.CellType.IMAGE, cellType.CellType.COLLABORATOR, cellType.CellType.MULTIPLE_SELECT].includes(array_type)) {
42
- return getCellValueStringResult(_defineProperty__default["default"]({}, key, cellValue), newColumn, {
43
- collaborators: collaborators
44
- });
45
- }
46
-
47
- // cellValue itself is a single value
48
- if (array_type === cellType.CellType.STRING) {
49
- newColumn.type = cellType.CellType.TEXT;
50
- var _result = cellValue.map(function (item) {
51
- return getCellValueStringResult(_defineProperty__default["default"]({}, key, item), newColumn);
52
- });
53
- return _result.filter(Boolean).join(', ');
54
- }
55
- if (array_type === cellType.CellType.BOOL) {
56
- newColumn.type = cellType.CellType.CHECKBOX;
57
- var _result2 = cellValue.map(function (item) {
58
- return getCellValueStringResult(_defineProperty__default["default"]({}, key, item), newColumn);
59
- });
60
- return _result2.filter(Boolean).join(', ');
61
- }
62
- var result = cellValue.map(function (item) {
63
- return getCellValueStringResult(_defineProperty__default["default"]({}, key, item), newColumn, {
64
- collaborators: collaborators,
65
- isArchiveView: isArchiveView
66
- });
67
- });
68
- return result.filter(function (item) {
69
- return item || item === 0;
70
- }).join(', ');
71
- };
72
19
 
73
20
  /**
74
21
  * Get formatted formula result to display. It will not be formatted
@@ -123,27 +70,27 @@ var getFormulaDisplayString = function getFormulaDisplayString(cellValue, column
123
70
 
124
71
  /**
125
72
  * Get formatted cell value to display.
126
- * @param {object} row e.g. { [column.key]: '' }
73
+ * @param {object} row e.g. { [column.key]: 'xxx' }
127
74
  * @param {string} type column type
128
75
  * @param {string} key column key
129
76
  * @param {object} data column data
130
77
  * @param {object} formulaRows formula results of rows. Default as "{}"
131
- * @param {array} collaborators e.g. [{ email, name, ... }, ...]. Default as "[]"
78
+ * @param {array} collaborators e.g. [{ email: 'xxx', name: 'xxx' }, ...]. Default as "[]"
132
79
  * @param {bool} isBaiduMap Determine the way to connect latitude and longitude. Default as true
133
80
  * @param {string} geolocationHyphen Used as a connector between province, city, district and detail. Default as empty string
134
81
  * @returns formatted cell value, string|array
135
82
  */
136
83
  var getCellValueDisplayString = function getCellValueDisplayString(row, type, key) {
137
- var _ref3 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
138
- data = _ref3.data,
139
- _ref3$formulaRows = _ref3.formulaRows,
140
- formulaRows = _ref3$formulaRows === void 0 ? {} : _ref3$formulaRows,
141
- _ref3$collaborators = _ref3.collaborators,
142
- collaborators = _ref3$collaborators === void 0 ? [] : _ref3$collaborators,
143
- _ref3$isBaiduMap = _ref3.isBaiduMap,
144
- isBaiduMap = _ref3$isBaiduMap === void 0 ? true : _ref3$isBaiduMap,
145
- _ref3$geolocationHyph = _ref3.geolocationHyphen,
146
- geolocationHyphen = _ref3$geolocationHyph === void 0 ? '' : _ref3$geolocationHyph;
84
+ var _ref = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
85
+ data = _ref.data,
86
+ _ref$formulaRows = _ref.formulaRows,
87
+ formulaRows = _ref$formulaRows === void 0 ? {} : _ref$formulaRows,
88
+ _ref$collaborators = _ref.collaborators,
89
+ collaborators = _ref$collaborators === void 0 ? [] : _ref$collaborators,
90
+ _ref$isBaiduMap = _ref.isBaiduMap,
91
+ isBaiduMap = _ref$isBaiduMap === void 0 ? true : _ref$isBaiduMap,
92
+ _ref$geolocationHyphe = _ref.geolocationHyphen,
93
+ geolocationHyphen = _ref$geolocationHyphe === void 0 ? '' : _ref$geolocationHyphe;
147
94
  if (!row) return '';
148
95
  var cellValue = row[key];
149
96
  switch (type) {
@@ -180,9 +127,9 @@ var getCellValueDisplayString = function getCellValueDisplayString(row, type, ke
180
127
  }
181
128
  case cellType.CellType.DATE:
182
129
  {
183
- var _ref4 = data || {},
184
- _ref4$format = _ref4.format,
185
- format = _ref4$format === void 0 ? column.DEFAULT_DATE_FORMAT : _ref4$format;
130
+ var _ref2 = data || {},
131
+ _ref2$format = _ref2.format,
132
+ format = _ref2$format === void 0 ? column.DEFAULT_DATE_FORMAT : _ref2$format;
186
133
  return date.getDateDisplayString(cellValue, format);
187
134
  }
188
135
  case cellType.CellType.CTIME:
@@ -218,166 +165,6 @@ var getCellValueDisplayString = function getCellValueDisplayString(row, type, ke
218
165
  }
219
166
  }
220
167
  };
221
- var getCellValueStringResult = function getCellValueStringResult(row, column$1) {
222
- var _ref5 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
223
- _ref5$formulaRows = _ref5.formulaRows,
224
- formulaRows = _ref5$formulaRows === void 0 ? {} : _ref5$formulaRows,
225
- _ref5$collaborators = _ref5.collaborators,
226
- collaborators = _ref5$collaborators === void 0 ? [] : _ref5$collaborators,
227
- _ref5$isArchiveView = _ref5.isArchiveView,
228
- isArchiveView = _ref5$isArchiveView === void 0 ? false : _ref5$isArchiveView;
229
- var _ref6 = column$1 || {},
230
- key = _ref6.key,
231
- type = _ref6.type,
232
- data = _ref6.data;
233
- var cellValue = row[key];
234
- switch (type) {
235
- case cellType.CellType.TEXT:
236
- case cellType.CellType.EMAIL:
237
- case cellType.CellType.URL:
238
- case cellType.CellType.AUTO_NUMBER:
239
- {
240
- return cellValue || '';
241
- }
242
- case cellType.CellType.RATE:
243
- {
244
- // number
245
- return cellValue ? String(cellValue) : '';
246
- }
247
- case cellType.CellType.CHECKBOX:
248
- {
249
- if (typeof cellValue === 'boolean') {
250
- return String(cellValue);
251
- }
252
- return cellValue === 'true' ? 'true' : 'false';
253
- }
254
- case cellType.CellType.LONG_TEXT:
255
- {
256
- // the data returned by archive view is a string, not a result in long-text format
257
- if (isArchiveView) {
258
- cellValue = {
259
- text: cellValue
260
- };
261
- }
262
- return longText.getLongtextDisplayString(cellValue);
263
- }
264
- case cellType.CellType.NUMBER:
265
- {
266
- return number.getNumberDisplayString(cellValue, data);
267
- }
268
- case cellType.CellType.DURATION:
269
- {
270
- return duration.getDurationDisplayString(cellValue, data);
271
- }
272
- case cellType.CellType.GEOLOCATION:
273
- {
274
- return geolocation.getGeolocationDisplayString(cellValue, data);
275
- }
276
- case cellType.CellType.SINGLE_SELECT:
277
- {
278
- if (!data) return '';
279
- var options = data.options;
280
- return option.getOptionName(options, cellValue);
281
- }
282
- case cellType.CellType.MULTIPLE_SELECT:
283
- {
284
- if (!data) return '';
285
- var _options2 = data.options;
286
- return option.getMultipleOptionName(_options2, cellValue);
287
- }
288
- case cellType.CellType.DATE:
289
- {
290
- var _ref7 = data || {},
291
- _ref7$format = _ref7.format,
292
- format = _ref7$format === void 0 ? column.DEFAULT_DATE_FORMAT : _ref7$format;
293
- // patch: compatible with previous format
294
- var normalizedFormat = format === 'D/M/YYYY' ? format.replace(/D\/M\/YYYY/, 'DD/MM/YYYY') : format;
295
- return date.getDateDisplayString(cellValue, normalizedFormat);
296
- }
297
- case cellType.CellType.CTIME:
298
- case cellType.CellType.MTIME:
299
- {
300
- return date$1.DateUtils.format(cellValue, 'YYYY-MM-DD HH:MM:SS');
301
- }
302
- case cellType.CellType.COLLABORATOR:
303
- {
304
- return collaborator.getCollaboratorsName(collaborators, cellValue);
305
- }
306
- case cellType.CellType.CREATOR:
307
- case cellType.CellType.LAST_MODIFIER:
308
- {
309
- return cellValue === 'anonymous' ? cellValue : collaborator.getCollaboratorsName(collaborators, [cellValue]);
310
- }
311
- case cellType.CellType.LINK:
312
- {
313
- if (!isArchiveView) {
314
- var formulaRow = formulaRows[row._id] || {};
315
- cellValue = formulaRow[key];
316
- }
317
- if (!cellValue || !Array.isArray(cellValue) || cellValue.length === 0) return '';
318
- var newCellValue = cellValue.map(function (linked) {
319
- return linked.display_value;
320
- });
321
- var isTwoDimensionalArray = newCellValue.some(function (item) {
322
- return Array.isArray(item);
323
- });
324
- if (!isTwoDimensionalArray) {
325
- return _getArrayColumnCellValue(newCellValue, column$1, {
326
- collaborators: collaborators
327
- });
328
- }
329
- var result = newCellValue.map(function (item) {
330
- return _getArrayColumnCellValue(item, column$1, {
331
- collaborators: collaborators,
332
- isArchiveView: isArchiveView
333
- });
334
- });
335
- return result.filter(Boolean).join(', ');
336
- }
337
- case cellType.CellType.FORMULA:
338
- case cellType.CellType.LINK_FORMULA:
339
- {
340
- if (!isArchiveView) {
341
- var _formulaRow = formulaRows[row._id] || {};
342
- cellValue = _formulaRow[key];
343
- }
344
- var result_type = data.result_type;
345
- if (result_type === formula.FORMULA_RESULT_TYPE.STRING) {
346
- return cellValue || '';
347
- }
348
- if (result_type === formula.FORMULA_RESULT_TYPE.BOOL) {
349
- return [true, 'true'].includes(cellValue) ? 'true' : 'false';
350
- }
351
- if (result_type === formula.FORMULA_RESULT_TYPE.NUMBER) {
352
- // data is stored in the data of the current column
353
- return number.getNumberDisplayString(cellValue, data);
354
- }
355
- if (result_type === formula.FORMULA_RESULT_TYPE.DATE) {
356
- // data is stored in the data of the current column
357
- var _ref8 = data || {},
358
- _format = _ref8.format;
359
- return date.getDateDisplayString(cellValue, _format);
360
- }
361
-
362
- // FORMULA_RESULT_TYPE.ARRAY
363
- return _getArrayColumnCellValue(cellValue, column$1, {
364
- collaborators: collaborators,
365
- isArchiveView: isArchiveView
366
- });
367
- }
368
- case cellType.CellType.FILE:
369
- case cellType.CellType.IMAGE:
370
- case cellType.CellType.BUTTON:
371
- {
372
- return '';
373
- }
374
- default:
375
- {
376
- return cellValue ? String(cellValue) : '';
377
- }
378
- }
379
- };
380
168
 
381
169
  exports.getCellValueDisplayString = getCellValueDisplayString;
382
- exports.getCellValueStringResult = getCellValueStringResult;
383
170
  exports.getFormulaDisplayString = getFormulaDisplayString;
@@ -2,16 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var getCollaborator = function getCollaborator(collaborators, collaboratorEmail) {
6
- return collaborators.find(function (collaborator) {
7
- return collaborator.email === collaboratorEmail;
8
- });
9
- };
10
-
11
5
  /**
12
6
  * Get collaborators name list of given emails
13
7
  * @param {array} emails e.g. ['email', ...]
14
- * @param {array} collaborators e.g. [{ email, name, ... }, ...]
8
+ * @param {array} collaborators e.g. [{ email: 'xxx', name: 'xxx' }, ...]
15
9
  * @returns name list, array. e.g. ['name1', 'name2']
16
10
  */
17
11
  var getCollaboratorsNames = function getCollaboratorsNames(emails, collaborators) {
@@ -30,7 +24,7 @@ var getCollaboratorsNames = function getCollaboratorsNames(emails, collaborators
30
24
 
31
25
  /**
32
26
  * Get concatenated collaborators names of given emails.
33
- * @param {array} collaborators e.g. [{ email, name, ... }, ...]
27
+ * @param {array} collaborators e.g. [{ email: 'xxx', name: 'xxx' }, ...]
34
28
  * @param {array} emails e.g. ['email', ...]
35
29
  * @returns concatenated collaborators names, string. e.g. 'name1, name2'
36
30
  */
@@ -40,6 +34,5 @@ var getCollaboratorsName = function getCollaboratorsName(collaborators, emails)
40
34
  return collaboratorsNames.join(', ');
41
35
  };
42
36
 
43
- exports.getCollaborator = getCollaborator;
44
37
  exports.getCollaboratorsName = getCollaboratorsName;
45
38
  exports.getCollaboratorsNames = getCollaboratorsNames;
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  /**
6
6
  * Get signature image url to display
7
- * @param {object} digitalSign object, e.g. { sign_image_url, ... }
7
+ * @param {object} digitalSign object, e.g. { sign_image_url: 'xxx' }
8
8
  * @returns signature image url, string
9
9
  */
10
10
  var getDigitalSignImageUrl = function getDigitalSignImageUrl(digitalSign) {
@@ -87,4 +87,5 @@ var getDurationDisplayString = function getDurationDisplayString(duration, forma
87
87
  return displayString;
88
88
  };
89
89
 
90
+ exports.getDurationDecimalSuffix = getDurationDecimalSuffix;
90
91
  exports.getDurationDisplayString = getDurationDisplayString;
@@ -2,13 +2,14 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var group = require('../constants/group.js');
6
- var geolocation = require('../validate/geolocation.js');
5
+ var isValidPosition = function isValidPosition(lng, lat) {
6
+ return (lng || lng === 0) && (lat || lat === 0);
7
+ };
7
8
 
8
9
  /**
9
10
  * Get formatted geolocation
10
11
  * @param {object} loc
11
- * @param {object} formats , e.g. { geo_format, ... }
12
+ * @param {object} formats , e.g. { geo_format: 'xxx' }
12
13
  * @param {bool} isBaiduMap Determine the way to connect latitude and longitude. Default as true
13
14
  * @param {string} hyphen Used as a connector between province, city, district and detail. Default as empty string
14
15
  * @returns formatted geolocation, string
@@ -30,7 +31,7 @@ var getGeolocationDisplayString = function getGeolocationDisplayString(loc, form
30
31
  var _ref3 = loc || {},
31
32
  lng = _ref3.lng,
32
33
  lat = _ref3.lat;
33
- if (!geolocation.isValidPosition(lng, lat)) return '';
34
+ if (!isValidPosition(lng, lat)) return '';
34
35
  return isBaiduMap ? "".concat(lng, ", ").concat(lat) : "".concat(lat, ", ").concat(lng);
35
36
  }
36
37
  case 'country_region':
@@ -80,31 +81,5 @@ var getGeolocationDisplayString = function getGeolocationDisplayString(loc, form
80
81
  }
81
82
  }
82
83
  };
83
- var getGeolocationByGranularity = function getGeolocationByGranularity(geolocation, granularity) {
84
- if (!geolocation) return '';
85
- var province = geolocation.province,
86
- city = geolocation.city,
87
- district = geolocation.district,
88
- country_region = geolocation.country_region;
89
- switch (granularity) {
90
- case group.GROUP_GEOLOCATION_GRANULARITY.CITY:
91
- {
92
- return city || '';
93
- }
94
- case group.GROUP_GEOLOCATION_GRANULARITY.DISTRICT:
95
- {
96
- return district || '';
97
- }
98
- case group.GROUP_GEOLOCATION_GRANULARITY.COUNTRY:
99
- {
100
- return country_region || '';
101
- }
102
- default:
103
- {
104
- return province || '';
105
- }
106
- }
107
- };
108
84
 
109
- exports.getGeolocationByGranularity = getGeolocationByGranularity;
110
85
  exports.getGeolocationDisplayString = getGeolocationDisplayString;
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  /**
6
6
  * Get text from long-text to display.
7
- * @param {object} longText e.g. { text, ... }
7
+ * @param {object} longText e.g. { text: 'xxx' }
8
8
  * @returns text from long-text, string
9
9
  */
10
10
  var getLongtextDisplayString = function getLongtextDisplayString(longText) {
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var index = require('../helper/number-precision/index.js');
6
- var duration = require('./duration.js');
7
6
  var column = require('../constants/column.js');
7
+ var duration = require('./duration.js');
8
8
 
9
9
  var separatorMap = {
10
10
  comma: ',',
@@ -12,30 +12,6 @@ var separatorMap = {
12
12
  no: '',
13
13
  space: ' '
14
14
  };
15
- var _getDecimalDigits = function _getDecimalDigits(num) {
16
- if (Number.isInteger(num)) {
17
- return 0;
18
- }
19
- var valueArr = (num + '').split('.');
20
- var digitsLength = valueArr[1] ? valueArr[1].length : 8;
21
- return digitsLength > 8 ? 8 : digitsLength;
22
- };
23
- var getPrecisionNumber = function getPrecisionNumber(num, formatData) {
24
- var _ref = formatData || {},
25
- _ref$precision = _ref.precision,
26
- precision = _ref$precision === void 0 ? 2 : _ref$precision,
27
- _ref$enable_precision = _ref.enable_precision,
28
- enable_precision = _ref$enable_precision === void 0 ? false : _ref$enable_precision;
29
- var type = Object.prototype.toString.call(num);
30
- if (type !== '[object Number]') {
31
- if (type === '[object String]' && DISPLAY_INTERNAL_ERRORS.includes(num)) {
32
- return num;
33
- }
34
- return null;
35
- }
36
- var decimalDigits = enable_precision ? precision : _getDecimalDigits(num);
37
- return num.toFixed(decimalDigits);
38
- };
39
15
 
40
16
  /**
41
17
  * removeZerosFromEnd('0.0100') // '0.01'
@@ -62,19 +38,19 @@ var getDecimalDigitsFromNumber = function getDecimalDigitsFromNumber(number) {
62
38
  var digitsLength = decimalPart ? decimalPart.length : 8;
63
39
  return digitsLength > 8 ? 8 : digitsLength;
64
40
  };
65
- var toThousands = function toThousands(number, _ref2) {
66
- var formats = _ref2.formats,
67
- _ref2$isCurrency = _ref2.isCurrency,
68
- isCurrency = _ref2$isCurrency === void 0 ? true : _ref2$isCurrency;
69
- var _ref3 = formats || {},
70
- _ref3$decimal = _ref3.decimal,
71
- decimal = _ref3$decimal === void 0 ? 'dot' : _ref3$decimal,
72
- _ref3$thousands = _ref3.thousands,
73
- thousands = _ref3$thousands === void 0 ? 'no' : _ref3$thousands,
74
- _ref3$precision = _ref3.precision,
75
- precision = _ref3$precision === void 0 ? 2 : _ref3$precision,
76
- _ref3$enable_precisio = _ref3.enable_precision,
77
- enable_precision = _ref3$enable_precisio === void 0 ? false : _ref3$enable_precisio;
41
+ var toThousands = function toThousands(number, _ref) {
42
+ var formats = _ref.formats,
43
+ _ref$isCurrency = _ref.isCurrency,
44
+ isCurrency = _ref$isCurrency === void 0 ? true : _ref$isCurrency;
45
+ var _ref2 = formats || {},
46
+ _ref2$decimal = _ref2.decimal,
47
+ decimal = _ref2$decimal === void 0 ? 'dot' : _ref2$decimal,
48
+ _ref2$thousands = _ref2.thousands,
49
+ thousands = _ref2$thousands === void 0 ? 'no' : _ref2$thousands,
50
+ _ref2$precision = _ref2.precision,
51
+ precision = _ref2$precision === void 0 ? 2 : _ref2$precision,
52
+ _ref2$enable_precisio = _ref2.enable_precision,
53
+ enable_precision = _ref2$enable_precisio === void 0 ? false : _ref2$enable_precisio;
78
54
 
79
55
  // handle numbers in scientific notation
80
56
  if (String(number).includes('e')) {
@@ -146,9 +122,9 @@ var getNumberDisplayString = function getNumberDisplayString(number, formats) {
146
122
  if (isNaN(number) || number === Infinity || number === -Infinity) return String(number);
147
123
 
148
124
  // formats: old version maybe 'null'
149
- var _ref4 = formats || {},
150
- _ref4$format = _ref4.format,
151
- format = _ref4$format === void 0 ? column.DEFAULT_NUMBER_FORMAT : _ref4$format;
125
+ var _ref3 = formats || {},
126
+ _ref3$format = _ref3.format,
127
+ format = _ref3$format === void 0 ? column.DEFAULT_NUMBER_FORMAT : _ref3$format;
152
128
  switch (format) {
153
129
  case 'number':
154
130
  {
@@ -248,5 +224,4 @@ var replaceNumberNotAllowInput = function replaceNumberNotAllowInput(sNum, forma
248
224
  };
249
225
 
250
226
  exports.getNumberDisplayString = getNumberDisplayString;
251
- exports.getPrecisionNumber = getPrecisionNumber;
252
227
  exports.replaceNumberNotAllowInput = replaceNumberNotAllowInput;
@@ -2,29 +2,19 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var option = require('../column/option.js');
6
-
7
- var getOption = function getOption(options, optionId) {
8
- return options.find(function (o) {
9
- return o.id === optionId;
10
- });
11
- };
12
-
13
5
  /**
14
6
  * Get option name of the given id
15
7
  * @param {array} options e.g. [ { id: '', color: '', name: '' } ]
16
- * @param {string} targetOptionId option id
8
+ * @param {string} targetOptionID option id
17
9
  * @returns option name, string
18
10
  */
19
- var getOptionName = function getOptionName(options, targetOptionId) {
20
- if (!targetOptionId || !Array.isArray(options)) return '';
21
- var targetOption = getOption(options, targetOptionId);
11
+ var getOptionName = function getOptionName(options, targetOptionID) {
12
+ if (!targetOptionID || !Array.isArray(options)) return '';
13
+ var targetOption = options.find(function (option) {
14
+ return option.id === targetOptionID;
15
+ });
22
16
  return targetOption ? targetOption.name : '';
23
17
  };
24
- var getColumnOptionNameById = function getColumnOptionNameById(column, optionId) {
25
- var options = option.getColumnOptions(column);
26
- return getOptionName(options, optionId);
27
- };
28
18
 
29
19
  /**
30
20
  * Get concatenated options names of given ids.
@@ -43,7 +33,5 @@ var getMultipleOptionName = function getMultipleOptionName(options, targetOption
43
33
  }).join(', ');
44
34
  };
45
35
 
46
- exports.getColumnOptionNameById = getColumnOptionNameById;
47
36
  exports.getMultipleOptionName = getMultipleOptionName;
48
- exports.getOption = getOption;
49
37
  exports.getOptionName = getOptionName;
@@ -3,8 +3,6 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var index = require('../helper/number-precision/index.js');
6
- var number = require('../number.js');
7
- var column = require('../constants/column.js');
8
6
 
9
7
  /**
10
8
  * @param {string} sNumber e.g. '1.23'
@@ -56,56 +54,5 @@ var formatStringToNumber = function formatStringToNumber(sNum, formats) {
56
54
  return value;
57
55
  };
58
56
 
59
- /**
60
- * parse duration to seconds depend on formats
61
- * @param {string} duration
62
- * @param {object} data { duration_format: '' }
63
- * @returns number
64
- */
65
- var formatDurationToNumber = function formatDurationToNumber(duration, data) {
66
- if (duration === 0) return 0;
67
- if (!duration) return null;
68
- var _ref2 = data || {},
69
- duration_format = _ref2.duration_format;
70
- duration_format = duration_format || column.DURATION_FORMATS_MAP.H_MM;
71
- if (column.DURATION_FORMATS.findIndex(function (format) {
72
- return format.type === duration_format;
73
- }) < 0) {
74
- return null;
75
- }
76
- var numericDuration = duration - 0;
77
- if (number.isNumber(numericDuration)) {
78
- return duration_format === column.DURATION_FORMATS_MAP.H_MM ? numericDuration * 60 : numericDuration;
79
- }
80
- var stringifyDuration = String(duration);
81
- var isNegative = stringifyDuration[0] === '-';
82
- if (isNegative) {
83
- stringifyDuration = stringifyDuration.substring(1);
84
- }
85
- var timeParts = stringifyDuration.split(/[::]/); // support ':' and ':'.
86
- var timePartsLen = timeParts.length;
87
- var hoursIndex;
88
- var minutesIndex;
89
- var secondsIndex;
90
- if (duration_format === column.DURATION_FORMATS_MAP.H_MM) {
91
- hoursIndex = timePartsLen - 2;
92
- minutesIndex = timePartsLen - 1;
93
- } else {
94
- hoursIndex = timePartsLen - 3;
95
- minutesIndex = timePartsLen - 2;
96
- secondsIndex = timePartsLen - 1;
97
- }
98
- var hours = timeParts[hoursIndex] - 0;
99
- var minutes = timeParts[minutesIndex] - 0;
100
- var seconds = timeParts[secondsIndex] - 0;
101
- if (!number.isNumber(hours) && !number.isNumber(minutes) && !number.isNumber(seconds)) return null;
102
- hours = number.isNumber(hours) ? hours : 0;
103
- minutes = number.isNumber(minutes) ? minutes : 0;
104
- seconds = number.isNumber(seconds) ? seconds : 0;
105
- var result = hours * 3600 + minutes * 60 + seconds;
106
- return isNegative ? -result : result;
107
- };
108
-
109
- exports.formatDurationToNumber = formatDurationToNumber;
110
57
  exports.formatStringToNumber = formatStringToNumber;
111
58
  exports.getFloatNumber = getFloatNumber;
@@ -7,7 +7,7 @@ var formula = require('../constants/formula.js');
7
7
 
8
8
  /**
9
9
  * Get column type.
10
- * @param {object} column { type, ... }
10
+ * @param {object} column { type: 'xxx', ... }
11
11
  * @returns column type
12
12
  */
13
13
  var getColumnType = function getColumnType(column) {
@@ -30,4 +30,17 @@ var getColumnType = function getColumnType(column) {
30
30
  return type;
31
31
  };
32
32
 
33
+ /**
34
+ * Get options from single-select/multiple-select column.
35
+ * @param {object} column e.g. { type, data: { options: [] } }
36
+ * @returns options, array
37
+ */
38
+ var getColumnOptions = function getColumnOptions(column) {
39
+ if (!column || !column.data || !Array.isArray(column.data.options)) {
40
+ return [];
41
+ }
42
+ return column.data.options;
43
+ };
44
+
45
+ exports.getColumnOptions = getColumnOptions;
33
46
  exports.getColumnType = getColumnType;
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var core = require('./core.js');
5
+ var common = require('./common.js');
6
6
  var column = require('../constants/column.js');
7
7
 
8
8
  /**
@@ -14,7 +14,7 @@ var column = require('../constants/column.js');
14
14
  * @returns true/false, bool
15
15
  */
16
16
  var isDateColumn = function isDateColumn(column$1) {
17
- return column.DATE_COLUMN_OPTIONS.includes(core.getColumnType(column$1));
17
+ return column.DATE_COLUMN_OPTIONS.includes(common.getColumnType(column$1));
18
18
  };
19
19
 
20
20
  exports.isDateColumn = isDateColumn;