@lobehub/ui 1.10.0 → 1.11.1

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.
Files changed (161) hide show
  1. package/es/ActionIcon/style.js +1 -1
  2. package/es/Highlighter/style.js +1 -2
  3. package/es/Input/index.js +7 -5
  4. package/es/Input/style.js +2 -3
  5. package/es/Markdown/style.js +1 -1
  6. package/es/SearchBar/index.js +2 -1
  7. package/es/Snippet/style.js +1 -2
  8. package/es/StroyBook/style.js +1 -1
  9. package/es/ThemeProvider/index.d.ts +2 -6
  10. package/es/ThemeProvider/index.js +8 -18
  11. package/es/styles/algorithms/generateColorPalette.d.ts +11 -0
  12. package/es/styles/algorithms/generateColorPalette.js +31 -0
  13. package/es/styles/{customStylish.d.ts → algorithms/generateCustomStylish.d.ts} +1 -1
  14. package/es/styles/{customStylish.js → algorithms/generateCustomStylish.js} +1 -1
  15. package/es/styles/algorithms/generateCustomToken.d.ts +3 -0
  16. package/es/styles/algorithms/generateCustomToken.js +57 -0
  17. package/es/styles/algorithms/generateTheme.d.ts +5 -0
  18. package/es/styles/algorithms/generateTheme.js +18 -0
  19. package/es/styles/colors.d.ts +38 -0
  20. package/es/styles/colors.js +176 -0
  21. package/es/styles/index.d.ts +3 -3
  22. package/es/styles/index.js +3 -3
  23. package/es/styles/theme/base.d.ts +2 -2
  24. package/es/styles/theme/base.js +8 -14
  25. package/es/styles/theme/dark.d.ts +3 -4
  26. package/es/styles/theme/dark.js +40 -71
  27. package/es/styles/theme/light.d.ts +3 -4
  28. package/es/styles/theme/light.js +41 -32
  29. package/es/types/customToken.d.ts +1027 -0
  30. package/es/types/global.d.ts +12 -0
  31. package/es/types/index.d.ts +5 -28
  32. package/es/types/index.js +1 -0
  33. package/lib/ActionIcon/index.js +77 -79
  34. package/lib/ActionIcon/style.js +17 -61
  35. package/lib/Avatar/index.js +62 -67
  36. package/lib/Chat/const.js +6 -27
  37. package/lib/Chat/index.js +24 -28
  38. package/lib/Chat/store/index.js +46 -40
  39. package/lib/Chat/store/initialState.js +6 -27
  40. package/lib/Chat/store/messageReducer.js +51 -58
  41. package/lib/Chat/store/selectors.js +44 -46
  42. package/lib/Chat/store/store.js +242 -115
  43. package/lib/Chat/types.js +4 -16
  44. package/lib/Chat/utils/fetch.js +104 -68
  45. package/lib/ContextMenu/MenuItem/icons.js +48 -66
  46. package/lib/ContextMenu/MenuItem/index.js +73 -66
  47. package/lib/ContextMenu/MenuItem/style.js +19 -89
  48. package/lib/ContextMenu/index.js +194 -178
  49. package/lib/ContextMenu/style.js +17 -85
  50. package/lib/ContextMenu/types/index.js +15 -18
  51. package/lib/ContextMenu/types/menuItem.js +4 -16
  52. package/lib/Conversation/App.js +47 -50
  53. package/lib/Conversation/ChatList/MessageItem/Content.js +98 -93
  54. package/lib/Conversation/ChatList/MessageItem/Toolbar.js +94 -104
  55. package/lib/Conversation/ChatList/MessageItem/index.js +125 -157
  56. package/lib/Conversation/ChatList/index.js +64 -58
  57. package/lib/Conversation/InputArea/ActionBar.js +74 -92
  58. package/lib/Conversation/InputArea/index.js +103 -142
  59. package/lib/Conversation/StoreUpdater.js +28 -48
  60. package/lib/Conversation/index.js +30 -42
  61. package/lib/CopyButton/index.js +37 -62
  62. package/lib/DraggablePanel/index.js +192 -207
  63. package/lib/DraggablePanel/style.js +30 -278
  64. package/lib/DraggablePanel/utils.js +14 -35
  65. package/lib/EditableMessage/index.js +66 -89
  66. package/lib/EditableMessageList/index.js +97 -112
  67. package/lib/EditableText/index.js +36 -49
  68. package/lib/Highlighter/SyntaxHighlighter/Prism.js +43 -38
  69. package/lib/Highlighter/SyntaxHighlighter/index.js +62 -53
  70. package/lib/Highlighter/SyntaxHighlighter/style.js +18 -56
  71. package/lib/Highlighter/index.js +52 -58
  72. package/lib/Highlighter/style.js +22 -102
  73. package/lib/Icon/index.js +29 -36
  74. package/lib/Input/index.js +45 -39
  75. package/lib/Input/style.js +17 -68
  76. package/lib/List/ListItem/index.js +108 -150
  77. package/lib/List/ListItem/time.js +15 -47
  78. package/lib/List/index.js +9 -37
  79. package/lib/Logo/Divider.js +21 -34
  80. package/lib/Logo/Logo3D.js +17 -33
  81. package/lib/Logo/LogoFlat.js +108 -118
  82. package/lib/Logo/LogoHighContrast.js +30 -33
  83. package/lib/Logo/LogoText.js +21 -34
  84. package/lib/Logo/index.js +97 -59
  85. package/lib/Logo/style.js +13 -36
  86. package/lib/Markdown/Code.js +16 -30
  87. package/lib/Markdown/CodeBlock.js +33 -65
  88. package/lib/Markdown/index.js +35 -54
  89. package/lib/Markdown/style.js +15 -125
  90. package/lib/MessageInput/index.js +60 -56
  91. package/lib/MessageModal/index.js +80 -91
  92. package/lib/SearchBar/index.js +86 -72
  93. package/lib/SearchBar/style.js +18 -46
  94. package/lib/SideNav/index.js +43 -31
  95. package/lib/SideNav/style.js +13 -43
  96. package/lib/Snippet/index.js +42 -45
  97. package/lib/Snippet/style.js +13 -72
  98. package/lib/StroyBook/index.js +60 -61
  99. package/lib/StroyBook/style.js +19 -87
  100. package/lib/Swatches/index.js +35 -53
  101. package/lib/TabsNav/index.js +23 -31
  102. package/lib/TabsNav/style.js +17 -60
  103. package/lib/ThemeProvider/GlobalStyle.js +29 -92
  104. package/lib/ThemeProvider/index.d.ts +2 -6
  105. package/lib/ThemeProvider/index.js +44 -69
  106. package/lib/ThemeSwitch/index.js +62 -46
  107. package/lib/Tooltip/index.js +26 -31
  108. package/lib/Tooltip/style.js +13 -49
  109. package/lib/components/ControlInput.js +86 -87
  110. package/lib/hooks/useCopied.js +27 -37
  111. package/lib/hooks/useHighlight.js +65 -70
  112. package/lib/index.js +211 -120
  113. package/lib/styles/algorithms/generateColorPalette.d.ts +11 -0
  114. package/lib/styles/algorithms/generateColorPalette.js +40 -0
  115. package/lib/styles/{customStylish.d.ts → algorithms/generateCustomStylish.d.ts} +1 -1
  116. package/lib/styles/algorithms/generateCustomStylish.js +27 -0
  117. package/lib/styles/algorithms/generateCustomToken.d.ts +3 -0
  118. package/lib/styles/algorithms/generateCustomToken.js +65 -0
  119. package/lib/styles/algorithms/generateTheme.d.ts +5 -0
  120. package/lib/styles/algorithms/generateTheme.js +28 -0
  121. package/lib/styles/colors.d.ts +38 -0
  122. package/lib/styles/colors.js +183 -0
  123. package/lib/styles/index.d.ts +3 -3
  124. package/lib/styles/index.js +25 -20
  125. package/lib/styles/theme/base.d.ts +2 -2
  126. package/lib/styles/theme/base.js +17 -44
  127. package/lib/styles/theme/dark.d.ts +3 -4
  128. package/lib/styles/theme/dark.js +45 -119
  129. package/lib/styles/theme/light.d.ts +3 -4
  130. package/lib/styles/theme/light.js +47 -61
  131. package/lib/types/customToken.d.ts +1027 -0
  132. package/lib/types/global.d.ts +12 -0
  133. package/lib/types/index.d.ts +5 -28
  134. package/lib/types/index.js +5 -0
  135. package/lib/utils/colorUtils.js +14 -48
  136. package/package.json +1 -1
  137. package/es/styles/algorithms/colorRelationship.d.ts +0 -6
  138. package/es/styles/algorithms/colorRelationship.js +0 -88
  139. package/es/styles/algorithms/index.d.ts +0 -15
  140. package/es/styles/algorithms/index.js +0 -66
  141. package/es/styles/algorithms/paletteGenerator.d.ts +0 -51
  142. package/es/styles/algorithms/paletteGenerator.js +0 -74
  143. package/es/styles/antdTheme.d.ts +0 -2
  144. package/es/styles/antdTheme.js +0 -4
  145. package/es/styles/customToken.d.ts +0 -65
  146. package/es/styles/customToken.js +0 -24
  147. package/es/styles/theme/index.d.ts +0 -2
  148. package/es/styles/theme/index.js +0 -2
  149. package/lib/styles/algorithms/colorRelationship.d.ts +0 -6
  150. package/lib/styles/algorithms/colorRelationship.js +0 -87
  151. package/lib/styles/algorithms/index.d.ts +0 -15
  152. package/lib/styles/algorithms/index.js +0 -81
  153. package/lib/styles/algorithms/paletteGenerator.d.ts +0 -51
  154. package/lib/styles/algorithms/paletteGenerator.js +0 -91
  155. package/lib/styles/antdTheme.d.ts +0 -2
  156. package/lib/styles/antdTheme.js +0 -30
  157. package/lib/styles/customStylish.js +0 -118
  158. package/lib/styles/customToken.d.ts +0 -65
  159. package/lib/styles/customToken.js +0 -54
  160. package/lib/styles/theme/index.d.ts +0 -2
  161. package/lib/styles/theme/index.js +0 -32
