@lobehub/ui 1.48.0 → 1.49.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.
@@ -34,6 +34,7 @@ export interface ChatItemProps {
34
34
  * @description The message content of the chat item
35
35
  */
36
36
  message?: string;
37
+ messageExtra?: ReactNode;
37
38
  /**
38
39
  * @description Callback when the message content changes
39
40
  * @param value - The new message content
@@ -1,11 +1,12 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
- var _excluded = ["actions", "className", "primary", "borderSpacing", "loading", "message", "placement", "type", "avatar", "alert", "showTitle", "time", "editing", "onChange", "onEditingChange"];
3
+ var _excluded = ["actions", "className", "primary", "borderSpacing", "loading", "message", "placement", "type", "avatar", "alert", "showTitle", "time", "editing", "onChange", "onEditingChange", "messageExtra"];
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 { Alert } from 'antd';
7
7
  import { Loader2 } from 'lucide-react';
8
8
  import { memo } from 'react';
9
+ import { Flexbox } from 'react-layout-kit';
9
10
  import Avatar from "../Avatar";
10
11
  import EditableMessage from "../EditableMessage";
11
12
  import Icon from "../Icon";
@@ -32,6 +33,7 @@ var ChatItem = /*#__PURE__*/memo(function (_ref) {
32
33
  editing = _ref.editing,
33
34
  onChange = _ref.onChange,
34
35
  onEditingChange = _ref.onEditingChange,
36
+ messageExtra = _ref.messageExtra,
35
37
  properties = _objectWithoutProperties(_ref, _excluded);
36
38
  var _useStyles = useStyles({
37
39
  avatarSize: AVATAR_SIZE,
@@ -76,17 +78,20 @@ var ChatItem = /*#__PURE__*/memo(function (_ref) {
76
78
  children: [alert ? /*#__PURE__*/_jsx(Alert, _objectSpread({
77
79
  className: styles.alert,
78
80
  showIcon: true
79
- }, alert)) : /*#__PURE__*/_jsx("div", {
81
+ }, alert)) : /*#__PURE__*/_jsxs(Flexbox, {
80
82
  className: styles.message,
81
83
  style: editing ? {
82
84
  padding: 12
83
85
  } : {},
84
- children: /*#__PURE__*/_jsx(EditableMessage, {
86
+ children: [/*#__PURE__*/_jsx(EditableMessage, {
85
87
  editing: editing,
86
88
  onChange: onChange,
87
89
  onEditingChange: onEditingChange,
88
90
  value: String(message || '...')
89
- })
91
+ }), messageExtra ? /*#__PURE__*/_jsx("div", {
92
+ className: styles.messageExtra,
93
+ children: messageExtra
94
+ }) : null]
90
95
  }), !editing && /*#__PURE__*/_jsx("div", {
91
96
  className: styles.actions,
92
97
  role: "chat-item-actions",
@@ -14,5 +14,6 @@ export declare const useStyles: (props?: {
14
14
  message: string;
15
15
  messageContainer: import("antd-style").SerializedStyles;
16
16
  messageContent: import("antd-style").SerializedStyles;
17
+ messageExtra: string;
17
18
  name: import("antd-style").SerializedStyles;
18
19
  }>;
@@ -26,6 +26,7 @@ export var useStyles = createStyles(function (_ref, _ref2) {
26
26
  message: cx(typeStylish, css(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n position: relative;\n "])))),
27
27
  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'),
28
28
  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'),
29
+ messageExtra: cx('message-extra'),
29
30
  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')
30
31
  };
31
32
  });
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import { ReactNode } from 'react';
2
2
  import { ChatItemProps } from "../ChatItem";
3
3
  import type { DivProps } from "../types";
4
4
  import { ChatMessage } from "../types/chatMessage";
@@ -13,6 +13,7 @@ export interface ChatListProps extends DivProps {
13
13
  * @param {string} messageId - The id of the message
14
14
  */
15
15
  onActionClick?: (actionKey: string, messageId: string) => void;
16
+ renderMessageExtra?: (props: ChatMessage) => ReactNode;
16
17
  /**
17
18
  * @description Whether to show name of the chat item
18
19
  * @default false
@@ -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", "className", "data", "type", "showTitle"];
3
+ var _excluded = ["onActionClick", "renderMessageExtra", "className", "data", "type", "showTitle"];
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';
@@ -10,6 +10,7 @@ import { useStyles } from "./style";
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
11
  var ChatList = /*#__PURE__*/memo(function (_ref) {
12
12
  var onActionClick = _ref.onActionClick,
13
+ MessageExtra = _ref.renderMessageExtra,
13
14
  className = _ref.className,
14
15
  data = _ref.data,
15
16
  _ref$type = _ref.type,
@@ -23,6 +24,7 @@ var ChatList = /*#__PURE__*/memo(function (_ref) {
23
24
  className: cx(styles.container, className)
24
25
  }, props), {}, {
25
26
  children: data.map(function (item) {
27
+ var renderMessageExtra = MessageExtra ? /*#__PURE__*/_jsx(MessageExtra, _objectSpread({}, item)) : undefined;
26
28
  return /*#__PURE__*/_jsx(ChatItem, {
27
29
  actions: /*#__PURE__*/_jsx(ActionsBar, {
28
30
  onActionClick: onActionClick ? function (actionKey) {
@@ -32,6 +34,7 @@ var ChatList = /*#__PURE__*/memo(function (_ref) {
32
34
  }),
33
35
  avatar: item.meta,
34
36
  message: item.content,
37
+ messageExtra: renderMessageExtra,
35
38
  placement: type === 'chat' ? item.role === 'user' ? 'right' : 'left' : 'left',
36
39
  primary: item.role === 'user',
37
40
  showTitle: showTitle,
@@ -44,7 +44,7 @@ export interface EditableMessageProps {
44
44
  * @default false
45
45
  */
46
46
  showEditWhenEmpty?: boolean;
47
- style?: {
47
+ styles?: {
48
48
  /**
49
49
  * @title The style for the MessageInput component
50
50
  */
@@ -20,7 +20,7 @@ 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
- style = _ref.style;
23
+ styles = _ref.styles;
24
24
  var _useControlledState = useControlledState(false, {
25
25
  onChange: onEditingChange,
26
26
  value: editing
@@ -46,7 +46,7 @@ var EditableMessage = /*#__PURE__*/memo(function (_ref) {
46
46
  setTyping(false);
47
47
  },
48
48
  placeholder: placeholder,
49
- style: style === null || style === void 0 ? void 0 : style.input
49
+ style: styles === null || styles === void 0 ? void 0 : styles.input
50
50
  }) : /*#__PURE__*/_jsxs(_Fragment, {
51
51
  children: [/*#__PURE__*/_jsx(MessageModal, {
52
52
  editing: isEdit,
@@ -68,10 +68,10 @@ var EditableMessage = /*#__PURE__*/memo(function (_ref) {
68
68
  setTyping(false);
69
69
  },
70
70
  placeholder: placeholder,
71
- style: style === null || style === void 0 ? void 0 : style.input
71
+ style: styles === null || styles === void 0 ? void 0 : styles.input
72
72
  }) : /*#__PURE__*/_jsx(Markdown, {
73
73
  className: classNames === null || classNames === void 0 ? void 0 : classNames.markdown,
74
- style: style === null || style === void 0 ? void 0 : style.markdown,
74
+ style: styles === null || styles === void 0 ? void 0 : styles.markdown,
75
75
  children: value
76
76
  })]
77
77
  });
@@ -30,28 +30,30 @@ var MessageInput = /*#__PURE__*/memo(function (_ref) {
30
30
  _useState2 = _slicedToArray(_useState, 2),
31
31
  temporarySystemRole = _useState2[0],
32
32
  setRole = _useState2[1];
33
- return /*#__PURE__*/_jsxs(Flexbox, _objectSpread(_objectSpread({
34
- gap: 8,
35
- style: {
36
- flex: 1,
37
- width: '100%'
38
- }
39
- }, props), {}, {
40
- children: [/*#__PURE__*/_jsx(CodeEditor, {
41
- className: textareaClassname,
42
- language: "md",
43
- onValueChange: function onValueChange(value) {
44
- setRole(value);
45
- },
46
- placeholder: placeholder,
47
- resize: false,
48
- style: _objectSpread({
49
- height: height,
50
- minHeight: '100%'
51
- }, textareaStyle),
52
- type: type,
53
- value: temporarySystemRole
54
- }), /*#__PURE__*/_jsx(Flexbox, {
33
+ return /*#__PURE__*/_jsxs(_Fragment, {
34
+ children: [/*#__PURE__*/_jsx(Flexbox, _objectSpread(_objectSpread({
35
+ gap: 8,
36
+ style: {
37
+ flex: 1,
38
+ width: '100%'
39
+ }
40
+ }, props), {}, {
41
+ children: /*#__PURE__*/_jsx(CodeEditor, {
42
+ className: textareaClassname,
43
+ language: "md",
44
+ onValueChange: function onValueChange(value) {
45
+ setRole(value);
46
+ },
47
+ placeholder: placeholder,
48
+ resize: false,
49
+ style: _objectSpread({
50
+ height: height,
51
+ minHeight: '100%'
52
+ }, textareaStyle),
53
+ type: type,
54
+ value: temporarySystemRole
55
+ })
56
+ })), /*#__PURE__*/_jsx(Flexbox, {
55
57
  direction: 'horizontal-reverse',
56
58
  gap: 8,
57
59
  children: renderButtons ? renderButtons(temporarySystemRole).map(function (buttonProps, index) {
@@ -63,16 +65,14 @@ var MessageInput = /*#__PURE__*/memo(function (_ref) {
63
65
  onClick: function onClick() {
64
66
  onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm(temporarySystemRole);
65
67
  },
66
- size: "small",
67
68
  type: "primary",
68
69
  children: (text === null || text === void 0 ? void 0 : text.confirm) || 'Confirm'
69
70
  }), /*#__PURE__*/_jsx(Button, {
70
71
  onClick: onCancel,
71
- size: "small",
72
72
  children: (text === null || text === void 0 ? void 0 : text.cancel) || 'Cancel'
73
73
  })]
74
74
  })
75
75
  })]
76
- }));
76
+ });
77
77
  });
78
78
  export default MessageInput;
@@ -18,8 +18,8 @@ export interface MetaData {
18
18
  title?: string;
19
19
  }
20
20
  export interface BaseDataModel {
21
- createAt?: number;
21
+ createAt: number;
22
22
  id: string;
23
23
  meta: MetaData;
24
- updateAt?: number;
24
+ updateAt: number;
25
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "1.48.0",
3
+ "version": "1.49.0",
4
4
  "description": "Lobe UI is an open-source UI component library for building chatbot web apps",
5
5
  "keywords": [
6
6
  "lobehub",