dtable-statistic 4.0.2-test-2
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/README.md +3 -0
- package/es/api/dtable-db-api.js +43 -0
- package/es/assets/css/color-picker.css +53 -0
- package/es/assets/css/color-rules-popover.css +144 -0
- package/es/assets/css/color-theme-dialog.css +40 -0
- package/es/assets/css/dashboard.css +562 -0
- package/es/assets/css/dialog.css +415 -0
- package/es/assets/css/mobile-dashboard.module.css +91 -0
- package/es/assets/css/slider.css +77 -0
- package/es/assets/css/statistic-chart.module.css +11 -0
- package/es/assets/css/statistic-custom-title.module.css +3 -0
- package/es/assets/css/statistic-custom.module.css +4 -0
- package/es/assets/css/statistic-numeric-column-item.module.css +43 -0
- package/es/assets/css/statistic-time-picker.module.css +21 -0
- package/es/assets/css/theme.css +61 -0
- package/es/assets/images/icon.png +0 -0
- package/es/calculator/base-calculator.js +111 -0
- package/es/calculator/basic-chart-calculator.js +571 -0
- package/es/calculator/combination-calculator.js +296 -0
- package/es/calculator/compare-bar-calculator.js +291 -0
- package/es/calculator/completeness-calculator.js +307 -0
- package/es/calculator/copy-value.js +47 -0
- package/es/calculator/dashboard-calculator.js +146 -0
- package/es/calculator/heat-map-calculator.js +225 -0
- package/es/calculator/horizontal-bar-calculator.js +100 -0
- package/es/calculator/index.js +88 -0
- package/es/calculator/map-calculator.js +169 -0
- package/es/calculator/mirror-calculator.js +217 -0
- package/es/calculator/number-card-calculator.js +135 -0
- package/es/calculator/pivot-table-calculator.js +810 -0
- package/es/calculator/scatter-calculator.js +150 -0
- package/es/calculator/thread-manager.js +70 -0
- package/es/calculator/trend-calculator.js +204 -0
- package/es/calculator/workers/basic-chart-calculator-worker.js +410 -0
- package/es/calculator/workers/calculator.worker.js +22 -0
- package/es/calculator/workers/card-calculator-worker.js +28 -0
- package/es/calculator/workers/combination-calculator-worker.js +257 -0
- package/es/calculator/workers/compare-bar-chart-calculator-worker.js +149 -0
- package/es/calculator/workers/completeness-calculator-worker.js +153 -0
- package/es/calculator/workers/dashboard-calculator-worker.js +56 -0
- package/es/calculator/workers/mirror-calculator-worker.js +132 -0
- package/es/calculator/workers/pivot-table-calculator-worker.js +615 -0
- package/es/calculator/workers/scatter-calculator-worker.js +67 -0
- package/es/calculator/workers/trend-calculator-worker.js +93 -0
- package/es/calculator/world-map-calculator.js +193 -0
- package/es/components/common-add-tool.js +19 -0
- package/es/components/dialog/chart-addition-edit-dialog.js +89 -0
- package/es/components/dialog/chart-addition-widgets/chart-selector.js +261 -0
- package/es/components/dialog/chart-addition-widgets/statistic-chart-selector.module.css +74 -0
- package/es/components/dialog/color-theme-dialog.js +71 -0
- package/es/components/dialog/enlarged-chart-dialog.js +73 -0
- package/es/components/dialog/new-table-dialog.js +113 -0
- package/es/components/dialog/new-view-dialog.js +87 -0
- package/es/components/dialog/rename-view-dialog.js +87 -0
- package/es/components/dialog/statistic-record-dialog/index.css +114 -0
- package/es/components/dialog/statistic-record-dialog/index.js +174 -0
- package/es/components/dialog/table-select-dialog.js +93 -0
- package/es/components/dropdown-menu/statistic-dropdown-menu.js +94 -0
- package/es/components/dtable-popover.js +109 -0
- package/es/components/dtable-search-input.js +137 -0
- package/es/components/dtable-select.js +104 -0
- package/es/components/index.js +11 -0
- package/es/components/loading.js +8 -0
- package/es/components/modal-portal.js +36 -0
- package/es/components/popover/color-rules/color-rule.js +179 -0
- package/es/components/popover/color-rules/index.js +87 -0
- package/es/components/popover/color-rules/rule-filters/filter.js +214 -0
- package/es/components/popover/color-rules/rule-filters/index.css +214 -0
- package/es/components/popover/color-rules/rule-filters/index.js +97 -0
- package/es/components/popover/color-rules/rule-filters/number-input.js +85 -0
- package/es/components/popover/color-rules-popover.js +213 -0
- package/es/components/popover/color-selector-popover.js +85 -0
- package/es/components/seatable-radio/index.css +51 -0
- package/es/components/seatable-radio/index.js +28 -0
- package/es/components/select/index.js +2 -0
- package/es/components/select/option-group.css +104 -0
- package/es/components/select/option-group.js +225 -0
- package/es/components/select/option.js +51 -0
- package/es/components/select/select.css +211 -0
- package/es/components/select/select.js +157 -0
- package/es/components/toast/alert.js +130 -0
- package/es/components/toast/index.js +3 -0
- package/es/components/toast/toast.js +164 -0
- package/es/components/toast/toastManager.js +150 -0
- package/es/components/toast/toaster.js +64 -0
- package/es/constants/color-rules.js +8 -0
- package/es/constants/dtable-select-style.js +61 -0
- package/es/constants/event-types.js +1 -0
- package/es/constants/index.js +501 -0
- package/es/constants/key-codes.js +102 -0
- package/es/constants/zIndexes.js +1 -0
- package/es/custom-g2.js +614 -0
- package/es/dashboard.js +408 -0
- package/es/desktop-dashboard.js +299 -0
- package/es/index.js +33 -0
- package/es/locale/index.js +17 -0
- package/es/locale/lang/de.js +237 -0
- package/es/locale/lang/en.js +237 -0
- package/es/locale/lang/fr.js +237 -0
- package/es/locale/lang/zh_CN.js +237 -0
- package/es/mobile-dashboard.js +103 -0
- package/es/model/collaborators.js +11 -0
- package/es/model/stat-item.js +340 -0
- package/es/model/statistic-dashboard.js +8 -0
- package/es/service/chart-service.js +192 -0
- package/es/service/dashboard-service.js +415 -0
- package/es/stat-editor/chart-name-editor.js +75 -0
- package/es/stat-editor/index.js +74 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +149 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +415 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +193 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +13 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +107 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/index.js +332 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +170 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +141 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +219 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +89 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +132 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +319 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +138 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +135 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +156 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +147 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +195 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +126 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +169 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +352 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +145 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +153 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/index.js +466 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +183 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +542 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +111 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +86 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +169 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +273 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +105 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +243 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +65 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +318 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +49 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +124 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +150 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +267 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +109 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +351 -0
- package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +60 -0
- package/es/stat-editor/stat-settings/color-setting/color-picker.js +129 -0
- package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +348 -0
- package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +102 -0
- package/es/stat-editor/stat-settings/public-setting/base-settings.js +124 -0
- package/es/stat-editor/stat-settings/public-setting/calender.js +124 -0
- package/es/stat-editor/stat-settings/public-setting/column-settings.js +15 -0
- package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +60 -0
- package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +57 -0
- package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +41 -0
- package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +64 -0
- package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +118 -0
- package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +39 -0
- package/es/stat-list/chart-preview.js +139 -0
- package/es/stat-list/index.js +275 -0
- package/es/stat-view/area-chart.js +521 -0
- package/es/stat-view/bar-chart.js +568 -0
- package/es/stat-view/base-chart.js +44 -0
- package/es/stat-view/basic-number-card.js +255 -0
- package/es/stat-view/combination-chart.js +558 -0
- package/es/stat-view/compare-chart.js +485 -0
- package/es/stat-view/completeness-chart.js +389 -0
- package/es/stat-view/custom-bar.js +433 -0
- package/es/stat-view/dashboard-chart.js +317 -0
- package/es/stat-view/heat-map.js +501 -0
- package/es/stat-view/horizontal-bar-chart.js +569 -0
- package/es/stat-view/index.js +183 -0
- package/es/stat-view/line-chart.js +505 -0
- package/es/stat-view/map.js +428 -0
- package/es/stat-view/mirror.js +285 -0
- package/es/stat-view/pie-chart.js +326 -0
- package/es/stat-view/pivot-table/index.js +206 -0
- package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +133 -0
- package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +164 -0
- package/es/stat-view/pivot-table/statistic-pivot-table.module.css +132 -0
- package/es/stat-view/pivot-table/two-dimension-table.js +344 -0
- package/es/stat-view/ring-chart.js +416 -0
- package/es/stat-view/scatter-chart.js +367 -0
- package/es/stat-view/treemap-chart.js +318 -0
- package/es/stat-view/trend-chart.js +299 -0
- package/es/stat-view/world-map.js +443 -0
- package/es/tabs/index.js +252 -0
- package/es/tabs/statistic-tabs.module.css +154 -0
- package/es/tabs/tab.js +167 -0
- package/es/utils/basic-chart-utils.js +24 -0
- package/es/utils/cell-format.js +110 -0
- package/es/utils/cell-value.js +27 -0
- package/es/utils/collaborator.js +31 -0
- package/es/utils/color-utils.js +112 -0
- package/es/utils/column-utils.js +18 -0
- package/es/utils/column.js +13 -0
- package/es/utils/common-utils.js +303 -0
- package/es/utils/date-format.js +65 -0
- package/es/utils/export-table-utils.js +632 -0
- package/es/utils/index.js +26 -0
- package/es/utils/object.js +26 -0
- package/es/utils/row-utils.js +115 -0
- package/es/utils/search.js +67 -0
- package/es/utils/sql-utils.js +293 -0
- package/es/utils/stat-utils.js +353 -0
- package/es/utils/trend-utils.js +136 -0
- package/index.js +1 -0
- package/package.json +188 -0
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
|
+
import React, { Component } from 'react';
|
|
6
|
+
import classnames from 'classnames';
|
|
7
|
+
import { Input } from 'reactstrap';
|
|
8
|
+
import ReactColor from 'react-color';
|
|
9
|
+
import intl from 'react-intl-universal';
|
|
10
|
+
import { DTableSelect } from '../../../components';
|
|
11
|
+
import ColorRulesPopover from '../../../components/popover/color-rules-popover';
|
|
12
|
+
import { getValidColorRules } from '../../../utils/color-utils';
|
|
13
|
+
import { STAT_TYPE, TYPE_COLOR_USING, TYPE_DISPLAY_COLOR_USING } from '../../../constants';
|
|
14
|
+
import { COLOR_RULE_FILTER_TYPE_MAP } from '../../../constants/color-rules';
|
|
15
|
+
var COVER = {
|
|
16
|
+
top: '0px',
|
|
17
|
+
right: '0px',
|
|
18
|
+
bottom: '0px',
|
|
19
|
+
left: '0px'
|
|
20
|
+
};
|
|
21
|
+
var ColorUseTypeSelector = /*#__PURE__*/function (_Component) {
|
|
22
|
+
_inherits(ColorUseTypeSelector, _Component);
|
|
23
|
+
var _super = _createSuper(ColorUseTypeSelector);
|
|
24
|
+
function ColorUseTypeSelector(props) {
|
|
25
|
+
var _this;
|
|
26
|
+
_classCallCheck(this, ColorUseTypeSelector);
|
|
27
|
+
_this = _super.call(this, props);
|
|
28
|
+
_this.getPopoverStyle = function () {
|
|
29
|
+
if (!_this.colorPickerContainerRef) return {};
|
|
30
|
+
var _this$colorPickerCont = _this.colorPickerContainerRef.getBoundingClientRect(),
|
|
31
|
+
top = _this$colorPickerCont.top,
|
|
32
|
+
height = _this$colorPickerCont.height;
|
|
33
|
+
var clientHeight = document.body.clientHeight;
|
|
34
|
+
var selectTop = top + height;
|
|
35
|
+
if (clientHeight - selectTop < 247) {
|
|
36
|
+
// 247: ReactColor's height
|
|
37
|
+
return {
|
|
38
|
+
position: 'absolute',
|
|
39
|
+
left: '20px',
|
|
40
|
+
bottom: '2.375rem',
|
|
41
|
+
zIndex: '2'
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
position: 'absolute',
|
|
46
|
+
left: '20px',
|
|
47
|
+
zIndex: '2'
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
_this.getUsableColorTypes = function (chartType) {
|
|
51
|
+
switch (chartType) {
|
|
52
|
+
case STAT_TYPE.BAR_GROUP:
|
|
53
|
+
case STAT_TYPE.BAR_STACK:
|
|
54
|
+
case STAT_TYPE.HORIZONTAL_GROUP_BAR:
|
|
55
|
+
case STAT_TYPE.STACKED_HORIZONTAL_BAR:
|
|
56
|
+
case STAT_TYPE.PIE:
|
|
57
|
+
case STAT_TYPE.RING:
|
|
58
|
+
case STAT_TYPE.GROUP_LINE:
|
|
59
|
+
case STAT_TYPE.AREA_GROUP_CHART:
|
|
60
|
+
{
|
|
61
|
+
return [TYPE_COLOR_USING.USE_DEFAULT, TYPE_COLOR_USING.USE_COLUMN_COLORS];
|
|
62
|
+
}
|
|
63
|
+
case STAT_TYPE.BAR:
|
|
64
|
+
case STAT_TYPE.HORIZONTAL_BAR:
|
|
65
|
+
{
|
|
66
|
+
return [TYPE_COLOR_USING.USE_DEFAULT, TYPE_COLOR_USING.USE_SPECIFIC_COLORS, TYPE_COLOR_USING.USE_RULES];
|
|
67
|
+
}
|
|
68
|
+
default:
|
|
69
|
+
{
|
|
70
|
+
return [TYPE_COLOR_USING.USE_DEFAULT];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
_this.initColorTypeOptions = function () {
|
|
75
|
+
var chart = _this.props.chart;
|
|
76
|
+
var type = chart.type;
|
|
77
|
+
var useableColorTypes = _this.getUsableColorTypes(type);
|
|
78
|
+
return useableColorTypes.map(function (colorType) {
|
|
79
|
+
return {
|
|
80
|
+
value: colorType,
|
|
81
|
+
label: /*#__PURE__*/React.createElement("span", {
|
|
82
|
+
className: "select-module select-module-name"
|
|
83
|
+
}, intl.get(TYPE_DISPLAY_COLOR_USING[colorType]))
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
_this.getSelectedSpecificColor = function () {
|
|
88
|
+
var _this$props = _this.props,
|
|
89
|
+
chart = _this$props.chart,
|
|
90
|
+
labelColorConfigs = _this$props.labelColorConfigs;
|
|
91
|
+
var type = chart.type;
|
|
92
|
+
switch (type) {
|
|
93
|
+
case STAT_TYPE.BAR:
|
|
94
|
+
{
|
|
95
|
+
var y_axis_label_color = chart.y_axis_label_color;
|
|
96
|
+
if (y_axis_label_color) {
|
|
97
|
+
return y_axis_label_color.toUpperCase();
|
|
98
|
+
}
|
|
99
|
+
return labelColorConfigs[0].color;
|
|
100
|
+
}
|
|
101
|
+
case STAT_TYPE.HORIZONTAL_BAR:
|
|
102
|
+
{
|
|
103
|
+
var horizontal_axis_label_color = chart.horizontal_axis_label_color;
|
|
104
|
+
if (horizontal_axis_label_color) {
|
|
105
|
+
return horizontal_axis_label_color.toUpperCase();
|
|
106
|
+
}
|
|
107
|
+
return labelColorConfigs[0].color;
|
|
108
|
+
}
|
|
109
|
+
default:
|
|
110
|
+
{
|
|
111
|
+
return '';
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
_this.getColorRules = function () {
|
|
116
|
+
var chart = _this.props.chart;
|
|
117
|
+
var type = chart.type;
|
|
118
|
+
switch (type) {
|
|
119
|
+
case STAT_TYPE.BAR:
|
|
120
|
+
{
|
|
121
|
+
return getValidColorRules(chart.y_axis_label_color_rules);
|
|
122
|
+
}
|
|
123
|
+
case STAT_TYPE.HORIZONTAL_BAR:
|
|
124
|
+
{
|
|
125
|
+
return getValidColorRules(chart.horizontal_axis_label_color_rules);
|
|
126
|
+
}
|
|
127
|
+
default:
|
|
128
|
+
{
|
|
129
|
+
return [];
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
_this.getColorRuleTypes = function () {
|
|
134
|
+
var chart = _this.props.chart;
|
|
135
|
+
var type = chart.type;
|
|
136
|
+
switch (type) {
|
|
137
|
+
case STAT_TYPE.BAR:
|
|
138
|
+
case STAT_TYPE.HORIZONTAL_BAR:
|
|
139
|
+
{
|
|
140
|
+
return [COLOR_RULE_FILTER_TYPE_MAP.NUMERIC_VALUE];
|
|
141
|
+
}
|
|
142
|
+
default:
|
|
143
|
+
{
|
|
144
|
+
return [];
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
_this.onSelectColorOption = function (_ref) {
|
|
149
|
+
var color_option = _ref.value;
|
|
150
|
+
var _this$props2 = _this.props,
|
|
151
|
+
chart = _this$props2.chart,
|
|
152
|
+
labelColorConfigs = _this$props2.labelColorConfigs;
|
|
153
|
+
var updatedChart = Object.assign({}, chart, {
|
|
154
|
+
color_option: color_option
|
|
155
|
+
});
|
|
156
|
+
if (color_option === TYPE_COLOR_USING.USE_SPECIFIC_COLORS) {
|
|
157
|
+
switch (chart.type) {
|
|
158
|
+
case STAT_TYPE.BAR:
|
|
159
|
+
{
|
|
160
|
+
updatedChart.y_axis_label_color = updatedChart.y_axis_label_color || labelColorConfigs[0].color;
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
case STAT_TYPE.HORIZONTAL_BAR:
|
|
164
|
+
{
|
|
165
|
+
updatedChart.horizontal_axis_label_color = updatedChart.horizontal_axis_label_color || labelColorConfigs[0].color;
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
default:
|
|
169
|
+
{
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
_this.props.updateChart(updatedChart);
|
|
175
|
+
};
|
|
176
|
+
_this.onToggleColorSelector = function () {
|
|
177
|
+
_this.setState({
|
|
178
|
+
isShowColorSelector: !_this.state.isShowColorSelector
|
|
179
|
+
}, function () {
|
|
180
|
+
if (!_this.state.isShowColorSelector) {
|
|
181
|
+
_this.modifySpecificColor(_this.state.specificColor);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
};
|
|
185
|
+
_this.showColorRulesEditor = function () {
|
|
186
|
+
if (_this.state.isShowColorRulesEditor) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
_this.setState({
|
|
190
|
+
isShowColorRulesEditor: true
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
_this.hideColorRulesEditor = function () {
|
|
194
|
+
_this.setState({
|
|
195
|
+
isShowColorRulesEditor: false
|
|
196
|
+
});
|
|
197
|
+
};
|
|
198
|
+
_this.modifySpecificColor = function (color) {
|
|
199
|
+
var chart = _this.props.chart;
|
|
200
|
+
var updatedChart = Object.assign({}, chart);
|
|
201
|
+
switch (chart.type) {
|
|
202
|
+
case STAT_TYPE.BAR:
|
|
203
|
+
{
|
|
204
|
+
updatedChart.y_axis_label_color = color;
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
case STAT_TYPE.HORIZONTAL_BAR:
|
|
208
|
+
{
|
|
209
|
+
updatedChart.horizontal_axis_label_color = color;
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
default:
|
|
213
|
+
{
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
_this.setState({
|
|
218
|
+
specificColor: color
|
|
219
|
+
}, function () {
|
|
220
|
+
_this.props.updateChart(updatedChart);
|
|
221
|
+
});
|
|
222
|
+
};
|
|
223
|
+
_this.modifyHex = function (colorSelection) {
|
|
224
|
+
if (colorSelection.hex === _this.state.specificColor) return;
|
|
225
|
+
_this.setState({
|
|
226
|
+
specificColor: colorSelection.hex
|
|
227
|
+
});
|
|
228
|
+
};
|
|
229
|
+
_this.modifyColorRules = function (colorRules) {
|
|
230
|
+
var chart = _this.props.chart;
|
|
231
|
+
var updatedChart = Object.assign({}, chart);
|
|
232
|
+
switch (chart.type) {
|
|
233
|
+
case STAT_TYPE.BAR:
|
|
234
|
+
{
|
|
235
|
+
updatedChart.y_axis_label_color_rules = colorRules;
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
238
|
+
case STAT_TYPE.HORIZONTAL_BAR:
|
|
239
|
+
{
|
|
240
|
+
updatedChart.horizontal_axis_label_color_rules = colorRules;
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
default:
|
|
244
|
+
{
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
_this.props.updateChart(updatedChart);
|
|
249
|
+
};
|
|
250
|
+
_this.renderSpecificColorSelector = function () {
|
|
251
|
+
var specificColor = _this.state.specificColor;
|
|
252
|
+
var id = 'statistic_selected_specific_color';
|
|
253
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
254
|
+
id: id,
|
|
255
|
+
className: "selected-specific-color mt-1",
|
|
256
|
+
ref: function ref(_ref2) {
|
|
257
|
+
return _this.colorPickerContainerRef = _ref2;
|
|
258
|
+
}
|
|
259
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
260
|
+
className: "selected-specific-color-wrapper"
|
|
261
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
262
|
+
className: "specific-color-show",
|
|
263
|
+
style: {
|
|
264
|
+
backgroundColor: specificColor
|
|
265
|
+
},
|
|
266
|
+
onClick: _this.onToggleColorSelector
|
|
267
|
+
}), /*#__PURE__*/React.createElement(Input, {
|
|
268
|
+
type: "text",
|
|
269
|
+
className: "specific-color-input",
|
|
270
|
+
value: specificColor,
|
|
271
|
+
onChange: function onChange(event) {
|
|
272
|
+
return _this.modifySpecificColor(event.target.value);
|
|
273
|
+
}
|
|
274
|
+
}))), _this.state.isShowColorSelector && /*#__PURE__*/React.createElement("div", {
|
|
275
|
+
style: _this.getPopoverStyle()
|
|
276
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
277
|
+
className: "position-fixed",
|
|
278
|
+
style: COVER,
|
|
279
|
+
onClick: _this.onToggleColorSelector
|
|
280
|
+
}), /*#__PURE__*/React.createElement(ReactColor, {
|
|
281
|
+
disableAlpha: true,
|
|
282
|
+
color: specificColor,
|
|
283
|
+
onChange: _this.modifyHex
|
|
284
|
+
})));
|
|
285
|
+
};
|
|
286
|
+
_this.renderColorRulesEditor = function () {
|
|
287
|
+
var labelColorConfigs = _this.props.labelColorConfigs;
|
|
288
|
+
var colorRules = _this.getColorRules();
|
|
289
|
+
var colorRuleTypes = _this.getColorRuleTypes();
|
|
290
|
+
var rulesLen = colorRules ? colorRules.length : 0;
|
|
291
|
+
var hasRules = rulesLen > 0;
|
|
292
|
+
var id = 'statistic_color_rules_toggle';
|
|
293
|
+
var msg = intl.get('Add_rule');
|
|
294
|
+
if (rulesLen === 1) {
|
|
295
|
+
msg = intl.get('Added_1_rule');
|
|
296
|
+
} else if (rulesLen > 1) {
|
|
297
|
+
msg = intl.get('Added_xxx_rules', {
|
|
298
|
+
rules_count: rulesLen
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
302
|
+
id: id,
|
|
303
|
+
className: classnames('statistic-color-rules-toggle', 'mt-1', hasRules ? 'statistic-edit-color-rule' : 'statistic-add-color-rule'),
|
|
304
|
+
onClick: _this.showColorRulesEditor
|
|
305
|
+
}, hasRules ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", null, msg), /*#__PURE__*/React.createElement("i", {
|
|
306
|
+
className: "dtable-font dtable-icon-rename"
|
|
307
|
+
})) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("i", {
|
|
308
|
+
className: "dtable-font dtable-icon-add-table"
|
|
309
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
310
|
+
className: "ml-2"
|
|
311
|
+
}, msg))), _this.state.isShowColorRulesEditor && /*#__PURE__*/React.createElement(ColorRulesPopover, {
|
|
312
|
+
target: id,
|
|
313
|
+
colorRules: colorRules,
|
|
314
|
+
colorRuleTypes: colorRuleTypes,
|
|
315
|
+
labelColorConfigs: labelColorConfigs,
|
|
316
|
+
hideColorRulesPopover: _this.hideColorRulesEditor,
|
|
317
|
+
updateColorRules: _this.modifyColorRules
|
|
318
|
+
}));
|
|
319
|
+
};
|
|
320
|
+
_this.state = {
|
|
321
|
+
isShowColorSelector: false,
|
|
322
|
+
isShowColorRulesEditor: false,
|
|
323
|
+
specificColor: _this.getSelectedSpecificColor()
|
|
324
|
+
};
|
|
325
|
+
_this.colorOptions = _this.initColorTypeOptions();
|
|
326
|
+
_this.isToggleColorRulesEditor = false;
|
|
327
|
+
return _this;
|
|
328
|
+
}
|
|
329
|
+
_createClass(ColorUseTypeSelector, [{
|
|
330
|
+
key: "render",
|
|
331
|
+
value: function render() {
|
|
332
|
+
var chart = this.props.chart;
|
|
333
|
+
var color_option = chart.color_option;
|
|
334
|
+
var selectedColorOption = this.colorOptions.find(function (colorOption) {
|
|
335
|
+
return colorOption.value === color_option;
|
|
336
|
+
}) || this.colorOptions[0];
|
|
337
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
338
|
+
className: "statistic-chart-parameter-item"
|
|
339
|
+
}, /*#__PURE__*/React.createElement("label", null, intl.get('Color')), /*#__PURE__*/React.createElement(DTableSelect, {
|
|
340
|
+
value: selectedColorOption,
|
|
341
|
+
options: this.colorOptions,
|
|
342
|
+
onChange: this.onSelectColorOption
|
|
343
|
+
}), color_option === TYPE_COLOR_USING.USE_SPECIFIC_COLORS && this.renderSpecificColorSelector(), color_option === TYPE_COLOR_USING.USE_RULES && this.renderColorRulesEditor());
|
|
344
|
+
}
|
|
345
|
+
}]);
|
|
346
|
+
return ColorUseTypeSelector;
|
|
347
|
+
}(Component);
|
|
348
|
+
export default ColorUseTypeSelector;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
|
+
import React, { Component } from 'react';
|
|
6
|
+
import intl from 'react-intl-universal';
|
|
7
|
+
import { DTableSelect } from '../../../components';
|
|
8
|
+
var LABEL_POSITIONS_X = ['left', 'center', 'right'];
|
|
9
|
+
var LABEL_POSITIONS_Y = ['bottom', 'center', 'top'];
|
|
10
|
+
var LABEL_POSITIONS_SHOW_X = {
|
|
11
|
+
left: 'Left',
|
|
12
|
+
center: 'Center',
|
|
13
|
+
right: 'Right'
|
|
14
|
+
};
|
|
15
|
+
var LABEL_POSITIONS_SHOW_Y = {
|
|
16
|
+
bottom: 'Bottom',
|
|
17
|
+
center: 'Center',
|
|
18
|
+
top: 'Top'
|
|
19
|
+
};
|
|
20
|
+
var AxisLabelPosition = /*#__PURE__*/function (_Component) {
|
|
21
|
+
_inherits(AxisLabelPosition, _Component);
|
|
22
|
+
var _super = _createSuper(AxisLabelPosition);
|
|
23
|
+
function AxisLabelPosition(props) {
|
|
24
|
+
var _this;
|
|
25
|
+
_classCallCheck(this, AxisLabelPosition);
|
|
26
|
+
_this = _super.call(this, props);
|
|
27
|
+
_this.getLabelPositionOptions = function () {
|
|
28
|
+
var axisType = _this.props.axisType;
|
|
29
|
+
var positions = LABEL_POSITIONS_X;
|
|
30
|
+
if (axisType.includes('y') || axisType === 'vertical') {
|
|
31
|
+
positions = LABEL_POSITIONS_Y;
|
|
32
|
+
}
|
|
33
|
+
if (axisType === 'x' || axisType === 'horizontal') {
|
|
34
|
+
return positions.map(function (g) {
|
|
35
|
+
return {
|
|
36
|
+
value: g,
|
|
37
|
+
label: /*#__PURE__*/React.createElement("span", {
|
|
38
|
+
className: 'select-module select-module-name'
|
|
39
|
+
}, intl.get(LABEL_POSITIONS_SHOW_X[g]))
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
if (axisType.includes('y') || axisType === 'vertical') {
|
|
44
|
+
return positions.map(function (g) {
|
|
45
|
+
return {
|
|
46
|
+
value: g,
|
|
47
|
+
label: /*#__PURE__*/React.createElement("span", {
|
|
48
|
+
className: 'select-module select-module-name'
|
|
49
|
+
}, intl.get(LABEL_POSITIONS_SHOW_Y[g]))
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
_this.onSelectAxisPosition = function (option) {
|
|
55
|
+
var axisType = _this.props.axisType;
|
|
56
|
+
_this.props.onSelectAxisLabelPosition(axisType, option);
|
|
57
|
+
};
|
|
58
|
+
_this.renderXAxisLabelPosition = function () {
|
|
59
|
+
var _this$props = _this.props,
|
|
60
|
+
statItem = _this$props.statItem,
|
|
61
|
+
axisType = _this$props.axisType;
|
|
62
|
+
var selectedOption = null;
|
|
63
|
+
if (axisType === 'y' || axisType === 'vertical') {
|
|
64
|
+
var y_axis_label_position = statItem.y_axis_label_position,
|
|
65
|
+
vertical_axis_label_position = statItem.vertical_axis_label_position;
|
|
66
|
+
selectedOption = _this.labelPositionOptions.find(function (item) {
|
|
67
|
+
return item.value === y_axis_label_position || item.value === vertical_axis_label_position;
|
|
68
|
+
});
|
|
69
|
+
} else if (axisType === 'y_left' || axisType === 'y_right') {
|
|
70
|
+
var y_axis_left_label_position = statItem.y_axis_left_label_position,
|
|
71
|
+
y_axis_right_label_position = statItem.y_axis_right_label_position;
|
|
72
|
+
var target = axisType === 'y_left' ? y_axis_left_label_position : y_axis_right_label_position;
|
|
73
|
+
selectedOption = _this.labelPositionOptions.find(function (item) {
|
|
74
|
+
return item.value === target;
|
|
75
|
+
});
|
|
76
|
+
} else {
|
|
77
|
+
var x_axis_label_position = statItem.x_axis_label_position,
|
|
78
|
+
horizontal_axis_label_position = statItem.horizontal_axis_label_position;
|
|
79
|
+
selectedOption = _this.labelPositionOptions.find(function (item) {
|
|
80
|
+
return item.value === x_axis_label_position || item.value === horizontal_axis_label_position;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
84
|
+
className: "mt-1"
|
|
85
|
+
}, /*#__PURE__*/React.createElement(DTableSelect, {
|
|
86
|
+
value: selectedOption,
|
|
87
|
+
onChange: _this.onSelectAxisPosition,
|
|
88
|
+
options: _this.labelPositionOptions
|
|
89
|
+
}));
|
|
90
|
+
};
|
|
91
|
+
_this.labelPositionOptions = _this.getLabelPositionOptions();
|
|
92
|
+
return _this;
|
|
93
|
+
}
|
|
94
|
+
_createClass(AxisLabelPosition, [{
|
|
95
|
+
key: "render",
|
|
96
|
+
value: function render() {
|
|
97
|
+
return this.renderXAxisLabelPosition();
|
|
98
|
+
}
|
|
99
|
+
}]);
|
|
100
|
+
return AxisLabelPosition;
|
|
101
|
+
}(Component);
|
|
102
|
+
export default AxisLabelPosition;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
6
|
+
import React, { Component, Fragment } from 'react';
|
|
7
|
+
import intl from 'react-intl-universal';
|
|
8
|
+
import { DTableSelect } from '../../../components';
|
|
9
|
+
import { INIT_STAT_ITEM } from '../../../constants';
|
|
10
|
+
var BaseSettings = /*#__PURE__*/function (_Component) {
|
|
11
|
+
_inherits(BaseSettings, _Component);
|
|
12
|
+
var _super = _createSuper(BaseSettings);
|
|
13
|
+
function BaseSettings(_props) {
|
|
14
|
+
var _this;
|
|
15
|
+
_classCallCheck(this, BaseSettings);
|
|
16
|
+
_this = _super.call(this, _props);
|
|
17
|
+
_this.getTablesOptions = function () {
|
|
18
|
+
var tables = _this.props.getTables();
|
|
19
|
+
return Array.isArray(tables) && tables.map(function (table) {
|
|
20
|
+
return {
|
|
21
|
+
label: /*#__PURE__*/React.createElement("span", {
|
|
22
|
+
className: "select-option-name"
|
|
23
|
+
}, table.name),
|
|
24
|
+
value: {
|
|
25
|
+
name: table.name,
|
|
26
|
+
id: table._id
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
_this.getViewsOptions = function (props) {
|
|
32
|
+
var getTableById = props.getTableById,
|
|
33
|
+
getViews = props.getViews,
|
|
34
|
+
selectedTableId = props.selectedTableId;
|
|
35
|
+
var selectedTable = getTableById(selectedTableId);
|
|
36
|
+
var views = getViews(selectedTable);
|
|
37
|
+
return views.map(function (view) {
|
|
38
|
+
var isArchiveView = view.type === 'archive';
|
|
39
|
+
return {
|
|
40
|
+
label: /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
41
|
+
className: "header-icon"
|
|
42
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
43
|
+
className: isArchiveView ? 'dtable-font dtable-icon-archive-view' : 'dtable-font dtable-icon-main-view'
|
|
44
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
45
|
+
className: "select-option-name"
|
|
46
|
+
}, view.name)),
|
|
47
|
+
value: {
|
|
48
|
+
name: view.name,
|
|
49
|
+
id: view._id
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
_this.getSelectedTableOption = function () {
|
|
55
|
+
return _this.tablesOptions.find(function (option) {
|
|
56
|
+
return option.value.id === _this.props.selectedTableId;
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
_this.getSelectedViewOption = function () {
|
|
60
|
+
return _this.viewsOptions.find(function (option) {
|
|
61
|
+
return option.value.id === _this.props.selectedViewId;
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
_this.onSelectTable = function (option) {
|
|
65
|
+
var selectedTableId = option.value.id;
|
|
66
|
+
var _this$props = _this.props,
|
|
67
|
+
getTableById = _this$props.getTableById,
|
|
68
|
+
getViews = _this$props.getViews,
|
|
69
|
+
statItem = _this$props.statItem;
|
|
70
|
+
var type = statItem.type,
|
|
71
|
+
table_id = statItem.table_id;
|
|
72
|
+
if (selectedTableId === table_id) return;
|
|
73
|
+
var selectedTable = getTableById(selectedTableId);
|
|
74
|
+
var selectedView = getViews(selectedTable)[0];
|
|
75
|
+
var view_id = selectedView._id;
|
|
76
|
+
_this.props.updateStatItem(Object.assign({}, statItem, _objectSpread({
|
|
77
|
+
table_id: selectedTable._id,
|
|
78
|
+
view_id: view_id
|
|
79
|
+
}, INIT_STAT_ITEM[type])));
|
|
80
|
+
};
|
|
81
|
+
_this.onSelectView = function (option) {
|
|
82
|
+
var selectedView = option.value;
|
|
83
|
+
var statItem = _this.props.statItem;
|
|
84
|
+
var id = selectedView.id;
|
|
85
|
+
var view_id = statItem.view_id;
|
|
86
|
+
if (id === view_id) return;
|
|
87
|
+
_this.props.updateStatItem(Object.assign({}, statItem, {
|
|
88
|
+
view_id: id
|
|
89
|
+
}));
|
|
90
|
+
};
|
|
91
|
+
_this.tablesOptions = _this.getTablesOptions();
|
|
92
|
+
_this.viewsOptions = _this.getViewsOptions(_props);
|
|
93
|
+
return _this;
|
|
94
|
+
}
|
|
95
|
+
_createClass(BaseSettings, [{
|
|
96
|
+
key: "UNSAFE_componentWillReceiveProps",
|
|
97
|
+
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
98
|
+
if (nextProps.selectedTableId !== this.props.selectedTableId) {
|
|
99
|
+
this.viewsOptions = this.getViewsOptions(nextProps);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}, {
|
|
103
|
+
key: "render",
|
|
104
|
+
value: function render() {
|
|
105
|
+
var selectedTableOption = this.getSelectedTableOption();
|
|
106
|
+
var selectedViewOption = this.getSelectedViewOption();
|
|
107
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
108
|
+
className: "statistic-chart-parameter-item"
|
|
109
|
+
}, /*#__PURE__*/React.createElement("label", null, intl.get('Table')), /*#__PURE__*/React.createElement(DTableSelect, {
|
|
110
|
+
value: selectedTableOption,
|
|
111
|
+
options: this.tablesOptions,
|
|
112
|
+
onChange: this.onSelectTable
|
|
113
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
114
|
+
className: "statistic-chart-parameter-item"
|
|
115
|
+
}, /*#__PURE__*/React.createElement("label", null, intl.get('Views')), /*#__PURE__*/React.createElement(DTableSelect, {
|
|
116
|
+
value: selectedViewOption,
|
|
117
|
+
options: this.viewsOptions,
|
|
118
|
+
onChange: this.onSelectView
|
|
119
|
+
})));
|
|
120
|
+
}
|
|
121
|
+
}]);
|
|
122
|
+
return BaseSettings;
|
|
123
|
+
}(Component);
|
|
124
|
+
export default BaseSettings;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
4
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import dayjs from 'dayjs';
|
|
7
|
+
import intl from 'react-intl-universal';
|
|
8
|
+
import DatePicker from '@seafile/seafile-calendar/lib/Picker';
|
|
9
|
+
import Calendar from '@seafile/seafile-calendar';
|
|
10
|
+
import { translateCalendar } from '../../../utils';
|
|
11
|
+
import 'dayjs/locale/zh-cn';
|
|
12
|
+
import 'dayjs/locale/en-gb';
|
|
13
|
+
import '@seafile/seafile-calendar/assets/index.css';
|
|
14
|
+
var DateEditorPopover = /*#__PURE__*/function (_React$Component) {
|
|
15
|
+
_inherits(DateEditorPopover, _React$Component);
|
|
16
|
+
var _super = _createSuper(DateEditorPopover);
|
|
17
|
+
function DateEditorPopover(props) {
|
|
18
|
+
var _this;
|
|
19
|
+
_classCallCheck(this, DateEditorPopover);
|
|
20
|
+
_this = _super.call(this, props);
|
|
21
|
+
// event trigger sequence: onOpenChange --> onChange
|
|
22
|
+
_this.onChange = function (value) {
|
|
23
|
+
if (!value) return;
|
|
24
|
+
var dateFormat = _this.props.dateFormat;
|
|
25
|
+
_this.setState({
|
|
26
|
+
datePickerValue: value
|
|
27
|
+
});
|
|
28
|
+
_this.props.onValueChanged(value.format(dateFormat));
|
|
29
|
+
};
|
|
30
|
+
_this.onOpenChange = function (open) {
|
|
31
|
+
_this.setState({
|
|
32
|
+
open: open
|
|
33
|
+
});
|
|
34
|
+
if (!open) {
|
|
35
|
+
setTimeout(function () {
|
|
36
|
+
_this.props.commitAndClosePopover();
|
|
37
|
+
}, 1);
|
|
38
|
+
}
|
|
39
|
+
return;
|
|
40
|
+
};
|
|
41
|
+
_this.onClear = function () {
|
|
42
|
+
_this.setState({
|
|
43
|
+
datePickerValue: null
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
_this.onFocusDatePicker = function () {
|
|
47
|
+
_this.setState({
|
|
48
|
+
open: true
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
_this.handleMouseDown = function (event) {
|
|
52
|
+
event.preventDefault();
|
|
53
|
+
event.stopPropagation();
|
|
54
|
+
};
|
|
55
|
+
_this.getCalendarContainer = function () {
|
|
56
|
+
return _this.calendarContainerRef.current;
|
|
57
|
+
};
|
|
58
|
+
_this.getCalender = function () {
|
|
59
|
+
var _this$props = _this.props,
|
|
60
|
+
dateFormat = _this$props.dateFormat,
|
|
61
|
+
showHourAndMinute = _this$props.showHourAndMinute;
|
|
62
|
+
var defaultValue = dayjs().clone();
|
|
63
|
+
return /*#__PURE__*/React.createElement(Calendar, {
|
|
64
|
+
showDateInput: true,
|
|
65
|
+
focusablePanel: false,
|
|
66
|
+
locale: translateCalendar(),
|
|
67
|
+
style: {
|
|
68
|
+
zIndex: 1001
|
|
69
|
+
},
|
|
70
|
+
format: dateFormat,
|
|
71
|
+
defaultValue: defaultValue,
|
|
72
|
+
showHourAndMinute: showHourAndMinute,
|
|
73
|
+
dateInputPlaceholder: intl.get('Enter_date'),
|
|
74
|
+
onClear: _this.onClear
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
_this.state = {
|
|
78
|
+
open: true,
|
|
79
|
+
datePickerValue: props.value ? dayjs(props.value) : null
|
|
80
|
+
};
|
|
81
|
+
_this.calendarContainerRef = React.createRef();
|
|
82
|
+
return _this;
|
|
83
|
+
}
|
|
84
|
+
_createClass(DateEditorPopover, [{
|
|
85
|
+
key: "render",
|
|
86
|
+
value: function render() {
|
|
87
|
+
var _this2 = this;
|
|
88
|
+
var dateFormat = this.props.dateFormat;
|
|
89
|
+
var _this$state = this.state,
|
|
90
|
+
open = _this$state.open,
|
|
91
|
+
datePickerValue = _this$state.datePickerValue;
|
|
92
|
+
var calendar = this.getCalender();
|
|
93
|
+
return /*#__PURE__*/React.createElement(DatePicker, {
|
|
94
|
+
open: open,
|
|
95
|
+
value: datePickerValue,
|
|
96
|
+
style: {
|
|
97
|
+
zIndex: 1001
|
|
98
|
+
},
|
|
99
|
+
calendar: calendar,
|
|
100
|
+
getCalendarContainer: this.getCalendarContainer,
|
|
101
|
+
onChange: this.onChange,
|
|
102
|
+
onOpenChange: this.onOpenChange
|
|
103
|
+
}, function (_ref) {
|
|
104
|
+
var value = _ref.value;
|
|
105
|
+
value = value && value.format(dateFormat);
|
|
106
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
107
|
+
tabIndex: "0",
|
|
108
|
+
onFocus: _this2.onFocusDatePicker
|
|
109
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
110
|
+
readOnly: true,
|
|
111
|
+
tabIndex: "-1",
|
|
112
|
+
className: "form-control",
|
|
113
|
+
placeholder: intl.get('Please_select'),
|
|
114
|
+
value: value || '',
|
|
115
|
+
onMouseDown: _this2.handleMouseDown
|
|
116
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
117
|
+
ref: _this2.calendarContainerRef
|
|
118
|
+
}));
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}]);
|
|
122
|
+
return DateEditorPopover;
|
|
123
|
+
}(React.Component);
|
|
124
|
+
export default DateEditorPopover;
|