dtable-ui-component 6.0.124 → 6.0.125-nsk.1

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.
Files changed (41) hide show
  1. package/lib/AsyncUserSelect/index.css +46 -14
  2. package/lib/AsyncUserSelect/index.js +22 -18
  3. package/lib/DTableCustomizeSearchInput/index.css +81 -0
  4. package/lib/DTableCustomizeSearchInput/index.js +141 -0
  5. package/lib/DTableCustomizeSelect/index.css +67 -43
  6. package/lib/DTableCustomizeSelect/index.js +16 -10
  7. package/lib/DTableCustomizeSelect/util.js +12 -0
  8. package/lib/DTableFiltersPopover/utils/filter-item-utils.js +2 -2
  9. package/lib/DTableFiltersPopover/widgets/collaborator-filter/index.js +1 -1
  10. package/lib/DTableFiltersPopover/widgets/filter-list/index.css +5 -5
  11. package/lib/DTableGroupSelect/index.css +31 -5
  12. package/lib/DTableGroupSelect/index.js +5 -5
  13. package/lib/DTableSelect/dtable-select-label.css +4 -4
  14. package/lib/DTableSelect/dtable-select-label.js +1 -1
  15. package/lib/DTableSelect/index.js +3 -3
  16. package/lib/DTableSelect/select-dropdown-indicator/index.css +16 -0
  17. package/lib/DTableSelect/select-dropdown-indicator/index.js +26 -0
  18. package/lib/DTableSelect/select-style.js +133 -0
  19. package/lib/DTableSelect/user-select.css +7 -46
  20. package/lib/DTableSelect/utils.js +166 -77
  21. package/lib/ImagePreviewerLightbox/index.js +2 -2
  22. package/lib/SelectOptionGroup/KeyCodes.js +96 -4
  23. package/lib/SelectOptionGroup/index.css +75 -54
  24. package/lib/SelectOptionGroup/index.js +43 -34
  25. package/lib/SelectOptionGroup/option.js +14 -4
  26. package/lib/assets/icons/close.svg +1 -0
  27. package/lib/assets/icons/down.svg +3 -0
  28. package/lib/index.js +3 -3
  29. package/lib/locales/de.json +2 -2
  30. package/lib/locales/en.json +2 -2
  31. package/lib/locales/es.json +2 -2
  32. package/lib/locales/fr.json +2 -2
  33. package/lib/locales/pt.json +2 -2
  34. package/lib/locales/ru.json +2 -2
  35. package/lib/locales/zh-CN.json +2 -2
  36. package/package.json +1 -1
  37. package/lib/DTableCustomizeCollaboratorSelect/index.css +0 -86
  38. package/lib/DTableCustomizeCollaboratorSelect/index.js +0 -161
  39. package/lib/DTableGroupSelect/option.js +0 -42
  40. package/lib/DTableGroupSelect/select-option-group.css +0 -54
  41. package/lib/DTableGroupSelect/select-option-group.js +0 -236
