@vueuse/integrations 13.4.0 → 13.6.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.d.mts +13 -3
- package/index.iife.js +38 -20
- package/index.iife.min.js +1 -1
- package/index.mjs +38 -20
- package/package.json +6 -6
- package/useChangeCase.iife.js +1 -0
- package/useChangeCase.mjs +1 -0
- package/useCookies.d.mts +2 -0
- package/useCookies.iife.js +2 -1
- package/useCookies.mjs +2 -1
- package/useFocusTrap.d.mts +1 -1
- package/useFocusTrap.iife.js +22 -14
- package/useFocusTrap.iife.min.js +1 -1
- package/useFocusTrap.mjs +22 -14
- package/useIDBKeyval.d.mts +10 -2
- package/useIDBKeyval.iife.js +13 -5
- package/useIDBKeyval.iife.min.js +1 -1
- package/useIDBKeyval.mjs +13 -5
package/index.d.mts
CHANGED
|
@@ -202,6 +202,8 @@ declare function createCookies(req?: IncomingMessage): (dependencies?: string[]
|
|
|
202
202
|
* @param options.doNotParse - don't try parse value as JSON
|
|
203
203
|
* @param options.autoUpdateDependencies - automatically update watching dependencies
|
|
204
204
|
* @param cookies - universal-cookie instance
|
|
205
|
+
*
|
|
206
|
+
* @__NO_SIDE_EFFECTS__
|
|
205
207
|
*/
|
|
206
208
|
declare function useCookies(dependencies?: string[] | null, { doNotParse, autoUpdateDependencies }?: {
|
|
207
209
|
doNotParse?: boolean | undefined;
|
|
@@ -295,7 +297,7 @@ interface UseFocusTrapReturn {
|
|
|
295
297
|
*
|
|
296
298
|
* @see https://vueuse.org/useFocusTrap
|
|
297
299
|
*/
|
|
298
|
-
declare function useFocusTrap(target: Arrayable<MaybeRefOrGetter<string> | MaybeComputedElementRef
|
|
300
|
+
declare function useFocusTrap(target: MaybeRefOrGetter<Arrayable<MaybeRefOrGetter<string> | MaybeComputedElementRef>>, options?: UseFocusTrapOptions): UseFocusTrapReturn;
|
|
299
301
|
|
|
300
302
|
type FuseOptions<T> = IFuseOptions<T>;
|
|
301
303
|
interface UseFuseOptions<T> {
|
|
@@ -323,7 +325,11 @@ declare function useFuse<DataItem>(search: MaybeRefOrGetter<string>, data: Maybe
|
|
|
323
325
|
};
|
|
324
326
|
type UseFuseReturn = ReturnType<typeof useFuse>;
|
|
325
327
|
|
|
326
|
-
interface
|
|
328
|
+
interface Serializer<T> {
|
|
329
|
+
read: (raw: unknown) => T;
|
|
330
|
+
write: (value: T) => unknown;
|
|
331
|
+
}
|
|
332
|
+
interface UseIDBOptions<T> extends ConfigurableFlush {
|
|
327
333
|
/**
|
|
328
334
|
* Watch for deep changes
|
|
329
335
|
*
|
|
@@ -348,6 +354,10 @@ interface UseIDBOptions extends ConfigurableFlush {
|
|
|
348
354
|
* @default true
|
|
349
355
|
*/
|
|
350
356
|
writeDefaults?: boolean;
|
|
357
|
+
/**
|
|
358
|
+
* Custom data serialization
|
|
359
|
+
*/
|
|
360
|
+
serializer?: Serializer<T>;
|
|
351
361
|
}
|
|
352
362
|
interface UseIDBKeyvalReturn<T> {
|
|
353
363
|
data: RemovableRef<T>;
|
|
@@ -360,7 +370,7 @@ interface UseIDBKeyvalReturn<T> {
|
|
|
360
370
|
* @param initialValue
|
|
361
371
|
* @param options
|
|
362
372
|
*/
|
|
363
|
-
declare function useIDBKeyval<T>(key: IDBValidKey, initialValue: MaybeRefOrGetter<T>, options?: UseIDBOptions): UseIDBKeyvalReturn<T>;
|
|
373
|
+
declare function useIDBKeyval<T>(key: IDBValidKey, initialValue: MaybeRefOrGetter<T>, options?: UseIDBOptions<T>): UseIDBKeyvalReturn<T>;
|
|
364
374
|
|
|
365
375
|
interface UseJwtOptions<Fallback> {
|
|
366
376
|
/**
|
package/index.iife.js
CHANGED
|
@@ -209,6 +209,7 @@
|
|
|
209
209
|
acc[name] = fn;
|
|
210
210
|
return acc;
|
|
211
211
|
}, {});
|
|
212
|
+
// @__NO_SIDE_EFFECTS__
|
|
212
213
|
function useChangeCase(input, type, options) {
|
|
213
214
|
const typeRef = vue.computed(() => {
|
|
214
215
|
const t = vue.toValue(type);
|
|
@@ -231,8 +232,9 @@
|
|
|
231
232
|
|
|
232
233
|
function createCookies(req) {
|
|
233
234
|
const universalCookie = new Cookie(req ? req.headers.cookie : null);
|
|
234
|
-
return (dependencies, { doNotParse = false, autoUpdateDependencies = false } = {}) => useCookies(dependencies, { doNotParse, autoUpdateDependencies }, universalCookie);
|
|
235
|
+
return (dependencies, { doNotParse = false, autoUpdateDependencies = false } = {}) => /* @__PURE__ */ useCookies(dependencies, { doNotParse, autoUpdateDependencies }, universalCookie);
|
|
235
236
|
}
|
|
237
|
+
// @__NO_SIDE_EFFECTS__
|
|
236
238
|
function useCookies(dependencies, { doNotParse = false, autoUpdateDependencies = false } = {}, cookies = new Cookie()) {
|
|
237
239
|
const watchingDependencies = autoUpdateDependencies ? [...dependencies || []] : dependencies;
|
|
238
240
|
let previousCookies = cookies.getAll({ doNotParse: true });
|
|
@@ -424,21 +426,29 @@
|
|
|
424
426
|
(els) => {
|
|
425
427
|
if (!els.length)
|
|
426
428
|
return;
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
options.onActivate
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
options.onDeactivate
|
|
429
|
+
if (!trap) {
|
|
430
|
+
trap = focusTrap.createFocusTrap(els, {
|
|
431
|
+
...focusTrapOptions,
|
|
432
|
+
onActivate() {
|
|
433
|
+
hasFocus.value = true;
|
|
434
|
+
if (options.onActivate)
|
|
435
|
+
options.onActivate();
|
|
436
|
+
},
|
|
437
|
+
onDeactivate() {
|
|
438
|
+
hasFocus.value = false;
|
|
439
|
+
if (options.onDeactivate)
|
|
440
|
+
options.onDeactivate();
|
|
441
|
+
}
|
|
442
|
+
});
|
|
443
|
+
if (immediate)
|
|
444
|
+
activate();
|
|
445
|
+
} else {
|
|
446
|
+
const isActive = trap == null ? void 0 : trap.active;
|
|
447
|
+
trap == null ? void 0 : trap.updateContainerElements(els);
|
|
448
|
+
if (!isActive && immediate) {
|
|
449
|
+
activate();
|
|
438
450
|
}
|
|
439
|
-
}
|
|
440
|
-
if (immediate)
|
|
441
|
-
activate();
|
|
451
|
+
}
|
|
442
452
|
},
|
|
443
453
|
{ flush: "post" }
|
|
444
454
|
);
|
|
@@ -500,7 +510,11 @@
|
|
|
500
510
|
onError = (e) => {
|
|
501
511
|
console.error(e);
|
|
502
512
|
},
|
|
503
|
-
writeDefaults = true
|
|
513
|
+
writeDefaults = true,
|
|
514
|
+
serializer = {
|
|
515
|
+
read: (raw) => raw,
|
|
516
|
+
write: (value) => value
|
|
517
|
+
}
|
|
504
518
|
} = options;
|
|
505
519
|
const isFinished = vue.shallowRef(false);
|
|
506
520
|
const data = (shallow ? vue.shallowRef : vue.ref)(initialValue);
|
|
@@ -509,10 +523,12 @@
|
|
|
509
523
|
try {
|
|
510
524
|
const rawValue = await idbKeyval.get(key);
|
|
511
525
|
if (rawValue === void 0) {
|
|
512
|
-
if (rawInit !== void 0 && rawInit !== null && writeDefaults)
|
|
513
|
-
|
|
526
|
+
if (rawInit !== void 0 && rawInit !== null && writeDefaults) {
|
|
527
|
+
const initValue = serializer.write(rawInit);
|
|
528
|
+
await idbKeyval.set(key, initValue);
|
|
529
|
+
}
|
|
514
530
|
} else {
|
|
515
|
-
data.value = rawValue;
|
|
531
|
+
data.value = serializer.read(rawValue);
|
|
516
532
|
}
|
|
517
533
|
} catch (e) {
|
|
518
534
|
onError(e);
|
|
@@ -525,7 +541,9 @@
|
|
|
525
541
|
if (data.value == null) {
|
|
526
542
|
await idbKeyval.del(key);
|
|
527
543
|
} else {
|
|
528
|
-
|
|
544
|
+
const rawValue = vue.toRaw(data.value);
|
|
545
|
+
const serializedValue = serializer.write(rawValue);
|
|
546
|
+
await idbKeyval.update(key, () => serializedValue);
|
|
529
547
|
}
|
|
530
548
|
} catch (e) {
|
|
531
549
|
onError(e);
|
package/index.iife.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(y,V,U,n,L,$,k,g,K,X,Y,P,Z,E,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.shallowRef(!0),h=n.shallowRef(!r||u),d=n.computed(()=>{var v;return((v=c.value)==null?void 0:v.errors)||[]}),C=n.computed(()=>{var v;return((v=c.value)==null?void 0:v.fields)||{}}),m=n.computed(()=>new ae(n.toValue(o))),p=async()=>{s.value=!1,h.value=!1;try{await m.value.validate(l.value,a),h.value=!0,c.value=null}catch(v){c.value=v}finally{s.value=!0}return{pass:h.value,errorInfo:c.value,errors:d.value,errorFields:C.value}};u||n.watch([l,m],()=>p(),{immediate:r,deep:!0});const R={isFinished:s,pass:h,errors:d,errorInfo:c,errorFields:C,execute:p};function A(){return new Promise((v,f)=>{V.until(s).toBe(!0).then(()=>v(R)).catch(b=>f(b))})}return{...R,then(v,f){return A().then(v,f)}}}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=w=>!!w?.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:h=V.noop,onError:d=V.noop,immediate:C,resetOnExecute:m=!1}=l,p=l.initialData,R=n.shallowRef(),A=(s?n.shallowRef:n.ref)(p),v=n.shallowRef(!1),f=n.shallowRef(!1),b=n.shallowRef(!1),D=n.shallowRef();let S=new AbortController;const F=w=>{v.value||!f.value||(S.abort(w),S=new AbortController,b.value=!0,f.value=!1,v.value=!1)},i=w=>{f.value=w,v.value=!w},_=()=>{m&&(A.value=p)},G=()=>new Promise((w,I)=>{V.until(v).toBe(!0).then(()=>D.value?I(D.value):w(q))}),H={then:(...w)=>G().then(...w),catch:(...w)=>G().catch(...w)};let j=0;const Q=(w=o,I={})=>{D.value=void 0;const J=typeof w=="string"?w:o??I.url;if(J===void 0)return D.value=new L.AxiosError(L.AxiosError.ERR_INVALID_URL),v.value=!0,H;_(),l.abortPrevious!==!1&&F(),i(!0),j+=1;const pe=j;return b.value=!1,u(J,{...r,...typeof w=="object"?w:I,signal:S.signal}).then(O=>{if(b.value)return;R.value=O;const M=O.data;A.value=M,h(M)}).catch(O=>{D.value=O,d(O)}).finally(()=>{var O;(O=l.onFinish)==null||O.call(l),pe===j&&i(!1)}),H};C&&o&&Q();const q={response:R,data:A,error:D,isFinished:v,isLoading:f,cancel:F,isAborted:b,isCanceled:b,abort:F,execute:Q};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 se(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.shallowRef(0),c=()=>{const s=a.getAll({doNotParse:!0});ue(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 ue(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=g.createEventHook(),u=g.createEventHook(),l=g.createEventHook(),c=g.createEventHook(),s=g.createEventHook(),h=n.shallowRef(!1),d=n.shallowRef(!1),C=n.shallowRef(!1),m=n.shallowRef(!1),p=n.ref({color:"black",size:3,arrowEnd:!1,cornerRadius:0,dasharray:void 0,fill:"transparent",mode:"draw",...o?.brush});n.watch(p,()=>{const i=e.value;i&&(i.brush=p.value,i.mode=p.value.mode)},{deep:!0});const R=()=>{var i;return(i=e.value)==null?void 0:i.undo()},A=()=>{var i;return(i=e.value)==null?void 0:i.redo()},v=()=>{var i;return(i=e.value)==null?void 0:i.clear()},f=()=>{var i;return(i=e.value)==null?void 0:i.cancel()},b=i=>{var _;return(_=e.value)==null?void 0:_.load(i)},D=()=>{var i;return(i=e.value)==null?void 0:i.dump()},S=()=>{var i;a.forEach(_=>_()),(i=e.value)==null||i.unmount()},F=()=>{e.value&&(h.value=e.value.canUndo(),d.value=e.value.canRedo(),C.value=e.value.altPressed,m.value=e.value.shiftPressed)};return n.watch(()=>g.unrefElement(t),i=>{!i||typeof SVGSVGElement>"u"||!(i instanceof SVGSVGElement)||(e.value&&S(),e.value=K.createDrauu({el:i,...o}),F(),a=[e.value.on("canceled",()=>u.trigger()),e.value.on("committed",_=>l.trigger(_)),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:b,dump:D,clear:v,cancel:f,undo:R,redo:A,canUndo:h,canRedo:d,brush:p,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.shallowRef(!1),l=n.shallowRef(!1),c=m=>e&&e.activate(m),s=m=>e&&e.deactivate(m),h=()=>{e&&(e.pause(),l.value=!0)},d=()=>{e&&(e.unpause(),l.value=!1)},C=n.computed(()=>{const m=n.toValue(t);return g.toArray(m).map(p=>{const R=n.toValue(p);return typeof R=="string"?R:g.unrefElement(R)}).filter(V.notNullish)});return n.watch(C,m=>{if(m.length)if(!e)e=X.createFocusTrap(m,{...r,onActivate(){u.value=!0,o.onActivate&&o.onActivate()},onDeactivate(){u.value=!1,o.onDeactivate&&o.onDeactivate()}}),a&&c();else{const p=e?.active;e?.updateContainerElements(m),!p&&a&&c()}},{flush:"post"}),g.tryOnScopeDispose(()=>s()),{hasFocus:u,isPaused:l,activate:c,deactivate:s,pause:h,unpause:d}}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,h)=>({item:s,refIndex:h}));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=f=>{console.error(f)},writeDefaults:c=!0,serializer:s={read:f=>f,write:f=>f}}=e,h=n.shallowRef(!1),d=(u?n.shallowRef:n.ref)(o),C=n.toValue(o);async function m(){try{const f=await P.get(t);if(f===void 0){if(C!=null&&c){const b=s.write(C);await P.set(t,b)}}else d.value=s.read(f)}catch(f){l(f)}h.value=!0}m();async function p(){try{if(d.value==null)await P.del(t);else{const f=n.toRaw(d.value),b=s.write(f);await P.update(t,()=>b)}}catch(f){l(f)}}const{pause:R,resume:A}=g.watchPausable(d,()=>p(),{flush:a,deep:r});async function v(f){R(),d.value=f,await p(),A()}return{set:v,isFinished:h,data:d}}function ve(t,o={}){const{onError:e,fallbackValue:a=null}=o,r=(c,s)=>{try{return Z.jwtDecode(c,s)}catch(h){return e?.(h),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=V.toRef(t),a=n.computed({set:u=>u?E.start():E.done(),get:()=>typeof e.value=="number"&&e.value<1});o&&E.configure(o);const r=E.set;return E.set=u=>(e.value=u,r.call(E,u)),n.watchEffect(()=>{typeof e.value=="number"&&V.isClient&&r.call(E,e.value)}),V.tryOnScopeDispose(E.remove),{isLoading:a,progress:e,start:E.start,done:E.done,remove:()=>{e.value=null,E.remove()}}}function me(t,o){const e=V.toRef(t),a=n.shallowRef("");return n.watch(e,async r=>{e.value&&V.isClient&&(a.value=await x.toDataURL(r,o))},{immediate:!0}),a}function we(t,o,e={}){let a;const{document:r=g.defaultDocument,...u}=e,l={onUpdate:d=>{z(o,d.oldIndex,d.newIndex,d)}},c=()=>{const d=typeof t=="string"?r?.querySelector(t):g.unrefElement(t);!d||a!==void 0||(a=new ee(d,{...l,...u}))},s=()=>{a?.destroy(),a=void 0},h=(d,C)=>{if(C!==void 0)a?.option(d,C);else return a?.option(d)};return g.tryOnMounted(c),g.tryOnScopeDispose(s),{stop:s,start:c,option:h}}function B(t,o,e){const a=t.children[e];t.insertBefore(o,a)}function W(t){t.parentNode&&t.parentNode.removeChild(t)}function z(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)})}}y.createCookies=se,y.insertNodeAt=B,y.moveArrayElement=z,y.removeNode=W,y.useAsyncValidator=oe,y.useAxios=le,y.useChangeCase=re,y.useCookies=T,y.useDrauu=ce,y.useFocusTrap=ie,y.useFuse=fe,y.useIDBKeyval=de,y.useJwt=ve,y.useNProgress=he,y.useQRCode=me,y.useSortable=we})(this.VueUse=this.VueUse||{},VueUse,AsyncValidator,Vue,axios,changeCase,UniversalCookie,VueUse,Drauu,focusTrap,Fuse,idbKeyval,jwt_decode,nprogress,QRCode,Sortable);
|
package/index.mjs
CHANGED
|
@@ -203,6 +203,7 @@ const changeCaseTransforms = /* @__PURE__ */ Object.entries(changeCase).filter((
|
|
|
203
203
|
acc[name] = fn;
|
|
204
204
|
return acc;
|
|
205
205
|
}, {});
|
|
206
|
+
// @__NO_SIDE_EFFECTS__
|
|
206
207
|
function useChangeCase(input, type, options) {
|
|
207
208
|
const typeRef = computed(() => {
|
|
208
209
|
const t = toValue(type);
|
|
@@ -225,8 +226,9 @@ function useChangeCase(input, type, options) {
|
|
|
225
226
|
|
|
226
227
|
function createCookies(req) {
|
|
227
228
|
const universalCookie = new Cookie(req ? req.headers.cookie : null);
|
|
228
|
-
return (dependencies, { doNotParse = false, autoUpdateDependencies = false } = {}) => useCookies(dependencies, { doNotParse, autoUpdateDependencies }, universalCookie);
|
|
229
|
+
return (dependencies, { doNotParse = false, autoUpdateDependencies = false } = {}) => /* @__PURE__ */ useCookies(dependencies, { doNotParse, autoUpdateDependencies }, universalCookie);
|
|
229
230
|
}
|
|
231
|
+
// @__NO_SIDE_EFFECTS__
|
|
230
232
|
function useCookies(dependencies, { doNotParse = false, autoUpdateDependencies = false } = {}, cookies = new Cookie()) {
|
|
231
233
|
const watchingDependencies = autoUpdateDependencies ? [...dependencies || []] : dependencies;
|
|
232
234
|
let previousCookies = cookies.getAll({ doNotParse: true });
|
|
@@ -418,21 +420,29 @@ function useFocusTrap(target, options = {}) {
|
|
|
418
420
|
(els) => {
|
|
419
421
|
if (!els.length)
|
|
420
422
|
return;
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
options.onActivate
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
options.onDeactivate
|
|
423
|
+
if (!trap) {
|
|
424
|
+
trap = createFocusTrap(els, {
|
|
425
|
+
...focusTrapOptions,
|
|
426
|
+
onActivate() {
|
|
427
|
+
hasFocus.value = true;
|
|
428
|
+
if (options.onActivate)
|
|
429
|
+
options.onActivate();
|
|
430
|
+
},
|
|
431
|
+
onDeactivate() {
|
|
432
|
+
hasFocus.value = false;
|
|
433
|
+
if (options.onDeactivate)
|
|
434
|
+
options.onDeactivate();
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
if (immediate)
|
|
438
|
+
activate();
|
|
439
|
+
} else {
|
|
440
|
+
const isActive = trap == null ? void 0 : trap.active;
|
|
441
|
+
trap == null ? void 0 : trap.updateContainerElements(els);
|
|
442
|
+
if (!isActive && immediate) {
|
|
443
|
+
activate();
|
|
432
444
|
}
|
|
433
|
-
}
|
|
434
|
-
if (immediate)
|
|
435
|
-
activate();
|
|
445
|
+
}
|
|
436
446
|
},
|
|
437
447
|
{ flush: "post" }
|
|
438
448
|
);
|
|
@@ -494,7 +504,11 @@ function useIDBKeyval(key, initialValue, options = {}) {
|
|
|
494
504
|
onError = (e) => {
|
|
495
505
|
console.error(e);
|
|
496
506
|
},
|
|
497
|
-
writeDefaults = true
|
|
507
|
+
writeDefaults = true,
|
|
508
|
+
serializer = {
|
|
509
|
+
read: (raw) => raw,
|
|
510
|
+
write: (value) => value
|
|
511
|
+
}
|
|
498
512
|
} = options;
|
|
499
513
|
const isFinished = shallowRef(false);
|
|
500
514
|
const data = (shallow ? shallowRef : ref)(initialValue);
|
|
@@ -503,10 +517,12 @@ function useIDBKeyval(key, initialValue, options = {}) {
|
|
|
503
517
|
try {
|
|
504
518
|
const rawValue = await get(key);
|
|
505
519
|
if (rawValue === void 0) {
|
|
506
|
-
if (rawInit !== void 0 && rawInit !== null && writeDefaults)
|
|
507
|
-
|
|
520
|
+
if (rawInit !== void 0 && rawInit !== null && writeDefaults) {
|
|
521
|
+
const initValue = serializer.write(rawInit);
|
|
522
|
+
await set(key, initValue);
|
|
523
|
+
}
|
|
508
524
|
} else {
|
|
509
|
-
data.value = rawValue;
|
|
525
|
+
data.value = serializer.read(rawValue);
|
|
510
526
|
}
|
|
511
527
|
} catch (e) {
|
|
512
528
|
onError(e);
|
|
@@ -519,7 +535,9 @@ function useIDBKeyval(key, initialValue, options = {}) {
|
|
|
519
535
|
if (data.value == null) {
|
|
520
536
|
await del(key);
|
|
521
537
|
} else {
|
|
522
|
-
|
|
538
|
+
const rawValue = toRaw(data.value);
|
|
539
|
+
const serializedValue = serializer.write(rawValue);
|
|
540
|
+
await update(key, () => serializedValue);
|
|
523
541
|
}
|
|
524
542
|
} catch (e) {
|
|
525
543
|
onError(e);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vueuse/integrations",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "13.
|
|
4
|
+
"version": "13.6.0",
|
|
5
5
|
"description": "Integration wrappers for utility libraries",
|
|
6
6
|
"author": "Anthony Fu <https://github.com/antfu>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"nprogress": "^0.2",
|
|
63
63
|
"qrcode": "^1.5",
|
|
64
64
|
"sortablejs": "^1",
|
|
65
|
-
"universal-cookie": "^7",
|
|
65
|
+
"universal-cookie": "^7 || ^8",
|
|
66
66
|
"vue": "^3.5.0"
|
|
67
67
|
},
|
|
68
68
|
"peerDependenciesMeta": {
|
|
@@ -104,15 +104,15 @@
|
|
|
104
104
|
}
|
|
105
105
|
},
|
|
106
106
|
"dependencies": {
|
|
107
|
-
"@vueuse/
|
|
108
|
-
"@vueuse/
|
|
107
|
+
"@vueuse/shared": "13.6.0",
|
|
108
|
+
"@vueuse/core": "13.6.0"
|
|
109
109
|
},
|
|
110
110
|
"devDependencies": {
|
|
111
111
|
"@types/nprogress": "^0.2.3",
|
|
112
112
|
"@types/qrcode": "^1.5.5",
|
|
113
113
|
"@types/sortablejs": "^1.15.8",
|
|
114
114
|
"async-validator": "^4.2.5",
|
|
115
|
-
"axios": "^1.
|
|
115
|
+
"axios": "^1.11.0",
|
|
116
116
|
"change-case": "^5.4.4",
|
|
117
117
|
"drauu": "^0.4.3",
|
|
118
118
|
"focus-trap": "^7.6.5",
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
"nprogress": "^0.2.0",
|
|
123
123
|
"qrcode": "^1.5.4",
|
|
124
124
|
"sortablejs": "^1.15.6",
|
|
125
|
-
"universal-cookie": "^
|
|
125
|
+
"universal-cookie": "^8.0.1"
|
|
126
126
|
},
|
|
127
127
|
"scripts": {
|
|
128
128
|
"build": "rollup --config=rollup.config.ts --configPlugin=rollup-plugin-esbuild",
|
package/useChangeCase.iife.js
CHANGED
package/useChangeCase.mjs
CHANGED
package/useCookies.d.mts
CHANGED
|
@@ -32,6 +32,8 @@ declare function createCookies(req?: IncomingMessage): (dependencies?: string[]
|
|
|
32
32
|
* @param options.doNotParse - don't try parse value as JSON
|
|
33
33
|
* @param options.autoUpdateDependencies - automatically update watching dependencies
|
|
34
34
|
* @param cookies - universal-cookie instance
|
|
35
|
+
*
|
|
36
|
+
* @__NO_SIDE_EFFECTS__
|
|
35
37
|
*/
|
|
36
38
|
declare function useCookies(dependencies?: string[] | null, { doNotParse, autoUpdateDependencies }?: {
|
|
37
39
|
doNotParse?: boolean | undefined;
|
package/useCookies.iife.js
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
function createCookies(req) {
|
|
5
5
|
const universalCookie = new Cookie(req ? req.headers.cookie : null);
|
|
6
|
-
return (dependencies, { doNotParse = false, autoUpdateDependencies = false } = {}) => useCookies(dependencies, { doNotParse, autoUpdateDependencies }, universalCookie);
|
|
6
|
+
return (dependencies, { doNotParse = false, autoUpdateDependencies = false } = {}) => /* @__PURE__ */ useCookies(dependencies, { doNotParse, autoUpdateDependencies }, universalCookie);
|
|
7
7
|
}
|
|
8
|
+
// @__NO_SIDE_EFFECTS__
|
|
8
9
|
function useCookies(dependencies, { doNotParse = false, autoUpdateDependencies = false } = {}, cookies = new Cookie()) {
|
|
9
10
|
const watchingDependencies = autoUpdateDependencies ? [...dependencies || []] : dependencies;
|
|
10
11
|
let previousCookies = cookies.getAll({ doNotParse: true });
|
package/useCookies.mjs
CHANGED
|
@@ -4,8 +4,9 @@ import { shallowRef } from 'vue';
|
|
|
4
4
|
|
|
5
5
|
function createCookies(req) {
|
|
6
6
|
const universalCookie = new Cookie(req ? req.headers.cookie : null);
|
|
7
|
-
return (dependencies, { doNotParse = false, autoUpdateDependencies = false } = {}) => useCookies(dependencies, { doNotParse, autoUpdateDependencies }, universalCookie);
|
|
7
|
+
return (dependencies, { doNotParse = false, autoUpdateDependencies = false } = {}) => /* @__PURE__ */ useCookies(dependencies, { doNotParse, autoUpdateDependencies }, universalCookie);
|
|
8
8
|
}
|
|
9
|
+
// @__NO_SIDE_EFFECTS__
|
|
9
10
|
function useCookies(dependencies, { doNotParse = false, autoUpdateDependencies = false } = {}, cookies = new Cookie()) {
|
|
10
11
|
const watchingDependencies = autoUpdateDependencies ? [...dependencies || []] : dependencies;
|
|
11
12
|
let previousCookies = cookies.getAll({ doNotParse: true });
|
package/useFocusTrap.d.mts
CHANGED
|
@@ -49,7 +49,7 @@ interface UseFocusTrapReturn {
|
|
|
49
49
|
*
|
|
50
50
|
* @see https://vueuse.org/useFocusTrap
|
|
51
51
|
*/
|
|
52
|
-
declare function useFocusTrap(target: Arrayable<MaybeRefOrGetter<string> | MaybeComputedElementRef
|
|
52
|
+
declare function useFocusTrap(target: MaybeRefOrGetter<Arrayable<MaybeRefOrGetter<string> | MaybeComputedElementRef>>, options?: UseFocusTrapOptions): UseFocusTrapReturn;
|
|
53
53
|
|
|
54
54
|
export { useFocusTrap };
|
|
55
55
|
export type { UseFocusTrapOptions, UseFocusTrapReturn };
|
package/useFocusTrap.iife.js
CHANGED
|
@@ -32,21 +32,29 @@
|
|
|
32
32
|
(els) => {
|
|
33
33
|
if (!els.length)
|
|
34
34
|
return;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
options.onActivate
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
options.onDeactivate
|
|
35
|
+
if (!trap) {
|
|
36
|
+
trap = focusTrap.createFocusTrap(els, {
|
|
37
|
+
...focusTrapOptions,
|
|
38
|
+
onActivate() {
|
|
39
|
+
hasFocus.value = true;
|
|
40
|
+
if (options.onActivate)
|
|
41
|
+
options.onActivate();
|
|
42
|
+
},
|
|
43
|
+
onDeactivate() {
|
|
44
|
+
hasFocus.value = false;
|
|
45
|
+
if (options.onDeactivate)
|
|
46
|
+
options.onDeactivate();
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
if (immediate)
|
|
50
|
+
activate();
|
|
51
|
+
} else {
|
|
52
|
+
const isActive = trap == null ? void 0 : trap.active;
|
|
53
|
+
trap == null ? void 0 : trap.updateContainerElements(els);
|
|
54
|
+
if (!isActive && immediate) {
|
|
55
|
+
activate();
|
|
46
56
|
}
|
|
47
|
-
}
|
|
48
|
-
if (immediate)
|
|
49
|
-
activate();
|
|
57
|
+
}
|
|
50
58
|
},
|
|
51
59
|
{ flush: "post" }
|
|
52
60
|
);
|
package/useFocusTrap.iife.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(p,u,v,h,a){"use strict";function d(V,s={}){let e;const{immediate:r,...m}=s,n=a.shallowRef(!1),c=a.shallowRef(!1),i=t=>e&&e.activate(t),f=t=>e&&e.deactivate(t),A=()=>{e&&(e.pause(),c.value=!0)},T=()=>{e&&(e.unpause(),c.value=!1)},g=a.computed(()=>{const t=a.toValue(V);return u.toArray(t).map(o=>{const l=a.toValue(o);return typeof l=="string"?l:u.unrefElement(l)}).filter(v.notNullish)});return a.watch(g,t=>{if(t.length)if(!e)e=h.createFocusTrap(t,{...m,onActivate(){n.value=!0,s.onActivate&&s.onActivate()},onDeactivate(){n.value=!1,s.onDeactivate&&s.onDeactivate()}}),r&&i();else{const o=e?.active;e?.updateContainerElements(t),!o&&r&&i()}},{flush:"post"}),u.tryOnScopeDispose(()=>f()),{hasFocus:n,isPaused:c,activate:i,deactivate:f,pause:A,unpause:T}}p.useFocusTrap=d})(this.VueUse=this.VueUse||{},VueUse,VueUse,focusTrap,Vue);
|
package/useFocusTrap.mjs
CHANGED
|
@@ -34,21 +34,29 @@ function useFocusTrap(target, options = {}) {
|
|
|
34
34
|
(els) => {
|
|
35
35
|
if (!els.length)
|
|
36
36
|
return;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
options.onActivate
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
options.onDeactivate
|
|
37
|
+
if (!trap) {
|
|
38
|
+
trap = createFocusTrap(els, {
|
|
39
|
+
...focusTrapOptions,
|
|
40
|
+
onActivate() {
|
|
41
|
+
hasFocus.value = true;
|
|
42
|
+
if (options.onActivate)
|
|
43
|
+
options.onActivate();
|
|
44
|
+
},
|
|
45
|
+
onDeactivate() {
|
|
46
|
+
hasFocus.value = false;
|
|
47
|
+
if (options.onDeactivate)
|
|
48
|
+
options.onDeactivate();
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
if (immediate)
|
|
52
|
+
activate();
|
|
53
|
+
} else {
|
|
54
|
+
const isActive = trap == null ? void 0 : trap.active;
|
|
55
|
+
trap == null ? void 0 : trap.updateContainerElements(els);
|
|
56
|
+
if (!isActive && immediate) {
|
|
57
|
+
activate();
|
|
48
58
|
}
|
|
49
|
-
}
|
|
50
|
-
if (immediate)
|
|
51
|
-
activate();
|
|
59
|
+
}
|
|
52
60
|
},
|
|
53
61
|
{ flush: "post" }
|
|
54
62
|
);
|
package/useIDBKeyval.d.mts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { ConfigurableFlush, RemovableRef } from '@vueuse/shared';
|
|
2
2
|
import { ShallowRef, MaybeRefOrGetter } from 'vue';
|
|
3
3
|
|
|
4
|
-
interface
|
|
4
|
+
interface Serializer<T> {
|
|
5
|
+
read: (raw: unknown) => T;
|
|
6
|
+
write: (value: T) => unknown;
|
|
7
|
+
}
|
|
8
|
+
interface UseIDBOptions<T> extends ConfigurableFlush {
|
|
5
9
|
/**
|
|
6
10
|
* Watch for deep changes
|
|
7
11
|
*
|
|
@@ -26,6 +30,10 @@ interface UseIDBOptions extends ConfigurableFlush {
|
|
|
26
30
|
* @default true
|
|
27
31
|
*/
|
|
28
32
|
writeDefaults?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Custom data serialization
|
|
35
|
+
*/
|
|
36
|
+
serializer?: Serializer<T>;
|
|
29
37
|
}
|
|
30
38
|
interface UseIDBKeyvalReturn<T> {
|
|
31
39
|
data: RemovableRef<T>;
|
|
@@ -38,7 +46,7 @@ interface UseIDBKeyvalReturn<T> {
|
|
|
38
46
|
* @param initialValue
|
|
39
47
|
* @param options
|
|
40
48
|
*/
|
|
41
|
-
declare function useIDBKeyval<T>(key: IDBValidKey, initialValue: MaybeRefOrGetter<T>, options?: UseIDBOptions): UseIDBKeyvalReturn<T>;
|
|
49
|
+
declare function useIDBKeyval<T>(key: IDBValidKey, initialValue: MaybeRefOrGetter<T>, options?: UseIDBOptions<T>): UseIDBKeyvalReturn<T>;
|
|
42
50
|
|
|
43
51
|
export { useIDBKeyval };
|
|
44
52
|
export type { UseIDBKeyvalReturn, UseIDBOptions };
|
package/useIDBKeyval.iife.js
CHANGED
|
@@ -9,7 +9,11 @@
|
|
|
9
9
|
onError = (e) => {
|
|
10
10
|
console.error(e);
|
|
11
11
|
},
|
|
12
|
-
writeDefaults = true
|
|
12
|
+
writeDefaults = true,
|
|
13
|
+
serializer = {
|
|
14
|
+
read: (raw) => raw,
|
|
15
|
+
write: (value) => value
|
|
16
|
+
}
|
|
13
17
|
} = options;
|
|
14
18
|
const isFinished = vue.shallowRef(false);
|
|
15
19
|
const data = (shallow ? vue.shallowRef : vue.ref)(initialValue);
|
|
@@ -18,10 +22,12 @@
|
|
|
18
22
|
try {
|
|
19
23
|
const rawValue = await idbKeyval.get(key);
|
|
20
24
|
if (rawValue === void 0) {
|
|
21
|
-
if (rawInit !== void 0 && rawInit !== null && writeDefaults)
|
|
22
|
-
|
|
25
|
+
if (rawInit !== void 0 && rawInit !== null && writeDefaults) {
|
|
26
|
+
const initValue = serializer.write(rawInit);
|
|
27
|
+
await idbKeyval.set(key, initValue);
|
|
28
|
+
}
|
|
23
29
|
} else {
|
|
24
|
-
data.value = rawValue;
|
|
30
|
+
data.value = serializer.read(rawValue);
|
|
25
31
|
}
|
|
26
32
|
} catch (e) {
|
|
27
33
|
onError(e);
|
|
@@ -34,7 +40,9 @@
|
|
|
34
40
|
if (data.value == null) {
|
|
35
41
|
await idbKeyval.del(key);
|
|
36
42
|
} else {
|
|
37
|
-
|
|
43
|
+
const rawValue = vue.toRaw(data.value);
|
|
44
|
+
const serializedValue = serializer.write(rawValue);
|
|
45
|
+
await idbKeyval.update(key, () => serializedValue);
|
|
38
46
|
}
|
|
39
47
|
} catch (e) {
|
|
40
48
|
onError(e);
|
package/useIDBKeyval.iife.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(f,h,s,t){"use strict";function d(r,i,V={}){const{flush:p="pre",deep:D=!0,shallow:v=!1,onError:c=e=>{console.error(e)},writeDefaults:I=!0,serializer:u={read:e=>e,write:e=>e}}=V,o=t.shallowRef(!1),a=(v?t.shallowRef:t.ref)(i),l=t.toValue(i);async function R(){try{const e=await s.get(r);if(e===void 0){if(l!=null&&I){const n=u.write(l);await s.set(r,n)}}else a.value=u.read(e)}catch(e){c(e)}o.value=!0}R();async function w(){try{if(a.value==null)await s.del(r);else{const e=t.toRaw(a.value),n=u.write(e);await s.update(r,()=>n)}}catch(e){c(e)}}const{pause:U,resume:m}=h.watchPausable(a,()=>w(),{flush:p,deep:D});async function y(e){U(),a.value=e,await w(),m()}return{set:y,isFinished:o,data:a}}f.useIDBKeyval=d})(this.VueUse=this.VueUse||{},VueUse,idbKeyval,Vue);
|
package/useIDBKeyval.mjs
CHANGED
|
@@ -10,7 +10,11 @@ function useIDBKeyval(key, initialValue, options = {}) {
|
|
|
10
10
|
onError = (e) => {
|
|
11
11
|
console.error(e);
|
|
12
12
|
},
|
|
13
|
-
writeDefaults = true
|
|
13
|
+
writeDefaults = true,
|
|
14
|
+
serializer = {
|
|
15
|
+
read: (raw) => raw,
|
|
16
|
+
write: (value) => value
|
|
17
|
+
}
|
|
14
18
|
} = options;
|
|
15
19
|
const isFinished = shallowRef(false);
|
|
16
20
|
const data = (shallow ? shallowRef : ref)(initialValue);
|
|
@@ -19,10 +23,12 @@ function useIDBKeyval(key, initialValue, options = {}) {
|
|
|
19
23
|
try {
|
|
20
24
|
const rawValue = await get(key);
|
|
21
25
|
if (rawValue === void 0) {
|
|
22
|
-
if (rawInit !== void 0 && rawInit !== null && writeDefaults)
|
|
23
|
-
|
|
26
|
+
if (rawInit !== void 0 && rawInit !== null && writeDefaults) {
|
|
27
|
+
const initValue = serializer.write(rawInit);
|
|
28
|
+
await set(key, initValue);
|
|
29
|
+
}
|
|
24
30
|
} else {
|
|
25
|
-
data.value = rawValue;
|
|
31
|
+
data.value = serializer.read(rawValue);
|
|
26
32
|
}
|
|
27
33
|
} catch (e) {
|
|
28
34
|
onError(e);
|
|
@@ -35,7 +41,9 @@ function useIDBKeyval(key, initialValue, options = {}) {
|
|
|
35
41
|
if (data.value == null) {
|
|
36
42
|
await del(key);
|
|
37
43
|
} else {
|
|
38
|
-
|
|
44
|
+
const rawValue = toRaw(data.value);
|
|
45
|
+
const serializedValue = serializer.write(rawValue);
|
|
46
|
+
await update(key, () => serializedValue);
|
|
39
47
|
}
|
|
40
48
|
} catch (e) {
|
|
41
49
|
onError(e);
|