@vueuse/shared 13.5.0 → 13.7.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.d.mts +53 -5
- package/index.iife.js +29 -1
- package/index.mjs +29 -1
- package/package.json +1 -1
package/index.d.mts
CHANGED
|
@@ -166,6 +166,8 @@ type EventHookReturn<T> = EventHook<T>;
|
|
|
166
166
|
* Utility for creating event hooks
|
|
167
167
|
*
|
|
168
168
|
* @see https://vueuse.org/createEventHook
|
|
169
|
+
*
|
|
170
|
+
* @__NO_SIDE_EFFECTS__
|
|
169
171
|
*/
|
|
170
172
|
declare function createEventHook<T = any>(): EventHookReturn<T>;
|
|
171
173
|
|
|
@@ -226,11 +228,6 @@ interface ThrottleFilterOptions {
|
|
|
226
228
|
}
|
|
227
229
|
/**
|
|
228
230
|
* Create an EventFilter that throttle the events
|
|
229
|
-
*
|
|
230
|
-
* @param ms
|
|
231
|
-
* @param [trailing]
|
|
232
|
-
* @param [leading]
|
|
233
|
-
* @param [rejectOnCancel]
|
|
234
231
|
*/
|
|
235
232
|
declare function throttleFilter(ms: MaybeRefOrGetter<number>, trailing?: boolean, leading?: boolean, rejectOnCancel?: boolean): EventFilter;
|
|
236
233
|
declare function throttleFilter(options: ThrottleFilterOptions): EventFilter;
|
|
@@ -327,6 +324,8 @@ type CreateGlobalStateReturn<Fn extends AnyFn = AnyFn> = Fn;
|
|
|
327
324
|
*
|
|
328
325
|
* @see https://vueuse.org/createGlobalState
|
|
329
326
|
* @param stateFactory A factory function to create the state
|
|
327
|
+
*
|
|
328
|
+
* @__NO_SIDE_EFFECTS__
|
|
330
329
|
*/
|
|
331
330
|
declare function createGlobalState<Fn extends AnyFn>(stateFactory: Fn): CreateGlobalStateReturn<Fn>;
|
|
332
331
|
|
|
@@ -345,6 +344,7 @@ interface CreateInjectionStateOptions<Return> {
|
|
|
345
344
|
*
|
|
346
345
|
* @see https://vueuse.org/createInjectionState
|
|
347
346
|
*
|
|
347
|
+
* @__NO_SIDE_EFFECTS__
|
|
348
348
|
*/
|
|
349
349
|
declare function createInjectionState<Arguments extends Array<any>, Return>(composable: (...args: Arguments) => Return, options?: CreateInjectionStateOptions<Return>): readonly [useProvidingState: (...args: Arguments) => Return, useInjectedState: () => Return | undefined];
|
|
350
350
|
|
|
@@ -362,6 +362,8 @@ type ShallowOrDeepRef<T = any, D extends boolean = false> = D extends true ? Ref
|
|
|
362
362
|
* @param value
|
|
363
363
|
* @param deep
|
|
364
364
|
* @returns the `deepRef` or `shallowRef`
|
|
365
|
+
*
|
|
366
|
+
* @__NO_SIDE_EFFECTS__
|
|
365
367
|
*/
|
|
366
368
|
declare function createRef<T = any, D extends boolean = false>(value: T, deep?: D): CreateRefReturn<T, D>;
|
|
367
369
|
|
|
@@ -370,6 +372,8 @@ type SharedComposableReturn<T extends AnyFn = AnyFn> = T;
|
|
|
370
372
|
* Make a composable function usable with multiple Vue instances.
|
|
371
373
|
*
|
|
372
374
|
* @see https://vueuse.org/createSharedComposable
|
|
375
|
+
*
|
|
376
|
+
* @__NO_SIDE_EFFECTS__
|
|
373
377
|
*/
|
|
374
378
|
declare function createSharedComposable<Fn extends AnyFn>(composable: Fn): SharedComposableReturn<Fn>;
|
|
375
379
|
|
|
@@ -411,6 +415,8 @@ declare function get<T, K extends keyof T>(ref: MaybeRef<T>, key: K): T[K];
|
|
|
411
415
|
* injectLocal('MyInjectionKey', 1)
|
|
412
416
|
* const injectedValue = injectLocal('MyInjectionKey') // injectedValue === 1
|
|
413
417
|
* ```
|
|
418
|
+
*
|
|
419
|
+
* @__NO_SIDE_EFFECTS__
|
|
414
420
|
*/
|
|
415
421
|
declare const injectLocal: typeof inject;
|
|
416
422
|
|
|
@@ -452,6 +458,8 @@ interface ReactifyOptions<T extends boolean> {
|
|
|
452
458
|
*
|
|
453
459
|
* @param fn - Source function
|
|
454
460
|
* @param options - Options
|
|
461
|
+
*
|
|
462
|
+
* @__NO_SIDE_EFFECTS__
|
|
455
463
|
*/
|
|
456
464
|
declare function reactify<T extends AnyFn, K extends boolean = true>(fn: T, options?: ReactifyOptions<K>): ReactifyReturn<T, K>;
|
|
457
465
|
|
|
@@ -469,6 +477,8 @@ interface ReactifyObjectOptions<T extends boolean> extends ReactifyOptions<T> {
|
|
|
469
477
|
}
|
|
470
478
|
/**
|
|
471
479
|
* Apply `reactify` to an object
|
|
480
|
+
*
|
|
481
|
+
* @__NO_SIDE_EFFECTS__
|
|
472
482
|
*/
|
|
473
483
|
declare function reactifyObject<T extends object, Keys extends keyof T>(obj: T, keys?: (keyof T)[]): ReactifyObjectReturn<T, Keys, true>;
|
|
474
484
|
declare function reactifyObject<T extends object, S extends boolean = true>(obj: T, options?: ReactifyObjectOptions<S>): ReactifyObjectReturn<T, keyof T, S>;
|
|
@@ -511,6 +521,8 @@ declare function refDebounced<T>(value: Ref<T>, ms?: MaybeRefOrGetter<number>, o
|
|
|
511
521
|
|
|
512
522
|
/**
|
|
513
523
|
* Apply default value to a ref.
|
|
524
|
+
*
|
|
525
|
+
* @__NO_SIDE_EFFECTS__
|
|
514
526
|
*/
|
|
515
527
|
declare function refDefault<T>(source: Ref<T | undefined | null>, defaultValue: T): Ref<T>;
|
|
516
528
|
|
|
@@ -542,6 +554,8 @@ interface ControlledRefOptions<T> {
|
|
|
542
554
|
}
|
|
543
555
|
/**
|
|
544
556
|
* Fine-grained controls over ref and its reactivity.
|
|
557
|
+
*
|
|
558
|
+
* @__NO_SIDE_EFFECTS__
|
|
545
559
|
*/
|
|
546
560
|
declare function refWithControl<T>(initial: T, options?: ControlledRefOptions<T>): vue.ShallowUnwrapRef<{
|
|
547
561
|
get: (tracking?: boolean) => T;
|
|
@@ -826,6 +840,8 @@ type UseArrayEveryReturn = ComputedRef<boolean>;
|
|
|
826
840
|
* @param fn - a function to test each element.
|
|
827
841
|
*
|
|
828
842
|
* @returns **true** if the `fn` function returns a **truthy** value for every element from the array. Otherwise, **false**.
|
|
843
|
+
*
|
|
844
|
+
* @__NO_SIDE_EFFECTS__
|
|
829
845
|
*/
|
|
830
846
|
declare function useArrayEvery<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: MaybeRefOrGetter<T>[]) => unknown): UseArrayEveryReturn;
|
|
831
847
|
|
|
@@ -838,6 +854,8 @@ type UseArrayFilterReturn<T = any> = ComputedRef<T[]>;
|
|
|
838
854
|
* @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.
|
|
839
855
|
*
|
|
840
856
|
* @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.
|
|
857
|
+
*
|
|
858
|
+
* @__NO_SIDE_EFFECTS__
|
|
841
859
|
*/
|
|
842
860
|
declare function useArrayFilter<T, S extends T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: T[]) => element is S): UseArrayFilterReturn<S>;
|
|
843
861
|
declare function useArrayFilter<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: T[]) => unknown): UseArrayFilterReturn<T>;
|
|
@@ -851,6 +869,8 @@ type UseArrayFindReturn<T = any> = ComputedRef<T | undefined>;
|
|
|
851
869
|
* @param fn - a function to test each element.
|
|
852
870
|
*
|
|
853
871
|
* @returns the first element in the array that satisfies the provided testing function. Otherwise, undefined is returned.
|
|
872
|
+
*
|
|
873
|
+
* @__NO_SIDE_EFFECTS__
|
|
854
874
|
*/
|
|
855
875
|
declare function useArrayFind<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: MaybeRefOrGetter<T>[]) => boolean): UseArrayFindReturn<T>;
|
|
856
876
|
|
|
@@ -863,6 +883,8 @@ type UseArrayFindIndexReturn = ComputedRef<number>;
|
|
|
863
883
|
* @param fn - a function to test each element.
|
|
864
884
|
*
|
|
865
885
|
* @returns the index of the first element in the array that passes the test. Otherwise, "-1".
|
|
886
|
+
*
|
|
887
|
+
* @__NO_SIDE_EFFECTS__
|
|
866
888
|
*/
|
|
867
889
|
declare function useArrayFindIndex<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: MaybeRefOrGetter<T>[]) => unknown): UseArrayFindIndexReturn;
|
|
868
890
|
|
|
@@ -875,6 +897,8 @@ type UseArrayFindLastReturn<T = any> = ComputedRef<T | undefined>;
|
|
|
875
897
|
* @param fn - a function to test each element.
|
|
876
898
|
*
|
|
877
899
|
* @returns the last element in the array that satisfies the provided testing function. Otherwise, undefined is returned.
|
|
900
|
+
*
|
|
901
|
+
* @__NO_SIDE_EFFECTS__
|
|
878
902
|
*/
|
|
879
903
|
declare function useArrayFindLast<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: MaybeRefOrGetter<T>[]) => boolean): UseArrayFindLastReturn<T>;
|
|
880
904
|
|
|
@@ -890,6 +914,8 @@ type UseArrayIncludesReturn = ComputedRef<boolean>;
|
|
|
890
914
|
* @see https://vueuse.org/useArrayIncludes
|
|
891
915
|
*
|
|
892
916
|
* @returns true if the `value` is found in the array. Otherwise, false.
|
|
917
|
+
*
|
|
918
|
+
* @__NO_SIDE_EFFECTS__
|
|
893
919
|
*/
|
|
894
920
|
declare function useArrayIncludes<T, V = any>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, value: MaybeRefOrGetter<V>, comparator?: UseArrayIncludesComparatorFn<T, V>): UseArrayIncludesReturn;
|
|
895
921
|
declare function useArrayIncludes<T, V = any>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, value: MaybeRefOrGetter<V>, comparator?: keyof T): UseArrayIncludesReturn;
|
|
@@ -904,6 +930,8 @@ type UseArrayJoinReturn = ComputedRef<string>;
|
|
|
904
930
|
* @param separator - a string to separate each pair of adjacent elements of the array. If omitted, the array elements are separated with a comma (",").
|
|
905
931
|
*
|
|
906
932
|
* @returns a string with all array elements joined. If arr.length is 0, the empty string is returned.
|
|
933
|
+
*
|
|
934
|
+
* @__NO_SIDE_EFFECTS__
|
|
907
935
|
*/
|
|
908
936
|
declare function useArrayJoin(list: MaybeRefOrGetter<MaybeRefOrGetter<any>[]>, separator?: MaybeRefOrGetter<string>): UseArrayJoinReturn;
|
|
909
937
|
|
|
@@ -916,6 +944,8 @@ type UseArrayMapReturn<T = any> = ComputedRef<T[]>;
|
|
|
916
944
|
* @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.
|
|
917
945
|
*
|
|
918
946
|
* @returns a new array with each element being the result of the callback function.
|
|
947
|
+
*
|
|
948
|
+
* @__NO_SIDE_EFFECTS__
|
|
919
949
|
*/
|
|
920
950
|
declare function useArrayMap<T, U = T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: T[]) => U): UseArrayMapReturn<U>;
|
|
921
951
|
|
|
@@ -928,6 +958,8 @@ type UseArrayReducer<PV, CV, R> = (previousValue: PV, currentValue: CV, currentI
|
|
|
928
958
|
* @param reducer - a "reducer" function.
|
|
929
959
|
*
|
|
930
960
|
* @returns the value that results from running the "reducer" callback function to completion over the entire array.
|
|
961
|
+
*
|
|
962
|
+
* @__NO_SIDE_EFFECTS__
|
|
931
963
|
*/
|
|
932
964
|
declare function useArrayReduce<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, reducer: UseArrayReducer<T, T, T>): ComputedRef<T>;
|
|
933
965
|
/**
|
|
@@ -939,6 +971,8 @@ declare function useArrayReduce<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>
|
|
|
939
971
|
* @param initialValue - a value to be initialized the first time when the callback is called.
|
|
940
972
|
*
|
|
941
973
|
* @returns the value that results from running the "reducer" callback function to completion over the entire array.
|
|
974
|
+
*
|
|
975
|
+
* @__NO_SIDE_EFFECTS__
|
|
942
976
|
*/
|
|
943
977
|
declare function useArrayReduce<T, U>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, reducer: UseArrayReducer<U, T, U>, initialValue: MaybeRefOrGetter<U>): ComputedRef<U>;
|
|
944
978
|
|
|
@@ -951,6 +985,8 @@ type UseArraySomeReturn = ComputedRef<boolean>;
|
|
|
951
985
|
* @param fn - a function to test each element.
|
|
952
986
|
*
|
|
953
987
|
* @returns **true** if the `fn` function returns a **truthy** value for any element from the array. Otherwise, **false**.
|
|
988
|
+
*
|
|
989
|
+
* @__NO_SIDE_EFFECTS__
|
|
954
990
|
*/
|
|
955
991
|
declare function useArraySome<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, fn: (element: T, index: number, array: MaybeRefOrGetter<T>[]) => unknown): UseArraySomeReturn;
|
|
956
992
|
|
|
@@ -961,6 +997,8 @@ type UseArrayUniqueReturn<T = any> = ComputedRef<T[]>;
|
|
|
961
997
|
* @param list - the array was called upon.
|
|
962
998
|
* @param compareFn
|
|
963
999
|
* @returns A computed ref that returns a unique array of items.
|
|
1000
|
+
*
|
|
1001
|
+
* @__NO_SIDE_EFFECTS__
|
|
964
1002
|
*/
|
|
965
1003
|
declare function useArrayUnique<T>(list: MaybeRefOrGetter<MaybeRefOrGetter<T>[]>, compareFn?: (a: T, b: T, array: T[]) => boolean): UseArrayUniqueReturn<T>;
|
|
966
1004
|
|
|
@@ -1040,6 +1078,8 @@ type UseDateFormatReturn = ComputedRef<string>;
|
|
|
1040
1078
|
* @param date - The date to format, can either be a `Date` object, a timestamp, or a string
|
|
1041
1079
|
* @param formatStr - The combination of tokens to format the date
|
|
1042
1080
|
* @param options - UseDateFormatOptions
|
|
1081
|
+
*
|
|
1082
|
+
* @__NO_SIDE_EFFECTS__
|
|
1043
1083
|
*/
|
|
1044
1084
|
declare function useDateFormat(date: MaybeRefOrGetter<DateLike>, formatStr?: MaybeRefOrGetter<string>, options?: UseDateFormatOptions): UseDateFormatReturn;
|
|
1045
1085
|
|
|
@@ -1053,6 +1093,8 @@ type UseDebounceFnReturn<T extends FunctionArgs> = PromisifyFn<T>;
|
|
|
1053
1093
|
* @param options Options
|
|
1054
1094
|
*
|
|
1055
1095
|
* @return A new, debounce, function.
|
|
1096
|
+
*
|
|
1097
|
+
* @__NO_SIDE_EFFECTS__
|
|
1056
1098
|
*/
|
|
1057
1099
|
declare function useDebounceFn<T extends FunctionArgs>(fn: T, ms?: MaybeRefOrGetter<number>, options?: DebounceFilterOptions): UseDebounceFnReturn<T>;
|
|
1058
1100
|
|
|
@@ -1142,6 +1184,8 @@ declare function useLastChanged(source: WatchSource, options: UseLastChangedOpti
|
|
|
1142
1184
|
* @param [rejectOnCancel] if true, reject the last call if it's been cancel (default value: false)
|
|
1143
1185
|
*
|
|
1144
1186
|
* @return A new, throttled, function.
|
|
1187
|
+
*
|
|
1188
|
+
* @__NO_SIDE_EFFECTS__
|
|
1145
1189
|
*/
|
|
1146
1190
|
declare function useThrottleFn<T extends FunctionArgs>(fn: T, ms?: MaybeRefOrGetter<number>, trailing?: boolean, leading?: boolean, rejectOnCancel?: boolean): PromisifyFn<T>;
|
|
1147
1191
|
|
|
@@ -1219,6 +1263,8 @@ interface UseToNumberOptions {
|
|
|
1219
1263
|
}
|
|
1220
1264
|
/**
|
|
1221
1265
|
* Reactively convert a string ref to number.
|
|
1266
|
+
*
|
|
1267
|
+
* @__NO_SIDE_EFFECTS__
|
|
1222
1268
|
*/
|
|
1223
1269
|
declare function useToNumber(value: MaybeRefOrGetter<number | string>, options?: UseToNumberOptions): ComputedRef<number>;
|
|
1224
1270
|
|
|
@@ -1226,6 +1272,8 @@ declare function useToNumber(value: MaybeRefOrGetter<number | string>, options?:
|
|
|
1226
1272
|
* Reactively convert a ref to string.
|
|
1227
1273
|
*
|
|
1228
1274
|
* @see https://vueuse.org/useToString
|
|
1275
|
+
*
|
|
1276
|
+
* @__NO_SIDE_EFFECTS__
|
|
1229
1277
|
*/
|
|
1230
1278
|
declare function useToString(value: MaybeRefOrGetter<unknown>): ComputedRef<string>;
|
|
1231
1279
|
|
package/index.iife.js
CHANGED
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
return false;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
// @__NO_SIDE_EFFECTS__
|
|
57
58
|
function createEventHook() {
|
|
58
59
|
const fns = /* @__PURE__ */ new Set();
|
|
59
60
|
const off = (fn) => {
|
|
@@ -81,6 +82,7 @@
|
|
|
81
82
|
};
|
|
82
83
|
}
|
|
83
84
|
|
|
85
|
+
// @__NO_SIDE_EFFECTS__
|
|
84
86
|
function createGlobalState(stateFactory) {
|
|
85
87
|
let initialized = false;
|
|
86
88
|
let state;
|
|
@@ -96,7 +98,7 @@
|
|
|
96
98
|
|
|
97
99
|
const localProvidedStateMap = /* @__PURE__ */ new WeakMap();
|
|
98
100
|
|
|
99
|
-
const injectLocal = (...args) => {
|
|
101
|
+
const injectLocal = /* @__NO_SIDE_EFFECTS__ */ (...args) => {
|
|
100
102
|
var _a;
|
|
101
103
|
const key = args[0];
|
|
102
104
|
const instance = (_a = vue.getCurrentInstance()) == null ? void 0 : _a.proxy;
|
|
@@ -119,6 +121,7 @@
|
|
|
119
121
|
return vue.provide(key, value);
|
|
120
122
|
}
|
|
121
123
|
|
|
124
|
+
// @__NO_SIDE_EFFECTS__
|
|
122
125
|
function createInjectionState(composable, options) {
|
|
123
126
|
const key = (options == null ? void 0 : options.injectionKey) || Symbol(composable.name || "InjectionState");
|
|
124
127
|
const defaultValue = options == null ? void 0 : options.defaultValue;
|
|
@@ -131,6 +134,7 @@
|
|
|
131
134
|
return [useProvidingState, useInjectedState];
|
|
132
135
|
}
|
|
133
136
|
|
|
137
|
+
// @__NO_SIDE_EFFECTS__
|
|
134
138
|
function createRef(value, deep) {
|
|
135
139
|
if (deep === true) {
|
|
136
140
|
return vue.ref(value);
|
|
@@ -139,6 +143,7 @@
|
|
|
139
143
|
}
|
|
140
144
|
}
|
|
141
145
|
|
|
146
|
+
// @__NO_SIDE_EFFECTS__
|
|
142
147
|
function createSharedComposable(composable) {
|
|
143
148
|
let subscribers = 0;
|
|
144
149
|
let state;
|
|
@@ -193,6 +198,7 @@
|
|
|
193
198
|
return vue.unref(v) != null;
|
|
194
199
|
}
|
|
195
200
|
|
|
201
|
+
// @__NO_SIDE_EFFECTS__
|
|
196
202
|
function makeDestructurable(obj, arr) {
|
|
197
203
|
if (typeof Symbol !== "undefined") {
|
|
198
204
|
const clone = { ...obj };
|
|
@@ -214,6 +220,7 @@
|
|
|
214
220
|
}
|
|
215
221
|
}
|
|
216
222
|
|
|
223
|
+
// @__NO_SIDE_EFFECTS__
|
|
217
224
|
function reactify(fn, options) {
|
|
218
225
|
const unrefFn = (options == null ? void 0 : options.computedGetter) === false ? vue.unref : vue.toValue;
|
|
219
226
|
return function(...args) {
|
|
@@ -221,6 +228,7 @@
|
|
|
221
228
|
};
|
|
222
229
|
}
|
|
223
230
|
|
|
231
|
+
// @__NO_SIDE_EFFECTS__
|
|
224
232
|
function reactifyObject(obj, optionsOrKeys = {}) {
|
|
225
233
|
let keys = [];
|
|
226
234
|
let options;
|
|
@@ -565,6 +573,7 @@
|
|
|
565
573
|
return target || vue.getCurrentInstance();
|
|
566
574
|
}
|
|
567
575
|
|
|
576
|
+
// @__NO_SIDE_EFFECTS__
|
|
568
577
|
function useDebounceFn(fn, ms = 200, options = {}) {
|
|
569
578
|
return createFilterWrapper(
|
|
570
579
|
debounceFilter(ms, options),
|
|
@@ -581,6 +590,7 @@
|
|
|
581
590
|
return vue.shallowReadonly(debounced);
|
|
582
591
|
}
|
|
583
592
|
|
|
593
|
+
// @__NO_SIDE_EFFECTS__
|
|
584
594
|
function refDefault(source, defaultValue) {
|
|
585
595
|
return vue.computed({
|
|
586
596
|
get() {
|
|
@@ -593,6 +603,7 @@
|
|
|
593
603
|
});
|
|
594
604
|
}
|
|
595
605
|
|
|
606
|
+
// @__NO_SIDE_EFFECTS__
|
|
596
607
|
function useThrottleFn(fn, ms = 200, trailing = false, leading = true, rejectOnCancel = false) {
|
|
597
608
|
return createFilterWrapper(
|
|
598
609
|
throttleFilter(ms, trailing, leading, rejectOnCancel),
|
|
@@ -611,6 +622,7 @@
|
|
|
611
622
|
return throttled;
|
|
612
623
|
}
|
|
613
624
|
|
|
625
|
+
// @__NO_SIDE_EFFECTS__
|
|
614
626
|
function refWithControl(initial, options = {}) {
|
|
615
627
|
let source = initial;
|
|
616
628
|
let track;
|
|
@@ -954,6 +966,7 @@
|
|
|
954
966
|
function defaultComparator(value, othVal) {
|
|
955
967
|
return value === othVal;
|
|
956
968
|
}
|
|
969
|
+
// @__NO_SIDE_EFFECTS__
|
|
957
970
|
function useArrayDifference(...args) {
|
|
958
971
|
var _a, _b;
|
|
959
972
|
const list = args[0];
|
|
@@ -975,20 +988,24 @@
|
|
|
975
988
|
}
|
|
976
989
|
}
|
|
977
990
|
|
|
991
|
+
// @__NO_SIDE_EFFECTS__
|
|
978
992
|
function useArrayEvery(list, fn) {
|
|
979
993
|
return vue.computed(() => vue.toValue(list).every((element, index, array) => fn(vue.toValue(element), index, array)));
|
|
980
994
|
}
|
|
981
995
|
|
|
996
|
+
// @__NO_SIDE_EFFECTS__
|
|
982
997
|
function useArrayFilter(list, fn) {
|
|
983
998
|
return vue.computed(() => vue.toValue(list).map((i) => vue.toValue(i)).filter(fn));
|
|
984
999
|
}
|
|
985
1000
|
|
|
1001
|
+
// @__NO_SIDE_EFFECTS__
|
|
986
1002
|
function useArrayFind(list, fn) {
|
|
987
1003
|
return vue.computed(() => vue.toValue(
|
|
988
1004
|
vue.toValue(list).find((element, index, array) => fn(vue.toValue(element), index, array))
|
|
989
1005
|
));
|
|
990
1006
|
}
|
|
991
1007
|
|
|
1008
|
+
// @__NO_SIDE_EFFECTS__
|
|
992
1009
|
function useArrayFindIndex(list, fn) {
|
|
993
1010
|
return vue.computed(() => vue.toValue(list).findIndex((element, index, array) => fn(vue.toValue(element), index, array)));
|
|
994
1011
|
}
|
|
@@ -1001,6 +1018,7 @@
|
|
|
1001
1018
|
}
|
|
1002
1019
|
return void 0;
|
|
1003
1020
|
}
|
|
1021
|
+
// @__NO_SIDE_EFFECTS__
|
|
1004
1022
|
function useArrayFindLast(list, fn) {
|
|
1005
1023
|
return vue.computed(() => vue.toValue(
|
|
1006
1024
|
!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))
|
|
@@ -1010,6 +1028,7 @@
|
|
|
1010
1028
|
function isArrayIncludesOptions(obj) {
|
|
1011
1029
|
return isObject(obj) && containsProp(obj, "formIndex", "comparator");
|
|
1012
1030
|
}
|
|
1031
|
+
// @__NO_SIDE_EFFECTS__
|
|
1013
1032
|
function useArrayIncludes(...args) {
|
|
1014
1033
|
var _a;
|
|
1015
1034
|
const list = args[0];
|
|
@@ -1033,14 +1052,17 @@
|
|
|
1033
1052
|
)));
|
|
1034
1053
|
}
|
|
1035
1054
|
|
|
1055
|
+
// @__NO_SIDE_EFFECTS__
|
|
1036
1056
|
function useArrayJoin(list, separator) {
|
|
1037
1057
|
return vue.computed(() => vue.toValue(list).map((i) => vue.toValue(i)).join(vue.toValue(separator)));
|
|
1038
1058
|
}
|
|
1039
1059
|
|
|
1060
|
+
// @__NO_SIDE_EFFECTS__
|
|
1040
1061
|
function useArrayMap(list, fn) {
|
|
1041
1062
|
return vue.computed(() => vue.toValue(list).map((i) => vue.toValue(i)).map(fn));
|
|
1042
1063
|
}
|
|
1043
1064
|
|
|
1065
|
+
// @__NO_SIDE_EFFECTS__
|
|
1044
1066
|
function useArrayReduce(list, reducer, ...args) {
|
|
1045
1067
|
const reduceCallback = (sum, value, index) => reducer(vue.toValue(sum), vue.toValue(value), index);
|
|
1046
1068
|
return vue.computed(() => {
|
|
@@ -1049,6 +1071,7 @@
|
|
|
1049
1071
|
});
|
|
1050
1072
|
}
|
|
1051
1073
|
|
|
1074
|
+
// @__NO_SIDE_EFFECTS__
|
|
1052
1075
|
function useArraySome(list, fn) {
|
|
1053
1076
|
return vue.computed(() => vue.toValue(list).some((element, index, array) => fn(vue.toValue(element), index, array)));
|
|
1054
1077
|
}
|
|
@@ -1063,6 +1086,7 @@
|
|
|
1063
1086
|
return acc;
|
|
1064
1087
|
}, []);
|
|
1065
1088
|
}
|
|
1089
|
+
// @__NO_SIDE_EFFECTS__
|
|
1066
1090
|
function useArrayUnique(list, compareFn) {
|
|
1067
1091
|
return vue.computed(() => {
|
|
1068
1092
|
const resolvedList = vue.toValue(list).map((element) => vue.toValue(element));
|
|
@@ -1176,6 +1200,7 @@
|
|
|
1176
1200
|
}
|
|
1177
1201
|
return new Date(date);
|
|
1178
1202
|
}
|
|
1203
|
+
// @__NO_SIDE_EFFECTS__
|
|
1179
1204
|
function useDateFormat(date, formatStr = "HH:mm:ss", options = {}) {
|
|
1180
1205
|
return vue.computed(() => formatDate(normalizeDate(vue.toValue(date)), vue.toValue(formatStr), options));
|
|
1181
1206
|
}
|
|
@@ -1328,6 +1353,7 @@
|
|
|
1328
1353
|
}
|
|
1329
1354
|
}
|
|
1330
1355
|
|
|
1356
|
+
// @__NO_SIDE_EFFECTS__
|
|
1331
1357
|
function useToNumber(value, options = {}) {
|
|
1332
1358
|
const {
|
|
1333
1359
|
method = "parseFloat",
|
|
@@ -1346,10 +1372,12 @@
|
|
|
1346
1372
|
});
|
|
1347
1373
|
}
|
|
1348
1374
|
|
|
1375
|
+
// @__NO_SIDE_EFFECTS__
|
|
1349
1376
|
function useToString(value) {
|
|
1350
1377
|
return vue.computed(() => `${vue.toValue(value)}`);
|
|
1351
1378
|
}
|
|
1352
1379
|
|
|
1380
|
+
// @__NO_SIDE_EFFECTS__
|
|
1353
1381
|
function useToggle(initialValue = false, options = {}) {
|
|
1354
1382
|
const {
|
|
1355
1383
|
truthyValue = true,
|
package/index.mjs
CHANGED
|
@@ -53,6 +53,7 @@ function tryOnScopeDispose(fn) {
|
|
|
53
53
|
return false;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
// @__NO_SIDE_EFFECTS__
|
|
56
57
|
function createEventHook() {
|
|
57
58
|
const fns = /* @__PURE__ */ new Set();
|
|
58
59
|
const off = (fn) => {
|
|
@@ -80,6 +81,7 @@ function createEventHook() {
|
|
|
80
81
|
};
|
|
81
82
|
}
|
|
82
83
|
|
|
84
|
+
// @__NO_SIDE_EFFECTS__
|
|
83
85
|
function createGlobalState(stateFactory) {
|
|
84
86
|
let initialized = false;
|
|
85
87
|
let state;
|
|
@@ -95,7 +97,7 @@ function createGlobalState(stateFactory) {
|
|
|
95
97
|
|
|
96
98
|
const localProvidedStateMap = /* @__PURE__ */ new WeakMap();
|
|
97
99
|
|
|
98
|
-
const injectLocal = (...args) => {
|
|
100
|
+
const injectLocal = /* @__NO_SIDE_EFFECTS__ */ (...args) => {
|
|
99
101
|
var _a;
|
|
100
102
|
const key = args[0];
|
|
101
103
|
const instance = (_a = getCurrentInstance()) == null ? void 0 : _a.proxy;
|
|
@@ -118,6 +120,7 @@ function provideLocal(key, value) {
|
|
|
118
120
|
return provide(key, value);
|
|
119
121
|
}
|
|
120
122
|
|
|
123
|
+
// @__NO_SIDE_EFFECTS__
|
|
121
124
|
function createInjectionState(composable, options) {
|
|
122
125
|
const key = (options == null ? void 0 : options.injectionKey) || Symbol(composable.name || "InjectionState");
|
|
123
126
|
const defaultValue = options == null ? void 0 : options.defaultValue;
|
|
@@ -130,6 +133,7 @@ function createInjectionState(composable, options) {
|
|
|
130
133
|
return [useProvidingState, useInjectedState];
|
|
131
134
|
}
|
|
132
135
|
|
|
136
|
+
// @__NO_SIDE_EFFECTS__
|
|
133
137
|
function createRef(value, deep) {
|
|
134
138
|
if (deep === true) {
|
|
135
139
|
return ref(value);
|
|
@@ -138,6 +142,7 @@ function createRef(value, deep) {
|
|
|
138
142
|
}
|
|
139
143
|
}
|
|
140
144
|
|
|
145
|
+
// @__NO_SIDE_EFFECTS__
|
|
141
146
|
function createSharedComposable(composable) {
|
|
142
147
|
let subscribers = 0;
|
|
143
148
|
let state;
|
|
@@ -192,6 +197,7 @@ function isDefined(v) {
|
|
|
192
197
|
return unref(v) != null;
|
|
193
198
|
}
|
|
194
199
|
|
|
200
|
+
// @__NO_SIDE_EFFECTS__
|
|
195
201
|
function makeDestructurable(obj, arr) {
|
|
196
202
|
if (typeof Symbol !== "undefined") {
|
|
197
203
|
const clone = { ...obj };
|
|
@@ -213,6 +219,7 @@ function makeDestructurable(obj, arr) {
|
|
|
213
219
|
}
|
|
214
220
|
}
|
|
215
221
|
|
|
222
|
+
// @__NO_SIDE_EFFECTS__
|
|
216
223
|
function reactify(fn, options) {
|
|
217
224
|
const unrefFn = (options == null ? void 0 : options.computedGetter) === false ? unref : toValue$1;
|
|
218
225
|
return function(...args) {
|
|
@@ -220,6 +227,7 @@ function reactify(fn, options) {
|
|
|
220
227
|
};
|
|
221
228
|
}
|
|
222
229
|
|
|
230
|
+
// @__NO_SIDE_EFFECTS__
|
|
223
231
|
function reactifyObject(obj, optionsOrKeys = {}) {
|
|
224
232
|
let keys = [];
|
|
225
233
|
let options;
|
|
@@ -564,6 +572,7 @@ function getLifeCycleTarget(target) {
|
|
|
564
572
|
return target || getCurrentInstance();
|
|
565
573
|
}
|
|
566
574
|
|
|
575
|
+
// @__NO_SIDE_EFFECTS__
|
|
567
576
|
function useDebounceFn(fn, ms = 200, options = {}) {
|
|
568
577
|
return createFilterWrapper(
|
|
569
578
|
debounceFilter(ms, options),
|
|
@@ -580,6 +589,7 @@ function refDebounced(value, ms = 200, options = {}) {
|
|
|
580
589
|
return shallowReadonly(debounced);
|
|
581
590
|
}
|
|
582
591
|
|
|
592
|
+
// @__NO_SIDE_EFFECTS__
|
|
583
593
|
function refDefault(source, defaultValue) {
|
|
584
594
|
return computed({
|
|
585
595
|
get() {
|
|
@@ -592,6 +602,7 @@ function refDefault(source, defaultValue) {
|
|
|
592
602
|
});
|
|
593
603
|
}
|
|
594
604
|
|
|
605
|
+
// @__NO_SIDE_EFFECTS__
|
|
595
606
|
function useThrottleFn(fn, ms = 200, trailing = false, leading = true, rejectOnCancel = false) {
|
|
596
607
|
return createFilterWrapper(
|
|
597
608
|
throttleFilter(ms, trailing, leading, rejectOnCancel),
|
|
@@ -610,6 +621,7 @@ function refThrottled(value, delay = 200, trailing = true, leading = true) {
|
|
|
610
621
|
return throttled;
|
|
611
622
|
}
|
|
612
623
|
|
|
624
|
+
// @__NO_SIDE_EFFECTS__
|
|
613
625
|
function refWithControl(initial, options = {}) {
|
|
614
626
|
let source = initial;
|
|
615
627
|
let track;
|
|
@@ -953,6 +965,7 @@ function until(r) {
|
|
|
953
965
|
function defaultComparator(value, othVal) {
|
|
954
966
|
return value === othVal;
|
|
955
967
|
}
|
|
968
|
+
// @__NO_SIDE_EFFECTS__
|
|
956
969
|
function useArrayDifference(...args) {
|
|
957
970
|
var _a, _b;
|
|
958
971
|
const list = args[0];
|
|
@@ -974,20 +987,24 @@ function useArrayDifference(...args) {
|
|
|
974
987
|
}
|
|
975
988
|
}
|
|
976
989
|
|
|
990
|
+
// @__NO_SIDE_EFFECTS__
|
|
977
991
|
function useArrayEvery(list, fn) {
|
|
978
992
|
return computed(() => toValue$1(list).every((element, index, array) => fn(toValue$1(element), index, array)));
|
|
979
993
|
}
|
|
980
994
|
|
|
995
|
+
// @__NO_SIDE_EFFECTS__
|
|
981
996
|
function useArrayFilter(list, fn) {
|
|
982
997
|
return computed(() => toValue$1(list).map((i) => toValue$1(i)).filter(fn));
|
|
983
998
|
}
|
|
984
999
|
|
|
1000
|
+
// @__NO_SIDE_EFFECTS__
|
|
985
1001
|
function useArrayFind(list, fn) {
|
|
986
1002
|
return computed(() => toValue$1(
|
|
987
1003
|
toValue$1(list).find((element, index, array) => fn(toValue$1(element), index, array))
|
|
988
1004
|
));
|
|
989
1005
|
}
|
|
990
1006
|
|
|
1007
|
+
// @__NO_SIDE_EFFECTS__
|
|
991
1008
|
function useArrayFindIndex(list, fn) {
|
|
992
1009
|
return computed(() => toValue$1(list).findIndex((element, index, array) => fn(toValue$1(element), index, array)));
|
|
993
1010
|
}
|
|
@@ -1000,6 +1017,7 @@ function findLast(arr, cb) {
|
|
|
1000
1017
|
}
|
|
1001
1018
|
return void 0;
|
|
1002
1019
|
}
|
|
1020
|
+
// @__NO_SIDE_EFFECTS__
|
|
1003
1021
|
function useArrayFindLast(list, fn) {
|
|
1004
1022
|
return computed(() => toValue$1(
|
|
1005
1023
|
!Array.prototype.findLast ? findLast(toValue$1(list), (element, index, array) => fn(toValue$1(element), index, array)) : toValue$1(list).findLast((element, index, array) => fn(toValue$1(element), index, array))
|
|
@@ -1009,6 +1027,7 @@ function useArrayFindLast(list, fn) {
|
|
|
1009
1027
|
function isArrayIncludesOptions(obj) {
|
|
1010
1028
|
return isObject(obj) && containsProp(obj, "formIndex", "comparator");
|
|
1011
1029
|
}
|
|
1030
|
+
// @__NO_SIDE_EFFECTS__
|
|
1012
1031
|
function useArrayIncludes(...args) {
|
|
1013
1032
|
var _a;
|
|
1014
1033
|
const list = args[0];
|
|
@@ -1032,14 +1051,17 @@ function useArrayIncludes(...args) {
|
|
|
1032
1051
|
)));
|
|
1033
1052
|
}
|
|
1034
1053
|
|
|
1054
|
+
// @__NO_SIDE_EFFECTS__
|
|
1035
1055
|
function useArrayJoin(list, separator) {
|
|
1036
1056
|
return computed(() => toValue$1(list).map((i) => toValue$1(i)).join(toValue$1(separator)));
|
|
1037
1057
|
}
|
|
1038
1058
|
|
|
1059
|
+
// @__NO_SIDE_EFFECTS__
|
|
1039
1060
|
function useArrayMap(list, fn) {
|
|
1040
1061
|
return computed(() => toValue$1(list).map((i) => toValue$1(i)).map(fn));
|
|
1041
1062
|
}
|
|
1042
1063
|
|
|
1064
|
+
// @__NO_SIDE_EFFECTS__
|
|
1043
1065
|
function useArrayReduce(list, reducer, ...args) {
|
|
1044
1066
|
const reduceCallback = (sum, value, index) => reducer(toValue$1(sum), toValue$1(value), index);
|
|
1045
1067
|
return computed(() => {
|
|
@@ -1048,6 +1070,7 @@ function useArrayReduce(list, reducer, ...args) {
|
|
|
1048
1070
|
});
|
|
1049
1071
|
}
|
|
1050
1072
|
|
|
1073
|
+
// @__NO_SIDE_EFFECTS__
|
|
1051
1074
|
function useArraySome(list, fn) {
|
|
1052
1075
|
return computed(() => toValue$1(list).some((element, index, array) => fn(toValue$1(element), index, array)));
|
|
1053
1076
|
}
|
|
@@ -1062,6 +1085,7 @@ function uniqueElementsBy(array, fn) {
|
|
|
1062
1085
|
return acc;
|
|
1063
1086
|
}, []);
|
|
1064
1087
|
}
|
|
1088
|
+
// @__NO_SIDE_EFFECTS__
|
|
1065
1089
|
function useArrayUnique(list, compareFn) {
|
|
1066
1090
|
return computed(() => {
|
|
1067
1091
|
const resolvedList = toValue$1(list).map((element) => toValue$1(element));
|
|
@@ -1175,6 +1199,7 @@ function normalizeDate(date) {
|
|
|
1175
1199
|
}
|
|
1176
1200
|
return new Date(date);
|
|
1177
1201
|
}
|
|
1202
|
+
// @__NO_SIDE_EFFECTS__
|
|
1178
1203
|
function useDateFormat(date, formatStr = "HH:mm:ss", options = {}) {
|
|
1179
1204
|
return computed(() => formatDate(normalizeDate(toValue$1(date)), toValue$1(formatStr), options));
|
|
1180
1205
|
}
|
|
@@ -1327,6 +1352,7 @@ function useTimeout(interval = 1e3, options = {}) {
|
|
|
1327
1352
|
}
|
|
1328
1353
|
}
|
|
1329
1354
|
|
|
1355
|
+
// @__NO_SIDE_EFFECTS__
|
|
1330
1356
|
function useToNumber(value, options = {}) {
|
|
1331
1357
|
const {
|
|
1332
1358
|
method = "parseFloat",
|
|
@@ -1345,10 +1371,12 @@ function useToNumber(value, options = {}) {
|
|
|
1345
1371
|
});
|
|
1346
1372
|
}
|
|
1347
1373
|
|
|
1374
|
+
// @__NO_SIDE_EFFECTS__
|
|
1348
1375
|
function useToString(value) {
|
|
1349
1376
|
return computed(() => `${toValue$1(value)}`);
|
|
1350
1377
|
}
|
|
1351
1378
|
|
|
1379
|
+
// @__NO_SIDE_EFFECTS__
|
|
1352
1380
|
function useToggle(initialValue = false, options = {}) {
|
|
1353
1381
|
const {
|
|
1354
1382
|
truthyValue = true,
|