@daeryun/dr_components 0.7.79 → 0.7.80

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 (136) hide show
  1. package/dist/asset/images/daeryuntalk/download.svg +5 -0
  2. package/dist/asset/images/daeryuntalk/firstGo.svg +5 -0
  3. package/dist/asset/images/daeryuntalk/objectBack.svg +4 -0
  4. package/dist/asset/images/daeryuntalk/viewer/close.svg +4 -0
  5. package/dist/asset/images/daeryuntalk/viewer/gray-download.svg +7 -0
  6. package/dist/asset/images/daeryuntalk/viewer/move-button.svg +4 -0
  7. package/dist/asset/images/daeryuntalk/viewer/rotate.svg +17 -0
  8. package/dist/asset/images/daeryuntalk/viewer/zoom-in.svg +5 -0
  9. package/dist/asset/images/daeryuntalk/viewer/zoom-out.svg +6 -0
  10. package/dist/cjs/tsconfig-cjs.tsbuildinfo +1 -1
  11. package/dist/components/Daeryuntalk/ChatButton.jsx +1 -0
  12. package/dist/components/Daeryuntalk/ChatButton.tsx +1 -0
  13. package/dist/components/Daeryuntalk/ChatConversation.d.ts +1 -0
  14. package/dist/components/Daeryuntalk/ChatConversation.jsx +19 -12
  15. package/dist/components/Daeryuntalk/ChatConversation.tsx +48 -11
  16. package/dist/components/Daeryuntalk/ChatHomeView.jsx +27 -6
  17. package/dist/components/Daeryuntalk/ChatHomeView.tsx +39 -8
  18. package/dist/components/Daeryuntalk/ChatInput.jsx +23 -3
  19. package/dist/components/Daeryuntalk/ChatInput.tsx +26 -10
  20. package/dist/components/Daeryuntalk/ChatItem/ChatFile.d.ts +10 -0
  21. package/dist/components/Daeryuntalk/ChatItem/ChatFile.jsx +186 -0
  22. package/dist/components/Daeryuntalk/ChatItem/ChatFile.tsx +252 -0
  23. package/dist/components/Daeryuntalk/ChatItem/ChatPrivacyAuth.d.ts +8 -0
  24. package/dist/components/Daeryuntalk/ChatItem/ChatPrivacyAuth.jsx +87 -0
  25. package/dist/components/Daeryuntalk/ChatItem/ChatPrivacyAuth.tsx +115 -0
  26. package/dist/components/Daeryuntalk/ChatItem/ChatWrapper.d.ts +8 -0
  27. package/dist/components/Daeryuntalk/ChatItem/ChatWrapper.jsx +13 -0
  28. package/dist/components/Daeryuntalk/ChatItem/ChatWrapper.tsx +25 -0
  29. package/dist/components/Daeryuntalk/ChatItem/RichText.d.ts +7 -0
  30. package/dist/components/Daeryuntalk/ChatItem/RichText.jsx +25 -0
  31. package/dist/components/Daeryuntalk/ChatItem/RichText.tsx +32 -0
  32. package/dist/components/Daeryuntalk/ChatItem/WorkFlowAuthForm.d.ts +8 -0
  33. package/dist/components/Daeryuntalk/ChatItem/WorkFlowAuthForm.jsx +19 -0
  34. package/dist/components/Daeryuntalk/ChatItem/WorkFlowAuthForm.tsx +31 -0
  35. package/dist/components/Daeryuntalk/ChatItem/WorkFlowClickData.d.ts +7 -0
  36. package/dist/components/Daeryuntalk/ChatItem/WorkFlowClickData.jsx +20 -0
  37. package/dist/components/Daeryuntalk/ChatItem/WorkFlowClickData.tsx +36 -0
  38. package/dist/components/Daeryuntalk/ChatItem/WorkFlowImg.d.ts +7 -0
  39. package/dist/components/Daeryuntalk/ChatItem/WorkFlowImg.jsx +9 -0
  40. package/dist/components/Daeryuntalk/ChatItem/WorkFlowImg.tsx +16 -0
  41. package/dist/components/Daeryuntalk/ChatMessage.d.ts +11 -1
  42. package/dist/components/Daeryuntalk/ChatMessage.jsx +116 -14
  43. package/dist/components/Daeryuntalk/ChatMessage.tsx +175 -20
  44. package/dist/components/Daeryuntalk/ChatObject/ObjectBack.d.ts +7 -0
  45. package/dist/components/Daeryuntalk/ChatObject/ObjectBack.jsx +16 -0
  46. package/dist/components/Daeryuntalk/ChatObject/ObjectBack.tsx +28 -0
  47. package/dist/components/Daeryuntalk/ChatObject/ObjectButton.d.ts +10 -0
  48. package/dist/components/Daeryuntalk/ChatObject/ObjectButton.jsx +118 -0
  49. package/dist/components/Daeryuntalk/ChatObject/ObjectButton.tsx +162 -0
  50. package/dist/components/Daeryuntalk/ChatWidget.jsx +7 -3
  51. package/dist/components/Daeryuntalk/ChatWidget.tsx +9 -5
  52. package/dist/components/Daeryuntalk/DaeryuntalkContext.d.ts +37 -5
  53. package/dist/components/Daeryuntalk/DaeryuntalkContext.jsx +71 -157
  54. package/dist/components/Daeryuntalk/DaeryuntalkContext.tsx +128 -189
  55. package/dist/components/Daeryuntalk/Tiptap/Tiptap.d.ts +17 -0
  56. package/dist/components/Daeryuntalk/Tiptap/Tiptap.jsx +57 -0
  57. package/dist/components/Daeryuntalk/Tiptap/Tiptap.tsx +82 -0
  58. package/dist/components/Daeryuntalk/Viewer/ImageViewer.d.ts +3 -0
  59. package/dist/components/Daeryuntalk/Viewer/ImageViewer.jsx +172 -0
  60. package/dist/components/Daeryuntalk/Viewer/ImageViewer.tsx +236 -0
  61. package/dist/components/Daeryuntalk/_api/daeryuntalk/index.d.ts +133 -0
  62. package/dist/{lib/api → components/Daeryuntalk/_api}/daeryuntalk/index.js +251 -46
  63. package/dist/{lib/api → components/Daeryuntalk/_api}/daeryuntalk/index.ts +353 -129
  64. package/dist/components/Daeryuntalk/_api/daeryuntalk/type/response.d.ts +115 -0
  65. package/dist/components/Daeryuntalk/_api/daeryuntalk/type/response.js +1 -0
  66. package/dist/components/Daeryuntalk/_api/daeryuntalk/type/response.ts +135 -0
  67. package/dist/components/Daeryuntalk/_enums/ask-status.d.ts +6 -0
  68. package/dist/components/Daeryuntalk/_enums/ask-status.js +11 -0
  69. package/dist/components/Daeryuntalk/_enums/ask-status.ts +11 -0
  70. package/dist/components/Daeryuntalk/_enums/message_type.d.ts +6 -0
  71. package/dist/components/Daeryuntalk/_enums/message_type.js +13 -0
  72. package/dist/components/Daeryuntalk/_enums/message_type.ts +13 -0
  73. package/dist/components/Daeryuntalk/_enums/sender_type.d.ts +8 -0
  74. package/dist/components/Daeryuntalk/_enums/sender_type.js +16 -0
  75. package/dist/components/Daeryuntalk/_enums/sender_type.ts +16 -0
  76. package/dist/components/Daeryuntalk/_enums/socket_type.d.ts +22 -0
  77. package/dist/components/Daeryuntalk/_enums/socket_type.js +23 -0
  78. package/dist/components/Daeryuntalk/_enums/socket_type.ts +31 -0
  79. package/dist/components/Daeryuntalk/_enums/template.d.ts +32 -0
  80. package/dist/components/Daeryuntalk/_enums/template.js +49 -0
  81. package/dist/components/Daeryuntalk/_enums/template.ts +53 -0
  82. package/dist/components/Daeryuntalk/_enums/work_flow_object_expose.d.ts +34 -0
  83. package/dist/components/Daeryuntalk/_enums/work_flow_object_expose.js +66 -0
  84. package/dist/components/Daeryuntalk/_enums/work_flow_object_expose.ts +69 -0
  85. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.d.ts +46 -0
  86. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.js +296 -0
  87. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.ts +364 -0
  88. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHistory.d.ts +1 -0
  89. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHistory.js +1 -0
  90. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHistory.ts +1 -0
  91. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatSocketState.d.ts +1 -0
  92. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatSocketState.js +22 -0
  93. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatSocketState.ts +30 -0
  94. package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.d.ts +21 -0
  95. package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.js +205 -0
  96. package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.ts +240 -0
  97. package/dist/components/Daeryuntalk/_hooks/talkprovider/useViewerHook.d.ts +8 -0
  98. package/dist/components/Daeryuntalk/_hooks/talkprovider/useViewerHook.js +18 -0
  99. package/dist/components/Daeryuntalk/_hooks/talkprovider/useViewerHook.ts +23 -0
  100. package/dist/components/Daeryuntalk/_lib/index.d.ts +7 -0
  101. package/dist/components/Daeryuntalk/_lib/index.js +101 -0
  102. package/dist/components/Daeryuntalk/_lib/index.ts +137 -0
  103. package/dist/components/Daeryuntalk/_lib/utils.d.ts +2 -0
  104. package/dist/components/Daeryuntalk/_lib/utils.js +16 -0
  105. package/dist/components/Daeryuntalk/_lib/utils.ts +17 -0
  106. package/dist/components/Daeryuntalk/{types.d.ts → _types/message.d.ts} +33 -17
  107. package/dist/components/Daeryuntalk/_types/message.js +19 -0
  108. package/dist/components/Daeryuntalk/{types.ts → _types/message.ts} +64 -19
  109. package/dist/components/Daeryuntalk/_types/message_object.d.ts +16 -0
  110. package/dist/components/Daeryuntalk/_types/message_object.js +1 -0
  111. package/dist/components/Daeryuntalk/_types/message_object.ts +20 -0
  112. package/dist/components/Daeryuntalk/_types/socket/message.d.ts +0 -0
  113. package/dist/components/Daeryuntalk/_types/socket/message.js +1 -0
  114. package/dist/components/Daeryuntalk/_types/socket/message.ts +0 -0
  115. package/dist/components/Daeryuntalk/_types/socket/workflow.d.ts +15 -0
  116. package/dist/components/Daeryuntalk/_types/socket/workflow.js +1 -0
  117. package/dist/components/Daeryuntalk/_types/socket/workflow.ts +15 -0
  118. package/dist/components/Daeryuntalk/_ui/buttons/Button1.d.ts +10 -0
  119. package/dist/components/Daeryuntalk/_ui/buttons/Button1.jsx +11 -0
  120. package/dist/components/Daeryuntalk/_ui/buttons/Button1.tsx +28 -0
  121. package/dist/components/Daeryuntalk/_ui/inputs/Input1.d.ts +12 -0
  122. package/dist/components/Daeryuntalk/_ui/inputs/Input1.jsx +9 -0
  123. package/dist/components/Daeryuntalk/_ui/inputs/Input1.tsx +39 -0
  124. package/dist/components/Daeryuntalk/index.tsx +1 -0
  125. package/dist/lib/categoryMenuName.js +0 -3
  126. package/dist/lib/categoryMenuName.ts +0 -2
  127. package/dist/lib/index.js +1 -1
  128. package/dist/lib/index.ts +1 -1
  129. package/dist/styles/globals.css +161 -8
  130. package/dist/tsconfig.tsbuildinfo +1 -1
  131. package/package.json +8 -2
  132. package/dist/components/Daeryuntalk/types.js +0 -8
  133. package/dist/lib/api/daeryuntalk/index.d.ts +0 -143
  134. /package/dist/{lib/api → components/Daeryuntalk/_api}/index.d.ts +0 -0
  135. /package/dist/{lib/api → components/Daeryuntalk/_api}/index.js +0 -0
  136. /package/dist/{lib/api → components/Daeryuntalk/_api}/index.ts +0 -0
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import Image from 'next/image';
3
+ const WorkFlowClickData = ({ message }) => {
4
+ var _a, _b;
5
+ const iconBlock = (_b = (_a = message === null || message === void 0 ? void 0 : message.blocks) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : null;
6
+ if (!iconBlock) {
7
+ return null;
8
+ }
9
+ return (<div className={`
10
+ flex flex-row items-center justify-center gap-[6px] rounded-[10px]
11
+ border-[1px] border-solid border-[#2E385B] bg-[#F7F7F7] px-[12px] py-[8px]
12
+ text-[14px] leading-[130%] tracking-[-4%] text-[#2E385B]
13
+ `}>
14
+ <div className={`h-[18px] w-[18px]`}>
15
+ <Image className={`h-full w-full`} src={(iconBlock === null || iconBlock === void 0 ? void 0 : iconBlock.iconUrl) || ''} alt={'icon'} width={100} height={100}/>
16
+ </div>
17
+ <p>{iconBlock === null || iconBlock === void 0 ? void 0 : iconBlock.value}</p>
18
+ </div>);
19
+ };
20
+ export default WorkFlowClickData;
@@ -0,0 +1,36 @@
1
+ import React from 'react';
2
+ import { Message } from '../_types/message';
3
+ import Image from 'next/image';
4
+
5
+ interface props {
6
+ message: Message;
7
+ }
8
+ const WorkFlowClickData = ({ message }: props) => {
9
+ const iconBlock = message?.blocks?.[0] ?? null;
10
+ if (!iconBlock) {
11
+ return null;
12
+ }
13
+
14
+ return (
15
+ <div
16
+ className={`
17
+ flex flex-row items-center justify-center gap-[6px] rounded-[10px]
18
+ border-[1px] border-solid border-[#2E385B] bg-[#F7F7F7] px-[12px] py-[8px]
19
+ text-[14px] leading-[130%] tracking-[-4%] text-[#2E385B]
20
+ `}
21
+ >
22
+ <div className={`h-[18px] w-[18px]`}>
23
+ <Image
24
+ className={`h-full w-full`}
25
+ src={iconBlock?.iconUrl || ''}
26
+ alt={'icon'}
27
+ width={100}
28
+ height={100}
29
+ />
30
+ </div>
31
+ <p>{iconBlock?.value}</p>
32
+ </div>
33
+ );
34
+ };
35
+
36
+ export default WorkFlowClickData;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { Message } from '../_types/message';
3
+ interface props {
4
+ message: Message;
5
+ }
6
+ declare const WorkFlowImg: ({ message }: props) => React.JSX.Element;
7
+ export default WorkFlowImg;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import Image from 'next/image';
3
+ const WorkFlowImg = ({ message }) => {
4
+ const workFlowItem = message.workFlow;
5
+ return (<div className={`mb-[10px] h-[311px] w-[281px] overflow-hidden rounded-[10px] border-[1px] border-solid`}>
6
+ <Image src={(workFlowItem === null || workFlowItem === void 0 ? void 0 : workFlowItem.imageUrl) || ''} alt={''} width={300} height={300} className={`h-full w-full`}/>
7
+ </div>);
8
+ };
9
+ export default WorkFlowImg;
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import Image from 'next/image';
3
+ import { Message } from '../_types/message';
4
+ interface props {
5
+ message: Message;
6
+ }
7
+ const WorkFlowImg = ({ message }: props) => {
8
+ const workFlowItem = message.workFlow;
9
+ return (
10
+ <div className={`mb-[10px] h-[311px] w-[281px] overflow-hidden rounded-[10px] border-[1px] border-solid`}>
11
+ <Image src={workFlowItem?.imageUrl || ''} alt={''} width={300} height={300} className={`h-full w-full`} />
12
+ </div>
13
+ );
14
+ };
15
+
16
+ export default WorkFlowImg;
@@ -1,7 +1,17 @@
1
1
  import React from 'react';
2
- import { Message } from './types';
2
+ import { Message } from './_types/message';
3
+ import { MessageObject } from './_types/message_object';
3
4
  type ChatMessageProps = {
4
5
  message: Message;
6
+ object?: MessageObject | null;
7
+ handelObjectBack?: (data: {
8
+ chatInquiryNumber: string;
9
+ messageNumber: string;
10
+ workFlowNavigationCode: string;
11
+ }) => void;
12
+ chatInquiryNumber: string;
13
+ workFlowStack: string[];
14
+ isHovered: boolean;
5
15
  };
6
16
  declare const ChatMessage: React.FC<ChatMessageProps>;
7
17
  export default ChatMessage;
@@ -1,43 +1,145 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  import React from 'react';
2
- import { hasBlocks } from './types';
11
+ import { hasBlocks, hasWorkFlowImg, hasCustomerWorkFlowClickData, hasForm, hasRichForm, hasFileArray } from './_types/message';
3
12
  import DaeryunLogoIcon from '../../asset/images/daeryuntalk/daeryun-logo.svg';
4
- const ChatMessage = ({ message }) => {
5
- const isUser = message.sender === 'user';
13
+ import { ObjectNumber, WorkFlowBackOrInit, WorkFlowButtonUiCode } from './_enums/work_flow_object_expose';
14
+ import { MessageSenderType } from './_enums/sender_type';
15
+ import ObjectButton from './ChatObject/ObjectButton';
16
+ import ObjectBack from './ChatObject/ObjectBack';
17
+ import WorkFlowClickData from './ChatItem/WorkFlowClickData';
18
+ import WorkFlowImg from './ChatItem/WorkFlowImg';
19
+ import WorkFlowAuthForm from './ChatItem/WorkFlowAuthForm';
20
+ import ChatWrapper from './ChatItem/ChatWrapper';
21
+ import RichText from './ChatItem/RichText';
22
+ import ChatFile from './ChatItem/ChatFile';
23
+ import { getMessageFileDownloadUrl } from './_api';
24
+ const ChatMessage = ({ message, object, handelObjectBack, chatInquiryNumber, workFlowStack, isHovered }) => {
25
+ // 고객 , 오퍼레이터 분리
26
+ const isOperator = message.senderType !== MessageSenderType.CUSTOMER;
6
27
  const formatTime = (date) => {
7
28
  const hours = date.getHours().toString().padStart(2, '0');
8
29
  const minutes = date.getMinutes().toString().padStart(2, '0');
9
30
  return `${hours}:${minutes}`;
10
31
  };
11
32
  const time = formatTime(message.createdAt);
33
+ getMessageFileDownloadUrl;
12
34
  // 텍스트 블록 렌더링
13
- 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'}`}>
14
- <p className="text-sm leading-[130%] tracking-[-4%]">{block.value}</p>
15
- </div>);
35
+ const renderText = (message) => {
36
+ /**
37
+ * 메세지 UICode 기반으로 바꿔야할 듯함
38
+ */
39
+ const isWorkFlowImg = hasWorkFlowImg(message);
40
+ const isBlock = hasBlocks(message);
41
+ const isWorkFlowCustomerClickData = hasCustomerWorkFlowClickData(message);
42
+ const isAuthForm = hasForm(message);
43
+ const isRichForm = hasRichForm(message);
44
+ const isFile = hasFileArray(message);
45
+ // const isHasFile = hasFiles(message);
46
+ // const isHasImage = hasImages(message);
47
+ if (isFile) {
48
+ return (<div className={`flex flex-col gap-[10px]`}>
49
+ {isRichForm && (<div className={`flex flex-row items-end gap-[4px]`}>
50
+ <ChatWrapper isOperator={isOperator}>
51
+ <RichText message={message}/>
52
+ </ChatWrapper>
53
+ <div className={`text-[12px] font-[400] text-[#C2C2C2]`}>{time}</div>
54
+ </div>)}
55
+ <ChatFile message={message} isOperator={isOperator} isHovered={isHovered} time={time}/>
56
+ </div>);
57
+ }
58
+ if (isAuthForm) {
59
+ return (<div className={`max-w-[80%]`}>
60
+ <WorkFlowAuthForm message={message} isOperator={isOperator}/>
61
+ </div>);
62
+ }
63
+ if (isWorkFlowCustomerClickData) {
64
+ return <WorkFlowClickData message={message}/>;
65
+ }
66
+ if (isWorkFlowImg) {
67
+ return <WorkFlowImg message={message}/>;
68
+ }
69
+ if (isRichForm) {
70
+ return (<div className={`flex flex-row items-end gap-[4px]`}>
71
+ <ChatWrapper isOperator={isOperator}>
72
+ <RichText message={message}/>
73
+ </ChatWrapper>
74
+ <div className={`text-[12px] font-[400] text-[#C2C2C2]`}>{time}</div>
75
+ </div>);
76
+ }
77
+ if (isBlock) {
78
+ }
79
+ return (<ChatWrapper isOperator={isOperator}>
80
+ <p className="whitespace-pre-line text-sm leading-[130%] tracking-[-4%]">{message.plainText}</p>
81
+ </ChatWrapper>);
82
+ };
16
83
  /** todo 메시지 내용 렌더링 추후 추가 될듯 */
17
84
  const renderMessageContent = () => {
18
85
  var _a;
19
- return (<div className="message-content">
20
- {hasBlocks(message) && ((_a = message.blocks) === null || _a === void 0 ? void 0 : _a.map((block, index) => renderTextBlock(block, index)))}
86
+ const objectFirstQuestionCheck = Array.isArray(object === null || object === void 0 ? void 0 : object.objectList)
87
+ ? Object.values(ObjectNumber).every(enumValue => { var _a; return (_a = object === null || object === void 0 ? void 0 : object.objectList) === null || _a === void 0 ? void 0 : _a.some(obj => (obj === null || obj === void 0 ? void 0 : obj.objectNumber) === enumValue); })
88
+ : false;
89
+ const objectIsBack = workFlowStack.length >= 3;
90
+ return (<div className={`
91
+ message-content
92
+ `}>
93
+ {/*{hasBlocks(message) && message.blocks?.map((block, index) => renderTextBlock(block, index))}*/}
94
+ {renderText(message)}
95
+ {/* 오브젝트 박스 */}
96
+ {object && object.exposeObjectListYn && (<div className={`mt-[10px] flex flex-col gap-[10px]`}>
97
+ <div className={`
98
+ ${WorkFlowButtonUiCode.TILE_BUTTON === (object === null || object === void 0 ? void 0 : object.objectGroupUiCode)
99
+ ? 'flex flex-row flex-wrap gap-x-[4px] gap-y-[8px]'
100
+ : 'flex flex-col gap-[8px]'}
101
+
102
+ `}>
103
+ {(_a = object.objectList) === null || _a === void 0 ? void 0 : _a.map((item, index) => {
104
+ var _a;
105
+ return (<ObjectButton key={`object-expose-${index}`} object={item} messageNumber={(object === null || object === void 0 ? void 0 : object.messageNumber) || ''} workFlowNumber={((_a = message === null || message === void 0 ? void 0 : message.workFlow) === null || _a === void 0 ? void 0 : _a.workFlowNumber) || ''} isFirstObject={objectFirstQuestionCheck} objectGroupUiCode={(object === null || object === void 0 ? void 0 : object.objectGroupUiCode) || ''}/>);
106
+ })}
107
+ </div>
108
+ {!objectFirstQuestionCheck && (<ObjectBack isBack={objectIsBack} handleBtn={() => __awaiter(void 0, void 0, void 0, function* () {
109
+ if (handelObjectBack) {
110
+ yield handelObjectBack({
111
+ chatInquiryNumber: chatInquiryNumber,
112
+ messageNumber: (object === null || object === void 0 ? void 0 : object.messageNumber) || '',
113
+ workFlowNavigationCode: objectIsBack
114
+ ? WorkFlowBackOrInit.BACK
115
+ : WorkFlowBackOrInit.INIT
116
+ });
117
+ }
118
+ })}/>)}
119
+ </div>)}
21
120
  </div>);
22
121
  };
23
- return (<div className={`mb-4 flex ${isUser ? 'justify-end' : 'justify-start'}`}>
24
- {!isUser ? (<div className="flex flex-col">
122
+ return (<div className={`mb-4 flex ${isOperator ? 'justify-start' : 'justify-end'}`}>
123
+ {/* 시스템 or 오퍼레이터 */}
124
+ {isOperator ? (<div className="flex flex-col">
25
125
  <div className="mb-1 flex items-center">
26
126
  <div className="mr-1 h-8 w-8 flex-shrink-0 rounded-full">
27
127
  <div className="relative h-full w-full p-1">
28
128
  <DaeryunLogoIcon width={24} height={24}/>
29
129
  </div>
30
130
  </div>
31
- <span className="leading-[100%] tracking-[-4%]">법무법인(유한)대륜</span>
131
+ <span className="font-[700] leading-[100%] tracking-[-4%]">법무법인(유한)대륜</span>
32
132
  </div>
33
133
 
34
134
  <div className="flex items-end gap-2 pl-9">
35
135
  {renderMessageContent()}
36
- <span className="mb-1 text-xs text-gray-500">{time}</span>
136
+ {/*<span className="mb-1 text-xs text-gray-500">{time}</span>*/}
37
137
  </div>
38
- </div>) : (<div className="flex max-w-[80%] flex-col">
138
+ </div>) : (
139
+ // 유저
140
+ <div className="flex max-w-[80%] flex-col">
39
141
  <div className="flex items-end gap-2">
40
- <span className="mb-1 text-xs text-gray-500">{time}</span>
142
+ {/*<span className="mb-1 text-xs text-gray-500">{time}</span>*/}
41
143
  {renderMessageContent()}
42
144
  </div>
43
145
  </div>)}
@@ -1,13 +1,55 @@
1
1
  import React from 'react';
2
- import { Message, TextBlock, hasBlocks } from './types';
2
+ import {
3
+ Message,
4
+ TextBlock,
5
+ hasBlocks,
6
+ hasWorkFlowImg,
7
+ hasCustomerWorkFlowClickData,
8
+ hasForm,
9
+ hasRichForm,
10
+ hasFiles,
11
+ hasImages,
12
+ hasFileArray
13
+ } from './_types/message';
3
14
  import DaeryunLogoIcon from '../../asset/images/daeryuntalk/daeryun-logo.svg';
15
+ import { MessageObject } from './_types/message_object';
16
+ import Image from 'next/image';
17
+ import { ObjectNumber, WorkFlowBackOrInit, WorkFlowButtonUiCode } from './_enums/work_flow_object_expose';
18
+ import { MessageSenderType } from './_enums/sender_type';
19
+ import { useDaeryuntalk } from './DaeryuntalkContext';
20
+ import ObjectButton from './ChatObject/ObjectButton';
21
+ import ObjectBack from './ChatObject/ObjectBack';
22
+ import WorkFlowClickData from './ChatItem/WorkFlowClickData';
23
+ import WorkFlowImg from './ChatItem/WorkFlowImg';
24
+ import WorkFlowAuthForm from './ChatItem/WorkFlowAuthForm';
25
+ import ChatWrapper from './ChatItem/ChatWrapper';
26
+ import RichText from './ChatItem/RichText';
27
+ import ChatFile from './ChatItem/ChatFile';
28
+ import { getMessageFileDownloadUrl } from './_api';
4
29
 
5
30
  type ChatMessageProps = {
6
31
  message: Message;
32
+ object?: MessageObject | null;
33
+ handelObjectBack?: (data: {
34
+ chatInquiryNumber: string;
35
+ messageNumber: string;
36
+ workFlowNavigationCode: string;
37
+ }) => void;
38
+ chatInquiryNumber: string;
39
+ workFlowStack: string[];
40
+ isHovered: boolean;
7
41
  };
8
42
 
9
- const ChatMessage: React.FC<ChatMessageProps> = ({ message }) => {
10
- const isUser = message.sender === 'user';
43
+ const ChatMessage: React.FC<ChatMessageProps> = ({
44
+ message,
45
+ object,
46
+ handelObjectBack,
47
+ chatInquiryNumber,
48
+ workFlowStack,
49
+ isHovered
50
+ }) => {
51
+ // 고객 , 오퍼레이터 분리
52
+ const isOperator = message.senderType !== MessageSenderType.CUSTOMER;
11
53
 
12
54
  const formatTime = (date: Date): string => {
13
55
  const hours = date.getHours().toString().padStart(2, '0');
@@ -17,29 +59,141 @@ const ChatMessage: React.FC<ChatMessageProps> = ({ message }) => {
17
59
 
18
60
  const time = formatTime(message.createdAt);
19
61
 
62
+ getMessageFileDownloadUrl;
63
+
20
64
  // 텍스트 블록 렌더링
21
- const renderTextBlock = (block: TextBlock, index: number) => (
22
- <div
23
- key={`text-${index}`}
24
- className={`mb-1 rounded-[10px] border p-2 ${
25
- isUser ? 'border-[#2E385B] text-[#2E385B]' : 'border-[#EDEDED] text-black'
26
- }`}
27
- >
28
- <p className="text-sm leading-[130%] tracking-[-4%]">{block.value}</p>
29
- </div>
30
- );
65
+ const renderText = (message: Message) => {
66
+ /**
67
+ * 메세지 UICode 기반으로 바꿔야할 듯함
68
+ */
69
+ const isWorkFlowImg = hasWorkFlowImg(message);
70
+ const isBlock = hasBlocks(message);
71
+ const isWorkFlowCustomerClickData = hasCustomerWorkFlowClickData(message);
72
+ const isAuthForm = hasForm(message);
73
+ const isRichForm = hasRichForm(message);
74
+ const isFile = hasFileArray(message);
75
+ // const isHasFile = hasFiles(message);
76
+ // const isHasImage = hasImages(message);
77
+ if (isFile) {
78
+ return (
79
+ <div className={`flex flex-col gap-[10px]`}>
80
+ {isRichForm && (
81
+ <div className={`flex flex-row items-end gap-[4px]`}>
82
+ <ChatWrapper isOperator={isOperator}>
83
+ <RichText message={message} />
84
+ </ChatWrapper>
85
+ <div className={`text-[12px] font-[400] text-[#C2C2C2]`}>{time}</div>
86
+ </div>
87
+ )}
88
+ <ChatFile message={message} isOperator={isOperator} isHovered={isHovered} time={time} />
89
+ </div>
90
+ );
91
+ }
92
+
93
+ if (isAuthForm) {
94
+ return (
95
+ <div className={`max-w-[80%]`}>
96
+ <WorkFlowAuthForm message={message} isOperator={isOperator} />
97
+ </div>
98
+ );
99
+ }
100
+ if (isWorkFlowCustomerClickData) {
101
+ return <WorkFlowClickData message={message} />;
102
+ }
103
+ if (isWorkFlowImg) {
104
+ return <WorkFlowImg message={message} />;
105
+ }
106
+ if (isRichForm) {
107
+ return (
108
+ <div className={`flex flex-row items-end gap-[4px]`}>
109
+ <ChatWrapper isOperator={isOperator}>
110
+ <RichText message={message} />
111
+ </ChatWrapper>
112
+ <div className={`text-[12px] font-[400] text-[#C2C2C2]`}>{time}</div>
113
+ </div>
114
+ );
115
+ }
116
+
117
+ if (isBlock) {
118
+ }
119
+
120
+ return (
121
+ <ChatWrapper isOperator={isOperator}>
122
+ <p className="whitespace-pre-line text-sm leading-[130%] tracking-[-4%]">{message.plainText}</p>
123
+ </ChatWrapper>
124
+ );
125
+ };
126
+
31
127
  /** todo 메시지 내용 렌더링 추후 추가 될듯 */
32
128
  const renderMessageContent = () => {
129
+ const objectFirstQuestionCheck = Array.isArray(object?.objectList)
130
+ ? Object.values(ObjectNumber).every(enumValue =>
131
+ object?.objectList?.some(obj => obj?.objectNumber === enumValue)
132
+ )
133
+ : false;
134
+
135
+ const objectIsBack = workFlowStack.length >= 3;
136
+
33
137
  return (
34
- <div className="message-content">
35
- {hasBlocks(message) && message.blocks?.map((block, index) => renderTextBlock(block, index))}
138
+ <div
139
+ className={`
140
+ message-content
141
+ `}
142
+ >
143
+ {/*{hasBlocks(message) && message.blocks?.map((block, index) => renderTextBlock(block, index))}*/}
144
+ {renderText(message)}
145
+ {/* 오브젝트 박스 */}
146
+ {object && object.exposeObjectListYn && (
147
+ <div className={`mt-[10px] flex flex-col gap-[10px]`}>
148
+ <div
149
+ className={`
150
+ ${
151
+ WorkFlowButtonUiCode.TILE_BUTTON === object?.objectGroupUiCode
152
+ ? 'flex flex-row flex-wrap gap-x-[4px] gap-y-[8px]'
153
+ : 'flex flex-col gap-[8px]'
154
+ }
155
+
156
+ `}
157
+ >
158
+ {object.objectList?.map((item, index) => {
159
+ return (
160
+ <ObjectButton
161
+ key={`object-expose-${index}`}
162
+ object={item}
163
+ messageNumber={object?.messageNumber || ''}
164
+ workFlowNumber={message?.workFlow?.workFlowNumber || ''}
165
+ isFirstObject={objectFirstQuestionCheck}
166
+ objectGroupUiCode={object?.objectGroupUiCode || ''}
167
+ />
168
+ );
169
+ })}
170
+ </div>
171
+ {!objectFirstQuestionCheck && (
172
+ <ObjectBack
173
+ isBack={objectIsBack}
174
+ handleBtn={async () => {
175
+ if (handelObjectBack) {
176
+ await handelObjectBack({
177
+ chatInquiryNumber: chatInquiryNumber,
178
+ messageNumber: object?.messageNumber || '',
179
+ workFlowNavigationCode: objectIsBack
180
+ ? WorkFlowBackOrInit.BACK
181
+ : WorkFlowBackOrInit.INIT
182
+ });
183
+ }
184
+ }}
185
+ />
186
+ )}
187
+ </div>
188
+ )}
36
189
  </div>
37
190
  );
38
191
  };
39
192
 
40
193
  return (
41
- <div className={`mb-4 flex ${isUser ? 'justify-end' : 'justify-start'}`}>
42
- {!isUser ? (
194
+ <div className={`mb-4 flex ${isOperator ? 'justify-start' : 'justify-end'}`}>
195
+ {/* 시스템 or 오퍼레이터 */}
196
+ {isOperator ? (
43
197
  <div className="flex flex-col">
44
198
  <div className="mb-1 flex items-center">
45
199
  <div className="mr-1 h-8 w-8 flex-shrink-0 rounded-full">
@@ -47,18 +201,19 @@ const ChatMessage: React.FC<ChatMessageProps> = ({ message }) => {
47
201
  <DaeryunLogoIcon width={24} height={24} />
48
202
  </div>
49
203
  </div>
50
- <span className="leading-[100%] tracking-[-4%]">법무법인(유한)대륜</span>
204
+ <span className="font-[700] leading-[100%] tracking-[-4%]">법무법인(유한)대륜</span>
51
205
  </div>
52
206
 
53
207
  <div className="flex items-end gap-2 pl-9">
54
208
  {renderMessageContent()}
55
- <span className="mb-1 text-xs text-gray-500">{time}</span>
209
+ {/*<span className="mb-1 text-xs text-gray-500">{time}</span>*/}
56
210
  </div>
57
211
  </div>
58
212
  ) : (
213
+ // 유저
59
214
  <div className="flex max-w-[80%] flex-col">
60
215
  <div className="flex items-end gap-2">
61
- <span className="mb-1 text-xs text-gray-500">{time}</span>
216
+ {/*<span className="mb-1 text-xs text-gray-500">{time}</span>*/}
62
217
  {renderMessageContent()}
63
218
  </div>
64
219
  </div>
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ interface props {
3
+ isBack: boolean;
4
+ handleBtn?: () => void;
5
+ }
6
+ declare const ObjectBack: ({ isBack, handleBtn }: props) => React.JSX.Element;
7
+ export default ObjectBack;
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import BackIcon from '../../../asset/images/daeryuntalk/objectBack.svg';
3
+ import FirstGoICon from '../../../asset/images/daeryuntalk/firstGo.svg';
4
+ const ObjectBack = ({ isBack, handleBtn }) => {
5
+ return (<button type={'button'} onClick={() => {
6
+ if (handleBtn) {
7
+ handleBtn();
8
+ }
9
+ }} className={`flex flex-row items-center gap-[4px] `}>
10
+ {isBack ? <BackIcon /> : <FirstGoICon />}
11
+ <p className={` text-[14px] font-[400] leading-[110%] tracking-[-4%] text-[#1E1E1E] `}>
12
+ {isBack ? '이전으로' : '처음으로'}
13
+ </p>
14
+ </button>);
15
+ };
16
+ export default ObjectBack;
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+ import BackIcon from '../../../asset/images/daeryuntalk/objectBack.svg';
3
+ import FirstGoICon from '../../../asset/images/daeryuntalk/firstGo.svg';
4
+
5
+ interface props {
6
+ isBack: boolean;
7
+ handleBtn?: () => void;
8
+ }
9
+ const ObjectBack = ({ isBack, handleBtn }: props) => {
10
+ return (
11
+ <button
12
+ type={'button'}
13
+ onClick={() => {
14
+ if (handleBtn) {
15
+ handleBtn();
16
+ }
17
+ }}
18
+ className={`flex flex-row items-center gap-[4px] `}
19
+ >
20
+ {isBack ? <BackIcon /> : <FirstGoICon />}
21
+ <p className={` text-[14px] font-[400] leading-[110%] tracking-[-4%] text-[#1E1E1E] `}>
22
+ {isBack ? '이전으로' : '처음으로'}
23
+ </p>
24
+ </button>
25
+ );
26
+ };
27
+
28
+ export default ObjectBack;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { MessageObjectExpose } from '../_types/message_object';
3
+ declare const ObjectButton: ({ object, messageNumber, workFlowNumber, isFirstObject, objectGroupUiCode }: {
4
+ object: MessageObjectExpose;
5
+ messageNumber: string;
6
+ workFlowNumber: string;
7
+ isFirstObject: boolean;
8
+ objectGroupUiCode: string;
9
+ }) => React.JSX.Element;
10
+ export default ObjectButton;