@dreamcommerce/aurora 2.8.1-33 → 2.8.1-35
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/cjs/packages/aurora/src/components/file_picker/use_file_picker.js +14 -0
- package/build/cjs/packages/aurora/src/components/file_picker/use_file_picker.js.map +1 -1
- package/build/cjs/packages/aurora/src/components/image_picker/index.js +1 -3
- package/build/cjs/packages/aurora/src/components/image_picker/index.js.map +1 -1
- package/build/esm/packages/aurora/src/components/file_picker/types.d.ts +5 -1
- package/build/esm/packages/aurora/src/components/file_picker/types.js +1 -1
- package/build/esm/packages/aurora/src/components/file_picker/types.js.map +1 -1
- package/build/esm/packages/aurora/src/components/file_picker/use_file_picker.js +14 -0
- package/build/esm/packages/aurora/src/components/file_picker/use_file_picker.js.map +1 -1
- package/build/esm/packages/aurora/src/components/image_picker/index.js +1 -3
- package/build/esm/packages/aurora/src/components/image_picker/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -11,12 +11,26 @@ const useFilePicker = ({ onChange, initialFile, allowedExtensions, inputRef, ini
|
|
|
11
11
|
const [errors, setErrors] = React.useState([]);
|
|
12
12
|
const [isDragOver, setDragOver] = React.useState(false);
|
|
13
13
|
const [isPreview, setPreview] = React.useState(true);
|
|
14
|
+
const [imageSize, setImageSize] = React.useState(undefined);
|
|
14
15
|
React.useEffect(() => {
|
|
15
16
|
setFile(initialFile);
|
|
17
|
+
initialFile &&
|
|
18
|
+
createImageFromUrl(initialFile === null || initialFile === void 0 ? void 0 : initialFile.fileUrl).then((image) => {
|
|
19
|
+
setImageSize({ width: image.naturalWidth, height: image.naturalHeight });
|
|
20
|
+
});
|
|
16
21
|
}, [initialFile]);
|
|
22
|
+
React.useEffect(() => {
|
|
23
|
+
console.log('imageSize', imageSize);
|
|
24
|
+
}, [imageSize]);
|
|
17
25
|
React.useEffect(() => {
|
|
18
26
|
initialErrors && setErrors(initialErrors);
|
|
19
27
|
}, [initialErrors]);
|
|
28
|
+
const createImageFromUrl = async (url) => {
|
|
29
|
+
const img = new Image();
|
|
30
|
+
img.src = url;
|
|
31
|
+
await img.decode();
|
|
32
|
+
return img;
|
|
33
|
+
};
|
|
20
34
|
const onDropFile = (event) => {
|
|
21
35
|
setErrors([]);
|
|
22
36
|
event.stopPropagation();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -32,7 +32,6 @@ const ImagePicker = React.memo(({ id, onChange, onError, errors: initialErrors,
|
|
|
32
32
|
const [t] = useTranslation.useTranslation();
|
|
33
33
|
const inputRef = React.createRef();
|
|
34
34
|
const [imageSize, setImageSize] = React.useState(undefined);
|
|
35
|
-
console.log('initialFile', initialFile);
|
|
36
35
|
const { onDropFile, onFileChange, onDragOver, onDragLeave, onFileDelete, onPreviewError, file, errors, isPreview, isDragOver } = use_file_picker.useFilePicker({ initialFile, onChange, allowedExtensions, initialErrors, onError, inputRef });
|
|
37
36
|
const acceptFiles = utils.getAcceptFilesParametersFromAllowedExtensions(allowedExtensions);
|
|
38
37
|
const imagePickerClassName = classnames__default['default'](main_module['default'][css_classes['default'].imagePicker], className && className);
|
|
@@ -74,8 +73,7 @@ const ImagePicker = React.memo(({ id, onChange, onError, errors: initialErrors,
|
|
|
74
73
|
var _a, _b, _c, _d;
|
|
75
74
|
return (((_a = prev.initialFile) === null || _a === void 0 ? void 0 : _a.fileUrl) === ((_b = curr.initialFile) === null || _b === void 0 ? void 0 : _b.fileUrl) &&
|
|
76
75
|
((_c = prev.initialFile) === null || _c === void 0 ? void 0 : _c.fileName) === ((_d = curr.initialFile) === null || _d === void 0 ? void 0 : _d.fileName) &&
|
|
77
|
-
prev.errors === curr.errors
|
|
78
|
-
prev.initialFile === curr.initialFile);
|
|
76
|
+
prev.errors === curr.errors);
|
|
79
77
|
});
|
|
80
78
|
|
|
81
79
|
exports.default = ImagePicker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,6BAA6B,iEAAqE;AAClG,2BAA2B,yDAA6D;AACxF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,6BAA6B,iEAAqE;AAClG,2BAA2B,yDAA6D;AACxF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import React, { ChangeEvent } from 'react';
|
|
2
1
|
import { FILES_EXTENSIONS, MIME_FILE_EXTENSIONS } from "./constants";
|
|
2
|
+
import React, { ChangeEvent } from 'react';
|
|
3
3
|
import { TControlErrors } from "../controls/types";
|
|
4
4
|
export declare type TFilePickerFile = {
|
|
5
5
|
fileUrl: string;
|
|
6
6
|
fileName: string;
|
|
7
7
|
};
|
|
8
|
+
export declare type TFilePickerImageSize = {
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
};
|
|
8
12
|
export interface IFilePicker {
|
|
9
13
|
id: string;
|
|
10
14
|
name?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../src/components/file_picker/types.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../src/components/file_picker/types.ts"],"names":[],"mappings":"AAAA,OAAuD,yCAAyC,CAAC;AACjG,OAAmC,OAAO,CAAC;AAE3C,OAA+B,kCAAkC,CAAC"}
|
|
@@ -7,12 +7,26 @@ const useFilePicker = ({ onChange, initialFile, allowedExtensions, inputRef, ini
|
|
|
7
7
|
const [errors, setErrors] = useState([]);
|
|
8
8
|
const [isDragOver, setDragOver] = useState(false);
|
|
9
9
|
const [isPreview, setPreview] = useState(true);
|
|
10
|
+
const [imageSize, setImageSize] = useState(undefined);
|
|
10
11
|
useEffect(() => {
|
|
11
12
|
setFile(initialFile);
|
|
13
|
+
initialFile &&
|
|
14
|
+
createImageFromUrl(initialFile === null || initialFile === void 0 ? void 0 : initialFile.fileUrl).then((image) => {
|
|
15
|
+
setImageSize({ width: image.naturalWidth, height: image.naturalHeight });
|
|
16
|
+
});
|
|
12
17
|
}, [initialFile]);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
console.log('imageSize', imageSize);
|
|
20
|
+
}, [imageSize]);
|
|
13
21
|
useEffect(() => {
|
|
14
22
|
initialErrors && setErrors(initialErrors);
|
|
15
23
|
}, [initialErrors]);
|
|
24
|
+
const createImageFromUrl = async (url) => {
|
|
25
|
+
const img = new Image();
|
|
26
|
+
img.src = url;
|
|
27
|
+
await img.decode();
|
|
28
|
+
return img;
|
|
29
|
+
};
|
|
16
30
|
const onDropFile = (event) => {
|
|
17
31
|
setErrors([]);
|
|
18
32
|
event.stopPropagation();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -23,7 +23,6 @@ const ImagePicker = memo(({ id, onChange, onError, errors: initialErrors, allowe
|
|
|
23
23
|
const [t] = useTranslation();
|
|
24
24
|
const inputRef = createRef();
|
|
25
25
|
const [imageSize, setImageSize] = useState(undefined);
|
|
26
|
-
console.log('initialFile', initialFile);
|
|
27
26
|
const { onDropFile, onFileChange, onDragOver, onDragLeave, onFileDelete, onPreviewError, file, errors, isPreview, isDragOver } = useFilePicker({ initialFile, onChange, allowedExtensions, initialErrors, onError, inputRef });
|
|
28
27
|
const acceptFiles = getAcceptFilesParametersFromAllowedExtensions(allowedExtensions);
|
|
29
28
|
const imagePickerClassName = classnames(styles[CSS_CLASSES.imagePicker], className && className);
|
|
@@ -65,8 +64,7 @@ const ImagePicker = memo(({ id, onChange, onError, errors: initialErrors, allowe
|
|
|
65
64
|
var _a, _b, _c, _d;
|
|
66
65
|
return (((_a = prev.initialFile) === null || _a === void 0 ? void 0 : _a.fileUrl) === ((_b = curr.initialFile) === null || _b === void 0 ? void 0 : _b.fileUrl) &&
|
|
67
66
|
((_c = prev.initialFile) === null || _c === void 0 ? void 0 : _c.fileName) === ((_d = curr.initialFile) === null || _d === void 0 ? void 0 : _d.fileName) &&
|
|
68
|
-
prev.errors === curr.errors
|
|
69
|
-
prev.initialFile === curr.initialFile);
|
|
67
|
+
prev.errors === curr.errors);
|
|
70
68
|
});
|
|
71
69
|
|
|
72
70
|
export default ImagePicker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA,+BAA+B,iEAAqE;AACpG,gCAAgC,yDAA6D;AAC7F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA,+BAA+B,iEAAqE;AACpG,gCAAgC,yDAA6D;AAC7F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|