dtable-ui-component 5.3.10 → 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 +4 -3
- package/lib/RowExpandEditor/RowExpandCollaboratorEditor/index.js +1 -1
- package/lib/RowExpandEditor/RowExpandDepartmentEditor/index.js +3 -5
- package/lib/RowExpandEditor/RowExpandEmailEditor/index.js +7 -7
- package/lib/RowExpandEditor/RowExpandGeolocationEditor/index.js +1 -1
- package/lib/RowExpandEditor/RowExpandMultipleSelectEditor/index.js +35 -12
- package/lib/RowExpandEditor/RowExpandSingleSelectorEditor/index.js +24 -11
- package/lib/RowExpandEditor/RowExpandTextEditor/index.js +10 -1
- package/lib/RowExpandEditor/RowExpandUrlEditor/index.js +8 -8
- package/lib/select-editor/pc-select-editor/index.js +8 -3
- 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);
|
|
@@ -73,7 +73,7 @@ const RowExpandDialog = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
73
73
|
if (readonly || !column || !column.editable || _dtableUtils.NOT_SUPPORT_EDIT_COLUMN_TYPE_MAP[column.type]) return false;
|
|
74
74
|
if (column.type === _dtableUtils.CellType.IMAGE || column.type === _dtableUtils.CellType.FILE) return Boolean(uploadFile);
|
|
75
75
|
return true;
|
|
76
|
-
}, [isSaving, uploadFile]);
|
|
76
|
+
}, [readonly, isSaving, uploadFile]);
|
|
77
77
|
const initRowData = (0, _react.useCallback)(() => {
|
|
78
78
|
setLoading(true);
|
|
79
79
|
setRow(defaultRow);
|
|
@@ -88,7 +88,7 @@ const RowExpandDialog = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
|
|
|
88
88
|
isChangedRef.current = isInsertingRow && Object.keys(defaultRow).length > 0;
|
|
89
89
|
setColumns(validColumns);
|
|
90
90
|
setLoading(false);
|
|
91
|
-
}, [isInsertingRow, checkEditable]);
|
|
91
|
+
}, [isInsertingRow, defaultColumns, defaultRow, checkEditable]);
|
|
92
92
|
const toggle = (0, _react.useCallback)(() => {
|
|
93
93
|
if (isSaving) return;
|
|
94
94
|
onToggle();
|
|
@@ -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"
|
|
@@ -48,7 +48,7 @@ class RowExpandCollaboratorEditor extends _react.default.Component {
|
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
50
|
this.hideSelect = event => {
|
|
51
|
-
if (!this.state.showCollaboratorSelect || !event.target
|
|
51
|
+
if (!this.state.showCollaboratorSelect || !event.target) {
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
54
|
const editor = document.querySelector('.dtable-ui-collaborator-editor-container');
|
|
@@ -11,9 +11,7 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
11
11
|
var _hooks = require("../../hooks");
|
|
12
12
|
var _DepartmentSingleSelectFormatter = _interopRequireDefault(require("../../DepartmentSingleSelectFormatter"));
|
|
13
13
|
var _constants = require("../../constants");
|
|
14
|
-
var _lang = require("../../lang");
|
|
15
14
|
var _departmentSingleSelect = _interopRequireDefault(require("../../Department-editor/department-single-select"));
|
|
16
|
-
var _constants2 = require("../../Department-editor/constants");
|
|
17
15
|
function RowExpandDepartmentEditor(props) {
|
|
18
16
|
const {
|
|
19
17
|
row,
|
|
@@ -38,20 +36,20 @@ function RowExpandDepartmentEditor(props) {
|
|
|
38
36
|
document.removeEventListener('keydown', onKeyDown);
|
|
39
37
|
};
|
|
40
38
|
// eslint-disable-next-line
|
|
41
|
-
}, [isEditorFocus]);
|
|
39
|
+
}, [isEditorFocus, showEditor]);
|
|
42
40
|
(0, _react.useEffect)(() => {
|
|
43
41
|
setValue(row[column[valueKey]] || '');
|
|
44
42
|
setShowEditor(false);
|
|
45
43
|
// eslint-disable-next-line
|
|
46
44
|
}, [row]);
|
|
47
45
|
function hideDropDownMenu(event) {
|
|
48
|
-
if (!event.target
|
|
46
|
+
if (!event.target) return;
|
|
49
47
|
toggleDepartmentSelect(false);
|
|
50
48
|
}
|
|
51
49
|
function onKeyDown(e) {
|
|
52
50
|
if (e.keyCode === _constants.KeyCodes.Enter && props.isEditorFocus && !showEditor) {
|
|
53
51
|
setShowEditor(true);
|
|
54
|
-
} else if (e.keyCode === _constants.KeyCodes.Escape) {
|
|
52
|
+
} else if (e.keyCode === _constants.KeyCodes.Escape && showEditor) {
|
|
55
53
|
e.stopPropagation();
|
|
56
54
|
setShowEditor(false);
|
|
57
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 = () => {
|
|
@@ -23,7 +23,7 @@ class RowExpandGeolocationEditor extends _react.default.Component {
|
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
this.hideEditor = event => {
|
|
26
|
-
if (!this.state.isShowEditor || !event.target ||
|
|
26
|
+
if (!this.state.isShowEditor || !event.target || this.editorContainer.contains(event.target)) return;
|
|
27
27
|
if (this.state.isShowEditor && this.geoEditor.getLargeEditorState()) return;
|
|
28
28
|
this.setState({
|
|
29
29
|
isShowEditor: false
|
|
@@ -11,6 +11,7 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
11
11
|
var _constants = require("../../constants");
|
|
12
12
|
var _MultipleSelectEditor = _interopRequireDefault(require("../../MultipleSelectEditor"));
|
|
13
13
|
var _lang = require("../../lang");
|
|
14
|
+
var _objectUtils = _interopRequireDefault(require("../../utils/object-utils"));
|
|
14
15
|
require("./index.css");
|
|
15
16
|
class RowExpandMultipleSelectEditor extends _react.default.Component {
|
|
16
17
|
constructor(_props) {
|
|
@@ -39,7 +40,7 @@ class RowExpandMultipleSelectEditor extends _react.default.Component {
|
|
|
39
40
|
});
|
|
40
41
|
};
|
|
41
42
|
this.hideDropDownMenu = event => {
|
|
42
|
-
if (!event.target
|
|
43
|
+
if (!event.target) return;
|
|
43
44
|
if (!this.ref.contains(event.target) && this.state.showSelectPopover) {
|
|
44
45
|
const singleSelectEditor = document.getElementsByClassName('dtable-ui-select-editor-container')[0];
|
|
45
46
|
if (singleSelectEditor && singleSelectEditor.contains(event.target)) return;
|
|
@@ -49,14 +50,22 @@ class RowExpandMultipleSelectEditor extends _react.default.Component {
|
|
|
49
50
|
this.onToggleSelect = e => {
|
|
50
51
|
e.preventDefault();
|
|
51
52
|
e.stopPropagation();
|
|
52
|
-
|
|
53
|
+
const {
|
|
54
|
+
updateTabIndex,
|
|
55
|
+
columnIndex
|
|
56
|
+
} = this.props;
|
|
57
|
+
updateTabIndex && updateTabIndex(columnIndex);
|
|
53
58
|
this.toggleSingleSelect(true);
|
|
54
59
|
};
|
|
55
60
|
this.closeEditor = () => {
|
|
56
61
|
this.toggleSingleSelect(false);
|
|
57
62
|
};
|
|
58
63
|
this.onFocus = () => {
|
|
59
|
-
|
|
64
|
+
const {
|
|
65
|
+
updateTabIndex,
|
|
66
|
+
columnIndex
|
|
67
|
+
} = this.props;
|
|
68
|
+
updateTabIndex && updateTabIndex(columnIndex);
|
|
60
69
|
};
|
|
61
70
|
this.onChange = option => {
|
|
62
71
|
const optionKey = option[this.key];
|
|
@@ -135,7 +144,9 @@ class RowExpandMultipleSelectEditor extends _react.default.Component {
|
|
|
135
144
|
};
|
|
136
145
|
this.renderOptions = () => {
|
|
137
146
|
const {
|
|
138
|
-
isEditorFocus
|
|
147
|
+
isEditorFocus,
|
|
148
|
+
classNamePrefix,
|
|
149
|
+
placeholder
|
|
139
150
|
} = this.props;
|
|
140
151
|
const options = this.getMultipleSelectList();
|
|
141
152
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -144,13 +155,22 @@ class RowExpandMultipleSelectEditor extends _react.default.Component {
|
|
|
144
155
|
onClick: this.onToggleSelect,
|
|
145
156
|
ref: ref => this.multipleSelectOptionsRef = ref,
|
|
146
157
|
className: (0, _classnames.default)('dtable-ui dtable-ui-row-expand-select-editor custom-select', {
|
|
147
|
-
'focus': isEditorFocus
|
|
158
|
+
'focus': isEditorFocus,
|
|
159
|
+
["".concat(classNamePrefix, "-select-editor")]: classNamePrefix
|
|
148
160
|
})
|
|
149
161
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
150
|
-
className:
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
},
|
|
162
|
+
className: (0, _classnames.default)('dtable-ui-row-expand-select-editor-inner', {
|
|
163
|
+
["".concat(classNamePrefix, "-select-editor-inner")]: classNamePrefix
|
|
164
|
+
})
|
|
165
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
166
|
+
className: (0, _classnames.default)('', {
|
|
167
|
+
["".concat(classNamePrefix, "-select-editor-inner-container")]: classNamePrefix
|
|
168
|
+
})
|
|
169
|
+
}, options.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
|
|
170
|
+
className: (0, _classnames.default)('dtable-ui-row-expand-select-options', {
|
|
171
|
+
["".concat(classNamePrefix, "-select-editor-options")]: classNamePrefix
|
|
172
|
+
})
|
|
173
|
+
}, options), options.length === 0 && placeholder && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, placeholder)), /*#__PURE__*/_react.default.createElement("i", {
|
|
154
174
|
"aria-hidden": "true",
|
|
155
175
|
className: "dtable-font dtable-icon-down3"
|
|
156
176
|
})));
|
|
@@ -169,9 +189,10 @@ class RowExpandMultipleSelectEditor extends _react.default.Component {
|
|
|
169
189
|
}
|
|
170
190
|
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
171
191
|
const {
|
|
172
|
-
value
|
|
192
|
+
value,
|
|
193
|
+
column
|
|
173
194
|
} = nextProps;
|
|
174
|
-
if (value !== this.props.value) {
|
|
195
|
+
if (value !== this.props.value || !_objectUtils.default.isSameObject(column, this.props.column)) {
|
|
175
196
|
this.options = this.getOptions(nextProps);
|
|
176
197
|
this.setState({
|
|
177
198
|
value
|
|
@@ -196,7 +217,8 @@ class RowExpandMultipleSelectEditor extends _react.default.Component {
|
|
|
196
217
|
const {
|
|
197
218
|
column,
|
|
198
219
|
isSupportNewOption,
|
|
199
|
-
onAddNewOption
|
|
220
|
+
onAddNewOption,
|
|
221
|
+
classNamePrefix
|
|
200
222
|
} = this.props;
|
|
201
223
|
const {
|
|
202
224
|
showSelectPopover,
|
|
@@ -214,6 +236,7 @@ class RowExpandMultipleSelectEditor extends _react.default.Component {
|
|
|
214
236
|
value: value,
|
|
215
237
|
valueKey: this.key,
|
|
216
238
|
target: this.targetRef,
|
|
239
|
+
classNamePrefix: classNamePrefix,
|
|
217
240
|
onCommit: this.onChange,
|
|
218
241
|
isSupportNewOption: isSupportNewOption,
|
|
219
242
|
onAddNewOption: onAddNewOption,
|
|
@@ -11,6 +11,7 @@ var _constants = require("../../constants");
|
|
|
11
11
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
12
12
|
var _SingleSelectEditor = _interopRequireDefault(require("../../SingleSelectEditor"));
|
|
13
13
|
var _lang = require("../../lang");
|
|
14
|
+
var _objectUtils = _interopRequireDefault(require("../../utils/object-utils"));
|
|
14
15
|
require("./index.css");
|
|
15
16
|
class RowExpandSingleSelectEditor extends _react.default.Component {
|
|
16
17
|
constructor(_props) {
|
|
@@ -62,8 +63,8 @@ class RowExpandSingleSelectEditor extends _react.default.Component {
|
|
|
62
63
|
this.toggleSingleSelect(false);
|
|
63
64
|
};
|
|
64
65
|
this.hideDropDownMenu = event => {
|
|
65
|
-
if (!event.target
|
|
66
|
-
if (!this.
|
|
66
|
+
if (!event.target) return;
|
|
67
|
+
if (!this.ref.contains(event.target) && this.state.showSelectPopover) {
|
|
67
68
|
const singleSelectEditor = document.getElementsByClassName('dtable-ui-select-editor-container')[0];
|
|
68
69
|
if (singleSelectEditor && singleSelectEditor.contains(event.target)) return;
|
|
69
70
|
this.toggleSingleSelect(false);
|
|
@@ -90,7 +91,9 @@ class RowExpandSingleSelectEditor extends _react.default.Component {
|
|
|
90
91
|
};
|
|
91
92
|
this.renderOption = () => {
|
|
92
93
|
const {
|
|
93
|
-
isEditorFocus
|
|
94
|
+
isEditorFocus,
|
|
95
|
+
classNamePrefix,
|
|
96
|
+
placeholder
|
|
94
97
|
} = this.props;
|
|
95
98
|
const {
|
|
96
99
|
value
|
|
@@ -109,15 +112,22 @@ class RowExpandSingleSelectEditor extends _react.default.Component {
|
|
|
109
112
|
onClick: this.onToggleSelect,
|
|
110
113
|
ref: ref => this.selectRef = ref,
|
|
111
114
|
className: (0, _classnames.default)('dtable-ui dtable-ui-row-expand-select-editor custom-select', {
|
|
112
|
-
'focus': isEditorFocus
|
|
115
|
+
'focus': isEditorFocus,
|
|
116
|
+
["".concat(classNamePrefix, "-select-editor")]: classNamePrefix
|
|
113
117
|
})
|
|
114
118
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
115
|
-
className:
|
|
116
|
-
|
|
119
|
+
className: (0, _classnames.default)('dtable-ui-row-expand-select-editor-inner', {
|
|
120
|
+
["".concat(classNamePrefix, "-select-editor-inner")]: classNamePrefix
|
|
121
|
+
})
|
|
122
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
123
|
+
className: (0, _classnames.default)('', {
|
|
124
|
+
["".concat(classNamePrefix, "-select-editor-inner-container")]: classNamePrefix
|
|
125
|
+
})
|
|
126
|
+
}, value && /*#__PURE__*/_react.default.createElement("div", {
|
|
117
127
|
className: "dtable-ui-select-option",
|
|
118
128
|
style: optionStyle,
|
|
119
129
|
title: optionName
|
|
120
|
-
}, optionName)), /*#__PURE__*/_react.default.createElement("i", {
|
|
130
|
+
}, optionName), !value && placeholder && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, placeholder)), /*#__PURE__*/_react.default.createElement("i", {
|
|
121
131
|
"aria-hidden": "true",
|
|
122
132
|
className: "dtable-font dtable-icon-down3"
|
|
123
133
|
})));
|
|
@@ -137,9 +147,10 @@ class RowExpandSingleSelectEditor extends _react.default.Component {
|
|
|
137
147
|
}
|
|
138
148
|
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
139
149
|
const {
|
|
140
|
-
value
|
|
150
|
+
value,
|
|
151
|
+
column
|
|
141
152
|
} = nextProps;
|
|
142
|
-
if (value !== this.props.value) {
|
|
153
|
+
if (value !== this.props.value || !_objectUtils.default.isSameObject(column, this.props.column)) {
|
|
143
154
|
this.options = this.getOptions(nextProps);
|
|
144
155
|
this.setState({
|
|
145
156
|
value,
|
|
@@ -165,7 +176,8 @@ class RowExpandSingleSelectEditor extends _react.default.Component {
|
|
|
165
176
|
const {
|
|
166
177
|
isSupportNewOption,
|
|
167
178
|
onAddNewOption,
|
|
168
|
-
column
|
|
179
|
+
column,
|
|
180
|
+
classNamePrefix
|
|
169
181
|
} = this.props;
|
|
170
182
|
const {
|
|
171
183
|
showSelectPopover,
|
|
@@ -173,7 +185,7 @@ class RowExpandSingleSelectEditor extends _react.default.Component {
|
|
|
173
185
|
} = this.state;
|
|
174
186
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
175
187
|
className: "position-relative w-100",
|
|
176
|
-
ref: ref => this.
|
|
188
|
+
ref: ref => this.ref = ref
|
|
177
189
|
}, this.renderOption(), /*#__PURE__*/_react.default.createElement("span", {
|
|
178
190
|
ref: ref => this.targetRef = ref
|
|
179
191
|
}), showSelectPopover && /*#__PURE__*/_react.default.createElement(_SingleSelectEditor.default, {
|
|
@@ -183,6 +195,7 @@ class RowExpandSingleSelectEditor extends _react.default.Component {
|
|
|
183
195
|
value: value,
|
|
184
196
|
valueKey: this.key,
|
|
185
197
|
target: this.targetRef,
|
|
198
|
+
classNamePrefix: classNamePrefix,
|
|
186
199
|
onCommit: this.onChange,
|
|
187
200
|
isSupportNewOption: isSupportNewOption,
|
|
188
201
|
onAddNewOption: onAddNewOption,
|
|
@@ -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 = () => {
|
|
@@ -77,7 +77,7 @@ class RowExpandUrlEditor extends _react.default.Component {
|
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
79
|
this.state = {
|
|
80
|
-
value: props.value
|
|
80
|
+
value: props.value || ''
|
|
81
81
|
};
|
|
82
82
|
this.inputRef = /*#__PURE__*/_react.default.createRef();
|
|
83
83
|
}
|
|
@@ -206,7 +206,8 @@ class PCSelectEditor extends _react.default.Component {
|
|
|
206
206
|
column,
|
|
207
207
|
valueKey,
|
|
208
208
|
isSupportNewOption,
|
|
209
|
-
target
|
|
209
|
+
target,
|
|
210
|
+
classNamePrefix
|
|
210
211
|
} = this.props;
|
|
211
212
|
const {
|
|
212
213
|
searchValue,
|
|
@@ -218,7 +219,9 @@ class PCSelectEditor extends _react.default.Component {
|
|
|
218
219
|
// maxWidth = column.width > 200 ? column.width - 62 : 200 - 62
|
|
219
220
|
let maxWidth = isInModal ? 250 : (column === null || column === void 0 ? void 0 : column.width) > 200 ? column.width - 62 : 138;
|
|
220
221
|
const dom = /*#__PURE__*/_react.default.createElement("div", {
|
|
221
|
-
className: (0, _classnames.default)('dtable-ui-editor-container dtable-ui-select-editor-container', className
|
|
222
|
+
className: (0, _classnames.default)('dtable-ui-editor-container dtable-ui-select-editor-container', className, {
|
|
223
|
+
["".concat(classNamePrefix, "-select-editor-container")]: classNamePrefix
|
|
224
|
+
}),
|
|
222
225
|
ref: ref => this.ref = ref
|
|
223
226
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
224
227
|
className: "select-options-search"
|
|
@@ -276,7 +279,9 @@ class PCSelectEditor extends _react.default.Component {
|
|
|
276
279
|
target: target,
|
|
277
280
|
hideArrow: true,
|
|
278
281
|
fade: false,
|
|
279
|
-
className:
|
|
282
|
+
className: (0, _classnames.default)('dtable-ui dtable-ui-row-expand-select-editor-popover', {
|
|
283
|
+
["".concat(classNamePrefix, "-select-editor-popover")]: classNamePrefix
|
|
284
|
+
})
|
|
280
285
|
}, dom));
|
|
281
286
|
}
|
|
282
287
|
return dom;
|