@daeryun/dr_components 1.1.57 → 1.1.58

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.
Files changed (90) hide show
  1. package/dist/asset/images/myCase//bfileViewer/download.webp +0 -0
  2. package/dist/asset/images/myCase//bfileViewer/rotate_ccw.webp +0 -0
  3. package/dist/asset/images/myCase//bfileViewer/zoom_in.webp +0 -0
  4. package/dist/asset/images/myCase//bfileViewer/zoom_out.webp +0 -0
  5. package/dist/asset/images/myCase/icon/arrow.webp +0 -0
  6. package/dist/asset/images/myCase/icon/chat.webp +0 -0
  7. package/dist/asset/images/myCase/icon/check_ok.webp +0 -0
  8. package/dist/asset/images/myCase/icon/search.webp +0 -0
  9. package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
  10. package/dist/components/page/MyCase/[id]/_component/ContactInfo.jsx +1 -1
  11. package/dist/components/page/MyCase/[id]/_component/ContactInfo.tsx +1 -1
  12. package/dist/components/page/MyCase/[id]/_component/DetailInfo.jsx +1 -1
  13. package/dist/components/page/MyCase/[id]/_component/DetailInfo.tsx +9 -3
  14. package/dist/components/page/MyCase/[id]/_component/MyCaseDetailPageContainer.jsx +35 -14
  15. package/dist/components/page/MyCase/[id]/_component/MyCaseDetailPageContainer.tsx +19 -7
  16. package/dist/components/page/MyCase/[id]/_component/TimeLine.jsx +1 -1
  17. package/dist/components/page/MyCase/[id]/_component/TimeLine.tsx +1 -1
  18. package/dist/components/page/MyCase/[id]/_component/_badge/DocumentBadge.d.ts +4 -0
  19. package/dist/components/page/MyCase/[id]/_component/_badge/DocumentBadge.jsx +13 -0
  20. package/dist/components/page/MyCase/[id]/_component/_badge/DocumentBadge.tsx +18 -0
  21. package/dist/components/page/MyCase/[id]/_component/_caseInquiry/CaseInquiry.jsx +1 -1
  22. package/dist/components/page/MyCase/[id]/_component/_caseInquiry/CaseInquiry.tsx +1 -1
  23. package/dist/components/page/MyCase/[id]/_component/_document/Document.d.ts +2 -1
  24. package/dist/components/page/MyCase/[id]/_component/_document/Document.jsx +63 -21
  25. package/dist/components/page/MyCase/[id]/_component/_document/Document.tsx +97 -17
  26. package/dist/components/page/MyCase/[id]/_component/_document/DocumentLine.d.ts +2 -1
  27. package/dist/components/page/MyCase/[id]/_component/_document/DocumentLine.jsx +58 -13
  28. package/dist/components/page/MyCase/[id]/_component/_document/DocumentLine.tsx +124 -25
  29. package/dist/components/page/MyCase/[id]/_component/_document/FileDropZone.jsx +12 -7
  30. package/dist/components/page/MyCase/[id]/_component/_document/FileDropZone.tsx +12 -7
  31. package/dist/components/page/MyCase/[id]/_component/_modal/CaeeExamineAskSuccessModal.d.ts +5 -0
  32. package/dist/components/page/MyCase/[id]/_component/_modal/CaeeExamineAskSuccessModal.jsx +27 -0
  33. package/dist/components/page/MyCase/[id]/_component/_modal/CaeeExamineAskSuccessModal.tsx +46 -0
  34. package/dist/components/page/MyCase/[id]/_component/_modal/CaeeExamineStopModal.d.ts +6 -0
  35. package/dist/components/page/MyCase/[id]/_component/_modal/CaeeExamineStopModal.jsx +34 -0
  36. package/dist/components/page/MyCase/[id]/_component/_modal/CaeeExamineStopModal.tsx +65 -0
  37. package/dist/components/page/MyCase/[id]/_component/_modal/CaeeExamineSuccessModal.d.ts +5 -0
  38. package/dist/components/page/MyCase/[id]/_component/_modal/CaeeExamineSuccessModal.jsx +27 -0
  39. package/dist/components/page/MyCase/[id]/_component/_modal/CaeeExamineSuccessModal.tsx +47 -0
  40. package/dist/components/page/MyCase/[id]/_component/_modal/CaseExamineDocumentModal.d.ts +7 -0
  41. package/dist/components/page/MyCase/[id]/_component/_modal/CaseExamineDocumentModal.jsx +95 -0
  42. package/dist/components/page/MyCase/[id]/_component/_modal/CaseExamineDocumentModal.tsx +141 -0
  43. package/dist/components/page/MyCase/[id]/_component/_modal/CaseExamineModal.d.ts +10 -0
  44. package/dist/components/page/MyCase/[id]/_component/_modal/CaseExamineModal.jsx +149 -0
  45. package/dist/components/page/MyCase/[id]/_component/_modal/CaseExamineModal.tsx +212 -0
  46. package/dist/components/page/MyCase/[id]/_component/_modal/ContractModal.d.ts +3 -4
  47. package/dist/components/page/MyCase/[id]/_component/_modal/ContractModal.jsx +51 -34
  48. package/dist/components/page/MyCase/[id]/_component/_modal/ContractModal.tsx +88 -59
  49. package/dist/components/page/MyCase/[id]/_component/_modal/FileSuccessModal.jsx +2 -2
  50. package/dist/components/page/MyCase/[id]/_component/_modal/FileSuccessModal.tsx +2 -2
  51. package/dist/components/page/MyCase/[id]/_component/_pdf/PdfInlineViewer.d.ts +6 -0
  52. package/dist/components/page/MyCase/[id]/_component/_pdf/PdfInlineViewer.jsx +154 -0
  53. package/dist/components/page/MyCase/[id]/_component/_pdf/PdfInlineViewer.tsx +177 -0
  54. package/dist/components/page/MyCase/_actions/action.d.ts +34 -0
  55. package/dist/components/page/MyCase/_actions/action.js +59 -0
  56. package/dist/components/page/MyCase/_actions/action.ts +79 -0
  57. package/dist/components/page/MyCase/_component/_button/SubMenuButton.jsx +2 -4
  58. package/dist/components/page/MyCase/_component/_button/SubMenuButton.tsx +2 -5
  59. package/dist/components/page/MyCase/_component/_empty/EmptyTable.d.ts +2 -1
  60. package/dist/components/page/MyCase/_component/_empty/EmptyTable.jsx +14 -6
  61. package/dist/components/page/MyCase/_component/_empty/EmptyTable.tsx +34 -6
  62. package/dist/components/page/MyCase/_component/_fileView/FilePreViewer.d.ts +14 -0
  63. package/dist/components/page/MyCase/_component/_fileView/FilePreViewer.jsx +278 -0
  64. package/dist/components/page/MyCase/_component/_fileView/FilePreViewer.tsx +411 -0
  65. package/dist/components/page/MyCase/_component/_fileView/HwpViewer.d.ts +8 -0
  66. package/dist/components/page/MyCase/_component/_fileView/HwpViewer.jsx +56 -0
  67. package/dist/components/page/MyCase/_component/_fileView/HwpViewer.tsx +111 -0
  68. package/dist/components/page/MyCase/_component/_fileView/TopOverlay.d.ts +3 -0
  69. package/dist/components/page/MyCase/_component/_fileView/TopOverlay.jsx +10 -0
  70. package/dist/components/page/MyCase/_component/_fileView/TopOverlay.tsx +10 -0
  71. package/dist/components/page/MyCase/_component/_table/CaseTabSwiper.jsx +8 -3
  72. package/dist/components/page/MyCase/_component/_table/CaseTabSwiper.tsx +3 -4
  73. package/dist/components/page/MyCase/_fetchers/addMyCaseExamine.d.ts +7 -0
  74. package/dist/components/page/MyCase/_fetchers/addMyCaseExamine.js +34 -0
  75. package/dist/components/page/MyCase/_fetchers/addMyCaseExamine.ts +36 -0
  76. package/dist/components/page/MyCase/_fetchers/getDaeryunFileList.d.ts +5 -0
  77. package/dist/components/page/MyCase/_fetchers/getDaeryunFileList.js +33 -0
  78. package/dist/components/page/MyCase/_fetchers/getDaeryunFileList.ts +25 -0
  79. package/dist/components/page/MyCase/_fetchers/getDocumentExamineHistory.d.ts +5 -0
  80. package/dist/components/page/MyCase/_fetchers/getDocumentExamineHistory.js +33 -0
  81. package/dist/components/page/MyCase/_fetchers/getDocumentExamineHistory.ts +25 -0
  82. package/dist/components/page/MyCase/_fetchers/getHwpToPdfFile.d.ts +4 -0
  83. package/dist/components/page/MyCase/_fetchers/getHwpToPdfFile.js +33 -0
  84. package/dist/components/page/MyCase/_fetchers/getHwpToPdfFile.ts +25 -0
  85. package/dist/components/page/MyCase/_type/type.d.ts +3 -1
  86. package/dist/components/page/MyCase/_type/type.ts +3 -1
  87. package/dist/styles/globals.css +501 -94
  88. package/dist/styles/homepage_login.css +3 -3
  89. package/dist/tsconfig.tsbuildinfo +1 -1
  90. package/package.json +6 -2
