@daeryun/dr_components 0.7.95 → 0.7.96

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.
@@ -68,6 +68,7 @@ const ChatConversation = ({ onBackClick, onChatNew, isActive }) => {
68
68
  });
69
69
  return elements;
70
70
  };
71
+ //
71
72
  const handleBackClick = () => {
72
73
  if (onBackClick) {
73
74
  onBackClick();
@@ -116,6 +116,7 @@ const ChatConversation: React.FC<ChatConversationProps> = ({ onBackClick, onChat
116
116
  return elements;
117
117
  };
118
118
 
119
+ //
119
120
  const handleBackClick = () => {
120
121
  if (onBackClick) {
121
122
  onBackClick();
@@ -19,9 +19,9 @@ 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';
23
22
  import { useScrollShadow } from './_hooks/useScrollShadow';
24
23
  import ShadowBox from './_ui/ShadowBox';
24
+ import { useDaeryunTalkToast } from './Toast/DaeryuntalkToastProvider';
25
25
  const ChatHomeView = () => {
26
26
  const { isAuthenticated, historyList, inquiryMainData, startChat, createNewChat, chatInquiryNumber, sendHeartbeat, sendInquiryLeft, goGetHistoryList, sendHistoryEntered, sendHistoryLeft, startSelectedChat } = useDaeryuntalk();
27
27
  const [viewState, setViewState] = useState('home');
@@ -31,7 +31,7 @@ const ChatHomeView = () => {
31
31
  useEffect(() => {
32
32
  checkScroll();
33
33
  }, [mainData]);
34
- const toast = useDearyunTalkToast();
34
+ const toast = useDaeryunTalkToast();
35
35
  useEffect(() => {
36
36
  if (viewState === 'history') {
37
37
  goGetHistoryList({});
@@ -11,9 +11,9 @@ 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';
15
14
  import { useScrollShadow } from './_hooks/useScrollShadow';
16
15
  import ShadowBox from './_ui/ShadowBox';
16
+ import { useDaeryunTalkToast } from './Toast/DaeryuntalkToastProvider';
17
17
 
18
18
  type ViewState = 'home' | 'conversation' | 'history';
19
19
 
@@ -40,7 +40,7 @@ const ChatHomeView: React.FC = () => {
40
40
  checkScroll();
41
41
  }, [mainData]);
42
42
 
43
- const toast = useDearyunTalkToast();
43
+ const toast = useDaeryunTalkToast();
44
44
 
45
45
  useEffect(() => {
46
46
  if (viewState === 'history') {
@@ -3,6 +3,7 @@ import ChatHomeView from './ChatHomeView';
3
3
  import ImageViewer from './Viewer/ImageViewer';
4
4
  import { useScrollShadow } from './_hooks/useScrollShadow';
5
5
  import ShadowBox from './_ui/ShadowBox';
6
+ import ToastRenderer from './Toast/ToastRender';
6
7
  const ChatWidget = ({ isOpen }) => {
7
8
  const { containerRef, isScroll, isBottom } = useScrollShadow();
8
9
  return (<>
@@ -22,6 +23,7 @@ const ChatWidget = ({ isOpen }) => {
22
23
 
23
24
  {/* 투명 그라데이션 그림자 표시 */}
24
25
  {!isScroll && !isBottom && <ShadowBox />}
26
+ <ToastRenderer />
25
27
  </div>
26
28
  </div>
27
29
  </>);
@@ -4,6 +4,7 @@ import ImageViewer from './Viewer/ImageViewer';
4
4
  import { DaeryuntalkToastProvider } from './Toast/DaeryuntalkToastProvider';
5
5
  import { useScrollShadow } from './_hooks/useScrollShadow';
6
6
  import ShadowBox from './_ui/ShadowBox';
7
+ import ToastRenderer from './Toast/ToastRender';
7
8
 
8
9
  interface ChatWidgetProps {
9
10
  isOpen: boolean;
@@ -31,6 +32,7 @@ const ChatWidget: React.FC<ChatWidgetProps> = ({ isOpen }) => {
31
32
 
32
33
  {/* 투명 그라데이션 그림자 표시 */}
33
34
  {!isScroll && !isBottom && <ShadowBox />}
35
+ <ToastRenderer />
34
36
  </div>
35
37
  </div>
36
38
  </>
@@ -12,8 +12,8 @@ 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';
16
15
  import { AuthErrorCode } from '../_enums/error_code';
16
+ import { useDaeryunTalkToast } from '../Toast/DaeryuntalkToastProvider';
17
17
  const AuthForm = ({ goGetHistoryList }) => {
18
18
  const [name, setName] = useState({ value: '', isValid: false });
19
19
  const [phone, setPhone] = useState({ value: '', isValid: false });
@@ -22,7 +22,7 @@ const AuthForm = ({ goGetHistoryList }) => {
22
22
  const [timer, setTimer] = useState(180); // 3분(180초)
23
23
  const [timerId, setTimerId] = useState(null);
24
24
  const [isLoading, setIsLoading] = useState(false);
25
- const toast = useDearyunTalkToast();
25
+ const toast = useDaeryunTalkToast();
26
26
  const resetTimerAndState = () => {
27
27
  if (timerId)
28
28
  clearInterval(timerId);
@@ -3,9 +3,8 @@ 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';
7
- import { isSetIterator } from 'util/types';
8
6
  import { AuthErrorCode } from '../_enums/error_code';
7
+ import { useDaeryunTalkToast } from '../Toast/DaeryuntalkToastProvider';
9
8
 
10
9
  interface IProps {
11
10
  goGetHistoryList: (data: { version?: string }) => void;
@@ -19,8 +18,7 @@ const AuthForm = ({ goGetHistoryList }: IProps) => {
19
18
  const [timerId, setTimerId] = useState<NodeJS.Timeout | null>(null);
20
19
  const [isLoading, setIsLoading] = useState(false);
21
20
 
22
- const toast = useDearyunTalkToast();
23
-
21
+ const toast = useDaeryunTalkToast();
24
22
  const resetTimerAndState = () => {
25
23
  if (timerId) clearInterval(timerId);
26
24
  setTimer(180);
@@ -1,12 +1,22 @@
1
1
  import { ReactNode } from 'react';
2
+ export type ToastType = 'success' | 'warning' | 'error';
3
+ interface ToastItem {
4
+ type: ToastType;
5
+ title: string;
6
+ description?: string;
7
+ duration?: number;
8
+ }
2
9
  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;
10
+ toast: ToastItem | null;
11
+ isVisible: boolean;
12
+ hideToast: () => void;
13
+ success: (title: string, desc?: string, duration?: number) => void;
14
+ warning: (title: string, desc?: string, duration?: number) => void;
15
+ error: (title: string, desc?: string, duration?: number) => void;
6
16
  }
7
- export declare const useDearyunTalkToast: () => ToastContextProps;
8
- interface ToastProviderProps {
17
+ export declare const ToastContext: import("react").Context<ToastContextProps | undefined>;
18
+ export declare const useDaeryunTalkToast: () => ToastContextProps;
19
+ export declare const DaeryuntalkToastProvider: ({ children }: {
9
20
  children: ReactNode;
10
- }
11
- export declare const DaeryuntalkToastProvider: ({ children }: ToastProviderProps) => import("react").JSX.Element;
21
+ }) => import("react").JSX.Element;
12
22
  export {};
@@ -1,33 +1,29 @@
1
+ // ./Toast/DaeryuntalkToastProvider.tsx
2
+ 'use client';
1
3
  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;
4
+ export const ToastContext = createContext(undefined);
5
+ export const useDaeryunTalkToast = () => {
6
+ const ctx = useContext(ToastContext);
7
+ if (!ctx)
8
+ throw new Error('ToastContext가 없습니다.');
9
+ return ctx;
9
10
  };
10
- const ToastContext = createContext(undefined);
11
11
  export const DaeryuntalkToastProvider = ({ children }) => {
12
12
  const [toast, setToast] = useState(null);
13
13
  const [isVisible, setIsVisible] = useState(false);
14
+ const hideToast = () => setIsVisible(false);
14
15
  const showToast = (type, title, description, duration = 3000) => {
15
16
  setToast({ type, title, description, duration });
16
17
  setIsVisible(true);
17
18
  setTimeout(() => {
18
19
  setIsVisible(false);
19
- setTimeout(() => setToast(null), 300); // exit transition
20
+ setTimeout(() => setToast(null), 300);
20
21
  }, duration);
21
22
  };
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 }}>
23
+ const success = (title, d, t) => showToast('success', title, d, t);
24
+ const warning = (title, d, t) => showToast('warning', title, d, t);
25
+ const error = (title, d, t) => showToast('error', title, d, t);
26
+ return (<ToastContext.Provider value={{ toast, isVisible, hideToast, success, warning, error }}>
26
27
  {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
28
  </ToastContext.Provider>);
33
29
  };
@@ -1,8 +1,8 @@
1
- import { createContext, ReactNode, useContext, useState } from 'react';
2
- import DaeryunTalkToast from './Toast';
3
-
4
- type ToastType = 'success' | 'warning' | 'error';
1
+ // ./Toast/DaeryuntalkToastProvider.tsx
2
+ 'use client';
5
3
 
4
+ import { createContext, useContext, useState, ReactNode } from 'react';
5
+ export type ToastType = 'success' | 'warning' | 'error';
6
6
  interface ToastItem {
7
7
  type: ToastType;
8
8
  title: string;
@@ -11,57 +11,44 @@ interface ToastItem {
11
11
  }
12
12
 
13
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;
14
+ toast: ToastItem | null;
15
+ isVisible: boolean;
16
+ hideToast: () => void;
17
+ success: (title: string, desc?: string, duration?: number) => void;
18
+ warning: (title: string, desc?: string, duration?: number) => void;
19
+ error: (title: string, desc?: string, duration?: number) => void;
17
20
  }
18
21
 
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);
22
+ export const ToastContext = createContext<ToastContextProps | undefined>(undefined);
28
23
 
29
- interface ToastProviderProps {
30
- children: ReactNode;
31
- }
24
+ export const useDaeryunTalkToast = () => {
25
+ const ctx = useContext(ToastContext);
26
+ if (!ctx) throw new Error('ToastContext가 없습니다.');
27
+ return ctx;
28
+ };
32
29
 
33
- export const DaeryuntalkToastProvider = ({ children }: ToastProviderProps) => {
30
+ export const DaeryuntalkToastProvider = ({ children }: { children: ReactNode }) => {
34
31
  const [toast, setToast] = useState<ToastItem | null>(null);
35
32
  const [isVisible, setIsVisible] = useState(false);
36
33
 
37
- const showToast = (type: ToastType, title: string, description?: string, duration: number = 3000) => {
34
+ const hideToast = () => setIsVisible(false);
35
+
36
+ const showToast = (type: ToastType, title: string, description?: string, duration = 3000) => {
38
37
  setToast({ type, title, description, duration });
39
38
  setIsVisible(true);
40
39
  setTimeout(() => {
41
40
  setIsVisible(false);
42
- setTimeout(() => setToast(null), 300); // exit transition
41
+ setTimeout(() => setToast(null), 300);
43
42
  }, duration);
44
43
  };
45
44
 
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);
45
+ const success = (title: string, d?: string, t?: number) => showToast('success', title, d, t);
46
+ const warning = (title: string, d?: string, t?: number) => showToast('warning', title, d, t);
47
+ const error = (title: string, d?: string, t?: number) => showToast('error', title, d, t);
52
48
 
53
49
  return (
54
- <ToastContext.Provider value={{ success, warning, error }}>
50
+ <ToastContext.Provider value={{ toast, isVisible, hideToast, success, warning, error }}>
55
51
  {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
52
  </ToastContext.Provider>
66
53
  );
67
54
  };
@@ -0,0 +1 @@
1
+ export default function ToastRenderer(): import("react").JSX.Element | null;
@@ -0,0 +1,17 @@
1
+ // ./Toast/ToastRenderer.tsx
2
+ 'use client';
3
+ import { useContext } from 'react';
4
+ import { ToastContext } from './DaeryuntalkToastProvider';
5
+ import DaeryunTalkToast from './Toast';
6
+ export default function ToastRenderer() {
7
+ const context = useContext(ToastContext);
8
+ if (!context)
9
+ return null;
10
+ const { toast, isVisible, hideToast } = context;
11
+ console.log('isVisible', isVisible);
12
+ return (<div className="absolute bottom-0 left-1/2 z-[50] w-[90%] -translate-x-1/2">
13
+ <div className={`transition-all duration-300 ${isVisible ? '-translate-y-[96px] opacity-100' : 'pointer-events-none translate-y-0 opacity-0'}`}>
14
+ {toast && <DaeryunTalkToast {...toast} onClose={hideToast}/>}
15
+ </div>
16
+ </div>);
17
+ }
@@ -0,0 +1,27 @@
1
+ // ./Toast/ToastRenderer.tsx
2
+ 'use client';
3
+
4
+ import { useContext } from 'react';
5
+ import { ToastContext } from './DaeryuntalkToastProvider';
6
+ import DaeryunTalkToast from './Toast';
7
+
8
+ export default function ToastRenderer() {
9
+ const context = useContext(ToastContext);
10
+
11
+ if (!context) return null;
12
+
13
+ const { toast, isVisible, hideToast } = context;
14
+ console.log('isVisible', isVisible);
15
+
16
+ return (
17
+ <div className="absolute bottom-0 left-1/2 z-[50] w-[90%] -translate-x-1/2">
18
+ <div
19
+ className={`transition-all duration-300 ${
20
+ isVisible ? '-translate-y-[96px] opacity-100' : 'pointer-events-none translate-y-0 opacity-0'
21
+ }`}
22
+ >
23
+ {toast && <DaeryunTalkToast {...toast} onClose={hideToast} />}
24
+ </div>
25
+ </div>
26
+ );
27
+ }
@@ -10,9 +10,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { useCallback } from 'react';
11
11
  import { chatUserUpdate as apiChatUserUpdate, chatWorkFlow, chatWorkFlowBack, generateChatInquiry, getChatInquiryDetailNew, getChatInquiryMessageList, sendChatMessage } from '../../_api';
12
12
  import { convertApiMessageObjectToUiMessageObject, convertApiMessageToUiMessage } from '../../_lib';
13
- import { useDearyunTalkToast } from '../../Toast/DaeryuntalkToastProvider';
13
+ import { useDaeryunTalkToast } from '../../Toast/DaeryuntalkToastProvider';
14
14
  export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNumber, setMessages, setInquiryStatus, setMessageObject, chatInquiryNumber, setIsNextPage, setWorkFlowStack, setInquiryMainData }) => {
15
- const toast = useDearyunTalkToast();
15
+ const toast = useDaeryunTalkToast();
16
16
  // 채팅 시작 (문의하기 버튼 클릭 시)
17
17
  const startChat = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
18
18
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
@@ -13,8 +13,7 @@ import { convertApiMessageObjectToUiMessageObject, convertApiMessageToUiMessage
13
13
  import { IChatInquiryMainDataResponse } from '../../_api/daeryuntalk/type/response';
14
14
  import { Message } from '../../_types/message';
15
15
  import { MessageObject } from '../../_types/message_object';
16
- import { useDearyunTalkToast } from '../../Toast/DaeryuntalkToastProvider';
17
-
16
+ import { useDaeryunTalkToast } from '../../Toast/DaeryuntalkToastProvider';
18
17
  interface props {
19
18
  setIsLoading: Dispatch<SetStateAction<boolean>>;
20
19
  inquiryMainData: IChatInquiryMainDataResponse | null;
@@ -40,7 +39,7 @@ export const useChatHandler = ({
40
39
  setWorkFlowStack,
41
40
  setInquiryMainData
42
41
  }: props) => {
43
- const toast = useDearyunTalkToast();
42
+ const toast = useDaeryunTalkToast();
44
43
  // 채팅 시작 (문의하기 버튼 클릭 시)
45
44
  const startChat = useCallback(async () => {
46
45
  try {
@@ -6,6 +6,7 @@ import ChatWidget from './ChatWidget';
6
6
  import { DaeryuntalkProvider } from './DaeryuntalkContext';
7
7
  import ImageViewer from './Viewer/ImageViewer';
8
8
  import { DaeryuntalkToastProvider } from './Toast/DaeryuntalkToastProvider';
9
+ import ToastRenderer from './Toast/ToastRender';
9
10
 
10
11
  type DaeryuntalkProps = {
11
12
  tel: string;