@lobehub/ui 1.165.5 → 1.165.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.
package/es/Mermaid/useMermaid.js
CHANGED
|
@@ -21,9 +21,12 @@ export var useMermaid = function useMermaid(content) {
|
|
|
21
21
|
useEffect(function () {
|
|
22
22
|
mermaid.initialize({
|
|
23
23
|
fontFamily: theme.fontFamilyCode,
|
|
24
|
+
gantt: {
|
|
25
|
+
useWidth: 1920
|
|
26
|
+
},
|
|
24
27
|
securityLevel: 'loose',
|
|
25
28
|
startOnLoad: true,
|
|
26
|
-
theme: '
|
|
29
|
+
theme: theme.isDarkMode ? 'dark' : 'default',
|
|
27
30
|
themeVariables: {
|
|
28
31
|
errorBkgColor: theme.colorError,
|
|
29
32
|
errorTextColor: theme.colorText,
|
|
@@ -7,10 +7,16 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
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; }
|
|
8
8
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
9
9
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
11
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
12
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
13
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
14
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
15
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
10
16
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
11
17
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
12
18
|
import { useResponsive } from 'antd-style';
|
|
13
|
-
import { memo } from 'react';
|
|
19
|
+
import { memo, useEffect, useRef, useState } from 'react';
|
|
14
20
|
import { Flexbox } from 'react-layout-kit';
|
|
15
21
|
import Actions from "./components/Actions";
|
|
16
22
|
import Avatar from "./components/Avatar";
|
|
@@ -68,6 +74,39 @@ var ChatItem = /*#__PURE__*/memo(function (_ref) {
|
|
|
68
74
|
}),
|
|
69
75
|
cx = _useStyles.cx,
|
|
70
76
|
styles = _useStyles.styles;
|
|
77
|
+
|
|
78
|
+
// 在 ChatItem 组件中添加
|
|
79
|
+
var contentRef = useRef(null);
|
|
80
|
+
var containerRef = useRef(null);
|
|
81
|
+
var _useState = useState(type === 'block' ? 'horizontal' : 'vertical'),
|
|
82
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
83
|
+
layoutMode = _useState2[0],
|
|
84
|
+
setLayoutMode = _useState2[1];
|
|
85
|
+
|
|
86
|
+
// 使用 ResizeObserver 监控内容和容器尺寸
|
|
87
|
+
useEffect(function () {
|
|
88
|
+
if (type === 'pure') {
|
|
89
|
+
setLayoutMode('vertical');
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (!contentRef.current || !containerRef.current) return;
|
|
93
|
+
var observer = new ResizeObserver(function () {
|
|
94
|
+
if (!contentRef.current || !containerRef.current) return;
|
|
95
|
+
var containerWidth = containerRef.current.clientWidth;
|
|
96
|
+
var contentWidth = contentRef.current.scrollWidth; // 使用scrollWidth获取实际内容宽度
|
|
97
|
+
|
|
98
|
+
// 预留给Actions的最小空间 (根据实际Actions大小调整)
|
|
99
|
+
var actionsMinWidth = 54;
|
|
100
|
+
console.log(contentWidth, actionsMinWidth, containerWidth);
|
|
101
|
+
// 只有当内容宽度 + Actions最小宽度 > 容器宽度时才切换布局
|
|
102
|
+
setLayoutMode(contentWidth + actionsMinWidth > containerWidth ? 'vertical' : 'horizontal');
|
|
103
|
+
});
|
|
104
|
+
observer.observe(contentRef.current);
|
|
105
|
+
observer.observe(containerRef.current);
|
|
106
|
+
return function () {
|
|
107
|
+
return observer.disconnect();
|
|
108
|
+
};
|
|
109
|
+
}, [type]);
|
|
71
110
|
return /*#__PURE__*/_jsxs(Flexbox, _objectSpread(_objectSpread({
|
|
72
111
|
className: cx(styles.container, className),
|
|
73
112
|
direction: placement === 'left' ? 'horizontal' : 'horizontal-reverse',
|
|
@@ -84,6 +123,7 @@ var ChatItem = /*#__PURE__*/memo(function (_ref) {
|
|
|
84
123
|
})), /*#__PURE__*/_jsxs(Flexbox, {
|
|
85
124
|
align: placement === 'left' ? 'flex-start' : 'flex-end',
|
|
86
125
|
className: styles.messageContainer,
|
|
126
|
+
ref: containerRef,
|
|
87
127
|
children: [/*#__PURE__*/_jsx(Title, {
|
|
88
128
|
avatar: avatar,
|
|
89
129
|
placement: placement,
|
|
@@ -92,9 +132,12 @@ var ChatItem = /*#__PURE__*/memo(function (_ref) {
|
|
|
92
132
|
}), aboveMessage, /*#__PURE__*/_jsxs(Flexbox, {
|
|
93
133
|
align: placement === 'left' ? 'flex-start' : 'flex-end',
|
|
94
134
|
className: styles.messageContent,
|
|
95
|
-
|
|
135
|
+
"data-layout": layoutMode // 添加数据属性以方便样式选择
|
|
136
|
+
,
|
|
137
|
+
direction: layoutMode === 'horizontal' ? placement === 'left' ? 'horizontal' : 'horizontal-reverse' : 'vertical',
|
|
96
138
|
gap: 8,
|
|
97
139
|
children: [/*#__PURE__*/_jsx(Flexbox, {
|
|
140
|
+
ref: contentRef,
|
|
98
141
|
width: '100%',
|
|
99
142
|
children: error && (message === placeholderMessage || !message) ? /*#__PURE__*/_jsx(ErrorContent, {
|
|
100
143
|
error: error,
|