@vueuse/components 7.7.0 → 8.0.0-beta.3
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 +522 -99
- package/index.d.ts +167 -19
- package/index.iife.js +522 -99
- package/index.iife.min.js +1 -1
- package/index.mjs +515 -101
- package/package.json +3 -3
package/index.cjs
CHANGED
|
@@ -92,8 +92,70 @@ function onClickOutside(target, handler, options = {}) {
|
|
|
92
92
|
return stop;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
const
|
|
96
|
-
|
|
95
|
+
const handler = () => {
|
|
96
|
+
let stop = null;
|
|
97
|
+
return (el, binding) => {
|
|
98
|
+
if (stop) {
|
|
99
|
+
stop();
|
|
100
|
+
stop = onClickOutside(el, binding.value);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
stop = onClickOutside(el, binding.value);
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
const vOnClickOutside = handler();
|
|
107
|
+
|
|
108
|
+
const createKeyPredicate = (keyFilter) => {
|
|
109
|
+
if (typeof keyFilter === "function")
|
|
110
|
+
return keyFilter;
|
|
111
|
+
else if (typeof keyFilter === "string")
|
|
112
|
+
return (event) => event.key === keyFilter;
|
|
113
|
+
else if (Array.isArray(keyFilter))
|
|
114
|
+
return (event) => keyFilter.includes(event.key);
|
|
115
|
+
else if (keyFilter)
|
|
116
|
+
return () => true;
|
|
117
|
+
else
|
|
118
|
+
return () => false;
|
|
119
|
+
};
|
|
120
|
+
function onKeyStroke(key, handler, options = {}) {
|
|
121
|
+
const { target = defaultWindow, eventName = "keydown", passive = false } = options;
|
|
122
|
+
const predicate = createKeyPredicate(key);
|
|
123
|
+
const listener = (e) => {
|
|
124
|
+
if (predicate(e))
|
|
125
|
+
handler(e);
|
|
126
|
+
};
|
|
127
|
+
return useEventListener(target, eventName, listener, passive);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
var __defProp$b = Object.defineProperty;
|
|
131
|
+
var __getOwnPropSymbols$c = Object.getOwnPropertySymbols;
|
|
132
|
+
var __hasOwnProp$c = Object.prototype.hasOwnProperty;
|
|
133
|
+
var __propIsEnum$c = Object.prototype.propertyIsEnumerable;
|
|
134
|
+
var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
135
|
+
var __spreadValues$b = (a, b) => {
|
|
136
|
+
for (var prop in b || (b = {}))
|
|
137
|
+
if (__hasOwnProp$c.call(b, prop))
|
|
138
|
+
__defNormalProp$b(a, prop, b[prop]);
|
|
139
|
+
if (__getOwnPropSymbols$c)
|
|
140
|
+
for (var prop of __getOwnPropSymbols$c(b)) {
|
|
141
|
+
if (__propIsEnum$c.call(b, prop))
|
|
142
|
+
__defNormalProp$b(a, prop, b[prop]);
|
|
143
|
+
}
|
|
144
|
+
return a;
|
|
145
|
+
};
|
|
146
|
+
const vOnKeyStroke = (el, binding) => {
|
|
147
|
+
var _a, _b;
|
|
148
|
+
const keys = (_b = (_a = binding.arg) == null ? void 0 : _a.split(",")) != null ? _b : [];
|
|
149
|
+
if (typeof binding.value === "function") {
|
|
150
|
+
onKeyStroke(keys, binding.value, {
|
|
151
|
+
target: el
|
|
152
|
+
});
|
|
153
|
+
} else {
|
|
154
|
+
const [handler, options] = binding.value;
|
|
155
|
+
onKeyStroke(keys, handler, __spreadValues$b({
|
|
156
|
+
target: el
|
|
157
|
+
}, options));
|
|
158
|
+
}
|
|
97
159
|
};
|
|
98
160
|
|
|
99
161
|
const DEFAULT_DELAY = 500;
|
|
@@ -132,11 +194,11 @@ const OnLongPress = vueDemi.defineComponent({
|
|
|
132
194
|
}
|
|
133
195
|
});
|
|
134
196
|
|
|
135
|
-
const
|
|
197
|
+
const vOnLongPress = (el, binding) => {
|
|
136
198
|
if (typeof binding.value === "function")
|
|
137
199
|
onLongPress(el, binding.value);
|
|
138
200
|
else
|
|
139
|
-
onLongPress(el, binding.value
|
|
201
|
+
onLongPress(el, ...binding.value);
|
|
140
202
|
};
|
|
141
203
|
|
|
142
204
|
const UseActiveElement = vueDemi.defineComponent({
|
|
@@ -317,19 +379,19 @@ function usePreferredDark(options) {
|
|
|
317
379
|
return useMediaQuery("(prefers-color-scheme: dark)", options);
|
|
318
380
|
}
|
|
319
381
|
|
|
320
|
-
var __defProp$
|
|
321
|
-
var __getOwnPropSymbols$
|
|
322
|
-
var __hasOwnProp$
|
|
323
|
-
var __propIsEnum$
|
|
324
|
-
var __defNormalProp$
|
|
325
|
-
var __spreadValues$
|
|
382
|
+
var __defProp$a = Object.defineProperty;
|
|
383
|
+
var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
|
|
384
|
+
var __hasOwnProp$b = Object.prototype.hasOwnProperty;
|
|
385
|
+
var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
|
|
386
|
+
var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
387
|
+
var __spreadValues$a = (a, b) => {
|
|
326
388
|
for (var prop in b || (b = {}))
|
|
327
|
-
if (__hasOwnProp$
|
|
328
|
-
__defNormalProp$
|
|
329
|
-
if (__getOwnPropSymbols$
|
|
330
|
-
for (var prop of __getOwnPropSymbols$
|
|
331
|
-
if (__propIsEnum$
|
|
332
|
-
__defNormalProp$
|
|
389
|
+
if (__hasOwnProp$b.call(b, prop))
|
|
390
|
+
__defNormalProp$a(a, prop, b[prop]);
|
|
391
|
+
if (__getOwnPropSymbols$b)
|
|
392
|
+
for (var prop of __getOwnPropSymbols$b(b)) {
|
|
393
|
+
if (__propIsEnum$b.call(b, prop))
|
|
394
|
+
__defNormalProp$a(a, prop, b[prop]);
|
|
333
395
|
}
|
|
334
396
|
return a;
|
|
335
397
|
};
|
|
@@ -343,7 +405,7 @@ function useColorMode(options = {}) {
|
|
|
343
405
|
listenToStorageChanges = true,
|
|
344
406
|
storageRef
|
|
345
407
|
} = options;
|
|
346
|
-
const modes = __spreadValues$
|
|
408
|
+
const modes = __spreadValues$a({
|
|
347
409
|
auto: "",
|
|
348
410
|
light: "light",
|
|
349
411
|
dark: "dark"
|
|
@@ -481,25 +543,25 @@ const UseDocumentVisibility = vueDemi.defineComponent({
|
|
|
481
543
|
}
|
|
482
544
|
});
|
|
483
545
|
|
|
484
|
-
var __defProp$
|
|
485
|
-
var __defProps$
|
|
486
|
-
var __getOwnPropDescs$
|
|
487
|
-
var __getOwnPropSymbols$
|
|
488
|
-
var __hasOwnProp$
|
|
489
|
-
var __propIsEnum$
|
|
490
|
-
var __defNormalProp$
|
|
491
|
-
var __spreadValues$
|
|
546
|
+
var __defProp$9 = Object.defineProperty;
|
|
547
|
+
var __defProps$8 = Object.defineProperties;
|
|
548
|
+
var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
|
|
549
|
+
var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
|
|
550
|
+
var __hasOwnProp$a = Object.prototype.hasOwnProperty;
|
|
551
|
+
var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
|
|
552
|
+
var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
553
|
+
var __spreadValues$9 = (a, b) => {
|
|
492
554
|
for (var prop in b || (b = {}))
|
|
493
|
-
if (__hasOwnProp$
|
|
494
|
-
__defNormalProp$
|
|
495
|
-
if (__getOwnPropSymbols$
|
|
496
|
-
for (var prop of __getOwnPropSymbols$
|
|
497
|
-
if (__propIsEnum$
|
|
498
|
-
__defNormalProp$
|
|
555
|
+
if (__hasOwnProp$a.call(b, prop))
|
|
556
|
+
__defNormalProp$9(a, prop, b[prop]);
|
|
557
|
+
if (__getOwnPropSymbols$a)
|
|
558
|
+
for (var prop of __getOwnPropSymbols$a(b)) {
|
|
559
|
+
if (__propIsEnum$a.call(b, prop))
|
|
560
|
+
__defNormalProp$9(a, prop, b[prop]);
|
|
499
561
|
}
|
|
500
562
|
return a;
|
|
501
563
|
};
|
|
502
|
-
var __spreadProps$
|
|
564
|
+
var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
|
|
503
565
|
const UseDraggable = vueDemi.defineComponent({
|
|
504
566
|
name: "UseDraggable",
|
|
505
567
|
props: [
|
|
@@ -514,7 +576,7 @@ const UseDraggable = vueDemi.defineComponent({
|
|
|
514
576
|
setup(props, { slots }) {
|
|
515
577
|
const target = vueDemi.ref();
|
|
516
578
|
const initialValue = props.storageKey ? core.useStorage(props.storageKey, vueDemi.unref(props.initialValue) || { x: 0, y: 0 }, core.isClient ? props.storageType === "session" ? sessionStorage : localStorage : void 0) : props.initialValue || { x: 0, y: 0 };
|
|
517
|
-
const data = vueDemi.reactive(core.useDraggable(target, __spreadProps$
|
|
579
|
+
const data = vueDemi.reactive(core.useDraggable(target, __spreadProps$8(__spreadValues$9({}, props), {
|
|
518
580
|
initialValue
|
|
519
581
|
})));
|
|
520
582
|
return () => {
|
|
@@ -537,6 +599,20 @@ const UseElementBounding = vueDemi.defineComponent({
|
|
|
537
599
|
}
|
|
538
600
|
});
|
|
539
601
|
|
|
602
|
+
function useElementHover(el) {
|
|
603
|
+
const isHovered = vueDemi.ref(false);
|
|
604
|
+
useEventListener(el, "mouseenter", () => isHovered.value = true);
|
|
605
|
+
useEventListener(el, "mouseleave", () => isHovered.value = false);
|
|
606
|
+
return isHovered;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
const vElementHover = (el, binding) => {
|
|
610
|
+
if (typeof binding.value === "function") {
|
|
611
|
+
const isHovered = useElementHover(el);
|
|
612
|
+
vueDemi.watch(isHovered, (v) => binding.value(v));
|
|
613
|
+
}
|
|
614
|
+
};
|
|
615
|
+
|
|
540
616
|
const UseElementSize = vueDemi.defineComponent({
|
|
541
617
|
name: "UseElementSize",
|
|
542
618
|
props: ["width", "height", "box"],
|
|
@@ -550,6 +626,74 @@ const UseElementSize = vueDemi.defineComponent({
|
|
|
550
626
|
}
|
|
551
627
|
});
|
|
552
628
|
|
|
629
|
+
var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
|
|
630
|
+
var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
|
|
631
|
+
var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
|
|
632
|
+
var __objRest = (source, exclude) => {
|
|
633
|
+
var target = {};
|
|
634
|
+
for (var prop in source)
|
|
635
|
+
if (__hasOwnProp$9.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
636
|
+
target[prop] = source[prop];
|
|
637
|
+
if (source != null && __getOwnPropSymbols$9)
|
|
638
|
+
for (var prop of __getOwnPropSymbols$9(source)) {
|
|
639
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$9.call(source, prop))
|
|
640
|
+
target[prop] = source[prop];
|
|
641
|
+
}
|
|
642
|
+
return target;
|
|
643
|
+
};
|
|
644
|
+
function useResizeObserver(target, callback, options = {}) {
|
|
645
|
+
const _a = options, { window = defaultWindow } = _a, observerOptions = __objRest(_a, ["window"]);
|
|
646
|
+
let observer;
|
|
647
|
+
const isSupported = window && "ResizeObserver" in window;
|
|
648
|
+
const cleanup = () => {
|
|
649
|
+
if (observer) {
|
|
650
|
+
observer.disconnect();
|
|
651
|
+
observer = void 0;
|
|
652
|
+
}
|
|
653
|
+
};
|
|
654
|
+
const stopWatch = vueDemi.watch(() => unrefElement(target), (el) => {
|
|
655
|
+
cleanup();
|
|
656
|
+
if (isSupported && window && el) {
|
|
657
|
+
observer = new window.ResizeObserver(callback);
|
|
658
|
+
observer.observe(el, observerOptions);
|
|
659
|
+
}
|
|
660
|
+
}, { immediate: true, flush: "post" });
|
|
661
|
+
const stop = () => {
|
|
662
|
+
cleanup();
|
|
663
|
+
stopWatch();
|
|
664
|
+
};
|
|
665
|
+
shared.tryOnScopeDispose(stop);
|
|
666
|
+
return {
|
|
667
|
+
isSupported,
|
|
668
|
+
stop
|
|
669
|
+
};
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
function useElementSize(target, initialSize = { width: 0, height: 0 }, options = {}) {
|
|
673
|
+
const width = vueDemi.ref(initialSize.width);
|
|
674
|
+
const height = vueDemi.ref(initialSize.height);
|
|
675
|
+
useResizeObserver(target, ([entry]) => {
|
|
676
|
+
width.value = entry.contentRect.width;
|
|
677
|
+
height.value = entry.contentRect.height;
|
|
678
|
+
}, options);
|
|
679
|
+
vueDemi.watch(() => unrefElement(target), (ele) => {
|
|
680
|
+
width.value = ele ? initialSize.width : 0;
|
|
681
|
+
height.value = ele ? initialSize.height : 0;
|
|
682
|
+
});
|
|
683
|
+
return {
|
|
684
|
+
width,
|
|
685
|
+
height
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
const vElementSize = (el, binding) => {
|
|
690
|
+
var _a;
|
|
691
|
+
const handler = typeof binding.value === "function" ? binding.value : (_a = binding.value) == null ? void 0 : _a[0];
|
|
692
|
+
const options = typeof binding.value === "function" ? [] : binding.value.slice(1);
|
|
693
|
+
const { width, height } = useElementSize(el, ...options);
|
|
694
|
+
vueDemi.watch([width, height], ([width2, height2]) => handler({ width: width2, height: height2 }));
|
|
695
|
+
};
|
|
696
|
+
|
|
553
697
|
const UseElementVisibility = vueDemi.defineComponent({
|
|
554
698
|
name: "UseElementVisibility",
|
|
555
699
|
props: ["as"],
|
|
@@ -616,6 +760,160 @@ const UseIdle = vueDemi.defineComponent({
|
|
|
616
760
|
}
|
|
617
761
|
});
|
|
618
762
|
|
|
763
|
+
function useScroll(element, options = {}) {
|
|
764
|
+
const {
|
|
765
|
+
throttle = 0,
|
|
766
|
+
idle = 200,
|
|
767
|
+
onStop = shared.noop,
|
|
768
|
+
onScroll = shared.noop,
|
|
769
|
+
offset = {
|
|
770
|
+
left: 0,
|
|
771
|
+
right: 0,
|
|
772
|
+
top: 0,
|
|
773
|
+
bottom: 0
|
|
774
|
+
},
|
|
775
|
+
eventListenerOptions = {
|
|
776
|
+
capture: false,
|
|
777
|
+
passive: true
|
|
778
|
+
}
|
|
779
|
+
} = options;
|
|
780
|
+
const x = vueDemi.ref(0);
|
|
781
|
+
const y = vueDemi.ref(0);
|
|
782
|
+
const isScrolling = vueDemi.ref(false);
|
|
783
|
+
const arrivedState = vueDemi.reactive({
|
|
784
|
+
left: true,
|
|
785
|
+
right: false,
|
|
786
|
+
top: true,
|
|
787
|
+
bottom: false
|
|
788
|
+
});
|
|
789
|
+
const directions = vueDemi.reactive({
|
|
790
|
+
left: false,
|
|
791
|
+
right: false,
|
|
792
|
+
top: false,
|
|
793
|
+
bottom: false
|
|
794
|
+
});
|
|
795
|
+
if (element) {
|
|
796
|
+
const onScrollEnd = shared.useDebounceFn((e) => {
|
|
797
|
+
isScrolling.value = false;
|
|
798
|
+
directions.left = false;
|
|
799
|
+
directions.right = false;
|
|
800
|
+
directions.top = false;
|
|
801
|
+
directions.bottom = false;
|
|
802
|
+
onStop(e);
|
|
803
|
+
}, throttle + idle);
|
|
804
|
+
const onScrollHandler = (e) => {
|
|
805
|
+
const eventTarget = e.target === document ? e.target.documentElement : e.target;
|
|
806
|
+
const scrollLeft = eventTarget.scrollLeft;
|
|
807
|
+
directions.left = scrollLeft < x.value;
|
|
808
|
+
directions.right = scrollLeft > x.value;
|
|
809
|
+
arrivedState.left = scrollLeft <= 0 + (offset.left || 0);
|
|
810
|
+
arrivedState.right = scrollLeft + eventTarget.clientWidth >= eventTarget.scrollWidth - (offset.right || 0);
|
|
811
|
+
x.value = scrollLeft;
|
|
812
|
+
const scrollTop = eventTarget.scrollTop;
|
|
813
|
+
directions.top = scrollTop < y.value;
|
|
814
|
+
directions.bottom = scrollTop > y.value;
|
|
815
|
+
arrivedState.top = scrollTop <= 0 + (offset.top || 0);
|
|
816
|
+
arrivedState.bottom = scrollTop + eventTarget.clientHeight >= eventTarget.scrollHeight - (offset.bottom || 0);
|
|
817
|
+
y.value = scrollTop;
|
|
818
|
+
isScrolling.value = true;
|
|
819
|
+
onScrollEnd(e);
|
|
820
|
+
onScroll(e);
|
|
821
|
+
};
|
|
822
|
+
useEventListener(element, "scroll", throttle ? shared.useThrottleFn(onScrollHandler, throttle) : onScrollHandler, eventListenerOptions);
|
|
823
|
+
}
|
|
824
|
+
return {
|
|
825
|
+
x,
|
|
826
|
+
y,
|
|
827
|
+
isScrolling,
|
|
828
|
+
arrivedState,
|
|
829
|
+
directions
|
|
830
|
+
};
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
var __defProp$8 = Object.defineProperty;
|
|
834
|
+
var __defProps$7 = Object.defineProperties;
|
|
835
|
+
var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
|
|
836
|
+
var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
|
|
837
|
+
var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
|
|
838
|
+
var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
|
|
839
|
+
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
840
|
+
var __spreadValues$8 = (a, b) => {
|
|
841
|
+
for (var prop in b || (b = {}))
|
|
842
|
+
if (__hasOwnProp$8.call(b, prop))
|
|
843
|
+
__defNormalProp$8(a, prop, b[prop]);
|
|
844
|
+
if (__getOwnPropSymbols$8)
|
|
845
|
+
for (var prop of __getOwnPropSymbols$8(b)) {
|
|
846
|
+
if (__propIsEnum$8.call(b, prop))
|
|
847
|
+
__defNormalProp$8(a, prop, b[prop]);
|
|
848
|
+
}
|
|
849
|
+
return a;
|
|
850
|
+
};
|
|
851
|
+
var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
|
|
852
|
+
function useInfiniteScroll(element, onLoadMore, options = {}) {
|
|
853
|
+
var _a;
|
|
854
|
+
const state = vueDemi.reactive(useScroll(element, __spreadProps$7(__spreadValues$8({}, options), {
|
|
855
|
+
offset: __spreadValues$8({
|
|
856
|
+
bottom: (_a = options.distance) != null ? _a : 0
|
|
857
|
+
}, options.offset)
|
|
858
|
+
})));
|
|
859
|
+
vueDemi.watch(() => state.arrivedState.bottom, (v) => {
|
|
860
|
+
if (v)
|
|
861
|
+
onLoadMore(state);
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
const vInfiniteScroll = (el, binding) => {
|
|
866
|
+
if (typeof binding.value === "function")
|
|
867
|
+
useInfiniteScroll(el, binding.value);
|
|
868
|
+
else
|
|
869
|
+
useInfiniteScroll(el, ...binding.value);
|
|
870
|
+
};
|
|
871
|
+
|
|
872
|
+
function useIntersectionObserver(target, callback, options = {}) {
|
|
873
|
+
const {
|
|
874
|
+
root,
|
|
875
|
+
rootMargin = "0px",
|
|
876
|
+
threshold = 0.1,
|
|
877
|
+
window = defaultWindow
|
|
878
|
+
} = options;
|
|
879
|
+
const isSupported = window && "IntersectionObserver" in window;
|
|
880
|
+
let cleanup = shared.noop;
|
|
881
|
+
const stopWatch = isSupported ? vueDemi.watch(() => ({
|
|
882
|
+
el: unrefElement(target),
|
|
883
|
+
root: unrefElement(root)
|
|
884
|
+
}), ({ el, root: root2 }) => {
|
|
885
|
+
cleanup();
|
|
886
|
+
if (!el)
|
|
887
|
+
return;
|
|
888
|
+
const observer = new window.IntersectionObserver(callback, {
|
|
889
|
+
root: root2,
|
|
890
|
+
rootMargin,
|
|
891
|
+
threshold
|
|
892
|
+
});
|
|
893
|
+
observer.observe(el);
|
|
894
|
+
cleanup = () => {
|
|
895
|
+
observer.disconnect();
|
|
896
|
+
cleanup = shared.noop;
|
|
897
|
+
};
|
|
898
|
+
}, { immediate: true, flush: "post" }) : shared.noop;
|
|
899
|
+
const stop = () => {
|
|
900
|
+
cleanup();
|
|
901
|
+
stopWatch();
|
|
902
|
+
};
|
|
903
|
+
shared.tryOnScopeDispose(stop);
|
|
904
|
+
return {
|
|
905
|
+
isSupported,
|
|
906
|
+
stop
|
|
907
|
+
};
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
const vIntersectionObserver = (el, binding) => {
|
|
911
|
+
if (typeof binding.value === "function")
|
|
912
|
+
useIntersectionObserver(el, binding.value);
|
|
913
|
+
else
|
|
914
|
+
useIntersectionObserver(el, ...binding.value);
|
|
915
|
+
};
|
|
916
|
+
|
|
619
917
|
const UseMouse = vueDemi.defineComponent({
|
|
620
918
|
name: "UseMouse",
|
|
621
919
|
props: ["touch", "resetOnTouchEnds", "initialValue"],
|
|
@@ -641,31 +939,31 @@ const UseMouseInElement = vueDemi.defineComponent({
|
|
|
641
939
|
}
|
|
642
940
|
});
|
|
643
941
|
|
|
644
|
-
var __defProp$
|
|
645
|
-
var __defProps$
|
|
646
|
-
var __getOwnPropDescs$
|
|
647
|
-
var __getOwnPropSymbols$
|
|
648
|
-
var __hasOwnProp$
|
|
649
|
-
var __propIsEnum$
|
|
650
|
-
var __defNormalProp$
|
|
651
|
-
var __spreadValues$
|
|
942
|
+
var __defProp$7 = Object.defineProperty;
|
|
943
|
+
var __defProps$6 = Object.defineProperties;
|
|
944
|
+
var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
|
|
945
|
+
var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
|
|
946
|
+
var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
|
|
947
|
+
var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
|
|
948
|
+
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
949
|
+
var __spreadValues$7 = (a, b) => {
|
|
652
950
|
for (var prop in b || (b = {}))
|
|
653
|
-
if (__hasOwnProp$
|
|
654
|
-
__defNormalProp$
|
|
655
|
-
if (__getOwnPropSymbols$
|
|
656
|
-
for (var prop of __getOwnPropSymbols$
|
|
657
|
-
if (__propIsEnum$
|
|
658
|
-
__defNormalProp$
|
|
951
|
+
if (__hasOwnProp$7.call(b, prop))
|
|
952
|
+
__defNormalProp$7(a, prop, b[prop]);
|
|
953
|
+
if (__getOwnPropSymbols$7)
|
|
954
|
+
for (var prop of __getOwnPropSymbols$7(b)) {
|
|
955
|
+
if (__propIsEnum$7.call(b, prop))
|
|
956
|
+
__defNormalProp$7(a, prop, b[prop]);
|
|
659
957
|
}
|
|
660
958
|
return a;
|
|
661
959
|
};
|
|
662
|
-
var __spreadProps$
|
|
960
|
+
var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
|
|
663
961
|
const UseMousePressed = vueDemi.defineComponent({
|
|
664
962
|
name: "UseMousePressed",
|
|
665
963
|
props: ["touch", "initialValue", "as"],
|
|
666
964
|
setup(props, { slots }) {
|
|
667
965
|
const target = vueDemi.ref();
|
|
668
|
-
const data = vueDemi.reactive(core.useMousePressed(__spreadProps$
|
|
966
|
+
const data = vueDemi.reactive(core.useMousePressed(__spreadProps$6(__spreadValues$7({}, props), { target })));
|
|
669
967
|
return () => {
|
|
670
968
|
if (slots.default)
|
|
671
969
|
return vueDemi.h(props.as || "div", { ref: target }, slots.default(data));
|
|
@@ -684,30 +982,30 @@ const UseNetwork = vueDemi.defineComponent({
|
|
|
684
982
|
}
|
|
685
983
|
});
|
|
686
984
|
|
|
687
|
-
var __defProp$
|
|
688
|
-
var __defProps$
|
|
689
|
-
var __getOwnPropDescs$
|
|
690
|
-
var __getOwnPropSymbols$
|
|
691
|
-
var __hasOwnProp$
|
|
692
|
-
var __propIsEnum$
|
|
693
|
-
var __defNormalProp$
|
|
694
|
-
var __spreadValues$
|
|
985
|
+
var __defProp$6 = Object.defineProperty;
|
|
986
|
+
var __defProps$5 = Object.defineProperties;
|
|
987
|
+
var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
|
|
988
|
+
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
|
989
|
+
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
|
990
|
+
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
|
991
|
+
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
992
|
+
var __spreadValues$6 = (a, b) => {
|
|
695
993
|
for (var prop in b || (b = {}))
|
|
696
|
-
if (__hasOwnProp$
|
|
697
|
-
__defNormalProp$
|
|
698
|
-
if (__getOwnPropSymbols$
|
|
699
|
-
for (var prop of __getOwnPropSymbols$
|
|
700
|
-
if (__propIsEnum$
|
|
701
|
-
__defNormalProp$
|
|
994
|
+
if (__hasOwnProp$6.call(b, prop))
|
|
995
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
996
|
+
if (__getOwnPropSymbols$6)
|
|
997
|
+
for (var prop of __getOwnPropSymbols$6(b)) {
|
|
998
|
+
if (__propIsEnum$6.call(b, prop))
|
|
999
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
702
1000
|
}
|
|
703
1001
|
return a;
|
|
704
1002
|
};
|
|
705
|
-
var __spreadProps$
|
|
1003
|
+
var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
|
|
706
1004
|
const UseNow = vueDemi.defineComponent({
|
|
707
1005
|
name: "UseNow",
|
|
708
1006
|
props: ["interval"],
|
|
709
1007
|
setup(props, { slots }) {
|
|
710
|
-
const data = vueDemi.reactive(core.useNow(__spreadProps$
|
|
1008
|
+
const data = vueDemi.reactive(core.useNow(__spreadProps$5(__spreadValues$6({}, props), { controls: true })));
|
|
711
1009
|
return () => {
|
|
712
1010
|
if (slots.default)
|
|
713
1011
|
return slots.default(data);
|
|
@@ -715,25 +1013,25 @@ const UseNow = vueDemi.defineComponent({
|
|
|
715
1013
|
}
|
|
716
1014
|
});
|
|
717
1015
|
|
|
718
|
-
var __defProp$
|
|
719
|
-
var __defProps$
|
|
720
|
-
var __getOwnPropDescs$
|
|
721
|
-
var __getOwnPropSymbols$
|
|
722
|
-
var __hasOwnProp$
|
|
723
|
-
var __propIsEnum$
|
|
724
|
-
var __defNormalProp$
|
|
725
|
-
var __spreadValues$
|
|
1016
|
+
var __defProp$5 = Object.defineProperty;
|
|
1017
|
+
var __defProps$4 = Object.defineProperties;
|
|
1018
|
+
var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
|
|
1019
|
+
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
1020
|
+
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
1021
|
+
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
1022
|
+
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1023
|
+
var __spreadValues$5 = (a, b) => {
|
|
726
1024
|
for (var prop in b || (b = {}))
|
|
727
|
-
if (__hasOwnProp$
|
|
728
|
-
__defNormalProp$
|
|
729
|
-
if (__getOwnPropSymbols$
|
|
730
|
-
for (var prop of __getOwnPropSymbols$
|
|
731
|
-
if (__propIsEnum$
|
|
732
|
-
__defNormalProp$
|
|
1025
|
+
if (__hasOwnProp$5.call(b, prop))
|
|
1026
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
1027
|
+
if (__getOwnPropSymbols$5)
|
|
1028
|
+
for (var prop of __getOwnPropSymbols$5(b)) {
|
|
1029
|
+
if (__propIsEnum$5.call(b, prop))
|
|
1030
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
733
1031
|
}
|
|
734
1032
|
return a;
|
|
735
1033
|
};
|
|
736
|
-
var __spreadProps$
|
|
1034
|
+
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
|
737
1035
|
const UseOffsetPagination = vueDemi.defineComponent({
|
|
738
1036
|
name: "UseOffsetPagination",
|
|
739
1037
|
props: [
|
|
@@ -750,7 +1048,7 @@ const UseOffsetPagination = vueDemi.defineComponent({
|
|
|
750
1048
|
"page-count-change"
|
|
751
1049
|
],
|
|
752
1050
|
setup(props, { slots, emit }) {
|
|
753
|
-
const data = vueDemi.reactive(core.useOffsetPagination(__spreadProps$
|
|
1051
|
+
const data = vueDemi.reactive(core.useOffsetPagination(__spreadProps$4(__spreadValues$5({}, props), {
|
|
754
1052
|
onPageChange(...args) {
|
|
755
1053
|
var _a;
|
|
756
1054
|
(_a = props.onPageChange) == null ? void 0 : _a.call(props, ...args);
|
|
@@ -800,25 +1098,25 @@ const UsePageLeave = vueDemi.defineComponent({
|
|
|
800
1098
|
}
|
|
801
1099
|
});
|
|
802
1100
|
|
|
803
|
-
var __defProp$
|
|
804
|
-
var __defProps$
|
|
805
|
-
var __getOwnPropDescs$
|
|
806
|
-
var __getOwnPropSymbols$
|
|
807
|
-
var __hasOwnProp$
|
|
808
|
-
var __propIsEnum$
|
|
809
|
-
var __defNormalProp$
|
|
810
|
-
var __spreadValues$
|
|
1101
|
+
var __defProp$4 = Object.defineProperty;
|
|
1102
|
+
var __defProps$3 = Object.defineProperties;
|
|
1103
|
+
var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
|
1104
|
+
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
1105
|
+
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
1106
|
+
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
1107
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1108
|
+
var __spreadValues$4 = (a, b) => {
|
|
811
1109
|
for (var prop in b || (b = {}))
|
|
812
|
-
if (__hasOwnProp$
|
|
813
|
-
__defNormalProp$
|
|
814
|
-
if (__getOwnPropSymbols$
|
|
815
|
-
for (var prop of __getOwnPropSymbols$
|
|
816
|
-
if (__propIsEnum$
|
|
817
|
-
__defNormalProp$
|
|
1110
|
+
if (__hasOwnProp$4.call(b, prop))
|
|
1111
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
1112
|
+
if (__getOwnPropSymbols$4)
|
|
1113
|
+
for (var prop of __getOwnPropSymbols$4(b)) {
|
|
1114
|
+
if (__propIsEnum$4.call(b, prop))
|
|
1115
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
818
1116
|
}
|
|
819
1117
|
return a;
|
|
820
1118
|
};
|
|
821
|
-
var __spreadProps$
|
|
1119
|
+
var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
|
|
822
1120
|
const UsePointer = vueDemi.defineComponent({
|
|
823
1121
|
name: "UsePointer",
|
|
824
1122
|
props: [
|
|
@@ -828,7 +1126,7 @@ const UsePointer = vueDemi.defineComponent({
|
|
|
828
1126
|
],
|
|
829
1127
|
setup(props, { slots }) {
|
|
830
1128
|
const el = vueDemi.ref(null);
|
|
831
|
-
const data = vueDemi.reactive(core.usePointer(__spreadProps$
|
|
1129
|
+
const data = vueDemi.reactive(core.usePointer(__spreadProps$3(__spreadValues$4({}, props), {
|
|
832
1130
|
target: props.target === "self" ? el : defaultWindow
|
|
833
1131
|
})));
|
|
834
1132
|
return () => {
|
|
@@ -968,6 +1266,122 @@ const UseScreenSafeArea = vueDemi.defineComponent({
|
|
|
968
1266
|
}
|
|
969
1267
|
});
|
|
970
1268
|
|
|
1269
|
+
var __defProp$3 = Object.defineProperty;
|
|
1270
|
+
var __defProps$2 = Object.defineProperties;
|
|
1271
|
+
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
1272
|
+
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
1273
|
+
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
1274
|
+
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
1275
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1276
|
+
var __spreadValues$3 = (a, b) => {
|
|
1277
|
+
for (var prop in b || (b = {}))
|
|
1278
|
+
if (__hasOwnProp$3.call(b, prop))
|
|
1279
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
1280
|
+
if (__getOwnPropSymbols$3)
|
|
1281
|
+
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
1282
|
+
if (__propIsEnum$3.call(b, prop))
|
|
1283
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
1284
|
+
}
|
|
1285
|
+
return a;
|
|
1286
|
+
};
|
|
1287
|
+
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
|
1288
|
+
const vScroll = (el, binding) => {
|
|
1289
|
+
if (typeof binding.value === "function") {
|
|
1290
|
+
const handler = binding.value;
|
|
1291
|
+
const state = useScroll(el, {
|
|
1292
|
+
onScroll() {
|
|
1293
|
+
handler(state);
|
|
1294
|
+
},
|
|
1295
|
+
onStop() {
|
|
1296
|
+
handler(state);
|
|
1297
|
+
}
|
|
1298
|
+
});
|
|
1299
|
+
} else {
|
|
1300
|
+
const [handler, options] = binding.value;
|
|
1301
|
+
const state = useScroll(el, __spreadProps$2(__spreadValues$3({}, options), {
|
|
1302
|
+
onScroll(e) {
|
|
1303
|
+
var _a;
|
|
1304
|
+
(_a = options.onScroll) == null ? void 0 : _a.call(options, e);
|
|
1305
|
+
handler(state);
|
|
1306
|
+
},
|
|
1307
|
+
onStop(e) {
|
|
1308
|
+
var _a;
|
|
1309
|
+
(_a = options.onStop) == null ? void 0 : _a.call(options, e);
|
|
1310
|
+
handler(state);
|
|
1311
|
+
}
|
|
1312
|
+
}));
|
|
1313
|
+
}
|
|
1314
|
+
};
|
|
1315
|
+
|
|
1316
|
+
var _a, _b;
|
|
1317
|
+
function preventDefault(rawEvent) {
|
|
1318
|
+
const e = rawEvent || window.event;
|
|
1319
|
+
if (e.touches.length > 1)
|
|
1320
|
+
return true;
|
|
1321
|
+
if (e.preventDefault)
|
|
1322
|
+
e.preventDefault();
|
|
1323
|
+
return false;
|
|
1324
|
+
}
|
|
1325
|
+
const isIOS = shared.isClient && (window == null ? void 0 : window.navigator) && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.platform) && /iP(ad|hone|od)/.test((_b = window == null ? void 0 : window.navigator) == null ? void 0 : _b.platform);
|
|
1326
|
+
function useScrollLock(element, initialState = false) {
|
|
1327
|
+
const isLocked = vueDemi.ref(initialState);
|
|
1328
|
+
let touchMoveListener = null;
|
|
1329
|
+
let initialOverflow;
|
|
1330
|
+
vueDemi.watch(() => vueDemi.unref(element), (el) => {
|
|
1331
|
+
if (el) {
|
|
1332
|
+
const ele = el;
|
|
1333
|
+
initialOverflow = ele.style.overflow;
|
|
1334
|
+
if (isLocked.value)
|
|
1335
|
+
ele.style.overflow = "hidden";
|
|
1336
|
+
}
|
|
1337
|
+
}, {
|
|
1338
|
+
immediate: true
|
|
1339
|
+
});
|
|
1340
|
+
const lock = () => {
|
|
1341
|
+
const ele = vueDemi.unref(element);
|
|
1342
|
+
if (!ele || isLocked.value)
|
|
1343
|
+
return;
|
|
1344
|
+
if (isIOS) {
|
|
1345
|
+
touchMoveListener = useEventListener(document, "touchmove", preventDefault, { passive: false });
|
|
1346
|
+
}
|
|
1347
|
+
ele.style.overflow = "hidden";
|
|
1348
|
+
isLocked.value = true;
|
|
1349
|
+
};
|
|
1350
|
+
const unlock = () => {
|
|
1351
|
+
const ele = vueDemi.unref(element);
|
|
1352
|
+
if (!ele || !isLocked.value)
|
|
1353
|
+
return;
|
|
1354
|
+
isIOS && (touchMoveListener == null ? void 0 : touchMoveListener());
|
|
1355
|
+
ele.style.overflow = initialOverflow;
|
|
1356
|
+
isLocked.value = false;
|
|
1357
|
+
};
|
|
1358
|
+
return vueDemi.computed({
|
|
1359
|
+
get() {
|
|
1360
|
+
return isLocked.value;
|
|
1361
|
+
},
|
|
1362
|
+
set(v) {
|
|
1363
|
+
if (v)
|
|
1364
|
+
lock();
|
|
1365
|
+
else
|
|
1366
|
+
unlock();
|
|
1367
|
+
}
|
|
1368
|
+
});
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
const onScrollLock = () => {
|
|
1372
|
+
let isMounted = false;
|
|
1373
|
+
const state = vueDemi.ref(false);
|
|
1374
|
+
return (el, binding) => {
|
|
1375
|
+
state.value = binding.value;
|
|
1376
|
+
if (isMounted)
|
|
1377
|
+
return;
|
|
1378
|
+
isMounted = true;
|
|
1379
|
+
const isLocked = useScrollLock(el, binding.value);
|
|
1380
|
+
vueDemi.watch(state, (v) => isLocked.value = v);
|
|
1381
|
+
};
|
|
1382
|
+
};
|
|
1383
|
+
const vScrollLock = onScrollLock();
|
|
1384
|
+
|
|
971
1385
|
var __defProp$2 = Object.defineProperty;
|
|
972
1386
|
var __defProps$1 = Object.defineProperties;
|
|
973
1387
|
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
@@ -1127,5 +1541,14 @@ exports.UseTimestamp = UseTimestamp;
|
|
|
1127
1541
|
exports.UseVirtualList = UseVirtualList;
|
|
1128
1542
|
exports.UseWindowFocus = UseWindowFocus;
|
|
1129
1543
|
exports.UseWindowSize = UseWindowSize;
|
|
1130
|
-
exports.VOnClickOutside =
|
|
1131
|
-
exports.VOnLongPress =
|
|
1544
|
+
exports.VOnClickOutside = vOnClickOutside;
|
|
1545
|
+
exports.VOnLongPress = vOnLongPress;
|
|
1546
|
+
exports.vElementHover = vElementHover;
|
|
1547
|
+
exports.vElementSize = vElementSize;
|
|
1548
|
+
exports.vInfiniteScroll = vInfiniteScroll;
|
|
1549
|
+
exports.vIntersectionObserver = vIntersectionObserver;
|
|
1550
|
+
exports.vOnClickOutside = vOnClickOutside;
|
|
1551
|
+
exports.vOnKeyStroke = vOnKeyStroke;
|
|
1552
|
+
exports.vOnLongPress = vOnLongPress;
|
|
1553
|
+
exports.vScroll = vScroll;
|
|
1554
|
+
exports.vScrollLock = vScrollLock;
|