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,214 @@
1
+ .statistic-color-rule-filters {
2
+ min-height: 120px;
3
+ max-height: 100%;
4
+ padding: 8px 15px;
5
+ }
6
+
7
+ .statistic-color-rule-filters .selected-option {
8
+ align-self: stretch;
9
+ }
10
+
11
+ .statistic-color-rule-filters .filter-item {
12
+ display: flex;
13
+ align-items: center;
14
+ padding: .25rem 12px .25rem 12px;
15
+ }
16
+
17
+ .statistic-color-rule-filters .filter-item .condition {
18
+ display: flex;
19
+ flex: 1;
20
+ }
21
+
22
+ .statistic-color-rule-filters .filter-item .condition>div {
23
+ margin-left: .5rem;
24
+ }
25
+
26
+ .statistic-color-rule-filters .filter-item .condition>div:first-child {
27
+ margin-left: 0;
28
+ }
29
+
30
+ .statistic-color-rule-filters .filter-item .filter-term {
31
+ max-width: 300px;
32
+ }
33
+
34
+ .statistic-color-rule-filters .filter-item .dtable-font {
35
+ font-size: 12px;
36
+ color: #747474;
37
+ }
38
+
39
+ .statistic-color-rule-filters .filter-item .dtable-font:hover {
40
+ color: #000;
41
+ }
42
+
43
+ .statistic-color-rule-filters .filter-conjunction {
44
+ width: 72px;
45
+ }
46
+
47
+ .statistic-color-rule-filters .filter-conjunction-readonly {
48
+ width: 52px;
49
+ }
50
+
51
+ .statistic-color-rule-filters .filter-container {
52
+ width : calc(100% - 72px);
53
+ display: flex;
54
+ }
55
+
56
+ .statistic-color-rule-filters .selected-option-show {
57
+ width: calc(100% - 20px);
58
+ height: 20px;
59
+ line-height: 20px;
60
+ }
61
+
62
+ .statistic-color-rule-filters .selected-option {
63
+ width: auto;
64
+ overflow-x: auto;
65
+ background-color: #f5f5f5;
66
+ }
67
+
68
+ .statistic-color-rule-filters .dtable-icon-drop-down {
69
+ margin-left: .5rem;
70
+ }
71
+
72
+ .statistic-color-rule-filters .selected-conjunction-show {
73
+ padding: 0 10px;
74
+ color: #999;
75
+ }
76
+
77
+ .statistic-color-rule-filters .filter-column {
78
+ max-width: 150px;
79
+ }
80
+
81
+ .filter-column .option:hover .filter-header-icon .dtable-font {
82
+ color: #fff;
83
+ }
84
+
85
+ .statistic-color-rule-filters .filter-term input {
86
+ display: flex;
87
+ width: 100%;
88
+ height: 30px;
89
+ background-color: #ffffff;
90
+ padding-left: 8px;
91
+ padding-right: 8px;
92
+ outline: none;
93
+ border-radius: 3px;
94
+ font-size: 0.875rem;
95
+ }
96
+
97
+ .statistic-color-rule-filters .custom-select:hover,
98
+ .statistic-color-rule-filters .filter-term input:hover {
99
+ border-color: rgb(179, 179, 179);
100
+ }
101
+
102
+ .statistic-color-rule-filters .filter-term input.disabled:hover {
103
+ border-color: rgba(0, 40, 100, 0.12);
104
+ }
105
+
106
+ .statistic-color-rule-filters .filter-term input:hover:focus {
107
+ border-color: #1991eb;
108
+ }
109
+
110
+ .statistic-color-rule-filters .filter-term input:focus {
111
+ color: #495057;
112
+ background-color: #fff;
113
+ border-color: #1991eb;
114
+ outline: 0;
115
+ box-shadow: 0 0 0 2px rgba(70, 127, 207, 0.25);
116
+ }
117
+
118
+ .statistic-color-rule-filters .filter-term .date-picker-container input:focus {
119
+ color: #495057;
120
+ background-color: #fff;
121
+ border: 1px solid #fff;
122
+ outline: 0;
123
+ }
124
+
125
+ .statistic-color-rule-filters .filter-term .date-picker-container table tr {
126
+ height: 30px;
127
+ }
128
+
129
+ .statistic-color-rule-filters .filter-term input[type='checkbox'] {
130
+ width: inherit;
131
+ }
132
+
133
+ .statistic-color-rule-filters .filter-term input[type='checkbox']:focus {
134
+ border: 0;
135
+ box-shadow: none;
136
+ }
137
+
138
+ .filter-term .filter-rate-list {
139
+ display: flex;
140
+ padding: 0 5px;
141
+ border: 1px solid rgba(0, 40, 100, 0.12);
142
+ }
143
+
144
+ .statistic-color-rule-filters .delete-filter {
145
+ width: 12px;
146
+ height: 20px;
147
+ margin-right: 14px;
148
+ text-align: center;
149
+ }
150
+
151
+ .statistic-color-rule-filters .delete-filter:hover {
152
+ cursor: pointer;
153
+ }
154
+
155
+ .statistic-color-rule-filters .delete-filter .dtable-icon-fork-number {
156
+ display: inline-block;
157
+ font-size: 12px;
158
+ color: #949494;
159
+ }
160
+
161
+ .statistic-color-rule-filters .popover-add-tool {
162
+ border-top: none;
163
+ color: #555555;
164
+ }
165
+
166
+ .statistic-color-rule-filters .popover-add-tool .popover-add-icon {
167
+ margin-right: 14px;
168
+ }
169
+
170
+ .statistic-color-rule-filters .option-group {
171
+ max-height: 360px;
172
+ overflow: auto;
173
+ }
174
+
175
+ .statistic-color-rule-filters .filter-item .dtable-icon-fork-number:hover {
176
+ color: #5a5a5a;
177
+ }
178
+
179
+ .statistic-color-rule-filters .filter-container-readonly .selected-option-show,
180
+ .statistic-color-rule-filters .filter-conjunction-readonly .selected-option-show {
181
+ width: 100%;
182
+ }
183
+
184
+ .statistic-color-rule-filters .selected-option-show .remove-container {
185
+ display: none;
186
+ }
187
+
188
+ .filter-header-icon {
189
+ display: inline-block;
190
+ padding: 0 0.3125rem;
191
+ margin-left: -0.3125rem;
192
+ }
193
+
194
+ .filter-header-icon .dtable-font {
195
+ font-size: 14px;
196
+ color: #aaa;
197
+ cursor: default;
198
+ }
199
+
200
+ .statistic-color-rule-filters .custom-select,
201
+ .statistic-color-rule-filters .filter-term,
202
+ .statistic-color-rule-filters .filter-term input,
203
+ .statistic-color-rule-filters .filter-item .condition>div,
204
+ .statistic-color-rule-filters .filter-item .filter-term input:focus {
205
+ height: 30px;
206
+ line-height: 30px;
207
+ background-color: #f5f5f5;
208
+ border-color: rgba(0, 40, 100, 0.12);
209
+ box-shadow: unset;
210
+ }
211
+
212
+ .statistic-color-rule-filters .dtable-select .selected-option {
213
+ background-color: transparent;
214
+ }
@@ -0,0 +1,97 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
4
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
5
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
+ import React, { Component } from 'react';
7
+ import classnames from 'classnames';
8
+ import intl from 'react-intl-universal';
9
+ import Filter from './filter';
10
+ import { DISPLAY_COLOR_RULE_FILTER_TYPE } from '../../../../constants/color-rules';
11
+ import './index.css';
12
+ var RuleFilters = /*#__PURE__*/function (_Component) {
13
+ _inherits(RuleFilters, _Component);
14
+ var _super = _createSuper(RuleFilters);
15
+ function RuleFilters(props) {
16
+ var _this;
17
+ _classCallCheck(this, RuleFilters);
18
+ _this = _super.call(this, props);
19
+ _this.generateConjunctionOptions = function () {
20
+ _this.conjunctionOptions = [{
21
+ value: 'And',
22
+ label: /*#__PURE__*/React.createElement("span", {
23
+ className: "select-option-name"
24
+ }, intl.get('And'))
25
+ }, {
26
+ value: 'Or',
27
+ label: /*#__PURE__*/React.createElement("span", {
28
+ className: "select-option-name"
29
+ }, intl.get('Or'))
30
+ }];
31
+ };
32
+ _this.generateFilterTypeOptions = function (_ref) {
33
+ var filterTypes = _ref.filterTypes;
34
+ _this.filterTypeOptions = filterTypes.map(function (filterType) {
35
+ return {
36
+ value: filterType,
37
+ label: /*#__PURE__*/React.createElement("span", {
38
+ className: "select-option-name"
39
+ }, intl.get(DISPLAY_COLOR_RULE_FILTER_TYPE[filterTypes]))
40
+ };
41
+ });
42
+ };
43
+ _this.deleteFilter = function (index) {
44
+ var filters = _this.props.filters;
45
+ var updatedFilters = _toConsumableArray(filters);
46
+ updatedFilters.splice(index, 1);
47
+ _this.props.updateFilters(updatedFilters);
48
+ };
49
+ _this.updateFilter = function (index, updatedFilter) {
50
+ var filters = _this.props.filters;
51
+ var updatedFilters = _toConsumableArray(filters);
52
+ updatedFilters[index] = updatedFilter;
53
+ _this.props.updateFilters(updatedFilters);
54
+ };
55
+ _this.renderFilter = function (filter, index) {
56
+ var filterConjunction = _this.props.filterConjunction;
57
+ return /*#__PURE__*/React.createElement(Filter, {
58
+ key: index,
59
+ index: index,
60
+ filter: filter,
61
+ filterConjunction: filterConjunction,
62
+ conjunctionOptions: _this.conjunctionOptions,
63
+ filterTypeOptions: _this.filterTypeOptions,
64
+ getFilterConfigByType: _this.props.getFilterConfigByType,
65
+ modifyConjunction: _this.props.modifyConjunction,
66
+ deleteFilter: _this.deleteFilter,
67
+ updateFilter: _this.updateFilter
68
+ });
69
+ };
70
+ _this.generateConjunctionOptions();
71
+ _this.generateFilterTypeOptions(props);
72
+ return _this;
73
+ }
74
+ _createClass(RuleFilters, [{
75
+ key: "UNSAFE_componentWillReceiveProps",
76
+ value: function UNSAFE_componentWillReceiveProps(nextProps) {
77
+ if (nextProps.filterTypes !== this.props.filterTypes) {
78
+ this.generateFilterTypeOptions(nextProps);
79
+ }
80
+ }
81
+ }, {
82
+ key: "render",
83
+ value: function render() {
84
+ var _this2 = this;
85
+ var _this$props = this.props,
86
+ filters = _this$props.filters,
87
+ className = _this$props.className;
88
+ return /*#__PURE__*/React.createElement("div", {
89
+ className: classnames('statistic-color-rule-filters', className)
90
+ }, filters.map(function (filter, index) {
91
+ return _this2.renderFilter(filter, index);
92
+ }));
93
+ }
94
+ }]);
95
+ return RuleFilters;
96
+ }(Component);
97
+ export default RuleFilters;
@@ -0,0 +1,85 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
4
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
+ /**
6
+ * support type number with format
7
+ */
8
+ import React, { Component } from 'react';
9
+ import { DEFAULT_NUMBER_FORMAT, formatStringToNumber, getNumberDisplayString, replaceNumberNotAllowInput } from 'dtable-store';
10
+ var NumberInput = /*#__PURE__*/function (_Component) {
11
+ _inherits(NumberInput, _Component);
12
+ var _super = _createSuper(NumberInput);
13
+ function NumberInput(props) {
14
+ var _this;
15
+ _classCallCheck(this, NumberInput);
16
+ _this = _super.call(this, props);
17
+ _this.getInitValue = function () {
18
+ var value = _this.props.value;
19
+ var numericValue = null;
20
+ var valueType = typeof value;
21
+ if (valueType === 'number') {
22
+ numericValue = value;
23
+ } else if (valueType === 'string') {
24
+ numericValue = formatStringToNumber(value, {});
25
+ }
26
+ if (!numericValue && numericValue !== 0) {
27
+ return '';
28
+ }
29
+ return getNumberDisplayString(numericValue, {}) || '';
30
+ };
31
+ _this.onChange = function (evt) {
32
+ var value = replaceNumberNotAllowInput(evt.target.value.trim(), DEFAULT_NUMBER_FORMAT, null);
33
+ _this.setState({
34
+ value: value
35
+ }, function () {
36
+ _this.props.onChange(formatStringToNumber(value, {}));
37
+ });
38
+ };
39
+ _this.onPaste = function (evt) {
40
+ evt.stopPropagation();
41
+ };
42
+ _this.state = {
43
+ value: _this.getInitValue()
44
+ };
45
+ return _this;
46
+ }
47
+ _createClass(NumberInput, [{
48
+ key: "componentDidUpdate",
49
+ value: function componentDidUpdate(prevProps) {
50
+ if (this.props.value !== prevProps.value) {
51
+ this.setState({
52
+ value: this.getInitValue()
53
+ });
54
+ }
55
+ }
56
+ }, {
57
+ key: "render",
58
+ value: function render() {
59
+ var _this2 = this;
60
+ var _this$props = this.props,
61
+ placeholder = _this$props.placeholder,
62
+ disabled = _this$props.disabled,
63
+ autoFocus = _this$props.autoFocus;
64
+ return /*#__PURE__*/React.createElement("input", {
65
+ ref: function ref(_ref) {
66
+ return _this2.input = _ref;
67
+ },
68
+ type: "text",
69
+ className: "form-control",
70
+ value: this.state.value,
71
+ onChange: this.onChange,
72
+ onPaste: this.onPaste,
73
+ placeholder: placeholder || '',
74
+ autoFocus: autoFocus,
75
+ disabled: disabled
76
+ });
77
+ }
78
+ }]);
79
+ return NumberInput;
80
+ }(Component);
81
+ NumberInput.defaultProps = {
82
+ autoFocus: false,
83
+ disabled: false
84
+ };
85
+ export default NumberInput;
@@ -0,0 +1,213 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
4
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
5
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
+ import React, { Component } from 'react';
7
+ import classnames from 'classnames';
8
+ import intl from 'react-intl-universal';
9
+ import { CellType, FILTER_COLUMN_OPTIONS } from 'dtable-store';
10
+ import { CommonAddTool, DTablePopover } from '../index';
11
+ import ColorRules from './color-rules';
12
+ import { COLOR_RULE_FILTER_TYPE_MAP, DISPLAY_COLOR_RULE_FILTER_TYPE, EMPTY_PREDICATE } from '../../constants/color-rules';
13
+ import '../../assets/css/color-rules-popover.css';
14
+ var SAFE_DISTANCE_2_BOTTOM = 30; // Keep the distance to the bottom
15
+ var ColorRulesPopover = /*#__PURE__*/function (_Component) {
16
+ _inherits(ColorRulesPopover, _Component);
17
+ var _super = _createSuper(ColorRulesPopover);
18
+ function ColorRulesPopover(props) {
19
+ var _this;
20
+ _classCallCheck(this, ColorRulesPopover);
21
+ _this = _super.call(this, props);
22
+ _this.getColorConfigByColor = function (color) {
23
+ return _this.props.labelColorConfigs.find(function (colorConfig) {
24
+ return colorConfig.color === color;
25
+ }) || {};
26
+ };
27
+ _this.getFilterDisplay = function (filter) {
28
+ var filter_type = filter.filter_type,
29
+ filter_predicate = filter.filter_predicate,
30
+ filter_term = filter.filter_term;
31
+ var name = DISPLAY_COLOR_RULE_FILTER_TYPE[filter_type];
32
+ var template = "".concat(intl.get(name), " ").concat(intl.get(filter_predicate));
33
+ if (EMPTY_PREDICATE.includes(filter_predicate)) {
34
+ return template;
35
+ }
36
+ switch (filter_type) {
37
+ case COLOR_RULE_FILTER_TYPE_MAP.NUMERIC_VALUE:
38
+ {
39
+ if (filter_term === 0) {
40
+ return "".concat(template, " 0");
41
+ }
42
+ if (!filter_term) {
43
+ return null;
44
+ }
45
+ return "".concat(template, " ").concat(filter_term);
46
+ }
47
+ default:
48
+ {
49
+ return null;
50
+ }
51
+ }
52
+ };
53
+ _this.getRuleName = function (filters, filterConjunction) {
54
+ if (filters.length === 0) return '';
55
+ var contentText = '';
56
+ filterConjunction = filterConjunction || 'And';
57
+ filters.forEach(function (filter, index) {
58
+ var filterContentText = index === 0 ? '' : " ".concat(filterConjunction === 'And' ? intl.get('And') : intl.get('Or'));
59
+ var filterDisplay = _this.getFilterDisplay(filter);
60
+ if (filterDisplay) {
61
+ contentText = contentText + filterContentText + " ".concat(filterDisplay);
62
+ }
63
+ });
64
+ return contentText;
65
+ };
66
+ _this.getRulesName = function () {
67
+ var colorRules = _this.state.colorRules;
68
+ return colorRules.map(function (rule) {
69
+ var filters = rule.filters,
70
+ filter_conjunction = rule.filter_conjunction;
71
+ return _this.getRuleName(filters, filter_conjunction);
72
+ });
73
+ };
74
+ _this.getFilterConfigByType = function (filterType) {
75
+ if (!filterType) {
76
+ return {};
77
+ }
78
+ switch (filterType) {
79
+ case COLOR_RULE_FILTER_TYPE_MAP.NUMERIC_VALUE:
80
+ {
81
+ return FILTER_COLUMN_OPTIONS[CellType.NUMBER];
82
+ }
83
+ default:
84
+ {
85
+ return {};
86
+ }
87
+ }
88
+ };
89
+ _this.generateDefaultFilter = function (filterType) {
90
+ var _this$getFilterConfig = _this.getFilterConfigByType(filterType),
91
+ filterPredicateList = _this$getFilterConfig.filterPredicateList;
92
+ if (!filterPredicateList) {
93
+ return null;
94
+ }
95
+ var filterPredicate = filterPredicateList[0];
96
+ return {
97
+ filter_type: filterType,
98
+ filter_predicate: filterPredicate,
99
+ filter_term: null
100
+ };
101
+ };
102
+ _this.addRule = function () {
103
+ var _this$props = _this.props,
104
+ colorRuleTypes = _this$props.colorRuleTypes,
105
+ labelColorConfigs = _this$props.labelColorConfigs;
106
+ var colorRules = _this.state.colorRules;
107
+ var defaultRuleType = colorRuleTypes[0];
108
+ var defaultFilter = defaultRuleType && _this.generateDefaultFilter(defaultRuleType);
109
+ if (!defaultFilter) return;
110
+ var updatedColorRules = _toConsumableArray(colorRules);
111
+ var defaultColorConfig = labelColorConfigs[colorRules.length] || labelColorConfigs[0];
112
+ updatedColorRules.push({
113
+ color: defaultColorConfig.color,
114
+ filters: [defaultFilter],
115
+ filter_conjunction: 'And'
116
+ });
117
+ _this.updateColorRules({
118
+ colorRules: updatedColorRules,
119
+ callback: function callback() {
120
+ _this.resetPopoverPosition();
121
+ }
122
+ });
123
+ };
124
+ _this.resetPopoverPosition = function () {
125
+ // keep the popover is visible in current window
126
+ var popoverWrapper = _this.popover && _this.popover.dtablePopoverRef && _this.popover.dtablePopoverRef.parentNode.parentNode;
127
+ if (!popoverWrapper) return;
128
+ var bodyHeight = document.body.clientHeight;
129
+ var _popoverWrapper$getBo = popoverWrapper.getBoundingClientRect(),
130
+ top = _popoverWrapper$getBo.top,
131
+ height = _popoverWrapper$getBo.height;
132
+ var offsetTop = popoverWrapper.offsetTop;
133
+ var offsetHeight = top + height + SAFE_DISTANCE_2_BOTTOM - bodyHeight;
134
+
135
+ // popover within the current window
136
+ if (offsetHeight < 0) {
137
+ return;
138
+ }
139
+ setTimeout(function () {
140
+ if (popoverWrapper) {
141
+ popoverWrapper.style.top = "".concat(-offsetHeight + offsetTop, "px");
142
+ }
143
+ }, 300);
144
+ };
145
+ _this.updateColorRules = function (_ref) {
146
+ var colorRules = _ref.colorRules,
147
+ callback = _ref.callback;
148
+ _this.setState({
149
+ colorRules: colorRules
150
+ }, function () {
151
+ callback && callback();
152
+ });
153
+ };
154
+ _this.hideColorRulesPopover = function () {
155
+ _this.props.updateColorRules(_this.state.colorRules);
156
+ _this.props.hideColorRulesPopover();
157
+ };
158
+ _this.state = {
159
+ colorRules: props.colorRules || []
160
+ };
161
+ return _this;
162
+ }
163
+ _createClass(ColorRulesPopover, [{
164
+ key: "render",
165
+ value: function render() {
166
+ var _this2 = this;
167
+ var _this$props2 = this.props,
168
+ target = _this$props2.target,
169
+ labelColorConfigs = _this$props2.labelColorConfigs,
170
+ colorRuleTypes = _this$props2.colorRuleTypes;
171
+ var colorRules = this.state.colorRules;
172
+ var hasRules = colorRules && colorRules.length > 0;
173
+ var rulesName = this.getRulesName();
174
+ var canAddRule = !rulesName.some(function (ruleName) {
175
+ return !ruleName;
176
+ });
177
+ return /*#__PURE__*/React.createElement(DTablePopover, {
178
+ hideArrow: true,
179
+ target: target,
180
+ placement: "left-end",
181
+ ref: function ref(_ref2) {
182
+ return _this2.popover = _ref2;
183
+ },
184
+ boundariesElement: document.body,
185
+ popoverClassName: "statistic-color-rules-popover",
186
+ hideDTablePopover: this.hideColorRulesPopover,
187
+ hideDTablePopoverWithEsc: this.hideColorRulesPopover
188
+ }, /*#__PURE__*/React.createElement("div", {
189
+ className: "statistic-color-rules-wrapper"
190
+ }, !hasRules && /*#__PURE__*/React.createElement("div", {
191
+ className: "no-color-rules"
192
+ }, intl.get('No_rules')), /*#__PURE__*/React.createElement(ColorRules, {
193
+ rules: colorRules,
194
+ rulesName: rulesName,
195
+ labelColorConfigs: labelColorConfigs,
196
+ colorRuleTypes: colorRuleTypes,
197
+ getColorConfigByColor: this.getColorConfigByColor,
198
+ getFilterConfigByType: this.getFilterConfigByType,
199
+ generateDefaultFilter: this.generateDefaultFilter,
200
+ updateRules: this.updateColorRules,
201
+ resetPopoverPosition: this.resetPopoverPosition
202
+ }), /*#__PURE__*/React.createElement(CommonAddTool, {
203
+ className: classnames('statistic-btn-add-color-rule', {
204
+ 'disabled': !canAddRule
205
+ }),
206
+ footerName: intl.get('Add_rule'),
207
+ callBack: canAddRule ? this.addRule : function () {}
208
+ })));
209
+ }
210
+ }]);
211
+ return ColorRulesPopover;
212
+ }(Component);
213
+ export default ColorRulesPopover;
@@ -0,0 +1,85 @@
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 { DTablePopover } from '../index';
8
+ import { hexToRgb } from '../../utils';
9
+ var ColorSelectorPopover = /*#__PURE__*/function (_Component) {
10
+ _inherits(ColorSelectorPopover, _Component);
11
+ var _super = _createSuper(ColorSelectorPopover);
12
+ function ColorSelectorPopover(props) {
13
+ var _this;
14
+ _classCallCheck(this, ColorSelectorPopover);
15
+ _this = _super.call(this, props);
16
+ _this.initColorOptions = function () {
17
+ var colorConfigs = _this.props.colorConfigs;
18
+ _this.colorOptions = colorConfigs.map(function (colorOption) {
19
+ if (!colorOption.border_color) {
20
+ var _hexToRgb = hexToRgb(colorOption.color),
21
+ r = _hexToRgb.r,
22
+ g = _hexToRgb.g,
23
+ b = _hexToRgb.b;
24
+ return _objectSpread(_objectSpread({}, colorOption), {}, {
25
+ border_color: "rgb(".concat(Math.max(r - 20, 0), ", ").concat(Math.max(g - 20, 0), ", ").concat(Math.max(b - 20, 0), ")")
26
+ });
27
+ }
28
+ return colorOption;
29
+ });
30
+ };
31
+ _this.onSelectColor = function (color) {
32
+ _this.props.onSelectColor(color);
33
+ _this.props.toggle();
34
+ };
35
+ _this.initColorOptions();
36
+ return _this;
37
+ }
38
+ _createClass(ColorSelectorPopover, [{
39
+ key: "render",
40
+ value: function render() {
41
+ var _this2 = this;
42
+ var _this$props = this.props,
43
+ target = _this$props.target,
44
+ placement = _this$props.placement,
45
+ hideArrow = _this$props.hideArrow,
46
+ selectedColor = _this$props.selectedColor;
47
+ var upperCaseSelectedColor = selectedColor.toUpperCase();
48
+ return /*#__PURE__*/React.createElement(DTablePopover, {
49
+ target: target,
50
+ placement: placement || 'auto-start',
51
+ hideArrow: hideArrow,
52
+ popoverClassName: "statistic-color-selector",
53
+ hideDTablePopover: this.props.toggle,
54
+ hideDTablePopoverWithEsc: this.props.toggle
55
+ }, /*#__PURE__*/React.createElement("div", {
56
+ className: "statistic-color-selector-wrapper"
57
+ }, this.colorOptions.map(function (colorOption) {
58
+ var color = colorOption.color,
59
+ border_color = colorOption.border_color,
60
+ text_color = colorOption.text_color;
61
+ return /*#__PURE__*/React.createElement("div", {
62
+ key: "statistic-color-option-".concat(color),
63
+ className: "statistic-color-option",
64
+ onClick: function onClick() {
65
+ return _this2.onSelectColor(color);
66
+ },
67
+ style: {
68
+ backgroundColor: color,
69
+ borderColor: border_color
70
+ }
71
+ }, color === upperCaseSelectedColor && /*#__PURE__*/React.createElement("i", {
72
+ className: "dtable-font dtable-icon-check-mark",
73
+ style: {
74
+ color: text_color
75
+ }
76
+ }));
77
+ })));
78
+ }
79
+ }]);
80
+ return ColorSelectorPopover;
81
+ }(Component);
82
+ ColorSelectorPopover.defaultProps = {
83
+ hideArrow: true
84
+ };
85
+ export default ColorSelectorPopover;