@lobehub/ui 1.118.0 → 1.118.2
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/Alert/index.d.ts +2 -0
- package/es/Alert/index.js +12 -3
- package/es/Alert/style.js +1 -1
- package/es/ChatList/Item.d.ts +5 -1
- package/es/ChatList/Item.js +13 -7
- package/es/styles/theme/customStylish.js +1 -1
- package/package.json +1 -1
package/es/Alert/index.d.ts
CHANGED
package/es/Alert/index.js
CHANGED
|
@@ -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 = ["closeIcon", "closable", "description", "showIcon", "type", "variant", "icon", "colorfulText", "style", "extra", "classNames", "text"];
|
|
4
|
+
var _excluded = ["closeIcon", "closable", "description", "showIcon", "type", "variant", "icon", "colorfulText", "style", "extra", "classNames", "text", "extraDefaultExpand", "extraIsolate"];
|
|
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
|
import { Alert as AntdAlert, message } from 'antd';
|
|
@@ -44,8 +44,11 @@ var Alert = /*#__PURE__*/memo(function (_ref) {
|
|
|
44
44
|
extra = _ref.extra,
|
|
45
45
|
classNames = _ref.classNames,
|
|
46
46
|
text = _ref.text,
|
|
47
|
+
_ref$extraDefaultExpa = _ref.extraDefaultExpand,
|
|
48
|
+
extraDefaultExpand = _ref$extraDefaultExpa === void 0 ? false : _ref$extraDefaultExpa,
|
|
49
|
+
extraIsolate = _ref.extraIsolate,
|
|
47
50
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
48
|
-
var _useState = useState(
|
|
51
|
+
var _useState = useState(extraDefaultExpand),
|
|
49
52
|
_useState2 = _slicedToArray(_useState, 2),
|
|
50
53
|
expand = _useState2[0],
|
|
51
54
|
setExpand = _useState2[1];
|
|
@@ -57,8 +60,9 @@ var Alert = /*#__PURE__*/memo(function (_ref) {
|
|
|
57
60
|
theme = _useStyles.theme,
|
|
58
61
|
styles = _useStyles.styles,
|
|
59
62
|
cx = _useStyles.cx;
|
|
63
|
+
var isInsideExtra = !extraIsolate && !!extra;
|
|
60
64
|
var alert = /*#__PURE__*/_jsx(AntdAlert, _objectSpread({
|
|
61
|
-
className: cx(styles.container, colorfulText && styles.colorfulText, !!
|
|
65
|
+
className: cx(styles.container, colorfulText && styles.colorfulText, !!isInsideExtra && styles.hasExtra, variant === 'block' && styles.variantBlock, variant === 'ghost' && styles.variantGhost, variant === 'pure' && styles.variantPure, classNames === null || classNames === void 0 ? void 0 : classNames.alert, !isInsideExtra && styles.container),
|
|
62
66
|
closable: closable,
|
|
63
67
|
closeIcon: closeIcon || /*#__PURE__*/_jsx(ActionIcon, {
|
|
64
68
|
color: colors(theme, type),
|
|
@@ -79,6 +83,11 @@ var Alert = /*#__PURE__*/memo(function (_ref) {
|
|
|
79
83
|
type: type
|
|
80
84
|
}, rest));
|
|
81
85
|
if (!extra) return alert;
|
|
86
|
+
if (extraIsolate) return /*#__PURE__*/_jsxs(Flexbox, {
|
|
87
|
+
className: classNames === null || classNames === void 0 ? void 0 : classNames.container,
|
|
88
|
+
gap: 8,
|
|
89
|
+
children: [alert, extra]
|
|
90
|
+
});
|
|
82
91
|
return /*#__PURE__*/_jsxs(Flexbox, {
|
|
83
92
|
className: classNames === null || classNames === void 0 ? void 0 : classNames.container,
|
|
84
93
|
children: [alert, /*#__PURE__*/_jsxs(Flexbox, {
|
package/es/Alert/style.js
CHANGED
|
@@ -17,7 +17,7 @@ export var useStyles = createStyles(function (_ref, _ref2) {
|
|
|
17
17
|
extra: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n position: relative;\n\n overflow: hidden;\n\n max-width: 100%;\n\n border: 1px solid;\n border-top: none;\n border-bottom-right-radius: ", "px;\n border-bottom-left-radius: ", "px;\n "])), token.borderRadiusLG, token.borderRadiusLG),
|
|
18
18
|
extraBody: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n overflow-x: auto;\n width: 100%;\n padding-block: ", "px;\n padding-inline: ", "px;\n "])), baseBlockPadding, baseInlinePadding),
|
|
19
19
|
extraHeader: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n padding-block: ", "px;\n padding-inline: ", "px;\n border-top: 1px dashed;\n "])), baseBlockPadding * 0.75, baseInlinePadding * 0.75),
|
|
20
|
-
hasExtra: css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n border-bottom-right-radius: 0;\n border-bottom-left-radius: 0;\n "]))),
|
|
20
|
+
hasExtra: css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n border-bottom: none;\n border-bottom-right-radius: 0;\n border-bottom-left-radius: 0;\n "]))),
|
|
21
21
|
variantBlock: css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n border: none;\n "]))),
|
|
22
22
|
variantGhost: css(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n background: transparent !important;\n "]))),
|
|
23
23
|
variantPure: css(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n padding: 0 !important;\n background: transparent !important;\n border: none;\n "]))),
|
package/es/ChatList/Item.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FC, ReactNode } from 'react';
|
|
2
2
|
import { ActionEvent } from "../ActionIconGroup";
|
|
3
|
+
import type { AlertProps } from "../Alert";
|
|
3
4
|
import { type ChatItemProps } from "../ChatItem";
|
|
4
5
|
import { ChatMessage } from "../types/chatMessage";
|
|
5
6
|
import { LLMRoleType } from "../types/llm";
|
|
@@ -15,7 +16,10 @@ export type RenderMessage = FC<ChatMessage & {
|
|
|
15
16
|
editableContent: ReactNode;
|
|
16
17
|
}>;
|
|
17
18
|
export type RenderMessageExtra = FC<ChatMessage>;
|
|
18
|
-
export
|
|
19
|
+
export interface RenderErrorMessage {
|
|
20
|
+
Render?: FC<ChatMessage>;
|
|
21
|
+
config?: AlertProps;
|
|
22
|
+
}
|
|
19
23
|
export type RenderAction = FC<ActionsBarProps & ChatMessage>;
|
|
20
24
|
export interface ListItemProps {
|
|
21
25
|
groupNav?: ChatItemProps['avatarAddon'];
|
package/es/ChatList/Item.js
CHANGED
|
@@ -58,7 +58,7 @@ var Item = /*#__PURE__*/memo(function (props) {
|
|
|
58
58
|
var RenderFunction;
|
|
59
59
|
if (renderMessagesExtra !== null && renderMessagesExtra !== void 0 && renderMessagesExtra[item.role]) RenderFunction = renderMessagesExtra[item.role];
|
|
60
60
|
if (renderMessagesExtra !== null && renderMessagesExtra !== void 0 && renderMessagesExtra['default']) RenderFunction = renderMessagesExtra['default'];
|
|
61
|
-
if (!RenderFunction
|
|
61
|
+
if (!RenderFunction) return;
|
|
62
62
|
return /*#__PURE__*/_jsx(RenderFunction, _objectSpread({}, data));
|
|
63
63
|
}, [renderMessagesExtra === null || renderMessagesExtra === void 0 ? void 0 : renderMessagesExtra[item.role]]);
|
|
64
64
|
var ErrorMessage = useCallback(function (_ref3) {
|
|
@@ -66,8 +66,8 @@ var Item = /*#__PURE__*/memo(function (props) {
|
|
|
66
66
|
var data = _ref3.data;
|
|
67
67
|
if (!renderErrorMessages || !(item !== null && item !== void 0 && (_item$error = item.error) !== null && _item$error !== void 0 && _item$error.type)) return;
|
|
68
68
|
var RenderFunction;
|
|
69
|
-
if (renderErrorMessages !== null && renderErrorMessages !== void 0 && renderErrorMessages[item.error.type]) RenderFunction = renderErrorMessages[item.error.type];
|
|
70
|
-
if (!RenderFunction && renderErrorMessages !== null && renderErrorMessages !== void 0 && renderErrorMessages['default']) RenderFunction = renderErrorMessages['default'];
|
|
69
|
+
if (renderErrorMessages !== null && renderErrorMessages !== void 0 && renderErrorMessages[item.error.type]) RenderFunction = renderErrorMessages[item.error.type].Render;
|
|
70
|
+
if (!RenderFunction && renderErrorMessages !== null && renderErrorMessages !== void 0 && renderErrorMessages['default']) RenderFunction = renderErrorMessages['default'].Render;
|
|
71
71
|
if (!RenderFunction) return;
|
|
72
72
|
return /*#__PURE__*/_jsx(RenderFunction, _objectSpread({}, data));
|
|
73
73
|
}, [renderErrorMessages === null || renderErrorMessages === void 0 ? void 0 : renderErrorMessages[item === null || item === void 0 || (_item$error2 = item.error) === null || _item$error2 === void 0 ? void 0 : _item$error2.type]]);
|
|
@@ -103,10 +103,16 @@ var Item = /*#__PURE__*/memo(function (props) {
|
|
|
103
103
|
var error = useMemo(function () {
|
|
104
104
|
var _item$error3;
|
|
105
105
|
if (!item.error) return;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
106
|
+
var message = (_item$error3 = item.error) === null || _item$error3 === void 0 ? void 0 : _item$error3.message;
|
|
107
|
+
var alertConfig = {};
|
|
108
|
+
if (item.error.type && renderErrorMessages !== null && renderErrorMessages !== void 0 && renderErrorMessages[item.error.type]) {
|
|
109
|
+
var _renderErrorMessages$;
|
|
110
|
+
alertConfig = (_renderErrorMessages$ = renderErrorMessages[item.error.type]) === null || _renderErrorMessages$ === void 0 ? void 0 : _renderErrorMessages$.config;
|
|
111
|
+
}
|
|
112
|
+
return _objectSpread({
|
|
113
|
+
message: message
|
|
114
|
+
}, alertConfig);
|
|
115
|
+
}, [renderErrorMessages, item.error]);
|
|
110
116
|
if (RenderItem) return /*#__PURE__*/_jsx(RenderItem, _objectSpread({}, props), item.id);
|
|
111
117
|
return /*#__PURE__*/_jsx(ChatItem, {
|
|
112
118
|
actions: /*#__PURE__*/_jsx(Actions, {
|
|
@@ -14,7 +14,7 @@ export var generateCustomStylish = function generateCustomStylish(_ref) {
|
|
|
14
14
|
bottomScrollbar: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n ::-webkit-scrollbar {\n width: 0;\n height: 4px;\n background-color: transparent;\n\n &-thumb {\n background-color: ", ";\n border-radius: 4px;\n transition: background-color 500ms ", ";\n }\n\n &-corner {\n display: none;\n width: 0;\n height: 0;\n }\n }\n "])), token.colorFill, token.motionEaseOut),
|
|
15
15
|
gradientAnimation: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n background-image: linear-gradient(\n -45deg,\n ", ",\n ", ",\n ", ",\n ", "\n );\n background-size: 400% 400%;\n border-radius: inherit;\n animation: 5s ", " 5s ease infinite;\n "])), token.gold, token.magenta, token.geekblue, token.cyan, gradient),
|
|
16
16
|
markdown: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n color: ", ";\n\n h1,\n h2,\n h3,\n h4,\n h5 {\n font-weight: 600;\n }\n\n p {\n margin-block: 0 0;\n\n font-size: 14px;\n line-height: 2;\n color: ", ";\n word-break: break-all;\n word-wrap: break-word;\n\n + * {\n margin-block-end: 1em;\n }\n\n &:not(:last-child) {\n margin-bottom: 1.5em;\n }\n }\n\n blockquote {\n margin: 16px 0;\n padding: 0 12px;\n\n p {\n font-style: italic;\n color: ", ";\n }\n }\n\n a {\n color: ", ";\n\n &:hover {\n color: ", ";\n }\n\n &:active {\n color: ", ";\n }\n }\n\n img {\n max-width: 100%;\n }\n\n pre,\n [data-code-type='highlighter'] {\n border: none;\n border-radius: ", "px;\n\n > code {\n padding: 0 !important;\n border: none !important;\n }\n }\n\n > :not([data-code-type='highlighter']) code {\n padding: 2px 6px;\n\n font-size: ", "px;\n color: ", ";\n\n background: ", ";\n border: 1px solid ", ";\n border-radius: ", "px;\n }\n\n table {\n border-spacing: 0;\n\n width: 100%;\n margin-block: 1em 1em;\n margin-inline: 0 0;\n padding: 8px;\n\n border: 1px solid ", ";\n border-radius: ", "px;\n\n code {\n display: inline-flex;\n }\n }\n\n th,\n td {\n padding-block: 10px 10px;\n padding-inline: 16px 16px;\n }\n\n thead {\n tr {\n th {\n background: ", ";\n\n &:first-child {\n border-top-left-radius: ", "px;\n border-bottom-left-radius: ", "px;\n }\n\n &:last-child {\n border-top-right-radius: ", "px;\n border-bottom-right-radius: ", "px;\n }\n }\n }\n }\n\n > ol > li::marker {\n color: ", " !important;\n }\n\n > ul > li {\n line-height: 1.8;\n list-style-type: disc;\n\n &::marker {\n color: ", " !important;\n }\n }\n\n ol,\n ul {\n > li::marker {\n color: ", ";\n }\n }\n\n details {\n margin-bottom: 1em;\n padding: 12px 16px;\n\n background: ", ";\n border: 1px solid ", ";\n border-radius: ", "px;\n\n transition: all 400ms ", ";\n }\n\n details[open] {\n summary {\n padding-bottom: 12px;\n border-bottom: 1px solid ", ";\n }\n }\n "])), token.colorText, token.colorText, token.colorTextDescription, token.colorLink, token.colorLinkHover, token.colorLinkActive, token.borderRadius, token.fontSizeSM, cyanColor, cyanBackground, isDarkMode ? token.cyan1A : token.cyan6A, token.borderRadiusSM, token.colorBorderSecondary, token.borderRadius, token.colorFillTertiary, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius, isDarkMode ? token.cyan9A : token.cyan10A, isDarkMode ? token.cyan9A : token.cyan10A, token.colorTextDescription, token.colorFillTertiary, token.colorBorderSecondary, token.borderRadiusLG, token.motionEaseOut, token.colorBorder),
|
|
17
|
-
markdownInChat: css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n h1 {\n margin-top: 0;\n margin-block-start: 0;\n font-size: 1.6em;\n }\n\n h2 {\n margin-top: 0;\n margin-block-start: 0;\n font-size: 1.4em;\n }\n\n h3 {\n margin-top: 0;\n margin-block-start: 0;\n font-size: 1.2em;\n }\n\n h4 {\n margin-top: 0;\n margin-block-start: 0;\n font-size: 1.1em;\n }\n\n h5 {\n margin-top: 0;\n margin-block-start: 0;\n font-size: 1em;\n }\n\n > *:last-child {\n margin-bottom: 0 !important;\n }\n\n p {\n line-height: 1.8;\n\n + * {\n margin-block-end: 0.5em;\n }\n\n &:not(:last-child) {\n margin-bottom: 1em;\n }\n }\n "]))),
|
|
17
|
+
markdownInChat: css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n h1 {\n margin-top: 0;\n margin-block-start: 0;\n font-size: 1.6em;\n }\n\n h2 {\n margin-top: 0;\n margin-block-start: 0;\n font-size: 1.4em;\n }\n\n h3 {\n margin-top: 0;\n margin-block-start: 0;\n font-size: 1.2em;\n }\n\n h4 {\n margin-top: 0;\n margin-block-start: 0;\n font-size: 1.1em;\n }\n\n h5 {\n margin-top: 0;\n margin-block-start: 0;\n font-size: 1em;\n }\n\n > *:last-child {\n margin-bottom: 0 !important;\n }\n\n p {\n line-height: 1.8 !important;\n\n + * {\n margin-block-end: 0.5em !important;\n }\n\n &:not(:last-child) {\n margin-bottom: 1em !important;\n }\n }\n "]))),
|
|
18
18
|
noScrollbar: css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n ::-webkit-scrollbar {\n display: none;\n width: 0;\n height: 0;\n background-color: transparent;\n }\n "]))),
|
|
19
19
|
resetLinkColor: css(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n cursor: pointer;\n color: ", ";\n\n &:hover {\n color: ", ";\n }\n "])), token.colorTextSecondary, token.colorText)
|
|
20
20
|
};
|