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.
Files changed (214) hide show
  1. package/README.md +4 -0
  2. package/lib/assets/icons/area-chart.svg +10 -0
  3. package/lib/assets/icons/bar-chart.svg +12 -0
  4. package/lib/assets/icons/card.svg +22 -0
  5. package/lib/assets/icons/combination-chart.svg +17 -0
  6. package/lib/assets/icons/dtable-logo.svg +16 -0
  7. package/lib/assets/icons/facet-chart.svg +12 -0
  8. package/lib/assets/icons/gauge.svg +18 -0
  9. package/lib/assets/icons/heat-map.svg +14 -0
  10. package/lib/assets/icons/histogram.svg +12 -0
  11. package/lib/assets/icons/line-chart.svg +12 -0
  12. package/lib/assets/icons/map.svg +20 -0
  13. package/lib/assets/icons/pie-chart.svg +11 -0
  14. package/lib/assets/icons/rectangular-tree-diagram.svg +10 -0
  15. package/lib/assets/icons/scatter-chart.svg +15 -0
  16. package/lib/assets/icons/type-change.svg +17 -0
  17. package/lib/assets/img/area-chart.png +0 -0
  18. package/lib/assets/img/area-group-chart.png +0 -0
  19. package/lib/assets/img/bar-group.png +0 -0
  20. package/lib/assets/img/bar-stack.png +0 -0
  21. package/lib/assets/img/bar.png +0 -0
  22. package/lib/assets/img/combination-chart.png +0 -0
  23. package/lib/assets/img/compared-chart.png +0 -0
  24. package/lib/assets/img/completeness-chart.png +0 -0
  25. package/lib/assets/img/custom-bar.png +0 -0
  26. package/lib/assets/img/dashboard-chart.png +0 -0
  27. package/lib/assets/img/group-completeness-chart.png +0 -0
  28. package/lib/assets/img/group_line.png +0 -0
  29. package/lib/assets/img/heat-map.png +0 -0
  30. package/lib/assets/img/horizontal-bar.png +0 -0
  31. package/lib/assets/img/horizontal-group-bar.png +0 -0
  32. package/lib/assets/img/line.png +0 -0
  33. package/lib/assets/img/map-bubble.png +0 -0
  34. package/lib/assets/img/map.png +0 -0
  35. package/lib/assets/img/mirror.png +0 -0
  36. package/lib/assets/img/number-card.png +0 -0
  37. package/lib/assets/img/pie.png +0 -0
  38. package/lib/assets/img/pivot-table.png +0 -0
  39. package/lib/assets/img/ring.png +0 -0
  40. package/lib/assets/img/scatter.png +0 -0
  41. package/lib/assets/img/stacked-horizontal-bar.png +0 -0
  42. package/lib/assets/img/treemap.png +0 -0
  43. package/lib/assets/img/trend-chart.png +0 -0
  44. package/lib/assets/img/world-map-bubble.png +0 -0
  45. package/lib/assets/img/world-map.png +0 -0
  46. package/lib/components/collaborator/index.js +24 -0
  47. package/lib/components/formatter/area.js +162 -0
  48. package/lib/components/formatter/bar-group.js +160 -0
  49. package/lib/components/formatter/bar.js +150 -0
  50. package/lib/components/formatter/basic-number-card.js +138 -0
  51. package/lib/components/formatter/chart-component.js +266 -0
  52. package/lib/components/formatter/combination.js +407 -0
  53. package/lib/components/formatter/dashboard.js +182 -0
  54. package/lib/components/formatter/horizontal-bar-group.js +161 -0
  55. package/lib/components/formatter/horizontal-bar.js +152 -0
  56. package/lib/components/formatter/horizontal-component.js +91 -0
  57. package/lib/components/formatter/index.js +181 -0
  58. package/lib/components/formatter/line-group.js +157 -0
  59. package/lib/components/formatter/line.js +170 -0
  60. package/lib/components/formatter/pie.js +201 -0
  61. package/lib/components/formatter/ring.js +277 -0
  62. package/lib/components/formatter/table/index.css +103 -0
  63. package/lib/components/formatter/table/index.js +42 -0
  64. package/lib/components/formatter/table/one-dimension-table-no-numeric-columns.js +145 -0
  65. package/lib/components/formatter/table/one-dimension-table-with-numeric-columns.js +193 -0
  66. package/lib/components/formatter/table/pivot-table-display-name.js +249 -0
  67. package/lib/components/formatter/table/two-dimension-table.js +241 -0
  68. package/lib/components/formatter/treemap.js +213 -0
  69. package/lib/components/icon/index.css +5 -0
  70. package/lib/components/icon/index.js +22 -0
  71. package/lib/components/index.js +5 -0
  72. package/lib/components/loading/index.css +54 -0
  73. package/lib/components/loading/index.js +10 -0
  74. package/lib/components/number-input/index.js +31 -0
  75. package/lib/components/pixel-editor/index.css +29 -0
  76. package/lib/components/pixel-editor/index.js +42 -0
  77. package/lib/components/select-group/index.css +67 -0
  78. package/lib/components/select-group/index.js +63 -0
  79. package/lib/components/settings/advance-bar-settings/data-settings.js +120 -0
  80. package/lib/components/settings/advance-bar-settings/index.js +3 -0
  81. package/lib/components/settings/advance-bar-settings/style-settings.js +149 -0
  82. package/lib/components/settings/bar-settings/data-settings.js +137 -0
  83. package/lib/components/settings/bar-settings/index.js +3 -0
  84. package/lib/components/settings/bar-settings/style-settings.js +163 -0
  85. package/lib/components/settings/basic-number-card/data-settings.js +121 -0
  86. package/lib/components/settings/basic-number-card/index.js +3 -0
  87. package/lib/components/settings/basic-number-card/style-settings.js +42 -0
  88. package/lib/components/settings/combination-settings/data-settings.js +256 -0
  89. package/lib/components/settings/combination-settings/index.js +3 -0
  90. package/lib/components/settings/combination-settings/style-settings.js +183 -0
  91. package/lib/components/settings/dashboard-settings/data-settings.js +167 -0
  92. package/lib/components/settings/dashboard-settings/index.js +2 -0
  93. package/lib/components/settings/data-settings.js +67 -0
  94. package/lib/components/settings/horizontal-bar-settings/data-settings.js +45 -0
  95. package/lib/components/settings/horizontal-bar-settings/index.js +3 -0
  96. package/lib/components/settings/horizontal-bar-settings/style-settings.js +38 -0
  97. package/lib/components/settings/index.css +73 -0
  98. package/lib/components/settings/index.js +74 -0
  99. package/lib/components/settings/pie-settings/data-settings.js +123 -0
  100. package/lib/components/settings/pie-settings/index.js +3 -0
  101. package/lib/components/settings/pie-settings/style-settings.js +123 -0
  102. package/lib/components/settings/style-settings.js +100 -0
  103. package/lib/components/settings/table-settings/data-settings.js +488 -0
  104. package/lib/components/settings/table-settings/index.js +2 -0
  105. package/lib/components/settings/time-comparison-settings/data-settings.js +157 -0
  106. package/lib/components/settings/time-comparison-settings/index.js +3 -0
  107. package/lib/components/settings/time-comparison-settings/style-settings.js +191 -0
  108. package/lib/components/settings/widgets/basic-summary/index.css +12 -0
  109. package/lib/components/settings/widgets/basic-summary/index.js +173 -0
  110. package/lib/components/settings/widgets/common-data-settings.js +42 -0
  111. package/lib/components/settings/widgets/data-filter/index.css +17 -0
  112. package/lib/components/settings/widgets/data-filter/index.js +76 -0
  113. package/lib/components/settings/widgets/data-sort.js +38 -0
  114. package/lib/components/settings/widgets/date-summary-item.js +126 -0
  115. package/lib/components/settings/widgets/display-values-settings/index.css +13 -0
  116. package/lib/components/settings/widgets/display-values-settings/index.js +37 -0
  117. package/lib/components/settings/widgets/divider/index.css +4 -0
  118. package/lib/components/settings/widgets/divider/index.js +10 -0
  119. package/lib/components/settings/widgets/font-settings/font-size-settings.js +31 -0
  120. package/lib/components/settings/widgets/font-settings/font-weight-settings.js +46 -0
  121. package/lib/components/settings/widgets/font-settings/index.js +3 -0
  122. package/lib/components/settings/widgets/group-by.js +168 -0
  123. package/lib/components/settings/widgets/label-color.js +30 -0
  124. package/lib/components/settings/widgets/min-max-setting.js +64 -0
  125. package/lib/components/settings/widgets/mininum-slice-percent.js +72 -0
  126. package/lib/components/settings/widgets/numeric-summary-item.js +109 -0
  127. package/lib/components/settings/widgets/select-table/index.css +0 -0
  128. package/lib/components/settings/widgets/select-table/index.js +49 -0
  129. package/lib/components/settings/widgets/stack.js +58 -0
  130. package/lib/components/settings/widgets/statistic-type/index.css +31 -0
  131. package/lib/components/settings/widgets/statistic-type/index.js +54 -0
  132. package/lib/components/settings/widgets/summary-method-setting.js +80 -0
  133. package/lib/components/settings/widgets/summary-settings.js +394 -0
  134. package/lib/components/settings/widgets/switch/index.css +37 -0
  135. package/lib/components/settings/widgets/switch/index.js +21 -0
  136. package/lib/components/settings/widgets/text-horizontal-settings.js +23 -0
  137. package/lib/components/settings/widgets/time-picker.js +182 -0
  138. package/lib/components/settings/widgets/title-settings/index.js +58 -0
  139. package/lib/components/settings/widgets/title-settings/title-text.js +31 -0
  140. package/lib/components/settings/widgets/x-axios.js +0 -0
  141. package/lib/components/settings/widgets/y-axis-group-settings.js +399 -0
  142. package/lib/components/types-dialog/index.css +97 -0
  143. package/lib/components/types-dialog/index.js +127 -0
  144. package/lib/constants/geolocation.js +11 -0
  145. package/lib/constants/index.js +164 -0
  146. package/lib/constants/model.js +167 -0
  147. package/lib/constants/style.js +13 -0
  148. package/lib/constants/type-image.js +32 -0
  149. package/lib/constants/type.js +97 -0
  150. package/lib/context.js +49 -0
  151. package/lib/index.js +6 -0
  152. package/lib/intl.js +37 -0
  153. package/lib/layout/index.js +4 -0
  154. package/lib/layout/statistic/index.css +53 -0
  155. package/lib/layout/statistic/index.js +190 -0
  156. package/lib/layout/title/index.css +3 -0
  157. package/lib/layout/title/index.js +41 -0
  158. package/lib/locale/index.js +11 -0
  159. package/lib/locale/lang/de.js +141 -0
  160. package/lib/locale/lang/en.js +143 -0
  161. package/lib/locale/lang/es.js +141 -0
  162. package/lib/locale/lang/fr.js +141 -0
  163. package/lib/locale/lang/pt.js +141 -0
  164. package/lib/locale/lang/ru.js +141 -0
  165. package/lib/locale/lang/zh_CN.js +143 -0
  166. package/lib/model/area-group.js +51 -0
  167. package/lib/model/area.js +42 -0
  168. package/lib/model/bar-group.js +54 -0
  169. package/lib/model/bar-stack.js +51 -0
  170. package/lib/model/bar.js +48 -0
  171. package/lib/model/base-model.js +11 -0
  172. package/lib/model/basic-number-card.js +32 -0
  173. package/lib/model/combination.js +48 -0
  174. package/lib/model/compare-bar.js +49 -0
  175. package/lib/model/completeness-group.js +34 -0
  176. package/lib/model/completeness.js +28 -0
  177. package/lib/model/dashboard.js +26 -0
  178. package/lib/model/generic-model.js +235 -0
  179. package/lib/model/heat-map.js +33 -0
  180. package/lib/model/horizontal-bar.js +48 -0
  181. package/lib/model/horizontal-group-bar.js +53 -0
  182. package/lib/model/index.js +36 -0
  183. package/lib/model/line-group.js +54 -0
  184. package/lib/model/line.js +48 -0
  185. package/lib/model/map-bubble.js +37 -0
  186. package/lib/model/map.js +37 -0
  187. package/lib/model/mirror.js +36 -0
  188. package/lib/model/pie.js +36 -0
  189. package/lib/model/ring.js +36 -0
  190. package/lib/model/scatter.js +29 -0
  191. package/lib/model/stacked-horizontal-bar.js +42 -0
  192. package/lib/model/statistic.js +22 -0
  193. package/lib/model/table.js +33 -0
  194. package/lib/model/tree-map.js +30 -0
  195. package/lib/model/trend.js +34 -0
  196. package/lib/model/user.js +22 -0
  197. package/lib/model/world-map-bubble.js +36 -0
  198. package/lib/model/world-map.js +36 -0
  199. package/lib/utils/cell-format-utils.js +41 -0
  200. package/lib/utils/chart.js +6 -0
  201. package/lib/utils/collaborator-utils.js +40 -0
  202. package/lib/utils/column-utils.js +247 -0
  203. package/lib/utils/custom-g2.js +612 -0
  204. package/lib/utils/data-filter/filter-item-utils.js +80 -0
  205. package/lib/utils/data-filter/filters-utils.js +406 -0
  206. package/lib/utils/data-filter/index.js +3 -0
  207. package/lib/utils/date-translate.js +66 -0
  208. package/lib/utils/index.js +50 -0
  209. package/lib/utils/key-generator.js +13 -0
  210. package/lib/utils/object-utils.js +61 -0
  211. package/lib/utils/options-utils.js +61 -0
  212. package/lib/utils/statistic-column-2-sql-column-utils.js +499 -0
  213. package/lib/utils/statistic-utils.js +1685 -0
  214. package/package.json +160 -0
