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
@@ -1,249 +0,0 @@
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;
@@ -1,241 +0,0 @@
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;