@daeryun/dr_components 0.6.33 → 0.6.35

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.
Files changed (57) hide show
  1. package/dist/Daeryuntalk/ChatButton.d.ts +7 -0
  2. package/dist/Daeryuntalk/ChatButton.jsx +37 -0
  3. package/dist/Daeryuntalk/ChatButton.tsx +63 -0
  4. package/dist/Daeryuntalk/ChatConversation.d.ts +6 -0
  5. package/dist/Daeryuntalk/ChatConversation.jsx +74 -0
  6. package/dist/Daeryuntalk/ChatConversation.tsx +109 -0
  7. package/dist/Daeryuntalk/ChatHomeView.d.ts +3 -0
  8. package/dist/Daeryuntalk/ChatHomeView.jsx +93 -0
  9. package/dist/Daeryuntalk/ChatHomeView.tsx +158 -0
  10. package/dist/Daeryuntalk/ChatInput.d.ts +3 -0
  11. package/dist/Daeryuntalk/ChatInput.jsx +23 -0
  12. package/dist/Daeryuntalk/ChatInput.tsx +42 -0
  13. package/dist/Daeryuntalk/ChatMessage.d.ts +7 -0
  14. package/dist/Daeryuntalk/ChatMessage.jsx +88 -0
  15. package/dist/Daeryuntalk/ChatMessage.tsx +153 -0
  16. package/dist/Daeryuntalk/ChatWidget.d.ts +6 -0
  17. package/dist/Daeryuntalk/ChatWidget.jsx +12 -0
  18. package/dist/Daeryuntalk/ChatWidget.tsx +22 -0
  19. package/dist/Daeryuntalk/DaeryuntalkContext.d.ts +20 -0
  20. package/dist/Daeryuntalk/DaeryuntalkContext.jsx +455 -0
  21. package/dist/Daeryuntalk/DaeryuntalkContext.tsx +530 -0
  22. package/dist/Daeryuntalk/DateSeparator.d.ts +6 -0
  23. package/dist/Daeryuntalk/DateSeparator.jsx +13 -0
  24. package/dist/Daeryuntalk/DateSeparator.tsx +23 -0
  25. package/dist/Daeryuntalk/HistoryView.d.ts +8 -0
  26. package/dist/Daeryuntalk/HistoryView.jsx +68 -0
  27. package/dist/Daeryuntalk/HistoryView.tsx +98 -0
  28. package/dist/Daeryuntalk/NavigationFooter.d.ts +8 -0
  29. package/dist/Daeryuntalk/NavigationFooter.jsx +23 -0
  30. package/dist/Daeryuntalk/NavigationFooter.tsx +55 -0
  31. package/dist/Daeryuntalk/NoticeMessage.d.ts +6 -0
  32. package/dist/Daeryuntalk/NoticeMessage.jsx +23 -0
  33. package/dist/Daeryuntalk/NoticeMessage.tsx +45 -0
  34. package/dist/Daeryuntalk/index.jsx +25 -0
  35. package/dist/Daeryuntalk/index.tsx +33 -0
  36. package/dist/Daeryuntalk/message-components/FileContent.d.ts +8 -0
  37. package/dist/Daeryuntalk/message-components/FileContent.jsx +32 -0
  38. package/dist/Daeryuntalk/message-components/FileContent.tsx +43 -0
  39. package/dist/Daeryuntalk/message-components/FormContent.d.ts +8 -0
  40. package/dist/Daeryuntalk/message-components/FormContent.jsx +104 -0
  41. package/dist/Daeryuntalk/message-components/FormContent.tsx +184 -0
  42. package/dist/Daeryuntalk/socketManager.d.ts +22 -0
  43. package/dist/Daeryuntalk/socketManager.js +96 -0
  44. package/dist/Daeryuntalk/socketManager.ts +123 -0
  45. package/dist/Daeryuntalk/types.d.ts +75 -0
  46. package/dist/Daeryuntalk/types.js +80 -0
  47. package/dist/Daeryuntalk/types.ts +174 -0
  48. package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
  49. package/dist/components/page/Faq/Detail/FaqDetail.d.ts +2 -1
  50. package/dist/components/page/Faq/Detail/FaqDetail.jsx +2 -2
  51. package/dist/components/page/Faq/Detail/FaqDetail.tsx +4 -1
  52. package/dist/components/page/Faq/FaqList.d.ts +2 -1
  53. package/dist/components/page/Faq/FaqList.jsx +2 -2
  54. package/dist/components/page/Faq/FaqList.tsx +10 -1
  55. package/dist/styles/globals.css +639 -255
  56. package/dist/tsconfig.tsbuildinfo +1 -1
  57. package/package.json +1 -1
