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,157 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
4
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
+ import React, { Component } from 'react';
6
+ import classnames from 'classnames';
7
+ import ModalPortal from '../modal-portal';
8
+ import OptGroup from './option-group';
9
+ import { CommonEventTypes } from '../../constants';
10
+ import './select.css';
11
+ var Select = /*#__PURE__*/function (_Component) {
12
+ _inherits(Select, _Component);
13
+ var _super = _createSuper(Select);
14
+ function Select(props) {
15
+ var _this;
16
+ _classCallCheck(this, Select);
17
+ _this = _super.call(this, props);
18
+ _this.onSelectToggle = function (event) {
19
+ event.preventDefault();
20
+ /*
21
+ if select is showing, click events do not need to be monitored by other click events,
22
+ so it can be closed when other select is clicked.
23
+ */
24
+ if (_this.state.isShowSelectOptions) event.nativeEvent.stopImmediatePropagation();
25
+ var eventClassName = event.target.className;
26
+ if (_this.props.isLocked || eventClassName.indexOf('option-search-control') > -1 || eventClassName === 'option-group-search') return;
27
+ //Prevent closing by pressing the spacebar in the search input
28
+ if (event.target.value === '') return;
29
+ _this.setState({
30
+ isShowSelectOptions: !_this.state.isShowSelectOptions
31
+ });
32
+ window.app.eventBus.dispatch(CommonEventTypes.OPEN_SELECT, !_this.state.isShowSelectOptions);
33
+ };
34
+ _this.onClick = function (event) {
35
+ if (_this.props.isShowSelected && event.target.className.includes('icon-fork-number')) {
36
+ return;
37
+ }
38
+ if (!_this.selector.contains(event.target)) {
39
+ _this.closeSelect();
40
+ }
41
+ };
42
+ _this.closeSelect = function () {
43
+ _this.setState({
44
+ isShowSelectOptions: false
45
+ });
46
+ };
47
+ _this.getSelectedOptionTop = function () {
48
+ if (!_this.selector) return 38;
49
+ var _this$selector$getBou = _this.selector.getBoundingClientRect(),
50
+ height = _this$selector$getBou.height;
51
+ return height;
52
+ };
53
+ _this.getFilterOptions = function (searchValue) {
54
+ var _this$props = _this.props,
55
+ options = _this$props.options,
56
+ searchable = _this$props.searchable;
57
+ if (!searchable) return options || [];
58
+ var validSearchVal = searchValue.trim().toLowerCase();
59
+ if (!validSearchVal) return options || [];
60
+ return options.filter(function (option) {
61
+ var value = option.value,
62
+ name = option.name;
63
+ if (typeof name === 'string') {
64
+ return name.toLowerCase().indexOf(validSearchVal) > -1;
65
+ }
66
+ if (typeof value === 'object') {
67
+ if (value.column) {
68
+ return value.column.name.toLowerCase().indexOf(validSearchVal) > -1;
69
+ }
70
+ if (value.name) {
71
+ return value.name.toLowerCase().indexOf(validSearchVal) > -1;
72
+ }
73
+ return value.columnOption && value.columnOption.name.toLowerCase().indexOf(validSearchVal) > -1;
74
+ }
75
+ return false;
76
+ });
77
+ };
78
+ _this.state = {
79
+ isShowSelectOptions: false
80
+ };
81
+ return _this;
82
+ }
83
+ _createClass(Select, [{
84
+ key: "componentDidMount",
85
+ value: function componentDidMount() {
86
+ document.addEventListener('click', this.onClick);
87
+ }
88
+ }, {
89
+ key: "componentWillUnmount",
90
+ value: function componentWillUnmount() {
91
+ document.removeEventListener('click', this.onClick);
92
+ }
93
+ }, {
94
+ key: "render",
95
+ value: function render() {
96
+ var _this2 = this;
97
+ var _this$props2 = this.props,
98
+ className = _this$props2.className,
99
+ value = _this$props2.value,
100
+ options = _this$props2.options,
101
+ placeholder = _this$props2.placeholder,
102
+ searchable = _this$props2.searchable,
103
+ searchPlaceholder = _this$props2.searchPlaceholder,
104
+ noOptionsPlaceholder = _this$props2.noOptionsPlaceholder,
105
+ isLocked = _this$props2.isLocked,
106
+ isInModal = _this$props2.isInModal;
107
+ return /*#__PURE__*/React.createElement("div", {
108
+ ref: function ref(node) {
109
+ return _this2.selector = node;
110
+ },
111
+ className: classnames('dtable-select custom-select', {
112
+ 'focus': this.state.isShowSelectOptions
113
+ }, {
114
+ 'disabled': isLocked
115
+ }, className),
116
+ onClick: this.onSelectToggle
117
+ }, /*#__PURE__*/React.createElement("div", {
118
+ className: "selected-option"
119
+ }, value.label ? /*#__PURE__*/React.createElement("span", {
120
+ className: "selected-option-show"
121
+ }, value.label) : /*#__PURE__*/React.createElement("span", {
122
+ className: "select-placeholder"
123
+ }, placeholder), !isLocked && /*#__PURE__*/React.createElement("i", {
124
+ className: "dtable-font dtable-icon-drop-down"
125
+ })), this.state.isShowSelectOptions && !isInModal && /*#__PURE__*/React.createElement(OptGroup, {
126
+ value: value,
127
+ isShowSelected: this.props.isShowSelected,
128
+ top: this.getSelectedOptionTop(),
129
+ options: options,
130
+ onSelectOption: this.props.onSelectOption,
131
+ searchable: searchable,
132
+ searchPlaceholder: searchPlaceholder,
133
+ noOptionsPlaceholder: noOptionsPlaceholder,
134
+ closeSelect: this.closeSelect,
135
+ getFilterOptions: this.getFilterOptions,
136
+ supportMultipleSelect: this.props.supportMultipleSelect
137
+ }), this.state.isShowSelectOptions && isInModal && /*#__PURE__*/React.createElement(ModalPortal, null, /*#__PURE__*/React.createElement(OptGroup, {
138
+ className: className,
139
+ value: value,
140
+ isShowSelected: this.props.isShowSelected,
141
+ position: this.selector.getBoundingClientRect(),
142
+ isInModal: isInModal,
143
+ top: this.getSelectedOptionTop(),
144
+ options: options,
145
+ onSelectOption: this.props.onSelectOption,
146
+ searchable: searchable,
147
+ searchPlaceholder: searchPlaceholder,
148
+ noOptionsPlaceholder: noOptionsPlaceholder,
149
+ closeSelect: this.closeSelect,
150
+ getFilterOptions: this.getFilterOptions,
151
+ supportMultipleSelect: this.props.supportMultipleSelect
152
+ })));
153
+ }
154
+ }]);
155
+ return Select;
156
+ }(Component);
157
+ export default Select;
@@ -0,0 +1,130 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
4
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
+ import React from 'react';
6
+ import { css } from 'glamor';
7
+ var Alert = /*#__PURE__*/function (_React$PureComponent) {
8
+ _inherits(Alert, _React$PureComponent);
9
+ var _super = _createSuper(Alert);
10
+ function Alert(props) {
11
+ var _this;
12
+ _classCallCheck(this, Alert);
13
+ _this = _super.call(this, props);
14
+ _this.containerStyle = css({
15
+ borderRadius: '3px',
16
+ backgroundColor: '#fff',
17
+ padding: '10px 16px',
18
+ display: 'flex',
19
+ boxSizing: 'border-box',
20
+ boxShadow: 'rgba(67, 90, 111, 0.3) 0px 0px 1px, rgba(67, 90, 111, 0.47) 0px 8px 10px -4px',
21
+ justifyContent: 'space-between',
22
+ flexDirection: 'row'
23
+ });
24
+ _this.containerBorderSuccess = css({
25
+ borderLeft: '3px solid rgb(71, 184, 129)'
26
+ });
27
+ _this.containerBorderWarn = css({
28
+ borderLeft: '3px solid rgb(217, 130, 43)'
29
+ });
30
+ _this.containerBorderDanger = css({
31
+ borderLeft: '3px solid rgb(236, 76, 71)'
32
+ });
33
+ _this.containerBorderNotify = css({
34
+ borderLeft: '3px solid rgb(16, 112, 202)'
35
+ });
36
+ _this.toastTextTitle = css({
37
+ fontWeight: '600',
38
+ fontSize: '14px',
39
+ color: '#435a6f',
40
+ margin: '0'
41
+ });
42
+ _this.toastTextChild = css({
43
+ fontSize: '14px',
44
+ color: '#999',
45
+ margin: '0'
46
+ });
47
+ _this.toastClose = css({
48
+ marginLeft: '15px',
49
+ height: '24px',
50
+ width: '24px',
51
+ lineHeight: '22px',
52
+ fontWeight: '700',
53
+ textAlign: 'center',
54
+ fontSize: '20px',
55
+ color: '#000',
56
+ cursor: 'pointer',
57
+ opacity: '0.5',
58
+ ':hover': {
59
+ opacity: 1
60
+ }
61
+ });
62
+ _this.toastIcon = css({
63
+ marginRight: '10px',
64
+ width: '14px',
65
+ height: '20px',
66
+ lineHeight: '20px'
67
+ });
68
+ return _this;
69
+ }
70
+ _createClass(Alert, [{
71
+ key: "getContainerStyle",
72
+ value: function getContainerStyle(intent) {
73
+ switch (intent) {
74
+ case 'success':
75
+ return {
76
+ borderStyle: this.containerBorderSuccess,
77
+ iconColor: css({
78
+ color: 'rgb(71, 184, 129)'
79
+ }),
80
+ iconClass: 'dtable-font dtable-icon-check-circle'
81
+ };
82
+ case 'warning':
83
+ return {
84
+ borderStyle: this.containerBorderWarn,
85
+ iconColor: css({
86
+ color: 'rgb(217, 130, 43)'
87
+ }),
88
+ iconClass: 'dtable-font dtable-icon-exclamation-triangle'
89
+ };
90
+ case 'none':
91
+ return {
92
+ borderStyle: this.containerBorderNotify,
93
+ iconColor: css({
94
+ color: 'rgb(16, 112, 202)'
95
+ }),
96
+ iconClass: 'dtable-font dtable-icon-description'
97
+ };
98
+ case 'danger':
99
+ return {
100
+ borderStyle: this.containerBorderDanger,
101
+ iconColor: css({
102
+ color: 'rgb(236, 76, 71)'
103
+ }),
104
+ iconClass: 'dtable-font dtable-icon-exclamation-circle'
105
+ };
106
+ }
107
+ }
108
+ }, {
109
+ key: "render",
110
+ value: function render() {
111
+ var toastStyle = this.getContainerStyle(this.props.intent);
112
+ return /*#__PURE__*/React.createElement("div", css(toastStyle.borderStyle, this.containerStyle), /*#__PURE__*/React.createElement("div", {
113
+ className: this.toastIcon
114
+ }, /*#__PURE__*/React.createElement("i", Object.assign({
115
+ className: toastStyle.iconClass
116
+ }, toastStyle.iconColor))), /*#__PURE__*/React.createElement("div", {
117
+ className: this.toastTextContainer
118
+ }, /*#__PURE__*/React.createElement("p", {
119
+ className: this.toastTextTitle
120
+ }, this.props.title), this.props.children ? /*#__PURE__*/React.createElement("p", {
121
+ className: this.toastTextChild
122
+ }, this.props.children) : null), this.props.isRemoveable && /*#__PURE__*/React.createElement("div", {
123
+ onClick: this.props.onRemove,
124
+ className: this.toastClose
125
+ }, /*#__PURE__*/React.createElement("span", null, "\xD7")));
126
+ }
127
+ }]);
128
+ return Alert;
129
+ }(React.PureComponent);
130
+ export default Alert;
@@ -0,0 +1,3 @@
1
+ import Toaster from './toaster';
2
+ var toaster = new Toaster();
3
+ export default toaster;
@@ -0,0 +1,164 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
4
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
+ import React from 'react';
6
+ import { css } from 'glamor';
7
+ import Transition from 'react-transition-group/Transition';
8
+ import Alert from './alert';
9
+ var animationEasing = {
10
+ deceleration: 'cubic-bezier(0.0, 0.0, 0.2, 1)',
11
+ acceleration: 'cubic-bezier(0.4, 0.0, 1, 1)',
12
+ spring: 'cubic-bezier(0.175, 0.885, 0.320, 1.175)'
13
+ };
14
+ var ANIMATION_DURATION = 240;
15
+ var openAnimation = css.keyframes('openAnimation', {
16
+ from: {
17
+ opacity: 0,
18
+ transform: 'translateY(-120%)'
19
+ },
20
+ to: {
21
+ transform: 'translateY(0)'
22
+ }
23
+ });
24
+ var closeAnimation = css.keyframes('closeAnimation', {
25
+ from: {
26
+ transform: 'scale(1)',
27
+ opacity: 1
28
+ },
29
+ to: {
30
+ transform: 'scale(0.9)',
31
+ opacity: 0
32
+ }
33
+ });
34
+ var animationStyles = css({
35
+ display: 'flex',
36
+ flexDirection: 'column',
37
+ alignItems: 'center',
38
+ height: 0,
39
+ transition: "all ".concat(ANIMATION_DURATION, "ms ").concat(animationEasing.deceleration),
40
+ '&[data-state="entering"], &[data-state="entered"]': {
41
+ animation: "".concat(openAnimation, " ").concat(ANIMATION_DURATION, "ms ").concat(animationEasing.spring, " both")
42
+ },
43
+ '&[data-state="exiting"]': {
44
+ animation: "".concat(closeAnimation, " 120ms ").concat(animationEasing.acceleration, " both")
45
+ }
46
+ });
47
+ var Toast = /*#__PURE__*/function (_React$PureComponent) {
48
+ _inherits(Toast, _React$PureComponent);
49
+ var _super = _createSuper(Toast);
50
+ function Toast() {
51
+ var _this;
52
+ _classCallCheck(this, Toast);
53
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
54
+ args[_key] = arguments[_key];
55
+ }
56
+ _this = _super.call.apply(_super, [this].concat(args));
57
+ _this.state = {
58
+ isShown: true,
59
+ height: 0
60
+ };
61
+ _this.close = function (event) {
62
+ if (event) {
63
+ event.nativeEvent.stopImmediatePropagation();
64
+ event.stopPropagation();
65
+ }
66
+ _this.clearCloseTimer();
67
+ _this.setState({
68
+ isShown: false
69
+ });
70
+ };
71
+ _this.startCloseTimer = function () {
72
+ if (_this.props.duration) {
73
+ _this.closeTimer = setTimeout(function () {
74
+ _this.close();
75
+ }, _this.props.duration * 1000);
76
+ }
77
+ };
78
+ _this.clearCloseTimer = function () {
79
+ if (_this.closeTimer) {
80
+ clearTimeout(_this.closeTimer);
81
+ _this.closeTimer = null;
82
+ }
83
+ };
84
+ _this.handleMouseEnter = function () {
85
+ _this.clearCloseTimer();
86
+ };
87
+ _this.handleMouseLeave = function () {
88
+ _this.startCloseTimer();
89
+ };
90
+ _this.onRef = function (ref) {
91
+ if (ref === null) return;
92
+ var _ref$getBoundingClien = ref.getBoundingClientRect(),
93
+ height = _ref$getBoundingClien.height;
94
+ _this.setState({
95
+ height: height
96
+ });
97
+ };
98
+ return _this;
99
+ }
100
+ _createClass(Toast, [{
101
+ key: "componentDidUpdate",
102
+ value: function componentDidUpdate(prevProps) {
103
+ if (prevProps.isShown !== this.props.isShown) {
104
+ // eslint-disable-next-line react/no-did-update-set-state
105
+ this.setState({
106
+ isShown: this.props.isShown
107
+ });
108
+ }
109
+ }
110
+ }, {
111
+ key: "componentDidMount",
112
+ value: function componentDidMount() {
113
+ this.startCloseTimer();
114
+ }
115
+ }, {
116
+ key: "componentWillUnmount",
117
+ value: function componentWillUnmount() {
118
+ this.clearCloseTimer();
119
+ }
120
+ }, {
121
+ key: "render",
122
+ value: function render() {
123
+ var _this2 = this;
124
+ return /*#__PURE__*/React.createElement(Transition, {
125
+ appear: true,
126
+ unmountOnExit: true,
127
+ timeout: ANIMATION_DURATION,
128
+ in: this.state.isShown,
129
+ onExited: this.props.onRemove
130
+ }, function (state) {
131
+ return /*#__PURE__*/React.createElement("div", {
132
+ "data-state": state,
133
+ className: animationStyles,
134
+ onMouseEnter: _this2.handleMouseEnter,
135
+ onMouseLeave: _this2.handleMouseLeave,
136
+ style: {
137
+ height: _this2.state.height,
138
+ zIndex: _this2.props.zIndex,
139
+ marginBottom: _this2.state.isShown ? 0 : -_this2.state.height
140
+ }
141
+ }, /*#__PURE__*/React.createElement("div", {
142
+ ref: _this2.onRef,
143
+ style: {
144
+ padding: 8
145
+ }
146
+ }, /*#__PURE__*/React.createElement(Alert, {
147
+ intent: _this2.props.intent,
148
+ title: _this2.props.title,
149
+ "aria-label": _this2.props.title,
150
+ children: _this2.props.children || '',
151
+ isRemoveable: _this2.props.hasCloseButton,
152
+ onRemove: function onRemove(event) {
153
+ return _this2.close(event);
154
+ }
155
+ })));
156
+ });
157
+ }
158
+ }]);
159
+ return Toast;
160
+ }(React.PureComponent);
161
+ Toast.defaultProps = {
162
+ intent: 'none'
163
+ };
164
+ export { Toast as default };
@@ -0,0 +1,150 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
4
+ import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
5
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
6
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
7
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
8
+ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
9
+ var _excluded = ["id", "description"];
10
+ import React from 'react';
11
+ import { css } from 'glamor';
12
+ import Toast from './toast';
13
+ import { TOAST_MANAGER } from '../../constants/zIndexes';
14
+ var wrapperClass = css({
15
+ maxWidth: 560,
16
+ margin: '0 auto',
17
+ top: 0,
18
+ left: 0,
19
+ right: 0,
20
+ position: 'fixed',
21
+ zIndex: TOAST_MANAGER
22
+ });
23
+ var hasCustomId = function hasCustomId(settings) {
24
+ return Object.hasOwnProperty.call(settings, 'id');
25
+ };
26
+ var ToastManager = /*#__PURE__*/function (_React$PureComponent) {
27
+ _inherits(ToastManager, _React$PureComponent);
28
+ var _super = _createSuper(ToastManager);
29
+ function ToastManager(props, context) {
30
+ var _this;
31
+ _classCallCheck(this, ToastManager);
32
+ _this = _super.call(this, props, context);
33
+ _this.getToasts = function () {
34
+ return _this.state.toasts;
35
+ };
36
+ _this.closeAll = function () {
37
+ _this.getToasts().forEach(function (toast) {
38
+ return toast.close();
39
+ });
40
+ };
41
+ _this.notify = function (title, settings) {
42
+ // If there's a custom toast ID passed, close existing toasts with the same custom ID
43
+ if (hasCustomId(settings)) {
44
+ var _iterator = _createForOfIteratorHelper(_this.state.toasts),
45
+ _step;
46
+ try {
47
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
48
+ var toast = _step.value;
49
+ // Since unique ID is still appended to a custom ID, skip the unique ID and check only prefix
50
+ if (String(toast.id).startsWith(settings.id)) {
51
+ _this.closeToast(toast.id);
52
+ }
53
+ }
54
+ } catch (err) {
55
+ _iterator.e(err);
56
+ } finally {
57
+ _iterator.f();
58
+ }
59
+ }
60
+ var instance = _this.createToastInstance(title, settings);
61
+ _this.onClose = settings.onClose;
62
+ _this.setState(function (previousState) {
63
+ return {
64
+ toasts: [instance].concat(_toConsumableArray(previousState.toasts))
65
+ };
66
+ });
67
+ return instance;
68
+ };
69
+ _this.createToastInstance = function (title, settings) {
70
+ var uniqueId = ++ToastManager.idCounter;
71
+ var id = hasCustomId(settings) ? "".concat(settings.id, "-").concat(uniqueId) : uniqueId;
72
+ var hasCloseButton = settings.hasCloseButton || true;
73
+ var duration = settings.duration || 2;
74
+ if (settings.hasCloseButton !== undefined) {
75
+ hasCloseButton = settings.hasCloseButton;
76
+ }
77
+ if (settings.duration !== undefined) {
78
+ duration = settings.duration;
79
+ }
80
+ return {
81
+ id: id,
82
+ title: title,
83
+ description: settings.description,
84
+ hasCloseButton: hasCloseButton,
85
+ duration: duration,
86
+ close: function close() {
87
+ return _this.closeToast(id);
88
+ },
89
+ intent: settings.intent
90
+ };
91
+ };
92
+ /**
93
+ * This will set isShown on the Toast which will close the toast.
94
+ * It won't remove the toast until onExited triggers onRemove.
95
+ */
96
+ _this.closeToast = function (id) {
97
+ _this.setState(function (previousState) {
98
+ return {
99
+ toasts: previousState.toasts.map(function (toast) {
100
+ if (toast.id === id) {
101
+ return _objectSpread(_objectSpread({}, toast), {}, {
102
+ isShown: false
103
+ });
104
+ }
105
+ return toast;
106
+ })
107
+ };
108
+ });
109
+ };
110
+ _this.removeToast = function (id) {
111
+ _this.onClose && _this.onClose();
112
+ _this.setState(function (previousState) {
113
+ return {
114
+ toasts: previousState.toasts.filter(function (toast) {
115
+ return toast.id !== id;
116
+ })
117
+ };
118
+ });
119
+ };
120
+ props.bindNotify(_this.notify);
121
+ props.bindGetToasts(_this.getToasts);
122
+ props.bindCloseAll(_this.closeAll);
123
+ _this.state = {
124
+ toasts: []
125
+ };
126
+ return _this;
127
+ }
128
+ _createClass(ToastManager, [{
129
+ key: "render",
130
+ value: function render() {
131
+ var _this2 = this;
132
+ return /*#__PURE__*/React.createElement("span", {
133
+ className: wrapperClass
134
+ }, this.state.toasts.map(function (_ref) {
135
+ var id = _ref.id,
136
+ description = _ref.description,
137
+ props = _objectWithoutProperties(_ref, _excluded);
138
+ return /*#__PURE__*/React.createElement(Toast, Object.assign({
139
+ key: id,
140
+ onRemove: function onRemove() {
141
+ return _this2.removeToast(id);
142
+ }
143
+ }, props), description);
144
+ }));
145
+ }
146
+ }]);
147
+ return ToastManager;
148
+ }(React.PureComponent);
149
+ ToastManager.idCounter = 0;
150
+ export { ToastManager as default };
@@ -0,0 +1,64 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
+ import React from 'react';
4
+ import ReactDOM from 'react-dom';
5
+ import ToastManager from './toastManager';
6
+ var isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
7
+
8
+ /**
9
+ * The Toaster manages the interactionsb between
10
+ * the ToasterManger and the toast API.
11
+ */
12
+ var Toaster = function Toaster() {
13
+ var _this = this;
14
+ _classCallCheck(this, Toaster);
15
+ this._bindNotify = function (handler) {
16
+ _this.notifyHandler = handler;
17
+ };
18
+ this._bindGetToasts = function (handler) {
19
+ _this.getToastsHandler = handler;
20
+ };
21
+ this._bindCloseAll = function (handler) {
22
+ _this.closeAllHandler = handler;
23
+ };
24
+ this.getToasts = function () {
25
+ return _this.getToastsHandler();
26
+ };
27
+ this.closeAll = function () {
28
+ return _this.closeAllHandler();
29
+ };
30
+ this.notify = function (title) {
31
+ var settings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
32
+ return _this.notifyHandler(title, _objectSpread(_objectSpread({}, settings), {}, {
33
+ intent: 'none'
34
+ }));
35
+ };
36
+ this.success = function (title) {
37
+ var settings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
38
+ return _this.notifyHandler(title, _objectSpread(_objectSpread({}, settings), {}, {
39
+ intent: 'success'
40
+ }));
41
+ };
42
+ this.warning = function (title) {
43
+ var settings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
44
+ return _this.notifyHandler(title, _objectSpread(_objectSpread({}, settings), {}, {
45
+ intent: 'warning'
46
+ }));
47
+ };
48
+ this.danger = function (title) {
49
+ var settings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
50
+ return _this.notifyHandler(title, _objectSpread(_objectSpread({}, settings), {}, {
51
+ intent: 'danger'
52
+ }));
53
+ };
54
+ if (!isBrowser) return;
55
+ var container = document.createElement('div');
56
+ container.setAttribute('data-evergreen-toaster-container', '');
57
+ document.body.appendChild(container);
58
+ ReactDOM.render( /*#__PURE__*/React.createElement(ToastManager, {
59
+ bindNotify: this._bindNotify,
60
+ bindGetToasts: this._bindGetToasts,
61
+ bindCloseAll: this._bindCloseAll
62
+ }), container);
63
+ };
64
+ export { Toaster as default };
@@ -0,0 +1,8 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import { CellType, FILTER_PREDICATE_TYPE } from 'dtable-store';
3
+ export var COLOR_RULE_FILTER_TYPE_MAP = {
4
+ NUMERIC_VALUE: 'numeric_value'
5
+ };
6
+ export var DISPLAY_COLOR_RULE_FILTER_TYPE = _defineProperty({}, COLOR_RULE_FILTER_TYPE_MAP.NUMERIC_VALUE, 'Numeric_value');
7
+ export var FILTER_TYPE_2_CELL_TYPE = _defineProperty({}, COLOR_RULE_FILTER_TYPE_MAP.NUMERIC_VALUE, CellType.NUMBER);
8
+ export var EMPTY_PREDICATE = [FILTER_PREDICATE_TYPE.EMPTY, FILTER_PREDICATE_TYPE.NOT_EMPTY];