sea-chart 2.0.36 → 2.0.38
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/dist/api/index.js +8 -15
- package/dist/components/cell-factory/FormatterConfig.js +55 -62
- package/dist/components/cell-factory/SimpleCellFormatter.js +5 -12
- package/dist/components/cell-factory/SingleSelectOption.js +11 -18
- package/dist/components/cell-factory/cell-editor-factory.js +5 -12
- package/dist/components/cell-factory/cell-formatter-factory.js +4 -11
- package/dist/components/cell-factory/link-content.js +30 -38
- package/dist/components/chart-color-selector/color-selector.js +11 -18
- package/dist/components/collaborator/index.js +7 -14
- package/dist/components/color-picker/index.js +12 -19
- package/dist/components/color-popover/color-rules/color-rule.js +26 -34
- package/dist/components/color-popover/color-rules/index.js +7 -15
- package/dist/components/color-popover/color-rules/rule-filters/filter.js +27 -34
- package/dist/components/color-popover/color-rules/rule-filters/index.js +17 -25
- package/dist/components/color-popover/color-rules/rule-filters/number-input.js +9 -17
- package/dist/components/color-popover/color-rules-popover.js +30 -38
- package/dist/components/color-popover/color-selector-popover.js +12 -20
- package/dist/components/color-setting/color-group-selector.js +13 -21
- package/dist/components/common-add-tool/index.js +8 -15
- package/dist/components/data-process-setter/data-setting-header.js +7 -14
- package/dist/components/data-process-setter/hide-column-setter.js +13 -20
- package/dist/components/data-process-setter/index.js +4 -27
- package/dist/components/data-process-setter/sort-setter.js +18 -26
- package/dist/components/draggable/Draggable.js +7 -13
- package/dist/components/drill-down-settings/drill-down-fields-popover/index.js +40 -48
- package/dist/components/drill-down-settings/drill-down-fields-settings/index.js +10 -18
- package/dist/components/drill-down-settings/index.js +11 -18
- package/dist/components/dtable-popover/index.js +13 -20
- package/dist/components/dtable-search-input/index.js +13 -21
- package/dist/components/font-settings/index.js +14 -22
- package/dist/components/goal-line-setting/goal-setting-item.js +6 -14
- package/dist/components/goal-line-setting/index.js +12 -19
- package/dist/components/highlighter/highlighter.js +7 -14
- package/dist/components/icon/index.js +5 -12
- package/dist/components/index.js +7 -48
- package/dist/components/loading/index.js +6 -13
- package/dist/components/number-input/index.js +4 -11
- package/dist/components/pixel-editor/index.js +15 -23
- package/dist/components/popover/hide-column-popover/hide-column-popover-widgets/hide-column-item.js +8 -15
- package/dist/components/popover/hide-column-popover/hide-column-popover.js +26 -34
- package/dist/components/popover/sort-popover/sort-popover-widgets/sort-utils.js +9 -18
- package/dist/components/popover/sort-popover/sort-popover.js +55 -65
- package/dist/components/resize-handle/ResizeHandle.js +6 -13
- package/dist/components/row-card/row-card-header-cell.js +17 -24
- package/dist/components/row-card/row-card-header.js +15 -22
- package/dist/components/row-card/row-card-item.js +35 -43
- package/dist/components/row-card/row-card.js +17 -25
- package/dist/components/statistic-record-dialog/index.js +56 -64
- package/dist/components/tooltip/index.js +14 -21
- package/dist/components/types-dialog/index.js +62 -70
- package/dist/components/types-dialog/use-force-update.js +4 -10
- package/dist/constants/color-rules.js +8 -14
- package/dist/constants/common-constants.js +8 -14
- package/dist/constants/error.js +2 -8
- package/dist/constants/geolocation.js +9 -15
- package/dist/constants/index.js +142 -271
- package/dist/constants/key-codes.js +0 -2
- package/dist/constants/model.js +3 -9
- package/dist/constants/regions.js +3 -8
- package/dist/constants/style.js +6 -12
- package/dist/constants/table.js +1 -7
- package/dist/constants/type-image.js +33 -39
- package/dist/constants/type.js +3 -9
- package/dist/context.js +13 -20
- package/dist/editor/index.js +8 -15
- package/dist/index.js +13 -104
- package/dist/intl.js +10 -17
- package/dist/locale/index.js +16 -23
- package/dist/locale/lang/de.js +1 -7
- package/dist/locale/lang/en.js +1 -7
- package/dist/locale/lang/es.js +1 -7
- package/dist/locale/lang/fr.js +1 -7
- package/dist/locale/lang/pt.js +1 -7
- package/dist/locale/lang/ru.js +1 -7
- package/dist/locale/lang/zh_CN.js +1 -7
- package/dist/model/area-group.js +12 -19
- package/dist/model/area.js +12 -19
- package/dist/model/bar-custom.js +11 -18
- package/dist/model/bar-group.js +12 -19
- package/dist/model/bar-stack.js +10 -17
- package/dist/model/bar.js +11 -18
- package/dist/model/base-model.js +4 -11
- package/dist/model/basic-number-card.js +13 -20
- package/dist/model/chart.js +7 -13
- package/dist/model/combination.js +15 -22
- package/dist/model/compare-bar.js +14 -21
- package/dist/model/completeness-group.js +11 -18
- package/dist/model/completeness.js +10 -17
- package/dist/model/dashboard.js +7 -14
- package/dist/model/funnel.js +14 -21
- package/dist/model/generic-model.js +135 -143
- package/dist/model/heat-map.js +9 -16
- package/dist/model/horizontal-bar.js +11 -18
- package/dist/model/horizontal-group-bar.js +10 -17
- package/dist/model/index.js +69 -93
- package/dist/model/line-group.js +13 -20
- package/dist/model/line.js +12 -19
- package/dist/model/map-bubble.js +12 -19
- package/dist/model/map.js +12 -19
- package/dist/model/mirror.js +13 -20
- package/dist/model/pie.js +12 -19
- package/dist/model/ring.js +12 -19
- package/dist/model/scatter.js +10 -17
- package/dist/model/stacked-horizontal-bar.js +11 -18
- package/dist/model/table-element.js +5 -12
- package/dist/model/table.js +7 -14
- package/dist/model/tree-map.js +7 -14
- package/dist/model/trend.js +11 -18
- package/dist/model/user.js +1 -7
- package/dist/model/world-map-bubble.js +12 -19
- package/dist/model/world-map.js +12 -19
- package/dist/services/map-json.js +11 -17
- package/dist/settings/advance-bar-settings/data-settings.js +36 -44
- package/dist/settings/advance-bar-settings/index.js +3 -20
- package/dist/settings/advance-bar-settings/style-settings.js +63 -71
- package/dist/settings/bar-settings/data-settings.js +39 -47
- package/dist/settings/bar-settings/index.js +3 -20
- package/dist/settings/bar-settings/style-settings.js +49 -57
- package/dist/settings/basic-number-card/data-settings.js +49 -57
- package/dist/settings/basic-number-card/index.js +3 -20
- package/dist/settings/basic-number-card/style-settings.js +19 -27
- package/dist/settings/combination-settings/data-settings.js +55 -63
- package/dist/settings/combination-settings/index.js +3 -20
- package/dist/settings/combination-settings/style-settings.js +65 -73
- package/dist/settings/completeness-settings/callbacks/callbacks.js +16 -27
- package/dist/settings/completeness-settings/data-settings/completion-settings.js +21 -28
- package/dist/settings/completeness-settings/data-settings/data-settings.js +25 -32
- package/dist/settings/completeness-settings/index.js +3 -20
- package/dist/settings/completeness-settings/style-settings.js +19 -26
- package/dist/settings/dashboard-settings/data-settings.js +43 -51
- package/dist/settings/dashboard-settings/index.js +2 -13
- package/dist/settings/data-settings.js +72 -79
- package/dist/settings/funnel-settings/components/dnd-item/dnd-item.js +12 -19
- package/dist/settings/funnel-settings/components/dnd-list.js +15 -23
- package/dist/settings/funnel-settings/components/funnel-label-setting.js +32 -40
- package/dist/settings/funnel-settings/components/funnel-layer-setting.js +20 -28
- package/dist/settings/funnel-settings/data-settings.js +23 -31
- package/dist/settings/funnel-settings/index.js +3 -20
- package/dist/settings/funnel-settings/style-settings.js +11 -19
- package/dist/settings/heat-map-settings/data-settings.js +18 -26
- package/dist/settings/heat-map-settings/index.js +3 -20
- package/dist/settings/heat-map-settings/style-settings.js +18 -26
- package/dist/settings/horizontal-bar-settings/data-settings.js +12 -19
- package/dist/settings/horizontal-bar-settings/index.js +3 -20
- package/dist/settings/horizontal-bar-settings/style-settings.js +12 -19
- package/dist/settings/index.js +52 -70
- package/dist/settings/map-settings/components/location-field-selector.js +10 -17
- package/dist/settings/map-settings/components/map-level-selector.js +11 -18
- package/dist/settings/map-settings/components/map-province-city-selector.js +19 -26
- package/dist/settings/map-settings/index.js +3 -20
- package/dist/settings/map-settings/map-data-settings.js +23 -30
- package/dist/settings/map-settings/map-style-settings.js +27 -35
- package/dist/settings/mirror-settings/data-settings.js +26 -34
- package/dist/settings/mirror-settings/index.js +2 -13
- package/dist/settings/pie-settings/data-settings.js +33 -41
- package/dist/settings/pie-settings/index.js +3 -20
- package/dist/settings/pie-settings/style-settings.js +47 -55
- package/dist/settings/scatter/data-settings.js +27 -34
- package/dist/settings/scatter/index.js +3 -12
- package/dist/settings/stacks-settings/index.js +19 -27
- package/dist/settings/stacks-settings/stack-item-settings.js +19 -27
- package/dist/settings/style-settings.js +65 -73
- package/dist/settings/table-element-settings/components/data-filter.js +30 -38
- package/dist/settings/table-element-settings/data-settings.js +21 -29
- package/dist/settings/table-element-settings/index.js +2 -13
- package/dist/settings/table-settings/data-settings.js +112 -120
- package/dist/settings/table-settings/index.js +2 -13
- package/dist/settings/time-comparison-settings/data-settings.js +43 -51
- package/dist/settings/time-comparison-settings/index.js +3 -20
- package/dist/settings/time-comparison-settings/style-settings.js +42 -50
- package/dist/settings/trend-settings/data-settings.js +24 -32
- package/dist/settings/trend-settings/index.js +3 -20
- package/dist/settings/trend-settings/style-setting.js +19 -27
- package/dist/settings/widgets/basic-summary/index.js +55 -63
- package/dist/settings/widgets/chart-type/index.js +18 -26
- package/dist/settings/widgets/color-settings/index.js +72 -80
- package/dist/settings/widgets/common-data-settings.js +21 -29
- package/dist/settings/widgets/data-filter/index.js +35 -43
- package/dist/settings/widgets/data-sort.js +16 -24
- package/dist/settings/widgets/date-summary-item.js +26 -34
- package/dist/settings/widgets/display-values-settings/index.js +14 -22
- package/dist/settings/widgets/divider/index.js +8 -16
- package/dist/settings/widgets/font-settings/font-color-settings.js +11 -19
- package/dist/settings/widgets/font-settings/font-size-settings.js +14 -22
- package/dist/settings/widgets/font-settings/font-weight-settings.js +17 -25
- package/dist/settings/widgets/font-settings/index.js +4 -27
- package/dist/settings/widgets/group-by.js +51 -59
- package/dist/settings/widgets/min-max-setting.js +10 -18
- package/dist/settings/widgets/mininum-slice-percent.js +10 -18
- package/dist/settings/widgets/numeric-summary-item.js +25 -33
- package/dist/settings/widgets/select-line-type/index.js +10 -17
- package/dist/settings/widgets/select-table/index.js +9 -16
- package/dist/settings/widgets/select-view/index.js +20 -28
- package/dist/settings/widgets/stack.js +14 -22
- package/dist/settings/widgets/summary-method-setting.js +17 -25
- package/dist/settings/widgets/summary-settings.js +74 -82
- package/dist/settings/widgets/switch/index.js +9 -16
- package/dist/settings/widgets/text-horizontal-settings.js +15 -23
- package/dist/settings/widgets/time-picker.js +29 -37
- package/dist/settings/widgets/title-settings/index.js +29 -37
- package/dist/settings/widgets/title-settings/title-text.js +5 -12
- package/dist/settings/widgets/x-axios.js +0 -1
- package/dist/settings/widgets/y-axis-group-settings.js +64 -72
- package/dist/utils/cell-format-utils.js +17 -27
- package/dist/utils/cell-value-utils.js +4 -11
- package/dist/utils/chart-utils/base-utils.js +324 -332
- package/dist/utils/chart-utils/index.js +28 -41
- package/dist/utils/chart-utils/original-data-utils/basic-chart-calculator.js +77 -84
- package/dist/utils/chart-utils/original-data-utils/card-calculator.js +13 -20
- package/dist/utils/chart-utils/original-data-utils/combination-calculator.js +45 -52
- package/dist/utils/chart-utils/original-data-utils/compare-bar-chart-calculator.js +21 -28
- package/dist/utils/chart-utils/original-data-utils/completeness-calculator.js +33 -40
- package/dist/utils/chart-utils/original-data-utils/dashboard-calculator.js +16 -23
- package/dist/utils/chart-utils/original-data-utils/index.js +50 -57
- package/dist/utils/chart-utils/original-data-utils/mirror-calculator.js +19 -26
- package/dist/utils/chart-utils/original-data-utils/pivot-table-calculator.js +90 -96
- package/dist/utils/chart-utils/original-data-utils/scatter-calculator.js +19 -26
- package/dist/utils/chart-utils/original-data-utils/trend-calculator.js +31 -38
- package/dist/utils/chart-utils/sql-statistics-utils.js +229 -237
- package/dist/utils/chart.js +9 -17
- package/dist/utils/collaborator-manager.js +3 -9
- package/dist/utils/collaborator-utils.js +19 -31
- package/dist/utils/collaborator.js +6 -15
- package/dist/utils/color-utils.js +18 -29
- package/dist/utils/column-utils.js +77 -104
- package/dist/utils/common-utils.js +28 -53
- package/dist/utils/concurrency-manager.js +1 -7
- package/dist/utils/contexts.js +5 -12
- package/dist/utils/date-translate.js +12 -20
- package/dist/utils/digital-sign-utils.js +7 -14
- package/dist/utils/event-bus.js +1 -7
- package/dist/utils/hotkey.js +5 -11
- package/dist/utils/index.js +54 -221
- package/dist/utils/key-generator.js +2 -9
- package/dist/utils/map.js +22 -31
- package/dist/utils/object-utils.js +2 -8
- package/dist/utils/options-utils.js +10 -18
- package/dist/utils/row-record-utils.js +166 -178
- package/dist/utils/row-utils.js +27 -38
- package/dist/utils/search.js +24 -32
- package/dist/utils/sql/chart-data-sql.js +106 -112
- package/dist/utils/sql/column-2-sql-column.js +158 -168
- package/dist/utils/sql/index.js +3 -27
- package/dist/utils/trend-utils.js +39 -47
- package/dist/view/index.js +90 -96
- package/dist/view/title/index.js +16 -24
- package/dist/view/wrapper/area-group.js +45 -53
- package/dist/view/wrapper/area.js +43 -51
- package/dist/view/wrapper/bar-compare.js +38 -46
- package/dist/view/wrapper/bar-custom-stack.js +39 -47
- package/dist/view/wrapper/bar-group.js +45 -53
- package/dist/view/wrapper/bar-stack.js +48 -56
- package/dist/view/wrapper/bar.js +40 -48
- package/dist/view/wrapper/basic-number-card.js +26 -34
- package/dist/view/wrapper/chart-component.js +123 -131
- package/dist/view/wrapper/combination.js +55 -63
- package/dist/view/wrapper/completeness-group.js +40 -48
- package/dist/view/wrapper/completeness.js +36 -44
- package/dist/view/wrapper/dashboard.js +39 -44
- package/dist/view/wrapper/funnel.js +40 -43
- package/dist/view/wrapper/heat-map.js +62 -70
- package/dist/view/wrapper/horizontal-bar-group.js +52 -60
- package/dist/view/wrapper/horizontal-bar-stack.js +47 -55
- package/dist/view/wrapper/horizontal-bar.js +41 -49
- package/dist/view/wrapper/index.js +107 -115
- package/dist/view/wrapper/line-group.js +43 -51
- package/dist/view/wrapper/line.js +42 -50
- package/dist/view/wrapper/map-bubble.js +40 -48
- package/dist/view/wrapper/map-world-bubble.js +39 -47
- package/dist/view/wrapper/map-world.js +41 -49
- package/dist/view/wrapper/map.js +42 -50
- package/dist/view/wrapper/mirror.js +41 -49
- package/dist/view/wrapper/pie.js +44 -52
- package/dist/view/wrapper/ring.js +49 -57
- package/dist/view/wrapper/scatter.js +42 -50
- package/dist/view/wrapper/table/index.js +14 -22
- package/dist/view/wrapper/table/one-dimension-table-no-numeric-columns.js +49 -57
- package/dist/view/wrapper/table/one-dimension-table-with-numeric-columns.js +53 -61
- package/dist/view/wrapper/table/pivot-table-display-name.js +82 -90
- package/dist/view/wrapper/table/two-dimension-table.js +85 -93
- package/dist/view/wrapper/table-element/components/dataset-utils.js +23 -36
- package/dist/view/wrapper/table-element/components/formatter.js +90 -99
- package/dist/view/wrapper/table-element/components/formatters/FileFormatter/index.js +23 -32
- package/dist/view/wrapper/table-element/components/formatters/formula-formatter.js +9 -16
- package/dist/view/wrapper/table-element/components/formatters/link-formatter.js +90 -97
- package/dist/view/wrapper/table-element/components/formula-formatter.js +9 -16
- package/dist/view/wrapper/table-element/components/link-formatter.js +90 -97
- package/dist/view/wrapper/table-element/components/record.js +13 -20
- package/dist/view/wrapper/table-element/components/records-body.js +9 -17
- package/dist/view/wrapper/table-element/components/records-header/index.js +7 -15
- package/dist/view/wrapper/table-element/components/records-header/records-header-cell.js +8 -16
- package/dist/view/wrapper/table-element/components/records.js +25 -33
- package/dist/view/wrapper/table-element/components/resize-column-handle/resize-column-handle.js +5 -12
- package/dist/view/wrapper/table-element/components/utils.js +6 -16
- package/dist/view/wrapper/table-element/components/value-display-utils.js +4 -11
- package/dist/view/wrapper/table-element/components/vertical-scrollbar/index.js +6 -13
- package/dist/view/wrapper/table-element/index.js +18 -26
- package/dist/view/wrapper/treemap.js +38 -46
- package/dist/view/wrapper/trend.js +58 -66
- package/package.json +5 -5
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.convertQuarterToDate = convertQuarterToDate;
|
|
8
|
-
exports.getMobileDatePickerLocale = getMobileDatePickerLocale;
|
|
9
|
-
exports.translateCalendar = translateCalendar;
|
|
10
|
-
var _intl = _interopRequireDefault(require("../intl"));
|
|
1
|
+
import intl from '../intl';
|
|
11
2
|
const zhCN = require('@seafile/seafile-calendar/lib/locale/zh_CN');
|
|
12
3
|
const zhTW = require('@seafile/seafile-calendar/lib/locale/zh_TW');
|
|
13
4
|
const enUS = require('@seafile/seafile-calendar/lib/locale/en_US');
|
|
@@ -62,14 +53,14 @@ function translateCalendar(lang) {
|
|
|
62
53
|
function getMobileDatePickerLocale() {
|
|
63
54
|
return {
|
|
64
55
|
DatePickerLocale: {
|
|
65
|
-
year:
|
|
66
|
-
month:
|
|
67
|
-
day:
|
|
68
|
-
hour:
|
|
69
|
-
minute:
|
|
56
|
+
year: intl.get('Year'),
|
|
57
|
+
month: intl.get('Month'),
|
|
58
|
+
day: intl.get('Day'),
|
|
59
|
+
hour: intl.get('Hour'),
|
|
60
|
+
minute: intl.get('Minute')
|
|
70
61
|
},
|
|
71
|
-
okText:
|
|
72
|
-
dismissText:
|
|
62
|
+
okText: intl.get('Done'),
|
|
63
|
+
dismissText: intl.get('Cancel')
|
|
73
64
|
};
|
|
74
65
|
}
|
|
75
66
|
const quarterTimeMap = {
|
|
@@ -78,11 +69,12 @@ const quarterTimeMap = {
|
|
|
78
69
|
'Q3': '07-01',
|
|
79
70
|
'Q4': '10-01'
|
|
80
71
|
};
|
|
81
|
-
function convertQuarterToDate(yearQuarter) {
|
|
72
|
+
export function convertQuarterToDate(yearQuarter) {
|
|
82
73
|
const timeDetailList = yearQuarter.split('-');
|
|
83
74
|
const year = timeDetailList[0];
|
|
84
75
|
const quarter = timeDetailList[1];
|
|
85
76
|
const quarterTime = quarterTimeMap[quarter];
|
|
86
|
-
const timeString =
|
|
77
|
+
const timeString = `${year}-${quarterTime}`;
|
|
87
78
|
return new Date(timeString);
|
|
88
|
-
}
|
|
79
|
+
}
|
|
80
|
+
export { translateCalendar, getMobileDatePickerLocale };
|
|
@@ -1,24 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
9
|
-
var _utc = _interopRequireDefault(require("dayjs/plugin/utc"));
|
|
10
|
-
var _dtableUtils = require("dtable-utils");
|
|
11
|
-
_dayjs.default.extend(_utc.default);
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import utc from 'dayjs/plugin/utc';
|
|
3
|
+
import { getDigitalSignImageUrl } from 'dtable-utils';
|
|
4
|
+
dayjs.extend(utc);
|
|
12
5
|
class DigitalSignUtils {
|
|
13
6
|
static getSignImageUrl(sign) {
|
|
14
|
-
return
|
|
7
|
+
return getDigitalSignImageUrl(sign);
|
|
15
8
|
}
|
|
16
9
|
static getUpdatedSign(_ref) {
|
|
17
10
|
let {
|
|
18
11
|
username,
|
|
19
12
|
sign_image_url
|
|
20
13
|
} = _ref;
|
|
21
|
-
const time = (
|
|
14
|
+
const time = dayjs().utc().format('YYYY-MM-DDTHH:mm:ss.SSSZ');
|
|
22
15
|
return {
|
|
23
16
|
username,
|
|
24
17
|
sign_image_url,
|
|
@@ -26,4 +19,4 @@ class DigitalSignUtils {
|
|
|
26
19
|
};
|
|
27
20
|
}
|
|
28
21
|
}
|
|
29
|
-
|
|
22
|
+
export default DigitalSignUtils;
|
package/dist/utils/event-bus.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
1
|
class EventBus {
|
|
8
2
|
constructor() {
|
|
9
3
|
this.subscribers = {};
|
|
@@ -31,4 +25,4 @@ class EventBus {
|
|
|
31
25
|
}
|
|
32
26
|
}
|
|
33
27
|
}
|
|
34
|
-
|
|
28
|
+
export default new EventBus();
|
package/dist/utils/hotkey.js
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
});
|
|
7
|
-
exports.isSpace = exports.isEsc = exports.isEnter = void 0;
|
|
8
|
-
var _isHotkey = _interopRequireDefault(require("is-hotkey"));
|
|
9
|
-
const isEsc = exports.isEsc = (0, _isHotkey.default)('esc');
|
|
10
|
-
const isSpace = exports.isSpace = (0, _isHotkey.default)('space');
|
|
11
|
-
const isEnter = exports.isEnter = (0, _isHotkey.default)('enter');
|
|
1
|
+
import isHotkey from 'is-hotkey';
|
|
2
|
+
const isEsc = isHotkey('esc');
|
|
3
|
+
const isSpace = isHotkey('space');
|
|
4
|
+
const isEnter = isHotkey('enter');
|
|
5
|
+
export { isEsc, isEnter, isSpace };
|
package/dist/utils/index.js
CHANGED
|
@@ -1,176 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports, "ChartUtils", {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
get: function () {
|
|
22
|
-
return _chartUtils.ChartUtils;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
Object.defineProperty(exports, "ObjectUtils", {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
get: function () {
|
|
28
|
-
return _objectUtils.default;
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
Object.defineProperty(exports, "chartColumn2SqlColumn", {
|
|
32
|
-
enumerable: true,
|
|
33
|
-
get: function () {
|
|
34
|
-
return _sql.chartColumn2SqlColumn;
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
exports.fixGeoGranularity = exports.eventStopPropagation = void 0;
|
|
38
|
-
exports.formatRowTotal = formatRowTotal;
|
|
39
|
-
exports.formatXAxisLabel = formatXAxisLabel;
|
|
40
|
-
Object.defineProperty(exports, "generateChartConfig", {
|
|
41
|
-
enumerable: true,
|
|
42
|
-
get: function () {
|
|
43
|
-
return _chart.generateChartConfig;
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
Object.defineProperty(exports, "generateDefaultUser", {
|
|
47
|
-
enumerable: true,
|
|
48
|
-
get: function () {
|
|
49
|
-
return _collaboratorUtils.generateDefaultUser;
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
Object.defineProperty(exports, "generatorCommonOptions", {
|
|
53
|
-
enumerable: true,
|
|
54
|
-
get: function () {
|
|
55
|
-
return _optionsUtils.generatorCommonOptions;
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
Object.defineProperty(exports, "generatorKey", {
|
|
59
|
-
enumerable: true,
|
|
60
|
-
get: function () {
|
|
61
|
-
return _keyGenerator.generatorKey;
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
exports.getChartConfigValueFromKeys = exports.getChartConfigValueByKey = void 0;
|
|
65
|
-
Object.defineProperty(exports, "getClientFormulaDisplayString", {
|
|
66
|
-
enumerable: true,
|
|
67
|
-
get: function () {
|
|
68
|
-
return _cellFormatUtils.getClientFormulaDisplayString;
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
Object.defineProperty(exports, "getClientLinkDisplayString", {
|
|
72
|
-
enumerable: true,
|
|
73
|
-
get: function () {
|
|
74
|
-
return _cellFormatUtils.getClientLinkDisplayString;
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
Object.defineProperty(exports, "getColorFromSingleSelectColumn", {
|
|
78
|
-
enumerable: true,
|
|
79
|
-
get: function () {
|
|
80
|
-
return _columnUtils.getColorFromSingleSelectColumn;
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
Object.defineProperty(exports, "getColumnByKey", {
|
|
84
|
-
enumerable: true,
|
|
85
|
-
get: function () {
|
|
86
|
-
return _columnUtils.getColumnByKey;
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
Object.defineProperty(exports, "getColumnOptions", {
|
|
90
|
-
enumerable: true,
|
|
91
|
-
get: function () {
|
|
92
|
-
return _dtableUtils.getColumnOptions;
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
Object.defineProperty(exports, "getDateColumnFormat", {
|
|
96
|
-
enumerable: true,
|
|
97
|
-
get: function () {
|
|
98
|
-
return _columnUtils.getDateColumnFormat;
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
exports.getGeoGranularityByLevel = exports.getFirstDayOfWeekForGroupby = exports.getEventClassName = exports.getErrorMessage = void 0;
|
|
102
|
-
Object.defineProperty(exports, "getKnownCollaboratorByEmail", {
|
|
103
|
-
enumerable: true,
|
|
104
|
-
get: function () {
|
|
105
|
-
return _collaboratorUtils.getKnownCollaboratorByEmail;
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
Object.defineProperty(exports, "getKnownCollaboratorsByEmails", {
|
|
109
|
-
enumerable: true,
|
|
110
|
-
get: function () {
|
|
111
|
-
return _collaboratorUtils.getKnownCollaboratorsByEmails;
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
exports.getMapCanvasStyle = getMapCanvasStyle;
|
|
115
|
-
exports.isBoolean = exports.getSortedDataByGivenOrder = exports.getSimilarKeys = void 0;
|
|
116
|
-
Object.defineProperty(exports, "isCheckboxColumn", {
|
|
117
|
-
enumerable: true,
|
|
118
|
-
get: function () {
|
|
119
|
-
return _columnUtils.isCheckboxColumn;
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
Object.defineProperty(exports, "isFunction", {
|
|
123
|
-
enumerable: true,
|
|
124
|
-
get: function () {
|
|
125
|
-
return _commonUtils.isFunction;
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
Object.defineProperty(exports, "isStatisticMapColumn", {
|
|
129
|
-
enumerable: true,
|
|
130
|
-
get: function () {
|
|
131
|
-
return _columnUtils.isStatisticMapColumn;
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
Object.defineProperty(exports, "isStatisticMirrorColumn", {
|
|
135
|
-
enumerable: true,
|
|
136
|
-
get: function () {
|
|
137
|
-
return _columnUtils.isStatisticMirrorColumn;
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
Object.defineProperty(exports, "isStatisticWorldMapColumn", {
|
|
141
|
-
enumerable: true,
|
|
142
|
-
get: function () {
|
|
143
|
-
return _columnUtils.isStatisticWorldMapColumn;
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
Object.defineProperty(exports, "summaryMethodColumn2SqlColumn", {
|
|
147
|
-
enumerable: true,
|
|
148
|
-
get: function () {
|
|
149
|
-
return _sql.summaryMethodColumn2SqlColumn;
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
Object.defineProperty(exports, "translateCalendar", {
|
|
153
|
-
enumerable: true,
|
|
154
|
-
get: function () {
|
|
155
|
-
return _dateTranslate.translateCalendar;
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
var _lodash = require("lodash");
|
|
159
|
-
var _constants = require("../constants");
|
|
160
|
-
var _intl = _interopRequireDefault(require("../intl"));
|
|
161
|
-
var _error = require("../constants/error");
|
|
162
|
-
var _objectUtils = _interopRequireDefault(require("./object-utils"));
|
|
163
|
-
var _chartUtils = require("./chart-utils");
|
|
164
|
-
var _sql = require("./sql");
|
|
165
|
-
var _optionsUtils = require("./options-utils");
|
|
166
|
-
var _dtableUtils = require("dtable-utils");
|
|
167
|
-
var _cellFormatUtils = require("./cell-format-utils");
|
|
168
|
-
var _chart = require("./chart");
|
|
169
|
-
var _collaboratorUtils = require("./collaborator-utils");
|
|
170
|
-
var _columnUtils = require("./column-utils");
|
|
171
|
-
var _keyGenerator = require("./key-generator");
|
|
172
|
-
var _dateTranslate = require("./date-translate");
|
|
173
|
-
var _commonUtils = require("./common-utils");
|
|
1
|
+
import { cloneDeep } from 'lodash';
|
|
2
|
+
import { GENERIC_KEY_2_SIMILAR_KEYS, GEOLOCATION_GRANULARITY, MAP_LEVEL, MUNICIPALITIES, regions } from '../constants';
|
|
3
|
+
import intl from '../intl';
|
|
4
|
+
import { SERVER_ERROR_DISPLAY_KEY, SERVER_ERROR_MSG } from '../constants/error';
|
|
5
|
+
import ObjectUtils from './object-utils';
|
|
6
|
+
import { BaseUtils, ChartUtils } from './chart-utils';
|
|
7
|
+
import { ChartDataSQL, chartColumn2SqlColumn, summaryMethodColumn2SqlColumn } from './sql';
|
|
8
|
+
export { generatorCommonOptions } from './options-utils';
|
|
9
|
+
export { getColumnOptions } from 'dtable-utils';
|
|
10
|
+
export { getClientFormulaDisplayString, getClientLinkDisplayString } from './cell-format-utils';
|
|
11
|
+
export { generateChartConfig } from './chart';
|
|
12
|
+
export { getKnownCollaboratorByEmail, getKnownCollaboratorsByEmails, generateDefaultUser } from './collaborator-utils';
|
|
13
|
+
export { getDateColumnFormat, isCheckboxColumn, getColumnByKey, isStatisticMapColumn, isStatisticWorldMapColumn, isStatisticMirrorColumn, getColorFromSingleSelectColumn } from './column-utils';
|
|
14
|
+
export { generatorKey } from './key-generator';
|
|
15
|
+
export { translateCalendar } from './date-translate';
|
|
16
|
+
export { isFunction } from './common-utils';
|
|
174
17
|
const splitLabelWithoutEnglish = label => {
|
|
175
18
|
let newLabel = '';
|
|
176
19
|
while (label.length > 0) {
|
|
@@ -184,7 +27,7 @@ const splitLabelWithoutEnglish = label => {
|
|
|
184
27
|
}
|
|
185
28
|
return newLabel;
|
|
186
29
|
};
|
|
187
|
-
function formatXAxisLabel(label) {
|
|
30
|
+
export function formatXAxisLabel(label) {
|
|
188
31
|
let maxLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 12;
|
|
189
32
|
const regex = /\b[a-zA-Z0-9'.,-]+\b/g;
|
|
190
33
|
const words = label.match(regex);
|
|
@@ -226,7 +69,7 @@ function formatXAxisLabel(label) {
|
|
|
226
69
|
}
|
|
227
70
|
return result.join('\n');
|
|
228
71
|
}
|
|
229
|
-
function formatRowTotal(rowTotal) {
|
|
72
|
+
export function formatRowTotal(rowTotal) {
|
|
230
73
|
const rowTotalNum = parseFloat(rowTotal);
|
|
231
74
|
if (!Number.isNaN(rowTotalNum) && rowTotalNum % 1 !== 0) {
|
|
232
75
|
return rowTotalNum.toFixed(2);
|
|
@@ -243,7 +86,7 @@ function formatRowTotal(rowTotal) {
|
|
|
243
86
|
* @param {Array} x_axis_option_list
|
|
244
87
|
* @returns {Array} sortedData
|
|
245
88
|
*/
|
|
246
|
-
const getSortedDataByGivenOrder = (data, x_axis_option_list) => {
|
|
89
|
+
export const getSortedDataByGivenOrder = (data, x_axis_option_list) => {
|
|
247
90
|
const idIndexMap = {};
|
|
248
91
|
x_axis_option_list.forEach((item, index) => {
|
|
249
92
|
idIndexMap[item.id] = index;
|
|
@@ -251,13 +94,12 @@ const getSortedDataByGivenOrder = (data, x_axis_option_list) => {
|
|
|
251
94
|
let sortedData = [];
|
|
252
95
|
data.forEach(item => {
|
|
253
96
|
const index = idIndexMap[item.group_name];
|
|
254
|
-
sortedData[index] =
|
|
97
|
+
sortedData[index] = cloneDeep(item);
|
|
255
98
|
});
|
|
256
99
|
sortedData = sortedData.filter(Boolean);
|
|
257
100
|
return sortedData;
|
|
258
101
|
};
|
|
259
|
-
|
|
260
|
-
function getMapCanvasStyle(container, ratio) {
|
|
102
|
+
export function getMapCanvasStyle(container, ratio) {
|
|
261
103
|
let cWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 200;
|
|
262
104
|
let cHeight = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 200;
|
|
263
105
|
let width, height;
|
|
@@ -281,11 +123,11 @@ function getMapCanvasStyle(container, ratio) {
|
|
|
281
123
|
height
|
|
282
124
|
};
|
|
283
125
|
}
|
|
284
|
-
const getErrorMessage = err => {
|
|
126
|
+
export const getErrorMessage = err => {
|
|
285
127
|
// log error to locate problems
|
|
286
128
|
console.error(err);
|
|
287
129
|
if (!err.response) {
|
|
288
|
-
return
|
|
130
|
+
return intl.get('Network_error');
|
|
289
131
|
}
|
|
290
132
|
const {
|
|
291
133
|
status,
|
|
@@ -293,44 +135,42 @@ const getErrorMessage = err => {
|
|
|
293
135
|
} = err.response;
|
|
294
136
|
const error_msg = data ? data.error_msg : '';
|
|
295
137
|
if (status === 400) {
|
|
296
|
-
if (error_msg ===
|
|
297
|
-
return
|
|
138
|
+
if (error_msg === SERVER_ERROR_MSG.EXECUTION_COST_EXCEEDED) {
|
|
139
|
+
return intl.get(SERVER_ERROR_DISPLAY_KEY[SERVER_ERROR_MSG.EXECUTION_COST_EXCEEDED]);
|
|
298
140
|
}
|
|
299
141
|
}
|
|
300
142
|
if (status === 403) {
|
|
301
|
-
return
|
|
143
|
+
return intl.get('Permission_denied');
|
|
302
144
|
}
|
|
303
145
|
if (status === 500 || status === 502) {
|
|
304
|
-
return
|
|
146
|
+
return intl.get('Internal_server_error');
|
|
305
147
|
}
|
|
306
|
-
return
|
|
148
|
+
return intl.get('Error');
|
|
307
149
|
};
|
|
308
|
-
|
|
309
|
-
const getGeoGranularityByLevel = mapLevel => {
|
|
150
|
+
export const getGeoGranularityByLevel = mapLevel => {
|
|
310
151
|
switch (mapLevel) {
|
|
311
|
-
case
|
|
152
|
+
case MAP_LEVEL.PROVINCE:
|
|
312
153
|
{
|
|
313
|
-
return
|
|
154
|
+
return GEOLOCATION_GRANULARITY.CITY;
|
|
314
155
|
}
|
|
315
|
-
case
|
|
156
|
+
case MAP_LEVEL.CITY:
|
|
316
157
|
{
|
|
317
|
-
return
|
|
158
|
+
return GEOLOCATION_GRANULARITY.DISTRICT;
|
|
318
159
|
}
|
|
319
160
|
default:
|
|
320
161
|
{
|
|
321
162
|
// default as 'country'
|
|
322
|
-
return
|
|
163
|
+
return GEOLOCATION_GRANULARITY.PROVINCE;
|
|
323
164
|
}
|
|
324
165
|
}
|
|
325
166
|
};
|
|
326
|
-
|
|
327
|
-
const fixGeoGranularity = _ref => {
|
|
167
|
+
export const fixGeoGranularity = _ref => {
|
|
328
168
|
let {
|
|
329
169
|
mapLevel,
|
|
330
170
|
mapLocation
|
|
331
171
|
} = _ref;
|
|
332
|
-
if (!mapLevel || mapLevel ===
|
|
333
|
-
return
|
|
172
|
+
if (!mapLevel || mapLevel === MAP_LEVEL.COUNTRY || !mapLocation) {
|
|
173
|
+
return GEOLOCATION_GRANULARITY.PROVINCE;
|
|
334
174
|
}
|
|
335
175
|
|
|
336
176
|
// e.g. Beijing
|
|
@@ -338,66 +178,59 @@ const fixGeoGranularity = _ref => {
|
|
|
338
178
|
province: provinceName,
|
|
339
179
|
city: cityName
|
|
340
180
|
} = mapLocation;
|
|
341
|
-
if (provinceName &&
|
|
342
|
-
return
|
|
181
|
+
if (provinceName && MUNICIPALITIES.includes(provinceName)) {
|
|
182
|
+
return GEOLOCATION_GRANULARITY.DISTRICT;
|
|
343
183
|
}
|
|
344
184
|
|
|
345
185
|
// e.g. HongKong
|
|
346
|
-
const selectedProvince = provinceName &&
|
|
186
|
+
const selectedProvince = provinceName && regions.find(province => province.name === provinceName);
|
|
347
187
|
if (selectedProvince && selectedProvince.disable_drill_down) {
|
|
348
|
-
return
|
|
188
|
+
return GEOLOCATION_GRANULARITY.PROVINCE;
|
|
349
189
|
}
|
|
350
190
|
const cities = selectedProvince && selectedProvince.cities;
|
|
351
191
|
const selectedCity = cities && cityName && cities.find(city => city.name === cityName);
|
|
352
|
-
if (mapLevel ===
|
|
353
|
-
return
|
|
192
|
+
if (mapLevel === MAP_LEVEL.CITY && selectedCity && selectedCity.disable_drill_down) {
|
|
193
|
+
return GEOLOCATION_GRANULARITY.CITY;
|
|
354
194
|
}
|
|
355
195
|
|
|
356
196
|
// others
|
|
357
197
|
return getGeoGranularityByLevel(mapLevel);
|
|
358
198
|
};
|
|
359
|
-
|
|
360
|
-
const isBoolean = val => {
|
|
199
|
+
export const isBoolean = val => {
|
|
361
200
|
return typeof val === 'boolean';
|
|
362
201
|
};
|
|
363
|
-
|
|
364
|
-
const
|
|
365
|
-
const similarKeys = _constants.GENERIC_KEY_2_SIMILAR_KEYS[genericKey];
|
|
202
|
+
export const getSimilarKeys = genericKey => {
|
|
203
|
+
const similarKeys = GENERIC_KEY_2_SIMILAR_KEYS[genericKey];
|
|
366
204
|
return similarKeys || [];
|
|
367
205
|
};
|
|
368
|
-
|
|
369
|
-
const getChartConfigValueFromKeys = (keys, object) => {
|
|
206
|
+
export const getChartConfigValueFromKeys = (keys, object) => {
|
|
370
207
|
// eslint-disable-next-line
|
|
371
|
-
const existKey = keys.find(key =>
|
|
208
|
+
const existKey = keys.find(key => ObjectUtils.hasOwnProperty(object, key));
|
|
372
209
|
return existKey ? object[existKey] : null;
|
|
373
210
|
};
|
|
374
|
-
|
|
375
|
-
const getChartConfigValueByKey = (key, object) => {
|
|
211
|
+
export const getChartConfigValueByKey = (key, object) => {
|
|
376
212
|
const similarKeys = getSimilarKeys(key);
|
|
377
213
|
if (!Array.isArray(similarKeys) || similarKeys.length === 0) {
|
|
378
214
|
// get value by the given 'genericKey' directly when has no similar keys.
|
|
379
215
|
// eslint-disable-next-line
|
|
380
|
-
return
|
|
216
|
+
return ObjectUtils.hasOwnProperty(object, key) ? object[key] : null;
|
|
381
217
|
}
|
|
382
218
|
|
|
383
219
|
// try to get value from the similar keys
|
|
384
220
|
return getChartConfigValueFromKeys(similarKeys, object);
|
|
385
221
|
};
|
|
386
|
-
|
|
387
|
-
const eventStopPropagation = event => {
|
|
222
|
+
export const eventStopPropagation = event => {
|
|
388
223
|
if (!event) return;
|
|
389
224
|
event.stopPropagation();
|
|
390
225
|
event.preventDefault && event.preventDefault();
|
|
391
226
|
event.nativeEvent && event.nativeEvent.stopImmediatePropagation && event.nativeEvent.stopImmediatePropagation();
|
|
392
227
|
};
|
|
393
|
-
|
|
394
|
-
const getEventClassName = e => {
|
|
228
|
+
export const getEventClassName = e => {
|
|
395
229
|
// svg mouseEvent event.target.className is an object
|
|
396
230
|
if (!e || !e.target) return '';
|
|
397
231
|
return e.target.getAttribute('class') || '';
|
|
398
232
|
};
|
|
399
|
-
|
|
400
|
-
const getFirstDayOfWeekForGroupby = source => {
|
|
233
|
+
export const getFirstDayOfWeekForGroupby = source => {
|
|
401
234
|
let firstDayOfWeek = 'Sunday';
|
|
402
235
|
if (source === 'base') {
|
|
403
236
|
const {
|
|
@@ -417,4 +250,4 @@ const getFirstDayOfWeekForGroupby = source => {
|
|
|
417
250
|
}
|
|
418
251
|
return firstDayOfWeek || 'Sunday';
|
|
419
252
|
};
|
|
420
|
-
|
|
253
|
+
export { ObjectUtils, chartColumn2SqlColumn, summaryMethodColumn2SqlColumn, ChartUtils, ChartDataSQL, BaseUtils };
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.generatorKey = void 0;
|
|
7
1
|
const generatorBase64Code = function () {
|
|
8
2
|
let keyLength = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 4;
|
|
9
3
|
let possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz0123456789';
|
|
@@ -13,8 +7,7 @@ const generatorBase64Code = function () {
|
|
|
13
7
|
}
|
|
14
8
|
return key;
|
|
15
9
|
};
|
|
16
|
-
const generatorKey = function () {
|
|
10
|
+
export const generatorKey = function () {
|
|
17
11
|
let length = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 4;
|
|
18
12
|
return generatorBase64Code(length);
|
|
19
|
-
};
|
|
20
|
-
exports.generatorKey = generatorKey;
|
|
13
|
+
};
|
package/dist/utils/map.js
CHANGED
|
@@ -1,33 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getRegionScaleOffsets = exports.getGeoGranularityByLevel = exports.fixGeoGranularity = void 0;
|
|
7
|
-
var _constants = require("../constants");
|
|
1
|
+
import { GEOLOCATION_GRANULARITY, MAP_LEVEL, MUNICIPALITIES, regions } from '../constants';
|
|
8
2
|
const COUNTY_SCALE_WIDTH = 5.95;
|
|
9
3
|
const COUNTY_SCALE_HEIGHT = 4.37;
|
|
10
|
-
const getGeoGranularityByLevel = mapLevel => {
|
|
4
|
+
export const getGeoGranularityByLevel = mapLevel => {
|
|
11
5
|
switch (mapLevel) {
|
|
12
|
-
case
|
|
6
|
+
case MAP_LEVEL.PROVINCE:
|
|
13
7
|
{
|
|
14
|
-
return
|
|
8
|
+
return GEOLOCATION_GRANULARITY.CITY;
|
|
15
9
|
}
|
|
16
|
-
case
|
|
10
|
+
case MAP_LEVEL.CITY:
|
|
17
11
|
{
|
|
18
|
-
return
|
|
12
|
+
return GEOLOCATION_GRANULARITY.DISTRICT;
|
|
19
13
|
}
|
|
20
14
|
default:
|
|
21
15
|
{
|
|
22
16
|
// default as 'country'
|
|
23
|
-
return
|
|
17
|
+
return GEOLOCATION_GRANULARITY.PROVINCE;
|
|
24
18
|
}
|
|
25
19
|
}
|
|
26
20
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return _constants.GEOLOCATION_GRANULARITY.PROVINCE;
|
|
21
|
+
export const fixGeoGranularity = (mapLevel, mapLocation) => {
|
|
22
|
+
if (!mapLevel || mapLevel === MAP_LEVEL.COUNTRY || !mapLocation) {
|
|
23
|
+
return GEOLOCATION_GRANULARITY.PROVINCE;
|
|
31
24
|
}
|
|
32
25
|
|
|
33
26
|
// e.g. Beijing
|
|
@@ -35,45 +28,44 @@ const fixGeoGranularity = (mapLevel, mapLocation) => {
|
|
|
35
28
|
province: provinceName,
|
|
36
29
|
city: cityName
|
|
37
30
|
} = mapLocation;
|
|
38
|
-
if (provinceName &&
|
|
39
|
-
return
|
|
31
|
+
if (provinceName && MUNICIPALITIES.includes(provinceName)) {
|
|
32
|
+
return GEOLOCATION_GRANULARITY.DISTRICT;
|
|
40
33
|
}
|
|
41
34
|
|
|
42
35
|
// e.g. HongKong
|
|
43
|
-
const selectedProvince = provinceName &&
|
|
36
|
+
const selectedProvince = provinceName && regions.find(province => province.name === provinceName);
|
|
44
37
|
if (selectedProvince && selectedProvince.disable_drill_down) {
|
|
45
|
-
return
|
|
38
|
+
return GEOLOCATION_GRANULARITY.PROVINCE;
|
|
46
39
|
}
|
|
47
40
|
const cities = selectedProvince && selectedProvince.cities;
|
|
48
41
|
const selectedCity = cities && cityName && cities.find(city => city.name === cityName);
|
|
49
|
-
if (mapLevel ===
|
|
50
|
-
return
|
|
42
|
+
if (mapLevel === MAP_LEVEL.CITY && selectedCity && selectedCity.disable_drill_down) {
|
|
43
|
+
return GEOLOCATION_GRANULARITY.CITY;
|
|
51
44
|
}
|
|
52
45
|
|
|
53
46
|
// others
|
|
54
47
|
return getGeoGranularityByLevel(mapLevel);
|
|
55
48
|
};
|
|
56
|
-
|
|
57
|
-
const getRegionScaleOffsets = (mapLevel, mapLocation) => {
|
|
49
|
+
export const getRegionScaleOffsets = (mapLevel, mapLocation) => {
|
|
58
50
|
const countryScaleOffsets = {
|
|
59
51
|
scale_w: COUNTY_SCALE_WIDTH,
|
|
60
52
|
scale_h: COUNTY_SCALE_HEIGHT
|
|
61
53
|
};
|
|
62
54
|
switch (mapLevel) {
|
|
63
|
-
case
|
|
55
|
+
case MAP_LEVEL.PROVINCE:
|
|
64
56
|
{
|
|
65
57
|
const provinceName = mapLocation && mapLocation.province;
|
|
66
|
-
const province = provinceName &&
|
|
58
|
+
const province = provinceName && regions.find(province => province.name === provinceName);
|
|
67
59
|
if (!province) return countryScaleOffsets;
|
|
68
60
|
return {
|
|
69
61
|
scale_w: province.scale_w,
|
|
70
62
|
scale_h: province.scale_h
|
|
71
63
|
};
|
|
72
64
|
}
|
|
73
|
-
case
|
|
65
|
+
case MAP_LEVEL.CITY:
|
|
74
66
|
{
|
|
75
67
|
const provinceName = mapLocation && mapLocation.province;
|
|
76
|
-
const province = provinceName &&
|
|
68
|
+
const province = provinceName && regions.find(province => province.name === provinceName);
|
|
77
69
|
const cities = province && province.cities;
|
|
78
70
|
const cityName = mapLocation.city;
|
|
79
71
|
const city = cityName && Array.isArray(cities) && cities.find(city => city.name === cityName);
|
|
@@ -89,5 +81,4 @@ const getRegionScaleOffsets = (mapLevel, mapLocation) => {
|
|
|
89
81
|
return countryScaleOffsets;
|
|
90
82
|
}
|
|
91
83
|
}
|
|
92
|
-
};
|
|
93
|
-
exports.getRegionScaleOffsets = getRegionScaleOffsets;
|
|
84
|
+
};
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
1
|
class ObjectUtils {
|
|
8
2
|
static getDataType(data) {
|
|
9
3
|
let type = typeof data;
|
|
@@ -17,7 +11,7 @@ class ObjectUtils {
|
|
|
17
11
|
}
|
|
18
12
|
static isObjectChanged(source, comparison) {
|
|
19
13
|
if (!this.iterable(source)) {
|
|
20
|
-
throw new Error(
|
|
14
|
+
throw new Error(`source should be a Object or Array , but got ${this.getDataType(source)}`);
|
|
21
15
|
}
|
|
22
16
|
if (this.getDataType(source) !== this.getDataType(comparison)) {
|
|
23
17
|
return true;
|
|
@@ -48,4 +42,4 @@ class ObjectUtils {
|
|
|
48
42
|
return Object.prototype.hasOwnProperty.call(obj, propertyKey);
|
|
49
43
|
}
|
|
50
44
|
}
|
|
51
|
-
|
|
45
|
+
export default ObjectUtils;
|