@@ -1,39 +1,56 @@
1
+ 'use client';
1
2
  import Image from 'next/image';
2
3
  import ModalContainer from './ModalCotainer';
3
- import { useState } from 'react';
4
4
  import close from '../../../../../../asset/images/myCase/icon/close.webp';
5
- const ContractModal = ({ isOpen, onClose, data }) => {
6
- // const [value, setValue] = useState('');
7
- // const [isCheck, setIsCheck] = useState(false);
8
- const [isOpenConfirm, setIsOpenConfirm] = useState(false);
9
- // const { mutateAsync, isLoading } = actionPostMyCaseQuestion(id, value);
10
- // console.log(isLoading);
11
- return (<>
12
- <ModalContainer isOpen={isOpen} onClose={() => {
13
- onClose();
14
- }}>
15
- <div className="absolute flex h-full w-full flex-col overflow-y-hidden rounded-[16px] border border-solid border-grayScale4 bg-grayScale8 p-[32px] sm-top:rounded-[32px] sm-top:p-[52px] lg:h-full lg:max-h-[800px] lg:w-full lg:max-w-[1000px] " onClick={e => e.stopPropagation()}>
16
- <div className="flex flex-row items-center justify-between">
17
- <p className="title_medium_mo sm-top:title_medium_tb lg:title_medium text-black">내 약정서</p>
18
- <Image src={close} alt="close" width={24} height={24} onClick={() => {
19
- onClose();
20
- }} className="h-[16px] w-[16px] cursor-pointer sm-top:h-[20px] sm-top:w-[20px] lg:h-[24px] lg:w-[24px]"/>
21
- </div>
22
- <div className="mt-[12px] h-[453px] w-full overflow-y-auto rounded-[8px] border border-solid border-grayScale1 sm-top:mt-[20px] sm-top:h-[605px] lg:h-[calc(100%-62px)]">
23
- {data === null || data === void 0 ? void 0 : data.map((item, index) => (<div key={index}>
24
- <Image src={item.path} alt={item.name} width={3000} height={3000} unoptimized className="h-auto w-full"/>
25
- </div>))}
26
- </div>
5
+ import PdfInlineViewer from '../_pdf/PdfInlineViewer';
6
+ // pdfjs로 전체 펼쳐 렌더
7
+ const getExt = (name) => ((name === null || name === void 0 ? void 0 : name.split('.').pop()) || '').toLowerCase();
8
+ const isPdf = (name) => getExt(name) === 'pdf';
9
+ const isHwp = (name) => {
10
+ const ext = getExt(name);
11
+ return ext === 'hwp' || ext === 'hwpx';
12
+ };
13
+ export default function ContractModal({ isOpen, onClose, data }) {
14
+ return (<ModalContainer isOpen={isOpen} onClose={onClose}>
15
+ {/* 모달 전체가 스크롤(콘텐츠 섹션엔 고정 height/overflow 넣지 않음) */}
16
+ <div className="absolute flex h-full w-full flex-col overflow-y-auto rounded-[16px] border border-solid border-grayScale4 bg-grayScale8 pb-[32px]
17
+ sm-top:rounded-[32px] sm-top:pb-[52px]
18
+ lg:h-full lg:max-h-[800px] lg:w-full lg:max-w-[1000px]" onClick={e => e.stopPropagation()}>
19
+ <div className="sticky top-0 z-10 flex flex-row items-center justify-between bg-grayScale8/95 px-[32px] pb-[8px] pt-[40px] backdrop-blur sm-top:px-[52px] sm-top:pt-[40px]">
20
+ <p className="title_medium_mo sm-top:title_medium_tb lg:title_medium text-black">내 약정서</p>
21
+ <Image src={close} alt="close" width={24} height={24} onClick={onClose} className="h-[16px] w-[16px] cursor-pointer sm-top:h-[20px] sm-top:w-[20px] lg:h-[24px] lg:w-[24px]"/>
22
+ </div>
27
23
 
28
- {/* {isLoading ? (
29
- <div className="absolute top-[0] flex h-full w-full items-center justify-center">
30
- <Loading />
31
- </div>
32
- ) : (
33
- <></>
34
- )} */}
24
+ <div className="mx-auto mt-[12px] w-full max-w-[calc(100%-64px)] rounded-[8px] border border-solid border-grayScale1 p-0 sm-top:mt-[20px] sm-top:max-w-[calc(100%-104px)]">
25
+ <div className="space-y-6 p-3">
26
+ {data === null || data === void 0 ? void 0 : data.map((item, index) => {
27
+ var _a;
28
+ const key = `${item.path}-${index}`;
29
+ if (isPdf(item.name)) {
30
+ // ✅ PDF: 페이지가 캔버스로 “쭉 펼쳐짐”
31
+ return <PdfInlineViewer key={key} url={item.path} name={item.name}/>;
32
+ }
33
+ if (isHwp(item.name)) {
34
+ return (<div key={key} className="w-full overflow-hidden rounded-lg border border-dashed border-gray-300">
35
+ <div className="flex items-center justify-between px-3 py-2 text-sm">
36
+ <span className="truncate">{item.name}</span>
37
+ <a href={item.path} download className="underline">
38
+ 다운로드
39
+ </a>
40
+ </div>
41
+ <div className="px-3 pb-4 text-sm text-gray-600">
42
+ 이 형식(HWP/HWXP)은 웹 미리보기를 지원하지 않습니다. PDF/이미지 변환 또는
43
+ 한컴 웹 뷰어가 필요합니다.
44
+ </div>
45
+ </div>);
46
+ }
47
+ // 이미지 그대로
48
+ return (<div key={key} className="w-full overflow-hidden rounded-lg">
49
+ <Image src={item.path} alt={(_a = item.name) !== null && _a !== void 0 ? _a : 'image'} width={3000} height={3000} unoptimized className="block h-auto w-full"/>
50
+ </div>);
51
+ })}
52
+ </div>
35
53
  </div>
36
- </ModalContainer>
37
- </>);
38
- };
39
- export default ContractModal;
54
+ </div>
55
+ </ModalContainer>);
56
+ }
@@ -1,69 +1,98 @@
1
- import Image from 'next/image';
2
- import ModalContainer from './ModalCotainer';
1
+ 'use client';
3
2
 
