listpage-next 0.0.102 → 0.0.104

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,14 +1,11 @@
1
1
  import { ReactNode } from "react";
2
- import { BaseMessageInfo, ChatRender, ChatRequest } from "../../context";
2
+ import { BaseMessageInfo, ChatActionEvent, ChatRender, ChatRequest } from "../../context";
3
3
  export interface ChatPageProps<SessionData = any, MessageInfo extends BaseMessageInfo = any> {
4
4
  logo?: string;
5
5
  title?: string;
6
6
  children?: ReactNode;
7
7
  request: ChatRequest<SessionData, MessageInfo>;
8
8
  render: ChatRender<MessageInfo>;
9
- onClickConversation?: (key: string, item: SessionData) => void;
10
- onClickNewConversation?: () => void;
11
- onRenameConversation?: (key: string, item: SessionData) => Promise<void>;
12
- onDeleteConversation?: (key: string, item: SessionData) => Promise<void>;
9
+ action: ChatActionEvent<SessionData>;
13
10
  }
14
11
  export declare const ChatPage: (props: ChatPageProps) => import("react/jsx-runtime").JSX.Element;
@@ -6,7 +6,7 @@ import { NewConversationButton } from "../NewConversationButton/index.js";
6
6
  import { ChatClientProvider } from "../../context/index.js";
7
7
  import { Content, Layout } from "./styles.js";
8
8
  const ChatPageComponent = (props)=>{
9
- const { logo, title, children, request, onClickConversation, onClickNewConversation, onRenameConversation, onDeleteConversation } = props;
9
+ const { logo, title, children, action } = props;
10
10
  return /*#__PURE__*/ jsxs(Layout, {
11
11
  style: {
12
12
  height: '100vh'
@@ -19,14 +19,9 @@ const ChatPageComponent = (props)=>{
19
19
  title: title || '智能对话'
20
20
  }),
21
21
  /*#__PURE__*/ jsx(NewConversationButton, {
22
- onClickNew: onClickNewConversation
22
+ onClickNew: action.onClickNewConversation
23
23
  }),
24
- /*#__PURE__*/ jsx(HistoryConversation, {
25
- request: request.getConversations,
26
- onSelect: onClickConversation,
27
- onRename: onRenameConversation,
28
- onDelete: onDeleteConversation
29
- })
24
+ /*#__PURE__*/ jsx(HistoryConversation, {})
30
25
  ]
31
26
  }),
