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