dtable-statistic 4.0.2-test-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/README.md +3 -0
  2. package/es/api/dtable-db-api.js +43 -0
  3. package/es/assets/css/color-picker.css +53 -0
  4. package/es/assets/css/color-rules-popover.css +144 -0
  5. package/es/assets/css/color-theme-dialog.css +40 -0
  6. package/es/assets/css/dashboard.css +562 -0
  7. package/es/assets/css/dialog.css +415 -0
  8. package/es/assets/css/mobile-dashboard.module.css +91 -0
  9. package/es/assets/css/slider.css +77 -0
  10. package/es/assets/css/statistic-chart.module.css +11 -0
  11. package/es/assets/css/statistic-custom-title.module.css +3 -0
  12. package/es/assets/css/statistic-custom.module.css +4 -0
  13. package/es/assets/css/statistic-numeric-column-item.module.css +43 -0
  14. package/es/assets/css/statistic-time-picker.module.css +21 -0
  15. package/es/assets/css/theme.css +61 -0
  16. package/es/assets/images/icon.png +0 -0
  17. package/es/calculator/base-calculator.js +111 -0
  18. package/es/calculator/basic-chart-calculator.js +571 -0
  19. package/es/calculator/combination-calculator.js +296 -0
  20. package/es/calculator/compare-bar-calculator.js +291 -0
  21. package/es/calculator/completeness-calculator.js +307 -0
  22. package/es/calculator/copy-value.js +47 -0
  23. package/es/calculator/dashboard-calculator.js +146 -0
  24. package/es/calculator/heat-map-calculator.js +225 -0
  25. package/es/calculator/horizontal-bar-calculator.js +100 -0
  26. package/es/calculator/index.js +88 -0
  27. package/es/calculator/map-calculator.js +169 -0
  28. package/es/calculator/mirror-calculator.js +217 -0
  29. package/es/calculator/number-card-calculator.js +135 -0
  30. package/es/calculator/pivot-table-calculator.js +810 -0
  31. package/es/calculator/scatter-calculator.js +150 -0
  32. package/es/calculator/thread-manager.js +70 -0
  33. package/es/calculator/trend-calculator.js +204 -0
  34. package/es/calculator/workers/basic-chart-calculator-worker.js +410 -0
  35. package/es/calculator/workers/calculator.worker.js +22 -0
  36. package/es/calculator/workers/card-calculator-worker.js +28 -0
  37. package/es/calculator/workers/combination-calculator-worker.js +257 -0
  38. package/es/calculator/workers/compare-bar-chart-calculator-worker.js +149 -0
  39. package/es/calculator/workers/completeness-calculator-worker.js +153 -0
  40. package/es/calculator/workers/dashboard-calculator-worker.js +56 -0
  41. package/es/calculator/workers/mirror-calculator-worker.js +132 -0
  42. package/es/calculator/workers/pivot-table-calculator-worker.js +615 -0
  43. package/es/calculator/workers/scatter-calculator-worker.js +67 -0
  44. package/es/calculator/workers/trend-calculator-worker.js +93 -0
  45. package/es/calculator/world-map-calculator.js +193 -0
  46. package/es/components/common-add-tool.js +19 -0
  47. package/es/components/dialog/chart-addition-edit-dialog.js +89 -0
  48. package/es/components/dialog/chart-addition-widgets/chart-selector.js +261 -0
  49. package/es/components/dialog/chart-addition-widgets/statistic-chart-selector.module.css +74 -0
  50. package/es/components/dialog/color-theme-dialog.js +71 -0
  51. package/es/components/dialog/enlarged-chart-dialog.js +73 -0
  52. package/es/components/dialog/new-table-dialog.js +113 -0
  53. package/es/components/dialog/new-view-dialog.js +87 -0
  54. package/es/components/dialog/rename-view-dialog.js +87 -0
  55. package/es/components/dialog/statistic-record-dialog/index.css +114 -0
  56. package/es/components/dialog/statistic-record-dialog/index.js +174 -0
  57. package/es/components/dialog/table-select-dialog.js +93 -0
  58. package/es/components/dropdown-menu/statistic-dropdown-menu.js +94 -0
  59. package/es/components/dtable-popover.js +109 -0
  60. package/es/components/dtable-search-input.js +137 -0
  61. package/es/components/dtable-select.js +104 -0
  62. package/es/components/index.js +11 -0
  63. package/es/components/loading.js +8 -0
  64. package/es/components/modal-portal.js +36 -0
  65. package/es/components/popover/color-rules/color-rule.js +179 -0
  66. package/es/components/popover/color-rules/index.js +87 -0
  67. package/es/components/popover/color-rules/rule-filters/filter.js +214 -0
  68. package/es/components/popover/color-rules/rule-filters/index.css +214 -0
  69. package/es/components/popover/color-rules/rule-filters/index.js +97 -0
  70. package/es/components/popover/color-rules/rule-filters/number-input.js +85 -0
  71. package/es/components/popover/color-rules-popover.js +213 -0
  72. package/es/components/popover/color-selector-popover.js +85 -0
  73. package/es/components/seatable-radio/index.css +51 -0
  74. package/es/components/seatable-radio/index.js +28 -0
  75. package/es/components/select/index.js +2 -0
  76. package/es/components/select/option-group.css +104 -0
  77. package/es/components/select/option-group.js +225 -0
  78. package/es/components/select/option.js +51 -0
  79. package/es/components/select/select.css +211 -0
  80. package/es/components/select/select.js +157 -0
  81. package/es/components/toast/alert.js +130 -0
  82. package/es/components/toast/index.js +3 -0
  83. package/es/components/toast/toast.js +164 -0
  84. package/es/components/toast/toastManager.js +150 -0
  85. package/es/components/toast/toaster.js +64 -0
  86. package/es/constants/color-rules.js +8 -0
  87. package/es/constants/dtable-select-style.js +61 -0
  88. package/es/constants/event-types.js +1 -0
  89. package/es/constants/index.js +501 -0
  90. package/es/constants/key-codes.js +102 -0
  91. package/es/constants/zIndexes.js +1 -0
  92. package/es/custom-g2.js +614 -0
  93. package/es/dashboard.js +408 -0
  94. package/es/desktop-dashboard.js +299 -0
  95. package/es/index.js +33 -0
  96. package/es/locale/index.js +17 -0
  97. package/es/locale/lang/de.js +237 -0
  98. package/es/locale/lang/en.js +237 -0
  99. package/es/locale/lang/fr.js +237 -0
  100. package/es/locale/lang/zh_CN.js +237 -0
  101. package/es/mobile-dashboard.js +103 -0
  102. package/es/model/collaborators.js +11 -0
  103. package/es/model/stat-item.js +340 -0
  104. package/es/model/statistic-dashboard.js +8 -0
  105. package/es/service/chart-service.js +192 -0
  106. package/es/service/dashboard-service.js +415 -0
  107. package/es/stat-editor/chart-name-editor.js +75 -0
  108. package/es/stat-editor/index.js +74 -0
  109. package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +149 -0
  110. package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +415 -0
  111. package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +193 -0
  112. package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +13 -0
  113. package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +107 -0
  114. package/es/stat-editor/stat-settings/advance-chart-settings/index.js +332 -0
  115. package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +170 -0
  116. package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +141 -0
  117. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +219 -0
  118. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +89 -0
  119. package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +132 -0
  120. package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +319 -0
  121. package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +138 -0
  122. package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +135 -0
  123. package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +156 -0
  124. package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +147 -0
  125. package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +195 -0
  126. package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +126 -0
  127. package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +169 -0
  128. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +352 -0
  129. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +145 -0
  130. package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +153 -0
  131. package/es/stat-editor/stat-settings/basic-chart-settings/index.js +466 -0
  132. package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +183 -0
  133. package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +542 -0
  134. package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +111 -0
  135. package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +86 -0
  136. package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +169 -0
  137. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +273 -0
  138. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +105 -0
  139. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +243 -0
  140. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +65 -0
  141. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +318 -0
  142. package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +49 -0
  143. package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +124 -0
  144. package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +150 -0
  145. package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +267 -0
  146. package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +109 -0
  147. package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +351 -0
  148. package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +60 -0
  149. package/es/stat-editor/stat-settings/color-setting/color-picker.js +129 -0
  150. package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +348 -0
  151. package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +102 -0
  152. package/es/stat-editor/stat-settings/public-setting/base-settings.js +124 -0
  153. package/es/stat-editor/stat-settings/public-setting/calender.js +124 -0
  154. package/es/stat-editor/stat-settings/public-setting/column-settings.js +15 -0
  155. package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +60 -0
  156. package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +57 -0
  157. package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +41 -0
  158. package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +64 -0
  159. package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +118 -0
  160. package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +39 -0
  161. package/es/stat-list/chart-preview.js +139 -0
  162. package/es/stat-list/index.js +275 -0
  163. package/es/stat-view/area-chart.js +521 -0
  164. package/es/stat-view/bar-chart.js +568 -0
  165. package/es/stat-view/base-chart.js +44 -0
  166. package/es/stat-view/basic-number-card.js +255 -0
  167. package/es/stat-view/combination-chart.js +558 -0
  168. package/es/stat-view/compare-chart.js +485 -0
  169. package/es/stat-view/completeness-chart.js +389 -0
  170. package/es/stat-view/custom-bar.js +433 -0
  171. package/es/stat-view/dashboard-chart.js +317 -0
  172. package/es/stat-view/heat-map.js +501 -0
  173. package/es/stat-view/horizontal-bar-chart.js +569 -0
  174. package/es/stat-view/index.js +183 -0
  175. package/es/stat-view/line-chart.js +505 -0
  176. package/es/stat-view/map.js +428 -0
  177. package/es/stat-view/mirror.js +285 -0
  178. package/es/stat-view/pie-chart.js +326 -0
  179. package/es/stat-view/pivot-table/index.js +206 -0
  180. package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +133 -0
  181. package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +164 -0
  182. package/es/stat-view/pivot-table/statistic-pivot-table.module.css +132 -0
  183. package/es/stat-view/pivot-table/two-dimension-table.js +344 -0
  184. package/es/stat-view/ring-chart.js +416 -0
  185. package/es/stat-view/scatter-chart.js +367 -0
  186. package/es/stat-view/treemap-chart.js +318 -0
  187. package/es/stat-view/trend-chart.js +299 -0
  188. package/es/stat-view/world-map.js +443 -0
  189. package/es/tabs/index.js +252 -0
  190. package/es/tabs/statistic-tabs.module.css +154 -0
  191. package/es/tabs/tab.js +167 -0
  192. package/es/utils/basic-chart-utils.js +24 -0
  193. package/es/utils/cell-format.js +110 -0
  194. package/es/utils/cell-value.js +27 -0
  195. package/es/utils/collaborator.js +31 -0
  196. package/es/utils/color-utils.js +112 -0
  197. package/es/utils/column-utils.js +18 -0
  198. package/es/utils/column.js +13 -0
  199. package/es/utils/common-utils.js +303 -0
  200. package/es/utils/date-format.js +65 -0
  201. package/es/utils/export-table-utils.js +632 -0
  202. package/es/utils/index.js +26 -0
  203. package/es/utils/object.js +26 -0
  204. package/es/utils/row-utils.js +115 -0
  205. package/es/utils/search.js +67 -0
  206. package/es/utils/sql-utils.js +293 -0
  207. package/es/utils/stat-utils.js +353 -0
  208. package/es/utils/trend-utils.js +136 -0
  209. package/index.js +1 -0
  210. package/package.json +188 -0
