@lobehub/ui 1.34.1 → 1.36.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/ChatInputArea/index.d.ts +29 -13
- package/es/ChatInputArea/index.js +31 -17
- package/es/ChatItem/index.d.ts +20 -19
- package/es/ChatItem/index.js +26 -24
- package/es/ChatItem/style.d.ts +3 -2
- package/es/ChatItem/style.js +9 -8
- package/es/ChatList/index.d.ts +6 -1
- package/es/ChatList/index.js +2 -2
- package/es/DraggablePanel/index.js +10 -2
- package/es/styles/algorithms/generateCustomStylish.js +1 -1
- package/package.json +2 -1
|
@@ -1,30 +1,34 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import type
|
|
3
|
-
export interface ChatInputAreaProps extends
|
|
1
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
import { type TextAreaProps } from "../Input";
|
|
3
|
+
export interface ChatInputAreaProps extends TextAreaProps {
|
|
4
4
|
/**
|
|
5
|
-
* @description Actions to be displayed in the
|
|
5
|
+
* @description Actions to be displayed in the input area
|
|
6
6
|
*/
|
|
7
7
|
actions?: ReactNode;
|
|
8
8
|
/**
|
|
9
|
-
* @description
|
|
9
|
+
* @description Additional class name for the component
|
|
10
|
+
*/
|
|
11
|
+
className?: string;
|
|
12
|
+
/**
|
|
13
|
+
* @description Default value for the input area
|
|
10
14
|
*/
|
|
11
15
|
defaultValue?: string;
|
|
12
16
|
/**
|
|
13
|
-
* @description Whether the input is disabled
|
|
17
|
+
* @description Whether the input area is disabled
|
|
14
18
|
* @default false
|
|
15
19
|
*/
|
|
16
20
|
disabled?: boolean;
|
|
17
21
|
/**
|
|
18
|
-
* @description Whether the input is expanded
|
|
22
|
+
* @description Whether the input area is expanded
|
|
19
23
|
* @default false
|
|
20
24
|
*/
|
|
21
25
|
expand?: boolean;
|
|
22
26
|
/**
|
|
23
|
-
* @description Footer to be displayed below input area
|
|
27
|
+
* @description Footer content to be displayed below the input area
|
|
24
28
|
*/
|
|
25
29
|
footer?: ReactNode;
|
|
26
30
|
/**
|
|
27
|
-
* @description Whether the input is in loading state
|
|
31
|
+
* @description Whether the input area is in loading state
|
|
28
32
|
* @default false
|
|
29
33
|
*/
|
|
30
34
|
loading?: boolean;
|
|
@@ -35,24 +39,36 @@ export interface ChatInputAreaProps extends DivProps {
|
|
|
35
39
|
minHeight?: number;
|
|
36
40
|
/**
|
|
37
41
|
* @description Callback function when the expand state changes
|
|
38
|
-
* @param expand - Whether the input is expanded
|
|
42
|
+
* @param expand - Whether the input area is expanded
|
|
39
43
|
*/
|
|
40
44
|
onExpandChange?: (expand: boolean) => void;
|
|
41
45
|
/**
|
|
42
46
|
* @description Callback function when the input value changes
|
|
43
|
-
* @param value - The current value of the input
|
|
47
|
+
* @param value - The current value of the input area
|
|
44
48
|
*/
|
|
45
49
|
onInputChange?: (value: string) => void;
|
|
46
50
|
/**
|
|
47
51
|
* @description Callback function when the send button is clicked
|
|
48
|
-
* @param value - The current value of the input
|
|
52
|
+
* @param value - The current value of the input area
|
|
49
53
|
*/
|
|
50
54
|
onSend?: (value: string) => void;
|
|
51
55
|
/**
|
|
52
|
-
* @description Placeholder text
|
|
56
|
+
* @description Placeholder text for the input area
|
|
53
57
|
* @default 'Type something to chat...'
|
|
54
58
|
*/
|
|
55
59
|
placeholder?: string;
|
|
60
|
+
/**
|
|
61
|
+
* @description CSS styles for the component
|
|
62
|
+
*/
|
|
63
|
+
style?: CSSProperties;
|
|
64
|
+
/**
|
|
65
|
+
* @description Additional class name for the textarea element
|
|
66
|
+
*/
|
|
67
|
+
textareaClassName?: string;
|
|
68
|
+
/**
|
|
69
|
+
* @description CSS styles for the textarea element
|
|
70
|
+
*/
|
|
71
|
+
textareaStyle?: CSSProperties;
|
|
56
72
|
}
|
|
57
73
|
declare const ChatInputArea: import("react").NamedExoticComponent<ChatInputAreaProps>;
|
|
58
74
|
export default ChatInputArea;
|
|
@@ -1,19 +1,22 @@
|
|
|
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 = ["minHeight", "className", "actions", "footer", "expand", "placeholder", "onExpandChange", "onSend", "defaultValue", "loading", "
|
|
4
|
+
var _excluded = ["textareaClassName", "style", "textareaStyle", "minHeight", "className", "actions", "footer", "expand", "placeholder", "onExpandChange", "onSend", "defaultValue", "loading", "disabled", "onInputChange", "onPressEnter", "onCompositionStart", "onCompositionEnd", "onBlur", "onChange"];
|
|
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
8
|
import { Maximize2, Minimize2 } from 'lucide-react';
|
|
9
|
-
import { memo, useCallback, useEffect, useRef, useState } from 'react';
|
|
9
|
+
import { forwardRef, memo, useCallback, useEffect, useRef, useState } from 'react';
|
|
10
10
|
import ActionIcon from "../ActionIcon";
|
|
11
11
|
import { TextArea } from "../Input";
|
|
12
12
|
import { useStyles } from "./style";
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
-
var ChatInputArea = /*#__PURE__*/memo(function (_ref) {
|
|
16
|
-
var
|
|
15
|
+
var ChatInputArea = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (_ref, reference) {
|
|
16
|
+
var textareaClassName = _ref.textareaClassName,
|
|
17
|
+
style = _ref.style,
|
|
18
|
+
textareaStyle = _ref.textareaStyle,
|
|
19
|
+
_ref$minHeight = _ref.minHeight,
|
|
17
20
|
minHeight = _ref$minHeight === void 0 ? 200 : _ref$minHeight,
|
|
18
21
|
className = _ref.className,
|
|
19
22
|
actions = _ref.actions,
|
|
@@ -26,9 +29,13 @@ var ChatInputArea = /*#__PURE__*/memo(function (_ref) {
|
|
|
26
29
|
_ref$defaultValue = _ref.defaultValue,
|
|
27
30
|
defaultValue = _ref$defaultValue === void 0 ? '' : _ref$defaultValue,
|
|
28
31
|
loading = _ref.loading,
|
|
29
|
-
style = _ref.style,
|
|
30
32
|
disabled = _ref.disabled,
|
|
31
33
|
onInputChange = _ref.onInputChange,
|
|
34
|
+
_onPressEnter = _ref.onPressEnter,
|
|
35
|
+
_onCompositionStart = _ref.onCompositionStart,
|
|
36
|
+
_onCompositionEnd = _ref.onCompositionEnd,
|
|
37
|
+
_onBlur = _ref.onBlur,
|
|
38
|
+
_onChange = _ref.onChange,
|
|
32
39
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
33
40
|
var isChineseInput = useRef(false);
|
|
34
41
|
var _useState = useState(defaultValue),
|
|
@@ -49,12 +56,11 @@ var ChatInputArea = /*#__PURE__*/memo(function (_ref) {
|
|
|
49
56
|
useEffect(function () {
|
|
50
57
|
if (onInputChange) onInputChange(value);
|
|
51
58
|
}, [value]);
|
|
52
|
-
return /*#__PURE__*/_jsxs("section",
|
|
59
|
+
return /*#__PURE__*/_jsxs("section", {
|
|
53
60
|
className: cx(styles.container, className),
|
|
54
61
|
style: _objectSpread({
|
|
55
62
|
minHeight: minHeight
|
|
56
|
-
}, style)
|
|
57
|
-
}, props), {}, {
|
|
63
|
+
}, style),
|
|
58
64
|
children: [/*#__PURE__*/_jsxs("div", {
|
|
59
65
|
className: styles.actionsBar,
|
|
60
66
|
children: [/*#__PURE__*/_jsx("div", {
|
|
@@ -67,22 +73,30 @@ var ChatInputArea = /*#__PURE__*/memo(function (_ref) {
|
|
|
67
73
|
onClick: handleExpandClick
|
|
68
74
|
})
|
|
69
75
|
})]
|
|
70
|
-
}), /*#__PURE__*/_jsx(TextArea, {
|
|
71
|
-
className: styles.textarea,
|
|
76
|
+
}), /*#__PURE__*/_jsx(TextArea, _objectSpread(_objectSpread({
|
|
77
|
+
className: cx(styles.textarea, textareaClassName),
|
|
72
78
|
defaultValue: defaultValue,
|
|
79
|
+
ref: reference,
|
|
80
|
+
style: textareaStyle
|
|
81
|
+
}, props), {}, {
|
|
73
82
|
onBlur: function onBlur(e) {
|
|
74
|
-
|
|
83
|
+
if (_onBlur) _onBlur(e);
|
|
84
|
+
setValue(e.target.value);
|
|
75
85
|
},
|
|
76
86
|
onChange: function onChange(e) {
|
|
77
|
-
|
|
87
|
+
if (_onChange) _onChange(e);
|
|
88
|
+
setValue(e.target.value);
|
|
78
89
|
},
|
|
79
|
-
onCompositionEnd: function onCompositionEnd() {
|
|
90
|
+
onCompositionEnd: function onCompositionEnd(e) {
|
|
91
|
+
if (_onCompositionEnd) _onCompositionEnd(e);
|
|
80
92
|
isChineseInput.current = false;
|
|
81
93
|
},
|
|
82
|
-
onCompositionStart: function onCompositionStart() {
|
|
94
|
+
onCompositionStart: function onCompositionStart(e) {
|
|
95
|
+
if (_onCompositionStart) _onCompositionStart(e);
|
|
83
96
|
isChineseInput.current = true;
|
|
84
97
|
},
|
|
85
98
|
onPressEnter: function onPressEnter(e) {
|
|
99
|
+
if (_onPressEnter) _onPressEnter(e);
|
|
86
100
|
if (!loading && !e.shiftKey && !isChineseInput.current) {
|
|
87
101
|
e.preventDefault();
|
|
88
102
|
handleSend();
|
|
@@ -92,7 +106,7 @@ var ChatInputArea = /*#__PURE__*/memo(function (_ref) {
|
|
|
92
106
|
resize: false,
|
|
93
107
|
type: "pure",
|
|
94
108
|
value: value
|
|
95
|
-
}), /*#__PURE__*/_jsxs("div", {
|
|
109
|
+
})), /*#__PURE__*/_jsxs("div", {
|
|
96
110
|
className: styles.footerBar,
|
|
97
111
|
children: [footer, /*#__PURE__*/_jsx(Button, {
|
|
98
112
|
disabled: disabled,
|
|
@@ -102,6 +116,6 @@ var ChatInputArea = /*#__PURE__*/memo(function (_ref) {
|
|
|
102
116
|
children: "Send"
|
|
103
117
|
})]
|
|
104
118
|
})]
|
|
105
|
-
})
|
|
106
|
-
});
|
|
119
|
+
});
|
|
120
|
+
}));
|
|
107
121
|
export default ChatInputArea;
|
package/es/ChatItem/index.d.ts
CHANGED
|
@@ -2,43 +2,46 @@ import { type AlertProps } from 'antd';
|
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import { MetaData } from "../types/meta";
|
|
4
4
|
export interface ChatItemProps {
|
|
5
|
+
/**
|
|
6
|
+
* @description Actions to be displayed in the chat item
|
|
7
|
+
*/
|
|
5
8
|
actions?: ReactNode;
|
|
6
9
|
/**
|
|
7
|
-
* @description
|
|
10
|
+
* @description Props for Alert component
|
|
8
11
|
*/
|
|
9
12
|
alert?: AlertProps;
|
|
10
13
|
/**
|
|
11
|
-
* @description
|
|
14
|
+
* @description Metadata for the avatar
|
|
12
15
|
*/
|
|
13
16
|
avatar: MetaData;
|
|
14
17
|
/**
|
|
15
|
-
* @description Whether to add spacing
|
|
16
|
-
|
|
18
|
+
* @description Whether to add border spacing
|
|
19
|
+
*/
|
|
20
|
+
borderSpacing?: number | string;
|
|
21
|
+
/**
|
|
22
|
+
* @description Custom CSS class name for the chat item
|
|
17
23
|
*/
|
|
18
|
-
borderSpacing?: boolean;
|
|
19
24
|
className?: string;
|
|
20
25
|
/**
|
|
21
|
-
* @
|
|
22
|
-
* @default false
|
|
26
|
+
* @description Whether the chat item is in editing mode
|
|
23
27
|
*/
|
|
24
28
|
editing?: boolean;
|
|
25
29
|
/**
|
|
26
|
-
* @description Whether
|
|
27
|
-
* @default false
|
|
30
|
+
* @description Whether the chat item is in loading state
|
|
28
31
|
*/
|
|
29
32
|
loading?: boolean;
|
|
30
33
|
/**
|
|
31
|
-
* @description The message
|
|
34
|
+
* @description The message content of the chat item
|
|
32
35
|
*/
|
|
33
36
|
message?: string;
|
|
34
37
|
/**
|
|
35
|
-
* @
|
|
36
|
-
* @param value - The new
|
|
38
|
+
* @description Callback when the message content changes
|
|
39
|
+
* @param value - The new message content
|
|
37
40
|
*/
|
|
38
41
|
onChange?: (value: string) => void;
|
|
39
42
|
/**
|
|
40
|
-
* @
|
|
41
|
-
* @param editing -
|
|
43
|
+
* @description Callback when the editing mode changes
|
|
44
|
+
* @param editing - The new editing mode
|
|
42
45
|
*/
|
|
43
46
|
onEditingChange?: (editing: boolean) => void;
|
|
44
47
|
/**
|
|
@@ -48,20 +51,18 @@ export interface ChatItemProps {
|
|
|
48
51
|
placement?: 'left' | 'right';
|
|
49
52
|
/**
|
|
50
53
|
* @description Whether the chat item is primary
|
|
51
|
-
* @default false
|
|
52
54
|
*/
|
|
53
55
|
primary?: boolean;
|
|
54
56
|
/**
|
|
55
|
-
* @description Whether to show
|
|
56
|
-
* @default false
|
|
57
|
+
* @description Whether to show the title of the chat item
|
|
57
58
|
*/
|
|
58
59
|
showTitle?: boolean;
|
|
59
60
|
/**
|
|
60
|
-
* @description
|
|
61
|
+
* @description The timestamp of the chat item
|
|
61
62
|
*/
|
|
62
63
|
time?: number;
|
|
63
64
|
/**
|
|
64
|
-
* @description The type of chat item
|
|
65
|
+
* @description The type of the chat item
|
|
65
66
|
* @default 'block'
|
|
66
67
|
*/
|
|
67
68
|
type?: 'block' | 'pure';
|
package/es/ChatItem/index.js
CHANGED
|
@@ -18,8 +18,7 @@ var ChatItem = /*#__PURE__*/memo(function (_ref) {
|
|
|
18
18
|
var actions = _ref.actions,
|
|
19
19
|
className = _ref.className,
|
|
20
20
|
primary = _ref.primary,
|
|
21
|
-
|
|
22
|
-
borderSpacing = _ref$borderSpacing === void 0 ? true : _ref$borderSpacing,
|
|
21
|
+
borderSpacing = _ref.borderSpacing,
|
|
23
22
|
loading = _ref.loading,
|
|
24
23
|
message = _ref.message,
|
|
25
24
|
_ref$placement = _ref.placement,
|
|
@@ -36,7 +35,6 @@ var ChatItem = /*#__PURE__*/memo(function (_ref) {
|
|
|
36
35
|
properties = _objectWithoutProperties(_ref, _excluded);
|
|
37
36
|
var _useStyles = useStyles({
|
|
38
37
|
avatarSize: AVATAR_SIZE,
|
|
39
|
-
borderSpacing: borderSpacing,
|
|
40
38
|
placement: placement,
|
|
41
39
|
primary: primary,
|
|
42
40
|
showTitle: showTitle,
|
|
@@ -68,33 +66,37 @@ var ChatItem = /*#__PURE__*/memo(function (_ref) {
|
|
|
68
66
|
})]
|
|
69
67
|
}), /*#__PURE__*/_jsxs("div", {
|
|
70
68
|
className: styles.messageContainer,
|
|
71
|
-
children: [/*#__PURE__*/_jsxs("
|
|
72
|
-
className:
|
|
73
|
-
children: [showTitle ? avatar.title || 'untitled' : undefined, time && /*#__PURE__*/_jsx("
|
|
74
|
-
className: "chat-item-time",
|
|
69
|
+
children: [/*#__PURE__*/_jsxs("title", {
|
|
70
|
+
className: styles.name,
|
|
71
|
+
children: [showTitle ? avatar.title || 'untitled' : undefined, time && /*#__PURE__*/_jsx("time", {
|
|
75
72
|
children: formatTime(time)
|
|
76
73
|
})]
|
|
77
|
-
}),
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
74
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
75
|
+
className: styles.messageContent,
|
|
76
|
+
children: [alert ? /*#__PURE__*/_jsx(Alert, _objectSpread({
|
|
77
|
+
className: styles.alert,
|
|
78
|
+
showIcon: true
|
|
79
|
+
}, alert)) : /*#__PURE__*/_jsx("div", {
|
|
80
|
+
className: styles.message,
|
|
81
|
+
style: editing ? {
|
|
82
|
+
padding: 12
|
|
83
|
+
} : {},
|
|
84
|
+
children: /*#__PURE__*/_jsx(EditableMessage, {
|
|
85
|
+
editing: editing,
|
|
86
|
+
onChange: onChange,
|
|
87
|
+
onEditingChange: onEditingChange,
|
|
88
|
+
value: String(message || '...')
|
|
89
|
+
})
|
|
90
|
+
}), !editing && /*#__PURE__*/_jsx("div", {
|
|
91
|
+
className: styles.actions,
|
|
92
|
+
role: "chat-item-actions",
|
|
93
|
+
children: actions
|
|
94
|
+
})]
|
|
93
95
|
})]
|
|
94
96
|
}), borderSpacing && /*#__PURE__*/_jsx("div", {
|
|
95
97
|
style: {
|
|
96
98
|
flex: 'none',
|
|
97
|
-
width:
|
|
99
|
+
width: borderSpacing
|
|
98
100
|
}
|
|
99
101
|
})]
|
|
100
102
|
}));
|
package/es/ChatItem/style.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
export declare const useStyles: (props?: {
|
|
2
2
|
avatarSize: number;
|
|
3
|
-
borderSpacing: boolean;
|
|
4
3
|
placement?: "left" | "right" | undefined;
|
|
5
4
|
primary?: boolean | undefined;
|
|
6
5
|
showTitle?: boolean | undefined;
|
|
7
6
|
title?: string | undefined;
|
|
8
7
|
type?: "block" | "pure" | undefined;
|
|
9
8
|
} | undefined) => import("antd-style").ReturnStyles<{
|
|
10
|
-
actions:
|
|
9
|
+
actions: import("antd-style").SerializedStyles;
|
|
10
|
+
alert: import("antd-style").SerializedStyles;
|
|
11
11
|
avatarContainer: import("antd-style").SerializedStyles;
|
|
12
12
|
container: string;
|
|
13
13
|
loading: import("antd-style").SerializedStyles;
|
|
14
14
|
message: string;
|
|
15
15
|
messageContainer: import("antd-style").SerializedStyles;
|
|
16
|
+
messageContent: import("antd-style").SerializedStyles;
|
|
16
17
|
name: import("antd-style").SerializedStyles;
|
|
17
18
|
}>;
|
package/es/ChatItem/style.js
CHANGED
|
@@ -10,19 +10,20 @@ export var useStyles = createStyles(function (_ref, _ref2) {
|
|
|
10
10
|
title = _ref2.title,
|
|
11
11
|
primary = _ref2.primary,
|
|
12
12
|
avatarSize = _ref2.avatarSize,
|
|
13
|
-
showTitle = _ref2.showTitle
|
|
14
|
-
borderSpacing = _ref2.borderSpacing;
|
|
13
|
+
showTitle = _ref2.showTitle;
|
|
15
14
|
var blockStylish = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding: 8px 12px;\n background-color: ", ";\n border-radius: ", "px;\n transition: background-color 100ms ", ";\n "])), primary ? token.colorFillSecondary : token.colorFillTertiary, token.borderRadiusLG, token.motionEaseOut);
|
|
16
15
|
var pureStylish = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n padding-top: ", ";\n "])), title ? 0 : '6px');
|
|
17
16
|
var pureContainerStylish = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n transition: background-color 100ms ", ";\n "])), token.motionEaseOut);
|
|
18
17
|
var typeStylish = type === 'block' ? blockStylish : pureStylish;
|
|
19
18
|
return {
|
|
20
|
-
actions:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
actions: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n display: flex;\n align-items: flex-start;\n align-self: ", ";\n justify-content: ", ";\n "])), type === 'block' ? 'flex-end' : placement === 'left' ? 'flex-start' : 'flex-end', placement === 'left' ? 'flex-end' : 'flex-start'),
|
|
20
|
+
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 "]))),
|
|
21
|
+
avatarContainer: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n position: relative;\n flex: none;\n width: ", "px;\n height: ", "px;\n "])), avatarSize, avatarSize),
|
|
22
|
+
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)),
|
|
23
|
+
loading: css(_templateObject8 || (_templateObject8 = _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),
|
|
24
|
+
message: cx(typeStylish, css(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n position: relative;\n "])))),
|
|
25
|
+
messageContainer: css(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n position: relative;\n display: flex;\n flex-direction: column;\n align-items: ", ";\n "])), placement === 'left' ? 'flex-start' : 'flex-end'),
|
|
26
|
+
messageContent: css(_templateObject11 || (_templateObject11 = _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'),
|
|
26
27
|
name: css(_templateObject12 || (_templateObject12 = _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')
|
|
27
28
|
};
|
|
28
29
|
});
|
package/es/ChatList/index.d.ts
CHANGED
|
@@ -7,7 +7,12 @@ export interface ChatListProps extends DivProps {
|
|
|
7
7
|
* @description Data of chat messages to be displayed
|
|
8
8
|
*/
|
|
9
9
|
data: ChatMessage[];
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* @description Callback function triggered when an action is clicked
|
|
12
|
+
* @param {string} actionKey - The key of the action
|
|
13
|
+
* @param {string} messageId - The id of the message
|
|
14
|
+
*/
|
|
15
|
+
onActionClick?: (actionKey: string, messageId: string) => void;
|
|
11
16
|
/**
|
|
12
17
|
* @description Whether to show name of the chat item
|
|
13
18
|
* @default false
|
package/es/ChatList/index.js
CHANGED
|
@@ -9,7 +9,8 @@ import ActionsBar from "./ActionsBar";
|
|
|
9
9
|
import { useStyles } from "./style";
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
var ChatList = /*#__PURE__*/memo(function (_ref) {
|
|
12
|
-
var
|
|
12
|
+
var _ref$onActionClick = _ref.onActionClick,
|
|
13
|
+
_onActionClick = _ref$onActionClick === void 0 ? function () {} : _ref$onActionClick,
|
|
13
14
|
className = _ref.className,
|
|
14
15
|
data = _ref.data,
|
|
15
16
|
_ref$type = _ref.type,
|
|
@@ -31,7 +32,6 @@ var ChatList = /*#__PURE__*/memo(function (_ref) {
|
|
|
31
32
|
primary: item.role === 'user'
|
|
32
33
|
}),
|
|
33
34
|
avatar: item.meta,
|
|
34
|
-
borderSpacing: type === 'chat',
|
|
35
35
|
message: item.content,
|
|
36
36
|
placement: type === 'chat' ? item.role === 'user' ? 'right' : 'left' : 'left',
|
|
37
37
|
primary: item.role === 'user',
|
|
@@ -70,6 +70,10 @@ var DraggablePanel = /*#__PURE__*/memo(function (_ref) {
|
|
|
70
70
|
_useState2 = _slicedToArray(_useState, 2),
|
|
71
71
|
showExpand = _useState2[0],
|
|
72
72
|
setShowExpand = _useState2[1];
|
|
73
|
+
var _useState3 = useState(false),
|
|
74
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
75
|
+
isResizing = _useState4[0],
|
|
76
|
+
setIsResizing = _useState4[1];
|
|
73
77
|
var canResizing = resize !== false && isExpand;
|
|
74
78
|
var resizeHandleClassNames = useMemo(function () {
|
|
75
79
|
if (!canResizing) return {};
|
|
@@ -185,16 +189,20 @@ var DraggablePanel = /*#__PURE__*/memo(function (_ref) {
|
|
|
185
189
|
});
|
|
186
190
|
},
|
|
187
191
|
onResizeStart: function onResizeStart() {
|
|
192
|
+
setIsResizing(true);
|
|
188
193
|
setShowExpand(false);
|
|
189
194
|
},
|
|
190
195
|
onResizeStop: function onResizeStop(e, direction, reference_, delta) {
|
|
196
|
+
setIsResizing(false);
|
|
191
197
|
setShowExpand(true);
|
|
192
198
|
onSizeChange === null || onSizeChange === void 0 ? void 0 : onSizeChange(delta, {
|
|
193
199
|
height: reference_.style.height,
|
|
194
200
|
width: reference_.style.width
|
|
195
201
|
});
|
|
196
202
|
},
|
|
197
|
-
style:
|
|
203
|
+
style: _objectSpread({
|
|
204
|
+
transition: isResizing ? 'unset' : undefined
|
|
205
|
+
}, style),
|
|
198
206
|
children: children
|
|
199
207
|
}));
|
|
200
208
|
if (fullscreen) return /*#__PURE__*/_jsx("div", {
|
|
@@ -206,7 +214,7 @@ var DraggablePanel = /*#__PURE__*/memo(function (_ref) {
|
|
|
206
214
|
// @ts-ignore
|
|
207
215
|
styles[mode === 'fixed' ? 'fixed' : "".concat(placement, "Float")], className),
|
|
208
216
|
ref: reference,
|
|
209
|
-
style: _defineProperty({}, "border".concat(arrowPlacement, "Width"), 1),
|
|
217
|
+
style: isExpand ? _defineProperty({}, "border".concat(arrowPlacement, "Width"), 1) : {},
|
|
210
218
|
children: [expandable && showExpand && handler, destroyOnClose ? isExpand && inner : inner]
|
|
211
219
|
});
|
|
212
220
|
});
|
|
@@ -10,7 +10,7 @@ export var generateCustomStylish = function generateCustomStylish(_ref) {
|
|
|
10
10
|
blur: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n backdrop-filter: saturate(180%) blur(10px);\n "]))),
|
|
11
11
|
bottomScrollbar: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n ::-webkit-scrollbar {\n width: 0;\n height: 4px;\n background-color: transparent;\n\n &-thumb {\n background-color: ", ";\n border-radius: 4px;\n transition: background-color 500ms ", ";\n }\n\n &-corner {\n display: none;\n width: 0;\n height: 0;\n }\n }\n "])), token.colorFill, token.motionEaseOut),
|
|
12
12
|
gradientAnimation: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n background-image: linear-gradient(\n -45deg,\n ", ",\n ", ",\n ", ",\n ", "\n );\n background-size: 400% 400%;\n border-radius: inherit;\n animation: 5s ", " 5s ease infinite;\n "])), token.gold, token.magenta, token.geekblue, token.cyan, gradient),
|
|
13
|
-
markdown: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n color: ", ";\n\n h1,\n h2,\n h3,\n h4,\n h5 {\n font-weight: 600;\n }\n\n p {\n margin-block-start: 0;\n margin-block-end: 0;\n\n font-size: 14px;\n line-height: 1.8;\n color: ", ";\n text-align: justify;\n word-wrap: break-word;\n\n + * {\n margin-block-end: 0.5em;\n }\n }\n\n blockquote {\n margin: 16px 0;\n padding: 0 12px;\n\n p {\n font-style: italic;\n color: ", ";\n }\n }\n\n p:not(:last-child) {\n margin-bottom: 1em;\n }\n\n a {\n color: ", ";\n\n &:hover {\n color: ", ";\n }\n\n &:active {\n color: ", ";\n }\n }\n\n img {\n max-width: 100%;\n }\n\n pre {\n border: none;\n border-radius: ", "px;\n }\n\n > :not([data-code-type='highlighter']) code {\n padding: 2px 6px;\n\n font-size: ", "px;\n color: ", ";\n\n background: ", ";\n border: 1px solid ", ";\n border-radius: ", "px;\n }\n\n table {\n border-spacing: 0;\n\n width: 100%;\n margin-block-start: 1em;\n margin-block-end: 1em;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 8px;\n\n border: 1px solid ", ";\n border-radius: ", "px;\n }\n\n th,\n td {\n padding-block-start: 10px;\n padding-block-end: 10px;\n padding-inline-start: 16px;\n padding-inline-end: 16px;\n }\n\n thead {\n tr {\n th {\n background: ", ";\n\n &:first-child {\n border-top-left-radius: ", "px;\n border-bottom-left-radius: ", "px;\n }\n\n &:last-child {\n border-top-right-radius: ", "px;\n border-bottom-right-radius: ", "px;\n }\n }\n }\n }\n\n li {\n line-height: 1.8;\n\n &::marker {\n color: ", ";\n }\n }\n\n details {\n margin-bottom: 1em;\n padding: 12px 16px;\n\n background: ", ";\n border: 1px solid ", ";\n border-radius: ", "px;\n\n transition: all 400ms ", ";\n }\n\n details[open] {\n summary {\n padding-bottom: 12px;\n border-bottom: 1px solid ", ";\n }\n }\n "])), isDarkMode ? token.colorTextSecondary : token.colorText, token.colorText, token.colorTextDescription, token.colorLink, token.colorLinkHover, token.colorLinkActive, token.borderRadius, token.fontSizeSM, isDarkMode ? token.cyan9A : token.cyan10A, isDarkMode ? token.cyan1A : token.cyan3A, isDarkMode ? token.cyan1A : token.cyan4A, token.borderRadiusSM, token.colorBorderSecondary, token.borderRadius, token.colorFillTertiary, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius, isDarkMode ? token.cyan9A : token.cyan10A, token.colorFillTertiary, token.colorBorderSecondary, token.borderRadiusLG, token.motionEaseOut, token.colorBorder),
|
|
13
|
+
markdown: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n color: ", ";\n\n h1,\n h2,\n h3,\n h4,\n h5 {\n font-weight: 600;\n }\n\n p {\n margin-block-start: 0;\n margin-block-end: 0;\n\n font-size: 14px;\n line-height: 1.8;\n color: ", ";\n text-align: justify;\n word-break: break-all;\n word-wrap: break-word;\n\n + * {\n margin-block-end: 0.5em;\n }\n }\n\n blockquote {\n margin: 16px 0;\n padding: 0 12px;\n\n p {\n font-style: italic;\n color: ", ";\n }\n }\n\n p:not(:last-child) {\n margin-bottom: 1em;\n }\n\n a {\n color: ", ";\n\n &:hover {\n color: ", ";\n }\n\n &:active {\n color: ", ";\n }\n }\n\n img {\n max-width: 100%;\n }\n\n pre {\n border: none;\n border-radius: ", "px;\n }\n\n > :not([data-code-type='highlighter']) code {\n padding: 2px 6px;\n\n font-size: ", "px;\n color: ", ";\n\n background: ", ";\n border: 1px solid ", ";\n border-radius: ", "px;\n }\n\n table {\n border-spacing: 0;\n\n width: 100%;\n margin-block-start: 1em;\n margin-block-end: 1em;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding: 8px;\n\n border: 1px solid ", ";\n border-radius: ", "px;\n }\n\n th,\n td {\n padding-block-start: 10px;\n padding-block-end: 10px;\n padding-inline-start: 16px;\n padding-inline-end: 16px;\n }\n\n thead {\n tr {\n th {\n background: ", ";\n\n &:first-child {\n border-top-left-radius: ", "px;\n border-bottom-left-radius: ", "px;\n }\n\n &:last-child {\n border-top-right-radius: ", "px;\n border-bottom-right-radius: ", "px;\n }\n }\n }\n }\n\n li {\n line-height: 1.8;\n\n &::marker {\n color: ", ";\n }\n }\n\n details {\n margin-bottom: 1em;\n padding: 12px 16px;\n\n background: ", ";\n border: 1px solid ", ";\n border-radius: ", "px;\n\n transition: all 400ms ", ";\n }\n\n details[open] {\n summary {\n padding-bottom: 12px;\n border-bottom: 1px solid ", ";\n }\n }\n "])), isDarkMode ? token.colorTextSecondary : token.colorText, token.colorText, token.colorTextDescription, token.colorLink, token.colorLinkHover, token.colorLinkActive, token.borderRadius, token.fontSizeSM, isDarkMode ? token.cyan9A : token.cyan10A, isDarkMode ? token.cyan1A : token.cyan3A, isDarkMode ? token.cyan1A : token.cyan4A, token.borderRadiusSM, token.colorBorderSecondary, token.borderRadius, token.colorFillTertiary, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius, isDarkMode ? token.cyan9A : token.cyan10A, token.colorFillTertiary, token.colorBorderSecondary, token.borderRadiusLG, token.motionEaseOut, token.colorBorder),
|
|
14
14
|
noScrollbar: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n ::-webkit-scrollbar {\n display: none;\n width: 0;\n height: 0;\n background-color: transparent;\n }\n "]))),
|
|
15
15
|
resetLinkColor: css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n cursor: pointer;\n color: ", ";\n\n &:hover {\n color: ", ";\n }\n "])), token.colorTextSecondary, token.colorText)
|
|
16
16
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.36.0",
|
|
4
4
|
"description": "Lobe UI is an open-source UI component library for building chatbot web apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lobehub",
|
|
@@ -114,6 +114,7 @@
|
|
|
114
114
|
"@types/react-dom": "^18",
|
|
115
115
|
"@vitest/coverage-v8": "latest",
|
|
116
116
|
"antd-style": "^3",
|
|
117
|
+
"babel-plugin-antd-style": "latest",
|
|
117
118
|
"commitlint": "^17",
|
|
118
119
|
"concurrently": "^8",
|
|
119
120
|
"cross-env": "^7",
|