sales-frontend-components 0.0.120 → 0.0.122
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.cjs.js +19 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.esm.js +20 -4
- package/dist/index.esm.js.map +1 -1
- package/package.json +12 -12
package/dist/index.cjs.js
CHANGED
|
@@ -3514,9 +3514,11 @@ function useCamera({
|
|
|
3514
3514
|
onDelete,
|
|
3515
3515
|
show,
|
|
3516
3516
|
type = "multiple",
|
|
3517
|
-
buttonText
|
|
3517
|
+
buttonText,
|
|
3518
|
+
initData
|
|
3518
3519
|
} = {}) {
|
|
3519
|
-
const
|
|
3520
|
+
const convertedInitData = initData?.map((data, index) => ({ ...data, id: String(index + 1) }));
|
|
3521
|
+
const [attachedPhotos, setAttachedPhotos] = React.useState(convertedInitData || []);
|
|
3520
3522
|
const findImage = (imageId) => {
|
|
3521
3523
|
return attachedPhotos.find((image) => image.id === imageId);
|
|
3522
3524
|
};
|
|
@@ -3585,7 +3587,21 @@ function useCamera({
|
|
|
3585
3587
|
getImage: findImage,
|
|
3586
3588
|
deleteImage,
|
|
3587
3589
|
attachedPhotos,
|
|
3588
|
-
Attachment: CameraComponent
|
|
3590
|
+
Attachment: CameraComponent,
|
|
3591
|
+
addImage: (data, name) => {
|
|
3592
|
+
let blobUrl = "";
|
|
3593
|
+
if (data instanceof Blob) {
|
|
3594
|
+
blobUrl = URL.createObjectURL(data);
|
|
3595
|
+
} else if (typeof data === "string") {
|
|
3596
|
+
blobUrl = URL.createObjectURL(salesFrontendUtils.base64ToBlob(data));
|
|
3597
|
+
}
|
|
3598
|
+
const newPhoto = {
|
|
3599
|
+
id: genImageId(),
|
|
3600
|
+
src: blobUrl,
|
|
3601
|
+
name: name || `\uC11C\uB958\uC0AC\uC9C4_${attachedPhotos.length + 1}`
|
|
3602
|
+
};
|
|
3603
|
+
setAttachedPhotos([...attachedPhotos, newPhoto]);
|
|
3604
|
+
}
|
|
3589
3605
|
};
|
|
3590
3606
|
}
|
|
3591
3607
|
|