react-hotkeys-hook 5.0.0-0 → 5.0.0-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.
Files changed (35) hide show
  1. package/package.json +13 -85
  2. package/{dist → packages/react-hotkeys-hook/dist}/BoundHotkeysProxyProvider.d.ts +14 -14
  3. package/{dist → packages/react-hotkeys-hook/dist}/HotkeysProvider.d.ts +16 -16
  4. package/packages/react-hotkeys-hook/dist/deepEqual.d.ts +1 -0
  5. package/{dist → packages/react-hotkeys-hook/dist}/index.d.ts +6 -6
  6. package/packages/react-hotkeys-hook/dist/index.js +220 -0
  7. package/{dist → packages/react-hotkeys-hook/dist}/isHotkeyPressed.d.ts +4 -4
  8. package/packages/react-hotkeys-hook/dist/parseHotkeys.d.ts +5 -0
  9. package/packages/react-hotkeys-hook/dist/types.d.ts +45 -0
  10. package/{dist → packages/react-hotkeys-hook/dist}/useDeepEqualMemo.d.ts +1 -1
  11. package/{dist → packages/react-hotkeys-hook/dist}/useHotkeys.d.ts +2 -3
  12. package/{dist → packages/react-hotkeys-hook/dist}/useRecordHotkeys.d.ts +6 -5
  13. package/{dist → packages/react-hotkeys-hook/dist}/validators.d.ts +8 -7
  14. package/dist/deepEqual.d.ts +0 -1
  15. package/dist/index.js +0 -8
  16. package/dist/parseHotkeys.d.ts +0 -5
  17. package/dist/react-hotkeys-hook.cjs.development.js +0 -514
  18. package/dist/react-hotkeys-hook.cjs.development.js.map +0 -1
  19. package/dist/react-hotkeys-hook.cjs.production.min.js +0 -2
  20. package/dist/react-hotkeys-hook.cjs.production.min.js.map +0 -1
  21. package/dist/react-hotkeys-hook.esm.js +0 -508
  22. package/dist/react-hotkeys-hook.esm.js.map +0 -1
  23. package/dist/setupTests.d.ts +0 -1
  24. package/dist/types.d.ts +0 -36
  25. package/src/BoundHotkeysProxyProvider.tsx +0 -27
  26. package/src/HotkeysProvider.tsx +0 -81
  27. package/src/deepEqual.ts +0 -8
  28. package/src/index.ts +0 -16
  29. package/src/isHotkeyPressed.ts +0 -73
  30. package/src/parseHotkeys.ts +0 -58
  31. package/src/types.ts +0 -45
  32. package/src/useDeepEqualMemo.ts +0 -12
  33. package/src/useHotkeys.ts +0 -172
  34. package/src/useRecordHotkeys.ts +0 -47
  35. package/src/validators.ts +0 -106
