@vueuse/shared 10.7.2 → 10.8.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 CHANGED
@@ -118,7 +118,7 @@ const injectLocal = (...args) => {
118
118
  };
119
119
 
120
120
  function createInjectionState(composable, options) {
121
- const key = (options == null ? void 0 : options.injectionKey) || Symbol("InjectionState");
121
+ const key = (options == null ? void 0 : options.injectionKey) || Symbol(composable.name || "InjectionState");
122
122
  const useProvidingState = (...args) => {
123
123
  const state = composable(...args);
124
124
  provideLocal(key, state);
@@ -365,12 +365,20 @@ function debounceFilter(ms, options = {}) {
365
365
  };
366
366
  return filter;
367
367
  }
368
- function throttleFilter(ms, trailing = true, leading = true, rejectOnCancel = false) {
368
+ function throttleFilter(...args) {
369
369
  let lastExec = 0;
370
370
  let timer;
371
371
  let isLeading = true;
372
372
  let lastRejector = noop;
373
373
  let lastValue;
374
+ let ms;
375
+ let trailing;
376
+ let leading;
377
+ let rejectOnCancel;
378
+ if (!vueDemi.isRef(args[0]) && typeof args[0] === "object")
379
+ ({ delay: ms, trailing = true, leading = true, rejectOnCancel = false } = args[0]);
380
+ else
381
+ [ms, trailing = true, leading = true, rejectOnCancel = false] = args;
374
382
  const clear = () => {
375
383
  if (timer) {
376
384
  clearTimeout(timer);
@@ -1048,8 +1056,8 @@ function useCounter(initialValue = 0, options = {}) {
1048
1056
  max = Number.POSITIVE_INFINITY,
1049
1057
  min = Number.NEGATIVE_INFINITY
1050
1058
  } = options;
1051
- const inc = (delta = 1) => count.value = Math.min(max, count.value + delta);
1052
- const dec = (delta = 1) => count.value = Math.max(min, count.value - delta);
1059
+ const inc = (delta = 1) => count.value = Math.max(Math.min(max, count.value + delta), min);
1060
+ const dec = (delta = 1) => count.value = Math.min(Math.max(min, count.value - delta), max);
1053
1061
  const get = () => count.value;
1054
1062
  const set = (val) => count.value = Math.max(min, Math.min(max, val));
1055
1063
  const reset = (val = _initialValue) => {
package/index.d.cts CHANGED
@@ -17,7 +17,7 @@ interface ComputedWithControlRefExtra {
17
17
  /**
18
18
  * Force update the computed value.
19
19
  */
20
- trigger(): void;
20
+ trigger: () => void;
21
21
  }
22
22
  interface ComputedRefWithControl<T> extends ComputedRef<T>, ComputedWithControlRefExtra {
23
23
  }
@@ -85,7 +85,7 @@ type ArgumentsType<T> = T extends (...args: infer U) => any ? U : never;
85
85
  * Compatible with versions below TypeScript 4.5 Awaited
86
86
  */
87
87
  type Awaited<T> = T extends null | undefined ? T : T extends object & {
88
- then(onfulfilled: infer F, ...args: infer _): any;
88
+ then: (onfulfilled: infer F, ...args: infer _) => any;
89
89
  } ? F extends ((value: infer V, ...args: infer _) => any) ? Awaited<V> : never : T;
90
90
  type Promisify<T> = Promise<Awaited<T>>;
91
91
  type PromisifyFn<T extends AnyFn> = (...args: ArgumentsType<T>) => Promisify<ReturnType<T>>;
@@ -226,6 +226,24 @@ declare const bypassFilter: EventFilter;
226
226
  * Create an EventFilter that debounce the events
227
227
  */
228
228
  declare function debounceFilter(ms: MaybeRefOrGetter<number>, options?: DebounceFilterOptions): EventFilter<any[], any, AnyFn>;
229
+ interface ThrottleFilterOptions {
230
+ /**
231
+ * The maximum time allowed to be delayed before it's invoked.
232
+ */
233
+ delay: MaybeRefOrGetter<number>;
234
+ /**
235
+ * Whether to invoke on the trailing edge of the timeout.
236
+ */
237
+ trailing?: boolean;
238
+ /**
239
+ * Whether to invoke on the leading edge of the timeout.
240
+ */
241
+ leading?: boolean;
242
+ /**
243
+ * Whether to reject the last call if it's been cancel.
244
+ */
245
+ rejectOnCancel?: boolean;
246
+ }
229
247
  /**
230
248
  * Create an EventFilter that throttle the events
231
249
  *
@@ -234,7 +252,8 @@ declare function debounceFilter(ms: MaybeRefOrGetter<number>, options?: Debounce
234
252
  * @param [leading]
235
253
  * @param [rejectOnCancel]
236
254
  */
237
- declare function throttleFilter(ms: MaybeRefOrGetter<number>, trailing?: boolean, leading?: boolean, rejectOnCancel?: boolean): EventFilter<any[], any, AnyFn>;
255
+ declare function throttleFilter(ms: MaybeRefOrGetter<number>, trailing?: boolean, leading?: boolean, rejectOnCancel?: boolean): EventFilter;
256
+ declare function throttleFilter(options: ThrottleFilterOptions): EventFilter;
238
257
  /**
239
258
  * EventFilter that gives extra controls to pause and resume the filter
240
259
  *
@@ -713,23 +732,22 @@ interface UntilToMatchOptions {
713
732
  deep?: WatchOptions['deep'];
714
733
  }
715
734
  interface UntilBaseInstance<T, Not extends boolean = false> {
716
- toMatch<U extends T = T>(condition: (v: T) => v is U, options?: UntilToMatchOptions): Not extends true ? Promise<Exclude<T, U>> : Promise<U>;
717
- toMatch(condition: (v: T) => boolean, options?: UntilToMatchOptions): Promise<T>;
718
- changed(options?: UntilToMatchOptions): Promise<T>;
719
- changedTimes(n?: number, options?: UntilToMatchOptions): Promise<T>;
735
+ toMatch: (<U extends T = T>(condition: (v: T) => v is U, options?: UntilToMatchOptions) => Not extends true ? Promise<Exclude<T, U>> : Promise<U>) & ((condition: (v: T) => boolean, options?: UntilToMatchOptions) => Promise<T>);
736
+ changed: (options?: UntilToMatchOptions) => Promise<T>;
737
+ changedTimes: (n?: number, options?: UntilToMatchOptions) => Promise<T>;
720
738
  }
721
739
  type Falsy = false | void | null | undefined | 0 | 0n | '';
722
740
  interface UntilValueInstance<T, Not extends boolean = false> extends UntilBaseInstance<T, Not> {
723
741
  readonly not: UntilValueInstance<T, Not extends true ? false : true>;
724
- toBe<P = T>(value: MaybeRefOrGetter<P>, options?: UntilToMatchOptions): Not extends true ? Promise<T> : Promise<P>;
725
- toBeTruthy(options?: UntilToMatchOptions): Not extends true ? Promise<T & Falsy> : Promise<Exclude<T, Falsy>>;
726
- toBeNull(options?: UntilToMatchOptions): Not extends true ? Promise<Exclude<T, null>> : Promise<null>;
727
- toBeUndefined(options?: UntilToMatchOptions): Not extends true ? Promise<Exclude<T, undefined>> : Promise<undefined>;
728
- toBeNaN(options?: UntilToMatchOptions): Promise<T>;
742
+ toBe: <P = T>(value: MaybeRefOrGetter<P>, options?: UntilToMatchOptions) => Not extends true ? Promise<T> : Promise<P>;
743
+ toBeTruthy: (options?: UntilToMatchOptions) => Not extends true ? Promise<T & Falsy> : Promise<Exclude<T, Falsy>>;
744
+ toBeNull: (options?: UntilToMatchOptions) => Not extends true ? Promise<Exclude<T, null>> : Promise<null>;
745
+ toBeUndefined: (options?: UntilToMatchOptions) => Not extends true ? Promise<Exclude<T, undefined>> : Promise<undefined>;
746
+ toBeNaN: (options?: UntilToMatchOptions) => Promise<T>;
729
747
  }
730
748
  interface UntilArrayInstance<T> extends UntilBaseInstance<T> {
731
749
  readonly not: UntilArrayInstance<T>;
732
- toContains(value: MaybeRefOrGetter<ElementOf<ShallowUnwrapRef<T>>>, options?: UntilToMatchOptions): Promise<T>;
750
+ toContains: (value: MaybeRefOrGetter<ElementOf<ShallowUnwrapRef<T>>>, options?: UntilToMatchOptions) => Promise<T>;
733
751
  }
734
752
  /**
735
753
  * Promised one-time watch for changes
@@ -1193,4 +1211,4 @@ declare function watchTriggerable<T extends object, FnReturnT>(source: T, cb: Wa
1193
1211
  */
1194
1212
  declare function whenever<T>(source: WatchSource<T | false | null | undefined>, cb: WatchCallback<T>, options?: WatchOptions): vue_demi.WatchStopHandle;
1195
1213
 
1196
- 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 IfAny, type IgnoredUpdater, type IsAny, 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, getLifeCycleTarget, hasOwn, hyphenate, identity, watchIgnorable as ignorableWatch, increaseWithUnit, injectLocal, invoke, isClient, isDef, isDefined, isIOS, isObject, isWorker, 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 };
1214
+ 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 IfAny, type IgnoredUpdater, type IsAny, 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 ThrottleFilterOptions, 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, getLifeCycleTarget, hasOwn, hyphenate, identity, watchIgnorable as ignorableWatch, increaseWithUnit, injectLocal, invoke, isClient, isDef, isDefined, isIOS, isObject, isWorker, 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 };
package/index.d.mts CHANGED
@@ -17,7 +17,7 @@ interface ComputedWithControlRefExtra {
17
17
  /**
18
18
  * Force update the computed value.
19
19
  */
20
- trigger(): void;
20
+ trigger: () => void;
21
21
  }
22
22
  interface ComputedRefWithControl<T> extends ComputedRef<T>, ComputedWithControlRefExtra {
23
23
  }
@@ -85,7 +85,7 @@ type ArgumentsType<T> = T extends (...args: infer U) => any ? U : never;
85
85
  * Compatible with versions below TypeScript 4.5 Awaited
86
86
  */
87
87
  type Awaited<T> = T extends null | undefined ? T : T extends object & {
88
- then(onfulfilled: infer F, ...args: infer _): any;
88
+ then: (onfulfilled: infer F, ...args: infer _) => any;
89
89
  } ? F extends ((value: infer V, ...args: infer _) => any) ? Awaited<V> : never : T;
90
90
  type Promisify<T> = Promise<Awaited<T>>;
91
91
  type PromisifyFn<T extends AnyFn> = (...args: ArgumentsType<T>) => Promisify<ReturnType<T>>;
@@ -226,6 +226,24 @@ declare const bypassFilter: EventFilter;
226
226
  * Create an EventFilter that debounce the events
227
227
  */
228
228
  declare function debounceFilter(ms: MaybeRefOrGetter<number>, options?: DebounceFilterOptions): EventFilter<any[], any, AnyFn>;
229
+ interface ThrottleFilterOptions {
230
+ /**
231
+ * The maximum time allowed to be delayed before it's invoked.
232
+ */
233
+ delay: MaybeRefOrGetter<number>;
234
+ /**
235
+ * Whether to invoke on the trailing edge of the timeout.
236
+ */
237
+ trailing?: boolean;
238
+ /**
239
+ * Whether to invoke on the leading edge of the timeout.
240
+ */
241
+ leading?: boolean;
242
+ /**
243
+ * Whether to reject the last call if it's been cancel.
244
+ */
245
+ rejectOnCancel?: boolean;
246
+ }
229
247
  /**
230
248
  * Create an EventFilter that throttle the events
231
249
  *
@@ -234,7 +252,8 @@ declare function debounceFilter(ms: MaybeRefOrGetter<number>, options?: Debounce
234
252
  * @param [leading]
235
253
  * @param [rejectOnCancel]
236
254
  */
237
- declare function throttleFilter(ms: MaybeRefOrGetter<number>, trailing?: boolean, leading?: boolean, rejectOnCancel?: boolean): EventFilter<any[], any, AnyFn>;
255
+ declare function throttleFilter(ms: MaybeRefOrGetter<number>, trailing?: boolean, leading?: boolean, rejectOnCancel?: boolean): EventFilter;
256
+ declare function throttleFilter(options: ThrottleFilterOptions): EventFilter;
238
257
  /**
239
258
  * EventFilter that gives extra controls to pause and resume the filter
240
259
  *
@@ -713,23 +732,22 @@ interface UntilToMatchOptions {
713
732
  deep?: WatchOptions['deep'];
714
733
  }
715
734
  interface UntilBaseInstance<T, Not extends boolean = false> {
716
- toMatch<U extends T = T>(condition: (v: T) => v is U, options?: UntilToMatchOptions): Not extends true ? Promise<Exclude<T, U>> : Promise<U>;
717
- toMatch(condition: (v: T) => boolean, options?: UntilToMatchOptions): Promise<T>;
718
- changed(options?: UntilToMatchOptions): Promise<T>;
719
- changedTimes(n?: number, options?: UntilToMatchOptions): Promise<T>;
735
+ toMatch: (<U extends T = T>(condition: (v: T) => v is U, options?: UntilToMatchOptions) => Not extends true ? Promise<Exclude<T, U>> : Promise<U>) & ((condition: (v: T) => boolean, options?: UntilToMatchOptions) => Promise<T>);
736
+ changed: (options?: UntilToMatchOptions) => Promise<T>;
737
+ changedTimes: (n?: number, options?: UntilToMatchOptions) => Promise<T>;
720
738
  }
721
739
  type Falsy = false | void | null | undefined | 0 | 0n | '';
722
740
  interface UntilValueInstance<T, Not extends boolean = false> extends UntilBaseInstance<T, Not> {
723
741
  readonly not: UntilValueInstance<T, Not extends true ? false : true>;
724
- toBe<P = T>(value: MaybeRefOrGetter<P>, options?: UntilToMatchOptions): Not extends true ? Promise<T> : Promise<P>;
725
- toBeTruthy(options?: UntilToMatchOptions): Not extends true ? Promise<T & Falsy> : Promise<Exclude<T, Falsy>>;
726
- toBeNull(options?: UntilToMatchOptions): Not extends true ? Promise<Exclude<T, null>> : Promise<null>;
727
- toBeUndefined(options?: UntilToMatchOptions): Not extends true ? Promise<Exclude<T, undefined>> : Promise<undefined>;
728
- toBeNaN(options?: UntilToMatchOptions): Promise<T>;
742
+ toBe: <P = T>(value: MaybeRefOrGetter<P>, options?: UntilToMatchOptions) => Not extends true ? Promise<T> : Promise<P>;
743
+ toBeTruthy: (options?: UntilToMatchOptions) => Not extends true ? Promise<T & Falsy> : Promise<Exclude<T, Falsy>>;
744
+ toBeNull: (options?: UntilToMatchOptions) => Not extends true ? Promise<Exclude<T, null>> : Promise<null>;
745
+ toBeUndefined: (options?: UntilToMatchOptions) => Not extends true ? Promise<Exclude<T, undefined>> : Promise<undefined>;
746
+ toBeNaN: (options?: UntilToMatchOptions) => Promise<T>;
729
747
  }
730
748
  interface UntilArrayInstance<T> extends UntilBaseInstance<T> {
731
749
  readonly not: UntilArrayInstance<T>;
732
- toContains(value: MaybeRefOrGetter<ElementOf<ShallowUnwrapRef<T>>>, options?: UntilToMatchOptions): Promise<T>;
750
+ toContains: (value: MaybeRefOrGetter<ElementOf<ShallowUnwrapRef<T>>>, options?: UntilToMatchOptions) => Promise<T>;
733
751
  }
734
752
  /**
735
753
  * Promised one-time watch for changes
@@ -1193,4 +1211,4 @@ declare function watchTriggerable<T extends object, FnReturnT>(source: T, cb: Wa
1193
1211
  */
1194
1212
  declare function whenever<T>(source: WatchSource<T | false | null | undefined>, cb: WatchCallback<T>, options?: WatchOptions): vue_demi.WatchStopHandle;
1195
1213
 
1196
- 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 IfAny, type IgnoredUpdater, type IsAny, 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, getLifeCycleTarget, hasOwn, hyphenate, identity, watchIgnorable as ignorableWatch, increaseWithUnit, injectLocal, invoke, isClient, isDef, isDefined, isIOS, isObject, isWorker, 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 };
1214
+ 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 IfAny, type IgnoredUpdater, type IsAny, 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 ThrottleFilterOptions, 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, getLifeCycleTarget, hasOwn, hyphenate, identity, watchIgnorable as ignorableWatch, increaseWithUnit, injectLocal, invoke, isClient, isDef, isDefined, isIOS, isObject, isWorker, 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 };
package/index.d.ts CHANGED
@@ -17,7 +17,7 @@ interface ComputedWithControlRefExtra {
17
17
  /**
18
18
  * Force update the computed value.
19
19
  */
20
- trigger(): void;
20
+ trigger: () => void;
21
21
  }
22
22
  interface ComputedRefWithControl<T> extends ComputedRef<T>, ComputedWithControlRefExtra {
23
23
  }
@@ -85,7 +85,7 @@ type ArgumentsType<T> = T extends (...args: infer U) => any ? U : never;
85
85
  * Compatible with versions below TypeScript 4.5 Awaited
86
86
  */
87
87
  type Awaited<T> = T extends null | undefined ? T : T extends object & {
88
- then(onfulfilled: infer F, ...args: infer _): any;
88
+ then: (onfulfilled: infer F, ...args: infer _) => any;
89
89
  } ? F extends ((value: infer V, ...args: infer _) => any) ? Awaited<V> : never : T;
90
90
  type Promisify<T> = Promise<Awaited<T>>;
91
91
  type PromisifyFn<T extends AnyFn> = (...args: ArgumentsType<T>) => Promisify<ReturnType<T>>;
@@ -226,6 +226,24 @@ declare const bypassFilter: EventFilter;
226
226
  * Create an EventFilter that debounce the events
227
227
  */
228
228
  declare function debounceFilter(ms: MaybeRefOrGetter<number>, options?: DebounceFilterOptions): EventFilter<any[], any, AnyFn>;
229
+ interface ThrottleFilterOptions {
230
+ /**
231
+ * The maximum time allowed to be delayed before it's invoked.
232
+ */
233
+ delay: MaybeRefOrGetter<number>;
234
+ /**
235
+ * Whether to invoke on the trailing edge of the timeout.
236
+ */
237
+ trailing?: boolean;
238
+ /**
239
+ * Whether to invoke on the leading edge of the timeout.
240
+ */
241
+ leading?: boolean;
242
+ /**
243
+ * Whether to reject the last call if it's been cancel.
244
+ */
245
+ rejectOnCancel?: boolean;
246
+ }
229
247
  /**
230
248
  * Create an EventFilter that throttle the events
231
249
  *
@@ -234,7 +252,8 @@ declare function debounceFilter(ms: MaybeRefOrGetter<number>, options?: Debounce
234
252
  * @param [leading]
235
253
  * @param [rejectOnCancel]
236
254
  */
237
- declare function throttleFilter(ms: MaybeRefOrGetter<number>, trailing?: boolean, leading?: boolean, rejectOnCancel?: boolean): EventFilter<any[], any, AnyFn>;
255
+ declare function throttleFilter(ms: MaybeRefOrGetter<number>, trailing?: boolean, leading?: boolean, rejectOnCancel?: boolean): EventFilter;
256
+ declare function throttleFilter(options: ThrottleFilterOptions): EventFilter;
238
257
  /**
239
258
  * EventFilter that gives extra controls to pause and resume the filter
240
259
  *
@@ -713,23 +732,22 @@ interface UntilToMatchOptions {
713
732
  deep?: WatchOptions['deep'];
714
733
  }
715
734
  interface UntilBaseInstance<T, Not extends boolean = false> {
716
- toMatch<U extends T = T>(condition: (v: T) => v is U, options?: UntilToMatchOptions): Not extends true ? Promise<Exclude<T, U>> : Promise<U>;
717
- toMatch(condition: (v: T) => boolean, options?: UntilToMatchOptions): Promise<T>;
718
- changed(options?: UntilToMatchOptions): Promise<T>;
719
- changedTimes(n?: number, options?: UntilToMatchOptions): Promise<T>;
735
+ toMatch: (<U extends T = T>(condition: (v: T) => v is U, options?: UntilToMatchOptions) => Not extends true ? Promise<Exclude<T, U>> : Promise<U>) & ((condition: (v: T) => boolean, options?: UntilToMatchOptions) => Promise<T>);
736
+ changed: (options?: UntilToMatchOptions) => Promise<T>;
737
+ changedTimes: (n?: number, options?: UntilToMatchOptions) => Promise<T>;
720
738
  }
721
739
  type Falsy = false | void | null | undefined | 0 | 0n | '';
722
740
  interface UntilValueInstance<T, Not extends boolean = false> extends UntilBaseInstance<T, Not> {
723
741
  readonly not: UntilValueInstance<T, Not extends true ? false : true>;
724
- toBe<P = T>(value: MaybeRefOrGetter<P>, options?: UntilToMatchOptions): Not extends true ? Promise<T> : Promise<P>;
725
- toBeTruthy(options?: UntilToMatchOptions): Not extends true ? Promise<T & Falsy> : Promise<Exclude<T, Falsy>>;
726
- toBeNull(options?: UntilToMatchOptions): Not extends true ? Promise<Exclude<T, null>> : Promise<null>;
727
- toBeUndefined(options?: UntilToMatchOptions): Not extends true ? Promise<Exclude<T, undefined>> : Promise<undefined>;
728
- toBeNaN(options?: UntilToMatchOptions): Promise<T>;
742
+ toBe: <P = T>(value: MaybeRefOrGetter<P>, options?: UntilToMatchOptions) => Not extends true ? Promise<T> : Promise<P>;
743
+ toBeTruthy: (options?: UntilToMatchOptions) => Not extends true ? Promise<T & Falsy> : Promise<Exclude<T, Falsy>>;
744
+ toBeNull: (options?: UntilToMatchOptions) => Not extends true ? Promise<Exclude<T, null>> : Promise<null>;
745
+ toBeUndefined: (options?: UntilToMatchOptions) => Not extends true ? Promise<Exclude<T, undefined>> : Promise<undefined>;
746
+ toBeNaN: (options?: UntilToMatchOptions) => Promise<T>;
729
747
  }
730
748
  interface UntilArrayInstance<T> extends UntilBaseInstance<T> {
731
749
  readonly not: UntilArrayInstance<T>;
732
- toContains(value: MaybeRefOrGetter<ElementOf<ShallowUnwrapRef<T>>>, options?: UntilToMatchOptions): Promise<T>;
750
+ toContains: (value: MaybeRefOrGetter<ElementOf<ShallowUnwrapRef<T>>>, options?: UntilToMatchOptions) => Promise<T>;
733
751
  }
734
752
  /**
735
753
  * Promised one-time watch for changes
@@ -1193,4 +1211,4 @@ declare function watchTriggerable<T extends object, FnReturnT>(source: T, cb: Wa
1193
1211
  */
1194
1212
  declare function whenever<T>(source: WatchSource<T | false | null | undefined>, cb: WatchCallback<T>, options?: WatchOptions): vue_demi.WatchStopHandle;
1195
1213
 
1196
- 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 IfAny, type IgnoredUpdater, type IsAny, 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, getLifeCycleTarget, hasOwn, hyphenate, identity, watchIgnorable as ignorableWatch, increaseWithUnit, injectLocal, invoke, isClient, isDef, isDefined, isIOS, isObject, isWorker, 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 };
1214
+ 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 IfAny, type IgnoredUpdater, type IsAny, 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 ThrottleFilterOptions, 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, getLifeCycleTarget, hasOwn, hyphenate, identity, watchIgnorable as ignorableWatch, increaseWithUnit, injectLocal, invoke, isClient, isDef, isDefined, isIOS, isObject, isWorker, 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 };
package/index.iife.js CHANGED
@@ -19,7 +19,9 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
19
19
  VueDemi.Vue2 = Vue
