@lobehub/ui 1.168.6 → 1.168.7

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.
@@ -1,9 +1,10 @@
1
- /// <reference types="react" />
1
+ import { Ref } from 'react';
2
2
  import { ChatItemProps } from "..";
3
3
  export interface ActionsProps {
4
4
  actions: ChatItemProps['actions'];
5
5
  editing?: boolean;
6
6
  placement?: ChatItemProps['placement'];
7
+ ref?: Ref<HTMLDivElement>;
7
8
  type?: ChatItemProps['type'];
8
9
  }
9
10
  declare const Actions: import("react").NamedExoticComponent<ActionsProps>;
@@ -6,7 +6,8 @@ var Actions = /*#__PURE__*/memo(function (_ref) {
6
6
  var actions = _ref.actions,
7
7
  placement = _ref.placement,
8
8
  type = _ref.type,
9
- editing = _ref.editing;
9
+ editing = _ref.editing,
10
+ ref = _ref.ref;
10
11
  var _useStyles = useStyles({
11
12
  editing: editing,
12
13
  placement: placement,
@@ -16,6 +17,7 @@ var Actions = /*#__PURE__*/memo(function (_ref) {
16
17
  return /*#__PURE__*/_jsx(Flexbox, {
17
18
  align: 'flex-start',
18
19
  className: styles.actions,
20
+ ref: ref,
19
21
  role: "menubar",
20
22
  children: actions
21
23
  });
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
 
3
3
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
- var _excluded = ["avatarAddon", "onAvatarClick", "avatarProps", "actions", "className", "primary", "loading", "message", "placeholderMessage", "placement", "type", "avatar", "error", "showTitle", "time", "editing", "onChange", "onEditingChange", "messageExtra", "renderMessage", "text", "errorMessage", "onDoubleClick", "fontSize", "aboveMessage", "belowMessage", "markdownProps"];
4
+ var _excluded = ["avatarAddon", "onAvatarClick", "avatarProps", "actions", "className", "primary", "loading", "message", "placeholderMessage", "placement", "type", "avatar", "error", "showTitle", "time", "editing", "onChange", "onEditingChange", "messageExtra", "renderMessage", "text", "errorMessage", "onDoubleClick", "fontSize", "aboveMessage", "belowMessage", "markdownProps", "actionsWrapWidth"];
5
5
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
6
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
7
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -60,6 +60,8 @@ var ChatItem = /*#__PURE__*/memo(function (_ref) {
60
60
  aboveMessage = _ref.aboveMessage,
61
61
  belowMessage = _ref.belowMessage,
62
62
  markdownProps = _ref.markdownProps,
63
+ _ref$actionsWrapWidth = _ref.actionsWrapWidth,
64
+ actionsWrapWidth = _ref$actionsWrapWidth === void 0 ? 54 : _ref$actionsWrapWidth,
63
65
  rest = _objectWithoutProperties(_ref, _excluded);
64
66
  var _useResponsive = useResponsive(),
65
67
  mobile = _useResponsive.mobile;
@@ -96,17 +98,16 @@ var ChatItem = /*#__PURE__*/memo(function (_ref) {
96
98
  var contentWidth = contentRef.current.scrollWidth; // 使用scrollWidth获取实际内容宽度
97
99
 
98
100
  // 预留给Actions的最小空间 (根据实际Actions大小调整)
99
- var actionsMinWidth = 54;
100
- console.log(contentWidth, actionsMinWidth, containerWidth);
101
+
101
102
  // 只有当内容宽度 + Actions最小宽度 > 容器宽度时才切换布局
102
- setLayoutMode(contentWidth + actionsMinWidth > containerWidth ? 'vertical' : 'horizontal');
103
+ setLayoutMode(contentWidth + actionsWrapWidth > containerWidth ? 'vertical' : 'horizontal');
103
104
  });
104
105
  observer.observe(contentRef.current);
105
106
  observer.observe(containerRef.current);
106
107
  return function () {
107
108
  return observer.disconnect();
108
109
  };
109
- }, [type]);
110
+ }, [type, actionsWrapWidth]);
110
111
  return /*#__PURE__*/_jsxs(Flexbox, _objectSpread(_objectSpread({
111
112
  className: cx(styles.container, className),
112
113
  direction: placement === 'left' ? 'horizontal' : 'horizontal-reverse',
@@ -11,6 +11,7 @@ export interface ChatItemProps extends Omit<FlexboxProps, 'children' | 'onChange
11
11
  * @description Actions to be displayed in the chat item
12
12
  */
13
13
  actions?: ReactNode;
14
+ actionsWrapWidth?: number;
14
15
  /**
15
16
  * @description Metadata for the avatar
16
17
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "1.168.6",
3
+ "version": "1.168.7",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",