@vueuse/shared 10.4.1 → 10.5.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 +46 -28
- package/index.d.cts +79 -44
- package/index.d.mts +79 -44
- package/index.d.ts +79 -44
- package/index.iife.js +46 -28
- package/index.iife.min.js +1 -1
- package/index.mjs +46 -30
- package/package.json +2 -2
package/index.cjs
CHANGED
|
@@ -92,14 +92,39 @@ function createGlobalState(stateFactory) {
|
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
const localProvidedStateMap = /* @__PURE__ */ new WeakMap();
|
|
96
|
+
|
|
97
|
+
const provideLocal = (key, value) => {
|
|
98
|
+
var _a;
|
|
99
|
+
const instance = (_a = vueDemi.getCurrentInstance()) == null ? void 0 : _a.proxy;
|
|
100
|
+
if (instance == null)
|
|
101
|
+
throw new Error("provideLocal must be called in setup");
|
|
102
|
+
if (!localProvidedStateMap.has(instance))
|
|
103
|
+
localProvidedStateMap.set(instance, /* @__PURE__ */ Object.create(null));
|
|
104
|
+
const localProvidedState = localProvidedStateMap.get(instance);
|
|
105
|
+
localProvidedState[key] = value;
|
|
106
|
+
vueDemi.provide(key, value);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const injectLocal = (...args) => {
|
|
110
|
+
var _a;
|
|
111
|
+
const key = args[0];
|
|
112
|
+
const instance = (_a = vueDemi.getCurrentInstance()) == null ? void 0 : _a.proxy;
|
|
113
|
+
if (instance == null)
|
|
114
|
+
throw new Error("injectLocal must be called in setup");
|
|
115
|
+
if (localProvidedStateMap.has(instance) && key in localProvidedStateMap.get(instance))
|
|
116
|
+
return localProvidedStateMap.get(instance)[key];
|
|
117
|
+
return vueDemi.inject(...args);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
function createInjectionState(composable, options) {
|
|
121
|
+
const key = (options == null ? void 0 : options.injectionKey) || Symbol("InjectionState");
|
|
97
122
|
const useProvidingState = (...args) => {
|
|
98
123
|
const state = composable(...args);
|
|
99
|
-
|
|
124
|
+
provideLocal(key, state);
|
|
100
125
|
return state;
|
|
101
126
|
};
|
|
102
|
-
const useInjectedState = () =>
|
|
127
|
+
const useInjectedState = () => injectLocal(key);
|
|
103
128
|
return [useProvidingState, useInjectedState];
|
|
104
129
|
}
|
|
105
130
|
|
|
@@ -258,9 +283,7 @@ function reactiveComputed(fn) {
|
|
|
258
283
|
function reactiveOmit(obj, ...keys) {
|
|
259
284
|
const flatKeys = keys.flat();
|
|
260
285
|
const predicate = flatKeys[0];
|
|
261
|
-
return reactiveComputed(
|
|
262
|
-
() => typeof predicate === "function" ? Object.fromEntries(Object.entries(vueDemi.toRefs(obj)).filter(([k, v]) => !predicate(toValue(v), k))) : Object.fromEntries(Object.entries(vueDemi.toRefs(obj)).filter((e) => !flatKeys.includes(e[0])))
|
|
263
|
-
);
|
|
286
|
+
return reactiveComputed(() => typeof predicate === "function" ? Object.fromEntries(Object.entries(vueDemi.toRefs(obj)).filter(([k, v]) => !predicate(toValue(v), k))) : Object.fromEntries(Object.entries(vueDemi.toRefs(obj)).filter((e) => !flatKeys.includes(e[0]))));
|
|
264
287
|
}
|
|
265
288
|
|
|
266
289
|
const isClient = typeof window !== "undefined" && typeof document !== "undefined";
|
|
@@ -416,9 +439,7 @@ function cacheStringFunction(fn) {
|
|
|
416
439
|
};
|
|
417
440
|
}
|
|
418
441
|
const hyphenateRE = /\B([A-Z])/g;
|
|
419
|
-
const hyphenate = cacheStringFunction(
|
|
420
|
-
(str) => str.replace(hyphenateRE, "-$1").toLowerCase()
|
|
421
|
-
);
|
|
442
|
+
const hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
|
|
422
443
|
const camelizeRE = /-(\w)/g;
|
|
423
444
|
const camelize = cacheStringFunction((str) => {
|
|
424
445
|
return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
|
|
@@ -927,11 +948,9 @@ function useArrayFilter(list, fn) {
|
|
|
927
948
|
}
|
|
928
949
|
|
|
929
950
|
function useArrayFind(list, fn) {
|
|
930
|
-
return vueDemi.computed(
|
|
931
|
-
() => toValue(
|
|
932
|
-
|
|
933
|
-
)
|
|
934
|
-
);
|
|
951
|
+
return vueDemi.computed(() => toValue(
|
|
952
|
+
toValue(list).find((element, index, array) => fn(toValue(element), index, array))
|
|
953
|
+
));
|
|
935
954
|
}
|
|
936
955
|
|
|
937
956
|
function useArrayFindIndex(list, fn) {
|
|
@@ -947,11 +966,9 @@ function findLast(arr, cb) {
|
|
|
947
966
|
return void 0;
|
|
948
967
|
}
|
|
949
968
|
function useArrayFindLast(list, fn) {
|
|
950
|
-
return vueDemi.computed(
|
|
951
|
-
() => toValue(
|
|
952
|
-
|
|
953
|
-
)
|
|
954
|
-
);
|
|
969
|
+
return vueDemi.computed(() => toValue(
|
|
970
|
+
!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))
|
|
971
|
+
));
|
|
955
972
|
}
|
|
956
973
|
|
|
957
974
|
function isArrayIncludesOptions(obj) {
|
|
@@ -972,11 +989,12 @@ function useArrayIncludes(...args) {
|
|
|
972
989
|
comparator = (element, value2) => element[key] === toValue(value2);
|
|
973
990
|
}
|
|
974
991
|
comparator = comparator != null ? comparator : (element, value2) => element === toValue(value2);
|
|
975
|
-
return vueDemi.computed(
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
992
|
+
return vueDemi.computed(() => toValue(list).slice(formIndex).some((element, index, array) => comparator(
|
|
993
|
+
toValue(element),
|
|
994
|
+
toValue(value),
|
|
995
|
+
index,
|
|
996
|
+
toValue(array)
|
|
997
|
+
)));
|
|
980
998
|
}
|
|
981
999
|
|
|
982
1000
|
function useArrayJoin(list, separator) {
|
|
@@ -1294,9 +1312,7 @@ function useToggle(initialValue = false, options = {}) {
|
|
|
1294
1312
|
}
|
|
1295
1313
|
|
|
1296
1314
|
function watchArray(source, cb, options) {
|
|
1297
|
-
let oldList = (options == null ? void 0 : options.immediate) ? [] : [
|
|
1298
|
-
...source instanceof Function ? source() : Array.isArray(source) ? source : toValue(source)
|
|
1299
|
-
];
|
|
1315
|
+
let oldList = (options == null ? void 0 : options.immediate) ? [] : [...source instanceof Function ? source() : Array.isArray(source) ? source : toValue(source)];
|
|
1300
1316
|
return vueDemi.watch(source, (newList, _, onCleanup) => {
|
|
1301
1317
|
const oldListRemains = Array.from({ length: oldList.length });
|
|
1302
1318
|
const added = [];
|
|
@@ -1552,6 +1568,7 @@ exports.hyphenate = hyphenate;
|
|
|
1552
1568
|
exports.identity = identity;
|
|
1553
1569
|
exports.ignorableWatch = watchIgnorable;
|
|
1554
1570
|
exports.increaseWithUnit = increaseWithUnit;
|
|
1571
|
+
exports.injectLocal = injectLocal;
|
|
1555
1572
|
exports.invoke = invoke;
|
|
1556
1573
|
exports.isClient = isClient;
|
|
1557
1574
|
exports.isDef = isDef;
|
|
@@ -1569,6 +1586,7 @@ exports.objectPick = objectPick;
|
|
|
1569
1586
|
exports.pausableFilter = pausableFilter;
|
|
1570
1587
|
exports.pausableWatch = watchPausable;
|
|
1571
1588
|
exports.promiseTimeout = promiseTimeout;
|
|
1589
|
+
exports.provideLocal = provideLocal;
|
|
1572
1590
|
exports.rand = rand;
|
|
1573
1591
|
exports.reactify = reactify;
|
|
1574
1592
|
exports.reactifyObject = reactifyObject;
|
package/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as vue_demi from 'vue-demi';
|
|
2
|
-
import { WatchOptionsBase, Ref, ComputedRef, WritableComputedRef, WatchSource, ComputedGetter, WritableComputedOptions, WatchOptions, ShallowUnwrapRef as ShallowUnwrapRef$1, UnwrapNestedRefs, UnwrapRef, ToRef, ToRefs, MaybeRef as MaybeRef$1, WatchCallback, WatchStopHandle } from 'vue-demi';
|
|
2
|
+
import { WatchOptionsBase, Ref, ComputedRef, WritableComputedRef, WatchSource, ComputedGetter, WritableComputedOptions, WatchOptions, InjectionKey, ShallowUnwrapRef as ShallowUnwrapRef$1, inject, provide, UnwrapNestedRefs, UnwrapRef, ToRef, ToRefs, MaybeRef as MaybeRef$1, WatchCallback, WatchStopHandle } from 'vue-demi';
|
|
3
3
|
|
|
4
4
|
declare function computedEager<T>(fn: () => T, options?: WatchOptionsBase): Readonly<Ref<T>>;
|
|
5
5
|
|
|
@@ -101,7 +101,14 @@ type ElementOf<T> = T extends (infer E)[] ? E : never;
|
|
|
101
101
|
type ShallowUnwrapRef<T> = T extends Ref<infer P> ? P : T;
|
|
102
102
|
type Awaitable<T> = Promise<T> | T;
|
|
103
103
|
type ArgumentsType<T> = T extends (...args: infer U) => any ? U : never;
|
|
104
|
-
|
|
104
|
+
/**
|
|
105
|
+
* Compatible with versions below TypeScript 4.5 Awaited
|
|
106
|
+
*/
|
|
107
|
+
type Awaited<T> = T extends null | undefined ? T : T extends object & {
|
|
108
|
+
then(onfulfilled: infer F, ...args: infer _): any;
|
|
109
|
+
} ? F extends ((value: infer V, ...args: infer _) => any) ? Awaited<V> : never : T;
|
|
110
|
+
type Promisify<T> = Promise<Awaited<T>>;
|
|
111
|
+
type PromisifyFn<T extends AnyFn> = (...args: ArgumentsType<T>) => Promisify<ReturnType<T>>;
|
|
105
112
|
interface Pausable {
|
|
106
113
|
/**
|
|
107
114
|
* A ref indicate whether a pausable instance is active
|
|
@@ -164,7 +171,7 @@ interface FunctionWrapperOptions<Args extends any[] = any[], This = any> {
|
|
|
164
171
|
args: Args;
|
|
165
172
|
thisArg: This;
|
|
166
173
|
}
|
|
167
|
-
type EventFilter<Args extends any[] = any[], This = any, Invoke extends AnyFn = AnyFn> = (invoke: Invoke, options: FunctionWrapperOptions<Args, This>) => ReturnType<Invoke> |
|
|
174
|
+
type EventFilter<Args extends any[] = any[], This = any, Invoke extends AnyFn = AnyFn> = (invoke: Invoke, options: FunctionWrapperOptions<Args, This>) => ReturnType<Invoke> | Promisify<ReturnType<Invoke>>;
|
|
168
175
|
interface ConfigurableEventFilter {
|
|
169
176
|
/**
|
|
170
177
|
* Filter for if events should to be received.
|
|
@@ -189,7 +196,7 @@ interface DebounceFilterOptions {
|
|
|
189
196
|
/**
|
|
190
197
|
* @internal
|
|
191
198
|
*/
|
|
192
|
-
declare function createFilterWrapper<T extends AnyFn>(filter: EventFilter, fn: T): (this: any, ...args: ArgumentsType<T>) => Promise<ReturnType<T
|
|
199
|
+
declare function createFilterWrapper<T extends AnyFn>(filter: EventFilter, fn: T): (this: any, ...args: ArgumentsType<T>) => Promise<Awaited<ReturnType<T>>>;
|
|
193
200
|
declare const bypassFilter: EventFilter;
|
|
194
201
|
/**
|
|
195
202
|
* Create an EventFilter that debounce the events
|
|
@@ -199,9 +206,9 @@ declare function debounceFilter(ms: MaybeRefOrGetter<number>, options?: Debounce
|
|
|
199
206
|
* Create an EventFilter that throttle the events
|
|
200
207
|
*
|
|
201
208
|
* @param ms
|
|
202
|
-
* @param [trailing
|
|
203
|
-
* @param [leading
|
|
204
|
-
* @param [rejectOnCancel
|
|
209
|
+
* @param [trailing]
|
|
210
|
+
* @param [leading]
|
|
211
|
+
* @param [rejectOnCancel]
|
|
205
212
|
*/
|
|
206
213
|
declare function throttleFilter(ms: MaybeRefOrGetter<number>, trailing?: boolean, leading?: boolean, rejectOnCancel?: boolean): EventFilter<any[], any, AnyFn>;
|
|
207
214
|
/**
|
|
@@ -275,13 +282,19 @@ declare function objectEntries<T extends object>(obj: T): [keyof T, T[keyof T]][
|
|
|
275
282
|
*/
|
|
276
283
|
declare function createGlobalState<Fn extends AnyFn>(stateFactory: Fn): Fn;
|
|
277
284
|
|
|
285
|
+
interface CreateInjectionStateOptions<Return> {
|
|
286
|
+
/**
|
|
287
|
+
* Custom injectionKey for InjectionState
|
|
288
|
+
*/
|
|
289
|
+
injectionKey?: string | InjectionKey<Return>;
|
|
290
|
+
}
|
|
278
291
|
/**
|
|
279
292
|
* Create global state that can be injected into components.
|
|
280
293
|
*
|
|
281
294
|
* @see https://vueuse.org/createInjectionState
|
|
282
295
|
*
|
|
283
296
|
*/
|
|
284
|
-
declare function createInjectionState<Arguments extends Array<any>, Return>(composable: (...args: Arguments) => Return): readonly [useProvidingState: (...args: Arguments) => Return, useInjectedState: () => Return | undefined];
|
|
297
|
+
declare function createInjectionState<Arguments extends Array<any>, Return>(composable: (...args: Arguments) => Return, options?: CreateInjectionStateOptions<Return>): readonly [useProvidingState: (...args: Arguments) => Return, useInjectedState: () => Return | undefined];
|
|
285
298
|
|
|
286
299
|
/**
|
|
287
300
|
* Make a composable function usable with multiple Vue instances.
|
|
@@ -319,12 +332,34 @@ declare function extendRef<R extends Ref<any>, Extend extends object, Options ex
|
|
|
319
332
|
declare function get<T>(ref: MaybeRef<T>): T;
|
|
320
333
|
declare function get<T, K extends keyof T>(ref: MaybeRef<T>, key: K): T[K];
|
|
321
334
|
|
|
335
|
+
/**
|
|
336
|
+
* On the basis of `inject`, it is allowed to directly call inject to obtain the value after call provide in the same component.
|
|
337
|
+
*
|
|
338
|
+
* @example
|
|
339
|
+
* ```ts
|
|
340
|
+
* injectLocal('MyInjectionKey', 1)
|
|
341
|
+
* const injectedValue = injectLocal('MyInjectionKey') // injectedValue === 1
|
|
342
|
+
* ```
|
|
343
|
+
*/
|
|
344
|
+
declare const injectLocal: typeof inject;
|
|
345
|
+
|
|
322
346
|
declare function isDefined<T>(v: Ref<T>): v is Ref<Exclude<T, null | undefined>>;
|
|
323
347
|
declare function isDefined<T>(v: ComputedRef<T>): v is ComputedRef<Exclude<T, null | undefined>>;
|
|
324
348
|
declare function isDefined<T>(v: T): v is Exclude<T, null | undefined>;
|
|
325
349
|
|
|
326
350
|
declare function makeDestructurable<T extends Record<string, unknown>, A extends readonly any[]>(obj: T, arr: A): T & A;
|
|
327
351
|
|
|
352
|
+
/**
|
|
353
|
+
* On the basis of `provide`, it is allowed to directly call inject to obtain the value after call provide in the same component.
|
|
354
|
+
*
|
|
355
|
+
* @example
|
|
356
|
+
* ```ts
|
|
357
|
+
* provideLocal('MyInjectionKey', 1)
|
|
358
|
+
* const injectedValue = injectLocal('MyInjectionKey') // injectedValue === 1
|
|
359
|
+
* ```
|
|
360
|
+
*/
|
|
361
|
+
declare const provideLocal: typeof provide;
|
|
362
|
+
|
|
328
363
|
type Reactified<T, Computed extends boolean> = T extends (...args: infer A) => infer R ? (...args: {
|
|
329
364
|
[K in keyof A]: Computed extends true ? MaybeRefOrGetter<A[K]> : MaybeRef<A[K]>;
|
|
330
365
|
}) => ComputedRef<R> : never;
|
|
@@ -397,9 +432,6 @@ declare function refDebounced<T>(value: Ref<T>, ms?: MaybeRefOrGetter<number>, o
|
|
|
397
432
|
|
|
398
433
|
/**
|
|
399
434
|
* Apply default value to a ref.
|
|
400
|
-
*
|
|
401
|
-
* @param source source ref
|
|
402
|
-
* @param targets
|
|
403
435
|
*/
|
|
404
436
|
declare function refDefault<T>(source: Ref<T | undefined | null>, defaultValue: T): Ref<T>;
|
|
405
437
|
|
|
@@ -409,8 +441,8 @@ declare function refDefault<T>(source: Ref<T | undefined | null>, defaultValue:
|
|
|
409
441
|
*
|
|
410
442
|
* @param value Ref value to be watched with throttle effect
|
|
411
443
|
* @param delay A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
|
|
412
|
-
* @param [trailing
|
|
413
|
-
* @param [leading
|
|
444
|
+
* @param [trailing] if true, update the value again after the delay time is up
|
|
445
|
+
* @param [leading] if true, update the value on the leading edge of the ms timeout
|
|
414
446
|
*/
|
|
415
447
|
declare function refThrottled<T>(value: Ref<T>, delay?: number, trailing?: boolean, leading?: boolean): Ref<T>;
|
|
416
448
|
|
|
@@ -430,9 +462,6 @@ interface ControlledRefOptions<T> {
|
|
|
430
462
|
}
|
|
431
463
|
/**
|
|
432
464
|
* Explicitly define the deps of computed.
|
|
433
|
-
*
|
|
434
|
-
* @param source
|
|
435
|
-
* @param fn
|
|
436
465
|
*/
|
|
437
466
|
declare function refWithControl<T>(initial: T, options?: ControlledRefOptions<T>): vue_demi.ShallowUnwrapRef<{
|
|
438
467
|
get: (tracking?: boolean) => T;
|
|
@@ -660,10 +689,10 @@ declare function useArrayDifference<T>(list: MaybeRefOrGetter<T[]>, values: Mayb
|
|
|
660
689
|
* Reactive `Array.every`
|
|
661
690
|
*
|
|
662
691
|
* @see https://vueuse.org/useArrayEvery
|
|
663
|
-
* @param
|
|
692
|
+
* @param list - the array was called upon.
|
|
664
693
|
* @param fn - a function to test each element.
|
|
665
694
|
*
|
|
666
|
-
* @returns
|
|
695
|
+
* @returns **true** if the `fn` function returns a **truthy** value for every element from the array. Otherwise, **false**.
|
|
667
696
|
*/
|
|
668
697
|
declare function useArrayEvery<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: MaybeRefOrGetter<T>[]) => unknown): ComputedRef<boolean>;
|
|
669
698
|
|
|
@@ -671,10 +700,10 @@ declare function useArrayEvery<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>,
|
|
|
671
700
|
* Reactive `Array.filter`
|
|
672
701
|
*
|
|
673
702
|
* @see https://vueuse.org/useArrayFilter
|
|
674
|
-
* @param
|
|
703
|
+
* @param list - the array was called upon.
|
|
675
704
|
* @param fn - a function that is called for every element of the given `list`. Each time `fn` executes, the returned value is added to the new array.
|
|
676
705
|
*
|
|
677
|
-
* @returns
|
|
706
|
+
* @returns a shallow copy of a portion of the given array, filtered down to just the elements from the given array that pass the test implemented by the provided function. If no elements pass the test, an empty array will be returned.
|
|
678
707
|
*/
|
|
679
708
|
declare function useArrayFilter<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: T[]) => boolean): ComputedRef<T[]>;
|
|
680
709
|
|
|
@@ -682,7 +711,7 @@ declare function useArrayFilter<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>
|
|
|
682
711
|
* Reactive `Array.find`
|
|
683
712
|
*
|
|
684
713
|
* @see https://vueuse.org/useArrayFind
|
|
685
|
-
* @param
|
|
714
|
+
* @param list - the array was called upon.
|
|
686
715
|
* @param fn - a function to test each element.
|
|
687
716
|
*
|
|
688
717
|
* @returns the first element in the array that satisfies the provided testing function. Otherwise, undefined is returned.
|
|
@@ -693,10 +722,10 @@ declare function useArrayFind<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>,
|
|
|
693
722
|
* Reactive `Array.findIndex`
|
|
694
723
|
*
|
|
695
724
|
* @see https://vueuse.org/useArrayFindIndex
|
|
696
|
-
* @param
|
|
725
|
+
* @param list - the array was called upon.
|
|
697
726
|
* @param fn - a function to test each element.
|
|
698
727
|
*
|
|
699
|
-
* @returns
|
|
728
|
+
* @returns the index of the first element in the array that passes the test. Otherwise, "-1".
|
|
700
729
|
*/
|
|
701
730
|
declare function useArrayFindIndex<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: MaybeRefOrGetter<T>[]) => unknown): ComputedRef<number>;
|
|
702
731
|
|
|
@@ -704,7 +733,7 @@ declare function useArrayFindIndex<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>
|
|
|
704
733
|
* Reactive `Array.findLast`
|
|
705
734
|
*
|
|
706
735
|
* @see https://vueuse.org/useArrayFindLast
|
|
707
|
-
* @param
|
|
736
|
+
* @param list - the array was called upon.
|
|
708
737
|
* @param fn - a function to test each element.
|
|
709
738
|
*
|
|
710
739
|
* @returns the last element in the array that satisfies the provided testing function. Otherwise, undefined is returned.
|
|
@@ -716,6 +745,13 @@ interface UseArrayIncludesOptions<T, V> {
|
|
|
716
745
|
fromIndex?: number;
|
|
717
746
|
comparator?: UseArrayIncludesComparatorFn<T, V> | keyof T;
|
|
718
747
|
}
|
|
748
|
+
/**
|
|
749
|
+
* Reactive `Array.includes`
|
|
750
|
+
*
|
|
751
|
+
* @see https://vueuse.org/useArrayIncludes
|
|
752
|
+
*
|
|
753
|
+
* @returns true if the `value` is found in the array. Otherwise, false.
|
|
754
|
+
*/
|
|
719
755
|
declare function useArrayIncludes<T, V = any>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, value: MaybeRefOrGetter<V>, comparator?: UseArrayIncludesComparatorFn<T, V>): ComputedRef<boolean>;
|
|
720
756
|
declare function useArrayIncludes<T, V = any>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, value: MaybeRefOrGetter<V>, comparator?: keyof T): ComputedRef<boolean>;
|
|
721
757
|
declare function useArrayIncludes<T, V = any>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, value: MaybeRefOrGetter<V>, options?: UseArrayIncludesOptions<T, V>): ComputedRef<boolean>;
|
|
@@ -724,10 +760,10 @@ declare function useArrayIncludes<T, V = any>(list: MaybeRefOrGetter<MaybeRefOrG
|
|
|
724
760
|
* Reactive `Array.join`
|
|
725
761
|
*
|
|
726
762
|
* @see https://vueuse.org/useArrayJoin
|
|
727
|
-
* @param
|
|
728
|
-
* @param
|
|
763
|
+
* @param list - the array was called upon.
|
|
764
|
+
* @param separator - a string to separate each pair of adjacent elements of the array. If omitted, the array elements are separated with a comma (",").
|
|
729
765
|
*
|
|
730
|
-
* @returns
|
|
766
|
+
* @returns a string with all array elements joined. If arr.length is 0, the empty string is returned.
|
|
731
767
|
*/
|
|
732
768
|
declare function useArrayJoin(list: MaybeRefOrGetter<MaybeRefOrGetter<any>[]>, separator?: MaybeRefOrGetter<string>): ComputedRef<string>;
|
|
733
769
|
|
|
@@ -735,10 +771,10 @@ declare function useArrayJoin(list: MaybeRefOrGetter<MaybeRefOrGetter<any>[]>, s
|
|
|
735
771
|
* Reactive `Array.map`
|
|
736
772
|
*
|
|
737
773
|
* @see https://vueuse.org/useArrayMap
|
|
738
|
-
* @param
|
|
774
|
+
* @param list - the array was called upon.
|
|
739
775
|
* @param fn - a function that is called for every element of the given `list`. Each time `fn` executes, the returned value is added to the new array.
|
|
740
776
|
*
|
|
741
|
-
* @returns
|
|
777
|
+
* @returns a new array with each element being the result of the callback function.
|
|
742
778
|
*/
|
|
743
779
|
declare function useArrayMap<T, U = T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: T[]) => U): ComputedRef<U[]>;
|
|
744
780
|
|
|
@@ -747,7 +783,7 @@ type UseArrayReducer<PV, CV, R> = (previousValue: PV, currentValue: CV, currentI
|
|
|
747
783
|
* Reactive `Array.reduce`
|
|
748
784
|
*
|
|
749
785
|
* @see https://vueuse.org/useArrayReduce
|
|
750
|
-
* @param
|
|
786
|
+
* @param list - the array was called upon.
|
|
751
787
|
* @param reducer - a "reducer" function.
|
|
752
788
|
*
|
|
753
789
|
* @returns the value that results from running the "reducer" callback function to completion over the entire array.
|
|
@@ -757,7 +793,7 @@ declare function useArrayReduce<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>
|
|
|
757
793
|
* Reactive `Array.reduce`
|
|
758
794
|
*
|
|
759
795
|
* @see https://vueuse.org/useArrayReduce
|
|
760
|
-
* @param
|
|
796
|
+
* @param list - the array was called upon.
|
|
761
797
|
* @param reducer - a "reducer" function.
|
|
762
798
|
* @param initialValue - a value to be initialized the first time when the callback is called.
|
|
763
799
|
*
|
|
@@ -769,19 +805,19 @@ declare function useArrayReduce<T, U>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>
|
|
|
769
805
|
* Reactive `Array.some`
|
|
770
806
|
*
|
|
771
807
|
* @see https://vueuse.org/useArraySome
|
|
772
|
-
* @param
|
|
808
|
+
* @param list - the array was called upon.
|
|
773
809
|
* @param fn - a function to test each element.
|
|
774
810
|
*
|
|
775
|
-
* @returns
|
|
811
|
+
* @returns **true** if the `fn` function returns a **truthy** value for any element from the array. Otherwise, **false**.
|
|
776
812
|
*/
|
|
777
813
|
declare function useArraySome<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: MaybeRefOrGetter<T>[]) => unknown): ComputedRef<boolean>;
|
|
778
814
|
|
|
779
815
|
/**
|
|
780
816
|
* reactive unique array
|
|
781
817
|
* @see https://vueuse.org/useArrayUnique
|
|
782
|
-
* @param
|
|
818
|
+
* @param list - the array was called upon.
|
|
783
819
|
* @param compareFn
|
|
784
|
-
* @returns
|
|
820
|
+
* @returns A computed ref that returns a unique array of items.
|
|
785
821
|
*/
|
|
786
822
|
declare function useArrayUnique<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, compareFn?: (a: T, b: T, array: T[]) => boolean): ComputedRef<T[]>;
|
|
787
823
|
|
|
@@ -793,8 +829,8 @@ interface UseCounterOptions {
|
|
|
793
829
|
* Basic counter with utility functions.
|
|
794
830
|
*
|
|
795
831
|
* @see https://vueuse.org/useCounter
|
|
796
|
-
* @param [initialValue
|
|
797
|
-
* @param
|
|
832
|
+
* @param [initialValue]
|
|
833
|
+
* @param options
|
|
798
834
|
*/
|
|
799
835
|
declare function useCounter(initialValue?: MaybeRef$1<number>, options?: UseCounterOptions): {
|
|
800
836
|
count: vue_demi.Ref<number>;
|
|
@@ -838,7 +874,7 @@ type UseDateFormatReturn = ReturnType<typeof useDateFormat>;
|
|
|
838
874
|
* @see https://vueuse.org/useDebounceFn
|
|
839
875
|
* @param fn A function to be executed after delay milliseconds debounced.
|
|
840
876
|
* @param ms A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
|
|
841
|
-
* @param
|
|
877
|
+
* @param options Options
|
|
842
878
|
*
|
|
843
879
|
* @return A new, debounce, function.
|
|
844
880
|
*/
|
|
@@ -908,8 +944,7 @@ interface UseLastChangedOptions<Immediate extends boolean, InitialValue extends
|
|
|
908
944
|
* @see https://vueuse.org/useLastChanged
|
|
909
945
|
*/
|
|
910
946
|
declare function useLastChanged(source: WatchSource, options?: UseLastChangedOptions<false>): Ref<number | null>;
|
|
911
|
-
declare function useLastChanged(source: WatchSource, options: UseLastChangedOptions<true>): Ref<number>;
|
|
912
|
-
declare function useLastChanged(source: WatchSource, options: UseLastChangedOptions<boolean, number>): Ref<number>;
|
|
947
|
+
declare function useLastChanged(source: WatchSource, options: UseLastChangedOptions<true> | UseLastChangedOptions<boolean, number>): Ref<number>;
|
|
913
948
|
|
|
914
949
|
/**
|
|
915
950
|
* Throttle execution of a function. Especially useful for rate limiting
|
|
@@ -919,11 +954,11 @@ declare function useLastChanged(source: WatchSource, options: UseLastChangedOpti
|
|
|
919
954
|
* to `callback` when the throttled-function is executed.
|
|
920
955
|
* @param ms A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
|
|
921
956
|
*
|
|
922
|
-
* @param [trailing
|
|
957
|
+
* @param [trailing] if true, call fn again after the time is up
|
|
923
958
|
*
|
|
924
|
-
* @param [leading
|
|
959
|
+
* @param [leading] if true, call fn on the leading edge of the ms timeout
|
|
925
960
|
*
|
|
926
|
-
* @param [rejectOnCancel
|
|
961
|
+
* @param [rejectOnCancel] if true, reject the last call if it's been cancel
|
|
927
962
|
*
|
|
928
963
|
* @return A new, throttled, function.
|
|
929
964
|
*/
|
|
@@ -1093,4 +1128,4 @@ declare function watchTriggerable<T extends object, FnReturnT>(source: T, cb: Wa
|
|
|
1093
1128
|
*/
|
|
1094
1129
|
declare function whenever<T>(source: WatchSource<T | false | null | undefined>, cb: WatchCallback<T>, options?: WatchOptions): vue_demi.WatchStopHandle;
|
|
1095
1130
|
|
|
1096
|
-
export { type AnyFn, type ArgumentsType, type Arrayable, type Awaitable, type ComputedRefWithControl, type ComputedWithControlRefExtra, type ConfigurableEventFilter, type ConfigurableFlush, type ConfigurableFlushSync, type ControlledRefOptions, type DateLike, type DebounceFilterOptions, type DeepMaybeRef, type ElementOf, type EventFilter, type EventHook, type EventHookOff, type EventHookOn, type EventHookTrigger, type ExtendRefOptions, type Fn, type FunctionArgs, type FunctionWrapperOptions, type IgnoredUpdater, type MapOldSources, type MapSources, type MaybeRef, type MaybeRefOrGetter, type MultiWatchSources, type Mutable, type Pausable, type PromisifyFn, type Reactified, type ReactifyNested, type ReactifyObjectOptions, type ReactifyOptions, type ReactiveOmitPredicate, type ReactivePickPredicate, type ReadonlyRefOrGetter, type RemovableRef, type ShallowUnwrapRef, type SingletonPromiseReturn, type Stoppable, type SyncRefOptions, type SyncRefsOptions, type ToRefsOptions, type UntilArrayInstance, type UntilBaseInstance, type UntilToMatchOptions, type UntilValueInstance, type UseArrayIncludesComparatorFn, type UseArrayIncludesOptions, type UseArrayReducer, type UseCounterOptions, type UseDateFormatOptions, type UseDateFormatReturn, type UseIntervalControls, type UseIntervalFnOptions, type UseIntervalOptions, type UseLastChangedOptions, type UseTimeoutFnOptions, type UseTimeoutOptions, type UseToNumberOptions, type UseToggleOptions, type WatchArrayCallback, type WatchAtMostOptions, type WatchAtMostReturn, type WatchDebouncedOptions, type WatchIgnorableReturn, type WatchPausableReturn, type WatchThrottledOptions, type WatchTriggerableCallback, type WatchTriggerableReturn, type WatchWithFilterOptions, type WritableComputedRefWithControl, assert, refAutoReset as autoResetRef, bypassFilter, camelize, clamp, computedEager, computedWithControl, containsProp, computedWithControl as controlledComputed, controlledRef, createEventHook, createFilterWrapper, createGlobalState, createInjectionState, reactify as createReactiveFn, createSharedComposable, createSingletonPromise, debounceFilter, refDebounced as debouncedRef, watchDebounced as debouncedWatch, directiveHooks, computedEager as eagerComputed, extendRef, formatDate, get, hasOwn, hyphenate, identity, watchIgnorable as ignorableWatch, increaseWithUnit, invoke, isClient, isDef, isDefined, isIOS, isObject, makeDestructurable, noop, normalizeDate, notNullish, now, objectEntries, objectOmit, objectPick, pausableFilter, watchPausable as pausableWatch, promiseTimeout, rand, reactify, reactifyObject, reactiveComputed, reactiveOmit, reactivePick, refAutoReset, refDebounced, refDefault, refThrottled, refWithControl, resolveRef, resolveUnref, set, syncRef, syncRefs, throttleFilter, refThrottled as throttledRef, watchThrottled as throttledWatch, timestamp, toReactive, toRef, toRefs, toValue, tryOnBeforeMount, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, until, useArrayDifference, useArrayEvery, useArrayFilter, useArrayFind, useArrayFindIndex, useArrayFindLast, useArrayIncludes, useArrayJoin, useArrayMap, useArrayReduce, useArraySome, useArrayUnique, useCounter, useDateFormat, refDebounced as useDebounce, useDebounceFn, useInterval, useIntervalFn, useLastChanged, refThrottled as useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useToNumber, useToString, useToggle, watchArray, watchAtMost, watchDebounced, watchDeep, watchIgnorable, watchImmediate, watchOnce, watchPausable, watchThrottled, watchTriggerable, watchWithFilter, whenever };
|
|
1131
|
+
export { type AnyFn, type ArgumentsType, type Arrayable, type Awaitable, type Awaited, type ComputedRefWithControl, type ComputedWithControlRefExtra, type ConfigurableEventFilter, type ConfigurableFlush, type ConfigurableFlushSync, type ControlledRefOptions, type CreateInjectionStateOptions, type DateLike, type DebounceFilterOptions, type DeepMaybeRef, type ElementOf, type EventFilter, type EventHook, type EventHookOff, type EventHookOn, type EventHookTrigger, type ExtendRefOptions, type Fn, type FunctionArgs, type FunctionWrapperOptions, type IgnoredUpdater, type MapOldSources, type MapSources, type MaybeRef, type MaybeRefOrGetter, type MultiWatchSources, type Mutable, type Pausable, type Promisify, type PromisifyFn, type Reactified, type ReactifyNested, type ReactifyObjectOptions, type ReactifyOptions, type ReactiveOmitPredicate, type ReactivePickPredicate, type ReadonlyRefOrGetter, type RemovableRef, type ShallowUnwrapRef, type SingletonPromiseReturn, type Stoppable, type SyncRefOptions, type SyncRefsOptions, type ToRefsOptions, type UntilArrayInstance, type UntilBaseInstance, type UntilToMatchOptions, type UntilValueInstance, type UseArrayIncludesComparatorFn, type UseArrayIncludesOptions, type UseArrayReducer, type UseCounterOptions, type UseDateFormatOptions, type UseDateFormatReturn, type UseIntervalControls, type UseIntervalFnOptions, type UseIntervalOptions, type UseLastChangedOptions, type UseTimeoutFnOptions, type UseTimeoutOptions, type UseToNumberOptions, type UseToggleOptions, type WatchArrayCallback, type WatchAtMostOptions, type WatchAtMostReturn, type WatchDebouncedOptions, type WatchIgnorableReturn, type WatchPausableReturn, type WatchThrottledOptions, type WatchTriggerableCallback, type WatchTriggerableReturn, type WatchWithFilterOptions, type WritableComputedRefWithControl, assert, refAutoReset as autoResetRef, bypassFilter, camelize, clamp, computedEager, computedWithControl, containsProp, computedWithControl as controlledComputed, controlledRef, createEventHook, createFilterWrapper, createGlobalState, createInjectionState, reactify as createReactiveFn, createSharedComposable, createSingletonPromise, debounceFilter, refDebounced as debouncedRef, watchDebounced as debouncedWatch, directiveHooks, computedEager as eagerComputed, extendRef, formatDate, get, hasOwn, hyphenate, identity, watchIgnorable as ignorableWatch, increaseWithUnit, injectLocal, invoke, isClient, isDef, isDefined, isIOS, isObject, makeDestructurable, noop, normalizeDate, notNullish, now, objectEntries, objectOmit, objectPick, pausableFilter, watchPausable as pausableWatch, promiseTimeout, provideLocal, rand, reactify, reactifyObject, reactiveComputed, reactiveOmit, reactivePick, refAutoReset, refDebounced, refDefault, refThrottled, refWithControl, resolveRef, resolveUnref, set, syncRef, syncRefs, throttleFilter, refThrottled as throttledRef, watchThrottled as throttledWatch, timestamp, toReactive, toRef, toRefs, toValue, tryOnBeforeMount, tryOnBeforeUnmount, tryOnMounted, tryOnScopeDispose, tryOnUnmounted, until, useArrayDifference, useArrayEvery, useArrayFilter, useArrayFind, useArrayFindIndex, useArrayFindLast, useArrayIncludes, useArrayJoin, useArrayMap, useArrayReduce, useArraySome, useArrayUnique, useCounter, useDateFormat, refDebounced as useDebounce, useDebounceFn, useInterval, useIntervalFn, useLastChanged, refThrottled as useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useToNumber, useToString, useToggle, watchArray, watchAtMost, watchDebounced, watchDeep, watchIgnorable, watchImmediate, watchOnce, watchPausable, watchThrottled, watchTriggerable, watchWithFilter, whenever };
|