20
20
  VueDemi.version = Vue.version
21
21
  VueDemi.warn = Vue.util.warn
22
- VueDemi.hasInjectionContext = () => !!VueDemi.getCurrentInstance()
22
+ VueDemi.hasInjectionContext = function() {
23
+ return !!VueDemi.getCurrentInstance()
24
+ }
23
25
  function createApp(rootComponent, rootProps) {
24
26
  var vm
25
27
  var provide = {}
@@ -72,7 +74,9 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
72
74
  VueDemi.Vue = Vue
73
75
  VueDemi.Vue2 = Vue
74
76
  VueDemi.version = Vue.version
75
- VueDemi.hasInjectionContext = () => !!VueDemi.getCurrentInstance()
77
+ VueDemi.hasInjectionContext = function() {
78
+ return !!VueDemi.getCurrentInstance()
79
+ }
76
80
  } else {
77
81
  console.error('[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.')
78
82
  }
@@ -233,7 +237,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
233
237
  };
234
238
 
235
239
  function createInjectionState(composable, options) {
236
- const key = (options == null ? void 0 : options.injectionKey) || Symbol("InjectionState");
240
+ const key = (options == null ? void 0 : options.injectionKey) || Symbol(composable.name || "InjectionState");
237
241
  const useProvidingState = (...args) => {
238
242
  const state = composable(...args);
239
243
  provideLocal(key, state);
@@ -480,12 +484,20 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
480
484
  };
481
485
  return filter;
482
486
  }