4
- import { useState } from 'react';
3
+ import Image from 'next/image';
5
4
 
5
+ import ModalContainer from './ModalCotainer';
6
6
  import close from '../../../../../../asset/images/myCase/icon/close.webp';
7
- import { ContractImage } from '../../../_type/type';
7
+ import type { ContractImage } from '../../../_type/type';
8
+ import PdfInlineViewer from '../_pdf/PdfInlineViewer';
8
9
 
9
- const ContractModal = ({ isOpen, onClose, data }: { isOpen: boolean; onClose: () => void; data: ContractImage[] }) => {
10
- // const [value, setValue] = useState('');
11
- // const [isCheck, setIsCheck] = useState(false);
12
- const [isOpenConfirm, setIsOpenConfirm] = useState(false);
10
+ // pdfjs로 전체 펼쳐 렌더
13
11
 
14
- // const { mutateAsync, isLoading } = actionPostMyCaseQuestion(id, value);
15
- // console.log(isLoading);
12
+ const getExt = (name?: string) => (name?.split('.').pop() || '').toLowerCase();
13
+ const isPdf = (name?: string) => getExt(name) === 'pdf';
14
+ const isHwp = (name?: string) => {
15
+ const ext = getExt(name);
16
+ return ext === 'hwp' || ext === 'hwpx';
17
+ };
18
+
19
+ export default function ContractModal({
20
+ isOpen,
21
+ onClose,
22
+ data
23
+ }: {
24
+ isOpen: boolean;
25
+ onClose: () => void;
26
+ data: ContractImage[];
27
+ }) {
16
28
  return (
17
- <>
18
- <ModalContainer
19
- isOpen={isOpen}
20
- onClose={() => {
21
- onClose();
22
- }}
29
+ <ModalContainer isOpen={isOpen} onClose={onClose}>
30
+ {/* 모달 전체가 스크롤(콘텐츠 섹션엔 고정 height/overflow 넣지 않음) */}
31
+ <div
32
+ className="absolute flex h-full w-full flex-col overflow-y-auto rounded-[16px] border border-solid border-grayScale4 bg-grayScale8 pb-[32px]
33
+ sm-top:rounded-[32px] sm-top:pb-[52px]
34
+ lg:h-full lg:max-h-[800px] lg:w-full lg:max-w-[1000px]"
35
+ onClick={e => e.stopPropagation()}
23
36
  >
24
- <div
25
- className="absolute flex h-full w-full flex-col overflow-y-hidden rounded-[16px] border border-solid border-grayScale4 bg-grayScale8 p-[32px] sm-top:rounded-[32px] sm-top:p-[52px] lg:h-full lg:max-h-[800px] lg:w-full lg:max-w-[1000px] "
26
- onClick={e => e.stopPropagation()}
27
- >
28
- <div className="flex flex-row items-center justify-between">
29
- <p className="title_medium_mo sm-top:title_medium_tb lg:title_medium text-black">내 약정서</p>
30
- <Image
31
- src={close}
32
- alt="close"
33
- width={24}
34
- height={24}
35
- onClick={() => {
36
- onClose();
37
- }}
38
- className="h-[16px] w-[16px] cursor-pointer sm-top:h-[20px] sm-top:w-[20px] lg:h-[24px] lg:w-[24px]"
39
- />
40
- </div>
41
- <div className="mt-[12px] h-[453px] w-full overflow-y-auto rounded-[8px] border border-solid border-grayScale1 sm-top:mt-[20px] sm-top:h-[605px] lg:h-[calc(100%-62px)]">
42
- {data?.map((item, index) => (
43
- <div key={index}>
44
- <Image
45
- src={item.path}
46
- alt={item.name}
47
- width={3000}
48
- height={3000}
49
- unoptimized
50
- className="h-auto w-full"
51
- />
52
- </div>
53
- ))}
54
- </div>
37
+ <div className="sticky top-0 z-10 flex flex-row items-center justify-between bg-grayScale8/95 px-[32px] pb-[8px] pt-[40px] backdrop-blur sm-top:px-[52px] sm-top:pt-[40px]">
38
+ <p className="title_medium_mo sm-top:title_medium_tb lg:title_medium text-black">내 약정서</p>
39
+ <Image
40
+ src={close}
41
+ alt="close"
42
+ width={24}
43
+ height={24}
44
+ onClick={onClose}
45
+ className="h-[16px] w-[16px] cursor-pointer sm-top:h-[20px] sm-top:w-[20px] lg:h-[24px] lg:w-[24px]"
46
+ />
47
+ </div>
48
+
49
+ <div className="mx-auto mt-[12px] w-full max-w-[calc(100%-64px)] rounded-[8px] border border-solid border-grayScale1 p-0 sm-top:mt-[20px] sm-top:max-w-[calc(100%-104px)]">
50
+ <div className="space-y-6 p-3">
51
+ {data?.map((item, index) => {
52
+ const key = `${item.path}-${index}`;
53
+
54
+ if (isPdf(item.name)) {
55
+ // ✅ PDF: 페이지가 캔버스로 “쭉 펼쳐짐”
56
+ return <PdfInlineViewer key={key} url={item.path} name={item.name} />;
57
+ }
58
+
59
+ if (isHwp(item.name)) {
60
+ return (
61
+ <div
62
+ key={key}
63
+ className="w-full overflow-hidden rounded-lg border border-dashed border-gray-300"
64
+ >
65
+ <div className="flex items-center justify-between px-3 py-2 text-sm">
66
+ <span className="truncate">{item.name}</span>
67
+ <a href={item.path} download className="underline">
68
+ 다운로드
69
+ </a>
70
+ </div>
71
+ <div className="px-3 pb-4 text-sm text-gray-600">
72
+ 이 형식(HWP/HWXP)은 웹 미리보기를 지원하지 않습니다. PDF/이미지 변환 또는
73
+ 한컴 웹 뷰어가 필요합니다.
74
+ </div>
75
+ </div>
76
+ );
77
+ }
55
78
 
56
- {/* {isLoading ? (
57
- <div className="absolute top-[0] flex h-full w-full items-center justify-center">
58
- <Loading />
59
- </div>
60
- ) : (
61
- <></>
62
- )} */}
79
+ // 이미지 그대로
80
+ return (
81
+ <div key={key} className="w-full overflow-hidden rounded-lg">
82
+ <Image
83
+ src={item.path}
84
+ alt={item.name ?? 'image'}
85
+ width={3000}
86
+ height={3000}
87
+ unoptimized
88
+ className="block h-auto w-full"
89
+ />
90
+ </div>
91
+ );
92
+ })}
93
+ </div>
63
94
  </div>
64
- </ModalContainer>
65
- </>
95
+ </div>
96
+ </ModalContainer>
66
97
  );
67
- };
68
-
69
- export default ContractModal;
98
+ }
@@ -1,6 +1,6 @@
1
1
  import Image from 'next/image';
