@vueuse/components 10.0.0-beta.3 → 10.0.0-beta.5
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 +110 -69
- package/index.d.ts +23 -15
- package/index.iife.js +110 -69
- package/index.iife.min.js +1 -1
- package/index.mjs +111 -70
- package/package.json +4 -4
package/index.cjs
CHANGED
|
@@ -22,7 +22,7 @@ const OnClickOutside = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineComponent({
|
|
|
22
22
|
|
|
23
23
|
function unrefElement(elRef) {
|
|
24
24
|
var _a;
|
|
25
|
-
const plain = shared.
|
|
25
|
+
const plain = shared.toValue(elRef);
|
|
26
26
|
return (_a = plain == null ? void 0 : plain.$el) != null ? _a : plain;
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -33,7 +33,7 @@ function useEventListener(...args) {
|
|
|
33
33
|
let events;
|
|
34
34
|
let listeners;
|
|
35
35
|
let options;
|
|
36
|
-
if (
|
|
36
|
+
if (typeof args[0] === "string" || Array.isArray(args[0])) {
|
|
37
37
|
[events, listeners, options] = args;
|
|
38
38
|
target = defaultWindow;
|
|
39
39
|
} else {
|
|
@@ -55,7 +55,7 @@ function useEventListener(...args) {
|
|
|
55
55
|
return () => el.removeEventListener(event, listener, options2);
|
|
56
56
|
};
|
|
57
57
|
const stopWatch = vueDemi.watch(
|
|
58
|
-
() => [unrefElement(target), shared.
|
|
58
|
+
() => [unrefElement(target), shared.toValue(options)],
|
|
59
59
|
([el, options2]) => {
|
|
60
60
|
cleanup();
|
|
61
61
|
if (!el)
|
|
@@ -179,7 +179,7 @@ function onKeyStroke(...args) {
|
|
|
179
179
|
} = options;
|
|
180
180
|
const predicate = createKeyPredicate(key);
|
|
181
181
|
const listener = (e) => {
|
|
182
|
-
if (e.repeat && shared.
|
|
182
|
+
if (e.repeat && shared.toValue(dedupe))
|
|
183
183
|
return;
|
|
184
184
|
if (predicate(e))
|
|
185
185
|
handler(e);
|
|
@@ -320,8 +320,12 @@ const UseBrowserLocation = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineCompone
|
|
|
320
320
|
|
|
321
321
|
const _global = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
322
322
|
const globalKey = "__vueuse_ssr_handlers__";
|
|
323
|
-
|
|
324
|
-
|
|
323
|
+
const handlers = /* @__PURE__ */ getHandlers();
|
|
324
|
+
function getHandlers() {
|
|
325
|
+
if (!(globalKey in _global))
|
|
326
|
+
_global[globalKey] = _global[globalKey] || {};
|
|
327
|
+
return _global[globalKey];
|
|
328
|
+
}
|
|
325
329
|
function getSSRHandler(key, fallback) {
|
|
326
330
|
return handlers[key] || fallback;
|
|
327
331
|
}
|
|
@@ -409,7 +413,7 @@ function useStorage(key, defaults, storage, options = {}) {
|
|
|
409
413
|
}
|
|
410
414
|
if (!storage)
|
|
411
415
|
return data;
|
|
412
|
-
const rawInit = shared.
|
|
416
|
+
const rawInit = shared.toValue(defaults);
|
|
413
417
|
const type = guessSerializerType(rawInit);
|
|
414
418
|
const serializer = (_a = options.serializer) != null ? _a : StorageSerializers[type];
|
|
415
419
|
const { pause: pauseWatch, resume: resumeWatch } = shared.pausableWatch(
|
|
@@ -456,7 +460,7 @@ function useStorage(key, defaults, storage, options = {}) {
|
|
|
456
460
|
return rawInit;
|
|
457
461
|
} else if (!event && mergeDefaults) {
|
|
458
462
|
const value = serializer.read(rawValue);
|
|
459
|
-
if (
|
|
463
|
+
if (typeof mergeDefaults === "function")
|
|
460
464
|
return mergeDefaults(value, rawInit);
|
|
461
465
|
else if (type === "object" && !Array.isArray(value))
|
|
462
466
|
return __spreadValues$c(__spreadValues$c({}, rawInit), value);
|
|
@@ -528,7 +532,7 @@ function useMediaQuery(query, options = {}) {
|
|
|
528
532
|
if (!isSupported.value)
|
|
529
533
|
return;
|
|
530
534
|
cleanup();
|
|
531
|
-
mediaQuery = window.matchMedia(shared.
|
|
535
|
+
mediaQuery = window.matchMedia(shared.toRef(query).value);
|
|
532
536
|
matches.value = !!(mediaQuery == null ? void 0 : mediaQuery.matches);
|
|
533
537
|
if (!mediaQuery)
|
|
534
538
|
return;
|
|
@@ -573,8 +577,7 @@ function useColorMode(options = {}) {
|
|
|
573
577
|
listenToStorageChanges = true,
|
|
574
578
|
storageRef,
|
|
575
579
|
emitAuto,
|
|
576
|
-
|
|
577
|
-
disableTransition = false
|
|
580
|
+
disableTransition = true
|
|
578
581
|
} = options;
|
|
579
582
|
const modes = __spreadValues$b({
|
|
580
583
|
auto: "",
|
|
@@ -582,11 +585,11 @@ function useColorMode(options = {}) {
|
|
|
582
585
|
dark: "dark"
|
|
583
586
|
}, options.modes || {});
|
|
584
587
|
const preferredDark = usePreferredDark({ window });
|
|
585
|
-
const
|
|
588
|
+
const system = vueDemi.computed(() => preferredDark.value ? "dark" : "light");
|
|
586
589
|
const store = storageRef || (storageKey == null ? vueDemi.ref(initialValue) : useStorage(storageKey, initialValue, storage, { window, listenToStorageChanges }));
|
|
587
590
|
const state = vueDemi.computed({
|
|
588
591
|
get() {
|
|
589
|
-
return store.value === "auto" && !emitAuto ?
|
|
592
|
+
return store.value === "auto" && !emitAuto ? system.value : store.value;
|
|
590
593
|
},
|
|
591
594
|
set(v) {
|
|
592
595
|
store.value = v;
|
|
@@ -595,13 +598,12 @@ function useColorMode(options = {}) {
|
|
|
595
598
|
const updateHTMLAttrs = getSSRHandler(
|
|
596
599
|
"updateHTMLAttrs",
|
|
597
600
|
(selector2, attribute2, value) => {
|
|
598
|
-
const el = window == null ? void 0 : window.document.querySelector(selector2);
|
|
601
|
+
const el = typeof selector2 === "string" ? window == null ? void 0 : window.document.querySelector(selector2) : shared.toValue(selector2);
|
|
599
602
|
if (!el)
|
|
600
603
|
return;
|
|
601
604
|
let style;
|
|
602
605
|
if (disableTransition) {
|
|
603
606
|
style = window.document.createElement("style");
|
|
604
|
-
style.type = "text/css";
|
|
605
607
|
style.appendChild(document.createTextNode("*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}"));
|
|
606
608
|
window.document.head.appendChild(style);
|
|
607
609
|
}
|
|
@@ -624,7 +626,7 @@ function useColorMode(options = {}) {
|
|
|
624
626
|
);
|
|
625
627
|
function defaultOnChanged(mode) {
|
|
626
628
|
var _a;
|
|
627
|
-
const resolvedMode = mode === "auto" ?
|
|
629
|
+
const resolvedMode = mode === "auto" ? system.value : mode;
|
|
628
630
|
updateHTMLAttrs(selector, attribute, (_a = modes[resolvedMode]) != null ? _a : resolvedMode);
|
|
629
631
|
}
|
|
630
632
|
function onChanged(mode) {
|
|
@@ -635,9 +637,13 @@ function useColorMode(options = {}) {
|
|
|
635
637
|
}
|
|
636
638
|
vueDemi.watch(state, onChanged, { flush: "post", immediate: true });
|
|
637
639
|
if (emitAuto)
|
|
638
|
-
vueDemi.watch(
|
|
640
|
+
vueDemi.watch(system, () => onChanged(state.value), { flush: "post" });
|
|
639
641
|
shared.tryOnMounted(() => onChanged(state.value));
|
|
640
|
-
|
|
642
|
+
try {
|
|
643
|
+
return Object.assign(state, { store, system });
|
|
644
|
+
} catch (e) {
|
|
645
|
+
return state;
|
|
646
|
+
}
|
|
641
647
|
}
|
|
642
648
|
|
|
643
649
|
const UseColorMode = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineComponent({
|
|
@@ -646,7 +652,9 @@ const UseColorMode = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineComponent({
|
|
|
646
652
|
setup(props, { slots }) {
|
|
647
653
|
const mode = useColorMode(props);
|
|
648
654
|
const data = vueDemi.reactive({
|
|
649
|
-
mode
|
|
655
|
+
mode,
|
|
656
|
+
system: mode.system,
|
|
657
|
+
store: mode.store
|
|
650
658
|
});
|
|
651
659
|
return () => {
|
|
652
660
|
if (slots.default)
|
|
@@ -772,7 +780,7 @@ const UseDraggable = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineComponent({
|
|
|
772
780
|
});
|
|
773
781
|
const storageValue = props.storageKey && core.useStorage(
|
|
774
782
|
props.storageKey,
|
|
775
|
-
shared.
|
|
783
|
+
shared.toValue(props.initialValue) || { x: 0, y: 0 },
|
|
776
784
|
core.isClient ? props.storageType === "session" ? sessionStorage : localStorage : void 0
|
|
777
785
|
);
|
|
778
786
|
const initialValue = storageValue || props.initialValue || { x: 0, y: 0 };
|
|
@@ -981,23 +989,24 @@ function useIntersectionObserver(target, callback, options = {}) {
|
|
|
981
989
|
root,
|
|
982
990
|
rootMargin = "0px",
|
|
983
991
|
threshold = 0.1,
|
|
984
|
-
window = defaultWindow
|
|
992
|
+
window = defaultWindow,
|
|
993
|
+
immediate = true
|
|
985
994
|
} = options;
|
|
986
995
|
const isSupported = useSupported(() => window && "IntersectionObserver" in window);
|
|
987
996
|
let cleanup = shared.noop;
|
|
997
|
+
const isActive = vueDemi.ref(immediate);
|
|
988
998
|
const stopWatch = isSupported.value ? vueDemi.watch(
|
|
989
|
-
() => (
|
|
990
|
-
|
|
991
|
-
root: unrefElement(root)
|
|
992
|
-
}),
|
|
993
|
-
({ el, root: root2 }) => {
|
|
999
|
+
() => [unrefElement(target), unrefElement(root), isActive.value],
|
|
1000
|
+
([el, root2]) => {
|
|
994
1001
|
cleanup();
|
|
1002
|
+
if (!isActive.value)
|
|
1003
|
+
return;
|
|
995
1004
|
if (!el)
|
|
996
1005
|
return;
|
|
997
1006
|
const observer = new IntersectionObserver(
|
|
998
1007
|
callback,
|
|
999
1008
|
{
|
|
1000
|
-
root: root2,
|
|
1009
|
+
root: unrefElement(root2),
|
|
1001
1010
|
rootMargin,
|
|
1002
1011
|
threshold
|
|
1003
1012
|
}
|
|
@@ -1008,15 +1017,24 @@ function useIntersectionObserver(target, callback, options = {}) {
|
|
|
1008
1017
|
cleanup = shared.noop;
|
|
1009
1018
|
};
|
|
1010
1019
|
},
|
|
1011
|
-
{ immediate
|
|
1020
|
+
{ immediate, flush: "post" }
|
|
1012
1021
|
) : shared.noop;
|
|
1013
1022
|
const stop = () => {
|
|
1014
1023
|
cleanup();
|
|
1015
1024
|
stopWatch();
|
|
1025
|
+
isActive.value = false;
|
|
1016
1026
|
};
|
|
1017
1027
|
shared.tryOnScopeDispose(stop);
|
|
1018
1028
|
return {
|
|
1019
1029
|
isSupported,
|
|
1030
|
+
isActive,
|
|
1031
|
+
pause() {
|
|
1032
|
+
cleanup();
|
|
1033
|
+
isActive.value = false;
|
|
1034
|
+
},
|
|
1035
|
+
resume() {
|
|
1036
|
+
isActive.value = true;
|
|
1037
|
+
},
|
|
1020
1038
|
stop
|
|
1021
1039
|
};
|
|
1022
1040
|
}
|
|
@@ -1181,14 +1199,14 @@ async function loadImage(options) {
|
|
|
1181
1199
|
}
|
|
1182
1200
|
function useImage(options, asyncStateOptions = {}) {
|
|
1183
1201
|
const state = useAsyncState(
|
|
1184
|
-
() => loadImage(shared.
|
|
1202
|
+
() => loadImage(shared.toValue(options)),
|
|
1185
1203
|
void 0,
|
|
1186
1204
|
__spreadValues$9({
|
|
1187
1205
|
resetOnExecute: true
|
|
1188
1206
|
}, asyncStateOptions)
|
|
1189
1207
|
);
|
|
1190
1208
|
vueDemi.watch(
|
|
1191
|
-
() => shared.
|
|
1209
|
+
() => shared.toValue(options),
|
|
1192
1210
|
() => state.execute(asyncStateOptions.delay),
|
|
1193
1211
|
{ deep: true }
|
|
1194
1212
|
);
|
|
@@ -1256,13 +1274,13 @@ function useScroll(element, options = {}) {
|
|
|
1256
1274
|
});
|
|
1257
1275
|
function scrollTo(_x, _y) {
|
|
1258
1276
|
var _a, _b, _c;
|
|
1259
|
-
const _element = shared.
|
|
1277
|
+
const _element = shared.toValue(element);
|
|
1260
1278
|
if (!_element)
|
|
1261
1279
|
return;
|
|
1262
1280
|
(_c = _element instanceof Document ? document.body : _element) == null ? void 0 : _c.scrollTo({
|
|
1263
|
-
top: (_a = shared.
|
|
1264
|
-
left: (_b = shared.
|
|
1265
|
-
behavior: shared.
|
|
1281
|
+
top: (_a = shared.toValue(_y)) != null ? _a : y.value,
|
|
1282
|
+
left: (_b = shared.toValue(_x)) != null ? _b : x.value,
|
|
1283
|
+
behavior: shared.toValue(behavior)
|
|
1266
1284
|
});
|
|
1267
1285
|
}
|
|
1268
1286
|
const isScrolling = vueDemi.ref(false);
|
|
@@ -1291,19 +1309,34 @@ function useScroll(element, options = {}) {
|
|
|
1291
1309
|
const onScrollEndDebounced = shared.useDebounceFn(onScrollEnd, throttle + idle);
|
|
1292
1310
|
const onScrollHandler = (e) => {
|
|
1293
1311
|
const eventTarget = e.target === document ? e.target.documentElement : e.target;
|
|
1312
|
+
const { display, flexDirection } = getComputedStyle(eventTarget);
|
|
1294
1313
|
const scrollLeft = eventTarget.scrollLeft;
|
|
1295
1314
|
directions.left = scrollLeft < internalX.value;
|
|
1296
|
-
directions.right = scrollLeft >
|
|
1297
|
-
|
|
1298
|
-
|
|
1315
|
+
directions.right = scrollLeft > internalX.value;
|
|
1316
|
+
const left = Math.abs(scrollLeft) <= 0 + (offset.left || 0);
|
|
1317
|
+
const right = Math.abs(scrollLeft) + eventTarget.clientWidth >= eventTarget.scrollWidth - (offset.right || 0) - ARRIVED_STATE_THRESHOLD_PIXELS;
|
|
1318
|
+
if (display === "flex" && flexDirection === "row-reverse") {
|
|
1319
|
+
arrivedState.left = right;
|
|
1320
|
+
arrivedState.right = left;
|
|
1321
|
+
} else {
|
|
1322
|
+
arrivedState.left = left;
|
|
1323
|
+
arrivedState.right = right;
|
|
1324
|
+
}
|
|
1299
1325
|
internalX.value = scrollLeft;
|
|
1300
1326
|
let scrollTop = eventTarget.scrollTop;
|
|
1301
1327
|
if (e.target === document && !scrollTop)
|
|
1302
1328
|
scrollTop = document.body.scrollTop;
|
|
1303
1329
|
directions.top = scrollTop < internalY.value;
|
|
1304
1330
|
directions.bottom = scrollTop > internalY.value;
|
|
1305
|
-
|
|
1306
|
-
|
|
1331
|
+
const top = Math.abs(scrollTop) <= 0 + (offset.top || 0);
|
|
1332
|
+
const bottom = Math.abs(scrollTop) + eventTarget.clientHeight >= eventTarget.scrollHeight - (offset.bottom || 0) - ARRIVED_STATE_THRESHOLD_PIXELS;
|
|
1333
|
+
if (display === "flex" && flexDirection === "column-reverse") {
|
|
1334
|
+
arrivedState.top = bottom;
|
|
1335
|
+
arrivedState.bottom = top;
|
|
1336
|
+
} else {
|
|
1337
|
+
arrivedState.top = top;
|
|
1338
|
+
arrivedState.bottom = bottom;
|
|
1339
|
+
}
|
|
1307
1340
|
internalY.value = scrollTop;
|
|
1308
1341
|
isScrolling.value = true;
|
|
1309
1342
|
onScrollEndDebounced(e);
|
|
@@ -1350,38 +1383,46 @@ var __spreadValues$8 = (a, b) => {
|
|
|
1350
1383
|
};
|
|
1351
1384
|
var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
|
|
1352
1385
|
function useInfiniteScroll(element, onLoadMore, options = {}) {
|
|
1353
|
-
var _a
|
|
1354
|
-
const
|
|
1386
|
+
var _a;
|
|
1387
|
+
const {
|
|
1388
|
+
direction = "bottom",
|
|
1389
|
+
interval = 100
|
|
1390
|
+
} = options;
|
|
1355
1391
|
const state = vueDemi.reactive(useScroll(
|
|
1356
1392
|
element,
|
|
1357
1393
|
__spreadProps$7(__spreadValues$8({}, options), {
|
|
1358
1394
|
offset: __spreadValues$8({
|
|
1359
|
-
[direction]: (
|
|
1395
|
+
[direction]: (_a = options.distance) != null ? _a : 0
|
|
1360
1396
|
}, options.offset)
|
|
1361
1397
|
})
|
|
1362
1398
|
));
|
|
1363
|
-
vueDemi.
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
});
|
|
1380
|
-
});
|
|
1381
|
-
}
|
|
1399
|
+
const promise = vueDemi.ref();
|
|
1400
|
+
const isLoading = vueDemi.computed(() => !!promise.value);
|
|
1401
|
+
function checkAndLoad() {
|
|
1402
|
+
const el = shared.toValue(element);
|
|
1403
|
+
if (!el)
|
|
1404
|
+
return;
|
|
1405
|
+
const isNarrower = direction === "bottom" || direction === "top" ? el.scrollHeight <= el.clientHeight : el.scrollWidth <= el.clientWidth;
|
|
1406
|
+
if (state.arrivedState[direction] || isNarrower) {
|
|
1407
|
+
if (!promise.value) {
|
|
1408
|
+
promise.value = Promise.all([
|
|
1409
|
+
onLoadMore(state),
|
|
1410
|
+
new Promise((resolve) => setTimeout(resolve, interval))
|
|
1411
|
+
]).finally(() => {
|
|
1412
|
+
promise.value = null;
|
|
1413
|
+
vueDemi.nextTick(() => checkAndLoad());
|
|
1414
|
+
});
|
|
1382
1415
|
}
|
|
1383
1416
|
}
|
|
1417
|
+
}
|
|
1418
|
+
vueDemi.watch(
|
|
1419
|
+
() => [state.arrivedState[direction], shared.toValue(element)],
|
|
1420
|
+
checkAndLoad,
|
|
1421
|
+
{ immediate: true }
|
|
1384
1422
|
);
|
|
1423
|
+
return {
|
|
1424
|
+
isLoading
|
|
1425
|
+
};
|
|
1385
1426
|
}
|
|
1386
1427
|
|
|
1387
1428
|
const vInfiniteScroll = {
|
|
@@ -1507,7 +1548,7 @@ const UseObjectUrl = /* @__PURE__ */ /* #__PURE__ */ vueDemi.defineComponent({
|
|
|
1507
1548
|
"object"
|
|
1508
1549
|
],
|
|
1509
1550
|
setup(props, { slots }) {
|
|
1510
|
-
const object =
|
|
1551
|
+
const object = shared.toRef(props, "object");
|
|
1511
1552
|
const url = core.useObjectUrl(object);
|
|
1512
1553
|
return () => {
|
|
1513
1554
|
if (slots.default && url.value)
|
|
@@ -1726,8 +1767,8 @@ function useCssVar(prop, target, options = {}) {
|
|
|
1726
1767
|
});
|
|
1727
1768
|
function updateCssVar() {
|
|
1728
1769
|
var _a;
|
|
1729
|
-
const key = shared.
|
|
1730
|
-
const el = shared.
|
|
1770
|
+
const key = shared.toValue(prop);
|
|
1771
|
+
const el = shared.toValue(elRef);
|
|
1731
1772
|
if (el && window) {
|
|
1732
1773
|
const value = (_a = window.getComputedStyle(el).getPropertyValue(key)) == null ? void 0 : _a.trim();
|
|
1733
1774
|
variable.value = value || initialValue;
|
|
@@ -1740,7 +1781,7 @@ function useCssVar(prop, target, options = {}) {
|
|
|
1740
1781
|
});
|
|
1741
1782
|
}
|
|
1742
1783
|
vueDemi.watch(
|
|
1743
|
-
[elRef, () => shared.
|
|
1784
|
+
[elRef, () => shared.toValue(prop)],
|
|
1744
1785
|
updateCssVar,
|
|
1745
1786
|
{ immediate: true }
|
|
1746
1787
|
);
|
|
@@ -1749,7 +1790,7 @@ function useCssVar(prop, target, options = {}) {
|
|
|
1749
1790
|
(val) => {
|
|
1750
1791
|
var _a;
|
|
1751
1792
|
if ((_a = elRef.value) == null ? void 0 : _a.style)
|
|
1752
|
-
elRef.value.style.setProperty(shared.
|
|
1793
|
+
elRef.value.style.setProperty(shared.toValue(prop), val);
|
|
1753
1794
|
}
|
|
1754
1795
|
);
|
|
1755
1796
|
return variable;
|
|
@@ -1903,7 +1944,7 @@ function useScrollLock(element, initialState = false) {
|
|
|
1903
1944
|
const isLocked = vueDemi.ref(initialState);
|
|
1904
1945
|
let stopTouchMoveListener = null;
|
|
1905
1946
|
let initialOverflow;
|
|
1906
|
-
vueDemi.watch(shared.
|
|
1947
|
+
vueDemi.watch(shared.toRef(element), (el) => {
|
|
1907
1948
|
if (el) {
|
|
1908
1949
|
const ele = el;
|
|
1909
1950
|
initialOverflow = ele.style.overflow;
|
|
@@ -1914,7 +1955,7 @@ function useScrollLock(element, initialState = false) {
|
|
|
1914
1955
|
immediate: true
|
|
1915
1956
|
});
|
|
1916
1957
|
const lock = () => {
|
|
1917
|
-
const ele = shared.
|
|
1958
|
+
const ele = shared.toValue(element);
|
|
1918
1959
|
if (!ele || isLocked.value)
|
|
1919
1960
|
return;
|
|
1920
1961
|
if (shared.isIOS) {
|
|
@@ -1931,7 +1972,7 @@ function useScrollLock(element, initialState = false) {
|
|
|
1931
1972
|
isLocked.value = true;
|
|
1932
1973
|
};
|
|
1933
1974
|
const unlock = () => {
|
|
1934
|
-
const ele = shared.
|
|
1975
|
+
const ele = shared.toValue(element);
|
|
1935
1976
|
if (!ele || !isLocked.value)
|
|
1936
1977
|
return;
|
|
1937
1978
|
shared.isIOS && (stopTouchMoveListener == null ? void 0 : stopTouchMoveListener());
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as vue_demi from 'vue-demi';
|
|
2
2
|
import { ComponentPublicInstance, ObjectDirective, Ref, UnwrapNestedRefs, ComputedRef, FunctionDirective } from 'vue-demi';
|
|
3
|
-
import { MaybeRef,
|
|
3
|
+
import { MaybeRef, MaybeRefOrGetter, ConfigurableEventFilter, ConfigurableFlush, Awaitable } from '@vueuse/shared';
|
|
4
4
|
import { UseDarkOptions, UseDevicesListOptions, UseDraggableOptions, ElementSize as ElementSize$1, UseGeolocationOptions, UseIdleOptions, UseMouseOptions, MouseInElementOptions, MousePressedOptions, UseNowOptions, UsePointerOptions, UseTimeAgoOptions, UseTimestampOptions, UseVirtualListOptions, UseWindowSizeOptions } from '@vueuse/core';
|
|
5
5
|
|
|
6
6
|
interface ConfigurableWindow {
|
|
@@ -18,7 +18,7 @@ interface RenderableComponent {
|
|
|
18
18
|
|
|
19
19
|
type VueInstance = ComponentPublicInstance;
|
|
20
20
|
type MaybeElementRef<T extends MaybeElement = MaybeElement> = MaybeRef<T>;
|
|
21
|
-
type MaybeComputedElementRef<T extends MaybeElement = MaybeElement> =
|
|
21
|
+
type MaybeComputedElementRef<T extends MaybeElement = MaybeElement> = MaybeRefOrGetter<T>;
|
|
22
22
|
type MaybeElement = HTMLElement | SVGElement | VueInstance | undefined | null;
|
|
23
23
|
|
|
24
24
|
interface OnClickOutsideOptions extends ConfigurableWindow {
|
|
@@ -53,14 +53,14 @@ declare const vOnClickOutside: ObjectDirective<HTMLElement, OnClickOutsideHandle
|
|
|
53
53
|
type KeyStrokeEventName = 'keydown' | 'keypress' | 'keyup';
|
|
54
54
|
interface OnKeyStrokeOptions {
|
|
55
55
|
eventName?: KeyStrokeEventName;
|
|
56
|
-
target?:
|
|
56
|
+
target?: MaybeRefOrGetter<EventTarget | null | undefined>;
|
|
57
57
|
passive?: boolean;
|
|
58
58
|
/**
|
|
59
59
|
* Set to `true` to ignore repeated events when the key is being held down.
|
|
60
60
|
*
|
|
61
61
|
* @default false
|
|
62
62
|
*/
|
|
63
|
-
dedupe?:
|
|
63
|
+
dedupe?: MaybeRefOrGetter<boolean>;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
type BindingValueFunction$7 = (event: KeyboardEvent) => void;
|
|
@@ -171,7 +171,7 @@ interface UseColorModeOptions<T extends string = BasicColorSchema> extends UseSt
|
|
|
171
171
|
*
|
|
172
172
|
* @default 'html'
|
|
173
173
|
*/
|
|
174
|
-
selector?: string
|
|
174
|
+
selector?: string | MaybeRefOrGetter<HTMLElement | null | undefined>;
|
|
175
175
|
/**
|
|
176
176
|
* HTML attribute applying the target element
|
|
177
177
|
*
|
|
@@ -228,7 +228,7 @@ interface UseColorModeOptions<T extends string = BasicColorSchema> extends UseSt
|
|
|
228
228
|
* Disable transition on switch
|
|
229
229
|
*
|
|
230
230
|
* @see https://paco.me/writing/disable-theme-transitions
|
|
231
|
-
* @default
|
|
231
|
+
* @default true
|
|
232
232
|
*/
|
|
233
233
|
disableTransition?: boolean;
|
|
234
234
|
}
|
|
@@ -312,7 +312,7 @@ declare const vElementSize: ObjectDirective<HTMLElement, BindingValueFunction$4
|
|
|
312
312
|
declare const UseElementVisibility: vue_demi.DefineComponent<RenderableComponent, {}, {}, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, {}, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<RenderableComponent>, {}>;
|
|
313
313
|
|
|
314
314
|
interface UseElementVisibilityOptions extends ConfigurableWindow {
|
|
315
|
-
scrollTarget?:
|
|
315
|
+
scrollTarget?: MaybeRefOrGetter<HTMLElement | undefined | null>;
|
|
316
316
|
}
|
|
317
317
|
|
|
318
318
|
type BindingValueFunction$3 = (state: boolean) => void;
|
|
@@ -394,7 +394,7 @@ interface UseScrollOptions {
|
|
|
394
394
|
*
|
|
395
395
|
* @default 'auto'
|
|
396
396
|
*/
|
|
397
|
-
behavior?:
|
|
397
|
+
behavior?: MaybeRefOrGetter<ScrollBehavior>;
|
|
398
398
|
}
|
|
399
399
|
/**
|
|
400
400
|
* Reactive scroll.
|
|
@@ -403,7 +403,7 @@ interface UseScrollOptions {
|
|
|
403
403
|
* @param element
|
|
404
404
|
* @param options
|
|
405
405
|
*/
|
|
406
|
-
declare function useScroll(element:
|
|
406
|
+
declare function useScroll(element: MaybeRefOrGetter<HTMLElement | SVGElement | Window | Document | null | undefined>, options?: UseScrollOptions): {
|
|
407
407
|
x: vue_demi.WritableComputedRef<number>;
|
|
408
408
|
y: vue_demi.WritableComputedRef<number>;
|
|
409
409
|
isScrolling: vue_demi.Ref<boolean>;
|
|
@@ -436,24 +436,32 @@ interface UseInfiniteScrollOptions extends UseScrollOptions {
|
|
|
436
436
|
*/
|
|
437
437
|
direction?: 'top' | 'bottom' | 'left' | 'right';
|
|
438
438
|
/**
|
|
439
|
-
*
|
|
439
|
+
* The interval time between two load more (to avoid too many invokes).
|
|
440
440
|
*
|
|
441
|
-
* @default
|
|
441
|
+
* @default 100
|
|
442
442
|
*/
|
|
443
|
-
|
|
443
|
+
interval?: number;
|
|
444
444
|
}
|
|
445
445
|
/**
|
|
446
446
|
* Reactive infinite scroll.
|
|
447
447
|
*
|
|
448
448
|
* @see https://vueuse.org/useInfiniteScroll
|
|
449
449
|
*/
|
|
450
|
-
declare function useInfiniteScroll(element:
|
|
450
|
+
declare function useInfiniteScroll(element: MaybeRefOrGetter<HTMLElement | SVGElement | Window | Document | null | undefined>, onLoadMore: (state: UnwrapNestedRefs<ReturnType<typeof useScroll>>) => Awaitable<void>, options?: UseInfiniteScrollOptions): {
|
|
451
|
+
isLoading: vue_demi.ComputedRef<boolean>;
|
|
452
|
+
};
|
|
451
453
|
|
|
452
454
|
type BindingValueFunction$2 = Parameters<typeof useInfiniteScroll>[1];
|
|
453
455
|
type BindingValueArray$2 = [BindingValueFunction$2, UseInfiniteScrollOptions];
|
|
454
456
|
declare const vInfiniteScroll: ObjectDirective<HTMLElement, BindingValueFunction$2 | BindingValueArray$2>;
|
|
455
457
|
|
|
456
458
|
interface UseIntersectionObserverOptions extends ConfigurableWindow {
|
|
459
|
+
/**
|
|
460
|
+
* Start the IntersectionObserver immediately on creation
|
|
461
|
+
*
|
|
462
|
+
* @default true
|
|
463
|
+
*/
|
|
464
|
+
immediate?: boolean;
|
|
457
465
|
/**
|
|
458
466
|
* The Element or Document whose bounds are used as the bounding box when testing for intersection.
|
|
459
467
|
*/
|
|
@@ -493,12 +501,12 @@ interface UseOffsetPaginationOptions {
|
|
|
493
501
|
/**
|
|
494
502
|
* Total number of items.
|
|
495
503
|
*/
|
|
496
|
-
total?:
|
|
504
|
+
total?: MaybeRefOrGetter<number>;
|
|
497
505
|
/**
|
|
498
506
|
* The number of items to display per page.
|
|
499
507
|
* @default 10
|
|
500
508
|
*/
|
|
501
|
-
pageSize?:
|
|
509
|
+
pageSize?: MaybeRefOrGetter<number>;
|
|
502
510
|
/**
|
|
503
511
|
* The current page number.
|
|
504
512
|
* @default 1
|