dtable-statistic 4.3.3 → 4.3.4

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 (222) hide show
  1. package/es/api/dtable-db-api.js +3 -10
  2. package/es/calculator/base-calculator.js +12 -20
  3. package/es/calculator/basic-chart-calculator.js +65 -72
  4. package/es/calculator/combination-calculator.js +57 -64
  5. package/es/calculator/compare-bar-calculator.js +26 -33
  6. package/es/calculator/completeness-calculator.js +30 -37
  7. package/es/calculator/copy-value.js +1 -7
  8. package/es/calculator/dashboard-calculator.js +13 -20
  9. package/es/calculator/heat-map-calculator.js +18 -25
  10. package/es/calculator/horizontal-bar-calculator.js +8 -15
  11. package/es/calculator/index.js +35 -42
  12. package/es/calculator/map-calculator.js +22 -29
  13. package/es/calculator/mirror-calculator.js +20 -27
  14. package/es/calculator/number-card-calculator.js +10 -17
  15. package/es/calculator/pivot-table-calculator.js +58 -65
  16. package/es/calculator/scatter-calculator.js +14 -21
  17. package/es/calculator/thread-manager.js +1 -7
  18. package/es/calculator/trend-calculator.js +22 -29
  19. package/es/calculator/workers/basic-chart-calculator-worker.js +76 -83
  20. package/es/calculator/workers/calculator.worker.js +30 -33
  21. package/es/calculator/workers/card-calculator-worker.js +13 -19
  22. package/es/calculator/workers/combination-calculator-worker.js +46 -53
  23. package/es/calculator/workers/compare-bar-chart-calculator-worker.js +22 -29
  24. package/es/calculator/workers/completeness-calculator-worker.js +34 -41
  25. package/es/calculator/workers/dashboard-calculator-worker.js +18 -24
  26. package/es/calculator/workers/mirror-calculator-worker.js +22 -29
  27. package/es/calculator/workers/pivot-table-calculator-worker.js +77 -84
  28. package/es/calculator/workers/scatter-calculator-worker.js +20 -27
  29. package/es/calculator/workers/trend-calculator-worker.js +27 -34
  30. package/es/calculator/world-map-calculator.js +17 -24
  31. package/es/components/common-add-tool.js +5 -12
  32. package/es/components/dialog/chart-addition-edit-dialog.js +12 -20
  33. package/es/components/dialog/chart-addition-widgets/chart-selector.js +101 -108
  34. package/es/components/dialog/color-theme-dialog.js +15 -22
  35. package/es/components/dialog/delete-confirmation-dialog.js +11 -18
  36. package/es/components/dialog/enlarged-chart-dialog.js +20 -28
  37. package/es/components/dialog/new-table-dialog.js +16 -23
  38. package/es/components/dialog/new-view-dialog.js +14 -21
  39. package/es/components/dialog/rename-view-dialog.js +14 -22
  40. package/es/components/dialog/statistic-record-dialog/index.js +37 -45
  41. package/es/components/dialog/statistic-types-dialog/index.js +14 -22
  42. package/es/components/dialog/table-select-dialog.js +15 -23
  43. package/es/components/dropdown-menu/statistic-dropdown-menu.js +41 -49
  44. package/es/components/dtable-popover.js +12 -19
  45. package/es/components/dtable-search-input.js +13 -21
  46. package/es/components/dtable-select.js +15 -21
  47. package/es/components/icon.js +4 -11
  48. package/es/components/index.js +11 -76
  49. package/es/components/loading.js +3 -10
  50. package/es/components/modal-portal.js +5 -12
  51. package/es/components/popover/color-rules/color-rule.js +25 -33
  52. package/es/components/popover/color-rules/index.js +6 -14
  53. package/es/components/popover/color-rules/rule-filters/filter.js +27 -34
  54. package/es/components/popover/color-rules/rule-filters/index.js +17 -25
  55. package/es/components/popover/color-rules/rule-filters/number-input.js +9 -17
  56. package/es/components/popover/color-rules-popover.js +24 -32
  57. package/es/components/popover/color-selector-popover.js +10 -17
  58. package/es/components/seatable-radio/index.js +9 -16
  59. package/es/components/select/index.js +2 -9
  60. package/es/components/select/option-group.js +19 -27
  61. package/es/components/select/option.js +6 -14
  62. package/es/components/select/select.js +17 -25
  63. package/es/components/toast/alert.js +24 -31
  64. package/es/components/toast/index.js +3 -10
  65. package/es/components/toast/toast.js +12 -20
  66. package/es/components/toast/toastManager.js +9 -17
  67. package/es/components/toast/toaster.js +6 -14
  68. package/es/constants/color-rules.js +6 -12
  69. package/es/constants/dtable-select-style.js +4 -9
  70. package/es/constants/event-types.js +4 -10
  71. package/es/constants/index.js +67 -96
  72. package/es/constants/key-codes.js +0 -2
  73. package/es/constants/map.js +2 -8
  74. package/es/constants/model.js +20 -26
  75. package/es/constants/regions.js +3 -8
  76. package/es/constants/zIndexes.js +1 -7
  77. package/es/custom-g2.js +208 -236
  78. package/es/dashboard.js +50 -58
  79. package/es/desktop-dashboard.js +47 -55
  80. package/es/index.js +3 -6
  81. package/es/locale/index.js +10 -13
  82. package/es/locale/lang/de.js +1 -7
  83. package/es/locale/lang/en.js +1 -7
  84. package/es/locale/lang/fr.js +1 -7
  85. package/es/locale/lang/zh_CN.js +1 -7
  86. package/es/mobile-dashboard.js +38 -46
  87. package/es/model/bar-group.js +11 -19
  88. package/es/model/bar.js +10 -18
  89. package/es/model/base-model.js +2 -9
  90. package/es/model/basic-number-card.js +8 -16
  91. package/es/model/collaborators.js +2 -9
  92. package/es/model/combination.js +12 -20
  93. package/es/model/compare-bar.js +16 -24
  94. package/es/model/completeness-group.js +8 -16
  95. package/es/model/completeness.js +5 -13
  96. package/es/model/custom-bar.js +6 -14
  97. package/es/model/dashboard.js +6 -14
  98. package/es/model/generic-model.js +133 -141
  99. package/es/model/heat-map.js +11 -19
  100. package/es/model/horizontal-bar-group.js +10 -18
  101. package/es/model/horizontal-bar.js +10 -18
  102. package/es/model/index.js +53 -185
  103. package/es/model/map.js +15 -23
  104. package/es/model/mirror.js +13 -21
  105. package/es/model/pie.js +10 -18
  106. package/es/model/ring.js +11 -19
  107. package/es/model/scatter.js +6 -14
  108. package/es/model/statistic-dashboard.js +2 -9
  109. package/es/model/table.js +10 -18
  110. package/es/model/trend.js +12 -20
  111. package/es/model/world-map.js +13 -21
  112. package/es/service/chart-service.js +7 -14
  113. package/es/service/dashboard-service.js +34 -41
  114. package/es/service/map-json.js +8 -14
  115. package/es/stat-editor/chart-name-editor.js +8 -15
  116. package/es/stat-editor/index.js +16 -24
  117. package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +21 -29
  118. package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +49 -57
  119. package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +23 -31
  120. package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +4 -11
  121. package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +19 -27
  122. package/es/stat-editor/stat-settings/advance-chart-settings/index.js +43 -51
  123. package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +23 -31
  124. package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +23 -31
  125. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +37 -45
  126. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +19 -27
  127. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +26 -34
  128. package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +47 -55
  129. package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +22 -30
  130. package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +18 -26
  131. package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +27 -35
  132. package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +24 -32
  133. package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +33 -41
  134. package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +22 -30
  135. package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +27 -26
  136. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +46 -54
  137. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +23 -31
  138. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +26 -34
  139. package/es/stat-editor/stat-settings/basic-chart-settings/index.js +77 -85
  140. package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +21 -29
  141. package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +73 -81
  142. package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +16 -24
  143. package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +19 -27
  144. package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +18 -26
  145. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +49 -57
  146. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +17 -25
  147. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +47 -55
  148. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +11 -19
  149. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +45 -53
  150. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +9 -17
  151. package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +20 -28
  152. package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +30 -38
  153. package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +50 -58
  154. package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +17 -25
  155. package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +47 -55
  156. package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +11 -19
  157. package/es/stat-editor/stat-settings/color-setting/color-picker.js +12 -19
  158. package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +62 -70
  159. package/es/stat-editor/stat-settings/map/map-level.js +13 -20
  160. package/es/stat-editor/stat-settings/map/map-province-city.js +20 -27
  161. package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +11 -19
  162. package/es/stat-editor/stat-settings/public-setting/base-settings.js +20 -28
  163. package/es/stat-editor/stat-settings/public-setting/calender.js +22 -29
  164. package/es/stat-editor/stat-settings/public-setting/column-settings.js +6 -13
  165. package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +9 -16
  166. package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +13 -21
  167. package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +8 -15
  168. package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +11 -19
  169. package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +27 -35
  170. package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +8 -15
  171. package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +18 -26
  172. package/es/stat-list/chart-preview.js +20 -28
  173. package/es/stat-list/index.js +27 -35
  174. package/es/stat-view/area-chart.js +43 -50
  175. package/es/stat-view/bar-chart.js +47 -54
  176. package/es/stat-view/base-chart.js +24 -32
  177. package/es/stat-view/basic-number-card.js +19 -26
  178. package/es/stat-view/combination-chart.js +49 -56
  179. package/es/stat-view/compare-chart.js +39 -46
  180. package/es/stat-view/completeness-chart.js +28 -35
  181. package/es/stat-view/custom-bar.js +31 -38
  182. package/es/stat-view/dashboard-chart.js +15 -22
  183. package/es/stat-view/heat-map.js +43 -50
  184. package/es/stat-view/horizontal-bar-chart.js +51 -58
  185. package/es/stat-view/index.js +73 -80
  186. package/es/stat-view/line-chart.js +39 -46
  187. package/es/stat-view/map.js +33 -40
  188. package/es/stat-view/mirror.js +21 -28
  189. package/es/stat-view/pie-chart.js +29 -36
  190. package/es/stat-view/pivot-table/index.js +32 -39
  191. package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +31 -39
  192. package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +29 -37
  193. package/es/stat-view/pivot-table/pivot-table-display-name.js +46 -54
  194. package/es/stat-view/pivot-table/two-dimension-table.js +62 -70
  195. package/es/stat-view/ring-chart.js +38 -45
  196. package/es/stat-view/scatter-chart.js +30 -37
  197. package/es/stat-view/treemap-chart.js +37 -44
  198. package/es/stat-view/trend-chart.js +32 -39
  199. package/es/stat-view/world-map.js +33 -40
  200. package/es/tabs/index.js +32 -40
  201. package/es/tabs/tab.js +26 -34
  202. package/es/utils/basic-chart-utils.js +2 -9
  203. package/es/utils/cell-format.js +14 -22
  204. package/es/utils/cell-value.js +7 -14
  205. package/es/utils/collaborator.js +4 -13
  206. package/es/utils/color-utils.js +18 -29
  207. package/es/utils/column-utils.js +18 -29
  208. package/es/utils/column.js +4 -11
  209. package/es/utils/common-utils.js +41 -65
  210. package/es/utils/date-format.js +2 -8
  211. package/es/utils/export-table-utils.js +82 -91
  212. package/es/utils/index.js +11 -100
  213. package/es/utils/map.js +26 -36
  214. package/es/utils/model.js +6 -14
  215. package/es/utils/object.js +6 -15
  216. package/es/utils/pivot-table.js +16 -23
  217. package/es/utils/row-utils.js +23 -33
  218. package/es/utils/search.js +21 -29
  219. package/es/utils/sql-utils.js +65 -75
  220. package/es/utils/stat-utils.js +60 -66
  221. package/es/utils/trend-utils.js +32 -40
  222. package/package.json +1 -1
