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.d.ts CHANGED
@@ -73,6 +73,7 @@ interface AttachedPhoto {
73
73
  name?: string;
74
74
  }
75
75
  interface cameraOptions {
76
+ initData?: Omit<AttachedPhoto, 'id'>[];
76
77
  show: boolean;
77
78
  type: cameraItemType;
78
79
  onChange: (file: File) => void;
@@ -88,12 +89,13 @@ interface cameraOptions {
88
89
  }
89
90
  type cameraItemType = 'single' | 'multiple' | 'linear';
90
91
 
91
- declare function useCamera({ onChange, resize: resizeOption, cameraOnly, onDelete, show, type, buttonText }?: Partial<cameraOptions>): {
92
+ declare function useCamera({ onChange, resize: resizeOption, cameraOnly, onDelete, show, type, buttonText, initData }?: Partial<cameraOptions>): {
92
93
  onClick: () => void;
93
94
  getImage: (imageId: string) => AttachedPhoto | undefined;
94
95
  deleteImage: (imageId: string) => void;
95
96
  attachedPhotos: AttachedPhoto[];
96
97
  Attachment: () => react_jsx_runtime.JSX.Element;
98
+ addImage: (data: Blob | string, name?: string) => void;
97
99
  };
98
100
 
99
101
  /**
package/dist/index.esm.js CHANGED
@@ -8,7 +8,7 @@ import styles from './modal/standard/address-search/select-address.module.scss';
8
8
  import styles$1 from './modal/standard/bank-stock-search/bank-stock-search-modal.module.scss';
9
9
  import styles$2 from './modal/standard/customer-search/customer-search.module.scss';
10
10
  import styles$3 from './modal/standard/nationality-search/select-nationality.module.scss';
11
- import { isClient, getE2EDataIDs, loadScript, initASTX2, MessageEventManager } from 'sales-frontend-utils';
11
+ import { isClient, getE2EDataIDs, loadScript, initASTX2, base64ToBlob, MessageEventManager } from 'sales-frontend-utils';
12
12
  import styles$4 from './modal/standard/visa-search/select-visa.module.scss';
13
13
  import { useQuery } from '@tanstack/react-query';
14
14
  import styles$5 from './modal/pre-standard/dea-customer-search-modal/dea-customer-search-modal.module.scss';
@@ -3512,9 +3512,11 @@ function useCamera({
3512
3512
  onDelete,
3513
3513
  show,
3514
3514
  type = "multiple",
3515
- buttonText
3515
+ buttonText,
3516
+ initData
3516
3517
  } = {}) {
3517
- const [attachedPhotos, setAttachedPhotos] = useState([]);
3518
+ const convertedInitData = initData?.map((data, index) => ({ ...data, id: String(index + 1) }));
3519
+ const [attachedPhotos, setAttachedPhotos] = useState(convertedInitData || []);
3518
3520
  const findImage = (imageId) => {
3519
3521
  return attachedPhotos.find((image) => image.id === imageId);
3520
3522
  };
@@ -3583,7 +3585,21 @@ function useCamera({
3583
3585
  getImage: findImage,
3584
3586
  deleteImage,
3585
3587
  attachedPhotos,
3586
- Attachment: CameraComponent
3588
+ Attachment: CameraComponent,
3589
+ addImage: (data, name) => {
3590
+ let blobUrl = "";
3591
+ if (data instanceof Blob) {
3592
+ blobUrl = URL.createObjectURL(data);
3593
+ } else if (typeof data === "string") {
3594
+ blobUrl = URL.createObjectURL(base64ToBlob(data));
3595
+ }
3596
+ const newPhoto = {
3597
+ id: genImageId(),
3598
+ src: blobUrl,
3599
+ name: name || `\uC11C\uB958\uC0AC\uC9C4_${attachedPhotos.length + 1}`
3600
+ };
3601
+ setAttachedPhotos([...attachedPhotos, newPhoto]);
3602
+ }
3587
3603
  };
3588
3604
  }
3589
3605