@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.iife.js CHANGED
@@ -148,8 +148,70 @@
148
148
  return stop;
149
149
  }
150
150
 
151
- const VOnClickOutside = (el, binding) => {
152
- onClickOutside(el, binding.value);
151
+ const handler = () => {
152
+ let stop = null;
153
+ return (el, binding) => {
154
+ if (stop) {
155
+ stop();
156
+ stop = onClickOutside(el, binding.value);
157
+ return;
158
+ }
159
+ stop = onClickOutside(el, binding.value);
160
+ };
161
+ };
162
+ const vOnClickOutside = handler();
163
+
164
+ const createKeyPredicate = (keyFilter) => {
165
+ if (typeof keyFilter === "function")
166
+ return keyFilter;
167
+ else if (typeof keyFilter === "string")
168
+ return (event) => event.key === keyFilter;
169
+ else if (Array.isArray(keyFilter))
170
+ return (event) => keyFilter.includes(event.key);
171
+ else if (keyFilter)
172
+ return () => true;
173
+ else
174
+ return () => false;
175
+ };
176
+ function onKeyStroke(key, handler, options = {}) {
177
+ const { target = defaultWindow, eventName = "keydown", passive = false } = options;
178
+ const predicate = createKeyPredicate(key);
179
+ const listener = (e) => {
180
+ if (predicate(e))
181
+ handler(e);
182
+ };
183
+ return useEventListener(target, eventName, listener, passive);
184
+ }
185
+
186
+ var __defProp$b = Object.defineProperty;
187
+ var __getOwnPropSymbols$c = Object.getOwnPropertySymbols;
188
+ var __hasOwnProp$c = Object.prototype.hasOwnProperty;
189
+ var __propIsEnum$c = Object.prototype.propertyIsEnumerable;
190
+ var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
191
+ var __spreadValues$b = (a, b) => {
192
+ for (var prop in b || (b = {}))
193
+ if (__hasOwnProp$c.call(b, prop))
194
+ __defNormalProp$b(a, prop, b[prop]);
195
+ if (__getOwnPropSymbols$c)
196
+ for (var prop of __getOwnPropSymbols$c(b)) {
197
+ if (__propIsEnum$c.call(b, prop))
198
+ __defNormalProp$b(a, prop, b[prop]);
199
+ }
200
+ return a;
201
+ };
202
+ const vOnKeyStroke = (el, binding) => {
203
+ var _a, _b;
204
+ const keys = (_b = (_a = binding.arg) == null ? void 0 : _a.split(",")) != null ? _b : [];
205
+ if (typeof binding.value === "function") {
206
+ onKeyStroke(keys, binding.value, {
207
+ target: el
208
+ });
209
+ } else {
210
+ const [handler, options] = binding.value;
211
+ onKeyStroke(keys, handler, __spreadValues$b({
212
+ target: el
213
+ }, options));
214
+ }
153
215
  };
154
216
 
155
217
  const DEFAULT_DELAY = 500;
@@ -188,11 +250,11 @@
188
250
  }
189
251
  });
190
252
 
