vue-global-events
Advanced tools
Comparing version 2.1.1 to 2.2.0
@@ -0,1 +1,7 @@ | ||
# [2.2.0](https://github.com/shentao/vue-global-events/compare/v2.1.1...v2.2.0) (2023-06-29) | ||
### Features | ||
- add global modifiers ([c4847f5](https://github.com/shentao/vue-global-events/commit/c4847f5e4252ff79f1f9973d20c72b51dccf875d)), closes [#19](https://github.com/shentao/vue-global-events/issues/19) | ||
## [2.1.1](https://github.com/shentao/vue-global-events/compare/v2.1.0...v2.1.1) (2022-03-11) | ||
@@ -2,0 +8,0 @@ |
/*! | ||
* vue-global-events v2.1.0 | ||
* (c) 2022 Damian Dulisz, Eduardo San Martin Morote | ||
* vue-global-events v2.1.1 | ||
* (c) 2023 Damian Dulisz, Eduardo San Martin Morote | ||
* @license MIT | ||
@@ -51,2 +51,5 @@ */ | ||
}, | ||
// global event options | ||
stop: Boolean, | ||
prevent: Boolean, | ||
}, | ||
@@ -78,5 +81,9 @@ setup(props, { attrs }) { | ||
const handlers = listeners.map((listener) => (event) => { | ||
isActive.value && | ||
props.filter(event, listener, eventName) && | ||
if (isActive.value && props.filter(event, listener, eventName)) { | ||
if (props.stop) | ||
event.stopPropagation(); | ||
if (props.prevent) | ||
event.preventDefault(); | ||
listener(event); | ||
} | ||
}); | ||
@@ -83,0 +90,0 @@ const options = extractEventOptions(modifiersRaw); |
/*! | ||
* vue-global-events v2.1.0 | ||
* (c) 2022 Damian Dulisz, Eduardo San Martin Morote | ||
* vue-global-events v2.1.1 | ||
* (c) 2023 Damian Dulisz, Eduardo San Martin Morote | ||
* @license MIT | ||
@@ -51,2 +51,5 @@ */ | ||
}, | ||
// global event options | ||
stop: Boolean, | ||
prevent: Boolean, | ||
}, | ||
@@ -75,5 +78,9 @@ setup(props, { attrs }) { | ||
const handlers = listeners.map((listener) => (event) => { | ||
isActive.value && | ||
props.filter(event, listener, eventName) && | ||
if (isActive.value && props.filter(event, listener, eventName)) { | ||
if (props.stop) | ||
event.stopPropagation(); | ||
if (props.prevent) | ||
event.preventDefault(); | ||
listener(event); | ||
} | ||
}); | ||
@@ -80,0 +87,0 @@ const options = extractEventOptions(modifiersRaw); |
/*! | ||
* vue-global-events v2.1.0 | ||
* (c) 2022 Damian Dulisz, Eduardo San Martin Morote | ||
* vue-global-events v2.1.1 | ||
* (c) 2023 Damian Dulisz, Eduardo San Martin Morote | ||
* @license MIT | ||
@@ -47,2 +47,5 @@ */ | ||
}, | ||
// global event options | ||
stop: Boolean, | ||
prevent: Boolean, | ||
}, | ||
@@ -74,5 +77,9 @@ setup(props, { attrs }) { | ||
const handlers = listeners.map((listener) => (event) => { | ||
isActive.value && | ||
props.filter(event, listener, eventName) && | ||
if (isActive.value && props.filter(event, listener, eventName)) { | ||
if (props.stop) | ||
event.stopPropagation(); | ||
if (props.prevent) | ||
event.preventDefault(); | ||
listener(event); | ||
} | ||
}); | ||
@@ -79,0 +86,0 @@ const options = extractEventOptions(modifiersRaw); |
/*! | ||
* vue-global-events v2.1.0 | ||
* (c) 2022 Damian Dulisz, Eduardo San Martin Morote | ||
* vue-global-events v2.1.1 | ||
* (c) 2023 Damian Dulisz, Eduardo San Martin Morote | ||
* @license MIT | ||
@@ -47,2 +47,5 @@ */ | ||
}, | ||
// global event options | ||
stop: Boolean, | ||
prevent: Boolean, | ||
}, | ||
@@ -74,5 +77,9 @@ setup(props, { attrs }) { | ||
const handlers = listeners.map((listener) => (event) => { | ||
isActive.value && | ||
props.filter(event, listener, eventName) && | ||
if (isActive.value && props.filter(event, listener, eventName)) { | ||
if (props.stop) | ||
event.stopPropagation(); | ||
if (props.prevent) | ||
event.preventDefault(); | ||
listener(event); | ||
} | ||
}); | ||
@@ -79,0 +86,0 @@ const options = extractEventOptions(modifiersRaw); |
/*! | ||
* vue-global-events v2.1.0 | ||
* (c) 2022 Damian Dulisz, Eduardo San Martin Morote | ||
* vue-global-events v2.1.1 | ||
* (c) 2023 Damian Dulisz, Eduardo San Martin Morote | ||
* @license MIT | ||
@@ -48,2 +48,5 @@ */ | ||
}, | ||
// global event options | ||
stop: Boolean, | ||
prevent: Boolean, | ||
}, | ||
@@ -75,5 +78,9 @@ setup(props, { attrs }) { | ||
const handlers = listeners.map((listener) => (event) => { | ||
isActive.value && | ||
props.filter(event, listener, eventName) && | ||
if (isActive.value && props.filter(event, listener, eventName)) { | ||
if (props.stop) | ||
event.stopPropagation(); | ||
if (props.prevent) | ||
event.preventDefault(); | ||
listener(event); | ||
} | ||
}); | ||
@@ -80,0 +87,0 @@ const options = extractEventOptions(modifiersRaw); |
/*! | ||
* vue-global-events v2.1.0 | ||
* (c) 2022 Damian Dulisz, Eduardo San Martin Morote | ||
* vue-global-events v2.1.1 | ||
* (c) 2023 Damian Dulisz, Eduardo San Martin Morote | ||
* @license MIT | ||
*/ | ||
var VueGlobalEvents=function(e,t){"use strict";let n;const r=/^on(\w+?)((?:Once|Capture|Passive)*)$/,o=/[OCP]/g;function a(e){if(!e)return;if(null==n?n=/msie|trident/.test(window.navigator.userAgent.toLowerCase()):n)return e.includes("Capture");return e.replace(o,",$&").toLowerCase().slice(1).split(",").reduce((e,t)=>(e[t]=!0,e),{})}const s=t.defineComponent({name:"GlobalEvents",props:{target:{type:String,default:"document"},filter:{type:Function,default:()=>()=>!0}},setup(e,{attrs:n}){let o=Object.create(null);const s=t.ref(!0);return t.onActivated(()=>{s.value=!0}),t.onDeactivated(()=>{s.value=!1}),t.onMounted(()=>{Object.keys(n).filter(e=>e.startsWith("on")).forEach(t=>{const i=n[t],u=Array.isArray(i)?i:[i],l=t.match(r);if(!l)return;let[,c,f]=l;c=c.toLowerCase();const d=u.map(t=>n=>{s.value&&e.filter(n,t,c)&&t(n)}),v=a(f);d.forEach(t=>{window[e.target].addEventListener(c,t,v)}),o[t]=[d,c,v]})}),t.onBeforeUnmount(()=>{for(const t in o){const[n,r,a]=o[t];n.forEach(t=>{window[e.target].removeEventListener(r,t,a)})}o={}}),()=>null}});return e.GlobalEvents=s,e}({},Vue); | ||
var VueGlobalEvents=function(e,t){"use strict";let n;const r=/^on(\w+?)((?:Once|Capture|Passive)*)$/,o=/[OCP]/g;function a(e){if(!e)return;if(null==n?n=/msie|trident/.test(window.navigator.userAgent.toLowerCase()):n)return e.includes("Capture");return e.replace(o,",$&").toLowerCase().slice(1).split(",").reduce((e,t)=>(e[t]=!0,e),{})}const s=t.defineComponent({name:"GlobalEvents",props:{target:{type:String,default:"document"},filter:{type:Function,default:()=>()=>!0},stop:Boolean,prevent:Boolean},setup(e,{attrs:n}){let o=Object.create(null);const s=t.ref(!0);return t.onActivated(()=>{s.value=!0}),t.onDeactivated(()=>{s.value=!1}),t.onMounted(()=>{Object.keys(n).filter(e=>e.startsWith("on")).forEach(t=>{const i=n[t],l=Array.isArray(i)?i:[i],u=t.match(r);if(!u)return;let[,c,f]=u;c=c.toLowerCase();const p=l.map(t=>n=>{s.value&&e.filter(n,t,c)&&(e.stop&&n.stopPropagation(),e.prevent&&n.preventDefault(),t(n))}),v=a(f);p.forEach(t=>{window[e.target].addEventListener(c,t,v)}),o[t]=[p,c,v]})}),t.onBeforeUnmount(()=>{for(const t in o){const[n,r,a]=o[t];n.forEach(t=>{window[e.target].removeEventListener(r,t,a)})}o={}}),()=>null}});return e.GlobalEvents=s,e}({},Vue); |
{ | ||
"name": "vue-global-events", | ||
"version": "2.1.1", | ||
"version": "2.2.0", | ||
"description": "Register global events using vue template shortcuts", | ||
@@ -5,0 +5,0 @@ "main": "dist/vue-global-events.cjs.js", |
@@ -5,2 +5,4 @@ # vue-global-events [![Build Status](https://img.shields.io/circleci/project/shentao/vue-global-events/master.svg)](https://circleci.com/gh/shentao/vue-global-events) [![npm package](https://img.shields.io/npm/v/vue-global-events.svg)](https://www.npmjs.com/package/vue-global-events) | ||
This is the version for Vue 3, if you are looking for the Vue 2 version, [take a look at the `v1` branch](https://github.com/shentao/vue-global-events/tree/v1) | ||
## Sponsors | ||
@@ -7,0 +9,0 @@ |
32460
582
130