@droppii-org/chat-sdk 0.1.23 → 0.1.25

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 (181) hide show
  1. package/dist/components/biz-inbox/BizInboxHeader.d.ts +3 -0
  2. package/dist/components/biz-inbox/BizInboxHeader.d.ts.map +1 -0
  3. package/dist/components/biz-inbox/BizInboxHeader.js +8 -0
  4. package/dist/components/biz-inbox/BizThreadAvatar.d.ts +10 -0
  5. package/dist/components/biz-inbox/BizThreadAvatar.d.ts.map +1 -0
  6. package/dist/components/biz-inbox/BizThreadAvatar.js +8 -0
  7. package/dist/components/biz-inbox/BizThreadCard.d.ts +8 -0
  8. package/dist/components/biz-inbox/BizThreadCard.d.ts.map +1 -0
  9. package/dist/components/biz-inbox/BizThreadCard.js +25 -0
  10. package/dist/components/biz-inbox/BizThreadList.d.ts +11 -0
  11. package/dist/components/biz-inbox/BizThreadList.d.ts.map +1 -0
  12. package/dist/components/biz-inbox/BizThreadList.js +35 -0
  13. package/dist/components/biz-inbox/BizThreadTitle.d.ts +8 -0
  14. package/dist/components/biz-inbox/BizThreadTitle.d.ts.map +1 -0
  15. package/dist/components/biz-inbox/BizThreadTitle.js +6 -0
  16. package/dist/components/biz-inbox/index.d.ts +10 -0
  17. package/dist/components/biz-inbox/index.d.ts.map +1 -0
  18. package/dist/components/biz-inbox/index.js +5 -0
  19. package/dist/components/bizInbox/BizThreadAvatar.d.ts +10 -0
  20. package/dist/components/bizInbox/BizThreadAvatar.d.ts.map +1 -0
  21. package/dist/components/bizInbox/BizThreadAvatar.js +8 -0
  22. package/dist/components/bizInbox/BizThreadCard.d.ts.map +1 -1
  23. package/dist/components/bizInbox/BizThreadCard.js +12 -40
  24. package/dist/components/bizInbox/BizThreadList.d.ts +1 -1
  25. package/dist/components/bizInbox/BizThreadList.d.ts.map +1 -1
  26. package/dist/components/bizInbox/BizThreadList.js +22 -4
  27. package/dist/components/bizInbox/BizThreadTitle.d.ts +8 -0
  28. package/dist/components/bizInbox/BizThreadTitle.d.ts.map +1 -0
  29. package/dist/components/bizInbox/BizThreadTitle.js +6 -0
  30. package/dist/components/bizInbox/index.d.ts +4 -0
  31. package/dist/components/bizInbox/index.d.ts.map +1 -1
  32. package/dist/components/bizInbox/index.js +2 -0
  33. package/dist/components/bizThreadDetail/BizMessageBubble.d.ts +10 -0
  34. package/dist/components/bizThreadDetail/BizMessageBubble.d.ts.map +1 -0
  35. package/dist/components/bizThreadDetail/BizMessageBubble.js +11 -0
  36. package/dist/components/bizThreadDetail/BizMessageList.d.ts +3 -0
  37. package/dist/components/bizThreadDetail/BizMessageList.d.ts.map +1 -0
  38. package/dist/components/bizThreadDetail/BizMessageList.js +28 -0
  39. package/dist/components/bizThreadDetail/BizThreadDetailHeader.d.ts +8 -0
  40. package/dist/components/bizThreadDetail/BizThreadDetailHeader.d.ts.map +1 -0
  41. package/dist/components/bizThreadDetail/BizThreadDetailHeader.js +18 -0
  42. package/dist/components/bizThreadDetail/BizThreadDetailInput.d.ts +8 -0
  43. package/dist/components/bizThreadDetail/BizThreadDetailInput.d.ts.map +1 -0
  44. package/dist/components/bizThreadDetail/BizThreadDetailInput.js +147 -0
  45. package/dist/components/bizThreadDetail/index.d.ts +8 -0
  46. package/dist/components/bizThreadDetail/index.d.ts.map +1 -0
  47. package/dist/components/bizThreadDetail/index.js +4 -0
  48. package/dist/components/bizThreadDetail/item/BizMessageItem.d.ts +8 -0
  49. package/dist/components/bizThreadDetail/item/BizMessageItem.d.ts.map +1 -0
  50. package/dist/components/bizThreadDetail/item/BizMessageItem.js +20 -0
  51. package/dist/components/cannedResponse/CannedResponseBody.js +2 -2
  52. package/dist/components/cannedResponse/CannedResponseFooter.js +1 -1
  53. package/dist/components/cannedResponse/CannedResponseHeader.js +1 -1
  54. package/dist/components/cannedResponse/team/TeamItem.d.ts.map +1 -1
  55. package/dist/components/cannedResponse/team/TeamItem.js +1 -1
  56. package/dist/components/chatBubble/ChatBubble.js +1 -1
  57. package/dist/components/conversation/ConversationBySessionItem.d.ts.map +1 -1
  58. package/dist/components/conversation/DeskConversationList.js +3 -3
  59. package/dist/components/mediaCollection/FileCollection.js +1 -1
  60. package/dist/components/mediaCollection/LinkCollection.js +1 -1
  61. package/dist/components/mediaCollection/VideoCollection.js +1 -1
  62. package/dist/components/mediaCollection/index.js +1 -1
  63. package/dist/components/message/GroupMembersDrawer.d.ts.map +1 -1
  64. package/dist/components/message/GroupMembersDrawer.js +1 -1
  65. package/dist/components/message/MessageHeader.d.ts.map +1 -1
  66. package/dist/components/message/MessageHeader.js +3 -3
  67. package/dist/components/message/MessageInfiniteScroll.d.ts +15 -0
  68. package/dist/components/message/MessageInfiniteScroll.d.ts.map +1 -0
  69. package/dist/components/message/MessageInfiniteScroll.js +20 -0
  70. package/dist/components/message/MessageList.d.ts.map +1 -1
  71. package/dist/components/message/MessageList.js +8 -76
  72. package/dist/components/message/SelectSession.js +1 -1
  73. package/dist/components/message/UnassignedSessionFooter.js +2 -2
  74. package/dist/components/message/footer/ActionBar.js +1 -1
  75. package/dist/components/message/footer/FilePreview.js +1 -1
  76. package/dist/components/message/footer/MediaActions.js +1 -1
  77. package/dist/components/message/footer/QuotedMessage.js +1 -1
  78. package/dist/components/message/footer/index.d.ts.map +1 -1
  79. package/dist/components/message/footer/index.js +1 -1
  80. package/dist/components/message/item/FileMessage.js +1 -1
  81. package/dist/components/message/item/QuoteMessage.js +2 -2
  82. package/dist/components/message/item/TextMessage.js +1 -1
  83. package/dist/components/message/item/index.js +1 -1
  84. package/dist/components/richTextEditor/RichTextEditor.js +4 -4
  85. package/dist/components/searchConversation/SearchAll.js +1 -1
  86. package/dist/components/searchConversation/SearchDrawer.js +1 -1
  87. package/dist/components/searchConversation/item/SearchItemAsUser.d.ts.map +1 -1
  88. package/dist/components/session/DeskAssignedSession.js +1 -1
  89. package/dist/components/session/DeskTeamInbox.js +1 -1
  90. package/dist/components/session/SessionFilterMenu.d.ts.map +1 -1
  91. package/dist/components/session/sessionMenuItems.d.ts.map +1 -1
  92. package/dist/components/session/sessionMenuItems.js +1 -1
  93. package/dist/components/thread/AssignConfirmModal.d.ts.map +1 -1
  94. package/dist/components/thread/ManualAssignPopover.js +1 -1
  95. package/dist/components/thread/SessionSection.d.ts.map +1 -1
  96. package/dist/components/thread/SessionSection.js +1 -1
  97. package/dist/components/thread/UserSection.js +1 -1
  98. package/dist/context/ChatContext.d.ts.map +1 -1
  99. package/dist/hooks/biz/index.d.ts +1 -0
  100. package/dist/hooks/biz/index.d.ts.map +1 -1
  101. package/dist/hooks/biz/index.js +1 -0
  102. package/dist/hooks/biz/useBizConversationList.d.ts.map +1 -1
  103. package/dist/hooks/biz/useBizSendMessage.d.ts +4 -0
  104. package/dist/hooks/biz/useBizSendMessage.d.ts.map +1 -0
  105. package/dist/hooks/biz/useBizSendMessage.js +61 -0
  106. package/dist/hooks/biz/useCreateBizConversation.d.ts.map +1 -1
  107. package/dist/hooks/cannedResponse/useFetchCannedCategories.d.ts.map +1 -1
  108. package/dist/hooks/cannedResponse/useFetchCannedResponse.d.ts.map +1 -1
  109. package/dist/hooks/conversation/useConversation.js +1 -1
  110. package/dist/hooks/global/useGlobalEvent.js +2 -2
  111. package/dist/hooks/message/useMessageListScroll.d.ts +29 -0
  112. package/dist/hooks/message/useMessageListScroll.d.ts.map +1 -0
  113. package/dist/hooks/message/useMessageListScroll.js +88 -0
  114. package/dist/hooks/message/usePullSessionMessages.d.ts.map +1 -1
  115. package/dist/hooks/message/useSendMessage.d.ts.map +1 -1
  116. package/dist/hooks/message/useSendMessage.js +1 -1
  117. package/dist/hooks/search/useSearchMessage.d.ts.map +1 -1
  118. package/dist/hooks/session/useAssignSession.d.ts.map +1 -1
  119. package/dist/hooks/session/useCloseSession.d.ts.map +1 -1
  120. package/dist/hooks/session/useCreateNote.d.ts.map +1 -1
  121. package/dist/hooks/session/useGetLabelSession.d.ts.map +1 -1
  122. package/dist/hooks/session/useGetListSessionByConversation.d.ts.map +1 -1
  123. package/dist/hooks/session/useGetSession.d.ts.map +1 -1
  124. package/dist/hooks/session/useGetSessionSummary.d.ts.map +1 -1
  125. package/dist/hooks/session/useGetTeamSessionSummary.d.ts.map +1 -1
  126. package/dist/hooks/session/useGetTeamSessionSummary.js +14 -8
  127. package/dist/hooks/session/useGetTeamSupporters.d.ts.map +1 -1
  128. package/dist/hooks/session/useGetUserSideInfo.d.ts.map +1 -1
  129. package/dist/hooks/session/useJoinSession.d.ts.map +1 -1
  130. package/dist/hooks/session/useLeaveConversation.d.ts.map +1 -1
  131. package/dist/hooks/session/useReopenOrCreateSession.d.ts.map +1 -1
  132. package/dist/hooks/session/useSessionLatestPreview.d.ts.map +1 -1
  133. package/dist/hooks/session/useSessionLatestPreview.js +1 -1
  134. package/dist/hooks/session/useSortedSessions.d.ts.map +1 -1
  135. package/dist/hooks/session/useUpdateNote.d.ts.map +1 -1
  136. package/dist/hooks/session/useUpdateSession.d.ts.map +1 -1
  137. package/dist/hooks/session/useUpdateSessionInfo.d.ts.map +1 -1
  138. package/dist/hooks/team/useFetchMyTeam.d.ts.map +1 -1
  139. package/dist/hooks/user/useCurrentUserAccountType.d.ts.map +1 -1
  140. package/dist/hooks/user/useUpdateFcmToken.d.ts.map +1 -1
  141. package/dist/hooks/user/useUpdateFcmToken.js +1 -1
  142. package/dist/index.d.ts +8 -2
  143. package/dist/index.d.ts.map +1 -1
  144. package/dist/index.js +5 -1
  145. package/dist/locales/i18n.js +3 -3
  146. package/dist/locales/i18n.ts +3 -3
  147. package/dist/locales/vi/biz-inbox.json +20 -0
  148. package/dist/locales/vi/bizInbox.json +7 -0
  149. package/dist/screens/bizMessage/index.d.ts.map +1 -1
  150. package/dist/screens/bizMessage/index.js +37 -12
  151. package/dist/screens/bizThreadDetail/index.d.ts +9 -0
  152. package/dist/screens/bizThreadDetail/index.d.ts.map +1 -0
  153. package/dist/screens/bizThreadDetail/index.js +36 -0
  154. package/dist/store/bizConversation.d.ts +12 -0
  155. package/dist/store/bizConversation.d.ts.map +1 -0
  156. package/dist/store/bizConversation.js +22 -0
  157. package/dist/store/bizMessageDraft.d.ts +8 -0
  158. package/dist/store/bizMessageDraft.d.ts.map +1 -0
  159. package/dist/store/bizMessageDraft.js +23 -0
  160. package/dist/store/type.d.ts +111 -0
  161. package/dist/store/type.d.ts.map +1 -0
  162. package/dist/store/type.js +1 -0
  163. package/dist/styles/global.css +1 -1
  164. package/dist/tsconfig.tsbuildinfo +1 -1
  165. package/dist/types/biz.d.ts +20 -17
  166. package/dist/types/biz.d.ts.map +1 -1
  167. package/dist/types/biz.js +17 -1
  168. package/dist/types/chat.d.ts +1 -0
  169. package/dist/types/chat.d.ts.map +1 -1
  170. package/dist/types/dto.d.ts +1 -1
  171. package/dist/types/dto.d.ts.map +1 -1
  172. package/dist/utils/bizConversation.d.ts +11 -0
  173. package/dist/utils/bizConversation.d.ts.map +1 -0
  174. package/dist/utils/bizConversation.js +65 -0
  175. package/dist/utils/bizMessage.d.ts +15 -0
  176. package/dist/utils/bizMessage.d.ts.map +1 -0
  177. package/dist/utils/bizMessage.js +23 -0
  178. package/dist/utils/events.d.ts +1 -0
  179. package/dist/utils/events.d.ts.map +1 -1
  180. package/dist/utils/messageTransform.d.ts.map +1 -1
  181. package/package.json +3 -2
