sea-chart 1.1.52 → 1.1.53-alpha.1
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/constants/type.js +2 -2
- package/dist/locale/lang/en.js +4 -1
- package/dist/locale/lang/zh_CN.js +2 -1
- package/dist/view/wrapper/table-element/components/formatter.js +28 -8
- package/dist/view/wrapper/table-element/components/formatters/EmailFormatter/index.css +6 -0
- package/dist/view/wrapper/table-element/components/formatters/EmailFormatter/index.js +23 -0
- package/dist/view/wrapper/table-element/components/formatters/FileFormatter/image-previewer-lightbox.js +14 -0
- package/dist/view/wrapper/table-element/components/formatters/FileFormatter/index.css +33 -0
- package/dist/view/wrapper/table-element/components/formatters/FileFormatter/index.js +133 -0
- package/dist/view/wrapper/table-element/components/formatters/UrlFormatter/index.css +6 -0
- package/dist/view/wrapper/table-element/components/formatters/UrlFormatter/index.js +23 -0
- package/dist/view/wrapper/table-element/components/formatters/css/cell-formatter.css +5 -0
- package/dist/view/wrapper/table-element/components/formatters/formula-formatter.js +36 -0
- package/dist/view/wrapper/table-element/components/formatters/link-formatter.js +282 -0
- package/dist/view/wrapper/table-element/components/formatters/utils.js +0 -0
- package/dist/view/wrapper/table-element/components/utils.js +20 -0
- package/package.json +3 -2
package/dist/constants/type.js
CHANGED
|
@@ -62,7 +62,7 @@ export const CHART_TYPE_SHOW = {
|
|
|
62
62
|
[CHART_TYPE.TREE_MAP]: 'Tree_map',
|
|
63
63
|
[CHART_TYPE.TABLE]: 'Pivot_table',
|
|
64
64
|
[CHART_TYPE.FUNNEL]: 'Funnel',
|
|
65
|
-
[CHART_TYPE.TABLE_ELEMENT]: '
|
|
65
|
+
[CHART_TYPE.TABLE_ELEMENT]: 'Basic_table'
|
|
66
66
|
};
|
|
67
67
|
export const CHART_TYPES = [{
|
|
68
68
|
name: 'Histogram',
|
|
@@ -119,7 +119,7 @@ export const CHART_TYPES = [{
|
|
|
119
119
|
}, {
|
|
120
120
|
name: 'Table',
|
|
121
121
|
icon: 'dtable-logo',
|
|
122
|
-
children: [CHART_TYPE.
|
|
122
|
+
children: [CHART_TYPE.TABLE_ELEMENT, CHART_TYPE.TABLE]
|
|
123
123
|
}, {
|
|
124
124
|
name: 'Funnel',
|
|
125
125
|
icon: 'funnel',
|
package/dist/locale/lang/en.js
CHANGED
|
@@ -293,6 +293,9 @@ const en = {
|
|
|
293
293
|
"Y_axis_(lift_side)": "Y axis (left side)",
|
|
294
294
|
"Y_axis_(right_side)": "Y axis (right side)",
|
|
295
295
|
"All": "All",
|
|
296
|
-
"Label_value": "Label value"
|
|
296
|
+
"Label_value": "Label value",
|
|
297
|
+
"Basic_table": "Basic table",
|
|
298
|
+
'Open_local_file_is_not_supported': 'Open local file is not supported',
|
|
299
|
+
'URL_is_invalid': 'URL is invalid'
|
|
297
300
|
};
|
|
298
301
|
export default en;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import _ButtonFormatter from "dtable-ui-component/lib/ButtonFormatter";
|
|
2
2
|
import _RateFormatter from "dtable-ui-component/lib/RateFormatter";
|
|
3
3
|
import _DurationFormatter from "dtable-ui-component/lib/DurationFormatter";
|
|
4
|
-
import _EmailFormatter from "dtable-ui-component/lib/EmailFormatter";
|
|
5
|
-
import _UrlFormatter from "dtable-ui-component/lib/UrlFormatter";
|
|
6
4
|
import _AutoNumberFormatter from "dtable-ui-component/lib/AutoNumberFormatter";
|
|
7
5
|
import _LastModifierFormatter from "dtable-ui-component/lib/LastModifierFormatter";
|
|
8
6
|
import _CreatorFormatter from "dtable-ui-component/lib/CreatorFormatter";
|
|
@@ -15,15 +13,20 @@ import _MultipleSelectFormatter from "dtable-ui-component/lib/MultipleSelectForm
|
|
|
15
13
|
import _DateFormatter from "dtable-ui-component/lib/DateFormatter";
|
|
16
14
|
import _NumberFormatter from "dtable-ui-component/lib/NumberFormatter";
|
|
17
15
|
import _GeolocationFormatter from "dtable-ui-component/lib/GeolocationFormatter";
|
|
18
|
-
import _FileFormatter from "dtable-ui-component/lib/FileFormatter";
|
|
19
16
|
import _ImageFormatter from "dtable-ui-component/lib/ImageFormatter";
|
|
20
17
|
import _LongTextFormatter from "dtable-ui-component/lib/LongTextFormatter";
|
|
21
18
|
import _CollaboratorFormatter from "dtable-ui-component/lib/CollaboratorFormatter";
|
|
22
19
|
import _TextFormatter from "dtable-ui-component/lib/TextFormatter";
|
|
20
|
+
import _toaster from "dtable-ui-component/lib/toaster";
|
|
23
21
|
import React, { Fragment } from 'react';
|
|
24
22
|
import { CellType } from 'dtable-utils';
|
|
25
|
-
import
|
|
26
|
-
import
|
|
23
|
+
import intl from '../../../../intl';
|
|
24
|
+
import DtableFormulaFormatter from './formatters/formula-formatter';
|
|
25
|
+
import LinkFormatter from './formatters/link-formatter';
|
|
26
|
+
import FileFormatter from './formatters/FileFormatter/index';
|
|
27
|
+
import UrlFormatter from './formatters/UrlFormatter/index';
|
|
28
|
+
import EmailFormatter from './formatters/EmailFormatter/index';
|
|
29
|
+
import { getTrimmedString, getValidUrl, openUrlLink } from './utils';
|
|
27
30
|
class Formatter extends React.Component {
|
|
28
31
|
constructor() {
|
|
29
32
|
super(...arguments);
|
|
@@ -44,6 +47,21 @@ class Formatter extends React.Component {
|
|
|
44
47
|
if (seafileFileIndex > -1) return;
|
|
45
48
|
window.location.href = url + '?dl=1';
|
|
46
49
|
};
|
|
50
|
+
this.onUrlClick = url => {
|
|
51
|
+
const vaildUrl = getValidUrl(url);
|
|
52
|
+
if (url.startsWith('file:///')) {
|
|
53
|
+
_toaster.danger(intl.get('Open_local_file_is_not_supported'));
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
openUrlLink(vaildUrl);
|
|
58
|
+
} catch {
|
|
59
|
+
_toaster.danger(intl.get('URL_is_invalid'));
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
this.onEmailClick = email => {
|
|
63
|
+
window.location.href = "mailto:".concat(getTrimmedString(email));
|
|
64
|
+
};
|
|
47
65
|
this.renderFormatter = () => {
|
|
48
66
|
let {
|
|
49
67
|
column,
|
|
@@ -102,7 +120,7 @@ class Formatter extends React.Component {
|
|
|
102
120
|
case CellType.FILE:
|
|
103
121
|
{
|
|
104
122
|
if (!cellValue || Array.isArray(cellValue) && cellValue.length === 0) return this.renderEmptyFormatter();
|
|
105
|
-
return /*#__PURE__*/React.createElement(
|
|
123
|
+
return /*#__PURE__*/React.createElement(FileFormatter, {
|
|
106
124
|
value: cellValue,
|
|
107
125
|
containerClassName: containerClassName,
|
|
108
126
|
isSample: isSample
|
|
@@ -229,7 +247,8 @@ class Formatter extends React.Component {
|
|
|
229
247
|
case CellType.URL:
|
|
230
248
|
{
|
|
231
249
|
if (!cellValue) return this.renderEmptyFormatter();
|
|
232
|
-
return /*#__PURE__*/React.createElement(
|
|
250
|
+
return /*#__PURE__*/React.createElement(UrlFormatter, {
|
|
251
|
+
onClick: () => this.onUrlClick(cellValue),
|
|
233
252
|
value: cellValue,
|
|
234
253
|
containerClassName: containerClassName
|
|
235
254
|
});
|
|
@@ -237,7 +256,8 @@ class Formatter extends React.Component {
|
|
|
237
256
|
case CellType.EMAIL:
|
|
238
257
|
{
|
|
239
258
|
if (!cellValue) return this.renderEmptyFormatter();
|
|
240
|
-
return /*#__PURE__*/React.createElement(
|
|
259
|
+
return /*#__PURE__*/React.createElement(EmailFormatter, {
|
|
260
|
+
onClick: () => this.onEmailClick(cellValue),
|
|
241
261
|
value: cellValue,
|
|
242
262
|
containerClassName: containerClassName
|
|
243
263
|
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classnames from 'classnames';
|
|
3
|
+
import './index.css';
|
|
4
|
+
class EmailFormatter extends React.Component {
|
|
5
|
+
render() {
|
|
6
|
+
const {
|
|
7
|
+
containerClassName,
|
|
8
|
+
value,
|
|
9
|
+
onClick
|
|
10
|
+
} = this.props;
|
|
11
|
+
let classname = classnames('dtable-ui cell-formatter-container email-formatter', containerClassName);
|
|
12
|
+
const props = {
|
|
13
|
+
title: value
|
|
14
|
+
};
|
|
15
|
+
if (onClick) {
|
|
16
|
+
props.onClick = onClick;
|
|
17
|
+
}
|
|
18
|
+
return /*#__PURE__*/React.createElement("div", Object.assign({}, props, {
|
|
19
|
+
className: classname
|
|
20
|
+
}), value);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export default EmailFormatter;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import _ImagePreviewerLightbox from "dtable-ui-component/lib/ImagePreviewerLightbox";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import context from '../../../../../../context';
|
|
4
|
+
function ImagePreviewerLightbox(props) {
|
|
5
|
+
const server = context.getSetting('server');
|
|
6
|
+
const workspaceID = context.getSetting('workspaceID');
|
|
7
|
+
const dtableUuid = context.getSetting('dtableUuid');
|
|
8
|
+
return /*#__PURE__*/React.createElement(_ImagePreviewerLightbox, Object.assign({}, props, {
|
|
9
|
+
server: server,
|
|
10
|
+
workspaceID: workspaceID,
|
|
11
|
+
dtableUuid: dtableUuid
|
|
12
|
+
}));
|
|
13
|
+
}
|
|
14
|
+
export default ImagePreviewerLightbox;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
@import url('../css/cell-formatter.css');
|
|
2
|
+
|
|
3
|
+
.dtable-ui.file-formatter {
|
|
4
|
+
display: flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.dtable-ui.file-formatter .file-item-icon {
|
|
9
|
+
display: inline-block;
|
|
10
|
+
height: 28px;
|
|
11
|
+
width: 28px;
|
|
12
|
+
border: 1px solid #f0f0f0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.dtable-ui.file-formatter .file-item-icon.img {
|
|
16
|
+
width: auto;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.dtable-ui.file-formatter .file-item-count {
|
|
20
|
+
display: inline-block;
|
|
21
|
+
padding: 0 3px;
|
|
22
|
+
min-width: 14px;
|
|
23
|
+
line-height: 14px;
|
|
24
|
+
font-size: 12px;
|
|
25
|
+
border-radius: 6px;
|
|
26
|
+
text-align: center;
|
|
27
|
+
text-overflow: ellipsis;
|
|
28
|
+
white-space: nowrap;
|
|
29
|
+
color: #fff;
|
|
30
|
+
background-color: #999;
|
|
31
|
+
-webkit-transform: translate(-50%, 8px) scale(.8);
|
|
32
|
+
transform: translate(-50%, 8px) scale(.8);
|
|
33
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import _FileItemFormatter from "dtable-ui-component/lib/FileItemFormatter";
|
|
2
|
+
import React, { Fragment } from 'react';
|
|
3
|
+
import classnames from 'classnames';
|
|
4
|
+
import { imageCheck } from '../../../../../../utils/common-utils';
|
|
5
|
+
import ImagePreviewerLightbox from './image-previewer-lightbox';
|
|
6
|
+
import './index.css';
|
|
7
|
+
// import FileItemFormatter from '../FileItemFormatter';
|
|
8
|
+
|
|
9
|
+
export default class FileFormatter extends React.PureComponent {
|
|
10
|
+
constructor(props) {
|
|
11
|
+
super(props);
|
|
12
|
+
this.getFileItemImageUrlList = value => {
|
|
13
|
+
let fileImageUrlList = [];
|
|
14
|
+
value.forEach(fileItem => {
|
|
15
|
+
const {
|
|
16
|
+
url,
|
|
17
|
+
name
|
|
18
|
+
} = fileItem;
|
|
19
|
+
let assetFileIndex = typeof url === 'string' ? url.indexOf('/asset') : -1;
|
|
20
|
+
if (assetFileIndex > -1) {
|
|
21
|
+
const isImage = imageCheck(name);
|
|
22
|
+
if (isImage) {
|
|
23
|
+
fileImageUrlList.push(url);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
this.setState({
|
|
28
|
+
fileImageUrlList
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
this.openFile = fileItem => {
|
|
32
|
+
let openFileUrl = fileItem.url;
|
|
33
|
+
let previewerUrl;
|
|
34
|
+
let assetFileIndex = openFileUrl.indexOf('/asset');
|
|
35
|
+
if (assetFileIndex > -1) {
|
|
36
|
+
if (imageCheck(fileItem.name)) {
|
|
37
|
+
this.showLargeImage(fileItem.url);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
previewerUrl = openFileUrl.replace('/asset', '/asset-preview');
|
|
41
|
+
window.open(previewerUrl, '_blank');
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
this.showLargeImage = itemUrl => {
|
|
45
|
+
let {
|
|
46
|
+
fileImageUrlList
|
|
47
|
+
} = this.state;
|
|
48
|
+
this.setState({
|
|
49
|
+
isShowLargeImage: true,
|
|
50
|
+
largeImageIndex: fileImageUrlList.indexOf(itemUrl)
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
this.moveNext = () => {
|
|
54
|
+
let {
|
|
55
|
+
fileImageUrlList
|
|
56
|
+
} = this.state;
|
|
57
|
+
this.setState(prevState => ({
|
|
58
|
+
largeImageIndex: (prevState.largeImageIndex + 1) % fileImageUrlList.length
|
|
59
|
+
}));
|
|
60
|
+
};
|
|
61
|
+
this.movePrev = () => {
|
|
62
|
+
let {
|
|
63
|
+
fileImageUrlList
|
|
64
|
+
} = this.state;
|
|
65
|
+
this.setState(prevState => ({
|
|
66
|
+
largeImageIndex: (prevState.largeImageIndex + fileImageUrlList.length - 1) % fileImageUrlList.length
|
|
67
|
+
}));
|
|
68
|
+
};
|
|
69
|
+
this.hideLargeImage = () => {
|
|
70
|
+
this.setState({
|
|
71
|
+
isShowLargeImage: false,
|
|
72
|
+
largeImageIndex: -1
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
this.state = {
|
|
76
|
+
isShowLargeImage: false,
|
|
77
|
+
largeImageIndex: -1,
|
|
78
|
+
fileImageUrlList: []
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
componentDidMount() {
|
|
82
|
+
this.getFileItemImageUrlList(this.props.value);
|
|
83
|
+
}
|
|
84
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
85
|
+
if (JSON.stringify(this.props.value) !== JSON.stringify(nextProps.value)) {
|
|
86
|
+
this.getFileItemImageUrlList(nextProps.value);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
render() {
|
|
90
|
+
let {
|
|
91
|
+
isSample,
|
|
92
|
+
value,
|
|
93
|
+
containerClassName
|
|
94
|
+
} = this.props;
|
|
95
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
let className = classnames('dtable-ui cell-formatter-container file-formatter', containerClassName);
|
|
99
|
+
if (isSample) {
|
|
100
|
+
let item = value[0];
|
|
101
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
102
|
+
className: className
|
|
103
|
+
}, /*#__PURE__*/React.createElement(_FileItemFormatter, {
|
|
104
|
+
file: item
|
|
105
|
+
}), value.length !== 1 && /*#__PURE__*/React.createElement("span", {
|
|
106
|
+
className: "file-item-count"
|
|
107
|
+
}, "+".concat(value.length)));
|
|
108
|
+
}
|
|
109
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
110
|
+
className: className
|
|
111
|
+
}, value.map((item, index) => {
|
|
112
|
+
return /*#__PURE__*/React.createElement(Fragment, {
|
|
113
|
+
key: index
|
|
114
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
115
|
+
onClick: () => this.openFile(item)
|
|
116
|
+
}, /*#__PURE__*/React.createElement(_FileItemFormatter, {
|
|
117
|
+
file: item
|
|
118
|
+
})));
|
|
119
|
+
}), this.state.isShowLargeImage && /*#__PURE__*/React.createElement(ImagePreviewerLightbox, {
|
|
120
|
+
readOnly: true,
|
|
121
|
+
imageItems: this.state.fileImageUrlList,
|
|
122
|
+
imageIndex: this.state.largeImageIndex,
|
|
123
|
+
closeImagePopup: this.hideLargeImage,
|
|
124
|
+
moveToPrevImage: this.movePrev,
|
|
125
|
+
moveToNextImage: this.moveNext
|
|
126
|
+
}));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
FileFormatter.defaultProps = {
|
|
130
|
+
isSample: false,
|
|
131
|
+
value: [],
|
|
132
|
+
containerClassName: ''
|
|
133
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classnames from 'classnames';
|
|
3
|
+
import './index.css';
|
|
4
|
+
class UrlFormatter extends React.Component {
|
|
5
|
+
render() {
|
|
6
|
+
const {
|
|
7
|
+
containerClassName,
|
|
8
|
+
value,
|
|
9
|
+
onClick
|
|
10
|
+
} = this.props;
|
|
11
|
+
let classname = classnames('dtable-ui cell-formatter-container url-formatter', containerClassName);
|
|
12
|
+
const props = {
|
|
13
|
+
title: value
|
|
14
|
+
};
|
|
15
|
+
if (onClick) {
|
|
16
|
+
props.onClick = onClick;
|
|
17
|
+
}
|
|
18
|
+
return /*#__PURE__*/React.createElement("div", Object.assign({}, props, {
|
|
19
|
+
className: classname
|
|
20
|
+
}), value);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export default UrlFormatter;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import _FormulaFormatter from "dtable-ui-component/lib/FormulaFormatter";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { CellType, COLLABORATOR_COLUMN_TYPES, FORMULA_RESULT_TYPE } from 'dtable-utils';
|
|
4
|
+
import { convertValueToDtableLongTextValue } from '../dataset-utils';
|
|
5
|
+
function DtableFormulaFormatter(props) {
|
|
6
|
+
const {
|
|
7
|
+
value,
|
|
8
|
+
column,
|
|
9
|
+
collaborators,
|
|
10
|
+
containerClassName
|
|
11
|
+
} = props;
|
|
12
|
+
if (!value && value !== 0 && value !== false) {
|
|
13
|
+
return props.renderEmptyFormatter();
|
|
14
|
+
}
|
|
15
|
+
const {
|
|
16
|
+
result_type,
|
|
17
|
+
array_type
|
|
18
|
+
} = column.data || {};
|
|
19
|
+
let cellValue = value;
|
|
20
|
+
if (Array.isArray(cellValue)) {
|
|
21
|
+
if (array_type === CellType.LONG_TEXT) {
|
|
22
|
+
cellValue = cellValue.map(item => convertValueToDtableLongTextValue(item));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (result_type === FORMULA_RESULT_TYPE.ARRAY && COLLABORATOR_COLUMN_TYPES.includes(array_type)) {
|
|
26
|
+
// need query user if not loaded
|
|
27
|
+
props.queryUsers(Array.isArray(cellValue) ? cellValue : [cellValue]);
|
|
28
|
+
}
|
|
29
|
+
return /*#__PURE__*/React.createElement(_FormulaFormatter, {
|
|
30
|
+
value: cellValue,
|
|
31
|
+
column: column,
|
|
32
|
+
collaborators: collaborators,
|
|
33
|
+
containerClassName: containerClassName
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
export default DtableFormulaFormatter;
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import _LongTextFormatter from "dtable-ui-component/lib/LongTextFormatter";
|
|
2
|
+
import _CheckboxFormatter from "dtable-ui-component/lib/CheckboxFormatter";
|
|
3
|
+
import _MultipleSelectFormatter from "dtable-ui-component/lib/MultipleSelectFormatter";
|
|
4
|
+
import _LastModifierFormatter from "dtable-ui-component/lib/LastModifierFormatter";
|
|
5
|
+
import _CreatorFormatter from "dtable-ui-component/lib/CreatorFormatter";
|
|
6
|
+
import _MTimeFormatter from "dtable-ui-component/lib/MTimeFormatter";
|
|
7
|
+
import _CTimeFormatter from "dtable-ui-component/lib/CTimeFormatter";
|
|
8
|
+
import _DateFormatter from "dtable-ui-component/lib/DateFormatter";
|
|
9
|
+
import _NumberFormatter from "dtable-ui-component/lib/NumberFormatter";
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import { CellType, FORMULA_RESULT_TYPE, getDurationDisplayString, getGeolocationDisplayString, getMultipleOptionName } from 'dtable-utils';
|
|
12
|
+
import { getFormulaArrayValue, isArrayFormalColumn } from '../dataset-utils';
|
|
13
|
+
import { getCellDisplayValue } from '../value-display-utils';
|
|
14
|
+
import { value } from '../../../../../../../dtable/src/utils/formula/parser.terms';
|
|
15
|
+
function LinkFormatter(props) {
|
|
16
|
+
const {
|
|
17
|
+
column,
|
|
18
|
+
value,
|
|
19
|
+
containerClassName,
|
|
20
|
+
collaborators
|
|
21
|
+
} = props;
|
|
22
|
+
const {
|
|
23
|
+
data
|
|
24
|
+
} = column;
|
|
25
|
+
if (!Array.isArray(value) || value.length === 0) return props.renderEmptyFormatter();
|
|
26
|
+
let {
|
|
27
|
+
display_column: displayColumn
|
|
28
|
+
} = data || {};
|
|
29
|
+
if (!displayColumn) return props.renderEmptyFormatter();
|
|
30
|
+
const {
|
|
31
|
+
type: displayColumnType,
|
|
32
|
+
data: displayColumnData
|
|
33
|
+
} = displayColumn;
|
|
34
|
+
const cellValue = getFormulaArrayValue(value, !isArrayFormalColumn(displayColumnType));
|
|
35
|
+
if (!Array.isArray(cellValue) || cellValue.length === 0) return props.renderEmptyFormatter();
|
|
36
|
+
switch (displayColumnType) {
|
|
37
|
+
case CellType.TEXT:
|
|
38
|
+
case CellType.AUTO_NUMBER:
|
|
39
|
+
case CellType.EMAIL:
|
|
40
|
+
case CellType.URL:
|
|
41
|
+
{
|
|
42
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
43
|
+
className: containerClassName
|
|
44
|
+
}, cellValue.map((value, index) => {
|
|
45
|
+
if (!value) return null;
|
|
46
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
47
|
+
title: value,
|
|
48
|
+
key: "link-".concat(displayColumnType, "-").concat(index),
|
|
49
|
+
className: "table-element-link-item"
|
|
50
|
+
}, value);
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
case CellType.NUMBER:
|
|
54
|
+
{
|
|
55
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
56
|
+
className: containerClassName
|
|
57
|
+
}, cellValue.map((value, index) => {
|
|
58
|
+
if (!value && value !== 0) return null;
|
|
59
|
+
return /*#__PURE__*/React.createElement(_NumberFormatter, {
|
|
60
|
+
key: "link-".concat(displayColumnType, "-").concat(index),
|
|
61
|
+
containerClassName: "table-element-link-item",
|
|
62
|
+
data: displayColumnData || {},
|
|
63
|
+
value: value
|
|
64
|
+
});
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
case CellType.DATE:
|
|
68
|
+
{
|
|
69
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
70
|
+
className: containerClassName
|
|
71
|
+
}, cellValue.map((value, index) => {
|
|
72
|
+
if (!value || typeof value !== 'string') return null;
|
|
73
|
+
const {
|
|
74
|
+
format
|
|
75
|
+
} = displayColumnData || {};
|
|
76
|
+
return /*#__PURE__*/React.createElement(_DateFormatter, {
|
|
77
|
+
key: "link-".concat(displayColumnType, "-").concat(index),
|
|
78
|
+
value: value,
|
|
79
|
+
format: format,
|
|
80
|
+
containerClassName: "table-element-link-item"
|
|
81
|
+
});
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
case CellType.CTIME:
|
|
85
|
+
{
|
|
86
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
87
|
+
className: containerClassName
|
|
88
|
+
}, cellValue.map((value, index) => {
|
|
89
|
+
if (!value) return null;
|
|
90
|
+
return /*#__PURE__*/React.createElement(_CTimeFormatter, {
|
|
91
|
+
key: "link-".concat(displayColumnType, "-").concat(index),
|
|
92
|
+
value: value,
|
|
93
|
+
containerClassName: "table-element-link-item"
|
|
94
|
+
});
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
case CellType.MTIME:
|
|
98
|
+
{
|
|
99
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
100
|
+
className: containerClassName
|
|
101
|
+
}, cellValue.map((value, index) => {
|
|
102
|
+
if (!value) return null;
|
|
103
|
+
return /*#__PURE__*/React.createElement(_MTimeFormatter, {
|
|
104
|
+
key: "link-".concat(displayColumnType, "-").concat(index),
|
|
105
|
+
value: value,
|
|
106
|
+
containerClassName: "table-element-link-item"
|
|
107
|
+
});
|
|
108
|
+
}));
|
|
109
|
+
}
|
|
110
|
+
case CellType.DURATION:
|
|
111
|
+
{
|
|
112
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
113
|
+
className: containerClassName
|
|
114
|
+
}, cellValue.map((value, index) => {
|
|
115
|
+
if (!value) return null;
|
|
116
|
+
const displayValue = getDurationDisplayString(value, displayColumnData);
|
|
117
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
118
|
+
title: displayValue,
|
|
119
|
+
key: "link-".concat(displayColumnType, "-").concat(index),
|
|
120
|
+
className: "table-element-link-item"
|
|
121
|
+
}, displayValue);
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
case CellType.CREATOR:
|
|
125
|
+
{
|
|
126
|
+
props.queryUsers([cellValue]);
|
|
127
|
+
return /*#__PURE__*/React.createElement(_CreatorFormatter, {
|
|
128
|
+
collaborators: collaborators,
|
|
129
|
+
value: cellValue
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
case CellType.LAST_MODIFIER:
|
|
133
|
+
{
|
|
134
|
+
props.queryUsers([cellValue]);
|
|
135
|
+
return /*#__PURE__*/React.createElement(_LastModifierFormatter, {
|
|
136
|
+
collaborators: collaborators,
|
|
137
|
+
value: cellValue
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
case CellType.SINGLE_SELECT:
|
|
141
|
+
{
|
|
142
|
+
if (!cellValue || cellValue.length === 0) {
|
|
143
|
+
return props.renderEmptyFormatter();
|
|
144
|
+
}
|
|
145
|
+
const options = displayColumnData && Array.isArray(displayColumnData.options) ? displayColumnData.options : [];
|
|
146
|
+
return /*#__PURE__*/React.createElement(_MultipleSelectFormatter, {
|
|
147
|
+
value: cellValue,
|
|
148
|
+
options: options || [],
|
|
149
|
+
containerClassName: "table-element-".concat(displayColumnType, "-formatter")
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
case CellType.MULTIPLE_SELECT:
|
|
153
|
+
{
|
|
154
|
+
if (!cellValue || cellValue.length === 0) {
|
|
155
|
+
return props.renderEmptyFormatter();
|
|
156
|
+
}
|
|
157
|
+
const options = displayColumnData && Array.isArray(displayColumnData.options) ? displayColumnData.options : [];
|
|
158
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
159
|
+
className: containerClassName
|
|
160
|
+
}, cellValue.map((value, index) => {
|
|
161
|
+
if (!value) return null;
|
|
162
|
+
const valueDisplayString = Array.isArray(value) ? getMultipleOptionName(options, value) : getMultipleOptionName(options, [value]);
|
|
163
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
164
|
+
title: valueDisplayString,
|
|
165
|
+
key: "link-".concat(displayColumnType, "-").concat(index),
|
|
166
|
+
className: "table-element-link-item"
|
|
167
|
+
}, valueDisplayString);
|
|
168
|
+
}));
|
|
169
|
+
}
|
|
170
|
+
case CellType.COLLABORATOR:
|
|
171
|
+
{
|
|
172
|
+
if (!cellValue || cellValue.length === 0) {
|
|
173
|
+
return props.renderEmptyFormatter();
|
|
174
|
+
}
|
|
175
|
+
props.queryUsers(cellValue);
|
|
176
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
177
|
+
className: containerClassName
|
|
178
|
+
}, cellValue.map((value, index) => {
|
|
179
|
+
if (!value) return null;
|
|
180
|
+
const valueDisplayString = Array.isArray(value) ? getCellDisplayValue({
|
|
181
|
+
[displayColumn.key]: value
|
|
182
|
+
}, displayColumn, collaborators) : getCellDisplayValue({
|
|
183
|
+
[displayColumn.key]: [value]
|
|
184
|
+
}, displayColumn, collaborators);
|
|
185
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
186
|
+
title: valueDisplayString,
|
|
187
|
+
key: "link-".concat(displayColumnType, "-").concat(index),
|
|
188
|
+
className: "table-element-link-item"
|
|
189
|
+
}, valueDisplayString);
|
|
190
|
+
}));
|
|
191
|
+
}
|
|
192
|
+
case CellType.CHECKBOX:
|
|
193
|
+
{
|
|
194
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
195
|
+
className: containerClassName
|
|
196
|
+
}, cellValue.map((value, index) => {
|
|
197
|
+
return /*#__PURE__*/React.createElement(_CheckboxFormatter, {
|
|
198
|
+
key: "link-".concat(displayColumnType, "-").concat(index),
|
|
199
|
+
value: Boolean(value),
|
|
200
|
+
containerClassName: "table-element-".concat(displayColumnType, "-item")
|
|
201
|
+
});
|
|
202
|
+
}));
|
|
203
|
+
}
|
|
204
|
+
case CellType.GEOLOCATION:
|
|
205
|
+
{
|
|
206
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
207
|
+
className: containerClassName
|
|
208
|
+
}, cellValue.map((value, index) => {
|
|
209
|
+
if (!value) return null;
|
|
210
|
+
const displayString = getGeolocationDisplayString(value, displayColumnData, {
|
|
211
|
+
hyphen: ' '
|
|
212
|
+
});
|
|
213
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
214
|
+
title: displayString,
|
|
215
|
+
key: "link-".concat(displayColumnType, "-").concat(index),
|
|
216
|
+
className: "table-element-link-item"
|
|
217
|
+
}, displayString);
|
|
218
|
+
}));
|
|
219
|
+
}
|
|
220
|
+
case CellType.LONG_TEXT:
|
|
221
|
+
{
|
|
222
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
223
|
+
className: containerClassName
|
|
224
|
+
}, cellValue.map((value, index) => {
|
|
225
|
+
if (!value) return null;
|
|
226
|
+
return /*#__PURE__*/React.createElement(_LongTextFormatter, {
|
|
227
|
+
key: "link-".concat(displayColumnType, "-").concat(index),
|
|
228
|
+
value: value,
|
|
229
|
+
containerClassName: "table-element-".concat(displayColumnType, "-item")
|
|
230
|
+
});
|
|
231
|
+
}));
|
|
232
|
+
}
|
|
233
|
+
case CellType.FORMULA:
|
|
234
|
+
case CellType.LINK_FORMULA:
|
|
235
|
+
{
|
|
236
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
237
|
+
className: containerClassName
|
|
238
|
+
}, cellValue.map((value, index) => {
|
|
239
|
+
if (!value) return null;
|
|
240
|
+
const displayString = getCellDisplayValue({
|
|
241
|
+
[displayColumn.key]: value
|
|
242
|
+
}, displayColumn, collaborators);
|
|
243
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
244
|
+
title: displayString,
|
|
245
|
+
key: "link-".concat(displayColumnType, "-").concat(index),
|
|
246
|
+
className: "table-element-link-item"
|
|
247
|
+
}, displayString);
|
|
248
|
+
}));
|
|
249
|
+
}
|
|
250
|
+
case FORMULA_RESULT_TYPE.BOOL:
|
|
251
|
+
{
|
|
252
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
253
|
+
className: containerClassName
|
|
254
|
+
}, cellValue.map((value, index) => {
|
|
255
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
256
|
+
title: value + '',
|
|
257
|
+
key: "link-".concat(displayColumnType, "-").concat(index),
|
|
258
|
+
className: "table-element-link-item"
|
|
259
|
+
}, value + '');
|
|
260
|
+
}));
|
|
261
|
+
}
|
|
262
|
+
case FORMULA_RESULT_TYPE.STRING:
|
|
263
|
+
{
|
|
264
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
265
|
+
className: containerClassName
|
|
266
|
+
}, cellValue.map((value, index) => {
|
|
267
|
+
if (!value) return null;
|
|
268
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
269
|
+
title: value,
|
|
270
|
+
value: value,
|
|
271
|
+
key: "link-".concat(displayColumnType, "-").concat(index),
|
|
272
|
+
className: "table-element-link-item"
|
|
273
|
+
}, value);
|
|
274
|
+
}));
|
|
275
|
+
}
|
|
276
|
+
default:
|
|
277
|
+
{
|
|
278
|
+
return props.renderEmptyFormatter();
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
export default LinkFormatter;
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const getTrimmedString = value => {
|
|
2
|
+
return typeof value === 'string' ? value.trim() : '';
|
|
3
|
+
};
|
|
4
|
+
export const isValidUrl = url => {
|
|
5
|
+
const reg = /^(([-a-zA-Z0-9+.]+):\/\/)[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/;
|
|
6
|
+
return reg.test(url);
|
|
7
|
+
};
|
|
8
|
+
export const getValidUrl = value => {
|
|
9
|
+
const url = getTrimmedString(value);
|
|
10
|
+
return isValidUrl(url) ? url : "http://".concat(url);
|
|
11
|
+
};
|
|
12
|
+
export const openUrlLink = url => {
|
|
13
|
+
let a = document.createElement('a');
|
|
14
|
+
document.body.appendChild(a);
|
|
15
|
+
a.href = url;
|
|
16
|
+
a.target = '_blank';
|
|
17
|
+
a.rel = 'noopener noreferrer';
|
|
18
|
+
a.click();
|
|
19
|
+
document.body.removeChild(a);
|
|
20
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sea-chart",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.53-alpha.1",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@antv/data-set": "0.11.8",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"@dnd-kit/sortable": "^8.0.0",
|
|
11
11
|
"@dnd-kit/utilities": "^3.2.2",
|
|
12
12
|
"@seafile/seafile-calendar": "^0.0.24",
|
|
13
|
+
"@seafile/seafile-editor": "^1.0.133",
|
|
13
14
|
"classnames": "^2.3.2",
|
|
14
15
|
"dayjs": "1.10.7",
|
|
15
16
|
"is-hotkey": "0.2.0",
|
|
@@ -164,4 +165,4 @@
|
|
|
164
165
|
"publishConfig": {
|
|
165
166
|
"access": "public"
|
|
166
167
|
}
|
|
167
|
-
}
|
|
168
|
+
}
|