483
- function throttleFilter(ms, trailing = true, leading = true, rejectOnCancel = false) {
487
+ function throttleFilter(...args) {
484
488
  let lastExec = 0;
485
489
  let timer;
486
490
  let isLeading = true;
487
491
  let lastRejector = noop;
488
492
  let lastValue;
493
+ let ms;
494
+ let trailing;
495
+ let leading;
496
+ let rejectOnCancel;
497
+ if (!vueDemi.isRef(args[0]) && typeof args[0] === "object")
498
+ ({ delay: ms, trailing = true, leading = true, rejectOnCancel = false } = args[0]);
499
+ else
500
+ [ms, trailing = true, leading = true, rejectOnCancel = false] = args;
489
501
  const clear = () => {
490
502
  if (timer) {
491
503
  clearTimeout(timer);
@@ -1163,8 +1175,8 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
1163
1175
  max = Number.POSITIVE_INFINITY,
1164
1176
  min = Number.NEGATIVE_INFINITY
1165
1177
  } = options;
1166
- const inc = (delta = 1) => count.value = Math.min(max, count.value + delta);
1167
- const dec = (delta = 1) => count.value = Math.max(min, count.value - delta);
1178
+ const inc = (delta = 1) => count.value = Math.max(Math.min(max, count.value + delta), min);
1179
+ const dec = (delta = 1) => count.value = Math.min(Math.max(min, count.value - delta), max);
1168
1180
  const get = () => count.value;
1169
1181
  const set = (val) => count.value = Math.max(min, Math.min(max, val));
1170
1182
  const reset = (val = _initialValue) => {
package/index.iife.min.js CHANGED
@@ -1 +1 @@
1
- var VueDemi=function(c,u,E){if(c.install)return c;if(!u)return console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`."),c;if(u.version.slice(0,4)==="2.7."){let v=function(S,b){var T,_={},U={config:u.config,use:u.use.bind(u),mixin:u.mixin.bind(u),component:u.component.bind(u),provide:function(M,P){return _[M]=P,this},directive:function(M,P){return P?(u.directive(M,P),U):u.directive(M)},mount:function(M,P){return T||(T=new u(Object.assign({propsData:b},S,{provide:Object.assign(_,S.provide)})),T.$mount(M,P),T)},unmount:function(){T&&(T.$destroy(),T=void 0)}};return U};var I=v;for(var O in u)c[O]=u[O];c.isVue2=!0,c.isVue3=!1,c.install=function(){},c.Vue=u,c.Vue2=u,c.version=u.version,c.warn=u.util.warn,c.hasInjectionContext=()=>!!c.getCurrentInstance(),c.createApp=v}else if(u.version.slice(0,2)==="2.")if(E){for(var O in E)c[O]=E[O];c.isVue2=!0,c.isVue3=!1,c.install=function(){},c.Vue=u,c.Vue2=u,c.version=u.version,c.hasInjectionContext=()=>!!c.getCurrentInstance()}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if(u.version.slice(0,2)==="3."){for(var O in u)c[O]=u[O];c.isVue2=!1,c.isVue3=!0,c.install=function(){},c.Vue=u,c.Vue2=void 0,c.version=u.version,c.set=function(v,S,b){return Array.isArray(v)?(v.length=Math.max(v.length,S),v.splice(S,1,b),b):(v[S]=b,b)},c.del=function(v,S){if(Array.isArray(v)){v.splice(S,1);return}delete v[S]}}else console.error("[vue-demi] Vue version "+u.version+" is unsupported.");return c}(this.VueDemi=this.VueDemi||(typeof VueDemi<"u"?VueDemi:{}),this.Vue||(typeof Vue<"u"?Vue:void 0),this.VueCompositionAPI||(typeof VueCompositionAPI<"u"?VueCompositionAPI:void 0));(function(c,u){"use strict";function E(t,e){var n;const r=u.shallowRef();return u.watchEffect(()=>{r.value=t()},{...e,flush:(n=e?.flush)!=null?n:"sync"}),u.readonly(r)}function O(t,e){let n,r,o;const i=u.ref(!0),a=()=>{i.value=!0,o()};u.watch(t,a,{flush:"sync"});const l=typeof e=="function"?e:e.get,d=typeof e=="function"?void 0:e.set,w=u.customRef((y,h)=>(r=y,o=h,{get(){return i.value&&(n=l(),i.value=!1),r(),n},set(f){d?.(f)}}));return Object.isExtensible(w)&&(w.trigger=a),w}function I(t){return u.getCurrentScope()?(u.onScopeDispose(t),!0):!1}function v(){const t=new Set,e=o=>{t.delete(o)};return{on:o=>{t.add(o);const i=()=>e(o);return I(i),{off:i}},off:e,trigger:(...o)=>Promise.all(Array.from(t).map(i=>i(...o)))}}function S(t){let e=!1,n;const r=u.effectScope(!0);return(...o)=>(e||(n=r.run(()=>t(...o)),e=!0),n)}const b=new WeakMap,T=(t,e)=>{var n;const r=(n=u.getCurrentInstance())==null?void 0:n.proxy;if(r==null)throw new Error("provideLocal must be called in setup");b.has(r)||b.set(r,Object.create(null));const o=b.get(r);o[t]=e,u.provide(t,e)},_=(...t)=>{var e;const n=t[0],r=(e=u.getCurrentInstance())==null?void 0:e.proxy;if(r==null)throw new Error("injectLocal must be called in setup");return b.has(r)&&n in b.get(r)?b.get(r)[n]:u.inject(...t)};function U(t,e){const n=e?.injectionKey||Symbol("InjectionState");return[(...i)=>{const a=t(...i);return T(n,a),a},()=>_(n)]}function M(t){let e=0,n,r;const o=()=>{e-=1,r&&e<=0&&(r.stop(),n=void 0,r=void 0)};return(...i)=>(e+=1,n||(r=u.effectScope(!0),n=r.run(()=>t(...i))),I(o),n)}function P(t,e,{enumerable:n=!1,unwrap:r=!0}={}){if(!u.isVue3&&!u.version.startsWith("2.7.")){if(process.env.NODE_ENV!=="production")throw new Error("[VueUse] extendRef only works in Vue 2.7 or above.");return}for(const[o,i]of Object.entries(e))o!=="value"&&(u.isRef(i)&&r?Object.defineProperty(t,o,{get(){return i.value},set(a){i.value=a},enumerable:n}):Object.defineProperty(t,o,{value:i,enumerable:n}));return t}function gt(t,e){return e==null?u.unref(t):u.unref(t)[e]}function mt(t){return u.unref(t)!=null}function pt(t,e){if(typeof Symbol<"u"){const n={...t};return Object.defineProperty(n,Symbol.iterator,{enumerable:!1,value(){let r=0;return{next:()=>({value:e[r++],done:r>e.length})}}}),n}else return Object.assign([...e],t)}function s(t){return typeof t=="function"?t():u.unref(t)}const vt=s;function Y(t,e){const n=e?.computedGetter===!1?u.unref:s;return function(...r){return u.computed(()=>t.apply(this,r.map(o=>n(o))))}}function bt(t,e={}){let n=[],r;if(Array.isArray(e))n=e;else{r=e;const{includeOwnProperties:o=!0}=e;n.push(...Object.keys(t)),o&&n.push(...Object.getOwnPropertyNames(t))}return Object.fromEntries(n.map(o=>{const i=t[o];return[o,typeof i=="function"?Y(i.bind(t),r):i]}))}function D(t){if(!u.isRef(t))return u.reactive(t);const e=new Proxy({},{get(n,r,o){return u.unref(Reflect.get(t.value,r,o))},set(n,r,o){return u.isRef(t.value[r])&&!u.isRef(o)?t.value[r].value=o:t.value[r]=o,!0},deleteProperty(n,r){return Reflect.deleteProperty(t.value,r)},has(n,r){return Reflect.has(t.value,r)},ownKeys(){return Object.keys(t.value)},getOwnPropertyDescriptor(){return{enumerable:!0,configurable:!0}}});return u.reactive(e)}function G(t){return D(u.computed(t))}function At(t,...e){const n=e.flat(),r=n[0];return G(()=>Object.fromEntries(typeof r=="function"?Object.entries(u.toRefs(t)).filter(([o,i])=>!r(s(i),o)):Object.entries(u.toRefs(t)).filter(o=>!n.includes(o[0]))))}const j=typeof window<"u"&&typeof document<"u",Ot=typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope,St=t=>typeof t<"u",Tt=t=>t!=null,Pt=(t,...e)=>{t||console.warn(...e)},Ft=Object.prototype.toString,tt=t=>Ft.call(t)==="[object Object]",It=()=>Date.now(),et=()=>+Date.now(),Mt=(t,e,n)=>Math.min(n,Math.max(e,t)),C=()=>{},Ct=(t,e)=>(t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t+1))+t),Rt=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Et=kt();function kt(){var t,e;return j&&((t=window?.navigator)==null?void 0:t.userAgent)&&(/iP(ad|hone|od)/.test(window.navigator.userAgent)||((e=window?.navigator)==null?void 0:e.maxTouchPoints)>2&&/iPad|Macintosh/.test(window?.navigator.userAgent))}function N(t,e){function n(...r){return new Promise((o,i)=>{Promise.resolve(t(()=>e.apply(this,r),{fn:e,thisArg:this,args:r})).then(o).catch(i)})}return n}const B=t=>t();function z(t,e={}){let n,r,o=C;const i=l=>{clearTimeout(l),o(),o=C};return l=>{const d=s(t),w=s(e.maxWait);return n&&i(n),d<=0||w!==void 0&&w<=0?(r&&(i(r),r=null),Promise.resolve(l())):new Promise((y,h)=>{o=e.rejectOnCancel?h:y,w&&!r&&(r=setTimeout(()=>{n&&i(n),r=null,y(l())},w)),n=setTimeout(()=>{r&&i(r),r=null,y(l())},d)})}}function q(t,e=!0,n=!0,r=!1){let o=0,i,a=!0,l=C,d;const w=()=>{i&&(clearTimeout(i),i=void 0,l(),l=C)};return h=>{const f=s(t),g=Date.now()-o,m=()=>d=h();return w(),f<=0?(o=Date.now(),m()):(g>f&&(n||!a)?(o=Date.now(),m()):e&&(d=new Promise((A,p)=>{l=r?p:A,i=setTimeout(()=>{o=Date.now(),a=!0,A(m()),w()},Math.max(0,f-g))})),!n&&!i&&(i=setTimeout(()=>a=!0,f)),a=!1,d)}}function nt(t=B){const e=u.ref(!0);function n(){e.value=!1}function r(){e.value=!0}const o=(...i)=>{e.value&&t(...i)};return{isActive:u.readonly(e),pause:n,resume:r,eventFilter:o}}const _t={mounted:u.isVue3?"mounted":"inserted",updated:u.isVue3?"updated":"componentUpdated",unmounted:u.isVue3?"unmounted":"unbind"};function rt(t){const e=Object.create(null);return n=>e[n]||(e[n]=t(n))}const jt=/\B([A-Z])/g,Nt=rt(t=>t.replace(jt,"-$1").toLowerCase()),Lt=/-(\w)/g,Wt=rt(t=>t.replace(Lt,(e,n)=>n?n.toUpperCase():""));function Z(t,e=!1,n="Timeout"){return new Promise((r,o)=>{setTimeout(e?()=>o(n):r,t)})}function Ut(t){return t}function Bt(t){let e;function n(){return e||(e=t()),e}return n.reset=async()=>{const r=e;e=void 0,r&&await r},n}function $t(t){return t()}function ot(t,...e){return e.some(n=>n in t)}function Ht(t,e){var n;if(typeof t=="number")return t+e;const r=((n=t.match(/^-?[0-9]+\.?[0-9]*/))==null?void 0:n[0])||"",o=t.slice(r.length),i=Number.parseFloat(r)+e;return Number.isNaN(i)?t:i+o}function Yt(t,e,n=!1){return e.reduce((r,o)=>(o in t&&(!n||t[o]!==void 0)&&(r[o]=t[o]),r),{})}function Gt(t,e,n=!1){return Object.fromEntries(Object.entries(t).filter(([r,o])=>(!n||o!==void 0)&&!e.includes(r)))}function zt(t){return Object.entries(t)}function L(t){return t||u.getCurrentInstance()}function J(...t){if(t.length!==1)return u.toRef(...t);const e=t[0];return typeof e=="function"?u.readonly(u.customRef(()=>({get:e,set:C}))):u.ref(e)}const qt=J;function Zt(t,...e){const n=e.flat(),r=n[0];return G(()=>Object.fromEntries(typeof r=="function"?Object.entries(u.toRefs(t)).filter(([o,i])=>r(s(i),o)):n.map(o=>[o,J(t,o)])))}function ct(t,e=1e4){return u.customRef((n,r)=>{let o=s(t),i;const a=()=>setTimeout(()=>{o=s(t),r()},s(e));return I(()=>{clearTimeout(i)}),{get(){return n(),o},set(l){o=l,r(),clearTimeout(i),i=a()}}})}function ut(t,e=200,n={}){return N(z(e,n),t)}function X(t,e=200,n={}){const r=u.ref(t.value),o=ut(()=>{r.value=t.value},e,n);return u.watch(t,()=>o()),r}function Jt(t,e){return u.computed({get(){var n;return(n=t.value)!=null?n:e},set(n){t.value=n}})}function it(t,e=200,n=!1,r=!0,o=!1){return N(q(e,n,r,o),t)}function K(t,e=200,n=!0,r=!0){if(e<=0)return t;const o=u.ref(t.value),i=it(()=>{o.value=t.value},e,n,r);return u.watch(t,()=>i()),o}function at(t,e={}){let n=t,r,o;const i=u.customRef((f,g)=>(r=f,o=g,{get(){return a()},set(m){l(m)}}));function a(f=!0){return f&&r(),n}function l(f,g=!0){var m,A;if(f===n)return;const p=n;((m=e.onBeforeChange)==null?void 0:m.call(e,f,p))!==!1&&(n=f,(A=e.onChanged)==null||A.call(e,f,p),g&&o())}return P(i,{get:a,set:l,untrackedGet:()=>a(!1),silentSet:f=>l(f,!1),peek:()=>a(!1),lay:f=>l(f,!1)},{enumerable:!0})}const Xt=at;function Kt(...t){if(t.length===2){const[e,n]=t;e.value=n}if(t.length===3)if(u.isVue2)u.set(...t);else{const[e,n,r]=t;e[n]=r}}function W(t,e,n={}){const{eventFilter:r=B,...o}=n;return u.watch(t,N(r,e),o)}function $(t,e,n={}){const{eventFilter:r,...o}=n,{eventFilter:i,pause:a,resume:l,isActive:d}=nt(r);return{stop:W(t,e,{...o,eventFilter:i}),pause:a,resume:l,isActive:d}}function Qt(t,e,...[n]){const{flush:r="sync",deep:o=!1,immediate:i=!0,direction:a="both",transform:l={}}=n||{},d=[],w="ltr"in l&&l.ltr||(f=>f),y="rtl"in l&&l.rtl||(f=>f);return(a==="both"||a==="ltr")&&d.push($(t,f=>{d.forEach(g=>g.pause()),e.value=w(f),d.forEach(g=>g.resume())},{flush:r,deep:o,immediate:i})),(a==="both"||a==="rtl")&&d.push($(e,f=>{d.forEach(g=>g.pause()),t.value=y(f),d.forEach(g=>g.resume())},{flush:r,deep:o,immediate:i})),()=>{d.forEach(f=>f.stop())}}function Vt(t,e,n={}){const{flush:r="sync",deep:o=!1,immediate:i=!0}=n;return Array.isArray(e)||(e=[e]),u.watch(t,a=>e.forEach(l=>l.value=a),{flush:r,deep:o,immediate:i})}function xt(t,e={}){if(!u.isRef(t))return u.toRefs(t);const n=Array.isArray(t.value)?Array.from({length:t.value.length}):{};for(const r in t.value)n[r]=u.customRef(()=>({get(){return t.value[r]},set(o){var i;if((i=s(e.replaceRef))!=null?i:!0)if(Array.isArray(t.value)){const l=[...t.value];l[r]=o,t.value=l}else{const l={...t.value,[r]:o};Object.setPrototypeOf(l,Object.getPrototypeOf(t.value)),t.value=l}else t.value[r]=o}}));return n}function Dt(t,e=!0,n){L(n)?u.onBeforeMount(t,n):e?t():u.nextTick(t)}function te(t,e){L(e)&&u.onBeforeUnmount(t,e)}function ee(t,e=!0,n){L()?u.onMounted(t,n):e?t():u.nextTick(t)}function ne(t,e){L(e)&&u.onUnmounted(t,e)}function Q(t,e=!1){function n(h,{flush:f="sync",deep:g=!1,timeout:m,throwOnTimeout:A}={}){let p=null;const x=[new Promise(H=>{p=u.watch(t,k=>{h(k)!==e&&(p?.(),H(k))},{flush:f,deep:g,immediate:!0})})];return m!=null&&x.push(Z(m,A).then(()=>s(t)).finally(()=>p?.())),Promise.race(x)}function r(h,f){if(!u.isRef(h))return n(k=>k===h,f);const{flush:g="sync",deep:m=!1,timeout:A,throwOnTimeout:p}=f??{};let F=null;const H=[new Promise(k=>{F=u.watch([t,h],([wt,He])=>{e!==(wt===He)&&(F?.(),k(wt))},{flush:g,deep:m,immediate:!0})})];return A!=null&&H.push(Z(A,p).then(()=>s(t)).finally(()=>(F?.(),s(t)))),Promise.race(H)}function o(h){return n(f=>!!f,h)}function i(h){return r(null,h)}function a(h){return r(void 0,h)}function l(h){return n(Number.isNaN,h)}function d(h,f){return n(g=>{const m=Array.from(g);return m.includes(h)||m.includes(s(h))},f)}function w(h){return y(1,h)}function y(h=1,f){let g=-1;return n(()=>(g+=1,g>=h),f)}return Array.isArray(s(t))?{toMatch:n,toContains:d,changed:w,changedTimes:y,get not(){return Q(t,!e)}}:{toMatch:n,toBe:r,toBeTruthy:o,toBeNull:i,toBeNaN:l,toBeUndefined:a,changed:w,changedTimes:y,get not(){return Q(t,!e)}}}function re(t){return Q(t)}function oe(t,e){return t===e}function ce(...t){var e;const n=t[0],r=t[1];let o=(e=t[2])!=null?e:oe;if(typeof o=="string"){const i=o;o=(a,l)=>a[i]===l[i]}return u.computed(()=>s(n).filter(i=>s(r).findIndex(a=>o(i,a))===-1))}function ue(t,e){return u.computed(()=>s(t).every((n,r,o)=>e(s(n),r,o)))}function ie(t,e){return u.computed(()=>s(t).map(n=>s(n)).filter(e))}function ae(t,e){return u.computed(()=>s(s(t).find((n,r,o)=>e(s(n),r,o))))}function le(t,e){return u.computed(()=>s(t).findIndex((n,r,o)=>e(s(n),r,o)))}function se(t,e){let n=t.length;for(;n-- >0;)if(e(t[n],n,t))return t[n]}function fe(t,e){return u.computed(()=>s(Array.prototype.findLast?s(t).findLast((n,r,o)=>e(s(n),r,o)):se(s(t),(n,r,o)=>e(s(n),r,o))))}function de(t){return tt(t)&&ot(t,"formIndex","comparator")}function he(...t){var e;const n=t[0],r=t[1];let o=t[2],i=0;if(de(o)&&(i=(e=o.fromIndex)!=null?e:0,o=o.comparator),typeof o=="string"){const a=o;o=(l,d)=>l[a]===s(d)}return o=o??((a,l)=>a===s(l)),u.computed(()=>s(n).slice(i).some((a,l,d)=>o(s(a),s(r),l,s(d))))}function ye(t,e){return u.computed(()=>s(t).map(n=>s(n)).join(s(e)))}function we(t,e){return u.computed(()=>s(t).map(n=>s(n)).map(e))}function ge(t,e,...n){const r=(o,i,a)=>e(s(o),s(i),a);return u.computed(()=>{const o=s(t);return n.length?o.reduce(r,s(n[0])):o.reduce(r)})}function me(t,e){return u.computed(()=>s(t).some((n,r,o)=>e(s(n),r,o)))}function pe(t){return Array.from(new Set(t))}function ve(t,e){return t.reduce((n,r)=>(n.some(o=>e(r,o,t))||n.push(r),n),[])}function be(t,e){return u.computed(()=>{const n=s(t).map(r=>s(r));return e?ve(n,e):pe(n)})}function Ae(t=0,e={}){let n=u.unref(t);const r=u.ref(t),{max:o=Number.POSITIVE_INFINITY,min:i=Number.NEGATIVE_INFINITY}=e,a=(h=1)=>r.value=Math.min(o,r.value+h),l=(h=1)=>r.value=Math.max(i,r.value-h),d=()=>r.value,w=h=>r.value=Math.max(i,Math.min(o,h));return{count:r,inc:a,dec:l,get:d,set:w,reset:(h=n)=>(n=h,w(h))}}const Oe=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,Se=/[YMDHhms]o|\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a{1,2}|A{1,2}|m{1,2}|s{1,2}|Z{1,2}|SSS/g;function Te(t,e,n,r){let o=t<12?"AM":"PM";return r&&(o=o.split("").reduce((i,a)=>i+=`${a}.`,"")),n?o.toLowerCase():o}function R(t){const e=["th","st","nd","rd"],n=t%100;return t+(e[(n-20)%10]||e[n]||e[0])}function lt(t,e,n={}){var r;const o=t.getFullYear(),i=t.getMonth(),a=t.getDate(),l=t.getHours(),d=t.getMinutes(),w=t.getSeconds(),y=t.getMilliseconds(),h=t.getDay(),f=(r=n.customMeridiem)!=null?r:Te,g={Yo:()=>R(o),YY:()=>String(o).slice(-2),YYYY:()=>o,M:()=>i+1,Mo:()=>R(i+1),MM:()=>`${i+1}`.padStart(2,"0"),MMM:()=>t.toLocaleDateString(n.locales,{month:"short"}),MMMM:()=>t.toLocaleDateString(n.locales,{month:"long"}),D:()=>String(a),Do:()=>R(a),DD:()=>`${a}`.padStart(2,"0"),H:()=>String(l),Ho:()=>R(l),HH:()=>`${l}`.padStart(2,"0"),h:()=>`${l%12||12}`.padStart(1,"0"),ho:()=>R(l%12||12),hh:()=>`${l%12||12}`.padStart(2,"0"),m:()=>String(d),mo:()=>R(d),mm:()=>`${d}`.padStart(2,"0"),s:()=>String(w),so:()=>R(w),ss:()=>`${w}`.padStart(2,"0"),SSS:()=>`${y}`.padStart(3,"0"),d:()=>h,dd:()=>t.toLocaleDateString(n.locales,{weekday:"narrow"}),ddd:()=>t.toLocaleDateString(n.locales,{weekday:"short"}),dddd:()=>t.toLocaleDateString(n.locales,{weekday:"long"}),A:()=>f(l,d),AA:()=>f(l,d,!1,!0),a:()=>f(l,d,!0),aa:()=>f(l,d,!0,!0)};return e.replace(Se,(m,A)=>{var p,F;return(F=A??((p=g[m])==null?void 0:p.call(g)))!=null?F:m})}function st(t){if(t===null)return new Date(Number.NaN);if(t===void 0)return new Date;if(t instanceof Date)return new Date(t);if(typeof t=="string"&&!/Z$/i.test(t)){const e=t.match(Oe);if(e){const n=e[2]-1||0,r=(e[7]||"0").substring(0,3);return new Date(e[1],n,e[3]||1,e[4]||0,e[5]||0,e[6]||0,r)}}return new Date(t)}function Pe(t,e="HH:mm:ss",n={}){return u.computed(()=>lt(st(s(t)),s(e),n))}function ft(t,e=1e3,n={}){const{immediate:r=!0,immediateCallback:o=!1}=n;let i=null;const a=u.ref(!1);function l(){i&&(clearInterval(i),i=null)}function d(){a.value=!1,l()}function w(){const y=s(e);y<=0||(a.value=!0,o&&t(),l(),i=setInterval(t,y))}if(r&&j&&w(),u.isRef(e)||typeof e=="function"){const y=u.watch(e,()=>{a.value&&j&&w()});I(y)}return I(d),{isActive:a,pause:d,resume:w}}function Fe(t=1e3,e={}){const{controls:n=!1,immediate:r=!0,callback:o}=e,i=u.ref(0),a=()=>i.value+=1,l=()=>{i.value=0},d=ft(o?()=>{a(),o(i.value)}:a,t,{immediate:r});return n?{counter:i,reset:l,...d}:i}function Ie(t,e={}){var n;const r=u.ref((n=e.initialValue)!=null?n:null);return u.watch(t,()=>r.value=et(),e),r}function dt(t,e,n={}){const{immediate:r=!0}=n,o=u.ref(!1);let i=null;function a(){i&&(clearTimeout(i),i=null)}function l(){o.value=!1,a()}function d(...w){a(),o.value=!0,i=setTimeout(()=>{o.value=!1,i=null,t(...w)},s(e))}return r&&(o.value=!0,j&&d()),I(l),{isPending:u.readonly(o),start:d,stop:l}}function Me(t=1e3,e={}){const{controls:n=!1,callback:r}=e,o=dt(r??C,t,e),i=u.computed(()=>!o.isPending.value);return n?{ready:i,...o}:i}function Ce(t,e={}){const{method:n="parseFloat",radix:r,nanToZero:o}=e;return u.computed(()=>{let i=s(t);return typeof i=="string"&&(i=Number[n](i,r)),o&&Number.isNaN(i)&&(i=0),i})}function Re(t){return u.computed(()=>`${s(t)}`)}function Ee(t=!1,e={}){const{truthyValue:n=!0,falsyValue:r=!1}=e,o=u.isRef(t),i=u.ref(t);function a(l){if(arguments.length)return i.value=l,i.value;{const d=s(n);return i.value=i.value===d?s(r):d,i.value}}return o?a:[i,a]}function ke(t,e,n){let r=n?.immediate?[]:[...t instanceof Function?t():Array.isArray(t)?t:s(t)];return u.watch(t,(o,i,a)=>{const l=Array.from({length:r.length}),d=[];for(const y of o){let h=!1;for(let f=0;f<r.length;f++)if(!l[f]&&y===r[f]){l[f]=!0,h=!0;break}h||d.push(y)}const w=r.filter((y,h)=>!l[h]);e(o,r,d,w,a),r=[...o]},n)}function _e(t,e,n){const{count:r,...o}=n,i=u.ref(0),a=W(t,(...l)=>{i.value+=1,i.value>=s(r)&&u.nextTick(()=>a()),e(...l)},o);return{count:i,stop:a}}function ht(t,e,n={}){const{debounce:r=0,maxWait:o=void 0,...i}=n;return W(t,e,{...i,eventFilter:z(r,{maxWait:o})})}function je(t,e,n){return u.watch(t,e,{...n,deep:!0})}function V(t,e,n={}){const{eventFilter:r=B,...o}=n,i=N(r,e);let a,l,d;if(o.flush==="sync"){const w=u.ref(!1);l=()=>{},a=y=>{w.value=!0,y(),w.value=!1},d=u.watch(t,(...y)=>{w.value||i(...y)},o)}else{const w=[],y=u.ref(0),h=u.ref(0);l=()=>{y.value=h.value},w.push(u.watch(t,()=>{h.value++},{...o,flush:"sync"})),a=f=>{const g=h.value;f(),y.value+=h.value-g},w.push(u.watch(t,(...f)=>{const g=y.value>0&&y.value===h.value;y.value=0,h.value=0,!g&&i(...f)},o)),d=()=>{w.forEach(f=>f())}}return{stop:d,ignoreUpdates:a,ignorePrevAsyncUpdates:l}}function Ne(t,e,n){return u.watch(t,e,{...n,immediate:!0})}function Le(t,e,n){const r=u.watch(t,(...o)=>(u.nextTick(()=>r()),e(...o)),n);return r}function yt(t,e,n={}){const{throttle:r=0,trailing:o=!0,leading:i=!0,...a}=n;return W(t,e,{...a,eventFilter:q(r,o,i)})}function We(t,e,n={}){let r;function o(){if(!r)return;const y=r;r=void 0,y()}function i(y){r=y}const a=(y,h)=>(o(),e(y,h,i)),l=V(t,a,n),{ignoreUpdates:d}=l;return{...l,trigger:()=>{let y;return d(()=>{y=a(Ue(t),Be(t))}),y}}}function Ue(t){return u.isReactive(t)?t:Array.isArray(t)?t.map(e=>s(e)):s(t)}function Be(t){return Array.isArray(t)?t.map(()=>{}):void 0}function $e(t,e,n){return u.watch(t,(r,o,i)=>{r&&e(r,o,i)},n)}c.assert=Pt,c.autoResetRef=ct,c.bypassFilter=B,c.camelize=Wt,c.clamp=Mt,c.computedEager=E,c.computedWithControl=O,c.containsProp=ot,c.controlledComputed=O,c.controlledRef=Xt,c.createEventHook=v,c.createFilterWrapper=N,c.createGlobalState=S,c.createInjectionState=U,c.createReactiveFn=Y,c.createSharedComposable=M,c.createSingletonPromise=Bt,c.debounceFilter=z,c.debouncedRef=X,c.debouncedWatch=ht,c.directiveHooks=_t,c.eagerComputed=E,c.extendRef=P,c.formatDate=lt,c.get=gt,c.getLifeCycleTarget=L,c.hasOwn=Rt,c.hyphenate=Nt,c.identity=Ut,c.ignorableWatch=V,c.increaseWithUnit=Ht,c.injectLocal=_,c.invoke=$t,c.isClient=j,c.isDef=St,c.isDefined=mt,c.isIOS=Et,c.isObject=tt,c.isWorker=Ot,c.makeDestructurable=pt,c.noop=C,c.normalizeDate=st,c.notNullish=Tt,c.now=It,c.objectEntries=zt,c.objectOmit=Gt,c.objectPick=Yt,c.pausableFilter=nt,c.pausableWatch=$,c.promiseTimeout=Z,c.provideLocal=T,c.rand=Ct,c.reactify=Y,c.reactifyObject=bt,c.reactiveComputed=G,c.reactiveOmit=At,c.reactivePick=Zt,c.refAutoReset=ct,c.refDebounced=X,c.refDefault=Jt,c.refThrottled=K,c.refWithControl=at,c.resolveRef=qt,c.resolveUnref=vt,c.set=Kt,c.syncRef=Qt,c.syncRefs=Vt,c.throttleFilter=q,c.throttledRef=K,c.throttledWatch=yt,c.timestamp=et,c.toReactive=D,c.toRef=J,c.toRefs=xt,c.toValue=s,c.tryOnBeforeMount=Dt,c.tryOnBeforeUnmount=te,c.tryOnMounted=ee,c.tryOnScopeDispose=I,c.tryOnUnmounted=ne,c.until=re,c.useArrayDifference=ce,c.useArrayEvery=ue,c.useArrayFilter=ie,c.useArrayFind=ae,c.useArrayFindIndex=le,c.useArrayFindLast=fe,c.useArrayIncludes=he,c.useArrayJoin=ye,c.useArrayMap=we,c.useArrayReduce=ge,c.useArraySome=me,c.useArrayUnique=be,c.useCounter=Ae,c.useDateFormat=Pe,c.useDebounce=X,c.useDebounceFn=ut,c.useInterval=Fe,c.useIntervalFn=ft,c.useLastChanged=Ie,c.useThrottle=K,c.useThrottleFn=it,c.useTimeout=Me,c.useTimeoutFn=dt,c.useToNumber=Ce,c.useToString=Re,c.useToggle=Ee,c.watchArray=ke,c.watchAtMost=_e,c.watchDebounced=ht,c.watchDeep=je,c.watchIgnorable=V,c.watchImmediate=Ne,c.watchOnce=Le,c.watchPausable=$,c.watchThrottled=yt,c.watchTriggerable=We,c.watchWithFilter=W,c.whenever=$e})(this.VueUse=this.VueUse||{},VueDemi);
1
+ var VueDemi=function(c,u,E){if(c.install)return c;if(!u)return console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`."),c;if(u.version.slice(0,4)==="2.7."){let v=function(S,A){var T,_={},U={config:u.config,use:u.use.bind(u),mixin:u.mixin.bind(u),component:u.component.bind(u),provide:function(I,F){return _[I]=F,this},directive:function(I,F){return F?(u.directive(I,F),U):u.directive(I)},mount:function(I,F){return T||(T=new u(Object.assign({propsData:A},S,{provide:Object.assign(_,S.provide)})),T.$mount(I,F),T)},unmount:function(){T&&(T.$destroy(),T=void 0)}};return U};var M=v;for(var O in u)c[O]=u[O];c.isVue2=!0,c.isVue3=!1,c.install=function(){},c.Vue=u,c.Vue2=u,c.version=u.version,c.warn=u.util.warn,c.hasInjectionContext=function(){return!!c.getCurrentInstance()},c.createApp=v}else if(u.version.slice(0,2)==="2.")if(E){for(var O in E)c[O]=E[O];c.isVue2=!0,c.isVue3=!1,c.install=function(){},c.Vue=u,c.Vue2=u,c.version=u.version,c.hasInjectionContext=function(){return!!c.getCurrentInstance()}}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if(u.version.slice(0,2)==="3."){for(var O in u)c[O]=u[O];c.isVue2=!1,c.isVue3=!0,c.install=function(){},c.Vue=u,c.Vue2=void 0,c.version=u.version,c.set=function(v,S,A){return Array.isArray(v)?(v.length=Math.max(v.length,S),v.splice(S,1,A),A):(v[S]=A,A)},c.del=function(v,S){if(Array.isArray(v)){v.splice(S,1);return}delete v[S]}}else console.error("[vue-demi] Vue version "+u.version+" is unsupported.");return c}(this.VueDemi=this.VueDemi||(typeof VueDemi<"u"?VueDemi:{}),this.Vue||(typeof Vue<"u"?Vue:void 0),this.VueCompositionAPI||(typeof VueCompositionAPI<"u"?VueCompositionAPI:void 0));(function(c,u){"use strict";function E(t,e){var n;const r=u.shallowRef();return u.watchEffect(()=>{r.value=t()},{...e,flush:(n=e?.flush)!=null?n:"sync"}),u.readonly(r)}function O(t,e){let n,r,o;const i=u.ref(!0),a=()=>{i.value=!0,o()};u.watch(t,a,{flush:"sync"});const l=typeof e=="function"?e:e.get,f=typeof e=="function"?void 0:e.set,m=u.customRef((y,h)=>(r=y,o=h,{get(){return i.value&&(n=l(),i.value=!1),r(),n},set(d){f?.(d)}}));return Object.isExtensible(m)&&(m.trigger=a),m}function M(t){return u.getCurrentScope()?(u.onScopeDispose(t),!0):!1}function v(){const t=new Set,e=o=>{t.delete(o)};return{on:o=>{t.add(o);const i=()=>e(o);return M(i),{off:i}},off:e,trigger:(...o)=>Promise.all(Array.from(t).map(i=>i(...o)))}}function S(t){let e=!1,n;const r=u.effectScope(!0);return(...o)=>(e||(n=r.run(()=>t(...o)),e=!0),n)}const A=new WeakMap,T=(t,e)=>{var n;const r=(n=u.getCurrentInstance())==null?void 0:n.proxy;if(r==null)throw new Error("provideLocal must be called in setup");A.has(r)||A.set(r,Object.create(null));const o=A.get(r);o[t]=e,u.provide(t,e)},_=(...t)=>{var e;const n=t[0],r=(e=u.getCurrentInstance())==null?void 0:e.proxy;if(r==null)throw new Error("injectLocal must be called in setup");return A.has(r)&&n in A.get(r)?A.get(r)[n]:u.inject(...t)};function U(t,e){const n=e?.injectionKey||Symbol(t.name||"InjectionState");return[(...i)=>{const a=t(...i);return T(n,a),a},()=>_(n)]}function I(t){let e=0,n,r;const o=()=>{e-=1,r&&e<=0&&(r.stop(),n=void 0,r=void 0)};return(...i)=>(e+=1,n||(r=u.effectScope(!0),n=r.run(()=>t(...i))),M(o),n)}function F(t,e,{enumerable:n=!1,unwrap:r=!0}={}){if(!u.isVue3&&!u.version.startsWith("2.7.")){if(process.env.NODE_ENV!=="production")throw new Error("[VueUse] extendRef only works in Vue 2.7 or above.");return}for(const[o,i]of Object.entries(e))o!=="value"&&(u.isRef(i)&&r?Object.defineProperty(t,o,{get(){return i.value},set(a){i.value=a},enumerable:n}):Object.defineProperty(t,o,{value:i,enumerable:n}));return t}function wt(t,e){return e==null?u.unref(t):u.unref(t)[e]}function gt(t){return u.unref(t)!=null}function pt(t,e){if(typeof Symbol<"u"){const n={...t};return Object.defineProperty(n,Symbol.iterator,{enumerable:!1,value(){let r=0;return{next:()=>({value:e[r++],done:r>e.length})}}}),n}else return Object.assign([...e],t)}function s(t){return typeof t=="function"?t():u.unref(t)}const vt=s;function Y(t,e){const n=e?.computedGetter===!1?u.unref:s;return function(...r){return u.computed(()=>t.apply(this,r.map(o=>n(o))))}}function bt(t,e={}){let n=[],r;if(Array.isArray(e))n=e;else{r=e;const{includeOwnProperties:o=!0}=e;n.push(...Object.keys(t)),o&&n.push(...Object.getOwnPropertyNames(t))}return Object.fromEntries(n.map(o=>{const i=t[o];return[o,typeof i=="function"?Y(i.bind(t),r):i]}))}function D(t){if(!u.isRef(t))return u.reactive(t);const e=new Proxy({},{get(n,r,o){return u.unref(Reflect.get(t.value,r,o))},set(n,r,o){return u.isRef(t.value[r])&&!u.isRef(o)?t.value[r].value=o:t.value[r]=o,!0},deleteProperty(n,r){return Reflect.deleteProperty(t.value,r)},has(n,r){return Reflect.has(t.value,r)},ownKeys(){return Object.keys(t.value)},getOwnPropertyDescriptor(){return{enumerable:!0,configurable:!0}}});return u.reactive(e)}function G(t){return D(u.computed(t))}function At(t,...e){const n=e.flat(),r=n[0];return G(()=>Object.fromEntries(typeof r=="function"?Object.entries(u.toRefs(t)).filter(([o,i])=>!r(s(i),o)):Object.entries(u.toRefs(t)).filter(o=>!n.includes(o[0]))))}const j=typeof window<"u"&&typeof document<"u",Ot=typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope,St=t=>typeof t<"u",Tt=t=>t!=null,Pt=(t,...e)=>{t||console.warn(...e)},Ft=Object.prototype.toString,tt=t=>Ft.call(t)==="[object Object]",Mt=()=>Date.now(),et=()=>+Date.now(),It=(t,e,n)=>Math.min(n,Math.max(e,t)),C=()=>{},Ct=(t,e)=>(t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t+1))+t),Rt=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Et=kt();function kt(){var t,e;return j&&((t=window?.navigator)==null?void 0:t.userAgent)&&(/iP(ad|hone|od)/.test(window.navigator.userAgent)||((e=window?.navigator)==null?void 0:e.maxTouchPoints)>2&&/iPad|Macintosh/.test(window?.navigator.userAgent))}function N(t,e){function n(...r){return new Promise((o,i)=>{Promise.resolve(t(()=>e.apply(this,r),{fn:e,thisArg:this,args:r})).then(o).catch(i)})}return n}const B=t=>t();function z(t,e={}){let n,r,o=C;const i=l=>{clearTimeout(l),o(),o=C};return l=>{const f=s(t),m=s(e.maxWait);return n&&i(n),f<=0||m!==void 0&&m<=0?(r&&(i(r),r=null),Promise.resolve(l())):new Promise((y,h)=>{o=e.rejectOnCancel?h:y,m&&!r&&(r=setTimeout(()=>{n&&i(n),r=null,y(l())},m)),n=setTimeout(()=>{r&&i(r),r=null,y(l())},f)})}}function q(...t){let e=0,n,r=!0,o=C,i,a,l,f,m;!u.isRef(t[0])&&typeof t[0]=="object"?{delay:a,trailing:l=!0,leading:f=!0,rejectOnCancel:m=!1}=t[0]:[a,l=!0,f=!0,m=!1]=t;const y=()=>{n&&(clearTimeout(n),n=void 0,o(),o=C)};return d=>{const w=s(a),g=Date.now()-e,b=()=>i=d();return y(),w<=0?(e=Date.now(),b()):(g>w&&(f||!r)?(e=Date.now(),b()):l&&(i=new Promise((p,P)=>{o=m?P:p,n=setTimeout(()=>{e=Date.now(),r=!0,p(b()),y()},Math.max(0,w-g))})),!f&&!n&&(n=setTimeout(()=>r=!0,w)),r=!1,i)}}function nt(t=B){const e=u.ref(!0);function n(){e.value=!1}function r(){e.value=!0}const o=(...i)=>{e.value&&t(...i)};return{isActive:u.readonly(e),pause:n,resume:r,eventFilter:o}}const _t={mounted:u.isVue3?"mounted":"inserted",updated:u.isVue3?"updated":"componentUpdated",unmounted:u.isVue3?"unmounted":"unbind"};function rt(t){const e=Object.create(null);return n=>e[n]||(e[n]=t(n))}const jt=/\B([A-Z])/g,Nt=rt(t=>t.replace(jt,"-$1").toLowerCase()),Lt=/-(\w)/g,Wt=rt(t=>t.replace(Lt,(e,n)=>n?n.toUpperCase():""));function Z(t,e=!1,n="Timeout"){return new Promise((r,o)=>{setTimeout(e?()=>o(n):r,t)})}function Ut(t){return t}function Bt(t){let e;function n(){return e||(e=t()),e}return n.reset=async()=>{const r=e;e=void 0,r&&await r},n}function $t(t){return t()}function ot(t,...e){return e.some(n=>n in t)}function Ht(t,e){var n;if(typeof t=="number")return t+e;const r=((n=t.match(/^-?[0-9]+\.?[0-9]*/))==null?void 0:n[0])||"",o=t.slice(r.length),i=Number.parseFloat(r)+e;return Number.isNaN(i)?t:i+o}function Yt(t,e,n=!1){return e.reduce((r,o)=>(o in t&&(!n||t[o]!==void 0)&&(r[o]=t[o]),r),{})}function Gt(t,e,n=!1){return Object.fromEntries(Object.entries(t).filter(([r,o])=>(!n||o!==void 0)&&!e.includes(r)))}function zt(t){return Object.entries(t)}function L(t){return t||u.getCurrentInstance()}function J(...t){if(t.length!==1)return u.toRef(...t);const e=t[0];return typeof e=="function"?u.readonly(u.customRef(()=>({get:e,set:C}))):u.ref(e)}const qt=J;function Zt(t,...e){const n=e.flat(),r=n[0];return G(()=>Object.fromEntries(typeof r=="function"?Object.entries(u.toRefs(t)).filter(([o,i])=>r(s(i),o)):n.map(o=>[o,J(t,o)])))}function ct(t,e=1e4){return u.customRef((n,r)=>{let o=s(t),i;const a=()=>setTimeout(()=>{o=s(t),r()},s(e));return M(()=>{clearTimeout(i)}),{get(){return n(),o},set(l){o=l,r(),clearTimeout(i),i=a()}}})}function ut(t,e=200,n={}){return N(z(e,n),t)}function X(t,e=200,n={}){const r=u.ref(t.value),o=ut(()=>{r.value=t.value},e,n);return u.watch(t,()=>o()),r}function Jt(t,e){return u.computed({get(){var n;return(n=t.value)!=null?n:e},set(n){t.value=n}})}function it(t,e=200,n=!1,r=!0,o=!1){return N(q(e,n,r,o),t)}function K(t,e=200,n=!0,r=!0){if(e<=0)return t;const o=u.ref(t.value),i=it(()=>{o.value=t.value},e,n,r);return u.watch(t,()=>i()),o}function at(t,e={}){let n=t,r,o;const i=u.customRef((d,w)=>(r=d,o=w,{get(){return a()},set(g){l(g)}}));function a(d=!0){return d&&r(),n}function l(d,w=!0){var g,b;if(d===n)return;const p=n;((g=e.onBeforeChange)==null?void 0:g.call(e,d,p))!==!1&&(n=d,(b=e.onChanged)==null||b.call(e,d,p),w&&o())}return F(i,{get:a,set:l,untrackedGet:()=>a(!1),silentSet:d=>l(d,!1),peek:()=>a(!1),lay:d=>l(d,!1)},{enumerable:!0})}const Xt=at;function Kt(...t){if(t.length===2){const[e,n]=t;e.value=n}if(t.length===3)if(u.isVue2)u.set(...t);else{const[e,n,r]=t;e[n]=r}}function W(t,e,n={}){const{eventFilter:r=B,...o}=n;return u.watch(t,N(r,e),o)}function $(t,e,n={}){const{eventFilter:r,...o}=n,{eventFilter:i,pause:a,resume:l,isActive:f}=nt(r);return{stop:W(t,e,{...o,eventFilter:i}),pause:a,resume:l,isActive:f}}function Qt(t,e,...[n]){const{flush:r="sync",deep:o=!1,immediate:i=!0,direction:a="both",transform:l={}}=n||{},f=[],m="ltr"in l&&l.ltr||(d=>d),y="rtl"in l&&l.rtl||(d=>d);return(a==="both"||a==="ltr")&&f.push($(t,d=>{f.forEach(w=>w.pause()),e.value=m(d),f.forEach(w=>w.resume())},{flush:r,deep:o,immediate:i})),(a==="both"||a==="rtl")&&f.push($(e,d=>{f.forEach(w=>w.pause()),t.value=y(d),f.forEach(w=>w.resume())},{flush:r,deep:o,immediate:i})),()=>{f.forEach(d=>d.stop())}}function Vt(t,e,n={}){const{flush:r="sync",deep:o=!1,immediate:i=!0}=n;return Array.isArray(e)||(e=[e]),u.watch(t,a=>e.forEach(l=>l.value=a),{flush:r,deep:o,immediate:i})}function xt(t,e={}){if(!u.isRef(t))return u.toRefs(t);const n=Array.isArray(t.value)?Array.from({length:t.value.length}):{};for(const r in t.value)n[r]=u.customRef(()=>({get(){return t.value[r]},set(o){var i;if((i=s(e.replaceRef))!=null?i:!0)if(Array.isArray(t.value)){const l=[...t.value];l[r]=o,t.value=l}else{const l={...t.value,[r]:o};Object.setPrototypeOf(l,Object.getPrototypeOf(t.value)),t.value=l}else t.value[r]=o}}));return n}function Dt(t,e=!0,n){L(n)?u.onBeforeMount(t,n):e?t():u.nextTick(t)}function te(t,e){L(e)&&u.onBeforeUnmount(t,e)}function ee(t,e=!0,n){L()?u.onMounted(t,n):e?t():u.nextTick(t)}function ne(t,e){L(e)&&u.onUnmounted(t,e)}function Q(t,e=!1){function n(h,{flush:d="sync",deep:w=!1,timeout:g,throwOnTimeout:b}={}){let p=null;const x=[new Promise(H=>{p=u.watch(t,k=>{h(k)!==e&&(p?.(),H(k))},{flush:d,deep:w,immediate:!0})})];return g!=null&&x.push(Z(g,b).then(()=>s(t)).finally(()=>p?.())),Promise.race(x)}function r(h,d){if(!u.isRef(h))return n(k=>k===h,d);const{flush:w="sync",deep:g=!1,timeout:b,throwOnTimeout:p}=d??{};let P=null;const H=[new Promise(k=>{P=u.watch([t,h],([mt,He])=>{e!==(mt===He)&&(P?.(),k(mt))},{flush:w,deep:g,immediate:!0})})];return b!=null&&H.push(Z(b,p).then(()=>s(t)).finally(()=>(P?.(),s(t)))),Promise.race(H)}function o(h){return n(d=>!!d,h)}function i(h){return r(null,h)}function a(h){return r(void 0,h)}function l(h){return n(Number.isNaN,h)}function f(h,d){return n(w=>{const g=Array.from(w);return g.includes(h)||g.includes(s(h))},d)}function m(h){return y(1,h)}function y(h=1,d){let w=-1;return n(()=>(w+=1,w>=h),d)}return Array.isArray(s(t))?{toMatch:n,toContains:f,changed:m,changedTimes:y,get not(){return Q(t,!e)}}:{toMatch:n,toBe:r,toBeTruthy:o,toBeNull:i,toBeNaN:l,toBeUndefined:a,changed:m,changedTimes:y,get not(){return Q(t,!e)}}}function re(t){return Q(t)}function oe(t,e){return t===e}function ce(...t){var e;const n=t[0],r=t[1];let o=(e=t[2])!=null?e:oe;if(typeof o=="string"){const i=o;o=(a,l)=>a[i]===l[i]}return u.computed(()=>s(n).filter(i=>s(r).findIndex(a=>o(i,a))===-1))}function ue(t,e){return u.computed(()=>s(t).every((n,r,o)=>e(s(n),r,o)))}function ie(t,e){return u.computed(()=>s(t).map(n=>s(n)).filter(e))}function ae(t,e){return u.computed(()=>s(s(t).find((n,r,o)=>e(s(n),r,o))))}function le(t,e){return u.computed(()=>s(t).findIndex((n,r,o)=>e(s(n),r,o)))}function se(t,e){let n=t.length;for(;n-- >0;)if(e(t[n],n,t))return t[n]}function fe(t,e){return u.computed(()=>s(Array.prototype.findLast?s(t).findLast((n,r,o)=>e(s(n),r,o)):se(s(t),(n,r,o)=>e(s(n),r,o))))}function de(t){return tt(t)&&ot(t,"formIndex","comparator")}function he(...t){var e;const n=t[0],r=t[1];let o=t[2],i=0;if(de(o)&&(i=(e=o.fromIndex)!=null?e:0,o=o.comparator),typeof o=="string"){const a=o;o=(l,f)=>l[a]===s(f)}return o=o??((a,l)=>a===s(l)),u.computed(()=>s(n).slice(i).some((a,l,f)=>o(s(a),s(r),l,s(f))))}function ye(t,e){return u.computed(()=>s(t).map(n=>s(n)).join(s(e)))}function me(t,e){return u.computed(()=>s(t).map(n=>s(n)).map(e))}function we(t,e,...n){const r=(o,i,a)=>e(s(o),s(i),a);return u.computed(()=>{const o=s(t);return n.length?o.reduce(r,s(n[0])):o.reduce(r)})}function ge(t,e){return u.computed(()=>s(t).some((n,r,o)=>e(s(n),r,o)))}function pe(t){return Array.from(new Set(t))}function ve(t,e){return t.reduce((n,r)=>(n.some(o=>e(r,o,t))||n.push(r),n),[])}function be(t,e){return u.computed(()=>{const n=s(t).map(r=>s(r));return e?ve(n,e):pe(n)})}function Ae(t=0,e={}){let n=u.unref(t);const r=u.ref(t),{max:o=Number.POSITIVE_INFINITY,min:i=Number.NEGATIVE_INFINITY}=e,a=(h=1)=>r.value=Math.max(Math.min(o,r.value+h),i),l=(h=1)=>r.value=Math.min(Math.max(i,r.value-h),o),f=()=>r.value,m=h=>r.value=Math.max(i,Math.min(o,h));return{count:r,inc:a,dec:l,get:f,set:m,reset:(h=n)=>(n=h,m(h))}}const Oe=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,Se=/[YMDHhms]o|\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a{1,2}|A{1,2}|m{1,2}|s{1,2}|Z{1,2}|SSS/g;function Te(t,e,n,r){let o=t<12?"AM":"PM";return r&&(o=o.split("").reduce((i,a)=>i+=`${a}.`,"")),n?o.toLowerCase():o}function R(t){const e=["th","st","nd","rd"],n=t%100;return t+(e[(n-20)%10]||e[n]||e[0])}function lt(t,e,n={}){var r;const o=t.getFullYear(),i=t.getMonth(),a=t.getDate(),l=t.getHours(),f=t.getMinutes(),m=t.getSeconds(),y=t.getMilliseconds(),h=t.getDay(),d=(r=n.customMeridiem)!=null?r:Te,w={Yo:()=>R(o),YY:()=>String(o).slice(-2),YYYY:()=>o,M:()=>i+1,Mo:()=>R(i+1),MM:()=>`${i+1}`.padStart(2,"0"),MMM:()=>t.toLocaleDateString(n.locales,{month:"short"}),MMMM:()=>t.toLocaleDateString(n.locales,{month:"long"}),D:()=>String(a),Do:()=>R(a),DD:()=>`${a}`.padStart(2,"0"),H:()=>String(l),Ho:()=>R(l),HH:()=>`${l}`.padStart(2,"0"),h:()=>`${l%12||12}`.padStart(1,"0"),ho:()=>R(l%12||12),hh:()=>`${l%12||12}`.padStart(2,"0"),m:()=>String(f),mo:()=>R(f),mm:()=>`${f}`.padStart(2,"0"),s:()=>String(m),so:()=>R(m),ss:()=>`${m}`.padStart(2,"0"),SSS:()=>`${y}`.padStart(3,"0"),d:()=>h,dd:()=>t.toLocaleDateString(n.locales,{weekday:"narrow"}),ddd:()=>t.toLocaleDateString(n.locales,{weekday:"short"}),dddd:()=>t.toLocaleDateString(n.locales,{weekday:"long"}),A:()=>d(l,f),AA:()=>d(l,f,!1,!0),a:()=>d(l,f,!0),aa:()=>d(l,f,!0,!0)};return e.replace(Se,(g,b)=>{var p,P;return(P=b??((p=w[g])==null?void 0:p.call(w)))!=null?P:g})}function st(t){if(t===null)return new Date(Number.NaN);if(t===void 0)return new Date;if(t instanceof Date)return new Date(t);if(typeof t=="string"&&!/Z$/i.test(t)){const e=t.match(Oe);if(e){const n=e[2]-1||0,r=(e[7]||"0").substring(0,3);return new Date(e[1],n,e[3]||1,e[4]||0,e[5]||0,e[6]||0,r)}}return new Date(t)}function Pe(t,e="HH:mm:ss",n={}){return u.computed(()=>lt(st(s(t)),s(e),n))}function ft(t,e=1e3,n={}){const{immediate:r=!0,immediateCallback:o=!1}=n;let i=null;const a=u.ref(!1);function l(){i&&(clearInterval(i),i=null)}function f(){a.value=!1,l()}function m(){const y=s(e);y<=0||(a.value=!0,o&&t(),l(),i=setInterval(t,y))}if(r&&j&&m(),u.isRef(e)||typeof e=="function"){const y=u.watch(e,()=>{a.value&&j&&m()});M(y)}return M(f),{isActive:a,pause:f,resume:m}}function Fe(t=1e3,e={}){const{controls:n=!1,immediate:r=!0,callback:o}=e,i=u.ref(0),a=()=>i.value+=1,l=()=>{i.value=0},f=ft(o?()=>{a(),o(i.value)}:a,t,{immediate:r});return n?{counter:i,reset:l,...f}:i}function Me(t,e={}){var n;const r=u.ref((n=e.initialValue)!=null?n:null);return u.watch(t,()=>r.value=et(),e),r}function dt(t,e,n={}){const{immediate:r=!0}=n,o=u.ref(!1);let i=null;function a(){i&&(clearTimeout(i),i=null)}function l(){o.value=!1,a()}function f(...m){a(),o.value=!0,i=setTimeout(()=>{o.value=!1,i=null,t(...m)},s(e))}return r&&(o.value=!0,j&&f()),M(l),{isPending:u.readonly(o),start:f,stop:l}}function Ie(t=1e3,e={}){const{controls:n=!1,callback:r}=e,o=dt(r??C,t,e),i=u.computed(()=>!o.isPending.value);return n?{ready:i,...o}:i}function Ce(t,e={}){const{method:n="parseFloat",radix:r,nanToZero:o}=e;return u.computed(()=>{let i=s(t);return typeof i=="string"&&(i=Number[n](i,r)),o&&Number.isNaN(i)&&(i=0),i})}function Re(t){return u.computed(()=>`${s(t)}`)}function Ee(t=!1,e={}){const{truthyValue:n=!0,falsyValue:r=!1}=e,o=u.isRef(t),i=u.ref(t);function a(l){if(arguments.length)return i.value=l,i.value;{const f=s(n);return i.value=i.value===f?s(r):f,i.value}}return o?a:[i,a]}function ke(t,e,n){let r=n?.immediate?[]:[...t instanceof Function?t():Array.isArray(t)?t:s(t)];return u.watch(t,(o,i,a)=>{const l=Array.from({length:r.length}),f=[];for(const y of o){let h=!1;for(let d=0;d<r.length;d++)if(!l[d]&&y===r[d]){l[d]=!0,h=!0;break}h||f.push(y)}const m=r.filter((y,h)=>!l[h]);e(o,r,f,m,a),r=[...o]},n)}function _e(t,e,n){const{count:r,...o}=n,i=u.ref(0),a=W(t,(...l)=>{i.value+=1,i.value>=s(r)&&u.nextTick(()=>a()),e(...l)},o);return{count:i,stop:a}}function ht(t,e,n={}){const{debounce:r=0,maxWait:o=void 0,...i}=n;return W(t,e,{...i,eventFilter:z(r,{maxWait:o})})}function je(t,e,n){return u.watch(t,e,{...n,deep:!0})}function V(t,e,n={}){const{eventFilter:r=B,...o}=n,i=N(r,e);let a,l,f;if(o.flush==="sync"){const m=u.ref(!1);l=()=>{},a=y=>{m.value=!0,y(),m.value=!1},f=u.watch(t,(...y)=>{m.value||i(...y)},o)}else{const m=[],y=u.ref(0),h=u.ref(0);l=()=>{y.value=h.value},m.push(u.watch(t,()=>{h.value++},{...o,flush:"sync"})),a=d=>{const w=h.value;d(),y.value+=h.value-w},m.push(u.watch(t,(...d)=>{const w=y.value>0&&y.value===h.value;y.value=0,h.value=0,!w&&i(...d)},o)),f=()=>{m.forEach(d=>d())}}return{stop:f,ignoreUpdates:a,ignorePrevAsyncUpdates:l}}function Ne(t,e,n){return u.watch(t,e,{...n,immediate:!0})}function Le(t,e,n){const r=u.watch(t,(...o)=>(u.nextTick(()=>r()),e(...o)),n);return r}function yt(t,e,n={}){const{throttle:r=0,trailing:o=!0,leading:i=!0,...a}=n;return W(t,e,{...a,eventFilter:q(r,o,i)})}function We(t,e,n={}){let r;function o(){if(!r)return;const y=r;r=void 0,y()}function i(y){r=y}const a=(y,h)=>(o(),e(y,h,i)),l=V(t,a,n),{ignoreUpdates:f}=l;return{...l,trigger:()=>{let y;return f(()=>{y=a(Ue(t),Be(t))}),y}}}function Ue(t){return u.isReactive(t)?t:Array.isArray(t)?t.map(e=>s(e)):s(t)}function Be(t){return Array.isArray(t)?t.map(()=>{}):void 0}function $e(t,e,n){return u.watch(t,(r,o,i)=>{r&&e(r,o,i)},n)}c.assert=Pt,c.autoResetRef=ct,c.bypassFilter=B,c.camelize=Wt,c.clamp=It,c.computedEager=E,c.computedWithControl=O,c.containsProp=ot,c.controlledComputed=O,c.controlledRef=Xt,c.createEventHook=v,c.createFilterWrapper=N,c.createGlobalState=S,c.createInjectionState=U,c.createReactiveFn=Y,c.createSharedComposable=I,c.createSingletonPromise=Bt,c.debounceFilter=z,c.debouncedRef=X,c.debouncedWatch=ht,c.directiveHooks=_t,c.eagerComputed=E,c.extendRef=F,c.formatDate=lt,c.get=wt,c.getLifeCycleTarget=L,c.hasOwn=Rt,c.hyphenate=Nt,c.identity=Ut,c.ignorableWatch=V,c.increaseWithUnit=Ht,c.injectLocal=_,c.invoke=$t,c.isClient=j,c.isDef=St,c.isDefined=gt,c.isIOS=Et,c.isObject=tt,c.isWorker=Ot,c.makeDestructurable=pt,c.noop=C,c.normalizeDate=st,c.notNullish=Tt,c.now=Mt,c.objectEntries=zt,c.objectOmit=Gt,c.objectPick=Yt,c.pausableFilter=nt,c.pausableWatch=$,c.promiseTimeout=Z,c.provideLocal=T,c.rand=Ct,c.reactify=Y,c.reactifyObject=bt,c.reactiveComputed=G,c.reactiveOmit=At,c.reactivePick=Zt,c.refAutoReset=ct,c.refDebounced=X,c.refDefault=Jt,c.refThrottled=K,c.refWithControl=at,c.resolveRef=qt,c.resolveUnref=vt,c.set=Kt,c.syncRef=Qt,c.syncRefs=Vt,c.throttleFilter=q,c.throttledRef=K,c.throttledWatch=yt,c.timestamp=et,c.toReactive=D,c.toRef=J,c.toRefs=xt,c.toValue=s,c.tryOnBeforeMount=Dt,c.tryOnBeforeUnmount=te,c.tryOnMounted=ee,c.tryOnScopeDispose=M,c.tryOnUnmounted=ne,c.until=re,c.useArrayDifference=ce,c.useArrayEvery=ue,c.useArrayFilter=ie,c.useArrayFind=ae,c.useArrayFindIndex=le,c.useArrayFindLast=fe,c.useArrayIncludes=he,c.useArrayJoin=ye,c.useArrayMap=me,c.useArrayReduce=we,c.useArraySome=ge,c.useArrayUnique=be,c.useCounter=Ae,c.useDateFormat=Pe,c.useDebounce=X,c.useDebounceFn=ut,c.useInterval=Fe,c.useIntervalFn=ft,c.useLastChanged=Me,c.useThrottle=K,c.useThrottleFn=it,c.useTimeout=Ie,c.useTimeoutFn=dt,c.useToNumber=Ce,c.useToString=Re,c.useToggle=Ee,c.watchArray=ke,c.watchAtMost=_e,c.watchDebounced=ht,c.watchDeep=je,c.watchIgnorable=V,c.watchImmediate=Ne,c.watchOnce=Le,c.watchPausable=$,c.watchThrottled=yt,c.watchTriggerable=We,c.watchWithFilter=W,c.whenever=$e})(this.VueUse=this.VueUse||{},VueDemi);
package/index.mjs CHANGED
@@ -116,7 +116,7 @@ const injectLocal = (...args) => {
116
116
  };
117
117
 
118
118
  function createInjectionState(composable, options) {
119
- const key = (options == null ? void 0 : options.injectionKey) || Symbol("InjectionState");
119
+ const key = (options == null ? void 0 : options.injectionKey) || Symbol(composable.name || "InjectionState");
120
120
  const useProvidingState = (...args) => {
121
121
  const state = composable(...args);
122
122
  provideLocal(key, state);
@@ -363,12 +363,20 @@ function debounceFilter(ms, options = {}) {
363
363
  };
364
364
  return filter;
365
365
  }
366
- function throttleFilter(ms, trailing = true, leading = true, rejectOnCancel = false) {
366
+ function throttleFilter(...args) {
367
367
  let lastExec = 0;
368
368
  let timer;
369
369
  let isLeading = true;
370
370
  let lastRejector = noop;
371
371
  let lastValue;
372
+ let ms;
373
+ let trailing;
374
+ let leading;
375
+ let rejectOnCancel;
376
+ if (!isRef(args[0]) && typeof args[0] === "object")
377
+ ({ delay: ms, trailing = true, leading = true, rejectOnCancel = false } = args[0]);
378
+ else
379
+ [ms, trailing = true, leading = true, rejectOnCancel = false] = args;
372
380
  const clear = () => {
373
381
  if (timer) {
374
382
  clearTimeout(timer);
@@ -1046,8 +1054,8 @@ function useCounter(initialValue = 0, options = {}) {
1046
1054
  max = Number.POSITIVE_INFINITY,
1047
1055
  min = Number.NEGATIVE_INFINITY
1048
1056
  } = options;
1049
- const inc = (delta = 1) => count.value = Math.min(max, count.value + delta);
1050
- const dec = (delta = 1) => count.value = Math.max(min, count.value - delta);
1057
+ const inc = (delta = 1) => count.value = Math.max(Math.min(max, count.value + delta), min);
1058
+ const dec = (delta = 1) => count.value = Math.min(Math.max(min, count.value - delta), max);
1051
1059
  const get = () => count.value;
1052
1060
  const set = (val) => count.value = Math.max(min, Math.min(max, val));
1053
1061
  const reset = (val = _initialValue) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vueuse/shared",
3
- "version": "10.7.2",
3
+ "version": "10.8.0",
4
4
  "author": "Anthony Fu <https://github.com/antfu>",
5
5
  "license": "MIT",
6
6
  "funding": "https://github.com/sponsors/antfu",
@@ -32,6 +32,6 @@
32
32
  "jsdelivr": "./index.iife.min.js",
33
33
  "types": "./index.d.cts",
34
34
  "dependencies": {
35
- "vue-demi": ">=0.14.6"
35
+ "vue-demi": ">=0.14.7"
36
36
  }
37
37
  }