@@ -0,0 +1,88 @@
1
+ import React from 'react';
2
+ import Image from 'next/image';
3
+ import { hasBlocks, hasButtons, hasFiles, hasImages, hasForm } from './types';
4
+ import { useDaeryuntalk } from './DaeryuntalkContext';
5
+ import FormContent from './message-components/FormContent';
6
+ import FileContent from './message-components/FileContent';
7
+ const ChatMessage = ({ message }) => {
8
+ const { sendQuickReply } = useDaeryuntalk();
9
+ const isUser = message.sender === 'user';
10
+ const formatTime = (date) => {
11
+ const hours = date.getHours().toString().padStart(2, '0');
12
+ const minutes = date.getMinutes().toString().padStart(2, '0');
13
+ return `${hours}:${minutes}`;
14
+ };
15
+ const time = formatTime(message.createdAt);
16
+ // 텍스트 블록 렌더링
17
+ const renderTextBlock = (block, index) => (<div key={`text-${index}`} className={`mb-1 rounded-[10px] border p-2 ${isUser ? 'border-[#2E385B] text-[#2E385B]' : 'border-[#EDEDED] text-black'}`}>
18
+ <p className="text-sm leading-[130%] tracking-[-4%]">{block.value}</p>
19
+ </div>);
20
+ // 버튼 렌더링
21
+ const renderButton = (button, index) => (<button key={`button-${index}`} className="rounded-[20px] border border-[#2E385B4D] px-2.5 py-1.5 text-xs font-medium leading-[140%] tracking-[-4%] text-[#2E385B] transition-colors hover:bg-[#2E385B]/10" onClick={() => {
22
+ // 버튼 클릭 시 sendQuickReply 함수 호출
23
+ if (button.action === 'send') {
24
+ sendQuickReply(button.id, button.value);
25
+ }
26
+ else if (button.action === 'url' && button.value) {
27
+ window.open(button.value, '_blank');
28
+ }
29
+ // form 액션은 추후 구현 예정
30
+ }}>
31
+ {button.text}
32
+ </button>);
33
+ // 이미지 렌더링
34
+ const renderImage = (image, index) => (<div key={`image-${index}`} className={`
35
+ mb-1 rounded-[10px] p-2
36
+ ${isUser ? 'border border-[#EDEDED] text-[#2E385B]' : 'border border-[#EDEDED] bg-white text-[#2E385B]'}
37
+ `}>
38
+ <div className="relative w-full overflow-hidden rounded-lg">
39
+ <Image src={image.url} alt={image.alt || '이미지'} width={300} height={200} className="object-cover" style={{ maxWidth: '100%', height: 'auto' }}/>
40
+ </div>
41
+ {image.caption && <p className="mt-2 text-sm">{image.caption}</p>}
42
+ </div>);
43
+ const renderMessageContent = () => {
44
+ var _a, _b, _c, _d;
45
+ return (<div className="message-content">
46
+ {/* 텍스트 블록 렌더링 */}
47
+ {hasBlocks(message) && ((_a = message.blocks) === null || _a === void 0 ? void 0 : _a.map((block, index) => renderTextBlock(block, index)))}
48
+
49
+ {/* 이미지 렌더링 */}
50
+ {hasImages(message) && ((_b = message.images) === null || _b === void 0 ? void 0 : _b.map((image, index) => renderImage(image, index)))}
51
+
52
+ {/* 버튼 렌더링 */}
53
+ {hasButtons(message) && (<div className="my-1 flex flex-wrap gap-2">
54
+ {(_c = message.buttons) === null || _c === void 0 ? void 0 : _c.map((button, index) => renderButton(button, index))}
55
+ </div>)}
56
+
57
+ {/* 폼 렌더링 */}
58
+ {hasForm(message) && message.form && <FormContent form={message.form} messageId={message.msgNo}/>}
59
+
60
+ {/* 파일 렌더링 */}
61
+ {hasFiles(message) &&
62
+ ((_d = message.files) === null || _d === void 0 ? void 0 : _d.map((file, index) => (<FileContent key={`file-${index}`} file={file} isUser={isUser}/>)))}
63
+ </div>);
64
+ };
65
+ return (<div className={`mb-4 flex ${isUser ? 'justify-end' : 'justify-start'}`}>
66
+ {!isUser ? (<div className="flex flex-col">
67
+ <div className="mb-1 flex items-center">
68
+ <div className="mr-1 h-8 w-8 flex-shrink-0 rounded-full">
69
+ <div className="relative h-full w-full p-1">
70
+ <Image src={message.msgIconUrl || '/images/daeryuntalk/daeryun-logo.svg'} alt="로고" width={24} height={24}/>
71
+ </div>
72
+ </div>
73
+ <span className="leading-[100%] tracking-[-4%]">법무법인(유한)대륜</span>
74
+ </div>
75
+
76
+ <div className="flex items-end gap-2 pl-9">
77
+ {renderMessageContent()}
78
+ <span className="mb-1 text-xs text-gray-500">{time}</span>
79
+ </div>
80
+ </div>) : (<div className="flex max-w-[80%] flex-col">
81
+ <div className="flex items-end gap-2">
82
+ <span className="mb-1 text-xs text-gray-500">{time}</span>
83
+ {renderMessageContent()}
84
+ </div>
85
+ </div>)}
86
+ </div>);
87
+ };
88
+ export default ChatMessage;
@@ -0,0 +1,153 @@
1
+ import React from 'react';
2
+ import Image from 'next/image';
3
+ import {
4
+ Message,
5
+ TextBlock,
6
+ Button,
7
+ FileInfo,
8
+ ImageInfo,
9
+ hasBlocks,
10
+ hasButtons,
11
+ hasFiles,
12
+ hasImages,
13
+ hasForm,
14
+ hasWebPage
15
+ } from './types';
16
+ import { useDaeryuntalk } from './DaeryuntalkContext';
17
+ import FormContent from './message-components/FormContent';
18
+ import FileContent from './message-components/FileContent';
19
+
20
+ type ChatMessageProps = {
21
+ message: Message;
22
+ };
23
+
24
+ const ChatMessage: React.FC<ChatMessageProps> = ({ message }) => {
25
+ const { sendQuickReply } = useDaeryuntalk();
26
+ const isUser = message.sender === 'user';
27
+
28
+ const formatTime = (date: Date): string => {
29
+ const hours = date.getHours().toString().padStart(2, '0');
30
+ const minutes = date.getMinutes().toString().padStart(2, '0');
31
+ return `${hours}:${minutes}`;
32
+ };
33
+
34
+ const time = formatTime(message.createdAt);
35
+
36
+ // 텍스트 블록 렌더링
37
+ const renderTextBlock = (block: TextBlock, index: number) => (
38
+ <div
39
+ key={`text-${index}`}
40
+ className={`mb-1 rounded-[10px] border p-2 ${
41
+ isUser ? 'border-[#2E385B] text-[#2E385B]' : 'border-[#EDEDED] text-black'
42
+ }`}
43
+ >
44
+ <p className="text-sm leading-[130%] tracking-[-4%]">{block.value}</p>
45
+ </div>
46
+ );
47
+
48
+ // 버튼 렌더링
49
+ const renderButton = (button: Button, index: number) => (
50
+ <button
51
+ key={`button-${index}`}
52
+ className="rounded-[20px] border border-[#2E385B4D] px-2.5 py-1.5 text-xs font-medium leading-[140%] tracking-[-4%] text-[#2E385B] transition-colors hover:bg-[#2E385B]/10"
53
+ onClick={() => {
54
+ // 버튼 클릭 시 sendQuickReply 함수 호출
55
+ if (button.action === 'send') {
56
+ sendQuickReply(button.id, button.value);
57
+ } else if (button.action === 'url' && button.value) {
58
+ window.open(button.value, '_blank');
59
+ }
60
+ // form 액션은 추후 구현 예정
61
+ }}
62
+ >
63
+ {button.text}
64
+ </button>
65
+ );
66
+
67
+ // 이미지 렌더링
68
+ const renderImage = (image: ImageInfo, index: number) => (
69
+ <div
70
+ key={`image-${index}`}
71
+ className={`
72
+ mb-1 rounded-[10px] p-2
73
+ ${isUser ? 'border border-[#EDEDED] text-[#2E385B]' : 'border border-[#EDEDED] bg-white text-[#2E385B]'}
74
+ `}
75
+ >
76
+ <div className="relative w-full overflow-hidden rounded-lg">
77
+ <Image
78
+ src={image.url}
79
+ alt={image.alt || '이미지'}
80
+ width={300}
81
+ height={200}
82
+ className="object-cover"
83
+ style={{ maxWidth: '100%', height: 'auto' }}
84
+ />
85
+ </div>
86
+ {image.caption && <p className="mt-2 text-sm">{image.caption}</p>}
87
+ </div>
88
+ );
89
+
90
+ const renderMessageContent = () => {
91
+ return (
92
+ <div className="message-content">
93
+ {/* 텍스트 블록 렌더링 */}
94
+ {hasBlocks(message) && message.blocks?.map((block, index) => renderTextBlock(block, index))}
95
+
96
+ {/* 이미지 렌더링 */}
97
+ {hasImages(message) && message.images?.map((image, index) => renderImage(image, index))}
98
+
99
+ {/* 버튼 렌더링 */}
100
+ {hasButtons(message) && (
101
+ <div className="my-1 flex flex-wrap gap-2">
102
+ {message.buttons?.map((button, index) => renderButton(button, index))}
103
+ </div>
104
+ )}
105
+
106
+ {/* 폼 렌더링 */}
107
+ {hasForm(message) && message.form && <FormContent form={message.form} messageId={message.msgNo} />}
108
+
109
+ {/* 파일 렌더링 */}
110
+ {hasFiles(message) &&
111
+ message.files?.map((file, index) => (
112
+ <FileContent key={`file-${index}`} file={file} isUser={isUser} />
113
+ ))}
114
+ </div>
115
+ );
116
+ };
117
+
118
+ return (
119
+ <div className={`mb-4 flex ${isUser ? 'justify-end' : 'justify-start'}`}>
120
+ {!isUser ? (
121
+ <div className="flex flex-col">
122
+ <div className="mb-1 flex items-center">
123
+ <div className="mr-1 h-8 w-8 flex-shrink-0 rounded-full">
124
+ <div className="relative h-full w-full p-1">
125
+ <Image
126
+ src={message.msgIconUrl || '/images/daeryuntalk/daeryun-logo.svg'}
127
+ alt="로고"
128
+ width={24}
129
+ height={24}
130
+ />
131
+ </div>
132
+ </div>
133
+ <span className="leading-[100%] tracking-[-4%]">법무법인(유한)대륜</span>
134
+ </div>
135
+
136
+ <div className="flex items-end gap-2 pl-9">
137
+ {renderMessageContent()}
138
+ <span className="mb-1 text-xs text-gray-500">{time}</span>
139
+ </div>
140
+ </div>
141
+ ) : (
142
+ <div className="flex max-w-[80%] flex-col">
143
+ <div className="flex items-end gap-2">
144
+ <span className="mb-1 text-xs text-gray-500">{time}</span>
145
+ {renderMessageContent()}
146
+ </div>
147
+ </div>
148
+ )}
149
+ </div>
150
+ );
151
+ };
152
+
153
+ export default ChatMessage;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ interface ChatWidgetProps {
3
+ isOpen: boolean;
4
+ }
5
+ declare const ChatWidget: React.FC<ChatWidgetProps>;
6
+ export default ChatWidget;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import ChatHomeView from './ChatHomeView';
3
+ const ChatWidget = ({ isOpen }) => {
4
+ return (<div className={`
5
+ fixed bottom-[110px] right-[30px] z-[999998]
6
+ transition-all duration-300 ease-out
7
+ ${isOpen ? 'translate-y-0 scale-100 opacity-100' : 'pointer-events-none translate-y-6 opacity-0'}
8
+ `}>
9
+ <ChatHomeView />
10
+ </div>);
11
+ };
12
+ export default ChatWidget;
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import ChatHomeView from './ChatHomeView';
3
+
4
+ interface ChatWidgetProps {
5
+ isOpen: boolean;
6
+ }
7
+
8
+ const ChatWidget: React.FC<ChatWidgetProps> = ({ isOpen }) => {
9
+ return (
10
+ <div
11
+ className={`
12
+ fixed bottom-[110px] right-[30px] z-[999998]
13
+ transition-all duration-300 ease-out
14
+ ${isOpen ? 'translate-y-0 scale-100 opacity-100' : 'pointer-events-none translate-y-6 opacity-0'}
15
+ `}
16
+ >
17
+ <ChatHomeView />
18
+ </div>
19
+ );
20
+ };
21
+
22
+ export default ChatWidget;
@@ -0,0 +1,20 @@
1
+ import React, { ReactNode } from 'react';
2
+ import { Message } from './types';
3
+ type DaeryuntalkContextType = {
4
+ messages: Message[];
5
+ isConnected: boolean;
6
+ isLoading: boolean;
7
+ sendMessage: (text: string) => void;
8
+ sendQuickReply: (replyId: string, text: string) => void;
9
+ submitForm: (formId: string, data: Record<string, string>) => void;
10
+ sendImage: (imageUrl: string, alt?: string, caption?: string) => void;
11
+ sendFile: (fileUrl: string, fileName: string, fileType?: string, fileSize?: number) => void;
12
+ viewHistory: () => void;
13
+ };
14
+ declare const DaeryuntalkContext: React.Context<DaeryuntalkContextType>;
15
+ type DaeryuntalkProviderProps = {
16
+ children: ReactNode;
17
+ };
18
+ export declare const DaeryuntalkProvider: React.FC<DaeryuntalkProviderProps>;
19
+ export declare const useDaeryuntalk: () => DaeryuntalkContextType;
20
+ export default DaeryuntalkContext;