sales-frontend-components 0.0.144 → 0.0.145

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
@@ -587,5 +587,37 @@ declare function DudUpload(): react_jsx_runtime.JSX.Element;
587
587
 
588
588
  declare function DudDownload(): react_jsx_runtime.JSX.Element;
589
589
 
590
- export { Attachment, BankStockSearchModal, CODES, CustomerSearch, CustomerSearchModal, DeaCustomerSearchModal, DudDownload, DudUpload, EmployeeSearchModal, FormCheckbox, FormCheckboxButton, FormDatePicker, FormDateRangePicker, FormSearchJobField, FormSegmentGroup, FormSelect, FormTextField, JobVehicleSearchModal, OrganizationSearchModal, RIV_SEARCH_PARAM_MAP, StepIndicator, resize, testSignatureBase64Data, useAddressComponent, useBankStockSearch, useCamera, useCanvasPaint, useJobSearchModal, useJobVehicleSearchModal, useNationalityComponent, useNxlOneModal, useRemoteIdentityVerification, useRemoteIdentityVerificationIframe, useRemoteIdentityVerificationPopup, useSearchAddress, useSearchNationality, useSearchVisa, useVisaComponent };
591
- export type { AttachedPhoto, AttachmentProps, BankStockSearchModalProps, CodeSet, DownloadProps, FormSegmentGroupProps, NxlOneProps, NxlOneResponse, PaintProps, Pen, RemoteIdentityVerificationSuccess, RivUrlParams, Step, StepIndicatorProps, StepItem, UseRemoteIdentityVerificationProps, VerificationResponse, cameraItemType, cameraOptions };
590
+ /**
591
+ * @property downloadTarget - 다운로드 대상 주소 또는, 주소를 리턴하는 함수
592
+ * @property onSuccess - 다운로드 성공했을 때 호출
593
+ * @property onError - 다운로드 실패했을 때 호출
594
+ * @property fileName - 다운로드 파일명 , 없으면 자동생성
595
+ */
596
+ interface DownloadTargetInfo {
597
+ downloadTarget: string | (() => Promise<string>);
598
+ onSuccess?: () => void;
599
+ onError?: () => void;
600
+ fileName?: string;
601
+ }
602
+ /**
603
+ * @property downloadTargetInfo - 다운로드 대상 정보
604
+ * @property onAllSuccess - 모든 다운로드가 성공했을 때 호출
605
+ * @property onAnyError - 하나라도 실패했을 때 호출
606
+ * @property startIndex - 다운로드 시작 인덱스 또는 다운로드할 인덱스배열
607
+ * @property keepGoingOnError - 하나라도 실패했을 때도 계속 다운로드를 수행할지 여부
608
+ */
609
+ interface DownloaderProps {
610
+ downloadTargetInfo: DownloadTargetInfo[];
611
+ onAllSuccess?: () => void;
612
+ onAnyError?: () => void;
613
+ startIndex?: number | number[];
614
+ keepGoingOnError?: boolean;
615
+ }
616
+ declare const useDownloader: () => {
617
+ onClick: (downloaderProps: DownloaderProps) => Promise<number | number[] | undefined>;
618
+ isLoading: boolean;
619
+ isError: boolean;
620
+ };
621
+
622
+ export { Attachment, BankStockSearchModal, CODES, CustomerSearch, CustomerSearchModal, DeaCustomerSearchModal, DudDownload, DudUpload, EmployeeSearchModal, FormCheckbox, FormCheckboxButton, FormDatePicker, FormDateRangePicker, FormSearchJobField, FormSegmentGroup, FormSelect, FormTextField, JobVehicleSearchModal, OrganizationSearchModal, RIV_SEARCH_PARAM_MAP, StepIndicator, resize, testSignatureBase64Data, useAddressComponent, useBankStockSearch, useCamera, useCanvasPaint, useDownloader, useJobSearchModal, useJobVehicleSearchModal, useNationalityComponent, useNxlOneModal, useRemoteIdentityVerification, useRemoteIdentityVerificationIframe, useRemoteIdentityVerificationPopup, useSearchAddress, useSearchNationality, useSearchVisa, useVisaComponent };
623
+ export type { AttachedPhoto, AttachmentProps, BankStockSearchModalProps, CodeSet, DownloadProps, DownloadTargetInfo, DownloaderProps, FormSegmentGroupProps, NxlOneProps, NxlOneResponse, PaintProps, Pen, RemoteIdentityVerificationSuccess, RivUrlParams, Step, StepIndicatorProps, StepItem, UseRemoteIdentityVerificationProps, VerificationResponse, cameraItemType, cameraOptions };
package/dist/index.esm.js CHANGED
@@ -4420,5 +4420,87 @@ function DudDownload() {
4420
4420
  ] });
4421
4421
  }
4422
4422
 
