@lobehub/ui 1.11.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.
- package/lib/ActionIcon/index.js +77 -79
- package/lib/ActionIcon/style.js +17 -61
- package/lib/Avatar/index.js +62 -67
- package/lib/Chat/const.js +6 -27
- package/lib/Chat/index.js +24 -28
- package/lib/Chat/store/index.js +46 -40
- package/lib/Chat/store/initialState.js +6 -27
- package/lib/Chat/store/messageReducer.js +51 -58
- package/lib/Chat/store/selectors.js +44 -46
- package/lib/Chat/store/store.js +242 -115
- package/lib/Chat/types.js +4 -16
- package/lib/Chat/utils/fetch.js +104 -68
- package/lib/ContextMenu/MenuItem/icons.js +48 -66
- package/lib/ContextMenu/MenuItem/index.js +73 -66
- package/lib/ContextMenu/MenuItem/style.js +19 -89
- package/lib/ContextMenu/index.js +194 -178
- package/lib/ContextMenu/style.js +17 -85
- package/lib/ContextMenu/types/index.js +15 -18
- package/lib/ContextMenu/types/menuItem.js +4 -16
- package/lib/Conversation/App.js +47 -50
- package/lib/Conversation/ChatList/MessageItem/Content.js +98 -93
- package/lib/Conversation/ChatList/MessageItem/Toolbar.js +94 -104
- package/lib/Conversation/ChatList/MessageItem/index.js +125 -157
- package/lib/Conversation/ChatList/index.js +64 -58
- package/lib/Conversation/InputArea/ActionBar.js +74 -92
- package/lib/Conversation/InputArea/index.js +103 -142
- package/lib/Conversation/StoreUpdater.js +28 -48
- package/lib/Conversation/index.js +30 -42
- package/lib/CopyButton/index.js +37 -62
- package/lib/DraggablePanel/index.js +192 -207
- package/lib/DraggablePanel/style.js +30 -278
- package/lib/DraggablePanel/utils.js +14 -35
- package/lib/EditableMessage/index.js +66 -89
- package/lib/EditableMessageList/index.js +97 -112
- package/lib/EditableText/index.js +36 -49
- package/lib/Highlighter/SyntaxHighlighter/Prism.js +43 -38
- package/lib/Highlighter/SyntaxHighlighter/index.js +62 -53
- package/lib/Highlighter/SyntaxHighlighter/style.js +18 -56
- package/lib/Highlighter/index.js +52 -58
- package/lib/Highlighter/style.js +22 -101
- package/lib/Icon/index.js +29 -36
- package/lib/Input/index.js +45 -43
- package/lib/Input/style.js +17 -67
- package/lib/List/ListItem/index.js +108 -150
- package/lib/List/ListItem/time.js +15 -47
- package/lib/List/index.js +9 -37
- package/lib/Logo/Divider.js +21 -34
- package/lib/Logo/Logo3D.js +17 -33
- package/lib/Logo/LogoFlat.js +108 -118
- package/lib/Logo/LogoHighContrast.js +30 -33
- package/lib/Logo/LogoText.js +21 -34
- package/lib/Logo/index.js +97 -59
- package/lib/Logo/style.js +13 -36
- package/lib/Markdown/Code.js +16 -30
- package/lib/Markdown/CodeBlock.js +33 -65
- package/lib/Markdown/index.js +35 -54
- package/lib/Markdown/style.js +15 -129
- package/lib/MessageInput/index.js +60 -56
- package/lib/MessageModal/index.js +80 -91
- package/lib/SearchBar/index.js +86 -73
- package/lib/SearchBar/style.js +18 -46
- package/lib/SideNav/index.js +43 -31
- package/lib/SideNav/style.js +13 -43
- package/lib/Snippet/index.js +42 -45
- package/lib/Snippet/style.js +13 -71
- package/lib/StroyBook/index.js +60 -61
- package/lib/StroyBook/style.js +19 -87
- package/lib/Swatches/index.js +35 -53
- package/lib/TabsNav/index.js +23 -31
- package/lib/TabsNav/style.js +17 -60
- package/lib/ThemeProvider/GlobalStyle.js +29 -92
- package/lib/ThemeProvider/index.js +43 -57
- package/lib/ThemeSwitch/index.js +62 -46
- package/lib/Tooltip/index.js +26 -31
- package/lib/Tooltip/style.js +13 -49
- package/lib/components/ControlInput.js +86 -87
- package/lib/hooks/useCopied.js +27 -37
- package/lib/hooks/useHighlight.js +65 -70
- package/lib/index.js +211 -120
- package/lib/styles/algorithms/generateColorPalette.js +28 -60
- package/lib/styles/algorithms/generateCustomStylish.js +22 -117
- package/lib/styles/algorithms/generateCustomToken.js +51 -65
- package/lib/styles/algorithms/generateTheme.js +22 -53
- package/lib/styles/colors.js +121 -1766
- package/lib/styles/index.js +23 -32
- package/lib/styles/theme/base.js +11 -32
- package/lib/styles/theme/dark.js +38 -62
- package/lib/styles/theme/light.js +38 -62
- package/lib/types/index.js +4 -16
- package/lib/utils/colorUtils.js +14 -48
- package/package.json +1 -1
package/lib/Markdown/style.js
CHANGED
|
@@ -1,134 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";
|
|
18
2
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
useStyles: () => useStyles
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
23
6
|
});
|
|
24
|
-
|
|
25
|
-
var
|
|
26
|
-
var
|
|
7
|
+
exports.useStyles = void 0;
|
|
8
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
9
|
+
var _antdStyle = require("antd-style");
|
|
10
|
+
var _templateObject, _templateObject2;
|
|
11
|
+
var useStyles = (0, _antdStyle.createStyles)(function (_ref) {
|
|
12
|
+
var css = _ref.css,
|
|
13
|
+
token = _ref.token,
|
|
14
|
+
isDarkMode = _ref.isDarkMode;
|
|
27
15
|
return {
|
|
28
|
-
container: css
|
|
29
|
-
color:
|
|
30
|
-
|
|
31
|
-
p {
|
|
32
|
-
margin: 20px auto;
|
|
33
|
-
|
|
34
|
-
font-size: 14px;
|
|
35
|
-
line-height: 1.8;
|
|
36
|
-
color: ${token.colorText};
|
|
37
|
-
text-align: justify;
|
|
38
|
-
word-wrap: break-word;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
blockquote {
|
|
42
|
-
margin: 16px 0;
|
|
43
|
-
padding: 0 12px;
|
|
44
|
-
p {
|
|
45
|
-
font-style: italic;
|
|
46
|
-
color: ${token.colorTextDescription};
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
p:not(:last-child) {
|
|
51
|
-
margin-bottom: 1em;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
a {
|
|
55
|
-
color: ${token.colorLink};
|
|
56
|
-
|
|
57
|
-
&:hover {
|
|
58
|
-
color: ${token.colorLinkHover};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
&:active {
|
|
62
|
-
color: ${token.colorLinkActive};
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
img {
|
|
67
|
-
max-width: 100%;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
> :not([data-code-type='highlighter']) code {
|
|
71
|
-
padding: 2px 6px;
|
|
72
|
-
color: ${isDarkMode ? token["cyan-7"] : token.colorPrimaryText};
|
|
73
|
-
background: ${isDarkMode ? token["cyan-1"] : token.colorPrimaryBg};
|
|
74
|
-
border-radius: 4px;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
table {
|
|
78
|
-
border-spacing: 0;
|
|
79
|
-
|
|
80
|
-
width: 100%;
|
|
81
|
-
margin-block-start: 1em;
|
|
82
|
-
margin-block-end: 1em;
|
|
83
|
-
margin-inline-start: 0px;
|
|
84
|
-
margin-inline-end: 0px;
|
|
85
|
-
padding: 8px;
|
|
86
|
-
|
|
87
|
-
border: 1px solid ${token.colorBorderSecondary};
|
|
88
|
-
border-radius: ${token.borderRadius}px;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
th,
|
|
92
|
-
td {
|
|
93
|
-
padding-block-start: 10px;
|
|
94
|
-
padding-block-end: 10px;
|
|
95
|
-
padding-inline-start: 16px;
|
|
96
|
-
padding-inline-end: 16px;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
thead {
|
|
100
|
-
tr {
|
|
101
|
-
th {
|
|
102
|
-
background: ${token.colorFillTertiary};
|
|
103
|
-
&:first-child {
|
|
104
|
-
border-top-left-radius: ${token.borderRadius}px;
|
|
105
|
-
border-bottom-left-radius: ${token.borderRadius}px;
|
|
106
|
-
}
|
|
107
|
-
&:last-child {
|
|
108
|
-
border-top-right-radius: ${token.borderRadius}px;
|
|
109
|
-
border-bottom-right-radius: ${token.borderRadius}px;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
ul li {
|
|
116
|
-
line-height: 1.8;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
pre {
|
|
120
|
-
border-radius: ${token.borderRadius}px;
|
|
121
|
-
}
|
|
122
|
-
`,
|
|
123
|
-
code: css`
|
|
124
|
-
padding: 2px 4px;
|
|
125
|
-
font-family: ${token.fontFamilyCode} !important;
|
|
126
|
-
color: ${isDarkMode ? token.cyan8 : token.pink7};
|
|
127
|
-
border-radius: 4px;
|
|
128
|
-
`
|
|
16
|
+
container: css(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n color: ", ";\n\n p {\n margin: 20px auto;\n\n font-size: 14px;\n line-height: 1.8;\n color: ", ";\n text-align: justify;\n word-wrap: break-word;\n }\n\n blockquote {\n margin: 16px 0;\n padding: 0 12px;\n p {\n font-style: italic;\n color: ", ";\n }\n }\n\n p:not(:last-child) {\n margin-bottom: 1em;\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 > :not([data-code-type='highlighter']) code {\n padding: 2px 6px;\n color: ", ";\n background: ", ";\n border-radius: 4px;\n }\n\n table {\n border-spacing: 0;\n\n width: 100%;\n margin-block-start: 1em;\n margin-block-end: 1em;\n margin-inline-start: 0px;\n margin-inline-end: 0px;\n padding: 8px;\n\n border: 1px solid ", ";\n border-radius: ", "px;\n }\n\n th,\n td {\n padding-block-start: 10px;\n padding-block-end: 10px;\n padding-inline-start: 16px;\n padding-inline-end: 16px;\n }\n\n thead {\n tr {\n th {\n background: ", ";\n &:first-child {\n border-top-left-radius: ", "px;\n border-bottom-left-radius: ", "px;\n }\n &:last-child {\n border-top-right-radius: ", "px;\n border-bottom-right-radius: ", "px;\n }\n }\n }\n }\n\n ul li {\n line-height: 1.8;\n }\n\n pre {\n border-radius: ", "px;\n }\n "])), isDarkMode ? token.colorTextSecondary : token.colorText, token.colorText, token.colorTextDescription, token.colorLink, token.colorLinkHover, token.colorLinkActive, isDarkMode ? token['cyan-7'] : token.colorPrimaryText, isDarkMode ? token['cyan-1'] : token.colorPrimaryBg, token.colorBorderSecondary, token.borderRadius, token.colorFillTertiary, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius),
|
|
17
|
+
code: css(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n padding: 2px 4px;\n font-family: ", " !important;\n color: ", ";\n border-radius: 4px;\n "])), token.fontFamilyCode, isDarkMode ? token.cyan8 : token.pink7)
|
|
129
18
|
};
|
|
130
19
|
});
|
|
131
|
-
|
|
132
|
-
0 && (module.exports = {
|
|
133
|
-
useStyles
|
|
134
|
-
});
|
|
20
|
+
exports.useStyles = useStyles;
|
|
@@ -1,59 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";
|
|
18
2
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
default: () => MessageInput_default
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
23
6
|
});
|
|
24
|
-
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
var
|
|
29
|
-
var
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
+
var _ = require("./..");
|
|
11
|
+
var _antd = require("antd");
|
|
12
|
+
var _antdStyle = require("antd-style");
|
|
13
|
+
var _react = require("react");
|
|
14
|
+
var _reactLayoutKit = require("react-layout-kit");
|
|
15
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
|
+
var MessageInput = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
17
|
+
var type = _ref.type,
|
|
18
|
+
onCancel = _ref.onCancel,
|
|
19
|
+
defaultValue = _ref.defaultValue,
|
|
20
|
+
onConfirm = _ref.onConfirm,
|
|
21
|
+
renderButtons = _ref.renderButtons,
|
|
22
|
+
height = _ref.height,
|
|
23
|
+
className = _ref.className;
|
|
24
|
+
var _useState = (0, _react.useState)(defaultValue || ''),
|
|
25
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
26
|
+
tempSystemRole = _useState2[0],
|
|
27
|
+
setRole = _useState2[1];
|
|
28
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactLayoutKit.Flexbox, {
|
|
29
|
+
gap: 8,
|
|
30
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_.TextArea, {
|
|
31
|
+
type: type,
|
|
32
|
+
value: tempSystemRole,
|
|
33
|
+
placeholder: '例如:你是一名擅长翻译的翻译官,请将用户所输入的英文都翻译为中文。',
|
|
34
|
+
style: {
|
|
35
|
+
height: height !== null && height !== void 0 ? height : 200
|
|
52
36
|
},
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
37
|
+
onChange: function onChange(e) {
|
|
38
|
+
setRole(e.target.value);
|
|
39
|
+
},
|
|
40
|
+
className: (0, _antdStyle.cx)('nowheel', className)
|
|
41
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactLayoutKit.Flexbox, {
|
|
42
|
+
direction: 'horizontal-reverse',
|
|
43
|
+
gap: 8,
|
|
44
|
+
children: renderButtons ? renderButtons(tempSystemRole).map(function (buttonProps, index) {
|
|
45
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Button, (0, _objectSpread2.default)({}, buttonProps), index);
|
|
46
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
47
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Button, {
|
|
48
|
+
type: "primary",
|
|
49
|
+
onClick: function onClick() {
|
|
50
|
+
onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm(tempSystemRole);
|
|
51
|
+
},
|
|
52
|
+
children: "Confirm"
|
|
53
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Button, {
|
|
54
|
+
type: "text",
|
|
55
|
+
onClick: onCancel,
|
|
56
|
+
children: "Cancel"
|
|
57
|
+
})]
|
|
58
|
+
})
|
|
59
|
+
})]
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
var _default = MessageInput;
|
|
63
|
+
exports.default = _default;
|
|
@@ -1,98 +1,87 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
default: () => MessageModal_default
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
33
6
|
});
|
|
34
|
-
|
|
35
|
-
var
|
|
36
|
-
var
|
|
37
|
-
var
|
|
38
|
-
var
|
|
39
|
-
var
|
|
40
|
-
var
|
|
41
|
-
var
|
|
42
|
-
var
|
|
43
|
-
var
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
max-height: 70vh
|
|
53
|
-
|
|
54
|
-
})
|
|
55
|
-
var MessageModal = (0,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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 _icons = require("@ant-design/icons");
|
|
11
|
+
var _antd = require("antd");
|
|
12
|
+
var _antdStyle = require("antd-style");
|
|
13
|
+
var _react = require("react");
|
|
14
|
+
var _reactLayoutKit = require("react-layout-kit");
|
|
15
|
+
var _useMergeValue = _interopRequireDefault(require("use-merge-value"));
|
|
16
|
+
var _Markdown = _interopRequireDefault(require("../Markdown"));
|
|
17
|
+
var _MessageInput = _interopRequireDefault(require("../MessageInput"));
|
|
18
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
+
var _templateObject, _templateObject2;
|
|
20
|
+
var useStyles = (0, _antdStyle.createStyles)(function (_ref) {
|
|
21
|
+
var css = _ref.css,
|
|
22
|
+
prefixCls = _ref.prefixCls;
|
|
23
|
+
return {
|
|
24
|
+
modal: css(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n height: 70%;\n .", "-modal-header {\n margin-bottom: 24px;\n }\n "])), prefixCls),
|
|
25
|
+
body: css(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n overflow-y: scroll;\n max-height: 70vh;\n "])))
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
var MessageModal = /*#__PURE__*/(0, _react.memo)(function (_ref2) {
|
|
29
|
+
var editing = _ref2.editing,
|
|
30
|
+
open = _ref2.open,
|
|
31
|
+
onOpenChange = _ref2.onOpenChange,
|
|
32
|
+
onEditingChange = _ref2.onEditingChange,
|
|
33
|
+
value = _ref2.value,
|
|
34
|
+
onChange = _ref2.onChange;
|
|
35
|
+
var _useStyles = useStyles(),
|
|
36
|
+
styles = _useStyles.styles;
|
|
37
|
+
var _useControlledState = (0, _useMergeValue.default)(false, {
|
|
59
38
|
value: editing,
|
|
60
39
|
onChange: onEditingChange
|
|
61
|
-
})
|
|
62
|
-
|
|
40
|
+
}),
|
|
41
|
+
_useControlledState2 = (0, _slicedToArray2.default)(_useControlledState, 2),
|
|
42
|
+
isEdit = _useControlledState2[0],
|
|
43
|
+
setTyping = _useControlledState2[1];
|
|
44
|
+
var _useControlledState3 = (0, _useMergeValue.default)(false, {
|
|
63
45
|
value: open,
|
|
64
46
|
onChange: onOpenChange
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
47
|
+
}),
|
|
48
|
+
_useControlledState4 = (0, _slicedToArray2.default)(_useControlledState3, 2),
|
|
49
|
+
expand = _useControlledState4[0],
|
|
50
|
+
setExpand = _useControlledState4[1];
|
|
51
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Modal, {
|
|
52
|
+
open: expand,
|
|
53
|
+
width: 800,
|
|
54
|
+
onCancel: function onCancel() {
|
|
55
|
+
return setExpand(false);
|
|
56
|
+
},
|
|
57
|
+
okText: '编辑',
|
|
58
|
+
onOk: function onOk() {
|
|
59
|
+
setTyping(true);
|
|
60
|
+
},
|
|
61
|
+
footer: isEdit ? null : undefined,
|
|
62
|
+
cancelText: '关闭',
|
|
63
|
+
title: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactLayoutKit.Flexbox, {
|
|
64
|
+
horizontal: true,
|
|
65
|
+
align: 'center',
|
|
66
|
+
gap: 4,
|
|
67
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.AimOutlined, {}), "\u63D0\u793A\u8BCD"]
|
|
68
|
+
}),
|
|
69
|
+
className: styles.modal,
|
|
70
|
+
children: isEdit ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_MessageInput.default, {
|
|
71
|
+
onConfirm: function onConfirm(text) {
|
|
72
|
+
setTyping(false);
|
|
73
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(text);
|
|
74
|
+
},
|
|
75
|
+
onCancel: function onCancel() {
|
|
76
|
+
return setTyping(false);
|
|
80
77
|
},
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
) : /* @__PURE__ */ React.createElement(import_Markdown.default, { className: styles.body }, value)
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
);
|
|
96
|
-
var MessageModal_default = MessageModal;
|
|
97
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
98
|
-
0 && (module.exports = {});
|
|
78
|
+
defaultValue: value,
|
|
79
|
+
height: 400
|
|
80
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Markdown.default, {
|
|
81
|
+
className: styles.body,
|
|
82
|
+
children: value
|
|
83
|
+
})
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
var _default = MessageModal;
|
|
87
|
+
exports.default = _default;
|
package/lib/SearchBar/index.js
CHANGED
|
@@ -1,77 +1,90 @@
|
|
|
1
|
-
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
1
|
+
"use strict";
|
|
18
2
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
default: () => SearchBar_default
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
23
6
|
});
|
|
24
|
-
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
var
|
|
29
|
-
var
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
);
|
|
33
|
-
var
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
11
|
+
var _ = require("./..");
|
|
12
|
+
var _antd = require("antd");
|
|
13
|
+
var _lucideReact = require("lucide-react");
|
|
14
|
+
var _react = require("react");
|
|
15
|
+
var _style = require("./style");
|
|
16
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
|
+
var _excluded = ["className", "value", "onChange", "placeholder", "enableShortKey", "shortKey"];
|
|
18
|
+
var _navigator;
|
|
19
|
+
var isAppleDevice = /(mac|iphone|ipod|ipad)/i.test(typeof navigator !== 'undefined' ? (_navigator = navigator) === null || _navigator === void 0 ? void 0 : _navigator.platform : '');
|
|
20
|
+
var symbol = isAppleDevice ? '⌘' : 'Ctrl';
|
|
21
|
+
var SearchBar = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
22
|
+
var className = _ref.className,
|
|
23
|
+
value = _ref.value,
|
|
24
|
+
_onChange = _ref.onChange,
|
|
25
|
+
placeholder = _ref.placeholder,
|
|
26
|
+
enableShortKey = _ref.enableShortKey,
|
|
27
|
+
_ref$shortKey = _ref.shortKey,
|
|
28
|
+
shortKey = _ref$shortKey === void 0 ? 'f' : _ref$shortKey,
|
|
29
|
+
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
30
|
+
var _useState = (0, _react.useState)(true),
|
|
31
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
32
|
+
showTag = _useState2[0],
|
|
33
|
+
setShowTag = _useState2[1];
|
|
34
|
+
var _useState3 = (0, _react.useState)(value),
|
|
35
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
36
|
+
inputValue = _useState4[0],
|
|
37
|
+
setInputValue = _useState4[1];
|
|
38
|
+
var _useStyles = (0, _style.useStyles)(),
|
|
39
|
+
styles = _useStyles.styles,
|
|
40
|
+
cx = _useStyles.cx;
|
|
41
|
+
var inputRef = (0, _react.useRef)(null);
|
|
42
|
+
(0, _react.useEffect)(function () {
|
|
43
|
+
if (!enableShortKey) return;
|
|
44
|
+
var handler = function handler(ev) {
|
|
45
|
+
if ((isAppleDevice ? ev.metaKey : ev.ctrlKey) && ev.key === shortKey) {
|
|
46
|
+
var _inputRef$current;
|
|
47
|
+
ev.preventDefault();
|
|
48
|
+
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
document.addEventListener('keydown', handler);
|
|
52
|
+
return function () {
|
|
53
|
+
return document.removeEventListener('keydown', handler);
|
|
54
|
+
};
|
|
55
|
+
}, []);
|
|
56
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
57
|
+
className: styles.search,
|
|
58
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_.Input, (0, _objectSpread2.default)({
|
|
59
|
+
ref: inputRef,
|
|
60
|
+
className: cx(styles.input, className),
|
|
61
|
+
prefix: /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Icon, {
|
|
62
|
+
className: styles.icon,
|
|
63
|
+
icon: _lucideReact.Search,
|
|
64
|
+
size: "small",
|
|
65
|
+
style: {
|
|
66
|
+
marginRight: 4
|
|
48
67
|
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
setInputValue(e.target.value);
|
|
64
|
-
setShowTag(e.target.value ? false : true);
|
|
65
|
-
if (onChange)
|
|
66
|
-
onChange(e);
|
|
67
|
-
},
|
|
68
|
-
onFocus: () => setShowTag(false),
|
|
69
|
-
onBlur: () => setShowTag(true),
|
|
70
|
-
...props
|
|
68
|
+
}),
|
|
69
|
+
allowClear: true,
|
|
70
|
+
value: value,
|
|
71
|
+
placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : 'Type keywords...',
|
|
72
|
+
onChange: function onChange(e) {
|
|
73
|
+
setInputValue(e.target.value);
|
|
74
|
+
setShowTag(e.target.value ? false : true);
|
|
75
|
+
if (_onChange) _onChange(e);
|
|
76
|
+
},
|
|
77
|
+
onFocus: function onFocus() {
|
|
78
|
+
return setShowTag(false);
|
|
79
|
+
},
|
|
80
|
+
onBlur: function onBlur() {
|
|
81
|
+
return setShowTag(true);
|
|
71
82
|
}
|
|
72
|
-
), enableShortKey && showTag && !inputValue &&
|
|
73
|
-
|
|
74
|
-
)
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
83
|
+
}, props)), enableShortKey && showTag && !inputValue && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_antd.Tag, {
|
|
84
|
+
className: styles.tag,
|
|
85
|
+
children: [symbol, " ", shortKey.toUpperCase()]
|
|
86
|
+
})]
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
var _default = SearchBar;
|
|
90
|
+
exports.default = _default;
|