@@ -0,0 +1,154 @@
1
+ .tabs-container {
2
+ display: flex;
3
+ flex: 1 1;
4
+ height: 100%;
5
+ font-size: 14px;
6
+ font-weight: 500;
7
+ overflow: hidden;
8
+ }
9
+
10
+ .dashboard-tab {
11
+ height: 100%;
12
+ padding: 0 16px;
13
+ flex: 1 0 auto;
14
+ user-select: none;
15
+ cursor: grab;
16
+ position: relative;
17
+ }
18
+
19
+ .dashboard-tab-can-drop-before::before,
20
+ .dashboard-tab-can-drop-after::after {
21
+ content: '';
22
+ border: 1px solid #555;
23
+ border-radius: 1px;
24
+ position: absolute;
25
+ top: 4px;
26
+ bottom: 4px;
27
+ }
28
+
29
+ .dashboard-tab-can-drop-before::before {
30
+ left: 0;
31
+ }
32
+
33
+ .dashboard-tab-can-drop-after::after {
34
+ right: -2px;
35
+ }
36
+
37
+ .dashboard-tab .dashboard-tab-content {
38
+ position: relative;
39
+ display: flex;
40
+ align-items: center;
41
+ justify-content: center;
42
+ width: 100%;
43
+ height: 100%;
44
+ color: var(--statistic-header-font-color);
45
+ border-bottom: 2px solid transparent;
46
+ }
47
+
48
+ .dashboard-tab .tab-item-active {
49
+ border-color: #3b88fd;
50
+ color: var(--statistic-header-focused-font-color);
51
+ cursor: default;
52
+ }
53
+
54
+ .dashboard-tab .tab-item-active-mobile {
55
+ border-color: #3b88fd;
56
+ color: var(--statistic-header-focused-font-color);
57
+ }
58
+
59
+ .icon {
60
+ display: inline-block;
61
+ height: 18px;
62
+ font-size: 12px;
63
+ color: var(--view-icon-color);
64
+ transform: scale(.8);
65
+ transition: all .1s;
66
+ }
67
+
68
+ .btn-view-dropdown {
69
+ display: flex;
70
+ align-items: center;
71
+ justify-content: center;
72
+ width: 20px;
73
+ height: 20px;
74
+ margin-left: 5px;
75
+ margin-right: -5px;
76
+ line-height: 20px;
77
+ cursor: pointer;
78
+ }
79
+
80
+ .views-scroll-control {
81
+ display: flex;
82
+ align-items: center;
83
+ padding: 0 .25rem;
84
+ }
85
+
86
+ .views-scroll-control .scroll-control-btn {
87
+ cursor: default;
88
+ }
89
+
90
+ .views-scroll-control .scroll-control-btn:first-child {
91
+ margin-right: .1rem;
92
+ }
93
+
94
+ .views-scroll-control .scroll-active {
95
+ cursor: pointer;
96
+ }
97
+
98
+ .views-scroll-control .btn-scroll-icon {
99
+ color: var(--btn-scroll-icon-color);
100
+ font-size: 12px;
101
+ line-height: 24px;
102
+ }
103
+
104
+ .views-scroll-control .scroll-active .btn-scroll-icon {
105
+ color: var(--btn-scroll-icon-active-color);
106
+ }
107
+
108
+ .views-scroll-control .scroll-active:hover .btn-scroll-icon {
109
+ color: var(--btn-scroll-icon-active-hover-color);
110
+ opacity: 1;
111
+ }
112
+
113
+ .btn-add-view {
114
+ display: flex;
115
+ align-items: center;
116
+ width: 24px;
117
+ height: 100%;
118
+ margin-right: .5rem;
119
+ }
120
+
121
+ .add-map-view-icon {
122
+ height: 24px;
123
+ width: 24px;
124
+ text-align: center;
125
+ cursor: pointer;
126
+ color: var(--common-font-color);
127
+ opacity: .5;
128
+ font-size: 14px;
129
+ font-weight: 500;
130
+ line-height: 24px;
131
+ }
132
+
133
+ .add-map-view-icon:hover {
134
+ opacity: 1;
135
+ color: var(--btn-add-view-hover-color);
136
+ }
137
+
138
+ .dashboard-tab .dashboard-tab-content:hover {
139
+ border-color: #3b88fd;
140
+ color: var(--statistic-header-focused-font-color);
141
+ cursor: pointer;
142
+ }
143
+
144
+ .views-tabs-scroll {
145
+ overflow-x: scroll;
146
+ overflow-y: hidden;
147
+ scrollbar-width: none;
148
+ }
149
+
150
+ .views-tabs-scroll::-webkit-scrollbar {
151
+ display: none;
152
+ width: 0;
153
+ height: 0;
154
+ }
package/es/tabs/tab.js ADDED
@@ -0,0 +1,167 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
4
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
5
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
+ import React, { Component } from 'react';
7
+ import intl from 'react-intl-universal';
8
+ import { ModalPortal } from '../components';
9
+ import { isMobile } from '../utils';
10
+ import styles from './statistic-tabs.module.css';
11
+ var DashBoardTab = /*#__PURE__*/function (_Component) {
12
+ _inherits(DashBoardTab, _Component);
13
+ var _super = _createSuper(DashBoardTab);
14
+ function DashBoardTab(props) {
15
+ var _this;
16
+ _classCallCheck(this, DashBoardTab);
17
+ _this = _super.call(this, props);
18
+ _this.onHideViewDropdown = function () {
19
+ if (_this.state.isShowViewDropdown) {
20
+ _this.setState({
21
+ isShowViewDropdown: false
22
+ });
23
+ }
24
+ };
25
+ _this.onDropdownToggle = function (evt) {
26
+ evt.nativeEvent.stopImmediatePropagation();
27
+ var _this$btnViewDropdown = _this.btnViewDropdown.parentNode.getBoundingClientRect(),
28
+ top = _this$btnViewDropdown.top,
29
+ left = _this$btnViewDropdown.left,
30
+ height = _this$btnViewDropdown.height;
31
+ _this.setState({
32
+ isShowViewDropdown: !_this.state.isShowViewDropdown,
33
+ dropdownMenuPosition: {
34
+ top: top + height - 3,
35
+ left: left
36
+ }
37
+ });
38
+ };
39
+ _this.onDragStart = function (event) {
40
+ event.stopPropagation();
41
+ var ref = _this.itemRef;
42
+ event.dataTransfer.setDragImage(ref, 10, 10);
43
+ event.dataTransfer.effectAllowed = 'move';
44
+ event.dataTransfer.setData('text/plain', _this.props.item._id);
45
+ };
46
+ _this.onDragEnter = function (event) {
47
+ event.stopPropagation();
48
+ _this.enteredCounter++;
49
+ };
50
+ _this.onDragOver = function (event) {
51
+ if (event.dataTransfer.dropEffect === 'copy') {
52
+ return;
53
+ }
54
+ event.stopPropagation();
55
+ event.preventDefault();
56
+ event.dataTransfer.dropEffect = 'move';
57
+ _this.setState({
58
+ dropRelativePosition: event.nativeEvent.offsetX <= event.target.clientWidth / 2 ? 'before' : 'after'
59
+ });
60
+ };
61
+ _this.onDragLeave = function (event) {
62
+ event.stopPropagation();
63
+ _this.enteredCounter--;
64
+ if (_this.enteredCounter === 0) {
65
+ _this.setState({
66
+ dropRelativePosition: ''
67
+ });
68
+ }
69
+ };
70
+ _this.onDrop = function (event) {
71
+ event.stopPropagation();
72
+ event.preventDefault();
73
+ _this.enteredCounter = 0;
74
+ var dropRelativePosition = _this.state.dropRelativePosition;
75
+ _this.setState({
76
+ dropRelativePosition: ''
77
+ });
78
+ var draggedDashboardId = event.dataTransfer.getData('text/plain');
79
+ var _id = _this.props.item._id;
80
+ if (draggedDashboardId == _id) {
81
+ return;
82
+ }
83
+ _this.props.onMoveDashboard && _this.props.onMoveDashboard(draggedDashboardId, _id, dropRelativePosition);
84
+ };
85
+ _this.state = {
86
+ isShowViewDropdown: false,
87
+ dropdownMenuPosition: {
88
+ top: 0,
89
+ left: 0
90
+ }
91
+ };
92
+ _this.enteredCounter = 0;
93
+ return _this;
94
+ }
95
+ _createClass(DashBoardTab, [{
96
+ key: "componentDidMount",
97
+ value: function componentDidMount() {
98
+ document.addEventListener('click', this.onHideViewDropdown);
99
+ }
100
+ }, {
101
+ key: "componentWillUnmount",
102
+ value: function componentWillUnmount() {
103
+ document.removeEventListener('click', this.onHideViewDropdown);
104
+ }
105
+ }, {
106
+ key: "render",
107
+ value: function render() {
108
+ var _this2 = this;
109
+ var _this$props = this.props,
110
+ selected = _this$props.selected,
111
+ theme = _this$props.theme,
112
+ item = _this$props.item,
113
+ canDelete = _this$props.canDelete;
114
+ var _this$state = this.state,
115
+ isShowViewDropdown = _this$state.isShowViewDropdown,
116
+ dropdownMenuPosition = _this$state.dropdownMenuPosition,
117
+ dropRelativePosition = _this$state.dropRelativePosition;
118
+ return /*#__PURE__*/React.createElement("div", {
119
+ ref: function ref(_ref2) {
120
+ return _this2.itemRef = _ref2;
121
+ },
122
+ draggable: "true",
123
+ onDragStart: this.onDragStart,
124
+ onDragEnter: this.onDragEnter,
125
+ onDragOver: this.onDragOver,
126
+ onDragLeave: this.onDragLeave,
127
+ onDrop: this.onDrop,
128
+ className: "\n ".concat(styles['dashboard-tab'], "\n ").concat(dropRelativePosition == 'before' ? styles['dashboard-tab-can-drop-before'] : '', "\n ").concat(dropRelativePosition == 'after' ? styles['dashboard-tab-can-drop-after'] : '', "\n ")
129
+ }, /*#__PURE__*/React.createElement("div", {
130
+ ref: this.props.setViewItem,
131
+ onClick: this.props.onSelectDashboard,
132
+ className: "".concat(styles['dashboard-tab-content'], " ").concat(selected ? isMobile ? styles['tab-item-active-mobile'] : styles['tab-item-active'] : '')
133
+ }, /*#__PURE__*/React.createElement("div", {
134
+ className: "view-name"
135
+ }, item.name), selected && !isMobile && /*#__PURE__*/React.createElement("div", {
136
+ onClick: this.onDropdownToggle,
137
+ ref: function ref(_ref) {
138
+ return _this2.btnViewDropdown = _ref;
139
+ },
140
+ className: "".concat(styles['btn-view-dropdown'])
141
+ }, /*#__PURE__*/React.createElement("i", {
142
+ className: "".concat(styles['icon'], " dtable-font dtable-icon-drop-down")
143
+ }), isShowViewDropdown && /*#__PURE__*/React.createElement(ModalPortal, null, /*#__PURE__*/React.createElement("div", {
144
+ className: "".concat(theme === 'dark' ? 'statistic-tabs-dropdown-dark' : 'statistic-tabs-dropdown-light', " statistic-dropdown-menu dropdown-menu large show"),
145
+ style: _objectSpread(_objectSpread({}, dropdownMenuPosition), {}, {
146
+ zIndex: 1500
147
+ })
148
+ }, /*#__PURE__*/React.createElement("button", {
149
+ className: "dropdown-item",
150
+ onClick: this.props.onToggleRenameView
151
+ }, /*#__PURE__*/React.createElement("i", {
152
+ className: "item-icon dtable-font dtable-icon-rename"
153
+ }), /*#__PURE__*/React.createElement("span", {
154
+ className: "item-text"
155
+ }, intl.get('Rename'))), canDelete && /*#__PURE__*/React.createElement("button", {
156
+ className: "dropdown-item",
157
+ onClick: this.props.onDeleteDashboard
158
+ }, /*#__PURE__*/React.createElement("i", {
159
+ className: "item-icon dtable-font dtable-icon-delete"
160
+ }), /*#__PURE__*/React.createElement("span", {
161
+ className: "item-text"
162
+ }, intl.get('Delete'))))))));
163
+ }
164
+ }]);
165
+ return DashBoardTab;
166
+ }(Component);
167
+ export default DashBoardTab;
@@ -0,0 +1,24 @@
1
+ export function getChartDisplayLabels(containerWidth, minItemWidth, statistics) {
2
+ var labels = [];
3
+ var labelCount = Math.floor(containerWidth / minItemWidth);
4
+ labelCount = labelCount % 2 ? labelCount + 1 : labelCount;
5
+ var avg = Math.round(statistics.length / labelCount);
6
+ avg = avg > 2 ? avg : 2;
7
+ Array.isArray(statistics) && statistics.forEach(function (v, i) {
8
+ if (i % avg === 0) {
9
+ labels.push(v.name);
10
+ }
11
+ });
12
+ return labels;
13
+ }
14
+ export function getChartGroups(statistics) {
15
+ var chartGroups = [];
16
+ Array.isArray(statistics) && statistics.forEach(function (item) {
17
+ if (!chartGroups.find(function (g) {
18
+ return g.name === item.name;
19
+ })) {
20
+ chartGroups.push(item);
21
+ }
22
+ });
23
+ return chartGroups;
24
+ }
@@ -0,0 +1,110 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import dayjs from 'dayjs';
3
+ import { getCollaboratorsName, getCellValueDisplayString, getFormulaDisplayString, CellType, FORMULA_COLUMN_TYPES, FORMULA_RESULT_TYPE, COLLABORATOR_COLUMN_TYPES } from 'dtable-store';
4
+ var getClientFormulaDisplayString = function getClientFormulaDisplayString(value, columnData) {
5
+ var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
6
+ _ref$tables = _ref.tables,
7
+ tables = _ref$tables === void 0 ? [] : _ref$tables,
8
+ _ref$collaborators = _ref.collaborators,
9
+ collaborators = _ref$collaborators === void 0 ? [] : _ref$collaborators;
10
+ if (!columnData || !value && value !== 0) return '';
11
+ var result_type = columnData.result_type,
12
+ array_type = columnData.array_type;
13
+ if (result_type === FORMULA_RESULT_TYPE.ARRAY) {
14
+ if (COLLABORATOR_COLUMN_TYPES.includes(array_type)) {
15
+ if (!value) {
16
+ return null;
17
+ }
18
+ var collaboratorList = Array.isArray(value) ? value : [value];
19
+ return getCollaboratorsName(collaborators, collaboratorList);
20
+ }
21
+ }
22
+ return getFormulaDisplayString(value, columnData, {
23
+ tables: tables,
24
+ collaborators: collaborators
25
+ });
26
+ };
27
+
28
+ /**
29
+ * @param {array} links [
30
+ * {
31
+ * row_id, // id of linked row
32
+ * display_value, // cell value from linked row
33
+ * }
34
+ * ]
35
+ */
36
+ var getClientLinkDisplayString = function getClientLinkDisplayString(links, columnData) {
37
+ var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
38
+ _ref2$tables = _ref2.tables,
39
+ tables = _ref2$tables === void 0 ? [] : _ref2$tables,
40
+ _ref2$collaborators = _ref2.collaborators,
41
+ collaborators = _ref2$collaborators === void 0 ? [] : _ref2$collaborators;
42
+ if (!columnData || !Array.isArray(links) || links.length === 0) {
43
+ return null;
44
+ }
45
+ var formulaData = _objectSpread({}, columnData);
46
+ if (!columnData.hasOwnProperty('result_type')) {
47
+ formulaData.result_type = FORMULA_RESULT_TYPE.ARRAY;
48
+ }
49
+ var displayValue = links.map(function (link) {
50
+ return link.display_value;
51
+ });
52
+ return getClientFormulaDisplayString(displayValue, formulaData, {
53
+ tables: tables,
54
+ collaborators: collaborators
55
+ });
56
+ };
57
+ var getAutoTimeDisplayString = function getAutoTimeDisplayString(row, key) {
58
+ var value = row[key];
59
+ if (value === '' || !value || typeof value !== 'string') {
60
+ return null;
61
+ }
62
+ var date = dayjs(value);
63
+ if (!date.isValid()) return value;
64
+ return date.format('YYYY-MM-DD HH:mm:ss');
65
+ };
66
+ var getFileDisplayString = function getFileDisplayString(row, key) {
67
+ var value = row[key];
68
+ if (!value || !Array.isArray(value) || value.length === 0) {
69
+ return null;
70
+ }
71
+ var fileNameList = [];
72
+ value.forEach(function (v) {
73
+ fileNameList.push(v.url.split('/').slice(-3).join('/').trim());
74
+ });
75
+ return decodeURIComponent(fileNameList.join(','));
76
+ };
77
+ var getClientCellValueDisplayString = function getClientCellValueDisplayString(row, type, key) {
78
+ var _ref3 = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
79
+ _ref3$formulaRows = _ref3.formulaRows,
80
+ formulaRows = _ref3$formulaRows === void 0 ? {} : _ref3$formulaRows,
81
+ data = _ref3.data,
82
+ _ref3$collaborators = _ref3.collaborators,
83
+ collaborators = _ref3$collaborators === void 0 ? [] : _ref3$collaborators,
84
+ _ref3$tables = _ref3.tables,
85
+ tables = _ref3$tables === void 0 ? [] : _ref3$tables;
86
+ if (FORMULA_COLUMN_TYPES.includes(type)) {
87
+ var formulaRow = formulaRows[row._id] || {};
88
+ return getClientFormulaDisplayString(formulaRow[key], data, {
89
+ tables: tables,
90
+ collaborators: collaborators
91
+ });
92
+ } else if (type === CellType.LINK) {
93
+ var _formulaRow = formulaRows[row._id] || {};
94
+ return getClientLinkDisplayString(_formulaRow[key], data, {
95
+ tables: tables,
96
+ collaborators: collaborators
97
+ });
98
+ } else if (type === CellType.CTIME || type === CellType.MTIME) {
99
+ return getAutoTimeDisplayString(row, key);
100
+ } else if (type === CellType.FILE) {
101
+ return getFileDisplayString(row, key);
102
+ }
103
+ return getCellValueDisplayString(row, type, key, {
104
+ formulaRows: formulaRows,
105
+ data: data,
106
+ collaborators: collaborators,
107
+ tables: tables
108
+ });
109
+ };
110
+ export { getClientCellValueDisplayString, getClientFormulaDisplayString };
@@ -0,0 +1,27 @@
1
+ import { CellType } from 'dtable-store';
2
+ import { isEmptyObject, isSameObject } from './object';
3
+ export var isCellValueChanged = function isCellValueChanged(oldVal, newVal, columnType) {
4
+ if (oldVal === newVal) {
5
+ return false;
6
+ }
7
+ if (oldVal === undefined || oldVal === null) {
8
+ if ((columnType === CellType.GEOLOCATION || columnType === CellType.DIGITAL_SIGN) && isEmptyObject(newVal)) {
9
+ return false;
10
+ }
11
+ if ((columnType === CellType.DATE || columnType === CellType.NUMBER || columnType === CellType.DURATION) && newVal === null) {
12
+ return false;
13
+ }
14
+ if (Array.isArray(newVal)) {
15
+ return newVal.length !== 0;
16
+ }
17
+ return newVal !== false && newVal !== '';
18
+ }
19
+ if (Array.isArray(oldVal) && Array.isArray(newVal)) {
20
+ // [{}].toString(): [object Object]
21
+ return JSON.stringify(oldVal) !== JSON.stringify(newVal);
22
+ }
23
+ if (typeof oldVal === 'object' && typeof newVal === 'object' && newVal !== null) {
24
+ return !isSameObject(oldVal, newVal);
25
+ }
26
+ return oldVal !== newVal;
27
+ };
@@ -0,0 +1,31 @@
1
+ export var isValidCollaboratorEmail = function isValidCollaboratorEmail(email) {
2
+ var reg = /^[A-Za-z0-9]+([-_.][A-Za-z0-9]+)*@([A-Za-z0-9]+[-.])+[A-Za-z0-9]{2,6}$/;
3
+ return reg.test(email);
4
+ };
5
+ export var getKnownCreatorByEmail = function getKnownCreatorByEmail(collaborators, email) {
6
+ var _ref = window.dtable || {},
7
+ mediaUrl = _ref.mediaUrl;
8
+ var defaultAvatarUrl = "".concat(mediaUrl, "avatars/default.png");
9
+ if (email === 'anonymous' || email === 'Automation Rule') {
10
+ return {
11
+ name: email,
12
+ avatar_url: defaultAvatarUrl
13
+ };
14
+ }
15
+ var creator = collaborators.find(function (collaborator) {
16
+ return collaborator.email === email;
17
+ });
18
+ if (creator) return creator;
19
+ var dtableCollaborators = window.app && window.app.collaboratorsCache ? window.app.collaboratorsCache : {};
20
+ if (!isValidCollaboratorEmail(email)) {
21
+ creator = {
22
+ name: email,
23
+ avatar_url: defaultAvatarUrl
24
+ };
25
+ dtableCollaborators[email] = creator;
26
+ return creator;
27
+ }
28
+ creator = dtableCollaborators[email];
29
+ if (creator) return creator;
30
+ return null;
31
+ };
@@ -0,0 +1,112 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import { filterRow, getValidFilters } from 'dtable-store';
3
+ import { STAT_TYPE, TYPE_COLOR_USING } from '../constants';
4
+ import { COLOR_RULE_FILTER_TYPE_MAP, FILTER_TYPE_2_CELL_TYPE } from '../constants/color-rules';
5
+ export var getValidColorRules = function getValidColorRules(colorRules) {
6
+ if (!Array.isArray(colorRules) || colorRules.length === 0) {
7
+ return [];
8
+ }
9
+ var columns = [];
10
+ var keyExistColumnMap = {};
11
+ colorRules.forEach(function (colorRule) {
12
+ colorRule.filters.forEach(function (filter) {
13
+ var filterType = filter.filter_type;
14
+ if (keyExistColumnMap[filterType]) {
15
+ return;
16
+ }
17
+ columns.push({
18
+ key: COLOR_RULE_FILTER_TYPE_MAP.NUMERIC_VALUE,
19
+ type: FILTER_TYPE_2_CELL_TYPE[filterType]
20
+ });
21
+ keyExistColumnMap[filterType] = true;
22
+ });
23
+ });
24
+ return colorRules.map(function (colorRule) {
25
+ var filters = colorRule.filters;
26
+ var convertedFilters = filters.map(function (filter) {
27
+ return _objectSpread(_objectSpread({}, filter), {}, {
28
+ column_key: filter.filter_type
29
+ });
30
+ });
31
+ var validFilters = getValidFilters(convertedFilters, columns);
32
+ if (validFilters.length === 0) {
33
+ return null;
34
+ }
35
+ return _objectSpread(_objectSpread({}, colorRule), {}, {
36
+ filters: validFilters
37
+ });
38
+ }).filter(Boolean);
39
+ };
40
+ export var getConvertedColorRules = function getConvertedColorRules(colorRules) {
41
+ var validColorRules = getValidColorRules(colorRules);
42
+ return validColorRules.map(function (colorRule) {
43
+ var convertedFilters = colorRule.filters.map(function (filter) {
44
+ var filter_type = filter.filter_type;
45
+ return _objectSpread(_objectSpread({}, filter), {}, {
46
+ column_key: filter_type,
47
+ column: {
48
+ key: filter_type,
49
+ type: FILTER_TYPE_2_CELL_TYPE[filter_type]
50
+ }
51
+ });
52
+ });
53
+ return _objectSpread(_objectSpread({}, colorRule), {}, {
54
+ filters: convertedFilters
55
+ });
56
+ });
57
+ };
58
+ export var getLabelColorFromSpecificColor = function getLabelColorFromSpecificColor(chart) {
59
+ switch (chart.type) {
60
+ case STAT_TYPE.BAR:
61
+ {
62
+ return chart.y_axis_label_color;
63
+ }
64
+ case STAT_TYPE.HORIZONTAL_BAR:
65
+ {
66
+ return chart.horizontal_axis_label_color;
67
+ }
68
+ default:
69
+ {
70
+ return null;
71
+ }
72
+ }
73
+ };
74
+ export var getLabelColorFromColorRules = function getLabelColorFromColorRules(colorRules, value) {
75
+ if (!colorRules) {
76
+ return null;
77
+ }
78
+ var row = {
79
+ 'numeric_value': value
80
+ };
81
+ var matchedRuleColor = null;
82
+ for (var i = 0, colorRulesLen = colorRules.length; i < colorRulesLen; i++) {
83
+ var colorRule = colorRules[i];
84
+ var color = colorRule.color,
85
+ filter_conjunction = colorRule.filter_conjunction,
86
+ filters = colorRule.filters;
87
+ if (filterRow(row, filter_conjunction, filters)) {
88
+ matchedRuleColor = color;
89
+ break;
90
+ }
91
+ }
92
+ return matchedRuleColor;
93
+ };
94
+ export var getLabelColor = function getLabelColor(_ref) {
95
+ var chart = _ref.chart,
96
+ colorRules = _ref.colorRules,
97
+ value = _ref.value;
98
+ switch (chart.color_option) {
99
+ case TYPE_COLOR_USING.USE_SPECIFIC_COLORS:
100
+ {
101
+ return getLabelColorFromSpecificColor(chart);
102
+ }
103
+ case TYPE_COLOR_USING.USE_RULES:
104
+ {
105
+ return getLabelColorFromColorRules(colorRules, value);
106
+ }
107
+ default:
108
+ {
109
+ return null;
110
+ }
111
+ }
112
+ };
@@ -0,0 +1,18 @@
1
+ import { CellType } from 'dtable-store';
2
+ export function getColorFromSingleSelectColumn(column, target) {
3
+ var columnType = column.type,
4
+ columnData = column.data;
5
+ if (columnType !== CellType.SINGLE_SELECT) {
6
+ return null;
7
+ }
8
+ var options = columnData ? columnData.options : [];
9
+ var selectedOption = options.find(function (option) {
10
+ var id = target;
11
+ if (Array.isArray(target)) {
12
+ id = target[0];
13
+ }
14
+ return option.id === id;
15
+ });
16
+ var color = selectedOption && selectedOption.color;
17
+ return color || null;
18
+ }
@@ -0,0 +1,13 @@
1
+ import { DEFAULT_DATE_FORMAT } from 'dtable-store';
2
+ export function getSelectColumnOptions(column) {
3
+ if (!column || !column.data || !Array.isArray(column.data.options)) {
4
+ return [];
5
+ }
6
+ return column.data.options;
7
+ }
8
+ export function getDateColumnFormat(column) {
9
+ var format = column && column.data && column.data.format ? column.data.format : DEFAULT_DATE_FORMAT;
10
+ // Old Europe format is D/M/YYYY new format is DD/MM/YYYY
11
+ format = format.replace(/D\/M\/YYYY/, 'DD/MM/YYYY');
12
+ return format;
13
+ }