@lobehub/ui 1.168.11 → 1.168.12
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/chat/MessageInput/index.js +16 -23
- package/package.json +1 -1
|
@@ -16,12 +16,13 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
16
16
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
17
17
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
18
18
|
import { Button } from 'antd';
|
|
19
|
-
import { ChevronUpIcon, CommandIcon, CornerDownLeft } from 'lucide-react';
|
|
20
19
|
import { memo, useState } from 'react';
|
|
20
|
+
import { useHotkeys } from 'react-hotkeys-hook';
|
|
21
21
|
import { Flexbox } from 'react-layout-kit';
|
|
22
|
-
import
|
|
22
|
+
import Hotkey from "../../Hotkey";
|
|
23
|
+
import { KeyMapEnum } from "../../Hotkey/type";
|
|
24
|
+
import { combineKeys } from "../../Hotkey/utils";
|
|
23
25
|
import { TextArea } from "../../Input";
|
|
24
|
-
import { isMacLike } from "../../utils/platform";
|
|
25
26
|
import { useStyles } from "./style";
|
|
26
27
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
27
28
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -52,7 +53,15 @@ var MessageInput = /*#__PURE__*/memo(function (_ref) {
|
|
|
52
53
|
var _useStyles = useStyles(),
|
|
53
54
|
cx = _useStyles.cx,
|
|
54
55
|
styles = _useStyles.styles;
|
|
56
|
+
var hotkey = combineKeys([KeyMapEnum.Mod, KeyMapEnum.Enter]);
|
|
55
57
|
var isAutoSize = height === 'auto';
|
|
58
|
+
useHotkeys(hotkey, function () {
|
|
59
|
+
return onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm(temporaryValue);
|
|
60
|
+
}, {
|
|
61
|
+
enableOnFormTags: true,
|
|
62
|
+
enabled: shortcut,
|
|
63
|
+
preventDefault: true
|
|
64
|
+
});
|
|
56
65
|
return /*#__PURE__*/_jsxs(Flexbox, _objectSpread(_objectSpread({
|
|
57
66
|
gap: 16,
|
|
58
67
|
style: _objectSpread({
|
|
@@ -70,11 +79,6 @@ var MessageInput = /*#__PURE__*/memo(function (_ref) {
|
|
|
70
79
|
onChange: function onChange(e) {
|
|
71
80
|
return setValue(e.target.value);
|
|
72
81
|
},
|
|
73
|
-
onPressEnter: shortcut ? function (e) {
|
|
74
|
-
if (isMacLike ? e.metaKey : e.ctrlKey) {
|
|
75
|
-
onConfirm === null || onConfirm === void 0 || onConfirm(temporaryValue);
|
|
76
|
-
}
|
|
77
|
-
} : undefined,
|
|
78
82
|
placeholder: placeholder,
|
|
79
83
|
resize: false,
|
|
80
84
|
style: textareaStyle,
|
|
@@ -90,24 +94,13 @@ var MessageInput = /*#__PURE__*/memo(function (_ref) {
|
|
|
90
94
|
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
91
95
|
children: [/*#__PURE__*/_jsxs(Button, {
|
|
92
96
|
onClick: function onClick() {
|
|
93
|
-
onConfirm === null || onConfirm === void 0
|
|
97
|
+
return onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm(temporaryValue);
|
|
94
98
|
},
|
|
95
99
|
size: editButtonSize,
|
|
96
100
|
type: "primary",
|
|
97
|
-
children: [(text === null || text === void 0 ? void 0 : text.confirm) || 'Confirm', shortcut && /*#__PURE__*/
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
children: [/*#__PURE__*/_jsx(Icon, {
|
|
101
|
-
icon: isMacLike ? CommandIcon : ChevronUpIcon,
|
|
102
|
-
size: {
|
|
103
|
-
fontSize: 12
|
|
104
|
-
}
|
|
105
|
-
}), /*#__PURE__*/_jsx(Icon, {
|
|
106
|
-
icon: CornerDownLeft,
|
|
107
|
-
size: {
|
|
108
|
-
fontSize: 12
|
|
109
|
-
}
|
|
110
|
-
})]
|
|
101
|
+
children: [(text === null || text === void 0 ? void 0 : text.confirm) || 'Confirm', shortcut && /*#__PURE__*/_jsx(Hotkey, {
|
|
102
|
+
inverseTheme: true,
|
|
103
|
+
keys: combineKeys([KeyMapEnum.Mod, KeyMapEnum.Enter])
|
|
111
104
|
})]
|
|
112
105
|
}), /*#__PURE__*/_jsx(Button, {
|
|
113
106
|
onClick: onCancel,
|