@vueuse/components 12.4.0 → 12.6.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 { onClickOutside as onClickOutside$1, useActiveElement, useBattery, useBrowserLocation, useClipboard, useDark, useDeviceMotion, useDeviceOrientation, useDevicePixelRatio, useDevicesList, useDocumentVisibility, useStorage as useStorage$1, isClient as isClient$1, useDraggable, useElementBounding as useElementBounding$1, useElementSize as useElementSize$1, useElementVisibility as useElementVisibility$1, useEyeDropper, useFullscreen, useGeolocation, useIdle, useMouse as useMouse$1, useMouseInElement as useMouseInElement$1, useMousePressed, useNetwork, useNow, useObjectUrl, useOffsetPagination, useOnline, usePageLeave, usePointer, usePointerLock, usePreferredColorScheme, usePreferredContrast, usePreferredDark as usePreferredDark$1, usePreferredLanguages, usePreferredReducedMotion, usePreferredReducedTransparency, useTimeAgo, useTimestamp, useVirtualList, useWindowFocus, useWindowSize } from '@vueuse/core';
2
- import { defineComponent, ref, h, toValue, watch, computed, reactive, hasInjectionContext, getCurrentInstance, onMounted, watchEffect, shallowRef, nextTick, toRefs } from 'vue';
3
- import { isClient, noop, toArray, isObject, tryOnScopeDispose, isIOS, injectLocal, pxValue, pausableWatch, tryOnMounted, toRef, useToggle, notNullish, promiseTimeout, until, useDebounceFn, useThrottleFn, tryOnUnmounted, reactiveOmit } from '@vueuse/shared';
2
+ import { defineComponent, ref, h, toValue, computed, unref, reactive, hasInjectionContext, getCurrentInstance, onMounted, shallowRef, watchEffect, watch, nextTick, toRefs } from 'vue';
3
+ import { isClient, toArray, watchImmediate, isObject, tryOnScopeDispose, noop, isIOS, injectLocal, pxValue, pausableWatch, tryOnMounted, toRef, useToggle, notNullish, watchOnce, promiseTimeout, until, useDebounceFn, useThrottleFn, tryOnUnmounted, reactiveOmit } from '@vueuse/shared';
4
4
 
