dtable-statistic 4.3.1 → 4.3.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.
- package/es/api/dtable-db-api.js +10 -3
- package/es/calculator/base-calculator.js +20 -12
- package/es/calculator/basic-chart-calculator.js +72 -65
- package/es/calculator/combination-calculator.js +64 -57
- package/es/calculator/compare-bar-calculator.js +33 -26
- package/es/calculator/completeness-calculator.js +37 -30
- package/es/calculator/copy-value.js +7 -1
- package/es/calculator/dashboard-calculator.js +20 -13
- package/es/calculator/heat-map-calculator.js +25 -18
- package/es/calculator/horizontal-bar-calculator.js +15 -8
- package/es/calculator/index.js +42 -35
- package/es/calculator/map-calculator.js +29 -22
- package/es/calculator/mirror-calculator.js +27 -20
- package/es/calculator/number-card-calculator.js +17 -10
- package/es/calculator/pivot-table-calculator.js +65 -58
- package/es/calculator/scatter-calculator.js +21 -14
- package/es/calculator/thread-manager.js +7 -1
- package/es/calculator/trend-calculator.js +29 -22
- package/es/calculator/workers/basic-chart-calculator-worker.js +83 -76
- package/es/calculator/workers/calculator.worker.js +33 -30
- package/es/calculator/workers/card-calculator-worker.js +19 -13
- package/es/calculator/workers/combination-calculator-worker.js +53 -46
- package/es/calculator/workers/compare-bar-chart-calculator-worker.js +29 -22
- package/es/calculator/workers/completeness-calculator-worker.js +41 -34
- package/es/calculator/workers/dashboard-calculator-worker.js +24 -18
- package/es/calculator/workers/mirror-calculator-worker.js +29 -22
- package/es/calculator/workers/pivot-table-calculator-worker.js +84 -77
- package/es/calculator/workers/scatter-calculator-worker.js +27 -20
- package/es/calculator/workers/trend-calculator-worker.js +34 -27
- package/es/calculator/world-map-calculator.js +24 -17
- package/es/components/common-add-tool.js +12 -5
- package/es/components/dialog/chart-addition-edit-dialog.js +20 -12
- package/es/components/dialog/chart-addition-widgets/chart-selector.js +110 -103
- package/es/components/dialog/color-theme-dialog.js +22 -15
- package/es/components/dialog/delete-confirmation-dialog.js +18 -11
- package/es/components/dialog/enlarged-chart-dialog.js +28 -20
- package/es/components/dialog/new-table-dialog.js +23 -16
- package/es/components/dialog/new-view-dialog.js +22 -15
- package/es/components/dialog/rename-view-dialog.js +22 -14
- package/es/components/dialog/statistic-record-dialog/index.js +45 -37
- package/es/components/dialog/statistic-types-dialog/index.js +22 -14
- package/es/components/dialog/table-select-dialog.js +23 -15
- package/es/components/dropdown-menu/statistic-dropdown-menu.js +56 -43
- package/es/components/dtable-popover.js +19 -12
- package/es/components/dtable-search-input.js +21 -13
- package/es/components/dtable-select.js +20 -12
- package/es/components/icon.js +11 -4
- package/es/components/index.js +76 -11
- package/es/components/loading.js +10 -3
- package/es/components/modal-portal.js +12 -5
- package/es/components/popover/color-rules/color-rule.js +33 -25
- package/es/components/popover/color-rules/index.js +14 -6
- package/es/components/popover/color-rules/rule-filters/filter.js +35 -28
- package/es/components/popover/color-rules/rule-filters/index.js +25 -17
- package/es/components/popover/color-rules/rule-filters/number-input.js +17 -9
- package/es/components/popover/color-rules-popover.js +32 -24
- package/es/components/popover/color-selector-popover.js +17 -10
- package/es/components/seatable-radio/index.js +16 -9
- package/es/components/select/index.js +9 -2
- package/es/components/select/option-group.js +27 -19
- package/es/components/select/option.js +14 -6
- package/es/components/select/select.js +25 -17
- package/es/components/toast/alert.js +31 -24
- package/es/components/toast/index.js +10 -3
- package/es/components/toast/toast.js +20 -12
- package/es/components/toast/toastManager.js +17 -9
- package/es/components/toast/toaster.js +14 -6
- package/es/constants/color-rules.js +12 -6
- package/es/constants/dtable-select-style.js +9 -4
- package/es/constants/event-types.js +10 -4
- package/es/constants/index.js +96 -67
- package/es/constants/key-codes.js +2 -0
- package/es/constants/map.js +8 -2
- package/es/constants/model.js +26 -20
- package/es/constants/regions.js +8 -3
- package/es/constants/zIndexes.js +7 -1
- package/es/custom-g2.js +236 -208
- package/es/dashboard.js +58 -50
- package/es/desktop-dashboard.js +55 -47
- package/es/index.js +6 -3
- package/es/locale/index.js +13 -10
- package/es/locale/lang/de.js +7 -1
- package/es/locale/lang/en.js +7 -1
- package/es/locale/lang/fr.js +7 -1
- package/es/locale/lang/zh_CN.js +7 -1
- package/es/mobile-dashboard.js +46 -38
- package/es/model/bar-group.js +19 -11
- package/es/model/bar.js +18 -10
- package/es/model/base-model.js +9 -2
- package/es/model/basic-number-card.js +16 -8
- package/es/model/collaborators.js +9 -2
- package/es/model/combination.js +20 -12
- package/es/model/compare-bar.js +24 -16
- package/es/model/completeness-group.js +16 -8
- package/es/model/completeness.js +13 -5
- package/es/model/custom-bar.js +14 -6
- package/es/model/dashboard.js +14 -6
- package/es/model/generic-model.js +141 -133
- package/es/model/heat-map.js +19 -11
- package/es/model/horizontal-bar-group.js +18 -10
- package/es/model/horizontal-bar.js +18 -10
- package/es/model/index.js +185 -53
- package/es/model/map.js +23 -15
- package/es/model/mirror.js +21 -13
- package/es/model/pie.js +18 -10
- package/es/model/ring.js +19 -11
- package/es/model/scatter.js +14 -6
- package/es/model/statistic-dashboard.js +9 -2
- package/es/model/table.js +18 -10
- package/es/model/trend.js +20 -12
- package/es/model/world-map.js +21 -13
- package/es/service/chart-service.js +14 -7
- package/es/service/dashboard-service.js +42 -35
- package/es/service/map-json.js +14 -8
- package/es/stat-editor/chart-name-editor.js +15 -8
- package/es/stat-editor/index.js +24 -16
- package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +30 -22
- package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +57 -49
- package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +32 -24
- package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +11 -4
- package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +27 -19
- package/es/stat-editor/stat-settings/advance-chart-settings/index.js +51 -43
- package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +31 -23
- package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +31 -23
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +48 -40
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +29 -21
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +34 -26
- package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +55 -47
- package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +30 -22
- package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +26 -18
- package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +35 -27
- package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +32 -24
- package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +41 -33
- package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +30 -22
- package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +25 -17
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +54 -46
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +31 -23
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +34 -26
- package/es/stat-editor/stat-settings/basic-chart-settings/index.js +85 -77
- package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +29 -21
- package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +81 -73
- package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +24 -16
- package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +27 -19
- package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +26 -18
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +59 -51
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +27 -19
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +57 -49
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +20 -12
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +56 -48
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +17 -9
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +29 -21
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +38 -30
- package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +58 -50
- package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +25 -17
- package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +56 -47
- package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +20 -12
- package/es/stat-editor/stat-settings/color-setting/color-picker.js +19 -12
- package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +70 -62
- package/es/stat-editor/stat-settings/map/map-level.js +20 -13
- package/es/stat-editor/stat-settings/map/map-province-city.js +27 -20
- package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +19 -11
- package/es/stat-editor/stat-settings/public-setting/base-settings.js +28 -20
- package/es/stat-editor/stat-settings/public-setting/calender.js +29 -22
- package/es/stat-editor/stat-settings/public-setting/column-settings.js +13 -6
- package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +16 -9
- package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +21 -13
- package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +15 -8
- package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +19 -11
- package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +35 -27
- package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +15 -8
- package/es/stat-editor/stat-settings/public-setting/type-settings/index.js +26 -18
- package/es/stat-list/chart-preview.js +33 -20
- package/es/stat-list/index.js +36 -28
- package/es/stat-view/area-chart.js +51 -44
- package/es/stat-view/bar-chart.js +55 -48
- package/es/stat-view/base-chart.js +32 -24
- package/es/stat-view/basic-number-card.js +26 -19
- package/es/stat-view/combination-chart.js +57 -50
- package/es/stat-view/compare-chart.js +47 -40
- package/es/stat-view/completeness-chart.js +37 -30
- package/es/stat-view/custom-bar.js +38 -31
- package/es/stat-view/dashboard-chart.js +22 -15
- package/es/stat-view/heat-map.js +50 -43
- package/es/stat-view/horizontal-bar-chart.js +59 -52
- package/es/stat-view/index.js +80 -73
- package/es/stat-view/line-chart.js +47 -40
- package/es/stat-view/map.js +40 -33
- package/es/stat-view/mirror.js +28 -21
- package/es/stat-view/pie-chart.js +36 -29
- package/es/stat-view/pivot-table/index.js +39 -32
- package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +39 -31
- package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +37 -29
- package/es/stat-view/pivot-table/pivot-table-display-name.js +54 -46
- package/es/stat-view/pivot-table/two-dimension-table.js +70 -62
- package/es/stat-view/ring-chart.js +46 -39
- package/es/stat-view/scatter-chart.js +37 -30
- package/es/stat-view/treemap-chart.js +45 -38
- package/es/stat-view/trend-chart.js +39 -32
- package/es/stat-view/world-map.js +40 -33
- package/es/tabs/index.js +40 -32
- package/es/tabs/tab.js +35 -27
- package/es/utils/basic-chart-utils.js +9 -2
- package/es/utils/cell-format.js +22 -14
- package/es/utils/cell-value.js +14 -7
- package/es/utils/collaborator.js +13 -4
- package/es/utils/color-utils.js +29 -18
- package/es/utils/column-utils.js +29 -18
- package/es/utils/column.js +11 -4
- package/es/utils/common-utils.js +67 -43
- package/es/utils/date-format.js +8 -2
- package/es/utils/export-table-utils.js +91 -82
- package/es/utils/index.js +100 -11
- package/es/utils/map.js +36 -26
- package/es/utils/model.js +14 -6
- package/es/utils/object.js +15 -6
- package/es/utils/pivot-table.js +23 -16
- package/es/utils/row-utils.js +34 -24
- package/es/utils/search.js +29 -21
- package/es/utils/sql-utils.js +75 -65
- package/es/utils/stat-utils.js +67 -60
- package/es/utils/trend-utils.js +40 -32
- package/package.json +85 -132
package/es/utils/map.js
CHANGED
|
@@ -1,32 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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");
|
|
4
10
|
const COUNTY_SCALE_WIDTH = 5.95;
|
|
5
11
|
const COUNTY_SCALE_HEIGHT = 4.37;
|
|
6
|
-
|
|
12
|
+
const getGeoGranularityByLevel = mapLevel => {
|
|
7
13
|
switch (mapLevel) {
|
|
8
|
-
case MAP_LEVEL.PROVINCE:
|
|
14
|
+
case _map.MAP_LEVEL.PROVINCE:
|
|
9
15
|
{
|
|
10
|
-
return GEOLOCATION_GRANULARITY.CITY;
|
|
16
|
+
return _constants.GEOLOCATION_GRANULARITY.CITY;
|
|
11
17
|
}
|
|
12
|
-
case MAP_LEVEL.CITY:
|
|
18
|
+
case _map.MAP_LEVEL.CITY:
|
|
13
19
|
{
|
|
14
|
-
return GEOLOCATION_GRANULARITY.DISTRICT;
|
|
20
|
+
return _constants.GEOLOCATION_GRANULARITY.DISTRICT;
|
|
15
21
|
}
|
|
16
22
|
default:
|
|
17
23
|
{
|
|
18
24
|
// default as 'country'
|
|
19
|
-
return GEOLOCATION_GRANULARITY.PROVINCE;
|
|
25
|
+
return _constants.GEOLOCATION_GRANULARITY.PROVINCE;
|
|
20
26
|
}
|
|
21
27
|
}
|
|
22
28
|
};
|
|
23
|
-
|
|
29
|
+
exports.getGeoGranularityByLevel = getGeoGranularityByLevel;
|
|
30
|
+
const fixGeoGranularity = _ref => {
|
|
24
31
|
let {
|
|
25
32
|
mapLevel,
|
|
26
33
|
mapLocation
|
|
27
34
|
} = _ref;
|
|
28
|
-
if (!mapLevel || mapLevel === MAP_LEVEL.COUNTRY || !mapLocation) {
|
|
29
|
-
return GEOLOCATION_GRANULARITY.PROVINCE;
|
|
35
|
+
if (!mapLevel || mapLevel === _map.MAP_LEVEL.COUNTRY || !mapLocation) {
|
|
36
|
+
return _constants.GEOLOCATION_GRANULARITY.PROVINCE;
|
|
30
37
|
}
|
|
31
38
|
|
|
32
39
|
// e.g. Beijing
|
|
@@ -34,31 +41,32 @@ export const fixGeoGranularity = _ref => {
|
|
|
34
41
|
province: provinceName,
|
|
35
42
|
city: cityName
|
|
36
43
|
} = mapLocation;
|
|
37
|
-
if (provinceName && MUNICIPALITIES.includes(provinceName)) {
|
|
38
|
-
return GEOLOCATION_GRANULARITY.DISTRICT;
|
|
44
|
+
if (provinceName && _map.MUNICIPALITIES.includes(provinceName)) {
|
|
45
|
+
return _constants.GEOLOCATION_GRANULARITY.DISTRICT;
|
|
39
46
|
}
|
|
40
47
|
|
|
41
48
|
// e.g. HongKong
|
|
42
|
-
const selectedProvince = provinceName && regions.find(province => province.name === provinceName);
|
|
49
|
+
const selectedProvince = provinceName && _regions.regions.find(province => province.name === provinceName);
|
|
43
50
|
if (selectedProvince && selectedProvince.disable_drill_down) {
|
|
44
|
-
return GEOLOCATION_GRANULARITY.PROVINCE;
|
|
51
|
+
return _constants.GEOLOCATION_GRANULARITY.PROVINCE;
|
|
45
52
|
}
|
|
46
53
|
const cities = selectedProvince && selectedProvince.cities;
|
|
47
54
|
const selectedCity = cities && cityName && cities.find(city => city.name === cityName);
|
|
48
|
-
if (mapLevel === MAP_LEVEL.CITY && selectedCity && selectedCity.disable_drill_down) {
|
|
49
|
-
return GEOLOCATION_GRANULARITY.CITY;
|
|
55
|
+
if (mapLevel === _map.MAP_LEVEL.CITY && selectedCity && selectedCity.disable_drill_down) {
|
|
56
|
+
return _constants.GEOLOCATION_GRANULARITY.CITY;
|
|
50
57
|
}
|
|
51
58
|
|
|
52
59
|
// others
|
|
53
60
|
return getGeoGranularityByLevel(mapLevel);
|
|
54
61
|
};
|
|
55
|
-
|
|
62
|
+
exports.fixGeoGranularity = fixGeoGranularity;
|
|
63
|
+
const fixMapGeoGranularity = chart => {
|
|
56
64
|
const {
|
|
57
65
|
type,
|
|
58
66
|
map_level,
|
|
59
67
|
map_location
|
|
60
68
|
} = chart;
|
|
61
|
-
if (type !== STAT_TYPE.MAP && type !== STAT_TYPE.MAP_BUBBLE) {
|
|
69
|
+
if (type !== _constants.STAT_TYPE.MAP && type !== _constants.STAT_TYPE.MAP_BUBBLE) {
|
|
62
70
|
return chart.geolocation_granularity;
|
|
63
71
|
}
|
|
64
72
|
return fixGeoGranularity({
|
|
@@ -66,26 +74,27 @@ export const fixMapGeoGranularity = chart => {
|
|
|
66
74
|
mapLocation: map_location
|
|
67
75
|
});
|
|
68
76
|
};
|
|
69
|
-
|
|
77
|
+
exports.fixMapGeoGranularity = fixMapGeoGranularity;
|
|
78
|
+
const getRegionScaleOffsets = (mapLevel, mapLocation) => {
|
|
70
79
|
const countryScaleOffsets = {
|
|
71
80
|
scale_w: COUNTY_SCALE_WIDTH,
|
|
72
81
|
scale_h: COUNTY_SCALE_HEIGHT
|
|
73
82
|
};
|
|
74
83
|
switch (mapLevel) {
|
|
75
|
-
case MAP_LEVEL.PROVINCE:
|
|
84
|
+
case _map.MAP_LEVEL.PROVINCE:
|
|
76
85
|
{
|
|
77
86
|
const provinceName = mapLocation && mapLocation.province;
|
|
78
|
-
const province = provinceName && regions.find(province => province.name === provinceName);
|
|
87
|
+
const province = provinceName && _regions.regions.find(province => province.name === provinceName);
|
|
79
88
|
if (!province) return countryScaleOffsets;
|
|
80
89
|
return {
|
|
81
90
|
scale_w: province.scale_w,
|
|
82
91
|
scale_h: province.scale_h
|
|
83
92
|
};
|
|
84
93
|
}
|
|
85
|
-
case MAP_LEVEL.CITY:
|
|
94
|
+
case _map.MAP_LEVEL.CITY:
|
|
86
95
|
{
|
|
87
96
|
const provinceName = mapLocation && mapLocation.province;
|
|
88
|
-
const province = provinceName && regions.find(province => province.name === provinceName);
|
|
97
|
+
const province = provinceName && _regions.regions.find(province => province.name === provinceName);
|
|
89
98
|
const cities = province && province.cities;
|
|
90
99
|
const cityName = mapLocation.city;
|
|
91
100
|
const city = cityName && Array.isArray(cities) && cities.find(city => city.name === cityName);
|
|
@@ -101,4 +110,5 @@ export const getRegionScaleOffsets = (mapLevel, mapLocation) => {
|
|
|
101
110
|
return countryScaleOffsets;
|
|
102
111
|
}
|
|
103
112
|
}
|
|
104
|
-
};
|
|
113
|
+
};
|
|
114
|
+
exports.getRegionScaleOffsets = getRegionScaleOffsets;
|
package/es/utils/model.js
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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)) {
|
|
4
10
|
return null;
|
|
5
11
|
}
|
|
6
12
|
return object[key];
|
|
7
13
|
};
|
|
8
|
-
|
|
9
|
-
|
|
14
|
+
exports.getChartConfigValueFromKey = getChartConfigValueFromKey;
|
|
15
|
+
const getChartConfigValueFromKeys = (keys, object) => {
|
|
16
|
+
const existKey = keys.find(key => (0, _object.hasOwnProperty)(object, key));
|
|
10
17
|
return existKey ? object[existKey] : null;
|
|
11
|
-
};
|
|
18
|
+
};
|
|
19
|
+
exports.getChartConfigValueFromKeys = getChartConfigValueFromKeys;
|
package/es/utils/object.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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) => {
|
|
3
9
|
let k;
|
|
4
10
|
for (k in a) {
|
|
5
11
|
if (a.hasOwnProperty(k)) {
|
|
6
|
-
if (typeof a[k] === 'function' && typeof b[k] === 'function' || isValidElement(a[k]) && isValidElement(b[k])) {
|
|
12
|
+
if (typeof a[k] === 'function' && typeof b[k] === 'function' || /*#__PURE__*/(0, _react.isValidElement)(a[k]) && /*#__PURE__*/(0, _react.isValidElement)(b[k])) {
|
|
7
13
|
continue;
|
|
8
14
|
}
|
|
9
15
|
if (!b.hasOwnProperty(k) || a[k] !== b[k]) {
|
|
@@ -18,9 +24,12 @@ export const isSameObject = (a, b) => {
|
|
|
18
24
|
}
|
|
19
25
|
return true;
|
|
20
26
|
};
|
|
21
|
-
|
|
27
|
+
exports.isSameObject = isSameObject;
|
|
28
|
+
const isEmptyObject = obj => {
|
|
22
29
|
return Object.keys(obj).length === 0 && obj.constructor === Object;
|
|
23
30
|
};
|
|
24
|
-
|
|
31
|
+
exports.isEmptyObject = isEmptyObject;
|
|
32
|
+
const hasOwnProperty = (obj, prop) => {
|
|
25
33
|
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
26
|
-
};
|
|
34
|
+
};
|
|
35
|
+
exports.hasOwnProperty = hasOwnProperty;
|
package/es/utils/pivot-table.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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");
|
|
3
9
|
const getCellValueFromRow = (row, formulaRow, columnType, columnKey, sqlKey, isSqlQuery) => {
|
|
4
10
|
if (!isSqlQuery) {
|
|
5
|
-
if (FORMULA_COLUMN_TYPES_MAP[columnType]) {
|
|
11
|
+
if (_dtableStore.FORMULA_COLUMN_TYPES_MAP[columnType]) {
|
|
6
12
|
const cellValue = formulaRow[columnKey];
|
|
7
13
|
return Array.isArray(cellValue) ? cellValue[0] : cellValue;
|
|
8
14
|
}
|
|
@@ -10,15 +16,15 @@ const getCellValueFromRow = (row, formulaRow, columnType, columnKey, sqlKey, isS
|
|
|
10
16
|
}
|
|
11
17
|
return row[sqlKey];
|
|
12
18
|
};
|
|
13
|
-
|
|
14
|
-
if (summaryType === STATISTICS_COUNT_TYPE.COUNT) {
|
|
19
|
+
const getPivotTableSummaryTotal = (summaryColumnType, summaryColumnKey, sqlKey, summaryType, summaryMethod, rows, formulaRows, isSqlQuery) => {
|
|
20
|
+
if (summaryType === _constants.STATISTICS_COUNT_TYPE.COUNT) {
|
|
15
21
|
return rows.length;
|
|
16
22
|
}
|
|
17
|
-
if (summaryType !== STATISTICS_COUNT_TYPE.ADVANCED) {
|
|
23
|
+
if (summaryType !== _constants.STATISTICS_COUNT_TYPE.ADVANCED) {
|
|
18
24
|
return 0;
|
|
19
25
|
}
|
|
20
26
|
switch (summaryMethod) {
|
|
21
|
-
case SUMMARY_METHOD_MAP.Distinct_values:
|
|
27
|
+
case _constants.SUMMARY_METHOD_MAP.Distinct_values:
|
|
22
28
|
{
|
|
23
29
|
let count = 0;
|
|
24
30
|
let existMap = {};
|
|
@@ -39,28 +45,28 @@ export const getPivotTableSummaryTotal = (summaryColumnType, summaryColumnKey, s
|
|
|
39
45
|
});
|
|
40
46
|
return count;
|
|
41
47
|
}
|
|
42
|
-
case SUMMARY_METHOD_MAP.Sum:
|
|
43
|
-
case SUMMARY_METHOD_MAP.Mean:
|
|
48
|
+
case _constants.SUMMARY_METHOD_MAP.Sum:
|
|
49
|
+
case _constants.SUMMARY_METHOD_MAP.Mean:
|
|
44
50
|
{
|
|
45
51
|
let sum = 0;
|
|
46
52
|
let validNumbersCount = 0;
|
|
47
53
|
rows.forEach(row => {
|
|
48
54
|
const formulaRow = formulaRows && formulaRows[row._id];
|
|
49
55
|
let cellValue = getCellValueFromRow(row, formulaRow, summaryColumnType, summaryColumnKey, sqlKey, isSqlQuery);
|
|
50
|
-
if (isNumber(cellValue)) {
|
|
56
|
+
if ((0, _dtableStore.isNumber)(cellValue)) {
|
|
51
57
|
validNumbersCount++;
|
|
52
58
|
sum += cellValue;
|
|
53
59
|
}
|
|
54
60
|
});
|
|
55
|
-
if (summaryMethod === SUMMARY_METHOD_MAP.Sum) {
|
|
61
|
+
if (summaryMethod === _constants.SUMMARY_METHOD_MAP.Sum) {
|
|
56
62
|
sum = Number.parseFloat(sum.toFixed(8));
|
|
57
|
-
} else if (summaryMethod === SUMMARY_METHOD_MAP.Mean) {
|
|
63
|
+
} else if (summaryMethod === _constants.SUMMARY_METHOD_MAP.Mean) {
|
|
58
64
|
sum = validNumbersCount === 0 ? 0 : Number.parseFloat((sum / validNumbersCount).toFixed(8));
|
|
59
65
|
}
|
|
60
66
|
return sum;
|
|
61
67
|
}
|
|
62
|
-
case SUMMARY_METHOD_MAP.Max:
|
|
63
|
-
case SUMMARY_METHOD_MAP.Min:
|
|
68
|
+
case _constants.SUMMARY_METHOD_MAP.Max:
|
|
69
|
+
case _constants.SUMMARY_METHOD_MAP.Min:
|
|
64
70
|
{
|
|
65
71
|
if (rows.length === 0) {
|
|
66
72
|
return 0;
|
|
@@ -74,7 +80,7 @@ export const getPivotTableSummaryTotal = (summaryColumnType, summaryColumnKey, s
|
|
|
74
80
|
return current;
|
|
75
81
|
}
|
|
76
82
|
let isNextGreater = currentValue < nextValue;
|
|
77
|
-
if (summaryMethod === SUMMARY_METHOD_MAP.Min) {
|
|
83
|
+
if (summaryMethod === _constants.SUMMARY_METHOD_MAP.Min) {
|
|
78
84
|
return isNextGreater ? current : next;
|
|
79
85
|
} else {
|
|
80
86
|
return isNextGreater ? next : current;
|
|
@@ -88,4 +94,5 @@ export const getPivotTableSummaryTotal = (summaryColumnType, summaryColumnKey, s
|
|
|
88
94
|
return 0;
|
|
89
95
|
}
|
|
90
96
|
}
|
|
91
|
-
};
|
|
97
|
+
};
|
|
98
|
+
exports.getPivotTableSummaryTotal = getPivotTableSummaryTotal;
|
package/es/utils/row-utils.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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) => {
|
|
4
11
|
if (!cellValue) return null;
|
|
5
12
|
if (format === 'lng_lat') {
|
|
6
13
|
return (cellValue.lng || cellValue.lng === 0) && (cellValue.lat || cellValue.lat === 0);
|
|
@@ -10,30 +17,32 @@ export const isEmptyGeolocationCell = (cellValue, format) => {
|
|
|
10
17
|
}
|
|
11
18
|
return cellValue.province;
|
|
12
19
|
};
|
|
13
|
-
|
|
20
|
+
exports.isEmptyGeolocationCell = isEmptyGeolocationCell;
|
|
21
|
+
const isValidRow = (row, formulaRow, column, includeEmpty) => {
|
|
14
22
|
const {
|
|
15
23
|
type: columnType,
|
|
16
24
|
key: columnKey
|
|
17
25
|
} = column;
|
|
18
|
-
if (includeEmpty || columnType === CellType.CHECKBOX) return true;
|
|
19
|
-
if (columnType === CellType.GEOLOCATION) {
|
|
26
|
+
if (includeEmpty || columnType === _dtableStore.CellType.CHECKBOX) return true;
|
|
27
|
+
if (columnType === _dtableStore.CellType.GEOLOCATION) {
|
|
20
28
|
const {
|
|
21
29
|
geo_format
|
|
22
30
|
} = column.data;
|
|
23
31
|
return isEmptyGeolocationCell(row[columnKey], geo_format);
|
|
24
32
|
}
|
|
25
33
|
let cellValue = row[columnKey];
|
|
26
|
-
if (FORMULA_COLUMN_TYPES_MAP[columnType] || columnType === CellType.LINK) {
|
|
34
|
+
if (_dtableStore.FORMULA_COLUMN_TYPES_MAP[columnType] || columnType === _dtableStore.CellType.LINK) {
|
|
27
35
|
cellValue = formulaRow ? formulaRow[columnKey] : null;
|
|
28
36
|
}
|
|
29
37
|
return cellValue || cellValue === 0;
|
|
30
38
|
};
|
|
31
|
-
|
|
39
|
+
exports.isValidRow = isValidRow;
|
|
40
|
+
const getFormattedLabel = (column, name, collaborators) => {
|
|
32
41
|
let {
|
|
33
42
|
type: columnType,
|
|
34
43
|
data: columnData
|
|
35
44
|
} = column;
|
|
36
|
-
if (columnType === CellType.SINGLE_SELECT || columnType === CellType.MULTIPLE_SELECT) {
|
|
45
|
+
if (columnType === _dtableStore.CellType.SINGLE_SELECT || columnType === _dtableStore.CellType.MULTIPLE_SELECT) {
|
|
37
46
|
let options = columnData ? columnData.options : [];
|
|
38
47
|
let selectedOption = options.find(o => {
|
|
39
48
|
let id = name;
|
|
@@ -48,7 +57,7 @@ export const getFormattedLabel = (column, name, collaborators) => {
|
|
|
48
57
|
if (selectedOption) {
|
|
49
58
|
return optionName;
|
|
50
59
|
}
|
|
51
|
-
} else if (columnType === CellType.COLLABORATOR) {
|
|
60
|
+
} else if (columnType === _dtableStore.CellType.COLLABORATOR) {
|
|
52
61
|
let collaborator = collaborators.find(item => {
|
|
53
62
|
let email = name;
|
|
54
63
|
if (Array.isArray(name)) {
|
|
@@ -59,7 +68,7 @@ export const getFormattedLabel = (column, name, collaborators) => {
|
|
|
59
68
|
if (collaborator) {
|
|
60
69
|
return collaborator.name;
|
|
61
70
|
}
|
|
62
|
-
} else if (columnType === CellType.CREATOR || columnType === CellType.LAST_MODIFIER) {
|
|
71
|
+
} else if (columnType === _dtableStore.CellType.CREATOR || columnType === _dtableStore.CellType.LAST_MODIFIER) {
|
|
63
72
|
if (name === 'anonymous') {
|
|
64
73
|
return name;
|
|
65
74
|
} else {
|
|
@@ -68,25 +77,25 @@ export const getFormattedLabel = (column, name, collaborators) => {
|
|
|
68
77
|
return collaborator.name;
|
|
69
78
|
}
|
|
70
79
|
}
|
|
71
|
-
} else if (columnType === CellType.LINK) {
|
|
72
|
-
return getClientFormulaDisplayString(Array.isArray(name) ? name : [name], columnData, {
|
|
80
|
+
} else if (columnType === _dtableStore.CellType.LINK) {
|
|
81
|
+
return (0, _utils.getClientFormulaDisplayString)(Array.isArray(name) ? name : [name], columnData, {
|
|
73
82
|
collaborators
|
|
74
83
|
});
|
|
75
|
-
} else if (columnType === CellType.CHECKBOX) {
|
|
76
|
-
return name
|
|
77
|
-
} else if (FORMULA_COLUMN_TYPES_MAP[columnType]) {
|
|
84
|
+
} else if (columnType === _dtableStore.CellType.CHECKBOX) {
|
|
85
|
+
return name === 'true' ? 'Checked' : 'Unchecked';
|
|
86
|
+
} else if (_dtableStore.FORMULA_COLUMN_TYPES_MAP[columnType]) {
|
|
78
87
|
const {
|
|
79
88
|
result_type,
|
|
80
89
|
array_type
|
|
81
90
|
} = columnData || {};
|
|
82
|
-
if (!name && !isNumber(name)) return '';
|
|
83
|
-
if (result_type === FORMULA_RESULT_TYPE.NUMBER) {
|
|
91
|
+
if (!name && !(0, _dtableStore.isNumber)(name)) return '';
|
|
92
|
+
if (result_type === _dtableStore.FORMULA_RESULT_TYPE.NUMBER) {
|
|
84
93
|
const valueNumber = parseFloat(name);
|
|
85
|
-
return isNumber(valueNumber) ? getNumberDisplayString(valueNumber, column.data) : name;
|
|
94
|
+
return (0, _dtableStore.isNumber)(valueNumber) ? (0, _dtableStore.getNumberDisplayString)(valueNumber, column.data) : name;
|
|
86
95
|
}
|
|
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') {
|
|
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') {
|
|
90
99
|
return name;
|
|
91
100
|
}
|
|
92
101
|
const collaborator = collaborators.find(item => {
|
|
@@ -107,13 +116,14 @@ export const getFormattedLabel = (column, name, collaborators) => {
|
|
|
107
116
|
}
|
|
108
117
|
return name;
|
|
109
118
|
};
|
|
110
|
-
|
|
119
|
+
exports.getFormattedLabel = getFormattedLabel;
|
|
120
|
+
function getCellValue(row, formulaRow, column) {
|
|
111
121
|
if (!column) return null;
|
|
112
122
|
const {
|
|
113
123
|
type,
|
|
114
124
|
key
|
|
115
125
|
} = column;
|
|
116
|
-
if (FORMULA_COLUMN_TYPES_MAP[type]) {
|
|
126
|
+
if (_dtableStore.FORMULA_COLUMN_TYPES_MAP[type]) {
|
|
117
127
|
const cellValue = formulaRow && formulaRow[key];
|
|
118
128
|
if (Array.isArray(cellValue)) {
|
|
119
129
|
return cellValue[0];
|
package/es/utils/search.js
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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) => {
|
|
6
13
|
let dtableCollaborators = window.app.collaboratorsCache || [];
|
|
7
14
|
let collaborators = window.app.state.collaborators;
|
|
8
15
|
let searchResult = [];
|
|
@@ -18,20 +25,20 @@ export const searchRows = (rows, columns, val, processRow) => {
|
|
|
18
25
|
const cellValue = row[columnKey];
|
|
19
26
|
if (cellValue) {
|
|
20
27
|
let text;
|
|
21
|
-
if (columnType === CellType.LONG_TEXT) {
|
|
28
|
+
if (columnType === _dtableStore.CellType.LONG_TEXT) {
|
|
22
29
|
text = cellValue.text;
|
|
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);
|
|
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);
|
|
27
34
|
const option = options.find(option => option.id === cellValue);
|
|
28
35
|
text = option ? option.name : '';
|
|
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) {
|
|
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) {
|
|
35
42
|
if (cellValue === 'anonymous') {
|
|
36
43
|
text = cellValue;
|
|
37
44
|
} else {
|
|
@@ -43,10 +50,10 @@ export const searchRows = (rows, columns, val, processRow) => {
|
|
|
43
50
|
text = collaborator.name;
|
|
44
51
|
}
|
|
45
52
|
}
|
|
46
|
-
} else if (columnType === CellType.GEOLOCATION) {
|
|
47
|
-
text = getGeolocationDisplayString(cellValue, column.data);
|
|
48
|
-
} else if (columnType === CellType.CTIME || columnType === CellType.MTIME) {
|
|
49
|
-
text =
|
|
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');
|
|
50
57
|
} else {
|
|
51
58
|
text = cellValue;
|
|
52
59
|
}
|
|
@@ -62,4 +69,5 @@ export const searchRows = (rows, columns, val, processRow) => {
|
|
|
62
69
|
}
|
|
63
70
|
});
|
|
64
71
|
return searchResult;
|
|
65
|
-
};
|
|
72
|
+
};
|
|
73
|
+
exports.searchRows = searchRows;
|