dtable-ui-component 6.0.98 → 6.0.100

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.
@@ -59,15 +59,18 @@ class ClickOutside extends _react.default.Component {
59
59
  constructor() {
60
60
  super(...arguments);
61
61
  this.isClickedInside = false;
62
+ this.setClickedInsideStatus = status => {
63
+ this.isClickedInside = status || false;
64
+ };
62
65
  this.handleDocumentClick = e => {
63
66
  if (this.isClickedInside) {
64
- this.isClickedInside = false;
67
+ this.setClickedInsideStatus(false);
65
68
  return;
66
69
  }
67
70
  this.props.onClickOutside(e);
68
71
  };
69
72
  this.handleMouseDown = () => {
70
- this.isClickedInside = true;
73
+ this.setClickedInsideStatus(true);
71
74
  };
72
75
  }
73
76
  componentDidMount() {
@@ -143,29 +143,35 @@ class FileUploader extends _react.default.Component {
143
143
  });
144
144
  }
145
145
  try {
146
- let fileReader = new FileReader();
147
- fileReader.readAsDataURL(file);
148
- fileReader.addEventListener('load', function (event) {
149
- let isImage = /image/i.test(file.type);
150
- if (uploadType === 'file' || isImage) {
151
- let uploadFileItem = {
152
- name: file.name,
153
- fileIconUrl: isImage ? event.target.result : (0, _url.getFileIconUrl)(file.name, file.type),
154
- isUploading: true,
155
- isErrorTip: false,
156
- file: file,
157
- size: file.size,
158
- url: '',
159
- type: uploadType === 'file' ? 'file' : '',
160
- percent: 0
161
- };
146
+ let isImage = /image/i.test(uploadFile.type);
147
+ let uploadFileItem = {
148
+ name: uploadFile.name,
149
+ fileIconUrl: (0, _url.getFileIconUrl)(uploadFile.name),
150
+ isUploading: true,
151
+ isErrorTip: false,
152
+ uploadFile: uploadFile,
153
+ size: uploadFile.size,
154
+ url: '',
155
+ type: uploadType === 'file' ? 'file' : '',
156
+ percent: 0
157
+ };
158
+
159
+ // Provide preview when the image size is less than 100MB
160
+ if (isImage && uploadFile.size < 100 * 1024 * 1024) {
161
+ let fileReader = new FileReader();
162
+ fileReader.readAsDataURL(uploadFile);
163
+ fileReader.onload = function (event) {
164
+ uploadFileItem.fileIconUrl = event.target.result;
162
165
  uploadFileList.push(uploadFileItem);
163
- }
164
- checkLoadFinish();
165
- }, false);
166
- fileReader.addEventListener('error', function (e) {
166
+ checkLoadFinish();
167
+ };
168
+ fileReader.onerror = function () {
169
+ checkLoadFinish();
170
+ };
171
+ } else {
172
+ uploadFileList.push(uploadFileItem);
167
173
  checkLoadFinish();
168
- }, false);
174
+ }
169
175
  } catch (event) {
170
176
  checkLoadFinish();
171
177
  }
@@ -26,12 +26,16 @@ class SelectOptionGroup extends _react.Component {
26
26
  } = this.props;
27
27
  const {
28
28
  top,
29
- height
29
+ height,
30
+ width
30
31
  } = this.optionGroupRef.getBoundingClientRect();
31
32
  if (isInModal) {
32
33
  if (position.y + position.height + height > window.innerHeight) {
33
34
  this.optionGroupRef.style.top = position.y - height + 'px';
34
35
  }
36
+ if (position && position.x + width > window.innerWidth) {
37
+ this.optionGroupRef.style.left = window.innerWidth - width - 10 + 'px';
38
+ }
35
39
  this.optionGroupRef.style.opacity = 1;
36
40
  this.searchInputRef.current && this.searchInputRef.current.inputRef.focus();
37
41
  } else {
@@ -85,6 +89,10 @@ class SelectOptionGroup extends _react.Component {
85
89
  if (isInModal) {
86
90
  e.stopPropagation();
87
91
  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);
88
96
  }
89
97
  };
90
98
  this.scrollContent = () => {
@@ -213,6 +221,7 @@ class SelectOptionGroup extends _react.Component {
213
221
  };
214
222
  }
215
223
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ClickOutside.default, {
224
+ ref: ref => this.clickOutsideRef = ref,
216
225
  onClickOutside: this.props.onClickOutside,
217
226
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
218
227
  className: (0, _classnames.default)('option-group', className ? 'option-group-' + className : '', {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-ui-component",
3
- "version": "6.0.98",
3
+ "version": "6.0.100",
4
4
  "main": "./lib/index.js",
5
5
  "dependencies": {
6
6
  "@seafile/react-image-lightbox": "4.0.2",