dtable-ui-component 7.0.7-beta.1 → 7.0.7-soa.2

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.
@@ -29,10 +29,15 @@
29
29
  height: 12px;
30
30
  }
31
31
 
32
- .dtable-ui-user-select-popover .popover {
33
- width: 385px;
32
+ .dtable-ui-user-select-popover {
33
+ z-index: 1060;
34
+ width: 385px !important;
34
35
  max-width: 385px;
35
36
  margin-top: -4px;
37
+ background-color: var(--bs-popover-bg);
38
+ box-shadow: var(--bs-border-secondary-shadow);
39
+ border: 1px solid var(--bs-border-secondary-color);
40
+ border-radius: 4px;
36
41
  }
37
42
 
38
43
  .dtable-ui-user-select-container {
@@ -58,6 +63,10 @@
58
63
  border-radius: 4px;
59
64
  }
60
65
 
66
+ .dtable-ui-user-select-container .dtable-ui-user-list-container .dtable-ui-user-item-container .dtable-ui-user-item {
67
+ background: none !important;
68
+ }
69
+
61
70
  .dtable-ui-user-select-container .dtable-ui-user-list-container .dtable-ui-user-item-container:hover,
62
71
  .dtable-ui-user-select-container .dtable-ui-user-list-container .dtable-ui-user-item-container-highlight {
63
72
  background-color: var(--bs-btn-background-hover);
@@ -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 _reactstrap = require("reactstrap");
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");
@@ -57,6 +56,10 @@ const AsyncUserSelect = _ref => {
57
56
  _useState10 = (0, _slicedToArray2.default)(_useState1, 2),
58
57
  itemHeight = _useState10[0],
59
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];
60
63
  const selectorRef = (0, _react.useRef)(null);
61
64
  const userSelectContainerRef = (0, _react.useRef)(null);
62
65
  const userListContainerRef = (0, _react.useRef)(null);
@@ -66,12 +69,6 @@ const AsyncUserSelect = _ref => {
66
69
  setSearchValue('');
67
70
  setHighlightIndex(-1);
68
71
  }, []);
69
- const onClickOutside = (0, _react.useCallback)(e => {
70
- if (isPopoverOpen && (!selectorRef.current || !selectorRef.current.contains(e.target))) {
71
- setIsPopoverOpen(false);
72
- clearStatus();
73
- }
74
- }, [isPopoverOpen, clearStatus]);
75
72
  const searchUsers = (0, _react.useCallback)(function () {
76
73
  let searchValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
77
74
  const trimmedSearchValue = (searchValue === null || searchValue === void 0 ? void 0 : searchValue.trim()) || '';
@@ -189,106 +186,127 @@ const AsyncUserSelect = _ref => {
189
186
  }
190
187
  }, [onEnter, onUpArrow, onDownArrow, onEsc]);
191
188
  (0, _react.useEffect)(() => {
192
- if (userSelectContainerRef.current) {
193
- const _userSelectContainerR = userSelectContainerRef.current.getBoundingClientRect(),
194
- bottom = _userSelectContainerR.bottom;
195
- if (bottom > window.innerHeight) {
196
- userSelectContainerRef.current.style.top = "".concat(window.innerHeight - bottom, "px");
197
- }
198
- }
189
+ if (!isPopoverOpen) return;
199
190
  if (userListContainerRef.current && userItemContainerRef.current) {
200
- const userContainerStyle = getComputedStyle(userListContainerRef.current, null);
201
- const userItemStyle = getComputedStyle(userItemContainerRef.current, null);
202
- const userItemHeight = parseInt(userItemStyle.height);
203
- const maxContainerItemNum = Math.floor(parseInt(userContainerStyle.maxHeight) / userItemHeight);
204
- setMaxItemNum(maxContainerItemNum);
191
+ const userItemHeight = userItemContainerRef.current.getBoundingClientRect().height;
192
+ const listMaxHeight = userListContainerRef.current.clientHeight;
205
193
  setItemHeight(userItemHeight);
194
+ setMaxItemNum(Math.max(1, Math.floor(listMaxHeight / userItemHeight)));
206
195
  }
207
- }, []);
196
+ }, [isPopoverOpen, searchedUsers]);
208
197
  (0, _react.useEffect)(() => {
209
198
  document.addEventListener('keydown', onHotKey, true);
210
199
  return () => {
211
200
  document.removeEventListener('keydown', onHotKey, true);
212
201
  };
213
202
  }, [onHotKey]);
