dtable-ui-component 0.3.20 → 0.3.21
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/lib/AutoNumberFormatter/index.js +2 -9
- package/lib/ButtonFormatter/index.js +4 -17
- package/lib/CTimeFormatter/index.js +2 -15
- package/lib/CheckboxEditor/index.js +0 -13
- package/lib/CheckboxFormatter/index.js +2 -11
- package/lib/CollaboratorEditor/index.js +6 -44
- package/lib/CollaboratorEditor/mb-collaborator-editor-popover/index.js +2 -27
- package/lib/CollaboratorEditor/pc-collaborator-editor-popover/index.js +2 -20
- package/lib/CollaboratorFormatter/index.js +6 -23
- package/lib/CollaboratorItem/index.js +2 -14
- package/lib/CreatorFormatter/index.js +6 -22
- package/lib/DTableCustomizeCollaboratorSelect/index.js +16 -37
- package/lib/DTableCustomizeCollaboratorSelect/utils.js +6 -5
- package/lib/DTableCustomizeSelect/index.js +14 -37
- package/lib/DTablePopover/index.js +8 -26
- package/lib/DTableRadio/index.js +0 -2
- package/lib/DTableSearchInput/index.js +12 -36
- package/lib/DTableSelect/index.js +13 -27
- package/lib/DTableSwitch/index.js +4 -6
- package/lib/DateEditor/index.js +8 -27
- package/lib/DateEditor/mb-date-editor-popover/index.js +8 -42
- package/lib/DateEditor/pc-date-editor-popover.js +7 -27
- package/lib/DateFormatter/index.js +3 -12
- package/lib/DigitalSignFormatter/index.js +8 -26
- package/lib/DigitalSignFormatter/utils.js +3 -6
- package/lib/DurationFormatter/index.js +3 -10
- package/lib/EditEditorButton/index.js +0 -7
- package/lib/EmailFormatter/index.js +2 -9
- package/lib/FieldDisplaySetting/field-item.js +6 -20
- package/lib/FieldDisplaySetting/index.js +8 -13
- package/lib/FileEditor/index.js +0 -8
- package/lib/FileFormatter/index.js +3 -14
- package/lib/FileItemFormatter/index.js +0 -13
- package/lib/FileItemFormatter/utils.js +0 -6
- package/lib/FileUploader/index.js +0 -16
- package/lib/FormulaFormatter/cell-value-validator.js +0 -10
- package/lib/FormulaFormatter/index.js +8 -38
- package/lib/FormulaFormatter/utils.js +0 -17
- package/lib/GeolocationFormatter/index.js +4 -13
- package/lib/HtmlLongTextFormatter/index.js +0 -21
- package/lib/HtmlLongTextFormatter/markdown2html.js +2 -17
- package/lib/HtmlLongTextFormatter/unified/index.js +29 -102
- package/lib/HtmlLongTextFormatter/vfile/core.js +13 -32
- package/lib/HtmlLongTextFormatter/vfile/index.js +4 -11
- package/lib/ImageFormatter/images-lazy-load.js +5 -35
- package/lib/ImageFormatter/index.js +7 -34
- package/lib/ImageFormatter/utils.js +0 -1
- package/lib/ImagePreviewerLightbox/index.js +11 -13
- package/lib/LastModifierFormatter/index.js +6 -22
- package/lib/LinkEditor/index.js +23 -69
- package/lib/LinkEditor/link-editor-option.js +2 -18
- package/lib/LinkEditor/mb-link-editor-popover/index.js +2 -27
- package/lib/LinkEditor/pc-link-editor-popover/index.js +2 -20
- package/lib/LinkFormatter/index.js +12 -35
- package/lib/LongTextFormatter/index.js +2 -6
- package/lib/MBEditorHeader/index.js +6 -13
- package/lib/MTimeFormatter/index.js +2 -15
- package/lib/ModalPortal/index.js +0 -8
- package/lib/MultipleSelectEditor/index.js +4 -42
- package/lib/MultipleSelectFormatter/index.js +4 -17
- package/lib/NotificationPopover/index.js +3 -22
- package/lib/NumberEditor/index.js +7 -35
- package/lib/NumberFormatter/index.js +3 -12
- package/lib/RateFormatter/index.js +10 -25
- package/lib/RowExpandEmailFormatter/index.js +2 -13
- package/lib/RowExpandFileFormatter/index.js +6 -15
- package/lib/RowExpandFileFormatter/row-expand-file-item-formatter.js +6 -24
- package/lib/RowExpandFormatter/index.js +10 -60
- package/lib/RowExpandFormulaFormatter/index.js +10 -41
- package/lib/RowExpandImageFormatter/index.js +8 -27
- package/lib/RowExpandImageFormatter/row-expand-image-item-formatter.js +11 -27
- package/lib/RowExpandImageFormatter/utils.js +0 -1
- package/lib/RowExpandLinkFormatter/collaborator-item-formatter.js +4 -35
- package/lib/RowExpandLinkFormatter/index.js +6 -28
- package/lib/RowExpandLinkFormatter/utils.js +0 -4
- package/lib/RowExpandLinkFormatter/value-display-utils.js +2 -2
- package/lib/RowExpandRateFormatter/index.js +8 -23
- package/lib/RowExpandUrlFormatter/index.js +2 -14
- package/lib/SelectItem/index.js +2 -13
- package/lib/SelectOptionGroup/index.js +13 -42
- package/lib/SelectOptionGroup/option.js +0 -14
- package/lib/SimpleLongTextFormatter/index.js +0 -26
- package/lib/SimpleLongTextFormatter/normalize-long-text-value.js +2 -12
- package/lib/SimpleLongTextFormatter/widgets/LongTextPreview.js +1 -16
- package/lib/SimpleLongTextFormatter/widgets/dtable-markdown-viewer.js +0 -17
- package/lib/SingleSelectEditor/index.js +4 -37
- package/lib/SingleSelectFormatter/index.js +5 -17
- package/lib/TextEditor/index.js +3 -22
- package/lib/TextFormatter/index.js +2 -15
- package/lib/UrlFormatter/index.js +2 -9
- package/lib/cellFormatterFactory/index.js +0 -5
- package/lib/common/delete-tip.js +4 -16
- package/lib/common/modal-portal.js +0 -8
- package/lib/formatterConfig/base-formatter-config.js +0 -2
- package/lib/formatterConfig/index.js +0 -4
- package/lib/index.js +12 -6
- package/lib/lang/index.js +0 -7
- package/lib/select-editor/mb-select-editor-popover/index.js +6 -38
- package/lib/select-editor/pc-select-editor-popover/index.js +3 -25
- package/lib/select-editor/select-editor-option.js +2 -17
- package/lib/toaster/alert.js +0 -12
- package/lib/toaster/toast.js +1 -22
- package/lib/toaster/toastManager.js +7 -30
- package/lib/toaster/toaster.js +4 -15
- package/lib/utils/editor-utils.js +0 -20
- package/lib/utils/utils.js +2 -5
- package/package.json +5 -5
|
@@ -5,43 +5,32 @@ import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import Loading from '../Loading';
|
|
7
7
|
import { getImageThumbnailUrl } from './utils';
|
|
8
|
-
|
|
9
8
|
var ImagesLazyLoad = /*#__PURE__*/function (_React$Component) {
|
|
10
9
|
_inherits(ImagesLazyLoad, _React$Component);
|
|
11
|
-
|
|
12
10
|
var _super = _createSuper(ImagesLazyLoad);
|
|
13
|
-
|
|
14
11
|
function ImagesLazyLoad(_props) {
|
|
15
12
|
var _this;
|
|
16
|
-
|
|
17
13
|
_classCallCheck(this, ImagesLazyLoad);
|
|
18
|
-
|
|
19
14
|
_this = _super.call(this, _props);
|
|
20
|
-
|
|
21
15
|
_this.componentDidMount = function () {
|
|
22
16
|
_this.lazyLoadImages(_this.props);
|
|
23
17
|
};
|
|
24
|
-
|
|
25
18
|
_this.UNSAFE_componentWillReceiveProps = function (nextProps) {
|
|
26
19
|
if (nextProps.images.toString() !== _this.props.images.toString()) {
|
|
27
20
|
_this.lazyLoadImages(nextProps);
|
|
28
21
|
}
|
|
29
22
|
};
|
|
30
|
-
|
|
31
23
|
_this.componentWillUnmount = function () {
|
|
32
24
|
// prevent async operation
|
|
33
25
|
_this.setState = function (state, callback) {
|
|
34
26
|
return;
|
|
35
27
|
};
|
|
36
28
|
};
|
|
37
|
-
|
|
38
29
|
_this.lazyLoadImages = function (props) {
|
|
39
30
|
var images = props.images;
|
|
40
|
-
|
|
41
31
|
if (!Array.isArray(images) || images.length === 0) {
|
|
42
32
|
return;
|
|
43
33
|
}
|
|
44
|
-
|
|
45
34
|
_this.setState({
|
|
46
35
|
images: images,
|
|
47
36
|
loadedImages: [],
|
|
@@ -50,21 +39,18 @@ var ImagesLazyLoad = /*#__PURE__*/function (_React$Component) {
|
|
|
50
39
|
var server = _this.props.server;
|
|
51
40
|
images.forEach(function (item, index) {
|
|
52
41
|
var url = getImageThumbnailUrl(item, server);
|
|
53
|
-
|
|
54
42
|
_this.lazyLoadImage(url, function (image) {
|
|
55
43
|
var _this$state = _this.state,
|
|
56
|
-
|
|
57
|
-
|
|
44
|
+
loadedCount = _this$state.loadedCount,
|
|
45
|
+
loadedImages = _this$state.loadedImages;
|
|
58
46
|
var newImageList = loadedImages.slice(0);
|
|
59
47
|
newImageList[index] = image;
|
|
60
|
-
|
|
61
48
|
_this.setState({
|
|
62
49
|
loadedCount: loadedCount + 1,
|
|
63
50
|
loadedImages: newImageList
|
|
64
51
|
});
|
|
65
52
|
}, function () {
|
|
66
53
|
var loadedCount = _this.state.loadedCount;
|
|
67
|
-
|
|
68
54
|
_this.setState({
|
|
69
55
|
loadedCount: loadedCount + 1
|
|
70
56
|
});
|
|
@@ -72,36 +58,27 @@ var ImagesLazyLoad = /*#__PURE__*/function (_React$Component) {
|
|
|
72
58
|
});
|
|
73
59
|
});
|
|
74
60
|
};
|
|
75
|
-
|
|
76
61
|
_this.lazyLoadImage = function (url, resolve, reject) {
|
|
77
62
|
if (!url) {
|
|
78
63
|
reject('img path is require');
|
|
79
64
|
return;
|
|
80
65
|
}
|
|
81
|
-
|
|
82
66
|
var image = new Image();
|
|
83
|
-
|
|
84
67
|
image.onload = function () {
|
|
85
68
|
resolve(image);
|
|
86
69
|
};
|
|
87
|
-
|
|
88
70
|
image.onerror = function (e) {
|
|
89
71
|
reject(e);
|
|
90
72
|
};
|
|
91
|
-
|
|
92
73
|
image.src = url;
|
|
93
74
|
};
|
|
94
|
-
|
|
95
75
|
_this.onMouseDown = function (event) {
|
|
96
76
|
event.stopPropagation();
|
|
97
77
|
};
|
|
98
|
-
|
|
99
78
|
_this.onImageClick = function (event, index) {
|
|
100
79
|
event.stopPropagation();
|
|
101
|
-
|
|
102
80
|
_this.props.onImageClick(index);
|
|
103
81
|
};
|
|
104
|
-
|
|
105
82
|
_this.state = {
|
|
106
83
|
images: _props.images,
|
|
107
84
|
loadedImages: [],
|
|
@@ -109,21 +86,17 @@ var ImagesLazyLoad = /*#__PURE__*/function (_React$Component) {
|
|
|
109
86
|
};
|
|
110
87
|
return _this;
|
|
111
88
|
}
|
|
112
|
-
|
|
113
89
|
_createClass(ImagesLazyLoad, [{
|
|
114
90
|
key: "render",
|
|
115
91
|
value: function render() {
|
|
116
92
|
var _this2 = this;
|
|
117
|
-
|
|
118
93
|
var _this$state2 = this.state,
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
94
|
+
images = _this$state2.images,
|
|
95
|
+
loadedImages = _this$state2.loadedImages,
|
|
96
|
+
loadedCount = _this$state2.loadedCount;
|
|
123
97
|
if (!Array.isArray(images) || images.length === 0) {
|
|
124
98
|
return '';
|
|
125
99
|
}
|
|
126
|
-
|
|
127
100
|
if (images.length > loadedCount) {
|
|
128
101
|
var style = {
|
|
129
102
|
marginLeft: '4px'
|
|
@@ -133,7 +106,6 @@ var ImagesLazyLoad = /*#__PURE__*/function (_React$Component) {
|
|
|
133
106
|
className: "d-flex align-items-center"
|
|
134
107
|
}, /*#__PURE__*/React.createElement(Loading, null));
|
|
135
108
|
}
|
|
136
|
-
|
|
137
109
|
return loadedImages.map(function (image, index) {
|
|
138
110
|
return /*#__PURE__*/React.createElement("img", {
|
|
139
111
|
key: index,
|
|
@@ -148,8 +120,6 @@ var ImagesLazyLoad = /*#__PURE__*/function (_React$Component) {
|
|
|
148
120
|
});
|
|
149
121
|
}
|
|
150
122
|
}]);
|
|
151
|
-
|
|
152
123
|
return ImagesLazyLoad;
|
|
153
124
|
}(React.Component);
|
|
154
|
-
|
|
155
125
|
export default ImagesLazyLoad;
|
|
@@ -8,108 +8,84 @@ import ImagesLazyLoad from './images-lazy-load';
|
|
|
8
8
|
import { getImageThumbnailUrl } from './utils';
|
|
9
9
|
import ImagePreviewerLightbox from '../ImagePreviewerLightbox';
|
|
10
10
|
import './index.css';
|
|
11
|
-
|
|
12
11
|
var ImageFormatter = /*#__PURE__*/function (_React$Component) {
|
|
13
12
|
_inherits(ImageFormatter, _React$Component);
|
|
14
|
-
|
|
15
13
|
var _super = _createSuper(ImageFormatter);
|
|
16
|
-
|
|
17
14
|
function ImageFormatter(props) {
|
|
18
15
|
var _this;
|
|
19
|
-
|
|
20
16
|
_classCallCheck(this, ImageFormatter);
|
|
21
|
-
|
|
22
17
|
_this = _super.call(this, props);
|
|
23
|
-
|
|
24
18
|
_this.onImageClick = function (index) {
|
|
25
19
|
if (!_this.props.isSupportPreview) return;
|
|
26
|
-
|
|
27
20
|
_this.setState({
|
|
28
21
|
isPreviewImage: true,
|
|
29
22
|
previewImageIndex: index
|
|
30
23
|
});
|
|
31
24
|
};
|
|
32
|
-
|
|
33
25
|
_this.closeImagePopup = function () {
|
|
34
26
|
if (!_this.props.isSupportPreview) return;
|
|
35
|
-
|
|
36
27
|
if (_this.props.onCloseCallback) {
|
|
37
28
|
_this.props.onCloseCallback();
|
|
38
29
|
}
|
|
39
|
-
|
|
40
30
|
_this.setState({
|
|
41
31
|
isPreviewImage: false,
|
|
42
32
|
previewImageIndex: -1
|
|
43
33
|
});
|
|
44
34
|
};
|
|
45
|
-
|
|
46
35
|
_this.movePrev = function () {
|
|
47
36
|
var images = _this.props.value;
|
|
48
|
-
|
|
49
37
|
_this.setState(function (prevState) {
|
|
50
38
|
return {
|
|
51
39
|
previewImageIndex: (prevState.previewImageIndex + images.length - 1) % images.length
|
|
52
40
|
};
|
|
53
41
|
});
|
|
54
42
|
};
|
|
55
|
-
|
|
56
43
|
_this.moveNext = function () {
|
|
57
44
|
var images = _this.props.value;
|
|
58
|
-
|
|
59
45
|
_this.setState(function (prevState) {
|
|
60
46
|
return {
|
|
61
47
|
previewImageIndex: (prevState.previewImageIndex + 1) % images.length
|
|
62
48
|
};
|
|
63
49
|
});
|
|
64
50
|
};
|
|
65
|
-
|
|
66
51
|
_this.downloadImage = function (imageItemUrl) {
|
|
67
52
|
if (!_this.props.downloadImage) return;
|
|
68
|
-
|
|
69
53
|
_this.props.downloadImage(imageItemUrl);
|
|
70
54
|
};
|
|
71
|
-
|
|
72
55
|
_this.deleteImage = function (index) {
|
|
73
56
|
var readOnly = _this.props.readOnly;
|
|
74
57
|
if (readOnly) return;
|
|
75
58
|
if (!_this.props.deleteImage) return;
|
|
76
|
-
|
|
77
59
|
_this.props.deleteImage(index);
|
|
78
60
|
};
|
|
79
|
-
|
|
80
61
|
_this.onRotateImage = function (index, degree) {
|
|
81
62
|
var readOnly = _this.props.readOnly;
|
|
82
63
|
if (readOnly) return;
|
|
83
64
|
if (!_this.props.rotateImage) return;
|
|
84
|
-
|
|
85
65
|
_this.props.rotateImage(index, degree);
|
|
86
66
|
};
|
|
87
|
-
|
|
88
67
|
_this.state = {
|
|
89
68
|
isPreviewImage: false,
|
|
90
69
|
previewImageIndex: -1
|
|
91
70
|
};
|
|
92
71
|
return _this;
|
|
93
72
|
}
|
|
94
|
-
|
|
95
73
|
_createClass(ImageFormatter, [{
|
|
96
74
|
key: "render",
|
|
97
75
|
value: function render() {
|
|
98
76
|
var _this$props = this.props,
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
77
|
+
isSample = _this$props.isSample,
|
|
78
|
+
value = _this$props.value,
|
|
79
|
+
server = _this$props.server,
|
|
80
|
+
containerClassName = _this$props.containerClassName,
|
|
81
|
+
readOnly = _this$props.readOnly;
|
|
104
82
|
var className = classnames('dtable-ui cell-formatter-container image-formatter', containerClassName);
|
|
105
83
|
var _this$state = this.state,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
84
|
+
isPreviewImage = _this$state.isPreviewImage,
|
|
85
|
+
previewImageIndex = _this$state.previewImageIndex;
|
|
109
86
|
if (!Array.isArray(value) || value.length === 0) {
|
|
110
87
|
return null;
|
|
111
88
|
}
|
|
112
|
-
|
|
113
89
|
if (isSample) {
|
|
114
90
|
var item = value[0];
|
|
115
91
|
var url = getImageThumbnailUrl(item, server);
|
|
@@ -123,7 +99,6 @@ var ImageFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
123
99
|
className: "image-item-count"
|
|
124
100
|
}, "+".concat(value.length)));
|
|
125
101
|
}
|
|
126
|
-
|
|
127
102
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
128
103
|
className: className
|
|
129
104
|
}, /*#__PURE__*/React.createElement(ImagesLazyLoad, {
|
|
@@ -146,10 +121,8 @@ var ImageFormatter = /*#__PURE__*/function (_React$Component) {
|
|
|
146
121
|
}));
|
|
147
122
|
}
|
|
148
123
|
}]);
|
|
149
|
-
|
|
150
124
|
return ImageFormatter;
|
|
151
125
|
}(React.Component);
|
|
152
|
-
|
|
153
126
|
ImageFormatter.defaultProps = {
|
|
154
127
|
isSample: false,
|
|
155
128
|
isSupportPreview: false,
|
|
@@ -3,22 +3,21 @@ import classnames from 'classnames';
|
|
|
3
3
|
import Lightbox from '@seafile/react-image-lightbox';
|
|
4
4
|
import { checkSVGImage, isInternalImg } from './utils';
|
|
5
5
|
import '@seafile/react-image-lightbox/style.css';
|
|
6
|
-
|
|
7
6
|
function ImagePreviewerLightbox(props) {
|
|
8
7
|
var imageItems = props.imageItems,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
imageIndex = props.imageIndex,
|
|
9
|
+
deleteImage = props.deleteImage,
|
|
10
|
+
downloadImage = props.downloadImage,
|
|
11
|
+
onRotateImage = props.onRotateImage,
|
|
12
|
+
readOnly = props.readOnly,
|
|
13
|
+
server = props.server,
|
|
14
|
+
moveToPrevRowImage = props.moveToPrevRowImage,
|
|
15
|
+
moveToNextRowImage = props.moveToNextRowImage,
|
|
16
|
+
className = props.className;
|
|
18
17
|
var imageItemsLength = imageItems.length;
|
|
19
18
|
var URL = imageItems[imageIndex];
|
|
20
|
-
var imageTitle = URL ? decodeURI(URL.slice(URL.lastIndexOf('/') + 1)) : '';
|
|
21
|
-
|
|
19
|
+
var imageTitle = URL ? decodeURI(URL.slice(URL.lastIndexOf('/') + 1)) : '';
|
|
20
|
+
// svg image is vectorgraph and can't rotate, external image can't rotate
|
|
22
21
|
var canRotateImage = onRotateImage && !readOnly && !checkSVGImage(URL) && isInternalImg(URL, server);
|
|
23
22
|
var imageTitleEl = /*#__PURE__*/React.createElement("span", {
|
|
24
23
|
className: "d-flex"
|
|
@@ -49,5 +48,4 @@ function ImagePreviewerLightbox(props) {
|
|
|
49
48
|
} : null
|
|
50
49
|
});
|
|
51
50
|
}
|
|
52
|
-
|
|
53
51
|
export default ImagePreviewerLightbox;
|
|
@@ -7,7 +7,6 @@ import classnames from 'classnames';
|
|
|
7
7
|
import CollaboratorItem from '../CollaboratorItem';
|
|
8
8
|
import DefaultAvatar from '../assets/images/avatar/default_avatar.png';
|
|
9
9
|
import './index.css';
|
|
10
|
-
|
|
11
10
|
// there will be there conditions
|
|
12
11
|
// 1 value is not exist, typeof value is array, but it's length is 0
|
|
13
12
|
// 2 value is exist, but can't find in collaborators
|
|
@@ -15,75 +14,60 @@ import './index.css';
|
|
|
15
14
|
// 4 value is exist, typeof value is array
|
|
16
15
|
var LastModifierFormatter = /*#__PURE__*/function (_React$PureComponent) {
|
|
17
16
|
_inherits(LastModifierFormatter, _React$PureComponent);
|
|
18
|
-
|
|
19
17
|
var _super = _createSuper(LastModifierFormatter);
|
|
20
|
-
|
|
21
18
|
function LastModifierFormatter() {
|
|
22
19
|
var _this;
|
|
23
|
-
|
|
24
20
|
_classCallCheck(this, LastModifierFormatter);
|
|
25
|
-
|
|
26
21
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
27
22
|
args[_key] = arguments[_key];
|
|
28
23
|
}
|
|
29
|
-
|
|
30
24
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
31
|
-
|
|
32
25
|
_this.getCollaborators = function () {
|
|
33
26
|
var _this$props = _this.props,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
value = _this$props.value,
|
|
28
|
+
collaborators = _this$props.collaborators;
|
|
37
29
|
if (!Array.isArray(value)) {
|
|
38
30
|
value = [value];
|
|
39
31
|
}
|
|
40
|
-
|
|
41
32
|
return value.map(function (item, index) {
|
|
42
33
|
var collaborator = collaborators.find(function (collaborator) {
|
|
43
34
|
return collaborator.email === item;
|
|
44
|
-
});
|
|
45
|
-
|
|
35
|
+
});
|
|
36
|
+
// the collaborator can be not exist, because the row modified by third app
|
|
46
37
|
if (!collaborator) {
|
|
47
38
|
collaborator = {
|
|
48
39
|
name: item,
|
|
49
40
|
avatar_url: DefaultAvatar
|
|
50
41
|
};
|
|
51
42
|
}
|
|
52
|
-
|
|
53
43
|
return /*#__PURE__*/React.createElement(CollaboratorItem, {
|
|
54
44
|
key: index,
|
|
55
45
|
collaborator: collaborator
|
|
56
46
|
});
|
|
57
47
|
});
|
|
58
48
|
};
|
|
59
|
-
|
|
60
49
|
return _this;
|
|
61
50
|
}
|
|
62
|
-
|
|
63
51
|
_createClass(LastModifierFormatter, [{
|
|
64
52
|
key: "render",
|
|
65
53
|
value: function render() {
|
|
66
54
|
var _this$props2 = this.props,
|
|
67
|
-
|
|
68
|
-
|
|
55
|
+
containerClassName = _this$props2.containerClassName,
|
|
56
|
+
value = _this$props2.value;
|
|
69
57
|
var classname = classnames('dtable-ui cell-formatter-container last-modified-formatter', containerClassName);
|
|
70
|
-
|
|
71
58
|
if (!value || Array.isArray(value) && value.length === 0) {
|
|
72
59
|
return /*#__PURE__*/React.createElement("div", {
|
|
73
60
|
className: classname
|
|
74
61
|
});
|
|
75
62
|
}
|
|
76
|
-
|
|
77
63
|
var collaborators = this.getCollaborators();
|
|
78
64
|
return /*#__PURE__*/React.createElement("div", {
|
|
79
65
|
className: classname
|
|
80
66
|
}, collaborators);
|
|
81
67
|
}
|
|
82
68
|
}]);
|
|
83
|
-
|
|
84
69
|
return LastModifierFormatter;
|
|
85
70
|
}(React.PureComponent);
|
|
86
|
-
|
|
87
71
|
LastModifierFormatter.defaultProps = {
|
|
88
72
|
value: ''
|
|
89
73
|
};
|
package/lib/LinkEditor/index.js
CHANGED
|
@@ -12,95 +12,77 @@ import LinkEditorOption from './link-editor-option';
|
|
|
12
12
|
import PCLinkEditorPopover from './pc-link-editor-popover';
|
|
13
13
|
import MBLinkEditorPopover from './mb-link-editor-popover';
|
|
14
14
|
import './index.css';
|
|
15
|
-
|
|
16
15
|
var LinkEditor = /*#__PURE__*/function (_React$Component) {
|
|
17
16
|
_inherits(LinkEditor, _React$Component);
|
|
18
|
-
|
|
19
17
|
var _super = _createSuper(LinkEditor);
|
|
20
|
-
|
|
21
18
|
function LinkEditor(props) {
|
|
22
19
|
var _this;
|
|
23
|
-
|
|
24
20
|
_classCallCheck(this, LinkEditor);
|
|
25
|
-
|
|
26
21
|
_this = _super.call(this, props);
|
|
27
|
-
|
|
28
22
|
_this.onDocumentToggle = function (e) {
|
|
29
23
|
if (_this.editorContainer !== e.target && !_this.editorContainer.contains(e.target)) {
|
|
30
24
|
_this.onClosePopover();
|
|
31
25
|
}
|
|
32
26
|
};
|
|
33
|
-
|
|
34
27
|
_this.getLinkedCellValue = function () {
|
|
35
28
|
var _this$props = _this.props,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
row = _this$props.row,
|
|
30
|
+
column = _this$props.column,
|
|
31
|
+
linkMetaData = _this$props.linkMetaData;
|
|
40
32
|
var _ref = column.data || {},
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
33
|
+
link_id = _ref.link_id,
|
|
34
|
+
table_id = _ref.table_id,
|
|
35
|
+
other_table_id = _ref.other_table_id;
|
|
45
36
|
_this.linkId = link_id;
|
|
46
37
|
_this.tableId = table_id;
|
|
47
38
|
_this.otherTableId = other_table_id;
|
|
48
39
|
return linkMetaData.getLinkedCellValue(_this.linkId, _this.tableId, _this.otherTableId, row._id);
|
|
49
40
|
};
|
|
50
|
-
|
|
51
41
|
_this.formatLinkedValuesToOptions = function () {
|
|
52
42
|
var _this$props2 = _this.props,
|
|
53
|
-
|
|
54
|
-
|
|
43
|
+
column = _this$props2.column,
|
|
44
|
+
linkMetaData = _this$props2.linkMetaData;
|
|
55
45
|
var rowIds = _this.state.newValue;
|
|
56
|
-
|
|
57
46
|
if (rowIds && Array.isArray(rowIds) && rowIds.length > 0) {
|
|
58
47
|
var linkedRows = linkMetaData.getLinkedRows(_this.otherTableId, rowIds);
|
|
59
48
|
var linkedTable = linkMetaData.getLinkedTable(_this.otherTableId);
|
|
60
49
|
return linkedRows.map(function (linkedRow) {
|
|
61
|
-
var displayColumnKey = column.data.display_column_key;
|
|
62
|
-
|
|
50
|
+
var displayColumnKey = column.data.display_column_key;
|
|
51
|
+
// format value to display
|
|
63
52
|
var displayValue = _this.getDisplayValue(linkedTable, linkedRow, displayColumnKey);
|
|
64
|
-
|
|
65
53
|
return {
|
|
66
54
|
id: linkedRow._id,
|
|
67
55
|
name: displayValue
|
|
68
56
|
};
|
|
69
57
|
});
|
|
70
58
|
}
|
|
71
|
-
|
|
72
59
|
return [];
|
|
73
60
|
};
|
|
74
|
-
|
|
75
61
|
_this.getDisplayValue = function (linkedTable, linkedRow, displayColumnKey) {
|
|
76
62
|
var value = linkedRow[displayColumnKey];
|
|
77
63
|
var linkedColumn = linkedTable.columns.find(function (column) {
|
|
78
64
|
return column.key === displayColumnKey;
|
|
79
65
|
});
|
|
80
66
|
var type = linkedColumn.type,
|
|
81
|
-
|
|
82
|
-
|
|
67
|
+
data = linkedColumn.data;
|
|
83
68
|
switch (type) {
|
|
84
69
|
case CellType.NUMBER:
|
|
85
70
|
{
|
|
86
71
|
return getNumberDisplayString(value, data);
|
|
87
72
|
}
|
|
88
|
-
|
|
89
73
|
case CellType.DATE:
|
|
90
74
|
{
|
|
91
75
|
var format = data.format;
|
|
92
76
|
return getDateDisplayString(value, format);
|
|
93
77
|
}
|
|
94
|
-
|
|
95
78
|
default:
|
|
96
79
|
return value;
|
|
97
80
|
}
|
|
98
81
|
};
|
|
99
|
-
|
|
100
82
|
_this.getAvailableLinkedOptions = function () {
|
|
101
83
|
var _this$props3 = _this.props,
|
|
102
|
-
|
|
103
|
-
|
|
84
|
+
column = _this$props3.column,
|
|
85
|
+
linkMetaData = _this$props3.linkMetaData;
|
|
104
86
|
var displayColumnKey = column.data.display_column_key;
|
|
105
87
|
var linkedTable = linkMetaData.getLinkedTable(_this.otherTableId);
|
|
106
88
|
var availableRows = linkedTable.rows.filter(function (row) {
|
|
@@ -108,7 +90,6 @@ var LinkEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
108
90
|
});
|
|
109
91
|
var availableOptions = availableRows.map(function (row) {
|
|
110
92
|
var displayValue = _this.getDisplayValue(linkedTable, row, displayColumnKey);
|
|
111
|
-
|
|
112
93
|
return {
|
|
113
94
|
id: row._id,
|
|
114
95
|
name: displayValue
|
|
@@ -116,23 +97,18 @@ var LinkEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
116
97
|
});
|
|
117
98
|
return availableOptions;
|
|
118
99
|
};
|
|
119
|
-
|
|
120
|
-
|
|
100
|
+
_this.onCommit = function (newValue) {
|
|
101
|
+
// nothing todo
|
|
121
102
|
};
|
|
122
|
-
|
|
123
103
|
_this.onAddOptionToggle = function (event) {
|
|
124
104
|
event.nativeEvent.stopImmediatePropagation();
|
|
125
105
|
event.stopPropagation();
|
|
126
|
-
|
|
127
106
|
if (_this.props.isReadOnly) {
|
|
128
107
|
return;
|
|
129
108
|
}
|
|
130
|
-
|
|
131
109
|
var isPopoverShow = !_this.state.isPopoverShow;
|
|
132
|
-
|
|
133
110
|
if (isPopoverShow) {
|
|
134
111
|
var popoverPosition = _this.caculatePopoverPosition();
|
|
135
|
-
|
|
136
112
|
_this.setState({
|
|
137
113
|
isPopoverShow: isPopoverShow,
|
|
138
114
|
popoverPosition: popoverPosition
|
|
@@ -143,18 +119,14 @@ var LinkEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
143
119
|
});
|
|
144
120
|
}
|
|
145
121
|
};
|
|
146
|
-
|
|
147
122
|
_this.onOptionItemToggle = function (option) {
|
|
148
123
|
var _this$props4 = _this.props,
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
124
|
+
row = _this$props4.row,
|
|
125
|
+
linkMetaData = _this$props4.linkMetaData;
|
|
152
126
|
var newValue = _this.state.newValue.slice();
|
|
153
|
-
|
|
154
127
|
var optionIndex = newValue.findIndex(function (option_id) {
|
|
155
128
|
return option_id === option.id;
|
|
156
129
|
});
|
|
157
|
-
|
|
158
130
|
if (optionIndex !== -1) {
|
|
159
131
|
newValue.splice(optionIndex, 1);
|
|
160
132
|
linkMetaData.removeLink(_this.linkId, _this.tableId, _this.otherTableId, row._id, option.id);
|
|
@@ -162,45 +134,36 @@ var LinkEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
162
134
|
newValue.push(option.id);
|
|
163
135
|
linkMetaData.addLink(_this.linkId, _this.tableId, _this.otherTableId, row._id, option.id);
|
|
164
136
|
}
|
|
165
|
-
|
|
166
137
|
_this.setState({
|
|
167
138
|
newValue: newValue
|
|
168
139
|
});
|
|
169
140
|
};
|
|
170
|
-
|
|
171
141
|
_this.onDeleteOption = function (option) {
|
|
172
142
|
var _this$props5 = _this.props,
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
143
|
+
row = _this$props5.row,
|
|
144
|
+
linkMetaData = _this$props5.linkMetaData;
|
|
176
145
|
var newValue = _this.state.newValue.slice();
|
|
177
|
-
|
|
178
146
|
var optionIndex = newValue.findIndex(function (option_id) {
|
|
179
147
|
return option_id === option.id;
|
|
180
148
|
});
|
|
181
149
|
newValue.splice(optionIndex, 1);
|
|
182
|
-
|
|
183
150
|
_this.setState({
|
|
184
151
|
newValue: newValue
|
|
185
152
|
}, function () {
|
|
186
153
|
linkMetaData.removeLink(_this.linkId, _this.tableId, _this.otherTableId, row._id, option.id);
|
|
187
154
|
});
|
|
188
155
|
};
|
|
189
|
-
|
|
190
156
|
_this.caculatePopoverPosition = function () {
|
|
191
157
|
var POPOVER_MAX_HEIGHT = 200;
|
|
192
158
|
var innerHeight = window.innerHeight;
|
|
193
|
-
|
|
194
159
|
var _this$editor$getClien = _this.editor.getClientRects()[0],
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
160
|
+
top = _this$editor$getClien.top,
|
|
161
|
+
height = _this$editor$getClien.height;
|
|
198
162
|
var isBelow = innerHeight - (top + height) > POPOVER_MAX_HEIGHT;
|
|
199
163
|
var position = {
|
|
200
164
|
top: height + 1,
|
|
201
165
|
left: 0
|
|
202
166
|
};
|
|
203
|
-
|
|
204
167
|
if (!isBelow) {
|
|
205
168
|
var bottom = height + 1;
|
|
206
169
|
position = {
|
|
@@ -208,24 +171,19 @@ var LinkEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
208
171
|
left: 0
|
|
209
172
|
};
|
|
210
173
|
}
|
|
211
|
-
|
|
212
174
|
return position;
|
|
213
175
|
};
|
|
214
|
-
|
|
215
176
|
_this.onClosePopover = function () {
|
|
216
177
|
_this.setState({
|
|
217
178
|
isPopoverShow: false
|
|
218
179
|
});
|
|
219
180
|
};
|
|
220
|
-
|
|
221
181
|
_this.setEditorContainerRef = function (editorContainer) {
|
|
222
182
|
_this.editorContainer = editorContainer;
|
|
223
183
|
};
|
|
224
|
-
|
|
225
184
|
_this.setEditorRef = function (editor) {
|
|
226
185
|
_this.editor = editor;
|
|
227
186
|
};
|
|
228
|
-
|
|
229
187
|
_this.linkId = '';
|
|
230
188
|
_this.tableId = '';
|
|
231
189
|
_this.otherTableId = '';
|
|
@@ -236,7 +194,6 @@ var LinkEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
236
194
|
};
|
|
237
195
|
return _this;
|
|
238
196
|
}
|
|
239
|
-
|
|
240
197
|
_createClass(LinkEditor, [{
|
|
241
198
|
key: "componentDidMount",
|
|
242
199
|
value: function componentDidMount() {
|
|
@@ -251,11 +208,10 @@ var LinkEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
251
208
|
key: "render",
|
|
252
209
|
value: function render() {
|
|
253
210
|
var _this2 = this;
|
|
254
|
-
|
|
255
211
|
var isReadOnly = this.props.isReadOnly;
|
|
256
212
|
var _this$state = this.state,
|
|
257
|
-
|
|
258
|
-
|
|
213
|
+
isPopoverShow = _this$state.isPopoverShow,
|
|
214
|
+
popoverPosition = _this$state.popoverPosition;
|
|
259
215
|
var options = this.getAvailableLinkedOptions();
|
|
260
216
|
var selectedOptions = this.formatLinkedValuesToOptions();
|
|
261
217
|
var isShowRemoveIcon = !isReadOnly;
|
|
@@ -294,10 +250,8 @@ var LinkEditor = /*#__PURE__*/function (_React$Component) {
|
|
|
294
250
|
}))));
|
|
295
251
|
}
|
|
296
252
|
}]);
|
|
297
|
-
|
|
298
253
|
return LinkEditor;
|
|
299
254
|
}(React.Component);
|
|
300
|
-
|
|
301
255
|
LinkEditor.defaultProps = {
|
|
302
256
|
isReadOnly: false
|
|
303
257
|
};
|