dtable-ui-component 7.0.8 → 7.0.9-beta.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,15 +29,10 @@
29
29
  height: 12px;
30
30
  }
31
31
 
32
- .dtable-ui-user-select-popover {
33
- z-index: 1060;
34
- width: 385px !important;
32
+ .dtable-ui-user-select-popover .popover {
33
+ width: 385px;
35
34
  max-width: 385px;
36
35
  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;
41
36
  }
42
37
 
43
38
  .dtable-ui-user-select-container {
@@ -63,10 +58,6 @@
63
58
  border-radius: 4px;
64
59
  }
65
60
 
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
-
70
61
  .dtable-ui-user-select-container .dtable-ui-user-list-container .dtable-ui-user-item-container:hover,
71
62
  .dtable-ui-user-select-container .dtable-ui-user-list-container .dtable-ui-user-item-container-highlight {
72
63
  background-color: var(--bs-btn-background-hover);
@@ -8,7 +8,8 @@ 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 _ModalPortal = _interopRequireDefault(require("../ModalPortal"));
11
+ var _reactstrap = require("reactstrap");
12
+ var _ClickOutside = _interopRequireDefault(require("../ClickOutside"));
12
13
  var _DTableCustomizeSearchInput = _interopRequireDefault(require("../DTableCustomizeSearchInput"));
13
14
  var _userItem = _interopRequireDefault(require("./user-item"));
14
15
  var _lang = require("../lang");
@@ -56,10 +57,6 @@ const AsyncUserSelect = _ref => {
56
57
  _useState10 = (0, _slicedToArray2.default)(_useState1, 2),
57
58
  itemHeight = _useState10[0],
58
59
  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];
63
60
  const selectorRef = (0, _react.useRef)(null);
64
61
  const userSelectContainerRef = (0, _react.useRef)(null);
65
62
  const userListContainerRef = (0, _react.useRef)(null);
@@ -69,6 +66,12 @@ const AsyncUserSelect = _ref => {
69
66
  setSearchValue('');
70
67
  setHighlightIndex(-1);
71
68
  }, []);
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]);
72
75
  const searchUsers = (0, _react.useCallback)(function () {
73
76
  let searchValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
74
77
  const trimmedSearchValue = (searchValue === null || searchValue === void 0 ? void 0 : searchValue.trim()) || '';
@@ -186,127 +189,106 @@ const AsyncUserSelect = _ref => {
186
189
  }
187
190
  }, [onEnter, onUpArrow, onDownArrow, onEsc]);
188
191
  (0, _react.useEffect)(() => {
189
- if (!isPopoverOpen) return;
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
+ }
190
199
  if (userListContainerRef.current && userItemContainerRef.current) {
191
- const userItemHeight = userItemContainerRef.current.getBoundingClientRect().height;
192
- const listMaxHeight = userListContainerRef.current.clientHeight;
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);
193
205
  setItemHeight(userItemHeight);
194
- setMaxItemNum(Math.max(1, Math.floor(listMaxHeight / userItemHeight)));
195
206
  }
196
- }, [isPopoverOpen, searchedUsers]);
207
+ }, []);
197
208
  (0, _react.useEffect)(() => {
198
209
  document.addEventListener('keydown', onHotKey, true);
199
210
  return () => {
200
211
  document.removeEventListener('keydown', onHotKey, true);
201
212
  };
202
213
  }, [onHotKey]);
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')
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
+ })]
306
288
  })]
307
- })]
308
- })
309
- })]
289
+ })
290
+ })]
291
+ })
310
292
  });
311
293
  };
312
294
  var _default = exports.default = AsyncUserSelect;
@@ -28,18 +28,6 @@
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
-
43
31
  .select-search-control:focus {
44
32
  outline: none;
45
33
  box-shadow: none;
@@ -82,6 +70,6 @@
82
70
 
83
71
  .dtable-ui-user-select-popover .select-search-control,
84
72
  .dtable-popover .select-search-control {
85
- border-top-left-radius: 4px;
86
- border-top-right-radius: 4px;
73
+ border-top-left-radius: 8px;
74
+ border-top-right-radius: 8px;
87
75
  }
@@ -107,6 +107,10 @@
107
107
  white-space: nowrap;
108
108
  }
