@histoire/vendors 0.13.0 → 0.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/b-vue-use.js +1705 -976
- package/dist/client/b-vue.js +1 -1
- package/dist/client/node_modules/@types/web-bluetooth/index.d.ts +0 -2
- package/dist/client/node_modules/@types/web-bluetooth/package.json +3 -3
- package/dist/client/node_modules/@vueuse/core/index.d.ts +740 -524
- package/dist/client/node_modules/@vueuse/core/package.json +4 -16
- package/dist/client/node_modules/@vueuse/metadata/index.d.ts +1 -0
- package/dist/client/node_modules/@vueuse/metadata/package.json +1 -1
- package/dist/client/node_modules/@vueuse/{core/node_modules/@vueuse/shared → shared}/index.d.ts +299 -114
- package/dist/client/node_modules/@vueuse/shared/node_modules/vue-demi/lib/index.d.ts +22 -0
- package/dist/client/node_modules/@vueuse/shared/node_modules/vue-demi/lib/v2/index.d.ts +31 -0
- package/dist/client/node_modules/@vueuse/shared/node_modules/vue-demi/lib/v2.7/index.d.ts +36 -0
- package/dist/client/node_modules/@vueuse/shared/node_modules/vue-demi/lib/v3/index.d.ts +22 -0
- package/dist/client/node_modules/@vueuse/shared/node_modules/vue-demi/package.json +47 -0
- package/dist/client/node_modules/@vueuse/{core/node_modules/@vueuse/shared → shared}/package.json +1 -13
- package/dist/client/vue.runtime.esm-bundler.js +1 -1
- package/package.json +2 -2
- package/rollup.config.mjs +1 -1
package/dist/client/b-vue-use.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as isVue3, i as isVue2, s as set$1, d as del } from './index.js';
|
|
2
|
-
import { T as shallowRef, R as watchEffect, U as readonly, C as unref, u as ref, B as watch,
|
|
2
|
+
import { T as shallowRef, R as watchEffect, U as readonly, C as unref, u as ref, V as version, B as watch, W as customRef, I as getCurrentScope, J as onScopeDispose, E as effectScope, S as provide, z as inject, G as isRef, L as computed, M as reactive, K as toRefs$1, N as toRef, y as getCurrentInstance, X as onBeforeMount, b as nextTick, Y as onBeforeUnmount, Z as onMounted, O as onUnmounted, H as isReactive, _ as onUpdated, D as markRaw, $ as onBeforeUpdate } from './vue.runtime.esm-bundler.js';
|
|
3
3
|
|
|
4
4
|
var __defProp$9$1 = Object.defineProperty;
|
|
5
5
|
var __defProps$6$1 = Object.defineProperties;
|
|
@@ -56,10 +56,17 @@ const rand = (min, max) => {
|
|
|
56
56
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
57
57
|
};
|
|
58
58
|
const isIOS = isClient && ((_a = window == null ? void 0 : window.navigator) == null ? void 0 : _a.userAgent) && /iP(ad|hone|od)/.test(window.navigator.userAgent);
|
|
59
|
+
const hasOwn = (val, key) => Object.prototype.hasOwnProperty.call(val, key);
|
|
60
|
+
|
|
61
|
+
function resolveUnref(r) {
|
|
62
|
+
return typeof r === "function" ? r() : unref(r);
|
|
63
|
+
}
|
|
59
64
|
|
|
60
65
|
function createFilterWrapper(filter, fn) {
|
|
61
66
|
function wrapper(...args) {
|
|
62
|
-
|
|
67
|
+
return new Promise((resolve, reject) => {
|
|
68
|
+
Promise.resolve(filter(() => fn.apply(this, args), { fn, thisArg: this, args })).then(resolve).catch(reject);
|
|
69
|
+
});
|
|
63
70
|
}
|
|
64
71
|
return wrapper;
|
|
65
72
|
}
|
|
@@ -69,48 +76,64 @@ const bypassFilter = (invoke) => {
|
|
|
69
76
|
function debounceFilter(ms, options = {}) {
|
|
70
77
|
let timer;
|
|
71
78
|
let maxTimer;
|
|
79
|
+
let lastRejector = noop;
|
|
80
|
+
const _clearTimeout = (timer2) => {
|
|
81
|
+
clearTimeout(timer2);
|
|
82
|
+
lastRejector();
|
|
83
|
+
lastRejector = noop;
|
|
84
|
+
};
|
|
72
85
|
const filter = (invoke) => {
|
|
73
|
-
const duration =
|
|
74
|
-
const maxDuration =
|
|
86
|
+
const duration = resolveUnref(ms);
|
|
87
|
+
const maxDuration = resolveUnref(options.maxWait);
|
|
75
88
|
if (timer)
|
|
76
|
-
|
|
89
|
+
_clearTimeout(timer);
|
|
77
90
|
if (duration <= 0 || maxDuration !== void 0 && maxDuration <= 0) {
|
|
78
91
|
if (maxTimer) {
|
|
79
|
-
|
|
92
|
+
_clearTimeout(maxTimer);
|
|
80
93
|
maxTimer = null;
|
|
81
94
|
}
|
|
82
|
-
return invoke();
|
|
95
|
+
return Promise.resolve(invoke());
|
|
83
96
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
97
|
+
return new Promise((resolve, reject) => {
|
|
98
|
+
lastRejector = options.rejectOnCancel ? reject : resolve;
|
|
99
|
+
if (maxDuration && !maxTimer) {
|
|
100
|
+
maxTimer = setTimeout(() => {
|
|
101
|
+
if (timer)
|
|
102
|
+
_clearTimeout(timer);
|
|
103
|
+
maxTimer = null;
|
|
104
|
+
resolve(invoke());
|
|
105
|
+
}, maxDuration);
|
|
106
|
+
}
|
|
107
|
+
timer = setTimeout(() => {
|
|
108
|
+
if (maxTimer)
|
|
109
|
+
_clearTimeout(maxTimer);
|
|
88
110
|
maxTimer = null;
|
|
89
|
-
invoke();
|
|
90
|
-
},
|
|
91
|
-
}
|
|
92
|
-
timer = setTimeout(() => {
|
|
93
|
-
if (maxTimer)
|
|
94
|
-
clearTimeout(maxTimer);
|
|
95
|
-
maxTimer = null;
|
|
96
|
-
invoke();
|
|
97
|
-
}, duration);
|
|
111
|
+
resolve(invoke());
|
|
112
|
+
}, duration);
|
|
113
|
+
});
|
|
98
114
|
};
|
|
99
115
|
return filter;
|
|
100
116
|
}
|
|
101
|
-
function throttleFilter(ms, trailing = true, leading = true) {
|
|
117
|
+
function throttleFilter(ms, trailing = true, leading = true, rejectOnCancel = false) {
|
|
102
118
|
let lastExec = 0;
|
|
103
119
|
let timer;
|
|
104
120
|
let isLeading = true;
|
|
121
|
+
let lastRejector = noop;
|
|
122
|
+
let lastValue;
|
|
105
123
|
const clear = () => {
|
|
106
124
|
if (timer) {
|
|
107
125
|
clearTimeout(timer);
|
|
108
126
|
timer = void 0;
|
|
127
|
+
lastRejector();
|
|
128
|
+
lastRejector = noop;
|
|
109
129
|
}
|
|
110
130
|
};
|
|
111
|
-
const filter = (
|
|
112
|
-
const duration =
|
|
131
|
+
const filter = (_invoke) => {
|
|
132
|
+
const duration = resolveUnref(ms);
|
|
113
133
|
const elapsed = Date.now() - lastExec;
|
|
134
|
+
const invoke = () => {
|
|
135
|
+
return lastValue = _invoke();
|
|
136
|
+
};
|
|
114
137
|
clear();
|
|
115
138
|
if (duration <= 0) {
|
|
116
139
|
lastExec = Date.now();
|
|
@@ -120,16 +143,20 @@ function throttleFilter(ms, trailing = true, leading = true) {
|
|
|
120
143
|
lastExec = Date.now();
|
|
121
144
|
invoke();
|
|
122
145
|
} else if (trailing) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
146
|
+
return new Promise((resolve, reject) => {
|
|
147
|
+
lastRejector = rejectOnCancel ? reject : resolve;
|
|
148
|
+
timer = setTimeout(() => {
|
|
149
|
+
lastExec = Date.now();
|
|
150
|
+
isLeading = true;
|
|
151
|
+
resolve(invoke());
|
|
152
|
+
clear();
|
|
153
|
+
}, duration - elapsed);
|
|
154
|
+
});
|
|
129
155
|
}
|
|
130
156
|
if (!leading && !timer)
|
|
131
157
|
timer = setTimeout(() => isLeading = true, duration);
|
|
132
158
|
isLeading = false;
|
|
159
|
+
return lastValue;
|
|
133
160
|
};
|
|
134
161
|
return filter;
|
|
135
162
|
}
|
|
@@ -145,7 +172,7 @@ function pausableFilter(extendFilter = bypassFilter) {
|
|
|
145
172
|
if (isActive.value)
|
|
146
173
|
extendFilter(...args);
|
|
147
174
|
};
|
|
148
|
-
return { isActive, pause, resume, eventFilter };
|
|
175
|
+
return { isActive: readonly(isActive), pause, resume, eventFilter };
|
|
149
176
|
}
|
|
150
177
|
|
|
151
178
|
function __onlyVue3(name = "this function") {
|
|
@@ -153,6 +180,11 @@ function __onlyVue3(name = "this function") {
|
|
|
153
180
|
return;
|
|
154
181
|
throw new Error(`[VueUse] ${name} is only works on Vue 3.`);
|
|
155
182
|
}
|
|
183
|
+
function __onlyVue27Plus(name = "this function") {
|
|
184
|
+
if (isVue3 || version.startsWith("2.7."))
|
|
185
|
+
return;
|
|
186
|
+
throw new Error(`[VueUse] ${name} is only works on Vue 2.7 or above.`);
|
|
187
|
+
}
|
|
156
188
|
const directiveHooks = {
|
|
157
189
|
mounted: isVue3 ? "mounted" : "inserted",
|
|
158
190
|
updated: isVue3 ? "updated" : "componentUpdated",
|
|
@@ -246,6 +278,14 @@ function computedWithControl(source, fn) {
|
|
|
246
278
|
return result;
|
|
247
279
|
}
|
|
248
280
|
|
|
281
|
+
function tryOnScopeDispose(fn) {
|
|
282
|
+
if (getCurrentScope()) {
|
|
283
|
+
onScopeDispose(fn);
|
|
284
|
+
return true;
|
|
285
|
+
}
|
|
286
|
+
return false;
|
|
287
|
+
}
|
|
288
|
+
|
|
249
289
|
function createEventHook() {
|
|
250
290
|
const fns = [];
|
|
251
291
|
const off = (fn) => {
|
|
@@ -255,8 +295,10 @@ function createEventHook() {
|
|
|
255
295
|
};
|
|
256
296
|
const on = (fn) => {
|
|
257
297
|
fns.push(fn);
|
|
298
|
+
const offFn = () => off(fn);
|
|
299
|
+
tryOnScopeDispose(offFn);
|
|
258
300
|
return {
|
|
259
|
-
off:
|
|
301
|
+
off: offFn
|
|
260
302
|
};
|
|
261
303
|
};
|
|
262
304
|
const trigger = (param) => {
|
|
@@ -285,20 +327,14 @@ function createGlobalState(stateFactory) {
|
|
|
285
327
|
function createInjectionState(composable) {
|
|
286
328
|
const key = Symbol("InjectionState");
|
|
287
329
|
const useProvidingState = (...args) => {
|
|
288
|
-
|
|
330
|
+
const state = composable(...args);
|
|
331
|
+
provide(key, state);
|
|
332
|
+
return state;
|
|
289
333
|
};
|
|
290
334
|
const useInjectedState = () => inject(key);
|
|
291
335
|
return [useProvidingState, useInjectedState];
|
|
292
336
|
}
|
|
293
337
|
|
|
294
|
-
function tryOnScopeDispose(fn) {
|
|
295
|
-
if (getCurrentScope()) {
|
|
296
|
-
onScopeDispose(fn);
|
|
297
|
-
return true;
|
|
298
|
-
}
|
|
299
|
-
return false;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
338
|
function createSharedComposable(composable) {
|
|
303
339
|
let subscribers = 0;
|
|
304
340
|
let state;
|
|
@@ -323,7 +359,7 @@ function createSharedComposable(composable) {
|
|
|
323
359
|
}
|
|
324
360
|
|
|
325
361
|
function extendRef(ref, extend, { enumerable = false, unwrap = true } = {}) {
|
|
326
|
-
|
|
362
|
+
__onlyVue27Plus();
|
|
327
363
|
for (const [key, value] of Object.entries(extend)) {
|
|
328
364
|
if (key === "value")
|
|
329
365
|
continue;
|
|
@@ -354,18 +390,6 @@ function isDefined(v) {
|
|
|
354
390
|
return unref(v) != null;
|
|
355
391
|
}
|
|
356
392
|
|
|
357
|
-
function logicAnd(...args) {
|
|
358
|
-
return computed(() => args.every((i) => unref(i)));
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
function logicNot(v) {
|
|
362
|
-
return computed(() => !unref(v));
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
function logicOr(...args) {
|
|
366
|
-
return computed(() => args.some((i) => unref(i)));
|
|
367
|
-
}
|
|
368
|
-
|
|
369
393
|
var __defProp$8$1 = Object.defineProperty;
|
|
370
394
|
var __getOwnPropSymbols$a$1 = Object.getOwnPropertySymbols;
|
|
371
395
|
var __hasOwnProp$a$1 = Object.prototype.hasOwnProperty;
|
|
@@ -403,17 +427,20 @@ function makeDestructurable(obj, arr) {
|
|
|
403
427
|
}
|
|
404
428
|
}
|
|
405
429
|
|
|
406
|
-
function reactify(fn) {
|
|
430
|
+
function reactify(fn, options) {
|
|
431
|
+
const unrefFn = (options == null ? void 0 : options.computedGetter) === false ? unref : resolveUnref;
|
|
407
432
|
return function(...args) {
|
|
408
|
-
return computed(() => fn.apply(this, args.map((i) =>
|
|
433
|
+
return computed(() => fn.apply(this, args.map((i) => unrefFn(i))));
|
|
409
434
|
};
|
|
410
435
|
}
|
|
411
436
|
|
|
412
437
|
function reactifyObject(obj, optionsOrKeys = {}) {
|
|
413
438
|
let keys = [];
|
|
439
|
+
let options;
|
|
414
440
|
if (Array.isArray(optionsOrKeys)) {
|
|
415
441
|
keys = optionsOrKeys;
|
|
416
442
|
} else {
|
|
443
|
+
options = optionsOrKeys;
|
|
417
444
|
const { includeOwnProperties = true } = optionsOrKeys;
|
|
418
445
|
keys.push(...Object.keys(obj));
|
|
419
446
|
if (includeOwnProperties)
|
|
@@ -423,7 +450,7 @@ function reactifyObject(obj, optionsOrKeys = {}) {
|
|
|
423
450
|
const value = obj[key];
|
|
424
451
|
return [
|
|
425
452
|
key,
|
|
426
|
-
typeof value === "function" ? reactify(value.bind(obj)) : value
|
|
453
|
+
typeof value === "function" ? reactify(value.bind(obj), options) : value
|
|
427
454
|
];
|
|
428
455
|
}));
|
|
429
456
|
}
|
|
@@ -482,7 +509,7 @@ function refAutoReset(defaultValue, afterMs = 1e4) {
|
|
|
482
509
|
const resetAfter = () => setTimeout(() => {
|
|
483
510
|
value = defaultValue;
|
|
484
511
|
trigger();
|
|
485
|
-
},
|
|
512
|
+
}, resolveUnref(afterMs));
|
|
486
513
|
tryOnScopeDispose(() => {
|
|
487
514
|
clearTimeout(timer);
|
|
488
515
|
});
|
|
@@ -506,8 +533,6 @@ function useDebounceFn(fn, ms = 200, options = {}) {
|
|
|
506
533
|
}
|
|
507
534
|
|
|
508
535
|
function refDebounced(value, ms = 200, options = {}) {
|
|
509
|
-
if (ms <= 0)
|
|
510
|
-
return value;
|
|
511
536
|
const debounced = ref(value.value);
|
|
512
537
|
const updater = useDebounceFn(() => {
|
|
513
538
|
debounced.value = value.value;
|
|
@@ -528,8 +553,8 @@ function refDefault(source, defaultValue) {
|
|
|
528
553
|
});
|
|
529
554
|
}
|
|
530
555
|
|
|
531
|
-
function useThrottleFn(fn, ms = 200, trailing =
|
|
532
|
-
return createFilterWrapper(throttleFilter(ms, trailing, leading), fn);
|
|
556
|
+
function useThrottleFn(fn, ms = 200, trailing = false, leading = true, rejectOnCancel = false) {
|
|
557
|
+
return createFilterWrapper(throttleFilter(ms, trailing, leading, rejectOnCancel), fn);
|
|
533
558
|
}
|
|
534
559
|
|
|
535
560
|
function refThrottled(value, delay = 200, trailing = true, leading = true) {
|
|
@@ -595,10 +620,6 @@ function resolveRef(r) {
|
|
|
595
620
|
return typeof r === "function" ? computed(r) : ref(r);
|
|
596
621
|
}
|
|
597
622
|
|
|
598
|
-
function resolveUnref(r) {
|
|
599
|
-
return typeof r === "function" ? r() : unref(r);
|
|
600
|
-
}
|
|
601
|
-
|
|
602
623
|
function set(...args) {
|
|
603
624
|
if (args.length === 2) {
|
|
604
625
|
const [ref, value] = args;
|
|
@@ -615,22 +636,27 @@ function set(...args) {
|
|
|
615
636
|
}
|
|
616
637
|
|
|
617
638
|
function syncRef(left, right, options = {}) {
|
|
639
|
+
var _a, _b;
|
|
618
640
|
const {
|
|
619
641
|
flush = "sync",
|
|
620
642
|
deep = false,
|
|
621
643
|
immediate = true,
|
|
622
|
-
direction = "both"
|
|
644
|
+
direction = "both",
|
|
645
|
+
transform = {}
|
|
623
646
|
} = options;
|
|
624
|
-
let
|
|
647
|
+
let watchLeft;
|
|
648
|
+
let watchRight;
|
|
649
|
+
const transformLTR = (_a = transform.ltr) != null ? _a : (v) => v;
|
|
650
|
+
const transformRTL = (_b = transform.rtl) != null ? _b : (v) => v;
|
|
625
651
|
if (direction === "both" || direction === "ltr") {
|
|
626
|
-
|
|
652
|
+
watchLeft = watch(left, (newValue) => right.value = transformLTR(newValue), { flush, deep, immediate });
|
|
627
653
|
}
|
|
628
654
|
if (direction === "both" || direction === "rtl") {
|
|
629
|
-
|
|
655
|
+
watchRight = watch(right, (newValue) => left.value = transformRTL(newValue), { flush, deep, immediate });
|
|
630
656
|
}
|
|
631
657
|
return () => {
|
|
632
|
-
|
|
633
|
-
|
|
658
|
+
watchLeft == null ? void 0 : watchLeft();
|
|
659
|
+
watchRight == null ? void 0 : watchRight();
|
|
634
660
|
};
|
|
635
661
|
}
|
|
636
662
|
|
|
@@ -717,8 +743,7 @@ function tryOnUnmounted(fn) {
|
|
|
717
743
|
onUnmounted(fn);
|
|
718
744
|
}
|
|
719
745
|
|
|
720
|
-
function
|
|
721
|
-
let isNot = false;
|
|
746
|
+
function createUntil(r, isNot = false) {
|
|
722
747
|
function toMatch(condition, { flush = "sync", deep = false, timeout, throwOnTimeout } = {}) {
|
|
723
748
|
let stop = null;
|
|
724
749
|
const watcher = new Promise((resolve) => {
|
|
@@ -735,7 +760,7 @@ function until(r) {
|
|
|
735
760
|
});
|
|
736
761
|
const promises = [watcher];
|
|
737
762
|
if (timeout != null) {
|
|
738
|
-
promises.push(promiseTimeout(timeout, throwOnTimeout).then(() =>
|
|
763
|
+
promises.push(promiseTimeout(timeout, throwOnTimeout).then(() => resolveUnref(r)).finally(() => stop == null ? void 0 : stop()));
|
|
739
764
|
}
|
|
740
765
|
return Promise.race(promises);
|
|
741
766
|
}
|
|
@@ -758,9 +783,9 @@ function until(r) {
|
|
|
758
783
|
});
|
|
759
784
|
const promises = [watcher];
|
|
760
785
|
if (timeout != null) {
|
|
761
|
-
promises.push(promiseTimeout(timeout, throwOnTimeout).then(() =>
|
|
786
|
+
promises.push(promiseTimeout(timeout, throwOnTimeout).then(() => resolveUnref(r)).finally(() => {
|
|
762
787
|
stop == null ? void 0 : stop();
|
|
763
|
-
return
|
|
788
|
+
return resolveUnref(r);
|
|
764
789
|
}));
|
|
765
790
|
}
|
|
766
791
|
return Promise.race(promises);
|
|
@@ -780,7 +805,7 @@ function until(r) {
|
|
|
780
805
|
function toContains(value, options) {
|
|
781
806
|
return toMatch((v) => {
|
|
782
807
|
const array = Array.from(v);
|
|
783
|
-
return array.includes(value) || array.includes(
|
|
808
|
+
return array.includes(value) || array.includes(resolveUnref(value));
|
|
784
809
|
}, options);
|
|
785
810
|
}
|
|
786
811
|
function changed(options) {
|
|
@@ -793,15 +818,14 @@ function until(r) {
|
|
|
793
818
|
return count >= n;
|
|
794
819
|
}, options);
|
|
795
820
|
}
|
|
796
|
-
if (Array.isArray(
|
|
821
|
+
if (Array.isArray(resolveUnref(r))) {
|
|
797
822
|
const instance = {
|
|
798
823
|
toMatch,
|
|
799
824
|
toContains,
|
|
800
825
|
changed,
|
|
801
826
|
changedTimes,
|
|
802
827
|
get not() {
|
|
803
|
-
|
|
804
|
-
return this;
|
|
828
|
+
return createUntil(r, !isNot);
|
|
805
829
|
}
|
|
806
830
|
};
|
|
807
831
|
return instance;
|
|
@@ -816,13 +840,55 @@ function until(r) {
|
|
|
816
840
|
changed,
|
|
817
841
|
changedTimes,
|
|
818
842
|
get not() {
|
|
819
|
-
|
|
820
|
-
return this;
|
|
843
|
+
return createUntil(r, !isNot);
|
|
821
844
|
}
|
|
822
845
|
};
|
|
823
846
|
return instance;
|
|
824
847
|
}
|
|
825
848
|
}
|
|
849
|
+
function until(r) {
|
|
850
|
+
return createUntil(r);
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
function useArrayEvery(list, fn) {
|
|
854
|
+
return computed(() => resolveUnref(list).every((element, index, array) => fn(resolveUnref(element), index, array)));
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
function useArrayFilter(list, fn) {
|
|
858
|
+
return computed(() => resolveUnref(list).map((i) => resolveUnref(i)).filter(fn));
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
function useArrayFind(list, fn) {
|
|
862
|
+
return computed(() => resolveUnref(resolveUnref(list).find((element, index, array) => fn(resolveUnref(element), index, array))));
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
function useArrayFindIndex(list, fn) {
|
|
866
|
+
return computed(() => resolveUnref(list).findIndex((element, index, array) => fn(resolveUnref(element), index, array)));
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
function useArrayJoin(list, separator) {
|
|
870
|
+
return computed(() => resolveUnref(list).map((i) => resolveUnref(i)).join(resolveUnref(separator)));
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
function useArrayMap(list, fn) {
|
|
874
|
+
return computed(() => resolveUnref(list).map((i) => resolveUnref(i)).map(fn));
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
function useArrayReduce(list, reducer, ...args) {
|
|
878
|
+
const reduceCallback = (sum, value, index) => reducer(resolveUnref(sum), resolveUnref(value), index);
|
|
879
|
+
return computed(() => {
|
|
880
|
+
const resolved = resolveUnref(list);
|
|
881
|
+
return args.length ? resolved.reduce(reduceCallback, resolveUnref(args[0])) : resolved.reduce(reduceCallback);
|
|
882
|
+
});
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
function useArraySome(list, fn) {
|
|
886
|
+
return computed(() => resolveUnref(list).some((element, index, array) => fn(resolveUnref(element), index, array)));
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
function useArrayUnique(list) {
|
|
890
|
+
return computed(() => [...new Set(resolveUnref(list).map((element) => resolveUnref(element)))]);
|
|
891
|
+
}
|
|
826
892
|
|
|
827
893
|
function useCounter(initialValue = 0, options = {}) {
|
|
828
894
|
const count = ref(initialValue);
|
|
@@ -833,7 +899,7 @@ function useCounter(initialValue = 0, options = {}) {
|
|
|
833
899
|
const inc = (delta = 1) => count.value = Math.min(max, count.value + delta);
|
|
834
900
|
const dec = (delta = 1) => count.value = Math.max(min, count.value - delta);
|
|
835
901
|
const get = () => count.value;
|
|
836
|
-
const set = (val) => count.value = val;
|
|
902
|
+
const set = (val) => count.value = Math.max(min, Math.min(max, val));
|
|
837
903
|
const reset = (val = initialValue) => {
|
|
838
904
|
initialValue = val;
|
|
839
905
|
return set(val);
|
|
@@ -842,8 +908,15 @@ function useCounter(initialValue = 0, options = {}) {
|
|
|
842
908
|
}
|
|
843
909
|
|
|
844
910
|
const REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/;
|
|
845
|
-
const REGEX_FORMAT = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g;
|
|
846
|
-
const
|
|
911
|
+
const REGEX_FORMAT = /\[([^\]]+)]|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;
|
|
912
|
+
const defaultMeridiem = (hours, minutes, isLowercase, hasPeriod) => {
|
|
913
|
+
let m = hours < 12 ? "AM" : "PM";
|
|
914
|
+
if (hasPeriod)
|
|
915
|
+
m = m.split("").reduce((acc, curr) => acc += `${curr}.`, "");
|
|
916
|
+
return isLowercase ? m.toLowerCase() : m;
|
|
917
|
+
};
|
|
918
|
+
const formatDate = (date, formatStr, options = {}) => {
|
|
919
|
+
var _a;
|
|
847
920
|
const years = date.getFullYear();
|
|
848
921
|
const month = date.getMonth();
|
|
849
922
|
const days = date.getDate();
|
|
@@ -852,25 +925,35 @@ const formatDate = (date, formatStr) => {
|
|
|
852
925
|
const seconds = date.getSeconds();
|
|
853
926
|
const milliseconds = date.getMilliseconds();
|
|
854
927
|
const day = date.getDay();
|
|
928
|
+
const meridiem = (_a = options.customMeridiem) != null ? _a : defaultMeridiem;
|
|
855
929
|
const matches = {
|
|
856
|
-
YY: String(years).slice(-2),
|
|
857
|
-
YYYY: years,
|
|
858
|
-
M: month + 1,
|
|
859
|
-
MM: `${month + 1}`.padStart(2, "0"),
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
930
|
+
YY: () => String(years).slice(-2),
|
|
931
|
+
YYYY: () => years,
|
|
932
|
+
M: () => month + 1,
|
|
933
|
+
MM: () => `${month + 1}`.padStart(2, "0"),
|
|
934
|
+
MMM: () => date.toLocaleDateString(options.locales, { month: "short" }),
|
|
935
|
+
MMMM: () => date.toLocaleDateString(options.locales, { month: "long" }),
|
|
936
|
+
D: () => String(days),
|
|
937
|
+
DD: () => `${days}`.padStart(2, "0"),
|
|
938
|
+
H: () => String(hours),
|
|
939
|
+
HH: () => `${hours}`.padStart(2, "0"),
|
|
940
|
+
h: () => `${hours % 12 || 12}`.padStart(1, "0"),
|
|
941
|
+
hh: () => `${hours % 12 || 12}`.padStart(2, "0"),
|
|
942
|
+
m: () => String(minutes),
|
|
943
|
+
mm: () => `${minutes}`.padStart(2, "0"),
|
|
944
|
+
s: () => String(seconds),
|
|
945
|
+
ss: () => `${seconds}`.padStart(2, "0"),
|
|
946
|
+
SSS: () => `${milliseconds}`.padStart(3, "0"),
|
|
947
|
+
d: () => day,
|
|
948
|
+
dd: () => date.toLocaleDateString(options.locales, { weekday: "narrow" }),
|
|
949
|
+
ddd: () => date.toLocaleDateString(options.locales, { weekday: "short" }),
|
|
950
|
+
dddd: () => date.toLocaleDateString(options.locales, { weekday: "long" }),
|
|
951
|
+
A: () => meridiem(hours, minutes),
|
|
952
|
+
AA: () => meridiem(hours, minutes, false, true),
|
|
953
|
+
a: () => meridiem(hours, minutes, true),
|
|
954
|
+
aa: () => meridiem(hours, minutes, true, true)
|
|
955
|
+
};
|
|
956
|
+
return formatStr.replace(REGEX_FORMAT, (match, $1) => $1 || matches[match]());
|
|
874
957
|
};
|
|
875
958
|
const normalizeDate = (date) => {
|
|
876
959
|
if (date === null)
|
|
@@ -889,8 +972,8 @@ const normalizeDate = (date) => {
|
|
|
889
972
|
}
|
|
890
973
|
return new Date(date);
|
|
891
974
|
};
|
|
892
|
-
function useDateFormat(date, formatStr = "HH:mm:ss") {
|
|
893
|
-
return computed(() => formatDate(normalizeDate(
|
|
975
|
+
function useDateFormat(date, formatStr = "HH:mm:ss", options = {}) {
|
|
976
|
+
return computed(() => formatDate(normalizeDate(resolveUnref(date)), resolveUnref(formatStr), options));
|
|
894
977
|
}
|
|
895
978
|
|
|
896
979
|
function useIntervalFn(cb, interval = 1e3, options = {}) {
|
|
@@ -911,17 +994,18 @@ function useIntervalFn(cb, interval = 1e3, options = {}) {
|
|
|
911
994
|
clean();
|
|
912
995
|
}
|
|
913
996
|
function resume() {
|
|
914
|
-
|
|
997
|
+
const intervalValue = resolveUnref(interval);
|
|
998
|
+
if (intervalValue <= 0)
|
|
915
999
|
return;
|
|
916
1000
|
isActive.value = true;
|
|
917
1001
|
if (immediateCallback)
|
|
918
1002
|
cb();
|
|
919
1003
|
clean();
|
|
920
|
-
timer = setInterval(cb,
|
|
1004
|
+
timer = setInterval(cb, intervalValue);
|
|
921
1005
|
}
|
|
922
1006
|
if (immediate && isClient)
|
|
923
1007
|
resume();
|
|
924
|
-
if (isRef(interval)) {
|
|
1008
|
+
if (isRef(interval) || isFunction(interval)) {
|
|
925
1009
|
const stopWatch = watch(interval, () => {
|
|
926
1010
|
if (isActive.value && isClient)
|
|
927
1011
|
resume();
|
|
@@ -955,10 +1039,15 @@ var __spreadValues$6$1 = (a, b) => {
|
|
|
955
1039
|
function useInterval(interval = 1e3, options = {}) {
|
|
956
1040
|
const {
|
|
957
1041
|
controls: exposeControls = false,
|
|
958
|
-
immediate = true
|
|
1042
|
+
immediate = true,
|
|
1043
|
+
callback
|
|
959
1044
|
} = options;
|
|
960
1045
|
const counter = ref(0);
|
|
961
|
-
const
|
|
1046
|
+
const update = () => counter.value += 1;
|
|
1047
|
+
const controls = useIntervalFn(callback ? () => {
|
|
1048
|
+
update();
|
|
1049
|
+
callback(counter.value);
|
|
1050
|
+
} : update, interval, { immediate });
|
|
962
1051
|
if (exposeControls) {
|
|
963
1052
|
return __spreadValues$6$1({
|
|
964
1053
|
counter
|
|
@@ -998,7 +1087,7 @@ function useTimeoutFn(cb, interval, options = {}) {
|
|
|
998
1087
|
isPending.value = false;
|
|
999
1088
|
timer = null;
|
|
1000
1089
|
cb(...args);
|
|
1001
|
-
},
|
|
1090
|
+
}, resolveUnref(interval));
|
|
1002
1091
|
}
|
|
1003
1092
|
if (immediate) {
|
|
1004
1093
|
isPending.value = true;
|
|
@@ -1007,7 +1096,7 @@ function useTimeoutFn(cb, interval, options = {}) {
|
|
|
1007
1096
|
}
|
|
1008
1097
|
tryOnScopeDispose(stop);
|
|
1009
1098
|
return {
|
|
1010
|
-
isPending,
|
|
1099
|
+
isPending: readonly(isPending),
|
|
1011
1100
|
start,
|
|
1012
1101
|
stop
|
|
1013
1102
|
};
|
|
@@ -1031,9 +1120,10 @@ var __spreadValues$5$1 = (a, b) => {
|
|
|
1031
1120
|
};
|
|
1032
1121
|
function useTimeout(interval = 1e3, options = {}) {
|
|
1033
1122
|
const {
|
|
1034
|
-
controls: exposeControls = false
|
|
1123
|
+
controls: exposeControls = false,
|
|
1124
|
+
callback
|
|
1035
1125
|
} = options;
|
|
1036
|
-
const controls = useTimeoutFn(noop, interval, options);
|
|
1126
|
+
const controls = useTimeoutFn(callback != null ? callback : noop, interval, options);
|
|
1037
1127
|
const ready = computed(() => !controls.isPending.value);
|
|
1038
1128
|
if (exposeControls) {
|
|
1039
1129
|
return __spreadValues$5$1({
|
|
@@ -1044,26 +1134,47 @@ function useTimeout(interval = 1e3, options = {}) {
|
|
|
1044
1134
|
}
|
|
1045
1135
|
}
|
|
1046
1136
|
|
|
1137
|
+
function useToNumber(value, options = {}) {
|
|
1138
|
+
const {
|
|
1139
|
+
method = "parseFloat",
|
|
1140
|
+
radix,
|
|
1141
|
+
nanToZero
|
|
1142
|
+
} = options;
|
|
1143
|
+
return computed(() => {
|
|
1144
|
+
let resolved = resolveUnref(value);
|
|
1145
|
+
if (typeof resolved === "string")
|
|
1146
|
+
resolved = Number[method](resolved, radix);
|
|
1147
|
+
if (nanToZero && isNaN(resolved))
|
|
1148
|
+
resolved = 0;
|
|
1149
|
+
return resolved;
|
|
1150
|
+
});
|
|
1151
|
+
}
|
|
1152
|
+
|
|
1153
|
+
function useToString(value) {
|
|
1154
|
+
return computed(() => `${resolveUnref(value)}`);
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1047
1157
|
function useToggle(initialValue = false, options = {}) {
|
|
1048
1158
|
const {
|
|
1049
1159
|
truthyValue = true,
|
|
1050
1160
|
falsyValue = false
|
|
1051
1161
|
} = options;
|
|
1052
1162
|
const valueIsRef = isRef(initialValue);
|
|
1053
|
-
const
|
|
1163
|
+
const _value = ref(initialValue);
|
|
1054
1164
|
function toggle(value) {
|
|
1055
1165
|
if (arguments.length) {
|
|
1056
|
-
|
|
1057
|
-
return
|
|
1166
|
+
_value.value = value;
|
|
1167
|
+
return _value.value;
|
|
1058
1168
|
} else {
|
|
1059
|
-
|
|
1060
|
-
|
|
1169
|
+
const truthy = resolveUnref(truthyValue);
|
|
1170
|
+
_value.value = _value.value === truthy ? resolveUnref(falsyValue) : truthy;
|
|
1171
|
+
return _value.value;
|
|
1061
1172
|
}
|
|
1062
1173
|
}
|
|
1063
1174
|
if (valueIsRef)
|
|
1064
1175
|
return toggle;
|
|
1065
1176
|
else
|
|
1066
|
-
return [
|
|
1177
|
+
return [_value, toggle];
|
|
1067
1178
|
}
|
|
1068
1179
|
|
|
1069
1180
|
function watchArray(source, cb, options) {
|
|
@@ -1139,7 +1250,7 @@ function watchAtMost(source, cb, options) {
|
|
|
1139
1250
|
const current = ref(0);
|
|
1140
1251
|
const stop = watchWithFilter(source, (...args) => {
|
|
1141
1252
|
current.value += 1;
|
|
1142
|
-
if (current.value >=
|
|
1253
|
+
if (current.value >= resolveUnref(count))
|
|
1143
1254
|
nextTick(() => stop());
|
|
1144
1255
|
cb(...args);
|
|
1145
1256
|
}, watchOptions);
|
|
@@ -1371,25 +1482,25 @@ function watchThrottled(source, cb, options = {}) {
|
|
|
1371
1482
|
}));
|
|
1372
1483
|
}
|
|
1373
1484
|
|
|
1374
|
-
var __defProp$
|
|
1375
|
-
var __defProps$
|
|
1376
|
-
var __getOwnPropDescs$
|
|
1377
|
-
var __getOwnPropSymbols$
|
|
1378
|
-
var __hasOwnProp$
|
|
1379
|
-
var __propIsEnum$
|
|
1380
|
-
var __defNormalProp$
|
|
1381
|
-
var __spreadValues$
|
|
1485
|
+
var __defProp$n = Object.defineProperty;
|
|
1486
|
+
var __defProps$a = Object.defineProperties;
|
|
1487
|
+
var __getOwnPropDescs$a = Object.getOwnPropertyDescriptors;
|
|
1488
|
+
var __getOwnPropSymbols$p = Object.getOwnPropertySymbols;
|
|
1489
|
+
var __hasOwnProp$p = Object.prototype.hasOwnProperty;
|
|
1490
|
+
var __propIsEnum$p = Object.prototype.propertyIsEnumerable;
|
|
1491
|
+
var __defNormalProp$n = (obj, key, value) => key in obj ? __defProp$n(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1492
|
+
var __spreadValues$n = (a, b) => {
|
|
1382
1493
|
for (var prop in b || (b = {}))
|
|
1383
|
-
if (__hasOwnProp$
|
|
1384
|
-
__defNormalProp$
|
|
1385
|
-
if (__getOwnPropSymbols$
|
|
1386
|
-
for (var prop of __getOwnPropSymbols$
|
|
1387
|
-
if (__propIsEnum$
|
|
1388
|
-
__defNormalProp$
|
|
1494
|
+
if (__hasOwnProp$p.call(b, prop))
|
|
1495
|
+
__defNormalProp$n(a, prop, b[prop]);
|
|
1496
|
+
if (__getOwnPropSymbols$p)
|
|
1497
|
+
for (var prop of __getOwnPropSymbols$p(b)) {
|
|
1498
|
+
if (__propIsEnum$p.call(b, prop))
|
|
1499
|
+
__defNormalProp$n(a, prop, b[prop]);
|
|
1389
1500
|
}
|
|
1390
1501
|
return a;
|
|
1391
1502
|
};
|
|
1392
|
-
var __spreadProps$
|
|
1503
|
+
var __spreadProps$a = (a, b) => __defProps$a(a, __getOwnPropDescs$a(b));
|
|
1393
1504
|
function watchTriggerable(source, cb, options = {}) {
|
|
1394
1505
|
let cleanupFn;
|
|
1395
1506
|
function onEffect() {
|
|
@@ -1415,7 +1526,7 @@ function watchTriggerable(source, cb, options = {}) {
|
|
|
1415
1526
|
});
|
|
1416
1527
|
return res2;
|
|
1417
1528
|
};
|
|
1418
|
-
return __spreadProps$
|
|
1529
|
+
return __spreadProps$a(__spreadValues$n({}, res), {
|
|
1419
1530
|
trigger
|
|
1420
1531
|
});
|
|
1421
1532
|
}
|
|
@@ -1452,10 +1563,11 @@ function computedAsync(evaluationCallback, initialState, optionsOrRef) {
|
|
|
1452
1563
|
const {
|
|
1453
1564
|
lazy = false,
|
|
1454
1565
|
evaluating = void 0,
|
|
1566
|
+
shallow = false,
|
|
1455
1567
|
onError = noop
|
|
1456
1568
|
} = options;
|
|
1457
1569
|
const started = ref(!lazy);
|
|
1458
|
-
const current = ref(initialState);
|
|
1570
|
+
const current = shallow ? shallowRef(initialState) : ref(initialState);
|
|
1459
1571
|
let counter = 0;
|
|
1460
1572
|
watchEffect(async (onInvalidate) => {
|
|
1461
1573
|
if (!started.value)
|
|
@@ -1521,7 +1633,7 @@ const createUnrefFn = (fn) => {
|
|
|
1521
1633
|
|
|
1522
1634
|
function unrefElement(elRef) {
|
|
1523
1635
|
var _a;
|
|
1524
|
-
const plain =
|
|
1636
|
+
const plain = resolveUnref(elRef);
|
|
1525
1637
|
return (_a = plain == null ? void 0 : plain.$el) != null ? _a : plain;
|
|
1526
1638
|
}
|
|
1527
1639
|
|
|
@@ -1532,27 +1644,37 @@ const defaultLocation = isClient ? window.location : void 0;
|
|
|
1532
1644
|
|
|
1533
1645
|
function useEventListener(...args) {
|
|
1534
1646
|
let target;
|
|
1535
|
-
let
|
|
1536
|
-
let
|
|
1647
|
+
let events;
|
|
1648
|
+
let listeners;
|
|
1537
1649
|
let options;
|
|
1538
|
-
if (isString(args[0])) {
|
|
1539
|
-
[
|
|
1650
|
+
if (isString(args[0]) || Array.isArray(args[0])) {
|
|
1651
|
+
[events, listeners, options] = args;
|
|
1540
1652
|
target = defaultWindow;
|
|
1541
1653
|
} else {
|
|
1542
|
-
[target,
|
|
1654
|
+
[target, events, listeners, options] = args;
|
|
1543
1655
|
}
|
|
1544
1656
|
if (!target)
|
|
1545
1657
|
return noop;
|
|
1546
|
-
|
|
1658
|
+
if (!Array.isArray(events))
|
|
1659
|
+
events = [events];
|
|
1660
|
+
if (!Array.isArray(listeners))
|
|
1661
|
+
listeners = [listeners];
|
|
1662
|
+
const cleanups = [];
|
|
1663
|
+
const cleanup = () => {
|
|
1664
|
+
cleanups.forEach((fn) => fn());
|
|
1665
|
+
cleanups.length = 0;
|
|
1666
|
+
};
|
|
1667
|
+
const register = (el, event, listener) => {
|
|
1668
|
+
el.addEventListener(event, listener, options);
|
|
1669
|
+
return () => el.removeEventListener(event, listener, options);
|
|
1670
|
+
};
|
|
1547
1671
|
const stopWatch = watch(() => unrefElement(target), (el) => {
|
|
1548
1672
|
cleanup();
|
|
1549
1673
|
if (!el)
|
|
1550
1674
|
return;
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
cleanup = noop;
|
|
1555
|
-
};
|
|
1675
|
+
cleanups.push(...events.flatMap((event) => {
|
|
1676
|
+
return listeners.map((listener) => register(el, event, listener));
|
|
1677
|
+
}));
|
|
1556
1678
|
}, { immediate: true, flush: "post" });
|
|
1557
1679
|
const stop = () => {
|
|
1558
1680
|
stopWatch();
|
|
@@ -1563,23 +1685,31 @@ function useEventListener(...args) {
|
|
|
1563
1685
|
}
|
|
1564
1686
|
|
|
1565
1687
|
function onClickOutside(target, handler, options = {}) {
|
|
1566
|
-
const { window = defaultWindow, ignore, capture = true, detectIframe = false } = options;
|
|
1688
|
+
const { window = defaultWindow, ignore = [], capture = true, detectIframe = false } = options;
|
|
1567
1689
|
if (!window)
|
|
1568
1690
|
return;
|
|
1569
|
-
|
|
1691
|
+
let shouldListen = true;
|
|
1570
1692
|
let fallback;
|
|
1693
|
+
const shouldIgnore = (event) => {
|
|
1694
|
+
return ignore.some((target2) => {
|
|
1695
|
+
if (typeof target2 === "string") {
|
|
1696
|
+
return Array.from(window.document.querySelectorAll(target2)).some((el) => el === event.target || event.composedPath().includes(el));
|
|
1697
|
+
} else {
|
|
1698
|
+
const el = unrefElement(target2);
|
|
1699
|
+
return el && (event.target === el || event.composedPath().includes(el));
|
|
1700
|
+
}
|
|
1701
|
+
});
|
|
1702
|
+
};
|
|
1571
1703
|
const listener = (event) => {
|
|
1572
1704
|
window.clearTimeout(fallback);
|
|
1573
1705
|
const el = unrefElement(target);
|
|
1574
|
-
|
|
1575
|
-
|
|
1706
|
+
if (!el || el === event.target || event.composedPath().includes(el))
|
|
1707
|
+
return;
|
|
1708
|
+
if (event.detail === 0)
|
|
1709
|
+
shouldListen = !shouldIgnore(event);
|
|
1710
|
+
if (!shouldListen) {
|
|
1711
|
+
shouldListen = true;
|
|
1576
1712
|
return;
|
|
1577
|
-
if (ignore && ignore.length > 0) {
|
|
1578
|
-
if (ignore.some((target2) => {
|
|
1579
|
-
const el2 = unrefElement(target2);
|
|
1580
|
-
return el2 && (event.target === el2 || composedPath.includes(el2));
|
|
1581
|
-
}))
|
|
1582
|
-
return;
|
|
1583
1713
|
}
|
|
1584
1714
|
handler(event);
|
|
1585
1715
|
};
|
|
@@ -1587,7 +1717,8 @@ function onClickOutside(target, handler, options = {}) {
|
|
|
1587
1717
|
useEventListener(window, "click", listener, { passive: true, capture }),
|
|
1588
1718
|
useEventListener(window, "pointerdown", (e) => {
|
|
1589
1719
|
const el = unrefElement(target);
|
|
1590
|
-
|
|
1720
|
+
if (el)
|
|
1721
|
+
shouldListen = !e.composedPath().includes(el) && !shouldIgnore(e);
|
|
1591
1722
|
}, { passive: true }),
|
|
1592
1723
|
useEventListener(window, "pointerup", (e) => {
|
|
1593
1724
|
if (e.button === 0) {
|
|
@@ -1599,7 +1730,7 @@ function onClickOutside(target, handler, options = {}) {
|
|
|
1599
1730
|
detectIframe && useEventListener(window, "blur", (event) => {
|
|
1600
1731
|
var _a;
|
|
1601
1732
|
const el = unrefElement(target);
|
|
1602
|
-
if (((_a = document.activeElement) == null ? void 0 : _a.tagName) === "IFRAME" && !(el == null ? void 0 : el.contains(document.activeElement)))
|
|
1733
|
+
if (((_a = window.document.activeElement) == null ? void 0 : _a.tagName) === "IFRAME" && !(el == null ? void 0 : el.contains(window.document.activeElement)))
|
|
1603
1734
|
handler(event);
|
|
1604
1735
|
})
|
|
1605
1736
|
].filter(Boolean);
|
|
@@ -1607,25 +1738,25 @@ function onClickOutside(target, handler, options = {}) {
|
|
|
1607
1738
|
return stop;
|
|
1608
1739
|
}
|
|
1609
1740
|
|
|
1610
|
-
var __defProp$
|
|
1611
|
-
var __defProps$
|
|
1612
|
-
var __getOwnPropDescs$
|
|
1613
|
-
var __getOwnPropSymbols$
|
|
1614
|
-
var __hasOwnProp$
|
|
1615
|
-
var __propIsEnum$
|
|
1616
|
-
var __defNormalProp$
|
|
1617
|
-
var __spreadValues$
|
|
1741
|
+
var __defProp$m = Object.defineProperty;
|
|
1742
|
+
var __defProps$9 = Object.defineProperties;
|
|
1743
|
+
var __getOwnPropDescs$9 = Object.getOwnPropertyDescriptors;
|
|
1744
|
+
var __getOwnPropSymbols$o = Object.getOwnPropertySymbols;
|
|
1745
|
+
var __hasOwnProp$o = Object.prototype.hasOwnProperty;
|
|
1746
|
+
var __propIsEnum$o = Object.prototype.propertyIsEnumerable;
|
|
1747
|
+
var __defNormalProp$m = (obj, key, value) => key in obj ? __defProp$m(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1748
|
+
var __spreadValues$m = (a, b) => {
|
|
1618
1749
|
for (var prop in b || (b = {}))
|
|
1619
|
-
if (__hasOwnProp$
|
|
1620
|
-
__defNormalProp$
|
|
1621
|
-
if (__getOwnPropSymbols$
|
|
1622
|
-
for (var prop of __getOwnPropSymbols$
|
|
1623
|
-
if (__propIsEnum$
|
|
1624
|
-
__defNormalProp$
|
|
1750
|
+
if (__hasOwnProp$o.call(b, prop))
|
|
1751
|
+
__defNormalProp$m(a, prop, b[prop]);
|
|
1752
|
+
if (__getOwnPropSymbols$o)
|
|
1753
|
+
for (var prop of __getOwnPropSymbols$o(b)) {
|
|
1754
|
+
if (__propIsEnum$o.call(b, prop))
|
|
1755
|
+
__defNormalProp$m(a, prop, b[prop]);
|
|
1625
1756
|
}
|
|
1626
1757
|
return a;
|
|
1627
1758
|
};
|
|
1628
|
-
var __spreadProps$
|
|
1759
|
+
var __spreadProps$9 = (a, b) => __defProps$9(a, __getOwnPropDescs$9(b));
|
|
1629
1760
|
const createKeyPredicate = (keyFilter) => {
|
|
1630
1761
|
if (typeof keyFilter === "function")
|
|
1631
1762
|
return keyFilter;
|
|
@@ -1633,12 +1764,29 @@ const createKeyPredicate = (keyFilter) => {
|
|
|
1633
1764
|
return (event) => event.key === keyFilter;
|
|
1634
1765
|
else if (Array.isArray(keyFilter))
|
|
1635
1766
|
return (event) => keyFilter.includes(event.key);
|
|
1636
|
-
|
|
1637
|
-
return () => true;
|
|
1638
|
-
else
|
|
1639
|
-
return () => false;
|
|
1767
|
+
return () => true;
|
|
1640
1768
|
};
|
|
1641
|
-
function onKeyStroke(
|
|
1769
|
+
function onKeyStroke(...args) {
|
|
1770
|
+
let key;
|
|
1771
|
+
let handler;
|
|
1772
|
+
let options = {};
|
|
1773
|
+
if (args.length === 3) {
|
|
1774
|
+
key = args[0];
|
|
1775
|
+
handler = args[1];
|
|
1776
|
+
options = args[2];
|
|
1777
|
+
} else if (args.length === 2) {
|
|
1778
|
+
if (typeof args[1] === "object") {
|
|
1779
|
+
key = true;
|
|
1780
|
+
handler = args[0];
|
|
1781
|
+
options = args[1];
|
|
1782
|
+
} else {
|
|
1783
|
+
key = args[0];
|
|
1784
|
+
handler = args[1];
|
|
1785
|
+
}
|
|
1786
|
+
} else {
|
|
1787
|
+
key = true;
|
|
1788
|
+
handler = args[0];
|
|
1789
|
+
}
|
|
1642
1790
|
const { target = defaultWindow, eventName = "keydown", passive = false } = options;
|
|
1643
1791
|
const predicate = createKeyPredicate(key);
|
|
1644
1792
|
const listener = (e) => {
|
|
@@ -1648,24 +1796,24 @@ function onKeyStroke(key, handler, options = {}) {
|
|
|
1648
1796
|
return useEventListener(target, eventName, listener, passive);
|
|
1649
1797
|
}
|
|
1650
1798
|
function onKeyDown(key, handler, options = {}) {
|
|
1651
|
-
return onKeyStroke(key, handler, __spreadProps$
|
|
1799
|
+
return onKeyStroke(key, handler, __spreadProps$9(__spreadValues$m({}, options), { eventName: "keydown" }));
|
|
1652
1800
|
}
|
|
1653
1801
|
function onKeyPressed(key, handler, options = {}) {
|
|
1654
|
-
return onKeyStroke(key, handler, __spreadProps$
|
|
1802
|
+
return onKeyStroke(key, handler, __spreadProps$9(__spreadValues$m({}, options), { eventName: "keypress" }));
|
|
1655
1803
|
}
|
|
1656
1804
|
function onKeyUp(key, handler, options = {}) {
|
|
1657
|
-
return onKeyStroke(key, handler, __spreadProps$
|
|
1805
|
+
return onKeyStroke(key, handler, __spreadProps$9(__spreadValues$m({}, options), { eventName: "keyup" }));
|
|
1658
1806
|
}
|
|
1659
1807
|
|
|
1660
1808
|
const DEFAULT_DELAY = 500;
|
|
1661
1809
|
function onLongPress(target, handler, options) {
|
|
1662
1810
|
var _a, _b;
|
|
1663
1811
|
const elementRef = computed(() => unrefElement(target));
|
|
1664
|
-
let timeout
|
|
1812
|
+
let timeout;
|
|
1665
1813
|
function clear() {
|
|
1666
|
-
if (timeout
|
|
1814
|
+
if (timeout) {
|
|
1667
1815
|
clearTimeout(timeout);
|
|
1668
|
-
timeout =
|
|
1816
|
+
timeout = void 0;
|
|
1669
1817
|
}
|
|
1670
1818
|
}
|
|
1671
1819
|
function onDown(ev) {
|
|
@@ -1746,16 +1894,19 @@ function templateRef(key, initialValue = null) {
|
|
|
1746
1894
|
}
|
|
1747
1895
|
|
|
1748
1896
|
function useActiveElement(options = {}) {
|
|
1897
|
+
var _a;
|
|
1749
1898
|
const { window = defaultWindow } = options;
|
|
1750
|
-
const
|
|
1899
|
+
const document = (_a = options.document) != null ? _a : window == null ? void 0 : window.document;
|
|
1900
|
+
const activeElement = computedWithControl(() => null, () => document == null ? void 0 : document.activeElement);
|
|
1751
1901
|
if (window) {
|
|
1752
|
-
useEventListener(window, "blur", () =>
|
|
1753
|
-
|
|
1902
|
+
useEventListener(window, "blur", (event) => {
|
|
1903
|
+
if (event.relatedTarget !== null)
|
|
1904
|
+
return;
|
|
1905
|
+
activeElement.trigger();
|
|
1906
|
+
}, true);
|
|
1907
|
+
useEventListener(window, "focus", activeElement.trigger, true);
|
|
1754
1908
|
}
|
|
1755
|
-
return
|
|
1756
|
-
counter.value;
|
|
1757
|
-
return window == null ? void 0 : window.document.activeElement;
|
|
1758
|
-
});
|
|
1909
|
+
return activeElement;
|
|
1759
1910
|
}
|
|
1760
1911
|
|
|
1761
1912
|
function useAsyncQueue(tasks, options = {}) {
|
|
@@ -1813,8 +1964,10 @@ function useAsyncState(promise, initialState, options) {
|
|
|
1813
1964
|
immediate = true,
|
|
1814
1965
|
delay = 0,
|
|
1815
1966
|
onError = noop,
|
|
1967
|
+
onSuccess = noop,
|
|
1816
1968
|
resetOnExecute = true,
|
|
1817
|
-
shallow = true
|
|
1969
|
+
shallow = true,
|
|
1970
|
+
throwError
|
|
1818
1971
|
} = options != null ? options : {};
|
|
1819
1972
|
const state = shallow ? shallowRef(initialState) : ref(initialState);
|
|
1820
1973
|
const isReady = ref(false);
|
|
@@ -1833,9 +1986,12 @@ function useAsyncState(promise, initialState, options) {
|
|
|
1833
1986
|
const data = await _promise;
|
|
1834
1987
|
state.value = data;
|
|
1835
1988
|
isReady.value = true;
|
|
1989
|
+
onSuccess(data);
|
|
1836
1990
|
} catch (e) {
|
|
1837
1991
|
error.value = e;
|
|
1838
1992
|
onError(e);
|
|
1993
|
+
if (throwError)
|
|
1994
|
+
throw error;
|
|
1839
1995
|
} finally {
|
|
1840
1996
|
isLoading.value = false;
|
|
1841
1997
|
}
|
|
@@ -1880,7 +2036,7 @@ function useBase64(target, options) {
|
|
|
1880
2036
|
return;
|
|
1881
2037
|
promise.value = new Promise((resolve, reject) => {
|
|
1882
2038
|
try {
|
|
1883
|
-
const _target =
|
|
2039
|
+
const _target = resolveUnref(target);
|
|
1884
2040
|
if (_target == null) {
|
|
1885
2041
|
resolve("");
|
|
1886
2042
|
} else if (typeof _target === "string") {
|
|
@@ -1916,7 +2072,7 @@ function useBase64(target, options) {
|
|
|
1916
2072
|
promise.value.then((res) => base64.value = res);
|
|
1917
2073
|
return promise.value;
|
|
1918
2074
|
}
|
|
1919
|
-
if (isRef(target))
|
|
2075
|
+
if (isRef(target) || isFunction(target))
|
|
1920
2076
|
watch(target, execute, { immediate: true });
|
|
1921
2077
|
else
|
|
1922
2078
|
execute();
|
|
@@ -1949,9 +2105,17 @@ function blobToBase64(blob) {
|
|
|
1949
2105
|
});
|
|
1950
2106
|
}
|
|
1951
2107
|
|
|
2108
|
+
function useSupported(callback, sync = false) {
|
|
2109
|
+
const isSupported = ref();
|
|
2110
|
+
const update = () => isSupported.value = Boolean(callback());
|
|
2111
|
+
update();
|
|
2112
|
+
tryOnMounted(update, sync);
|
|
2113
|
+
return isSupported;
|
|
2114
|
+
}
|
|
2115
|
+
|
|
1952
2116
|
function useBattery({ navigator = defaultNavigator } = {}) {
|
|
1953
2117
|
const events = ["chargingchange", "chargingtimechange", "dischargingtimechange", "levelchange"];
|
|
1954
|
-
const isSupported = navigator && "getBattery" in navigator;
|
|
2118
|
+
const isSupported = useSupported(() => navigator && "getBattery" in navigator);
|
|
1955
2119
|
const charging = ref(false);
|
|
1956
2120
|
const chargingTime = ref(0);
|
|
1957
2121
|
const dischargingTime = ref(0);
|
|
@@ -1963,7 +2127,7 @@ function useBattery({ navigator = defaultNavigator } = {}) {
|
|
|
1963
2127
|
dischargingTime.value = this.dischargingTime || 0;
|
|
1964
2128
|
level.value = this.level;
|
|
1965
2129
|
}
|
|
1966
|
-
if (isSupported) {
|
|
2130
|
+
if (isSupported.value) {
|
|
1967
2131
|
navigator.getBattery().then((_battery) => {
|
|
1968
2132
|
battery = _battery;
|
|
1969
2133
|
updateBatteryInfo.call(battery);
|
|
@@ -1989,14 +2153,14 @@ function useBluetooth(options) {
|
|
|
1989
2153
|
optionalServices = void 0,
|
|
1990
2154
|
navigator = defaultNavigator
|
|
1991
2155
|
} = options || {};
|
|
1992
|
-
const isSupported = navigator && "bluetooth" in navigator;
|
|
1993
|
-
const device =
|
|
1994
|
-
const error =
|
|
2156
|
+
const isSupported = useSupported(() => navigator && "bluetooth" in navigator);
|
|
2157
|
+
const device = shallowRef(void 0);
|
|
2158
|
+
const error = shallowRef(null);
|
|
1995
2159
|
watch(device, () => {
|
|
1996
2160
|
connectToBluetoothGATTServer();
|
|
1997
2161
|
});
|
|
1998
2162
|
async function requestDevice() {
|
|
1999
|
-
if (!isSupported)
|
|
2163
|
+
if (!isSupported.value)
|
|
2000
2164
|
return;
|
|
2001
2165
|
error.value = null;
|
|
2002
2166
|
if (filters && filters.length > 0)
|
|
@@ -2050,31 +2214,30 @@ function useBluetooth(options) {
|
|
|
2050
2214
|
|
|
2051
2215
|
function useMediaQuery(query, options = {}) {
|
|
2052
2216
|
const { window = defaultWindow } = options;
|
|
2053
|
-
const isSupported =
|
|
2217
|
+
const isSupported = useSupported(() => window && "matchMedia" in window && typeof window.matchMedia === "function");
|
|
2054
2218
|
let mediaQuery;
|
|
2055
2219
|
const matches = ref(false);
|
|
2056
|
-
const
|
|
2057
|
-
if (!isSupported)
|
|
2058
|
-
return;
|
|
2220
|
+
const cleanup = () => {
|
|
2059
2221
|
if (!mediaQuery)
|
|
2060
|
-
|
|
2061
|
-
|
|
2222
|
+
return;
|
|
2223
|
+
if ("removeEventListener" in mediaQuery)
|
|
2224
|
+
mediaQuery.removeEventListener("change", update);
|
|
2225
|
+
else
|
|
2226
|
+
mediaQuery.removeListener(update);
|
|
2062
2227
|
};
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
if (!mediaQuery)
|
|
2228
|
+
const update = () => {
|
|
2229
|
+
if (!isSupported.value)
|
|
2066
2230
|
return;
|
|
2231
|
+
cleanup();
|
|
2232
|
+
mediaQuery = window.matchMedia(resolveRef(query).value);
|
|
2233
|
+
matches.value = mediaQuery.matches;
|
|
2067
2234
|
if ("addEventListener" in mediaQuery)
|
|
2068
2235
|
mediaQuery.addEventListener("change", update);
|
|
2069
2236
|
else
|
|
2070
2237
|
mediaQuery.addListener(update);
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
else
|
|
2075
|
-
mediaQuery.removeListener(update);
|
|
2076
|
-
});
|
|
2077
|
-
});
|
|
2238
|
+
};
|
|
2239
|
+
watchEffect(update);
|
|
2240
|
+
tryOnScopeDispose(() => cleanup());
|
|
2078
2241
|
return matches;
|
|
2079
2242
|
}
|
|
2080
2243
|
|
|
@@ -2121,20 +2284,32 @@ const breakpointsSematic = {
|
|
|
2121
2284
|
laptopL: 1440,
|
|
2122
2285
|
desktop4K: 2560
|
|
2123
2286
|
};
|
|
2287
|
+
const breakpointsMasterCss = {
|
|
2288
|
+
"3xs": 360,
|
|
2289
|
+
"2xs": 480,
|
|
2290
|
+
"xs": 600,
|
|
2291
|
+
"sm": 768,
|
|
2292
|
+
"md": 1024,
|
|
2293
|
+
"lg": 1280,
|
|
2294
|
+
"xl": 1440,
|
|
2295
|
+
"2xl": 1600,
|
|
2296
|
+
"3xl": 1920,
|
|
2297
|
+
"4xl": 2560
|
|
2298
|
+
};
|
|
2124
2299
|
|
|
2125
|
-
var __defProp$
|
|
2126
|
-
var __getOwnPropSymbols$
|
|
2127
|
-
var __hasOwnProp$
|
|
2128
|
-
var __propIsEnum$
|
|
2129
|
-
var __defNormalProp$
|
|
2130
|
-
var __spreadValues$
|
|
2300
|
+
var __defProp$l = Object.defineProperty;
|
|
2301
|
+
var __getOwnPropSymbols$n = Object.getOwnPropertySymbols;
|
|
2302
|
+
var __hasOwnProp$n = Object.prototype.hasOwnProperty;
|
|
2303
|
+
var __propIsEnum$n = Object.prototype.propertyIsEnumerable;
|
|
2304
|
+
var __defNormalProp$l = (obj, key, value) => key in obj ? __defProp$l(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2305
|
+
var __spreadValues$l = (a, b) => {
|
|
2131
2306
|
for (var prop in b || (b = {}))
|
|
2132
|
-
if (__hasOwnProp$
|
|
2133
|
-
__defNormalProp$
|
|
2134
|
-
if (__getOwnPropSymbols$
|
|
2135
|
-
for (var prop of __getOwnPropSymbols$
|
|
2136
|
-
if (__propIsEnum$
|
|
2137
|
-
__defNormalProp$
|
|
2307
|
+
if (__hasOwnProp$n.call(b, prop))
|
|
2308
|
+
__defNormalProp$l(a, prop, b[prop]);
|
|
2309
|
+
if (__getOwnPropSymbols$n)
|
|
2310
|
+
for (var prop of __getOwnPropSymbols$n(b)) {
|
|
2311
|
+
if (__propIsEnum$n.call(b, prop))
|
|
2312
|
+
__defNormalProp$l(a, prop, b[prop]);
|
|
2138
2313
|
}
|
|
2139
2314
|
return a;
|
|
2140
2315
|
};
|
|
@@ -2153,31 +2328,43 @@ function useBreakpoints(breakpoints, options = {}) {
|
|
|
2153
2328
|
return false;
|
|
2154
2329
|
return window.matchMedia(query).matches;
|
|
2155
2330
|
}
|
|
2156
|
-
const
|
|
2331
|
+
const greaterOrEqual = (k) => {
|
|
2157
2332
|
return useMediaQuery(`(min-width: ${getValue(k)})`, options);
|
|
2158
2333
|
};
|
|
2159
2334
|
const shortcutMethods = Object.keys(breakpoints).reduce((shortcuts, k) => {
|
|
2160
2335
|
Object.defineProperty(shortcuts, k, {
|
|
2161
|
-
get: () =>
|
|
2336
|
+
get: () => greaterOrEqual(k),
|
|
2162
2337
|
enumerable: true,
|
|
2163
2338
|
configurable: true
|
|
2164
2339
|
});
|
|
2165
2340
|
return shortcuts;
|
|
2166
2341
|
}, {});
|
|
2167
|
-
return __spreadValues$
|
|
2168
|
-
greater
|
|
2342
|
+
return __spreadValues$l({
|
|
2343
|
+
greater(k) {
|
|
2344
|
+
return useMediaQuery(`(min-width: ${getValue(k, 0.1)})`, options);
|
|
2345
|
+
},
|
|
2346
|
+
greaterOrEqual,
|
|
2169
2347
|
smaller(k) {
|
|
2170
2348
|
return useMediaQuery(`(max-width: ${getValue(k, -0.1)})`, options);
|
|
2171
2349
|
},
|
|
2350
|
+
smallerOrEqual(k) {
|
|
2351
|
+
return useMediaQuery(`(max-width: ${getValue(k)})`, options);
|
|
2352
|
+
},
|
|
2172
2353
|
between(a, b) {
|
|
2173
2354
|
return useMediaQuery(`(min-width: ${getValue(a)}) and (max-width: ${getValue(b, -0.1)})`, options);
|
|
2174
2355
|
},
|
|
2175
2356
|
isGreater(k) {
|
|
2357
|
+
return match(`(min-width: ${getValue(k, 0.1)})`);
|
|
2358
|
+
},
|
|
2359
|
+
isGreaterOrEqual(k) {
|
|
2176
2360
|
return match(`(min-width: ${getValue(k)})`);
|
|
2177
2361
|
},
|
|
2178
2362
|
isSmaller(k) {
|
|
2179
2363
|
return match(`(max-width: ${getValue(k, -0.1)})`);
|
|
2180
2364
|
},
|
|
2365
|
+
isSmallerOrEqual(k) {
|
|
2366
|
+
return match(`(max-width: ${getValue(k)})`);
|
|
2367
|
+
},
|
|
2181
2368
|
isInBetween(a, b) {
|
|
2182
2369
|
return match(`(min-width: ${getValue(a)}) and (max-width: ${getValue(b, -0.1)})`);
|
|
2183
2370
|
}
|
|
@@ -2189,7 +2376,7 @@ const useBroadcastChannel = (options) => {
|
|
|
2189
2376
|
name,
|
|
2190
2377
|
window = defaultWindow
|
|
2191
2378
|
} = options;
|
|
2192
|
-
const isSupported = window && "BroadcastChannel" in window;
|
|
2379
|
+
const isSupported = useSupported(() => window && "BroadcastChannel" in window);
|
|
2193
2380
|
const isClosed = ref(false);
|
|
2194
2381
|
const channel = ref();
|
|
2195
2382
|
const data = ref();
|
|
@@ -2203,7 +2390,7 @@ const useBroadcastChannel = (options) => {
|
|
|
2203
2390
|
channel.value.close();
|
|
2204
2391
|
isClosed.value = true;
|
|
2205
2392
|
};
|
|
2206
|
-
if (isSupported) {
|
|
2393
|
+
if (isSupported.value) {
|
|
2207
2394
|
tryOnMounted(() => {
|
|
2208
2395
|
error.value = null;
|
|
2209
2396
|
channel.value = new BroadcastChannel(name);
|
|
@@ -2268,47 +2455,58 @@ function useCached(refValue, comparator = (a, b) => a === b, watchOptions) {
|
|
|
2268
2455
|
return cachedValue;
|
|
2269
2456
|
}
|
|
2270
2457
|
|
|
2271
|
-
function useClamp(value, min, max) {
|
|
2272
|
-
const _value = ref(value);
|
|
2273
|
-
return computed({
|
|
2274
|
-
get() {
|
|
2275
|
-
return _value.value = clamp(_value.value, unref(min), unref(max));
|
|
2276
|
-
},
|
|
2277
|
-
set(value2) {
|
|
2278
|
-
_value.value = clamp(value2, unref(min), unref(max));
|
|
2279
|
-
}
|
|
2280
|
-
});
|
|
2281
|
-
}
|
|
2282
|
-
|
|
2283
2458
|
function useClipboard(options = {}) {
|
|
2284
2459
|
const {
|
|
2285
2460
|
navigator = defaultNavigator,
|
|
2286
2461
|
read = false,
|
|
2287
2462
|
source,
|
|
2288
|
-
copiedDuring = 1500
|
|
2463
|
+
copiedDuring = 1500,
|
|
2464
|
+
legacy = false
|
|
2289
2465
|
} = options;
|
|
2290
2466
|
const events = ["copy", "cut"];
|
|
2291
|
-
const
|
|
2467
|
+
const isClipboardApiSupported = useSupported(() => navigator && "clipboard" in navigator);
|
|
2468
|
+
const isSupported = computed(() => isClipboardApiSupported.value || legacy);
|
|
2292
2469
|
const text = ref("");
|
|
2293
2470
|
const copied = ref(false);
|
|
2294
2471
|
const timeout = useTimeoutFn(() => copied.value = false, copiedDuring);
|
|
2295
2472
|
function updateText() {
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2473
|
+
if (isClipboardApiSupported.value) {
|
|
2474
|
+
navigator.clipboard.readText().then((value) => {
|
|
2475
|
+
text.value = value;
|
|
2476
|
+
});
|
|
2477
|
+
} else {
|
|
2478
|
+
text.value = legacyRead();
|
|
2479
|
+
}
|
|
2299
2480
|
}
|
|
2300
|
-
if (isSupported && read) {
|
|
2481
|
+
if (isSupported.value && read) {
|
|
2301
2482
|
for (const event of events)
|
|
2302
2483
|
useEventListener(event, updateText);
|
|
2303
2484
|
}
|
|
2304
|
-
async function copy(value =
|
|
2305
|
-
if (isSupported && value != null) {
|
|
2306
|
-
|
|
2485
|
+
async function copy(value = resolveUnref(source)) {
|
|
2486
|
+
if (isSupported.value && value != null) {
|
|
2487
|
+
if (isClipboardApiSupported.value)
|
|
2488
|
+
await navigator.clipboard.writeText(value);
|
|
2489
|
+
else
|
|
2490
|
+
legacyCopy(value);
|
|
2307
2491
|
text.value = value;
|
|
2308
2492
|
copied.value = true;
|
|
2309
2493
|
timeout.start();
|
|
2310
2494
|
}
|
|
2311
2495
|
}
|
|
2496
|
+
function legacyCopy(value) {
|
|
2497
|
+
const ta = document.createElement("textarea");
|
|
2498
|
+
ta.value = value != null ? value : "";
|
|
2499
|
+
ta.style.position = "absolute";
|
|
2500
|
+
ta.style.opacity = "0";
|
|
2501
|
+
document.body.appendChild(ta);
|
|
2502
|
+
ta.select();
|
|
2503
|
+
document.execCommand("copy");
|
|
2504
|
+
ta.remove();
|
|
2505
|
+
}
|
|
2506
|
+
function legacyRead() {
|
|
2507
|
+
var _a, _b, _c;
|
|
2508
|
+
return (_c = (_b = (_a = document == null ? void 0 : document.getSelection) == null ? void 0 : _a.call(document)) == null ? void 0 : _b.toString()) != null ? _c : "";
|
|
2509
|
+
}
|
|
2312
2510
|
return {
|
|
2313
2511
|
isSupported,
|
|
2314
2512
|
text,
|
|
@@ -2317,6 +2515,50 @@ function useClipboard(options = {}) {
|
|
|
2317
2515
|
};
|
|
2318
2516
|
}
|
|
2319
2517
|
|
|
2518
|
+
var __defProp$k = Object.defineProperty;
|
|
2519
|
+
var __defProps$8 = Object.defineProperties;
|
|
2520
|
+
var __getOwnPropDescs$8 = Object.getOwnPropertyDescriptors;
|
|
2521
|
+
var __getOwnPropSymbols$m = Object.getOwnPropertySymbols;
|
|
2522
|
+
var __hasOwnProp$m = Object.prototype.hasOwnProperty;
|
|
2523
|
+
var __propIsEnum$m = Object.prototype.propertyIsEnumerable;
|
|
2524
|
+
var __defNormalProp$k = (obj, key, value) => key in obj ? __defProp$k(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2525
|
+
var __spreadValues$k = (a, b) => {
|
|
2526
|
+
for (var prop in b || (b = {}))
|
|
2527
|
+
if (__hasOwnProp$m.call(b, prop))
|
|
2528
|
+
__defNormalProp$k(a, prop, b[prop]);
|
|
2529
|
+
if (__getOwnPropSymbols$m)
|
|
2530
|
+
for (var prop of __getOwnPropSymbols$m(b)) {
|
|
2531
|
+
if (__propIsEnum$m.call(b, prop))
|
|
2532
|
+
__defNormalProp$k(a, prop, b[prop]);
|
|
2533
|
+
}
|
|
2534
|
+
return a;
|
|
2535
|
+
};
|
|
2536
|
+
var __spreadProps$8 = (a, b) => __defProps$8(a, __getOwnPropDescs$8(b));
|
|
2537
|
+
function cloneFnJSON(source) {
|
|
2538
|
+
return JSON.parse(JSON.stringify(source));
|
|
2539
|
+
}
|
|
2540
|
+
function useCloned(source, options = {}) {
|
|
2541
|
+
const cloned = ref({});
|
|
2542
|
+
const {
|
|
2543
|
+
manual,
|
|
2544
|
+
clone = cloneFnJSON,
|
|
2545
|
+
deep = true,
|
|
2546
|
+
immediate = true
|
|
2547
|
+
} = options;
|
|
2548
|
+
function sync() {
|
|
2549
|
+
cloned.value = clone(unref(source));
|
|
2550
|
+
}
|
|
2551
|
+
if (!manual && isRef(source)) {
|
|
2552
|
+
watch(source, sync, __spreadProps$8(__spreadValues$k({}, options), {
|
|
2553
|
+
deep,
|
|
2554
|
+
immediate
|
|
2555
|
+
}));
|
|
2556
|
+
} else {
|
|
2557
|
+
sync();
|
|
2558
|
+
}
|
|
2559
|
+
return { cloned, sync };
|
|
2560
|
+
}
|
|
2561
|
+
|
|
2320
2562
|
const _global = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
2321
2563
|
const globalKey = "__vueuse_ssr_handlers__";
|
|
2322
2564
|
_global[globalKey] = _global[globalKey] || {};
|
|
@@ -2329,24 +2571,40 @@ function setSSRHandler(key, fn) {
|
|
|
2329
2571
|
}
|
|
2330
2572
|
|
|
2331
2573
|
function guessSerializerType(rawInit) {
|
|
2332
|
-
return rawInit == null ? "any" : rawInit instanceof Set ? "set" : rawInit instanceof Map ? "map" : rawInit instanceof Date ? "date" : typeof rawInit === "boolean" ? "boolean" : typeof rawInit === "string" ? "string" : typeof rawInit === "object" ? "object" :
|
|
2574
|
+
return rawInit == null ? "any" : rawInit instanceof Set ? "set" : rawInit instanceof Map ? "map" : rawInit instanceof Date ? "date" : typeof rawInit === "boolean" ? "boolean" : typeof rawInit === "string" ? "string" : typeof rawInit === "object" ? "object" : !Number.isNaN(rawInit) ? "number" : "any";
|
|
2333
2575
|
}
|
|
2334
2576
|
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2577
|
+
var __defProp$j = Object.defineProperty;
|
|
2578
|
+
var __getOwnPropSymbols$l = Object.getOwnPropertySymbols;
|
|
2579
|
+
var __hasOwnProp$l = Object.prototype.hasOwnProperty;
|
|
2580
|
+
var __propIsEnum$l = Object.prototype.propertyIsEnumerable;
|
|
2581
|
+
var __defNormalProp$j = (obj, key, value) => key in obj ? __defProp$j(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2582
|
+
var __spreadValues$j = (a, b) => {
|
|
2583
|
+
for (var prop in b || (b = {}))
|
|
2584
|
+
if (__hasOwnProp$l.call(b, prop))
|
|
2585
|
+
__defNormalProp$j(a, prop, b[prop]);
|
|
2586
|
+
if (__getOwnPropSymbols$l)
|
|
2587
|
+
for (var prop of __getOwnPropSymbols$l(b)) {
|
|
2588
|
+
if (__propIsEnum$l.call(b, prop))
|
|
2589
|
+
__defNormalProp$j(a, prop, b[prop]);
|
|
2590
|
+
}
|
|
2591
|
+
return a;
|
|
2592
|
+
};
|
|
2593
|
+
const StorageSerializers = {
|
|
2594
|
+
boolean: {
|
|
2595
|
+
read: (v) => v === "true",
|
|
2596
|
+
write: (v) => String(v)
|
|
2597
|
+
},
|
|
2598
|
+
object: {
|
|
2599
|
+
read: (v) => JSON.parse(v),
|
|
2600
|
+
write: (v) => JSON.stringify(v)
|
|
2601
|
+
},
|
|
2602
|
+
number: {
|
|
2603
|
+
read: (v) => Number.parseFloat(v),
|
|
2604
|
+
write: (v) => String(v)
|
|
2605
|
+
},
|
|
2606
|
+
any: {
|
|
2607
|
+
read: (v) => v,
|
|
2350
2608
|
write: (v) => String(v)
|
|
2351
2609
|
},
|
|
2352
2610
|
string: {
|
|
@@ -2366,13 +2624,14 @@ const StorageSerializers = {
|
|
|
2366
2624
|
write: (v) => v.toISOString()
|
|
2367
2625
|
}
|
|
2368
2626
|
};
|
|
2369
|
-
function useStorage(key,
|
|
2627
|
+
function useStorage(key, defaults, storage, options = {}) {
|
|
2370
2628
|
var _a;
|
|
2371
2629
|
const {
|
|
2372
2630
|
flush = "pre",
|
|
2373
2631
|
deep = true,
|
|
2374
2632
|
listenToStorageChanges = true,
|
|
2375
2633
|
writeDefaults = true,
|
|
2634
|
+
mergeDefaults = false,
|
|
2376
2635
|
shallow,
|
|
2377
2636
|
window = defaultWindow,
|
|
2378
2637
|
eventFilter,
|
|
@@ -2380,7 +2639,7 @@ function useStorage(key, initialValue, storage, options = {}) {
|
|
|
2380
2639
|
console.error(e);
|
|
2381
2640
|
}
|
|
2382
2641
|
} = options;
|
|
2383
|
-
const data = (shallow ? shallowRef : ref)(
|
|
2642
|
+
const data = (shallow ? shallowRef : ref)(defaults);
|
|
2384
2643
|
if (!storage) {
|
|
2385
2644
|
try {
|
|
2386
2645
|
storage = getSSRHandler("getDefaultStorage", () => {
|
|
@@ -2393,7 +2652,7 @@ function useStorage(key, initialValue, storage, options = {}) {
|
|
|
2393
2652
|
}
|
|
2394
2653
|
if (!storage)
|
|
2395
2654
|
return data;
|
|
2396
|
-
const rawInit =
|
|
2655
|
+
const rawInit = resolveUnref(defaults);
|
|
2397
2656
|
const type = guessSerializerType(rawInit);
|
|
2398
2657
|
const serializer = (_a = options.serializer) != null ? _a : StorageSerializers[type];
|
|
2399
2658
|
const { pause: pauseWatch, resume: resumeWatch } = watchPausable(data, () => write(data.value), { flush, deep, eventFilter });
|
|
@@ -2403,59 +2662,86 @@ function useStorage(key, initialValue, storage, options = {}) {
|
|
|
2403
2662
|
return data;
|
|
2404
2663
|
function write(v) {
|
|
2405
2664
|
try {
|
|
2406
|
-
if (v == null)
|
|
2665
|
+
if (v == null) {
|
|
2407
2666
|
storage.removeItem(key);
|
|
2408
|
-
else
|
|
2409
|
-
|
|
2667
|
+
} else {
|
|
2668
|
+
const serialized = serializer.write(v);
|
|
2669
|
+
const oldValue = storage.getItem(key);
|
|
2670
|
+
if (oldValue !== serialized) {
|
|
2671
|
+
storage.setItem(key, serialized);
|
|
2672
|
+
if (window) {
|
|
2673
|
+
window == null ? void 0 : window.dispatchEvent(new StorageEvent("storage", {
|
|
2674
|
+
key,
|
|
2675
|
+
oldValue,
|
|
2676
|
+
newValue: serialized,
|
|
2677
|
+
storageArea: storage
|
|
2678
|
+
}));
|
|
2679
|
+
}
|
|
2680
|
+
}
|
|
2681
|
+
}
|
|
2410
2682
|
} catch (e) {
|
|
2411
2683
|
onError(e);
|
|
2412
2684
|
}
|
|
2413
2685
|
}
|
|
2414
2686
|
function read(event) {
|
|
2687
|
+
const rawValue = event ? event.newValue : storage.getItem(key);
|
|
2688
|
+
if (rawValue == null) {
|
|
2689
|
+
if (writeDefaults && rawInit !== null)
|
|
2690
|
+
storage.setItem(key, serializer.write(rawInit));
|
|
2691
|
+
return rawInit;
|
|
2692
|
+
} else if (!event && mergeDefaults) {
|
|
2693
|
+
const value = serializer.read(rawValue);
|
|
2694
|
+
if (isFunction(mergeDefaults))
|
|
2695
|
+
return mergeDefaults(value, rawInit);
|
|
2696
|
+
else if (type === "object" && !Array.isArray(value))
|
|
2697
|
+
return __spreadValues$j(__spreadValues$j({}, rawInit), value);
|
|
2698
|
+
return value;
|
|
2699
|
+
} else if (typeof rawValue !== "string") {
|
|
2700
|
+
return rawValue;
|
|
2701
|
+
} else {
|
|
2702
|
+
return serializer.read(rawValue);
|
|
2703
|
+
}
|
|
2704
|
+
}
|
|
2705
|
+
function update(event) {
|
|
2706
|
+
if (event && event.storageArea !== storage)
|
|
2707
|
+
return;
|
|
2708
|
+
if (event && event.key == null) {
|
|
2709
|
+
data.value = rawInit;
|
|
2710
|
+
return;
|
|
2711
|
+
}
|
|
2415
2712
|
if (event && event.key !== key)
|
|
2416
2713
|
return;
|
|
2417
2714
|
pauseWatch();
|
|
2418
2715
|
try {
|
|
2419
|
-
|
|
2420
|
-
if (rawValue == null) {
|
|
2421
|
-
if (writeDefaults && rawInit !== null)
|
|
2422
|
-
storage.setItem(key, serializer.write(rawInit));
|
|
2423
|
-
return rawInit;
|
|
2424
|
-
} else if (typeof rawValue !== "string") {
|
|
2425
|
-
return rawValue;
|
|
2426
|
-
} else {
|
|
2427
|
-
return serializer.read(rawValue);
|
|
2428
|
-
}
|
|
2716
|
+
data.value = read(event);
|
|
2429
2717
|
} catch (e) {
|
|
2430
2718
|
onError(e);
|
|
2431
2719
|
} finally {
|
|
2432
|
-
|
|
2720
|
+
if (event)
|
|
2721
|
+
nextTick(resumeWatch);
|
|
2722
|
+
else
|
|
2723
|
+
resumeWatch();
|
|
2433
2724
|
}
|
|
2434
2725
|
}
|
|
2435
|
-
function update(event) {
|
|
2436
|
-
if (event && event.key !== key)
|
|
2437
|
-
return;
|
|
2438
|
-
data.value = read(event);
|
|
2439
|
-
}
|
|
2440
2726
|
}
|
|
2441
2727
|
|
|
2442
2728
|
function usePreferredDark(options) {
|
|
2443
2729
|
return useMediaQuery("(prefers-color-scheme: dark)", options);
|
|
2444
2730
|
}
|
|
2445
2731
|
|
|
2446
|
-
var __defProp$
|
|
2447
|
-
var __getOwnPropSymbols$
|
|
2448
|
-
var __hasOwnProp$
|
|
2449
|
-
var __propIsEnum$
|
|
2450
|
-
var __defNormalProp$
|
|
2451
|
-
var __spreadValues$
|
|
2732
|
+
var __defProp$i = Object.defineProperty;
|
|
2733
|
+
var __getOwnPropSymbols$k = Object.getOwnPropertySymbols;
|
|
2734
|
+
var __hasOwnProp$k = Object.prototype.hasOwnProperty;
|
|
2735
|
+
var __propIsEnum$k = Object.prototype.propertyIsEnumerable;
|
|
2736
|
+
var __defNormalProp$i = (obj, key, value) => key in obj ? __defProp$i(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2737
|
+
var __spreadValues$i = (a, b) => {
|
|
2452
2738
|
for (var prop in b || (b = {}))
|
|
2453
|
-
if (__hasOwnProp$
|
|
2454
|
-
__defNormalProp$
|
|
2455
|
-
if (__getOwnPropSymbols$
|
|
2456
|
-
for (var prop of __getOwnPropSymbols$
|
|
2457
|
-
if (__propIsEnum$
|
|
2458
|
-
__defNormalProp$
|
|
2739
|
+
if (__hasOwnProp$k.call(b, prop))
|
|
2740
|
+
__defNormalProp$i(a, prop, b[prop]);
|
|
2741
|
+
if (__getOwnPropSymbols$k)
|
|
2742
|
+
for (var prop of __getOwnPropSymbols$k(b)) {
|
|
2743
|
+
if (__propIsEnum$k.call(b, prop))
|
|
2744
|
+
__defNormalProp$i(a, prop, b[prop]);
|
|
2459
2745
|
}
|
|
2460
2746
|
return a;
|
|
2461
2747
|
};
|
|
@@ -2463,6 +2749,7 @@ function useColorMode(options = {}) {
|
|
|
2463
2749
|
const {
|
|
2464
2750
|
selector = "html",
|
|
2465
2751
|
attribute = "class",
|
|
2752
|
+
initialValue = "auto",
|
|
2466
2753
|
window = defaultWindow,
|
|
2467
2754
|
storage,
|
|
2468
2755
|
storageKey = "vueuse-color-scheme",
|
|
@@ -2470,14 +2757,14 @@ function useColorMode(options = {}) {
|
|
|
2470
2757
|
storageRef,
|
|
2471
2758
|
emitAuto
|
|
2472
2759
|
} = options;
|
|
2473
|
-
const modes = __spreadValues$
|
|
2760
|
+
const modes = __spreadValues$i({
|
|
2474
2761
|
auto: "",
|
|
2475
2762
|
light: "light",
|
|
2476
2763
|
dark: "dark"
|
|
2477
2764
|
}, options.modes || {});
|
|
2478
2765
|
const preferredDark = usePreferredDark({ window });
|
|
2479
2766
|
const preferredMode = computed(() => preferredDark.value ? "dark" : "light");
|
|
2480
|
-
const store = storageRef || (storageKey == null ? ref(
|
|
2767
|
+
const store = storageRef || (storageKey == null ? ref(initialValue) : useStorage(storageKey, initialValue, storage, { window, listenToStorageChanges }));
|
|
2481
2768
|
const state = computed({
|
|
2482
2769
|
get() {
|
|
2483
2770
|
return store.value === "auto" && !emitAuto ? preferredMode.value : store.value;
|
|
@@ -2514,6 +2801,8 @@ function useColorMode(options = {}) {
|
|
|
2514
2801
|
defaultOnChanged(mode);
|
|
2515
2802
|
}
|
|
2516
2803
|
watch(state, onChanged, { flush: "post", immediate: true });
|
|
2804
|
+
if (emitAuto)
|
|
2805
|
+
watch(preferredMode, () => onChanged(state.value), { flush: "post" });
|
|
2517
2806
|
tryOnMounted(() => onChanged(state.value));
|
|
2518
2807
|
return state;
|
|
2519
2808
|
}
|
|
@@ -2557,7 +2846,7 @@ function useCssVar(prop, target, { window = defaultWindow, initialValue = "" } =
|
|
|
2557
2846
|
var _a;
|
|
2558
2847
|
return unrefElement(target) || ((_a = window == null ? void 0 : window.document) == null ? void 0 : _a.documentElement);
|
|
2559
2848
|
});
|
|
2560
|
-
watch([elRef, () =>
|
|
2849
|
+
watch([elRef, () => resolveUnref(prop)], ([el, prop2]) => {
|
|
2561
2850
|
var _a;
|
|
2562
2851
|
if (el && window) {
|
|
2563
2852
|
const value = (_a = window.getComputedStyle(el).getPropertyValue(prop2)) == null ? void 0 : _a.trim();
|
|
@@ -2567,24 +2856,17 @@ function useCssVar(prop, target, { window = defaultWindow, initialValue = "" } =
|
|
|
2567
2856
|
watch(variable, (val) => {
|
|
2568
2857
|
var _a;
|
|
2569
2858
|
if ((_a = elRef.value) == null ? void 0 : _a.style)
|
|
2570
|
-
elRef.value.style.setProperty(
|
|
2859
|
+
elRef.value.style.setProperty(resolveUnref(prop), val);
|
|
2571
2860
|
});
|
|
2572
2861
|
return variable;
|
|
2573
2862
|
}
|
|
2574
2863
|
|
|
2575
2864
|
function useCurrentElement() {
|
|
2576
2865
|
const vm = getCurrentInstance();
|
|
2577
|
-
const
|
|
2578
|
-
onUpdated(
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
onMounted(() => {
|
|
2582
|
-
count.value += 1;
|
|
2583
|
-
});
|
|
2584
|
-
return computed(() => {
|
|
2585
|
-
count.value;
|
|
2586
|
-
return vm.proxy.$el;
|
|
2587
|
-
});
|
|
2866
|
+
const currentElement = computedWithControl(() => null, () => vm.proxy.$el);
|
|
2867
|
+
onUpdated(currentElement.trigger);
|
|
2868
|
+
onMounted(currentElement.trigger);
|
|
2869
|
+
return currentElement;
|
|
2588
2870
|
}
|
|
2589
2871
|
|
|
2590
2872
|
function useCycleList(list, options) {
|
|
@@ -2626,21 +2908,21 @@ function useCycleList(list, options) {
|
|
|
2626
2908
|
};
|
|
2627
2909
|
}
|
|
2628
2910
|
|
|
2629
|
-
var __defProp$
|
|
2911
|
+
var __defProp$h = Object.defineProperty;
|
|
2630
2912
|
var __defProps$7 = Object.defineProperties;
|
|
2631
2913
|
var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
|
|
2632
|
-
var __getOwnPropSymbols$
|
|
2633
|
-
var __hasOwnProp$
|
|
2634
|
-
var __propIsEnum$
|
|
2635
|
-
var __defNormalProp$
|
|
2636
|
-
var __spreadValues$
|
|
2914
|
+
var __getOwnPropSymbols$j = Object.getOwnPropertySymbols;
|
|
2915
|
+
var __hasOwnProp$j = Object.prototype.hasOwnProperty;
|
|
2916
|
+
var __propIsEnum$j = Object.prototype.propertyIsEnumerable;
|
|
2917
|
+
var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2918
|
+
var __spreadValues$h = (a, b) => {
|
|
2637
2919
|
for (var prop in b || (b = {}))
|
|
2638
|
-
if (__hasOwnProp$
|
|
2639
|
-
__defNormalProp$
|
|
2640
|
-
if (__getOwnPropSymbols$
|
|
2641
|
-
for (var prop of __getOwnPropSymbols$
|
|
2642
|
-
if (__propIsEnum$
|
|
2643
|
-
__defNormalProp$
|
|
2920
|
+
if (__hasOwnProp$j.call(b, prop))
|
|
2921
|
+
__defNormalProp$h(a, prop, b[prop]);
|
|
2922
|
+
if (__getOwnPropSymbols$j)
|
|
2923
|
+
for (var prop of __getOwnPropSymbols$j(b)) {
|
|
2924
|
+
if (__propIsEnum$j.call(b, prop))
|
|
2925
|
+
__defNormalProp$h(a, prop, b[prop]);
|
|
2644
2926
|
}
|
|
2645
2927
|
return a;
|
|
2646
2928
|
};
|
|
@@ -2651,7 +2933,7 @@ function useDark(options = {}) {
|
|
|
2651
2933
|
valueLight = "",
|
|
2652
2934
|
window = defaultWindow
|
|
2653
2935
|
} = options;
|
|
2654
|
-
const mode = useColorMode(__spreadProps$7(__spreadValues$
|
|
2936
|
+
const mode = useColorMode(__spreadProps$7(__spreadValues$h({}, options), {
|
|
2655
2937
|
onChanged: (mode2, defaultHandler) => {
|
|
2656
2938
|
var _a;
|
|
2657
2939
|
if (options.onChanged)
|
|
@@ -2679,14 +2961,13 @@ function useDark(options = {}) {
|
|
|
2679
2961
|
return isDark;
|
|
2680
2962
|
}
|
|
2681
2963
|
|
|
2682
|
-
const fnClone = (v) => JSON.parse(JSON.stringify(v));
|
|
2683
2964
|
const fnBypass = (v) => v;
|
|
2684
2965
|
const fnSetSource = (source, value) => source.value = value;
|
|
2685
2966
|
function defaultDump(clone) {
|
|
2686
|
-
return clone ? isFunction(clone) ? clone :
|
|
2967
|
+
return clone ? isFunction(clone) ? clone : cloneFnJSON : fnBypass;
|
|
2687
2968
|
}
|
|
2688
2969
|
function defaultParse(clone) {
|
|
2689
|
-
return clone ? isFunction(clone) ? clone :
|
|
2970
|
+
return clone ? isFunction(clone) ? clone : cloneFnJSON : fnBypass;
|
|
2690
2971
|
}
|
|
2691
2972
|
function useManualRefHistory(source, options = {}) {
|
|
2692
2973
|
const {
|
|
@@ -2756,21 +3037,21 @@ function useManualRefHistory(source, options = {}) {
|
|
|
2756
3037
|
};
|
|
2757
3038
|
}
|
|
2758
3039
|
|
|
2759
|
-
var __defProp$
|
|
3040
|
+
var __defProp$g = Object.defineProperty;
|
|
2760
3041
|
var __defProps$6 = Object.defineProperties;
|
|
2761
3042
|
var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
|
|
2762
|
-
var __getOwnPropSymbols$
|
|
2763
|
-
var __hasOwnProp$
|
|
2764
|
-
var __propIsEnum$
|
|
2765
|
-
var __defNormalProp$
|
|
2766
|
-
var __spreadValues$
|
|
3043
|
+
var __getOwnPropSymbols$i = Object.getOwnPropertySymbols;
|
|
3044
|
+
var __hasOwnProp$i = Object.prototype.hasOwnProperty;
|
|
3045
|
+
var __propIsEnum$i = Object.prototype.propertyIsEnumerable;
|
|
3046
|
+
var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3047
|
+
var __spreadValues$g = (a, b) => {
|
|
2767
3048
|
for (var prop in b || (b = {}))
|
|
2768
|
-
if (__hasOwnProp$
|
|
2769
|
-
__defNormalProp$
|
|
2770
|
-
if (__getOwnPropSymbols$
|
|
2771
|
-
for (var prop of __getOwnPropSymbols$
|
|
2772
|
-
if (__propIsEnum$
|
|
2773
|
-
__defNormalProp$
|
|
3049
|
+
if (__hasOwnProp$i.call(b, prop))
|
|
3050
|
+
__defNormalProp$g(a, prop, b[prop]);
|
|
3051
|
+
if (__getOwnPropSymbols$i)
|
|
3052
|
+
for (var prop of __getOwnPropSymbols$i(b)) {
|
|
3053
|
+
if (__propIsEnum$i.call(b, prop))
|
|
3054
|
+
__defNormalProp$g(a, prop, b[prop]);
|
|
2774
3055
|
}
|
|
2775
3056
|
return a;
|
|
2776
3057
|
};
|
|
@@ -2798,7 +3079,7 @@ function useRefHistory(source, options = {}) {
|
|
|
2798
3079
|
source2.value = value;
|
|
2799
3080
|
});
|
|
2800
3081
|
}
|
|
2801
|
-
const manualHistory = useManualRefHistory(source, __spreadProps$6(__spreadValues$
|
|
3082
|
+
const manualHistory = useManualRefHistory(source, __spreadProps$6(__spreadValues$g({}, options), { clone: options.clone || deep, setSource }));
|
|
2802
3083
|
const { clear, commit: manualCommit } = manualHistory;
|
|
2803
3084
|
function commit() {
|
|
2804
3085
|
ignorePrevAsyncUpdates();
|
|
@@ -2822,7 +3103,7 @@ function useRefHistory(source, options = {}) {
|
|
|
2822
3103
|
stop();
|
|
2823
3104
|
clear();
|
|
2824
3105
|
}
|
|
2825
|
-
return __spreadProps$6(__spreadValues$
|
|
3106
|
+
return __spreadProps$6(__spreadValues$g({}, manualHistory), {
|
|
2826
3107
|
isTracking,
|
|
2827
3108
|
pause,
|
|
2828
3109
|
resume,
|
|
@@ -2832,29 +3113,29 @@ function useRefHistory(source, options = {}) {
|
|
|
2832
3113
|
});
|
|
2833
3114
|
}
|
|
2834
3115
|
|
|
2835
|
-
var __defProp$
|
|
3116
|
+
var __defProp$f = Object.defineProperty;
|
|
2836
3117
|
var __defProps$5 = Object.defineProperties;
|
|
2837
3118
|
var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
|
|
2838
|
-
var __getOwnPropSymbols$
|
|
2839
|
-
var __hasOwnProp$
|
|
2840
|
-
var __propIsEnum$
|
|
2841
|
-
var __defNormalProp$
|
|
2842
|
-
var __spreadValues$
|
|
3119
|
+
var __getOwnPropSymbols$h = Object.getOwnPropertySymbols;
|
|
3120
|
+
var __hasOwnProp$h = Object.prototype.hasOwnProperty;
|
|
3121
|
+
var __propIsEnum$h = Object.prototype.propertyIsEnumerable;
|
|
3122
|
+
var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3123
|
+
var __spreadValues$f = (a, b) => {
|
|
2843
3124
|
for (var prop in b || (b = {}))
|
|
2844
|
-
if (__hasOwnProp$
|
|
2845
|
-
__defNormalProp$
|
|
2846
|
-
if (__getOwnPropSymbols$
|
|
2847
|
-
for (var prop of __getOwnPropSymbols$
|
|
2848
|
-
if (__propIsEnum$
|
|
2849
|
-
__defNormalProp$
|
|
3125
|
+
if (__hasOwnProp$h.call(b, prop))
|
|
3126
|
+
__defNormalProp$f(a, prop, b[prop]);
|
|
3127
|
+
if (__getOwnPropSymbols$h)
|
|
3128
|
+
for (var prop of __getOwnPropSymbols$h(b)) {
|
|
3129
|
+
if (__propIsEnum$h.call(b, prop))
|
|
3130
|
+
__defNormalProp$f(a, prop, b[prop]);
|
|
2850
3131
|
}
|
|
2851
3132
|
return a;
|
|
2852
3133
|
};
|
|
2853
3134
|
var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
|
|
2854
3135
|
function useDebouncedRefHistory(source, options = {}) {
|
|
2855
3136
|
const filter = options.debounce ? debounceFilter(options.debounce) : void 0;
|
|
2856
|
-
const history = useRefHistory(source, __spreadProps$5(__spreadValues$
|
|
2857
|
-
return __spreadValues$
|
|
3137
|
+
const history = useRefHistory(source, __spreadProps$5(__spreadValues$f({}, options), { eventFilter: filter }));
|
|
3138
|
+
return __spreadValues$f({}, history);
|
|
2858
3139
|
}
|
|
2859
3140
|
|
|
2860
3141
|
function useDeviceMotion(options = {}) {
|
|
@@ -2889,12 +3170,12 @@ function useDeviceMotion(options = {}) {
|
|
|
2889
3170
|
|
|
2890
3171
|
function useDeviceOrientation(options = {}) {
|
|
2891
3172
|
const { window = defaultWindow } = options;
|
|
2892
|
-
const isSupported =
|
|
3173
|
+
const isSupported = useSupported(() => window && "DeviceOrientationEvent" in window);
|
|
2893
3174
|
const isAbsolute = ref(false);
|
|
2894
3175
|
const alpha = ref(null);
|
|
2895
3176
|
const beta = ref(null);
|
|
2896
3177
|
const gamma = ref(null);
|
|
2897
|
-
if (window && isSupported) {
|
|
3178
|
+
if (window && isSupported.value) {
|
|
2898
3179
|
useEventListener(window, "deviceorientation", (event) => {
|
|
2899
3180
|
isAbsolute.value = event.absolute;
|
|
2900
3181
|
alpha.value = event.alpha;
|
|
@@ -2911,20 +3192,6 @@ function useDeviceOrientation(options = {}) {
|
|
|
2911
3192
|
};
|
|
2912
3193
|
}
|
|
2913
3194
|
|
|
2914
|
-
const DEVICE_PIXEL_RATIO_SCALES = [
|
|
2915
|
-
1,
|
|
2916
|
-
1.325,
|
|
2917
|
-
1.4,
|
|
2918
|
-
1.5,
|
|
2919
|
-
1.8,
|
|
2920
|
-
2,
|
|
2921
|
-
2.4,
|
|
2922
|
-
2.5,
|
|
2923
|
-
2.75,
|
|
2924
|
-
3,
|
|
2925
|
-
3.5,
|
|
2926
|
-
4
|
|
2927
|
-
];
|
|
2928
3195
|
function useDevicePixelRatio({
|
|
2929
3196
|
window = defaultWindow
|
|
2930
3197
|
} = {}) {
|
|
@@ -2933,16 +3200,23 @@ function useDevicePixelRatio({
|
|
|
2933
3200
|
pixelRatio: ref(1)
|
|
2934
3201
|
};
|
|
2935
3202
|
}
|
|
2936
|
-
const pixelRatio = ref(
|
|
2937
|
-
const
|
|
3203
|
+
const pixelRatio = ref(1);
|
|
3204
|
+
const cleanups = [];
|
|
3205
|
+
const cleanup = () => {
|
|
3206
|
+
cleanups.map((i) => i());
|
|
3207
|
+
cleanups.length = 0;
|
|
3208
|
+
};
|
|
3209
|
+
const observe = () => {
|
|
2938
3210
|
pixelRatio.value = window.devicePixelRatio;
|
|
3211
|
+
cleanup();
|
|
3212
|
+
const media = window.matchMedia(`(resolution: ${pixelRatio.value}dppx)`);
|
|
3213
|
+
media.addEventListener("change", observe, { once: true });
|
|
3214
|
+
cleanups.push(() => {
|
|
3215
|
+
media.removeEventListener("change", observe);
|
|
3216
|
+
});
|
|
2939
3217
|
};
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
const mqlMin = useMediaQuery(`screen and (min-resolution: ${dppx}dppx)`);
|
|
2943
|
-
const mqlMax = useMediaQuery(`screen and (max-resolution: ${dppx}dppx)`);
|
|
2944
|
-
watch([mqlMin, mqlMax], handleDevicePixelRatio);
|
|
2945
|
-
});
|
|
3218
|
+
observe();
|
|
3219
|
+
tryOnScopeDispose(cleanup);
|
|
2946
3220
|
return { pixelRatio };
|
|
2947
3221
|
}
|
|
2948
3222
|
|
|
@@ -2951,7 +3225,7 @@ function usePermission(permissionDesc, options = {}) {
|
|
|
2951
3225
|
controls = false,
|
|
2952
3226
|
navigator = defaultNavigator
|
|
2953
3227
|
} = options;
|
|
2954
|
-
const isSupported =
|
|
3228
|
+
const isSupported = useSupported(() => navigator && "permissions" in navigator);
|
|
2955
3229
|
let permissionStatus;
|
|
2956
3230
|
const desc = typeof permissionDesc === "string" ? { name: permissionDesc } : permissionDesc;
|
|
2957
3231
|
const state = ref();
|
|
@@ -2960,7 +3234,7 @@ function usePermission(permissionDesc, options = {}) {
|
|
|
2960
3234
|
state.value = permissionStatus.state;
|
|
2961
3235
|
};
|
|
2962
3236
|
const query = createSingletonPromise(async () => {
|
|
2963
|
-
if (!isSupported)
|
|
3237
|
+
if (!isSupported.value)
|
|
2964
3238
|
return;
|
|
2965
3239
|
if (!permissionStatus) {
|
|
2966
3240
|
try {
|
|
@@ -2996,16 +3270,16 @@ function useDevicesList(options = {}) {
|
|
|
2996
3270
|
const videoInputs = computed(() => devices.value.filter((i) => i.kind === "videoinput"));
|
|
2997
3271
|
const audioInputs = computed(() => devices.value.filter((i) => i.kind === "audioinput"));
|
|
2998
3272
|
const audioOutputs = computed(() => devices.value.filter((i) => i.kind === "audiooutput"));
|
|
2999
|
-
|
|
3273
|
+
const isSupported = useSupported(() => navigator && navigator.mediaDevices && navigator.mediaDevices.enumerateDevices);
|
|
3000
3274
|
const permissionGranted = ref(false);
|
|
3001
3275
|
async function update() {
|
|
3002
|
-
if (!isSupported)
|
|
3276
|
+
if (!isSupported.value)
|
|
3003
3277
|
return;
|
|
3004
3278
|
devices.value = await navigator.mediaDevices.enumerateDevices();
|
|
3005
3279
|
onUpdated == null ? void 0 : onUpdated(devices.value);
|
|
3006
3280
|
}
|
|
3007
3281
|
async function ensurePermissions() {
|
|
3008
|
-
if (!isSupported)
|
|
3282
|
+
if (!isSupported.value)
|
|
3009
3283
|
return false;
|
|
3010
3284
|
if (permissionGranted.value)
|
|
3011
3285
|
return true;
|
|
@@ -3021,14 +3295,11 @@ function useDevicesList(options = {}) {
|
|
|
3021
3295
|
}
|
|
3022
3296
|
return permissionGranted.value;
|
|
3023
3297
|
}
|
|
3024
|
-
if (
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
useEventListener(navigator.mediaDevices, "devicechange", update);
|
|
3030
|
-
update();
|
|
3031
|
-
}
|
|
3298
|
+
if (isSupported.value) {
|
|
3299
|
+
if (requestPermissions)
|
|
3300
|
+
ensurePermissions();
|
|
3301
|
+
useEventListener(navigator.mediaDevices, "devicechange", update);
|
|
3302
|
+
update();
|
|
3032
3303
|
}
|
|
3033
3304
|
return {
|
|
3034
3305
|
devices,
|
|
@@ -3042,16 +3313,19 @@ function useDevicesList(options = {}) {
|
|
|
3042
3313
|
}
|
|
3043
3314
|
|
|
3044
3315
|
function useDisplayMedia(options = {}) {
|
|
3045
|
-
var _a
|
|
3316
|
+
var _a;
|
|
3046
3317
|
const enabled = ref((_a = options.enabled) != null ? _a : false);
|
|
3047
3318
|
const video = options.video;
|
|
3048
3319
|
const audio = options.audio;
|
|
3049
3320
|
const { navigator = defaultNavigator } = options;
|
|
3050
|
-
const isSupported =
|
|
3321
|
+
const isSupported = useSupported(() => {
|
|
3322
|
+
var _a2;
|
|
3323
|
+
return (_a2 = navigator == null ? void 0 : navigator.mediaDevices) == null ? void 0 : _a2.getDisplayMedia;
|
|
3324
|
+
});
|
|
3051
3325
|
const constraint = { audio, video };
|
|
3052
3326
|
const stream = shallowRef();
|
|
3053
3327
|
async function _start() {
|
|
3054
|
-
if (!isSupported || stream.value)
|
|
3328
|
+
if (!isSupported.value || stream.value)
|
|
3055
3329
|
return;
|
|
3056
3330
|
stream.value = await navigator.mediaDevices.getDisplayMedia(constraint);
|
|
3057
3331
|
return stream.value;
|
|
@@ -3096,29 +3370,30 @@ function useDocumentVisibility({ document = defaultDocument } = {}) {
|
|
|
3096
3370
|
return visibility;
|
|
3097
3371
|
}
|
|
3098
3372
|
|
|
3099
|
-
var __defProp$
|
|
3373
|
+
var __defProp$e = Object.defineProperty;
|
|
3100
3374
|
var __defProps$4 = Object.defineProperties;
|
|
3101
3375
|
var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
|
|
3102
|
-
var __getOwnPropSymbols$
|
|
3103
|
-
var __hasOwnProp$
|
|
3104
|
-
var __propIsEnum$
|
|
3105
|
-
var __defNormalProp$
|
|
3106
|
-
var __spreadValues$
|
|
3376
|
+
var __getOwnPropSymbols$g = Object.getOwnPropertySymbols;
|
|
3377
|
+
var __hasOwnProp$g = Object.prototype.hasOwnProperty;
|
|
3378
|
+
var __propIsEnum$g = Object.prototype.propertyIsEnumerable;
|
|
3379
|
+
var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3380
|
+
var __spreadValues$e = (a, b) => {
|
|
3107
3381
|
for (var prop in b || (b = {}))
|
|
3108
|
-
if (__hasOwnProp$
|
|
3109
|
-
__defNormalProp$
|
|
3110
|
-
if (__getOwnPropSymbols$
|
|
3111
|
-
for (var prop of __getOwnPropSymbols$
|
|
3112
|
-
if (__propIsEnum$
|
|
3113
|
-
__defNormalProp$
|
|
3382
|
+
if (__hasOwnProp$g.call(b, prop))
|
|
3383
|
+
__defNormalProp$e(a, prop, b[prop]);
|
|
3384
|
+
if (__getOwnPropSymbols$g)
|
|
3385
|
+
for (var prop of __getOwnPropSymbols$g(b)) {
|
|
3386
|
+
if (__propIsEnum$g.call(b, prop))
|
|
3387
|
+
__defNormalProp$e(a, prop, b[prop]);
|
|
3114
3388
|
}
|
|
3115
3389
|
return a;
|
|
3116
3390
|
};
|
|
3117
3391
|
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
|
3118
3392
|
function useDraggable(target, options = {}) {
|
|
3119
|
-
var _a, _b;
|
|
3393
|
+
var _a, _b, _c;
|
|
3120
3394
|
const draggingElement = (_a = options.draggingElement) != null ? _a : defaultWindow;
|
|
3121
|
-
const
|
|
3395
|
+
const draggingHandle = (_b = options.handle) != null ? _b : target;
|
|
3396
|
+
const position = ref((_c = resolveUnref(options.initialValue)) != null ? _c : { x: 0, y: 0 });
|
|
3122
3397
|
const pressedDelta = ref();
|
|
3123
3398
|
const filterEvent = (e) => {
|
|
3124
3399
|
if (options.pointerTypes)
|
|
@@ -3126,21 +3401,21 @@ function useDraggable(target, options = {}) {
|
|
|
3126
3401
|
return true;
|
|
3127
3402
|
};
|
|
3128
3403
|
const handleEvent = (e) => {
|
|
3129
|
-
if (
|
|
3404
|
+
if (resolveUnref(options.preventDefault))
|
|
3130
3405
|
e.preventDefault();
|
|
3131
|
-
if (
|
|
3406
|
+
if (resolveUnref(options.stopPropagation))
|
|
3132
3407
|
e.stopPropagation();
|
|
3133
3408
|
};
|
|
3134
3409
|
const start = (e) => {
|
|
3135
3410
|
var _a2;
|
|
3136
3411
|
if (!filterEvent(e))
|
|
3137
3412
|
return;
|
|
3138
|
-
if (
|
|
3413
|
+
if (resolveUnref(options.exact) && e.target !== resolveUnref(target))
|
|
3139
3414
|
return;
|
|
3140
|
-
const rect =
|
|
3415
|
+
const rect = resolveUnref(target).getBoundingClientRect();
|
|
3141
3416
|
const pos = {
|
|
3142
|
-
x: e.
|
|
3143
|
-
y: e.
|
|
3417
|
+
x: e.clientX - rect.left,
|
|
3418
|
+
y: e.clientY - rect.top
|
|
3144
3419
|
};
|
|
3145
3420
|
if (((_a2 = options.onStart) == null ? void 0 : _a2.call(options, pos, e)) === false)
|
|
3146
3421
|
return;
|
|
@@ -3154,8 +3429,8 @@ function useDraggable(target, options = {}) {
|
|
|
3154
3429
|
if (!pressedDelta.value)
|
|
3155
3430
|
return;
|
|
3156
3431
|
position.value = {
|
|
3157
|
-
x: e.
|
|
3158
|
-
y: e.
|
|
3432
|
+
x: e.clientX - pressedDelta.value.x,
|
|
3433
|
+
y: e.clientY - pressedDelta.value.y
|
|
3159
3434
|
};
|
|
3160
3435
|
(_a2 = options.onMove) == null ? void 0 : _a2.call(options, position.value, e);
|
|
3161
3436
|
handleEvent(e);
|
|
@@ -3171,11 +3446,11 @@ function useDraggable(target, options = {}) {
|
|
|
3171
3446
|
handleEvent(e);
|
|
3172
3447
|
};
|
|
3173
3448
|
if (isClient) {
|
|
3174
|
-
useEventListener(
|
|
3449
|
+
useEventListener(draggingHandle, "pointerdown", start, true);
|
|
3175
3450
|
useEventListener(draggingElement, "pointermove", move, true);
|
|
3176
3451
|
useEventListener(draggingElement, "pointerup", end, true);
|
|
3177
3452
|
}
|
|
3178
|
-
return __spreadProps$4(__spreadValues$
|
|
3453
|
+
return __spreadProps$4(__spreadValues$e({}, toRefs(position)), {
|
|
3179
3454
|
position,
|
|
3180
3455
|
isDragging: computed(() => !!pressedDelta.value),
|
|
3181
3456
|
style: computed(() => `left:${position.value.x}px;top:${position.value.y}px;`)
|
|
@@ -3206,11 +3481,7 @@ function useDropZone(target, onDrop) {
|
|
|
3206
3481
|
counter = 0;
|
|
3207
3482
|
isOverDropZone.value = false;
|
|
3208
3483
|
const files = Array.from((_b = (_a = event.dataTransfer) == null ? void 0 : _a.files) != null ? _b : []);
|
|
3209
|
-
|
|
3210
|
-
onDrop(null);
|
|
3211
|
-
return;
|
|
3212
|
-
}
|
|
3213
|
-
onDrop(files);
|
|
3484
|
+
onDrop == null ? void 0 : onDrop(files.length === 0 ? null : files);
|
|
3214
3485
|
});
|
|
3215
3486
|
}
|
|
3216
3487
|
return {
|
|
@@ -3218,17 +3489,17 @@ function useDropZone(target, onDrop) {
|
|
|
3218
3489
|
};
|
|
3219
3490
|
}
|
|
3220
3491
|
|
|
3221
|
-
var __getOwnPropSymbols$
|
|
3222
|
-
var __hasOwnProp$
|
|
3223
|
-
var __propIsEnum$
|
|
3492
|
+
var __getOwnPropSymbols$f = Object.getOwnPropertySymbols;
|
|
3493
|
+
var __hasOwnProp$f = Object.prototype.hasOwnProperty;
|
|
3494
|
+
var __propIsEnum$f = Object.prototype.propertyIsEnumerable;
|
|
3224
3495
|
var __objRest$2 = (source, exclude) => {
|
|
3225
3496
|
var target = {};
|
|
3226
3497
|
for (var prop in source)
|
|
3227
|
-
if (__hasOwnProp$
|
|
3498
|
+
if (__hasOwnProp$f.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
3228
3499
|
target[prop] = source[prop];
|
|
3229
|
-
if (source != null && __getOwnPropSymbols$
|
|
3230
|
-
for (var prop of __getOwnPropSymbols$
|
|
3231
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
3500
|
+
if (source != null && __getOwnPropSymbols$f)
|
|
3501
|
+
for (var prop of __getOwnPropSymbols$f(source)) {
|
|
3502
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$f.call(source, prop))
|
|
3232
3503
|
target[prop] = source[prop];
|
|
3233
3504
|
}
|
|
3234
3505
|
return target;
|
|
@@ -3236,7 +3507,7 @@ var __objRest$2 = (source, exclude) => {
|
|
|
3236
3507
|
function useResizeObserver(target, callback, options = {}) {
|
|
3237
3508
|
const _a = options, { window = defaultWindow } = _a, observerOptions = __objRest$2(_a, ["window"]);
|
|
3238
3509
|
let observer;
|
|
3239
|
-
const isSupported = window && "ResizeObserver" in window;
|
|
3510
|
+
const isSupported = useSupported(() => window && "ResizeObserver" in window);
|
|
3240
3511
|
const cleanup = () => {
|
|
3241
3512
|
if (observer) {
|
|
3242
3513
|
observer.disconnect();
|
|
@@ -3245,7 +3516,7 @@ function useResizeObserver(target, callback, options = {}) {
|
|
|
3245
3516
|
};
|
|
3246
3517
|
const stopWatch = watch(() => unrefElement(target), (el) => {
|
|
3247
3518
|
cleanup();
|
|
3248
|
-
if (isSupported && window && el) {
|
|
3519
|
+
if (isSupported.value && window && el) {
|
|
3249
3520
|
observer = new ResizeObserver(callback);
|
|
3250
3521
|
observer.observe(el, observerOptions);
|
|
3251
3522
|
}
|
|
@@ -3304,7 +3575,7 @@ function useElementBounding(target, options = {}) {
|
|
|
3304
3575
|
useResizeObserver(target, update);
|
|
3305
3576
|
watch(() => unrefElement(target), (ele) => !ele && update());
|
|
3306
3577
|
if (windowScroll)
|
|
3307
|
-
useEventListener("scroll", update, { passive: true });
|
|
3578
|
+
useEventListener("scroll", update, { capture: true, passive: true });
|
|
3308
3579
|
if (windowResize)
|
|
3309
3580
|
useEventListener("resize", update, { passive: true });
|
|
3310
3581
|
tryOnMounted(() => {
|
|
@@ -3330,17 +3601,20 @@ function useRafFn(fn, options = {}) {
|
|
|
3330
3601
|
window = defaultWindow
|
|
3331
3602
|
} = options;
|
|
3332
3603
|
const isActive = ref(false);
|
|
3604
|
+
let previousFrameTimestamp = 0;
|
|
3333
3605
|
let rafId = null;
|
|
3334
|
-
function loop() {
|
|
3606
|
+
function loop(timestamp) {
|
|
3335
3607
|
if (!isActive.value || !window)
|
|
3336
3608
|
return;
|
|
3337
|
-
|
|
3609
|
+
const delta = timestamp - previousFrameTimestamp;
|
|
3610
|
+
fn({ delta, timestamp });
|
|
3611
|
+
previousFrameTimestamp = timestamp;
|
|
3338
3612
|
rafId = window.requestAnimationFrame(loop);
|
|
3339
3613
|
}
|
|
3340
3614
|
function resume() {
|
|
3341
3615
|
if (!isActive.value && window) {
|
|
3342
3616
|
isActive.value = true;
|
|
3343
|
-
loop
|
|
3617
|
+
rafId = window.requestAnimationFrame(loop);
|
|
3344
3618
|
}
|
|
3345
3619
|
}
|
|
3346
3620
|
function pause() {
|
|
@@ -3354,35 +3628,35 @@ function useRafFn(fn, options = {}) {
|
|
|
3354
3628
|
resume();
|
|
3355
3629
|
tryOnScopeDispose(pause);
|
|
3356
3630
|
return {
|
|
3357
|
-
isActive,
|
|
3631
|
+
isActive: readonly(isActive),
|
|
3358
3632
|
pause,
|
|
3359
3633
|
resume
|
|
3360
3634
|
};
|
|
3361
3635
|
}
|
|
3362
3636
|
|
|
3363
|
-
var __defProp$
|
|
3364
|
-
var __getOwnPropSymbols$
|
|
3365
|
-
var __hasOwnProp$
|
|
3366
|
-
var __propIsEnum$
|
|
3367
|
-
var __defNormalProp$
|
|
3368
|
-
var __spreadValues$
|
|
3637
|
+
var __defProp$d = Object.defineProperty;
|
|
3638
|
+
var __getOwnPropSymbols$e = Object.getOwnPropertySymbols;
|
|
3639
|
+
var __hasOwnProp$e = Object.prototype.hasOwnProperty;
|
|
3640
|
+
var __propIsEnum$e = Object.prototype.propertyIsEnumerable;
|
|
3641
|
+
var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3642
|
+
var __spreadValues$d = (a, b) => {
|
|
3369
3643
|
for (var prop in b || (b = {}))
|
|
3370
|
-
if (__hasOwnProp$
|
|
3371
|
-
__defNormalProp$
|
|
3372
|
-
if (__getOwnPropSymbols$
|
|
3373
|
-
for (var prop of __getOwnPropSymbols$
|
|
3374
|
-
if (__propIsEnum$
|
|
3375
|
-
__defNormalProp$
|
|
3644
|
+
if (__hasOwnProp$e.call(b, prop))
|
|
3645
|
+
__defNormalProp$d(a, prop, b[prop]);
|
|
3646
|
+
if (__getOwnPropSymbols$e)
|
|
3647
|
+
for (var prop of __getOwnPropSymbols$e(b)) {
|
|
3648
|
+
if (__propIsEnum$e.call(b, prop))
|
|
3649
|
+
__defNormalProp$d(a, prop, b[prop]);
|
|
3376
3650
|
}
|
|
3377
3651
|
return a;
|
|
3378
3652
|
};
|
|
3379
3653
|
function useElementByPoint(options) {
|
|
3380
3654
|
const element = ref(null);
|
|
3381
|
-
const { x, y } = options;
|
|
3655
|
+
const { x, y, document = defaultDocument } = options;
|
|
3382
3656
|
const controls = useRafFn(() => {
|
|
3383
|
-
element.value = document.elementFromPoint(
|
|
3657
|
+
element.value = (document == null ? void 0 : document.elementFromPoint(resolveUnref(x), resolveUnref(y))) || null;
|
|
3384
3658
|
});
|
|
3385
|
-
return __spreadValues$
|
|
3659
|
+
return __spreadValues$d({
|
|
3386
3660
|
element
|
|
3387
3661
|
}, controls);
|
|
3388
3662
|
}
|
|
@@ -3395,11 +3669,32 @@ function useElementHover(el) {
|
|
|
3395
3669
|
}
|
|
3396
3670
|
|
|
3397
3671
|
function useElementSize(target, initialSize = { width: 0, height: 0 }, options = {}) {
|
|
3672
|
+
const { window = defaultWindow, box = "content-box" } = options;
|
|
3673
|
+
const isSVG = computed(() => {
|
|
3674
|
+
var _a, _b;
|
|
3675
|
+
return (_b = (_a = unrefElement(target)) == null ? void 0 : _a.namespaceURI) == null ? void 0 : _b.includes("svg");
|
|
3676
|
+
});
|
|
3398
3677
|
const width = ref(initialSize.width);
|
|
3399
3678
|
const height = ref(initialSize.height);
|
|
3400
3679
|
useResizeObserver(target, ([entry]) => {
|
|
3401
|
-
|
|
3402
|
-
|
|
3680
|
+
const boxSize = box === "border-box" ? entry.borderBoxSize : box === "content-box" ? entry.contentBoxSize : entry.devicePixelContentBoxSize;
|
|
3681
|
+
if (window && isSVG.value) {
|
|
3682
|
+
const $elem = unrefElement(target);
|
|
3683
|
+
if ($elem) {
|
|
3684
|
+
const styles = window.getComputedStyle($elem);
|
|
3685
|
+
width.value = parseFloat(styles.width);
|
|
3686
|
+
height.value = parseFloat(styles.height);
|
|
3687
|
+
}
|
|
3688
|
+
} else {
|
|
3689
|
+
if (boxSize) {
|
|
3690
|
+
const formatBoxSize = Array.isArray(boxSize) ? boxSize : [boxSize];
|
|
3691
|
+
width.value = formatBoxSize.reduce((acc, { inlineSize }) => acc + inlineSize, 0);
|
|
3692
|
+
height.value = formatBoxSize.reduce((acc, { blockSize }) => acc + blockSize, 0);
|
|
3693
|
+
} else {
|
|
3694
|
+
width.value = entry.contentRect.width;
|
|
3695
|
+
height.value = entry.contentRect.height;
|
|
3696
|
+
}
|
|
3697
|
+
}
|
|
3403
3698
|
}, options);
|
|
3404
3699
|
watch(() => unrefElement(target), (ele) => {
|
|
3405
3700
|
width.value = ele ? initialSize.width : 0;
|
|
@@ -3417,16 +3712,21 @@ function useElementVisibility(element, { window = defaultWindow, scrollTarget }
|
|
|
3417
3712
|
if (!window)
|
|
3418
3713
|
return;
|
|
3419
3714
|
const document = window.document;
|
|
3420
|
-
|
|
3715
|
+
const el = unrefElement(element);
|
|
3716
|
+
if (!el) {
|
|
3421
3717
|
elementIsVisible.value = false;
|
|
3422
3718
|
} else {
|
|
3423
|
-
const rect =
|
|
3719
|
+
const rect = el.getBoundingClientRect();
|
|
3424
3720
|
elementIsVisible.value = rect.top <= (window.innerHeight || document.documentElement.clientHeight) && rect.left <= (window.innerWidth || document.documentElement.clientWidth) && rect.bottom >= 0 && rect.right >= 0;
|
|
3425
3721
|
}
|
|
3426
3722
|
};
|
|
3427
|
-
|
|
3428
|
-
if (window)
|
|
3429
|
-
|
|
3723
|
+
watch(() => unrefElement(element), () => testBounding(), { immediate: true, flush: "post" });
|
|
3724
|
+
if (window) {
|
|
3725
|
+
useEventListener(scrollTarget || window, "scroll", testBounding, {
|
|
3726
|
+
capture: false,
|
|
3727
|
+
passive: true
|
|
3728
|
+
});
|
|
3729
|
+
}
|
|
3430
3730
|
return elementIsVisible;
|
|
3431
3731
|
}
|
|
3432
3732
|
|
|
@@ -3521,10 +3821,10 @@ function useEventSource(url, events = [], options = {}) {
|
|
|
3521
3821
|
|
|
3522
3822
|
function useEyeDropper(options = {}) {
|
|
3523
3823
|
const { initialValue = "" } = options;
|
|
3524
|
-
const isSupported =
|
|
3824
|
+
const isSupported = useSupported(() => typeof window !== "undefined" && "EyeDropper" in window);
|
|
3525
3825
|
const sRGBHex = ref(initialValue);
|
|
3526
3826
|
async function open(openOptions) {
|
|
3527
|
-
if (!isSupported)
|
|
3827
|
+
if (!isSupported.value)
|
|
3528
3828
|
return;
|
|
3529
3829
|
const eyeDropper = new window.EyeDropper();
|
|
3530
3830
|
const result = await eyeDropper.open(openOptions);
|
|
@@ -3540,7 +3840,7 @@ function useFavicon(newIcon = null, options = {}) {
|
|
|
3540
3840
|
rel = "icon",
|
|
3541
3841
|
document = defaultDocument
|
|
3542
3842
|
} = options;
|
|
3543
|
-
const favicon =
|
|
3843
|
+
const favicon = resolveRef(newIcon);
|
|
3544
3844
|
const applyIcon = (icon) => {
|
|
3545
3845
|
document == null ? void 0 : document.head.querySelectorAll(`link[rel*="${rel}"]`).forEach((el) => el.href = `${baseUrl}${icon}`);
|
|
3546
3846
|
};
|
|
@@ -3551,56 +3851,90 @@ function useFavicon(newIcon = null, options = {}) {
|
|
|
3551
3851
|
return favicon;
|
|
3552
3852
|
}
|
|
3553
3853
|
|
|
3554
|
-
var __defProp$
|
|
3854
|
+
var __defProp$c = Object.defineProperty;
|
|
3555
3855
|
var __defProps$3 = Object.defineProperties;
|
|
3556
3856
|
var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
|
3557
|
-
var __getOwnPropSymbols$
|
|
3558
|
-
var __hasOwnProp$
|
|
3559
|
-
var __propIsEnum$
|
|
3560
|
-
var __defNormalProp$
|
|
3561
|
-
var __spreadValues$
|
|
3857
|
+
var __getOwnPropSymbols$d = Object.getOwnPropertySymbols;
|
|
3858
|
+
var __hasOwnProp$d = Object.prototype.hasOwnProperty;
|
|
3859
|
+
var __propIsEnum$d = Object.prototype.propertyIsEnumerable;
|
|
3860
|
+
var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3861
|
+
var __spreadValues$c = (a, b) => {
|
|
3562
3862
|
for (var prop in b || (b = {}))
|
|
3563
|
-
if (__hasOwnProp$
|
|
3564
|
-
__defNormalProp$
|
|
3565
|
-
if (__getOwnPropSymbols$
|
|
3566
|
-
for (var prop of __getOwnPropSymbols$
|
|
3567
|
-
if (__propIsEnum$
|
|
3568
|
-
__defNormalProp$
|
|
3863
|
+
if (__hasOwnProp$d.call(b, prop))
|
|
3864
|
+
__defNormalProp$c(a, prop, b[prop]);
|
|
3865
|
+
if (__getOwnPropSymbols$d)
|
|
3866
|
+
for (var prop of __getOwnPropSymbols$d(b)) {
|
|
3867
|
+
if (__propIsEnum$d.call(b, prop))
|
|
3868
|
+
__defNormalProp$c(a, prop, b[prop]);
|
|
3569
3869
|
}
|
|
3570
3870
|
return a;
|
|
3571
3871
|
};
|
|
3572
3872
|
var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
|
|
3573
3873
|
const payloadMapping = {
|
|
3574
3874
|
json: "application/json",
|
|
3575
|
-
text: "text/plain"
|
|
3576
|
-
formData: "multipart/form-data"
|
|
3875
|
+
text: "text/plain"
|
|
3577
3876
|
};
|
|
3578
3877
|
function isFetchOptions(obj) {
|
|
3579
3878
|
return containsProp(obj, "immediate", "refetch", "initialData", "timeout", "beforeFetch", "afterFetch", "onFetchError", "fetch");
|
|
3580
3879
|
}
|
|
3880
|
+
function isAbsoluteURL(url) {
|
|
3881
|
+
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
|
3882
|
+
}
|
|
3581
3883
|
function headersToObject(headers) {
|
|
3582
3884
|
if (typeof Headers !== "undefined" && headers instanceof Headers)
|
|
3583
3885
|
return Object.fromEntries([...headers.entries()]);
|
|
3584
3886
|
return headers;
|
|
3585
3887
|
}
|
|
3888
|
+
function combineCallbacks(combination, ...callbacks) {
|
|
3889
|
+
if (combination === "overwrite") {
|
|
3890
|
+
return async (ctx) => {
|
|
3891
|
+
const callback = callbacks[callbacks.length - 1];
|
|
3892
|
+
if (callback !== void 0)
|
|
3893
|
+
await callback(ctx);
|
|
3894
|
+
return ctx;
|
|
3895
|
+
};
|
|
3896
|
+
} else {
|
|
3897
|
+
return async (ctx) => {
|
|
3898
|
+
await callbacks.reduce((prevCallback, callback) => prevCallback.then(async () => {
|
|
3899
|
+
if (callback)
|
|
3900
|
+
ctx = __spreadValues$c(__spreadValues$c({}, ctx), await callback(ctx));
|
|
3901
|
+
}), Promise.resolve());
|
|
3902
|
+
return ctx;
|
|
3903
|
+
};
|
|
3904
|
+
}
|
|
3905
|
+
}
|
|
3586
3906
|
function createFetch(config = {}) {
|
|
3907
|
+
const _combination = config.combination || "chain";
|
|
3587
3908
|
const _options = config.options || {};
|
|
3588
3909
|
const _fetchOptions = config.fetchOptions || {};
|
|
3589
3910
|
function useFactoryFetch(url, ...args) {
|
|
3590
|
-
const computedUrl = computed(() =>
|
|
3911
|
+
const computedUrl = computed(() => {
|
|
3912
|
+
const baseUrl = resolveUnref(config.baseUrl);
|
|
3913
|
+
const targetUrl = resolveUnref(url);
|
|
3914
|
+
return baseUrl && !isAbsoluteURL(targetUrl) ? joinPaths(baseUrl, targetUrl) : targetUrl;
|
|
3915
|
+
});
|
|
3591
3916
|
let options = _options;
|
|
3592
3917
|
let fetchOptions = _fetchOptions;
|
|
3593
3918
|
if (args.length > 0) {
|
|
3594
3919
|
if (isFetchOptions(args[0])) {
|
|
3595
|
-
options = __spreadValues$
|
|
3920
|
+
options = __spreadProps$3(__spreadValues$c(__spreadValues$c({}, options), args[0]), {
|
|
3921
|
+
beforeFetch: combineCallbacks(_combination, _options.beforeFetch, args[0].beforeFetch),
|
|
3922
|
+
afterFetch: combineCallbacks(_combination, _options.afterFetch, args[0].afterFetch),
|
|
3923
|
+
onFetchError: combineCallbacks(_combination, _options.onFetchError, args[0].onFetchError)
|
|
3924
|
+
});
|
|
3596
3925
|
} else {
|
|
3597
|
-
fetchOptions = __spreadProps$3(__spreadValues$
|
|
3598
|
-
headers: __spreadValues$
|
|
3926
|
+
fetchOptions = __spreadProps$3(__spreadValues$c(__spreadValues$c({}, fetchOptions), args[0]), {
|
|
3927
|
+
headers: __spreadValues$c(__spreadValues$c({}, headersToObject(fetchOptions.headers) || {}), headersToObject(args[0].headers) || {})
|
|
3599
3928
|
});
|
|
3600
3929
|
}
|
|
3601
3930
|
}
|
|
3602
|
-
if (args.length > 1 && isFetchOptions(args[1]))
|
|
3603
|
-
options = __spreadValues$
|
|
3931
|
+
if (args.length > 1 && isFetchOptions(args[1])) {
|
|
3932
|
+
options = __spreadProps$3(__spreadValues$c(__spreadValues$c({}, options), args[1]), {
|
|
3933
|
+
beforeFetch: combineCallbacks(_combination, _options.beforeFetch, args[1].beforeFetch),
|
|
3934
|
+
afterFetch: combineCallbacks(_combination, _options.afterFetch, args[1].afterFetch),
|
|
3935
|
+
onFetchError: combineCallbacks(_combination, _options.onFetchError, args[1].onFetchError)
|
|
3936
|
+
});
|
|
3937
|
+
}
|
|
3604
3938
|
return useFetch(computedUrl, fetchOptions, options);
|
|
3605
3939
|
}
|
|
3606
3940
|
return useFactoryFetch;
|
|
@@ -3617,13 +3951,13 @@ function useFetch(url, ...args) {
|
|
|
3617
3951
|
};
|
|
3618
3952
|
if (args.length > 0) {
|
|
3619
3953
|
if (isFetchOptions(args[0]))
|
|
3620
|
-
options = __spreadValues$
|
|
3954
|
+
options = __spreadValues$c(__spreadValues$c({}, options), args[0]);
|
|
3621
3955
|
else
|
|
3622
3956
|
fetchOptions = args[0];
|
|
3623
3957
|
}
|
|
3624
3958
|
if (args.length > 1) {
|
|
3625
3959
|
if (isFetchOptions(args[1]))
|
|
3626
|
-
options = __spreadValues$
|
|
3960
|
+
options = __spreadValues$c(__spreadValues$c({}, options), args[1]);
|
|
3627
3961
|
}
|
|
3628
3962
|
const {
|
|
3629
3963
|
fetch = (_a = defaultWindow) == null ? void 0 : _a.fetch,
|
|
@@ -3663,7 +3997,7 @@ function useFetch(url, ...args) {
|
|
|
3663
3997
|
if (supportsAbort) {
|
|
3664
3998
|
controller = new AbortController();
|
|
3665
3999
|
controller.signal.onabort = () => aborted.value = true;
|
|
3666
|
-
fetchOptions = __spreadProps$3(__spreadValues$
|
|
4000
|
+
fetchOptions = __spreadProps$3(__spreadValues$c({}, fetchOptions), {
|
|
3667
4001
|
signal: controller.signal
|
|
3668
4002
|
});
|
|
3669
4003
|
}
|
|
@@ -3675,12 +4009,17 @@ function useFetch(url, ...args) {
|
|
|
3675
4009
|
const headers = headersToObject(defaultFetchOptions.headers);
|
|
3676
4010
|
if (config.payloadType)
|
|
3677
4011
|
headers["Content-Type"] = (_a2 = payloadMapping[config.payloadType]) != null ? _a2 : config.payloadType;
|
|
3678
|
-
|
|
4012
|
+
const payload = resolveUnref(config.payload);
|
|
4013
|
+
defaultFetchOptions.body = config.payloadType === "json" ? JSON.stringify(payload) : payload;
|
|
3679
4014
|
}
|
|
3680
4015
|
let isCanceled = false;
|
|
3681
|
-
const context = {
|
|
3682
|
-
|
|
3683
|
-
|
|
4016
|
+
const context = {
|
|
4017
|
+
url: resolveUnref(url),
|
|
4018
|
+
options: __spreadValues$c(__spreadValues$c({}, defaultFetchOptions), fetchOptions),
|
|
4019
|
+
cancel: () => {
|
|
4020
|
+
isCanceled = true;
|
|
4021
|
+
}
|
|
4022
|
+
};
|
|
3684
4023
|
if (options.beforeFetch)
|
|
3685
4024
|
Object.assign(context, await options.beforeFetch(context));
|
|
3686
4025
|
if (isCanceled || !fetch) {
|
|
@@ -3692,8 +4031,8 @@ function useFetch(url, ...args) {
|
|
|
3692
4031
|
timer.start();
|
|
3693
4032
|
return new Promise((resolve, reject) => {
|
|
3694
4033
|
var _a3;
|
|
3695
|
-
fetch(context.url, __spreadProps$3(__spreadValues$
|
|
3696
|
-
headers: __spreadValues$
|
|
4034
|
+
fetch(context.url, __spreadProps$3(__spreadValues$c(__spreadValues$c({}, defaultFetchOptions), context.options), {
|
|
4035
|
+
headers: __spreadValues$c(__spreadValues$c({}, headersToObject(defaultFetchOptions.headers)), headersToObject((_a3 = context.options) == null ? void 0 : _a3.headers))
|
|
3697
4036
|
})).then(async (fetchResponse) => {
|
|
3698
4037
|
response.value = fetchResponse;
|
|
3699
4038
|
statusCode.value = fetchResponse.status;
|
|
@@ -3723,10 +4062,11 @@ function useFetch(url, ...args) {
|
|
|
3723
4062
|
});
|
|
3724
4063
|
});
|
|
3725
4064
|
};
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
4065
|
+
const refetch = resolveRef(options.refetch);
|
|
4066
|
+
watch([
|
|
4067
|
+
refetch,
|
|
4068
|
+
resolveRef(url)
|
|
4069
|
+
], ([refetch2]) => refetch2 && execute(), { deep: true });
|
|
3730
4070
|
const shell = {
|
|
3731
4071
|
isFinished,
|
|
3732
4072
|
statusCode,
|
|
@@ -3761,14 +4101,15 @@ function useFetch(url, ...args) {
|
|
|
3761
4101
|
config.payload = payload;
|
|
3762
4102
|
config.payloadType = payloadType;
|
|
3763
4103
|
if (isRef(config.payload)) {
|
|
3764
|
-
watch(
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
], () =>
|
|
4104
|
+
watch([
|
|
4105
|
+
refetch,
|
|
4106
|
+
resolveRef(config.payload)
|
|
4107
|
+
], ([refetch2]) => refetch2 && execute(), { deep: true });
|
|
3768
4108
|
}
|
|
3769
|
-
|
|
4109
|
+
const rawPayload = resolveUnref(config.payload);
|
|
4110
|
+
if (!payloadType && rawPayload && Object.getPrototypeOf(rawPayload) === Object.prototype && !(rawPayload instanceof FormData))
|
|
3770
4111
|
config.payloadType = "json";
|
|
3771
|
-
return __spreadProps$3(__spreadValues$
|
|
4112
|
+
return __spreadProps$3(__spreadValues$c({}, shell), {
|
|
3772
4113
|
then(onFulfilled, onRejected) {
|
|
3773
4114
|
return waitUntilFinished().then(onFulfilled, onRejected);
|
|
3774
4115
|
}
|
|
@@ -3786,7 +4127,7 @@ function useFetch(url, ...args) {
|
|
|
3786
4127
|
return () => {
|
|
3787
4128
|
if (!isFetching.value) {
|
|
3788
4129
|
config.type = type;
|
|
3789
|
-
return __spreadProps$3(__spreadValues$
|
|
4130
|
+
return __spreadProps$3(__spreadValues$c({}, shell), {
|
|
3790
4131
|
then(onFulfilled, onRejected) {
|
|
3791
4132
|
return waitUntilFinished().then(onFulfilled, onRejected);
|
|
3792
4133
|
}
|
|
@@ -3797,7 +4138,7 @@ function useFetch(url, ...args) {
|
|
|
3797
4138
|
}
|
|
3798
4139
|
if (options.immediate)
|
|
3799
4140
|
setTimeout(execute, 0);
|
|
3800
|
-
return __spreadProps$3(__spreadValues$
|
|
4141
|
+
return __spreadProps$3(__spreadValues$c({}, shell), {
|
|
3801
4142
|
then(onFulfilled, onRejected) {
|
|
3802
4143
|
return waitUntilFinished().then(onFulfilled, onRejected);
|
|
3803
4144
|
}
|
|
@@ -3809,19 +4150,19 @@ function joinPaths(start, end) {
|
|
|
3809
4150
|
return `${start}${end}`;
|
|
3810
4151
|
}
|
|
3811
4152
|
|
|
3812
|
-
var __defProp$
|
|
3813
|
-
var __getOwnPropSymbols$
|
|
3814
|
-
var __hasOwnProp$
|
|
3815
|
-
var __propIsEnum$
|
|
3816
|
-
var __defNormalProp$
|
|
3817
|
-
var __spreadValues$
|
|
4153
|
+
var __defProp$b = Object.defineProperty;
|
|
4154
|
+
var __getOwnPropSymbols$c = Object.getOwnPropertySymbols;
|
|
4155
|
+
var __hasOwnProp$c = Object.prototype.hasOwnProperty;
|
|
4156
|
+
var __propIsEnum$c = Object.prototype.propertyIsEnumerable;
|
|
4157
|
+
var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4158
|
+
var __spreadValues$b = (a, b) => {
|
|
3818
4159
|
for (var prop in b || (b = {}))
|
|
3819
|
-
if (__hasOwnProp$
|
|
3820
|
-
__defNormalProp$
|
|
3821
|
-
if (__getOwnPropSymbols$
|
|
3822
|
-
for (var prop of __getOwnPropSymbols$
|
|
3823
|
-
if (__propIsEnum$
|
|
3824
|
-
__defNormalProp$
|
|
4160
|
+
if (__hasOwnProp$c.call(b, prop))
|
|
4161
|
+
__defNormalProp$b(a, prop, b[prop]);
|
|
4162
|
+
if (__getOwnPropSymbols$c)
|
|
4163
|
+
for (var prop of __getOwnPropSymbols$c(b)) {
|
|
4164
|
+
if (__propIsEnum$c.call(b, prop))
|
|
4165
|
+
__defNormalProp$b(a, prop, b[prop]);
|
|
3825
4166
|
}
|
|
3826
4167
|
return a;
|
|
3827
4168
|
};
|
|
@@ -3846,10 +4187,11 @@ function useFileDialog(options = {}) {
|
|
|
3846
4187
|
const open = (localOptions) => {
|
|
3847
4188
|
if (!input)
|
|
3848
4189
|
return;
|
|
3849
|
-
const _options = __spreadValues$
|
|
4190
|
+
const _options = __spreadValues$b(__spreadValues$b(__spreadValues$b({}, DEFAULT_OPTIONS), options), localOptions);
|
|
3850
4191
|
input.multiple = _options.multiple;
|
|
3851
4192
|
input.accept = _options.accept;
|
|
3852
|
-
|
|
4193
|
+
if (hasOwn(_options, "capture"))
|
|
4194
|
+
input.capture = _options.capture;
|
|
3853
4195
|
input.click();
|
|
3854
4196
|
};
|
|
3855
4197
|
const reset = () => {
|
|
@@ -3860,23 +4202,23 @@ function useFileDialog(options = {}) {
|
|
|
3860
4202
|
return {
|
|
3861
4203
|
files: readonly(files),
|
|
3862
4204
|
open,
|
|
3863
|
-
reset
|
|
3864
|
-
};
|
|
3865
|
-
}
|
|
3866
|
-
|
|
3867
|
-
var __defProp$
|
|
3868
|
-
var __getOwnPropSymbols$
|
|
3869
|
-
var __hasOwnProp$
|
|
3870
|
-
var __propIsEnum$
|
|
3871
|
-
var __defNormalProp$
|
|
3872
|
-
var __spreadValues$
|
|
4205
|
+
reset
|
|
4206
|
+
};
|
|
4207
|
+
}
|
|
4208
|
+
|
|
4209
|
+
var __defProp$a = Object.defineProperty;
|
|
4210
|
+
var __getOwnPropSymbols$b = Object.getOwnPropertySymbols;
|
|
4211
|
+
var __hasOwnProp$b = Object.prototype.hasOwnProperty;
|
|
4212
|
+
var __propIsEnum$b = Object.prototype.propertyIsEnumerable;
|
|
4213
|
+
var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4214
|
+
var __spreadValues$a = (a, b) => {
|
|
3873
4215
|
for (var prop in b || (b = {}))
|
|
3874
|
-
if (__hasOwnProp$
|
|
3875
|
-
__defNormalProp$
|
|
3876
|
-
if (__getOwnPropSymbols$
|
|
3877
|
-
for (var prop of __getOwnPropSymbols$
|
|
3878
|
-
if (__propIsEnum$
|
|
3879
|
-
__defNormalProp$
|
|
4216
|
+
if (__hasOwnProp$b.call(b, prop))
|
|
4217
|
+
__defNormalProp$a(a, prop, b[prop]);
|
|
4218
|
+
if (__getOwnPropSymbols$b)
|
|
4219
|
+
for (var prop of __getOwnPropSymbols$b(b)) {
|
|
4220
|
+
if (__propIsEnum$b.call(b, prop))
|
|
4221
|
+
__defNormalProp$a(a, prop, b[prop]);
|
|
3880
4222
|
}
|
|
3881
4223
|
return a;
|
|
3882
4224
|
};
|
|
@@ -3886,7 +4228,7 @@ function useFileSystemAccess(options = {}) {
|
|
|
3886
4228
|
dataType = "Text"
|
|
3887
4229
|
} = unref(options);
|
|
3888
4230
|
const window = _window;
|
|
3889
|
-
const isSupported =
|
|
4231
|
+
const isSupported = useSupported(() => window && "showSaveFilePicker" in window && "showOpenFilePicker" in window);
|
|
3890
4232
|
const fileHandle = ref();
|
|
3891
4233
|
const data = ref();
|
|
3892
4234
|
const file = ref();
|
|
@@ -3907,23 +4249,23 @@ function useFileSystemAccess(options = {}) {
|
|
|
3907
4249
|
return (_b = (_a = file.value) == null ? void 0 : _a.lastModified) != null ? _b : 0;
|
|
3908
4250
|
});
|
|
3909
4251
|
async function open(_options = {}) {
|
|
3910
|
-
if (!isSupported)
|
|
4252
|
+
if (!isSupported.value)
|
|
3911
4253
|
return;
|
|
3912
|
-
const [handle] = await window.showOpenFilePicker(__spreadValues$
|
|
4254
|
+
const [handle] = await window.showOpenFilePicker(__spreadValues$a(__spreadValues$a({}, unref(options)), _options));
|
|
3913
4255
|
fileHandle.value = handle;
|
|
3914
4256
|
await updateFile();
|
|
3915
4257
|
await updateData();
|
|
3916
4258
|
}
|
|
3917
4259
|
async function create(_options = {}) {
|
|
3918
|
-
if (!isSupported)
|
|
4260
|
+
if (!isSupported.value)
|
|
3919
4261
|
return;
|
|
3920
|
-
fileHandle.value = await window.showSaveFilePicker(__spreadValues$
|
|
4262
|
+
fileHandle.value = await window.showSaveFilePicker(__spreadValues$a(__spreadValues$a({}, unref(options)), _options));
|
|
3921
4263
|
data.value = void 0;
|
|
3922
4264
|
await updateFile();
|
|
3923
4265
|
await updateData();
|
|
3924
4266
|
}
|
|
3925
4267
|
async function save(_options = {}) {
|
|
3926
|
-
if (!isSupported)
|
|
4268
|
+
if (!isSupported.value)
|
|
3927
4269
|
return;
|
|
3928
4270
|
if (!fileHandle.value)
|
|
3929
4271
|
return saveAs(_options);
|
|
@@ -3935,9 +4277,9 @@ function useFileSystemAccess(options = {}) {
|
|
|
3935
4277
|
await updateFile();
|
|
3936
4278
|
}
|
|
3937
4279
|
async function saveAs(_options = {}) {
|
|
3938
|
-
if (!isSupported)
|
|
4280
|
+
if (!isSupported.value)
|
|
3939
4281
|
return;
|
|
3940
|
-
fileHandle.value = await window.showSaveFilePicker(__spreadValues$
|
|
4282
|
+
fileHandle.value = await window.showSaveFilePicker(__spreadValues$a(__spreadValues$a({}, unref(options)), _options));
|
|
3941
4283
|
if (data.value) {
|
|
3942
4284
|
const writableStream = await fileHandle.value.createWritable();
|
|
3943
4285
|
await writableStream.write(data.value);
|
|
@@ -4071,29 +4413,30 @@ function useFullscreen(target, options = {}) {
|
|
|
4071
4413
|
const { document = defaultDocument, autoExit = false } = options;
|
|
4072
4414
|
const targetRef = target || (document == null ? void 0 : document.querySelector("html"));
|
|
4073
4415
|
const isFullscreen = ref(false);
|
|
4074
|
-
let isSupported = false;
|
|
4075
4416
|
let map = functionsMap[0];
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4417
|
+
const isSupported = useSupported(() => {
|
|
4418
|
+
if (!document) {
|
|
4419
|
+
return false;
|
|
4420
|
+
} else {
|
|
4421
|
+
for (const m of functionsMap) {
|
|
4422
|
+
if (m[1] in document) {
|
|
4423
|
+
map = m;
|
|
4424
|
+
return true;
|
|
4425
|
+
}
|
|
4084
4426
|
}
|
|
4085
4427
|
}
|
|
4086
|
-
|
|
4428
|
+
return false;
|
|
4429
|
+
});
|
|
4087
4430
|
const [REQUEST, EXIT, ELEMENT, , EVENT] = map;
|
|
4088
4431
|
async function exit() {
|
|
4089
|
-
if (!isSupported)
|
|
4432
|
+
if (!isSupported.value)
|
|
4090
4433
|
return;
|
|
4091
4434
|
if (document == null ? void 0 : document[ELEMENT])
|
|
4092
4435
|
await document[EXIT]();
|
|
4093
4436
|
isFullscreen.value = false;
|
|
4094
4437
|
}
|
|
4095
4438
|
async function enter() {
|
|
4096
|
-
if (!isSupported)
|
|
4439
|
+
if (!isSupported.value)
|
|
4097
4440
|
return;
|
|
4098
4441
|
await exit();
|
|
4099
4442
|
const target2 = unrefElement(targetRef);
|
|
@@ -4171,7 +4514,7 @@ function useGamepad(options = {}) {
|
|
|
4171
4514
|
const {
|
|
4172
4515
|
navigator = defaultNavigator
|
|
4173
4516
|
} = options;
|
|
4174
|
-
const isSupported = navigator && "getGamepads" in navigator;
|
|
4517
|
+
const isSupported = useSupported(() => navigator && "getGamepads" in navigator);
|
|
4175
4518
|
const gamepads = ref([]);
|
|
4176
4519
|
const onConnectedHook = createEventHook();
|
|
4177
4520
|
const onDisconnectedHook = createEventHook();
|
|
@@ -4245,9 +4588,10 @@ function useGeolocation(options = {}) {
|
|
|
4245
4588
|
enableHighAccuracy = true,
|
|
4246
4589
|
maximumAge = 3e4,
|
|
4247
4590
|
timeout = 27e3,
|
|
4248
|
-
navigator = defaultNavigator
|
|
4591
|
+
navigator = defaultNavigator,
|
|
4592
|
+
immediate = true
|
|
4249
4593
|
} = options;
|
|
4250
|
-
const isSupported = navigator && "geolocation" in navigator;
|
|
4594
|
+
const isSupported = useSupported(() => navigator && "geolocation" in navigator);
|
|
4251
4595
|
const locatedAt = ref(null);
|
|
4252
4596
|
const error = ref(null);
|
|
4253
4597
|
const coords = ref({
|
|
@@ -4265,22 +4609,31 @@ function useGeolocation(options = {}) {
|
|
|
4265
4609
|
error.value = null;
|
|
4266
4610
|
}
|
|
4267
4611
|
let watcher;
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4612
|
+
function resume() {
|
|
4613
|
+
if (isSupported.value) {
|
|
4614
|
+
watcher = navigator.geolocation.watchPosition(updatePosition, (err) => error.value = err, {
|
|
4615
|
+
enableHighAccuracy,
|
|
4616
|
+
maximumAge,
|
|
4617
|
+
timeout
|
|
4618
|
+
});
|
|
4619
|
+
}
|
|
4274
4620
|
}
|
|
4275
|
-
|
|
4621
|
+
if (immediate)
|
|
4622
|
+
resume();
|
|
4623
|
+
function pause() {
|
|
4276
4624
|
if (watcher && navigator)
|
|
4277
4625
|
navigator.geolocation.clearWatch(watcher);
|
|
4626
|
+
}
|
|
4627
|
+
tryOnScopeDispose(() => {
|
|
4628
|
+
pause();
|
|
4278
4629
|
});
|
|
4279
4630
|
return {
|
|
4280
4631
|
isSupported,
|
|
4281
4632
|
coords,
|
|
4282
4633
|
locatedAt,
|
|
4283
|
-
error
|
|
4634
|
+
error,
|
|
4635
|
+
resume,
|
|
4636
|
+
pause
|
|
4284
4637
|
};
|
|
4285
4638
|
}
|
|
4286
4639
|
|
|
@@ -4318,19 +4671,19 @@ function useIdle(timeout = oneMinute, options = {}) {
|
|
|
4318
4671
|
return { idle, lastActive };
|
|
4319
4672
|
}
|
|
4320
4673
|
|
|
4321
|
-
var __defProp$
|
|
4322
|
-
var __getOwnPropSymbols$
|
|
4323
|
-
var __hasOwnProp$
|
|
4324
|
-
var __propIsEnum$
|
|
4325
|
-
var __defNormalProp$
|
|
4326
|
-
var __spreadValues$
|
|
4674
|
+
var __defProp$9 = Object.defineProperty;
|
|
4675
|
+
var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
|
|
4676
|
+
var __hasOwnProp$a = Object.prototype.hasOwnProperty;
|
|
4677
|
+
var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
|
|
4678
|
+
var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4679
|
+
var __spreadValues$9 = (a, b) => {
|
|
4327
4680
|
for (var prop in b || (b = {}))
|
|
4328
|
-
if (__hasOwnProp$
|
|
4329
|
-
__defNormalProp$
|
|
4330
|
-
if (__getOwnPropSymbols$
|
|
4331
|
-
for (var prop of __getOwnPropSymbols$
|
|
4332
|
-
if (__propIsEnum$
|
|
4333
|
-
__defNormalProp$
|
|
4681
|
+
if (__hasOwnProp$a.call(b, prop))
|
|
4682
|
+
__defNormalProp$9(a, prop, b[prop]);
|
|
4683
|
+
if (__getOwnPropSymbols$a)
|
|
4684
|
+
for (var prop of __getOwnPropSymbols$a(b)) {
|
|
4685
|
+
if (__propIsEnum$a.call(b, prop))
|
|
4686
|
+
__defNormalProp$9(a, prop, b[prop]);
|
|
4334
4687
|
}
|
|
4335
4688
|
return a;
|
|
4336
4689
|
};
|
|
@@ -4348,13 +4701,14 @@ async function loadImage(options) {
|
|
|
4348
4701
|
});
|
|
4349
4702
|
}
|
|
4350
4703
|
const useImage = (options, asyncStateOptions = {}) => {
|
|
4351
|
-
const state = useAsyncState(() => loadImage(
|
|
4704
|
+
const state = useAsyncState(() => loadImage(resolveUnref(options)), void 0, __spreadValues$9({
|
|
4352
4705
|
resetOnExecute: true
|
|
4353
4706
|
}, asyncStateOptions));
|
|
4354
|
-
watch(() =>
|
|
4707
|
+
watch(() => resolveUnref(options), () => state.execute(asyncStateOptions.delay), { deep: true });
|
|
4355
4708
|
return state;
|
|
4356
4709
|
};
|
|
4357
4710
|
|
|
4711
|
+
const ARRIVED_STATE_THRESHOLD_PIXELS = 1;
|
|
4358
4712
|
function useScroll(element, options = {}) {
|
|
4359
4713
|
const {
|
|
4360
4714
|
throttle = 0,
|
|
@@ -4370,10 +4724,38 @@ function useScroll(element, options = {}) {
|
|
|
4370
4724
|
eventListenerOptions = {
|
|
4371
4725
|
capture: false,
|
|
4372
4726
|
passive: true
|
|
4373
|
-
}
|
|
4727
|
+
},
|
|
4728
|
+
behavior = "auto"
|
|
4374
4729
|
} = options;
|
|
4375
|
-
const
|
|
4376
|
-
const
|
|
4730
|
+
const internalX = ref(0);
|
|
4731
|
+
const internalY = ref(0);
|
|
4732
|
+
const x = computed({
|
|
4733
|
+
get() {
|
|
4734
|
+
return internalX.value;
|
|
4735
|
+
},
|
|
4736
|
+
set(x2) {
|
|
4737
|
+
scrollTo(x2, void 0);
|
|
4738
|
+
}
|
|
4739
|
+
});
|
|
4740
|
+
const y = computed({
|
|
4741
|
+
get() {
|
|
4742
|
+
return internalY.value;
|
|
4743
|
+
},
|
|
4744
|
+
set(y2) {
|
|
4745
|
+
scrollTo(void 0, y2);
|
|
4746
|
+
}
|
|
4747
|
+
});
|
|
4748
|
+
function scrollTo(_x, _y) {
|
|
4749
|
+
var _a, _b, _c;
|
|
4750
|
+
const _element = resolveUnref(element);
|
|
4751
|
+
if (!_element)
|
|
4752
|
+
return;
|
|
4753
|
+
(_c = _element instanceof Document ? document.body : _element) == null ? void 0 : _c.scrollTo({
|
|
4754
|
+
top: (_a = resolveUnref(_y)) != null ? _a : y.value,
|
|
4755
|
+
left: (_b = resolveUnref(_x)) != null ? _b : x.value,
|
|
4756
|
+
behavior: resolveUnref(behavior)
|
|
4757
|
+
});
|
|
4758
|
+
}
|
|
4377
4759
|
const isScrolling = ref(false);
|
|
4378
4760
|
const arrivedState = reactive({
|
|
4379
4761
|
left: true,
|
|
@@ -4387,37 +4769,35 @@ function useScroll(element, options = {}) {
|
|
|
4387
4769
|
top: false,
|
|
4388
4770
|
bottom: false
|
|
4389
4771
|
});
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
const
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
useEventListener(element, "scroll", throttle ? useThrottleFn(onScrollHandler, throttle) : onScrollHandler, eventListenerOptions);
|
|
4420
|
-
}
|
|
4772
|
+
const onScrollEnd = useDebounceFn((e) => {
|
|
4773
|
+
isScrolling.value = false;
|
|
4774
|
+
directions.left = false;
|
|
4775
|
+
directions.right = false;
|
|
4776
|
+
directions.top = false;
|
|
4777
|
+
directions.bottom = false;
|
|
4778
|
+
onStop(e);
|
|
4779
|
+
}, throttle + idle);
|
|
4780
|
+
const onScrollHandler = (e) => {
|
|
4781
|
+
const eventTarget = e.target === document ? e.target.documentElement : e.target;
|
|
4782
|
+
const scrollLeft = eventTarget.scrollLeft;
|
|
4783
|
+
directions.left = scrollLeft < internalX.value;
|
|
4784
|
+
directions.right = scrollLeft > internalY.value;
|
|
4785
|
+
arrivedState.left = scrollLeft <= 0 + (offset.left || 0);
|
|
4786
|
+
arrivedState.right = scrollLeft + eventTarget.clientWidth >= eventTarget.scrollWidth - (offset.right || 0) - ARRIVED_STATE_THRESHOLD_PIXELS;
|
|
4787
|
+
internalX.value = scrollLeft;
|
|
4788
|
+
let scrollTop = eventTarget.scrollTop;
|
|
4789
|
+
if (e.target === document && !scrollTop)
|
|
4790
|
+
scrollTop = document.body.scrollTop;
|
|
4791
|
+
directions.top = scrollTop < internalY.value;
|
|
4792
|
+
directions.bottom = scrollTop > internalY.value;
|
|
4793
|
+
arrivedState.top = scrollTop <= 0 + (offset.top || 0);
|
|
4794
|
+
arrivedState.bottom = scrollTop + eventTarget.clientHeight >= eventTarget.scrollHeight - (offset.bottom || 0) - ARRIVED_STATE_THRESHOLD_PIXELS;
|
|
4795
|
+
internalY.value = scrollTop;
|
|
4796
|
+
isScrolling.value = true;
|
|
4797
|
+
onScrollEnd(e);
|
|
4798
|
+
onScroll(e);
|
|
4799
|
+
};
|
|
4800
|
+
useEventListener(element, "scroll", throttle ? useThrottleFn(onScrollHandler, throttle, true, false) : onScrollHandler, eventListenerOptions);
|
|
4421
4801
|
return {
|
|
4422
4802
|
x,
|
|
4423
4803
|
y,
|
|
@@ -4427,21 +4807,21 @@ function useScroll(element, options = {}) {
|
|
|
4427
4807
|
};
|
|
4428
4808
|
}
|
|
4429
4809
|
|
|
4430
|
-
var __defProp$
|
|
4810
|
+
var __defProp$8 = Object.defineProperty;
|
|
4431
4811
|
var __defProps$2 = Object.defineProperties;
|
|
4432
4812
|
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
4433
|
-
var __getOwnPropSymbols$
|
|
4434
|
-
var __hasOwnProp$
|
|
4435
|
-
var __propIsEnum$
|
|
4436
|
-
var __defNormalProp$
|
|
4437
|
-
var __spreadValues$
|
|
4813
|
+
var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
|
|
4814
|
+
var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
|
|
4815
|
+
var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
|
|
4816
|
+
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4817
|
+
var __spreadValues$8 = (a, b) => {
|
|
4438
4818
|
for (var prop in b || (b = {}))
|
|
4439
|
-
if (__hasOwnProp$
|
|
4440
|
-
__defNormalProp$
|
|
4441
|
-
if (__getOwnPropSymbols$
|
|
4442
|
-
for (var prop of __getOwnPropSymbols$
|
|
4443
|
-
if (__propIsEnum$
|
|
4444
|
-
__defNormalProp$
|
|
4819
|
+
if (__hasOwnProp$9.call(b, prop))
|
|
4820
|
+
__defNormalProp$8(a, prop, b[prop]);
|
|
4821
|
+
if (__getOwnPropSymbols$9)
|
|
4822
|
+
for (var prop of __getOwnPropSymbols$9(b)) {
|
|
4823
|
+
if (__propIsEnum$9.call(b, prop))
|
|
4824
|
+
__defNormalProp$8(a, prop, b[prop]);
|
|
4445
4825
|
}
|
|
4446
4826
|
return a;
|
|
4447
4827
|
};
|
|
@@ -4449,15 +4829,15 @@ var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
|
|
4449
4829
|
function useInfiniteScroll(element, onLoadMore, options = {}) {
|
|
4450
4830
|
var _a, _b;
|
|
4451
4831
|
const direction = (_a = options.direction) != null ? _a : "bottom";
|
|
4452
|
-
const state = reactive(useScroll(element, __spreadProps$2(__spreadValues$
|
|
4453
|
-
offset: __spreadValues$
|
|
4832
|
+
const state = reactive(useScroll(element, __spreadProps$2(__spreadValues$8({}, options), {
|
|
4833
|
+
offset: __spreadValues$8({
|
|
4454
4834
|
[direction]: (_b = options.distance) != null ? _b : 0
|
|
4455
4835
|
}, options.offset)
|
|
4456
4836
|
})));
|
|
4457
4837
|
watch(() => state.arrivedState[direction], async (v) => {
|
|
4458
4838
|
var _a2, _b2;
|
|
4459
4839
|
if (v) {
|
|
4460
|
-
const elem =
|
|
4840
|
+
const elem = resolveUnref(element);
|
|
4461
4841
|
const previous = {
|
|
4462
4842
|
height: (_a2 = elem == null ? void 0 : elem.scrollHeight) != null ? _a2 : 0,
|
|
4463
4843
|
width: (_b2 = elem == null ? void 0 : elem.scrollWidth) != null ? _b2 : 0
|
|
@@ -4482,9 +4862,9 @@ function useIntersectionObserver(target, callback, options = {}) {
|
|
|
4482
4862
|
threshold = 0.1,
|
|
4483
4863
|
window = defaultWindow
|
|
4484
4864
|
} = options;
|
|
4485
|
-
const isSupported = window && "IntersectionObserver" in window;
|
|
4865
|
+
const isSupported = useSupported(() => window && "IntersectionObserver" in window);
|
|
4486
4866
|
let cleanup = noop;
|
|
4487
|
-
const stopWatch = isSupported ? watch(() => ({
|
|
4867
|
+
const stopWatch = isSupported.value ? watch(() => ({
|
|
4488
4868
|
el: unrefElement(target),
|
|
4489
4869
|
root: unrefElement(root)
|
|
4490
4870
|
}), ({ el, root: root2 }) => {
|
|
@@ -4557,9 +4937,12 @@ function useMagicKeys(options = {}) {
|
|
|
4557
4937
|
onEventFired = noop
|
|
4558
4938
|
} = options;
|
|
4559
4939
|
const current = reactive(new Set());
|
|
4560
|
-
const obj = {
|
|
4561
|
-
|
|
4562
|
-
|
|
4940
|
+
const obj = {
|
|
4941
|
+
toJSON() {
|
|
4942
|
+
return {};
|
|
4943
|
+
},
|
|
4944
|
+
current
|
|
4945
|
+
};
|
|
4563
4946
|
const refs = useReactive ? reactive(obj) : obj;
|
|
4564
4947
|
const metaDeps = new Set();
|
|
4565
4948
|
const usedKeys = new Set();
|
|
@@ -4572,6 +4955,7 @@ function useMagicKeys(options = {}) {
|
|
|
4572
4955
|
}
|
|
4573
4956
|
}
|
|
4574
4957
|
function reset() {
|
|
4958
|
+
current.clear();
|
|
4575
4959
|
for (const key of usedKeys)
|
|
4576
4960
|
setRefs(key, false);
|
|
4577
4961
|
}
|
|
@@ -4580,11 +4964,11 @@ function useMagicKeys(options = {}) {
|
|
|
4580
4964
|
const key = (_a = e.key) == null ? void 0 : _a.toLowerCase();
|
|
4581
4965
|
const code = (_b = e.code) == null ? void 0 : _b.toLowerCase();
|
|
4582
4966
|
const values = [code, key].filter(Boolean);
|
|
4583
|
-
if (
|
|
4967
|
+
if (key) {
|
|
4584
4968
|
if (value)
|
|
4585
|
-
current.add(
|
|
4969
|
+
current.add(key);
|
|
4586
4970
|
else
|
|
4587
|
-
current.delete(
|
|
4971
|
+
current.delete(key);
|
|
4588
4972
|
}
|
|
4589
4973
|
for (const key2 of values) {
|
|
4590
4974
|
usedKeys.add(key2);
|
|
@@ -4600,18 +4984,16 @@ function useMagicKeys(options = {}) {
|
|
|
4600
4984
|
[...current, ...values].forEach((key2) => metaDeps.add(key2));
|
|
4601
4985
|
}
|
|
4602
4986
|
}
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
useEventListener("focus", reset, { passive: true });
|
|
4614
|
-
}
|
|
4987
|
+
useEventListener(target, "keydown", (e) => {
|
|
4988
|
+
updateRefs(e, true);
|
|
4989
|
+
return onEventFired(e);
|
|
4990
|
+
}, { passive });
|
|
4991
|
+
useEventListener(target, "keyup", (e) => {
|
|
4992
|
+
updateRefs(e, false);
|
|
4993
|
+
return onEventFired(e);
|
|
4994
|
+
}, { passive });
|
|
4995
|
+
useEventListener("blur", reset, { passive: true });
|
|
4996
|
+
useEventListener("focus", reset, { passive: true });
|
|
4615
4997
|
const proxy = new Proxy(refs, {
|
|
4616
4998
|
get(target2, prop, rec) {
|
|
4617
4999
|
if (typeof prop !== "string")
|
|
@@ -4634,25 +5016,25 @@ function useMagicKeys(options = {}) {
|
|
|
4634
5016
|
return proxy;
|
|
4635
5017
|
}
|
|
4636
5018
|
|
|
4637
|
-
var __defProp$
|
|
4638
|
-
var __getOwnPropSymbols$
|
|
4639
|
-
var __hasOwnProp$
|
|
4640
|
-
var __propIsEnum$
|
|
4641
|
-
var __defNormalProp$
|
|
4642
|
-
var __spreadValues$
|
|
5019
|
+
var __defProp$7 = Object.defineProperty;
|
|
5020
|
+
var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
|
|
5021
|
+
var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
|
|
5022
|
+
var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
|
|
5023
|
+
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5024
|
+
var __spreadValues$7 = (a, b) => {
|
|
4643
5025
|
for (var prop in b || (b = {}))
|
|
4644
|
-
if (__hasOwnProp$
|
|
4645
|
-
__defNormalProp$
|
|
4646
|
-
if (__getOwnPropSymbols$
|
|
4647
|
-
for (var prop of __getOwnPropSymbols$
|
|
4648
|
-
if (__propIsEnum$
|
|
4649
|
-
__defNormalProp$
|
|
5026
|
+
if (__hasOwnProp$8.call(b, prop))
|
|
5027
|
+
__defNormalProp$7(a, prop, b[prop]);
|
|
5028
|
+
if (__getOwnPropSymbols$8)
|
|
5029
|
+
for (var prop of __getOwnPropSymbols$8(b)) {
|
|
5030
|
+
if (__propIsEnum$8.call(b, prop))
|
|
5031
|
+
__defNormalProp$7(a, prop, b[prop]);
|
|
4650
5032
|
}
|
|
4651
5033
|
return a;
|
|
4652
5034
|
};
|
|
4653
5035
|
function usingElRef(source, cb) {
|
|
4654
|
-
if (
|
|
4655
|
-
cb(
|
|
5036
|
+
if (resolveUnref(source))
|
|
5037
|
+
cb(resolveUnref(source));
|
|
4656
5038
|
}
|
|
4657
5039
|
function timeRangeToArray(timeRanges) {
|
|
4658
5040
|
let ranges = [];
|
|
@@ -4668,7 +5050,7 @@ const defaultOptions = {
|
|
|
4668
5050
|
tracks: []
|
|
4669
5051
|
};
|
|
4670
5052
|
function useMediaControls(target, options = {}) {
|
|
4671
|
-
options = __spreadValues$
|
|
5053
|
+
options = __spreadValues$7(__spreadValues$7({}, defaultOptions), options);
|
|
4672
5054
|
const {
|
|
4673
5055
|
document = defaultDocument
|
|
4674
5056
|
} = options;
|
|
@@ -4725,10 +5107,10 @@ function useMediaControls(target, options = {}) {
|
|
|
4725
5107
|
watchEffect(() => {
|
|
4726
5108
|
if (!document)
|
|
4727
5109
|
return;
|
|
4728
|
-
const el =
|
|
5110
|
+
const el = resolveUnref(target);
|
|
4729
5111
|
if (!el)
|
|
4730
5112
|
return;
|
|
4731
|
-
const src =
|
|
5113
|
+
const src = resolveUnref(options.src);
|
|
4732
5114
|
let sources = [];
|
|
4733
5115
|
if (!src)
|
|
4734
5116
|
return;
|
|
@@ -4752,25 +5134,25 @@ function useMediaControls(target, options = {}) {
|
|
|
4752
5134
|
el.load();
|
|
4753
5135
|
});
|
|
4754
5136
|
tryOnScopeDispose(() => {
|
|
4755
|
-
const el =
|
|
5137
|
+
const el = resolveUnref(target);
|
|
4756
5138
|
if (!el)
|
|
4757
5139
|
return;
|
|
4758
5140
|
el.querySelectorAll("source").forEach((e) => e.removeEventListener("error", sourceErrorEvent.trigger));
|
|
4759
5141
|
});
|
|
4760
5142
|
watch(volume, (vol) => {
|
|
4761
|
-
const el =
|
|
5143
|
+
const el = resolveUnref(target);
|
|
4762
5144
|
if (!el)
|
|
4763
5145
|
return;
|
|
4764
5146
|
el.volume = vol;
|
|
4765
5147
|
});
|
|
4766
5148
|
watch(muted, (mute) => {
|
|
4767
|
-
const el =
|
|
5149
|
+
const el = resolveUnref(target);
|
|
4768
5150
|
if (!el)
|
|
4769
5151
|
return;
|
|
4770
5152
|
el.muted = mute;
|
|
4771
5153
|
});
|
|
4772
5154
|
watch(rate, (rate2) => {
|
|
4773
|
-
const el =
|
|
5155
|
+
const el = resolveUnref(target);
|
|
4774
5156
|
if (!el)
|
|
4775
5157
|
return;
|
|
4776
5158
|
el.playbackRate = rate2;
|
|
@@ -4778,8 +5160,8 @@ function useMediaControls(target, options = {}) {
|
|
|
4778
5160
|
watchEffect(() => {
|
|
4779
5161
|
if (!document)
|
|
4780
5162
|
return;
|
|
4781
|
-
const textTracks =
|
|
4782
|
-
const el =
|
|
5163
|
+
const textTracks = resolveUnref(options.tracks);
|
|
5164
|
+
const el = resolveUnref(target);
|
|
4783
5165
|
if (!textTracks || !textTracks.length || !el)
|
|
4784
5166
|
return;
|
|
4785
5167
|
el.querySelectorAll("track").forEach((e) => e.remove());
|
|
@@ -4796,25 +5178,28 @@ function useMediaControls(target, options = {}) {
|
|
|
4796
5178
|
});
|
|
4797
5179
|
});
|
|
4798
5180
|
const { ignoreUpdates: ignoreCurrentTimeUpdates } = watchIgnorable(currentTime, (time) => {
|
|
4799
|
-
const el =
|
|
5181
|
+
const el = resolveUnref(target);
|
|
4800
5182
|
if (!el)
|
|
4801
5183
|
return;
|
|
4802
5184
|
el.currentTime = time;
|
|
4803
5185
|
});
|
|
4804
5186
|
const { ignoreUpdates: ignorePlayingUpdates } = watchIgnorable(playing, (isPlaying) => {
|
|
4805
|
-
const el =
|
|
5187
|
+
const el = resolveUnref(target);
|
|
4806
5188
|
if (!el)
|
|
4807
5189
|
return;
|
|
4808
5190
|
isPlaying ? el.play() : el.pause();
|
|
4809
5191
|
});
|
|
4810
|
-
useEventListener(target, "timeupdate", () => ignoreCurrentTimeUpdates(() => currentTime.value =
|
|
4811
|
-
useEventListener(target, "durationchange", () => duration.value =
|
|
4812
|
-
useEventListener(target, "progress", () => buffered.value = timeRangeToArray(
|
|
5192
|
+
useEventListener(target, "timeupdate", () => ignoreCurrentTimeUpdates(() => currentTime.value = resolveUnref(target).currentTime));
|
|
5193
|
+
useEventListener(target, "durationchange", () => duration.value = resolveUnref(target).duration);
|
|
5194
|
+
useEventListener(target, "progress", () => buffered.value = timeRangeToArray(resolveUnref(target).buffered));
|
|
4813
5195
|
useEventListener(target, "seeking", () => seeking.value = true);
|
|
4814
5196
|
useEventListener(target, "seeked", () => seeking.value = false);
|
|
4815
5197
|
useEventListener(target, "waiting", () => waiting.value = true);
|
|
4816
|
-
useEventListener(target, "playing", () =>
|
|
4817
|
-
|
|
5198
|
+
useEventListener(target, "playing", () => {
|
|
5199
|
+
waiting.value = false;
|
|
5200
|
+
ended.value = false;
|
|
5201
|
+
});
|
|
5202
|
+
useEventListener(target, "ratechange", () => rate.value = resolveUnref(target).playbackRate);
|
|
4818
5203
|
useEventListener(target, "stalled", () => stalled.value = true);
|
|
4819
5204
|
useEventListener(target, "ended", () => ended.value = true);
|
|
4820
5205
|
useEventListener(target, "pause", () => ignorePlayingUpdates(() => playing.value = false));
|
|
@@ -4822,7 +5207,7 @@ function useMediaControls(target, options = {}) {
|
|
|
4822
5207
|
useEventListener(target, "enterpictureinpicture", () => isPictureInPicture.value = true);
|
|
4823
5208
|
useEventListener(target, "leavepictureinpicture", () => isPictureInPicture.value = false);
|
|
4824
5209
|
useEventListener(target, "volumechange", () => {
|
|
4825
|
-
const el =
|
|
5210
|
+
const el = resolveUnref(target);
|
|
4826
5211
|
if (!el)
|
|
4827
5212
|
return;
|
|
4828
5213
|
volume.value = el.volume;
|
|
@@ -4830,7 +5215,7 @@ function useMediaControls(target, options = {}) {
|
|
|
4830
5215
|
});
|
|
4831
5216
|
const listeners = [];
|
|
4832
5217
|
const stop = watch([target], () => {
|
|
4833
|
-
const el =
|
|
5218
|
+
const el = resolveUnref(target);
|
|
4834
5219
|
if (!el)
|
|
4835
5220
|
return;
|
|
4836
5221
|
stop();
|
|
@@ -4867,7 +5252,7 @@ const getMapVue2Compat = () => {
|
|
|
4867
5252
|
return {
|
|
4868
5253
|
get: (key) => data[key],
|
|
4869
5254
|
set: (key, value) => set$1(data, key, value),
|
|
4870
|
-
has: (key) =>
|
|
5255
|
+
has: (key) => hasOwn(data, key),
|
|
4871
5256
|
delete: (key) => del(data, key),
|
|
4872
5257
|
clear: () => {
|
|
4873
5258
|
Object.keys(data).forEach((key) => {
|
|
@@ -4913,8 +5298,8 @@ function useMemoize(resolver, options) {
|
|
|
4913
5298
|
|
|
4914
5299
|
function useMemory(options = {}) {
|
|
4915
5300
|
const memory = ref();
|
|
4916
|
-
const isSupported = typeof performance !== "undefined" && "memory" in performance;
|
|
4917
|
-
if (isSupported) {
|
|
5301
|
+
const isSupported = useSupported(() => typeof performance !== "undefined" && "memory" in performance);
|
|
5302
|
+
if (isSupported.value) {
|
|
4918
5303
|
const { interval = 1e3 } = options;
|
|
4919
5304
|
useIntervalFn(() => {
|
|
4920
5305
|
memory.value = performance.memory;
|
|
@@ -4950,6 +5335,9 @@ function useMouse(options = {}) {
|
|
|
4950
5335
|
} else if (type === "client") {
|
|
4951
5336
|
x.value = event.clientX;
|
|
4952
5337
|
y.value = event.clientY;
|
|
5338
|
+
} else if (type === "movement") {
|
|
5339
|
+
x.value = event.movementX;
|
|
5340
|
+
y.value = event.movementY;
|
|
4953
5341
|
}
|
|
4954
5342
|
sourceType.value = "mouse";
|
|
4955
5343
|
};
|
|
@@ -4979,7 +5367,7 @@ function useMouse(options = {}) {
|
|
|
4979
5367
|
if (window) {
|
|
4980
5368
|
useEventListener(window, "mousemove", mouseHandlerWrapper, { passive: true });
|
|
4981
5369
|
useEventListener(window, "dragover", mouseHandlerWrapper, { passive: true });
|
|
4982
|
-
if (touch) {
|
|
5370
|
+
if (touch && type !== "movement") {
|
|
4983
5371
|
useEventListener(window, "touchstart", touchHandlerWrapper, { passive: true });
|
|
4984
5372
|
useEventListener(window, "touchmove", touchHandlerWrapper, { passive: true });
|
|
4985
5373
|
if (resetOnTouchEnds)
|
|
@@ -5032,6 +5420,9 @@ function useMouseInElement(target, options = {}) {
|
|
|
5032
5420
|
elementY.value = elY;
|
|
5033
5421
|
}
|
|
5034
5422
|
}, { immediate: true });
|
|
5423
|
+
useEventListener(document, "mouseleave", () => {
|
|
5424
|
+
isOutside.value = true;
|
|
5425
|
+
});
|
|
5035
5426
|
}
|
|
5036
5427
|
return {
|
|
5037
5428
|
x,
|
|
@@ -5091,17 +5482,17 @@ function useMousePressed(options = {}) {
|
|
|
5091
5482
|
};
|
|
5092
5483
|
}
|
|
5093
5484
|
|
|
5094
|
-
var __getOwnPropSymbols$
|
|
5095
|
-
var __hasOwnProp$
|
|
5096
|
-
var __propIsEnum$
|
|
5485
|
+
var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
|
|
5486
|
+
var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
|
|
5487
|
+
var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
|
|
5097
5488
|
var __objRest$1 = (source, exclude) => {
|
|
5098
5489
|
var target = {};
|
|
5099
5490
|
for (var prop in source)
|
|
5100
|
-
if (__hasOwnProp$
|
|
5491
|
+
if (__hasOwnProp$7.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
5101
5492
|
target[prop] = source[prop];
|
|
5102
|
-
if (source != null && __getOwnPropSymbols$
|
|
5103
|
-
for (var prop of __getOwnPropSymbols$
|
|
5104
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
5493
|
+
if (source != null && __getOwnPropSymbols$7)
|
|
5494
|
+
for (var prop of __getOwnPropSymbols$7(source)) {
|
|
5495
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$7.call(source, prop))
|
|
5105
5496
|
target[prop] = source[prop];
|
|
5106
5497
|
}
|
|
5107
5498
|
return target;
|
|
@@ -5109,7 +5500,7 @@ var __objRest$1 = (source, exclude) => {
|
|
|
5109
5500
|
function useMutationObserver(target, callback, options = {}) {
|
|
5110
5501
|
const _a = options, { window = defaultWindow } = _a, mutationOptions = __objRest$1(_a, ["window"]);
|
|
5111
5502
|
let observer;
|
|
5112
|
-
const isSupported = window && "MutationObserver" in window;
|
|
5503
|
+
const isSupported = useSupported(() => window && "MutationObserver" in window);
|
|
5113
5504
|
const cleanup = () => {
|
|
5114
5505
|
if (observer) {
|
|
5115
5506
|
observer.disconnect();
|
|
@@ -5118,7 +5509,7 @@ function useMutationObserver(target, callback, options = {}) {
|
|
|
5118
5509
|
};
|
|
5119
5510
|
const stopWatch = watch(() => unrefElement(target), (el) => {
|
|
5120
5511
|
cleanup();
|
|
5121
|
-
if (isSupported && window && el) {
|
|
5512
|
+
if (isSupported.value && window && el) {
|
|
5122
5513
|
observer = new MutationObserver(callback);
|
|
5123
5514
|
observer.observe(el, mutationOptions);
|
|
5124
5515
|
}
|
|
@@ -5137,7 +5528,7 @@ function useMutationObserver(target, callback, options = {}) {
|
|
|
5137
5528
|
const useNavigatorLanguage = (options = {}) => {
|
|
5138
5529
|
const { window = defaultWindow } = options;
|
|
5139
5530
|
const navigator = window == null ? void 0 : window.navigator;
|
|
5140
|
-
const isSupported =
|
|
5531
|
+
const isSupported = useSupported(() => navigator && "language" in navigator);
|
|
5141
5532
|
const language = ref(navigator == null ? void 0 : navigator.language);
|
|
5142
5533
|
useEventListener(window, "languagechange", () => {
|
|
5143
5534
|
if (navigator)
|
|
@@ -5152,7 +5543,7 @@ const useNavigatorLanguage = (options = {}) => {
|
|
|
5152
5543
|
function useNetwork(options = {}) {
|
|
5153
5544
|
const { window = defaultWindow } = options;
|
|
5154
5545
|
const navigator = window == null ? void 0 : window.navigator;
|
|
5155
|
-
const isSupported =
|
|
5546
|
+
const isSupported = useSupported(() => navigator && "connection" in navigator);
|
|
5156
5547
|
const isOnline = ref(true);
|
|
5157
5548
|
const saveData = ref(false);
|
|
5158
5549
|
const offlineAt = ref(void 0);
|
|
@@ -5162,7 +5553,7 @@ function useNetwork(options = {}) {
|
|
|
5162
5553
|
const rtt = ref(void 0);
|
|
5163
5554
|
const effectiveType = ref(void 0);
|
|
5164
5555
|
const type = ref("unknown");
|
|
5165
|
-
const connection = isSupported && navigator.connection;
|
|
5556
|
+
const connection = isSupported.value && navigator.connection;
|
|
5166
5557
|
function updateNetworkInformation() {
|
|
5167
5558
|
if (!navigator)
|
|
5168
5559
|
return;
|
|
@@ -5205,19 +5596,19 @@ function useNetwork(options = {}) {
|
|
|
5205
5596
|
};
|
|
5206
5597
|
}
|
|
5207
5598
|
|
|
5208
|
-
var __defProp$
|
|
5209
|
-
var __getOwnPropSymbols$
|
|
5210
|
-
var __hasOwnProp$
|
|
5211
|
-
var __propIsEnum$
|
|
5212
|
-
var __defNormalProp$
|
|
5213
|
-
var __spreadValues$
|
|
5599
|
+
var __defProp$6 = Object.defineProperty;
|
|
5600
|
+
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
|
5601
|
+
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
|
5602
|
+
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
|
5603
|
+
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5604
|
+
var __spreadValues$6 = (a, b) => {
|
|
5214
5605
|
for (var prop in b || (b = {}))
|
|
5215
|
-
if (__hasOwnProp$
|
|
5216
|
-
__defNormalProp$
|
|
5217
|
-
if (__getOwnPropSymbols$
|
|
5218
|
-
for (var prop of __getOwnPropSymbols$
|
|
5219
|
-
if (__propIsEnum$
|
|
5220
|
-
__defNormalProp$
|
|
5606
|
+
if (__hasOwnProp$6.call(b, prop))
|
|
5607
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
5608
|
+
if (__getOwnPropSymbols$6)
|
|
5609
|
+
for (var prop of __getOwnPropSymbols$6(b)) {
|
|
5610
|
+
if (__propIsEnum$6.call(b, prop))
|
|
5611
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
5221
5612
|
}
|
|
5222
5613
|
return a;
|
|
5223
5614
|
};
|
|
@@ -5230,7 +5621,7 @@ function useNow(options = {}) {
|
|
|
5230
5621
|
const update = () => now.value = new Date();
|
|
5231
5622
|
const controls = interval === "requestAnimationFrame" ? useRafFn(update, { immediate: true }) : useIntervalFn(update, interval, { immediate: true });
|
|
5232
5623
|
if (exposeControls) {
|
|
5233
|
-
return __spreadValues$
|
|
5624
|
+
return __spreadValues$6({
|
|
5234
5625
|
now
|
|
5235
5626
|
}, controls);
|
|
5236
5627
|
} else {
|
|
@@ -5254,6 +5645,18 @@ function useObjectUrl(object) {
|
|
|
5254
5645
|
return readonly(url);
|
|
5255
5646
|
}
|
|
5256
5647
|
|
|
5648
|
+
function useClamp(value, min, max) {
|
|
5649
|
+
const _value = ref(value);
|
|
5650
|
+
return computed({
|
|
5651
|
+
get() {
|
|
5652
|
+
return _value.value = clamp(_value.value, resolveUnref(min), resolveUnref(max));
|
|
5653
|
+
},
|
|
5654
|
+
set(value2) {
|
|
5655
|
+
_value.value = clamp(value2, resolveUnref(min), resolveUnref(max));
|
|
5656
|
+
}
|
|
5657
|
+
});
|
|
5658
|
+
}
|
|
5659
|
+
|
|
5257
5660
|
function useOffsetPagination(options) {
|
|
5258
5661
|
const {
|
|
5259
5662
|
total = Infinity,
|
|
@@ -5264,7 +5667,7 @@ function useOffsetPagination(options) {
|
|
|
5264
5667
|
onPageCountChange = noop
|
|
5265
5668
|
} = options;
|
|
5266
5669
|
const currentPageSize = useClamp(pageSize, 1, Infinity);
|
|
5267
|
-
const pageCount = computed(() => Math.ceil(unref(total) / unref(currentPageSize)));
|
|
5670
|
+
const pageCount = computed(() => Math.max(1, Math.ceil(unref(total) / unref(currentPageSize))));
|
|
5268
5671
|
const currentPage = useClamp(page, 1, pageCount);
|
|
5269
5672
|
const isFirstPage = computed(() => currentPage.value === 1);
|
|
5270
5673
|
const isLastPage = computed(() => currentPage.value === pageCount.value);
|
|
@@ -5363,21 +5766,21 @@ function useParallax(target, options = {}) {
|
|
|
5363
5766
|
return { roll, tilt, source };
|
|
5364
5767
|
}
|
|
5365
5768
|
|
|
5366
|
-
var __defProp$
|
|
5769
|
+
var __defProp$5 = Object.defineProperty;
|
|
5367
5770
|
var __defProps$1 = Object.defineProperties;
|
|
5368
5771
|
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
5369
|
-
var __getOwnPropSymbols$
|
|
5370
|
-
var __hasOwnProp$
|
|
5371
|
-
var __propIsEnum$
|
|
5372
|
-
var __defNormalProp$
|
|
5373
|
-
var __spreadValues$
|
|
5772
|
+
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
5773
|
+
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
5774
|
+
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
5775
|
+
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5776
|
+
var __spreadValues$5 = (a, b) => {
|
|
5374
5777
|
for (var prop in b || (b = {}))
|
|
5375
|
-
if (__hasOwnProp$
|
|
5376
|
-
__defNormalProp$
|
|
5377
|
-
if (__getOwnPropSymbols$
|
|
5378
|
-
for (var prop of __getOwnPropSymbols$
|
|
5379
|
-
if (__propIsEnum$
|
|
5380
|
-
__defNormalProp$
|
|
5778
|
+
if (__hasOwnProp$5.call(b, prop))
|
|
5779
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
5780
|
+
if (__getOwnPropSymbols$5)
|
|
5781
|
+
for (var prop of __getOwnPropSymbols$5(b)) {
|
|
5782
|
+
if (__propIsEnum$5.call(b, prop))
|
|
5783
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
5381
5784
|
}
|
|
5382
5785
|
return a;
|
|
5383
5786
|
};
|
|
@@ -5413,11 +5816,63 @@ function usePointer(options = {}) {
|
|
|
5413
5816
|
useEventListener(target, "pointermove", handler, { passive: true });
|
|
5414
5817
|
useEventListener(target, "pointerleave", () => isInside.value = false, { passive: true });
|
|
5415
5818
|
}
|
|
5416
|
-
return __spreadProps$1(__spreadValues$
|
|
5819
|
+
return __spreadProps$1(__spreadValues$5({}, toRefs(state)), {
|
|
5417
5820
|
isInside
|
|
5418
5821
|
});
|
|
5419
5822
|
}
|
|
5420
5823
|
|
|
5824
|
+
function usePointerLock(target, options = {}) {
|
|
5825
|
+
const { document = defaultDocument, pointerLockOptions } = options;
|
|
5826
|
+
const isSupported = useSupported(() => document && "pointerLockElement" in document);
|
|
5827
|
+
const element = ref();
|
|
5828
|
+
const triggerElement = ref();
|
|
5829
|
+
let targetElement;
|
|
5830
|
+
if (isSupported.value) {
|
|
5831
|
+
useEventListener(document, "pointerlockchange", () => {
|
|
5832
|
+
var _a;
|
|
5833
|
+
const currentElement = (_a = document.pointerLockElement) != null ? _a : element.value;
|
|
5834
|
+
if (targetElement && currentElement === targetElement) {
|
|
5835
|
+
element.value = document.pointerLockElement;
|
|
5836
|
+
if (!element.value)
|
|
5837
|
+
targetElement = triggerElement.value = null;
|
|
5838
|
+
}
|
|
5839
|
+
});
|
|
5840
|
+
useEventListener(document, "pointerlockerror", () => {
|
|
5841
|
+
var _a;
|
|
5842
|
+
const currentElement = (_a = document.pointerLockElement) != null ? _a : element.value;
|
|
5843
|
+
if (targetElement && currentElement === targetElement) {
|
|
5844
|
+
const action = document.pointerLockElement ? "release" : "acquire";
|
|
5845
|
+
throw new Error(`Failed to ${action} pointer lock.`);
|
|
5846
|
+
}
|
|
5847
|
+
});
|
|
5848
|
+
}
|
|
5849
|
+
async function lock(e, options2) {
|
|
5850
|
+
var _a;
|
|
5851
|
+
if (!isSupported.value)
|
|
5852
|
+
throw new Error("Pointer Lock API is not supported by your browser.");
|
|
5853
|
+
triggerElement.value = e instanceof Event ? e.currentTarget : null;
|
|
5854
|
+
targetElement = e instanceof Event ? (_a = unrefElement(target)) != null ? _a : triggerElement.value : unrefElement(e);
|
|
5855
|
+
if (!targetElement)
|
|
5856
|
+
throw new Error("Target element undefined.");
|
|
5857
|
+
targetElement.requestPointerLock(options2 != null ? options2 : pointerLockOptions);
|
|
5858
|
+
return await until(element).toBe(targetElement);
|
|
5859
|
+
}
|
|
5860
|
+
async function unlock() {
|
|
5861
|
+
if (!element.value)
|
|
5862
|
+
return false;
|
|
5863
|
+
document.exitPointerLock();
|
|
5864
|
+
await until(element).toBeNull();
|
|
5865
|
+
return true;
|
|
5866
|
+
}
|
|
5867
|
+
return {
|
|
5868
|
+
isSupported,
|
|
5869
|
+
element,
|
|
5870
|
+
triggerElement,
|
|
5871
|
+
lock,
|
|
5872
|
+
unlock
|
|
5873
|
+
};
|
|
5874
|
+
}
|
|
5875
|
+
|
|
5421
5876
|
var SwipeDirection;
|
|
5422
5877
|
(function(SwipeDirection2) {
|
|
5423
5878
|
SwipeDirection2["UP"] = "UP";
|
|
@@ -5519,7 +5974,7 @@ function checkPassiveEventSupport(document) {
|
|
|
5519
5974
|
}
|
|
5520
5975
|
|
|
5521
5976
|
function usePointerSwipe(target, options = {}) {
|
|
5522
|
-
const targetRef =
|
|
5977
|
+
const targetRef = resolveRef(target);
|
|
5523
5978
|
const {
|
|
5524
5979
|
threshold = 50,
|
|
5525
5980
|
onSwipe,
|
|
@@ -5551,15 +6006,16 @@ function usePointerSwipe(target, options = {}) {
|
|
|
5551
6006
|
return distanceY.value > 0 ? SwipeDirection.UP : SwipeDirection.DOWN;
|
|
5552
6007
|
}
|
|
5553
6008
|
});
|
|
5554
|
-
const
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
|
|
6009
|
+
const eventIsAllowed = (e) => {
|
|
6010
|
+
var _a, _b, _c;
|
|
6011
|
+
const isReleasingButton = e.buttons === 0;
|
|
6012
|
+
const isPrimaryButton = e.buttons === 1;
|
|
6013
|
+
return (_c = (_b = (_a = options.pointerTypes) == null ? void 0 : _a.includes(e.pointerType)) != null ? _b : isReleasingButton || isPrimaryButton) != null ? _c : true;
|
|
5558
6014
|
};
|
|
5559
6015
|
const stops = [
|
|
5560
6016
|
useEventListener(target, "pointerdown", (e) => {
|
|
5561
6017
|
var _a, _b;
|
|
5562
|
-
if (!
|
|
6018
|
+
if (!eventIsAllowed(e))
|
|
5563
6019
|
return;
|
|
5564
6020
|
isPointerDown.value = true;
|
|
5565
6021
|
(_b = (_a = targetRef.value) == null ? void 0 : _a.style) == null ? void 0 : _b.setProperty("touch-action", "none");
|
|
@@ -5571,7 +6027,7 @@ function usePointerSwipe(target, options = {}) {
|
|
|
5571
6027
|
onSwipeStart == null ? void 0 : onSwipeStart(e);
|
|
5572
6028
|
}),
|
|
5573
6029
|
useEventListener(target, "pointermove", (e) => {
|
|
5574
|
-
if (!
|
|
6030
|
+
if (!eventIsAllowed(e))
|
|
5575
6031
|
return;
|
|
5576
6032
|
if (!isPointerDown.value)
|
|
5577
6033
|
return;
|
|
@@ -5584,7 +6040,7 @@ function usePointerSwipe(target, options = {}) {
|
|
|
5584
6040
|
}),
|
|
5585
6041
|
useEventListener(target, "pointerup", (e) => {
|
|
5586
6042
|
var _a, _b;
|
|
5587
|
-
if (!
|
|
6043
|
+
if (!eventIsAllowed(e))
|
|
5588
6044
|
return;
|
|
5589
6045
|
if (isSwiping.value)
|
|
5590
6046
|
onSwipeEnd == null ? void 0 : onSwipeEnd(e, direction.value);
|
|
@@ -5617,6 +6073,21 @@ function usePreferredColorScheme(options) {
|
|
|
5617
6073
|
});
|
|
5618
6074
|
}
|
|
5619
6075
|
|
|
6076
|
+
function usePreferredContrast(options) {
|
|
6077
|
+
const isMore = useMediaQuery("(prefers-contrast: more)", options);
|
|
6078
|
+
const isLess = useMediaQuery("(prefers-contrast: less)", options);
|
|
6079
|
+
const isCustom = useMediaQuery("(prefers-contrast: custom)", options);
|
|
6080
|
+
return computed(() => {
|
|
6081
|
+
if (isMore.value)
|
|
6082
|
+
return "more";
|
|
6083
|
+
if (isLess.value)
|
|
6084
|
+
return "less";
|
|
6085
|
+
if (isCustom.value)
|
|
6086
|
+
return "custom";
|
|
6087
|
+
return "no-preference";
|
|
6088
|
+
});
|
|
6089
|
+
}
|
|
6090
|
+
|
|
5620
6091
|
function usePreferredLanguages(options = {}) {
|
|
5621
6092
|
const { window = defaultWindow } = options;
|
|
5622
6093
|
if (!window)
|
|
@@ -5629,27 +6100,44 @@ function usePreferredLanguages(options = {}) {
|
|
|
5629
6100
|
return value;
|
|
5630
6101
|
}
|
|
5631
6102
|
|
|
6103
|
+
function usePreferredReducedMotion(options) {
|
|
6104
|
+
const isReduced = useMediaQuery("(prefers-reduced-motion: reduce)", options);
|
|
6105
|
+
return computed(() => {
|
|
6106
|
+
if (isReduced.value)
|
|
6107
|
+
return "reduce";
|
|
6108
|
+
return "no-preference";
|
|
6109
|
+
});
|
|
6110
|
+
}
|
|
6111
|
+
|
|
6112
|
+
function usePrevious(value, initialValue) {
|
|
6113
|
+
const previous = shallowRef(initialValue);
|
|
6114
|
+
watch(resolveRef(value), (_, oldValue) => {
|
|
6115
|
+
previous.value = oldValue;
|
|
6116
|
+
}, { flush: "sync" });
|
|
6117
|
+
return readonly(previous);
|
|
6118
|
+
}
|
|
6119
|
+
|
|
5632
6120
|
const useScreenOrientation = (options = {}) => {
|
|
5633
6121
|
const {
|
|
5634
6122
|
window = defaultWindow
|
|
5635
6123
|
} = options;
|
|
5636
|
-
const isSupported =
|
|
5637
|
-
const screenOrientation = isSupported ? window.screen.orientation : {};
|
|
6124
|
+
const isSupported = useSupported(() => window && "screen" in window && "orientation" in window.screen);
|
|
6125
|
+
const screenOrientation = isSupported.value ? window.screen.orientation : {};
|
|
5638
6126
|
const orientation = ref(screenOrientation.type);
|
|
5639
6127
|
const angle = ref(screenOrientation.angle || 0);
|
|
5640
|
-
if (isSupported) {
|
|
6128
|
+
if (isSupported.value) {
|
|
5641
6129
|
useEventListener(window, "orientationchange", () => {
|
|
5642
6130
|
orientation.value = screenOrientation.type;
|
|
5643
6131
|
angle.value = screenOrientation.angle;
|
|
5644
6132
|
});
|
|
5645
6133
|
}
|
|
5646
6134
|
const lockOrientation = (type) => {
|
|
5647
|
-
if (!isSupported)
|
|
6135
|
+
if (!isSupported.value)
|
|
5648
6136
|
return Promise.reject(new Error("Not supported"));
|
|
5649
6137
|
return screenOrientation.lock(type);
|
|
5650
6138
|
};
|
|
5651
6139
|
const unlockOrientation = () => {
|
|
5652
|
-
if (isSupported)
|
|
6140
|
+
if (isSupported.value)
|
|
5653
6141
|
screenOrientation.unlock();
|
|
5654
6142
|
};
|
|
5655
6143
|
return {
|
|
@@ -5726,12 +6214,12 @@ function useScriptTag(src, onLoaded = noop, options = {}) {
|
|
|
5726
6214
|
return;
|
|
5727
6215
|
}
|
|
5728
6216
|
let shouldAppend = false;
|
|
5729
|
-
let el = document.querySelector(`script[src="${src}"]`);
|
|
6217
|
+
let el = document.querySelector(`script[src="${resolveUnref(src)}"]`);
|
|
5730
6218
|
if (!el) {
|
|
5731
6219
|
el = document.createElement("script");
|
|
5732
6220
|
el.type = type;
|
|
5733
6221
|
el.async = async;
|
|
5734
|
-
el.src =
|
|
6222
|
+
el.src = resolveUnref(src);
|
|
5735
6223
|
if (defer)
|
|
5736
6224
|
el.defer = defer;
|
|
5737
6225
|
if (crossOrigin)
|
|
@@ -5768,7 +6256,7 @@ function useScriptTag(src, onLoaded = noop, options = {}) {
|
|
|
5768
6256
|
_promise = null;
|
|
5769
6257
|
if (scriptTag.value)
|
|
5770
6258
|
scriptTag.value = null;
|
|
5771
|
-
const el = document.querySelector(`script[src="${src}"]`);
|
|
6259
|
+
const el = document.querySelector(`script[src="${resolveUnref(src)}"]`);
|
|
5772
6260
|
if (el)
|
|
5773
6261
|
document.head.removeChild(el);
|
|
5774
6262
|
};
|
|
@@ -5779,8 +6267,22 @@ function useScriptTag(src, onLoaded = noop, options = {}) {
|
|
|
5779
6267
|
return { scriptTag, load, unload };
|
|
5780
6268
|
}
|
|
5781
6269
|
|
|
6270
|
+
function checkOverflowScroll(ele) {
|
|
6271
|
+
const style = window.getComputedStyle(ele);
|
|
6272
|
+
if (style.overflowX === "scroll" || style.overflowY === "scroll") {
|
|
6273
|
+
return true;
|
|
6274
|
+
} else {
|
|
6275
|
+
const parent = ele.parentNode;
|
|
6276
|
+
if (!parent || parent.tagName === "BODY")
|
|
6277
|
+
return false;
|
|
6278
|
+
return checkOverflowScroll(parent);
|
|
6279
|
+
}
|
|
6280
|
+
}
|
|
5782
6281
|
function preventDefault(rawEvent) {
|
|
5783
6282
|
const e = rawEvent || window.event;
|
|
6283
|
+
const _target = e.target;
|
|
6284
|
+
if (checkOverflowScroll(_target))
|
|
6285
|
+
return false;
|
|
5784
6286
|
if (e.touches.length > 1)
|
|
5785
6287
|
return true;
|
|
5786
6288
|
if (e.preventDefault)
|
|
@@ -5791,7 +6293,7 @@ function useScrollLock(element, initialState = false) {
|
|
|
5791
6293
|
const isLocked = ref(initialState);
|
|
5792
6294
|
let stopTouchMoveListener = null;
|
|
5793
6295
|
let initialOverflow;
|
|
5794
|
-
watch((
|
|
6296
|
+
watch(resolveRef(element), (el) => {
|
|
5795
6297
|
if (el) {
|
|
5796
6298
|
const ele = el;
|
|
5797
6299
|
initialOverflow = ele.style.overflow;
|
|
@@ -5802,17 +6304,19 @@ function useScrollLock(element, initialState = false) {
|
|
|
5802
6304
|
immediate: true
|
|
5803
6305
|
});
|
|
5804
6306
|
const lock = () => {
|
|
5805
|
-
const ele =
|
|
6307
|
+
const ele = resolveUnref(element);
|
|
5806
6308
|
if (!ele || isLocked.value)
|
|
5807
6309
|
return;
|
|
5808
6310
|
if (isIOS) {
|
|
5809
|
-
stopTouchMoveListener = useEventListener(ele, "touchmove",
|
|
6311
|
+
stopTouchMoveListener = useEventListener(ele, "touchmove", (e) => {
|
|
6312
|
+
preventDefault(e);
|
|
6313
|
+
}, { passive: false });
|
|
5810
6314
|
}
|
|
5811
6315
|
ele.style.overflow = "hidden";
|
|
5812
6316
|
isLocked.value = true;
|
|
5813
6317
|
};
|
|
5814
6318
|
const unlock = () => {
|
|
5815
|
-
const ele =
|
|
6319
|
+
const ele = resolveUnref(element);
|
|
5816
6320
|
if (!ele || !isLocked.value)
|
|
5817
6321
|
return;
|
|
5818
6322
|
isIOS && (stopTouchMoveListener == null ? void 0 : stopTouchMoveListener());
|
|
@@ -5838,29 +6342,29 @@ function useSessionStorage(key, initialValue, options = {}) {
|
|
|
5838
6342
|
return useStorage(key, initialValue, window == null ? void 0 : window.sessionStorage, options);
|
|
5839
6343
|
}
|
|
5840
6344
|
|
|
5841
|
-
var __defProp$
|
|
5842
|
-
var __getOwnPropSymbols$
|
|
5843
|
-
var __hasOwnProp$
|
|
5844
|
-
var __propIsEnum$
|
|
5845
|
-
var __defNormalProp$
|
|
5846
|
-
var __spreadValues$
|
|
5847
|
-
for (var prop in b || (b = {}))
|
|
5848
|
-
if (__hasOwnProp$
|
|
5849
|
-
__defNormalProp$
|
|
5850
|
-
if (__getOwnPropSymbols$
|
|
5851
|
-
for (var prop of __getOwnPropSymbols$
|
|
5852
|
-
if (__propIsEnum$
|
|
5853
|
-
__defNormalProp$
|
|
6345
|
+
var __defProp$4 = Object.defineProperty;
|
|
6346
|
+
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
6347
|
+
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
6348
|
+
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
6349
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6350
|
+
var __spreadValues$4 = (a, b) => {
|
|
6351
|
+
for (var prop in b || (b = {}))
|
|
6352
|
+
if (__hasOwnProp$4.call(b, prop))
|
|
6353
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
6354
|
+
if (__getOwnPropSymbols$4)
|
|
6355
|
+
for (var prop of __getOwnPropSymbols$4(b)) {
|
|
6356
|
+
if (__propIsEnum$4.call(b, prop))
|
|
6357
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
5854
6358
|
}
|
|
5855
6359
|
return a;
|
|
5856
6360
|
};
|
|
5857
6361
|
function useShare(shareOptions = {}, options = {}) {
|
|
5858
6362
|
const { navigator = defaultNavigator } = options;
|
|
5859
6363
|
const _navigator = navigator;
|
|
5860
|
-
const isSupported = _navigator && "canShare" in _navigator;
|
|
6364
|
+
const isSupported = useSupported(() => _navigator && "canShare" in _navigator);
|
|
5861
6365
|
const share = async (overrideOptions = {}) => {
|
|
5862
|
-
if (isSupported) {
|
|
5863
|
-
const data = __spreadValues$
|
|
6366
|
+
if (isSupported.value) {
|
|
6367
|
+
const data = __spreadValues$4(__spreadValues$4({}, resolveUnref(shareOptions)), resolveUnref(overrideOptions));
|
|
5864
6368
|
let granted = true;
|
|
5865
6369
|
if (data.files && _navigator.canShare)
|
|
5866
6370
|
granted = _navigator.canShare({ files: data.files });
|
|
@@ -5874,13 +6378,47 @@ function useShare(shareOptions = {}, options = {}) {
|
|
|
5874
6378
|
};
|
|
5875
6379
|
}
|
|
5876
6380
|
|
|
6381
|
+
const defaultSortFn = (source, compareFn) => source.sort(compareFn);
|
|
6382
|
+
const defaultCompare = (a, b) => a - b;
|
|
6383
|
+
function useSorted(...args) {
|
|
6384
|
+
var _a, _b, _c, _d;
|
|
6385
|
+
const [source] = args;
|
|
6386
|
+
let compareFn = defaultCompare;
|
|
6387
|
+
let options = {};
|
|
6388
|
+
if (args.length === 2) {
|
|
6389
|
+
if (typeof args[1] === "object") {
|
|
6390
|
+
options = args[1];
|
|
6391
|
+
compareFn = (_a = options.compareFn) != null ? _a : defaultCompare;
|
|
6392
|
+
} else {
|
|
6393
|
+
compareFn = (_b = args[1]) != null ? _b : defaultCompare;
|
|
6394
|
+
}
|
|
6395
|
+
} else if (args.length > 2) {
|
|
6396
|
+
compareFn = (_c = args[1]) != null ? _c : defaultCompare;
|
|
6397
|
+
options = (_d = args[2]) != null ? _d : {};
|
|
6398
|
+
}
|
|
6399
|
+
const {
|
|
6400
|
+
dirty = false,
|
|
6401
|
+
sortFn = defaultSortFn
|
|
6402
|
+
} = options;
|
|
6403
|
+
if (!dirty)
|
|
6404
|
+
return computed(() => sortFn([...unref(source)], compareFn));
|
|
6405
|
+
watchEffect(() => {
|
|
6406
|
+
const result = sortFn(unref(source), compareFn);
|
|
6407
|
+
if (isRef(source))
|
|
6408
|
+
source.value = result;
|
|
6409
|
+
else
|
|
6410
|
+
source.splice(0, source.length, ...result);
|
|
6411
|
+
});
|
|
6412
|
+
return source;
|
|
6413
|
+
}
|
|
6414
|
+
|
|
5877
6415
|
function useSpeechRecognition(options = {}) {
|
|
5878
6416
|
const {
|
|
5879
6417
|
interimResults = true,
|
|
5880
6418
|
continuous = true,
|
|
5881
6419
|
window = defaultWindow
|
|
5882
6420
|
} = options;
|
|
5883
|
-
const lang =
|
|
6421
|
+
const lang = resolveRef(options.lang || "en-US");
|
|
5884
6422
|
const isListening = ref(false);
|
|
5885
6423
|
const isFinal = ref(false);
|
|
5886
6424
|
const result = ref("");
|
|
@@ -5895,9 +6433,9 @@ function useSpeechRecognition(options = {}) {
|
|
|
5895
6433
|
isListening.value = false;
|
|
5896
6434
|
};
|
|
5897
6435
|
const SpeechRecognition = window && (window.SpeechRecognition || window.webkitSpeechRecognition);
|
|
5898
|
-
const isSupported =
|
|
6436
|
+
const isSupported = useSupported(() => SpeechRecognition);
|
|
5899
6437
|
let recognition;
|
|
5900
|
-
if (isSupported) {
|
|
6438
|
+
if (isSupported.value) {
|
|
5901
6439
|
recognition = new SpeechRecognition();
|
|
5902
6440
|
recognition.continuous = continuous;
|
|
5903
6441
|
recognition.interimResults = interimResults;
|
|
@@ -5948,7 +6486,6 @@ function useSpeechRecognition(options = {}) {
|
|
|
5948
6486
|
}
|
|
5949
6487
|
|
|
5950
6488
|
function useSpeechSynthesis(text, options = {}) {
|
|
5951
|
-
var _a, _b;
|
|
5952
6489
|
const {
|
|
5953
6490
|
pitch = 1,
|
|
5954
6491
|
rate = 1,
|
|
@@ -5956,22 +6493,18 @@ function useSpeechSynthesis(text, options = {}) {
|
|
|
5956
6493
|
window = defaultWindow
|
|
5957
6494
|
} = options;
|
|
5958
6495
|
const synth = window && window.speechSynthesis;
|
|
5959
|
-
const isSupported =
|
|
6496
|
+
const isSupported = useSupported(() => synth);
|
|
5960
6497
|
const isPlaying = ref(false);
|
|
5961
6498
|
const status = ref("init");
|
|
5962
|
-
const
|
|
5963
|
-
|
|
5964
|
-
name: ((_b = options.voice) == null ? void 0 : _b.name) || ""
|
|
5965
|
-
};
|
|
5966
|
-
const spokenText = ref(text || "");
|
|
5967
|
-
const lang = ref(options.lang || "en-US");
|
|
6499
|
+
const spokenText = resolveRef(text || "");
|
|
6500
|
+
const lang = resolveRef(options.lang || "en-US");
|
|
5968
6501
|
const error = shallowRef(void 0);
|
|
5969
6502
|
const toggle = (value = !isPlaying.value) => {
|
|
5970
6503
|
isPlaying.value = value;
|
|
5971
6504
|
};
|
|
5972
6505
|
const bindEventsForUtterance = (utterance2) => {
|
|
5973
6506
|
utterance2.lang = unref(lang);
|
|
5974
|
-
|
|
6507
|
+
utterance2.voice = unref(options.voice) || null;
|
|
5975
6508
|
utterance2.pitch = pitch;
|
|
5976
6509
|
utterance2.rate = rate;
|
|
5977
6510
|
utterance2.volume = volume;
|
|
@@ -5994,10 +6527,6 @@ function useSpeechSynthesis(text, options = {}) {
|
|
|
5994
6527
|
utterance2.onerror = (event) => {
|
|
5995
6528
|
error.value = event;
|
|
5996
6529
|
};
|
|
5997
|
-
utterance2.onend = () => {
|
|
5998
|
-
isPlaying.value = false;
|
|
5999
|
-
utterance2.lang = unref(lang);
|
|
6000
|
-
};
|
|
6001
6530
|
};
|
|
6002
6531
|
const utterance = computed(() => {
|
|
6003
6532
|
isPlaying.value = false;
|
|
@@ -6010,12 +6539,17 @@ function useSpeechSynthesis(text, options = {}) {
|
|
|
6010
6539
|
synth.cancel();
|
|
6011
6540
|
utterance && synth.speak(utterance.value);
|
|
6012
6541
|
};
|
|
6013
|
-
if (isSupported) {
|
|
6542
|
+
if (isSupported.value) {
|
|
6014
6543
|
bindEventsForUtterance(utterance.value);
|
|
6015
6544
|
watch(lang, (lang2) => {
|
|
6016
6545
|
if (utterance.value && !isPlaying.value)
|
|
6017
6546
|
utterance.value.lang = lang2;
|
|
6018
6547
|
});
|
|
6548
|
+
if (options.voice) {
|
|
6549
|
+
watch(options.voice, () => {
|
|
6550
|
+
synth.cancel();
|
|
6551
|
+
});
|
|
6552
|
+
}
|
|
6019
6553
|
watch(isPlaying, () => {
|
|
6020
6554
|
if (isPlaying.value)
|
|
6021
6555
|
synth.resume();
|
|
@@ -6030,7 +6564,6 @@ function useSpeechSynthesis(text, options = {}) {
|
|
|
6030
6564
|
isSupported,
|
|
6031
6565
|
isPlaying,
|
|
6032
6566
|
status,
|
|
6033
|
-
voiceInfo,
|
|
6034
6567
|
utterance,
|
|
6035
6568
|
error,
|
|
6036
6569
|
toggle,
|
|
@@ -6127,7 +6660,7 @@ function useStorageAsync(key, initialValue, storage, options = {}) {
|
|
|
6127
6660
|
console.error(e);
|
|
6128
6661
|
}
|
|
6129
6662
|
} = options;
|
|
6130
|
-
const rawInit =
|
|
6663
|
+
const rawInit = resolveUnref(initialValue);
|
|
6131
6664
|
const type = guessSerializerType(rawInit);
|
|
6132
6665
|
const data = (shallow ? shallowRef : ref)(initialValue);
|
|
6133
6666
|
const serializer = (_a = options.serializer) != null ? _a : StorageSerializers[type];
|
|
@@ -6195,15 +6728,17 @@ function useStyleTag(css, options = {}) {
|
|
|
6195
6728
|
if (!document)
|
|
6196
6729
|
return;
|
|
6197
6730
|
const el = document.getElementById(id) || document.createElement("style");
|
|
6198
|
-
el.
|
|
6199
|
-
|
|
6200
|
-
|
|
6201
|
-
|
|
6202
|
-
|
|
6731
|
+
if (!el.isConnected) {
|
|
6732
|
+
el.type = "text/css";
|
|
6733
|
+
el.id = id;
|
|
6734
|
+
if (options.media)
|
|
6735
|
+
el.media = options.media;
|
|
6736
|
+
document.head.appendChild(el);
|
|
6737
|
+
}
|
|
6203
6738
|
if (isLoaded.value)
|
|
6204
6739
|
return;
|
|
6205
6740
|
stop = watch(cssRef, (value) => {
|
|
6206
|
-
el.
|
|
6741
|
+
el.textContent = value;
|
|
6207
6742
|
}, { immediate: true });
|
|
6208
6743
|
isLoaded.value = true;
|
|
6209
6744
|
};
|
|
@@ -6239,6 +6774,39 @@ function useTemplateRefsList() {
|
|
|
6239
6774
|
return refs;
|
|
6240
6775
|
}
|
|
6241
6776
|
|
|
6777
|
+
function useTextDirection(options = {}) {
|
|
6778
|
+
const {
|
|
6779
|
+
document = defaultDocument,
|
|
6780
|
+
selector = "html",
|
|
6781
|
+
observe = false,
|
|
6782
|
+
initialValue = "ltr"
|
|
6783
|
+
} = options;
|
|
6784
|
+
function getValue() {
|
|
6785
|
+
var _a, _b;
|
|
6786
|
+
return (_b = (_a = document == null ? void 0 : document.querySelector(selector)) == null ? void 0 : _a.getAttribute("dir")) != null ? _b : initialValue;
|
|
6787
|
+
}
|
|
6788
|
+
const dir = ref(getValue());
|
|
6789
|
+
tryOnMounted(() => dir.value = getValue());
|
|
6790
|
+
if (observe && document) {
|
|
6791
|
+
useMutationObserver(document.querySelector(selector), () => dir.value = getValue(), { attributes: true });
|
|
6792
|
+
}
|
|
6793
|
+
return computed({
|
|
6794
|
+
get() {
|
|
6795
|
+
return dir.value;
|
|
6796
|
+
},
|
|
6797
|
+
set(v) {
|
|
6798
|
+
var _a, _b;
|
|
6799
|
+
dir.value = v;
|
|
6800
|
+
if (!document)
|
|
6801
|
+
return;
|
|
6802
|
+
if (dir.value)
|
|
6803
|
+
(_a = document.querySelector(selector)) == null ? void 0 : _a.setAttribute("dir", dir.value);
|
|
6804
|
+
else
|
|
6805
|
+
(_b = document.querySelector(selector)) == null ? void 0 : _b.removeAttribute("dir");
|
|
6806
|
+
}
|
|
6807
|
+
});
|
|
6808
|
+
}
|
|
6809
|
+
|
|
6242
6810
|
function getRangesFromSelection(selection) {
|
|
6243
6811
|
var _a;
|
|
6244
6812
|
const rangeCount = (_a = selection.rangeCount) != null ? _a : 0;
|
|
@@ -6287,6 +6855,7 @@ function useTextareaAutosize(options) {
|
|
|
6287
6855
|
(_b = options == null ? void 0 : options.onResize) == null ? void 0 : _b.call(options);
|
|
6288
6856
|
}
|
|
6289
6857
|
watch([input, textarea], triggerResize, { immediate: true });
|
|
6858
|
+
useResizeObserver(textarea, () => triggerResize());
|
|
6290
6859
|
if (options == null ? void 0 : options.watch)
|
|
6291
6860
|
watch(options.watch, triggerResize, { immediate: true, deep: true });
|
|
6292
6861
|
return {
|
|
@@ -6296,9 +6865,33 @@ function useTextareaAutosize(options) {
|
|
|
6296
6865
|
};
|
|
6297
6866
|
}
|
|
6298
6867
|
|
|
6299
|
-
var __defProp$
|
|
6868
|
+
var __defProp$3 = Object.defineProperty;
|
|
6300
6869
|
var __defProps = Object.defineProperties;
|
|
6301
6870
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6871
|
+
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
6872
|
+
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
6873
|
+
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
6874
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6875
|
+
var __spreadValues$3 = (a, b) => {
|
|
6876
|
+
for (var prop in b || (b = {}))
|
|
6877
|
+
if (__hasOwnProp$3.call(b, prop))
|
|
6878
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
6879
|
+
if (__getOwnPropSymbols$3)
|
|
6880
|
+
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
6881
|
+
if (__propIsEnum$3.call(b, prop))
|
|
6882
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
6883
|
+
}
|
|
6884
|
+
return a;
|
|
6885
|
+
};
|
|
6886
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
6887
|
+
function useThrottledRefHistory(source, options = {}) {
|
|
6888
|
+
const { throttle = 200, trailing = true } = options;
|
|
6889
|
+
const filter = throttleFilter(throttle, trailing);
|
|
6890
|
+
const history = useRefHistory(source, __spreadProps(__spreadValues$3({}, options), { eventFilter: filter }));
|
|
6891
|
+
return __spreadValues$3({}, history);
|
|
6892
|
+
}
|
|
6893
|
+
|
|
6894
|
+
var __defProp$2 = Object.defineProperty;
|
|
6302
6895
|
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
6303
6896
|
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
6304
6897
|
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
@@ -6314,43 +6907,19 @@ var __spreadValues$2 = (a, b) => {
|
|
|
6314
6907
|
}
|
|
6315
6908
|
return a;
|
|
6316
6909
|
};
|
|
6317
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
6318
|
-
function useThrottledRefHistory(source, options = {}) {
|
|
6319
|
-
const { throttle = 200, trailing = true } = options;
|
|
6320
|
-
const filter = throttleFilter(throttle, trailing);
|
|
6321
|
-
const history = useRefHistory(source, __spreadProps(__spreadValues$2({}, options), { eventFilter: filter }));
|
|
6322
|
-
return __spreadValues$2({}, history);
|
|
6323
|
-
}
|
|
6324
|
-
|
|
6325
|
-
var __defProp$1 = Object.defineProperty;
|
|
6326
|
-
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
6327
|
-
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
6328
|
-
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
6329
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6330
|
-
var __spreadValues$1 = (a, b) => {
|
|
6331
|
-
for (var prop in b || (b = {}))
|
|
6332
|
-
if (__hasOwnProp$1.call(b, prop))
|
|
6333
|
-
__defNormalProp$1(a, prop, b[prop]);
|
|
6334
|
-
if (__getOwnPropSymbols$1)
|
|
6335
|
-
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
6336
|
-
if (__propIsEnum$1.call(b, prop))
|
|
6337
|
-
__defNormalProp$1(a, prop, b[prop]);
|
|
6338
|
-
}
|
|
6339
|
-
return a;
|
|
6340
|
-
};
|
|
6341
6910
|
var __objRest = (source, exclude) => {
|
|
6342
6911
|
var target = {};
|
|
6343
6912
|
for (var prop in source)
|
|
6344
|
-
if (__hasOwnProp$
|
|
6913
|
+
if (__hasOwnProp$2.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
6345
6914
|
target[prop] = source[prop];
|
|
6346
|
-
if (source != null && __getOwnPropSymbols$
|
|
6347
|
-
for (var prop of __getOwnPropSymbols$
|
|
6348
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
6915
|
+
if (source != null && __getOwnPropSymbols$2)
|
|
6916
|
+
for (var prop of __getOwnPropSymbols$2(source)) {
|
|
6917
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$2.call(source, prop))
|
|
6349
6918
|
target[prop] = source[prop];
|
|
6350
6919
|
}
|
|
6351
6920
|
return target;
|
|
6352
6921
|
};
|
|
6353
|
-
const
|
|
6922
|
+
const DEFAULT_UNITS = [
|
|
6354
6923
|
{ max: 6e4, value: 1e3, name: "second" },
|
|
6355
6924
|
{ max: 276e4, value: 6e4, name: "minute" },
|
|
6356
6925
|
{ max: 72e6, value: 36e5, name: "hour" },
|
|
@@ -6369,36 +6938,46 @@ const DEFAULT_MESSAGES = {
|
|
|
6369
6938
|
week: (n, past) => n === 1 ? past ? "last week" : "next week" : `${n} week${n > 1 ? "s" : ""}`,
|
|
6370
6939
|
hour: (n) => `${n} hour${n > 1 ? "s" : ""}`,
|
|
6371
6940
|
minute: (n) => `${n} minute${n > 1 ? "s" : ""}`,
|
|
6372
|
-
second: (n) => `${n} second${n > 1 ? "s" : ""}
|
|
6941
|
+
second: (n) => `${n} second${n > 1 ? "s" : ""}`,
|
|
6942
|
+
invalid: ""
|
|
6373
6943
|
};
|
|
6374
6944
|
const DEFAULT_FORMATTER = (date) => date.toISOString().slice(0, 10);
|
|
6375
6945
|
function useTimeAgo(time, options = {}) {
|
|
6376
6946
|
const {
|
|
6377
6947
|
controls: exposeControls = false,
|
|
6948
|
+
updateInterval = 3e4
|
|
6949
|
+
} = options;
|
|
6950
|
+
const _a = useNow({ interval: updateInterval, controls: true }), { now } = _a, controls = __objRest(_a, ["now"]);
|
|
6951
|
+
const timeAgo = computed(() => formatTimeAgo(new Date(resolveUnref(time)), options, unref(now.value)));
|
|
6952
|
+
if (exposeControls) {
|
|
6953
|
+
return __spreadValues$2({
|
|
6954
|
+
timeAgo
|
|
6955
|
+
}, controls);
|
|
6956
|
+
} else {
|
|
6957
|
+
return timeAgo;
|
|
6958
|
+
}
|
|
6959
|
+
}
|
|
6960
|
+
function formatTimeAgo(from, options = {}, now = Date.now()) {
|
|
6961
|
+
var _a;
|
|
6962
|
+
const {
|
|
6378
6963
|
max,
|
|
6379
|
-
updateInterval = 3e4,
|
|
6380
6964
|
messages = DEFAULT_MESSAGES,
|
|
6381
|
-
fullDateFormatter = DEFAULT_FORMATTER
|
|
6965
|
+
fullDateFormatter = DEFAULT_FORMATTER,
|
|
6966
|
+
units = DEFAULT_UNITS,
|
|
6967
|
+
showSecond = false,
|
|
6968
|
+
rounding = "round"
|
|
6382
6969
|
} = options;
|
|
6383
|
-
const
|
|
6384
|
-
const
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
-
|
|
6391
|
-
|
|
6392
|
-
|
|
6393
|
-
|
|
6394
|
-
const unitMax = (_a2 = UNITS.find((i) => i.name === max)) == null ? void 0 : _a2.max;
|
|
6395
|
-
if (unitMax && absDiff > unitMax)
|
|
6396
|
-
return fullDateFormatter(new Date(from));
|
|
6397
|
-
}
|
|
6398
|
-
for (const unit of UNITS) {
|
|
6399
|
-
if (absDiff < unit.max)
|
|
6400
|
-
return format(diff, unit);
|
|
6401
|
-
}
|
|
6970
|
+
const roundFn = typeof rounding === "number" ? (n) => +n.toFixed(rounding) : Math[rounding];
|
|
6971
|
+
const diff = +now - +from;
|
|
6972
|
+
const absDiff = Math.abs(diff);
|
|
6973
|
+
function getValue(diff2, unit) {
|
|
6974
|
+
return roundFn(Math.abs(diff2) / unit.value);
|
|
6975
|
+
}
|
|
6976
|
+
function format(diff2, unit) {
|
|
6977
|
+
const val = getValue(diff2, unit);
|
|
6978
|
+
const past = diff2 > 0;
|
|
6979
|
+
const str = applyFormat(unit.name, val, past);
|
|
6980
|
+
return applyFormat(past ? "past" : "future", str, past);
|
|
6402
6981
|
}
|
|
6403
6982
|
function applyFormat(name, val, isPast) {
|
|
6404
6983
|
const formatter = messages[name];
|
|
@@ -6406,20 +6985,23 @@ function useTimeAgo(time, options = {}) {
|
|
|
6406
6985
|
return formatter(val, isPast);
|
|
6407
6986
|
return formatter.replace("{0}", val.toString());
|
|
6408
6987
|
}
|
|
6409
|
-
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
|
|
6413
|
-
|
|
6988
|
+
if (absDiff < 6e4 && !showSecond)
|
|
6989
|
+
return messages.justNow;
|
|
6990
|
+
if (typeof max === "number" && absDiff > max)
|
|
6991
|
+
return fullDateFormatter(new Date(from));
|
|
6992
|
+
if (typeof max === "string") {
|
|
6993
|
+
const unitMax = (_a = units.find((i) => i.name === max)) == null ? void 0 : _a.max;
|
|
6994
|
+
if (unitMax && absDiff > unitMax)
|
|
6995
|
+
return fullDateFormatter(new Date(from));
|
|
6414
6996
|
}
|
|
6415
|
-
const
|
|
6416
|
-
|
|
6417
|
-
|
|
6418
|
-
|
|
6419
|
-
|
|
6420
|
-
|
|
6421
|
-
return timeAgo;
|
|
6997
|
+
for (const [idx, unit] of units.entries()) {
|
|
6998
|
+
const val = getValue(diff, unit);
|
|
6999
|
+
if (val <= 0 && units[idx - 1])
|
|
7000
|
+
return format(diff, units[idx - 1]);
|
|
7001
|
+
if (absDiff < unit.max)
|
|
7002
|
+
return format(diff, unit);
|
|
6422
7003
|
}
|
|
7004
|
+
return messages.invalid;
|
|
6423
7005
|
}
|
|
6424
7006
|
|
|
6425
7007
|
function useTimeoutPoll(fn, interval, timeoutPollOptions) {
|
|
@@ -6450,19 +7032,19 @@ function useTimeoutPoll(fn, interval, timeoutPollOptions) {
|
|
|
6450
7032
|
};
|
|
6451
7033
|
}
|
|
6452
7034
|
|
|
6453
|
-
var __defProp = Object.defineProperty;
|
|
6454
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6455
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6456
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
6457
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6458
|
-
var __spreadValues = (a, b) => {
|
|
7035
|
+
var __defProp$1 = Object.defineProperty;
|
|
7036
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
7037
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
7038
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
7039
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7040
|
+
var __spreadValues$1 = (a, b) => {
|
|
6459
7041
|
for (var prop in b || (b = {}))
|
|
6460
|
-
if (__hasOwnProp.call(b, prop))
|
|
6461
|
-
__defNormalProp(a, prop, b[prop]);
|
|
6462
|
-
if (__getOwnPropSymbols)
|
|
6463
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
6464
|
-
if (__propIsEnum.call(b, prop))
|
|
6465
|
-
__defNormalProp(a, prop, b[prop]);
|
|
7042
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
7043
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
7044
|
+
if (__getOwnPropSymbols$1)
|
|
7045
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
7046
|
+
if (__propIsEnum$1.call(b, prop))
|
|
7047
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
6466
7048
|
}
|
|
6467
7049
|
return a;
|
|
6468
7050
|
};
|
|
@@ -6471,13 +7053,18 @@ function useTimestamp(options = {}) {
|
|
|
6471
7053
|
controls: exposeControls = false,
|
|
6472
7054
|
offset = 0,
|
|
6473
7055
|
immediate = true,
|
|
6474
|
-
interval = "requestAnimationFrame"
|
|
7056
|
+
interval = "requestAnimationFrame",
|
|
7057
|
+
callback
|
|
6475
7058
|
} = options;
|
|
6476
7059
|
const ts = ref(timestamp() + offset);
|
|
6477
7060
|
const update = () => ts.value = timestamp() + offset;
|
|
6478
|
-
const
|
|
7061
|
+
const cb = callback ? () => {
|
|
7062
|
+
update();
|
|
7063
|
+
callback(ts.value);
|
|
7064
|
+
} : update;
|
|
7065
|
+
const controls = interval === "requestAnimationFrame" ? useRafFn(cb, { immediate }) : useIntervalFn(cb, interval, { immediate });
|
|
6479
7066
|
if (exposeControls) {
|
|
6480
|
-
return __spreadValues({
|
|
7067
|
+
return __spreadValues$1({
|
|
6481
7068
|
timestamp: ts
|
|
6482
7069
|
}, controls);
|
|
6483
7070
|
} else {
|
|
@@ -6488,26 +7075,46 @@ function useTimestamp(options = {}) {
|
|
|
6488
7075
|
function useTitle(newTitle = null, options = {}) {
|
|
6489
7076
|
var _a, _b;
|
|
6490
7077
|
const {
|
|
6491
|
-
document = defaultDocument
|
|
6492
|
-
observe = false,
|
|
6493
|
-
titleTemplate = "%s"
|
|
7078
|
+
document = defaultDocument
|
|
6494
7079
|
} = options;
|
|
6495
|
-
const title =
|
|
7080
|
+
const title = resolveRef((_a = newTitle != null ? newTitle : document == null ? void 0 : document.title) != null ? _a : null);
|
|
7081
|
+
const isReadonly = newTitle && isFunction(newTitle);
|
|
7082
|
+
function format(t) {
|
|
7083
|
+
if (!("titleTemplate" in options))
|
|
7084
|
+
return t;
|
|
7085
|
+
const template = options.titleTemplate || "%s";
|
|
7086
|
+
return isFunction(template) ? template(t) : unref(template).replace(/%s/g, t);
|
|
7087
|
+
}
|
|
6496
7088
|
watch(title, (t, o) => {
|
|
6497
|
-
if (
|
|
6498
|
-
document.title =
|
|
7089
|
+
if (t !== o && document)
|
|
7090
|
+
document.title = format(isString(t) ? t : "");
|
|
6499
7091
|
}, { immediate: true });
|
|
6500
|
-
if (observe && document) {
|
|
7092
|
+
if (options.observe && !options.titleTemplate && document && !isReadonly) {
|
|
6501
7093
|
useMutationObserver((_b = document.head) == null ? void 0 : _b.querySelector("title"), () => {
|
|
6502
7094
|
if (document && document.title !== title.value)
|
|
6503
|
-
title.value =
|
|
7095
|
+
title.value = format(document.title);
|
|
6504
7096
|
}, { childList: true });
|
|
6505
7097
|
}
|
|
6506
7098
|
return title;
|
|
6507
7099
|
}
|
|
6508
7100
|
|
|
6509
|
-
|
|
6510
|
-
|
|
7101
|
+
var __defProp = Object.defineProperty;
|
|
7102
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7103
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7104
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7105
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
7106
|
+
var __spreadValues = (a, b) => {
|
|
7107
|
+
for (var prop in b || (b = {}))
|
|
7108
|
+
if (__hasOwnProp.call(b, prop))
|
|
7109
|
+
__defNormalProp(a, prop, b[prop]);
|
|
7110
|
+
if (__getOwnPropSymbols)
|
|
7111
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
7112
|
+
if (__propIsEnum.call(b, prop))
|
|
7113
|
+
__defNormalProp(a, prop, b[prop]);
|
|
7114
|
+
}
|
|
7115
|
+
return a;
|
|
7116
|
+
};
|
|
7117
|
+
const _TransitionPresets = {
|
|
6511
7118
|
easeInSine: [0.12, 0, 0.39, 0],
|
|
6512
7119
|
easeOutSine: [0.61, 1, 0.88, 1],
|
|
6513
7120
|
easeInOutSine: [0.37, 0, 0.63, 1],
|
|
@@ -6533,6 +7140,9 @@ const TransitionPresets = {
|
|
|
6533
7140
|
easeOutBack: [0.34, 1.56, 0.64, 1],
|
|
6534
7141
|
easeInOutBack: [0.68, -0.6, 0.32, 1.6]
|
|
6535
7142
|
};
|
|
7143
|
+
const TransitionPresets = __spreadValues({
|
|
7144
|
+
linear: identity
|
|
7145
|
+
}, _TransitionPresets);
|
|
6536
7146
|
function createEasingFunction([p0, p1, p2, p3]) {
|
|
6537
7147
|
const a = (a1, a2) => 1 - 3 * a2 + 3 * a1;
|
|
6538
7148
|
const b = (a1, a2) => 3 * a2 - 6 * a1;
|
|
@@ -6603,15 +7213,19 @@ function useTransition(source, options = {}) {
|
|
|
6603
7213
|
};
|
|
6604
7214
|
const timeout = useTimeoutFn(start, delay, { immediate: false });
|
|
6605
7215
|
watch(sourceVector, () => {
|
|
6606
|
-
if (unref(disabled))
|
|
7216
|
+
if (unref(disabled))
|
|
7217
|
+
return;
|
|
7218
|
+
if (unref(delay) <= 0)
|
|
7219
|
+
start();
|
|
7220
|
+
else
|
|
7221
|
+
timeout.start();
|
|
7222
|
+
}, { deep: true });
|
|
7223
|
+
watch(() => unref(disabled), (v) => {
|
|
7224
|
+
if (v) {
|
|
6607
7225
|
outputVector.value = sourceVector.value.slice(0);
|
|
6608
|
-
|
|
6609
|
-
if (unref(delay) <= 0)
|
|
6610
|
-
start();
|
|
6611
|
-
else
|
|
6612
|
-
timeout.start();
|
|
7226
|
+
pause();
|
|
6613
7227
|
}
|
|
6614
|
-
}
|
|
7228
|
+
});
|
|
6615
7229
|
return computed(() => {
|
|
6616
7230
|
const targetVector = unref(disabled) ? sourceVector : outputVector;
|
|
6617
7231
|
return isNumber(sourceValue.value) ? targetVector.value[0] : targetVector.value;
|
|
@@ -6623,6 +7237,7 @@ function useUrlSearchParams(mode = "history", options = {}) {
|
|
|
6623
7237
|
initialValue = {},
|
|
6624
7238
|
removeNullishValues = true,
|
|
6625
7239
|
removeFalsyValues = false,
|
|
7240
|
+
write: enableWrite = true,
|
|
6626
7241
|
window = defaultWindow
|
|
6627
7242
|
} = options;
|
|
6628
7243
|
if (!window)
|
|
@@ -6642,9 +7257,9 @@ function useUrlSearchParams(mode = "history", options = {}) {
|
|
|
6642
7257
|
function constructQuery(params) {
|
|
6643
7258
|
const stringified = params.toString();
|
|
6644
7259
|
if (mode === "history")
|
|
6645
|
-
return `${stringified ? `?${stringified}` : ""}${location.hash || ""}`;
|
|
7260
|
+
return `${stringified ? `?${stringified}` : ""}${window.location.hash || ""}`;
|
|
6646
7261
|
if (mode === "hash-params")
|
|
6647
|
-
return `${location.search || ""}${stringified ? `#${stringified}` : ""}`;
|
|
7262
|
+
return `${window.location.search || ""}${stringified ? `#${stringified}` : ""}`;
|
|
6648
7263
|
const hash = window.location.hash || "#";
|
|
6649
7264
|
const index = hash.indexOf("?");
|
|
6650
7265
|
if (index > 0)
|
|
@@ -6686,6 +7301,8 @@ function useUrlSearchParams(mode = "history", options = {}) {
|
|
|
6686
7301
|
resume();
|
|
6687
7302
|
}
|
|
6688
7303
|
function onChanged() {
|
|
7304
|
+
if (!enableWrite)
|
|
7305
|
+
return;
|
|
6689
7306
|
write(read(), true);
|
|
6690
7307
|
}
|
|
6691
7308
|
useEventListener(window, "popstate", onChanged, false);
|
|
@@ -6700,13 +7317,16 @@ function useUrlSearchParams(mode = "history", options = {}) {
|
|
|
6700
7317
|
}
|
|
6701
7318
|
|
|
6702
7319
|
function useUserMedia(options = {}) {
|
|
6703
|
-
var _a, _b
|
|
7320
|
+
var _a, _b;
|
|
6704
7321
|
const enabled = ref((_a = options.enabled) != null ? _a : false);
|
|
6705
7322
|
const autoSwitch = ref((_b = options.autoSwitch) != null ? _b : true);
|
|
6706
7323
|
const videoDeviceId = ref(options.videoDeviceId);
|
|
6707
7324
|
const audioDeviceId = ref(options.audioDeviceId);
|
|
6708
7325
|
const { navigator = defaultNavigator } = options;
|
|
6709
|
-
const isSupported =
|
|
7326
|
+
const isSupported = useSupported(() => {
|
|
7327
|
+
var _a2;
|
|
7328
|
+
return (_a2 = navigator == null ? void 0 : navigator.mediaDevices) == null ? void 0 : _a2.getUserMedia;
|
|
7329
|
+
});
|
|
6710
7330
|
const stream = shallowRef();
|
|
6711
7331
|
function getDeviceOptions(device) {
|
|
6712
7332
|
if (device.value === "none" || device.value === false)
|
|
@@ -6718,7 +7338,7 @@ function useUserMedia(options = {}) {
|
|
|
6718
7338
|
};
|
|
6719
7339
|
}
|
|
6720
7340
|
async function _start() {
|
|
6721
|
-
if (!isSupported || stream.value)
|
|
7341
|
+
if (!isSupported.value || stream.value)
|
|
6722
7342
|
return;
|
|
6723
7343
|
stream.value = await navigator.mediaDevices.getUserMedia({
|
|
6724
7344
|
video: getDeviceOptions(videoDeviceId),
|
|
@@ -6771,6 +7391,7 @@ function useUserMedia(options = {}) {
|
|
|
6771
7391
|
function useVModel(props, key, emit, options = {}) {
|
|
6772
7392
|
var _a, _b, _c, _d, _e;
|
|
6773
7393
|
const {
|
|
7394
|
+
clone = false,
|
|
6774
7395
|
passive = false,
|
|
6775
7396
|
eventName,
|
|
6776
7397
|
deep = false,
|
|
@@ -6790,16 +7411,16 @@ function useVModel(props, key, emit, options = {}) {
|
|
|
6790
7411
|
}
|
|
6791
7412
|
}
|
|
6792
7413
|
event = eventName || event || `update:${key.toString()}`;
|
|
6793
|
-
const
|
|
7414
|
+
const cloneFn = (val) => !clone ? val : isFunction(clone) ? clone(val) : cloneFnJSON(val);
|
|
7415
|
+
const getValue = () => isDef(props[key]) ? cloneFn(props[key]) : defaultValue;
|
|
6794
7416
|
if (passive) {
|
|
6795
|
-
const
|
|
6796
|
-
|
|
7417
|
+
const initialValue = getValue();
|
|
7418
|
+
const proxy = ref(initialValue);
|
|
7419
|
+
watch(() => props[key], (v) => proxy.value = cloneFn(v));
|
|
6797
7420
|
watch(proxy, (v) => {
|
|
6798
7421
|
if (v !== props[key] || deep)
|
|
6799
7422
|
_emit(event, v);
|
|
6800
|
-
}, {
|
|
6801
|
-
deep
|
|
6802
|
-
});
|
|
7423
|
+
}, { deep });
|
|
6803
7424
|
return proxy;
|
|
6804
7425
|
} else {
|
|
6805
7426
|
return computed({
|
|
@@ -6826,15 +7447,15 @@ function useVibrate(options) {
|
|
|
6826
7447
|
interval = 0,
|
|
6827
7448
|
navigator = defaultNavigator
|
|
6828
7449
|
} = options || {};
|
|
6829
|
-
const isSupported = typeof navigator !== "undefined" && "vibrate" in navigator;
|
|
6830
|
-
const patternRef =
|
|
7450
|
+
const isSupported = useSupported(() => typeof navigator !== "undefined" && "vibrate" in navigator);
|
|
7451
|
+
const patternRef = resolveRef(pattern);
|
|
6831
7452
|
let intervalControls;
|
|
6832
7453
|
const vibrate = (pattern2 = patternRef.value) => {
|
|
6833
|
-
if (isSupported)
|
|
7454
|
+
if (isSupported.value)
|
|
6834
7455
|
navigator.vibrate(pattern2);
|
|
6835
7456
|
};
|
|
6836
7457
|
const stop = () => {
|
|
6837
|
-
if (isSupported)
|
|
7458
|
+
if (isSupported.value)
|
|
6838
7459
|
navigator.vibrate(0);
|
|
6839
7460
|
intervalControls == null ? void 0 : intervalControls.pause();
|
|
6840
7461
|
};
|
|
@@ -6854,48 +7475,68 @@ function useVibrate(options) {
|
|
|
6854
7475
|
}
|
|
6855
7476
|
|
|
6856
7477
|
function useVirtualList(list, options) {
|
|
6857
|
-
const containerRef =
|
|
7478
|
+
const { containerStyle, wrapperProps, scrollTo, calculateRange, currentList, containerRef } = "itemHeight" in options ? useVerticalVirtualList(options, list) : useHorizontalVirtualList(options, list);
|
|
7479
|
+
return {
|
|
7480
|
+
list: currentList,
|
|
7481
|
+
scrollTo,
|
|
7482
|
+
containerProps: {
|
|
7483
|
+
ref: containerRef,
|
|
7484
|
+
onScroll: () => {
|
|
7485
|
+
calculateRange();
|
|
7486
|
+
},
|
|
7487
|
+
style: containerStyle
|
|
7488
|
+
},
|
|
7489
|
+
wrapperProps
|
|
7490
|
+
};
|
|
7491
|
+
}
|
|
7492
|
+
function useVirtualListResources(list) {
|
|
7493
|
+
const containerRef = ref(null);
|
|
6858
7494
|
const size = useElementSize(containerRef);
|
|
6859
7495
|
const currentList = ref([]);
|
|
6860
7496
|
const source = shallowRef(list);
|
|
6861
7497
|
const state = ref({ start: 0, end: 10 });
|
|
6862
|
-
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
|
|
7498
|
+
return { state, source, currentList, size, containerRef };
|
|
7499
|
+
}
|
|
7500
|
+
function createGetViewCapacity(state, source, itemSize) {
|
|
7501
|
+
return (containerSize) => {
|
|
7502
|
+
if (typeof itemSize === "number")
|
|
7503
|
+
return Math.ceil(containerSize / itemSize);
|
|
6866
7504
|
const { start = 0 } = state.value;
|
|
6867
7505
|
let sum = 0;
|
|
6868
7506
|
let capacity = 0;
|
|
6869
7507
|
for (let i = start; i < source.value.length; i++) {
|
|
6870
|
-
const
|
|
6871
|
-
sum +=
|
|
6872
|
-
|
|
6873
|
-
|
|
7508
|
+
const size = itemSize(i);
|
|
7509
|
+
sum += size;
|
|
7510
|
+
capacity = i;
|
|
7511
|
+
if (sum > containerSize)
|
|
6874
7512
|
break;
|
|
6875
|
-
}
|
|
6876
7513
|
}
|
|
6877
7514
|
return capacity - start;
|
|
6878
7515
|
};
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
|
|
7516
|
+
}
|
|
7517
|
+
function createGetOffset(source, itemSize) {
|
|
7518
|
+
return (scrollDirection) => {
|
|
7519
|
+
if (typeof itemSize === "number")
|
|
7520
|
+
return Math.floor(scrollDirection / itemSize) + 1;
|
|
6882
7521
|
let sum = 0;
|
|
6883
7522
|
let offset = 0;
|
|
6884
7523
|
for (let i = 0; i < source.value.length; i++) {
|
|
6885
|
-
const
|
|
6886
|
-
sum +=
|
|
6887
|
-
if (sum >=
|
|
7524
|
+
const size = itemSize(i);
|
|
7525
|
+
sum += size;
|
|
7526
|
+
if (sum >= scrollDirection) {
|
|
6888
7527
|
offset = i;
|
|
6889
7528
|
break;
|
|
6890
7529
|
}
|
|
6891
7530
|
}
|
|
6892
7531
|
return offset + 1;
|
|
6893
7532
|
};
|
|
6894
|
-
|
|
7533
|
+
}
|
|
7534
|
+
function createCalculateRange(type, overscan, getOffset, getViewCapacity, { containerRef, state, currentList, source }) {
|
|
7535
|
+
return () => {
|
|
6895
7536
|
const element = containerRef.value;
|
|
6896
7537
|
if (element) {
|
|
6897
|
-
const offset = getOffset(element.scrollTop);
|
|
6898
|
-
const viewCapacity = getViewCapacity(element.clientHeight);
|
|
7538
|
+
const offset = getOffset(type === "vertical" ? element.scrollTop : element.scrollLeft);
|
|
7539
|
+
const viewCapacity = getViewCapacity(type === "vertical" ? element.clientHeight : element.clientWidth);
|
|
6899
7540
|
const from = offset - overscan;
|
|
6900
7541
|
const to = offset + viewCapacity + overscan;
|
|
6901
7542
|
state.value = {
|
|
@@ -6908,29 +7549,86 @@ function useVirtualList(list, options) {
|
|
|
6908
7549
|
}));
|
|
6909
7550
|
}
|
|
6910
7551
|
};
|
|
7552
|
+
}
|
|
7553
|
+
function createGetDistance(itemSize, source) {
|
|
7554
|
+
return (index) => {
|
|
7555
|
+
if (typeof itemSize === "number") {
|
|
7556
|
+
const size2 = index * itemSize;
|
|
7557
|
+
return size2;
|
|
7558
|
+
}
|
|
7559
|
+
const size = source.value.slice(0, index).reduce((sum, _, i) => sum + itemSize(i), 0);
|
|
7560
|
+
return size;
|
|
7561
|
+
};
|
|
7562
|
+
}
|
|
7563
|
+
function useWatchForSizes(size, list, calculateRange) {
|
|
6911
7564
|
watch([size.width, size.height, list], () => {
|
|
6912
7565
|
calculateRange();
|
|
6913
7566
|
});
|
|
6914
|
-
|
|
6915
|
-
|
|
6916
|
-
|
|
6917
|
-
|
|
7567
|
+
}
|
|
7568
|
+
function createComputedTotalSize(itemSize, source) {
|
|
7569
|
+
return computed(() => {
|
|
7570
|
+
if (typeof itemSize === "number")
|
|
7571
|
+
return source.value.length * itemSize;
|
|
7572
|
+
return source.value.reduce((sum, _, index) => sum + itemSize(index), 0);
|
|
6918
7573
|
});
|
|
6919
|
-
|
|
6920
|
-
|
|
6921
|
-
|
|
6922
|
-
|
|
6923
|
-
|
|
6924
|
-
|
|
6925
|
-
|
|
6926
|
-
};
|
|
6927
|
-
const scrollTo = (index) => {
|
|
7574
|
+
}
|
|
7575
|
+
const scrollToDictionaryForElementScrollKey = {
|
|
7576
|
+
horizontal: "scrollLeft",
|
|
7577
|
+
vertical: "scrollTop"
|
|
7578
|
+
};
|
|
7579
|
+
function createScrollTo(type, calculateRange, getDistance, containerRef) {
|
|
7580
|
+
return (index) => {
|
|
6928
7581
|
if (containerRef.value) {
|
|
6929
|
-
containerRef.value
|
|
7582
|
+
containerRef.value[scrollToDictionaryForElementScrollKey[type]] = getDistance(index);
|
|
6930
7583
|
calculateRange();
|
|
6931
7584
|
}
|
|
6932
7585
|
};
|
|
7586
|
+
}
|
|
7587
|
+
function useHorizontalVirtualList(options, list) {
|
|
7588
|
+
const resources = useVirtualListResources(list);
|
|
7589
|
+
const { state, source, currentList, size, containerRef } = resources;
|
|
7590
|
+
const containerStyle = { overflowX: "auto" };
|
|
7591
|
+
const { itemWidth, overscan = 5 } = options;
|
|
7592
|
+
const getViewCapacity = createGetViewCapacity(state, source, itemWidth);
|
|
7593
|
+
const getOffset = createGetOffset(source, itemWidth);
|
|
7594
|
+
const calculateRange = createCalculateRange("horizontal", overscan, getOffset, getViewCapacity, resources);
|
|
7595
|
+
const getDistanceLeft = createGetDistance(itemWidth, source);
|
|
7596
|
+
const offsetLeft = computed(() => getDistanceLeft(state.value.start));
|
|
7597
|
+
const totalWidth = createComputedTotalSize(itemWidth, source);
|
|
7598
|
+
useWatchForSizes(size, list, calculateRange);
|
|
7599
|
+
const scrollTo = createScrollTo("horizontal", calculateRange, getDistanceLeft, containerRef);
|
|
7600
|
+
const wrapperProps = computed(() => {
|
|
7601
|
+
return {
|
|
7602
|
+
style: {
|
|
7603
|
+
height: "100%",
|
|
7604
|
+
width: `${totalWidth.value - offsetLeft.value}px`,
|
|
7605
|
+
marginLeft: `${offsetLeft.value}px`,
|
|
7606
|
+
display: "flex"
|
|
7607
|
+
}
|
|
7608
|
+
};
|
|
7609
|
+
});
|
|
7610
|
+
return {
|
|
7611
|
+
scrollTo,
|
|
7612
|
+
calculateRange,
|
|
7613
|
+
wrapperProps,
|
|
7614
|
+
containerStyle,
|
|
7615
|
+
currentList,
|
|
7616
|
+
containerRef
|
|
7617
|
+
};
|
|
7618
|
+
}
|
|
7619
|
+
function useVerticalVirtualList(options, list) {
|
|
7620
|
+
const resources = useVirtualListResources(list);
|
|
7621
|
+
const { state, source, currentList, size, containerRef } = resources;
|
|
7622
|
+
const containerStyle = { overflowY: "auto" };
|
|
7623
|
+
const { itemHeight, overscan = 5 } = options;
|
|
7624
|
+
const getViewCapacity = createGetViewCapacity(state, source, itemHeight);
|
|
7625
|
+
const getOffset = createGetOffset(source, itemHeight);
|
|
7626
|
+
const calculateRange = createCalculateRange("vertical", overscan, getOffset, getViewCapacity, resources);
|
|
7627
|
+
const getDistanceTop = createGetDistance(itemHeight, source);
|
|
6933
7628
|
const offsetTop = computed(() => getDistanceTop(state.value.start));
|
|
7629
|
+
const totalHeight = createComputedTotalSize(itemHeight, source);
|
|
7630
|
+
useWatchForSizes(size, list, calculateRange);
|
|
7631
|
+
const scrollTo = createScrollTo("vertical", calculateRange, getDistanceTop, containerRef);
|
|
6934
7632
|
const wrapperProps = computed(() => {
|
|
6935
7633
|
return {
|
|
6936
7634
|
style: {
|
|
@@ -6940,18 +7638,13 @@ function useVirtualList(list, options) {
|
|
|
6940
7638
|
}
|
|
6941
7639
|
};
|
|
6942
7640
|
});
|
|
6943
|
-
const containerStyle = { overflowY: "auto" };
|
|
6944
7641
|
return {
|
|
6945
|
-
|
|
7642
|
+
calculateRange,
|
|
6946
7643
|
scrollTo,
|
|
6947
|
-
|
|
6948
|
-
|
|
6949
|
-
|
|
6950
|
-
|
|
6951
|
-
},
|
|
6952
|
-
style: containerStyle
|
|
6953
|
-
},
|
|
6954
|
-
wrapperProps
|
|
7644
|
+
containerStyle,
|
|
7645
|
+
wrapperProps,
|
|
7646
|
+
currentList,
|
|
7647
|
+
containerRef
|
|
6955
7648
|
};
|
|
6956
7649
|
}
|
|
6957
7650
|
|
|
@@ -6961,10 +7654,10 @@ const useWakeLock = (options = {}) => {
|
|
|
6961
7654
|
document = defaultDocument
|
|
6962
7655
|
} = options;
|
|
6963
7656
|
let wakeLock;
|
|
6964
|
-
const isSupported = navigator && "wakeLock" in navigator;
|
|
7657
|
+
const isSupported = useSupported(() => navigator && "wakeLock" in navigator);
|
|
6965
7658
|
const isActive = ref(false);
|
|
6966
7659
|
async function onVisibilityChange() {
|
|
6967
|
-
if (!isSupported || !wakeLock)
|
|
7660
|
+
if (!isSupported.value || !wakeLock)
|
|
6968
7661
|
return;
|
|
6969
7662
|
if (document && document.visibilityState === "visible")
|
|
6970
7663
|
wakeLock = await navigator.wakeLock.request("screen");
|
|
@@ -6973,13 +7666,13 @@ const useWakeLock = (options = {}) => {
|
|
|
6973
7666
|
if (document)
|
|
6974
7667
|
useEventListener(document, "visibilitychange", onVisibilityChange, { passive: true });
|
|
6975
7668
|
async function request(type) {
|
|
6976
|
-
if (!isSupported)
|
|
7669
|
+
if (!isSupported.value)
|
|
6977
7670
|
return;
|
|
6978
7671
|
wakeLock = await navigator.wakeLock.request(type);
|
|
6979
7672
|
isActive.value = !wakeLock.released;
|
|
6980
7673
|
}
|
|
6981
7674
|
async function release() {
|
|
6982
|
-
if (!isSupported || !wakeLock)
|
|
7675
|
+
if (!isSupported.value || !wakeLock)
|
|
6983
7676
|
return;
|
|
6984
7677
|
await wakeLock.release();
|
|
6985
7678
|
isActive.value = !wakeLock.released;
|
|
@@ -6997,10 +7690,10 @@ const useWebNotification = (defaultOptions = {}) => {
|
|
|
6997
7690
|
const {
|
|
6998
7691
|
window = defaultWindow
|
|
6999
7692
|
} = defaultOptions;
|
|
7000
|
-
const isSupported = !!window && "Notification" in window;
|
|
7693
|
+
const isSupported = useSupported(() => !!window && "Notification" in window);
|
|
7001
7694
|
const notification = ref(null);
|
|
7002
7695
|
const requestPermission = async () => {
|
|
7003
|
-
if (!isSupported)
|
|
7696
|
+
if (!isSupported.value)
|
|
7004
7697
|
return;
|
|
7005
7698
|
if ("permission" in Notification && Notification.permission !== "denied")
|
|
7006
7699
|
await Notification.requestPermission();
|
|
@@ -7010,7 +7703,7 @@ const useWebNotification = (defaultOptions = {}) => {
|
|
|
7010
7703
|
const onError = createEventHook();
|
|
7011
7704
|
const onClose = createEventHook();
|
|
7012
7705
|
const show = async (overrides) => {
|
|
7013
|
-
if (!isSupported)
|
|
7706
|
+
if (!isSupported.value)
|
|
7014
7707
|
return;
|
|
7015
7708
|
await requestPermission();
|
|
7016
7709
|
const options = Object.assign({}, defaultOptions, overrides);
|
|
@@ -7027,11 +7720,11 @@ const useWebNotification = (defaultOptions = {}) => {
|
|
|
7027
7720
|
notification.value = null;
|
|
7028
7721
|
};
|
|
7029
7722
|
tryOnMounted(async () => {
|
|
7030
|
-
if (isSupported)
|
|
7723
|
+
if (isSupported.value)
|
|
7031
7724
|
await requestPermission();
|
|
7032
7725
|
});
|
|
7033
7726
|
tryOnScopeDispose(close);
|
|
7034
|
-
if (isSupported && window) {
|
|
7727
|
+
if (isSupported.value && window) {
|
|
7035
7728
|
const document = window.document;
|
|
7036
7729
|
useEventListener(document, "visibilitychange", (e) => {
|
|
7037
7730
|
e.preventDefault();
|
|
@@ -7052,6 +7745,7 @@ const useWebNotification = (defaultOptions = {}) => {
|
|
|
7052
7745
|
};
|
|
7053
7746
|
};
|
|
7054
7747
|
|
|
7748
|
+
const DEFAULT_PING_MESSAGE = "ping";
|
|
7055
7749
|
function resolveNestedOptions(options) {
|
|
7056
7750
|
if (options === true)
|
|
7057
7751
|
return {};
|
|
@@ -7068,13 +7762,15 @@ function useWebSocket(url, options = {}) {
|
|
|
7068
7762
|
protocols = []
|
|
7069
7763
|
} = options;
|
|
7070
7764
|
const data = ref(null);
|
|
7071
|
-
const status = ref("
|
|
7765
|
+
const status = ref("CLOSED");
|
|
7072
7766
|
const wsRef = ref();
|
|
7767
|
+
const urlRef = resolveRef(url);
|
|
7073
7768
|
let heartbeatPause;
|
|
7074
7769
|
let heartbeatResume;
|
|
7075
7770
|
let explicitlyClosed = false;
|
|
7076
7771
|
let retried = 0;
|
|
7077
7772
|
let bufferedData = [];
|
|
7773
|
+
let pongTimeoutWait;
|
|
7078
7774
|
const close = (code = 1e3, reason) => {
|
|
7079
7775
|
if (!wsRef.value)
|
|
7080
7776
|
return;
|
|
@@ -7089,6 +7785,10 @@ function useWebSocket(url, options = {}) {
|
|
|
7089
7785
|
bufferedData = [];
|
|
7090
7786
|
}
|
|
7091
7787
|
};
|
|
7788
|
+
const resetHeartbeat = () => {
|
|
7789
|
+
clearTimeout(pongTimeoutWait);
|
|
7790
|
+
pongTimeoutWait = void 0;
|
|
7791
|
+
};
|
|
7092
7792
|
const send = (data2, useBuffer = true) => {
|
|
7093
7793
|
if (!wsRef.value || status.value !== "OPEN") {
|
|
7094
7794
|
if (useBuffer)
|
|
@@ -7100,10 +7800,11 @@ function useWebSocket(url, options = {}) {
|
|
|
7100
7800
|
return true;
|
|
7101
7801
|
};
|
|
7102
7802
|
const _init = () => {
|
|
7103
|
-
|
|
7803
|
+
if (explicitlyClosed || typeof urlRef.value === "undefined")
|
|
7804
|
+
return;
|
|
7805
|
+
const ws = new WebSocket(urlRef.value, protocols);
|
|
7104
7806
|
wsRef.value = ws;
|
|
7105
7807
|
status.value = "CONNECTING";
|
|
7106
|
-
explicitlyClosed = false;
|
|
7107
7808
|
ws.onopen = () => {
|
|
7108
7809
|
status.value = "OPEN";
|
|
7109
7810
|
onConnected == null ? void 0 : onConnected(ws);
|
|
@@ -7133,30 +7834,47 @@ function useWebSocket(url, options = {}) {
|
|
|
7133
7834
|
onError == null ? void 0 : onError(ws, e);
|
|
7134
7835
|
};
|
|
7135
7836
|
ws.onmessage = (e) => {
|
|
7837
|
+
if (options.heartbeat) {
|
|
7838
|
+
resetHeartbeat();
|
|
7839
|
+
const {
|
|
7840
|
+
message = DEFAULT_PING_MESSAGE
|
|
7841
|
+
} = resolveNestedOptions(options.heartbeat);
|
|
7842
|
+
if (e.data === message)
|
|
7843
|
+
return;
|
|
7844
|
+
}
|
|
7136
7845
|
data.value = e.data;
|
|
7137
7846
|
onMessage == null ? void 0 : onMessage(ws, e);
|
|
7138
7847
|
};
|
|
7139
7848
|
};
|
|
7140
7849
|
if (options.heartbeat) {
|
|
7141
7850
|
const {
|
|
7142
|
-
message =
|
|
7143
|
-
interval = 1e3
|
|
7851
|
+
message = DEFAULT_PING_MESSAGE,
|
|
7852
|
+
interval = 1e3,
|
|
7853
|
+
pongTimeout = 1e3
|
|
7144
7854
|
} = resolveNestedOptions(options.heartbeat);
|
|
7145
|
-
const { pause, resume } = useIntervalFn(() =>
|
|
7855
|
+
const { pause, resume } = useIntervalFn(() => {
|
|
7856
|
+
send(message, false);
|
|
7857
|
+
if (pongTimeoutWait != null)
|
|
7858
|
+
return;
|
|
7859
|
+
pongTimeoutWait = setTimeout(() => {
|
|
7860
|
+
close();
|
|
7861
|
+
}, pongTimeout);
|
|
7862
|
+
}, interval, { immediate: false });
|
|
7146
7863
|
heartbeatPause = pause;
|
|
7147
7864
|
heartbeatResume = resume;
|
|
7148
7865
|
}
|
|
7149
|
-
if (immediate)
|
|
7150
|
-
_init();
|
|
7151
7866
|
if (autoClose) {
|
|
7152
7867
|
useEventListener(window, "beforeunload", () => close());
|
|
7153
7868
|
tryOnScopeDispose(close);
|
|
7154
7869
|
}
|
|
7155
7870
|
const open = () => {
|
|
7156
7871
|
close();
|
|
7872
|
+
explicitlyClosed = false;
|
|
7157
7873
|
retried = 0;
|
|
7158
7874
|
_init();
|
|
7159
7875
|
};
|
|
7876
|
+
if (immediate)
|
|
7877
|
+
watch(urlRef, open, { immediate: true });
|
|
7160
7878
|
return {
|
|
7161
7879
|
data,
|
|
7162
7880
|
status,
|
|
@@ -7167,10 +7885,10 @@ function useWebSocket(url, options = {}) {
|
|
|
7167
7885
|
};
|
|
7168
7886
|
}
|
|
7169
7887
|
|
|
7170
|
-
function useWebWorker(
|
|
7888
|
+
function useWebWorker(arg0, workerOptions, options) {
|
|
7171
7889
|
const {
|
|
7172
7890
|
window = defaultWindow
|
|
7173
|
-
} = options;
|
|
7891
|
+
} = options != null ? options : {};
|
|
7174
7892
|
const data = ref(null);
|
|
7175
7893
|
const worker = shallowRef();
|
|
7176
7894
|
const post = function post2(val) {
|
|
@@ -7184,7 +7902,12 @@ function useWebWorker(url, workerOptions, options = {}) {
|
|
|
7184
7902
|
worker.value.terminate();
|
|
7185
7903
|
};
|
|
7186
7904
|
if (window) {
|
|
7187
|
-
|
|
7905
|
+
if (isString(arg0))
|
|
7906
|
+
worker.value = new Worker(arg0, workerOptions);
|
|
7907
|
+
else if (isFunction(arg0))
|
|
7908
|
+
worker.value = arg0();
|
|
7909
|
+
else
|
|
7910
|
+
worker.value = arg0;
|
|
7188
7911
|
worker.value.onmessage = (e) => {
|
|
7189
7912
|
data.value = e.data;
|
|
7190
7913
|
};
|
|
@@ -7322,7 +8045,7 @@ function useWindowScroll({ window = defaultWindow } = {}) {
|
|
|
7322
8045
|
}
|
|
7323
8046
|
const x = ref(window.pageXOffset);
|
|
7324
8047
|
const y = ref(window.pageYOffset);
|
|
7325
|
-
useEventListener("scroll", () => {
|
|
8048
|
+
useEventListener(window, "scroll", () => {
|
|
7326
8049
|
x.value = window.pageXOffset;
|
|
7327
8050
|
y.value = window.pageYOffset;
|
|
7328
8051
|
}, {
|
|
@@ -7337,14 +8060,20 @@ function useWindowSize(options = {}) {
|
|
|
7337
8060
|
window = defaultWindow,
|
|
7338
8061
|
initialWidth = Infinity,
|
|
7339
8062
|
initialHeight = Infinity,
|
|
7340
|
-
listenOrientation = true
|
|
8063
|
+
listenOrientation = true,
|
|
8064
|
+
includeScrollbar = true
|
|
7341
8065
|
} = options;
|
|
7342
8066
|
const width = ref(initialWidth);
|
|
7343
8067
|
const height = ref(initialHeight);
|
|
7344
8068
|
const update = () => {
|
|
7345
8069
|
if (window) {
|
|
7346
|
-
|
|
7347
|
-
|
|
8070
|
+
if (includeScrollbar) {
|
|
8071
|
+
width.value = window.innerWidth;
|
|
8072
|
+
height.value = window.innerHeight;
|
|
8073
|
+
} else {
|
|
8074
|
+
width.value = window.document.documentElement.clientWidth;
|
|
8075
|
+
height.value = window.document.documentElement.clientHeight;
|
|
8076
|
+
}
|
|
7348
8077
|
}
|
|
7349
8078
|
};
|
|
7350
8079
|
update();
|
|
@@ -7355,4 +8084,4 @@ function useWindowSize(options = {}) {
|
|
|
7355
8084
|
return { width, height };
|
|
7356
8085
|
}
|
|
7357
8086
|
|
|
7358
|
-
export { DefaultMagicKeysAliasMap, StorageSerializers, SwipeDirection, TransitionPresets,
|
|
8087
|
+
export { DefaultMagicKeysAliasMap, StorageSerializers, SwipeDirection, TransitionPresets, __onlyVue27Plus, __onlyVue3, assert, computedAsync as asyncComputed, refAutoReset as autoResetRef, breakpointsAntDesign, breakpointsBootstrapV5, breakpointsMasterCss, breakpointsQuasar, breakpointsSematic, breakpointsTailwind, breakpointsVuetify, bypassFilter, clamp, cloneFnJSON, computedAsync, computedEager, computedInject, computedWithControl, containsProp, computedWithControl as controlledComputed, controlledRef, createEventHook, createFetch, createFilterWrapper, createGlobalState, createInjectionState, reactify as createReactiveFn, createSharedComposable, createSingletonPromise, createUnrefFn, debounceFilter, refDebounced as debouncedRef, watchDebounced as debouncedWatch, defaultDocument, defaultLocation, defaultNavigator, defaultWindow, directiveHooks, computedEager as eagerComputed, extendRef, formatDate, formatTimeAgo, get, getSSRHandler, hasOwn, identity, watchIgnorable as ignorableWatch, increaseWithUnit, invoke, isBoolean, isClient, isDef, isDefined, isFunction, isIOS, isNumber, isObject, isString, isWindow, makeDestructurable, mapGamepadToXbox360Controller, noop, normalizeDate, now, objectPick, onClickOutside, onKeyDown, onKeyPressed, onKeyStroke, onKeyUp, onLongPress, onStartTyping, pausableFilter, watchPausable as pausableWatch, promiseTimeout, 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, toRefs, tryOnBeforeMount, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, unrefElement, until, useActiveElement, useArrayEvery, useArrayFilter, useArrayFind, useArrayFindIndex, useArrayJoin, useArrayMap, useArrayReduce, useArraySome, useArrayUnique, useAsyncQueue, useAsyncState, useBase64, useBattery, useBluetooth, useBreakpoints, useBroadcastChannel, useBrowserLocation, useCached, useClipboard, 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, 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, watchIgnorable, watchOnce, watchPausable, watchThrottled, watchTriggerable, watchWithFilter, whenever };
|