214
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ClickOutside.default, {
215
- onClickOutside: onClickOutside,
216
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
217
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
218
- className: (0, _classnames.default)('dtable-ui-selected-users-container form-control d-flex align-items-center', className, {
219
- 'focus': isPopoverOpen
220
- }),
221
- onClick: onTogglePopover,
222
- ref: selectorRef,
223
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
224
- className: "dtable-ui-users-input",
225
- children: [selectedUsers.map((user, index) => {
226
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_userItem.default, {
227
- user: user,
228
- deleteUser: deselectUser
229
- }, "dtable-ui-user-selector-selected-user-".concat(index));
230
- }), selectedUsers.length === 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
231
- className: "dtable-ui-user-select-placeholder",
232
- children: emptyPlaceholder || (0, _lang.getLocale)('Search_users')
233
- }), !showDeptBtn && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
234
- className: "select-dropdown-indicator d-inline-flex align-items-center",
235
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_DTableIcon.default, {
236
- symbol: "down",
237
- color: "var(--bs-icon-color)"
238
- })
239
- })]
240
- })
241
- }), selectorRef.current && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactstrap.Popover, {
242
- placement: "bottom-start",
243
- isOpen: isPopoverOpen,
244
- target: selectorRef.current,
245
- hideArrow: true,
246
- fade: false,
247
- className: "dtable-ui-user-select-popover",
248
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
249
- className: "dtable-ui-user-select-container",
250
- ref: userSelectContainerRef,
251
- onMouseDown: e => e.stopPropagation(),
252
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
253
- className: "seatable-select-search",
254
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_DTableCustomizeSearchInput.default, {
255
- className: "option-search-control",
256
- placeholder: searchPlaceholder || (0, _lang.getLocale)('Search_users'),
257
- onChange: onSearchValueChanged,
258
- clearValue: () => onSearchValueChanged(''),
259
- autoFocus: true,
260
- isClearable: true,
261
- value: searchValue
262
- })
263
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
264
- className: "dtable-ui-user-list-container",
265
- ref: userListContainerRef,
266
- children: [searchedUsers.length > 0 && searchedUsers.map((user, index) => {
267
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
268
- className: (0, _classnames.default)('dtable-ui-user-item-container', {
269
- 'dtable-ui-user-item-container-highlight': index === highlightIndex
270
- }),
271
- ref: userItemContainerRef,
272
- onClick: () => onUserClick(user),
273
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_userItem.default, {
274
- user: user,
275
- enableShowIDInOrgWhenSearchUser: enableShowIDInOrgWhenSearchUser
276
- }, "dtable-ui-user-selector-searched-user-".concat(index)), selectedUsers.find(u => u.email === user.email) && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
277
- className: "dtable-ui-collaborator-check-icon",
278
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
279
- className: "dtable-font dtable-icon-check",
280
- "aria-hidden": "true"
281
- })
282
- })]
283
- }, user.email);
284
- }), searchedUsers.length === 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
285
- className: "no-user-search-result",
286
- children: searchValue ? (0, _lang.getLocale)('User_not_found') : (0, _lang.getLocale)('Enter_characters_to_start_searching')
287
- })]
203
+ (0, _react.useEffect)(() => {
204
+ if (!isPopoverOpen) return;
205
+ const isInside = target => {
206
+ if (!target) return false;
207
+ if (selectorRef.current && selectorRef.current.contains(target)) return true;
208
+ if (userSelectContainerRef.current && userSelectContainerRef.current.contains(target)) return true;
209
+ return false;
210
+ };
211
+ const handleDocumentMouseDown = e => {
212
+ if (isInside(e.target)) return;
213
+ setIsPopoverOpen(false);
214
+ clearStatus();
215
+ };
216
+ document.addEventListener('mousedown', handleDocumentMouseDown, true);
217
+ return () => {
218
+ document.removeEventListener('mousedown', handleDocumentMouseDown, true);
219
+ };
220
+ }, [isPopoverOpen, clearStatus]);
221
+ const getSelectorRect = () => {
222
+ if (!selectorRef.current) return null;
223
+ return selectorRef.current.getBoundingClientRect();
224
+ };
225
+ (0, _react.useLayoutEffect)(() => {
226
+ if (!isPopoverOpen) {
227
+ setPopoverPosition(null);
228
+ return;
229
+ }
230
+ const rect = getSelectorRect();
231
+ if (!rect) return;
232
+ setPopoverPosition({
233
+ position: 'fixed',
234
+ top: rect.bottom + 8,
235
+ left: rect.left,
236
+ width: rect.width
237
+ });
238
+ }, [isPopoverOpen, selectedUsers]);
239
+ const popoverStyle = popoverPosition;
240
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
241
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
242
+ className: (0, _classnames.default)('dtable-ui-selected-users-container form-control d-flex align-items-center', className, {
243
+ 'focus': isPopoverOpen
244
+ }),
245
+ onClick: onTogglePopover,
246
+ ref: selectorRef,
247
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
248
+ className: "dtable-ui-users-input",
249
+ children: [selectedUsers.map((user, index) => {
250
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_userItem.default, {
251
+ user: user,
252
+ deleteUser: deselectUser
253
+ }, "dtable-ui-user-selector-selected-user-".concat(index));
254
+ }), selectedUsers.length === 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
255
+ className: "dtable-ui-user-select-placeholder",
256
+ children: emptyPlaceholder || (0, _lang.getLocale)('Search_users')
257
+ }), !showDeptBtn && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
258
+ className: "select-dropdown-indicator d-inline-flex align-items-center",
259
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_DTableIcon.default, {
260
+ symbol: "down",
261
+ color: "var(--bs-icon-color)"
262
+ })
263
+ })]
264
+ })
265
+ }), isPopoverOpen && popoverStyle && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ModalPortal.default, {
266
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
267
+ className: "dtable-ui-user-select-popover dtable-ui-user-select-container",
268
+ ref: userSelectContainerRef,
269
+ style: popoverStyle,
270
+ onMouseDown: e => e.stopPropagation(),
271
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
272
+ className: "seatable-select-search",
273
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_DTableCustomizeSearchInput.default, {
274
+ className: "option-search-control",
275
+ placeholder: searchPlaceholder || (0, _lang.getLocale)('Search_users'),
276
+ onChange: onSearchValueChanged,
277
+ clearValue: () => onSearchValueChanged(''),
278
+ autoFocus: true,
279
+ isClearable: true,
280
+ value: searchValue
281
+ })
282
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
283
+ className: "dtable-ui-user-list-container",
284
+ ref: userListContainerRef,
285
+ children: [searchedUsers.length > 0 && searchedUsers.map((user, index) => {
286
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
287
+ className: (0, _classnames.default)('dtable-ui-user-item-container', {
288
+ 'dtable-ui-user-item-container-highlight': index === highlightIndex
289
+ }),
290
+ ref: index === 0 ? userItemContainerRef : null,
291
+ onClick: () => onUserClick(user),
292
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_userItem.default, {
293
+ user: user,
294
+ enableShowIDInOrgWhenSearchUser: enableShowIDInOrgWhenSearchUser
295
+ }, "dtable-ui-user-selector-searched-user-".concat(index)), selectedUsers.find(u => u.email === user.email) && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
296
+ className: "dtable-ui-collaborator-check-icon",
297
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
298
+ className: "dtable-font dtable-icon-check",
299
+ "aria-hidden": "true"
300
+ })
301
+ })]
302
+ }, user.email);
303
+ }), searchedUsers.length === 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
304
+ className: "no-user-search-result",
305
+ children: searchValue ? (0, _lang.getLocale)('User_not_found') : (0, _lang.getLocale)('Enter_characters_to_start_searching')
288
306
  })]