32
27
  /*#__PURE__*/ jsx(Content, {
@@ -38,6 +33,7 @@ const ChatPageComponent = (props)=>{
38
33
  const ChatPage = (props)=>/*#__PURE__*/ jsx(ChatClientProvider, {
39
34
  request: props.request,
40
35
  render: props.render,
36
+ action: props.action,
41
37
  children: /*#__PURE__*/ jsx(ChatPageComponent, {
42
38
  ...props
43
39
  })
@@ -1,11 +1,6 @@
1
- import { InfiniteListProps } from "../../../../components/InfiniteList";
2
1
  export interface HistoryConversationProps<T = any> {
3
2
  rowKey?: string;
4
- request: InfiniteListProps<T>['request'];
5
3
  activeKey?: string;
6
- onDelete?: (key: string, item: T) => Promise<void>;
7
- onRename?: (key: string, item: T) => Promise<void>;
8
- onSelect?: (key: string, item: T) => void;
9
4
  }
10
5
  export declare const HistoryConversation: <T extends ItemData = any>(props: HistoryConversationProps<T>) => import("react/jsx-runtime").JSX.Element;
11
6
  type ItemData = {
@@ -7,15 +7,16 @@ import { InfiniteList } from "../../../../components/InfiniteList/index.js";
7
7
  import { useChatClientContext } from "../../context/index.js";
8
8
  import { HeaderContainer, HeaderTitle, HistoryConversationContainer, ListContainer, ListItemContainer, ListText } from "./styles.js";
9
9
  const HistoryConversation = (props)=>{
10
- const { rowKey = "id", request, activeKey, onDelete, onRename, onSelect } = props;
11
- const { showUpdateTitleModal, conversationListRef } = useChatClientContext();
10
+ const { rowKey = "id", activeKey } = props;
11
+ const { showUpdateTitleModal, conversationListRef, action, request } = useChatClientContext();
12
+ const { onClickConversation, onRenameConversation, onDeleteConversation } = action;
12
13
  return /*#__PURE__*/ jsxs(HistoryConversationContainer, {
13
14
  children: [
14
15
  /*#__PURE__*/ jsx(Header, {}),
15
16
  /*#__PURE__*/ jsx(ListContainer, {
16
17
  children: /*#__PURE__*/ jsx(InfiniteList, {
17
18
  ref: conversationListRef,
18
- request: request,
19
+ request: request.getConversations,
19
20
  rowKey: rowKey,
20
21
  pageSize: 10,
21
22
  renderItem: (item, index, actions)=>{
@@ -30,7 +31,7 @@ const HistoryConversation = (props)=>{
30
31
  ...item,
31
32
  title: newTitle
32
33
  };
33
- await onRename?.(key, newItem);
34
+ await onRenameConversation?.(key, newItem);
34
35
  actions.updateItem(key, newItem);
35
36
  });
36
37
  }
@@ -40,14 +41,14 @@ const HistoryConversation = (props)=>{
40
41
  danger: true,
41
42
  label: '删除',
42
43
  onClick: async ()=>{
43
- await onDelete?.(key, item);
44
+ await onDeleteConversation?.(key, item);
44
45
  actions.deleteItem(key);
45
46
  }
46
47
  }
47
48
  ];
48
49
  return /*#__PURE__*/ jsxs(ListItemContainer, {
49
50
  isHover: activeKey === key ? true : void 0,
50
- onClick: ()=>onSelect?.(key, item),
51
+ onClick: ()=>onClickConversation?.(key, item),
51
52
  children: [
52
53
  /*#__PURE__*/ jsx(Avatar, {
53
54
  size: 20,
@@ -32,10 +32,7 @@ const Reasoning = ({ thinking, children })=>{
32
32
  })
33
33
  ]
34
34
  }),
35
- /*#__PURE__*/ jsx(ReasoningContent, {
36
- style: {
37
- height: collapsed ? 0 : 'auto'
38
- },
35
+ !collapsed && /*#__PURE__*/ jsx(ReasoningContent, {
39
36
  children: children
40
37
  })
41
38
  ]
@@ -10,9 +10,16 @@ export type ChatRequest<SessionData = any, MessageInfo extends BaseMessageInfo =
10
10
  export type ChatRender<MessageInfo extends BaseMessageInfo = any> = {
11
11
  renderMessage: (message: Message<MessageInfo>) => ReactNode;
12
12
  };
13
+ export type ChatActionEvent<SessionData = any> = {
14
+ onClickConversation?: (key: string, item: SessionData) => void;
15
+ onClickNewConversation?: () => void;
16
+ onRenameConversation?: (key: string, item: SessionData) => Promise<void>;
17
+ onDeleteConversation?: (key: string, item: SessionData) => Promise<void>;
18
+ };
13
19
  export interface ChatClientContextProps<SessionData = any, MessageInfo extends BaseMessageInfo = any> {
14
20
  request: ChatRequest<SessionData, MessageInfo>;
15
21
  render: ChatRender<MessageInfo>;
22
+ action: ChatActionEvent<SessionData>;
16
23
  collapsed: boolean;
17
24
  setCollapsed: (collapsed: boolean) => void;
18
25
  showUpdateTitleModal: (title: string, onSubmit?: (title: string) => any) => void;
@@ -24,6 +31,7 @@ export interface ChatClientProviderProps<SessionData = any, MessageInfo extends
24
31
  children: ReactNode;
25
32
  request: ChatRequest<SessionData, MessageInfo>;
26
33
  render: ChatRender<MessageInfo>;
34
+ action: ChatActionEvent<SessionData>;
27
35
  }
28
36
  export declare const ChatClientContext: import("react").Context<ChatClientContextProps<any, any>>;
29
37
  export declare const ChatClientProvider: (props: ChatClientProviderProps) => import("react/jsx-runtime").JSX.Element;
@@ -5,13 +5,14 @@ import { useConversationListRef } from "./useConversationListRef.js";
5
5
  import { useBubbleListRef } from "./useBubbleListRef.js";
6
6
  const ChatClientContext = /*#__PURE__*/ createContext({});
7
7
  const ChatClientProvider = (props)=>{
8
- const { children, request, render } = props;
8
+ const { children, request, render, action } = props;
9
9
  const { updateTitleModalEle, showUpdateTitleModal } = useUpdateTitleModal();
10
10
  const [collapsed, setCollapsed] = useState(false);
11
11
  const { conversationListRef, ...conversationActions } = useConversationListRef();
12
12
  const { bubbleListRef } = useBubbleListRef();
13
13
  return /*#__PURE__*/ jsxs(ChatClientContext.Provider, {
14
14
  value: {
15
+ action,
15
16
  render,
16
17
  request,
17
18
  collapsed,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "listpage-next",
3
- "version": "0.0.102",
3
+ "version": "0.0.104",
4
4
  "description": "A React component library for creating filter forms with Ant Design",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",