@@ -1,53 +1,50 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ "use strict";
28
2
 
29
- // src/Conversation/App.tsx
30
- var App_exports = {};
31
- __export(App_exports, {
32
- default: () => App_default
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
33
6
  });
34
- module.exports = __toCommonJS(App_exports);
35
- var import_antd = require("antd");
36
- var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
37
- var import_react = require("react");
38
- var import_react_layout_kit = require("react-layout-kit");
39
- var import_ChatList = __toESM(require("./ChatList"));
40
- var import_InputArea = __toESM(require("./InputArea"));
41
- var import_store = require("../Chat/store");
42
- var ChatContainer = ({ readonly, includeSystem = true }) => {
43
- const [showInput, title, description] = (0, import_store.useStore)(
44
- (s) => [!s.changingSystemRole, s.title, s.description],
45
- import_fast_deep_equal.default
46
- );
47
- if (readonly)
48
- return /* @__PURE__ */ React.createElement(import_ChatList.default, { readonly: true, includeSystem });
49
- return /* @__PURE__ */ React.createElement(import_react_layout_kit.Flexbox, { width: "100%", height: "100%", gap: 24 }, title || description ? /* @__PURE__ */ React.createElement(import_react_layout_kit.Flexbox, null, /* @__PURE__ */ React.createElement(import_antd.Typography.Title, { level: 4 }, title), /* @__PURE__ */ React.createElement(import_antd.Typography.Text, { type: "secondary" }, description)) : null, /* @__PURE__ */ React.createElement(import_ChatList.default, { includeSystem }), showInput ? /* @__PURE__ */ React.createElement(import_InputArea.default, null) : null);
7
+ exports.default = void 0;
8
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
+ var _antd = require("antd");
10
+ var _fastDeepEqual = _interopRequireDefault(require("fast-deep-equal"));
11
+ var _react = require("react");
12
+ var _reactLayoutKit = require("react-layout-kit");
13
+ var _ChatList = _interopRequireDefault(require("./ChatList"));
14
+ var _InputArea = _interopRequireDefault(require("./InputArea"));
15
+ var _store = require("../Chat/store");
16
+ var _jsxRuntime = require("react/jsx-runtime");
17
+ var ChatContainer = function ChatContainer(_ref) {
18
+ var readonly = _ref.readonly,
19
+ _ref$includeSystem = _ref.includeSystem,
20
+ includeSystem = _ref$includeSystem === void 0 ? true : _ref$includeSystem;
21
+ var _useStore = (0, _store.useStore)(function (s) {
22
+ return [!s.changingSystemRole, s.title, s.description];
23
+ }, _fastDeepEqual.default),
24
+ _useStore2 = (0, _slicedToArray2.default)(_useStore, 3),
25
+ showInput = _useStore2[0],
26
+ title = _useStore2[1],
27
+ description = _useStore2[2];
28
+ if (readonly) return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChatList.default, {
29
+ readonly: true,
30
+ includeSystem: includeSystem
31
+ });
32
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactLayoutKit.Flexbox, {
33
+ width: '100%',
34
+ height: '100%',
35
+ gap: 24,
36
+ children: [title || description ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactLayoutKit.Flexbox, {
37
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Typography.Title, {
38
+ level: 4,
39
+ children: title
40
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Typography.Text, {
41
+ type: 'secondary',
42
+ children: description
43
+ })]
44
+ }) : null, /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChatList.default, {
45
+ includeSystem: includeSystem
46
+ }), showInput ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_InputArea.default, {}) : null]
47
+ });
50
48
  };
