@vueuse/integrations 12.2.0-beta.4 → 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.
- package/index.cjs +20 -20
- package/index.d.cts +19 -13
- package/index.d.mts +19 -13
- package/index.d.ts +19 -13
- package/index.iife.js +20 -20
- package/index.iife.min.js +1 -1
- package/index.mjs +6 -6
- package/package.json +3 -3
- package/useAsyncValidator/component.cjs +1 -1
- package/useAsyncValidator/component.mjs +2 -2
- package/useAsyncValidator.cjs +1 -1
- package/useAsyncValidator.iife.js +1 -1
- package/useAsyncValidator.iife.min.js +1 -1
- package/useAsyncValidator.mjs +2 -2
- package/useAxios.cjs +1 -1
- package/useAxios.d.cts +19 -13
- package/useAxios.d.mts +19 -13
- package/useAxios.d.ts +19 -13
- package/useAxios.iife.js +1 -1
- package/useAxios.iife.min.js +1 -1
- package/useAxios.mjs +1 -1
- package/useChangeCase.cjs +3 -4
- package/useChangeCase.iife.js +5 -5
- package/useChangeCase.iife.min.js +1 -1
- package/useChangeCase.mjs +1 -2
- package/useFocusTrap.cjs +3 -3
- package/useFocusTrap.d.cts +1 -1
- package/useFocusTrap.d.mts +1 -1
- package/useFocusTrap.d.ts +1 -1
- package/useFocusTrap.iife.js +3 -3
- package/useFocusTrap.iife.min.js +1 -1
- package/useFocusTrap.mjs +4 -4
- package/useFuse.cjs +8 -9
- package/useFuse.iife.js +10 -10
- package/useFuse.iife.min.js +1 -1
- package/useFuse.mjs +1 -2
- package/useIDBKeyval.cjs +1 -2
- package/useIDBKeyval.iife.js +3 -3
- package/useIDBKeyval.iife.min.js +1 -1
- package/useIDBKeyval.mjs +1 -2
- package/useJwt.cjs +2 -3
- package/useJwt.iife.js +4 -4
- package/useJwt.iife.min.js +1 -1
- package/useJwt.mjs +1 -2
- package/useSortable/component.cjs +1 -1
- package/useSortable/component.mjs +2 -2
- package/useSortable.cjs +1 -1
- package/useSortable.iife.js +1 -1
- package/useSortable.iife.min.js +1 -1
- 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(
|
|
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 =
|
|
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](
|
|
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,
|
|
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 =
|
|
432
|
-
return
|
|
433
|
-
const _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 =
|
|
476
|
-
(_b =
|
|
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 =
|
|
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
|
-
() =>
|
|
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 =
|
|
499
|
-
if ((resolved == null ? void 0 : resolved.matchAllWhenSearchEmpty) && !
|
|
500
|
-
return
|
|
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(
|
|
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 =
|
|
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(
|
|
580
|
-
const payload = vue.computed(() => decodeWithFallback(
|
|
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 ? [...
|
|
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
|
|
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
|
|
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
|
-
|
|
154
|
-
|
|
155
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
154
|
-
|
|
155
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
154
|
-
|
|
155
|
-
|
|
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(
|
|
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 =
|
|
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](
|
|
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,
|
|
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 =
|
|
417
|
-
return
|
|
418
|
-
const _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 =
|
|
461
|
-
(_b =
|
|
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 =
|
|
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
|
-
() =>
|
|
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 =
|
|
484
|
-
if ((resolved == null ? void 0 : resolved.matchAllWhenSearchEmpty) && !
|
|
485
|
-
return
|
|
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(
|
|
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 =
|
|
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(
|
|
565
|
-
const payload = vue.computed(() => decodeWithFallback(
|
|
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 ? [...
|
|
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(
|
|
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,
|
|
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,
|
|
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 (
|
|
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
|
|
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(() => {
|