@seafile/sdoc-editor 0.3.25 → 0.3.26-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.
- package/dist/api/seafile-api.js +20 -0
- package/dist/basic-sdk/constants/index.js +2 -1
- package/dist/basic-sdk/editor/sdoc-editor.js +20 -2
- package/dist/basic-sdk/extension/constants/element-type.js +1 -0
- package/dist/basic-sdk/extension/constants/index.js +2 -2
- package/dist/basic-sdk/extension/constants/menus-config.js +6 -1
- package/dist/basic-sdk/extension/plugins/chart/chart-components/base-setting/index.js +46 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/chart-type-setting/index.css +29 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/chart-type-setting/index.js +23 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/column-setting.js +119 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/data-sort-setting.js +54 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/date-granularities.js +55 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/dtable-select-setting.js +86 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/geolocation-granularities.js +97 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/groupby-numeric-item.js +108 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/groupby-numeric-items.js +87 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/include-empty-setting.js +35 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/summary-field-setting.js +64 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/summary-method-setting.js +61 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/summary-type-setting.js +74 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/x-axis-group-setting.js +108 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/y-axis-group-settings.js +182 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/common-add-tool.js +23 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/common-hooks.js +15 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/constants.js +10 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/custom-select/index.js +98 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/custom-select/option-group.js +236 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/custom-select/option.js +40 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/custom-select/select.css +135 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/date-translate.js +54 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/department-editor/department-multiple-select.js +146 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/department-editor/department-single-select.js +272 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/department-editor/index.css +209 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/department-editor/index.js +98 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/department-editor/selected-departments.js +85 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/dtable-search-input.js +127 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/filter-popover-widgets/collaborator-filter.js +106 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/filter-popover-widgets/department-multiple-select-filter.js +86 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/filter-popover-widgets/department-single-select-filter.js +85 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/filter-popover-widgets/filter-calendar.js +166 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/filter-popover-widgets/filter-item-utils.js +144 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/filter-popover-widgets/filter-item.js +679 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/filter-popover-widgets/filters-list.css +320 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/filter-popover-widgets/filters-list.js +121 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/filter-popover-widgets/rate-item.js +72 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/filter-popover.js +208 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/filters-popover.css +30 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/index.css +18 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/index.js +79 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/data-filter-setting/utils.js +531 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/seatable-radio/index.js +28 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/seatable-radio/style.css +52 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/table-setting/index.js +46 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/toggle-setting/index.js +27 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-components/toggle-setting/style.css +29 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-edit-dialog/index.css +22 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-edit-dialog/index.js +111 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-setting/index.css +24 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-setting/index.js +120 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-utils/common-utils/base-utils.js +430 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-utils/common-utils/dtable-utils.js +144 -0
- package/dist/basic-sdk/extension/plugins/chart/chart-utils/histogram-bar-utils.js +83 -0
- package/dist/basic-sdk/extension/plugins/chart/constants/date-constants.js +9 -0
- package/dist/basic-sdk/extension/plugins/chart/constants/geolocation-constants.js +11 -0
- package/dist/basic-sdk/extension/plugins/chart/constants/index.js +109 -0
- package/dist/basic-sdk/extension/plugins/chart/constants/special-column-types.js +7 -0
- package/dist/basic-sdk/extension/plugins/chart/constants/summary-constants.js +18 -0
- package/dist/basic-sdk/extension/plugins/chart/helpers.js +98 -0
- package/dist/basic-sdk/extension/plugins/chart/hover-menu/index.css +55 -0
- package/dist/basic-sdk/extension/plugins/chart/hover-menu/index.js +54 -0
- package/dist/basic-sdk/extension/plugins/chart/index.js +12 -0
- package/dist/basic-sdk/extension/plugins/chart/menu/index.js +23 -0
- package/dist/basic-sdk/extension/plugins/chart/model.js +34 -0
- package/dist/basic-sdk/extension/plugins/chart/plugin.js +20 -0
- package/dist/basic-sdk/extension/plugins/chart/render-elem.css +26 -0
- package/dist/basic-sdk/extension/plugins/chart/render-elem.js +229 -0
- package/dist/basic-sdk/extension/plugins/index.js +3 -2
- package/dist/basic-sdk/extension/plugins/link/hover/index.js +3 -1
- package/dist/basic-sdk/extension/plugins/link/render-elem.js +4 -3
- package/dist/basic-sdk/extension/render/custom-element.js +10 -4
- package/dist/basic-sdk/extension/toolbar/header-toolbar/insert-toolbar/index.js +2 -1
- package/dist/components/doc-operations/more-operations.js +21 -12
- package/dist/constants/index.js +3 -0
- package/dist/context.js +44 -0
- package/package.json +9 -1
- package/public/locales/en/sdoc-editor.json +34 -1
- package/public/locales/zh_CN/sdoc-editor.json +35 -1
- package/public/media/{sdoc-editor-font.css → iconfont.css} +10 -10
- package/public/media/sdoc-editor-font/iconfont.eot +0 -0
- package/public/media/sdoc-editor-font/iconfont.svg +2 -2
- package/public/media/sdoc-editor-font/iconfont.ttf +0 -0
- package/public/media/sdoc-editor-font/iconfont.woff +0 -0
- package/public/media/sdoc-editor-font/iconfont.woff2 +0 -0
package/dist/api/seafile-api.js
CHANGED
|
@@ -199,5 +199,25 @@ class SeafileAPI {
|
|
|
199
199
|
data: params
|
|
200
200
|
});
|
|
201
201
|
}
|
|
202
|
+
getFileDownloadLink(repoID, filePath) {
|
|
203
|
+
const path = encodeURIComponent(filePath);
|
|
204
|
+
const url = '/api2/repos/' + repoID + '/file/?p=' + path + '&dl=1';
|
|
205
|
+
return this.req.get(url);
|
|
206
|
+
}
|
|
207
|
+
getFileContentByLink(downloadLink) {
|
|
208
|
+
return this.req.get(downloadLink);
|
|
209
|
+
}
|
|
210
|
+
getDtableServer(url) {
|
|
211
|
+
return this.req.get(url);
|
|
212
|
+
}
|
|
213
|
+
getDtables(url) {
|
|
214
|
+
return this.req.get(url);
|
|
215
|
+
}
|
|
216
|
+
getDtableMetaData(url, tableName) {
|
|
217
|
+
return this.req.post(url, {
|
|
218
|
+
'sql': "select * from ".concat(tableName),
|
|
219
|
+
'convert_keys': true
|
|
220
|
+
});
|
|
221
|
+
}
|
|
202
222
|
}
|
|
203
223
|
export default SeafileAPI;
|
|
@@ -14,7 +14,8 @@ export const INTERNAL_EVENT = {
|
|
|
14
14
|
UPDATE_TAG_VIEW: 'update_tag_view',
|
|
15
15
|
COMMENT_LIST_CLICK: 'comment_list_click',
|
|
16
16
|
UNSEEN_NOTIFICATIONS_COUNT: 'unseen_notifications_count',
|
|
17
|
-
CLOSE_CALLOUT_COLOR_PICKER: 'close_callout_color_picker'
|
|
17
|
+
CLOSE_CALLOUT_COLOR_PICKER: 'close_callout_color_picker',
|
|
18
|
+
OPEN_SELECT: 'open_select'
|
|
18
19
|
};
|
|
19
20
|
export const REVISION_DIFF_KEY = 'diff';
|
|
20
21
|
export const REVISION_DIFF_VALUE = '1';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
-
import React, { useEffect, useState, useImperativeHandle, forwardRef, useMemo } from 'react';
|
|
2
|
+
import React, { useEffect, useState, useImperativeHandle, forwardRef, useMemo, useCallback } from 'react';
|
|
3
3
|
import { Editor } from '@seafile/slate';
|
|
4
4
|
import deepCopy from 'deep-copy';
|
|
5
5
|
import context from '../../context';
|
|
@@ -17,6 +17,9 @@ import { HeaderToolbar } from '../extension';
|
|
|
17
17
|
import ReadOnlyArticle from '../views/readonly-article';
|
|
18
18
|
import { isMobile } from '../../utils';
|
|
19
19
|
import { CollaboratorsProvider } from '../../hooks';
|
|
20
|
+
import { EventBus } from '../../basic-sdk';
|
|
21
|
+
import { EXTERNAL_EVENT } from '../../constants';
|
|
22
|
+
import { getDtableBases } from '../extension/plugins/chart/helpers';
|
|
20
23
|
const SdocEditor = forwardRef((_ref, ref) => {
|
|
21
24
|
let {
|
|
22
25
|
editor,
|
|
@@ -42,7 +45,7 @@ const SdocEditor = forwardRef((_ref, ref) => {
|
|
|
42
45
|
const [slateValue, setSlateValue] = useState(document.children);
|
|
43
46
|
useEffect(() => {
|
|
44
47
|
validEditor.readonly = false;
|
|
45
|
-
}, []);
|
|
48
|
+
}, [validEditor.readonly]);
|
|
46
49
|
|
|
47
50
|
// useMount: init socket connection
|
|
48
51
|
useEffect(() => {
|
|
@@ -76,6 +79,21 @@ const SdocEditor = forwardRef((_ref, ref) => {
|
|
|
76
79
|
};
|
|
77
80
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
78
81
|
}, []);
|
|
82
|
+
const onRefreshDocument = useCallback(() => {
|
|
83
|
+
window.location.reload();
|
|
84
|
+
}, []);
|
|
85
|
+
|
|
86
|
+
// useMount: refresh document
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
const eventBus = EventBus.getInstance();
|
|
89
|
+
eventBus.subscribe(EXTERNAL_EVENT.REFRESH_DOCUMENT, onRefreshDocument);
|
|
90
|
+
}, [onRefreshDocument]);
|
|
91
|
+
|
|
92
|
+
// useMount: get dtable bases
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
getDtableBases(validEditor);
|
|
95
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
96
|
+
}, []);
|
|
79
97
|
|
|
80
98
|
// The parent component can call the method of this component through ref
|
|
81
99
|
useImperativeHandle(ref, () => ({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// extension plugin
|
|
2
2
|
import * as ELEMENT_TYPE from './element-type';
|
|
3
|
-
import { BLOCKQUOTE, TITLE, SUBTITLE, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, PARAGRAPH, ORDERED_LIST, UNORDERED_LIST, LIST_ITEM, CHECK_LIST_ITEM, CODE_BLOCK, CODE_LINE, TABLE, TABLE_CELL, TABLE_ROW, LINK, SDOC_LINK, FILE_LINK, IMAGE, TOP_LEVEL_TYPES, INLINE_LEVEL_TYPES, CALL_OUT } from './element-type';
|
|
3
|
+
import { BLOCKQUOTE, TITLE, SUBTITLE, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, PARAGRAPH, ORDERED_LIST, UNORDERED_LIST, LIST_ITEM, CHECK_LIST_ITEM, CODE_BLOCK, CODE_LINE, TABLE, TABLE_CELL, TABLE_ROW, LINK, SDOC_LINK, FILE_LINK, IMAGE, CHART, TOP_LEVEL_TYPES, INLINE_LEVEL_TYPES, CALL_OUT } from './element-type';
|
|
4
4
|
export { DEFAULT_COLORS, STANDARD_COLORS, DEFAULT_RECENT_USED_LIST, DEFAULT_FONT_COLOR, RECENT_USED_HIGHLIGHT_COLORS_KEY, RECENT_USED_FONT_COLORS_KEY, RECENT_USED_TABLE_CELL_BACKGROUND_COLORS_KEY, DEFAULT_LAST_USED_FONT_COLOR, DEFAULT_LAST_USED_HIGHLIGHT_COLOR, DEFAULT_LAST_USED_TABLE_CELL_BACKGROUND_COLOR } from './color';
|
|
5
5
|
export { FONT_SIZE, DEFAULT_FONT, FONT, GOOGLE_FONT_CLASS, RECENT_USED_FONTS_KEY, SDOC_FONT_SIZE } from './font';
|
|
6
6
|
export { DIFF_TYPE, ADDED_STYLE, DELETED_STYLE } from './diff-view';
|
|
@@ -55,4 +55,4 @@ export const MOUSE_ENTER_EVENT_DISABLED_MAP = {
|
|
|
55
55
|
[HEADER6]: [CALL_OUT],
|
|
56
56
|
[CALL_OUT]: [CALL_OUT]
|
|
57
57
|
};
|
|
58
|
-
export { ELEMENT_TYPE, BLOCKQUOTE, TITLE, SUBTITLE, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, PARAGRAPH, ORDERED_LIST, UNORDERED_LIST, LIST_ITEM, CHECK_LIST_ITEM, CODE_BLOCK, CODE_LINE, TABLE, TABLE_CELL, TABLE_ROW, LINK, SDOC_LINK, FILE_LINK, IMAGE, TOP_LEVEL_TYPES, INLINE_LEVEL_TYPES, CALL_OUT };
|
|
58
|
+
export { ELEMENT_TYPE, BLOCKQUOTE, TITLE, SUBTITLE, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, PARAGRAPH, ORDERED_LIST, UNORDERED_LIST, LIST_ITEM, CHECK_LIST_ITEM, CODE_BLOCK, CODE_LINE, TABLE, TABLE_CELL, TABLE_ROW, LINK, SDOC_LINK, FILE_LINK, IMAGE, CHART, TOP_LEVEL_TYPES, INLINE_LEVEL_TYPES, CALL_OUT };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RECENT_USED_HIGHLIGHT_COLORS_KEY, DEFAULT_LAST_USED_HIGHLIGHT_COLOR, RECENT_USED_FONT_COLORS_KEY, DEFAULT_FONT_COLOR, DEFAULT_LAST_USED_FONT_COLOR } from './color';
|
|
2
|
-
import { BLOCKQUOTE, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, ORDERED_LIST, UNORDERED_LIST, CHECK_LIST_ITEM, CODE_BLOCK, LINK, IMAGE, TABLE, SDOC_LINK, FILE_LINK, PARAGRAPH, CALL_OUT } from './element-type';
|
|
2
|
+
import { BLOCKQUOTE, HEADER, HEADER1, HEADER2, HEADER3, HEADER4, HEADER5, HEADER6, ORDERED_LIST, UNORDERED_LIST, CHECK_LIST_ITEM, CODE_BLOCK, LINK, CHART, IMAGE, TABLE, SDOC_LINK, FILE_LINK, PARAGRAPH, CALL_OUT } from './element-type';
|
|
3
3
|
export const UNDO = 'undo';
|
|
4
4
|
export const REDO = 'redo';
|
|
5
5
|
export const CLEAR_FORMAT = 'clear_format';
|
|
@@ -80,6 +80,11 @@ export const MENUS_CONFIG_MAP = {
|
|
|
80
80
|
iconClass: 'sdocfont sdoc-image',
|
|
81
81
|
text: 'Insert_image'
|
|
82
82
|
},
|
|
83
|
+
[CHART]: {
|
|
84
|
+
id: "sdoc_".concat(CHART),
|
|
85
|
+
iconClass: 'sdocfont sdoc-chart',
|
|
86
|
+
text: 'Insert_chart'
|
|
87
|
+
},
|
|
83
88
|
[TABLE]: {
|
|
84
89
|
id: "sdoc_".concat(TABLE),
|
|
85
90
|
iconClass: 'sdocfont sdoc-table',
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { withTranslation } from 'react-i18next';
|
|
3
|
+
import DtableSelect from '../common-settings/dtable-select-setting';
|
|
4
|
+
const BaseSetting = _ref => {
|
|
5
|
+
let {
|
|
6
|
+
tables,
|
|
7
|
+
activeTableId,
|
|
8
|
+
onSelectedBaseChanged,
|
|
9
|
+
t
|
|
10
|
+
} = _ref;
|
|
11
|
+
const getTablesOptions = useCallback(() => {
|
|
12
|
+
return Array.isArray(tables) && tables.map(table => {
|
|
13
|
+
return {
|
|
14
|
+
label: /*#__PURE__*/React.createElement("span", {
|
|
15
|
+
className: "select-option-name"
|
|
16
|
+
}, table.base_name),
|
|
17
|
+
value: {
|
|
18
|
+
name: table.base_name,
|
|
19
|
+
id: table.base_api_token
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
}, [tables]);
|
|
24
|
+
const getActiveTableOption = useCallback(() => {
|
|
25
|
+
if (!activeTableId) return null;
|
|
26
|
+
const tablesOptions = getTablesOptions();
|
|
27
|
+
return tablesOptions.find(option => {
|
|
28
|
+
const {
|
|
29
|
+
id
|
|
30
|
+
} = option.value;
|
|
31
|
+
return activeTableId === id;
|
|
32
|
+
});
|
|
33
|
+
}, [activeTableId, getTablesOptions]);
|
|
34
|
+
const activeTableOption = getActiveTableOption();
|
|
35
|
+
const tablesOptions = getTablesOptions();
|
|
36
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
37
|
+
className: "sdoc-chart-setting-item"
|
|
38
|
+
}, /*#__PURE__*/React.createElement("label", null, t('Base')), /*#__PURE__*/React.createElement(DtableSelect, {
|
|
39
|
+
value: activeTableOption,
|
|
40
|
+
options: tablesOptions,
|
|
41
|
+
onChange: option => {
|
|
42
|
+
onSelectedBaseChanged(option);
|
|
43
|
+
}
|
|
44
|
+
}));
|
|
45
|
+
};
|
|
46
|
+
export default withTranslation('sdoc-editor')(BaseSetting);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
.sdoc-chart-selected-type-container {
|
|
2
|
+
height: 38px;
|
|
3
|
+
border: 1px solid hsl(0, 0%, 80%);
|
|
4
|
+
border-radius: 4px;
|
|
5
|
+
padding-left: 8px;
|
|
6
|
+
padding-right: 3px;
|
|
7
|
+
justify-content: space-between;
|
|
8
|
+
background-color: #f5f5f5;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.sdoc-chart-switch-type-container {
|
|
12
|
+
height: 24px;
|
|
13
|
+
width: 24px;
|
|
14
|
+
text-align: center;
|
|
15
|
+
line-height: 24px;
|
|
16
|
+
margin-left: 10px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.sdoc-chart-switch-type-container:hover {
|
|
20
|
+
cursor: pointer;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.sdoc-chart-switch-type-container .sdoc-chart-type-switch-icon {
|
|
24
|
+
color: hsl(0, 0%, 80%);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.sdoc-chart-switch-type-container:hover .sdoc-chart-type-switch-icon {
|
|
28
|
+
color: hsl(0, 0%, 60%);
|
|
29
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import { Label, FormGroup } from 'reactstrap';
|
|
3
|
+
import { withTranslation } from 'react-i18next';
|
|
4
|
+
import { STATISTIC_TYPE_SHOW } from '../../constants';
|
|
5
|
+
import './index.css';
|
|
6
|
+
class ChartTypeSetting extends Component {
|
|
7
|
+
render() {
|
|
8
|
+
const {
|
|
9
|
+
element,
|
|
10
|
+
t
|
|
11
|
+
} = this.props;
|
|
12
|
+
const {
|
|
13
|
+
statItem
|
|
14
|
+
} = element;
|
|
15
|
+
const {
|
|
16
|
+
type
|
|
17
|
+
} = statItem;
|
|
18
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormGroup, null, /*#__PURE__*/React.createElement(Label, null, t('Chart_type')), /*#__PURE__*/React.createElement("div", {
|
|
19
|
+
className: "sdoc-chart-selected-type-container d-flex align-items-center"
|
|
20
|
+
}, /*#__PURE__*/React.createElement("span", null, t(STATISTIC_TYPE_SHOW[type])))));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export default withTranslation('sdoc-editor')(ChartTypeSetting);
|
package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/column-setting.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import React, { Fragment } from 'react';
|
|
2
|
+
import { COLUMN_OPTIONS } from 'dtable-utils';
|
|
3
|
+
import { withTranslation } from 'react-i18next';
|
|
4
|
+
import DtableSelect from './dtable-select-setting';
|
|
5
|
+
import DtableUtils from '../../chart-utils/common-utils/dtable-utils';
|
|
6
|
+
class ColumnSetting extends React.Component {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.getColumnsOptions = () => {
|
|
10
|
+
const {
|
|
11
|
+
columns,
|
|
12
|
+
specifiedColumnType
|
|
13
|
+
} = this.props;
|
|
14
|
+
if (!columns || columns.length === 0) return [];
|
|
15
|
+
let validColumns = columns;
|
|
16
|
+
if (specifiedColumnType) {
|
|
17
|
+
validColumns = columns.filter(column => {
|
|
18
|
+
if (specifiedColumnType === 'text') {
|
|
19
|
+
return DtableUtils.isTextColumn(column);
|
|
20
|
+
}
|
|
21
|
+
if (specifiedColumnType === 'date') {
|
|
22
|
+
return DtableUtils.isDateColumn(column);
|
|
23
|
+
}
|
|
24
|
+
if (specifiedColumnType === 'number') {
|
|
25
|
+
return DtableUtils.isNumericColumn(column);
|
|
26
|
+
}
|
|
27
|
+
if (specifiedColumnType === 'geolocation') {
|
|
28
|
+
return column.type === 'geolocation';
|
|
29
|
+
}
|
|
30
|
+
if (specifiedColumnType === 'dateAndNumber') {
|
|
31
|
+
return DtableUtils.isDateColumn(column) || DtableUtils.isNumericColumn(column);
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return validColumns.map(column => {
|
|
37
|
+
const {
|
|
38
|
+
name,
|
|
39
|
+
key,
|
|
40
|
+
type
|
|
41
|
+
} = column;
|
|
42
|
+
const option = COLUMN_OPTIONS.find(o => o.type === type) || {};
|
|
43
|
+
if (key === null) {
|
|
44
|
+
return {
|
|
45
|
+
label: /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
46
|
+
className: "column-header-icon"
|
|
47
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
48
|
+
className: option.iconClass
|
|
49
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
50
|
+
style: {
|
|
51
|
+
color: '#999999'
|
|
52
|
+
},
|
|
53
|
+
className: "select-option-name"
|
|
54
|
+
}, name)),
|
|
55
|
+
value: {
|
|
56
|
+
name,
|
|
57
|
+
key,
|
|
58
|
+
type
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
label: /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
64
|
+
className: "column-header-icon"
|
|
65
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
66
|
+
className: option.iconClass
|
|
67
|
+
})), /*#__PURE__*/React.createElement("span", {
|
|
68
|
+
className: "select-option-name"
|
|
69
|
+
}, name)),
|
|
70
|
+
value: {
|
|
71
|
+
name,
|
|
72
|
+
key,
|
|
73
|
+
type
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
this.getActiveColumnOption = columnsOptions => {
|
|
79
|
+
const {
|
|
80
|
+
activeColumnKey
|
|
81
|
+
} = this.props;
|
|
82
|
+
if (!activeColumnKey) return null;
|
|
83
|
+
return columnsOptions.find(option => {
|
|
84
|
+
const {
|
|
85
|
+
key
|
|
86
|
+
} = option.value;
|
|
87
|
+
return activeColumnKey === key;
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
this.onSelectedColumnChanged = option => {
|
|
91
|
+
const {
|
|
92
|
+
key
|
|
93
|
+
} = option && option.value;
|
|
94
|
+
const {
|
|
95
|
+
activeColumnKey
|
|
96
|
+
} = this.props;
|
|
97
|
+
if (key === activeColumnKey) return;
|
|
98
|
+
this.props.onSelectedColumnChanged(option);
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
render() {
|
|
102
|
+
const {
|
|
103
|
+
noOptionsMessage
|
|
104
|
+
} = this.props;
|
|
105
|
+
const columnsOptions = this.getColumnsOptions();
|
|
106
|
+
const activeColumnOption = this.getActiveColumnOption(columnsOptions);
|
|
107
|
+
return /*#__PURE__*/React.createElement(DtableSelect, {
|
|
108
|
+
value: activeColumnOption,
|
|
109
|
+
options: columnsOptions,
|
|
110
|
+
placeholder: this.props.t('Select_a_column'),
|
|
111
|
+
onChange: this.onSelectedColumnChanged,
|
|
112
|
+
noOptionsMessage: noOptionsMessage
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
ColumnSetting.defaultProps = {
|
|
117
|
+
specifiedColumnType: ''
|
|
118
|
+
};
|
|
119
|
+
export default withTranslation('sdoc-editor')(ColumnSetting);
|
package/dist/basic-sdk/extension/plugins/chart/chart-components/common-settings/data-sort-setting.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React, { Component } from 'react';
|
|
2
|
+
import { withTranslation } from 'react-i18next';
|
|
3
|
+
import SeaTableRadio from '../seatable-radio';
|
|
4
|
+
import { DATA_SORT_TYPES, DATA_SORT_TYPE, DATA_SORT_TYPE_LABEL } from '../../constants';
|
|
5
|
+
class DataSort extends Component {
|
|
6
|
+
constructor(props) {
|
|
7
|
+
super(props);
|
|
8
|
+
this.onChangeSortType = type => {
|
|
9
|
+
const {
|
|
10
|
+
settingKey,
|
|
11
|
+
settingValue: sortType
|
|
12
|
+
} = this.props;
|
|
13
|
+
if (type === sortType) return;
|
|
14
|
+
this.setState({
|
|
15
|
+
sortType: type
|
|
16
|
+
}, () => {
|
|
17
|
+
const newType = type === DATA_SORT_TYPE.NOT_SORTED ? '' : type;
|
|
18
|
+
const newSetting = {
|
|
19
|
+
[settingKey]: newType
|
|
20
|
+
};
|
|
21
|
+
this.props.updateSetting(newSetting);
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
const {
|
|
25
|
+
settingValue: _sortType
|
|
26
|
+
} = props;
|
|
27
|
+
this.state = {
|
|
28
|
+
sortType: _sortType || DATA_SORT_TYPE.NOT_SORTED
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
render() {
|
|
32
|
+
const {
|
|
33
|
+
sortType
|
|
34
|
+
} = this.state;
|
|
35
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
36
|
+
className: "sdoc-chart-setting-item"
|
|
37
|
+
}, /*#__PURE__*/React.createElement("label", null, this.props.t('Data_sorting')), DATA_SORT_TYPES.map((item, index) => {
|
|
38
|
+
const isChecked = sortType === item;
|
|
39
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
40
|
+
key: 'chart-group-item-' + index,
|
|
41
|
+
className: 'chart-group-item'
|
|
42
|
+
}, /*#__PURE__*/React.createElement(SeaTableRadio, {
|
|
43
|
+
isChecked: isChecked,
|
|
44
|
+
onCheckedChange: this.onChangeSortType.bind(this, item),
|
|
45
|
+
label: this.props.t(DATA_SORT_TYPE_LABEL[item])
|
|
46
|
+
}));
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
DataSort.defaultProps = {
|
|
51
|
+
settingKey: 'sort_type',
|
|
52
|
+
settingValue: ''
|
|
53
|
+
};
|
|
54
|
+
export default withTranslation('sdoc-editor')(DataSort);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { withTranslation } from 'react-i18next';
|
|
3
|
+
import DTableSelect from './dtable-select-setting';
|
|
4
|
+
import { DATE_GRANULARITIES } from '../../constants/date-constants';
|
|
5
|
+
import { STATISTICS_COUNT_SHOW } from '../../constants';
|
|
6
|
+
class DateGranularities extends React.Component {
|
|
7
|
+
constructor(props) {
|
|
8
|
+
super(props);
|
|
9
|
+
this.getDateGranularitiesOptions = () => {
|
|
10
|
+
return DATE_GRANULARITIES.map(g => {
|
|
11
|
+
return {
|
|
12
|
+
value: g,
|
|
13
|
+
label: /*#__PURE__*/React.createElement("span", {
|
|
14
|
+
className: 'select-module select-module-name'
|
|
15
|
+
}, this.props.t(STATISTICS_COUNT_SHOW[g]))
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
this.getActiveDateGranularityOption = () => {
|
|
20
|
+
const {
|
|
21
|
+
settingValue
|
|
22
|
+
} = this.props;
|
|
23
|
+
if (!settingValue) return null;
|
|
24
|
+
return this.dateGranularitiesOptions.find(item => item.value === settingValue);
|
|
25
|
+
};
|
|
26
|
+
this.onSelectDateGranularity = option => {
|
|
27
|
+
const {
|
|
28
|
+
settingKey,
|
|
29
|
+
settingValue
|
|
30
|
+
} = this.props;
|
|
31
|
+
const {
|
|
32
|
+
value
|
|
33
|
+
} = option;
|
|
34
|
+
if (value === settingValue) return;
|
|
35
|
+
this.props.updateSetting({
|
|
36
|
+
[settingKey]: value
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
this.dateGranularitiesOptions = this.getDateGranularitiesOptions();
|
|
40
|
+
}
|
|
41
|
+
render() {
|
|
42
|
+
const activeValue = this.getActiveDateGranularityOption();
|
|
43
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
44
|
+
className: "mt-1"
|
|
45
|
+
}, /*#__PURE__*/React.createElement(DTableSelect, {
|
|
46
|
+
value: activeValue,
|
|
47
|
+
options: this.dateGranularitiesOptions,
|
|
48
|
+
onChange: this.onSelectDateGranularity
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
DateGranularities.defaultProps = {
|
|
53
|
+
settingKey: ''
|
|
54
|
+
};
|
|
55
|
+
export default withTranslation('sdoc-editor')(DateGranularities);
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { withTranslation } from 'react-i18next';
|
|
4
|
+
import Select, { components } from 'react-select';
|
|
5
|
+
const DropdownIndicator = props => {
|
|
6
|
+
return components.DropdownIndicator && /*#__PURE__*/React.createElement(components.DropdownIndicator, props, /*#__PURE__*/React.createElement("span", {
|
|
7
|
+
className: "sdocfont sdoc-drop-down parameter-icon"
|
|
8
|
+
}));
|
|
9
|
+
};
|
|
10
|
+
const PluginSelectStyle = {
|
|
11
|
+
control: styles => _objectSpread(_objectSpread({}, styles), {}, {
|
|
12
|
+
fontSize: '14px',
|
|
13
|
+
cursor: 'pointer',
|
|
14
|
+
lineHeight: '1.5'
|
|
15
|
+
}),
|
|
16
|
+
indicatorSeparator: () => {},
|
|
17
|
+
option: (provided, state) => {
|
|
18
|
+
const {
|
|
19
|
+
isDisabled,
|
|
20
|
+
isSelected,
|
|
21
|
+
isFocused
|
|
22
|
+
} = state;
|
|
23
|
+
return _objectSpread(_objectSpread({}, provided), {}, {
|
|
24
|
+
cursor: isDisabled ? 'default' : 'pointer',
|
|
25
|
+
backgroundColor: isSelected ? '#20a0ff' : isFocused ? '#f5f5f5' : '#fff',
|
|
26
|
+
'.dtable-font': {
|
|
27
|
+
color: isSelected ? '#fff' : '#aaa'
|
|
28
|
+
},
|
|
29
|
+
fontSize: '14px',
|
|
30
|
+
wordBreak: 'break-all'
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
class DTableSelect extends React.Component {
|
|
35
|
+
constructor() {
|
|
36
|
+
super(...arguments);
|
|
37
|
+
this.getMenuPortalTarget = () => {
|
|
38
|
+
return document.querySelector('.modal');
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
componentDidMount() {
|
|
42
|
+
this.forceUpdate();
|
|
43
|
+
}
|
|
44
|
+
render() {
|
|
45
|
+
const {
|
|
46
|
+
options,
|
|
47
|
+
onChange,
|
|
48
|
+
value,
|
|
49
|
+
isSearchable,
|
|
50
|
+
placeholder,
|
|
51
|
+
classNamePrefix
|
|
52
|
+
} = this.props;
|
|
53
|
+
return /*#__PURE__*/React.createElement(Select, {
|
|
54
|
+
value: value,
|
|
55
|
+
onChange: onChange,
|
|
56
|
+
options: options,
|
|
57
|
+
styles: PluginSelectStyle,
|
|
58
|
+
components: {
|
|
59
|
+
DropdownIndicator,
|
|
60
|
+
NoOptionsMessage: props => {
|
|
61
|
+
return /*#__PURE__*/React.createElement("div", Object.assign({}, props.innerProps, {
|
|
62
|
+
className: "d-flex align-items-center justify-content-center",
|
|
63
|
+
style: {
|
|
64
|
+
margin: '6px 10px',
|
|
65
|
+
color: '#c2c2c2'
|
|
66
|
+
}
|
|
67
|
+
}), this.props.t('No_options'));
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
placeholder: placeholder,
|
|
71
|
+
isSearchable: isSearchable,
|
|
72
|
+
menuPosition: 'fixed',
|
|
73
|
+
menuShouldScrollIntoView: true,
|
|
74
|
+
menuPortalTarget: this.getMenuPortalTarget(),
|
|
75
|
+
classNamePrefix: classNamePrefix
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
DTableSelect.defaultProps = {
|
|
80
|
+
options: [],
|
|
81
|
+
value: null,
|
|
82
|
+
isSearchable: false,
|
|
83
|
+
placeholder: '',
|
|
84
|
+
classNamePrefix: ''
|
|
85
|
+
};
|
|
86
|
+
export default withTranslation('sdoc-editor')(DTableSelect);
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { withTranslation } from 'react-i18next';
|
|
3
|
+
import DTableSelect from './dtable-select-setting';
|
|
4
|
+
import { GEOLOCATION_GRANULARITIES } from '../../constants/geolocation-constants';
|
|
5
|
+
import { STATISTICS_COUNT_SHOW } from '../../constants';
|
|
6
|
+
class GeolocationGranlarities extends React.Component {
|
|
7
|
+
constructor(props) {
|
|
8
|
+
super(props);
|
|
9
|
+
this.getGranularitiesOptions = () => {
|
|
10
|
+
let types = GEOLOCATION_GRANULARITIES;
|
|
11
|
+
const {
|
|
12
|
+
supportGeolocationTypes
|
|
13
|
+
} = this.props;
|
|
14
|
+
if (supportGeolocationTypes && supportGeolocationTypes.length > 0) {
|
|
15
|
+
types = GEOLOCATION_GRANULARITIES.filter(item => supportGeolocationTypes.includes(item));
|
|
16
|
+
}
|
|
17
|
+
return types.map(g => {
|
|
18
|
+
return {
|
|
19
|
+
value: g,
|
|
20
|
+
label: /*#__PURE__*/React.createElement("span", {
|
|
21
|
+
className: 'select-module select-module-name'
|
|
22
|
+
}, this.props.t(STATISTICS_COUNT_SHOW[g]))
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
this.getGeolocationGranularitiesOptions = () => {
|
|
27
|
+
const {
|
|
28
|
+
groupbyColumn: column,
|
|
29
|
+
supportGeolocationTypes
|
|
30
|
+
} = this.props;
|
|
31
|
+
// custom defined
|
|
32
|
+
if (supportGeolocationTypes && supportGeolocationTypes.length > 0) {
|
|
33
|
+
return this.geolocationGranularitiesOptions;
|
|
34
|
+
}
|
|
35
|
+
let geolocationGranularitiesOptions = this.geolocationGranularitiesOptions;
|
|
36
|
+
if (column) {
|
|
37
|
+
const {
|
|
38
|
+
geo_format
|
|
39
|
+
} = column.data || {};
|
|
40
|
+
if (geo_format === 'province') {
|
|
41
|
+
geolocationGranularitiesOptions = geolocationGranularitiesOptions.filter(option => option.value === 'province');
|
|
42
|
+
}
|
|
43
|
+
if (geo_format === 'province_city') {
|
|
44
|
+
geolocationGranularitiesOptions = geolocationGranularitiesOptions.filter(option => option.value !== 'district');
|
|
45
|
+
}
|
|
46
|
+
if (geo_format === 'country_region' || geo_format === 'lng_lat') {
|
|
47
|
+
geolocationGranularitiesOptions = [];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return geolocationGranularitiesOptions;
|
|
51
|
+
};
|
|
52
|
+
this.getActiveGeolocationGranularity = () => {
|
|
53
|
+
const {
|
|
54
|
+
settingValue,
|
|
55
|
+
supportGeolocationTypes
|
|
56
|
+
} = this.props;
|
|
57
|
+
const {
|
|
58
|
+
geolocationGranularitiesOptions
|
|
59
|
+
} = this;
|
|
60
|
+
|
|
61
|
+
// custom define
|
|
62
|
+
if (supportGeolocationTypes && supportGeolocationTypes.length > 0) {
|
|
63
|
+
return geolocationGranularitiesOptions.find(g => g.value === settingValue) || geolocationGranularitiesOptions[0];
|
|
64
|
+
}
|
|
65
|
+
return geolocationGranularitiesOptions.find(g => g.value === settingValue) || geolocationGranularitiesOptions[2];
|
|
66
|
+
};
|
|
67
|
+
this.onSelectGeolocationGranularity = option => {
|
|
68
|
+
const {
|
|
69
|
+
settingKey,
|
|
70
|
+
settingValue
|
|
71
|
+
} = this.props;
|
|
72
|
+
const {
|
|
73
|
+
value
|
|
74
|
+
} = option;
|
|
75
|
+
if (value === settingValue) return;
|
|
76
|
+
this.props.updateSetting({
|
|
77
|
+
[settingKey]: value
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
this.geolocationGranularitiesOptions = this.getGranularitiesOptions();
|
|
81
|
+
}
|
|
82
|
+
render() {
|
|
83
|
+
const activeValue = this.getActiveGeolocationGranularity();
|
|
84
|
+
const geolocationGranularitiesOptions = this.getGeolocationGranularitiesOptions();
|
|
85
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
86
|
+
className: "mt-1"
|
|
87
|
+
}, /*#__PURE__*/React.createElement(DTableSelect, {
|
|
88
|
+
value: activeValue,
|
|
89
|
+
options: geolocationGranularitiesOptions,
|
|
90
|
+
onChange: this.onSelectGeolocationGranularity
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
GeolocationGranlarities.defaultProps = {
|
|
95
|
+
settingKey: ''
|
|
96
|
+
};
|
|
97
|
+
export default withTranslation('sdoc-editor')(GeolocationGranlarities);
|