@daeryun/dr_components 0.8.80 → 0.8.83

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 (63) hide show
  1. package/dist/components/Daeryuntalk/ChatConversation.jsx +23 -15
  2. package/dist/components/Daeryuntalk/ChatConversation.tsx +47 -36
  3. package/dist/components/Daeryuntalk/ChatHomeView.jsx +15 -5
  4. package/dist/components/Daeryuntalk/ChatHomeView.tsx +24 -11
  5. package/dist/components/Daeryuntalk/ChatInput.jsx +15 -4
  6. package/dist/components/Daeryuntalk/ChatInput.tsx +17 -5
  7. package/dist/components/Daeryuntalk/ChatItem/ChatFile.jsx +1 -1
  8. package/dist/components/Daeryuntalk/ChatItem/ChatFile.tsx +1 -1
  9. package/dist/components/Daeryuntalk/ChatItem/WorkFlowImg.d.ts +3 -1
  10. package/dist/components/Daeryuntalk/ChatItem/WorkFlowImg.jsx +164 -3
  11. package/dist/components/Daeryuntalk/ChatItem/WorkFlowImg.tsx +197 -4
  12. package/dist/components/Daeryuntalk/ChatMessage.d.ts +1 -0
  13. package/dist/components/Daeryuntalk/ChatMessage.jsx +31 -29
  14. package/dist/components/Daeryuntalk/ChatMessage.tsx +54 -50
  15. package/dist/components/Daeryuntalk/ChatObject/ObjectButton.jsx +4 -2
  16. package/dist/components/Daeryuntalk/ChatObject/ObjectButton.tsx +6 -4
  17. package/dist/components/Daeryuntalk/ChatWidget.d.ts +1 -0
  18. package/dist/components/Daeryuntalk/ChatWidget.jsx +1 -1
  19. package/dist/components/Daeryuntalk/ChatWidget.tsx +10 -2
  20. package/dist/components/Daeryuntalk/DaeryuntalkContext.d.ts +1 -0
  21. package/dist/components/Daeryuntalk/DaeryuntalkContext.jsx +5 -3
  22. package/dist/components/Daeryuntalk/DaeryuntalkContext.tsx +7 -3
  23. package/dist/components/Daeryuntalk/HomeView.jsx +4 -9
  24. package/dist/components/Daeryuntalk/HomeView.tsx +9 -9
  25. package/dist/components/Daeryuntalk/NavigationFooter.jsx +1 -1
  26. package/dist/components/Daeryuntalk/NavigationFooter.tsx +1 -1
  27. package/dist/components/Daeryuntalk/Tiptap/Tiptap.d.ts +2 -1
  28. package/dist/components/Daeryuntalk/Tiptap/Tiptap.jsx +38 -5
  29. package/dist/components/Daeryuntalk/Tiptap/Tiptap.tsx +48 -9
  30. package/dist/components/Daeryuntalk/Toast/DaeryuntalkToastProvider.d.ts +2 -1
  31. package/dist/components/Daeryuntalk/Toast/DaeryuntalkToastProvider.jsx +18 -7
  32. package/dist/components/Daeryuntalk/Toast/DaeryuntalkToastProvider.tsx +24 -8
  33. package/dist/components/Daeryuntalk/Toast/ToastRender.jsx +9 -3
  34. package/dist/components/Daeryuntalk/Toast/ToastRender.tsx +10 -6
  35. package/dist/components/Daeryuntalk/Viewer/ImageViewer.jsx +6 -8
  36. package/dist/components/Daeryuntalk/Viewer/ImageViewer.tsx +7 -10
  37. package/dist/components/Daeryuntalk/Viewer/MobileViewer.d.ts +2 -0
  38. package/dist/components/Daeryuntalk/Viewer/MobileViewer.jsx +52 -19
  39. package/dist/components/Daeryuntalk/Viewer/MobileViewer.tsx +89 -43
  40. package/dist/components/Daeryuntalk/Viewer/TbPcViewer.d.ts +2 -0
  41. package/dist/components/Daeryuntalk/Viewer/TbPcViewer.jsx +35 -5
  42. package/dist/components/Daeryuntalk/Viewer/TbPcViewer.tsx +57 -21
  43. package/dist/components/Daeryuntalk/_api/daeryuntalk/index.d.ts +1 -0
  44. package/dist/components/Daeryuntalk/_api/daeryuntalk/index.js +14 -12
  45. package/dist/components/Daeryuntalk/_api/daeryuntalk/index.ts +9 -8
  46. package/dist/components/Daeryuntalk/_enums/ask-status.d.ts +2 -2
  47. package/dist/components/Daeryuntalk/_enums/ask-status.js +9 -9
  48. package/dist/components/Daeryuntalk/_enums/ask-status.ts +5 -5
  49. package/dist/components/Daeryuntalk/_enums/error.js +119 -111
  50. package/dist/components/Daeryuntalk/_enums/error.ts +135 -127
  51. package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.d.ts +1 -0
  52. package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.js +10 -4
  53. package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.ts +12 -4
  54. package/dist/components/Daeryuntalk/_hooks/view/useHomeView.js +1 -0
  55. package/dist/components/Daeryuntalk/_hooks/view/useHomeView.ts +1 -0
  56. package/dist/components/Daeryuntalk/_lib/utils.d.ts +2 -0
  57. package/dist/components/Daeryuntalk/_lib/utils.js +12 -0
  58. package/dist/components/Daeryuntalk/_lib/utils.ts +15 -0
  59. package/dist/components/Daeryuntalk/index.jsx +34 -5
  60. package/dist/components/Daeryuntalk/index.tsx +37 -6
  61. package/dist/styles/globals.css +30 -24
  62. package/dist/tsconfig.tsbuildinfo +1 -1
  63. package/package.json +1 -1
