@vueuse/components 8.9.4 → 9.0.0-beta.2
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 +106 -71
- package/index.d.ts +40 -24
- package/index.iife.js +106 -87
- package/index.iife.min.js +1 -1
- package/index.mjs +108 -73
- package/package.json +3 -3
package/index.cjs
CHANGED
|
@@ -24,7 +24,7 @@ const OnClickOutside = vueDemi.defineComponent({
|
|
|
24
24
|
|
|
25
25
|
function unrefElement(elRef) {
|
|
26
26
|
var _a;
|
|
27
|
-
const plain =
|
|
27
|
+
const plain = shared.resolveUnref(elRef);
|
|
28
28
|
return (_a = plain == null ? void 0 : plain.$el) != null ? _a : plain;
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -142,19 +142,19 @@ function onKeyStroke(key, handler, options = {}) {
|
|
|
142
142
|
return useEventListener(target, eventName, listener, passive);
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
var __defProp$
|
|
146
|
-
var __getOwnPropSymbols$
|
|
147
|
-
var __hasOwnProp$
|
|
148
|
-
var __propIsEnum$
|
|
149
|
-
var __defNormalProp$
|
|
150
|
-
var __spreadValues$
|
|
145
|
+
var __defProp$d = Object.defineProperty;
|
|
146
|
+
var __getOwnPropSymbols$e = Object.getOwnPropertySymbols;
|
|
147
|
+
var __hasOwnProp$e = Object.prototype.hasOwnProperty;
|
|
148
|
+
var __propIsEnum$e = Object.prototype.propertyIsEnumerable;
|
|
149
|
+
var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
150
|
+
var __spreadValues$d = (a, b) => {
|
|
151
151
|
for (var prop in b || (b = {}))
|
|
152
|
-
if (__hasOwnProp$
|
|
153
|
-
__defNormalProp$
|
|
154
|
-
if (__getOwnPropSymbols$
|
|
155
|
-
for (var prop of __getOwnPropSymbols$
|
|
156
|
-
if (__propIsEnum$
|
|
157
|
-
__defNormalProp$
|
|
152
|
+
if (__hasOwnProp$e.call(b, prop))
|
|
153
|
+
__defNormalProp$d(a, prop, b[prop]);
|
|
154
|
+
if (__getOwnPropSymbols$e)
|
|
155
|
+
for (var prop of __getOwnPropSymbols$e(b)) {
|
|
156
|
+
if (__propIsEnum$e.call(b, prop))
|
|
157
|
+
__defNormalProp$d(a, prop, b[prop]);
|
|
158
158
|
}
|
|
159
159
|
return a;
|
|
160
160
|
};
|
|
@@ -168,7 +168,7 @@ const vOnKeyStroke = {
|
|
|
168
168
|
});
|
|
169
169
|
} else {
|
|
170
170
|
const [handler, options] = binding.value;
|
|
171
|
-
onKeyStroke(keys, handler, __spreadValues$
|
|
171
|
+
onKeyStroke(keys, handler, __spreadValues$d({
|
|
172
172
|
target: el
|
|
173
173
|
}, options));
|
|
174
174
|
}
|
|
@@ -278,6 +278,22 @@ function guessSerializerType(rawInit) {
|
|
|
278
278
|
return rawInit == null ? "any" : rawInit instanceof Set ? "set" : rawInit instanceof Map ? "map" : rawInit instanceof Date ? "date" : typeof rawInit === "boolean" ? "boolean" : typeof rawInit === "string" ? "string" : typeof rawInit === "object" ? "object" : Array.isArray(rawInit) ? "object" : !Number.isNaN(rawInit) ? "number" : "any";
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
+
var __defProp$c = Object.defineProperty;
|
|
282
|
+
var __getOwnPropSymbols$d = Object.getOwnPropertySymbols;
|
|
283
|
+
var __hasOwnProp$d = Object.prototype.hasOwnProperty;
|
|
284
|
+
var __propIsEnum$d = Object.prototype.propertyIsEnumerable;
|
|
285
|
+
var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
286
|
+
var __spreadValues$c = (a, b) => {
|
|
287
|
+
for (var prop in b || (b = {}))
|
|
288
|
+
if (__hasOwnProp$d.call(b, prop))
|
|
289
|
+
__defNormalProp$c(a, prop, b[prop]);
|
|
290
|
+
if (__getOwnPropSymbols$d)
|
|
291
|
+
for (var prop of __getOwnPropSymbols$d(b)) {
|
|
292
|
+
if (__propIsEnum$d.call(b, prop))
|
|
293
|
+
__defNormalProp$c(a, prop, b[prop]);
|
|
294
|
+
}
|
|
295
|
+
return a;
|
|
296
|
+
};
|
|
281
297
|
const StorageSerializers = {
|
|
282
298
|
boolean: {
|
|
283
299
|
read: (v) => v === "true",
|
|
@@ -312,13 +328,14 @@ const StorageSerializers = {
|
|
|
312
328
|
write: (v) => v.toISOString()
|
|
313
329
|
}
|
|
314
330
|
};
|
|
315
|
-
function useStorage(key,
|
|
331
|
+
function useStorage(key, defaults, storage, options = {}) {
|
|
316
332
|
var _a;
|
|
317
333
|
const {
|
|
318
334
|
flush = "pre",
|
|
319
335
|
deep = true,
|
|
320
336
|
listenToStorageChanges = true,
|
|
321
337
|
writeDefaults = true,
|
|
338
|
+
mergeDefaults = false,
|
|
322
339
|
shallow,
|
|
323
340
|
window = defaultWindow,
|
|
324
341
|
eventFilter,
|
|
@@ -326,7 +343,7 @@ function useStorage(key, initialValue, storage, options = {}) {
|
|
|
326
343
|
console.error(e);
|
|
327
344
|
}
|
|
328
345
|
} = options;
|
|
329
|
-
const data = (shallow ? vueDemi.shallowRef : vueDemi.ref)(
|
|
346
|
+
const data = (shallow ? vueDemi.shallowRef : vueDemi.ref)(defaults);
|
|
330
347
|
if (!storage) {
|
|
331
348
|
try {
|
|
332
349
|
storage = getSSRHandler("getDefaultStorage", () => {
|
|
@@ -339,7 +356,7 @@ function useStorage(key, initialValue, storage, options = {}) {
|
|
|
339
356
|
}
|
|
340
357
|
if (!storage)
|
|
341
358
|
return data;
|
|
342
|
-
const rawInit =
|
|
359
|
+
const rawInit = shared.resolveUnref(defaults);
|
|
343
360
|
const type = guessSerializerType(rawInit);
|
|
344
361
|
const serializer = (_a = options.serializer) != null ? _a : StorageSerializers[type];
|
|
345
362
|
const { pause: pauseWatch, resume: resumeWatch } = shared.pausableWatch(data, () => write(data.value), { flush, deep, eventFilter });
|
|
@@ -367,6 +384,13 @@ function useStorage(key, initialValue, storage, options = {}) {
|
|
|
367
384
|
if (writeDefaults && rawInit !== null)
|
|
368
385
|
storage.setItem(key, serializer.write(rawInit));
|
|
369
386
|
return rawInit;
|
|
387
|
+
} else if (!event && mergeDefaults) {
|
|
388
|
+
const value = serializer.read(rawValue);
|
|
389
|
+
if (shared.isFunction(mergeDefaults))
|
|
390
|
+
return mergeDefaults(value, rawInit);
|
|
391
|
+
else if (type === "object" && !Array.isArray(value))
|
|
392
|
+
return __spreadValues$c(__spreadValues$c({}, rawInit), value);
|
|
393
|
+
return value;
|
|
370
394
|
} else if (typeof rawValue !== "string") {
|
|
371
395
|
return rawValue;
|
|
372
396
|
} else {
|
|
@@ -385,13 +409,21 @@ function useStorage(key, initialValue, storage, options = {}) {
|
|
|
385
409
|
}
|
|
386
410
|
}
|
|
387
411
|
|
|
412
|
+
function useSupported(callback, sync = false) {
|
|
413
|
+
const isSupported = vueDemi.ref();
|
|
414
|
+
const update = () => isSupported.value = Boolean(callback());
|
|
415
|
+
update();
|
|
416
|
+
shared.tryOnMounted(update, sync);
|
|
417
|
+
return isSupported;
|
|
418
|
+
}
|
|
419
|
+
|
|
388
420
|
function useMediaQuery(query, options = {}) {
|
|
389
421
|
const { window = defaultWindow } = options;
|
|
390
|
-
const isSupported =
|
|
422
|
+
const isSupported = useSupported(() => window && "matchMedia" in window && typeof window.matchMedia === "function");
|
|
391
423
|
let mediaQuery;
|
|
392
424
|
const matches = vueDemi.ref(false);
|
|
393
425
|
const update = () => {
|
|
394
|
-
if (!isSupported)
|
|
426
|
+
if (!isSupported.value)
|
|
395
427
|
return;
|
|
396
428
|
if (!mediaQuery)
|
|
397
429
|
mediaQuery = window.matchMedia(query);
|
|
@@ -439,6 +471,7 @@ function useColorMode(options = {}) {
|
|
|
439
471
|
const {
|
|
440
472
|
selector = "html",
|
|
441
473
|
attribute = "class",
|
|
474
|
+
initialValue = "auto",
|
|
442
475
|
window = defaultWindow,
|
|
443
476
|
storage,
|
|
444
477
|
storageKey = "vueuse-color-scheme",
|
|
@@ -453,7 +486,7 @@ function useColorMode(options = {}) {
|
|
|
453
486
|
}, options.modes || {});
|
|
454
487
|
const preferredDark = usePreferredDark({ window });
|
|
455
488
|
const preferredMode = vueDemi.computed(() => preferredDark.value ? "dark" : "light");
|
|
456
|
-
const store = storageRef || (storageKey == null ? vueDemi.ref(
|
|
489
|
+
const store = storageRef || (storageKey == null ? vueDemi.ref(initialValue) : useStorage(storageKey, initialValue, storage, { window, listenToStorageChanges }));
|
|
457
490
|
const state = vueDemi.computed({
|
|
458
491
|
get() {
|
|
459
492
|
return store.value === "auto" && !emitAuto ? preferredMode.value : store.value;
|
|
@@ -618,7 +651,7 @@ const UseDraggable = vueDemi.defineComponent({
|
|
|
618
651
|
],
|
|
619
652
|
setup(props, { slots }) {
|
|
620
653
|
const target = vueDemi.ref();
|
|
621
|
-
const initialValue = props.storageKey ? core.useStorage(props.storageKey,
|
|
654
|
+
const initialValue = props.storageKey ? core.useStorage(props.storageKey, shared.resolveUnref(props.initialValue) || { x: 0, y: 0 }, core.isClient ? props.storageType === "session" ? sessionStorage : localStorage : void 0) : props.initialValue || { x: 0, y: 0 };
|
|
622
655
|
const data = vueDemi.reactive(core.useDraggable(target, __spreadProps$8(__spreadValues$a({}, props), {
|
|
623
656
|
initialValue
|
|
624
657
|
})));
|
|
@@ -689,7 +722,7 @@ var __objRest = (source, exclude) => {
|
|
|
689
722
|
function useResizeObserver(target, callback, options = {}) {
|
|
690
723
|
const _a = options, { window = defaultWindow } = _a, observerOptions = __objRest(_a, ["window"]);
|
|
691
724
|
let observer;
|
|
692
|
-
const isSupported = window && "ResizeObserver" in window;
|
|
725
|
+
const isSupported = useSupported(() => window && "ResizeObserver" in window);
|
|
693
726
|
const cleanup = () => {
|
|
694
727
|
if (observer) {
|
|
695
728
|
observer.disconnect();
|
|
@@ -698,7 +731,7 @@ function useResizeObserver(target, callback, options = {}) {
|
|
|
698
731
|
};
|
|
699
732
|
const stopWatch = vueDemi.watch(() => unrefElement(target), (el) => {
|
|
700
733
|
cleanup();
|
|
701
|
-
if (isSupported && window && el) {
|
|
734
|
+
if (isSupported.value && window && el) {
|
|
702
735
|
observer = new ResizeObserver(callback);
|
|
703
736
|
observer.observe(el, observerOptions);
|
|
704
737
|
}
|
|
@@ -762,16 +795,18 @@ function useElementVisibility(element, { window = defaultWindow, scrollTarget }
|
|
|
762
795
|
if (!window)
|
|
763
796
|
return;
|
|
764
797
|
const document = window.document;
|
|
765
|
-
|
|
798
|
+
const el = shared.resolveUnref(element);
|
|
799
|
+
if (!el) {
|
|
766
800
|
elementIsVisible.value = false;
|
|
767
801
|
} else {
|
|
768
|
-
const rect =
|
|
802
|
+
const rect = el.getBoundingClientRect();
|
|
769
803
|
elementIsVisible.value = rect.top <= (window.innerHeight || document.documentElement.clientHeight) && rect.left <= (window.innerWidth || document.documentElement.clientWidth) && rect.bottom >= 0 && rect.right >= 0;
|
|
770
804
|
}
|
|
771
805
|
};
|
|
772
806
|
shared.tryOnMounted(testBounding);
|
|
773
|
-
if (window)
|
|
774
|
-
shared.tryOnMounted(() => useEventListener(
|
|
807
|
+
if (window) {
|
|
808
|
+
shared.tryOnMounted(() => useEventListener(() => shared.resolveUnref(scrollTarget) || window, "scroll", testBounding, { capture: false, passive: true }));
|
|
809
|
+
}
|
|
775
810
|
return elementIsVisible;
|
|
776
811
|
}
|
|
777
812
|
|
|
@@ -846,7 +881,8 @@ function useAsyncState(promise, initialState, options) {
|
|
|
846
881
|
delay = 0,
|
|
847
882
|
onError = shared.noop,
|
|
848
883
|
resetOnExecute = true,
|
|
849
|
-
shallow = true
|
|
884
|
+
shallow = true,
|
|
885
|
+
throwError
|
|
850
886
|
} = options != null ? options : {};
|
|
851
887
|
const state = shallow ? vueDemi.shallowRef(initialState) : vueDemi.ref(initialState);
|
|
852
888
|
const isReady = vueDemi.ref(false);
|
|
@@ -868,6 +904,8 @@ function useAsyncState(promise, initialState, options) {
|
|
|
868
904
|
} catch (e) {
|
|
869
905
|
error.value = e;
|
|
870
906
|
onError(e);
|
|
907
|
+
if (throwError)
|
|
908
|
+
throw error;
|
|
871
909
|
} finally {
|
|
872
910
|
isLoading.value = false;
|
|
873
911
|
}
|
|
@@ -914,10 +952,10 @@ async function loadImage(options) {
|
|
|
914
952
|
});
|
|
915
953
|
}
|
|
916
954
|
const useImage = (options, asyncStateOptions = {}) => {
|
|
917
|
-
const state = useAsyncState(() => loadImage(
|
|
955
|
+
const state = useAsyncState(() => loadImage(shared.resolveUnref(options)), void 0, __spreadValues$9({
|
|
918
956
|
resetOnExecute: true
|
|
919
957
|
}, asyncStateOptions));
|
|
920
|
-
vueDemi.watch(() =>
|
|
958
|
+
vueDemi.watch(() => shared.resolveUnref(options), () => state.execute(asyncStateOptions.delay), { deep: true });
|
|
921
959
|
return state;
|
|
922
960
|
};
|
|
923
961
|
|
|
@@ -975,37 +1013,35 @@ function useScroll(element, options = {}) {
|
|
|
975
1013
|
top: false,
|
|
976
1014
|
bottom: false
|
|
977
1015
|
});
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
const
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
useEventListener(element, "scroll", throttle ? shared.useThrottleFn(onScrollHandler, throttle) : onScrollHandler, eventListenerOptions);
|
|
1008
|
-
}
|
|
1016
|
+
const onScrollEnd = shared.useDebounceFn((e) => {
|
|
1017
|
+
isScrolling.value = false;
|
|
1018
|
+
directions.left = false;
|
|
1019
|
+
directions.right = false;
|
|
1020
|
+
directions.top = false;
|
|
1021
|
+
directions.bottom = false;
|
|
1022
|
+
onStop(e);
|
|
1023
|
+
}, throttle + idle);
|
|
1024
|
+
const onScrollHandler = (e) => {
|
|
1025
|
+
const eventTarget = e.target === document ? e.target.documentElement : e.target;
|
|
1026
|
+
const scrollLeft = eventTarget.scrollLeft;
|
|
1027
|
+
directions.left = scrollLeft < x.value;
|
|
1028
|
+
directions.right = scrollLeft > x.value;
|
|
1029
|
+
arrivedState.left = scrollLeft <= 0 + (offset.left || 0);
|
|
1030
|
+
arrivedState.right = scrollLeft + eventTarget.clientWidth >= eventTarget.scrollWidth - (offset.right || 0);
|
|
1031
|
+
x.value = scrollLeft;
|
|
1032
|
+
let scrollTop = eventTarget.scrollTop;
|
|
1033
|
+
if (e.target === document && !scrollTop)
|
|
1034
|
+
scrollTop = document.body.scrollTop;
|
|
1035
|
+
directions.top = scrollTop < y.value;
|
|
1036
|
+
directions.bottom = scrollTop > y.value;
|
|
1037
|
+
arrivedState.top = scrollTop <= 0 + (offset.top || 0);
|
|
1038
|
+
arrivedState.bottom = scrollTop + eventTarget.clientHeight >= eventTarget.scrollHeight - (offset.bottom || 0);
|
|
1039
|
+
y.value = scrollTop;
|
|
1040
|
+
isScrolling.value = true;
|
|
1041
|
+
onScrollEnd(e);
|
|
1042
|
+
onScroll(e);
|
|
1043
|
+
};
|
|
1044
|
+
useEventListener(element, "scroll", throttle ? shared.useThrottleFn(onScrollHandler, throttle) : onScrollHandler, eventListenerOptions);
|
|
1009
1045
|
return {
|
|
1010
1046
|
x,
|
|
1011
1047
|
y,
|
|
@@ -1045,7 +1081,7 @@ function useInfiniteScroll(element, onLoadMore, options = {}) {
|
|
|
1045
1081
|
vueDemi.watch(() => state.arrivedState[direction], async (v) => {
|
|
1046
1082
|
var _a2, _b2;
|
|
1047
1083
|
if (v) {
|
|
1048
|
-
const elem =
|
|
1084
|
+
const elem = shared.resolveUnref(element);
|
|
1049
1085
|
const previous = {
|
|
1050
1086
|
height: (_a2 = elem == null ? void 0 : elem.scrollHeight) != null ? _a2 : 0,
|
|
1051
1087
|
width: (_b2 = elem == null ? void 0 : elem.scrollWidth) != null ? _b2 : 0
|
|
@@ -1079,9 +1115,9 @@ function useIntersectionObserver(target, callback, options = {}) {
|
|
|
1079
1115
|
threshold = 0.1,
|
|
1080
1116
|
window = defaultWindow
|
|
1081
1117
|
} = options;
|
|
1082
|
-
const isSupported = window && "IntersectionObserver" in window;
|
|
1118
|
+
const isSupported = useSupported(() => window && "IntersectionObserver" in window);
|
|
1083
1119
|
let cleanup = shared.noop;
|
|
1084
|
-
const stopWatch = isSupported ? vueDemi.watch(() => ({
|
|
1120
|
+
const stopWatch = isSupported.value ? vueDemi.watch(() => ({
|
|
1085
1121
|
el: unrefElement(target),
|
|
1086
1122
|
root: unrefElement(root)
|
|
1087
1123
|
}), ({ el, root: root2 }) => {
|
|
@@ -1401,7 +1437,7 @@ function useCssVar(prop, target, { window = defaultWindow, initialValue = "" } =
|
|
|
1401
1437
|
var _a;
|
|
1402
1438
|
return unrefElement(target) || ((_a = window == null ? void 0 : window.document) == null ? void 0 : _a.documentElement);
|
|
1403
1439
|
});
|
|
1404
|
-
vueDemi.watch([elRef, () =>
|
|
1440
|
+
vueDemi.watch([elRef, () => shared.resolveUnref(prop)], ([el, prop2]) => {
|
|
1405
1441
|
var _a;
|
|
1406
1442
|
if (el && window) {
|
|
1407
1443
|
const value = (_a = window.getComputedStyle(el).getPropertyValue(prop2)) == null ? void 0 : _a.trim();
|
|
@@ -1411,7 +1447,7 @@ function useCssVar(prop, target, { window = defaultWindow, initialValue = "" } =
|
|
|
1411
1447
|
vueDemi.watch(variable, (val) => {
|
|
1412
1448
|
var _a;
|
|
1413
1449
|
if ((_a = elRef.value) == null ? void 0 : _a.style)
|
|
1414
|
-
elRef.value.style.setProperty(
|
|
1450
|
+
elRef.value.style.setProperty(shared.resolveUnref(prop), val);
|
|
1415
1451
|
});
|
|
1416
1452
|
return variable;
|
|
1417
1453
|
}
|
|
@@ -1550,7 +1586,7 @@ function useScrollLock(element, initialState = false) {
|
|
|
1550
1586
|
const isLocked = vueDemi.ref(initialState);
|
|
1551
1587
|
let stopTouchMoveListener = null;
|
|
1552
1588
|
let initialOverflow;
|
|
1553
|
-
vueDemi.watch(
|
|
1589
|
+
vueDemi.watch(shared.resolveRef(element), (el) => {
|
|
1554
1590
|
if (el) {
|
|
1555
1591
|
const ele = el;
|
|
1556
1592
|
initialOverflow = ele.style.overflow;
|
|
@@ -1561,7 +1597,7 @@ function useScrollLock(element, initialState = false) {
|
|
|
1561
1597
|
immediate: true
|
|
1562
1598
|
});
|
|
1563
1599
|
const lock = () => {
|
|
1564
|
-
const ele =
|
|
1600
|
+
const ele = shared.resolveUnref(element);
|
|
1565
1601
|
if (!ele || isLocked.value)
|
|
1566
1602
|
return;
|
|
1567
1603
|
if (shared.isIOS) {
|
|
@@ -1571,7 +1607,7 @@ function useScrollLock(element, initialState = false) {
|
|
|
1571
1607
|
isLocked.value = true;
|
|
1572
1608
|
};
|
|
1573
1609
|
const unlock = () => {
|
|
1574
|
-
const ele =
|
|
1610
|
+
const ele = shared.resolveUnref(element);
|
|
1575
1611
|
if (!ele || !isLocked.value)
|
|
1576
1612
|
return;
|
|
1577
1613
|
shared.isIOS && (stopTouchMoveListener == null ? void 0 : stopTouchMoveListener());
|
|
@@ -1629,8 +1665,7 @@ const UseTimeAgo = vueDemi.defineComponent({
|
|
|
1629
1665
|
name: "UseTimeAgo",
|
|
1630
1666
|
props: ["time", "updateInterval", "max", "fullDateFormatter", "messages"],
|
|
1631
1667
|
setup(props, { slots }) {
|
|
1632
|
-
const
|
|
1633
|
-
const data = vueDemi.reactive(core.useTimeAgo(time, __spreadProps$1(__spreadValues$2({}, props), { controls: true })));
|
|
1668
|
+
const data = vueDemi.reactive(core.useTimeAgo(() => props.time, __spreadProps$1(__spreadValues$2({}, props), { controls: true })));
|
|
1634
1669
|
return () => {
|
|
1635
1670
|
if (slots.default)
|
|
1636
1671
|
return slots.default(data);
|
package/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as vue_demi from 'vue-demi';
|
|
2
2
|
import { FunctionDirective, ObjectDirective, ComponentPublicInstance, Ref, UnwrapNestedRefs, ComputedRef } from 'vue-demi';
|
|
3
|
-
import { MaybeRef, ConfigurableEventFilter, ConfigurableFlush } from '@vueuse/shared';
|
|
4
|
-
import { UseDarkOptions, UseDevicesListOptions, UseDraggableOptions, ElementSize as ElementSize$1,
|
|
3
|
+
import { MaybeComputedRef, MaybeRef, ConfigurableEventFilter, ConfigurableFlush } from '@vueuse/shared';
|
|
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 {
|
|
7
7
|
window?: Window;
|
|
@@ -21,18 +21,19 @@ declare const OnClickOutside: vue_demi.DefineComponent<RenderableComponent, {},
|
|
|
21
21
|
declare const vOnClickOutside: FunctionDirective<any, <E = PointerEvent>(evt: E) => void>;
|
|
22
22
|
|
|
23
23
|
declare type KeyStrokeEventName = 'keydown' | 'keypress' | 'keyup';
|
|
24
|
-
interface
|
|
24
|
+
interface OnKeyStrokeOptions {
|
|
25
25
|
eventName?: KeyStrokeEventName;
|
|
26
|
-
target?:
|
|
26
|
+
target?: MaybeComputedRef<EventTarget>;
|
|
27
27
|
passive?: boolean;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
declare type BindingValueFunction$7 = (event: KeyboardEvent) => void;
|
|
31
|
-
declare type BindingValueArray$6 = [BindingValueFunction$7,
|
|
31
|
+
declare type BindingValueArray$6 = [BindingValueFunction$7, OnKeyStrokeOptions];
|
|
32
32
|
declare const vOnKeyStroke: ObjectDirective<HTMLElement, BindingValueFunction$7 | BindingValueArray$6>;
|
|
33
33
|
|
|
34
34
|
declare type VueInstance = ComponentPublicInstance;
|
|
35
35
|
declare type MaybeElementRef<T extends MaybeElement = MaybeElement> = MaybeRef<T>;
|
|
36
|
+
declare type MaybeComputedElementRef<T extends MaybeElement = MaybeElement> = MaybeComputedRef<T>;
|
|
36
37
|
declare type MaybeElement = HTMLElement | SVGElement | VueInstance | undefined | null;
|
|
37
38
|
|
|
38
39
|
interface OnLongPressOptions {
|
|
@@ -86,7 +87,7 @@ interface Serializer<T> {
|
|
|
86
87
|
read(raw: string): T;
|
|
87
88
|
write(value: T): string;
|
|
88
89
|
}
|
|
89
|
-
interface
|
|
90
|
+
interface UseStorageOptions<T> extends ConfigurableEventFilter, ConfigurableWindow, ConfigurableFlush {
|
|
90
91
|
/**
|
|
91
92
|
* Watch for deep changes
|
|
92
93
|
*
|
|
@@ -105,6 +106,15 @@ interface StorageOptions<T> extends ConfigurableEventFilter, ConfigurableWindow,
|
|
|
105
106
|
* @default true
|
|
106
107
|
*/
|
|
107
108
|
writeDefaults?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Merge the default value with the value read from the storage.
|
|
111
|
+
*
|
|
112
|
+
* When setting it to true, it will perform a **shallow merge** for objects.
|
|
113
|
+
* You can pass a function to perform custom merge (e.g. deep merge), for example:
|
|
114
|
+
*
|
|
115
|
+
* @default false
|
|
116
|
+
*/
|
|
117
|
+
mergeDefaults?: boolean | ((storageValue: T, defaults: T) => T);
|
|
108
118
|
/**
|
|
109
119
|
* Custom data serialization
|
|
110
120
|
*/
|
|
@@ -124,7 +134,7 @@ interface StorageOptions<T> extends ConfigurableEventFilter, ConfigurableWindow,
|
|
|
124
134
|
}
|
|
125
135
|
|
|
126
136
|
declare type BasicColorSchema = 'light' | 'dark' | 'auto';
|
|
127
|
-
interface UseColorModeOptions<T extends string = BasicColorSchema> extends
|
|
137
|
+
interface UseColorModeOptions<T extends string = BasicColorSchema> extends UseStorageOptions<T | BasicColorSchema> {
|
|
128
138
|
/**
|
|
129
139
|
* CSS Selector for the target element applying to
|
|
130
140
|
*
|
|
@@ -137,6 +147,12 @@ interface UseColorModeOptions<T extends string = BasicColorSchema> extends Stora
|
|
|
137
147
|
* @default 'class'
|
|
138
148
|
*/
|
|
139
149
|
attribute?: string;
|
|
150
|
+
/**
|
|
151
|
+
* The initial color mode
|
|
152
|
+
*
|
|
153
|
+
* @default 'auto'
|
|
154
|
+
*/
|
|
155
|
+
initialValue?: T | BasicColorSchema;
|
|
140
156
|
/**
|
|
141
157
|
* Prefix when adding value to the attribute
|
|
142
158
|
*/
|
|
@@ -215,7 +231,7 @@ interface UseDraggableProps extends UseDraggableOptions, RenderableComponent {
|
|
|
215
231
|
}
|
|
216
232
|
declare const UseDraggable: vue_demi.DefineComponent<UseDraggableProps, {}, {}, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, vue_demi.EmitsOptions, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<UseDraggableProps>, {}>;
|
|
217
233
|
|
|
218
|
-
interface
|
|
234
|
+
interface UseResizeObserverOptions extends ConfigurableWindow {
|
|
219
235
|
/**
|
|
220
236
|
* Sets which box model the observer will observe changes to. Possible values
|
|
221
237
|
* are `content-box` (the default), and `border-box`.
|
|
@@ -225,12 +241,12 @@ interface ResizeObserverOptions extends ConfigurableWindow {
|
|
|
225
241
|
box?: 'content-box' | 'border-box';
|
|
226
242
|
}
|
|
227
243
|
|
|
228
|
-
declare const UseElementBounding: vue_demi.DefineComponent<
|
|
244
|
+
declare const UseElementBounding: vue_demi.DefineComponent<UseResizeObserverOptions & RenderableComponent, {}, {}, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, vue_demi.EmitsOptions, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<UseResizeObserverOptions & RenderableComponent>, {}>;
|
|
229
245
|
|
|
230
246
|
declare type BindingValueFunction$5 = (state: boolean) => void;
|
|
231
247
|
declare const vElementHover: ObjectDirective<HTMLElement, BindingValueFunction$5>;
|
|
232
248
|
|
|
233
|
-
declare const UseElementSize: vue_demi.DefineComponent<ElementSize$1 &
|
|
249
|
+
declare const UseElementSize: vue_demi.DefineComponent<ElementSize$1 & UseResizeObserverOptions & RenderableComponent, {}, {}, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, vue_demi.EmitsOptions, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<ElementSize$1 & UseResizeObserverOptions & RenderableComponent>, {}>;
|
|
234
250
|
|
|
235
251
|
interface ElementSize {
|
|
236
252
|
width: number;
|
|
@@ -244,7 +260,7 @@ interface ElementSize {
|
|
|
244
260
|
* @param callback
|
|
245
261
|
* @param options
|
|
246
262
|
*/
|
|
247
|
-
declare function useElementSize(target:
|
|
263
|
+
declare function useElementSize(target: MaybeComputedElementRef, initialSize?: ElementSize, options?: UseResizeObserverOptions): {
|
|
248
264
|
width: vue_demi.Ref<number>;
|
|
249
265
|
height: vue_demi.Ref<number>;
|
|
250
266
|
};
|
|
@@ -257,12 +273,12 @@ declare const vElementSize: ObjectDirective<HTMLElement, BindingValueFunction$4
|
|
|
257
273
|
|
|
258
274
|
declare const UseElementVisibility: vue_demi.DefineComponent<RenderableComponent, {}, {}, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, vue_demi.EmitsOptions, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<RenderableComponent>, {}>;
|
|
259
275
|
|
|
260
|
-
interface
|
|
261
|
-
scrollTarget?:
|
|
276
|
+
interface UseElementVisibilityOptions extends ConfigurableWindow {
|
|
277
|
+
scrollTarget?: MaybeComputedRef<HTMLElement | undefined | null>;
|
|
262
278
|
}
|
|
263
279
|
|
|
264
280
|
declare type BindingValueFunction$3 = (state: boolean) => void;
|
|
265
|
-
declare type BindingValueArray$3 = [BindingValueFunction$3,
|
|
281
|
+
declare type BindingValueArray$3 = [BindingValueFunction$3, UseElementVisibilityOptions];
|
|
266
282
|
declare const vElementVisibility: ObjectDirective<HTMLElement, BindingValueFunction$3 | BindingValueArray$3>;
|
|
267
283
|
|
|
268
284
|
declare const UseEyeDropper: vue_demi.DefineComponent<{
|
|
@@ -275,11 +291,11 @@ declare const UseEyeDropper: vue_demi.DefineComponent<{
|
|
|
275
291
|
|
|
276
292
|
declare const UseFullscreen: vue_demi.DefineComponent<RenderableComponent, {}, {}, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, vue_demi.EmitsOptions, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<RenderableComponent>, {}>;
|
|
277
293
|
|
|
278
|
-
declare const UseGeolocation: vue_demi.DefineComponent<
|
|
294
|
+
declare const UseGeolocation: vue_demi.DefineComponent<UseGeolocationOptions, {}, {}, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, vue_demi.EmitsOptions, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<UseGeolocationOptions>, {}>;
|
|
279
295
|
|
|
280
|
-
declare const UseIdle: vue_demi.DefineComponent<
|
|
296
|
+
declare const UseIdle: vue_demi.DefineComponent<UseIdleOptions & {
|
|
281
297
|
timeout: number;
|
|
282
|
-
}, {}, {}, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, vue_demi.EmitsOptions, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<
|
|
298
|
+
}, {}, {}, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, vue_demi.EmitsOptions, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<UseIdleOptions & {
|
|
283
299
|
timeout: number;
|
|
284
300
|
}>, {}>;
|
|
285
301
|
|
|
@@ -342,7 +358,7 @@ interface UseScrollOptions {
|
|
|
342
358
|
* @param element
|
|
343
359
|
* @param options
|
|
344
360
|
*/
|
|
345
|
-
declare function useScroll(element:
|
|
361
|
+
declare function useScroll(element: MaybeComputedRef<HTMLElement | SVGElement | Window | Document | null | undefined>, options?: UseScrollOptions): {
|
|
346
362
|
x: vue_demi.Ref<number>;
|
|
347
363
|
y: vue_demi.Ref<number>;
|
|
348
364
|
isScrolling: vue_demi.Ref<boolean>;
|
|
@@ -386,13 +402,13 @@ interface UseInfiniteScrollOptions extends UseScrollOptions {
|
|
|
386
402
|
*
|
|
387
403
|
* @see https://vueuse.org/useInfiniteScroll
|
|
388
404
|
*/
|
|
389
|
-
declare function useInfiniteScroll(element:
|
|
405
|
+
declare function useInfiniteScroll(element: MaybeComputedRef<HTMLElement | SVGElement | Window | Document | null | undefined>, onLoadMore: (state: UnwrapNestedRefs<ReturnType<typeof useScroll>>) => void | Promise<void>, options?: UseInfiniteScrollOptions): void;
|
|
390
406
|
|
|
391
407
|
declare type BindingValueFunction$2 = Parameters<typeof useInfiniteScroll>[1];
|
|
392
408
|
declare type BindingValueArray$2 = [BindingValueFunction$2, UseInfiniteScrollOptions];
|
|
393
409
|
declare const vInfiniteScroll: ObjectDirective<HTMLElement, BindingValueFunction$2 | BindingValueArray$2>;
|
|
394
410
|
|
|
395
|
-
interface
|
|
411
|
+
interface UseIntersectionObserverOptions extends ConfigurableWindow {
|
|
396
412
|
/**
|
|
397
413
|
* The Element or Document whose bounds are used as the bounding box when testing for intersection.
|
|
398
414
|
*/
|
|
@@ -408,10 +424,10 @@ interface IntersectionObserverOptions extends ConfigurableWindow {
|
|
|
408
424
|
}
|
|
409
425
|
|
|
410
426
|
declare type BindingValueFunction$1 = IntersectionObserverCallback;
|
|
411
|
-
declare type BindingValueArray$1 = [BindingValueFunction$1,
|
|
427
|
+
declare type BindingValueArray$1 = [BindingValueFunction$1, UseIntersectionObserverOptions];
|
|
412
428
|
declare const vIntersectionObserver: ObjectDirective<HTMLElement, BindingValueFunction$1 | BindingValueArray$1>;
|
|
413
429
|
|
|
414
|
-
declare const UseMouse: vue_demi.DefineComponent<
|
|
430
|
+
declare const UseMouse: vue_demi.DefineComponent<UseMouseOptions, {}, {}, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, vue_demi.EmitsOptions, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<UseMouseOptions>, {}>;
|
|
415
431
|
|
|
416
432
|
declare const UseMouseInElement: vue_demi.DefineComponent<MouseInElementOptions & RenderableComponent, {}, {}, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, vue_demi.EmitsOptions, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<MouseInElementOptions & RenderableComponent>, {}>;
|
|
417
433
|
|
|
@@ -524,7 +540,7 @@ interface UseTimeAgoComponentOptions extends Omit<UseTimeAgoOptions<true>, 'cont
|
|
|
524
540
|
}
|
|
525
541
|
declare const UseTimeAgo: vue_demi.DefineComponent<UseTimeAgoComponentOptions, {}, {}, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, vue_demi.EmitsOptions, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<UseTimeAgoComponentOptions>, {}>;
|
|
526
542
|
|
|
527
|
-
declare const UseTimestamp: vue_demi.DefineComponent<Omit<
|
|
543
|
+
declare const UseTimestamp: vue_demi.DefineComponent<Omit<UseTimestampOptions<true>, "controls">, {}, {}, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, vue_demi.EmitsOptions, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<Omit<UseTimestampOptions<true>, "controls">>, {}>;
|
|
528
544
|
|
|
529
545
|
interface UseVirtualListProps {
|
|
530
546
|
/**
|
|
@@ -552,6 +568,6 @@ declare const UseWindowFocus: vue_demi.DefineComponent<{}, () => vue_demi.VNode<
|
|
|
552
568
|
[key: string]: any;
|
|
553
569
|
}>[] | undefined, {}, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, vue_demi.EmitsOptions, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<vue_demi.ExtractPropTypes<{}>>, {}>;
|
|
554
570
|
|
|
555
|
-
declare const UseWindowSize: vue_demi.DefineComponent<
|
|
571
|
+
declare const UseWindowSize: vue_demi.DefineComponent<UseWindowSizeOptions, {}, {}, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, vue_demi.EmitsOptions, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<UseWindowSizeOptions>, {}>;
|
|
556
572
|
|
|
557
573
|
export { OnClickOutside, OnLongPress, OnLongPressProps, UseActiveElement, UseBattery, UseBrowserLocation, UseColorMode, UseDark, UseDeviceMotion, UseDeviceOrientation, UseDevicePixelRatio, UseDevicesList, UseDocumentVisibility, UseDraggable, UseDraggableProps, UseElementBounding, UseElementSize, UseElementVisibility, UseEyeDropper, UseFullscreen, UseGeolocation, UseIdle, UseImage, UseMouse, UseMouseInElement, UseMousePressed, UseNetwork, UseNow, UseObjectUrl, UseObjectUrlProps, UseOffsetPagination, UseOnline, UsePageLeave, UsePointer, UsePreferredColorScheme, UsePreferredDark, UsePreferredLanguages, UseScreenSafeArea, UseTimeAgo, UseTimestamp, UseVirtualList, UseVirtualListProps, UseWindowFocus, UseWindowSize, vOnClickOutside as VOnClickOutside, vOnLongPress as VOnLongPress, vElementHover, vElementSize, vElementVisibility, vInfiniteScroll, vIntersectionObserver, vOnClickOutside, vOnKeyStroke, vOnLongPress, vScroll, vScrollLock };
|