index.mjs 532 B

123456789101112131415161718192021222324
  1. import { watch } from 'vue';
  2. import { useEventListener } from '@vueuse/core';
  3. const usePreventGlobal = (indicator, evt, cb) => {
  4. const prevent = (e) => {
  5. if (cb(e))
  6. e.stopImmediatePropagation();
  7. };
  8. let stop = void 0;
  9. watch(
  10. () => indicator.value,
  11. (val) => {
  12. if (val) {
  13. stop = useEventListener(document, evt, prevent, true);
  14. } else {
  15. stop == null ? void 0 : stop();
  16. }
  17. },
  18. { immediate: true }
  19. );
  20. };
  21. export { usePreventGlobal };
  22. //# sourceMappingURL=index.mjs.map