@@ -8,36 +8,33 @@ Object.defineProperty(exports, "__esModule", {
8
8
  exports.default = void 0;
9
9
  var _react = _interopRequireWildcard(require("react"));
10
10
  var _classnames = _interopRequireDefault(require("classnames"));
11
+ var _ClickOutside = _interopRequireDefault(require("../ClickOutside"));
12
+ var _DTableCustomizeSearchInput = _interopRequireDefault(require("../DTableCustomizeSearchInput"));
11
13
  var _option = _interopRequireDefault(require("./option"));
12
- var _DTableSearchInput = _interopRequireDefault(require("../DTableSearchInput"));
13
14
  var _KeyCodes = _interopRequireDefault(require("./KeyCodes"));
14
- var _ClickOutside = _interopRequireDefault(require("../ClickOutside"));
15
15
  require("./index.css");
16
16
  var _jsxRuntime = require("react/jsx-runtime");
17
17
  const OPTION_HEIGHT = 32;
18
18
  class SelectOptionGroup extends _react.Component {
19
19
  constructor(props) {
20
20
  super(props);
21
+ this.handleDocumentClick = e => {
22
+ this.props.onClickOutside(e);
23
+ };
21
24
  this.resetMenuStyle = () => {
22
- if (!this.optionGroupRef) return;
23
25
  const {
24
26
  isInModal,
25
27
  position
26
28
  } = this.props;
27
29
  const {
28
30
  top,
29
- height,
30
- width
31
+ height
31
32
  } = this.optionGroupRef.getBoundingClientRect();
32
33
  if (isInModal) {
33
34
  if (position.y + position.height + height > window.innerHeight) {
34
35
  this.optionGroupRef.style.top = position.y - height + 'px';
35
36
  }
36
- if (position && position.x + width > window.innerWidth) {
37
- this.optionGroupRef.style.left = window.innerWidth - width - 10 + 'px';
38
- }
39
37
  this.optionGroupRef.style.opacity = 1;
40
- this.searchInputRef.current && this.searchInputRef.current.inputRef.focus();
41
38
  } else {
42
39
  if (height + top > window.innerHeight) {
43
40
  const borderWidth = 2;
@@ -89,10 +86,6 @@ class SelectOptionGroup extends _react.Component {
89
86
  if (isInModal) {
90
87
  e.stopPropagation();
91
88
  e.nativeEvent.stopImmediatePropagation();
92
-
93
- // ClickOutside set isClickedInside to true via mouse down capture first
94
- // Set isClickedInside to false after mouse down
95
- this.clickOutsideRef && this.clickOutsideRef.setClickedInsideStatus(false);
96
89
  }
97
90
  };
98
91
  this.scrollContent = () => {
@@ -132,10 +125,17 @@ class SelectOptionGroup extends _react.Component {
132
125
  });
133
126
  }
134
127
  };
128
+ this.clearSearch = () => {
129
+ this.setState({
130
+ searchVal: '',
131
+ activeIndex: -1
132
+ });
133
+ };
135
134
  this.renderOptGroup = searchVal => {
136
135
  let {
137
136
  noOptionsPlaceholder,
138
- onSelectOption
137
+ onSelectOption,
138
+ value
139
139
  } = this.props;
140
140
  this.filterOptions = this.props.getFilterOptions(searchVal);
141
141
  if (this.filterOptions.length === 0) {
@@ -147,7 +147,16 @@ class SelectOptionGroup extends _react.Component {
147
147
  return this.filterOptions.map((opt, i) => {
148
148
  let key = opt.value.column ? opt.value.column.key : i;
149
149
  let isActive = this.state.activeIndex === i;
150
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_option.default, {
150
+ let isSelected = false;
151
+ if (value) {
152
+ // Handle both single value and array of values
153
+ if (Array.isArray(value.value)) {
154
+ isSelected = value.value.includes(opt.value);
155
+ } else {
156
+ isSelected = opt.value === value.value || JSON.stringify(opt.value) === JSON.stringify(value.value);
157
+ }
158
+ }
159
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_option.default, {
151
160
  index: i,
152
161
  isActive: isActive,
153
162
  value: opt.value,
@@ -155,8 +164,13 @@ class SelectOptionGroup extends _react.Component {
155
164
  changeIndex: this.changeIndex,
156
165
  supportMultipleSelect: this.props.supportMultipleSelect,
157
166
  disableHover: this.state.disableHover,
158
- children: opt.label
159
- }, "".concat(key, "-").concat(i));
167
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
168
+ className: "select-label",
169
+ children: opt.label
170
+ }), isSelected && /*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
171
+ className: "dtable-font dtable-icon-check seatable-check-color"
172
+ })]
173
+ }, key);
160
174
  });
161
175
  };
162
176
  this.state = {
@@ -166,10 +180,10 @@ class SelectOptionGroup extends _react.Component {
166
180
  };
167
181
  this.filterOptions = null;
168
182
  this.timer = null;
169
- this.searchInputRef = /*#__PURE__*/_react.default.createRef();
170
183
  }
171
184
  componentDidMount() {
172
185
  window.addEventListener('keydown', this.onHotKey);
186
+ document.addEventListener('mousedown', this.handleDocumentClick);
173
187
  setTimeout(() => {
174
188
  this.resetMenuStyle();
175
189
  }, 1);
@@ -178,6 +192,7 @@ class SelectOptionGroup extends _react.Component {
178
192
  this.filterOptions = null;
179
193
  this.timer && clearTimeout(this.timer);
180
194
  window.removeEventListener('keydown', this.onHotKey);
195
+ document.removeEventListener('mousedown', this.handleDocumentClick);
181
196
  }
182
197
  render() {
183
198
  const {
@@ -190,13 +205,8 @@ class SelectOptionGroup extends _react.Component {
190
205
  isShowSelected,
191
206
  isInModal,
192
207
  position,
193
- className,
194
- addOptionAble,
195
- component
208
+ className
196
209
  } = this.props;
197
- const {
198
- AddOption
199
- } = component || {};
200
210
  let {
201
211
  searchVal
202
212
  } = this.state;
@@ -221,12 +231,10 @@ class SelectOptionGroup extends _react.Component {
221
231
  };
222
232
  }
223
233
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ClickOutside.default, {
224
- ref: ref => this.clickOutsideRef = ref,
225
234
  onClickOutside: this.props.onClickOutside,
226
235
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
227
- className: (0, _classnames.default)('option-group', className ? 'option-group-' + className : '', {
228
- 'pt-0': isShowSelected,
229
- 'create-new-option-group': addOptionAble
236
+ className: (0, _classnames.default)('seatable-option-group', className ? 'seatable-option-group-' + className : '', {
237
+ 'pt-0': isShowSelected
230
238
  }),
231
239
  ref: ref => this.optionGroupRef = ref,
232
240
  style: style,
@@ -235,20 +243,21 @@ class SelectOptionGroup extends _react.Component {
235
243
  className: "editor-list-delete mb-2",
236
244
  onClick: e => e.stopPropagation(),
237
245
  children: value.label || ''
238
- }), searchable && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
239
- className: "option-group-search",
240
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_DTableSearchInput.default, {
246
+ }), searchable && this.props.options && this.props.options.length > 10 && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
247
+ className: "seatable-option-group-search",
248
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_DTableCustomizeSearchInput.default, {
241
249
  className: "option-search-control",
242
250
  placeholder: searchPlaceholder,
243
251
  onChange: this.onChangeSearch,
252
+ clearValue: this.clearSearch,
244
253
  autoFocus: true,
245
- ref: this.searchInputRef
254
+ isClearable: true
246
255
  })
247
256
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
248
- className: "option-group-content",
257
+ className: "seatable-option-group-content",
249
258
  ref: ref => this.optionGroupContentRef = ref,
250
259
  children: this.renderOptGroup(searchVal)
251
- }), addOptionAble && AddOption]
260
+ })]
252
261
  })
253
262
  });
