@vueuse/integrations 12.2.0 → 12.3.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 (50) hide show
  1. package/index.cjs +20 -20
  2. package/index.d.cts +19 -13
  3. package/index.d.mts +19 -13
  4. package/index.d.ts +19 -13
  5. package/index.iife.js +20 -20
  6. package/index.iife.min.js +1 -1
  7. package/index.mjs +6 -6
  8. package/package.json +3 -3
  9. package/useAsyncValidator/component.cjs +1 -1
  10. package/useAsyncValidator/component.mjs +2 -2
  11. package/useAsyncValidator.cjs +1 -1
  12. package/useAsyncValidator.iife.js +1 -1
  13. package/useAsyncValidator.iife.min.js +1 -1
  14. package/useAsyncValidator.mjs +2 -2
  15. package/useAxios.cjs +1 -1
  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 +1 -1
  20. package/useAxios.iife.min.js +1 -1
  21. package/useAxios.mjs +1 -1
  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/useFocusTrap.cjs +3 -3
  27. package/useFocusTrap.d.cts +1 -1
  28. package/useFocusTrap.d.mts +1 -1
  29. package/useFocusTrap.d.ts +1 -1
  30. package/useFocusTrap.iife.js +3 -3
  31. package/useFocusTrap.iife.min.js +1 -1
  32. package/useFocusTrap.mjs +4 -4
  33. package/useFuse.cjs +8 -9
  34. package/useFuse.iife.js +10 -10
  35. package/useFuse.iife.min.js +1 -1
  36. package/useFuse.mjs +1 -2
  37. package/useIDBKeyval.cjs +1 -2
  38. package/useIDBKeyval.iife.js +3 -3
  39. package/useIDBKeyval.iife.min.js +1 -1
  40. package/useIDBKeyval.mjs +1 -2
  41. package/useJwt.cjs +2 -3
  42. package/useJwt.iife.js +4 -4
  43. package/useJwt.iife.min.js +1 -1
  44. package/useJwt.mjs +1 -2
  45. package/useSortable/component.cjs +1 -1
  46. package/useSortable/component.mjs +2 -2
  47. package/useSortable.cjs +1 -1
  48. package/useSortable.iife.js +1 -1
  49. package/useSortable.iife.min.js +1 -1
  50. package/useSortable.mjs +2 -2
package/index.cjs CHANGED
@@ -54,7 +54,7 @@ function useAsyncValidator(value, rules, options = {}) {
54
54
  var _a;
55
55
  return ((_a = errorInfo.value) == null ? void 0 : _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;
@@ -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);
@@ -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;
@@ -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 ? void 0 : _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 ? void 0 : _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 }));
498
+ const resolved = vue.toValue(options);
499
+ if ((resolved == null ? void 0 : resolved.matchAllWhenSearchEmpty) && !vue.toValue(search))
500
+ return vue.toValue(data).map((item, index) => ({ item, refIndex: index }));
501
501
  const limit = resolved == null ? void 0 : resolved.resultLimit;
502
- return fuse.value.search(shared.toValue(search), limit ? { limit } : void 0);
502
+ return fuse.value.search(vue.toValue(search), limit ? { limit } : void 0);
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);
@@ -576,8 +576,8 @@ function useJwt(encodedJwt, options = {}) {
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
@@ -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>>;
@@ -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>>;
@@ -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>>;
@@ -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.iife.js CHANGED
@@ -39,7 +39,7 @@
39
39
  var _a;
40
40
  return ((_a = errorInfo.value) == null ? void 0 : _a.fields) || {};
41
41
  });
42
- const validator = vue.computed(() => new AsyncValidatorSchema(shared.toValue(rules)));
42
+ const validator = vue.computed(() => new AsyncValidatorSchema(vue.toValue(rules)));
43
43
  const execute = async () => {
44
44
  isFinished.value = false;
45
45
  pass.value = false;
@@ -113,13 +113,13 @@
113
113
  options = args[args.length - 1] || defaultOptions;
114
114
  }
115
115
  const {
116
- initialData,
117
116
  shallow,
118
117
  onSuccess = shared.noop,
119
118
  onError = shared.noop,
120
119
  immediate,
121
120
  resetOnExecute = false
122
121
  } = options;
122
+ const initialData = options.initialData;
123
123
  const response = vue.shallowRef();
124
124
  const data = (shallow ? vue.shallowRef : vue.ref)(initialData);
125
125
  const isFinished = vue.ref(false);
@@ -211,17 +211,17 @@
211
211
  }, {});
