@vueuse/integrations 12.2.0 → 12.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/index.cjs +46 -46
  2. package/index.d.cts +20 -14
  3. package/index.d.mts +20 -14
  4. package/index.d.ts +20 -14
  5. package/index.iife.js +46 -46
  6. package/index.iife.min.js +1 -1
  7. package/index.mjs +36 -36
  8. package/package.json +3 -3
  9. package/useAsyncValidator/component.cjs +1 -1
  10. package/useAsyncValidator/component.mjs +2 -2
  11. package/useAsyncValidator.cjs +3 -3
  12. package/useAsyncValidator.iife.js +3 -3
  13. package/useAsyncValidator.iife.min.js +1 -1
  14. package/useAsyncValidator.mjs +4 -4
  15. package/useAxios.cjs +6 -6
  16. package/useAxios.d.cts +19 -13
  17. package/useAxios.d.mts +19 -13
  18. package/useAxios.d.ts +19 -13
  19. package/useAxios.iife.js +6 -6
  20. package/useAxios.iife.min.js +1 -1
  21. package/useAxios.mjs +6 -6
  22. package/useChangeCase.cjs +3 -4
  23. package/useChangeCase.iife.js +5 -5
  24. package/useChangeCase.iife.min.js +1 -1
  25. package/useChangeCase.mjs +1 -2
  26. package/useDrauu.cjs +9 -9
  27. package/useDrauu.iife.js +9 -9
  28. package/useDrauu.iife.min.js +1 -1
  29. package/useDrauu.mjs +9 -9
  30. package/useFocusTrap.cjs +3 -3
  31. package/useFocusTrap.d.cts +1 -1
  32. package/useFocusTrap.d.mts +1 -1
  33. package/useFocusTrap.d.ts +1 -1
  34. package/useFocusTrap.iife.js +3 -3
  35. package/useFocusTrap.iife.min.js +1 -1
  36. package/useFocusTrap.mjs +4 -4
  37. package/useFuse.cjs +9 -10
  38. package/useFuse.iife.js +11 -11
  39. package/useFuse.iife.min.js +1 -1
  40. package/useFuse.mjs +6 -7
  41. package/useIDBKeyval.cjs +1 -2
  42. package/useIDBKeyval.iife.js +3 -3
  43. package/useIDBKeyval.iife.min.js +1 -1
  44. package/useIDBKeyval.mjs +1 -2
  45. package/useJwt.cjs +3 -4
  46. package/useJwt.iife.js +5 -5
  47. package/useJwt.iife.min.js +1 -1
  48. package/useJwt.mjs +2 -3
  49. package/useNProgress.cjs +1 -1
  50. package/useNProgress.d.cts +1 -1
  51. package/useNProgress.d.mts +1 -1
  52. package/useNProgress.d.ts +1 -1
  53. package/useNProgress.iife.js +1 -1
  54. package/useNProgress.iife.min.js +1 -1
  55. package/useNProgress.mjs +3 -3
  56. package/useSortable/component.cjs +4 -4
  57. package/useSortable/component.mjs +5 -5
  58. package/useSortable.cjs +8 -8
  59. package/useSortable.iife.js +8 -8
  60. package/useSortable.iife.min.js +1 -1
  61. package/useSortable.mjs +9 -9