@@ -0,0 +1,147 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useCallback, useEffect, useRef, useState } from "react";
4
+ import { useTranslation } from "react-i18next";
5
+ import clsx from "clsx";
6
+ import { Icon } from "../../components/icon";
7
+ import { useBizSendMessage } from "../../hooks/biz/useBizSendMessage";
8
+ import useBizConversationStore from "../../store/bizConversation";
9
+ import useBizMessageDraftStore from "../../store/bizMessageDraft";
10
+ import { emit } from "../../utils/events";
11
+ const MAX_LINES = 5;
12
+ const CONTAINER_MIN_HEIGHT = 48;
13
+ const BizThreadDetailInput = ({ placeholder, onSendMessage, onInputChange, }) => {
14
+ const { t } = useTranslation("biz-inbox");
15
+ const { sendTextMessage } = useBizSendMessage();
16
+ const conversationId = useBizConversationStore((state) => { var _a; return (_a = state.conversationData) === null || _a === void 0 ? void 0 : _a.conversationId; });
17
+ const setDraft = useBizMessageDraftStore((state) => state.setDraft);
18
+ const clearDraft = useBizMessageDraftStore((state) => state.clearDraft);
19
+ const containerRef = useRef(null);
20
+ const textareaRef = useRef(null);
21
+ const [value, setValue] = useState("");
22
+ const [isFocused, setIsFocused] = useState(false);
23
+ const [isSending, setIsSending] = useState(false);
24
+ const canSend = value.trim().length > 0 && !isSending;
25
+ const getTextareaHeights = useCallback(() => {
26
+ const textarea = textareaRef.current;
27
+ if (!textarea)
28
+ return null;
29
+ const lineHeight = parseFloat(window.getComputedStyle(textarea).lineHeight);
30
+ return {
31
+ lineHeight,
32
+ maxHeight: lineHeight * MAX_LINES,
33
+ };
34
+ }, []);
35
+ const adjustTextareaHeight = useCallback(() => {
36
+ const textarea = textareaRef.current;
37
+ const heights = getTextareaHeights();
38
+ if (!textarea || !heights)
39
+ return;
40
+ textarea.style.height = `${heights.lineHeight}px`;
41
+ const scrollHeight = textarea.scrollHeight;
42
+ const nextHeight = Math.min(Math.max(scrollHeight, heights.lineHeight), heights.maxHeight);
43
+ textarea.style.height = `${nextHeight}px`;
44
+ textarea.style.overflowY =
45
+ scrollHeight > heights.maxHeight ? "auto" : "hidden";
46
+ }, [getTextareaHeights]);
47
+ useEffect(() => {
48
+ var _a;
49
+ if (!conversationId) {
50
+ setValue("");
51
+ return;
52
+ }
53
+ const draft = (_a = useBizMessageDraftStore.getState().drafts[conversationId]) !== null && _a !== void 0 ? _a : "";
54
+ setValue(draft);
55
+ requestAnimationFrame(adjustTextareaHeight);
56
+ }, [conversationId, adjustTextareaHeight]);
57
+ useEffect(() => {
58
+ adjustTextareaHeight();
59
+ }, [value, adjustTextareaHeight]);
60
+ useEffect(() => {
61
+ if (!isFocused)
62
+ return;
63
+ const handlePointerDown = (event) => {
64
+ var _a, _b;
65
+ if ((_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.contains(event.target))
66
+ return;
67
+ (_b = textareaRef.current) === null || _b === void 0 ? void 0 : _b.blur();
68
+ };
69
+ document.addEventListener("pointerdown", handlePointerDown);
70
+ return () => document.removeEventListener("pointerdown", handlePointerDown);
71
+ }, [isFocused]);
72
+ useEffect(() => {
73
+ const viewport = window.visualViewport;
74
+ if (!viewport)
75
+ return;
76
+ const handleViewportChange = () => {
77
+ if (document.activeElement === textareaRef.current) {
78
+ emit("BIZ_CHAT_SCROLL_TO_BOTTOM_IF_AT_BOTTOM");
79
+ }
80
+ };
81
+ viewport.addEventListener("resize", handleViewportChange);
82
+ return () => viewport.removeEventListener("resize", handleViewportChange);
83
+ }, []);
84
+ const handleChange = (nextValue) => {
85
+ setValue(nextValue);
86
+ if (conversationId) {
87
+ setDraft(conversationId, nextValue);
88
+ }
89
+ onInputChange === null || onInputChange === void 0 ? void 0 : onInputChange(nextValue);
90
+ };
91
+ const handleSend = async () => {
92
+ const text = value.trim();
93
+ if (!text || isSending)
94
+ return;
95
+ setIsSending(true);
96
+ try {
97
+ if (onSendMessage) {
98
+ onSendMessage(text);
99
+ }
100
+ else {
101
+ const sent = await sendTextMessage(text);
102
+ if (!sent)
103
+ return;
104
+ }
105
+ setValue("");
106
+ if (conversationId) {
107
+ clearDraft(conversationId);
108
+ }
109
+ requestAnimationFrame(adjustTextareaHeight);
110
+ }
111
+ finally {
112
+ setIsSending(false);
113
+ }
114
+ };
115
+ const handleFocus = () => {
116
+ setIsFocused(true);
117
+ emit("BIZ_CHAT_SCROLL_TO_BOTTOM_IF_AT_BOTTOM");
118
+ };
119
+ const handleBlur = () => {
120
+ setIsFocused(false);
121
+ };
122
+ const insertNewline = (textarea) => {
123
+ const { selectionStart, selectionEnd } = textarea;
124
+ const nextValue = value.slice(0, selectionStart) + "\n" + value.slice(selectionEnd);
125
+ handleChange(nextValue);
126
+ requestAnimationFrame(() => {
127
+ textarea.selectionStart = selectionStart + 1;
128
+ textarea.selectionEnd = selectionStart + 1;
129
+ adjustTextareaHeight();
130
+ });
131
+ };
132
+ const handleKeyDown = (event) => {
133
+ if (event.key !== "Enter")
134
+ return;
135
+ if (event.shiftKey) {
136
+ event.preventDefault();
137
+ insertNewline(event.currentTarget);
138
+ return;
139
+ }
140
+ event.preventDefault();
141
+ void handleSend();
142
+ };
143
+ return (_jsx("div", { ref: containerRef, "data-testid": "biz-thread-detail-input", className: "flex w-full shrink-0 flex-col bg-[rgba(131,137,157,0.05)]", children: _jsxs("div", { className: "flex items-end gap-3 px-3 py-2", children: [_jsx("div", { className: clsx("flex min-w-0 flex-1 overflow-hidden rounded-xl border bg-white transition-shadow", isFocused
144
+ ? "border-[#607CFB] shadow-[0px_0px_2px_rgba(27,63,228,0.5)]"
145
+ : "border-[#DDDEDF]"), style: { minHeight: CONTAINER_MIN_HEIGHT }, children: _jsx("div", { className: "flex min-w-0 flex-[1_0_0] items-center gap-2 self-stretch px-3 py-1", children: _jsx("textarea", { ref: textareaRef, value: value, rows: 1, onChange: (event) => handleChange(event.target.value), onFocus: handleFocus, onBlur: handleBlur, onKeyDown: handleKeyDown, placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : t("thread_detail.input_placeholder"), "data-testid": "biz-thread-detail-message-input", className: "biz-message-input-scrollbar min-h-0 min-w-0 flex-1 resize-none bg-transparent text-[16px] leading-[1.6] tracking-[0.16px] text-black outline-none placeholder:text-[#747B7E]" }) }) }), _jsx("div", { className: "flex shrink-0 items-center pb-1", children: _jsx("button", { type: "button", onClick: () => void handleSend(), disabled: !canSend, "data-testid": "biz-thread-detail-send", className: clsx("flex h-10 w-10 items-center justify-center rounded-full", canSend ? "bg-[#002BEB]" : "bg-[#002BEB] opacity-25"), children: _jsx(Icon, { icon: "send-b", size: 20, className: "text-white" }) }) })] }) }));
146
+ };
147
+ export default BizThreadDetailInput;
@@ -0,0 +1,8 @@
1
+ export { default as BizThreadDetailHeader } from "./BizThreadDetailHeader";
2
+ export type { BizThreadDetailHeaderProps } from "./BizThreadDetailHeader";
3
+ export { default as BizThreadDetailInput } from "./BizThreadDetailInput";
4
+ export type { BizThreadDetailInputProps } from "./BizThreadDetailInput";
5
+ export { default as BizMessageList } from "./BizMessageList";
6
+ export { default as BizMessageItem } from "./item/BizMessageItem";
7
+ export type { BizMessageItemProps } from "./item/BizMessageItem";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/bizThreadDetail/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,YAAY,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAE1E,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACzE,YAAY,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAExE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAClE,YAAY,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { default as BizThreadDetailHeader } from "./BizThreadDetailHeader";
2
+ export { default as BizThreadDetailInput } from "./BizThreadDetailInput";
3
+ export { default as BizMessageList } from "./BizMessageList";
4
+ export { default as BizMessageItem } from "./item/BizMessageItem";
@@ -0,0 +1,8 @@
1
+ import { MessageItem } from "@openim/wasm-client-sdk";
2
+ export interface BizMessageItemProps {
3
+ message: MessageItem;
4
+ allMessages: MessageItem[];
5
+ }
6
+ declare const BizMessageItem: ({ message, allMessages }: BizMessageItemProps) => import("react/jsx-runtime").JSX.Element | null;
7
+ export default BizMessageItem;
8
+ //# sourceMappingURL=BizMessageItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BizMessageItem.d.ts","sourceRoot":"","sources":["../../../../src/components/bizThreadDetail/item/BizMessageItem.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAQtD,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,WAAW,CAAC;IACrB,WAAW,EAAE,WAAW,EAAE,CAAC;CAC5B;AA4BD,QAAA,MAAM,cAAc,GAAI,0BAA0B,mBAAmB,mDA6CpE,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -0,0 +1,20 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Icon } from "../../../components/icon";
4
+ import useAuthStore from "../../../store/auth";
5
+ import { formatTimestamp } from "../../../utils/common";
6
+ import { getBizMessageDisplay } from "../../../utils/bizMessage";
7
+ import BizMessageBubble from "../BizMessageBubble";
8
+ const BizMessageAvatar = ({ avatarUrl }) => (_jsx("div", { className: "flex shrink-0 items-center pb-4", children: avatarUrl ? (_jsx("img", { src: avatarUrl, alt: "", className: "h-6 w-6 rounded-full object-cover" })) : (_jsx("div", { className: "flex h-6 w-6 items-center justify-center rounded-full bg-[#0C5CFF]", children: _jsx(Icon, { icon: "droppii-o-1", size: 14, className: "text-white" }) })) }));
9
+ const BizMessageTime = ({ sendTime }) => (_jsx("div", { className: "flex w-full items-center px-4 py-1", children: _jsx("div", { className: "flex min-w-0 flex-1 flex-col items-start", children: _jsx("p", { className: "w-full break-words text-center text-[12px] font-normal leading-[160%] tracking-normal text-[#747B7E]", children: formatTimestamp(sendTime, { hasTime: true }) }) }) }));
10
+ const BizMessageItem = ({ message, allMessages }) => {
11
+ const userID = useAuthStore((state) => state.userID);
12
+ if (!userID)
13
+ return null;
14
+ const display = getBizMessageDisplay(message, allMessages, userID);
15
+ if (!display.isMine) {
16
+ return (_jsxs("div", { className: "flex w-full flex-col pb-1", "data-testid": "biz-message-item", children: [display.showTimeBreak && _jsx(BizMessageTime, { sendTime: display.sendTime }), _jsxs("div", { className: "flex w-full items-end pl-3 pr-12", children: [display.showAvatar ? (_jsx(BizMessageAvatar, { avatarUrl: display.senderFaceUrl })) : (_jsx("div", { className: "w-6 shrink-0" })), _jsx("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: _jsx(BizMessageBubble, { isMine: display.isMine, content: display.content, senderName: display.senderName, showSenderName: display.showSenderName, showTip: display.showTip }) })] })] }));
17
+ }
18
+ return (_jsxs("div", { className: "flex w-full flex-col pb-1", "data-testid": "biz-message-item", children: [display.showTimeBreak && _jsx(BizMessageTime, { sendTime: display.sendTime }), _jsx("div", { className: "flex w-full justify-end pl-12 pr-3", children: _jsx("div", { className: "flex min-w-0 max-w-[calc(100%-48px)] flex-col items-end gap-1", children: _jsx(BizMessageBubble, { isMine: display.isMine, content: display.content, showTip: display.showTip }) }) })] }));
19
+ };
20
+ export default BizMessageItem;
@@ -7,13 +7,13 @@ import { CannedResponseVisibleScope } from "../../types/chat";
7
7
  import TeamItem from "./team/TeamItem";
8
8
  import { useFetchCannedResponse } from "../../hooks/cannedResponse/useFetchCannedResponse";
9
9
  import InfiniteScroll from "react-infinite-scroll-component";
10
- import { Icon } from "../icon";
10
+ import { Icon } from "../../components/icon";
11
11
  import { sanitizeHtml } from "../../utils/common";
12
12
  import { useDebounce } from "ahooks";
13
13
  import clsx from "clsx";
14
14
  import emitter from "../../utils/events";
15
15
  import { isArray } from "lodash";
16
- import { useMessageFooterContext } from "../message/footer";
16
+ import { useMessageFooterContext } from "../../components/message/footer";
17
17
  const parseIndex = (index, length) => {
18
18
  if (index === null)
19
19
  return null;
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useTranslation } from "react-i18next";
3
- import { Icon } from "../icon";
3
+ import { Icon } from "../../components/icon";
4
4
  const CannedResponseFooter = ({ openCreateCannedModal, }) => {
5
5
  const { t } = useTranslation();
6
6
  return (_jsx("div", { className: "flex items-center justify-end border-t border-gray-200 p-2", children: _jsxs("div", { className: "flex cursor-pointer items-center gap-1", onClick: openCreateCannedModal, children: [_jsx(Icon, { icon: "plus-circle-o", size: 16, className: "text-blue-500" }), _jsx("span", { className: "text-sm text-blue-500", children: t("add_canned_response") })] }) }));
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useTranslation } from "react-i18next";
3
3
  import CannedResponseIcon from "../../assets/svg/cannedResponse";
4
4
  import { Button, Input } from "antd";
5
- import { Icon } from "../icon";
5
+ import { Icon } from "../../components/icon";
6
6
  const CannedResponseHeader = (props) => {
7
7
  const { onClose, search, setSearch } = props;
8
8
  const { t } = useTranslation();
@@ -1 +1 @@
1
- {"version":3,"file":"TeamItem.d.ts","sourceRoot":"","sources":["../../../../src/components/cannedResponse/team/TeamItem.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAQrD,UAAU,aAAa;IACrB,IAAI,EAAE,eAAe,CAAC;IACtB,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACjE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,QAAA,MAAM,QAAQ,GAAI,8EAMf,aAAa,4CAiFf,CAAC;AAEF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"TeamItem.d.ts","sourceRoot":"","sources":["../../../../src/components/cannedResponse/team/TeamItem.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAQ9C,UAAU,aAAa;IACrB,IAAI,EAAE,eAAe,CAAC;IACtB,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACjE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,QAAA,MAAM,QAAQ,GAAI,8EAMf,aAAa,4CAiFf,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useFetchCannedCategories } from "../../../hooks/cannedResponse/useFetchCannedCategories";
3
3
  import { useBoolean } from "ahooks";
4
- import { Icon } from "../../icon";
4
+ import { Icon } from "../../../components/icon";
5
5
  import clsx from "clsx";
6
6
  import { useTranslation } from "react-i18next";
7
7
  import { useCallback } from "react";
@@ -2,7 +2,7 @@
2
2
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { FloatButton, Drawer, Popover } from "antd";
4
4
  import { MessageOutlined, CloseOutlined } from "@ant-design/icons";
5
- import MessageList from "../message/MessageList";
5
+ import MessageList from "../../components/message/MessageList";
6
6
  import useConversationStore from "../../store/conversation";
7
7
  import { useIsMobile } from "../../hooks/common/useIsMobile";
8
8
  import { useBoolean } from "ahooks";
@@ -1 +1 @@
1
- {"version":3,"file":"ConversationBySessionItem.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/ConversationBySessionItem.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAEjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAQpD,UAAU,8BAA8B;IACtC,WAAW,EAAE,gBAAgB,CAAC;IAC9B,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B;AAED,QAAA,MAAM,yBAAyB,GAAI,iCAGhC,8BAA8B,mDAyFhC,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
1
+ {"version":3,"file":"ConversationBySessionItem.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/ConversationBySessionItem.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAE7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAQhD,UAAU,8BAA8B;IACtC,WAAW,EAAE,gBAAgB,CAAC;IAC9B,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B;AAED,QAAA,MAAM,yBAAyB,GAAI,iCAGhC,8BAA8B,mDAyFhC,CAAC;AAEF,eAAe,yBAAyB,CAAC"}
@@ -3,11 +3,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useState, useEffect, useRef } from "react";
4
4
  import { useSearchParams } from "next/navigation";
5
5
  import { Input, Empty, Drawer, Button, Spin } from "antd";
6
- import { Icon } from "../icon";
6
+ import { Icon } from "../../components/icon";
7
7
  import useConversationStore from "../../store/conversation";
8
8
  import { useTranslation } from "react-i18next";
9
9
  import { useBoolean, useDebounce } from "ahooks";
10
- import SearchConversation from "../searchConversation";
10
+ import SearchConversation from "../../components/searchConversation";
11
11
  import useSessionStore from "../../store/session";
12
12
  import InfiniteScroll from "react-infinite-scroll-component";
13
13
  import ConversationBySessionItem from "./ConversationBySessionItem";
@@ -17,7 +17,7 @@ import { useSessionLatestPreview } from "../../hooks/session/useSessionLatestPre
17
17
  import { useGetTeamSessionSummary } from "../../hooks/session/useGetTeamSessionSummary";
18
18
  import { DChatSDK } from "../../constants/sdk";
19
19
  import emitter from "../../utils/events";
20
- import { getFilterConfig } from "../session/sessionMenuItems";
20
+ import { getFilterConfig } from "../../components/session/sessionMenuItems";
21
21
  const DeskConversationList = () => {
22
22
  var _a, _b;
23
23
  const searchInputRef = useRef(null);
@@ -8,7 +8,7 @@ import dayjs from "dayjs";
8
8
  import useConversationStore from "../../store/conversation";
9
9
  import { useTranslation } from "react-i18next";
10
10
  import { documentIcon } from "../../assets/svg";
11
- import { shortenFileName } from "../message/footer/FilePreview";
11
+ import { shortenFileName } from "../../components/message/footer/FilePreview";
12
12
  import { renderFileSize } from "../../utils/common";
13
13
  const FileCollection = () => {
14
14
  const { t } = useTranslation();
@@ -7,7 +7,7 @@ import { useCallback, useEffect, useState } from "react";
7
7
  import dayjs from "dayjs";
8
8
  import InfiniteScroll from "react-infinite-scroll-component";
9
9
  import { MessageType, SessionType } from "@openim/wasm-client-sdk";
10
- import { Icon } from "../icon";
10
+ import { Icon } from "../../components/icon";
11
11
  import { DChatSDK } from "../../constants/sdk";
12
12
  import { useChatContext } from "../../context/ChatContext";
13
13
  import { message as antdMessage } from "antd";
@@ -8,7 +8,7 @@ import dayjs from "dayjs";
8
8
  import useConversationStore from "../../store/conversation";
9
9
  import { useBoolean } from "ahooks";
10
10
  import { images } from "../../constants/images";
11
- import { Icon } from "../icon";
11
+ import { Icon } from "../../components/icon";
12
12
  import { useTranslation } from "react-i18next";
13
13
  const VideoCollection = () => {
14
14
  const { t } = useTranslation();
@@ -2,7 +2,7 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { useBoolean } from "ahooks";
4
4
  import { Button, Drawer, Tabs } from "antd";
5
- import { Icon } from "../icon";
5
+ import { Icon } from "../../components/icon";
6
6
  import { useTranslation } from "react-i18next";
7
7
  import ImageCollection from "./ImageCollection";
8
8
  import VideoCollection from "./VideoCollection";
@@ -1 +1 @@
1
- {"version":3,"file":"GroupMembersDrawer.d.ts","sourceRoot":"","sources":["../../../src/components/message/GroupMembersDrawer.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAKnD,UAAU,uBAAuB;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,gBAAgB,CAAC;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAsCD,QAAA,MAAM,kBAAkB,GAAI,wDAKzB,uBAAuB,4CA0OzB,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
1
+ {"version":3,"file":"GroupMembersDrawer.d.ts","sourceRoot":"","sources":["../../../src/components/message/GroupMembersDrawer.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAK/C,UAAU,uBAAuB;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,gBAAgB,CAAC;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAsCD,QAAA,MAAM,kBAAkB,GAAI,wDAKzB,uBAAuB,4CA0OzB,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
@@ -8,7 +8,7 @@ import useAuthStore from "../../store/auth";
8
8
  import useConversationStore from "../../store/conversation";
9
9
  import { useGroupMembers } from "../../hooks/group/useGroupMembers";
10
10
  import { useLeaveConversation } from "../../hooks/session/useLeaveConversation";
11
- import { Icon } from "../icon";
11
+ import { Icon } from "../../components/icon";
12
12
  const getMemberDisplayName = (member) => {
13
13
  return member.nickname || member.userID || "";
14
14
  };
@@ -1 +1 @@
1
- {"version":3,"file":"MessageHeader.d.ts","sourceRoot":"","sources":["../../../src/components/message/MessageHeader.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAMnD,UAAU,kBAAkB;IAC1B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,cAAc,CAAC,EAAE,gBAAgB,CAAC;IAClC,QAAQ,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CAC3B;AAED,KAAK,sBAAsB,GAAG,aAAa,GAAG,UAAU,CAAC;AAEzD,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,sBAAsB,CAAC;IAC9B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED,QAAA,MAAM,aAAa,GAAI,wCAIpB,kBAAkB,4CA6MpB,CAAC;AAEF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"MessageHeader.d.ts","sourceRoot":"","sources":["../../../src/components/message/MessageHeader.tsx"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAGzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAM/C,UAAU,kBAAkB;IAC1B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,cAAc,CAAC,EAAE,gBAAgB,CAAC;IAClC,QAAQ,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CAC3B;AAED,KAAK,sBAAsB,GAAG,aAAa,GAAG,UAAU,CAAC;AAEzD,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,sBAAsB,CAAC;IAC9B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED,QAAA,MAAM,aAAa,GAAI,wCAIpB,kBAAkB,4CA6MpB,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -1,17 +1,17 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { Avatar, Button, message } from "antd";
4
- import { Icon } from "../icon";
4
+ import { Icon } from "../../components/icon";
5
5
  import { useConversationDisplayData } from "../../hooks/conversation/useConversation";
6
6
  import useConversationStore from "../../store/conversation";
7
- import MediaCollection from "../mediaCollection";
7
+ import MediaCollection from "../../components/mediaCollection";
8
8
  import { useEffect, useMemo, useState } from "react";
9
9
  import { useTranslation } from "react-i18next";
10
10
  import { SessionStatus, SessionTag } from "../../types/chat";
11
11
  import SelectSession from "./SelectSession";
12
12
  import { useUpdateSession } from "../../hooks/session/useUpdateSession";
13
13
  import useAuthStore from "../../store/auth";
14
- import SearchDrawer from "../searchConversation/SearchDrawer";
14
+ import SearchDrawer from "../../components/searchConversation/SearchDrawer";
15
15
  import { isGroupSession } from "../../utils/imCommon";
16
16
  import GroupMembersDrawer from "./GroupMembersDrawer";
17
17
  const MessageHeader = ({ onClose, currentSession, isJoined, }) => {
@@ -0,0 +1,15 @@
1
+ import { ReactNode, Ref } from "react";
2
+ import type { MessageListLoadState } from "../../hooks/message/useMessageListScroll";
3
+ export interface MessageInfiniteScrollProps {
4
+ scrollRef: Ref<HTMLDivElement>;
5
+ scrollableTargetId: string;
6
+ loadState: MessageListLoadState;
7
+ onLoadMoreOld: () => void;
8
+ onScroll: (e: React.UIEvent<HTMLDivElement>) => void;
9
+ children: ReactNode;
10
+ empty?: ReactNode;
11
+ containerClassName?: string;
12
+ }
13
+ declare const MessageInfiniteScroll: ({ scrollRef, scrollableTargetId, loadState, onLoadMoreOld, onScroll, children, empty, containerClassName, }: MessageInfiniteScrollProps) => import("react/jsx-runtime").JSX.Element;
14
+ export default MessageInfiniteScroll;
15
+ //# sourceMappingURL=MessageInfiniteScroll.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MessageInfiniteScroll.d.ts","sourceRoot":"","sources":["../../../src/components/message/MessageInfiniteScroll.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAkBjF,MAAM,WAAW,0BAA0B;IACzC,SAAS,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IAC/B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,SAAS,EAAE,oBAAoB,CAAC;IAChC,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,QAAQ,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,IAAI,CAAC;IACrD,QAAQ,EAAE,SAAS,CAAC;IACpB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,QAAA,MAAM,qBAAqB,GAAI,6GAS5B,0BAA0B,4CA8B5B,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
@@ -0,0 +1,20 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { Spin } from "antd";
4
+ import InfiniteScroll from "react-infinite-scroll-component";
5
+ const scrollContainerStyle = {
6
+ height: "100%",
7
+ overflowY: "auto",
8
+ overflowX: "hidden",
9
+ display: "flex",
10
+ flexDirection: "column-reverse",
11
+ paddingBottom: 12,
12
+ };
13
+ const infiniteScrollStyle = {
14
+ display: "flex",
15
+ flexDirection: "column-reverse",
16
+ minWidth: 0,
17
+ width: "100%",
18
+ };
19
+ const MessageInfiniteScroll = ({ scrollRef, scrollableTargetId, loadState, onLoadMoreOld, onScroll, children, empty, containerClassName, }) => (_jsx("div", { id: scrollableTargetId, ref: scrollRef, className: containerClassName, style: scrollContainerStyle, children: empty && loadState.messageList.length === 0 ? (empty) : (_jsx(InfiniteScroll, { dataLength: loadState.messageList.length, next: onLoadMoreOld, style: infiniteScrollStyle, inverse: true, hasMore: loadState.hasMoreOld, loader: _jsx("div", { className: "flex items-center justify-center py-2", children: _jsx(Spin, {}) }), scrollableTarget: scrollableTargetId, onScroll: (e) => onScroll(e), children: children })) }));
20
+ export default MessageInfiniteScroll;
@@ -1 +1 @@
1
- {"version":3,"file":"MessageList.d.ts","sourceRoot":"","sources":["../../../src/components/message/MessageList.tsx"],"names":[],"mappings":"AA4BA,UAAU,gBAAgB;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,qBAAqB,CAAC,EAAE,MAAM,IAAI,CAAC;CACpC;AAGD,QAAA,MAAM,WAAW,GAAI,OAAO,gBAAgB,4CA6V3C,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"MessageList.d.ts","sourceRoot":"","sources":["../../../src/components/message/MessageList.tsx"],"names":[],"mappings":"AA2BA,UAAU,gBAAgB;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,qBAAqB,CAAC,EAAE,MAAM,IAAI,CAAC;CACpC;AAED,QAAA,MAAM,WAAW,GAAI,OAAO,gBAAgB,4CAoQ3C,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -2,35 +2,31 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useConversationMessages } from "../../hooks/message/useConversationMessages";
4
4
  import { Button, Empty, Modal, Spin } from "antd";
5
- import { useCallback, useEffect, useRef, useState } from "react";
5
+ import { useCallback, useEffect, useState } from "react";
6
6
  import dayjs from "dayjs";
7
7
  import isToday from "dayjs/plugin/isToday";
8
8
  import emitter from "../../utils/events";
9
9
  import MessageItem from "./item";
10
- import InfiniteScroll from "react-infinite-scroll-component";
10
+ import MessageInfiniteScroll from "./MessageInfiniteScroll";
11
11
  import MessageHeader from "./MessageHeader";
12
12
  import MessageFooter from "./footer";
13
13
  import UnassignedSessionFooter from "./UnassignedSessionFooter";
14
14
  import { images } from "../../constants/images";
15
15
  import { useTranslation } from "react-i18next";
16
16
  import useConversationStore from "../../store/conversation";
17
- import { isNumber } from "lodash";
18
- import { useBoolean, useDebounceFn } from "ahooks";
17
+ import { useBoolean } from "ahooks";
18
+ import { useMessageListScroll } from "../../hooks/message/useMessageListScroll";
19
19
  import { MSG_ITEM_CONTENT_PREFIX, MSG_ITEM_PREFIX } from "../../constants";
20
- import { markConversationMessageAsRead } from "../../hooks/conversation/useConversation";
21
20
  import { useChatContext } from "../../context/ChatContext";
22
21
  import { useRevokeMessage } from "../../hooks/message/useRevokeMessage";
23
22
  import { useConversationSessionState } from "../../hooks/session/useConversationSessionState";
24
23
  import { useJoinGroupFlow } from "../../hooks/session/useJoinGroupFlow";
25
24
  import { ConnectStatus, SessionStatus } from "../../types/chat";
26
25
  dayjs.extend(isToday);
27
- const BOTTOM_THRESHOLD = -5;
28
26
  const MessageList = (props) => {
29
- var _a;
30
27
  const { t } = useTranslation();
31
28
  const { user, connectStatus } = useChatContext();
32
29
  const { onClose, conversationId, searchClientMsgID, openCreateCannedModal } = props;
33
- const scrollRef = useRef(null);
34
30
  const conversationData = useConversationStore((state) => state.conversationData);
35
31
  const setQuotedMessage = useConversationStore((state) => state.setQuotedMessage);
36
32
  const setSearchClientMsgID = useConversationStore((state) => state.setSearchClientMsgID);
@@ -47,12 +43,14 @@ const MessageList = (props) => {
47
43
  groupId,
48
44
  sessionId: latestConversationSession === null || latestConversationSession === void 0 ? void 0 : latestConversationSession.id,
49
45
  });
50
- const { getMoreOldMessages, moreOldLoading, loadState, getMoreNewMessages, moreNewLoading, latestLoadState, } = useConversationMessages({
46
+ const messageController = useConversationMessages({
51
47
  conversationId,
52
48
  searchClientMsgID,
53
49
  restrictToLastSession: shouldRestrictToLastSession,
54
50
  customerUserID,
55
51
  });
52
+ const { loadState, moreNewLoading } = messageController;
53
+ const { scrollRef, loadMoreOldMessage, handleInfiniteScroll, scrollToBottom } = useMessageListScroll(Object.assign({ conversationId, userId: user === null || user === void 0 ? void 0 : user.userID }, messageController));
56
54
  const handleOpenRevoke = useCallback((clientMsgID) => {
57
55
  setSelectedItem(clientMsgID);
58
56
  openConfirmRevoke();
@@ -70,32 +68,6 @@ const MessageList = (props) => {
70
68
  revokeMessage,
71
69
  handleCloseRevoke,
72
70
  ]);
73
- const handleMarkConversationMessageAsRead = useCallback(() => {
74
- var _a, _b, _c, _d, _e;
75
- const lastMessage = (_b = (_a = latestLoadState === null || latestLoadState === void 0 ? void 0 : latestLoadState.current) === null || _a === void 0 ? void 0 : _a.messageList) === null || _b === void 0 ? void 0 : _b[0];
76
- if (!((_c = latestLoadState === null || latestLoadState === void 0 ? void 0 : latestLoadState.current) === null || _c === void 0 ? void 0 : _c.hasMoreNew) &&
77
- !moreNewLoading &&
78
- (lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.isRead) === false &&
79
- (lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.sendID) !== (user === null || user === void 0 ? void 0 : user.userID) &&
80
- isNumber((_d = scrollRef.current) === null || _d === void 0 ? void 0 : _d.scrollTop) &&
81
- ((_e = scrollRef.current) === null || _e === void 0 ? void 0 : _e.scrollTop) >= BOTTOM_THRESHOLD) {
82
- markConversationMessageAsRead(conversationId);
83
- }
84
- }, [conversationId, moreNewLoading, user === null || user === void 0 ? void 0 : user.userID]);
85
- const scrollToBottom = () => {
86
- handleMarkConversationMessageAsRead();
87
- setTimeout(() => {
88
- var _a, _b, _c, _d;
89
- if (isNumber((_a = scrollRef.current) === null || _a === void 0 ? void 0 : _a.scrollTop) &&
90
- ((_b = scrollRef.current) === null || _b === void 0 ? void 0 : _b.scrollTop) >= BOTTOM_THRESHOLD) {
91
- return;
92
- }
93
- (_c = scrollRef.current) === null || _c === void 0 ? void 0 : _c.scrollTo({
94
- top: (_d = scrollRef.current) === null || _d === void 0 ? void 0 : _d.scrollHeight,
95
- behavior: "smooth",
96
- });
97
- });
98
- };
99
71
  const scrollToMessage = (clientMsgID) => {
100
72
  setTimeout(() => {
101
73
  const targetElement = document.getElementById(`${MSG_ITEM_PREFIX}${clientMsgID}`);
@@ -126,16 +98,6 @@ const MessageList = (props) => {
126
98
  setSearchClientMsgID(clientMsgID);
127
99
  }
128
100
  }, [scrollToMessage, loadState.messageList, setSearchClientMsgID]);
129
- const loadMoreOldMessage = () => {
130
- if (!loadState.hasMoreOld || moreOldLoading)
131
- return;
132
- getMoreOldMessages();
133
- };
134
- const { run: loadMoreNewMessage } = useDebounceFn(() => {
135
- if (!loadState.hasMoreNew || moreNewLoading)
136
- return;
137
- getMoreNewMessages();
138
- }, { wait: 200 });
139
101
  useEffect(() => {
140
102
  emitter.on("CHAT_LIST_SCROLL_TO_BOTTOM", scrollToBottom);
141
103
  emitter.on("CHAT_LIST_SCROLL_TO_MESSAGE", scrollToMessage);
@@ -155,18 +117,6 @@ const MessageList = (props) => {
155
117
  emitter.off("UPDATE_SESSION", handler);
156
118
  };
157
119
  }, [conversationId, refetchConversationSessions]);
158
- useEffect(() => {
159
- if (!loadState.hasMoreNew &&
160
- !loadState.initLoading &&
161
- loadState.messageList.length > 0) {
162
- handleMarkConversationMessageAsRead();
163
- }
164
- }, [
165
- loadState.messageList.length,
166
- loadState.hasMoreNew,
167
- loadState.initLoading,
168
- handleMarkConversationMessageAsRead,
169
- ]);
170
120
  useEffect(() => {
171
121
  if (!openMenuId)
172
122
  return;
@@ -185,24 +135,6 @@ const MessageList = (props) => {
185
135
  backgroundSize: "cover",
186
136
  backgroundPosition: "center",
187
137
  overflowX: "hidden",
188
- }, children: [_jsx(MessageHeader, { onClose: onClose, currentSession: latestConversationSession, isJoined: isJoined }), _jsx("div", { id: "scrollableMessagesDiv", ref: scrollRef, style: {
189
- height: "100%",
190
- overflowY: "auto",
191
- overflowX: "hidden",
192
- display: "flex",
193
- flexDirection: "column-reverse",
194
- paddingBottom: 12,
195
- }, children: _jsx(InfiniteScroll, { dataLength: ((_a = loadState.messageList) === null || _a === void 0 ? void 0 : _a.length) || 0, next: loadMoreOldMessage, style: {
196
- display: "flex",
197
- flexDirection: "column-reverse",
198
- minWidth: 0,
199
- width: "100%",
200
- }, inverse: true, hasMore: loadState.hasMoreOld, loader: _jsx("div", { className: "flex items-center justify-center py-2", children: _jsx(Spin, {}) }), scrollableTarget: "scrollableMessagesDiv", onScroll: (e) => {
201
- const target = e.target;
202
- if (target.scrollTop > BOTTOM_THRESHOLD) {
203
- handleMarkConversationMessageAsRead();
204
- loadMoreNewMessage();
205
- }
206
- }, children: loadState.messageList.map((message, _, array) => (_jsx(MessageItem, { message: message, allMessages: array, contextMenuOpen: openMenuId === message.clientMsgID, onContextMenuOpenChange: (open) => setOpenMenuId(open ? message.clientMsgID : null), onRevokeMessage: handleOpenRevoke, onQuoteMessage: setQuotedMessage, onPressQuoteMessage: onPressQuoteMessage }, message.clientMsgID))) }) }), moreNewLoading && (_jsx("div", { className: "flex items-center justify-center py-2", children: _jsx(Spin, {}) })), isCheckingMembership ? (_jsx("div", { className: "border-t bg-white py-4 flex items-center justify-center", children: _jsx(Spin, {}) })) : (latestConversationSession === null || latestConversationSession === void 0 ? void 0 : latestConversationSession.status) === SessionStatus.UNASSIGNED ? (_jsx(UnassignedSessionFooter, { sessionId: latestConversationSession.id, teamId: latestConversationSession.teamId })) : shouldRestrictToLastSession ? (_jsxs("div", { className: "border-t bg-white py-4 flex flex-col items-center gap-2", children: [_jsx("p", { className: "text-sm text-gray-500", children: t("join_group_required") }), _jsx(Button, { type: "primary", onClick: joinGroup, loading: isJoining, children: t("join_group") })] })) : (_jsx(MessageFooter, { currentSession: latestConversationSession, openCreateCannedModal: openCreateCannedModal })), _jsx(Modal, { centered: true, open: showConfirmRevoke, onOk: onRevokeMessage, onCancel: handleCloseRevoke, title: t("revoke_message_confirm_title"), okText: t("revoke"), cancelText: t("cancel"), okType: "danger", confirmLoading: isRevoking, getContainer: false, forceRender: true, children: _jsx("p", { children: t("revoke_message_confirm_message") }) })] }));
138
+ }, children: [_jsx(MessageHeader, { onClose: onClose, currentSession: latestConversationSession, isJoined: isJoined }), _jsx(MessageInfiniteScroll, { scrollRef: scrollRef, scrollableTargetId: "scrollableMessagesDiv", loadState: loadState, onLoadMoreOld: loadMoreOldMessage, onScroll: handleInfiniteScroll, children: loadState.messageList.map((message, _, array) => (_jsx(MessageItem, { message: message, allMessages: array, contextMenuOpen: openMenuId === message.clientMsgID, onContextMenuOpenChange: (open) => setOpenMenuId(open ? message.clientMsgID : null), onRevokeMessage: handleOpenRevoke, onQuoteMessage: setQuotedMessage, onPressQuoteMessage: onPressQuoteMessage }, message.clientMsgID))) }), moreNewLoading && (_jsx("div", { className: "flex items-center justify-center py-2", children: _jsx(Spin, {}) })), isCheckingMembership ? (_jsx("div", { className: "border-t bg-white py-4 flex items-center justify-center", children: _jsx(Spin, {}) })) : (latestConversationSession === null || latestConversationSession === void 0 ? void 0 : latestConversationSession.status) === SessionStatus.UNASSIGNED ? (_jsx(UnassignedSessionFooter, { sessionId: latestConversationSession.id, teamId: latestConversationSession.teamId })) : shouldRestrictToLastSession ? (_jsxs("div", { className: "border-t bg-white py-4 flex flex-col items-center gap-2", children: [_jsx("p", { className: "text-sm text-gray-500", children: t("join_group_required") }), _jsx(Button, { type: "primary", onClick: joinGroup, loading: isJoining, children: t("join_group") })] })) : (_jsx(MessageFooter, { currentSession: latestConversationSession, openCreateCannedModal: openCreateCannedModal })), _jsx(Modal, { centered: true, open: showConfirmRevoke, onOk: onRevokeMessage, onCancel: handleCloseRevoke, title: t("revoke_message_confirm_title"), okText: t("revoke"), cancelText: t("cancel"), okType: "danger", confirmLoading: isRevoking, getContainer: false, forceRender: true, children: _jsx("p", { children: t("revoke_message_confirm_message") }) })] }));
207
139
  };
208
140
  export default MessageList;
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { Select } from "antd";
4
- import { Icon } from "../icon";
4
+ import { Icon } from "../../components/icon";
5
5
  import clsx from "clsx";
6
6
  const SelectSession = ({ options, value, onChange, excludeOptions, placeholder, }) => {
7
7
  const selectedOption = options.find((option) => option.value === value);
@@ -4,8 +4,8 @@ import { Button, message as antdMessage } from "antd";
4
4
  import { useTranslation } from "react-i18next";
5
5
  import { useAssignSession } from "../../hooks/session/useAssignSession";
6
6
  import useAuthStore from "../../store/auth";
7
- import ManualAssignPopover from "../thread/ManualAssignPopover";
8
- import { Icon } from "../icon";
7
+ import ManualAssignPopover from "../../components/thread/ManualAssignPopover";
8
+ import { Icon } from "../../components/icon";
9
9
  const UnassignedSessionFooter = ({ sessionId, teamId, }) => {
10
10
  const { t } = useTranslation();
11
11
  const userID = useAuthStore((state) => state.userID);