@lobehub/ui 1.158.1 → 1.160.0
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/es/A/index.js +2 -2
- package/es/ActionIcon/index.js +15 -11
- package/es/ActionIconGroup/index.js +47 -45
- package/es/Alert/index.js +50 -43
- package/es/Avatar/index.js +12 -10
- package/es/Burger/index.js +35 -30
- package/es/CodeEditor/index.js +43 -38
- package/es/Collapse/index.js +3 -3
- package/es/ColorScales/ScaleRow.js +43 -39
- package/es/ColorScales/index.js +59 -57
- package/es/ConfigProvider/index.js +5 -3
- package/es/ContextMenu/index.js +3 -2
- package/es/CopyButton/index.js +4 -3
- package/es/DraggablePanel/components/DraggablePanelBody.js +3 -2
- package/es/DraggablePanel/components/DraggablePanelContainer.js +3 -2
- package/es/DraggablePanel/components/DraggablePanelFooter.js +3 -2
- package/es/DraggablePanel/components/DraggablePanelHeader.js +9 -5
- package/es/DraggablePanel/index.js +32 -25
- package/es/EditableText/index.js +16 -13
- package/es/EmojiPicker/AvatarUploader.js +71 -60
- package/es/EmojiPicker/index.js +110 -101
- package/es/EmptyCard/index.js +31 -23
- package/es/FileTypeIcon/index.js +55 -44
- package/es/FluentEmoji/index.js +6 -4
- package/es/Footer/index.js +10 -8
- package/es/Form/components/FormDivider.js +2 -2
- package/es/Form/components/FormFlatGroup.js +9 -4
- package/es/Form/components/FormFooter.js +6 -3
- package/es/Form/components/FormGroup.js +21 -15
- package/es/Form/components/FormItem.js +17 -10
- package/es/Form/components/FormTitle.js +23 -15
- package/es/Form/index.js +30 -26
- package/es/FormModal/index.js +34 -30
- package/es/Grid/index.js +6 -3
- package/es/Header/index.js +65 -49
- package/es/Highlighter/FullFeatured.js +51 -41
- package/es/Highlighter/SyntaxHighlighter/index.js +30 -19
- package/es/Highlighter/index.js +29 -19
- package/es/Icon/icons/DiscordIcon.js +3 -2
- package/es/Icon/index.js +16 -13
- package/es/Image/ImageGallery.js +5 -3
- package/es/Image/Preview.js +5 -3
- package/es/Image/index.js +38 -34
- package/es/Image/usePreview.js +37 -33
- package/es/Img/index.js +2 -2
- package/es/Input/index.js +3 -3
- package/es/Layout/index.js +63 -35
- package/es/List/ListItem/index.js +67 -53
- package/es/Markdown/CodeBlock.js +16 -10
- package/es/Markdown/Typography.js +6 -3
- package/es/Markdown/index.js +22 -18
- package/es/MaterialFileTypeIcon/index.js +20 -17
- package/es/MaterialFileTypeIcon/utils.d.ts +2 -2
- package/es/Mermaid/FullFeatured.js +45 -35
- package/es/Mermaid/index.js +26 -17
- package/es/Mermaid/useMermaid.d.ts +1 -2
- package/es/Mermaid/useMermaid.js +5 -3
- package/es/Modal/index.js +60 -48
- package/es/SearchBar/index.js +51 -47
- package/es/SelectWithImg/index.js +40 -34
- package/es/SideNav/index.js +22 -15
- package/es/SliderWithInput/index.js +38 -35
- package/es/Snippet/index.js +15 -10
- package/es/SortableList/DragHandle.js +3 -3
- package/es/SortableList/SortableItem.js +19 -16
- package/es/SortableList/SortableOverlay.js +5 -3
- package/es/SortableList/index.js +23 -15
- package/es/Swatches/index.js +20 -18
- package/es/TabsNav/index.js +3 -2
- package/es/Tag/index.js +12 -7
- package/es/ThemeProvider/Meta.js +58 -53
- package/es/ThemeProvider/index.js +23 -17
- package/es/ThemeSwitch/index.js +19 -15
- package/es/Toc/TocMobile.js +52 -47
- package/es/Toc/index.js +13 -8
- package/es/Tooltip/index.js +3 -2
- package/es/Video/index.js +47 -41
- package/es/awesome/AuroraBackground/index.js +18 -11
- package/es/awesome/Features/Item.js +45 -37
- package/es/awesome/Features/index.js +4 -5
- package/es/awesome/GaussianBackground/index.js +13 -8
- package/es/awesome/Giscus/index.js +15 -13
- package/es/awesome/GradientButton/index.js +9 -5
- package/es/awesome/GridBackground/Grid.js +61 -49
- package/es/awesome/GridBackground/GridShowcase.js +28 -24
- package/es/awesome/GridBackground/index.js +33 -27
- package/es/awesome/Hero/index.js +74 -63
- package/es/awesome/Spline/ParentSize.js +8 -7
- package/es/awesome/Spline/index.js +13 -10
- package/es/awesome/Spotlight/index.js +3 -2
- package/es/awesome/SpotlightCard/SpotlightCardItem.js +8 -5
- package/es/awesome/SpotlightCard/index.js +12 -9
- package/es/brand/BrandLoading/index.js +3 -2
- package/es/brand/LobeChat/index.js +38 -29
- package/es/brand/LobeChatText/index.js +13 -8
- package/es/brand/LobeHub/index.js +38 -29
- package/es/brand/LobeHubText/index.js +9 -4
- package/es/brand/Logo3d/index.js +3 -2
- package/es/brand/LogoFlat/index.js +49 -44
- package/es/brand/LogoMono/index.js +53 -48
- package/es/brand/LogoThree/Loading.js +11 -9
- package/es/brand/LogoThree/LogoSpline.js +12 -10
- package/es/brand/LogoThree/index.js +25 -23
- package/es/brand/components/Divider.js +6 -4
- package/es/chat/BackBottom/index.js +6 -4
- package/es/chat/ChatHeader/ChatHeaderTitle.js +31 -22
- package/es/chat/ChatHeader/index.js +42 -35
- package/es/chat/ChatInputArea/ChatInputActionBar.js +21 -16
- package/es/chat/ChatInputArea/ChatInputArea.js +23 -19
- package/es/chat/ChatInputArea/ChatInputAreaInner.js +3 -2
- package/es/chat/ChatInputArea/SendButton.js +51 -36
- package/es/chat/ChatItem/components/Actions.js +5 -3
- package/es/chat/ChatItem/components/Avatar.js +21 -17
- package/es/chat/ChatItem/components/BorderSpacing.js +2 -1
- package/es/chat/ChatItem/components/ErrorContent.js +11 -9
- package/es/chat/ChatItem/components/Loading.js +12 -10
- package/es/chat/ChatItem/components/MessageContent.js +10 -6
- package/es/chat/ChatItem/components/Title.js +8 -3
- package/es/chat/ChatItem/index.js +53 -47
- package/es/chat/ChatList/ActionsBar.js +3 -2
- package/es/chat/ChatList/HistoryDivider.js +11 -6
- package/es/chat/ChatList/Item.js +12 -14
- package/es/chat/ChatList/index.js +29 -25
- package/es/chat/EditableMessage/index.js +32 -26
- package/es/chat/EditableMessageList/index.js +76 -72
- package/es/chat/MessageInput/index.js +43 -35
- package/es/chat/MessageModal/index.js +51 -41
- package/es/chat/TokenTag/index.js +11 -7
- package/es/components/ControlInput.js +22 -18
- package/es/hooks/useHighlight.d.ts +1 -1
- package/es/mdx/Callout/index.js +19 -13
- package/es/mdx/Cards/Card.js +59 -46
- package/es/mdx/Cards/index.js +6 -3
- package/es/mdx/FileTree/File.js +11 -5
- package/es/mdx/FileTree/Folder.js +22 -13
- package/es/mdx/FileTree/index.js +6 -3
- package/es/mdx/Mdx/index.js +9 -7
- package/es/mdx/Steps/index.js +6 -3
- package/es/mdx/Tabs/Tab.js +8 -3
- package/es/mdx/Tabs/index.js +21 -17
- package/es/mdx/mdxComponents/CodeBlock.js +14 -9
- package/es/mdx/mdxComponents/Image.js +2 -2
- package/es/mdx/mdxComponents/Link.js +3 -2
- package/es/mdx/mdxComponents/Pre.js +14 -7
- package/es/mdx/mdxComponents/Video.js +2 -2
- package/es/mobile/MobileChatInputArea/SendButton.js +4 -3
- package/es/mobile/MobileChatInputArea/index.js +79 -69
- package/es/mobile/MobileNavBar/MobileNavBarTitle.js +37 -26
- package/es/mobile/MobileNavBar/index.js +48 -41
- package/es/mobile/MobileSafeArea/index.js +3 -2
- package/es/mobile/MobileTabBar/index.js +35 -29
- package/es/storybook/StoryBook/index.js +26 -19
- package/package.json +1 -90
|
@@ -3,6 +3,8 @@ import { memo } from 'react';
|
|
|
3
3
|
import { Flexbox } from 'react-layout-kit';
|
|
4
4
|
import EditableMessage from "../../EditableMessage";
|
|
5
5
|
import { useStyles } from "../style";
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
8
|
var MessageContent = /*#__PURE__*/memo(function (_ref) {
|
|
7
9
|
var editing = _ref.editing,
|
|
8
10
|
onChange = _ref.onChange,
|
|
@@ -27,7 +29,7 @@ var MessageContent = /*#__PURE__*/memo(function (_ref) {
|
|
|
27
29
|
styles = _useStyles.styles;
|
|
28
30
|
var _useResponsive = useResponsive(),
|
|
29
31
|
mobile = _useResponsive.mobile;
|
|
30
|
-
var content = /*#__PURE__*/
|
|
32
|
+
var content = /*#__PURE__*/_jsx(EditableMessage, {
|
|
31
33
|
classNames: {
|
|
32
34
|
input: styles.editingInput
|
|
33
35
|
},
|
|
@@ -43,11 +45,13 @@ var MessageContent = /*#__PURE__*/memo(function (_ref) {
|
|
|
43
45
|
value: message ? String(message) : ''
|
|
44
46
|
});
|
|
45
47
|
var messageContent = renderMessage ? renderMessage(content) : content;
|
|
46
|
-
return /*#__PURE__*/
|
|
48
|
+
return /*#__PURE__*/_jsxs(Flexbox, {
|
|
47
49
|
className: cx(styles.message, editing && styles.editingContainer),
|
|
48
|
-
onDoubleClick: onDoubleClick
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
onDoubleClick: onDoubleClick,
|
|
51
|
+
children: [messageContent, messageExtra && !editing ? /*#__PURE__*/_jsx("div", {
|
|
52
|
+
className: styles.messageExtra,
|
|
53
|
+
children: messageExtra
|
|
54
|
+
}) : null]
|
|
55
|
+
});
|
|
52
56
|
});
|
|
53
57
|
export default MessageContent;
|
|
@@ -2,6 +2,8 @@ import { memo } from 'react';
|
|
|
2
2
|
import { Flexbox } from 'react-layout-kit';
|
|
3
3
|
import { formatTime } from "../../../utils/formatTime";
|
|
4
4
|
import { useStyles } from "../style";
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
7
|
var Title = /*#__PURE__*/memo(function (_ref) {
|
|
6
8
|
var showTitle = _ref.showTitle,
|
|
7
9
|
placement = _ref.placement,
|
|
@@ -13,10 +15,13 @@ var Title = /*#__PURE__*/memo(function (_ref) {
|
|
|
13
15
|
time: time
|
|
14
16
|
}),
|
|
15
17
|
styles = _useStyles.styles;
|
|
16
|
-
return /*#__PURE__*/
|
|
18
|
+
return /*#__PURE__*/_jsxs(Flexbox, {
|
|
17
19
|
className: styles.name,
|
|
18
20
|
direction: placement === 'left' ? 'horizontal' : 'horizontal-reverse',
|
|
19
|
-
gap: 4
|
|
20
|
-
|
|
21
|
+
gap: 4,
|
|
22
|
+
children: [showTitle ? avatar.title || 'untitled' : undefined, time && /*#__PURE__*/_jsx("time", {
|
|
23
|
+
children: formatTime(time)
|
|
24
|
+
})]
|
|
25
|
+
});
|
|
21
26
|
});
|
|
22
27
|
export default Title;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
5
|
var _excluded = ["avatarAddon", "onAvatarClick", "avatarProps", "actions", "className", "primary", "loading", "message", "placement", "type", "avatar", "error", "showTitle", "time", "editing", "onChange", "onEditingChange", "messageExtra", "renderMessage", "text", "errorMessage", "onDoubleClick", "fontSize", "aboveMessage", "belowMessage", "markdownProps"];
|
|
6
6
|
import { useResponsive } from 'antd-style';
|
|
@@ -13,6 +13,8 @@ import ErrorContent from "./components/ErrorContent";
|
|
|
13
13
|
import MessageContent from "./components/MessageContent";
|
|
14
14
|
import Title from "./components/Title";
|
|
15
15
|
import { useStyles } from "./style";
|
|
16
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
18
|
var MOBILE_AVATAR_SIZE = 32;
|
|
17
19
|
var ChatItem = /*#__PURE__*/memo(function (_ref) {
|
|
18
20
|
var avatarAddon = _ref.avatarAddon,
|
|
@@ -57,55 +59,59 @@ var ChatItem = /*#__PURE__*/memo(function (_ref) {
|
|
|
57
59
|
}),
|
|
58
60
|
cx = _useStyles.cx,
|
|
59
61
|
styles = _useStyles.styles;
|
|
60
|
-
return /*#__PURE__*/
|
|
62
|
+
return /*#__PURE__*/_jsxs(Flexbox, _objectSpread(_objectSpread({
|
|
61
63
|
className: cx(styles.container, className),
|
|
62
64
|
direction: placement === 'left' ? 'horizontal' : 'horizontal-reverse',
|
|
63
65
|
gap: mobile ? 6 : 12
|
|
64
|
-
}, rest),
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
66
|
+
}, rest), {}, {
|
|
67
|
+
children: [/*#__PURE__*/_jsx(Avatar, _objectSpread(_objectSpread({}, avatarProps), {}, {
|
|
68
|
+
addon: avatarAddon,
|
|
69
|
+
avatar: avatar,
|
|
70
|
+
loading: loading,
|
|
71
|
+
onClick: onAvatarClick,
|
|
72
|
+
placement: placement,
|
|
73
|
+
size: mobile ? MOBILE_AVATAR_SIZE : undefined
|
|
74
|
+
})), /*#__PURE__*/_jsxs(Flexbox, {
|
|
75
|
+
align: placement === 'left' ? 'flex-start' : 'flex-end',
|
|
76
|
+
className: styles.messageContainer,
|
|
77
|
+
children: [/*#__PURE__*/_jsx(Title, {
|
|
78
|
+
avatar: avatar,
|
|
79
|
+
placement: placement,
|
|
80
|
+
showTitle: showTitle,
|
|
81
|
+
time: time
|
|
82
|
+
}), aboveMessage, /*#__PURE__*/_jsxs(Flexbox, {
|
|
83
|
+
align: placement === 'left' ? 'flex-start' : 'flex-end',
|
|
84
|
+
className: styles.messageContent,
|
|
85
|
+
direction: type === 'block' ? placement === 'left' ? 'horizontal' : 'horizontal-reverse' : 'vertical',
|
|
86
|
+
gap: 8,
|
|
87
|
+
children: [error ? /*#__PURE__*/_jsx(ErrorContent, {
|
|
88
|
+
error: error,
|
|
89
|
+
message: errorMessage,
|
|
90
|
+
placement: placement
|
|
91
|
+
}) : /*#__PURE__*/_jsx(MessageContent, {
|
|
92
|
+
editing: editing,
|
|
93
|
+
fontSize: fontSize,
|
|
94
|
+
markdownProps: markdownProps,
|
|
95
|
+
message: message,
|
|
96
|
+
messageExtra: messageExtra,
|
|
97
|
+
onChange: onChange,
|
|
98
|
+
onDoubleClick: onDoubleClick,
|
|
99
|
+
onEditingChange: onEditingChange,
|
|
100
|
+
placement: placement,
|
|
101
|
+
primary: primary,
|
|
102
|
+
renderMessage: renderMessage,
|
|
103
|
+
text: text,
|
|
104
|
+
type: type
|
|
105
|
+
}), /*#__PURE__*/_jsx(Actions, {
|
|
106
|
+
actions: actions,
|
|
107
|
+
editing: editing,
|
|
108
|
+
placement: placement,
|
|
109
|
+
type: type
|
|
110
|
+
})]
|
|
111
|
+
}), belowMessage]
|
|
112
|
+
}), mobile && type === 'block' && /*#__PURE__*/_jsx(BorderSpacing, {
|
|
113
|
+
borderSpacing: MOBILE_AVATAR_SIZE
|
|
114
|
+
})]
|
|
109
115
|
}));
|
|
110
116
|
});
|
|
111
117
|
export default ChatItem;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
3
|
var _excluded = ["text"];
|
|
4
4
|
import { memo } from 'react';
|
|
5
5
|
import ActionIconGroup from "../../ActionIconGroup";
|
|
6
6
|
import { useChatListActionsBar } from "../../hooks/useChatListActionsBar";
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
8
|
var ActionsBar = /*#__PURE__*/memo(function (_ref) {
|
|
8
9
|
var text = _ref.text,
|
|
9
10
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
@@ -13,7 +14,7 @@ var ActionsBar = /*#__PURE__*/memo(function (_ref) {
|
|
|
13
14
|
copy = _useChatListActionsBa.copy,
|
|
14
15
|
divider = _useChatListActionsBa.divider,
|
|
15
16
|
del = _useChatListActionsBa.del;
|
|
16
|
-
return /*#__PURE__*/
|
|
17
|
+
return /*#__PURE__*/_jsx(ActionIconGroup, _objectSpread({
|
|
17
18
|
dropdownMenu: [edit, copy, regenerate, divider, del],
|
|
18
19
|
items: [regenerate, edit],
|
|
19
20
|
type: "ghost"
|
|
@@ -3,18 +3,23 @@ import { Timer } from 'lucide-react';
|
|
|
3
3
|
import { memo } from 'react';
|
|
4
4
|
import Icon from "../../Icon";
|
|
5
5
|
import Tag from "../../Tag";
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
7
|
var HistoryDivider = /*#__PURE__*/memo(function (_ref) {
|
|
7
8
|
var enable = _ref.enable,
|
|
8
9
|
text = _ref.text;
|
|
9
10
|
if (!enable) return null;
|
|
10
|
-
return /*#__PURE__*/
|
|
11
|
+
return /*#__PURE__*/_jsx("div", {
|
|
11
12
|
style: {
|
|
12
13
|
padding: '0 20px'
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
},
|
|
15
|
+
children: /*#__PURE__*/_jsx(Divider, {
|
|
16
|
+
children: /*#__PURE__*/_jsx(Tag, {
|
|
17
|
+
icon: /*#__PURE__*/_jsx(Icon, {
|
|
18
|
+
icon: Timer
|
|
19
|
+
}),
|
|
20
|
+
children: text || 'History Message'
|
|
21
|
+
})
|
|
17
22
|
})
|
|
18
|
-
}
|
|
23
|
+
});
|
|
19
24
|
});
|
|
20
25
|
export default HistoryDivider;
|
package/es/chat/ChatList/Item.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
1
|
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
3
2
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
|
-
import
|
|
3
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
5
4
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
6
5
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
7
6
|
var _excluded = ["renderMessagesExtra", "showTitle", "onActionsClick", "onAvatarsClick", "onMessageChange", "type", "text", "renderMessages", "renderErrorMessages", "renderActions", "loading", "groupNav", "renderItems"];
|
|
@@ -10,6 +9,7 @@ import { memo, useCallback, useMemo, useState } from 'react';
|
|
|
10
9
|
import ChatItem from "../ChatItem";
|
|
11
10
|
import { copyToClipboard } from "../../utils/copyToClipboard";
|
|
12
11
|
import ActionsBar from "./ActionsBar";
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
var Item = /*#__PURE__*/memo(function (props) {
|
|
14
14
|
var renderMessagesExtra = props.renderMessagesExtra,
|
|
15
15
|
showTitle = props.showTitle,
|
|
@@ -47,7 +47,7 @@ var Item = /*#__PURE__*/memo(function (props) {
|
|
|
47
47
|
if (renderMessages !== null && renderMessages !== void 0 && renderMessages[item.role]) RenderFunction = renderMessages[item.role];
|
|
48
48
|
if (!RenderFunction && renderMessages !== null && renderMessages !== void 0 && renderMessages['default']) RenderFunction = renderMessages['default'];
|
|
49
49
|
if (!RenderFunction) return;
|
|
50
|
-
return /*#__PURE__*/
|
|
50
|
+
return /*#__PURE__*/_jsx(RenderFunction, _objectSpread(_objectSpread({}, data), {}, {
|
|
51
51
|
editableContent: editableContent
|
|
52
52
|
}));
|
|
53
53
|
}, [renderMessages === null || renderMessages === void 0 ? void 0 : renderMessages[item.role]]);
|
|
@@ -58,7 +58,7 @@ var Item = /*#__PURE__*/memo(function (props) {
|
|
|
58
58
|
if (renderMessagesExtra !== null && renderMessagesExtra !== void 0 && renderMessagesExtra[item.role]) RenderFunction = renderMessagesExtra[item.role];
|
|
59
59
|
if (renderMessagesExtra !== null && renderMessagesExtra !== void 0 && renderMessagesExtra['default']) RenderFunction = renderMessagesExtra['default'];
|
|
60
60
|
if (!RenderFunction) return;
|
|
61
|
-
return /*#__PURE__*/
|
|
61
|
+
return /*#__PURE__*/_jsx(RenderFunction, _objectSpread({}, data));
|
|
62
62
|
}, [renderMessagesExtra === null || renderMessagesExtra === void 0 ? void 0 : renderMessagesExtra[item.role]]);
|
|
63
63
|
var ErrorMessage = useCallback(function (_ref3) {
|
|
64
64
|
var _item$error;
|
|
@@ -68,7 +68,7 @@ var Item = /*#__PURE__*/memo(function (props) {
|
|
|
68
68
|
if (renderErrorMessages !== null && renderErrorMessages !== void 0 && renderErrorMessages[item.error.type]) RenderFunction = renderErrorMessages[item.error.type].Render;
|
|
69
69
|
if (!RenderFunction && renderErrorMessages !== null && renderErrorMessages !== void 0 && renderErrorMessages['default']) RenderFunction = renderErrorMessages['default'].Render;
|
|
70
70
|
if (!RenderFunction) return;
|
|
71
|
-
return /*#__PURE__*/
|
|
71
|
+
return /*#__PURE__*/_jsx(RenderFunction, _objectSpread({}, data));
|
|
72
72
|
}, [renderErrorMessages]);
|
|
73
73
|
var Actions = useCallback(function (_ref4) {
|
|
74
74
|
var data = _ref4.data;
|
|
@@ -105,7 +105,7 @@ var Item = /*#__PURE__*/memo(function (props) {
|
|
|
105
105
|
return _ref5.apply(this, arguments);
|
|
106
106
|
};
|
|
107
107
|
}();
|
|
108
|
-
return /*#__PURE__*/
|
|
108
|
+
return /*#__PURE__*/_jsx(RenderFunction, _objectSpread(_objectSpread({}, data), {}, {
|
|
109
109
|
onActionClick: function onActionClick(actionKey) {
|
|
110
110
|
return handleActionClick === null || handleActionClick === void 0 ? void 0 : handleActionClick(actionKey, data);
|
|
111
111
|
},
|
|
@@ -125,23 +125,21 @@ var Item = /*#__PURE__*/memo(function (props) {
|
|
|
125
125
|
message: message
|
|
126
126
|
}, alertConfig);
|
|
127
127
|
}, [renderErrorMessages, item.error]);
|
|
128
|
-
if (RenderItem) return /*#__PURE__*/
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return /*#__PURE__*/React.createElement(ChatItem, {
|
|
132
|
-
actions: /*#__PURE__*/React.createElement(Actions, {
|
|
128
|
+
if (RenderItem) return /*#__PURE__*/_jsx(RenderItem, _objectSpread({}, props), item.id);
|
|
129
|
+
return /*#__PURE__*/_jsx(ChatItem, {
|
|
130
|
+
actions: /*#__PURE__*/_jsx(Actions, {
|
|
133
131
|
data: item
|
|
134
132
|
}),
|
|
135
133
|
avatar: item.meta,
|
|
136
134
|
avatarAddon: groupNav,
|
|
137
135
|
editing: editing,
|
|
138
136
|
error: error,
|
|
139
|
-
errorMessage: /*#__PURE__*/
|
|
137
|
+
errorMessage: /*#__PURE__*/_jsx(ErrorMessage, {
|
|
140
138
|
data: item
|
|
141
139
|
}),
|
|
142
140
|
loading: loading,
|
|
143
141
|
message: item.content,
|
|
144
|
-
messageExtra: /*#__PURE__*/
|
|
142
|
+
messageExtra: /*#__PURE__*/_jsx(MessageExtra, {
|
|
145
143
|
data: item
|
|
146
144
|
}),
|
|
147
145
|
onAvatarClick: onAvatarsClick === null || onAvatarsClick === void 0 ? void 0 : onAvatarsClick(item.role),
|
|
@@ -158,7 +156,7 @@ var Item = /*#__PURE__*/memo(function (props) {
|
|
|
158
156
|
placement: type === 'chat' ? item.role === 'user' ? 'right' : 'left' : 'left',
|
|
159
157
|
primary: item.role === 'user',
|
|
160
158
|
renderMessage: function renderMessage(editableContent) {
|
|
161
|
-
return /*#__PURE__*/
|
|
159
|
+
return /*#__PURE__*/_jsx(RenderMessage, {
|
|
162
160
|
data: item,
|
|
163
161
|
editableContent: editableContent
|
|
164
162
|
});
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
5
|
var _excluded = ["onActionsClick", "onAvatarsClick", "renderMessagesExtra", "className", "data", "type", "text", "showTitle", "onMessageChange", "renderMessages", "renderErrorMessages", "loadingId", "renderItems", "enableHistoryCount", "renderActions", "historyCount"];
|
|
6
6
|
import { Fragment, memo } from 'react';
|
|
7
7
|
import HistoryDivider from "./HistoryDivider";
|
|
8
8
|
import Item from "./Item";
|
|
9
9
|
import { useStyles } from "./style";
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
12
|
var ChatList = /*#__PURE__*/memo(function (_ref) {
|
|
11
13
|
var onActionsClick = _ref.onActionsClick,
|
|
12
14
|
onAvatarsClick = _ref.onAvatarsClick,
|
|
@@ -30,31 +32,33 @@ var ChatList = /*#__PURE__*/memo(function (_ref) {
|
|
|
30
32
|
var _useStyles = useStyles(),
|
|
31
33
|
cx = _useStyles.cx,
|
|
32
34
|
styles = _useStyles.styles;
|
|
33
|
-
return /*#__PURE__*/
|
|
35
|
+
return /*#__PURE__*/_jsx("div", _objectSpread(_objectSpread({
|
|
34
36
|
className: cx(styles.container, className)
|
|
35
|
-
}, rest),
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
37
|
+
}, rest), {}, {
|
|
38
|
+
children: data.map(function (item, index) {
|
|
39
|
+
var itemProps = {
|
|
40
|
+
loading: loadingId === item.id,
|
|
41
|
+
onActionsClick: onActionsClick,
|
|
42
|
+
onAvatarsClick: onAvatarsClick,
|
|
43
|
+
onMessageChange: onMessageChange,
|
|
44
|
+
renderActions: renderActions,
|
|
45
|
+
renderErrorMessages: renderErrorMessages,
|
|
46
|
+
renderItems: renderItems,
|
|
47
|
+
renderMessages: renderMessages,
|
|
48
|
+
renderMessagesExtra: renderMessagesExtra,
|
|
49
|
+
showTitle: showTitle,
|
|
50
|
+
text: text,
|
|
51
|
+
type: type
|
|
52
|
+
};
|
|
53
|
+
var historyLength = data.length;
|
|
54
|
+
var enableHistoryDivider = enableHistoryCount && historyLength > historyCount && historyCount === historyLength - index + 1;
|
|
55
|
+
return /*#__PURE__*/_jsxs(Fragment, {
|
|
56
|
+
children: [/*#__PURE__*/_jsx(HistoryDivider, {
|
|
57
|
+
enable: enableHistoryDivider,
|
|
58
|
+
text: text === null || text === void 0 ? void 0 : text.history
|
|
59
|
+
}), /*#__PURE__*/_jsx(Item, _objectSpread(_objectSpread({}, itemProps), item))]
|
|
60
|
+
}, item.id);
|
|
61
|
+
})
|
|
58
62
|
}));
|
|
59
63
|
});
|
|
60
64
|
export default ChatList;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
3
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
5
4
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
6
5
|
import { memo } from 'react';
|
|
@@ -8,6 +7,9 @@ import useControlledState from 'use-merge-value';
|
|
|
8
7
|
import Markdown from "../../Markdown";
|
|
9
8
|
import MessageInput from "../MessageInput";
|
|
10
9
|
import MessageModal from "../MessageModal";
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
12
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
13
|
var EditableMessage = /*#__PURE__*/memo(function (_ref) {
|
|
12
14
|
var value = _ref.value,
|
|
13
15
|
onChange = _ref.onChange,
|
|
@@ -44,7 +46,7 @@ var EditableMessage = /*#__PURE__*/memo(function (_ref) {
|
|
|
44
46
|
expand = _useControlledState4[0],
|
|
45
47
|
setExpand = _useControlledState4[1];
|
|
46
48
|
var isAutoSize = height === 'auto';
|
|
47
|
-
var input = /*#__PURE__*/
|
|
49
|
+
var input = /*#__PURE__*/_jsx(MessageInput, {
|
|
48
50
|
className: classNames === null || classNames === void 0 ? void 0 : classNames.input,
|
|
49
51
|
classNames: {
|
|
50
52
|
textarea: classNames === null || classNames === void 0 ? void 0 : classNames.textarea
|
|
@@ -66,29 +68,33 @@ var EditableMessage = /*#__PURE__*/memo(function (_ref) {
|
|
|
66
68
|
type: inputType
|
|
67
69
|
});
|
|
68
70
|
if (!value && showEditWhenEmpty) return input;
|
|
69
|
-
return /*#__PURE__*/
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
setTyping
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
71
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
72
|
+
children: [!expand && isEdit ? input : /*#__PURE__*/_jsx(Markdown, _objectSpread(_objectSpread({
|
|
73
|
+
className: classNames === null || classNames === void 0 ? void 0 : classNames.markdown,
|
|
74
|
+
fontSize: fontSize,
|
|
75
|
+
fullFeaturedCodeBlock: fullFeaturedCodeBlock,
|
|
76
|
+
style: _objectSpread({
|
|
77
|
+
height: isAutoSize ? 'unset' : height
|
|
78
|
+
}, stylesProps === null || stylesProps === void 0 ? void 0 : stylesProps.markdown),
|
|
79
|
+
variant: 'chat'
|
|
80
|
+
}, markdownProps), {}, {
|
|
81
|
+
children: value || placeholder || ''
|
|
82
|
+
})), expand && /*#__PURE__*/_jsx(MessageModal, {
|
|
83
|
+
editing: isEdit,
|
|
84
|
+
extra: model === null || model === void 0 ? void 0 : model.extra,
|
|
85
|
+
footer: model === null || model === void 0 ? void 0 : model.footer,
|
|
86
|
+
height: height,
|
|
87
|
+
onChange: onChange,
|
|
88
|
+
onEditingChange: setTyping,
|
|
89
|
+
onOpenChange: function onOpenChange(e) {
|
|
90
|
+
setExpand(e);
|
|
91
|
+
setTyping(false);
|
|
92
|
+
},
|
|
93
|
+
open: expand,
|
|
94
|
+
placeholder: placeholder,
|
|
95
|
+
text: text,
|
|
96
|
+
value: value
|
|
97
|
+
})]
|
|
98
|
+
});
|
|
93
99
|
});
|
|
94
100
|
export default EditableMessage;
|
|
@@ -10,6 +10,8 @@ import ActionIcon from "../../ActionIcon";
|
|
|
10
10
|
import Icon from "../../Icon";
|
|
11
11
|
import { ControlInput } from "../../components/ControlInput";
|
|
12
12
|
import { messagesReducer } from "./messageReducer";
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
15
|
export var EditableMessageList = /*#__PURE__*/memo(function (_ref) {
|
|
14
16
|
var disabled = _ref.disabled,
|
|
15
17
|
dataSources = _ref.dataSources,
|
|
@@ -23,82 +25,84 @@ export var EditableMessageList = /*#__PURE__*/memo(function (_ref) {
|
|
|
23
25
|
onChange === null || onChange === void 0 || onChange(chatMessages);
|
|
24
26
|
}
|
|
25
27
|
}, [chatMessages]);
|
|
26
|
-
return dataSources ? /*#__PURE__*/
|
|
27
|
-
gap: 12
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
return dataSources ? /*#__PURE__*/_jsxs(Flexbox, {
|
|
29
|
+
gap: 12,
|
|
30
|
+
children: [chatMessages.map(function (item, index) {
|
|
31
|
+
return /*#__PURE__*/_jsxs(Flexbox, {
|
|
32
|
+
align: 'center',
|
|
33
|
+
gap: 8,
|
|
34
|
+
horizontal: true,
|
|
35
|
+
width: '100%',
|
|
36
|
+
children: [/*#__PURE__*/_jsx(Select, {
|
|
37
|
+
disabled: disabled,
|
|
38
|
+
dropdownStyle: {
|
|
39
|
+
zIndex: 100
|
|
40
|
+
},
|
|
41
|
+
onChange: function onChange(value) {
|
|
42
|
+
dispatch({
|
|
43
|
+
index: index,
|
|
44
|
+
role: value,
|
|
45
|
+
type: 'updateMessageRole'
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
options: [{
|
|
49
|
+
label: 'System',
|
|
50
|
+
value: 'system'
|
|
51
|
+
}, {
|
|
52
|
+
label: 'Input',
|
|
53
|
+
value: 'user'
|
|
54
|
+
}, {
|
|
55
|
+
label: 'Output',
|
|
56
|
+
value: 'assistant'
|
|
57
|
+
}],
|
|
58
|
+
style: {
|
|
59
|
+
width: 120
|
|
60
|
+
},
|
|
61
|
+
value: item.role
|
|
62
|
+
}), /*#__PURE__*/_jsx(ControlInput, {
|
|
63
|
+
disabled: disabled,
|
|
64
|
+
onChange: function onChange(e) {
|
|
65
|
+
dispatch({
|
|
66
|
+
index: index,
|
|
67
|
+
message: e,
|
|
68
|
+
type: 'updateMessage'
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
placeholder: item.role === 'user' ? '请填入输入的样例内容' : '请填入输出的样例',
|
|
72
|
+
value: item.content
|
|
73
|
+
}), /*#__PURE__*/_jsx(ActionIcon, {
|
|
74
|
+
icon: Trash,
|
|
75
|
+
onClick: function onClick() {
|
|
76
|
+
dispatch({
|
|
77
|
+
index: index,
|
|
78
|
+
type: 'deleteMessage'
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
placement: "right",
|
|
82
|
+
size: {
|
|
83
|
+
fontSize: 16
|
|
84
|
+
},
|
|
85
|
+
title: "Delete"
|
|
86
|
+
})]
|
|
87
|
+
}, "".concat(index, "-").concat(item.content));
|
|
88
|
+
}), /*#__PURE__*/_jsx(Button, {
|
|
89
|
+
block: true,
|
|
36
90
|
disabled: disabled,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
},
|
|
40
|
-
onChange: function onChange(value) {
|
|
41
|
-
dispatch({
|
|
42
|
-
index: index,
|
|
43
|
-
role: value,
|
|
44
|
-
type: 'updateMessageRole'
|
|
45
|
-
});
|
|
46
|
-
},
|
|
47
|
-
options: [{
|
|
48
|
-
label: 'System',
|
|
49
|
-
value: 'system'
|
|
50
|
-
}, {
|
|
51
|
-
label: 'Input',
|
|
52
|
-
value: 'user'
|
|
53
|
-
}, {
|
|
54
|
-
label: 'Output',
|
|
55
|
-
value: 'assistant'
|
|
56
|
-
}],
|
|
57
|
-
style: {
|
|
58
|
-
width: 120
|
|
59
|
-
},
|
|
60
|
-
value: item.role
|
|
61
|
-
}), /*#__PURE__*/React.createElement(ControlInput, {
|
|
62
|
-
disabled: disabled,
|
|
63
|
-
onChange: function onChange(e) {
|
|
64
|
-
dispatch({
|
|
65
|
-
index: index,
|
|
66
|
-
message: e,
|
|
67
|
-
type: 'updateMessage'
|
|
68
|
-
});
|
|
69
|
-
},
|
|
70
|
-
placeholder: item.role === 'user' ? '请填入输入的样例内容' : '请填入输出的样例',
|
|
71
|
-
value: item.content
|
|
72
|
-
}), /*#__PURE__*/React.createElement(ActionIcon, {
|
|
73
|
-
icon: Trash,
|
|
91
|
+
icon: /*#__PURE__*/_jsx(Icon, {
|
|
92
|
+
icon: Plus
|
|
93
|
+
}),
|
|
74
94
|
onClick: function onClick() {
|
|
95
|
+
var lastMeg = chatMessages.at(-1);
|
|
75
96
|
dispatch({
|
|
76
|
-
|
|
77
|
-
|
|
97
|
+
message: {
|
|
98
|
+
content: '',
|
|
99
|
+
role: (lastMeg === null || lastMeg === void 0 ? void 0 : lastMeg.role) === 'user' ? 'assistant' : 'user'
|
|
100
|
+
},
|
|
101
|
+
type: 'addMessage'
|
|
78
102
|
});
|
|
79
103
|
},
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
},
|
|
84
|
-
title: "Delete"
|
|
85
|
-
}));
|
|
86
|
-
}), /*#__PURE__*/React.createElement(Button, {
|
|
87
|
-
block: true,
|
|
88
|
-
disabled: disabled,
|
|
89
|
-
icon: /*#__PURE__*/React.createElement(Icon, {
|
|
90
|
-
icon: Plus
|
|
91
|
-
}),
|
|
92
|
-
onClick: function onClick() {
|
|
93
|
-
var lastMeg = chatMessages.at(-1);
|
|
94
|
-
dispatch({
|
|
95
|
-
message: {
|
|
96
|
-
content: '',
|
|
97
|
-
role: (lastMeg === null || lastMeg === void 0 ? void 0 : lastMeg.role) === 'user' ? 'assistant' : 'user'
|
|
98
|
-
},
|
|
99
|
-
type: 'addMessage'
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
}, "Add Props")) : undefined;
|
|
104
|
+
children: "Add Props"
|
|
105
|
+
})]
|
|
106
|
+
}) : undefined;
|
|
103
107
|
}, isEqual);
|
|
104
108
|
export default EditableMessageList;
|