@vueuse/components 10.0.0-beta.2 → 10.0.0-beta.4

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.cjs CHANGED
@@ -22,7 +22,7 @@ const OnClickOutside = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineComponent({
22
22
 
23
23
  function unrefElement(elRef) {
24
24
  var _a;
25
- const plain = shared.resolveUnref(elRef);
25
+ const plain = shared.toValue(elRef);
26
26
  return (_a = plain == null ? void 0 : plain.$el) != null ? _a : plain;
27
27
  }
28
28
 
@@ -54,14 +54,20 @@ function useEventListener(...args) {
54
54
  el.addEventListener(event, listener, options2);
55
55
  return () => el.removeEventListener(event, listener, options2);
56
56
  };
57
- const stopWatch = vueDemi.watch(() => [unrefElement(target), shared.resolveUnref(options)], ([el, options2]) => {
58
- cleanup();
59
- if (!el)
60
- return;
61
- cleanups.push(...events.flatMap((event) => {
62
- return listeners.map((listener) => register(el, event, listener, options2));
63
- }));
64
- }, { immediate: true, flush: "post" });
57
+ const stopWatch = vueDemi.watch(
58
+ () => [unrefElement(target), shared.toValue(options)],
59
+ ([el, options2]) => {
60
+ cleanup();
61
+ if (!el)
62
+ return;
63
+ cleanups.push(
64
+ ...events.flatMap((event) => {
65
+ return listeners.map((listener) => register(el, event, listener, options2));
66
+ })
67
+ );
68
+ },
69
+ { immediate: true, flush: "post" }
70
+ );
65
71
  const stop = () => {
66
72
  stopWatch();
67
73
  cleanup();
@@ -135,7 +141,7 @@ const vOnClickOutside = {
135
141
  }
136
142
  };
137
143
 
138
- const createKeyPredicate = (keyFilter) => {
144
+ function createKeyPredicate(keyFilter) {
139
145
  if (typeof keyFilter === "function")
140
146
  return keyFilter;
141
147
  else if (typeof keyFilter === "string")
@@ -143,7 +149,7 @@ const createKeyPredicate = (keyFilter) => {
143
149
  else if (Array.isArray(keyFilter))
144
150
  return (event) => keyFilter.includes(event.key);
145
151
  return () => true;
146
- };
152
+ }
147
153
  function onKeyStroke(...args) {
148
154
  let key;
149
155
  let handler;
@@ -173,7 +179,7 @@ function onKeyStroke(...args) {
173
179
  } = options;
174
180
  const predicate = createKeyPredicate(key);
175
181
  const listener = (e) => {
176
- if (e.repeat && shared.resolveUnref(dedupe))
182
+ if (e.repeat && shared.toValue(dedupe))
177
183
  return;
178
184
  if (predicate(e))
179
185
  handler(e);
@@ -234,7 +240,10 @@ function onLongPress(target, handler, options) {
234
240
  ev.preventDefault();
235
241
  if ((_c = options == null ? void 0 : options.modifiers) == null ? void 0 : _c.stop)
236
242
  ev.stopPropagation();
237
- timeout = setTimeout(() => handler(ev), (_d = options == null ? void 0 : options.delay) != null ? _d : DEFAULT_DELAY);
243
+ timeout = setTimeout(
244
+ () => handler(ev),
245
+ (_d = options == null ? void 0 : options.delay) != null ? _d : DEFAULT_DELAY
246
+ );
238
247
  }
239
248
  const listenerOptions = {
240
249
  capture: (_a = options == null ? void 0 : options.modifiers) == null ? void 0 : _a.capture,
@@ -251,9 +260,13 @@ const OnLongPress = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineComponent({
251
260
  emits: ["trigger"],
252
261
  setup(props, { slots, emit }) {
253
262
  const target = vueDemi.ref();
254
- onLongPress(target, (e) => {
255
- emit("trigger", e);
256
- }, props.options);
263
+ onLongPress(
264
+ target,
265
+ (e) => {
266
+ emit("trigger", e);
267
+ },
268
+ props.options
269
+ );
257
270
  return () => {
258
271
  if (slots.default)
259
272
  return vueDemi.h(props.as || "div", { ref: target }, slots.default());
@@ -396,10 +409,14 @@ function useStorage(key, defaults, storage, options = {}) {
396
409
  }
397
410
  if (!storage)
398
411
  return data;
399
- const rawInit = shared.resolveUnref(defaults);
412
+ const rawInit = shared.toValue(defaults);
400
413
  const type = guessSerializerType(rawInit);
401
414
  const serializer = (_a = options.serializer) != null ? _a : StorageSerializers[type];
402
- const { pause: pauseWatch, resume: resumeWatch } = shared.pausableWatch(data, () => write(data.value), { flush, deep, eventFilter });
415
+ const { pause: pauseWatch, resume: resumeWatch } = shared.pausableWatch(
416
+ data,
417
+ () => write(data.value),
418
+ { flush, deep, eventFilter }
419
+ );
403
420
  if (window && listenToStorageChanges) {
404
421
  useEventListener(window, "storage", update);
405
422
  useEventListener(window, customStorageEventName, updateFromCustomEvent);
@@ -478,9 +495,11 @@ function useStorage(key, defaults, storage, options = {}) {
478
495
 
479
496
  function useMounted() {
480
497
  const isMounted = vueDemi.ref(false);
481
- vueDemi.onMounted(() => {
482
- isMounted.value = true;
483
- });
498
+ if (vueDemi.getCurrentInstance()) {
499
+ vueDemi.onMounted(() => {
500
+ isMounted.value = true;
501
+ });
502
+ }
484
503
  return isMounted;
485
504
  }
486
505
 
@@ -509,8 +528,10 @@ function useMediaQuery(query, options = {}) {
509
528
  if (!isSupported.value)
510
529
  return;
511
530
  cleanup();
512
- mediaQuery = window.matchMedia(shared.resolveRef(query).value);
513
- matches.value = mediaQuery.matches;
531
+ mediaQuery = window.matchMedia(shared.toRef(query).value);
532
+ matches.value = !!(mediaQuery == null ? void 0 : mediaQuery.matches);
533
+ if (!mediaQuery)
534
+ return;
514
535
  if ("addEventListener" in mediaQuery)
515
536
  mediaQuery.addEventListener("change", update);
516
537
  else
@@ -552,7 +573,7 @@ function useColorMode(options = {}) {
552
573
  listenToStorageChanges = true,
553
574
  storageRef,
554
575
  emitAuto,
555
- disableTransition = false
576
+ disableTransition = true
556
577
  } = options;
557
578
  const modes = __spreadValues$b({
558
579
  auto: "",
@@ -560,46 +581,48 @@ function useColorMode(options = {}) {
560
581
  dark: "dark"
561
582
  }, options.modes || {});
562
583
  const preferredDark = usePreferredDark({ window });
563
- const preferredMode = vueDemi.computed(() => preferredDark.value ? "dark" : "light");
584
+ const system = vueDemi.computed(() => preferredDark.value ? "dark" : "light");
564
585
  const store = storageRef || (storageKey == null ? vueDemi.ref(initialValue) : useStorage(storageKey, initialValue, storage, { window, listenToStorageChanges }));
565
586
  const state = vueDemi.computed({
566
587
  get() {
567
- return store.value === "auto" && !emitAuto ? preferredMode.value : store.value;
588
+ return store.value === "auto" && !emitAuto ? system.value : store.value;
568
589
  },
569
590
  set(v) {
570
591
  store.value = v;
571
592
  }
572
593
  });
573
- const updateHTMLAttrs = getSSRHandler("updateHTMLAttrs", (selector2, attribute2, value) => {
574
- const el = window == null ? void 0 : window.document.querySelector(selector2);
575
- if (!el)
576
- return;
577
- let style;
578
- if (disableTransition) {
579
- style = window.document.createElement("style");
580
- style.type = "text/css";
581
- style.appendChild(document.createTextNode("*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}"));
582
- window.document.head.appendChild(style);
583
- }
584
- if (attribute2 === "class") {
585
- const current = value.split(/\s/g);
586
- Object.values(modes).flatMap((i) => (i || "").split(/\s/g)).filter(Boolean).forEach((v) => {
587
- if (current.includes(v))
588
- el.classList.add(v);
589
- else
590
- el.classList.remove(v);
591
- });
592
- } else {
593
- el.setAttribute(attribute2, value);
594
- }
595
- if (disableTransition) {
596
- window.getComputedStyle(style).opacity;
597
- document.head.removeChild(style);
594
+ const updateHTMLAttrs = getSSRHandler(
595
+ "updateHTMLAttrs",
596
+ (selector2, attribute2, value) => {
597
+ const el = typeof selector2 === "string" ? window == null ? void 0 : window.document.querySelector(selector2) : shared.toValue(selector2);
598
+ if (!el)
599
+ return;
600
+ let style;
601
+ if (disableTransition) {
602
+ style = window.document.createElement("style");
603
+ style.appendChild(document.createTextNode("*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}"));
604
+ window.document.head.appendChild(style);
605
+ }
606
+ if (attribute2 === "class") {
607
+ const current = value.split(/\s/g);
608
+ Object.values(modes).flatMap((i) => (i || "").split(/\s/g)).filter(Boolean).forEach((v) => {
609
+ if (current.includes(v))
610
+ el.classList.add(v);
611
+ else
612
+ el.classList.remove(v);
613
+ });
614
+ } else {
615
+ el.setAttribute(attribute2, value);
616
+ }
617
+ if (disableTransition) {
618
+ window.getComputedStyle(style).opacity;
619
+ document.head.removeChild(style);
620
+ }
598
621
  }
599
- });
622
+ );
600
623
  function defaultOnChanged(mode) {
601
624
  var _a;
602
- const resolvedMode = mode === "auto" ? preferredMode.value : mode;
625
+ const resolvedMode = mode === "auto" ? system.value : mode;
603
626
  updateHTMLAttrs(selector, attribute, (_a = modes[resolvedMode]) != null ? _a : resolvedMode);
604
627
  }
605
628
  function onChanged(mode) {
@@ -610,9 +633,13 @@ function useColorMode(options = {}) {
610
633
  }
611
634
  vueDemi.watch(state, onChanged, { flush: "post", immediate: true });
612
635
  if (emitAuto)
613
- vueDemi.watch(preferredMode, () => onChanged(state.value), { flush: "post" });
636
+ vueDemi.watch(system, () => onChanged(state.value), { flush: "post" });
614
637
  shared.tryOnMounted(() => onChanged(state.value));
615
- return state;
638
+ try {
639
+ return Object.assign(state, { store, system });
640
+ } catch (e) {
641
+ return state;
642
+ }
616
643
  }
617
644
 
618
645
  const UseColorMode = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineComponent({
@@ -621,7 +648,9 @@ const UseColorMode = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineComponent({
621
648
  setup(props, { slots }) {
622
649
  const mode = useColorMode(props);
623
650
  const data = vueDemi.reactive({
624
- mode
651
+ mode,
652
+ system: mode.system,
653
+ store: mode.store
625
654
  });
626
655
  return () => {
627
656
  if (slots.default)
@@ -736,7 +765,8 @@ const UseDraggable = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineComponent({
736
765
  "stopPropagation",
737
766
  "pointerTypes",
738
767
  "as",
739
- "handle"
768
+ "handle",
769
+ "axis"
740
770
  ],
741
771
  setup(props, { slots }) {
742
772
  const target = vueDemi.ref();
@@ -744,7 +774,11 @@ const UseDraggable = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineComponent({
744
774
  var _a;
745
775
  return (_a = props.handle) != null ? _a : target.value;
746
776
  });
747
- const storageValue = props.storageKey && core.useStorage(props.storageKey, shared.resolveUnref(props.initialValue) || { x: 0, y: 0 }, core.isClient ? props.storageType === "session" ? sessionStorage : localStorage : void 0);
777
+ const storageValue = props.storageKey && core.useStorage(
778
+ props.storageKey,
779
+ shared.toValue(props.initialValue) || { x: 0, y: 0 },
780
+ core.isClient ? props.storageType === "session" ? sessionStorage : localStorage : void 0
781
+ );
748
782
  const initialValue = storageValue || props.initialValue || { x: 0, y: 0 };
749
783
  const onEnd = (position) => {
750
784
  if (!storageValue)
@@ -850,15 +884,21 @@ function useResizeObserver(target, callback, options = {}) {
850
884
  observer = void 0;
851
885
  }
852
886
  };
853
- const targets = vueDemi.computed(() => Array.isArray(target) ? target.map((el) => unrefElement(el)) : [unrefElement(target)]);
854
- const stopWatch = vueDemi.watch(targets, (els) => {
855
- cleanup();
856
- if (isSupported.value && window) {
857
- observer = new ResizeObserver(callback);
858
- for (const _el of els)
859
- _el && observer.observe(_el, observerOptions);
860
- }
861
- }, { immediate: true, flush: "post", deep: true });
887
+ const targets = vueDemi.computed(
888
+ () => Array.isArray(target) ? target.map((el) => unrefElement(el)) : [unrefElement(target)]
889
+ );
890
+ const stopWatch = vueDemi.watch(
891
+ targets,
892
+ (els) => {
893
+ cleanup();
894
+ if (isSupported.value && window) {
895
+ observer = new ResizeObserver(callback);
896
+ for (const _el of els)
897
+ _el && observer.observe(_el, observerOptions);
898
+ }
899
+ },
900
+ { immediate: true, flush: "post", deep: true }
901
+ );
862
902
  const stop = () => {
863
903
  cleanup();
864
904
  stopWatch();
@@ -878,30 +918,37 @@ function useElementSize(target, initialSize = { width: 0, height: 0 }, options =
878
918
  });
879
919
  const width = vueDemi.ref(initialSize.width);
880
920
  const height = vueDemi.ref(initialSize.height);
881
- useResizeObserver(target, ([entry]) => {
882
- const boxSize = box === "border-box" ? entry.borderBoxSize : box === "content-box" ? entry.contentBoxSize : entry.devicePixelContentBoxSize;
883
- if (window && isSVG.value) {
884
- const $elem = unrefElement(target);
885
- if ($elem) {
886
- const styles = window.getComputedStyle($elem);
887
- width.value = parseFloat(styles.width);
888
- height.value = parseFloat(styles.height);
889
- }
890
- } else {
891
- if (boxSize) {
892
- const formatBoxSize = Array.isArray(boxSize) ? boxSize : [boxSize];
893
- width.value = formatBoxSize.reduce((acc, { inlineSize }) => acc + inlineSize, 0);
894
- height.value = formatBoxSize.reduce((acc, { blockSize }) => acc + blockSize, 0);
921
+ useResizeObserver(
922
+ target,
923
+ ([entry]) => {
924
+ const boxSize = box === "border-box" ? entry.borderBoxSize : box === "content-box" ? entry.contentBoxSize : entry.devicePixelContentBoxSize;
925
+ if (window && isSVG.value) {
926
+ const $elem = unrefElement(target);
927
+ if ($elem) {
928
+ const styles = window.getComputedStyle($elem);
929
+ width.value = parseFloat(styles.width);
930
+ height.value = parseFloat(styles.height);
931
+ }
895
932
  } else {
896
- width.value = entry.contentRect.width;
897
- height.value = entry.contentRect.height;
933
+ if (boxSize) {
934
+ const formatBoxSize = Array.isArray(boxSize) ? boxSize : [boxSize];
935
+ width.value = formatBoxSize.reduce((acc, { inlineSize }) => acc + inlineSize, 0);
936
+ height.value = formatBoxSize.reduce((acc, { blockSize }) => acc + blockSize, 0);
937
+ } else {
938
+ width.value = entry.contentRect.width;
939
+ height.value = entry.contentRect.height;
940
+ }
898
941
  }
942
+ },
943
+ options
944
+ );
945
+ vueDemi.watch(
946
+ () => unrefElement(target),
947
+ (ele) => {
948
+ width.value = ele ? initialSize.width : 0;
949
+ height.value = ele ? initialSize.height : 0;
899
950
  }
900
- }, options);
901
- vueDemi.watch(() => unrefElement(target), (ele) => {
902
- width.value = ele ? initialSize.width : 0;
903
- height.value = ele ? initialSize.height : 0;
904
- });
951
+ );
905
952
  return {
906
953
  width,
907
954
  height
@@ -938,47 +985,68 @@ function useIntersectionObserver(target, callback, options = {}) {
938
985
  root,
939
986
  rootMargin = "0px",
940
987
  threshold = 0.1,
941
- window = defaultWindow
988
+ window = defaultWindow,
989
+ immediate = true
942
990
  } = options;
943
991
  const isSupported = useSupported(() => window && "IntersectionObserver" in window);
944
992
  let cleanup = shared.noop;
945
- const stopWatch = isSupported.value ? vueDemi.watch(() => ({
946
- el: unrefElement(target),
947
- root: unrefElement(root)
948
- }), ({ el, root: root2 }) => {
949
- cleanup();
950
- if (!el)
951
- return;
952
- const observer = new IntersectionObserver(callback, {
953
- root: root2,
954
- rootMargin,
955
- threshold
956
- });
957
- observer.observe(el);
958
- cleanup = () => {
959
- observer.disconnect();
960
- cleanup = shared.noop;
961
- };
962
- }, { immediate: true, flush: "post" }) : shared.noop;
993
+ const isActive = vueDemi.ref(immediate);
994
+ const stopWatch = isSupported.value ? vueDemi.watch(
995
+ () => [unrefElement(target), unrefElement(root), isActive.value],
996
+ ([el, root2]) => {
997
+ cleanup();
998
+ if (!isActive.value)
999
+ return;
1000
+ if (!el)
1001
+ return;
1002
+ const observer = new IntersectionObserver(
1003
+ callback,
1004
+ {
1005
+ root: unrefElement(root2),
1006
+ rootMargin,
1007
+ threshold
1008
+ }
1009
+ );
1010
+ observer.observe(el);
1011
+ cleanup = () => {
1012
+ observer.disconnect();
1013
+ cleanup = shared.noop;
1014
+ };
1015
+ },
1016
+ { immediate, flush: "post" }
1017
+ ) : shared.noop;
963
1018
  const stop = () => {
964
1019
  cleanup();
965
1020
  stopWatch();
1021
+ isActive.value = false;
966
1022
  };
967
1023
  shared.tryOnScopeDispose(stop);
968
1024
  return {
969
1025
  isSupported,
1026
+ isActive,
1027
+ pause() {
1028
+ cleanup();
1029
+ isActive.value = false;
1030
+ },
1031
+ resume() {
1032
+ isActive.value = true;
1033
+ },
970
1034
  stop
971
1035
  };
972
1036
  }
973
1037
 
974
1038
  function useElementVisibility(element, { window = defaultWindow, scrollTarget } = {}) {
975
1039
  const elementIsVisible = vueDemi.ref(false);
976
- useIntersectionObserver(element, ([{ isIntersecting }]) => {
977
- elementIsVisible.value = isIntersecting;
978
- }, {
979
- root: scrollTarget,
980
- window
981
- });
1040
+ useIntersectionObserver(
1041
+ element,
1042
+ ([{ isIntersecting }]) => {
1043
+ elementIsVisible.value = isIntersecting;
1044
+ },
1045
+ {
1046
+ root: scrollTarget,
1047
+ window
1048
+ }
1049
+ );
982
1050
  return elementIsVisible;
983
1051
  }
984
1052
 
@@ -1125,13 +1193,21 @@ async function loadImage(options) {
1125
1193
  img.onerror = reject;
1126
1194
  });
1127
1195
  }
1128
- const useImage = (options, asyncStateOptions = {}) => {
1129
- const state = useAsyncState(() => loadImage(shared.resolveUnref(options)), void 0, __spreadValues$9({
1130
- resetOnExecute: true
1131
- }, asyncStateOptions));
1132
- vueDemi.watch(() => shared.resolveUnref(options), () => state.execute(asyncStateOptions.delay), { deep: true });
1196
+ function useImage(options, asyncStateOptions = {}) {
1197
+ const state = useAsyncState(
1198
+ () => loadImage(shared.toValue(options)),
1199
+ void 0,
1200
+ __spreadValues$9({
1201
+ resetOnExecute: true
1202
+ }, asyncStateOptions)
1203
+ );
1204
+ vueDemi.watch(
1205
+ () => shared.toValue(options),
1206
+ () => state.execute(asyncStateOptions.delay),
1207
+ { deep: true }
1208
+ );
1133
1209
  return state;
1134
- };
1210
+ }
1135
1211
 
1136
1212
  const UseImage = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineComponent({
1137
1213
  name: "UseImage",
@@ -1194,13 +1270,13 @@ function useScroll(element, options = {}) {
1194
1270
  });
1195
1271
  function scrollTo(_x, _y) {
1196
1272
  var _a, _b, _c;
1197
- const _element = shared.resolveUnref(element);
1273
+ const _element = shared.toValue(element);
1198
1274
  if (!_element)
1199
1275
  return;
1200
1276
  (_c = _element instanceof Document ? document.body : _element) == null ? void 0 : _c.scrollTo({
1201
- top: (_a = shared.resolveUnref(_y)) != null ? _a : y.value,
1202
- left: (_b = shared.resolveUnref(_x)) != null ? _b : x.value,
1203
- behavior: shared.resolveUnref(behavior)
1277
+ top: (_a = shared.toValue(_y)) != null ? _a : y.value,
1278
+ left: (_b = shared.toValue(_x)) != null ? _b : x.value,
1279
+ behavior: shared.toValue(behavior)
1204
1280
  });
1205
1281
  }
1206
1282
  const isScrolling = vueDemi.ref(false);
@@ -1229,26 +1305,51 @@ function useScroll(element, options = {}) {
1229
1305
  const onScrollEndDebounced = shared.useDebounceFn(onScrollEnd, throttle + idle);
1230
1306
  const onScrollHandler = (e) => {
1231
1307
  const eventTarget = e.target === document ? e.target.documentElement : e.target;
1308
+ const { display, flexDirection } = getComputedStyle(eventTarget);
1232
1309
  const scrollLeft = eventTarget.scrollLeft;
1233
1310
  directions.left = scrollLeft < internalX.value;
1234
- directions.right = scrollLeft > internalY.value;
1235
- arrivedState.left = scrollLeft <= 0 + (offset.left || 0);
1236
- arrivedState.right = scrollLeft + eventTarget.clientWidth >= eventTarget.scrollWidth - (offset.right || 0) - ARRIVED_STATE_THRESHOLD_PIXELS;
1311
+ directions.right = scrollLeft > internalX.value;
1312
+ const left = Math.abs(scrollLeft) <= 0 + (offset.left || 0);
1313
+ const right = Math.abs(scrollLeft) + eventTarget.clientWidth >= eventTarget.scrollWidth - (offset.right || 0) - ARRIVED_STATE_THRESHOLD_PIXELS;
1314
+ if (display === "flex" && flexDirection === "row-reverse") {
1315
+ arrivedState.left = right;
1316
+ arrivedState.right = left;
1317
+ } else {
1318
+ arrivedState.left = left;
1319
+ arrivedState.right = right;
1320
+ }
1237
1321
  internalX.value = scrollLeft;
1238
1322
  let scrollTop = eventTarget.scrollTop;
1239
1323
  if (e.target === document && !scrollTop)
1240
1324
  scrollTop = document.body.scrollTop;
1241
1325
  directions.top = scrollTop < internalY.value;
1242
1326
  directions.bottom = scrollTop > internalY.value;
1243
- arrivedState.top = scrollTop <= 0 + (offset.top || 0);
1244
- arrivedState.bottom = scrollTop + eventTarget.clientHeight >= eventTarget.scrollHeight - (offset.bottom || 0) - ARRIVED_STATE_THRESHOLD_PIXELS;
1327
+ const top = Math.abs(scrollTop) <= 0 + (offset.top || 0);
1328
+ const bottom = Math.abs(scrollTop) + eventTarget.clientHeight >= eventTarget.scrollHeight - (offset.bottom || 0) - ARRIVED_STATE_THRESHOLD_PIXELS;
1329
+ if (display === "flex" && flexDirection === "column-reverse") {
1330
+ arrivedState.top = bottom;
1331
+ arrivedState.bottom = top;
1332
+ } else {
1333
+ arrivedState.top = top;
1334
+ arrivedState.bottom = bottom;
1335
+ }
1245
1336
  internalY.value = scrollTop;
1246
1337
  isScrolling.value = true;
1247
1338
  onScrollEndDebounced(e);
1248
1339
  onScroll(e);
1249
1340
  };
1250
- useEventListener(element, "scroll", throttle ? shared.useThrottleFn(onScrollHandler, throttle, true, false) : onScrollHandler, eventListenerOptions);
1251
- useEventListener(element, "scrollend", onScrollEnd, eventListenerOptions);
1341
+ useEventListener(
1342
+ element,
1343
+ "scroll",
1344
+ throttle ? shared.useThrottleFn(onScrollHandler, throttle, true, false) : onScrollHandler,
1345
+ eventListenerOptions
1346
+ );
1347
+ useEventListener(
1348
+ element,
1349
+ "scrollend",
1350
+ onScrollEnd,
1351
+ eventListenerOptions
1352
+ );
1252
1353
  return {
1253
1354
  x,
1254
1355
  y,
@@ -1280,30 +1381,36 @@ var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
1280
1381
  function useInfiniteScroll(element, onLoadMore, options = {}) {
1281
1382
  var _a, _b;
1282
1383
  const direction = (_a = options.direction) != null ? _a : "bottom";
1283
- const state = vueDemi.reactive(useScroll(element, __spreadProps$7(__spreadValues$8({}, options), {
1284
- offset: __spreadValues$8({
1285
- [direction]: (_b = options.distance) != null ? _b : 0
1286
- }, options.offset)
1287
- })));
1288
- vueDemi.watch(() => state.arrivedState[direction], async (v) => {
1289
- var _a2, _b2;
1290
- if (v) {
1291
- const elem = shared.resolveUnref(element);
1292
- const previous = {
1293
- height: (_a2 = elem == null ? void 0 : elem.scrollHeight) != null ? _a2 : 0,
1294
- width: (_b2 = elem == null ? void 0 : elem.scrollWidth) != null ? _b2 : 0
1295
- };
1296
- await onLoadMore(state);
1297
- if (options.preserveScrollPosition && elem) {
1298
- vueDemi.nextTick(() => {
1299
- elem.scrollTo({
1300
- top: elem.scrollHeight - previous.height,
1301
- left: elem.scrollWidth - previous.width
1384
+ const state = vueDemi.reactive(useScroll(
1385
+ element,
1386
+ __spreadProps$7(__spreadValues$8({}, options), {
1387
+ offset: __spreadValues$8({
1388
+ [direction]: (_b = options.distance) != null ? _b : 0
1389
+ }, options.offset)
1390
+ })
1391
+ ));
1392
+ vueDemi.watch(
1393
+ () => state.arrivedState[direction],
1394
+ async (v) => {
1395
+ var _a2, _b2;
1396
+ if (v) {
1397
+ const elem = shared.toValue(element);
1398
+ const previous = {
1399
+ height: (_a2 = elem == null ? void 0 : elem.scrollHeight) != null ? _a2 : 0,
1400
+ width: (_b2 = elem == null ? void 0 : elem.scrollWidth) != null ? _b2 : 0
1401
+ };
1402
+ await onLoadMore(state);
1403
+ if (options.preserveScrollPosition && elem) {
1404
+ vueDemi.nextTick(() => {
1405
+ elem.scrollTo({
1406
+ top: elem.scrollHeight - previous.height,
1407
+ left: elem.scrollWidth - previous.width
1408
+ });
1302
1409
  });
1303
- });
1410
+ }
1304
1411
  }
1305
1412
  }
1306
- });
1413
+ );
1307
1414
  }
1308
1415
 
1309
1416
  const vInfiniteScroll = {
@@ -1429,7 +1536,7 @@ const UseObjectUrl = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineComponent({
1429
1536
  "object"
1430
1537
  ],
1431
1538
  setup(props, { slots }) {
1432
- const object = vueDemi.toRef(props, "object");
1539
+ const object = shared.toRef(props, "object");
1433
1540
  const url = core.useObjectUrl(object);
1434
1541
  return () => {
1435
1542
  if (slots.default && url.value)
@@ -1648,8 +1755,8 @@ function useCssVar(prop, target, options = {}) {
1648
1755
  });
1649
1756
  function updateCssVar() {
1650
1757
  var _a;
1651
- const key = shared.resolveUnref(prop);
1652
- const el = shared.resolveUnref(elRef);
1758
+ const key = shared.toValue(prop);
1759
+ const el = shared.toValue(elRef);
1653
1760
  if (el && window) {
1654
1761
  const value = (_a = window.getComputedStyle(el).getPropertyValue(key)) == null ? void 0 : _a.trim();
1655
1762
  variable.value = value || initialValue;
@@ -1661,12 +1768,19 @@ function useCssVar(prop, target, options = {}) {
1661
1768
  window
1662
1769
  });
1663
1770
  }
1664
- vueDemi.watch([elRef, () => shared.resolveUnref(prop)], updateCssVar, { immediate: true });
1665
- vueDemi.watch(variable, (val) => {
1666
- var _a;
1667
- if ((_a = elRef.value) == null ? void 0 : _a.style)
1668
- elRef.value.style.setProperty(shared.resolveUnref(prop), val);
1669
- });
1771
+ vueDemi.watch(
1772
+ [elRef, () => shared.toValue(prop)],
1773
+ updateCssVar,
1774
+ { immediate: true }
1775
+ );
1776
+ vueDemi.watch(
1777
+ variable,
1778
+ (val) => {
1779
+ var _a;
1780
+ if ((_a = elRef.value) == null ? void 0 : _a.style)
1781
+ elRef.value.style.setProperty(shared.toValue(prop), val);
1782
+ }
1783
+ );
1670
1784
  return variable;
1671
1785
  }
1672
1786
 
@@ -1818,7 +1932,7 @@ function useScrollLock(element, initialState = false) {
1818
1932
  const isLocked = vueDemi.ref(initialState);
1819
1933
  let stopTouchMoveListener = null;
1820
1934
  let initialOverflow;
1821
- vueDemi.watch(shared.resolveRef(element), (el) => {
1935
+ vueDemi.watch(shared.toRef(element), (el) => {
1822
1936
  if (el) {
1823
1937
  const ele = el;
1824
1938
  initialOverflow = ele.style.overflow;
@@ -1829,19 +1943,24 @@ function useScrollLock(element, initialState = false) {
1829
1943
  immediate: true
1830
1944
  });
1831
1945
  const lock = () => {
1832
- const ele = shared.resolveUnref(element);
1946
+ const ele = shared.toValue(element);
1833
1947
  if (!ele || isLocked.value)
1834
1948
  return;
1835
1949
  if (shared.isIOS) {
1836
- stopTouchMoveListener = useEventListener(ele, "touchmove", (e) => {
1837
- preventDefault(e);
1838
- }, { passive: false });
1950
+ stopTouchMoveListener = useEventListener(
1951
+ ele,
1952
+ "touchmove",
1953
+ (e) => {
1954
+ preventDefault(e);
1955
+ },
1956
+ { passive: false }
1957
+ );
1839
1958
  }
1840
1959
  ele.style.overflow = "hidden";
1841
1960
  isLocked.value = true;
1842
1961
  };
1843
1962
  const unlock = () => {
1844
- const ele = shared.resolveUnref(element);
1963
+ const ele = shared.toValue(element);
1845
1964
  if (!ele || !isLocked.value)
1846
1965
  return;
1847
1966
  shared.isIOS && (stopTouchMoveListener == null ? void 0 : stopTouchMoveListener());
@@ -1862,7 +1981,7 @@ function useScrollLock(element, initialState = false) {
1862
1981
  });
1863
1982
  }
1864
1983
 
1865
- const onScrollLock = () => {
1984
+ function onScrollLock() {
1866
1985
  let isMounted = false;
1867
1986
  const state = vueDemi.ref(false);
1868
1987
  return (el, binding) => {
@@ -1873,7 +1992,7 @@ const onScrollLock = () => {
1873
1992
  const isLocked = useScrollLock(el, binding.value);
1874
1993
  vueDemi.watch(state, (v) => isLocked.value = v);
1875
1994
  };
1876
- };
1995
+ }
1877
1996
  const vScrollLock = onScrollLock();
1878
1997
 
1879
1998
  var __defProp$2 = Object.defineProperty;
@@ -1966,9 +2085,21 @@ const UseVirtualList = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineComponent({
1966
2085
  const { list, containerProps, wrapperProps, scrollTo } = core.useVirtualList(listRef, props.options);
1967
2086
  expose({ scrollTo });
1968
2087
  typeof containerProps.style === "object" && !Array.isArray(containerProps.style) && (containerProps.style.height = props.height || "300px");
1969
- return () => vueDemi.h("div", __spreadValues({}, containerProps), [
1970
- vueDemi.h("div", __spreadValues({}, wrapperProps.value), list.value.map((item) => vueDemi.h("div", { style: { overFlow: "hidden", height: item.height } }, slots.default ? slots.default(item) : "Please set content!")))
1971
- ]);
2088
+ return () => vueDemi.h(
2089
+ "div",
2090
+ __spreadValues({}, containerProps),
2091
+ [
2092
+ vueDemi.h(
2093
+ "div",
2094
+ __spreadValues({}, wrapperProps.value),
2095
+ list.value.map((item) => vueDemi.h(
2096
+ "div",
2097
+ { style: { overFlow: "hidden", height: item.height } },
2098
+ slots.default ? slots.default(item) : "Please set content!"
2099
+ ))
2100
+ )
2101
+ ]
2102
+ );
1972
2103
  }
1973
2104
  });
1974
2105