@vueuse/integrations 10.0.0-beta.0 → 10.0.0-beta.2
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 +31 -12
- package/index.d.ts +24 -2
- package/index.iife.js +31 -12
- package/index.iife.min.js +1 -1
- package/index.mjs +33 -14
- package/package.json +3 -3
- package/useAsyncValidator/component.cjs +26 -11
- package/useAsyncValidator/component.mjs +28 -13
- package/useAsyncValidator.cjs +26 -11
- package/useAsyncValidator.d.ts +20 -2
- package/useAsyncValidator.iife.js +26 -11
- package/useAsyncValidator.iife.min.js +1 -1
- package/useAsyncValidator.mjs +28 -13
- package/useAxios.cjs +5 -1
- package/useAxios.d.ts +4 -0
- package/useAxios.iife.js +5 -1
- package/useAxios.iife.min.js +1 -1
- package/useAxios.mjs +5 -1
package/index.cjs
CHANGED
|
@@ -37,9 +37,15 @@ var __spreadValues$6 = (a, b) => {
|
|
|
37
37
|
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
|
38
38
|
const AsyncValidatorSchema = Schema.default || Schema;
|
|
39
39
|
function useAsyncValidator(value, rules, options = {}) {
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
const {
|
|
41
|
+
validateOption = {},
|
|
42
|
+
immediate = true,
|
|
43
|
+
manual = false
|
|
44
|
+
} = options;
|
|
45
|
+
const valueRef = shared.resolveRef(value);
|
|
46
|
+
const errorInfo = vueDemi.shallowRef(null);
|
|
47
|
+
const isFinished = vueDemi.ref(true);
|
|
48
|
+
const pass = vueDemi.ref(!immediate || manual);
|
|
43
49
|
const errors = vueDemi.computed(() => {
|
|
44
50
|
var _a;
|
|
45
51
|
return ((_a = errorInfo.value) == null ? void 0 : _a.errors) || [];
|
|
@@ -48,13 +54,12 @@ function useAsyncValidator(value, rules, options = {}) {
|
|
|
48
54
|
var _a;
|
|
49
55
|
return ((_a = errorInfo.value) == null ? void 0 : _a.fields) || {};
|
|
50
56
|
});
|
|
51
|
-
const
|
|
52
|
-
|
|
57
|
+
const validator = vueDemi.computed(() => new AsyncValidatorSchema(shared.resolveUnref(rules)));
|
|
58
|
+
const execute = async () => {
|
|
53
59
|
isFinished.value = false;
|
|
54
60
|
pass.value = false;
|
|
55
|
-
const validator = new AsyncValidatorSchema(shared.resolveUnref(rules));
|
|
56
61
|
try {
|
|
57
|
-
await validator.validate(
|
|
62
|
+
await validator.value.validate(valueRef.value, validateOption);
|
|
58
63
|
pass.value = true;
|
|
59
64
|
errorInfo.value = null;
|
|
60
65
|
} catch (err) {
|
|
@@ -62,13 +67,23 @@ function useAsyncValidator(value, rules, options = {}) {
|
|
|
62
67
|
} finally {
|
|
63
68
|
isFinished.value = true;
|
|
64
69
|
}
|
|
65
|
-
|
|
70
|
+
return {
|
|
71
|
+
pass: pass.value,
|
|
72
|
+
errorInfo: errorInfo.value,
|
|
73
|
+
errors: errors.value,
|
|
74
|
+
errorFields: errorFields.value
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
if (!manual) {
|
|
78
|
+
vueDemi.watch([valueRef, validator], () => execute(), { immediate, deep: true });
|
|
79
|
+
}
|
|
66
80
|
const shell = {
|
|
67
|
-
pass,
|
|
68
81
|
isFinished,
|
|
69
|
-
|
|
82
|
+
pass,
|
|
70
83
|
errors,
|
|
71
|
-
|
|
84
|
+
errorInfo,
|
|
85
|
+
errorFields,
|
|
86
|
+
execute
|
|
72
87
|
};
|
|
73
88
|
function waitUntilFinished() {
|
|
74
89
|
return new Promise((resolve, reject) => {
|
|
@@ -168,7 +183,11 @@ function useAxios(...args) {
|
|
|
168
183
|
var _a;
|
|
169
184
|
error.value = e;
|
|
170
185
|
(_a = options.onError) == null ? void 0 : _a.call(options, e);
|
|
171
|
-
}).finally(() =>
|
|
186
|
+
}).finally(() => {
|
|
187
|
+
var _a;
|
|
188
|
+
(_a = options.onFinish) == null ? void 0 : _a.call(options);
|
|
189
|
+
loading(false);
|
|
190
|
+
});
|
|
172
191
|
return { then };
|
|
173
192
|
};
|
|
174
193
|
if (options.immediate && url)
|
package/index.d.ts
CHANGED
|
@@ -20,18 +20,36 @@ type AsyncValidatorError = Error & {
|
|
|
20
20
|
errors: ValidateError[];
|
|
21
21
|
fields: Record<string, ValidateError[]>;
|
|
22
22
|
};
|
|
23
|
+
interface UseAsyncValidatorExecuteReturn {
|
|
24
|
+
pass: boolean;
|
|
25
|
+
errors: AsyncValidatorError['errors'] | undefined;
|
|
26
|
+
errorInfo: AsyncValidatorError | null;
|
|
27
|
+
errorFields: AsyncValidatorError['fields'] | undefined;
|
|
28
|
+
}
|
|
23
29
|
interface UseAsyncValidatorReturn {
|
|
24
30
|
pass: Ref<boolean>;
|
|
25
|
-
errorInfo: Ref<AsyncValidatorError | null>;
|
|
26
31
|
isFinished: Ref<boolean>;
|
|
27
32
|
errors: Ref<AsyncValidatorError['errors'] | undefined>;
|
|
33
|
+
errorInfo: Ref<AsyncValidatorError | null>;
|
|
28
34
|
errorFields: Ref<AsyncValidatorError['fields'] | undefined>;
|
|
35
|
+
execute: () => Promise<UseAsyncValidatorExecuteReturn>;
|
|
29
36
|
}
|
|
30
37
|
interface UseAsyncValidatorOptions {
|
|
31
38
|
/**
|
|
32
39
|
* @see https://github.com/yiminghe/async-validator#options
|
|
33
40
|
*/
|
|
34
41
|
validateOption?: ValidateOption;
|
|
42
|
+
/**
|
|
43
|
+
* The validation will be triggered right away for the first time.
|
|
44
|
+
* Only works when `manual` is not set to true.
|
|
45
|
+
*
|
|
46
|
+
* @default true
|
|
47
|
+
*/
|
|
48
|
+
immediate?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* If set to true, the validation will not be triggered automatically.
|
|
51
|
+
*/
|
|
52
|
+
manual?: boolean;
|
|
35
53
|
}
|
|
36
54
|
/**
|
|
37
55
|
* Wrapper for async-validator.
|
|
@@ -131,6 +149,10 @@ interface UseAxiosOptions<T = any> {
|
|
|
131
149
|
* Callback when success is caught.
|
|
132
150
|
*/
|
|
133
151
|
onSuccess?: (data: T) => void;
|
|
152
|
+
/**
|
|
153
|
+
* Callback when request is finished.
|
|
154
|
+
*/
|
|
155
|
+
onFinish?: () => void;
|
|
134
156
|
}
|
|
135
157
|
declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>, options?: UseAxiosOptions): StrictUseAxiosReturn<T, R, D> & PromiseLike<StrictUseAxiosReturn<T, R, D>>;
|
|
136
158
|
declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(url: string, instance?: AxiosInstance, options?: UseAxiosOptions): StrictUseAxiosReturn<T, R, D> & PromiseLike<StrictUseAxiosReturn<T, R, D>>;
|
|
@@ -417,4 +439,4 @@ declare function useSortable<T>(selector: string, list: MaybeComputedRef$1<T[]>,
|
|
|
417
439
|
declare function useSortable<T>(el: MaybeComputedRef$1<HTMLElement | null | undefined>, list: MaybeComputedRef$1<T[]>, options?: UseSortableOptions): UseSortableReturn;
|
|
418
440
|
declare function moveArrayElement<T>(list: MaybeComputedRef$1<T[]>, from: number, to: number): void;
|
|
419
441
|
|
|
420
|
-
export { AsyncValidatorError, ChangeCaseType, EasyUseAxiosReturn, FuseOptions, StrictUseAxiosReturn, UseAsyncValidatorOptions, UseAsyncValidatorReturn, UseAxiosOptions, UseAxiosReturn, UseDrauuOptions, UseDrauuReturn, UseFocusTrapOptions, UseFocusTrapReturn, UseFuseOptions, UseFuseReturn, UseIDBOptions, UseJwtOptions, UseJwtReturn, UseNProgressOptions, UseNProgressReturn, UseSortableOptions, UseSortableReturn, createCookies, moveArrayElement, useAsyncValidator, useAxios, useChangeCase, useCookies, useDrauu, useFocusTrap, useFuse, useIDBKeyval, useJwt, useNProgress, useQRCode, useSortable };
|
|
442
|
+
export { AsyncValidatorError, ChangeCaseType, EasyUseAxiosReturn, FuseOptions, StrictUseAxiosReturn, UseAsyncValidatorExecuteReturn, UseAsyncValidatorOptions, UseAsyncValidatorReturn, UseAxiosOptions, UseAxiosReturn, UseDrauuOptions, UseDrauuReturn, UseFocusTrapOptions, UseFocusTrapReturn, UseFuseOptions, UseFuseReturn, UseIDBOptions, UseJwtOptions, UseJwtReturn, UseNProgressOptions, UseNProgressReturn, UseSortableOptions, UseSortableReturn, createCookies, moveArrayElement, useAsyncValidator, useAxios, useChangeCase, useCookies, useDrauu, useFocusTrap, useFuse, useIDBKeyval, useJwt, useNProgress, useQRCode, useSortable };
|
package/index.iife.js
CHANGED
|
@@ -136,9 +136,15 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
|
|
|
136
136
|
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
|
137
137
|
const AsyncValidatorSchema = Schema.default || Schema;
|
|
138
138
|
function useAsyncValidator(value, rules, options = {}) {
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
139
|
+
const {
|
|
140
|
+
validateOption = {},
|
|
141
|
+
immediate = true,
|
|
142
|
+
manual = false
|
|
143
|
+
} = options;
|
|
144
|
+
const valueRef = shared.resolveRef(value);
|
|
145
|
+
const errorInfo = vueDemi.shallowRef(null);
|
|
146
|
+
const isFinished = vueDemi.ref(true);
|
|
147
|
+
const pass = vueDemi.ref(!immediate || manual);
|
|
142
148
|
const errors = vueDemi.computed(() => {
|
|
143
149
|
var _a;
|
|
144
150
|
return ((_a = errorInfo.value) == null ? void 0 : _a.errors) || [];
|
|
@@ -147,13 +153,12 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
|
|
|
147
153
|
var _a;
|
|
148
154
|
return ((_a = errorInfo.value) == null ? void 0 : _a.fields) || {};
|
|
149
155
|
});
|
|
150
|
-
const
|
|
151
|
-
|
|
156
|
+
const validator = vueDemi.computed(() => new AsyncValidatorSchema(shared.resolveUnref(rules)));
|
|
157
|
+
const execute = async () => {
|
|
152
158
|
isFinished.value = false;
|
|
153
159
|
pass.value = false;
|
|
154
|
-
const validator = new AsyncValidatorSchema(shared.resolveUnref(rules));
|
|
155
160
|
try {
|
|
156
|
-
await validator.validate(
|
|
161
|
+
await validator.value.validate(valueRef.value, validateOption);
|
|
157
162
|
pass.value = true;
|
|
158
163
|
errorInfo.value = null;
|
|
159
164
|
} catch (err) {
|
|
@@ -161,13 +166,23 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
|
|
|
161
166
|
} finally {
|
|
162
167
|
isFinished.value = true;
|
|
163
168
|
}
|
|
164
|
-
|
|
169
|
+
return {
|
|
170
|
+
pass: pass.value,
|
|
171
|
+
errorInfo: errorInfo.value,
|
|
172
|
+
errors: errors.value,
|
|
173
|
+
errorFields: errorFields.value
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
if (!manual) {
|
|
177
|
+
vueDemi.watch([valueRef, validator], () => execute(), { immediate, deep: true });
|
|
178
|
+
}
|
|
165
179
|
const shell = {
|
|
166
|
-
pass,
|
|
167
180
|
isFinished,
|
|
168
|
-
|
|
181
|
+
pass,
|
|
169
182
|
errors,
|
|
170
|
-
|
|
183
|
+
errorInfo,
|
|
184
|
+
errorFields,
|
|
185
|
+
execute
|
|
171
186
|
};
|
|
172
187
|
function waitUntilFinished() {
|
|
173
188
|
return new Promise((resolve, reject) => {
|
|
@@ -267,7 +282,11 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
|
|
|
267
282
|
var _a;
|
|
268
283
|
error.value = e;
|
|
269
284
|
(_a = options.onError) == null ? void 0 : _a.call(options, e);
|
|
270
|
-
}).finally(() =>
|
|
285
|
+
}).finally(() => {
|
|
286
|
+
var _a;
|
|
287
|
+
(_a = options.onFinish) == null ? void 0 : _a.call(options);
|
|
288
|
+
loading(false);
|
|
289
|
+
});
|
|
271
290
|
return { then };
|
|
272
291
|
};
|
|
273
292
|
if (options.immediate && url)
|
package/index.iife.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var VueDemi=function(l,o,$){if(l.install)return l;if(!o)return console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`."),l;if(o.version.slice(0,4)==="2.7."){let p=function(g,b){var w,L={},H={config:o.config,use:o.use.bind(o),mixin:o.mixin.bind(o),component:o.component.bind(o),provide:function(m,E){return L[m]=E,this},directive:function(m,E){return E?(o.directive(m,E),H):o.directive(m)},mount:function(m,E){return w||(w=new o(Object.assign({propsData:b},g,{provide:Object.assign(L,g.provide)})),w.$mount(m,E),w)},unmount:function(){w&&(w.$destroy(),w=void 0)}};return H};var N=p;for(var a in o)l[a]=o[a];l.isVue2=!0,l.isVue3=!1,l.install=function(){},l.Vue=o,l.Vue2=o,l.version=o.version,l.warn=o.util.warn,l.createApp=p}else if(o.version.slice(0,2)==="2.")if($){for(var a in $)l[a]=$[a];l.isVue2=!0,l.isVue3=!1,l.install=function(){},l.Vue=o,l.Vue2=o,l.version=o.version}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if(o.version.slice(0,2)==="3."){for(var a in o)l[a]=o[a];l.isVue2=!1,l.isVue3=!0,l.install=function(){},l.Vue=o,l.Vue2=void 0,l.version=o.version,l.set=function(p,g,b){return Array.isArray(p)?(p.length=Math.max(p.length,g),p.splice(g,1,b),b):(p[g]=b,b)},l.del=function(p,g){if(Array.isArray(p)){p.splice(g,1);return}delete p[g]}}else console.error("[vue-demi] Vue version "+o.version+" is unsupported.");return l}(this.VueDemi=this.VueDemi||(typeof VueDemi!="undefined"?VueDemi:{}),this.Vue||(typeof Vue!="undefined"?Vue:void 0),this.VueCompositionAPI||(typeof VueCompositionAPI!="undefined"?VueCompositionAPI:void 0));(function(l,o,$,a,N,p,g,b,w,L,H,m,E,C,ve,de){"use strict";var pe=Object.defineProperty,_e=Object.defineProperties,we=Object.getOwnPropertyDescriptors,M=Object.getOwnPropertySymbols,Oe=Object.prototype.hasOwnProperty,ye=Object.prototype.propertyIsEnumerable,W=(t,r,e)=>r in t?pe(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,Pe=(t,r)=>{for(var e in r||(r={}))Oe.call(r,e)&&W(t,e,r[e]);if(M)for(var e of M(r))ye.call(r,e)&&W(t,e,r[e]);return t},he=(t,r)=>_e(t,we(r));const me=$.default||$;function ge(t,r,e={}){const n=a.ref(),s=a.ref(!1),f=a.ref(!1),i=a.computed(()=>{var _;return((_=n.value)==null?void 0:_.errors)||[]}),d=a.computed(()=>{var _;return((_=n.value)==null?void 0:_.fields)||{}}),{validateOption:u={}}=e;a.watchEffect(async()=>{s.value=!1,f.value=!1;const _=new me(o.resolveUnref(r));try{await _.validate(o.resolveUnref(t),u),f.value=!0,n.value=null}catch(y){n.value=y}finally{s.value=!0}});const v={pass:f,isFinished:s,errorInfo:n,errors:i,errorFields:d};function O(){return new Promise((_,y)=>{o.until(s).toBe(!0).then(()=>_(v)).catch(h=>y(h))})}return he(Pe({},v),{then(_,y){return O().then(_,y)}})}var Ce=Object.defineProperty,be=Object.defineProperties,Ee=Object.getOwnPropertyDescriptors,q=Object.getOwnPropertySymbols,Se=Object.prototype.hasOwnProperty,$e=Object.prototype.propertyIsEnumerable,X=(t,r,e)=>r in t?Ce(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,Q=(t,r)=>{for(var e in r||(r={}))Se.call(r,e)&&X(t,e,r[e]);if(q)for(var e of q(r))$e.call(r,e)&&X(t,e,r[e]);return t},Y=(t,r)=>be(t,Ee(r));function Ae(...t){const r=typeof t[0]=="string"?t[0]:void 0,e=o.isString(r)?1:0;let n={},s=N,f={immediate:!!e,shallow:!0};const i=P=>!!(P==null?void 0:P.request);t.length>0+e&&(i(t[0+e])?s=t[0+e]:n=t[0+e]),t.length>1+e&&i(t[1+e])&&(s=t[1+e]),(t.length===2+e&&!i(t[1+e])||t.length===3+e)&&(f=t[t.length-1]);const d=a.shallowRef(),u=f.shallow?a.shallowRef():a.ref(),v=a.ref(!1),O=a.ref(!1),_=a.ref(!1),y=a.shallowRef(),h=N.CancelToken.source;let A=h();const j=P=>{v.value||!O.value||(A.cancel(P),A=h(),_.value=!0,O.value=!1,v.value=!1)},G=P=>{O.value=P,v.value=!P},z=()=>new Promise((P,c)=>{o.until(v).toBe(!0).then(()=>P(U)).catch(c)}),I=(P,c)=>z().then(P,c),J=(P=r,c={})=>{y.value=void 0;const S=typeof P=="string"?P:r??c.url;return S===void 0?(y.value=new N.AxiosError(N.AxiosError.ERR_INVALID_URL),v.value=!0,{then:I}):(j(),G(!0),s(S,Y(Q(Q({},n),typeof P=="object"?P:c),{cancelToken:A.token})).then(R=>{var F;d.value=R;const fe=R.data;u.value=fe,(F=f.onSuccess)==null||F.call(f,fe)}).catch(R=>{var F;y.value=R,(F=f.onError)==null||F.call(f,R)}).finally(()=>G(!1)),{then:I})};f.immediate&&r&&J();const U={response:d,data:u,error:y,finished:v,loading:O,isFinished:v,isLoading:O,cancel:j,isAborted:_,canceled:_,aborted:_,isCanceled:_,abort:j,execute:J};return Y(Q({},U),{then:I})}var Z=Object.freeze({__proto__:null,camelCase:p.camelCase,capitalCase:p.capitalCase,constantCase:p.constantCase,dotCase:p.dotCase,headerCase:p.headerCase,noCase:p.noCase,paramCase:p.paramCase,pascalCase:p.pascalCase,pathCase:p.pathCase,sentenceCase:p.sentenceCase,snakeCase:p.snakeCase});function je(t,r,e){if(o.isFunction(t))return a.computed(()=>Z[r](o.resolveUnref(t),e));const n=a.ref(t);return a.computed({get(){return Z[r](n.value,e)},set(s){n.value=s}})}var Ie=Object.defineProperty,k=Object.getOwnPropertySymbols,Ue=Object.prototype.hasOwnProperty,Re=Object.prototype.propertyIsEnumerable,K=(t,r,e)=>r in t?Ie(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,x=(t,r)=>{for(var e in r||(r={}))Ue.call(r,e)&&K(t,e,r[e]);if(k)for(var e of k(r))Re.call(r,e)&&K(t,e,r[e]);return t};function Fe(t){const r=new g(t?t.headers.cookie:null);return(e,{doNotParse:n=!1,autoUpdateDependencies:s=!1}={})=>V(e,{doNotParse:n,autoUpdateDependencies:s},r)}function V(t,{doNotParse:r=!1,autoUpdateDependencies:e=!1}={},n=new g){const s=e?[...t||[]]:t;let f=n.getAll({doNotParse:!0});const i=a.ref(0),d=()=>{const u=n.getAll({doNotParse:!0});Ne(s||null,u,f)&&i.value++,f=u};return n.addChangeListener(d),o.tryOnScopeDispose(()=>{n.removeChangeListener(d)}),{get:(...u)=>(e&&s&&!s.includes(u[0])&&s.push(u[0]),i.value,n.get(u[0],x({doNotParse:r},u[1]))),getAll:(...u)=>(i.value,n.getAll(x({doNotParse:r},u[0]))),set:(...u)=>n.set(...u),remove:(...u)=>n.remove(...u),addChangeListener:(...u)=>n.addChangeListener(...u),removeChangeListener:(...u)=>n.removeChangeListener(...u)}}function Ne(t,r,e){if(!t)return!0;for(const n of t)if(r[n]!==e[n])return!0;return!1}var Le=Object.defineProperty,D=Object.getOwnPropertySymbols,He=Object.prototype.hasOwnProperty,Te=Object.prototype.propertyIsEnumerable,ee=(t,r,e)=>r in t?Le(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,Be=(t,r)=>{for(var e in r||(r={}))He.call(r,e)&&ee(t,e,r[e]);if(D)for(var e of D(r))Te.call(r,e)&&ee(t,e,r[e]);return t};function Ge(t,r){const e=a.ref();let n=[];const s=w.createEventHook(),f=w.createEventHook(),i=w.createEventHook(),d=w.createEventHook(),u=w.createEventHook(),v=a.ref(!1),O=a.ref(!1),_=a.ref(!1),y=a.ref(!1),h=a.ref({color:"black",size:3,arrowEnd:!1,cornerRadius:0,dasharray:void 0,fill:"transparent",mode:"draw"});a.watch(h,()=>{const c=e.value;c&&(c.brush=h.value,c.mode=h.value.mode)},{deep:!0});const A=()=>{var c;return(c=e.value)==null?void 0:c.undo()},j=()=>{var c;return(c=e.value)==null?void 0:c.redo()},G=()=>{var c;return(c=e.value)==null?void 0:c.clear()},z=()=>{var c;return(c=e.value)==null?void 0:c.cancel()},I=c=>{var S;return(S=e.value)==null?void 0:S.load(c)},J=()=>{var c;return(c=e.value)==null?void 0:c.dump()},U=()=>{var c;n.forEach(S=>S()),(c=e.value)==null||c.unmount()},P=()=>{e.value&&(v.value=e.value.canUndo(),O.value=e.value.canRedo(),_.value=e.value.altPressed,y.value=e.value.shiftPressed)};return a.watch(()=>w.unrefElement(t),c=>{!c||typeof SVGSVGElement=="undefined"||!(c instanceof SVGSVGElement)||(e.value&&U(),e.value=b.createDrauu(Be({el:c},r)),P(),n=[e.value.on("canceled",()=>f.trigger()),e.value.on("committed",()=>i.trigger()),e.value.on("start",()=>d.trigger()),e.value.on("end",()=>u.trigger()),e.value.on("changed",()=>{P(),s.trigger()})])},{flush:"post"}),o.tryOnScopeDispose(()=>U()),{drauuInstance:e,load:I,dump:J,clear:G,cancel:z,undo:A,redo:j,canUndo:v,canRedo:O,brush:h,onChanged:s.on,onCommitted:i.on,onStart:d.on,onEnd:u.on,onCanceled:f.on}}var Je=Object.defineProperty,Qe=Object.defineProperties,ze=Object.getOwnPropertyDescriptors,T=Object.getOwnPropertySymbols,re=Object.prototype.hasOwnProperty,te=Object.prototype.propertyIsEnumerable,ne=(t,r,e)=>r in t?Je(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,Me=(t,r)=>{for(var e in r||(r={}))re.call(r,e)&&ne(t,e,r[e]);if(T)for(var e of T(r))te.call(r,e)&&ne(t,e,r[e]);return t},We=(t,r)=>Qe(t,ze(r)),qe=(t,r)=>{var e={};for(var n in t)re.call(t,n)&&r.indexOf(n)<0&&(e[n]=t[n]);if(t!=null&&T)for(var n of T(t))r.indexOf(n)<0&&te.call(t,n)&&(e[n]=t[n]);return e};function Xe(t,r={}){let e;const n=r,{immediate:s}=n,f=qe(n,["immediate"]),i=a.ref(!1),d=a.ref(!1),u=y=>e&&e.activate(y),v=y=>e&&e.deactivate(y),O=()=>{e&&(e.pause(),d.value=!0)},_=()=>{e&&(e.unpause(),d.value=!1)};return a.watch(()=>w.unrefElement(t),y=>{!y||(e=L.createFocusTrap(y,We(Me({},f),{onActivate(){i.value=!0,r.onActivate&&r.onActivate()},onDeactivate(){i.value=!1,r.onDeactivate&&r.onDeactivate()}})),s&&u())},{flush:"post"}),w.tryOnScopeDispose(()=>v()),{hasFocus:i,isPaused:d,activate:u,deactivate:v,pause:O,unpause:_}}function Ye(t,r,e){const n=()=>{var i,d;return new H((i=o.resolveUnref(r))!=null?i:[],(d=o.resolveUnref(e))==null?void 0:d.fuseOptions)},s=a.ref(n());a.watch(()=>{var i;return(i=o.resolveUnref(e))==null?void 0:i.fuseOptions},()=>{s.value=n()},{deep:!0}),a.watch(()=>o.resolveUnref(r),i=>{s.value.setCollection(i)},{deep:!0});const f=a.computed(()=>{const i=o.resolveUnref(e);if((i==null?void 0:i.matchAllWhenSearchEmpty)&&!a.unref(t))return o.resolveUnref(r).map((u,v)=>({item:u,refIndex:v}));const d=i==null?void 0:i.resultLimit;return s.value.search(o.resolveUnref(t),d?{limit:d}:void 0)});return{fuse:s,results:f}}var Ze=Object.defineProperty,oe=Object.getOwnPropertySymbols,ke=Object.prototype.hasOwnProperty,Ke=Object.prototype.propertyIsEnumerable,ae=(t,r,e)=>r in t?Ze(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,xe=(t,r)=>{for(var e in r||(r={}))ke.call(r,e)&&ae(t,e,r[e]);if(oe)for(var e of oe(r))Ke.call(r,e)&&ae(t,e,r[e]);return t};function Ve(t,r,e={}){const{flush:n="pre",deep:s=!0,shallow:f=!1,onError:i=h=>{console.error(h)},writeDefaults:d=!0}=e,u=a.ref(!1),v=(f?a.shallowRef:a.ref)(r),O=o.resolveUnref(r);async function _(){try{const h=await m.get(t);h===void 0?O!=null&&d&&await m.set(t,O):v.value=h}catch(h){i(h)}u.value=!0}_();async function y(){try{v.value==null?await m.del(t):Array.isArray(v.value)?await m.update(t,()=>JSON.parse(JSON.stringify(v.value))):typeof v.value=="object"?await m.update(t,()=>xe({},v.value)):await m.update(t,()=>v.value)}catch(h){i(h)}}return a.watch(v,()=>y(),{flush:n,deep:s}),{isFinished:u,data:v}}function De(t,r={}){const{onError:e,fallbackValue:n=null}=r,s=(d,u)=>{try{return E(d,u)}catch(v){return e==null||e(v),n}},f=a.computed(()=>s(o.resolveUnref(t),{header:!0})),i=a.computed(()=>s(o.resolveUnref(t)));return{header:f,payload:i}}function er(t=null,r){const e=a.ref(t),n=a.computed({set:f=>f?C.start():C.done(),get:()=>o.isNumber(e.value)&&e.value<1});r&&C.configure(r);const s=C.set;return C.set=f=>(e.value=f,s.call(C,f)),a.watchEffect(()=>{o.isNumber(e.value)&&o.isClient&&s.call(C,e.value)}),o.tryOnScopeDispose(C.remove),{isLoading:n,progress:e,start:C.start,done:C.done,remove:()=>{e.value=null,C.remove()}}}function rr(t,r){const e=o.resolveRef(t),n=a.ref("");return a.watch(e,async s=>{e.value&&o.isClient&&(n.value=await ve.toDataURL(s,r))},{immediate:!0}),n}var tr=Object.defineProperty,B=Object.getOwnPropertySymbols,le=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable,ue=(t,r,e)=>r in t?tr(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,ie=(t,r)=>{for(var e in r||(r={}))le.call(r,e)&&ue(t,e,r[e]);if(B)for(var e of B(r))se.call(r,e)&&ue(t,e,r[e]);return t},nr=(t,r)=>{var e={};for(var n in t)le.call(t,n)&&r.indexOf(n)<0&&(e[n]=t[n]);if(t!=null&&B)for(var n of B(t))r.indexOf(n)<0&&se.call(t,n)&&(e[n]=t[n]);return e};function or(t,r,e={}){let n;const s=e,{document:f=w.defaultDocument}=s,i=nr(s,["document"]),d={onUpdate:O=>{ce(r,O.oldIndex,O.newIndex)}},u=()=>{const O=typeof t=="string"?f==null?void 0:f.querySelector(t):w.unrefElement(t);!O||(n=new de(O,ie(ie({},d),i)))},v=()=>n==null?void 0:n.destroy();return w.tryOnMounted(u),w.tryOnScopeDispose(v),{stop:v,start:u}}function ce(t,r,e){const n=w.resolveUnref(t);e>=0&&e<n.length&&n.splice(e,0,n.splice(r,1)[0])}l.createCookies=Fe,l.moveArrayElement=ce,l.useAsyncValidator=ge,l.useAxios=Ae,l.useChangeCase=je,l.useCookies=V,l.useDrauu=Ge,l.useFocusTrap=Xe,l.useFuse=Ye,l.useIDBKeyval=Ve,l.useJwt=De,l.useNProgress=er,l.useQRCode=rr,l.useSortable=or})(this.VueUse=this.VueUse||{},VueUse,AsyncValidator,VueDemi,axios,changeCase,UniversalCookie,Drauu,VueUse,focusTrap,Fuse,idbKeyval,jwt_decode,nprogress,QRCode,Sortable);
|
|
1
|
+
var VueDemi=function(l,o,F){if(l.install)return l;if(!o)return console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`."),l;if(o.version.slice(0,4)==="2.7."){let p=function(C,E){var w,T={},B={config:o.config,use:o.use.bind(o),mixin:o.mixin.bind(o),component:o.component.bind(o),provide:function(g,S){return T[g]=S,this},directive:function(g,S){return S?(o.directive(g,S),B):o.directive(g)},mount:function(g,S){return w||(w=new o(Object.assign({propsData:E},C,{provide:Object.assign(T,C.provide)})),w.$mount(g,S),w)},unmount:function(){w&&(w.$destroy(),w=void 0)}};return B};var H=p;for(var a in o)l[a]=o[a];l.isVue2=!0,l.isVue3=!1,l.install=function(){},l.Vue=o,l.Vue2=o,l.version=o.version,l.warn=o.util.warn,l.createApp=p}else if(o.version.slice(0,2)==="2.")if(F){for(var a in F)l[a]=F[a];l.isVue2=!0,l.isVue3=!1,l.install=function(){},l.Vue=o,l.Vue2=o,l.version=o.version}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if(o.version.slice(0,2)==="3."){for(var a in o)l[a]=o[a];l.isVue2=!1,l.isVue3=!0,l.install=function(){},l.Vue=o,l.Vue2=void 0,l.version=o.version,l.set=function(p,C,E){return Array.isArray(p)?(p.length=Math.max(p.length,C),p.splice(C,1,E),E):(p[C]=E,E)},l.del=function(p,C){if(Array.isArray(p)){p.splice(C,1);return}delete p[C]}}else console.error("[vue-demi] Vue version "+o.version+" is unsupported.");return l}(this.VueDemi=this.VueDemi||(typeof VueDemi!="undefined"?VueDemi:{}),this.Vue||(typeof Vue!="undefined"?Vue:void 0),this.VueCompositionAPI||(typeof VueCompositionAPI!="undefined"?VueCompositionAPI:void 0));(function(l,o,F,a,H,p,C,E,w,T,B,g,S,b,ve,de){"use strict";var pe=Object.defineProperty,_e=Object.defineProperties,we=Object.getOwnPropertyDescriptors,M=Object.getOwnPropertySymbols,Oe=Object.prototype.hasOwnProperty,ye=Object.prototype.propertyIsEnumerable,W=(t,r,e)=>r in t?pe(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,Pe=(t,r)=>{for(var e in r||(r={}))Oe.call(r,e)&&W(t,e,r[e]);if(M)for(var e of M(r))ye.call(r,e)&&W(t,e,r[e]);return t},he=(t,r)=>_e(t,we(r));const me=F.default||F;function ge(t,r,e={}){const{validateOption:n={},immediate:u=!0,manual:f=!1}=e,i=o.resolveRef(t),d=a.shallowRef(null),s=a.ref(!0),c=a.ref(!u||f),_=a.computed(()=>{var h;return((h=d.value)==null?void 0:h.errors)||[]}),m=a.computed(()=>{var h;return((h=d.value)==null?void 0:h.fields)||{}}),P=a.computed(()=>new me(o.resolveUnref(r))),O=async()=>{s.value=!1,c.value=!1;try{await P.value.validate(i.value,n),c.value=!0,d.value=null}catch(h){d.value=h}finally{s.value=!0}return{pass:c.value,errorInfo:d.value,errors:_.value,errorFields:m.value}};f||a.watch([i,P],()=>O(),{immediate:u,deep:!0});const $={isFinished:s,pass:c,errors:_,errorInfo:d,errorFields:m,execute:O};function j(){return new Promise((h,I)=>{o.until(s).toBe(!0).then(()=>h($)).catch(U=>I(U))})}return he(Pe({},$),{then(h,I){return j().then(h,I)}})}var Ce=Object.defineProperty,be=Object.defineProperties,Ee=Object.getOwnPropertyDescriptors,q=Object.getOwnPropertySymbols,Se=Object.prototype.hasOwnProperty,$e=Object.prototype.propertyIsEnumerable,X=(t,r,e)=>r in t?Ce(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,z=(t,r)=>{for(var e in r||(r={}))Se.call(r,e)&&X(t,e,r[e]);if(q)for(var e of q(r))$e.call(r,e)&&X(t,e,r[e]);return t},Y=(t,r)=>be(t,Ee(r));function Ae(...t){const r=typeof t[0]=="string"?t[0]:void 0,e=o.isString(r)?1:0;let n={},u=H,f={immediate:!!e,shallow:!0};const i=y=>!!(y==null?void 0:y.request);t.length>0+e&&(i(t[0+e])?u=t[0+e]:n=t[0+e]),t.length>1+e&&i(t[1+e])&&(u=t[1+e]),(t.length===2+e&&!i(t[1+e])||t.length===3+e)&&(f=t[t.length-1]);const d=a.shallowRef(),s=f.shallow?a.shallowRef():a.ref(),c=a.ref(!1),_=a.ref(!1),m=a.ref(!1),P=a.shallowRef(),O=H.CancelToken.source;let $=O();const j=y=>{c.value||!_.value||($.cancel(y),$=O(),m.value=!0,_.value=!1,c.value=!1)},h=y=>{_.value=y,c.value=!y},I=()=>new Promise((y,v)=>{o.until(c).toBe(!0).then(()=>y(N)).catch(v)}),U=(y,v)=>I().then(y,v),Q=(y=r,v={})=>{P.value=void 0;const R=typeof y=="string"?y:r??v.url;return R===void 0?(P.value=new H.AxiosError(H.AxiosError.ERR_INVALID_URL),c.value=!0,{then:U}):(j(),h(!0),u(R,Y(z(z({},n),typeof y=="object"?y:v),{cancelToken:$.token})).then(A=>{var L;d.value=A;const fe=A.data;s.value=fe,(L=f.onSuccess)==null||L.call(f,fe)}).catch(A=>{var L;P.value=A,(L=f.onError)==null||L.call(f,A)}).finally(()=>{var A;(A=f.onFinish)==null||A.call(f),h(!1)}),{then:U})};f.immediate&&r&&Q();const N={response:d,data:s,error:P,finished:c,loading:_,isFinished:c,isLoading:_,cancel:j,isAborted:m,canceled:m,aborted:m,isCanceled:m,abort:j,execute:Q};return Y(z({},N),{then:U})}var Z=Object.freeze({__proto__:null,camelCase:p.camelCase,capitalCase:p.capitalCase,constantCase:p.constantCase,dotCase:p.dotCase,headerCase:p.headerCase,noCase:p.noCase,paramCase:p.paramCase,pascalCase:p.pascalCase,pathCase:p.pathCase,sentenceCase:p.sentenceCase,snakeCase:p.snakeCase});function je(t,r,e){if(o.isFunction(t))return a.computed(()=>Z[r](o.resolveUnref(t),e));const n=a.ref(t);return a.computed({get(){return Z[r](n.value,e)},set(u){n.value=u}})}var Ie=Object.defineProperty,k=Object.getOwnPropertySymbols,Ue=Object.prototype.hasOwnProperty,Re=Object.prototype.propertyIsEnumerable,x=(t,r,e)=>r in t?Ie(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,K=(t,r)=>{for(var e in r||(r={}))Ue.call(r,e)&&x(t,e,r[e]);if(k)for(var e of k(r))Re.call(r,e)&&x(t,e,r[e]);return t};function Fe(t){const r=new C(t?t.headers.cookie:null);return(e,{doNotParse:n=!1,autoUpdateDependencies:u=!1}={})=>V(e,{doNotParse:n,autoUpdateDependencies:u},r)}function V(t,{doNotParse:r=!1,autoUpdateDependencies:e=!1}={},n=new C){const u=e?[...t||[]]:t;let f=n.getAll({doNotParse:!0});const i=a.ref(0),d=()=>{const s=n.getAll({doNotParse:!0});Ne(u||null,s,f)&&i.value++,f=s};return n.addChangeListener(d),o.tryOnScopeDispose(()=>{n.removeChangeListener(d)}),{get:(...s)=>(e&&u&&!u.includes(s[0])&&u.push(s[0]),i.value,n.get(s[0],K({doNotParse:r},s[1]))),getAll:(...s)=>(i.value,n.getAll(K({doNotParse:r},s[0]))),set:(...s)=>n.set(...s),remove:(...s)=>n.remove(...s),addChangeListener:(...s)=>n.addChangeListener(...s),removeChangeListener:(...s)=>n.removeChangeListener(...s)}}function Ne(t,r,e){if(!t)return!0;for(const n of t)if(r[n]!==e[n])return!0;return!1}var Le=Object.defineProperty,D=Object.getOwnPropertySymbols,He=Object.prototype.hasOwnProperty,Te=Object.prototype.propertyIsEnumerable,ee=(t,r,e)=>r in t?Le(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,Be=(t,r)=>{for(var e in r||(r={}))He.call(r,e)&&ee(t,e,r[e]);if(D)for(var e of D(r))Te.call(r,e)&&ee(t,e,r[e]);return t};function Ge(t,r){const e=a.ref();let n=[];const u=w.createEventHook(),f=w.createEventHook(),i=w.createEventHook(),d=w.createEventHook(),s=w.createEventHook(),c=a.ref(!1),_=a.ref(!1),m=a.ref(!1),P=a.ref(!1),O=a.ref({color:"black",size:3,arrowEnd:!1,cornerRadius:0,dasharray:void 0,fill:"transparent",mode:"draw"});a.watch(O,()=>{const v=e.value;v&&(v.brush=O.value,v.mode=O.value.mode)},{deep:!0});const $=()=>{var v;return(v=e.value)==null?void 0:v.undo()},j=()=>{var v;return(v=e.value)==null?void 0:v.redo()},h=()=>{var v;return(v=e.value)==null?void 0:v.clear()},I=()=>{var v;return(v=e.value)==null?void 0:v.cancel()},U=v=>{var R;return(R=e.value)==null?void 0:R.load(v)},Q=()=>{var v;return(v=e.value)==null?void 0:v.dump()},N=()=>{var v;n.forEach(R=>R()),(v=e.value)==null||v.unmount()},y=()=>{e.value&&(c.value=e.value.canUndo(),_.value=e.value.canRedo(),m.value=e.value.altPressed,P.value=e.value.shiftPressed)};return a.watch(()=>w.unrefElement(t),v=>{!v||typeof SVGSVGElement=="undefined"||!(v instanceof SVGSVGElement)||(e.value&&N(),e.value=E.createDrauu(Be({el:v},r)),y(),n=[e.value.on("canceled",()=>f.trigger()),e.value.on("committed",()=>i.trigger()),e.value.on("start",()=>d.trigger()),e.value.on("end",()=>s.trigger()),e.value.on("changed",()=>{y(),u.trigger()})])},{flush:"post"}),o.tryOnScopeDispose(()=>N()),{drauuInstance:e,load:U,dump:Q,clear:h,cancel:I,undo:$,redo:j,canUndo:c,canRedo:_,brush:O,onChanged:u.on,onCommitted:i.on,onStart:d.on,onEnd:s.on,onCanceled:f.on}}var Je=Object.defineProperty,Qe=Object.defineProperties,ze=Object.getOwnPropertyDescriptors,G=Object.getOwnPropertySymbols,re=Object.prototype.hasOwnProperty,te=Object.prototype.propertyIsEnumerable,ne=(t,r,e)=>r in t?Je(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,Me=(t,r)=>{for(var e in r||(r={}))re.call(r,e)&&ne(t,e,r[e]);if(G)for(var e of G(r))te.call(r,e)&&ne(t,e,r[e]);return t},We=(t,r)=>Qe(t,ze(r)),qe=(t,r)=>{var e={};for(var n in t)re.call(t,n)&&r.indexOf(n)<0&&(e[n]=t[n]);if(t!=null&&G)for(var n of G(t))r.indexOf(n)<0&&te.call(t,n)&&(e[n]=t[n]);return e};function Xe(t,r={}){let e;const n=r,{immediate:u}=n,f=qe(n,["immediate"]),i=a.ref(!1),d=a.ref(!1),s=P=>e&&e.activate(P),c=P=>e&&e.deactivate(P),_=()=>{e&&(e.pause(),d.value=!0)},m=()=>{e&&(e.unpause(),d.value=!1)};return a.watch(()=>w.unrefElement(t),P=>{!P||(e=T.createFocusTrap(P,We(Me({},f),{onActivate(){i.value=!0,r.onActivate&&r.onActivate()},onDeactivate(){i.value=!1,r.onDeactivate&&r.onDeactivate()}})),u&&s())},{flush:"post"}),w.tryOnScopeDispose(()=>c()),{hasFocus:i,isPaused:d,activate:s,deactivate:c,pause:_,unpause:m}}function Ye(t,r,e){const n=()=>{var i,d;return new B((i=o.resolveUnref(r))!=null?i:[],(d=o.resolveUnref(e))==null?void 0:d.fuseOptions)},u=a.ref(n());a.watch(()=>{var i;return(i=o.resolveUnref(e))==null?void 0:i.fuseOptions},()=>{u.value=n()},{deep:!0}),a.watch(()=>o.resolveUnref(r),i=>{u.value.setCollection(i)},{deep:!0});const f=a.computed(()=>{const i=o.resolveUnref(e);if((i==null?void 0:i.matchAllWhenSearchEmpty)&&!a.unref(t))return o.resolveUnref(r).map((s,c)=>({item:s,refIndex:c}));const d=i==null?void 0:i.resultLimit;return u.value.search(o.resolveUnref(t),d?{limit:d}:void 0)});return{fuse:u,results:f}}var Ze=Object.defineProperty,oe=Object.getOwnPropertySymbols,ke=Object.prototype.hasOwnProperty,xe=Object.prototype.propertyIsEnumerable,ae=(t,r,e)=>r in t?Ze(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,Ke=(t,r)=>{for(var e in r||(r={}))ke.call(r,e)&&ae(t,e,r[e]);if(oe)for(var e of oe(r))xe.call(r,e)&&ae(t,e,r[e]);return t};function Ve(t,r,e={}){const{flush:n="pre",deep:u=!0,shallow:f=!1,onError:i=O=>{console.error(O)},writeDefaults:d=!0}=e,s=a.ref(!1),c=(f?a.shallowRef:a.ref)(r),_=o.resolveUnref(r);async function m(){try{const O=await g.get(t);O===void 0?_!=null&&d&&await g.set(t,_):c.value=O}catch(O){i(O)}s.value=!0}m();async function P(){try{c.value==null?await g.del(t):Array.isArray(c.value)?await g.update(t,()=>JSON.parse(JSON.stringify(c.value))):typeof c.value=="object"?await g.update(t,()=>Ke({},c.value)):await g.update(t,()=>c.value)}catch(O){i(O)}}return a.watch(c,()=>P(),{flush:n,deep:u}),{isFinished:s,data:c}}function De(t,r={}){const{onError:e,fallbackValue:n=null}=r,u=(d,s)=>{try{return S(d,s)}catch(c){return e==null||e(c),n}},f=a.computed(()=>u(o.resolveUnref(t),{header:!0})),i=a.computed(()=>u(o.resolveUnref(t)));return{header:f,payload:i}}function er(t=null,r){const e=a.ref(t),n=a.computed({set:f=>f?b.start():b.done(),get:()=>o.isNumber(e.value)&&e.value<1});r&&b.configure(r);const u=b.set;return b.set=f=>(e.value=f,u.call(b,f)),a.watchEffect(()=>{o.isNumber(e.value)&&o.isClient&&u.call(b,e.value)}),o.tryOnScopeDispose(b.remove),{isLoading:n,progress:e,start:b.start,done:b.done,remove:()=>{e.value=null,b.remove()}}}function rr(t,r){const e=o.resolveRef(t),n=a.ref("");return a.watch(e,async u=>{e.value&&o.isClient&&(n.value=await ve.toDataURL(u,r))},{immediate:!0}),n}var tr=Object.defineProperty,J=Object.getOwnPropertySymbols,le=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable,ue=(t,r,e)=>r in t?tr(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e,ie=(t,r)=>{for(var e in r||(r={}))le.call(r,e)&&ue(t,e,r[e]);if(J)for(var e of J(r))se.call(r,e)&&ue(t,e,r[e]);return t},nr=(t,r)=>{var e={};for(var n in t)le.call(t,n)&&r.indexOf(n)<0&&(e[n]=t[n]);if(t!=null&&J)for(var n of J(t))r.indexOf(n)<0&&se.call(t,n)&&(e[n]=t[n]);return e};function or(t,r,e={}){let n;const u=e,{document:f=w.defaultDocument}=u,i=nr(u,["document"]),d={onUpdate:_=>{ce(r,_.oldIndex,_.newIndex)}},s=()=>{const _=typeof t=="string"?f==null?void 0:f.querySelector(t):w.unrefElement(t);!_||(n=new de(_,ie(ie({},d),i)))},c=()=>n==null?void 0:n.destroy();return w.tryOnMounted(s),w.tryOnScopeDispose(c),{stop:c,start:s}}function ce(t,r,e){const n=w.resolveUnref(t);e>=0&&e<n.length&&n.splice(e,0,n.splice(r,1)[0])}l.createCookies=Fe,l.moveArrayElement=ce,l.useAsyncValidator=ge,l.useAxios=Ae,l.useChangeCase=je,l.useCookies=V,l.useDrauu=Ge,l.useFocusTrap=Xe,l.useFuse=Ye,l.useIDBKeyval=Ve,l.useJwt=De,l.useNProgress=er,l.useQRCode=rr,l.useSortable=or})(this.VueUse=this.VueUse||{},VueUse,AsyncValidator,VueDemi,axios,changeCase,UniversalCookie,Drauu,VueUse,focusTrap,Fuse,idbKeyval,jwt_decode,nprogress,QRCode,Sortable);
|
package/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { resolveUnref, until, isString, isFunction, tryOnScopeDispose, isNumber, isClient
|
|
1
|
+
import { resolveRef, resolveUnref, until, isString, isFunction, tryOnScopeDispose, isNumber, isClient } from '@vueuse/shared';
|
|
2
2
|
import Schema from 'async-validator';
|
|
3
|
-
import { ref, computed,
|
|
3
|
+
import { shallowRef, ref, computed, watch, unref, watchEffect } from 'vue-demi';
|
|
4
4
|
import axios, { AxiosError } from 'axios';
|
|
5
5
|
import { camelCase, capitalCase, constantCase, dotCase, headerCase, noCase, paramCase, pascalCase, pathCase, sentenceCase, snakeCase } from 'change-case';
|
|
6
6
|
import Cookie from 'universal-cookie';
|
|
@@ -35,9 +35,15 @@ var __spreadValues$6 = (a, b) => {
|
|
|
35
35
|
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
|
36
36
|
const AsyncValidatorSchema = Schema.default || Schema;
|
|
37
37
|
function useAsyncValidator(value, rules, options = {}) {
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
const {
|
|
39
|
+
validateOption = {},
|
|
40
|
+
immediate = true,
|
|
41
|
+
manual = false
|
|
42
|
+
} = options;
|
|
43
|
+
const valueRef = resolveRef(value);
|
|
44
|
+
const errorInfo = shallowRef(null);
|
|
45
|
+
const isFinished = ref(true);
|
|
46
|
+
const pass = ref(!immediate || manual);
|
|
41
47
|
const errors = computed(() => {
|
|
42
48
|
var _a;
|
|
43
49
|
return ((_a = errorInfo.value) == null ? void 0 : _a.errors) || [];
|
|
@@ -46,13 +52,12 @@ function useAsyncValidator(value, rules, options = {}) {
|
|
|
46
52
|
var _a;
|
|
47
53
|
return ((_a = errorInfo.value) == null ? void 0 : _a.fields) || {};
|
|
48
54
|
});
|
|
49
|
-
const
|
|
50
|
-
|
|
55
|
+
const validator = computed(() => new AsyncValidatorSchema(resolveUnref(rules)));
|
|
56
|
+
const execute = async () => {
|
|
51
57
|
isFinished.value = false;
|
|
52
58
|
pass.value = false;
|
|
53
|
-
const validator = new AsyncValidatorSchema(resolveUnref(rules));
|
|
54
59
|
try {
|
|
55
|
-
await validator.validate(
|
|
60
|
+
await validator.value.validate(valueRef.value, validateOption);
|
|
56
61
|
pass.value = true;
|
|
57
62
|
errorInfo.value = null;
|
|
58
63
|
} catch (err) {
|
|
@@ -60,13 +65,23 @@ function useAsyncValidator(value, rules, options = {}) {
|
|
|
60
65
|
} finally {
|
|
61
66
|
isFinished.value = true;
|
|
62
67
|
}
|
|
63
|
-
|
|
68
|
+
return {
|
|
69
|
+
pass: pass.value,
|
|
70
|
+
errorInfo: errorInfo.value,
|
|
71
|
+
errors: errors.value,
|
|
72
|
+
errorFields: errorFields.value
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
if (!manual) {
|
|
76
|
+
watch([valueRef, validator], () => execute(), { immediate, deep: true });
|
|
77
|
+
}
|
|
64
78
|
const shell = {
|
|
65
|
-
pass,
|
|
66
79
|
isFinished,
|
|
67
|
-
|
|
80
|
+
pass,
|
|
68
81
|
errors,
|
|
69
|
-
|
|
82
|
+
errorInfo,
|
|
83
|
+
errorFields,
|
|
84
|
+
execute
|
|
70
85
|
};
|
|
71
86
|
function waitUntilFinished() {
|
|
72
87
|
return new Promise((resolve, reject) => {
|
|
@@ -166,7 +181,11 @@ function useAxios(...args) {
|
|
|
166
181
|
var _a;
|
|
167
182
|
error.value = e;
|
|
168
183
|
(_a = options.onError) == null ? void 0 : _a.call(options, e);
|
|
169
|
-
}).finally(() =>
|
|
184
|
+
}).finally(() => {
|
|
185
|
+
var _a;
|
|
186
|
+
(_a = options.onFinish) == null ? void 0 : _a.call(options);
|
|
187
|
+
loading(false);
|
|
188
|
+
});
|
|
170
189
|
return { then };
|
|
171
190
|
};
|
|
172
191
|
if (options.immediate && url)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vueuse/integrations",
|
|
3
|
-
"version": "10.0.0-beta.
|
|
3
|
+
"version": "10.0.0-beta.2",
|
|
4
4
|
"description": "Integration wrappers for utility libraries",
|
|
5
5
|
"author": "Anthony Fu <https://github.com/antfu>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -161,8 +161,8 @@
|
|
|
161
161
|
}
|
|
162
162
|
},
|
|
163
163
|
"dependencies": {
|
|
164
|
-
"@vueuse/core": "10.0.0-beta.
|
|
165
|
-
"@vueuse/shared": "10.0.0-beta.
|
|
164
|
+
"@vueuse/core": "10.0.0-beta.2",
|
|
165
|
+
"@vueuse/shared": "10.0.0-beta.2",
|
|
166
166
|
"vue-demi": "*"
|
|
167
167
|
},
|
|
168
168
|
"devDependencies": {
|
|
@@ -25,9 +25,15 @@ var __spreadValues = (a, b) => {
|
|
|
25
25
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
26
26
|
const AsyncValidatorSchema = Schema.default || Schema;
|
|
27
27
|
function useAsyncValidator(value, rules, options = {}) {
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
const {
|
|
29
|
+
validateOption = {},
|
|
30
|
+
immediate = true,
|
|
31
|
+
manual = false
|
|
32
|
+
} = options;
|
|
33
|
+
const valueRef = shared.resolveRef(value);
|
|
34
|
+
const errorInfo = vueDemi.shallowRef(null);
|
|
35
|
+
const isFinished = vueDemi.ref(true);
|
|
36
|
+
const pass = vueDemi.ref(!immediate || manual);
|
|
31
37
|
const errors = vueDemi.computed(() => {
|
|
32
38
|
var _a;
|
|
33
39
|
return ((_a = errorInfo.value) == null ? void 0 : _a.errors) || [];
|
|
@@ -36,13 +42,12 @@ function useAsyncValidator(value, rules, options = {}) {
|
|
|
36
42
|
var _a;
|
|
37
43
|
return ((_a = errorInfo.value) == null ? void 0 : _a.fields) || {};
|
|
38
44
|
});
|
|
39
|
-
const
|
|
40
|
-
|
|
45
|
+
const validator = vueDemi.computed(() => new AsyncValidatorSchema(shared.resolveUnref(rules)));
|
|
46
|
+
const execute = async () => {
|
|
41
47
|
isFinished.value = false;
|
|
42
48
|
pass.value = false;
|
|
43
|
-
const validator = new AsyncValidatorSchema(shared.resolveUnref(rules));
|
|
44
49
|
try {
|
|
45
|
-
await validator.validate(
|
|
50
|
+
await validator.value.validate(valueRef.value, validateOption);
|
|
46
51
|
pass.value = true;
|
|
47
52
|
errorInfo.value = null;
|
|
48
53
|
} catch (err) {
|
|
@@ -50,13 +55,23 @@ function useAsyncValidator(value, rules, options = {}) {
|
|
|
50
55
|
} finally {
|
|
51
56
|
isFinished.value = true;
|
|
52
57
|
}
|
|
53
|
-
|
|
58
|
+
return {
|
|
59
|
+
pass: pass.value,
|
|
60
|
+
errorInfo: errorInfo.value,
|
|
61
|
+
errors: errors.value,
|
|
62
|
+
errorFields: errorFields.value
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
if (!manual) {
|
|
66
|
+
vueDemi.watch([valueRef, validator], () => execute(), { immediate, deep: true });
|
|
67
|
+
}
|
|
54
68
|
const shell = {
|
|
55
|
-
pass,
|
|
56
69
|
isFinished,
|
|
57
|
-
|
|
70
|
+
pass,
|
|
58
71
|
errors,
|
|
59
|
-
|
|
72
|
+
errorInfo,
|
|
73
|
+
errorFields,
|
|
74
|
+
execute
|
|
60
75
|
};
|
|
61
76
|
function waitUntilFinished() {
|
|
62
77
|
return new Promise((resolve, reject) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ref, computed,
|
|
2
|
-
import { resolveUnref, until } from '@vueuse/shared';
|
|
1
|
+
import { shallowRef, ref, computed, watch, defineComponent, reactive } from 'vue-demi';
|
|
2
|
+
import { resolveRef, resolveUnref, until } from '@vueuse/shared';
|
|
3
3
|
import Schema from 'async-validator';
|
|
4
4
|
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
@@ -23,9 +23,15 @@ var __spreadValues = (a, b) => {
|
|
|
23
23
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
24
|
const AsyncValidatorSchema = Schema.default || Schema;
|
|
25
25
|
function useAsyncValidator(value, rules, options = {}) {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
const {
|
|
27
|
+
validateOption = {},
|
|
28
|
+
immediate = true,
|
|
29
|
+
manual = false
|
|
30
|
+
} = options;
|
|
31
|
+
const valueRef = resolveRef(value);
|
|
32
|
+
const errorInfo = shallowRef(null);
|
|
33
|
+
const isFinished = ref(true);
|
|
34
|
+
const pass = ref(!immediate || manual);
|
|
29
35
|
const errors = computed(() => {
|
|
30
36
|
var _a;
|
|
31
37
|
return ((_a = errorInfo.value) == null ? void 0 : _a.errors) || [];
|
|
@@ -34,13 +40,12 @@ function useAsyncValidator(value, rules, options = {}) {
|
|
|
34
40
|
var _a;
|
|
35
41
|
return ((_a = errorInfo.value) == null ? void 0 : _a.fields) || {};
|
|
36
42
|
});
|
|
37
|
-
const
|
|
38
|
-
|
|
43
|
+
const validator = computed(() => new AsyncValidatorSchema(resolveUnref(rules)));
|
|
44
|
+
const execute = async () => {
|
|
39
45
|
isFinished.value = false;
|
|
40
46
|
pass.value = false;
|
|
41
|
-
const validator = new AsyncValidatorSchema(resolveUnref(rules));
|
|
42
47
|
try {
|
|
43
|
-
await validator.validate(
|
|
48
|
+
await validator.value.validate(valueRef.value, validateOption);
|
|
44
49
|
pass.value = true;
|
|
45
50
|
errorInfo.value = null;
|
|
46
51
|
} catch (err) {
|
|
@@ -48,13 +53,23 @@ function useAsyncValidator(value, rules, options = {}) {
|
|
|
48
53
|
} finally {
|
|
49
54
|
isFinished.value = true;
|
|
50
55
|
}
|
|
51
|
-
|
|
56
|
+
return {
|
|
57
|
+
pass: pass.value,
|
|
58
|
+
errorInfo: errorInfo.value,
|
|
59
|
+
errors: errors.value,
|
|
60
|
+
errorFields: errorFields.value
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
if (!manual) {
|
|
64
|
+
watch([valueRef, validator], () => execute(), { immediate, deep: true });
|
|
65
|
+
}
|
|
52
66
|
const shell = {
|
|
53
|
-
pass,
|
|
54
67
|
isFinished,
|
|
55
|
-
|
|
68
|
+
pass,
|
|
56
69
|
errors,
|
|
57
|
-
|
|
70
|
+
errorInfo,
|
|
71
|
+
errorFields,
|
|
72
|
+
execute
|
|
58
73
|
};
|
|
59
74
|
function waitUntilFinished() {
|
|
60
75
|
return new Promise((resolve, reject) => {
|
package/useAsyncValidator.cjs
CHANGED
|
@@ -25,9 +25,15 @@ var __spreadValues = (a, b) => {
|
|
|
25
25
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
26
26
|
const AsyncValidatorSchema = Schema.default || Schema;
|
|
27
27
|
function useAsyncValidator(value, rules, options = {}) {
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
const {
|
|
29
|
+
validateOption = {},
|
|
30
|
+
immediate = true,
|
|
31
|
+
manual = false
|
|
32
|
+
} = options;
|
|
33
|
+
const valueRef = shared.resolveRef(value);
|
|
34
|
+
const errorInfo = vueDemi.shallowRef(null);
|
|
35
|
+
const isFinished = vueDemi.ref(true);
|
|
36
|
+
const pass = vueDemi.ref(!immediate || manual);
|
|
31
37
|
const errors = vueDemi.computed(() => {
|
|
32
38
|
var _a;
|
|
33
39
|
return ((_a = errorInfo.value) == null ? void 0 : _a.errors) || [];
|
|
@@ -36,13 +42,12 @@ function useAsyncValidator(value, rules, options = {}) {
|
|
|
36
42
|
var _a;
|
|
37
43
|
return ((_a = errorInfo.value) == null ? void 0 : _a.fields) || {};
|
|
38
44
|
});
|
|
39
|
-
const
|
|
40
|
-
|
|
45
|
+
const validator = vueDemi.computed(() => new AsyncValidatorSchema(shared.resolveUnref(rules)));
|
|
46
|
+
const execute = async () => {
|
|
41
47
|
isFinished.value = false;
|
|
42
48
|
pass.value = false;
|
|
43
|
-
const validator = new AsyncValidatorSchema(shared.resolveUnref(rules));
|
|
44
49
|
try {
|
|
45
|
-
await validator.validate(
|
|
50
|
+
await validator.value.validate(valueRef.value, validateOption);
|
|
46
51
|
pass.value = true;
|
|
47
52
|
errorInfo.value = null;
|
|
48
53
|
} catch (err) {
|
|
@@ -50,13 +55,23 @@ function useAsyncValidator(value, rules, options = {}) {
|
|
|
50
55
|
} finally {
|
|
51
56
|
isFinished.value = true;
|
|
52
57
|
}
|
|
53
|
-
|
|
58
|
+
return {
|
|
59
|
+
pass: pass.value,
|
|
60
|
+
errorInfo: errorInfo.value,
|
|
61
|
+
errors: errors.value,
|
|
62
|
+
errorFields: errorFields.value
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
if (!manual) {
|
|
66
|
+
vueDemi.watch([valueRef, validator], () => execute(), { immediate, deep: true });
|
|
67
|
+
}
|
|
54
68
|
const shell = {
|
|
55
|
-
pass,
|
|
56
69
|
isFinished,
|
|
57
|
-
|
|
70
|
+
pass,
|
|
58
71
|
errors,
|
|
59
|
-
|
|
72
|
+
errorInfo,
|
|
73
|
+
errorFields,
|
|
74
|
+
execute
|
|
60
75
|
};
|
|
61
76
|
function waitUntilFinished() {
|
|
62
77
|
return new Promise((resolve, reject) => {
|
package/useAsyncValidator.d.ts
CHANGED
|
@@ -6,18 +6,36 @@ type AsyncValidatorError = Error & {
|
|
|
6
6
|
errors: ValidateError[];
|
|
7
7
|
fields: Record<string, ValidateError[]>;
|
|
8
8
|
};
|
|
9
|
+
interface UseAsyncValidatorExecuteReturn {
|
|
10
|
+
pass: boolean;
|
|
11
|
+
errors: AsyncValidatorError['errors'] | undefined;
|
|
12
|
+
errorInfo: AsyncValidatorError | null;
|
|
13
|
+
errorFields: AsyncValidatorError['fields'] | undefined;
|
|
14
|
+
}
|
|
9
15
|
interface UseAsyncValidatorReturn {
|
|
10
16
|
pass: Ref<boolean>;
|
|
11
|
-
errorInfo: Ref<AsyncValidatorError | null>;
|
|
12
17
|
isFinished: Ref<boolean>;
|
|
13
18
|
errors: Ref<AsyncValidatorError['errors'] | undefined>;
|
|
19
|
+
errorInfo: Ref<AsyncValidatorError | null>;
|
|
14
20
|
errorFields: Ref<AsyncValidatorError['fields'] | undefined>;
|
|
21
|
+
execute: () => Promise<UseAsyncValidatorExecuteReturn>;
|
|
15
22
|
}
|
|
16
23
|
interface UseAsyncValidatorOptions {
|
|
17
24
|
/**
|
|
18
25
|
* @see https://github.com/yiminghe/async-validator#options
|
|
19
26
|
*/
|
|
20
27
|
validateOption?: ValidateOption;
|
|
28
|
+
/**
|
|
29
|
+
* The validation will be triggered right away for the first time.
|
|
30
|
+
* Only works when `manual` is not set to true.
|
|
31
|
+
*
|
|
32
|
+
* @default true
|
|
33
|
+
*/
|
|
34
|
+
immediate?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* If set to true, the validation will not be triggered automatically.
|
|
37
|
+
*/
|
|
38
|
+
manual?: boolean;
|
|
21
39
|
}
|
|
22
40
|
/**
|
|
23
41
|
* Wrapper for async-validator.
|
|
@@ -27,4 +45,4 @@ interface UseAsyncValidatorOptions {
|
|
|
27
45
|
*/
|
|
28
46
|
declare function useAsyncValidator(value: MaybeComputedRef<Record<string, any>>, rules: MaybeComputedRef<Rules>, options?: UseAsyncValidatorOptions): UseAsyncValidatorReturn & PromiseLike<UseAsyncValidatorReturn>;
|
|
29
47
|
|
|
30
|
-
export { AsyncValidatorError, UseAsyncValidatorOptions, UseAsyncValidatorReturn, useAsyncValidator };
|
|
48
|
+
export { AsyncValidatorError, UseAsyncValidatorExecuteReturn, UseAsyncValidatorOptions, UseAsyncValidatorReturn, useAsyncValidator };
|
|
@@ -136,9 +136,15 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
|
|
|
136
136
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
137
137
|
const AsyncValidatorSchema = Schema.default || Schema;
|
|
138
138
|
function useAsyncValidator(value, rules, options = {}) {
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
139
|
+
const {
|
|
140
|
+
validateOption = {},
|
|
141
|
+
immediate = true,
|
|
142
|
+
manual = false
|
|
143
|
+
} = options;
|
|
144
|
+
const valueRef = shared.resolveRef(value);
|
|
145
|
+
const errorInfo = vueDemi.shallowRef(null);
|
|
146
|
+
const isFinished = vueDemi.ref(true);
|
|
147
|
+
const pass = vueDemi.ref(!immediate || manual);
|
|
142
148
|
const errors = vueDemi.computed(() => {
|
|
143
149
|
var _a;
|
|
144
150
|
return ((_a = errorInfo.value) == null ? void 0 : _a.errors) || [];
|
|
@@ -147,13 +153,12 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
|
|
|
147
153
|
var _a;
|
|
148
154
|
return ((_a = errorInfo.value) == null ? void 0 : _a.fields) || {};
|
|
149
155
|
});
|
|
150
|
-
const
|
|
151
|
-
|
|
156
|
+
const validator = vueDemi.computed(() => new AsyncValidatorSchema(shared.resolveUnref(rules)));
|
|
157
|
+
const execute = async () => {
|
|
152
158
|
isFinished.value = false;
|
|
153
159
|
pass.value = false;
|
|
154
|
-
const validator = new AsyncValidatorSchema(shared.resolveUnref(rules));
|
|
155
160
|
try {
|
|
156
|
-
await validator.validate(
|
|
161
|
+
await validator.value.validate(valueRef.value, validateOption);
|
|
157
162
|
pass.value = true;
|
|
158
163
|
errorInfo.value = null;
|
|
159
164
|
} catch (err) {
|
|
@@ -161,13 +166,23 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
|
|
|
161
166
|
} finally {
|
|
162
167
|
isFinished.value = true;
|
|
163
168
|
}
|
|
164
|
-
|
|
169
|
+
return {
|
|
170
|
+
pass: pass.value,
|
|
171
|
+
errorInfo: errorInfo.value,
|
|
172
|
+
errors: errors.value,
|
|
173
|
+
errorFields: errorFields.value
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
if (!manual) {
|
|
177
|
+
vueDemi.watch([valueRef, validator], () => execute(), { immediate, deep: true });
|
|
178
|
+
}
|
|
165
179
|
const shell = {
|
|
166
|
-
pass,
|
|
167
180
|
isFinished,
|
|
168
|
-
|
|
181
|
+
pass,
|
|
169
182
|
errors,
|
|
170
|
-
|
|
183
|
+
errorInfo,
|
|
184
|
+
errorFields,
|
|
185
|
+
execute
|
|
171
186
|
};
|
|
172
187
|
function waitUntilFinished() {
|
|
173
188
|
return new Promise((resolve, reject) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var VueDemi=function(
|
|
1
|
+
var VueDemi=function(e,r,v){if(e.install)return e;if(!r)return console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`."),e;if(r.version.slice(0,4)==="2.7."){let o=function(i,c){var f,y={},h={config:r.config,use:r.use.bind(r),mixin:r.mixin.bind(r),component:r.component.bind(r),provide:function(u,d){return y[u]=d,this},directive:function(u,d){return d?(r.directive(u,d),h):r.directive(u)},mount:function(u,d){return f||(f=new r(Object.assign({propsData:c},i,{provide:Object.assign(y,i.provide)})),f.$mount(u,d),f)},unmount:function(){f&&(f.$destroy(),f=void 0)}};return h};var F=o;for(var n in r)e[n]=r[n];e.isVue2=!0,e.isVue3=!1,e.install=function(){},e.Vue=r,e.Vue2=r,e.version=r.version,e.warn=r.util.warn,e.createApp=o}else if(r.version.slice(0,2)==="2.")if(v){for(var n in v)e[n]=v[n];e.isVue2=!0,e.isVue3=!1,e.install=function(){},e.Vue=r,e.Vue2=r,e.version=r.version}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if(r.version.slice(0,2)==="3."){for(var n in r)e[n]=r[n];e.isVue2=!1,e.isVue3=!0,e.install=function(){},e.Vue=r,e.Vue2=void 0,e.version=r.version,e.set=function(o,i,c){return Array.isArray(o)?(o.length=Math.max(o.length,i),o.splice(i,1,c),c):(o[i]=c,c)},e.del=function(o,i){if(Array.isArray(o)){o.splice(i,1);return}delete o[i]}}else console.error("[vue-demi] Vue version "+r.version+" is unsupported.");return e}(this.VueDemi=this.VueDemi||(typeof VueDemi!="undefined"?VueDemi:{}),this.Vue||(typeof Vue!="undefined"?Vue:void 0),this.VueCompositionAPI||(typeof VueCompositionAPI!="undefined"?VueCompositionAPI:void 0));(function(e,r,v,n){"use strict";var F=Object.defineProperty,o=Object.defineProperties,i=Object.getOwnPropertyDescriptors,c=Object.getOwnPropertySymbols,f=Object.prototype.hasOwnProperty,y=Object.prototype.propertyIsEnumerable,h=(a,t,s)=>t in a?F(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s,u=(a,t)=>{for(var s in t||(t={}))f.call(t,s)&&h(a,s,t[s]);if(c)for(var s of c(t))y.call(t,s)&&h(a,s,t[s]);return a},d=(a,t)=>o(a,i(t));const R=v.default||v;function E(a,t,s={}){const{validateOption:S={},immediate:P=!0,manual:b=!1}=s,A=r.resolveRef(a),p=n.shallowRef(null),_=n.ref(!0),w=n.ref(!P||b),j=n.computed(()=>{var l;return((l=p.value)==null?void 0:l.errors)||[]}),I=n.computed(()=>{var l;return((l=p.value)==null?void 0:l.fields)||{}}),g=n.computed(()=>new R(r.resolveUnref(t))),U=async()=>{_.value=!1,w.value=!1;try{await g.value.validate(A.value,S),w.value=!0,p.value=null}catch(l){p.value=l}finally{_.value=!0}return{pass:w.value,errorInfo:p.value,errors:j.value,errorFields:I.value}};b||n.watch([A,g],()=>U(),{immediate:P,deep:!0});const x={isFinished:_,pass:w,errors:j,errorInfo:p,errorFields:I,execute:U};function $(){return new Promise((l,O)=>{r.until(_).toBe(!0).then(()=>l(x)).catch(B=>O(B))})}return d(u({},x),{then(l,O){return $().then(l,O)}})}e.useAsyncValidator=E})(this.VueUse=this.VueUse||{},VueUse,AsyncValidator,VueDemi);
|
package/useAsyncValidator.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { resolveUnref, until } from '@vueuse/shared';
|
|
1
|
+
import { resolveRef, resolveUnref, until } from '@vueuse/shared';
|
|
2
2
|
import Schema from 'async-validator';
|
|
3
|
-
import { ref, computed,
|
|
3
|
+
import { shallowRef, ref, computed, watch } from 'vue-demi';
|
|
4
4
|
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
6
6
|
var __defProps = Object.defineProperties;
|
|
@@ -23,9 +23,15 @@ var __spreadValues = (a, b) => {
|
|
|
23
23
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
24
|
const AsyncValidatorSchema = Schema.default || Schema;
|
|
25
25
|
function useAsyncValidator(value, rules, options = {}) {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
const {
|
|
27
|
+
validateOption = {},
|
|
28
|
+
immediate = true,
|
|
29
|
+
manual = false
|
|
30
|
+
} = options;
|
|
31
|
+
const valueRef = resolveRef(value);
|
|
32
|
+
const errorInfo = shallowRef(null);
|
|
33
|
+
const isFinished = ref(true);
|
|
34
|
+
const pass = ref(!immediate || manual);
|
|
29
35
|
const errors = computed(() => {
|
|
30
36
|
var _a;
|
|
31
37
|
return ((_a = errorInfo.value) == null ? void 0 : _a.errors) || [];
|
|
@@ -34,13 +40,12 @@ function useAsyncValidator(value, rules, options = {}) {
|
|
|
34
40
|
var _a;
|
|
35
41
|
return ((_a = errorInfo.value) == null ? void 0 : _a.fields) || {};
|
|
36
42
|
});
|
|
37
|
-
const
|
|
38
|
-
|
|
43
|
+
const validator = computed(() => new AsyncValidatorSchema(resolveUnref(rules)));
|
|
44
|
+
const execute = async () => {
|
|
39
45
|
isFinished.value = false;
|
|
40
46
|
pass.value = false;
|
|
41
|
-
const validator = new AsyncValidatorSchema(resolveUnref(rules));
|
|
42
47
|
try {
|
|
43
|
-
await validator.validate(
|
|
48
|
+
await validator.value.validate(valueRef.value, validateOption);
|
|
44
49
|
pass.value = true;
|
|
45
50
|
errorInfo.value = null;
|
|
46
51
|
} catch (err) {
|
|
@@ -48,13 +53,23 @@ function useAsyncValidator(value, rules, options = {}) {
|
|
|
48
53
|
} finally {
|
|
49
54
|
isFinished.value = true;
|
|
50
55
|
}
|
|
51
|
-
|
|
56
|
+
return {
|
|
57
|
+
pass: pass.value,
|
|
58
|
+
errorInfo: errorInfo.value,
|
|
59
|
+
errors: errors.value,
|
|
60
|
+
errorFields: errorFields.value
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
if (!manual) {
|
|
64
|
+
watch([valueRef, validator], () => execute(), { immediate, deep: true });
|
|
65
|
+
}
|
|
52
66
|
const shell = {
|
|
53
|
-
pass,
|
|
54
67
|
isFinished,
|
|
55
|
-
|
|
68
|
+
pass,
|
|
56
69
|
errors,
|
|
57
|
-
|
|
70
|
+
errorInfo,
|
|
71
|
+
errorFields,
|
|
72
|
+
execute
|
|
58
73
|
};
|
|
59
74
|
function waitUntilFinished() {
|
|
60
75
|
return new Promise((resolve, reject) => {
|
package/useAxios.cjs
CHANGED
|
@@ -90,7 +90,11 @@ function useAxios(...args) {
|
|
|
90
90
|
var _a;
|
|
91
91
|
error.value = e;
|
|
92
92
|
(_a = options.onError) == null ? void 0 : _a.call(options, e);
|
|
93
|
-
}).finally(() =>
|
|
93
|
+
}).finally(() => {
|
|
94
|
+
var _a;
|
|
95
|
+
(_a = options.onFinish) == null ? void 0 : _a.call(options);
|
|
96
|
+
loading(false);
|
|
97
|
+
});
|
|
94
98
|
return { then };
|
|
95
99
|
};
|
|
96
100
|
if (options.immediate && url)
|
package/useAxios.d.ts
CHANGED
|
@@ -91,6 +91,10 @@ interface UseAxiosOptions<T = any> {
|
|
|
91
91
|
* Callback when success is caught.
|
|
92
92
|
*/
|
|
93
93
|
onSuccess?: (data: T) => void;
|
|
94
|
+
/**
|
|
95
|
+
* Callback when request is finished.
|
|
96
|
+
*/
|
|
97
|
+
onFinish?: () => void;
|
|
94
98
|
}
|
|
95
99
|
declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>, options?: UseAxiosOptions): StrictUseAxiosReturn<T, R, D> & PromiseLike<StrictUseAxiosReturn<T, R, D>>;
|
|
96
100
|
declare function useAxios<T = any, R = AxiosResponse<T>, D = any>(url: string, instance?: AxiosInstance, options?: UseAxiosOptions): StrictUseAxiosReturn<T, R, D> & PromiseLike<StrictUseAxiosReturn<T, R, D>>;
|
package/useAxios.iife.js
CHANGED
|
@@ -201,7 +201,11 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
|
|
|
201
201
|
var _a;
|
|
202
202
|
error.value = e;
|
|
203
203
|
(_a = options.onError) == null ? void 0 : _a.call(options, e);
|
|
204
|
-
}).finally(() =>
|
|
204
|
+
}).finally(() => {
|
|
205
|
+
var _a;
|
|
206
|
+
(_a = options.onFinish) == null ? void 0 : _a.call(options);
|
|
207
|
+
loading(false);
|
|
208
|
+
});
|
|
205
209
|
return { then };
|
|
206
210
|
};
|
|
207
211
|
if (options.immediate && url)
|
package/useAxios.iife.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var VueDemi=function(e,n,
|
|
1
|
+
var VueDemi=function(e,n,_){if(e.install)return e;if(!n)return console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`."),e;if(n.version.slice(0,4)==="2.7."){let s=function(c,u){var a,O={},b={config:n.config,use:n.use.bind(n),mixin:n.mixin.bind(n),component:n.component.bind(n),provide:function(f,d){return O[f]=d,this},directive:function(f,d){return d?(n.directive(f,d),b):n.directive(f)},mount:function(f,d){return a||(a=new n(Object.assign({propsData:u},c,{provide:Object.assign(O,c.provide)})),a.$mount(f,d),a)},unmount:function(){a&&(a.$destroy(),a=void 0)}};return b};var q=s;for(var l in n)e[l]=n[l];e.isVue2=!0,e.isVue3=!1,e.install=function(){},e.Vue=n,e.Vue2=n,e.version=n.version,e.warn=n.util.warn,e.createApp=s}else if(n.version.slice(0,2)==="2.")if(_){for(var l in _)e[l]=_[l];e.isVue2=!0,e.isVue3=!1,e.install=function(){},e.Vue=n,e.Vue2=n,e.version=n.version}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if(n.version.slice(0,2)==="3."){for(var l in n)e[l]=n[l];e.isVue2=!1,e.isVue3=!0,e.install=function(){},e.Vue=n,e.Vue2=void 0,e.version=n.version,e.set=function(s,c,u){return Array.isArray(s)?(s.length=Math.max(s.length,c),s.splice(c,1,u),u):(s[c]=u,u)},e.del=function(s,c){if(Array.isArray(s)){s.splice(c,1);return}delete s[c]}}else console.error("[vue-demi] Vue version "+n.version+" is unsupported.");return e}(this.VueDemi=this.VueDemi||(typeof VueDemi!="undefined"?VueDemi:{}),this.Vue||(typeof Vue!="undefined"?Vue:void 0),this.VueCompositionAPI||(typeof VueCompositionAPI!="undefined"?VueCompositionAPI:void 0));(function(e,n,_,l){"use strict";var q=Object.defineProperty,s=Object.defineProperties,c=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable,b=(r,t,o)=>t in r?q(r,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[t]=o,f=(r,t)=>{for(var o in t||(t={}))a.call(t,o)&&b(r,o,t[o]);if(u)for(var o of u(t))O.call(t,o)&&b(r,o,t[o]);return r},d=(r,t)=>s(r,c(t));function B(...r){const t=typeof r[0]=="string"?r[0]:void 0,o=_.isString(t)?1:0;let C={},I=l,v={immediate:!!o,shallow:!0};const E=i=>!!(i==null?void 0:i.request);r.length>0+o&&(E(r[0+o])?I=r[0+o]:C=r[0+o]),r.length>1+o&&E(r[1+o])&&(I=r[1+o]),(r.length===2+o&&!E(r[1+o])||r.length===3+o)&&(v=r[r.length-1]);const T=n.shallowRef(),g=v.shallow?n.shallowRef():n.ref(),h=n.ref(!1),y=n.ref(!1),P=n.ref(!1),j=n.shallowRef(),F=l.CancelToken.source;let R=F();const S=i=>{h.value||!y.value||(R.cancel(i),R=F(),P.value=!0,y.value=!1,h.value=!1)},L=i=>{y.value=i,h.value=!i},M=()=>new Promise((i,w)=>{_.until(h).toBe(!0).then(()=>i(U)).catch(w)}),x=(i,w)=>M().then(i,w),N=(i=t,w={})=>{j.value=void 0;const $=typeof i=="string"?i:t??w.url;return $===void 0?(j.value=new l.AxiosError(l.AxiosError.ERR_INVALID_URL),h.value=!0,{then:x}):(S(),L(!0),I($,d(f(f({},C),typeof i=="object"?i:w),{cancelToken:R.token})).then(p=>{var A;T.value=p;const k=p.data;g.value=k,(A=v.onSuccess)==null||A.call(v,k)}).catch(p=>{var A;j.value=p,(A=v.onError)==null||A.call(v,p)}).finally(()=>{var p;(p=v.onFinish)==null||p.call(v),L(!1)}),{then:x})};v.immediate&&t&&N();const U={response:T,data:g,error:j,finished:h,loading:y,isFinished:h,isLoading:y,cancel:S,isAborted:P,canceled:P,aborted:P,isCanceled:P,abort:S,execute:N};return d(f({},U),{then:x})}e.useAxios=B})(this.VueUse=this.VueUse||{},VueDemi,VueUse,axios);
|
package/useAxios.mjs
CHANGED
|
@@ -88,7 +88,11 @@ function useAxios(...args) {
|
|
|
88
88
|
var _a;
|
|
89
89
|
error.value = e;
|
|
90
90
|
(_a = options.onError) == null ? void 0 : _a.call(options, e);
|
|
91
|
-
}).finally(() =>
|
|
91
|
+
}).finally(() => {
|
|
92
|
+
var _a;
|
|
93
|
+
(_a = options.onFinish) == null ? void 0 : _a.call(options);
|
|
94
|
+
loading(false);
|
|
95
|
+
});
|
|
92
96
|
return { then };
|
|
93
97
|
};
|
|
94
98
|
if (options.immediate && url)
|