@vueuse/components 11.0.3 → 11.2.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 +90 -74
- package/index.d.cts +131 -131
- package/index.d.mts +131 -131
- package/index.d.ts +131 -131
- package/index.iife.js +91 -75
- package/index.iife.min.js +1 -1
- package/index.mjs +91 -75
- package/package.json +3 -3
package/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineComponent, ref, h, watch, computed, reactive, shallowRef, nextTick, getCurrentInstance, onMounted, isVue2, watchEffect, toRefs } from 'vue-demi';
|
|
2
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, useElementSize as useElementSize$1, useElementVisibility as useElementVisibility$1, useEyeDropper, useFullscreen, useGeolocation, useIdle, useMouse, useMouseInElement, useMousePressed, useNetwork, useNow, useObjectUrl, useOffsetPagination, useOnline, usePageLeave, usePointer, usePointerLock, usePreferredColorScheme, usePreferredContrast, usePreferredDark as usePreferredDark$1, usePreferredLanguages, usePreferredReducedMotion, useTimeAgo, useTimestamp, useVirtualList, useWindowFocus, useWindowSize } from '@vueuse/core';
|
|
3
|
-
import {
|
|
2
|
+
import { defineComponent, ref, h, watch, computed, reactive, getCurrentInstance, onMounted, isVue2, watchEffect, shallowRef, nextTick, toRefs } from 'vue-demi';
|
|
3
|
+
import { isClient, toValue, noop, isObject, tryOnScopeDispose, isIOS, directiveHooks, pausableWatch, tryOnMounted, toRef, useToggle, notNullish, promiseTimeout, until, useDebounceFn, useThrottleFn, tryOnUnmounted } from '@vueuse/shared';
|
|
4
4
|
|
|
5
5
|
const OnClickOutside = /* @__PURE__ */ /* #__PURE__ */ defineComponent({
|
|
6
6
|
name: "OnClickOutside",
|
|
@@ -18,14 +18,14 @@ const OnClickOutside = /* @__PURE__ */ /* #__PURE__ */ defineComponent({
|
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
+
const defaultWindow = isClient ? window : void 0;
|
|
22
|
+
|
|
21
23
|
function unrefElement(elRef) {
|
|
22
24
|
var _a;
|
|
23
25
|
const plain = toValue(elRef);
|
|
24
26
|
return (_a = plain == null ? void 0 : plain.$el) != null ? _a : plain;
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
const defaultWindow = isClient ? window : void 0;
|
|
28
|
-
|
|
29
29
|
function useEventListener(...args) {
|
|
30
30
|
let target;
|
|
31
31
|
let events;
|
|
@@ -87,7 +87,7 @@ function onClickOutside(target, handler, options = {}) {
|
|
|
87
87
|
}
|
|
88
88
|
let shouldListen = true;
|
|
89
89
|
const shouldIgnore = (event) => {
|
|
90
|
-
return ignore.some((target2) => {
|
|
90
|
+
return toValue(ignore).some((target2) => {
|
|
91
91
|
if (typeof target2 === "string") {
|
|
92
92
|
return Array.from(window.document.querySelectorAll(target2)).some((el) => el === event.target || event.composedPath().includes(el));
|
|
93
93
|
} else {
|
|
@@ -108,8 +108,17 @@ function onClickOutside(target, handler, options = {}) {
|
|
|
108
108
|
}
|
|
109
109
|
handler(event);
|
|
110
110
|
};
|
|
111
|
+
let isProcessingClick = false;
|
|
111
112
|
const cleanup = [
|
|
112
|
-
useEventListener(window, "click",
|
|
113
|
+
useEventListener(window, "click", (event) => {
|
|
114
|
+
if (!isProcessingClick) {
|
|
115
|
+
isProcessingClick = true;
|
|
116
|
+
setTimeout(() => {
|
|
117
|
+
isProcessingClick = false;
|
|
118
|
+
}, 0);
|
|
119
|
+
listener(event);
|
|
120
|
+
}
|
|
121
|
+
}, { passive: true, capture }),
|
|
113
122
|
useEventListener(window, "pointerdown", (e) => {
|
|
114
123
|
const el = unrefElement(target);
|
|
115
124
|
shouldListen = !shouldIgnore(e) && !!(el && !e.composedPath().includes(el));
|
|
@@ -387,6 +396,64 @@ function getSSRHandler(key, fallback) {
|
|
|
387
396
|
return handlers[key] || fallback;
|
|
388
397
|
}
|
|
389
398
|
|
|
399
|
+
function useMounted() {
|
|
400
|
+
const isMounted = ref(false);
|
|
401
|
+
const instance = getCurrentInstance();
|
|
402
|
+
if (instance) {
|
|
403
|
+
onMounted(() => {
|
|
404
|
+
isMounted.value = true;
|
|
405
|
+
}, isVue2 ? void 0 : instance);
|
|
406
|
+
}
|
|
407
|
+
return isMounted;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
function useSupported(callback) {
|
|
411
|
+
const isMounted = useMounted();
|
|
412
|
+
return computed(() => {
|
|
413
|
+
isMounted.value;
|
|
414
|
+
return Boolean(callback());
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
function useMediaQuery(query, options = {}) {
|
|
419
|
+
const { window = defaultWindow } = options;
|
|
420
|
+
const isSupported = useSupported(() => window && "matchMedia" in window && typeof window.matchMedia === "function");
|
|
421
|
+
let mediaQuery;
|
|
422
|
+
const matches = ref(false);
|
|
423
|
+
const handler = (event) => {
|
|
424
|
+
matches.value = event.matches;
|
|
425
|
+
};
|
|
426
|
+
const cleanup = () => {
|
|
427
|
+
if (!mediaQuery)
|
|
428
|
+
return;
|
|
429
|
+
if ("removeEventListener" in mediaQuery)
|
|
430
|
+
mediaQuery.removeEventListener("change", handler);
|
|
431
|
+
else
|
|
432
|
+
mediaQuery.removeListener(handler);
|
|
433
|
+
};
|
|
434
|
+
const stopWatch = watchEffect(() => {
|
|
435
|
+
if (!isSupported.value)
|
|
436
|
+
return;
|
|
437
|
+
cleanup();
|
|
438
|
+
mediaQuery = window.matchMedia(toValue(query));
|
|
439
|
+
if ("addEventListener" in mediaQuery)
|
|
440
|
+
mediaQuery.addEventListener("change", handler);
|
|
441
|
+
else
|
|
442
|
+
mediaQuery.addListener(handler);
|
|
443
|
+
matches.value = mediaQuery.matches;
|
|
444
|
+
});
|
|
445
|
+
tryOnScopeDispose(() => {
|
|
446
|
+
stopWatch();
|
|
447
|
+
cleanup();
|
|
448
|
+
mediaQuery = void 0;
|
|
449
|
+
});
|
|
450
|
+
return matches;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
function usePreferredDark(options) {
|
|
454
|
+
return useMediaQuery("(prefers-color-scheme: dark)", options);
|
|
455
|
+
}
|
|
456
|
+
|
|
390
457
|
function guessSerializerType(rawInit) {
|
|
391
458
|
return rawInit == null ? "any" : rawInit instanceof Set ? "set" : rawInit instanceof Map ? "map" : rawInit instanceof Date ? "date" : typeof rawInit === "boolean" ? "boolean" : typeof rawInit === "string" ? "string" : typeof rawInit === "object" ? "object" : !Number.isNaN(rawInit) ? "number" : "any";
|
|
392
459
|
}
|
|
@@ -552,64 +619,6 @@ function useStorage(key, defaults, storage, options = {}) {
|
|
|
552
619
|
return data;
|
|
553
620
|
}
|
|
554
621
|
|
|
555
|
-
function useMounted() {
|
|
556
|
-
const isMounted = ref(false);
|
|
557
|
-
const instance = getCurrentInstance();
|
|
558
|
-
if (instance) {
|
|
559
|
-
onMounted(() => {
|
|
560
|
-
isMounted.value = true;
|
|
561
|
-
}, isVue2 ? void 0 : instance);
|
|
562
|
-
}
|
|
563
|
-
return isMounted;
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
function useSupported(callback) {
|
|
567
|
-
const isMounted = useMounted();
|
|
568
|
-
return computed(() => {
|
|
569
|
-
isMounted.value;
|
|
570
|
-
return Boolean(callback());
|
|
571
|
-
});
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
function useMediaQuery(query, options = {}) {
|
|
575
|
-
const { window = defaultWindow } = options;
|
|
576
|
-
const isSupported = useSupported(() => window && "matchMedia" in window && typeof window.matchMedia === "function");
|
|
577
|
-
let mediaQuery;
|
|
578
|
-
const matches = ref(false);
|
|
579
|
-
const handler = (event) => {
|
|
580
|
-
matches.value = event.matches;
|
|
581
|
-
};
|
|
582
|
-
const cleanup = () => {
|
|
583
|
-
if (!mediaQuery)
|
|
584
|
-
return;
|
|
585
|
-
if ("removeEventListener" in mediaQuery)
|
|
586
|
-
mediaQuery.removeEventListener("change", handler);
|
|
587
|
-
else
|
|
588
|
-
mediaQuery.removeListener(handler);
|
|
589
|
-
};
|
|
590
|
-
const stopWatch = watchEffect(() => {
|
|
591
|
-
if (!isSupported.value)
|
|
592
|
-
return;
|
|
593
|
-
cleanup();
|
|
594
|
-
mediaQuery = window.matchMedia(toValue(query));
|
|
595
|
-
if ("addEventListener" in mediaQuery)
|
|
596
|
-
mediaQuery.addEventListener("change", handler);
|
|
597
|
-
else
|
|
598
|
-
mediaQuery.addListener(handler);
|
|
599
|
-
matches.value = mediaQuery.matches;
|
|
600
|
-
});
|
|
601
|
-
tryOnScopeDispose(() => {
|
|
602
|
-
stopWatch();
|
|
603
|
-
cleanup();
|
|
604
|
-
mediaQuery = void 0;
|
|
605
|
-
});
|
|
606
|
-
return matches;
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
function usePreferredDark(options) {
|
|
610
|
-
return useMediaQuery("(prefers-color-scheme: dark)", options);
|
|
611
|
-
}
|
|
612
|
-
|
|
613
622
|
const CSS_DISABLE_TRANS = "*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}";
|
|
614
623
|
function useColorMode(options = {}) {
|
|
615
624
|
const {
|
|
@@ -814,7 +823,8 @@ const UseDraggable = /* @__PURE__ */ /* #__PURE__ */ defineComponent({
|
|
|
814
823
|
"onMove",
|
|
815
824
|
"onEnd",
|
|
816
825
|
"disabled",
|
|
817
|
-
"buttons"
|
|
826
|
+
"buttons",
|
|
827
|
+
"containerElement"
|
|
818
828
|
],
|
|
819
829
|
setup(props, { slots }) {
|
|
820
830
|
const target = ref();
|
|
@@ -822,6 +832,10 @@ const UseDraggable = /* @__PURE__ */ /* #__PURE__ */ defineComponent({
|
|
|
822
832
|
var _a;
|
|
823
833
|
return (_a = props.handle) != null ? _a : target.value;
|
|
824
834
|
});
|
|
835
|
+
const containerElement = computed(() => {
|
|
836
|
+
var _a;
|
|
837
|
+
return (_a = props.containerElement) != null ? _a : void 0;
|
|
838
|
+
});
|
|
825
839
|
const disabled = computed(() => !!props.disabled);
|
|
826
840
|
const storageValue = props.storageKey && useStorage$1(
|
|
827
841
|
props.storageKey,
|
|
@@ -842,7 +856,8 @@ const UseDraggable = /* @__PURE__ */ /* #__PURE__ */ defineComponent({
|
|
|
842
856
|
handle,
|
|
843
857
|
initialValue,
|
|
844
858
|
onEnd,
|
|
845
|
-
disabled
|
|
859
|
+
disabled,
|
|
860
|
+
containerElement
|
|
846
861
|
}));
|
|
847
862
|
return () => {
|
|
848
863
|
if (slots.default)
|
|
@@ -1312,6 +1327,14 @@ const UseImage = /* @__PURE__ */ /* #__PURE__ */ defineComponent({
|
|
|
1312
1327
|
}
|
|
1313
1328
|
});
|
|
1314
1329
|
|
|
1330
|
+
function resolveElement(el) {
|
|
1331
|
+
if (typeof Window !== "undefined" && el instanceof Window)
|
|
1332
|
+
return el.document.documentElement;
|
|
1333
|
+
if (typeof Document !== "undefined" && el instanceof Document)
|
|
1334
|
+
return el.documentElement;
|
|
1335
|
+
return el;
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1315
1338
|
const ARRIVED_STATE_THRESHOLD_PIXELS = 1;
|
|
1316
1339
|
function useScroll(element, options = {}) {
|
|
1317
1340
|
const {
|
|
@@ -1476,14 +1499,6 @@ function useScroll(element, options = {}) {
|
|
|
1476
1499
|
};
|
|
1477
1500
|
}
|
|
1478
1501
|
|
|
1479
|
-
function resolveElement(el) {
|
|
1480
|
-
if (typeof Window !== "undefined" && el instanceof Window)
|
|
1481
|
-
return el.document.documentElement;
|
|
1482
|
-
if (typeof Document !== "undefined" && el instanceof Document)
|
|
1483
|
-
return el.documentElement;
|
|
1484
|
-
return el;
|
|
1485
|
-
}
|
|
1486
|
-
|
|
1487
1502
|
function useInfiniteScroll(element, onLoadMore, options = {}) {
|
|
1488
1503
|
var _a;
|
|
1489
1504
|
const {
|
|
@@ -1525,11 +1540,12 @@ function useInfiniteScroll(element, onLoadMore, options = {}) {
|
|
|
1525
1540
|
}
|
|
1526
1541
|
}
|
|
1527
1542
|
}
|
|
1528
|
-
watch(
|
|
1543
|
+
const stop = watch(
|
|
1529
1544
|
() => [state.arrivedState[direction], isElementVisible.value],
|
|
1530
1545
|
checkAndLoad,
|
|
1531
1546
|
{ immediate: true }
|
|
1532
1547
|
);
|
|
1548
|
+
tryOnUnmounted(stop);
|
|
1533
1549
|
return {
|
|
1534
1550
|
isLoading,
|
|
1535
1551
|
reset() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vueuse/components",
|
|
3
|
-
"version": "11.0
|
|
3
|
+
"version": "11.2.0",
|
|
4
4
|
"description": "Renderless components for VueUse",
|
|
5
5
|
"author": "Jacob Clevenger<https://github.com/wheatjs>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"jsdelivr": "./index.iife.min.js",
|
|
33
33
|
"types": "./index.d.cts",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@vueuse/core": "11.0
|
|
36
|
-
"@vueuse/shared": "11.0
|
|
35
|
+
"@vueuse/core": "11.2.0",
|
|
36
|
+
"@vueuse/shared": "11.2.0",
|
|
37
37
|
"vue-demi": ">=0.14.10"
|
|
38
38
|
}
|
|
39
39
|
}
|