index.mjs 512 B

123456789101112131415161718
  1. import { useEventListener } from "@vueuse/core";
  2. import { watch } from "vue";
  3. //#region ../../packages/hooks/use-prevent-global/index.ts
  4. const usePreventGlobal = (indicator, evt, cb) => {
  5. const prevent = (e) => {
  6. if (cb(e)) e.stopImmediatePropagation();
  7. };
  8. let stop = void 0;
  9. watch(() => indicator.value, (val) => {
  10. if (val) stop = useEventListener(document, evt, prevent, true);
  11. else stop?.();
  12. }, { immediate: true });
  13. };
  14. //#endregion
  15. export { usePreventGlobal };
  16. //# sourceMappingURL=index.mjs.map