sea-chart 0.0.1
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 +4 -0
- package/lib/assets/icons/area-chart.svg +10 -0
- package/lib/assets/icons/bar-chart.svg +12 -0
- package/lib/assets/icons/card.svg +22 -0
- package/lib/assets/icons/combination-chart.svg +17 -0
- package/lib/assets/icons/dtable-logo.svg +16 -0
- package/lib/assets/icons/facet-chart.svg +12 -0
- package/lib/assets/icons/gauge.svg +18 -0
- package/lib/assets/icons/heat-map.svg +14 -0
- package/lib/assets/icons/histogram.svg +12 -0
- package/lib/assets/icons/line-chart.svg +12 -0
- package/lib/assets/icons/map.svg +20 -0
- package/lib/assets/icons/pie-chart.svg +11 -0
- package/lib/assets/icons/rectangular-tree-diagram.svg +10 -0
- package/lib/assets/icons/scatter-chart.svg +15 -0
- package/lib/assets/icons/type-change.svg +17 -0
- package/lib/assets/img/area-chart.png +0 -0
- package/lib/assets/img/area-group-chart.png +0 -0
- package/lib/assets/img/bar-group.png +0 -0
- package/lib/assets/img/bar-stack.png +0 -0
- package/lib/assets/img/bar.png +0 -0
- package/lib/assets/img/combination-chart.png +0 -0
- package/lib/assets/img/compared-chart.png +0 -0
- package/lib/assets/img/completeness-chart.png +0 -0
- package/lib/assets/img/custom-bar.png +0 -0
- package/lib/assets/img/dashboard-chart.png +0 -0
- package/lib/assets/img/group-completeness-chart.png +0 -0
- package/lib/assets/img/group_line.png +0 -0
- package/lib/assets/img/heat-map.png +0 -0
- package/lib/assets/img/horizontal-bar.png +0 -0
- package/lib/assets/img/horizontal-group-bar.png +0 -0
- package/lib/assets/img/line.png +0 -0
- package/lib/assets/img/map-bubble.png +0 -0
- package/lib/assets/img/map.png +0 -0
- package/lib/assets/img/mirror.png +0 -0
- package/lib/assets/img/number-card.png +0 -0
- package/lib/assets/img/pie.png +0 -0
- package/lib/assets/img/pivot-table.png +0 -0
- package/lib/assets/img/ring.png +0 -0
- package/lib/assets/img/scatter.png +0 -0
- package/lib/assets/img/stacked-horizontal-bar.png +0 -0
- package/lib/assets/img/treemap.png +0 -0
- package/lib/assets/img/trend-chart.png +0 -0
- package/lib/assets/img/world-map-bubble.png +0 -0
- package/lib/assets/img/world-map.png +0 -0
- package/lib/components/collaborator/index.js +24 -0
- package/lib/components/formatter/area.js +162 -0
- package/lib/components/formatter/bar-group.js +160 -0
- package/lib/components/formatter/bar.js +150 -0
- package/lib/components/formatter/basic-number-card.js +138 -0
- package/lib/components/formatter/chart-component.js +266 -0
- package/lib/components/formatter/combination.js +407 -0
- package/lib/components/formatter/dashboard.js +182 -0
- package/lib/components/formatter/horizontal-bar-group.js +161 -0
- package/lib/components/formatter/horizontal-bar.js +152 -0
- package/lib/components/formatter/horizontal-component.js +91 -0
- package/lib/components/formatter/index.js +181 -0
- package/lib/components/formatter/line-group.js +157 -0
- package/lib/components/formatter/line.js +170 -0
- package/lib/components/formatter/pie.js +201 -0
- package/lib/components/formatter/ring.js +277 -0
- package/lib/components/formatter/table/index.css +103 -0
- package/lib/components/formatter/table/index.js +42 -0
- package/lib/components/formatter/table/one-dimension-table-no-numeric-columns.js +145 -0
- package/lib/components/formatter/table/one-dimension-table-with-numeric-columns.js +193 -0
- package/lib/components/formatter/table/pivot-table-display-name.js +249 -0
- package/lib/components/formatter/table/two-dimension-table.js +241 -0
- package/lib/components/formatter/treemap.js +213 -0
- package/lib/components/icon/index.css +5 -0
- package/lib/components/icon/index.js +22 -0
- package/lib/components/index.js +5 -0
- package/lib/components/loading/index.css +54 -0
- package/lib/components/loading/index.js +10 -0
- package/lib/components/number-input/index.js +31 -0
- package/lib/components/pixel-editor/index.css +29 -0
- package/lib/components/pixel-editor/index.js +42 -0
- package/lib/components/select-group/index.css +67 -0
- package/lib/components/select-group/index.js +63 -0
- package/lib/components/settings/advance-bar-settings/data-settings.js +120 -0
- package/lib/components/settings/advance-bar-settings/index.js +3 -0
- package/lib/components/settings/advance-bar-settings/style-settings.js +149 -0
- package/lib/components/settings/bar-settings/data-settings.js +137 -0
- package/lib/components/settings/bar-settings/index.js +3 -0
- package/lib/components/settings/bar-settings/style-settings.js +163 -0
- package/lib/components/settings/basic-number-card/data-settings.js +121 -0
- package/lib/components/settings/basic-number-card/index.js +3 -0
- package/lib/components/settings/basic-number-card/style-settings.js +42 -0
- package/lib/components/settings/combination-settings/data-settings.js +256 -0
- package/lib/components/settings/combination-settings/index.js +3 -0
- package/lib/components/settings/combination-settings/style-settings.js +183 -0
- package/lib/components/settings/dashboard-settings/data-settings.js +167 -0
- package/lib/components/settings/dashboard-settings/index.js +2 -0
- package/lib/components/settings/data-settings.js +67 -0
- package/lib/components/settings/horizontal-bar-settings/data-settings.js +45 -0
- package/lib/components/settings/horizontal-bar-settings/index.js +3 -0
- package/lib/components/settings/horizontal-bar-settings/style-settings.js +38 -0
- package/lib/components/settings/index.css +73 -0
- package/lib/components/settings/index.js +74 -0
- package/lib/components/settings/pie-settings/data-settings.js +123 -0
- package/lib/components/settings/pie-settings/index.js +3 -0
- package/lib/components/settings/pie-settings/style-settings.js +123 -0
- package/lib/components/settings/style-settings.js +100 -0
- package/lib/components/settings/table-settings/data-settings.js +488 -0
- package/lib/components/settings/table-settings/index.js +2 -0
- package/lib/components/settings/time-comparison-settings/data-settings.js +157 -0
- package/lib/components/settings/time-comparison-settings/index.js +3 -0
- package/lib/components/settings/time-comparison-settings/style-settings.js +191 -0
- package/lib/components/settings/widgets/basic-summary/index.css +12 -0
- package/lib/components/settings/widgets/basic-summary/index.js +173 -0
- package/lib/components/settings/widgets/common-data-settings.js +42 -0
- package/lib/components/settings/widgets/data-filter/index.css +17 -0
- package/lib/components/settings/widgets/data-filter/index.js +76 -0
- package/lib/components/settings/widgets/data-sort.js +38 -0
- package/lib/components/settings/widgets/date-summary-item.js +126 -0
- package/lib/components/settings/widgets/display-values-settings/index.css +13 -0
- package/lib/components/settings/widgets/display-values-settings/index.js +37 -0
- package/lib/components/settings/widgets/divider/index.css +4 -0
- package/lib/components/settings/widgets/divider/index.js +10 -0
- package/lib/components/settings/widgets/font-settings/font-size-settings.js +31 -0
- package/lib/components/settings/widgets/font-settings/font-weight-settings.js +46 -0
- package/lib/components/settings/widgets/font-settings/index.js +3 -0
- package/lib/components/settings/widgets/group-by.js +168 -0
- package/lib/components/settings/widgets/label-color.js +30 -0
- package/lib/components/settings/widgets/min-max-setting.js +64 -0
- package/lib/components/settings/widgets/mininum-slice-percent.js +72 -0
- package/lib/components/settings/widgets/numeric-summary-item.js +109 -0
- package/lib/components/settings/widgets/select-table/index.css +0 -0
- package/lib/components/settings/widgets/select-table/index.js +49 -0
- package/lib/components/settings/widgets/stack.js +58 -0
- package/lib/components/settings/widgets/statistic-type/index.css +31 -0
- package/lib/components/settings/widgets/statistic-type/index.js +54 -0
- package/lib/components/settings/widgets/summary-method-setting.js +80 -0
- package/lib/components/settings/widgets/summary-settings.js +394 -0
- package/lib/components/settings/widgets/switch/index.css +37 -0
- package/lib/components/settings/widgets/switch/index.js +21 -0
- package/lib/components/settings/widgets/text-horizontal-settings.js +23 -0
- package/lib/components/settings/widgets/time-picker.js +182 -0
- package/lib/components/settings/widgets/title-settings/index.js +58 -0
- package/lib/components/settings/widgets/title-settings/title-text.js +31 -0
- package/lib/components/settings/widgets/x-axios.js +0 -0
- package/lib/components/settings/widgets/y-axis-group-settings.js +399 -0
- package/lib/components/types-dialog/index.css +97 -0
- package/lib/components/types-dialog/index.js +127 -0
- package/lib/constants/geolocation.js +11 -0
- package/lib/constants/index.js +164 -0
- package/lib/constants/model.js +167 -0
- package/lib/constants/style.js +13 -0
- package/lib/constants/type-image.js +32 -0
- package/lib/constants/type.js +97 -0
- package/lib/context.js +49 -0
- package/lib/index.js +6 -0
- package/lib/intl.js +37 -0
- package/lib/layout/index.js +4 -0
- package/lib/layout/statistic/index.css +53 -0
- package/lib/layout/statistic/index.js +190 -0
- package/lib/layout/title/index.css +3 -0
- package/lib/layout/title/index.js +41 -0
- package/lib/locale/index.js +11 -0
- package/lib/locale/lang/de.js +141 -0
- package/lib/locale/lang/en.js +143 -0
- package/lib/locale/lang/es.js +141 -0
- package/lib/locale/lang/fr.js +141 -0
- package/lib/locale/lang/pt.js +141 -0
- package/lib/locale/lang/ru.js +141 -0
- package/lib/locale/lang/zh_CN.js +143 -0
- package/lib/model/area-group.js +51 -0
- package/lib/model/area.js +42 -0
- package/lib/model/bar-group.js +54 -0
- package/lib/model/bar-stack.js +51 -0
- package/lib/model/bar.js +48 -0
- package/lib/model/base-model.js +11 -0
- package/lib/model/basic-number-card.js +32 -0
- package/lib/model/combination.js +48 -0
- package/lib/model/compare-bar.js +49 -0
- package/lib/model/completeness-group.js +34 -0
- package/lib/model/completeness.js +28 -0
- package/lib/model/dashboard.js +26 -0
- package/lib/model/generic-model.js +235 -0
- package/lib/model/heat-map.js +33 -0
- package/lib/model/horizontal-bar.js +48 -0
- package/lib/model/horizontal-group-bar.js +53 -0
- package/lib/model/index.js +36 -0
- package/lib/model/line-group.js +54 -0
- package/lib/model/line.js +48 -0
- package/lib/model/map-bubble.js +37 -0
- package/lib/model/map.js +37 -0
- package/lib/model/mirror.js +36 -0
- package/lib/model/pie.js +36 -0
- package/lib/model/ring.js +36 -0
- package/lib/model/scatter.js +29 -0
- package/lib/model/stacked-horizontal-bar.js +42 -0
- package/lib/model/statistic.js +22 -0
- package/lib/model/table.js +33 -0
- package/lib/model/tree-map.js +30 -0
- package/lib/model/trend.js +34 -0
- package/lib/model/user.js +22 -0
- package/lib/model/world-map-bubble.js +36 -0
- package/lib/model/world-map.js +36 -0
- package/lib/utils/cell-format-utils.js +41 -0
- package/lib/utils/chart.js +6 -0
- package/lib/utils/collaborator-utils.js +40 -0
- package/lib/utils/column-utils.js +247 -0
- package/lib/utils/custom-g2.js +612 -0
- package/lib/utils/data-filter/filter-item-utils.js +80 -0
- package/lib/utils/data-filter/filters-utils.js +406 -0
- package/lib/utils/data-filter/index.js +3 -0
- package/lib/utils/date-translate.js +66 -0
- package/lib/utils/index.js +50 -0
- package/lib/utils/key-generator.js +13 -0
- package/lib/utils/object-utils.js +61 -0
- package/lib/utils/options-utils.js +61 -0
- package/lib/utils/statistic-column-2-sql-column-utils.js +499 -0
- package/lib/utils/statistic-utils.js +1685 -0
- package/package.json +160 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
5
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
6
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
7
|
+
import React, { PureComponent } from 'react';
|
|
8
|
+
import classnames from 'classnames';
|
|
9
|
+
import PivotTableDisplayName from './pivot-table-display-name';
|
|
10
|
+
import { StatisticsUtils } from '../../../utils';
|
|
11
|
+
import intl from '../../../intl';
|
|
12
|
+
var TwoDimensionTable = /*#__PURE__*/function (_PureComponent) {
|
|
13
|
+
_inherits(TwoDimensionTable, _PureComponent);
|
|
14
|
+
var _super = _createSuper(TwoDimensionTable);
|
|
15
|
+
function TwoDimensionTable() {
|
|
16
|
+
var _this;
|
|
17
|
+
_classCallCheck(this, TwoDimensionTable);
|
|
18
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
19
|
+
args[_key] = arguments[_key];
|
|
20
|
+
}
|
|
21
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
22
|
+
_this.getCells = function (row) {
|
|
23
|
+
var _this$props = _this.props,
|
|
24
|
+
result = _this$props.result,
|
|
25
|
+
summaryColumn = _this$props.summaryColumn;
|
|
26
|
+
var pivot_columns = result.pivot_columns;
|
|
27
|
+
var cells = row.cells;
|
|
28
|
+
if (!Array.isArray(pivot_columns)) {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
return pivot_columns.map(function (item) {
|
|
32
|
+
return _objectSpread(_objectSpread({}, cells[item.key]), {}, {
|
|
33
|
+
column: summaryColumn
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
_this.renderHeader = function () {
|
|
38
|
+
var _this$props2 = _this.props,
|
|
39
|
+
result = _this$props2.result,
|
|
40
|
+
groupbyColumn = _this$props2.groupbyColumn,
|
|
41
|
+
columnGroupbyColumn = _this$props2.columnGroupbyColumn,
|
|
42
|
+
selectedCell = _this$props2.selectedCell;
|
|
43
|
+
var groupName = groupbyColumn.name;
|
|
44
|
+
var _ref = columnGroupbyColumn || {},
|
|
45
|
+
rowGroupName = _ref.name;
|
|
46
|
+
var pivot_columns = result.pivot_columns;
|
|
47
|
+
var _ref2 = selectedCell || {},
|
|
48
|
+
selectRowIdx = _ref2.rowIdx,
|
|
49
|
+
selectedCellIdx = _ref2.cellIdx;
|
|
50
|
+
var isSelectedTotalCellBottom = selectRowIdx === 0 && selectedCellIdx === (Array.isArray(pivot_columns) ? pivot_columns.length : 0);
|
|
51
|
+
return /*#__PURE__*/React.createElement("thead", {
|
|
52
|
+
className: "seatable-table-header-sm"
|
|
53
|
+
}, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
|
|
54
|
+
className: "pivot-table-header"
|
|
55
|
+
}, !rowGroupName && groupName), Array.isArray(pivot_columns) && pivot_columns.map(function (item, index) {
|
|
56
|
+
var key = item.key;
|
|
57
|
+
var isSelectedHeaderBottom = selectRowIdx === 0 && selectedCellIdx === index;
|
|
58
|
+
return /*#__PURE__*/React.createElement("th", {
|
|
59
|
+
className: classnames('pivot-table-header', {
|
|
60
|
+
'selected-pivot-cell-top': isSelectedHeaderBottom
|
|
61
|
+
}),
|
|
62
|
+
key: "pivot-column-".concat(index)
|
|
63
|
+
}, /*#__PURE__*/React.createElement(PivotTableDisplayName, {
|
|
64
|
+
value: key,
|
|
65
|
+
column: columnGroupbyColumn || {}
|
|
66
|
+
}));
|
|
67
|
+
}), /*#__PURE__*/React.createElement("th", {
|
|
68
|
+
className: classnames('pivot-table-header', {
|
|
69
|
+
'selected-pivot-cell-top': isSelectedTotalCellBottom
|
|
70
|
+
})
|
|
71
|
+
}, /*#__PURE__*/React.createElement("div", null, intl.get('Total')))));
|
|
72
|
+
};
|
|
73
|
+
_this.toggleRecords = function (cell, selectedCell) {
|
|
74
|
+
if (window.isMobile) return;
|
|
75
|
+
var _ref3 = _this.props.selectedCell || {},
|
|
76
|
+
selectedRowIdx = _ref3.rowIdx,
|
|
77
|
+
selectedCellIdx = _ref3.cellIdx;
|
|
78
|
+
var rowIdx = selectedCell.rowIdx,
|
|
79
|
+
cellIdx = selectedCell.cellIdx;
|
|
80
|
+
if (rowIdx === selectedRowIdx && selectedCellIdx === cellIdx) return;
|
|
81
|
+
_this.props.toggleRecords(cell, selectedCell);
|
|
82
|
+
};
|
|
83
|
+
_this.onClickTotals = function (recordsList, selectedCell) {
|
|
84
|
+
if (window.isMobile) return;
|
|
85
|
+
var rows = recordsList.flat();
|
|
86
|
+
var total = rows.length;
|
|
87
|
+
_this.toggleRecords({
|
|
88
|
+
rows: rows,
|
|
89
|
+
total: total
|
|
90
|
+
}, selectedCell);
|
|
91
|
+
};
|
|
92
|
+
_this.renderRows = function () {
|
|
93
|
+
var _this$props3 = _this.props,
|
|
94
|
+
result = _this$props3.result,
|
|
95
|
+
groupbyColumn = _this$props3.groupbyColumn,
|
|
96
|
+
selectedCell = _this$props3.selectedCell,
|
|
97
|
+
summaryColumn = _this$props3.summaryColumn,
|
|
98
|
+
summaryMethod = _this$props3.summaryMethod;
|
|
99
|
+
var pivot_rows = result.pivot_rows,
|
|
100
|
+
pivot_columns = result.pivot_columns,
|
|
101
|
+
pivot_columns_total = result.pivot_columns_total,
|
|
102
|
+
pivot_table_total = result.pivot_table_total;
|
|
103
|
+
var _ref4 = selectedCell || {},
|
|
104
|
+
selectRowIdx = _ref4.rowIdx,
|
|
105
|
+
selectedCellIdx = _ref4.cellIdx;
|
|
106
|
+
var pivotRowsLen = Array.isArray(pivot_rows) ? pivot_rows.length : 0;
|
|
107
|
+
var pivotColumnCells = [];
|
|
108
|
+
var isSelectRowTotalCellRight = selectRowIdx === pivotRowsLen && selectedCellIdx === 0;
|
|
109
|
+
var isSelectTotal = selectRowIdx === pivotRowsLen && selectedCellIdx === (Array.isArray(pivot_columns) ? pivot_columns.length : 0);
|
|
110
|
+
var tableTotalDisplayValue = StatisticsUtils.getSummaryValueDisplayString(summaryColumn, pivot_table_total, summaryMethod);
|
|
111
|
+
var isValidTableTotalDisplayValue = StatisticsUtils.isValidValue(tableTotalDisplayValue);
|
|
112
|
+
return /*#__PURE__*/React.createElement("tbody", null, pivotRowsLen > 0 && pivot_rows.map(function (rowItem, rowIdx) {
|
|
113
|
+
var name = rowItem.name,
|
|
114
|
+
total = rowItem.total;
|
|
115
|
+
var cells = _this.getCells(rowItem);
|
|
116
|
+
var isSelectedRowNameRight = selectRowIdx === rowIdx && selectedCellIdx === 0;
|
|
117
|
+
var pivotRowCells = [];
|
|
118
|
+
var isSelectedTotalCell = selectRowIdx === rowIdx && selectedCellIdx === cells.length;
|
|
119
|
+
var isSelectedTotalCellTop = selectRowIdx - 1 === rowIdx && selectedCellIdx === cells.length;
|
|
120
|
+
var isSelectedTotalCellLeft = selectRowIdx === rowIdx && selectedCellIdx - 1 === cells.length - 1;
|
|
121
|
+
if (!Array.isArray(pivot_columns)) {
|
|
122
|
+
pivotColumnCells[rowIdx] = rowItem.rows || [];
|
|
123
|
+
}
|
|
124
|
+
var summaryDisplayValue = StatisticsUtils.getSummaryValueDisplayString(summaryColumn, total, summaryMethod);
|
|
125
|
+
var isValidSummaryDisplayValue = StatisticsUtils.isValidValue(summaryDisplayValue);
|
|
126
|
+
return /*#__PURE__*/React.createElement("tr", {
|
|
127
|
+
key: 'table-row' + rowIdx
|
|
128
|
+
}, /*#__PURE__*/React.createElement("td", {
|
|
129
|
+
className: classnames('pivot-row-name', {
|
|
130
|
+
'selected-pivot-cell-left': isSelectedRowNameRight
|
|
131
|
+
})
|
|
132
|
+
}, /*#__PURE__*/React.createElement(PivotTableDisplayName, {
|
|
133
|
+
value: name,
|
|
134
|
+
column: groupbyColumn
|
|
135
|
+
})), Array.isArray(cells) && cells.map(function (c, cellIdx) {
|
|
136
|
+
var isSelectedCell = selectRowIdx === rowIdx && selectedCellIdx === cellIdx;
|
|
137
|
+
var isSelectedCellTop = selectRowIdx - 1 === rowIdx && selectedCellIdx === cellIdx;
|
|
138
|
+
var isSelectedCellLeft = selectRowIdx === rowIdx && selectedCellIdx - 1 === cellIdx;
|
|
139
|
+
var column = c.column,
|
|
140
|
+
total = c.total;
|
|
141
|
+
var displayValue = StatisticsUtils.getSummaryValueDisplayString(column, total, summaryMethod);
|
|
142
|
+
var isValidDisplayValue = StatisticsUtils.isValidValue(displayValue);
|
|
143
|
+
if (c && Array.isArray(c.rows) && c.rows.length > 0) {
|
|
144
|
+
pivotRowCells.push.apply(pivotRowCells, _toConsumableArray(c.rows));
|
|
145
|
+
if (pivotColumnCells[cellIdx]) {
|
|
146
|
+
var _pivotColumnCells$cel;
|
|
147
|
+
(_pivotColumnCells$cel = pivotColumnCells[cellIdx]).push.apply(_pivotColumnCells$cel, _toConsumableArray(c.rows));
|
|
148
|
+
} else {
|
|
149
|
+
pivotColumnCells[cellIdx] = _toConsumableArray(c.rows);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return /*#__PURE__*/React.createElement("td", {
|
|
153
|
+
className: classnames('pivot-cell', {
|
|
154
|
+
'pivot-empty-cell': !isValidDisplayValue,
|
|
155
|
+
'selected-pivot-cell': isSelectedCell,
|
|
156
|
+
'selected-pivot-cell-top': isSelectedCellTop,
|
|
157
|
+
'selected-pivot-cell-left': isSelectedCellLeft
|
|
158
|
+
}),
|
|
159
|
+
key: "table-cell-".concat(cellIdx)
|
|
160
|
+
// onClick={() => this.toggleRecords(c, {rowIdx, cellIdx})}
|
|
161
|
+
,
|
|
162
|
+
title: displayValue
|
|
163
|
+
}, isValidDisplayValue ? displayValue : /*#__PURE__*/React.createElement("i", null), /*#__PURE__*/React.createElement("span", {
|
|
164
|
+
className: classnames({
|
|
165
|
+
'selected-pivot-cell-border': isSelectedCell
|
|
166
|
+
})
|
|
167
|
+
}));
|
|
168
|
+
}), /*#__PURE__*/React.createElement("td", {
|
|
169
|
+
className: classnames('pivot-cell', {
|
|
170
|
+
'pivot-empty-cell': !isValidSummaryDisplayValue,
|
|
171
|
+
'selected-pivot-cell': isSelectedTotalCell,
|
|
172
|
+
'selected-pivot-cell-top': isSelectedTotalCellTop,
|
|
173
|
+
'selected-pivot-cell-left': isSelectedTotalCellLeft
|
|
174
|
+
})
|
|
175
|
+
// onClick={() => this.toggleRecords({ rows: Array.isArray(cells) && cells.length > 0 ? pivotRowCells : rowItem.rows, total: total }, { rowIdx, cellIdx: cells.length })}
|
|
176
|
+
,
|
|
177
|
+
title: summaryDisplayValue
|
|
178
|
+
}, isValidSummaryDisplayValue ? summaryDisplayValue : /*#__PURE__*/React.createElement("i", null), /*#__PURE__*/React.createElement("span", {
|
|
179
|
+
className: classnames({
|
|
180
|
+
'selected-pivot-cell-border': isSelectedTotalCell
|
|
181
|
+
})
|
|
182
|
+
})));
|
|
183
|
+
}), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
|
|
184
|
+
className: classnames('pivot-column-total', {
|
|
185
|
+
'selected-pivot-cell-left': isSelectRowTotalCellRight
|
|
186
|
+
})
|
|
187
|
+
}, /*#__PURE__*/React.createElement("div", null, intl.get('Total'))), Array.isArray(pivot_columns) && pivot_columns.map(function (c, index) {
|
|
188
|
+
// const pivotColumnCell = pivotColumnCells[index];
|
|
189
|
+
var isSelectRowTotalCell = selectRowIdx === pivot_rows.length && selectedCellIdx === index;
|
|
190
|
+
var isSelectRowTotalCellLeft = selectRowIdx === pivot_rows.length && selectedCellIdx - 1 === index;
|
|
191
|
+
var pivotColumnTotal = pivot_columns_total[c.key];
|
|
192
|
+
var totalDisplayValue = StatisticsUtils.getSummaryValueDisplayString(summaryColumn, pivotColumnTotal, summaryMethod);
|
|
193
|
+
var isValidTotalDisplayValue = StatisticsUtils.isValidValue(totalDisplayValue);
|
|
194
|
+
return /*#__PURE__*/React.createElement("td", {
|
|
195
|
+
className: classnames('pivot-cell', {
|
|
196
|
+
'pivot-empty-cell': !isValidTotalDisplayValue,
|
|
197
|
+
'selected-pivot-cell': isSelectRowTotalCell,
|
|
198
|
+
'selected-pivot-cell-left': isSelectRowTotalCellLeft
|
|
199
|
+
}),
|
|
200
|
+
key: "total-cell-".concat(index)
|
|
201
|
+
// onClick={() => this.toggleRecords({ rows: pivotColumnCell, total: pivot_columns_total[c.key] }, { rowIdx: pivot_rows.length, cellIdx: index })}
|
|
202
|
+
,
|
|
203
|
+
title: totalDisplayValue
|
|
204
|
+
}, isValidTotalDisplayValue ? totalDisplayValue : /*#__PURE__*/React.createElement("i", null), /*#__PURE__*/React.createElement("span", {
|
|
205
|
+
className: classnames({
|
|
206
|
+
'selected-pivot-cell-border': isSelectRowTotalCell
|
|
207
|
+
})
|
|
208
|
+
}));
|
|
209
|
+
}), /*#__PURE__*/React.createElement("td", {
|
|
210
|
+
className: classnames('pivot-cell pivot-table-total', {
|
|
211
|
+
'pivot-empty-cell': !isValidTableTotalDisplayValue,
|
|
212
|
+
'selected-pivot-cell': isSelectTotal
|
|
213
|
+
})
|
|
214
|
+
// onClick={() => this.onClickTotals(pivotColumnCells, {rowIdx: pivot_rows.length, cellIdx: Array.isArray(pivot_columns) ? pivot_columns.length : 0})}
|
|
215
|
+
}, isValidTableTotalDisplayValue ? tableTotalDisplayValue : /*#__PURE__*/React.createElement("i", null), /*#__PURE__*/React.createElement("span", {
|
|
216
|
+
className: classnames({
|
|
217
|
+
'selected-pivot-cell-border': isSelectTotal
|
|
218
|
+
})
|
|
219
|
+
}))));
|
|
220
|
+
};
|
|
221
|
+
return _this;
|
|
222
|
+
}
|
|
223
|
+
_createClass(TwoDimensionTable, [{
|
|
224
|
+
key: "render",
|
|
225
|
+
value: function render() {
|
|
226
|
+
var _this$props4 = this.props,
|
|
227
|
+
groupbyColumn = _this$props4.groupbyColumn,
|
|
228
|
+
columnGroupbyColumn = _this$props4.columnGroupbyColumn;
|
|
229
|
+
if (!groupbyColumn) return '';
|
|
230
|
+
return /*#__PURE__*/React.createElement("table", {
|
|
231
|
+
className: "seastatistic-pivot-table"
|
|
232
|
+
}, /*#__PURE__*/React.createElement("caption", {
|
|
233
|
+
className: "column-title"
|
|
234
|
+
}, columnGroupbyColumn.name), /*#__PURE__*/React.createElement("caption", {
|
|
235
|
+
className: "row-title"
|
|
236
|
+
}, groupbyColumn.name), this.renderHeader(), this.renderRows());
|
|
237
|
+
}
|
|
238
|
+
}]);
|
|
239
|
+
return TwoDimensionTable;
|
|
240
|
+
}(PureComponent);
|
|
241
|
+
export default TwoDimensionTable;
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
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 from 'react';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import DataSet from '@antv/data-set';
|
|
9
|
+
import { each, pick } from '@antv/util';
|
|
10
|
+
import { getEllipsisText } from '@antv/g2/esm/util/text';
|
|
11
|
+
import { STATISTIC_SUMMARY_TYPE, EMPTY_NAME } from '../../constants';
|
|
12
|
+
import { StatisticsUtils } from '../../utils';
|
|
13
|
+
import { registerGeometryLabelLayout } from '../../utils/custom-g2';
|
|
14
|
+
import ChartComponent from './chart-component';
|
|
15
|
+
import intl from '../../intl';
|
|
16
|
+
var Treemap = /*#__PURE__*/function (_ChartComponent) {
|
|
17
|
+
_inherits(Treemap, _ChartComponent);
|
|
18
|
+
var _super = _createSuper(Treemap);
|
|
19
|
+
function Treemap(props) {
|
|
20
|
+
var _this;
|
|
21
|
+
_classCallCheck(this, Treemap);
|
|
22
|
+
_this = _super.call(this, props);
|
|
23
|
+
// customize label layout: show ellipsis for long labels
|
|
24
|
+
_this.limitInShape = function (items, labels, shapes, region) {
|
|
25
|
+
each(labels, function (label, index) {
|
|
26
|
+
var labelBBox = label.getCanvasBBox();
|
|
27
|
+
var shapeBBox = shapes[index].getBBox();
|
|
28
|
+
if (labelBBox.minX < shapeBBox.minX || labelBBox.minY < shapeBBox.minY || labelBBox.maxX > shapeBBox.maxX || labelBBox.maxY > shapeBBox.maxY) {
|
|
29
|
+
var translateX = labelBBox.width - shapeBBox.width + 20;
|
|
30
|
+
var textShapes = label.findAll(function (shape) {
|
|
31
|
+
return shape.get('type') === 'text';
|
|
32
|
+
});
|
|
33
|
+
textShapes.forEach(function (textShape) {
|
|
34
|
+
var style = pick(textShape.attr(), ['fontSize', 'fontFamily', 'fontWeight', 'fontStyle', 'fontVariant']);
|
|
35
|
+
var textBox = textShape.getCanvasBBox();
|
|
36
|
+
var text = getEllipsisText(textShape.attr('text'), textBox.width - Math.abs(translateX), style);
|
|
37
|
+
textShape.attr('text', text);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
_this.createChart = function () {
|
|
43
|
+
var canvasStyle = _this.props.canvasStyle;
|
|
44
|
+
_this.initChart(_this.container, canvasStyle, 0);
|
|
45
|
+
};
|
|
46
|
+
_this.destroyChart = function () {
|
|
47
|
+
_this.chart.destroy();
|
|
48
|
+
_this.chart = null;
|
|
49
|
+
};
|
|
50
|
+
_this.clearChart = function () {
|
|
51
|
+
_this.chart.annotation().clear(true);
|
|
52
|
+
_this.chart.clear(true);
|
|
53
|
+
};
|
|
54
|
+
_this.drawChart = function () {
|
|
55
|
+
var _this$props = _this.props,
|
|
56
|
+
data = _this$props.result,
|
|
57
|
+
statistic = _this$props.statistic,
|
|
58
|
+
tables = _this$props.tables,
|
|
59
|
+
summaryColumn = _this$props.summaryColumn;
|
|
60
|
+
var _statistic$config = statistic.config,
|
|
61
|
+
summary_type = _statistic$config.summary_type,
|
|
62
|
+
summary_method = _statistic$config.summary_method;
|
|
63
|
+
var _StatisticsUtils$form = StatisticsUtils.formatPieChartData(data, statistic, tables),
|
|
64
|
+
newData = _StatisticsUtils$form.data,
|
|
65
|
+
colorSet = _StatisticsUtils$form.colorSet;
|
|
66
|
+
if (!Array.isArray(newData)) return;
|
|
67
|
+
var DataView = DataSet.DataView;
|
|
68
|
+
var dv = new DataView();
|
|
69
|
+
var fullData = {
|
|
70
|
+
name: 'root',
|
|
71
|
+
children: newData.map(function (item) {
|
|
72
|
+
var name = item.name;
|
|
73
|
+
item.name = name || name === 0 ? name : intl.get(EMPTY_NAME);
|
|
74
|
+
if (name === '_Others') {
|
|
75
|
+
item.name = intl.get('Others');
|
|
76
|
+
}
|
|
77
|
+
return item;
|
|
78
|
+
})
|
|
79
|
+
};
|
|
80
|
+
dv.source(fullData, {
|
|
81
|
+
type: 'hierarchy'
|
|
82
|
+
}).transform({
|
|
83
|
+
field: 'value',
|
|
84
|
+
type: 'hierarchy.treemap',
|
|
85
|
+
tile: 'treemapResquarify',
|
|
86
|
+
as: ['x', 'y']
|
|
87
|
+
});
|
|
88
|
+
var nodes = [];
|
|
89
|
+
var _iterator = _createForOfIteratorHelper(dv.getAllNodes()),
|
|
90
|
+
_step;
|
|
91
|
+
try {
|
|
92
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
93
|
+
var node = _step.value;
|
|
94
|
+
if (node.data.name === 'root') {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
var eachNode = {
|
|
98
|
+
name: node.data.name,
|
|
99
|
+
x: node.x,
|
|
100
|
+
y: node.y,
|
|
101
|
+
value: node.data.value,
|
|
102
|
+
percent: node.data.percent,
|
|
103
|
+
original_name: node.data.original_name,
|
|
104
|
+
rows: node.data.rows || null
|
|
105
|
+
};
|
|
106
|
+
nodes.push(eachNode);
|
|
107
|
+
}
|
|
108
|
+
} catch (err) {
|
|
109
|
+
_iterator.e(err);
|
|
110
|
+
} finally {
|
|
111
|
+
_iterator.f();
|
|
112
|
+
}
|
|
113
|
+
_this.chart.data(nodes);
|
|
114
|
+
_this.chart.scale({
|
|
115
|
+
x: {
|
|
116
|
+
nice: true
|
|
117
|
+
},
|
|
118
|
+
y: {
|
|
119
|
+
nice: true
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
_this.chart.axis(false);
|
|
123
|
+
_this.chart.legend(false);
|
|
124
|
+
_this.chart.tooltip({
|
|
125
|
+
showTitle: false,
|
|
126
|
+
showMarkers: false,
|
|
127
|
+
containerTpl: '<div class="g2-tooltip"><div class="g2-tooltip-list"></div></div>',
|
|
128
|
+
itemTpl: '<div class="g2-tooltip-content"><div class="tooltip-name">{name}<div><div class="tooltip-item">{info}<div></div>',
|
|
129
|
+
domStyles: {
|
|
130
|
+
'g2-tooltip': {
|
|
131
|
+
borderRadius: '2px',
|
|
132
|
+
backgroundColor: '#fff',
|
|
133
|
+
padding: '10px'
|
|
134
|
+
},
|
|
135
|
+
'tooltip-item': {
|
|
136
|
+
marginTop: '5px'
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
_this.chart.polygon().position('x*y').color('name', colorSet).tooltip('name*value*percent', function (name, value, percent) {
|
|
141
|
+
var displayValue = StatisticsUtils.getSummaryValueDisplayString(summaryColumn, value, summary_method);
|
|
142
|
+
return {
|
|
143
|
+
name: name,
|
|
144
|
+
info: summary_type === STATISTIC_SUMMARY_TYPE.COUNT ? "".concat(value) : "".concat(summaryColumn.name, ": ").concat(displayValue, " (").concat(percent, ")")
|
|
145
|
+
};
|
|
146
|
+
}).style({
|
|
147
|
+
lineWidth: 1,
|
|
148
|
+
stroke: '#fff'
|
|
149
|
+
}).label('name', {
|
|
150
|
+
offset: 0,
|
|
151
|
+
style: {
|
|
152
|
+
textBaseline: 'middle'
|
|
153
|
+
},
|
|
154
|
+
content: function content(obj) {
|
|
155
|
+
if (obj.name !== 'root') {
|
|
156
|
+
return obj.name;
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
layout: {
|
|
160
|
+
type: 'custom-limit-in-shape'
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
_this.chart.interaction('statistic-active');
|
|
164
|
+
_this.chart.render();
|
|
165
|
+
};
|
|
166
|
+
_this.chart = null;
|
|
167
|
+
registerGeometryLabelLayout('custom-limit-in-shape', _this.limitInShape);
|
|
168
|
+
return _this;
|
|
169
|
+
}
|
|
170
|
+
_createClass(Treemap, [{
|
|
171
|
+
key: "componentDidMount",
|
|
172
|
+
value: function componentDidMount() {
|
|
173
|
+
this.createChart();
|
|
174
|
+
this.drawChart();
|
|
175
|
+
}
|
|
176
|
+
}, {
|
|
177
|
+
key: "componentDidUpdate",
|
|
178
|
+
value: function componentDidUpdate(prevProps) {
|
|
179
|
+
if (StatisticsUtils.shouldChartComponentUpdate(prevProps, this.props)) {
|
|
180
|
+
this.chart && this.destroyChart();
|
|
181
|
+
this.createChart();
|
|
182
|
+
this.drawChart();
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}, {
|
|
186
|
+
key: "componentWillUnmount",
|
|
187
|
+
value: function componentWillUnmount() {
|
|
188
|
+
this.chart && this.destroyChart();
|
|
189
|
+
}
|
|
190
|
+
}, {
|
|
191
|
+
key: "render",
|
|
192
|
+
value: function render() {
|
|
193
|
+
var _this2 = this;
|
|
194
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
195
|
+
className: "seastatistic-container w-100",
|
|
196
|
+
ref: function ref(_ref) {
|
|
197
|
+
return _this2.container = _ref;
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
}]);
|
|
202
|
+
return Treemap;
|
|
203
|
+
}(ChartComponent);
|
|
204
|
+
Treemap.propTypes = {
|
|
205
|
+
canvasStyle: PropTypes.object,
|
|
206
|
+
statistic: PropTypes.object,
|
|
207
|
+
groupbyColumn: PropTypes.object,
|
|
208
|
+
summaryColumn: PropTypes.object,
|
|
209
|
+
result: PropTypes.array,
|
|
210
|
+
tables: PropTypes.array,
|
|
211
|
+
theme: PropTypes.object
|
|
212
|
+
};
|
|
213
|
+
export default Treemap;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './index.css';
|
|
3
|
+
var importAll = function importAll(requireContext) {
|
|
4
|
+
requireContext.keys().forEach(requireContext);
|
|
5
|
+
};
|
|
6
|
+
try {
|
|
7
|
+
importAll(require.context('../../assets/icons', true, /\.svg$/));
|
|
8
|
+
} catch (error) {
|
|
9
|
+
// eslint-disable-next-line no-console
|
|
10
|
+
console.log(error);
|
|
11
|
+
}
|
|
12
|
+
var Icon = function Icon(props) {
|
|
13
|
+
var className = props.className,
|
|
14
|
+
symbol = props.symbol;
|
|
15
|
+
var iconClass = "seastatistic-icon seastatistic-icon-".concat(symbol, " ").concat(className || '');
|
|
16
|
+
return /*#__PURE__*/React.createElement("svg", {
|
|
17
|
+
className: iconClass
|
|
18
|
+
}, /*#__PURE__*/React.createElement("use", {
|
|
19
|
+
xlinkHref: "#".concat(symbol)
|
|
20
|
+
}));
|
|
21
|
+
};
|
|
22
|
+
export default Icon;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** loading **/
|
|
2
|
+
@-moz-keyframes loading {
|
|
3
|
+
0% {
|
|
4
|
+
-moz-transform: rotate(0deg);
|
|
5
|
+
transform: rotate(0deg);
|
|
6
|
+
}
|
|
7
|
+
100% {
|
|
8
|
+
-moz-transform: rotate(360deg);
|
|
9
|
+
transform: rotate(360deg);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@-webkit-keyframes loading {
|
|
14
|
+
0% {
|
|
15
|
+
-webkit-transform: rotate(0deg);
|
|
16
|
+
transform: rotate(0deg);
|
|
17
|
+
}
|
|
18
|
+
100% {
|
|
19
|
+
-webkit-transform: rotate(360deg);
|
|
20
|
+
transform: rotate(360deg);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@keyframes loading {
|
|
25
|
+
0% {
|
|
26
|
+
-moz-transform: rotate(0deg);
|
|
27
|
+
-ms-transform: rotate(0deg);
|
|
28
|
+
-webkit-transform: rotate(0deg);
|
|
29
|
+
transform: rotate(0deg);
|
|
30
|
+
}
|
|
31
|
+
100% {
|
|
32
|
+
-moz-transform: rotate(360deg);
|
|
33
|
+
-ms-transform: rotate(360deg);
|
|
34
|
+
-webkit-transform: rotate(360deg);
|
|
35
|
+
transform: rotate(360deg);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.loading-icon {
|
|
40
|
+
display: inline-block;
|
|
41
|
+
width: 20px;
|
|
42
|
+
height: 20px;
|
|
43
|
+
border: 2px solid #eee;
|
|
44
|
+
border-left-color: #aaa;
|
|
45
|
+
border-radius: 50%;
|
|
46
|
+
-moz-animation: loading 0.9s infinite linear;
|
|
47
|
+
-webkit-animation: loading 0.9s infinite linear;
|
|
48
|
+
animation: loading 0.9s infinite linear;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.loading-tip {
|
|
52
|
+
display: block;
|
|
53
|
+
margin: 0 auto;
|
|
54
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classnames from 'classnames';
|
|
3
|
+
import './index.css';
|
|
4
|
+
var Loading = function Loading(_ref) {
|
|
5
|
+
var className = _ref.className;
|
|
6
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
7
|
+
className: classnames('loading-icon loading-tip', className)
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
export default Loading;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
|
+
var _excluded = ["value", "onChange", "min", "step", "max", "readOnly", "className"];
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Input } from 'reactstrap';
|
|
5
|
+
function NumberInput(props) {
|
|
6
|
+
var value = props.value,
|
|
7
|
+
onChange = props.onChange,
|
|
8
|
+
min = props.min,
|
|
9
|
+
step = props.step,
|
|
10
|
+
max = props.max,
|
|
11
|
+
readOnly = props.readOnly,
|
|
12
|
+
className = props.className,
|
|
13
|
+
otherProps = _objectWithoutProperties(props, _excluded);
|
|
14
|
+
return /*#__PURE__*/React.createElement(Input, Object.assign({
|
|
15
|
+
type: "number",
|
|
16
|
+
className: className,
|
|
17
|
+
value: value || '0',
|
|
18
|
+
min: min,
|
|
19
|
+
step: step,
|
|
20
|
+
max: max,
|
|
21
|
+
readOnly: readOnly,
|
|
22
|
+
onChange: onChange
|
|
23
|
+
}, otherProps));
|
|
24
|
+
}
|
|
25
|
+
NumberInput.defaultProps = {
|
|
26
|
+
min: 0,
|
|
27
|
+
step: 1,
|
|
28
|
+
max: Infinity,
|
|
29
|
+
readOnly: false
|
|
30
|
+
};
|
|
31
|
+
export default NumberInput;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
.seastatistic-pixel-editor-wrapper {
|
|
2
|
+
display: flex;
|
|
3
|
+
width: 100%;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.seastatistic-pixel-editor-wrapper .form-control {
|
|
7
|
+
position: relative;
|
|
8
|
+
flex: 1;
|
|
9
|
+
border-top-right-radius: 0;
|
|
10
|
+
border-bottom-right-radius: 0;
|
|
11
|
+
z-index: 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.seastatistic-pixel-editor-wrapper .pixel-unit {
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
justify-content: center;
|
|
18
|
+
height: 2.375rem;
|
|
19
|
+
width: 2.375rem;
|
|
20
|
+
border: 1px solid rgba(0, 40, 100, 0.12);
|
|
21
|
+
border-left: none;
|
|
22
|
+
border-top-right-radius: 3px;
|
|
23
|
+
border-bottom-right-radius: 3px;
|
|
24
|
+
background-color: #fff;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.seastatistic-pixel-editor-wrapper .pixel-unit span {
|
|
28
|
+
margin-top: -2px;
|
|
29
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { isNumber } from 'dtable-utils';
|
|
4
|
+
import NumberInput from '../number-input';
|
|
5
|
+
import './index.css';
|
|
6
|
+
var PixelEditor = function PixelEditor(props) {
|
|
7
|
+
var pixel = props.pixel;
|
|
8
|
+
var _useState = useState(isNumber(pixel) ? pixel : null),
|
|
9
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
10
|
+
currPixel = _useState2[0],
|
|
11
|
+
setCurrPixel = _useState2[1];
|
|
12
|
+
var mountRef = useRef(false);
|
|
13
|
+
useEffect(function () {
|
|
14
|
+
if (!mountRef.current) {
|
|
15
|
+
mountRef.current = true;
|
|
16
|
+
} else {
|
|
17
|
+
setCurrPixel(isNumber(props.pixel) ? props.pixel : null);
|
|
18
|
+
}
|
|
19
|
+
}, [props.pixel]);
|
|
20
|
+
var onSavePixel = function onSavePixel() {
|
|
21
|
+
props.modifyPixel(currPixel);
|
|
22
|
+
};
|
|
23
|
+
var onKeyDown = function onKeyDown(event) {
|
|
24
|
+
if (event.key === 'Enter') {
|
|
25
|
+
event.preventDefault();
|
|
26
|
+
event.target.blur();
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
30
|
+
className: "seastatistic-pixel-editor-wrapper"
|
|
31
|
+
}, /*#__PURE__*/React.createElement(NumberInput, {
|
|
32
|
+
value: currPixel,
|
|
33
|
+
onChange: function onChange(event) {
|
|
34
|
+
return setCurrPixel(event.target.value);
|
|
35
|
+
},
|
|
36
|
+
onBlur: onSavePixel,
|
|
37
|
+
onKeyDown: onKeyDown
|
|
38
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
39
|
+
className: "pixel-unit"
|
|
40
|
+
}, /*#__PURE__*/React.createElement("span", null, "px")));
|
|
41
|
+
};
|
|
42
|
+
export default PixelEditor;
|