reaxify 0.0.84 → 0.0.85

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 (44) hide show
  1. package/dist/components/Drawer/index.cjs.js +1 -1
  2. package/dist/components/Drawer/index.d.ts +2 -4
  3. package/dist/components/Drawer/index.es.js +16 -21
  4. package/dist/components/Menu/index.cjs.js +1 -1
  5. package/dist/components/Menu/index.d.ts +3 -3
  6. package/dist/components/Menu/index.es.js +71 -77
  7. package/dist/components/Modal/index.cjs.js +1 -1
  8. package/dist/components/Modal/index.d.ts +2 -4
  9. package/dist/components/Modal/index.es.js +36 -41
  10. package/dist/helpers/scrollIntoView.cjs.js +1 -1
  11. package/dist/helpers/scrollIntoView.d.ts +1 -1
  12. package/dist/helpers/scrollIntoView.es.js +4 -3
  13. package/dist/hooks/index.cjs.js +1 -1
  14. package/dist/hooks/index.d.ts +0 -1
  15. package/dist/hooks/index.es.js +6 -8
  16. package/dist/node_modules/@tanstack/hotkeys/dist/constants.cjs.js +1 -0
  17. package/dist/node_modules/@tanstack/hotkeys/dist/constants.es.js +206 -0
  18. package/dist/node_modules/@tanstack/hotkeys/dist/format.cjs.js +1 -0
  19. package/dist/node_modules/@tanstack/hotkeys/dist/format.es.js +10 -0
  20. package/dist/node_modules/@tanstack/hotkeys/dist/hotkey-manager.cjs.js +1 -0
  21. package/dist/node_modules/@tanstack/hotkeys/dist/hotkey-manager.es.js +276 -0
  22. package/dist/node_modules/@tanstack/hotkeys/dist/manager.utils.cjs.js +1 -0
  23. package/dist/node_modules/@tanstack/hotkeys/dist/manager.utils.es.js +48 -0
  24. package/dist/node_modules/@tanstack/hotkeys/dist/match.cjs.js +1 -0
  25. package/dist/node_modules/@tanstack/hotkeys/dist/match.es.js +27 -0
  26. package/dist/node_modules/@tanstack/hotkeys/dist/parse.cjs.js +1 -0
  27. package/dist/node_modules/@tanstack/hotkeys/dist/parse.es.js +72 -0
  28. package/dist/node_modules/@tanstack/react-hotkeys/dist/HotkeysProvider.cjs.js +1 -0
  29. package/dist/node_modules/@tanstack/react-hotkeys/dist/HotkeysProvider.es.js +10 -0
  30. package/dist/node_modules/@tanstack/react-hotkeys/dist/useHotkey.cjs.js +1 -0
  31. package/dist/node_modules/@tanstack/react-hotkeys/dist/useHotkey.es.js +35 -0
  32. package/dist/node_modules/@tanstack/react-hotkeys/dist/utils.cjs.js +1 -0
  33. package/dist/node_modules/@tanstack/react-hotkeys/dist/utils.es.js +7 -0
  34. package/dist/node_modules/@tanstack/store/dist/esm/alien.cjs.js +1 -0
  35. package/dist/node_modules/@tanstack/store/dist/esm/alien.es.js +129 -0
  36. package/dist/node_modules/@tanstack/store/dist/esm/atom.cjs.js +1 -0
  37. package/dist/node_modules/@tanstack/store/dist/esm/atom.es.js +124 -0
  38. package/dist/node_modules/@tanstack/store/dist/esm/store.cjs.js +1 -0
  39. package/dist/node_modules/@tanstack/store/dist/esm/store.es.js +24 -0
  40. package/dist/types/index.d.ts +2 -2
  41. package/package.json +4 -3
  42. package/dist/hooks/useKeyDown.cjs.js +0 -1
  43. package/dist/hooks/useKeyDown.d.ts +0 -6
  44. package/dist/hooks/useKeyDown.es.js +0 -17
@@ -3,6 +3,5 @@ export { default as useCreateRipple } from './useCreateRipple';
3
3
  export { default as useDebounce } from './useDebounce';
4
4
  export { default as useDocumentVisible } from './useDocumentVisible';
5
5
  export { default as useIsOffline } from './useIsOffline';
6
- export { default as useKeyDown } from './useKeyDown';
7
6
  export { default as usePersistedState } from './usePersistedState';
8
7
  export { default as useToggle } from './useToggle';
@@ -1,19 +1,17 @@
1
1
  "use client";
2
2
  import { default as t } from "./useClasses.es.js";
3
- import { default as a } from "./useCreateRipple.es.js";
3
+ import { default as o } from "./useCreateRipple.es.js";
4
4
  import { default as f } from "./useDebounce.es.js";
5
5
  import { default as l } from "./useDocumentVisible.es.js";
6
6
  import { default as d } from "./useIsOffline.es.js";
7
- import { default as x } from "./useKeyDown.es.js";
8
- import { default as n } from "./usePersistedState.es.js";
9
- import { default as D } from "./useToggle.es.js";
7
+ import { default as x } from "./usePersistedState.es.js";
8
+ import { default as n } from "./useToggle.es.js";
10
9
  export {
11
10
  t as useClasses,
12
- a as useCreateRipple,
11
+ o as useCreateRipple,
13
12
  f as useDebounce,
14
13
  l as useDocumentVisible,
15
14
  d as useIsOffline,
16
- x as useKeyDown,
17
- n as usePersistedState,
18
- D as useToggle
15
+ x as usePersistedState,
16
+ n as useToggle
19
17
  };
