dtable-ui-component 0.3.1 → 0.3.2-alpha1

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.
@@ -28,10 +28,20 @@ var ButtonFormatter = /*#__PURE__*/function (_React$Component) {
28
28
  url_address = _this$props$data.url_address;
29
29
 
30
30
  if (button_type === 'open_url' && url_address) {
31
- window.open(url_address);
31
+ _this.openUrlLink(url_address);
32
32
  }
33
33
  };
34
34
 
35
+ _this.openUrlLink = function (url) {
36
+ var a = document.createElement('a');
37
+ document.body.appendChild(a);
38
+ a.href = url;
39
+ a.target = '_blank';
40
+ a.rel = 'noopener noreferrer';
41
+ a.click();
42
+ document.body.removeChild(a);
43
+ };
44
+
35
45
  return _this;
36
46
  }
37
47
 
@@ -23,8 +23,10 @@ var DigitalSignFormatter = /*#__PURE__*/function (_Component) {
23
23
  _this = _super.call(this, props);
24
24
 
25
25
  _this.getSignImages = function () {
26
- var value = _this.props.value;
27
- return [getDigitalSignImageUrl(value)].filter(Boolean);
26
+ var _this$props = _this.props,
27
+ value = _this$props.value,
28
+ config = _this$props.config;
29
+ return [getDigitalSignImageUrl(value, config)].filter(Boolean);
28
30
  };
29
31
 
30
32
  _this.onClickSignImage = function (index) {
@@ -72,10 +74,11 @@ var DigitalSignFormatter = /*#__PURE__*/function (_Component) {
72
74
  _createClass(DigitalSignFormatter, [{
73
75
  key: "render",
74
76
  value: function render() {
75
- var _this$props = this.props,
76
- server = _this$props.server,
77
- containerClassName = _this$props.containerClassName,
78
- readOnly = _this$props.readOnly;
77
+ var _this$props2 = this.props,
78
+ containerClassName = _this$props2.containerClassName,
79
+ readOnly = _this$props2.readOnly,
80
+ config = _this$props2.config,
81
+ isSample = _this$props2.isSample;
79
82
  var className = cn('dtable-ui cell-formatter-container digital-sign-formatter', containerClassName);
80
83
  var signImages = this.getSignImages();
81
84
  if (signImages.length === 0) return null;
@@ -86,12 +89,12 @@ var DigitalSignFormatter = /*#__PURE__*/function (_Component) {
86
89
  className: className
87
90
  }, /*#__PURE__*/React.createElement(ImagesLazyLoad, {
88
91
  images: signImages,
89
- server: server,
92
+ server: config.server,
90
93
  onImageClick: this.onClickSignImage
91
94
  })), isPreviewSignImage && /*#__PURE__*/React.createElement(ImagePreviewerLightbox, {
92
95
  className: "digital-sign-formatter-image-previewer",
93
96
  readOnly: readOnly,
94
- server: server,
97
+ server: isSample ? config.server : '',
95
98
  imageItems: signImages,
96
99
  imageIndex: largeSignImageIndex,
97
100
  closeImagePopup: this.hideLargeSignImage,
@@ -110,7 +113,7 @@ DigitalSignFormatter.defaultProps = {
110
113
  isSupportPreview: false,
111
114
  readOnly: true,
112
115
  value: '',
113
- server: '',
116
+ config: {},
114
117
  containerClassName: ''
115
118
  };
116
119
  export default DigitalSignFormatter;
@@ -1,6 +1,23 @@
1
- import dayjs from 'dayjs';
2
- import utc from 'dayjs/plugin/utc';
3
- dayjs.extend(utc);
4
- export var getDigitalSignImageUrl = function getDigitalSignImageUrl(cellValue) {
5
- return cellValue && cellValue.sign_image_url || '';
1
+ export var getDigitalSignImageUrl = function getDigitalSignImageUrl(cellValue, config) {
2
+ if (!cellValue) return '';
3
+ var url = cellValue && cellValue.sign_image_url || '';
4
+ if (!url) return '';
5
+ if (!config) return url;
6
+
7
+ var _ref = config || {},
8
+ server = _ref.server,
9
+ workspaceID = _ref.workspaceID,
10
+ dtableUuid = _ref.dtableUuid;
11
+
12
+ if (server && (workspaceID || workspaceID === 0) && dtableUuid) {
13
+ return "".concat(server, "/workspace/").concat(workspaceID, "/asset/").concat(dtableUuid).concat(url);
14
+ }
15
+
16
+ return url;
17
+ };
18
+ export var isValidDigitalSignImageValue = function isValidDigitalSignImageValue(cellValue) {
19
+ if (!cellValue) return false;
20
+ var digitalSignImage = cellValue && cellValue.sign_image_url;
21
+ if (!digitalSignImage) return false;
22
+ return true;
6
23
  };
@@ -25,12 +25,13 @@ var FileFormatter = /*#__PURE__*/function (_React$PureComponent) {
25
25
  isSample = _this$props.isSample,
26
26
  value = _this$props.value,
27
27
  containerClassName = _this$props.containerClassName;
28
- var className = cn('dtable-ui cell-formatter-container file-formatter', containerClassName);
29
28
 
30
29
  if (!Array.isArray(value) || value.length === 0) {
31
30
  return null;
32
31
  }
33
32
 
33
+ var className = cn('dtable-ui cell-formatter-container file-formatter', containerClassName);
34
+
34
35
  if (isSample) {
35
36
  var item = value[0];
36
37
  return /*#__PURE__*/React.createElement("div", {
@@ -61,4 +62,4 @@ FileFormatter.defaultProps = {
61
62
  value: [],
62
63
  containerClassName: ''
63
64
  };
64
- export default FileFormatter;
65
+ export { FileFormatter as default };
@@ -0,0 +1,60 @@
1
+ .dtable-ui.row-expand-file-formatter {
2
+ display: flex;
3
+ flex-wrap: wrap;
4
+ justify-content: flex-start;
5
+ width: 550px;
6
+ }
7
+
8
+ .dtable-ui.row-expand-file-formatter .row-expand-item-file {
9
+ height: 100px;
10
+ width: 100px;
11
+ border: 2px solid #ededed;
12
+ border-radius: 4px;
13
+ cursor: pointer;
14
+ display: flex;
15
+ align-items: center;
16
+ justify-content: center;
17
+ margin: 5px;
18
+ position: relative;
19
+ }
20
+
21
+ .dtable-ui.row-expand-file-formatter .row-expand-item-file:hover {
22
+ border-color: #c9c9c9;
23
+ }
24
+
25
+ .dtable-ui.row-expand-file-formatter .row-expand-item-file .dtable-file-icons-choice {
26
+ height: 20px;
27
+ width: 100%;
28
+ top: 0;
29
+ position: absolute;
30
+ color: #fff;
31
+ display: none;
32
+ padding: 0 3px;
33
+ justify-content: flex-end;
34
+ align-items: center;
35
+ }
36
+
37
+ .dtable-ui.row-expand-file-formatter .row-expand-item-file:hover .dtable-file-icons-choice {
38
+ display: flex;
39
+ }
40
+
41
+ .dtable-ui.row-expand-file-formatter .row-expand-item-file .dtable-file-icons-choice .file-icon {
42
+ height: 16px;
43
+ width: 16px;
44
+ border-radius: 50%;
45
+ background: rgba(0,0,0,.5);
46
+ color: #fff;
47
+ cursor: pointer;
48
+ display: flex;
49
+ justify-content: center;
50
+ align-items: center;
51
+ }
52
+
53
+ .dtable-ui.row-expand-file-formatter .row-expand-item-file .dtable-file-icons-choice .file-icon:nth-child(2) {
54
+ margin-left: 5px;
55
+ }
56
+
57
+ .dtable-ui.row-expand-file-formatter .row-expand-item-file .dtable-file-icons-choice .file-icon .dtable-font {
58
+ font-size: 12px;
59
+ transform: scale(.7);
60
+ }
@@ -0,0 +1,60 @@
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 classname from 'classnames';
7
+ import RowExpandFileItemFormatter from '../FileItemFormatter/row-expand-file-item-formatter';
8
+ import './index.css';
9
+ import './row-expand-file-formatter.css';
10
+
11
+ var RowExpandFileFormatter = /*#__PURE__*/function (_React$PureComponent) {
12
+ _inherits(RowExpandFileFormatter, _React$PureComponent);
13
+
14
+ var _super = _createSuper(RowExpandFileFormatter);
15
+
16
+ function RowExpandFileFormatter() {
17
+ _classCallCheck(this, RowExpandFileFormatter);
18
+
19
+ return _super.apply(this, arguments);
20
+ }
21
+
22
+ _createClass(RowExpandFileFormatter, [{
23
+ key: "render",
24
+ value: function render() {
25
+ var _this$props = this.props,
26
+ value = _this$props.value,
27
+ containerClassName = _this$props.containerClassName,
28
+ column = _this$props.column,
29
+ downloadFile = _this$props.downloadFile,
30
+ deleteFile = _this$props.deleteFile,
31
+ readOnly = _this$props.readOnly;
32
+
33
+ if (!Array.isArray(value) || value.length === 0) {
34
+ return null;
35
+ }
36
+
37
+ return /*#__PURE__*/React.createElement("div", {
38
+ className: classname('dtable-ui cell-formatter-container row-expand-file-formatter', containerClassName)
39
+ }, value.map(function (item, index) {
40
+ return /*#__PURE__*/React.createElement(RowExpandFileItemFormatter, {
41
+ file: item,
42
+ key: index,
43
+ index: index,
44
+ column: column,
45
+ downloadFile: downloadFile,
46
+ deleteFile: deleteFile,
47
+ readOnly: readOnly
48
+ });
49
+ }));
50
+ }
51
+ }]);
52
+
53
+ return RowExpandFileFormatter;
54
+ }(React.PureComponent);
55
+
56
+ RowExpandFileFormatter.defaultProps = {
57
+ value: [],
58
+ containerClassName: ''
59
+ };
60
+ export { RowExpandFileFormatter as default };
@@ -47,4 +47,4 @@ var FileItemFormatter = /*#__PURE__*/function (_Component) {
47
47
  return FileItemFormatter;
48
48
  }(Component);
49
49
 
50
- export default FileItemFormatter;
50
+ export { FileItemFormatter as default };
@@ -0,0 +1,125 @@
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 { Tooltip } from 'reactstrap';
7
+ import { getLocale } from '../lang';
8
+ import { getFileIconUrl } from './utils';
9
+ import DeleteTip from '../common/delete-tip';
10
+
11
+ var RowExpandFileItemFormatter = /*#__PURE__*/function (_Component) {
12
+ _inherits(RowExpandFileItemFormatter, _Component);
13
+
14
+ var _super = _createSuper(RowExpandFileItemFormatter);
15
+
16
+ function RowExpandFileItemFormatter(props) {
17
+ var _this;
18
+
19
+ _classCallCheck(this, RowExpandFileItemFormatter);
20
+
21
+ _this = _super.call(this, props);
22
+
23
+ _this.toggleTooltip = function () {
24
+ _this.setState({
25
+ isTooltipOpen: !_this.state.isTooltipOpen
26
+ });
27
+ };
28
+
29
+ _this.closeDeleteTip = function () {
30
+ _this.setState({
31
+ isDeleteTipOpen: false
32
+ });
33
+ };
34
+
35
+ _this.onClickDelete = function (e) {
36
+ e.stopPropagation();
37
+ _this.position = {
38
+ top: e.clientY,
39
+ left: e.clientX
40
+ };
41
+
42
+ _this.setState({
43
+ isDeleteTipOpen: true
44
+ });
45
+ };
46
+
47
+ _this.onDelete = function (e) {
48
+ e.stopPropagation();
49
+
50
+ _this.closeDeleteTip();
51
+
52
+ _this.props.deleteFile(_this.props.index);
53
+ };
54
+
55
+ _this.getFileIconData = function (item) {
56
+ var fileIconUrl = getFileIconUrl(item.name, item.type);
57
+ return require('./' + fileIconUrl);
58
+ };
59
+
60
+ _this.state = {
61
+ isTooltipOpen: false,
62
+ isDeleteTipOpen: false
63
+ };
64
+ return _this;
65
+ }
66
+
67
+ _createClass(RowExpandFileItemFormatter, [{
68
+ key: "render",
69
+ value: function render() {
70
+ var _this2 = this;
71
+
72
+ var _this$props = this.props,
73
+ file = _this$props.file,
74
+ column = _this$props.column,
75
+ index = _this$props.index,
76
+ readOnly = _this$props.readOnly,
77
+ downloadFile = _this$props.downloadFile,
78
+ deleteFile = _this$props.deleteFile;
79
+ var id = 'file-list-preview-item' + column.key + index;
80
+ var url = this.getFileIconData(file);
81
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
82
+ key: "file-".concat(index),
83
+ className: "row-expand-item-file",
84
+ id: id
85
+ }, /*#__PURE__*/React.createElement("img", {
86
+ src: url,
87
+ id: "item-file-".concat(index),
88
+ alt: file.name
89
+ }), /*#__PURE__*/React.createElement("div", {
90
+ className: "dtable-file-icons-choice"
91
+ }, downloadFile && /*#__PURE__*/React.createElement("span", {
92
+ className: "file-icon",
93
+ onClick: function onClick(e) {
94
+ return _this2.props.downloadFile(file, e);
95
+ }
96
+ }, /*#__PURE__*/React.createElement("i", {
97
+ className: "dtable-font dtable-icon-download"
98
+ })), !readOnly && deleteFile && /*#__PURE__*/React.createElement("span", {
99
+ className: "file-icon",
100
+ onClick: this.onClickDelete
101
+ }, /*#__PURE__*/React.createElement("i", {
102
+ className: "dtable-font dtable-icon-fork-number"
103
+ })))), this.state.isDeleteTipOpen && /*#__PURE__*/React.createElement(DeleteTip, {
104
+ position: this.position,
105
+ toggle: this.closeDeleteTip,
106
+ onDelete: this.onDelete,
107
+ deleteTip: getLocale('Are_you_sure_you_want_to_delete_this_file')
108
+ }), /*#__PURE__*/React.createElement(Tooltip, {
109
+ placement: "bottom",
110
+ isOpen: this.state.isTooltipOpen,
111
+ toggle: this.toggleTooltip,
112
+ target: id,
113
+ delay: {
114
+ show: 0,
115
+ hide: 0
116
+ },
117
+ fade: false
118
+ }, file.name));
119
+ }
120
+ }]);
121
+
122
+ return RowExpandFileItemFormatter;
123
+ }(Component);
124
+
125
+ export { RowExpandFileItemFormatter as default };
@@ -55,6 +55,7 @@ var ImagesLazyLoad = /*#__PURE__*/function (_React$Component) {
55
55
  var _this$state = _this.state,
56
56
  loadedCount = _this$state.loadedCount,
57
57
  loadedImages = _this$state.loadedImages;
58
+ if (loadedCount + 1 > images.length) return;
58
59
  var newImageList = loadedImages.slice(0);
59
60
  newImageList[index] = image;
60
61
 
@@ -64,6 +65,7 @@ var ImagesLazyLoad = /*#__PURE__*/function (_React$Component) {
64
65
  });
65
66
  }, function () {
66
67
  var loadedCount = _this.state.loadedCount;
68
+ if (loadedCount + 1 > images.length) return;
67
69
 
68
70
  _this.setState({
69
71
  loadedCount: loadedCount + 1
@@ -0,0 +1,16 @@
1
+ .dtable-tip.tip-container {
2
+ display: flex;
3
+ flex-direction: column;
4
+ width: 232px;
5
+ padding: 16px;
6
+ background: #fff;
7
+ border-radius: 5px;
8
+ border: 1px solid #ddd;
9
+ box-shadow: 0 2px 8px 1px rgba(0,0,0,.2);
10
+ position: fixed;
11
+ z-index: 10000;
12
+ }
13
+
14
+ .dtable-tip.tip-container b {
15
+ line-height: 1.5;
16
+ }
@@ -0,0 +1,83 @@
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 { getLocale } from '../lang';
7
+ import './delete-tip.css';
8
+
9
+ var DeleteTip = /*#__PURE__*/function (_React$Component) {
10
+ _inherits(DeleteTip, _React$Component);
11
+
12
+ var _super = _createSuper(DeleteTip);
13
+
14
+ function DeleteTip() {
15
+ var _this;
16
+
17
+ _classCallCheck(this, DeleteTip);
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.handleOutsideClick = function (e) {
26
+ if (_this.tipContainer && !_this.tipContainer.contains(e.target)) {
27
+ _this.props.toggle();
28
+ }
29
+ };
30
+
31
+ return _this;
32
+ }
33
+
34
+ _createClass(DeleteTip, [{
35
+ key: "componentDidMount",
36
+ value: function componentDidMount() {
37
+ document.addEventListener('click', this.handleOutsideClick);
38
+ }
39
+ }, {
40
+ key: "componentWillUnmount",
41
+ value: function componentWillUnmount() {
42
+ document.removeEventListener('click', this.handleOutsideClick);
43
+ }
44
+ }, {
45
+ key: "render",
46
+ value: function render() {
47
+ var _this2 = this;
48
+
49
+ var _this$props = this.props,
50
+ toggle = _this$props.toggle,
51
+ onDelete = _this$props.onDelete,
52
+ position = _this$props.position,
53
+ deleteTip = _this$props.deleteTip;
54
+ return /*#__PURE__*/React.createElement("div", {
55
+ ref: function ref(node) {
56
+ return _this2.tipContainer = node;
57
+ },
58
+ className: "dtable-tip tip-container",
59
+ style: {
60
+ top: position.top,
61
+ left: position.left
62
+ },
63
+ onClick: function onClick(e) {
64
+ return e.stopPropagation();
65
+ }
66
+ }, /*#__PURE__*/React.createElement("b", {
67
+ className: "mb-4"
68
+ }, deleteTip), /*#__PURE__*/React.createElement("div", {
69
+ className: "d-flex justify-content-end"
70
+ }, /*#__PURE__*/React.createElement("button", {
71
+ className: "btn btn-secondary mr-2",
72
+ onClick: toggle
73
+ }, getLocale('Cancel')), /*#__PURE__*/React.createElement("button", {
74
+ className: "btn btn-primary",
75
+ onClick: onDelete
76
+ }, getLocale('Delete'))));
77
+ }
78
+ }]);
79
+
80
+ return DeleteTip;
81
+ }(React.Component);
82
+
83
+ export { DeleteTip as default };