sales-frontend-components 0.0.121 → 0.0.123

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
  /**
@@ -264,6 +266,9 @@ declare function useSearchNationality({ setValue, onClose, isOpen }: Props$2): {
264
266
  setSearchInput: React__default.Dispatch<React__default.SetStateAction<string>>;
265
267
  };
266
268
  declare const useNationalityComponent: () => {
269
+ isOpen: boolean;
270
+ closeModal: () => void;
271
+ setNationality: React__default.Dispatch<React__default.SetStateAction<NationalityResponseDto | undefined>>;
267
272
  nationality: NationalityResponseDto | undefined;
268
273
  openModal: () => void;
269
274
  NationalitySearchComponent: () => react_jsx_runtime.JSX.Element;
@@ -388,6 +393,9 @@ declare const useVisaComponent: () => {
388
393
  visa: VisaStatusResponseDto | undefined;
389
394
  openModal: () => void;
390
395
  VisaSearchComponent: () => react_jsx_runtime.JSX.Element;
396
+ isOpen: boolean;
397
+ closeModal: () => void;
398
+ setVisa: React__default.Dispatch<React__default.SetStateAction<VisaStatusResponseDto | undefined>>;
391
399
  };
392
400
 
393
401
  interface DeaCustomerSearchModalProps {
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';
@@ -1390,6 +1390,9 @@ const useNationalityComponent = () => {
1390
1390
  const { isOpen, closeModal, openModal } = useModalState();
1391
1391
  const NationalitySearchComponent = () => /* @__PURE__ */ jsx(NationalityComponent, { isOpen, onClose: closeModal, setValue: setNationality });
1392
1392
  return {
1393
+ isOpen,
1394
+ closeModal,
1395
+ setNationality,
1393
1396
  nationality,
1394
1397
  openModal,
1395
1398
  NationalitySearchComponent
@@ -1803,7 +1806,10 @@ const useVisaComponent = () => {
1803
1806
  return {
1804
1807
  visa,
1805
1808
  openModal,
1806
- VisaSearchComponent
1809
+ VisaSearchComponent,
1810
+ isOpen,
1811
+ closeModal,
1812
+ setVisa
1807
1813
  };
1808
1814
  };
1809
1815
 
@@ -3512,9 +3518,11 @@ function useCamera({
3512
3518
  onDelete,
3513
3519
  show,
3514
3520
  type = "multiple",
3515
- buttonText
3521
+ buttonText,
3522
+ initData
3516
3523
  } = {}) {
3517
- const [attachedPhotos, setAttachedPhotos] = useState([]);
3524
+ const convertedInitData = initData?.map((data, index) => ({ ...data, id: String(index + 1) }));
3525
+ const [attachedPhotos, setAttachedPhotos] = useState(convertedInitData || []);
3518
3526
  const findImage = (imageId) => {
3519
3527
  return attachedPhotos.find((image) => image.id === imageId);
3520
3528
  };
@@ -3583,7 +3591,21 @@ function useCamera({
3583
3591
  getImage: findImage,
3584
3592
  deleteImage,
3585
3593
  attachedPhotos,
3586
- Attachment: CameraComponent
3594
+ Attachment: CameraComponent,
3595
+ addImage: (data, name) => {
3596
+ let blobUrl = "";
3597
+ if (data instanceof Blob) {
3598
+ blobUrl = URL.createObjectURL(data);
3599
+ } else if (typeof data === "string") {
3600
+ blobUrl = URL.createObjectURL(base64ToBlob(data));
3601
+ }
3602
+ const newPhoto = {
3603
+ id: genImageId(),
3604
+ src: blobUrl,
3605
+ name: name || `\uC11C\uB958\uC0AC\uC9C4_${attachedPhotos.length + 1}`
3606
+ };
3607
+ setAttachedPhotos([...attachedPhotos, newPhoto]);
3608
+ }
3587
3609
  };
3588
3610
  }
3589
3611