@vueuse/components 12.4.0 → 12.6.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 +125 -121
- package/index.d.cts +17 -4
- package/index.d.mts +17 -4
- package/index.d.ts +17 -4
- package/index.iife.js +125 -121
- package/index.iife.min.js +1 -1
- package/index.mjs +127 -123
- package/package.json +3 -3
package/index.cjs
CHANGED
|
@@ -20,70 +20,73 @@ const OnClickOutside = /* @__PURE__ */ /* #__PURE__ */ vue.defineComponent({
|
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
const defaultWindow = shared.isClient ? window :
|
|
23
|
+
const defaultWindow = shared.isClient ? window : void 0;
|
|
24
24
|
|
|
25
25
|
function unrefElement(elRef) {
|
|
26
26
|
var _a;
|
|
27
27
|
const plain = vue.toValue(elRef);
|
|
28
|
-
return (_a = plain == null ?
|
|
28
|
+
return (_a = plain == null ? void 0 : plain.$el) != null ? _a : plain;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
function useEventListener(...args) {
|
|
32
|
-
let target;
|
|
33
|
-
let events;
|
|
34
|
-
let listeners;
|
|
35
|
-
let options;
|
|
36
|
-
if (typeof args[0] === "string" || Array.isArray(args[0])) {
|
|
37
|
-
[events, listeners, options] = args;
|
|
38
|
-
target = defaultWindow;
|
|
39
|
-
} else {
|
|
40
|
-
[target, events, listeners, options] = args;
|
|
41
|
-
}
|
|
42
|
-
if (!target)
|
|
43
|
-
return shared.noop;
|
|
44
|
-
events = shared.toArray(events);
|
|
45
|
-
listeners = shared.toArray(listeners);
|
|
46
32
|
const cleanups = [];
|
|
47
33
|
const cleanup = () => {
|
|
48
34
|
cleanups.forEach((fn) => fn());
|
|
49
35
|
cleanups.length = 0;
|
|
50
36
|
};
|
|
51
|
-
const register = (el, event, listener,
|
|
52
|
-
el.addEventListener(event, listener,
|
|
53
|
-
return () => el.removeEventListener(event, listener,
|
|
37
|
+
const register = (el, event, listener, options) => {
|
|
38
|
+
el.addEventListener(event, listener, options);
|
|
39
|
+
return () => el.removeEventListener(event, listener, options);
|
|
54
40
|
};
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
(
|
|
41
|
+
const firstParamTargets = vue.computed(() => {
|
|
42
|
+
const test = shared.toArray(vue.toValue(args[0])).filter((e) => e != null);
|
|
43
|
+
return test.every((e) => typeof e !== "string") ? test : void 0;
|
|
44
|
+
});
|
|
45
|
+
const stopWatch = shared.watchImmediate(
|
|
46
|
+
() => {
|
|
47
|
+
var _a, _b;
|
|
48
|
+
return [
|
|
49
|
+
(_b = (_a = firstParamTargets.value) == null ? void 0 : _a.map((e) => unrefElement(e))) != null ? _b : [defaultWindow].filter((e) => e != null),
|
|
50
|
+
shared.toArray(vue.toValue(firstParamTargets.value ? args[1] : args[0])),
|
|
51
|
+
shared.toArray(vue.unref(firstParamTargets.value ? args[2] : args[1])),
|
|
52
|
+
// @ts-expect-error - TypeScript gets the correct types, but somehow still complains
|
|
53
|
+
vue.toValue(firstParamTargets.value ? args[3] : args[2])
|
|
54
|
+
];
|
|
55
|
+
},
|
|
56
|
+
([raw_targets, raw_events, raw_listeners, raw_options]) => {
|
|
58
57
|
cleanup();
|
|
59
|
-
if (!
|
|
58
|
+
if (!(raw_targets == null ? void 0 : raw_targets.length) || !(raw_events == null ? void 0 : raw_events.length) || !(raw_listeners == null ? void 0 : raw_listeners.length))
|
|
60
59
|
return;
|
|
61
|
-
const optionsClone = shared.isObject(
|
|
60
|
+
const optionsClone = shared.isObject(raw_options) ? { ...raw_options } : raw_options;
|
|
62
61
|
cleanups.push(
|
|
63
|
-
...
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
...raw_targets.flatMap(
|
|
63
|
+
(el) => raw_events.flatMap(
|
|
64
|
+
(event) => raw_listeners.map((listener) => register(el, event, listener, optionsClone))
|
|
65
|
+
)
|
|
66
|
+
)
|
|
66
67
|
);
|
|
67
68
|
},
|
|
68
|
-
{
|
|
69
|
+
{ flush: "post" }
|
|
69
70
|
);
|
|
70
71
|
const stop = () => {
|
|
71
72
|
stopWatch();
|
|
72
73
|
cleanup();
|
|
73
74
|
};
|
|
74
|
-
shared.tryOnScopeDispose(
|
|
75
|
+
shared.tryOnScopeDispose(cleanup);
|
|
75
76
|
return stop;
|
|
76
77
|
}
|
|
77
78
|
|
|
78
79
|
let _iOSWorkaround = false;
|
|
79
80
|
function onClickOutside(target, handler, options = {}) {
|
|
80
|
-
const { window = defaultWindow, ignore = [], capture = true, detectIframe = false } = options;
|
|
81
|
-
if (!window)
|
|
82
|
-
return shared.noop;
|
|
81
|
+
const { window = defaultWindow, ignore = [], capture = true, detectIframe = false, controls = false } = options;
|
|
82
|
+
if (!window) {
|
|
83
|
+
return controls ? { stop: shared.noop, cancel: shared.noop, trigger: shared.noop } : shared.noop;
|
|
84
|
+
}
|
|
83
85
|
if (shared.isIOS && !_iOSWorkaround) {
|
|
84
86
|
_iOSWorkaround = true;
|
|
85
|
-
|
|
86
|
-
window.document.
|
|
87
|
+
const listenerOptions = { passive: true };
|
|
88
|
+
Array.from(window.document.body.children).forEach((el) => useEventListener(el, "click", shared.noop, listenerOptions));
|
|
89
|
+
useEventListener(window.document.documentElement, "click", shared.noop, listenerOptions);
|
|
87
90
|
}
|
|
88
91
|
let shouldListen = true;
|
|
89
92
|
const shouldIgnore = (event) => {
|
|
@@ -115,7 +118,7 @@ function onClickOutside(target, handler, options = {}) {
|
|
|
115
118
|
return;
|
|
116
119
|
if (!el || el === event.target || event.composedPath().includes(el))
|
|
117
120
|
return;
|
|
118
|
-
if (event.detail === 0)
|
|
121
|
+
if ("detail" in event && event.detail === 0)
|
|
119
122
|
shouldListen = !shouldIgnore(event);
|
|
120
123
|
if (!shouldListen) {
|
|
121
124
|
shouldListen = true;
|
|
@@ -142,13 +145,26 @@ function onClickOutside(target, handler, options = {}) {
|
|
|
142
145
|
setTimeout(() => {
|
|
143
146
|
var _a;
|
|
144
147
|
const el = unrefElement(target);
|
|
145
|
-
if (((_a = window.document.activeElement) == null ?
|
|
148
|
+
if (((_a = window.document.activeElement) == null ? void 0 : _a.tagName) === "IFRAME" && !(el == null ? void 0 : el.contains(window.document.activeElement))) {
|
|
146
149
|
handler(event);
|
|
147
150
|
}
|
|
148
151
|
}, 0);
|
|
149
152
|
}, { passive: true })
|
|
150
153
|
].filter(Boolean);
|
|
151
154
|
const stop = () => cleanup.forEach((fn) => fn());
|
|
155
|
+
if (controls) {
|
|
156
|
+
return {
|
|
157
|
+
stop,
|
|
158
|
+
cancel: () => {
|
|
159
|
+
shouldListen = false;
|
|
160
|
+
},
|
|
161
|
+
trigger: (event) => {
|
|
162
|
+
shouldListen = true;
|
|
163
|
+
listener(event);
|
|
164
|
+
shouldListen = false;
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
}
|
|
152
168
|
return stop;
|
|
153
169
|
}
|
|
154
170
|
|
|
@@ -216,7 +232,7 @@ function onKeyStroke(...args) {
|
|
|
216
232
|
const vOnKeyStroke = {
|
|
217
233
|
mounted(el, binding) {
|
|
218
234
|
var _a, _b;
|
|
219
|
-
const keys = (_b = (_a = binding.arg) == null ?
|
|
235
|
+
const keys = (_b = (_a = binding.arg) == null ? void 0 : _a.split(",")) != null ? _b : true;
|
|
220
236
|
if (typeof binding.value === "function") {
|
|
221
237
|
onKeyStroke(keys, binding.value, {
|
|
222
238
|
target: el
|
|
@@ -243,23 +259,23 @@ function onLongPress(target, handler, options) {
|
|
|
243
259
|
function clear() {
|
|
244
260
|
if (timeout) {
|
|
245
261
|
clearTimeout(timeout);
|
|
246
|
-
timeout =
|
|
262
|
+
timeout = void 0;
|
|
247
263
|
}
|
|
248
|
-
posStart =
|
|
249
|
-
startTimestamp =
|
|
264
|
+
posStart = void 0;
|
|
265
|
+
startTimestamp = void 0;
|
|
250
266
|
hasLongPressed = false;
|
|
251
267
|
}
|
|
252
268
|
function onRelease(ev) {
|
|
253
269
|
var _a2, _b2, _c;
|
|
254
270
|
const [_startTimestamp, _posStart, _hasLongPressed] = [startTimestamp, posStart, hasLongPressed];
|
|
255
271
|
clear();
|
|
256
|
-
if (!(options == null ?
|
|
272
|
+
if (!(options == null ? void 0 : options.onMouseUp) || !_posStart || !_startTimestamp)
|
|
257
273
|
return;
|
|
258
|
-
if (((_a2 = options == null ?
|
|
274
|
+
if (((_a2 = options == null ? void 0 : options.modifiers) == null ? void 0 : _a2.self) && ev.target !== elementRef.value)
|
|
259
275
|
return;
|
|
260
|
-
if ((_b2 = options == null ?
|
|
276
|
+
if ((_b2 = options == null ? void 0 : options.modifiers) == null ? void 0 : _b2.prevent)
|
|
261
277
|
ev.preventDefault();
|
|
262
|
-
if ((_c = options == null ?
|
|
278
|
+
if ((_c = options == null ? void 0 : options.modifiers) == null ? void 0 : _c.stop)
|
|
263
279
|
ev.stopPropagation();
|
|
264
280
|
const dx = ev.x - _posStart.x;
|
|
265
281
|
const dy = ev.y - _posStart.y;
|
|
@@ -268,12 +284,12 @@ function onLongPress(target, handler, options) {
|
|
|
268
284
|
}
|
|
269
285
|
function onDown(ev) {
|
|
270
286
|
var _a2, _b2, _c, _d;
|
|
271
|
-
if (((_a2 = options == null ?
|
|
287
|
+
if (((_a2 = options == null ? void 0 : options.modifiers) == null ? void 0 : _a2.self) && ev.target !== elementRef.value)
|
|
272
288
|
return;
|
|
273
289
|
clear();
|
|
274
|
-
if ((_b2 = options == null ?
|
|
290
|
+
if ((_b2 = options == null ? void 0 : options.modifiers) == null ? void 0 : _b2.prevent)
|
|
275
291
|
ev.preventDefault();
|
|
276
|
-
if ((_c = options == null ?
|
|
292
|
+
if ((_c = options == null ? void 0 : options.modifiers) == null ? void 0 : _c.stop)
|
|
277
293
|
ev.stopPropagation();
|
|
278
294
|
posStart = {
|
|
279
295
|
x: ev.x,
|
|
@@ -285,28 +301,28 @@ function onLongPress(target, handler, options) {
|
|
|
285
301
|
hasLongPressed = true;
|
|
286
302
|
handler(ev);
|
|
287
303
|
},
|
|
288
|
-
(_d = options == null ?
|
|
304
|
+
(_d = options == null ? void 0 : options.delay) != null ? _d : DEFAULT_DELAY
|
|
289
305
|
);
|
|
290
306
|
}
|
|
291
307
|
function onMove(ev) {
|
|
292
308
|
var _a2, _b2, _c, _d;
|
|
293
|
-
if (((_a2 = options == null ?
|
|
309
|
+
if (((_a2 = options == null ? void 0 : options.modifiers) == null ? void 0 : _a2.self) && ev.target !== elementRef.value)
|
|
294
310
|
return;
|
|
295
|
-
if (!posStart || (options == null ?
|
|
311
|
+
if (!posStart || (options == null ? void 0 : options.distanceThreshold) === false)
|
|
296
312
|
return;
|
|
297
|
-
if ((_b2 = options == null ?
|
|
313
|
+
if ((_b2 = options == null ? void 0 : options.modifiers) == null ? void 0 : _b2.prevent)
|
|
298
314
|
ev.preventDefault();
|
|
299
|
-
if ((_c = options == null ?
|
|
315
|
+
if ((_c = options == null ? void 0 : options.modifiers) == null ? void 0 : _c.stop)
|
|
300
316
|
ev.stopPropagation();
|
|
301
317
|
const dx = ev.x - posStart.x;
|
|
302
318
|
const dy = ev.y - posStart.y;
|
|
303
319
|
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
304
|
-
if (distance >= ((_d = options == null ?
|
|
320
|
+
if (distance >= ((_d = options == null ? void 0 : options.distanceThreshold) != null ? _d : DEFAULT_THRESHOLD))
|
|
305
321
|
clear();
|
|
306
322
|
}
|
|
307
323
|
const listenerOptions = {
|
|
308
|
-
capture: (_a = options == null ?
|
|
309
|
-
once: (_b = options == null ?
|
|
324
|
+
capture: (_a = options == null ? void 0 : options.modifiers) == null ? void 0 : _a.capture,
|
|
325
|
+
once: (_b = options == null ? void 0 : options.modifiers) == null ? void 0 : _b.once
|
|
310
326
|
};
|
|
311
327
|
const cleanup = [
|
|
312
328
|
useEventListener(elementRef, "pointerdown", onDown, listenerOptions),
|
|
@@ -394,7 +410,7 @@ const UseClipboard = /* @__PURE__ */ /* #__PURE__ */ vue.defineComponent({
|
|
|
394
410
|
const data = vue.reactive(core.useClipboard(props));
|
|
395
411
|
return () => {
|
|
396
412
|
var _a;
|
|
397
|
-
return (_a = slots.default) == null ?
|
|
413
|
+
return (_a = slots.default) == null ? void 0 : _a.call(slots, data);
|
|
398
414
|
};
|
|
399
415
|
}
|
|
400
416
|
});
|
|
@@ -414,7 +430,7 @@ function getSSRHandler(key, fallback) {
|
|
|
414
430
|
const ssrWidthSymbol = Symbol("vueuse-ssr-width");
|
|
415
431
|
function useSSRWidth() {
|
|
416
432
|
const ssrWidth = vue.hasInjectionContext() ? shared.injectLocal(ssrWidthSymbol, null) : null;
|
|
417
|
-
return typeof ssrWidth === "number" ? ssrWidth :
|
|
433
|
+
return typeof ssrWidth === "number" ? ssrWidth : void 0;
|
|
418
434
|
}
|
|
419
435
|
|
|
420
436
|
function useMounted() {
|
|
@@ -440,20 +456,12 @@ function useMediaQuery(query, options = {}) {
|
|
|
440
456
|
const { window = defaultWindow, ssrWidth = useSSRWidth() } = options;
|
|
441
457
|
const isSupported = useSupported(() => window && "matchMedia" in window && typeof window.matchMedia === "function");
|
|
442
458
|
const ssrSupport = vue.ref(typeof ssrWidth === "number");
|
|
443
|
-
|
|
459
|
+
const mediaQuery = vue.shallowRef();
|
|
444
460
|
const matches = vue.ref(false);
|
|
445
461
|
const handler = (event) => {
|
|
446
462
|
matches.value = event.matches;
|
|
447
463
|
};
|
|
448
|
-
|
|
449
|
-
if (!mediaQuery)
|
|
450
|
-
return;
|
|
451
|
-
if ("removeEventListener" in mediaQuery)
|
|
452
|
-
mediaQuery.removeEventListener("change", handler);
|
|
453
|
-
else
|
|
454
|
-
mediaQuery.removeListener(handler);
|
|
455
|
-
};
|
|
456
|
-
const stopWatch = vue.watchEffect(() => {
|
|
464
|
+
vue.watchEffect(() => {
|
|
457
465
|
if (ssrSupport.value) {
|
|
458
466
|
ssrSupport.value = !isSupported.value;
|
|
459
467
|
const queryStrings = vue.toValue(query).split(",");
|
|
@@ -474,19 +482,10 @@ function useMediaQuery(query, options = {}) {
|
|
|
474
482
|
}
|
|
475
483
|
if (!isSupported.value)
|
|
476
484
|
return;
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
if ("addEventListener" in mediaQuery)
|
|
480
|
-
mediaQuery.addEventListener("change", handler);
|
|
481
|
-
else
|
|
482
|
-
mediaQuery.addListener(handler);
|
|
483
|
-
matches.value = mediaQuery.matches;
|
|
484
|
-
});
|
|
485
|
-
shared.tryOnScopeDispose(() => {
|
|
486
|
-
stopWatch();
|
|
487
|
-
cleanup();
|
|
488
|
-
mediaQuery = undefined;
|
|
485
|
+
mediaQuery.value = window.matchMedia(vue.toValue(query));
|
|
486
|
+
matches.value = mediaQuery.value.matches;
|
|
489
487
|
});
|
|
488
|
+
useEventListener(mediaQuery, "change", handler, { passive: true });
|
|
490
489
|
return vue.computed(() => matches.value);
|
|
491
490
|
}
|
|
492
491
|
|
|
@@ -688,7 +687,7 @@ function useColorMode(options = {}) {
|
|
|
688
687
|
const updateHTMLAttrs = getSSRHandler(
|
|
689
688
|
"updateHTMLAttrs",
|
|
690
689
|
(selector2, attribute2, value) => {
|
|
691
|
-
const el = typeof selector2 === "string" ? window == null ?
|
|
690
|
+
const el = typeof selector2 === "string" ? window == null ? void 0 : window.document.querySelector(selector2) : unrefElement(selector2);
|
|
692
691
|
if (!el)
|
|
693
692
|
return;
|
|
694
693
|
const classesToAdd = /* @__PURE__ */ new Set();
|
|
@@ -872,18 +871,18 @@ const UseDraggable = /* @__PURE__ */ /* #__PURE__ */ vue.defineComponent({
|
|
|
872
871
|
});
|
|
873
872
|
const containerElement = vue.computed(() => {
|
|
874
873
|
var _a;
|
|
875
|
-
return (_a = props.containerElement) != null ? _a :
|
|
874
|
+
return (_a = props.containerElement) != null ? _a : void 0;
|
|
876
875
|
});
|
|
877
876
|
const disabled = vue.computed(() => !!props.disabled);
|
|
878
877
|
const storageValue = props.storageKey && core.useStorage(
|
|
879
878
|
props.storageKey,
|
|
880
879
|
vue.toValue(props.initialValue) || { x: 0, y: 0 },
|
|
881
|
-
core.isClient ? props.storageType === "session" ? sessionStorage : localStorage :
|
|
880
|
+
core.isClient ? props.storageType === "session" ? sessionStorage : localStorage : void 0
|
|
882
881
|
);
|
|
883
882
|
const initialValue = storageValue || props.initialValue || { x: 0, y: 0 };
|
|
884
883
|
const onEnd = (position, event) => {
|
|
885
884
|
var _a;
|
|
886
|
-
(_a = props.onEnd) == null ?
|
|
885
|
+
(_a = props.onEnd) == null ? void 0 : _a.call(props, position, event);
|
|
887
886
|
if (!storageValue)
|
|
888
887
|
return;
|
|
889
888
|
storageValue.value.x = position.x;
|
|
@@ -924,7 +923,7 @@ function useMutationObserver(target, callback, options = {}) {
|
|
|
924
923
|
const cleanup = () => {
|
|
925
924
|
if (observer) {
|
|
926
925
|
observer.disconnect();
|
|
927
|
-
observer =
|
|
926
|
+
observer = void 0;
|
|
928
927
|
}
|
|
929
928
|
};
|
|
930
929
|
const targets = vue.computed(() => {
|
|
@@ -944,7 +943,7 @@ function useMutationObserver(target, callback, options = {}) {
|
|
|
944
943
|
{ immediate: true, flush: "post" }
|
|
945
944
|
);
|
|
946
945
|
const takeRecords = () => {
|
|
947
|
-
return observer == null ?
|
|
946
|
+
return observer == null ? void 0 : observer.takeRecords();
|
|
948
947
|
};
|
|
949
948
|
const stop = () => {
|
|
950
949
|
stopWatch();
|
|
@@ -965,7 +964,7 @@ function useResizeObserver(target, callback, options = {}) {
|
|
|
965
964
|
const cleanup = () => {
|
|
966
965
|
if (observer) {
|
|
967
966
|
observer.disconnect();
|
|
968
|
-
observer =
|
|
967
|
+
observer = void 0;
|
|
969
968
|
}
|
|
970
969
|
};
|
|
971
970
|
const targets = vue.computed(() => {
|
|
@@ -1090,14 +1089,14 @@ const vElementBounding = {
|
|
|
1090
1089
|
function onElementRemoval(target, callback, options = {}) {
|
|
1091
1090
|
const {
|
|
1092
1091
|
window = defaultWindow,
|
|
1093
|
-
document = window == null ?
|
|
1092
|
+
document = window == null ? void 0 : window.document,
|
|
1094
1093
|
flush = "sync"
|
|
1095
1094
|
} = options;
|
|
1096
1095
|
if (!window || !document)
|
|
1097
1096
|
return shared.noop;
|
|
1098
1097
|
let stopFn;
|
|
1099
1098
|
const cleanupAndUpdate = (fn) => {
|
|
1100
|
-
stopFn == null ?
|
|
1099
|
+
stopFn == null ? void 0 : stopFn();
|
|
1101
1100
|
stopFn = fn;
|
|
1102
1101
|
};
|
|
1103
1102
|
const stopWatch = vue.watchEffect(() => {
|
|
@@ -1141,7 +1140,7 @@ function useElementHover(el, options = {}) {
|
|
|
1141
1140
|
const delay = entering ? delayEnter : delayLeave;
|
|
1142
1141
|
if (timer) {
|
|
1143
1142
|
clearTimeout(timer);
|
|
1144
|
-
timer =
|
|
1143
|
+
timer = void 0;
|
|
1145
1144
|
}
|
|
1146
1145
|
if (delay)
|
|
1147
1146
|
timer = setTimeout(() => isHovered.value = entering, delay);
|
|
@@ -1192,7 +1191,7 @@ function useElementSize(target, initialSize = { width: 0, height: 0 }, options =
|
|
|
1192
1191
|
const { window = defaultWindow, box = "content-box" } = options;
|
|
1193
1192
|
const isSVG = vue.computed(() => {
|
|
1194
1193
|
var _a, _b;
|
|
1195
|
-
return (_b = (_a = unrefElement(target)) == null ?
|
|
1194
|
+
return (_b = (_a = unrefElement(target)) == null ? void 0 : _a.namespaceURI) == null ? void 0 : _b.includes("svg");
|
|
1196
1195
|
});
|
|
1197
1196
|
const width = vue.ref(initialSize.width);
|
|
1198
1197
|
const height = vue.ref(initialSize.height);
|
|
@@ -1248,7 +1247,7 @@ function useElementSize(target, initialSize = { width: 0, height: 0 }, options =
|
|
|
1248
1247
|
const vElementSize = {
|
|
1249
1248
|
mounted(el, binding) {
|
|
1250
1249
|
var _a;
|
|
1251
|
-
const handler = typeof binding.value === "function" ? binding.value : (_a = binding.value) == null ?
|
|
1250
|
+
const handler = typeof binding.value === "function" ? binding.value : (_a = binding.value) == null ? void 0 : _a[0];
|
|
1252
1251
|
const options = typeof binding.value === "function" ? [] : binding.value.slice(1);
|
|
1253
1252
|
const { width, height } = useElementSize(el, ...options);
|
|
1254
1253
|
vue.watch([width, height], ([width2, height2]) => handler({ width: width2, height: height2 }));
|
|
@@ -1334,10 +1333,11 @@ function useElementVisibility(element, options = {}) {
|
|
|
1334
1333
|
window = defaultWindow,
|
|
1335
1334
|
scrollTarget,
|
|
1336
1335
|
threshold = 0,
|
|
1337
|
-
rootMargin
|
|
1336
|
+
rootMargin,
|
|
1337
|
+
once = false
|
|
1338
1338
|
} = options;
|
|
1339
1339
|
const elementIsVisible = vue.ref(false);
|
|
1340
|
-
useIntersectionObserver(
|
|
1340
|
+
const { stop } = useIntersectionObserver(
|
|
1341
1341
|
element,
|
|
1342
1342
|
(intersectionObserverEntries) => {
|
|
1343
1343
|
let isIntersecting = elementIsVisible.value;
|
|
@@ -1349,6 +1349,11 @@ function useElementVisibility(element, options = {}) {
|
|
|
1349
1349
|
}
|
|
1350
1350
|
}
|
|
1351
1351
|
elementIsVisible.value = isIntersecting;
|
|
1352
|
+
if (once) {
|
|
1353
|
+
shared.watchOnce(elementIsVisible, () => {
|
|
1354
|
+
stop();
|
|
1355
|
+
});
|
|
1356
|
+
}
|
|
1352
1357
|
},
|
|
1353
1358
|
{
|
|
1354
1359
|
root: scrollTarget,
|
|
@@ -1438,11 +1443,11 @@ function useAsyncState(promise, initialState, options) {
|
|
|
1438
1443
|
const state = shallow ? vue.shallowRef(initialState) : vue.ref(initialState);
|
|
1439
1444
|
const isReady = vue.ref(false);
|
|
1440
1445
|
const isLoading = vue.ref(false);
|
|
1441
|
-
const error = vue.shallowRef(
|
|
1446
|
+
const error = vue.shallowRef(void 0);
|
|
1442
1447
|
async function execute(delay2 = 0, ...args) {
|
|
1443
1448
|
if (resetOnExecute)
|
|
1444
1449
|
state.value = initialState;
|
|
1445
|
-
error.value =
|
|
1450
|
+
error.value = void 0;
|
|
1446
1451
|
isReady.value = false;
|
|
1447
1452
|
isLoading.value = true;
|
|
1448
1453
|
if (delay2 > 0)
|
|
@@ -1522,7 +1527,7 @@ async function loadImage(options) {
|
|
|
1522
1527
|
function useImage(options, asyncStateOptions = {}) {
|
|
1523
1528
|
const state = useAsyncState(
|
|
1524
1529
|
() => loadImage(vue.toValue(options)),
|
|
1525
|
-
|
|
1530
|
+
void 0,
|
|
1526
1531
|
{
|
|
1527
1532
|
resetOnExecute: true,
|
|
1528
1533
|
...asyncStateOptions
|
|
@@ -1607,7 +1612,7 @@ function useScroll(element, options = {}) {
|
|
|
1607
1612
|
return internalX.value;
|
|
1608
1613
|
},
|
|
1609
1614
|
set(x2) {
|
|
1610
|
-
scrollTo(x2,
|
|
1615
|
+
scrollTo(x2, void 0);
|
|
1611
1616
|
}
|
|
1612
1617
|
});
|
|
1613
1618
|
const y = vue.computed({
|
|
@@ -1615,7 +1620,7 @@ function useScroll(element, options = {}) {
|
|
|
1615
1620
|
return internalY.value;
|
|
1616
1621
|
},
|
|
1617
1622
|
set(y2) {
|
|
1618
|
-
scrollTo(
|
|
1623
|
+
scrollTo(void 0, y2);
|
|
1619
1624
|
}
|
|
1620
1625
|
});
|
|
1621
1626
|
function scrollTo(_x, _y) {
|
|
@@ -1625,12 +1630,12 @@ function useScroll(element, options = {}) {
|
|
|
1625
1630
|
const _element = vue.toValue(element);
|
|
1626
1631
|
if (!_element)
|
|
1627
1632
|
return;
|
|
1628
|
-
(_c = _element instanceof Document ? window.document.body : _element) == null ?
|
|
1633
|
+
(_c = _element instanceof Document ? window.document.body : _element) == null ? void 0 : _c.scrollTo({
|
|
1629
1634
|
top: (_a = vue.toValue(_y)) != null ? _a : y.value,
|
|
1630
1635
|
left: (_b = vue.toValue(_x)) != null ? _b : x.value,
|
|
1631
1636
|
behavior: vue.toValue(behavior)
|
|
1632
1637
|
});
|
|
1633
|
-
const scrollContainer = ((_d = _element == null ?
|
|
1638
|
+
const scrollContainer = ((_d = _element == null ? void 0 : _element.document) == null ? void 0 : _d.documentElement) || (_element == null ? void 0 : _element.documentElement) || _element;
|
|
1634
1639
|
if (x != null)
|
|
1635
1640
|
internalX.value = scrollContainer.scrollLeft;
|
|
1636
1641
|
if (y != null)
|
|
@@ -1664,7 +1669,7 @@ function useScroll(element, options = {}) {
|
|
|
1664
1669
|
var _a;
|
|
1665
1670
|
if (!window)
|
|
1666
1671
|
return;
|
|
1667
|
-
const el = ((_a = target == null ?
|
|
1672
|
+
const el = ((_a = target == null ? void 0 : target.document) == null ? void 0 : _a.documentElement) || (target == null ? void 0 : target.documentElement) || unrefElement(target);
|
|
1668
1673
|
const { display, flexDirection, direction } = getComputedStyle(el);
|
|
1669
1674
|
const directionMultipler = direction === "rtl" ? -1 : 1;
|
|
1670
1675
|
const scrollLeft = el.scrollLeft;
|
|
@@ -1844,7 +1849,7 @@ const UseMouseBuiltinExtractors = {
|
|
|
1844
1849
|
page: (event) => [event.pageX, event.pageY],
|
|
1845
1850
|
client: (event) => [event.clientX, event.clientY],
|
|
1846
1851
|
screen: (event) => [event.screenX, event.screenY],
|
|
1847
|
-
movement: (event) => event instanceof
|
|
1852
|
+
movement: (event) => event instanceof MouseEvent ? [event.movementX, event.movementY] : null
|
|
1848
1853
|
};
|
|
1849
1854
|
function useMouse(options = {}) {
|
|
1850
1855
|
const {
|
|
@@ -1926,7 +1931,7 @@ function useMouseInElement(target, options = {}) {
|
|
|
1926
1931
|
} = options;
|
|
1927
1932
|
const type = options.type || "page";
|
|
1928
1933
|
const { x, y, sourceType } = useMouse(options);
|
|
1929
|
-
const targetRef = vue.ref(target != null ? target : window == null ?
|
|
1934
|
+
const targetRef = vue.ref(target != null ? target : window == null ? void 0 : window.document.body);
|
|
1930
1935
|
const elementX = vue.ref(0);
|
|
1931
1936
|
const elementY = vue.ref(0);
|
|
1932
1937
|
const elementPositionX = vue.ref(0);
|
|
@@ -2064,17 +2069,17 @@ const UseOffsetPagination = /* @__PURE__ */ /* #__PURE__ */ vue.defineComponent(
|
|
|
2064
2069
|
...props,
|
|
2065
2070
|
onPageChange(...args) {
|
|
2066
2071
|
var _a;
|
|
2067
|
-
(_a = props.onPageChange) == null ?
|
|
2072
|
+
(_a = props.onPageChange) == null ? void 0 : _a.call(props, ...args);
|
|
2068
2073
|
emit("page-change", ...args);
|
|
2069
2074
|
},
|
|
2070
2075
|
onPageSizeChange(...args) {
|
|
2071
2076
|
var _a;
|
|
2072
|
-
(_a = props.onPageSizeChange) == null ?
|
|
2077
|
+
(_a = props.onPageSizeChange) == null ? void 0 : _a.call(props, ...args);
|
|
2073
2078
|
emit("page-size-change", ...args);
|
|
2074
2079
|
},
|
|
2075
2080
|
onPageCountChange(...args) {
|
|
2076
2081
|
var _a;
|
|
2077
|
-
(_a = props.onPageCountChange) == null ?
|
|
2082
|
+
(_a = props.onPageCountChange) == null ? void 0 : _a.call(props, ...args);
|
|
2078
2083
|
emit("page-count-change", ...args);
|
|
2079
2084
|
}
|
|
2080
2085
|
}));
|
|
@@ -2236,15 +2241,15 @@ function useCssVar(prop, target, options = {}) {
|
|
|
2236
2241
|
const variable = vue.ref(initialValue);
|
|
2237
2242
|
const elRef = vue.computed(() => {
|
|
2238
2243
|
var _a;
|
|
2239
|
-
return unrefElement(target) || ((_a = window == null ?
|
|
2244
|
+
return unrefElement(target) || ((_a = window == null ? void 0 : window.document) == null ? void 0 : _a.documentElement);
|
|
2240
2245
|
});
|
|
2241
2246
|
function updateCssVar() {
|
|
2242
2247
|
var _a;
|
|
2243
2248
|
const key = vue.toValue(prop);
|
|
2244
2249
|
const el = vue.toValue(elRef);
|
|
2245
2250
|
if (el && window && key) {
|
|
2246
|
-
const value = (_a = window.getComputedStyle(el).getPropertyValue(key)) == null ?
|
|
2247
|
-
variable.value = value || initialValue;
|
|
2251
|
+
const value = (_a = window.getComputedStyle(el).getPropertyValue(key)) == null ? void 0 : _a.trim();
|
|
2252
|
+
variable.value = value || variable.value || initialValue;
|
|
2248
2253
|
}
|
|
2249
2254
|
}
|
|
2250
2255
|
if (observe) {
|
|
@@ -2259,21 +2264,20 @@ function useCssVar(prop, target, options = {}) {
|
|
|
2259
2264
|
if (old[0] && old[1])
|
|
2260
2265
|
old[0].style.removeProperty(old[1]);
|
|
2261
2266
|
updateCssVar();
|
|
2262
|
-
}
|
|
2263
|
-
{ immediate: true }
|
|
2267
|
+
}
|
|
2264
2268
|
);
|
|
2265
2269
|
vue.watch(
|
|
2266
|
-
variable,
|
|
2267
|
-
(val) => {
|
|
2268
|
-
var _a;
|
|
2270
|
+
[variable, elRef],
|
|
2271
|
+
([val, el]) => {
|
|
2269
2272
|
const raw_prop = vue.toValue(prop);
|
|
2270
|
-
if ((
|
|
2273
|
+
if ((el == null ? void 0 : el.style) && raw_prop) {
|
|
2271
2274
|
if (val == null)
|
|
2272
|
-
|
|
2275
|
+
el.style.removeProperty(raw_prop);
|
|
2273
2276
|
else
|
|
2274
|
-
|
|
2277
|
+
el.style.setProperty(raw_prop, val);
|
|
2275
2278
|
}
|
|
2276
|
-
}
|
|
2279
|
+
},
|
|
2280
|
+
{ immediate: true }
|
|
2277
2281
|
);
|
|
2278
2282
|
return variable;
|
|
2279
2283
|
}
|
|
@@ -2369,12 +2373,12 @@ const vScroll = {
|
|
|
2369
2373
|
...options,
|
|
2370
2374
|
onScroll(e) {
|
|
2371
2375
|
var _a;
|
|
2372
|
-
(_a = options.onScroll) == null ?
|
|
2376
|
+
(_a = options.onScroll) == null ? void 0 : _a.call(options, e);
|
|
2373
2377
|
handler(state);
|
|
2374
2378
|
},
|
|
2375
2379
|
onStop(e) {
|
|
2376
2380
|
var _a;
|
|
2377
|
-
(_a = options.onStop) == null ?
|
|
2381
|
+
(_a = options.onStop) == null ? void 0 : _a.call(options, e);
|
|
2378
2382
|
handler(state);
|
|
2379
2383
|
}
|
|
2380
2384
|
});
|
|
@@ -2447,7 +2451,7 @@ function useScrollLock(element, initialState = false) {
|
|
|
2447
2451
|
if (!el || !isLocked.value)
|
|
2448
2452
|
return;
|
|
2449
2453
|
if (shared.isIOS)
|
|
2450
|
-
stopTouchMoveListener == null ?
|
|
2454
|
+
stopTouchMoveListener == null ? void 0 : stopTouchMoveListener();
|
|
2451
2455
|
el.style.overflow = initialOverflow;
|
|
2452
2456
|
elInitialOverflow.delete(el);
|
|
2453
2457
|
isLocked.value = false;
|
package/index.d.cts
CHANGED
|
@@ -12,7 +12,7 @@ type MaybeElementRef<T extends MaybeElement = MaybeElement> = MaybeRef<T>;
|
|
|
12
12
|
type MaybeComputedElementRef<T extends MaybeElement = MaybeElement> = MaybeRefOrGetter<T>;
|
|
13
13
|
type MaybeElement = HTMLElement | SVGElement | VueInstance | undefined | null;
|
|
14
14
|
|
|
15
|
-
interface OnClickOutsideOptions extends ConfigurableWindow {
|
|
15
|
+
interface OnClickOutsideOptions<Controls extends boolean = false> extends ConfigurableWindow {
|
|
16
16
|
/**
|
|
17
17
|
* List of elements that should not trigger the event.
|
|
18
18
|
*/
|
|
@@ -27,12 +27,19 @@ interface OnClickOutsideOptions extends ConfigurableWindow {
|
|
|
27
27
|
* @default false
|
|
28
28
|
*/
|
|
29
29
|
detectIframe?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Use controls to cancel/trigger listener.
|
|
32
|
+
* @default false
|
|
33
|
+
*/
|
|
34
|
+
controls?: Controls;
|
|
30
35
|
}
|
|
31
36
|
type OnClickOutsideHandler<T extends {
|
|
32
37
|
detectIframe: OnClickOutsideOptions['detectIframe'];
|
|
38
|
+
controls: boolean;
|
|
33
39
|
} = {
|
|
34
40
|
detectIframe: false;
|
|
35
|
-
|
|
41
|
+
controls: false;
|
|
42
|
+
}> = (event: T['controls'] extends true ? Event | (T['detectIframe'] extends true ? PointerEvent | FocusEvent : PointerEvent) : T['detectIframe'] extends true ? PointerEvent | FocusEvent : PointerEvent) => void;
|
|
36
43
|
|
|
37
44
|
interface Position {
|
|
38
45
|
x: number;
|
|
@@ -48,11 +55,11 @@ interface RenderableComponent {
|
|
|
48
55
|
}
|
|
49
56
|
|
|
50
57
|
interface OnClickOutsideProps extends RenderableComponent {
|
|
51
|
-
options?: OnClickOutsideOptions
|
|
58
|
+
options?: Omit<OnClickOutsideOptions, 'controls'>;
|
|
52
59
|
}
|
|
53
60
|
declare const OnClickOutside: vue.DefineComponent<OnClickOutsideProps, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<OnClickOutsideProps> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, false, {}, any>;
|
|
54
61
|
|
|
55
|
-
declare const vOnClickOutside: ObjectDirective<HTMLElement, OnClickOutsideHandler | [(evt: any) => void, OnClickOutsideOptions]>;
|
|
62
|
+
declare const vOnClickOutside: ObjectDirective<HTMLElement, OnClickOutsideHandler | [(evt: any) => void, Omit<OnClickOutsideOptions, 'controls'>]>;
|
|
56
63
|
|
|
57
64
|
type KeyStrokeEventName = 'keydown' | 'keypress' | 'keyup';
|
|
58
65
|
interface OnKeyStrokeOptions {
|
|
@@ -453,6 +460,12 @@ interface UseElementVisibilityOptions extends ConfigurableWindow, Pick<UseInters
|
|
|
453
460
|
* The element that is used as the viewport for checking visibility of the target.
|
|
454
461
|
*/
|
|
455
462
|
scrollTarget?: MaybeRefOrGetter<HTMLElement | undefined | null>;
|
|
463
|
+
/**
|
|
464
|
+
* Stop tracking when element visibility changes for the first time
|
|
465
|
+
*
|
|
466
|
+
* @default false
|
|
467
|
+
*/
|
|
468
|
+
once?: boolean;
|
|
456
469
|
}
|
|
457
470
|
|
|
458
471
|
type BindingValueFunction$5 = (state: boolean) => void;
|