listpage-next 0.0.86 → 0.0.88

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 (22) hide show
  1. package/dist/demos/demo8.js +3 -9
  2. package/dist/features/ChatClient/components/ChatSender/index.js +1 -1
  3. package/dist/features/ChatClient/components/ChatSender/styles.js +1 -0
  4. package/dist/features/ChatClient/components/ClientContent/Content.d.ts +0 -1
  5. package/dist/features/ChatClient/components/ClientContent/Content.js +5 -2
  6. package/dist/features/ChatClient/components/ClientContent/index.d.ts +2 -1
  7. package/dist/features/ChatClient/components/ClientContent/index.js +2 -2
  8. package/dist/features/ChatClient/components/HistoryConversation/index.js +1 -1
  9. package/dist/features/ChatClient/components/HistoryConversation/styles.d.ts +1 -1
  10. package/dist/features/ChatClient/components/Layout/ChatPage.d.ts +3 -3
  11. package/dist/features/ChatClient/components/Layout/ChatPage.js +5 -5
  12. package/dist/features/ChatClient/components/{NewConversation → NewConversationButton}/index.d.ts +1 -1
  13. package/dist/features/ChatClient/components/NewConversationButton/index.js +37 -0
  14. package/dist/features/ChatClient/context/client.d.ts +9 -4
  15. package/dist/features/ChatClient/context/client.js +2 -1
  16. package/dist/features/ChatClient/context/message.d.ts +1 -0
  17. package/dist/features/ChatClient/context/message.js +5 -2
  18. package/dist/features/ChatClient/context/useChatContext.js +1 -1
  19. package/package.json +1 -1
  20. package/dist/features/ChatClient/components/NewConversation/index.js +0 -42
  21. package/dist/features/ChatClient/context/useMessageContext.d.ts +0 -2
  22. package/dist/features/ChatClient/context/useMessageContext.js +0 -6
@@ -1,11 +1,5 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { ClientContent } from "../features/ChatClient/index.js";
3
- const Demo8 = ()=>/*#__PURE__*/ jsx(ClientContent, {
4
- style: {
5
- height: 800
6
- },
7
- headerProps: {
8
- defaultTitle: "搜索海量信息,生成研究报告"
9
- }
10
- });
2
+ import { NewConversationButton } from "../features/ChatClient/components/NewConversationButton/index.js";
3
+ import "../features/ChatClient/index.js";
4
+ const Demo8 = ()=>/*#__PURE__*/ jsx(NewConversationButton, {});
11
5
  export { Demo8 };
@@ -3,7 +3,7 @@ import { useState } from "react";
3
3
  import { Button, Divider, Input } from "antd";
4
4
  import { ChatInputBottom, ChatInputContent, ChatInputPanel } from "./styles.js";
5
5
  import { ArrowUpOutlined, PauseCircleTwoTone } from "@ant-design/icons";
