@lobehub/ui 1.49.1 → 1.50.1
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/ChatInputArea/Action.d.ts +11 -0
- package/es/ChatInputArea/Action.js +40 -0
- package/es/ChatInputArea/index.d.ts +2 -15
- package/es/ChatInputArea/index.js +8 -20
- package/es/ChatItem/index.js +6 -5
- package/es/ChatItem/style.d.ts +2 -0
- package/es/ChatItem/style.js +8 -6
- package/es/ChatList/ActionsBar.js +1 -5
- package/es/ChatList/index.d.ts +10 -1
- package/es/ChatList/index.js +70 -26
- package/es/EditableMessage/index.d.ts +1 -0
- package/es/EditableMessage/index.js +14 -11
- package/es/MessageInput/index.d.ts +1 -0
- package/es/MessageInput/index.js +5 -1
- package/es/utils/formatTime.js +3 -3
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface ActionProps {
|
|
3
|
+
/**
|
|
4
|
+
* @description Actions to be displayed in the input area
|
|
5
|
+
*/
|
|
6
|
+
actions?: ReactNode;
|
|
7
|
+
expand?: boolean;
|
|
8
|
+
onExpandChange?: (expand: boolean) => void;
|
|
9
|
+
}
|
|
10
|
+
declare const Action: import("react").NamedExoticComponent<ActionProps>;
|
|
11
|
+
export default Action;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
3
|
+
import { createStyles } from 'antd-style';
|
|
4
|
+
import { Maximize2, Minimize2 } from 'lucide-react';
|
|
5
|
+
import { memo, useCallback } from 'react';
|
|
6
|
+
import ActionIcon from "../ActionIcon";
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
var useStyles = createStyles(function (_ref) {
|
|
10
|
+
var css = _ref.css;
|
|
11
|
+
return {
|
|
12
|
+
actionLeft: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n flex: 1;\n gap: 4px;\n align-items: center;\n justify-content: flex-start;\n "]))),
|
|
13
|
+
actionsBar: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: flex;\n flex: none;\n align-items: center;\n justify-content: space-between;\n\n padding: 0 16px;\n "]))),
|
|
14
|
+
actionsRight: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: flex;\n flex: 0;\n gap: 4px;\n align-items: center;\n justify-content: flex-end;\n "])))
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
var Action = /*#__PURE__*/memo(function (_ref2) {
|
|
18
|
+
var actions = _ref2.actions,
|
|
19
|
+
expand = _ref2.expand,
|
|
20
|
+
onExpandChange = _ref2.onExpandChange;
|
|
21
|
+
var _useStyles = useStyles(),
|
|
22
|
+
styles = _useStyles.styles;
|
|
23
|
+
var handleExpandClick = useCallback(function () {
|
|
24
|
+
if (onExpandChange) onExpandChange(!expand);
|
|
25
|
+
}, [expand]);
|
|
26
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
27
|
+
className: styles.actionsBar,
|
|
28
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
29
|
+
className: styles.actionLeft,
|
|
30
|
+
children: actions
|
|
31
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
32
|
+
className: styles.actionsRight,
|
|
33
|
+
children: /*#__PURE__*/_jsx(ActionIcon, {
|
|
34
|
+
icon: expand ? Minimize2 : Maximize2,
|
|
35
|
+
onClick: handleExpandClick
|
|
36
|
+
})
|
|
37
|
+
})]
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
export default Action;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { type InputRef } from 'antd';
|
|
2
2
|
import { CSSProperties, ReactNode } from 'react';
|
|
3
3
|
import { type TextAreaProps } from "../Input";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* @description Actions to be displayed in the input area
|
|
7
|
-
*/
|
|
8
|
-
actions?: ReactNode;
|
|
4
|
+
import { ActionProps } from './Action';
|
|
5
|
+
export interface ChatInputAreaProps extends ActionProps, TextAreaProps {
|
|
9
6
|
/**
|
|
10
7
|
* @description Additional class name for the component
|
|
11
8
|
*/
|
|
@@ -19,11 +16,6 @@ export interface ChatInputAreaProps extends TextAreaProps {
|
|
|
19
16
|
* @default false
|
|
20
17
|
*/
|
|
21
18
|
disabled?: boolean;
|
|
22
|
-
/**
|
|
23
|
-
* @description Whether the input area is expanded
|
|
24
|
-
* @default false
|
|
25
|
-
*/
|
|
26
|
-
expand?: boolean;
|
|
27
19
|
/**
|
|
28
20
|
* @description Footer content to be displayed below the input area
|
|
29
21
|
*/
|
|
@@ -38,11 +30,6 @@ export interface ChatInputAreaProps extends TextAreaProps {
|
|
|
38
30
|
* @default 200
|
|
39
31
|
*/
|
|
40
32
|
minHeight?: number;
|
|
41
|
-
/**
|
|
42
|
-
* @description Callback function when the expand state changes
|
|
43
|
-
* @param expand - Whether the input area is expanded
|
|
44
|
-
*/
|
|
45
|
-
onExpandChange?: (expand: boolean) => void;
|
|
46
33
|
/**
|
|
47
34
|
* @description Callback function when the input value changes
|
|
48
35
|
* @param value - The current value of the input area
|
|
@@ -5,10 +5,9 @@ var _excluded = ["text", "textareaClassName", "style", "textareaStyle", "minHeig
|
|
|
5
5
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
6
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
7
|
import { Button } from 'antd';
|
|
8
|
-
import { Maximize2, Minimize2 } from 'lucide-react';
|
|
9
8
|
import { forwardRef, useCallback, useEffect, useRef, useState } from 'react';
|
|
10
|
-
import ActionIcon from "../ActionIcon";
|
|
11
9
|
import { TextArea } from "../Input";
|
|
10
|
+
import Action from "./Action";
|
|
12
11
|
import InputHighlight from "./InputHighlight";
|
|
13
12
|
import { useStyles } from "./style";
|
|
14
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -41,17 +40,14 @@ var ChatInputArea = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
41
40
|
_ref$textareaId = _ref.textareaId,
|
|
42
41
|
textareaId = _ref$textareaId === void 0 ? 'lobe-chat-input-area' : _ref$textareaId,
|
|
43
42
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
43
|
+
var _useStyles = useStyles(),
|
|
44
|
+
cx = _useStyles.cx,
|
|
45
|
+
styles = _useStyles.styles;
|
|
44
46
|
var isChineseInput = useRef(false);
|
|
45
47
|
var _useState = useState(defaultValue),
|
|
46
48
|
_useState2 = _slicedToArray(_useState, 2),
|
|
47
49
|
value = _useState2[0],
|
|
48
50
|
setValue = _useState2[1];
|
|
49
|
-
var _useStyles = useStyles(),
|
|
50
|
-
cx = _useStyles.cx,
|
|
51
|
-
styles = _useStyles.styles;
|
|
52
|
-
var handleExpandClick = useCallback(function () {
|
|
53
|
-
if (onExpandChange) onExpandChange(!expand);
|
|
54
|
-
}, [expand]);
|
|
55
51
|
var handleSend = useCallback(function () {
|
|
56
52
|
if (disabled) return;
|
|
57
53
|
if (onSend) onSend(value);
|
|
@@ -65,18 +61,10 @@ var ChatInputArea = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
65
61
|
style: _objectSpread({
|
|
66
62
|
minHeight: minHeight
|
|
67
63
|
}, style),
|
|
68
|
-
children: [/*#__PURE__*/
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
children: actions
|
|
73
|
-
}), /*#__PURE__*/_jsx("div", {
|
|
74
|
-
className: styles.actionsRight,
|
|
75
|
-
children: /*#__PURE__*/_jsx(ActionIcon, {
|
|
76
|
-
icon: expand ? Minimize2 : Maximize2,
|
|
77
|
-
onClick: handleExpandClick
|
|
78
|
-
})
|
|
79
|
-
})]
|
|
64
|
+
children: [/*#__PURE__*/_jsx(Action, {
|
|
65
|
+
actions: actions,
|
|
66
|
+
expand: expand,
|
|
67
|
+
onExpandChange: onExpandChange
|
|
80
68
|
}), /*#__PURE__*/_jsxs("div", {
|
|
81
69
|
className: styles.textareaContainer,
|
|
82
70
|
children: [/*#__PURE__*/_jsx(InputHighlight, {
|
package/es/ChatItem/index.js
CHANGED
|
@@ -79,16 +79,17 @@ var ChatItem = /*#__PURE__*/memo(function (_ref) {
|
|
|
79
79
|
className: styles.alert,
|
|
80
80
|
showIcon: true
|
|
81
81
|
}, alert)) : /*#__PURE__*/_jsxs(Flexbox, {
|
|
82
|
-
className: styles.message,
|
|
83
|
-
style: editing ? {
|
|
84
|
-
padding: 12
|
|
85
|
-
} : {},
|
|
82
|
+
className: cx(styles.message, editing && styles.editingContainer),
|
|
86
83
|
children: [/*#__PURE__*/_jsx(EditableMessage, {
|
|
84
|
+
classNames: {
|
|
85
|
+
input: styles.editingInput
|
|
86
|
+
},
|
|
87
|
+
editButtonSize: 'small',
|
|
87
88
|
editing: editing,
|
|
88
89
|
onChange: onChange,
|
|
89
90
|
onEditingChange: onEditingChange,
|
|
90
91
|
value: String(message || '...')
|
|
91
|
-
}), messageExtra ? /*#__PURE__*/_jsx("div", {
|
|
92
|
+
}), messageExtra && !editing ? /*#__PURE__*/_jsx("div", {
|
|
92
93
|
className: styles.messageExtra,
|
|
93
94
|
children: messageExtra
|
|
94
95
|
}) : null]
|
package/es/ChatItem/style.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export declare const useStyles: (props?: {
|
|
|
10
10
|
alert: import("antd-style").SerializedStyles;
|
|
11
11
|
avatarContainer: import("antd-style").SerializedStyles;
|
|
12
12
|
container: string;
|
|
13
|
+
editingContainer: import("antd-style").SerializedStyles;
|
|
14
|
+
editingInput: import("antd-style").SerializedStyles;
|
|
13
15
|
loading: import("antd-style").SerializedStyles;
|
|
14
16
|
message: string;
|
|
15
17
|
messageContainer: import("antd-style").SerializedStyles;
|
package/es/ChatItem/style.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12;
|
|
2
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14;
|
|
3
3
|
import { createStyles } from 'antd-style';
|
|
4
4
|
import { rgba } from 'polished';
|
|
5
5
|
export var useStyles = createStyles(function (_ref, _ref2) {
|
|
@@ -22,11 +22,13 @@ export var useStyles = createStyles(function (_ref, _ref2) {
|
|
|
22
22
|
alert: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n span[role='img'] {\n align-self: flex-start;\n width: 16px;\n height: 16px;\n margin-top: 3px;\n }\n\n .ant-alert-description {\n text-align: justify;\n word-break: break-all;\n word-wrap: break-word;\n }\n\n &.ant-alert-with-description {\n padding-block: 12px;\n padding-inline: 12px;\n\n .ant-alert-message {\n font-size: 14px;\n font-weight: 600;\n text-align: justify;\n word-break: break-all;\n word-wrap: break-word;\n }\n }\n "]))),
|
|
23
23
|
avatarContainer: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n position: relative;\n flex: none;\n width: ", "px;\n height: ", "px;\n "])), avatarSize, avatarSize),
|
|
24
24
|
container: cx(type === 'pure' && pureContainerStylish, css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n position: relative;\n\n display: flex;\n flex-direction: ", ";\n gap: 12px;\n align-items: flex-start;\n justify-content: revert;\n\n width: 100%;\n padding: 12px;\n\n time {\n display: inline-block;\n white-space: nowrap;\n }\n\n div[role='chat-item-actions'] {\n display: flex;\n }\n\n time,\n div[role='chat-item-actions'] {\n pointer-events: none;\n opacity: 0;\n transition: opacity 200ms ", ";\n }\n\n &:hover {\n time,\n div[role='chat-item-actions'] {\n pointer-events: unset;\n opacity: 1;\n }\n }\n "])), placement === 'left' ? 'row' : 'row-reverse', token.motionEaseOut)),
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
editingContainer: css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n padding-block: 8px;\n border: 1px solid ", ";\n\n &:active,\n &:hover {\n border-color: ", ";\n }\n "])), token.colorPrimaryBorder, token.colorPrimary),
|
|
26
|
+
editingInput: css(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n min-height: 80px;\n "]))),
|
|
27
|
+
loading: css(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n position: absolute;\n right: ", ";\n bottom: 0;\n left: ", ";\n\n display: flex;\n align-items: center;\n justify-content: center;\n\n width: 16px;\n height: 16px;\n\n color: ", ";\n\n background: ", ";\n border-radius: 50%;\n "])), placement === 'left' ? '-4px' : 'unset', placement === 'right' ? '-4px' : 'unset', token.colorBgLayout, token.colorPrimary),
|
|
28
|
+
message: cx(typeStylish, css(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n position: relative;\n "])))),
|
|
29
|
+
messageContainer: css(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\n position: relative;\n display: flex;\n flex-direction: column;\n align-items: ", ";\n "])), placement === 'left' ? 'flex-start' : 'flex-end'),
|
|
30
|
+
messageContent: css(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["\n position: revert;\n\n display: flex;\n flex-direction: ", ";\n gap: 8px;\n align-items: ", ";\n "])), type === 'block' ? placement === 'left' ? 'row' : 'row-reverse' : 'column', placement === 'left' ? 'flex-start' : 'flex-end'),
|
|
29
31
|
messageExtra: cx('message-extra'),
|
|
30
|
-
name: css(
|
|
32
|
+
name: css(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["\n position: ", ";\n top: ", ";\n right: ", ";\n left: ", ";\n\n display: flex;\n flex-direction: ", ";\n gap: 4px;\n\n margin-bottom: 6px;\n\n font-size: 12px;\n line-height: 1;\n color: ", ";\n text-align: ", ";\n "])), showTitle ? 'relative' : 'absolute', showTitle ? 'unset' : '-16px', placement === 'right' ? '0' : 'unset', placement === 'left' ? '0' : 'unset', placement === 'left' ? 'row' : 'row-reverse', token.colorTextDescription, placement === 'left' ? 'left' : 'right')
|
|
31
33
|
};
|
|
32
34
|
});
|
|
@@ -16,11 +16,7 @@ var ActionsBar = /*#__PURE__*/memo(function (_ref) {
|
|
|
16
16
|
dropdownMenu = _ref$dropdownMenu === void 0 ? [] : _ref$dropdownMenu,
|
|
17
17
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
18
18
|
var groupItems = useMemo(function () {
|
|
19
|
-
return [
|
|
20
|
-
icon: Edit,
|
|
21
|
-
key: 'edit',
|
|
22
|
-
label: 'Edit'
|
|
23
|
-
} : {
|
|
19
|
+
return [{
|
|
24
20
|
icon: RotateCw,
|
|
25
21
|
key: 'regenerate',
|
|
26
22
|
label: 'Regenerate'
|
package/es/ChatList/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { ReactNode } from 'react';
|
|
|
2
2
|
import { ChatItemProps } from "../ChatItem";
|
|
3
3
|
import type { DivProps } from "../types";
|
|
4
4
|
import { ChatMessage } from "../types/chatMessage";
|
|
5
|
+
declare type MessageExtra = (props: ChatMessage) => ReactNode;
|
|
5
6
|
export interface ChatListProps extends DivProps {
|
|
6
7
|
/**
|
|
7
8
|
* @description Data of chat messages to be displayed
|
|
@@ -13,7 +14,8 @@ export interface ChatListProps extends DivProps {
|
|
|
13
14
|
* @param {string} messageId - The id of the message
|
|
14
15
|
*/
|
|
15
16
|
onActionClick?: (actionKey: string, messageId: string) => void;
|
|
16
|
-
|
|
17
|
+
onMessageChange?: (id: string, content: string) => void;
|
|
18
|
+
renderMessageExtra?: MessageExtra;
|
|
17
19
|
/**
|
|
18
20
|
* @description Whether to show name of the chat item
|
|
19
21
|
* @default false
|
|
@@ -25,5 +27,12 @@ export interface ChatListProps extends DivProps {
|
|
|
25
27
|
*/
|
|
26
28
|
type?: 'docs' | 'chat';
|
|
27
29
|
}
|
|
30
|
+
export interface ItemProps extends ChatMessage {
|
|
31
|
+
MessageExtra?: MessageExtra;
|
|
32
|
+
onActionClick?: (actionKey: string, messageId: string) => void;
|
|
33
|
+
onMessageChange?: (id: string, content: string) => void;
|
|
34
|
+
showTitle?: boolean;
|
|
35
|
+
type: 'docs' | 'chat';
|
|
36
|
+
}
|
|
28
37
|
declare const ChatList: import("react").NamedExoticComponent<ChatListProps>;
|
|
29
38
|
export default ChatList;
|
package/es/ChatList/index.js
CHANGED
|
@@ -1,22 +1,76 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
1
2
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["
|
|
4
|
+
var _excluded = ["MessageExtra", "showTitle", "onActionClick", "onMessageChange", "type"],
|
|
5
|
+
_excluded2 = ["onActionClick", "renderMessageExtra", "className", "data", "type", "showTitle", "onMessageChange"];
|
|
4
6
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
7
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
-
import {
|
|
8
|
+
import { App } from 'antd';
|
|
9
|
+
import copy from 'copy-to-clipboard';
|
|
10
|
+
import { memo, useState } from 'react';
|
|
7
11
|
import ChatItem from "../ChatItem";
|
|
8
12
|
import ActionsBar from "./ActionsBar";
|
|
9
13
|
import { useStyles } from "./style";
|
|
10
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
MessageExtra = _ref.renderMessageExtra,
|
|
14
|
-
className = _ref.className,
|
|
15
|
-
data = _ref.data,
|
|
16
|
-
_ref$type = _ref.type,
|
|
17
|
-
type = _ref$type === void 0 ? 'chat' : _ref$type,
|
|
15
|
+
var Item = function Item(_ref) {
|
|
16
|
+
var MessageExtra = _ref.MessageExtra,
|
|
18
17
|
showTitle = _ref.showTitle,
|
|
19
|
-
|
|
18
|
+
_onActionClick = _ref.onActionClick,
|
|
19
|
+
onMessageChange = _ref.onMessageChange,
|
|
20
|
+
type = _ref.type,
|
|
21
|
+
item = _objectWithoutProperties(_ref, _excluded);
|
|
22
|
+
var renderMessageExtra = MessageExtra ? /*#__PURE__*/_jsx(MessageExtra, _objectSpread({}, item)) : undefined;
|
|
23
|
+
var _useState = useState(false),
|
|
24
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
25
|
+
editing = _useState2[0],
|
|
26
|
+
setEditing = _useState2[1];
|
|
27
|
+
var _App$useApp = App.useApp(),
|
|
28
|
+
message = _App$useApp.message;
|
|
29
|
+
return /*#__PURE__*/_jsx(ChatItem, {
|
|
30
|
+
actions: /*#__PURE__*/_jsx(ActionsBar, {
|
|
31
|
+
onActionClick: function onActionClick(actionKey) {
|
|
32
|
+
switch (actionKey) {
|
|
33
|
+
case 'copy':
|
|
34
|
+
{
|
|
35
|
+
copy(item.content);
|
|
36
|
+
message.success('复制成功');
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
case 'edit':
|
|
40
|
+
{
|
|
41
|
+
console.log('editing');
|
|
42
|
+
setEditing(true);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
_onActionClick === null || _onActionClick === void 0 ? void 0 : _onActionClick(actionKey, item.id);
|
|
46
|
+
},
|
|
47
|
+
primary: item.role === 'user'
|
|
48
|
+
}),
|
|
49
|
+
avatar: item.meta,
|
|
50
|
+
editing: editing,
|
|
51
|
+
message: item.content,
|
|
52
|
+
messageExtra: renderMessageExtra,
|
|
53
|
+
onChange: function onChange(value) {
|
|
54
|
+
onMessageChange === null || onMessageChange === void 0 ? void 0 : onMessageChange(item.id, value);
|
|
55
|
+
},
|
|
56
|
+
onEditingChange: setEditing,
|
|
57
|
+
placement: type === 'chat' ? item.role === 'user' ? 'right' : 'left' : 'left',
|
|
58
|
+
primary: item.role === 'user',
|
|
59
|
+
showTitle: showTitle,
|
|
60
|
+
time: item.updateAt || item.createAt,
|
|
61
|
+
type: type === 'chat' ? 'block' : 'pure'
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
var ChatList = /*#__PURE__*/memo(function (_ref2) {
|
|
65
|
+
var onActionClick = _ref2.onActionClick,
|
|
66
|
+
MessageExtra = _ref2.renderMessageExtra,
|
|
67
|
+
className = _ref2.className,
|
|
68
|
+
data = _ref2.data,
|
|
69
|
+
_ref2$type = _ref2.type,
|
|
70
|
+
type = _ref2$type === void 0 ? 'chat' : _ref2$type,
|
|
71
|
+
showTitle = _ref2.showTitle,
|
|
72
|
+
onMessageChange = _ref2.onMessageChange,
|
|
73
|
+
props = _objectWithoutProperties(_ref2, _excluded2);
|
|
20
74
|
var _useStyles = useStyles(),
|
|
21
75
|
cx = _useStyles.cx,
|
|
22
76
|
styles = _useStyles.styles;
|
|
@@ -24,23 +78,13 @@ var ChatList = /*#__PURE__*/memo(function (_ref) {
|
|
|
24
78
|
className: cx(styles.container, className)
|
|
25
79
|
}, props), {}, {
|
|
26
80
|
children: data.map(function (item) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return onActionClick === null || onActionClick === void 0 ? void 0 : onActionClick(actionKey, item.id);
|
|
32
|
-
} : undefined,
|
|
33
|
-
primary: item.role === 'user'
|
|
34
|
-
}),
|
|
35
|
-
avatar: item.meta,
|
|
36
|
-
message: item.content,
|
|
37
|
-
messageExtra: renderMessageExtra,
|
|
38
|
-
placement: type === 'chat' ? item.role === 'user' ? 'right' : 'left' : 'left',
|
|
39
|
-
primary: item.role === 'user',
|
|
81
|
+
return /*#__PURE__*/_jsx(Item, _objectSpread({
|
|
82
|
+
MessageExtra: MessageExtra,
|
|
83
|
+
onActionClick: onActionClick,
|
|
84
|
+
onMessageChange: onMessageChange,
|
|
40
85
|
showTitle: showTitle,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}, item.id);
|
|
86
|
+
type: type
|
|
87
|
+
}, item), item.id);
|
|
44
88
|
})
|
|
45
89
|
}));
|
|
46
90
|
});
|
|
@@ -20,7 +20,8 @@ var EditableMessage = /*#__PURE__*/memo(function (_ref) {
|
|
|
20
20
|
placeholder = _ref$placeholder === void 0 ? 'Type something...' : _ref$placeholder,
|
|
21
21
|
_ref$showEditWhenEmpt = _ref.showEditWhenEmpty,
|
|
22
22
|
showEditWhenEmpty = _ref$showEditWhenEmpt === void 0 ? false : _ref$showEditWhenEmpt,
|
|
23
|
-
styles = _ref.styles
|
|
23
|
+
styles = _ref.styles,
|
|
24
|
+
editButtonSize = _ref.editButtonSize;
|
|
24
25
|
var _useControlledState = useControlledState(false, {
|
|
25
26
|
onChange: onEditingChange,
|
|
26
27
|
value: editing
|
|
@@ -38,6 +39,7 @@ var EditableMessage = /*#__PURE__*/memo(function (_ref) {
|
|
|
38
39
|
return !value && showEditWhenEmpty ? /*#__PURE__*/_jsx(MessageInput, {
|
|
39
40
|
className: classNames === null || classNames === void 0 ? void 0 : classNames.input,
|
|
40
41
|
defaultValue: value,
|
|
42
|
+
editButtonSize: editButtonSize,
|
|
41
43
|
onCancel: function onCancel() {
|
|
42
44
|
return setTyping(false);
|
|
43
45
|
},
|
|
@@ -48,18 +50,10 @@ var EditableMessage = /*#__PURE__*/memo(function (_ref) {
|
|
|
48
50
|
placeholder: placeholder,
|
|
49
51
|
style: styles === null || styles === void 0 ? void 0 : styles.input
|
|
50
52
|
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
51
|
-
children: [/*#__PURE__*/_jsx(
|
|
52
|
-
editing: isEdit,
|
|
53
|
-
onChange: function onChange(text) {
|
|
54
|
-
_onChange === null || _onChange === void 0 ? void 0 : _onChange(text);
|
|
55
|
-
},
|
|
56
|
-
onEditingChange: setTyping,
|
|
57
|
-
onOpenChange: setExpand,
|
|
58
|
-
open: expand,
|
|
59
|
-
value: value
|
|
60
|
-
}), !expand && isEdit ? /*#__PURE__*/_jsx(MessageInput, {
|
|
53
|
+
children: [!expand && isEdit ? /*#__PURE__*/_jsx(MessageInput, {
|
|
61
54
|
className: classNames === null || classNames === void 0 ? void 0 : classNames.input,
|
|
62
55
|
defaultValue: value,
|
|
56
|
+
editButtonSize: editButtonSize,
|
|
63
57
|
onCancel: function onCancel() {
|
|
64
58
|
return setTyping(false);
|
|
65
59
|
},
|
|
@@ -73,6 +67,15 @@ var EditableMessage = /*#__PURE__*/memo(function (_ref) {
|
|
|
73
67
|
className: classNames === null || classNames === void 0 ? void 0 : classNames.markdown,
|
|
74
68
|
style: styles === null || styles === void 0 ? void 0 : styles.markdown,
|
|
75
69
|
children: value
|
|
70
|
+
}), /*#__PURE__*/_jsx(MessageModal, {
|
|
71
|
+
editing: isEdit,
|
|
72
|
+
onChange: function onChange(text) {
|
|
73
|
+
_onChange === null || _onChange === void 0 ? void 0 : _onChange(text);
|
|
74
|
+
},
|
|
75
|
+
onEditingChange: setTyping,
|
|
76
|
+
onOpenChange: setExpand,
|
|
77
|
+
open: expand,
|
|
78
|
+
value: value
|
|
76
79
|
})]
|
|
77
80
|
});
|
|
78
81
|
});
|
|
@@ -11,6 +11,7 @@ export interface MessageInputProps extends DivProps {
|
|
|
11
11
|
* @description The default value of the input box.
|
|
12
12
|
*/
|
|
13
13
|
defaultValue?: string;
|
|
14
|
+
editButtonSize?: 'small' | 'middle';
|
|
14
15
|
height?: number | string;
|
|
15
16
|
/**
|
|
16
17
|
* @description Callback function triggered when user clicks on the cancel button.
|
package/es/MessageInput/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["text", "type", "onCancel", "defaultValue", "onConfirm", "renderButtons", "textareaStyle", "textareaClassname", "placeholder", "height"];
|
|
4
|
+
var _excluded = ["text", "type", "onCancel", "defaultValue", "onConfirm", "renderButtons", "textareaStyle", "textareaClassname", "placeholder", "height", "editButtonSize"];
|
|
5
5
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
6
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
7
|
import { Button } from 'antd';
|
|
@@ -25,6 +25,8 @@ var MessageInput = /*#__PURE__*/memo(function (_ref) {
|
|
|
25
25
|
placeholder = _ref$placeholder === void 0 ? 'Type something...' : _ref$placeholder,
|
|
26
26
|
_ref$height = _ref.height,
|
|
27
27
|
height = _ref$height === void 0 ? 'fit-content' : _ref$height,
|
|
28
|
+
_ref$editButtonSize = _ref.editButtonSize,
|
|
29
|
+
editButtonSize = _ref$editButtonSize === void 0 ? 'middle' : _ref$editButtonSize,
|
|
28
30
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
29
31
|
var _useState = useState(defaultValue || ''),
|
|
30
32
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -65,10 +67,12 @@ var MessageInput = /*#__PURE__*/memo(function (_ref) {
|
|
|
65
67
|
onClick: function onClick() {
|
|
66
68
|
onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm(temporarySystemRole);
|
|
67
69
|
},
|
|
70
|
+
size: editButtonSize,
|
|
68
71
|
type: "primary",
|
|
69
72
|
children: (text === null || text === void 0 ? void 0 : text.confirm) || 'Confirm'
|
|
70
73
|
}), /*#__PURE__*/_jsx(Button, {
|
|
71
74
|
onClick: onCancel,
|
|
75
|
+
size: editButtonSize,
|
|
72
76
|
children: (text === null || text === void 0 ? void 0 : text.cancel) || 'Cancel'
|
|
73
77
|
})]
|
|
74
78
|
})
|
package/es/utils/formatTime.js
CHANGED
|
@@ -3,10 +3,10 @@ export var formatTime = function formatTime(time) {
|
|
|
3
3
|
var now = dayjs();
|
|
4
4
|
var target = dayjs(time);
|
|
5
5
|
if (target.isSame(now, 'day')) {
|
|
6
|
-
return target.format('HH:mm');
|
|
6
|
+
return target.format('HH:mm:ss');
|
|
7
7
|
} else if (target.isSame(now, 'year')) {
|
|
8
|
-
return target.format('MM-DD HH:mm');
|
|
8
|
+
return target.format('MM-DD HH:mm:ss');
|
|
9
9
|
} else {
|
|
10
|
-
return target.format('YYYY-MM-DD HH:mm');
|
|
10
|
+
return target.format('YYYY-MM-DD HH:mm:ss');
|
|
11
11
|
}
|
|
12
12
|
};
|