dtable-ui-component 0.2.1 → 0.2.3
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/es/app.css +20 -0
- package/es/app.js +91 -0
- package/es/assets/images/avatar/default_avatar.png +0 -0
- package/es/assets/images/file/192/excel.png +0 -0
- package/es/assets/images/file/192/file.png +0 -0
- package/es/assets/images/file/192/music.png +0 -0
- package/es/assets/images/file/192/pdf.png +0 -0
- package/es/assets/images/file/192/pic.png +0 -0
- package/es/assets/images/file/192/ppt.png +0 -0
- package/es/assets/images/file/192/txt.png +0 -0
- package/es/assets/images/file/192/video.png +0 -0
- package/es/assets/images/file/192/word.png +0 -0
- package/es/assets/images/file/24/excel.png +0 -0
- package/es/assets/images/file/24/file.png +0 -0
- package/es/assets/images/file/24/music.png +0 -0
- package/es/assets/images/file/24/pdf.png +0 -0
- package/es/assets/images/file/24/pic.png +0 -0
- package/es/assets/images/file/24/ppt.png +0 -0
- package/es/assets/images/file/24/txt.png +0 -0
- package/es/assets/images/file/24/video.png +0 -0
- package/es/assets/images/file/24/word.png +0 -0
- package/es/assets/images/folder/folder-192.png +0 -0
- package/es/assets/images/folder/folder-24.png +0 -0
- package/es/components/cell-editor/checkbox-editor.js +104 -0
- package/es/components/cell-editor/collaborator-editor.js +236 -0
- package/es/components/cell-editor/date-editor.js +151 -0
- package/es/components/cell-editor/index.js +9 -0
- package/es/components/cell-editor/link-editor.js +303 -0
- package/es/components/cell-editor/multiple-select-editor.js +237 -0
- package/es/components/cell-editor/number-editor.js +154 -0
- package/es/components/cell-editor/single-select-editor.js +202 -0
- package/es/components/cell-editor/text-editor.js +122 -0
- package/es/components/cell-editor-dialog/pc-file-editor-dialog.js +46 -0
- package/es/components/cell-editor-dialog/pc-files-addition/index.js +0 -0
- package/es/components/cell-editor-dialog/pc-files-addition/pc-file-uploaded-item.js +0 -0
- package/es/components/cell-editor-dialog/pc-files-preview/index.js +0 -0
- package/es/components/cell-editor-dialog/pc-files-preview/pc-file-item-preview.js +0 -0
- package/es/components/cell-editor-popover/mb-collaborator-editor-popover.js +177 -0
- package/es/components/cell-editor-popover/mb-date-editor-popover.js +245 -0
- package/es/components/cell-editor-popover/mb-link-editor-popover.js +170 -0
- package/es/components/cell-editor-popover/mb-select-editor-popover.js +230 -0
- package/es/components/cell-editor-popover/pc-collaborator-editor-popover.js +109 -0
- package/es/components/cell-editor-popover/pc-date-editor-popover.js +142 -0
- package/es/components/cell-editor-popover/pc-link-editor-popover.js +114 -0
- package/es/components/cell-editor-popover/pc-select-editor-popover.js +143 -0
- package/es/components/cell-factory/cell-formatter-factory.js +25 -0
- package/es/components/cell-formatter/auto-number-formatter.js +35 -0
- package/es/components/cell-formatter/button-formatter.js +55 -0
- package/es/components/cell-formatter/checkbox-formatter.js +44 -0
- package/es/components/cell-formatter/collaborator-formatter.js +91 -0
- package/es/components/cell-formatter/creator-formatter.js +87 -0
- package/es/components/cell-formatter/ctime-formatter.js +57 -0
- package/es/components/cell-formatter/date-formatter.js +59 -0
- package/es/components/cell-formatter/duration-formatter.js +37 -0
- package/es/components/cell-formatter/email-formatter.js +35 -0
- package/es/components/cell-formatter/file-formatter.js +63 -0
- package/es/components/cell-formatter/formatter-config.js +31 -0
- package/es/components/cell-formatter/formula-formatter.js +173 -0
- package/es/components/cell-formatter/geolocation-formatter.js +49 -0
- package/es/components/cell-formatter/image-formatter.js +153 -0
- package/es/components/cell-formatter/index.js +26 -0
- package/es/components/cell-formatter/last-modifier-formatter.js +87 -0
- package/es/components/cell-formatter/link-formatter.js +144 -0
- package/es/components/cell-formatter/long-text-formatter.js +106 -0
- package/es/components/cell-formatter/mtime-formatter.js +57 -0
- package/es/components/cell-formatter/multiple-select-formatter.js +70 -0
- package/es/components/cell-formatter/number-formatter.js +46 -0
- package/es/components/cell-formatter/rate-formatter.js +74 -0
- package/es/components/cell-formatter/single-select-formatter.js +69 -0
- package/es/components/cell-formatter/text-formatter.js +35 -0
- package/es/components/cell-formatter/url-formatter.js +35 -0
- package/es/components/cell-formatter/widgets/file-item-formatter.js +50 -0
- package/es/components/cell-formatter/widgets/image-previewer-lightbox.js +119 -0
- package/es/components/common/collaborator-item.js +63 -0
- package/es/components/common/edit-editor-button.js +56 -0
- package/es/components/common/images-lazy-load.js +148 -0
- package/es/components/common/link-editor-option.js +113 -0
- package/es/components/common/mobile/mb-editor-header.js +48 -0
- package/es/components/common/modal-portal.js +44 -0
- package/es/components/common/select-editor-option.js +106 -0
- package/es/components/common/select-item.js +58 -0
- package/es/components/file-uploader/index.js +53 -0
- package/es/components/loading.js +7 -0
- package/es/components/toast/alert.js +150 -0
- package/es/components/toast/index.js +3 -0
- package/es/components/toast/toast.js +179 -0
- package/es/components/toast/toastManager.js +170 -0
- package/es/components/toast/toaster.js +76 -0
- package/es/css/cell-editor.css +614 -0
- package/es/css/cell-formatter.css +241 -0
- package/es/css/custom-rc-calendar.css +118 -0
- package/es/css/image-previewer-ligntbox.css +87 -0
- package/es/css/loading.css +54 -0
- package/es/index.js +5 -0
- package/es/lang/index.js +50 -0
- package/es/locals/de.js +2 -0
- package/es/locals/en.js +17 -0
- package/es/locals/fr.js +2 -0
- package/es/locals/zh-CN.js +17 -0
- package/es/utils/cell-types.js +25 -0
- package/es/utils/constants.js +41 -0
- package/es/utils/editor-utils.js +71 -0
- package/es/utils/normalize-long-text-value.js +68 -0
- package/es/utils/number-precision.js +163 -0
- package/es/utils/utils.js +116 -0
- package/es/utils/value-format-utils.js +281 -0
- package/lib/ImageFormatter/index.js +4 -1
- package/lib/ImagePreviewerLightbox/index.js +23 -2
- package/lib/ImagePreviewerLightbox/utils.js +3 -2
- package/package.json +1 -1
|
@@ -0,0 +1,49 @@
|
|
|
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 cn from 'astro-classname';
|
|
7
|
+
|
|
8
|
+
var GeolocationFormatter = /*#__PURE__*/function (_React$Component) {
|
|
9
|
+
_inherits(GeolocationFormatter, _React$Component);
|
|
10
|
+
|
|
11
|
+
var _super = _createSuper(GeolocationFormatter);
|
|
12
|
+
|
|
13
|
+
function GeolocationFormatter() {
|
|
14
|
+
_classCallCheck(this, GeolocationFormatter);
|
|
15
|
+
|
|
16
|
+
return _super.apply(this, arguments);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
_createClass(GeolocationFormatter, [{
|
|
20
|
+
key: "render",
|
|
21
|
+
value: function render() {
|
|
22
|
+
var _this$props = this.props,
|
|
23
|
+
value = _this$props.value,
|
|
24
|
+
containerClassName = _this$props.containerClassName;
|
|
25
|
+
var classname = cn('dtable-ui cell-formatter-container geolocation-formatter', containerClassName);
|
|
26
|
+
|
|
27
|
+
if (typeof value !== 'object') {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
32
|
+
className: classname
|
|
33
|
+
}, "".concat(value.province || '', " ").concat(value.city || '', " ").concat(value.district || '', " ").concat(value.detail || ''));
|
|
34
|
+
}
|
|
35
|
+
}]);
|
|
36
|
+
|
|
37
|
+
return GeolocationFormatter;
|
|
38
|
+
}(React.Component);
|
|
39
|
+
|
|
40
|
+
GeolocationFormatter.defaultProps = {
|
|
41
|
+
value: {
|
|
42
|
+
province: '',
|
|
43
|
+
city: '',
|
|
44
|
+
district: '',
|
|
45
|
+
detail: ''
|
|
46
|
+
},
|
|
47
|
+
containerClassName: ''
|
|
48
|
+
};
|
|
49
|
+
export default GeolocationFormatter;
|
|
@@ -0,0 +1,153 @@
|
|
|
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, { Fragment } from 'react';
|
|
6
|
+
import cn from 'astro-classname';
|
|
7
|
+
import ImagesLazyLoad from '../common/images-lazy-load';
|
|
8
|
+
import { getImageThumbnailUrl } from '../../utils/utils';
|
|
9
|
+
import ImagePreviewerLightbox from './widgets/image-previewer-lightbox';
|
|
10
|
+
|
|
11
|
+
var ImageFormatter = /*#__PURE__*/function (_React$Component) {
|
|
12
|
+
_inherits(ImageFormatter, _React$Component);
|
|
13
|
+
|
|
14
|
+
var _super = _createSuper(ImageFormatter);
|
|
15
|
+
|
|
16
|
+
function ImageFormatter(props) {
|
|
17
|
+
var _this;
|
|
18
|
+
|
|
19
|
+
_classCallCheck(this, ImageFormatter);
|
|
20
|
+
|
|
21
|
+
_this = _super.call(this, props);
|
|
22
|
+
|
|
23
|
+
_this.onImageClick = function (index) {
|
|
24
|
+
if (!_this.props.isSupportPreview) return;
|
|
25
|
+
|
|
26
|
+
_this.setState({
|
|
27
|
+
isPreviewImage: true,
|
|
28
|
+
previewImageIndex: index
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
_this.closeImagePopup = function () {
|
|
33
|
+
if (!_this.props.isSupportPreview) return;
|
|
34
|
+
|
|
35
|
+
_this.setState({
|
|
36
|
+
isPreviewImage: false,
|
|
37
|
+
previewImageIndex: -1
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
_this.movePrev = function () {
|
|
42
|
+
var images = _this.props.value;
|
|
43
|
+
|
|
44
|
+
_this.setState(function (prevState) {
|
|
45
|
+
return {
|
|
46
|
+
previewImageIndex: (prevState.previewImageIndex + images.length - 1) % images.length
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
_this.moveNext = function () {
|
|
52
|
+
var images = _this.props.value;
|
|
53
|
+
|
|
54
|
+
_this.setState(function (prevState) {
|
|
55
|
+
return {
|
|
56
|
+
previewImageIndex: (prevState.previewImageIndex + 1) % images.length
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
_this.downloadImage = function (imageItemUrl) {
|
|
62
|
+
if (!_this.props.downloadImage) return;
|
|
63
|
+
|
|
64
|
+
_this.props.downloadImage(imageItemUrl);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
_this.deleteImage = function (index) {
|
|
68
|
+
var readOnly = _this.props.readOnly;
|
|
69
|
+
if (readOnly) return;
|
|
70
|
+
if (!_this.props.deleteImage) return;
|
|
71
|
+
|
|
72
|
+
_this.props.deleteImage(index);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
_this.onRotateImage = function (index, degree) {
|
|
76
|
+
var readOnly = _this.props.readOnly;
|
|
77
|
+
if (readOnly) return;
|
|
78
|
+
if (!_this.props.rotateImage) return;
|
|
79
|
+
|
|
80
|
+
_this.props.rotateImage(index, degree);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
_this.state = {
|
|
84
|
+
isPreviewImage: false,
|
|
85
|
+
previewImageIndex: -1
|
|
86
|
+
};
|
|
87
|
+
return _this;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
_createClass(ImageFormatter, [{
|
|
91
|
+
key: "render",
|
|
92
|
+
value: function render() {
|
|
93
|
+
var _this$props = this.props,
|
|
94
|
+
isSample = _this$props.isSample,
|
|
95
|
+
value = _this$props.value,
|
|
96
|
+
server = _this$props.server,
|
|
97
|
+
containerClassName = _this$props.containerClassName,
|
|
98
|
+
readOnly = _this$props.readOnly;
|
|
99
|
+
var className = cn('dtable-ui cell-formatter-container image-formatter', containerClassName);
|
|
100
|
+
var _this$state = this.state,
|
|
101
|
+
isPreviewImage = _this$state.isPreviewImage,
|
|
102
|
+
previewImageIndex = _this$state.previewImageIndex;
|
|
103
|
+
|
|
104
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (isSample) {
|
|
109
|
+
var item = value[0];
|
|
110
|
+
var url = getImageThumbnailUrl(item, server);
|
|
111
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
112
|
+
className: className
|
|
113
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
114
|
+
className: "image-item",
|
|
115
|
+
src: url,
|
|
116
|
+
alt: ""
|
|
117
|
+
}), value.length !== 1 && /*#__PURE__*/React.createElement("span", {
|
|
118
|
+
className: "image-item-count"
|
|
119
|
+
}, "+".concat(value.length)));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
123
|
+
className: className
|
|
124
|
+
}, /*#__PURE__*/React.createElement(ImagesLazyLoad, {
|
|
125
|
+
images: value,
|
|
126
|
+
server: server,
|
|
127
|
+
onImageClick: this.onImageClick
|
|
128
|
+
})), isPreviewImage && /*#__PURE__*/React.createElement(ImagePreviewerLightbox, {
|
|
129
|
+
imageItems: value,
|
|
130
|
+
imageIndex: previewImageIndex,
|
|
131
|
+
closeImagePopup: this.closeImagePopup,
|
|
132
|
+
moveToPrevImage: this.movePrev,
|
|
133
|
+
moveToNextImage: this.moveNext,
|
|
134
|
+
deleteImage: readOnly ? null : this.deleteImage,
|
|
135
|
+
downloadImage: this.downloadImage,
|
|
136
|
+
onRotateImage: readOnly ? null : this.onRotateImage,
|
|
137
|
+
readOnly: readOnly
|
|
138
|
+
}));
|
|
139
|
+
}
|
|
140
|
+
}]);
|
|
141
|
+
|
|
142
|
+
return ImageFormatter;
|
|
143
|
+
}(React.Component);
|
|
144
|
+
|
|
145
|
+
ImageFormatter.defaultProps = {
|
|
146
|
+
isSample: false,
|
|
147
|
+
isSupportPreview: false,
|
|
148
|
+
readOnly: true,
|
|
149
|
+
value: [],
|
|
150
|
+
server: '',
|
|
151
|
+
containerClassName: ''
|
|
152
|
+
};
|
|
153
|
+
export default ImageFormatter;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import '../../css/cell-formatter.css';
|
|
2
|
+
export { default as TextFormatter } from './text-formatter';
|
|
3
|
+
export { default as NumberFormatter } from './number-formatter';
|
|
4
|
+
export { default as DateFormatter } from './date-formatter';
|
|
5
|
+
export { default as CheckboxFormatter } from './checkbox-formatter';
|
|
6
|
+
export { default as CollaboratorFormatter } from './collaborator-formatter';
|
|
7
|
+
export { default as SingleSelectFormatter } from './single-select-formatter';
|
|
8
|
+
export { default as MultipleSelectFormatter } from './multiple-select-formatter';
|
|
9
|
+
export { default as LongTextFormatter } from './long-text-formatter';
|
|
10
|
+
export { default as FileFormatter } from './file-formatter';
|
|
11
|
+
export { default as ImageFormatter } from './image-formatter';
|
|
12
|
+
export { default as GeolocationFormatter } from './geolocation-formatter';
|
|
13
|
+
export { default as CTimeFormatter } from './ctime-formatter';
|
|
14
|
+
export { default as CreatorFormatter } from './creator-formatter';
|
|
15
|
+
export { default as LastModifierFormatter } from './last-modifier-formatter';
|
|
16
|
+
export { default as MTimeFormatter } from './mtime-formatter';
|
|
17
|
+
export { default as FormulaFormatter } from './formula-formatter';
|
|
18
|
+
export { default as LinkFormatter } from './link-formatter';
|
|
19
|
+
export { default as AutoNumberFormatter } from './auto-number-formatter';
|
|
20
|
+
export { default as UrlFormatter } from './url-formatter';
|
|
21
|
+
export { default as EmailFormatter } from './email-formatter';
|
|
22
|
+
export { default as DurationFormatter } from './duration-formatter';
|
|
23
|
+
export { default as RateFormatter } from './rate-formatter';
|
|
24
|
+
export { default as ButtonFormatter } from './button-formatter';
|
|
25
|
+
export { default as FileItemFormatter } from './widgets/file-item-formatter';
|
|
26
|
+
export { default as ImagePreviewerLightbox } from './widgets/image-previewer-lightbox';
|
|
@@ -0,0 +1,87 @@
|
|
|
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 cn from 'astro-classname';
|
|
7
|
+
import ColloboratorItem from '../common/collaborator-item';
|
|
8
|
+
import DefaultAvatar from '../../assets/images/avatar/default_avatar.png';
|
|
9
|
+
|
|
10
|
+
// there will be there conditions
|
|
11
|
+
// 1 value is not exist, typeof value is array, but it's length is 0
|
|
12
|
+
// 2 value is exist, but can't find in collaborators
|
|
13
|
+
// 3 value is exist, typeof value is a string
|
|
14
|
+
// 4 vlaue is exist, typeof value is array
|
|
15
|
+
var LastModifierFormatter = /*#__PURE__*/function (_React$PureComponent) {
|
|
16
|
+
_inherits(LastModifierFormatter, _React$PureComponent);
|
|
17
|
+
|
|
18
|
+
var _super = _createSuper(LastModifierFormatter);
|
|
19
|
+
|
|
20
|
+
function LastModifierFormatter() {
|
|
21
|
+
var _this;
|
|
22
|
+
|
|
23
|
+
_classCallCheck(this, LastModifierFormatter);
|
|
24
|
+
|
|
25
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
26
|
+
args[_key] = arguments[_key];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
30
|
+
|
|
31
|
+
_this.getCollaborators = function () {
|
|
32
|
+
var _this$props = _this.props,
|
|
33
|
+
value = _this$props.value,
|
|
34
|
+
collaborators = _this$props.collaborators;
|
|
35
|
+
|
|
36
|
+
if (!Array.isArray(value)) {
|
|
37
|
+
value = [value];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return value.map(function (item, index) {
|
|
41
|
+
var collaborator = collaborators.find(function (collaborator) {
|
|
42
|
+
return collaborator.email === item;
|
|
43
|
+
}); // the collaborator can be not exist, beacuse the row modified by third app
|
|
44
|
+
|
|
45
|
+
if (!collaborator) {
|
|
46
|
+
collaborator = {
|
|
47
|
+
name: item,
|
|
48
|
+
avatar_url: DefaultAvatar
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
;
|
|
53
|
+
return /*#__PURE__*/React.createElement(ColloboratorItem, {
|
|
54
|
+
key: index,
|
|
55
|
+
collaborator: collaborator
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
return _this;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
_createClass(LastModifierFormatter, [{
|
|
64
|
+
key: "render",
|
|
65
|
+
value: function render() {
|
|
66
|
+
var _this$props2 = this.props,
|
|
67
|
+
containerClassName = _this$props2.containerClassName,
|
|
68
|
+
value = _this$props2.value;
|
|
69
|
+
var classname = cn('dtable-ui cell-formatter-container last-modified-formatter', containerClassName);
|
|
70
|
+
|
|
71
|
+
if (!value || Array.isArray(value) && value.length === 0) {
|
|
72
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
73
|
+
className: classname
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
var collaborators = this.getCollaborators();
|
|
78
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
79
|
+
className: classname
|
|
80
|
+
}, collaborators);
|
|
81
|
+
}
|
|
82
|
+
}]);
|
|
83
|
+
|
|
84
|
+
return LastModifierFormatter;
|
|
85
|
+
}(React.PureComponent);
|
|
86
|
+
|
|
87
|
+
export default LastModifierFormatter;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import cn from 'astro-classname';
|
|
8
|
+
import * as CellTypes from '../../utils/cell-types';
|
|
9
|
+
import { formatNumberToString, formatDateToString } from '../../utils/value-format-utils';
|
|
10
|
+
|
|
11
|
+
// link value is get form parant's interface
|
|
12
|
+
var LinkFormatter = /*#__PURE__*/function (_React$Component) {
|
|
13
|
+
_inherits(LinkFormatter, _React$Component);
|
|
14
|
+
|
|
15
|
+
var _super = _createSuper(LinkFormatter);
|
|
16
|
+
|
|
17
|
+
function LinkFormatter(props) {
|
|
18
|
+
var _this;
|
|
19
|
+
|
|
20
|
+
_classCallCheck(this, LinkFormatter);
|
|
21
|
+
|
|
22
|
+
_this = _super.call(this, props);
|
|
23
|
+
|
|
24
|
+
_this.getLinkedCellValue = function (row) {
|
|
25
|
+
if (!row) return [];
|
|
26
|
+
var _this$props = _this.props,
|
|
27
|
+
column = _this$props.column,
|
|
28
|
+
currentTableId = _this$props.currentTableId,
|
|
29
|
+
linkMetaData = _this$props.linkMetaData;
|
|
30
|
+
|
|
31
|
+
var _ref = column.data || {},
|
|
32
|
+
link_id = _ref.link_id,
|
|
33
|
+
table_id = _ref.table_id,
|
|
34
|
+
other_table_id = _ref.other_table_id;
|
|
35
|
+
|
|
36
|
+
_this.linkID = link_id;
|
|
37
|
+
_this.tableID = currentTableId === table_id ? table_id : other_table_id;
|
|
38
|
+
_this.otherTableID = _this.tableID === table_id ? other_table_id : table_id;
|
|
39
|
+
return linkMetaData.getLinkedCellValue(_this.linkID, _this.tableID, _this.otherTableID, row._id);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
_this.expandLinkedTableRow = function (row) {
|
|
43
|
+
var _this$props2 = _this.props,
|
|
44
|
+
enableOpenLinkedRow = _this$props2.enableOpenLinkedRow,
|
|
45
|
+
linkMetaData = _this$props2.linkMetaData;
|
|
46
|
+
|
|
47
|
+
if (enableOpenLinkedRow) {
|
|
48
|
+
linkMetaData.expandLinkedTableRow(row, _this.otherTableID);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
_this.getDisplayValues = function () {
|
|
53
|
+
var _this$props3 = _this.props,
|
|
54
|
+
column = _this$props3.column,
|
|
55
|
+
linkMetaData = _this$props3.linkMetaData;
|
|
56
|
+
var rowIds = _this.state.value;
|
|
57
|
+
|
|
58
|
+
if (rowIds && Array.isArray(rowIds) && rowIds.length > 0) {
|
|
59
|
+
var linkedTable = linkMetaData.getLinkedTable(_this.otherTableID);
|
|
60
|
+
var linkedRows = linkMetaData.getLinkedRows(_this.otherTableID, rowIds);
|
|
61
|
+
var result = linkedRows.map(function (row, index) {
|
|
62
|
+
var displayColumnKey = column.data.display_column_key;
|
|
63
|
+
|
|
64
|
+
var displayValue = _this.getDisplayValue(linkedTable, row, displayColumnKey);
|
|
65
|
+
|
|
66
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
67
|
+
key: index,
|
|
68
|
+
className: "link-item",
|
|
69
|
+
onClick: _this.expandLinkedTableRow.bind(_assertThisInitialized(_this), row)
|
|
70
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
71
|
+
className: "link-name"
|
|
72
|
+
}, displayValue));
|
|
73
|
+
});
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return null;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
_this.getDisplayValue = function (linkedTable, row, displayColumnKey) {
|
|
81
|
+
var value = row[displayColumnKey];
|
|
82
|
+
var linkedColumn = linkedTable.columns.find(function (column) {
|
|
83
|
+
return column.key === displayColumnKey;
|
|
84
|
+
});
|
|
85
|
+
var type = linkedColumn.type,
|
|
86
|
+
data = linkedColumn.data; // todo: improve
|
|
87
|
+
|
|
88
|
+
switch (type) {
|
|
89
|
+
case CellTypes.NUMBER:
|
|
90
|
+
{
|
|
91
|
+
return formatNumberToString(value, data);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
case CellTypes.DATE:
|
|
95
|
+
{
|
|
96
|
+
var format = data.format;
|
|
97
|
+
return formatDateToString(value, format);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
default:
|
|
101
|
+
return value;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
_this.linkID = '';
|
|
106
|
+
_this.tableID = '';
|
|
107
|
+
_this.otherTableID = '';
|
|
108
|
+
_this.state = {
|
|
109
|
+
value: _this.getLinkedCellValue(props.row)
|
|
110
|
+
};
|
|
111
|
+
return _this;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
_createClass(LinkFormatter, [{
|
|
115
|
+
key: "componentWillReceiveProps",
|
|
116
|
+
value: function componentWillReceiveProps(nextProps) {
|
|
117
|
+
var nextRow = nextProps.row;
|
|
118
|
+
|
|
119
|
+
if (nextRow._id !== this.props.row._id) {
|
|
120
|
+
this.setState({
|
|
121
|
+
value: this.getLinkedCellValue(nextRow)
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}, {
|
|
126
|
+
key: "render",
|
|
127
|
+
value: function render() {
|
|
128
|
+
var containerClassName = this.props.containerClassName;
|
|
129
|
+
var classname = cn('dtable-ui cell-formatter-container link-formatter', containerClassName);
|
|
130
|
+
var displayValues = this.getDisplayValues();
|
|
131
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
132
|
+
className: classname
|
|
133
|
+
}, displayValues);
|
|
134
|
+
}
|
|
135
|
+
}]);
|
|
136
|
+
|
|
137
|
+
return LinkFormatter;
|
|
138
|
+
}(React.Component);
|
|
139
|
+
|
|
140
|
+
LinkFormatter.defaultProps = {
|
|
141
|
+
enableOpenLinkedRow: false,
|
|
142
|
+
value: []
|
|
143
|
+
};
|
|
144
|
+
export default LinkFormatter;
|
|
@@ -0,0 +1,106 @@
|
|
|
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 cn from 'astro-classname';
|
|
7
|
+
import getPreviewContent from '../../utils/normalize-long-text-value';
|
|
8
|
+
|
|
9
|
+
var LongTextFormatter = /*#__PURE__*/function (_React$Component) {
|
|
10
|
+
_inherits(LongTextFormatter, _React$Component);
|
|
11
|
+
|
|
12
|
+
var _super = _createSuper(LongTextFormatter);
|
|
13
|
+
|
|
14
|
+
function LongTextFormatter() {
|
|
15
|
+
var _this;
|
|
16
|
+
|
|
17
|
+
_classCallCheck(this, LongTextFormatter);
|
|
18
|
+
|
|
19
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
20
|
+
args[_key] = arguments[_key];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
24
|
+
|
|
25
|
+
_this.renderLinks = function (value) {
|
|
26
|
+
var links = value.links;
|
|
27
|
+
if (!Array.isArray(links) || links.length === 0) return null;
|
|
28
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
29
|
+
className: "long-text-links"
|
|
30
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
31
|
+
className: "dtable-font dtable-icon-url"
|
|
32
|
+
}), links.length);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
_this.renderCheckList = function (value) {
|
|
36
|
+
var checkList = value.checklist;
|
|
37
|
+
if (!checkList || checkList.total === 0) return null;
|
|
38
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
39
|
+
className: "long-text-check-list"
|
|
40
|
+
}, /*#__PURE__*/React.createElement("i", {
|
|
41
|
+
className: "dtable-font dtable-icon-check-square-solid ".concat(checkList.completed === checkList.total ? 'long-text-check-list-completed' : '')
|
|
42
|
+
}), "".concat(checkList.completed, "/").concat(checkList.total));
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
_this.renderImages = function (value) {
|
|
46
|
+
var images = value.images;
|
|
47
|
+
if (!Array.isArray(images) || images.length === 0) return null;
|
|
48
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
49
|
+
className: "long-text-images"
|
|
50
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
51
|
+
src: images[0],
|
|
52
|
+
alt: ""
|
|
53
|
+
}), /*#__PURE__*/React.createElement("i", {
|
|
54
|
+
className: "image-number"
|
|
55
|
+
}, images.length > 1 ? '+' + images.length : null));
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
_this.renderContent = function (value) {
|
|
59
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
60
|
+
className: "long-text-content"
|
|
61
|
+
}, value.preview);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
_this.translateValue = function () {
|
|
65
|
+
var value = _this.props.value;
|
|
66
|
+
if (!value) return {};
|
|
67
|
+
var valueType = Object.prototype.toString.call(value);
|
|
68
|
+
|
|
69
|
+
if (valueType === '[object String]') {
|
|
70
|
+
return getPreviewContent(value);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (valueType === '[object Object]') {
|
|
74
|
+
return value;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return {};
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
return _this;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
_createClass(LongTextFormatter, [{
|
|
84
|
+
key: "render",
|
|
85
|
+
value: function render() {
|
|
86
|
+
var containerClassName = this.props.containerClassName;
|
|
87
|
+
var className = cn('dtable-ui cell-formatter-container long-text-formatter', containerClassName);
|
|
88
|
+
var value = this.translateValue();
|
|
89
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
90
|
+
className: className
|
|
91
|
+
}, this.renderLinks(value), this.renderCheckList(value), this.renderImages(value), this.renderContent(value));
|
|
92
|
+
}
|
|
93
|
+
}]);
|
|
94
|
+
|
|
95
|
+
return LongTextFormatter;
|
|
96
|
+
}(React.Component);
|
|
97
|
+
|
|
98
|
+
LongTextFormatter.defaultProps = {
|
|
99
|
+
value: {
|
|
100
|
+
text: '',
|
|
101
|
+
images: [],
|
|
102
|
+
links: [],
|
|
103
|
+
preview: ''
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
export default LongTextFormatter;
|
|
@@ -0,0 +1,57 @@
|
|
|
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 cn from 'astro-classname';
|
|
7
|
+
import moment from 'moment';
|
|
8
|
+
|
|
9
|
+
var MTimeFormatter = /*#__PURE__*/function (_React$Component) {
|
|
10
|
+
_inherits(MTimeFormatter, _React$Component);
|
|
11
|
+
|
|
12
|
+
var _super = _createSuper(MTimeFormatter);
|
|
13
|
+
|
|
14
|
+
function MTimeFormatter() {
|
|
15
|
+
var _this;
|
|
16
|
+
|
|
17
|
+
_classCallCheck(this, MTimeFormatter);
|
|
18
|
+
|
|
19
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
20
|
+
args[_key] = arguments[_key];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
24
|
+
|
|
25
|
+
_this.formatDate = function (date) {
|
|
26
|
+
return moment(date).format('YYYY-MM-DD HH:mm:ss');
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return _this;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
_createClass(MTimeFormatter, [{
|
|
33
|
+
key: "render",
|
|
34
|
+
value: function render() {
|
|
35
|
+
var _this$props = this.props,
|
|
36
|
+
date = _this$props.value,
|
|
37
|
+
containerClassName = _this$props.containerClassName;
|
|
38
|
+
var classname = cn('dtable-ui cell-formatter-container ctime-formatter', containerClassName);
|
|
39
|
+
|
|
40
|
+
if (date !== '') {
|
|
41
|
+
date = this.formatDate(date);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
45
|
+
className: classname
|
|
46
|
+
}, date);
|
|
47
|
+
}
|
|
48
|
+
}]);
|
|
49
|
+
|
|
50
|
+
return MTimeFormatter;
|
|
51
|
+
}(React.Component);
|
|
52
|
+
|
|
53
|
+
MTimeFormatter.defaultProps = {
|
|
54
|
+
value: '',
|
|
55
|
+
containerClassName: ''
|
|
56
|
+
};
|
|
57
|
+
export default MTimeFormatter;
|
|
@@ -0,0 +1,70 @@
|
|
|
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 cn from 'astro-classname';
|
|
7
|
+
import SelectItem from '../common/select-item';
|
|
8
|
+
|
|
9
|
+
var MultipleSelectFormatter = /*#__PURE__*/function (_React$PureComponent) {
|
|
10
|
+
_inherits(MultipleSelectFormatter, _React$PureComponent);
|
|
11
|
+
|
|
12
|
+
var _super = _createSuper(MultipleSelectFormatter);
|
|
13
|
+
|
|
14
|
+
function MultipleSelectFormatter() {
|
|
15
|
+
var _this;
|
|
16
|
+
|
|
17
|
+
_classCallCheck(this, MultipleSelectFormatter);
|
|
18
|
+
|
|
19
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
20
|
+
args[_key] = arguments[_key];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
24
|
+
|
|
25
|
+
_this.getOptions = function () {
|
|
26
|
+
var _this$props = _this.props,
|
|
27
|
+
value = _this$props.value,
|
|
28
|
+
options = _this$props.options;
|
|
29
|
+
return value.map(function (item) {
|
|
30
|
+
var option = options.find(function (option) {
|
|
31
|
+
return option.id === item || option.name === item;
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
if (option) {
|
|
35
|
+
return /*#__PURE__*/React.createElement(SelectItem, {
|
|
36
|
+
key: item,
|
|
37
|
+
option: option
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
return _this;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
_createClass(MultipleSelectFormatter, [{
|
|
47
|
+
key: "render",
|
|
48
|
+
value: function render() {
|
|
49
|
+
var _this$props2 = this.props,
|
|
50
|
+
value = _this$props2.value,
|
|
51
|
+
containerClassName = _this$props2.containerClassName;
|
|
52
|
+
var classname = cn('dtable-ui cell-formatter-container multiple-select-formatter', containerClassName);
|
|
53
|
+
|
|
54
|
+
if (!value || Array.isArray(value) && value.length === 0) {
|
|
55
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
56
|
+
className: classname
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
var options = this.getOptions();
|
|
61
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
62
|
+
className: classname
|
|
63
|
+
}, options);
|
|
64
|
+
}
|
|
65
|
+
}]);
|
|
66
|
+
|
|
67
|
+
return MultipleSelectFormatter;
|
|
68
|
+
}(React.PureComponent);
|
|
69
|
+
|
|
70
|
+
export default MultipleSelectFormatter;
|