@redis-ui/components 47.3.3 → 47.5.0
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/dist/AppSelectionMenu/components/Compose/Compose.cjs +1 -1
- package/dist/AppSelectionMenu/components/Compose/Compose.js +1 -1
- package/dist/BoxSelectionGroup/hooks/useBoxSelectionGroup.cjs +1 -1
- package/dist/BoxSelectionGroup/hooks/useBoxSelectionGroup.js +1 -1
- package/dist/Checkbox/components/Compose/Compose.cjs +1 -1
- package/dist/Checkbox/components/Compose/Compose.js +1 -1
- package/dist/Checkbox/components/Indicator/Indicator.style.cjs +2 -2
- package/dist/Checkbox/components/Indicator/Indicator.style.js +3 -3
- package/dist/Drawer/components/Description/Description.cjs +1 -1
- package/dist/Drawer/components/Description/Description.js +1 -1
- package/dist/Drawer/components/Header/components/Title/Title.cjs +1 -1
- package/dist/Drawer/components/Header/components/Title/Title.js +1 -1
- package/dist/Inputs/PasswordInput/components/PasswordInput.context.cjs +1 -1
- package/dist/Inputs/PasswordInput/components/PasswordInput.context.js +1 -1
- package/dist/Inputs/TextArea/components/TextAreaTag/TextAreaTag.cjs +1 -1
- package/dist/Inputs/TextArea/components/TextAreaTag/TextAreaTag.js +1 -1
- package/dist/Inputs/components/Context/InputValue.context.d.ts +1 -1
- package/dist/Inputs/components/Context/InputValueProvider.cjs +1 -1
- package/dist/Inputs/components/Context/InputValueProvider.js +1 -1
- package/dist/Inputs/components/Context/NumericInputValueProvider.cjs +1 -1
- package/dist/Inputs/components/Context/NumericInputValueProvider.js +1 -1
- package/dist/Inputs/components/InputTag/InputTag.cjs +1 -1
- package/dist/Inputs/components/InputTag/InputTag.js +1 -1
- package/dist/Loader/Loader.cjs +1 -1
- package/dist/Loader/Loader.js +1 -1
- package/dist/Modal/components/Content/components/Description/Description.cjs +1 -1
- package/dist/Modal/components/Content/components/Description/Description.js +1 -1
- package/dist/Modal/components/Content/components/Header/components/Title/Title.cjs +1 -1
- package/dist/Modal/components/Content/components/Header/components/Title/Title.js +1 -1
- package/dist/MultiSelect/components/Compose/hooks/useMultiSelectContextApi.cjs +1 -1
- package/dist/MultiSelect/components/Compose/hooks/useMultiSelectContextApi.d.ts +1 -1
- package/dist/MultiSelect/components/Compose/hooks/useMultiSelectContextApi.js +1 -1
- package/dist/MultiSelect/components/Content/components/SelectAll/SelectAll.cjs +11 -7
- package/dist/MultiSelect/components/Content/components/SelectAll/SelectAll.js +12 -8
- package/dist/RadioGroup/components/Compose/Compose.cjs +2 -2
- package/dist/RadioGroup/components/Compose/Compose.js +2 -2
- package/dist/ScreenReaderAnnounce/ScreenReaderAnnounce.cjs +1 -1
- package/dist/ScreenReaderAnnounce/ScreenReaderAnnounce.js +1 -1
- package/dist/Section/components/Compose/Compose.cjs +1 -1
- package/dist/Section/components/Compose/Compose.js +1 -1
- package/dist/Section/components/Header/components/CollapseButton/CollapseButton.cjs +1 -1
- package/dist/Section/components/Header/components/CollapseButton/CollapseButton.js +1 -1
- package/dist/Select/components/Context/hooks/useSelectContextApi.d.ts +1 -1
- package/dist/Select/components/Trigger/components/Compose/Compose.cjs +1 -1
- package/dist/Select/components/Trigger/components/Compose/Compose.js +1 -1
- package/dist/Slider/components/Compose/Compose.cjs +1 -1
- package/dist/Slider/components/Compose/Compose.js +1 -1
- package/dist/Switch/components/Compose/Compose.cjs +1 -1
- package/dist/Switch/components/Compose/Compose.js +1 -1
- package/dist/Toast/Toaster.style.cjs +2 -2
- package/dist/Toast/Toaster.style.js +2 -2
- package/dist/Toast/core/mapping.helpers.cjs +1 -1
- package/dist/Toast/core/mapping.helpers.js +1 -1
- package/dist/Typography/hooks/useEllipsisTooltip.d.ts +1 -1
- package/dist/node_modules/@radix-ui/primitive/dist/index.cjs +1 -1
- package/dist/node_modules/@radix-ui/primitive/dist/index.js +1 -1
- package/dist/node_modules/@radix-ui/react-checkbox/dist/index.cjs +108 -62
- package/dist/node_modules/@radix-ui/react-checkbox/dist/index.js +108 -62
- package/dist/node_modules/@radix-ui/react-collapsible/dist/index.cjs +5 -4
- package/dist/node_modules/@radix-ui/react-collapsible/dist/index.js +5 -4
- package/dist/node_modules/@radix-ui/react-collection/dist/index.cjs +4 -2
- package/dist/node_modules/@radix-ui/react-collection/dist/index.js +5 -3
- package/dist/node_modules/@radix-ui/react-compose-refs/dist/index.cjs +16 -2
- package/dist/node_modules/@radix-ui/react-compose-refs/dist/index.js +16 -2
- package/dist/node_modules/@radix-ui/react-context/dist/index.cjs +8 -8
- package/dist/node_modules/@radix-ui/react-context/dist/index.js +8 -8
- package/dist/node_modules/@radix-ui/react-dialog/dist/index.cjs +6 -4
- package/dist/node_modules/@radix-ui/react-dialog/dist/index.js +6 -4
- package/dist/node_modules/@radix-ui/react-dropdown-menu/dist/index.cjs +4 -3
- package/dist/node_modules/@radix-ui/react-dropdown-menu/dist/index.js +4 -3
- package/dist/node_modules/@radix-ui/react-focus-guards/dist/index.cjs +4 -1
- package/dist/node_modules/@radix-ui/react-focus-guards/dist/index.js +4 -1
- package/dist/node_modules/@radix-ui/react-id/dist/index.cjs +1 -1
- package/dist/node_modules/@radix-ui/react-id/dist/index.js +1 -1
- package/dist/node_modules/@radix-ui/react-menu/dist/index.cjs +8 -5
- package/dist/node_modules/@radix-ui/react-menu/dist/index.js +8 -5
- package/dist/node_modules/@radix-ui/react-popover/dist/index.cjs +6 -4
- package/dist/node_modules/@radix-ui/react-popover/dist/index.js +6 -4
- package/dist/node_modules/@radix-ui/react-popper/dist/index.cjs +4 -1
- package/dist/node_modules/@radix-ui/react-popper/dist/index.js +4 -1
- package/dist/node_modules/@radix-ui/react-presence/dist/index.cjs +16 -6
- package/dist/node_modules/@radix-ui/react-presence/dist/index.js +16 -5
- package/dist/node_modules/@radix-ui/react-primitive/dist/index.cjs +3 -1
- package/dist/node_modules/@radix-ui/react-primitive/dist/index.js +3 -1
- package/dist/node_modules/@radix-ui/react-progress/dist/index.cjs +2 -2
- package/dist/node_modules/@radix-ui/react-progress/dist/index.js +2 -2
- package/dist/node_modules/@radix-ui/{react-slider → react-progress}/node_modules/@radix-ui/react-context/dist/index.cjs +2 -1
- package/dist/node_modules/@radix-ui/{react-switch → react-progress}/node_modules/@radix-ui/react-context/dist/index.js +2 -1
- package/dist/node_modules/@radix-ui/{react-slider → react-progress}/node_modules/@radix-ui/react-primitive/dist/index.cjs +1 -1
- package/dist/node_modules/@radix-ui/{react-switch → react-progress}/node_modules/@radix-ui/react-primitive/dist/index.js +4 -2
- package/dist/node_modules/@radix-ui/{react-slider → react-progress}/node_modules/@radix-ui/react-slot/dist/index.cjs +14 -4
- package/dist/node_modules/@radix-ui/react-progress/node_modules/@radix-ui/react-slot/dist/index.js +97 -0
- package/dist/node_modules/@radix-ui/react-radio-group/dist/index.cjs +16 -11
- package/dist/node_modules/@radix-ui/react-radio-group/dist/index.js +16 -11
- package/dist/node_modules/@radix-ui/react-roving-focus/dist/index.cjs +11 -6
- package/dist/node_modules/@radix-ui/react-roving-focus/dist/index.js +11 -6
- package/dist/node_modules/@radix-ui/react-select/dist/index.cjs +56 -35
- package/dist/node_modules/@radix-ui/react-select/dist/index.js +57 -36
- package/dist/node_modules/@radix-ui/react-slider/dist/index.cjs +35 -35
- package/dist/node_modules/@radix-ui/react-slider/dist/index.js +10 -10
- package/dist/node_modules/@radix-ui/react-slot/dist/index.cjs +55 -39
- package/dist/node_modules/@radix-ui/react-slot/dist/index.js +54 -38
- package/dist/node_modules/@radix-ui/react-switch/dist/index.cjs +27 -23
- package/dist/node_modules/@radix-ui/react-switch/dist/index.js +17 -13
- package/dist/node_modules/@radix-ui/react-tabs/dist/index.cjs +2 -1
- package/dist/node_modules/@radix-ui/react-tabs/dist/index.js +2 -1
- package/dist/node_modules/@radix-ui/react-toggle/dist/index.cjs +4 -3
- package/dist/node_modules/@radix-ui/react-toggle/dist/index.js +4 -3
- package/dist/node_modules/@radix-ui/react-tooltip/dist/index.cjs +33 -17
- package/dist/node_modules/@radix-ui/react-tooltip/dist/index.js +33 -17
- package/dist/node_modules/@radix-ui/react-use-controllable-state/dist/index.cjs +29 -16
- package/dist/node_modules/@radix-ui/react-use-controllable-state/dist/index.js +29 -16
- package/dist/node_modules/@radix-ui/react-use-layout-effect/dist/index.cjs +1 -1
- package/dist/node_modules/@radix-ui/react-use-layout-effect/dist/index.js +1 -1
- package/dist/node_modules/@radix-ui/react-visually-hidden/dist/index.cjs +14 -11
- package/dist/node_modules/@radix-ui/react-visually-hidden/dist/index.js +14 -11
- package/dist/node_modules/@tanstack/hotkeys/dist/constants.cjs +389 -0
- package/dist/node_modules/@tanstack/hotkeys/dist/constants.js +383 -0
- package/dist/node_modules/@tanstack/hotkeys/dist/format.cjs +22 -0
- package/dist/node_modules/@tanstack/hotkeys/dist/format.js +22 -0
- package/dist/node_modules/@tanstack/hotkeys/dist/hotkey-manager.cjs +363 -0
- package/dist/node_modules/@tanstack/hotkeys/dist/hotkey-manager.js +363 -0
- package/dist/node_modules/@tanstack/hotkeys/dist/manager.utils.cjs +111 -0
- package/dist/node_modules/@tanstack/hotkeys/dist/manager.utils.js +107 -0
- package/dist/node_modules/@tanstack/hotkeys/dist/match.cjs +59 -0
- package/dist/node_modules/@tanstack/hotkeys/dist/match.js +59 -0
- package/dist/node_modules/@tanstack/hotkeys/dist/parse.cjs +143 -0
- package/dist/node_modules/@tanstack/hotkeys/dist/parse.js +141 -0
- package/dist/node_modules/@tanstack/react-hotkeys/dist/HotkeysProvider.cjs +10 -0
- package/dist/node_modules/@tanstack/react-hotkeys/dist/HotkeysProvider.js +8 -0
- package/dist/node_modules/@tanstack/react-hotkeys/dist/useHotkey.cjs +121 -0
- package/dist/node_modules/@tanstack/react-hotkeys/dist/useHotkey.js +120 -0
- package/dist/node_modules/@tanstack/react-hotkeys/dist/utils.cjs +9 -0
- package/dist/node_modules/@tanstack/react-hotkeys/dist/utils.js +9 -0
- package/dist/node_modules/@tanstack/store/dist/alien.cjs +183 -0
- package/dist/node_modules/@tanstack/store/dist/alien.js +182 -0
- package/dist/node_modules/@tanstack/store/dist/atom.cjs +161 -0
- package/dist/node_modules/@tanstack/store/dist/atom.js +160 -0
- package/dist/node_modules/@tanstack/store/dist/store.cjs +25 -0
- package/dist/node_modules/@tanstack/store/dist/store.js +25 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/SideEffect.cjs +8 -2
- package/dist/node_modules/react-remove-scroll/dist/es2015/SideEffect.js +8 -2
- package/dist/node_modules/react-remove-scroll/dist/es2015/UI.cjs +3 -1
- package/dist/node_modules/react-remove-scroll/dist/es2015/UI.js +3 -1
- package/dist/node_modules/react-remove-scroll/dist/es2015/handleScroll.cjs +4 -2
- package/dist/node_modules/react-remove-scroll/dist/es2015/handleScroll.js +4 -2
- package/dist/{node_modules/@radix-ui/react-switch → packages/components}/node_modules/@radix-ui/react-primitive/dist/index.cjs +5 -3
- package/dist/{node_modules/@radix-ui/react-slider → packages/components}/node_modules/@radix-ui/react-primitive/dist/index.js +1 -1
- package/dist/packages/components/node_modules/@radix-ui/react-slot/dist/index.cjs +99 -0
- package/dist/{node_modules/@radix-ui/react-slider → packages/components}/node_modules/@radix-ui/react-slot/dist/index.js +14 -4
- package/dist/packages/components/node_modules/@radix-ui/react-visually-hidden/dist/index.cjs +32 -0
- package/dist/packages/components/node_modules/@radix-ui/react-visually-hidden/dist/index.js +30 -0
- package/dist/{node_modules → packages/components/node_modules}/react-toastify/dist/react-toastify.esm.cjs +3 -3
- package/dist/{node_modules → packages/components/node_modules}/react-toastify/dist/react-toastify.esm.js +2 -2
- package/package.json +19 -15
- package/dist/node_modules/@radix-ui/react-slider/node_modules/@radix-ui/number/dist/index.cjs +0 -6
- package/dist/node_modules/@radix-ui/react-slider/node_modules/@radix-ui/number/dist/index.js +0 -6
- package/dist/node_modules/@radix-ui/react-slider/node_modules/@radix-ui/primitive/dist/index.cjs +0 -9
- package/dist/node_modules/@radix-ui/react-slider/node_modules/@radix-ui/primitive/dist/index.js +0 -9
- package/dist/node_modules/@radix-ui/react-slider/node_modules/@radix-ui/react-collection/dist/index.cjs +0 -81
- package/dist/node_modules/@radix-ui/react-slider/node_modules/@radix-ui/react-collection/dist/index.js +0 -79
- package/dist/node_modules/@radix-ui/react-slider/node_modules/@radix-ui/react-compose-refs/dist/index.cjs +0 -31
- package/dist/node_modules/@radix-ui/react-slider/node_modules/@radix-ui/react-compose-refs/dist/index.js +0 -28
- package/dist/node_modules/@radix-ui/react-slider/node_modules/@radix-ui/react-context/dist/index.js +0 -67
- package/dist/node_modules/@radix-ui/react-slider/node_modules/@radix-ui/react-direction/dist/index.cjs +0 -12
- package/dist/node_modules/@radix-ui/react-slider/node_modules/@radix-ui/react-direction/dist/index.js +0 -10
- package/dist/node_modules/@radix-ui/react-slider/node_modules/@radix-ui/react-use-controllable-state/dist/index.cjs +0 -57
- package/dist/node_modules/@radix-ui/react-slider/node_modules/@radix-ui/react-use-controllable-state/dist/index.js +0 -55
- package/dist/node_modules/@radix-ui/react-slider/node_modules/@radix-ui/react-use-layout-effect/dist/index.cjs +0 -7
- package/dist/node_modules/@radix-ui/react-slider/node_modules/@radix-ui/react-use-layout-effect/dist/index.js +0 -5
- package/dist/node_modules/@radix-ui/react-slider/node_modules/@radix-ui/react-use-previous/dist/index.cjs +0 -19
- package/dist/node_modules/@radix-ui/react-slider/node_modules/@radix-ui/react-use-previous/dist/index.js +0 -17
- package/dist/node_modules/@radix-ui/react-slider/node_modules/@radix-ui/react-use-size/dist/index.cjs +0 -41
- package/dist/node_modules/@radix-ui/react-slider/node_modules/@radix-ui/react-use-size/dist/index.js +0 -39
- package/dist/node_modules/@radix-ui/react-switch/node_modules/@radix-ui/primitive/dist/index.cjs +0 -9
- package/dist/node_modules/@radix-ui/react-switch/node_modules/@radix-ui/primitive/dist/index.js +0 -9
- package/dist/node_modules/@radix-ui/react-switch/node_modules/@radix-ui/react-compose-refs/dist/index.cjs +0 -31
- package/dist/node_modules/@radix-ui/react-switch/node_modules/@radix-ui/react-compose-refs/dist/index.js +0 -28
- package/dist/node_modules/@radix-ui/react-switch/node_modules/@radix-ui/react-context/dist/index.cjs +0 -69
- package/dist/node_modules/@radix-ui/react-switch/node_modules/@radix-ui/react-slot/dist/index.cjs +0 -82
- package/dist/node_modules/@radix-ui/react-switch/node_modules/@radix-ui/react-slot/dist/index.js +0 -80
- package/dist/node_modules/react-hotkeys-hook/dist/react-hotkeys-hook.esm.cjs +0 -289
- package/dist/node_modules/react-hotkeys-hook/dist/react-hotkeys-hook.esm.js +0 -288
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
import "react/jsx-runtime";
|
|
2
|
-
import { createContext, useCallback, useContext, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
3
|
-
//#region ../../node_modules/react-hotkeys-hook/dist/react-hotkeys-hook.esm.js
|
|
4
|
-
function _extends() {
|
|
5
|
-
return _extends = Object.assign ? Object.assign.bind() : function(n) {
|
|
6
|
-
for (var e = 1; e < arguments.length; e++) {
|
|
7
|
-
var t = arguments[e];
|
|
8
|
-
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
9
|
-
}
|
|
10
|
-
return n;
|
|
11
|
-
}, _extends.apply(null, arguments);
|
|
12
|
-
}
|
|
13
|
-
var reservedModifierKeywords = [
|
|
14
|
-
"shift",
|
|
15
|
-
"alt",
|
|
16
|
-
"meta",
|
|
17
|
-
"mod",
|
|
18
|
-
"ctrl"
|
|
19
|
-
];
|
|
20
|
-
var mappedKeys = {
|
|
21
|
-
esc: "escape",
|
|
22
|
-
"return": "enter",
|
|
23
|
-
".": "period",
|
|
24
|
-
",": "comma",
|
|
25
|
-
"-": "slash",
|
|
26
|
-
" ": "space",
|
|
27
|
-
"`": "backquote",
|
|
28
|
-
"#": "backslash",
|
|
29
|
-
"+": "bracketright",
|
|
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 (key && mappedKeys[key] || key || "").trim().toLowerCase().replace(/key|digit|numpad|arrow/, "");
|
|
43
|
-
}
|
|
44
|
-
function isHotkeyModifier(key) {
|
|
45
|
-
return reservedModifierKeywords.includes(key);
|
|
46
|
-
}
|
|
47
|
-
function parseKeysHookInput(keys, splitKey) {
|
|
48
|
-
if (splitKey === void 0) splitKey = ",";
|
|
49
|
-
return keys.split(splitKey);
|
|
50
|
-
}
|
|
51
|
-
function parseHotkey(hotkey, combinationKey, description) {
|
|
52
|
-
if (combinationKey === void 0) combinationKey = "+";
|
|
53
|
-
var keys = hotkey.toLocaleLowerCase().split(combinationKey).map(function(k) {
|
|
54
|
-
return mapKey(k);
|
|
55
|
-
});
|
|
56
|
-
var modifiers = {
|
|
57
|
-
alt: keys.includes("alt"),
|
|
58
|
-
ctrl: keys.includes("ctrl") || keys.includes("control"),
|
|
59
|
-
shift: keys.includes("shift"),
|
|
60
|
-
meta: keys.includes("meta"),
|
|
61
|
-
mod: keys.includes("mod")
|
|
62
|
-
};
|
|
63
|
-
var singleCharKeys = keys.filter(function(k) {
|
|
64
|
-
return !reservedModifierKeywords.includes(k);
|
|
65
|
-
});
|
|
66
|
-
return _extends({}, modifiers, {
|
|
67
|
-
keys: singleCharKeys,
|
|
68
|
-
description,
|
|
69
|
-
hotkey
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
(function() {
|
|
73
|
-
if (typeof document !== "undefined") {
|
|
74
|
-
document.addEventListener("keydown", function(e) {
|
|
75
|
-
if (e.key === void 0) return;
|
|
76
|
-
pushToCurrentlyPressedKeys([mapKey(e.key), mapKey(e.code)]);
|
|
77
|
-
});
|
|
78
|
-
document.addEventListener("keyup", function(e) {
|
|
79
|
-
if (e.key === void 0) return;
|
|
80
|
-
removeFromCurrentlyPressedKeys([mapKey(e.key), mapKey(e.code)]);
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
if (typeof window !== "undefined") window.addEventListener("blur", function() {
|
|
84
|
-
currentlyPressedKeys.clear();
|
|
85
|
-
});
|
|
86
|
-
})();
|
|
87
|
-
var currentlyPressedKeys = /* @__PURE__ */ new Set();
|
|
88
|
-
function isReadonlyArray(value) {
|
|
89
|
-
return Array.isArray(value);
|
|
90
|
-
}
|
|
91
|
-
function isHotkeyPressed(key, splitKey) {
|
|
92
|
-
if (splitKey === void 0) splitKey = ",";
|
|
93
|
-
return (isReadonlyArray(key) ? key : key.split(splitKey)).every(function(hotkey) {
|
|
94
|
-
return currentlyPressedKeys.has(hotkey.trim().toLowerCase());
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
function pushToCurrentlyPressedKeys(key) {
|
|
98
|
-
var hotkeyArray = Array.isArray(key) ? key : [key];
|
|
99
|
-
if (currentlyPressedKeys.has("meta")) currentlyPressedKeys.forEach(function(key) {
|
|
100
|
-
return !isHotkeyModifier(key) && currentlyPressedKeys["delete"](key.toLowerCase());
|
|
101
|
-
});
|
|
102
|
-
hotkeyArray.forEach(function(hotkey) {
|
|
103
|
-
return currentlyPressedKeys.add(hotkey.toLowerCase());
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
function removeFromCurrentlyPressedKeys(key) {
|
|
107
|
-
var hotkeyArray = Array.isArray(key) ? key : [key];
|
|
108
|
-
if (key === "meta") currentlyPressedKeys.clear();
|
|
109
|
-
else hotkeyArray.forEach(function(hotkey) {
|
|
110
|
-
return currentlyPressedKeys["delete"](hotkey.toLowerCase());
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
function maybePreventDefault(e, hotkey, preventDefault) {
|
|
114
|
-
if (typeof preventDefault === "function" && preventDefault(e, hotkey) || preventDefault === true) e.preventDefault();
|
|
115
|
-
}
|
|
116
|
-
function isHotkeyEnabled(e, hotkey, enabled) {
|
|
117
|
-
if (typeof enabled === "function") return enabled(e, hotkey);
|
|
118
|
-
return enabled === true || enabled === void 0;
|
|
119
|
-
}
|
|
120
|
-
function isKeyboardEventTriggeredByInput(ev) {
|
|
121
|
-
return isHotkeyEnabledOnTag(ev, [
|
|
122
|
-
"input",
|
|
123
|
-
"textarea",
|
|
124
|
-
"select"
|
|
125
|
-
]);
|
|
126
|
-
}
|
|
127
|
-
function isHotkeyEnabledOnTag(event, enabledOnTags) {
|
|
128
|
-
if (enabledOnTags === void 0) enabledOnTags = false;
|
|
129
|
-
var target = event.target, composed = event.composed;
|
|
130
|
-
var targetTagName = null;
|
|
131
|
-
if (isCustomElement(target) && composed) targetTagName = event.composedPath()[0] && event.composedPath()[0].tagName;
|
|
132
|
-
else targetTagName = target && target.tagName;
|
|
133
|
-
if (isReadonlyArray(enabledOnTags)) return Boolean(targetTagName && enabledOnTags && enabledOnTags.some(function(tag) {
|
|
134
|
-
var _targetTagName;
|
|
135
|
-
return tag.toLowerCase() === ((_targetTagName = targetTagName) == null ? void 0 : _targetTagName.toLowerCase());
|
|
136
|
-
}));
|
|
137
|
-
return Boolean(targetTagName && enabledOnTags && enabledOnTags);
|
|
138
|
-
}
|
|
139
|
-
function isCustomElement(element) {
|
|
140
|
-
return !!element.tagName && !element.tagName.startsWith("-") && element.tagName.includes("-");
|
|
141
|
-
}
|
|
142
|
-
function isScopeActive(activeScopes, scopes) {
|
|
143
|
-
if (activeScopes.length === 0 && scopes) {
|
|
144
|
-
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>");
|
|
145
|
-
return true;
|
|
146
|
-
}
|
|
147
|
-
if (!scopes) return true;
|
|
148
|
-
return activeScopes.some(function(scope) {
|
|
149
|
-
return scopes.includes(scope);
|
|
150
|
-
}) || activeScopes.includes("*");
|
|
151
|
-
}
|
|
152
|
-
var isHotkeyMatchingKeyboardEvent = function isHotkeyMatchingKeyboardEvent(e, hotkey, ignoreModifiers) {
|
|
153
|
-
if (ignoreModifiers === void 0) ignoreModifiers = false;
|
|
154
|
-
var alt = hotkey.alt, meta = hotkey.meta, mod = hotkey.mod, shift = hotkey.shift, ctrl = hotkey.ctrl, keys = hotkey.keys;
|
|
155
|
-
var pressedKeyUppercase = e.key, code = e.code, ctrlKey = e.ctrlKey, metaKey = e.metaKey, shiftKey = e.shiftKey, altKey = e.altKey;
|
|
156
|
-
var keyCode = mapKey(code);
|
|
157
|
-
var pressedKey = pressedKeyUppercase.toLowerCase();
|
|
158
|
-
if (!(keys != null && keys.includes(keyCode)) && !(keys != null && keys.includes(pressedKey)) && ![
|
|
159
|
-
"ctrl",
|
|
160
|
-
"control",
|
|
161
|
-
"unknown",
|
|
162
|
-
"meta",
|
|
163
|
-
"alt",
|
|
164
|
-
"shift",
|
|
165
|
-
"os"
|
|
166
|
-
].includes(keyCode)) return false;
|
|
167
|
-
if (!ignoreModifiers) {
|
|
168
|
-
if (alt === !altKey && pressedKey !== "alt") return false;
|
|
169
|
-
if (shift === !shiftKey && pressedKey !== "shift") return false;
|
|
170
|
-
if (mod) {
|
|
171
|
-
if (!metaKey && !ctrlKey) return false;
|
|
172
|
-
} else {
|
|
173
|
-
if (meta === !metaKey && pressedKey !== "meta" && pressedKey !== "os") return false;
|
|
174
|
-
if (ctrl === !ctrlKey && pressedKey !== "ctrl" && pressedKey !== "control") return false;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
if (keys && keys.length === 1 && (keys.includes(pressedKey) || keys.includes(keyCode))) return true;
|
|
178
|
-
else if (keys) return isHotkeyPressed(keys);
|
|
179
|
-
else if (!keys) return true;
|
|
180
|
-
return false;
|
|
181
|
-
};
|
|
182
|
-
var BoundHotkeysProxyProvider = /* @__PURE__ */ createContext(void 0);
|
|
183
|
-
var useBoundHotkeysProxy = function useBoundHotkeysProxy() {
|
|
184
|
-
return useContext(BoundHotkeysProxyProvider);
|
|
185
|
-
};
|
|
186
|
-
function deepEqual(x, y) {
|
|
187
|
-
return x && y && typeof x === "object" && typeof y === "object" ? Object.keys(x).length === Object.keys(y).length && Object.keys(x).reduce(function(isEqual, key) {
|
|
188
|
-
return isEqual && deepEqual(x[key], y[key]);
|
|
189
|
-
}, true) : x === y;
|
|
190
|
-
}
|
|
191
|
-
var HotkeysContext = /* @__PURE__ */ createContext({
|
|
192
|
-
hotkeys: [],
|
|
193
|
-
enabledScopes: [],
|
|
194
|
-
toggleScope: function toggleScope() {},
|
|
195
|
-
enableScope: function enableScope() {},
|
|
196
|
-
disableScope: function disableScope() {}
|
|
197
|
-
});
|
|
198
|
-
var useHotkeysContext = function useHotkeysContext() {
|
|
199
|
-
return useContext(HotkeysContext);
|
|
200
|
-
};
|
|
201
|
-
function useDeepEqualMemo(value) {
|
|
202
|
-
var ref = useRef(void 0);
|
|
203
|
-
if (!deepEqual(ref.current, value)) ref.current = value;
|
|
204
|
-
return ref.current;
|
|
205
|
-
}
|
|
206
|
-
var stopPropagation = function stopPropagation(e) {
|
|
207
|
-
e.stopPropagation();
|
|
208
|
-
e.preventDefault();
|
|
209
|
-
e.stopImmediatePropagation();
|
|
210
|
-
};
|
|
211
|
-
var useSafeLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect;
|
|
212
|
-
function useHotkeys(keys, callback, options, dependencies) {
|
|
213
|
-
var _useState = useState(null), ref = _useState[0], setRef = _useState[1];
|
|
214
|
-
var hasTriggeredRef = useRef(false);
|
|
215
|
-
var _options = !(options instanceof Array) ? options : !(dependencies instanceof Array) ? dependencies : void 0;
|
|
216
|
-
var _keys = isReadonlyArray(keys) ? keys.join(_options == null ? void 0 : _options.splitKey) : keys;
|
|
217
|
-
var _deps = options instanceof Array ? options : dependencies instanceof Array ? dependencies : void 0;
|
|
218
|
-
var memoisedCB = useCallback(callback, _deps != null ? _deps : []);
|
|
219
|
-
var cbRef = useRef(memoisedCB);
|
|
220
|
-
if (_deps) cbRef.current = memoisedCB;
|
|
221
|
-
else cbRef.current = callback;
|
|
222
|
-
var memoisedOptions = useDeepEqualMemo(_options);
|
|
223
|
-
var enabledScopes = useHotkeysContext().enabledScopes;
|
|
224
|
-
var proxy = useBoundHotkeysProxy();
|
|
225
|
-
useSafeLayoutEffect(function() {
|
|
226
|
-
if ((memoisedOptions == null ? void 0 : memoisedOptions.enabled) === false || !isScopeActive(enabledScopes, memoisedOptions == null ? void 0 : memoisedOptions.scopes)) return;
|
|
227
|
-
var listener = function listener(e, isKeyUp) {
|
|
228
|
-
var _e$target;
|
|
229
|
-
if (isKeyUp === void 0) isKeyUp = false;
|
|
230
|
-
if (isKeyboardEventTriggeredByInput(e) && !isHotkeyEnabledOnTag(e, memoisedOptions == null ? void 0 : memoisedOptions.enableOnFormTags)) return;
|
|
231
|
-
if (ref !== null) {
|
|
232
|
-
var rootNode = ref.getRootNode();
|
|
233
|
-
if ((rootNode instanceof Document || rootNode instanceof ShadowRoot) && rootNode.activeElement !== ref && !ref.contains(rootNode.activeElement)) {
|
|
234
|
-
stopPropagation(e);
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
if ((_e$target = e.target) != null && _e$target.isContentEditable && !(memoisedOptions != null && memoisedOptions.enableOnContentEditable)) return;
|
|
239
|
-
parseKeysHookInput(_keys, memoisedOptions == null ? void 0 : memoisedOptions.splitKey).forEach(function(key) {
|
|
240
|
-
var _hotkey$keys;
|
|
241
|
-
var hotkey = parseHotkey(key, memoisedOptions == null ? void 0 : memoisedOptions.combinationKey);
|
|
242
|
-
if (isHotkeyMatchingKeyboardEvent(e, hotkey, memoisedOptions == null ? void 0 : memoisedOptions.ignoreModifiers) || (_hotkey$keys = hotkey.keys) != null && _hotkey$keys.includes("*")) {
|
|
243
|
-
if (memoisedOptions != null && memoisedOptions.ignoreEventWhen != null && memoisedOptions.ignoreEventWhen(e)) return;
|
|
244
|
-
if (isKeyUp && hasTriggeredRef.current) return;
|
|
245
|
-
maybePreventDefault(e, hotkey, memoisedOptions == null ? void 0 : memoisedOptions.preventDefault);
|
|
246
|
-
if (!isHotkeyEnabled(e, hotkey, memoisedOptions == null ? void 0 : memoisedOptions.enabled)) {
|
|
247
|
-
stopPropagation(e);
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
cbRef.current(e, hotkey);
|
|
251
|
-
if (!isKeyUp) hasTriggeredRef.current = true;
|
|
252
|
-
}
|
|
253
|
-
});
|
|
254
|
-
};
|
|
255
|
-
var handleKeyDown = function handleKeyDown(event) {
|
|
256
|
-
if (event.key === void 0) return;
|
|
257
|
-
pushToCurrentlyPressedKeys(mapKey(event.code));
|
|
258
|
-
if ((memoisedOptions == null ? void 0 : memoisedOptions.keydown) === void 0 && (memoisedOptions == null ? void 0 : memoisedOptions.keyup) !== true || memoisedOptions != null && memoisedOptions.keydown) listener(event);
|
|
259
|
-
};
|
|
260
|
-
var handleKeyUp = function handleKeyUp(event) {
|
|
261
|
-
if (event.key === void 0) return;
|
|
262
|
-
removeFromCurrentlyPressedKeys(mapKey(event.code));
|
|
263
|
-
hasTriggeredRef.current = false;
|
|
264
|
-
if (memoisedOptions != null && memoisedOptions.keyup) listener(event, true);
|
|
265
|
-
};
|
|
266
|
-
var domNode = ref || (_options == null ? void 0 : _options.document) || document;
|
|
267
|
-
domNode.addEventListener("keyup", handleKeyUp);
|
|
268
|
-
domNode.addEventListener("keydown", handleKeyDown);
|
|
269
|
-
if (proxy) parseKeysHookInput(_keys, memoisedOptions == null ? void 0 : memoisedOptions.splitKey).forEach(function(key) {
|
|
270
|
-
return proxy.addHotkey(parseHotkey(key, memoisedOptions == null ? void 0 : memoisedOptions.combinationKey, memoisedOptions == null ? void 0 : memoisedOptions.description));
|
|
271
|
-
});
|
|
272
|
-
return function() {
|
|
273
|
-
domNode.removeEventListener("keyup", handleKeyUp);
|
|
274
|
-
domNode.removeEventListener("keydown", handleKeyDown);
|
|
275
|
-
if (proxy) parseKeysHookInput(_keys, memoisedOptions == null ? void 0 : memoisedOptions.splitKey).forEach(function(key) {
|
|
276
|
-
return proxy.removeHotkey(parseHotkey(key, memoisedOptions == null ? void 0 : memoisedOptions.combinationKey, memoisedOptions == null ? void 0 : memoisedOptions.description));
|
|
277
|
-
});
|
|
278
|
-
};
|
|
279
|
-
}, [
|
|
280
|
-
ref,
|
|
281
|
-
_keys,
|
|
282
|
-
memoisedOptions,
|
|
283
|
-
enabledScopes
|
|
284
|
-
]);
|
|
285
|
-
return setRef;
|
|
286
|
-
}
|
|
287
|
-
//#endregion
|
|
288
|
-
export { useHotkeys };
|