@vueuse/components 12.2.0 → 12.4.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 +468 -174
- package/index.d.cts +161 -26
- package/index.d.mts +161 -26
- package/index.d.ts +161 -26
- package/index.iife.js +468 -174
- package/index.iife.min.js +1 -1
- package/index.mjs +445 -153
- package/package.json +3 -3
package/index.iife.js
CHANGED
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
const defaultWindow = shared.isClient ? window :
|
|
20
|
+
const defaultWindow = shared.isClient ? window : undefined;
|
|
21
21
|
|
|
22
22
|
function unrefElement(elRef) {
|
|
23
23
|
var _a;
|
|
24
|
-
const plain =
|
|
25
|
-
return (_a = plain == null ?
|
|
24
|
+
const plain = vue.toValue(elRef);
|
|
25
|
+
return (_a = plain == null ? undefined : plain.$el) != null ? _a : plain;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
function useEventListener(...args) {
|
|
@@ -38,10 +38,8 @@
|
|
|
38
38
|
}
|
|
39
39
|
if (!target)
|
|
40
40
|
return shared.noop;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (!Array.isArray(listeners))
|
|
44
|
-
listeners = [listeners];
|
|
41
|
+
events = shared.toArray(events);
|
|
42
|
+
listeners = shared.toArray(listeners);
|
|
45
43
|
const cleanups = [];
|
|
46
44
|
const cleanup = () => {
|
|
47
45
|
cleanups.forEach((fn) => fn());
|
|
@@ -52,7 +50,7 @@
|
|
|
52
50
|
return () => el.removeEventListener(event, listener, options2);
|
|
53
51
|
};
|
|
54
52
|
const stopWatch = vue.watch(
|
|
55
|
-
() => [unrefElement(target),
|
|
53
|
+
() => [unrefElement(target), vue.toValue(options)],
|
|
56
54
|
([el, options2]) => {
|
|
57
55
|
cleanup();
|
|
58
56
|
if (!el)
|
|
@@ -86,7 +84,7 @@
|
|
|
86
84
|
}
|
|
87
85
|
let shouldListen = true;
|
|
88
86
|
const shouldIgnore = (event) => {
|
|
89
|
-
return
|
|
87
|
+
return vue.toValue(ignore).some((target2) => {
|
|
90
88
|
if (typeof target2 === "string") {
|
|
91
89
|
return Array.from(window.document.querySelectorAll(target2)).some((el) => el === event.target || event.composedPath().includes(el));
|
|
92
90
|
} else {
|
|
@@ -96,11 +94,11 @@
|
|
|
96
94
|
});
|
|
97
95
|
};
|
|
98
96
|
function hasMultipleRoots(target2) {
|
|
99
|
-
const vm =
|
|
97
|
+
const vm = vue.toValue(target2);
|
|
100
98
|
return vm && vm.$.subTree.shapeFlag === 16;
|
|
101
99
|
}
|
|
102
100
|
function checkMultipleRoots(target2, event) {
|
|
103
|
-
const vm =
|
|
101
|
+
const vm = vue.toValue(target2);
|
|
104
102
|
const children = vm.$.subTree && vm.$.subTree.children;
|
|
105
103
|
if (children == null || !Array.isArray(children))
|
|
106
104
|
return false;
|
|
@@ -141,11 +139,11 @@
|
|
|
141
139
|
setTimeout(() => {
|
|
142
140
|
var _a;
|
|
143
141
|
const el = unrefElement(target);
|
|
144
|
-
if (((_a = window.document.activeElement) == null ?
|
|
142
|
+
if (((_a = window.document.activeElement) == null ? undefined : _a.tagName) === "IFRAME" && !(el == null ? undefined : el.contains(window.document.activeElement))) {
|
|
145
143
|
handler(event);
|
|
146
144
|
}
|
|
147
145
|
}, 0);
|
|
148
|
-
})
|
|
146
|
+
}, { passive: true })
|
|
149
147
|
].filter(Boolean);
|
|
150
148
|
const stop = () => cleanup.forEach((fn) => fn());
|
|
151
149
|
return stop;
|
|
@@ -204,7 +202,7 @@
|
|
|
204
202
|
} = options;
|
|
205
203
|
const predicate = createKeyPredicate(key);
|
|
206
204
|
const listener = (e) => {
|
|
207
|
-
if (e.repeat &&
|
|
205
|
+
if (e.repeat && vue.toValue(dedupe))
|
|
208
206
|
return;
|
|
209
207
|
if (predicate(e))
|
|
210
208
|
handler(e);
|
|
@@ -215,7 +213,7 @@
|
|
|
215
213
|
const vOnKeyStroke = {
|
|
216
214
|
mounted(el, binding) {
|
|
217
215
|
var _a, _b;
|
|
218
|
-
const keys = (_b = (_a = binding.arg) == null ?
|
|
216
|
+
const keys = (_b = (_a = binding.arg) == null ? undefined : _a.split(",")) != null ? _b : true;
|
|
219
217
|
if (typeof binding.value === "function") {
|
|
220
218
|
onKeyStroke(keys, binding.value, {
|
|
221
219
|
target: el
|
|
@@ -242,23 +240,23 @@
|
|
|
242
240
|
function clear() {
|
|
243
241
|
if (timeout) {
|
|
244
242
|
clearTimeout(timeout);
|
|
245
|
-
timeout =
|
|
243
|
+
timeout = undefined;
|
|
246
244
|
}
|
|
247
|
-
posStart =
|
|
248
|
-
startTimestamp =
|
|
245
|
+
posStart = undefined;
|
|
246
|
+
startTimestamp = undefined;
|
|
249
247
|
hasLongPressed = false;
|
|
250
248
|
}
|
|
251
249
|
function onRelease(ev) {
|
|
252
250
|
var _a2, _b2, _c;
|
|
253
251
|
const [_startTimestamp, _posStart, _hasLongPressed] = [startTimestamp, posStart, hasLongPressed];
|
|
254
252
|
clear();
|
|
255
|
-
if (!(options == null ?
|
|
253
|
+
if (!(options == null ? undefined : options.onMouseUp) || !_posStart || !_startTimestamp)
|
|
256
254
|
return;
|
|
257
|
-
if (((_a2 = options == null ?
|
|
255
|
+
if (((_a2 = options == null ? undefined : options.modifiers) == null ? undefined : _a2.self) && ev.target !== elementRef.value)
|
|
258
256
|
return;
|
|
259
|
-
if ((_b2 = options == null ?
|
|
257
|
+
if ((_b2 = options == null ? undefined : options.modifiers) == null ? undefined : _b2.prevent)
|
|
260
258
|
ev.preventDefault();
|
|
261
|
-
if ((_c = options == null ?
|
|
259
|
+
if ((_c = options == null ? undefined : options.modifiers) == null ? undefined : _c.stop)
|
|
262
260
|
ev.stopPropagation();
|
|
263
261
|
const dx = ev.x - _posStart.x;
|
|
264
262
|
const dy = ev.y - _posStart.y;
|
|
@@ -267,12 +265,12 @@
|
|
|
267
265
|
}
|
|
268
266
|
function onDown(ev) {
|
|
269
267
|
var _a2, _b2, _c, _d;
|
|
270
|
-
if (((_a2 = options == null ?
|
|
268
|
+
if (((_a2 = options == null ? undefined : options.modifiers) == null ? undefined : _a2.self) && ev.target !== elementRef.value)
|
|
271
269
|
return;
|
|
272
270
|
clear();
|
|
273
|
-
if ((_b2 = options == null ?
|
|
271
|
+
if ((_b2 = options == null ? undefined : options.modifiers) == null ? undefined : _b2.prevent)
|
|
274
272
|
ev.preventDefault();
|
|
275
|
-
if ((_c = options == null ?
|
|
273
|
+
if ((_c = options == null ? undefined : options.modifiers) == null ? undefined : _c.stop)
|
|
276
274
|
ev.stopPropagation();
|
|
277
275
|
posStart = {
|
|
278
276
|
x: ev.x,
|
|
@@ -284,28 +282,28 @@
|
|
|
284
282
|
hasLongPressed = true;
|
|
285
283
|
handler(ev);
|
|
286
284
|
},
|
|
287
|
-
(_d = options == null ?
|
|
285
|
+
(_d = options == null ? undefined : options.delay) != null ? _d : DEFAULT_DELAY
|
|
288
286
|
);
|
|
289
287
|
}
|
|
290
288
|
function onMove(ev) {
|
|
291
289
|
var _a2, _b2, _c, _d;
|
|
292
|
-
if (((_a2 = options == null ?
|
|
290
|
+
if (((_a2 = options == null ? undefined : options.modifiers) == null ? undefined : _a2.self) && ev.target !== elementRef.value)
|
|
293
291
|
return;
|
|
294
|
-
if (!posStart || (options == null ?
|
|
292
|
+
if (!posStart || (options == null ? undefined : options.distanceThreshold) === false)
|
|
295
293
|
return;
|
|
296
|
-
if ((_b2 = options == null ?
|
|
294
|
+
if ((_b2 = options == null ? undefined : options.modifiers) == null ? undefined : _b2.prevent)
|
|
297
295
|
ev.preventDefault();
|
|
298
|
-
if ((_c = options == null ?
|
|
296
|
+
if ((_c = options == null ? undefined : options.modifiers) == null ? undefined : _c.stop)
|
|
299
297
|
ev.stopPropagation();
|
|
300
298
|
const dx = ev.x - posStart.x;
|
|
301
299
|
const dy = ev.y - posStart.y;
|
|
302
300
|
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
303
|
-
if (distance >= ((_d = options == null ?
|
|
301
|
+
if (distance >= ((_d = options == null ? undefined : options.distanceThreshold) != null ? _d : DEFAULT_THRESHOLD))
|
|
304
302
|
clear();
|
|
305
303
|
}
|
|
306
304
|
const listenerOptions = {
|
|
307
|
-
capture: (_a = options == null ?
|
|
308
|
-
once: (_b = options == null ?
|
|
305
|
+
capture: (_a = options == null ? undefined : options.modifiers) == null ? undefined : _a.capture,
|
|
306
|
+
once: (_b = options == null ? undefined : options.modifiers) == null ? undefined : _b.once
|
|
309
307
|
};
|
|
310
308
|
const cleanup = [
|
|
311
309
|
useEventListener(elementRef, "pointerdown", onDown, listenerOptions),
|
|
@@ -393,7 +391,7 @@
|
|
|
393
391
|
const data = vue.reactive(core.useClipboard(props));
|
|
394
392
|
return () => {
|
|
395
393
|
var _a;
|
|
396
|
-
return (_a = slots.default) == null ?
|
|
394
|
+
return (_a = slots.default) == null ? undefined : _a.call(slots, data);
|
|
397
395
|
};
|
|
398
396
|
}
|
|
399
397
|
});
|
|
@@ -413,7 +411,7 @@
|
|
|
413
411
|
const ssrWidthSymbol = Symbol("vueuse-ssr-width");
|
|
414
412
|
function useSSRWidth() {
|
|
415
413
|
const ssrWidth = vue.hasInjectionContext() ? shared.injectLocal(ssrWidthSymbol, null) : null;
|
|
416
|
-
return typeof ssrWidth === "number" ? ssrWidth :
|
|
414
|
+
return typeof ssrWidth === "number" ? ssrWidth : undefined;
|
|
417
415
|
}
|
|
418
416
|
|
|
419
417
|
function useMounted() {
|
|
@@ -455,7 +453,7 @@
|
|
|
455
453
|
const stopWatch = vue.watchEffect(() => {
|
|
456
454
|
if (ssrSupport.value) {
|
|
457
455
|
ssrSupport.value = !isSupported.value;
|
|
458
|
-
const queryStrings =
|
|
456
|
+
const queryStrings = vue.toValue(query).split(",");
|
|
459
457
|
matches.value = queryStrings.some((queryString) => {
|
|
460
458
|
const not = queryString.includes("not all");
|
|
461
459
|
const minWidth = queryString.match(/\(\s*min-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/);
|
|
@@ -474,7 +472,7 @@
|
|
|
474
472
|
if (!isSupported.value)
|
|
475
473
|
return;
|
|
476
474
|
cleanup();
|
|
477
|
-
mediaQuery = window.matchMedia(
|
|
475
|
+
mediaQuery = window.matchMedia(vue.toValue(query));
|
|
478
476
|
if ("addEventListener" in mediaQuery)
|
|
479
477
|
mediaQuery.addEventListener("change", handler);
|
|
480
478
|
else
|
|
@@ -484,7 +482,7 @@
|
|
|
484
482
|
shared.tryOnScopeDispose(() => {
|
|
485
483
|
stopWatch();
|
|
486
484
|
cleanup();
|
|
487
|
-
mediaQuery =
|
|
485
|
+
mediaQuery = undefined;
|
|
488
486
|
});
|
|
489
487
|
return vue.computed(() => matches.value);
|
|
490
488
|
}
|
|
@@ -549,6 +547,7 @@
|
|
|
549
547
|
initOnMounted
|
|
550
548
|
} = options;
|
|
551
549
|
const data = (shallow ? vue.shallowRef : vue.ref)(typeof defaults === "function" ? defaults() : defaults);
|
|
550
|
+
const keyComputed = vue.computed(() => vue.toValue(key));
|
|
552
551
|
if (!storage) {
|
|
553
552
|
try {
|
|
554
553
|
storage = getSSRHandler("getDefaultStorage", () => {
|
|
@@ -561,7 +560,7 @@
|
|
|
561
560
|
}
|
|
562
561
|
if (!storage)
|
|
563
562
|
return data;
|
|
564
|
-
const rawInit =
|
|
563
|
+
const rawInit = vue.toValue(defaults);
|
|
565
564
|
const type = guessSerializerType(rawInit);
|
|
566
565
|
const serializer = (_a = options.serializer) != null ? _a : StorageSerializers[type];
|
|
567
566
|
const { pause: pauseWatch, resume: resumeWatch } = shared.pausableWatch(
|
|
@@ -569,10 +568,11 @@
|
|
|
569
568
|
() => write(data.value),
|
|
570
569
|
{ flush, deep, eventFilter }
|
|
571
570
|
);
|
|
571
|
+
vue.watch(keyComputed, () => update(), { flush });
|
|
572
572
|
if (window && listenToStorageChanges) {
|
|
573
573
|
shared.tryOnMounted(() => {
|
|
574
574
|
if (storage instanceof Storage)
|
|
575
|
-
useEventListener(window, "storage", update);
|
|
575
|
+
useEventListener(window, "storage", update, { passive: true });
|
|
576
576
|
else
|
|
577
577
|
useEventListener(window, customStorageEventName, updateFromCustomEvent);
|
|
578
578
|
if (initOnMounted)
|
|
@@ -584,7 +584,7 @@
|
|
|
584
584
|
function dispatchWriteEvent(oldValue, newValue) {
|
|
585
585
|
if (window) {
|
|
586
586
|
const payload = {
|
|
587
|
-
key,
|
|
587
|
+
key: keyComputed.value,
|
|
588
588
|
oldValue,
|
|
589
589
|
newValue,
|
|
590
590
|
storageArea: storage
|
|
@@ -596,14 +596,14 @@
|
|
|
596
596
|
}
|
|
597
597
|
function write(v) {
|
|
598
598
|
try {
|
|
599
|
-
const oldValue = storage.getItem(
|
|
599
|
+
const oldValue = storage.getItem(keyComputed.value);
|
|
600
600
|
if (v == null) {
|
|
601
601
|
dispatchWriteEvent(oldValue, null);
|
|
602
|
-
storage.removeItem(
|
|
602
|
+
storage.removeItem(keyComputed.value);
|
|
603
603
|
} else {
|
|
604
604
|
const serialized = serializer.write(v);
|
|
605
605
|
if (oldValue !== serialized) {
|
|
606
|
-
storage.setItem(
|
|
606
|
+
storage.setItem(keyComputed.value, serialized);
|
|
607
607
|
dispatchWriteEvent(oldValue, serialized);
|
|
608
608
|
}
|
|
609
609
|
}
|
|
@@ -612,10 +612,10 @@
|
|
|
612
612
|
}
|
|
613
613
|
}
|
|
614
614
|
function read(event) {
|
|
615
|
-
const rawValue = event ? event.newValue : storage.getItem(
|
|
615
|
+
const rawValue = event ? event.newValue : storage.getItem(keyComputed.value);
|
|
616
616
|
if (rawValue == null) {
|
|
617
617
|
if (writeDefaults && rawInit != null)
|
|
618
|
-
storage.setItem(
|
|
618
|
+
storage.setItem(keyComputed.value, serializer.write(rawInit));
|
|
619
619
|
return rawInit;
|
|
620
620
|
} else if (!event && mergeDefaults) {
|
|
621
621
|
const value = serializer.read(rawValue);
|
|
@@ -637,7 +637,7 @@
|
|
|
637
637
|
data.value = rawInit;
|
|
638
638
|
return;
|
|
639
639
|
}
|
|
640
|
-
if (event && event.key !==
|
|
640
|
+
if (event && event.key !== keyComputed.value)
|
|
641
641
|
return;
|
|
642
642
|
pauseWatch();
|
|
643
643
|
try {
|
|
@@ -685,7 +685,7 @@
|
|
|
685
685
|
const updateHTMLAttrs = getSSRHandler(
|
|
686
686
|
"updateHTMLAttrs",
|
|
687
687
|
(selector2, attribute2, value) => {
|
|
688
|
-
const el = typeof selector2 === "string" ? window == null ?
|
|
688
|
+
const el = typeof selector2 === "string" ? window == null ? undefined : window.document.querySelector(selector2) : unrefElement(selector2);
|
|
689
689
|
if (!el)
|
|
690
690
|
return;
|
|
691
691
|
const classesToAdd = /* @__PURE__ */ new Set();
|
|
@@ -869,18 +869,18 @@
|
|
|
869
869
|
});
|
|
870
870
|
const containerElement = vue.computed(() => {
|
|
871
871
|
var _a;
|
|
872
|
-
return (_a = props.containerElement) != null ? _a :
|
|
872
|
+
return (_a = props.containerElement) != null ? _a : undefined;
|
|
873
873
|
});
|
|
874
874
|
const disabled = vue.computed(() => !!props.disabled);
|
|
875
875
|
const storageValue = props.storageKey && core.useStorage(
|
|
876
876
|
props.storageKey,
|
|
877
|
-
|
|
878
|
-
core.isClient ? props.storageType === "session" ? sessionStorage : localStorage :
|
|
877
|
+
vue.toValue(props.initialValue) || { x: 0, y: 0 },
|
|
878
|
+
core.isClient ? props.storageType === "session" ? sessionStorage : localStorage : undefined
|
|
879
879
|
);
|
|
880
880
|
const initialValue = storageValue || props.initialValue || { x: 0, y: 0 };
|
|
881
881
|
const onEnd = (position, event) => {
|
|
882
882
|
var _a;
|
|
883
|
-
(_a = props.onEnd) == null ?
|
|
883
|
+
(_a = props.onEnd) == null ? undefined : _a.call(props, position, event);
|
|
884
884
|
if (!storageValue)
|
|
885
885
|
return;
|
|
886
886
|
storageValue.value.x = position.x;
|
|
@@ -914,10 +914,222 @@
|
|
|
914
914
|
}
|
|
915
915
|
});
|
|
916
916
|
|
|
917
|
+
function useMutationObserver(target, callback, options = {}) {
|
|
918
|
+
const { window = defaultWindow, ...mutationOptions } = options;
|
|
919
|
+
let observer;
|
|
920
|
+
const isSupported = useSupported(() => window && "MutationObserver" in window);
|
|
921
|
+
const cleanup = () => {
|
|
922
|
+
if (observer) {
|
|
923
|
+
observer.disconnect();
|
|
924
|
+
observer = undefined;
|
|
925
|
+
}
|
|
926
|
+
};
|
|
927
|
+
const targets = vue.computed(() => {
|
|
928
|
+
const value = vue.toValue(target);
|
|
929
|
+
const items = shared.toArray(value).map(unrefElement).filter(shared.notNullish);
|
|
930
|
+
return new Set(items);
|
|
931
|
+
});
|
|
932
|
+
const stopWatch = vue.watch(
|
|
933
|
+
() => targets.value,
|
|
934
|
+
(targets2) => {
|
|
935
|
+
cleanup();
|
|
936
|
+
if (isSupported.value && targets2.size) {
|
|
937
|
+
observer = new MutationObserver(callback);
|
|
938
|
+
targets2.forEach((el) => observer.observe(el, mutationOptions));
|
|
939
|
+
}
|
|
940
|
+
},
|
|
941
|
+
{ immediate: true, flush: "post" }
|
|
942
|
+
);
|
|
943
|
+
const takeRecords = () => {
|
|
944
|
+
return observer == null ? undefined : observer.takeRecords();
|
|
945
|
+
};
|
|
946
|
+
const stop = () => {
|
|
947
|
+
stopWatch();
|
|
948
|
+
cleanup();
|
|
949
|
+
};
|
|
950
|
+
shared.tryOnScopeDispose(stop);
|
|
951
|
+
return {
|
|
952
|
+
isSupported,
|
|
953
|
+
stop,
|
|
954
|
+
takeRecords
|
|
955
|
+
};
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
function useResizeObserver(target, callback, options = {}) {
|
|
959
|
+
const { window = defaultWindow, ...observerOptions } = options;
|
|
960
|
+
let observer;
|
|
961
|
+
const isSupported = useSupported(() => window && "ResizeObserver" in window);
|
|
962
|
+
const cleanup = () => {
|
|
963
|
+
if (observer) {
|
|
964
|
+
observer.disconnect();
|
|
965
|
+
observer = undefined;
|
|
966
|
+
}
|
|
967
|
+
};
|
|
968
|
+
const targets = vue.computed(() => {
|
|
969
|
+
const _targets = vue.toValue(target);
|
|
970
|
+
return Array.isArray(_targets) ? _targets.map((el) => unrefElement(el)) : [unrefElement(_targets)];
|
|
971
|
+
});
|
|
972
|
+
const stopWatch = vue.watch(
|
|
973
|
+
targets,
|
|
974
|
+
(els) => {
|
|
975
|
+
cleanup();
|
|
976
|
+
if (isSupported.value && window) {
|
|
977
|
+
observer = new ResizeObserver(callback);
|
|
978
|
+
for (const _el of els) {
|
|
979
|
+
if (_el)
|
|
980
|
+
observer.observe(_el, observerOptions);
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
},
|
|
984
|
+
{ immediate: true, flush: "post" }
|
|
985
|
+
);
|
|
986
|
+
const stop = () => {
|
|
987
|
+
cleanup();
|
|
988
|
+
stopWatch();
|
|
989
|
+
};
|
|
990
|
+
shared.tryOnScopeDispose(stop);
|
|
991
|
+
return {
|
|
992
|
+
isSupported,
|
|
993
|
+
stop
|
|
994
|
+
};
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
function useElementBounding(target, options = {}) {
|
|
998
|
+
const {
|
|
999
|
+
reset = true,
|
|
1000
|
+
windowResize = true,
|
|
1001
|
+
windowScroll = true,
|
|
1002
|
+
immediate = true,
|
|
1003
|
+
updateTiming = "sync"
|
|
1004
|
+
} = options;
|
|
1005
|
+
const height = vue.ref(0);
|
|
1006
|
+
const bottom = vue.ref(0);
|
|
1007
|
+
const left = vue.ref(0);
|
|
1008
|
+
const right = vue.ref(0);
|
|
1009
|
+
const top = vue.ref(0);
|
|
1010
|
+
const width = vue.ref(0);
|
|
1011
|
+
const x = vue.ref(0);
|
|
1012
|
+
const y = vue.ref(0);
|
|
1013
|
+
function recalculate() {
|
|
1014
|
+
const el = unrefElement(target);
|
|
1015
|
+
if (!el) {
|
|
1016
|
+
if (reset) {
|
|
1017
|
+
height.value = 0;
|
|
1018
|
+
bottom.value = 0;
|
|
1019
|
+
left.value = 0;
|
|
1020
|
+
right.value = 0;
|
|
1021
|
+
top.value = 0;
|
|
1022
|
+
width.value = 0;
|
|
1023
|
+
x.value = 0;
|
|
1024
|
+
y.value = 0;
|
|
1025
|
+
}
|
|
1026
|
+
return;
|
|
1027
|
+
}
|
|
1028
|
+
const rect = el.getBoundingClientRect();
|
|
1029
|
+
height.value = rect.height;
|
|
1030
|
+
bottom.value = rect.bottom;
|
|
1031
|
+
left.value = rect.left;
|
|
1032
|
+
right.value = rect.right;
|
|
1033
|
+
top.value = rect.top;
|
|
1034
|
+
width.value = rect.width;
|
|
1035
|
+
x.value = rect.x;
|
|
1036
|
+
y.value = rect.y;
|
|
1037
|
+
}
|
|
1038
|
+
function update() {
|
|
1039
|
+
if (updateTiming === "sync")
|
|
1040
|
+
recalculate();
|
|
1041
|
+
else if (updateTiming === "next-frame")
|
|
1042
|
+
requestAnimationFrame(() => recalculate());
|
|
1043
|
+
}
|
|
1044
|
+
useResizeObserver(target, update);
|
|
1045
|
+
vue.watch(() => unrefElement(target), (ele) => !ele && update());
|
|
1046
|
+
useMutationObserver(target, update, {
|
|
1047
|
+
attributeFilter: ["style", "class"]
|
|
1048
|
+
});
|
|
1049
|
+
if (windowScroll)
|
|
1050
|
+
useEventListener("scroll", update, { capture: true, passive: true });
|
|
1051
|
+
if (windowResize)
|
|
1052
|
+
useEventListener("resize", update, { passive: true });
|
|
1053
|
+
shared.tryOnMounted(() => {
|
|
1054
|
+
if (immediate)
|
|
1055
|
+
update();
|
|
1056
|
+
});
|
|
1057
|
+
return {
|
|
1058
|
+
height,
|
|
1059
|
+
bottom,
|
|
1060
|
+
left,
|
|
1061
|
+
right,
|
|
1062
|
+
top,
|
|
1063
|
+
width,
|
|
1064
|
+
x,
|
|
1065
|
+
y,
|
|
1066
|
+
update
|
|
1067
|
+
};
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
const vElementBounding = {
|
|
1071
|
+
mounted(el, binding) {
|
|
1072
|
+
const [handler, options] = typeof binding.value === "function" ? [binding.value, {}] : binding.value;
|
|
1073
|
+
const {
|
|
1074
|
+
height,
|
|
1075
|
+
bottom,
|
|
1076
|
+
left,
|
|
1077
|
+
right,
|
|
1078
|
+
top,
|
|
1079
|
+
width,
|
|
1080
|
+
x,
|
|
1081
|
+
y
|
|
1082
|
+
} = useElementBounding(el, options);
|
|
1083
|
+
vue.watch([height, bottom, left, right, top, width, x, y], () => handler({ height, bottom, left, right, top, width, x, y }));
|
|
1084
|
+
}
|
|
1085
|
+
};
|
|
1086
|
+
|
|
1087
|
+
function onElementRemoval(target, callback, options = {}) {
|
|
1088
|
+
const {
|
|
1089
|
+
window = defaultWindow,
|
|
1090
|
+
document = window == null ? undefined : window.document,
|
|
1091
|
+
flush = "sync"
|
|
1092
|
+
} = options;
|
|
1093
|
+
if (!window || !document)
|
|
1094
|
+
return shared.noop;
|
|
1095
|
+
let stopFn;
|
|
1096
|
+
const cleanupAndUpdate = (fn) => {
|
|
1097
|
+
stopFn == null ? undefined : stopFn();
|
|
1098
|
+
stopFn = fn;
|
|
1099
|
+
};
|
|
1100
|
+
const stopWatch = vue.watchEffect(() => {
|
|
1101
|
+
const el = unrefElement(target);
|
|
1102
|
+
if (el) {
|
|
1103
|
+
const { stop } = useMutationObserver(
|
|
1104
|
+
document,
|
|
1105
|
+
(mutationsList) => {
|
|
1106
|
+
const targetRemoved = mutationsList.map((mutation) => [...mutation.removedNodes]).flat().some((node) => node === el || node.contains(el));
|
|
1107
|
+
if (targetRemoved) {
|
|
1108
|
+
callback(mutationsList);
|
|
1109
|
+
}
|
|
1110
|
+
},
|
|
1111
|
+
{
|
|
1112
|
+
window,
|
|
1113
|
+
childList: true,
|
|
1114
|
+
subtree: true
|
|
1115
|
+
}
|
|
1116
|
+
);
|
|
1117
|
+
cleanupAndUpdate(stop);
|
|
1118
|
+
}
|
|
1119
|
+
}, { flush });
|
|
1120
|
+
const stopHandle = () => {
|
|
1121
|
+
stopWatch();
|
|
1122
|
+
cleanupAndUpdate();
|
|
1123
|
+
};
|
|
1124
|
+
shared.tryOnScopeDispose(stopHandle);
|
|
1125
|
+
return stopHandle;
|
|
1126
|
+
}
|
|
1127
|
+
|
|
917
1128
|
function useElementHover(el, options = {}) {
|
|
918
1129
|
const {
|
|
919
1130
|
delayEnter = 0,
|
|
920
1131
|
delayLeave = 0,
|
|
1132
|
+
triggerOnRemoval = false,
|
|
921
1133
|
window = defaultWindow
|
|
922
1134
|
} = options;
|
|
923
1135
|
const isHovered = vue.ref(false);
|
|
@@ -926,7 +1138,7 @@
|
|
|
926
1138
|
const delay = entering ? delayEnter : delayLeave;
|
|
927
1139
|
if (timer) {
|
|
928
1140
|
clearTimeout(timer);
|
|
929
|
-
timer =
|
|
1141
|
+
timer = undefined;
|
|
930
1142
|
}
|
|
931
1143
|
if (delay)
|
|
932
1144
|
timer = setTimeout(() => isHovered.value = entering, delay);
|
|
@@ -937,6 +1149,12 @@
|
|
|
937
1149
|
return isHovered;
|
|
938
1150
|
useEventListener(el, "mouseenter", () => toggle(true), { passive: true });
|
|
939
1151
|
useEventListener(el, "mouseleave", () => toggle(false), { passive: true });
|
|
1152
|
+
if (triggerOnRemoval) {
|
|
1153
|
+
onElementRemoval(
|
|
1154
|
+
vue.computed(() => unrefElement(el)),
|
|
1155
|
+
() => toggle(false)
|
|
1156
|
+
);
|
|
1157
|
+
}
|
|
940
1158
|
return isHovered;
|
|
941
1159
|
}
|
|
942
1160
|
|
|
@@ -967,50 +1185,11 @@
|
|
|
967
1185
|
}
|
|
968
1186
|
});
|
|
969
1187
|
|
|
970
|
-
function useResizeObserver(target, callback, options = {}) {
|
|
971
|
-
const { window = defaultWindow, ...observerOptions } = options;
|
|
972
|
-
let observer;
|
|
973
|
-
const isSupported = useSupported(() => window && "ResizeObserver" in window);
|
|
974
|
-
const cleanup = () => {
|
|
975
|
-
if (observer) {
|
|
976
|
-
observer.disconnect();
|
|
977
|
-
observer = void 0;
|
|
978
|
-
}
|
|
979
|
-
};
|
|
980
|
-
const targets = vue.computed(() => {
|
|
981
|
-
const _targets = shared.toValue(target);
|
|
982
|
-
return Array.isArray(_targets) ? _targets.map((el) => unrefElement(el)) : [unrefElement(_targets)];
|
|
983
|
-
});
|
|
984
|
-
const stopWatch = vue.watch(
|
|
985
|
-
targets,
|
|
986
|
-
(els) => {
|
|
987
|
-
cleanup();
|
|
988
|
-
if (isSupported.value && window) {
|
|
989
|
-
observer = new ResizeObserver(callback);
|
|
990
|
-
for (const _el of els) {
|
|
991
|
-
if (_el)
|
|
992
|
-
observer.observe(_el, observerOptions);
|
|
993
|
-
}
|
|
994
|
-
}
|
|
995
|
-
},
|
|
996
|
-
{ immediate: true, flush: "post" }
|
|
997
|
-
);
|
|
998
|
-
const stop = () => {
|
|
999
|
-
cleanup();
|
|
1000
|
-
stopWatch();
|
|
1001
|
-
};
|
|
1002
|
-
shared.tryOnScopeDispose(stop);
|
|
1003
|
-
return {
|
|
1004
|
-
isSupported,
|
|
1005
|
-
stop
|
|
1006
|
-
};
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
1188
|
function useElementSize(target, initialSize = { width: 0, height: 0 }, options = {}) {
|
|
1010
1189
|
const { window = defaultWindow, box = "content-box" } = options;
|
|
1011
1190
|
const isSVG = vue.computed(() => {
|
|
1012
1191
|
var _a, _b;
|
|
1013
|
-
return (_b = (_a = unrefElement(target)) == null ?
|
|
1192
|
+
return (_b = (_a = unrefElement(target)) == null ? undefined : _a.namespaceURI) == null ? undefined : _b.includes("svg");
|
|
1014
1193
|
});
|
|
1015
1194
|
const width = vue.ref(initialSize.width);
|
|
1016
1195
|
const height = vue.ref(initialSize.height);
|
|
@@ -1027,7 +1206,7 @@
|
|
|
1027
1206
|
}
|
|
1028
1207
|
} else {
|
|
1029
1208
|
if (boxSize) {
|
|
1030
|
-
const formatBoxSize =
|
|
1209
|
+
const formatBoxSize = shared.toArray(boxSize);
|
|
1031
1210
|
width.value = formatBoxSize.reduce((acc, { inlineSize }) => acc + inlineSize, 0);
|
|
1032
1211
|
height.value = formatBoxSize.reduce((acc, { blockSize }) => acc + blockSize, 0);
|
|
1033
1212
|
} else {
|
|
@@ -1066,7 +1245,7 @@
|
|
|
1066
1245
|
const vElementSize = {
|
|
1067
1246
|
mounted(el, binding) {
|
|
1068
1247
|
var _a;
|
|
1069
|
-
const handler = typeof binding.value === "function" ? binding.value : (_a = binding.value) == null ?
|
|
1248
|
+
const handler = typeof binding.value === "function" ? binding.value : (_a = binding.value) == null ? undefined : _a[0];
|
|
1070
1249
|
const options = typeof binding.value === "function" ? [] : binding.value.slice(1);
|
|
1071
1250
|
const { width, height } = useElementSize(el, ...options);
|
|
1072
1251
|
vue.watch([width, height], ([width2, height2]) => handler({ width: width2, height: height2 }));
|
|
@@ -1098,8 +1277,8 @@
|
|
|
1098
1277
|
} = options;
|
|
1099
1278
|
const isSupported = useSupported(() => window && "IntersectionObserver" in window);
|
|
1100
1279
|
const targets = vue.computed(() => {
|
|
1101
|
-
const _target =
|
|
1102
|
-
return
|
|
1280
|
+
const _target = vue.toValue(target);
|
|
1281
|
+
return shared.toArray(_target).map(unrefElement).filter(shared.notNullish);
|
|
1103
1282
|
});
|
|
1104
1283
|
let cleanup = shared.noop;
|
|
1105
1284
|
const isActive = vue.ref(immediate);
|
|
@@ -1172,7 +1351,7 @@
|
|
|
1172
1351
|
root: scrollTarget,
|
|
1173
1352
|
window,
|
|
1174
1353
|
threshold,
|
|
1175
|
-
rootMargin:
|
|
1354
|
+
rootMargin: vue.toValue(rootMargin)
|
|
1176
1355
|
}
|
|
1177
1356
|
);
|
|
1178
1357
|
return elementIsVisible;
|
|
@@ -1256,11 +1435,11 @@
|
|
|
1256
1435
|
const state = shallow ? vue.shallowRef(initialState) : vue.ref(initialState);
|
|
1257
1436
|
const isReady = vue.ref(false);
|
|
1258
1437
|
const isLoading = vue.ref(false);
|
|
1259
|
-
const error = vue.shallowRef(
|
|
1438
|
+
const error = vue.shallowRef(undefined);
|
|
1260
1439
|
async function execute(delay2 = 0, ...args) {
|
|
1261
1440
|
if (resetOnExecute)
|
|
1262
1441
|
state.value = initialState;
|
|
1263
|
-
error.value =
|
|
1442
|
+
error.value = undefined;
|
|
1264
1443
|
isReady.value = false;
|
|
1265
1444
|
isLoading.value = true;
|
|
1266
1445
|
if (delay2 > 0)
|
|
@@ -1281,8 +1460,9 @@
|
|
|
1281
1460
|
}
|
|
1282
1461
|
return state.value;
|
|
1283
1462
|
}
|
|
1284
|
-
if (immediate)
|
|
1463
|
+
if (immediate) {
|
|
1285
1464
|
execute(delay);
|
|
1465
|
+
}
|
|
1286
1466
|
const shell = {
|
|
1287
1467
|
state,
|
|
1288
1468
|
isReady,
|
|
@@ -1338,15 +1518,15 @@
|
|
|
1338
1518
|
}
|
|
1339
1519
|
function useImage(options, asyncStateOptions = {}) {
|
|
1340
1520
|
const state = useAsyncState(
|
|
1341
|
-
() => loadImage(
|
|
1342
|
-
|
|
1521
|
+
() => loadImage(vue.toValue(options)),
|
|
1522
|
+
undefined,
|
|
1343
1523
|
{
|
|
1344
1524
|
resetOnExecute: true,
|
|
1345
1525
|
...asyncStateOptions
|
|
1346
1526
|
}
|
|
1347
1527
|
);
|
|
1348
1528
|
vue.watch(
|
|
1349
|
-
() =>
|
|
1529
|
+
() => vue.toValue(options),
|
|
1350
1530
|
() => state.execute(asyncStateOptions.delay),
|
|
1351
1531
|
{ deep: true }
|
|
1352
1532
|
);
|
|
@@ -1424,7 +1604,7 @@
|
|
|
1424
1604
|
return internalX.value;
|
|
1425
1605
|
},
|
|
1426
1606
|
set(x2) {
|
|
1427
|
-
scrollTo(x2,
|
|
1607
|
+
scrollTo(x2, undefined);
|
|
1428
1608
|
}
|
|
1429
1609
|
});
|
|
1430
1610
|
const y = vue.computed({
|
|
@@ -1432,22 +1612,22 @@
|
|
|
1432
1612
|
return internalY.value;
|
|
1433
1613
|
},
|
|
1434
1614
|
set(y2) {
|
|
1435
|
-
scrollTo(
|
|
1615
|
+
scrollTo(undefined, y2);
|
|
1436
1616
|
}
|
|
1437
1617
|
});
|
|
1438
1618
|
function scrollTo(_x, _y) {
|
|
1439
1619
|
var _a, _b, _c, _d;
|
|
1440
1620
|
if (!window)
|
|
1441
1621
|
return;
|
|
1442
|
-
const _element =
|
|
1622
|
+
const _element = vue.toValue(element);
|
|
1443
1623
|
if (!_element)
|
|
1444
1624
|
return;
|
|
1445
|
-
(_c = _element instanceof Document ? window.document.body : _element) == null ?
|
|
1446
|
-
top: (_a =
|
|
1447
|
-
left: (_b =
|
|
1448
|
-
behavior:
|
|
1625
|
+
(_c = _element instanceof Document ? window.document.body : _element) == null ? undefined : _c.scrollTo({
|
|
1626
|
+
top: (_a = vue.toValue(_y)) != null ? _a : y.value,
|
|
1627
|
+
left: (_b = vue.toValue(_x)) != null ? _b : x.value,
|
|
1628
|
+
behavior: vue.toValue(behavior)
|
|
1449
1629
|
});
|
|
1450
|
-
const scrollContainer = ((_d = _element == null ?
|
|
1630
|
+
const scrollContainer = ((_d = _element == null ? undefined : _element.document) == null ? undefined : _d.documentElement) || (_element == null ? undefined : _element.documentElement) || _element;
|
|
1451
1631
|
if (x != null)
|
|
1452
1632
|
internalX.value = scrollContainer.scrollLeft;
|
|
1453
1633
|
if (y != null)
|
|
@@ -1481,7 +1661,7 @@
|
|
|
1481
1661
|
var _a;
|
|
1482
1662
|
if (!window)
|
|
1483
1663
|
return;
|
|
1484
|
-
const el = ((_a = target == null ?
|
|
1664
|
+
const el = ((_a = target == null ? undefined : target.document) == null ? undefined : _a.documentElement) || (target == null ? undefined : target.documentElement) || unrefElement(target);
|
|
1485
1665
|
const { display, flexDirection, direction } = getComputedStyle(el);
|
|
1486
1666
|
const directionMultipler = direction === "rtl" ? -1 : 1;
|
|
1487
1667
|
const scrollLeft = el.scrollLeft;
|
|
@@ -1531,7 +1711,7 @@
|
|
|
1531
1711
|
);
|
|
1532
1712
|
shared.tryOnMounted(() => {
|
|
1533
1713
|
try {
|
|
1534
|
-
const _element =
|
|
1714
|
+
const _element = vue.toValue(element);
|
|
1535
1715
|
if (!_element)
|
|
1536
1716
|
return;
|
|
1537
1717
|
setArrivedState(_element);
|
|
@@ -1552,7 +1732,7 @@
|
|
|
1552
1732
|
arrivedState,
|
|
1553
1733
|
directions,
|
|
1554
1734
|
measure() {
|
|
1555
|
-
const _element =
|
|
1735
|
+
const _element = vue.toValue(element);
|
|
1556
1736
|
if (window && _element)
|
|
1557
1737
|
setArrivedState(_element);
|
|
1558
1738
|
}
|
|
@@ -1579,7 +1759,7 @@
|
|
|
1579
1759
|
const promise = vue.ref();
|
|
1580
1760
|
const isLoading = vue.computed(() => !!promise.value);
|
|
1581
1761
|
const observedElement = vue.computed(() => {
|
|
1582
|
-
return resolveElement(
|
|
1762
|
+
return resolveElement(vue.toValue(element));
|
|
1583
1763
|
});
|
|
1584
1764
|
const isElementVisible = useElementVisibility(observedElement);
|
|
1585
1765
|
function checkAndLoad() {
|
|
@@ -1657,6 +1837,159 @@
|
|
|
1657
1837
|
}
|
|
1658
1838
|
});
|
|
1659
1839
|
|
|
1840
|
+
const UseMouseBuiltinExtractors = {
|
|
1841
|
+
page: (event) => [event.pageX, event.pageY],
|
|
1842
|
+
client: (event) => [event.clientX, event.clientY],
|
|
1843
|
+
screen: (event) => [event.screenX, event.screenY],
|
|
1844
|
+
movement: (event) => event instanceof Touch ? null : [event.movementX, event.movementY]
|
|
1845
|
+
};
|
|
1846
|
+
function useMouse(options = {}) {
|
|
1847
|
+
const {
|
|
1848
|
+
type = "page",
|
|
1849
|
+
touch = true,
|
|
1850
|
+
resetOnTouchEnds = false,
|
|
1851
|
+
initialValue = { x: 0, y: 0 },
|
|
1852
|
+
window = defaultWindow,
|
|
1853
|
+
target = window,
|
|
1854
|
+
scroll = true,
|
|
1855
|
+
eventFilter
|
|
1856
|
+
} = options;
|
|
1857
|
+
let _prevMouseEvent = null;
|
|
1858
|
+
let _prevScrollX = 0;
|
|
1859
|
+
let _prevScrollY = 0;
|
|
1860
|
+
const x = vue.ref(initialValue.x);
|
|
1861
|
+
const y = vue.ref(initialValue.y);
|
|
1862
|
+
const sourceType = vue.ref(null);
|
|
1863
|
+
const extractor = typeof type === "function" ? type : UseMouseBuiltinExtractors[type];
|
|
1864
|
+
const mouseHandler = (event) => {
|
|
1865
|
+
const result = extractor(event);
|
|
1866
|
+
_prevMouseEvent = event;
|
|
1867
|
+
if (result) {
|
|
1868
|
+
[x.value, y.value] = result;
|
|
1869
|
+
sourceType.value = "mouse";
|
|
1870
|
+
}
|
|
1871
|
+
if (window) {
|
|
1872
|
+
_prevScrollX = window.scrollX;
|
|
1873
|
+
_prevScrollY = window.scrollY;
|
|
1874
|
+
}
|
|
1875
|
+
};
|
|
1876
|
+
const touchHandler = (event) => {
|
|
1877
|
+
if (event.touches.length > 0) {
|
|
1878
|
+
const result = extractor(event.touches[0]);
|
|
1879
|
+
if (result) {
|
|
1880
|
+
[x.value, y.value] = result;
|
|
1881
|
+
sourceType.value = "touch";
|
|
1882
|
+
}
|
|
1883
|
+
}
|
|
1884
|
+
};
|
|
1885
|
+
const scrollHandler = () => {
|
|
1886
|
+
if (!_prevMouseEvent || !window)
|
|
1887
|
+
return;
|
|
1888
|
+
const pos = extractor(_prevMouseEvent);
|
|
1889
|
+
if (_prevMouseEvent instanceof MouseEvent && pos) {
|
|
1890
|
+
x.value = pos[0] + window.scrollX - _prevScrollX;
|
|
1891
|
+
y.value = pos[1] + window.scrollY - _prevScrollY;
|
|
1892
|
+
}
|
|
1893
|
+
};
|
|
1894
|
+
const reset = () => {
|
|
1895
|
+
x.value = initialValue.x;
|
|
1896
|
+
y.value = initialValue.y;
|
|
1897
|
+
};
|
|
1898
|
+
const mouseHandlerWrapper = eventFilter ? (event) => eventFilter(() => mouseHandler(event), {}) : (event) => mouseHandler(event);
|
|
1899
|
+
const touchHandlerWrapper = eventFilter ? (event) => eventFilter(() => touchHandler(event), {}) : (event) => touchHandler(event);
|
|
1900
|
+
const scrollHandlerWrapper = eventFilter ? () => eventFilter(() => scrollHandler(), {}) : () => scrollHandler();
|
|
1901
|
+
if (target) {
|
|
1902
|
+
const listenerOptions = { passive: true };
|
|
1903
|
+
useEventListener(target, ["mousemove", "dragover"], mouseHandlerWrapper, listenerOptions);
|
|
1904
|
+
if (touch && type !== "movement") {
|
|
1905
|
+
useEventListener(target, ["touchstart", "touchmove"], touchHandlerWrapper, listenerOptions);
|
|
1906
|
+
if (resetOnTouchEnds)
|
|
1907
|
+
useEventListener(target, "touchend", reset, listenerOptions);
|
|
1908
|
+
}
|
|
1909
|
+
if (scroll && type === "page")
|
|
1910
|
+
useEventListener(window, "scroll", scrollHandlerWrapper, listenerOptions);
|
|
1911
|
+
}
|
|
1912
|
+
return {
|
|
1913
|
+
x,
|
|
1914
|
+
y,
|
|
1915
|
+
sourceType
|
|
1916
|
+
};
|
|
1917
|
+
}
|
|
1918
|
+
|
|
1919
|
+
function useMouseInElement(target, options = {}) {
|
|
1920
|
+
const {
|
|
1921
|
+
handleOutside = true,
|
|
1922
|
+
window = defaultWindow
|
|
1923
|
+
} = options;
|
|
1924
|
+
const type = options.type || "page";
|
|
1925
|
+
const { x, y, sourceType } = useMouse(options);
|
|
1926
|
+
const targetRef = vue.ref(target != null ? target : window == null ? undefined : window.document.body);
|
|
1927
|
+
const elementX = vue.ref(0);
|
|
1928
|
+
const elementY = vue.ref(0);
|
|
1929
|
+
const elementPositionX = vue.ref(0);
|
|
1930
|
+
const elementPositionY = vue.ref(0);
|
|
1931
|
+
const elementHeight = vue.ref(0);
|
|
1932
|
+
const elementWidth = vue.ref(0);
|
|
1933
|
+
const isOutside = vue.ref(true);
|
|
1934
|
+
let stop = () => {
|
|
1935
|
+
};
|
|
1936
|
+
if (window) {
|
|
1937
|
+
stop = vue.watch(
|
|
1938
|
+
[targetRef, x, y],
|
|
1939
|
+
() => {
|
|
1940
|
+
const el = unrefElement(targetRef);
|
|
1941
|
+
if (!el || !(el instanceof Element))
|
|
1942
|
+
return;
|
|
1943
|
+
const {
|
|
1944
|
+
left,
|
|
1945
|
+
top,
|
|
1946
|
+
width,
|
|
1947
|
+
height
|
|
1948
|
+
} = el.getBoundingClientRect();
|
|
1949
|
+
elementPositionX.value = left + (type === "page" ? window.pageXOffset : 0);
|
|
1950
|
+
elementPositionY.value = top + (type === "page" ? window.pageYOffset : 0);
|
|
1951
|
+
elementHeight.value = height;
|
|
1952
|
+
elementWidth.value = width;
|
|
1953
|
+
const elX = x.value - elementPositionX.value;
|
|
1954
|
+
const elY = y.value - elementPositionY.value;
|
|
1955
|
+
isOutside.value = width === 0 || height === 0 || elX < 0 || elY < 0 || elX > width || elY > height;
|
|
1956
|
+
if (handleOutside || !isOutside.value) {
|
|
1957
|
+
elementX.value = elX;
|
|
1958
|
+
elementY.value = elY;
|
|
1959
|
+
}
|
|
1960
|
+
},
|
|
1961
|
+
{ immediate: true }
|
|
1962
|
+
);
|
|
1963
|
+
useEventListener(
|
|
1964
|
+
document,
|
|
1965
|
+
"mouseleave",
|
|
1966
|
+
() => isOutside.value = true,
|
|
1967
|
+
{ passive: true }
|
|
1968
|
+
);
|
|
1969
|
+
}
|
|
1970
|
+
return {
|
|
1971
|
+
x,
|
|
1972
|
+
y,
|
|
1973
|
+
sourceType,
|
|
1974
|
+
elementX,
|
|
1975
|
+
elementY,
|
|
1976
|
+
elementPositionX,
|
|
1977
|
+
elementPositionY,
|
|
1978
|
+
elementHeight,
|
|
1979
|
+
elementWidth,
|
|
1980
|
+
isOutside,
|
|
1981
|
+
stop
|
|
1982
|
+
};
|
|
1983
|
+
}
|
|
1984
|
+
|
|
1985
|
+
const vMouseInElement = {
|
|
1986
|
+
mounted(el, binding) {
|
|
1987
|
+
const [handler, options] = typeof binding.value === "function" ? [binding.value, {}] : binding.value;
|
|
1988
|
+
const state = shared.reactiveOmit(vue.reactive(useMouseInElement(el, options)), "stop");
|
|
1989
|
+
vue.watch(state, (val) => handler(val));
|
|
1990
|
+
}
|
|
1991
|
+
};
|
|
1992
|
+
|
|
1660
1993
|
const UseMousePressed = /* @__PURE__ */ /* #__PURE__ */ vue.defineComponent({
|
|
1661
1994
|
name: "UseMousePressed",
|
|
1662
1995
|
props: ["touch", "initialValue", "as"],
|
|
@@ -1728,17 +2061,17 @@
|
|
|
1728
2061
|
...props,
|
|
1729
2062
|
onPageChange(...args) {
|
|
1730
2063
|
var _a;
|
|
1731
|
-
(_a = props.onPageChange) == null ?
|
|
2064
|
+
(_a = props.onPageChange) == null ? undefined : _a.call(props, ...args);
|
|
1732
2065
|
emit("page-change", ...args);
|
|
1733
2066
|
},
|
|
1734
2067
|
onPageSizeChange(...args) {
|
|
1735
2068
|
var _a;
|
|
1736
|
-
(_a = props.onPageSizeChange) == null ?
|
|
2069
|
+
(_a = props.onPageSizeChange) == null ? undefined : _a.call(props, ...args);
|
|
1737
2070
|
emit("page-size-change", ...args);
|
|
1738
2071
|
},
|
|
1739
2072
|
onPageCountChange(...args) {
|
|
1740
2073
|
var _a;
|
|
1741
|
-
(_a = props.onPageCountChange) == null ?
|
|
2074
|
+
(_a = props.onPageCountChange) == null ? undefined : _a.call(props, ...args);
|
|
1742
2075
|
emit("page-count-change", ...args);
|
|
1743
2076
|
}
|
|
1744
2077
|
}));
|
|
@@ -1895,60 +2228,19 @@
|
|
|
1895
2228
|
}
|
|
1896
2229
|
};
|
|
1897
2230
|
|
|
1898
|
-
function useMutationObserver(target, callback, options = {}) {
|
|
1899
|
-
const { window = defaultWindow, ...mutationOptions } = options;
|
|
1900
|
-
let observer;
|
|
1901
|
-
const isSupported = useSupported(() => window && "MutationObserver" in window);
|
|
1902
|
-
const cleanup = () => {
|
|
1903
|
-
if (observer) {
|
|
1904
|
-
observer.disconnect();
|
|
1905
|
-
observer = void 0;
|
|
1906
|
-
}
|
|
1907
|
-
};
|
|
1908
|
-
const targets = vue.computed(() => {
|
|
1909
|
-
const value = shared.toValue(target);
|
|
1910
|
-
const items = (Array.isArray(value) ? value : [value]).map(unrefElement).filter(shared.notNullish);
|
|
1911
|
-
return new Set(items);
|
|
1912
|
-
});
|
|
1913
|
-
const stopWatch = vue.watch(
|
|
1914
|
-
() => targets.value,
|
|
1915
|
-
(targets2) => {
|
|
1916
|
-
cleanup();
|
|
1917
|
-
if (isSupported.value && targets2.size) {
|
|
1918
|
-
observer = new MutationObserver(callback);
|
|
1919
|
-
targets2.forEach((el) => observer.observe(el, mutationOptions));
|
|
1920
|
-
}
|
|
1921
|
-
},
|
|
1922
|
-
{ immediate: true, flush: "post" }
|
|
1923
|
-
);
|
|
1924
|
-
const takeRecords = () => {
|
|
1925
|
-
return observer == null ? void 0 : observer.takeRecords();
|
|
1926
|
-
};
|
|
1927
|
-
const stop = () => {
|
|
1928
|
-
stopWatch();
|
|
1929
|
-
cleanup();
|
|
1930
|
-
};
|
|
1931
|
-
shared.tryOnScopeDispose(stop);
|
|
1932
|
-
return {
|
|
1933
|
-
isSupported,
|
|
1934
|
-
stop,
|
|
1935
|
-
takeRecords
|
|
1936
|
-
};
|
|
1937
|
-
}
|
|
1938
|
-
|
|
1939
2231
|
function useCssVar(prop, target, options = {}) {
|
|
1940
2232
|
const { window = defaultWindow, initialValue, observe = false } = options;
|
|
1941
2233
|
const variable = vue.ref(initialValue);
|
|
1942
2234
|
const elRef = vue.computed(() => {
|
|
1943
2235
|
var _a;
|
|
1944
|
-
return unrefElement(target) || ((_a = window == null ?
|
|
2236
|
+
return unrefElement(target) || ((_a = window == null ? undefined : window.document) == null ? undefined : _a.documentElement);
|
|
1945
2237
|
});
|
|
1946
2238
|
function updateCssVar() {
|
|
1947
2239
|
var _a;
|
|
1948
|
-
const key =
|
|
1949
|
-
const el =
|
|
2240
|
+
const key = vue.toValue(prop);
|
|
2241
|
+
const el = vue.toValue(elRef);
|
|
1950
2242
|
if (el && window && key) {
|
|
1951
|
-
const value = (_a = window.getComputedStyle(el).getPropertyValue(key)) == null ?
|
|
2243
|
+
const value = (_a = window.getComputedStyle(el).getPropertyValue(key)) == null ? undefined : _a.trim();
|
|
1952
2244
|
variable.value = value || initialValue;
|
|
1953
2245
|
}
|
|
1954
2246
|
}
|
|
@@ -1959,7 +2251,7 @@
|
|
|
1959
2251
|
});
|
|
1960
2252
|
}
|
|
1961
2253
|
vue.watch(
|
|
1962
|
-
[elRef, () =>
|
|
2254
|
+
[elRef, () => vue.toValue(prop)],
|
|
1963
2255
|
(_, old) => {
|
|
1964
2256
|
if (old[0] && old[1])
|
|
1965
2257
|
old[0].style.removeProperty(old[1]);
|
|
@@ -1971,8 +2263,8 @@
|
|
|
1971
2263
|
variable,
|
|
1972
2264
|
(val) => {
|
|
1973
2265
|
var _a;
|
|
1974
|
-
const raw_prop =
|
|
1975
|
-
if (((_a = elRef.value) == null ?
|
|
2266
|
+
const raw_prop = vue.toValue(prop);
|
|
2267
|
+
if (((_a = elRef.value) == null ? undefined : _a.style) && raw_prop) {
|
|
1976
2268
|
if (val == null)
|
|
1977
2269
|
elRef.value.style.removeProperty(raw_prop);
|
|
1978
2270
|
else
|
|
@@ -2002,7 +2294,7 @@
|
|
|
2002
2294
|
bottomCssVar.value = "env(safe-area-inset-bottom, 0px)";
|
|
2003
2295
|
leftCssVar.value = "env(safe-area-inset-left, 0px)";
|
|
2004
2296
|
update();
|
|
2005
|
-
useEventListener("resize", shared.useDebounceFn(update));
|
|
2297
|
+
useEventListener("resize", shared.useDebounceFn(update), { passive: true });
|
|
2006
2298
|
}
|
|
2007
2299
|
function update() {
|
|
2008
2300
|
top.value = getValue(topVarName);
|
|
@@ -2074,12 +2366,12 @@
|
|
|
2074
2366
|
...options,
|
|
2075
2367
|
onScroll(e) {
|
|
2076
2368
|
var _a;
|
|
2077
|
-
(_a = options.onScroll) == null ?
|
|
2369
|
+
(_a = options.onScroll) == null ? undefined : _a.call(options, e);
|
|
2078
2370
|
handler(state);
|
|
2079
2371
|
},
|
|
2080
2372
|
onStop(e) {
|
|
2081
2373
|
var _a;
|
|
2082
|
-
(_a = options.onStop) == null ?
|
|
2374
|
+
(_a = options.onStop) == null ? undefined : _a.call(options, e);
|
|
2083
2375
|
handler(state);
|
|
2084
2376
|
}
|
|
2085
2377
|
});
|
|
@@ -2115,7 +2407,7 @@
|
|
|
2115
2407
|
let stopTouchMoveListener = null;
|
|
2116
2408
|
let initialOverflow = "";
|
|
2117
2409
|
vue.watch(shared.toRef(element), (el) => {
|
|
2118
|
-
const target = resolveElement(
|
|
2410
|
+
const target = resolveElement(vue.toValue(el));
|
|
2119
2411
|
if (target) {
|
|
2120
2412
|
const ele = target;
|
|
2121
2413
|
if (!elInitialOverflow.get(ele))
|
|
@@ -2131,7 +2423,7 @@
|
|
|
2131
2423
|
immediate: true
|
|
2132
2424
|
});
|
|
2133
2425
|
const lock = () => {
|
|
2134
|
-
const el = resolveElement(
|
|
2426
|
+
const el = resolveElement(vue.toValue(element));
|
|
2135
2427
|
if (!el || isLocked.value)
|
|
2136
2428
|
return;
|
|
2137
2429
|
if (shared.isIOS) {
|
|
@@ -2148,11 +2440,11 @@
|
|
|
2148
2440
|
isLocked.value = true;
|
|
2149
2441
|
};
|
|
2150
2442
|
const unlock = () => {
|
|
2151
|
-
const el = resolveElement(
|
|
2443
|
+
const el = resolveElement(vue.toValue(element));
|
|
2152
2444
|
if (!el || !isLocked.value)
|
|
2153
2445
|
return;
|
|
2154
2446
|
if (shared.isIOS)
|
|
2155
|
-
stopTouchMoveListener == null ?
|
|
2447
|
+
stopTouchMoveListener == null ? undefined : stopTouchMoveListener();
|
|
2156
2448
|
el.style.overflow = initialOverflow;
|
|
2157
2449
|
elInitialOverflow.delete(el);
|
|
2158
2450
|
isLocked.value = false;
|
|
@@ -2299,11 +2591,13 @@
|
|
|
2299
2591
|
exports.UseWindowSize = UseWindowSize;
|
|
2300
2592
|
exports.VOnClickOutside = vOnClickOutside;
|
|
2301
2593
|
exports.VOnLongPress = vOnLongPress;
|
|
2594
|
+
exports.vElementBounding = vElementBounding;
|
|
2302
2595
|
exports.vElementHover = vElementHover;
|
|
2303
2596
|
exports.vElementSize = vElementSize;
|
|
2304
2597
|
exports.vElementVisibility = vElementVisibility;
|
|
2305
2598
|
exports.vInfiniteScroll = vInfiniteScroll;
|
|
2306
2599
|
exports.vIntersectionObserver = vIntersectionObserver;
|
|
2600
|
+
exports.vMouseInElement = vMouseInElement;
|
|
2307
2601
|
exports.vOnClickOutside = vOnClickOutside;
|
|
2308
2602
|
exports.vOnKeyStroke = vOnKeyStroke;
|
|
2309
2603
|
exports.vOnLongPress = vOnLongPress;
|