@lobehub/ui 1.64.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.
@@ -4,6 +4,7 @@ export interface ActionProps {
4
4
  * @description Actions to be displayed in the input area
5
5
  */
6
6
  actions?: ReactNode;
7
+ actionsRight?: ReactNode;
7
8
  expand?: boolean;
8
9
  onExpandChange?: (expand: boolean) => void;
9
10
  }
@@ -16,6 +16,7 @@ var useStyles = createStyles(function (_ref) {
16
16
  });
17
17
  var Action = /*#__PURE__*/memo(function (_ref2) {
18
18
  var actions = _ref2.actions,
19
+ actionsRight = _ref2.actionsRight,
19
20
  expand = _ref2.expand,
20
21
  onExpandChange = _ref2.onExpandChange;
21
22
  var _useStyles = useStyles(),
@@ -28,12 +29,12 @@ var Action = /*#__PURE__*/memo(function (_ref2) {
28
29
  children: [/*#__PURE__*/_jsx("div", {
29
30
  className: styles.actionLeft,
30
31
  children: actions
31
- }), /*#__PURE__*/_jsx("div", {
32
+ }), /*#__PURE__*/_jsxs("div", {
32
33
  className: styles.actionsRight,
33
- children: /*#__PURE__*/_jsx(ActionIcon, {
34
+ children: [actionsRight, /*#__PURE__*/_jsx(ActionIcon, {
34
35
  icon: expand ? Minimize2 : Maximize2,
35
36
  onClick: handleExpandClick
36
- })
37
+ })]
37
38
  })]
38
39
  });
39
40
  });
@@ -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", "textareaClassName", "style", "textareaStyle", "minHeight", "className", "actions", "footer", "expand", "placeholder", "onExpandChange", "onSend", "defaultValue", "loading", "disabled", "onInputChange", "onPressEnter", "onCompositionStart", "onCompositionEnd", "onBlur", "onChange", "textareaId"];
4
+ var _excluded = ["text", "textareaClassName", "style", "textareaStyle", "minHeight", "className", "actions", "footer", "expand", "placeholder", "onExpandChange", "onSend", "defaultValue", "loading", "disabled", "onInputChange", "onPressEnter", "onCompositionStart", "onCompositionEnd", "onBlur", "onChange", "textareaId", "actionsRight"];
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';
@@ -39,6 +39,7 @@ var ChatInputArea = /*#__PURE__*/forwardRef(function (_ref, ref) {
39
39
  _onChange = _ref.onChange,
40
40
  _ref$textareaId = _ref.textareaId,
41
41
  textareaId = _ref$textareaId === void 0 ? 'lobe-chat-input-area' : _ref$textareaId,
42
+ actionsRight = _ref.actionsRight,
42
43
  props = _objectWithoutProperties(_ref, _excluded);
43
44
  var _useStyles = useStyles(),
44
45
  cx = _useStyles.cx,
@@ -63,6 +64,7 @@ var ChatInputArea = /*#__PURE__*/forwardRef(function (_ref, ref) {
63
64
  }, style),
64
65
  children: [/*#__PURE__*/_jsx(Action, {
65
66
  actions: actions,
67
+ actionsRight: actionsRight,
66
68
  expand: expand,
67
69
  onExpandChange: onExpandChange
68
70
  }), /*#__PURE__*/_jsxs("div", {
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
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>;
@@ -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
- return /*#__PURE__*/_jsx(Item, _objectSpread({
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), item.id);
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
- }) : showAction ? /*#__PURE__*/_jsx(Flexbox, {
75
- className: styles.actions,
76
- gap: 4,
77
- horizontal: true,
78
- onClick: function onClick(e) {
79
- e.preventDefault();
80
- e.stopPropagation();
81
- },
82
- style: {
83
- display: showAction ? undefined : 'none'
84
- },
85
- children: actions
86
- }) : date && /*#__PURE__*/_jsx("div", {
87
- className: cx(styles.time, classNames.time),
88
- children: getChatItemTime(date)
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 margin-top: 2px;\n\n font-size: 12px;\n color: ", ";\n text-overflow: ellipsis;\n white-space: nowrap;\n "])), token.colorTextDescription),
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
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "1.64.0",
4
- "description": "Lobe UI is an open-source UI component library for building chatbot web apps",
3
+ "version": "1.66.0",
4
+ "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",
7
7
  "components",