289
- })
290
- })]
291
- })
307
+ })]
308
+ })
309
+ })]
292
310
  });
293
311
  };
294
312
  var _default = exports.default = AsyncUserSelect;
@@ -28,6 +28,18 @@
28
28
  border-top-right-radius: 4px;
29
29
  }
30
30
 
31
+ .select-search-control:-webkit-autofill,
32
+ .select-search-control:-webkit-autofill:hover,
33
+ .select-search-control:-webkit-autofill:focus,
34
+ .select-search-control:-webkit-autofill:active,
35
+ .select-search-control:-internal-autofill-previewed,
36
+ .select-search-control:-internal-autofill-selected {
37
+ -webkit-box-shadow: inset 0 0 0 1000px var(--bs-popover-bg) !important;
38
+ box-shadow: inset 0 0 0 1000px var(--bs-popover-bg) !important;
39
+ -webkit-text-fill-color: var(--bs-body-color) !important;
40
+ transition: background-color 5000s ease-in-out 0s !important;
41
+ }
42
+
31
43
  .select-search-control:focus {
32
44
  outline: none;
33
45
  box-shadow: none;
@@ -70,6 +82,6 @@
70
82
 
71
83
  .dtable-ui-user-select-popover .select-search-control,
72
84
  .dtable-popover .select-search-control {
73
- border-top-left-radius: 8px;
74
- border-top-right-radius: 8px;
85
+ border-top-left-radius: 4px;
86
+ border-top-right-radius: 4px;
75
87
  }
@@ -107,10 +107,6 @@
107
107
  white-space: nowrap;
108
108
  }