@@ -1,514 +0,0 @@
1
- 'use strict';
2
-
3
- var react = require('react');
4
- var jsxRuntime = require('react/jsx-runtime');
5
-
6
- function _extends() {
7
- _extends = Object.assign ? Object.assign.bind() : function (target) {
8
- for (var i = 1; i < arguments.length; i++) {
9
- var source = arguments[i];
10
- for (var key in source) {
11
- if (Object.prototype.hasOwnProperty.call(source, key)) {
12
- target[key] = source[key];
13
- }
14
- }
15
- }
16
- return target;
17
- };
18
- return _extends.apply(this, arguments);
19
- }
20
-
21
- var reservedModifierKeywords = ['shift', 'alt', 'meta', 'mod', 'ctrl'];
22
- var mappedKeys = {
23
- esc: 'escape',
24
- "return": 'enter',
25
- left: 'arrowleft',
26
- right: 'arrowright',
27
- up: 'arrowup',
28
- down: 'arrowdown',
29
- space: ' ',
30
- ShiftLeft: 'shift',
31
- ShiftRight: 'shift',
32
- AltLeft: 'alt',
33
- AltRight: 'alt',
34
- MetaLeft: 'meta',
35
- MetaRight: 'meta',
36
- OSLeft: 'meta',
37
- OSRight: 'meta',
38
- ControlLeft: 'ctrl',
39
- ControlRight: 'ctrl'
40
- };
41
- function mapKey(key) {
42
- return (mappedKeys[key.trim()] || key.trim()).toLowerCase().replace(/key|digit|numpad/, '');
43
- }
44
- function isHotkeyModifier(key) {
45
- return reservedModifierKeywords.includes(key);
46
- }
47
- function parseKeysHookInput(keys, splitKey) {
48
- if (splitKey === void 0) {
49
- splitKey = ',';
50
- }
51
- return keys.split(splitKey);
52
- }
53
- function parseHotkey(hotkey, combinationKey, description) {
54
- if (combinationKey === void 0) {
55
- combinationKey = '+';
56
- }
57
- var keys = hotkey.toLocaleLowerCase().split(combinationKey).map(function (k) {
58
- return mapKey(k);
59
- });
60
- var modifiers = {
61
- alt: keys.includes('alt'),
62
- ctrl: keys.includes('ctrl') || keys.includes('control'),
63
- shift: keys.includes('shift'),
64
- meta: keys.includes('meta'),
65
- mod: keys.includes('mod')
66
- };
67
- var singleCharKeys = keys.filter(function (k) {
68
- return !reservedModifierKeywords.includes(k);
69
- });
70
- return _extends({}, modifiers, {
71
- keys: singleCharKeys,
72
- description: description
73
- });
74
- }
75
-
76
- (function () {
77
- if (typeof document !== 'undefined') {
78
- document.addEventListener('keydown', function (e) {
79
- if (e.key === undefined) {
80
- // Synthetic event (e.g., Chrome autofill). Ignore.
81
- return;
82
- }
83
- console.log('keydown', e.key, mapKey(e.key), e.key.length);
84
- pushToCurrentlyPressedKeys([mapKey(e.key)]);
85
- });
86
- document.addEventListener('keyup', function (e) {
87
- if (e.key === undefined) {
88
- // Synthetic event (e.g., Chrome autofill). Ignore.
89
- return;
90
- }
91
- removeFromCurrentlyPressedKeys([mapKey(e.key)]);
92
- });
93
- }
94
- if (typeof window !== 'undefined') {
95
- window.addEventListener('blur', function () {
96
- currentlyPressedKeys.clear();
97
- });
98
- }
99
- })();
100
- var currentlyPressedKeys = /*#__PURE__*/new Set();
101
- // https://github.com/microsoft/TypeScript/issues/17002
102
- function isReadonlyArray(value) {
103
- return Array.isArray(value);
104
- }
105
- function isHotkeyPressed(key, splitKey) {
106
- if (splitKey === void 0) {
107
- splitKey = ',';
108
- }
109
- var hotkeyArray = isReadonlyArray(key) ? key : key.split(splitKey);
110
- return hotkeyArray.every(function (hotkey) {
111
- return currentlyPressedKeys.has(hotkey.trim().toLowerCase());
112
- });
113
- }
114
- function pushToCurrentlyPressedKeys(key) {
115
- var hotkeyArray = Array.isArray(key) ? key : [key];
116
- /*
117
- Due to a weird behavior on macOS we need to clear the set if the user pressed down the meta key and presses another key.
118
- https://stackoverflow.com/questions/11818637/why-does-javascript-drop-keyup-events-when-the-metakey-is-pressed-on-mac-browser
119
- Otherwise the set will hold all ever pressed keys while the meta key is down which leads to wrong results.
120
- */
121
- if (currentlyPressedKeys.has('meta')) {
122
- currentlyPressedKeys.forEach(function (key) {
123
- return !isHotkeyModifier(key) && currentlyPressedKeys["delete"](key.toLowerCase());
124
- });
125
- }
126
- hotkeyArray.forEach(function (hotkey) {
127
- return currentlyPressedKeys.add(hotkey.toLowerCase());
128
- });
129
- }
130
- function removeFromCurrentlyPressedKeys(key) {
131
- var hotkeyArray = Array.isArray(key) ? key : [key];
132
- /*
133
- Due to a weird behavior on macOS we need to clear the set if the user pressed down the meta key and presses another key.
134
- https://stackoverflow.com/questions/11818637/why-does-javascript-drop-keyup-events-when-the-metakey-is-pressed-on-mac-browser
135
- Otherwise the set will hold all ever pressed keys while the meta key is down which leads to wrong results.
136
- */
137
- if (key === 'meta') {
138
- currentlyPressedKeys.clear();
139
- } else {
140
- hotkeyArray.forEach(function (hotkey) {
141
- return currentlyPressedKeys["delete"](hotkey.toLowerCase());
142
- });
143
- }
144
- }
145
-
146
- function maybePreventDefault(e, hotkey, preventDefault) {
147
- if (typeof preventDefault === 'function' && preventDefault(e, hotkey) || preventDefault === true) {
148
- e.preventDefault();
149
- }
150
- }
151
- function isHotkeyEnabled(e, hotkey, enabled) {
152
- if (typeof enabled === 'function') {
153
- return enabled(e, hotkey);
154
- }
155
- return enabled === true || enabled === undefined;
156
- }
157
- function isKeyboardEventTriggeredByInput(ev) {
158
- return isHotkeyEnabledOnTag(ev, ['input', 'textarea', 'select']);
159
- }
160
- function isHotkeyEnabledOnTag(_ref, enabledOnTags) {
161
- var target = _ref.target;
162
- if (enabledOnTags === void 0) {
163
- enabledOnTags = false;
164
- }
165
- var targetTagName = target && target.tagName;
166
- if (isReadonlyArray(enabledOnTags)) {
167
- return Boolean(targetTagName && enabledOnTags && enabledOnTags.some(function (tag) {
168
- return tag.toLowerCase() === targetTagName.toLowerCase();
169
- }));
170
- }
171
- return Boolean(targetTagName && enabledOnTags && enabledOnTags === true);
172
- }
173
- function isScopeActive(activeScopes, scopes) {
174
- if (activeScopes.length === 0 && scopes) {
175
- 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>');
176
- return true;
177
- }
178
- if (!scopes) {
179
- return true;
180
- }
181
- return activeScopes.some(function (scope) {
182
- return scopes.includes(scope);
183
- }) || activeScopes.includes('*');
184
- }
185
- var isHotkeyMatchingKeyboardEvent = function isHotkeyMatchingKeyboardEvent(e, hotkey, ignoreModifiers) {
186
- if (ignoreModifiers === void 0) {
187
- ignoreModifiers = false;
188
- }
189
- var alt = hotkey.alt,
190
- meta = hotkey.meta,
191
- mod = hotkey.mod,
192
- shift = hotkey.shift,
193
- ctrl = hotkey.ctrl,
194
- keys = hotkey.keys;
195
- var pressedKeyUppercase = e.key,
196
- ctrlKey = e.ctrlKey,
197
- metaKey = e.metaKey,
198
- shiftKey = e.shiftKey,
199
- altKey = e.altKey;
200
- var pressedKey = pressedKeyUppercase.toLowerCase();
201
- if (!(keys != null && keys.includes(pressedKey)) && !['ctrl', 'control', 'unknown', 'meta', 'alt', 'shift', 'os'].includes(pressedKey)) {
202
- return false;
203
- }
204
- if (!ignoreModifiers) {
205
- // We check the pressed keys for compatibility with the keyup event. In keyup events the modifier flags are not set.
206
- if (alt === !altKey && pressedKey !== 'alt') {
207
- return false;
208
- }
209
- if (shift === !shiftKey && pressedKey !== 'shift') {
210
- return false;
211
- }
212
- // Mod is a special key name that is checking for meta on macOS and ctrl on other platforms
213
- if (mod) {
214
- if (!metaKey && !ctrlKey) {
215
- return false;
216
- }
217
- } else {
218
- if (meta === !metaKey && pressedKey !== 'meta' && pressedKey !== 'os') {
219
- return false;
220
- }
221
- if (ctrl === !ctrlKey && pressedKey !== 'ctrl' && pressedKey !== 'control') {
222
- return false;
223
- }
224
- }
225
- }
226
- // All modifiers are correct, now check the key
227
- // If the key is set, we check for the key
228
- if (keys && keys.length === 1 && keys.includes(pressedKey)) {
229
- return true;
230
- } else if (keys) {
231
- // Check if all keys are present in pressedDownKeys set
232
- return isHotkeyPressed(keys);
233
- } else if (!keys) {
234
- // If the key is not set, we only listen for modifiers, that check went alright, so we return true
235
- return true;
236
- }
237
- // There is nothing that matches.
238
- return false;
239
- };
240
-
241
- var BoundHotkeysProxyProvider = /*#__PURE__*/react.createContext(undefined);
242
- var useBoundHotkeysProxy = function useBoundHotkeysProxy() {
243
- return react.useContext(BoundHotkeysProxyProvider);
244
- };
245
- function BoundHotkeysProxyProviderProvider(_ref) {
246
- var addHotkey = _ref.addHotkey,
247
- removeHotkey = _ref.removeHotkey,
248
- children = _ref.children;
249
- return /*#__PURE__*/jsxRuntime.jsx(BoundHotkeysProxyProvider.Provider, {
250
- value: {
251
- addHotkey: addHotkey,
252
- removeHotkey: removeHotkey
253
- },
254
- children: children
255
- });
256
- }
257
-
258
- function deepEqual(x, y) {
259
- //@ts-ignore
260
- return x && y && typeof x === 'object' && typeof y === 'object' ? Object.keys(x).length === Object.keys(y).length &&
261
- //@ts-ignore
262
- Object.keys(x).reduce(function (isEqual, key) {
263
- return isEqual && deepEqual(x[key], y[key]);
264
- }, true) : x === y;
265
- }
266
-
267
- var HotkeysContext = /*#__PURE__*/react.createContext({
268
- hotkeys: [],
269
- activeScopes: [],
270
- toggleScope: function toggleScope() {},
271
- enableScope: function enableScope() {},
272
- disableScope: function disableScope() {}
273
- });
274
- var useHotkeysContext = function useHotkeysContext() {
275
- return react.useContext(HotkeysContext);
276
- };
277
- var HotkeysProvider = function HotkeysProvider(_ref) {
278
- var _ref$initiallyActiveS = _ref.initiallyActiveScopes,
279
- initiallyActiveScopes = _ref$initiallyActiveS === void 0 ? ['*'] : _ref$initiallyActiveS,
280
- children = _ref.children;
281
- var _useState = react.useState(initiallyActiveScopes),
282
- internalActiveScopes = _useState[0],
283
- setInternalActiveScopes = _useState[1];
284
- var _useState2 = react.useState([]),
285
- boundHotkeys = _useState2[0],
286
- setBoundHotkeys = _useState2[1];
287
- var enableScope = react.useCallback(function (scope) {
288
- setInternalActiveScopes(function (prev) {
289
- if (prev.includes('*')) {
290
- return [scope];
291
- }
292
- return Array.from(new Set([].concat(prev, [scope])));
293
- });
294
- }, []);
295
- var disableScope = react.useCallback(function (scope) {
296
- setInternalActiveScopes(function (prev) {
297
- return prev.filter(function (s) {
298
- return s !== scope;
299
- });
300
- });
301
- }, []);
302
- var toggleScope = react.useCallback(function (scope) {
303
- setInternalActiveScopes(function (prev) {
304
- if (prev.includes(scope)) {
305
- return prev.filter(function (s) {
306
- return s !== scope;
307
- });
308
- } else {
309
- if (prev.includes('*')) {
310
- return [scope];
311
- }
312
- return Array.from(new Set([].concat(prev, [scope])));
313
- }
314
- });
315
- }, []);
316
- var addBoundHotkey = react.useCallback(function (hotkey) {
317
- setBoundHotkeys(function (prev) {
318
- return [].concat(prev, [hotkey]);
319
- });
320
- }, []);
321
- var removeBoundHotkey = react.useCallback(function (hotkey) {
322
- setBoundHotkeys(function (prev) {
323
- return prev.filter(function (h) {
324
- return !deepEqual(h, hotkey);
325
- });
326
- });
327
- }, []);
328
- return /*#__PURE__*/jsxRuntime.jsx(HotkeysContext.Provider, {
329
- value: {
330
- activeScopes: internalActiveScopes,
331
- hotkeys: boundHotkeys,
332
- enableScope: enableScope,
333
- disableScope: disableScope,
334
- toggleScope: toggleScope
335
- },
336
- children: /*#__PURE__*/jsxRuntime.jsx(BoundHotkeysProxyProviderProvider, {
337
- addHotkey: addBoundHotkey,
338
- removeHotkey: removeBoundHotkey,
339
- children: children
340
- })
341
- });
342
- };
343
-
344
- function useDeepEqualMemo(value) {
345
- var ref = react.useRef(undefined);
346
- if (!deepEqual(ref.current, value)) {
347
- ref.current = value;
348
- }
349
- return ref.current;
350
- }
351
-
352
- var stopPropagation = function stopPropagation(e) {
353
- e.stopPropagation();
354
- e.preventDefault();
355
- e.stopImmediatePropagation();
356
- };
357
- var useSafeLayoutEffect = typeof window !== 'undefined' ? react.useLayoutEffect : react.useEffect;
358
- function useHotkeys(keys, callback, options, dependencies) {
359
- var ref = react.useRef(null);
360
- var hasTriggeredRef = react.useRef(false);
361
- var _options = !(options instanceof Array) ? options : !(dependencies instanceof Array) ? dependencies : undefined;
362
- var _keys = isReadonlyArray(keys) ? keys.join(_options == null ? void 0 : _options.splitKey) : keys;
363
- var _deps = options instanceof Array ? options : dependencies instanceof Array ? dependencies : undefined;
364
- var memoisedCB = react.useCallback(callback, _deps != null ? _deps : []);
365
- var cbRef = react.useRef(memoisedCB);
366
- if (_deps) {
367
- cbRef.current = memoisedCB;
368
- } else {
369
- cbRef.current = callback;
370
- }
371
- var memoisedOptions = useDeepEqualMemo(_options);
372
- var _useHotkeysContext = useHotkeysContext(),
373
- activeScopes = _useHotkeysContext.activeScopes;
374
- var proxy = useBoundHotkeysProxy();
375
- useSafeLayoutEffect(function () {
376
- if ((memoisedOptions == null ? void 0 : memoisedOptions.enabled) === false || !isScopeActive(activeScopes, memoisedOptions == null ? void 0 : memoisedOptions.scopes)) {
377
- return;
378
- }
379
- var listener = function listener(e, isKeyUp) {
380
- var _e$target;
381
- if (isKeyUp === void 0) {
382
- isKeyUp = false;
383
- }
384
- if (isKeyboardEventTriggeredByInput(e) && !isHotkeyEnabledOnTag(e, memoisedOptions == null ? void 0 : memoisedOptions.enableOnFormTags)) {
385
- return;
386
- }
387
- // TODO: SINCE THE EVENT IS NOW ATTACHED TO THE REF, THE ACTIVE ELEMENT CAN NEVER BE INSIDE THE REF. THE HOTKEY ONLY TRIGGERS IF THE
388
- // REF IS THE ACTIVE ELEMENT. THIS IS A PROBLEM SINCE FOCUSED SUB COMPONENTS WON'T TRIGGER THE HOTKEY.
389
- if (ref.current !== null) {
390
- var rootNode = ref.current.getRootNode();
391
- if ((rootNode instanceof Document || rootNode instanceof ShadowRoot) && rootNode.activeElement !== ref.current && !ref.current.contains(rootNode.activeElement)) {
392
- stopPropagation(e);
393
- return;
394
- }
395
- }
396
- if ((_e$target = e.target) != null && _e$target.isContentEditable && !(memoisedOptions != null && memoisedOptions.enableOnContentEditable)) {
397
- return;
398
- }
399
- parseKeysHookInput(_keys, memoisedOptions == null ? void 0 : memoisedOptions.splitKey).forEach(function (key) {
400
- var _hotkey$keys;
401
- var hotkey = parseHotkey(key, memoisedOptions == null ? void 0 : memoisedOptions.combinationKey);
402
- if (isHotkeyMatchingKeyboardEvent(e, hotkey, memoisedOptions == null ? void 0 : memoisedOptions.ignoreModifiers) || (_hotkey$keys = hotkey.keys) != null && _hotkey$keys.includes('*')) {
403
- if (memoisedOptions != null && memoisedOptions.ignoreEventWhen != null && memoisedOptions.ignoreEventWhen(e)) {
404
- return;
405
- }
406
- if (isKeyUp && hasTriggeredRef.current) {
407
- return;
408
- }
409
- maybePreventDefault(e, hotkey, memoisedOptions == null ? void 0 : memoisedOptions.preventDefault);
410
- if (!isHotkeyEnabled(e, hotkey, memoisedOptions == null ? void 0 : memoisedOptions.enabled)) {
411
- stopPropagation(e);
412
- return;
413
- }
414
- // Execute the user callback for that hotkey
415
- cbRef.current(e, hotkey);
416
- if (!isKeyUp) {
417
- hasTriggeredRef.current = true;
418
- }
419
- }
420
- });
421
- };
422
- var handleKeyDown = function handleKeyDown(event) {
423
- if (event.key === undefined) {
424
- // Synthetic event (e.g., Chrome autofill). Ignore.
425
- return;
426
- }
427
- pushToCurrentlyPressedKeys(mapKey(event.key));
428
- if ((memoisedOptions == null ? void 0 : memoisedOptions.keydown) === undefined && (memoisedOptions == null ? void 0 : memoisedOptions.keyup) !== true || memoisedOptions != null && memoisedOptions.keydown) {
429
- listener(event);
430
- }
431
- };
432
- var handleKeyUp = function handleKeyUp(event) {
433
- if (event.key === undefined) {
434
- // Synthetic event (e.g., Chrome autofill). Ignore.
435
- return;
436
- }
437
- removeFromCurrentlyPressedKeys(mapKey(event.key));
438
- hasTriggeredRef.current = false;
439
- if (memoisedOptions != null && memoisedOptions.keyup) {
440
- listener(event, true);
441
- }
442
- };
443
- var domNode = ref.current || (_options == null ? void 0 : _options.document) || document;
444
- // @ts-ignore
445
- domNode.addEventListener('keyup', handleKeyUp);
446
- // @ts-ignore
447
- domNode.addEventListener('keydown', handleKeyDown);
448
- if (proxy) {
449
- parseKeysHookInput(_keys, memoisedOptions == null ? void 0 : memoisedOptions.splitKey).forEach(function (key) {
450
- return proxy.addHotkey(parseHotkey(key, memoisedOptions == null ? void 0 : memoisedOptions.combinationKey, memoisedOptions == null ? void 0 : memoisedOptions.description));
451
- });
452
- }
453
- return function () {
454
- // @ts-ignore
455
- domNode.removeEventListener('keyup', handleKeyUp);
456
- // @ts-ignore
457
- domNode.removeEventListener('keydown', handleKeyDown);
458
- if (proxy) {
459
- parseKeysHookInput(_keys, memoisedOptions == null ? void 0 : memoisedOptions.splitKey).forEach(function (key) {
460
- return proxy.removeHotkey(parseHotkey(key, memoisedOptions == null ? void 0 : memoisedOptions.combinationKey, memoisedOptions == null ? void 0 : memoisedOptions.description));
461
- });
462
- }
463
- };
464
- }, [_keys, memoisedOptions, activeScopes]);
465
- return ref;
466
- }
467
-
468
- function useRecordHotkeys() {
469
- var _useState = react.useState(new Set()),
470
- keys = _useState[0],
471
- setKeys = _useState[1];
472
- var _useState2 = react.useState(false),
473
- isRecording = _useState2[0],
474
- setIsRecording = _useState2[1];
475
- var handler = react.useCallback(function (event) {
476
- if (event.key === undefined) {
477
- // Synthetic event (e.g., Chrome autofill). Ignore.
478
- return;
479
- }
480
- event.preventDefault();
481
- event.stopPropagation();
482
- setKeys(function (prev) {
483
- var newKeys = new Set(prev);
484
- newKeys.add(mapKey(event.key));
485
- return newKeys;
486
- });
487
- }, []);
488
- var stop = react.useCallback(function () {
489
- if (typeof document !== 'undefined') {
490
- document.removeEventListener('keydown', handler);
491
- setIsRecording(false);
492
- }
493
- }, [handler]);
494
- var start = react.useCallback(function () {
495
- setKeys(new Set());
496
- if (typeof document !== 'undefined') {
497
- stop();
498
- document.addEventListener('keydown', handler);
499
- setIsRecording(true);
500
- }
501
- }, [handler, stop]);
502
- return [keys, {
503
- start: start,
504
- stop: stop,
505
- isRecording: isRecording
506
- }];
507
- }
508
-
509
- exports.HotkeysProvider = HotkeysProvider;
510
- exports.isHotkeyPressed = isHotkeyPressed;
511
- exports.useHotkeys = useHotkeys;
512
- exports.useHotkeysContext = useHotkeysContext;
513
- exports.useRecordHotkeys = useRecordHotkeys;
514
- //# sourceMappingURL=react-hotkeys-hook.cjs.development.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"react-hotkeys-hook.cjs.development.js","sources":["../src/parseHotkeys.ts","../src/isHotkeyPressed.ts","../src/validators.ts","../src/BoundHotkeysProxyProvider.tsx","../src/deepEqual.ts","../src/HotkeysProvider.tsx","../src/useDeepEqualMemo.ts","../src/useHotkeys.ts","../src/useRecordHotkeys.ts"],"sourcesContent":["import { Hotkey, KeyboardModifiers } from './types'\n\nconst reservedModifierKeywords = ['shift', 'alt', 'meta', 'mod', 'ctrl']\n\nconst mappedKeys: Record<string, string> = {\n esc: 'escape',\n return: 'enter',\n left: 'arrowleft',\n right: 'arrowright',\n up: 'arrowup',\n down: 'arrowdown',\n space: ' ',\n ShiftLeft: 'shift',\n ShiftRight: 'shift',\n AltLeft: 'alt',\n AltRight: 'alt',\n MetaLeft: 'meta',\n MetaRight: 'meta',\n OSLeft: 'meta',\n OSRight: 'meta',\n ControlLeft: 'ctrl',\n ControlRight: 'ctrl',\n}\n\nexport function mapKey(key: string): string {\n return (mappedKeys[key.trim()] || key.trim()).toLowerCase().replace(/key|digit|numpad/, '')\n}\n\nexport function isHotkeyModifier(key: string) {\n return reservedModifierKeywords.includes(key)\n}\n\nexport function parseKeysHookInput(keys: string, splitKey = ','): string[] {\n return keys.split(splitKey)\n}\n\nexport function parseHotkey(hotkey: string, combinationKey = '+', description?: string): Hotkey {\n const keys = hotkey\n .toLocaleLowerCase()\n .split(combinationKey)\n .map((k) => mapKey(k))\n\n const modifiers: KeyboardModifiers = {\n alt: keys.includes('alt'),\n ctrl: keys.includes('ctrl') || keys.includes('control'),\n shift: keys.includes('shift'),\n meta: keys.includes('meta'),\n mod: keys.includes('mod'),\n }\n\n const singleCharKeys = keys.filter((k) => !reservedModifierKeywords.includes(k))\n\n return {\n ...modifiers,\n keys: singleCharKeys,\n description,\n }\n}\n","import { isHotkeyModifier, mapKey } from './parseHotkeys'\n;(() => {\n if (typeof document !== 'undefined') {\n document.addEventListener('keydown', (e) => {\n if (e.key === undefined) {\n // Synthetic event (e.g., Chrome autofill). Ignore.\n return\n }\n\n console.log('keydown', e.key, mapKey(e.key), e.key.length)\n\n pushToCurrentlyPressedKeys([mapKey(e.key)])\n })\n\n document.addEventListener('keyup', (e) => {\n if (e.key === undefined) {\n // Synthetic event (e.g., Chrome autofill). Ignore.\n return\n }\n\n removeFromCurrentlyPressedKeys([mapKey(e.key)])\n })\n }\n\n if (typeof window !== 'undefined') {\n window.addEventListener('blur', () => {\n currentlyPressedKeys.clear()\n })\n }\n})()\n\nconst currentlyPressedKeys: Set<string> = new Set<string>()\n\n// https://github.com/microsoft/TypeScript/issues/17002\nexport function isReadonlyArray(value: unknown): value is readonly unknown[] {\n return Array.isArray(value)\n}\n\nexport function isHotkeyPressed(key: string | readonly string[], splitKey = ','): boolean {\n const hotkeyArray = isReadonlyArray(key) ? key : key.split(splitKey)\n\n return hotkeyArray.every((hotkey) => currentlyPressedKeys.has(hotkey.trim().toLowerCase()))\n}\n\nexport function pushToCurrentlyPressedKeys(key: string | string[]): void {\n const hotkeyArray = Array.isArray(key) ? key : [key]\n\n /*\n Due to a weird behavior on macOS we need to clear the set if the user pressed down the meta key and presses another key.\n https://stackoverflow.com/questions/11818637/why-does-javascript-drop-keyup-events-when-the-metakey-is-pressed-on-mac-browser\n Otherwise the set will hold all ever pressed keys while the meta key is down which leads to wrong results.\n */\n if (currentlyPressedKeys.has('meta')) {\n currentlyPressedKeys.forEach((key) => !isHotkeyModifier(key) && currentlyPressedKeys.delete(key.toLowerCase()))\n }\n\n hotkeyArray.forEach((hotkey) => currentlyPressedKeys.add(hotkey.toLowerCase()))\n}\n\nexport function removeFromCurrentlyPressedKeys(key: string | string[]): void {\n const hotkeyArray = Array.isArray(key) ? key : [key]\n\n /*\n Due to a weird behavior on macOS we need to clear the set if the user pressed down the meta key and presses another key.\n https://stackoverflow.com/questions/11818637/why-does-javascript-drop-keyup-events-when-the-metakey-is-pressed-on-mac-browser\n Otherwise the set will hold all ever pressed keys while the meta key is down which leads to wrong results.\n */\n if (key === 'meta') {\n currentlyPressedKeys.clear()\n } else {\n hotkeyArray.forEach((hotkey) => currentlyPressedKeys.delete(hotkey.toLowerCase()))\n }\n}\n","import { FormTags, Hotkey, Scopes, Trigger } from './types'\nimport { isHotkeyPressed, isReadonlyArray } from './isHotkeyPressed'\n\nexport function maybePreventDefault(e: KeyboardEvent, hotkey: Hotkey, preventDefault?: Trigger): void {\n if ((typeof preventDefault === 'function' && preventDefault(e, hotkey)) || preventDefault === true) {\n e.preventDefault()\n }\n}\n\nexport function isHotkeyEnabled(e: KeyboardEvent, hotkey: Hotkey, enabled?: Trigger): boolean {\n if (typeof enabled === 'function') {\n return enabled(e, hotkey)\n }\n\n return enabled === true || enabled === undefined\n}\n\nexport function isKeyboardEventTriggeredByInput(ev: KeyboardEvent): boolean {\n return isHotkeyEnabledOnTag(ev, ['input', 'textarea', 'select'])\n}\n\nexport function isHotkeyEnabledOnTag(\n { target }: KeyboardEvent,\n enabledOnTags: readonly FormTags[] | boolean = false\n): boolean {\n const targetTagName = target && (target as HTMLElement).tagName\n\n if (isReadonlyArray(enabledOnTags)) {\n return Boolean(\n targetTagName && enabledOnTags && enabledOnTags.some((tag) => tag.toLowerCase() === targetTagName.toLowerCase())\n )\n }\n\n return Boolean(targetTagName && enabledOnTags && enabledOnTags === true)\n}\n\nexport function isScopeActive(activeScopes: string[], scopes?: Scopes): boolean {\n if (activeScopes.length === 0 && scopes) {\n console.warn(\n '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>'\n )\n\n return true\n }\n\n if (!scopes) {\n return true\n }\n\n return activeScopes.some((scope) => scopes.includes(scope)) || activeScopes.includes('*')\n}\n\nexport const isHotkeyMatchingKeyboardEvent = (e: KeyboardEvent, hotkey: Hotkey, ignoreModifiers = false): boolean => {\n const { alt, meta, mod, shift, ctrl, keys } = hotkey\n const { key: pressedKeyUppercase, ctrlKey, metaKey, shiftKey, altKey } = e\n\n const pressedKey = pressedKeyUppercase.toLowerCase()\n\n if (\n !keys?.includes(pressedKey) &&\n !['ctrl', 'control', 'unknown', 'meta', 'alt', 'shift', 'os'].includes(pressedKey)\n ) {\n return false\n }\n\n if (!ignoreModifiers) {\n // We check the pressed keys for compatibility with the keyup event. In keyup events the modifier flags are not set.\n if (alt === !altKey && pressedKey !== 'alt') {\n return false\n }\n\n if (shift === !shiftKey && pressedKey !== 'shift') {\n return false\n }\n\n // Mod is a special key name that is checking for meta on macOS and ctrl on other platforms\n if (mod) {\n if (!metaKey && !ctrlKey) {\n return false\n }\n } else {\n if (meta === !metaKey && pressedKey !== 'meta' && pressedKey !== 'os') {\n return false\n }\n\n if (ctrl === !ctrlKey && pressedKey !== 'ctrl' && pressedKey !== 'control') {\n return false\n }\n }\n }\n\n // All modifiers are correct, now check the key\n // If the key is set, we check for the key\n if (keys && keys.length === 1 && keys.includes(pressedKey)) {\n return true\n } else if (keys) {\n // Check if all keys are present in pressedDownKeys set\n return isHotkeyPressed(keys)\n } else if (!keys) {\n // If the key is not set, we only listen for modifiers, that check went alright, so we return true\n return true\n }\n\n // There is nothing that matches.\n return false\n}\n","import { createContext, ReactNode, useContext } from 'react'\nimport { Hotkey } from './types'\n\ntype BoundHotkeysProxyProviderType = {\n addHotkey: (hotkey: Hotkey) => void\n removeHotkey: (hotkey: Hotkey) => void\n}\n\nconst BoundHotkeysProxyProvider = createContext<BoundHotkeysProxyProviderType | undefined>(undefined)\n\nexport const useBoundHotkeysProxy = () => {\n return useContext(BoundHotkeysProxyProvider)\n}\n\ninterface Props {\n children: ReactNode\n addHotkey: (hotkey: Hotkey) => void\n removeHotkey: (hotkey: Hotkey) => void\n}\n\nexport default function BoundHotkeysProxyProviderProvider({ addHotkey, removeHotkey, children }: Props) {\n return (\n <BoundHotkeysProxyProvider.Provider value={{ addHotkey, removeHotkey }}>\n {children}\n </BoundHotkeysProxyProvider.Provider>\n )\n}\n","export default function deepEqual(x: any, y: any): boolean {\n //@ts-ignore\n return x && y && typeof x === 'object' && typeof y === 'object'\n ? Object.keys(x).length === Object.keys(y).length &&\n //@ts-ignore\n Object.keys(x).reduce((isEqual, key) => isEqual && deepEqual(x[key], y[key]), true)\n : x === y\n}\n","import { Hotkey } from './types'\nimport { createContext, ReactNode, useState, useContext, useCallback } from 'react'\nimport BoundHotkeysProxyProviderProvider from './BoundHotkeysProxyProvider'\nimport deepEqual from './deepEqual'\n\nexport type HotkeysContextType = {\n hotkeys: ReadonlyArray<Hotkey>\n activeScopes: string[]\n toggleScope: (scope: string) => void\n enableScope: (scope: string) => void\n disableScope: (scope: string) => void\n}\n\n// The context is only needed for special features like global scoping, so we use a graceful default fallback\nconst HotkeysContext = createContext<HotkeysContextType>({\n hotkeys: [],\n activeScopes: [], // This array has to be empty instead of containing '*' as default, to check if the provider is set or not\n toggleScope: () => {},\n enableScope: () => {},\n disableScope: () => {},\n})\n\nexport const useHotkeysContext = () => {\n return useContext(HotkeysContext)\n}\n\ninterface Props {\n initiallyActiveScopes?: string[]\n children: ReactNode\n}\n\nexport const HotkeysProvider = ({ initiallyActiveScopes = ['*'], children }: Props) => {\n const [internalActiveScopes, setInternalActiveScopes] = useState(initiallyActiveScopes)\n const [boundHotkeys, setBoundHotkeys] = useState<Hotkey[]>([])\n\n const enableScope = useCallback((scope: string) => {\n setInternalActiveScopes((prev) => {\n if (prev.includes('*')) {\n return [scope]\n }\n return Array.from(new Set([...prev, scope]))\n })\n }, [])\n\n const disableScope = useCallback((scope: string) => {\n setInternalActiveScopes((prev) => {\n return prev.filter((s) => s !== scope)\n })\n }, [])\n\n const toggleScope = useCallback((scope: string) => {\n setInternalActiveScopes((prev) => {\n if (prev.includes(scope)) {\n return prev.filter((s) => s !== scope)\n } else {\n if (prev.includes('*')) {\n return [scope]\n }\n return Array.from(new Set([...prev, scope]))\n }\n })\n }, [])\n\n const addBoundHotkey = useCallback((hotkey: Hotkey) => {\n setBoundHotkeys((prev) => [...prev, hotkey])\n }, [])\n\n const removeBoundHotkey = useCallback((hotkey: Hotkey) => {\n setBoundHotkeys((prev) => prev.filter((h) => !deepEqual(h, hotkey)))\n }, [])\n\n return (\n <HotkeysContext.Provider\n value={{ activeScopes: internalActiveScopes, hotkeys: boundHotkeys, enableScope, disableScope, toggleScope }}\n >\n <BoundHotkeysProxyProviderProvider addHotkey={addBoundHotkey} removeHotkey={removeBoundHotkey}>\n {children}\n </BoundHotkeysProxyProviderProvider>\n </HotkeysContext.Provider>\n )\n}\n","import { useRef } from 'react'\nimport deepEqual from './deepEqual'\n\nexport default function useDeepEqualMemo<T>(value: T) {\n const ref = useRef<T | undefined>(undefined)\n\n if (!deepEqual(ref.current, value)) {\n ref.current = value\n }\n\n return ref.current\n}\n","import { HotkeyCallback, Keys, Options, OptionsOrDependencyArray, RefType } from './types'\nimport { DependencyList, useCallback, useEffect, useLayoutEffect, useRef } from 'react'\nimport { mapKey, parseHotkey, parseKeysHookInput } from './parseHotkeys'\nimport {\n isHotkeyEnabled,\n isHotkeyEnabledOnTag,\n isHotkeyMatchingKeyboardEvent,\n isKeyboardEventTriggeredByInput,\n isScopeActive,\n maybePreventDefault,\n} from './validators'\nimport { useHotkeysContext } from './HotkeysProvider'\nimport { useBoundHotkeysProxy } from './BoundHotkeysProxyProvider'\nimport useDeepEqualMemo from './useDeepEqualMemo'\nimport { isReadonlyArray, pushToCurrentlyPressedKeys, removeFromCurrentlyPressedKeys } from './isHotkeyPressed'\n\nconst stopPropagation = (e: KeyboardEvent): void => {\n e.stopPropagation()\n e.preventDefault()\n e.stopImmediatePropagation()\n}\n\nconst useSafeLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect\n\nexport default function useHotkeys<T extends HTMLElement>(\n keys: Keys,\n callback: HotkeyCallback,\n options?: OptionsOrDependencyArray,\n dependencies?: OptionsOrDependencyArray\n) {\n const ref = useRef<RefType<T>>(null)\n const hasTriggeredRef = useRef(false)\n\n const _options: Options | undefined = !(options instanceof Array)\n ? (options as Options)\n : !(dependencies instanceof Array)\n ? (dependencies as Options)\n : undefined\n const _keys: string = isReadonlyArray(keys) ? keys.join(_options?.splitKey) : keys\n const _deps: DependencyList | undefined =\n options instanceof Array ? options : dependencies instanceof Array ? dependencies : undefined\n\n const memoisedCB = useCallback(callback, _deps ?? [])\n const cbRef = useRef<HotkeyCallback>(memoisedCB)\n\n if (_deps) {\n cbRef.current = memoisedCB\n } else {\n cbRef.current = callback\n }\n\n const memoisedOptions = useDeepEqualMemo(_options)\n\n const { activeScopes } = useHotkeysContext()\n const proxy = useBoundHotkeysProxy()\n\n useSafeLayoutEffect(() => {\n if (memoisedOptions?.enabled === false || !isScopeActive(activeScopes, memoisedOptions?.scopes)) {\n return\n }\n\n const listener = (e: KeyboardEvent, isKeyUp = false) => {\n if (isKeyboardEventTriggeredByInput(e) && !isHotkeyEnabledOnTag(e, memoisedOptions?.enableOnFormTags)) {\n return\n }\n\n // TODO: SINCE THE EVENT IS NOW ATTACHED TO THE REF, THE ACTIVE ELEMENT CAN NEVER BE INSIDE THE REF. THE HOTKEY ONLY TRIGGERS IF THE\n // REF IS THE ACTIVE ELEMENT. THIS IS A PROBLEM SINCE FOCUSED SUB COMPONENTS WON'T TRIGGER THE HOTKEY.\n if (ref.current !== null) {\n const rootNode = ref.current.getRootNode()\n\n if (\n (rootNode instanceof Document || rootNode instanceof ShadowRoot) &&\n rootNode.activeElement !== ref.current &&\n !ref.current.contains(rootNode.activeElement)\n ) {\n stopPropagation(e)\n return\n }\n }\n\n if ((e.target as HTMLElement)?.isContentEditable && !memoisedOptions?.enableOnContentEditable) {\n return\n }\n\n parseKeysHookInput(_keys, memoisedOptions?.splitKey).forEach((key) => {\n const hotkey = parseHotkey(key, memoisedOptions?.combinationKey)\n\n if (isHotkeyMatchingKeyboardEvent(e, hotkey, memoisedOptions?.ignoreModifiers) || hotkey.keys?.includes('*')) {\n if (memoisedOptions?.ignoreEventWhen?.(e)) {\n return\n }\n\n if (isKeyUp && hasTriggeredRef.current) {\n return\n }\n\n maybePreventDefault(e, hotkey, memoisedOptions?.preventDefault)\n\n if (!isHotkeyEnabled(e, hotkey, memoisedOptions?.enabled)) {\n stopPropagation(e)\n\n return\n }\n\n // Execute the user callback for that hotkey\n cbRef.current(e, hotkey)\n\n if (!isKeyUp) {\n hasTriggeredRef.current = true\n }\n }\n })\n }\n\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === undefined) {\n // Synthetic event (e.g., Chrome autofill). Ignore.\n return\n }\n\n pushToCurrentlyPressedKeys(mapKey(event.key))\n\n if ((memoisedOptions?.keydown === undefined && memoisedOptions?.keyup !== true) || memoisedOptions?.keydown) {\n listener(event)\n }\n }\n\n const handleKeyUp = (event: KeyboardEvent) => {\n if (event.key === undefined) {\n // Synthetic event (e.g., Chrome autofill). Ignore.\n return\n }\n\n removeFromCurrentlyPressedKeys(mapKey(event.key))\n\n hasTriggeredRef.current = false\n\n if (memoisedOptions?.keyup) {\n listener(event, true)\n }\n }\n\n const domNode = ref.current || _options?.document || document\n\n // @ts-ignore\n domNode.addEventListener('keyup', handleKeyUp)\n // @ts-ignore\n domNode.addEventListener('keydown', handleKeyDown)\n\n if (proxy) {\n parseKeysHookInput(_keys, memoisedOptions?.splitKey).forEach((key) =>\n proxy.addHotkey(parseHotkey(key, memoisedOptions?.combinationKey, memoisedOptions?.description))\n )\n }\n\n return () => {\n // @ts-ignore\n domNode.removeEventListener('keyup', handleKeyUp)\n // @ts-ignore\n domNode.removeEventListener('keydown', handleKeyDown)\n\n if (proxy) {\n parseKeysHookInput(_keys, memoisedOptions?.splitKey).forEach((key) =>\n proxy.removeHotkey(parseHotkey(key, memoisedOptions?.combinationKey, memoisedOptions?.description))\n )\n }\n }\n }, [_keys, memoisedOptions, activeScopes])\n\n return ref\n}\n","import { useCallback, useState } from 'react'\nimport { mapKey } from './parseHotkeys'\n\nexport default function useRecordHotkeys() {\n const [keys, setKeys] = useState(new Set<string>())\n const [isRecording, setIsRecording] = useState(false)\n\n const handler = useCallback((event: KeyboardEvent) => {\n if (event.key === undefined) {\n // Synthetic event (e.g., Chrome autofill). Ignore.\n return\n }\n\n event.preventDefault()\n event.stopPropagation()\n\n setKeys((prev) => {\n const newKeys = new Set(prev)\n\n newKeys.add(mapKey(event.key))\n\n return newKeys\n })\n }, [])\n\n const stop = useCallback(() => {\n if (typeof document !== 'undefined') {\n document.removeEventListener('keydown', handler)\n\n setIsRecording(false)\n }\n }, [handler])\n\n const start = useCallback(() => {\n setKeys(new Set<string>())\n\n if (typeof document !== 'undefined') {\n stop()\n\n document.addEventListener('keydown', handler)\n\n setIsRecording(true)\n }\n }, [handler, stop])\n\n return [keys, { start, stop, isRecording }] as const\n}\n"],"names":["reservedModifierKeywords","mappedKeys","esc","left","right","up","down","space","ShiftLeft","ShiftRight","AltLeft","AltRight","MetaLeft","MetaRight","OSLeft","OSRight","ControlLeft","ControlRight","mapKey","key","trim","toLowerCase","replace","isHotkeyModifier","includes","parseKeysHookInput","keys","splitKey","split","parseHotkey","hotkey","combinationKey","description","toLocaleLowerCase","map","k","modifiers","alt","ctrl","shift","meta","mod","singleCharKeys","filter","_extends","document","addEventListener","e","undefined","console","log","length","pushToCurrentlyPressedKeys","removeFromCurrentlyPressedKeys","window","currentlyPressedKeys","clear","Set","isReadonlyArray","value","Array","isArray","isHotkeyPressed","hotkeyArray","every","has","forEach","add","maybePreventDefault","preventDefault","isHotkeyEnabled","enabled","isKeyboardEventTriggeredByInput","ev","isHotkeyEnabledOnTag","_ref","enabledOnTags","target","targetTagName","tagName","Boolean","some","tag","isScopeActive","activeScopes","scopes","warn","scope","isHotkeyMatchingKeyboardEvent","ignoreModifiers","pressedKeyUppercase","ctrlKey","metaKey","shiftKey","altKey","pressedKey","BoundHotkeysProxyProvider","createContext","useBoundHotkeysProxy","useContext","BoundHotkeysProxyProviderProvider","addHotkey","removeHotkey","children","_jsx","Provider","deepEqual","x","y","Object","reduce","isEqual","HotkeysContext","hotkeys","toggleScope","enableScope","disableScope","useHotkeysContext","HotkeysProvider","initiallyActiveScopes","_ref$initiallyActiveS","_useState","useState","internalActiveScopes","setInternalActiveScopes","_useState2","boundHotkeys","setBoundHotkeys","useCallback","prev","from","concat","s","addBoundHotkey","removeBoundHotkey","h","useDeepEqualMemo","ref","useRef","current","stopPropagation","stopImmediatePropagation","useSafeLayoutEffect","useLayoutEffect","useEffect","useHotkeys","callback","options","dependencies","hasTriggeredRef","_options","_keys","join","_deps","memoisedCB","cbRef","memoisedOptions","_useHotkeysContext","proxy","listener","isKeyUp","enableOnFormTags","rootNode","getRootNode","Document","ShadowRoot","activeElement","contains","_e$target","isContentEditable","enableOnContentEditable","_hotkey$keys","ignoreEventWhen","handleKeyDown","event","keydown","keyup","handleKeyUp","domNode","removeEventListener","useRecordHotkeys","setKeys","isRecording","setIsRecording","handler","newKeys","stop","start"],"mappings":";;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,wBAAwB,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC;AAExE,IAAMC,UAAU,GAA2B;EACzCC,GAAG,EAAE,QAAQ;EACb,UAAQ,OAAO;EACfC,IAAI,EAAE,WAAW;EACjBC,KAAK,EAAE,YAAY;EACnBC,EAAE,EAAE,SAAS;EACbC,IAAI,EAAE,WAAW;EACjBC,KAAK,EAAE,GAAG;EACVC,SAAS,EAAE,OAAO;EAClBC,UAAU,EAAE,OAAO;EACnBC,OAAO,EAAE,KAAK;EACdC,QAAQ,EAAE,KAAK;EACfC,QAAQ,EAAE,MAAM;EAChBC,SAAS,EAAE,MAAM;EACjBC,MAAM,EAAE,MAAM;EACdC,OAAO,EAAE,MAAM;EACfC,WAAW,EAAE,MAAM;EACnBC,YAAY,EA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AAO,CAAC,UAACpD,IAAI;MACX,IAAMwD,OAAO,GAAG,IAAIhI,GAAG,CAACwE,IAAI,CAAC;MAE7BwD,OAAO,CAACtH,GAAG,CAACjD,MAAM,CAAC4J,KAAK,CAAC3J,GAAG,CAAC,CAAC;MAE9B,OAAOsK,OAAO;KACf,CAAC;GACH,EAAE,EAAE,CAAC;EAEN,IAAMC,IAAI,GAAG1D,iBAAW,CAAC;IACvB,IAAI,OAAOnF,QAAQ,KAAK,WAAW,EAAE;MACnCA,QAAQ,CAACsI,mBAAmB,CAAC,SAAS,EAAEK,OAAO,CAAC;MAEhDD,cAAc,CAAC,KAAK,CAAC;;GAExB,EAAE,CAACC,OAAO,CAAC,CAAC;EAEb,IAAMG,KAAK,GAAG3D,iBAAW,CAAC;IACxBqD,OAAO,CAAC,IAAI5H,GAAG,EAAU,CAAC;IAE1B,IAAI,OAAOZ,QAAQ,KAAK,WAAW,EAAE;MACnC6I,IAAI,EAAE;MAEN7I,QAAQ,CAACC,gBAAgB,CAAC,SAAS,EAAE0I,OAAO,CAAC;MAE7CD,cAAc,CAAC,IAAI,CAAC;;GAEvB,EAAE,CAACC,OAAO,EAAEE,IAAI,CAAC,CAAC;EAEnB,OAAO,CAAChK,IAAI,EAAE;IAAEiK,KAAK,EAALA,KAAK;IAAED,IAAI,EAAJA,IAAI;IAAEJ,WAAW,EAAXA;GAAa,CAAU;AACtD;;;;;;;;"}
@@ -1,2 +0,0 @@
1
- "use strict";var e=require("react"),t=require("react/jsx-runtime");function n(){return(n=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e}).apply(this,arguments)}var o=["shift","alt","meta","mod","ctrl"],r={esc:"escape",return:"enter",left:"arrowleft",right:"arrowright",up:"arrowup",down:"arrowdown",space:" ",ShiftLeft:"shift",ShiftRight:"shift",AltLeft:"alt",AltRight:"alt",MetaLeft:"meta",MetaRight:"meta",OSLeft:"meta",OSRight:"meta",ControlLeft:"ctrl",ControlRight:"ctrl"};function i(e){return(r[e.trim()]||e.trim()).toLowerCase().replace(/key|digit|numpad/,"")}function u(e,t){return void 0===t&&(t=","),e.split(t)}function c(e,t,r){void 0===t&&(t="+");var u=e.toLocaleLowerCase().split(t).map((function(e){return i(e)}));return n({},{alt:u.includes("alt"),ctrl:u.includes("ctrl")||u.includes("control"),shift:u.includes("shift"),meta:u.includes("meta"),mod:u.includes("mod")},{keys:u.filter((function(e){return!o.includes(e)})),description:r})}"undefined"!=typeof document&&(document.addEventListener("keydown",(function(e){void 0!==e.key&&(console.log("keydown",e.key,i(e.key),e.key.length),f([i(e.key)]))})),document.addEventListener("keyup",(function(e){void 0!==e.key&&d([i(e.key)])}))),"undefined"!=typeof window&&window.addEventListener("blur",(function(){a.clear()}));var a=new Set;function l(e){return Array.isArray(e)}function s(e,t){return void 0===t&&(t=","),(l(e)?e:e.split(t)).every((function(e){return a.has(e.trim().toLowerCase())}))}function f(e){var t=Array.isArray(e)?e:[e];a.has("meta")&&a.forEach((function(e){return!function(e){return o.includes(e)}(e)&&a.delete(e.toLowerCase())})),t.forEach((function(e){return a.add(e.toLowerCase())}))}function d(e){var t=Array.isArray(e)?e:[e];"meta"===e?a.clear():t.forEach((function(e){return a.delete(e.toLowerCase())}))}function v(e,t){var n=e.target;void 0===t&&(t=!1);var o=n&&n.tagName;return l(t)?Boolean(o&&t&&t.some((function(e){return e.toLowerCase()===o.toLowerCase()}))):Boolean(o&&t&&!0===t)}var y=e.createContext(void 0);function p(e){return t.jsx(y.Provider,{value:{addHotkey:e.addHotkey,removeHotkey:e.removeHotkey},children:e.children})}function k(e,t){return e&&t&&"object"==typeof e&&"object"==typeof t?Object.keys(e).length===Object.keys(t).length&&Object.keys(e).reduce((function(n,o){return n&&k(e[o],t[o])}),!0):e===t}var m=e.createContext({hotkeys:[],activeScopes:[],toggleScope:function(){},enableScope:function(){},disableScope:function(){}}),h=function(){return e.useContext(m)},w=function(e){e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},g="undefined"!=typeof window?e.useLayoutEffect:e.useEffect;exports.HotkeysProvider=function(n){var o=n.initiallyActiveScopes,r=n.children,i=e.useState(void 0===o?["*"]:o),u=i[0],c=i[1],a=e.useState([]),l=a[0],s=a[1],f=e.useCallback((function(e){c((function(t){return t.includes("*")?[e]:Array.from(new Set([].concat(t,[e])))}))}),[]),d=e.useCallback((function(e){c((function(t){return t.filter((function(t){return t!==e}))}))}),[]),v=e.useCallback((function(e){c((function(t){return t.includes(e)?t.filter((function(t){return t!==e})):t.includes("*")?[e]:Array.from(new Set([].concat(t,[e])))}))}),[]),y=e.useCallback((function(e){s((function(t){return[].concat(t,[e])}))}),[]),h=e.useCallback((function(e){s((function(t){return t.filter((function(t){return!k(t,e)}))}))}),[]);return t.jsx(m.Provider,{value:{activeScopes:u,hotkeys:l,enableScope:f,disableScope:d,toggleScope:v},children:t.jsx(p,{addHotkey:y,removeHotkey:h,children:r})})},exports.isHotkeyPressed=s,exports.useHotkeys=function(t,n,o,r){var a=e.useRef(null),p=e.useRef(!1),m=o instanceof Array?r instanceof Array?void 0:r:o,b=l(t)?t.join(null==m?void 0:m.splitKey):t,C=o instanceof Array?o:r instanceof Array?r:void 0,L=e.useCallback(n,null!=C?C:[]),S=e.useRef(L);S.current=C?L:n;var E=function(t){var n=e.useRef(void 0);return k(n.current,t)||(n.current=t),n.current}(m),A=h().activeScopes,x=e.useContext(y);return g((function(){if(!1!==(null==E?void 0:E.enabled)&&function(e,t){return 0===e.length&&t?(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>'),!0):!t||e.some((function(e){return t.includes(e)}))||e.includes("*")}(A,null==E?void 0:E.scopes)){var e=function(e,t){var n;if(void 0===t&&(t=!1),!v(e,["input","textarea","select"])||v(e,null==E?void 0:E.enableOnFormTags)){if(null!==a.current){var o=a.current.getRootNode();if((o instanceof Document||o instanceof ShadowRoot)&&o.activeElement!==a.current&&!a.current.contains(o.activeElement))return void w(e)}(null==(n=e.target)||!n.isContentEditable||null!=E&&E.enableOnContentEditable)&&u(b,null==E?void 0:E.splitKey).forEach((function(n){var o,r=c(n,null==E?void 0:E.combinationKey);if(function(e,t,n){void 0===n&&(n=!1);var o=t.alt,r=t.meta,i=t.mod,u=t.shift,c=t.ctrl,a=t.keys,l=e.ctrlKey,f=e.metaKey,d=e.shiftKey,v=e.altKey,y=e.key.toLowerCase();if(!(null!=a&&a.includes(y)||["ctrl","control","unknown","meta","alt","shift","os"].includes(y)))return!1;if(!n){if(o===!v&&"alt"!==y)return!1;if(u===!d&&"shift"!==y)return!1;if(i){if(!f&&!l)return!1}else{if(r===!f&&"meta"!==y&&"os"!==y)return!1;if(c===!l&&"ctrl"!==y&&"control"!==y)return!1}}return!(!a||1!==a.length||!a.includes(y))||(a?s(a):!a)}(e,r,null==E?void 0:E.ignoreModifiers)||null!=(o=r.keys)&&o.includes("*")){if(null!=E&&null!=E.ignoreEventWhen&&E.ignoreEventWhen(e))return;if(t&&p.current)return;if(function(e,t,n){("function"==typeof n&&n(e,t)||!0===n)&&e.preventDefault()}(e,r,null==E?void 0:E.preventDefault),!function(e,t,n){return"function"==typeof n?n(e,t):!0===n||void 0===n}(e,r,null==E?void 0:E.enabled))return void w(e);S.current(e,r),t||(p.current=!0)}}))}},t=function(t){void 0!==t.key&&(f(i(t.key)),(void 0===(null==E?void 0:E.keydown)&&!0!==(null==E?void 0:E.keyup)||null!=E&&E.keydown)&&e(t))},n=function(t){void 0!==t.key&&(d(i(t.key)),p.current=!1,null!=E&&E.keyup&&e(t,!0))},o=a.current||(null==m?void 0:m.document)||document;return o.addEventListener("keyup",n),o.addEventListener("keydown",t),x&&u(b,null==E?void 0:E.splitKey).forEach((function(e){return x.addHotkey(c(e,null==E?void 0:E.combinationKey,null==E?void 0:E.description))})),function(){o.removeEventListener("keyup",n),o.removeEventListener("keydown",t),x&&u(b,null==E?void 0:E.splitKey).forEach((function(e){return x.removeHotkey(c(e,null==E?void 0:E.combinationKey,null==E?void 0:E.description))}))}}}),[b,E,A]),a},exports.useHotkeysContext=h,exports.useRecordHotkeys=function(){var t=e.useState(new Set),n=t[0],o=t[1],r=e.useState(!1),u=r[0],c=r[1],a=e.useCallback((function(e){void 0!==e.key&&(e.preventDefault(),e.stopPropagation(),o((function(t){var n=new Set(t);return n.add(i(e.key)),n})))}),[]),l=e.useCallback((function(){"undefined"!=typeof document&&(document.removeEventListener("keydown",a),c(!1))}),[a]);return[n,{start:e.useCallback((function(){o(new Set),"undefined"!=typeof document&&(l(),document.addEventListener("keydown",a),c(!0))}),[a,l]),stop:l,isRecording:u}]};
2
- //# sourceMappingURL=react-hotkeys-hook.cjs.production.min.js.map