dtable-statistic 4.3.6 → 4.3.7

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 (107) hide show
  1. package/es/calculator/base-calculator.js +16 -5
  2. package/es/calculator/basic-chart-calculator.js +17 -31
  3. package/es/calculator/combination-calculator.js +19 -30
  4. package/es/calculator/compare-bar-calculator.js +9 -20
  5. package/es/calculator/completeness-calculator.js +10 -24
  6. package/es/calculator/dashboard-calculator.js +6 -20
  7. package/es/calculator/heat-map-calculator.js +6 -20
  8. package/es/calculator/horizontal-bar-calculator.js +2 -13
  9. package/es/calculator/index.js +2 -0
  10. package/es/calculator/map-calculator.js +7 -21
  11. package/es/calculator/mirror-calculator.js +8 -22
  12. package/es/calculator/number-card-calculator.js +4 -18
  13. package/es/calculator/pivot-table-calculator.js +40 -54
  14. package/es/calculator/scatter-calculator.js +6 -20
  15. package/es/calculator/trend-calculator.js +6 -20
  16. package/es/calculator/workers/basic-chart-calculator-worker.js +77 -45
  17. package/es/calculator/workers/calculator.worker.js +5 -2
  18. package/es/calculator/workers/card-calculator-worker.js +13 -9
  19. package/es/calculator/workers/combination-calculator-worker.js +20 -16
  20. package/es/calculator/workers/compare-bar-chart-calculator-worker.js +12 -8
  21. package/es/calculator/workers/completeness-calculator-worker.js +21 -17
  22. package/es/calculator/workers/dashboard-calculator-worker.js +16 -12
  23. package/es/calculator/workers/mirror-calculator-worker.js +14 -10
  24. package/es/calculator/workers/pivot-table-calculator-worker.js +53 -35
  25. package/es/calculator/workers/scatter-calculator-worker.js +15 -11
  26. package/es/calculator/workers/trend-calculator-worker.js +14 -10
  27. package/es/calculator/world-map-calculator.js +6 -20
  28. package/es/components/dialog/chart-addition-edit-dialog.js +1 -1
  29. package/es/components/dialog/chart-addition-widgets/chart-selector.js +1 -1
  30. package/es/components/dialog/statistic-record-dialog/index.js +21 -11
  31. package/es/components/dropdown-menu/statistic-dropdown-menu.js +1 -1
  32. package/es/components/popover/color-rules/rule-filters/number-input.js +5 -5
  33. package/es/components/popover/color-rules-popover.js +2 -2
  34. package/es/components/toast/alert.js +2 -0
  35. package/es/components/toast/toastManager.js +1 -0
  36. package/es/constants/color-rules.js +3 -3
  37. package/es/constants/index.js +9 -9
  38. package/es/dashboard.js +7 -13
  39. package/es/desktop-dashboard.js +1 -1
  40. package/es/locale/lang/de.js +10 -10
  41. package/es/locale/lang/en.js +8 -8
  42. package/es/locale/lang/fr.js +10 -10
  43. package/es/locale/lang/zh_CN.js +8 -8
  44. package/es/model/basic-number-card.js +3 -3
  45. package/es/model/compare-bar.js +2 -2
  46. package/es/model/generic-model.js +11 -11
  47. package/es/model/heat-map.js +2 -2
  48. package/es/model/horizontal-bar.js +2 -2
  49. package/es/model/index.js +3 -2
  50. package/es/model/map.js +3 -3
  51. package/es/model/mirror.js +2 -2
  52. package/es/model/trend.js +2 -2
  53. package/es/model/world-map.js +3 -3
  54. package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +7 -7
  55. package/es/stat-editor/stat-settings/advance-chart-settings/index.js +2 -2
  56. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +2 -2
  57. package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +1 -1
  58. package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +1 -1
  59. package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +7 -7
  60. package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +6 -6
  61. package/es/stat-editor/stat-settings/basic-chart-settings/index.js +4 -4
  62. package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +5 -5
  63. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +3 -3
  64. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +3 -3
  65. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +3 -3
  66. package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +1 -1
  67. package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +1 -1
  68. package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +1 -1
  69. package/es/stat-editor/stat-settings/public-setting/column-settings.js +1 -1
  70. package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +1 -1
  71. package/es/stat-view/area-chart.js +4 -4
  72. package/es/stat-view/bar-chart.js +4 -4
  73. package/es/stat-view/base-chart.js +2 -2
  74. package/es/stat-view/basic-number-card.js +2 -2
  75. package/es/stat-view/combination-chart.js +9 -9
  76. package/es/stat-view/compare-chart.js +4 -4
  77. package/es/stat-view/completeness-chart.js +3 -3
  78. package/es/stat-view/custom-bar.js +2 -2
  79. package/es/stat-view/heat-map.js +2 -2
  80. package/es/stat-view/horizontal-bar-chart.js +4 -4
  81. package/es/stat-view/line-chart.js +4 -4
  82. package/es/stat-view/map.js +3 -3
  83. package/es/stat-view/mirror.js +2 -2
  84. package/es/stat-view/pivot-table/index.js +6 -6
  85. package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +5 -5
  86. package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +3 -3
  87. package/es/stat-view/pivot-table/pivot-table-display-name.js +19 -19
  88. package/es/stat-view/pivot-table/two-dimension-table.js +7 -7
  89. package/es/stat-view/ring-chart.js +2 -2
  90. package/es/stat-view/scatter-chart.js +5 -5
  91. package/es/stat-view/treemap-chart.js +3 -2
  92. package/es/stat-view/trend-chart.js +2 -2
  93. package/es/stat-view/world-map.js +3 -3
  94. package/es/utils/cell-format.js +14 -15
  95. package/es/utils/cell-value.js +3 -3
  96. package/es/utils/color-utils.js +3 -3
  97. package/es/utils/column-utils.js +10 -10
  98. package/es/utils/column.js +2 -2
  99. package/es/utils/common-utils.js +10 -8
  100. package/es/utils/export-table-utils.js +38 -38
  101. package/es/utils/pivot-table.js +3 -3
  102. package/es/utils/row-utils.js +17 -17
  103. package/es/utils/search.js +14 -14
  104. package/es/utils/sql-utils.js +23 -20
  105. package/es/utils/stat-utils.js +52 -52
  106. package/es/utils/trend-utils.js +1 -0
  107. package/package.json +3 -2
