@vueuse/components 7.7.1 → 8.0.0

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.
package/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { defineComponent, ref, h, unref, watch, computed, reactive, shallowRef, toRef, toRefs } from 'vue-demi';
2
- import { onClickOutside as onClickOutside$1, unrefElement as unrefElement$1, useEventListener as useEventListener$1, useActiveElement, useBattery, useBrowserLocation, useDark, useDeviceMotion, useDeviceOrientation, useDevicePixelRatio, useDevicesList, useDocumentVisibility, useStorage as useStorage$1, isClient as isClient$1, useDraggable, useElementBounding, useElementSize, useElementVisibility, useEyeDropper, useFullscreen, useGeolocation, useIdle, useMouse, useMouseInElement, useMousePressed, useNetwork, useNow, useOffsetPagination, useOnline, usePageLeave, usePointer, usePreferredColorScheme, usePreferredDark as usePreferredDark$1, usePreferredLanguages, useTimeAgo, useTimestamp, useVirtualList, useWindowFocus, useWindowSize } from '@vueuse/core';
3
- import { isClient, isString, noop, tryOnScopeDispose, watchWithFilter, tryOnMounted, useToggle, useDebounceFn } from '@vueuse/shared';
2
+ import { onClickOutside as onClickOutside$1, unrefElement as unrefElement$1, useEventListener as useEventListener$1, useActiveElement, useBattery, useBrowserLocation, useDark, useDeviceMotion, useDeviceOrientation, useDevicePixelRatio, useDevicesList, useDocumentVisibility, useStorage as useStorage$1, isClient as isClient$1, useDraggable, useElementBounding, useElementSize as useElementSize$1, useElementVisibility, useEyeDropper, useFullscreen, useGeolocation, useIdle, useMouse, useMouseInElement, useMousePressed, useNetwork, useNow, useOffsetPagination, useOnline, usePageLeave, usePointer, usePreferredColorScheme, usePreferredDark as usePreferredDark$1, usePreferredLanguages, useTimeAgo, useTimestamp, useVirtualList, useWindowFocus, useWindowSize } from '@vueuse/core';
3
+ import { isClient, isString, noop, tryOnScopeDispose, watchWithFilter, tryOnMounted, useToggle, useDebounceFn, useThrottleFn } from '@vueuse/shared';
4
4
 
