@mailstep/design-system 0.10.4 → 0.10.6
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/package.json
CHANGED
|
@@ -3,16 +3,22 @@ import { Container, HiddenInput } from "./styles.js";
|
|
|
3
3
|
import { useCallback } from "react";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
//#region packages/ui/Blocks/ImageList/components/AddPhoto/index.tsx
|
|
6
|
+
const IMAGE_MIME_PREFIX = "image/";
|
|
6
7
|
const AddPhoto = ({ onImageUpload, isDisabled, hasRemove }) => {
|
|
7
8
|
const handleImageUpload = useCallback((event) => {
|
|
8
|
-
|
|
9
|
+
const input = event.target;
|
|
10
|
+
const file = input?.files?.[0];
|
|
11
|
+
if (!file?.type.startsWith(IMAGE_MIME_PREFIX)) {
|
|
12
|
+
input.value = "";
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
9
15
|
const reader = new FileReader();
|
|
10
|
-
reader.readAsDataURL(
|
|
16
|
+
reader.readAsDataURL(file);
|
|
11
17
|
reader.onload = async () => {
|
|
12
18
|
await onImageUpload?.({
|
|
13
19
|
base64image: reader.result?.split(",").pop(),
|
|
14
20
|
base64WithDataDeclaration: reader.result,
|
|
15
|
-
file
|
|
21
|
+
file
|
|
16
22
|
});
|
|
17
23
|
};
|
|
18
24
|
}, [onImageUpload]);
|
|
@@ -24,7 +30,7 @@ const AddPhoto = ({ onImageUpload, isDisabled, hasRemove }) => {
|
|
|
24
30
|
disabled: isDisabled,
|
|
25
31
|
onChange: handleImageUpload,
|
|
26
32
|
type: "file",
|
|
27
|
-
accept: "image
|
|
33
|
+
accept: "image/*",
|
|
28
34
|
capture: "environment"
|
|
29
35
|
}), /* @__PURE__ */ jsx(AddPhoto$1, {
|
|
30
36
|
width: "36",
|