@mamrp/components 1.7.59 → 1.7.61
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/dist/index.js +29 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -12
- package/dist/index.mjs.map +1 -1
- package/dist/selectors/index.js +5 -1
- package/dist/selectors/index.js.map +1 -1
- package/dist/selectors/index.mjs +5 -1
- package/dist/selectors/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -3744,6 +3744,23 @@ function ImageViewer({
|
|
|
3744
3744
|
}
|
|
3745
3745
|
|
|
3746
3746
|
// src/enhanced-upload-image/index.tsx
|
|
3747
|
+
var import_heic2any = __toESM(require("heic2any"));
|
|
3748
|
+
var isHeic = (file) => file.type === "image/heic" || file.type === "image/heif" || file.name.toLowerCase().endsWith(".heic") || file.name.toLowerCase().endsWith(".heif");
|
|
3749
|
+
var convertHeicToJpeg = async (file) => {
|
|
3750
|
+
const convertedBlob = await (0, import_heic2any.default)({
|
|
3751
|
+
blob: file,
|
|
3752
|
+
toType: "image/jpeg",
|
|
3753
|
+
quality: 0.9
|
|
3754
|
+
});
|
|
3755
|
+
return new File(
|
|
3756
|
+
[convertedBlob],
|
|
3757
|
+
file.name.replace(/\.(heic|heif)$/i, ".jpg"),
|
|
3758
|
+
{
|
|
3759
|
+
type: "image/jpeg",
|
|
3760
|
+
lastModified: Date.now()
|
|
3761
|
+
}
|
|
3762
|
+
);
|
|
3763
|
+
};
|
|
3747
3764
|
var UploadImage = ({
|
|
3748
3765
|
placeholder,
|
|
3749
3766
|
name,
|
|
@@ -3805,20 +3822,20 @@ var UploadImage = ({
|
|
|
3805
3822
|
});
|
|
3806
3823
|
};
|
|
3807
3824
|
const handleImageChange = async (event) => {
|
|
3808
|
-
|
|
3809
|
-
if (file)
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
(compressedFile.size / 1024).toFixed(2)
|
|
3816
|
-
);
|
|
3817
|
-
const objectURL = URL.createObjectURL(compressedFile);
|
|
3818
|
-
setSelectedImage(objectURL);
|
|
3819
|
-
setValue(name, compressedFile);
|
|
3825
|
+
let file = event.target.files?.[0];
|
|
3826
|
+
if (!file) return;
|
|
3827
|
+
if (isHeic(file)) {
|
|
3828
|
+
try {
|
|
3829
|
+
file = await convertHeicToJpeg(file);
|
|
3830
|
+
} catch (e) {
|
|
3831
|
+
return;
|
|
3820
3832
|
}
|
|
3821
3833
|
}
|
|
3834
|
+
const compressedFile = await compressImage(file);
|
|
3835
|
+
if (!compressedFile) return;
|
|
3836
|
+
const objectURL = URL.createObjectURL(compressedFile);
|
|
3837
|
+
setSelectedImage(objectURL);
|
|
3838
|
+
setValue(name, compressedFile);
|
|
3822
3839
|
};
|
|
3823
3840
|
const handleRemoveImage = () => {
|
|
3824
3841
|
setSelectedImage(null);
|