5
5
  const OnClickOutside = defineComponent({
6
6
  name: "OnClickOutside",
@@ -88,8 +88,70 @@ function onClickOutside(target, handler, options = {}) {
88
88
  return stop;
89
89
  }
90
90
 
91
- const VOnClickOutside = (el, binding) => {
92
- onClickOutside(el, binding.value);
91
+ const handler = () => {
92
+ let stop = null;
93
+ return (el, binding) => {
94
+ if (stop) {
95
+ stop();
96
+ stop = onClickOutside(el, binding.value);
97
+ return;
98
+ }
99
+ stop = onClickOutside(el, binding.value);
100
+ };
101
+ };
102
+ const vOnClickOutside = handler();
103
+
104
+ const createKeyPredicate = (keyFilter) => {
105
+ if (typeof keyFilter === "function")
106
+ return keyFilter;
107
+ else if (typeof keyFilter === "string")
108
+ return (event) => event.key === keyFilter;
109
+ else if (Array.isArray(keyFilter))
110
+ return (event) => keyFilter.includes(event.key);
111
+ else if (keyFilter)
112
+ return () => true;
113
+ else
114
+ return () => false;
115
+ };
116
+ function onKeyStroke(key, handler, options = {}) {
117
+ const { target = defaultWindow, eventName = "keydown", passive = false } = options;
118
+ const predicate = createKeyPredicate(key);
119
+ const listener = (e) => {
120
+ if (predicate(e))
121
+ handler(e);
122
+ };
123
+ return useEventListener(target, eventName, listener, passive);
124
+ }
125
+
126
+ var __defProp$b = Object.defineProperty;
127
+ var __getOwnPropSymbols$c = Object.getOwnPropertySymbols;
128
+ var __hasOwnProp$c = Object.prototype.hasOwnProperty;
129
+ var __propIsEnum$c = Object.prototype.propertyIsEnumerable;
130
+ var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
131
+ var __spreadValues$b = (a, b) => {
132
+ for (var prop in b || (b = {}))
133
+ if (__hasOwnProp$c.call(b, prop))
134
+ __defNormalProp$b(a, prop, b[prop]);
135
+ if (__getOwnPropSymbols$c)
136
+ for (var prop of __getOwnPropSymbols$c(b)) {
137
+ if (__propIsEnum$c.call(b, prop))
138
+ __defNormalProp$b(a, prop, b[prop]);
139
+ }
140
+ return a;
141
+ };
142
+ const vOnKeyStroke = (el, binding) => {
143
+ var _a, _b;
144
+ const keys = (_b = (_a = binding.arg) == null ? void 0 : _a.split(",")) != null ? _b : [];
145
+ if (typeof binding.value === "function") {
146
+ onKeyStroke(keys, binding.value, {
147
+ target: el
148
+ });
149
+ } else {
150
+ const [handler, options] = binding.value;
151
+ onKeyStroke(keys, handler, __spreadValues$b({
152
+ target: el
153
+ }, options));
154
+ }
93
155
  };
94
156
 
95
157
  const DEFAULT_DELAY = 500;
@@ -128,11 +190,11 @@ const OnLongPress = defineComponent({
128
190
  }
129
191
  });
130
192
 
131
- const VOnLongPress = (el, binding) => {
193
+ const vOnLongPress = (el, binding) => {
132
194
  if (typeof binding.value === "function")
133
195
  onLongPress(el, binding.value);
134
196
  else
135
- onLongPress(el, binding.value.handler, binding.value.options);
197
+ onLongPress(el, ...binding.value);
136
198
  };
137
199
 
138
200
  const UseActiveElement = defineComponent({
@@ -313,19 +375,19 @@ function usePreferredDark(options) {
313
375
  return useMediaQuery("(prefers-color-scheme: dark)", options);
314
376
  }
315
377
 
316
- var __defProp$8 = Object.defineProperty;
317
- var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
318
- var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
319
- var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
320
- var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
321
- var __spreadValues$8 = (a, b) => {
378
+ var __defProp$a = Object.defineProperty;
379
+ var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
380
+ var __hasOwnProp$b = Object.prototype.hasOwnProperty;
381
+ var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
382
+ var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
383
+ var __spreadValues$a = (a, b) => {
322
384
  for (var prop in b || (b = {}))
323
- if (__hasOwnProp$8.call(b, prop))
324
- __defNormalProp$8(a, prop, b[prop]);
325
- if (__getOwnPropSymbols$8)
326
- for (var prop of __getOwnPropSymbols$8(b)) {
327
- if (__propIsEnum$8.call(b, prop))
328
- __defNormalProp$8(a, prop, b[prop]);
385
+ if (__hasOwnProp$b.call(b, prop))
386
+ __defNormalProp$a(a, prop, b[prop]);
387
+ if (__getOwnPropSymbols$b)
388
+ for (var prop of __getOwnPropSymbols$b(b)) {
389
+ if (__propIsEnum$b.call(b, prop))
390
+ __defNormalProp$a(a, prop, b[prop]);
329
391
  }
330
392
  return a;
331
393
  };
@@ -339,7 +401,7 @@ function useColorMode(options = {}) {
339
401
  listenToStorageChanges = true,
340
402
  storageRef
341
403
  } = options;
342
- const modes = __spreadValues$8({
404
+ const modes = __spreadValues$a({
343
405
  auto: "",
344
406
  light: "light",
345
407
  dark: "dark"
@@ -477,25 +539,25 @@ const UseDocumentVisibility = defineComponent({
477
539
  }
478
540
  });
479
541
 
480
- var __defProp$7 = Object.defineProperty;
481
- var __defProps$6 = Object.defineProperties;
482
- var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
483
- var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
484
- var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
485
- var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
486
- var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
487
- var __spreadValues$7 = (a, b) => {
542
+ var __defProp$9 = Object.defineProperty;
543
+ var __defProps$8 = Object.defineProperties;
544
+ var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
545
+ var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
546
+ var __hasOwnProp$a = Object.prototype.hasOwnProperty;
547
+ var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
548
+ var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
549
+ var __spreadValues$9 = (a, b) => {
488
550
  for (var prop in b || (b = {}))
489
- if (__hasOwnProp$7.call(b, prop))
490
- __defNormalProp$7(a, prop, b[prop]);
491
- if (__getOwnPropSymbols$7)
492
- for (var prop of __getOwnPropSymbols$7(b)) {
493
- if (__propIsEnum$7.call(b, prop))
494
- __defNormalProp$7(a, prop, b[prop]);
551
+ if (__hasOwnProp$a.call(b, prop))
552
+ __defNormalProp$9(a, prop, b[prop]);
553
+ if (__getOwnPropSymbols$a)
554
+ for (var prop of __getOwnPropSymbols$a(b)) {
555
+ if (__propIsEnum$a.call(b, prop))
556
+ __defNormalProp$9(a, prop, b[prop]);
495
557
  }
496
558
  return a;
497
559
  };
498
- var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
560
+ var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
499
561
  const UseDraggable = defineComponent({
500
562
  name: "UseDraggable",
501
563
  props: [
@@ -510,7 +572,7 @@ const UseDraggable = defineComponent({
510
572
  setup(props, { slots }) {
511
573
  const target = ref();
512
574
  const initialValue = props.storageKey ? useStorage$1(props.storageKey, unref(props.initialValue) || { x: 0, y: 0 }, isClient$1 ? props.storageType === "session" ? sessionStorage : localStorage : void 0) : props.initialValue || { x: 0, y: 0 };
513
- const data = reactive(useDraggable(target, __spreadProps$6(__spreadValues$7({}, props), {
575
+ const data = reactive(useDraggable(target, __spreadProps$8(__spreadValues$9({}, props), {
514
576
  initialValue
515
577
  })));
516
578
  return () => {
@@ -533,12 +595,26 @@ const UseElementBounding = defineComponent({
533
595
  }
534
596
  });
535
597
 
598
+ function useElementHover(el) {
599
+ const isHovered = ref(false);
600
+ useEventListener(el, "mouseenter", () => isHovered.value = true);
601
+ useEventListener(el, "mouseleave", () => isHovered.value = false);
602
+ return isHovered;
603
+ }
604
+
605
+ const vElementHover = (el, binding) => {
606
+ if (typeof binding.value === "function") {
607
+ const isHovered = useElementHover(el);
608
+ watch(isHovered, (v) => binding.value(v));
609
+ }
610
+ };
611
+
536
612
  const UseElementSize = defineComponent({
537
613
  name: "UseElementSize",
538
614
  props: ["width", "height", "box"],
539
615
  setup(props, { slots }) {
540
616
  const target = ref();
541
- const data = reactive(useElementSize(target, { width: props.width, height: props.height }, { box: props.box }));
617
+ const data = reactive(useElementSize$1(target, { width: props.width, height: props.height }, { box: props.box }));
542
618
  return () => {
543
619
  if (slots.default)
544
620
  return h(props.as || "div", { ref: target }, slots.default(data));
@@ -546,6 +622,74 @@ const UseElementSize = defineComponent({
546
622
  }
547
623
  });
548
624
 
625
+ var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
626
+ var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
627
+ var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
628
+ var __objRest = (source, exclude) => {
629
+ var target = {};
630
+ for (var prop in source)
631
+ if (__hasOwnProp$9.call(source, prop) && exclude.indexOf(prop) < 0)
632
+ target[prop] = source[prop];
633
+ if (source != null && __getOwnPropSymbols$9)
634
+ for (var prop of __getOwnPropSymbols$9(source)) {
635
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$9.call(source, prop))
636
+ target[prop] = source[prop];
637
+ }
638
+ return target;
639
+ };
640
+ function useResizeObserver(target, callback, options = {}) {
641
+ const _a = options, { window = defaultWindow } = _a, observerOptions = __objRest(_a, ["window"]);
642
+ let observer;
643
+ const isSupported = window && "ResizeObserver" in window;
644
+ const cleanup = () => {
645
+ if (observer) {
646
+ observer.disconnect();
647
+ observer = void 0;
648
+ }
649
+ };
650
+ const stopWatch = watch(() => unrefElement(target), (el) => {
651
+ cleanup();
652
+ if (isSupported && window && el) {
653
+ observer = new window.ResizeObserver(callback);
654
+ observer.observe(el, observerOptions);
655
+ }
656
+ }, { immediate: true, flush: "post" });
657
+ const stop = () => {
658
+ cleanup();
659
+ stopWatch();
660
+ };
661
+ tryOnScopeDispose(stop);
662
+ return {
663
+ isSupported,
664
+ stop
665
+ };
666
+ }
667
+
668
+ function useElementSize(target, initialSize = { width: 0, height: 0 }, options = {}) {
669
+ const width = ref(initialSize.width);
670
+ const height = ref(initialSize.height);
671
+ useResizeObserver(target, ([entry]) => {
672
+ width.value = entry.contentRect.width;
673
+ height.value = entry.contentRect.height;
674
+ }, options);
675
+ watch(() => unrefElement(target), (ele) => {
676
+ width.value = ele ? initialSize.width : 0;
677
+ height.value = ele ? initialSize.height : 0;
678
+ });
679
+ return {
680
+ width,
681
+ height
682
+ };
683
+ }
684
+
685
+ const vElementSize = (el, binding) => {
686
+ var _a;
687
+ const handler = typeof binding.value === "function" ? binding.value : (_a = binding.value) == null ? void 0 : _a[0];
688
+ const options = typeof binding.value === "function" ? [] : binding.value.slice(1);
689
+ const { width, height } = useElementSize(el, ...options);
690
+ watch([width, height], ([width2, height2]) => handler({ width: width2, height: height2 }));
691
+ };
692
+
549
693
  const UseElementVisibility = defineComponent({
550
694
  name: "UseElementVisibility",
551
695
  props: ["as"],
@@ -612,6 +756,160 @@ const UseIdle = defineComponent({
612
756
  }
613
757
  });
614
758
 
759
+ function useScroll(element, options = {}) {
760
+ const {
761
+ throttle = 0,
762
+ idle = 200,
763
+ onStop = noop,
764
+ onScroll = noop,
765
+ offset = {
766
+ left: 0,
767
+ right: 0,
768
+ top: 0,
769
+ bottom: 0
770
+ },
771
+ eventListenerOptions = {
772
+ capture: false,
773
+ passive: true
774
+ }
775
+ } = options;
776
+ const x = ref(0);
777
+ const y = ref(0);
778
+ const isScrolling = ref(false);
779
+ const arrivedState = reactive({
780
+ left: true,
781
+ right: false,
782
+ top: true,
783
+ bottom: false
784
+ });
785
+ const directions = reactive({
786
+ left: false,
787
+ right: false,
788
+ top: false,
789
+ bottom: false
790
+ });
791
+ if (element) {
792
+ const onScrollEnd = useDebounceFn((e) => {
793
+ isScrolling.value = false;
794
+ directions.left = false;
795
+ directions.right = false;
796
+ directions.top = false;
797
+ directions.bottom = false;
798
+ onStop(e);
799
+ }, throttle + idle);
800
+ const onScrollHandler = (e) => {
801
+ const eventTarget = e.target === document ? e.target.documentElement : e.target;
802
+ const scrollLeft = eventTarget.scrollLeft;
803
+ directions.left = scrollLeft < x.value;
804
+ directions.right = scrollLeft > x.value;
805
+ arrivedState.left = scrollLeft <= 0 + (offset.left || 0);
806
+ arrivedState.right = scrollLeft + eventTarget.clientWidth >= eventTarget.scrollWidth - (offset.right || 0);
807
+ x.value = scrollLeft;
808
+ const scrollTop = eventTarget.scrollTop;
809
+ directions.top = scrollTop < y.value;
810
+ directions.bottom = scrollTop > y.value;
811
+ arrivedState.top = scrollTop <= 0 + (offset.top || 0);
812
+ arrivedState.bottom = scrollTop + eventTarget.clientHeight >= eventTarget.scrollHeight - (offset.bottom || 0);
813
+ y.value = scrollTop;
814
+ isScrolling.value = true;
815
+ onScrollEnd(e);
816
+ onScroll(e);
817
+ };
818
+ useEventListener(element, "scroll", throttle ? useThrottleFn(onScrollHandler, throttle) : onScrollHandler, eventListenerOptions);
819
+ }
820
+ return {
821
+ x,
822
+ y,
823
+ isScrolling,
824
+ arrivedState,
825
+ directions
826
+ };
827
+ }
828
+
829
+ var __defProp$8 = Object.defineProperty;
830
+ var __defProps$7 = Object.defineProperties;
831
+ var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
832
+ var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
833
+ var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
834
+ var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
835
+ var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
836
+ var __spreadValues$8 = (a, b) => {
837
+ for (var prop in b || (b = {}))
838
+ if (__hasOwnProp$8.call(b, prop))
839
+ __defNormalProp$8(a, prop, b[prop]);
840
+ if (__getOwnPropSymbols$8)
841
+ for (var prop of __getOwnPropSymbols$8(b)) {
842
+ if (__propIsEnum$8.call(b, prop))
843
+ __defNormalProp$8(a, prop, b[prop]);
844
+ }
845
+ return a;
846
+ };
847
+ var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
848
+ function useInfiniteScroll(element, onLoadMore, options = {}) {
849
+ var _a;
850
+ const state = reactive(useScroll(element, __spreadProps$7(__spreadValues$8({}, options), {
851
+ offset: __spreadValues$8({
852
+ bottom: (_a = options.distance) != null ? _a : 0
853
+ }, options.offset)
854
+ })));
855
+ watch(() => state.arrivedState.bottom, (v) => {
856
+ if (v)
857
+ onLoadMore(state);
858
+ });
859
+ }
860
+
861
+ const vInfiniteScroll = (el, binding) => {
862
+ if (typeof binding.value === "function")
863
+ useInfiniteScroll(el, binding.value);
864
+ else
865
+ useInfiniteScroll(el, ...binding.value);
866
+ };
867
+
868
+ function useIntersectionObserver(target, callback, options = {}) {
869
+ const {
870
+ root,
871
+ rootMargin = "0px",
872
+ threshold = 0.1,
873
+ window = defaultWindow
874
+ } = options;
875
+ const isSupported = window && "IntersectionObserver" in window;
876
+ let cleanup = noop;
877
+ const stopWatch = isSupported ? watch(() => ({
878
+ el: unrefElement(target),
879
+ root: unrefElement(root)
880
+ }), ({ el, root: root2 }) => {
881
+ cleanup();
882
+ if (!el)
883
+ return;
884
+ const observer = new window.IntersectionObserver(callback, {
885
+ root: root2,
886
+ rootMargin,
887
+ threshold
888
+ });
889
+ observer.observe(el);
890
+ cleanup = () => {
891
+ observer.disconnect();
892
+ cleanup = noop;
893
+ };
894
+ }, { immediate: true, flush: "post" }) : noop;
895
+ const stop = () => {
896
+ cleanup();
897
+ stopWatch();
898
+ };
899
+ tryOnScopeDispose(stop);
900
+ return {
901
+ isSupported,
902
+ stop
903
+ };
904
+ }
905
+
906
+ const vIntersectionObserver = (el, binding) => {
907
+ if (typeof binding.value === "function")
908
+ useIntersectionObserver(el, binding.value);
909
+ else
910
+ useIntersectionObserver(el, ...binding.value);
911
+ };
912
+
615
913
  const UseMouse = defineComponent({
616
914
  name: "UseMouse",
617
915
  props: ["touch", "resetOnTouchEnds", "initialValue"],
@@ -637,31 +935,31 @@ const UseMouseInElement = defineComponent({
637
935
  }
638
936
  });
639
937
 
640
- var __defProp$6 = Object.defineProperty;
641
- var __defProps$5 = Object.defineProperties;
642
- var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
643
- var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
644
- var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
645
- var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
646
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
647
- var __spreadValues$6 = (a, b) => {
938
+ var __defProp$7 = Object.defineProperty;
939
+ var __defProps$6 = Object.defineProperties;
940
+ var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
941
+ var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
942
+ var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
943
+ var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
944
+ var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
945
+ var __spreadValues$7 = (a, b) => {
648
946
  for (var prop in b || (b = {}))
649
- if (__hasOwnProp$6.call(b, prop))
650
- __defNormalProp$6(a, prop, b[prop]);
651
- if (__getOwnPropSymbols$6)
652
- for (var prop of __getOwnPropSymbols$6(b)) {
653
- if (__propIsEnum$6.call(b, prop))
654
- __defNormalProp$6(a, prop, b[prop]);
947
+ if (__hasOwnProp$7.call(b, prop))
948
+ __defNormalProp$7(a, prop, b[prop]);
949
+ if (__getOwnPropSymbols$7)
950
+ for (var prop of __getOwnPropSymbols$7(b)) {
951
+ if (__propIsEnum$7.call(b, prop))
952
+ __defNormalProp$7(a, prop, b[prop]);
655
953
  }
656
954
  return a;
657
955
  };
658
- var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
956
+ var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
659
957
  const UseMousePressed = defineComponent({
660
958
  name: "UseMousePressed",
661
959
  props: ["touch", "initialValue", "as"],
662
960
  setup(props, { slots }) {
663
961
  const target = ref();
664
- const data = reactive(useMousePressed(__spreadProps$5(__spreadValues$6({}, props), { target })));
962
+ const data = reactive(useMousePressed(__spreadProps$6(__spreadValues$7({}, props), { target })));
665
963
  return () => {
666
964
  if (slots.default)
667
965
  return h(props.as || "div", { ref: target }, slots.default(data));
@@ -680,30 +978,30 @@ const UseNetwork = defineComponent({
680
978
  }
681
979
  });
682
980
 
683
- var __defProp$5 = Object.defineProperty;
684
- var __defProps$4 = Object.defineProperties;
685
- var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
686
- var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
687
- var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
688
- var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
689
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
690
- var __spreadValues$5 = (a, b) => {
981
+ var __defProp$6 = Object.defineProperty;
982
+ var __defProps$5 = Object.defineProperties;
983
+ var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
984
+ var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
985
+ var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
986
+ var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
987
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
988
+ var __spreadValues$6 = (a, b) => {
691
989
  for (var prop in b || (b = {}))
692
- if (__hasOwnProp$5.call(b, prop))
693
- __defNormalProp$5(a, prop, b[prop]);
694
- if (__getOwnPropSymbols$5)
695
- for (var prop of __getOwnPropSymbols$5(b)) {
696
- if (__propIsEnum$5.call(b, prop))
697
- __defNormalProp$5(a, prop, b[prop]);
990
+ if (__hasOwnProp$6.call(b, prop))
991
+ __defNormalProp$6(a, prop, b[prop]);
992
+ if (__getOwnPropSymbols$6)
993
+ for (var prop of __getOwnPropSymbols$6(b)) {
994
+ if (__propIsEnum$6.call(b, prop))
995
+ __defNormalProp$6(a, prop, b[prop]);
698
996
  }
699
997
  return a;
700
998
  };
701
- var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
999
+ var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
702
1000
  const UseNow = defineComponent({
703
1001
  name: "UseNow",
704
1002
  props: ["interval"],
705
1003
  setup(props, { slots }) {
706
- const data = reactive(useNow(__spreadProps$4(__spreadValues$5({}, props), { controls: true })));
1004
+ const data = reactive(useNow(__spreadProps$5(__spreadValues$6({}, props), { controls: true })));
707
1005
  return () => {
708
1006
  if (slots.default)
709
1007
  return slots.default(data);
@@ -711,25 +1009,25 @@ const UseNow = defineComponent({
711
1009
  }
712
1010
  });
713
1011
 
714
- var __defProp$4 = Object.defineProperty;
715
- var __defProps$3 = Object.defineProperties;
716
- var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
717
- var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
718
- var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
719
- var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
720
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
721
- var __spreadValues$4 = (a, b) => {
1012
+ var __defProp$5 = Object.defineProperty;
1013
+ var __defProps$4 = Object.defineProperties;
1014
+ var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
1015
+ var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
1016
+ var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
1017
+ var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
1018
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1019
+ var __spreadValues$5 = (a, b) => {
722
1020
  for (var prop in b || (b = {}))
723
- if (__hasOwnProp$4.call(b, prop))
724
- __defNormalProp$4(a, prop, b[prop]);
725
- if (__getOwnPropSymbols$4)
726
- for (var prop of __getOwnPropSymbols$4(b)) {
727
- if (__propIsEnum$4.call(b, prop))
728
- __defNormalProp$4(a, prop, b[prop]);
1021
+ if (__hasOwnProp$5.call(b, prop))
1022
+ __defNormalProp$5(a, prop, b[prop]);
1023
+ if (__getOwnPropSymbols$5)
1024
+ for (var prop of __getOwnPropSymbols$5(b)) {
1025
+ if (__propIsEnum$5.call(b, prop))
1026
+ __defNormalProp$5(a, prop, b[prop]);
729
1027
  }
730
1028
  return a;
731
1029
  };
732
- var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
1030
+ var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
733
1031
  const UseOffsetPagination = defineComponent({
734
1032
  name: "UseOffsetPagination",
735
1033
  props: [
@@ -746,7 +1044,7 @@ const UseOffsetPagination = defineComponent({
746
1044
  "page-count-change"
747
1045
  ],
748
1046
  setup(props, { slots, emit }) {
749
- const data = reactive(useOffsetPagination(__spreadProps$3(__spreadValues$4({}, props), {
1047
+ const data = reactive(useOffsetPagination(__spreadProps$4(__spreadValues$5({}, props), {
750
1048
  onPageChange(...args) {
751
1049
  var _a;
752
1050
  (_a = props.onPageChange) == null ? void 0 : _a.call(props, ...args);
@@ -796,25 +1094,25 @@ const UsePageLeave = defineComponent({
796
1094
  }
797
1095
  });
798
1096
 
799
- var __defProp$3 = Object.defineProperty;
800
- var __defProps$2 = Object.defineProperties;
801
- var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
802
- var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
803
- var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
804
- var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
805
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
806
- var __spreadValues$3 = (a, b) => {
1097
+ var __defProp$4 = Object.defineProperty;
1098
+ var __defProps$3 = Object.defineProperties;
1099
+ var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
1100
+ var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
1101
+ var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
1102
+ var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
1103
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1104
+ var __spreadValues$4 = (a, b) => {
807
1105
  for (var prop in b || (b = {}))
808
- if (__hasOwnProp$3.call(b, prop))
809
- __defNormalProp$3(a, prop, b[prop]);
810
- if (__getOwnPropSymbols$3)
811
- for (var prop of __getOwnPropSymbols$3(b)) {
812
- if (__propIsEnum$3.call(b, prop))
813
- __defNormalProp$3(a, prop, b[prop]);
1106
+ if (__hasOwnProp$4.call(b, prop))
1107
+ __defNormalProp$4(a, prop, b[prop]);
1108
+ if (__getOwnPropSymbols$4)
1109
+ for (var prop of __getOwnPropSymbols$4(b)) {
1110
+ if (__propIsEnum$4.call(b, prop))
1111
+ __defNormalProp$4(a, prop, b[prop]);
814
1112
  }
815
1113
  return a;
816
1114
  };
817
- var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
1115
+ var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
818
1116
  const UsePointer = defineComponent({
819
1117
  name: "UsePointer",
820
1118
  props: [
@@ -824,7 +1122,7 @@ const UsePointer = defineComponent({
824
1122
  ],
825
1123
  setup(props, { slots }) {
826
1124
  const el = ref(null);
827
- const data = reactive(usePointer(__spreadProps$2(__spreadValues$3({}, props), {
1125
+ const data = reactive(usePointer(__spreadProps$3(__spreadValues$4({}, props), {
828
1126
  target: props.target === "self" ? el : defaultWindow
829
1127
  })));
830
1128
  return () => {
@@ -964,6 +1262,122 @@ const UseScreenSafeArea = defineComponent({
964
1262
  }
965
1263
  });
966
1264
 
1265
+ var __defProp$3 = Object.defineProperty;
1266
+ var __defProps$2 = Object.defineProperties;
1267
+ var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
1268
+ var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
1269
+ var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
1270
+ var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
1271
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1272
+ var __spreadValues$3 = (a, b) => {
1273
+ for (var prop in b || (b = {}))
1274
+ if (__hasOwnProp$3.call(b, prop))
1275
+ __defNormalProp$3(a, prop, b[prop]);
1276
+ if (__getOwnPropSymbols$3)
1277
+ for (var prop of __getOwnPropSymbols$3(b)) {
1278
+ if (__propIsEnum$3.call(b, prop))
1279
+ __defNormalProp$3(a, prop, b[prop]);
1280
+ }
1281
+ return a;
1282
+ };
1283
+ var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
1284
+ const vScroll = (el, binding) => {
1285
+ if (typeof binding.value === "function") {
1286
+ const handler = binding.value;
1287
+ const state = useScroll(el, {
1288
+ onScroll() {
1289
+ handler(state);
1290
+ },
1291
+ onStop() {
1292
+ handler(state);
1293
+ }
1294
+ });
1295
+ } else {
1296
+ const [handler, options] = binding.value;
1297
+ const state = useScroll(el, __spreadProps$2(__spreadValues$3({}, options), {
1298
+ onScroll(e) {
1299
+ var _a;
1300
+ (_a = options.onScroll) == null ? void 0 : _a.call(options, e);
1301
+ handler(state);
1302
+ },
1303
+ onStop(e) {
1304
+ var _a;
1305
+ (_a = options.onStop) == null ? void 0 : _a.call(options, e);
1306
+ handler(state);
1307
+ }
1308
+ }));
1309
+ }
1310
+ };
1311
+
1312
+ var _a, _b;
1313
+ function preventDefault(rawEvent) {
1314
+ const e = rawEvent || window.event;
1315
+ if (e.touches.length > 1)
1316
+ return true;
1317
+ if (e.preventDefault)
1318
+ e.preventDefault();
1319
+ return false;
1320
+ }
1321
+ const isIOS = isClient && (window == null ? void 0 : window.navigator) && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.platform) && /iP(ad|hone|od)/.test((_b = window == null ? void 0 : window.navigator) == null ? void 0 : _b.platform);
1322
+ function useScrollLock(element, initialState = false) {
1323
+ const isLocked = ref(initialState);
1324
+ let touchMoveListener = null;
1325
+ let initialOverflow;
1326
+ watch(() => unref(element), (el) => {
1327
+ if (el) {
1328
+ const ele = el;
1329
+ initialOverflow = ele.style.overflow;
1330
+ if (isLocked.value)
1331
+ ele.style.overflow = "hidden";
1332
+ }
1333
+ }, {
1334
+ immediate: true
1335
+ });
1336
+ const lock = () => {
1337
+ const ele = unref(element);
1338
+ if (!ele || isLocked.value)
1339
+ return;
1340
+ if (isIOS) {
1341
+ touchMoveListener = useEventListener(document, "touchmove", preventDefault, { passive: false });
1342
+ }
1343
+ ele.style.overflow = "hidden";
1344
+ isLocked.value = true;
1345
+ };
1346
+ const unlock = () => {
1347
+ const ele = unref(element);
1348
+ if (!ele || !isLocked.value)
1349
+ return;
1350
+ isIOS && (touchMoveListener == null ? void 0 : touchMoveListener());
1351
+ ele.style.overflow = initialOverflow;
1352
+ isLocked.value = false;
1353
+ };
1354
+ return computed({
1355
+ get() {
1356
+ return isLocked.value;
1357
+ },
1358
+ set(v) {
1359
+ if (v)
1360
+ lock();
1361
+ else
1362
+ unlock();
1363
+ }
1364
+ });
1365
+ }
1366
+
1367
+ const onScrollLock = () => {
1368
+ let isMounted = false;
1369
+ const state = ref(false);
1370
+ return (el, binding) => {
1371
+ state.value = binding.value;
1372
+ if (isMounted)
1373
+ return;
1374
+ isMounted = true;
1375
+ const isLocked = useScrollLock(el, binding.value);
1376
+ watch(state, (v) => isLocked.value = v);
1377
+ };
1378
+ };
1379
+ const vScrollLock = onScrollLock();
1380
+
967
1381
  var __defProp$2 = Object.defineProperty;
968
1382
  var __defProps$1 = Object.defineProperties;
969
1383
  var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
@@ -1085,4 +1499,4 @@ const UseWindowSize = defineComponent({
1085
1499
  }
1086
1500
  });
1087
1501
 
1088
- export { OnClickOutside, OnLongPress, UseActiveElement, UseBattery, UseBrowserLocation, UseColorMode, UseDark, UseDeviceMotion, UseDeviceOrientation, UseDevicePixelRatio, UseDevicesList, UseDocumentVisibility, UseDraggable, UseElementBounding, UseElementSize, UseElementVisibility, UseEyeDropper, UseFullscreen, UseGeolocation, UseIdle, UseMouse, UseMouseInElement, UseMousePressed, UseNetwork, UseNow, UseOffsetPagination, UseOnline, UsePageLeave, UsePointer, UsePreferredColorScheme, UsePreferredDark, UsePreferredLanguages, UseScreenSafeArea, UseTimeAgo, UseTimestamp, UseVirtualList, UseWindowFocus, UseWindowSize, VOnClickOutside, VOnLongPress };
1502
+ export { OnClickOutside, OnLongPress, UseActiveElement, UseBattery, UseBrowserLocation, UseColorMode, UseDark, UseDeviceMotion, UseDeviceOrientation, UseDevicePixelRatio, UseDevicesList, UseDocumentVisibility, UseDraggable, UseElementBounding, UseElementSize, UseElementVisibility, UseEyeDropper, UseFullscreen, UseGeolocation, UseIdle, UseMouse, UseMouseInElement, UseMousePressed, UseNetwork, UseNow, UseOffsetPagination, UseOnline, UsePageLeave, UsePointer, UsePreferredColorScheme, UsePreferredDark, UsePreferredLanguages, UseScreenSafeArea, UseTimeAgo, UseTimestamp, UseVirtualList, UseWindowFocus, UseWindowSize, vOnClickOutside as VOnClickOutside, vOnLongPress as VOnLongPress, vElementHover, vElementSize, vInfiniteScroll, vIntersectionObserver, vOnClickOutside, vOnKeyStroke, vOnLongPress, vScroll, vScrollLock };