51
- var App_default = (0, import_react.memo)(ChatContainer);
52
- // Annotate the CommonJS export names for ESM import in node:
53
- 0 && (module.exports = {});
49
+ var _default = /*#__PURE__*/(0, _react.memo)(ChatContainer);
50
+ exports.default = _default;
@@ -1,104 +1,109 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ "use strict";
28
2
 
29
- // src/Conversation/ChatList/MessageItem/Content.tsx
30
- var Content_exports = {};
31
- __export(Content_exports, {
32
- default: () => Content_default
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
33
6
  });
34
- module.exports = __toCommonJS(Content_exports);
35
- var import_icons = require("@ant-design/icons");
36
- var import_antd = require("antd");
37
- var import_react = require("react");
38
- var import_shallow = require("zustand/shallow");
39
- var import_Markdown = __toESM(require("../../../Markdown"));
40
- var import_MessageInput = __toESM(require("../../../MessageInput"));
41
- var import_store = require("../../../Chat/store");
42
- var Content = (0, import_react.memo)(({ content, role, index, error, loading }) => {
43
- const [editingMessageId, dispatchMessage, handleMessageEditing, resendMessage] = (0, import_store.useStore)(
44
- (s) => [s.editingMessageId, s.dispatchMessage, s.handleMessageEditing, s.resendMessage],
45
- import_shallow.shallow
46
- );
47
- const isEditing = editingMessageId === index;
48
- const isUser = role === "user";
7
+ exports.default = void 0;
8
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
+ var _icons = require("@ant-design/icons");
10
+ var _antd = require("antd");
11
+ var _react = require("react");
12
+ var _shallow = require("zustand/shallow");
13
+ var _Markdown = _interopRequireDefault(require("../../../Markdown"));
14
+ var _MessageInput = _interopRequireDefault(require("../../../MessageInput"));
15
+ var _store = require("../../../Chat/store");
16
+ var _jsxRuntime = require("react/jsx-runtime");
17
+ var Content = /*#__PURE__*/(0, _react.memo)(function (_ref) {
18
+ var content = _ref.content,
19
+ role = _ref.role,
20
+ index = _ref.index,
21
+ error = _ref.error,
22
+ loading = _ref.loading;
23
+ var _useStore = (0, _store.useStore)(function (s) {
24
+ return [s.editingMessageId, s.dispatchMessage, s.handleMessageEditing, s.resendMessage];
25
+ }, _shallow.shallow),
26
+ _useStore2 = (0, _slicedToArray2.default)(_useStore, 4),
27
+ editingMessageId = _useStore2[0],
28
+ dispatchMessage = _useStore2[1],
29
+ handleMessageEditing = _useStore2[2],
30
+ resendMessage = _useStore2[3];
31
+ var isEditing = editingMessageId === index;
32
+ var isUser = role === 'user';
49
33
  if (isEditing) {
50
- return /* @__PURE__ */ React.createElement(
51
- import_MessageInput.default,
52
- {
53
- defaultValue: content,
54
- renderButtons: (text) => [
55
- {
56
- type: "primary",
57
- children: isUser ? "更新并重新生成" : "更新",
58
- onClick: () => {
59
- dispatchMessage({ type: "updateMessage", message: text, index });
60
- handleMessageEditing(null);
61
- if (isUser) {
62
- resendMessage(index + 1);
63
- }
64
- }
65
- },
66
- isUser ? {
67
- children: "仅更新",
68
- onClick: () => {
69
- dispatchMessage({ type: "updateMessage", message: text, index });
70
- handleMessageEditing(null);
34
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_MessageInput.default, {
35
+ defaultValue: content,
36
+ renderButtons: function renderButtons(text) {
37
+ return [{
38
+ type: 'primary',
39
+ children: isUser ? '更新并重新生成' : '更新',
40
+ onClick: function onClick() {
41
+ dispatchMessage({
42
+ type: 'updateMessage',
43
+ message: text,
44
+ index: index
45
+ });
46
+ handleMessageEditing(null);
47
+ // 如果是用户的消息,那么重新生成下一条消息
48
+ if (isUser) {
49
+ resendMessage(index + 1);
71
50
  }
72
- } : null,
73
- {
74
- type: "text",
75
- children: "取消",
76
- onClick: () => handleMessageEditing(null)
77
51
  }
78
- ].filter(Boolean)
52
+ }, isUser ? {
53
+ children: '仅更新',
54
+ onClick: function onClick() {
55
+ dispatchMessage({
56
+ type: 'updateMessage',
57
+ message: text,
58
+ index: index
59
+ });
60
+ handleMessageEditing(null);
61
+ }
62
+ } : null, {
63
+ type: 'text',
64
+ children: '取消',
65
+ onClick: function onClick() {
66
+ return handleMessageEditing(null);
67
+ }
68
+ }].filter(Boolean);
79
69
  }
80
- );
70
+ });
81
71
  }
82
- return /* @__PURE__ */ React.createElement(React.Fragment, null, !loading ? /* @__PURE__ */ React.createElement(import_Markdown.default, null, content) : !!error ? null : /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(import_icons.LoadingOutlined, { style: { fontSize: 20 }, spin: true })), error && /* @__PURE__ */ React.createElement(
83
- import_antd.Alert,
84
- {
85
- type: "error",
72
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
73
+ children: [!loading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Markdown.default, {
74
+ children: content
75
+ }) : !!error ? null : /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
76
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.LoadingOutlined, {
77
+ style: {
78
+ fontSize: 20
79
+ },
80
+ spin: true
81
+ })
82
+ }), error && /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Alert, {
83
+ type: 'error',
86
84
  showIcon: true,
87
- description: error.type === "openai" ? /* @__PURE__ */ React.createElement("div", null, error.message, " (错误码:", /* @__PURE__ */ React.createElement("code", null, error.status), ",详情可查看", " ", /* @__PURE__ */ React.createElement(
88
- "a",
89
- {
90
- target: "_blank",
85
+ description: error.type === 'openai' ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
86
+ children: [error.message, " \uFF08\u9519\u8BEF\u7801\uFF1A", /*#__PURE__*/(0, _jsxRuntime.jsx)("code", {
87
+ children: error.status
88
+ }), "\uFF0C\u8BE6\u60C5\u53EF\u67E5\u770B", ' ', /*#__PURE__*/(0, _jsxRuntime.jsx)("a", {
89
+ target: '_blank',
91
90
  href: "https://platform.openai.com/docs/guides/error-codes",
92
- rel: "noreferrer"
91
+ rel: "noreferrer",
92
+ children: "\u5B98\u65B9\u6587\u6863"
93
+ }), "\uFF09"]
94
+ }) : error.message,
95
+ message: error.type === 'openai' ? "\u8BF7\u6C42 OpenAI \u670D\u52A1\u51FA\u9519" : "\u4F1A\u8BDD\u51FA\u9519\u5566\uFF08\u9519\u8BEF\u7801 ".concat(error.status, "\uFF09"),
96
+ action: /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Button, {
97
+ onClick: function onClick() {
98
+ return resendMessage(index);
93
99
  },
94
- "官方文档"
95
- ), ")") : error.message,
96
- message: error.type === "openai" ? `请求 OpenAI 服务出错` : `会话出错啦(错误码 ${error.status})`,
97
- action: /* @__PURE__ */ React.createElement(import_antd.Button, { onClick: () => resendMessage(index) }, "重试"),
98
- style: { marginTop: 12 }
99
- }
100
- ));
100
+ children: "\u91CD\u8BD5"
101
+ }),
102
+ style: {
103
+ marginTop: 12
104
+ }
105
+ })]
106
+ });
101
107
  });