254
263
  }
@@ -1,20 +1,22 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
3
4
  var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.default = void 0;
8
9
  var _react = _interopRequireWildcard(require("react"));
10
+ var _classnames = _interopRequireDefault(require("classnames"));
9
11
  var _jsxRuntime = require("react/jsx-runtime");
10
12
  class Option extends _react.Component {
11
13
  constructor() {
12
14
  super(...arguments);
13
- this.onSelectOption = (value, event) => {
15
+ this.onSelectOption = event => {
14
16
  if (this.props.supportMultipleSelect) {
15
17
  event.stopPropagation();
16
18
  }
17
- this.props.onSelectOption(value, event);
19
+ this.props.onSelectOption(this.props.value, event);
18
20
  };
19
21
  this.onMouseEnter = () => {
20
22
  if (!this.props.disableHover) {
@@ -26,11 +28,19 @@ class Option extends _react.Component {
26
28
  this.props.changeIndex(-1);
27
29
  }
28
30
  };
31
+ this.onKeyDown = e => {
32
+ if (e.key === 'Enter' || e.key === 'Space') {
33
+ e.target.click();
34
+ }
35
+ };
29
36
  }
30
37
  render() {
31
38
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
32
- className: this.props.isActive ? 'option option-active' : 'option',
33
- onClick: this.onSelectOption.bind(this, this.props.value),
39
+ className: (0, _classnames.default)('seatable-select-option', {
40
+ 'seatable-select-option-active': this.props.isActive
41
+ }),
42
+ onClick: this.onSelectOption,
43
+ onKeyDown: this.onKeyDown,
34
44
  onMouseEnter: this.onMouseEnter,
35
45
  onMouseLeave: this.onMouseLeave,
36
46
  children: this.props.children
@@ -0,0 +1 @@
1
+ <?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1718937171668" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="18368" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M489.6 444.8l294.4-294.4 67.2 67.2-294.4 294.4 294.4 294.4-67.2 67.2-294.4-294.4-272 272-67.2-67.2 272-272-272-272 67.2-67.2z" p-id="18369" fill="currentColor"></path></svg>
@@ -0,0 +1,3 @@
1
+ <svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M3.27148 11.2718L6.09991 8.44336L15.9994 18.3429L25.8989 8.44336L28.7273 11.2718L15.9994 23.9997L3.27148 11.2718Z" fill="currentColor"/>
3
+ </svg>
package/lib/index.js CHANGED
@@ -118,10 +118,10 @@ Object.defineProperty(exports, "DTableCustomFooter", {
118
118
  return _DTableCustomFooter.default;
119
119
  }
120
120
  });
121
- Object.defineProperty(exports, "DTableCustomizeCollaboratorSelect", {
121
+ Object.defineProperty(exports, "DTableCustomizeSearchInput", {
122
122
  enumerable: true,
123
123
  get: function () {
124
- return _DTableCustomizeCollaboratorSelect.default;
124
+ return _DTableCustomizeSearchInput.default;
125
125
  }
126
126
  });
127
127
  Object.defineProperty(exports, "DTableCustomizeSelect", {
@@ -722,8 +722,8 @@ var _index = _interopRequireDefault(require("./DTableGroupSelect/index"));
722
722
  var _dtableSelectLabel = _interopRequireDefault(require("./DTableSelect/dtable-select-label"));
723
723
  var _DTableSwitch = _interopRequireDefault(require("./DTableSwitch"));
724
724
  var _DTableCustomizeSelect = _interopRequireDefault(require("./DTableCustomizeSelect"));
725
- var _DTableCustomizeCollaboratorSelect = _interopRequireDefault(require("./DTableCustomizeCollaboratorSelect"));
726
725
  var _DTableSearchInput = _interopRequireDefault(require("./DTableSearchInput"));
726
+ var _DTableCustomizeSearchInput = _interopRequireDefault(require("./DTableCustomizeSearchInput"));
727
727
  var _DTableColorPicker = _interopRequireDefault(require("./DTableColorPicker"));
728
728
  var _ModalPortal = _interopRequireDefault(require("./ModalPortal"));
729
729
  var _RoleStatusEditor = _interopRequireDefault(require("./RoleStatusEditor"));
@@ -12,8 +12,8 @@
12
12
  "Rotate_image": "Rotate image",
13
13
  "Delete_image": "delete image",
14
14
  "Download_image": "Download image",
15
- "Pre_Line": "previous Line",
16
- "Next_Line": "next Line",
15
+ "Previous_record": "Vorheriger Eintrag",
16
+ "Next_record": "Nächster Eintrag",
17
17
  "Zoom_in": "Zoom in",
18
18
  "Zoom_out": "Zoom out",
19
19
  "Choose_a_collaborator": "Wählen Sie einen Mitarbeiter",
@@ -12,8 +12,8 @@
12
12
  "Rotate_image": "Rotate image",
13
13
  "Delete_image": "delete image",
14
14
  "Download_image": "Download image",
15
- "Pre_Line": "previous Line",
16
- "Next_Line": "next Line",
15
+ "Previous_record": "Previous record",
16
+ "Next_record": "Next record",
17
17
  "Zoom_in": "Zoom in",
18
18
  "Zoom_out": "Zoom out",
19
19
  "Choose_a_collaborator": "Choose a collaborator",
@@ -12,8 +12,8 @@
12
12
  "Rotate_image": "Rotate image",
13
13
  "Delete_image": "delete image",
14
14
  "Download_image": "Download image",
15
- "Pre_Line": "previous Line",
16
- "Next_Line": "next Line",
15
+ "Previous_record": "Registro previo",
16
+ "Next_record": "Próximo registro",
17
17
  "Zoom_in": "Zoom in",
18
18
  "Zoom_out": "Zoom out",
19
19
  "Choose_a_collaborator": "Choose a collaborator",
@@ -12,8 +12,8 @@
12
12
  "Rotate_image": "Rotate image",
13
13
  "Delete_image": "delete image",
14
14
  "Download_image": "Download image",
15
- "Pre_Line": "previous Line",
16
- "Next_Line": "next Line",
15
+ "Previous_record": "Enregistrement précédent",
16
+ "Next_record": "Enregistrement suivant",
17
17
  "Zoom_in": "Zoom in",
18
18
  "Zoom_out": "Zoom out",
19
19
  "Choose_a_collaborator": "Choisissez un collaborateur",
@@ -12,8 +12,8 @@
12
12
  "Rotate_image": "Rotate image",
13
13
  "Delete_image": "delete image",
14
14
  "Download_image": "Download image",
15
- "Pre_Line": "previous Line",
16
- "Next_Line": "next Line",
15
+ "Previous_record": "Registro anterior",
16
+ "Next_record": "Próximo registro",
17
17
  "Zoom_in": "Zoom in",
18
18
  "Zoom_out": "Zoom out",
19
19
  "Choose_a_collaborator": "Choose a collaborator",
@@ -12,8 +12,8 @@
12
12
  "Rotate_image": "Rotate image",
13
13
  "Delete_image": "delete image",
14
14
  "Download_image": "Download image",
15
- "Pre_Line": "previous Line",
16
- "Next_Line": "next Line",
15
+ "Previous_record": "Предыдущая запись",
16
+ "Next_record": "Следующая запись",
17
17
  "Zoom_in": "Zoom in",
18
18
  "Zoom_out": "Zoom out",
19
19
  "Choose_a_collaborator": "Choose a collaborator",
@@ -12,8 +12,8 @@
12
12
  "Rotate_image": "旋转",
13
13
  "Delete_image": "删除",
14
14
  "Download_image": "下载",
15
- "Pre_Line": "上一行",
16
- "Next_Line": "下一行",
15
+ "Previous_record": "前一行",
16
+ "Next_record": "后一行",
17
17
  "Zoom_in": "放大",
18
18
  "Zoom_out": "缩小",
19
19
  "Choose_a_collaborator": "选择一个协作人",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-ui-component",
3
- "version": "6.0.124",
3
+ "version": "6.0.125nsk.1",
4
4
  "main": "./lib/index.js",
5
5
  "dependencies": {
6
6
  "@seafile/react-image-lightbox": "5.0.9",
@@ -1,86 +0,0 @@
1
- .dtable-customize-collaborator-select.dtable-select {
2
- position: unset;
3
- }
4
-
5
- .dtable-customize-collaborator-select .collaborator-avatar {
6
- width: 16px;
7
- height: 16px;
8
- transform: translateY(-1px);
9
- }
10
-
11
- .dtable-customize-collaborator-select .selected-option-show {
12
- width: calc(100% - 20px);
13
- height: 20px;
14
- }
15
-
16
- .dtable-customize-collaborator-select .selected-option {
17
- width: auto;
18
- overflow-x: auto;
19
- }
20
-
21
- .dtable-customize-collaborator-select .dtable-icon-down3 {
22
- margin-left: .5rem;
23
- }
24
-
25
- .dtable-customize-collaborator-select .option-collaborator {
26
- display: flex;
27
- }
28
-
29
- .dtable-customize-collaborator-select .collaborator-container {
30
- flex: 1 1;
31
- }
32
-
33
- .dtable-customize-collaborator-select .editor-list-delete .collaborator-container {
34
- flex: 1 1;
35
- display: inline;
36
- }
37
-
38
- .dtable-customize-collaborator-select .multiple-check-icon {
39
- display: inline-flex;
40
- width: 20px;
41
- text-align: center;
42
- }
43
-
44
- .dtable-customize-collaborator-select .collaborator-check-icon .dtable-icon-check-mark,
45
- .dtable-customize-collaborator-select .multiple-check-icon .dtable-icon-check-mark {
46
- font-size: 12px;
47
- color: #798d99;
48
- }
49
-
50
- .dtable-customize-collaborator-select.dtable-select .option-active,
51
- .dtable-customize-collaborator-select.dtable-select .option:hover {
52
- color: #212529;
53
- background-color: #f5f5f5;
54
- }
55
-
56
- .dtable-customize-collaborator-select.dtable-select .option.option-active .select-option-name {
57
- color: #212529;
58
- }
59
-
60
- .collaborator-select .option-group-content .collaborator,
61
- .dtable-customize-collaborator-select .option-group .option-group-content .collaborator {
62
- background: none;
63
- }
64
-
65
- .dtable-customize-collaborator-select .collaborator-avatar-container {
66
- width: 16px;
67
- }
68
-
69
- .dtable-customize-collaborator-select .option-group-content .remove-container {
70
- display: none;
71
- }
72
-
73
- .dtable-customize-collaborator-select .collaborator-container {
74
- display: flex;
75
- justify-content: space-between;
76
- }
77
-
78
- .collaborator-container .collaborator-name {
79
- margin-left: 5px;
80
- max-width: 200px;
81
- color: #212529;
82
- }
83
-
84
- .collaborator-select .option-group {
85
- max-height: fit-content;
86
- }
@@ -1,161 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
- var _react = _interopRequireWildcard(require("react"));
10
- var _classnames = _interopRequireDefault(require("classnames"));
11
- var _reactstrap = require("reactstrap");
12
- var _dtableUtils = require("dtable-utils");
13
- var _SelectOptionGroup = _interopRequireDefault(require("../SelectOptionGroup"));
14
- require("./index.css");
15
- var _jsxRuntime = require("react/jsx-runtime");
16
- class CollaboratorSelect extends _react.Component {
17
- constructor(props) {
18
- super(props);
19
- this.onSelectToggle = event => {
20
- event.preventDefault();
21
- /*
22
- if select is showing, click events do not need to be monitored by other click events,
23
- so it can be closed when other select is clicked.
24
- */
25
- if (this.state.isShowSelectOptions) event.nativeEvent.stopImmediatePropagation();
26
- let eventClassName = event.target.className;
27
- if (this.props.isLocked || eventClassName.indexOf('option-search-control') > -1 || eventClassName === 'option-group-search') return;
28
- // Prevent closing by pressing the spacebar in the search input
29
- if (event.target.value === '') return;
30
- this.selectedOptionWidth = this.selectedOptionRef.clientWidth;
31
- this.setState({
32
- isShowSelectOptions: !this.state.isShowSelectOptions
33
- });
34
- };
35
- this.onMousedown = event => {
36
- const name = event.target.className;
37
- if (name === 'select-placeholder' || name.includes('icon-fork-number')) {
38
- return;
39
- }
40
- if (!this.selector.contains(event.target)) {
41
- this.closeSelect();
42
- }
43
- };
44
- this.closeSelect = () => {
45
- this.setState({
46
- isShowSelectOptions: false
47
- });
48
- };
49
- this.getFilterOptions = searchValue => {
50
- const {
51
- options,
52
- searchable
53
- } = this.props;
54
- if (!searchable) return options || [];
55
- return (0, _dtableUtils.searchCollaborators)(options, searchValue);
56
- };
57
- this.renderOptionGroup = () => {
58
- const {
59
- value,
60
- options,
61
- searchable,
62
- searchPlaceholder,
63
- noOptionsPlaceholder,
64
- top,
65
- left,
66
- isUsePopover
67
- } = this.props;
68
- if (!isUsePopover) {
69
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_SelectOptionGroup.default, {
70
- value: value,
71
- top: top,
72
- left: left,
73
- minWidth: this.btnWidth + 8 // 8px is padding
74
- ,
75
- options: options,
76
- onSelectOption: this.props.onSelectOption,
77
- searchable: searchable,
78
- searchPlaceholder: searchPlaceholder,
79
- noOptionsPlaceholder: noOptionsPlaceholder,
80
- closeSelect: this.closeSelect,
81
- getFilterOptions: this.getFilterOptions,
82
- supportMultipleSelect: this.props.supportMultipleSelect,
83
- stopClickEvent: true,
84
- isShowSelected: true
85
- });
86
- }
87
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactstrap.Popover, {
88
- placement: "bottom",
89
- isOpen: true,
90
- target: this.id,
91
- fade: false,
92
- hideArrow: true,
93
- className: "dtable-customize-collaborator-select dtable-select",
94
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_SelectOptionGroup.default, {
95
- value: value,
96
- top: top,
97
- left: left,
98
- minWidth: this.btnWidth + 8 // 8px is padding
99
- ,
100
- options: options,
101
- onSelectOption: this.props.onSelectOption,
102
- searchable: searchable,
103
- searchPlaceholder: searchPlaceholder,
104
- noOptionsPlaceholder: noOptionsPlaceholder,
105
- closeSelect: this.closeSelect,
106
- getFilterOptions: this.getFilterOptions,
107
- supportMultipleSelect: this.props.supportMultipleSelect,
108
- stopClickEvent: true,
109
- isShowSelected: true
110
- })
111
- });
112
- };
113
- this.state = {
114
- isShowSelectOptions: false
115
- };
116
- this.id = 'collaborator-select-' + Math.trunc(Math.random() * 10000);
117
- }
118
- componentDidMount() {
119
- document.addEventListener('mousedown', this.onMousedown);
120
- this.btnWidth = this.selector.clientWidth;
121
- }
122
- componentWillUnmount() {
123
- document.removeEventListener('mousedown', this.onMousedown);
124
- }
125
- render() {
126
- let {
127
- className,
128
- value,
129
- placeholder,
130
- isLocked
131
- } = this.props;
132
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)("button", {
133
- ref: node => this.selector = node,
134
- className: (0, _classnames.default)('dtable-select custom-select collaborator-select', {
135
- 'focus': this.state.isShowSelectOptions
136
- }, {
137
- 'disabled': isLocked
138
- }, className),
139
- id: this.id,
140
- onClick: this.onSelectToggle,
141
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
142
- className: "selected-option",
143
- ref: node => this.selectedOptionRef = node,
144
- children: [value.label ? /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
145
- className: "selected-option-show",
146
- children: value.label
147
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
148
- className: "select-placeholder",
149
- children: placeholder
150
- }), !isLocked && /*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
151
- className: "dtable-font dtable-icon-down3"
152
- })]
153
- }), this.state.isShowSelectOptions && this.renderOptionGroup()]
154
- });
155
- }
156
- }
157
- CollaboratorSelect.defaultProps = {
158
- top: -3,
159
- left: -3
160
- };
161
- var _default = exports.default = CollaboratorSelect;
@@ -1,42 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
- var _react = _interopRequireWildcard(require("react"));
10
- var _classnames = _interopRequireDefault(require("classnames"));
11
- var _jsxRuntime = require("react/jsx-runtime");
12
- class Option extends _react.Component {
13
- constructor() {
14
- super(...arguments);
15
- this.onSelectOption = e => {
16
- e.stopPropagation();
17
- this.props.onSelectOption(this.props.option);
18
- };
19
- this.onMouseEnter = () => {
20
- if (!this.props.disableHover) {
21
- this.props.changeIndex(this.props.index);
22
- }
23
- };
24
- this.onMouseLeave = () => {
25
- if (!this.props.disableHover) {
26
- this.props.changeIndex(-1);
27
- }
28
- };
29
- }
30
- render() {
31
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
32
- className: (0, _classnames.default)('d-flex option', {
33
- 'option-active': this.props.isActive
34
- }),
35
- onClick: this.onSelectOption,
36
- onMouseEnter: this.onMouseEnter,
37
- onMouseLeave: this.onMouseLeave,
38
- children: this.props.children
39
- });
40
- }
41
- }
42
- var _default = exports.default = Option;