@steroidsjs/core 2.2.50 → 2.2.53

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/hooks/useFile.js CHANGED
@@ -54,21 +54,40 @@ function useFile(props) {
54
54
  }
55
55
  react_1.useEffect(function () {
56
56
  if (initialFiles) {
57
- uploader.queue.add([].concat(initialFiles || [])
58
- .filter(function (item) { return !!item.uid; })
59
- .map(function (item) { return new File_1["default"]({
60
- path: item.title || item.label || item.uid || item.id,
61
- status: File_1["default"].STATUS_END,
62
- result: File_1["default"].RESULT_SUCCESS,
63
- resultHttpStatus: 200,
64
- resultHttpMessage: {
57
+ var normalizedInitialFiles_1 = [].concat(initialFiles || [])
58
+ .filter(function (item) { return !!item.uid; });
59
+ // Remove not exists
60
+ var toDelete = uploader.queue.getFiles()
61
+ .filter(function (file) { return !normalizedInitialFiles_1.find(function (item) { return item.uid === file.getUid(); }); });
62
+ if (toDelete.length > 0) {
63
+ uploader.queue.remove(toDelete);
64
+ }
65
+ // Add or update
66
+ uploader.queue.add(normalizedInitialFiles_1
67
+ .map(function (item) {
68
+ var path = item.title || item.label || item.uid || item.id;
69
+ var resultHttpMessage = {
65
70
  id: item.id || item.uid,
66
71
  images: item.thumbnailUrl
67
72
  ? [{ url: item.thumbnailUrl }]
68
73
  : null
69
- },
70
- uid: item.uid
71
- }); }));
74
+ };
75
+ var file = uploader.queue.getByUid(item.uid);
76
+ if (file) {
77
+ file.setPath(path);
78
+ file.setResultHttpMessage(resultHttpMessage);
79
+ return false;
80
+ }
81
+ return new File_1["default"]({
82
+ path: path,
83
+ status: File_1["default"].STATUS_END,
84
+ result: File_1["default"].RESULT_SUCCESS,
85
+ resultHttpStatus: 200,
86
+ resultHttpMessage: resultHttpMessage,
87
+ uid: item.uid
88
+ });
89
+ })
90
+ .filter(Boolean));
72
91
  forceUpdate();
73
92
  }
74
93
  // eslint-disable-next-line react-hooks/exhaustive-deps
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steroidsjs/core",
3
- "version": "2.2.50",
3
+ "version": "2.2.53",
4
4
  "description": "",
5
5
  "author": "Vladimir Kozhin <hello@kozhindev.com>",
6
6
  "repository": {
@@ -39,6 +39,7 @@ declare namespace DropDown {
39
39
  defaultVisible: boolean;
40
40
  gap: number;
41
41
  position: string;
42
+ closeMode: string;
42
43
  };
43
44
  }
44
45
  export default DropDown;
@@ -46,13 +46,15 @@ function DropDown(props) {
46
46
  onHide();
47
47
  }
48
48
  }
49
- });
49
+ }, ['mousedown', 'touchstart']);
50
50
  // Any click -> close
51
- react_use_1.useEvent('click', react_1.useCallback(function () {
51
+ var onAnyClick = react_1.useCallback(function () {
52
52
  if (isComponentExist && isComponentVisible && props.closeMode === 'click-any') {
53
53
  onHide();
54
54
  }
55
- }, [isComponentExist, isComponentVisible, onHide, props.closeMode]));
55
+ }, [isComponentExist, isComponentVisible, onHide, props.closeMode]);
56
+ react_use_1.useEvent('mousedown', onAnyClick);
57
+ react_use_1.useEvent('touchstart', onAnyClick);
56
58
  var calculatePosition = react_1.useCallback(function (componentSize) {
57
59
  calculateAbsolutePosition(position, childRef.current, componentSize);
58
60
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -83,6 +85,7 @@ DropDown.defaultProps = {
83
85
  componentDestroyDelay: 300,
84
86
  defaultVisible: false,
85
87
  gap: 15,
86
- position: 'bottom'
88
+ position: 'bottom',
89
+ closeMode: 'click-away'
87
90
  };
88
91
  exports["default"] = DropDown;