dtable-ui-component 5.3.11 → 5.3.12-alpha0
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/CollaboratorItem/index.css +0 -1
- package/lib/DTableGroupSelect/select-option-group.js +7 -5
- package/lib/ImageFormatter/images-lazy-load.js +101 -126
- package/lib/RowExpandDialog/body/index.js +3 -2
- package/lib/RowExpandDialog/index.js +2 -1
- package/lib/RowExpandEditor/RowExpandDepartmentEditor/index.js +2 -2
- package/lib/RowExpandEditor/RowExpandEmailEditor/index.js +7 -7
- package/lib/RowExpandEditor/RowExpandTextEditor/index.js +10 -1
- package/lib/RowExpandEditor/RowExpandUrlEditor/index.js +7 -7
- package/package.json +1 -1
|
@@ -11,12 +11,14 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
11
11
|
var _DTableSearchInput = _interopRequireDefault(require("../DTableSearchInput"));
|
|
12
12
|
var _option = _interopRequireDefault(require("./option"));
|
|
13
13
|
var _KeyCodes = _interopRequireDefault(require("../SelectOptionGroup/KeyCodes"));
|
|
14
|
-
var _ClickOutside = _interopRequireDefault(require("../ClickOutside"));
|
|
15
14
|
require("./select-option-group.css");
|
|
16
15
|
const OPTION_HEIGHT = 32;
|
|
17
16
|
class SelectOptionGroup extends _react.Component {
|
|
18
17
|
constructor(props) {
|
|
19
18
|
super(props);
|
|
19
|
+
this.handleDocumentClick = e => {
|
|
20
|
+
this.props.onClickOutside(e);
|
|
21
|
+
};
|
|
20
22
|
this.resetMenuStyle = () => {
|
|
21
23
|
const {
|
|
22
24
|
isInModal,
|
|
@@ -163,6 +165,7 @@ class SelectOptionGroup extends _react.Component {
|
|
|
163
165
|
}
|
|
164
166
|
componentDidMount() {
|
|
165
167
|
window.addEventListener('keydown', this.onHotKey);
|
|
168
|
+
document.addEventListener('mousedown', this.handleDocumentClick);
|
|
166
169
|
setTimeout(() => {
|
|
167
170
|
this.resetMenuStyle();
|
|
168
171
|
}, 1);
|
|
@@ -171,6 +174,7 @@ class SelectOptionGroup extends _react.Component {
|
|
|
171
174
|
this.filterOptions = null;
|
|
172
175
|
this.timer && clearTimeout(this.timer);
|
|
173
176
|
window.removeEventListener('keydown', this.onHotKey);
|
|
177
|
+
document.removeEventListener('mousedown', this.handleDocumentClick);
|
|
174
178
|
}
|
|
175
179
|
render() {
|
|
176
180
|
const {
|
|
@@ -205,9 +209,7 @@ class SelectOptionGroup extends _react.Component {
|
|
|
205
209
|
opacity: 0
|
|
206
210
|
};
|
|
207
211
|
}
|
|
208
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
209
|
-
onClickOutside: this.props.onClickOutside
|
|
210
|
-
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
212
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
211
213
|
className: (0, _classnames.default)('option-group group-selector', className ? 'option-group-' + className : ''),
|
|
212
214
|
ref: ref => this.optionGroupRef = ref,
|
|
213
215
|
style: style,
|
|
@@ -222,7 +224,7 @@ class SelectOptionGroup extends _react.Component {
|
|
|
222
224
|
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
223
225
|
className: "option-group-content",
|
|
224
226
|
ref: ref => this.optionGroupContentRef = ref
|
|
225
|
-
}, this.renderOptGroup(searchVal)))
|
|
227
|
+
}, this.renderOptGroup(searchVal)));
|
|
226
228
|
}
|
|
227
229
|
}
|
|
228
230
|
var _default = exports.default = SelectOptionGroup;
|
|
@@ -9,138 +9,113 @@ exports.default = void 0;
|
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _Loading = _interopRequireDefault(require("../Loading"));
|
|
11
11
|
var _url = require("../utils/url");
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
const ImagesLazyLoad = _ref => {
|
|
13
|
+
let {
|
|
14
|
+
images,
|
|
15
|
+
server,
|
|
16
|
+
onImageClick,
|
|
17
|
+
renderItem,
|
|
18
|
+
dtableUuid
|
|
19
|
+
} = _ref;
|
|
20
|
+
const [currentImages, setCurrentImages] = (0, _react.useState)(images);
|
|
21
|
+
const [loadedImages, setLoadedImages] = (0, _react.useState)([]);
|
|
22
|
+
const [loadedCount, setLoadedCount] = (0, _react.useState)(0);
|
|
23
|
+
const lazyLoadImage = (url, resolve, reject) => {
|
|
24
|
+
if (!url) {
|
|
25
|
+
reject('img path is required');
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const image = new Image();
|
|
29
|
+
image.onload = () => {
|
|
30
|
+
resolve(image);
|
|
22
31
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this.setState = (state, callback) => {
|
|
26
|
-
return;
|
|
27
|
-
};
|
|
32
|
+
image.onerror = e => {
|
|
33
|
+
reject(e);
|
|
28
34
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
});
|
|
50
|
-
this.lazyLoadImage(url, image => {
|
|
51
|
-
let {
|
|
52
|
-
loadedCount,
|
|
53
|
-
loadedImages
|
|
54
|
-
} = this.state;
|
|
55
|
-
let newImageList = loadedImages.slice(0);
|
|
56
|
-
newImageList[index] = image;
|
|
57
|
-
this.setState({
|
|
58
|
-
loadedCount: loadedCount + 1,
|
|
59
|
-
loadedImages: newImageList
|
|
60
|
-
});
|
|
61
|
-
}, () => {
|
|
62
|
-
let {
|
|
63
|
-
loadedCount
|
|
64
|
-
} = this.state;
|
|
65
|
-
this.setState({
|
|
66
|
-
loadedCount: loadedCount + 1
|
|
67
|
-
});
|
|
68
|
-
});
|
|
35
|
+
image.src = url;
|
|
36
|
+
};
|
|
37
|
+
const lazyLoadImages = () => {
|
|
38
|
+
if (!Array.isArray(currentImages) || currentImages.length === 0) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Reset state for new images
|
|
43
|
+
setLoadedImages([]);
|
|
44
|
+
setLoadedCount(0);
|
|
45
|
+
currentImages.forEach((item, index) => {
|
|
46
|
+
const url = (0, _url.getImageThumbnailUrl)(item, {
|
|
47
|
+
server,
|
|
48
|
+
dtableUuid
|
|
49
|
+
});
|
|
50
|
+
lazyLoadImage(url, image => {
|
|
51
|
+
setLoadedImages(prev => {
|
|
52
|
+
const newList = [...prev];
|
|
53
|
+
newList[index] = image;
|
|
54
|
+
return newList;
|
|
69
55
|
});
|
|
56
|
+
setLoadedCount(count => count + 1);
|
|
57
|
+
}, () => {
|
|
58
|
+
setLoadedCount(count => count + 1);
|
|
70
59
|
});
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
(0, _react.useEffect)(() => {
|
|
63
|
+
lazyLoadImages();
|
|
64
|
+
}, []);
|
|
65
|
+
(0, _react.useEffect)(() => {
|
|
66
|
+
if (images.toString() !== currentImages.toString()) {
|
|
67
|
+
setCurrentImages(images);
|
|
68
|
+
}
|
|
69
|
+
}, [images]);
|
|
70
|
+
(0, _react.useEffect)(() => {
|
|
71
|
+
if (currentImages !== images) {
|
|
72
|
+
lazyLoadImages();
|
|
73
|
+
}
|
|
74
|
+
}, [currentImages]);
|
|
75
|
+
const handleMouseDown = event => {
|
|
76
|
+
event.stopPropagation();
|
|
77
|
+
};
|
|
78
|
+
const handleImageClick = (event, index) => {
|
|
79
|
+
event.stopPropagation();
|
|
80
|
+
if (onImageClick) {
|
|
81
|
+
onImageClick(index);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
if (!Array.isArray(currentImages) || currentImages.length === 0) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
if (currentImages.length > loadedCount) {
|
|
88
|
+
const style = {
|
|
89
|
+
marginLeft: '4px'
|
|
71
90
|
};
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
const image = new Image();
|
|
78
|
-
image.onload = () => {
|
|
79
|
-
resolve(image);
|
|
80
|
-
};
|
|
81
|
-
image.onerror = e => {
|
|
82
|
-
reject(e);
|
|
83
|
-
};
|
|
84
|
-
image.src = url;
|
|
85
|
-
};
|
|
86
|
-
this.onMouseDown = event => {
|
|
87
|
-
event.stopPropagation();
|
|
88
|
-
};
|
|
89
|
-
this.onImageClick = (event, index) => {
|
|
90
|
-
event.stopPropagation();
|
|
91
|
-
this.props.onImageClick(index);
|
|
92
|
-
};
|
|
93
|
-
this.state = {
|
|
94
|
-
images: _props.images,
|
|
95
|
-
loadedImages: [],
|
|
96
|
-
loadedCount: 0
|
|
97
|
-
};
|
|
91
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
92
|
+
style: style,
|
|
93
|
+
className: "d-flex align-items-center"
|
|
94
|
+
}, /*#__PURE__*/_react.default.createElement(_Loading.default, null));
|
|
98
95
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
} = this.props;
|
|
108
|
-
if (!Array.isArray(images) || images.length === 0) {
|
|
109
|
-
return '';
|
|
110
|
-
}
|
|
111
|
-
if (images.length > loadedCount) {
|
|
112
|
-
let style = {
|
|
113
|
-
marginLeft: '4px'
|
|
114
|
-
};
|
|
115
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
116
|
-
style: style,
|
|
117
|
-
className: "d-flex align-items-center"
|
|
118
|
-
}, /*#__PURE__*/_react.default.createElement(_Loading.default, null));
|
|
96
|
+
return loadedImages.map((image, index) => {
|
|
97
|
+
let imageName = '';
|
|
98
|
+
const imageSrc = image === null || image === void 0 ? void 0 : image.src;
|
|
99
|
+
try {
|
|
100
|
+
imageName = imageSrc ? decodeURI(imageSrc.slice(imageSrc.lastIndexOf('/') + 1)) : '';
|
|
101
|
+
} catch (error) {
|
|
102
|
+
// eslint-disable-next-line no-console
|
|
103
|
+
console.log(error);
|
|
119
104
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
console.log(error);
|
|
128
|
-
}
|
|
129
|
-
const imgDom = /*#__PURE__*/_react.default.createElement("img", {
|
|
130
|
-
title: imageName,
|
|
131
|
-
className: "image-item",
|
|
132
|
-
src: image.src,
|
|
133
|
-
onMouseDown: this.onMouseDown,
|
|
134
|
-
onClick: event => this.onImageClick(event, index),
|
|
135
|
-
alt: ""
|
|
136
|
-
});
|
|
137
|
-
if (renderItem) return /*#__PURE__*/_react.default.createElement(_react.Fragment, {
|
|
138
|
-
key: index
|
|
139
|
-
}, renderItem(imgDom));
|
|
140
|
-
return /*#__PURE__*/_react.default.createElement(_react.Fragment, {
|
|
141
|
-
key: index
|
|
142
|
-
}, imgDom);
|
|
105
|
+
const imgDom = /*#__PURE__*/_react.default.createElement("img", {
|
|
106
|
+
title: imageName,
|
|
107
|
+
className: "image-item",
|
|
108
|
+
src: image === null || image === void 0 ? void 0 : image.src,
|
|
109
|
+
onMouseDown: handleMouseDown,
|
|
110
|
+
onClick: event => handleImageClick(event, index),
|
|
111
|
+
alt: ""
|
|
143
112
|
});
|
|
144
|
-
|
|
145
|
-
|
|
113
|
+
if (renderItem) return /*#__PURE__*/_react.default.createElement(_react.Fragment, {
|
|
114
|
+
key: index
|
|
115
|
+
}, renderItem(imgDom));
|
|
116
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, {
|
|
117
|
+
key: index
|
|
118
|
+
}, imgDom);
|
|
119
|
+
});
|
|
120
|
+
};
|
|
146
121
|
var _default = exports.default = ImagesLazyLoad;
|
|
@@ -62,7 +62,8 @@ class Body extends _react.default.Component {
|
|
|
62
62
|
this.onHotKey = event => {
|
|
63
63
|
const {
|
|
64
64
|
columns,
|
|
65
|
-
onKeyDown
|
|
65
|
+
onKeyDown,
|
|
66
|
+
onToggle
|
|
66
67
|
} = this.props;
|
|
67
68
|
const readonly = Array.isArray(columns) && columns.length > 0 ? !columns.some(c => c.editable) : true;
|
|
68
69
|
const keyCode = event.keyCode;
|
|
@@ -71,7 +72,7 @@ class Body extends _react.default.Component {
|
|
|
71
72
|
return;
|
|
72
73
|
}
|
|
73
74
|
if (keyCode === _constants.KeyCodes.Esc) {
|
|
74
|
-
|
|
75
|
+
onToggle && onToggle();
|
|
75
76
|
return;
|
|
76
77
|
}
|
|
77
78
|
onKeyDown && onKeyDown(event);
|
|
@@ -224,7 +224,8 @@ const RowExpandDialog = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
224
224
|
columns: columns,
|
|
225
225
|
valueKey: valueKey,
|
|
226
226
|
onChange: onChange,
|
|
227
|
-
uploadFile: uploadFile
|
|
227
|
+
uploadFile: uploadFile,
|
|
228
|
+
onToggle: onToggle
|
|
228
229
|
}), children[1]), (!saveImmediately || isInsertingRow) && /*#__PURE__*/_react.default.createElement(_reactstrap.ModalFooter, null, /*#__PURE__*/_react.default.createElement(_reactstrap.Button, {
|
|
229
230
|
onClick: toggle,
|
|
230
231
|
color: "secondary"
|
|
@@ -36,7 +36,7 @@ function RowExpandDepartmentEditor(props) {
|
|
|
36
36
|
document.removeEventListener('keydown', onKeyDown);
|
|
37
37
|
};
|
|
38
38
|
// eslint-disable-next-line
|
|
39
|
-
}, [isEditorFocus]);
|
|
39
|
+
}, [isEditorFocus, showEditor]);
|
|
40
40
|
(0, _react.useEffect)(() => {
|
|
41
41
|
setValue(row[column[valueKey]] || '');
|
|
42
42
|
setShowEditor(false);
|
|
@@ -49,7 +49,7 @@ function RowExpandDepartmentEditor(props) {
|
|
|
49
49
|
function onKeyDown(e) {
|
|
50
50
|
if (e.keyCode === _constants.KeyCodes.Enter && props.isEditorFocus && !showEditor) {
|
|
51
51
|
setShowEditor(true);
|
|
52
|
-
} else if (e.keyCode === _constants.KeyCodes.Escape) {
|
|
52
|
+
} else if (e.keyCode === _constants.KeyCodes.Escape && showEditor) {
|
|
53
53
|
e.stopPropagation();
|
|
54
54
|
setShowEditor(false);
|
|
55
55
|
departmentSelectContent.current.focus();
|
|
@@ -45,19 +45,19 @@ class RowExpandEmailEditor extends _react.default.Component {
|
|
|
45
45
|
this.onPaste = e => {
|
|
46
46
|
e.stopPropagation();
|
|
47
47
|
};
|
|
48
|
-
this.onKeyDown =
|
|
49
|
-
if (
|
|
50
|
-
|
|
48
|
+
this.onKeyDown = event => {
|
|
49
|
+
if (event.keyCode === _constants.KeyCodes.Esc) {
|
|
50
|
+
event.stopPropagation();
|
|
51
51
|
this.blurInput();
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
const {
|
|
55
55
|
selectionStart,
|
|
56
56
|
selectionEnd,
|
|
57
57
|
value
|
|
58
|
-
} =
|
|
59
|
-
if (
|
|
60
|
-
|
|
58
|
+
} = event.currentTarget;
|
|
59
|
+
if (event.keyCode === _constants.KeyCodes.ChineseInputMethod || event.keyCode === _constants.KeyCodes.LeftArrow && selectionStart === 0 || event.keyCode === _constants.KeyCodes.RightArrow && selectionEnd === value.length) {
|
|
60
|
+
event.stopPropagation();
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
this.onOpenEmailLink = () => {
|
|
@@ -58,8 +58,17 @@ class RowExpandSimpleText extends _react.default.Component {
|
|
|
58
58
|
};
|
|
59
59
|
this.onKeyDown = event => {
|
|
60
60
|
if (event.keyCode === _constants.KeyCodes.Esc) {
|
|
61
|
-
event.
|
|
61
|
+
event.stopPropagation();
|
|
62
62
|
this.blurInput();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const {
|
|
66
|
+
selectionStart,
|
|
67
|
+
selectionEnd,
|
|
68
|
+
value
|
|
69
|
+
} = event.currentTarget;
|
|
70
|
+
if (event.keyCode === _constants.KeyCodes.ChineseInputMethod || event.keyCode === _constants.KeyCodes.LeftArrow && selectionStart === 0 || event.keyCode === _constants.KeyCodes.RightArrow && selectionEnd === value.length) {
|
|
71
|
+
event.stopPropagation();
|
|
63
72
|
}
|
|
64
73
|
};
|
|
65
74
|
this.isChecked = () => {
|
|
@@ -47,19 +47,19 @@ class RowExpandUrlEditor extends _react.default.Component {
|
|
|
47
47
|
this.onPaste = e => {
|
|
48
48
|
e.stopPropagation();
|
|
49
49
|
};
|
|
50
|
-
this.onKeyDown =
|
|
51
|
-
if (
|
|
52
|
-
|
|
50
|
+
this.onKeyDown = event => {
|
|
51
|
+
if (event.keyCode === _constants.KeyCodes.Esc) {
|
|
52
|
+
event.preventDefault();
|
|
53
53
|
this.blurInput();
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
const {
|
|
57
57
|
selectionStart,
|
|
58
58
|
selectionEnd,
|
|
59
59
|
value
|
|
60
|
-
} =
|
|
61
|
-
if (
|
|
62
|
-
|
|
60
|
+
} = event.currentTarget;
|
|
61
|
+
if (event.keyCode === _constants.KeyCodes.ChineseInputMethod || event.keyCode === _constants.KeyCodes.LeftArrow && selectionStart === 0 || event.keyCode === _constants.KeyCodes.RightArrow && selectionEnd === value.length) {
|
|
62
|
+
event.stopPropagation();
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
65
|
this.onOpenUrlLink = () => {
|