@droppii-org/chat-sdk 0.1.29 → 0.1.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/svg/index.ts +1 -1
- package/dist/components/biz-inbox/BizThreadAvatar.d.ts.map +1 -1
- package/dist/components/biz-inbox/BizThreadAvatar.js +6 -1
- package/dist/components/biz-inbox/BizThreadCard.d.ts +3 -3
- package/dist/components/biz-inbox/BizThreadCard.d.ts.map +1 -1
- package/dist/components/biz-inbox/BizThreadCard.js +20 -8
- package/dist/components/biz-inbox/BizThreadList.d.ts +5 -4
- package/dist/components/biz-inbox/BizThreadList.d.ts.map +1 -1
- package/dist/components/biz-inbox/BizThreadList.js +29 -6
- package/dist/components/biz-inbox/BizThreadTitle.d.ts +2 -1
- package/dist/components/biz-inbox/BizThreadTitle.d.ts.map +1 -1
- package/dist/components/biz-inbox/BizThreadTitle.js +2 -1
- package/dist/components/biz-thread-detail/BizLinkInputPreview.d.ts +7 -0
- package/dist/components/biz-thread-detail/BizLinkInputPreview.d.ts.map +1 -0
- package/dist/components/biz-thread-detail/BizLinkInputPreview.js +16 -0
- package/dist/components/biz-thread-detail/BizLinkMessageCard.d.ts +6 -0
- package/dist/components/biz-thread-detail/BizLinkMessageCard.d.ts.map +1 -0
- package/dist/components/biz-thread-detail/BizLinkMessageCard.js +21 -0
- package/dist/components/biz-thread-detail/BizLinkTextContent.d.ts +6 -0
- package/dist/components/biz-thread-detail/BizLinkTextContent.d.ts.map +1 -0
- package/dist/components/biz-thread-detail/BizLinkTextContent.js +11 -0
- package/dist/components/biz-thread-detail/BizMessageBubble.d.ts +2 -1
- package/dist/components/biz-thread-detail/BizMessageBubble.d.ts.map +1 -1
- package/dist/components/biz-thread-detail/BizMessageBubble.js +1 -1
- package/dist/components/biz-thread-detail/BizMessageContent.d.ts +7 -0
- package/dist/components/biz-thread-detail/BizMessageContent.d.ts.map +1 -0
- package/dist/components/biz-thread-detail/BizMessageContent.js +23 -0
- package/dist/components/biz-thread-detail/BizMessageList.d.ts.map +1 -1
- package/dist/components/biz-thread-detail/BizMessageList.js +15 -7
- package/dist/components/biz-thread-detail/BizThreadDetailHeader.d.ts.map +1 -1
- package/dist/components/biz-thread-detail/BizThreadDetailHeader.js +3 -4
- package/dist/components/biz-thread-detail/BizThreadDetailInput.d.ts.map +1 -1
- package/dist/components/biz-thread-detail/BizThreadDetailInput.js +15 -4
- package/dist/components/biz-thread-detail/item/BizMessageItem.d.ts +2 -1
- package/dist/components/biz-thread-detail/item/BizMessageItem.d.ts.map +1 -1
- package/dist/components/biz-thread-detail/item/BizMessageItem.js +13 -6
- package/dist/components/message/MessageInfiniteScroll.d.ts +2 -1
- package/dist/components/message/MessageInfiniteScroll.d.ts.map +1 -1
- package/dist/components/message/MessageInfiniteScroll.js +2 -15
- package/dist/components/message/MessageList.d.ts.map +1 -1
- package/dist/components/message/MessageList.js +2 -2
- package/dist/hooks/biz/index.d.ts +4 -0
- package/dist/hooks/biz/index.d.ts.map +1 -1
- package/dist/hooks/biz/index.js +3 -0
- package/dist/hooks/biz/useBizActiveConversation.d.ts +3 -0
- package/dist/hooks/biz/useBizActiveConversation.d.ts.map +1 -0
- package/dist/hooks/biz/useBizActiveConversation.js +59 -0
- package/dist/hooks/biz/useBizConversationList.d.ts +3 -2
- package/dist/hooks/biz/useBizConversationList.d.ts.map +1 -1
- package/dist/hooks/biz/useBizConversationList.js +4 -1
- package/dist/hooks/biz/useBizConversationListItems.d.ts +8 -0
- package/dist/hooks/biz/useBizConversationListItems.d.ts.map +1 -0
- package/dist/hooks/biz/useBizConversationListItems.js +10 -0
- package/dist/hooks/biz/useBizGlobalEvent.d.ts +2 -0
- package/dist/hooks/biz/useBizGlobalEvent.d.ts.map +1 -0
- package/dist/hooks/biz/useBizGlobalEvent.js +44 -0
- package/dist/hooks/biz/useBizSendMessage.d.ts.map +1 -1
- package/dist/hooks/biz/useBizSendMessage.js +13 -8
- package/dist/hooks/common/useFetchUrlMetadata.d.ts +9 -0
- package/dist/hooks/common/useFetchUrlMetadata.d.ts.map +1 -0
- package/dist/hooks/common/useFetchUrlMetadata.js +21 -0
- package/dist/hooks/message/useMessageListScroll.d.ts.map +1 -1
- package/dist/hooks/message/useMessageListScroll.js +10 -0
- package/dist/locales/vi/biz-inbox.json +7 -1
- package/dist/screens/biz-message/index.d.ts.map +1 -1
- package/dist/screens/biz-message/index.js +7 -28
- package/dist/services/query.d.ts +1 -0
- package/dist/services/query.d.ts.map +1 -1
- package/dist/services/query.js +1 -0
- package/dist/services/routes.d.ts +1 -0
- package/dist/services/routes.d.ts.map +1 -1
- package/dist/services/routes.js +1 -0
- package/dist/store/bizConversation.d.ts +4 -0
- package/dist/store/bizConversation.d.ts.map +1 -1
- package/dist/store/bizConversation.js +9 -0
- package/dist/styles/global.css +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/biz.d.ts +5 -2
- package/dist/types/biz.d.ts.map +1 -1
- package/dist/types/biz.js +2 -0
- package/dist/utils/bizConversation.d.ts +3 -5
- package/dist/utils/bizConversation.d.ts.map +1 -1
- package/dist/utils/bizConversation.js +18 -40
- package/dist/utils/bizLink.d.ts +13 -0
- package/dist/utils/bizLink.d.ts.map +1 -0
- package/dist/utils/bizLink.js +77 -0
- package/dist/utils/bizMessage.d.ts +8 -2
- package/dist/utils/bizMessage.d.ts.map +1 -1
- package/dist/utils/bizMessage.js +64 -4
- package/dist/utils/openBizLink.d.ts +3 -0
- package/dist/utils/openBizLink.d.ts.map +1 -0
- package/dist/utils/openBizLink.js +18 -0
- package/package.json +127 -126
package/dist/assets/svg/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from "./document";
|
|
2
|
-
export * from "./canned-response";
|
|
2
|
+
export * from "./canned-response";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BizThreadAvatar.d.ts","sourceRoot":"","sources":["../../../src/components/biz-inbox/BizThreadAvatar.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG9C,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,eAAe,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,QAAA,MAAM,eAAe,GAAI,uDAKtB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"BizThreadAvatar.d.ts","sourceRoot":"","sources":["../../../src/components/biz-inbox/BizThreadAvatar.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG9C,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,eAAe,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,QAAA,MAAM,eAAe,GAAI,uDAKtB,oBAAoB,4CAwCtB,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -4,5 +4,10 @@ import clsx from "clsx";
|
|
|
4
4
|
import { Icon } from "../../components/icon";
|
|
5
5
|
import { BizChatCategory } from "../../types/biz";
|
|
6
6
|
import { resolveBizBadgeColor } from "../../utils/bizConversation";
|
|
7
|
-
const BizThreadAvatar = ({ chatCategory, displayName, avatarUrl, badgeLabel, }) =>
|
|
7
|
+
const BizThreadAvatar = ({ chatCategory, displayName, avatarUrl, badgeLabel, }) => {
|
|
8
|
+
if (chatCategory === BizChatCategory.BIZ_BOT_CRM) {
|
|
9
|
+
return (_jsx("div", { className: "flex h-12 w-12 shrink-0 items-center justify-center rounded-xl bg-[#607CFB] p-2.5 shadow-[inset_2px_3px_8px_0_rgba(0,0,0,0.40)]", children: _jsx(Icon, { icon: "head-phone-o1", size: 28, className: "text-white" }) }));
|
|
10
|
+
}
|
|
11
|
+
return (_jsxs("div", { className: "relative h-12 w-12 shrink-0", children: [avatarUrl ? (_jsx("img", { src: avatarUrl, alt: displayName, className: "h-12 w-12 rounded-full object-cover" })) : (_jsx("div", { className: "flex h-12 w-12 items-center justify-center rounded-full bg-[#0C5CFF] text-white", children: chatCategory === BizChatCategory.GROUP ? (_jsx(Icon, { icon: "user-two-b", size: 20 })) : chatCategory === BizChatCategory.BIZ_BOT_PDP ? (_jsx(Icon, { icon: "droppii-o-1", size: 20 })) : (_jsx(Icon, { icon: "user-o", size: 20 })) })), badgeLabel && (_jsx("span", { className: clsx("absolute -bottom-px -right-px flex h-[17px] items-center justify-center gap-2 rounded-md border border-white px-1 text-[10px] font-semibold leading-3 text-white shadow-[inset_2px_6px_8px_0_rgba(0,0,0,0.40)]", resolveBizBadgeColor(chatCategory)), children: badgeLabel }))] }));
|
|
12
|
+
};
|
|
8
13
|
export default BizThreadAvatar;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BizConversationListItem } from "../../hooks/biz/useBizConversationListItems";
|
|
2
2
|
export interface BizThreadCardProps {
|
|
3
|
-
item:
|
|
4
|
-
onClick: (item:
|
|
3
|
+
item: BizConversationListItem;
|
|
4
|
+
onClick: (item: BizConversationListItem) => void;
|
|
5
5
|
}
|
|
6
6
|
declare const BizThreadCard: ({ item, onClick }: BizThreadCardProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export default BizThreadCard;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BizThreadCard.d.ts","sourceRoot":"","sources":["../../../src/components/biz-inbox/BizThreadCard.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BizThreadCard.d.ts","sourceRoot":"","sources":["../../../src/components/biz-inbox/BizThreadCard.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAavF,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,uBAAuB,CAAC;IAC9B,OAAO,EAAE,CAAC,IAAI,EAAE,uBAAuB,KAAK,IAAI,CAAC;CAClD;AAuBD,QAAA,MAAM,aAAa,GAAI,mBAAmB,kBAAkB,4CA+D3D,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import clsx from "clsx";
|
|
3
4
|
import { useTranslation } from "react-i18next";
|
|
5
|
+
import { useChatContext } from "../../context/ChatContext";
|
|
4
6
|
import { formatTimestamp } from "../../utils/common";
|
|
5
|
-
import {
|
|
7
|
+
import { parseBizLatestMessage } from "../../utils/bizMessage";
|
|
8
|
+
import { isBizGroupChat, resolveBizAvatarUrl, resolveBizBadgeLabel, resolveBizDisplayName, } from "../../utils/bizConversation";
|
|
6
9
|
import BizThreadAvatar from "./BizThreadAvatar";
|
|
7
10
|
import BizThreadTitle from "./BizThreadTitle";
|
|
8
11
|
const formatLatestMessageTime = (sendTime) => {
|
|
@@ -10,16 +13,25 @@ const formatLatestMessageTime = (sendTime) => {
|
|
|
10
13
|
return "";
|
|
11
14
|
return formatTimestamp(sendTime, { hasTime: true });
|
|
12
15
|
};
|
|
16
|
+
const formatUnreadCount = (count) => (count > 99 ? "99+" : count);
|
|
17
|
+
const UnreadBadge = ({ count }) => {
|
|
18
|
+
const label = String(formatUnreadCount(count));
|
|
19
|
+
const isWide = label.length > 1;
|
|
20
|
+
return (_jsx("span", { className: `inline-flex h-5 shrink-0 items-center justify-center rounded-[32px] border-2 border-white bg-[linear-gradient(93deg,#FF7D74_0%,#F04438_100%)] text-center text-[12px] font-semibold leading-[160%] text-white px-[3px] ${isWide ? "min-w-8" : "min-w-5"}`, children: label }));
|
|
21
|
+
};
|
|
13
22
|
const BizThreadCard = ({ item, onClick }) => {
|
|
23
|
+
var _a;
|
|
14
24
|
const { t } = useTranslation("biz-inbox");
|
|
15
|
-
const
|
|
25
|
+
const { t: tCommon } = useTranslation("common");
|
|
26
|
+
const { user } = useChatContext();
|
|
27
|
+
const displayName = resolveBizDisplayName(item, t);
|
|
16
28
|
const avatarUrl = resolveBizAvatarUrl(item);
|
|
17
29
|
const badgeLabel = resolveBizBadgeLabel(item.chatCategory, t);
|
|
18
|
-
const latestMessagePreview =
|
|
19
|
-
const latestMessageTime = formatLatestMessageTime(
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
30
|
+
const latestMessagePreview = parseBizLatestMessage(item.latestMsg, user === null || user === void 0 ? void 0 : user.userID, tCommon, isBizGroupChat(item));
|
|
31
|
+
const latestMessageTime = formatLatestMessageTime(item.latestMsgSendTime || null);
|
|
32
|
+
const unreadCount = (_a = item.unreadCount) !== null && _a !== void 0 ? _a : 0;
|
|
33
|
+
return (_jsxs("button", { type: "button", onClick: () => onClick(item), "data-testid": "biz-inbox-thread-card", className: "flex w-full shrink-0 items-start gap-2 border-b border-[#EFEFEF] bg-white p-3 text-left transition-colors hover:bg-gray-50 focus:outline-none focus-visible:ring-2 focus-visible:ring-[#1677ff]", children: [_jsx(BizThreadAvatar, { chatCategory: item.chatCategory, displayName: displayName, avatarUrl: avatarUrl, badgeLabel: badgeLabel }), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col", children: [_jsxs("div", { className: "flex min-h-[25.6px] items-center justify-between gap-1", children: [_jsx("div", { className: "min-w-0 flex-1", children: _jsx(BizThreadTitle, { chatCategory: item.chatCategory, displayName: displayName, hasUnread: unreadCount > 0 }) }), latestMessageTime && (_jsx("span", { className: "shrink-0 text-[12px] font-normal leading-[160%] text-[#747B7E] [font-feature-settings:'liga'_off,'clig'_off]", children: latestMessageTime }))] }), _jsxs("div", { className: "flex items-center justify-between gap-2", children: [_jsx("p", { className: clsx("min-w-0 flex-1 truncate text-[14px] leading-[160%] [font-feature-settings:'liga'_off,'clig'_off]", unreadCount > 0
|
|
34
|
+
? "font-[510] text-black"
|
|
35
|
+
: "font-normal tracking-[0.14px] text-[#5C6366]"), children: latestMessagePreview }), unreadCount > 0 && _jsx(UnreadBadge, { count: unreadCount })] })] })] }));
|
|
24
36
|
};
|
|
25
37
|
export default BizThreadCard;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BizConversationListItem } from "../../hooks/biz/useBizConversationListItems";
|
|
2
2
|
export interface BizThreadListProps {
|
|
3
|
-
items:
|
|
3
|
+
items: BizConversationListItem[];
|
|
4
|
+
isLoading: boolean;
|
|
4
5
|
isFetchingNextPage: boolean;
|
|
5
6
|
hasNextPage: boolean;
|
|
6
7
|
onLoadMore: () => void;
|
|
7
|
-
onSelectThread?: (item:
|
|
8
|
+
onSelectThread?: (item: BizConversationListItem) => void;
|
|
8
9
|
}
|
|
9
|
-
declare const BizThreadList: ({ items, isFetchingNextPage, hasNextPage, onLoadMore, onSelectThread, }: BizThreadListProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
declare const BizThreadList: ({ items, isLoading, isFetchingNextPage, hasNextPage, onLoadMore, onSelectThread, }: BizThreadListProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
11
|
export default BizThreadList;
|
|
11
12
|
//# sourceMappingURL=BizThreadList.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BizThreadList.d.ts","sourceRoot":"","sources":["../../../src/components/biz-inbox/BizThreadList.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BizThreadList.d.ts","sourceRoot":"","sources":["../../../src/components/biz-inbox/BizThreadList.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAMvF,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,uBAAuB,EAAE,CAAC;IACjC,SAAS,EAAE,OAAO,CAAC;IACnB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,uBAAuB,KAAK,IAAI,CAAC;CAC1D;AAYD,QAAA,MAAM,aAAa,GAAI,oFAOpB,kBAAkB,4CAwGpB,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -2,27 +2,47 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { usePathname, useRouter, useSearchParams } from "next/navigation";
|
|
4
4
|
import { useTranslation } from "react-i18next";
|
|
5
|
-
import { Empty } from "antd";
|
|
5
|
+
import { Empty, Spin } from "antd";
|
|
6
6
|
import InfiniteScroll from "react-infinite-scroll-component";
|
|
7
|
+
import { DChatSDK } from "../../constants/sdk";
|
|
7
8
|
import useBizConversationStore from "../../store/bizConversation";
|
|
9
|
+
import useConversationStore from "../../store/conversation";
|
|
8
10
|
import { Icon } from "../../components/icon";
|
|
9
11
|
import BizThreadCard from "./BizThreadCard";
|
|
10
12
|
const FooterSkeleton = () => (_jsxs("div", { className: "flex items-center gap-3 p-3", children: [_jsx("div", { className: "h-10 w-10 animate-pulse rounded-full bg-neutral-200" }), _jsxs("div", { className: "flex flex-1 flex-col gap-2", children: [_jsx("div", { className: "h-3 w-1/2 animate-pulse rounded bg-neutral-200" }), _jsx("div", { className: "h-2.5 w-1/3 animate-pulse rounded bg-neutral-200" })] })] }));
|
|
11
|
-
const BizThreadList = ({ items, isFetchingNextPage, hasNextPage, onLoadMore, onSelectThread, }) => {
|
|
13
|
+
const BizThreadList = ({ items, isLoading, isFetchingNextPage, hasNextPage, onLoadMore, onSelectThread, }) => {
|
|
12
14
|
const { t } = useTranslation("biz-inbox");
|
|
13
15
|
const router = useRouter();
|
|
14
16
|
const pathname = usePathname();
|
|
15
17
|
const searchParams = useSearchParams();
|
|
18
|
+
const sdkConversations = useBizConversationStore((state) => state.sdkConversations);
|
|
16
19
|
const selectConversation = useBizConversationStore((state) => state.selectConversation);
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
const setConversationData = useConversationStore((state) => state.setConversationData);
|
|
21
|
+
const setSelectedConversationId = useConversationStore((state) => state.setSelectedConversationId);
|
|
22
|
+
const syncSdkConversation = (conversationId) => {
|
|
23
|
+
const cachedConversation = sdkConversations[conversationId];
|
|
24
|
+
if (cachedConversation) {
|
|
25
|
+
setConversationData(cachedConversation);
|
|
26
|
+
setSelectedConversationId(conversationId);
|
|
21
27
|
return;
|
|
22
28
|
}
|
|
29
|
+
DChatSDK.getMultipleConversation([conversationId])
|
|
30
|
+
.then((res) => {
|
|
31
|
+
if (res.data.length > 0) {
|
|
32
|
+
setConversationData(res.data[0]);
|
|
33
|
+
setSelectedConversationId(conversationId);
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
.catch((error) => {
|
|
37
|
+
console.error("getMultipleConversation", error);
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
const handleSelectThread = (item) => {
|
|
23
41
|
const newSearchParams = new URLSearchParams(searchParams);
|
|
24
42
|
newSearchParams.set("threadId", item.conversationId);
|
|
25
43
|
router.push(`${pathname}?${newSearchParams.toString()}`);
|
|
44
|
+
selectConversation(item);
|
|
45
|
+
syncSdkConversation(item.conversationId);
|
|
26
46
|
onSelectThread === null || onSelectThread === void 0 ? void 0 : onSelectThread(item);
|
|
27
47
|
};
|
|
28
48
|
const handleEndReached = () => {
|
|
@@ -30,6 +50,9 @@ const BizThreadList = ({ items, isFetchingNextPage, hasNextPage, onLoadMore, onS
|
|
|
30
50
|
onLoadMore();
|
|
31
51
|
}
|
|
32
52
|
};
|
|
53
|
+
if (isLoading) {
|
|
54
|
+
return (_jsx("div", { "data-testid": "biz-inbox-thread-list", className: "flex flex-1 items-center justify-center py-12", children: _jsx(Spin, {}) }));
|
|
55
|
+
}
|
|
33
56
|
return (_jsx("div", { id: "scrollableBizThreadsDiv", "data-testid": "biz-inbox-thread-list", className: "min-h-0 w-full flex-1 overflow-auto", children: _jsx(InfiniteScroll, { dataLength: items.length, next: handleEndReached, hasMore: hasNextPage, loader: isFetchingNextPage ? _jsx(FooterSkeleton, {}) : null, scrollableTarget: "scrollableBizThreadsDiv", children: items.length === 0 ? (_jsx("div", { className: "flex items-center justify-center py-12", children: _jsx(Empty, { image: _jsx(Icon, { icon: "chat-square-b", size: 80, className: "text-gray-300" }), description: t("empty.no_conversations") }) })) : (items.map((item) => (_jsx(BizThreadCard, { item: item, onClick: handleSelectThread }, item.conversationId)))) }) }));
|
|
34
57
|
};
|
|
35
58
|
export default BizThreadList;
|
|
@@ -2,7 +2,8 @@ import { BizChatCategory } from "../../types/biz";
|
|
|
2
2
|
export interface BizThreadTitleProps {
|
|
3
3
|
chatCategory: BizChatCategory;
|
|
4
4
|
displayName: string;
|
|
5
|
+
hasUnread?: boolean;
|
|
5
6
|
}
|
|
6
|
-
declare const BizThreadTitle: ({ chatCategory, displayName }: BizThreadTitleProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
declare const BizThreadTitle: ({ chatCategory, displayName, hasUnread, }: BizThreadTitleProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
8
|
export default BizThreadTitle;
|
|
8
9
|
//# sourceMappingURL=BizThreadTitle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BizThreadTitle.d.ts","sourceRoot":"","sources":["../../../src/components/biz-inbox/BizThreadTitle.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BizThreadTitle.d.ts","sourceRoot":"","sources":["../../../src/components/biz-inbox/BizThreadTitle.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,eAAe,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,QAAA,MAAM,cAAc,GAAI,2CAIrB,mBAAmB,4CAwBrB,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import clsx from "clsx";
|
|
3
4
|
import { Icon } from "../../components/icon";
|
|
4
5
|
import { BizChatCategory } from "../../types/biz";
|
|
5
|
-
const BizThreadTitle = ({ chatCategory, displayName }) => (_jsxs("div", { className: "flex min-w-0 items-center gap-1", children: [chatCategory === BizChatCategory.GROUP && (_jsx(Icon, { icon: "user-two-b", size: 12, className: "shrink-0 text-black" })), chatCategory === BizChatCategory.BIZ_BOT_PDP && (_jsx("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center gap-0.5 rounded-full border border-white bg-[linear-gradient(93deg,#607CFB_0%,#1B3FE4_100%)] px-1 py-0.5 text-white", children: _jsx(Icon, { icon: "shield-done-b", size: 8 }) })), _jsx("span", { className: "truncate text-[16px]
|
|
6
|
+
const BizThreadTitle = ({ chatCategory, displayName, hasUnread = false, }) => (_jsxs("div", { className: "flex min-w-0 items-center gap-1", children: [chatCategory === BizChatCategory.GROUP && (_jsx(Icon, { icon: "user-two-b", size: 12, className: "shrink-0 text-black" })), chatCategory === BizChatCategory.BIZ_BOT_PDP && (_jsx("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center gap-0.5 rounded-full border border-white bg-[linear-gradient(93deg,#607CFB_0%,#1B3FE4_100%)] px-1 py-0.5 text-white", children: _jsx(Icon, { icon: "shield-done-b", size: 8 }) })), chatCategory === BizChatCategory.BIZ_BOT_CRM && (_jsx("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-black text-white", children: _jsx(Icon, { icon: "droppii-o-1", size: 8 }) })), _jsx("span", { className: clsx("min-w-0 truncate text-[16px] leading-[160%] text-black [font-feature-settings:'liga'_off,'clig'_off]", hasUnread ? "font-bold tracking-[0.16px]" : "font-[510]"), children: displayName })] }));
|
|
6
7
|
export default BizThreadTitle;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface BizLinkInputPreviewProps {
|
|
2
|
+
url: string;
|
|
3
|
+
onRemove: () => void;
|
|
4
|
+
}
|
|
5
|
+
declare const BizLinkInputPreview: ({ url, onRemove }: BizLinkInputPreviewProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export default BizLinkInputPreview;
|
|
7
|
+
//# sourceMappingURL=BizLinkInputPreview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BizLinkInputPreview.d.ts","sourceRoot":"","sources":["../../../src/components/biz-thread-detail/BizLinkInputPreview.tsx"],"names":[],"mappings":"AAQA,MAAM,WAAW,wBAAwB;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,QAAA,MAAM,mBAAmB,GAAI,mBAAmB,wBAAwB,4CAoEvE,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Icon } from "../../components/icon";
|
|
4
|
+
import { useFetchUrlMetadata } from "../../hooks/common/useFetchUrlMetadata";
|
|
5
|
+
import { getHostLabel } from "../../utils/bizLink";
|
|
6
|
+
import { openBizLink } from "../../utils/openBizLink";
|
|
7
|
+
import { useTranslation } from "react-i18next";
|
|
8
|
+
const BizLinkInputPreview = ({ url, onRemove }) => {
|
|
9
|
+
const { t } = useTranslation("biz-inbox");
|
|
10
|
+
const { data, isLoading, isError } = useFetchUrlMetadata(url);
|
|
11
|
+
const handleOpen = () => {
|
|
12
|
+
openBizLink(url, t);
|
|
13
|
+
};
|
|
14
|
+
return (_jsxs("div", { "data-testid": "biz-link-input-preview", className: "flex w-full shrink-0 items-center gap-2 overflow-hidden bg-[#EAF5FF] pr-2", children: [_jsxs("button", { type: "button", onClick: handleOpen, className: "flex min-w-0 flex-1 items-center gap-2 py-0 pl-0 text-left", children: [_jsx("div", { className: "flex h-[51px] w-[51px] shrink-0 items-center justify-center overflow-hidden bg-[#EAF5FF]", children: isLoading ? (_jsx("div", { className: "h-5 w-5 animate-spin rounded-full border-2 border-[#1B3FE4] border-t-transparent" })) : (data === null || data === void 0 ? void 0 : data.image) ? (_jsx("img", { src: data.image, alt: "", className: "h-full w-full object-cover" })) : (_jsx(Icon, { icon: "link-alt-b", size: 24, className: "text-[#1B3FE4]" })) }), _jsxs("div", { className: "min-w-0 flex-1", children: [isLoading ? (_jsx("p", { className: "truncate text-[14px] font-medium leading-[1.6] text-[#393E40]", children: t("link_preview.loading") })) : (_jsxs(_Fragment, { children: [_jsx("p", { className: "truncate text-[14px] font-medium leading-[1.6] text-[#393E40]", children: (data === null || data === void 0 ? void 0 : data.title) || getHostLabel(url) }), ((data === null || data === void 0 ? void 0 : data.description) || !(data === null || data === void 0 ? void 0 : data.title)) && (_jsx("p", { className: "truncate text-[13px] leading-[1.6] text-[#747B7E]", children: (data === null || data === void 0 ? void 0 : data.description) || getHostLabel(url) }))] })), isError && !isLoading && (_jsx("p", { className: "truncate text-[13px] leading-[1.6] text-[#747B7E]", children: getHostLabel(url) }))] })] }), _jsx("button", { type: "button", onClick: onRemove, "data-testid": "biz-link-input-preview-remove", className: "flex h-4 w-4 shrink-0 items-center justify-center", "aria-label": t("link_preview.remove"), children: _jsx(Icon, { icon: "close-b", size: 16, className: "text-[#393E40]" }) })] }));
|
|
15
|
+
};
|
|
16
|
+
export default BizLinkInputPreview;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface BizLinkMessageCardProps {
|
|
2
|
+
url: string;
|
|
3
|
+
}
|
|
4
|
+
declare const BizLinkMessageCard: ({ url }: BizLinkMessageCardProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
5
|
+
export default BizLinkMessageCard;
|
|
6
|
+
//# sourceMappingURL=BizLinkMessageCard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BizLinkMessageCard.d.ts","sourceRoot":"","sources":["../../../src/components/biz-thread-detail/BizLinkMessageCard.tsx"],"names":[],"mappings":"AAOA,MAAM,WAAW,uBAAuB;IACtC,GAAG,EAAE,MAAM,CAAC;CACb;AAED,QAAA,MAAM,kBAAkB,GAAI,SAAS,uBAAuB,mDA+D3D,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useTranslation } from "react-i18next";
|
|
4
|
+
import { useFetchUrlMetadata } from "../../hooks/common/useFetchUrlMetadata";
|
|
5
|
+
import { getHostLabel } from "../../utils/bizLink";
|
|
6
|
+
import { openBizLink } from "../../utils/openBizLink";
|
|
7
|
+
const BizLinkMessageCard = ({ url }) => {
|
|
8
|
+
const { t } = useTranslation("biz-inbox");
|
|
9
|
+
const { data, isLoading } = useFetchUrlMetadata(url);
|
|
10
|
+
if (isLoading) {
|
|
11
|
+
return (_jsxs("div", { "data-testid": "biz-link-message-card-loading", className: "flex w-full max-w-[292px] flex-col overflow-hidden rounded-[12px] border border-[rgba(57,62,64,0.1)] bg-white", children: [_jsx("div", { className: "flex aspect-[1920/1080] w-full items-center justify-center bg-[#EAF5FF]", children: _jsx("div", { className: "h-6 w-6 animate-spin rounded-full border-2 border-[#1B3FE4] border-t-transparent" }) }), _jsxs("div", { className: "flex flex-col gap-1 px-3 py-2", children: [_jsx("div", { className: "h-4 w-2/3 animate-pulse rounded bg-[#EFEFEF]" }), _jsx("div", { className: "h-3 w-1/3 animate-pulse rounded bg-[#EFEFEF]" })] })] }));
|
|
12
|
+
}
|
|
13
|
+
if (!(data === null || data === void 0 ? void 0 : data.title) && !(data === null || data === void 0 ? void 0 : data.description) && !(data === null || data === void 0 ? void 0 : data.image)) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const handleOpen = () => {
|
|
17
|
+
openBizLink(url, t);
|
|
18
|
+
};
|
|
19
|
+
return (_jsxs("button", { type: "button", onClick: handleOpen, "data-testid": "biz-link-message-card", className: "flex w-full max-w-[292px] flex-col overflow-hidden rounded-[12px] border border-[rgba(57,62,64,0.1)] bg-white text-left", children: [(data === null || data === void 0 ? void 0 : data.image) && (_jsx("div", { className: "aspect-[1920/1080] w-full overflow-hidden", children: _jsx("img", { src: data.image, alt: "", className: "h-full w-full object-cover" }) })), _jsxs("div", { className: "flex flex-col px-3 py-2", children: [(data === null || data === void 0 ? void 0 : data.title) && (_jsx("p", { className: "truncate text-[14px] font-medium leading-[1.6] text-[#393E40]", children: data.title })), _jsx("p", { className: "truncate text-[12px] font-medium leading-[1.6] tracking-[0.12px] text-[#1B3FE4]", children: getHostLabel(url) }), (data === null || data === void 0 ? void 0 : data.description) && (_jsx("p", { className: "line-clamp-2 text-[12px] leading-[1.6] text-[#5C6366]", children: data.description }))] })] }));
|
|
20
|
+
};
|
|
21
|
+
export default BizLinkMessageCard;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BizLinkTextContent.d.ts","sourceRoot":"","sources":["../../../src/components/biz-thread-detail/BizLinkTextContent.tsx"],"names":[],"mappings":"AAMA,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,QAAA,MAAM,kBAAkB,GAAI,UAAU,uBAAuB,4CAsB5D,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useTranslation } from "react-i18next";
|
|
4
|
+
import { parseBizTextWithLinks } from "../../utils/bizLink";
|
|
5
|
+
import { openBizLink } from "../../utils/openBizLink";
|
|
6
|
+
const BizLinkTextContent = ({ text }) => {
|
|
7
|
+
const { t } = useTranslation("biz-inbox");
|
|
8
|
+
const segments = parseBizTextWithLinks(text);
|
|
9
|
+
return (_jsx("span", { className: "whitespace-pre-wrap break-words text-[16px] leading-[160%] tracking-[0.16px] text-[#393E40]", children: segments.map((segment, index) => segment.type === "link" ? (_jsx("button", { type: "button", onClick: () => openBizLink(segment.url, t), className: "inline font-medium text-[#1B3FE4] underline-offset-2 hover:underline", children: segment.value }, `${segment.url}-${index}`)) : (_jsx("span", { children: segment.value }, `text-${index}`))) }));
|
|
10
|
+
};
|
|
11
|
+
export default BizLinkTextContent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BizMessageBubble.d.ts","sourceRoot":"","sources":["../../../src/components/biz-thread-detail/BizMessageBubble.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BizMessageBubble.d.ts","sourceRoot":"","sources":["../../../src/components/biz-thread-detail/BizMessageBubble.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,SAAS,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AA6BD,QAAA,MAAM,gBAAgB,GAAI,2DAMvB,qBAAqB,4CA8BvB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -10,6 +10,6 @@ const BizMessageBubble = ({ isMine, content, senderName, showSenderName, showTip
|
|
|
10
10
|
? "rounded-[20px] rounded-br-none"
|
|
11
11
|
: "rounded-[20px] rounded-bl-none"
|
|
12
12
|
: "rounded-[20px]", isMine ? "bg-[rgba(0,81,255,0.1)]" : "bg-[rgba(131,137,157,0.1)]");
|
|
13
|
-
return (_jsxs("div", { className: "relative flex items-end", "data-testid": "biz-message-bubble", children: [!isMine && showTip && _jsx(BizMessageBubbleTail, { isMine: isMine }), _jsx("div", { className: bubbleClass, children: _jsxs("div", { className: "flex flex-col gap-1 px-1", children: [showSenderName && senderName && (_jsx("span", { className: "text-[12px] font-medium leading-[160%] tracking-[0.12px] text-[#747B7E]", children: senderName })), _jsx("
|
|
13
|
+
return (_jsxs("div", { className: "relative flex items-end", "data-testid": "biz-message-bubble", children: [!isMine && showTip && _jsx(BizMessageBubbleTail, { isMine: isMine }), _jsx("div", { className: bubbleClass, children: _jsxs("div", { className: "flex flex-col gap-1 px-1", children: [showSenderName && senderName && (_jsx("span", { className: "text-[12px] font-medium leading-[160%] tracking-[0.12px] text-[#747B7E]", children: senderName })), _jsx("div", { className: "flex flex-col gap-2", children: content })] }) }), isMine && showTip && _jsx(BizMessageBubbleTail, { isMine: isMine })] }));
|
|
14
14
|
};
|
|
15
15
|
export default BizMessageBubble;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MessageItem } from "@openim/wasm-client-sdk";
|
|
2
|
+
export interface BizMessageContentProps {
|
|
3
|
+
message: MessageItem;
|
|
4
|
+
}
|
|
5
|
+
declare const BizMessageContent: ({ message }: BizMessageContentProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
6
|
+
export default BizMessageContent;
|
|
7
|
+
//# sourceMappingURL=BizMessageContent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BizMessageContent.d.ts","sourceRoot":"","sources":["../../../src/components/biz-thread-detail/BizMessageContent.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAe,MAAM,yBAAyB,CAAC;AAKnE,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,WAAW,CAAC;CACtB;AAED,QAAA,MAAM,iBAAiB,GAAI,aAAa,sBAAsB,mDAgC7D,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { MessageType } from "@openim/wasm-client-sdk";
|
|
4
|
+
import BizLinkMessageCard from "./BizLinkMessageCard";
|
|
5
|
+
import BizLinkTextContent from "./BizLinkTextContent";
|
|
6
|
+
import { extractBizLinkUrls } from "../../utils/bizLink";
|
|
7
|
+
const BizMessageContent = ({ message }) => {
|
|
8
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
9
|
+
const text = (_e = (_d = (_b = (_a = message.textElem) === null || _a === void 0 ? void 0 : _a.content) !== null && _b !== void 0 ? _b : (_c = message.urlTextElem) === null || _c === void 0 ? void 0 : _c.content) !== null && _d !== void 0 ? _d : message.content) !== null && _e !== void 0 ? _e : "";
|
|
10
|
+
const hasLinks = text ? extractBizLinkUrls(text).length > 0 : false;
|
|
11
|
+
if (message.contentType === MessageType.UrlTextMessage) {
|
|
12
|
+
const urls = (_g = (_f = message.urlTextElem) === null || _f === void 0 ? void 0 : _f.urls) !== null && _g !== void 0 ? _g : [];
|
|
13
|
+
const singleLink = urls.length === 1 ? urls[0] : null;
|
|
14
|
+
return (_jsxs(_Fragment, { children: [text && _jsx(BizLinkTextContent, { text: text }), singleLink && _jsx(BizLinkMessageCard, { url: singleLink })] }));
|
|
15
|
+
}
|
|
16
|
+
if (!text)
|
|
17
|
+
return null;
|
|
18
|
+
if (hasLinks) {
|
|
19
|
+
return _jsx(BizLinkTextContent, { text: text });
|
|
20
|
+
}
|
|
21
|
+
return (_jsx("p", { className: "whitespace-pre-wrap break-words text-[16px] leading-[160%] tracking-[0.16px] text-[#393E40]", children: text }));
|
|
22
|
+
};
|
|
23
|
+
export default BizMessageContent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BizMessageList.d.ts","sourceRoot":"","sources":["../../../src/components/biz-thread-detail/BizMessageList.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BizMessageList.d.ts","sourceRoot":"","sources":["../../../src/components/biz-thread-detail/BizMessageList.tsx"],"names":[],"mappings":"AAgBA,QAAA,MAAM,cAAc,+CA8EnB,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect } from "react";
|
|
4
4
|
import { Empty, Spin } from "antd";
|
|
5
5
|
import { useTranslation } from "react-i18next";
|
|
@@ -8,21 +8,29 @@ import MessageInfiniteScroll from "../../components/message/MessageInfiniteScrol
|
|
|
8
8
|
import { useMessage } from "../../hooks/message/useMessage";
|
|
9
9
|
import { useMessageListScroll } from "../../hooks/message/useMessageListScroll";
|
|
10
10
|
import useBizConversationStore from "../../store/bizConversation";
|
|
11
|
+
import useConversationStore from "../../store/conversation";
|
|
12
|
+
import { ConnectStatus, SyncStatus } from "../../types/chat";
|
|
13
|
+
import { isBizGroupChat } from "../../utils/bizConversation";
|
|
11
14
|
import emitter from "../../utils/events";
|
|
12
15
|
import BizMessageItem from "./item/BizMessageItem";
|
|
13
16
|
const BizMessageList = () => {
|
|
14
17
|
const { t } = useTranslation("biz-inbox");
|
|
15
|
-
const { user } = useChatContext();
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
18
|
+
const { user, connectStatus, syncStatus } = useChatContext();
|
|
19
|
+
const conversation = useBizConversationStore((state) => state.conversationData);
|
|
20
|
+
const selectedConversationId = useConversationStore((state) => state.selectedConversationId);
|
|
21
|
+
const isGroupChat = conversation ? isBizGroupChat(conversation) : false;
|
|
22
|
+
const isSdkReady = connectStatus === ConnectStatus.Connected &&
|
|
23
|
+
syncStatus !== SyncStatus.Loading;
|
|
24
|
+
const messageController = useMessage(selectedConversationId, undefined, isSdkReady && !!selectedConversationId);
|
|
25
|
+
const { scrollRef, loadMoreOldMessage, handleInfiniteScroll, scrollToBottomIfAtBottom, } = useMessageListScroll(Object.assign({ conversationId: selectedConversationId, userId: user === null || user === void 0 ? void 0 : user.userID }, messageController));
|
|
26
|
+
const { loadState, moreOldLoading } = messageController;
|
|
27
|
+
const isMessageLoading = !isSdkReady || !selectedConversationId || loadState.initLoading;
|
|
20
28
|
useEffect(() => {
|
|
21
29
|
emitter.on("BIZ_CHAT_SCROLL_TO_BOTTOM_IF_AT_BOTTOM", scrollToBottomIfAtBottom);
|
|
22
30
|
return () => {
|
|
23
31
|
emitter.off("BIZ_CHAT_SCROLL_TO_BOTTOM_IF_AT_BOTTOM", scrollToBottomIfAtBottom);
|
|
24
32
|
};
|
|
25
33
|
}, [scrollToBottomIfAtBottom]);
|
|
26
|
-
return (
|
|
34
|
+
return (_jsx("div", { "data-testid": "biz-message-list", className: "relative flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-white", children: isMessageLoading ? (_jsx("div", { className: "flex flex-1 items-center justify-center py-12", children: _jsx(Spin, {}) })) : (_jsx(MessageInfiniteScroll, { scrollRef: scrollRef, scrollableTargetId: "scrollableBizMessagesDiv", loadState: loadState, moreOldLoading: moreOldLoading, onLoadMoreOld: loadMoreOldMessage, onScroll: handleInfiniteScroll, containerClassName: "h-full", empty: _jsx("div", { className: "flex flex-1 items-center justify-center py-12", children: _jsx(Empty, { description: t("empty.no_messages") }) }), children: loadState.messageList.map((message, _, array) => (_jsx(BizMessageItem, { message: message, allMessages: array, isGroupChat: isGroupChat }, message.clientMsgID))) })) }));
|
|
27
35
|
};
|
|
28
36
|
export default BizMessageList;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BizThreadDetailHeader.d.ts","sourceRoot":"","sources":["../../../src/components/biz-thread-detail/BizThreadDetailHeader.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"BizThreadDetailHeader.d.ts","sourceRoot":"","sources":["../../../src/components/biz-thread-detail/BizThreadDetailHeader.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAOvD,MAAM,WAAW,0BAA0B;IACzC,YAAY,EAAE,mBAAmB,CAAC;IAClC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAqBD,QAAA,MAAM,qBAAqB,GAAI,2BAG5B,0BAA0B,4CA0C5B,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|
|
@@ -4,15 +4,14 @@ import { useTranslation } from "react-i18next";
|
|
|
4
4
|
import { Icon } from "../../components/icon";
|
|
5
5
|
import BizThreadAvatar from "../../components/biz-inbox/BizThreadAvatar";
|
|
6
6
|
import BizThreadTitle from "../../components/biz-inbox/BizThreadTitle";
|
|
7
|
-
import {
|
|
7
|
+
import { resolveBizAvatarUrl, resolveBizBadgeLabel, resolveBizDisplayName, } from "../../utils/bizConversation";
|
|
8
8
|
const HeaderIconButton = ({ icon, onClick, testId, }) => (_jsx("button", { type: "button", onClick: onClick, "data-testid": testId, className: "flex shrink-0 cursor-pointer items-center justify-center p-2 text-[#1B3FE4]", children: _jsx(Icon, { icon: icon, size: 24 }) }));
|
|
9
9
|
const BizThreadDetailHeader = ({ conversation, onBack, }) => {
|
|
10
10
|
const { t } = useTranslation("biz-inbox");
|
|
11
|
-
const
|
|
12
|
-
const displayName = resolveBizDisplayName(conversation, t("thread_card.fallback_name"));
|
|
11
|
+
const displayName = resolveBizDisplayName(conversation, t);
|
|
13
12
|
const avatarUrl = resolveBizAvatarUrl(conversation);
|
|
14
13
|
const badgeLabel = resolveBizBadgeLabel(conversation.chatCategory, t);
|
|
15
|
-
const subtitle =
|
|
14
|
+
const subtitle = t("thread_detail.profile_hint");
|
|
16
15
|
return (_jsxs("div", { "data-testid": "biz-thread-detail-header", className: "flex w-full cursor-default items-center border-b border-[#EFEFEF] bg-white p-2 shadow-[inset_0px_-1px_0px_0px_rgba(61,63,64,0.1)]", children: [_jsx(HeaderIconButton, { icon: "arrow-left-o", onClick: onBack, testId: "biz-thread-detail-back" }), _jsxs("div", { className: "flex min-w-0 flex-1 items-center gap-2 px-1", "data-testid": "biz-thread-detail-profile", children: [_jsx(BizThreadAvatar, { chatCategory: conversation.chatCategory, displayName: displayName, avatarUrl: avatarUrl, badgeLabel: badgeLabel }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx(BizThreadTitle, { chatCategory: conversation.chatCategory, displayName: displayName }), _jsx("p", { className: "truncate text-[10px] font-normal leading-[160%] tracking-[0.1px] text-[#5C6366] [font-feature-settings:'liga'_off,'clig'_off]", children: subtitle })] })] })] }));
|
|
17
16
|
};
|
|
18
17
|
export default BizThreadDetailHeader;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BizThreadDetailInput.d.ts","sourceRoot":"","sources":["../../../src/components/biz-thread-detail/BizThreadDetailInput.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BizThreadDetailInput.d.ts","sourceRoot":"","sources":["../../../src/components/biz-thread-detail/BizThreadDetailInput.tsx"],"names":[],"mappings":"AAgBA,MAAM,WAAW,yBAAyB;IACxC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC;AAED,QAAA,MAAM,oBAAoB,GAAI,gDAI3B,yBAAyB,4CA0N3B,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
import { useTranslation } from "react-i18next";
|
|
5
5
|
import clsx from "clsx";
|
|
6
6
|
import { Icon } from "../../components/icon";
|
|
@@ -8,6 +8,8 @@ import { useBizSendMessage } from "../../hooks/biz/useBizSendMessage";
|
|
|
8
8
|
import useBizConversationStore from "../../store/bizConversation";
|
|
9
9
|
import useBizMessageDraftStore from "../../store/bizMessageDraft";
|
|
10
10
|
import { emit } from "../../utils/events";
|
|
11
|
+
import { extractBizLinkUrls } from "../../utils/bizLink";
|
|
12
|
+
import BizLinkInputPreview from "./BizLinkInputPreview";
|
|
11
13
|
const MAX_LINES = 5;
|
|
12
14
|
const CONTAINER_MIN_HEIGHT = 48;
|
|
13
15
|
const BizThreadDetailInput = ({ placeholder, onSendMessage, onInputChange, }) => {
|
|
@@ -21,6 +23,15 @@ const BizThreadDetailInput = ({ placeholder, onSendMessage, onInputChange, }) =>
|
|
|
21
23
|
const [value, setValue] = useState("");
|
|
22
24
|
const [isFocused, setIsFocused] = useState(false);
|
|
23
25
|
const [isSending, setIsSending] = useState(false);
|
|
26
|
+
const [previewDismissed, setPreviewDismissed] = useState(false);
|
|
27
|
+
const previewUrl = useMemo(() => {
|
|
28
|
+
const urls = extractBizLinkUrls(value);
|
|
29
|
+
return urls.length === 1 ? urls[0] : null;
|
|
30
|
+
}, [value]);
|
|
31
|
+
const showLinkPreview = !!previewUrl && !previewDismissed;
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
setPreviewDismissed(false);
|
|
34
|
+
}, [previewUrl]);
|
|
24
35
|
const canSend = value.trim().length > 0 && !isSending;
|
|
25
36
|
const getTextareaHeights = useCallback(() => {
|
|
26
37
|
const textarea = textareaRef.current;
|
|
@@ -140,8 +151,8 @@ const BizThreadDetailInput = ({ placeholder, onSendMessage, onInputChange, }) =>
|
|
|
140
151
|
event.preventDefault();
|
|
141
152
|
void handleSend();
|
|
142
153
|
};
|
|
143
|
-
return (
|
|
144
|
-
|
|
145
|
-
|
|
154
|
+
return (_jsxs("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: [showLinkPreview && previewUrl && (_jsx(BizLinkInputPreview, { url: previewUrl, onRemove: () => setPreviewDismissed(true) })), _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
|
|
155
|
+
? "border-[#607CFB] shadow-[0px_0px_2px_rgba(27,63,228,0.5)]"
|
|
156
|
+
: "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 appearance-none border-0 bg-transparent p-0 text-[16px] leading-[1.6] tracking-[0.16px] text-black outline-none ring-0 placeholder:text-[#747B7E] focus:border-0 focus:outline-none focus:ring-0" }) }) }), _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
157
|
};
|
|
147
158
|
export default BizThreadDetailInput;
|
|
@@ -2,7 +2,8 @@ import { MessageItem } from "@openim/wasm-client-sdk";
|
|
|
2
2
|
export interface BizMessageItemProps {
|
|
3
3
|
message: MessageItem;
|
|
4
4
|
allMessages: MessageItem[];
|
|
5
|
+
isGroupChat?: boolean;
|
|
5
6
|
}
|
|
6
|
-
declare const BizMessageItem: ({ message, allMessages }: BizMessageItemProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
7
|
+
declare const BizMessageItem: ({ message, allMessages, isGroupChat, }: BizMessageItemProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
7
8
|
export default BizMessageItem;
|
|
8
9
|
//# sourceMappingURL=BizMessageItem.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BizMessageItem.d.ts","sourceRoot":"","sources":["../../../../src/components/biz-thread-detail/item/BizMessageItem.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"BizMessageItem.d.ts","sourceRoot":"","sources":["../../../../src/components/biz-thread-detail/item/BizMessageItem.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAStD,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,WAAW,CAAC;IACrB,WAAW,EAAE,WAAW,EAAE,CAAC;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAyBD,QAAA,MAAM,cAAc,GAAI,wCAIrB,mBAAmB,mDA0DrB,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -2,19 +2,26 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { Icon } from "../../../components/icon";
|
|
4
4
|
import useAuthStore from "../../../store/auth";
|
|
5
|
+
import { visibleTypeMessage } from "../../../hooks/message/useMessage";
|
|
5
6
|
import { formatTimestamp } from "../../../utils/common";
|
|
6
|
-
import { getBizMessageDisplay } from "../../../utils/bizMessage";
|
|
7
|
+
import { getBizMessageDisplay, shouldHideBizMessage } from "../../../utils/bizMessage";
|
|
7
8
|
import BizMessageBubble from "../BizMessageBubble";
|
|
8
|
-
|
|
9
|
+
import BizMessageContent from "../BizMessageContent";
|
|
10
|
+
const BizMessageAvatar = ({ avatarUrl }) => avatarUrl ? (_jsx("img", { src: avatarUrl, alt: "", className: "h-6 w-6 shrink-0 self-end rounded-full object-cover" })) : (_jsx("div", { className: "flex h-6 w-6 shrink-0 items-center justify-center self-end rounded-full bg-[#0C5CFF]", children: _jsx(Icon, { icon: "droppii-o-1", size: 14, className: "text-white" }) }));
|
|
9
11
|
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 }) => {
|
|
12
|
+
const BizMessageItem = ({ message, allMessages, isGroupChat = false, }) => {
|
|
11
13
|
const userID = useAuthStore((state) => state.userID);
|
|
12
14
|
if (!userID)
|
|
13
15
|
return null;
|
|
14
|
-
|
|
16
|
+
if (shouldHideBizMessage(message) ||
|
|
17
|
+
!visibleTypeMessage.includes(message.contentType)) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const display = getBizMessageDisplay(message, allMessages, userID, isGroupChat);
|
|
15
21
|
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: [
|
|
22
|
+
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 gap-1 pl-3 pr-12", children: [isGroupChat &&
|
|
23
|
+
(display.showAvatar ? (_jsx(BizMessageAvatar, { avatarUrl: display.senderFaceUrl })) : (_jsx("div", { className: "h-6 w-6 shrink-0 self-end" }))), _jsx("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: _jsx(BizMessageBubble, { isMine: display.isMine, content: _jsx(BizMessageContent, { message: message }), senderName: display.senderName, showSenderName: display.showSenderName, showTip: display.showTip }) })] })] }));
|
|
17
24
|
}
|
|
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:
|
|
25
|
+
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: _jsx(BizMessageContent, { message: message }), showTip: display.showTip }) }) })] }));
|
|
19
26
|
};
|
|
20
27
|
export default BizMessageItem;
|
|
@@ -4,12 +4,13 @@ export interface MessageInfiniteScrollProps {
|
|
|
4
4
|
scrollRef: Ref<HTMLDivElement>;
|
|
5
5
|
scrollableTargetId: string;
|
|
6
6
|
loadState: MessageListLoadState;
|
|
7
|
+
moreOldLoading?: boolean;
|
|
7
8
|
onLoadMoreOld: () => void;
|
|
8
9
|
onScroll: (e: React.UIEvent<HTMLDivElement>) => void;
|
|
9
10
|
children: ReactNode;
|
|
10
11
|
empty?: ReactNode;
|
|
11
12
|
containerClassName?: string;
|
|
12
13
|
}
|
|
13
|
-
declare const MessageInfiniteScroll: ({ scrollRef, scrollableTargetId, loadState, onLoadMoreOld, onScroll, children, empty, containerClassName, }: MessageInfiniteScrollProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
declare const MessageInfiniteScroll: ({ scrollRef, scrollableTargetId, loadState, moreOldLoading, onLoadMoreOld, onScroll, children, empty, containerClassName, }: MessageInfiniteScrollProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
15
|
export default MessageInfiniteScroll;
|
|
15
16
|
//# sourceMappingURL=MessageInfiniteScroll.d.ts.map
|