@vueuse/components 7.5.3 → 7.6.1
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 +169 -54
- package/index.d.ts +92 -38
- package/index.iife.js +169 -54
- package/index.iife.min.js +1 -1
- package/index.mjs +169 -57
- package/package.json +3 -3
package/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineComponent, ref, h, unref, watch, reactive, shallowRef,
|
|
2
|
-
import { onClickOutside as onClickOutside$1, useActiveElement, useBattery, useBrowserLocation, useDark, useDeviceMotion, useDeviceOrientation, useDevicePixelRatio, useDevicesList, useDocumentVisibility, useStorage as useStorage$1, isClient as isClient$1, useDraggable, useElementBounding, useElementSize, useElementVisibility, useEyeDropper, useFullscreen, useGeolocation, useIdle, useMouse, useMouseInElement, useMousePressed, useNetwork, useNow, useOnline, usePageLeave, usePointer, usePreferredColorScheme, usePreferredDark as usePreferredDark$1, usePreferredLanguages, useTimeAgo, useTimestamp, useVirtualList, useWindowFocus, useWindowSize } from '@vueuse/core';
|
|
1
|
+
import { defineComponent, ref, h, unref, watch, computed, reactive, shallowRef, toRef, toRefs } from 'vue-demi';
|
|
2
|
+
import { onClickOutside as onClickOutside$1, unrefElement as unrefElement$1, useEventListener as useEventListener$1, useActiveElement, useBattery, useBrowserLocation, useDark, useDeviceMotion, useDeviceOrientation, useDevicePixelRatio, useDevicesList, useDocumentVisibility, useStorage as useStorage$1, isClient as isClient$1, useDraggable, useElementBounding, useElementSize, useElementVisibility, useEyeDropper, useFullscreen, useGeolocation, useIdle, useMouse, useMouseInElement, useMousePressed, useNetwork, useNow, useOffsetPagination, useOnline, usePageLeave, usePointer, usePreferredColorScheme, usePreferredDark as usePreferredDark$1, usePreferredLanguages, useTimeAgo, useTimestamp, useVirtualList, useWindowFocus, useWindowSize } from '@vueuse/core';
|
|
3
3
|
import { isClient, isString, noop, tryOnScopeDispose, watchWithFilter, tryOnMounted, useToggle, useDebounceFn } from '@vueuse/shared';
|
|
4
4
|
|
|
5
5
|
const OnClickOutside = defineComponent({
|
|
@@ -59,14 +59,22 @@ function useEventListener(...args) {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
function onClickOutside(target, handler, options = {}) {
|
|
62
|
-
const { window = defaultWindow } = options;
|
|
62
|
+
const { window = defaultWindow, ignore } = options;
|
|
63
63
|
if (!window)
|
|
64
64
|
return;
|
|
65
65
|
const shouldListen = ref(true);
|
|
66
66
|
const listener = (event) => {
|
|
67
67
|
const el = unrefElement(target);
|
|
68
|
-
|
|
68
|
+
const composedPath = event.composedPath();
|
|
69
|
+
if (!el || el === event.target || composedPath.includes(el) || !shouldListen.value)
|
|
69
70
|
return;
|
|
71
|
+
if (ignore && ignore.length > 0) {
|
|
72
|
+
if (ignore.some((target2) => {
|
|
73
|
+
const el2 = unrefElement(target2);
|
|
74
|
+
return el2 && (event.target === el2 || composedPath.includes(el2));
|
|
75
|
+
}))
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
70
78
|
handler(event);
|
|
71
79
|
};
|
|
72
80
|
const cleanup = [
|
|
@@ -84,6 +92,49 @@ const VOnClickOutside = (el, binding) => {
|
|
|
84
92
|
onClickOutside(el, binding.value);
|
|
85
93
|
};
|
|
86
94
|
|
|
95
|
+
const DEFAULT_DELAY = 500;
|
|
96
|
+
function onLongPress(target, handler, options) {
|
|
97
|
+
const elementRef = computed(() => unrefElement$1(target));
|
|
98
|
+
let timeout = null;
|
|
99
|
+
function clear() {
|
|
100
|
+
if (timeout != null) {
|
|
101
|
+
clearTimeout(timeout);
|
|
102
|
+
timeout = null;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function onDown(ev) {
|
|
106
|
+
var _a;
|
|
107
|
+
clear();
|
|
108
|
+
timeout = setTimeout(() => handler(ev), (_a = options == null ? void 0 : options.delay) != null ? _a : DEFAULT_DELAY);
|
|
109
|
+
}
|
|
110
|
+
useEventListener$1(elementRef, "pointerdown", onDown);
|
|
111
|
+
useEventListener$1(elementRef, "pointerup", clear);
|
|
112
|
+
useEventListener$1(elementRef, "pointerleave", clear);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const OnLongPress = defineComponent({
|
|
116
|
+
name: "OnLongPress",
|
|
117
|
+
props: ["as", "options"],
|
|
118
|
+
emits: ["trigger"],
|
|
119
|
+
setup(props, { slots, emit }) {
|
|
120
|
+
const target = ref();
|
|
121
|
+
onLongPress(target, (e) => {
|
|
122
|
+
emit("trigger", e);
|
|
123
|
+
}, props.options);
|
|
124
|
+
return () => {
|
|
125
|
+
if (slots.default)
|
|
126
|
+
return h(props.as || "div", { ref: target }, slots.default());
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
const VOnLongPress = (el, binding) => {
|
|
132
|
+
if (typeof binding.value === "function")
|
|
133
|
+
onLongPress(el, binding.value);
|
|
134
|
+
else
|
|
135
|
+
onLongPress(el, binding.value.handler, binding.value.options);
|
|
136
|
+
};
|
|
137
|
+
|
|
87
138
|
const UseActiveElement = defineComponent({
|
|
88
139
|
name: "UseActiveElement",
|
|
89
140
|
setup(props, { slots }) {
|
|
@@ -119,9 +170,10 @@ const UseBrowserLocation = defineComponent({
|
|
|
119
170
|
}
|
|
120
171
|
});
|
|
121
172
|
|
|
173
|
+
const _global = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
122
174
|
const globalKey = "__vueuse_ssr_handlers__";
|
|
123
|
-
|
|
124
|
-
const handlers =
|
|
175
|
+
_global[globalKey] = _global[globalKey] || {};
|
|
176
|
+
const handlers = _global[globalKey];
|
|
125
177
|
function getSSRHandler(key, fallback) {
|
|
126
178
|
return handlers[key] || fallback;
|
|
127
179
|
}
|
|
@@ -261,19 +313,19 @@ function usePreferredDark(options) {
|
|
|
261
313
|
return useMediaQuery("(prefers-color-scheme: dark)", options);
|
|
262
314
|
}
|
|
263
315
|
|
|
264
|
-
var __defProp$
|
|
265
|
-
var __getOwnPropSymbols$
|
|
266
|
-
var __hasOwnProp$
|
|
267
|
-
var __propIsEnum$
|
|
268
|
-
var __defNormalProp$
|
|
269
|
-
var __spreadValues$
|
|
316
|
+
var __defProp$8 = Object.defineProperty;
|
|
317
|
+
var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
|
|
318
|
+
var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
|
|
319
|
+
var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
|
|
320
|
+
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
321
|
+
var __spreadValues$8 = (a, b) => {
|
|
270
322
|
for (var prop in b || (b = {}))
|
|
271
|
-
if (__hasOwnProp$
|
|
272
|
-
__defNormalProp$
|
|
273
|
-
if (__getOwnPropSymbols$
|
|
274
|
-
for (var prop of __getOwnPropSymbols$
|
|
275
|
-
if (__propIsEnum$
|
|
276
|
-
__defNormalProp$
|
|
323
|
+
if (__hasOwnProp$8.call(b, prop))
|
|
324
|
+
__defNormalProp$8(a, prop, b[prop]);
|
|
325
|
+
if (__getOwnPropSymbols$8)
|
|
326
|
+
for (var prop of __getOwnPropSymbols$8(b)) {
|
|
327
|
+
if (__propIsEnum$8.call(b, prop))
|
|
328
|
+
__defNormalProp$8(a, prop, b[prop]);
|
|
277
329
|
}
|
|
278
330
|
return a;
|
|
279
331
|
};
|
|
@@ -287,7 +339,7 @@ function useColorMode(options = {}) {
|
|
|
287
339
|
listenToStorageChanges = true,
|
|
288
340
|
storageRef
|
|
289
341
|
} = options;
|
|
290
|
-
const modes = __spreadValues$
|
|
342
|
+
const modes = __spreadValues$8({
|
|
291
343
|
auto: "",
|
|
292
344
|
light: "light",
|
|
293
345
|
dark: "dark"
|
|
@@ -425,29 +477,30 @@ const UseDocumentVisibility = defineComponent({
|
|
|
425
477
|
}
|
|
426
478
|
});
|
|
427
479
|
|
|
428
|
-
var __defProp$
|
|
429
|
-
var __defProps$
|
|
430
|
-
var __getOwnPropDescs$
|
|
431
|
-
var __getOwnPropSymbols$
|
|
432
|
-
var __hasOwnProp$
|
|
433
|
-
var __propIsEnum$
|
|
434
|
-
var __defNormalProp$
|
|
435
|
-
var __spreadValues$
|
|
480
|
+
var __defProp$7 = Object.defineProperty;
|
|
481
|
+
var __defProps$6 = Object.defineProperties;
|
|
482
|
+
var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
|
|
483
|
+
var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
|
|
484
|
+
var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
|
|
485
|
+
var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
|
|
486
|
+
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
487
|
+
var __spreadValues$7 = (a, b) => {
|
|
436
488
|
for (var prop in b || (b = {}))
|
|
437
|
-
if (__hasOwnProp$
|
|
438
|
-
__defNormalProp$
|
|
439
|
-
if (__getOwnPropSymbols$
|
|
440
|
-
for (var prop of __getOwnPropSymbols$
|
|
441
|
-
if (__propIsEnum$
|
|
442
|
-
__defNormalProp$
|
|
489
|
+
if (__hasOwnProp$7.call(b, prop))
|
|
490
|
+
__defNormalProp$7(a, prop, b[prop]);
|
|
491
|
+
if (__getOwnPropSymbols$7)
|
|
492
|
+
for (var prop of __getOwnPropSymbols$7(b)) {
|
|
493
|
+
if (__propIsEnum$7.call(b, prop))
|
|
494
|
+
__defNormalProp$7(a, prop, b[prop]);
|
|
443
495
|
}
|
|
444
496
|
return a;
|
|
445
497
|
};
|
|
446
|
-
var __spreadProps$
|
|
498
|
+
var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
|
|
447
499
|
const UseDraggable = defineComponent({
|
|
448
500
|
name: "UseDraggable",
|
|
449
501
|
props: [
|
|
450
502
|
"storageKey",
|
|
503
|
+
"storageType",
|
|
451
504
|
"initialValue",
|
|
452
505
|
"exact",
|
|
453
506
|
"preventDefault",
|
|
@@ -457,7 +510,7 @@ const UseDraggable = defineComponent({
|
|
|
457
510
|
setup(props, { slots }) {
|
|
458
511
|
const target = ref();
|
|
459
512
|
const initialValue = props.storageKey ? useStorage$1(props.storageKey, unref(props.initialValue) || { x: 0, y: 0 }, isClient$1 ? props.storageType === "session" ? sessionStorage : localStorage : void 0) : props.initialValue || { x: 0, y: 0 };
|
|
460
|
-
const data = reactive(useDraggable(target, __spreadProps$
|
|
513
|
+
const data = reactive(useDraggable(target, __spreadProps$6(__spreadValues$7({}, props), {
|
|
461
514
|
initialValue
|
|
462
515
|
})));
|
|
463
516
|
return () => {
|
|
@@ -584,31 +637,31 @@ const UseMouseInElement = defineComponent({
|
|
|
584
637
|
}
|
|
585
638
|
});
|
|
586
639
|
|
|
587
|
-
var __defProp$
|
|
588
|
-
var __defProps$
|
|
589
|
-
var __getOwnPropDescs$
|
|
590
|
-
var __getOwnPropSymbols$
|
|
591
|
-
var __hasOwnProp$
|
|
592
|
-
var __propIsEnum$
|
|
593
|
-
var __defNormalProp$
|
|
594
|
-
var __spreadValues$
|
|
640
|
+
var __defProp$6 = Object.defineProperty;
|
|
641
|
+
var __defProps$5 = Object.defineProperties;
|
|
642
|
+
var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
|
|
643
|
+
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
|
644
|
+
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
|
645
|
+
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
|
646
|
+
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
647
|
+
var __spreadValues$6 = (a, b) => {
|
|
595
648
|
for (var prop in b || (b = {}))
|
|
596
|
-
if (__hasOwnProp$
|
|
597
|
-
__defNormalProp$
|
|
598
|
-
if (__getOwnPropSymbols$
|
|
599
|
-
for (var prop of __getOwnPropSymbols$
|
|
600
|
-
if (__propIsEnum$
|
|
601
|
-
__defNormalProp$
|
|
649
|
+
if (__hasOwnProp$6.call(b, prop))
|
|
650
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
651
|
+
if (__getOwnPropSymbols$6)
|
|
652
|
+
for (var prop of __getOwnPropSymbols$6(b)) {
|
|
653
|
+
if (__propIsEnum$6.call(b, prop))
|
|
654
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
602
655
|
}
|
|
603
656
|
return a;
|
|
604
657
|
};
|
|
605
|
-
var __spreadProps$
|
|
658
|
+
var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
|
|
606
659
|
const UseMousePressed = defineComponent({
|
|
607
660
|
name: "UseMousePressed",
|
|
608
661
|
props: ["touch", "initialValue", "as"],
|
|
609
662
|
setup(props, { slots }) {
|
|
610
663
|
const target = ref();
|
|
611
|
-
const data = reactive(useMousePressed(__spreadProps$
|
|
664
|
+
const data = reactive(useMousePressed(__spreadProps$5(__spreadValues$6({}, props), { target })));
|
|
612
665
|
return () => {
|
|
613
666
|
if (slots.default)
|
|
614
667
|
return h(props.as || "div", { ref: target }, slots.default(data));
|
|
@@ -627,6 +680,37 @@ const UseNetwork = defineComponent({
|
|
|
627
680
|
}
|
|
628
681
|
});
|
|
629
682
|
|
|
683
|
+
var __defProp$5 = Object.defineProperty;
|
|
684
|
+
var __defProps$4 = Object.defineProperties;
|
|
685
|
+
var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
|
|
686
|
+
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
687
|
+
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
688
|
+
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
689
|
+
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
690
|
+
var __spreadValues$5 = (a, b) => {
|
|
691
|
+
for (var prop in b || (b = {}))
|
|
692
|
+
if (__hasOwnProp$5.call(b, prop))
|
|
693
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
694
|
+
if (__getOwnPropSymbols$5)
|
|
695
|
+
for (var prop of __getOwnPropSymbols$5(b)) {
|
|
696
|
+
if (__propIsEnum$5.call(b, prop))
|
|
697
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
698
|
+
}
|
|
699
|
+
return a;
|
|
700
|
+
};
|
|
701
|
+
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
|
702
|
+
const UseNow = defineComponent({
|
|
703
|
+
name: "UseNow",
|
|
704
|
+
props: ["interval"],
|
|
705
|
+
setup(props, { slots }) {
|
|
706
|
+
const data = reactive(useNow(__spreadProps$4(__spreadValues$5({}, props), { controls: true })));
|
|
707
|
+
return () => {
|
|
708
|
+
if (slots.default)
|
|
709
|
+
return slots.default(data);
|
|
710
|
+
};
|
|
711
|
+
}
|
|
712
|
+
});
|
|
713
|
+
|
|
630
714
|
var __defProp$4 = Object.defineProperty;
|
|
631
715
|
var __defProps$3 = Object.defineProperties;
|
|
632
716
|
var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
|
@@ -646,11 +730,39 @@ var __spreadValues$4 = (a, b) => {
|
|
|
646
730
|
return a;
|
|
647
731
|
};
|
|
648
732
|
var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
|
|
649
|
-
const
|
|
650
|
-
name: "
|
|
651
|
-
props: [
|
|
652
|
-
|
|
653
|
-
|
|
733
|
+
const UseOffsetPagination = defineComponent({
|
|
734
|
+
name: "UseOffsetPagination",
|
|
735
|
+
props: [
|
|
736
|
+
"total",
|
|
737
|
+
"page",
|
|
738
|
+
"pageSize",
|
|
739
|
+
"onPageChange",
|
|
740
|
+
"onPageSizeChange",
|
|
741
|
+
"onPageCountChange"
|
|
742
|
+
],
|
|
743
|
+
emits: [
|
|
744
|
+
"page-change",
|
|
745
|
+
"page-size-change",
|
|
746
|
+
"page-count-change"
|
|
747
|
+
],
|
|
748
|
+
setup(props, { slots, emit }) {
|
|
749
|
+
const data = reactive(useOffsetPagination(__spreadProps$3(__spreadValues$4({}, props), {
|
|
750
|
+
onPageChange(...args) {
|
|
751
|
+
var _a;
|
|
752
|
+
(_a = props.onPageChange) == null ? void 0 : _a.call(props, ...args);
|
|
753
|
+
emit("page-change", ...args);
|
|
754
|
+
},
|
|
755
|
+
onPageSizeChange(...args) {
|
|
756
|
+
var _a;
|
|
757
|
+
(_a = props.onPageSizeChange) == null ? void 0 : _a.call(props, ...args);
|
|
758
|
+
emit("page-size-change", ...args);
|
|
759
|
+
},
|
|
760
|
+
onPageCountChange(...args) {
|
|
761
|
+
var _a;
|
|
762
|
+
(_a = props.onPageCountChange) == null ? void 0 : _a.call(props, ...args);
|
|
763
|
+
emit("page-count-change", ...args);
|
|
764
|
+
}
|
|
765
|
+
})));
|
|
654
766
|
return () => {
|
|
655
767
|
if (slots.default)
|
|
656
768
|
return slots.default(data);
|
|
@@ -973,4 +1085,4 @@ const UseWindowSize = defineComponent({
|
|
|
973
1085
|
}
|
|
974
1086
|
});
|
|
975
1087
|
|
|
976
|
-
export { OnClickOutside, UseActiveElement, UseBattery, UseBrowserLocation, UseColorMode, UseDark, UseDeviceMotion, UseDeviceOrientation, UseDevicePixelRatio, UseDevicesList, UseDocumentVisibility, UseDraggable, UseElementBounding, UseElementSize, UseElementVisibility, UseEyeDropper, UseFullscreen, UseGeolocation, UseIdle, UseMouse, UseMouseInElement, UseMousePressed, UseNetwork, UseNow, UseOnline, UsePageLeave, UsePointer, UsePreferredColorScheme, UsePreferredDark, UsePreferredLanguages, UseScreenSafeArea, UseTimeAgo, UseTimestamp, UseVirtualList, UseWindowFocus, UseWindowSize, VOnClickOutside };
|
|
1088
|
+
export { OnClickOutside, OnLongPress, UseActiveElement, UseBattery, UseBrowserLocation, UseColorMode, UseDark, UseDeviceMotion, UseDeviceOrientation, UseDevicePixelRatio, UseDevicesList, UseDocumentVisibility, UseDraggable, UseElementBounding, UseElementSize, UseElementVisibility, UseEyeDropper, UseFullscreen, UseGeolocation, UseIdle, UseMouse, UseMouseInElement, UseMousePressed, UseNetwork, UseNow, UseOffsetPagination, UseOnline, UsePageLeave, UsePointer, UsePreferredColorScheme, UsePreferredDark, UsePreferredLanguages, UseScreenSafeArea, UseTimeAgo, UseTimestamp, UseVirtualList, UseWindowFocus, UseWindowSize, VOnClickOutside, VOnLongPress };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vueuse/components",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.6.1",
|
|
4
4
|
"description": "Renderless components for VueUse",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vue",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
},
|
|
34
34
|
"homepage": "https://github.com/vueuse/vueuse/tree/main/packages/components#readme",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@vueuse/core": "7.
|
|
37
|
-
"@vueuse/shared": "7.
|
|
36
|
+
"@vueuse/core": "7.6.1",
|
|
37
|
+
"@vueuse/shared": "7.6.1",
|
|
38
38
|
"vue-demi": "*"
|
|
39
39
|
}
|
|
40
40
|
}
|