sea-chart 0.0.41-beta.0 → 0.0.41-beta.10
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.
- package/dist/components/types-dialog/index.js +1 -2
- package/dist/constants/common-constants.js +3 -0
- package/dist/constants/index.js +3 -0
- package/dist/context.js +16 -9
- package/dist/editor/index.js +50 -1
- package/dist/index.js +3 -2
- package/dist/settings/index.js +3 -3
- package/dist/settings/widgets/common-data-settings.js +1 -1
- package/dist/settings/widgets/group-by.js +1 -0
- package/dist/utils/event-bus.js +28 -0
- package/package.json +1 -1
|
@@ -10,7 +10,6 @@ import './index.css';
|
|
|
10
10
|
const TypesDialog = _ref => {
|
|
11
11
|
let {
|
|
12
12
|
type,
|
|
13
|
-
mediaUrl,
|
|
14
13
|
onToggle: propsOnToggle,
|
|
15
14
|
onChange
|
|
16
15
|
} = _ref;
|
|
@@ -102,7 +101,7 @@ const TypesDialog = _ref => {
|
|
|
102
101
|
}, intl.get(CHART_TYPE_SHOW[chartType])), /*#__PURE__*/React.createElement("div", {
|
|
103
102
|
className: "sea-chart-type-image-container"
|
|
104
103
|
}, /*#__PURE__*/React.createElement("img", {
|
|
105
|
-
src: context.getChartImageUrl(chartType
|
|
104
|
+
src: context.getChartImageUrl(chartType),
|
|
106
105
|
alt: "",
|
|
107
106
|
className: "sea-chart-type-demo-image"
|
|
108
107
|
})));
|
package/dist/constants/index.js
CHANGED
|
@@ -236,6 +236,9 @@ export const TYPE_DISPLAY_COLOR_USING = {
|
|
|
236
236
|
// default grid size, grid distance for heat map chart
|
|
237
237
|
export const DEFAULT_GRID_SIZE = 12;
|
|
238
238
|
export const DEFAULT_GRID_DISTANCE = 4;
|
|
239
|
+
|
|
240
|
+
// default mediaUrl
|
|
241
|
+
export const DEFAULT_MEDIAURL = 'https://dev.seatable.cn/media/';
|
|
239
242
|
export const MONTH_MIRROR = {
|
|
240
243
|
'0': 'Jan',
|
|
241
244
|
'1': 'Feb',
|
package/dist/context.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getTableById } from 'dtable-utils';
|
|
2
2
|
import CollaboratorManager from './utils/collaborator-manager';
|
|
3
3
|
import { ChartDataSQL } from './utils';
|
|
4
|
-
import { CHART_TYPE, CHART_TYPE_IMAGE } from './constants';
|
|
4
|
+
import { CHART_TYPE, CHART_TYPE_IMAGE, DEFAULT_MEDIAURL } from './constants';
|
|
5
5
|
class Context {
|
|
6
6
|
constructor() {
|
|
7
7
|
this.queryChartResult = async _ref => {
|
|
@@ -101,16 +101,23 @@ class Context {
|
|
|
101
101
|
this.getTableFormulaResults = (table, rows, value) => {
|
|
102
102
|
return this.api.getTableFormulaResults(table, rows, value);
|
|
103
103
|
};
|
|
104
|
-
this.getChartImageUrl =
|
|
104
|
+
this.getChartImageUrl = type => {
|
|
105
|
+
var _this$settings, _this$settings2, _window$dtable;
|
|
105
106
|
const name = CHART_TYPE_IMAGE[type];
|
|
106
|
-
if (
|
|
107
|
-
|
|
107
|
+
if (((_this$settings = this.settings) === null || _this$settings === void 0 ? void 0 : _this$settings.server) && ((_this$settings2 = this.settings) === null || _this$settings2 === void 0 ? void 0 : _this$settings2.mediaUrl)) {
|
|
108
|
+
const {
|
|
109
|
+
server,
|
|
110
|
+
mediaUrl
|
|
111
|
+
} = this.settings;
|
|
112
|
+
return "".concat(server).concat(mediaUrl, "dtable-statistic/img/").concat(name);
|
|
108
113
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
+
if ((_window$dtable = window.dtable) === null || _window$dtable === void 0 ? void 0 : _window$dtable.mediaUrl) {
|
|
115
|
+
const {
|
|
116
|
+
mediaUrl
|
|
117
|
+
} = window.dtable;
|
|
118
|
+
return "".concat(mediaUrl, "dtable-statistic/img/").concat(name);
|
|
119
|
+
}
|
|
120
|
+
return "".concat(DEFAULT_MEDIAURL, "dtable-statistic/img/").concat(name);
|
|
114
121
|
};
|
|
115
122
|
this.api = null;
|
|
116
123
|
this.settings = {};
|
package/dist/editor/index.js
CHANGED
|
@@ -1,8 +1,57 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useEffect, useState, useCallback } from 'react';
|
|
2
2
|
import View, { defaultProps, propTypes } from '../view';
|
|
3
3
|
import Settings from '../settings';
|
|
4
|
+
import TypesDialog from '../components/types-dialog';
|
|
5
|
+
import EventBus from '../utils/event-bus';
|
|
6
|
+
import { generateChartConfig } from '../utils';
|
|
7
|
+
import { EXTERNAL_EVENT } from '../constants/common-constants';
|
|
4
8
|
import './index.css';
|
|
5
9
|
function Editor(props) {
|
|
10
|
+
const {
|
|
11
|
+
chart,
|
|
12
|
+
tables,
|
|
13
|
+
mode,
|
|
14
|
+
onChange
|
|
15
|
+
} = props;
|
|
16
|
+
const [isDialogShow, setDialogShow] = useState(false);
|
|
17
|
+
const showTypesDialog = () => {
|
|
18
|
+
setDialogShow(true);
|
|
19
|
+
};
|
|
20
|
+
const closeTypesDialog = useCallback(() => {
|
|
21
|
+
setDialogShow(false);
|
|
22
|
+
}, []);
|
|
23
|
+
const onTypeChange = useCallback(newType => {
|
|
24
|
+
const {
|
|
25
|
+
config = {}
|
|
26
|
+
} = chart || {};
|
|
27
|
+
const {
|
|
28
|
+
type: oldType
|
|
29
|
+
} = config;
|
|
30
|
+
if (newType === oldType) return;
|
|
31
|
+
const convertedChart = generateChartConfig({
|
|
32
|
+
...config,
|
|
33
|
+
type: newType
|
|
34
|
+
}, tables);
|
|
35
|
+
onChange && onChange({
|
|
36
|
+
...chart,
|
|
37
|
+
config: convertedChart
|
|
38
|
+
}, 'data');
|
|
39
|
+
closeTypesDialog();
|
|
40
|
+
}, [chart, closeTypesDialog, onChange, tables]);
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
const unsubscribeShowTypesDialog = EventBus.subscribe(EXTERNAL_EVENT.SHOW_TYPES_DIALOG, showTypesDialog);
|
|
43
|
+
return () => {
|
|
44
|
+
unsubscribeShowTypesDialog();
|
|
45
|
+
};
|
|
46
|
+
}, []);
|
|
47
|
+
if (mode === 'new_mode') {
|
|
48
|
+
var _chart$config;
|
|
49
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, isDialogShow && /*#__PURE__*/React.createElement(TypesDialog, {
|
|
50
|
+
type: chart === null || chart === void 0 ? void 0 : (_chart$config = chart.config) === null || _chart$config === void 0 ? void 0 : _chart$config.type,
|
|
51
|
+
onToggle: closeTypesDialog,
|
|
52
|
+
onChange: onTypeChange
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
6
55
|
return /*#__PURE__*/React.createElement("div", {
|
|
7
56
|
className: "sea-chart-editor"
|
|
8
57
|
}, /*#__PURE__*/React.createElement(View, props), /*#__PURE__*/React.createElement(Settings, props, props.children));
|
package/dist/index.js
CHANGED
|
@@ -4,8 +4,9 @@ import { ChartModel } from './model';
|
|
|
4
4
|
import View from './view';
|
|
5
5
|
import Editor from './editor';
|
|
6
6
|
import Settings, { StyleSettings, Divider } from './settings';
|
|
7
|
-
import TypesDialog from './components/types-dialog';
|
|
8
7
|
import { ChartDataSQL } from './utils';
|
|
9
8
|
import Context from './context';
|
|
9
|
+
import EventBus from './utils/event-bus';
|
|
10
|
+
import { EXTERNAL_EVENT } from './constants/common-constants';
|
|
10
11
|
export default View;
|
|
11
|
-
export { SeaChartAPI, CHART_TYPE, CHART_TYPES, View, Editor, Settings,
|
|
12
|
+
export { SeaChartAPI, CHART_TYPE, CHART_TYPES, View, Editor, Settings, StyleSettings, Divider, Context, ChartModel, ChartDataSQL, EventBus, EXTERNAL_EVENT };
|
package/dist/settings/index.js
CHANGED
|
@@ -2,10 +2,10 @@ import React, { useCallback, useMemo, useState, useEffect } from 'react';
|
|
|
2
2
|
import classnames from 'classnames';
|
|
3
3
|
import { eventStopPropagation } from '../utils';
|
|
4
4
|
import { BaseUtils } from '../utils';
|
|
5
|
-
import DataSettings from './data-settings';
|
|
6
|
-
import StyleSettings from './style-settings';
|
|
7
|
-
import { CHART_SETTINGS_TYPE, CHART_SETTINGS } from '../constants';
|
|
8
5
|
import intl from '../intl';
|
|
6
|
+
import { CHART_SETTINGS_TYPE, CHART_SETTINGS } from '../constants';
|
|
7
|
+
import StyleSettings from './style-settings';
|
|
8
|
+
import DataSettings from './data-settings';
|
|
9
9
|
import Divider from './widgets/divider';
|
|
10
10
|
import './index.css';
|
|
11
11
|
const Settings = _ref => {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
|
+
import { generateChartConfig } from '../../utils';
|
|
2
3
|
import StatisticType from './chart-type';
|
|
3
4
|
import SelectTable from './select-table';
|
|
4
5
|
import SelectView from './select-view';
|
|
5
6
|
import DataFilter from './data-filter';
|
|
6
7
|
import Divider from './divider';
|
|
7
|
-
import { generateChartConfig } from '../../utils';
|
|
8
8
|
const CommonDataSettings = _ref => {
|
|
9
9
|
let {
|
|
10
10
|
chart,
|
|
@@ -125,6 +125,7 @@ class GroupBy extends Component {
|
|
|
125
125
|
selectedOption = options ? options : null;
|
|
126
126
|
}
|
|
127
127
|
return /*#__PURE__*/React.createElement(DTableSelect, {
|
|
128
|
+
menuPortalTarget: "#wrapper",
|
|
128
129
|
value: selectedOption,
|
|
129
130
|
classNamePrefix: "select-column",
|
|
130
131
|
options: this.columnOptions,
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
class EventBus {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.subscribers = {};
|
|
4
|
+
}
|
|
5
|
+
subscribe(type, handler) {
|
|
6
|
+
if (!this.subscribers[type]) {
|
|
7
|
+
this.subscribers[type] = [];
|
|
8
|
+
}
|
|
9
|
+
const handlers = this.subscribers[type];
|
|
10
|
+
handlers.push(handler);
|
|
11
|
+
return () => {
|
|
12
|
+
const index = handlers.indexOf(handler);
|
|
13
|
+
if (index > -1) {
|
|
14
|
+
handlers.splice(index, 1);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
dispatch(type) {
|
|
19
|
+
for (var _len = arguments.length, data = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
20
|
+
data[_key - 1] = arguments[_key];
|
|
21
|
+
}
|
|
22
|
+
const handlers = this.subscribers[type];
|
|
23
|
+
if (Array.isArray(handlers)) {
|
|
24
|
+
handlers.forEach(handler => handler(...data));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export default new EventBus();
|