@lobehub/ui 2.0.6 → 2.0.8

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.
@@ -96,7 +96,6 @@ var Drawer = /*#__PURE__*/memo(function (_ref) {
96
96
  style: _objectSpread({
97
97
  background: theme.colorBgLayout,
98
98
  borderRight: "1px solid ".concat(theme.colorBorderSecondary),
99
- height: '100%',
100
99
  overflowX: 'hidden',
101
100
  overflowY: 'auto'
102
101
  }, styles === null || styles === void 0 ? void 0 : styles.sidebar),
@@ -109,7 +108,6 @@ var Drawer = /*#__PURE__*/memo(function (_ref) {
109
108
  paddingInline: 16,
110
109
  style: _objectSpread({
111
110
  background: theme.colorBgContainer,
112
- height: '100%',
113
111
  overflowX: 'hidden',
114
112
  overflowY: 'auto'
115
113
  }, styles === null || styles === void 0 ? void 0 : styles.sidebarContent),
@@ -6,6 +6,7 @@ export declare const KeyMapEnum: {
6
6
  readonly BracketLeft: "bracketleft";
7
7
  readonly BracketRight: "bracketright";
8
8
  readonly Comma: "comma";
9
+ readonly Control: "control";
9
10
  readonly Ctrl: "ctrl";
10
11
  readonly Down: "down";
11
12
  readonly Enter: "enter";
@@ -10,7 +10,7 @@ export var KeyMapEnum = {
10
10
  BracketRight: 'bracketright',
11
11
  // ]
12
12
  Comma: 'comma',
13
- // ,
13
+ Control: 'control',
14
14
  Ctrl: 'ctrl',
15
15
  Down: 'down',
16
16
  Enter: 'enter',
@@ -1,3 +1,4 @@
1
+ export declare const NORMATIVE_MODIFIER: ("shift" | "alt" | "control" | "ctrl" | "meta" | "mod")[];
1
2
  export declare const splitKeysByPlus: (keys: string) => string[];
2
3
  export declare const startCase: (str: string) => string;
3
4
  export declare const checkIsAppleDevice: (isApple?: boolean) => boolean;
@@ -1,6 +1,25 @@
1
1
  import { KeyMapEnum } from "./const";
2
+
3
+ // https://superuser.com/questions/1238058/key-combination-order
4
+ export var NORMATIVE_MODIFIER = [
5
+ // win: Ctrl ,mac: Control
6
+ KeyMapEnum.Ctrl, KeyMapEnum.Control,
7
+ // win: Alt ,mac: Option
8
+ KeyMapEnum.Alt,
9
+ // win: Shift ,mac: Shift
10
+ KeyMapEnum.Shift,
11
+ // win: Win ,mac: Command
12
+ KeyMapEnum.Meta, KeyMapEnum.Mod];
13
+ var orderMap = Object.fromEntries(NORMATIVE_MODIFIER.map(function (key, index) {
14
+ return [key, index];
15
+ }));
2
16
  export var splitKeysByPlus = function splitKeysByPlus(keys) {
3
- return keys.replaceAll('++', "+".concat(KeyMapEnum.Equal)).split('+');
17
+ return keys.replaceAll('++', "+".concat(KeyMapEnum.Equal)).split('+').sort(function (x, y) {
18
+ var _orderMap$x$toLowerCa, _orderMap$y$toLowerCa;
19
+ var idxX = (_orderMap$x$toLowerCa = orderMap[x.toLowerCase()]) !== null && _orderMap$x$toLowerCa !== void 0 ? _orderMap$x$toLowerCa : orderMap.length;
20
+ var idxY = (_orderMap$y$toLowerCa = orderMap[y.toLowerCase()]) !== null && _orderMap$y$toLowerCa !== void 0 ? _orderMap$y$toLowerCa : orderMap.length;
21
+ return idxX - idxY;
22
+ });
4
23
  };
5
24
  export var startCase = function startCase(str) {
6
25
  return str.replaceAll(/([A-Z])/g, ' $1').replace(/^./, function (s) {
@@ -22,12 +22,10 @@ import { Flexbox } from 'react-layout-kit';
22
22
  import useControlledState from 'use-merge-value';
23
23
  import ActionIcon from "../ActionIcon";
24
24
  import Hotkey from "../Hotkey";
25
- import { checkIsAppleDevice, splitKeysByPlus } from "../Hotkey/utils";
25
+ import { NORMATIVE_MODIFIER, checkIsAppleDevice, splitKeysByPlus } from "../Hotkey/utils";
26
26
  import { useStyles } from "./style";
27
27
  import { jsx as _jsx } from "react/jsx-runtime";
28
28
  import { jsxs as _jsxs } from "react/jsx-runtime";
29
- // 修饰键列表
30
- var MODIFIER_KEYS = new Set(['alt', 'mod', 'shift', 'meta', 'ctrl', 'control']);
31
29
  var HotkeyInput = /*#__PURE__*/memo(function (_ref) {
32
30
  var _ref$value = _ref.value,
33
31
  value = _ref$value === void 0 ? '' : _ref$value,
@@ -149,7 +147,7 @@ var HotkeyInput = /*#__PURE__*/memo(function (_ref) {
149
147
  var key = _step.value;
150
148
  // 处理不同表示的修饰键
151
149
  var normalizedKey = key.toLowerCase();
152
- if (MODIFIER_KEYS.has(normalizedKey)) {
150
+ if (NORMATIVE_MODIFIER.includes(normalizedKey)) {
153
151
  // 统一修饰键表示
154
152
  if (!isAppleDevice && normalizedKey === 'ctrl' || isAppleDevice && normalizedKey === 'meta') {
155
153
  if (!modifiers.includes('mod')) modifiers.push('mod');
@@ -176,12 +174,13 @@ var HotkeyInput = /*#__PURE__*/memo(function (_ref) {
176
174
 
177
175
  // 只允许一个非修饰键,如果有多个,只保留最后一个
178
176
  var finalKey = normalKeys.length > 0 ? [normalKeys.at(-1)] : [];
179
- var validKeys = [].concat(modifiers, finalKey);
180
-
181
- // 组合必须包含至少一个按键
177
+ var shortcuts = [modifiers, finalKey];
182
178
  return {
183
- isValid: validKeys.length > 0,
184
- keys: validKeys
179
+ // 组合必须包含至少一个按键
180
+ isValid: shortcuts.every(function (k) {
181
+ return k.length > 0;
182
+ }),
183
+ keys: shortcuts.flat()
185
184
  };
186
185
  }, []);
187
186
 
@@ -198,7 +197,7 @@ var HotkeyInput = /*#__PURE__*/memo(function (_ref) {
198
197
  }).some(function (conflictKey) {
199
198
  var newKeys = splitKeysByPlus(newHotkey);
200
199
  var conflictKeys = splitKeysByPlus(conflictKey);
201
- return isEqual(newKeys.sort(), conflictKeys.sort());
200
+ return isEqual(newKeys, conflictKeys);
202
201
  });
203
202
  }, [hotkeyConflicts]);
204
203
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "2.0.6",
3
+ "version": "2.0.8",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",