@vueuse/shared 12.2.0 → 12.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +95 -92
- package/index.d.cts +10 -5
- package/index.d.mts +10 -5
- package/index.d.ts +10 -5
- package/index.iife.js +95 -92
- package/index.iife.min.js +1 -1
- package/index.mjs +96 -94
- package/package.json +1 -1
package/index.iife.js
CHANGED
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
result.value = fn();
|
|
9
9
|
}, {
|
|
10
10
|
...options,
|
|
11
|
-
flush: (_a = options == null ?
|
|
11
|
+
flush: (_a = options == null ? undefined : options.flush) != null ? _a : "sync"
|
|
12
12
|
});
|
|
13
13
|
return vue.readonly(result);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
function computedWithControl(source, fn) {
|
|
17
|
-
let v =
|
|
17
|
+
let v = undefined;
|
|
18
18
|
let track;
|
|
19
19
|
let trigger;
|
|
20
20
|
const dirty = vue.ref(true);
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
};
|
|
25
25
|
vue.watch(source, update, { flush: "sync" });
|
|
26
26
|
const get = typeof fn === "function" ? fn : fn.get;
|
|
27
|
-
const set = typeof fn === "function" ?
|
|
27
|
+
const set = typeof fn === "function" ? undefined : fn.set;
|
|
28
28
|
const result = vue.customRef((_track, _trigger) => {
|
|
29
29
|
track = _track;
|
|
30
30
|
trigger = _trigger;
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
return v;
|
|
39
39
|
},
|
|
40
40
|
set(v2) {
|
|
41
|
-
set == null ?
|
|
41
|
+
set == null ? undefined : set(v2);
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
});
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
const injectLocal = (...args) => {
|
|
101
101
|
var _a;
|
|
102
102
|
const key = args[0];
|
|
103
|
-
const instance = (_a = vue.getCurrentInstance()) == null ?
|
|
103
|
+
const instance = (_a = vue.getCurrentInstance()) == null ? undefined : _a.proxy;
|
|
104
104
|
if (instance == null && !vue.hasInjectionContext())
|
|
105
105
|
throw new Error("injectLocal must be called in setup");
|
|
106
106
|
if (instance && localProvidedStateMap.has(instance) && key in localProvidedStateMap.get(instance))
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
|
|
111
111
|
const provideLocal = (key, value) => {
|
|
112
112
|
var _a;
|
|
113
|
-
const instance = (_a = vue.getCurrentInstance()) == null ?
|
|
113
|
+
const instance = (_a = vue.getCurrentInstance()) == null ? undefined : _a.proxy;
|
|
114
114
|
if (instance == null)
|
|
115
115
|
throw new Error("provideLocal must be called in setup");
|
|
116
116
|
if (!localProvidedStateMap.has(instance))
|
|
@@ -121,8 +121,8 @@
|
|
|
121
121
|
};
|
|
122
122
|
|
|
123
123
|
function createInjectionState(composable, options) {
|
|
124
|
-
const key = (options == null ?
|
|
125
|
-
const defaultValue = options == null ?
|
|
124
|
+
const key = (options == null ? undefined : options.injectionKey) || Symbol(composable.name || "InjectionState");
|
|
125
|
+
const defaultValue = options == null ? undefined : options.defaultValue;
|
|
126
126
|
const useProvidingState = (...args) => {
|
|
127
127
|
const state = composable(...args);
|
|
128
128
|
provideLocal(key, state);
|
|
@@ -140,8 +140,8 @@
|
|
|
140
140
|
subscribers -= 1;
|
|
141
141
|
if (scope && subscribers <= 0) {
|
|
142
142
|
scope.stop();
|
|
143
|
-
state =
|
|
144
|
-
scope =
|
|
143
|
+
state = undefined;
|
|
144
|
+
scope = undefined;
|
|
145
145
|
}
|
|
146
146
|
};
|
|
147
147
|
return (...args) => {
|
|
@@ -207,13 +207,8 @@
|
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
-
function toValue(r) {
|
|
211
|
-
return typeof r === "function" ? r() : vue.unref(r);
|
|
212
|
-
}
|
|
213
|
-
const resolveUnref = toValue;
|
|
214
|
-
|
|
215
210
|
function reactify(fn, options) {
|
|
216
|
-
const unrefFn = (options == null ?
|
|
211
|
+
const unrefFn = (options == null ? undefined : options.computedGetter) === false ? vue.unref : vue.toValue;
|
|
217
212
|
return function(...args) {
|
|
218
213
|
return vue.computed(() => fn.apply(this, args.map((i) => unrefFn(i))));
|
|
219
214
|
};
|
|
@@ -282,7 +277,7 @@
|
|
|
282
277
|
function reactiveOmit(obj, ...keys) {
|
|
283
278
|
const flatKeys = keys.flat();
|
|
284
279
|
const predicate = flatKeys[0];
|
|
285
|
-
return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(vue.toRefs(obj)).filter(([k, v]) => !predicate(toValue(v), k))) : Object.fromEntries(Object.entries(vue.toRefs(obj)).filter((e) => !flatKeys.includes(e[0]))));
|
|
280
|
+
return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(vue.toRefs(obj)).filter(([k, v]) => !predicate(vue.toValue(v), k))) : Object.fromEntries(Object.entries(vue.toRefs(obj)).filter((e) => !flatKeys.includes(e[0]))));
|
|
286
281
|
}
|
|
287
282
|
|
|
288
283
|
const isClient = typeof window !== "undefined" && typeof document !== "undefined";
|
|
@@ -309,7 +304,7 @@
|
|
|
309
304
|
const isIOS = /* @__PURE__ */ getIsIOS();
|
|
310
305
|
function getIsIOS() {
|
|
311
306
|
var _a, _b;
|
|
312
|
-
return isClient && ((_a = window == null ?
|
|
307
|
+
return isClient && ((_a = window == null ? undefined : window.navigator) == null ? undefined : _a.userAgent) && (/iP(?:ad|hone|od)/.test(window.navigator.userAgent) || ((_b = window == null ? undefined : window.navigator) == null ? undefined : _b.maxTouchPoints) > 2 && /iPad|Macintosh/.test(window == null ? undefined : window.navigator.userAgent));
|
|
313
308
|
}
|
|
314
309
|
|
|
315
310
|
function createFilterWrapper(filter, fn) {
|
|
@@ -333,11 +328,11 @@
|
|
|
333
328
|
lastRejector = noop;
|
|
334
329
|
};
|
|
335
330
|
const filter = (invoke) => {
|
|
336
|
-
const duration = toValue(ms);
|
|
337
|
-
const maxDuration = toValue(options.maxWait);
|
|
331
|
+
const duration = vue.toValue(ms);
|
|
332
|
+
const maxDuration = vue.toValue(options.maxWait);
|
|
338
333
|
if (timer)
|
|
339
334
|
_clearTimeout(timer);
|
|
340
|
-
if (duration <= 0 || maxDuration !==
|
|
335
|
+
if (duration <= 0 || maxDuration !== undefined && maxDuration <= 0) {
|
|
341
336
|
if (maxTimer) {
|
|
342
337
|
_clearTimeout(maxTimer);
|
|
343
338
|
maxTimer = null;
|
|
@@ -381,13 +376,13 @@
|
|
|
381
376
|
const clear = () => {
|
|
382
377
|
if (timer) {
|
|
383
378
|
clearTimeout(timer);
|
|
384
|
-
timer =
|
|
379
|
+
timer = undefined;
|
|
385
380
|
lastRejector();
|
|
386
381
|
lastRejector = noop;
|
|
387
382
|
}
|
|
388
383
|
};
|
|
389
384
|
const filter = (_invoke) => {
|
|
390
|
-
const duration = toValue(ms);
|
|
385
|
+
const duration = vue.toValue(ms);
|
|
391
386
|
const elapsed = Date.now() - lastExec;
|
|
392
387
|
const invoke = () => {
|
|
393
388
|
return lastValue = _invoke();
|
|
@@ -467,7 +462,7 @@
|
|
|
467
462
|
}
|
|
468
463
|
wrapper.reset = async () => {
|
|
469
464
|
const _prev = _promise;
|
|
470
|
-
_promise =
|
|
465
|
+
_promise = undefined;
|
|
471
466
|
if (_prev)
|
|
472
467
|
await _prev;
|
|
473
468
|
};
|
|
@@ -483,7 +478,7 @@
|
|
|
483
478
|
var _a;
|
|
484
479
|
if (typeof target === "number")
|
|
485
480
|
return target + delta;
|
|
486
|
-
const value = ((_a = target.match(/^-?\d+\.?\d*/)) == null ?
|
|
481
|
+
const value = ((_a = target.match(/^-?\d+\.?\d*/)) == null ? undefined : _a[0]) || "";
|
|
487
482
|
const unit = target.slice(value.length);
|
|
488
483
|
const result = Number.parseFloat(value) + delta;
|
|
489
484
|
if (Number.isNaN(result))
|
|
@@ -496,7 +491,7 @@
|
|
|
496
491
|
function objectPick(obj, keys, omitUndefined = false) {
|
|
497
492
|
return keys.reduce((n, k) => {
|
|
498
493
|
if (k in obj) {
|
|
499
|
-
if (!omitUndefined || obj[k] !==
|
|
494
|
+
if (!omitUndefined || obj[k] !== undefined)
|
|
500
495
|
n[k] = obj[k];
|
|
501
496
|
}
|
|
502
497
|
return n;
|
|
@@ -504,7 +499,7 @@
|
|
|
504
499
|
}
|
|
505
500
|
function objectOmit(obj, keys, omitUndefined = false) {
|
|
506
501
|
return Object.fromEntries(Object.entries(obj).filter(([key, value]) => {
|
|
507
|
-
return (!omitUndefined || value !==
|
|
502
|
+
return (!omitUndefined || value !== undefined) && !keys.includes(key);
|
|
508
503
|
}));
|
|
509
504
|
}
|
|
510
505
|
function objectEntries(obj) {
|
|
@@ -513,6 +508,9 @@
|
|
|
513
508
|
function getLifeCycleTarget(target) {
|
|
514
509
|
return target || vue.getCurrentInstance();
|
|
515
510
|
}
|
|
511
|
+
function toArray(value) {
|
|
512
|
+
return Array.isArray(value) ? value : [value];
|
|
513
|
+
}
|
|
516
514
|
|
|
517
515
|
function toRef(...args) {
|
|
518
516
|
if (args.length !== 1)
|
|
@@ -525,17 +523,17 @@
|
|
|
525
523
|
function reactivePick(obj, ...keys) {
|
|
526
524
|
const flatKeys = keys.flat();
|
|
527
525
|
const predicate = flatKeys[0];
|
|
528
|
-
return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(vue.toRefs(obj)).filter(([k, v]) => predicate(toValue(v), k))) : Object.fromEntries(flatKeys.map((k) => [k, toRef(obj, k)])));
|
|
526
|
+
return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(vue.toRefs(obj)).filter(([k, v]) => predicate(vue.toValue(v), k))) : Object.fromEntries(flatKeys.map((k) => [k, toRef(obj, k)])));
|
|
529
527
|
}
|
|
530
528
|
|
|
531
529
|
function refAutoReset(defaultValue, afterMs = 1e4) {
|
|
532
530
|
return vue.customRef((track, trigger) => {
|
|
533
|
-
let value = toValue(defaultValue);
|
|
531
|
+
let value = vue.toValue(defaultValue);
|
|
534
532
|
let timer;
|
|
535
533
|
const resetAfter = () => setTimeout(() => {
|
|
536
|
-
value = toValue(defaultValue);
|
|
534
|
+
value = vue.toValue(defaultValue);
|
|
537
535
|
trigger();
|
|
538
|
-
}, toValue(afterMs));
|
|
536
|
+
}, vue.toValue(afterMs));
|
|
539
537
|
tryOnScopeDispose(() => {
|
|
540
538
|
clearTimeout(timer);
|
|
541
539
|
});
|
|
@@ -626,10 +624,10 @@
|
|
|
626
624
|
if (value === source)
|
|
627
625
|
return;
|
|
628
626
|
const old = source;
|
|
629
|
-
if (((_a = options.onBeforeChange) == null ?
|
|
627
|
+
if (((_a = options.onBeforeChange) == null ? undefined : _a.call(options, value, old)) === false)
|
|
630
628
|
return;
|
|
631
629
|
source = value;
|
|
632
|
-
(_b = options.onChanged) == null ?
|
|
630
|
+
(_b = options.onChanged) == null ? undefined : _b.call(options, value, old);
|
|
633
631
|
if (triggering)
|
|
634
632
|
trigger();
|
|
635
633
|
}
|
|
@@ -740,8 +738,7 @@
|
|
|
740
738
|
deep = false,
|
|
741
739
|
immediate = true
|
|
742
740
|
} = options;
|
|
743
|
-
|
|
744
|
-
targets = [targets];
|
|
741
|
+
targets = toArray(targets);
|
|
745
742
|
return vue.watch(
|
|
746
743
|
source,
|
|
747
744
|
(newValue) => targets.forEach((target) => target.value = newValue),
|
|
@@ -760,7 +757,7 @@
|
|
|
760
757
|
},
|
|
761
758
|
set(v) {
|
|
762
759
|
var _a;
|
|
763
|
-
const replaceRef = (_a = toValue(options.replaceRef)) != null ? _a : true;
|
|
760
|
+
const replaceRef = (_a = vue.toValue(options.replaceRef)) != null ? _a : true;
|
|
764
761
|
if (replaceRef) {
|
|
765
762
|
if (Array.isArray(objectRef.value)) {
|
|
766
763
|
const copy = [...objectRef.value];
|
|
@@ -780,6 +777,9 @@
|
|
|
780
777
|
return result;
|
|
781
778
|
}
|
|
782
779
|
|
|
780
|
+
const toValue = vue.toValue;
|
|
781
|
+
const resolveUnref = vue.toValue;
|
|
782
|
+
|
|
783
783
|
function tryOnBeforeMount(fn, sync = true, target) {
|
|
784
784
|
const instance = getLifeCycleTarget(target);
|
|
785
785
|
if (instance)
|
|
@@ -823,7 +823,7 @@
|
|
|
823
823
|
if (stop)
|
|
824
824
|
stop();
|
|
825
825
|
else
|
|
826
|
-
vue.nextTick(() => stop == null ?
|
|
826
|
+
vue.nextTick(() => stop == null ? undefined : stop());
|
|
827
827
|
resolve(v);
|
|
828
828
|
}
|
|
829
829
|
},
|
|
@@ -837,7 +837,7 @@
|
|
|
837
837
|
const promises = [watcher];
|
|
838
838
|
if (timeout != null) {
|
|
839
839
|
promises.push(
|
|
840
|
-
promiseTimeout(timeout, throwOnTimeout).then(() => toValue(r)).finally(() => stop == null ?
|
|
840
|
+
promiseTimeout(timeout, throwOnTimeout).then(() => vue.toValue(r)).finally(() => stop == null ? undefined : stop())
|
|
841
841
|
);
|
|
842
842
|
}
|
|
843
843
|
return Promise.race(promises);
|
|
@@ -855,7 +855,7 @@
|
|
|
855
855
|
if (stop)
|
|
856
856
|
stop();
|
|
857
857
|
else
|
|
858
|
-
vue.nextTick(() => stop == null ?
|
|
858
|
+
vue.nextTick(() => stop == null ? undefined : stop());
|
|
859
859
|
resolve(v1);
|
|
860
860
|
}
|
|
861
861
|
},
|
|
@@ -869,9 +869,9 @@
|
|
|
869
869
|
const promises = [watcher];
|
|
870
870
|
if (timeout != null) {
|
|
871
871
|
promises.push(
|
|
872
|
-
promiseTimeout(timeout, throwOnTimeout).then(() => toValue(r)).finally(() => {
|
|
873
|
-
stop == null ?
|
|
874
|
-
return toValue(r);
|
|
872
|
+
promiseTimeout(timeout, throwOnTimeout).then(() => vue.toValue(r)).finally(() => {
|
|
873
|
+
stop == null ? undefined : stop();
|
|
874
|
+
return vue.toValue(r);
|
|
875
875
|
})
|
|
876
876
|
);
|
|
877
877
|
}
|
|
@@ -884,7 +884,7 @@
|
|
|
884
884
|
return toBe(null, options);
|
|
885
885
|
}
|
|
886
886
|
function toBeUndefined(options) {
|
|
887
|
-
return toBe(
|
|
887
|
+
return toBe(undefined, options);
|
|
888
888
|
}
|
|
889
889
|
function toBeNaN(options) {
|
|
890
890
|
return toMatch(Number.isNaN, options);
|
|
@@ -892,7 +892,7 @@
|
|
|
892
892
|
function toContains(value, options) {
|
|
893
893
|
return toMatch((v) => {
|
|
894
894
|
const array = Array.from(v);
|
|
895
|
-
return array.includes(value) || array.includes(toValue(value));
|
|
895
|
+
return array.includes(value) || array.includes(vue.toValue(value));
|
|
896
896
|
}, options);
|
|
897
897
|
}
|
|
898
898
|
function changed(options) {
|
|
@@ -905,7 +905,7 @@
|
|
|
905
905
|
return count >= n;
|
|
906
906
|
}, options);
|
|
907
907
|
}
|
|
908
|
-
if (Array.isArray(toValue(r))) {
|
|
908
|
+
if (Array.isArray(vue.toValue(r))) {
|
|
909
909
|
const instance = {
|
|
910
910
|
toMatch,
|
|
911
911
|
toContains,
|
|
@@ -952,31 +952,31 @@
|
|
|
952
952
|
const key = compareFn;
|
|
953
953
|
compareFn = (value, othVal) => value[key] === othVal[key];
|
|
954
954
|
}
|
|
955
|
-
const diff1 = vue.computed(() => toValue(list).filter((x) => toValue(values).findIndex((y) => compareFn(x, y)) === -1));
|
|
955
|
+
const diff1 = vue.computed(() => vue.toValue(list).filter((x) => vue.toValue(values).findIndex((y) => compareFn(x, y)) === -1));
|
|
956
956
|
if (symmetric) {
|
|
957
|
-
const diff2 = vue.computed(() => toValue(values).filter((x) => toValue(list).findIndex((y) => compareFn(x, y)) === -1));
|
|
958
|
-
return vue.computed(() => symmetric ? [...toValue(diff1), ...toValue(diff2)] : toValue(diff1));
|
|
957
|
+
const diff2 = vue.computed(() => vue.toValue(values).filter((x) => vue.toValue(list).findIndex((y) => compareFn(x, y)) === -1));
|
|
958
|
+
return vue.computed(() => symmetric ? [...vue.toValue(diff1), ...vue.toValue(diff2)] : vue.toValue(diff1));
|
|
959
959
|
} else {
|
|
960
960
|
return diff1;
|
|
961
961
|
}
|
|
962
962
|
}
|
|
963
963
|
|
|
964
964
|
function useArrayEvery(list, fn) {
|
|
965
|
-
return vue.computed(() => toValue(list).every((element, index, array) => fn(toValue(element), index, array)));
|
|
965
|
+
return vue.computed(() => vue.toValue(list).every((element, index, array) => fn(vue.toValue(element), index, array)));
|
|
966
966
|
}
|
|
967
967
|
|
|
968
968
|
function useArrayFilter(list, fn) {
|
|
969
|
-
return vue.computed(() => toValue(list).map((i) => toValue(i)).filter(fn));
|
|
969
|
+
return vue.computed(() => vue.toValue(list).map((i) => vue.toValue(i)).filter(fn));
|
|
970
970
|
}
|
|
971
971
|
|
|
972
972
|
function useArrayFind(list, fn) {
|
|
973
|
-
return vue.computed(() => toValue(
|
|
974
|
-
toValue(list).find((element, index, array) => fn(toValue(element), index, array))
|
|
973
|
+
return vue.computed(() => vue.toValue(
|
|
974
|
+
vue.toValue(list).find((element, index, array) => fn(vue.toValue(element), index, array))
|
|
975
975
|
));
|
|
976
976
|
}
|
|
977
977
|
|
|
978
978
|
function useArrayFindIndex(list, fn) {
|
|
979
|
-
return vue.computed(() => toValue(list).findIndex((element, index, array) => fn(toValue(element), index, array)));
|
|
979
|
+
return vue.computed(() => vue.toValue(list).findIndex((element, index, array) => fn(vue.toValue(element), index, array)));
|
|
980
980
|
}
|
|
981
981
|
|
|
982
982
|
function findLast(arr, cb) {
|
|
@@ -985,11 +985,11 @@
|
|
|
985
985
|
if (cb(arr[index], index, arr))
|
|
986
986
|
return arr[index];
|
|
987
987
|
}
|
|
988
|
-
return
|
|
988
|
+
return undefined;
|
|
989
989
|
}
|
|
990
990
|
function useArrayFindLast(list, fn) {
|
|
991
|
-
return vue.computed(() => toValue(
|
|
992
|
-
!Array.prototype.findLast ? findLast(toValue(list), (element, index, array) => fn(toValue(element), index, array)) : toValue(list).findLast((element, index, array) => fn(toValue(element), index, array))
|
|
991
|
+
return vue.computed(() => vue.toValue(
|
|
992
|
+
!Array.prototype.findLast ? findLast(vue.toValue(list), (element, index, array) => fn(vue.toValue(element), index, array)) : vue.toValue(list).findLast((element, index, array) => fn(vue.toValue(element), index, array))
|
|
993
993
|
));
|
|
994
994
|
}
|
|
995
995
|
|
|
@@ -1008,35 +1008,35 @@
|
|
|
1008
1008
|
}
|
|
1009
1009
|
if (typeof comparator === "string") {
|
|
1010
1010
|
const key = comparator;
|
|
1011
|
-
comparator = (element, value2) => element[key] === toValue(value2);
|
|
1011
|
+
comparator = (element, value2) => element[key] === vue.toValue(value2);
|
|
1012
1012
|
}
|
|
1013
|
-
comparator = comparator != null ? comparator : (element, value2) => element === toValue(value2);
|
|
1014
|
-
return vue.computed(() => toValue(list).slice(formIndex).some((element, index, array) => comparator(
|
|
1015
|
-
toValue(element),
|
|
1016
|
-
toValue(value),
|
|
1013
|
+
comparator = comparator != null ? comparator : (element, value2) => element === vue.toValue(value2);
|
|
1014
|
+
return vue.computed(() => vue.toValue(list).slice(formIndex).some((element, index, array) => comparator(
|
|
1015
|
+
vue.toValue(element),
|
|
1016
|
+
vue.toValue(value),
|
|
1017
1017
|
index,
|
|
1018
|
-
toValue(array)
|
|
1018
|
+
vue.toValue(array)
|
|
1019
1019
|
)));
|
|
1020
1020
|
}
|
|
1021
1021
|
|
|
1022
1022
|
function useArrayJoin(list, separator) {
|
|
1023
|
-
return vue.computed(() => toValue(list).map((i) => toValue(i)).join(toValue(separator)));
|
|
1023
|
+
return vue.computed(() => vue.toValue(list).map((i) => vue.toValue(i)).join(vue.toValue(separator)));
|
|
1024
1024
|
}
|
|
1025
1025
|
|
|
1026
1026
|
function useArrayMap(list, fn) {
|
|
1027
|
-
return vue.computed(() => toValue(list).map((i) => toValue(i)).map(fn));
|
|
1027
|
+
return vue.computed(() => vue.toValue(list).map((i) => vue.toValue(i)).map(fn));
|
|
1028
1028
|
}
|
|
1029
1029
|
|
|
1030
1030
|
function useArrayReduce(list, reducer, ...args) {
|
|
1031
|
-
const reduceCallback = (sum, value, index) => reducer(toValue(sum), toValue(value), index);
|
|
1031
|
+
const reduceCallback = (sum, value, index) => reducer(vue.toValue(sum), vue.toValue(value), index);
|
|
1032
1032
|
return vue.computed(() => {
|
|
1033
|
-
const resolved = toValue(list);
|
|
1034
|
-
return args.length ? resolved.reduce(reduceCallback, typeof args[0] === "function" ? toValue(args[0]()) : toValue(args[0])) : resolved.reduce(reduceCallback);
|
|
1033
|
+
const resolved = vue.toValue(list);
|
|
1034
|
+
return args.length ? resolved.reduce(reduceCallback, typeof args[0] === "function" ? vue.toValue(args[0]()) : vue.toValue(args[0])) : resolved.reduce(reduceCallback);
|
|
1035
1035
|
});
|
|
1036
1036
|
}
|
|
1037
1037
|
|
|
1038
1038
|
function useArraySome(list, fn) {
|
|
1039
|
-
return vue.computed(() => toValue(list).some((element, index, array) => fn(toValue(element), index, array)));
|
|
1039
|
+
return vue.computed(() => vue.toValue(list).some((element, index, array) => fn(vue.toValue(element), index, array)));
|
|
1040
1040
|
}
|
|
1041
1041
|
|
|
1042
1042
|
function uniq(array) {
|
|
@@ -1051,7 +1051,7 @@
|
|
|
1051
1051
|
}
|
|
1052
1052
|
function useArrayUnique(list, compareFn) {
|
|
1053
1053
|
return vue.computed(() => {
|
|
1054
|
-
const resolvedList = toValue(list).map((element) => toValue(element));
|
|
1054
|
+
const resolvedList = vue.toValue(list).map((element) => vue.toValue(element));
|
|
1055
1055
|
return compareFn ? uniqueElementsBy(resolvedList, compareFn) : uniq(resolvedList);
|
|
1056
1056
|
});
|
|
1057
1057
|
}
|
|
@@ -1105,8 +1105,8 @@
|
|
|
1105
1105
|
M: () => month + 1,
|
|
1106
1106
|
Mo: () => formatOrdinal(month + 1),
|
|
1107
1107
|
MM: () => `${month + 1}`.padStart(2, "0"),
|
|
1108
|
-
MMM: () => date.toLocaleDateString(toValue(options.locales), { month: "short" }),
|
|
1109
|
-
MMMM: () => date.toLocaleDateString(toValue(options.locales), { month: "long" }),
|
|
1108
|
+
MMM: () => date.toLocaleDateString(vue.toValue(options.locales), { month: "short" }),
|
|
1109
|
+
MMMM: () => date.toLocaleDateString(vue.toValue(options.locales), { month: "long" }),
|
|
1110
1110
|
D: () => String(days),
|
|
1111
1111
|
Do: () => formatOrdinal(days),
|
|
1112
1112
|
DD: () => `${days}`.padStart(2, "0"),
|
|
@@ -1124,9 +1124,9 @@
|
|
|
1124
1124
|
ss: () => `${seconds}`.padStart(2, "0"),
|
|
1125
1125
|
SSS: () => `${milliseconds}`.padStart(3, "0"),
|
|
1126
1126
|
d: () => day,
|
|
1127
|
-
dd: () => date.toLocaleDateString(toValue(options.locales), { weekday: "narrow" }),
|
|
1128
|
-
ddd: () => date.toLocaleDateString(toValue(options.locales), { weekday: "short" }),
|
|
1129
|
-
dddd: () => date.toLocaleDateString(toValue(options.locales), { weekday: "long" }),
|
|
1127
|
+
dd: () => date.toLocaleDateString(vue.toValue(options.locales), { weekday: "narrow" }),
|
|
1128
|
+
ddd: () => date.toLocaleDateString(vue.toValue(options.locales), { weekday: "short" }),
|
|
1129
|
+
dddd: () => date.toLocaleDateString(vue.toValue(options.locales), { weekday: "long" }),
|
|
1130
1130
|
A: () => meridiem(hours, minutes),
|
|
1131
1131
|
AA: () => meridiem(hours, minutes, false, true),
|
|
1132
1132
|
a: () => meridiem(hours, minutes, true),
|
|
@@ -1134,13 +1134,13 @@
|
|
|
1134
1134
|
};
|
|
1135
1135
|
return formatStr.replace(REGEX_FORMAT, (match, $1) => {
|
|
1136
1136
|
var _a2, _b;
|
|
1137
|
-
return (_b = $1 != null ? $1 : (_a2 = matches[match]) == null ?
|
|
1137
|
+
return (_b = $1 != null ? $1 : (_a2 = matches[match]) == null ? undefined : _a2.call(matches)) != null ? _b : match;
|
|
1138
1138
|
});
|
|
1139
1139
|
}
|
|
1140
1140
|
function normalizeDate(date) {
|
|
1141
1141
|
if (date === null)
|
|
1142
1142
|
return new Date(Number.NaN);
|
|
1143
|
-
if (date ===
|
|
1143
|
+
if (date === undefined)
|
|
1144
1144
|
return /* @__PURE__ */ new Date();
|
|
1145
1145
|
if (date instanceof Date)
|
|
1146
1146
|
return new Date(date);
|
|
@@ -1155,7 +1155,7 @@
|
|
|
1155
1155
|
return new Date(date);
|
|
1156
1156
|
}
|
|
1157
1157
|
function useDateFormat(date, formatStr = "HH:mm:ss", options = {}) {
|
|
1158
|
-
return vue.computed(() => formatDate(normalizeDate(toValue(date)), toValue(formatStr), options));
|
|
1158
|
+
return vue.computed(() => formatDate(normalizeDate(vue.toValue(date)), vue.toValue(formatStr), options));
|
|
1159
1159
|
}
|
|
1160
1160
|
|
|
1161
1161
|
function useIntervalFn(cb, interval = 1e3, options = {}) {
|
|
@@ -1176,7 +1176,7 @@
|
|
|
1176
1176
|
clean();
|
|
1177
1177
|
}
|
|
1178
1178
|
function resume() {
|
|
1179
|
-
const intervalValue = toValue(interval);
|
|
1179
|
+
const intervalValue = vue.toValue(interval);
|
|
1180
1180
|
if (intervalValue <= 0)
|
|
1181
1181
|
return;
|
|
1182
1182
|
isActive.value = true;
|
|
@@ -1267,7 +1267,7 @@
|
|
|
1267
1267
|
isPending.value = false;
|
|
1268
1268
|
timer = null;
|
|
1269
1269
|
cb(...args);
|
|
1270
|
-
}, toValue(interval));
|
|
1270
|
+
}, vue.toValue(interval));
|
|
1271
1271
|
}
|
|
1272
1272
|
if (immediate) {
|
|
1273
1273
|
isPending.value = true;
|
|
@@ -1310,8 +1310,10 @@
|
|
|
1310
1310
|
nanToZero
|
|
1311
1311
|
} = options;
|
|
1312
1312
|
return vue.computed(() => {
|
|
1313
|
-
let resolved = toValue(value);
|
|
1314
|
-
if (typeof
|
|
1313
|
+
let resolved = vue.toValue(value);
|
|
1314
|
+
if (typeof method === "function")
|
|
1315
|
+
resolved = method(resolved);
|
|
1316
|
+
else if (typeof resolved === "string")
|
|
1315
1317
|
resolved = Number[method](resolved, radix);
|
|
1316
1318
|
if (nanToZero && Number.isNaN(resolved))
|
|
1317
1319
|
resolved = 0;
|
|
@@ -1320,7 +1322,7 @@
|
|
|
1320
1322
|
}
|
|
1321
1323
|
|
|
1322
1324
|
function useToString(value) {
|
|
1323
|
-
return vue.computed(() => `${toValue(value)}`);
|
|
1325
|
+
return vue.computed(() => `${vue.toValue(value)}`);
|
|
1324
1326
|
}
|
|
1325
1327
|
|
|
1326
1328
|
function useToggle(initialValue = false, options = {}) {
|
|
@@ -1335,8 +1337,8 @@
|
|
|
1335
1337
|
_value.value = value;
|
|
1336
1338
|
return _value.value;
|
|
1337
1339
|
} else {
|
|
1338
|
-
const truthy = toValue(truthyValue);
|
|
1339
|
-
_value.value = _value.value === truthy ? toValue(falsyValue) : truthy;
|
|
1340
|
+
const truthy = vue.toValue(truthyValue);
|
|
1341
|
+
_value.value = _value.value === truthy ? vue.toValue(falsyValue) : truthy;
|
|
1340
1342
|
return _value.value;
|
|
1341
1343
|
}
|
|
1342
1344
|
}
|
|
@@ -1347,7 +1349,7 @@
|
|
|
1347
1349
|
}
|
|
1348
1350
|
|
|
1349
1351
|
function watchArray(source, cb, options) {
|
|
1350
|
-
let oldList = (options == null ?
|
|
1352
|
+
let oldList = (options == null ? undefined : options.immediate) ? [] : [...source instanceof Function ? source() : Array.isArray(source) ? source : vue.toValue(source)];
|
|
1351
1353
|
return vue.watch(source, (newList, _, onCleanup) => {
|
|
1352
1354
|
const oldListRemains = Array.from({ length: oldList.length });
|
|
1353
1355
|
const added = [];
|
|
@@ -1379,7 +1381,7 @@
|
|
|
1379
1381
|
source,
|
|
1380
1382
|
(...args) => {
|
|
1381
1383
|
current.value += 1;
|
|
1382
|
-
if (current.value >= toValue(count))
|
|
1384
|
+
if (current.value >= vue.toValue(count))
|
|
1383
1385
|
vue.nextTick(() => stop());
|
|
1384
1386
|
cb(...args);
|
|
1385
1387
|
},
|
|
@@ -1391,7 +1393,7 @@
|
|
|
1391
1393
|
function watchDebounced(source, cb, options = {}) {
|
|
1392
1394
|
const {
|
|
1393
1395
|
debounce = 0,
|
|
1394
|
-
maxWait =
|
|
1396
|
+
maxWait = undefined,
|
|
1395
1397
|
...watchOptions
|
|
1396
1398
|
} = options;
|
|
1397
1399
|
return watchWithFilter(
|
|
@@ -1528,7 +1530,7 @@
|
|
|
1528
1530
|
if (!cleanupFn)
|
|
1529
1531
|
return;
|
|
1530
1532
|
const fn = cleanupFn;
|
|
1531
|
-
cleanupFn =
|
|
1533
|
+
cleanupFn = undefined;
|
|
1532
1534
|
fn();
|
|
1533
1535
|
}
|
|
1534
1536
|
function onCleanup(callback) {
|
|
@@ -1556,11 +1558,11 @@
|
|
|
1556
1558
|
if (vue.isReactive(sources))
|
|
1557
1559
|
return sources;
|
|
1558
1560
|
if (Array.isArray(sources))
|
|
1559
|
-
return sources.map((item) => toValue(item));
|
|
1560
|
-
return toValue(sources);
|
|
1561
|
+
return sources.map((item) => vue.toValue(item));
|
|
1562
|
+
return vue.toValue(sources);
|
|
1561
1563
|
}
|
|
1562
1564
|
function getOldValue(source) {
|
|
1563
|
-
return Array.isArray(source) ? source.map(() =>
|
|
1565
|
+
return Array.isArray(source) ? source.map(() => undefined) : undefined;
|
|
1564
1566
|
}
|
|
1565
1567
|
|
|
1566
1568
|
function whenever(source, cb, options) {
|
|
@@ -1568,7 +1570,7 @@
|
|
|
1568
1570
|
source,
|
|
1569
1571
|
(v, ov, onInvalidate) => {
|
|
1570
1572
|
if (v) {
|
|
1571
|
-
if (options == null ?
|
|
1573
|
+
if (options == null ? undefined : options.once)
|
|
1572
1574
|
vue.nextTick(() => stop());
|
|
1573
1575
|
cb(v, ov, onInvalidate);
|
|
1574
1576
|
}
|
|
@@ -1652,6 +1654,7 @@
|
|
|
1652
1654
|
exports.throttledRef = refThrottled;
|
|
1653
1655
|
exports.throttledWatch = watchThrottled;
|
|
1654
1656
|
exports.timestamp = timestamp;
|
|
1657
|
+
exports.toArray = toArray;
|
|
1655
1658
|
exports.toReactive = toReactive;
|
|
1656
1659
|
exports.toRef = toRef;
|
|
1657
1660
|
exports.toRefs = toRefs;
|