4423
- export { Attachment, BankStockSearchModal, CODES, CustomerSearch, CustomerSearchModal, DeaCustomerSearchModal, DudDownload, DudUpload, EmployeeSearchModal, FormCheckbox, FormCheckboxButton, FormDatePicker, FormDateRangePicker, FormSearchJobField, FormSegmentGroup, FormSelect, FormTextField, JobVehicleSearchModal, OrganizationSearchModal, RIV_SEARCH_PARAM_MAP, StepIndicator, resize, testSignatureBase64Data, useAddressComponent, useBankStockSearch, useCamera, useCanvasPaint, useJobSearchModal, useJobVehicleSearchModal, useNationalityComponent, useNxlOneModal, useRemoteIdentityVerification, useRemoteIdentityVerificationIframe, useRemoteIdentityVerificationPopup, useSearchAddress, useSearchNationality, useSearchVisa, useVisaComponent };
4423
+ const useDownloader = () => {
4424
+ const [isError, setIsError] = useState(false);
4425
+ const [isLoading, setIsLoading] = useState(false);
4426
+ const downloadFile = async (url, fileName) => {
4427
+ try {
4428
+ const response = await fetch(url);
4429
+ if (!response.ok) {
4430
+ throw new Error(`Failed to download ${url}`);
4431
+ }
4432
+ const blob = await response.blob();
4433
+ const downloadUrl = window.URL.createObjectURL(blob);
4434
+ const a = document.createElement("a");
4435
+ a.href = downloadUrl;
4436
+ a.download = fileName || url.split("/").pop() || "download";
4437
+ document.body.appendChild(a);
4438
+ a.click();
4439
+ a.remove();
4440
+ window.URL.revokeObjectURL(downloadUrl);
4441
+ } catch (e) {
4442
+ console.error(e);
4443
+ throw e;
4444
+ }
4445
+ };
4446
+ const onClick = async (downloaderProps) => {
4447
+ const { downloadTargetInfo, onAllSuccess, onAnyError, startIndex = 0 } = downloaderProps;
4448
+ setIsLoading(true);
4449
+ setIsError(false);
4450
+ const failedIndex = [];
4451
+ const targetIndices = [];
4452
+ if (typeof startIndex === "number") {
4453
+ for (let i = startIndex; i < downloadTargetInfo.length; i++) {
4454
+ targetIndices.push(i);
4455
+ }
4456
+ } else if (Array.isArray(startIndex)) {
4457
+ for (let i = 0; i < downloadTargetInfo.length; i++) {
4458
+ if (startIndex.includes(i)) {
4459
+ targetIndices.push(i);
4460
+ }
4461
+ }
4462
+ }
4463
+ for (const i of targetIndices) {
4464
+ const info = downloadTargetInfo[i];
4465
+ if (!info) {
4466
+ continue;
4467
+ }
4468
+ try {
4469
+ let url;
4470
+ if (typeof info.downloadTarget === "function") {
4471
+ url = await info.downloadTarget();
4472
+ } else {
4473
+ url = info.downloadTarget;
4474
+ }
4475
+ if (!url) {
4476
+ throw new Error("Download URL is empty");
4477
+ }
4478
+ await downloadFile(url, info.fileName);
4479
+ info.onSuccess?.();
4480
+ } catch (error) {
4481
+ console.error(`Download failed at index ${i}`, error);
4482
+ info.onError?.();
4483
+ onAnyError?.();
4484
+ setIsError(true);
4485
+ failedIndex.push(i);
4486
+ if (downloaderProps.keepGoingOnError) {
4487
+ continue;
4488
+ }
4489
+ break;
4490
+ }
4491
+ }
4492
+ if (failedIndex.length === 0) {
4493
+ onAllSuccess?.();
4494
+ }
4495
+ setIsLoading(false);
4496
+ return failedIndex.length === 1 ? failedIndex[0] : failedIndex;
4497
+ };
4498
+ return {
4499
+ onClick,
4500
+ isLoading,
4501
+ isError
4502
+ };
4503
+ };
4504
+
4505
+ export { Attachment, BankStockSearchModal, CODES, CustomerSearch, CustomerSearchModal, DeaCustomerSearchModal, DudDownload, DudUpload, EmployeeSearchModal, FormCheckbox, FormCheckboxButton, FormDatePicker, FormDateRangePicker, FormSearchJobField, FormSegmentGroup, FormSelect, FormTextField, JobVehicleSearchModal, OrganizationSearchModal, RIV_SEARCH_PARAM_MAP, StepIndicator, resize, testSignatureBase64Data, useAddressComponent, useBankStockSearch, useCamera, useCanvasPaint, useDownloader, useJobSearchModal, useJobVehicleSearchModal, useNationalityComponent, useNxlOneModal, useRemoteIdentityVerification, useRemoteIdentityVerificationIframe, useRemoteIdentityVerificationPopup, useSearchAddress, useSearchNationality, useSearchVisa, useVisaComponent };
4424
4506
  //# sourceMappingURL=index.esm.js.map