@lobehub/ui 1.168.2 → 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/Hotkey/index.d.ts +0 -1
- package/es/Hotkey/index.js +4 -12
- package/es/HotkeyInput/index.d.ts +1 -0
- package/es/HotkeyInput/index.js +7 -3
- package/es/Tooltip/index.d.ts +9 -4
- package/es/Tooltip/index.js +21 -3
- package/package.json +1 -1
package/es/Hotkey/index.d.ts
CHANGED
package/es/Hotkey/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
var _excluded = ["classNames", "styles", "keys", "
|
|
3
|
+
var _excluded = ["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; }
|
|
@@ -25,7 +25,6 @@ import { useStyles } from "./style";
|
|
|
25
25
|
import { KeyMap } from "./type";
|
|
26
26
|
import { checkIsAppleDevice, splitKeysByPlus, startCase } from "./utils";
|
|
27
27
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
28
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
29
28
|
var mappingKey = function mappingKey(isAppleDevice) {
|
|
30
29
|
var _ref;
|
|
31
30
|
return _ref = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_ref, KeyMap.Alt, isAppleDevice ? /*#__PURE__*/_jsx(Icon, {
|
|
@@ -84,7 +83,6 @@ var Hotkey = /*#__PURE__*/memo(function (_ref2) {
|
|
|
84
83
|
var classNames = _ref2.classNames,
|
|
85
84
|
styles = _ref2.styles,
|
|
86
85
|
keys = _ref2.keys,
|
|
87
|
-
desc = _ref2.desc,
|
|
88
86
|
inverseTheme = _ref2.inverseTheme,
|
|
89
87
|
isApple = _ref2.isApple,
|
|
90
88
|
compact = _ref2.compact,
|
|
@@ -109,7 +107,7 @@ var Hotkey = /*#__PURE__*/memo(function (_ref2) {
|
|
|
109
107
|
var mapping = useMemo(function () {
|
|
110
108
|
return mappingKey(isAppleDevice);
|
|
111
109
|
}, [isAppleDevice]);
|
|
112
|
-
return /*#__PURE__*/
|
|
110
|
+
return /*#__PURE__*/_jsx(Flexbox, _objectSpread(_objectSpread({
|
|
113
111
|
align: 'center',
|
|
114
112
|
className: cx(s, className),
|
|
115
113
|
gap: 2,
|
|
@@ -118,13 +116,7 @@ var Hotkey = /*#__PURE__*/memo(function (_ref2) {
|
|
|
118
116
|
visibility: visibility
|
|
119
117
|
}, style)
|
|
120
118
|
}, rest), {}, {
|
|
121
|
-
children:
|
|
122
|
-
className: classNames === null || classNames === void 0 ? void 0 : classNames.descClassName,
|
|
123
|
-
style: _objectSpread({
|
|
124
|
-
marginRight: 10
|
|
125
|
-
}, styles === null || styles === void 0 ? void 0 : styles.descStyle),
|
|
126
|
-
children: desc
|
|
127
|
-
}), compact ? /*#__PURE__*/_jsx(Flexbox, {
|
|
119
|
+
children: compact ? /*#__PURE__*/_jsx(Flexbox, {
|
|
128
120
|
align: 'center',
|
|
129
121
|
as: 'kbd',
|
|
130
122
|
className: classNames === null || classNames === void 0 ? void 0 : classNames.descClassName,
|
|
@@ -144,7 +136,7 @@ var Hotkey = /*#__PURE__*/memo(function (_ref2) {
|
|
|
144
136
|
style: styles === null || styles === void 0 ? void 0 : styles.kbdStyle,
|
|
145
137
|
children: (_mapping$key2 = mapping[key]) !== null && _mapping$key2 !== void 0 ? _mapping$key2 : startCase(key)
|
|
146
138
|
}, index);
|
|
147
|
-
})
|
|
139
|
+
})
|
|
148
140
|
}));
|
|
149
141
|
});
|
|
150
142
|
export default Hotkey;
|
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,
|
package/es/Tooltip/index.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { type TooltipProps as AntdTooltipProps } from 'antd';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { type HotkeyProps } from "../Hotkey";
|
|
4
|
+
export type TooltipProps = Omit<AntdTooltipProps, 'title'> & {
|
|
5
|
+
hotkey?: string;
|
|
6
|
+
hotkeyProps?: Omit<HotkeyProps, 'keys'>;
|
|
7
|
+
title: ReactNode;
|
|
8
|
+
};
|
|
9
|
+
declare const Tooltip: import("react").NamedExoticComponent<TooltipProps>;
|
|
5
10
|
export default Tooltip;
|
package/es/Tooltip/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
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); }
|
|
4
|
-
var _excluded = ["className", "arrow"];
|
|
4
|
+
var _excluded = ["hotkey", "className", "arrow", "title", "hotkeyProps"];
|
|
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; }
|
|
7
7
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -11,12 +11,18 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
11
11
|
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; }
|
|
12
12
|
import { Tooltip as AntdTooltip } from 'antd';
|
|
13
13
|
import { memo } from 'react';
|
|
14
|
+
import { Flexbox } from 'react-layout-kit';
|
|
15
|
+
import Hotkey from "../Hotkey";
|
|
14
16
|
import { useStyles } from "./style";
|
|
15
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
19
|
var Tooltip = /*#__PURE__*/memo(function (_ref) {
|
|
17
|
-
var
|
|
20
|
+
var hotkey = _ref.hotkey,
|
|
21
|
+
className = _ref.className,
|
|
18
22
|
_ref$arrow = _ref.arrow,
|
|
19
23
|
arrow = _ref$arrow === void 0 ? false : _ref$arrow,
|
|
24
|
+
title = _ref.title,
|
|
25
|
+
hotkeyProps = _ref.hotkeyProps,
|
|
20
26
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
21
27
|
var _useStyles = useStyles(),
|
|
22
28
|
styles = _useStyles.styles,
|
|
@@ -25,7 +31,19 @@ var Tooltip = /*#__PURE__*/memo(function (_ref) {
|
|
|
25
31
|
arrow: arrow,
|
|
26
32
|
classNames: {
|
|
27
33
|
root: cx(styles.tooltip, className)
|
|
28
|
-
}
|
|
34
|
+
},
|
|
35
|
+
title: hotkey ? /*#__PURE__*/_jsxs(Flexbox, {
|
|
36
|
+
align: 'center',
|
|
37
|
+
gap: 8,
|
|
38
|
+
horizontal: true,
|
|
39
|
+
justify: 'space-between',
|
|
40
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
41
|
+
children: title
|
|
42
|
+
}), /*#__PURE__*/_jsx(Hotkey, _objectSpread({
|
|
43
|
+
inverseTheme: true,
|
|
44
|
+
keys: hotkey
|
|
45
|
+
}, hotkeyProps))]
|
|
46
|
+
}) : title
|
|
29
47
|
}, rest));
|
|
30
48
|
});
|
|
31
49
|
export default Tooltip;
|