This commit is contained in:
2025-09-19 14:25:20 +08:00
parent 269893a435
commit fbf3f77229
24949 changed files with 2839404 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
import type { Ref } from 'vue';
export declare const usePreventGlobal: <E extends keyof DocumentEventMap>(indicator: Ref<boolean>, evt: E, cb: (e: DocumentEventMap[E]) => boolean) => void;

View File

@@ -0,0 +1,24 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var core = require('@vueuse/core');
const usePreventGlobal = (indicator, evt, cb) => {
const prevent = (e) => {
if (cb(e))
e.stopImmediatePropagation();
};
let stop = void 0;
vue.watch(() => indicator.value, (val) => {
if (val) {
stop = core.useEventListener(document, evt, prevent, true);
} else {
stop == null ? void 0 : stop();
}
}, { immediate: true });
};
exports.usePreventGlobal = usePreventGlobal;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":["../../../../../packages/hooks/use-prevent-global/index.ts"],"sourcesContent":["import { watch } from 'vue'\nimport { useEventListener } from '@vueuse/core'\n\nimport type { Ref } from 'vue'\n\nexport const usePreventGlobal = <E extends keyof DocumentEventMap>(\n indicator: Ref<boolean>,\n evt: E,\n cb: (e: DocumentEventMap[E]) => boolean\n) => {\n const prevent = (e: DocumentEventMap[E]) => {\n if (cb(e)) e.stopImmediatePropagation()\n }\n let stop: (() => void) | undefined = undefined\n watch(\n () => indicator.value,\n (val) => {\n if (val) {\n stop = useEventListener(document, evt, prevent, true)\n } else {\n stop?.()\n }\n },\n { immediate: true }\n )\n}\n"],"names":["watch","useEventListener"],"mappings":";;;;;;;AAEY,MAAC,gBAAgB,GAAG,CAAC,SAAS,EAAE,GAAG,EAAE,EAAE,KAAK;AACxD,EAAE,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK;AACzB,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC;AACb,MAAM,CAAC,CAAC,wBAAwB,EAAE,CAAC;AACnC,GAAG,CAAC;AACJ,EAAE,IAAI,IAAI,GAAG,KAAK,CAAC,CAAC;AACpB,EAAEA,SAAK,CAAC,MAAM,SAAS,CAAC,KAAK,EAAE,CAAC,GAAG,KAAK;AACxC,IAAI,IAAI,GAAG,EAAE;AACb,MAAM,IAAI,GAAGC,qBAAgB,CAAC,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;AAC5D,KAAK,MAAM;AACX,MAAM,IAAI,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,IAAI,EAAE,CAAC;AACrC,KAAK;AACL,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAC1B;;;;"}