listpage-next 0.0.89 → 0.0.90
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/features/ChatClient/components/ClientContent/{Content.d.ts → BubbleList.d.ts} +2 -2
- package/dist/features/ChatClient/components/ClientContent/{Content.js → BubbleList.js} +21 -3
- package/dist/features/ChatClient/components/ClientContent/index.d.ts +2 -2
- package/dist/features/ChatClient/components/ClientContent/index.js +4 -4
- package/dist/features/ChatClient/components/Layout/styles.js +1 -0
- package/dist/features/ChatClient/context/client.d.ts +1 -0
- package/dist/features/ChatClient/context/client.js +3 -0
- package/dist/features/ChatClient/context/useBubbleListRef.d.ts +9 -0
- package/dist/features/ChatClient/context/useBubbleListRef.js +11 -0
- package/dist/features/ChatClient/context/useChatContext.d.ts +1 -0
- package/dist/features/ChatClient/context/useChatContext.js +3 -2
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { CSSProperties } from "react";
|
|
2
|
-
export interface
|
|
2
|
+
export interface BubbleListProps {
|
|
3
3
|
styles?: {
|
|
4
4
|
topPlaceholder?: CSSProperties;
|
|
5
5
|
bottomPlaceholder?: CSSProperties;
|
|
6
6
|
content?: CSSProperties;
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const BubbleList: (props: BubbleListProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,11 +1,29 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useImperativeHandle, useRef } from "react";
|
|
2
3
|
import { styled } from "styled-components";
|
|
3
4
|
import { useChatClientContext, useMessageContext } from "../../context/index.js";
|
|
4
|
-
|
|
5
|
+
import { useMount } from "ahooks";
|
|
6
|
+
const BubbleList = (props)=>{
|
|
5
7
|
const { styles } = props;
|
|
6
|
-
const
|
|
8
|
+
const containerRef = useRef(null);
|
|
9
|
+
const { render, bubbleListRef } = useChatClientContext();
|
|
7
10
|
const { messages } = useMessageContext();
|
|
11
|
+
const scrollToBottom = ()=>{
|
|
12
|
+
containerRef.current?.scrollTo({
|
|
13
|
+
top: containerRef.current.scrollHeight,
|
|
14
|
+
behavior: "smooth"
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
useMount(()=>{
|
|
18
|
+
scrollToBottom();
|
|
19
|
+
});
|
|
20
|
+
useImperativeHandle(bubbleListRef, ()=>({
|
|
21
|
+
scrollToBottom
|
|
22
|
+
}), [
|
|
23
|
+
scrollToBottom
|
|
24
|
+
]);
|
|
8
25
|
return /*#__PURE__*/ jsxs(ContentContainer, {
|
|
26
|
+
ref: containerRef,
|
|
9
27
|
children: [
|
|
10
28
|
/*#__PURE__*/ jsx("div", {
|
|
11
29
|
style: styles?.topPlaceholder ?? {
|
|
@@ -33,4 +51,4 @@ const ContentContainer = styled.div`
|
|
|
33
51
|
overflow: auto;
|
|
34
52
|
position: relative;
|
|
35
53
|
`;
|
|
36
|
-
export {
|
|
54
|
+
export { BubbleList };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { FooterProps } from "./Footer";
|
|
2
2
|
import { HeaderProps } from "./Header";
|
|
3
|
-
import {
|
|
3
|
+
import { BubbleListProps } from "./BubbleList";
|
|
4
4
|
export interface ClientContentProps {
|
|
5
5
|
className?: string;
|
|
6
6
|
style?: React.CSSProperties;
|
|
7
7
|
headerProps?: HeaderProps;
|
|
8
8
|
footerProps?: FooterProps;
|
|
9
|
-
|
|
9
|
+
bubbleProps?: BubbleListProps;
|
|
10
10
|
}
|
|
11
11
|
export declare const ClientContent: (props: ClientContentProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,12 +2,12 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useRequest } from "ahooks";
|
|
3
3
|
import { Footer } from "./Footer.js";
|
|
4
4
|
import { Header } from "./Header.js";
|
|
5
|
-
import {
|
|
5
|
+
import { BubbleList } from "./BubbleList.js";
|
|
6
6
|
import { MessageProvider, useChatClientContext } from "../../context/index.js";
|
|
7
7
|
import { PageLoading } from "../../../../components/Page/components/Loading/index.js";
|
|
8
8
|
import { Container } from "./styles.js";
|
|
9
9
|
const ClientContentComponent = (props)=>{
|
|
10
|
-
const { style, className, headerProps, footerProps,
|
|
10
|
+
const { style, className, headerProps, footerProps, bubbleProps } = props;
|
|
11
11
|
return /*#__PURE__*/ jsxs(Container, {
|
|
12
12
|
style: style,
|
|
13
13
|
className: className,
|
|
@@ -15,8 +15,8 @@ const ClientContentComponent = (props)=>{
|
|
|
15
15
|
/*#__PURE__*/ jsx(Header, {
|
|
16
16
|
...headerProps
|
|
17
17
|
}),
|
|
18
|
-
/*#__PURE__*/ jsx(
|
|
19
|
-
...
|
|
18
|
+
/*#__PURE__*/ jsx(BubbleList, {
|
|
19
|
+
...bubbleProps
|
|
20
20
|
}),
|
|
21
21
|
/*#__PURE__*/ jsx(Footer, {
|
|
22
22
|
...footerProps
|
|
@@ -17,6 +17,7 @@ export interface ChatClientContextProps<SessionData = any, MessageInfo extends B
|
|
|
17
17
|
showUpdateTitleModal: (title: string, onSubmit?: (title: string) => any) => void;
|
|
18
18
|
conversationListRef: InfiniteListRef<SessionData>;
|
|
19
19
|
conversationAction: Partial<RenderActions<SessionData>>;
|
|
20
|
+
bubbleListRef: any;
|
|
20
21
|
}
|
|
21
22
|
export interface ChatClientProviderProps<SessionData = any, MessageInfo extends BaseMessageInfo = any> {
|
|
22
23
|
children: ReactNode;
|
|
@@ -2,12 +2,14 @@ import { jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { createContext, useContext, useState } from "react";
|
|
3
3
|
import { useUpdateTitleModal } from "./useUpdateTitleModal.js";
|
|
4
4
|
import { useConversationListRef } from "./useConversationListRef.js";
|
|
5
|
+
import { useBubbleListRef } from "./useBubbleListRef.js";
|
|
5
6
|
const ChatClientContext = /*#__PURE__*/ createContext({});
|
|
6
7
|
const ChatClientProvider = (props)=>{
|
|
7
8
|
const { children, request, render } = props;
|
|
8
9
|
const { updateTitleModalEle, showUpdateTitleModal } = useUpdateTitleModal();
|
|
9
10
|
const [collapsed, setCollapsed] = useState(false);
|
|
10
11
|
const { conversationListRef, ...conversationActions } = useConversationListRef();
|
|
12
|
+
const { bubbleListRef } = useBubbleListRef();
|
|
11
13
|
return /*#__PURE__*/ jsxs(ChatClientContext.Provider, {
|
|
12
14
|
value: {
|
|
13
15
|
render,
|
|
@@ -16,6 +18,7 @@ const ChatClientProvider = (props)=>{
|
|
|
16
18
|
setCollapsed,
|
|
17
19
|
showUpdateTitleModal,
|
|
18
20
|
conversationListRef,
|
|
21
|
+
bubbleListRef,
|
|
19
22
|
conversationAction: conversationActions
|
|
20
23
|
},
|
|
21
24
|
children: [
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Ref } from "react";
|
|
2
|
+
export type BubbleListAction = {
|
|
3
|
+
scrollToBottom: () => void;
|
|
4
|
+
};
|
|
5
|
+
export type BubbleListRef = Ref<BubbleListAction>;
|
|
6
|
+
export declare function useBubbleListRef(): {
|
|
7
|
+
scrollToBottom: () => void;
|
|
8
|
+
bubbleListRef: import("react").RefObject<BubbleListAction>;
|
|
9
|
+
};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { useChatClientContext } from "./client.js";
|
|
2
2
|
import { useMessageContext } from "./message.js";
|
|
3
3
|
function useChatContext() {
|
|
4
|
-
const { conversationAction } = useChatClientContext();
|
|
4
|
+
const { conversationAction, bubbleListRef } = useChatClientContext();
|
|
5
5
|
const { messages, sendMessage } = useMessageContext();
|
|
6
6
|
const { deleteItem, updateItem } = conversationAction ?? {};
|
|
7
7
|
return {
|
|
8
8
|
messages,
|
|
9
9
|
sendMessage,
|
|
10
10
|
deleteConversation: deleteItem,
|
|
11
|
-
updateConversation: updateItem
|
|
11
|
+
updateConversation: updateItem,
|
|
12
|
+
scrollToBottom: ()=>bubbleListRef.current?.scrollToBottom()
|
|
12
13
|
};
|
|
13
14
|
}
|
|
14
15
|
export { useChatContext };
|