@redis-ui/components 47.4.0 → 47.5.1

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.
Files changed (32) hide show
  1. package/dist/MultiSelect/components/Content/components/SelectAll/SelectAll.cjs +11 -7
  2. package/dist/MultiSelect/components/Content/components/SelectAll/SelectAll.js +12 -8
  3. package/dist/node_modules/@tanstack/hotkeys/dist/constants.cjs +389 -0
  4. package/dist/node_modules/@tanstack/hotkeys/dist/constants.js +383 -0
  5. package/dist/node_modules/@tanstack/hotkeys/dist/format.cjs +22 -0
  6. package/dist/node_modules/@tanstack/hotkeys/dist/format.js +22 -0
  7. package/dist/node_modules/@tanstack/hotkeys/dist/hotkey-manager.cjs +363 -0
  8. package/dist/node_modules/@tanstack/hotkeys/dist/hotkey-manager.js +363 -0
  9. package/dist/node_modules/@tanstack/hotkeys/dist/manager.utils.cjs +111 -0
  10. package/dist/node_modules/@tanstack/hotkeys/dist/manager.utils.js +107 -0
  11. package/dist/node_modules/@tanstack/hotkeys/dist/match.cjs +59 -0
  12. package/dist/node_modules/@tanstack/hotkeys/dist/match.js +59 -0
  13. package/dist/node_modules/@tanstack/hotkeys/dist/parse.cjs +143 -0
  14. package/dist/node_modules/@tanstack/hotkeys/dist/parse.js +141 -0
  15. package/dist/node_modules/@tanstack/react-hotkeys/dist/HotkeysProvider.cjs +10 -0
  16. package/dist/node_modules/@tanstack/react-hotkeys/dist/HotkeysProvider.js +8 -0
  17. package/dist/node_modules/@tanstack/react-hotkeys/dist/useHotkey.cjs +121 -0
  18. package/dist/node_modules/@tanstack/react-hotkeys/dist/useHotkey.js +120 -0
  19. package/dist/node_modules/@tanstack/react-hotkeys/dist/utils.cjs +9 -0
  20. package/dist/node_modules/@tanstack/react-hotkeys/dist/utils.js +9 -0
  21. package/dist/node_modules/@tanstack/store/dist/alien.cjs +183 -0
  22. package/dist/node_modules/@tanstack/store/dist/alien.js +182 -0
  23. package/dist/node_modules/@tanstack/store/dist/atom.cjs +161 -0
  24. package/dist/node_modules/@tanstack/store/dist/atom.js +160 -0
  25. package/dist/node_modules/@tanstack/store/dist/store.cjs +25 -0
  26. package/dist/node_modules/@tanstack/store/dist/store.js +25 -0
  27. package/package.json +3 -3
  28. package/skills/redis-ui-components/SKILL.md +1 -1
  29. package/skills/redis-ui-components/references/Icons.md +3 -3
  30. package/skills/redis-ui-components/references/SideBar.md +8 -8
  31. package/dist/node_modules/react-hotkeys-hook/dist/react-hotkeys-hook.esm.cjs +0 -289
  32. package/dist/node_modules/react-hotkeys-hook/dist/react-hotkeys-hook.esm.js +0 -288
@@ -0,0 +1,25 @@
1
+ import { createAtom, toObserver } from "./atom.js";
2
+ //#region ../../node_modules/@tanstack/store/dist/store.js
3
+ var Store = class {
4
+ constructor(valueOrFn, actionsFactory) {
5
+ this.atom = createAtom(valueOrFn);
6
+ this.get = this.get.bind(this);
7
+ this.setState = this.setState.bind(this);
8
+ this.subscribe = this.subscribe.bind(this);
9
+ if (actionsFactory) this.actions = actionsFactory(this);
10
+ }
11
+ setState(updater) {
12
+ this.atom.set(updater);
13
+ }
14
+ get state() {
15
+ return this.atom.get();
16
+ }
17
+ get() {
18
+ return this.state;
19
+ }
20
+ subscribe(observerOrFn) {
21
+ return this.atom.subscribe(toObserver(observerOrFn));
22
+ }
23
+ };
24
+ //#endregion
25
+ export { Store };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@redis-ui/components",
3
3
  "license": "UNLICENSED",