2
2
  import ModalContainer from './ModalCotainer';
3
- import modalCheck from '../../../../../../asset/images/myCase/icon/modal_icon.webp';
3
+ import modalCheck from '../../../../../../asset/images/myCase/icon/check_ok.webp';
4
4
  const CaseInquiryConfirmModal = ({ isOpen, onClose }) => {
5
5
  // console.log(isLoading);
6
6
  return (<ModalContainer isOpen={isOpen} onClose={() => {
@@ -9,7 +9,7 @@ const CaseInquiryConfirmModal = ({ isOpen, onClose }) => {
9
9
  <div className="absolute flex w-[calc(100%-40px)] flex-col items-center justify-center overflow-y-auto rounded-[12px] border border-solid border-grayScale4 bg-grayScale8 p-[30px] sm-top:w-[calc(100%-252px)] sm-top:max-w-[648px] sm-top:rounded-[24px] sm-top:px-[54px] sm-top:py-[44px] lg:w-full lg:max-w-[804px] lg:p-[52px] " onClick={e => e.stopPropagation()}>
10
10
  <Image src={modalCheck} alt="check" width={40} height={48.9} className="h-[48.9px] w-[40px] sm-top:h-[68.44px] sm-top:w-[56px] lg:h-[88px] lg:w-[72px]"/>
11
11
  <p className="body_large1_mo sm-top:body_large1_tb sm-top: lg:body_large1 mt-[20.11px] sm-top:mt-[48px] lg:mt-[60px]">
12
- 파일 제출이 완료되었습니다.
12
+ 문서 제출이 완료되었습니다.
13
13
  </p>
14
14
 
15
15
  <button className={`mt-[20px] h-[48px] w-full rounded-[4px] bg-grayScale1 sm-top:mt-[53px] sm-top:h-[60px] sm-top:rounded-[8px] lg:mt-[73px] lg:h-[72px] lg:rounded-[16px] `} onClick={() => {
@@ -1,6 +1,6 @@
1
1
  import Image from 'next/image';
2
2
  import ModalContainer from './ModalCotainer';
3
- import modalCheck from '../../../../../../asset/images/myCase/icon/modal_icon.webp';
3
+ import modalCheck from '../../../../../../asset/images/myCase/icon/check_ok.webp';
4
4
 
5
5
  const CaseInquiryConfirmModal = ({ isOpen, onClose }: { isOpen: boolean; onClose: () => void }) => {
6
6
  // console.log(isLoading);
@@ -23,7 +23,7 @@ const CaseInquiryConfirmModal = ({ isOpen, onClose }: { isOpen: boolean; onClose
23
23
  className="h-[48.9px] w-[40px] sm-top:h-[68.44px] sm-top:w-[56px] lg:h-[88px] lg:w-[72px]"
24
24
  />
25
25
  <p className="body_large1_mo sm-top:body_large1_tb sm-top: lg:body_large1 mt-[20.11px] sm-top:mt-[48px] lg:mt-[60px]">
26
- 파일 제출이 완료되었습니다.
26
+ 문서 제출이 완료되었습니다.
27
27
  </p>
28
28
 
29
29
  <button
@@ -0,0 +1,6 @@
1
+ type Props = {
2
+ url: string;
3
+ name?: string;
4
+ };
5
+ export default function PdfSpread({ url, name }: Props): import("react").JSX.Element;
6
+ export {};
@@ -0,0 +1,154 @@
1
+ 'use client';
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ import { useEffect, useRef, useState } from 'react';
12
+ import * as pdfjsLib from 'pdfjs-dist';
13
+ // pdf.js worker (pdfjs-dist 3.x)
14
+ pdfjsLib.GlobalWorkerOptions.workerSrc = 'https://unpkg.com/pdfjs-dist@3.11.174/build/pdf.worker.min.js';
15
+ export default function PdfSpread({ url, name }) {
16
+ const hostRef = useRef(null);
17
+ // 문서 객체
18
+ const pdfRef = useRef(null);
19
+ const [numPages, setNumPages] = useState(0);
20
+ // 컨테이너 폭 (ResizeObserver 사용)
21
+ const [width, setWidth] = useState(0);
22
+ const roRef = useRef(null);
23
+ // 페이지별 진행 중인 렌더 태스크 & 캔버스
24
+ const tasksRef = useRef(new Map());
25
+ const canvasesRef = useRef(new Map());
26
+ // 렌더 세션 토큰 (stale run 무시용)
27
+ const sessionRef = useRef(null);
28
+ // 컨테이너 폭 관찰
29
+ useEffect(() => {
30
+ const el = hostRef.current;
31
+ if (!el)
32
+ return;
33
+ const ro = new ResizeObserver(entries => {
34
+ for (const entry of entries) {
35
+ const cw = Math.floor(entry.contentRect.width);
36
+ if (cw && cw !== width)
37
+ setWidth(cw);
38
+ }
39
+ });
40
+ ro.observe(el);
41
+ roRef.current = ro;
42
+ // 초기 폭
43
+ setWidth(el.clientWidth);
44
+ return () => {
45
+ ro.disconnect();
46
+ roRef.current = null;
47
+ };
48
+ }, []);
49
+ // 문서 로드
50
+ useEffect(() => {
51
+ let cancelled = false;
52
+ // 이전 상태 정리
53
+ cancelAll();
54
+ clearHost();
55
+ setNumPages(0);
56
+ pdfRef.current = null;
57
+ (() => __awaiter(this, void 0, void 0, function* () {
58
+ try {
59
+ const pdf = yield pdfjsLib.getDocument({
60
+ url,
61
+ // 서버가 Range를 지원 안 하거나 CORS가 애매할 때 대비 옵션(필요 시 조정)
62
+ disableStream: false,
63
+ disableAutoFetch: false
64
+ }).promise;
65
+ if (cancelled)
66
+ return;
67
+ pdfRef.current = pdf;
68
+ setNumPages(pdf.numPages);
69
+ }
70
+ catch (e) {
71
+ // eslint-disable-next-line no-console
72
+ console.error('[PdfSpread] load error:', e);
73
+ }
74
+ }))();
75
+ return () => {
76
+ cancelled = true;
77
+ cancelAll();
78
+ clearHost();
79
+ };
80
+ }, [url]);
81
+ // 렌더링
82
+ useEffect(() => {
83
+ const pdf = pdfRef.current;
84
+ if (!pdf || !numPages || !width)
85
+ return;
86
+ // 새 세션 시작
87
+ const token = Symbol('render-session');
88
+ sessionRef.current = token;
89
+ // 이전 작업/캔버스 정리
90
+ cancelAll();
91
+ clearHost();
92
+ const host = hostRef.current;
93
+ let aborted = false;
94
+ (() => __awaiter(this, void 0, void 0, function* () {
95
+ for (let i = 1; i <= numPages; i++) {
96
+ if (aborted)
97
+ break;
98
+ if (sessionRef.current !== token)
99
+ break; // stale run 무시
100
+ try {
101
+ const page = yield pdf.getPage(i);
102
+ const unscaled = page.getViewport({ scale: 1 });
103
+ const scale = width / unscaled.width;
104
+ const viewport = page.getViewport({ scale });
105
+ // 새 캔버스 생성(재사용 X가 가장 안전)
106
+ const canvas = document.createElement('canvas');
107
+ canvas.className = 'mb-3 block overflow-hidden rounded bg-white';
108
+ canvas.width = Math.floor(viewport.width);
109
+ canvas.height = Math.floor(viewport.height);
110
+ canvas.style.width = `${viewport.width}px`;
111
+ canvas.style.height = `${viewport.height}px`;
112
+ host.appendChild(canvas);
113
+ canvasesRef.current.set(i, canvas);
114
+ const ctx = canvas.getContext('2d');
115
+ const task = page.render({ canvasContext: ctx, viewport });
116
+ tasksRef.current.set(i, task);
117
+ yield task.promise; // 순차 렌더
118
+ tasksRef.current.delete(i);
119
+ // page.cleanup(); // 필요 시 활성화
120
+ }
121
+ catch (e) {
122
+ // cancel() 시 RenderingCancelledException 발생 → 무시
123
+ if ((e === null || e === void 0 ? void 0 : e.name) !== 'RenderingCancelledException') {
124
+ // eslint-disable-next-line no-console
125
+ console.warn('[PdfSpread] render error page', i, e);
126
+ }
127
+ }
128
+ }
129
+ }))();
130
+ return () => {
131
+ aborted = true;
132
+ // 다음 세션에서 clearHost()가 정리합니다.
133
+ };
134
+ }, [numPages, width]);
135
+ function cancelAll() {
136
+ tasksRef.current.forEach(task => {
137
+ try {
138
+ task.cancel();
139
+ }
140
+ catch (_a) { }
141
+ });
142
+ tasksRef.current.clear();
143
+ }
144
+ function clearHost() {
145
+ const host = hostRef.current;
146
+ if (host)
147
+ host.innerHTML = '';
148
+ canvasesRef.current.clear();
149
+ }
150
+ return (<div className="w-full overflow-hidden rounded-lg border border-gray-200">
151
+ {/* 이 블록의 가로폭에 맞춰 모든 페이지를 “쭉” 렌더 */}
152
+ <div ref={hostRef} className="w-full p-3"/>
153
+ </div>);
154
+ }
@@ -0,0 +1,177 @@
1
+ 'use client';
2
+
3
+ import { useEffect, useRef, useState } from 'react';
4
+ import * as pdfjsLib from 'pdfjs-dist';
5
+
6
+ // pdf.js worker (pdfjs-dist 3.x)
7
+ (pdfjsLib as any).GlobalWorkerOptions.workerSrc = 'https://unpkg.com/pdfjs-dist@3.11.174/build/pdf.worker.min.js';
8
+
9
+ type Props = {
10
+ url: string;
11
+ name?: string;
12
+ };
13
+
14
+ type RenderTask = {
15
+ cancel: () => void;
16
+ promise: Promise<any>;
17
+ };
18
+
19
+ export default function PdfSpread({ url, name }: Props) {
20
+ const hostRef = useRef<HTMLDivElement>(null);
21
+
22
+ // 문서 객체
23
+ const pdfRef = useRef<any>(null);
24
+ const [numPages, setNumPages] = useState(0);
25
+
26
+ // 컨테이너 폭 (ResizeObserver 사용)
27
+ const [width, setWidth] = useState(0);
28
+ const roRef = useRef<ResizeObserver | null>(null);
29
+
30
+ // 페이지별 진행 중인 렌더 태스크 & 캔버스
31
+ const tasksRef = useRef<Map<number, RenderTask>>(new Map());
32
+ const canvasesRef = useRef<Map<number, HTMLCanvasElement>>(new Map());
33
+
34
+ // 렌더 세션 토큰 (stale run 무시용)
35
+ const sessionRef = useRef<symbol | null>(null);
36
+
37
+ // 컨테이너 폭 관찰
38
+ useEffect(() => {
39
+ const el = hostRef.current;
40
+ if (!el) return;
41
+ const ro = new ResizeObserver(entries => {
42
+ for (const entry of entries) {
43
+ const cw = Math.floor(entry.contentRect.width);
44
+ if (cw && cw !== width) setWidth(cw);
45
+ }
46
+ });
47
+ ro.observe(el);
48
+ roRef.current = ro;
49
+ // 초기 폭
50
+ setWidth(el.clientWidth);
51
+ return () => {
52
+ ro.disconnect();
53
+ roRef.current = null;
54
+ };
55
+ }, []);
56
+
57
+ // 문서 로드
58
+ useEffect(() => {
59
+ let cancelled = false;
60
+
61
+ // 이전 상태 정리
62
+ cancelAll();
63
+ clearHost();
64
+
65
+ setNumPages(0);
66
+ pdfRef.current = null;
67
+
68
+ (async () => {
69
+ try {
70
+ const pdf = await pdfjsLib.getDocument({
71
+ url,
72
+ // 서버가 Range를 지원 안 하거나 CORS가 애매할 때 대비 옵션(필요 시 조정)
73
+ disableStream: false,
74
+ disableAutoFetch: false
75
+ }).promise;
76
+
77
+ if (cancelled) return;
78
+ pdfRef.current = pdf;
79
+ setNumPages(pdf.numPages);
80
+ } catch (e) {
81
+ // eslint-disable-next-line no-console
82
+ console.error('[PdfSpread] load error:', e);
83
+ }
84
+ })();
85
+
86
+ return () => {
87
+ cancelled = true;
88
+ cancelAll();
89
+ clearHost();
90
+ };
91
+ }, [url]);
92
+
93
+ // 렌더링
94
+ useEffect(() => {
95
+ const pdf = pdfRef.current;
96
+ if (!pdf || !numPages || !width) return;
97
+
98
+ // 새 세션 시작
99
+ const token = Symbol('render-session');
100
+ sessionRef.current = token;
101
+
102
+ // 이전 작업/캔버스 정리
103
+ cancelAll();
104
+ clearHost();
105
+
106
+ const host = hostRef.current!;
107
+ let aborted = false;
108
+
109
+ (async () => {
110
+ for (let i = 1; i <= numPages; i++) {
111
+ if (aborted) break;
112
+ if (sessionRef.current !== token) break; // stale run 무시
113
+
114
+ try {
115
+ const page = await pdf.getPage(i);
116
+
117
+ const unscaled = page.getViewport({ scale: 1 });
118
+ const scale = width / unscaled.width;
119
+ const viewport = page.getViewport({ scale });
120
+
121
+ // 새 캔버스 생성(재사용 X가 가장 안전)
122
+ const canvas = document.createElement('canvas');
123
+ canvas.className = 'mb-3 block overflow-hidden rounded bg-white';
124
+ canvas.width = Math.floor(viewport.width);
125
+ canvas.height = Math.floor(viewport.height);
126
+ canvas.style.width = `${viewport.width}px`;
127
+ canvas.style.height = `${viewport.height}px`;
128
+ host.appendChild(canvas);
129
+
130
+ canvasesRef.current.set(i, canvas);
131
+
132
+ const ctx = canvas.getContext('2d')!;
133
+ const task = page.render({ canvasContext: ctx, viewport }) as unknown as RenderTask;
134
+
135
+ tasksRef.current.set(i, task);
136
+ await task.promise; // 순차 렌더
137
+
138
+ tasksRef.current.delete(i);
139
+ // page.cleanup(); // 필요 시 활성화
140
+ } catch (e: any) {
141
+ // cancel() 시 RenderingCancelledException 발생 → 무시
142
+ if (e?.name !== 'RenderingCancelledException') {
143
+ // eslint-disable-next-line no-console
144
+ console.warn('[PdfSpread] render error page', i, e);
145
+ }
146
+ }
147
+ }
148
+ })();
149
+
150
+ return () => {
151
+ aborted = true;
152
+ // 다음 세션에서 clearHost()가 정리합니다.
153
+ };
154
+ }, [numPages, width]);
155
+
156
+ function cancelAll() {
157
+ tasksRef.current.forEach(task => {
158
+ try {
159
+ task.cancel();
160
+ } catch {}
161
+ });
162
+ tasksRef.current.clear();
163
+ }
164
+
165
+ function clearHost() {
166
+ const host = hostRef.current;
167
+ if (host) host.innerHTML = '';
168
+ canvasesRef.current.clear();
169
+ }
170
+
171
+ return (
172
+ <div className="w-full overflow-hidden rounded-lg border border-gray-200">
173
+ {/* 이 블록의 가로폭에 맞춰 모든 페이지를 “쭉” 렌더 */}
174
+ <div ref={hostRef} className="w-full p-3" />
175
+ </div>
176
+ );
177
+ }