6
- import { useMessageContext } from "../../context/useMessageContext.js";
6
+ import { useMessageContext } from "../../context/index.js";
7
7
  const ChatSender = (props)=>{
8
8
  const { placeholder, extra, style, className } = props;
9
9
  const { isRequesting, sendMessage } = useMessageContext();
@@ -34,6 +34,7 @@ const ChatInputContent = styled.div`
34
34
  min-height: 60px;
35
35
  max-height: 220px;
36
36
  resize: none;
37
+ font-size: 16px;
37
38
 
38
39
  background-color: transparent;
39
40
  box-shadow: none;
@@ -1,6 +1,5 @@
1
1
  import { CSSProperties } from "react";
2
2
  export interface ContentProps {
3
- children?: React.ReactNode;
4
3
  styles?: {
5
4
  topPlaceholder?: CSSProperties;
6
5
  bottomPlaceholder?: CSSProperties;
@@ -1,7 +1,10 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { styled } from "styled-components";
3
+ import { useChatClientContext, useMessageContext } from "../../context/index.js";
3
4
  const Content = (props)=>{
4
- const { children, styles } = props;
5
+ const { styles } = props;
6
+ const { render } = useChatClientContext();
7
+ const { messages } = useMessageContext();
5
8
  return /*#__PURE__*/ jsxs(ContentContainer, {
6
9
  children: [
7
10
  /*#__PURE__*/ jsx("div", {
@@ -13,7 +16,7 @@ const Content = (props)=>{
13
16
  style: styles?.content ?? {
14
17
  padding: "0 200px"
15
18
  },
16
- children: children
19
+ children: (messages ?? []).map((msg)=>render.renderMessage(msg))
17
20
  }),
18
21
  /*#__PURE__*/ jsx("div", {
19
22
  style: styles?.bottomPlaceholder ?? {
@@ -1,10 +1,11 @@
1
1
  import { FooterProps } from "./Footer";
2
2
  import { HeaderProps } from "./Header";
3
+ import { ContentProps } from "./Content";
3
4
  export interface ClientContentProps {
4
5
  className?: string;
5
6
  style?: React.CSSProperties;
6
7
  headerProps?: HeaderProps;
7
8
  footerProps?: FooterProps;
8
- children?: React.ReactNode;
9
+ contentProps?: ContentProps;
9
10
  }
10
11
  export declare const ClientContent: (props: ClientContentProps) => import("react/jsx-runtime").JSX.Element;
@@ -7,7 +7,7 @@ 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, children, headerProps, footerProps } = props;
10
+ const { style, className, headerProps, footerProps, contentProps } = props;
11
11
  return /*#__PURE__*/ jsxs(Container, {
12
12
  style: style,
13
13
  className: className,
@@ -16,7 +16,7 @@ const ClientContentComponent = (props)=>{
16
16
  ...headerProps
17
17
  }),
18
18
  /*#__PURE__*/ jsx(Content, {
19
- children: children
19
+ ...contentProps
20
20
  }),
21
21
  /*#__PURE__*/ jsx(Footer, {
22
22
  ...footerProps
@@ -46,7 +46,7 @@ const HistoryConversation = (props)=>{
46
46
  }
47
47
  ];
48
48
  return /*#__PURE__*/ jsxs(ListItemContainer, {
49
- isHover: activeKey === key,
49
+ isHover: activeKey === key ? true : void 0,
50
50
  onClick: ()=>onSelect?.(key, item),
51
51
  children: [
52
52
  /*#__PURE__*/ jsx(Avatar, {
@@ -3,6 +3,6 @@ export declare const HeaderContainer: import("styled-components/dist/types").ISt
3
3
  export declare const HeaderTitle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
4
4
  export declare const ListContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
5
5
  export declare const ListItemContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
6
- isHover: boolean;
6
+ isHover?: boolean;
7
7
  }>> & string;
8
8
  export declare const ListText: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
@@ -1,13 +1,13 @@
1
1
  import { ReactNode } from "react";
2
- import { BaseMessageInfo, ClientRequest } from "../../context";
2
+ import { BaseMessageInfo, 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
- request: ClientRequest<SessionData, MessageInfo>;
7
+ request: ChatRequest<SessionData, MessageInfo>;
8
+ render: ChatRender<MessageInfo>;
8
9
  onClickConversation?: (key: string, item: SessionData) => void;
9
10
  onClickNewConversation?: () => void;
10
- onClickMoreAgent?: () => void;
11
11
  onRenameConversation?: (key: string, item: SessionData) => Promise<void>;
12
12
  onDeleteConversation?: (key: string, item: SessionData) => Promise<void>;
13
13
  }
@@ -2,11 +2,11 @@ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Sider } from "./Sider.js";
3
3
  import { Logo } from "../Logo/index.js";
4
4
  import { HistoryConversation } from "../HistoryConversation/index.js";
5
- import { NewConversation } from "../NewConversation/index.js";
5
+ 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, onClickMoreAgent, onRenameConversation, onDeleteConversation } = props;
9
+ const { logo, title, children, request, onClickConversation, onClickNewConversation, onRenameConversation, onDeleteConversation } = props;
10
10
  return /*#__PURE__*/ jsxs(Layout, {
11
11
  style: {
12
12
  height: '100vh'
@@ -18,9 +18,8 @@ const ChatPageComponent = (props)=>{
18
18
  icon: logo,
19
19
  title: title || '智能对话'
20
20
  }),
21
- /*#__PURE__*/ jsx(NewConversation, {
22
- onClickNew: onClickNewConversation,
23
- onClickMoreAgent: onClickMoreAgent
21
+ /*#__PURE__*/ jsx(NewConversationButton, {
22
+ onClickNew: onClickNewConversation
24
23
  }),
25
24
  /*#__PURE__*/ jsx(HistoryConversation, {
26
25
  request: request.getConversations,
@@ -38,6 +37,7 @@ const ChatPageComponent = (props)=>{
38
37
  };
39
38
  const ChatPage = (props)=>/*#__PURE__*/ jsx(ChatClientProvider, {
40
39
  request: props.request,
40
+ render: props.render,
41
41
  children: /*#__PURE__*/ jsx(ChatPageComponent, {
42
42
  ...props
43
43
  })
@@ -1,4 +1,4 @@
1
- export declare const NewConversation: (props: {
1
+ export declare const NewConversationButton: (props: {
2
2
  onClickNew?: () => void;
3
3
  onClickMoreAgent?: () => void;
4
4
  }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,37 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { EditTwoTone } from "@ant-design/icons";
3
+ import { styled } from "styled-components";
4
+ const NewConversationContainer = styled.div`
5
+ padding: 0 12px;
6
+ margin-top: 16px;
7
+ `;
8
+ const NewConversationButtonStyle = styled.div`
9
+ cursor: pointer;
10
+ border: .5px solid rgba(0, 102, 255, .15);
11
+ color: #0057ff;
12
+
13
+ display: flex;
14
+ align-items: center;
15
+ gap: 6px;
16
+
17
+ padding: 8px 6px;
18
+ border-radius: 12px;
19
+ font-size: 14px;
20
+ font-weight: 600;
21
+ background: #0057ff0f;
22
+ &:hover {
23
+ background: rgba(0, 102, 255, .1);
24
+ }
25
+ `;
26
+ const NewConversationButton = (props)=>/*#__PURE__*/ jsx(NewConversationContainer, {
27
+ children: /*#__PURE__*/ jsxs(NewConversationButtonStyle, {
28
+ onClick: props.onClickNew,
29
+ children: [
30
+ /*#__PURE__*/ jsx(EditTwoTone, {}),
31
+ /*#__PURE__*/ jsx("span", {
32
+ children: "新对话"
33
+ })
34
+ ]
35
+ })
36
+ });
37
+ export { NewConversationButton };
@@ -1,13 +1,17 @@
1
1
  import { ReactNode } from "react";
2
2
  import { InfiniteListProps, InfiniteListRef, RenderActions } from "../../../components/InfiniteList";
3
- import { BaseMessageInfo, SendMessageRequest } from "./message";
4
- export type ClientRequest<SessionData = any, MessageInfo extends BaseMessageInfo = any> = {
3
+ import { BaseMessageInfo, Message, SendMessageRequest } from "./message";
4
+ export type ChatRequest<SessionData = any, MessageInfo extends BaseMessageInfo = any> = {
5
5
  getConversations: InfiniteListProps<SessionData>['request'];
6
6
  getMessages: () => Promise<MessageInfo[]>;
7
7
  chat: SendMessageRequest<MessageInfo>;
8
8
  };
9
+ export type ChatRender<MessageInfo extends BaseMessageInfo = any> = {
10
+ renderMessage: (message: Message<MessageInfo>) => ReactNode;
11
+ };
9
12
  export interface ChatClientContextProps<SessionData = any, MessageInfo extends BaseMessageInfo = any> {
10
- request: ClientRequest<SessionData, MessageInfo>;
13
+ request: ChatRequest<SessionData, MessageInfo>;
14
+ render: ChatRender<MessageInfo>;
11
15
  collapsed: boolean;
12
16
  setCollapsed: (collapsed: boolean) => void;
13
17
  showUpdateTitleModal: (title: string, onSubmit?: (title: string) => any) => void;
@@ -16,7 +20,8 @@ export interface ChatClientContextProps<SessionData = any, MessageInfo extends B
16
20
  }
17
21
  export interface ChatClientProviderProps<SessionData = any, MessageInfo extends BaseMessageInfo = any> {
18
22
  children: ReactNode;
19
- request: ClientRequest<SessionData, MessageInfo>;
23
+ request: ChatRequest<SessionData, MessageInfo>;
24
+ render: ChatRender<MessageInfo>;
20
25
  }
21
26
  export declare const ChatClientContext: import("react").Context<ChatClientContextProps<any, any>>;
22
27
  export declare const ChatClientProvider: (props: ChatClientProviderProps) => import("react/jsx-runtime").JSX.Element;
@@ -4,12 +4,13 @@ import { useUpdateTitleModal } from "./useUpdateTitleModal.js";
4
4
  import { useConversationListRef } from "./useConversationListRef.js";
5
5
  const ChatClientContext = /*#__PURE__*/ createContext({});
6
6
  const ChatClientProvider = (props)=>{
7
- const { children, request } = props;
7
+ const { children, request, render } = props;
8
8
  const { updateTitleModalEle, showUpdateTitleModal } = useUpdateTitleModal();
9
9
  const [collapsed, setCollapsed] = useState(false);
10
10
  const { conversationListRef, ...conversationActions } = useConversationListRef();
11
11
  return /*#__PURE__*/ jsxs(ChatClientContext.Provider, {
12
12
  value: {
13
+ render,
13
14
  request,
14
15
  collapsed,
15
16
  setCollapsed,
@@ -29,3 +29,4 @@ export declare const MessageProvider: <MessageInfo extends BaseMessageInfo = any
29
29
  initialMessages: MessageInfo[];
30
30
  request: SendMessageRequest<MessageInfo>;
31
31
  }) => import("react/jsx-runtime").JSX.Element;
32
+ export declare function useMessageContext<MessageInfo extends BaseMessageInfo = any>(): MessageContextValue<MessageInfo>;
@@ -1,5 +1,5 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { createContext, useCallback, useRef, useState } from "react";
2
+ import { createContext, useCallback, useContext, useRef, useState } from "react";
3
3
  import { useMount } from "ahooks";
4
4
  const MessageContext = /*#__PURE__*/ createContext({});
5
5
  const MessageProvider = ({ initialMessages, children, request })=>{
@@ -121,4 +121,7 @@ const MessageProvider = ({ initialMessages, children, request })=>{
121
121
  children: children
122
122
  });
123
123
  };
124
- export { MessageContext, MessageProvider };
124
+ function useMessageContext() {
125
+ return useContext(MessageContext);
126
+ }
127
+ export { MessageContext, MessageProvider, useMessageContext };
@@ -1,5 +1,5 @@
1
1
  import { useChatClientContext } from "./client.js";
2
- import { useMessageContext } from "./useMessageContext.js";
2
+ import { useMessageContext } from "./message.js";
3
3
  function useChatContext() {
4
4
  const { conversationAction } = useChatClientContext();
5
5
  const { messages, sendMessage } = useMessageContext();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "listpage-next",
3
- "version": "0.0.86",
3
+ "version": "0.0.88",
4
4
  "description": "A React component library for creating filter forms with Ant Design",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,42 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { EditOutlined } from "@ant-design/icons";
3
- import { Button, Divider } from "antd";
4
- import { styled } from "styled-components";
5
- const NewConversationContainer = styled.div`
6
- padding: 0 12px;
7
- margin-top: 16px;
8
- `;
9
- const FakeButtonStyle = styled.div`
10
- &:hover {
11
- background-color: #0000000a;
12
- }
13
- color: #000000;
14
- display: flex;
15
- align-items: center;
16
- padding: 8px;
17
- border-radius: 8px;
18
- cursor: pointer;
19
-
20
- font-weight: 400;
21
- font-size: 14px;
22
-
23
- margin-top: 8px;
24
- `;
25
- const NewConversation = (props)=>/*#__PURE__*/ jsxs(NewConversationContainer, {
26
- children: [
27
- /*#__PURE__*/ jsx(Button, {
28
- onClick: props.onClickNew,
29
- variant: "outlined",
30
- icon: /*#__PURE__*/ jsx(EditOutlined, {}),
31
- block: true,
32
- color: "blue",
33
- children: "新对话"
34
- }),
35
- /*#__PURE__*/ jsx(FakeButtonStyle, {
36
- onClick: props.onClickMoreAgent,
37
- children: "AI智能体"
38
- }),
39
- /*#__PURE__*/ jsx(Divider, {})
40
- ]
41
- });
42
- export { NewConversation };
@@ -1,2 +0,0 @@
1
- import { BaseMessageInfo, MessageContextValue } from "./message";
2
- export declare function useMessageContext<MessageInfo extends BaseMessageInfo = any>(): MessageContextValue<MessageInfo>;
@@ -1,6 +0,0 @@
1
- import { useContext } from "react";
2
- import { MessageContext } from "./message.js";
3
- function useMessageContext() {
4
- return useContext(MessageContext);
5
- }
6
- export { useMessageContext };