@lobehub/ui 1.65.0 → 1.66.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/ChatList/index.d.ts +7 -2
- package/es/ChatList/index.js +11 -3
- package/es/List/ListItem/index.js +25 -17
- package/es/List/ListItem/style.js +3 -3
- package/package.json +1 -1
package/es/ChatList/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import type { ChatMessage, DivProps } from "../types";
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import type { ChatMessage, DivProps, MessageRoleType } from "../types";
|
|
3
3
|
import { ListItemProps } from './Item';
|
|
4
4
|
export interface ChatListProps extends DivProps, ListItemProps {
|
|
5
5
|
/**
|
|
@@ -7,6 +7,11 @@ export interface ChatListProps extends DivProps, ListItemProps {
|
|
|
7
7
|
*/
|
|
8
8
|
data: ChatMessage[];
|
|
9
9
|
loadingId?: string;
|
|
10
|
+
renderItem?: {
|
|
11
|
+
[role: MessageRoleType | string]: (data: {
|
|
12
|
+
key: string;
|
|
13
|
+
} & ChatMessage & ListItemProps) => ReactNode;
|
|
14
|
+
};
|
|
10
15
|
}
|
|
11
16
|
export type { OnActionClick, OnMessageChange, RenderErrorMessage, RenderMessage } from './Item';
|
|
12
17
|
declare const ChatList: import("react").NamedExoticComponent<ChatListProps>;
|
package/es/ChatList/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["onActionClick", "renderMessageExtra", "className", "data", "type", "text", "showTitle", "onMessageChange", "renderMessage", "renderErrorMessage", "loadingId"];
|
|
3
|
+
var _excluded = ["onActionClick", "renderMessageExtra", "className", "data", "type", "text", "showTitle", "onMessageChange", "renderMessage", "renderErrorMessage", "loadingId", "renderItem"];
|
|
4
4
|
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
5
|
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
6
|
import { memo } from 'react';
|
|
@@ -20,6 +20,7 @@ var ChatList = /*#__PURE__*/memo(function (_ref) {
|
|
|
20
20
|
renderMessage = _ref.renderMessage,
|
|
21
21
|
renderErrorMessage = _ref.renderErrorMessage,
|
|
22
22
|
loadingId = _ref.loadingId,
|
|
23
|
+
renderItem = _ref.renderItem,
|
|
23
24
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
24
25
|
var _useStyles = useStyles(),
|
|
25
26
|
cx = _useStyles.cx,
|
|
@@ -28,7 +29,8 @@ var ChatList = /*#__PURE__*/memo(function (_ref) {
|
|
|
28
29
|
className: cx(styles.container, className)
|
|
29
30
|
}, props), {}, {
|
|
30
31
|
children: data.map(function (item) {
|
|
31
|
-
|
|
32
|
+
var key = item.id;
|
|
33
|
+
var props = _objectSpread({
|
|
32
34
|
loading: loadingId === item.id,
|
|
33
35
|
onActionClick: onActionClick,
|
|
34
36
|
onMessageChange: onMessageChange,
|
|
@@ -38,7 +40,13 @@ var ChatList = /*#__PURE__*/memo(function (_ref) {
|
|
|
38
40
|
showTitle: showTitle,
|
|
39
41
|
text: text,
|
|
40
42
|
type: type
|
|
41
|
-
}, item)
|
|
43
|
+
}, item);
|
|
44
|
+
if (renderItem && renderItem[item.role]) {
|
|
45
|
+
return renderItem[item.role](_objectSpread({
|
|
46
|
+
key: key
|
|
47
|
+
}, props));
|
|
48
|
+
}
|
|
49
|
+
return /*#__PURE__*/_jsx(Item, _objectSpread({}, props), key);
|
|
42
50
|
})
|
|
43
51
|
}));
|
|
44
52
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["active", "avatar", "loading", "description", "date", "title", "onHoverChange", "actions", "className", "style", "showAction", "children", "classNames", "pin"];
|
|
3
|
+
var _excluded = ["active", "avatar", "loading", "description", "date", "title", "onHoverChange", "actions", "className", "style", "showAction", "children", "classNames", "addon", "pin"];
|
|
4
4
|
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
5
|
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
6
|
import { LoadingOutlined, MessageOutlined } from '@ant-design/icons';
|
|
@@ -14,6 +14,7 @@ import { getChatItemTime } from "./time";
|
|
|
14
14
|
*/
|
|
15
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
16
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
17
18
|
var ListItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
18
19
|
var active = _ref.active,
|
|
19
20
|
avatar = _ref.avatar,
|
|
@@ -29,6 +30,7 @@ var ListItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
29
30
|
children = _ref.children,
|
|
30
31
|
_ref$classNames = _ref.classNames,
|
|
31
32
|
classNames = _ref$classNames === void 0 ? {} : _ref$classNames,
|
|
33
|
+
addon = _ref.addon,
|
|
32
34
|
pin = _ref.pin,
|
|
33
35
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
34
36
|
var _useStyles = useStyles(pin),
|
|
@@ -58,6 +60,7 @@ var ListItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
58
60
|
}
|
|
59
61
|
}), /*#__PURE__*/_jsxs(Flexbox, {
|
|
60
62
|
className: styles.content,
|
|
63
|
+
gap: 8,
|
|
61
64
|
children: [/*#__PURE__*/_jsx(Flexbox, {
|
|
62
65
|
distribution: 'space-between',
|
|
63
66
|
horizontal: true,
|
|
@@ -68,24 +71,29 @@ var ListItem = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
68
71
|
}), description && /*#__PURE__*/_jsx("div", {
|
|
69
72
|
className: styles.desc,
|
|
70
73
|
children: description
|
|
71
|
-
})]
|
|
74
|
+
}), addon]
|
|
72
75
|
}), loading ? /*#__PURE__*/_jsx(LoadingOutlined, {
|
|
73
76
|
spin: true
|
|
74
|
-
}) :
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
e
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
77
|
+
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
78
|
+
children: [showAction && /*#__PURE__*/_jsx(Flexbox, {
|
|
79
|
+
className: styles.actions,
|
|
80
|
+
gap: 4,
|
|
81
|
+
horizontal: true,
|
|
82
|
+
onClick: function onClick(e) {
|
|
83
|
+
e.preventDefault();
|
|
84
|
+
e.stopPropagation();
|
|
85
|
+
},
|
|
86
|
+
style: {
|
|
87
|
+
display: showAction ? undefined : 'none'
|
|
88
|
+
},
|
|
89
|
+
children: actions
|
|
90
|
+
}), date && /*#__PURE__*/_jsx("div", {
|
|
91
|
+
className: cx(styles.time, classNames.time),
|
|
92
|
+
style: showAction ? {
|
|
93
|
+
opacity: 0
|
|
94
|
+
} : {},
|
|
95
|
+
children: getChatItemTime(date)
|
|
96
|
+
})]
|
|
89
97
|
}), children]
|
|
90
98
|
})
|
|
91
99
|
}));
|
|
@@ -8,10 +8,10 @@ export var useStyles = createStyles(function (_ref, pin) {
|
|
|
8
8
|
actions: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: absolute;\n top: 50%;\n right: 16px;\n transform: translateY(-50%);\n "]))),
|
|
9
9
|
active: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n color: ", ";\n background-color: ", ";\n\n &:hover {\n background-color: ", ";\n }\n "])), token.colorText, token.colorFillSecondary, token.colorFill),
|
|
10
10
|
container: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n cursor: pointer;\n color: ", ";\n background: ", ";\n transition: background-color 200ms ", ";\n\n &:active {\n background-color: ", " !important;\n }\n\n &:hover {\n background-color: ", ";\n }\n "])), token.colorTextTertiary, pin ? token.colorFillTertiary : 'transparent', token.motionEaseOut, pin ? token.colorFill : token.colorFillSecondary, pin ? token.colorFill : token.colorFillTertiary),
|
|
11
|
-
content: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n position: relative;\n overflow: hidden;\n flex: 1;\n "]))),
|
|
12
|
-
desc: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n overflow: hidden;\n\n width: 100%;\n
|
|
11
|
+
content: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n position: relative;\n overflow: hidden;\n flex: 1;\n padding-top: 6px;\n "]))),
|
|
12
|
+
desc: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n overflow: hidden;\n\n width: 100%;\n\n font-size: 12px;\n line-height: 1;\n color: ", ";\n text-overflow: ellipsis;\n white-space: nowrap;\n "])), token.colorTextDescription),
|
|
13
13
|
pin: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n background-color: ", ";\n "])), token.colorFillTertiary),
|
|
14
14
|
time: css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n font-size: 12px;\n color: ", ";\n "])), token.colorTextPlaceholder),
|
|
15
|
-
title: css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n overflow: hidden;\n\n width: 100%;\n\n font-size: 16px;\n color: ", ";\n text-overflow: ellipsis;\n white-space: nowrap;\n "])), token.colorText)
|
|
15
|
+
title: css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n overflow: hidden;\n\n width: 100%;\n\n font-size: 16px;\n line-height: 1;\n color: ", ";\n text-overflow: ellipsis;\n white-space: nowrap;\n "])), token.colorText)
|
|
16
16
|
};
|
|
17
17
|
});
|