dtable-ui-component 7.0.9-beta.3 → 7.0.10
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/AsyncUserSelect/index.css +13 -7
- package/lib/AsyncUserSelect/index.js +116 -102
- package/lib/DTableCustomizeSearchInput/index.css +5 -1
- package/lib/DTableCustomizeSelect/index.css +5 -1
- package/lib/DTableCustomizeSelect/index.js +1 -1
- package/lib/DTableSelect/dtable-select-label.css +4 -1
- package/package.json +3 -3
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
flex-wrap: wrap;
|
|
3
3
|
height: auto !important;
|
|
4
4
|
min-height: 38px;
|
|
5
|
-
max-width: calc(100% - 10px);
|
|
6
5
|
padding: .375rem 40px .375rem 1rem;
|
|
7
6
|
position: relative;
|
|
7
|
+
border-radius: 4px;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
.dtable-ui-selected-users-container.focus {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
.dtable-ui-selected-users-container .dtable-ui-user-select-placeholder {
|
|
15
|
-
color: var(--bs-
|
|
15
|
+
color: var(--bs-bg-placeholder-color)
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
.select-dropdown-indicator {
|
|
@@ -29,10 +29,13 @@
|
|
|
29
29
|
height: 12px;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
.dtable-ui-user-select-popover
|
|
33
|
-
|
|
34
|
-
max-width: 385px;
|
|
32
|
+
.dtable-ui-user-select-popover {
|
|
33
|
+
z-index: 1060;
|
|
35
34
|
margin-top: -4px;
|
|
35
|
+
background-color: var(--bs-popover-bg);
|
|
36
|
+
box-shadow: var(--bs-border-secondary-shadow);
|
|
37
|
+
border: 1px solid var(--bs-border-secondary-color);
|
|
38
|
+
border-radius: 4px;
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
.dtable-ui-user-select-container {
|
|
@@ -58,8 +61,11 @@
|
|
|
58
61
|
border-radius: 4px;
|
|
59
62
|
}
|
|
60
63
|
|
|
61
|
-
.dtable-ui-user-select-container .dtable-ui-user-list-container .dtable-ui-user-item-container
|
|
62
|
-
|
|
64
|
+
.dtable-ui-user-select-container .dtable-ui-user-list-container .dtable-ui-user-item-container .dtable-ui-user-item {
|
|
65
|
+
background: none !important;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.dtable-ui-user-select-container .dtable-ui-user-list-container .dtable-ui-user-item-container:hover {
|
|
63
69
|
background-color: var(--bs-btn-background-hover);
|
|
64
70
|
cursor: pointer;
|
|
65
71
|
}
|
|
@@ -8,8 +8,7 @@ exports.default = void 0;
|
|
|
8
8
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
9
9
|
var _react = require("react");
|
|
10
10
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
-
var
|
|
12
|
-
var _ClickOutside = _interopRequireDefault(require("../ClickOutside"));
|
|
11
|
+
var _ModalPortal = _interopRequireDefault(require("../ModalPortal"));
|
|
13
12
|
var _DTableCustomizeSearchInput = _interopRequireDefault(require("../DTableCustomizeSearchInput"));
|
|
14
13
|
var _userItem = _interopRequireDefault(require("./user-item"));
|
|
15
14
|
var _lang = require("../lang");
|
|
@@ -18,7 +17,6 @@ var _DTableIcon = _interopRequireDefault(require("../DTableIcon"));
|
|
|
18
17
|
require("./index.css");
|
|
19
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
19
|
const AsyncUserSelect = _ref => {
|
|
21
|
-
var _selectorRef$current;
|
|
22
20
|
let className = _ref.className,
|
|
23
21
|
_ref$emptyPlaceholder = _ref.emptyPlaceholder,
|
|
24
22
|
emptyPlaceholder = _ref$emptyPlaceholder === void 0 ? '' : _ref$emptyPlaceholder,
|
|
@@ -58,6 +56,10 @@ const AsyncUserSelect = _ref => {
|
|
|
58
56
|
_useState10 = (0, _slicedToArray2.default)(_useState1, 2),
|
|
59
57
|
itemHeight = _useState10[0],
|
|
60
58
|
setItemHeight = _useState10[1];
|
|
59
|
+
const _useState11 = (0, _react.useState)(null),
|
|
60
|
+
_useState12 = (0, _slicedToArray2.default)(_useState11, 2),
|
|
61
|
+
popoverPosition = _useState12[0],
|
|
62
|
+
setPopoverPosition = _useState12[1];
|
|
61
63
|
const selectorRef = (0, _react.useRef)(null);
|
|
62
64
|
const userSelectContainerRef = (0, _react.useRef)(null);
|
|
63
65
|
const userListContainerRef = (0, _react.useRef)(null);
|
|
@@ -67,12 +69,6 @@ const AsyncUserSelect = _ref => {
|
|
|
67
69
|
setSearchValue('');
|
|
68
70
|
setHighlightIndex(-1);
|
|
69
71
|
}, []);
|
|
70
|
-
const onClickOutside = (0, _react.useCallback)(e => {
|
|
71
|
-
if (isPopoverOpen && (!selectorRef.current || !selectorRef.current.contains(e.target))) {
|
|
72
|
-
setIsPopoverOpen(false);
|
|
73
|
-
clearStatus();
|
|
74
|
-
}
|
|
75
|
-
}, [isPopoverOpen, clearStatus]);
|
|
76
72
|
const searchUsers = (0, _react.useCallback)(function () {
|
|
77
73
|
let searchValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
78
74
|
const trimmedSearchValue = (searchValue === null || searchValue === void 0 ? void 0 : searchValue.trim()) || '';
|
|
@@ -85,7 +81,6 @@ const AsyncUserSelect = _ref => {
|
|
|
85
81
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
86
82
|
// [{ email, name, avatar_url }, ...]
|
|
87
83
|
setSearchedUsers(options);
|
|
88
|
-
setHighlightIndex(options.length > 0 ? 0 : -1);
|
|
89
84
|
});
|
|
90
85
|
}, [loadOptions]);
|
|
91
86
|
const onSearchValueChanged = (0, _react.useCallback)(newSearchValue => {
|
|
@@ -190,108 +185,127 @@ const AsyncUserSelect = _ref => {
|
|
|
190
185
|
}
|
|
191
186
|
}, [onEnter, onUpArrow, onDownArrow, onEsc]);
|
|
192
187
|
(0, _react.useEffect)(() => {
|
|
193
|
-
if (
|
|
194
|
-
const _userSelectContainerR = userSelectContainerRef.current.getBoundingClientRect(),
|
|
195
|
-
bottom = _userSelectContainerR.bottom;
|
|
196
|
-
if (bottom > window.innerHeight) {
|
|
197
|
-
userSelectContainerRef.current.style.top = "".concat(window.innerHeight - bottom, "px");
|
|
198
|
-
}
|
|
199
|
-
}
|
|
188
|
+
if (!isPopoverOpen) return;
|
|
200
189
|
if (userListContainerRef.current && userItemContainerRef.current) {
|
|
201
|
-
const
|
|
202
|
-
const
|
|
203
|
-
const userItemHeight = parseInt(userItemStyle.height);
|
|
204
|
-
const maxContainerItemNum = Math.floor(parseInt(userContainerStyle.maxHeight) / userItemHeight);
|
|
205
|
-
setMaxItemNum(maxContainerItemNum);
|
|
190
|
+
const userItemHeight = userItemContainerRef.current.getBoundingClientRect().height;
|
|
191
|
+
const listMaxHeight = userListContainerRef.current.clientHeight;
|
|
206
192
|
setItemHeight(userItemHeight);
|
|
193
|
+
setMaxItemNum(Math.max(1, Math.floor(listMaxHeight / userItemHeight)));
|
|
207
194
|
}
|
|
208
|
-
}, []);
|
|
195
|
+
}, [isPopoverOpen, searchedUsers]);
|
|
209
196
|
(0, _react.useEffect)(() => {
|
|
210
197
|
document.addEventListener('keydown', onHotKey, true);
|
|
211
198
|
return () => {
|
|
212
199
|
document.removeEventListener('keydown', onHotKey, true);
|
|
213
200
|
};
|
|
214
201
|
}, [onHotKey]);
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
202
|
+
(0, _react.useEffect)(() => {
|
|
203
|
+
if (!isPopoverOpen) return;
|
|
204
|
+
const isInside = target => {
|
|
205
|
+
if (!target) return false;
|
|
206
|
+
if (selectorRef.current && selectorRef.current.contains(target)) return true;
|
|
207
|
+
if (userSelectContainerRef.current && userSelectContainerRef.current.contains(target)) return true;
|
|
208
|
+
return false;
|
|
209
|
+
};
|
|
210
|
+
const handleDocumentMouseDown = e => {
|
|
211
|
+
if (isInside(e.target)) return;
|
|
212
|
+
setIsPopoverOpen(false);
|
|
213
|
+
clearStatus();
|
|
214
|
+
};
|
|
215
|
+
document.addEventListener('mousedown', handleDocumentMouseDown, true);
|
|
216
|
+
return () => {
|
|
217
|
+
document.removeEventListener('mousedown', handleDocumentMouseDown, true);
|
|
218
|
+
};
|
|
219
|
+
}, [isPopoverOpen, clearStatus]);
|
|
220
|
+
const getSelectorRect = () => {
|
|
221
|
+
if (!selectorRef.current) return null;
|
|
222
|
+
return selectorRef.current.getBoundingClientRect();
|
|
223
|
+
};
|
|
224
|
+
(0, _react.useLayoutEffect)(() => {
|
|
225
|
+
if (!isPopoverOpen) {
|
|
226
|
+
setPopoverPosition(null);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
const rect = getSelectorRect();
|
|
230
|
+
if (!rect) return;
|
|
231
|
+
setPopoverPosition({
|
|
232
|
+
position: 'fixed',
|
|
233
|
+
top: rect.bottom + 8,
|
|
234
|
+
left: rect.left,
|
|
235
|
+
width: rect.width
|
|
236
|
+
});
|
|
237
|
+
}, [isPopoverOpen, selectedUsers]);
|
|
238
|
+
const popoverStyle = popoverPosition;
|
|
239
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
240
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
241
|
+
className: (0, _classnames.default)('dtable-ui-selected-users-container form-control d-flex align-items-center', className, {
|
|
242
|
+
'focus': isPopoverOpen
|
|
243
|
+
}),
|
|
244
|
+
onClick: onTogglePopover,
|
|
245
|
+
ref: selectorRef,
|
|
246
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
247
|
+
className: "dtable-ui-users-input",
|
|
248
|
+
children: [selectedUsers.map((user, index) => {
|
|
249
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_userItem.default, {
|
|
250
|
+
user: user,
|
|
251
|
+
deleteUser: deselectUser
|
|
252
|
+
}, "dtable-ui-user-selector-selected-user-".concat(index));
|
|
253
|
+
}), selectedUsers.length === 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
254
|
+
className: "dtable-ui-user-select-placeholder",
|
|
255
|
+
children: emptyPlaceholder || (0, _lang.getLocale)('Search_users')
|
|
256
|
+
}), !showDeptBtn && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
257
|
+
className: "select-dropdown-indicator d-inline-flex align-items-center",
|
|
258
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_DTableIcon.default, {
|
|
259
|
+
symbol: "down",
|
|
260
|
+
color: "var(--bs-icon-color)"
|
|
261
|
+
})
|
|
262
|
+
})]
|
|
263
|
+
})
|
|
264
|
+
}), isPopoverOpen && popoverStyle && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ModalPortal.default, {
|
|
265
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
266
|
+
className: "dtable-ui-user-select-popover dtable-ui-user-select-container",
|
|
267
|
+
ref: userSelectContainerRef,
|
|
268
|
+
style: popoverStyle,
|
|
269
|
+
onMouseDown: e => e.stopPropagation(),
|
|
270
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
271
|
+
className: "seatable-select-search",
|
|
272
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_DTableCustomizeSearchInput.default, {
|
|
273
|
+
className: "option-search-control",
|
|
274
|
+
placeholder: searchPlaceholder || (0, _lang.getLocale)('Search_users'),
|
|
275
|
+
onChange: onSearchValueChanged,
|
|
276
|
+
clearValue: () => onSearchValueChanged(''),
|
|
277
|
+
autoFocus: true,
|
|
278
|
+
isClearable: true,
|
|
279
|
+
value: searchValue
|
|
280
|
+
})
|
|
281
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
282
|
+
className: "dtable-ui-user-list-container",
|
|
283
|
+
ref: userListContainerRef,
|
|
284
|
+
children: [searchedUsers.length > 0 && searchedUsers.map((user, index) => {
|
|
285
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
286
|
+
className: (0, _classnames.default)('dtable-ui-user-item-container', {
|
|
287
|
+
'dtable-ui-user-item-container-highlight': index === highlightIndex
|
|
288
|
+
}),
|
|
289
|
+
ref: index === 0 ? userItemContainerRef : null,
|
|
290
|
+
onClick: () => onUserClick(user),
|
|
291
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_userItem.default, {
|
|
292
|
+
user: user,
|
|
293
|
+
enableShowIDInOrgWhenSearchUser: enableShowIDInOrgWhenSearchUser
|
|
294
|
+
}, "dtable-ui-user-selector-searched-user-".concat(index)), selectedUsers.find(u => u.email === user.email) && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
295
|
+
className: "dtable-ui-collaborator-check-icon",
|
|
296
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
|
|
297
|
+
className: "dtable-font dtable-icon-check",
|
|
298
|
+
"aria-hidden": "true"
|
|
299
|
+
})
|
|
300
|
+
})]
|
|
301
|
+
}, user.email);
|
|
302
|
+
}), searchedUsers.length === 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
303
|
+
className: "no-user-search-result",
|
|
304
|
+
children: searchValue ? (0, _lang.getLocale)('User_not_found') : (0, _lang.getLocale)('Enter_characters_to_start_searching')
|
|
291
305
|
})]
|
|
292
|
-
})
|
|
293
|
-
})
|
|
294
|
-
})
|
|
306
|
+
})]
|
|
307
|
+
})
|
|
308
|
+
})]
|
|
295
309
|
});
|
|
296
310
|
};
|
|
297
311
|
var _default = exports.default = AsyncUserSelect;
|
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
height: 32px;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
.select-search-control::placeholder {
|
|
17
|
+
color: var(--bs-bg-placeholder-color);
|
|
18
|
+
}
|
|
19
|
+
|
|
16
20
|
.select-search-control {
|
|
17
21
|
height: 100%;
|
|
18
22
|
border: none;
|
|
@@ -62,7 +66,7 @@
|
|
|
62
66
|
height: 20px;
|
|
63
67
|
width: 20px;
|
|
64
68
|
cursor: pointer;
|
|
65
|
-
border-radius:
|
|
69
|
+
border-radius: 4px;
|
|
66
70
|
}
|
|
67
71
|
|
|
68
72
|
.clear-icon-x .multicolor-icon {
|
|
@@ -15,6 +15,10 @@
|
|
|
15
15
|
border: 1px solid rgba(0, 40, 100, 0.12);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
.seatable-select-search .select-search-control::placeholder {
|
|
19
|
+
color: var(--bs-bg-placeholder-color);
|
|
20
|
+
}
|
|
21
|
+
|
|
18
22
|
.seatable-customize-select:focus,
|
|
19
23
|
.seatable-customize-select.focus {
|
|
20
24
|
border: 1px solid var(--bs-bg-border-color) !important;
|
|
@@ -101,7 +105,7 @@
|
|
|
101
105
|
line-height: 20px;
|
|
102
106
|
margin-right: 8px;
|
|
103
107
|
width: calc(100% - 20px);
|
|
104
|
-
display:
|
|
108
|
+
display: block;
|
|
105
109
|
text-overflow: ellipsis;
|
|
106
110
|
overflow: hidden;
|
|
107
111
|
white-space: nowrap;
|
|
@@ -122,7 +122,7 @@ class DTableCustomizeSelect extends _react.Component {
|
|
|
122
122
|
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
123
123
|
className: "select-placeholder",
|
|
124
124
|
children: placeholder
|
|
125
|
-
}),
|
|
125
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
126
126
|
className: "d-inline-flex align-items-center",
|
|
127
127
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_DTableIcon.default, {
|
|
128
128
|
symbol: "down",
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dtable-ui-component",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.10",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@seafile/react-image-lightbox": "5.0.9",
|
|
7
|
-
"@seafile/seafile-calendar": "^1.0.
|
|
7
|
+
"@seafile/seafile-calendar": "^1.0.13",
|
|
8
8
|
"@seafile/seafile-editor": "^3.0.34",
|
|
9
9
|
"classnames": "~2.5.*",
|
|
10
10
|
"dayjs": "1.10.7",
|
|
11
|
-
"dtable-utils": "~5.0.
|
|
11
|
+
"dtable-utils": "~5.0.33",
|
|
12
12
|
"is-hotkey": "0.2.0",
|
|
13
13
|
"rc-checkbox": "3.5.0",
|
|
14
14
|
"react-color": "2.19.3",
|