@lobehub/ui 1.168.3 → 1.168.4
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/HotkeyInput/index.js
CHANGED
|
@@ -32,6 +32,7 @@ var HotkeyInput = /*#__PURE__*/memo(function (_ref) {
|
|
|
32
32
|
value = _ref$value === void 0 ? '' : _ref$value,
|
|
33
33
|
_ref$defaultValue = _ref.defaultValue,
|
|
34
34
|
defaultValue = _ref$defaultValue === void 0 ? '' : _ref$defaultValue,
|
|
35
|
+
resetValue = _ref.resetValue,
|
|
35
36
|
onChange = _ref.onChange,
|
|
36
37
|
onConflict = _ref.onConflict,
|
|
37
38
|
_ref$placeholder = _ref.placeholder,
|
|
@@ -79,6 +80,7 @@ var HotkeyInput = /*#__PURE__*/memo(function (_ref) {
|
|
|
79
80
|
stop = _useRecordHotkeys2$.stop,
|
|
80
81
|
isRecording = _useRecordHotkeys2$.isRecording,
|
|
81
82
|
resetKeys = _useRecordHotkeys2$.resetKeys;
|
|
83
|
+
var oldValue = resetValue || defaultValue;
|
|
82
84
|
useHotkeys('*', function () {
|
|
83
85
|
var _inputRef$current;
|
|
84
86
|
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.blur();
|
|
@@ -145,7 +147,9 @@ var HotkeyInput = /*#__PURE__*/memo(function (_ref) {
|
|
|
145
147
|
|
|
146
148
|
// 检查快捷键冲突
|
|
147
149
|
var checkHotkeyConflict = useCallback(function (newHotkey) {
|
|
148
|
-
return hotkeyConflicts.
|
|
150
|
+
return hotkeyConflicts.filter(function (conflictKey) {
|
|
151
|
+
return conflictKey !== oldValue;
|
|
152
|
+
}).some(function (conflictKey) {
|
|
149
153
|
var newKeys = splitKeysByPlus(newHotkey);
|
|
150
154
|
var conflictKeys = splitKeysByPlus(conflictKey);
|
|
151
155
|
return isEqual(newKeys.sort(), conflictKeys.sort());
|
|
@@ -193,7 +197,7 @@ var HotkeyInput = /*#__PURE__*/memo(function (_ref) {
|
|
|
193
197
|
var handleReset = function handleReset(e) {
|
|
194
198
|
e.preventDefault();
|
|
195
199
|
e.stopPropagation();
|
|
196
|
-
onChange === null || onChange === void 0 || onChange(
|
|
200
|
+
onChange === null || onChange === void 0 || onChange(oldValue);
|
|
197
201
|
resetKeys();
|
|
198
202
|
setHasConflict(false);
|
|
199
203
|
setHasInvalidCombination(false);
|
|
@@ -239,7 +243,7 @@ var HotkeyInput = /*#__PURE__*/memo(function (_ref) {
|
|
|
239
243
|
style: {
|
|
240
244
|
pointerEvents: 'none'
|
|
241
245
|
}
|
|
242
|
-
}), allowReset && value && value !==
|
|
246
|
+
}), allowReset && value && value !== oldValue && !disabled && /*#__PURE__*/_jsx(ActionIcon, {
|
|
243
247
|
active: true,
|
|
244
248
|
icon: Undo2Icon,
|
|
245
249
|
onClick: handleReset,
|