@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/Chat/utils/fetch.js
CHANGED
|
@@ -1,72 +1,108 @@
|
|
|
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
|
-
fetchSSE: () => fetchSSE
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
23
6
|
});
|
|
24
|
-
|
|
7
|
+
exports.fetchSSE = void 0;
|
|
8
|
+
var _regeneratorRuntime2 = _interopRequireDefault(require("@babel/runtime/helpers/regeneratorRuntime"));
|
|
9
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
25
10
|
var codeMessage = {
|
|
26
|
-
200:
|
|
27
|
-
201:
|
|
28
|
-
202:
|
|
29
|
-
204:
|
|
30
|
-
400:
|
|
31
|
-
401:
|
|
32
|
-
403:
|
|
33
|
-
404:
|
|
34
|
-
406:
|
|
35
|
-
410:
|
|
36
|
-
422:
|
|
37
|
-
500:
|
|
38
|
-
502:
|
|
39
|
-
503:
|
|
40
|
-
504:
|
|
11
|
+
200: '成功获取数据,服务已响应',
|
|
12
|
+
201: '操作成功,数据已保存',
|
|
13
|
+
202: '您的请求已进入后台排队,请耐心等待异步任务完成',
|
|
14
|
+
204: '数据已成功删除',
|
|
15
|
+
400: '很抱歉,您的请求出错,服务器未执行任何数据的创建或修改操作',
|
|
16
|
+
401: '很抱歉,您的权限不足。请确认用户名或密码是否正确',
|
|
17
|
+
403: '很抱歉,您无权访问此内容',
|
|
18
|
+
404: '很抱歉,您请求的记录不存在,服务器未能执行任何操作',
|
|
19
|
+
406: '很抱歉,服务器不支持该请求格式',
|
|
20
|
+
410: '很抱歉,你所请求的资源已永久删除',
|
|
21
|
+
422: '很抱歉,在创建对象时遇到验证错误,请稍后再试',
|
|
22
|
+
500: '很抱歉,服务器出现了问题,请稍后再试',
|
|
23
|
+
502: '很抱歉,您遇到了网关错误。这可能是由于网络故障或服务器问题导致的。请稍后再试,或联系管理员以获取更多帮助',
|
|
24
|
+
503: '很抱歉,我们的服务器过载或处在维护中,服务暂时不可用',
|
|
25
|
+
504: '很抱歉,网关请求超时,请稍后再试'
|
|
41
26
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
27
|
+
/**
|
|
28
|
+
* 使用流式方法获取数据
|
|
29
|
+
* @param fetchFn
|
|
30
|
+
* @param options
|
|
31
|
+
*/
|
|
32
|
+
var fetchSSE = /*#__PURE__*/function () {
|
|
33
|
+
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee(fetchFn) {
|
|
34
|
+
var options,
|
|
35
|
+
response,
|
|
36
|
+
_options$onErrorHandl,
|
|
37
|
+
chatMessageError,
|
|
38
|
+
returnRes,
|
|
39
|
+
data,
|
|
40
|
+
reader,
|
|
41
|
+
decoder,
|
|
42
|
+
done,
|
|
43
|
+
_options$onMessageHan,
|
|
44
|
+
_yield$reader$read,
|
|
45
|
+
value,
|
|
46
|
+
doneReading,
|
|
47
|
+
chunkValue,
|
|
48
|
+
_args = arguments;
|
|
49
|
+
return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
|
|
50
|
+
while (1) switch (_context.prev = _context.next) {
|
|
51
|
+
case 0:
|
|
52
|
+
options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
|
|
53
|
+
_context.next = 3;
|
|
54
|
+
return fetchFn();
|
|
55
|
+
case 3:
|
|
56
|
+
response = _context.sent;
|
|
57
|
+
if (response.ok) {
|
|
58
|
+
_context.next = 8;
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
chatMessageError = {
|
|
62
|
+
type: 'chatbot',
|
|
63
|
+
message: codeMessage[response.status],
|
|
64
|
+
status: response.status
|
|
65
|
+
};
|
|
66
|
+
(_options$onErrorHandl = options.onErrorHandle) === null || _options$onErrorHandl === void 0 ? void 0 : _options$onErrorHandl.call(options, chatMessageError);
|
|
67
|
+
return _context.abrupt("return");
|
|
68
|
+
case 8:
|
|
69
|
+
returnRes = response.clone();
|
|
70
|
+
data = response.body;
|
|
71
|
+
if (data) {
|
|
72
|
+
_context.next = 12;
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
return _context.abrupt("return");
|
|
76
|
+
case 12:
|
|
77
|
+
reader = data.getReader();
|
|
78
|
+
decoder = new TextDecoder();
|
|
79
|
+
done = false;
|
|
80
|
+
case 15:
|
|
81
|
+
if (done) {
|
|
82
|
+
_context.next = 26;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
_context.next = 18;
|
|
86
|
+
return reader.read();
|
|
87
|
+
case 18:
|
|
88
|
+
_yield$reader$read = _context.sent;
|
|
89
|
+
value = _yield$reader$read.value;
|
|
90
|
+
doneReading = _yield$reader$read.done;
|
|
91
|
+
done = doneReading;
|
|
92
|
+
chunkValue = decoder.decode(value);
|
|
93
|
+
(_options$onMessageHan = options.onMessageHandle) === null || _options$onMessageHan === void 0 ? void 0 : _options$onMessageHan.call(options, chunkValue);
|
|
94
|
+
_context.next = 15;
|
|
95
|
+
break;
|
|
96
|
+
case 26:
|
|
97
|
+
return _context.abrupt("return", returnRes);
|
|
98
|
+
case 27:
|
|
99
|
+
case "end":
|
|
100
|
+
return _context.stop();
|
|
101
|
+
}
|
|
102
|
+
}, _callee);
|
|
103
|
+
}));
|
|
104
|
+
return function fetchSSE(_x) {
|
|
105
|
+
return _ref.apply(this, arguments);
|
|
106
|
+
};
|
|
107
|
+
}();
|
|
108
|
+
exports.fetchSSE = fetchSSE;
|
|
@@ -1,100 +1,82 @@
|
|
|
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
|
-
__export(icons_exports, {
|
|
22
|
-
AltIcon: () => AltIcon,
|
|
23
|
-
CommandIcon: () => CommandIcon,
|
|
24
|
-
ControlIcon: () => ControlIcon,
|
|
25
|
-
ShiftIcon: () => ShiftIcon
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
26
5
|
});
|
|
27
|
-
|
|
6
|
+
exports.ShiftIcon = exports.ControlIcon = exports.CommandIcon = exports.AltIcon = void 0;
|
|
7
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
28
8
|
var strokeWidth = 2.2;
|
|
29
|
-
var iconSize =
|
|
30
|
-
var CommandIcon = ()
|
|
31
|
-
"svg",
|
|
32
|
-
{
|
|
9
|
+
var iconSize = '13px';
|
|
10
|
+
var CommandIcon = function CommandIcon() {
|
|
11
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
|
|
33
12
|
xmlns: "http://www.w3.org/2000/svg",
|
|
34
13
|
width: iconSize,
|
|
35
14
|
height: iconSize,
|
|
36
15
|
viewBox: "0 0 24 24",
|
|
37
16
|
fill: "none",
|
|
38
17
|
stroke: "currentColor",
|
|
39
|
-
strokeWidth,
|
|
18
|
+
strokeWidth: strokeWidth,
|
|
40
19
|
strokeLinecap: "round",
|
|
41
|
-
strokeLinejoin: "round"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
20
|
+
strokeLinejoin: "round",
|
|
21
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
|
22
|
+
d: "M18 3a3 3 0 0 0-3 3v12a3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3H6a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3V6a3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3h12a3 3 0 0 0 3-3 3 3 0 0 0-3-3z"
|
|
23
|
+
})
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
exports.CommandIcon = CommandIcon;
|
|
27
|
+
var ControlIcon = function ControlIcon() {
|
|
28
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
|
|
48
29
|
xmlns: "http://www.w3.org/2000/svg",
|
|
49
30
|
width: iconSize,
|
|
50
31
|
height: iconSize,
|
|
51
32
|
viewBox: "0 0 24 24",
|
|
52
33
|
fill: "none",
|
|
53
34
|
stroke: "currentColor",
|
|
54
|
-
strokeWidth,
|
|
35
|
+
strokeWidth: strokeWidth,
|
|
55
36
|
strokeLinecap: "round",
|
|
56
37
|
strokeLinejoin: "round",
|
|
57
|
-
className: "lucide lucide-chevron-up"
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
)
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
38
|
+
className: "lucide lucide-chevron-up",
|
|
39
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("polyline", {
|
|
40
|
+
points: "18 15 12 9 6 15"
|
|
41
|
+
})
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
exports.ControlIcon = ControlIcon;
|
|
45
|
+
var ShiftIcon = function ShiftIcon() {
|
|
46
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
|
|
64
47
|
xmlns: "http://www.w3.org/2000/svg",
|
|
65
48
|
width: iconSize,
|
|
66
49
|
height: iconSize,
|
|
67
50
|
viewBox: "0 0 24 24",
|
|
68
51
|
fill: "none",
|
|
69
52
|
stroke: "currentColor",
|
|
70
|
-
strokeWidth,
|
|
53
|
+
strokeWidth: strokeWidth,
|
|
71
54
|
strokeLinecap: "round",
|
|
72
55
|
strokeLinejoin: "round",
|
|
73
|
-
className: "lucide lucide-chevron-up"
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
)
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
56
|
+
className: "lucide lucide-chevron-up",
|
|
57
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
|
58
|
+
d: "M9 18v-6H5l7-7 7 7h-4v6H9z"
|
|
59
|
+
})
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
exports.ShiftIcon = ShiftIcon;
|
|
63
|
+
var AltIcon = function AltIcon() {
|
|
64
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("svg", {
|
|
80
65
|
xmlns: "http://www.w3.org/2000/svg",
|
|
81
66
|
width: iconSize,
|
|
82
67
|
height: iconSize,
|
|
83
68
|
viewBox: "0 0 24 24",
|
|
84
69
|
fill: "none",
|
|
85
70
|
stroke: "currentColor",
|
|
86
|
-
strokeWidth,
|
|
71
|
+
strokeWidth: strokeWidth,
|
|
87
72
|
strokeLinecap: "round",
|
|
88
73
|
strokeLinejoin: "round",
|
|
89
|
-
className: "lucide lucide-chevron-up"
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
ControlIcon,
|
|
99
|
-
ShiftIcon
|
|
100
|
-
});
|
|
74
|
+
className: "lucide lucide-chevron-up",
|
|
75
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
|
76
|
+
d: "M3 3h6l6 18h6"
|
|
77
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
|
78
|
+
d: "M14 3h7"
|
|
79
|
+
})]
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
exports.AltIcon = AltIcon;
|
|
@@ -1,72 +1,79 @@
|
|
|
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: () => MenuItem_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
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
11
|
+
var _lucideReact = require("lucide-react");
|
|
12
|
+
var _react = require("react");
|
|
13
|
+
var _reactLayoutKit = require("react-layout-kit");
|
|
14
|
+
var _icons = require("./icons");
|
|
15
|
+
var _style = require("./style");
|
|
16
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
|
+
var _excluded = ["label", "icon", "disabled", "nested", "shortcut", "active", "selected"];
|
|
30
18
|
var KEYBOARD_ICON_MAP = {
|
|
31
|
-
meta:
|
|
32
|
-
control:
|
|
33
|
-
shift:
|
|
34
|
-
alt:
|
|
35
|
-
enter:
|
|
19
|
+
meta: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.CommandIcon, {}),
|
|
20
|
+
control: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.ControlIcon, {}),
|
|
21
|
+
shift: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.ShiftIcon, {}),
|
|
22
|
+
alt: /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.AltIcon, {}),
|
|
23
|
+
enter: '↵'
|
|
36
24
|
};
|
|
37
25
|
var CODE_MAP = {
|
|
38
|
-
meta:
|
|
39
|
-
command:
|
|
40
|
-
cmd:
|
|
41
|
-
ctl:
|
|
42
|
-
control:
|
|
43
|
-
shift:
|
|
44
|
-
alt:
|
|
26
|
+
meta: 'meta',
|
|
27
|
+
command: 'meta',
|
|
28
|
+
cmd: 'meta',
|
|
29
|
+
ctl: 'control',
|
|
30
|
+
control: 'control',
|
|
31
|
+
shift: 'shift',
|
|
32
|
+
alt: 'alt'
|
|
45
33
|
};
|
|
46
|
-
var MenuItem = (0,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
)
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
34
|
+
var MenuItem = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
35
|
+
var _cx;
|
|
36
|
+
var label = _ref.label,
|
|
37
|
+
icon = _ref.icon,
|
|
38
|
+
disabled = _ref.disabled,
|
|
39
|
+
nested = _ref.nested,
|
|
40
|
+
shortcut = _ref.shortcut,
|
|
41
|
+
active = _ref.active,
|
|
42
|
+
selected = _ref.selected,
|
|
43
|
+
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
44
|
+
var _useStyles = (0, _style.useStyles)(),
|
|
45
|
+
styles = _useStyles.styles,
|
|
46
|
+
cx = _useStyles.cx;
|
|
47
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("button", (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
48
|
+
type: 'button'
|
|
49
|
+
}, props), {}, {
|
|
50
|
+
ref: ref,
|
|
51
|
+
role: "menuitem",
|
|
52
|
+
disabled: disabled,
|
|
53
|
+
className: cx(styles.item, (_cx = {}, (0, _defineProperty2.default)(_cx, styles.selected, selected), (0, _defineProperty2.default)(_cx, styles.active, active), _cx)),
|
|
54
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactLayoutKit.Flexbox, {
|
|
55
|
+
horizontal: true,
|
|
56
|
+
gap: 8,
|
|
57
|
+
children: [icon && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
58
|
+
children: icon
|
|
59
|
+
}), label]
|
|
60
|
+
}), nested ? /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
61
|
+
"aria-hidden": true,
|
|
62
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_lucideReact.ChevronRightIcon, {
|
|
63
|
+
className: styles.arrow
|
|
64
|
+
})
|
|
65
|
+
}) : shortcut ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactLayoutKit.Flexbox, {
|
|
66
|
+
horizontal: true,
|
|
67
|
+
align: 'center',
|
|
68
|
+
children: shortcut.map(function (c) {
|
|
69
|
+
var code = CODE_MAP[c.toLowerCase()];
|
|
70
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("kbd", {
|
|
71
|
+
className: styles.kbd,
|
|
72
|
+
children: code ? KEYBOARD_ICON_MAP[code] : c.toUpperCase()
|
|
73
|
+
}, c);
|
|
74
|
+
})
|
|
75
|
+
}) : null]
|
|
76
|
+
}));
|
|
77
|
+
});
|
|
78
|
+
var _default = MenuItem;
|
|
79
|
+
exports.default = _default;
|
|
@@ -1,94 +1,24 @@
|
|
|
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
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
color:
|
|
33
|
-
background: ${token.colorPrimaryBgHover};
|
|
34
|
-
}
|
|
35
|
-
`;
|
|
7
|
+
exports.useStyles = void 0;
|
|
8
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
9
|
+
var _antdStyle = require("antd-style");
|
|
10
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
11
|
+
var useStyles = (0, _antdStyle.createStyles)(function (_ref, prefixCls) {
|
|
12
|
+
var css = _ref.css,
|
|
13
|
+
cx = _ref.cx,
|
|
14
|
+
token = _ref.token;
|
|
15
|
+
var selected = css(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n font-weight: bold;\n color: ", ";\n background: ", ";\n &:hover {\n color: ", ";\n background: ", ";\n }\n "])), token.colorPrimaryText, token.colorPrimaryBg, token.colorPrimaryTextHover, token.colorPrimaryBgHover);
|
|
36
16
|
return {
|
|
37
|
-
item: cx(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
user-select: none;
|
|
43
|
-
scroll-margin: 50px;
|
|
44
|
-
|
|
45
|
-
display: flex;
|
|
46
|
-
align-items: center;
|
|
47
|
-
justify-content: space-between;
|
|
48
|
-
|
|
49
|
-
box-sizing: inherit;
|
|
50
|
-
width: 100%;
|
|
51
|
-
padding: 12px 10px;
|
|
52
|
-
|
|
53
|
-
font-family: ${token.fontFamily};
|
|
54
|
-
font-weight: normal;
|
|
55
|
-
line-height: 1;
|
|
56
|
-
color: ${token.colorText};
|
|
57
|
-
|
|
58
|
-
background: transparent;
|
|
59
|
-
border-radius: 5px;
|
|
60
|
-
&:hover {
|
|
61
|
-
background: ${token.colorFillTertiary};
|
|
62
|
-
}
|
|
63
|
-
`
|
|
64
|
-
),
|
|
65
|
-
selected: cx(`${prefixCls}-item-selected`, selected),
|
|
66
|
-
active: cx(
|
|
67
|
-
`${prefixCls}-item-active`,
|
|
68
|
-
css`
|
|
69
|
-
background: ${token.colorFillTertiary};
|
|
70
|
-
`
|
|
71
|
-
),
|
|
72
|
-
arrow: css`
|
|
73
|
-
color: ${token.colorTextTertiary};
|
|
74
|
-
`,
|
|
75
|
-
kbd: css`
|
|
76
|
-
display: flex;
|
|
77
|
-
align-items: center;
|
|
78
|
-
justify-content: center;
|
|
79
|
-
|
|
80
|
-
width: 18px;
|
|
81
|
-
height: 20px;
|
|
82
|
-
|
|
83
|
-
font-family: ${token.fontFamily};
|
|
84
|
-
font-size: 14px;
|
|
85
|
-
color: ${token.colorTextQuaternary};
|
|
86
|
-
|
|
87
|
-
border-radius: 2px;
|
|
88
|
-
`
|
|
17
|
+
item: cx("".concat(prefixCls, "-item"), css(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n all: unset;\n\n user-select: none;\n scroll-margin: 50px;\n\n display: flex;\n align-items: center;\n justify-content: space-between;\n\n box-sizing: inherit;\n width: 100%;\n padding: 12px 10px;\n\n font-family: ", ";\n font-weight: normal;\n line-height: 1;\n color: ", ";\n\n background: transparent;\n border-radius: 5px;\n &:hover {\n background: ", ";\n }\n "])), token.fontFamily, token.colorText, token.colorFillTertiary)),
|
|
18
|
+
selected: cx("".concat(prefixCls, "-item-selected"), selected),
|
|
19
|
+
active: cx("".concat(prefixCls, "-item-active"), css(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n background: ", ";\n "])), token.colorFillTertiary)),
|
|
20
|
+
arrow: css(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n color: ", ";\n "])), token.colorTextTertiary),
|
|
21
|
+
kbd: css(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n align-items: center;\n justify-content: center;\n\n width: 18px;\n height: 20px;\n\n font-family: ", ";\n font-size: 14px;\n color: ", ";\n\n border-radius: 2px;\n "])), token.fontFamily, token.colorTextQuaternary)
|
|
89
22
|
};
|
|
90
23
|
});
|
|
91
|
-
|
|
92
|
-
0 && (module.exports = {
|
|
93
|
-
useStyles
|
|
94
|
-
});
|
|
24
|
+
exports.useStyles = useStyles;
|