@@ -1,4 +1,3 @@
1
- // ./Toast/DaeryuntalkToastProvider.tsx
2
1
  'use client';
3
2
  import { createContext, useContext, useState } from 'react';
4
3
  export const ToastContext = createContext(undefined);
@@ -10,20 +9,32 @@ export const useDaeryunTalkToast = () => {
10
9
  };
11
10
  export const DaeryuntalkToastProvider = ({ children }) => {
12
11
  const [toast, setToast] = useState(null);
13
- const [isVisible, setIsVisible] = useState(false);
14
- const hideToast = () => setIsVisible(false);
12
+ const [animationState, setAnimationState] = useState('hidden');
13
+ const hideToast = () => {
14
+ setAnimationState('exiting');
15
+ setTimeout(() => {
16
+ setAnimationState('hidden');
17
+ setToast(null);
18
+ }, 500);
19
+ };
15
20
  const showToast = (type, title, description, duration = 3000) => {
16
21
  setToast({ type, title, description, duration });
17
- setIsVisible(true);
22
+ setAnimationState('entering');
23
+ // 짧은 딜레이 후 visible 상태로 전환 (아래에서 위로 애니메이션)
24
+ setTimeout(() => {
25
+ setAnimationState('visible');
26
+ }, 50);
27
+ // duration 후 자동 숨김
18
28
  setTimeout(() => {
19
- setIsVisible(false);
20
- setTimeout(() => setToast(null), 300);
29
+ if (animationState !== 'hidden') {
30
+ hideToast();
31
+ }
21
32
  }, duration);
22
33
  };
23
34
  const success = (title, d, t) => showToast('success', title, d, t);
24
35
  const warning = (title, d, t) => showToast('warning', title, d, t);
25
36
  const error = (title, d, t) => showToast('error', title, d, t);
26
- return (<ToastContext.Provider value={{ toast, isVisible, hideToast, success, warning, error }}>
37
+ return (<ToastContext.Provider value={{ toast, animationState, hideToast, success, warning, error }}>
27
38
  {children}
28
39
  </ToastContext.Provider>);
29
40
  };
@@ -1,8 +1,10 @@
1
- // ./Toast/DaeryuntalkToastProvider.tsx
2
1
  'use client';
3
2
 
4
3
  import { createContext, useContext, useState, ReactNode } from 'react';
4
+
5
5
  export type ToastType = 'success' | 'warning' | 'error';
6
+ export type AnimationState = 'hidden' | 'entering' | 'visible' | 'exiting';
7
+
6
8
  interface ToastItem {
7
9
  type: ToastType;
8
10
  title: string;
@@ -12,7 +14,7 @@ interface ToastItem {
12
14
 
13
15
  interface ToastContextProps {
14
16
  toast: ToastItem | null;
15
- isVisible: boolean;
17
+ animationState: AnimationState;
16
18
  hideToast: () => void;
17
19
  success: (title: string, desc?: string, duration?: number) => void;
18
20
  warning: (title: string, desc?: string, duration?: number) => void;
@@ -29,16 +31,30 @@ export const useDaeryunTalkToast = () => {
29
31
 
30
32
  export const DaeryuntalkToastProvider = ({ children }: { children: ReactNode }) => {
31
33
  const [toast, setToast] = useState<ToastItem | null>(null);
32
- const [isVisible, setIsVisible] = useState(false);
34
+ const [animationState, setAnimationState] = useState<AnimationState>('hidden');
33
35
 
34
- const hideToast = () => setIsVisible(false);
36
+ const hideToast = () => {
37
+ setAnimationState('exiting');
38
+ setTimeout(() => {
39
+ setAnimationState('hidden');
40
+ setToast(null);
41
+ }, 500);
42
+ };
35
43
 
36
44
  const showToast = (type: ToastType, title: string, description?: string, duration = 3000) => {
37
45
  setToast({ type, title, description, duration });
38
- setIsVisible(true);
46
+ setAnimationState('entering');
47
+
48
+ // 짧은 딜레이 후 visible 상태로 전환 (아래에서 위로 애니메이션)
49
+ setTimeout(() => {
50
+ setAnimationState('visible');
51
+ }, 50);
52
+
53
+ // duration 후 자동 숨김
39
54
  setTimeout(() => {
40
- setIsVisible(false);
41
- setTimeout(() => setToast(null), 300);
55
+ if (animationState !== 'hidden') {
56
+ hideToast();
57
+ }
42
58
  }, duration);
43
59
  };
44
60
 
@@ -47,7 +63,7 @@ export const DaeryuntalkToastProvider = ({ children }: { children: ReactNode })
47
63
  const error = (title: string, d?: string, t?: number) => showToast('error', title, d, t);
48
64
 
49
65
  return (
50
- <ToastContext.Provider value={{ toast, isVisible, hideToast, success, warning, error }}>
66
+ <ToastContext.Provider value={{ toast, animationState, hideToast, success, warning, error }}>
51
67
  {children}
52
68
  </ToastContext.Provider>
53
69
  );
@@ -7,9 +7,15 @@ export default function ToastRenderer() {
7
7
  const context = useContext(ToastContext);
8
8
  if (!context)
9
9
  return null;
10
- const { toast, isVisible, hideToast } = context;
11
- return (<div className="absolute bottom-0 left-1/2 z-[50] w-[90%] -translate-x-1/2">
12
- <div className={`transition-all duration-300 ${isVisible ? '-translate-y-[96px] opacity-100' : 'pointer-events-none translate-y-0 opacity-0 '}`}>
10
+ const { toast, animationState, hideToast } = context;
11
+ return (<div className="absolute bottom-0 left-1/2 z-[10] w-[90%] -translate-x-1/2">
12
+ <div className={`
13
+ transition-all duration-500 ease-out
14
+ ${animationState === 'hidden' && 'pointer-events-none translate-y-[20px] opacity-0'}
15
+ ${animationState === 'entering' && 'translate-y-[20px] opacity-0'}
16
+ ${animationState === 'visible' && 'translate-y-[-80px] opacity-100'}
17
+ ${animationState === 'exiting' && 'pointer-events-none translate-y-[-80px] opacity-0'}
18
+ `}>
13
19
  {toast && <DaeryunTalkToast {...toast} onClose={hideToast}/>}
14
20
  </div>
15
21
  </div>);
@@ -1,7 +1,7 @@
1
1
  // ./Toast/ToastRenderer.tsx
2
2
  'use client';
3
3
 
4
- import { useContext, useEffect } from 'react';
4
+ import { useContext } from 'react';
5
5
  import { ToastContext } from './DaeryuntalkToastProvider';
6
6
  import DaeryunTalkToast from './Toast';
7
7
 
@@ -10,14 +10,18 @@ export default function ToastRenderer() {
10
10
 
11
11
  if (!context) return null;
12
12
 
13
- const { toast, isVisible, hideToast } = context;
13
+ const { toast, animationState, hideToast } = context;
14
14
 
15
15
  return (
16
- <div className="absolute bottom-0 left-1/2 z-[50] w-[90%] -translate-x-1/2">
16
+ <div className="absolute bottom-0 left-1/2 z-[10] w-[90%] -translate-x-1/2">
17
17
  <div
18
- className={`transition-all duration-300 ${
19
- isVisible ? '-translate-y-[96px] opacity-100' : 'pointer-events-none translate-y-0 opacity-0 '
20
- }`}
18
+ className={`
19
+ transition-all duration-500 ease-out
20
+ ${animationState === 'hidden' && 'pointer-events-none translate-y-[20px] opacity-0'}
21
+ ${animationState === 'entering' && 'translate-y-[20px] opacity-0'}
22
+ ${animationState === 'visible' && 'translate-y-[-80px] opacity-100'}
23
+ ${animationState === 'exiting' && 'pointer-events-none translate-y-[-80px] opacity-0'}
24
+ `}
21
25
  >
22
26
  {toast && <DaeryunTalkToast {...toast} onClose={hideToast} />}
23
27
  </div>
@@ -40,14 +40,12 @@ const ImageViewer = () => {
40
40
  if (!imageViewerMessage || images.length === 0)
41
41
  return;
42
42
  const fetchAllUrls = () => __awaiter(void 0, void 0, void 0, function* () {
43
- const results = yield Promise.all(images.map((file) => __awaiter(void 0, void 0, void 0, function* () {
44
- const res = yield getMessageFileDownloadUrl({
45
- chatInquiryNumber: imageViewerMessage.inquiryNumber || '',
46
- fileNumber: file.fileNumber
47
- });
48
- return { file, url: res.data.url };
49
- })));
50
- setPreviewImages(results);
43
+ // STEP 1: 썸네일 기반 먼저 세팅
44
+ const initialPreviews = images.map(file => ({
45
+ file,
46
+ url: file.thumbnailUrl // 빠르게 미리 보여주기
47
+ }));
48
+ setPreviewImages(initialPreviews);
51
49
  });
52
50
  fetchAllUrls();
53
51
  }, [imageViewerMessage, selectedImageFile]);
@@ -54,16 +54,13 @@ const ImageViewer = () => {
54
54
  if (!imageViewerMessage || images.length === 0) return;
55
55
 
56
56
  const fetchAllUrls = async () => {
57
- const results: PreviewImage[] = await Promise.all(
58
- images.map(async file => {
59
- const res = await getMessageFileDownloadUrl({
60
- chatInquiryNumber: imageViewerMessage.inquiryNumber || '',
61
- fileNumber: file.fileNumber
62
- });
63
- return { file, url: res.data.url };
64
- })
65
- );
66
- setPreviewImages(results);
57
+ // STEP 1: 썸네일 기반 먼저 세팅
58
+ const initialPreviews = images.map(file => ({
59
+ file,
60
+ url: file.thumbnailUrl // 빠르게 미리 보여주기
61
+ }));
62
+
63
+ setPreviewImages(initialPreviews);
67
64
  };
68
65
 
69
66
  fetchAllUrls();
@@ -1,6 +1,8 @@
1
1
  import React, { Dispatch, SetStateAction } from 'react';
2
2
  import { Message } from '../_types/message';
3
3
  import { PreviewImage } from './ImageViewer';
4
+ import 'swiper/css';
5
+ import 'swiper/css/navigation';
4
6
  interface IMobileViewerProps {
5
7
  imageViewerMessage?: Message | null;
6
8
  handleDownload: () => void;
@@ -1,10 +1,14 @@
1
- import React from 'react';
1
+ import React, { useRef } from 'react';
2
2
  import DaeryunLogoIcon from '../../../asset/images/daeryuntalk/daeryun-logo.svg';
3
3
  import { formatDateToKorean } from '../_lib/utils';
4
4
  import DownloadIcon from '../../../asset/images/daeryuntalk/download.svg';
5
5
  import Image from 'next/image';
6
6
  import CloseIcon from '../../../asset/images/daeryuntalk/viewer/close.svg';
7
+ import { Swiper, SwiperSlide } from 'swiper/react';
8
+ import 'swiper/css';
9
+ import 'swiper/css/navigation';
7
10
  const MobileViewer = ({ imageViewerMessage, handleDownload, currentIndex, setCurrentIndex, currentImage, closeImageViewer, previewImages, setRotation, setZoomLevel }) => {
11
+ const thumbSwiperRef = useRef(null);
8
12
  return (<div className={`md2:hidden`}>
9
13
  <div className="flex h-[68px] w-full items-center justify-between bg-black/90 p-[20px] text-white">
10
14
  <div className="flex w-[calc(100%-88px)] gap-[10px]">
@@ -36,30 +40,59 @@ const MobileViewer = ({ imageViewerMessage, handleDownload, currentIndex, setCur
36
40
  </div>
37
41
  {/* 해당 공간은 중앙 배치 및 화면작아지면 스크롤 */}
38
42
  <div className={`mx-[20px] flex h-[calc(100dvh-68px-155px)] flex-col items-center justify-center overflow-auto`}>
39
- {/* Main Image + Toolbar */}
40
- <div className="group relative flex items-center justify-center overflow-auto">
41
- <div className="relative h-auto max-h-[500px] w-full">
42
- <Image src={currentImage.url} alt={currentImage.file.name} width={500} height={500} className="h-auto w-full rounded-[20px] object-contain" unoptimized style={{
43
- // maxWidth: '800px',
44
- // maxHeight: '500px'
45
- }}/>
46
- </div>
43
+ <div className="group relative flex w-full items-center justify-center overflow-auto">
44
+ <Swiper spaceBetween={0} slidesPerView={1} initialSlide={currentIndex} onSlideChange={swiper => {
45
+ setCurrentIndex(swiper.activeIndex);
46
+ setRotation(0);
47
+ setZoomLevel(3);
48
+ }} onSwiper={swiper => {
49
+ thumbSwiperRef.current = swiper;
50
+ }} allowTouchMove={previewImages.length > 1} className="w-full">
51
+ {previewImages.map((img, idx) => (<SwiperSlide key={idx} className="flex items-center justify-center rounded-[20px] ">
52
+ <div className="relative flex h-auto max-h-[500px] items-center justify-center rounded-[20px]">
53
+ <Image src={img.url} alt={img.file.name} width={500} height={500} className="mx-auto h-auto max-h-[500px] w-fit max-w-full rounded-[20px] object-contain" unoptimized/>
54
+ </div>
55
+ </SwiperSlide>))}
56
+ </Swiper>
47
57
  </div>
48
- {/* 여기는 하단 고정 */}
49
58
  </div>
59
+ {/*<div*/}
60
+ {/* className={`mx-[20px] flex h-[calc(100dvh-68px-155px)] flex-col items-center justify-center overflow-auto`}*/}
61
+ {/*>*/}
62
+ {/* <div className="group relative flex items-center justify-center overflow-auto">*/}
63
+ {/* <div className="relative h-auto max-h-[500px] w-full">*/}
64
+ {/* <Image*/}
65
+ {/* src={currentImage.url}*/}
66
+ {/* alt={currentImage.file.name}*/}
67
+ {/* width={500}*/}
68
+ {/* height={500}*/}
69
+ {/* className="h-auto w-full rounded-[20px] object-contain"*/}
70
+ {/* unoptimized*/}
71
+ {/* />*/}
72
+ {/* </div>*/}
73
+ {/* </div>*/}
74
+ {/*</div>*/}
50
75
  {/* Thumbnail Preview */}
51
- <div className={`flex items-center justify-center px-[20px] pb-[65px] pt-[40px]`}>
52
- {previewImages.length > 1 ? (<div className="flex flex-row gap-[10px]">
53
- {previewImages.map((img, idx) => (<div key={img.file.fileNumber} onClick={() => {
76
+ <div className="relative flex items-center justify-center px-[20px] pb-[65px] pt-[40px]">
77
+ {previewImages.length > 1 ? (<Swiper spaceBetween={10} slidesPerView={Math.min(previewImages.length, 5)} watchSlidesProgress allowTouchMove>
78
+ {previewImages.map((img, idx) => (<SwiperSlide key={idx} className={`!w-fit`}>
79
+ <div onClick={() => {
80
+ var _a;
54
81
  setCurrentIndex(idx);
55
82
  setRotation(0);
56
83
  setZoomLevel(3);
57
- }} className={`h-[50px] w-[50px] shrink-0 cursor-pointer overflow-hidden rounded-[10px] border-[1px]
58
-
59
- ${idx === currentIndex ? 'border-white' : 'opacity-50 hover:border-white hover:opacity-100'}`}>
60
- <Image src={img.file.thumbnailUrl} alt={img.file.name} width={200} height={200} className="h-full w-full object-cover" unoptimized/>
61
- </div>))}
62
- </div>) : (<div></div>)}
84
+ (_a = thumbSwiperRef.current) === null || _a === void 0 ? void 0 : _a.slideTo(idx); // 👈 스와이퍼 이동
85
+ }} className={`
86
+ relative
87
+ h-[50px] w-[50px] cursor-pointer overflow-hidden rounded-[10px] border-[1px]
88
+ ${idx === currentIndex ? 'border-white' : 'opacity-50 hover:border-white hover:opacity-100'}
89
+ `}>
90
+ {/*<div className={`absolute left-0 top-0 bg-yellow-200 !text-black`}>{idx}</div>*/}
91
+
92
+ <Image src={img.file.thumbnailUrl} alt={img.file.name} width={200} height={200} className="h-full w-full object-cover" unoptimized/>
93
+ </div>
94
+ </SwiperSlide>))}
95
+ </Swiper>) : (<div></div>)}
63
96
  </div>
64
97
  </div>);
65
98
  };
@@ -1,4 +1,4 @@
1
- import React, { Dispatch, SetStateAction } from 'react';
1
+ import React, { Dispatch, SetStateAction, useRef } from 'react';
2
2
  import DaeryunLogoIcon from '../../../asset/images/daeryuntalk/daeryun-logo.svg';
3
3
  import { formatDateToKorean } from '../_lib/utils';
4
4
  import DownloadIcon from '../../../asset/images/daeryuntalk/download.svg';
@@ -6,6 +6,11 @@ import { Message } from '../_types/message';
6
6
  import Image from 'next/image';
7
7
  import CloseIcon from '../../../asset/images/daeryuntalk/viewer/close.svg';
8
8
  import { PreviewImage } from './ImageViewer';
9
+ import { Swiper, SwiperSlide } from 'swiper/react';
10
+ import { Swiper as SwiperClass } from 'swiper';
11
+
12
+ import 'swiper/css';
13
+ import 'swiper/css/navigation';
9
14
  interface IMobileViewerProps {
10
15
  imageViewerMessage?: Message | null;
11
16
  handleDownload: () => void;
@@ -28,6 +33,8 @@ const MobileViewer = ({
28
33
  setRotation,
29
34
  setZoomLevel
30
35
  }: IMobileViewerProps) => {
36
+ const thumbSwiperRef = useRef<SwiperClass | null>(null);
37
+
31
38
  return (
32
39
  <div className={`md2:hidden`}>
33
40
  <div className="flex h-[68px] w-full items-center justify-between bg-black/90 p-[20px] text-white">
@@ -62,54 +69,93 @@ const MobileViewer = ({
62
69
  <div
63
70
  className={`mx-[20px] flex h-[calc(100dvh-68px-155px)] flex-col items-center justify-center overflow-auto`}
64
71
  >
65
- {/* Main Image + Toolbar */}
66
- <div className="group relative flex items-center justify-center overflow-auto">
67
- <div className="relative h-auto max-h-[500px] w-full">
68
- <Image
69
- src={currentImage.url}
70
- alt={currentImage.file.name}
71
- width={500}
72
- height={500}
73
- className="h-auto w-full rounded-[20px] object-contain"
74
- unoptimized
75
- style={
76
- {
77
- // maxWidth: '800px',
78
- // maxHeight: '500px'
79
- }
80
- }
81
- />
82
- </div>
72
+ <div className="group relative flex w-full items-center justify-center overflow-auto">
73
+ <Swiper
74
+ spaceBetween={0}
75
+ slidesPerView={1}
76
+ initialSlide={currentIndex}
77
+ onSlideChange={swiper => {
78
+ setCurrentIndex(swiper.activeIndex);
79
+ setRotation(0);
80
+ setZoomLevel(3);
81
+ }}
82
+ onSwiper={swiper => {
83
+ thumbSwiperRef.current = swiper;
84
+ }}
85
+ allowTouchMove={previewImages.length > 1}
86
+ className="w-full"
87
+ >
88
+ {previewImages.map((img, idx) => (
89
+ <SwiperSlide key={idx} className="flex items-center justify-center rounded-[20px] ">
90
+ <div className="relative flex h-auto max-h-[500px] items-center justify-center rounded-[20px]">
91
+ <Image
92
+ src={img.url}
93
+ alt={img.file.name}
94
+ width={500}
95
+ height={500}
96
+ className="mx-auto h-auto max-h-[500px] w-fit max-w-full rounded-[20px] object-contain"
97
+ unoptimized
98
+ />
99
+ </div>
100
+ </SwiperSlide>
101
+ ))}
102
+ </Swiper>
83
103
  </div>
84
- {/* 여기는 하단 고정 */}
85
104
  </div>
105
+ {/*<div*/}
106
+ {/* className={`mx-[20px] flex h-[calc(100dvh-68px-155px)] flex-col items-center justify-center overflow-auto`}*/}
107
+ {/*>*/}
108
+ {/* <div className="group relative flex items-center justify-center overflow-auto">*/}
109
+ {/* <div className="relative h-auto max-h-[500px] w-full">*/}
110
+ {/* <Image*/}
111
+ {/* src={currentImage.url}*/}
112
+ {/* alt={currentImage.file.name}*/}
113
+ {/* width={500}*/}
114
+ {/* height={500}*/}
115
+ {/* className="h-auto w-full rounded-[20px] object-contain"*/}
116
+ {/* unoptimized*/}
117
+ {/* />*/}
118
+ {/* </div>*/}
119
+ {/* </div>*/}
120
+ {/*</div>*/}
86
121
  {/* Thumbnail Preview */}
87
- <div className={`flex items-center justify-center px-[20px] pb-[65px] pt-[40px]`}>
122
+ <div className="relative flex items-center justify-center px-[20px] pb-[65px] pt-[40px]">
88
123
  {previewImages.length > 1 ? (
89
- <div className="flex flex-row gap-[10px]">
124
+ <Swiper
125
+ spaceBetween={10}
126
+ slidesPerView={Math.min(previewImages.length, 5)}
127
+ watchSlidesProgress
128
+ allowTouchMove
129
+ >
90
130
  {previewImages.map((img, idx) => (
91
- <div
92
- key={img.file.fileNumber}
93
- onClick={() => {
94
- setCurrentIndex(idx);
95
- setRotation(0);
96
- setZoomLevel(3);
97
- }}
98
- className={`h-[50px] w-[50px] shrink-0 cursor-pointer overflow-hidden rounded-[10px] border-[1px]
99
-
100
- ${idx === currentIndex ? 'border-white' : 'opacity-50 hover:border-white hover:opacity-100'}`}
101
- >
102
- <Image
103
- src={img.file.thumbnailUrl}
104
- alt={img.file.name}
105
- width={200}
106
- height={200}
107
- className="h-full w-full object-cover"
108
- unoptimized
109
- />
110
- </div>
131
+ <SwiperSlide key={idx} className={`!w-fit`}>
132
+ <div
133
+ onClick={() => {
134
+ setCurrentIndex(idx);
135
+ setRotation(0);
136
+ setZoomLevel(3);
137
+ thumbSwiperRef.current?.slideTo(idx); // 👈 스와이퍼 이동
138
+ }}
139
+ className={`
140
+ relative
141
+ h-[50px] w-[50px] cursor-pointer overflow-hidden rounded-[10px] border-[1px]
142
+ ${idx === currentIndex ? 'border-white' : 'opacity-50 hover:border-white hover:opacity-100'}
143
+ `}
144
+ >
145
+ {/*<div className={`absolute left-0 top-0 bg-yellow-200 !text-black`}>{idx}</div>*/}
146
+
147
+ <Image
148
+ src={img.file.thumbnailUrl}
149
+ alt={img.file.name}
150
+ width={200}
151
+ height={200}
152
+ className="h-full w-full object-cover"
153
+ unoptimized
154
+ />
155
+ </div>
156
+ </SwiperSlide>
111
157
  ))}
112
- </div>
158
+ </Swiper>
113
159
  ) : (
114
160
  <div></div>
115
161
  )}
@@ -1,6 +1,8 @@
1
1
  import React, { Dispatch, SetStateAction } from 'react';
2
2
  import { Message } from '../_types/message';
3
3
  import { PreviewImage } from './ImageViewer';
4
+ import 'swiper/css';
5
+ import 'swiper/css/navigation';
4
6
  interface ITbPcViewerProps {
5
7
  imageViewerMessage?: Message | null;
6
8
  handleDownload: () => void;
@@ -9,6 +9,9 @@ import CloseIcon from '../../../asset/images/daeryuntalk/viewer/close.svg';
9
9
  import MoveSwipingIcon from '../../../asset/images/daeryuntalk/viewer/move-button.svg';
10
10
  import DaeryunLogoIcon from '../../../asset/images/daeryuntalk/daeryun-logo.svg';
11
11
  import { formatDateToKorean } from '../_lib/utils';
12
+ import { Swiper, SwiperSlide } from 'swiper/react';
13
+ import 'swiper/css';
14
+ import 'swiper/css/navigation';
12
15
  const TbPcViewer = ({ imageViewerMessage, handleDownload, currentIndex, setCurrentIndex, rotation, currentZoom, currentImage, closeImageViewer, previewImages, setRotation, setZoomLevel, rotateImage, zoomIn, zoomOut, zoomLevel }) => {
13
16
  return (<div className={`hidden md2:block`}>
14
17
  <div className={`flex h-[100dvh] flex-col items-center justify-center gap-[60px] px-[88px]`}>
@@ -92,14 +95,41 @@ const TbPcViewer = ({ imageViewerMessage, handleDownload, currentIndex, setCurre
92
95
 
93
96
  {/* Thumbnail Preview - 고정된 위치 */}
94
97
  {previewImages.length > 1 && (<div className="flex w-full max-w-[90vw] flex-row justify-center gap-[10px] overflow-x-auto px-[20px] md2:w-[830px]">
95
- {previewImages.map((img, idx) => (<div key={img.file.fileNumber} onClick={() => {
98
+ <Swiper spaceBetween={10} slidesPerView={Math.min(previewImages.length, 5)} watchSlidesProgress allowTouchMove>
99
+ {previewImages.map((img, idx) => (<SwiperSlide key={idx} className={`!w-fit`}>
100
+ <div onClick={() => {
96
101
  setCurrentIndex(idx);
97
102
  setRotation(0);
98
103
  setZoomLevel(3);
99
- }} className={`h-[60px] w-[96px] shrink-0 cursor-pointer overflow-hidden rounded-[10px] border-[1px]
100
- ${idx === currentIndex ? 'border-white' : 'border-transparent opacity-50 hover:opacity-100'}`}>
101
- <Image src={img.file.thumbnailUrl} alt={img.file.name} width={96} height={60} className="h-full w-full object-cover" unoptimized/>
102
- </div>))}
104
+ }} className={`
105
+ h-[60px] w-[96px] shrink-0 cursor-pointer overflow-hidden rounded-[10px] border-[1px]
106
+ ${idx === currentIndex ? 'border-white' : 'border-transparent opacity-50 hover:opacity-100'}
107
+ `}>
108
+ <Image src={img.file.thumbnailUrl} alt={img.file.name} width={96} height={60} className="h-full w-full object-cover" unoptimized/>
109
+ </div>
110
+ </SwiperSlide>))}
111
+ </Swiper>
112
+ {/*{previewImages.map((img, idx) => (*/}
113
+ {/* <div*/}
114
+ {/* key={img.file.fileNumber}*/}
115
+ {/* onClick={() => {*/}
116
+ {/* setCurrentIndex(idx);*/}
117
+ {/* setRotation(0);*/}
118
+ {/* setZoomLevel(3);*/}
119
+ {/* }}*/}
120
+ {/* className={`h-[60px] w-[96px] shrink-0 cursor-pointer overflow-hidden rounded-[10px] border-[1px]*/}
121
+ {/* ${idx === currentIndex ? 'border-white' : 'border-transparent opacity-50 hover:opacity-100'}`}*/}
122
+ {/* >*/}
123
+ {/* <Image*/}
124
+ {/* src={img.file.thumbnailUrl}*/}
125
+ {/* alt={img.file.name}*/}
126
+ {/* width={96}*/}
127
+ {/* height={60}*/}
128
+ {/* className="h-full w-full object-cover"*/}
129
+ {/* unoptimized*/}
130
+ {/* />*/}
131
+ {/* </div>*/}
132
+ {/*))}*/}
103
133
  </div>)}
104
134
  </div>
105
135
  </div>);