@daeryun/dr_components 0.8.6 → 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.
- package/dist/components/Daeryuntalk/ViewportHandler.d.ts +1 -0
- package/dist/components/Daeryuntalk/ViewportHandler.jsx +32 -0
- package/dist/components/Daeryuntalk/ViewportHandler.tsx +39 -0
- package/dist/components/Daeryuntalk/_api/daeryuntalk/index.d.ts +4 -3
- package/dist/components/Daeryuntalk/_api/daeryuntalk/index.js +6 -4
- package/dist/components/Daeryuntalk/_api/daeryuntalk/index.ts +6 -3
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.js +6 -2
- package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.ts +8 -2
- package/dist/components/Daeryuntalk/index.jsx +2 -0
- package/dist/components/Daeryuntalk/index.tsx +2 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -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
|
|
52
|
-
* @
|
|
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
|
|
294
|
-
* @
|
|
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 {
|
|
@@ -359,18 +359,21 @@ export async function getChatInquiryMain(
|
|
|
359
359
|
|
|
360
360
|
/**
|
|
361
361
|
* 새 채팅 문의 생성 (개선된 API)
|
|
362
|
-
* @param
|
|
363
|
-
* @
|
|
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
|
|
|
@@ -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
|