109
109
 
110
- .seatable-customize-select .selected-option .multicolor-icon {
111
- font-size: 12px;
112
- }
113
-
114
110
  .seatable-customize-select .multiple-check-icon,
115
111
  .seatable-customize-select .header-icon .dtable-font,
116
112
  .seatable-option-group .select-label .header-icon .dtable-font {
@@ -125,6 +121,12 @@
125
121
  margin-left: 0 !important;
126
122
  }
127
123
 
124
+ .seatable-customize-select .selected-option .dtable-icon-down3,
125
+ .seatable-customize-select .selected-option .multicolor-icon {
126
+ color: var(--bs-icon-color) !important;
127
+ font-size: 12px;
128
+ }
129
+
128
130
  .selector-group-select .selected-option-show .selected-option-item {
129
131
  align-items: center;
130
132
  border-radius: 4px;
@@ -159,7 +161,9 @@
159
161
  }
160
162
 
161
163
  .selector-group-select {
162
- padding: 7px 16px 7px 8px;
164
+ height: auto;
165
+ min-height: 38px;
166
+ padding: 6px 16px 6px 8px;
163
167
  }
164
168
 
165
169
  .selector-group-select .selected-option {
@@ -172,7 +176,3 @@
172
176
  height: auto;
173
177
  min-height: 24px
174
178
  }
175
-
176
- .selector-group-select {
177
- height: auto;
178
- }
@@ -45,6 +45,13 @@ class DTableCustomizeSelect extends _react.Component {
45
45
  isShowSelectOptions: false
46
46
  });
47
47
  };
