@lobehub/ui 1.168.18 → 1.168.20
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/Highlighter/style.d.ts +1 -1
- package/es/Hotkey/index.d.ts +1 -0
- package/es/Hotkey/index.js +15 -7
- package/es/Hotkey/style.js +1 -1
- package/es/Hotkey/type.d.ts +1 -0
- package/es/Hotkey/type.js +1 -0
- package/es/Mermaid/style.d.ts +1 -1
- package/es/chat/MessageInput/index.js +37 -20
- package/es/hooks/useHighlight.d.ts +6 -0
- package/es/hooks/useHighlight.js +3 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const useStyles: (props?: "block" | "
|
|
1
|
+
export declare const useStyles: (props?: "block" | "pure" | "ghost" | undefined) => import("antd-style").ReturnStyles<{
|
|
2
2
|
button: string;
|
|
3
3
|
container: string;
|
|
4
4
|
header: import("antd-style").SerializedStyles;
|
package/es/Hotkey/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export interface HotkeyProps extends Omit<FlexboxProps, 'children'> {
|
|
|
13
13
|
descStyle?: CSSProperties;
|
|
14
14
|
kbdStyle?: CSSProperties;
|
|
15
15
|
};
|
|
16
|
+
variant?: 'default' | 'pure';
|
|
16
17
|
}
|
|
17
18
|
declare const Hotkey: import("react").NamedExoticComponent<HotkeyProps>;
|
|
18
19
|
export default Hotkey;
|
package/es/Hotkey/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
var _excluded = ["classNames", "styles", "keys", "inverseTheme", "isApple", "compact", "className", "style"];
|
|
3
|
+
var _excluded = ["variant", "classNames", "styles", "keys", "inverseTheme", "isApple", "compact", "className", "style"];
|
|
4
4
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
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; }
|
|
@@ -94,7 +94,9 @@ var mappingKey = function mappingKey(isAppleDevice) {
|
|
|
94
94
|
})), KeyMapEnum.Comma, ','), KeyMapEnum.Period, '.'), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_ref, KeyMapEnum.Slash, '/'), KeyMapEnum.Semicolon, ';'), KeyMapEnum.Quote, "'"), KeyMapEnum.Backquote, '`'), KeyMapEnum.Backslash, '\\'), KeyMapEnum.BracketLeft, '['), KeyMapEnum.BracketRight, ']'), KeyMapEnum.Minus, '-'), KeyMapEnum.Equal, '=');
|
|
95
95
|
};
|
|
96
96
|
var Hotkey = /*#__PURE__*/memo(function (_ref2) {
|
|
97
|
-
var
|
|
97
|
+
var _ref2$variant = _ref2.variant,
|
|
98
|
+
variant = _ref2$variant === void 0 ? 'default' : _ref2$variant,
|
|
99
|
+
classNames = _ref2.classNames,
|
|
98
100
|
styles = _ref2.styles,
|
|
99
101
|
keys = _ref2.keys,
|
|
100
102
|
inverseTheme = _ref2.inverseTheme,
|
|
@@ -106,6 +108,7 @@ var Hotkey = /*#__PURE__*/memo(function (_ref2) {
|
|
|
106
108
|
var _useStyles = useStyles(inverseTheme),
|
|
107
109
|
cx = _useStyles.cx,
|
|
108
110
|
s = _useStyles.styles;
|
|
111
|
+
var isPure = variant === 'pure';
|
|
109
112
|
var _useState = useState(splitKeysByPlus(keys)),
|
|
110
113
|
_useState2 = _slicedToArray(_useState, 2),
|
|
111
114
|
keysGroup = _useState2[0],
|
|
@@ -130,7 +133,12 @@ var Hotkey = /*#__PURE__*/memo(function (_ref2) {
|
|
|
130
133
|
visibility: visibility
|
|
131
134
|
}, style)
|
|
132
135
|
}, rest), {}, {
|
|
133
|
-
children:
|
|
136
|
+
children: isPure ? keysGroup.map(function (key, index) {
|
|
137
|
+
var _mapping$key;
|
|
138
|
+
return /*#__PURE__*/_jsx("span", {
|
|
139
|
+
children: (_mapping$key = mapping[key]) !== null && _mapping$key !== void 0 ? _mapping$key : startCase(key)
|
|
140
|
+
}, index);
|
|
141
|
+
}) : compact ? /*#__PURE__*/_jsx(Flexbox, {
|
|
134
142
|
align: 'center',
|
|
135
143
|
as: 'kbd',
|
|
136
144
|
className: classNames === null || classNames === void 0 ? void 0 : classNames.descClassName,
|
|
@@ -138,17 +146,17 @@ var Hotkey = /*#__PURE__*/memo(function (_ref2) {
|
|
|
138
146
|
horizontal: true,
|
|
139
147
|
style: styles === null || styles === void 0 ? void 0 : styles.kbdStyle,
|
|
140
148
|
children: keysGroup.map(function (key, index) {
|
|
141
|
-
var _mapping$
|
|
149
|
+
var _mapping$key2;
|
|
142
150
|
return /*#__PURE__*/_jsx("div", {
|
|
143
|
-
children: (_mapping$
|
|
151
|
+
children: (_mapping$key2 = mapping[key]) !== null && _mapping$key2 !== void 0 ? _mapping$key2 : startCase(key)
|
|
144
152
|
}, index);
|
|
145
153
|
})
|
|
146
154
|
}) : keysGroup.map(function (key, index) {
|
|
147
|
-
var _mapping$
|
|
155
|
+
var _mapping$key3;
|
|
148
156
|
return /*#__PURE__*/_jsx("kbd", {
|
|
149
157
|
className: classNames === null || classNames === void 0 ? void 0 : classNames.descClassName,
|
|
150
158
|
style: styles === null || styles === void 0 ? void 0 : styles.kbdStyle,
|
|
151
|
-
children: (_mapping$
|
|
159
|
+
children: (_mapping$key3 = mapping[key]) !== null && _mapping$key3 !== void 0 ? _mapping$key3 : startCase(key)
|
|
152
160
|
}, index);
|
|
153
161
|
})
|
|
154
162
|
}));
|
package/es/Hotkey/style.js
CHANGED
|
@@ -5,5 +5,5 @@ import { rgba } from 'polished';
|
|
|
5
5
|
export var useStyles = createStyles(function (_ref, inverseTheme) {
|
|
6
6
|
var css = _ref.css,
|
|
7
7
|
token = _ref.token;
|
|
8
|
-
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n kbd {\n overflow: hidden;\n display: flex;\n flex: none;\n align-items: center;\n justify-content: center;\n\n min-width: 16px;\n height: 22px;\n padding-block: 0;\n padding-inline: 8px;\n\n font-family: ", ";\n font-size: 12px;\n line-height: 1.1;\n color:
|
|
8
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n\n kbd {\n overflow: hidden;\n display: flex;\n flex: none;\n align-items: center;\n justify-content: center;\n\n min-width: 16px;\n height: 22px;\n padding-block: 0;\n padding-inline: 8px;\n\n font-family: ", ";\n font-size: 12px;\n line-height: 1.1;\n color: inherit;\n text-align: center;\n white-space: nowrap;\n\n background: ", ";\n border: none;\n border-radius: ", "px;\n }\n "])), inverseTheme ? token.colorTextTertiary : token.colorTextSecondary, token.fontFamily, inverseTheme ? rgba(token.colorTextTertiary, 0.15) : token.colorFillTertiary, token.borderRadiusSM);
|
|
9
9
|
});
|
package/es/Hotkey/type.d.ts
CHANGED
package/es/Hotkey/type.js
CHANGED
package/es/Mermaid/style.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const useStyles: (props?: "block" | "
|
|
1
|
+
export declare const useStyles: (props?: "block" | "pure" | "ghost" | undefined) => import("antd-style").ReturnStyles<{
|
|
2
2
|
button: string;
|
|
3
3
|
container: string;
|
|
4
4
|
header: import("antd-style").SerializedStyles;
|
|
@@ -19,14 +19,14 @@ import { Button } from 'antd';
|
|
|
19
19
|
import { memo, useState } from 'react';
|
|
20
20
|
import { useHotkeys } from 'react-hotkeys-hook';
|
|
21
21
|
import { Flexbox } from 'react-layout-kit';
|
|
22
|
-
import Hotkey from "../../Hotkey";
|
|
23
22
|
import { KeyMapEnum } from "../../Hotkey/type";
|
|
24
23
|
import { combineKeys } from "../../Hotkey/utils";
|
|
25
24
|
import { TextArea } from "../../Input";
|
|
25
|
+
import Tooltip from "../../Tooltip";
|
|
26
26
|
import { useStyles } from "./style";
|
|
27
27
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
28
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
29
28
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
29
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
30
30
|
var MessageInput = /*#__PURE__*/memo(function (_ref) {
|
|
31
31
|
var text = _ref.text,
|
|
32
32
|
_ref$type = _ref.type,
|
|
@@ -53,15 +53,38 @@ var MessageInput = /*#__PURE__*/memo(function (_ref) {
|
|
|
53
53
|
var _useStyles = useStyles(),
|
|
54
54
|
cx = _useStyles.cx,
|
|
55
55
|
styles = _useStyles.styles;
|
|
56
|
-
var
|
|
56
|
+
var confirmHotkey = combineKeys([KeyMapEnum.Mod, KeyMapEnum.Enter]);
|
|
57
|
+
var confirmText = (text === null || text === void 0 ? void 0 : text.confirm) || 'Confirm';
|
|
58
|
+
var cancelHotkey = combineKeys([KeyMapEnum.Esc]);
|
|
59
|
+
var cancelText = (text === null || text === void 0 ? void 0 : text.cancel) || 'Cancel';
|
|
57
60
|
var isAutoSize = height === 'auto';
|
|
58
|
-
|
|
61
|
+
var handleConfirm = function handleConfirm() {
|
|
59
62
|
return onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm(temporaryValue);
|
|
60
|
-
}
|
|
63
|
+
};
|
|
64
|
+
var handleCancel = function handleCancel() {
|
|
65
|
+
return onCancel === null || onCancel === void 0 ? void 0 : onCancel();
|
|
66
|
+
};
|
|
67
|
+
useHotkeys(confirmHotkey, handleConfirm, {
|
|
68
|
+
enableOnFormTags: true,
|
|
69
|
+
enabled: shortcut,
|
|
70
|
+
preventDefault: true
|
|
71
|
+
});
|
|
72
|
+
useHotkeys(cancelHotkey, handleCancel, {
|
|
61
73
|
enableOnFormTags: true,
|
|
62
74
|
enabled: shortcut,
|
|
63
75
|
preventDefault: true
|
|
64
76
|
});
|
|
77
|
+
var confirmButton = /*#__PURE__*/_jsx(Button, {
|
|
78
|
+
onClick: handleConfirm,
|
|
79
|
+
size: editButtonSize,
|
|
80
|
+
type: "primary",
|
|
81
|
+
children: confirmText
|
|
82
|
+
});
|
|
83
|
+
var cancllButton = /*#__PURE__*/_jsx(Button, {
|
|
84
|
+
onClick: handleCancel,
|
|
85
|
+
size: editButtonSize,
|
|
86
|
+
children: (text === null || text === void 0 ? void 0 : text.cancel) || 'Cancel'
|
|
87
|
+
});
|
|
65
88
|
return /*#__PURE__*/_jsxs(Flexbox, _objectSpread(_objectSpread({
|
|
66
89
|
gap: 16,
|
|
67
90
|
style: _objectSpread({
|
|
@@ -92,21 +115,15 @@ var MessageInput = /*#__PURE__*/memo(function (_ref) {
|
|
|
92
115
|
size: "small"
|
|
93
116
|
}, buttonProps), index);
|
|
94
117
|
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
95
|
-
children: [/*#__PURE__*/
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
})]
|
|
105
|
-
}), /*#__PURE__*/_jsx(Button, {
|
|
106
|
-
onClick: onCancel,
|
|
107
|
-
size: editButtonSize,
|
|
108
|
-
children: (text === null || text === void 0 ? void 0 : text.cancel) || 'Cancel'
|
|
109
|
-
})]
|
|
118
|
+
children: [shortcut ? /*#__PURE__*/_jsx(Tooltip, {
|
|
119
|
+
hotkey: confirmHotkey,
|
|
120
|
+
title: confirmText,
|
|
121
|
+
children: confirmButton
|
|
122
|
+
}) : confirmButton, shortcut ? /*#__PURE__*/_jsx(Tooltip, {
|
|
123
|
+
hotkey: cancelHotkey,
|
|
124
|
+
title: cancelText,
|
|
125
|
+
children: cancllButton
|
|
126
|
+
}) : cancllButton]
|
|
110
127
|
})
|
|
111
128
|
})]
|
|
112
129
|
}));
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { SWRResponse } from 'swr';
|
|
2
2
|
export declare const FALLBACK_LANG = "txt";
|
|
3
|
+
declare const highlightCache: Map<string, string>;
|
|
4
|
+
declare const MD5_LENGTH_THRESHOLD = 10000;
|
|
5
|
+
declare const loadShiki: () => Promise<(code: string, options: import("@shikijs/types").CodeToHastOptions<import("shiki/dist/langs.mjs").BundledLanguage, import("shiki/dist/themes.mjs").BundledTheme>) => Promise<string>>;
|
|
6
|
+
declare const shikiPromise: Promise<(code: string, options: import("@shikijs/types").CodeToHastOptions<import("shiki/dist/langs.mjs").BundledLanguage, import("shiki/dist/themes.mjs").BundledTheme>) => Promise<string>>;
|
|
7
|
+
declare const escapeHtml: (str: string) => string;
|
|
3
8
|
export declare const useHighlight: (text: string, lang: string, enableTransformer?: boolean) => SWRResponse<string, Error>;
|
|
4
9
|
export { default as languageMap } from './languageMap';
|
|
10
|
+
export { escapeHtml, highlightCache, loadShiki, MD5_LENGTH_THRESHOLD, shikiPromise };
|
package/es/hooks/useHighlight.js
CHANGED
|
@@ -80,7 +80,7 @@ export var useHighlight = function useHighlight(text, lang, enableTransformer) {
|
|
|
80
80
|
// 长文本使用 hash
|
|
81
81
|
var hash = text.length < MD5_LENGTH_THRESHOLD ? text : Md5.hashStr(text);
|
|
82
82
|
return [matchedLanguage, isDarkMode ? 'd' : 'l', hash].join('-');
|
|
83
|
-
}, [matchedLanguage, isDarkMode]);
|
|
83
|
+
}, [text, matchedLanguage, isDarkMode]);
|
|
84
84
|
|
|
85
85
|
// 使用SWR获取高亮HTML
|
|
86
86
|
return useSWR(cacheKey, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
@@ -150,4 +150,5 @@ export var useHighlight = function useHighlight(text, lang, enableTransformer) {
|
|
|
150
150
|
revalidateOnReconnect: false
|
|
151
151
|
});
|
|
152
152
|
};
|
|
153
|
-
export { default as languageMap } from "./languageMap";
|
|
153
|
+
export { default as languageMap } from "./languageMap";
|
|
154
|
+
export { escapeHtml, highlightCache, loadShiki, MD5_LENGTH_THRESHOLD, shikiPromise };
|