@daeryun/dr_components 0.7.88 → 0.7.89
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/ChatHomeView.jsx +2 -0
- package/dist/components/Daeryuntalk/ChatHomeView.tsx +2 -0
- package/dist/components/Daeryuntalk/ChatInput.tsx +1 -1
- package/dist/components/Daeryuntalk/ChatWidget.jsx +5 -2
- package/dist/components/Daeryuntalk/ChatWidget.tsx +5 -2
- package/dist/components/Daeryuntalk/History/AuthForm.jsx +10 -1
- package/dist/components/Daeryuntalk/History/AuthForm.tsx +11 -1
- package/dist/components/Daeryuntalk/HistoryView.jsx +7 -1
- package/dist/components/Daeryuntalk/HistoryView.tsx +9 -1
- package/dist/components/Daeryuntalk/Tiptap/Tiptap.jsx +9 -1
- package/dist/components/Daeryuntalk/Tiptap/Tiptap.tsx +10 -1
- package/dist/components/Daeryuntalk/Toast/DaeryuntalkToastProvider.d.ts +12 -0
- package/dist/components/Daeryuntalk/Toast/DaeryuntalkToastProvider.jsx +33 -0
- package/dist/components/Daeryuntalk/Toast/DaeryuntalkToastProvider.tsx +67 -0
- package/dist/components/Daeryuntalk/Toast/Toast.d.ts +11 -0
- package/dist/components/Daeryuntalk/Toast/Toast.jsx +61 -0
- package/dist/components/Daeryuntalk/Toast/Toast.tsx +94 -0
- package/dist/styles/globals.css +38 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -19,11 +19,13 @@ import InfoIcon from '../../asset/images/daeryuntalk/info.svg';
|
|
|
19
19
|
import DaeryunLogoIcon from '../../asset/images/daeryuntalk/daeryun-logo.svg';
|
|
20
20
|
import DaeryuntalkIntro from '../../asset/images/daeryuntalk/daeryuntalk-intro.png';
|
|
21
21
|
import { useChatSocketState } from './_hooks/talkprovider/useChatSocketState';
|
|
22
|
+
import { useDearyunTalkToast } from './Toast/DaeryuntalkToastProvider';
|
|
22
23
|
const ChatHomeView = () => {
|
|
23
24
|
const { isAuthenticated, historyList, inquiryMainData, startChat, createNewChat, chatInquiryNumber, sendHeartbeat, sendInquiryLeft, goGetHistoryList, sendHistoryEntered, sendHistoryLeft, startSelectedChat } = useDaeryuntalk();
|
|
24
25
|
const [viewState, setViewState] = useState('home');
|
|
25
26
|
const [mainData, setMainData] = useState(null);
|
|
26
27
|
const [isLoading, setIsLoading] = useState(false);
|
|
28
|
+
const toast = useDearyunTalkToast();
|
|
27
29
|
useEffect(() => {
|
|
28
30
|
if (inquiryMainData) {
|
|
29
31
|
setMainData(inquiryMainData);
|
|
@@ -11,6 +11,7 @@ import DaeryunLogoIcon from '../../asset/images/daeryuntalk/daeryun-logo.svg';
|
|
|
11
11
|
import DaeryuntalkIntro from '../../asset/images/daeryuntalk/daeryuntalk-intro.png';
|
|
12
12
|
import { IChatInquiryMainDataResponse } from './_api/daeryuntalk/type/response';
|
|
13
13
|
import { useChatSocketState } from './_hooks/talkprovider/useChatSocketState';
|
|
14
|
+
import { useDearyunTalkToast } from './Toast/DaeryuntalkToastProvider';
|
|
14
15
|
|
|
15
16
|
type ViewState = 'home' | 'conversation' | 'history';
|
|
16
17
|
|
|
@@ -32,6 +33,7 @@ const ChatHomeView: React.FC = () => {
|
|
|
32
33
|
const [viewState, setViewState] = useState<ViewState>('home');
|
|
33
34
|
const [mainData, setMainData] = useState<IChatInquiryMainDataResponse | null>(null);
|
|
34
35
|
const [isLoading, setIsLoading] = useState(false);
|
|
36
|
+
const toast = useDearyunTalkToast();
|
|
35
37
|
|
|
36
38
|
useEffect(() => {
|
|
37
39
|
if (inquiryMainData) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useRef, useState } from 'react';
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { useDaeryuntalk } from './DaeryuntalkContext';
|
|
3
3
|
import SendIcon from '../../asset/images/daeryuntalk/send.svg';
|
|
4
4
|
import Tiptap, { TiptapEditorRef } from './Tiptap/Tiptap';
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import ChatHomeView from './ChatHomeView';
|
|
3
3
|
import ImageViewer from './Viewer/ImageViewer';
|
|
4
|
+
import { DaeryuntalkToastProvider } from './Toast/DaeryuntalkToastProvider';
|
|
4
5
|
const ChatWidget = ({ isOpen }) => {
|
|
5
6
|
return (<>
|
|
6
7
|
<ImageViewer />
|
|
7
|
-
<div className={`
|
|
8
|
+
<div className={`
|
|
8
9
|
fixed bottom-[110px] right-[30px] z-[999998]
|
|
9
10
|
transition-all duration-300 ease-out
|
|
10
11
|
${isOpen ? 'translate-y-0 scale-100 opacity-100' : 'pointer-events-none translate-y-6 opacity-0'}
|
|
11
12
|
`}>
|
|
12
|
-
<
|
|
13
|
+
<DaeryuntalkToastProvider>
|
|
14
|
+
<ChatHomeView />
|
|
15
|
+
</DaeryuntalkToastProvider>
|
|
13
16
|
</div>
|
|
14
17
|
</>);
|
|
15
18
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import ChatHomeView from './ChatHomeView';
|
|
3
3
|
import ImageViewer from './Viewer/ImageViewer';
|
|
4
|
+
import { DaeryuntalkToastProvider } from './Toast/DaeryuntalkToastProvider';
|
|
4
5
|
|
|
5
6
|
interface ChatWidgetProps {
|
|
6
7
|
isOpen: boolean;
|
|
@@ -11,13 +12,15 @@ const ChatWidget: React.FC<ChatWidgetProps> = ({ isOpen }) => {
|
|
|
11
12
|
<>
|
|
12
13
|
<ImageViewer />
|
|
13
14
|
<div
|
|
14
|
-
className={`
|
|
15
|
+
className={`
|
|
15
16
|
fixed bottom-[110px] right-[30px] z-[999998]
|
|
16
17
|
transition-all duration-300 ease-out
|
|
17
18
|
${isOpen ? 'translate-y-0 scale-100 opacity-100' : 'pointer-events-none translate-y-6 opacity-0'}
|
|
18
19
|
`}
|
|
19
20
|
>
|
|
20
|
-
<
|
|
21
|
+
<DaeryuntalkToastProvider>
|
|
22
|
+
<ChatHomeView />
|
|
23
|
+
</DaeryuntalkToastProvider>
|
|
21
24
|
</div>
|
|
22
25
|
</>
|
|
23
26
|
);
|
|
@@ -12,6 +12,7 @@ import Input2 from '../_ui/inputs/Input2';
|
|
|
12
12
|
import { formatSecondsToMMSS, nameFilter, onlyNumbers, phoneCheck } from '../_lib/utils';
|
|
13
13
|
import Button2 from '../_ui/buttons/Button2';
|
|
14
14
|
import { historyPhoneAuth, requestPhone } from '../_api';
|
|
15
|
+
import { useDearyunTalkToast } from '../Toast/DaeryuntalkToastProvider';
|
|
15
16
|
const AuthForm = ({ goGetHistoryList }) => {
|
|
16
17
|
const [name, setName] = useState({ value: '', isValid: false });
|
|
17
18
|
const [phone, setPhone] = useState({ value: '', isValid: false });
|
|
@@ -19,6 +20,7 @@ const AuthForm = ({ goGetHistoryList }) => {
|
|
|
19
20
|
const [isConfirmState, setIsConfirmState] = useState(false);
|
|
20
21
|
const [timer, setTimer] = useState(180); // 3분(180초)
|
|
21
22
|
const [timerId, setTimerId] = useState(null);
|
|
23
|
+
const toast = useDearyunTalkToast();
|
|
22
24
|
// 3분 인증시간 start 필요
|
|
23
25
|
const handleInput = (e) => {
|
|
24
26
|
const { name: formName, value } = e.currentTarget;
|
|
@@ -76,6 +78,10 @@ const AuthForm = ({ goGetHistoryList }) => {
|
|
|
76
78
|
});
|
|
77
79
|
// 인증번호 확인
|
|
78
80
|
const handleSubmit = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
81
|
+
if (timer < 1) {
|
|
82
|
+
toast.warning('인증 유효 시간이 만료되었습니다.');
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
79
85
|
try {
|
|
80
86
|
const res = yield historyPhoneAuth({
|
|
81
87
|
name: name.value,
|
|
@@ -84,6 +90,7 @@ const AuthForm = ({ goGetHistoryList }) => {
|
|
|
84
90
|
});
|
|
85
91
|
if (res.result_info.result_type_cd === 'OK' || res.result_info.result_cd === 'OK') {
|
|
86
92
|
yield goGetHistoryList({});
|
|
93
|
+
toast.success('인증이 완료되었습니다.');
|
|
87
94
|
}
|
|
88
95
|
}
|
|
89
96
|
catch (e) {
|
|
@@ -129,7 +136,9 @@ const AuthForm = ({ goGetHistoryList }) => {
|
|
|
129
136
|
</div>)}
|
|
130
137
|
|
|
131
138
|
{isConfirmState && (<div className="mt-[40px]">
|
|
132
|
-
<button disabled={authNumber.length < 5} className="flex w-full items-center justify-center gap-2.5 rounded-[25px] bg-[#2E385B] px-6 py-3 text-white
|
|
139
|
+
<button disabled={authNumber.length < 5} className="flex w-full items-center justify-center gap-2.5 rounded-[25px] bg-[#2E385B] px-6 py-3 text-white
|
|
140
|
+
disabled:bg-[#D2D2D2]
|
|
141
|
+
" onClick={handleSubmit}>
|
|
133
142
|
인증번호 확인
|
|
134
143
|
</button>
|
|
135
144
|
</div>)}
|
|
@@ -3,6 +3,7 @@ import Input2 from '../_ui/inputs/Input2';
|
|
|
3
3
|
import { formatSecondsToMMSS, nameFilter, onlyNumbers, phoneCheck } from '../_lib/utils';
|
|
4
4
|
import Button2 from '../_ui/buttons/Button2';
|
|
5
5
|
import { historyPhoneAuth, requestPhone } from '../_api';
|
|
6
|
+
import { useDearyunTalkToast } from '../Toast/DaeryuntalkToastProvider';
|
|
6
7
|
|
|
7
8
|
interface IProps {
|
|
8
9
|
goGetHistoryList: (data: { version?: string }) => void;
|
|
@@ -14,6 +15,7 @@ const AuthForm = ({ goGetHistoryList }: IProps) => {
|
|
|
14
15
|
const [isConfirmState, setIsConfirmState] = useState<boolean>(false);
|
|
15
16
|
const [timer, setTimer] = useState<number>(180); // 3분(180초)
|
|
16
17
|
const [timerId, setTimerId] = useState<NodeJS.Timeout | null>(null);
|
|
18
|
+
const toast = useDearyunTalkToast();
|
|
17
19
|
|
|
18
20
|
// 3분 인증시간 start 필요
|
|
19
21
|
|
|
@@ -72,6 +74,11 @@ const AuthForm = ({ goGetHistoryList }: IProps) => {
|
|
|
72
74
|
|
|
73
75
|
// 인증번호 확인
|
|
74
76
|
const handleSubmit = async () => {
|
|
77
|
+
if (timer < 1) {
|
|
78
|
+
toast.warning('인증 유효 시간이 만료되었습니다.');
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
75
82
|
try {
|
|
76
83
|
const res = await historyPhoneAuth({
|
|
77
84
|
name: name.value,
|
|
@@ -80,6 +87,7 @@ const AuthForm = ({ goGetHistoryList }: IProps) => {
|
|
|
80
87
|
});
|
|
81
88
|
if (res.result_info.result_type_cd === 'OK' || res.result_info.result_cd === 'OK') {
|
|
82
89
|
await goGetHistoryList({});
|
|
90
|
+
toast.success('인증이 완료되었습니다.');
|
|
83
91
|
}
|
|
84
92
|
} catch (e) {
|
|
85
93
|
console.error('e', e);
|
|
@@ -170,7 +178,9 @@ const AuthForm = ({ goGetHistoryList }: IProps) => {
|
|
|
170
178
|
<div className="mt-[40px]">
|
|
171
179
|
<button
|
|
172
180
|
disabled={authNumber.length < 5}
|
|
173
|
-
className="flex w-full items-center justify-center gap-2.5 rounded-[25px] bg-[#2E385B] px-6 py-3 text-white
|
|
181
|
+
className="flex w-full items-center justify-center gap-2.5 rounded-[25px] bg-[#2E385B] px-6 py-3 text-white
|
|
182
|
+
disabled:bg-[#D2D2D2]
|
|
183
|
+
"
|
|
174
184
|
onClick={handleSubmit}
|
|
175
185
|
>
|
|
176
186
|
인증번호 확인
|
|
@@ -48,9 +48,15 @@ const HistoryView = ({ onBackClick, onChatHistoryClick, onNewChatClick, isAuthen
|
|
|
48
48
|
<div className="flex-1 overflow-y-auto px-[20px] pb-[20px] pt-[24px]">
|
|
49
49
|
{hasHistories ? (historyLit.map(history => (<div key={history.chat_inquiry_number} className="cursor-pointer border-b border-gray-100 px-[12px] py-[18px] hover:bg-gray-50" onClick={() => onChatHistoryClick(history.chat_inquiry_number)}>
|
|
50
50
|
<div className="flex items-center justify-between">
|
|
51
|
-
<
|
|
51
|
+
<div className={`flex flex-row items-center gap-[10px]`}>
|
|
52
|
+
<span className="font-medium">{history.customer_name}</span>
|
|
53
|
+
{history.unread_message_count && history.unread_message_count > 0 ? (<span className="flex h-[18px] w-[18px] items-center justify-center rounded-full bg-[#AA1D36] px-[5.5px] py-[3px] text-[12px] font-medium leading-[100%] tracking-[-4%] text-white">
|
|
54
|
+
{history.unread_message_count}
|
|
55
|
+
</span>) : null}
|
|
56
|
+
</div>
|
|
52
57
|
<span className="text-xs text-gray-500">
|
|
53
58
|
{formatTimestamp(history.recent_message_date_time)}
|
|
59
|
+
{/*{history.unread_message_count}*/}
|
|
54
60
|
</span>
|
|
55
61
|
</div>
|
|
56
62
|
<div className="mt-1 flex items-center justify-between">
|
|
@@ -85,9 +85,17 @@ const HistoryView: React.FC<HistoryViewProps> = ({
|
|
|
85
85
|
onClick={() => onChatHistoryClick(history.chat_inquiry_number)}
|
|
86
86
|
>
|
|
87
87
|
<div className="flex items-center justify-between">
|
|
88
|
-
<
|
|
88
|
+
<div className={`flex flex-row items-center gap-[10px]`}>
|
|
89
|
+
<span className="font-medium">{history.customer_name}</span>
|
|
90
|
+
{history.unread_message_count && history.unread_message_count > 0 ? (
|
|
91
|
+
<span className="flex h-[18px] w-[18px] items-center justify-center rounded-full bg-[#AA1D36] px-[5.5px] py-[3px] text-[12px] font-medium leading-[100%] tracking-[-4%] text-white">
|
|
92
|
+
{history.unread_message_count}
|
|
93
|
+
</span>
|
|
94
|
+
) : null}
|
|
95
|
+
</div>
|
|
89
96
|
<span className="text-xs text-gray-500">
|
|
90
97
|
{formatTimestamp(history.recent_message_date_time)}
|
|
98
|
+
{/*{history.unread_message_count}*/}
|
|
91
99
|
</span>
|
|
92
100
|
</div>
|
|
93
101
|
<div className="mt-1 flex items-center justify-between">
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEditor, EditorContent } from '@tiptap/react';
|
|
2
2
|
import Placeholder from '@tiptap/extension-placeholder';
|
|
3
|
-
import { useImperativeHandle, forwardRef } from 'react';
|
|
3
|
+
import { useImperativeHandle, forwardRef, useEffect } from 'react';
|
|
4
4
|
import Document from '@tiptap/extension-document';
|
|
5
5
|
import Paragraph from '@tiptap/extension-paragraph';
|
|
6
6
|
import Text from '@tiptap/extension-text';
|
|
@@ -40,6 +40,14 @@ const Tiptap = forwardRef(({ onChange, placeholder = '메시지를 입력하세
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
|
+
// 최초 렌더시 포커스 설정
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (editor) {
|
|
46
|
+
editor === null || editor === void 0 ? void 0 : editor.commands.clearContent(true);
|
|
47
|
+
// 내용을 지운 후 포커스 유지
|
|
48
|
+
editor === null || editor === void 0 ? void 0 : editor.commands.focus();
|
|
49
|
+
}
|
|
50
|
+
}, [editor]);
|
|
43
51
|
useImperativeHandle(ref, () => ({
|
|
44
52
|
clearContent: () => {
|
|
45
53
|
editor === null || editor === void 0 ? void 0 : editor.commands.clearContent(true);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useEditor, EditorContent } from '@tiptap/react';
|
|
2
2
|
import StarterKit from '@tiptap/starter-kit';
|
|
3
3
|
import Placeholder from '@tiptap/extension-placeholder';
|
|
4
|
-
import { useImperativeHandle, forwardRef } from 'react';
|
|
4
|
+
import { useImperativeHandle, forwardRef, useEffect } from 'react';
|
|
5
5
|
import { JSONContent } from '@tiptap/core'; // 추가 필요
|
|
6
6
|
import Document from '@tiptap/extension-document';
|
|
7
7
|
import Paragraph from '@tiptap/extension-paragraph';
|
|
@@ -62,6 +62,15 @@ const Tiptap = forwardRef<TiptapEditorRef, TiptapProps>(
|
|
|
62
62
|
}
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
+
// 최초 렌더시 포커스 설정
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (editor) {
|
|
68
|
+
editor?.commands.clearContent(true);
|
|
69
|
+
// 내용을 지운 후 포커스 유지
|
|
70
|
+
editor?.commands.focus();
|
|
71
|
+
}
|
|
72
|
+
}, [editor]);
|
|
73
|
+
|
|
65
74
|
useImperativeHandle(ref, () => ({
|
|
66
75
|
clearContent: () => {
|
|
67
76
|
editor?.commands.clearContent(true);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
interface ToastContextProps {
|
|
3
|
+
success: (title: string, description?: string, duration?: number) => void;
|
|
4
|
+
warning: (title: string, description?: string, duration?: number) => void;
|
|
5
|
+
error: (title: string, description?: string, duration?: number) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const useDearyunTalkToast: () => ToastContextProps;
|
|
8
|
+
interface ToastProviderProps {
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
}
|
|
11
|
+
export declare const DaeryuntalkToastProvider: ({ children }: ToastProviderProps) => import("react").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { createContext, useContext, useState } from 'react';
|
|
2
|
+
import DaeryunTalkToast from './Toast';
|
|
3
|
+
export const useDearyunTalkToast = () => {
|
|
4
|
+
const context = useContext(ToastContext);
|
|
5
|
+
if (!context) {
|
|
6
|
+
throw new Error('토스트 프로바이더 설정이 필요합니다.');
|
|
7
|
+
}
|
|
8
|
+
return context;
|
|
9
|
+
};
|
|
10
|
+
const ToastContext = createContext(undefined);
|
|
11
|
+
export const DaeryuntalkToastProvider = ({ children }) => {
|
|
12
|
+
const [toast, setToast] = useState(null);
|
|
13
|
+
const [isVisible, setIsVisible] = useState(false);
|
|
14
|
+
const showToast = (type, title, description, duration = 3000) => {
|
|
15
|
+
setToast({ type, title, description, duration });
|
|
16
|
+
setIsVisible(true);
|
|
17
|
+
setTimeout(() => {
|
|
18
|
+
setIsVisible(false);
|
|
19
|
+
setTimeout(() => setToast(null), 300); // exit transition
|
|
20
|
+
}, duration);
|
|
21
|
+
};
|
|
22
|
+
const success = (title, description, duration) => showToast('success', title, description, duration);
|
|
23
|
+
const warning = (title, description, duration) => showToast('warning', title, description, duration);
|
|
24
|
+
const error = (title, description, duration) => showToast('error', title, description, duration);
|
|
25
|
+
return (<ToastContext.Provider value={{ success, warning, error }}>
|
|
26
|
+
{children}
|
|
27
|
+
<div className="absolute bottom-0 left-1/2 z-50 w-[90%] -translate-x-1/2 rounded-[25px]">
|
|
28
|
+
<div className={`transition-all duration-300 ${isVisible ? '-translate-y-[96px] opacity-100' : 'pointer-events-none translate-y-0 opacity-0'}`}>
|
|
29
|
+
{toast && <DaeryunTalkToast {...toast} onClose={() => setIsVisible(false)}/>}
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
</ToastContext.Provider>);
|
|
33
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { createContext, ReactNode, useContext, useState } from 'react';
|
|
2
|
+
import DaeryunTalkToast from './Toast';
|
|
3
|
+
|
|
4
|
+
type ToastType = 'success' | 'warning' | 'error';
|
|
5
|
+
|
|
6
|
+
interface ToastItem {
|
|
7
|
+
type: ToastType;
|
|
8
|
+
title: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
duration?: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface ToastContextProps {
|
|
14
|
+
success: (title: string, description?: string, duration?: number) => void;
|
|
15
|
+
warning: (title: string, description?: string, duration?: number) => void;
|
|
16
|
+
error: (title: string, description?: string, duration?: number) => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const useDearyunTalkToast = () => {
|
|
20
|
+
const context = useContext(ToastContext);
|
|
21
|
+
if (!context) {
|
|
22
|
+
throw new Error('토스트 프로바이더 설정이 필요합니다.');
|
|
23
|
+
}
|
|
24
|
+
return context;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const ToastContext = createContext<ToastContextProps | undefined>(undefined);
|
|
28
|
+
|
|
29
|
+
interface ToastProviderProps {
|
|
30
|
+
children: ReactNode;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const DaeryuntalkToastProvider = ({ children }: ToastProviderProps) => {
|
|
34
|
+
const [toast, setToast] = useState<ToastItem | null>(null);
|
|
35
|
+
const [isVisible, setIsVisible] = useState(false);
|
|
36
|
+
|
|
37
|
+
const showToast = (type: ToastType, title: string, description?: string, duration: number = 3000) => {
|
|
38
|
+
setToast({ type, title, description, duration });
|
|
39
|
+
setIsVisible(true);
|
|
40
|
+
setTimeout(() => {
|
|
41
|
+
setIsVisible(false);
|
|
42
|
+
setTimeout(() => setToast(null), 300); // exit transition
|
|
43
|
+
}, duration);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const success = (title: string, description?: string, duration?: number) =>
|
|
47
|
+
showToast('success', title, description, duration);
|
|
48
|
+
const warning = (title: string, description?: string, duration?: number) =>
|
|
49
|
+
showToast('warning', title, description, duration);
|
|
50
|
+
const error = (title: string, description?: string, duration?: number) =>
|
|
51
|
+
showToast('error', title, description, duration);
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<ToastContext.Provider value={{ success, warning, error }}>
|
|
55
|
+
{children}
|
|
56
|
+
<div className="absolute bottom-0 left-1/2 z-50 w-[90%] -translate-x-1/2 rounded-[25px]">
|
|
57
|
+
<div
|
|
58
|
+
className={`transition-all duration-300 ${
|
|
59
|
+
isVisible ? '-translate-y-[96px] opacity-100' : 'pointer-events-none translate-y-0 opacity-0'
|
|
60
|
+
}`}
|
|
61
|
+
>
|
|
62
|
+
{toast && <DaeryunTalkToast {...toast} onClose={() => setIsVisible(false)} />}
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
</ToastContext.Provider>
|
|
66
|
+
);
|
|
67
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type ToastType = 'success' | 'warning' | 'error';
|
|
3
|
+
interface ToastProps {
|
|
4
|
+
type: ToastType;
|
|
5
|
+
title: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
duration?: number;
|
|
8
|
+
onClose: () => void;
|
|
9
|
+
}
|
|
10
|
+
declare const _default: React.MemoExoticComponent<({ type, title, description, duration, onClose }: ToastProps) => React.JSX.Element>;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
// 1. 함수 이름을 PascalCase로 변경
|
|
3
|
+
const WarningIcon = ({ className = '' }) => {
|
|
4
|
+
return (<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" className={className}>
|
|
5
|
+
<g clipPath="url(#clip0_1775_25245)">
|
|
6
|
+
<path d="M3 12C3 13.1819 3.23279 14.3522 3.68508 15.4442C4.13738 16.5361 4.80031 17.5282 5.63604 18.364C6.47177 19.1997 7.46392 19.8626 8.55585 20.3149C9.64778 20.7672 10.8181 21 12 21C13.1819 21 14.3522 20.7672 15.4442 20.3149C16.5361 19.8626 17.5282 19.1997 18.364 18.364C19.1997 17.5282 19.8626 16.5361 20.3149 15.4442C20.7672 14.3522 21 13.1819 21 12C21 9.61305 20.0518 7.32387 18.364 5.63604C16.6761 3.94821 14.3869 3 12 3C9.61305 3 7.32387 3.94821 5.63604 5.63604C3.94821 7.32387 3 9.61305 3 12Z" stroke="white" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
|
|
7
|
+
<path d="M12 16V16.01" stroke="white" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
|
|
8
|
+
<path d="M12 8.5L12 13" stroke="white" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"/>
|
|
9
|
+
</g>
|
|
10
|
+
<defs>
|
|
11
|
+
<clipPath id="clip0_1775_25245">
|
|
12
|
+
<rect width="24" height="24" fill="white"/>
|
|
13
|
+
</clipPath>
|
|
14
|
+
</defs>
|
|
15
|
+
</svg>);
|
|
16
|
+
};
|
|
17
|
+
const ICONS = {
|
|
18
|
+
success: <WarningIcon className="h-6 w-6 text-white"/>,
|
|
19
|
+
warning: <WarningIcon className="h-6 w-6 text-white"/>,
|
|
20
|
+
error: <WarningIcon className="h-6 w-6 text-white"/>
|
|
21
|
+
};
|
|
22
|
+
const DaeryunTalkToast = ({ type, title, description, duration = 3000, onClose }) => {
|
|
23
|
+
const timerRef = useRef(null);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (timerRef.current) {
|
|
26
|
+
clearTimeout(timerRef === null || timerRef === void 0 ? void 0 : timerRef.current);
|
|
27
|
+
}
|
|
28
|
+
const timer = setTimeout(() => {
|
|
29
|
+
onClose();
|
|
30
|
+
}, duration || 3000);
|
|
31
|
+
timerRef.current = timer;
|
|
32
|
+
return () => {
|
|
33
|
+
clearTimeout(timer);
|
|
34
|
+
};
|
|
35
|
+
}, [duration, onClose]);
|
|
36
|
+
const closeToast = () => {
|
|
37
|
+
if (timerRef.current) {
|
|
38
|
+
clearTimeout(timerRef.current);
|
|
39
|
+
timerRef.current = null;
|
|
40
|
+
}
|
|
41
|
+
onClose();
|
|
42
|
+
};
|
|
43
|
+
return (<>
|
|
44
|
+
<div className=" flex h-[48px] w-full items-center justify-center space-x-[6px] rounded-[25px] bg-[#505050] text-white">
|
|
45
|
+
<div className="mt-0.5 flex-shrink-0">{ICONS[type]}</div>
|
|
46
|
+
<div className="flex">
|
|
47
|
+
<h3 className="text-[14px] font-[400] leading-[130%] tracking-[-4%]">{title}</h3>
|
|
48
|
+
{/*{description && <p className="mt-0.5 text-sm text-white text-opacity-90">{description}</p>}*/}
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
{/*<button*/}
|
|
52
|
+
{/* onClick={closeToast}*/}
|
|
53
|
+
{/* className="ml-3 flex-shrink-0 rounded-full bg-white bg-opacity-10 p-1 hover:bg-opacity-20"*/}
|
|
54
|
+
{/*>*/}
|
|
55
|
+
{/* <svg className="h-4 w-4 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor">*/}
|
|
56
|
+
{/* <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />*/}
|
|
57
|
+
{/* </svg>*/}
|
|
58
|
+
{/*</button>*/}
|
|
59
|
+
</>);
|
|
60
|
+
};
|
|
61
|
+
export default React.memo(DaeryunTalkToast);
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
type ToastType = 'success' | 'warning' | 'error';
|
|
3
|
+
|
|
4
|
+
interface ToastProps {
|
|
5
|
+
type: ToastType;
|
|
6
|
+
title: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
duration?: number;
|
|
9
|
+
onClose: () => void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// 1. 함수 이름을 PascalCase로 변경
|
|
13
|
+
const WarningIcon = ({ className = '' }: { className?: string }) => {
|
|
14
|
+
return (
|
|
15
|
+
<svg
|
|
16
|
+
width="24"
|
|
17
|
+
height="24"
|
|
18
|
+
viewBox="0 0 24 24"
|
|
19
|
+
fill="none"
|
|
20
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
21
|
+
className={className}
|
|
22
|
+
>
|
|
23
|
+
<g clipPath="url(#clip0_1775_25245)">
|
|
24
|
+
<path
|
|
25
|
+
d="M3 12C3 13.1819 3.23279 14.3522 3.68508 15.4442C4.13738 16.5361 4.80031 17.5282 5.63604 18.364C6.47177 19.1997 7.46392 19.8626 8.55585 20.3149C9.64778 20.7672 10.8181 21 12 21C13.1819 21 14.3522 20.7672 15.4442 20.3149C16.5361 19.8626 17.5282 19.1997 18.364 18.364C19.1997 17.5282 19.8626 16.5361 20.3149 15.4442C20.7672 14.3522 21 13.1819 21 12C21 9.61305 20.0518 7.32387 18.364 5.63604C16.6761 3.94821 14.3869 3 12 3C9.61305 3 7.32387 3.94821 5.63604 5.63604C3.94821 7.32387 3 9.61305 3 12Z"
|
|
26
|
+
stroke="white"
|
|
27
|
+
strokeWidth="2"
|
|
28
|
+
strokeLinecap="round"
|
|
29
|
+
strokeLinejoin="round"
|
|
30
|
+
/>
|
|
31
|
+
<path d="M12 16V16.01" stroke="white" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
|
|
32
|
+
<path d="M12 8.5L12 13" stroke="white" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
|
|
33
|
+
</g>
|
|
34
|
+
<defs>
|
|
35
|
+
<clipPath id="clip0_1775_25245">
|
|
36
|
+
<rect width="24" height="24" fill="white" />
|
|
37
|
+
</clipPath>
|
|
38
|
+
</defs>
|
|
39
|
+
</svg>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const ICONS = {
|
|
44
|
+
success: <WarningIcon className="h-6 w-6 text-white" />,
|
|
45
|
+
warning: <WarningIcon className="h-6 w-6 text-white" />,
|
|
46
|
+
error: <WarningIcon className="h-6 w-6 text-white" />
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const DaeryunTalkToast = ({ type, title, description, duration = 3000, onClose }: ToastProps) => {
|
|
50
|
+
const timerRef = useRef<NodeJS.Timeout | null>(null);
|
|
51
|
+
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (timerRef.current) {
|
|
54
|
+
clearTimeout(timerRef?.current!);
|
|
55
|
+
}
|
|
56
|
+
const timer = setTimeout(() => {
|
|
57
|
+
onClose();
|
|
58
|
+
}, duration || 3000);
|
|
59
|
+
timerRef.current = timer;
|
|
60
|
+
return () => {
|
|
61
|
+
clearTimeout(timer);
|
|
62
|
+
};
|
|
63
|
+
}, [duration, onClose]);
|
|
64
|
+
|
|
65
|
+
const closeToast = () => {
|
|
66
|
+
if (timerRef.current) {
|
|
67
|
+
clearTimeout(timerRef.current!);
|
|
68
|
+
timerRef.current = null;
|
|
69
|
+
}
|
|
70
|
+
onClose();
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<>
|
|
75
|
+
<div className=" flex h-[48px] w-full items-center justify-center space-x-[6px] rounded-[25px] bg-[#505050] text-white">
|
|
76
|
+
<div className="mt-0.5 flex-shrink-0">{ICONS[type]}</div>
|
|
77
|
+
<div className="flex">
|
|
78
|
+
<h3 className="text-[14px] font-[400] leading-[130%] tracking-[-4%]">{title}</h3>
|
|
79
|
+
{/*{description && <p className="mt-0.5 text-sm text-white text-opacity-90">{description}</p>}*/}
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
{/*<button*/}
|
|
83
|
+
{/* onClick={closeToast}*/}
|
|
84
|
+
{/* className="ml-3 flex-shrink-0 rounded-full bg-white bg-opacity-10 p-1 hover:bg-opacity-20"*/}
|
|
85
|
+
{/*>*/}
|
|
86
|
+
{/* <svg className="h-4 w-4 text-white" fill="none" viewBox="0 0 24 24" stroke="currentColor">*/}
|
|
87
|
+
{/* <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />*/}
|
|
88
|
+
{/* </svg>*/}
|
|
89
|
+
{/*</button>*/}
|
|
90
|
+
</>
|
|
91
|
+
);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export default React.memo(DaeryunTalkToast);
|
package/dist/styles/globals.css
CHANGED
|
@@ -1539,6 +1539,10 @@ video {
|
|
|
1539
1539
|
margin-top: 0px;
|
|
1540
1540
|
}
|
|
1541
1541
|
|
|
1542
|
+
.mt-0\.5 {
|
|
1543
|
+
margin-top: 0.125rem;
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1542
1546
|
.mt-1 {
|
|
1543
1547
|
margin-top: 0.25rem;
|
|
1544
1548
|
}
|
|
@@ -3322,6 +3326,11 @@ video {
|
|
|
3322
3326
|
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
|
3323
3327
|
}
|
|
3324
3328
|
|
|
3329
|
+
.-translate-y-\[96px\] {
|
|
3330
|
+
--tw-translate-y: -96px;
|
|
3331
|
+
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
|
3332
|
+
}
|
|
3333
|
+
|
|
3325
3334
|
.translate-x-\[-1px\] {
|
|
3326
3335
|
--tw-translate-x: -1px;
|
|
3327
3336
|
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
|
@@ -3990,6 +3999,12 @@ video {
|
|
|
3990
3999
|
margin-left: calc(1rem * calc(1 - var(--tw-space-x-reverse)));
|
|
3991
4000
|
}
|
|
3992
4001
|
|
|
4002
|
+
.space-x-\[6px\] > :not([hidden]) ~ :not([hidden]) {
|
|
4003
|
+
--tw-space-x-reverse: 0;
|
|
4004
|
+
margin-right: calc(6px * var(--tw-space-x-reverse));
|
|
4005
|
+
margin-left: calc(6px * calc(1 - var(--tw-space-x-reverse)));
|
|
4006
|
+
}
|
|
4007
|
+
|
|
3993
4008
|
.overflow-hidden {
|
|
3994
4009
|
overflow: hidden;
|
|
3995
4010
|
}
|
|
@@ -4684,6 +4699,11 @@ video {
|
|
|
4684
4699
|
background-color: rgb(65 70 76 / var(--tw-bg-opacity, 1));
|
|
4685
4700
|
}
|
|
4686
4701
|
|
|
4702
|
+
.bg-\[\#505050\] {
|
|
4703
|
+
--tw-bg-opacity: 1;
|
|
4704
|
+
background-color: rgb(80 80 80 / var(--tw-bg-opacity, 1));
|
|
4705
|
+
}
|
|
4706
|
+
|
|
4687
4707
|
.bg-\[\#545454\] {
|
|
4688
4708
|
--tw-bg-opacity: 1;
|
|
4689
4709
|
background-color: rgb(84 84 84 / var(--tw-bg-opacity, 1));
|
|
@@ -5457,6 +5477,11 @@ video {
|
|
|
5457
5477
|
padding-right: 48px;
|
|
5458
5478
|
}
|
|
5459
5479
|
|
|
5480
|
+
.px-\[5\.5px\] {
|
|
5481
|
+
padding-left: 5.5px;
|
|
5482
|
+
padding-right: 5.5px;
|
|
5483
|
+
}
|
|
5484
|
+
|
|
5460
5485
|
.px-\[50px\] {
|
|
5461
5486
|
padding-left: 50px;
|
|
5462
5487
|
padding-right: 50px;
|
|
@@ -5602,6 +5627,11 @@ video {
|
|
|
5602
5627
|
padding-bottom: 36px;
|
|
5603
5628
|
}
|
|
5604
5629
|
|
|
5630
|
+
.py-\[3px\] {
|
|
5631
|
+
padding-top: 3px;
|
|
5632
|
+
padding-bottom: 3px;
|
|
5633
|
+
}
|
|
5634
|
+
|
|
5605
5635
|
.py-\[400px\] {
|
|
5606
5636
|
padding-top: 400px;
|
|
5607
5637
|
padding-bottom: 400px;
|
|
@@ -6951,6 +6981,10 @@ video {
|
|
|
6951
6981
|
color: rgb(255 255 255 / 0.8);
|
|
6952
6982
|
}
|
|
6953
6983
|
|
|
6984
|
+
.text-opacity-90 {
|
|
6985
|
+
--tw-text-opacity: 0.9;
|
|
6986
|
+
}
|
|
6987
|
+
|
|
6954
6988
|
.underline {
|
|
6955
6989
|
text-decoration-line: underline;
|
|
6956
6990
|
}
|
|
@@ -8306,6 +8340,10 @@ body {
|
|
|
8306
8340
|
background-color: rgb(245 245 245 / var(--tw-bg-opacity, 1));
|
|
8307
8341
|
}
|
|
8308
8342
|
|
|
8343
|
+
.hover\:bg-opacity-20:hover {
|
|
8344
|
+
--tw-bg-opacity: 0.2;
|
|
8345
|
+
}
|
|
8346
|
+
|
|
8309
8347
|
.hover\:font-\[700\]:hover {
|
|
8310
8348
|
font-weight: 700;
|
|
8311
8349
|
}
|