48
+ this.handleDocumentMouseDown = event => {
49
+ if (!this.state.isShowSelectOptions) return;
50
+ const target = event.target;
51
+ if (this.selector && this.selector.contains(target)) return;
52
+ if (target && target.closest && target.closest('.seatable-option-group')) return;
53
+ this.closeSelect();
54
+ };
48
55
  this.getSelectedOptionTop = () => {
49
56
  if (!this.selector) return 38;
50
57
  const _this$selector$getBou = this.selector.getBoundingClientRect(),
@@ -80,6 +87,12 @@ class DTableCustomizeSelect extends _react.Component {
80
87
  isShowSelectOptions: false
81
88
  };
82
89
  }
90
+ componentDidMount() {
91
+ document.addEventListener('mousedown', this.handleDocumentMouseDown, true);
92
+ }
93
+ componentWillUnmount() {
94
+ document.removeEventListener('mousedown', this.handleDocumentMouseDown, true);
95
+ }
83
96
  render() {
84
97
  let _this$props2 = this.props,
85
98
  className = _this$props2.className,
@@ -109,7 +122,7 @@ class DTableCustomizeSelect extends _react.Component {
109
122
  }) : /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
110
123
  className: "select-placeholder",
111
124
  children: placeholder
112
- }), !isLocked && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
125
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
113
126
  className: "d-inline-flex align-items-center",
114
127
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_DTableIcon.default, {
115
128
  symbol: "down",
@@ -132,7 +132,7 @@
132
132
  }
133
133
 
134
134
  .dtable-ui-filters-list .filter-conjunction {
135
- width: 72px;
135
+ width: 88px;
136
136
  }
137
137
 
138
138
  .dtable-ui-filters-list .filter-conjunction-readonly {
@@ -166,21 +166,12 @@
166
166
  color: #666666;
167
167
  }
168
168
 
169
- .dtable-ui-filters-list .filter-column {
170
- max-width: 150px;
171
- }
172
-
173
169
  .filter-term .dtable-ui-multiple-select-selector .option,
174
170
  .filter-term .dtable-ui-single-select-selector .option {
175
171
  height: 30px;
176
172
  padding: 0 10px;
177
173
  }
178
174
 
179
- .filter-term .dtable-ui-multiple-select-selector .select-option-name,
180
- .filter-term .dtable-ui-single-select-selector .select-option-name {
181
- margin-top: 5px !important;
182
- }
183
-
184
175
  .filter-term .dtable-ui-single-select-selector .option:hover {
185
176
  color: #212529;
186
177
  background-color: #f7f7f7;
@@ -9,7 +9,15 @@
9
9
  color: var(--bs-icon-color);
10
10
  }
11
11
 
12
- .seatable-option .select-option-name .seatable-tip-default {
12
+ .seatable-option .seatable-tip-default {
13
13
  font-size: 12px;
14
14
  margin-top: 4px
15
15
  }
16
+
17
+ .select-option-name .group-select-option,
18
+ .seatable-option.option-name {
19
+ width: 100%;
20
+ overflow: hidden;
21
+ text-overflow: ellipsis;
22
+ white-space: nowrap;
23
+ }
@@ -214,7 +214,7 @@ const Option = props => {
214
214
  whiteSpace: 'pre-line'
215
215
  },
216
216
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
217
- className: "seatable-option",
217
+ className: "seatable-option option-name",
218
218
  children: label
219
219
  }), isSelected && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
220
220
  className: "dtable-font dtable-icon-check",
@@ -66,6 +66,9 @@
66
66
 
67
67
  .select-label {
68
68
  width: 100%;
69
+ overflow: hidden;
70
+ white-space: nowrap;
71
+ text-overflow: ellipsis;
69
72
  }
70
73
 
71
74
  .seatable-option-group-selector-multiple-select .select-label,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-ui-component",
3
- "version": "7.0.7-beta.1",
3
+ "version": "7.0.7soa.2",
4
4
  "main": "./lib/index.js",
5
5
  "dependencies": {
6
6
  "@seafile/react-image-lightbox": "5.0.9",