@ramstack/alpinegear-hotkey 1.1.0-preview.6 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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:".",quote:'"',singlequote:"'",colon:":",semicolon:";",plus:"+",minus:"-",tilde:"~",equal:"=",slash:"/"},t=["ctrlKey","altKey","shiftKey","metaKey"];function o(e){r(`Invalid hotkey: '${e}'`)}function r(e){throw new Error(e)}const n=(e,t)=>e.includes(t),s=["capture","passive","once","prevent","stop","trusted","window","document"];function c({directive:c}){c("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:".",quote:'"',singlequote:"'",colon:":",semicolon:";",plus:"+",minus:"-",tilde:"~",equal:"=",slash:"/"},t=["ctrlKey","altKey","shiftKey","metaKey"];function o(e){r(`Invalid hotkey: '${e}'`)}function r(e){throw new Error(e)}const n=(e,t)=>e.includes(t),s=["capture","passive","once","prevent","stop","trusted","window","document"];function c({directive:c}){c("hotkey",(c,{expression:a,value:i,modifiers:l},{evaluateLater:u,cleanup:p})=>{const d=a?u(a):()=>{},m=n(l,"window")?window:n(l,"document")?document:c;p(((...e)=>(...t)=>{for(const o of e)o&&o(...t)})(...l.filter(e=>!s.includes(e)).flatMap(e=>e.split(",")).map(s=>function(n,s,c,a="keydown",i){const l=function(t){const r=t.replace(/\s+/g,"").toLowerCase().split("+").reduce((r,n)=>{switch(n=e[n]??n){case"ctrl":case"alt":case"shift":case"meta":r[`${n}Key`]=!0;break;default:n.length||o(t),n=n.toUpperCase(),r.code=1!==n.length||"A">n||n>"Z"?n:`KEY${n}`}return r},{code:"",ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1});return r.code||o(t),r}(s);return"string"==typeof n&&(n=document.querySelector(n)??r(`No element found for selector '${n}'`)),function(e,t,o,r){return e.addEventListener(t,o,r),()=>e.removeEventListener(t,o,r)}(n,a,function(e){i?.trusted&&!e.isTrusted||e.target?.closest("[data-hotkey-ignore]")||l.code===e.code.toUpperCase()&&t.every(t=>l[t]===e[t])&&c.call(this,e)},i)}(m,s,e=>{n(l,"prevent")&&e.preventDefault(),n(l,"stop")&&e.stopPropogation(),e.hotkey=s,(e=>{d(()=>{},{scope:{$event:e},params:[e]})})(e)},i||"keydown",{capture:n(l,"capture"),passive:n(l,"passive"),once:n(l,"once"),trusted:n(l,"trusted")}))))})}export{c as hotkey};
|
package/alpinegear-hotkey.min.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
!function(){"use strict";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:".",quote:'"',singlequote:"'",colon:":",semicolon:";",plus:"+",minus:"-",tilde:"~",equal:"=",slash:"/"},t=["ctrlKey","altKey","shiftKey","metaKey"];function o(e){n(`Invalid hotkey: '${e}'`)}function n(e){throw new Error(e)}const r=(e,t)=>e.includes(t),s=["capture","passive","once","prevent","stop","trusted","window","document"];function c({directive:c}){c("hotkey",(
|
1
|
+
!function(){"use strict";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:".",quote:'"',singlequote:"'",colon:":",semicolon:";",plus:"+",minus:"-",tilde:"~",equal:"=",slash:"/"},t=["ctrlKey","altKey","shiftKey","metaKey"];function o(e){n(`Invalid hotkey: '${e}'`)}function n(e){throw new Error(e)}const r=(e,t)=>e.includes(t),s=["capture","passive","once","prevent","stop","trusted","window","document"];function c({directive:c}){c("hotkey",(c,{expression:a,value:i,modifiers:l},{evaluateLater:u,cleanup:d})=>{const p=a?u(a):()=>{},m=r(l,"window")?window:r(l,"document")?document:c;d(((...e)=>(...t)=>{for(const o of e)o&&o(...t)})(...l.filter(e=>!s.includes(e)).flatMap(e=>e.split(",")).map(s=>function(r,s,c,a="keydown",i){const l=function(t){const n=t.replace(/\s+/g,"").toLowerCase().split("+").reduce((n,r)=>{switch(r=e[r]??r){case"ctrl":case"alt":case"shift":case"meta":n[`${r}Key`]=!0;break;default:r.length||o(t),r=r.toUpperCase(),n.code=1!==r.length||"A">r||r>"Z"?r:`KEY${r}`}return n},{code:"",ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1});return n.code||o(t),n}(s);return"string"==typeof r&&(r=document.querySelector(r)??n(`No element found for selector '${r}'`)),function(e,t,o,n){return e.addEventListener(t,o,n),()=>e.removeEventListener(t,o,n)}(r,a,function(e){i?.trusted&&!e.isTrusted||e.target?.closest("[data-hotkey-ignore]")||l.code===e.code.toUpperCase()&&t.every(t=>l[t]===e[t])&&c.call(this,e)},i)}(m,s,e=>{r(l,"prevent")&&e.preventDefault(),r(l,"stop")&&e.stopPropogation(),e.hotkey=s,(e=>{p(()=>{},{scope:{$event:e},params:[e]})})(e)},i||"keydown",{capture:r(l,"capture"),passive:r(l,"passive"),once:r(l,"once"),trusted:r(l,"trusted")}))))})}document.addEventListener("alpine:init",()=>{Alpine.plugin(c)})}();
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ramstack/alpinegear-hotkey",
|
3
|
-
"version": "1.1.
|
3
|
+
"version": "1.1.1",
|
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",
|