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.
@@ -1,9 +1,9 @@
1
1
  import { CSSProperties } from "react";
2
- export interface ContentProps {
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 Content: (props: ContentProps) => import("react/jsx-runtime").JSX.Element;
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
- const Content = (props)=>{
5
+ import { useMount } from "ahooks";
6
+ const BubbleList = (props)=>{
5
7
  const { styles } = props;
6
- const { render } = useChatClientContext();
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 { Content };
54
+ export { BubbleList };
@@ -1,11 +1,11 @@
1
1
  import { FooterProps } from "./Footer";
2
2
  import { HeaderProps } from "./Header";
3
- import { ContentProps } from "./Content";
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
- contentProps?: ContentProps;
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 { Content } from "./Content.js";
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, contentProps } = props;
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(Content, {
19
- ...contentProps
18
+ /*#__PURE__*/ jsx(BubbleList, {
19
+ ...bubbleProps
20
20
  }),
21
21
  /*#__PURE__*/ jsx(Footer, {
22
22
  ...footerProps
@@ -8,5 +8,6 @@ const Layout = styled_components.div`
8
8
  `;
9
9
  const Content = styled_components.div`
10
10
  flex: 1;
11
+ min-width: 0;
11
12
  `;
12
13
  export { Content, Layout };
@@ -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
+ };
@@ -0,0 +1,11 @@
1
+ import { useRef } from "react";
2
+ function useBubbleListRef() {
3
+ const bubbleListRef = useRef({
4
+ scrollToBottom: ()=>{}
5
+ });
6
+ return {
7
+ bubbleListRef,
8
+ ...bubbleListRef.current
9
+ };
10
+ }
11
+ export { useBubbleListRef };
@@ -3,4 +3,5 @@ export declare function useChatContext(): {
3
3
  sendMessage: (info: any) => void;
4
4
  deleteConversation: ((key: string) => void) | undefined;
5
5
  updateConversation: ((key: string, item: any) => void) | undefined;
6
+ scrollToBottom: () => any;
6
7
  };
@@ -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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "listpage-next",
3
- "version": "0.0.89",
3
+ "version": "0.0.90",
4
4
  "description": "A React component library for creating filter forms with Ant Design",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",