@daeryun/dr_components 0.8.80 → 0.8.82
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/components/Daeryuntalk/ChatConversation.jsx +3 -3
- package/dist/components/Daeryuntalk/ChatConversation.tsx +3 -2
- package/dist/components/Daeryuntalk/ChatHomeView.jsx +15 -5
- package/dist/components/Daeryuntalk/ChatHomeView.tsx +24 -11
- package/dist/components/Daeryuntalk/ChatInput.jsx +15 -4
- package/dist/components/Daeryuntalk/ChatInput.tsx +17 -5
- package/dist/components/Daeryuntalk/ChatItem/ChatFile.jsx +1 -1
- package/dist/components/Daeryuntalk/ChatItem/ChatFile.tsx +1 -1
- package/dist/components/Daeryuntalk/ChatItem/WorkFlowImg.d.ts +3 -1
- package/dist/components/Daeryuntalk/ChatItem/WorkFlowImg.jsx +164 -3
- package/dist/components/Daeryuntalk/ChatItem/WorkFlowImg.tsx +197 -4
- package/dist/components/Daeryuntalk/ChatMessage.d.ts +1 -0
- package/dist/components/Daeryuntalk/ChatMessage.jsx +3 -3
- package/dist/components/Daeryuntalk/ChatMessage.tsx +5 -3
- package/dist/components/Daeryuntalk/ChatObject/ObjectButton.jsx +4 -2
- package/dist/components/Daeryuntalk/ChatObject/ObjectButton.tsx +6 -4
- package/dist/components/Daeryuntalk/ChatWidget.d.ts +1 -0
- package/dist/components/Daeryuntalk/ChatWidget.jsx +1 -1
- package/dist/components/Daeryuntalk/ChatWidget.tsx +10 -2
- package/dist/components/Daeryuntalk/DaeryuntalkContext.d.ts +1 -0
- package/dist/components/Daeryuntalk/DaeryuntalkContext.jsx +5 -3
- package/dist/components/Daeryuntalk/DaeryuntalkContext.tsx +7 -3
- package/dist/components/Daeryuntalk/HomeView.jsx +4 -9
- package/dist/components/Daeryuntalk/HomeView.tsx +9 -9
- package/dist/components/Daeryuntalk/NavigationFooter.jsx +1 -1
- package/dist/components/Daeryuntalk/NavigationFooter.tsx +1 -1
- package/dist/components/Daeryuntalk/Tiptap/Tiptap.d.ts +2 -1
- package/dist/components/Daeryuntalk/Tiptap/Tiptap.jsx +38 -5
- package/dist/components/Daeryuntalk/Tiptap/Tiptap.tsx +48 -9
- package/dist/components/Daeryuntalk/Toast/DaeryuntalkToastProvider.d.ts +2 -1
- package/dist/components/Daeryuntalk/Toast/DaeryuntalkToastProvider.jsx +18 -7
- package/dist/components/Daeryuntalk/Toast/DaeryuntalkToastProvider.tsx +24 -8
- package/dist/components/Daeryuntalk/Toast/ToastRender.jsx +9 -3
- package/dist/components/Daeryuntalk/Toast/ToastRender.tsx +10 -6
- package/dist/components/Daeryuntalk/Viewer/ImageViewer.jsx +6 -8
- package/dist/components/Daeryuntalk/Viewer/ImageViewer.tsx +7 -10
- package/dist/components/Daeryuntalk/Viewer/MobileViewer.d.ts +2 -0
- package/dist/components/Daeryuntalk/Viewer/MobileViewer.jsx +52 -19
- package/dist/components/Daeryuntalk/Viewer/MobileViewer.tsx +89 -43
- package/dist/components/Daeryuntalk/Viewer/TbPcViewer.d.ts +2 -0
- package/dist/components/Daeryuntalk/Viewer/TbPcViewer.jsx +35 -5
- package/dist/components/Daeryuntalk/Viewer/TbPcViewer.tsx +57 -21
- package/dist/components/Daeryuntalk/_api/daeryuntalk/index.d.ts +1 -0
- package/dist/components/Daeryuntalk/_api/daeryuntalk/index.js +14 -12
- package/dist/components/Daeryuntalk/_api/daeryuntalk/index.ts +9 -8
- package/dist/components/Daeryuntalk/_enums/error.js +119 -111
- package/dist/components/Daeryuntalk/_enums/error.ts +135 -127
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.d.ts +1 -0
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.js +8 -2
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.ts +10 -2
- package/dist/components/Daeryuntalk/_hooks/view/useHomeView.js +1 -0
- package/dist/components/Daeryuntalk/_hooks/view/useHomeView.ts +1 -0
- package/dist/components/Daeryuntalk/_lib/utils.d.ts +2 -0
- package/dist/components/Daeryuntalk/_lib/utils.js +12 -0
- package/dist/components/Daeryuntalk/_lib/utils.ts +15 -0
- package/dist/components/Daeryuntalk/index.jsx +34 -5
- package/dist/components/Daeryuntalk/index.tsx +37 -6
- package/dist/styles/globals.css +30 -24
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { EditorContent, useEditor } from '@tiptap/react';
|
|
2
2
|
import Placeholder from '@tiptap/extension-placeholder';
|
|
3
|
-
import { forwardRef, useEffect, useImperativeHandle } from 'react';
|
|
3
|
+
import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
4
4
|
import HardBreak from '@tiptap/extension-hard-break'; // 추가
|
|
5
5
|
import Document from '@tiptap/extension-document';
|
|
6
6
|
import Paragraph from '@tiptap/extension-paragraph';
|
|
7
7
|
import Text from '@tiptap/extension-text';
|
|
8
|
-
|
|
8
|
+
import ShadowBox from '../_ui/ShadowBox';
|
|
9
|
+
const Tiptap = forwardRef(({ onChange, placeholder = '메시지를 입력해 주세요.', onEnterKeyPress, onKeyDown, contentClassName = '' }, ref) => {
|
|
10
|
+
const containerRef = useRef(null);
|
|
11
|
+
const [isScroll, setIsScroll] = useState(false);
|
|
12
|
+
const [isBottom, setIsBottom] = useState(false);
|
|
9
13
|
const editor = useEditor({
|
|
10
14
|
extensions: [
|
|
11
15
|
Document,
|
|
@@ -36,7 +40,7 @@ const Tiptap = forwardRef(({ onChange, placeholder = '메시지를 입력하세
|
|
|
36
40
|
},
|
|
37
41
|
editorProps: {
|
|
38
42
|
attributes: {
|
|
39
|
-
class: `dr_talk_body_medium2 focus:outline-none
|
|
43
|
+
class: `dr_talk_body_medium2 focus:outline-none overflow-y-auto resize-none pt-[6px] pb-[4px] break-words whitespace-pre-wrap word-wrap break-word overflow-wrap-anywhere no-scrollbar `
|
|
40
44
|
},
|
|
41
45
|
handleKeyDown: (view, event) => {
|
|
42
46
|
const isMobile = /Mobi|Android/i.test(navigator.userAgent); // 모바일 여부 판별
|
|
@@ -88,10 +92,39 @@ const Tiptap = forwardRef(({ onChange, placeholder = '메시지를 입력하세
|
|
|
88
92
|
editor === null || editor === void 0 ? void 0 : editor.commands.insertContent(content);
|
|
89
93
|
}
|
|
90
94
|
}));
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
var _a;
|
|
97
|
+
const checkScroll = () => {
|
|
98
|
+
var _a;
|
|
99
|
+
const proseEl = (_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('.ProseMirror');
|
|
100
|
+
if (!proseEl)
|
|
101
|
+
return;
|
|
102
|
+
const hasScroll = proseEl.scrollHeight > proseEl.clientHeight;
|
|
103
|
+
const atBottom = proseEl.scrollTop + proseEl.clientHeight >= proseEl.scrollHeight - 1;
|
|
104
|
+
setIsScroll(hasScroll);
|
|
105
|
+
setIsBottom(atBottom);
|
|
106
|
+
};
|
|
107
|
+
const proseEl = (_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('.ProseMirror');
|
|
108
|
+
if (proseEl) {
|
|
109
|
+
proseEl.addEventListener('scroll', checkScroll);
|
|
110
|
+
const observer = new ResizeObserver(checkScroll);
|
|
111
|
+
observer.observe(proseEl);
|
|
112
|
+
// 초기 체크
|
|
113
|
+
checkScroll();
|
|
114
|
+
return () => {
|
|
115
|
+
proseEl.removeEventListener('scroll', checkScroll);
|
|
116
|
+
observer.disconnect();
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
}, [editor]);
|
|
91
120
|
if (!editor)
|
|
92
121
|
return null;
|
|
93
|
-
|
|
94
|
-
|
|
122
|
+
return (<div className={`relative w-full `}>
|
|
123
|
+
<div ref={containerRef} className={`w-full`}>
|
|
124
|
+
<EditorContent editor={editor} tabIndex={0} className={`${contentClassName} max-h-[72px] min-h-[36px] w-full overflow-hidden rounded-md border !text-black dark:text-white `}/>
|
|
125
|
+
</div>
|
|
126
|
+
{isScroll && !isBottom && <ShadowBox />}
|
|
127
|
+
</div>);
|
|
95
128
|
});
|
|
96
129
|
Tiptap.displayName = 'Tiptap';
|
|
97
130
|
export default Tiptap;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { EditorContent, useEditor } from '@tiptap/react';
|
|
2
2
|
import Placeholder from '@tiptap/extension-placeholder';
|
|
3
|
-
import { forwardRef, useEffect, useImperativeHandle } from 'react';
|
|
3
|
+
import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
4
4
|
import HardBreak from '@tiptap/extension-hard-break'; // 추가
|
|
5
5
|
|
|
6
6
|
import { JSONContent } from '@tiptap/core'; // 추가 필요
|
|
7
7
|
import Document from '@tiptap/extension-document';
|
|
8
8
|
import Paragraph from '@tiptap/extension-paragraph';
|
|
9
9
|
import Text from '@tiptap/extension-text';
|
|
10
|
+
import { useScrollShadow } from '../_hooks/useScrollShadow';
|
|
11
|
+
import ShadowBox from '../_ui/ShadowBox';
|
|
10
12
|
|
|
11
13
|
export interface TiptapEditorRef {
|
|
12
14
|
clearContent: () => void;
|
|
@@ -26,7 +28,12 @@ interface TiptapProps {
|
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
const Tiptap = forwardRef<TiptapEditorRef, TiptapProps>(
|
|
29
|
-
({ onChange, placeholder = '메시지를
|
|
31
|
+
({ onChange, placeholder = '메시지를 입력해 주세요.', onEnterKeyPress, onKeyDown, contentClassName = '' }, ref) => {
|
|
32
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
33
|
+
|
|
34
|
+
const [isScroll, setIsScroll] = useState(false);
|
|
35
|
+
const [isBottom, setIsBottom] = useState(false);
|
|
36
|
+
|
|
30
37
|
const editor = useEditor({
|
|
31
38
|
extensions: [
|
|
32
39
|
Document,
|
|
@@ -57,7 +64,7 @@ const Tiptap = forwardRef<TiptapEditorRef, TiptapProps>(
|
|
|
57
64
|
},
|
|
58
65
|
editorProps: {
|
|
59
66
|
attributes: {
|
|
60
|
-
class: `dr_talk_body_medium2 focus:outline-none
|
|
67
|
+
class: `dr_talk_body_medium2 focus:outline-none overflow-y-auto resize-none pt-[6px] pb-[4px] break-words whitespace-pre-wrap word-wrap break-word overflow-wrap-anywhere no-scrollbar `
|
|
61
68
|
},
|
|
62
69
|
handleKeyDown: (view, event) => {
|
|
63
70
|
const isMobile = /Mobi|Android/i.test(navigator.userAgent); // 모바일 여부 판별
|
|
@@ -114,15 +121,47 @@ const Tiptap = forwardRef<TiptapEditorRef, TiptapProps>(
|
|
|
114
121
|
}
|
|
115
122
|
}));
|
|
116
123
|
|
|
124
|
+
useEffect(() => {
|
|
125
|
+
const checkScroll = () => {
|
|
126
|
+
const proseEl = containerRef.current?.querySelector('.ProseMirror');
|
|
127
|
+
if (!proseEl) return;
|
|
128
|
+
|
|
129
|
+
const hasScroll = proseEl.scrollHeight > proseEl.clientHeight;
|
|
130
|
+
const atBottom = proseEl.scrollTop + proseEl.clientHeight >= proseEl.scrollHeight - 1;
|
|
131
|
+
|
|
132
|
+
setIsScroll(hasScroll);
|
|
133
|
+
setIsBottom(atBottom);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const proseEl = containerRef.current?.querySelector('.ProseMirror');
|
|
137
|
+
if (proseEl) {
|
|
138
|
+
proseEl.addEventListener('scroll', checkScroll);
|
|
139
|
+
const observer = new ResizeObserver(checkScroll);
|
|
140
|
+
observer.observe(proseEl);
|
|
141
|
+
|
|
142
|
+
// 초기 체크
|
|
143
|
+
checkScroll();
|
|
144
|
+
|
|
145
|
+
return () => {
|
|
146
|
+
proseEl.removeEventListener('scroll', checkScroll);
|
|
147
|
+
observer.disconnect();
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
}, [editor]);
|
|
151
|
+
|
|
117
152
|
if (!editor) return null;
|
|
118
153
|
|
|
119
|
-
// return <EditorContent editor={editor} tabIndex={0} className="rounded-md border text-black dark:text-white" />;
|
|
120
154
|
return (
|
|
121
|
-
<
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
155
|
+
<div className={`relative w-full `}>
|
|
156
|
+
<div ref={containerRef} className={`w-full`}>
|
|
157
|
+
<EditorContent
|
|
158
|
+
editor={editor}
|
|
159
|
+
tabIndex={0}
|
|
160
|
+
className={`${contentClassName} max-h-[72px] min-h-[36px] w-full overflow-hidden rounded-md border !text-black dark:text-white `}
|
|
161
|
+
/>
|
|
162
|
+
</div>
|
|
163
|
+
{isScroll && !isBottom && <ShadowBox />}
|
|
164
|
+
</div>
|
|
126
165
|
);
|
|
127
166
|
}
|
|
128
167
|
);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
export type ToastType = 'success' | 'warning' | 'error';
|
|
3
|
+
export type AnimationState = 'hidden' | 'entering' | 'visible' | 'exiting';
|
|
3
4
|
interface ToastItem {
|
|
4
5
|
type: ToastType;
|
|
5
6
|
title: string;
|
|
@@ -8,7 +9,7 @@ interface ToastItem {
|
|
|
8
9
|
}
|
|
9
10
|
interface ToastContextProps {
|
|
10
11
|
toast: ToastItem | null;
|
|
11
|
-
|
|
12
|
+
animationState: AnimationState;
|
|
12
13
|
hideToast: () => void;
|
|
13
14
|
success: (title: string, desc?: string, duration?: number) => void;
|
|
14
15
|
warning: (title: string, desc?: string, duration?: number) => void;
|
|
@@ -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 [
|
|
14
|
-
const hideToast = () =>
|
|
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
|
-
|
|
22
|
+
setAnimationState('entering');
|
|
23
|
+
// 짧은 딜레이 후 visible 상태로 전환 (아래에서 위로 애니메이션)
|
|
24
|
+
setTimeout(() => {
|
|
25
|
+
setAnimationState('visible');
|
|
26
|
+
}, 50);
|
|
27
|
+
// duration 후 자동 숨김
|
|
18
28
|
setTimeout(() => {
|
|
19
|
-
|
|
20
|
-
|
|
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,
|
|
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
|
-
|
|
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 [
|
|
34
|
+
const [animationState, setAnimationState] = useState<AnimationState>('hidden');
|
|
33
35
|
|
|
34
|
-
const hideToast = () =>
|
|
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
|
-
|
|
46
|
+
setAnimationState('entering');
|
|
47
|
+
|
|
48
|
+
// 짧은 딜레이 후 visible 상태로 전환 (아래에서 위로 애니메이션)
|
|
49
|
+
setTimeout(() => {
|
|
50
|
+
setAnimationState('visible');
|
|
51
|
+
}, 50);
|
|
52
|
+
|
|
53
|
+
// duration 후 자동 숨김
|
|
39
54
|
setTimeout(() => {
|
|
40
|
-
|
|
41
|
-
|
|
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,
|
|
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,
|
|
11
|
-
return (<div className="absolute bottom-0 left-1/2 z-[
|
|
12
|
-
<div className={`
|
|
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
|
|
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,
|
|
13
|
+
const { toast, animationState, hideToast } = context;
|
|
14
14
|
|
|
15
15
|
return (
|
|
16
|
-
<div className="absolute bottom-0 left-1/2 z-[
|
|
16
|
+
<div className="absolute bottom-0 left-1/2 z-[10] w-[90%] -translate-x-1/2">
|
|
17
17
|
<div
|
|
18
|
-
className={`
|
|
19
|
-
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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=
|
|
52
|
-
{previewImages.length > 1 ? (<
|
|
53
|
-
{previewImages.map((img, idx) => (<
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
};
|