listpage-next 0.0.169 → 0.0.170
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/HistoryConversation/index.d.ts +3 -9
- package/dist/features/ChatClient/components/HistoryConversation/index.js +20 -73
- package/dist/features/ChatClient/components/HistoryConversation/styles.d.ts +0 -5
- package/dist/features/ChatClient/components/HistoryConversation/styles.js +17 -45
- package/dist/features/ChatClient/ui/Bubble/BubbleList.d.ts +2 -0
- package/dist/features/ChatClient/ui/Bubble/BubbleList.js +22 -15
- package/dist/features/ChatClient/ui/ConversationList/index.d.ts +21 -0
- package/dist/features/ChatClient/ui/ConversationList/index.js +85 -0
- package/dist/features/ChatClient/ui/ConversationList/styles.d.ts +5 -0
- package/dist/features/ChatClient/ui/ConversationList/styles.js +30 -0
- package/dist/features/ChatClient/ui/index.d.ts +1 -0
- package/dist/features/ChatClient/ui/index.js +1 -0
- package/package.json +1 -2
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
export interface HistoryConversationProps
|
|
1
|
+
export interface HistoryConversationProps {
|
|
2
2
|
rowKey?: string;
|
|
3
|
-
|
|
3
|
+
defaultActiveKey?: string;
|
|
4
4
|
}
|
|
5
|
-
export declare const HistoryConversation:
|
|
6
|
-
type ItemData = {
|
|
7
|
-
icon?: React.ReactNode;
|
|
8
|
-
title: string;
|
|
9
|
-
key: string;
|
|
10
|
-
};
|
|
11
|
-
export {};
|
|
5
|
+
export declare const HistoryConversation: (props: HistoryConversationProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,87 +1,34 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useRef } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { Button, Tooltip } from "antd";
|
|
4
4
|
import { useHover } from "ahooks";
|
|
5
|
-
import { ClockCircleOutlined
|
|
6
|
-
import { InfiniteList } from "../../../../components/InfiniteList/index.js";
|
|
5
|
+
import { ClockCircleOutlined } from "@ant-design/icons";
|
|
7
6
|
import { useChatClientContext } from "../../context/index.js";
|
|
8
|
-
import {
|
|
7
|
+
import { ConversationList } from "../../ui/ConversationList/index.js";
|
|
8
|
+
import { HeaderContainer, HeaderTitle, HistoryConversationContainer } from "./styles.js";
|
|
9
9
|
const HistoryConversation = (props)=>{
|
|
10
|
-
const { rowKey =
|
|
10
|
+
const { rowKey = 'id', defaultActiveKey } = props;
|
|
11
11
|
const { showUpdateTitleModal, conversationListRef, action, request } = useChatClientContext();
|
|
12
12
|
const { onClickConversation, onRenameConversation, onDeleteConversation } = action ?? {};
|
|
13
13
|
return /*#__PURE__*/ jsxs(HistoryConversationContainer, {
|
|
14
14
|
children: [
|
|
15
15
|
/*#__PURE__*/ jsx(Header, {}),
|
|
16
|
-
/*#__PURE__*/ jsx(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const newItem = {
|
|
31
|
-
...item,
|
|
32
|
-
title: newTitle
|
|
33
|
-
};
|
|
34
|
-
await onRenameConversation?.(key, newItem);
|
|
35
|
-
actions.updateItem(key, newItem);
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
key: 'delete',
|
|
41
|
-
danger: true,
|
|
42
|
-
label: '删除',
|
|
43
|
-
onClick: async ()=>{
|
|
44
|
-
await onDeleteConversation?.(key, item);
|
|
45
|
-
actions.deleteItem(key);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
];
|
|
49
|
-
return /*#__PURE__*/ jsxs(ListItemContainer, {
|
|
50
|
-
isHover: activeKey === key ? true : void 0,
|
|
51
|
-
onClick: ()=>onClickConversation?.(key, item),
|
|
52
|
-
children: [
|
|
53
|
-
/*#__PURE__*/ jsx(Avatar, {
|
|
54
|
-
size: 20,
|
|
55
|
-
icon: item.icon || /*#__PURE__*/ jsx(MessageOutlined, {})
|
|
56
|
-
}),
|
|
57
|
-
/*#__PURE__*/ jsx(ListText, {
|
|
58
|
-
children: /*#__PURE__*/ jsx(Typography.Text, {
|
|
59
|
-
ellipsis: {
|
|
60
|
-
tooltip: {
|
|
61
|
-
title: item.title,
|
|
62
|
-
placement: 'right'
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
children: item.title
|
|
66
|
-
})
|
|
67
|
-
}),
|
|
68
|
-
/*#__PURE__*/ jsx("div", {
|
|
69
|
-
onClick: (e)=>e.stopPropagation(),
|
|
70
|
-
children: /*#__PURE__*/ jsx(Dropdown, {
|
|
71
|
-
menu: {
|
|
72
|
-
items
|
|
73
|
-
},
|
|
74
|
-
children: /*#__PURE__*/ jsx(Button, {
|
|
75
|
-
type: "text",
|
|
76
|
-
size: "small",
|
|
77
|
-
icon: /*#__PURE__*/ jsx(MoreOutlined, {})
|
|
78
|
-
})
|
|
79
|
-
})
|
|
80
|
-
})
|
|
81
|
-
]
|
|
16
|
+
/*#__PURE__*/ jsx(ConversationList, {
|
|
17
|
+
rowKey: rowKey,
|
|
18
|
+
defaultActiveKey: defaultActiveKey,
|
|
19
|
+
request: request.getConversations,
|
|
20
|
+
ref: conversationListRef,
|
|
21
|
+
onSelectConversation: (data)=>onClickConversation?.(data[rowKey], data),
|
|
22
|
+
onDeleteConversation: (data)=>{
|
|
23
|
+
onDeleteConversation?.(data[rowKey], data);
|
|
24
|
+
},
|
|
25
|
+
onRenameConversation: (data)=>new Promise((resolve)=>{
|
|
26
|
+
showUpdateTitleModal(data.title, async (newTitle)=>{
|
|
27
|
+
data.title = newTitle;
|
|
28
|
+
await onRenameConversation?.(data[rowKey], data);
|
|
29
|
+
resolve(data);
|
|
82
30
|
});
|
|
83
|
-
}
|
|
84
|
-
})
|
|
31
|
+
})
|
|
85
32
|
})
|
|
86
33
|
]
|
|
87
34
|
});
|
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
export declare const HistoryConversationContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
2
2
|
export declare const HeaderContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
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
|
-
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
|
-
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;
|
|
7
|
-
}>> & string;
|
|
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,52 +1,24 @@
|
|
|
1
1
|
import styled_components from "styled-components";
|
|
2
2
|
const HistoryConversationContainer = styled_components.div`
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
flex: 1;
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
6
|
`;
|
|
7
7
|
const HeaderContainer = styled_components.div`
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
display: flex;
|
|
9
|
+
justify-content: space-between;
|
|
10
|
+
align-items: center;
|
|
11
|
+
padding: 8px 6px;
|
|
12
12
|
`;
|
|
13
13
|
const HeaderTitle = styled_components.div`
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
align-items: center;
|
|
15
|
+
display: flex;
|
|
16
|
+
flex: 1 1;
|
|
17
|
+
font-size: 12px;
|
|
18
|
+
font-weight: 600;
|
|
19
|
+
min-width: 0;
|
|
20
|
+
color: #0000004d;
|
|
21
|
+
line-height: 20px;
|
|
22
|
+
height: 20px;
|
|
23
23
|
`;
|
|
24
|
-
|
|
25
|
-
flex: 1;
|
|
26
|
-
overflow: hidden;
|
|
27
|
-
padding: 0 2px;
|
|
28
|
-
`;
|
|
29
|
-
const ListItemContainer = styled_components.div`
|
|
30
|
-
display: flex;
|
|
31
|
-
align-items: center;
|
|
32
|
-
padding: 8px 4px;
|
|
33
|
-
border-radius: 8px;
|
|
34
|
-
cursor: pointer;
|
|
35
|
-
gap: 4px;
|
|
36
|
-
|
|
37
|
-
background-color: ${(props)=>props.isHover ? "#0000000a" : "transparent"};
|
|
38
|
-
|
|
39
|
-
&:hover {
|
|
40
|
-
background-color: #0000000a;
|
|
41
|
-
}
|
|
42
|
-
`;
|
|
43
|
-
const ListText = styled_components.div`
|
|
44
|
-
flex: 1;
|
|
45
|
-
|
|
46
|
-
overflow: hidden;
|
|
47
|
-
text-overflow: ellipsis;
|
|
48
|
-
white-space: nowrap;
|
|
49
|
-
word-break: break-all;
|
|
50
|
-
word-wrap: break-word;
|
|
51
|
-
`;
|
|
52
|
-
export { HeaderContainer, HeaderTitle, HistoryConversationContainer, ListContainer, ListItemContainer, ListText };
|
|
24
|
+
export { HeaderContainer, HeaderTitle, HistoryConversationContainer };
|
|
@@ -2,9 +2,11 @@ import { CSSProperties } from 'react';
|
|
|
2
2
|
import { BaseMessageInfo, Message } from '../../context';
|
|
3
3
|
export interface BubbleListProps<MessageInfo extends BaseMessageInfo> {
|
|
4
4
|
styles?: {
|
|
5
|
+
headerPlaceholder?: CSSProperties;
|
|
5
6
|
bottomPlaceholder?: CSSProperties;
|
|
6
7
|
content?: CSSProperties;
|
|
7
8
|
};
|
|
9
|
+
loading?: boolean;
|
|
8
10
|
messages: Message<MessageInfo>[];
|
|
9
11
|
messageRender: (message: Message<MessageInfo>) => React.ReactNode;
|
|
10
12
|
}
|
|
@@ -1,24 +1,31 @@
|
|
|
1
|
-
import { jsx
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useRef } from "react";
|
|
3
3
|
import { styled } from "styled-components";
|
|
4
|
+
import { PageLoading } from "../../../../components/Page/index.js";
|
|
4
5
|
const BubbleList = (props)=>{
|
|
5
|
-
const { styles, messages, messageRender } = props;
|
|
6
|
+
const { loading, styles, messages, messageRender } = props;
|
|
6
7
|
const bottomRef = useRef(null);
|
|
7
8
|
const containerRef = useRef(null);
|
|
8
|
-
|
|
9
|
+
const content = [
|
|
10
|
+
/*#__PURE__*/ jsx("div", {
|
|
11
|
+
style: styles?.headerPlaceholder ?? {
|
|
12
|
+
height: 4
|
|
13
|
+
}
|
|
14
|
+
}, "header"),
|
|
15
|
+
/*#__PURE__*/ jsx("div", {
|
|
16
|
+
style: styles?.content,
|
|
17
|
+
children: (messages ?? []).map(messageRender)
|
|
18
|
+
}, "content"),
|
|
19
|
+
/*#__PURE__*/ jsx("div", {
|
|
20
|
+
ref: bottomRef,
|
|
21
|
+
style: styles?.bottomPlaceholder ?? {
|
|
22
|
+
height: 60
|
|
23
|
+
}
|
|
24
|
+
}, "footer")
|
|
25
|
+
];
|
|
26
|
+
return /*#__PURE__*/ jsx(ContentContainer, {
|
|
9
27
|
ref: containerRef,
|
|
10
|
-
children:
|
|
11
|
-
/*#__PURE__*/ jsx("div", {
|
|
12
|
-
style: styles?.content,
|
|
13
|
-
children: (messages ?? []).map(messageRender)
|
|
14
|
-
}),
|
|
15
|
-
/*#__PURE__*/ jsx("div", {
|
|
16
|
-
ref: bottomRef,
|
|
17
|
-
style: styles?.bottomPlaceholder ?? {
|
|
18
|
-
height: 60
|
|
19
|
-
}
|
|
20
|
-
})
|
|
21
|
-
]
|
|
28
|
+
children: loading ? /*#__PURE__*/ jsx(PageLoading, {}) : content
|
|
22
29
|
});
|
|
23
30
|
};
|
|
24
31
|
const ContentContainer = styled.div`
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ItemType } from 'antd/es/menu/interface';
|
|
2
|
+
import { InfiniteListProps, InfiniteListRef, RenderActions } from '../../../../components/InfiniteList';
|
|
3
|
+
export interface ConverstionListProps<T = any> {
|
|
4
|
+
rowKey: string;
|
|
5
|
+
ref?: InfiniteListRef<T>;
|
|
6
|
+
defaultActiveKey?: string;
|
|
7
|
+
request: InfiniteListProps<T>['request'];
|
|
8
|
+
menus?: (Omit<ItemType, 'onClick'> & {
|
|
9
|
+
onClick?: (item: T, index: number, actions: RenderActions<Record<string, any>>) => void;
|
|
10
|
+
})[];
|
|
11
|
+
onSelectConversation?: (data: T) => void;
|
|
12
|
+
onDeleteConversation?: (data: T) => void;
|
|
13
|
+
onRenameConversation?: (data: T) => T;
|
|
14
|
+
}
|
|
15
|
+
type ItemData = {
|
|
16
|
+
icon?: React.ReactNode;
|
|
17
|
+
title: string;
|
|
18
|
+
key: string;
|
|
19
|
+
};
|
|
20
|
+
export declare const ConversationList: <T extends ItemData = any>(props: ConverstionListProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { Avatar, Button, Dropdown, Typography } from "antd";
|
|
4
|
+
import { ListContainer, ListItemContainer, ListText } from "./styles.js";
|
|
5
|
+
import { MessageOutlined, MoreOutlined } from "@ant-design/icons";
|
|
6
|
+
import { InfiniteList } from "../../../../components/InfiniteList/index.js";
|
|
7
|
+
const ConversationList = (props)=>{
|
|
8
|
+
const { ref, rowKey, request, menus = [], defaultActiveKey, onSelectConversation, onDeleteConversation, onRenameConversation } = props;
|
|
9
|
+
const [activeKey, setActiveKey] = useState(defaultActiveKey);
|
|
10
|
+
return /*#__PURE__*/ jsx(ListContainer, {
|
|
11
|
+
children: /*#__PURE__*/ jsx(InfiniteList, {
|
|
12
|
+
pageSize: 10,
|
|
13
|
+
rowKey: rowKey,
|
|
14
|
+
ref: ref,
|
|
15
|
+
request: request,
|
|
16
|
+
renderItem: (item, index, actions)=>{
|
|
17
|
+
const key = item[rowKey];
|
|
18
|
+
const items = [
|
|
19
|
+
...menus.map((menu)=>({
|
|
20
|
+
...menu,
|
|
21
|
+
onClick: ()=>menu.onClick?.(item, index, actions)
|
|
22
|
+
})),
|
|
23
|
+
onRenameConversation && {
|
|
24
|
+
key: 'rename',
|
|
25
|
+
label: '重命名',
|
|
26
|
+
onClick: async ()=>{
|
|
27
|
+
const newItem = await onRenameConversation?.(item);
|
|
28
|
+
if (!newItem) return;
|
|
29
|
+
actions.updateItem(key, newItem);
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
onDeleteConversation && {
|
|
33
|
+
key: 'delete',
|
|
34
|
+
danger: true,
|
|
35
|
+
label: '删除',
|
|
36
|
+
onClick: async ()=>{
|
|
37
|
+
await onDeleteConversation?.(item);
|
|
38
|
+
setActiveKey('');
|
|
39
|
+
actions.deleteItem(key);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
].filter(Boolean);
|
|
43
|
+
return /*#__PURE__*/ jsxs(ListItemContainer, {
|
|
44
|
+
isHover: activeKey === key ? true : void 0,
|
|
45
|
+
onClick: ()=>{
|
|
46
|
+
if (activeKey === key) return;
|
|
47
|
+
setActiveKey?.(key);
|
|
48
|
+
onSelectConversation?.(item);
|
|
49
|
+
},
|
|
50
|
+
children: [
|
|
51
|
+
/*#__PURE__*/ jsx(Avatar, {
|
|
52
|
+
size: 20,
|
|
53
|
+
icon: item.icon || /*#__PURE__*/ jsx(MessageOutlined, {})
|
|
54
|
+
}),
|
|
55
|
+
/*#__PURE__*/ jsx(ListText, {
|
|
56
|
+
children: /*#__PURE__*/ jsx(Typography.Text, {
|
|
57
|
+
ellipsis: {
|
|
58
|
+
tooltip: {
|
|
59
|
+
title: item.title,
|
|
60
|
+
placement: 'right'
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
children: item.title
|
|
64
|
+
})
|
|
65
|
+
}),
|
|
66
|
+
/*#__PURE__*/ jsx("div", {
|
|
67
|
+
onClick: (e)=>e.stopPropagation(),
|
|
68
|
+
children: /*#__PURE__*/ jsx(Dropdown, {
|
|
69
|
+
menu: {
|
|
70
|
+
items
|
|
71
|
+
},
|
|
72
|
+
children: /*#__PURE__*/ jsx(Button, {
|
|
73
|
+
type: "text",
|
|
74
|
+
size: "small",
|
|
75
|
+
icon: /*#__PURE__*/ jsx(MoreOutlined, {})
|
|
76
|
+
})
|
|
77
|
+
})
|
|
78
|
+
})
|
|
79
|
+
]
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
export { ConversationList };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
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;
|
|
2
|
+
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>, {
|
|
3
|
+
isHover?: boolean;
|
|
4
|
+
}>> & string;
|
|
5
|
+
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;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import styled_components from "styled-components";
|
|
2
|
+
const ListContainer = styled_components.div`
|
|
3
|
+
flex: 1;
|
|
4
|
+
overflow: hidden;
|
|
5
|
+
padding: 0 2px;
|
|
6
|
+
`;
|
|
7
|
+
const ListItemContainer = styled_components.div`
|
|
8
|
+
display: flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
padding: 8px 4px;
|
|
11
|
+
border-radius: 8px;
|
|
12
|
+
cursor: pointer;
|
|
13
|
+
gap: 4px;
|
|
14
|
+
|
|
15
|
+
background-color: ${(props)=>props.isHover ? '#0000000a' : 'transparent'};
|
|
16
|
+
|
|
17
|
+
&:hover {
|
|
18
|
+
background-color: #0000000a;
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
21
|
+
const ListText = styled_components.div`
|
|
22
|
+
flex: 1;
|
|
23
|
+
|
|
24
|
+
overflow: hidden;
|
|
25
|
+
text-overflow: ellipsis;
|
|
26
|
+
white-space: nowrap;
|
|
27
|
+
word-break: break-all;
|
|
28
|
+
word-wrap: break-word;
|
|
29
|
+
`;
|
|
30
|
+
export { ListContainer, ListItemContainer, ListText };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "listpage-next",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.170",
|
|
4
4
|
"description": "A React component library for creating filter forms with Ant Design",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -68,7 +68,6 @@
|
|
|
68
68
|
"rc-virtual-list": "~3.19.2",
|
|
69
69
|
"react-draggable": "~4.5.0",
|
|
70
70
|
"markdown-it": "~14.1.0",
|
|
71
|
-
"@douyinfe/semi-ui": "~2.88.0",
|
|
72
71
|
"@tiptap/react": "~3.10.7",
|
|
73
72
|
"@tiptap/extension-document": "~3.10.7",
|
|
74
73
|
"@tiptap/extension-text": "~3.10.7",
|