5
5
  const OnClickOutside = /* @__PURE__ */ /* #__PURE__ */ defineComponent({
6
6
  name: "OnClickOutside",
@@ -18,70 +18,73 @@ const OnClickOutside = /* @__PURE__ */ /* #__PURE__ */ defineComponent({
18
18
  }
19
19
  });
20
20
 
21
- const defaultWindow = isClient ? window : undefined;
21
+ const defaultWindow = isClient ? window : void 0;
22
22
 
23
23
  function unrefElement(elRef) {
24
24
  var _a;
25
25
  const plain = toValue(elRef);
26
- return (_a = plain == null ? undefined : plain.$el) != null ? _a : plain;
26
+ return (_a = plain == null ? void 0 : plain.$el) != null ? _a : plain;
27
27
  }
28
28
 
29
29
  function useEventListener(...args) {
30
- let target;
31
- let events;
32
- let listeners;
33
- let options;
34
- if (typeof args[0] === "string" || Array.isArray(args[0])) {
35
- [events, listeners, options] = args;
36
- target = defaultWindow;
37
- } else {
38
- [target, events, listeners, options] = args;
39
- }
40
- if (!target)
41
- return noop;
42
- events = toArray(events);
43
- listeners = toArray(listeners);
44
30
  const cleanups = [];
45
31
  const cleanup = () => {
46
32
  cleanups.forEach((fn) => fn());
47
33
  cleanups.length = 0;
48
34
  };
49
- const register = (el, event, listener, options2) => {
50
- el.addEventListener(event, listener, options2);
51
- return () => el.removeEventListener(event, listener, options2);
35
+ const register = (el, event, listener, options) => {
36
+ el.addEventListener(event, listener, options);
37
+ return () => el.removeEventListener(event, listener, options);
52
38
  };
53
- const stopWatch = watch(
54
- () => [unrefElement(target), toValue(options)],
55
- ([el, options2]) => {
39
+ const firstParamTargets = computed(() => {
40
+ const test = toArray(toValue(args[0])).filter((e) => e != null);
41
+ return test.every((e) => typeof e !== "string") ? test : void 0;
42
+ });
43
+ const stopWatch = watchImmediate(
44
+ () => {
45
+ var _a, _b;
46
+ return [
47
+ (_b = (_a = firstParamTargets.value) == null ? void 0 : _a.map((e) => unrefElement(e))) != null ? _b : [defaultWindow].filter((e) => e != null),
48
+ toArray(toValue(firstParamTargets.value ? args[1] : args[0])),
49
+ toArray(unref(firstParamTargets.value ? args[2] : args[1])),
50
+ // @ts-expect-error - TypeScript gets the correct types, but somehow still complains
51
+ toValue(firstParamTargets.value ? args[3] : args[2])
52
+ ];
53
+ },
54
+ ([raw_targets, raw_events, raw_listeners, raw_options]) => {
56
55
  cleanup();
57
- if (!el)
56
+ if (!(raw_targets == null ? void 0 : raw_targets.length) || !(raw_events == null ? void 0 : raw_events.length) || !(raw_listeners == null ? void 0 : raw_listeners.length))
58
57
  return;
59
- const optionsClone = isObject(options2) ? { ...options2 } : options2;
58
+ const optionsClone = isObject(raw_options) ? { ...raw_options } : raw_options;
60
59
  cleanups.push(
61
- ...events.flatMap((event) => {
62
- return listeners.map((listener) => register(el, event, listener, optionsClone));
63
- })
60
+ ...raw_targets.flatMap(
61
+ (el) => raw_events.flatMap(
62
+ (event) => raw_listeners.map((listener) => register(el, event, listener, optionsClone))
63
+ )
64
+ )
64
65
  );
65
66
  },
66
- { immediate: true, flush: "post" }
67
+ { flush: "post" }
67
68
  );
68
69
  const stop = () => {
69
70
  stopWatch();
70
71
  cleanup();
71
72
  };
72
- tryOnScopeDispose(stop);
73
+ tryOnScopeDispose(cleanup);
73
74
  return stop;
74
75
  }
75
76
 
76
77
  let _iOSWorkaround = false;
77
78
  function onClickOutside(target, handler, options = {}) {
78
- const { window = defaultWindow, ignore = [], capture = true, detectIframe = false } = options;
79
- if (!window)
80
- return noop;
79
+ const { window = defaultWindow, ignore = [], capture = true, detectIframe = false, controls = false } = options;
80
+ if (!window) {
81
+ return controls ? { stop: noop, cancel: noop, trigger: noop } : noop;
82
+ }
81
83
  if (isIOS && !_iOSWorkaround) {
82
84
  _iOSWorkaround = true;
83
- Array.from(window.document.body.children).forEach((el) => el.addEventListener("click", noop));
84
- window.document.documentElement.addEventListener("click", noop);
85
+ const listenerOptions = { passive: true };
86
+ Array.from(window.document.body.children).forEach((el) => useEventListener(el, "click", noop, listenerOptions));
87
+ useEventListener(window.document.documentElement, "click", noop, listenerOptions);
85
88
  }
86
89
  let shouldListen = true;
87
90
  const shouldIgnore = (event) => {
@@ -113,7 +116,7 @@ function onClickOutside(target, handler, options = {}) {
113
116
  return;
114
117
  if (!el || el === event.target || event.composedPath().includes(el))
115
118
  return;
116
- if (event.detail === 0)
119
+ if ("detail" in event && event.detail === 0)
117
120
  shouldListen = !shouldIgnore(event);
118
121
  if (!shouldListen) {
119
122
  shouldListen = true;
@@ -140,13 +143,26 @@ function onClickOutside(target, handler, options = {}) {
140
143
  setTimeout(() => {
141
144
  var _a;
142
145
  const el = unrefElement(target);
143
- if (((_a = window.document.activeElement) == null ? undefined : _a.tagName) === "IFRAME" && !(el == null ? undefined : el.contains(window.document.activeElement))) {
146
+ if (((_a = window.document.activeElement) == null ? void 0 : _a.tagName) === "IFRAME" && !(el == null ? void 0 : el.contains(window.document.activeElement))) {
144
147
  handler(event);
145
148
  }
146
149
  }, 0);
147
150
  }, { passive: true })
148
151
  ].filter(Boolean);
149
152
  const stop = () => cleanup.forEach((fn) => fn());
153
+ if (controls) {
154
+ return {
155
+ stop,
156
+ cancel: () => {
157
+ shouldListen = false;
158
+ },
159
+ trigger: (event) => {
160
+ shouldListen = true;
161
+ listener(event);
162
+ shouldListen = false;
163
+ }
164
+ };
165
+ }
150
166
  return stop;
151
167
  }
152
168
 
@@ -214,7 +230,7 @@ function onKeyStroke(...args) {
214
230
  const vOnKeyStroke = {
215
231
  mounted(el, binding) {
216
232
  var _a, _b;
217
- const keys = (_b = (_a = binding.arg) == null ? undefined : _a.split(",")) != null ? _b : true;
233
+ const keys = (_b = (_a = binding.arg) == null ? void 0 : _a.split(",")) != null ? _b : true;
218
234
  if (typeof binding.value === "function") {
219
235
  onKeyStroke(keys, binding.value, {
220
236
  target: el
@@ -241,23 +257,23 @@ function onLongPress(target, handler, options) {
241
257
  function clear() {
242
258
  if (timeout) {
243
259
  clearTimeout(timeout);
244
- timeout = undefined;
260
+ timeout = void 0;
245
261
  }
246
- posStart = undefined;
247
- startTimestamp = undefined;
262
+ posStart = void 0;
263
+ startTimestamp = void 0;
248
264
  hasLongPressed = false;
249
265
  }
250
266
  function onRelease(ev) {
251
267
  var _a2, _b2, _c;
252
268
  const [_startTimestamp, _posStart, _hasLongPressed] = [startTimestamp, posStart, hasLongPressed];
253
269
  clear();
254
- if (!(options == null ? undefined : options.onMouseUp) || !_posStart || !_startTimestamp)
270
+ if (!(options == null ? void 0 : options.onMouseUp) || !_posStart || !_startTimestamp)
255
271
  return;
256
- if (((_a2 = options == null ? undefined : options.modifiers) == null ? undefined : _a2.self) && ev.target !== elementRef.value)
272
+ if (((_a2 = options == null ? void 0 : options.modifiers) == null ? void 0 : _a2.self) && ev.target !== elementRef.value)
257
273
  return;
258
- if ((_b2 = options == null ? undefined : options.modifiers) == null ? undefined : _b2.prevent)
274
+ if ((_b2 = options == null ? void 0 : options.modifiers) == null ? void 0 : _b2.prevent)
259
275
  ev.preventDefault();
260
- if ((_c = options == null ? undefined : options.modifiers) == null ? undefined : _c.stop)
276
+ if ((_c = options == null ? void 0 : options.modifiers) == null ? void 0 : _c.stop)
261
277
  ev.stopPropagation();
262
278
  const dx = ev.x - _posStart.x;
263
279
  const dy = ev.y - _posStart.y;
@@ -266,12 +282,12 @@ function onLongPress(target, handler, options) {
266
282
  }
267
283
  function onDown(ev) {
268
284
  var _a2, _b2, _c, _d;
269
- if (((_a2 = options == null ? undefined : options.modifiers) == null ? undefined : _a2.self) && ev.target !== elementRef.value)
285
+ if (((_a2 = options == null ? void 0 : options.modifiers) == null ? void 0 : _a2.self) && ev.target !== elementRef.value)
270
286
  return;
271
287
  clear();
272
- if ((_b2 = options == null ? undefined : options.modifiers) == null ? undefined : _b2.prevent)
288
+ if ((_b2 = options == null ? void 0 : options.modifiers) == null ? void 0 : _b2.prevent)
273
289
  ev.preventDefault();
274
- if ((_c = options == null ? undefined : options.modifiers) == null ? undefined : _c.stop)
290
+ if ((_c = options == null ? void 0 : options.modifiers) == null ? void 0 : _c.stop)
275
291
  ev.stopPropagation();
276
292
  posStart = {
277
293
  x: ev.x,
@@ -283,28 +299,28 @@ function onLongPress(target, handler, options) {
283
299
  hasLongPressed = true;
284
300
  handler(ev);
285
301
  },
286
- (_d = options == null ? undefined : options.delay) != null ? _d : DEFAULT_DELAY
302
+ (_d = options == null ? void 0 : options.delay) != null ? _d : DEFAULT_DELAY
287
303
  );
288
304
  }
289
305
  function onMove(ev) {
290
306
  var _a2, _b2, _c, _d;
291
- if (((_a2 = options == null ? undefined : options.modifiers) == null ? undefined : _a2.self) && ev.target !== elementRef.value)
307
+ if (((_a2 = options == null ? void 0 : options.modifiers) == null ? void 0 : _a2.self) && ev.target !== elementRef.value)
292
308
  return;
293
- if (!posStart || (options == null ? undefined : options.distanceThreshold) === false)
309
+ if (!posStart || (options == null ? void 0 : options.distanceThreshold) === false)
294
310
  return;
295
- if ((_b2 = options == null ? undefined : options.modifiers) == null ? undefined : _b2.prevent)
311
+ if ((_b2 = options == null ? void 0 : options.modifiers) == null ? void 0 : _b2.prevent)
296
312
  ev.preventDefault();
297
- if ((_c = options == null ? undefined : options.modifiers) == null ? undefined : _c.stop)
313
+ if ((_c = options == null ? void 0 : options.modifiers) == null ? void 0 : _c.stop)
298
314
  ev.stopPropagation();
299
315
  const dx = ev.x - posStart.x;
300
316
  const dy = ev.y - posStart.y;
301
317
  const distance = Math.sqrt(dx * dx + dy * dy);
302
- if (distance >= ((_d = options == null ? undefined : options.distanceThreshold) != null ? _d : DEFAULT_THRESHOLD))
318
+ if (distance >= ((_d = options == null ? void 0 : options.distanceThreshold) != null ? _d : DEFAULT_THRESHOLD))
303
319
  clear();
304
320
  }
305
321
  const listenerOptions = {
306
- capture: (_a = options == null ? undefined : options.modifiers) == null ? undefined : _a.capture,
307
- once: (_b = options == null ? undefined : options.modifiers) == null ? undefined : _b.once
322
+ capture: (_a = options == null ? void 0 : options.modifiers) == null ? void 0 : _a.capture,
323
+ once: (_b = options == null ? void 0 : options.modifiers) == null ? void 0 : _b.once
308
324
  };
309
325
  const cleanup = [
310
326
  useEventListener(elementRef, "pointerdown", onDown, listenerOptions),
@@ -392,7 +408,7 @@ const UseClipboard = /* @__PURE__ */ /* #__PURE__ */ defineComponent({
392
408
  const data = reactive(useClipboard(props));
393
409
  return () => {
394
410
  var _a;
395
- return (_a = slots.default) == null ? undefined : _a.call(slots, data);
411
+ return (_a = slots.default) == null ? void 0 : _a.call(slots, data);
396
412
  };
397
413
  }
398
414
  });
@@ -412,7 +428,7 @@ function getSSRHandler(key, fallback) {
412
428
  const ssrWidthSymbol = Symbol("vueuse-ssr-width");
413
429
  function useSSRWidth() {
414
430
  const ssrWidth = hasInjectionContext() ? injectLocal(ssrWidthSymbol, null) : null;
415
- return typeof ssrWidth === "number" ? ssrWidth : undefined;
431
+ return typeof ssrWidth === "number" ? ssrWidth : void 0;
416
432
  }
417
433
 
418
434
  function useMounted() {
@@ -438,20 +454,12 @@ function useMediaQuery(query, options = {}) {
438
454
  const { window = defaultWindow, ssrWidth = useSSRWidth() } = options;
439
455
  const isSupported = useSupported(() => window && "matchMedia" in window && typeof window.matchMedia === "function");
440
456
  const ssrSupport = ref(typeof ssrWidth === "number");
441
- let mediaQuery;
457
+ const mediaQuery = shallowRef();
442
458
  const matches = ref(false);
443
459
  const handler = (event) => {
444
460
  matches.value = event.matches;
445
461
  };
446
- const cleanup = () => {
447
- if (!mediaQuery)
448
- return;
449
- if ("removeEventListener" in mediaQuery)
450
- mediaQuery.removeEventListener("change", handler);
451
- else
452
- mediaQuery.removeListener(handler);
453
- };
454
- const stopWatch = watchEffect(() => {
462
+ watchEffect(() => {
455
463
  if (ssrSupport.value) {
456
464
  ssrSupport.value = !isSupported.value;
457
465
  const queryStrings = toValue(query).split(",");
@@ -472,19 +480,10 @@ function useMediaQuery(query, options = {}) {
472
480
  }
473
481
  if (!isSupported.value)
474
482
  return;
475
- cleanup();
476
- mediaQuery = window.matchMedia(toValue(query));
477
- if ("addEventListener" in mediaQuery)
478
- mediaQuery.addEventListener("change", handler);
479
- else
480
- mediaQuery.addListener(handler);
481
- matches.value = mediaQuery.matches;
482
- });
483
- tryOnScopeDispose(() => {
484
- stopWatch();
485
- cleanup();
486
- mediaQuery = undefined;
483
+ mediaQuery.value = window.matchMedia(toValue(query));
484
+ matches.value = mediaQuery.value.matches;
487
485
  });
486
+ useEventListener(mediaQuery, "change", handler, { passive: true });
488
487
  return computed(() => matches.value);
489
488
  }
490
489
 
@@ -686,7 +685,7 @@ function useColorMode(options = {}) {
686
685
  const updateHTMLAttrs = getSSRHandler(
687
686
  "updateHTMLAttrs",
688
687
  (selector2, attribute2, value) => {
689
- const el = typeof selector2 === "string" ? window == null ? undefined : window.document.querySelector(selector2) : unrefElement(selector2);
688
+ const el = typeof selector2 === "string" ? window == null ? void 0 : window.document.querySelector(selector2) : unrefElement(selector2);
690
689
  if (!el)
691
690
  return;
692
691
  const classesToAdd = /* @__PURE__ */ new Set();
@@ -870,18 +869,18 @@ const UseDraggable = /* @__PURE__ */ /* #__PURE__ */ defineComponent({
870
869
  });
871
870
  const containerElement = computed(() => {
872
871
  var _a;
873
- return (_a = props.containerElement) != null ? _a : undefined;
872
+ return (_a = props.containerElement) != null ? _a : void 0;
874
873
  });
875
874
  const disabled = computed(() => !!props.disabled);
876
875
  const storageValue = props.storageKey && useStorage$1(
877
876
  props.storageKey,
878
877
  toValue(props.initialValue) || { x: 0, y: 0 },
879
- isClient$1 ? props.storageType === "session" ? sessionStorage : localStorage : undefined
878
+ isClient$1 ? props.storageType === "session" ? sessionStorage : localStorage : void 0
880
879
  );
881
880
  const initialValue = storageValue || props.initialValue || { x: 0, y: 0 };
882
881
  const onEnd = (position, event) => {
883
882
  var _a;
884
- (_a = props.onEnd) == null ? undefined : _a.call(props, position, event);
883
+ (_a = props.onEnd) == null ? void 0 : _a.call(props, position, event);
885
884
  if (!storageValue)
886
885
  return;
887
886
  storageValue.value.x = position.x;
@@ -922,7 +921,7 @@ function useMutationObserver(target, callback, options = {}) {
922
921
  const cleanup = () => {
923
922
  if (observer) {
924
923
  observer.disconnect();
925
- observer = undefined;
924
+ observer = void 0;
926
925
  }
927
926
  };
928
927
  const targets = computed(() => {
@@ -942,7 +941,7 @@ function useMutationObserver(target, callback, options = {}) {
942
941
  { immediate: true, flush: "post" }
943
942
  );
944
943
  const takeRecords = () => {
945
- return observer == null ? undefined : observer.takeRecords();
944
+ return observer == null ? void 0 : observer.takeRecords();
946
945
  };
947
946
  const stop = () => {
948
947
  stopWatch();
@@ -963,7 +962,7 @@ function useResizeObserver(target, callback, options = {}) {
963
962
  const cleanup = () => {
964
963
  if (observer) {
965
964
  observer.disconnect();
966
- observer = undefined;
965
+ observer = void 0;
967
966
  }
968
967
  };
969
968
  const targets = computed(() => {
@@ -1088,14 +1087,14 @@ const vElementBounding = {
1088
1087
  function onElementRemoval(target, callback, options = {}) {
1089
1088
  const {
1090
1089
  window = defaultWindow,
1091
- document = window == null ? undefined : window.document,
1090
+ document = window == null ? void 0 : window.document,
1092
1091
  flush = "sync"
1093
1092
  } = options;
1094
1093
  if (!window || !document)
1095
1094
  return noop;
1096
1095
  let stopFn;
1097
1096
  const cleanupAndUpdate = (fn) => {
1098
- stopFn == null ? undefined : stopFn();
1097
+ stopFn == null ? void 0 : stopFn();
1099
1098
  stopFn = fn;
1100
1099
  };
1101
1100
  const stopWatch = watchEffect(() => {
@@ -1139,7 +1138,7 @@ function useElementHover(el, options = {}) {
1139
1138
  const delay = entering ? delayEnter : delayLeave;
1140
1139
  if (timer) {
1141
1140
  clearTimeout(timer);
1142
- timer = undefined;
1141
+ timer = void 0;
1143
1142
  }
1144
1143
  if (delay)
1145
1144
  timer = setTimeout(() => isHovered.value = entering, delay);
@@ -1190,7 +1189,7 @@ function useElementSize(target, initialSize = { width: 0, height: 0 }, options =
1190
1189
  const { window = defaultWindow, box = "content-box" } = options;
1191
1190
  const isSVG = computed(() => {
1192
1191
  var _a, _b;
1193
- return (_b = (_a = unrefElement(target)) == null ? undefined : _a.namespaceURI) == null ? undefined : _b.includes("svg");
1192
+ return (_b = (_a = unrefElement(target)) == null ? void 0 : _a.namespaceURI) == null ? void 0 : _b.includes("svg");
1194
1193
  });
1195
1194
  const width = ref(initialSize.width);
1196
1195
  const height = ref(initialSize.height);
@@ -1246,7 +1245,7 @@ function useElementSize(target, initialSize = { width: 0, height: 0 }, options =
1246
1245
  const vElementSize = {
1247
1246
  mounted(el, binding) {
1248
1247
  var _a;
1249
- const handler = typeof binding.value === "function" ? binding.value : (_a = binding.value) == null ? undefined : _a[0];
1248
+ const handler = typeof binding.value === "function" ? binding.value : (_a = binding.value) == null ? void 0 : _a[0];
1250
1249
  const options = typeof binding.value === "function" ? [] : binding.value.slice(1);
1251
1250
  const { width, height } = useElementSize(el, ...options);
1252
1251
  watch([width, height], ([width2, height2]) => handler({ width: width2, height: height2 }));
@@ -1332,10 +1331,11 @@ function useElementVisibility(element, options = {}) {
1332
1331
  window = defaultWindow,
1333
1332
  scrollTarget,
1334
1333
  threshold = 0,
1335
- rootMargin
1334
+ rootMargin,
1335
+ once = false
1336
1336
  } = options;
1337
1337
  const elementIsVisible = ref(false);
1338
- useIntersectionObserver(
1338
+ const { stop } = useIntersectionObserver(
1339
1339
  element,
1340
1340
  (intersectionObserverEntries) => {
1341
1341
  let isIntersecting = elementIsVisible.value;
@@ -1347,6 +1347,11 @@ function useElementVisibility(element, options = {}) {
1347
1347
  }
1348
1348
  }
1349
1349
  elementIsVisible.value = isIntersecting;
1350
+ if (once) {
1351
+ watchOnce(elementIsVisible, () => {
1352
+ stop();
1353
+ });
1354
+ }
1350
1355
  },
1351
1356
  {
1352
1357
  root: scrollTarget,
@@ -1436,11 +1441,11 @@ function useAsyncState(promise, initialState, options) {
1436
1441
  const state = shallow ? shallowRef(initialState) : ref(initialState);
1437
1442
  const isReady = ref(false);
1438
1443
  const isLoading = ref(false);
1439
- const error = shallowRef(undefined);
1444
+ const error = shallowRef(void 0);
1440
1445
  async function execute(delay2 = 0, ...args) {
1441
1446
  if (resetOnExecute)
1442
1447
  state.value = initialState;
1443
- error.value = undefined;
1448
+ error.value = void 0;
1444
1449
  isReady.value = false;
1445
1450
  isLoading.value = true;
1446
1451
  if (delay2 > 0)
@@ -1520,7 +1525,7 @@ async function loadImage(options) {
1520
1525
  function useImage(options, asyncStateOptions = {}) {
1521
1526
  const state = useAsyncState(
1522
1527
  () => loadImage(toValue(options)),
1523
- undefined,
1528
+ void 0,
1524
1529
  {
1525
1530
  resetOnExecute: true,
1526
1531
  ...asyncStateOptions
@@ -1605,7 +1610,7 @@ function useScroll(element, options = {}) {
1605
1610
  return internalX.value;
1606
1611
  },
1607
1612
  set(x2) {
1608
- scrollTo(x2, undefined);
1613
+ scrollTo(x2, void 0);
1609
1614
  }
1610
1615
  });
1611
1616
  const y = computed({
@@ -1613,7 +1618,7 @@ function useScroll(element, options = {}) {
1613
1618
  return internalY.value;
1614
1619
  },
1615
1620
  set(y2) {
1616
- scrollTo(undefined, y2);
1621
+ scrollTo(void 0, y2);
1617
1622
  }
1618
1623
  });
1619
1624
  function scrollTo(_x, _y) {
@@ -1623,12 +1628,12 @@ function useScroll(element, options = {}) {
1623
1628
  const _element = toValue(element);
1624
1629
  if (!_element)
1625
1630
  return;
1626
- (_c = _element instanceof Document ? window.document.body : _element) == null ? undefined : _c.scrollTo({
1631
+ (_c = _element instanceof Document ? window.document.body : _element) == null ? void 0 : _c.scrollTo({
1627
1632
  top: (_a = toValue(_y)) != null ? _a : y.value,
1628
1633
  left: (_b = toValue(_x)) != null ? _b : x.value,
1629
1634
  behavior: toValue(behavior)
1630
1635
  });
1631
- const scrollContainer = ((_d = _element == null ? undefined : _element.document) == null ? undefined : _d.documentElement) || (_element == null ? undefined : _element.documentElement) || _element;
1636
+ const scrollContainer = ((_d = _element == null ? void 0 : _element.document) == null ? void 0 : _d.documentElement) || (_element == null ? void 0 : _element.documentElement) || _element;
1632
1637
  if (x != null)
1633
1638
  internalX.value = scrollContainer.scrollLeft;
1634
1639
  if (y != null)
@@ -1662,7 +1667,7 @@ function useScroll(element, options = {}) {
1662
1667
  var _a;
1663
1668
  if (!window)
1664
1669
  return;
1665
- const el = ((_a = target == null ? undefined : target.document) == null ? undefined : _a.documentElement) || (target == null ? undefined : target.documentElement) || unrefElement(target);
1670
+ const el = ((_a = target == null ? void 0 : target.document) == null ? void 0 : _a.documentElement) || (target == null ? void 0 : target.documentElement) || unrefElement(target);
1666
1671
  const { display, flexDirection, direction } = getComputedStyle(el);
1667
1672
  const directionMultipler = direction === "rtl" ? -1 : 1;
1668
1673
  const scrollLeft = el.scrollLeft;
@@ -1842,7 +1847,7 @@ const UseMouseBuiltinExtractors = {
1842
1847
  page: (event) => [event.pageX, event.pageY],
1843
1848
  client: (event) => [event.clientX, event.clientY],
1844
1849
  screen: (event) => [event.screenX, event.screenY],
1845
- movement: (event) => event instanceof Touch ? null : [event.movementX, event.movementY]
1850
+ movement: (event) => event instanceof MouseEvent ? [event.movementX, event.movementY] : null
1846
1851
  };
1847
1852
  function useMouse(options = {}) {
1848
1853
  const {
@@ -1924,7 +1929,7 @@ function useMouseInElement(target, options = {}) {
1924
1929
  } = options;
1925
1930
  const type = options.type || "page";
1926
1931
  const { x, y, sourceType } = useMouse(options);
1927
- const targetRef = ref(target != null ? target : window == null ? undefined : window.document.body);
1932
+ const targetRef = ref(target != null ? target : window == null ? void 0 : window.document.body);
1928
1933
  const elementX = ref(0);
1929
1934
  const elementY = ref(0);
1930
1935
  const elementPositionX = ref(0);
@@ -2062,17 +2067,17 @@ const UseOffsetPagination = /* @__PURE__ */ /* #__PURE__ */ defineComponent({
2062
2067
  ...props,
2063
2068
  onPageChange(...args) {
2064
2069
  var _a;
2065
- (_a = props.onPageChange) == null ? undefined : _a.call(props, ...args);
2070
+ (_a = props.onPageChange) == null ? void 0 : _a.call(props, ...args);
2066
2071
  emit("page-change", ...args);
2067
2072
  },
2068
2073
  onPageSizeChange(...args) {
2069
2074
  var _a;
2070
- (_a = props.onPageSizeChange) == null ? undefined : _a.call(props, ...args);
2075
+ (_a = props.onPageSizeChange) == null ? void 0 : _a.call(props, ...args);
2071
2076
  emit("page-size-change", ...args);
2072
2077
  },
2073
2078
  onPageCountChange(...args) {
2074
2079
  var _a;
2075
- (_a = props.onPageCountChange) == null ? undefined : _a.call(props, ...args);
2080
+ (_a = props.onPageCountChange) == null ? void 0 : _a.call(props, ...args);
2076
2081
  emit("page-count-change", ...args);
2077
2082
  }
2078
2083
  }));
@@ -2234,15 +2239,15 @@ function useCssVar(prop, target, options = {}) {
2234
2239
  const variable = ref(initialValue);
2235
2240
  const elRef = computed(() => {
2236
2241
  var _a;
2237
- return unrefElement(target) || ((_a = window == null ? undefined : window.document) == null ? undefined : _a.documentElement);
2242
+ return unrefElement(target) || ((_a = window == null ? void 0 : window.document) == null ? void 0 : _a.documentElement);
2238
2243
  });
2239
2244
  function updateCssVar() {
2240
2245
  var _a;
2241
2246
  const key = toValue(prop);
2242
2247
  const el = toValue(elRef);
2243
2248
  if (el && window && key) {
2244
- const value = (_a = window.getComputedStyle(el).getPropertyValue(key)) == null ? undefined : _a.trim();
2245
- variable.value = value || initialValue;
2249
+ const value = (_a = window.getComputedStyle(el).getPropertyValue(key)) == null ? void 0 : _a.trim();
2250
+ variable.value = value || variable.value || initialValue;
2246
2251
  }
2247
2252
  }
2248
2253
  if (observe) {
@@ -2257,21 +2262,20 @@ function useCssVar(prop, target, options = {}) {
2257
2262
  if (old[0] && old[1])
2258
2263
  old[0].style.removeProperty(old[1]);
2259
2264
  updateCssVar();
2260
- },
2261
- { immediate: true }
2265
+ }
2262
2266
  );
2263
2267
  watch(
2264
- variable,
2265
- (val) => {
2266
- var _a;
2268
+ [variable, elRef],
2269
+ ([val, el]) => {
2267
2270
  const raw_prop = toValue(prop);
2268
- if (((_a = elRef.value) == null ? undefined : _a.style) && raw_prop) {
2271
+ if ((el == null ? void 0 : el.style) && raw_prop) {
2269
2272
  if (val == null)
2270
- elRef.value.style.removeProperty(raw_prop);
2273
+ el.style.removeProperty(raw_prop);
2271
2274
  else
2272
- elRef.value.style.setProperty(raw_prop, val);
2275
+ el.style.setProperty(raw_prop, val);
2273
2276
  }
2274
- }
2277
+ },
2278
+ { immediate: true }
2275
2279
  );
2276
2280
  return variable;
2277
2281
  }
@@ -2367,12 +2371,12 @@ const vScroll = {
2367
2371
  ...options,
2368
2372
  onScroll(e) {
2369
2373
  var _a;
2370
- (_a = options.onScroll) == null ? undefined : _a.call(options, e);
2374
+ (_a = options.onScroll) == null ? void 0 : _a.call(options, e);
2371
2375
  handler(state);
2372
2376
  },
2373
2377
  onStop(e) {
2374
2378
  var _a;
2375
- (_a = options.onStop) == null ? undefined : _a.call(options, e);
2379
+ (_a = options.onStop) == null ? void 0 : _a.call(options, e);
2376
2380
  handler(state);
2377
2381
  }
2378
2382
  });
@@ -2445,7 +2449,7 @@ function useScrollLock(element, initialState = false) {
2445
2449
  if (!el || !isLocked.value)
2446
2450
  return;
2447
2451
  if (isIOS)
2448
- stopTouchMoveListener == null ? undefined : stopTouchMoveListener();
2452
+ stopTouchMoveListener == null ? void 0 : stopTouchMoveListener();
2449
2453
  el.style.overflow = initialOverflow;
2450
2454
  elInitialOverflow.delete(el);
2451
2455
  isLocked.value = false;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vueuse/components",
3
3
  "type": "module",
4
- "version": "12.4.0",
4
+ "version": "12.6.0",
5
5
  "description": "Renderless components for VueUse",
6
6
  "author": "Jacob Clevenger<https://github.com/wheatjs>",
7
7
  "license": "MIT",
@@ -42,8 +42,8 @@
42
42
  ],
43
43
  "dependencies": {
44
44
  "vue": "^3.5.13",
45
- "@vueuse/core": "12.4.0",
46
- "@vueuse/shared": "12.4.0"
45
+ "@vueuse/core": "12.6.0",
46
+ "@vueuse/shared": "12.6.0"
47
47
  },
48
48
  "scripts": {
49
49
  "build": "rollup --config=rollup.config.ts --configPlugin=rollup-plugin-esbuild"