package/es/utils/map.js CHANGED
@@ -1,39 +1,32 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getRegionScaleOffsets = exports.getGeoGranularityByLevel = exports.fixMapGeoGranularity = exports.fixGeoGranularity = void 0;
7
- var _constants = require("../constants");
8
- var _map = require("../constants/map");
9
- var _regions = require("../constants/regions");
1
+ import { GEOLOCATION_GRANULARITY, STAT_TYPE } from '../constants';
2
+ import { MAP_LEVEL, MUNICIPALITIES } from '../constants/map';
3
+ import { regions } from '../constants/regions';
10
4
  const COUNTY_SCALE_WIDTH = 5.95;
11
5
  const COUNTY_SCALE_HEIGHT = 4.37;
12
- const getGeoGranularityByLevel = mapLevel => {
6
+ export const getGeoGranularityByLevel = mapLevel => {
13
7
  switch (mapLevel) {
14
- case _map.MAP_LEVEL.PROVINCE:
8
+ case MAP_LEVEL.PROVINCE:
15
9
  {
16
- return _constants.GEOLOCATION_GRANULARITY.CITY;
10
+ return GEOLOCATION_GRANULARITY.CITY;
17
11
  }
18
- case _map.MAP_LEVEL.CITY:
12
+ case MAP_LEVEL.CITY:
19
13
  {
20
- return _constants.GEOLOCATION_GRANULARITY.DISTRICT;
14
+ return GEOLOCATION_GRANULARITY.DISTRICT;
21
15
  }
22
16
  default:
23
17
  {
24
18
  // default as 'country'
25
- return _constants.GEOLOCATION_GRANULARITY.PROVINCE;
19
+ return GEOLOCATION_GRANULARITY.PROVINCE;
26
20
  }
27
21
  }
28
22
  };
29
- exports.getGeoGranularityByLevel = getGeoGranularityByLevel;
30
- const fixGeoGranularity = _ref => {
23
+ export const fixGeoGranularity = _ref => {
31
24
  let {
32
25
  mapLevel,
33
26
  mapLocation
34
27
  } = _ref;
35
- if (!mapLevel || mapLevel === _map.MAP_LEVEL.COUNTRY || !mapLocation) {
36
- return _constants.GEOLOCATION_GRANULARITY.PROVINCE;
28
+ if (!mapLevel || mapLevel === MAP_LEVEL.COUNTRY || !mapLocation) {
29
+ return GEOLOCATION_GRANULARITY.PROVINCE;
37
30
  }
38
31
 
39
32
  // e.g. Beijing
@@ -41,32 +34,31 @@ const fixGeoGranularity = _ref => {
41
34
  province: provinceName,
42
35
  city: cityName
43
36
  } = mapLocation;
44
- if (provinceName && _map.MUNICIPALITIES.includes(provinceName)) {
45
- return _constants.GEOLOCATION_GRANULARITY.DISTRICT;
37
+ if (provinceName && MUNICIPALITIES.includes(provinceName)) {
38
+ return GEOLOCATION_GRANULARITY.DISTRICT;
46
39
  }
47
40
 
48
41
  // e.g. HongKong
49
- const selectedProvince = provinceName && _regions.regions.find(province => province.name === provinceName);
42
+ const selectedProvince = provinceName && regions.find(province => province.name === provinceName);
50
43
  if (selectedProvince && selectedProvince.disable_drill_down) {
51
- return _constants.GEOLOCATION_GRANULARITY.PROVINCE;
44
+ return GEOLOCATION_GRANULARITY.PROVINCE;
52
45
  }
53
46
  const cities = selectedProvince && selectedProvince.cities;
54
47
  const selectedCity = cities && cityName && cities.find(city => city.name === cityName);
55
- if (mapLevel === _map.MAP_LEVEL.CITY && selectedCity && selectedCity.disable_drill_down) {
56
- return _constants.GEOLOCATION_GRANULARITY.CITY;
48
+ if (mapLevel === MAP_LEVEL.CITY && selectedCity && selectedCity.disable_drill_down) {
49
+ return GEOLOCATION_GRANULARITY.CITY;
57
50
  }
58
51
 
59
52
  // others
60
53
  return getGeoGranularityByLevel(mapLevel);
61
54
  };
62
- exports.fixGeoGranularity = fixGeoGranularity;
63
- const fixMapGeoGranularity = chart => {
55
+ export const fixMapGeoGranularity = chart => {
64
56
  const {
65
57
  type,
66
58
  map_level,
67
59
  map_location
68
60
  } = chart;
69
- if (type !== _constants.STAT_TYPE.MAP && type !== _constants.STAT_TYPE.MAP_BUBBLE) {
61
+ if (type !== STAT_TYPE.MAP && type !== STAT_TYPE.MAP_BUBBLE) {
70
62
  return chart.geolocation_granularity;
71
63
  }
72
64
  return fixGeoGranularity({
@@ -74,27 +66,26 @@ const fixMapGeoGranularity = chart => {
74
66
  mapLocation: map_location
75
67
  });
76
68
  };
77
- exports.fixMapGeoGranularity = fixMapGeoGranularity;
78
- const getRegionScaleOffsets = (mapLevel, mapLocation) => {
69
+ export const getRegionScaleOffsets = (mapLevel, mapLocation) => {
79
70
  const countryScaleOffsets = {
80
71
  scale_w: COUNTY_SCALE_WIDTH,
81
72
  scale_h: COUNTY_SCALE_HEIGHT
82
73
  };
83
74
  switch (mapLevel) {
84
- case _map.MAP_LEVEL.PROVINCE:
75
+ case MAP_LEVEL.PROVINCE:
85
76
  {
86
77
  const provinceName = mapLocation && mapLocation.province;
87
- const province = provinceName && _regions.regions.find(province => province.name === provinceName);
78
+ const province = provinceName && regions.find(province => province.name === provinceName);
88
79
  if (!province) return countryScaleOffsets;
89
80
  return {
90
81
  scale_w: province.scale_w,
91
82
  scale_h: province.scale_h
92
83
  };
93
84
  }
94
- case _map.MAP_LEVEL.CITY:
85
+ case MAP_LEVEL.CITY:
95
86
  {
96
87
  const provinceName = mapLocation && mapLocation.province;
97
- const province = provinceName && _regions.regions.find(province => province.name === provinceName);
88
+ const province = provinceName && regions.find(province => province.name === provinceName);
98
89
  const cities = province && province.cities;
99
90
  const cityName = mapLocation.city;
100
91
  const city = cityName && Array.isArray(cities) && cities.find(city => city.name === cityName);
@@ -110,5 +101,4 @@ const getRegionScaleOffsets = (mapLevel, mapLocation) => {
110
101
  return countryScaleOffsets;
111
102
  }
112
103
  }
113
- };
114
- exports.getRegionScaleOffsets = getRegionScaleOffsets;
104
+ };
package/es/utils/model.js CHANGED
@@ -1,19 +1,11 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getChartConfigValueFromKeys = exports.getChartConfigValueFromKey = void 0;
7
- var _object = require("./object");
8
- const getChartConfigValueFromKey = (key, object) => {
9
- if (!(0, _object.hasOwnProperty)(object, key)) {
1
+ import { hasOwnProperty } from './object';
2
+ export const getChartConfigValueFromKey = (key, object) => {
3
+ if (!hasOwnProperty(object, key)) {
10
4
  return null;
11
5
  }
12
6
  return object[key];
13
7
  };
14
- exports.getChartConfigValueFromKey = getChartConfigValueFromKey;
15
- const getChartConfigValueFromKeys = (keys, object) => {
16
- const existKey = keys.find(key => (0, _object.hasOwnProperty)(object, key));
8
+ export const getChartConfigValueFromKeys = (keys, object) => {
9
+ const existKey = keys.find(key => hasOwnProperty(object, key));
17
10
  return existKey ? object[existKey] : null;
18
- };
19
- exports.getChartConfigValueFromKeys = getChartConfigValueFromKeys;
11
+ };
@@ -1,15 +1,9 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isSameObject = exports.isEmptyObject = exports.hasOwnProperty = void 0;
7
- var _react = require("react");
8
- const isSameObject = (a, b) => {
1
+ import { isValidElement } from 'react';
2
+ export const isSameObject = (a, b) => {
9
3
  let k;
10
4
  for (k in a) {
11
5
  if (a.hasOwnProperty(k)) {
12
- if (typeof a[k] === 'function' && typeof b[k] === 'function' || /*#__PURE__*/(0, _react.isValidElement)(a[k]) && /*#__PURE__*/(0, _react.isValidElement)(b[k])) {
6
+ if (typeof a[k] === 'function' && typeof b[k] === 'function' || isValidElement(a[k]) && isValidElement(b[k])) {
13
7
  continue;
14
8
  }
15
9
  if (!b.hasOwnProperty(k) || a[k] !== b[k]) {
@@ -24,12 +18,9 @@ const isSameObject = (a, b) => {
24
18
  }
25
19
  return true;
26
20
  };
27
- exports.isSameObject = isSameObject;
28
- const isEmptyObject = obj => {
21
+ export const isEmptyObject = obj => {
29
22
  return Object.keys(obj).length === 0 && obj.constructor === Object;
30
23
  };
31
- exports.isEmptyObject = isEmptyObject;
32
- const hasOwnProperty = (obj, prop) => {
24
+ export const hasOwnProperty = (obj, prop) => {
33
25
  return Object.prototype.hasOwnProperty.call(obj, prop);
34
- };
35
- exports.hasOwnProperty = hasOwnProperty;
26
+ };
@@ -1,14 +1,8 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getPivotTableSummaryTotal = void 0;
7
- var _dtableStore = require("dtable-store");
8
- var _constants = require("../constants");
1
+ import { FORMULA_COLUMN_TYPES_MAP, isNumber } from 'dtable-store';
2
+ import { STATISTICS_COUNT_TYPE, SUMMARY_METHOD_MAP } from '../constants';
9
3
  const getCellValueFromRow = (row, formulaRow, columnType, columnKey, sqlKey, isSqlQuery) => {
10
4
  if (!isSqlQuery) {
11
- if (_dtableStore.FORMULA_COLUMN_TYPES_MAP[columnType]) {
5
+ if (FORMULA_COLUMN_TYPES_MAP[columnType]) {
12
6
  const cellValue = formulaRow[columnKey];
13
7
  return Array.isArray(cellValue) ? cellValue[0] : cellValue;
14
8
  }
@@ -16,15 +10,15 @@ const getCellValueFromRow = (row, formulaRow, columnType, columnKey, sqlKey, isS
16
10
  }
17
11
  return row[sqlKey];
18
12
  };
19
- const getPivotTableSummaryTotal = (summaryColumnType, summaryColumnKey, sqlKey, summaryType, summaryMethod, rows, formulaRows, isSqlQuery) => {
20
- if (summaryType === _constants.STATISTICS_COUNT_TYPE.COUNT) {
13
+ export const getPivotTableSummaryTotal = (summaryColumnType, summaryColumnKey, sqlKey, summaryType, summaryMethod, rows, formulaRows, isSqlQuery) => {
14
+ if (summaryType === STATISTICS_COUNT_TYPE.COUNT) {
21
15
  return rows.length;
22
16
  }
23
- if (summaryType !== _constants.STATISTICS_COUNT_TYPE.ADVANCED) {
17
+ if (summaryType !== STATISTICS_COUNT_TYPE.ADVANCED) {
24
18
  return 0;
25
19
  }
26
20
  switch (summaryMethod) {
27
- case _constants.SUMMARY_METHOD_MAP.Distinct_values:
21
+ case SUMMARY_METHOD_MAP.Distinct_values:
28
22
  {
29
23
  let count = 0;
30
24
  let existMap = {};
@@ -45,28 +39,28 @@ const getPivotTableSummaryTotal = (summaryColumnType, summaryColumnKey, sqlKey,
45
39
  });
46
40
  return count;
47
41
  }
48
- case _constants.SUMMARY_METHOD_MAP.Sum:
49
- case _constants.SUMMARY_METHOD_MAP.Mean:
42
+ case SUMMARY_METHOD_MAP.Sum:
43
+ case SUMMARY_METHOD_MAP.Mean:
50
44
  {
51
45
  let sum = 0;
52
46
  let validNumbersCount = 0;
53
47
  rows.forEach(row => {
54
48
  const formulaRow = formulaRows && formulaRows[row._id];
55
49
  let cellValue = getCellValueFromRow(row, formulaRow, summaryColumnType, summaryColumnKey, sqlKey, isSqlQuery);
56
- if ((0, _dtableStore.isNumber)(cellValue)) {
50
+ if (isNumber(cellValue)) {
57
51
  validNumbersCount++;
58
52
  sum += cellValue;
59
53
  }
60
54
  });
61
- if (summaryMethod === _constants.SUMMARY_METHOD_MAP.Sum) {
55
+ if (summaryMethod === SUMMARY_METHOD_MAP.Sum) {
62
56
  sum = Number.parseFloat(sum.toFixed(8));
63
- } else if (summaryMethod === _constants.SUMMARY_METHOD_MAP.Mean) {
57
+ } else if (summaryMethod === SUMMARY_METHOD_MAP.Mean) {
64
58
  sum = validNumbersCount === 0 ? 0 : Number.parseFloat((sum / validNumbersCount).toFixed(8));
65
59
  }
66
60
  return sum;
67
61
  }
68
- case _constants.SUMMARY_METHOD_MAP.Max:
69
- case _constants.SUMMARY_METHOD_MAP.Min:
62
+ case SUMMARY_METHOD_MAP.Max:
63
+ case SUMMARY_METHOD_MAP.Min:
70
64
  {
71
65
  if (rows.length === 0) {
72
66
  return 0;
@@ -80,7 +74,7 @@ const getPivotTableSummaryTotal = (summaryColumnType, summaryColumnKey, sqlKey,
80
74
  return current;
81
75
  }
82
76
  let isNextGreater = currentValue < nextValue;
83
- if (summaryMethod === _constants.SUMMARY_METHOD_MAP.Min) {
77
+ if (summaryMethod === SUMMARY_METHOD_MAP.Min) {
84
78
  return isNextGreater ? current : next;
85
79
  } else {
86
80
  return isNextGreater ? next : current;
@@ -94,5 +88,4 @@ const getPivotTableSummaryTotal = (summaryColumnType, summaryColumnKey, sqlKey,
94
88
  return 0;
95
89
  }
96
90
  }
97
- };
98
- exports.getPivotTableSummaryTotal = getPivotTableSummaryTotal;
91
+ };
@@ -1,13 +1,6 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getCellValue = getCellValue;
7
- exports.isValidRow = exports.isEmptyGeolocationCell = exports.getFormattedLabel = void 0;
8
- var _dtableStore = require("dtable-store");
9
- var _utils = require("../utils");
10
- const isEmptyGeolocationCell = (cellValue, format) => {
1
+ import { CellType, COLLABORATOR_COLUMN_TYPES, FORMULA_COLUMN_TYPES_MAP, FORMULA_RESULT_TYPE, isNumber, getNumberDisplayString } from 'dtable-store';
2
+ import { getClientFormulaDisplayString } from '../utils';
3
+ export const isEmptyGeolocationCell = (cellValue, format) => {
11
4
  if (!cellValue) return null;
12
5
  if (format === 'lng_lat') {
13
6
  return (cellValue.lng || cellValue.lng === 0) && (cellValue.lat || cellValue.lat === 0);
@@ -17,32 +10,30 @@ const isEmptyGeolocationCell = (cellValue, format) => {
17
10
  }
18
11
  return cellValue.province;
19
12
  };
20
- exports.isEmptyGeolocationCell = isEmptyGeolocationCell;
21
- const isValidRow = (row, formulaRow, column, includeEmpty) => {
13
+ export const isValidRow = (row, formulaRow, column, includeEmpty) => {
22
14
  const {
23
15
  type: columnType,
24
16
  key: columnKey
25
17
  } = column;
26
- if (includeEmpty || columnType === _dtableStore.CellType.CHECKBOX) return true;
27
- if (columnType === _dtableStore.CellType.GEOLOCATION) {
18
+ if (includeEmpty || columnType === CellType.CHECKBOX) return true;
19
+ if (columnType === CellType.GEOLOCATION) {
28
20
  const {
29
21
  geo_format
30
22
  } = column.data;
31
23
  return isEmptyGeolocationCell(row[columnKey], geo_format);
32
24
  }
33
25
  let cellValue = row[columnKey];
34
- if (_dtableStore.FORMULA_COLUMN_TYPES_MAP[columnType] || columnType === _dtableStore.CellType.LINK) {
26
+ if (FORMULA_COLUMN_TYPES_MAP[columnType] || columnType === CellType.LINK) {
35
27
  cellValue = formulaRow ? formulaRow[columnKey] : null;
36
28
  }
37
29
  return cellValue || cellValue === 0;
38
30
  };
39
- exports.isValidRow = isValidRow;
40
- const getFormattedLabel = (column, name, collaborators) => {
31
+ export const getFormattedLabel = (column, name, collaborators) => {
41
32
  let {
42
33
  type: columnType,
43
34
  data: columnData
44
35
  } = column;
45
- if (columnType === _dtableStore.CellType.SINGLE_SELECT || columnType === _dtableStore.CellType.MULTIPLE_SELECT) {
36
+ if (columnType === CellType.SINGLE_SELECT || columnType === CellType.MULTIPLE_SELECT) {
46
37
  let options = columnData ? columnData.options : [];
47
38
  let selectedOption = options.find(o => {
48
39
  let id = name;
@@ -57,7 +48,7 @@ const getFormattedLabel = (column, name, collaborators) => {
57
48
  if (selectedOption) {
58
49
  return optionName;
59
50
  }
60
- } else if (columnType === _dtableStore.CellType.COLLABORATOR) {
51
+ } else if (columnType === CellType.COLLABORATOR) {
61
52
  let collaborator = collaborators.find(item => {
62
53
  let email = name;
63
54
  if (Array.isArray(name)) {
@@ -68,7 +59,7 @@ const getFormattedLabel = (column, name, collaborators) => {
68
59
  if (collaborator) {
69
60
  return collaborator.name;
70
61
  }
71
- } else if (columnType === _dtableStore.CellType.CREATOR || columnType === _dtableStore.CellType.LAST_MODIFIER) {
62
+ } else if (columnType === CellType.CREATOR || columnType === CellType.LAST_MODIFIER) {
72
63
  if (name === 'anonymous') {
73
64
  return name;
74
65
  } else {
@@ -77,25 +68,25 @@ const getFormattedLabel = (column, name, collaborators) => {
77
68
  return collaborator.name;
78
69
  }
79
70
  }
80
- } else if (columnType === _dtableStore.CellType.LINK) {
81
- return (0, _utils.getClientFormulaDisplayString)(Array.isArray(name) ? name : [name], columnData, {
71
+ } else if (columnType === CellType.LINK) {
72
+ return getClientFormulaDisplayString(Array.isArray(name) ? name : [name], columnData, {
82
73
  collaborators
83
74
  });
84
- } else if (columnType === _dtableStore.CellType.CHECKBOX) {
75
+ } else if (columnType === CellType.CHECKBOX) {
85
76
  return name === 'true' ? 'Checked' : 'Unchecked';
86
- } else if (_dtableStore.FORMULA_COLUMN_TYPES_MAP[columnType]) {
77
+ } else if (FORMULA_COLUMN_TYPES_MAP[columnType]) {
87
78
  const {
88
79
  result_type,
89
80
  array_type
90
81
  } = columnData || {};
91
- if (!name && !(0, _dtableStore.isNumber)(name)) return '';
92
- if (result_type === _dtableStore.FORMULA_RESULT_TYPE.NUMBER) {
82
+ if (!name && !isNumber(name)) return '';
83
+ if (result_type === FORMULA_RESULT_TYPE.NUMBER) {
93
84
  const valueNumber = parseFloat(name);
94
- return (0, _dtableStore.isNumber)(valueNumber) ? (0, _dtableStore.getNumberDisplayString)(valueNumber, column.data) : name;
85
+ return isNumber(valueNumber) ? getNumberDisplayString(valueNumber, column.data) : name;
95
86
  }
96
- if (result_type === _dtableStore.FORMULA_RESULT_TYPE.ARRAY) {
97
- if (_dtableStore.COLLABORATOR_COLUMN_TYPES.includes(array_type)) {
98
- if ([_dtableStore.CellType.CREATOR, _dtableStore.CellType.LAST_MODIFIER].includes(array_type) && name === 'anonymous') {
87
+ if (result_type === FORMULA_RESULT_TYPE.ARRAY) {
88
+ if (COLLABORATOR_COLUMN_TYPES.includes(array_type)) {
89
+ if ([CellType.CREATOR, CellType.LAST_MODIFIER].includes(array_type) && name === 'anonymous') {
99
90
  return name;
100
91
  }
101
92
  const collaborator = collaborators.find(item => {
@@ -116,14 +107,13 @@ const getFormattedLabel = (column, name, collaborators) => {
116
107
  }
117
108
  return name;
118
109
  };
119
- exports.getFormattedLabel = getFormattedLabel;
120
- function getCellValue(row, formulaRow, column) {
110
+ export function getCellValue(row, formulaRow, column) {
121
111
  if (!column) return null;
122
112
  const {
123
113
  type,
124
114
  key
125
115
  } = column;
126
- if (_dtableStore.FORMULA_COLUMN_TYPES_MAP[type]) {
116
+ if (FORMULA_COLUMN_TYPES_MAP[type]) {
127
117
  const cellValue = formulaRow && formulaRow[key];
128
118
  if (Array.isArray(cellValue)) {
129
119
  return cellValue[0];
@@ -1,15 +1,8 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.searchRows = void 0;
8
- var _dayjs = _interopRequireDefault(require("dayjs"));
9
- var _dtableStore = require("dtable-store");
10
- var _column = require("./column");
11
- const SUPPORT_SEARCH_COLUMN_TYPES = [_dtableStore.CellType.DATE, _dtableStore.CellType.TEXT, _dtableStore.CellType.LONG_TEXT, _dtableStore.CellType.NUMBER, _dtableStore.CellType.URL, _dtableStore.CellType.EMAIL, _dtableStore.CellType.SINGLE_SELECT, _dtableStore.CellType.CTIME, _dtableStore.CellType.MTIME, _dtableStore.CellType.MULTIPLE_SELECT, _dtableStore.CellType.LAST_MODIFIER, _dtableStore.CellType.CREATOR, _dtableStore.CellType.COLLABORATOR, _dtableStore.CellType.LINK, _dtableStore.CellType.FORMULA, _dtableStore.CellType.LINK_FORMULA, _dtableStore.CellType.AUTO_NUMBER, _dtableStore.CellType.GEOLOCATION, _dtableStore.CellType.DURATION];
12
- const searchRows = (rows, columns, val, processRow) => {
1
+ import dayjs from 'dayjs';
2
+ import { CellType, getNumberDisplayString, getMultipleOptionName, getCollaboratorsName, getGeolocationDisplayString } from 'dtable-store';
3
+ import { getSelectColumnOptions } from './column';
4
+ const SUPPORT_SEARCH_COLUMN_TYPES = [CellType.DATE, CellType.TEXT, CellType.LONG_TEXT, CellType.NUMBER, CellType.URL, CellType.EMAIL, CellType.SINGLE_SELECT, CellType.CTIME, CellType.MTIME, CellType.MULTIPLE_SELECT, CellType.LAST_MODIFIER, CellType.CREATOR, CellType.COLLABORATOR, CellType.LINK, CellType.FORMULA, CellType.LINK_FORMULA, CellType.AUTO_NUMBER, CellType.GEOLOCATION, CellType.DURATION];
5
+ export const searchRows = (rows, columns, val, processRow) => {
13
6
  let dtableCollaborators = window.app.collaboratorsCache || [];
14
7
  let collaborators = window.app.state.collaborators;
15
8
  let searchResult = [];
@@ -25,20 +18,20 @@ const searchRows = (rows, columns, val, processRow) => {
25
18
  const cellValue = row[columnKey];
26
19
  if (cellValue) {
27
20
  let text;
28
- if (columnType === _dtableStore.CellType.LONG_TEXT) {
21
+ if (columnType === CellType.LONG_TEXT) {
29
22
  text = cellValue.text;
30
- } else if (columnType === _dtableStore.CellType.NUMBER || columnType === _dtableStore.CellType.DURATION) {
31
- text = (0, _dtableStore.getNumberDisplayString)(cellValue, column.data);
32
- } else if (columnType === _dtableStore.CellType.SINGLE_SELECT) {
33
- const options = (0, _column.getSelectColumnOptions)(column);
23
+ } else if (columnType === CellType.NUMBER || columnType === CellType.DURATION) {
24
+ text = getNumberDisplayString(cellValue, column.data);
25
+ } else if (columnType === CellType.SINGLE_SELECT) {
26
+ const options = getSelectColumnOptions(column);
34
27
  const option = options.find(option => option.id === cellValue);
35
28
  text = option ? option.name : '';
36
- } else if (columnType === _dtableStore.CellType.MULTIPLE_SELECT) {
37
- const options = (0, _column.getSelectColumnOptions)(column);
38
- text = (0, _dtableStore.getMultipleOptionName)(options, cellValue);
39
- } else if (columnType === _dtableStore.CellType.COLLABORATOR) {
40
- text = (0, _dtableStore.getCollaboratorsName)(collaborators, cellValue);
41
- } else if (columnType === _dtableStore.CellType.LAST_MODIFIER || columnType === _dtableStore.CellType.CREATOR) {
29
+ } else if (columnType === CellType.MULTIPLE_SELECT) {
30
+ const options = getSelectColumnOptions(column);
31
+ text = getMultipleOptionName(options, cellValue);
32
+ } else if (columnType === CellType.COLLABORATOR) {
33
+ text = getCollaboratorsName(collaborators, cellValue);
34
+ } else if (columnType === CellType.LAST_MODIFIER || columnType === CellType.CREATOR) {
42
35
  if (cellValue === 'anonymous') {
43
36
  text = cellValue;
44
37
  } else {
@@ -50,10 +43,10 @@ const searchRows = (rows, columns, val, processRow) => {
50
43
  text = collaborator.name;
51
44
  }
52
45
  }
53
- } else if (columnType === _dtableStore.CellType.GEOLOCATION) {
54
- text = (0, _dtableStore.getGeolocationDisplayString)(cellValue, column.data);
55
- } else if (columnType === _dtableStore.CellType.CTIME || columnType === _dtableStore.CellType.MTIME) {
56
- text = (0, _dayjs.default)(cellValue).format('YYYY-MM-DD HH:mm:ss');
46
+ } else if (columnType === CellType.GEOLOCATION) {
47
+ text = getGeolocationDisplayString(cellValue, column.data);
48
+ } else if (columnType === CellType.CTIME || columnType === CellType.MTIME) {
49
+ text = dayjs(cellValue).format('YYYY-MM-DD HH:mm:ss');
57
50
  } else {
58
51
  text = cellValue;
59
52
  }
@@ -69,5 +62,4 @@ const searchRows = (rows, columns, val, processRow) => {
69
62
  }
70
63
  });
71
64
  return searchResult;
72
- };
73
- exports.searchRows = searchRows;
65
+ };