package/index.cjs CHANGED
@@ -48,13 +48,13 @@ function useAsyncValidator(value, rules, options = {}) {
48
48
  const pass = vue.ref(!immediate || manual);
49
49
  const errors = vue.computed(() => {
50
50
  var _a;
51
- return ((_a = errorInfo.value) == null ? void 0 : _a.errors) || [];
51
+ return ((_a = errorInfo.value) == null ? undefined : _a.errors) || [];
52
52
  });
53
53
  const errorFields = vue.computed(() => {
54
54
  var _a;
55
- return ((_a = errorInfo.value) == null ? void 0 : _a.fields) || {};
55
+ return ((_a = errorInfo.value) == null ? undefined : _a.fields) || {};
56
56
  });
57
- const validator = vue.computed(() => new AsyncValidatorSchema(shared.toValue(rules)));
57
+ const validator = vue.computed(() => new AsyncValidatorSchema(vue.toValue(rules)));
58
58
  const execute = async () => {
59
59
  isFinished.value = false;
60
60
  pass.value = false;
@@ -103,7 +103,7 @@ function useAsyncValidator(value, rules, options = {}) {
103
103
  }
104
104
 
105
105
  function useAxios(...args) {
106
- const url = typeof args[0] === "string" ? args[0] : void 0;
106
+ const url = typeof args[0] === "string" ? args[0] : undefined;
107
107
  const argsPlaceholder = typeof url === "string" ? 1 : 0;
108
108
  const defaultOptions = {
109
109
  immediate: !!argsPlaceholder,
@@ -113,7 +113,7 @@ function useAxios(...args) {
113
113
  let defaultConfig = {};
114
114
  let instance = axios;
115
115
  let options = defaultOptions;
116
- const isAxiosInstance = (val) => !!(val == null ? void 0 : val.request);
116
+ const isAxiosInstance = (val) => !!(val == null ? undefined : val.request);
117
117
  if (args.length > 0 + argsPlaceholder) {
118
118
  if (isAxiosInstance(args[0 + argsPlaceholder]))
119
119
  instance = args[0 + argsPlaceholder];
@@ -128,13 +128,13 @@ function useAxios(...args) {
128
128
  options = args[args.length - 1] || defaultOptions;
129
129
  }
130
130
  const {
131
- initialData,
132
131
  shallow,
133
132
  onSuccess = shared.noop,
134
133
  onError = shared.noop,
135
134
  immediate,
136
135
  resetOnExecute = false
137
136
  } = options;
137
+ const initialData = options.initialData;
138
138
  const response = vue.shallowRef();
139
139
  const data = (shallow ? vue.shallowRef : vue.ref)(initialData);
140
140
  const isFinished = vue.ref(false);
@@ -168,9 +168,9 @@ function useAxios(...args) {
168
168
  };
169
169
  let executeCounter = 0;
170
170
  const execute = (executeUrl = url, config = {}) => {
171
- error.value = void 0;
171
+ error.value = undefined;
172
172
  const _url = typeof executeUrl === "string" ? executeUrl : url != null ? url : config.url;
173
- if (_url === void 0) {
173
+ if (_url === undefined) {
174
174
  error.value = new axios.AxiosError(axios.AxiosError.ERR_INVALID_URL);
175
175
  isFinished.value = true;
176
176
  return promise;
@@ -194,7 +194,7 @@ function useAxios(...args) {
194
194
  onError(e);
195
195
  }).finally(() => {
196
196
  var _a;
197
- (_a = options.onFinish) == null ? void 0 : _a.call(options);
197
+ (_a = options.onFinish) == null ? undefined : _a.call(options);
198
198
  if (currentExecuteCounter === executeCounter)
199
199
  loading(false);
200
200
  });
@@ -226,17 +226,17 @@ const changeCaseTransforms = /* @__PURE__ */ Object.entries(changeCase__namespac
226
226
  }, {});
227
227
  function useChangeCase(input, type, options) {
228
228
  const typeRef = vue.computed(() => {
229
- const t = shared.toValue(type);
229
+ const t = vue.toValue(type);
230
230
  if (!changeCaseTransforms[t])
231
231
  throw new Error(`Invalid change case type "${t}"`);
232
232
  return t;
233
233
  });
234
234
  if (typeof input === "function")
235
- return vue.computed(() => changeCaseTransforms[typeRef.value](shared.toValue(input), shared.toValue(options)));
235
+ return vue.computed(() => changeCaseTransforms[typeRef.value](vue.toValue(input), vue.toValue(options)));
236
236
  const text = vue.ref(input);
237
237
  return vue.computed({
238
238
  get() {
239
- return changeCaseTransforms[typeRef.value](text.value, shared.toValue(options));
239
+ return changeCaseTransforms[typeRef.value](text.value, vue.toValue(options));
240
240
  },
241
241
  set(value) {
242
242
  text.value = value;
@@ -317,10 +317,10 @@ function useDrauu(target, options) {
317
317
  size: 3,
318
318
  arrowEnd: false,
319
319
  cornerRadius: 0,
320
- dasharray: void 0,
320
+ dasharray: undefined,
321
321
  fill: "transparent",
322
322
  mode: "draw",
323
- ...options == null ? void 0 : options.brush
323
+ ...options == null ? undefined : options.brush
324
324
  });
325
325
  vue.watch(brush, () => {
326
326
  const instance = drauuInstance.value;
@@ -331,32 +331,32 @@ function useDrauu(target, options) {
331
331
  }, { deep: true });
332
332
  const undo = () => {
333
333
  var _a;
334
- return (_a = drauuInstance.value) == null ? void 0 : _a.undo();
334
+ return (_a = drauuInstance.value) == null ? undefined : _a.undo();
335
335
  };
336
336
  const redo = () => {
337
337
  var _a;
338
- return (_a = drauuInstance.value) == null ? void 0 : _a.redo();
338
+ return (_a = drauuInstance.value) == null ? undefined : _a.redo();
339
339
  };
340
340
  const clear = () => {
341
341
  var _a;
342
- return (_a = drauuInstance.value) == null ? void 0 : _a.clear();
342
+ return (_a = drauuInstance.value) == null ? undefined : _a.clear();
343
343
  };
344
344
  const cancel = () => {
345
345
  var _a;
346
- return (_a = drauuInstance.value) == null ? void 0 : _a.cancel();
346
+ return (_a = drauuInstance.value) == null ? undefined : _a.cancel();
347
347
  };
348
348
  const load = (svg) => {
349
349
  var _a;
350
- return (_a = drauuInstance.value) == null ? void 0 : _a.load(svg);
350
+ return (_a = drauuInstance.value) == null ? undefined : _a.load(svg);
351
351
  };
352
352
  const dump = () => {
353
353
  var _a;
354
- return (_a = drauuInstance.value) == null ? void 0 : _a.dump();
354
+ return (_a = drauuInstance.value) == null ? undefined : _a.dump();
355
355
  };
356
356
  const cleanup = () => {
357
357
  var _a;
358
358
  disposables.forEach((dispose) => dispose());
359
- (_a = drauuInstance.value) == null ? void 0 : _a.unmount();
359
+ (_a = drauuInstance.value) == null ? undefined : _a.unmount();
360
360
  };
361
361
  const syncStatus = () => {
362
362
  if (drauuInstance.value) {
@@ -428,9 +428,9 @@ function useFocusTrap(target, options = {}) {
428
428
  }
429
429
  };
430
430
  const targets = vue.computed(() => {
431
- const _targets = shared.toValue(target);
432
- return (Array.isArray(_targets) ? _targets : [_targets]).map((el) => {
433
- const _el = shared.toValue(el);
431
+ const _targets = vue.toValue(target);
432
+ return core.toArray(_targets).map((el) => {
433
+ const _el = vue.toValue(el);
434
434
  return typeof _el === "string" ? _el : core.unrefElement(_el);
435
435
  }).filter(shared.notNullish);
436
436
  });
@@ -472,15 +472,15 @@ function useFuse(search, data, options) {
472
472
  const createFuse = () => {
473
473
  var _a, _b;
474
474
  return new Fuse(
475
- (_a = shared.toValue(data)) != null ? _a : [],
476
- (_b = shared.toValue(options)) == null ? void 0 : _b.fuseOptions
475
+ (_a = vue.toValue(data)) != null ? _a : [],
476
+ (_b = vue.toValue(options)) == null ? undefined : _b.fuseOptions
477
477
  );
478
478
  };
479
479
  const fuse = vue.ref(createFuse());
480
480
  vue.watch(
481
481
  () => {
482
482
  var _a;
483
- return (_a = shared.toValue(options)) == null ? void 0 : _a.fuseOptions;
483
+ return (_a = vue.toValue(options)) == null ? undefined : _a.fuseOptions;
484
484
  },
485
485
  () => {
486
486
  fuse.value = createFuse();
@@ -488,18 +488,18 @@ function useFuse(search, data, options) {
488
488
  { deep: true }
489
489
  );
490
490
  vue.watch(
491
- () => shared.toValue(data),
491
+ () => vue.toValue(data),
492
492
  (newData) => {
493
493
  fuse.value.setCollection(newData);
494
494
  },
495
495
  { deep: true }
496
496
  );
497
497
  const results = vue.computed(() => {
498
- const resolved = shared.toValue(options);
499
- if ((resolved == null ? void 0 : resolved.matchAllWhenSearchEmpty) && !shared.toValue(search))
500
- return shared.toValue(data).map((item, index) => ({ item, refIndex: index }));
501
- const limit = resolved == null ? void 0 : resolved.resultLimit;
502
- return fuse.value.search(shared.toValue(search), limit ? { limit } : void 0);
498
+ const resolved = vue.toValue(options);
499
+ if ((resolved == null ? undefined : resolved.matchAllWhenSearchEmpty) && !vue.toValue(search))
500
+ return vue.toValue(data).map((item, index) => ({ item, refIndex: index }));
501
+ const limit = resolved == null ? undefined : resolved.resultLimit;
502
+ return fuse.value.search(vue.toValue(search), limit ? { limit } : undefined);
503
503
  });
504
504
  return {
505
505
  fuse,
@@ -519,7 +519,7 @@ function useIDBKeyval(key, initialValue, options = {}) {
519
519
  } = options;
520
520
  const isFinished = vue.ref(false);
521
521
  const data = (shallow ? vue.shallowRef : vue.ref)(initialValue);
522
- const rawInit = shared.toValue(initialValue);
522
+ const rawInit = vue.toValue(initialValue);
523
523
  async function read() {
524
524
  try {
525
525
  const rawValue = await idbKeyval.get(key);
@@ -572,12 +572,12 @@ function useJwt(encodedJwt, options = {}) {
572
572
  try {
573
573
  return jwtDecode.jwtDecode(encodedJwt2, options2);
574
574
  } catch (err) {
575
- onError == null ? void 0 : onError(err);
575
+ onError == null ? undefined : onError(err);
576
576
  return fallbackValue;
577
577
  }
578
578
  };
579
- const header = vue.computed(() => decodeWithFallback(shared.toValue(encodedJwt), { header: true }));
580
- const payload = vue.computed(() => decodeWithFallback(shared.toValue(encodedJwt)));
579
+ const header = vue.computed(() => decodeWithFallback(vue.toValue(encodedJwt), { header: true }));
580
+ const payload = vue.computed(() => decodeWithFallback(vue.toValue(encodedJwt)));
581
581
  return {
582
582
  header,
583
583
  payload
@@ -585,7 +585,7 @@ function useJwt(encodedJwt, options = {}) {
585
585
  }
586
586
 
587
587
  function useNProgress(currentProgress = null, options) {
588
- const progress = vue.ref(currentProgress);
588
+ const progress = shared.toRef(currentProgress);
589
589
  const isLoading = vue.computed({
590
590
  set: (load) => load ? nprogress.start() : nprogress.done(),
591
591
  get: () => typeof progress.value === "number" && progress.value < 1
@@ -637,20 +637,20 @@ function useSortable(el, list, options = {}) {
637
637
  }
638
638
  };
639
639
  const start = () => {
640
- const target = typeof el === "string" ? document == null ? void 0 : document.querySelector(el) : core.unrefElement(el);
641
- if (!target || sortable !== void 0)
640
+ const target = typeof el === "string" ? document == null ? undefined : document.querySelector(el) : core.unrefElement(el);
641
+ if (!target || sortable !== undefined)
642
642
  return;
643
643
  sortable = new Sortable(target, { ...defaultOptions, ...resetOptions });
644
644
  };
645
645
  const stop = () => {
646
- sortable == null ? void 0 : sortable.destroy();
647
- sortable = void 0;
646
+ sortable == null ? undefined : sortable.destroy();
647
+ sortable = undefined;
648
648
  };
649
649
  const option = (name, value) => {
650
- if (value !== void 0)
651
- sortable == null ? void 0 : sortable.option(name, value);
650
+ if (value !== undefined)
651
+ sortable == null ? undefined : sortable.option(name, value);
652
652
  else
653
- return sortable == null ? void 0 : sortable.option(name);
653
+ return sortable == null ? undefined : sortable.option(name);
654
654
  };
655
655
  core.tryOnMounted(start);
656
656
  core.tryOnScopeDispose(stop);
@@ -674,7 +674,7 @@ function moveArrayElement(list, from, to, e = null) {
674
674
  insertNodeAt(e.from, e.item, from);
675
675
  }
676
676
  const _valueIsRef = vue.isRef(list);
677
- const array = _valueIsRef ? [...core.toValue(list)] : core.toValue(list);
677
+ const array = _valueIsRef ? [...vue.toValue(list)] : vue.toValue(list);
678
678
  if (to >= 0 && to < array.length) {
679
679
  const element = array.splice(from, 1)[0];
680
680
  vue.nextTick(() => {
package/index.d.cts CHANGED
@@ -61,7 +61,7 @@ interface UseAsyncValidatorOptions {
61
61
  */
62
62
  declare function useAsyncValidator(value: MaybeRefOrGetter<Record<string, any>>, rules: MaybeRefOrGetter<Rules>, options?: UseAsyncValidatorOptions): UseAsyncValidatorReturn & PromiseLike<UseAsyncValidatorReturn>;
63
63
 
64
- interface UseAxiosReturn<T, R = AxiosResponse<T>, _D = any> {
64
+ interface UseAxiosReturn<T, R = AxiosResponse<T>, _D = any, O extends UseAxiosOptions = UseAxiosOptions<T>> {
65
65
  /**
66
66
  * Axios Response
67
67
  */
@@ -69,7 +69,7 @@ interface UseAxiosReturn<T, R = AxiosResponse<T>, _D = any> {
69
69
  /**
70
70
  * Axios response data
71
71
  */
72
- data: Ref<T | undefined>;
72
+ data: O extends UseAxiosOptionsWithInitialData<T> ? Ref<T> : Ref<T | undefined>;
73
73
  /**
74
74
  * Indicates if the request has finished
75
75
  */
@@ -99,11 +99,11 @@ interface UseAxiosReturn<T, R = AxiosResponse<T>, _D = any> {
99
99
  */
100
100
  isCanceled: Ref<boolean>;
101
101
  }
102
- interface StrictUseAxiosReturn<T, R, D> extends UseAxiosReturn<T, R, D> {
102
+ interface StrictUseAxiosReturn<T, R, D, O extends UseAxiosOptions = UseAxiosOptions<T>> extends UseAxiosReturn<T, R, D, O> {
103
103
  /**
104
104
  * Manually call the axios request
105
105
  */
106
- execute: (url?: string | AxiosRequestConfig<D>, config?: AxiosRequestConfig<D>) => Promise<StrictUseAxiosReturn<T, R, D>>;
106
+ execute: (url?: string | AxiosRequestConfig<D>, config?: AxiosRequestConfig<D>) => Promise<StrictUseAxiosReturn<T, R, D, O>>;
107
107
  }
108
108
  interface EasyUseAxiosReturn<T, R, D> extends UseAxiosReturn<T, R, D> {
109
109
  /**
@@ -111,7 +111,7 @@ interface EasyUseAxiosReturn<T, R, D> extends UseAxiosReturn<T, R, D> {
111
111
  */
112
112
  execute: (url: string, config?: AxiosRequestConfig<D>) => Promise<EasyUseAxiosReturn<T, R, D>>;
113
113
  }
114
- interface UseAxiosOptions<T = any> {
114
+ interface UseAxiosOptionsBase<T = any> {
115
115
  /**
116
116
  * Will automatically run axios request when `useAxios` is used
117
117
  *
@@ -137,10 +137,6 @@ interface UseAxiosOptions<T = any> {
137
137
  * Callback when success is caught.
138
138
  */
139
139
  onSuccess?: (data: T) => void;
140
- /**
141
- * Initial data to use
142
- */
143
- initialData?: T;
144
140
  /**
145
141
  * Sets the state to initialState before executing the promise.
146
142
  */
@@ -150,9 +146,19 @@ interface UseAxiosOptions<T = any> {
150
146
  */
151
147
  onFinish?: () => void;
152
148
  }
153
- declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>, options?: UseAxiosOptions): StrictUseAxiosReturn<T, R, D> & Promise<StrictUseAxiosReturn<T, R, D>>;
154
- declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(url: string, instance?: AxiosInstance, options?: UseAxiosOptions): StrictUseAxiosReturn<T, R, D> & Promise<StrictUseAxiosReturn<T, R, D>>;
155
- declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(url: string, config: AxiosRequestConfig<D>, instance: AxiosInstance, options?: UseAxiosOptions): StrictUseAxiosReturn<T, R, D> & Promise<StrictUseAxiosReturn<T, R, D>>;
149
+ interface UseAxiosOptionsWithInitialData<T> extends UseAxiosOptionsBase<T> {
150
+ /**
151
+ * Initial data
152
+ */
153
+ initialData: T;
154
+ }
155
+ type UseAxiosOptions<T = any> = UseAxiosOptionsBase<T> | UseAxiosOptionsWithInitialData<T>;
156
+ declare function useAxios<T = any, R = AxiosResponse<T>, D = any, O extends UseAxiosOptionsWithInitialData<T> = UseAxiosOptionsWithInitialData<T>>(url: string, config?: AxiosRequestConfig<D>, options?: O): StrictUseAxiosReturn<T, R, D, O> & Promise<StrictUseAxiosReturn<T, R, D, O>>;
157
+ declare function useAxios<T = any, R = AxiosResponse<T>, D = any, O extends UseAxiosOptionsWithInitialData<T> = UseAxiosOptionsWithInitialData<T>>(url: string, instance?: AxiosInstance, options?: O): StrictUseAxiosReturn<T, R, D, O> & Promise<StrictUseAxiosReturn<T, R, D, O>>;
158
+ declare function useAxios<T = any, R = AxiosResponse<T>, D = any, O extends UseAxiosOptionsWithInitialData<T> = UseAxiosOptionsWithInitialData<T>>(url: string, config: AxiosRequestConfig<D>, instance: AxiosInstance, options?: O): StrictUseAxiosReturn<T, R, D, O> & Promise<StrictUseAxiosReturn<T, R, D, O>>;
159
+ declare function useAxios<T = any, R = AxiosResponse<T>, D = any, O extends UseAxiosOptionsBase<T> = UseAxiosOptionsBase<T>>(url: string, config?: AxiosRequestConfig<D>, options?: O): StrictUseAxiosReturn<T, R, D, O> & Promise<StrictUseAxiosReturn<T, R, D, O>>;
160
+ declare function useAxios<T = any, R = AxiosResponse<T>, D = any, O extends UseAxiosOptionsBase<T> = UseAxiosOptionsBase<T>>(url: string, instance?: AxiosInstance, options?: O): StrictUseAxiosReturn<T, R, D, O> & Promise<StrictUseAxiosReturn<T, R, D, O>>;
161
+ declare function useAxios<T = any, R = AxiosResponse<T>, D = any, O extends UseAxiosOptionsBase<T> = UseAxiosOptionsBase<T>>(url: string, config: AxiosRequestConfig<D>, instance: AxiosInstance, options?: O): StrictUseAxiosReturn<T, R, D, O> & Promise<StrictUseAxiosReturn<T, R, D, O>>;
156
162
  declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(config?: AxiosRequestConfig<D>): EasyUseAxiosReturn<T, R, D> & Promise<EasyUseAxiosReturn<T, R, D>>;
157
163
  declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(instance?: AxiosInstance): EasyUseAxiosReturn<T, R, D> & Promise<EasyUseAxiosReturn<T, R, D>>;
158
164
  declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(config?: AxiosRequestConfig<D>, instance?: AxiosInstance): EasyUseAxiosReturn<T, R, D> & Promise<EasyUseAxiosReturn<T, R, D>>;
@@ -387,7 +393,7 @@ type UseNProgressOptions = Partial<NProgressOptions>;
387
393
  */
388
394
  declare function useNProgress(currentProgress?: MaybeRefOrGetter<number | null | undefined>, options?: UseNProgressOptions): {
389
395
  isLoading: vue.WritableComputedRef<boolean, boolean>;
390
- progress: vue.Ref<number | (() => number | null | undefined) | null | undefined, number | vue.Ref<number | null | undefined, number | null | undefined> | vue.ShallowRef<number | null | undefined, number | null | undefined> | vue.WritableComputedRef<number | null | undefined, number | null | undefined> | vue.ComputedRef<number | null | undefined> | (() => number | null | undefined) | null | undefined>;
396
+ progress: vue.Ref<number | null | undefined, number | null | undefined>;
391
397
  start: () => nprogress.NProgress;
392
398
  done: (force?: boolean) => nprogress.NProgress;
393
399
  remove: () => void;
@@ -438,4 +444,4 @@ declare function insertNodeAt(parentElement: Element, element: Element, index: n
438
444
  declare function removeNode(node: Node): void;
439
445
  declare function moveArrayElement<T>(list: MaybeRefOrGetter$1<T[]>, from: number, to: number, e?: Sortable.SortableEvent | null): void;
440
446
 
441
- export { type AsyncValidatorError, type ChangeCaseType, type EasyUseAxiosReturn, type FuseOptions, type StrictUseAxiosReturn, type UseAsyncValidatorExecuteReturn, type UseAsyncValidatorOptions, type UseAsyncValidatorReturn, type UseAxiosOptions, type UseAxiosReturn, type UseDrauuOptions, type UseDrauuReturn, type UseFocusTrapOptions, type UseFocusTrapReturn, type UseFuseOptions, type UseFuseReturn, type UseIDBKeyvalReturn, type UseIDBOptions, type UseJwtOptions, type UseJwtReturn, type UseNProgressOptions, type UseNProgressReturn, type UseSortableOptions, type UseSortableReturn, createCookies, insertNodeAt, moveArrayElement, removeNode, useAsyncValidator, useAxios, useChangeCase, useCookies, useDrauu, useFocusTrap, useFuse, useIDBKeyval, useJwt, useNProgress, useQRCode, useSortable };
447
+ export { type AsyncValidatorError, type ChangeCaseType, type EasyUseAxiosReturn, type FuseOptions, type StrictUseAxiosReturn, type UseAsyncValidatorExecuteReturn, type UseAsyncValidatorOptions, type UseAsyncValidatorReturn, type UseAxiosOptions, type UseAxiosOptionsBase, type UseAxiosOptionsWithInitialData, type UseAxiosReturn, type UseDrauuOptions, type UseDrauuReturn, type UseFocusTrapOptions, type UseFocusTrapReturn, type UseFuseOptions, type UseFuseReturn, type UseIDBKeyvalReturn, type UseIDBOptions, type UseJwtOptions, type UseJwtReturn, type UseNProgressOptions, type UseNProgressReturn, type UseSortableOptions, type UseSortableReturn, createCookies, insertNodeAt, moveArrayElement, removeNode, useAsyncValidator, useAxios, useChangeCase, useCookies, useDrauu, useFocusTrap, useFuse, useIDBKeyval, useJwt, useNProgress, useQRCode, useSortable };
package/index.d.mts CHANGED
@@ -61,7 +61,7 @@ interface UseAsyncValidatorOptions {
61
61
  */
62
62
  declare function useAsyncValidator(value: MaybeRefOrGetter<Record<string, any>>, rules: MaybeRefOrGetter<Rules>, options?: UseAsyncValidatorOptions): UseAsyncValidatorReturn & PromiseLike<UseAsyncValidatorReturn>;
63
63
 
64
- interface UseAxiosReturn<T, R = AxiosResponse<T>, _D = any> {
64
+ interface UseAxiosReturn<T, R = AxiosResponse<T>, _D = any, O extends UseAxiosOptions = UseAxiosOptions<T>> {
65
65
  /**
66
66
  * Axios Response
67
67
  */
@@ -69,7 +69,7 @@ interface UseAxiosReturn<T, R = AxiosResponse<T>, _D = any> {
69
69
  /**
70
70
  * Axios response data
71
71
  */
72
- data: Ref<T | undefined>;
72
+ data: O extends UseAxiosOptionsWithInitialData<T> ? Ref<T> : Ref<T | undefined>;
73
73
  /**
74
74
  * Indicates if the request has finished
75
75
  */
@@ -99,11 +99,11 @@ interface UseAxiosReturn<T, R = AxiosResponse<T>, _D = any> {
99
99
  */
100
100
  isCanceled: Ref<boolean>;
101
101
  }
102
- interface StrictUseAxiosReturn<T, R, D> extends UseAxiosReturn<T, R, D> {
102
+ interface StrictUseAxiosReturn<T, R, D, O extends UseAxiosOptions = UseAxiosOptions<T>> extends UseAxiosReturn<T, R, D, O> {
103
103
  /**
104
104
  * Manually call the axios request
105
105
  */
106
- execute: (url?: string | AxiosRequestConfig<D>, config?: AxiosRequestConfig<D>) => Promise<StrictUseAxiosReturn<T, R, D>>;
106
+ execute: (url?: string | AxiosRequestConfig<D>, config?: AxiosRequestConfig<D>) => Promise<StrictUseAxiosReturn<T, R, D, O>>;
107
107
  }
108
108
  interface EasyUseAxiosReturn<T, R, D> extends UseAxiosReturn<T, R, D> {
109
109
  /**
@@ -111,7 +111,7 @@ interface EasyUseAxiosReturn<T, R, D> extends UseAxiosReturn<T, R, D> {
111
111
  */
112
112
  execute: (url: string, config?: AxiosRequestConfig<D>) => Promise<EasyUseAxiosReturn<T, R, D>>;
113
113
  }
114
- interface UseAxiosOptions<T = any> {
114
+ interface UseAxiosOptionsBase<T = any> {
115
115
  /**
116
116
  * Will automatically run axios request when `useAxios` is used
117
117
  *
@@ -137,10 +137,6 @@ interface UseAxiosOptions<T = any> {
137
137
  * Callback when success is caught.
138
138
  */
139
139
  onSuccess?: (data: T) => void;
140
- /**
141
- * Initial data to use
142
- */
143
- initialData?: T;
144
140
  /**
145
141
  * Sets the state to initialState before executing the promise.
146
142
  */
@@ -150,9 +146,19 @@ interface UseAxiosOptions<T = any> {
150
146
  */
151
147
  onFinish?: () => void;
152
148
  }
153
- declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>, options?: UseAxiosOptions): StrictUseAxiosReturn<T, R, D> & Promise<StrictUseAxiosReturn<T, R, D>>;
154
- declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(url: string, instance?: AxiosInstance, options?: UseAxiosOptions): StrictUseAxiosReturn<T, R, D> & Promise<StrictUseAxiosReturn<T, R, D>>;
155
- declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(url: string, config: AxiosRequestConfig<D>, instance: AxiosInstance, options?: UseAxiosOptions): StrictUseAxiosReturn<T, R, D> & Promise<StrictUseAxiosReturn<T, R, D>>;
149
+ interface UseAxiosOptionsWithInitialData<T> extends UseAxiosOptionsBase<T> {
150
+ /**
151
+ * Initial data
152
+ */
153
+ initialData: T;
154
+ }
155
+ type UseAxiosOptions<T = any> = UseAxiosOptionsBase<T> | UseAxiosOptionsWithInitialData<T>;
156
+ declare function useAxios<T = any, R = AxiosResponse<T>, D = any, O extends UseAxiosOptionsWithInitialData<T> = UseAxiosOptionsWithInitialData<T>>(url: string, config?: AxiosRequestConfig<D>, options?: O): StrictUseAxiosReturn<T, R, D, O> & Promise<StrictUseAxiosReturn<T, R, D, O>>;
157
+ declare function useAxios<T = any, R = AxiosResponse<T>, D = any, O extends UseAxiosOptionsWithInitialData<T> = UseAxiosOptionsWithInitialData<T>>(url: string, instance?: AxiosInstance, options?: O): StrictUseAxiosReturn<T, R, D, O> & Promise<StrictUseAxiosReturn<T, R, D, O>>;
158
+ declare function useAxios<T = any, R = AxiosResponse<T>, D = any, O extends UseAxiosOptionsWithInitialData<T> = UseAxiosOptionsWithInitialData<T>>(url: string, config: AxiosRequestConfig<D>, instance: AxiosInstance, options?: O): StrictUseAxiosReturn<T, R, D, O> & Promise<StrictUseAxiosReturn<T, R, D, O>>;
159
+ declare function useAxios<T = any, R = AxiosResponse<T>, D = any, O extends UseAxiosOptionsBase<T> = UseAxiosOptionsBase<T>>(url: string, config?: AxiosRequestConfig<D>, options?: O): StrictUseAxiosReturn<T, R, D, O> & Promise<StrictUseAxiosReturn<T, R, D, O>>;
160
+ declare function useAxios<T = any, R = AxiosResponse<T>, D = any, O extends UseAxiosOptionsBase<T> = UseAxiosOptionsBase<T>>(url: string, instance?: AxiosInstance, options?: O): StrictUseAxiosReturn<T, R, D, O> & Promise<StrictUseAxiosReturn<T, R, D, O>>;
161
+ declare function useAxios<T = any, R = AxiosResponse<T>, D = any, O extends UseAxiosOptionsBase<T> = UseAxiosOptionsBase<T>>(url: string, config: AxiosRequestConfig<D>, instance: AxiosInstance, options?: O): StrictUseAxiosReturn<T, R, D, O> & Promise<StrictUseAxiosReturn<T, R, D, O>>;
156
162
  declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(config?: AxiosRequestConfig<D>): EasyUseAxiosReturn<T, R, D> & Promise<EasyUseAxiosReturn<T, R, D>>;
157
163
  declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(instance?: AxiosInstance): EasyUseAxiosReturn<T, R, D> & Promise<EasyUseAxiosReturn<T, R, D>>;
158
164
  declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(config?: AxiosRequestConfig<D>, instance?: AxiosInstance): EasyUseAxiosReturn<T, R, D> & Promise<EasyUseAxiosReturn<T, R, D>>;
@@ -387,7 +393,7 @@ type UseNProgressOptions = Partial<NProgressOptions>;
387
393
  */
388
394
  declare function useNProgress(currentProgress?: MaybeRefOrGetter<number | null | undefined>, options?: UseNProgressOptions): {
389
395
  isLoading: vue.WritableComputedRef<boolean, boolean>;
390
- progress: vue.Ref<number | (() => number | null | undefined) | null | undefined, number | vue.Ref<number | null | undefined, number | null | undefined> | vue.ShallowRef<number | null | undefined, number | null | undefined> | vue.WritableComputedRef<number | null | undefined, number | null | undefined> | vue.ComputedRef<number | null | undefined> | (() => number | null | undefined) | null | undefined>;
396
+ progress: vue.Ref<number | null | undefined, number | null | undefined>;
391
397
  start: () => nprogress.NProgress;
392
398
  done: (force?: boolean) => nprogress.NProgress;
393
399
  remove: () => void;
@@ -438,4 +444,4 @@ declare function insertNodeAt(parentElement: Element, element: Element, index: n
438
444
  declare function removeNode(node: Node): void;
439
445
  declare function moveArrayElement<T>(list: MaybeRefOrGetter$1<T[]>, from: number, to: number, e?: Sortable.SortableEvent | null): void;
440
446
 
441
- export { type AsyncValidatorError, type ChangeCaseType, type EasyUseAxiosReturn, type FuseOptions, type StrictUseAxiosReturn, type UseAsyncValidatorExecuteReturn, type UseAsyncValidatorOptions, type UseAsyncValidatorReturn, type UseAxiosOptions, type UseAxiosReturn, type UseDrauuOptions, type UseDrauuReturn, type UseFocusTrapOptions, type UseFocusTrapReturn, type UseFuseOptions, type UseFuseReturn, type UseIDBKeyvalReturn, type UseIDBOptions, type UseJwtOptions, type UseJwtReturn, type UseNProgressOptions, type UseNProgressReturn, type UseSortableOptions, type UseSortableReturn, createCookies, insertNodeAt, moveArrayElement, removeNode, useAsyncValidator, useAxios, useChangeCase, useCookies, useDrauu, useFocusTrap, useFuse, useIDBKeyval, useJwt, useNProgress, useQRCode, useSortable };
447
+ export { type AsyncValidatorError, type ChangeCaseType, type EasyUseAxiosReturn, type FuseOptions, type StrictUseAxiosReturn, type UseAsyncValidatorExecuteReturn, type UseAsyncValidatorOptions, type UseAsyncValidatorReturn, type UseAxiosOptions, type UseAxiosOptionsBase, type UseAxiosOptionsWithInitialData, type UseAxiosReturn, type UseDrauuOptions, type UseDrauuReturn, type UseFocusTrapOptions, type UseFocusTrapReturn, type UseFuseOptions, type UseFuseReturn, type UseIDBKeyvalReturn, type UseIDBOptions, type UseJwtOptions, type UseJwtReturn, type UseNProgressOptions, type UseNProgressReturn, type UseSortableOptions, type UseSortableReturn, createCookies, insertNodeAt, moveArrayElement, removeNode, useAsyncValidator, useAxios, useChangeCase, useCookies, useDrauu, useFocusTrap, useFuse, useIDBKeyval, useJwt, useNProgress, useQRCode, useSortable };
package/index.d.ts CHANGED
@@ -61,7 +61,7 @@ interface UseAsyncValidatorOptions {
61
61
  */
62
62
  declare function useAsyncValidator(value: MaybeRefOrGetter<Record<string, any>>, rules: MaybeRefOrGetter<Rules>, options?: UseAsyncValidatorOptions): UseAsyncValidatorReturn & PromiseLike<UseAsyncValidatorReturn>;
63
63
 
64
- interface UseAxiosReturn<T, R = AxiosResponse<T>, _D = any> {
64
+ interface UseAxiosReturn<T, R = AxiosResponse<T>, _D = any, O extends UseAxiosOptions = UseAxiosOptions<T>> {
65
65
  /**
66
66
  * Axios Response
67
67
  */
@@ -69,7 +69,7 @@ interface UseAxiosReturn<T, R = AxiosResponse<T>, _D = any> {
69
69
  /**
70
70
  * Axios response data
71
71
  */
72
- data: Ref<T | undefined>;
72
+ data: O extends UseAxiosOptionsWithInitialData<T> ? Ref<T> : Ref<T | undefined>;
73
73
  /**
74
74
  * Indicates if the request has finished
75
75
  */
@@ -99,11 +99,11 @@ interface UseAxiosReturn<T, R = AxiosResponse<T>, _D = any> {
99
99
  */
100
100
  isCanceled: Ref<boolean>;
101
101
  }
102
- interface StrictUseAxiosReturn<T, R, D> extends UseAxiosReturn<T, R, D> {
102
+ interface StrictUseAxiosReturn<T, R, D, O extends UseAxiosOptions = UseAxiosOptions<T>> extends UseAxiosReturn<T, R, D, O> {
103
103
  /**
104
104
  * Manually call the axios request
105
105
  */
106
- execute: (url?: string | AxiosRequestConfig<D>, config?: AxiosRequestConfig<D>) => Promise<StrictUseAxiosReturn<T, R, D>>;
106
+ execute: (url?: string | AxiosRequestConfig<D>, config?: AxiosRequestConfig<D>) => Promise<StrictUseAxiosReturn<T, R, D, O>>;
107
107
  }
108
108
  interface EasyUseAxiosReturn<T, R, D> extends UseAxiosReturn<T, R, D> {
109
109
  /**
@@ -111,7 +111,7 @@ interface EasyUseAxiosReturn<T, R, D> extends UseAxiosReturn<T, R, D> {
111
111
  */
112
112
  execute: (url: string, config?: AxiosRequestConfig<D>) => Promise<EasyUseAxiosReturn<T, R, D>>;
113
113
  }
114
- interface UseAxiosOptions<T = any> {
114
+ interface UseAxiosOptionsBase<T = any> {
115
115
  /**
116
116
  * Will automatically run axios request when `useAxios` is used
117
117
  *
@@ -137,10 +137,6 @@ interface UseAxiosOptions<T = any> {
137
137
  * Callback when success is caught.
138
138
  */
139
139
  onSuccess?: (data: T) => void;
140
- /**
141
- * Initial data to use
142
- */
143
- initialData?: T;
144
140
  /**
145
141
  * Sets the state to initialState before executing the promise.
146
142
  */
@@ -150,9 +146,19 @@ interface UseAxiosOptions<T = any> {
150
146
  */
151
147
  onFinish?: () => void;
152
148
  }
153
- declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>, options?: UseAxiosOptions): StrictUseAxiosReturn<T, R, D> & Promise<StrictUseAxiosReturn<T, R, D>>;
154
- declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(url: string, instance?: AxiosInstance, options?: UseAxiosOptions): StrictUseAxiosReturn<T, R, D> & Promise<StrictUseAxiosReturn<T, R, D>>;
155
- declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(url: string, config: AxiosRequestConfig<D>, instance: AxiosInstance, options?: UseAxiosOptions): StrictUseAxiosReturn<T, R, D> & Promise<StrictUseAxiosReturn<T, R, D>>;
149
+ interface UseAxiosOptionsWithInitialData<T> extends UseAxiosOptionsBase<T> {
150
+ /**
151
+ * Initial data
152
+ */
153
+ initialData: T;
154
+ }
155
+ type UseAxiosOptions<T = any> = UseAxiosOptionsBase<T> | UseAxiosOptionsWithInitialData<T>;
156
+ declare function useAxios<T = any, R = AxiosResponse<T>, D = any, O extends UseAxiosOptionsWithInitialData<T> = UseAxiosOptionsWithInitialData<T>>(url: string, config?: AxiosRequestConfig<D>, options?: O): StrictUseAxiosReturn<T, R, D, O> & Promise<StrictUseAxiosReturn<T, R, D, O>>;
157
+ declare function useAxios<T = any, R = AxiosResponse<T>, D = any, O extends UseAxiosOptionsWithInitialData<T> = UseAxiosOptionsWithInitialData<T>>(url: string, instance?: AxiosInstance, options?: O): StrictUseAxiosReturn<T, R, D, O> & Promise<StrictUseAxiosReturn<T, R, D, O>>;
158
+ declare function useAxios<T = any, R = AxiosResponse<T>, D = any, O extends UseAxiosOptionsWithInitialData<T> = UseAxiosOptionsWithInitialData<T>>(url: string, config: AxiosRequestConfig<D>, instance: AxiosInstance, options?: O): StrictUseAxiosReturn<T, R, D, O> & Promise<StrictUseAxiosReturn<T, R, D, O>>;
159
+ declare function useAxios<T = any, R = AxiosResponse<T>, D = any, O extends UseAxiosOptionsBase<T> = UseAxiosOptionsBase<T>>(url: string, config?: AxiosRequestConfig<D>, options?: O): StrictUseAxiosReturn<T, R, D, O> & Promise<StrictUseAxiosReturn<T, R, D, O>>;
160
+ declare function useAxios<T = any, R = AxiosResponse<T>, D = any, O extends UseAxiosOptionsBase<T> = UseAxiosOptionsBase<T>>(url: string, instance?: AxiosInstance, options?: O): StrictUseAxiosReturn<T, R, D, O> & Promise<StrictUseAxiosReturn<T, R, D, O>>;
161
+ declare function useAxios<T = any, R = AxiosResponse<T>, D = any, O extends UseAxiosOptionsBase<T> = UseAxiosOptionsBase<T>>(url: string, config: AxiosRequestConfig<D>, instance: AxiosInstance, options?: O): StrictUseAxiosReturn<T, R, D, O> & Promise<StrictUseAxiosReturn<T, R, D, O>>;
156
162
  declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(config?: AxiosRequestConfig<D>): EasyUseAxiosReturn<T, R, D> & Promise<EasyUseAxiosReturn<T, R, D>>;
157
163
  declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(instance?: AxiosInstance): EasyUseAxiosReturn<T, R, D> & Promise<EasyUseAxiosReturn<T, R, D>>;
158
164
  declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(config?: AxiosRequestConfig<D>, instance?: AxiosInstance): EasyUseAxiosReturn<T, R, D> & Promise<EasyUseAxiosReturn<T, R, D>>;
@@ -387,7 +393,7 @@ type UseNProgressOptions = Partial<NProgressOptions>;
387
393
  */
388
394
  declare function useNProgress(currentProgress?: MaybeRefOrGetter<number | null | undefined>, options?: UseNProgressOptions): {
389
395
  isLoading: vue.WritableComputedRef<boolean, boolean>;
390
- progress: vue.Ref<number | (() => number | null | undefined) | null | undefined, number | vue.Ref<number | null | undefined, number | null | undefined> | vue.ShallowRef<number | null | undefined, number | null | undefined> | vue.WritableComputedRef<number | null | undefined, number | null | undefined> | vue.ComputedRef<number | null | undefined> | (() => number | null | undefined) | null | undefined>;
396
+ progress: vue.Ref<number | null | undefined, number | null | undefined>;
391
397
  start: () => nprogress.NProgress;
392
398
  done: (force?: boolean) => nprogress.NProgress;
393
399
  remove: () => void;
@@ -438,4 +444,4 @@ declare function insertNodeAt(parentElement: Element, element: Element, index: n
438
444
  declare function removeNode(node: Node): void;
439
445
  declare function moveArrayElement<T>(list: MaybeRefOrGetter$1<T[]>, from: number, to: number, e?: Sortable.SortableEvent | null): void;
440
446
 
441
- export { type AsyncValidatorError, type ChangeCaseType, type EasyUseAxiosReturn, type FuseOptions, type StrictUseAxiosReturn, type UseAsyncValidatorExecuteReturn, type UseAsyncValidatorOptions, type UseAsyncValidatorReturn, type UseAxiosOptions, type UseAxiosReturn, type UseDrauuOptions, type UseDrauuReturn, type UseFocusTrapOptions, type UseFocusTrapReturn, type UseFuseOptions, type UseFuseReturn, type UseIDBKeyvalReturn, type UseIDBOptions, type UseJwtOptions, type UseJwtReturn, type UseNProgressOptions, type UseNProgressReturn, type UseSortableOptions, type UseSortableReturn, createCookies, insertNodeAt, moveArrayElement, removeNode, useAsyncValidator, useAxios, useChangeCase, useCookies, useDrauu, useFocusTrap, useFuse, useIDBKeyval, useJwt, useNProgress, useQRCode, useSortable };
447
+ export { type AsyncValidatorError, type ChangeCaseType, type EasyUseAxiosReturn, type FuseOptions, type StrictUseAxiosReturn, type UseAsyncValidatorExecuteReturn, type UseAsyncValidatorOptions, type UseAsyncValidatorReturn, type UseAxiosOptions, type UseAxiosOptionsBase, type UseAxiosOptionsWithInitialData, type UseAxiosReturn, type UseDrauuOptions, type UseDrauuReturn, type UseFocusTrapOptions, type UseFocusTrapReturn, type UseFuseOptions, type UseFuseReturn, type UseIDBKeyvalReturn, type UseIDBOptions, type UseJwtOptions, type UseJwtReturn, type UseNProgressOptions, type UseNProgressReturn, type UseSortableOptions, type UseSortableReturn, createCookies, insertNodeAt, moveArrayElement, removeNode, useAsyncValidator, useAxios, useChangeCase, useCookies, useDrauu, useFocusTrap, useFuse, useIDBKeyval, useJwt, useNProgress, useQRCode, useSortable };