102
- var Content_default = Content;
103
- // Annotate the CommonJS export names for ESM import in node:
104
- 0 && (module.exports = {});
108
+ var _default = Content;
109
+ exports.default = _default;
@@ -1,110 +1,100 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ "use strict";
28
2
 
29
- // src/Conversation/ChatList/MessageItem/Toolbar.tsx
30
- var Toolbar_exports = {};
31
- __export(Toolbar_exports, {
32
- default: () => Toolbar_default
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
33
6
  });
34
- module.exports = __toCommonJS(Toolbar_exports);
35
- var import_antd = require("antd");
36
- var import_antd_style = require("antd-style");
37
- var import_lucide_react = require("lucide-react");
38
- var import_polished = require("polished");
39
- var import_react = require("react");
40
- var import_react_layout_kit = require("react-layout-kit");
41
- var import_shallow = require("zustand/shallow");
42
- var import_ActionIcon = __toESM(require("../../../ActionIcon"));
43
- var import_store = require("../../../Chat/store");
44
- var import_CopyButton = __toESM(require("../../../CopyButton"));
45
- var useStyles = (0, import_antd_style.createStyles)(({ css, token }) => {
7
+ exports.default = void 0;
8
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
+ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
10
+ var _antd = require("antd");
11
+ var _antdStyle = require("antd-style");
12
+ var _lucideReact = require("lucide-react");
13
+ var _polished = require("polished");
14
+ var _react = require("react");
15
+ var _reactLayoutKit = require("react-layout-kit");
16
+ var _shallow = require("zustand/shallow");
17
+ var _ActionIcon = _interopRequireDefault(require("../../../ActionIcon"));
18
+ var _store = require("../../../Chat/store");
19
+ var _CopyButton = _interopRequireDefault(require("../../../CopyButton"));
20
+ var _jsxRuntime = require("react/jsx-runtime");
21
+ var _templateObject;
22
+ var useStyles = (0, _antdStyle.createStyles)(function (_ref) {
23
+ var css = _ref.css,
24
+ token = _ref.token;
46
25
  return {
47
- container: css`
48
- background: ${(0, import_polished.rgba)(token.colorBgElevated, 0.2)};
49
- backdrop-filter: blur(6px);
50
- border-radius: 4px;
51
- `
26
+ container: css(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n background: ", ";\n backdrop-filter: blur(6px);\n border-radius: 4px;\n "])), (0, _polished.rgba)(token.colorBgElevated, 0.2))
52
27
  };
53
28
  });
54
- var Toolbar = (0, import_react.memo)(({ content, isUser, index, readonly, className }) => {
55
- const { styles, cx } = useStyles();
56
- const [dispatchMessage, handleMessageEditing, resendMessage] = (0, import_store.useStore)(
57
- (s) => [s.dispatchMessage, s.handleMessageEditing, s.resendMessage],
58
- import_shallow.shallow
59
- );
60
- return /* @__PURE__ */ React.createElement(import_react_layout_kit.Flexbox, { gap: 4, horizontal: true, className: cx(className, styles.container) }, /* @__PURE__ */ React.createElement(
61
- import_CopyButton.default,
62
- {
63
- placement: "top",
64
- title: "复制",
65
- content,
66
- size: "small"
67
- }
68
- ), readonly ? null : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
69
- import_ActionIcon.default,
70
- {
71
- placement: "top",
72
- title: isUser ? "重新生成回答" : "重新生成",
73
- icon: import_lucide_react.RotateCwIcon,
74
- size: "small",
75
- onClick: () => {
76
- resendMessage(isUser ? index + 1 : index);
77
- }
78
- }
79
- ), /* @__PURE__ */ React.createElement(
80
- import_ActionIcon.default,
81
- {
82
- placement: "top",
83
- title: "编辑",
84
- icon: import_lucide_react.EditIcon,
85
- size: "small",
86
- onClick: () => handleMessageEditing(index)
87
- }
88
- ), /* @__PURE__ */ React.createElement(
89
- import_antd.Popconfirm,
90
- {
91
- title: "确定要删除这条消息吗?",
92
- okButtonProps: { danger: true },
93
- onConfirm: () => {
94
- dispatchMessage({ type: "deleteMessage", index });
95
- }
96
- },
97
- /* @__PURE__ */ React.createElement(
98
- import_ActionIcon.default,
99
- {
100
- placement: "top",
101
- title: "删除",
102
- icon: import_lucide_react.TrashIcon,
103
- size: "small"
104
- }
105
- )
106
- )));
29
+ var Toolbar = /*#__PURE__*/(0, _react.memo)(function (_ref2) {
30
+ var content = _ref2.content,
31
+ isUser = _ref2.isUser,
32
+ index = _ref2.index,
33
+ readonly = _ref2.readonly,
34
+ className = _ref2.className;
35
+ var _useStyles = useStyles(),
36
+ styles = _useStyles.styles,
37
+ cx = _useStyles.cx;
38
+ var _useStore = (0, _store.useStore)(function (s) {
39
+ return [s.dispatchMessage, s.handleMessageEditing, s.resendMessage];
40
+ }, _shallow.shallow),
41
+ _useStore2 = (0, _slicedToArray2.default)(_useStore, 3),
42
+ dispatchMessage = _useStore2[0],
43
+ handleMessageEditing = _useStore2[1],
44
+ resendMessage = _useStore2[2];
45
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactLayoutKit.Flexbox, {
46
+ gap: 4,
47
+ horizontal: true,
48
+ className: cx(className, styles.container),
49
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_CopyButton.default, {
50
+ placement: 'top',
51
+ title: '复制',
52
+ content: content
53
+ // icon={CopyIcon}
54
+ ,
55
+ size: 'small'
56
+ // onClick={() => {
57
+ // copy(content);
58
+ // }}
59
+ }), readonly ? null : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
60
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ActionIcon.default, {
61
+ placement: 'top',
62
+ title: isUser ? '重新生成回答' : '重新生成',
63
+ icon: _lucideReact.RotateCwIcon,
64
+ size: 'small',
65
+ onClick: function onClick() {
66
+ resendMessage(isUser ? index + 1 : index);
67
+ }
68
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ActionIcon.default, {
69
+ placement: 'top',
70
+ title: '编辑',
71
+ icon: _lucideReact.EditIcon,
72
+ size: 'small',
73
+ onClick: function onClick() {
74
+ return handleMessageEditing(index);
75
+ }
76
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Popconfirm, {
77
+ title: '确定要删除这条消息吗?',
78
+ okButtonProps: {
79
+ danger: true
80
+ },
81
+ onConfirm: function onConfirm() {
82
+ dispatchMessage({
83
+ type: 'deleteMessage',
84
+ index: index
85
+ });
86
+ },
87
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ActionIcon.default
88
+ // type={'danger'}
89
+ , {
90
+ placement: 'top',
91
+ title: '删除',
92
+ icon: _lucideReact.TrashIcon,
93
+ size: 'small'
94
+ })
95
+ })]
96
+ })]
97
+ });
107
98
  });
108
- var Toolbar_default = Toolbar;
109
- // Annotate the CommonJS export names for ESM import in node:
110
- 0 && (module.exports = {});
99
+ var _default = Toolbar;
100
+ exports.default = _default;