@@ -0,0 +1 @@
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function a(){var r,o;if(typeof navigator>"u")return"linux";const e=((r=navigator.platform)==null?void 0:r.toLowerCase())??"",t=((o=navigator.userAgent)==null?void 0:o.toLowerCase())??"";return e.includes("mac")||t.includes("mac")?"mac":e.includes("win")||t.includes("win")?"windows":"linux"}const c=["Control","Alt","Shift","Meta"];new Set(c);const u={Control:"Control",Ctrl:"Control",control:"Control",ctrl:"Control",Shift:"Shift",shift:"Shift",Alt:"Alt",Option:"Alt",alt:"Alt",option:"Alt",Command:"Meta",Cmd:"Meta",Meta:"Meta",command:"Meta",cmd:"Meta",meta:"Meta",OS:"Meta",os:"Meta",Win:"Meta",win:"Meta",CommandOrControl:"Mod",Mod:"Mod",commandorcontrol:"Mod",mod:"Mod"};function A(e,t=a()){return e==="Mod"?t==="mac"?"Meta":"Control":e}const i=new Set(["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]),l=new Set(["0","1","2","3","4","5","6","7","8","9"]),s=new Set(["F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12"]),p=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Home","End","PageUp","PageDown"]),w=new Set(["Enter","Escape","Space","Tab","Backspace","Delete"]),E=new Set(["/","[","]","\\","=","-",",",".",";","`"]),d={Backquote:"`",Backslash:"\\",BracketLeft:"[",BracketRight:"]",Comma:",",Equal:"=",Minus:"-",Period:".",Semicolon:";",Slash:"/"};[...i,...l,...s,...p,...w,...E];const n={Esc:"Escape",esc:"Escape",escape:"Escape",Return:"Enter",return:"Enter",enter:"Enter"," ":"Space",space:"Space",Spacebar:"Space",spacebar:"Space",tab:"Tab",backspace:"Backspace",Del:"Delete",del:"Delete",delete:"Delete",Up:"ArrowUp",up:"ArrowUp",arrowup:"ArrowUp",Down:"ArrowDown",down:"ArrowDown",arrowdown:"ArrowDown",Left:"ArrowLeft",left:"ArrowLeft",arrowleft:"ArrowLeft",Right:"ArrowRight",right:"ArrowRight",arrowright:"ArrowRight",home:"Home",end:"End",pageup:"PageUp",pagedown:"PageDown",PgUp:"PageUp",PgDn:"PageDown",pgup:"PageUp",pgdn:"PageDown"};function S(e){return new RegExp("^\\p{Letter}$","u").test(e)}function f(e){if(!e)return"";if(e in n)return n[e];if(S(e)){const r=e.toUpperCase();return r.length===1?r:e}const t=e.toUpperCase();return/^F([1-9]|1[0-2])$/.test(t)?t:e}exports.EDITING_KEYS=w;exports.FUNCTION_KEYS=s;exports.LETTER_KEYS=i;exports.MODIFIER_ALIASES=u;exports.MODIFIER_ORDER=c;exports.NAVIGATION_KEYS=p;exports.NUMBER_KEYS=l;exports.PUNCTUATION_CODE_MAP=d;exports.PUNCTUATION_KEYS=E;exports.detectPlatform=a;exports.isSingleLetterKey=S;exports.normalizeKeyName=f;exports.resolveModifier=A;
@@ -0,0 +1,206 @@
1
+ "use client";
2
+ function a() {
3
+ var r, o;
4
+ if (typeof navigator > "u") return "linux";
5
+ const e = ((r = navigator.platform) == null ? void 0 : r.toLowerCase()) ?? "", t = ((o = navigator.userAgent) == null ? void 0 : o.toLowerCase()) ?? "";
6
+ return e.includes("mac") || t.includes("mac") ? "mac" : e.includes("win") || t.includes("win") ? "windows" : "linux";
7
+ }
8
+ const c = [
9
+ "Control",
10
+ "Alt",
11
+ "Shift",
12
+ "Meta"
13
+ ];
14
+ new Set(c);
15
+ const S = {
16
+ Control: "Control",
17
+ Ctrl: "Control",
18
+ control: "Control",
19
+ ctrl: "Control",
20
+ Shift: "Shift",
21
+ shift: "Shift",
22
+ Alt: "Alt",
23
+ Option: "Alt",
24
+ alt: "Alt",
25
+ option: "Alt",
26
+ Command: "Meta",
27
+ Cmd: "Meta",
28
+ Meta: "Meta",
29
+ command: "Meta",
30
+ cmd: "Meta",
31
+ meta: "Meta",
32
+ OS: "Meta",
33
+ os: "Meta",
34
+ Win: "Meta",
35
+ win: "Meta",
36
+ CommandOrControl: "Mod",
37
+ Mod: "Mod",
38
+ commandorcontrol: "Mod",
39
+ mod: "Mod"
40
+ };
41
+ function d(e, t = a()) {
42
+ return e === "Mod" ? t === "mac" ? "Meta" : "Control" : e;
43
+ }
44
+ const i = /* @__PURE__ */ new Set([
45
+ "A",
46
+ "B",
47
+ "C",
48
+ "D",
49
+ "E",
50
+ "F",
51
+ "G",
52
+ "H",
53
+ "I",
54
+ "J",
55
+ "K",
56
+ "L",
57
+ "M",
58
+ "N",
59
+ "O",
60
+ "P",
61
+ "Q",
62
+ "R",
63
+ "S",
64
+ "T",
65
+ "U",
66
+ "V",
67
+ "W",
68
+ "X",
69
+ "Y",
70
+ "Z"
71
+ ]), p = /* @__PURE__ */ new Set([
72
+ "0",
73
+ "1",
74
+ "2",
75
+ "3",
76
+ "4",
77
+ "5",
78
+ "6",
79
+ "7",
80
+ "8",
81
+ "9"
82
+ ]), s = /* @__PURE__ */ new Set([
83
+ "F1",
84
+ "F2",
85
+ "F3",
86
+ "F4",
87
+ "F5",
88
+ "F6",
89
+ "F7",
90
+ "F8",
91
+ "F9",
92
+ "F10",
93
+ "F11",
94
+ "F12"
95
+ ]), w = /* @__PURE__ */ new Set([
96
+ "ArrowUp",
97
+ "ArrowDown",
98
+ "ArrowLeft",
99
+ "ArrowRight",
100
+ "Home",
101
+ "End",
102
+ "PageUp",
103
+ "PageDown"
104
+ ]), l = /* @__PURE__ */ new Set([
105
+ "Enter",
106
+ "Escape",
107
+ "Space",
108
+ "Tab",
109
+ "Backspace",
110
+ "Delete"
111
+ ]), u = /* @__PURE__ */ new Set([
112
+ "/",
113
+ "[",
114
+ "]",
115
+ "\\",
116
+ "=",
117
+ "-",
118
+ ",",
119
+ ".",
120
+ ";",
121
+ "`"
122
+ ]), f = {
123
+ Backquote: "`",
124
+ Backslash: "\\",
125
+ BracketLeft: "[",
126
+ BracketRight: "]",
127
+ Comma: ",",
128
+ Equal: "=",
129
+ Minus: "-",
130
+ Period: ".",
131
+ Semicolon: ";",
132
+ Slash: "/"
133
+ };
134
+ [
135
+ ...i,
136
+ ...p,
137
+ ...s,
138
+ ...w,
139
+ ...l,
140
+ ...u
141
+ ];
142
+ const n = {
143
+ Esc: "Escape",
144
+ esc: "Escape",
145
+ escape: "Escape",
146
+ Return: "Enter",
147
+ return: "Enter",
148
+ enter: "Enter",
149
+ " ": "Space",
150
+ space: "Space",
151
+ Spacebar: "Space",
152
+ spacebar: "Space",
153
+ tab: "Tab",
154
+ backspace: "Backspace",
155
+ Del: "Delete",
156
+ del: "Delete",
157
+ delete: "Delete",
158
+ Up: "ArrowUp",
159
+ up: "ArrowUp",
160
+ arrowup: "ArrowUp",
161
+ Down: "ArrowDown",
162
+ down: "ArrowDown",
163
+ arrowdown: "ArrowDown",
164
+ Left: "ArrowLeft",
165
+ left: "ArrowLeft",
166
+ arrowleft: "ArrowLeft",
167
+ Right: "ArrowRight",
168
+ right: "ArrowRight",
169
+ arrowright: "ArrowRight",
170
+ home: "Home",
171
+ end: "End",
172
+ pageup: "PageUp",
173
+ pagedown: "PageDown",
174
+ PgUp: "PageUp",
175
+ PgDn: "PageDown",
176
+ pgup: "PageUp",
177
+ pgdn: "PageDown"
178
+ };
179
+ function A(e) {
180
+ return new RegExp("^\\p{Letter}$", "u").test(e);
181
+ }
182
+ function E(e) {
183
+ if (!e) return "";
184
+ if (e in n) return n[e];
185
+ if (A(e)) {
186
+ const r = e.toUpperCase();
187
+ return r.length === 1 ? r : e;
188
+ }
189
+ const t = e.toUpperCase();
190
+ return /^F([1-9]|1[0-2])$/.test(t) ? t : e;
191
+ }
192
+ export {
193
+ l as EDITING_KEYS,
194
+ s as FUNCTION_KEYS,
195
+ i as LETTER_KEYS,
196
+ S as MODIFIER_ALIASES,
197
+ c as MODIFIER_ORDER,
198
+ w as NAVIGATION_KEYS,
199
+ p as NUMBER_KEYS,
200
+ f as PUNCTUATION_CODE_MAP,
201
+ u as PUNCTUATION_KEYS,
202
+ a as detectPlatform,
203
+ A as isSingleLetterKey,
204
+ E as normalizeKeyName,
205
+ d as resolveModifier
206
+ };
@@ -0,0 +1 @@
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./constants.cjs.js");function n(o){const t=[];for(const e of i.MODIFIER_ORDER)o.modifiers.includes(e)&&t.push(e);return t.push(o.key),t.join("+")}exports.formatHotkey=n;
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import { MODIFIER_ORDER as r } from "./constants.es.js";
3
+ function f(i) {
4
+ const o = [];
5
+ for (const t of r) i.modifiers.includes(t) && o.push(t);
6
+ return o.push(i.key), o.join("+");
7
+ }
8
+ export {
9
+ f as formatHotkey
10
+ };
@@ -0,0 +1 @@
1
+ "use client";"use strict";var q=a=>{throw TypeError(a)};var I=(a,t,e)=>t.has(a)||q("Cannot "+e);var o=(a,t,e)=>(I(a,t,"read from private field"),e?e.call(a):t.get(a)),k=(a,t,e)=>t.has(a)?q("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(a):t.set(a,e),v=(a,t,e,r)=>(I(a,t,"write to private field"),r?r.call(a,e):t.set(a,e),e),c=(a,t,e)=>(I(a,t,"access private method"),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("./constants.cjs.js"),L=require("./parse.cjs.js"),G=require("./format.cjs.js"),P=require("./match.cjs.js"),w=require("./manager.utils.cjs.js"),J=require("../../store/dist/esm/store.cjs.js");let Q=0;function D(){return`hotkey_${++Q}`}var g,p,H,d,l,i,R,z,C,K,S,O,A,U,B,x=(g=class{constructor(){k(this,i);k(this,H);k(this,d,new Map);k(this,l,new Map);this.registrations=new J.Store(new Map),v(this,H,F.detectPlatform())}static getInstance(){return o(g,p)||v(g,p,new g),o(g,p)}static resetInstance(){o(g,p)&&(o(g,p).destroy(),v(g,p,null))}register(t,e,r={}){if(typeof document>"u"&&!r.target){let u=e;return{id:D(),unregister:()=>{},get callback(){return u},set callback(y){u=y},setOptions:()=>{},get isActive(){return!1}}}const s=D(),f=r.platform??o(this,H),n=typeof t=="string"?L.parseHotkey(t,f):L.rawHotkeyToParsedHotkey(t,f),b=typeof t=="string"?t:G.formatHotkey(n),h=r.target??document,N=r.conflictBehavior??"warn",E=c(this,i,U).call(this,b,h);E&&w.handleConflict(E.id,b,N,u=>c(this,i,R).call(this,u));const j=r.ignoreInputs??w.getDefaultIgnoreInputs(n),$={id:s,hotkey:b,parsedHotkey:n,callback:e,options:{...w.defaultHotkeyOptions,requireReset:!1,...r,platform:f,ignoreInputs:j},hasFired:!1,triggerCount:0,target:h};this.registrations.setState(u=>new Map(u).set(s,$)),o(this,l).has(h)||o(this,l).set(h,new Set),o(this,l).get(h).add(s),c(this,i,z).call(this,h);const m=this;return{get id(){return s},unregister:()=>{var u;c(u=m,i,R).call(u,s)},get callback(){var u;return((u=m.registrations.state.get(s))==null?void 0:u.callback)??e},set callback(u){const y=m.registrations.state.get(s);y&&(y.callback=u)},setOptions:u=>{m.registrations.setState(y=>{const M=y.get(s);if(M){const T=new Map(y);return T.set(s,{...M,options:{...M.options,...u}}),T}return y})},get isActive(){return m.registrations.state.has(s)}}}triggerRegistration(t){const e=this.registrations.state.get(t);if(!e)return!1;const r=e.parsedHotkey,s=new KeyboardEvent(e.options.eventType??"keydown",{key:r.key,ctrlKey:r.ctrl,shiftKey:r.shift,altKey:r.alt,metaKey:r.meta,bubbles:!0,cancelable:!0});return e.triggerCount++,this.registrations.setState(f=>new Map(f)),e.callback(s,{hotkey:e.hotkey,parsedHotkey:e.parsedHotkey}),!0}getRegistrationCount(){return this.registrations.state.size}isRegistered(t,e){for(const r of this.registrations.state.values())if(r.hotkey===t&&(e===void 0||r.target===e))return!0;return!1}destroy(){for(const t of o(this,d).keys())c(this,i,C).call(this,t);this.registrations.setState(()=>new Map),o(this,d).clear(),o(this,l).clear()}},p=new WeakMap,H=new WeakMap,d=new WeakMap,l=new WeakMap,i=new WeakSet,R=function(t){const e=this.registrations.state.get(t);if(!e)return;const r=e.target;this.registrations.setState(f=>{const n=new Map(f);return n.delete(t),n});const s=o(this,l).get(r);s&&(s.delete(t),s.size===0&&c(this,i,C).call(this,r))},z=function(t){if(typeof document>"u"||o(this,d).has(t))return;const e=c(this,i,O).call(this,t),r=c(this,i,A).call(this,t);t.addEventListener("keydown",e),t.addEventListener("keyup",r),o(this,d).set(t,{keydown:e,keyup:r})},C=function(t){if(typeof document>"u")return;const e=o(this,d).get(t);e&&(t.removeEventListener("keydown",e.keydown),t.removeEventListener("keyup",e.keyup),o(this,d).delete(t),o(this,l).delete(t))},K=function(t,e,r){const s=o(this,l).get(e);if(s)for(const f of s){const n=this.registrations.state.get(f);if(n&&w.isEventForTarget(t,e)&&n.options.enabled&&!(n.options.ignoreInputs!==!1&&w.shouldIgnoreInputEvent(t,e,n.target)))if(r==="keydown"){if(n.options.eventType!=="keydown")continue;P.matchesKeyboardEvent(t,n.parsedHotkey,n.options.platform)&&(n.options.preventDefault&&t.preventDefault(),n.options.stopPropagation&&t.stopPropagation(),(!n.options.requireReset||!n.hasFired)&&(c(this,i,S).call(this,n,t),n.options.requireReset&&(n.hasFired=!0)))}else n.options.eventType==="keyup"&&P.matchesKeyboardEvent(t,n.parsedHotkey,n.options.platform)&&c(this,i,S).call(this,n,t),n.options.requireReset&&n.hasFired&&c(this,i,B).call(this,n,t)&&(n.hasFired=!1)}},S=function(t,e){t.options.preventDefault&&e.preventDefault(),t.options.stopPropagation&&e.stopPropagation(),t.triggerCount++,this.registrations.setState(s=>new Map(s));const r={hotkey:t.hotkey,parsedHotkey:t.parsedHotkey};t.callback(e,r)},O=function(t){return e=>{c(this,i,K).call(this,e,t,"keydown")}},A=function(t){return e=>{c(this,i,K).call(this,e,t,"keyup")}},U=function(t,e){for(const r of this.registrations.state.values())if(r.hotkey===t&&r.target===e)return r;return null},B=function(t,e){const r=t.parsedHotkey,s=F.normalizeKeyName(e.key),f=r.key.length===1?r.key.toUpperCase():r.key;return!!((s.length===1?s.toUpperCase():s)===f||r.ctrl&&s==="Control"||r.shift&&s==="Shift"||r.alt&&s==="Alt"||r.meta&&s==="Meta")},k(g,p,null),g);function V(){return x.getInstance()}exports.HotkeyManager=x;exports.getHotkeyManager=V;
@@ -0,0 +1,276 @@
1
+ "use client";
2
+ var T = (a) => {
3
+ throw TypeError(a);
4
+ };
5
+ var I = (a, t, e) => t.has(a) || T("Cannot " + e);
6
+ var o = (a, t, e) => (I(a, t, "read from private field"), e ? e.call(a) : t.get(a)), k = (a, t, e) => t.has(a) ? T("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(a) : t.set(a, e), H = (a, t, e, r) => (I(a, t, "write to private field"), r ? r.call(a, e) : t.set(a, e), e), f = (a, t, e) => (I(a, t, "access private method"), e);
7
+ import { detectPlatform as B, normalizeKeyName as N } from "./constants.es.js";
8
+ import { parseHotkey as $, rawHotkeyToParsedHotkey as j } from "./parse.es.js";
9
+ import { formatHotkey as G } from "./format.es.js";
10
+ import { matchesKeyboardEvent as F } from "./match.es.js";
11
+ import { handleConflict as J, getDefaultIgnoreInputs as Q, defaultHotkeyOptions as V, isEventForTarget as W, shouldIgnoreInputEvent as X } from "./manager.utils.es.js";
12
+ import { Store as Y } from "../../store/dist/esm/store.es.js";
13
+ let Z = 0;
14
+ function L() {
15
+ return `hotkey_${++Z}`;
16
+ }
17
+ var c, p, w, d, l, i, R, D, M, C, K, P, x, q, z, _ = (c = class {
18
+ constructor() {
19
+ k(this, i);
20
+ k(this, w);
21
+ k(this, d, /* @__PURE__ */ new Map());
22
+ k(this, l, /* @__PURE__ */ new Map());
23
+ this.registrations = new Y(/* @__PURE__ */ new Map()), H(this, w, B());
24
+ }
25
+ /**
26
+ * Gets the singleton instance of HotkeyManager.
27
+ */
28
+ static getInstance() {
29
+ return o(c, p) || H(c, p, new c()), o(c, p);
30
+ }
31
+ /**
32
+ * Resets the singleton instance. Useful for testing.
33
+ */
34
+ static resetInstance() {
35
+ o(c, p) && (o(c, p).destroy(), H(c, p, null));
36
+ }
37
+ /**
38
+ * Registers a hotkey handler and returns a handle for updating the registration.
39
+ *
40
+ * The returned handle allows updating the callback and options without
41
+ * re-registering, which is useful for avoiding stale closures in React.
42
+ *
43
+ * @param hotkey - The hotkey string (e.g., 'Mod+S') or RawHotkey object
44
+ * @param callback - The function to call when the hotkey is pressed
45
+ * @param options - Options for the hotkey behavior
46
+ * @returns A handle for managing the registration
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * const handle = manager.register('Mod+S', callback)
51
+ *
52
+ * // Update callback without re-registering (avoids stale closures)
53
+ * handle.callback = newCallback
54
+ *
55
+ * // Update options
56
+ * handle.setOptions({ enabled: false })
57
+ *
58
+ * // Unregister when done
59
+ * handle.unregister()
60
+ * ```
61
+ */
62
+ register(t, e, r = {}) {
63
+ if (typeof document > "u" && !r.target) {
64
+ let u = e;
65
+ return {
66
+ id: L(),
67
+ unregister: () => {
68
+ },
69
+ get callback() {
70
+ return u;
71
+ },
72
+ set callback(y) {
73
+ u = y;
74
+ },
75
+ setOptions: () => {
76
+ },
77
+ get isActive() {
78
+ return !1;
79
+ }
80
+ };
81
+ }
82
+ const s = L(), g = r.platform ?? o(this, w), n = typeof t == "string" ? $(t, g) : j(t, g), v = typeof t == "string" ? t : G(n), h = r.target ?? document, A = r.conflictBehavior ?? "warn", E = f(this, i, q).call(this, v, h);
83
+ E && J(E.id, v, A, (u) => f(this, i, R).call(this, u));
84
+ const O = r.ignoreInputs ?? Q(n), U = {
85
+ id: s,
86
+ hotkey: v,
87
+ parsedHotkey: n,
88
+ callback: e,
89
+ options: {
90
+ ...V,
91
+ requireReset: !1,
92
+ ...r,
93
+ platform: g,
94
+ ignoreInputs: O
95
+ },
96
+ hasFired: !1,
97
+ triggerCount: 0,
98
+ target: h
99
+ };
100
+ this.registrations.setState((u) => new Map(u).set(s, U)), o(this, l).has(h) || o(this, l).set(h, /* @__PURE__ */ new Set()), o(this, l).get(h).add(s), f(this, i, D).call(this, h);
101
+ const m = this;
102
+ return {
103
+ get id() {
104
+ return s;
105
+ },
106
+ unregister: () => {
107
+ var u;
108
+ f(u = m, i, R).call(u, s);
109
+ },
110
+ get callback() {
111
+ var u;
112
+ return ((u = m.registrations.state.get(s)) == null ? void 0 : u.callback) ?? e;
113
+ },
114
+ set callback(u) {
115
+ const y = m.registrations.state.get(s);
116
+ y && (y.callback = u);
117
+ },
118
+ setOptions: (u) => {
119
+ m.registrations.setState((y) => {
120
+ const b = y.get(s);
121
+ if (b) {
122
+ const S = new Map(y);
123
+ return S.set(s, {
124
+ ...b,
125
+ options: {
126
+ ...b.options,
127
+ ...u
128
+ }
129
+ }), S;
130
+ }
131
+ return y;
132
+ });
133
+ },
134
+ get isActive() {
135
+ return m.registrations.state.has(s);
136
+ }
137
+ };
138
+ }
139
+ /**
140
+ * Triggers a registration's callback programmatically from devtools.
141
+ * Creates a synthetic KeyboardEvent and invokes the callback.
142
+ *
143
+ * @param id - The registration ID to trigger
144
+ * @returns True if the registration was found and triggered
145
+ */
146
+ triggerRegistration(t) {
147
+ const e = this.registrations.state.get(t);
148
+ if (!e) return !1;
149
+ const r = e.parsedHotkey, s = new KeyboardEvent(e.options.eventType ?? "keydown", {
150
+ key: r.key,
151
+ ctrlKey: r.ctrl,
152
+ shiftKey: r.shift,
153
+ altKey: r.alt,
154
+ metaKey: r.meta,
155
+ bubbles: !0,
156
+ cancelable: !0
157
+ });
158
+ return e.triggerCount++, this.registrations.setState((g) => new Map(g)), e.callback(s, {
159
+ hotkey: e.hotkey,
160
+ parsedHotkey: e.parsedHotkey
161
+ }), !0;
162
+ }
163
+ /**
164
+ * Gets the number of registered hotkeys.
165
+ */
166
+ getRegistrationCount() {
167
+ return this.registrations.state.size;
168
+ }
169
+ /**
170
+ * Checks if a specific hotkey is registered.
171
+ *
172
+ * @param hotkey - The hotkey string to check
173
+ * @param target - Optional target element to match (if provided, both hotkey and target must match)
174
+ * @returns True if a matching registration exists
175
+ */
176
+ isRegistered(t, e) {
177
+ for (const r of this.registrations.state.values()) if (r.hotkey === t && (e === void 0 || r.target === e))
178
+ return !0;
179
+ return !1;
180
+ }
181
+ /**
182
+ * Destroys the manager and removes all listeners.
183
+ */
184
+ destroy() {
185
+ for (const t of o(this, d).keys()) f(this, i, M).call(this, t);
186
+ this.registrations.setState(() => /* @__PURE__ */ new Map()), o(this, d).clear(), o(this, l).clear();
187
+ }
188
+ }, p = new WeakMap(), w = new WeakMap(), d = new WeakMap(), l = new WeakMap(), i = new WeakSet(), /**
189
+ * Unregisters a hotkey by its registration ID.
190
+ */
191
+ R = function(t) {
192
+ const e = this.registrations.state.get(t);
193
+ if (!e) return;
194
+ const r = e.target;
195
+ this.registrations.setState((g) => {
196
+ const n = new Map(g);
197
+ return n.delete(t), n;
198
+ });
199
+ const s = o(this, l).get(r);
200
+ s && (s.delete(t), s.size === 0 && f(this, i, M).call(this, r));
201
+ }, /**
202
+ * Ensures event listeners are attached for a specific target.
203
+ */
204
+ D = function(t) {
205
+ if (typeof document > "u" || o(this, d).has(t)) return;
206
+ const e = f(this, i, P).call(this, t), r = f(this, i, x).call(this, t);
207
+ t.addEventListener("keydown", e), t.addEventListener("keyup", r), o(this, d).set(t, {
208
+ keydown: e,
209
+ keyup: r
210
+ });
211
+ }, /**
212
+ * Removes event listeners for a specific target.
213
+ */
214
+ M = function(t) {
215
+ if (typeof document > "u") return;
216
+ const e = o(this, d).get(t);
217
+ e && (t.removeEventListener("keydown", e.keydown), t.removeEventListener("keyup", e.keyup), o(this, d).delete(t), o(this, l).delete(t));
218
+ }, /**
219
+ * Processes keyboard events for a specific target and event type.
220
+ */
221
+ C = function(t, e, r) {
222
+ const s = o(this, l).get(e);
223
+ if (s)
224
+ for (const g of s) {
225
+ const n = this.registrations.state.get(g);
226
+ if (n && W(t, e) && n.options.enabled && !(n.options.ignoreInputs !== !1 && X(t, e, n.target)))
227
+ if (r === "keydown") {
228
+ if (n.options.eventType !== "keydown") continue;
229
+ F(t, n.parsedHotkey, n.options.platform) && (n.options.preventDefault && t.preventDefault(), n.options.stopPropagation && t.stopPropagation(), (!n.options.requireReset || !n.hasFired) && (f(this, i, K).call(this, n, t), n.options.requireReset && (n.hasFired = !0)));
230
+ } else
231
+ n.options.eventType === "keyup" && F(t, n.parsedHotkey, n.options.platform) && f(this, i, K).call(this, n, t), n.options.requireReset && n.hasFired && f(this, i, z).call(this, n, t) && (n.hasFired = !1);
232
+ }
233
+ }, /**
234
+ * Executes a hotkey callback with proper event handling.
235
+ */
236
+ K = function(t, e) {
237
+ t.options.preventDefault && e.preventDefault(), t.options.stopPropagation && e.stopPropagation(), t.triggerCount++, this.registrations.setState((s) => new Map(s));
238
+ const r = {
239
+ hotkey: t.hotkey,
240
+ parsedHotkey: t.parsedHotkey
241
+ };
242
+ t.callback(e, r);
243
+ }, /**
244
+ * Creates a keydown handler for a specific target.
245
+ */
246
+ P = function(t) {
247
+ return (e) => {
248
+ f(this, i, C).call(this, e, t, "keydown");
249
+ };
250
+ }, /**
251
+ * Creates a keyup handler for a specific target.
252
+ */
253
+ x = function(t) {
254
+ return (e) => {
255
+ f(this, i, C).call(this, e, t, "keyup");
256
+ };
257
+ }, /**
258
+ * Finds an existing registration with the same hotkey and target.
259
+ */
260
+ q = function(t, e) {
261
+ for (const r of this.registrations.state.values()) if (r.hotkey === t && r.target === e) return r;
262
+ return null;
263
+ }, /**
264
+ * Determines if a registration should be reset based on the keyup event.
265
+ */
266
+ z = function(t, e) {
267
+ const r = t.parsedHotkey, s = N(e.key), g = r.key.length === 1 ? r.key.toUpperCase() : r.key;
268
+ return !!((s.length === 1 ? s.toUpperCase() : s) === g || r.ctrl && s === "Control" || r.shift && s === "Shift" || r.alt && s === "Alt" || r.meta && s === "Meta");
269
+ }, k(c, p, null), c);
270
+ function at() {
271
+ return _.getInstance();
272
+ }
273
+ export {
274
+ _ as HotkeyManager,
275
+ at as getHotkeyManager
276
+ };
@@ -0,0 +1 @@
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i={preventDefault:!0,stopPropagation:!0,eventType:"keydown",enabled:!0,ignoreInputs:!0,conflictBehavior:"warn"};function l(e){return!(e.ctrl||e.meta||e.key==="Escape")}function o(e){if(!e)return!1;if(e instanceof HTMLInputElement){const n=e.type.toLowerCase();return!(n==="button"||n==="submit"||n==="reset")}return!!(e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e instanceof HTMLElement&&e.isContentEditable)}function c(e){return typeof document>"u"?null:typeof Document<"u"&&e instanceof Document||typeof Node<"u"&&e.nodeType===Node.DOCUMENT_NODE?e.activeElement:typeof HTMLElement<"u"&&e instanceof HTMLElement?e.ownerDocument.activeElement??null:e.document.activeElement??null}function f(e,n,t){const r=c(n);return r&&o(r)&&r!==t||e.composedPath().some(u=>o(u)&&u!==t)?!0:o(e.target)&&e.target!==t}function a(e,n){return n===document||n===window?e.currentTarget===n||e.currentTarget===document.documentElement:n===window?e.currentTarget===window||e.currentTarget===document||e.currentTarget===document.documentElement:!!(n instanceof HTMLElement&&(e.currentTarget===n||e.target instanceof Node&&n.contains(e.target)))}function s(e,n,t,r){if(t!=="allow"){if(t==="warn"){console.warn(`'${n}' is already registered. Multiple handlers will be triggered. Use conflictBehavior: 'replace' to replace the existing handler, or conflictBehavior: 'allow' to suppress this warning.`);return}if(t==="error")throw new Error(`'${n}' is already registered. Use conflictBehavior: 'replace' to replace the existing handler, or conflictBehavior: 'allow' to allow multiple registrations.`);r(e)}}exports.defaultHotkeyOptions=i;exports.getDefaultIgnoreInputs=l;exports.handleConflict=s;exports.isEventForTarget=a;exports.isInputElement=o;exports.shouldIgnoreInputEvent=f;
@@ -0,0 +1,48 @@
1
+ "use client";
2
+ const c = {
3
+ preventDefault: !0,
4
+ stopPropagation: !0,
5
+ eventType: "keydown",
6
+ enabled: !0,
7
+ ignoreInputs: !0,
8
+ conflictBehavior: "warn"
9
+ };
10
+ function f(e) {
11
+ return !(e.ctrl || e.meta || e.key === "Escape");
12
+ }
13
+ function o(e) {
14
+ if (!e) return !1;
15
+ if (e instanceof HTMLInputElement) {
16
+ const n = e.type.toLowerCase();
17
+ return !(n === "button" || n === "submit" || n === "reset");
18
+ }
19
+ return !!(e instanceof HTMLTextAreaElement || e instanceof HTMLSelectElement || e instanceof HTMLElement && e.isContentEditable);
20
+ }
21
+ function i(e) {
22
+ return typeof document > "u" ? null : typeof Document < "u" && e instanceof Document || typeof Node < "u" && e.nodeType === Node.DOCUMENT_NODE ? e.activeElement : typeof HTMLElement < "u" && e instanceof HTMLElement ? e.ownerDocument.activeElement ?? null : e.document.activeElement ?? null;
23
+ }
24
+ function l(e, n, t) {
25
+ const r = i(n);
26
+ return r && o(r) && r !== t || e.composedPath().some((u) => o(u) && u !== t) ? !0 : o(e.target) && e.target !== t;
27
+ }
28
+ function a(e, n) {
29
+ return n === document || n === window ? e.currentTarget === n || e.currentTarget === document.documentElement : n === window ? e.currentTarget === window || e.currentTarget === document || e.currentTarget === document.documentElement : !!(n instanceof HTMLElement && (e.currentTarget === n || e.target instanceof Node && n.contains(e.target)));
30
+ }
31
+ function s(e, n, t, r) {
32
+ if (t !== "allow") {
33
+ if (t === "warn") {
34
+ console.warn(`'${n}' is already registered. Multiple handlers will be triggered. Use conflictBehavior: 'replace' to replace the existing handler, or conflictBehavior: 'allow' to suppress this warning.`);
35
+ return;
36
+ }
37
+ if (t === "error") throw new Error(`'${n}' is already registered. Use conflictBehavior: 'replace' to replace the existing handler, or conflictBehavior: 'allow' to allow multiple registrations.`);
38
+ r(e);
39
+ }
40
+ }
41
+ export {
42
+ c as defaultHotkeyOptions,
43
+ f as getDefaultIgnoreInputs,
44
+ s as handleConflict,
45
+ a as isEventForTarget,
46
+ o as isInputElement,
47
+ l as shouldIgnoreInputEvent
48
+ };
@@ -0,0 +1 @@
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./constants.cjs.js"),l=require("./parse.cjs.js");function n(e,o,c=a.detectPlatform()){const i=typeof o=="string"?l.parseHotkey(o,c):o;if(e.ctrlKey!==i.ctrl||e.shiftKey!==i.shift||e.altKey!==i.alt||e.metaKey!==i.meta)return!1;const t=a.normalizeKeyName(e.key),r=i.key;if(t!=="Dead"&&t.length===1&&r.length===1){if(t.toUpperCase()===r.toUpperCase())return!0;if(a.isSingleLetterKey(t)&&(/^[A-Za-z]$/.test(t)||!e.altKey))return!1}if(e.code&&(t==="Dead"||t.length===1&&r.length===1)){if(e.code.startsWith("Key")){const s=e.code.slice(3);if(s.length===1&&/^[A-Za-z]$/.test(s))return s.toUpperCase()===r.toUpperCase()}if(e.code.startsWith("Digit")){const s=e.code.slice(5);if(s.length===1&&/^[0-9]$/.test(s))return s===r}return e.code in a.PUNCTUATION_CODE_MAP?a.PUNCTUATION_CODE_MAP[e.code]===r:!1}return t===r}exports.matchesKeyboardEvent=n;
@@ -0,0 +1,27 @@
1
+ "use client";
2
+ import { detectPlatform as l, normalizeKeyName as c, isSingleLetterKey as n, PUNCTUATION_CODE_MAP as o } from "./constants.es.js";
3
+ import { parseHotkey as d } from "./parse.es.js";
4
+ function y(e, a, f = l()) {
5
+ const s = typeof a == "string" ? d(a, f) : a;
6
+ if (e.ctrlKey !== s.ctrl || e.shiftKey !== s.shift || e.altKey !== s.alt || e.metaKey !== s.meta) return !1;
7
+ const t = c(e.key), r = s.key;
8
+ if (t !== "Dead" && t.length === 1 && r.length === 1) {
9
+ if (t.toUpperCase() === r.toUpperCase()) return !0;
10
+ if (n(t) && (/^[A-Za-z]$/.test(t) || !e.altKey)) return !1;
11
+ }
12
+ if (e.code && (t === "Dead" || t.length === 1 && r.length === 1)) {
13
+ if (e.code.startsWith("Key")) {
14
+ const i = e.code.slice(3);
15
+ if (i.length === 1 && /^[A-Za-z]$/.test(i)) return i.toUpperCase() === r.toUpperCase();
16
+ }
17
+ if (e.code.startsWith("Digit")) {
18
+ const i = e.code.slice(5);
19
+ if (i.length === 1 && /^[0-9]$/.test(i)) return i === r;
20
+ }
21
+ return e.code in o ? o[e.code] === r : !1;
22
+ }
23
+ return t === r;
24
+ }
25
+ export {
26
+ y as matchesKeyboardEvent
27
+ };
@@ -0,0 +1 @@
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./constants.cjs.js");function f(e,l=o.detectPlatform()){const r=e.split("+"),t=new Set;let i="";for(let n=0;n<r.length;n++){const s=r[n].trim();if(n===r.length-1)i=o.normalizeKeyName(s);else{const a=o.MODIFIER_ALIASES[s]??o.MODIFIER_ALIASES[s.toLowerCase()];if(a){const m=o.resolveModifier(a,l);t.add(m)}else r.length===1&&(i=o.normalizeKeyName(s))}}return!i&&r.length>0&&(i=o.normalizeKeyName(r[r.length-1].trim())),{key:i,ctrl:t.has("Control"),shift:t.has("Shift"),alt:t.has("Alt"),meta:t.has("Meta"),modifiers:o.MODIFIER_ORDER.filter(n=>t.has(n))}}function u(e,l=o.detectPlatform()){let r=e.ctrl??!1;const t=e.shift??!1,i=e.alt??!1;let n=e.meta??!1;e.mod&&(o.resolveModifier("Mod",l)==="Control"?r=!0:n=!0);const s=o.MODIFIER_ORDER.filter(a=>{switch(a){case"Control":return r;case"Shift":return t;case"Alt":return i;case"Meta":return n;default:return!1}});return{key:e.key,ctrl:r,shift:t,alt:i,meta:n,modifiers:s}}function h(e,l){const r=l==="mac"?e.meta&&!e.ctrl:e.ctrl&&!e.meta,t=[];if(r)t.push("Mod"),e.alt&&t.push("Alt"),e.shift&&t.push("Shift");else for(const i of o.MODIFIER_ORDER)e.modifiers.includes(i)&&t.push(i);return t.push(o.normalizeKeyName(e.key)),t.join("+")}function c(e,l=o.detectPlatform()){return h(f(e,l),l)}function y(e,l=o.detectPlatform()){return c(e,l)}exports.normalizeHotkey=c;exports.normalizeRegisterableHotkey=y;exports.parseHotkey=f;exports.rawHotkeyToParsedHotkey=u;