4
- "version": "47.4.0",
4
+ "version": "47.5.1",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "repository": "git@github.com:redislabsdev/redis-ui.git",
@@ -29,7 +29,7 @@
29
29
  "test": "vitest"
30
30
  },
31
31
  "peerDependencies": {
32
- "@redis-ui/icons": "^8.0.0",
32
+ "@redis-ui/icons": "^8.0.0 || ^9.0.0",
33
33
  "@redis-ui/styles": "^16.4.1",
34
34
  "react": "^17.0.0 || ^18.0.0 || ^19.0.0",
35
35
  "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0",
@@ -55,8 +55,8 @@
55
55
  "@radix-ui/react-use-controllable-state": "^1.2.2",
56
56
  "@radix-ui/react-visually-hidden": "^1.2.4",
57
57
  "@react-hook/resize-observer": "^2.0.2",
58
+ "@tanstack/react-hotkeys": "^0.10.0",
58
59
  "react-children-utilities": "2.9.0",
59
- "react-hotkeys-hook": "^4.6.1",
60
60
  "react-loading-skeleton": "^3.5.0",
61
61
  "react-toastify": "10.0.4",
62
62
  "type-fest": "^5.4.4",
@@ -21,7 +21,7 @@ or `style.width`/`height` for custom sizing. See the [Icons](./references/Icons.
21
21
 
22
22
  ```tsx
23
23
  import { EditIcon, DeleteIcon, iconVariants, type IconVariant } from '@redis-ui/icons';
24
- import { RedisIcon } from '@redis-ui/icons/multicolor';
24
+ import { RedisLogoDarkMinIcon } from '@redis-ui/icons/multicolor';
25
25
  ```
26
26
 
27
27
  ## Key Patterns
@@ -7,7 +7,7 @@ Icon set published in `@redis-ui/icons`. Two flavors are available:
7
7
 
8
8
  ```tsx
9
9
  import { StarsIcon, EditIcon, DeleteIcon } from '@redis-ui/icons';
10
- import { RedisIcon } from '@redis-ui/icons/multicolor';
10
+ import { RedisLogoDarkMinIcon } from '@redis-ui/icons/multicolor';
11
11
  ```
12
12
 
13
13
  Type and variant exports:
@@ -52,10 +52,10 @@ their colors are baked in.
52
52
 
53
53
  ```tsx
54
54
  import { StarsIcon } from '@redis-ui/icons';
55
- import { RedisIcon } from '@redis-ui/icons/multicolor';
55
+ import { RedisLogoDarkMinIcon } from '@redis-ui/icons/multicolor';
56
56
 
57
57
  <StarsIcon size="XL" variant="success" />
58
- <RedisIcon />
58
+ <RedisLogoDarkMinIcon />
59
59
  ```
60
60
 
61
61
  ### Sizes and Variants
@@ -158,14 +158,14 @@ This slot inherits `TypographyBodyProps` except `children` and renders footer te
158
158
  ```tsx
159
159
  import { SideBar } from '@redis-ui/components';
160
160
  import { ShardIcon } from '@redis-ui/icons';
161
- import { RedisIcon } from '@redis-ui/icons/multicolor';
161
+ import { RedisLogoDarkMinIcon } from '@redis-ui/icons/multicolor';
162
162
  import { useArgState } from '../../helpers/useArgState';
163
163
 
164
164
  const [expanded, onToggle] = useArgState({ arg: true, getNewState: (arg) => !arg });
165
165
 
166
166
  <SideBar isExpanded={expanded}>
167
167
  <SideBar.Header onToggle={onToggle}>
168
- <SideBar.SideBarLogo logoIcon={RedisIcon} />
168
+ <SideBar.SideBarLogo logoIcon={RedisLogoDarkMinIcon} />
169
169
  </SideBar.Header>
170
170
  <SideBar.Item tooltipProps={{ text: 'tooltip' }}>
171
171
  <SideBar.Item.Icon icon={ShardIcon} />
@@ -187,7 +187,7 @@ const [expanded, onToggle] = useArgState({ arg: true, getNewState: (arg) => !arg
187
187
  import { SideBar } from '@redis-ui/components';
188
188
  import { PlusIcon } from '@redis-ui/icons';
189
189
  import { useState } from 'react';
190
- import { RedisIcon } from '@redis-ui/icons/multicolor';
190
+ import { RedisLogoDarkMinIcon } from '@redis-ui/icons/multicolor';
191
191
  import { items } from './SideBar.data';
192
192
 
193
193
  const [expanded, setExpanded] = useState(true);
@@ -195,7 +195,7 @@ const [activeLink, setActiveLink] = useState(items.top[0].content);
195
195
 
196
196
  <SideBar isExpanded={expanded} style={{ maxHeight: '55rem', height: 'calc(100vh - 2rem)' }}>
197
197
  <SideBar.Header onToggle={() => setExpanded(!expanded)}>
198
- <SideBar.SideBarLogo logoIcon={RedisIcon} />
198
+ <SideBar.SideBarLogo logoIcon={RedisLogoDarkMinIcon} />
199
199
  </SideBar.Header>
200
200
  <SideBar.ScrollContainer>
201
201
  <SideBar.ItemsContainer>
@@ -277,7 +277,7 @@ const [activeLink, setActiveLink] = useState(items.top[0].content);
277
277
  import { SideBar } from '@redis-ui/components';
278
278
  import { PlusIcon } from '@redis-ui/icons';
279
279
  import { useState } from 'react';
280
- import { RedisIcon } from '@redis-ui/icons/multicolor';
280
+ import { RedisLogoDarkMinIcon } from '@redis-ui/icons/multicolor';
281
281
  import { groups } from './SideBar.data';
282
282
 
283
283
  const [expanded, setExpanded] = useState(true);
@@ -289,7 +289,7 @@ const [activeLink, setActiveLink] = useState(groups[0].items[0].content);
289
289
  expandedWidth="35rem"
290
290
  >
291
291
  <SideBar.Header onToggle={() => setExpanded(!expanded)}>
292
- <SideBar.SideBarLogo logoIcon={RedisIcon} />
292
+ <SideBar.SideBarLogo logoIcon={RedisLogoDarkMinIcon} />
293
293
  </SideBar.Header>
294
294
  <SideBar.ScrollContainer>
295
295
  {groups.map((group, groupIdx) => (
@@ -340,7 +340,7 @@ const [activeLink, setActiveLink] = useState(groups[0].items[0].content);
340
340
  ```tsx
341
341
  import { SideBar } from '@redis-ui/components';
342
342
  import { useState } from 'react';
343
- import { RedisIcon } from '@redis-ui/icons/multicolor';
343
+ import { RedisLogoDarkMinIcon } from '@redis-ui/icons/multicolor';
344
344
  import { StoryHList } from '../../helpers/Story.style';
345
345
 
346
346
  const [expanded, setExpanded] = useState(true);
@@ -348,7 +348,7 @@ const [expanded, setExpanded] = useState(true);
348
348
  const content = (
349
349
  <>
350
350
  <SideBar.Header onToggle={() => setExpanded((val) => !val)}>
351
- <SideBar.SideBarLogo logoIcon={RedisIcon} />
351
+ <SideBar.SideBarLogo logoIcon={RedisLogoDarkMinIcon} />
352
352
  </SideBar.Header>
353
353
  <SideBar.Footer>
354
354
  <SideBar.Footer.MetaData>
@@ -1,289 +0,0 @@
1
- require("../../../_virtual/_rolldown/runtime.cjs");
2
- require("react/jsx-runtime");
3
- let react = require("react");
4
- //#region ../../node_modules/react-hotkeys-hook/dist/react-hotkeys-hook.esm.js
5
- function _extends() {
6
- return _extends = Object.assign ? Object.assign.bind() : function(n) {
7
- for (var e = 1; e < arguments.length; e++) {
8
- var t = arguments[e];
9
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
10
- }
11
- return n;
12
- }, _extends.apply(null, arguments);
13
- }
14
- var reservedModifierKeywords = [
15
- "shift",
16
- "alt",
17
- "meta",
18
- "mod",
19
- "ctrl"
20
- ];
21
- var mappedKeys = {
22
- esc: "escape",
23
- "return": "enter",
24
- ".": "period",
25
- ",": "comma",
26
- "-": "slash",
27
- " ": "space",
28
- "`": "backquote",
29
- "#": "backslash",
30
- "+": "bracketright",
31
- ShiftLeft: "shift",
32
- ShiftRight: "shift",
33
- AltLeft: "alt",
34
- AltRight: "alt",
35
- MetaLeft: "meta",
36
- MetaRight: "meta",
37
- OSLeft: "meta",
38
- OSRight: "meta",
39
- ControlLeft: "ctrl",
40
- ControlRight: "ctrl"
41
- };
42
- function mapKey(key) {
43
- return (key && mappedKeys[key] || key || "").trim().toLowerCase().replace(/key|digit|numpad|arrow/, "");
44
- }
45
- function isHotkeyModifier(key) {
46
- return reservedModifierKeywords.includes(key);
47
- }
48
- function parseKeysHookInput(keys, splitKey) {
49
- if (splitKey === void 0) splitKey = ",";
50
- return keys.split(splitKey);
51
- }
52
- function parseHotkey(hotkey, combinationKey, description) {
53
- if (combinationKey === void 0) combinationKey = "+";
54
- var keys = hotkey.toLocaleLowerCase().split(combinationKey).map(function(k) {
55
- return mapKey(k);
56
- });
57
- var modifiers = {
58
- alt: keys.includes("alt"),
59
- ctrl: keys.includes("ctrl") || keys.includes("control"),
60
- shift: keys.includes("shift"),
61
- meta: keys.includes("meta"),
62
- mod: keys.includes("mod")
63
- };
64
- var singleCharKeys = keys.filter(function(k) {
65
- return !reservedModifierKeywords.includes(k);
66
- });
67
- return _extends({}, modifiers, {
68
- keys: singleCharKeys,
69
- description,
70
- hotkey
71
- });
72
- }
73
- (function() {
74
- if (typeof document !== "undefined") {
75
- document.addEventListener("keydown", function(e) {
76
- if (e.key === void 0) return;
77
- pushToCurrentlyPressedKeys([mapKey(e.key), mapKey(e.code)]);
78
- });
79
- document.addEventListener("keyup", function(e) {
80
- if (e.key === void 0) return;
81
- removeFromCurrentlyPressedKeys([mapKey(e.key), mapKey(e.code)]);
82
- });
83
- }
84
- if (typeof window !== "undefined") window.addEventListener("blur", function() {
85
- currentlyPressedKeys.clear();
86
- });
87
- })();
88
- var currentlyPressedKeys = /* @__PURE__ */ new Set();
89
- function isReadonlyArray(value) {
90
- return Array.isArray(value);
91
- }
92
- function isHotkeyPressed(key, splitKey) {
93
- if (splitKey === void 0) splitKey = ",";
94
- return (isReadonlyArray(key) ? key : key.split(splitKey)).every(function(hotkey) {
95
- return currentlyPressedKeys.has(hotkey.trim().toLowerCase());
96
- });
97
- }
98
- function pushToCurrentlyPressedKeys(key) {
99
- var hotkeyArray = Array.isArray(key) ? key : [key];
100
- if (currentlyPressedKeys.has("meta")) currentlyPressedKeys.forEach(function(key) {
101
- return !isHotkeyModifier(key) && currentlyPressedKeys["delete"](key.toLowerCase());
102
- });
103
- hotkeyArray.forEach(function(hotkey) {
104
- return currentlyPressedKeys.add(hotkey.toLowerCase());
105
- });
106
- }
107
- function removeFromCurrentlyPressedKeys(key) {
108
- var hotkeyArray = Array.isArray(key) ? key : [key];
109
- if (key === "meta") currentlyPressedKeys.clear();
110
- else hotkeyArray.forEach(function(hotkey) {
111
- return currentlyPressedKeys["delete"](hotkey.toLowerCase());
112
- });
113
- }
114
- function maybePreventDefault(e, hotkey, preventDefault) {
115
- if (typeof preventDefault === "function" && preventDefault(e, hotkey) || preventDefault === true) e.preventDefault();
116
- }
117
- function isHotkeyEnabled(e, hotkey, enabled) {
118
- if (typeof enabled === "function") return enabled(e, hotkey);
119
- return enabled === true || enabled === void 0;
120
- }
121
- function isKeyboardEventTriggeredByInput(ev) {
122
- return isHotkeyEnabledOnTag(ev, [
123
- "input",
124
- "textarea",
125
- "select"
126
- ]);
127
- }
128
- function isHotkeyEnabledOnTag(event, enabledOnTags) {
129
- if (enabledOnTags === void 0) enabledOnTags = false;
130
- var target = event.target, composed = event.composed;
131
- var targetTagName = null;
132
- if (isCustomElement(target) && composed) targetTagName = event.composedPath()[0] && event.composedPath()[0].tagName;
133
- else targetTagName = target && target.tagName;
134
- if (isReadonlyArray(enabledOnTags)) return Boolean(targetTagName && enabledOnTags && enabledOnTags.some(function(tag) {
135
- var _targetTagName;
136
- return tag.toLowerCase() === ((_targetTagName = targetTagName) == null ? void 0 : _targetTagName.toLowerCase());
137
- }));
138
- return Boolean(targetTagName && enabledOnTags && enabledOnTags);
139
- }
140
- function isCustomElement(element) {
141
- return !!element.tagName && !element.tagName.startsWith("-") && element.tagName.includes("-");
142
- }
143
- function isScopeActive(activeScopes, scopes) {
144
- if (activeScopes.length === 0 && scopes) {
145
- console.warn("A hotkey has the \"scopes\" option set, however no active scopes were found. If you want to use the global scopes feature, you need to wrap your app in a <HotkeysProvider>");
146
- return true;
147
- }
148
- if (!scopes) return true;
149
- return activeScopes.some(function(scope) {
150
- return scopes.includes(scope);
151
- }) || activeScopes.includes("*");
152
- }
153
- var isHotkeyMatchingKeyboardEvent = function isHotkeyMatchingKeyboardEvent(e, hotkey, ignoreModifiers) {
154
- if (ignoreModifiers === void 0) ignoreModifiers = false;
155
- var alt = hotkey.alt, meta = hotkey.meta, mod = hotkey.mod, shift = hotkey.shift, ctrl = hotkey.ctrl, keys = hotkey.keys;
156
- var pressedKeyUppercase = e.key, code = e.code, ctrlKey = e.ctrlKey, metaKey = e.metaKey, shiftKey = e.shiftKey, altKey = e.altKey;
157
- var keyCode = mapKey(code);
158
- var pressedKey = pressedKeyUppercase.toLowerCase();
159
- if (!(keys != null && keys.includes(keyCode)) && !(keys != null && keys.includes(pressedKey)) && ![
160
- "ctrl",
161
- "control",
162
- "unknown",
163
- "meta",
164
- "alt",
165
- "shift",
166
- "os"
167
- ].includes(keyCode)) return false;
168
- if (!ignoreModifiers) {
169
- if (alt === !altKey && pressedKey !== "alt") return false;
170
- if (shift === !shiftKey && pressedKey !== "shift") return false;
171
- if (mod) {
172
- if (!metaKey && !ctrlKey) return false;
173
- } else {
174
- if (meta === !metaKey && pressedKey !== "meta" && pressedKey !== "os") return false;
175
- if (ctrl === !ctrlKey && pressedKey !== "ctrl" && pressedKey !== "control") return false;
176
- }
177
- }
178
- if (keys && keys.length === 1 && (keys.includes(pressedKey) || keys.includes(keyCode))) return true;
179
- else if (keys) return isHotkeyPressed(keys);
180
- else if (!keys) return true;
181
- return false;
182
- };
183
- var BoundHotkeysProxyProvider = /* @__PURE__ */ (0, react.createContext)(void 0);
184
- var useBoundHotkeysProxy = function useBoundHotkeysProxy() {
185
- return (0, react.useContext)(BoundHotkeysProxyProvider);
186
- };
187
- function deepEqual(x, y) {
188
- return x && y && typeof x === "object" && typeof y === "object" ? Object.keys(x).length === Object.keys(y).length && Object.keys(x).reduce(function(isEqual, key) {
189
- return isEqual && deepEqual(x[key], y[key]);
190
- }, true) : x === y;
191
- }
192
- var HotkeysContext = /* @__PURE__ */ (0, react.createContext)({
193
- hotkeys: [],
194
- enabledScopes: [],
195
- toggleScope: function toggleScope() {},
196
- enableScope: function enableScope() {},
197
- disableScope: function disableScope() {}
198
- });
199
- var useHotkeysContext = function useHotkeysContext() {
200
- return (0, react.useContext)(HotkeysContext);
201
- };
202
- function useDeepEqualMemo(value) {
203
- var ref = (0, react.useRef)(void 0);
204
- if (!deepEqual(ref.current, value)) ref.current = value;
205
- return ref.current;
206
- }
207
- var stopPropagation = function stopPropagation(e) {
208
- e.stopPropagation();
209
- e.preventDefault();
210
- e.stopImmediatePropagation();
211
- };
212
- var useSafeLayoutEffect = typeof window !== "undefined" ? react.useLayoutEffect : react.useEffect;
213
- function useHotkeys(keys, callback, options, dependencies) {
214
- var _useState = (0, react.useState)(null), ref = _useState[0], setRef = _useState[1];
215
- var hasTriggeredRef = (0, react.useRef)(false);
216
- var _options = !(options instanceof Array) ? options : !(dependencies instanceof Array) ? dependencies : void 0;
217
- var _keys = isReadonlyArray(keys) ? keys.join(_options == null ? void 0 : _options.splitKey) : keys;
218
- var _deps = options instanceof Array ? options : dependencies instanceof Array ? dependencies : void 0;
219
- var memoisedCB = (0, react.useCallback)(callback, _deps != null ? _deps : []);
220
- var cbRef = (0, react.useRef)(memoisedCB);
221
- if (_deps) cbRef.current = memoisedCB;
222
- else cbRef.current = callback;
223
- var memoisedOptions = useDeepEqualMemo(_options);
224
- var enabledScopes = useHotkeysContext().enabledScopes;
225
- var proxy = useBoundHotkeysProxy();
226
- useSafeLayoutEffect(function() {
227
- if ((memoisedOptions == null ? void 0 : memoisedOptions.enabled) === false || !isScopeActive(enabledScopes, memoisedOptions == null ? void 0 : memoisedOptions.scopes)) return;
228
- var listener = function listener(e, isKeyUp) {
229
- var _e$target;
230
- if (isKeyUp === void 0) isKeyUp = false;
231
- if (isKeyboardEventTriggeredByInput(e) && !isHotkeyEnabledOnTag(e, memoisedOptions == null ? void 0 : memoisedOptions.enableOnFormTags)) return;
232
- if (ref !== null) {
233
- var rootNode = ref.getRootNode();
234
- if ((rootNode instanceof Document || rootNode instanceof ShadowRoot) && rootNode.activeElement !== ref && !ref.contains(rootNode.activeElement)) {
235
- stopPropagation(e);
236
- return;
237
- }
238
- }
239
- if ((_e$target = e.target) != null && _e$target.isContentEditable && !(memoisedOptions != null && memoisedOptions.enableOnContentEditable)) return;
240
- parseKeysHookInput(_keys, memoisedOptions == null ? void 0 : memoisedOptions.splitKey).forEach(function(key) {
241
- var _hotkey$keys;
242
- var hotkey = parseHotkey(key, memoisedOptions == null ? void 0 : memoisedOptions.combinationKey);
243
- if (isHotkeyMatchingKeyboardEvent(e, hotkey, memoisedOptions == null ? void 0 : memoisedOptions.ignoreModifiers) || (_hotkey$keys = hotkey.keys) != null && _hotkey$keys.includes("*")) {
244
- if (memoisedOptions != null && memoisedOptions.ignoreEventWhen != null && memoisedOptions.ignoreEventWhen(e)) return;
245
- if (isKeyUp && hasTriggeredRef.current) return;
246
- maybePreventDefault(e, hotkey, memoisedOptions == null ? void 0 : memoisedOptions.preventDefault);
247
- if (!isHotkeyEnabled(e, hotkey, memoisedOptions == null ? void 0 : memoisedOptions.enabled)) {
248
- stopPropagation(e);
249
- return;
250
- }
251
- cbRef.current(e, hotkey);
252
- if (!isKeyUp) hasTriggeredRef.current = true;
253
- }
254
- });
255
- };
256
- var handleKeyDown = function handleKeyDown(event) {
257
- if (event.key === void 0) return;
258
- pushToCurrentlyPressedKeys(mapKey(event.code));
259
- if ((memoisedOptions == null ? void 0 : memoisedOptions.keydown) === void 0 && (memoisedOptions == null ? void 0 : memoisedOptions.keyup) !== true || memoisedOptions != null && memoisedOptions.keydown) listener(event);
260
- };
261
- var handleKeyUp = function handleKeyUp(event) {
262
- if (event.key === void 0) return;
263
- removeFromCurrentlyPressedKeys(mapKey(event.code));
264
- hasTriggeredRef.current = false;
265
- if (memoisedOptions != null && memoisedOptions.keyup) listener(event, true);
266
- };
267
- var domNode = ref || (_options == null ? void 0 : _options.document) || document;
268
- domNode.addEventListener("keyup", handleKeyUp);
269
- domNode.addEventListener("keydown", handleKeyDown);
270
- if (proxy) parseKeysHookInput(_keys, memoisedOptions == null ? void 0 : memoisedOptions.splitKey).forEach(function(key) {
271
- return proxy.addHotkey(parseHotkey(key, memoisedOptions == null ? void 0 : memoisedOptions.combinationKey, memoisedOptions == null ? void 0 : memoisedOptions.description));
272
- });
273
- return function() {
274
- domNode.removeEventListener("keyup", handleKeyUp);
275
- domNode.removeEventListener("keydown", handleKeyDown);
276
- if (proxy) parseKeysHookInput(_keys, memoisedOptions == null ? void 0 : memoisedOptions.splitKey).forEach(function(key) {
277
- return proxy.removeHotkey(parseHotkey(key, memoisedOptions == null ? void 0 : memoisedOptions.combinationKey, memoisedOptions == null ? void 0 : memoisedOptions.description));
278
- });
279
- };
280
- }, [
281
- ref,
282
- _keys,
283
- memoisedOptions,
284
- enabledScopes
285
- ]);
286
- return setRef;
287
- }
288
- //#endregion
289
- exports.useHotkeys = useHotkeys;