dtable-ui-component 0.2.12 → 0.3.0-beta
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.
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
@import url('../css/cell-formatter.css');
|
|
2
|
+
|
|
3
|
+
.dtable-ui.digital-sign-formatter {
|
|
4
|
+
display: flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.dtable-ui.digital-sign-formatter .image-item {
|
|
9
|
+
height: 100%;
|
|
10
|
+
margin-right: 4px;
|
|
11
|
+
border: 1px solid #f0f0f0;
|
|
12
|
+
background-color: #fff;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.dtable-ui.digital-sign-formatter .image-item:hover {
|
|
16
|
+
border: 1px solid #c9c9c9;
|
|
17
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
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, { Component } from 'react';
|
|
6
|
+
import cn from 'astro-classname';
|
|
7
|
+
import ImagesLazyLoad from '../ImageFormatter/images-lazy-load';
|
|
8
|
+
import ImagePreviewerLightbox from '../ImagePreviewerLightbox';
|
|
9
|
+
import { DigitalSignUtils } from './utils';
|
|
10
|
+
import { downloadFile } from '../utils/utils';
|
|
11
|
+
import './index.css';
|
|
12
|
+
|
|
13
|
+
var DigitalSignFormatter = /*#__PURE__*/function (_Component) {
|
|
14
|
+
_inherits(DigitalSignFormatter, _Component);
|
|
15
|
+
|
|
16
|
+
var _super = _createSuper(DigitalSignFormatter);
|
|
17
|
+
|
|
18
|
+
function DigitalSignFormatter(props) {
|
|
19
|
+
var _this;
|
|
20
|
+
|
|
21
|
+
_classCallCheck(this, DigitalSignFormatter);
|
|
22
|
+
|
|
23
|
+
_this = _super.call(this, props);
|
|
24
|
+
|
|
25
|
+
_this.getSignImages = function () {
|
|
26
|
+
var value = _this.props.value;
|
|
27
|
+
return [DigitalSignUtils.getSignImageUrl(value)].filter(Boolean);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
_this.onClickSignImage = function (index) {
|
|
31
|
+
if (!_this.props.isSupportPreview) return;
|
|
32
|
+
|
|
33
|
+
_this.setState({
|
|
34
|
+
isPreviewSignImage: true,
|
|
35
|
+
largeSignImageIndex: index
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
_this.hideLargeSignImage = function () {
|
|
40
|
+
if (!_this.props.isSupportPreview) return;
|
|
41
|
+
|
|
42
|
+
if (_this.props.onCloseCallback) {
|
|
43
|
+
_this.props.onCloseCallback();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
_this.setState({
|
|
47
|
+
isPreviewSignImage: false,
|
|
48
|
+
largeSignImageIndex: -1
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
_this.downloadImage = function (url) {
|
|
53
|
+
var availableUrl = url;
|
|
54
|
+
var rotateIndex = availableUrl.indexOf('?a=');
|
|
55
|
+
|
|
56
|
+
if (rotateIndex > -1) {
|
|
57
|
+
availableUrl = availableUrl.slice(0, rotateIndex);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
var urlSuffix = availableUrl.indexOf('?dl=1');
|
|
61
|
+
var downloadUrl = urlSuffix !== -1 ? availableUrl : availableUrl + '?dl=1';
|
|
62
|
+
downloadFile(downloadUrl);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
_this.state = {
|
|
66
|
+
isPreviewSignImage: false,
|
|
67
|
+
largeSignImageIndex: -1
|
|
68
|
+
};
|
|
69
|
+
return _this;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
_createClass(DigitalSignFormatter, [{
|
|
73
|
+
key: "render",
|
|
74
|
+
value: function render() {
|
|
75
|
+
var _this$props = this.props,
|
|
76
|
+
value = _this$props.value,
|
|
77
|
+
server = _this$props.server,
|
|
78
|
+
containerClassName = _this$props.containerClassName,
|
|
79
|
+
readOnly = _this$props.readOnly;
|
|
80
|
+
var className = cn('dtable-ui cell-formatter-container digital-sign-formatter', containerClassName);
|
|
81
|
+
var signImages = this.getSignImages();
|
|
82
|
+
if (signImages.length === 0) return null;
|
|
83
|
+
var _this$state = this.state,
|
|
84
|
+
isPreviewSignImage = _this$state.isPreviewSignImage,
|
|
85
|
+
largeSignImageIndex = _this$state.largeSignImageIndex;
|
|
86
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
87
|
+
className: className
|
|
88
|
+
}, /*#__PURE__*/React.createElement(ImagesLazyLoad, {
|
|
89
|
+
images: value,
|
|
90
|
+
server: server,
|
|
91
|
+
onImageClick: this.onClickSignImage
|
|
92
|
+
})), isPreviewSignImage && /*#__PURE__*/React.createElement(ImagePreviewerLightbox, {
|
|
93
|
+
readOnly: readOnly,
|
|
94
|
+
server: server,
|
|
95
|
+
imageItems: signImages,
|
|
96
|
+
imageIndex: largeSignImageIndex,
|
|
97
|
+
closeImagePopup: this.hideLargeSignImage,
|
|
98
|
+
downloadImage: this.downloadImage,
|
|
99
|
+
moveToPrevImage: function moveToPrevImage() {},
|
|
100
|
+
moveToNextImage: function moveToNextImage() {}
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
}]);
|
|
104
|
+
|
|
105
|
+
return DigitalSignFormatter;
|
|
106
|
+
}(Component);
|
|
107
|
+
|
|
108
|
+
export default DigitalSignFormatter;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import dayjs from 'dayjs';
|
|
4
|
+
import utc from 'dayjs/plugin/utc';
|
|
5
|
+
dayjs.extend(utc);
|
|
6
|
+
export var getDigitalSignImageUrl = function getDigitalSignImageUrl(cellValue) {
|
|
7
|
+
return cellValue && cellValue.sign_image_url || '';
|
|
8
|
+
};
|
|
9
|
+
export var DigitalSignUtils = /*#__PURE__*/function () {
|
|
10
|
+
function DigitalSignUtils() {
|
|
11
|
+
_classCallCheck(this, DigitalSignUtils);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
_createClass(DigitalSignUtils, null, [{
|
|
15
|
+
key: "getSignImageUrl",
|
|
16
|
+
value: function getSignImageUrl(sign) {
|
|
17
|
+
return getDigitalSignImageUrl(sign);
|
|
18
|
+
}
|
|
19
|
+
}, {
|
|
20
|
+
key: "getUpdatedSign",
|
|
21
|
+
value: function getUpdatedSign(_ref) {
|
|
22
|
+
var username = _ref.username,
|
|
23
|
+
sign_image_url = _ref.sign_image_url;
|
|
24
|
+
var time = dayjs().utc().format('YYYY-MM-DDTHH:mm:ss.SSSZ');
|
|
25
|
+
return {
|
|
26
|
+
username: username,
|
|
27
|
+
sign_image_url: sign_image_url,
|
|
28
|
+
sign_time: time
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}]);
|
|
32
|
+
|
|
33
|
+
return DigitalSignUtils;
|
|
34
|
+
}();
|
|
@@ -48,17 +48,19 @@ var ImagesLazyLoad = /*#__PURE__*/function (_React$Component) {
|
|
|
48
48
|
loadedCount: 0
|
|
49
49
|
}, function () {
|
|
50
50
|
var server = _this.props.server;
|
|
51
|
-
images.forEach(function (item) {
|
|
51
|
+
images.forEach(function (item, index) {
|
|
52
52
|
var url = getImageThumbnailUrl(item, server);
|
|
53
53
|
|
|
54
54
|
_this.lazyLoadImage(url, function (image) {
|
|
55
55
|
var _this$state = _this.state,
|
|
56
56
|
loadedCount = _this$state.loadedCount,
|
|
57
57
|
loadedImages = _this$state.loadedImages;
|
|
58
|
+
var newImageList = loadedImages.slice(0);
|
|
59
|
+
newImageList[index] = image;
|
|
58
60
|
|
|
59
61
|
_this.setState({
|
|
60
62
|
loadedCount: loadedCount + 1,
|
|
61
|
-
loadedImages:
|
|
63
|
+
loadedImages: newImageList
|
|
62
64
|
});
|
|
63
65
|
}, function () {
|
|
64
66
|
var loadedCount = _this.state.loadedCount;
|
package/lib/index.js
CHANGED
|
@@ -32,7 +32,8 @@ export { default as RateFormatter } from './RateFormatter';
|
|
|
32
32
|
export { default as ButtonFormatter } from './ButtonFormatter';
|
|
33
33
|
export { default as ImagePreviewerLightbox } from './ImagePreviewerLightbox';
|
|
34
34
|
export { default as CollaboratorItem } from './CollaboratorItem';
|
|
35
|
-
export { default as FileItemFormatter } from './FileItemFormatter';
|
|
35
|
+
export { default as FileItemFormatter } from './FileItemFormatter';
|
|
36
|
+
export { default as DigitalSignFormatter } from './DigitalSignFormatter'; // editor
|
|
36
37
|
|
|
37
38
|
export { default as TextEditor } from './TextEditor';
|
|
38
39
|
export { default as NumberEditor } from './NumberEditor';
|
package/lib/utils/utils.js
CHANGED
|
@@ -41,4 +41,17 @@ export var isMac = function isMac() {
|
|
|
41
41
|
var platform = navigator.platform; // eslint-disable-next-line eqeqeq
|
|
42
42
|
|
|
43
43
|
return platform == 'Mac68K' || platform == 'MacPPC' || platform == 'Macintosh' || platform == 'MacIntel';
|
|
44
|
+
};
|
|
45
|
+
export var downloadFile = function downloadFile(downloadUrl) {
|
|
46
|
+
var downloadFrame = document.getElementById('dtableUiComponentDownloadFrame');
|
|
47
|
+
|
|
48
|
+
if (downloadFrame != null) {
|
|
49
|
+
document.body.removeChild(downloadFrame);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
var iframe = document.createElement('iframe');
|
|
53
|
+
iframe.setAttribute('id', 'dtableUiComponentDownloadFrame');
|
|
54
|
+
iframe.style.display = 'none';
|
|
55
|
+
iframe.src = downloadUrl;
|
|
56
|
+
document.body.appendChild(iframe);
|
|
44
57
|
};
|