@vueuse/components 12.3.0 → 12.5.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.cjs +111 -120
- package/index.iife.js +111 -120
- package/index.iife.min.js +1 -1
- package/index.mjs +113 -122
- package/package.json +3 -3
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,
|
|
3
|
-
import { isClient,
|
|
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, promiseTimeout, until, useDebounceFn, useThrottleFn, tryOnUnmounted, reactiveOmit } from '@vueuse/shared';
|
|
4
4
|
|
|
5
5
|
const OnClickOutside = /* @__PURE__ */ /* #__PURE__ */ defineComponent({
|
|
6
6
|
name: "OnClickOutside",
|
|
@@ -18,58 +18,59 @@ const OnClickOutside = /* @__PURE__ */ /* #__PURE__ */ defineComponent({
|
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
-
const defaultWindow = isClient ? window :
|
|
21
|
+
const defaultWindow = isClient ? window : undefined;
|
|
22
22
|
|
|
23
23
|
function unrefElement(elRef) {
|
|
24
24
|
var _a;
|
|
25
25
|
const plain = toValue(elRef);
|
|
26
|
-
return (_a = plain == null ?
|
|
26
|
+
return (_a = plain == null ? undefined : 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,
|
|
50
|
-
el.addEventListener(event, listener,
|
|
51
|
-
return () => el.removeEventListener(event, listener,
|
|
35
|
+
const register = (el, event, listener, options) => {
|
|
36
|
+
el.addEventListener(event, listener, options);
|
|
37
|
+
return () => el.removeEventListener(event, listener, options);
|
|
52
38
|
};
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
(
|
|
39
|
+
const firstParamTargets = computed(() => {
|
|
40
|
+
const test = toArray(toValue(args[0])).filter((e) => e != null);
|
|
41
|
+
return test.every((e) => typeof e !== "string") ? test : undefined;
|
|
42
|
+
});
|
|
43
|
+
const stopWatch = watchImmediate(
|
|
44
|
+
() => {
|
|
45
|
+
var _a, _b;
|
|
46
|
+
return [
|
|
47
|
+
(_b = (_a = firstParamTargets.value) == null ? undefined : _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 (!
|
|
56
|
+
if (!(raw_targets == null ? undefined : raw_targets.length) || !(raw_events == null ? undefined : raw_events.length) || !(raw_listeners == null ? undefined : raw_listeners.length))
|
|
58
57
|
return;
|
|
59
|
-
const optionsClone = isObject(
|
|
58
|
+
const optionsClone = isObject(raw_options) ? { ...raw_options } : raw_options;
|
|
60
59
|
cleanups.push(
|
|
61
|
-
...
|
|
62
|
-
|
|
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
|
-
{
|
|
67
|
+
{ flush: "post" }
|
|
67
68
|
);
|
|
68
69
|
const stop = () => {
|
|
69
70
|
stopWatch();
|
|
70
71
|
cleanup();
|
|
71
72
|
};
|
|
72
|
-
tryOnScopeDispose(
|
|
73
|
+
tryOnScopeDispose(cleanup);
|
|
73
74
|
return stop;
|
|
74
75
|
}
|
|
75
76
|
|
|
@@ -80,8 +81,9 @@ function onClickOutside(target, handler, options = {}) {
|
|
|
80
81
|
return noop;
|
|
81
82
|
if (isIOS && !_iOSWorkaround) {
|
|
82
83
|
_iOSWorkaround = true;
|
|
83
|
-
|
|
84
|
-
window.document.
|
|
84
|
+
const listenerOptions = { passive: true };
|
|
85
|
+
Array.from(window.document.body.children).forEach((el) => useEventListener(el, "click", noop, listenerOptions));
|
|
86
|
+
useEventListener(window.document.documentElement, "click", noop, listenerOptions);
|
|
85
87
|
}
|
|
86
88
|
let shouldListen = true;
|
|
87
89
|
const shouldIgnore = (event) => {
|
|
@@ -140,11 +142,11 @@ function onClickOutside(target, handler, options = {}) {
|
|
|
140
142
|
setTimeout(() => {
|
|
141
143
|
var _a;
|
|
142
144
|
const el = unrefElement(target);
|
|
143
|
-
if (((_a = window.document.activeElement) == null ?
|
|
145
|
+
if (((_a = window.document.activeElement) == null ? undefined : _a.tagName) === "IFRAME" && !(el == null ? undefined : el.contains(window.document.activeElement))) {
|
|
144
146
|
handler(event);
|
|
145
147
|
}
|
|
146
148
|
}, 0);
|
|
147
|
-
})
|
|
149
|
+
}, { passive: true })
|
|
148
150
|
].filter(Boolean);
|
|
149
151
|
const stop = () => cleanup.forEach((fn) => fn());
|
|
150
152
|
return stop;
|
|
@@ -214,7 +216,7 @@ function onKeyStroke(...args) {
|
|
|
214
216
|
const vOnKeyStroke = {
|
|
215
217
|
mounted(el, binding) {
|
|
216
218
|
var _a, _b;
|
|
217
|
-
const keys = (_b = (_a = binding.arg) == null ?
|
|
219
|
+
const keys = (_b = (_a = binding.arg) == null ? undefined : _a.split(",")) != null ? _b : true;
|
|
218
220
|
if (typeof binding.value === "function") {
|
|
219
221
|
onKeyStroke(keys, binding.value, {
|
|
220
222
|
target: el
|
|
@@ -241,23 +243,23 @@ function onLongPress(target, handler, options) {
|
|
|
241
243
|
function clear() {
|
|
242
244
|
if (timeout) {
|
|
243
245
|
clearTimeout(timeout);
|
|
244
|
-
timeout =
|
|
246
|
+
timeout = undefined;
|
|
245
247
|
}
|
|
246
|
-
posStart =
|
|
247
|
-
startTimestamp =
|
|
248
|
+
posStart = undefined;
|
|
249
|
+
startTimestamp = undefined;
|
|
248
250
|
hasLongPressed = false;
|
|
249
251
|
}
|
|
250
252
|
function onRelease(ev) {
|
|
251
253
|
var _a2, _b2, _c;
|
|
252
254
|
const [_startTimestamp, _posStart, _hasLongPressed] = [startTimestamp, posStart, hasLongPressed];
|
|
253
255
|
clear();
|
|
254
|
-
if (!(options == null ?
|
|
256
|
+
if (!(options == null ? undefined : options.onMouseUp) || !_posStart || !_startTimestamp)
|
|
255
257
|
return;
|
|
256
|
-
if (((_a2 = options == null ?
|
|
258
|
+
if (((_a2 = options == null ? undefined : options.modifiers) == null ? undefined : _a2.self) && ev.target !== elementRef.value)
|
|
257
259
|
return;
|
|
258
|
-
if ((_b2 = options == null ?
|
|
260
|
+
if ((_b2 = options == null ? undefined : options.modifiers) == null ? undefined : _b2.prevent)
|
|
259
261
|
ev.preventDefault();
|
|
260
|
-
if ((_c = options == null ?
|
|
262
|
+
if ((_c = options == null ? undefined : options.modifiers) == null ? undefined : _c.stop)
|
|
261
263
|
ev.stopPropagation();
|
|
262
264
|
const dx = ev.x - _posStart.x;
|
|
263
265
|
const dy = ev.y - _posStart.y;
|
|
@@ -266,12 +268,12 @@ function onLongPress(target, handler, options) {
|
|
|
266
268
|
}
|
|
267
269
|
function onDown(ev) {
|
|
268
270
|
var _a2, _b2, _c, _d;
|
|
269
|
-
if (((_a2 = options == null ?
|
|
271
|
+
if (((_a2 = options == null ? undefined : options.modifiers) == null ? undefined : _a2.self) && ev.target !== elementRef.value)
|
|
270
272
|
return;
|
|
271
273
|
clear();
|
|
272
|
-
if ((_b2 = options == null ?
|
|
274
|
+
if ((_b2 = options == null ? undefined : options.modifiers) == null ? undefined : _b2.prevent)
|
|
273
275
|
ev.preventDefault();
|
|
274
|
-
if ((_c = options == null ?
|
|
276
|
+
if ((_c = options == null ? undefined : options.modifiers) == null ? undefined : _c.stop)
|
|
275
277
|
ev.stopPropagation();
|
|
276
278
|
posStart = {
|
|
277
279
|
x: ev.x,
|
|
@@ -283,28 +285,28 @@ function onLongPress(target, handler, options) {
|
|
|
283
285
|
hasLongPressed = true;
|
|
284
286
|
handler(ev);
|
|
285
287
|
},
|
|
286
|
-
(_d = options == null ?
|
|
288
|
+
(_d = options == null ? undefined : options.delay) != null ? _d : DEFAULT_DELAY
|
|
287
289
|
);
|
|
288
290
|
}
|
|
289
291
|
function onMove(ev) {
|
|
290
292
|
var _a2, _b2, _c, _d;
|
|
291
|
-
if (((_a2 = options == null ?
|
|
293
|
+
if (((_a2 = options == null ? undefined : options.modifiers) == null ? undefined : _a2.self) && ev.target !== elementRef.value)
|
|
292
294
|
return;
|
|
293
|
-
if (!posStart || (options == null ?
|
|
295
|
+
if (!posStart || (options == null ? undefined : options.distanceThreshold) === false)
|
|
294
296
|
return;
|
|
295
|
-
if ((_b2 = options == null ?
|
|
297
|
+
if ((_b2 = options == null ? undefined : options.modifiers) == null ? undefined : _b2.prevent)
|
|
296
298
|
ev.preventDefault();
|
|
297
|
-
if ((_c = options == null ?
|
|
299
|
+
if ((_c = options == null ? undefined : options.modifiers) == null ? undefined : _c.stop)
|
|
298
300
|
ev.stopPropagation();
|
|
299
301
|
const dx = ev.x - posStart.x;
|
|
300
302
|
const dy = ev.y - posStart.y;
|
|
301
303
|
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
302
|
-
if (distance >= ((_d = options == null ?
|
|
304
|
+
if (distance >= ((_d = options == null ? undefined : options.distanceThreshold) != null ? _d : DEFAULT_THRESHOLD))
|
|
303
305
|
clear();
|
|
304
306
|
}
|
|
305
307
|
const listenerOptions = {
|
|
306
|
-
capture: (_a = options == null ?
|
|
307
|
-
once: (_b = options == null ?
|
|
308
|
+
capture: (_a = options == null ? undefined : options.modifiers) == null ? undefined : _a.capture,
|
|
309
|
+
once: (_b = options == null ? undefined : options.modifiers) == null ? undefined : _b.once
|
|
308
310
|
};
|
|
309
311
|
const cleanup = [
|
|
310
312
|
useEventListener(elementRef, "pointerdown", onDown, listenerOptions),
|
|
@@ -392,7 +394,7 @@ const UseClipboard = /* @__PURE__ */ /* #__PURE__ */ defineComponent({
|
|
|
392
394
|
const data = reactive(useClipboard(props));
|
|
393
395
|
return () => {
|
|
394
396
|
var _a;
|
|
395
|
-
return (_a = slots.default) == null ?
|
|
397
|
+
return (_a = slots.default) == null ? undefined : _a.call(slots, data);
|
|
396
398
|
};
|
|
397
399
|
}
|
|
398
400
|
});
|
|
@@ -412,7 +414,7 @@ function getSSRHandler(key, fallback) {
|
|
|
412
414
|
const ssrWidthSymbol = Symbol("vueuse-ssr-width");
|
|
413
415
|
function useSSRWidth() {
|
|
414
416
|
const ssrWidth = hasInjectionContext() ? injectLocal(ssrWidthSymbol, null) : null;
|
|
415
|
-
return typeof ssrWidth === "number" ? ssrWidth :
|
|
417
|
+
return typeof ssrWidth === "number" ? ssrWidth : undefined;
|
|
416
418
|
}
|
|
417
419
|
|
|
418
420
|
function useMounted() {
|
|
@@ -438,20 +440,12 @@ function useMediaQuery(query, options = {}) {
|
|
|
438
440
|
const { window = defaultWindow, ssrWidth = useSSRWidth() } = options;
|
|
439
441
|
const isSupported = useSupported(() => window && "matchMedia" in window && typeof window.matchMedia === "function");
|
|
440
442
|
const ssrSupport = ref(typeof ssrWidth === "number");
|
|
441
|
-
|
|
443
|
+
const mediaQuery = shallowRef();
|
|
442
444
|
const matches = ref(false);
|
|
443
445
|
const handler = (event) => {
|
|
444
446
|
matches.value = event.matches;
|
|
445
447
|
};
|
|
446
|
-
|
|
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(() => {
|
|
448
|
+
watchEffect(() => {
|
|
455
449
|
if (ssrSupport.value) {
|
|
456
450
|
ssrSupport.value = !isSupported.value;
|
|
457
451
|
const queryStrings = toValue(query).split(",");
|
|
@@ -472,19 +466,10 @@ function useMediaQuery(query, options = {}) {
|
|
|
472
466
|
}
|
|
473
467
|
if (!isSupported.value)
|
|
474
468
|
return;
|
|
475
|
-
|
|
476
|
-
|
|
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 = void 0;
|
|
469
|
+
mediaQuery.value = window.matchMedia(toValue(query));
|
|
470
|
+
matches.value = mediaQuery.value.matches;
|
|
487
471
|
});
|
|
472
|
+
useEventListener(mediaQuery, "change", handler, { passive: true });
|
|
488
473
|
return computed(() => matches.value);
|
|
489
474
|
}
|
|
490
475
|
|
|
@@ -548,6 +533,7 @@ function useStorage(key, defaults, storage, options = {}) {
|
|
|
548
533
|
initOnMounted
|
|
549
534
|
} = options;
|
|
550
535
|
const data = (shallow ? shallowRef : ref)(typeof defaults === "function" ? defaults() : defaults);
|
|
536
|
+
const keyComputed = computed(() => toValue(key));
|
|
551
537
|
if (!storage) {
|
|
552
538
|
try {
|
|
553
539
|
storage = getSSRHandler("getDefaultStorage", () => {
|
|
@@ -568,10 +554,11 @@ function useStorage(key, defaults, storage, options = {}) {
|
|
|
568
554
|
() => write(data.value),
|
|
569
555
|
{ flush, deep, eventFilter }
|
|
570
556
|
);
|
|
557
|
+
watch(keyComputed, () => update(), { flush });
|
|
571
558
|
if (window && listenToStorageChanges) {
|
|
572
559
|
tryOnMounted(() => {
|
|
573
560
|
if (storage instanceof Storage)
|
|
574
|
-
useEventListener(window, "storage", update);
|
|
561
|
+
useEventListener(window, "storage", update, { passive: true });
|
|
575
562
|
else
|
|
576
563
|
useEventListener(window, customStorageEventName, updateFromCustomEvent);
|
|
577
564
|
if (initOnMounted)
|
|
@@ -583,7 +570,7 @@ function useStorage(key, defaults, storage, options = {}) {
|
|
|
583
570
|
function dispatchWriteEvent(oldValue, newValue) {
|
|
584
571
|
if (window) {
|
|
585
572
|
const payload = {
|
|
586
|
-
key,
|
|
573
|
+
key: keyComputed.value,
|
|
587
574
|
oldValue,
|
|
588
575
|
newValue,
|
|
589
576
|
storageArea: storage
|
|
@@ -595,14 +582,14 @@ function useStorage(key, defaults, storage, options = {}) {
|
|
|
595
582
|
}
|
|
596
583
|
function write(v) {
|
|
597
584
|
try {
|
|
598
|
-
const oldValue = storage.getItem(
|
|
585
|
+
const oldValue = storage.getItem(keyComputed.value);
|
|
599
586
|
if (v == null) {
|
|
600
587
|
dispatchWriteEvent(oldValue, null);
|
|
601
|
-
storage.removeItem(
|
|
588
|
+
storage.removeItem(keyComputed.value);
|
|
602
589
|
} else {
|
|
603
590
|
const serialized = serializer.write(v);
|
|
604
591
|
if (oldValue !== serialized) {
|
|
605
|
-
storage.setItem(
|
|
592
|
+
storage.setItem(keyComputed.value, serialized);
|
|
606
593
|
dispatchWriteEvent(oldValue, serialized);
|
|
607
594
|
}
|
|
608
595
|
}
|
|
@@ -611,10 +598,10 @@ function useStorage(key, defaults, storage, options = {}) {
|
|
|
611
598
|
}
|
|
612
599
|
}
|
|
613
600
|
function read(event) {
|
|
614
|
-
const rawValue = event ? event.newValue : storage.getItem(
|
|
601
|
+
const rawValue = event ? event.newValue : storage.getItem(keyComputed.value);
|
|
615
602
|
if (rawValue == null) {
|
|
616
603
|
if (writeDefaults && rawInit != null)
|
|
617
|
-
storage.setItem(
|
|
604
|
+
storage.setItem(keyComputed.value, serializer.write(rawInit));
|
|
618
605
|
return rawInit;
|
|
619
606
|
} else if (!event && mergeDefaults) {
|
|
620
607
|
const value = serializer.read(rawValue);
|
|
@@ -636,7 +623,7 @@ function useStorage(key, defaults, storage, options = {}) {
|
|
|
636
623
|
data.value = rawInit;
|
|
637
624
|
return;
|
|
638
625
|
}
|
|
639
|
-
if (event && event.key !==
|
|
626
|
+
if (event && event.key !== keyComputed.value)
|
|
640
627
|
return;
|
|
641
628
|
pauseWatch();
|
|
642
629
|
try {
|
|
@@ -684,7 +671,7 @@ function useColorMode(options = {}) {
|
|
|
684
671
|
const updateHTMLAttrs = getSSRHandler(
|
|
685
672
|
"updateHTMLAttrs",
|
|
686
673
|
(selector2, attribute2, value) => {
|
|
687
|
-
const el = typeof selector2 === "string" ? window == null ?
|
|
674
|
+
const el = typeof selector2 === "string" ? window == null ? undefined : window.document.querySelector(selector2) : unrefElement(selector2);
|
|
688
675
|
if (!el)
|
|
689
676
|
return;
|
|
690
677
|
const classesToAdd = /* @__PURE__ */ new Set();
|
|
@@ -868,18 +855,18 @@ const UseDraggable = /* @__PURE__ */ /* #__PURE__ */ defineComponent({
|
|
|
868
855
|
});
|
|
869
856
|
const containerElement = computed(() => {
|
|
870
857
|
var _a;
|
|
871
|
-
return (_a = props.containerElement) != null ? _a :
|
|
858
|
+
return (_a = props.containerElement) != null ? _a : undefined;
|
|
872
859
|
});
|
|
873
860
|
const disabled = computed(() => !!props.disabled);
|
|
874
861
|
const storageValue = props.storageKey && useStorage$1(
|
|
875
862
|
props.storageKey,
|
|
876
863
|
toValue(props.initialValue) || { x: 0, y: 0 },
|
|
877
|
-
isClient$1 ? props.storageType === "session" ? sessionStorage : localStorage :
|
|
864
|
+
isClient$1 ? props.storageType === "session" ? sessionStorage : localStorage : undefined
|
|
878
865
|
);
|
|
879
866
|
const initialValue = storageValue || props.initialValue || { x: 0, y: 0 };
|
|
880
867
|
const onEnd = (position, event) => {
|
|
881
868
|
var _a;
|
|
882
|
-
(_a = props.onEnd) == null ?
|
|
869
|
+
(_a = props.onEnd) == null ? undefined : _a.call(props, position, event);
|
|
883
870
|
if (!storageValue)
|
|
884
871
|
return;
|
|
885
872
|
storageValue.value.x = position.x;
|
|
@@ -920,7 +907,7 @@ function useMutationObserver(target, callback, options = {}) {
|
|
|
920
907
|
const cleanup = () => {
|
|
921
908
|
if (observer) {
|
|
922
909
|
observer.disconnect();
|
|
923
|
-
observer =
|
|
910
|
+
observer = undefined;
|
|
924
911
|
}
|
|
925
912
|
};
|
|
926
913
|
const targets = computed(() => {
|
|
@@ -940,7 +927,7 @@ function useMutationObserver(target, callback, options = {}) {
|
|
|
940
927
|
{ immediate: true, flush: "post" }
|
|
941
928
|
);
|
|
942
929
|
const takeRecords = () => {
|
|
943
|
-
return observer == null ?
|
|
930
|
+
return observer == null ? undefined : observer.takeRecords();
|
|
944
931
|
};
|
|
945
932
|
const stop = () => {
|
|
946
933
|
stopWatch();
|
|
@@ -961,7 +948,7 @@ function useResizeObserver(target, callback, options = {}) {
|
|
|
961
948
|
const cleanup = () => {
|
|
962
949
|
if (observer) {
|
|
963
950
|
observer.disconnect();
|
|
964
|
-
observer =
|
|
951
|
+
observer = undefined;
|
|
965
952
|
}
|
|
966
953
|
};
|
|
967
954
|
const targets = computed(() => {
|
|
@@ -1086,14 +1073,14 @@ const vElementBounding = {
|
|
|
1086
1073
|
function onElementRemoval(target, callback, options = {}) {
|
|
1087
1074
|
const {
|
|
1088
1075
|
window = defaultWindow,
|
|
1089
|
-
document = window == null ?
|
|
1076
|
+
document = window == null ? undefined : window.document,
|
|
1090
1077
|
flush = "sync"
|
|
1091
1078
|
} = options;
|
|
1092
1079
|
if (!window || !document)
|
|
1093
1080
|
return noop;
|
|
1094
1081
|
let stopFn;
|
|
1095
1082
|
const cleanupAndUpdate = (fn) => {
|
|
1096
|
-
stopFn == null ?
|
|
1083
|
+
stopFn == null ? undefined : stopFn();
|
|
1097
1084
|
stopFn = fn;
|
|
1098
1085
|
};
|
|
1099
1086
|
const stopWatch = watchEffect(() => {
|
|
@@ -1137,7 +1124,7 @@ function useElementHover(el, options = {}) {
|
|
|
1137
1124
|
const delay = entering ? delayEnter : delayLeave;
|
|
1138
1125
|
if (timer) {
|
|
1139
1126
|
clearTimeout(timer);
|
|
1140
|
-
timer =
|
|
1127
|
+
timer = undefined;
|
|
1141
1128
|
}
|
|
1142
1129
|
if (delay)
|
|
1143
1130
|
timer = setTimeout(() => isHovered.value = entering, delay);
|
|
@@ -1188,7 +1175,7 @@ function useElementSize(target, initialSize = { width: 0, height: 0 }, options =
|
|
|
1188
1175
|
const { window = defaultWindow, box = "content-box" } = options;
|
|
1189
1176
|
const isSVG = computed(() => {
|
|
1190
1177
|
var _a, _b;
|
|
1191
|
-
return (_b = (_a = unrefElement(target)) == null ?
|
|
1178
|
+
return (_b = (_a = unrefElement(target)) == null ? undefined : _a.namespaceURI) == null ? undefined : _b.includes("svg");
|
|
1192
1179
|
});
|
|
1193
1180
|
const width = ref(initialSize.width);
|
|
1194
1181
|
const height = ref(initialSize.height);
|
|
@@ -1244,7 +1231,7 @@ function useElementSize(target, initialSize = { width: 0, height: 0 }, options =
|
|
|
1244
1231
|
const vElementSize = {
|
|
1245
1232
|
mounted(el, binding) {
|
|
1246
1233
|
var _a;
|
|
1247
|
-
const handler = typeof binding.value === "function" ? binding.value : (_a = binding.value) == null ?
|
|
1234
|
+
const handler = typeof binding.value === "function" ? binding.value : (_a = binding.value) == null ? undefined : _a[0];
|
|
1248
1235
|
const options = typeof binding.value === "function" ? [] : binding.value.slice(1);
|
|
1249
1236
|
const { width, height } = useElementSize(el, ...options);
|
|
1250
1237
|
watch([width, height], ([width2, height2]) => handler({ width: width2, height: height2 }));
|
|
@@ -1434,11 +1421,11 @@ function useAsyncState(promise, initialState, options) {
|
|
|
1434
1421
|
const state = shallow ? shallowRef(initialState) : ref(initialState);
|
|
1435
1422
|
const isReady = ref(false);
|
|
1436
1423
|
const isLoading = ref(false);
|
|
1437
|
-
const error = shallowRef(
|
|
1424
|
+
const error = shallowRef(undefined);
|
|
1438
1425
|
async function execute(delay2 = 0, ...args) {
|
|
1439
1426
|
if (resetOnExecute)
|
|
1440
1427
|
state.value = initialState;
|
|
1441
|
-
error.value =
|
|
1428
|
+
error.value = undefined;
|
|
1442
1429
|
isReady.value = false;
|
|
1443
1430
|
isLoading.value = true;
|
|
1444
1431
|
if (delay2 > 0)
|
|
@@ -1459,8 +1446,9 @@ function useAsyncState(promise, initialState, options) {
|
|
|
1459
1446
|
}
|
|
1460
1447
|
return state.value;
|
|
1461
1448
|
}
|
|
1462
|
-
if (immediate)
|
|
1449
|
+
if (immediate) {
|
|
1463
1450
|
execute(delay);
|
|
1451
|
+
}
|
|
1464
1452
|
const shell = {
|
|
1465
1453
|
state,
|
|
1466
1454
|
isReady,
|
|
@@ -1517,7 +1505,7 @@ async function loadImage(options) {
|
|
|
1517
1505
|
function useImage(options, asyncStateOptions = {}) {
|
|
1518
1506
|
const state = useAsyncState(
|
|
1519
1507
|
() => loadImage(toValue(options)),
|
|
1520
|
-
|
|
1508
|
+
undefined,
|
|
1521
1509
|
{
|
|
1522
1510
|
resetOnExecute: true,
|
|
1523
1511
|
...asyncStateOptions
|
|
@@ -1602,7 +1590,7 @@ function useScroll(element, options = {}) {
|
|
|
1602
1590
|
return internalX.value;
|
|
1603
1591
|
},
|
|
1604
1592
|
set(x2) {
|
|
1605
|
-
scrollTo(x2,
|
|
1593
|
+
scrollTo(x2, undefined);
|
|
1606
1594
|
}
|
|
1607
1595
|
});
|
|
1608
1596
|
const y = computed({
|
|
@@ -1610,7 +1598,7 @@ function useScroll(element, options = {}) {
|
|
|
1610
1598
|
return internalY.value;
|
|
1611
1599
|
},
|
|
1612
1600
|
set(y2) {
|
|
1613
|
-
scrollTo(
|
|
1601
|
+
scrollTo(undefined, y2);
|
|
1614
1602
|
}
|
|
1615
1603
|
});
|
|
1616
1604
|
function scrollTo(_x, _y) {
|
|
@@ -1620,12 +1608,12 @@ function useScroll(element, options = {}) {
|
|
|
1620
1608
|
const _element = toValue(element);
|
|
1621
1609
|
if (!_element)
|
|
1622
1610
|
return;
|
|
1623
|
-
(_c = _element instanceof Document ? window.document.body : _element) == null ?
|
|
1611
|
+
(_c = _element instanceof Document ? window.document.body : _element) == null ? undefined : _c.scrollTo({
|
|
1624
1612
|
top: (_a = toValue(_y)) != null ? _a : y.value,
|
|
1625
1613
|
left: (_b = toValue(_x)) != null ? _b : x.value,
|
|
1626
1614
|
behavior: toValue(behavior)
|
|
1627
1615
|
});
|
|
1628
|
-
const scrollContainer = ((_d = _element == null ?
|
|
1616
|
+
const scrollContainer = ((_d = _element == null ? undefined : _element.document) == null ? undefined : _d.documentElement) || (_element == null ? undefined : _element.documentElement) || _element;
|
|
1629
1617
|
if (x != null)
|
|
1630
1618
|
internalX.value = scrollContainer.scrollLeft;
|
|
1631
1619
|
if (y != null)
|
|
@@ -1659,7 +1647,7 @@ function useScroll(element, options = {}) {
|
|
|
1659
1647
|
var _a;
|
|
1660
1648
|
if (!window)
|
|
1661
1649
|
return;
|
|
1662
|
-
const el = ((_a = target == null ?
|
|
1650
|
+
const el = ((_a = target == null ? undefined : target.document) == null ? undefined : _a.documentElement) || (target == null ? undefined : target.documentElement) || unrefElement(target);
|
|
1663
1651
|
const { display, flexDirection, direction } = getComputedStyle(el);
|
|
1664
1652
|
const directionMultipler = direction === "rtl" ? -1 : 1;
|
|
1665
1653
|
const scrollLeft = el.scrollLeft;
|
|
@@ -1905,7 +1893,7 @@ function useMouse(options = {}) {
|
|
|
1905
1893
|
useEventListener(target, "touchend", reset, listenerOptions);
|
|
1906
1894
|
}
|
|
1907
1895
|
if (scroll && type === "page")
|
|
1908
|
-
useEventListener(window, "scroll", scrollHandlerWrapper,
|
|
1896
|
+
useEventListener(window, "scroll", scrollHandlerWrapper, listenerOptions);
|
|
1909
1897
|
}
|
|
1910
1898
|
return {
|
|
1911
1899
|
x,
|
|
@@ -1921,7 +1909,7 @@ function useMouseInElement(target, options = {}) {
|
|
|
1921
1909
|
} = options;
|
|
1922
1910
|
const type = options.type || "page";
|
|
1923
1911
|
const { x, y, sourceType } = useMouse(options);
|
|
1924
|
-
const targetRef = ref(target != null ? target : window == null ?
|
|
1912
|
+
const targetRef = ref(target != null ? target : window == null ? undefined : window.document.body);
|
|
1925
1913
|
const elementX = ref(0);
|
|
1926
1914
|
const elementY = ref(0);
|
|
1927
1915
|
const elementPositionX = ref(0);
|
|
@@ -1958,9 +1946,12 @@ function useMouseInElement(target, options = {}) {
|
|
|
1958
1946
|
},
|
|
1959
1947
|
{ immediate: true }
|
|
1960
1948
|
);
|
|
1961
|
-
useEventListener(
|
|
1962
|
-
|
|
1963
|
-
|
|
1949
|
+
useEventListener(
|
|
1950
|
+
document,
|
|
1951
|
+
"mouseleave",
|
|
1952
|
+
() => isOutside.value = true,
|
|
1953
|
+
{ passive: true }
|
|
1954
|
+
);
|
|
1964
1955
|
}
|
|
1965
1956
|
return {
|
|
1966
1957
|
x,
|
|
@@ -2056,17 +2047,17 @@ const UseOffsetPagination = /* @__PURE__ */ /* #__PURE__ */ defineComponent({
|
|
|
2056
2047
|
...props,
|
|
2057
2048
|
onPageChange(...args) {
|
|
2058
2049
|
var _a;
|
|
2059
|
-
(_a = props.onPageChange) == null ?
|
|
2050
|
+
(_a = props.onPageChange) == null ? undefined : _a.call(props, ...args);
|
|
2060
2051
|
emit("page-change", ...args);
|
|
2061
2052
|
},
|
|
2062
2053
|
onPageSizeChange(...args) {
|
|
2063
2054
|
var _a;
|
|
2064
|
-
(_a = props.onPageSizeChange) == null ?
|
|
2055
|
+
(_a = props.onPageSizeChange) == null ? undefined : _a.call(props, ...args);
|
|
2065
2056
|
emit("page-size-change", ...args);
|
|
2066
2057
|
},
|
|
2067
2058
|
onPageCountChange(...args) {
|
|
2068
2059
|
var _a;
|
|
2069
|
-
(_a = props.onPageCountChange) == null ?
|
|
2060
|
+
(_a = props.onPageCountChange) == null ? undefined : _a.call(props, ...args);
|
|
2070
2061
|
emit("page-count-change", ...args);
|
|
2071
2062
|
}
|
|
2072
2063
|
}));
|
|
@@ -2228,14 +2219,14 @@ function useCssVar(prop, target, options = {}) {
|
|
|
2228
2219
|
const variable = ref(initialValue);
|
|
2229
2220
|
const elRef = computed(() => {
|
|
2230
2221
|
var _a;
|
|
2231
|
-
return unrefElement(target) || ((_a = window == null ?
|
|
2222
|
+
return unrefElement(target) || ((_a = window == null ? undefined : window.document) == null ? undefined : _a.documentElement);
|
|
2232
2223
|
});
|
|
2233
2224
|
function updateCssVar() {
|
|
2234
2225
|
var _a;
|
|
2235
2226
|
const key = toValue(prop);
|
|
2236
2227
|
const el = toValue(elRef);
|
|
2237
2228
|
if (el && window && key) {
|
|
2238
|
-
const value = (_a = window.getComputedStyle(el).getPropertyValue(key)) == null ?
|
|
2229
|
+
const value = (_a = window.getComputedStyle(el).getPropertyValue(key)) == null ? undefined : _a.trim();
|
|
2239
2230
|
variable.value = value || initialValue;
|
|
2240
2231
|
}
|
|
2241
2232
|
}
|
|
@@ -2259,7 +2250,7 @@ function useCssVar(prop, target, options = {}) {
|
|
|
2259
2250
|
(val) => {
|
|
2260
2251
|
var _a;
|
|
2261
2252
|
const raw_prop = toValue(prop);
|
|
2262
|
-
if (((_a = elRef.value) == null ?
|
|
2253
|
+
if (((_a = elRef.value) == null ? undefined : _a.style) && raw_prop) {
|
|
2263
2254
|
if (val == null)
|
|
2264
2255
|
elRef.value.style.removeProperty(raw_prop);
|
|
2265
2256
|
else
|
|
@@ -2289,7 +2280,7 @@ function useScreenSafeArea() {
|
|
|
2289
2280
|
bottomCssVar.value = "env(safe-area-inset-bottom, 0px)";
|
|
2290
2281
|
leftCssVar.value = "env(safe-area-inset-left, 0px)";
|
|
2291
2282
|
update();
|
|
2292
|
-
useEventListener("resize", useDebounceFn(update));
|
|
2283
|
+
useEventListener("resize", useDebounceFn(update), { passive: true });
|
|
2293
2284
|
}
|
|
2294
2285
|
function update() {
|
|
2295
2286
|
top.value = getValue(topVarName);
|
|
@@ -2361,12 +2352,12 @@ const vScroll = {
|
|
|
2361
2352
|
...options,
|
|
2362
2353
|
onScroll(e) {
|
|
2363
2354
|
var _a;
|
|
2364
|
-
(_a = options.onScroll) == null ?
|
|
2355
|
+
(_a = options.onScroll) == null ? undefined : _a.call(options, e);
|
|
2365
2356
|
handler(state);
|
|
2366
2357
|
},
|
|
2367
2358
|
onStop(e) {
|
|
2368
2359
|
var _a;
|
|
2369
|
-
(_a = options.onStop) == null ?
|
|
2360
|
+
(_a = options.onStop) == null ? undefined : _a.call(options, e);
|
|
2370
2361
|
handler(state);
|
|
2371
2362
|
}
|
|
2372
2363
|
});
|
|
@@ -2439,7 +2430,7 @@ function useScrollLock(element, initialState = false) {
|
|
|
2439
2430
|
if (!el || !isLocked.value)
|
|
2440
2431
|
return;
|
|
2441
2432
|
if (isIOS)
|
|
2442
|
-
stopTouchMoveListener == null ?
|
|
2433
|
+
stopTouchMoveListener == null ? undefined : stopTouchMoveListener();
|
|
2443
2434
|
el.style.overflow = initialOverflow;
|
|
2444
2435
|
elInitialOverflow.delete(el);
|
|
2445
2436
|
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
|
+
"version": "12.5.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.
|
|
46
|
-
"@vueuse/shared": "12.
|
|
45
|
+
"@vueuse/core": "12.5.0",
|
|
46
|
+
"@vueuse/shared": "12.5.0"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"build": "rollup --config=rollup.config.ts --configPlugin=rollup-plugin-esbuild"
|