212
212
  function useChangeCase(input, type, options) {
213
213
  const typeRef = vue.computed(() => {
214
- const t = shared.toValue(type);
214
+ const t = vue.toValue(type);
215
215
  if (!changeCaseTransforms[t])
216
216
  throw new Error(`Invalid change case type "${t}"`);
217
217
  return t;
218
218
  });
219
219
  if (typeof input === "function")
220
- return vue.computed(() => changeCaseTransforms[typeRef.value](shared.toValue(input), shared.toValue(options)));
220
+ return vue.computed(() => changeCaseTransforms[typeRef.value](vue.toValue(input), vue.toValue(options)));
221
221
  const text = vue.ref(input);
222
222
  return vue.computed({
223
223
  get() {
224
- return changeCaseTransforms[typeRef.value](text.value, shared.toValue(options));
224
+ return changeCaseTransforms[typeRef.value](text.value, vue.toValue(options));
225
225
  },
226
226
  set(value) {
227
227
  text.value = value;
@@ -413,9 +413,9 @@
413
413
  }
414
414
  };
415
415
  const targets = vue.computed(() => {
416
- const _targets = shared.toValue(target);
417
- return (Array.isArray(_targets) ? _targets : [_targets]).map((el) => {
418
- const _el = shared.toValue(el);
416
+ const _targets = vue.toValue(target);
417
+ return core.toArray(_targets).map((el) => {
418
+ const _el = vue.toValue(el);
419
419
  return typeof _el === "string" ? _el : core.unrefElement(_el);
420
420
  }).filter(shared.notNullish);
421
421
  });
@@ -457,15 +457,15 @@
457
457
  const createFuse = () => {
458
458
  var _a, _b;
459
459
  return new Fuse(
460
- (_a = shared.toValue(data)) != null ? _a : [],
461
- (_b = shared.toValue(options)) == null ? void 0 : _b.fuseOptions
460
+ (_a = vue.toValue(data)) != null ? _a : [],
461
+ (_b = vue.toValue(options)) == null ? void 0 : _b.fuseOptions
462
462
  );
463
463
  };
464
464
  const fuse = vue.ref(createFuse());
465
465
  vue.watch(
466
466
  () => {
467
467
  var _a;
468
- return (_a = shared.toValue(options)) == null ? void 0 : _a.fuseOptions;
468
+ return (_a = vue.toValue(options)) == null ? void 0 : _a.fuseOptions;
469
469
  },
470
470
  () => {
471
471
  fuse.value = createFuse();
@@ -473,18 +473,18 @@
473
473
  { deep: true }
474
474
  );
475
475
  vue.watch(
476
- () => shared.toValue(data),
476
+ () => vue.toValue(data),
477
477
  (newData) => {
478
478
  fuse.value.setCollection(newData);
479
479
  },
480
480
  { deep: true }
481
481
  );
482
482
  const results = vue.computed(() => {
483
- const resolved = shared.toValue(options);
484
- if ((resolved == null ? void 0 : resolved.matchAllWhenSearchEmpty) && !shared.toValue(search))
485
- return shared.toValue(data).map((item, index) => ({ item, refIndex: index }));
483
+ const resolved = vue.toValue(options);
484
+ if ((resolved == null ? void 0 : resolved.matchAllWhenSearchEmpty) && !vue.toValue(search))
485
+ return vue.toValue(data).map((item, index) => ({ item, refIndex: index }));
486
486
  const limit = resolved == null ? void 0 : resolved.resultLimit;
487
- return fuse.value.search(shared.toValue(search), limit ? { limit } : void 0);
487
+ return fuse.value.search(vue.toValue(search), limit ? { limit } : void 0);
488
488
  });
489
489
  return {
490
490
  fuse,
@@ -504,7 +504,7 @@
504
504
  } = options;
505
505
  const isFinished = vue.ref(false);
506
506
  const data = (shallow ? vue.shallowRef : vue.ref)(initialValue);
507
- const rawInit = shared.toValue(initialValue);
507
+ const rawInit = vue.toValue(initialValue);
508
508
  async function read() {
509
509
  try {
510
510
  const rawValue = await idbKeyval.get(key);
@@ -561,8 +561,8 @@
561
561
  return fallbackValue;
562
562
  }
563
563
  };
564
- const header = vue.computed(() => decodeWithFallback(shared.toValue(encodedJwt), { header: true }));
565
- const payload = vue.computed(() => decodeWithFallback(shared.toValue(encodedJwt)));
564
+ const header = vue.computed(() => decodeWithFallback(vue.toValue(encodedJwt), { header: true }));
565
+ const payload = vue.computed(() => decodeWithFallback(vue.toValue(encodedJwt)));
566
566
  return {
567
567
  header,
568
568
  payload
@@ -659,7 +659,7 @@
659
659
  insertNodeAt(e.from, e.item, from);
660
660
  }
661
661
  const _valueIsRef = vue.isRef(list);
662
- const array = _valueIsRef ? [...core.toValue(list)] : core.toValue(list);
662
+ const array = _valueIsRef ? [...vue.toValue(list)] : vue.toValue(list);
663
663
  if (to >= 0 && to < array.length) {
664
664
  const element = array.splice(from, 1)[0];
665
665
  vue.nextTick(() => {
package/index.iife.min.js CHANGED
@@ -1 +1 @@
1
- (function(w,f,U,a,L,$,k,y,K,X,Y,P,Z,b,x,ee){"use strict";function te(t){var o=Object.create(null);return t&&Object.keys(t).forEach(function(e){if(e!=="default"){var n=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(o,e,n.get?n:{enumerable:!0,get:function(){return t[e]}})}}),o.default=t,Object.freeze(o)}var ne=te($);const oe=U.default||U;function ae(t,o,e={}){const{validateOption:n={},immediate:l=!0,manual:s=!1}=e,u=f.toRef(t),c=a.shallowRef(null),r=a.ref(!0),v=a.ref(!l||s),m=a.computed(()=>{var i;return((i=c.value)==null?void 0:i.errors)||[]}),C=a.computed(()=>{var i;return((i=c.value)==null?void 0:i.fields)||{}}),h=a.computed(()=>new oe(f.toValue(o))),g=async()=>{r.value=!1,v.value=!1;try{await h.value.validate(u.value,n),v.value=!0,c.value=null}catch(i){c.value=i}finally{r.value=!0}return{pass:v.value,errorInfo:c.value,errors:m.value,errorFields:C.value}};s||a.watch([u,h],()=>g(),{immediate:l,deep:!0});const V={isFinished:r,pass:v,errors:m,errorInfo:c,errorFields:C,execute:g};function A(){return new Promise((i,E)=>{f.until(r).toBe(!0).then(()=>i(V)).catch(D=>E(D))})}return{...V,then(i,E){return A().then(i,E)}}}function le(...t){const o=typeof t[0]=="string"?t[0]:void 0,e=typeof o=="string"?1:0,n={immediate:!!e,shallow:!0,abortPrevious:!0};let l={},s=L,u=n;const c=p=>!!p?.request;t.length>0+e&&(c(t[0+e])?s=t[0+e]:l=t[0+e]),t.length>1+e&&c(t[1+e])&&(s=t[1+e]),(t.length===2+e&&!c(t[1+e])||t.length===3+e)&&(u=t[t.length-1]||n);const{initialData:r,shallow:v,onSuccess:m=f.noop,onError:C=f.noop,immediate:h,resetOnExecute:g=!1}=u,V=a.shallowRef(),A=(v?a.shallowRef:a.ref)(r),i=a.ref(!1),E=a.ref(!1),D=a.ref(!1),_=a.shallowRef();let S=new AbortController;const F=p=>{i.value||!E.value||(S.abort(p),S=new AbortController,D.value=!0,E.value=!1,i.value=!1)},d=p=>{E.value=p,i.value=!p},R=()=>{g&&(A.value=r)},Q=()=>new Promise((p,I)=>{f.until(i).toBe(!0).then(()=>_.value?I(_.value):p(q))}),H={then:(...p)=>Q().then(...p),catch:(...p)=>Q().catch(...p)};let j=0;const z=(p=o,I={})=>{_.value=void 0;const J=typeof p=="string"?p:o??I.url;if(J===void 0)return _.value=new L.AxiosError(L.AxiosError.ERR_INVALID_URL),i.value=!0,H;R(),u.abortPrevious!==!1&&F(),d(!0),j+=1;const we=j;return D.value=!1,s(J,{...l,...typeof p=="object"?p:I,signal:S.signal}).then(O=>{if(D.value)return;V.value=O;const M=O.data;A.value=M,m(M)}).catch(O=>{_.value=O,C(O)}).finally(()=>{var O;(O=u.onFinish)==null||O.call(u),we===j&&d(!1)}),H};h&&o&&z();const q={response:V,data:A,error:_,isFinished:i,isLoading:E,cancel:F,isAborted:D,isCanceled:D,abort:F,execute:z};return{...q,...H}}const N=Object.entries(ne).filter(([t,o])=>typeof o=="function"&&t.endsWith("Case")).reduce((t,[o,e])=>(t[o]=e,t),{});function ue(t,o,e){const n=a.computed(()=>{const s=f.toValue(o);if(!N[s])throw new Error(`Invalid change case type "${s}"`);return s});if(typeof t=="function")return a.computed(()=>N[n.value](f.toValue(t),f.toValue(e)));const l=a.ref(t);return a.computed({get(){return N[n.value](l.value,f.toValue(e))},set(s){l.value=s}})}function re(t){const o=new k(t?t.headers.cookie:null);return(e,{doNotParse:n=!1,autoUpdateDependencies:l=!1}={})=>T(e,{doNotParse:n,autoUpdateDependencies:l},o)}function T(t,{doNotParse:o=!1,autoUpdateDependencies:e=!1}={},n=new k){const l=e?[...t||[]]:t;let s=n.getAll({doNotParse:!0});const u=a.ref(0),c=()=>{const r=n.getAll({doNotParse:!0});se(l||null,r,s)&&u.value++,s=r};return n.addChangeListener(c),f.tryOnScopeDispose(()=>{n.removeChangeListener(c)}),{get:(...r)=>(e&&l&&!l.includes(r[0])&&l.push(r[0]),u.value,n.get(r[0],{doNotParse:o,...r[1]})),getAll:(...r)=>(u.value,n.getAll({doNotParse:o,...r[0]})),set:(...r)=>n.set(...r),remove:(...r)=>n.remove(...r),addChangeListener:(...r)=>n.addChangeListener(...r),removeChangeListener:(...r)=>n.removeChangeListener(...r)}}function se(t,o,e){if(!t)return!0;for(const n of t)if(o[n]!==e[n])return!0;return!1}function ce(t,o){const e=a.ref();let n=[];const l=y.createEventHook(),s=y.createEventHook(),u=y.createEventHook(),c=y.createEventHook(),r=y.createEventHook(),v=a.ref(!1),m=a.ref(!1),C=a.ref(!1),h=a.ref(!1),g=a.ref({color:"black",size:3,arrowEnd:!1,cornerRadius:0,dasharray:void 0,fill:"transparent",mode:"draw",...o?.brush});a.watch(g,()=>{const d=e.value;d&&(d.brush=g.value,d.mode=g.value.mode)},{deep:!0});const V=()=>{var d;return(d=e.value)==null?void 0:d.undo()},A=()=>{var d;return(d=e.value)==null?void 0:d.redo()},i=()=>{var d;return(d=e.value)==null?void 0:d.clear()},E=()=>{var d;return(d=e.value)==null?void 0:d.cancel()},D=d=>{var R;return(R=e.value)==null?void 0:R.load(d)},_=()=>{var d;return(d=e.value)==null?void 0:d.dump()},S=()=>{var d;n.forEach(R=>R()),(d=e.value)==null||d.unmount()},F=()=>{e.value&&(v.value=e.value.canUndo(),m.value=e.value.canRedo(),C.value=e.value.altPressed,h.value=e.value.shiftPressed)};return a.watch(()=>y.unrefElement(t),d=>{!d||typeof SVGSVGElement>"u"||!(d instanceof SVGSVGElement)||(e.value&&S(),e.value=K.createDrauu({el:d,...o}),F(),n=[e.value.on("canceled",()=>s.trigger()),e.value.on("committed",R=>u.trigger(R)),e.value.on("start",()=>c.trigger()),e.value.on("end",()=>r.trigger()),e.value.on("changed",()=>{F(),l.trigger()})])},{flush:"post"}),f.tryOnScopeDispose(()=>S()),{drauuInstance:e,load:D,dump:_,clear:i,cancel:E,undo:V,redo:A,canUndo:v,canRedo:m,brush:g,onChanged:l.on,onCommitted:u.on,onStart:c.on,onEnd:r.on,onCanceled:s.on}}function ie(t,o={}){let e;const{immediate:n,...l}=o,s=a.ref(!1),u=a.ref(!1),c=h=>e&&e.activate(h),r=h=>e&&e.deactivate(h),v=()=>{e&&(e.pause(),u.value=!0)},m=()=>{e&&(e.unpause(),u.value=!1)},C=a.computed(()=>{const h=f.toValue(t);return(Array.isArray(h)?h:[h]).map(g=>{const V=f.toValue(g);return typeof V=="string"?V:y.unrefElement(V)}).filter(f.notNullish)});return a.watch(C,h=>{h.length&&(e=X.createFocusTrap(h,{...l,onActivate(){s.value=!0,o.onActivate&&o.onActivate()},onDeactivate(){s.value=!1,o.onDeactivate&&o.onDeactivate()}}),n&&c())},{flush:"post"}),y.tryOnScopeDispose(()=>r()),{hasFocus:s,isPaused:u,activate:c,deactivate:r,pause:v,unpause:m}}function fe(t,o,e){const n=()=>{var u,c;return new Y((u=f.toValue(o))!=null?u:[],(c=f.toValue(e))==null?void 0:c.fuseOptions)},l=a.ref(n());a.watch(()=>{var u;return(u=f.toValue(e))==null?void 0:u.fuseOptions},()=>{l.value=n()},{deep:!0}),a.watch(()=>f.toValue(o),u=>{l.value.setCollection(u)},{deep:!0});const s=a.computed(()=>{const u=f.toValue(e);if(u?.matchAllWhenSearchEmpty&&!f.toValue(t))return f.toValue(o).map((r,v)=>({item:r,refIndex:v}));const c=u?.resultLimit;return l.value.search(f.toValue(t),c?{limit:c}:void 0)});return{fuse:l,results:s}}function de(t,o,e={}){const{flush:n="pre",deep:l=!0,shallow:s=!1,onError:u=i=>{console.error(i)},writeDefaults:c=!0}=e,r=a.ref(!1),v=(s?a.shallowRef:a.ref)(o),m=f.toValue(o);async function C(){try{const i=await P.get(t);i===void 0?m!=null&&c&&await P.set(t,m):v.value=i}catch(i){u(i)}r.value=!0}C();async function h(){try{v.value==null?await P.del(t):await P.update(t,()=>a.toRaw(v.value))}catch(i){u(i)}}const{pause:g,resume:V}=y.watchPausable(v,()=>h(),{flush:n,deep:l});async function A(i){g(),v.value=i,await h(),V()}return{set:A,isFinished:r,data:v}}function ve(t,o={}){const{onError:e,fallbackValue:n=null}=o,l=(c,r)=>{try{return Z.jwtDecode(c,r)}catch(v){return e?.(v),n}},s=a.computed(()=>l(f.toValue(t),{header:!0})),u=a.computed(()=>l(f.toValue(t)));return{header:s,payload:u}}function me(t=null,o){const e=a.ref(t),n=a.computed({set:s=>s?b.start():b.done(),get:()=>typeof e.value=="number"&&e.value<1});o&&b.configure(o);const l=b.set;return b.set=s=>(e.value=s,l.call(b,s)),a.watchEffect(()=>{typeof e.value=="number"&&f.isClient&&l.call(b,e.value)}),f.tryOnScopeDispose(b.remove),{isLoading:n,progress:e,start:b.start,done:b.done,remove:()=>{e.value=null,b.remove()}}}function he(t,o){const e=f.toRef(t),n=a.ref("");return a.watch(e,async l=>{e.value&&f.isClient&&(n.value=await x.toDataURL(l,o))},{immediate:!0}),n}function pe(t,o,e={}){let n;const{document:l=y.defaultDocument,...s}=e,u={onUpdate:m=>{G(o,m.oldIndex,m.newIndex,m)}},c=()=>{const m=typeof t=="string"?l?.querySelector(t):y.unrefElement(t);!m||n!==void 0||(n=new ee(m,{...u,...s}))},r=()=>{n?.destroy(),n=void 0},v=(m,C)=>{if(C!==void 0)n?.option(m,C);else return n?.option(m)};return y.tryOnMounted(c),y.tryOnScopeDispose(r),{stop:r,start:c,option:v}}function B(t,o,e){const n=t.children[e];t.insertBefore(o,n)}function W(t){t.parentNode&&t.parentNode.removeChild(t)}function G(t,o,e,n=null){n!=null&&(W(n.item),B(n.from,n.item,o));const l=a.isRef(t),s=l?[...y.toValue(t)]:y.toValue(t);if(e>=0&&e<s.length){const u=s.splice(o,1)[0];a.nextTick(()=>{s.splice(e,0,u),l&&(t.value=s)})}}w.createCookies=re,w.insertNodeAt=B,w.moveArrayElement=G,w.removeNode=W,w.useAsyncValidator=ae,w.useAxios=le,w.useChangeCase=ue,w.useCookies=T,w.useDrauu=ce,w.useFocusTrap=ie,w.useFuse=fe,w.useIDBKeyval=de,w.useJwt=ve,w.useNProgress=me,w.useQRCode=he,w.useSortable=pe})(this.VueUse=this.VueUse||{},VueUse,AsyncValidator,Vue,axios,changeCase,UniversalCookie,VueUse,Drauu,focusTrap,Fuse,idbKeyval,jwt_decode,nprogress,QRCode,Sortable);
1
+ (function(p,V,U,n,L,$,k,w,K,X,Y,P,Z,b,x,ee){"use strict";function te(t){var o=Object.create(null);return t&&Object.keys(t).forEach(function(e){if(e!=="default"){var a=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(o,e,a.get?a:{enumerable:!0,get:function(){return t[e]}})}}),o.default=t,Object.freeze(o)}var ne=te($);const ae=U.default||U;function oe(t,o,e={}){const{validateOption:a={},immediate:r=!0,manual:u=!1}=e,l=V.toRef(t),c=n.shallowRef(null),s=n.ref(!0),d=n.ref(!r||u),v=n.computed(()=>{var i;return((i=c.value)==null?void 0:i.errors)||[]}),C=n.computed(()=>{var i;return((i=c.value)==null?void 0:i.fields)||{}}),h=n.computed(()=>new ae(n.toValue(o))),y=async()=>{s.value=!1,d.value=!1;try{await h.value.validate(l.value,a),d.value=!0,c.value=null}catch(i){c.value=i}finally{s.value=!0}return{pass:d.value,errorInfo:c.value,errors:v.value,errorFields:C.value}};u||n.watch([l,h],()=>y(),{immediate:r,deep:!0});const g={isFinished:s,pass:d,errors:v,errorInfo:c,errorFields:C,execute:y};function A(){return new Promise((i,E)=>{V.until(s).toBe(!0).then(()=>i(g)).catch(D=>E(D))})}return{...g,then(i,E){return A().then(i,E)}}}function le(...t){const o=typeof t[0]=="string"?t[0]:void 0,e=typeof o=="string"?1:0,a={immediate:!!e,shallow:!0,abortPrevious:!0};let r={},u=L,l=a;const c=m=>!!m?.request;t.length>0+e&&(c(t[0+e])?u=t[0+e]:r=t[0+e]),t.length>1+e&&c(t[1+e])&&(u=t[1+e]),(t.length===2+e&&!c(t[1+e])||t.length===3+e)&&(l=t[t.length-1]||a);const{shallow:s,onSuccess:d=V.noop,onError:v=V.noop,immediate:C,resetOnExecute:h=!1}=l,y=l.initialData,g=n.shallowRef(),A=(s?n.shallowRef:n.ref)(y),i=n.ref(!1),E=n.ref(!1),D=n.ref(!1),_=n.shallowRef();let S=new AbortController;const F=m=>{i.value||!E.value||(S.abort(m),S=new AbortController,D.value=!0,E.value=!1,i.value=!1)},f=m=>{E.value=m,i.value=!m},R=()=>{h&&(A.value=y)},Q=()=>new Promise((m,I)=>{V.until(i).toBe(!0).then(()=>_.value?I(_.value):m(q))}),H={then:(...m)=>Q().then(...m),catch:(...m)=>Q().catch(...m)};let j=0;const z=(m=o,I={})=>{_.value=void 0;const J=typeof m=="string"?m:o??I.url;if(J===void 0)return _.value=new L.AxiosError(L.AxiosError.ERR_INVALID_URL),i.value=!0,H;R(),l.abortPrevious!==!1&&F(),f(!0),j+=1;const we=j;return D.value=!1,u(J,{...r,...typeof m=="object"?m:I,signal:S.signal}).then(O=>{if(D.value)return;g.value=O;const M=O.data;A.value=M,d(M)}).catch(O=>{_.value=O,v(O)}).finally(()=>{var O;(O=l.onFinish)==null||O.call(l),we===j&&f(!1)}),H};C&&o&&z();const q={response:g,data:A,error:_,isFinished:i,isLoading:E,cancel:F,isAborted:D,isCanceled:D,abort:F,execute:z};return{...q,...H}}const N=Object.entries(ne).filter(([t,o])=>typeof o=="function"&&t.endsWith("Case")).reduce((t,[o,e])=>(t[o]=e,t),{});function re(t,o,e){const a=n.computed(()=>{const u=n.toValue(o);if(!N[u])throw new Error(`Invalid change case type "${u}"`);return u});if(typeof t=="function")return n.computed(()=>N[a.value](n.toValue(t),n.toValue(e)));const r=n.ref(t);return n.computed({get(){return N[a.value](r.value,n.toValue(e))},set(u){r.value=u}})}function ue(t){const o=new k(t?t.headers.cookie:null);return(e,{doNotParse:a=!1,autoUpdateDependencies:r=!1}={})=>T(e,{doNotParse:a,autoUpdateDependencies:r},o)}function T(t,{doNotParse:o=!1,autoUpdateDependencies:e=!1}={},a=new k){const r=e?[...t||[]]:t;let u=a.getAll({doNotParse:!0});const l=n.ref(0),c=()=>{const s=a.getAll({doNotParse:!0});se(r||null,s,u)&&l.value++,u=s};return a.addChangeListener(c),V.tryOnScopeDispose(()=>{a.removeChangeListener(c)}),{get:(...s)=>(e&&r&&!r.includes(s[0])&&r.push(s[0]),l.value,a.get(s[0],{doNotParse:o,...s[1]})),getAll:(...s)=>(l.value,a.getAll({doNotParse:o,...s[0]})),set:(...s)=>a.set(...s),remove:(...s)=>a.remove(...s),addChangeListener:(...s)=>a.addChangeListener(...s),removeChangeListener:(...s)=>a.removeChangeListener(...s)}}function se(t,o,e){if(!t)return!0;for(const a of t)if(o[a]!==e[a])return!0;return!1}function ce(t,o){const e=n.ref();let a=[];const r=w.createEventHook(),u=w.createEventHook(),l=w.createEventHook(),c=w.createEventHook(),s=w.createEventHook(),d=n.ref(!1),v=n.ref(!1),C=n.ref(!1),h=n.ref(!1),y=n.ref({color:"black",size:3,arrowEnd:!1,cornerRadius:0,dasharray:void 0,fill:"transparent",mode:"draw",...o?.brush});n.watch(y,()=>{const f=e.value;f&&(f.brush=y.value,f.mode=y.value.mode)},{deep:!0});const g=()=>{var f;return(f=e.value)==null?void 0:f.undo()},A=()=>{var f;return(f=e.value)==null?void 0:f.redo()},i=()=>{var f;return(f=e.value)==null?void 0:f.clear()},E=()=>{var f;return(f=e.value)==null?void 0:f.cancel()},D=f=>{var R;return(R=e.value)==null?void 0:R.load(f)},_=()=>{var f;return(f=e.value)==null?void 0:f.dump()},S=()=>{var f;a.forEach(R=>R()),(f=e.value)==null||f.unmount()},F=()=>{e.value&&(d.value=e.value.canUndo(),v.value=e.value.canRedo(),C.value=e.value.altPressed,h.value=e.value.shiftPressed)};return n.watch(()=>w.unrefElement(t),f=>{!f||typeof SVGSVGElement>"u"||!(f instanceof SVGSVGElement)||(e.value&&S(),e.value=K.createDrauu({el:f,...o}),F(),a=[e.value.on("canceled",()=>u.trigger()),e.value.on("committed",R=>l.trigger(R)),e.value.on("start",()=>c.trigger()),e.value.on("end",()=>s.trigger()),e.value.on("changed",()=>{F(),r.trigger()})])},{flush:"post"}),V.tryOnScopeDispose(()=>S()),{drauuInstance:e,load:D,dump:_,clear:i,cancel:E,undo:g,redo:A,canUndo:d,canRedo:v,brush:y,onChanged:r.on,onCommitted:l.on,onStart:c.on,onEnd:s.on,onCanceled:u.on}}function ie(t,o={}){let e;const{immediate:a,...r}=o,u=n.ref(!1),l=n.ref(!1),c=h=>e&&e.activate(h),s=h=>e&&e.deactivate(h),d=()=>{e&&(e.pause(),l.value=!0)},v=()=>{e&&(e.unpause(),l.value=!1)},C=n.computed(()=>{const h=n.toValue(t);return w.toArray(h).map(y=>{const g=n.toValue(y);return typeof g=="string"?g:w.unrefElement(g)}).filter(V.notNullish)});return n.watch(C,h=>{h.length&&(e=X.createFocusTrap(h,{...r,onActivate(){u.value=!0,o.onActivate&&o.onActivate()},onDeactivate(){u.value=!1,o.onDeactivate&&o.onDeactivate()}}),a&&c())},{flush:"post"}),w.tryOnScopeDispose(()=>s()),{hasFocus:u,isPaused:l,activate:c,deactivate:s,pause:d,unpause:v}}function fe(t,o,e){const a=()=>{var l,c;return new Y((l=n.toValue(o))!=null?l:[],(c=n.toValue(e))==null?void 0:c.fuseOptions)},r=n.ref(a());n.watch(()=>{var l;return(l=n.toValue(e))==null?void 0:l.fuseOptions},()=>{r.value=a()},{deep:!0}),n.watch(()=>n.toValue(o),l=>{r.value.setCollection(l)},{deep:!0});const u=n.computed(()=>{const l=n.toValue(e);if(l?.matchAllWhenSearchEmpty&&!n.toValue(t))return n.toValue(o).map((s,d)=>({item:s,refIndex:d}));const c=l?.resultLimit;return r.value.search(n.toValue(t),c?{limit:c}:void 0)});return{fuse:r,results:u}}function de(t,o,e={}){const{flush:a="pre",deep:r=!0,shallow:u=!1,onError:l=i=>{console.error(i)},writeDefaults:c=!0}=e,s=n.ref(!1),d=(u?n.shallowRef:n.ref)(o),v=n.toValue(o);async function C(){try{const i=await P.get(t);i===void 0?v!=null&&c&&await P.set(t,v):d.value=i}catch(i){l(i)}s.value=!0}C();async function h(){try{d.value==null?await P.del(t):await P.update(t,()=>n.toRaw(d.value))}catch(i){l(i)}}const{pause:y,resume:g}=w.watchPausable(d,()=>h(),{flush:a,deep:r});async function A(i){y(),d.value=i,await h(),g()}return{set:A,isFinished:s,data:d}}function ve(t,o={}){const{onError:e,fallbackValue:a=null}=o,r=(c,s)=>{try{return Z.jwtDecode(c,s)}catch(d){return e?.(d),a}},u=n.computed(()=>r(n.toValue(t),{header:!0})),l=n.computed(()=>r(n.toValue(t)));return{header:u,payload:l}}function he(t=null,o){const e=n.ref(t),a=n.computed({set:u=>u?b.start():b.done(),get:()=>typeof e.value=="number"&&e.value<1});o&&b.configure(o);const r=b.set;return b.set=u=>(e.value=u,r.call(b,u)),n.watchEffect(()=>{typeof e.value=="number"&&V.isClient&&r.call(b,e.value)}),V.tryOnScopeDispose(b.remove),{isLoading:a,progress:e,start:b.start,done:b.done,remove:()=>{e.value=null,b.remove()}}}function me(t,o){const e=V.toRef(t),a=n.ref("");return n.watch(e,async r=>{e.value&&V.isClient&&(a.value=await x.toDataURL(r,o))},{immediate:!0}),a}function pe(t,o,e={}){let a;const{document:r=w.defaultDocument,...u}=e,l={onUpdate:v=>{G(o,v.oldIndex,v.newIndex,v)}},c=()=>{const v=typeof t=="string"?r?.querySelector(t):w.unrefElement(t);!v||a!==void 0||(a=new ee(v,{...l,...u}))},s=()=>{a?.destroy(),a=void 0},d=(v,C)=>{if(C!==void 0)a?.option(v,C);else return a?.option(v)};return w.tryOnMounted(c),w.tryOnScopeDispose(s),{stop:s,start:c,option:d}}function B(t,o,e){const a=t.children[e];t.insertBefore(o,a)}function W(t){t.parentNode&&t.parentNode.removeChild(t)}function G(t,o,e,a=null){a!=null&&(W(a.item),B(a.from,a.item,o));const r=n.isRef(t),u=r?[...n.toValue(t)]:n.toValue(t);if(e>=0&&e<u.length){const l=u.splice(o,1)[0];n.nextTick(()=>{u.splice(e,0,l),r&&(t.value=u)})}}p.createCookies=ue,p.insertNodeAt=B,p.moveArrayElement=G,p.removeNode=W,p.useAsyncValidator=oe,p.useAxios=le,p.useChangeCase=re,p.useCookies=T,p.useDrauu=ce,p.useFocusTrap=ie,p.useFuse=fe,p.useIDBKeyval=de,p.useJwt=ve,p.useNProgress=he,p.useQRCode=me,p.useSortable=pe})(this.VueUse=this.VueUse||{},VueUse,AsyncValidator,Vue,axios,changeCase,UniversalCookie,VueUse,Drauu,focusTrap,Fuse,idbKeyval,jwt_decode,nprogress,QRCode,Sortable);
package/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
- import { toRef, toValue, until, noop, tryOnScopeDispose, notNullish, isClient } from '@vueuse/shared';
1
+ import { toRef, until, noop, tryOnScopeDispose, notNullish, isClient } from '@vueuse/shared';
2
2
  import Schema from 'async-validator';
3
- import { shallowRef, ref, computed, watch, toRaw, watchEffect, isRef, nextTick } from 'vue';
3
+ import { shallowRef, ref, computed, toValue, watch, toRaw, watchEffect, isRef, nextTick } from 'vue';
4
4
  import axios, { AxiosError } from 'axios';
5
5
  import * as changeCase from 'change-case';
6
6
  import Cookie from 'universal-cookie';
7
- import { createEventHook, unrefElement, tryOnScopeDispose as tryOnScopeDispose$1, watchPausable, tryOnMounted, toValue as toValue$1, defaultDocument } from '@vueuse/core';
7
+ import { createEventHook, unrefElement, toArray, tryOnScopeDispose as tryOnScopeDispose$1, watchPausable, tryOnMounted, defaultDocument } from '@vueuse/core';
8
8
  import { createDrauu } from 'drauu';
9
9
  import { createFocusTrap } from 'focus-trap';
10
10
  import Fuse from 'fuse.js';
@@ -107,13 +107,13 @@ function useAxios(...args) {
107
107
  options = args[args.length - 1] || defaultOptions;
108
108
  }
109
109
  const {
110
- initialData,
111
110
  shallow,
112
111
  onSuccess = noop,
113
112
  onError = noop,
114
113
  immediate,
115
114
  resetOnExecute = false
116
115
  } = options;
116
+ const initialData = options.initialData;
117
117
  const response = shallowRef();
118
118
  const data = (shallow ? shallowRef : ref)(initialData);
119
119
  const isFinished = ref(false);
@@ -408,7 +408,7 @@ function useFocusTrap(target, options = {}) {
408
408
  };
409
409
  const targets = computed(() => {
410
410
  const _targets = toValue(target);
411
- return (Array.isArray(_targets) ? _targets : [_targets]).map((el) => {
411
+ return toArray(_targets).map((el) => {
412
412
  const _el = toValue(el);
413
413
  return typeof _el === "string" ? _el : unrefElement(_el);
414
414
  }).filter(notNullish);
@@ -653,7 +653,7 @@ function moveArrayElement(list, from, to, e = null) {
653
653
  insertNodeAt(e.from, e.item, from);
654
654
  }
655
655
  const _valueIsRef = isRef(list);
656
- const array = _valueIsRef ? [...toValue$1(list)] : toValue$1(list);
656
+ const array = _valueIsRef ? [...toValue(list)] : toValue(list);
657
657
  if (to >= 0 && to < array.length) {
658
658
  const element = array.splice(from, 1)[0];
659
659
  nextTick(() => {