@ramstack/alpinegear-hotkey 1.4.5 → 1.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.
@@ -40,7 +40,7 @@ function registerHotkey(target, hotkey, handler, eventName = "keydown", options)
40
40
  const require_trusted = options?.trusted;
41
41
  const once = options?.once;
42
42
  const native_options = options && typeof options === "object"
43
- ? { capture: options.capture, passive: options.passive }
43
+ ? { capture: options.capture, passive: options.passive, signal: options.signal }
44
44
  : options;
45
45
  const unregister = listen(target, eventName, function (e) {
46
46
  if (!require_trusted || e.isTrusted) {
@@ -1 +1 @@
1
- const e={esc:"escape",ins:"insert",del:"delete",up:"arrowup",down:"arrowdown",right:"arrowright",left:"arrowleft",pgup:"pageup",pgdn:"pagedown",break:"pause",scroll:"scrolllock",scrlk:"scrolllock",prtscr:"printscreen",win:"meta",windows:"meta",cmd:"meta",command:"meta",",":"comma",".":"period","/":"slash","\\":"backslash",";":"semicolon","=":"equal","`":"backquote","]":"bracketright","[":"bracketleft"},t=["ctrlKey","altKey","shiftKey","metaKey"];function o(e){r(`Invalid hotkey: '${e}'`)}function r(e){throw new Error(e)}const s=(e,t)=>e.includes(t),n=["capture","passive","once","prevent","stop","trusted","window","document"];function c({directive:c}){c("hotkey",(c,{expression:a,value:i,modifiers:p},{evaluateLater:l,cleanup:u})=>{const d=a?l(a):()=>{},f=s(p,"window")?window:s(p,"document")?document:c;u(((...e)=>(...t)=>{for(const o of e)o&&o(...t)})(...p.filter(e=>!n.includes(e)).flatMap(e=>e.split(",")).map(n=>function(s,n,c,a="keydown",i){const p=function(t){const r=t.replace(/\s+/g,"").toLowerCase().split("+").reduce((r,s)=>(/^(ctrl|alt|shift|meta)$/.test(s=e[s]??s)?r[`${s}Key`]=!0:(s.length||o(t),s=s.toUpperCase(),r.code=/^[A-Z]$/.test(s)?`KEY${s}`:/^[0-9]$/.test(s)?`DIGIT${s}`:s),r),{code:"",ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1});return r.code||o(t),r}(n);"string"==typeof s&&(s=document.querySelector(s)??r(`No element found for selector '${s}'`));const l=i?.trusted,u=i?.once,d=function(e,t,o,r){return e.addEventListener(t,o,r),()=>e.removeEventListener(t,o,r)}(s,a,function(e){l&&!e.isTrusted||e.target?.closest("[data-hotkey-ignore]")||p.code===e.code.toUpperCase()&&t.every(t=>p[t]===e[t])&&(u&&d(),c.call(this,e))},i&&"object"==typeof i?{capture:i.capture,passive:i.passive}:i);return d}(f,n,e=>{s(p,"prevent")&&e.preventDefault(),s(p,"stop")&&e.stopPropagation(),e.hotkey=n,(e=>{d(()=>{},{scope:{$event:e},params:[e]})})(e)},i||"keydown",{capture:s(p,"capture"),passive:s(p,"passive"),once:s(p,"once"),trusted:s(p,"trusted")}))))})}export{c as default,c as hotkey};
1
+ const e={esc:"escape",ins:"insert",del:"delete",up:"arrowup",down:"arrowdown",right:"arrowright",left:"arrowleft",pgup:"pageup",pgdn:"pagedown",break:"pause",scroll:"scrolllock",scrlk:"scrolllock",prtscr:"printscreen",win:"meta",windows:"meta",cmd:"meta",command:"meta",",":"comma",".":"period","/":"slash","\\":"backslash",";":"semicolon","=":"equal","`":"backquote","]":"bracketright","[":"bracketleft"},t=["ctrlKey","altKey","shiftKey","metaKey"];function o(e){r(`Invalid hotkey: '${e}'`)}function r(e){throw new Error(e)}const s=(e,t)=>e.includes(t),n=["capture","passive","once","prevent","stop","trusted","window","document"];function a({directive:a}){a("hotkey",(a,{expression:c,value:i,modifiers:l},{evaluateLater:p,cleanup:u})=>{const d=c?p(c):()=>{},f=s(l,"window")?window:s(l,"document")?document:a;u(((...e)=>(...t)=>{for(const o of e)o&&o(...t)})(...l.filter(e=>!n.includes(e)).flatMap(e=>e.split(",")).map(n=>function(s,n,a,c="keydown",i){const l=function(t){const r=t.replace(/\s+/g,"").toLowerCase().split("+").reduce((r,s)=>(/^(ctrl|alt|shift|meta)$/.test(s=e[s]??s)?r[`${s}Key`]=!0:(s.length||o(t),s=s.toUpperCase(),r.code=/^[A-Z]$/.test(s)?`KEY${s}`:/^[0-9]$/.test(s)?`DIGIT${s}`:s),r),{code:"",ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1});return r.code||o(t),r}(n);"string"==typeof s&&(s=document.querySelector(s)??r(`No element found for selector '${s}'`));const p=i?.trusted,u=i?.once,d=function(e,t,o,r){return e.addEventListener(t,o,r),()=>e.removeEventListener(t,o,r)}(s,c,function(e){p&&!e.isTrusted||e.target?.closest("[data-hotkey-ignore]")||l.code===e.code.toUpperCase()&&t.every(t=>l[t]===e[t])&&(u&&d(),a.call(this,e))},i&&"object"==typeof i?{capture:i.capture,passive:i.passive,signal:i.signal}:i);return d}(f,n,e=>{s(l,"prevent")&&e.preventDefault(),s(l,"stop")&&e.stopPropagation(),e.hotkey=n,(e=>{d(()=>{},{scope:{$event:e},params:[e]})})(e)},i||"keydown",{capture:s(l,"capture"),passive:s(l,"passive"),once:s(l,"once"),trusted:s(l,"trusted")}))))})}export{a as default,a as hotkey};
@@ -56,7 +56,7 @@
56
56
  const require_trusted = options?.trusted;
57
57
  const once = options?.once;
58
58
  const native_options = options && typeof options === "object"
59
- ? { capture: options.capture, passive: options.passive }
59
+ ? { capture: options.capture, passive: options.passive, signal: options.signal }
60
60
  : options;
61
61
  const unregister = listen(target, eventName, function (e) {
62
62
  if (!require_trusted || e.isTrusted) {
@@ -1 +1 @@
1
- !function(){"use strict";const e=(e,t)=>e.includes(t),t={esc:"escape",ins:"insert",del:"delete",up:"arrowup",down:"arrowdown",right:"arrowright",left:"arrowleft",pgup:"pageup",pgdn:"pagedown",break:"pause",scroll:"scrolllock",scrlk:"scrolllock",prtscr:"printscreen",win:"meta",windows:"meta",cmd:"meta",command:"meta",",":"comma",".":"period","/":"slash","\\":"backslash",";":"semicolon","=":"equal","`":"backquote","]":"bracketright","[":"bracketleft"},o=["ctrlKey","altKey","shiftKey","metaKey"];function n(e){r(`Invalid hotkey: '${e}'`)}function r(e){throw new Error(e)}const s=["capture","passive","once","prevent","stop","trusted","window","document"];function c({directive:c}){c("hotkey",(c,{expression:a,value:i,modifiers:p},{evaluateLater:l,cleanup:u})=>{const d=a?l(a):()=>{},f=e(p,"window")?window:e(p,"document")?document:c;u(((...e)=>(...t)=>{for(const o of e)o&&o(...t)})(...p.filter(e=>!s.includes(e)).flatMap(e=>e.split(",")).map(s=>function(e,s,c,a="keydown",i){const p=function(e){const o=e.replace(/\s+/g,"").toLowerCase().split("+").reduce((o,r)=>(/^(ctrl|alt|shift|meta)$/.test(r=t[r]??r)?o[`${r}Key`]=!0:(r.length||n(e),r=r.toUpperCase(),o.code=/^[A-Z]$/.test(r)?`KEY${r}`:/^[0-9]$/.test(r)?`DIGIT${r}`:r),o),{code:"",ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1});return o.code||n(e),o}(s);"string"==typeof e&&(e=document.querySelector(e)??r(`No element found for selector '${e}'`));const l=i?.trusted,u=i?.once,d=function(e,t,o,n){return e.addEventListener(t,o,n),()=>e.removeEventListener(t,o,n)}(e,a,function(e){l&&!e.isTrusted||e.target?.closest("[data-hotkey-ignore]")||p.code===e.code.toUpperCase()&&o.every(t=>p[t]===e[t])&&(u&&d(),c.call(this,e))},i&&"object"==typeof i?{capture:i.capture,passive:i.passive}:i);return d}(f,s,t=>{e(p,"prevent")&&t.preventDefault(),e(p,"stop")&&t.stopPropagation(),t.hotkey=s,(e=>{d(()=>{},{scope:{$event:e},params:[e]})})(t)},i||"keydown",{capture:e(p,"capture"),passive:e(p,"passive"),once:e(p,"once"),trusted:e(p,"trusted")}))))})}document.addEventListener("alpine:init",()=>Alpine.plugin(c),void 0)}();
1
+ !function(){"use strict";const e=(e,t)=>e.includes(t),t={esc:"escape",ins:"insert",del:"delete",up:"arrowup",down:"arrowdown",right:"arrowright",left:"arrowleft",pgup:"pageup",pgdn:"pagedown",break:"pause",scroll:"scrolllock",scrlk:"scrolllock",prtscr:"printscreen",win:"meta",windows:"meta",cmd:"meta",command:"meta",",":"comma",".":"period","/":"slash","\\":"backslash",";":"semicolon","=":"equal","`":"backquote","]":"bracketright","[":"bracketleft"},o=["ctrlKey","altKey","shiftKey","metaKey"];function n(e){r(`Invalid hotkey: '${e}'`)}function r(e){throw new Error(e)}const s=["capture","passive","once","prevent","stop","trusted","window","document"];function c({directive:c}){c("hotkey",(c,{expression:a,value:i,modifiers:l},{evaluateLater:p,cleanup:u})=>{const d=a?p(a):()=>{},f=e(l,"window")?window:e(l,"document")?document:c;u(((...e)=>(...t)=>{for(const o of e)o&&o(...t)})(...l.filter(e=>!s.includes(e)).flatMap(e=>e.split(",")).map(s=>function(e,s,c,a="keydown",i){const l=function(e){const o=e.replace(/\s+/g,"").toLowerCase().split("+").reduce((o,r)=>(/^(ctrl|alt|shift|meta)$/.test(r=t[r]??r)?o[`${r}Key`]=!0:(r.length||n(e),r=r.toUpperCase(),o.code=/^[A-Z]$/.test(r)?`KEY${r}`:/^[0-9]$/.test(r)?`DIGIT${r}`:r),o),{code:"",ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1});return o.code||n(e),o}(s);"string"==typeof e&&(e=document.querySelector(e)??r(`No element found for selector '${e}'`));const p=i?.trusted,u=i?.once,d=function(e,t,o,n){return e.addEventListener(t,o,n),()=>e.removeEventListener(t,o,n)}(e,a,function(e){p&&!e.isTrusted||e.target?.closest("[data-hotkey-ignore]")||l.code===e.code.toUpperCase()&&o.every(t=>l[t]===e[t])&&(u&&d(),c.call(this,e))},i&&"object"==typeof i?{capture:i.capture,passive:i.passive,signal:i.signal}:i);return d}(f,s,t=>{e(l,"prevent")&&t.preventDefault(),e(l,"stop")&&t.stopPropagation(),t.hotkey=s,(e=>{d(()=>{},{scope:{$event:e},params:[e]})})(t)},i||"keydown",{capture:e(l,"capture"),passive:e(l,"passive"),once:e(l,"once"),trusted:e(l,"trusted")}))))})}document.addEventListener("alpine:init",()=>Alpine.plugin(c),void 0)}();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ramstack/alpinegear-hotkey",
3
- "version": "1.4.5",
3
+ "version": "1.5.0",
4
4
  "description": "@ramstack/alpinegear-hotkey provides 'x-hotkey' Alpine.js directive, allowing easily handle keyboard shortcuts.",
5
5
  "author": "Rameel Burhan",
6
6
  "license": "MIT",