@lobehub/ui 2.4.0 → 2.4.2
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.
|
@@ -16,7 +16,7 @@ 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 { LucideLoader2, Search } from 'lucide-react';
|
|
19
|
-
import { memo, useRef, useState } from 'react';
|
|
19
|
+
import { memo, useMemo, useRef, useState } from 'react';
|
|
20
20
|
import { useHotkeys } from 'react-hotkeys-hook';
|
|
21
21
|
import useControlledState from 'use-merge-value';
|
|
22
22
|
import Hotkey from "../Hotkey";
|
|
@@ -69,13 +69,16 @@ var SearchBar = /*#__PURE__*/memo(function (_ref) {
|
|
|
69
69
|
styles = _useStyles.styles,
|
|
70
70
|
cx = _useStyles.cx;
|
|
71
71
|
var inputReference = useRef(null);
|
|
72
|
-
var hotkey =
|
|
72
|
+
var hotkey = useMemo(function () {
|
|
73
|
+
return shortKey.includes('+') ? shortKey : "mod+".concat(shortKey);
|
|
74
|
+
}, [shortKey]);
|
|
73
75
|
useHotkeys(hotkey, function () {
|
|
74
76
|
var _inputReference$curre;
|
|
75
77
|
if (!enableShortKey) return;
|
|
76
78
|
(_inputReference$curre = inputReference.current) === null || _inputReference$curre === void 0 || _inputReference$curre.focus();
|
|
77
79
|
}, {
|
|
78
80
|
enableOnFormTags: true,
|
|
81
|
+
enabled: !!enableShortKey && !!shortKey,
|
|
79
82
|
preventDefault: true
|
|
80
83
|
});
|
|
81
84
|
return /*#__PURE__*/_jsxs("div", {
|
|
@@ -113,7 +116,7 @@ var SearchBar = /*#__PURE__*/memo(function (_ref) {
|
|
|
113
116
|
}),
|
|
114
117
|
ref: inputReference,
|
|
115
118
|
style: inputStyle,
|
|
116
|
-
value:
|
|
119
|
+
value: inputValue
|
|
117
120
|
}, rest)), enableShortKey && showTag && !inputValue && /*#__PURE__*/_jsx(Hotkey, {
|
|
118
121
|
className: cx(styles.tag, shortKeyClassName),
|
|
119
122
|
compact: true,
|