@@ -6,10 +6,9 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.getClientFormulaDisplayString = exports.getClientCellValueDisplayString = void 0;
8
8
  var _dayjs = _interopRequireDefault(require("dayjs"));
9
- var _dtableStore = require("dtable-store");
9
+ var _dtableUtils = require("dtable-utils");
10
10
  const getClientFormulaDisplayString = function (value, columnData) {
11
11
  let {
12
- tables = [],
13
12
  collaborators = []
14
13
  } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
15
14
  if (!columnData || !value && value !== 0) return '';
@@ -17,19 +16,16 @@ const getClientFormulaDisplayString = function (value, columnData) {
17
16
  result_type,
18
17
  array_type
19
18
  } = columnData;
20
- if (result_type === _dtableStore.FORMULA_RESULT_TYPE.ARRAY) {
21
- if (_dtableStore.COLLABORATOR_COLUMN_TYPES.includes(array_type)) {
19
+ if (result_type === _dtableUtils.FORMULA_RESULT_TYPE.ARRAY) {
20
+ if (_dtableUtils.COLLABORATOR_COLUMN_TYPES.includes(array_type)) {
22
21
  if (!value) {
23
22
  return null;
24
23
  }
25
24
  const collaboratorList = Array.isArray(value) ? value : [value];
26
- return (0, _dtableStore.getCollaboratorsName)(collaborators, collaboratorList);
25
+ return (0, _dtableUtils.getCollaboratorsName)(collaborators, collaboratorList);
27
26
  }
28
27
  }
29
- return (0, _dtableStore.getFormulaDisplayString)(value, columnData, {
30
- tables,
31
- collaborators
32
- });
28
+ return (0, _dtableUtils.getFormulaDisplayString)(value, columnData);
33
29
  };
34
30
 
35
31
  /**
@@ -53,7 +49,7 @@ const getClientLinkDisplayString = function (links, columnData) {
53
49
  ...columnData
54
50
  };
55
51
  if (!columnData.hasOwnProperty('result_type')) {
56
- formulaData.result_type = _dtableStore.FORMULA_RESULT_TYPE.ARRAY;
52
+ formulaData.result_type = _dtableUtils.FORMULA_RESULT_TYPE.ARRAY;
57
53
  }
58
54
  const displayValue = links.map(link => link.display_value);
59
55
  return getClientFormulaDisplayString(displayValue, formulaData, {
@@ -88,24 +84,27 @@ const getClientCellValueDisplayString = function (row, type, key) {
88
84
  collaborators = [],
89
85
  tables = []
90
86
  } = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
91
- if (_dtableStore.FORMULA_COLUMN_TYPES.includes(type)) {
87
+ if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[type]) {
92
88
  const formulaRow = formulaRows[row._id] || {};
93
89
  return getClientFormulaDisplayString(formulaRow[key], data, {
94
90
  tables,
95
91
  collaborators
96
92
  });
97
- } else if (type === _dtableStore.CellType.LINK) {
93
+ }
94
+ if (type === _dtableUtils.CellType.LINK) {
98
95
  const formulaRow = formulaRows[row._id] || {};
99
96
  return getClientLinkDisplayString(formulaRow[key], data, {
100
97
  tables,
101
98
  collaborators
102
99
  });
103
- } else if (type === _dtableStore.CellType.CTIME || type === _dtableStore.CellType.MTIME) {
100
+ }
101
+ if (type === _dtableUtils.CellType.CTIME || type === _dtableUtils.CellType.MTIME) {
104
102
  return getAutoTimeDisplayString(row, key);
105
- } else if (type === _dtableStore.CellType.FILE) {
103
+ }
104
+ if (type === _dtableUtils.CellType.FILE) {
106
105
  return getFileDisplayString(row, key);
107
106
  }
108
- return (0, _dtableStore.getCellValueDisplayString)(row, type, key, {
107
+ return (0, _dtableUtils.getCellValueDisplayString)(row, type, key, {
109
108
  formulaRows,
110
109
  data,
111
110
  collaborators,
@@ -4,17 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.isCellValueChanged = void 0;
7
- var _dtableStore = require("dtable-store");
7
+ var _dtableUtils = require("dtable-utils");
8
8
  var _object = require("./object");
9
9
  const isCellValueChanged = (oldVal, newVal, columnType) => {
10
10
  if (oldVal === newVal) {
11
11
  return false;
12
12
  }
13
13
  if (oldVal === undefined || oldVal === null) {
14
- if ((columnType === _dtableStore.CellType.GEOLOCATION || columnType === _dtableStore.CellType.DIGITAL_SIGN) && (0, _object.isEmptyObject)(newVal)) {
14
+ if ((columnType === _dtableUtils.CellType.GEOLOCATION || columnType === _dtableUtils.CellType.DIGITAL_SIGN) && (0, _object.isEmptyObject)(newVal)) {
15
15
  return false;
16
16
  }
17
- if ((columnType === _dtableStore.CellType.DATE || columnType === _dtableStore.CellType.NUMBER || columnType === _dtableStore.CellType.DURATION) && newVal === null) {
17
+ if ((columnType === _dtableUtils.CellType.DATE || columnType === _dtableUtils.CellType.NUMBER || columnType === _dtableUtils.CellType.DURATION) && newVal === null) {
18
18
  return false;
19
19
  }
20
20
  if (Array.isArray(newVal)) {
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getValidColorRules = exports.getLabelColorFromSpecificColor = exports.getLabelColorFromColorRules = exports.getLabelColor = exports.getConvertedColorRules = void 0;
7
- var _dtableStore = require("dtable-store");
7
+ var _dtableUtils = require("dtable-utils");
8
8
  var _constants = require("../constants");
9
9
  var _colorRules = require("../constants/color-rules");
10
10
  const getValidColorRules = colorRules => {
@@ -36,7 +36,7 @@ const getValidColorRules = colorRules => {
36
36
  column_key: filter.filter_type
37
37
  };
38
38
  });
39
- const validFilters = (0, _dtableStore.getValidFilters)(convertedFilters, columns);
39
+ const validFilters = (0, _dtableUtils.getValidFilters)(convertedFilters, columns);
40
40
  if (validFilters.length === 0) {
41
41
  return null;
42
42
  }
@@ -102,7 +102,7 @@ const getLabelColorFromColorRules = (colorRules, value) => {
102
102
  filter_conjunction,
103
103
  filters
104
104
  } = colorRule;
105
- if ((0, _dtableStore.filterRow)(row, filter_conjunction, filters)) {
105
+ if ((0, _dtableUtils.filterRow)(row, filter_conjunction, filters)) {
106
106
  matchedRuleColor = color;
107
107
  break;
108
108
  }
@@ -5,14 +5,14 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getColorFromSingleSelectColumn = getColorFromSingleSelectColumn;
7
7
  exports.isWorldMapColumn = exports.isStatisticDateColumn = exports.isMirrorColumn = exports.isMapColumn = void 0;
8
- var _dtableStore = require("dtable-store");
8
+ var _dtableUtils = require("dtable-utils");
9
9
  var _constants = require("../constants");
10
10
  function getColorFromSingleSelectColumn(column, target) {
11
11
  let {
12
12
  type: columnType,
13
13
  data: columnData
14
14
  } = column;
15
- if (columnType !== _dtableStore.CellType.SINGLE_SELECT) {
15
+ if (columnType !== _dtableUtils.CellType.SINGLE_SELECT) {
16
16
  return null;
17
17
  }
18
18
  const options = columnData ? columnData.options : [];
@@ -28,7 +28,7 @@ function getColorFromSingleSelectColumn(column, target) {
28
28
  }
29
29
  const isStatisticDateColumn = column => {
30
30
  if (!column) return false;
31
- return (0, _dtableStore.isDateColumn)(column);
31
+ return (0, _dtableUtils.isDateColumn)(column);
32
32
  };
33
33
  exports.isStatisticDateColumn = isStatisticDateColumn;
34
34
  const isMapColumn = column => {
@@ -37,7 +37,7 @@ const isMapColumn = column => {
37
37
  type,
38
38
  data
39
39
  } = column;
40
- if (type === _dtableStore.CellType.GEOLOCATION) {
40
+ if (type === _dtableUtils.CellType.GEOLOCATION) {
41
41
  const {
42
42
  geo_format
43
43
  } = data || {};
@@ -46,13 +46,13 @@ const isMapColumn = column => {
46
46
  }
47
47
  return true;
48
48
  }
49
- if (_dtableStore.FORMULA_COLUMN_TYPES.includes(type)) {
49
+ if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[type]) {
50
50
  const {
51
51
  result_type,
52
52
  array_type,
53
53
  array_data
54
54
  } = data || {};
55
- if (result_type !== _dtableStore.FORMULA_RESULT_TYPE.ARRAY || array_type !== _dtableStore.CellType.GEOLOCATION) {
55
+ if (result_type !== _dtableUtils.FORMULA_RESULT_TYPE.ARRAY || array_type !== _dtableUtils.CellType.GEOLOCATION) {
56
56
  return false;
57
57
  }
58
58
  const {
@@ -77,8 +77,8 @@ const isWorldMapColumn = column => {
77
77
  type,
78
78
  data
79
79
  } = column;
80
- if (type === _dtableStore.CellType.TEXT) return true;
81
- if (type === _dtableStore.CellType.GEOLOCATION) {
80
+ if (type === _dtableUtils.CellType.TEXT) return true;
81
+ if (type === _dtableUtils.CellType.GEOLOCATION) {
82
82
  const {
83
83
  geo_format
84
84
  } = data || {};
@@ -86,7 +86,7 @@ const isWorldMapColumn = column => {
86
86
  return true;
87
87
  }
88
88
  }
89
- if (_dtableStore.FORMULA_COLUMN_TYPES.includes(type)) {
89
+ if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[type]) {
90
90
  const {
91
91
  data
92
92
  } = column;
@@ -95,7 +95,7 @@ const isWorldMapColumn = column => {
95
95
  array_type,
96
96
  array_data
97
97
  } = data || {};
98
- if (result_type !== _dtableStore.FORMULA_RESULT_TYPE.ARRAY || array_type !== _dtableStore.CellType.GEOLOCATION) {
98
+ if (result_type !== _dtableUtils.FORMULA_RESULT_TYPE.ARRAY || array_type !== _dtableUtils.CellType.GEOLOCATION) {
99
99
  return false;
100
100
  }
101
101
  const {
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getDateColumnFormat = getDateColumnFormat;
7
7
  exports.getSelectColumnOptions = getSelectColumnOptions;
8
- var _dtableStore = require("dtable-store");
8
+ var _dtableUtils = require("dtable-utils");
9
9
  function getSelectColumnOptions(column) {
10
10
  if (!column || !column.data || !Array.isArray(column.data.options)) {
11
11
  return [];
@@ -13,7 +13,7 @@ function getSelectColumnOptions(column) {
13
13
  return column.data.options;
14
14
  }
15
15
  function getDateColumnFormat(column) {
16
- let format = column && column.data && column.data.format ? column.data.format : _dtableStore.DEFAULT_DATE_FORMAT;
16
+ let format = column && column.data && column.data.format ? column.data.format : _dtableUtils.DEFAULT_DATE_FORMAT;
17
17
  // Old Europe format is D/M/YYYY new format is DD/MM/YYYY
18
18
  format = format.replace(/D\/M\/YYYY/, 'DD/MM/YYYY');
19
19
  return format;
@@ -11,7 +11,7 @@ exports.isShapeEqual = exports.isBoolean = exports.isArrayCellValue = exports.ge
11
11
  exports.isStatItemEqual = isStatItemEqual;
12
12
  exports.shallowEqual = shallowEqual;
13
13
  exports.sortDataByGroupSum = exports.shouldCalculateStatItem = void 0;
14
- var _dtableStore = require("dtable-store");
14
+ var _dtableUtils = require("dtable-utils");
15
15
  var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
16
16
  var _constants = require("../constants");
17
17
  var _statUtils = _interopRequireDefault(require("./stat-utils"));
@@ -19,12 +19,14 @@ const generatorUniqueId = list => {
19
19
  let uniqueId;
20
20
  let isUnique = false;
21
21
  while (!isUnique) {
22
- uniqueId = (0, _dtableStore.generatorBase64Code)();
22
+ uniqueId = (0, _dtableUtils.generatorBase64Code)();
23
23
 
24
24
  // eslint-disable-next-line
25
25
  if (!Array.isArray(list) || list.length === 0) {
26
26
  break;
27
27
  }
28
+
29
+ // eslint-disable-next-line
28
30
  isUnique = list.every(item => item._id !== uniqueId);
29
31
  if (isUnique) {
30
32
  break;
@@ -152,13 +154,13 @@ const isArrayCellValue = column => {
152
154
  type,
153
155
  data
154
156
  } = column;
155
- return _constants.MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP[type] || _dtableStore.FORMULA_COLUMN_TYPES_MAP[type] && data && data.result_type === _dtableStore.FORMULA_RESULT_TYPE.ARRAY && _dtableStore.COLLABORATOR_COLUMN_TYPES.includes(data.array_type) // the collaborator lookup is not formatted
157
+ return _constants.MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP[type] || _dtableUtils.FORMULA_COLUMN_TYPES_MAP[type] && data && data.result_type === _dtableUtils.FORMULA_RESULT_TYPE.ARRAY && _dtableUtils.COLLABORATOR_COLUMN_TYPES.includes(data.array_type) // the collaborator lookup is not formatted
156
158
  ;
157
159
  };
158
160
  exports.isArrayCellValue = isArrayCellValue;
159
161
  const getSummaryResult = function (results, summaryMethod) {
160
162
  let precision = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 8;
161
- const numericResults = Array.isArray(results) && results.length > 0 ? results.filter(res => (0, _dtableStore.isNumber)(res)) : [];
163
+ const numericResults = Array.isArray(results) && results.length > 0 ? results.filter(res => (0, _dtableUtils.isNumber)(res)) : [];
162
164
  switch (summaryMethod) {
163
165
  case _constants.SUMMARY_METHOD_MAP.Max:
164
166
  {
@@ -233,7 +235,7 @@ const getPieColor = (color_option, column, index, data, currentTheme) => {
233
235
  const {
234
236
  colors
235
237
  } = currentTheme;
236
- if (color_option === _constants.PIE_COLOR_OPTIONS[1] && (columnType === _dtableStore.CellType.SINGLE_SELECT || columnType === _dtableStore.CellType.MULTIPLE_SELECT)) {
238
+ if (color_option === _constants.PIE_COLOR_OPTIONS[1] && (columnType === _dtableUtils.CellType.SINGLE_SELECT || columnType === _dtableUtils.CellType.MULTIPLE_SELECT)) {
237
239
  if (columnData && columnData.options) {
238
240
  const selectedItem = columnData.options.find(item => item.name === data.name) || {};
239
241
  return selectedItem.color || '#dbdbdb';
@@ -253,7 +255,7 @@ function formatPieChartData(data, statItem, table, currentTheme) {
253
255
  summary_type
254
256
  } = statItem;
255
257
  const isAdvanced = summary_type === 'advanced';
256
- const column = _dtableStore.TableUtils.getTableColumnByKey(table, groupby_column_key);
258
+ const column = (0, _dtableUtils.getTableColumnByKey)(table, groupby_column_key);
257
259
  let sum = data.reduce((total, currentValue) => {
258
260
  return total += currentValue.value;
259
261
  }, 0);
@@ -284,7 +286,7 @@ function formatPieChartData(data, statItem, table, currentTheme) {
284
286
  }, 0);
285
287
  let formattedValueSum = filteredSum;
286
288
  if (isAdvanced) {
287
- const summaryColumn = _dtableStore.TableUtils.getTableColumnByKey(table, summary_column_key);
289
+ const summaryColumn = (0, _dtableUtils.getTableColumnByKey)(table, summary_column_key);
288
290
  formattedValueSum = _statUtils.default.getFormattedValue(filteredSum, summaryColumn, summaryMethod);
289
291
  }
290
292
  let original_name_list = [];
@@ -329,7 +331,7 @@ const formatNumericValue = function (value) {
329
331
  };
330
332
  exports.formatNumericValue = formatNumericValue;
331
333
  const getLabelFontSize = label_font_size => {
332
- return (0, _dtableStore.isNumber)(label_font_size) ? label_font_size : _constants.DEFAULT_LABEL_FONT_SIZE;
334
+ return (0, _dtableUtils.isNumber)(label_font_size) ? label_font_size : _constants.DEFAULT_LABEL_FONT_SIZE;
333
335
  };
334
336
  exports.getLabelFontSize = getLabelFontSize;
335
337
  const getSummaryColumnMethod = function (method, summaryColumnName) {
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.updateStatisticToTable = exports.exportStatisticToTable = void 0;
8
8
  var _dayjs = _interopRequireDefault(require("dayjs"));
9
9
  var _reactIntlUniversal = _interopRequireDefault(require("react-intl-universal"));
10
- var _dtableStore = require("dtable-store");
10
+ var _dtableUtils = require("dtable-utils");
11
11
  var _cellValue = require("./cell-value");
12
12
  var _column = require("./column");
13
13
  var _collaborator = require("./collaborator");
@@ -21,7 +21,7 @@ const isSummaryDateColumn = summaryColumn => {
21
21
  const {
22
22
  type
23
23
  } = summaryColumn;
24
- return type !== _dtableStore.CellType.LINK && (0, _dtableStore.isDateColumn)(summaryColumn);
24
+ return type !== _dtableUtils.CellType.LINK && (0, _dtableUtils.isDateColumn)(summaryColumn);
25
25
  };
26
26
 
27
27
  // eslint-disable-next-line
@@ -34,31 +34,31 @@ const getTableValueDisplayName = (value, column) => {
34
34
  collaborators
35
35
  } = window.app.state;
36
36
  switch (type) {
37
- case _dtableStore.CellType.SINGLE_SELECT:
38
- case _dtableStore.CellType.MULTIPLE_SELECT:
37
+ case _dtableUtils.CellType.SINGLE_SELECT:
38
+ case _dtableUtils.CellType.MULTIPLE_SELECT:
39
39
  {
40
40
  let options = (0, _column.getSelectColumnOptions)(column);
41
- let option = (0, _dtableStore.getOption)(options, value) || {};
41
+ let option = (0, _dtableUtils.getOption)(options, value) || {};
42
42
  return option.name;
43
43
  }
44
- case _dtableStore.CellType.COLLABORATOR:
44
+ case _dtableUtils.CellType.COLLABORATOR:
45
45
  {
46
- let collaborator = (0, _dtableStore.getCollaborator)(collaborators, value) || {};
46
+ let collaborator = (0, _dtableUtils.getCollaborator)(collaborators, value) || {};
47
47
  return collaborator.name;
48
48
  }
49
- case _dtableStore.CellType.CREATOR:
50
- case _dtableStore.CellType.LAST_MODIFIER:
49
+ case _dtableUtils.CellType.CREATOR:
50
+ case _dtableUtils.CellType.LAST_MODIFIER:
51
51
  {
52
52
  let collaborator = (0, _collaborator.getKnownCreatorByEmail)(collaborators, value) || {};
53
53
  return collaborator.name;
54
54
  }
55
- case _dtableStore.CellType.NUMBER:
55
+ case _dtableUtils.CellType.NUMBER:
56
56
  {
57
57
  let valueNumber = parseFloat(value);
58
- let displayValue = (0, _dtableStore.isNumber)(valueNumber) ? (0, _dtableStore.getNumberDisplayString)(valueNumber, data) : value;
58
+ let displayValue = (0, _dtableUtils.isNumber)(valueNumber) ? (0, _dtableUtils.getNumberDisplayString)(valueNumber, data) : value;
59
59
  return displayValue;
60
60
  }
61
- case _dtableStore.CellType.DATE:
61
+ case _dtableUtils.CellType.DATE:
62
62
  {
63
63
  let displayValue = value;
64
64
  if (value && value.split('-').length === 3) {
@@ -71,16 +71,16 @@ const getTableValueDisplayName = (value, column) => {
71
71
  }
72
72
  return displayValue;
73
73
  }
74
- case _dtableStore.CellType.FORMULA:
75
- case _dtableStore.CellType.LINK_FORMULA:
74
+ case _dtableUtils.CellType.FORMULA:
75
+ case _dtableUtils.CellType.LINK_FORMULA:
76
76
  {
77
77
  let displayValue = value;
78
78
  let {
79
79
  result_type
80
80
  } = data || {};
81
- if (result_type === _dtableStore.FORMULA_RESULT_TYPE.NUMBER) {
81
+ if (result_type === _dtableUtils.FORMULA_RESULT_TYPE.NUMBER) {
82
82
  let valueNumber = parseFloat(value);
83
- displayValue = (0, _dtableStore.isNumber)(valueNumber) ? (0, _dtableStore.getNumberDisplayString)(valueNumber, data) : value;
83
+ displayValue = (0, _dtableUtils.isNumber)(valueNumber) ? (0, _dtableUtils.getNumberDisplayString)(valueNumber, data) : value;
84
84
  }
85
85
  return displayValue;
86
86
  }
@@ -96,19 +96,19 @@ const getValidValueForColumn = (column, value) => {
96
96
  type,
97
97
  data
98
98
  } = column;
99
- if (_dtableStore.FORMULA_COLUMN_TYPES.includes(type)) return '';
100
- if (type === _dtableStore.CellType.NUMBER) {
99
+ if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[type]) return '';
100
+ if (type === _dtableUtils.CellType.NUMBER) {
101
101
  if (!value && value !== 0) return '';
102
102
  if (typeof value === 'number') return value;
103
103
  return '';
104
104
  }
105
- if (type === _dtableStore.CellType.DATE) {
105
+ if (type === _dtableUtils.CellType.DATE) {
106
106
  if (!value) return '';
107
107
  if (typeof value !== 'string') return '';
108
108
  const validValueFormat = data && data.format && data.format.indexOf('HH:mm') > -1 ? 'YYYY-MM-DD HH:mm' : 'YYYY-MM-DD';
109
109
  return (0, _dayjs.default)(value).format(validValueFormat);
110
110
  }
111
- if (type === _dtableStore.CellType.TEXT) return value ? value : '';
111
+ if (type === _dtableUtils.CellType.TEXT) return value ? value : '';
112
112
  return '';
113
113
  };
114
114
  const exportOneDimensionToTable = _ref => {
@@ -132,7 +132,7 @@ const exportOneDimensionToTable = _ref => {
132
132
  let columns = [{
133
133
  // first column
134
134
  key: '0000',
135
- type: _dtableStore.CellType.TEXT,
135
+ type: _dtableUtils.CellType.TEXT,
136
136
  name: groupbyColumn.name,
137
137
  data: null
138
138
  }];
@@ -179,7 +179,7 @@ const exportOneDimensionToTable = _ref => {
179
179
 
180
180
  // total column
181
181
  const totalColumn = {
182
- type: _isDateSummaryColumn ? _dtableStore.CellType.DATE : _dtableStore.CellType.NUMBER,
182
+ type: _isDateSummaryColumn ? _dtableUtils.CellType.DATE : _dtableUtils.CellType.NUMBER,
183
183
  name: _reactIntlUniversal.default.get('Total'),
184
184
  data: columnData
185
185
  };
@@ -218,9 +218,9 @@ const exportOneDimensionToTable = _ref => {
218
218
  if (column) {
219
219
  const columnName = column.name;
220
220
  let columnData;
221
- let columnType = _dtableStore.CellType.NUMBER;
221
+ let columnType = _dtableUtils.CellType.NUMBER;
222
222
  if (isSummaryDateColumn(column)) {
223
- columnType = _dtableStore.CellType.DATE;
223
+ columnType = _dtableUtils.CellType.DATE;
224
224
  const {
225
225
  format
226
226
  } = column.data || {};
@@ -282,7 +282,7 @@ const exportOneDimensionToTable = _ref => {
282
282
  data
283
283
  } = column;
284
284
  let cellValue = total[cellValueKey];
285
- if (type === _dtableStore.CellType.DATE && cellValue) {
285
+ if (type === _dtableUtils.CellType.DATE && cellValue) {
286
286
  const dateFormat = data && data.format && data.format.indexOf('HH:mm') > -1 ? 'YYYY-MM-DD HH:mm' : 'YYYY-MM-DD';
287
287
  cellValue = (0, _dayjs.default)(cellValue).format(dateFormat);
288
288
  }
@@ -315,7 +315,7 @@ const exportTwoDimensionToTable = _ref2 => {
315
315
  let columns = [{
316
316
  // first column
317
317
  key: '0000',
318
- type: _dtableStore.CellType.TEXT,
318
+ type: _dtableUtils.CellType.TEXT,
319
319
  name: groupbyColumn.name,
320
320
  data: null
321
321
  }];
@@ -363,7 +363,7 @@ const exportTwoDimensionToTable = _ref2 => {
363
363
  } = item;
364
364
  const columnName = isEmptyName(original_key) ? _reactIntlUniversal.default.get(_constants.EMPTY_NAME) : key;
365
365
  const newColumn = {
366
- type: _isDateSummaryColumn ? _dtableStore.CellType.DATE : _dtableStore.CellType.NUMBER,
366
+ type: _isDateSummaryColumn ? _dtableUtils.CellType.DATE : _dtableUtils.CellType.NUMBER,
367
367
  name: columnName,
368
368
  data: columnData
369
369
  };
@@ -373,7 +373,7 @@ const exportTwoDimensionToTable = _ref2 => {
373
373
 
374
374
  // total column
375
375
  const totalColumn = {
376
- type: _isDateSummaryColumn ? _dtableStore.CellType.DATE : _dtableStore.CellType.NUMBER,
376
+ type: _isDateSummaryColumn ? _dtableUtils.CellType.DATE : _dtableUtils.CellType.NUMBER,
377
377
  name: _reactIntlUniversal.default.get('Total'),
378
378
  data: columnData
379
379
  };
@@ -435,7 +435,7 @@ const getTwoDimensionWithSummaryColumns = _ref3 => {
435
435
  let columns = [{
436
436
  // name column
437
437
  key: '0000',
438
- type: _dtableStore.CellType.TEXT,
438
+ type: _dtableUtils.CellType.TEXT,
439
439
  name: groupbyColumnName,
440
440
  data: null
441
441
  }];
@@ -458,7 +458,7 @@ const getTwoDimensionWithSummaryColumns = _ref3 => {
458
458
  const newColumnName = "".concat(pivotColumnColumnName, "-").concat(column_name);
459
459
  columns.push({
460
460
  // just support number column
461
- type: _dtableStore.CellType.NUMBER,
461
+ type: _dtableUtils.CellType.NUMBER,
462
462
  name: newColumnName,
463
463
  data
464
464
  });
@@ -473,7 +473,7 @@ const getTwoDimensionWithSummaryColumns = _ref3 => {
473
473
  });
474
474
  });
475
475
  columns.push({
476
- type: _dtableStore.CellType.NUMBER,
476
+ type: _dtableUtils.CellType.NUMBER,
477
477
  name: _reactIntlUniversal.default.get('Total'),
478
478
  data: firstSummaryColumn.data
479
479
  });
@@ -537,7 +537,7 @@ const updatedOneDimensionToTable = _ref5 => {
537
537
  statisticTableColumns
538
538
  } = statisticalResult;
539
539
  if (!groupbyColumn) return {};
540
- const nameColumn = _dtableStore.TableUtils.getTableColumnByName(updateTable, groupbyColumn.name);
540
+ const nameColumn = (0, _dtableUtils.getTableColumnByName)(updateTable, groupbyColumn.name);
541
541
  if (!nameColumn) return {};
542
542
  const {
543
543
  pivot_rows,
@@ -554,7 +554,7 @@ const updatedOneDimensionToTable = _ref5 => {
554
554
 
555
555
  // one dimension table no summary columns
556
556
  if (pivot_columns.length < 2) {
557
- columnMap['total'] = _dtableStore.TableUtils.getTableColumnByName(updateTable, _reactIntlUniversal.default.get('Total'));
557
+ columnMap['total'] = (0, _dtableUtils.getTableColumnByName)(updateTable, _reactIntlUniversal.default.get('Total'));
558
558
 
559
559
  // updated rows
560
560
  pivot_rows.forEach(item => {
@@ -606,7 +606,7 @@ const updatedOneDimensionToTable = _ref5 => {
606
606
  } = item;
607
607
  const column = statisticTableColumns.find(column => column.key === key);
608
608
  if (column) {
609
- columnMap[key] = _dtableStore.TableUtils.getTableColumnByName(updateTable, column.name);
609
+ columnMap[key] = (0, _dtableUtils.getTableColumnByName)(updateTable, column.name);
610
610
  }
611
611
  });
612
612
 
@@ -679,7 +679,7 @@ const updateTwoDimensionToTable = _ref6 => {
679
679
  pivotResult,
680
680
  groupbyColumn
681
681
  } = statisticalResult;
682
- const nameColumn = _dtableStore.TableUtils.getTableColumnByName(updateTable, groupbyColumn.name);
682
+ const nameColumn = (0, _dtableUtils.getTableColumnByName)(updateTable, groupbyColumn.name);
683
683
  if (!nameColumn) return {};
684
684
  const {
685
685
  pivot_rows,
@@ -702,11 +702,11 @@ const updateTwoDimensionToTable = _ref6 => {
702
702
  original_key
703
703
  } = item;
704
704
  const columnName = isEmptyName(original_key) ? _reactIntlUniversal.default.get(_constants.EMPTY_NAME) : key;
705
- const column = _dtableStore.TableUtils.getTableColumnByName(updateTable, columnName);
705
+ const column = (0, _dtableUtils.getTableColumnByName)(updateTable, columnName);
706
706
  columnMap[columnName] = column;
707
707
  updateColumns.push(column);
708
708
  });
709
- const totalColumn = _dtableStore.TableUtils.getTableColumnByName(updateTable, _reactIntlUniversal.default.get('Total'));
709
+ const totalColumn = (0, _dtableUtils.getTableColumnByName)(updateTable, _reactIntlUniversal.default.get('Total'));
710
710
  columnMap['total'] = totalColumn;
711
711
  updateColumns.push(totalColumn);
712
712
 
@@ -800,7 +800,7 @@ const updateTwoDimensionWithSummaryColumnsToTable = _ref7 => {
800
800
  const {
801
801
  groupbyColumn
802
802
  } = statisticalResult;
803
- const nameColumn = groupbyColumn && _dtableStore.TableUtils.getTableColumnByName(updateTable, groupbyColumn.name);
803
+ const nameColumn = groupbyColumn && (0, _dtableUtils.getTableColumnByName)(updateTable, groupbyColumn.name);
804
804
  if (!nameColumn) return {};
805
805
  const {
806
806
  columns: exportingColumns,
@@ -4,11 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getPivotTableSummaryTotal = void 0;
7
- var _dtableStore = require("dtable-store");
7
+ var _dtableUtils = require("dtable-utils");
8
8
  var _constants = require("../constants");
9
9
  const getCellValueFromRow = (row, formulaRow, columnType, columnKey, sqlKey, isSqlQuery) => {
10
10
  if (!isSqlQuery) {
11
- if (_dtableStore.FORMULA_COLUMN_TYPES_MAP[columnType]) {
11
+ if (_dtableUtils.FORMULA_COLUMN_TYPES_MAP[columnType]) {
12
12
  const cellValue = formulaRow[columnKey];
13
13
  return Array.isArray(cellValue) ? cellValue[0] : cellValue;
14
14
  }
@@ -53,7 +53,7 @@ const getPivotTableSummaryTotal = (summaryColumnType, summaryColumnKey, sqlKey,
53
53
  rows.forEach(row => {
54
54
  const formulaRow = formulaRows && formulaRows[row._id];
55
55
  let cellValue = getCellValueFromRow(row, formulaRow, summaryColumnType, summaryColumnKey, sqlKey, isSqlQuery);
56
- if ((0, _dtableStore.isNumber)(cellValue)) {
56
+ if ((0, _dtableUtils.isNumber)(cellValue)) {
57
57
  validNumbersCount++;
58
58
  sum += cellValue;
59
59
  }