191
- const VOnLongPress = (el, binding) => {
253
+ const vOnLongPress = (el, binding) => {
192
254
  if (typeof binding.value === "function")
193
255
  onLongPress(el, binding.value);
194
256
  else
195
- onLongPress(el, binding.value.handler, binding.value.options);
257
+ onLongPress(el, ...binding.value);
196
258
  };
197
259
 
198
260
  const UseActiveElement = vueDemi.defineComponent({
@@ -373,19 +435,19 @@
373
435
  return useMediaQuery("(prefers-color-scheme: dark)", options);
374
436
  }
375
437
 
376
- var __defProp$8 = Object.defineProperty;
377
- var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
378
- var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
379
- var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
380
- var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
381
- var __spreadValues$8 = (a, b) => {
438
+ var __defProp$a = Object.defineProperty;
439
+ var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
440
+ var __hasOwnProp$b = Object.prototype.hasOwnProperty;
441
+ var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
442
+ var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
443
+ var __spreadValues$a = (a, b) => {
382
444
  for (var prop in b || (b = {}))
383
- if (__hasOwnProp$8.call(b, prop))
384
- __defNormalProp$8(a, prop, b[prop]);
385
- if (__getOwnPropSymbols$8)
386
- for (var prop of __getOwnPropSymbols$8(b)) {
387
- if (__propIsEnum$8.call(b, prop))
388
- __defNormalProp$8(a, prop, b[prop]);
445
+ if (__hasOwnProp$b.call(b, prop))
446
+ __defNormalProp$a(a, prop, b[prop]);
447
+ if (__getOwnPropSymbols$b)
448
+ for (var prop of __getOwnPropSymbols$b(b)) {
449
+ if (__propIsEnum$b.call(b, prop))
450
+ __defNormalProp$a(a, prop, b[prop]);
389
451
  }
390
452
  return a;
391
453
  };
@@ -399,7 +461,7 @@
399
461
  listenToStorageChanges = true,
400
462
  storageRef
401
463
  } = options;
402
- const modes = __spreadValues$8({
464
+ const modes = __spreadValues$a({
403
465
  auto: "",
404
466
  light: "light",
405
467
  dark: "dark"
@@ -537,25 +599,25 @@
537
599
  }
538
600
  });
539
601
 
540
- var __defProp$7 = Object.defineProperty;
541
- var __defProps$6 = Object.defineProperties;
542
- var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
543
- var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
544
- var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
545
- var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
546
- var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
547
- var __spreadValues$7 = (a, b) => {
602
+ var __defProp$9 = Object.defineProperty;
603
+ var __defProps$8 = Object.defineProperties;
604
+ var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
605
+ var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
606
+ var __hasOwnProp$a = Object.prototype.hasOwnProperty;
607
+ var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
608
+ var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
609
+ var __spreadValues$9 = (a, b) => {
548
610
  for (var prop in b || (b = {}))
549
- if (__hasOwnProp$7.call(b, prop))
550
- __defNormalProp$7(a, prop, b[prop]);
551
- if (__getOwnPropSymbols$7)
552
- for (var prop of __getOwnPropSymbols$7(b)) {
553
- if (__propIsEnum$7.call(b, prop))
554
- __defNormalProp$7(a, prop, b[prop]);
611
+ if (__hasOwnProp$a.call(b, prop))
612
+ __defNormalProp$9(a, prop, b[prop]);
613
+ if (__getOwnPropSymbols$a)
614
+ for (var prop of __getOwnPropSymbols$a(b)) {
615
+ if (__propIsEnum$a.call(b, prop))
616
+ __defNormalProp$9(a, prop, b[prop]);
555
617
  }
556
618
  return a;
557
619
  };
558
- var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
620
+ var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
559
621
  const UseDraggable = vueDemi.defineComponent({
560
622
  name: "UseDraggable",
561
623
  props: [
@@ -570,7 +632,7 @@
570
632
  setup(props, { slots }) {
571
633
  const target = vueDemi.ref();
572
634
  const initialValue = props.storageKey ? core.useStorage(props.storageKey, vueDemi.unref(props.initialValue) || { x: 0, y: 0 }, core.isClient ? props.storageType === "session" ? sessionStorage : localStorage : void 0) : props.initialValue || { x: 0, y: 0 };
573
- const data = vueDemi.reactive(core.useDraggable(target, __spreadProps$6(__spreadValues$7({}, props), {
635
+ const data = vueDemi.reactive(core.useDraggable(target, __spreadProps$8(__spreadValues$9({}, props), {
574
636
  initialValue
575
637
  })));
576
638
  return () => {
@@ -593,6 +655,20 @@
593
655
  }
594
656
  });
595
657
 
658
+ function useElementHover(el) {
659
+ const isHovered = vueDemi.ref(false);
660
+ useEventListener(el, "mouseenter", () => isHovered.value = true);
661
+ useEventListener(el, "mouseleave", () => isHovered.value = false);
662
+ return isHovered;
663
+ }
664
+
665
+ const vElementHover = (el, binding) => {
666
+ if (typeof binding.value === "function") {
667
+ const isHovered = useElementHover(el);
668
+ vueDemi.watch(isHovered, (v) => binding.value(v));
669
+ }
670
+ };
671
+
596
672
  const UseElementSize = vueDemi.defineComponent({
597
673
  name: "UseElementSize",
598
674
  props: ["width", "height", "box"],
@@ -606,6 +682,74 @@
606
682
  }
607
683
  });
608
684
 
685
+ var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
686
+ var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
687
+ var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
688
+ var __objRest = (source, exclude) => {
689
+ var target = {};
690
+ for (var prop in source)
691
+ if (__hasOwnProp$9.call(source, prop) && exclude.indexOf(prop) < 0)
692
+ target[prop] = source[prop];
693
+ if (source != null && __getOwnPropSymbols$9)
694
+ for (var prop of __getOwnPropSymbols$9(source)) {
695
+ if (exclude.indexOf(prop) < 0 && __propIsEnum$9.call(source, prop))
696
+ target[prop] = source[prop];
697
+ }
698
+ return target;
699
+ };
700
+ function useResizeObserver(target, callback, options = {}) {
701
+ const _a = options, { window = defaultWindow } = _a, observerOptions = __objRest(_a, ["window"]);
702
+ let observer;
703
+ const isSupported = window && "ResizeObserver" in window;
704
+ const cleanup = () => {
705
+ if (observer) {
706
+ observer.disconnect();
707
+ observer = void 0;
708
+ }
709
+ };
710
+ const stopWatch = vueDemi.watch(() => unrefElement(target), (el) => {
711
+ cleanup();
712
+ if (isSupported && window && el) {
713
+ observer = new window.ResizeObserver(callback);
714
+ observer.observe(el, observerOptions);
715
+ }
716
+ }, { immediate: true, flush: "post" });
717
+ const stop = () => {
718
+ cleanup();
719
+ stopWatch();
720
+ };
721
+ shared.tryOnScopeDispose(stop);
722
+ return {
723
+ isSupported,
724
+ stop
725
+ };
726
+ }
727
+
728
+ function useElementSize(target, initialSize = { width: 0, height: 0 }, options = {}) {
729
+ const width = vueDemi.ref(initialSize.width);
730
+ const height = vueDemi.ref(initialSize.height);
731
+ useResizeObserver(target, ([entry]) => {
732
+ width.value = entry.contentRect.width;
733
+ height.value = entry.contentRect.height;
734
+ }, options);
735
+ vueDemi.watch(() => unrefElement(target), (ele) => {
736
+ width.value = ele ? initialSize.width : 0;
737
+ height.value = ele ? initialSize.height : 0;
738
+ });
739
+ return {
740
+ width,
741
+ height
742
+ };
743
+ }
744
+
745
+ const vElementSize = (el, binding) => {
746
+ var _a;
747
+ const handler = typeof binding.value === "function" ? binding.value : (_a = binding.value) == null ? void 0 : _a[0];
748
+ const options = typeof binding.value === "function" ? [] : binding.value.slice(1);
749
+ const { width, height } = useElementSize(el, ...options);
750
+ vueDemi.watch([width, height], ([width2, height2]) => handler({ width: width2, height: height2 }));
751
+ };
752
+
609
753
  const UseElementVisibility = vueDemi.defineComponent({
610
754
  name: "UseElementVisibility",
611
755
  props: ["as"],
@@ -672,6 +816,160 @@
672
816
  }
673
817
  });
674
818
 
819
+ function useScroll(element, options = {}) {
820
+ const {
821
+ throttle = 0,
822
+ idle = 200,
823
+ onStop = shared.noop,
824
+ onScroll = shared.noop,
825
+ offset = {
826
+ left: 0,
827
+ right: 0,
828
+ top: 0,
829
+ bottom: 0
830
+ },
831
+ eventListenerOptions = {
832
+ capture: false,
833
+ passive: true
834
+ }
835
+ } = options;
836
+ const x = vueDemi.ref(0);
837
+ const y = vueDemi.ref(0);
838
+ const isScrolling = vueDemi.ref(false);
839
+ const arrivedState = vueDemi.reactive({
840
+ left: true,
841
+ right: false,
842
+ top: true,
843
+ bottom: false
844
+ });
845
+ const directions = vueDemi.reactive({
846
+ left: false,
847
+ right: false,
848
+ top: false,
849
+ bottom: false
850
+ });
851
+ if (element) {
852
+ const onScrollEnd = shared.useDebounceFn((e) => {
853
+ isScrolling.value = false;
854
+ directions.left = false;
855
+ directions.right = false;
856
+ directions.top = false;
857
+ directions.bottom = false;
858
+ onStop(e);
859
+ }, throttle + idle);
860
+ const onScrollHandler = (e) => {
861
+ const eventTarget = e.target === document ? e.target.documentElement : e.target;
862
+ const scrollLeft = eventTarget.scrollLeft;
863
+ directions.left = scrollLeft < x.value;
864
+ directions.right = scrollLeft > x.value;
865
+ arrivedState.left = scrollLeft <= 0 + (offset.left || 0);
866
+ arrivedState.right = scrollLeft + eventTarget.clientWidth >= eventTarget.scrollWidth - (offset.right || 0);
867
+ x.value = scrollLeft;
868
+ const scrollTop = eventTarget.scrollTop;
869
+ directions.top = scrollTop < y.value;
870
+ directions.bottom = scrollTop > y.value;
871
+ arrivedState.top = scrollTop <= 0 + (offset.top || 0);
872
+ arrivedState.bottom = scrollTop + eventTarget.clientHeight >= eventTarget.scrollHeight - (offset.bottom || 0);
873
+ y.value = scrollTop;
874
+ isScrolling.value = true;
875
+ onScrollEnd(e);
876
+ onScroll(e);
877
+ };
878
+ useEventListener(element, "scroll", throttle ? shared.useThrottleFn(onScrollHandler, throttle) : onScrollHandler, eventListenerOptions);
879
+ }
880
+ return {
881
+ x,
882
+ y,
883
+ isScrolling,
884
+ arrivedState,
885
+ directions
886
+ };
887
+ }
888
+
889
+ var __defProp$8 = Object.defineProperty;
890
+ var __defProps$7 = Object.defineProperties;
891
+ var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
892
+ var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
893
+ var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
894
+ var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
895
+ var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
896
+ var __spreadValues$8 = (a, b) => {
897
+ for (var prop in b || (b = {}))
898
+ if (__hasOwnProp$8.call(b, prop))
899
+ __defNormalProp$8(a, prop, b[prop]);
900
+ if (__getOwnPropSymbols$8)
901
+ for (var prop of __getOwnPropSymbols$8(b)) {
902
+ if (__propIsEnum$8.call(b, prop))
903
+ __defNormalProp$8(a, prop, b[prop]);
904
+ }
905
+ return a;
906
+ };
907
+ var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
908
+ function useInfiniteScroll(element, onLoadMore, options = {}) {
909
+ var _a;
910
+ const state = vueDemi.reactive(useScroll(element, __spreadProps$7(__spreadValues$8({}, options), {
911
+ offset: __spreadValues$8({
912
+ bottom: (_a = options.distance) != null ? _a : 0
913
+ }, options.offset)
914
+ })));
915
+ vueDemi.watch(() => state.arrivedState.bottom, (v) => {
916
+ if (v)
917
+ onLoadMore(state);
918
+ });
919
+ }
920
+
921
+ const vInfiniteScroll = (el, binding) => {
922
+ if (typeof binding.value === "function")
923
+ useInfiniteScroll(el, binding.value);
924
+ else
925
+ useInfiniteScroll(el, ...binding.value);
926
+ };
927
+
928
+ function useIntersectionObserver(target, callback, options = {}) {
929
+ const {
930
+ root,
931
+ rootMargin = "0px",
932
+ threshold = 0.1,
933
+ window = defaultWindow
934
+ } = options;
935
+ const isSupported = window && "IntersectionObserver" in window;
936
+ let cleanup = shared.noop;
937
+ const stopWatch = isSupported ? vueDemi.watch(() => ({
938
+ el: unrefElement(target),
939
+ root: unrefElement(root)
940
+ }), ({ el, root: root2 }) => {
941
+ cleanup();
942
+ if (!el)
943
+ return;
944
+ const observer = new window.IntersectionObserver(callback, {
945
+ root: root2,
946
+ rootMargin,
947
+ threshold
948
+ });
949
+ observer.observe(el);
950
+ cleanup = () => {
951
+ observer.disconnect();
952
+ cleanup = shared.noop;
953
+ };
954
+ }, { immediate: true, flush: "post" }) : shared.noop;
955
+ const stop = () => {
956
+ cleanup();
957
+ stopWatch();
958
+ };
959
+ shared.tryOnScopeDispose(stop);
960
+ return {
961
+ isSupported,
962
+ stop
963
+ };
964
+ }
965
+
966
+ const vIntersectionObserver = (el, binding) => {
967
+ if (typeof binding.value === "function")
968
+ useIntersectionObserver(el, binding.value);
969
+ else
970
+ useIntersectionObserver(el, ...binding.value);
971
+ };
972
+
675
973
  const UseMouse = vueDemi.defineComponent({
676
974
  name: "UseMouse",
677
975
  props: ["touch", "resetOnTouchEnds", "initialValue"],
@@ -697,31 +995,31 @@
697
995
  }
698
996
  });
699
997
 
700
- var __defProp$6 = Object.defineProperty;
701
- var __defProps$5 = Object.defineProperties;
702
- var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
703
- var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
704
- var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
705
- var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
706
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
707
- var __spreadValues$6 = (a, b) => {
998
+ var __defProp$7 = Object.defineProperty;
999
+ var __defProps$6 = Object.defineProperties;
1000
+ var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
1001
+ var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
1002
+ var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
1003
+ var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
1004
+ var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1005
+ var __spreadValues$7 = (a, b) => {
708
1006
  for (var prop in b || (b = {}))
709
- if (__hasOwnProp$6.call(b, prop))
710
- __defNormalProp$6(a, prop, b[prop]);
711
- if (__getOwnPropSymbols$6)
712
- for (var prop of __getOwnPropSymbols$6(b)) {
713
- if (__propIsEnum$6.call(b, prop))
714
- __defNormalProp$6(a, prop, b[prop]);
1007
+ if (__hasOwnProp$7.call(b, prop))
1008
+ __defNormalProp$7(a, prop, b[prop]);
1009
+ if (__getOwnPropSymbols$7)
1010
+ for (var prop of __getOwnPropSymbols$7(b)) {
1011
+ if (__propIsEnum$7.call(b, prop))
1012
+ __defNormalProp$7(a, prop, b[prop]);
715
1013
  }
716
1014
  return a;
717
1015
  };
718
- var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
1016
+ var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
719
1017
  const UseMousePressed = vueDemi.defineComponent({
720
1018
  name: "UseMousePressed",
721
1019
  props: ["touch", "initialValue", "as"],
722
1020
  setup(props, { slots }) {
723
1021
  const target = vueDemi.ref();
724
- const data = vueDemi.reactive(core.useMousePressed(__spreadProps$5(__spreadValues$6({}, props), { target })));
1022
+ const data = vueDemi.reactive(core.useMousePressed(__spreadProps$6(__spreadValues$7({}, props), { target })));
725
1023
  return () => {
726
1024
  if (slots.default)
727
1025
  return vueDemi.h(props.as || "div", { ref: target }, slots.default(data));
@@ -740,30 +1038,30 @@
740
1038
  }
741
1039
  });
742
1040
 
743
- var __defProp$5 = Object.defineProperty;
744
- var __defProps$4 = Object.defineProperties;
745
- var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
746
- var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
747
- var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
748
- var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
749
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
750
- var __spreadValues$5 = (a, b) => {
1041
+ var __defProp$6 = Object.defineProperty;
1042
+ var __defProps$5 = Object.defineProperties;
1043
+ var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
1044
+ var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
1045
+ var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
1046
+ var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
1047
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1048
+ var __spreadValues$6 = (a, b) => {
751
1049
  for (var prop in b || (b = {}))
752
- if (__hasOwnProp$5.call(b, prop))
753
- __defNormalProp$5(a, prop, b[prop]);
754
- if (__getOwnPropSymbols$5)
755
- for (var prop of __getOwnPropSymbols$5(b)) {
756
- if (__propIsEnum$5.call(b, prop))
757
- __defNormalProp$5(a, prop, b[prop]);
1050
+ if (__hasOwnProp$6.call(b, prop))
1051
+ __defNormalProp$6(a, prop, b[prop]);
1052
+ if (__getOwnPropSymbols$6)
1053
+ for (var prop of __getOwnPropSymbols$6(b)) {
1054
+ if (__propIsEnum$6.call(b, prop))
1055
+ __defNormalProp$6(a, prop, b[prop]);
758
1056
  }
759
1057
  return a;
760
1058
  };
761
- var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
1059
+ var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
762
1060
  const UseNow = vueDemi.defineComponent({
763
1061
  name: "UseNow",
764
1062
  props: ["interval"],
765
1063
  setup(props, { slots }) {
766
- const data = vueDemi.reactive(core.useNow(__spreadProps$4(__spreadValues$5({}, props), { controls: true })));
1064
+ const data = vueDemi.reactive(core.useNow(__spreadProps$5(__spreadValues$6({}, props), { controls: true })));
767
1065
  return () => {
768
1066
  if (slots.default)
769
1067
  return slots.default(data);
@@ -771,25 +1069,25 @@
771
1069
  }
772
1070
  });
773
1071
 
774
- var __defProp$4 = Object.defineProperty;
775
- var __defProps$3 = Object.defineProperties;
776
- var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
777
- var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
778
- var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
779
- var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
780
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
781
- var __spreadValues$4 = (a, b) => {
1072
+ var __defProp$5 = Object.defineProperty;
1073
+ var __defProps$4 = Object.defineProperties;
1074
+ var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
1075
+ var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
1076
+ var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
1077
+ var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
1078
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1079
+ var __spreadValues$5 = (a, b) => {
782
1080
  for (var prop in b || (b = {}))
783
- if (__hasOwnProp$4.call(b, prop))
784
- __defNormalProp$4(a, prop, b[prop]);
785
- if (__getOwnPropSymbols$4)
786
- for (var prop of __getOwnPropSymbols$4(b)) {
787
- if (__propIsEnum$4.call(b, prop))
788
- __defNormalProp$4(a, prop, b[prop]);
1081
+ if (__hasOwnProp$5.call(b, prop))
1082
+ __defNormalProp$5(a, prop, b[prop]);
1083
+ if (__getOwnPropSymbols$5)
1084
+ for (var prop of __getOwnPropSymbols$5(b)) {
1085
+ if (__propIsEnum$5.call(b, prop))
1086
+ __defNormalProp$5(a, prop, b[prop]);
789
1087
  }
790
1088
  return a;
791
1089
  };
792
- var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
1090
+ var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
793
1091
  const UseOffsetPagination = vueDemi.defineComponent({
794
1092
  name: "UseOffsetPagination",
795
1093
  props: [
@@ -806,7 +1104,7 @@
806
1104
  "page-count-change"
807
1105
  ],
808
1106
  setup(props, { slots, emit }) {
809
- const data = vueDemi.reactive(core.useOffsetPagination(__spreadProps$3(__spreadValues$4({}, props), {
1107
+ const data = vueDemi.reactive(core.useOffsetPagination(__spreadProps$4(__spreadValues$5({}, props), {
810
1108
  onPageChange(...args) {
811
1109
  var _a;
812
1110
  (_a = props.onPageChange) == null ? void 0 : _a.call(props, ...args);
@@ -856,25 +1154,25 @@
856
1154
  }
857
1155
  });
858
1156
 
859
- var __defProp$3 = Object.defineProperty;
860
- var __defProps$2 = Object.defineProperties;
861
- var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
862
- var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
863
- var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
864
- var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
865
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
866
- var __spreadValues$3 = (a, b) => {
1157
+ var __defProp$4 = Object.defineProperty;
1158
+ var __defProps$3 = Object.defineProperties;
1159
+ var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
1160
+ var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
1161
+ var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
1162
+ var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
1163
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1164
+ var __spreadValues$4 = (a, b) => {
867
1165
  for (var prop in b || (b = {}))
868
- if (__hasOwnProp$3.call(b, prop))
869
- __defNormalProp$3(a, prop, b[prop]);
870
- if (__getOwnPropSymbols$3)
871
- for (var prop of __getOwnPropSymbols$3(b)) {
872
- if (__propIsEnum$3.call(b, prop))
873
- __defNormalProp$3(a, prop, b[prop]);
1166
+ if (__hasOwnProp$4.call(b, prop))
1167
+ __defNormalProp$4(a, prop, b[prop]);
1168
+ if (__getOwnPropSymbols$4)
1169
+ for (var prop of __getOwnPropSymbols$4(b)) {
1170
+ if (__propIsEnum$4.call(b, prop))
1171
+ __defNormalProp$4(a, prop, b[prop]);
874
1172
  }
875
1173
  return a;
876
1174
  };
877
- var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
1175
+ var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
878
1176
  const UsePointer = vueDemi.defineComponent({
879
1177
  name: "UsePointer",
880
1178
  props: [
@@ -884,7 +1182,7 @@
884
1182
  ],
885
1183
  setup(props, { slots }) {
886
1184
  const el = vueDemi.ref(null);
887
- const data = vueDemi.reactive(core.usePointer(__spreadProps$2(__spreadValues$3({}, props), {
1185
+ const data = vueDemi.reactive(core.usePointer(__spreadProps$3(__spreadValues$4({}, props), {
888
1186
  target: props.target === "self" ? el : defaultWindow
889
1187
  })));
890
1188
  return () => {
@@ -1024,6 +1322,122 @@
1024
1322
  }
1025
1323
  });
1026
1324
 
1325
+ var __defProp$3 = Object.defineProperty;
1326
+ var __defProps$2 = Object.defineProperties;
1327
+ var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
1328
+ var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
1329
+ var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
1330
+ var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
1331
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1332
+ var __spreadValues$3 = (a, b) => {
1333
+ for (var prop in b || (b = {}))
1334
+ if (__hasOwnProp$3.call(b, prop))
1335
+ __defNormalProp$3(a, prop, b[prop]);
1336
+ if (__getOwnPropSymbols$3)
1337
+ for (var prop of __getOwnPropSymbols$3(b)) {
1338
+ if (__propIsEnum$3.call(b, prop))
1339
+ __defNormalProp$3(a, prop, b[prop]);
1340
+ }
1341
+ return a;
1342
+ };
1343
+ var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
1344
+ const vScroll = (el, binding) => {
1345
+ if (typeof binding.value === "function") {
1346
+ const handler = binding.value;
1347
+ const state = useScroll(el, {
1348
+ onScroll() {
1349
+ handler(state);
1350
+ },
1351
+ onStop() {
1352
+ handler(state);
1353
+ }
1354
+ });
1355
+ } else {
1356
+ const [handler, options] = binding.value;
1357
+ const state = useScroll(el, __spreadProps$2(__spreadValues$3({}, options), {
1358
+ onScroll(e) {
1359
+ var _a;
1360
+ (_a = options.onScroll) == null ? void 0 : _a.call(options, e);
1361
+ handler(state);
1362
+ },
1363
+ onStop(e) {
1364
+ var _a;
1365
+ (_a = options.onStop) == null ? void 0 : _a.call(options, e);
1366
+ handler(state);
1367
+ }
1368
+ }));
1369
+ }
1370
+ };
1371
+
1372
+ var _a, _b;
1373
+ function preventDefault(rawEvent) {
1374
+ const e = rawEvent || window.event;
1375
+ if (e.touches.length > 1)
1376
+ return true;
1377
+ if (e.preventDefault)
1378
+ e.preventDefault();
1379
+ return false;
1380
+ }
1381
+ const isIOS = shared.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);
1382
+ function useScrollLock(element, initialState = false) {
1383
+ const isLocked = vueDemi.ref(initialState);
1384
+ let touchMoveListener = null;
1385
+ let initialOverflow;
1386
+ vueDemi.watch(() => vueDemi.unref(element), (el) => {
1387
+ if (el) {
1388
+ const ele = el;
1389
+ initialOverflow = ele.style.overflow;
1390
+ if (isLocked.value)
1391
+ ele.style.overflow = "hidden";
1392
+ }
1393
+ }, {
1394
+ immediate: true
1395
+ });
1396
+ const lock = () => {
1397
+ const ele = vueDemi.unref(element);
1398
+ if (!ele || isLocked.value)
1399
+ return;
1400
+ if (isIOS) {
1401
+ touchMoveListener = useEventListener(document, "touchmove", preventDefault, { passive: false });
1402
+ }
1403
+ ele.style.overflow = "hidden";
1404
+ isLocked.value = true;
1405
+ };
1406
+ const unlock = () => {
1407
+ const ele = vueDemi.unref(element);
1408
+ if (!ele || !isLocked.value)
1409
+ return;
1410
+ isIOS && (touchMoveListener == null ? void 0 : touchMoveListener());
1411
+ ele.style.overflow = initialOverflow;
1412
+ isLocked.value = false;
1413
+ };
1414
+ return vueDemi.computed({
1415
+ get() {
1416
+ return isLocked.value;
1417
+ },
1418
+ set(v) {
1419
+ if (v)
1420
+ lock();
1421
+ else
1422
+ unlock();
1423
+ }
1424
+ });
1425
+ }
1426
+
1427
+ const onScrollLock = () => {
1428
+ let isMounted = false;
1429
+ const state = vueDemi.ref(false);
1430
+ return (el, binding) => {
1431
+ state.value = binding.value;
1432
+ if (isMounted)
1433
+ return;
1434
+ isMounted = true;
1435
+ const isLocked = useScrollLock(el, binding.value);
1436
+ vueDemi.watch(state, (v) => isLocked.value = v);
1437
+ };
1438
+ };
1439
+ const vScrollLock = onScrollLock();
1440
+
1027
1441
  var __defProp$2 = Object.defineProperty;
1028
1442
  var __defProps$1 = Object.defineProperties;
1029
1443
  var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
@@ -1183,8 +1597,17 @@
1183
1597
  exports.UseVirtualList = UseVirtualList;
1184
1598
  exports.UseWindowFocus = UseWindowFocus;
1185
1599
  exports.UseWindowSize = UseWindowSize;
1186
- exports.VOnClickOutside = VOnClickOutside;
1187
- exports.VOnLongPress = VOnLongPress;
1600
+ exports.VOnClickOutside = vOnClickOutside;
1601
+ exports.VOnLongPress = vOnLongPress;
1602
+ exports.vElementHover = vElementHover;
1603
+ exports.vElementSize = vElementSize;
1604
+ exports.vInfiniteScroll = vInfiniteScroll;
1605
+ exports.vIntersectionObserver = vIntersectionObserver;
1606
+ exports.vOnClickOutside = vOnClickOutside;
1607
+ exports.vOnKeyStroke = vOnKeyStroke;
1608
+ exports.vOnLongPress = vOnLongPress;
1609
+ exports.vScroll = vScroll;
1610
+ exports.vScrollLock = vScrollLock;
1188
1611
 
1189
1612
  Object.defineProperty(exports, '__esModule', { value: true });
1190
1613