@daeryun/dr_components 0.8.5 → 0.8.7

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.
@@ -24,7 +24,7 @@ import ShadowBox from './_ui/ShadowBox';
24
24
  import { useDaeryunTalkToast } from './Toast/DaeryuntalkToastProvider';
25
25
  import ToastRenderer from './Toast/ToastRender';
26
26
  const ChatHomeView = ({ hashValue, setHashValue, isMobile }) => {
27
- const { isConnected, isAuthenticated, historyList, inquiryMainData, startChat, createNewChat, chatInquiryNumber, sendHeartbeat, sendInquiryLeft, goGetHistoryList, sendHistoryEntered, sendHistoryLeft, startSelectedChat, attendRoomByHistory } = useDaeryuntalk();
27
+ const { isLoading: isProviderLoading, isConnected, isAuthenticated, historyList, inquiryMainData, startChat, createNewChat, chatInquiryNumber, sendHeartbeat, sendInquiryLeft, goGetHistoryList, sendHistoryEntered, sendHistoryLeft, startSelectedChat, attendRoomByHistory } = useDaeryuntalk();
28
28
  const [viewState, setViewState] = useState('home');
29
29
  const [mainData, setMainData] = useState(null);
30
30
  const [isLoading, setIsLoading] = useState(false);
@@ -32,7 +32,7 @@ const ChatHomeView = ({ hashValue, setHashValue, isMobile }) => {
32
32
  // 아직 커버이미지 url이 안나옴
33
33
  const backgroundImage = (mainData === null || mainData === void 0 ? void 0 : mainData.sleeve_image_url) ? mainData.sleeve_image_url : DaeryuntalkIntro;
34
34
  useEffect(() => {
35
- if (hashValue && isConnected) {
35
+ if (hashValue && isConnected && !isProviderLoading) {
36
36
  handleStartChat();
37
37
  }
38
38
  }, [hashValue, isConnected]);
@@ -26,6 +26,7 @@ type ChatHomeViewProps = {
26
26
  };
27
27
  const ChatHomeView: React.FC<ChatHomeViewProps> = ({ hashValue, setHashValue, isMobile }) => {
28
28
  const {
29
+ isLoading: isProviderLoading,
29
30
  isConnected,
30
31
  isAuthenticated,
31
32
  historyList,
@@ -48,7 +49,7 @@ const ChatHomeView: React.FC<ChatHomeViewProps> = ({ hashValue, setHashValue, is
48
49
  // 아직 커버이미지 url이 안나옴
49
50
  const backgroundImage = mainData?.sleeve_image_url ? mainData.sleeve_image_url : DaeryuntalkIntro;
50
51
  useEffect(() => {
51
- if (hashValue && isConnected) {
52
+ if (hashValue && isConnected && !isProviderLoading) {
52
53
  handleStartChat();
53
54
  }
54
55
  }, [hashValue, isConnected]);
@@ -17,9 +17,9 @@ const ChatWidget = ({ isOpen, isMobile, onClose, hashValue, setHashValue }) => {
17
17
  bg-white shadow-[0px_4px_10px_0px_#00000026]
18
18
  ${isMobile ? '' : 'duration-300 ease-in-out'}
19
19
  ${isHash && isMobile
20
- ? 'inset-0 h-[100dvh] w-screen rounded-none'
20
+ ? 'inset-0 h-screen w-screen rounded-none'
21
21
  : isMobile || isHash
22
- ? 'inset-0 w-screen rounded-none'
22
+ ? 'inset-0 h-screen w-screen rounded-none'
23
23
  : 'bottom-[165px] right-[30px] max-w-[390px] rounded-[30px] lg:bottom-[110px]'}
24
24
 
25
25
  ${isMobile
@@ -30,9 +30,9 @@ const ChatWidget: React.FC<ChatWidgetProps> = ({ isOpen, isMobile, onClose, hash
30
30
  ${isMobile ? '' : 'duration-300 ease-in-out'}
31
31
  ${
32
32
  isHash && isMobile
33
- ? 'inset-0 h-[100dvh] w-screen rounded-none'
33
+ ? 'inset-0 h-screen w-screen rounded-none'
34
34
  : isMobile || isHash
35
- ? 'inset-0 w-screen rounded-none'
35
+ ? 'inset-0 h-screen w-screen rounded-none'
36
36
  : 'bottom-[165px] right-[30px] max-w-[390px] rounded-[30px] lg:bottom-[110px]'
37
37
  }
38
38
 
@@ -0,0 +1 @@
1
+ export default function ViewportHandler(): null;
@@ -0,0 +1,32 @@
1
+ 'use client';
2
+ import { useEffect } from 'react';
3
+ export default function ViewportHandler() {
4
+ useEffect(() => {
5
+ function updateViewport() {
6
+ let viewportMeta = document.querySelector('meta[name="viewport"]');
7
+ if (!viewportMeta) {
8
+ viewportMeta = document.createElement('meta');
9
+ viewportMeta.name = 'viewport';
10
+ document.head.appendChild(viewportMeta);
11
+ }
12
+ const currentContent = viewportMeta.getAttribute('content');
13
+ let newContent = '';
14
+ if (window.screen.width < 360) {
15
+ const scale = window.screen.width / 360;
16
+ newContent = `width=device-width, initial-scale=${scale.toFixed(2)}, user-scalable=yes, maximum-scale=5, viewport-fit=contain`;
17
+ }
18
+ else {
19
+ newContent = `width=device-width, initial-scale=1, user-scalable=yes, maximum-scale=5, viewport-fit=contain`;
20
+ }
21
+ if (currentContent !== newContent) {
22
+ viewportMeta.setAttribute('content', newContent);
23
+ }
24
+ }
25
+ updateViewport();
26
+ window.addEventListener('resize', updateViewport);
27
+ return () => {
28
+ window.removeEventListener('resize', updateViewport);
29
+ };
30
+ }, []);
31
+ return null;
32
+ }
@@ -0,0 +1,39 @@
1
+ 'use client';
2
+
3
+ import { useEffect } from 'react';
4
+
5
+ export default function ViewportHandler() {
6
+ useEffect(() => {
7
+ function updateViewport() {
8
+ let viewportMeta = document.querySelector('meta[name="viewport"]') as HTMLMetaElement | null;
9
+ if (!viewportMeta) {
10
+ viewportMeta = document.createElement('meta');
11
+ viewportMeta.name = 'viewport';
12
+ document.head.appendChild(viewportMeta);
13
+ }
14
+
15
+ const currentContent = viewportMeta.getAttribute('content');
16
+
17
+ let newContent = '';
18
+ if (window.screen.width < 360) {
19
+ const scale = window.screen.width / 360;
20
+ newContent = `width=device-width, initial-scale=${scale.toFixed(2)}, user-scalable=yes, maximum-scale=5, viewport-fit=contain`;
21
+ } else {
22
+ newContent = `width=device-width, initial-scale=1, user-scalable=yes, maximum-scale=5, viewport-fit=contain`;
23
+ }
24
+
25
+ if (currentContent !== newContent) {
26
+ viewportMeta.setAttribute('content', newContent);
27
+ }
28
+ }
29
+
30
+ updateViewport();
31
+ window.addEventListener('resize', updateViewport);
32
+
33
+ return () => {
34
+ window.removeEventListener('resize', updateViewport);
35
+ };
36
+ }, []);
37
+
38
+ return null;
39
+ }
@@ -48,10 +48,11 @@ export declare function connectWebSocket(wsUrl: string, token: string, onMessage
48
48
  export declare function getChatInquiryMain(channelNumber: string, version?: string): Promise<IDaeryunTalkResponseWrapper<IChatInquiryMainDataResponse>>;
49
49
  /**
50
50
  * 새 채팅 문의 생성 (개선된 API)
51
- * @param version API 버전 (기본값: 1.0.0)
52
- * @returns 문의 번호가 포함된 생성된 채팅 문의 데이터
51
+ * @param channelNumber
52
+ * @param currentUrl
53
+ * @param version
53
54
  */
54
- export declare function generateChatInquiry(channelNumber: string, version?: string): Promise<IDaeryunTalkResponseWrapper<ChatInquiryCreateDataResponse>>;
55
+ export declare function generateChatInquiry(channelNumber: string, currentUrl: string, version?: string): Promise<IDaeryunTalkResponseWrapper<ChatInquiryCreateDataResponse>>;
55
56
  /**
56
57
  * 채팅 문의 상세 조회 (개선된 API)
57
58
  * @param chatInquiryNumber 채팅 문의 번호
@@ -290,15 +290,17 @@ export function getChatInquiryMain(channelNumber, version) {
290
290
  }
291
291
  /**
292
292
  * 새 채팅 문의 생성 (개선된 API)
293
- * @param version API 버전 (기본값: 1.0.0)
294
- * @returns 문의 번호가 포함된 생성된 채팅 문의 데이터
293
+ * @param channelNumber
294
+ * @param currentUrl
295
+ * @param version
295
296
  */
296
- export function generateChatInquiry(channelNumber, version) {
297
+ export function generateChatInquiry(channelNumber, currentUrl, version) {
297
298
  return __awaiter(this, void 0, void 0, function* () {
298
299
  console.log('[새 채팅 문의 생성 시작 (개선)]', version ? `버전: ${version}` : `기본 버전: ${DEFAULT_API_VERSION}`);
299
300
  const body = {
300
301
  d: {
301
- channel_number: channelNumber
302
+ channel_number: channelNumber,
303
+ current_url: currentUrl
302
304
  }
303
305
  };
304
306
  try {
@@ -356,7 +358,7 @@ export function getChatInquiryMessageList(chatInquiryNumber, standardDateTime, s
356
358
  const body = {
357
359
  d: Object.assign(Object.assign({ chat_inquiry_number: chatInquiryNumber }, (standardDateTime && { standard_date_time: standardDateTime })), {
358
360
  // standard_date_time: standard_date_time ?? new Date().toISOString(),
359
- size: size !== null && size !== void 0 ? size : 100 })
361
+ size: size !== null && size !== void 0 ? size : 200 })
360
362
  };
361
363
  console.log('[채팅 메세지 리스트] 문의 번호:', chatInquiryNumber, version ? `버전: ${version}` : `기본 버전: ${DEFAULT_API_VERSION}`);
362
364
  try {
@@ -359,18 +359,21 @@ export async function getChatInquiryMain(
359
359
 
360
360
  /**
361
361
  * 새 채팅 문의 생성 (개선된 API)
362
- * @param version API 버전 (기본값: 1.0.0)
363
- * @returns 문의 번호가 포함된 생성된 채팅 문의 데이터
362
+ * @param channelNumber
363
+ * @param currentUrl
364
+ * @param version
364
365
  */
365
366
  export async function generateChatInquiry(
366
367
  channelNumber: string,
368
+ currentUrl: string,
367
369
  version?: string
368
370
  ): Promise<IDaeryunTalkResponseWrapper<ChatInquiryCreateDataResponse>> {
369
371
  console.log('[새 채팅 문의 생성 시작 (개선)]', version ? `버전: ${version}` : `기본 버전: ${DEFAULT_API_VERSION}`);
370
372
 
371
373
  const body = {
372
374
  d: {
373
- channel_number: channelNumber
375
+ channel_number: channelNumber,
376
+ current_url: currentUrl
374
377
  }
375
378
  };
376
379
 
@@ -448,7 +451,7 @@ export async function getChatInquiryMessageList(
448
451
  chat_inquiry_number: chatInquiryNumber,
449
452
  ...(standardDateTime && { standard_date_time: standardDateTime }),
450
453
  // standard_date_time: standard_date_time ?? new Date().toISOString(),
451
- size: size ?? 100
454
+ size: size ?? 200
452
455
  }
453
456
  };
454
457
 
@@ -11,8 +11,12 @@ import { useCallback } from 'react';
11
11
  import { attendChatRoomByHistory, chatUserUpdate as apiChatUserUpdate, chatWorkFlow, chatWorkFlowBack, generateChatInquiry, getChatInquiryDetailNew, getChatInquiryMessageList, sendChatMessage } from '../../_api';
12
12
  import { convertApiMessageObjectToUiMessageObject, convertApiMessageToUiMessage } from '../../_lib';
13
13
  import { useDaeryunTalkToast } from '../../Toast/DaeryuntalkToastProvider';
14
+ import { usePathname, useSearchParams } from 'next/navigation';
14
15
  export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNumber, setMessages, setInquiryStatus, setMessageObject, chatInquiryNumber, setIsNextPage, setWorkFlowStack, setInquiryMainData }) => {
15
16
  const toast = useDaeryunTalkToast();
17
+ const pathname = usePathname(); // => "/daeryuntalk"
18
+ const searchParams = useSearchParams(); // => URLSearchParams 객체
19
+ const fullPath = `${pathname}?${searchParams.toString()}`;
16
20
  // 채팅 시작 (문의하기 버튼 클릭 시)
17
21
  const startChat = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
18
22
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
@@ -30,7 +34,7 @@ export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNu
30
34
  else {
31
35
  // 새 문의 생성
32
36
  console.log('[DaeryuntalkContext] 새 문의 생성 시작');
33
- const createResponse = yield generateChatInquiry((inquiryMainData === null || inquiryMainData === void 0 ? void 0 : inquiryMainData.channel_number) || '');
37
+ const createResponse = yield generateChatInquiry((inquiryMainData === null || inquiryMainData === void 0 ? void 0 : inquiryMainData.channel_number) || '', fullPath);
34
38
  if (createResponse && createResponse.data && createResponse.data.chat_inquiry_number) {
35
39
  currentChatInquiryNumber = createResponse.data.chat_inquiry_number;
36
40
  console.log('[DaeryuntalkContext] 새 문의 생성 완료:', currentChatInquiryNumber);
@@ -201,7 +205,7 @@ export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNu
201
205
  }
202
206
  setIsLoading(true);
203
207
  console.log('chatInquiryNumber', chatInquiryNumber);
204
- const createResponse = yield generateChatInquiry((inquiryMainData === null || inquiryMainData === void 0 ? void 0 : inquiryMainData.channel_number) || '');
208
+ const createResponse = yield generateChatInquiry((inquiryMainData === null || inquiryMainData === void 0 ? void 0 : inquiryMainData.channel_number) || '', fullPath);
205
209
  console.log('[DaeryuntalkContext] 새 문의 생성 완료:', createResponse);
206
210
  if (createResponse.data) {
207
211
  const currentChatInquiryNumber = createResponse.data.chat_inquiry_number;
@@ -15,6 +15,8 @@ import { IChatInquiryMainDataResponse } from '../../_api/daeryuntalk/type/respon
15
15
  import { Message } from '../../_types/message';
16
16
  import { MessageObject } from '../../_types/message_object';
17
17
  import { useDaeryunTalkToast } from '../../Toast/DaeryuntalkToastProvider';
18
+ import { usePathname, useRouter, useSearchParams } from 'next/navigation';
19
+ import { router } from 'next/client';
18
20
  interface props {
19
21
  setIsLoading: Dispatch<SetStateAction<boolean>>;
20
22
  inquiryMainData: IChatInquiryMainDataResponse | null;
@@ -41,6 +43,10 @@ export const useChatHandler = ({
41
43
  setInquiryMainData
42
44
  }: props) => {
43
45
  const toast = useDaeryunTalkToast();
46
+ const pathname = usePathname(); // => "/daeryuntalk"
47
+ const searchParams = useSearchParams(); // => URLSearchParams 객체
48
+ const fullPath = `${pathname}?${searchParams.toString()}`;
49
+
44
50
  // 채팅 시작 (문의하기 버튼 클릭 시)
45
51
  const startChat = useCallback(async () => {
46
52
  try {
@@ -60,7 +66,7 @@ export const useChatHandler = ({
60
66
  } else {
61
67
  // 새 문의 생성
62
68
  console.log('[DaeryuntalkContext] 새 문의 생성 시작');
63
- const createResponse = await generateChatInquiry(inquiryMainData?.channel_number || '');
69
+ const createResponse = await generateChatInquiry(inquiryMainData?.channel_number || '', fullPath);
64
70
 
65
71
  if (createResponse && createResponse.data && createResponse.data.chat_inquiry_number) {
66
72
  currentChatInquiryNumber = createResponse.data.chat_inquiry_number;
@@ -252,7 +258,7 @@ export const useChatHandler = ({
252
258
  }
253
259
  setIsLoading(true);
254
260
  console.log('chatInquiryNumber', chatInquiryNumber);
255
- const createResponse = await generateChatInquiry(inquiryMainData?.channel_number || '');
261
+ const createResponse = await generateChatInquiry(inquiryMainData?.channel_number || '', fullPath);
256
262
  console.log('[DaeryuntalkContext] 새 문의 생성 완료:', createResponse);
257
263
  if (createResponse.data) {
258
264
  const currentChatInquiryNumber = createResponse.data.chat_inquiry_number;
@@ -5,6 +5,7 @@ import ChatWidget from './ChatWidget';
5
5
  import { DaeryuntalkProvider } from './DaeryuntalkContext';
6
6
  import { DaeryuntalkToastProvider } from './Toast/DaeryuntalkToastProvider';
7
7
  import mobile from 'is-mobile';
8
+ import ViewportHandler from './ViewportHandler';
8
9
  const Daeryuntalk = ({ tel = '1800-7905' }) => {
9
10
  const [isOpen, setIsOpen] = useState(false);
10
11
  const [isMobile, setIsMobile] = useState(false);
@@ -33,6 +34,7 @@ const Daeryuntalk = ({ tel = '1800-7905' }) => {
33
34
  }
34
35
  }, []);
35
36
  return (<DaeryuntalkToastProvider>
37
+ <ViewportHandler />
36
38
  <DaeryuntalkProvider propsTel={tel}>
37
39
  <ChatButton isOpen={isOpen} isMobile={isMobile} hashValue={hashValue} onClick={toggleChat}/>
38
40
  <ChatWidget isOpen={hashValue ? true : isOpen} isMobile={isMobile} onClose={closeChatWidget} hashValue={hashValue} setHashValue={setHashValue}/>
@@ -6,6 +6,7 @@ import ChatWidget from './ChatWidget';
6
6
  import { DaeryuntalkProvider, useDaeryuntalk } from './DaeryuntalkContext';
7
7
  import { DaeryuntalkToastProvider } from './Toast/DaeryuntalkToastProvider';
8
8
  import mobile from 'is-mobile';
9
+ import ViewportHandler from './ViewportHandler';
9
10
 
10
11
  type DaeryuntalkProps = {
11
12
  tel: string;
@@ -48,6 +49,7 @@ const Daeryuntalk: React.FC<DaeryuntalkProps> = ({ tel = '1800-7905' }) => {
48
49
 
49
50
  return (
50
51
  <DaeryuntalkToastProvider>
52
+ <ViewportHandler />
51
53
  <DaeryuntalkProvider propsTel={tel}>
52
54
  <ChatButton isOpen={isOpen} isMobile={isMobile} hashValue={hashValue} onClick={toggleChat} />
53
55
  <ChatWidget
@@ -2216,10 +2216,6 @@ video {
2216
2216
  height: 1000px;
2217
2217
  }
2218
2218
 
2219
- .h-\[100dvh\] {
2220
- height: 100dvh;
2221
- }
2222
-
2223
2219
  .h-\[100px\] {
2224
2220
  height: 100px;
2225
2221
  }
@@ -2645,6 +2641,10 @@ video {
2645
2641
  height: 1px;
2646
2642
  }
2647
2643
 
2644
+ .h-screen {
2645
+ height: 100vh;
2646
+ }
2647
+
2648
2648
  .\!max-h-fit {
2649
2649
  max-height: -moz-fit-content !important;
2650
2650
  max-height: fit-content !important;