@vueuse/components 12.5.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 +92 -73
- package/index.d.cts +17 -4
- package/index.d.mts +17 -4
- package/index.d.ts +17 -4
- package/index.iife.js +92 -73
- package/index.iife.min.js +1 -1
- package/index.mjs +93 -74
- package/package.json +3 -3
package/index.cjs
CHANGED
|
@@ -20,12 +20,12 @@ 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) {
|
|
@@ -40,13 +40,13 @@ function useEventListener(...args) {
|
|
|
40
40
|
};
|
|
41
41
|
const firstParamTargets = vue.computed(() => {
|
|
42
42
|
const test = shared.toArray(vue.toValue(args[0])).filter((e) => e != null);
|
|
43
|
-
return test.every((e) => typeof e !== "string") ? test :
|
|
43
|
+
return test.every((e) => typeof e !== "string") ? test : void 0;
|
|
44
44
|
});
|
|
45
45
|
const stopWatch = shared.watchImmediate(
|
|
46
46
|
() => {
|
|
47
47
|
var _a, _b;
|
|
48
48
|
return [
|
|
49
|
-
(_b = (_a = firstParamTargets.value) == null ?
|
|
49
|
+
(_b = (_a = firstParamTargets.value) == null ? void 0 : _a.map((e) => unrefElement(e))) != null ? _b : [defaultWindow].filter((e) => e != null),
|
|
50
50
|
shared.toArray(vue.toValue(firstParamTargets.value ? args[1] : args[0])),
|
|
51
51
|
shared.toArray(vue.unref(firstParamTargets.value ? args[2] : args[1])),
|
|
52
52
|
// @ts-expect-error - TypeScript gets the correct types, but somehow still complains
|
|
@@ -55,7 +55,7 @@ function useEventListener(...args) {
|
|
|
55
55
|
},
|
|
56
56
|
([raw_targets, raw_events, raw_listeners, raw_options]) => {
|
|
57
57
|
cleanup();
|
|
58
|
-
if (!(raw_targets == null ?
|
|
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))
|
|
59
59
|
return;
|
|
60
60
|
const optionsClone = shared.isObject(raw_options) ? { ...raw_options } : raw_options;
|
|
61
61
|
cleanups.push(
|
|
@@ -78,9 +78,10 @@ function useEventListener(...args) {
|
|
|
78
78
|
|
|
79
79
|
let _iOSWorkaround = false;
|
|
80
80
|
function onClickOutside(target, handler, options = {}) {
|
|
81
|
-
const { window = defaultWindow, ignore = [], capture = true, detectIframe = false } = options;
|
|
82
|
-
if (!window)
|
|
83
|
-
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
|
+
}
|
|
84
85
|
if (shared.isIOS && !_iOSWorkaround) {
|
|
85
86
|
_iOSWorkaround = true;
|
|
86
87
|
const listenerOptions = { passive: true };
|
|
@@ -117,7 +118,7 @@ function onClickOutside(target, handler, options = {}) {
|
|
|
117
118
|
return;
|
|
118
119
|
if (!el || el === event.target || event.composedPath().includes(el))
|
|
119
120
|
return;
|
|
120
|
-
if (event.detail === 0)
|
|
121
|
+
if ("detail" in event && event.detail === 0)
|
|
121
122
|
shouldListen = !shouldIgnore(event);
|
|
122
123
|
if (!shouldListen) {
|
|
123
124
|
shouldListen = true;
|
|
@@ -144,13 +145,26 @@ function onClickOutside(target, handler, options = {}) {
|
|
|
144
145
|
setTimeout(() => {
|
|
145
146
|
var _a;
|
|
146
147
|
const el = unrefElement(target);
|
|
147
|
-
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))) {
|
|
148
149
|
handler(event);
|
|
149
150
|
}
|
|
150
151
|
}, 0);
|
|
151
152
|
}, { passive: true })
|
|
152
153
|
].filter(Boolean);
|
|
153
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
|
+
}
|
|
154
168
|
return stop;
|
|
155
169
|
}
|
|
156
170
|
|
|
@@ -218,7 +232,7 @@ function onKeyStroke(...args) {
|
|
|
218
232
|
const vOnKeyStroke = {
|
|
219
233
|
mounted(el, binding) {
|
|
220
234
|
var _a, _b;
|
|
221
|
-
const keys = (_b = (_a = binding.arg) == null ?
|
|
235
|
+
const keys = (_b = (_a = binding.arg) == null ? void 0 : _a.split(",")) != null ? _b : true;
|
|
222
236
|
if (typeof binding.value === "function") {
|
|
223
237
|
onKeyStroke(keys, binding.value, {
|
|
224
238
|
target: el
|
|
@@ -245,23 +259,23 @@ function onLongPress(target, handler, options) {
|
|
|
245
259
|
function clear() {
|
|
246
260
|
if (timeout) {
|
|
247
261
|
clearTimeout(timeout);
|
|
248
|
-
timeout =
|
|
262
|
+
timeout = void 0;
|
|
249
263
|
}
|
|
250
|
-
posStart =
|
|
251
|
-
startTimestamp =
|
|
264
|
+
posStart = void 0;
|
|
265
|
+
startTimestamp = void 0;
|
|
252
266
|
hasLongPressed = false;
|
|
253
267
|
}
|
|
254
268
|
function onRelease(ev) {
|
|
255
269
|
var _a2, _b2, _c;
|
|
256
270
|
const [_startTimestamp, _posStart, _hasLongPressed] = [startTimestamp, posStart, hasLongPressed];
|
|
257
271
|
clear();
|
|
258
|
-
if (!(options == null ?
|
|
272
|
+
if (!(options == null ? void 0 : options.onMouseUp) || !_posStart || !_startTimestamp)
|
|
259
273
|
return;
|
|
260
|
-
if (((_a2 = options == null ?
|
|
274
|
+
if (((_a2 = options == null ? void 0 : options.modifiers) == null ? void 0 : _a2.self) && ev.target !== elementRef.value)
|
|
261
275
|
return;
|
|
262
|
-
if ((_b2 = options == null ?
|
|
276
|
+
if ((_b2 = options == null ? void 0 : options.modifiers) == null ? void 0 : _b2.prevent)
|
|
263
277
|
ev.preventDefault();
|
|
264
|
-
if ((_c = options == null ?
|
|
278
|
+
if ((_c = options == null ? void 0 : options.modifiers) == null ? void 0 : _c.stop)
|
|
265
279
|
ev.stopPropagation();
|
|
266
280
|
const dx = ev.x - _posStart.x;
|
|
267
281
|
const dy = ev.y - _posStart.y;
|
|
@@ -270,12 +284,12 @@ function onLongPress(target, handler, options) {
|
|
|
270
284
|
}
|
|
271
285
|
function onDown(ev) {
|
|
272
286
|
var _a2, _b2, _c, _d;
|
|
273
|
-
if (((_a2 = options == null ?
|
|
287
|
+
if (((_a2 = options == null ? void 0 : options.modifiers) == null ? void 0 : _a2.self) && ev.target !== elementRef.value)
|
|
274
288
|
return;
|
|
275
289
|
clear();
|
|
276
|
-
if ((_b2 = options == null ?
|
|
290
|
+
if ((_b2 = options == null ? void 0 : options.modifiers) == null ? void 0 : _b2.prevent)
|
|
277
291
|
ev.preventDefault();
|
|
278
|
-
if ((_c = options == null ?
|
|
292
|
+
if ((_c = options == null ? void 0 : options.modifiers) == null ? void 0 : _c.stop)
|
|
279
293
|
ev.stopPropagation();
|
|
280
294
|
posStart = {
|
|
281
295
|
x: ev.x,
|
|
@@ -287,28 +301,28 @@ function onLongPress(target, handler, options) {
|
|
|
287
301
|
hasLongPressed = true;
|
|
288
302
|
handler(ev);
|
|
289
303
|
},
|
|
290
|
-
(_d = options == null ?
|
|
304
|
+
(_d = options == null ? void 0 : options.delay) != null ? _d : DEFAULT_DELAY
|
|
291
305
|
);
|
|
292
306
|
}
|
|
293
307
|
function onMove(ev) {
|
|
294
308
|
var _a2, _b2, _c, _d;
|
|
295
|
-
if (((_a2 = options == null ?
|
|
309
|
+
if (((_a2 = options == null ? void 0 : options.modifiers) == null ? void 0 : _a2.self) && ev.target !== elementRef.value)
|
|
296
310
|
return;
|
|
297
|
-
if (!posStart || (options == null ?
|
|
311
|
+
if (!posStart || (options == null ? void 0 : options.distanceThreshold) === false)
|
|
298
312
|
return;
|
|
299
|
-
if ((_b2 = options == null ?
|
|
313
|
+
if ((_b2 = options == null ? void 0 : options.modifiers) == null ? void 0 : _b2.prevent)
|
|
300
314
|
ev.preventDefault();
|
|
301
|
-
if ((_c = options == null ?
|
|
315
|
+
if ((_c = options == null ? void 0 : options.modifiers) == null ? void 0 : _c.stop)
|
|
302
316
|
ev.stopPropagation();
|
|
303
317
|
const dx = ev.x - posStart.x;
|
|
304
318
|
const dy = ev.y - posStart.y;
|
|
305
319
|
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
306
|
-
if (distance >= ((_d = options == null ?
|
|
320
|
+
if (distance >= ((_d = options == null ? void 0 : options.distanceThreshold) != null ? _d : DEFAULT_THRESHOLD))
|
|
307
321
|
clear();
|
|
308
322
|
}
|
|
309
323
|
const listenerOptions = {
|
|
310
|
-
capture: (_a = options == null ?
|
|
311
|
-
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
|
|
312
326
|
};
|
|
313
327
|
const cleanup = [
|
|
314
328
|
useEventListener(elementRef, "pointerdown", onDown, listenerOptions),
|
|
@@ -396,7 +410,7 @@ const UseClipboard = /* @__PURE__ */ /* #__PURE__ */ vue.defineComponent({
|
|
|
396
410
|
const data = vue.reactive(core.useClipboard(props));
|
|
397
411
|
return () => {
|
|
398
412
|
var _a;
|
|
399
|
-
return (_a = slots.default) == null ?
|
|
413
|
+
return (_a = slots.default) == null ? void 0 : _a.call(slots, data);
|
|
400
414
|
};
|
|
401
415
|
}
|
|
402
416
|
});
|
|
@@ -416,7 +430,7 @@ function getSSRHandler(key, fallback) {
|
|
|
416
430
|
const ssrWidthSymbol = Symbol("vueuse-ssr-width");
|
|
417
431
|
function useSSRWidth() {
|
|
418
432
|
const ssrWidth = vue.hasInjectionContext() ? shared.injectLocal(ssrWidthSymbol, null) : null;
|
|
419
|
-
return typeof ssrWidth === "number" ? ssrWidth :
|
|
433
|
+
return typeof ssrWidth === "number" ? ssrWidth : void 0;
|
|
420
434
|
}
|
|
421
435
|
|
|
422
436
|
function useMounted() {
|
|
@@ -673,7 +687,7 @@ function useColorMode(options = {}) {
|
|
|
673
687
|
const updateHTMLAttrs = getSSRHandler(
|
|
674
688
|
"updateHTMLAttrs",
|
|
675
689
|
(selector2, attribute2, value) => {
|
|
676
|
-
const el = typeof selector2 === "string" ? window == null ?
|
|
690
|
+
const el = typeof selector2 === "string" ? window == null ? void 0 : window.document.querySelector(selector2) : unrefElement(selector2);
|
|
677
691
|
if (!el)
|
|
678
692
|
return;
|
|
679
693
|
const classesToAdd = /* @__PURE__ */ new Set();
|
|
@@ -857,18 +871,18 @@ const UseDraggable = /* @__PURE__ */ /* #__PURE__ */ vue.defineComponent({
|
|
|
857
871
|
});
|
|
858
872
|
const containerElement = vue.computed(() => {
|
|
859
873
|
var _a;
|
|
860
|
-
return (_a = props.containerElement) != null ? _a :
|
|
874
|
+
return (_a = props.containerElement) != null ? _a : void 0;
|
|
861
875
|
});
|
|
862
876
|
const disabled = vue.computed(() => !!props.disabled);
|
|
863
877
|
const storageValue = props.storageKey && core.useStorage(
|
|
864
878
|
props.storageKey,
|
|
865
879
|
vue.toValue(props.initialValue) || { x: 0, y: 0 },
|
|
866
|
-
core.isClient ? props.storageType === "session" ? sessionStorage : localStorage :
|
|
880
|
+
core.isClient ? props.storageType === "session" ? sessionStorage : localStorage : void 0
|
|
867
881
|
);
|
|
868
882
|
const initialValue = storageValue || props.initialValue || { x: 0, y: 0 };
|
|
869
883
|
const onEnd = (position, event) => {
|
|
870
884
|
var _a;
|
|
871
|
-
(_a = props.onEnd) == null ?
|
|
885
|
+
(_a = props.onEnd) == null ? void 0 : _a.call(props, position, event);
|
|
872
886
|
if (!storageValue)
|
|
873
887
|
return;
|
|
874
888
|
storageValue.value.x = position.x;
|
|
@@ -909,7 +923,7 @@ function useMutationObserver(target, callback, options = {}) {
|
|
|
909
923
|
const cleanup = () => {
|
|
910
924
|
if (observer) {
|
|
911
925
|
observer.disconnect();
|
|
912
|
-
observer =
|
|
926
|
+
observer = void 0;
|
|
913
927
|
}
|
|
914
928
|
};
|
|
915
929
|
const targets = vue.computed(() => {
|
|
@@ -929,7 +943,7 @@ function useMutationObserver(target, callback, options = {}) {
|
|
|
929
943
|
{ immediate: true, flush: "post" }
|
|
930
944
|
);
|
|
931
945
|
const takeRecords = () => {
|
|
932
|
-
return observer == null ?
|
|
946
|
+
return observer == null ? void 0 : observer.takeRecords();
|
|
933
947
|
};
|
|
934
948
|
const stop = () => {
|
|
935
949
|
stopWatch();
|
|
@@ -950,7 +964,7 @@ function useResizeObserver(target, callback, options = {}) {
|
|
|
950
964
|
const cleanup = () => {
|
|
951
965
|
if (observer) {
|
|
952
966
|
observer.disconnect();
|
|
953
|
-
observer =
|
|
967
|
+
observer = void 0;
|
|
954
968
|
}
|
|
955
969
|
};
|
|
956
970
|
const targets = vue.computed(() => {
|
|
@@ -1075,14 +1089,14 @@ const vElementBounding = {
|
|
|
1075
1089
|
function onElementRemoval(target, callback, options = {}) {
|
|
1076
1090
|
const {
|
|
1077
1091
|
window = defaultWindow,
|
|
1078
|
-
document = window == null ?
|
|
1092
|
+
document = window == null ? void 0 : window.document,
|
|
1079
1093
|
flush = "sync"
|
|
1080
1094
|
} = options;
|
|
1081
1095
|
if (!window || !document)
|
|
1082
1096
|
return shared.noop;
|
|
1083
1097
|
let stopFn;
|
|
1084
1098
|
const cleanupAndUpdate = (fn) => {
|
|
1085
|
-
stopFn == null ?
|
|
1099
|
+
stopFn == null ? void 0 : stopFn();
|
|
1086
1100
|
stopFn = fn;
|
|
1087
1101
|
};
|
|
1088
1102
|
const stopWatch = vue.watchEffect(() => {
|
|
@@ -1126,7 +1140,7 @@ function useElementHover(el, options = {}) {
|
|
|
1126
1140
|
const delay = entering ? delayEnter : delayLeave;
|
|
1127
1141
|
if (timer) {
|
|
1128
1142
|
clearTimeout(timer);
|
|
1129
|
-
timer =
|
|
1143
|
+
timer = void 0;
|
|
1130
1144
|
}
|
|
1131
1145
|
if (delay)
|
|
1132
1146
|
timer = setTimeout(() => isHovered.value = entering, delay);
|
|
@@ -1177,7 +1191,7 @@ function useElementSize(target, initialSize = { width: 0, height: 0 }, options =
|
|
|
1177
1191
|
const { window = defaultWindow, box = "content-box" } = options;
|
|
1178
1192
|
const isSVG = vue.computed(() => {
|
|
1179
1193
|
var _a, _b;
|
|
1180
|
-
return (_b = (_a = unrefElement(target)) == null ?
|
|
1194
|
+
return (_b = (_a = unrefElement(target)) == null ? void 0 : _a.namespaceURI) == null ? void 0 : _b.includes("svg");
|
|
1181
1195
|
});
|
|
1182
1196
|
const width = vue.ref(initialSize.width);
|
|
1183
1197
|
const height = vue.ref(initialSize.height);
|
|
@@ -1233,7 +1247,7 @@ function useElementSize(target, initialSize = { width: 0, height: 0 }, options =
|
|
|
1233
1247
|
const vElementSize = {
|
|
1234
1248
|
mounted(el, binding) {
|
|
1235
1249
|
var _a;
|
|
1236
|
-
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];
|
|
1237
1251
|
const options = typeof binding.value === "function" ? [] : binding.value.slice(1);
|
|
1238
1252
|
const { width, height } = useElementSize(el, ...options);
|
|
1239
1253
|
vue.watch([width, height], ([width2, height2]) => handler({ width: width2, height: height2 }));
|
|
@@ -1319,10 +1333,11 @@ function useElementVisibility(element, options = {}) {
|
|
|
1319
1333
|
window = defaultWindow,
|
|
1320
1334
|
scrollTarget,
|
|
1321
1335
|
threshold = 0,
|
|
1322
|
-
rootMargin
|
|
1336
|
+
rootMargin,
|
|
1337
|
+
once = false
|
|
1323
1338
|
} = options;
|
|
1324
1339
|
const elementIsVisible = vue.ref(false);
|
|
1325
|
-
useIntersectionObserver(
|
|
1340
|
+
const { stop } = useIntersectionObserver(
|
|
1326
1341
|
element,
|
|
1327
1342
|
(intersectionObserverEntries) => {
|
|
1328
1343
|
let isIntersecting = elementIsVisible.value;
|
|
@@ -1334,6 +1349,11 @@ function useElementVisibility(element, options = {}) {
|
|
|
1334
1349
|
}
|
|
1335
1350
|
}
|
|
1336
1351
|
elementIsVisible.value = isIntersecting;
|
|
1352
|
+
if (once) {
|
|
1353
|
+
shared.watchOnce(elementIsVisible, () => {
|
|
1354
|
+
stop();
|
|
1355
|
+
});
|
|
1356
|
+
}
|
|
1337
1357
|
},
|
|
1338
1358
|
{
|
|
1339
1359
|
root: scrollTarget,
|
|
@@ -1423,11 +1443,11 @@ function useAsyncState(promise, initialState, options) {
|
|
|
1423
1443
|
const state = shallow ? vue.shallowRef(initialState) : vue.ref(initialState);
|
|
1424
1444
|
const isReady = vue.ref(false);
|
|
1425
1445
|
const isLoading = vue.ref(false);
|
|
1426
|
-
const error = vue.shallowRef(
|
|
1446
|
+
const error = vue.shallowRef(void 0);
|
|
1427
1447
|
async function execute(delay2 = 0, ...args) {
|
|
1428
1448
|
if (resetOnExecute)
|
|
1429
1449
|
state.value = initialState;
|
|
1430
|
-
error.value =
|
|
1450
|
+
error.value = void 0;
|
|
1431
1451
|
isReady.value = false;
|
|
1432
1452
|
isLoading.value = true;
|
|
1433
1453
|
if (delay2 > 0)
|
|
@@ -1507,7 +1527,7 @@ async function loadImage(options) {
|
|
|
1507
1527
|
function useImage(options, asyncStateOptions = {}) {
|
|
1508
1528
|
const state = useAsyncState(
|
|
1509
1529
|
() => loadImage(vue.toValue(options)),
|
|
1510
|
-
|
|
1530
|
+
void 0,
|
|
1511
1531
|
{
|
|
1512
1532
|
resetOnExecute: true,
|
|
1513
1533
|
...asyncStateOptions
|
|
@@ -1592,7 +1612,7 @@ function useScroll(element, options = {}) {
|
|
|
1592
1612
|
return internalX.value;
|
|
1593
1613
|
},
|
|
1594
1614
|
set(x2) {
|
|
1595
|
-
scrollTo(x2,
|
|
1615
|
+
scrollTo(x2, void 0);
|
|
1596
1616
|
}
|
|
1597
1617
|
});
|
|
1598
1618
|
const y = vue.computed({
|
|
@@ -1600,7 +1620,7 @@ function useScroll(element, options = {}) {
|
|
|
1600
1620
|
return internalY.value;
|
|
1601
1621
|
},
|
|
1602
1622
|
set(y2) {
|
|
1603
|
-
scrollTo(
|
|
1623
|
+
scrollTo(void 0, y2);
|
|
1604
1624
|
}
|
|
1605
1625
|
});
|
|
1606
1626
|
function scrollTo(_x, _y) {
|
|
@@ -1610,12 +1630,12 @@ function useScroll(element, options = {}) {
|
|
|
1610
1630
|
const _element = vue.toValue(element);
|
|
1611
1631
|
if (!_element)
|
|
1612
1632
|
return;
|
|
1613
|
-
(_c = _element instanceof Document ? window.document.body : _element) == null ?
|
|
1633
|
+
(_c = _element instanceof Document ? window.document.body : _element) == null ? void 0 : _c.scrollTo({
|
|
1614
1634
|
top: (_a = vue.toValue(_y)) != null ? _a : y.value,
|
|
1615
1635
|
left: (_b = vue.toValue(_x)) != null ? _b : x.value,
|
|
1616
1636
|
behavior: vue.toValue(behavior)
|
|
1617
1637
|
});
|
|
1618
|
-
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;
|
|
1619
1639
|
if (x != null)
|
|
1620
1640
|
internalX.value = scrollContainer.scrollLeft;
|
|
1621
1641
|
if (y != null)
|
|
@@ -1649,7 +1669,7 @@ function useScroll(element, options = {}) {
|
|
|
1649
1669
|
var _a;
|
|
1650
1670
|
if (!window)
|
|
1651
1671
|
return;
|
|
1652
|
-
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);
|
|
1653
1673
|
const { display, flexDirection, direction } = getComputedStyle(el);
|
|
1654
1674
|
const directionMultipler = direction === "rtl" ? -1 : 1;
|
|
1655
1675
|
const scrollLeft = el.scrollLeft;
|
|
@@ -1829,7 +1849,7 @@ const UseMouseBuiltinExtractors = {
|
|
|
1829
1849
|
page: (event) => [event.pageX, event.pageY],
|
|
1830
1850
|
client: (event) => [event.clientX, event.clientY],
|
|
1831
1851
|
screen: (event) => [event.screenX, event.screenY],
|
|
1832
|
-
movement: (event) => event instanceof
|
|
1852
|
+
movement: (event) => event instanceof MouseEvent ? [event.movementX, event.movementY] : null
|
|
1833
1853
|
};
|
|
1834
1854
|
function useMouse(options = {}) {
|
|
1835
1855
|
const {
|
|
@@ -1911,7 +1931,7 @@ function useMouseInElement(target, options = {}) {
|
|
|
1911
1931
|
} = options;
|
|
1912
1932
|
const type = options.type || "page";
|
|
1913
1933
|
const { x, y, sourceType } = useMouse(options);
|
|
1914
|
-
const targetRef = vue.ref(target != null ? target : window == null ?
|
|
1934
|
+
const targetRef = vue.ref(target != null ? target : window == null ? void 0 : window.document.body);
|
|
1915
1935
|
const elementX = vue.ref(0);
|
|
1916
1936
|
const elementY = vue.ref(0);
|
|
1917
1937
|
const elementPositionX = vue.ref(0);
|
|
@@ -2049,17 +2069,17 @@ const UseOffsetPagination = /* @__PURE__ */ /* #__PURE__ */ vue.defineComponent(
|
|
|
2049
2069
|
...props,
|
|
2050
2070
|
onPageChange(...args) {
|
|
2051
2071
|
var _a;
|
|
2052
|
-
(_a = props.onPageChange) == null ?
|
|
2072
|
+
(_a = props.onPageChange) == null ? void 0 : _a.call(props, ...args);
|
|
2053
2073
|
emit("page-change", ...args);
|
|
2054
2074
|
},
|
|
2055
2075
|
onPageSizeChange(...args) {
|
|
2056
2076
|
var _a;
|
|
2057
|
-
(_a = props.onPageSizeChange) == null ?
|
|
2077
|
+
(_a = props.onPageSizeChange) == null ? void 0 : _a.call(props, ...args);
|
|
2058
2078
|
emit("page-size-change", ...args);
|
|
2059
2079
|
},
|
|
2060
2080
|
onPageCountChange(...args) {
|
|
2061
2081
|
var _a;
|
|
2062
|
-
(_a = props.onPageCountChange) == null ?
|
|
2082
|
+
(_a = props.onPageCountChange) == null ? void 0 : _a.call(props, ...args);
|
|
2063
2083
|
emit("page-count-change", ...args);
|
|
2064
2084
|
}
|
|
2065
2085
|
}));
|
|
@@ -2221,15 +2241,15 @@ function useCssVar(prop, target, options = {}) {
|
|
|
2221
2241
|
const variable = vue.ref(initialValue);
|
|
2222
2242
|
const elRef = vue.computed(() => {
|
|
2223
2243
|
var _a;
|
|
2224
|
-
return unrefElement(target) || ((_a = window == null ?
|
|
2244
|
+
return unrefElement(target) || ((_a = window == null ? void 0 : window.document) == null ? void 0 : _a.documentElement);
|
|
2225
2245
|
});
|
|
2226
2246
|
function updateCssVar() {
|
|
2227
2247
|
var _a;
|
|
2228
2248
|
const key = vue.toValue(prop);
|
|
2229
2249
|
const el = vue.toValue(elRef);
|
|
2230
2250
|
if (el && window && key) {
|
|
2231
|
-
const value = (_a = window.getComputedStyle(el).getPropertyValue(key)) == null ?
|
|
2232
|
-
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;
|
|
2233
2253
|
}
|
|
2234
2254
|
}
|
|
2235
2255
|
if (observe) {
|
|
@@ -2244,21 +2264,20 @@ function useCssVar(prop, target, options = {}) {
|
|
|
2244
2264
|
if (old[0] && old[1])
|
|
2245
2265
|
old[0].style.removeProperty(old[1]);
|
|
2246
2266
|
updateCssVar();
|
|
2247
|
-
}
|
|
2248
|
-
{ immediate: true }
|
|
2267
|
+
}
|
|
2249
2268
|
);
|
|
2250
2269
|
vue.watch(
|
|
2251
|
-
variable,
|
|
2252
|
-
(val) => {
|
|
2253
|
-
var _a;
|
|
2270
|
+
[variable, elRef],
|
|
2271
|
+
([val, el]) => {
|
|
2254
2272
|
const raw_prop = vue.toValue(prop);
|
|
2255
|
-
if ((
|
|
2273
|
+
if ((el == null ? void 0 : el.style) && raw_prop) {
|
|
2256
2274
|
if (val == null)
|
|
2257
|
-
|
|
2275
|
+
el.style.removeProperty(raw_prop);
|
|
2258
2276
|
else
|
|
2259
|
-
|
|
2277
|
+
el.style.setProperty(raw_prop, val);
|
|
2260
2278
|
}
|
|
2261
|
-
}
|
|
2279
|
+
},
|
|
2280
|
+
{ immediate: true }
|
|
2262
2281
|
);
|
|
2263
2282
|
return variable;
|
|
2264
2283
|
}
|
|
@@ -2354,12 +2373,12 @@ const vScroll = {
|
|
|
2354
2373
|
...options,
|
|
2355
2374
|
onScroll(e) {
|
|
2356
2375
|
var _a;
|
|
2357
|
-
(_a = options.onScroll) == null ?
|
|
2376
|
+
(_a = options.onScroll) == null ? void 0 : _a.call(options, e);
|
|
2358
2377
|
handler(state);
|
|
2359
2378
|
},
|
|
2360
2379
|
onStop(e) {
|
|
2361
2380
|
var _a;
|
|
2362
|
-
(_a = options.onStop) == null ?
|
|
2381
|
+
(_a = options.onStop) == null ? void 0 : _a.call(options, e);
|
|
2363
2382
|
handler(state);
|
|
2364
2383
|
}
|
|
2365
2384
|
});
|
|
@@ -2432,7 +2451,7 @@ function useScrollLock(element, initialState = false) {
|
|
|
2432
2451
|
if (!el || !isLocked.value)
|
|
2433
2452
|
return;
|
|
2434
2453
|
if (shared.isIOS)
|
|
2435
|
-
stopTouchMoveListener == null ?
|
|
2454
|
+
stopTouchMoveListener == null ? void 0 : stopTouchMoveListener();
|
|
2436
2455
|
el.style.overflow = initialOverflow;
|
|
2437
2456
|
elInitialOverflow.delete(el);
|
|
2438
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;
|
package/index.d.mts
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;
|
package/index.d.ts
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;
|