@histoire/vendors 1.0.0-alpha.1 → 1.0.0-alpha.3
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/dist/client/b-floating-vue.js +1 -1
- package/dist/client/b-iconify.js +142 -255
- package/dist/client/b-pinia.js +3 -3
- package/dist/client/b-scroll.js +1 -1
- package/dist/client/b-vue-use.js +1200 -764
- package/dist/client/b-vue.js +1 -1
- package/dist/client/node_modules/@babel/helper-string-parser/package.json +1 -1
- package/dist/client/node_modules/@babel/helper-validator-identifier/package.json +1 -1
- package/dist/client/node_modules/@babel/parser/package.json +7 -7
- package/dist/client/node_modules/@babel/parser/typings/babel-parser.d.ts +137 -165
- package/dist/client/node_modules/@babel/types/lib/index-legacy.d.ts +61 -40
- package/dist/client/node_modules/@babel/types/lib/index.d.ts +1691 -1658
- package/dist/client/node_modules/@babel/types/package.json +14 -14
- package/dist/client/node_modules/@floating-ui/core/dist/floating-ui.core.d.ts +4 -1
- package/dist/client/node_modules/@floating-ui/core/package.json +2 -2
- package/dist/client/node_modules/@floating-ui/utils/package.json +1 -1
- package/dist/client/node_modules/@iconify/vue/dist/iconify.d.ts +59 -6
- package/dist/client/node_modules/@iconify/vue/dist/offline.d.ts +9 -2
- package/dist/client/node_modules/@iconify/vue/package.json +14 -14
- package/dist/client/node_modules/@jridgewell/sourcemap-codec/package.json +39 -47
- package/dist/client/node_modules/@vueuse/core/index.d.ts +486 -236
- package/dist/client/node_modules/@vueuse/core/package.json +18 -6
- package/dist/client/node_modules/@vueuse/metadata/package.json +11 -4
- package/dist/client/node_modules/@vueuse/shared/index.d.ts +50 -16
- package/dist/client/node_modules/@vueuse/shared/package.json +15 -3
- package/dist/client/node_modules/nanoid/package.json +3 -2
- package/dist/client/node_modules/pinia/dist/pinia.d.ts +1 -1
- package/dist/client/node_modules/pinia/package.json +1 -1
- package/dist/client/node_modules/postcss/lib/at-rule.d.ts +9 -9
- package/dist/client/node_modules/postcss/lib/comment.d.ts +7 -7
- package/dist/client/node_modules/postcss/lib/container.d.ts +52 -52
- package/dist/client/node_modules/postcss/lib/declaration.d.ts +9 -9
- package/dist/client/node_modules/postcss/lib/input.d.ts +38 -19
- package/dist/client/node_modules/postcss/lib/lazy-result.d.ts +40 -40
- package/dist/client/node_modules/postcss/lib/no-work-result.d.ts +5 -5
- package/dist/client/node_modules/postcss/lib/node.d.ts +25 -10
- package/dist/client/node_modules/postcss/lib/result.d.ts +10 -10
- package/dist/client/node_modules/postcss/lib/rule.d.ts +8 -8
- package/dist/client/node_modules/postcss/lib/stringifier.d.ts +2 -2
- package/dist/client/node_modules/postcss/package.json +4 -4
- package/dist/client/vue.runtime.esm-bundler.js +1 -1
- package/package.json +1 -1
- package/dist/client/node_modules/@jridgewell/sourcemap-codec/dist/types/scopes.d.ts +0 -49
- package/dist/client/node_modules/@jridgewell/sourcemap-codec/dist/types/sourcemap-codec.d.ts +0 -8
- package/dist/client/node_modules/@jridgewell/sourcemap-codec/dist/types/strings.d.ts +0 -15
- package/dist/client/node_modules/@jridgewell/sourcemap-codec/dist/types/vlq.d.ts +0 -6
- /package/dist/client/node_modules/{vue-demi → pinia/node_modules/vue-demi}/lib/index.d.ts +0 -0
- /package/dist/client/node_modules/{vue-demi → pinia/node_modules/vue-demi}/lib/v2/index.d.ts +0 -0
- /package/dist/client/node_modules/{vue-demi → pinia/node_modules/vue-demi}/lib/v2.7/index.d.ts +0 -0
- /package/dist/client/node_modules/{vue-demi → pinia/node_modules/vue-demi}/lib/v3/index.d.ts +0 -0
- /package/dist/client/node_modules/{vue-demi → pinia/node_modules/vue-demi}/package.json +0 -0
package/dist/client/b-vue-use.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { U as shallowRef, S as watchEffect, W as readonly,
|
|
1
|
+
import { U as shallowRef, S as watchEffect, W as readonly, B as watch, X as customRef, I as getCurrentScope, J as onScopeDispose, E as effectScope, O as getCurrentInstance, y as hasInjectionContext, z as inject, T as provide, G as isRef, C as unref, Y as toValue$1, L as computed, M as reactive, K as toRefs$1, N as toRef$1, u as ref, Z as onBeforeMount, b as nextTick, _ as onBeforeUnmount, $ as onMounted, P as onUnmounted, H as isReactive, d as defineComponent, V as shallowReactive, x as h, F as Fragment, a0 as TransitionGroup, a1 as onUpdated, A as toRaw, D as markRaw, a2 as isReadonly, a3 as onBeforeUpdate } from './vue.runtime.esm-bundler.js';
|
|
2
2
|
|
|
3
3
|
function computedEager(fn, options) {
|
|
4
4
|
var _a;
|
|
@@ -16,7 +16,7 @@ function computedWithControl(source, fn) {
|
|
|
16
16
|
let v = void 0;
|
|
17
17
|
let track;
|
|
18
18
|
let trigger;
|
|
19
|
-
const dirty =
|
|
19
|
+
const dirty = shallowRef(true);
|
|
20
20
|
const update = () => {
|
|
21
21
|
dirty.value = true;
|
|
22
22
|
trigger();
|
|
@@ -59,6 +59,9 @@ function createEventHook() {
|
|
|
59
59
|
const off = (fn) => {
|
|
60
60
|
fns.delete(fn);
|
|
61
61
|
};
|
|
62
|
+
const clear = () => {
|
|
63
|
+
fns.clear();
|
|
64
|
+
};
|
|
62
65
|
const on = (fn) => {
|
|
63
66
|
fns.add(fn);
|
|
64
67
|
const offFn = () => off(fn);
|
|
@@ -73,7 +76,8 @@ function createEventHook() {
|
|
|
73
76
|
return {
|
|
74
77
|
on,
|
|
75
78
|
off,
|
|
76
|
-
trigger
|
|
79
|
+
trigger,
|
|
80
|
+
clear
|
|
77
81
|
};
|
|
78
82
|
}
|
|
79
83
|
|
|
@@ -96,9 +100,9 @@ const injectLocal = (...args) => {
|
|
|
96
100
|
var _a;
|
|
97
101
|
const key = args[0];
|
|
98
102
|
const instance = (_a = getCurrentInstance()) == null ? void 0 : _a.proxy;
|
|
99
|
-
if (instance == null)
|
|
103
|
+
if (instance == null && !hasInjectionContext())
|
|
100
104
|
throw new Error("injectLocal must be called in setup");
|
|
101
|
-
if (localProvidedStateMap.has(instance) && key in localProvidedStateMap.get(instance))
|
|
105
|
+
if (instance && localProvidedStateMap.has(instance) && key in localProvidedStateMap.get(instance))
|
|
102
106
|
return localProvidedStateMap.get(instance)[key];
|
|
103
107
|
return inject(...args);
|
|
104
108
|
};
|
|
@@ -202,13 +206,8 @@ function makeDestructurable(obj, arr) {
|
|
|
202
206
|
}
|
|
203
207
|
}
|
|
204
208
|
|
|
205
|
-
function toValue(r) {
|
|
206
|
-
return typeof r === "function" ? r() : unref(r);
|
|
207
|
-
}
|
|
208
|
-
const resolveUnref = toValue;
|
|
209
|
-
|
|
210
209
|
function reactify(fn, options) {
|
|
211
|
-
const unrefFn = (options == null ? void 0 : options.computedGetter) === false ? unref : toValue;
|
|
210
|
+
const unrefFn = (options == null ? void 0 : options.computedGetter) === false ? unref : toValue$1;
|
|
212
211
|
return function(...args) {
|
|
213
212
|
return computed(() => fn.apply(this, args.map((i) => unrefFn(i))));
|
|
214
213
|
};
|
|
@@ -277,7 +276,7 @@ function reactiveComputed(fn) {
|
|
|
277
276
|
function reactiveOmit(obj, ...keys) {
|
|
278
277
|
const flatKeys = keys.flat();
|
|
279
278
|
const predicate = flatKeys[0];
|
|
280
|
-
return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(toRefs$1(obj)).filter(([k, v]) => !predicate(toValue(v), k))) : Object.fromEntries(Object.entries(toRefs$1(obj)).filter((e) => !flatKeys.includes(e[0]))));
|
|
279
|
+
return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(toRefs$1(obj)).filter(([k, v]) => !predicate(toValue$1(v), k))) : Object.fromEntries(Object.entries(toRefs$1(obj)).filter((e) => !flatKeys.includes(e[0]))));
|
|
281
280
|
}
|
|
282
281
|
|
|
283
282
|
const isClient = typeof window !== "undefined" && typeof document !== "undefined";
|
|
@@ -327,9 +326,10 @@ function debounceFilter(ms, options = {}) {
|
|
|
327
326
|
lastRejector();
|
|
328
327
|
lastRejector = noop;
|
|
329
328
|
};
|
|
329
|
+
let lastInvoker;
|
|
330
330
|
const filter = (invoke) => {
|
|
331
|
-
const duration = toValue(ms);
|
|
332
|
-
const maxDuration = toValue(options.maxWait);
|
|
331
|
+
const duration = toValue$1(ms);
|
|
332
|
+
const maxDuration = toValue$1(options.maxWait);
|
|
333
333
|
if (timer)
|
|
334
334
|
_clearTimeout(timer);
|
|
335
335
|
if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
|
|
@@ -341,12 +341,13 @@ function debounceFilter(ms, options = {}) {
|
|
|
341
341
|
}
|
|
342
342
|
return new Promise((resolve, reject) => {
|
|
343
343
|
lastRejector = options.rejectOnCancel ? reject : resolve;
|
|
344
|
+
lastInvoker = invoke;
|
|
344
345
|
if (maxDuration && !maxTimer) {
|
|
345
346
|
maxTimer = setTimeout(() => {
|
|
346
347
|
if (timer)
|
|
347
348
|
_clearTimeout(timer);
|
|
348
349
|
maxTimer = null;
|
|
349
|
-
resolve(
|
|
350
|
+
resolve(lastInvoker());
|
|
350
351
|
}, maxDuration);
|
|
351
352
|
}
|
|
352
353
|
timer = setTimeout(() => {
|
|
@@ -382,7 +383,7 @@ function throttleFilter(...args) {
|
|
|
382
383
|
}
|
|
383
384
|
};
|
|
384
385
|
const filter = (_invoke) => {
|
|
385
|
-
const duration = toValue(ms);
|
|
386
|
+
const duration = toValue$1(ms);
|
|
386
387
|
const elapsed = Date.now() - lastExec;
|
|
387
388
|
const invoke = () => {
|
|
388
389
|
return lastValue = _invoke();
|
|
@@ -413,8 +414,11 @@ function throttleFilter(...args) {
|
|
|
413
414
|
};
|
|
414
415
|
return filter;
|
|
415
416
|
}
|
|
416
|
-
function pausableFilter(extendFilter = bypassFilter) {
|
|
417
|
-
const
|
|
417
|
+
function pausableFilter(extendFilter = bypassFilter, options = {}) {
|
|
418
|
+
const {
|
|
419
|
+
initialState = "active"
|
|
420
|
+
} = options;
|
|
421
|
+
const isActive = toRef(initialState === "active");
|
|
418
422
|
function pause() {
|
|
419
423
|
isActive.value = false;
|
|
420
424
|
}
|
|
@@ -485,6 +489,9 @@ function increaseWithUnit(target, delta) {
|
|
|
485
489
|
return target;
|
|
486
490
|
return result + unit;
|
|
487
491
|
}
|
|
492
|
+
function pxValue(px) {
|
|
493
|
+
return px.endsWith("rem") ? Number.parseFloat(px) * 16 : Number.parseFloat(px);
|
|
494
|
+
}
|
|
488
495
|
function objectPick(obj, keys, omitUndefined = false) {
|
|
489
496
|
return keys.reduce((n, k) => {
|
|
490
497
|
if (k in obj) {
|
|
@@ -505,6 +512,9 @@ function objectEntries(obj) {
|
|
|
505
512
|
function getLifeCycleTarget(target) {
|
|
506
513
|
return target || getCurrentInstance();
|
|
507
514
|
}
|
|
515
|
+
function toArray(value) {
|
|
516
|
+
return Array.isArray(value) ? value : [value];
|
|
517
|
+
}
|
|
508
518
|
|
|
509
519
|
function toRef(...args) {
|
|
510
520
|
if (args.length !== 1)
|
|
@@ -517,17 +527,17 @@ const resolveRef = toRef;
|
|
|
517
527
|
function reactivePick(obj, ...keys) {
|
|
518
528
|
const flatKeys = keys.flat();
|
|
519
529
|
const predicate = flatKeys[0];
|
|
520
|
-
return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(toRefs$1(obj)).filter(([k, v]) => predicate(toValue(v), k))) : Object.fromEntries(flatKeys.map((k) => [k, toRef(obj, k)])));
|
|
530
|
+
return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(toRefs$1(obj)).filter(([k, v]) => predicate(toValue$1(v), k))) : Object.fromEntries(flatKeys.map((k) => [k, toRef(obj, k)])));
|
|
521
531
|
}
|
|
522
532
|
|
|
523
533
|
function refAutoReset(defaultValue, afterMs = 1e4) {
|
|
524
534
|
return customRef((track, trigger) => {
|
|
525
|
-
let value = toValue(defaultValue);
|
|
535
|
+
let value = toValue$1(defaultValue);
|
|
526
536
|
let timer;
|
|
527
537
|
const resetAfter = () => setTimeout(() => {
|
|
528
|
-
value = toValue(defaultValue);
|
|
538
|
+
value = toValue$1(defaultValue);
|
|
529
539
|
trigger();
|
|
530
|
-
}, toValue(afterMs));
|
|
540
|
+
}, toValue$1(afterMs));
|
|
531
541
|
tryOnScopeDispose(() => {
|
|
532
542
|
clearTimeout(timer);
|
|
533
543
|
});
|
|
@@ -673,9 +683,10 @@ function watchWithFilter(source, cb, options = {}) {
|
|
|
673
683
|
function watchPausable(source, cb, options = {}) {
|
|
674
684
|
const {
|
|
675
685
|
eventFilter: filter,
|
|
686
|
+
initialState = "active",
|
|
676
687
|
...watchOptions
|
|
677
688
|
} = options;
|
|
678
|
-
const { eventFilter, pause, resume, isActive } = pausableFilter(filter);
|
|
689
|
+
const { eventFilter, pause, resume, isActive } = pausableFilter(filter, { initialState });
|
|
679
690
|
const stop = watchWithFilter(
|
|
680
691
|
source,
|
|
681
692
|
cb,
|
|
@@ -732,8 +743,7 @@ function syncRefs(source, targets, options = {}) {
|
|
|
732
743
|
deep = false,
|
|
733
744
|
immediate = true
|
|
734
745
|
} = options;
|
|
735
|
-
|
|
736
|
-
targets = [targets];
|
|
746
|
+
targets = toArray(targets);
|
|
737
747
|
return watch(
|
|
738
748
|
source,
|
|
739
749
|
(newValue) => targets.forEach((target) => target.value = newValue),
|
|
@@ -752,7 +762,7 @@ function toRefs(objectRef, options = {}) {
|
|
|
752
762
|
},
|
|
753
763
|
set(v) {
|
|
754
764
|
var _a;
|
|
755
|
-
const replaceRef = (_a = toValue(options.replaceRef)) != null ? _a : true;
|
|
765
|
+
const replaceRef = (_a = toValue$1(options.replaceRef)) != null ? _a : true;
|
|
756
766
|
if (replaceRef) {
|
|
757
767
|
if (Array.isArray(objectRef.value)) {
|
|
758
768
|
const copy = [...objectRef.value];
|
|
@@ -772,6 +782,9 @@ function toRefs(objectRef, options = {}) {
|
|
|
772
782
|
return result;
|
|
773
783
|
}
|
|
774
784
|
|
|
785
|
+
const toValue = toValue$1;
|
|
786
|
+
const resolveUnref = toValue$1;
|
|
787
|
+
|
|
775
788
|
function tryOnBeforeMount(fn, sync = true, target) {
|
|
776
789
|
const instance = getLifeCycleTarget(target);
|
|
777
790
|
if (instance)
|
|
@@ -829,7 +842,7 @@ function createUntil(r, isNot = false) {
|
|
|
829
842
|
const promises = [watcher];
|
|
830
843
|
if (timeout != null) {
|
|
831
844
|
promises.push(
|
|
832
|
-
promiseTimeout(timeout, throwOnTimeout).then(() => toValue(r)).finally(() => stop == null ? void 0 : stop())
|
|
845
|
+
promiseTimeout(timeout, throwOnTimeout).then(() => toValue$1(r)).finally(() => stop == null ? void 0 : stop())
|
|
833
846
|
);
|
|
834
847
|
}
|
|
835
848
|
return Promise.race(promises);
|
|
@@ -861,9 +874,9 @@ function createUntil(r, isNot = false) {
|
|
|
861
874
|
const promises = [watcher];
|
|
862
875
|
if (timeout != null) {
|
|
863
876
|
promises.push(
|
|
864
|
-
promiseTimeout(timeout, throwOnTimeout).then(() => toValue(r)).finally(() => {
|
|
877
|
+
promiseTimeout(timeout, throwOnTimeout).then(() => toValue$1(r)).finally(() => {
|
|
865
878
|
stop == null ? void 0 : stop();
|
|
866
|
-
return toValue(r);
|
|
879
|
+
return toValue$1(r);
|
|
867
880
|
})
|
|
868
881
|
);
|
|
869
882
|
}
|
|
@@ -884,7 +897,7 @@ function createUntil(r, isNot = false) {
|
|
|
884
897
|
function toContains(value, options) {
|
|
885
898
|
return toMatch((v) => {
|
|
886
899
|
const array = Array.from(v);
|
|
887
|
-
return array.includes(value) || array.includes(toValue(value));
|
|
900
|
+
return array.includes(value) || array.includes(toValue$1(value));
|
|
888
901
|
}, options);
|
|
889
902
|
}
|
|
890
903
|
function changed(options) {
|
|
@@ -897,7 +910,7 @@ function createUntil(r, isNot = false) {
|
|
|
897
910
|
return count >= n;
|
|
898
911
|
}, options);
|
|
899
912
|
}
|
|
900
|
-
if (Array.isArray(toValue(r))) {
|
|
913
|
+
if (Array.isArray(toValue$1(r))) {
|
|
901
914
|
const instance = {
|
|
902
915
|
toMatch,
|
|
903
916
|
toContains,
|
|
@@ -933,33 +946,42 @@ function defaultComparator(value, othVal) {
|
|
|
933
946
|
return value === othVal;
|
|
934
947
|
}
|
|
935
948
|
function useArrayDifference(...args) {
|
|
936
|
-
var _a;
|
|
949
|
+
var _a, _b;
|
|
937
950
|
const list = args[0];
|
|
938
951
|
const values = args[1];
|
|
939
952
|
let compareFn = (_a = args[2]) != null ? _a : defaultComparator;
|
|
953
|
+
const {
|
|
954
|
+
symmetric = false
|
|
955
|
+
} = (_b = args[3]) != null ? _b : {};
|
|
940
956
|
if (typeof compareFn === "string") {
|
|
941
957
|
const key = compareFn;
|
|
942
958
|
compareFn = (value, othVal) => value[key] === othVal[key];
|
|
943
959
|
}
|
|
944
|
-
|
|
960
|
+
const diff1 = computed(() => toValue$1(list).filter((x) => toValue$1(values).findIndex((y) => compareFn(x, y)) === -1));
|
|
961
|
+
if (symmetric) {
|
|
962
|
+
const diff2 = computed(() => toValue$1(values).filter((x) => toValue$1(list).findIndex((y) => compareFn(x, y)) === -1));
|
|
963
|
+
return computed(() => symmetric ? [...toValue$1(diff1), ...toValue$1(diff2)] : toValue$1(diff1));
|
|
964
|
+
} else {
|
|
965
|
+
return diff1;
|
|
966
|
+
}
|
|
945
967
|
}
|
|
946
968
|
|
|
947
969
|
function useArrayEvery(list, fn) {
|
|
948
|
-
return computed(() => toValue(list).every((element, index, array) => fn(toValue(element), index, array)));
|
|
970
|
+
return computed(() => toValue$1(list).every((element, index, array) => fn(toValue$1(element), index, array)));
|
|
949
971
|
}
|
|
950
972
|
|
|
951
973
|
function useArrayFilter(list, fn) {
|
|
952
|
-
return computed(() => toValue(list).map((i) => toValue(i)).filter(fn));
|
|
974
|
+
return computed(() => toValue$1(list).map((i) => toValue$1(i)).filter(fn));
|
|
953
975
|
}
|
|
954
976
|
|
|
955
977
|
function useArrayFind(list, fn) {
|
|
956
|
-
return computed(() => toValue(
|
|
957
|
-
toValue(list).find((element, index, array) => fn(toValue(element), index, array))
|
|
978
|
+
return computed(() => toValue$1(
|
|
979
|
+
toValue$1(list).find((element, index, array) => fn(toValue$1(element), index, array))
|
|
958
980
|
));
|
|
959
981
|
}
|
|
960
982
|
|
|
961
983
|
function useArrayFindIndex(list, fn) {
|
|
962
|
-
return computed(() => toValue(list).findIndex((element, index, array) => fn(toValue(element), index, array)));
|
|
984
|
+
return computed(() => toValue$1(list).findIndex((element, index, array) => fn(toValue$1(element), index, array)));
|
|
963
985
|
}
|
|
964
986
|
|
|
965
987
|
function findLast(arr, cb) {
|
|
@@ -971,8 +993,8 @@ function findLast(arr, cb) {
|
|
|
971
993
|
return void 0;
|
|
972
994
|
}
|
|
973
995
|
function useArrayFindLast(list, fn) {
|
|
974
|
-
return computed(() => toValue(
|
|
975
|
-
!Array.prototype.findLast ? findLast(toValue(list), (element, index, array) => fn(toValue(element), index, array)) : toValue(list).findLast((element, index, array) => fn(toValue(element), index, array))
|
|
996
|
+
return computed(() => toValue$1(
|
|
997
|
+
!Array.prototype.findLast ? findLast(toValue$1(list), (element, index, array) => fn(toValue$1(element), index, array)) : toValue$1(list).findLast((element, index, array) => fn(toValue$1(element), index, array))
|
|
976
998
|
));
|
|
977
999
|
}
|
|
978
1000
|
|
|
@@ -991,35 +1013,35 @@ function useArrayIncludes(...args) {
|
|
|
991
1013
|
}
|
|
992
1014
|
if (typeof comparator === "string") {
|
|
993
1015
|
const key = comparator;
|
|
994
|
-
comparator = (element, value2) => element[key] === toValue(value2);
|
|
1016
|
+
comparator = (element, value2) => element[key] === toValue$1(value2);
|
|
995
1017
|
}
|
|
996
|
-
comparator = comparator != null ? comparator : (element, value2) => element === toValue(value2);
|
|
997
|
-
return computed(() => toValue(list).slice(formIndex).some((element, index, array) => comparator(
|
|
998
|
-
toValue(element),
|
|
999
|
-
toValue(value),
|
|
1018
|
+
comparator = comparator != null ? comparator : (element, value2) => element === toValue$1(value2);
|
|
1019
|
+
return computed(() => toValue$1(list).slice(formIndex).some((element, index, array) => comparator(
|
|
1020
|
+
toValue$1(element),
|
|
1021
|
+
toValue$1(value),
|
|
1000
1022
|
index,
|
|
1001
|
-
toValue(array)
|
|
1023
|
+
toValue$1(array)
|
|
1002
1024
|
)));
|
|
1003
1025
|
}
|
|
1004
1026
|
|
|
1005
1027
|
function useArrayJoin(list, separator) {
|
|
1006
|
-
return computed(() => toValue(list).map((i) => toValue(i)).join(toValue(separator)));
|
|
1028
|
+
return computed(() => toValue$1(list).map((i) => toValue$1(i)).join(toValue$1(separator)));
|
|
1007
1029
|
}
|
|
1008
1030
|
|
|
1009
1031
|
function useArrayMap(list, fn) {
|
|
1010
|
-
return computed(() => toValue(list).map((i) => toValue(i)).map(fn));
|
|
1032
|
+
return computed(() => toValue$1(list).map((i) => toValue$1(i)).map(fn));
|
|
1011
1033
|
}
|
|
1012
1034
|
|
|
1013
1035
|
function useArrayReduce(list, reducer, ...args) {
|
|
1014
|
-
const reduceCallback = (sum, value, index) => reducer(toValue(sum), toValue(value), index);
|
|
1036
|
+
const reduceCallback = (sum, value, index) => reducer(toValue$1(sum), toValue$1(value), index);
|
|
1015
1037
|
return computed(() => {
|
|
1016
|
-
const resolved = toValue(list);
|
|
1017
|
-
return args.length ? resolved.reduce(reduceCallback, typeof args[0] === "function" ? toValue(args[0]()) : toValue(args[0])) : resolved.reduce(reduceCallback);
|
|
1038
|
+
const resolved = toValue$1(list);
|
|
1039
|
+
return args.length ? resolved.reduce(reduceCallback, typeof args[0] === "function" ? toValue$1(args[0]()) : toValue$1(args[0])) : resolved.reduce(reduceCallback);
|
|
1018
1040
|
});
|
|
1019
1041
|
}
|
|
1020
1042
|
|
|
1021
1043
|
function useArraySome(list, fn) {
|
|
1022
|
-
return computed(() => toValue(list).some((element, index, array) => fn(toValue(element), index, array)));
|
|
1044
|
+
return computed(() => toValue$1(list).some((element, index, array) => fn(toValue$1(element), index, array)));
|
|
1023
1045
|
}
|
|
1024
1046
|
|
|
1025
1047
|
function uniq(array) {
|
|
@@ -1034,7 +1056,7 @@ function uniqueElementsBy(array, fn) {
|
|
|
1034
1056
|
}
|
|
1035
1057
|
function useArrayUnique(list, compareFn) {
|
|
1036
1058
|
return computed(() => {
|
|
1037
|
-
const resolvedList = toValue(list).map((element) => toValue(element));
|
|
1059
|
+
const resolvedList = toValue$1(list).map((element) => toValue$1(element));
|
|
1038
1060
|
return compareFn ? uniqueElementsBy(resolvedList, compareFn) : uniq(resolvedList);
|
|
1039
1061
|
});
|
|
1040
1062
|
}
|
|
@@ -1058,7 +1080,7 @@ function useCounter(initialValue = 0, options = {}) {
|
|
|
1058
1080
|
}
|
|
1059
1081
|
|
|
1060
1082
|
const REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[T\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/i;
|
|
1061
|
-
const REGEX_FORMAT = /[YMDHhms]o|\[([^\]]+)\]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a{1,2}|A{1,2}|m{1,2}|s{1,2}|Z{1,2}|SSS/g;
|
|
1083
|
+
const REGEX_FORMAT = /[YMDHhms]o|\[([^\]]+)\]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a{1,2}|A{1,2}|m{1,2}|s{1,2}|Z{1,2}|z{1,4}|SSS/g;
|
|
1062
1084
|
function defaultMeridiem(hours, minutes, isLowercase, hasPeriod) {
|
|
1063
1085
|
let m = hours < 12 ? "AM" : "PM";
|
|
1064
1086
|
if (hasPeriod)
|
|
@@ -1081,6 +1103,10 @@ function formatDate(date, formatStr, options = {}) {
|
|
|
1081
1103
|
const milliseconds = date.getMilliseconds();
|
|
1082
1104
|
const day = date.getDay();
|
|
1083
1105
|
const meridiem = (_a = options.customMeridiem) != null ? _a : defaultMeridiem;
|
|
1106
|
+
const stripTimeZone = (dateString) => {
|
|
1107
|
+
var _a2;
|
|
1108
|
+
return (_a2 = dateString.split(" ")[1]) != null ? _a2 : "";
|
|
1109
|
+
};
|
|
1084
1110
|
const matches = {
|
|
1085
1111
|
Yo: () => formatOrdinal(years),
|
|
1086
1112
|
YY: () => String(years).slice(-2),
|
|
@@ -1088,8 +1114,8 @@ function formatDate(date, formatStr, options = {}) {
|
|
|
1088
1114
|
M: () => month + 1,
|
|
1089
1115
|
Mo: () => formatOrdinal(month + 1),
|
|
1090
1116
|
MM: () => `${month + 1}`.padStart(2, "0"),
|
|
1091
|
-
MMM: () => date.toLocaleDateString(toValue(options.locales), { month: "short" }),
|
|
1092
|
-
MMMM: () => date.toLocaleDateString(toValue(options.locales), { month: "long" }),
|
|
1117
|
+
MMM: () => date.toLocaleDateString(toValue$1(options.locales), { month: "short" }),
|
|
1118
|
+
MMMM: () => date.toLocaleDateString(toValue$1(options.locales), { month: "long" }),
|
|
1093
1119
|
D: () => String(days),
|
|
1094
1120
|
Do: () => formatOrdinal(days),
|
|
1095
1121
|
DD: () => `${days}`.padStart(2, "0"),
|
|
@@ -1107,13 +1133,17 @@ function formatDate(date, formatStr, options = {}) {
|
|
|
1107
1133
|
ss: () => `${seconds}`.padStart(2, "0"),
|
|
1108
1134
|
SSS: () => `${milliseconds}`.padStart(3, "0"),
|
|
1109
1135
|
d: () => day,
|
|
1110
|
-
dd: () => date.toLocaleDateString(toValue(options.locales), { weekday: "narrow" }),
|
|
1111
|
-
ddd: () => date.toLocaleDateString(toValue(options.locales), { weekday: "short" }),
|
|
1112
|
-
dddd: () => date.toLocaleDateString(toValue(options.locales), { weekday: "long" }),
|
|
1136
|
+
dd: () => date.toLocaleDateString(toValue$1(options.locales), { weekday: "narrow" }),
|
|
1137
|
+
ddd: () => date.toLocaleDateString(toValue$1(options.locales), { weekday: "short" }),
|
|
1138
|
+
dddd: () => date.toLocaleDateString(toValue$1(options.locales), { weekday: "long" }),
|
|
1113
1139
|
A: () => meridiem(hours, minutes),
|
|
1114
1140
|
AA: () => meridiem(hours, minutes, false, true),
|
|
1115
1141
|
a: () => meridiem(hours, minutes, true),
|
|
1116
|
-
aa: () => meridiem(hours, minutes, true, true)
|
|
1142
|
+
aa: () => meridiem(hours, minutes, true, true),
|
|
1143
|
+
z: () => stripTimeZone(date.toLocaleDateString(toValue$1(options.locales), { timeZoneName: "shortOffset" })),
|
|
1144
|
+
zz: () => stripTimeZone(date.toLocaleDateString(toValue$1(options.locales), { timeZoneName: "shortOffset" })),
|
|
1145
|
+
zzz: () => stripTimeZone(date.toLocaleDateString(toValue$1(options.locales), { timeZoneName: "shortOffset" })),
|
|
1146
|
+
zzzz: () => stripTimeZone(date.toLocaleDateString(toValue$1(options.locales), { timeZoneName: "longOffset" }))
|
|
1117
1147
|
};
|
|
1118
1148
|
return formatStr.replace(REGEX_FORMAT, (match, $1) => {
|
|
1119
1149
|
var _a2, _b;
|
|
@@ -1138,7 +1168,7 @@ function normalizeDate(date) {
|
|
|
1138
1168
|
return new Date(date);
|
|
1139
1169
|
}
|
|
1140
1170
|
function useDateFormat(date, formatStr = "HH:mm:ss", options = {}) {
|
|
1141
|
-
return computed(() => formatDate(normalizeDate(toValue(date)), toValue(formatStr), options));
|
|
1171
|
+
return computed(() => formatDate(normalizeDate(toValue$1(date)), toValue$1(formatStr), options));
|
|
1142
1172
|
}
|
|
1143
1173
|
|
|
1144
1174
|
function useIntervalFn(cb, interval = 1e3, options = {}) {
|
|
@@ -1147,7 +1177,7 @@ function useIntervalFn(cb, interval = 1e3, options = {}) {
|
|
|
1147
1177
|
immediateCallback = false
|
|
1148
1178
|
} = options;
|
|
1149
1179
|
let timer = null;
|
|
1150
|
-
const isActive =
|
|
1180
|
+
const isActive = shallowRef(false);
|
|
1151
1181
|
function clean() {
|
|
1152
1182
|
if (timer) {
|
|
1153
1183
|
clearInterval(timer);
|
|
@@ -1159,7 +1189,7 @@ function useIntervalFn(cb, interval = 1e3, options = {}) {
|
|
|
1159
1189
|
clean();
|
|
1160
1190
|
}
|
|
1161
1191
|
function resume() {
|
|
1162
|
-
const intervalValue = toValue(interval);
|
|
1192
|
+
const intervalValue = toValue$1(interval);
|
|
1163
1193
|
if (intervalValue <= 0)
|
|
1164
1194
|
return;
|
|
1165
1195
|
isActive.value = true;
|
|
@@ -1192,7 +1222,7 @@ function useInterval(interval = 1e3, options = {}) {
|
|
|
1192
1222
|
immediate = true,
|
|
1193
1223
|
callback
|
|
1194
1224
|
} = options;
|
|
1195
|
-
const counter =
|
|
1225
|
+
const counter = shallowRef(0);
|
|
1196
1226
|
const update = () => counter.value += 1;
|
|
1197
1227
|
const reset = () => {
|
|
1198
1228
|
counter.value = 0;
|
|
@@ -1229,9 +1259,10 @@ function useLastChanged(source, options = {}) {
|
|
|
1229
1259
|
|
|
1230
1260
|
function useTimeoutFn(cb, interval, options = {}) {
|
|
1231
1261
|
const {
|
|
1232
|
-
immediate = true
|
|
1262
|
+
immediate = true,
|
|
1263
|
+
immediateCallback = false
|
|
1233
1264
|
} = options;
|
|
1234
|
-
const isPending =
|
|
1265
|
+
const isPending = shallowRef(false);
|
|
1235
1266
|
let timer = null;
|
|
1236
1267
|
function clear() {
|
|
1237
1268
|
if (timer) {
|
|
@@ -1244,13 +1275,15 @@ function useTimeoutFn(cb, interval, options = {}) {
|
|
|
1244
1275
|
clear();
|
|
1245
1276
|
}
|
|
1246
1277
|
function start(...args) {
|
|
1278
|
+
if (immediateCallback)
|
|
1279
|
+
cb();
|
|
1247
1280
|
clear();
|
|
1248
1281
|
isPending.value = true;
|
|
1249
1282
|
timer = setTimeout(() => {
|
|
1250
1283
|
isPending.value = false;
|
|
1251
1284
|
timer = null;
|
|
1252
1285
|
cb(...args);
|
|
1253
|
-
}, toValue(interval));
|
|
1286
|
+
}, toValue$1(interval));
|
|
1254
1287
|
}
|
|
1255
1288
|
if (immediate) {
|
|
1256
1289
|
isPending.value = true;
|
|
@@ -1293,8 +1326,10 @@ function useToNumber(value, options = {}) {
|
|
|
1293
1326
|
nanToZero
|
|
1294
1327
|
} = options;
|
|
1295
1328
|
return computed(() => {
|
|
1296
|
-
let resolved = toValue(value);
|
|
1297
|
-
if (typeof
|
|
1329
|
+
let resolved = toValue$1(value);
|
|
1330
|
+
if (typeof method === "function")
|
|
1331
|
+
resolved = method(resolved);
|
|
1332
|
+
else if (typeof resolved === "string")
|
|
1298
1333
|
resolved = Number[method](resolved, radix);
|
|
1299
1334
|
if (nanToZero && Number.isNaN(resolved))
|
|
1300
1335
|
resolved = 0;
|
|
@@ -1303,7 +1338,7 @@ function useToNumber(value, options = {}) {
|
|
|
1303
1338
|
}
|
|
1304
1339
|
|
|
1305
1340
|
function useToString(value) {
|
|
1306
|
-
return computed(() => `${toValue(value)}`);
|
|
1341
|
+
return computed(() => `${toValue$1(value)}`);
|
|
1307
1342
|
}
|
|
1308
1343
|
|
|
1309
1344
|
function useToggle(initialValue = false, options = {}) {
|
|
@@ -1318,8 +1353,8 @@ function useToggle(initialValue = false, options = {}) {
|
|
|
1318
1353
|
_value.value = value;
|
|
1319
1354
|
return _value.value;
|
|
1320
1355
|
} else {
|
|
1321
|
-
const truthy = toValue(truthyValue);
|
|
1322
|
-
_value.value = _value.value === truthy ? toValue(falsyValue) : truthy;
|
|
1356
|
+
const truthy = toValue$1(truthyValue);
|
|
1357
|
+
_value.value = _value.value === truthy ? toValue$1(falsyValue) : truthy;
|
|
1323
1358
|
return _value.value;
|
|
1324
1359
|
}
|
|
1325
1360
|
}
|
|
@@ -1330,7 +1365,7 @@ function useToggle(initialValue = false, options = {}) {
|
|
|
1330
1365
|
}
|
|
1331
1366
|
|
|
1332
1367
|
function watchArray(source, cb, options) {
|
|
1333
|
-
let oldList = (options == null ? void 0 : options.immediate) ? [] : [...source instanceof Function ? source() : Array.isArray(source) ? source : toValue(source)];
|
|
1368
|
+
let oldList = (options == null ? void 0 : options.immediate) ? [] : [...source instanceof Function ? source() : Array.isArray(source) ? source : toValue$1(source)];
|
|
1334
1369
|
return watch(source, (newList, _, onCleanup) => {
|
|
1335
1370
|
const oldListRemains = Array.from({ length: oldList.length });
|
|
1336
1371
|
const added = [];
|
|
@@ -1357,12 +1392,12 @@ function watchAtMost(source, cb, options) {
|
|
|
1357
1392
|
count,
|
|
1358
1393
|
...watchOptions
|
|
1359
1394
|
} = options;
|
|
1360
|
-
const current =
|
|
1395
|
+
const current = shallowRef(0);
|
|
1361
1396
|
const stop = watchWithFilter(
|
|
1362
1397
|
source,
|
|
1363
1398
|
(...args) => {
|
|
1364
1399
|
current.value += 1;
|
|
1365
|
-
if (current.value >= toValue(count))
|
|
1400
|
+
if (current.value >= toValue$1(count))
|
|
1366
1401
|
nextTick(() => stop());
|
|
1367
1402
|
cb(...args);
|
|
1368
1403
|
},
|
|
@@ -1411,7 +1446,7 @@ function watchIgnorable(source, cb, options = {}) {
|
|
|
1411
1446
|
let ignorePrevAsyncUpdates;
|
|
1412
1447
|
let stop;
|
|
1413
1448
|
if (watchOptions.flush === "sync") {
|
|
1414
|
-
const ignore =
|
|
1449
|
+
const ignore = shallowRef(false);
|
|
1415
1450
|
ignorePrevAsyncUpdates = () => {
|
|
1416
1451
|
};
|
|
1417
1452
|
ignoreUpdates = (updater) => {
|
|
@@ -1429,8 +1464,8 @@ function watchIgnorable(source, cb, options = {}) {
|
|
|
1429
1464
|
);
|
|
1430
1465
|
} else {
|
|
1431
1466
|
const disposables = [];
|
|
1432
|
-
const ignoreCounter =
|
|
1433
|
-
const syncCounter =
|
|
1467
|
+
const ignoreCounter = shallowRef(0);
|
|
1468
|
+
const syncCounter = shallowRef(0);
|
|
1434
1469
|
ignorePrevAsyncUpdates = () => {
|
|
1435
1470
|
ignoreCounter.value = syncCounter.value;
|
|
1436
1471
|
};
|
|
@@ -1539,8 +1574,8 @@ function getWatchSources(sources) {
|
|
|
1539
1574
|
if (isReactive(sources))
|
|
1540
1575
|
return sources;
|
|
1541
1576
|
if (Array.isArray(sources))
|
|
1542
|
-
return sources.map((item) => toValue(item));
|
|
1543
|
-
return toValue(sources);
|
|
1577
|
+
return sources.map((item) => toValue$1(item));
|
|
1578
|
+
return toValue$1(sources);
|
|
1544
1579
|
}
|
|
1545
1580
|
function getOldValue(source) {
|
|
1546
1581
|
return Array.isArray(source) ? source.map(() => void 0) : void 0;
|
|
@@ -1579,7 +1614,7 @@ function computedAsync(evaluationCallback, initialState, optionsOrRef) {
|
|
|
1579
1614
|
shallow = true,
|
|
1580
1615
|
onError = noop
|
|
1581
1616
|
} = options;
|
|
1582
|
-
const started =
|
|
1617
|
+
const started = shallowRef(!lazy);
|
|
1583
1618
|
const current = shallow ? shallowRef(initialState) : ref(initialState);
|
|
1584
1619
|
let counter = 0;
|
|
1585
1620
|
watchEffect(async (onInvalidate) => {
|
|
@@ -1652,12 +1687,16 @@ function createReusableTemplate(options = {}) {
|
|
|
1652
1687
|
});
|
|
1653
1688
|
const reuse = /* #__PURE__ */ defineComponent({
|
|
1654
1689
|
inheritAttrs,
|
|
1655
|
-
|
|
1690
|
+
props: options.props,
|
|
1691
|
+
setup(props, { attrs, slots }) {
|
|
1656
1692
|
return () => {
|
|
1657
1693
|
var _a;
|
|
1658
1694
|
if (!render.value && process.env.NODE_ENV !== "production")
|
|
1659
1695
|
throw new Error("[VueUse] Failed to find the definition of reusable template");
|
|
1660
|
-
const vnode = (_a = render.value) == null ? void 0 : _a.call(render, {
|
|
1696
|
+
const vnode = (_a = render.value) == null ? void 0 : _a.call(render, {
|
|
1697
|
+
...options.props == null ? keysToCamelKebabCase(attrs) : props,
|
|
1698
|
+
$slots: slots
|
|
1699
|
+
});
|
|
1661
1700
|
return inheritAttrs && (vnode == null ? void 0 : vnode.length) === 1 ? vnode[0] : vnode;
|
|
1662
1701
|
};
|
|
1663
1702
|
}
|
|
@@ -1724,7 +1763,7 @@ function createTemplatePromise(options = {}) {
|
|
|
1724
1763
|
|
|
1725
1764
|
function createUnrefFn(fn) {
|
|
1726
1765
|
return function(...args) {
|
|
1727
|
-
return fn.apply(this, args.map((i) => toValue(i)));
|
|
1766
|
+
return fn.apply(this, args.map((i) => toValue$1(i)));
|
|
1728
1767
|
};
|
|
1729
1768
|
}
|
|
1730
1769
|
|
|
@@ -1735,72 +1774,73 @@ const defaultLocation = isClient ? window.location : void 0;
|
|
|
1735
1774
|
|
|
1736
1775
|
function unrefElement(elRef) {
|
|
1737
1776
|
var _a;
|
|
1738
|
-
const plain = toValue(elRef);
|
|
1777
|
+
const plain = toValue$1(elRef);
|
|
1739
1778
|
return (_a = plain == null ? void 0 : plain.$el) != null ? _a : plain;
|
|
1740
1779
|
}
|
|
1741
1780
|
|
|
1742
1781
|
function useEventListener(...args) {
|
|
1743
|
-
let target;
|
|
1744
|
-
let events;
|
|
1745
|
-
let listeners;
|
|
1746
|
-
let options;
|
|
1747
|
-
if (typeof args[0] === "string" || Array.isArray(args[0])) {
|
|
1748
|
-
[events, listeners, options] = args;
|
|
1749
|
-
target = defaultWindow;
|
|
1750
|
-
} else {
|
|
1751
|
-
[target, events, listeners, options] = args;
|
|
1752
|
-
}
|
|
1753
|
-
if (!target)
|
|
1754
|
-
return noop;
|
|
1755
|
-
if (!Array.isArray(events))
|
|
1756
|
-
events = [events];
|
|
1757
|
-
if (!Array.isArray(listeners))
|
|
1758
|
-
listeners = [listeners];
|
|
1759
1782
|
const cleanups = [];
|
|
1760
1783
|
const cleanup = () => {
|
|
1761
1784
|
cleanups.forEach((fn) => fn());
|
|
1762
1785
|
cleanups.length = 0;
|
|
1763
1786
|
};
|
|
1764
|
-
const register = (el, event, listener,
|
|
1765
|
-
el.addEventListener(event, listener,
|
|
1766
|
-
return () => el.removeEventListener(event, listener,
|
|
1787
|
+
const register = (el, event, listener, options) => {
|
|
1788
|
+
el.addEventListener(event, listener, options);
|
|
1789
|
+
return () => el.removeEventListener(event, listener, options);
|
|
1767
1790
|
};
|
|
1768
|
-
const
|
|
1769
|
-
|
|
1770
|
-
(
|
|
1791
|
+
const firstParamTargets = computed(() => {
|
|
1792
|
+
const test = toArray(toValue$1(args[0])).filter((e) => e != null);
|
|
1793
|
+
return test.every((e) => typeof e !== "string") ? test : void 0;
|
|
1794
|
+
});
|
|
1795
|
+
const stopWatch = watchImmediate(
|
|
1796
|
+
() => {
|
|
1797
|
+
var _a, _b;
|
|
1798
|
+
return [
|
|
1799
|
+
(_b = (_a = firstParamTargets.value) == null ? void 0 : _a.map((e) => unrefElement(e))) != null ? _b : [defaultWindow].filter((e) => e != null),
|
|
1800
|
+
toArray(toValue$1(firstParamTargets.value ? args[1] : args[0])),
|
|
1801
|
+
toArray(unref(firstParamTargets.value ? args[2] : args[1])),
|
|
1802
|
+
// @ts-expect-error - TypeScript gets the correct types, but somehow still complains
|
|
1803
|
+
toValue$1(firstParamTargets.value ? args[3] : args[2])
|
|
1804
|
+
];
|
|
1805
|
+
},
|
|
1806
|
+
([raw_targets, raw_events, raw_listeners, raw_options]) => {
|
|
1771
1807
|
cleanup();
|
|
1772
|
-
if (!
|
|
1808
|
+
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))
|
|
1773
1809
|
return;
|
|
1774
|
-
const optionsClone = isObject(
|
|
1810
|
+
const optionsClone = isObject(raw_options) ? { ...raw_options } : raw_options;
|
|
1775
1811
|
cleanups.push(
|
|
1776
|
-
...
|
|
1777
|
-
|
|
1778
|
-
|
|
1812
|
+
...raw_targets.flatMap(
|
|
1813
|
+
(el) => raw_events.flatMap(
|
|
1814
|
+
(event) => raw_listeners.map((listener) => register(el, event, listener, optionsClone))
|
|
1815
|
+
)
|
|
1816
|
+
)
|
|
1779
1817
|
);
|
|
1780
1818
|
},
|
|
1781
|
-
{
|
|
1819
|
+
{ flush: "post" }
|
|
1782
1820
|
);
|
|
1783
1821
|
const stop = () => {
|
|
1784
1822
|
stopWatch();
|
|
1785
1823
|
cleanup();
|
|
1786
1824
|
};
|
|
1787
|
-
tryOnScopeDispose(
|
|
1825
|
+
tryOnScopeDispose(cleanup);
|
|
1788
1826
|
return stop;
|
|
1789
1827
|
}
|
|
1790
1828
|
|
|
1791
1829
|
let _iOSWorkaround = false;
|
|
1792
1830
|
function onClickOutside(target, handler, options = {}) {
|
|
1793
|
-
const { window = defaultWindow, ignore = [], capture = true, detectIframe = false } = options;
|
|
1794
|
-
if (!window)
|
|
1795
|
-
return noop;
|
|
1831
|
+
const { window = defaultWindow, ignore = [], capture = true, detectIframe = false, controls = false } = options;
|
|
1832
|
+
if (!window) {
|
|
1833
|
+
return controls ? { stop: noop, cancel: noop, trigger: noop } : noop;
|
|
1834
|
+
}
|
|
1796
1835
|
if (isIOS && !_iOSWorkaround) {
|
|
1797
1836
|
_iOSWorkaround = true;
|
|
1798
|
-
|
|
1799
|
-
window.document.
|
|
1837
|
+
const listenerOptions = { passive: true };
|
|
1838
|
+
Array.from(window.document.body.children).forEach((el) => useEventListener(el, "click", noop, listenerOptions));
|
|
1839
|
+
useEventListener(window.document.documentElement, "click", noop, listenerOptions);
|
|
1800
1840
|
}
|
|
1801
1841
|
let shouldListen = true;
|
|
1802
1842
|
const shouldIgnore = (event) => {
|
|
1803
|
-
return toValue(ignore).some((target2) => {
|
|
1843
|
+
return toValue$1(ignore).some((target2) => {
|
|
1804
1844
|
if (typeof target2 === "string") {
|
|
1805
1845
|
return Array.from(window.document.querySelectorAll(target2)).some((el) => el === event.target || event.composedPath().includes(el));
|
|
1806
1846
|
} else {
|
|
@@ -1810,11 +1850,11 @@ function onClickOutside(target, handler, options = {}) {
|
|
|
1810
1850
|
});
|
|
1811
1851
|
};
|
|
1812
1852
|
function hasMultipleRoots(target2) {
|
|
1813
|
-
const vm = toValue(target2);
|
|
1853
|
+
const vm = toValue$1(target2);
|
|
1814
1854
|
return vm && vm.$.subTree.shapeFlag === 16;
|
|
1815
1855
|
}
|
|
1816
1856
|
function checkMultipleRoots(target2, event) {
|
|
1817
|
-
const vm = toValue(target2);
|
|
1857
|
+
const vm = toValue$1(target2);
|
|
1818
1858
|
const children = vm.$.subTree && vm.$.subTree.children;
|
|
1819
1859
|
if (children == null || !Array.isArray(children))
|
|
1820
1860
|
return false;
|
|
@@ -1828,7 +1868,7 @@ function onClickOutside(target, handler, options = {}) {
|
|
|
1828
1868
|
return;
|
|
1829
1869
|
if (!el || el === event.target || event.composedPath().includes(el))
|
|
1830
1870
|
return;
|
|
1831
|
-
if (event.detail === 0)
|
|
1871
|
+
if ("detail" in event && event.detail === 0)
|
|
1832
1872
|
shouldListen = !shouldIgnore(event);
|
|
1833
1873
|
if (!shouldListen) {
|
|
1834
1874
|
shouldListen = true;
|
|
@@ -1859,12 +1899,126 @@ function onClickOutside(target, handler, options = {}) {
|
|
|
1859
1899
|
handler(event);
|
|
1860
1900
|
}
|
|
1861
1901
|
}, 0);
|
|
1862
|
-
})
|
|
1902
|
+
}, { passive: true })
|
|
1863
1903
|
].filter(Boolean);
|
|
1864
1904
|
const stop = () => cleanup.forEach((fn) => fn());
|
|
1905
|
+
if (controls) {
|
|
1906
|
+
return {
|
|
1907
|
+
stop,
|
|
1908
|
+
cancel: () => {
|
|
1909
|
+
shouldListen = false;
|
|
1910
|
+
},
|
|
1911
|
+
trigger: (event) => {
|
|
1912
|
+
shouldListen = true;
|
|
1913
|
+
listener(event);
|
|
1914
|
+
shouldListen = false;
|
|
1915
|
+
}
|
|
1916
|
+
};
|
|
1917
|
+
}
|
|
1865
1918
|
return stop;
|
|
1866
1919
|
}
|
|
1867
1920
|
|
|
1921
|
+
function useMounted() {
|
|
1922
|
+
const isMounted = shallowRef(false);
|
|
1923
|
+
const instance = getCurrentInstance();
|
|
1924
|
+
if (instance) {
|
|
1925
|
+
onMounted(() => {
|
|
1926
|
+
isMounted.value = true;
|
|
1927
|
+
}, instance);
|
|
1928
|
+
}
|
|
1929
|
+
return isMounted;
|
|
1930
|
+
}
|
|
1931
|
+
|
|
1932
|
+
function useSupported(callback) {
|
|
1933
|
+
const isMounted = useMounted();
|
|
1934
|
+
return computed(() => {
|
|
1935
|
+
isMounted.value;
|
|
1936
|
+
return Boolean(callback());
|
|
1937
|
+
});
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1940
|
+
function useMutationObserver(target, callback, options = {}) {
|
|
1941
|
+
const { window = defaultWindow, ...mutationOptions } = options;
|
|
1942
|
+
let observer;
|
|
1943
|
+
const isSupported = useSupported(() => window && "MutationObserver" in window);
|
|
1944
|
+
const cleanup = () => {
|
|
1945
|
+
if (observer) {
|
|
1946
|
+
observer.disconnect();
|
|
1947
|
+
observer = void 0;
|
|
1948
|
+
}
|
|
1949
|
+
};
|
|
1950
|
+
const targets = computed(() => {
|
|
1951
|
+
const value = toValue$1(target);
|
|
1952
|
+
const items = toArray(value).map(unrefElement).filter(notNullish);
|
|
1953
|
+
return new Set(items);
|
|
1954
|
+
});
|
|
1955
|
+
const stopWatch = watch(
|
|
1956
|
+
() => targets.value,
|
|
1957
|
+
(targets2) => {
|
|
1958
|
+
cleanup();
|
|
1959
|
+
if (isSupported.value && targets2.size) {
|
|
1960
|
+
observer = new MutationObserver(callback);
|
|
1961
|
+
targets2.forEach((el) => observer.observe(el, mutationOptions));
|
|
1962
|
+
}
|
|
1963
|
+
},
|
|
1964
|
+
{ immediate: true, flush: "post" }
|
|
1965
|
+
);
|
|
1966
|
+
const takeRecords = () => {
|
|
1967
|
+
return observer == null ? void 0 : observer.takeRecords();
|
|
1968
|
+
};
|
|
1969
|
+
const stop = () => {
|
|
1970
|
+
stopWatch();
|
|
1971
|
+
cleanup();
|
|
1972
|
+
};
|
|
1973
|
+
tryOnScopeDispose(stop);
|
|
1974
|
+
return {
|
|
1975
|
+
isSupported,
|
|
1976
|
+
stop,
|
|
1977
|
+
takeRecords
|
|
1978
|
+
};
|
|
1979
|
+
}
|
|
1980
|
+
|
|
1981
|
+
function onElementRemoval(target, callback, options = {}) {
|
|
1982
|
+
const {
|
|
1983
|
+
window = defaultWindow,
|
|
1984
|
+
document = window == null ? void 0 : window.document,
|
|
1985
|
+
flush = "sync"
|
|
1986
|
+
} = options;
|
|
1987
|
+
if (!window || !document)
|
|
1988
|
+
return noop;
|
|
1989
|
+
let stopFn;
|
|
1990
|
+
const cleanupAndUpdate = (fn) => {
|
|
1991
|
+
stopFn == null ? void 0 : stopFn();
|
|
1992
|
+
stopFn = fn;
|
|
1993
|
+
};
|
|
1994
|
+
const stopWatch = watchEffect(() => {
|
|
1995
|
+
const el = unrefElement(target);
|
|
1996
|
+
if (el) {
|
|
1997
|
+
const { stop } = useMutationObserver(
|
|
1998
|
+
document,
|
|
1999
|
+
(mutationsList) => {
|
|
2000
|
+
const targetRemoved = mutationsList.map((mutation) => [...mutation.removedNodes]).flat().some((node) => node === el || node.contains(el));
|
|
2001
|
+
if (targetRemoved) {
|
|
2002
|
+
callback(mutationsList);
|
|
2003
|
+
}
|
|
2004
|
+
},
|
|
2005
|
+
{
|
|
2006
|
+
window,
|
|
2007
|
+
childList: true,
|
|
2008
|
+
subtree: true
|
|
2009
|
+
}
|
|
2010
|
+
);
|
|
2011
|
+
cleanupAndUpdate(stop);
|
|
2012
|
+
}
|
|
2013
|
+
}, { flush });
|
|
2014
|
+
const stopHandle = () => {
|
|
2015
|
+
stopWatch();
|
|
2016
|
+
cleanupAndUpdate();
|
|
2017
|
+
};
|
|
2018
|
+
tryOnScopeDispose(stopHandle);
|
|
2019
|
+
return stopHandle;
|
|
2020
|
+
}
|
|
2021
|
+
|
|
1868
2022
|
function createKeyPredicate(keyFilter) {
|
|
1869
2023
|
if (typeof keyFilter === "function")
|
|
1870
2024
|
return keyFilter;
|
|
@@ -1903,7 +2057,7 @@ function onKeyStroke(...args) {
|
|
|
1903
2057
|
} = options;
|
|
1904
2058
|
const predicate = createKeyPredicate(key);
|
|
1905
2059
|
const listener = (e) => {
|
|
1906
|
-
if (e.repeat && toValue(dedupe))
|
|
2060
|
+
if (e.repeat && toValue$1(dedupe))
|
|
1907
2061
|
return;
|
|
1908
2062
|
if (predicate(e))
|
|
1909
2063
|
handler(e);
|
|
@@ -2067,66 +2221,6 @@ function templateRef(key, initialValue = null) {
|
|
|
2067
2221
|
return element;
|
|
2068
2222
|
}
|
|
2069
2223
|
|
|
2070
|
-
function useMounted() {
|
|
2071
|
-
const isMounted = ref(false);
|
|
2072
|
-
const instance = getCurrentInstance();
|
|
2073
|
-
if (instance) {
|
|
2074
|
-
onMounted(() => {
|
|
2075
|
-
isMounted.value = true;
|
|
2076
|
-
}, instance);
|
|
2077
|
-
}
|
|
2078
|
-
return isMounted;
|
|
2079
|
-
}
|
|
2080
|
-
|
|
2081
|
-
function useSupported(callback) {
|
|
2082
|
-
const isMounted = useMounted();
|
|
2083
|
-
return computed(() => {
|
|
2084
|
-
isMounted.value;
|
|
2085
|
-
return Boolean(callback());
|
|
2086
|
-
});
|
|
2087
|
-
}
|
|
2088
|
-
|
|
2089
|
-
function useMutationObserver(target, callback, options = {}) {
|
|
2090
|
-
const { window = defaultWindow, ...mutationOptions } = options;
|
|
2091
|
-
let observer;
|
|
2092
|
-
const isSupported = useSupported(() => window && "MutationObserver" in window);
|
|
2093
|
-
const cleanup = () => {
|
|
2094
|
-
if (observer) {
|
|
2095
|
-
observer.disconnect();
|
|
2096
|
-
observer = void 0;
|
|
2097
|
-
}
|
|
2098
|
-
};
|
|
2099
|
-
const targets = computed(() => {
|
|
2100
|
-
const value = toValue(target);
|
|
2101
|
-
const items = (Array.isArray(value) ? value : [value]).map(unrefElement).filter(notNullish);
|
|
2102
|
-
return new Set(items);
|
|
2103
|
-
});
|
|
2104
|
-
const stopWatch = watch(
|
|
2105
|
-
() => targets.value,
|
|
2106
|
-
(targets2) => {
|
|
2107
|
-
cleanup();
|
|
2108
|
-
if (isSupported.value && targets2.size) {
|
|
2109
|
-
observer = new MutationObserver(callback);
|
|
2110
|
-
targets2.forEach((el) => observer.observe(el, mutationOptions));
|
|
2111
|
-
}
|
|
2112
|
-
},
|
|
2113
|
-
{ immediate: true, flush: "post" }
|
|
2114
|
-
);
|
|
2115
|
-
const takeRecords = () => {
|
|
2116
|
-
return observer == null ? void 0 : observer.takeRecords();
|
|
2117
|
-
};
|
|
2118
|
-
const stop = () => {
|
|
2119
|
-
stopWatch();
|
|
2120
|
-
cleanup();
|
|
2121
|
-
};
|
|
2122
|
-
tryOnScopeDispose(stop);
|
|
2123
|
-
return {
|
|
2124
|
-
isSupported,
|
|
2125
|
-
stop,
|
|
2126
|
-
takeRecords
|
|
2127
|
-
};
|
|
2128
|
-
}
|
|
2129
|
-
|
|
2130
2224
|
function useActiveElement(options = {}) {
|
|
2131
2225
|
var _a;
|
|
2132
2226
|
const {
|
|
@@ -2149,23 +2243,29 @@ function useActiveElement(options = {}) {
|
|
|
2149
2243
|
activeElement.value = getDeepActiveElement();
|
|
2150
2244
|
};
|
|
2151
2245
|
if (window) {
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2246
|
+
const listenerOptions = {
|
|
2247
|
+
capture: true,
|
|
2248
|
+
passive: true
|
|
2249
|
+
};
|
|
2250
|
+
useEventListener(
|
|
2251
|
+
window,
|
|
2252
|
+
"blur",
|
|
2253
|
+
(event) => {
|
|
2254
|
+
if (event.relatedTarget !== null)
|
|
2255
|
+
return;
|
|
2256
|
+
trigger();
|
|
2257
|
+
},
|
|
2258
|
+
listenerOptions
|
|
2259
|
+
);
|
|
2260
|
+
useEventListener(
|
|
2261
|
+
window,
|
|
2262
|
+
"focus",
|
|
2263
|
+
trigger,
|
|
2264
|
+
listenerOptions
|
|
2265
|
+
);
|
|
2158
2266
|
}
|
|
2159
2267
|
if (triggerOnRemoval) {
|
|
2160
|
-
|
|
2161
|
-
mutations.filter((m) => m.removedNodes.length).map((n) => Array.from(n.removedNodes)).flat().forEach((node) => {
|
|
2162
|
-
if (node === activeElement.value)
|
|
2163
|
-
trigger();
|
|
2164
|
-
});
|
|
2165
|
-
}, {
|
|
2166
|
-
childList: true,
|
|
2167
|
-
subtree: true
|
|
2168
|
-
});
|
|
2268
|
+
onElementRemoval(activeElement, trigger, { document });
|
|
2169
2269
|
}
|
|
2170
2270
|
trigger();
|
|
2171
2271
|
return activeElement;
|
|
@@ -2175,10 +2275,13 @@ function useRafFn(fn, options = {}) {
|
|
|
2175
2275
|
const {
|
|
2176
2276
|
immediate = true,
|
|
2177
2277
|
fpsLimit = void 0,
|
|
2178
|
-
window = defaultWindow
|
|
2278
|
+
window = defaultWindow,
|
|
2279
|
+
once = false
|
|
2179
2280
|
} = options;
|
|
2180
|
-
const isActive =
|
|
2181
|
-
const intervalLimit =
|
|
2281
|
+
const isActive = shallowRef(false);
|
|
2282
|
+
const intervalLimit = computed(() => {
|
|
2283
|
+
return fpsLimit ? 1e3 / toValue$1(fpsLimit) : null;
|
|
2284
|
+
});
|
|
2182
2285
|
let previousFrameTimestamp = 0;
|
|
2183
2286
|
let rafId = null;
|
|
2184
2287
|
function loop(timestamp) {
|
|
@@ -2187,12 +2290,17 @@ function useRafFn(fn, options = {}) {
|
|
|
2187
2290
|
if (!previousFrameTimestamp)
|
|
2188
2291
|
previousFrameTimestamp = timestamp;
|
|
2189
2292
|
const delta = timestamp - previousFrameTimestamp;
|
|
2190
|
-
if (intervalLimit && delta < intervalLimit) {
|
|
2293
|
+
if (intervalLimit.value && delta < intervalLimit.value) {
|
|
2191
2294
|
rafId = window.requestAnimationFrame(loop);
|
|
2192
2295
|
return;
|
|
2193
2296
|
}
|
|
2194
2297
|
previousFrameTimestamp = timestamp;
|
|
2195
2298
|
fn({ delta, timestamp });
|
|
2299
|
+
if (once) {
|
|
2300
|
+
isActive.value = false;
|
|
2301
|
+
rafId = null;
|
|
2302
|
+
return;
|
|
2303
|
+
}
|
|
2196
2304
|
rafId = window.requestAnimationFrame(loop);
|
|
2197
2305
|
}
|
|
2198
2306
|
function resume() {
|
|
@@ -2349,8 +2457,11 @@ function useAnimate(target, keyframes, options) {
|
|
|
2349
2457
|
}
|
|
2350
2458
|
};
|
|
2351
2459
|
watch(() => unrefElement(target), (el) => {
|
|
2352
|
-
if (el)
|
|
2460
|
+
if (el) {
|
|
2353
2461
|
update();
|
|
2462
|
+
} else {
|
|
2463
|
+
animate.value = void 0;
|
|
2464
|
+
}
|
|
2354
2465
|
});
|
|
2355
2466
|
watch(() => keyframes, (value) => {
|
|
2356
2467
|
if (animate.value)
|
|
@@ -2358,7 +2469,7 @@ function useAnimate(target, keyframes, options) {
|
|
|
2358
2469
|
if (!unrefElement(target) && animate.value) {
|
|
2359
2470
|
animate.value.effect = new KeyframeEffect(
|
|
2360
2471
|
unrefElement(target),
|
|
2361
|
-
toValue(value),
|
|
2472
|
+
toValue$1(value),
|
|
2362
2473
|
animateOptions
|
|
2363
2474
|
);
|
|
2364
2475
|
}
|
|
@@ -2370,7 +2481,7 @@ function useAnimate(target, keyframes, options) {
|
|
|
2370
2481
|
if (!isSupported.value || !el)
|
|
2371
2482
|
return;
|
|
2372
2483
|
if (!animate.value)
|
|
2373
|
-
animate.value = el.animate(toValue(keyframes), animateOptions);
|
|
2484
|
+
animate.value = el.animate(toValue$1(keyframes), animateOptions);
|
|
2374
2485
|
if (persist)
|
|
2375
2486
|
animate.value.persist();
|
|
2376
2487
|
if (_playbackRate !== 1)
|
|
@@ -2381,12 +2492,13 @@ function useAnimate(target, keyframes, options) {
|
|
|
2381
2492
|
syncResume();
|
|
2382
2493
|
onReady == null ? void 0 : onReady(animate.value);
|
|
2383
2494
|
}
|
|
2384
|
-
|
|
2495
|
+
const listenerOptions = { passive: true };
|
|
2496
|
+
useEventListener(animate, ["cancel", "finish", "remove"], syncPause, listenerOptions);
|
|
2385
2497
|
useEventListener(animate, "finish", () => {
|
|
2386
2498
|
var _a;
|
|
2387
2499
|
if (commitStyles)
|
|
2388
2500
|
(_a = animate.value) == null ? void 0 : _a.commitStyles();
|
|
2389
|
-
});
|
|
2501
|
+
}, listenerOptions);
|
|
2390
2502
|
const { resume: resumeRef, pause: pauseRef } = useRafFn(() => {
|
|
2391
2503
|
if (!animate.value)
|
|
2392
2504
|
return;
|
|
@@ -2441,7 +2553,7 @@ function useAsyncQueue(tasks, options) {
|
|
|
2441
2553
|
};
|
|
2442
2554
|
const initialResult = Array.from(Array.from({ length: tasks.length }), () => ({ state: promiseState.pending, data: null }));
|
|
2443
2555
|
const result = reactive(initialResult);
|
|
2444
|
-
const activeIndex =
|
|
2556
|
+
const activeIndex = shallowRef(-1);
|
|
2445
2557
|
if (!tasks || tasks.length === 0) {
|
|
2446
2558
|
onFinished();
|
|
2447
2559
|
return {
|
|
@@ -2510,8 +2622,8 @@ function useAsyncState(promise, initialState, options) {
|
|
|
2510
2622
|
throwError
|
|
2511
2623
|
} = options != null ? options : {};
|
|
2512
2624
|
const state = shallow ? shallowRef(initialState) : ref(initialState);
|
|
2513
|
-
const isReady =
|
|
2514
|
-
const isLoading =
|
|
2625
|
+
const isReady = shallowRef(false);
|
|
2626
|
+
const isLoading = shallowRef(false);
|
|
2515
2627
|
const error = shallowRef(void 0);
|
|
2516
2628
|
async function execute(delay2 = 0, ...args) {
|
|
2517
2629
|
if (resetOnExecute)
|
|
@@ -2537,8 +2649,9 @@ function useAsyncState(promise, initialState, options) {
|
|
|
2537
2649
|
}
|
|
2538
2650
|
return state.value;
|
|
2539
2651
|
}
|
|
2540
|
-
if (immediate)
|
|
2652
|
+
if (immediate) {
|
|
2541
2653
|
execute(delay);
|
|
2654
|
+
}
|
|
2542
2655
|
const shell = {
|
|
2543
2656
|
state,
|
|
2544
2657
|
isReady,
|
|
@@ -2580,14 +2693,14 @@ function getDefaultSerialization(target) {
|
|
|
2580
2693
|
}
|
|
2581
2694
|
|
|
2582
2695
|
function useBase64(target, options) {
|
|
2583
|
-
const base64 =
|
|
2584
|
-
const promise =
|
|
2696
|
+
const base64 = shallowRef("");
|
|
2697
|
+
const promise = shallowRef();
|
|
2585
2698
|
function execute() {
|
|
2586
2699
|
if (!isClient)
|
|
2587
2700
|
return;
|
|
2588
2701
|
promise.value = new Promise((resolve, reject) => {
|
|
2589
2702
|
try {
|
|
2590
|
-
const _target = toValue(target);
|
|
2703
|
+
const _target = toValue$1(target);
|
|
2591
2704
|
if (_target == null) {
|
|
2592
2705
|
resolve("");
|
|
2593
2706
|
} else if (typeof _target === "string") {
|
|
@@ -2620,7 +2733,9 @@ function useBase64(target, options) {
|
|
|
2620
2733
|
reject(error);
|
|
2621
2734
|
}
|
|
2622
2735
|
});
|
|
2623
|
-
promise.value.then((res) =>
|
|
2736
|
+
promise.value.then((res) => {
|
|
2737
|
+
base64.value = (options == null ? void 0 : options.dataUrl) === false ? res.replace(/^data:.*?;base64,/, "") : res;
|
|
2738
|
+
});
|
|
2624
2739
|
return promise.value;
|
|
2625
2740
|
}
|
|
2626
2741
|
if (isRef(target) || typeof target === "function")
|
|
@@ -2660,10 +2775,10 @@ function useBattery(options = {}) {
|
|
|
2660
2775
|
const { navigator = defaultNavigator } = options;
|
|
2661
2776
|
const events = ["chargingchange", "chargingtimechange", "dischargingtimechange", "levelchange"];
|
|
2662
2777
|
const isSupported = useSupported(() => navigator && "getBattery" in navigator && typeof navigator.getBattery === "function");
|
|
2663
|
-
const charging =
|
|
2664
|
-
const chargingTime =
|
|
2665
|
-
const dischargingTime =
|
|
2666
|
-
const level =
|
|
2778
|
+
const charging = shallowRef(false);
|
|
2779
|
+
const chargingTime = shallowRef(0);
|
|
2780
|
+
const dischargingTime = shallowRef(0);
|
|
2781
|
+
const level = shallowRef(1);
|
|
2667
2782
|
let battery;
|
|
2668
2783
|
function updateBatteryInfo() {
|
|
2669
2784
|
charging.value = this.charging;
|
|
@@ -2697,7 +2812,7 @@ function useBluetooth(options) {
|
|
|
2697
2812
|
navigator = defaultNavigator
|
|
2698
2813
|
} = options || {};
|
|
2699
2814
|
const isSupported = useSupported(() => navigator && "bluetooth" in navigator);
|
|
2700
|
-
const device = shallowRef(
|
|
2815
|
+
const device = shallowRef();
|
|
2701
2816
|
const error = shallowRef(null);
|
|
2702
2817
|
watch(device, () => {
|
|
2703
2818
|
connectToBluetoothGATTServer();
|
|
@@ -2718,18 +2833,20 @@ function useBluetooth(options) {
|
|
|
2718
2833
|
error.value = err;
|
|
2719
2834
|
}
|
|
2720
2835
|
}
|
|
2721
|
-
const server =
|
|
2722
|
-
const isConnected =
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2836
|
+
const server = shallowRef();
|
|
2837
|
+
const isConnected = shallowRef(false);
|
|
2838
|
+
function reset() {
|
|
2839
|
+
isConnected.value = false;
|
|
2840
|
+
device.value = void 0;
|
|
2841
|
+
server.value = void 0;
|
|
2842
|
+
}
|
|
2726
2843
|
async function connectToBluetoothGATTServer() {
|
|
2727
2844
|
error.value = null;
|
|
2728
2845
|
if (device.value && device.value.gatt) {
|
|
2729
|
-
device
|
|
2730
|
-
});
|
|
2846
|
+
useEventListener(device, "gattserverdisconnected", reset, { passive: true });
|
|
2731
2847
|
try {
|
|
2732
2848
|
server.value = await device.value.gatt.connect();
|
|
2849
|
+
isConnected.value = server.value.connected;
|
|
2733
2850
|
} catch (err) {
|
|
2734
2851
|
error.value = err;
|
|
2735
2852
|
}
|
|
@@ -2747,7 +2864,7 @@ function useBluetooth(options) {
|
|
|
2747
2864
|
});
|
|
2748
2865
|
return {
|
|
2749
2866
|
isSupported,
|
|
2750
|
-
isConnected,
|
|
2867
|
+
isConnected: readonly(isConnected),
|
|
2751
2868
|
// Device:
|
|
2752
2869
|
device,
|
|
2753
2870
|
requestDevice,
|
|
@@ -2758,39 +2875,54 @@ function useBluetooth(options) {
|
|
|
2758
2875
|
};
|
|
2759
2876
|
}
|
|
2760
2877
|
|
|
2878
|
+
const ssrWidthSymbol = Symbol("vueuse-ssr-width");
|
|
2879
|
+
function useSSRWidth() {
|
|
2880
|
+
const ssrWidth = hasInjectionContext() ? injectLocal(ssrWidthSymbol, null) : null;
|
|
2881
|
+
return typeof ssrWidth === "number" ? ssrWidth : void 0;
|
|
2882
|
+
}
|
|
2883
|
+
function provideSSRWidth(width, app) {
|
|
2884
|
+
if (app !== void 0) {
|
|
2885
|
+
app.provide(ssrWidthSymbol, width);
|
|
2886
|
+
} else {
|
|
2887
|
+
provideLocal(ssrWidthSymbol, width);
|
|
2888
|
+
}
|
|
2889
|
+
}
|
|
2890
|
+
|
|
2761
2891
|
function useMediaQuery(query, options = {}) {
|
|
2762
|
-
const { window = defaultWindow } = options;
|
|
2892
|
+
const { window = defaultWindow, ssrWidth = useSSRWidth() } = options;
|
|
2763
2893
|
const isSupported = useSupported(() => window && "matchMedia" in window && typeof window.matchMedia === "function");
|
|
2764
|
-
|
|
2765
|
-
const
|
|
2894
|
+
const ssrSupport = ref(typeof ssrWidth === "number");
|
|
2895
|
+
const mediaQuery = shallowRef();
|
|
2896
|
+
const matches = shallowRef(false);
|
|
2766
2897
|
const handler = (event) => {
|
|
2767
2898
|
matches.value = event.matches;
|
|
2768
2899
|
};
|
|
2769
|
-
|
|
2770
|
-
if (
|
|
2900
|
+
watchEffect(() => {
|
|
2901
|
+
if (ssrSupport.value) {
|
|
2902
|
+
ssrSupport.value = !isSupported.value;
|
|
2903
|
+
const queryStrings = toValue$1(query).split(",");
|
|
2904
|
+
matches.value = queryStrings.some((queryString) => {
|
|
2905
|
+
const not = queryString.includes("not all");
|
|
2906
|
+
const minWidth = queryString.match(/\(\s*min-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/);
|
|
2907
|
+
const maxWidth = queryString.match(/\(\s*max-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/);
|
|
2908
|
+
let res = Boolean(minWidth || maxWidth);
|
|
2909
|
+
if (minWidth && res) {
|
|
2910
|
+
res = ssrWidth >= pxValue(minWidth[1]);
|
|
2911
|
+
}
|
|
2912
|
+
if (maxWidth && res) {
|
|
2913
|
+
res = ssrWidth <= pxValue(maxWidth[1]);
|
|
2914
|
+
}
|
|
2915
|
+
return not ? !res : res;
|
|
2916
|
+
});
|
|
2771
2917
|
return;
|
|
2772
|
-
|
|
2773
|
-
mediaQuery.removeEventListener("change", handler);
|
|
2774
|
-
else
|
|
2775
|
-
mediaQuery.removeListener(handler);
|
|
2776
|
-
};
|
|
2777
|
-
const stopWatch = watchEffect(() => {
|
|
2918
|
+
}
|
|
2778
2919
|
if (!isSupported.value)
|
|
2779
2920
|
return;
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
if ("addEventListener" in mediaQuery)
|
|
2783
|
-
mediaQuery.addEventListener("change", handler);
|
|
2784
|
-
else
|
|
2785
|
-
mediaQuery.addListener(handler);
|
|
2786
|
-
matches.value = mediaQuery.matches;
|
|
2921
|
+
mediaQuery.value = window.matchMedia(toValue$1(query));
|
|
2922
|
+
matches.value = mediaQuery.value.matches;
|
|
2787
2923
|
});
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
cleanup();
|
|
2791
|
-
mediaQuery = void 0;
|
|
2792
|
-
});
|
|
2793
|
-
return matches;
|
|
2924
|
+
useEventListener(mediaQuery, "change", handler, { passive: true });
|
|
2925
|
+
return computed(() => matches.value);
|
|
2794
2926
|
}
|
|
2795
2927
|
|
|
2796
2928
|
const breakpointsTailwind = {
|
|
@@ -2876,18 +3008,26 @@ const breakpointsElement = {
|
|
|
2876
3008
|
|
|
2877
3009
|
function useBreakpoints(breakpoints, options = {}) {
|
|
2878
3010
|
function getValue(k, delta) {
|
|
2879
|
-
let v = toValue(breakpoints[toValue(k)]);
|
|
3011
|
+
let v = toValue$1(breakpoints[toValue$1(k)]);
|
|
2880
3012
|
if (delta != null)
|
|
2881
3013
|
v = increaseWithUnit(v, delta);
|
|
2882
3014
|
if (typeof v === "number")
|
|
2883
3015
|
v = `${v}px`;
|
|
2884
3016
|
return v;
|
|
2885
3017
|
}
|
|
2886
|
-
const { window = defaultWindow, strategy = "min-width" } = options;
|
|
2887
|
-
|
|
3018
|
+
const { window = defaultWindow, strategy = "min-width", ssrWidth = useSSRWidth() } = options;
|
|
3019
|
+
const ssrSupport = typeof ssrWidth === "number";
|
|
3020
|
+
const mounted = ssrSupport ? shallowRef(false) : { value: true };
|
|
3021
|
+
if (ssrSupport) {
|
|
3022
|
+
tryOnMounted(() => mounted.value = !!window);
|
|
3023
|
+
}
|
|
3024
|
+
function match(query, size) {
|
|
3025
|
+
if (!mounted.value && ssrSupport) {
|
|
3026
|
+
return query === "min" ? ssrWidth >= pxValue(size) : ssrWidth <= pxValue(size);
|
|
3027
|
+
}
|
|
2888
3028
|
if (!window)
|
|
2889
3029
|
return false;
|
|
2890
|
-
return window.matchMedia(query).matches;
|
|
3030
|
+
return window.matchMedia(`(${query}-width: ${size})`).matches;
|
|
2891
3031
|
}
|
|
2892
3032
|
const greaterOrEqual = (k) => {
|
|
2893
3033
|
return useMediaQuery(() => `(min-width: ${getValue(k)})`, options);
|
|
@@ -2904,7 +3044,7 @@ function useBreakpoints(breakpoints, options = {}) {
|
|
|
2904
3044
|
return shortcuts;
|
|
2905
3045
|
}, {});
|
|
2906
3046
|
function current() {
|
|
2907
|
-
const points = Object.keys(breakpoints).map((
|
|
3047
|
+
const points = Object.keys(breakpoints).map((k) => [k, shortcutMethods[k], pxValue(getValue(k))]).sort((a, b) => a[2] - b[2]);
|
|
2908
3048
|
return computed(() => points.filter(([, v]) => v.value).map(([k]) => k));
|
|
2909
3049
|
}
|
|
2910
3050
|
return Object.assign(shortcutMethods, {
|
|
@@ -2920,24 +3060,24 @@ function useBreakpoints(breakpoints, options = {}) {
|
|
|
2920
3060
|
return useMediaQuery(() => `(min-width: ${getValue(a)}) and (max-width: ${getValue(b, -0.1)})`, options);
|
|
2921
3061
|
},
|
|
2922
3062
|
isGreater(k) {
|
|
2923
|
-
return match(
|
|
3063
|
+
return match("min", getValue(k, 0.1));
|
|
2924
3064
|
},
|
|
2925
3065
|
isGreaterOrEqual(k) {
|
|
2926
|
-
return match(
|
|
3066
|
+
return match("min", getValue(k));
|
|
2927
3067
|
},
|
|
2928
3068
|
isSmaller(k) {
|
|
2929
|
-
return match(
|
|
3069
|
+
return match("max", getValue(k, -0.1));
|
|
2930
3070
|
},
|
|
2931
3071
|
isSmallerOrEqual(k) {
|
|
2932
|
-
return match(
|
|
3072
|
+
return match("max", getValue(k));
|
|
2933
3073
|
},
|
|
2934
3074
|
isInBetween(a, b) {
|
|
2935
|
-
return match(
|
|
3075
|
+
return match("min", getValue(a)) && match("max", getValue(b, -0.1));
|
|
2936
3076
|
},
|
|
2937
3077
|
current,
|
|
2938
3078
|
active() {
|
|
2939
3079
|
const bps = current();
|
|
2940
|
-
return computed(() => bps.value.length === 0 ? "" : bps.value.at(-1));
|
|
3080
|
+
return computed(() => bps.value.length === 0 ? "" : bps.value.at(strategy === "min-width" ? -1 : 0));
|
|
2941
3081
|
}
|
|
2942
3082
|
});
|
|
2943
3083
|
}
|
|
@@ -2948,7 +3088,7 @@ function useBroadcastChannel(options) {
|
|
|
2948
3088
|
window = defaultWindow
|
|
2949
3089
|
} = options;
|
|
2950
3090
|
const isSupported = useSupported(() => window && "BroadcastChannel" in window);
|
|
2951
|
-
const isClosed =
|
|
3091
|
+
const isClosed = shallowRef(false);
|
|
2952
3092
|
const channel = ref();
|
|
2953
3093
|
const data = ref();
|
|
2954
3094
|
const error = shallowRef(null);
|
|
@@ -2965,15 +3105,18 @@ function useBroadcastChannel(options) {
|
|
|
2965
3105
|
tryOnMounted(() => {
|
|
2966
3106
|
error.value = null;
|
|
2967
3107
|
channel.value = new BroadcastChannel(name);
|
|
2968
|
-
|
|
3108
|
+
const listenerOptions = {
|
|
3109
|
+
passive: true
|
|
3110
|
+
};
|
|
3111
|
+
useEventListener(channel, "message", (e) => {
|
|
2969
3112
|
data.value = e.data;
|
|
2970
|
-
},
|
|
2971
|
-
channel
|
|
3113
|
+
}, listenerOptions);
|
|
3114
|
+
useEventListener(channel, "messageerror", (e) => {
|
|
2972
3115
|
error.value = e;
|
|
2973
|
-
},
|
|
2974
|
-
channel
|
|
3116
|
+
}, listenerOptions);
|
|
3117
|
+
useEventListener(channel, "close", () => {
|
|
2975
3118
|
isClosed.value = true;
|
|
2976
|
-
});
|
|
3119
|
+
}, listenerOptions);
|
|
2977
3120
|
});
|
|
2978
3121
|
}
|
|
2979
3122
|
tryOnScopeDispose(() => {
|
|
@@ -3005,8 +3148,8 @@ function useBrowserLocation(options = {}) {
|
|
|
3005
3148
|
const refs = Object.fromEntries(
|
|
3006
3149
|
WRITABLE_PROPERTIES.map((key) => [key, ref()])
|
|
3007
3150
|
);
|
|
3008
|
-
for (const [key,
|
|
3009
|
-
watch(
|
|
3151
|
+
for (const [key, ref] of objectEntries(refs)) {
|
|
3152
|
+
watch(ref, (value) => {
|
|
3010
3153
|
if (!(window == null ? void 0 : window.location) || window.location[key] === value)
|
|
3011
3154
|
return;
|
|
3012
3155
|
window.location[key] = value;
|
|
@@ -3028,8 +3171,9 @@ function useBrowserLocation(options = {}) {
|
|
|
3028
3171
|
};
|
|
3029
3172
|
const state = ref(buildState("load"));
|
|
3030
3173
|
if (window) {
|
|
3031
|
-
|
|
3032
|
-
useEventListener(window, "
|
|
3174
|
+
const listenerOptions = { passive: true };
|
|
3175
|
+
useEventListener(window, "popstate", () => state.value = buildState("popstate"), listenerOptions);
|
|
3176
|
+
useEventListener(window, "hashchange", () => state.value = buildState("hashchange"), listenerOptions);
|
|
3033
3177
|
}
|
|
3034
3178
|
return state;
|
|
3035
3179
|
}
|
|
@@ -3056,7 +3200,7 @@ function usePermission(permissionDesc, options = {}) {
|
|
|
3056
3200
|
var _a, _b;
|
|
3057
3201
|
state.value = (_b = (_a = permissionStatus.value) == null ? void 0 : _a.state) != null ? _b : "prompt";
|
|
3058
3202
|
};
|
|
3059
|
-
useEventListener(permissionStatus, "change", update);
|
|
3203
|
+
useEventListener(permissionStatus, "change", update, { passive: true });
|
|
3060
3204
|
const query = createSingletonPromise(async () => {
|
|
3061
3205
|
if (!isSupported.value)
|
|
3062
3206
|
return;
|
|
@@ -3096,25 +3240,37 @@ function useClipboard(options = {}) {
|
|
|
3096
3240
|
const permissionRead = usePermission("clipboard-read");
|
|
3097
3241
|
const permissionWrite = usePermission("clipboard-write");
|
|
3098
3242
|
const isSupported = computed(() => isClipboardApiSupported.value || legacy);
|
|
3099
|
-
const text =
|
|
3100
|
-
const copied =
|
|
3101
|
-
const timeout = useTimeoutFn(() => copied.value = false, copiedDuring);
|
|
3243
|
+
const text = shallowRef("");
|
|
3244
|
+
const copied = shallowRef(false);
|
|
3245
|
+
const timeout = useTimeoutFn(() => copied.value = false, copiedDuring, { immediate: false });
|
|
3102
3246
|
function updateText() {
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3247
|
+
let useLegacy = !(isClipboardApiSupported.value && isAllowed(permissionRead.value));
|
|
3248
|
+
if (!useLegacy) {
|
|
3249
|
+
try {
|
|
3250
|
+
navigator.clipboard.readText().then((value) => {
|
|
3251
|
+
text.value = value;
|
|
3252
|
+
});
|
|
3253
|
+
} catch (e) {
|
|
3254
|
+
useLegacy = true;
|
|
3255
|
+
}
|
|
3256
|
+
}
|
|
3257
|
+
if (useLegacy) {
|
|
3108
3258
|
text.value = legacyRead();
|
|
3109
3259
|
}
|
|
3110
3260
|
}
|
|
3111
3261
|
if (isSupported.value && read)
|
|
3112
|
-
useEventListener(["copy", "cut"], updateText);
|
|
3113
|
-
async function copy(value = toValue(source)) {
|
|
3262
|
+
useEventListener(["copy", "cut"], updateText, { passive: true });
|
|
3263
|
+
async function copy(value = toValue$1(source)) {
|
|
3114
3264
|
if (isSupported.value && value != null) {
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3265
|
+
let useLegacy = !(isClipboardApiSupported.value && isAllowed(permissionWrite.value));
|
|
3266
|
+
if (!useLegacy) {
|
|
3267
|
+
try {
|
|
3268
|
+
await navigator.clipboard.writeText(value);
|
|
3269
|
+
} catch (e) {
|
|
3270
|
+
useLegacy = true;
|
|
3271
|
+
}
|
|
3272
|
+
}
|
|
3273
|
+
if (useLegacy)
|
|
3118
3274
|
legacyCopy(value);
|
|
3119
3275
|
text.value = value;
|
|
3120
3276
|
copied.value = true;
|
|
@@ -3155,8 +3311,8 @@ function useClipboardItems(options = {}) {
|
|
|
3155
3311
|
} = options;
|
|
3156
3312
|
const isSupported = useSupported(() => navigator && "clipboard" in navigator);
|
|
3157
3313
|
const content = ref([]);
|
|
3158
|
-
const copied =
|
|
3159
|
-
const timeout = useTimeoutFn(() => copied.value = false, copiedDuring);
|
|
3314
|
+
const copied = shallowRef(false);
|
|
3315
|
+
const timeout = useTimeoutFn(() => copied.value = false, copiedDuring, { immediate: false });
|
|
3160
3316
|
function updateContent() {
|
|
3161
3317
|
if (isSupported.value) {
|
|
3162
3318
|
navigator.clipboard.read().then((items) => {
|
|
@@ -3165,8 +3321,8 @@ function useClipboardItems(options = {}) {
|
|
|
3165
3321
|
}
|
|
3166
3322
|
}
|
|
3167
3323
|
if (isSupported.value && read)
|
|
3168
|
-
useEventListener(["copy", "cut"], updateContent);
|
|
3169
|
-
async function copy(value = toValue(source)) {
|
|
3324
|
+
useEventListener(["copy", "cut"], updateContent, { passive: true });
|
|
3325
|
+
async function copy(value = toValue$1(source)) {
|
|
3170
3326
|
if (isSupported.value && value != null) {
|
|
3171
3327
|
await navigator.clipboard.write(value);
|
|
3172
3328
|
content.value = value;
|
|
@@ -3187,6 +3343,8 @@ function cloneFnJSON(source) {
|
|
|
3187
3343
|
}
|
|
3188
3344
|
function useCloned(source, options = {}) {
|
|
3189
3345
|
const cloned = ref({});
|
|
3346
|
+
const isModified = ref(false);
|
|
3347
|
+
let _lastSync = false;
|
|
3190
3348
|
const {
|
|
3191
3349
|
manual,
|
|
3192
3350
|
clone = cloneFnJSON,
|
|
@@ -3194,8 +3352,20 @@ function useCloned(source, options = {}) {
|
|
|
3194
3352
|
deep = true,
|
|
3195
3353
|
immediate = true
|
|
3196
3354
|
} = options;
|
|
3355
|
+
watch(cloned, () => {
|
|
3356
|
+
if (_lastSync) {
|
|
3357
|
+
_lastSync = false;
|
|
3358
|
+
return;
|
|
3359
|
+
}
|
|
3360
|
+
isModified.value = true;
|
|
3361
|
+
}, {
|
|
3362
|
+
deep: true,
|
|
3363
|
+
flush: "sync"
|
|
3364
|
+
});
|
|
3197
3365
|
function sync() {
|
|
3198
|
-
|
|
3366
|
+
_lastSync = true;
|
|
3367
|
+
isModified.value = false;
|
|
3368
|
+
cloned.value = clone(toValue$1(source));
|
|
3199
3369
|
}
|
|
3200
3370
|
if (!manual && (isRef(source) || typeof source === "function")) {
|
|
3201
3371
|
watch(source, sync, {
|
|
@@ -3206,7 +3376,7 @@ function useCloned(source, options = {}) {
|
|
|
3206
3376
|
} else {
|
|
3207
3377
|
sync();
|
|
3208
3378
|
}
|
|
3209
|
-
return { cloned, sync };
|
|
3379
|
+
return { cloned, isModified, sync };
|
|
3210
3380
|
}
|
|
3211
3381
|
|
|
3212
3382
|
const _global = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
@@ -3284,6 +3454,7 @@ function useStorage(key, defaults, storage, options = {}) {
|
|
|
3284
3454
|
initOnMounted
|
|
3285
3455
|
} = options;
|
|
3286
3456
|
const data = (shallow ? shallowRef : ref)(typeof defaults === "function" ? defaults() : defaults);
|
|
3457
|
+
const keyComputed = computed(() => toValue$1(key));
|
|
3287
3458
|
if (!storage) {
|
|
3288
3459
|
try {
|
|
3289
3460
|
storage = getSSRHandler("getDefaultStorage", () => {
|
|
@@ -3296,7 +3467,7 @@ function useStorage(key, defaults, storage, options = {}) {
|
|
|
3296
3467
|
}
|
|
3297
3468
|
if (!storage)
|
|
3298
3469
|
return data;
|
|
3299
|
-
const rawInit = toValue(defaults);
|
|
3470
|
+
const rawInit = toValue$1(defaults);
|
|
3300
3471
|
const type = guessSerializerType(rawInit);
|
|
3301
3472
|
const serializer = (_a = options.serializer) != null ? _a : StorageSerializers[type];
|
|
3302
3473
|
const { pause: pauseWatch, resume: resumeWatch } = watchPausable(
|
|
@@ -3304,10 +3475,11 @@ function useStorage(key, defaults, storage, options = {}) {
|
|
|
3304
3475
|
() => write(data.value),
|
|
3305
3476
|
{ flush, deep, eventFilter }
|
|
3306
3477
|
);
|
|
3478
|
+
watch(keyComputed, () => update(), { flush });
|
|
3307
3479
|
if (window && listenToStorageChanges) {
|
|
3308
3480
|
tryOnMounted(() => {
|
|
3309
3481
|
if (storage instanceof Storage)
|
|
3310
|
-
useEventListener(window, "storage", update);
|
|
3482
|
+
useEventListener(window, "storage", update, { passive: true });
|
|
3311
3483
|
else
|
|
3312
3484
|
useEventListener(window, customStorageEventName, updateFromCustomEvent);
|
|
3313
3485
|
if (initOnMounted)
|
|
@@ -3319,7 +3491,7 @@ function useStorage(key, defaults, storage, options = {}) {
|
|
|
3319
3491
|
function dispatchWriteEvent(oldValue, newValue) {
|
|
3320
3492
|
if (window) {
|
|
3321
3493
|
const payload = {
|
|
3322
|
-
key,
|
|
3494
|
+
key: keyComputed.value,
|
|
3323
3495
|
oldValue,
|
|
3324
3496
|
newValue,
|
|
3325
3497
|
storageArea: storage
|
|
@@ -3331,14 +3503,14 @@ function useStorage(key, defaults, storage, options = {}) {
|
|
|
3331
3503
|
}
|
|
3332
3504
|
function write(v) {
|
|
3333
3505
|
try {
|
|
3334
|
-
const oldValue = storage.getItem(
|
|
3506
|
+
const oldValue = storage.getItem(keyComputed.value);
|
|
3335
3507
|
if (v == null) {
|
|
3336
3508
|
dispatchWriteEvent(oldValue, null);
|
|
3337
|
-
storage.removeItem(
|
|
3509
|
+
storage.removeItem(keyComputed.value);
|
|
3338
3510
|
} else {
|
|
3339
3511
|
const serialized = serializer.write(v);
|
|
3340
3512
|
if (oldValue !== serialized) {
|
|
3341
|
-
storage.setItem(
|
|
3513
|
+
storage.setItem(keyComputed.value, serialized);
|
|
3342
3514
|
dispatchWriteEvent(oldValue, serialized);
|
|
3343
3515
|
}
|
|
3344
3516
|
}
|
|
@@ -3347,10 +3519,10 @@ function useStorage(key, defaults, storage, options = {}) {
|
|
|
3347
3519
|
}
|
|
3348
3520
|
}
|
|
3349
3521
|
function read(event) {
|
|
3350
|
-
const rawValue = event ? event.newValue : storage.getItem(
|
|
3522
|
+
const rawValue = event ? event.newValue : storage.getItem(keyComputed.value);
|
|
3351
3523
|
if (rawValue == null) {
|
|
3352
3524
|
if (writeDefaults && rawInit != null)
|
|
3353
|
-
storage.setItem(
|
|
3525
|
+
storage.setItem(keyComputed.value, serializer.write(rawInit));
|
|
3354
3526
|
return rawInit;
|
|
3355
3527
|
} else if (!event && mergeDefaults) {
|
|
3356
3528
|
const value = serializer.read(rawValue);
|
|
@@ -3372,7 +3544,7 @@ function useStorage(key, defaults, storage, options = {}) {
|
|
|
3372
3544
|
data.value = rawInit;
|
|
3373
3545
|
return;
|
|
3374
3546
|
}
|
|
3375
|
-
if (event && event.key !==
|
|
3547
|
+
if (event && event.key !== keyComputed.value)
|
|
3376
3548
|
return;
|
|
3377
3549
|
pauseWatch();
|
|
3378
3550
|
try {
|
|
@@ -3483,7 +3655,7 @@ function useColorMode(options = {}) {
|
|
|
3483
3655
|
return Object.assign(auto, { store, system, state });
|
|
3484
3656
|
}
|
|
3485
3657
|
|
|
3486
|
-
function useConfirmDialog(revealed =
|
|
3658
|
+
function useConfirmDialog(revealed = shallowRef(false)) {
|
|
3487
3659
|
const confirmHook = createEventHook();
|
|
3488
3660
|
const cancelHook = createEventHook();
|
|
3489
3661
|
const revealHook = createEventHook();
|
|
@@ -3516,20 +3688,63 @@ function useConfirmDialog(revealed = ref(false)) {
|
|
|
3516
3688
|
};
|
|
3517
3689
|
}
|
|
3518
3690
|
|
|
3691
|
+
function useCountdown(initialCountdown, options) {
|
|
3692
|
+
var _a, _b;
|
|
3693
|
+
const remaining = shallowRef(toValue$1(initialCountdown));
|
|
3694
|
+
const intervalController = useIntervalFn(() => {
|
|
3695
|
+
var _a2, _b2;
|
|
3696
|
+
const value = remaining.value - 1;
|
|
3697
|
+
remaining.value = value < 0 ? 0 : value;
|
|
3698
|
+
(_a2 = options == null ? void 0 : options.onTick) == null ? void 0 : _a2.call(options);
|
|
3699
|
+
if (remaining.value <= 0) {
|
|
3700
|
+
intervalController.pause();
|
|
3701
|
+
(_b2 = options == null ? void 0 : options.onComplete) == null ? void 0 : _b2.call(options);
|
|
3702
|
+
}
|
|
3703
|
+
}, (_a = options == null ? void 0 : options.interval) != null ? _a : 1e3, { immediate: (_b = options == null ? void 0 : options.immediate) != null ? _b : false });
|
|
3704
|
+
const reset = (countdown) => {
|
|
3705
|
+
var _a2;
|
|
3706
|
+
remaining.value = (_a2 = toValue$1(countdown)) != null ? _a2 : toValue$1(initialCountdown);
|
|
3707
|
+
};
|
|
3708
|
+
const stop = () => {
|
|
3709
|
+
intervalController.pause();
|
|
3710
|
+
reset();
|
|
3711
|
+
};
|
|
3712
|
+
const resume = () => {
|
|
3713
|
+
if (!intervalController.isActive.value) {
|
|
3714
|
+
if (remaining.value > 0) {
|
|
3715
|
+
intervalController.resume();
|
|
3716
|
+
}
|
|
3717
|
+
}
|
|
3718
|
+
};
|
|
3719
|
+
const start = (countdown) => {
|
|
3720
|
+
reset(countdown);
|
|
3721
|
+
intervalController.resume();
|
|
3722
|
+
};
|
|
3723
|
+
return {
|
|
3724
|
+
remaining,
|
|
3725
|
+
reset,
|
|
3726
|
+
stop,
|
|
3727
|
+
start,
|
|
3728
|
+
pause: intervalController.pause,
|
|
3729
|
+
resume,
|
|
3730
|
+
isActive: intervalController.isActive
|
|
3731
|
+
};
|
|
3732
|
+
}
|
|
3733
|
+
|
|
3519
3734
|
function useCssVar(prop, target, options = {}) {
|
|
3520
3735
|
const { window = defaultWindow, initialValue, observe = false } = options;
|
|
3521
|
-
const variable =
|
|
3736
|
+
const variable = shallowRef(initialValue);
|
|
3522
3737
|
const elRef = computed(() => {
|
|
3523
3738
|
var _a;
|
|
3524
3739
|
return unrefElement(target) || ((_a = window == null ? void 0 : window.document) == null ? void 0 : _a.documentElement);
|
|
3525
3740
|
});
|
|
3526
3741
|
function updateCssVar() {
|
|
3527
3742
|
var _a;
|
|
3528
|
-
const key = toValue(prop);
|
|
3529
|
-
const el = toValue(elRef);
|
|
3743
|
+
const key = toValue$1(prop);
|
|
3744
|
+
const el = toValue$1(elRef);
|
|
3530
3745
|
if (el && window && key) {
|
|
3531
3746
|
const value = (_a = window.getComputedStyle(el).getPropertyValue(key)) == null ? void 0 : _a.trim();
|
|
3532
|
-
variable.value = value || initialValue;
|
|
3747
|
+
variable.value = value || variable.value || initialValue;
|
|
3533
3748
|
}
|
|
3534
3749
|
}
|
|
3535
3750
|
if (observe) {
|
|
@@ -3539,26 +3754,25 @@ function useCssVar(prop, target, options = {}) {
|
|
|
3539
3754
|
});
|
|
3540
3755
|
}
|
|
3541
3756
|
watch(
|
|
3542
|
-
[elRef, () => toValue(prop)],
|
|
3757
|
+
[elRef, () => toValue$1(prop)],
|
|
3543
3758
|
(_, old) => {
|
|
3544
3759
|
if (old[0] && old[1])
|
|
3545
3760
|
old[0].style.removeProperty(old[1]);
|
|
3546
3761
|
updateCssVar();
|
|
3547
|
-
}
|
|
3548
|
-
{ immediate: true }
|
|
3762
|
+
}
|
|
3549
3763
|
);
|
|
3550
3764
|
watch(
|
|
3551
|
-
variable,
|
|
3552
|
-
(val) => {
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
if (((_a = elRef.value) == null ? void 0 : _a.style) && raw_prop) {
|
|
3765
|
+
[variable, elRef],
|
|
3766
|
+
([val, el]) => {
|
|
3767
|
+
const raw_prop = toValue$1(prop);
|
|
3768
|
+
if ((el == null ? void 0 : el.style) && raw_prop) {
|
|
3556
3769
|
if (val == null)
|
|
3557
|
-
|
|
3770
|
+
el.style.removeProperty(raw_prop);
|
|
3558
3771
|
else
|
|
3559
|
-
|
|
3772
|
+
el.style.setProperty(raw_prop, val);
|
|
3560
3773
|
}
|
|
3561
|
-
}
|
|
3774
|
+
},
|
|
3775
|
+
{ immediate: true }
|
|
3562
3776
|
);
|
|
3563
3777
|
return variable;
|
|
3564
3778
|
}
|
|
@@ -3609,7 +3823,7 @@ function useCycleList(list, options) {
|
|
|
3609
3823
|
}
|
|
3610
3824
|
function getInitialValue() {
|
|
3611
3825
|
var _a, _b;
|
|
3612
|
-
return (_b = toValue((_a = options == null ? void 0 : options.initialValue) != null ? _a : toValue(list)[0])) != null ? _b : void 0;
|
|
3826
|
+
return (_b = toValue$1((_a = options == null ? void 0 : options.initialValue) != null ? _a : toValue$1(list)[0])) != null ? _b : void 0;
|
|
3613
3827
|
}
|
|
3614
3828
|
watch(listRef, () => set(index.value));
|
|
3615
3829
|
return {
|
|
@@ -3809,50 +4023,98 @@ function useDebouncedRefHistory(source, options = {}) {
|
|
|
3809
4023
|
function useDeviceMotion(options = {}) {
|
|
3810
4024
|
const {
|
|
3811
4025
|
window = defaultWindow,
|
|
4026
|
+
requestPermissions = false,
|
|
3812
4027
|
eventFilter = bypassFilter
|
|
3813
4028
|
} = options;
|
|
4029
|
+
const isSupported = useSupported(() => typeof DeviceMotionEvent !== "undefined");
|
|
4030
|
+
const requirePermissions = useSupported(() => isSupported.value && "requestPermission" in DeviceMotionEvent && typeof DeviceMotionEvent.requestPermission === "function");
|
|
4031
|
+
const permissionGranted = shallowRef(false);
|
|
3814
4032
|
const acceleration = ref({ x: null, y: null, z: null });
|
|
3815
4033
|
const rotationRate = ref({ alpha: null, beta: null, gamma: null });
|
|
3816
|
-
const interval =
|
|
4034
|
+
const interval = shallowRef(0);
|
|
3817
4035
|
const accelerationIncludingGravity = ref({
|
|
3818
4036
|
x: null,
|
|
3819
4037
|
y: null,
|
|
3820
4038
|
z: null
|
|
3821
4039
|
});
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
4040
|
+
function init() {
|
|
4041
|
+
if (window) {
|
|
4042
|
+
const onDeviceMotion = createFilterWrapper(
|
|
4043
|
+
eventFilter,
|
|
4044
|
+
(event) => {
|
|
4045
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
4046
|
+
acceleration.value = {
|
|
4047
|
+
x: ((_a = event.acceleration) == null ? void 0 : _a.x) || null,
|
|
4048
|
+
y: ((_b = event.acceleration) == null ? void 0 : _b.y) || null,
|
|
4049
|
+
z: ((_c = event.acceleration) == null ? void 0 : _c.z) || null
|
|
4050
|
+
};
|
|
4051
|
+
accelerationIncludingGravity.value = {
|
|
4052
|
+
x: ((_d = event.accelerationIncludingGravity) == null ? void 0 : _d.x) || null,
|
|
4053
|
+
y: ((_e = event.accelerationIncludingGravity) == null ? void 0 : _e.y) || null,
|
|
4054
|
+
z: ((_f = event.accelerationIncludingGravity) == null ? void 0 : _f.z) || null
|
|
4055
|
+
};
|
|
4056
|
+
rotationRate.value = {
|
|
4057
|
+
alpha: ((_g = event.rotationRate) == null ? void 0 : _g.alpha) || null,
|
|
4058
|
+
beta: ((_h = event.rotationRate) == null ? void 0 : _h.beta) || null,
|
|
4059
|
+
gamma: ((_i = event.rotationRate) == null ? void 0 : _i.gamma) || null
|
|
4060
|
+
};
|
|
4061
|
+
interval.value = event.interval;
|
|
4062
|
+
}
|
|
4063
|
+
);
|
|
4064
|
+
useEventListener(window, "devicemotion", onDeviceMotion, { passive: true });
|
|
4065
|
+
}
|
|
4066
|
+
}
|
|
4067
|
+
const ensurePermissions = async () => {
|
|
4068
|
+
if (!requirePermissions.value)
|
|
4069
|
+
permissionGranted.value = true;
|
|
4070
|
+
if (permissionGranted.value)
|
|
4071
|
+
return;
|
|
4072
|
+
if (requirePermissions.value) {
|
|
4073
|
+
const requestPermission = DeviceMotionEvent.requestPermission;
|
|
4074
|
+
try {
|
|
4075
|
+
const response = await requestPermission();
|
|
4076
|
+
if (response === "granted") {
|
|
4077
|
+
permissionGranted.value = true;
|
|
4078
|
+
init();
|
|
4079
|
+
}
|
|
4080
|
+
} catch (error) {
|
|
4081
|
+
console.error(error);
|
|
3830
4082
|
}
|
|
3831
|
-
|
|
3832
|
-
|
|
4083
|
+
}
|
|
4084
|
+
};
|
|
4085
|
+
if (isSupported.value) {
|
|
4086
|
+
if (requestPermissions && requirePermissions.value) {
|
|
4087
|
+
ensurePermissions().then(() => init());
|
|
4088
|
+
} else {
|
|
4089
|
+
init();
|
|
4090
|
+
}
|
|
3833
4091
|
}
|
|
3834
4092
|
return {
|
|
3835
4093
|
acceleration,
|
|
3836
4094
|
accelerationIncludingGravity,
|
|
3837
4095
|
rotationRate,
|
|
3838
|
-
interval
|
|
4096
|
+
interval,
|
|
4097
|
+
isSupported,
|
|
4098
|
+
requirePermissions,
|
|
4099
|
+
ensurePermissions,
|
|
4100
|
+
permissionGranted
|
|
3839
4101
|
};
|
|
3840
4102
|
}
|
|
3841
4103
|
|
|
3842
4104
|
function useDeviceOrientation(options = {}) {
|
|
3843
4105
|
const { window = defaultWindow } = options;
|
|
3844
4106
|
const isSupported = useSupported(() => window && "DeviceOrientationEvent" in window);
|
|
3845
|
-
const isAbsolute =
|
|
3846
|
-
const alpha =
|
|
3847
|
-
const beta =
|
|
3848
|
-
const gamma =
|
|
4107
|
+
const isAbsolute = shallowRef(false);
|
|
4108
|
+
const alpha = shallowRef(null);
|
|
4109
|
+
const beta = shallowRef(null);
|
|
4110
|
+
const gamma = shallowRef(null);
|
|
3849
4111
|
if (window && isSupported.value) {
|
|
3850
4112
|
useEventListener(window, "deviceorientation", (event) => {
|
|
3851
4113
|
isAbsolute.value = event.absolute;
|
|
3852
4114
|
alpha.value = event.alpha;
|
|
3853
4115
|
beta.value = event.beta;
|
|
3854
4116
|
gamma.value = event.gamma;
|
|
3855
|
-
});
|
|
4117
|
+
}, { passive: true });
|
|
3856
4118
|
}
|
|
3857
4119
|
return {
|
|
3858
4120
|
isSupported,
|
|
@@ -3867,21 +4129,16 @@ function useDevicePixelRatio(options = {}) {
|
|
|
3867
4129
|
const {
|
|
3868
4130
|
window = defaultWindow
|
|
3869
4131
|
} = options;
|
|
3870
|
-
const pixelRatio =
|
|
4132
|
+
const pixelRatio = shallowRef(1);
|
|
4133
|
+
const query = useMediaQuery(() => `(resolution: ${pixelRatio.value}dppx)`, options);
|
|
4134
|
+
let stop = noop;
|
|
3871
4135
|
if (window) {
|
|
3872
|
-
|
|
3873
|
-
pixelRatio.value = window.devicePixelRatio;
|
|
3874
|
-
cleanup2();
|
|
3875
|
-
media = window.matchMedia(`(resolution: ${pixelRatio.value}dppx)`);
|
|
3876
|
-
media.addEventListener("change", observe2, { once: true });
|
|
3877
|
-
}, cleanup2 = function() {
|
|
3878
|
-
media == null ? void 0 : media.removeEventListener("change", observe2);
|
|
3879
|
-
};
|
|
3880
|
-
let media;
|
|
3881
|
-
observe2();
|
|
3882
|
-
tryOnScopeDispose(cleanup2);
|
|
4136
|
+
stop = watchImmediate(query, () => pixelRatio.value = window.devicePixelRatio);
|
|
3883
4137
|
}
|
|
3884
|
-
return {
|
|
4138
|
+
return {
|
|
4139
|
+
pixelRatio: readonly(pixelRatio),
|
|
4140
|
+
stop
|
|
4141
|
+
};
|
|
3885
4142
|
}
|
|
3886
4143
|
|
|
3887
4144
|
function useDevicesList(options = {}) {
|
|
@@ -3896,7 +4153,7 @@ function useDevicesList(options = {}) {
|
|
|
3896
4153
|
const audioInputs = computed(() => devices.value.filter((i) => i.kind === "audioinput"));
|
|
3897
4154
|
const audioOutputs = computed(() => devices.value.filter((i) => i.kind === "audiooutput"));
|
|
3898
4155
|
const isSupported = useSupported(() => navigator && navigator.mediaDevices && navigator.mediaDevices.enumerateDevices);
|
|
3899
|
-
const permissionGranted =
|
|
4156
|
+
const permissionGranted = shallowRef(false);
|
|
3900
4157
|
let stream;
|
|
3901
4158
|
async function update() {
|
|
3902
4159
|
if (!isSupported.value)
|
|
@@ -3933,7 +4190,7 @@ function useDevicesList(options = {}) {
|
|
|
3933
4190
|
if (isSupported.value) {
|
|
3934
4191
|
if (requestPermissions)
|
|
3935
4192
|
ensurePermissions();
|
|
3936
|
-
useEventListener(navigator.mediaDevices, "devicechange", update);
|
|
4193
|
+
useEventListener(navigator.mediaDevices, "devicechange", update, { passive: true });
|
|
3937
4194
|
update();
|
|
3938
4195
|
}
|
|
3939
4196
|
return {
|
|
@@ -3949,7 +4206,7 @@ function useDevicesList(options = {}) {
|
|
|
3949
4206
|
|
|
3950
4207
|
function useDisplayMedia(options = {}) {
|
|
3951
4208
|
var _a;
|
|
3952
|
-
const enabled =
|
|
4209
|
+
const enabled = shallowRef((_a = options.enabled) != null ? _a : false);
|
|
3953
4210
|
const video = options.video;
|
|
3954
4211
|
const audio = options.audio;
|
|
3955
4212
|
const { navigator = defaultNavigator } = options;
|
|
@@ -3964,7 +4221,7 @@ function useDisplayMedia(options = {}) {
|
|
|
3964
4221
|
if (!isSupported.value || stream.value)
|
|
3965
4222
|
return;
|
|
3966
4223
|
stream.value = await navigator.mediaDevices.getDisplayMedia(constraint);
|
|
3967
|
-
(_a2 = stream.value) == null ? void 0 : _a2.getTracks().forEach((t) => t
|
|
4224
|
+
(_a2 = stream.value) == null ? void 0 : _a2.getTracks().forEach((t) => useEventListener(t, "ended", stop, { passive: true }));
|
|
3968
4225
|
return stream.value;
|
|
3969
4226
|
}
|
|
3970
4227
|
async function _stop() {
|
|
@@ -4004,16 +4261,16 @@ function useDisplayMedia(options = {}) {
|
|
|
4004
4261
|
function useDocumentVisibility(options = {}) {
|
|
4005
4262
|
const { document = defaultDocument } = options;
|
|
4006
4263
|
if (!document)
|
|
4007
|
-
return
|
|
4264
|
+
return shallowRef("visible");
|
|
4008
4265
|
const visibility = ref(document.visibilityState);
|
|
4009
4266
|
useEventListener(document, "visibilitychange", () => {
|
|
4010
4267
|
visibility.value = document.visibilityState;
|
|
4011
|
-
});
|
|
4268
|
+
}, { passive: true });
|
|
4012
4269
|
return visibility;
|
|
4013
4270
|
}
|
|
4014
4271
|
|
|
4015
4272
|
function useDraggable(target, options = {}) {
|
|
4016
|
-
var _a
|
|
4273
|
+
var _a;
|
|
4017
4274
|
const {
|
|
4018
4275
|
pointerTypes,
|
|
4019
4276
|
preventDefault,
|
|
@@ -4030,7 +4287,7 @@ function useDraggable(target, options = {}) {
|
|
|
4030
4287
|
buttons = [0]
|
|
4031
4288
|
} = options;
|
|
4032
4289
|
const position = ref(
|
|
4033
|
-
(_a = toValue(initialValue)) != null ? _a : { x: 0, y: 0 }
|
|
4290
|
+
(_a = toValue$1(initialValue)) != null ? _a : { x: 0, y: 0 }
|
|
4034
4291
|
);
|
|
4035
4292
|
const pressedDelta = ref();
|
|
4036
4293
|
const filterEvent = (e) => {
|
|
@@ -4039,22 +4296,22 @@ function useDraggable(target, options = {}) {
|
|
|
4039
4296
|
return true;
|
|
4040
4297
|
};
|
|
4041
4298
|
const handleEvent = (e) => {
|
|
4042
|
-
if (toValue(preventDefault))
|
|
4299
|
+
if (toValue$1(preventDefault))
|
|
4043
4300
|
e.preventDefault();
|
|
4044
|
-
if (toValue(stopPropagation))
|
|
4301
|
+
if (toValue$1(stopPropagation))
|
|
4045
4302
|
e.stopPropagation();
|
|
4046
4303
|
};
|
|
4047
4304
|
const start = (e) => {
|
|
4048
4305
|
var _a2;
|
|
4049
|
-
if (!toValue(buttons).includes(e.button))
|
|
4306
|
+
if (!toValue$1(buttons).includes(e.button))
|
|
4050
4307
|
return;
|
|
4051
|
-
if (toValue(options.disabled) || !filterEvent(e))
|
|
4308
|
+
if (toValue$1(options.disabled) || !filterEvent(e))
|
|
4052
4309
|
return;
|
|
4053
|
-
if (toValue(exact) && e.target !== toValue(target))
|
|
4310
|
+
if (toValue$1(exact) && e.target !== toValue$1(target))
|
|
4054
4311
|
return;
|
|
4055
|
-
const container = toValue(containerElement);
|
|
4312
|
+
const container = toValue$1(containerElement);
|
|
4056
4313
|
const containerRect = (_a2 = container == null ? void 0 : container.getBoundingClientRect) == null ? void 0 : _a2.call(container);
|
|
4057
|
-
const targetRect = toValue(target).getBoundingClientRect();
|
|
4314
|
+
const targetRect = toValue$1(target).getBoundingClientRect();
|
|
4058
4315
|
const pos = {
|
|
4059
4316
|
x: e.clientX - (container ? targetRect.left - containerRect.left + container.scrollLeft : targetRect.left),
|
|
4060
4317
|
y: e.clientY - (container ? targetRect.top - containerRect.top + container.scrollTop : targetRect.top)
|
|
@@ -4065,12 +4322,12 @@ function useDraggable(target, options = {}) {
|
|
|
4065
4322
|
handleEvent(e);
|
|
4066
4323
|
};
|
|
4067
4324
|
const move = (e) => {
|
|
4068
|
-
if (toValue(options.disabled) || !filterEvent(e))
|
|
4325
|
+
if (toValue$1(options.disabled) || !filterEvent(e))
|
|
4069
4326
|
return;
|
|
4070
4327
|
if (!pressedDelta.value)
|
|
4071
4328
|
return;
|
|
4072
|
-
const container = toValue(containerElement);
|
|
4073
|
-
const targetRect = toValue(target).getBoundingClientRect();
|
|
4329
|
+
const container = toValue$1(containerElement);
|
|
4330
|
+
const targetRect = toValue$1(target).getBoundingClientRect();
|
|
4074
4331
|
let { x, y } = position.value;
|
|
4075
4332
|
if (axis === "x" || axis === "both") {
|
|
4076
4333
|
x = e.clientX - pressedDelta.value.x;
|
|
@@ -4090,7 +4347,7 @@ function useDraggable(target, options = {}) {
|
|
|
4090
4347
|
handleEvent(e);
|
|
4091
4348
|
};
|
|
4092
4349
|
const end = (e) => {
|
|
4093
|
-
if (toValue(options.disabled) || !filterEvent(e))
|
|
4350
|
+
if (toValue$1(options.disabled) || !filterEvent(e))
|
|
4094
4351
|
return;
|
|
4095
4352
|
if (!pressedDelta.value)
|
|
4096
4353
|
return;
|
|
@@ -4099,7 +4356,13 @@ function useDraggable(target, options = {}) {
|
|
|
4099
4356
|
handleEvent(e);
|
|
4100
4357
|
};
|
|
4101
4358
|
if (isClient) {
|
|
4102
|
-
const config =
|
|
4359
|
+
const config = () => {
|
|
4360
|
+
var _a2;
|
|
4361
|
+
return {
|
|
4362
|
+
capture: (_a2 = options.capture) != null ? _a2 : true,
|
|
4363
|
+
passive: !toValue$1(preventDefault)
|
|
4364
|
+
};
|
|
4365
|
+
};
|
|
4103
4366
|
useEventListener(draggingHandle, "pointerdown", start, config);
|
|
4104
4367
|
useEventListener(draggingElement, "pointermove", move, config);
|
|
4105
4368
|
useEventListener(draggingElement, "pointerup", end, config);
|
|
@@ -4116,7 +4379,7 @@ function useDraggable(target, options = {}) {
|
|
|
4116
4379
|
|
|
4117
4380
|
function useDropZone(target, options = {}) {
|
|
4118
4381
|
var _a, _b;
|
|
4119
|
-
const isOverDropZone =
|
|
4382
|
+
const isOverDropZone = shallowRef(false);
|
|
4120
4383
|
const files = shallowRef(null);
|
|
4121
4384
|
let counter = 0;
|
|
4122
4385
|
let isValid = true;
|
|
@@ -4130,27 +4393,32 @@ function useDropZone(target, options = {}) {
|
|
|
4130
4393
|
return list.length === 0 ? null : multiple ? list : [list[0]];
|
|
4131
4394
|
};
|
|
4132
4395
|
const checkDataTypes = (types) => {
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
return
|
|
4136
|
-
|
|
4137
|
-
|
|
4396
|
+
const dataTypes = unref(_options.dataTypes);
|
|
4397
|
+
if (typeof dataTypes === "function")
|
|
4398
|
+
return dataTypes(types);
|
|
4399
|
+
if (!(dataTypes == null ? void 0 : dataTypes.length))
|
|
4400
|
+
return true;
|
|
4401
|
+
if (types.length === 0)
|
|
4402
|
+
return false;
|
|
4403
|
+
return types.every(
|
|
4404
|
+
(type) => dataTypes.some((allowedType) => type.includes(allowedType))
|
|
4405
|
+
);
|
|
4138
4406
|
};
|
|
4139
|
-
const checkValidity = (
|
|
4140
|
-
|
|
4141
|
-
const items = Array.from((_b2 = (_a2 = event.dataTransfer) == null ? void 0 : _a2.items) != null ? _b2 : []);
|
|
4142
|
-
const types = items.map((item) => item.type);
|
|
4407
|
+
const checkValidity = (items) => {
|
|
4408
|
+
const types = Array.from(items != null ? items : []).map((item) => item.type);
|
|
4143
4409
|
const dataTypesValid = checkDataTypes(types);
|
|
4144
4410
|
const multipleFilesValid = multiple || items.length <= 1;
|
|
4145
4411
|
return dataTypesValid && multipleFilesValid;
|
|
4146
4412
|
};
|
|
4413
|
+
const isSafari = () => /^(?:(?!chrome|android).)*safari/i.test(navigator.userAgent) && !("chrome" in window);
|
|
4147
4414
|
const handleDragEvent = (event, eventType) => {
|
|
4148
|
-
var _a2, _b2, _c, _d;
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4415
|
+
var _a2, _b2, _c, _d, _e, _f;
|
|
4416
|
+
const dataTransferItemList = (_a2 = event.dataTransfer) == null ? void 0 : _a2.items;
|
|
4417
|
+
isValid = (_b2 = dataTransferItemList && checkValidity(dataTransferItemList)) != null ? _b2 : false;
|
|
4418
|
+
if (preventDefaultForUnhandled) {
|
|
4419
|
+
event.preventDefault();
|
|
4420
|
+
}
|
|
4421
|
+
if (!isSafari() && !isValid) {
|
|
4154
4422
|
if (event.dataTransfer) {
|
|
4155
4423
|
event.dataTransfer.dropEffect = "none";
|
|
4156
4424
|
}
|
|
@@ -4165,23 +4433,23 @@ function useDropZone(target, options = {}) {
|
|
|
4165
4433
|
case "enter":
|
|
4166
4434
|
counter += 1;
|
|
4167
4435
|
isOverDropZone.value = true;
|
|
4168
|
-
(
|
|
4436
|
+
(_c = _options.onEnter) == null ? void 0 : _c.call(_options, null, event);
|
|
4169
4437
|
break;
|
|
4170
4438
|
case "over":
|
|
4171
|
-
(
|
|
4439
|
+
(_d = _options.onOver) == null ? void 0 : _d.call(_options, null, event);
|
|
4172
4440
|
break;
|
|
4173
4441
|
case "leave":
|
|
4174
4442
|
counter -= 1;
|
|
4175
4443
|
if (counter === 0)
|
|
4176
4444
|
isOverDropZone.value = false;
|
|
4177
|
-
(
|
|
4445
|
+
(_e = _options.onLeave) == null ? void 0 : _e.call(_options, null, event);
|
|
4178
4446
|
break;
|
|
4179
4447
|
case "drop":
|
|
4180
4448
|
counter = 0;
|
|
4181
4449
|
isOverDropZone.value = false;
|
|
4182
4450
|
if (isValid) {
|
|
4183
4451
|
files.value = currentFiles;
|
|
4184
|
-
(
|
|
4452
|
+
(_f = _options.onDrop) == null ? void 0 : _f.call(_options, currentFiles, event);
|
|
4185
4453
|
}
|
|
4186
4454
|
break;
|
|
4187
4455
|
}
|
|
@@ -4208,7 +4476,7 @@ function useResizeObserver(target, callback, options = {}) {
|
|
|
4208
4476
|
}
|
|
4209
4477
|
};
|
|
4210
4478
|
const targets = computed(() => {
|
|
4211
|
-
const _targets = toValue(target);
|
|
4479
|
+
const _targets = toValue$1(target);
|
|
4212
4480
|
return Array.isArray(_targets) ? _targets.map((el) => unrefElement(el)) : [unrefElement(_targets)];
|
|
4213
4481
|
});
|
|
4214
4482
|
const stopWatch = watch(
|
|
@@ -4244,14 +4512,14 @@ function useElementBounding(target, options = {}) {
|
|
|
4244
4512
|
immediate = true,
|
|
4245
4513
|
updateTiming = "sync"
|
|
4246
4514
|
} = options;
|
|
4247
|
-
const height =
|
|
4248
|
-
const bottom =
|
|
4249
|
-
const left =
|
|
4250
|
-
const right =
|
|
4251
|
-
const top =
|
|
4252
|
-
const width =
|
|
4253
|
-
const x =
|
|
4254
|
-
const y =
|
|
4515
|
+
const height = shallowRef(0);
|
|
4516
|
+
const bottom = shallowRef(0);
|
|
4517
|
+
const left = shallowRef(0);
|
|
4518
|
+
const right = shallowRef(0);
|
|
4519
|
+
const top = shallowRef(0);
|
|
4520
|
+
const width = shallowRef(0);
|
|
4521
|
+
const x = shallowRef(0);
|
|
4522
|
+
const y = shallowRef(0);
|
|
4255
4523
|
function recalculate() {
|
|
4256
4524
|
const el = unrefElement(target);
|
|
4257
4525
|
if (!el) {
|
|
@@ -4319,14 +4587,14 @@ function useElementByPoint(options) {
|
|
|
4319
4587
|
immediate = true
|
|
4320
4588
|
} = options;
|
|
4321
4589
|
const isSupported = useSupported(() => {
|
|
4322
|
-
if (toValue(multiple))
|
|
4590
|
+
if (toValue$1(multiple))
|
|
4323
4591
|
return document && "elementsFromPoint" in document;
|
|
4324
4592
|
return document && "elementFromPoint" in document;
|
|
4325
4593
|
});
|
|
4326
4594
|
const element = ref(null);
|
|
4327
4595
|
const cb = () => {
|
|
4328
4596
|
var _a, _b;
|
|
4329
|
-
element.value = toValue(multiple) ? (_a = document == null ? void 0 : document.elementsFromPoint(toValue(x), toValue(y))) != null ? _a : [] : (_b = document == null ? void 0 : document.elementFromPoint(toValue(x), toValue(y))) != null ? _b : null;
|
|
4597
|
+
element.value = toValue$1(multiple) ? (_a = document == null ? void 0 : document.elementsFromPoint(toValue$1(x), toValue$1(y))) != null ? _a : [] : (_b = document == null ? void 0 : document.elementFromPoint(toValue$1(x), toValue$1(y))) != null ? _b : null;
|
|
4330
4598
|
};
|
|
4331
4599
|
const controls = interval === "requestAnimationFrame" ? useRafFn(cb, { immediate }) : useIntervalFn(cb, interval, { immediate });
|
|
4332
4600
|
return {
|
|
@@ -4340,9 +4608,10 @@ function useElementHover(el, options = {}) {
|
|
|
4340
4608
|
const {
|
|
4341
4609
|
delayEnter = 0,
|
|
4342
4610
|
delayLeave = 0,
|
|
4611
|
+
triggerOnRemoval = false,
|
|
4343
4612
|
window = defaultWindow
|
|
4344
4613
|
} = options;
|
|
4345
|
-
const isHovered =
|
|
4614
|
+
const isHovered = shallowRef(false);
|
|
4346
4615
|
let timer;
|
|
4347
4616
|
const toggle = (entering) => {
|
|
4348
4617
|
const delay = entering ? delayEnter : delayLeave;
|
|
@@ -4359,6 +4628,12 @@ function useElementHover(el, options = {}) {
|
|
|
4359
4628
|
return isHovered;
|
|
4360
4629
|
useEventListener(el, "mouseenter", () => toggle(true), { passive: true });
|
|
4361
4630
|
useEventListener(el, "mouseleave", () => toggle(false), { passive: true });
|
|
4631
|
+
if (triggerOnRemoval) {
|
|
4632
|
+
onElementRemoval(
|
|
4633
|
+
computed(() => unrefElement(el)),
|
|
4634
|
+
() => toggle(false)
|
|
4635
|
+
);
|
|
4636
|
+
}
|
|
4362
4637
|
return isHovered;
|
|
4363
4638
|
}
|
|
4364
4639
|
|
|
@@ -4383,7 +4658,7 @@ function useElementSize(target, initialSize = { width: 0, height: 0 }, options =
|
|
|
4383
4658
|
}
|
|
4384
4659
|
} else {
|
|
4385
4660
|
if (boxSize) {
|
|
4386
|
-
const formatBoxSize =
|
|
4661
|
+
const formatBoxSize = toArray(boxSize);
|
|
4387
4662
|
width.value = formatBoxSize.reduce((acc, { inlineSize }) => acc + inlineSize, 0);
|
|
4388
4663
|
height.value = formatBoxSize.reduce((acc, { blockSize }) => acc + blockSize, 0);
|
|
4389
4664
|
} else {
|
|
@@ -4429,8 +4704,8 @@ function useIntersectionObserver(target, callback, options = {}) {
|
|
|
4429
4704
|
} = options;
|
|
4430
4705
|
const isSupported = useSupported(() => window && "IntersectionObserver" in window);
|
|
4431
4706
|
const targets = computed(() => {
|
|
4432
|
-
const _target = toValue(target);
|
|
4433
|
-
return (
|
|
4707
|
+
const _target = toValue$1(target);
|
|
4708
|
+
return toArray(_target).map(unrefElement).filter(notNullish);
|
|
4434
4709
|
});
|
|
4435
4710
|
let cleanup = noop;
|
|
4436
4711
|
const isActive = ref(immediate);
|
|
@@ -4479,9 +4754,15 @@ function useIntersectionObserver(target, callback, options = {}) {
|
|
|
4479
4754
|
}
|
|
4480
4755
|
|
|
4481
4756
|
function useElementVisibility(element, options = {}) {
|
|
4482
|
-
const {
|
|
4483
|
-
|
|
4484
|
-
|
|
4757
|
+
const {
|
|
4758
|
+
window = defaultWindow,
|
|
4759
|
+
scrollTarget,
|
|
4760
|
+
threshold = 0,
|
|
4761
|
+
rootMargin,
|
|
4762
|
+
once = false
|
|
4763
|
+
} = options;
|
|
4764
|
+
const elementIsVisible = shallowRef(false);
|
|
4765
|
+
const { stop } = useIntersectionObserver(
|
|
4485
4766
|
element,
|
|
4486
4767
|
(intersectionObserverEntries) => {
|
|
4487
4768
|
let isIntersecting = elementIsVisible.value;
|
|
@@ -4493,11 +4774,17 @@ function useElementVisibility(element, options = {}) {
|
|
|
4493
4774
|
}
|
|
4494
4775
|
}
|
|
4495
4776
|
elementIsVisible.value = isIntersecting;
|
|
4777
|
+
if (once) {
|
|
4778
|
+
watchOnce(elementIsVisible, () => {
|
|
4779
|
+
stop();
|
|
4780
|
+
});
|
|
4781
|
+
}
|
|
4496
4782
|
},
|
|
4497
4783
|
{
|
|
4498
4784
|
root: scrollTarget,
|
|
4499
4785
|
window,
|
|
4500
|
-
threshold
|
|
4786
|
+
threshold,
|
|
4787
|
+
rootMargin: toValue$1(rootMargin)
|
|
4501
4788
|
}
|
|
4502
4789
|
);
|
|
4503
4790
|
return elementIsVisible;
|
|
@@ -4549,7 +4836,7 @@ function resolveNestedOptions$1(options) {
|
|
|
4549
4836
|
function useEventSource(url, events = [], options = {}) {
|
|
4550
4837
|
const event = ref(null);
|
|
4551
4838
|
const data = ref(null);
|
|
4552
|
-
const status =
|
|
4839
|
+
const status = shallowRef("CONNECTING");
|
|
4553
4840
|
const eventSource = ref(null);
|
|
4554
4841
|
const error = shallowRef(null);
|
|
4555
4842
|
const urlRef = toRef(url);
|
|
@@ -4558,7 +4845,9 @@ function useEventSource(url, events = [], options = {}) {
|
|
|
4558
4845
|
let retried = 0;
|
|
4559
4846
|
const {
|
|
4560
4847
|
withCredentials = false,
|
|
4561
|
-
immediate = true
|
|
4848
|
+
immediate = true,
|
|
4849
|
+
autoConnect = true,
|
|
4850
|
+
autoReconnect
|
|
4562
4851
|
} = options;
|
|
4563
4852
|
const close = () => {
|
|
4564
4853
|
if (isClient && eventSource.value) {
|
|
@@ -4581,13 +4870,13 @@ function useEventSource(url, events = [], options = {}) {
|
|
|
4581
4870
|
es.onerror = (e) => {
|
|
4582
4871
|
status.value = "CLOSED";
|
|
4583
4872
|
error.value = e;
|
|
4584
|
-
if (es.readyState === 2 && !explicitlyClosed &&
|
|
4873
|
+
if (es.readyState === 2 && !explicitlyClosed && autoReconnect) {
|
|
4585
4874
|
es.close();
|
|
4586
4875
|
const {
|
|
4587
4876
|
retries = -1,
|
|
4588
4877
|
delay = 1e3,
|
|
4589
4878
|
onFailed
|
|
4590
|
-
} = resolveNestedOptions$1(
|
|
4879
|
+
} = resolveNestedOptions$1(autoReconnect);
|
|
4591
4880
|
retried += 1;
|
|
4592
4881
|
if (typeof retries === "number" && (retries < 0 || retried < retries))
|
|
4593
4882
|
setTimeout(_init, delay);
|
|
@@ -4606,7 +4895,7 @@ function useEventSource(url, events = [], options = {}) {
|
|
|
4606
4895
|
useEventListener(es, event_name, (e) => {
|
|
4607
4896
|
event.value = event_name;
|
|
4608
4897
|
data.value = e.data || null;
|
|
4609
|
-
});
|
|
4898
|
+
}, { passive: true });
|
|
4610
4899
|
}
|
|
4611
4900
|
};
|
|
4612
4901
|
const open = () => {
|
|
@@ -4618,7 +4907,9 @@ function useEventSource(url, events = [], options = {}) {
|
|
|
4618
4907
|
_init();
|
|
4619
4908
|
};
|
|
4620
4909
|
if (immediate)
|
|
4621
|
-
|
|
4910
|
+
open();
|
|
4911
|
+
if (autoConnect)
|
|
4912
|
+
watch(urlRef, open);
|
|
4622
4913
|
tryOnScopeDispose(close);
|
|
4623
4914
|
return {
|
|
4624
4915
|
eventSource,
|
|
@@ -4635,7 +4926,7 @@ function useEventSource(url, events = [], options = {}) {
|
|
|
4635
4926
|
function useEyeDropper(options = {}) {
|
|
4636
4927
|
const { initialValue = "" } = options;
|
|
4637
4928
|
const isSupported = useSupported(() => typeof window !== "undefined" && "EyeDropper" in window);
|
|
4638
|
-
const sRGBHex =
|
|
4929
|
+
const sRGBHex = shallowRef(initialValue);
|
|
4639
4930
|
async function open(openOptions) {
|
|
4640
4931
|
if (!isSupported.value)
|
|
4641
4932
|
return;
|
|
@@ -4698,7 +4989,13 @@ function headersToObject(headers) {
|
|
|
4698
4989
|
function combineCallbacks(combination, ...callbacks) {
|
|
4699
4990
|
if (combination === "overwrite") {
|
|
4700
4991
|
return async (ctx) => {
|
|
4701
|
-
|
|
4992
|
+
let callback;
|
|
4993
|
+
for (let i = callbacks.length - 1; i >= 0; i--) {
|
|
4994
|
+
if (callbacks[i] != null) {
|
|
4995
|
+
callback = callbacks[i];
|
|
4996
|
+
break;
|
|
4997
|
+
}
|
|
4998
|
+
}
|
|
4702
4999
|
if (callback)
|
|
4703
5000
|
return { ...ctx, ...await callback(ctx) };
|
|
4704
5001
|
return ctx;
|
|
@@ -4719,8 +5016,8 @@ function createFetch(config = {}) {
|
|
|
4719
5016
|
const _fetchOptions = config.fetchOptions || {};
|
|
4720
5017
|
function useFactoryFetch(url, ...args) {
|
|
4721
5018
|
const computedUrl = computed(() => {
|
|
4722
|
-
const baseUrl = toValue(config.baseUrl);
|
|
4723
|
-
const targetUrl = toValue(url);
|
|
5019
|
+
const baseUrl = toValue$1(config.baseUrl);
|
|
5020
|
+
const targetUrl = toValue$1(url);
|
|
4724
5021
|
return baseUrl && !isAbsoluteURL(targetUrl) ? joinPaths(baseUrl, targetUrl) : targetUrl;
|
|
4725
5022
|
});
|
|
4726
5023
|
let options = _options;
|
|
@@ -4791,9 +5088,9 @@ function useFetch(url, ...args) {
|
|
|
4791
5088
|
const responseEvent = createEventHook();
|
|
4792
5089
|
const errorEvent = createEventHook();
|
|
4793
5090
|
const finallyEvent = createEventHook();
|
|
4794
|
-
const isFinished =
|
|
4795
|
-
const isFetching =
|
|
4796
|
-
const aborted =
|
|
5091
|
+
const isFinished = shallowRef(false);
|
|
5092
|
+
const isFetching = shallowRef(false);
|
|
5093
|
+
const aborted = shallowRef(false);
|
|
4797
5094
|
const statusCode = ref(null);
|
|
4798
5095
|
const response = shallowRef(null);
|
|
4799
5096
|
const error = shallowRef(null);
|
|
@@ -4832,9 +5129,9 @@ function useFetch(url, ...args) {
|
|
|
4832
5129
|
method: config.method,
|
|
4833
5130
|
headers: {}
|
|
4834
5131
|
};
|
|
4835
|
-
|
|
5132
|
+
const payload = toValue$1(config.payload);
|
|
5133
|
+
if (payload) {
|
|
4836
5134
|
const headers = headersToObject(defaultFetchOptions.headers);
|
|
4837
|
-
const payload = toValue(config.payload);
|
|
4838
5135
|
const proto = Object.getPrototypeOf(payload);
|
|
4839
5136
|
if (!config.payloadType && payload && (proto === Object.prototype || Array.isArray(proto)) && !(payload instanceof FormData))
|
|
4840
5137
|
config.payloadType = "json";
|
|
@@ -4844,7 +5141,7 @@ function useFetch(url, ...args) {
|
|
|
4844
5141
|
}
|
|
4845
5142
|
let isCanceled = false;
|
|
4846
5143
|
const context = {
|
|
4847
|
-
url: toValue(url),
|
|
5144
|
+
url: toValue$1(url),
|
|
4848
5145
|
options: {
|
|
4849
5146
|
...defaultFetchOptions,
|
|
4850
5147
|
...fetchOptions
|
|
@@ -4883,7 +5180,9 @@ function useFetch(url, ...args) {
|
|
|
4883
5180
|
if (options.afterFetch) {
|
|
4884
5181
|
({ data: responseData } = await options.afterFetch({
|
|
4885
5182
|
data: responseData,
|
|
4886
|
-
response: fetchResponse
|
|
5183
|
+
response: fetchResponse,
|
|
5184
|
+
context,
|
|
5185
|
+
execute
|
|
4887
5186
|
}));
|
|
4888
5187
|
}
|
|
4889
5188
|
data.value = responseData;
|
|
@@ -4895,7 +5194,9 @@ function useFetch(url, ...args) {
|
|
|
4895
5194
|
({ error: errorData, data: responseData } = await options.onFetchError({
|
|
4896
5195
|
data: responseData,
|
|
4897
5196
|
error: fetchError,
|
|
4898
|
-
response: response.value
|
|
5197
|
+
response: response.value,
|
|
5198
|
+
context,
|
|
5199
|
+
execute
|
|
4899
5200
|
}));
|
|
4900
5201
|
}
|
|
4901
5202
|
error.value = errorData;
|
|
@@ -5021,11 +5322,22 @@ const DEFAULT_OPTIONS = {
|
|
|
5021
5322
|
reset: false,
|
|
5022
5323
|
directory: false
|
|
5023
5324
|
};
|
|
5325
|
+
function prepareInitialFiles(files) {
|
|
5326
|
+
if (!files)
|
|
5327
|
+
return null;
|
|
5328
|
+
if (files instanceof FileList)
|
|
5329
|
+
return files;
|
|
5330
|
+
const dt = new DataTransfer();
|
|
5331
|
+
for (const file of files) {
|
|
5332
|
+
dt.items.add(file);
|
|
5333
|
+
}
|
|
5334
|
+
return dt.files;
|
|
5335
|
+
}
|
|
5024
5336
|
function useFileDialog(options = {}) {
|
|
5025
5337
|
const {
|
|
5026
5338
|
document = defaultDocument
|
|
5027
5339
|
} = options;
|
|
5028
|
-
const files = ref(
|
|
5340
|
+
const files = ref(prepareInitialFiles(options.initialFiles));
|
|
5029
5341
|
const { on: onChange, trigger: changeTrigger } = createEventHook();
|
|
5030
5342
|
const { on: onCancel, trigger: cancelTrigger } = createEventHook();
|
|
5031
5343
|
let input;
|
|
@@ -5081,9 +5393,9 @@ function useFileSystemAccess(options = {}) {
|
|
|
5081
5393
|
} = options;
|
|
5082
5394
|
const window = _window;
|
|
5083
5395
|
const isSupported = useSupported(() => window && "showSaveFilePicker" in window && "showOpenFilePicker" in window);
|
|
5084
|
-
const fileHandle =
|
|
5085
|
-
const data =
|
|
5086
|
-
const file =
|
|
5396
|
+
const fileHandle = shallowRef();
|
|
5397
|
+
const data = shallowRef();
|
|
5398
|
+
const file = shallowRef();
|
|
5087
5399
|
const fileName = computed(() => {
|
|
5088
5400
|
var _a, _b;
|
|
5089
5401
|
return (_b = (_a = file.value) == null ? void 0 : _a.name) != null ? _b : "";
|
|
@@ -5103,7 +5415,7 @@ function useFileSystemAccess(options = {}) {
|
|
|
5103
5415
|
async function open(_options = {}) {
|
|
5104
5416
|
if (!isSupported.value)
|
|
5105
5417
|
return;
|
|
5106
|
-
const [handle] = await window.showOpenFilePicker({ ...toValue(options), ..._options });
|
|
5418
|
+
const [handle] = await window.showOpenFilePicker({ ...toValue$1(options), ..._options });
|
|
5107
5419
|
fileHandle.value = handle;
|
|
5108
5420
|
await updateData();
|
|
5109
5421
|
}
|
|
@@ -5144,7 +5456,7 @@ function useFileSystemAccess(options = {}) {
|
|
|
5144
5456
|
async function updateData() {
|
|
5145
5457
|
var _a, _b;
|
|
5146
5458
|
await updateFile();
|
|
5147
|
-
const type = toValue(dataType);
|
|
5459
|
+
const type = toValue$1(dataType);
|
|
5148
5460
|
if (type === "Text")
|
|
5149
5461
|
data.value = await ((_a = file.value) == null ? void 0 : _a.text());
|
|
5150
5462
|
else if (type === "ArrayBuffer")
|
|
@@ -5152,7 +5464,7 @@ function useFileSystemAccess(options = {}) {
|
|
|
5152
5464
|
else if (type === "Blob")
|
|
5153
5465
|
data.value = file.value;
|
|
5154
5466
|
}
|
|
5155
|
-
watch(() => toValue(dataType), updateData);
|
|
5467
|
+
watch(() => toValue$1(dataType), updateData);
|
|
5156
5468
|
return {
|
|
5157
5469
|
isSupported,
|
|
5158
5470
|
data,
|
|
@@ -5171,14 +5483,15 @@ function useFileSystemAccess(options = {}) {
|
|
|
5171
5483
|
|
|
5172
5484
|
function useFocus(target, options = {}) {
|
|
5173
5485
|
const { initialValue = false, focusVisible = false, preventScroll = false } = options;
|
|
5174
|
-
const innerFocused =
|
|
5486
|
+
const innerFocused = shallowRef(false);
|
|
5175
5487
|
const targetElement = computed(() => unrefElement(target));
|
|
5488
|
+
const listenerOptions = { passive: true };
|
|
5176
5489
|
useEventListener(targetElement, "focus", (event) => {
|
|
5177
5490
|
var _a, _b;
|
|
5178
5491
|
if (!focusVisible || ((_b = (_a = event.target).matches) == null ? void 0 : _b.call(_a, ":focus-visible")))
|
|
5179
5492
|
innerFocused.value = true;
|
|
5180
|
-
});
|
|
5181
|
-
useEventListener(targetElement, "blur", () => innerFocused.value = false);
|
|
5493
|
+
}, listenerOptions);
|
|
5494
|
+
useEventListener(targetElement, "blur", () => innerFocused.value = false, listenerOptions);
|
|
5182
5495
|
const focused = computed({
|
|
5183
5496
|
get: () => innerFocused.value,
|
|
5184
5497
|
set(value) {
|
|
@@ -5201,23 +5514,28 @@ function useFocus(target, options = {}) {
|
|
|
5201
5514
|
|
|
5202
5515
|
const EVENT_FOCUS_IN = "focusin";
|
|
5203
5516
|
const EVENT_FOCUS_OUT = "focusout";
|
|
5517
|
+
const PSEUDO_CLASS_FOCUS_WITHIN = ":focus-within";
|
|
5204
5518
|
function useFocusWithin(target, options = {}) {
|
|
5205
5519
|
const { window = defaultWindow } = options;
|
|
5206
5520
|
const targetElement = computed(() => unrefElement(target));
|
|
5207
|
-
const _focused =
|
|
5521
|
+
const _focused = shallowRef(false);
|
|
5208
5522
|
const focused = computed(() => _focused.value);
|
|
5209
5523
|
const activeElement = useActiveElement(options);
|
|
5210
5524
|
if (!window || !activeElement.value) {
|
|
5211
5525
|
return { focused };
|
|
5212
5526
|
}
|
|
5213
|
-
|
|
5214
|
-
useEventListener(targetElement,
|
|
5527
|
+
const listenerOptions = { passive: true };
|
|
5528
|
+
useEventListener(targetElement, EVENT_FOCUS_IN, () => _focused.value = true, listenerOptions);
|
|
5529
|
+
useEventListener(targetElement, EVENT_FOCUS_OUT, () => {
|
|
5530
|
+
var _a, _b, _c;
|
|
5531
|
+
return _focused.value = (_c = (_b = (_a = targetElement.value) == null ? void 0 : _a.matches) == null ? void 0 : _b.call(_a, PSEUDO_CLASS_FOCUS_WITHIN)) != null ? _c : false;
|
|
5532
|
+
}, listenerOptions);
|
|
5215
5533
|
return { focused };
|
|
5216
5534
|
}
|
|
5217
5535
|
|
|
5218
5536
|
function useFps(options) {
|
|
5219
5537
|
var _a;
|
|
5220
|
-
const fps =
|
|
5538
|
+
const fps = shallowRef(0);
|
|
5221
5539
|
if (typeof performance === "undefined")
|
|
5222
5540
|
return fps;
|
|
5223
5541
|
const every = (_a = options == null ? void 0 : options.every) != null ? _a : 10;
|
|
@@ -5250,9 +5568,9 @@ function useFullscreen(target, options = {}) {
|
|
|
5250
5568
|
} = options;
|
|
5251
5569
|
const targetRef = computed(() => {
|
|
5252
5570
|
var _a;
|
|
5253
|
-
return (_a = unrefElement(target)) != null ? _a : document == null ? void 0 : document.
|
|
5571
|
+
return (_a = unrefElement(target)) != null ? _a : document == null ? void 0 : document.documentElement;
|
|
5254
5572
|
});
|
|
5255
|
-
const isFullscreen =
|
|
5573
|
+
const isFullscreen = shallowRef(false);
|
|
5256
5574
|
const requestMethod = computed(() => {
|
|
5257
5575
|
return [
|
|
5258
5576
|
"requestFullscreen",
|
|
@@ -5341,8 +5659,9 @@ function useFullscreen(target, options = {}) {
|
|
|
5341
5659
|
if (!isElementFullScreenValue || isElementFullScreenValue && isCurrentElementFullScreen())
|
|
5342
5660
|
isFullscreen.value = isElementFullScreenValue;
|
|
5343
5661
|
};
|
|
5344
|
-
|
|
5345
|
-
useEventListener(
|
|
5662
|
+
const listenerOptions = { capture: false, passive: true };
|
|
5663
|
+
useEventListener(document, eventHandlers, handlerCallback, listenerOptions);
|
|
5664
|
+
useEventListener(() => unrefElement(targetRef), eventHandlers, handlerCallback, listenerOptions);
|
|
5346
5665
|
if (autoExit)
|
|
5347
5666
|
tryOnScopeDispose(exit);
|
|
5348
5667
|
return {
|
|
@@ -5443,8 +5762,9 @@ function useGamepad(options = {}) {
|
|
|
5443
5762
|
gamepads.value = gamepads.value.filter((x) => x.index !== gamepad.index);
|
|
5444
5763
|
onDisconnectedHook.trigger(gamepad.index);
|
|
5445
5764
|
};
|
|
5446
|
-
|
|
5447
|
-
useEventListener("
|
|
5765
|
+
const listenerOptions = { passive: true };
|
|
5766
|
+
useEventListener("gamepadconnected", (e) => onGamepadConnected(e.gamepad), listenerOptions);
|
|
5767
|
+
useEventListener("gamepaddisconnected", (e) => onGamepadDisconnected(e.gamepad), listenerOptions);
|
|
5448
5768
|
tryOnMounted(() => {
|
|
5449
5769
|
const _gamepads = (navigator == null ? void 0 : navigator.getGamepads()) || [];
|
|
5450
5770
|
for (const gamepad of _gamepads) {
|
|
@@ -5532,8 +5852,8 @@ function useIdle(timeout = oneMinute, options = {}) {
|
|
|
5532
5852
|
window = defaultWindow,
|
|
5533
5853
|
eventFilter = throttleFilter(50)
|
|
5534
5854
|
} = options;
|
|
5535
|
-
const idle =
|
|
5536
|
-
const lastActive =
|
|
5855
|
+
const idle = shallowRef(initialState);
|
|
5856
|
+
const lastActive = shallowRef(timestamp());
|
|
5537
5857
|
let timer;
|
|
5538
5858
|
const reset = () => {
|
|
5539
5859
|
idle.value = false;
|
|
@@ -5549,13 +5869,14 @@ function useIdle(timeout = oneMinute, options = {}) {
|
|
|
5549
5869
|
);
|
|
5550
5870
|
if (window) {
|
|
5551
5871
|
const document = window.document;
|
|
5872
|
+
const listenerOptions = { passive: true };
|
|
5552
5873
|
for (const event of events)
|
|
5553
|
-
useEventListener(window, event, onEvent,
|
|
5874
|
+
useEventListener(window, event, onEvent, listenerOptions);
|
|
5554
5875
|
if (listenForVisibilityChange) {
|
|
5555
5876
|
useEventListener(document, "visibilitychange", () => {
|
|
5556
5877
|
if (!document.hidden)
|
|
5557
5878
|
onEvent();
|
|
5558
|
-
});
|
|
5879
|
+
}, listenerOptions);
|
|
5559
5880
|
}
|
|
5560
5881
|
reset();
|
|
5561
5882
|
}
|
|
@@ -5569,27 +5890,39 @@ function useIdle(timeout = oneMinute, options = {}) {
|
|
|
5569
5890
|
async function loadImage(options) {
|
|
5570
5891
|
return new Promise((resolve, reject) => {
|
|
5571
5892
|
const img = new Image();
|
|
5572
|
-
const { src, srcset, sizes, class: clazz, loading, crossorigin, referrerPolicy } = options;
|
|
5893
|
+
const { src, srcset, sizes, class: clazz, loading, crossorigin, referrerPolicy, width, height, decoding, fetchPriority, ismap, usemap } = options;
|
|
5573
5894
|
img.src = src;
|
|
5574
|
-
if (srcset)
|
|
5895
|
+
if (srcset != null)
|
|
5575
5896
|
img.srcset = srcset;
|
|
5576
|
-
if (sizes)
|
|
5897
|
+
if (sizes != null)
|
|
5577
5898
|
img.sizes = sizes;
|
|
5578
|
-
if (clazz)
|
|
5899
|
+
if (clazz != null)
|
|
5579
5900
|
img.className = clazz;
|
|
5580
|
-
if (loading)
|
|
5901
|
+
if (loading != null)
|
|
5581
5902
|
img.loading = loading;
|
|
5582
|
-
if (crossorigin)
|
|
5903
|
+
if (crossorigin != null)
|
|
5583
5904
|
img.crossOrigin = crossorigin;
|
|
5584
|
-
if (referrerPolicy)
|
|
5905
|
+
if (referrerPolicy != null)
|
|
5585
5906
|
img.referrerPolicy = referrerPolicy;
|
|
5907
|
+
if (width != null)
|
|
5908
|
+
img.width = width;
|
|
5909
|
+
if (height != null)
|
|
5910
|
+
img.height = height;
|
|
5911
|
+
if (decoding != null)
|
|
5912
|
+
img.decoding = decoding;
|
|
5913
|
+
if (fetchPriority != null)
|
|
5914
|
+
img.fetchPriority = fetchPriority;
|
|
5915
|
+
if (ismap != null)
|
|
5916
|
+
img.isMap = ismap;
|
|
5917
|
+
if (usemap != null)
|
|
5918
|
+
img.useMap = usemap;
|
|
5586
5919
|
img.onload = () => resolve(img);
|
|
5587
5920
|
img.onerror = reject;
|
|
5588
5921
|
});
|
|
5589
5922
|
}
|
|
5590
5923
|
function useImage(options, asyncStateOptions = {}) {
|
|
5591
5924
|
const state = useAsyncState(
|
|
5592
|
-
() => loadImage(toValue(options)),
|
|
5925
|
+
() => loadImage(toValue$1(options)),
|
|
5593
5926
|
void 0,
|
|
5594
5927
|
{
|
|
5595
5928
|
resetOnExecute: true,
|
|
@@ -5597,7 +5930,7 @@ function useImage(options, asyncStateOptions = {}) {
|
|
|
5597
5930
|
}
|
|
5598
5931
|
);
|
|
5599
5932
|
watch(
|
|
5600
|
-
() => toValue(options),
|
|
5933
|
+
() => toValue$1(options),
|
|
5601
5934
|
() => state.execute(asyncStateOptions.delay),
|
|
5602
5935
|
{ deep: true }
|
|
5603
5936
|
);
|
|
@@ -5635,8 +5968,8 @@ function useScroll(element, options = {}) {
|
|
|
5635
5968
|
console.error(e);
|
|
5636
5969
|
}
|
|
5637
5970
|
} = options;
|
|
5638
|
-
const internalX =
|
|
5639
|
-
const internalY =
|
|
5971
|
+
const internalX = shallowRef(0);
|
|
5972
|
+
const internalY = shallowRef(0);
|
|
5640
5973
|
const x = computed({
|
|
5641
5974
|
get() {
|
|
5642
5975
|
return internalX.value;
|
|
@@ -5657,13 +5990,13 @@ function useScroll(element, options = {}) {
|
|
|
5657
5990
|
var _a, _b, _c, _d;
|
|
5658
5991
|
if (!window)
|
|
5659
5992
|
return;
|
|
5660
|
-
const _element = toValue(element);
|
|
5993
|
+
const _element = toValue$1(element);
|
|
5661
5994
|
if (!_element)
|
|
5662
5995
|
return;
|
|
5663
5996
|
(_c = _element instanceof Document ? window.document.body : _element) == null ? void 0 : _c.scrollTo({
|
|
5664
|
-
top: (_a = toValue(_y)) != null ? _a : y.value,
|
|
5665
|
-
left: (_b = toValue(_x)) != null ? _b : x.value,
|
|
5666
|
-
behavior: toValue(behavior)
|
|
5997
|
+
top: (_a = toValue$1(_y)) != null ? _a : y.value,
|
|
5998
|
+
left: (_b = toValue$1(_x)) != null ? _b : x.value,
|
|
5999
|
+
behavior: toValue$1(behavior)
|
|
5667
6000
|
});
|
|
5668
6001
|
const scrollContainer = ((_d = _element == null ? void 0 : _element.document) == null ? void 0 : _d.documentElement) || (_element == null ? void 0 : _element.documentElement) || _element;
|
|
5669
6002
|
if (x != null)
|
|
@@ -5671,7 +6004,7 @@ function useScroll(element, options = {}) {
|
|
|
5671
6004
|
if (y != null)
|
|
5672
6005
|
internalY.value = scrollContainer.scrollTop;
|
|
5673
6006
|
}
|
|
5674
|
-
const isScrolling =
|
|
6007
|
+
const isScrolling = shallowRef(false);
|
|
5675
6008
|
const arrivedState = reactive({
|
|
5676
6009
|
left: true,
|
|
5677
6010
|
right: false,
|
|
@@ -5700,12 +6033,13 @@ function useScroll(element, options = {}) {
|
|
|
5700
6033
|
if (!window)
|
|
5701
6034
|
return;
|
|
5702
6035
|
const el = ((_a = target == null ? void 0 : target.document) == null ? void 0 : _a.documentElement) || (target == null ? void 0 : target.documentElement) || unrefElement(target);
|
|
5703
|
-
const { display, flexDirection } = getComputedStyle(el);
|
|
6036
|
+
const { display, flexDirection, direction } = getComputedStyle(el);
|
|
6037
|
+
const directionMultipler = direction === "rtl" ? -1 : 1;
|
|
5704
6038
|
const scrollLeft = el.scrollLeft;
|
|
5705
6039
|
directions.left = scrollLeft < internalX.value;
|
|
5706
6040
|
directions.right = scrollLeft > internalX.value;
|
|
5707
|
-
const left =
|
|
5708
|
-
const right =
|
|
6041
|
+
const left = scrollLeft * directionMultipler <= (offset.left || 0);
|
|
6042
|
+
const right = scrollLeft * directionMultipler + el.clientWidth >= el.scrollWidth - (offset.right || 0) - ARRIVED_STATE_THRESHOLD_PIXELS;
|
|
5709
6043
|
if (display === "flex" && flexDirection === "row-reverse") {
|
|
5710
6044
|
arrivedState.left = right;
|
|
5711
6045
|
arrivedState.right = left;
|
|
@@ -5719,8 +6053,8 @@ function useScroll(element, options = {}) {
|
|
|
5719
6053
|
scrollTop = window.document.body.scrollTop;
|
|
5720
6054
|
directions.top = scrollTop < internalY.value;
|
|
5721
6055
|
directions.bottom = scrollTop > internalY.value;
|
|
5722
|
-
const top =
|
|
5723
|
-
const bottom =
|
|
6056
|
+
const top = scrollTop <= (offset.top || 0);
|
|
6057
|
+
const bottom = scrollTop + el.clientHeight >= el.scrollHeight - (offset.bottom || 0) - ARRIVED_STATE_THRESHOLD_PIXELS;
|
|
5724
6058
|
if (display === "flex" && flexDirection === "column-reverse") {
|
|
5725
6059
|
arrivedState.top = bottom;
|
|
5726
6060
|
arrivedState.bottom = top;
|
|
@@ -5748,7 +6082,7 @@ function useScroll(element, options = {}) {
|
|
|
5748
6082
|
);
|
|
5749
6083
|
tryOnMounted(() => {
|
|
5750
6084
|
try {
|
|
5751
|
-
const _element = toValue(element);
|
|
6085
|
+
const _element = toValue$1(element);
|
|
5752
6086
|
if (!_element)
|
|
5753
6087
|
return;
|
|
5754
6088
|
setArrivedState(_element);
|
|
@@ -5769,7 +6103,7 @@ function useScroll(element, options = {}) {
|
|
|
5769
6103
|
arrivedState,
|
|
5770
6104
|
directions,
|
|
5771
6105
|
measure() {
|
|
5772
|
-
const _element = toValue(element);
|
|
6106
|
+
const _element = toValue$1(element);
|
|
5773
6107
|
if (window && _element)
|
|
5774
6108
|
setArrivedState(_element);
|
|
5775
6109
|
}
|
|
@@ -5796,7 +6130,7 @@ function useInfiniteScroll(element, onLoadMore, options = {}) {
|
|
|
5796
6130
|
const promise = ref();
|
|
5797
6131
|
const isLoading = computed(() => !!promise.value);
|
|
5798
6132
|
const observedElement = computed(() => {
|
|
5799
|
-
return resolveElement(toValue(element));
|
|
6133
|
+
return resolveElement(toValue$1(element));
|
|
5800
6134
|
});
|
|
5801
6135
|
const isElementVisible = useElementVisibility(observedElement);
|
|
5802
6136
|
function checkAndLoad() {
|
|
@@ -5844,7 +6178,7 @@ function useKeyModifier(modifier, options = {}) {
|
|
|
5844
6178
|
useEventListener(document, listenerEvent, (evt) => {
|
|
5845
6179
|
if (typeof evt.getModifierState === "function")
|
|
5846
6180
|
state.value = evt.getModifierState(modifier);
|
|
5847
|
-
});
|
|
6181
|
+
}, { passive: true });
|
|
5848
6182
|
});
|
|
5849
6183
|
}
|
|
5850
6184
|
return state;
|
|
@@ -5930,8 +6264,8 @@ function useMagicKeys(options = {}) {
|
|
|
5930
6264
|
updateRefs(e, false);
|
|
5931
6265
|
return onEventFired(e);
|
|
5932
6266
|
}, { passive });
|
|
5933
|
-
useEventListener("blur", reset, { passive
|
|
5934
|
-
useEventListener("focus", reset, { passive
|
|
6267
|
+
useEventListener("blur", reset, { passive });
|
|
6268
|
+
useEventListener("focus", reset, { passive });
|
|
5935
6269
|
const proxy = new Proxy(
|
|
5936
6270
|
refs,
|
|
5937
6271
|
{
|
|
@@ -5944,13 +6278,13 @@ function useMagicKeys(options = {}) {
|
|
|
5944
6278
|
if (!(prop in refs)) {
|
|
5945
6279
|
if (/[+_-]/.test(prop)) {
|
|
5946
6280
|
const keys = prop.split(/[+_-]/g).map((i) => i.trim());
|
|
5947
|
-
refs[prop] = computed(() => keys.
|
|
6281
|
+
refs[prop] = computed(() => keys.map((key) => toValue$1(proxy[key])).every(Boolean));
|
|
5948
6282
|
} else {
|
|
5949
|
-
refs[prop] =
|
|
6283
|
+
refs[prop] = shallowRef(false);
|
|
5950
6284
|
}
|
|
5951
6285
|
}
|
|
5952
6286
|
const r = Reflect.get(target2, prop, rec);
|
|
5953
|
-
return useReactive ? toValue(r) : r;
|
|
6287
|
+
return useReactive ? toValue$1(r) : r;
|
|
5954
6288
|
}
|
|
5955
6289
|
}
|
|
5956
6290
|
);
|
|
@@ -5958,8 +6292,8 @@ function useMagicKeys(options = {}) {
|
|
|
5958
6292
|
}
|
|
5959
6293
|
|
|
5960
6294
|
function usingElRef(source, cb) {
|
|
5961
|
-
if (toValue(source))
|
|
5962
|
-
cb(toValue(source));
|
|
6295
|
+
if (toValue$1(source))
|
|
6296
|
+
cb(toValue$1(source));
|
|
5963
6297
|
}
|
|
5964
6298
|
function timeRangeToArray(timeRanges) {
|
|
5965
6299
|
let ranges = [];
|
|
@@ -5983,20 +6317,21 @@ function useMediaControls(target, options = {}) {
|
|
|
5983
6317
|
const {
|
|
5984
6318
|
document = defaultDocument
|
|
5985
6319
|
} = options;
|
|
5986
|
-
const
|
|
5987
|
-
const
|
|
5988
|
-
const
|
|
5989
|
-
const
|
|
5990
|
-
const
|
|
5991
|
-
const
|
|
5992
|
-
const
|
|
5993
|
-
const
|
|
5994
|
-
const
|
|
6320
|
+
const listenerOptions = { passive: true };
|
|
6321
|
+
const currentTime = shallowRef(0);
|
|
6322
|
+
const duration = shallowRef(0);
|
|
6323
|
+
const seeking = shallowRef(false);
|
|
6324
|
+
const volume = shallowRef(1);
|
|
6325
|
+
const waiting = shallowRef(false);
|
|
6326
|
+
const ended = shallowRef(false);
|
|
6327
|
+
const playing = shallowRef(false);
|
|
6328
|
+
const rate = shallowRef(1);
|
|
6329
|
+
const stalled = shallowRef(false);
|
|
5995
6330
|
const buffered = ref([]);
|
|
5996
6331
|
const tracks = ref([]);
|
|
5997
|
-
const selectedTrack =
|
|
5998
|
-
const isPictureInPicture =
|
|
5999
|
-
const muted =
|
|
6332
|
+
const selectedTrack = shallowRef(-1);
|
|
6333
|
+
const isPictureInPicture = shallowRef(false);
|
|
6334
|
+
const muted = shallowRef(false);
|
|
6000
6335
|
const supportsPictureInPicture = document && "pictureInPictureEnabled" in document;
|
|
6001
6336
|
const sourceErrorEvent = createEventHook();
|
|
6002
6337
|
const playbackErrorEvent = createEventHook();
|
|
@@ -6037,10 +6372,10 @@ function useMediaControls(target, options = {}) {
|
|
|
6037
6372
|
watchEffect(() => {
|
|
6038
6373
|
if (!document)
|
|
6039
6374
|
return;
|
|
6040
|
-
const el = toValue(target);
|
|
6375
|
+
const el = toValue$1(target);
|
|
6041
6376
|
if (!el)
|
|
6042
6377
|
return;
|
|
6043
|
-
const src = toValue(options.src);
|
|
6378
|
+
const src = toValue$1(options.src);
|
|
6044
6379
|
let sources = [];
|
|
6045
6380
|
if (!src)
|
|
6046
6381
|
return;
|
|
@@ -6051,38 +6386,32 @@ function useMediaControls(target, options = {}) {
|
|
|
6051
6386
|
else if (isObject(src))
|
|
6052
6387
|
sources = [src];
|
|
6053
6388
|
el.querySelectorAll("source").forEach((e) => {
|
|
6054
|
-
e.removeEventListener("error", sourceErrorEvent.trigger);
|
|
6055
6389
|
e.remove();
|
|
6056
6390
|
});
|
|
6057
|
-
sources.forEach(({ src: src2, type }) => {
|
|
6391
|
+
sources.forEach(({ src: src2, type, media }) => {
|
|
6058
6392
|
const source = document.createElement("source");
|
|
6059
6393
|
source.setAttribute("src", src2);
|
|
6060
6394
|
source.setAttribute("type", type || "");
|
|
6061
|
-
source.
|
|
6395
|
+
source.setAttribute("media", media || "");
|
|
6396
|
+
useEventListener(source, "error", sourceErrorEvent.trigger, listenerOptions);
|
|
6062
6397
|
el.appendChild(source);
|
|
6063
6398
|
});
|
|
6064
6399
|
el.load();
|
|
6065
6400
|
});
|
|
6066
|
-
tryOnScopeDispose(() => {
|
|
6067
|
-
const el = toValue(target);
|
|
6068
|
-
if (!el)
|
|
6069
|
-
return;
|
|
6070
|
-
el.querySelectorAll("source").forEach((e) => e.removeEventListener("error", sourceErrorEvent.trigger));
|
|
6071
|
-
});
|
|
6072
6401
|
watch([target, volume], () => {
|
|
6073
|
-
const el = toValue(target);
|
|
6402
|
+
const el = toValue$1(target);
|
|
6074
6403
|
if (!el)
|
|
6075
6404
|
return;
|
|
6076
6405
|
el.volume = volume.value;
|
|
6077
6406
|
});
|
|
6078
6407
|
watch([target, muted], () => {
|
|
6079
|
-
const el = toValue(target);
|
|
6408
|
+
const el = toValue$1(target);
|
|
6080
6409
|
if (!el)
|
|
6081
6410
|
return;
|
|
6082
6411
|
el.muted = muted.value;
|
|
6083
6412
|
});
|
|
6084
6413
|
watch([target, rate], () => {
|
|
6085
|
-
const el = toValue(target);
|
|
6414
|
+
const el = toValue$1(target);
|
|
6086
6415
|
if (!el)
|
|
6087
6416
|
return;
|
|
6088
6417
|
el.playbackRate = rate.value;
|
|
@@ -6090,8 +6419,8 @@ function useMediaControls(target, options = {}) {
|
|
|
6090
6419
|
watchEffect(() => {
|
|
6091
6420
|
if (!document)
|
|
6092
6421
|
return;
|
|
6093
|
-
const textTracks = toValue(options.tracks);
|
|
6094
|
-
const el = toValue(target);
|
|
6422
|
+
const textTracks = toValue$1(options.tracks);
|
|
6423
|
+
const el = toValue$1(target);
|
|
6095
6424
|
if (!textTracks || !textTracks.length || !el)
|
|
6096
6425
|
return;
|
|
6097
6426
|
el.querySelectorAll("track").forEach((e) => e.remove());
|
|
@@ -6108,13 +6437,13 @@ function useMediaControls(target, options = {}) {
|
|
|
6108
6437
|
});
|
|
6109
6438
|
});
|
|
6110
6439
|
const { ignoreUpdates: ignoreCurrentTimeUpdates } = watchIgnorable(currentTime, (time) => {
|
|
6111
|
-
const el = toValue(target);
|
|
6440
|
+
const el = toValue$1(target);
|
|
6112
6441
|
if (!el)
|
|
6113
6442
|
return;
|
|
6114
6443
|
el.currentTime = time;
|
|
6115
6444
|
});
|
|
6116
6445
|
const { ignoreUpdates: ignorePlayingUpdates } = watchIgnorable(playing, (isPlaying) => {
|
|
6117
|
-
const el = toValue(target);
|
|
6446
|
+
const el = toValue$1(target);
|
|
6118
6447
|
if (!el)
|
|
6119
6448
|
return;
|
|
6120
6449
|
if (isPlaying) {
|
|
@@ -6126,44 +6455,124 @@ function useMediaControls(target, options = {}) {
|
|
|
6126
6455
|
el.pause();
|
|
6127
6456
|
}
|
|
6128
6457
|
});
|
|
6129
|
-
useEventListener(
|
|
6130
|
-
|
|
6131
|
-
|
|
6132
|
-
|
|
6133
|
-
|
|
6134
|
-
|
|
6135
|
-
|
|
6136
|
-
|
|
6137
|
-
|
|
6138
|
-
|
|
6139
|
-
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
|
|
6146
|
-
|
|
6147
|
-
useEventListener(
|
|
6148
|
-
|
|
6149
|
-
|
|
6150
|
-
|
|
6151
|
-
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6458
|
+
useEventListener(
|
|
6459
|
+
target,
|
|
6460
|
+
"timeupdate",
|
|
6461
|
+
() => ignoreCurrentTimeUpdates(() => currentTime.value = toValue$1(target).currentTime),
|
|
6462
|
+
listenerOptions
|
|
6463
|
+
);
|
|
6464
|
+
useEventListener(
|
|
6465
|
+
target,
|
|
6466
|
+
"durationchange",
|
|
6467
|
+
() => duration.value = toValue$1(target).duration,
|
|
6468
|
+
listenerOptions
|
|
6469
|
+
);
|
|
6470
|
+
useEventListener(
|
|
6471
|
+
target,
|
|
6472
|
+
"progress",
|
|
6473
|
+
() => buffered.value = timeRangeToArray(toValue$1(target).buffered),
|
|
6474
|
+
listenerOptions
|
|
6475
|
+
);
|
|
6476
|
+
useEventListener(
|
|
6477
|
+
target,
|
|
6478
|
+
"seeking",
|
|
6479
|
+
() => seeking.value = true,
|
|
6480
|
+
listenerOptions
|
|
6481
|
+
);
|
|
6482
|
+
useEventListener(
|
|
6483
|
+
target,
|
|
6484
|
+
"seeked",
|
|
6485
|
+
() => seeking.value = false,
|
|
6486
|
+
listenerOptions
|
|
6487
|
+
);
|
|
6488
|
+
useEventListener(
|
|
6489
|
+
target,
|
|
6490
|
+
["waiting", "loadstart"],
|
|
6491
|
+
() => {
|
|
6492
|
+
waiting.value = true;
|
|
6493
|
+
ignorePlayingUpdates(() => playing.value = false);
|
|
6494
|
+
},
|
|
6495
|
+
listenerOptions
|
|
6496
|
+
);
|
|
6497
|
+
useEventListener(
|
|
6498
|
+
target,
|
|
6499
|
+
"loadeddata",
|
|
6500
|
+
() => waiting.value = false,
|
|
6501
|
+
listenerOptions
|
|
6502
|
+
);
|
|
6503
|
+
useEventListener(
|
|
6504
|
+
target,
|
|
6505
|
+
"playing",
|
|
6506
|
+
() => {
|
|
6507
|
+
waiting.value = false;
|
|
6508
|
+
ended.value = false;
|
|
6509
|
+
ignorePlayingUpdates(() => playing.value = true);
|
|
6510
|
+
},
|
|
6511
|
+
listenerOptions
|
|
6512
|
+
);
|
|
6513
|
+
useEventListener(
|
|
6514
|
+
target,
|
|
6515
|
+
"ratechange",
|
|
6516
|
+
() => rate.value = toValue$1(target).playbackRate,
|
|
6517
|
+
listenerOptions
|
|
6518
|
+
);
|
|
6519
|
+
useEventListener(
|
|
6520
|
+
target,
|
|
6521
|
+
"stalled",
|
|
6522
|
+
() => stalled.value = true,
|
|
6523
|
+
listenerOptions
|
|
6524
|
+
);
|
|
6525
|
+
useEventListener(
|
|
6526
|
+
target,
|
|
6527
|
+
"ended",
|
|
6528
|
+
() => ended.value = true,
|
|
6529
|
+
listenerOptions
|
|
6530
|
+
);
|
|
6531
|
+
useEventListener(
|
|
6532
|
+
target,
|
|
6533
|
+
"pause",
|
|
6534
|
+
() => ignorePlayingUpdates(() => playing.value = false),
|
|
6535
|
+
listenerOptions
|
|
6536
|
+
);
|
|
6537
|
+
useEventListener(
|
|
6538
|
+
target,
|
|
6539
|
+
"play",
|
|
6540
|
+
() => ignorePlayingUpdates(() => playing.value = true),
|
|
6541
|
+
listenerOptions
|
|
6542
|
+
);
|
|
6543
|
+
useEventListener(
|
|
6544
|
+
target,
|
|
6545
|
+
"enterpictureinpicture",
|
|
6546
|
+
() => isPictureInPicture.value = true,
|
|
6547
|
+
listenerOptions
|
|
6548
|
+
);
|
|
6549
|
+
useEventListener(
|
|
6550
|
+
target,
|
|
6551
|
+
"leavepictureinpicture",
|
|
6552
|
+
() => isPictureInPicture.value = false,
|
|
6553
|
+
listenerOptions
|
|
6554
|
+
);
|
|
6555
|
+
useEventListener(
|
|
6556
|
+
target,
|
|
6557
|
+
"volumechange",
|
|
6558
|
+
() => {
|
|
6559
|
+
const el = toValue$1(target);
|
|
6560
|
+
if (!el)
|
|
6561
|
+
return;
|
|
6562
|
+
volume.value = el.volume;
|
|
6563
|
+
muted.value = el.muted;
|
|
6564
|
+
},
|
|
6565
|
+
listenerOptions
|
|
6566
|
+
);
|
|
6158
6567
|
const listeners = [];
|
|
6159
6568
|
const stop = watch([target], () => {
|
|
6160
|
-
const el = toValue(target);
|
|
6569
|
+
const el = toValue$1(target);
|
|
6161
6570
|
if (!el)
|
|
6162
6571
|
return;
|
|
6163
6572
|
stop();
|
|
6164
|
-
listeners[0] = useEventListener(el.textTracks, "addtrack", () => tracks.value = tracksToArray(el.textTracks));
|
|
6165
|
-
listeners[1] = useEventListener(el.textTracks, "removetrack", () => tracks.value = tracksToArray(el.textTracks));
|
|
6166
|
-
listeners[2] = useEventListener(el.textTracks, "change", () => tracks.value = tracksToArray(el.textTracks));
|
|
6573
|
+
listeners[0] = useEventListener(el.textTracks, "addtrack", () => tracks.value = tracksToArray(el.textTracks), listenerOptions);
|
|
6574
|
+
listeners[1] = useEventListener(el.textTracks, "removetrack", () => tracks.value = tracksToArray(el.textTracks), listenerOptions);
|
|
6575
|
+
listeners[2] = useEventListener(el.textTracks, "change", () => tracks.value = tracksToArray(el.textTracks), listenerOptions);
|
|
6167
6576
|
});
|
|
6168
6577
|
tryOnScopeDispose(() => listeners.forEach((listener) => listener()));
|
|
6169
6578
|
return {
|
|
@@ -6243,7 +6652,7 @@ const UseMouseBuiltinExtractors = {
|
|
|
6243
6652
|
page: (event) => [event.pageX, event.pageY],
|
|
6244
6653
|
client: (event) => [event.clientX, event.clientY],
|
|
6245
6654
|
screen: (event) => [event.screenX, event.screenY],
|
|
6246
|
-
movement: (event) => event instanceof
|
|
6655
|
+
movement: (event) => event instanceof MouseEvent ? [event.movementX, event.movementY] : null
|
|
6247
6656
|
};
|
|
6248
6657
|
function useMouse(options = {}) {
|
|
6249
6658
|
const {
|
|
@@ -6259,9 +6668,9 @@ function useMouse(options = {}) {
|
|
|
6259
6668
|
let _prevMouseEvent = null;
|
|
6260
6669
|
let _prevScrollX = 0;
|
|
6261
6670
|
let _prevScrollY = 0;
|
|
6262
|
-
const x =
|
|
6263
|
-
const y =
|
|
6264
|
-
const sourceType =
|
|
6671
|
+
const x = shallowRef(initialValue.x);
|
|
6672
|
+
const y = shallowRef(initialValue.y);
|
|
6673
|
+
const sourceType = shallowRef(null);
|
|
6265
6674
|
const extractor = typeof type === "function" ? type : UseMouseBuiltinExtractors[type];
|
|
6266
6675
|
const mouseHandler = (event) => {
|
|
6267
6676
|
const result = extractor(event);
|
|
@@ -6309,7 +6718,7 @@ function useMouse(options = {}) {
|
|
|
6309
6718
|
useEventListener(target, "touchend", reset, listenerOptions);
|
|
6310
6719
|
}
|
|
6311
6720
|
if (scroll && type === "page")
|
|
6312
|
-
useEventListener(window, "scroll", scrollHandlerWrapper,
|
|
6721
|
+
useEventListener(window, "scroll", scrollHandlerWrapper, listenerOptions);
|
|
6313
6722
|
}
|
|
6314
6723
|
return {
|
|
6315
6724
|
x,
|
|
@@ -6326,13 +6735,13 @@ function useMouseInElement(target, options = {}) {
|
|
|
6326
6735
|
const type = options.type || "page";
|
|
6327
6736
|
const { x, y, sourceType } = useMouse(options);
|
|
6328
6737
|
const targetRef = ref(target != null ? target : window == null ? void 0 : window.document.body);
|
|
6329
|
-
const elementX =
|
|
6330
|
-
const elementY =
|
|
6331
|
-
const elementPositionX =
|
|
6332
|
-
const elementPositionY =
|
|
6333
|
-
const elementHeight =
|
|
6334
|
-
const elementWidth =
|
|
6335
|
-
const isOutside =
|
|
6738
|
+
const elementX = shallowRef(0);
|
|
6739
|
+
const elementY = shallowRef(0);
|
|
6740
|
+
const elementPositionX = shallowRef(0);
|
|
6741
|
+
const elementPositionY = shallowRef(0);
|
|
6742
|
+
const elementHeight = shallowRef(0);
|
|
6743
|
+
const elementWidth = shallowRef(0);
|
|
6744
|
+
const isOutside = shallowRef(true);
|
|
6336
6745
|
let stop = () => {
|
|
6337
6746
|
};
|
|
6338
6747
|
if (window) {
|
|
@@ -6362,9 +6771,12 @@ function useMouseInElement(target, options = {}) {
|
|
|
6362
6771
|
},
|
|
6363
6772
|
{ immediate: true }
|
|
6364
6773
|
);
|
|
6365
|
-
useEventListener(
|
|
6366
|
-
|
|
6367
|
-
|
|
6774
|
+
useEventListener(
|
|
6775
|
+
document,
|
|
6776
|
+
"mouseleave",
|
|
6777
|
+
() => isOutside.value = true,
|
|
6778
|
+
{ passive: true }
|
|
6779
|
+
);
|
|
6368
6780
|
}
|
|
6369
6781
|
return {
|
|
6370
6782
|
x,
|
|
@@ -6397,27 +6809,32 @@ function useMousePressed(options = {}) {
|
|
|
6397
6809
|
sourceType
|
|
6398
6810
|
};
|
|
6399
6811
|
}
|
|
6400
|
-
const onPressed = (srcType) => () => {
|
|
6812
|
+
const onPressed = (srcType) => (event) => {
|
|
6813
|
+
var _a;
|
|
6401
6814
|
pressed.value = true;
|
|
6402
6815
|
sourceType.value = srcType;
|
|
6816
|
+
(_a = options.onPressed) == null ? void 0 : _a.call(options, event);
|
|
6403
6817
|
};
|
|
6404
|
-
const onReleased = () => {
|
|
6818
|
+
const onReleased = (event) => {
|
|
6819
|
+
var _a;
|
|
6405
6820
|
pressed.value = false;
|
|
6406
6821
|
sourceType.value = null;
|
|
6822
|
+
(_a = options.onReleased) == null ? void 0 : _a.call(options, event);
|
|
6407
6823
|
};
|
|
6408
6824
|
const target = computed(() => unrefElement(options.target) || window);
|
|
6409
|
-
|
|
6410
|
-
useEventListener(
|
|
6411
|
-
useEventListener(window, "
|
|
6825
|
+
const listenerOptions = { passive: true, capture };
|
|
6826
|
+
useEventListener(target, "mousedown", onPressed("mouse"), listenerOptions);
|
|
6827
|
+
useEventListener(window, "mouseleave", onReleased, listenerOptions);
|
|
6828
|
+
useEventListener(window, "mouseup", onReleased, listenerOptions);
|
|
6412
6829
|
if (drag) {
|
|
6413
|
-
useEventListener(target, "dragstart", onPressed("mouse"),
|
|
6414
|
-
useEventListener(window, "drop", onReleased,
|
|
6415
|
-
useEventListener(window, "dragend", onReleased,
|
|
6830
|
+
useEventListener(target, "dragstart", onPressed("mouse"), listenerOptions);
|
|
6831
|
+
useEventListener(window, "drop", onReleased, listenerOptions);
|
|
6832
|
+
useEventListener(window, "dragend", onReleased, listenerOptions);
|
|
6416
6833
|
}
|
|
6417
6834
|
if (touch) {
|
|
6418
|
-
useEventListener(target, "touchstart", onPressed("touch"),
|
|
6419
|
-
useEventListener(window, "touchend", onReleased,
|
|
6420
|
-
useEventListener(window, "touchcancel", onReleased,
|
|
6835
|
+
useEventListener(target, "touchstart", onPressed("touch"), listenerOptions);
|
|
6836
|
+
useEventListener(window, "touchend", onReleased, listenerOptions);
|
|
6837
|
+
useEventListener(window, "touchcancel", onReleased, listenerOptions);
|
|
6421
6838
|
}
|
|
6422
6839
|
return {
|
|
6423
6840
|
pressed,
|
|
@@ -6433,7 +6850,7 @@ function useNavigatorLanguage(options = {}) {
|
|
|
6433
6850
|
useEventListener(window, "languagechange", () => {
|
|
6434
6851
|
if (navigator)
|
|
6435
6852
|
language.value = navigator.language;
|
|
6436
|
-
});
|
|
6853
|
+
}, { passive: true });
|
|
6437
6854
|
return {
|
|
6438
6855
|
isSupported,
|
|
6439
6856
|
language
|
|
@@ -6444,8 +6861,8 @@ function useNetwork(options = {}) {
|
|
|
6444
6861
|
const { window = defaultWindow } = options;
|
|
6445
6862
|
const navigator = window == null ? void 0 : window.navigator;
|
|
6446
6863
|
const isSupported = useSupported(() => navigator && "connection" in navigator);
|
|
6447
|
-
const isOnline =
|
|
6448
|
-
const saveData =
|
|
6864
|
+
const isOnline = shallowRef(true);
|
|
6865
|
+
const saveData = shallowRef(false);
|
|
6449
6866
|
const offlineAt = ref(void 0);
|
|
6450
6867
|
const onlineAt = ref(void 0);
|
|
6451
6868
|
const downlink = ref(void 0);
|
|
@@ -6469,21 +6886,22 @@ function useNetwork(options = {}) {
|
|
|
6469
6886
|
type.value = connection.type;
|
|
6470
6887
|
}
|
|
6471
6888
|
}
|
|
6889
|
+
const listenerOptions = { passive: true };
|
|
6472
6890
|
if (window) {
|
|
6473
6891
|
useEventListener(window, "offline", () => {
|
|
6474
6892
|
isOnline.value = false;
|
|
6475
6893
|
offlineAt.value = Date.now();
|
|
6476
|
-
});
|
|
6894
|
+
}, listenerOptions);
|
|
6477
6895
|
useEventListener(window, "online", () => {
|
|
6478
6896
|
isOnline.value = true;
|
|
6479
6897
|
onlineAt.value = Date.now();
|
|
6480
|
-
});
|
|
6898
|
+
}, listenerOptions);
|
|
6481
6899
|
}
|
|
6482
6900
|
if (connection)
|
|
6483
|
-
useEventListener(connection, "change", updateNetworkInformation,
|
|
6901
|
+
useEventListener(connection, "change", updateNetworkInformation, listenerOptions);
|
|
6484
6902
|
updateNetworkInformation();
|
|
6485
6903
|
return {
|
|
6486
|
-
isSupported
|
|
6904
|
+
isSupported,
|
|
6487
6905
|
isOnline: readonly(isOnline),
|
|
6488
6906
|
saveData: readonly(saveData),
|
|
6489
6907
|
offlineAt: readonly(offlineAt),
|
|
@@ -6522,7 +6940,7 @@ function useObjectUrl(object) {
|
|
|
6522
6940
|
url.value = void 0;
|
|
6523
6941
|
};
|
|
6524
6942
|
watch(
|
|
6525
|
-
() => toValue(object),
|
|
6943
|
+
() => toValue$1(object),
|
|
6526
6944
|
(newObject) => {
|
|
6527
6945
|
release();
|
|
6528
6946
|
if (newObject)
|
|
@@ -6536,14 +6954,14 @@ function useObjectUrl(object) {
|
|
|
6536
6954
|
|
|
6537
6955
|
function useClamp(value, min, max) {
|
|
6538
6956
|
if (typeof value === "function" || isReadonly(value))
|
|
6539
|
-
return computed(() => clamp(toValue(value), toValue(min), toValue(max)));
|
|
6957
|
+
return computed(() => clamp(toValue$1(value), toValue$1(min), toValue$1(max)));
|
|
6540
6958
|
const _value = ref(value);
|
|
6541
6959
|
return computed({
|
|
6542
6960
|
get() {
|
|
6543
|
-
return _value.value = clamp(_value.value, toValue(min), toValue(max));
|
|
6961
|
+
return _value.value = clamp(_value.value, toValue$1(min), toValue$1(max));
|
|
6544
6962
|
},
|
|
6545
6963
|
set(value2) {
|
|
6546
|
-
_value.value = clamp(value2, toValue(min), toValue(max));
|
|
6964
|
+
_value.value = clamp(value2, toValue$1(min), toValue$1(max));
|
|
6547
6965
|
}
|
|
6548
6966
|
});
|
|
6549
6967
|
}
|
|
@@ -6560,7 +6978,7 @@ function useOffsetPagination(options) {
|
|
|
6560
6978
|
const currentPageSize = useClamp(pageSize, 1, Number.POSITIVE_INFINITY);
|
|
6561
6979
|
const pageCount = computed(() => Math.max(
|
|
6562
6980
|
1,
|
|
6563
|
-
Math.ceil(toValue(total) / toValue(currentPageSize))
|
|
6981
|
+
Math.ceil(toValue$1(total) / toValue$1(currentPageSize))
|
|
6564
6982
|
));
|
|
6565
6983
|
const currentPage = useClamp(page, 1, pageCount);
|
|
6566
6984
|
const isFirstPage = computed(() => currentPage.value === 1);
|
|
@@ -6609,7 +7027,7 @@ function useOnline(options = {}) {
|
|
|
6609
7027
|
|
|
6610
7028
|
function usePageLeave(options = {}) {
|
|
6611
7029
|
const { window = defaultWindow } = options;
|
|
6612
|
-
const isLeft =
|
|
7030
|
+
const isLeft = shallowRef(false);
|
|
6613
7031
|
const handler = (event) => {
|
|
6614
7032
|
if (!window)
|
|
6615
7033
|
return;
|
|
@@ -6618,9 +7036,10 @@ function usePageLeave(options = {}) {
|
|
|
6618
7036
|
isLeft.value = !from;
|
|
6619
7037
|
};
|
|
6620
7038
|
if (window) {
|
|
6621
|
-
|
|
6622
|
-
useEventListener(window
|
|
6623
|
-
useEventListener(window.document, "
|
|
7039
|
+
const listenerOptions = { passive: true };
|
|
7040
|
+
useEventListener(window, "mouseout", handler, listenerOptions);
|
|
7041
|
+
useEventListener(window.document, "mouseleave", handler, listenerOptions);
|
|
7042
|
+
useEventListener(window.document, "mouseenter", handler, listenerOptions);
|
|
6624
7043
|
}
|
|
6625
7044
|
return isLeft;
|
|
6626
7045
|
}
|
|
@@ -6637,7 +7056,7 @@ function useScreenOrientation(options = {}) {
|
|
|
6637
7056
|
useEventListener(window, "orientationchange", () => {
|
|
6638
7057
|
orientation.value = screenOrientation.type;
|
|
6639
7058
|
angle.value = screenOrientation.angle;
|
|
6640
|
-
});
|
|
7059
|
+
}, { passive: true });
|
|
6641
7060
|
}
|
|
6642
7061
|
const lockOrientation = (type) => {
|
|
6643
7062
|
if (isSupported.value && typeof screenOrientation.lock === "function")
|
|
@@ -6740,7 +7159,7 @@ function useParentElement(element = useCurrentElement()) {
|
|
|
6740
7159
|
parentElement.value = el.parentElement;
|
|
6741
7160
|
};
|
|
6742
7161
|
tryOnMounted(update);
|
|
6743
|
-
watch(() => toValue(element), update);
|
|
7162
|
+
watch(() => toValue$1(element), update);
|
|
6744
7163
|
return parentElement;
|
|
6745
7164
|
}
|
|
6746
7165
|
|
|
@@ -6789,7 +7208,7 @@ function usePointer(options = {}) {
|
|
|
6789
7208
|
const {
|
|
6790
7209
|
target = defaultWindow
|
|
6791
7210
|
} = options;
|
|
6792
|
-
const isInside =
|
|
7211
|
+
const isInside = shallowRef(false);
|
|
6793
7212
|
const state = ref(options.initialValue || {});
|
|
6794
7213
|
Object.assign(state.value, defaultState, state.value);
|
|
6795
7214
|
const handler = (event) => {
|
|
@@ -6816,6 +7235,7 @@ function usePointerLock(target, options = {}) {
|
|
|
6816
7235
|
const triggerElement = ref();
|
|
6817
7236
|
let targetElement;
|
|
6818
7237
|
if (isSupported.value) {
|
|
7238
|
+
const listenerOptions = { passive: true };
|
|
6819
7239
|
useEventListener(document, "pointerlockchange", () => {
|
|
6820
7240
|
var _a;
|
|
6821
7241
|
const currentElement = (_a = document.pointerLockElement) != null ? _a : element.value;
|
|
@@ -6824,7 +7244,7 @@ function usePointerLock(target, options = {}) {
|
|
|
6824
7244
|
if (!element.value)
|
|
6825
7245
|
targetElement = triggerElement.value = null;
|
|
6826
7246
|
}
|
|
6827
|
-
});
|
|
7247
|
+
}, listenerOptions);
|
|
6828
7248
|
useEventListener(document, "pointerlockerror", () => {
|
|
6829
7249
|
var _a;
|
|
6830
7250
|
const currentElement = (_a = document.pointerLockElement) != null ? _a : element.value;
|
|
@@ -6832,7 +7252,7 @@ function usePointerLock(target, options = {}) {
|
|
|
6832
7252
|
const action = document.pointerLockElement ? "release" : "acquire";
|
|
6833
7253
|
throw new Error(`Failed to ${action} pointer lock.`);
|
|
6834
7254
|
}
|
|
6835
|
-
});
|
|
7255
|
+
}, listenerOptions);
|
|
6836
7256
|
}
|
|
6837
7257
|
async function lock(e) {
|
|
6838
7258
|
var _a;
|
|
@@ -6884,8 +7304,8 @@ function usePointerSwipe(target, options = {}) {
|
|
|
6884
7304
|
const distanceY = computed(() => posStart.y - posEnd.y);
|
|
6885
7305
|
const { max, abs } = Math;
|
|
6886
7306
|
const isThresholdExceeded = computed(() => max(abs(distanceX.value), abs(distanceY.value)) >= threshold);
|
|
6887
|
-
const isSwiping =
|
|
6888
|
-
const isPointerDown =
|
|
7307
|
+
const isSwiping = shallowRef(false);
|
|
7308
|
+
const isPointerDown = shallowRef(false);
|
|
6889
7309
|
const direction = computed(() => {
|
|
6890
7310
|
if (!isThresholdExceeded.value)
|
|
6891
7311
|
return "none";
|
|
@@ -6901,6 +7321,7 @@ function usePointerSwipe(target, options = {}) {
|
|
|
6901
7321
|
const isPrimaryButton = e.buttons === 1;
|
|
6902
7322
|
return (_c = (_b = (_a = options.pointerTypes) == null ? void 0 : _a.includes(e.pointerType)) != null ? _b : isReleasingButton || isPrimaryButton) != null ? _c : true;
|
|
6903
7323
|
};
|
|
7324
|
+
const listenerOptions = { passive: true };
|
|
6904
7325
|
const stops = [
|
|
6905
7326
|
useEventListener(target, "pointerdown", (e) => {
|
|
6906
7327
|
if (!eventIsAllowed(e))
|
|
@@ -6912,7 +7333,7 @@ function usePointerSwipe(target, options = {}) {
|
|
|
6912
7333
|
updatePosStart(x, y);
|
|
6913
7334
|
updatePosEnd(x, y);
|
|
6914
7335
|
onSwipeStart == null ? void 0 : onSwipeStart(e);
|
|
6915
|
-
}),
|
|
7336
|
+
}, listenerOptions),
|
|
6916
7337
|
useEventListener(target, "pointermove", (e) => {
|
|
6917
7338
|
if (!eventIsAllowed(e))
|
|
6918
7339
|
return;
|
|
@@ -6924,7 +7345,7 @@ function usePointerSwipe(target, options = {}) {
|
|
|
6924
7345
|
isSwiping.value = true;
|
|
6925
7346
|
if (isSwiping.value)
|
|
6926
7347
|
onSwipe == null ? void 0 : onSwipe(e);
|
|
6927
|
-
}),
|
|
7348
|
+
}, listenerOptions),
|
|
6928
7349
|
useEventListener(target, "pointerup", (e) => {
|
|
6929
7350
|
if (!eventIsAllowed(e))
|
|
6930
7351
|
return;
|
|
@@ -6932,7 +7353,7 @@ function usePointerSwipe(target, options = {}) {
|
|
|
6932
7353
|
onSwipeEnd == null ? void 0 : onSwipeEnd(e, direction.value);
|
|
6933
7354
|
isPointerDown.value = false;
|
|
6934
7355
|
isSwiping.value = false;
|
|
6935
|
-
})
|
|
7356
|
+
}, listenerOptions)
|
|
6936
7357
|
];
|
|
6937
7358
|
tryOnMounted(() => {
|
|
6938
7359
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
@@ -6990,7 +7411,7 @@ function usePreferredLanguages(options = {}) {
|
|
|
6990
7411
|
const value = ref(navigator.languages);
|
|
6991
7412
|
useEventListener(window, "languagechange", () => {
|
|
6992
7413
|
value.value = navigator.languages;
|
|
6993
|
-
});
|
|
7414
|
+
}, { passive: true });
|
|
6994
7415
|
return value;
|
|
6995
7416
|
}
|
|
6996
7417
|
|
|
@@ -7003,6 +7424,15 @@ function usePreferredReducedMotion(options) {
|
|
|
7003
7424
|
});
|
|
7004
7425
|
}
|
|
7005
7426
|
|
|
7427
|
+
function usePreferredReducedTransparency(options) {
|
|
7428
|
+
const isReduced = useMediaQuery("(prefers-reduced-transparency: reduce)", options);
|
|
7429
|
+
return computed(() => {
|
|
7430
|
+
if (isReduced.value)
|
|
7431
|
+
return "reduce";
|
|
7432
|
+
return "no-preference";
|
|
7433
|
+
});
|
|
7434
|
+
}
|
|
7435
|
+
|
|
7006
7436
|
function usePrevious(value, initialValue) {
|
|
7007
7437
|
const previous = shallowRef(initialValue);
|
|
7008
7438
|
watch(
|
|
@@ -7020,10 +7450,10 @@ const rightVarName = "--vueuse-safe-area-right";
|
|
|
7020
7450
|
const bottomVarName = "--vueuse-safe-area-bottom";
|
|
7021
7451
|
const leftVarName = "--vueuse-safe-area-left";
|
|
7022
7452
|
function useScreenSafeArea() {
|
|
7023
|
-
const top =
|
|
7024
|
-
const right =
|
|
7025
|
-
const bottom =
|
|
7026
|
-
const left =
|
|
7453
|
+
const top = shallowRef("");
|
|
7454
|
+
const right = shallowRef("");
|
|
7455
|
+
const bottom = shallowRef("");
|
|
7456
|
+
const left = shallowRef("");
|
|
7027
7457
|
if (isClient) {
|
|
7028
7458
|
const topCssVar = useCssVar(topVarName);
|
|
7029
7459
|
const rightCssVar = useCssVar(rightVarName);
|
|
@@ -7034,7 +7464,7 @@ function useScreenSafeArea() {
|
|
|
7034
7464
|
bottomCssVar.value = "env(safe-area-inset-bottom, 0px)";
|
|
7035
7465
|
leftCssVar.value = "env(safe-area-inset-left, 0px)";
|
|
7036
7466
|
update();
|
|
7037
|
-
useEventListener("resize", useDebounceFn(update));
|
|
7467
|
+
useEventListener("resize", useDebounceFn(update), { passive: true });
|
|
7038
7468
|
}
|
|
7039
7469
|
function update() {
|
|
7040
7470
|
top.value = getValue(topVarName);
|
|
@@ -7080,12 +7510,12 @@ function useScriptTag(src, onLoaded = noop, options = {}) {
|
|
|
7080
7510
|
return;
|
|
7081
7511
|
}
|
|
7082
7512
|
let shouldAppend = false;
|
|
7083
|
-
let el = document.querySelector(`script[src="${toValue(src)}"]`);
|
|
7513
|
+
let el = document.querySelector(`script[src="${toValue$1(src)}"]`);
|
|
7084
7514
|
if (!el) {
|
|
7085
7515
|
el = document.createElement("script");
|
|
7086
7516
|
el.type = type;
|
|
7087
7517
|
el.async = async;
|
|
7088
|
-
el.src = toValue(src);
|
|
7518
|
+
el.src = toValue$1(src);
|
|
7089
7519
|
if (defer)
|
|
7090
7520
|
el.defer = defer;
|
|
7091
7521
|
if (crossOrigin)
|
|
@@ -7099,13 +7529,16 @@ function useScriptTag(src, onLoaded = noop, options = {}) {
|
|
|
7099
7529
|
} else if (el.hasAttribute("data-loaded")) {
|
|
7100
7530
|
resolveWithElement(el);
|
|
7101
7531
|
}
|
|
7102
|
-
|
|
7103
|
-
|
|
7104
|
-
|
|
7532
|
+
const listenerOptions = {
|
|
7533
|
+
passive: true
|
|
7534
|
+
};
|
|
7535
|
+
useEventListener(el, "error", (event) => reject(event), listenerOptions);
|
|
7536
|
+
useEventListener(el, "abort", (event) => reject(event), listenerOptions);
|
|
7537
|
+
useEventListener(el, "load", () => {
|
|
7105
7538
|
el.setAttribute("data-loaded", "true");
|
|
7106
7539
|
onLoaded(el);
|
|
7107
7540
|
resolveWithElement(el);
|
|
7108
|
-
});
|
|
7541
|
+
}, listenerOptions);
|
|
7109
7542
|
if (shouldAppend)
|
|
7110
7543
|
el = document.head.appendChild(el);
|
|
7111
7544
|
if (!waitForScriptLoad)
|
|
@@ -7122,7 +7555,7 @@ function useScriptTag(src, onLoaded = noop, options = {}) {
|
|
|
7122
7555
|
_promise = null;
|
|
7123
7556
|
if (scriptTag.value)
|
|
7124
7557
|
scriptTag.value = null;
|
|
7125
|
-
const el = document.querySelector(`script[src="${toValue(src)}"]`);
|
|
7558
|
+
const el = document.querySelector(`script[src="${toValue$1(src)}"]`);
|
|
7126
7559
|
if (el)
|
|
7127
7560
|
document.head.removeChild(el);
|
|
7128
7561
|
};
|
|
@@ -7161,7 +7594,7 @@ function useScrollLock(element, initialState = false) {
|
|
|
7161
7594
|
let stopTouchMoveListener = null;
|
|
7162
7595
|
let initialOverflow = "";
|
|
7163
7596
|
watch(toRef(element), (el) => {
|
|
7164
|
-
const target = resolveElement(toValue(el));
|
|
7597
|
+
const target = resolveElement(toValue$1(el));
|
|
7165
7598
|
if (target) {
|
|
7166
7599
|
const ele = target;
|
|
7167
7600
|
if (!elInitialOverflow.get(ele))
|
|
@@ -7177,7 +7610,7 @@ function useScrollLock(element, initialState = false) {
|
|
|
7177
7610
|
immediate: true
|
|
7178
7611
|
});
|
|
7179
7612
|
const lock = () => {
|
|
7180
|
-
const el = resolveElement(toValue(element));
|
|
7613
|
+
const el = resolveElement(toValue$1(element));
|
|
7181
7614
|
if (!el || isLocked.value)
|
|
7182
7615
|
return;
|
|
7183
7616
|
if (isIOS) {
|
|
@@ -7194,7 +7627,7 @@ function useScrollLock(element, initialState = false) {
|
|
|
7194
7627
|
isLocked.value = true;
|
|
7195
7628
|
};
|
|
7196
7629
|
const unlock = () => {
|
|
7197
|
-
const el = resolveElement(toValue(element));
|
|
7630
|
+
const el = resolveElement(toValue$1(element));
|
|
7198
7631
|
if (!el || !isLocked.value)
|
|
7199
7632
|
return;
|
|
7200
7633
|
if (isIOS)
|
|
@@ -7228,8 +7661,8 @@ function useShare(shareOptions = {}, options = {}) {
|
|
|
7228
7661
|
const share = async (overrideOptions = {}) => {
|
|
7229
7662
|
if (isSupported.value) {
|
|
7230
7663
|
const data = {
|
|
7231
|
-
...toValue(shareOptions),
|
|
7232
|
-
...toValue(overrideOptions)
|
|
7664
|
+
...toValue$1(shareOptions),
|
|
7665
|
+
...toValue$1(overrideOptions)
|
|
7233
7666
|
};
|
|
7234
7667
|
let granted = true;
|
|
7235
7668
|
if (data.files && _navigator.canShare)
|
|
@@ -7267,9 +7700,9 @@ function useSorted(...args) {
|
|
|
7267
7700
|
sortFn = defaultSortFn
|
|
7268
7701
|
} = options;
|
|
7269
7702
|
if (!dirty)
|
|
7270
|
-
return computed(() => sortFn([...toValue(source)], compareFn));
|
|
7703
|
+
return computed(() => sortFn([...toValue$1(source)], compareFn));
|
|
7271
7704
|
watchEffect(() => {
|
|
7272
|
-
const result = sortFn(toValue(source), compareFn);
|
|
7705
|
+
const result = sortFn(toValue$1(source), compareFn);
|
|
7273
7706
|
if (isRef(source))
|
|
7274
7707
|
source.value = result;
|
|
7275
7708
|
else
|
|
@@ -7286,29 +7719,34 @@ function useSpeechRecognition(options = {}) {
|
|
|
7286
7719
|
window = defaultWindow
|
|
7287
7720
|
} = options;
|
|
7288
7721
|
const lang = toRef(options.lang || "en-US");
|
|
7289
|
-
const isListening =
|
|
7290
|
-
const isFinal =
|
|
7291
|
-
const result =
|
|
7722
|
+
const isListening = shallowRef(false);
|
|
7723
|
+
const isFinal = shallowRef(false);
|
|
7724
|
+
const result = shallowRef("");
|
|
7292
7725
|
const error = shallowRef(void 0);
|
|
7293
|
-
|
|
7294
|
-
isListening.value = value;
|
|
7295
|
-
};
|
|
7726
|
+
let recognition;
|
|
7296
7727
|
const start = () => {
|
|
7297
7728
|
isListening.value = true;
|
|
7298
7729
|
};
|
|
7299
7730
|
const stop = () => {
|
|
7300
7731
|
isListening.value = false;
|
|
7301
7732
|
};
|
|
7733
|
+
const toggle = (value = !isListening.value) => {
|
|
7734
|
+
if (value) {
|
|
7735
|
+
start();
|
|
7736
|
+
} else {
|
|
7737
|
+
stop();
|
|
7738
|
+
}
|
|
7739
|
+
};
|
|
7302
7740
|
const SpeechRecognition = window && (window.SpeechRecognition || window.webkitSpeechRecognition);
|
|
7303
7741
|
const isSupported = useSupported(() => SpeechRecognition);
|
|
7304
|
-
let recognition;
|
|
7305
7742
|
if (isSupported.value) {
|
|
7306
7743
|
recognition = new SpeechRecognition();
|
|
7307
7744
|
recognition.continuous = continuous;
|
|
7308
7745
|
recognition.interimResults = interimResults;
|
|
7309
|
-
recognition.lang = toValue(lang);
|
|
7746
|
+
recognition.lang = toValue$1(lang);
|
|
7310
7747
|
recognition.maxAlternatives = maxAlternatives;
|
|
7311
7748
|
recognition.onstart = () => {
|
|
7749
|
+
isListening.value = true;
|
|
7312
7750
|
isFinal.value = false;
|
|
7313
7751
|
};
|
|
7314
7752
|
watch(lang, (lang2) => {
|
|
@@ -7327,17 +7765,19 @@ function useSpeechRecognition(options = {}) {
|
|
|
7327
7765
|
};
|
|
7328
7766
|
recognition.onend = () => {
|
|
7329
7767
|
isListening.value = false;
|
|
7330
|
-
recognition.lang = toValue(lang);
|
|
7768
|
+
recognition.lang = toValue$1(lang);
|
|
7331
7769
|
};
|
|
7332
|
-
watch(isListening, () => {
|
|
7333
|
-
if (
|
|
7770
|
+
watch(isListening, (newValue, oldValue) => {
|
|
7771
|
+
if (newValue === oldValue)
|
|
7772
|
+
return;
|
|
7773
|
+
if (newValue)
|
|
7334
7774
|
recognition.start();
|
|
7335
7775
|
else
|
|
7336
7776
|
recognition.stop();
|
|
7337
7777
|
});
|
|
7338
7778
|
}
|
|
7339
7779
|
tryOnScopeDispose(() => {
|
|
7340
|
-
|
|
7780
|
+
stop();
|
|
7341
7781
|
});
|
|
7342
7782
|
return {
|
|
7343
7783
|
isSupported,
|
|
@@ -7361,7 +7801,7 @@ function useSpeechSynthesis(text, options = {}) {
|
|
|
7361
7801
|
} = options;
|
|
7362
7802
|
const synth = window && window.speechSynthesis;
|
|
7363
7803
|
const isSupported = useSupported(() => synth);
|
|
7364
|
-
const isPlaying =
|
|
7804
|
+
const isPlaying = shallowRef(false);
|
|
7365
7805
|
const status = ref("init");
|
|
7366
7806
|
const spokenText = toRef(text || "");
|
|
7367
7807
|
const lang = toRef(options.lang || "en-US");
|
|
@@ -7370,10 +7810,10 @@ function useSpeechSynthesis(text, options = {}) {
|
|
|
7370
7810
|
isPlaying.value = value;
|
|
7371
7811
|
};
|
|
7372
7812
|
const bindEventsForUtterance = (utterance2) => {
|
|
7373
|
-
utterance2.lang = toValue(lang);
|
|
7374
|
-
utterance2.voice = toValue(options.voice) || null;
|
|
7375
|
-
utterance2.pitch = toValue(pitch);
|
|
7376
|
-
utterance2.rate = toValue(rate);
|
|
7813
|
+
utterance2.lang = toValue$1(lang);
|
|
7814
|
+
utterance2.voice = toValue$1(options.voice) || null;
|
|
7815
|
+
utterance2.pitch = toValue$1(pitch);
|
|
7816
|
+
utterance2.rate = toValue$1(rate);
|
|
7377
7817
|
utterance2.volume = volume;
|
|
7378
7818
|
utterance2.onstart = () => {
|
|
7379
7819
|
isPlaying.value = true;
|
|
@@ -7534,9 +7974,9 @@ function useStorageAsync(key, initialValue, storage, options = {}) {
|
|
|
7534
7974
|
console.error(e);
|
|
7535
7975
|
}
|
|
7536
7976
|
} = options;
|
|
7537
|
-
const rawInit = toValue(initialValue);
|
|
7977
|
+
const rawInit = toValue$1(initialValue);
|
|
7538
7978
|
const type = guessSerializerType(rawInit);
|
|
7539
|
-
const data = (shallow ? shallowRef : ref)(initialValue);
|
|
7979
|
+
const data = (shallow ? shallowRef : ref)(toValue$1(initialValue));
|
|
7540
7980
|
const serializer = (_a = options.serializer) != null ? _a : StorageSerializers[type];
|
|
7541
7981
|
if (!storage) {
|
|
7542
7982
|
try {
|
|
@@ -7573,7 +8013,7 @@ function useStorageAsync(key, initialValue, storage, options = {}) {
|
|
|
7573
8013
|
}
|
|
7574
8014
|
read();
|
|
7575
8015
|
if (window && listenToStorageChanges)
|
|
7576
|
-
useEventListener(window, "storage", (e) => Promise.resolve().then(() => read(e)));
|
|
8016
|
+
useEventListener(window, "storage", (e) => Promise.resolve().then(() => read(e)), { passive: true });
|
|
7577
8017
|
if (storage) {
|
|
7578
8018
|
watchWithFilter(
|
|
7579
8019
|
data,
|
|
@@ -7599,14 +8039,14 @@ function useStorageAsync(key, initialValue, storage, options = {}) {
|
|
|
7599
8039
|
|
|
7600
8040
|
let _id = 0;
|
|
7601
8041
|
function useStyleTag(css, options = {}) {
|
|
7602
|
-
const isLoaded =
|
|
8042
|
+
const isLoaded = shallowRef(false);
|
|
7603
8043
|
const {
|
|
7604
8044
|
document = defaultDocument,
|
|
7605
8045
|
immediate = true,
|
|
7606
8046
|
manual = false,
|
|
7607
8047
|
id = `vueuse_styletag_${++_id}`
|
|
7608
8048
|
} = options;
|
|
7609
|
-
const cssRef =
|
|
8049
|
+
const cssRef = shallowRef(css);
|
|
7610
8050
|
let stop = () => {
|
|
7611
8051
|
};
|
|
7612
8052
|
const load = () => {
|
|
@@ -7656,8 +8096,7 @@ function useSwipe(target, options = {}) {
|
|
|
7656
8096
|
onSwipe,
|
|
7657
8097
|
onSwipeEnd,
|
|
7658
8098
|
onSwipeStart,
|
|
7659
|
-
passive = true
|
|
7660
|
-
window = defaultWindow
|
|
8099
|
+
passive = true
|
|
7661
8100
|
} = options;
|
|
7662
8101
|
const coordsStart = reactive({ x: 0, y: 0 });
|
|
7663
8102
|
const coordsEnd = reactive({ x: 0, y: 0 });
|
|
@@ -7665,7 +8104,7 @@ function useSwipe(target, options = {}) {
|
|
|
7665
8104
|
const diffY = computed(() => coordsStart.y - coordsEnd.y);
|
|
7666
8105
|
const { max, abs } = Math;
|
|
7667
8106
|
const isThresholdExceeded = computed(() => max(abs(diffX.value), abs(diffY.value)) >= threshold);
|
|
7668
|
-
const isSwiping =
|
|
8107
|
+
const isSwiping = shallowRef(false);
|
|
7669
8108
|
const direction = computed(() => {
|
|
7670
8109
|
if (!isThresholdExceeded.value)
|
|
7671
8110
|
return "none";
|
|
@@ -7684,12 +8123,7 @@ function useSwipe(target, options = {}) {
|
|
|
7684
8123
|
coordsEnd.x = x;
|
|
7685
8124
|
coordsEnd.y = y;
|
|
7686
8125
|
};
|
|
7687
|
-
|
|
7688
|
-
const isPassiveEventSupported = checkPassiveEventSupport(window == null ? void 0 : window.document);
|
|
7689
|
-
if (!passive)
|
|
7690
|
-
listenerOptions = isPassiveEventSupported ? { passive: false, capture: true } : { capture: true };
|
|
7691
|
-
else
|
|
7692
|
-
listenerOptions = isPassiveEventSupported ? { passive: true } : { capture: false };
|
|
8126
|
+
const listenerOptions = { passive, capture: !passive };
|
|
7693
8127
|
const onTouchEnd = (e) => {
|
|
7694
8128
|
if (isSwiping.value)
|
|
7695
8129
|
onSwipeEnd == null ? void 0 : onSwipeEnd(e, direction.value);
|
|
@@ -7720,29 +8154,16 @@ function useSwipe(target, options = {}) {
|
|
|
7720
8154
|
];
|
|
7721
8155
|
const stop = () => stops.forEach((s) => s());
|
|
7722
8156
|
return {
|
|
7723
|
-
isPassiveEventSupported,
|
|
7724
8157
|
isSwiping,
|
|
7725
8158
|
direction,
|
|
7726
8159
|
coordsStart,
|
|
7727
8160
|
coordsEnd,
|
|
7728
8161
|
lengthX: diffX,
|
|
7729
8162
|
lengthY: diffY,
|
|
7730
|
-
stop
|
|
7731
|
-
|
|
7732
|
-
|
|
7733
|
-
function checkPassiveEventSupport(document) {
|
|
7734
|
-
if (!document)
|
|
7735
|
-
return false;
|
|
7736
|
-
let supportsPassive = false;
|
|
7737
|
-
const optionsBlock = {
|
|
7738
|
-
get passive() {
|
|
7739
|
-
supportsPassive = true;
|
|
7740
|
-
return false;
|
|
7741
|
-
}
|
|
8163
|
+
stop,
|
|
8164
|
+
// TODO: Remove in the next major version
|
|
8165
|
+
isPassiveEventSupported: true
|
|
7742
8166
|
};
|
|
7743
|
-
document.addEventListener("x", noop, optionsBlock);
|
|
7744
|
-
document.removeEventListener("x", noop);
|
|
7745
|
-
return supportsPassive;
|
|
7746
8167
|
}
|
|
7747
8168
|
|
|
7748
8169
|
function useTemplateRefsList() {
|
|
@@ -7816,7 +8237,7 @@ function useTextSelection(options = {}) {
|
|
|
7816
8237
|
selection.value = window.getSelection();
|
|
7817
8238
|
}
|
|
7818
8239
|
if (window)
|
|
7819
|
-
useEventListener(window.document, "selectionchange", onSelectionChange);
|
|
8240
|
+
useEventListener(window.document, "selectionchange", onSelectionChange, { passive: true });
|
|
7820
8241
|
return {
|
|
7821
8242
|
text,
|
|
7822
8243
|
rects,
|
|
@@ -7825,13 +8246,21 @@ function useTextSelection(options = {}) {
|
|
|
7825
8246
|
};
|
|
7826
8247
|
}
|
|
7827
8248
|
|
|
7828
|
-
function
|
|
7829
|
-
|
|
7830
|
-
|
|
7831
|
-
|
|
7832
|
-
|
|
7833
|
-
|
|
7834
|
-
|
|
8249
|
+
function tryRequestAnimationFrame(window = defaultWindow, fn) {
|
|
8250
|
+
if (window && typeof window.requestAnimationFrame === "function") {
|
|
8251
|
+
window.requestAnimationFrame(fn);
|
|
8252
|
+
} else {
|
|
8253
|
+
fn();
|
|
8254
|
+
}
|
|
8255
|
+
}
|
|
8256
|
+
function useTextareaAutosize(options = {}) {
|
|
8257
|
+
var _a, _b;
|
|
8258
|
+
const { window = defaultWindow } = options;
|
|
8259
|
+
const textarea = toRef(options == null ? void 0 : options.element);
|
|
8260
|
+
const input = toRef((_a = options == null ? void 0 : options.input) != null ? _a : "");
|
|
8261
|
+
const styleProp = (_b = options == null ? void 0 : options.styleProp) != null ? _b : "height";
|
|
8262
|
+
const textareaScrollHeight = shallowRef(1);
|
|
8263
|
+
const textareaOldWidth = shallowRef(0);
|
|
7835
8264
|
function triggerResize() {
|
|
7836
8265
|
var _a2;
|
|
7837
8266
|
if (!textarea.value)
|
|
@@ -7839,7 +8268,7 @@ function useTextareaAutosize(options) {
|
|
|
7839
8268
|
let height = "";
|
|
7840
8269
|
textarea.value.style[styleProp] = "1px";
|
|
7841
8270
|
textareaScrollHeight.value = (_a2 = textarea.value) == null ? void 0 : _a2.scrollHeight;
|
|
7842
|
-
const _styleTarget = toValue(options == null ? void 0 : options.styleTarget);
|
|
8271
|
+
const _styleTarget = toValue$1(options == null ? void 0 : options.styleTarget);
|
|
7843
8272
|
if (_styleTarget)
|
|
7844
8273
|
_styleTarget.style[styleProp] = `${textareaScrollHeight.value}px`;
|
|
7845
8274
|
else
|
|
@@ -7854,8 +8283,10 @@ function useTextareaAutosize(options) {
|
|
|
7854
8283
|
useResizeObserver(textarea, ([{ contentRect }]) => {
|
|
7855
8284
|
if (textareaOldWidth.value === contentRect.width)
|
|
7856
8285
|
return;
|
|
7857
|
-
|
|
7858
|
-
|
|
8286
|
+
tryRequestAnimationFrame(window, () => {
|
|
8287
|
+
textareaOldWidth.value = contentRect.width;
|
|
8288
|
+
triggerResize();
|
|
8289
|
+
});
|
|
7859
8290
|
});
|
|
7860
8291
|
if (options == null ? void 0 : options.watch)
|
|
7861
8292
|
watch(options.watch, triggerResize, { immediate: true, deep: true });
|
|
@@ -7906,7 +8337,7 @@ function useTimeAgo(time, options = {}) {
|
|
|
7906
8337
|
updateInterval = 3e4
|
|
7907
8338
|
} = options;
|
|
7908
8339
|
const { now, ...controls } = useNow({ interval: updateInterval, controls: true });
|
|
7909
|
-
const timeAgo = computed(() => formatTimeAgo(new Date(toValue(time)), options, toValue(now)));
|
|
8340
|
+
const timeAgo = computed(() => formatTimeAgo(new Date(toValue$1(time)), options, toValue$1(now)));
|
|
7910
8341
|
if (exposeControls) {
|
|
7911
8342
|
return {
|
|
7912
8343
|
timeAgo,
|
|
@@ -7963,9 +8394,13 @@ function formatTimeAgo(from, options = {}, now = Date.now()) {
|
|
|
7963
8394
|
return messages.invalid;
|
|
7964
8395
|
}
|
|
7965
8396
|
|
|
7966
|
-
function useTimeoutPoll(fn, interval,
|
|
7967
|
-
const {
|
|
7968
|
-
|
|
8397
|
+
function useTimeoutPoll(fn, interval, options = {}) {
|
|
8398
|
+
const {
|
|
8399
|
+
immediate = true,
|
|
8400
|
+
immediateCallback = false
|
|
8401
|
+
} = options;
|
|
8402
|
+
const { start } = useTimeoutFn(loop, interval, { immediate });
|
|
8403
|
+
const isActive = shallowRef(false);
|
|
7969
8404
|
async function loop() {
|
|
7970
8405
|
if (!isActive.value)
|
|
7971
8406
|
return;
|
|
@@ -7975,13 +8410,15 @@ function useTimeoutPoll(fn, interval, timeoutPollOptions) {
|
|
|
7975
8410
|
function resume() {
|
|
7976
8411
|
if (!isActive.value) {
|
|
7977
8412
|
isActive.value = true;
|
|
7978
|
-
|
|
8413
|
+
if (immediateCallback)
|
|
8414
|
+
fn();
|
|
8415
|
+
start();
|
|
7979
8416
|
}
|
|
7980
8417
|
}
|
|
7981
8418
|
function pause() {
|
|
7982
8419
|
isActive.value = false;
|
|
7983
8420
|
}
|
|
7984
|
-
if (
|
|
8421
|
+
if (immediate && isClient)
|
|
7985
8422
|
resume();
|
|
7986
8423
|
tryOnScopeDispose(pause);
|
|
7987
8424
|
return {
|
|
@@ -7999,7 +8436,7 @@ function useTimestamp(options = {}) {
|
|
|
7999
8436
|
interval = "requestAnimationFrame",
|
|
8000
8437
|
callback
|
|
8001
8438
|
} = options;
|
|
8002
|
-
const ts =
|
|
8439
|
+
const ts = shallowRef(timestamp() + offset);
|
|
8003
8440
|
const update = () => ts.value = timestamp() + offset;
|
|
8004
8441
|
const cb = callback ? () => {
|
|
8005
8442
|
update();
|
|
@@ -8024,18 +8461,18 @@ function useTitle(newTitle = null, options = {}) {
|
|
|
8024
8461
|
} = options;
|
|
8025
8462
|
const originalTitle = (_a = document == null ? void 0 : document.title) != null ? _a : "";
|
|
8026
8463
|
const title = toRef((_b = newTitle != null ? newTitle : document == null ? void 0 : document.title) != null ? _b : null);
|
|
8027
|
-
const isReadonly = newTitle && typeof newTitle === "function";
|
|
8464
|
+
const isReadonly = !!(newTitle && typeof newTitle === "function");
|
|
8028
8465
|
function format(t) {
|
|
8029
8466
|
if (!("titleTemplate" in options))
|
|
8030
8467
|
return t;
|
|
8031
8468
|
const template = options.titleTemplate || "%s";
|
|
8032
|
-
return typeof template === "function" ? template(t) : toValue(template).replace(/%s/g, t);
|
|
8469
|
+
return typeof template === "function" ? template(t) : toValue$1(template).replace(/%s/g, t);
|
|
8033
8470
|
}
|
|
8034
8471
|
watch(
|
|
8035
8472
|
title,
|
|
8036
|
-
(
|
|
8037
|
-
if (
|
|
8038
|
-
document.title = format(
|
|
8473
|
+
(newValue, oldValue) => {
|
|
8474
|
+
if (newValue !== oldValue && document)
|
|
8475
|
+
document.title = format(newValue != null ? newValue : "");
|
|
8039
8476
|
},
|
|
8040
8477
|
{ immediate: true }
|
|
8041
8478
|
);
|
|
@@ -8049,7 +8486,7 @@ function useTitle(newTitle = null, options = {}) {
|
|
|
8049
8486
|
{ childList: true }
|
|
8050
8487
|
);
|
|
8051
8488
|
}
|
|
8052
|
-
|
|
8489
|
+
tryOnScopeDispose(() => {
|
|
8053
8490
|
if (restoreOnUnmount) {
|
|
8054
8491
|
const restoredTitle = restoreOnUnmount(originalTitle, title.value || "");
|
|
8055
8492
|
if (restoredTitle != null && document)
|
|
@@ -8113,14 +8550,14 @@ function toVec(t) {
|
|
|
8113
8550
|
}
|
|
8114
8551
|
function executeTransition(source, from, to, options = {}) {
|
|
8115
8552
|
var _a, _b;
|
|
8116
|
-
const fromVal = toValue(from);
|
|
8117
|
-
const toVal = toValue(to);
|
|
8553
|
+
const fromVal = toValue$1(from);
|
|
8554
|
+
const toVal = toValue$1(to);
|
|
8118
8555
|
const v1 = toVec(fromVal);
|
|
8119
8556
|
const v2 = toVec(toVal);
|
|
8120
|
-
const duration = (_a = toValue(options.duration)) != null ? _a : 1e3;
|
|
8557
|
+
const duration = (_a = toValue$1(options.duration)) != null ? _a : 1e3;
|
|
8121
8558
|
const startedAt = Date.now();
|
|
8122
8559
|
const endAt = Date.now() + duration;
|
|
8123
|
-
const trans = typeof options.transition === "function" ? options.transition : (_b = toValue(options.transition)) != null ? _b : identity;
|
|
8560
|
+
const trans = typeof options.transition === "function" ? options.transition : (_b = toValue$1(options.transition)) != null ? _b : identity;
|
|
8124
8561
|
const ease = typeof trans === "function" ? trans : createEasingFunction(trans);
|
|
8125
8562
|
return new Promise((resolve) => {
|
|
8126
8563
|
source.value = fromVal;
|
|
@@ -8153,20 +8590,20 @@ function executeTransition(source, from, to, options = {}) {
|
|
|
8153
8590
|
function useTransition(source, options = {}) {
|
|
8154
8591
|
let currentId = 0;
|
|
8155
8592
|
const sourceVal = () => {
|
|
8156
|
-
const v = toValue(source);
|
|
8157
|
-
return typeof v === "number" ? v : v.map(toValue);
|
|
8593
|
+
const v = toValue$1(source);
|
|
8594
|
+
return typeof v === "number" ? v : v.map(toValue$1);
|
|
8158
8595
|
};
|
|
8159
8596
|
const outputRef = ref(sourceVal());
|
|
8160
8597
|
watch(sourceVal, async (to) => {
|
|
8161
8598
|
var _a, _b;
|
|
8162
|
-
if (toValue(options.disabled))
|
|
8599
|
+
if (toValue$1(options.disabled))
|
|
8163
8600
|
return;
|
|
8164
8601
|
const id = ++currentId;
|
|
8165
8602
|
if (options.delay)
|
|
8166
|
-
await promiseTimeout(toValue(options.delay));
|
|
8603
|
+
await promiseTimeout(toValue$1(options.delay));
|
|
8167
8604
|
if (id !== currentId)
|
|
8168
8605
|
return;
|
|
8169
|
-
const toVal = Array.isArray(to) ? to.map(toValue) : toValue(to);
|
|
8606
|
+
const toVal = Array.isArray(to) ? to.map(toValue$1) : toValue$1(to);
|
|
8170
8607
|
(_a = options.onStarted) == null ? void 0 : _a.call(options);
|
|
8171
8608
|
await executeTransition(outputRef, outputRef.value, toVal, {
|
|
8172
8609
|
...options,
|
|
@@ -8177,7 +8614,7 @@ function useTransition(source, options = {}) {
|
|
|
8177
8614
|
});
|
|
8178
8615
|
(_b = options.onFinished) == null ? void 0 : _b.call(options);
|
|
8179
8616
|
}, { deep: true });
|
|
8180
|
-
watch(() => toValue(options.disabled), (disabled) => {
|
|
8617
|
+
watch(() => toValue$1(options.disabled), (disabled) => {
|
|
8181
8618
|
if (disabled) {
|
|
8182
8619
|
currentId++;
|
|
8183
8620
|
outputRef.value = sourceVal();
|
|
@@ -8186,7 +8623,7 @@ function useTransition(source, options = {}) {
|
|
|
8186
8623
|
tryOnScopeDispose(() => {
|
|
8187
8624
|
currentId++;
|
|
8188
8625
|
});
|
|
8189
|
-
return computed(() => toValue(options.disabled) ? sourceVal() : outputRef.value);
|
|
8626
|
+
return computed(() => toValue$1(options.disabled) ? sourceVal() : outputRef.value);
|
|
8190
8627
|
}
|
|
8191
8628
|
|
|
8192
8629
|
function useUrlSearchParams(mode = "history", options = {}) {
|
|
@@ -8195,6 +8632,7 @@ function useUrlSearchParams(mode = "history", options = {}) {
|
|
|
8195
8632
|
removeNullishValues = true,
|
|
8196
8633
|
removeFalsyValues = false,
|
|
8197
8634
|
write: enableWrite = true,
|
|
8635
|
+
writeMode = "replace",
|
|
8198
8636
|
window = defaultWindow
|
|
8199
8637
|
} = options;
|
|
8200
8638
|
if (!window)
|
|
@@ -8250,7 +8688,7 @@ function useUrlSearchParams(mode = "history", options = {}) {
|
|
|
8250
8688
|
else
|
|
8251
8689
|
params.set(key, mapEntry);
|
|
8252
8690
|
});
|
|
8253
|
-
write(params);
|
|
8691
|
+
write(params, false);
|
|
8254
8692
|
},
|
|
8255
8693
|
{ deep: true }
|
|
8256
8694
|
);
|
|
@@ -8258,11 +8696,19 @@ function useUrlSearchParams(mode = "history", options = {}) {
|
|
|
8258
8696
|
pause();
|
|
8259
8697
|
if (shouldUpdate)
|
|
8260
8698
|
updateState(params);
|
|
8261
|
-
|
|
8262
|
-
window.history.
|
|
8263
|
-
|
|
8264
|
-
|
|
8265
|
-
|
|
8699
|
+
if (writeMode === "replace") {
|
|
8700
|
+
window.history.replaceState(
|
|
8701
|
+
window.history.state,
|
|
8702
|
+
window.document.title,
|
|
8703
|
+
window.location.pathname + constructQuery(params)
|
|
8704
|
+
);
|
|
8705
|
+
} else {
|
|
8706
|
+
window.history.pushState(
|
|
8707
|
+
window.history.state,
|
|
8708
|
+
window.document.title,
|
|
8709
|
+
window.location.pathname + constructQuery(params)
|
|
8710
|
+
);
|
|
8711
|
+
}
|
|
8266
8712
|
resume();
|
|
8267
8713
|
}
|
|
8268
8714
|
function onChanged() {
|
|
@@ -8270,9 +8716,10 @@ function useUrlSearchParams(mode = "history", options = {}) {
|
|
|
8270
8716
|
return;
|
|
8271
8717
|
write(read(), true);
|
|
8272
8718
|
}
|
|
8273
|
-
|
|
8719
|
+
const listenerOptions = { passive: true };
|
|
8720
|
+
useEventListener(window, "popstate", onChanged, listenerOptions);
|
|
8274
8721
|
if (mode !== "history")
|
|
8275
|
-
useEventListener(window, "hashchange", onChanged,
|
|
8722
|
+
useEventListener(window, "hashchange", onChanged, listenerOptions);
|
|
8276
8723
|
const initial = read();
|
|
8277
8724
|
if (initial.keys().next().value)
|
|
8278
8725
|
updateState(initial);
|
|
@@ -8494,7 +8941,7 @@ function useVirtualList(list, options) {
|
|
|
8494
8941
|
};
|
|
8495
8942
|
}
|
|
8496
8943
|
function useVirtualListResources(list) {
|
|
8497
|
-
const containerRef =
|
|
8944
|
+
const containerRef = shallowRef(null);
|
|
8498
8945
|
const size = useElementSize(containerRef);
|
|
8499
8946
|
const currentList = ref([]);
|
|
8500
8947
|
const source = shallowRef(list);
|
|
@@ -8666,7 +9113,7 @@ function useWakeLock(options = {}) {
|
|
|
8666
9113
|
useEventListener(sentinel, "release", () => {
|
|
8667
9114
|
var _a, _b;
|
|
8668
9115
|
requestedType.value = (_b = (_a = sentinel.value) == null ? void 0 : _a.type) != null ? _b : false;
|
|
8669
|
-
});
|
|
9116
|
+
}, { passive: true });
|
|
8670
9117
|
whenever(
|
|
8671
9118
|
() => documentVisibility.value === "visible" && (document == null ? void 0 : document.visibilityState) === "visible" && requestedType.value,
|
|
8672
9119
|
(type) => {
|
|
@@ -8711,10 +9158,16 @@ function useWebNotification(options = {}) {
|
|
|
8711
9158
|
const isSupported = useSupported(() => {
|
|
8712
9159
|
if (!window || !("Notification" in window))
|
|
8713
9160
|
return false;
|
|
9161
|
+
if (Notification.permission === "granted")
|
|
9162
|
+
return true;
|
|
8714
9163
|
try {
|
|
8715
|
-
new Notification("");
|
|
9164
|
+
const notification2 = new Notification("");
|
|
9165
|
+
notification2.onshow = () => {
|
|
9166
|
+
notification2.close();
|
|
9167
|
+
};
|
|
8716
9168
|
} catch (e) {
|
|
8717
|
-
|
|
9169
|
+
if (e.name === "TypeError")
|
|
9170
|
+
return false;
|
|
8718
9171
|
}
|
|
8719
9172
|
return true;
|
|
8720
9173
|
});
|
|
@@ -8789,6 +9242,7 @@ function useWebSocket(url, options = {}) {
|
|
|
8789
9242
|
onError,
|
|
8790
9243
|
onMessage,
|
|
8791
9244
|
immediate = true,
|
|
9245
|
+
autoConnect = true,
|
|
8792
9246
|
autoClose = true,
|
|
8793
9247
|
protocols = []
|
|
8794
9248
|
} = options;
|
|
@@ -8801,6 +9255,7 @@ function useWebSocket(url, options = {}) {
|
|
|
8801
9255
|
let explicitlyClosed = false;
|
|
8802
9256
|
let retried = 0;
|
|
8803
9257
|
let bufferedData = [];
|
|
9258
|
+
let retryTimeout;
|
|
8804
9259
|
let pongTimeoutWait;
|
|
8805
9260
|
const _sendBuffer = () => {
|
|
8806
9261
|
if (bufferedData.length && wsRef.value && status.value === "OPEN") {
|
|
@@ -8809,12 +9264,19 @@ function useWebSocket(url, options = {}) {
|
|
|
8809
9264
|
bufferedData = [];
|
|
8810
9265
|
}
|
|
8811
9266
|
};
|
|
9267
|
+
const resetRetry = () => {
|
|
9268
|
+
if (retryTimeout != null) {
|
|
9269
|
+
clearTimeout(retryTimeout);
|
|
9270
|
+
retryTimeout = void 0;
|
|
9271
|
+
}
|
|
9272
|
+
};
|
|
8812
9273
|
const resetHeartbeat = () => {
|
|
8813
9274
|
clearTimeout(pongTimeoutWait);
|
|
8814
9275
|
pongTimeoutWait = void 0;
|
|
8815
9276
|
};
|
|
8816
9277
|
const close = (code = 1e3, reason) => {
|
|
8817
|
-
|
|
9278
|
+
resetRetry();
|
|
9279
|
+
if (!isClient && !isWorker || !wsRef.value)
|
|
8818
9280
|
return;
|
|
8819
9281
|
explicitlyClosed = true;
|
|
8820
9282
|
resetHeartbeat();
|
|
@@ -8856,9 +9318,9 @@ function useWebSocket(url, options = {}) {
|
|
|
8856
9318
|
} = resolveNestedOptions(options.autoReconnect);
|
|
8857
9319
|
if (typeof retries === "number" && (retries < 0 || retried < retries)) {
|
|
8858
9320
|
retried += 1;
|
|
8859
|
-
setTimeout(_init, delay);
|
|
9321
|
+
retryTimeout = setTimeout(_init, delay);
|
|
8860
9322
|
} else if (typeof retries === "function" && retries()) {
|
|
8861
|
-
setTimeout(_init, delay);
|
|
9323
|
+
retryTimeout = setTimeout(_init, delay);
|
|
8862
9324
|
} else {
|
|
8863
9325
|
onFailed == null ? void 0 : onFailed();
|
|
8864
9326
|
}
|
|
@@ -8874,7 +9336,7 @@ function useWebSocket(url, options = {}) {
|
|
|
8874
9336
|
message = DEFAULT_PING_MESSAGE,
|
|
8875
9337
|
responseMessage = message
|
|
8876
9338
|
} = resolveNestedOptions(options.heartbeat);
|
|
8877
|
-
if (e.data === responseMessage)
|
|
9339
|
+
if (e.data === toValue$1(responseMessage))
|
|
8878
9340
|
return;
|
|
8879
9341
|
}
|
|
8880
9342
|
data.value = e.data;
|
|
@@ -8889,7 +9351,7 @@ function useWebSocket(url, options = {}) {
|
|
|
8889
9351
|
} = resolveNestedOptions(options.heartbeat);
|
|
8890
9352
|
const { pause, resume } = useIntervalFn(
|
|
8891
9353
|
() => {
|
|
8892
|
-
send(message, false);
|
|
9354
|
+
send(toValue$1(message), false);
|
|
8893
9355
|
if (pongTimeoutWait != null)
|
|
8894
9356
|
return;
|
|
8895
9357
|
pongTimeoutWait = setTimeout(() => {
|
|
@@ -8905,7 +9367,7 @@ function useWebSocket(url, options = {}) {
|
|
|
8905
9367
|
}
|
|
8906
9368
|
if (autoClose) {
|
|
8907
9369
|
if (isClient)
|
|
8908
|
-
useEventListener("beforeunload", () => close());
|
|
9370
|
+
useEventListener("beforeunload", () => close(), { passive: true });
|
|
8909
9371
|
tryOnScopeDispose(close);
|
|
8910
9372
|
}
|
|
8911
9373
|
const open = () => {
|
|
@@ -8918,7 +9380,8 @@ function useWebSocket(url, options = {}) {
|
|
|
8918
9380
|
};
|
|
8919
9381
|
if (immediate)
|
|
8920
9382
|
open();
|
|
8921
|
-
|
|
9383
|
+
if (autoConnect)
|
|
9384
|
+
watch(urlRef, open);
|
|
8922
9385
|
return {
|
|
8923
9386
|
data,
|
|
8924
9387
|
status,
|
|
@@ -9090,56 +9553,21 @@ function useWebWorkerFn(fn, options = {}) {
|
|
|
9090
9553
|
function useWindowFocus(options = {}) {
|
|
9091
9554
|
const { window = defaultWindow } = options;
|
|
9092
9555
|
if (!window)
|
|
9093
|
-
return
|
|
9556
|
+
return shallowRef(false);
|
|
9094
9557
|
const focused = ref(window.document.hasFocus());
|
|
9558
|
+
const listenerOptions = { passive: true };
|
|
9095
9559
|
useEventListener(window, "blur", () => {
|
|
9096
9560
|
focused.value = false;
|
|
9097
|
-
});
|
|
9561
|
+
}, listenerOptions);
|
|
9098
9562
|
useEventListener(window, "focus", () => {
|
|
9099
9563
|
focused.value = true;
|
|
9100
|
-
});
|
|
9564
|
+
}, listenerOptions);
|
|
9101
9565
|
return focused;
|
|
9102
9566
|
}
|
|
9103
9567
|
|
|
9104
9568
|
function useWindowScroll(options = {}) {
|
|
9105
|
-
const { window = defaultWindow,
|
|
9106
|
-
|
|
9107
|
-
return {
|
|
9108
|
-
x: ref(0),
|
|
9109
|
-
y: ref(0)
|
|
9110
|
-
};
|
|
9111
|
-
}
|
|
9112
|
-
const internalX = ref(window.scrollX);
|
|
9113
|
-
const internalY = ref(window.scrollY);
|
|
9114
|
-
const x = computed({
|
|
9115
|
-
get() {
|
|
9116
|
-
return internalX.value;
|
|
9117
|
-
},
|
|
9118
|
-
set(x2) {
|
|
9119
|
-
scrollTo({ left: x2, behavior });
|
|
9120
|
-
}
|
|
9121
|
-
});
|
|
9122
|
-
const y = computed({
|
|
9123
|
-
get() {
|
|
9124
|
-
return internalY.value;
|
|
9125
|
-
},
|
|
9126
|
-
set(y2) {
|
|
9127
|
-
scrollTo({ top: y2, behavior });
|
|
9128
|
-
}
|
|
9129
|
-
});
|
|
9130
|
-
useEventListener(
|
|
9131
|
-
window,
|
|
9132
|
-
"scroll",
|
|
9133
|
-
() => {
|
|
9134
|
-
internalX.value = window.scrollX;
|
|
9135
|
-
internalY.value = window.scrollY;
|
|
9136
|
-
},
|
|
9137
|
-
{
|
|
9138
|
-
capture: false,
|
|
9139
|
-
passive: true
|
|
9140
|
-
}
|
|
9141
|
-
);
|
|
9142
|
-
return { x, y };
|
|
9569
|
+
const { window = defaultWindow, ...rest } = options;
|
|
9570
|
+
return useScroll(window, rest);
|
|
9143
9571
|
}
|
|
9144
9572
|
|
|
9145
9573
|
function useWindowSize(options = {}) {
|
|
@@ -9158,6 +9586,10 @@ function useWindowSize(options = {}) {
|
|
|
9158
9586
|
if (type === "outer") {
|
|
9159
9587
|
width.value = window.outerWidth;
|
|
9160
9588
|
height.value = window.outerHeight;
|
|
9589
|
+
} else if (type === "visual" && window.visualViewport) {
|
|
9590
|
+
const { width: visualViewportWidth, height: visualViewportHeight, scale } = window.visualViewport;
|
|
9591
|
+
width.value = Math.round(visualViewportWidth * scale);
|
|
9592
|
+
height.value = Math.round(visualViewportHeight * scale);
|
|
9161
9593
|
} else if (includeScrollbar) {
|
|
9162
9594
|
width.value = window.innerWidth;
|
|
9163
9595
|
height.value = window.innerHeight;
|
|
@@ -9169,7 +9601,11 @@ function useWindowSize(options = {}) {
|
|
|
9169
9601
|
};
|
|
9170
9602
|
update();
|
|
9171
9603
|
tryOnMounted(update);
|
|
9172
|
-
|
|
9604
|
+
const listenerOptions = { passive: true };
|
|
9605
|
+
useEventListener("resize", update, listenerOptions);
|
|
9606
|
+
if (window && type === "visual" && window.visualViewport) {
|
|
9607
|
+
useEventListener(window.visualViewport, "resize", update, listenerOptions);
|
|
9608
|
+
}
|
|
9173
9609
|
if (listenOrientation) {
|
|
9174
9610
|
const matches = useMediaQuery("(orientation: portrait)");
|
|
9175
9611
|
watch(matches, () => update());
|
|
@@ -9177,4 +9613,4 @@ function useWindowSize(options = {}) {
|
|
|
9177
9613
|
return { width, height };
|
|
9178
9614
|
}
|
|
9179
9615
|
|
|
9180
|
-
export { DefaultMagicKeysAliasMap, StorageSerializers, TransitionPresets, assert, computedAsync as asyncComputed, refAutoReset as autoResetRef, breakpointsAntDesign, breakpointsBootstrapV5, breakpointsElement, breakpointsMasterCss, breakpointsPrimeFlex, breakpointsQuasar, breakpointsSematic, breakpointsTailwind, breakpointsVuetify, breakpointsVuetifyV2, breakpointsVuetifyV3, bypassFilter, camelize, clamp, cloneFnJSON, computedAsync, computedEager, computedInject, computedWithControl, containsProp, computedWithControl as controlledComputed, controlledRef, createEventHook, createFetch, createFilterWrapper, createGlobalState, createInjectionState, reactify as createReactiveFn, createReusableTemplate, createSharedComposable, createSingletonPromise, createTemplatePromise, createUnrefFn, customStorageEventName, debounceFilter, refDebounced as debouncedRef, watchDebounced as debouncedWatch, defaultDocument, defaultLocation, defaultNavigator, defaultWindow, computedEager as eagerComputed, executeTransition, extendRef, formatDate, formatTimeAgo, get, getLifeCycleTarget, getSSRHandler, hasOwn, hyphenate, identity, watchIgnorable as ignorableWatch, increaseWithUnit, injectLocal, invoke, isClient, isDef, isDefined, isIOS, isObject, isWorker, makeDestructurable, mapGamepadToXbox360Controller, noop, normalizeDate, notNullish, now, objectEntries, objectOmit, objectPick, onClickOutside, onKeyDown, onKeyPressed, onKeyStroke, onKeyUp, onLongPress, onStartTyping, pausableFilter, watchPausable as pausableWatch, promiseTimeout, provideLocal, rand, reactify, reactifyObject, reactiveComputed, reactiveOmit, reactivePick, refAutoReset, refDebounced, refDefault, refThrottled, refWithControl, resolveRef, resolveUnref, set, setSSRHandler, syncRef, syncRefs, templateRef, throttleFilter, refThrottled as throttledRef, watchThrottled as throttledWatch, timestamp, toReactive, toRef, toRefs, toValue, tryOnBeforeMount, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, unrefElement, until, useActiveElement, useAnimate, useArrayDifference, useArrayEvery, useArrayFilter, useArrayFind, useArrayFindIndex, useArrayFindLast, useArrayIncludes, useArrayJoin, useArrayMap, useArrayReduce, useArraySome, useArrayUnique, useAsyncQueue, useAsyncState, useBase64, useBattery, useBluetooth, useBreakpoints, useBroadcastChannel, useBrowserLocation, useCached, useClipboard, useClipboardItems, useCloned, useColorMode, useConfirmDialog, useCounter, useCssVar, useCurrentElement, useCycleList, useDark, useDateFormat, refDebounced as useDebounce, useDebounceFn, useDebouncedRefHistory, useDeviceMotion, useDeviceOrientation, useDevicePixelRatio, useDevicesList, useDisplayMedia, useDocumentVisibility, useDraggable, useDropZone, useElementBounding, useElementByPoint, useElementHover, useElementSize, useElementVisibility, useEventBus, useEventListener, useEventSource, useEyeDropper, useFavicon, useFetch, useFileDialog, useFileSystemAccess, useFocus, useFocusWithin, useFps, useFullscreen, useGamepad, useGeolocation, useIdle, useImage, useInfiniteScroll, useIntersectionObserver, useInterval, useIntervalFn, useKeyModifier, useLastChanged, useLocalStorage, useMagicKeys, useManualRefHistory, useMediaControls, useMediaQuery, useMemoize, useMemory, useMounted, useMouse, useMouseInElement, useMousePressed, useMutationObserver, useNavigatorLanguage, useNetwork, useNow, useObjectUrl, useOffsetPagination, useOnline, usePageLeave, useParallax, useParentElement, usePerformanceObserver, usePermission, usePointer, usePointerLock, usePointerSwipe, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePreferredLanguages, usePreferredReducedMotion, usePrevious, useRafFn, useRefHistory, useResizeObserver, useScreenOrientation, useScreenSafeArea, useScriptTag, useScroll, useScrollLock, useSessionStorage, useShare, useSorted, useSpeechRecognition, useSpeechSynthesis, useStepper, useStorage, useStorageAsync, useStyleTag, useSupported, useSwipe, useTemplateRefsList, useTextDirection, useTextSelection, useTextareaAutosize, refThrottled as useThrottle, useThrottleFn, useThrottledRefHistory, useTimeAgo, useTimeout, useTimeoutFn, useTimeoutPoll, useTimestamp, useTitle, useToNumber, useToString, useToggle, useTransition, useUrlSearchParams, useUserMedia, useVModel, useVModels, useVibrate, useVirtualList, useWakeLock, useWebNotification, useWebSocket, useWebWorker, useWebWorkerFn, useWindowFocus, useWindowScroll, useWindowSize, watchArray, watchAtMost, watchDebounced, watchDeep, watchIgnorable, watchImmediate, watchOnce, watchPausable, watchThrottled, watchTriggerable, watchWithFilter, whenever };
|
|
9616
|
+
export { DefaultMagicKeysAliasMap, StorageSerializers, TransitionPresets, assert, computedAsync as asyncComputed, refAutoReset as autoResetRef, breakpointsAntDesign, breakpointsBootstrapV5, breakpointsElement, breakpointsMasterCss, breakpointsPrimeFlex, breakpointsQuasar, breakpointsSematic, breakpointsTailwind, breakpointsVuetify, breakpointsVuetifyV2, breakpointsVuetifyV3, bypassFilter, camelize, clamp, cloneFnJSON, computedAsync, computedEager, computedInject, computedWithControl, containsProp, computedWithControl as controlledComputed, controlledRef, createEventHook, createFetch, createFilterWrapper, createGlobalState, createInjectionState, reactify as createReactiveFn, createReusableTemplate, createSharedComposable, createSingletonPromise, createTemplatePromise, createUnrefFn, customStorageEventName, debounceFilter, refDebounced as debouncedRef, watchDebounced as debouncedWatch, defaultDocument, defaultLocation, defaultNavigator, defaultWindow, computedEager as eagerComputed, executeTransition, extendRef, formatDate, formatTimeAgo, get, getLifeCycleTarget, getSSRHandler, hasOwn, hyphenate, identity, watchIgnorable as ignorableWatch, increaseWithUnit, injectLocal, invoke, isClient, isDef, isDefined, isIOS, isObject, isWorker, makeDestructurable, mapGamepadToXbox360Controller, noop, normalizeDate, notNullish, now, objectEntries, objectOmit, objectPick, onClickOutside, onElementRemoval, onKeyDown, onKeyPressed, onKeyStroke, onKeyUp, onLongPress, onStartTyping, pausableFilter, watchPausable as pausableWatch, promiseTimeout, provideLocal, provideSSRWidth, pxValue, rand, reactify, reactifyObject, reactiveComputed, reactiveOmit, reactivePick, refAutoReset, refDebounced, refDefault, refThrottled, refWithControl, resolveRef, resolveUnref, set, setSSRHandler, syncRef, syncRefs, templateRef, throttleFilter, refThrottled as throttledRef, watchThrottled as throttledWatch, timestamp, toArray, toReactive, toRef, toRefs, toValue, tryOnBeforeMount, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, unrefElement, until, useActiveElement, useAnimate, useArrayDifference, useArrayEvery, useArrayFilter, useArrayFind, useArrayFindIndex, useArrayFindLast, useArrayIncludes, useArrayJoin, useArrayMap, useArrayReduce, useArraySome, useArrayUnique, useAsyncQueue, useAsyncState, useBase64, useBattery, useBluetooth, useBreakpoints, useBroadcastChannel, useBrowserLocation, useCached, useClipboard, useClipboardItems, useCloned, useColorMode, useConfirmDialog, useCountdown, useCounter, useCssVar, useCurrentElement, useCycleList, useDark, useDateFormat, refDebounced as useDebounce, useDebounceFn, useDebouncedRefHistory, useDeviceMotion, useDeviceOrientation, useDevicePixelRatio, useDevicesList, useDisplayMedia, useDocumentVisibility, useDraggable, useDropZone, useElementBounding, useElementByPoint, useElementHover, useElementSize, useElementVisibility, useEventBus, useEventListener, useEventSource, useEyeDropper, useFavicon, useFetch, useFileDialog, useFileSystemAccess, useFocus, useFocusWithin, useFps, useFullscreen, useGamepad, useGeolocation, useIdle, useImage, useInfiniteScroll, useIntersectionObserver, useInterval, useIntervalFn, useKeyModifier, useLastChanged, useLocalStorage, useMagicKeys, useManualRefHistory, useMediaControls, useMediaQuery, useMemoize, useMemory, useMounted, useMouse, useMouseInElement, useMousePressed, useMutationObserver, useNavigatorLanguage, useNetwork, useNow, useObjectUrl, useOffsetPagination, useOnline, usePageLeave, useParallax, useParentElement, usePerformanceObserver, usePermission, usePointer, usePointerLock, usePointerSwipe, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePreferredLanguages, usePreferredReducedMotion, usePreferredReducedTransparency, usePrevious, useRafFn, useRefHistory, useResizeObserver, useSSRWidth, useScreenOrientation, useScreenSafeArea, useScriptTag, useScroll, useScrollLock, useSessionStorage, useShare, useSorted, useSpeechRecognition, useSpeechSynthesis, useStepper, useStorage, useStorageAsync, useStyleTag, useSupported, useSwipe, useTemplateRefsList, useTextDirection, useTextSelection, useTextareaAutosize, refThrottled as useThrottle, useThrottleFn, useThrottledRefHistory, useTimeAgo, useTimeout, useTimeoutFn, useTimeoutPoll, useTimestamp, useTitle, useToNumber, useToString, useToggle, useTransition, useUrlSearchParams, useUserMedia, useVModel, useVModels, useVibrate, useVirtualList, useWakeLock, useWebNotification, useWebSocket, useWebWorker, useWebWorkerFn, useWindowFocus, useWindowScroll, useWindowSize, watchArray, watchAtMost, watchDebounced, watchDeep, watchIgnorable, watchImmediate, watchOnce, watchPausable, watchThrottled, watchTriggerable, watchWithFilter, whenever };
|