@nyris/nyris-webapp 0.3.74 → 0.3.76
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/build/asset-manifest.json +3 -3
- package/build/index.html +1 -1
- package/build/static/js/{main.f6a2972e.js → main.50e54cc4.js} +3 -3
- package/build/static/js/{main.f6a2972e.js.map → main.50e54cc4.js.map} +1 -1
- package/package.json +3 -3
- package/src/components/DragDropFile.tsx +7 -6
- package/src/components/Product/Product.tsx +1 -1
- package/src/hooks/useDragAndDrop.ts +29 -4
- /package/build/static/js/{main.f6a2972e.js.LICENSE.txt → main.50e54cc4.js.LICENSE.txt} +0 -0
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nyris/nyris-webapp",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.76",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@auth0/auth0-react": "^2.2.4",
|
|
6
6
|
"@emailjs/browser": "^4.3.3",
|
|
7
|
-
"@nyris/nyris-api": "^0.3.
|
|
8
|
-
"@nyris/nyris-react-components": "^0.3.
|
|
7
|
+
"@nyris/nyris-api": "^0.3.76",
|
|
8
|
+
"@nyris/nyris-react-components": "^0.3.76",
|
|
9
9
|
"@radix-ui/react-accordion": "^1.2.2",
|
|
10
10
|
"@radix-ui/react-dialog": "^1.1.4",
|
|
11
11
|
"@radix-ui/react-popover": "^1.1.4",
|
|
@@ -24,12 +24,12 @@ function DragDropFile(props: Props) {
|
|
|
24
24
|
const { singleImageSearch } = useImageSearch();
|
|
25
25
|
const { cadSearch } = useCadSearch();
|
|
26
26
|
|
|
27
|
-
const handleUpload = (
|
|
27
|
+
const handleUpload = (file: File) => {
|
|
28
28
|
navigate('/result');
|
|
29
29
|
|
|
30
|
-
if (isCadFile(
|
|
30
|
+
if (isCadFile(file)) {
|
|
31
31
|
cadSearch({
|
|
32
|
-
file:
|
|
32
|
+
file: file,
|
|
33
33
|
settings: window.settings,
|
|
34
34
|
newSearch: true,
|
|
35
35
|
}).then(res => {});
|
|
@@ -38,7 +38,7 @@ function DragDropFile(props: Props) {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
singleImageSearch({
|
|
41
|
-
image:
|
|
41
|
+
image: file,
|
|
42
42
|
settings: window.settings,
|
|
43
43
|
showFeedback: true,
|
|
44
44
|
}).then(() => {});
|
|
@@ -78,9 +78,10 @@ function DragDropFile(props: Props) {
|
|
|
78
78
|
</div>
|
|
79
79
|
<input
|
|
80
80
|
onChange={e => {
|
|
81
|
+
console.log({ e });
|
|
81
82
|
e.stopPropagation();
|
|
82
|
-
if (e.target.files) {
|
|
83
|
-
handleUpload(
|
|
83
|
+
if (e.target.files && e.target.files[0]) {
|
|
84
|
+
handleUpload(e.target.files[0]);
|
|
84
85
|
e.target.value = '';
|
|
85
86
|
}
|
|
86
87
|
}}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useState, useCallback } from 'react';
|
|
2
2
|
|
|
3
3
|
interface UseDragAndDropOptions {
|
|
4
|
-
onDropCallback?: (
|
|
4
|
+
onDropCallback?: (file: File) => void;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
interface UseDragAndDropReturn {
|
|
@@ -13,6 +13,23 @@ interface UseDragAndDropReturn {
|
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
const getImageFromUrl = async (
|
|
17
|
+
url: string,
|
|
18
|
+
onDownload: (file: File) => void,
|
|
19
|
+
) => {
|
|
20
|
+
try {
|
|
21
|
+
const response = await fetch(url);
|
|
22
|
+
const blob = await response.blob();
|
|
23
|
+
const file = new File([blob], 'image.png', { type: blob.type });
|
|
24
|
+
// URL.createObjectURL(file);
|
|
25
|
+
if (onDownload) {
|
|
26
|
+
onDownload(file);
|
|
27
|
+
}
|
|
28
|
+
} catch (err) {
|
|
29
|
+
console.error('Failed to fetch image:', err);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
16
33
|
const useDragAndDrop = ({
|
|
17
34
|
onDropCallback,
|
|
18
35
|
}: UseDragAndDropOptions = {}): UseDragAndDropReturn => {
|
|
@@ -29,13 +46,21 @@ const useDragAndDrop = ({
|
|
|
29
46
|
}, []);
|
|
30
47
|
|
|
31
48
|
const onDrop = useCallback(
|
|
32
|
-
(event: React.DragEvent) => {
|
|
49
|
+
async (event: React.DragEvent) => {
|
|
33
50
|
event.preventDefault();
|
|
34
51
|
setIsDragging(false);
|
|
35
52
|
|
|
36
|
-
const
|
|
53
|
+
const url =
|
|
54
|
+
event.dataTransfer.getData('text/uri-list') ||
|
|
55
|
+
event.dataTransfer.getData('text/plain');
|
|
56
|
+
|
|
57
|
+
if (url && url.startsWith('http') && onDropCallback) {
|
|
58
|
+
getImageFromUrl(url, onDropCallback);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
37
62
|
if (onDropCallback) {
|
|
38
|
-
onDropCallback(
|
|
63
|
+
onDropCallback(event.dataTransfer.files[0]);
|
|
39
64
|
}
|
|
40
65
|
},
|
|
41
66
|
[onDropCallback],
|
|
File without changes
|