109
109
 
110
+ .seatable-customize-select .selected-option .multicolor-icon {
111
+ font-size: 12px;
112
+ }
113
+
110
114
  .seatable-customize-select .multiple-check-icon,
111
115
  .seatable-customize-select .header-icon .dtable-font,
112
116
  .seatable-option-group .select-label .header-icon .dtable-font {
@@ -121,12 +125,6 @@
121
125
  margin-left: 0 !important;
122
126
  }
123
127
 
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
-
130
128
  .selector-group-select .selected-option-show .selected-option-item {
131
129
  align-items: center;
132
130
  border-radius: 4px;
@@ -161,9 +159,7 @@
161
159
  }
162
160
 
163
161
  .selector-group-select {
164
- height: auto;
165
- min-height: 38px;
166
- padding: 6px 16px 6px 8px;
162
+ padding: 7px 16px 7px 8px;
167
163
  }
168
164
 
169
165
  .selector-group-select .selected-option {
@@ -176,3 +172,7 @@
176
172
  height: auto;
177
173
  min-height: 24px
178
174
  }
175
+
176
+ .selector-group-select {
177
+ height: auto;
178
+ }
@@ -45,13 +45,6 @@ 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
- };
55
48
  this.getSelectedOptionTop = () => {
56
49
  if (!this.selector) return 38;
57
50
  const _this$selector$getBou = this.selector.getBoundingClientRect(),
@@ -87,12 +80,6 @@ class DTableCustomizeSelect extends _react.Component {
87
80
  isShowSelectOptions: false
88
81
  };
89
82
  }
90
- componentDidMount() {
91
- document.addEventListener('mousedown', this.handleDocumentMouseDown, true);
92
- }
93
- componentWillUnmount() {
94
- document.removeEventListener('mousedown', this.handleDocumentMouseDown, true);
95
- }
96
83
  render() {
97
84
  let _this$props2 = this.props,
98
85
  className = _this$props2.className,
@@ -132,7 +132,7 @@
132
132
  }
133
133
 
134
134
  .dtable-ui-filters-list .filter-conjunction {
135
- width: 88px;
135
+ width: 72px;
136
136
  }
137
137
 
138
138
  .dtable-ui-filters-list .filter-conjunction-readonly {
@@ -166,12 +166,21 @@
166
166
  color: #666666;
167
167
  }
168
168
 
169
+ .dtable-ui-filters-list .filter-column {
170
+ max-width: 150px;
171
+ }
172
+
169
173
  .filter-term .dtable-ui-multiple-select-selector .option,
170
174
  .filter-term .dtable-ui-single-select-selector .option {
171
175
  height: 30px;
172
176
  padding: 0 10px;
173
177
  }
174
178
 
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
+
175
184
  .filter-term .dtable-ui-single-select-selector .option:hover {
176
185
  color: #212529;
177
186
  background-color: #f7f7f7;
@@ -9,15 +9,7 @@
9
9
  color: var(--bs-icon-color);
10
10
  }
11
11
 
12
- .seatable-option .seatable-tip-default {
12
+ .seatable-option .select-option-name .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 option-name",
217
+ className: "seatable-option",
218
218
  children: label
219
219
  }), isSelected && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
220
220
  className: "dtable-font dtable-icon-check",
@@ -66,9 +66,6 @@
66
66
 
67
67
  .select-label {
68
68
  width: 100%;
69
- overflow: hidden;
70
- white-space: nowrap;
71
- text-overflow: ellipsis;
72
69
  }
73
70
 
74
71
  .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.8",
3
+ "version": "7.0.9-beta.2",
4
4
  "main": "./lib/index.js",
5
5
  "dependencies": {
6
6
  "@seafile/react-image-lightbox": "5.0.9",