@@ -0,0 +1,145 @@
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, { PureComponent } from 'react';
6
+ import classnames from 'classnames';
7
+ import PivotTableDisplayName from './pivot-table-display-name';
8
+ import { StatisticsUtils, ObjectUtils } from '../../../utils';
9
+ import intl from '../../../intl';
10
+ var OneDimensionTableNoNumericColumns = /*#__PURE__*/function (_PureComponent) {
11
+ _inherits(OneDimensionTableNoNumericColumns, _PureComponent);
12
+ var _super = _createSuper(OneDimensionTableNoNumericColumns);
13
+ function OneDimensionTableNoNumericColumns() {
14
+ var _this;
15
+ _classCallCheck(this, OneDimensionTableNoNumericColumns);
16
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
17
+ args[_key] = arguments[_key];
18
+ }
19
+ _this = _super.call.apply(_super, [this].concat(args));
20
+ _this.renderHeader = function () {
21
+ var _this$props = _this.props,
22
+ groupbyColumn = _this$props.groupbyColumn,
23
+ selectedCell = _this$props.selectedCell;
24
+ var groupName = groupbyColumn.name;
25
+ var _ref = selectedCell || {},
26
+ selectRowIdx = _ref.rowIdx,
27
+ selectedCellIdx = _ref.cellIdx;
28
+ var isSelectedTotalCellBottom = selectRowIdx === 0 && selectedCellIdx === 0;
29
+ return /*#__PURE__*/React.createElement("thead", {
30
+ className: "seatable-table-header-sm"
31
+ }, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
32
+ className: "pivot-table-header"
33
+ }, groupName), /*#__PURE__*/React.createElement("th", {
34
+ className: classnames('pivot-table-header', {
35
+ 'selected-pivot-cell-top': isSelectedTotalCellBottom
36
+ })
37
+ }, /*#__PURE__*/React.createElement("div", null, intl.get('Total')))));
38
+ };
39
+ _this.toggleRecords = function (cell, selectedCell) {
40
+ if (window.isMobile) return;
41
+ var _ref2 = _this.props.selectedCell || {},
42
+ selectedRowIdx = _ref2.rowIdx,
43
+ selectedCellIdx = _ref2.cellIdx;
44
+ var rowIdx = selectedCell.rowIdx,
45
+ cellIdx = selectedCell.cellIdx;
46
+ if (rowIdx === selectedRowIdx && selectedCellIdx === cellIdx) return;
47
+ _this.props.toggleRecords(cell, selectedCell);
48
+ };
49
+ _this.onClickTotals = function (recordsList, selectedCell) {
50
+ if (window.isMobile) return;
51
+ var rows = recordsList.flat();
52
+ var total = rows.length;
53
+ _this.toggleRecords({
54
+ rows: rows,
55
+ total: total
56
+ }, selectedCell);
57
+ };
58
+ _this.renderRows = function () {
59
+ var _this$props2 = _this.props,
60
+ result = _this$props2.result,
61
+ groupbyColumn = _this$props2.groupbyColumn,
62
+ selectedCell = _this$props2.selectedCell,
63
+ summaryColumn = _this$props2.summaryColumn;
64
+ var pivot_rows = result.pivot_rows,
65
+ pivot_columns_total = result.pivot_columns_total;
66
+ var _ref3 = selectedCell || {},
67
+ selectRowIdx = _ref3.rowIdx,
68
+ selectedCellIdx = _ref3.cellIdx;
69
+ var pivotRowsLen = Array.isArray(pivot_rows) ? pivot_rows.length : 0;
70
+ var pivotColumnCells = [];
71
+ var isSelectRowTotalCellRight = selectRowIdx === pivotRowsLen && selectedCellIdx === 0;
72
+ var isSelectTotal = selectRowIdx === pivotRowsLen && selectedCellIdx === 0;
73
+ // eslint-disable-next-line
74
+ var total = ObjectUtils.hasOwnProperty(pivot_columns_total, 'total') ? pivot_columns_total['total'] : 0;
75
+ var summaryDisplayValue = StatisticsUtils.getSummaryValueDisplayString(summaryColumn, total);
76
+ var isValidSummaryDisplayValue = StatisticsUtils.isValidValue(summaryDisplayValue);
77
+ return /*#__PURE__*/React.createElement("tbody", null, pivotRowsLen > 0 && pivot_rows.map(function (rowItem, rowIdx) {
78
+ var name = rowItem.name,
79
+ total = rowItem.total,
80
+ rows = rowItem.rows;
81
+ var isSelectedRowNameRight = selectRowIdx === rowIdx && selectedCellIdx === 0;
82
+ // let pivotRowCells = [];
83
+ var isSelectedTotalCell = selectRowIdx === rowIdx && selectedCellIdx === 0;
84
+ var isSelectedTotalCellTop = selectRowIdx - 1 === rowIdx && selectedCellIdx === 0;
85
+ var isSelectedTotalCellLeft = selectRowIdx === rowIdx && selectedCellIdx === 0;
86
+ pivotColumnCells[rowIdx] = rows;
87
+ var totalDisplayValue = StatisticsUtils.getSummaryValueDisplayString(summaryColumn, total.total);
88
+ var isValidTotalDisplayValue = StatisticsUtils.isValidValue(totalDisplayValue);
89
+ return /*#__PURE__*/React.createElement("tr", {
90
+ key: 'table-row-' + rowIdx
91
+ }, /*#__PURE__*/React.createElement("td", {
92
+ className: classnames('pivot-row-name', {
93
+ 'selected-pivot-cell-left': isSelectedRowNameRight
94
+ })
95
+ }, /*#__PURE__*/React.createElement(PivotTableDisplayName, {
96
+ value: name,
97
+ column: groupbyColumn
98
+ })), /*#__PURE__*/React.createElement("td", {
99
+ className: classnames('pivot-cell', {
100
+ 'pivot-empty-cell': !isValidTotalDisplayValue,
101
+ 'selected-pivot-cell': isSelectedTotalCell,
102
+ 'selected-pivot-cell-top': isSelectedTotalCellTop,
103
+ 'selected-pivot-cell-left': isSelectedTotalCellLeft
104
+ })
105
+ // onClick={() => this.toggleRecords({rows: Array.isArray(rows) && rows.length > 0 ? rows : pivotRowCells, total: total}, {rowIdx, cellIdx: 0})}
106
+ ,
107
+ total: totalDisplayValue
108
+ }, isValidTotalDisplayValue ? totalDisplayValue : /*#__PURE__*/React.createElement("i", null), /*#__PURE__*/React.createElement("span", {
109
+ className: classnames({
110
+ 'selected-pivot-cell-border': isSelectedTotalCell
111
+ })
112
+ })));
113
+ }), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
114
+ className: classnames('pivot-column-total', {
115
+ 'selected-pivot-cell-left': isSelectRowTotalCellRight
116
+ })
117
+ }, /*#__PURE__*/React.createElement("div", null, intl.get('Total'))), /*#__PURE__*/React.createElement("td", {
118
+ className: classnames('pivot-cell pivot-table-total', {
119
+ 'pivot-empty-cell': !isValidSummaryDisplayValue,
120
+ 'selected-pivot-cell': isSelectTotal
121
+ })
122
+ // onClick={() => this.onClickTotals(pivotColumnCells, {rowIdx: pivot_rows.length, cellIdx: 0})}
123
+ ,
124
+ title: isValidSummaryDisplayValue ? summaryDisplayValue : ''
125
+ }, isValidSummaryDisplayValue ? summaryDisplayValue : /*#__PURE__*/React.createElement("i", null), /*#__PURE__*/React.createElement("span", {
126
+ className: classnames({
127
+ 'selected-pivot-cell-border': isSelectTotal
128
+ })
129
+ }))));
130
+ };
131
+ return _this;
132
+ }
133
+ _createClass(OneDimensionTableNoNumericColumns, [{
134
+ key: "render",
135
+ value: function render() {
136
+ var groupbyColumn = this.props.groupbyColumn;
137
+ if (!groupbyColumn) return '';
138
+ return /*#__PURE__*/React.createElement("table", {
139
+ className: "seastatistic-pivot-table"
140
+ }, this.renderHeader(), this.renderRows());
141
+ }
142
+ }]);
143
+ return OneDimensionTableNoNumericColumns;
144
+ }(PureComponent);
145
+ export default OneDimensionTableNoNumericColumns;
@@ -0,0 +1,193 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
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, { PureComponent } from 'react';
7
+ import classnames from 'classnames';
8
+ import PivotTableDisplayName from './pivot-table-display-name';
9
+ import { StatisticsUtils } from '../../../utils';
10
+ import intl from '../../../intl';
11
+ var OneDimensionTableWithNumericColumns = /*#__PURE__*/function (_PureComponent) {
12
+ _inherits(OneDimensionTableWithNumericColumns, _PureComponent);
13
+ var _super = _createSuper(OneDimensionTableWithNumericColumns);
14
+ function OneDimensionTableWithNumericColumns(_props) {
15
+ var _this;
16
+ _classCallCheck(this, OneDimensionTableWithNumericColumns);
17
+ _this = _super.call(this, _props);
18
+ _this.init = function (props) {
19
+ var summaryColumns = props.summaryColumns;
20
+ _this.summaryColumnsMethodMap = {};
21
+ if (Array.isArray(summaryColumns) && summaryColumns.length > 0) {
22
+ summaryColumns.forEach(function (item) {
23
+ var column_key = item.column_key,
24
+ summary_method = item.summary_method;
25
+ _this.summaryColumnsMethodMap[column_key] = summary_method;
26
+ });
27
+ }
28
+ };
29
+ _this.renderHeader = function () {
30
+ var _this$props = _this.props,
31
+ result = _this$props.result,
32
+ groupbyColumn = _this$props.groupbyColumn,
33
+ columnGroupbyColumn = _this$props.columnGroupbyColumn,
34
+ selectedCell = _this$props.selectedCell,
35
+ statisticTableColumns = _this$props.statisticTableColumns;
36
+ var groupName = groupbyColumn.name;
37
+ var _ref = columnGroupbyColumn || {},
38
+ rowGroupName = _ref.name;
39
+ var pivot_columns = result.pivot_columns;
40
+ var _ref2 = selectedCell || {},
41
+ selectRowIdx = _ref2.rowIdx,
42
+ selectedCellIdx = _ref2.cellIdx;
43
+ return /*#__PURE__*/React.createElement("thead", {
44
+ className: "seatable-table-header-sm"
45
+ }, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
46
+ className: "pivot-table-header"
47
+ }, !rowGroupName && groupName), Array.isArray(pivot_columns) && pivot_columns.map(function (item, index) {
48
+ var key = item.key;
49
+ var column = statisticTableColumns.find(function (column) {
50
+ return column.key === key;
51
+ });
52
+ var isSelectedHeaderBottom = selectRowIdx === 0 && selectedCellIdx === index;
53
+ return /*#__PURE__*/React.createElement("th", {
54
+ className: classnames('pivot-table-header', {
55
+ 'selected-pivot-cell-top': isSelectedHeaderBottom
56
+ }),
57
+ key: "pivot-column-".concat(index)
58
+ }, /*#__PURE__*/React.createElement("div", null, column.name));
59
+ })));
60
+ };
61
+ _this.toggleRecords = function (cell, selectedCell) {
62
+ if (window.isMobile) return;
63
+ var _ref3 = _this.props.selectedCell || {},
64
+ selectedRowIdx = _ref3.rowIdx,
65
+ selectedCellIdx = _ref3.cellIdx;
66
+ var rowIdx = selectedCell.rowIdx,
67
+ cellIdx = selectedCell.cellIdx;
68
+ if (rowIdx === selectedRowIdx && selectedCellIdx === cellIdx) return;
69
+ _this.props.toggleRecords(cell, selectedCell);
70
+ };
71
+ _this.onClickTotals = function (recordsList, selectedCell) {
72
+ if (window.isMobile) return;
73
+ var rows = recordsList.flat();
74
+ var total = rows.length;
75
+ _this.toggleRecords({
76
+ rows: rows,
77
+ total: total
78
+ }, selectedCell);
79
+ };
80
+ _this.renderRows = function () {
81
+ var _this$props2 = _this.props,
82
+ result = _this$props2.result,
83
+ groupbyColumn = _this$props2.groupbyColumn,
84
+ selectedCell = _this$props2.selectedCell,
85
+ statisticTableColumns = _this$props2.statisticTableColumns;
86
+ var pivot_rows = result.pivot_rows,
87
+ pivot_columns = result.pivot_columns,
88
+ pivot_columns_total = result.pivot_columns_total;
89
+ var _ref4 = selectedCell || {},
90
+ selectRowIdx = _ref4.rowIdx,
91
+ selectedCellIdx = _ref4.cellIdx;
92
+ var pivotRowsLen = Array.isArray(pivot_rows) ? pivot_rows.length : 0;
93
+ var pivotColumnCells = [];
94
+ var isSelectRowTotalCellRight = selectRowIdx === pivotRowsLen && selectedCellIdx === 0;
95
+ return /*#__PURE__*/React.createElement("tbody", null, pivotRowsLen > 0 && pivot_rows.map(function (rowItem, rowIdx) {
96
+ var name = rowItem.name,
97
+ total = rowItem.total,
98
+ rows = rowItem.rows;
99
+ var isSelectedRowNameRight = selectRowIdx === rowIdx && selectedCellIdx === 0;
100
+ if (!Array.isArray(pivot_columns)) {
101
+ pivotColumnCells[rowIdx] = rowItem.rows || [];
102
+ }
103
+ return /*#__PURE__*/React.createElement("tr", {
104
+ key: 'table-row' + rowIdx
105
+ }, /*#__PURE__*/React.createElement("td", {
106
+ className: classnames('pivot-row-name', {
107
+ 'selected-pivot-cell-left': isSelectedRowNameRight
108
+ })
109
+ }, /*#__PURE__*/React.createElement(PivotTableDisplayName, {
110
+ value: name,
111
+ column: groupbyColumn
112
+ })), Array.isArray(pivot_columns) && pivot_columns.map(function (columnMap, cellIdx) {
113
+ var isSelectedCell = selectRowIdx === rowIdx && selectedCellIdx === cellIdx;
114
+ var isSelectedCellTop = selectRowIdx - 1 === rowIdx && selectedCellIdx === cellIdx;
115
+ var isSelectedCellLeft = selectRowIdx === rowIdx && selectedCellIdx - 1 === cellIdx;
116
+ var key = columnMap.key;
117
+ var column = statisticTableColumns.find(function (item) {
118
+ return item.key === key;
119
+ });
120
+ var displayValue = StatisticsUtils.getSummaryValueDisplayString(column, total[key], _this.summaryColumnsMethodMap[key]);
121
+ var isValidDisplayValue = StatisticsUtils.isValidValue(displayValue);
122
+ if (Array.isArray(rows) && rows.length > 0) {
123
+ if (pivotColumnCells[cellIdx]) {
124
+ var _pivotColumnCells$cel;
125
+ (_pivotColumnCells$cel = pivotColumnCells[cellIdx]).push.apply(_pivotColumnCells$cel, _toConsumableArray(rows));
126
+ } else {
127
+ pivotColumnCells[cellIdx] = _toConsumableArray(rows);
128
+ }
129
+ }
130
+ return /*#__PURE__*/React.createElement("td", {
131
+ className: classnames('pivot-cell', {
132
+ 'pivot-empty-cell': !isValidDisplayValue,
133
+ 'selected-pivot-cell': isSelectedCell,
134
+ 'selected-pivot-cell-top': isSelectedCellTop,
135
+ 'selected-pivot-cell-left': isSelectedCellLeft
136
+ }),
137
+ key: "table-cell-".concat(cellIdx)
138
+ // onClick={() => this.toggleRecords({rows, total: total[key]}, {rowIdx, cellIdx})}
139
+ ,
140
+ title: isValidDisplayValue ? displayValue : ''
141
+ }, isValidDisplayValue ? displayValue : /*#__PURE__*/React.createElement("i", null), /*#__PURE__*/React.createElement("span", {
142
+ className: classnames({
143
+ 'selected-pivot-cell-border': isSelectedCell
144
+ })
145
+ }));
146
+ }));
147
+ }), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
148
+ className: classnames('pivot-column-total', {
149
+ 'selected-pivot-cell-left': isSelectRowTotalCellRight
150
+ })
151
+ }, /*#__PURE__*/React.createElement("div", null, intl.get('Total'))), Array.isArray(pivot_columns) && pivot_columns.map(function (c, index) {
152
+ // const pivotColumnCell = pivotColumnCells[index];
153
+ var pivotColumnTotal = pivot_columns_total[c.key];
154
+ var column = statisticTableColumns.find(function (column) {
155
+ return column.key === c.key;
156
+ });
157
+ var totalDisplayValue = StatisticsUtils.getSummaryValueDisplayString(column, pivotColumnTotal, _this.summaryColumnsMethodMap[c.key]);
158
+ var isValidTotalDisplayValue = StatisticsUtils.isValidValue(totalDisplayValue);
159
+ var isSelectRowTotalCell = selectRowIdx === pivot_rows.length && selectedCellIdx === index;
160
+ var isSelectRowTotalCellLeft = selectRowIdx === pivot_rows.length && selectedCellIdx - 1 === index;
161
+ return /*#__PURE__*/React.createElement("td", {
162
+ className: classnames('pivot-cell', {
163
+ 'pivot-empty-cell': !isValidTotalDisplayValue,
164
+ 'selected-pivot-cell': isSelectRowTotalCell,
165
+ 'selected-pivot-cell-left': isSelectRowTotalCellLeft
166
+ }),
167
+ key: "total-cell-".concat(index)
168
+ // onClick={() => this.toggleRecords({ rows: pivotColumnCell, total: pivot_columns_total[c.key] }, {rowIdx: pivot_rows.length, cellIdx: index})}
169
+ ,
170
+ title: totalDisplayValue
171
+ }, isValidTotalDisplayValue ? totalDisplayValue : /*#__PURE__*/React.createElement("i", null), /*#__PURE__*/React.createElement("span", {
172
+ className: classnames({
173
+ 'selected-pivot-cell-border': isSelectRowTotalCell
174
+ })
175
+ }));
176
+ })));
177
+ };
178
+ _this.init(_props);
179
+ return _this;
180
+ }
181
+ _createClass(OneDimensionTableWithNumericColumns, [{
182
+ key: "render",
183
+ value: function render() {
184
+ var groupbyColumn = this.props.groupbyColumn;
185
+ if (!groupbyColumn) return '';
186
+ return /*#__PURE__*/React.createElement("table", {
187
+ className: "seastatistic-pivot-table"
188
+ }, this.renderHeader(), this.renderRows());
189
+ }
190
+ }]);
191
+ return OneDimensionTableWithNumericColumns;
192
+ }(PureComponent);
193
+ export default OneDimensionTableWithNumericColumns;
@@ -0,0 +1,249 @@
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, { Fragment } from 'react';
7
+ import shallowEqual from 'shallowequal';
8
+ import dayjs from 'dayjs';
9
+ import { CellType, COLLABORATOR_COLUMN_TYPES, FORMULA_RESULT_TYPE, getOption, getCollaborator, getNumberDisplayString, isNumber } from 'dtable-utils';
10
+ import { getClientFormulaDisplayString, getKnownCollaboratorByEmail, getColumnOptions, getDateColumnFormat, generateDefaultUser } from '../../../utils';
11
+ import Collaborator from '../../collaborator';
12
+ import intl from '../../../intl';
13
+ var PivotTableDisplayName = /*#__PURE__*/function (_React$Component) {
14
+ _inherits(PivotTableDisplayName, _React$Component);
15
+ var _super = _createSuper(PivotTableDisplayName);
16
+ function PivotTableDisplayName(props) {
17
+ var _this;
18
+ _classCallCheck(this, PivotTableDisplayName);
19
+ _this = _super.call(this, props);
20
+ _this.updateCreator = function (email) {
21
+ var creator = getKnownCollaboratorByEmail(email);
22
+ if (creator) {
23
+ _this.setState({
24
+ creator: creator
25
+ });
26
+ return;
27
+ }
28
+ if (creator && creator.loaded) {
29
+ _this.setState({
30
+ creator: creator
31
+ });
32
+ return;
33
+ }
34
+ if (!creator) {
35
+ var valueTemplate = {
36
+ loaded: false,
37
+ email: email,
38
+ name: email
39
+ };
40
+ window.seaStatistic.context.updateCollaboratorsCache(email, valueTemplate);
41
+ window.seaStatistic.queryUsers([email], function (emailUserMap) {
42
+ creator = emailUserMap && emailUserMap[email] || generateDefaultUser(email);
43
+ var loadedCreator = _objectSpread(_objectSpread({}, creator), {}, {
44
+ loaded: true
45
+ });
46
+ window.seaStatistic.context.updateCollaboratorsCache(email, loadedCreator);
47
+ _this.setState({
48
+ creator: creator
49
+ });
50
+ });
51
+ }
52
+ };
53
+ _this.renderSelectOption = function (option) {
54
+ if (!option) return null;
55
+ var optionName = option.name,
56
+ color = option.color,
57
+ textColor = option.textColor;
58
+ return /*#__PURE__*/React.createElement("div", {
59
+ style: {
60
+ color: textColor,
61
+ backgroundColor: color
62
+ },
63
+ className: "multiple-select-option d-inline-block align-middle mw-100",
64
+ title: optionName,
65
+ "aria-label": optionName
66
+ }, optionName);
67
+ };
68
+ _this.renderCollaborator = function (collaborator) {
69
+ if (!collaborator) return null;
70
+ var avatar_url = collaborator.avatar_url,
71
+ name = collaborator.name;
72
+ return /*#__PURE__*/React.createElement("div", {
73
+ className: "collaborators-formatter"
74
+ }, /*#__PURE__*/React.createElement("div", {
75
+ className: "collaborator"
76
+ }, /*#__PURE__*/React.createElement("span", {
77
+ className: "collaborator-avatar-container"
78
+ }, /*#__PURE__*/React.createElement("img", {
79
+ src: avatar_url,
80
+ alt: '',
81
+ className: "collaborator-avatar"
82
+ })), /*#__PURE__*/React.createElement("span", {
83
+ className: "collaborator-name",
84
+ title: name,
85
+ "aria-label": name
86
+ }, name)));
87
+ };
88
+ _this.getDisplayName = function (value, column) {
89
+ var type = column.type,
90
+ data = column.data;
91
+ var collaborators = window.seaStatistic.context.getCollaboratorsFromCache();
92
+ var displayName;
93
+ switch (type) {
94
+ case CellType.SINGLE_SELECT:
95
+ {
96
+ var options = getColumnOptions(column);
97
+ var option = getOption(options, value) || {};
98
+ displayName = /*#__PURE__*/React.createElement(React.Fragment, null, _this.renderSelectOption(option));
99
+ break;
100
+ }
101
+ case CellType.MULTIPLE_SELECT:
102
+ {
103
+ var _options = getColumnOptions(column);
104
+ var validValue = Array.isArray(value) && value.length !== 0 ? value : [];
105
+ displayName = /*#__PURE__*/React.createElement("div", {
106
+ className: "pivot-table-display-name-row"
107
+ }, validValue.map(function (item) {
108
+ var option = getOption(_options, item);
109
+ if (!item) return null;
110
+ return /*#__PURE__*/React.createElement(Fragment, {
111
+ key: item
112
+ }, _this.renderSelectOption(option));
113
+ }));
114
+ break;
115
+ }
116
+ case CellType.COLLABORATOR:
117
+ {
118
+ var _validValue = Array.isArray(value) && value.length !== 0 ? value : [];
119
+ displayName = /*#__PURE__*/React.createElement("div", {
120
+ className: "pivot-table-display-name-row"
121
+ }, _validValue.map(function (item) {
122
+ var collaborator = getCollaborator(collaborators, item);
123
+ if (!item) return null;
124
+ return /*#__PURE__*/React.createElement(Fragment, {
125
+ key: item
126
+ }, _this.renderCollaborator(collaborator));
127
+ }));
128
+ break;
129
+ }
130
+ case CellType.CREATOR:
131
+ case CellType.LAST_MODIFIER:
132
+ {
133
+ var creator = _this.state.creator;
134
+ displayName = /*#__PURE__*/React.createElement(Collaborator, {
135
+ collaborator: creator
136
+ });
137
+ break;
138
+ }
139
+ case CellType.NUMBER:
140
+ {
141
+ var valueNumber = parseFloat(value);
142
+ var displayValue = isNumber(valueNumber) ? getNumberDisplayString(valueNumber, data) : value;
143
+ displayName = /*#__PURE__*/React.createElement("div", {
144
+ title: displayValue,
145
+ "aria-label": displayValue
146
+ }, displayValue);
147
+ break;
148
+ }
149
+ case CellType.DATE:
150
+ {
151
+ var _displayValue = value + '';
152
+ if (_displayValue && _displayValue.split('-').length === 3) {
153
+ var format = getDateColumnFormat(column);
154
+ var spaceIndex = format.indexOf(' ');
155
+ if (spaceIndex > -1) {
156
+ format = format.slice(0, spaceIndex);
157
+ }
158
+ _displayValue = dayjs(_displayValue).format(format);
159
+ }
160
+ displayName = /*#__PURE__*/React.createElement("div", {
161
+ title: _displayValue,
162
+ "aria-label": _displayValue
163
+ }, _displayValue);
164
+ break;
165
+ }
166
+ case CellType.LINK:
167
+ {
168
+ var _displayValue2 = getClientFormulaDisplayString([value], data, {
169
+ collaborators: collaborators
170
+ }) || null;
171
+ displayName = /*#__PURE__*/React.createElement("div", {
172
+ title: _displayValue2,
173
+ "aria-label": _displayValue2
174
+ }, _displayValue2);
175
+ break;
176
+ }
177
+ case CellType.FORMULA:
178
+ case CellType.LINK_FORMULA:
179
+ {
180
+ var _displayValue3 = value;
181
+ var _ref = data || {},
182
+ result_type = _ref.result_type,
183
+ array_type = _ref.array_type;
184
+ if (result_type === FORMULA_RESULT_TYPE.NUMBER) {
185
+ var _valueNumber = parseFloat(value);
186
+ _displayValue3 = isNumber(_valueNumber) ? getNumberDisplayString(_valueNumber, data) : value;
187
+ } else if (result_type === FORMULA_RESULT_TYPE.ARRAY) {
188
+ if (COLLABORATOR_COLUMN_TYPES.includes(array_type) && Array.isArray(value)) {
189
+ _displayValue3 = value.map(function (email) {
190
+ var user = array_type === CellType.COLLABORATOR ? getCollaborator(collaborators, email) : getKnownCollaboratorByEmail(email);
191
+ return (user || {}).name;
192
+ });
193
+ }
194
+ }
195
+ displayName = /*#__PURE__*/React.createElement("div", {
196
+ title: _displayValue3,
197
+ "aria-label": _displayValue3
198
+ }, _displayValue3);
199
+ break;
200
+ }
201
+ default:
202
+ {
203
+ displayName = /*#__PURE__*/React.createElement("div", {
204
+ title: String(value),
205
+ "aria-label": String(value)
206
+ }, value);
207
+ break;
208
+ }
209
+ }
210
+ return displayName;
211
+ };
212
+ _this.state = {
213
+ creator: {}
214
+ };
215
+ return _this;
216
+ }
217
+ _createClass(PivotTableDisplayName, [{
218
+ key: "componentDidMount",
219
+ value: function componentDidMount() {
220
+ var _this$props = this.props,
221
+ column = _this$props.column,
222
+ value = _this$props.value;
223
+ if (column.type !== CellType.CREATOR && column.type !== CellType.LAST_MODIFIER) return;
224
+ this.updateCreator(value);
225
+ }
226
+ }, {
227
+ key: "UNSAFE_componentWillReceiveProps",
228
+ value: function UNSAFE_componentWillReceiveProps(nextProps) {
229
+ var column = nextProps.column,
230
+ value = nextProps.value;
231
+ var type = column.type;
232
+ if (type !== CellType.CREATOR && type !== CellType.LAST_MODIFIER) return;
233
+ if (value !== this.props.value || shallowEqual(nextProps.column, this.props.column)) {
234
+ this.updateCreator(value);
235
+ }
236
+ }
237
+ }, {
238
+ key: "render",
239
+ value: function render() {
240
+ var _this$props2 = this.props,
241
+ value = _this$props2.value,
242
+ column = _this$props2.column;
243
+ var displayName = value ? this.getDisplayName(value, column) : /*#__PURE__*/React.createElement("div", null, "(".concat(intl.get('Empty'), ")"));
244
+ return /*#__PURE__*/React.createElement(Fragment, null, displayName);
245
+ }
246
+ }]);
247
+ return PivotTableDisplayName;
248
+ }(React.Component);
249
+ export default PivotTableDisplayName;