vue-composable
Advanced tools
Comparing version 1.0.0-dev.15 to 1.0.0-dev.16
@@ -1,1 +0,1 @@ | ||
var vueComposable=function(e,t){"use strict";function n(e){return t.isRef(e)?e.value:e}function r(e){return t.isRef(e)?e:t.ref(e)}const o=Array.isArray,a=e=>"function"==typeof e,l=e=>"string"==typeof e,u=e=>"boolean"==typeof e,s=e=>c(e)&&a(e.getTime),i=e=>"number"==typeof e,c=e=>null!==e&&"object"==typeof e,v=e=>c(e)&&!!e.tagName;function d(e){return c(e)&&a(e.then)&&a(e.catch)}const f=()=>{},m=()=>!1,p={passive:!0};function h(e){return new Promise(t=>{setTimeout(t,e)})}function g(e,t,n){return e<t?t:e>n?n:e}const y="undefined"!=typeof window;function w(e,...t){for(let r=0;r<t.length;r++){const o=t[r];if(void 0===o||!c(o))continue;const a=Object.keys(o);for(let t=0;t<a.length;t++){const r=a[t],l=n(o[r]),u=typeof l,s=typeof e[r];void 0!==e[r]&&u!==s||(e[r]=c(l)?w(e[r]||{},l):o[r])}}return e}function b(e){const n=r(e.currentPage),o=r(e.pageSize),a=t.ref(0),l=r(e.total),u=t.computed({get:()=>a.value,set(e){i(e)&&(a.value=Math.min(e,l.value))}}),s=t.computed({get:()=>n.value,set(e){i(e)&&(n.value=g(e,1,v.value),u.value=(n.value-1)*c.value)}}),c=t.computed({get:()=>o.value,set(e){i(e)&&(o.value=e)}}),v=t.computed(()=>Math.ceil(l.value/c.value));s.value=n.value;return t.watch([l,c],()=>{s.value>v.value&&(s.value=v.value)},{lazy:!0}),{pageSize:c,total:l,currentPage:s,offset:u,lastPage:v,next:()=>++s.value,prev:()=>--s.value,first:()=>s.value=1,last:()=>s.value=v.value}}function $(e,n=!1){if(!e)throw new Error(`[usePromise] argument can't be '${e}'`);if("function"!=typeof e)throw new Error(`[usePromise] expects function, but received ${typeof e}`);const r=t.ref(!1),o=t.ref(null),a=t.ref(null),l=t.ref();return{exec:async(...t)=>{r.value=!0,o.value=null,a.value=null;let s=t&&e.length!==t.length&&t.length>0&&u(t[t.length-1])?t[t.length-1]:n;const i=l.value=e(...t);try{const e=await i;return l.value===i&&(a.value=e),e}catch(e){return l.value===i&&(o.value=e,a.value=null),s?i:void 0}finally{l.value===i&&(r.value=!1)}},result:a,promise:l,loading:r,error:o}}const E=Symbol(""),M=Symbol(""),S=async(e,t,n,r)=>{const o=t[E].value;let a=-1;const l=e.maxRetries||9001,u=e.retryDelay||I;t.retryErrors.value=[],t.isRetrying.value=!1,t.nextRetry.value=void 0;let c=void 0;do{let e=!1,v=null;try{if(++a,v=r?n(...r):n(),d(v)&&(v=await v),t[M].value)return null;e=!0}catch(e){v=null,t.retryErrors.value.push(e)}if(o!==t[E].value)return v;if(e)return t.isRetrying.value=!1,t.nextRetry.value=void 0,v;if(a>=l)return t.isRetrying.value=!1,t.nextRetry.value=void 0,Promise.reject(new Error(`[useRetry] max retries reached ${l}`));t.isRetrying.value=!0;const f=Date.now(),m=u(a),p=d(m)?await m:m;if(!d(m)||p){if(i(p))c=p;else{if(!s(p))throw new Error(`[useRetry] invalid value received from options.retryDelay '${typeof p}'`);c=p.getTime()}c<f?t.nextRetry.value=f+c:(t.nextRetry.value=c,c-=f),c>0&&await h(c)}if(t[M].value)return null;if(o!==t[E].value)return v}while(a<9e3);return null};const I=()=>0;function k(e,t,n){return L(e,t,n)}function L(e,t=50,n={isImmediate:!1}){let r;return function(...o){const a=this,l=n.isImmediate&&void 0===r;void 0!==r&&clearTimeout(r),r=setTimeout((function(){r=void 0,n.isImmediate||e.apply(a,o)}),t),l&&e.apply(a,o)}}function x(e){const n=e&&e.refreshMs||1e3,r=!e||!u(e.sync)||e.sync,o=e&&a(e.timeFn)&&e.timeFn||Date.now;let l=void 0,s=void 0;const i=t.ref(o()),c=()=>{clearInterval(l),clearTimeout(s)},v=y?()=>l=setInterval(()=>i.value=o(),n):f;if(r){const e=1e3-(i.value-1e3*Math.floor(i.value/1e3));s=setTimeout(v,e)}else v();return t.onUnmounted(c),{now:i,remove:c}}function R(e,r){return t.computed(()=>{const a=n(e);if(!r)return a;const l=t.isRef(r)?t.reactive(r.value):t.reactive(r);return a.replace(/({?{[\w\s]*}?})/g,e=>{const t=e.replace("{","").replace("}","").trim();if(e[0]===e[1]&&"{"===e[0])return`${t}`;const r=o(l)?l[+t]:l[t];return void 0===r?e:`${n(r)}`})})}function O(e,r,o=".",a=f){return t.computed(()=>{const t=n(e),l=n(r);if(void 0===t)return a(l,t,l,t);if(!l)return t;const u=l.split(o);let s=t;for(let e=0;e<u.length;e++){let n=u[e],r=-1;if("]"===n[n.length-1]){const e=n.match(/\[(\d+)\]$/);e&&e[1]&&(r=+e[1],n=n.slice(0,-e[0].length))}if(!c(s))return a(u.slice(0,e).join(o),s,l,t);if(s=s[n],r>=0&&(s=s[r]),!s)return a(u.slice(0,e).join(o),s,l,t)}return s})}function P(e){return void 0!==e.$value}const C=(e,n,r)=>{const{$message:o,$validator:a,...l}=function(e){return c(e)}(n)?n:{$validator:n,$message:""},{$pending:u,$promise:s,$invalid:i,$error:v}=((e,n,r)=>{const o=t.ref(null),a=t.ref(!1),l=t.ref(),u=t.ref(!1);let s=void 0;const i=e=>{o.value=(async()=>{try{a.value=!0;const t=n(e,s);d(t)?u.value=!await t:u.value=!t}catch(e){throw u.value=!0,e}finally{a.value=!1}})().catch(e=>(l.value=e,u.value=!0,e))};return r.push(r=>{s=r,t.watch(()=>{try{n(e.value,s)}catch(e){}return e.value},i,{deep:!0})}),{$promise:o,$pending:a,$invalid:u,$error:l}})(e,a,r);return{$pending:u,$error:v,$promise:s,$invalid:i,$message:o,...l}},T=(e,n)=>{const r={},o=P(e)?e.$value:void 0;for(const a of Object.keys(e))if("$"!==a[0])if(o){const t=C(o,e[a],n);r[a]={...t,$value:o}}else{const o=T(e[a],n);let l,s,i=void 0;if(P(o)){const e=Object.keys(o).filter(e=>"$"!==e[0]).map(e=>o[e]);l=t.computed(()=>e.map(e=>e.$error).filter(e=>Boolean(e)&&Array.isArray(e)?e.some(Boolean):e)),s=t.computed(()=>e.some(e=>!!e.$invalid))}else{const e=Object.keys(o).map(e=>o[e]);l=t.computed(()=>e.map(e=>e.$errors).filter(Boolean).filter(e=>e.some(Boolean))),i=t.computed(()=>e.some(e=>e.$anyDirty&&e.$anyDirty||u(e.$dirty)&&e.$dirty)),s=t.computed(()=>e.some(e=>!!e.$anyInvalid))}r[a]={...o,$errors:l,$anyInvalid:s},i&&(r[a].$anyDirty=i)}else{if("$value"===a){r[a]=o;const e=t.ref(!1),n=t.watch(o,()=>{e.value=!0,n()},{lazy:!0,deep:!0});r.$dirty=e;continue}r[a]=e[a]}return r};const A=Symbol("");function j(e){const n=t.ref(Object.keys(e.messages)),o=t.ref(e.messages),l=t.ref(e.locale),s=t.ref({});let i=t.ref();const c={},v=(e,n)=>{if(c[e])return c[e];const o=n.value[e];return o?a(o)?Promise.resolve(o()).then(t=>c[e]=r(t)):c[e]=t.computed(()=>n.value[e]):t.ref({})},f=!!e.fallback&&(!u(e.notFoundFallback)||e.notFoundFallback);let m=!1;if(f){const t=v(e.fallback,o);d(t)?(t.then(e=>{i=e}),m=!0):i=t}else i.value={};t.watch([l,i],async([t,n])=>{if(t===e.fallback&&f)s.value=n;else{const e=await v(t,o);s.value=w({},n,e.value)}},{lazy:m});return{locale:l,locales:n,i18n:s,$t:(t,n)=>e.resolve?r(e.resolve(s.value,t,n)):R(O(s,t,".",(e,t,n)=>n),n),addLocale:(e,t)=>{n.value.indexOf(e)>=0||n.value.push(e),delete c[e],o.value[e]=t},removeLocale:e=>{const t=n.value.indexOf(e);t>=0&&n.value.splice(t,1),delete o.value[e],delete c[e]}}}function D(e,n,o,a){let l=f;if(e){const u=r(e),s=e=>e.removeEventListener(n,o),i=e=>e.addEventListener(n,o,a);l=()=>{s(u.value)},t.onUnmounted(l),t.onMounted(()=>{t.watch(u,(e,t)=>{t&&s(t),e&&i(e)})})}return l}let z=void 0;let F=void 0,V=void 0;let B=void 0,U=void 0;function H(e,n){const r=y&&"BroadcastChannel"in self,o=t.ref(null),a=t.ref(null),l=t.ref(null),u=t.ref(!1),s=t.ref(!1);let i=f,c=f,v=f;if(r){const r=new BroadcastChannel(e);r.addEventListener("messageerror",e=>{l.value=e,u.value=!0},p),r.addEventListener("message",e=>{a.value=e,o.value=e.data},p),i=e=>r.postMessage(e),c=()=>{r.close(),s.value=!0},v=(e,n)=>{r.addEventListener("message",e,n),t.onUnmounted(()=>r.removeEventListener("message",e))},t.onUnmounted(()=>{n&&n(),c()})}return{supported:r,data:o,messageEvent:a,errorEvent:l,errored:u,isClosed:s,send:i,close:c,addListener:v}}function N(e,t){const n=getComputedStyle(e).getPropertyValue(t);return n?n.trim():null}function K(e,t,n){e.style.setProperty(t,n)}const W={attributes:!0,childList:!0,attributeFilter:["style"]},_=e=>e.length<=2||"-"!==e[0]||"-"!==e[1]?`--${e}`:e;function J(e){const n=!!y&&"matchMedia"in window;let r=void 0,o=void 0,a=f;if(n){r=t.ref(matchMedia(e)),o=t.ref(r.value.matches);const n=e=>{o.value=e.matches};r.value.addEventListener("change",n,p);const a=()=>r.value.removeEventListener("change",n);t.onUnmounted(a)}else r=t.ref({}),o=t.ref(!1);return{supported:n,mediaQueryList:r,matches:o,remove:a}}function q(e,n){const{addListener:r,send:o,close:a,supported:l}=H(e,()=>w()),u=Date.now(),s=t.ref(!1),i=t.ref(0),v=t.computed(()=>1!==i.value||s.value),d=t.ref([]),f=t.ref(n);let m=!1,h=void 0;o({type:0});const g=()=>o({type:5,id:u}),w=()=>{0!==d.value.length&&(s.value&&o({type:3,mind:1,id:Math.min(...d.value)}),o({type:4,id:u}))};return r(e=>{switch(e.data.type){case 0:o({type:2,value:f.value,mind:i.value});break;case 4:{const t=d.value.indexOf(e.data.id);t>=0&&d.value.splice(t,1),h===e.data.id&&d.value.length>0&&o({type:3,mind:1,id:Math.min(u,...d.value)});break}case 2:m=!0,f.value=e.data.value,i.value=e.data.mind;break;case 3:i.value=e.data.mind,h=1===e.data.mind&&e.data.id||void 0,s.value=h===u,s.value&&(d.value=[],g());break;case 5:d.value=[e.data.id],o({type:6,id:u});break;case 6:d.value.push(e.data.id)}},p),g(),t.watch(f,(e,t)=>{if(m)m=!1;else{if(1===i.value&&!1===s.value)return m=!0,void(f.value=t);o({type:2,mind:i.value,value:c(e)?{...e}:e}),m=!1}},{deep:!0,lazy:!0}),y&&window.addEventListener("unload",w,p),t.onUnmounted(()=>{w(),a()}),{supported:l,id:u,data:f,master:s,mind:i,editable:v,targets:d,ping:g,setMind:e=>{switch(e){case 1:s.value=!0;break;case 0:s.value=!1}i.value=e,o({type:3,id:u,mind:i.value})},addListener:r}}function Q(e){if(e)return i(e)?e:G(e)}const G=e=>{const t=e.match(/^(\d+)px$/);if(t)return+t[1]};function X(e){const n={},r=new Map,o=t.ref();let a=[];const l=[];for(const o in e){const u=e[o],s=Q(u);if(void 0!==s){const e=t.ref(!1);n[o]=e,r.set(s,{name:o,valid:e}),a.push(s)}else{const{matches:e,remove:t}=J(u);n[o]=e,l.push(t)}}a=a.sort((e,t)=>t-e);const u=y?()=>{const e=window.innerWidth;let t=void 0;for(let n=0;n<a.length;n++){const o=a[n],l=r.get(o);l.valid.value=e>=o,e>=o&&void 0===t&&(t=l.name)}o.value=t}:f,s=k(u,10),i=y?()=>window.removeEventListener("resize",s):f;return t.onMounted(()=>{u(),window.addEventListener("resize",s,p)}),t.onUnmounted(()=>{i(),l.forEach(e=>e())}),{...n,remove:i,current:o}}const Y=Symbol(""),Z={sm:640,md:768,lg:1024,xl:1280};function ee(e){return c(e.theme)&&c(e.theme.screen)}function te(e){const t=[];if(o(e)){const n=e.map(te);for(let e=0;e<n.length;e++){const r=n[e];t.push(...r)}}else l(e.raw)?t.push(e.raw):!function(e){return l(e.min)||l(e.max)}(e)?t.push(`min-width: ${e}`):t.push(function(e){return`(${[e.max&&`max-width: ${e.max}`,e.min&&`min-width: ${e.min}`].join(" and ")})`}(e));return t}function ne(e){const n=ee(e)?e.theme.screens:e;if(ee(e))for(const e in n)n.hasOwnProperty(e)&&(n[e]=te(n).join(" or "));const r=X(n);return t.provide(Y,r),r}function re(e,t){return e instanceof DOMException&&(22===e.code||1014===e.code||"QuotaExceededError"===e.name||"NS_ERROR_DOM_QUOTA_REACHED"===e.name)&&(t&&0!==t.length||!1)}function oe(e){try{if(!e)return!1;const t=":$";return e.setItem(t,t),e.removeItem(t),!0}catch(t){return re(t,e)}}function ae(e,t){try{return e.parse(t)}catch{return t}}let le=void 0;function ue(e,n=JSON,o=10){const a=y?window[e]:void 0,u=oe(a);le||(le=new Map,y&&window.addEventListener("storage",e=>{if(e.newValue===e.oldValue)return;let t=le.get("localStorage");t=e.storageArea===window.localStorage?le.get("localStorage"):le.get("sessionStorage"),t&&Object.keys(t.$syncKeys).length>0&&(null===e.key?t.clear():t.$syncKeys[e.key]&&(null===e.newValue?t.removeItem(e.key):t.updateItem(e.key,e.newValue)))}));let s,i=le.get(e);return u&&a?i?s=i.$quotaError:(s=t.ref(!1),i={$refMap:new Map,$watchHandlers:new Map,$syncKeys:{},$quotaError:s,key:a.key,length:a.length,setSync(e,t){t?this.$syncKeys[e]=!0:delete this.$syncKeys[e]},clear(){this.$refMap.forEach((e,t)=>this.removeItem(t))},removeItem(e){const t=this.$refMap.get(e);t&&(t.value=void 0);const n=this.$watchHandlers.get(e);n&&n(),delete this.$syncKeys[e],this.$refMap.delete(e),a.removeItem(e)},getItem(e){const t=a.getItem(e);return t?this.setItem(e,ae(n,t)):null},setItem(e,u){const i=r(u);this.$refMap.set(e,i);const c=(e,t)=>{try{const r=a.getItem(e),o=l(t)?t:n.stringify(t);a.setItem(e,o),r!==o&&y&&this.$syncKeys[e]&&window.dispatchEvent(new StorageEvent(e,{newValue:o,oldValue:r,storageArea:a}))}catch(e){s.value=re(e,a)}};c(e,u);const v=t.watch(i,L(t=>{c(e,t)},o),{lazy:!0,deep:!0});return this.$watchHandlers.set(e,v),i},updateItem(e,t){let r=this.$refMap.get(e);r&&(r.value=ae(n,t))}},le.set(e,i)):(s=t.ref(!1),i={}),{supported:u,quotaError:s,store:i,remove:()=>le.delete(e)}}function se(e,n,r){const{supported:o,store:a}=ue("localStorage");let l=f,u=f,s=f,i=void 0;return o&&a?(s=t=>a.setSync(e,t),l=()=>a.removeItem(e),u=()=>a.clear(),i=a.getItem(e),i||(i=a.setItem(e,n)),!1!==r&&s(!0)):i=t.ref(n),{supported:o,storage:i,clear:u,remove:l,setSync:s}}function ie(e,n,r){const{supported:o,store:a}=ue("sessionStorage");let l=f,u=f,s=m,i=void 0;return o&&a?(l=()=>a.removeItem(e),u=()=>a.clear(),i=a.getItem(e),i||(i=a.setItem(e,n))):i=t.ref(n),{supported:o,storage:i,clear:u,remove:l,setSync:s}}let ce=void 0;return e.FALSE_OP=m,e.NO_OP=f,e.PASSIVE_EV=p,e.buildI18n=j,e.debounce=L,e.deepClone=w,e.exponentialDelay=e=>{const t=100*Math.pow(2,e);return t+.2*t*Math.random()},e.getCssVariableFor=N,e.isArray=o,e.isBoolean=u,e.isClient=y,e.isDate=s,e.isElement=v,e.isFunction=a,e.isNumber=i,e.isObject=c,e.isPromise=d,e.isString=l,e.isSymbol=e=>"symbol"==typeof e,e.minMax=g,e.noDelay=I,e.promisedTimeout=h,e.refShared=function(e,n){const r=t.getCurrentInstance(),o=n||r.$vnode.tag,{data:a,supported:l}=q(o,e);return a},e.setBreakpointTailwindCSS=ne,e.setCssVariableFor=K,e.setI18n=function(e){const n=j(e);return t.provide(A,n),n},e.storageAvailable=oe,e.unwrap=n,e.useArrayPagination=function(e,n){const o=r(e),a=b({currentPage:1,pageSize:10,...n,total:t.computed(()=>o.value.length)}),l=t.computed(()=>{const e=o.value;return Array.isArray(e)?e.slice(a.offset.value,a.offset.value+a.pageSize.value):[]});return{...a,result:l}},e.useBreakpoint=X,e.useBreakpointChrome=function(){return X({mobileS:320,mobileM:375,mobileL:425,tablet:768,laptop:1024,laptopL:1440,desktop4K:2560})},e.useBreakpointTailwindCSS=function(e){const n=t.inject(Y);return n||ne(e||Z)},e.useBroadcastChannel=H,e.useCancellablePromise=function(e,n=!1){const r=t.ref(!1);let o=void 0;return{...$((...t)=>{return n=e(...t),new Promise((e,t)=>{o=e=>{r.value=!0,t(e)},n.then(e).catch(t)});var n},n),cancel:e=>o(e),cancelled:r}},e.useCssVariables=function(e,o,a){const u=y&&"MutationObserver"in self,[s,i]=t.isRef(o)||v(o)?[o,a||W]:[u&&document.documentElement||{},o||W],c=t.ref(!0),d={},m=[],p=Object.entries(e).map(e=>{const[t,o]=l(e[1])?[e[1]]:[e[1].name,e[1].value];return o&&(m.push(()=>K(n(s),t,n(o))),d[e[0]]=r(o)),[e[0],_(t)]});for(let e=0;e<p.length;e++){const[o,a]=p[e];d[o]||(d[o]=t.ref(t.isRef(s)&&!s.value||!u?null:N(n(s),a))),u&&t.watch([d[o],r(s)],e=>{c&&e&&K(e[1],a,e[0])},{lazy:t.isRef(s)})}if(!u)return{...d,stop:f,resume:f,supported:u,observing:c};const h=()=>{for(let e=0;e<p.length;e++){const[t,r]=p[e];d[t].value=N(n(s),r)}},g=new MutationObserver(h),w=()=>{g.disconnect(),c.value=!1},b=()=>{c.value||h(),g.observe(n(s),i),c.value=!0};return t.onUnmounted(w),t.isRef(s)?t.onMounted(()=>{m.forEach(e=>e()),t.watch(s,(e,t)=>{t&&w(),e&&b()})}):(y||s)&&(m.forEach(e=>e()),b()),{...d,supported:u,resume:b,stop:w,observing:c}},e.useDateNow=function(e){return x({refreshMs:e&&e.refreshMs||1e3,sync:!e||!u(e.sync)||e.sync,timeFn:Date.now})},e.useDebounce=k,e.useEvent=D,e.useFetch=function(e,n){const r=t.ref(null),o=t.ref(""),a=t.ref(),s=!!e&&(u(e.isJson)||u(e.isJson)),i=t.ref(null),c=!s||!1!==e.isJson,v=!s||!1!==e.parseImmediate,d=t.ref(!1),f=t.ref();let m=void 0;const p=$(async(e,t)=>{m=new AbortController;const l=await fetch(e,{signal:m.signal,...n,...t});if(l){const e=[c?l.clone().json().then(e=>r.value=e).catch(e=>{r.value=null,i.value=e}):Promise.resolve(),l.clone().blob().then(e=>{a.value=e}),l.clone().text().then(e=>{o.value=e})];v&&await Promise.all(e)}return l}),h=t.computed(()=>p.result.value&&p.result.value.status||null),g=t.computed(()=>p.result.value&&p.result.value.statusText||null);return e&&(!l(e)&&s||p.exec(e,void 0,!1)),{...p,cancel:e=>{m&&(m.abort(),d.value=!0,f.value=e)},isCancelled:d,cancelledMessage:f,text:o,blob:a,json:r,jsonError:i,status:h,statusText:g}},e.useFormat=R,e.useGeolocation=function(e){const n=y&&!!navigator.geolocation,r=t.ref(e?!1===e.immediate:void 0),o=t.ref(null),a=t.ref(null),l=t.ref(null),s=t.ref(e&&e.enableHighAccuracy||null);let i=f;if(n){const n=e=>{a.value=e.timestamp,l.value=e.coords,o.value=null},c=e=>{a.value=Date.now(),l.value=null,o.value=e},v=()=>!0!==r.value&&f&&navigator.geolocation.clearWatch(f);let d=()=>navigator.geolocation.getCurrentPosition(n,c,e);i=r.value?()=>{r.value?r.value=!1:d()}:d;let f=0;t.onMounted(()=>t.watch([s,r],t=>{v();const r=u(t[0])?t[0]:e?e.enableHighAccuracy:void 0;f=navigator.geolocation.watchPosition(n,c,e?{...e,enableHighAccuracy:r}:{enableHighAccuracy:r})},{lazy:r.value})),t.onUnmounted(v)}return{supported:n,refresh:i,error:o,timestamp:a,coords:l,highAccuracy:s}},e.useI18n=function(e){return e?j(e):t.inject(A)},e.useIntersectionObserver=function(e,o){const a=y&&"IntersectionObserver"in window,l=e?r(e):void 0,u=!l||!v(l.value)&&l.value?void 0:l,s=t.computed(()=>o?n(o):u?void 0:n(e)),i=t.ref(u&&u.value?[u.value]:[]),c=t.computed(()=>i.value.length>0&&i.value.every(e=>e.isIntersecting)),d=e=>{i.value=e};let m=t.ref();a&&t.watch(s,e=>{m.value&&m.value.disconnect();const t=e&&e&&{root:n(e.root),rootMargin:n(e.rootMargin),threshold:n(e.threshold)}||void 0;m.value=new IntersectionObserver(d,t),i.value.map(e=>e.target).forEach(m.value.observe)},{deep:!0});const p=a?e=>{const t=n(e);m.value.observe(t)}:f,h=a?e=>{const t=n(e);m.value.unobserve(t)}:f,g=()=>m.value.disconnect();return u&&(u.value||t.onMounted(()=>{u.value&&p(u)}),t.onUnmounted(()=>{g()})),{supported:a,elements:i,observe:p,unobserve:h,disconnect:g,isIntersecting:c}},e.useLanguage=function(){if(B||(B=y?t.ref(navigator.language):t.ref("")),!U)if(y){U=t.ref(navigator.languages);const e=()=>{B.value=navigator.language,U.value=navigator.languages};window.addEventListener("languagechange",e,p)}else U=t.ref([]);return{language:B,languages:U}},e.useLocalStorage=se,e.useMatchMedia=J,e.useNetworkInformation=function(){const e=!!y&&(navigator.connection||navigator.mozConnection||navigator.webkitConnection),n=!!e,r=t.ref(0),o=t.ref(0),a=t.ref("unknown"),l=t.ref(0),u=t.ref(!1),s=t.ref("none");let i=f,c=f;return e&&(i=()=>{r.value=e.downlink,o.value=e.downlinkMax,a.value=e.effectiveType,l.value=e.rtt,u.value=e.saveData,s.value=e.type},c=D(e,"change",i,p),i()),{supported:n,downlink:r,downlinkMax:o,effectiveType:a,rtt:l,saveData:u,type:s,remove:c}},e.useNow=x,e.useOnMouseMove=function(e,n,r){const o=t.ref(0),a=t.ref(0);let l=e=>{o.value=e.x,a.value=e.y};const[u,s]=i(n)?[void 0,n]:[n,r];s&&(l=k(l,r));const c=D(e,"mousemove",l,u);return{mouseX:o,mouseY:a,remove:c}},e.useOnResize=function(e,n,o){const a=r(e),l=t.ref(a.value&&a.value.clientHeight),u=t.ref(a.value&&a.value.clientWidth);let s=()=>{l.value=a.value.clientHeight,u.value=a.value.clientWidth};const[c,v]=i(n)?[void 0,n]:[n,o];v&&(s=k(s,o));const d=y?D(window,"resize",s,c||p):f;return{height:l,width:u,remove:d}},e.useOnScroll=function(e,n,o){const a=e=>!(i(e)||u(e)||!v(e)&&!t.isRef(e)||!e),l=a(e)?r(e):t.ref(y&&window||void 0),s=a(e)?l:t.ref(y&&window.document.scrollingElement||void 0),c=t.ref(s.value&&s.value.scrollTop||0),d=t.ref(s.value&&s.value.scrollLeft||0);let f=()=>{c.value=s.value.scrollTop,d.value=s.value.scrollLeft};const m=(...e)=>s.value&&s.value.scrollTo&&s.value.scrollTo.apply(s.value,e),h=e=>m({top:e}),g=e=>m({left:e}),[w,b]=i(e)||!e?[p,e]:i(n)?[p,n]:[n,o];b&&(f=k(f,o));const $=D(l,"scroll",f,w),E=t.watch(c,h,{lazy:!0}),M=t.watch(d,g,{lazy:!0});return{scrollTop:c,scrollLeft:d,scrollTo:m,remove:()=>{$(),M(),E()},scrollTopTo:h,scrollLeftTo:g}},e.useOnline=function(){const e=y&&"onLine"in navigator;return e||(z=t.ref(!1)),z||(z=t.ref(navigator.onLine),window.addEventListener("offline",()=>z.value=!1,p),window.addEventListener("online",()=>z.value=!0,p)),{supported:e,online:z}},e.usePageVisibility=function(){return V||(V=t.ref(y&&document.hidden)),F||(y?(F=t.ref(document.visibilityState),document.addEventListener("visibilitychange",()=>{F.value=document.visibilityState,V.value=document.hidden},p)):F=t.ref(!1)),{visibility:F,hidden:V}},e.usePagination=b,e.usePath=O,e.usePerformanceNow=function(e){return x({refreshMs:e&&e.refreshMs||1e3,sync:!e||!u(e.sync)||e.sync,timeFn:()=>performance.now()})},e.usePromise=$,e.useRetry=function(e,n){const r=!e||a(e)?{}:e,o=a(e)?e:n;if(!a(e)&&!c(e))throw new Error("[useRetry] options needs to be 'object'");if(o&&!a(o))throw new Error("[useRetry] factory needs to be 'function'");const l=t.ref(!1),u=t.ref(),s=t.ref([]),i={value:!1},v={isRetrying:l,retryCount:t.computed(()=>s.value.length),nextRetry:u,retryErrors:s,[E]:{value:0},[M]:i},d=o?(...e)=>(++v[E].value,S(r,v,o,e)):e=>(++v[E].value,S(r,v,e,void 0));return{...v,cancel:()=>{v.isRetrying.value=!1,v.retryErrors.value.push(new Error("[useRetry] cancelled")),v.nextRetry.value=void 0,i.value=!0},exec:d}},e.useSessionStorage=ie,e.useSharedRef=q,e.useStorage=function(e,t,n){return void 0===ce&&(ce=ue("localStorage").supported),ce?se(e,t,n):ie(e,t)},e.useValidation=function(e){const n=[],r=T({input:e},n),o=t.reactive(r.input);return n.forEach(e=>e(o)),o},e.useWebSocket=function(e,n){const r=y&&"WebSocket"in window;let o=null;const a=t.ref(null),l=t.ref(),u=t.ref(null),s=t.ref(!1),i=t.ref(!1),c=t.ref(!1);let v=f,d=f;return r&&(o=new WebSocket(e,n),o.addEventListener("message",e=>{a.value=e,u.value=e.data}),o.addEventListener("error",e=>{l.value=e,c.value=!0}),o.addEventListener("close",()=>{s.value=!1,i.value=!0}),o.addEventListener("open",()=>{s.value=!0,i.value=!1}),v=e=>o.send(e),d=(e,t)=>{o.close(e,t)}),{supported:r,ws:o,send:v,close:d,messageEvent:a,errorEvent:l,data:u,isOpen:s,isClosed:i,errored:c}},e.useWebStorage=ue,e.wrap=r,e}({},vueCompositionApi); | ||
var vueComposable=function(e,t){"use strict";function n(e){return t.isRef(e)?e.value:e}function r(e){return t.isRef(e)?e:t.ref(e)}const o=Array.isArray,a=e=>"function"==typeof e,l=e=>"string"==typeof e,u=e=>"boolean"==typeof e,s=e=>c(e)&&a(e.getTime),i=e=>"number"==typeof e,c=e=>null!==e&&"object"==typeof e,v=e=>c(e)&&!!e.tagName;function d(e){return c(e)&&a(e.then)&&a(e.catch)}const f=()=>{},m=()=>!1,p={passive:!0};function h(e){return new Promise(t=>{setTimeout(t,e)})}function y(e,t,n){return e<t?t:e>n?n:e}const g="undefined"!=typeof window;function w(e,...t){for(let r=0;r<t.length;r++){const o=t[r];if(void 0===o||!c(o))continue;const a=Object.keys(o);for(let t=0;t<a.length;t++){const r=a[t],l=n(o[r]),u=typeof l,s=typeof e[r];void 0!==e[r]&&u!==s||(e[r]=c(l)?w(e[r]||{},l):o[r])}}return e}function b(e){const n=r(e.currentPage),o=r(e.pageSize),a=t.ref(0),l=r(e.total),u=t.computed({get:()=>a.value,set(e){i(e)&&(a.value=Math.min(e,l.value))}}),s=t.computed({get:()=>n.value,set(e){i(e)&&(n.value=y(e,1,v.value),u.value=(n.value-1)*c.value)}}),c=t.computed({get:()=>o.value,set(e){i(e)&&(o.value=e)}}),v=t.computed(()=>Math.ceil(l.value/c.value));s.value=n.value;return t.watch([l,c],()=>{s.value>v.value&&(s.value=v.value)},{lazy:!0}),{pageSize:c,total:l,currentPage:s,offset:u,lastPage:v,next:()=>++s.value,prev:()=>--s.value,first:()=>s.value=1,last:()=>s.value=v.value}}function $(e,n){if(!e)throw new Error(`[usePromise] argument can't be '${e}'`);if("function"!=typeof e)throw new Error(`[usePromise] expects function, but received ${typeof e}`);const[r,o]=u(n)?[n,!1]:c(n)?[n.lazy,n.throwException]:[!1,!1],a=t.ref(!1),l=t.ref(null),s=t.ref(null),i=t.ref(),v=async(...t)=>{a.value=!0,l.value=null;const n=t&&e.length!==t.length&&t.length>0&&u(t[t.length-1])?t[t.length-1]:o,r=i.value=e(...t);try{const e=await r;return i.value===r&&(s.value=e),e}catch(e){return i.value===r&&(l.value=e,s.value=null),n?r:void 0}finally{i.value===r&&(a.value=!1)}};return r||v(),{exec:v,result:s,promise:i,loading:a,error:l}}const E=Symbol(""),M=Symbol(""),S=async(e,t,n,r)=>{const o=t[E].value;let a=-1;const l=e.maxRetries||9001,u=e.retryDelay||I;t.retryErrors.value=[],t.isRetrying.value=!1,t.nextRetry.value=void 0;let c=void 0;do{let e=!1,v=null;try{if(++a,v=r?n(...r):n(),d(v)&&(v=await v),t[M].value)return null;e=!0}catch(e){v=null,t.retryErrors.value.push(e)}if(o!==t[E].value)return v;if(e)return t.isRetrying.value=!1,t.nextRetry.value=void 0,v;if(a>=l)return t.isRetrying.value=!1,t.nextRetry.value=void 0,Promise.reject(new Error(`[useRetry] max retries reached ${l}`));t.isRetrying.value=!0;const f=Date.now(),m=u(a),p=d(m)?await m:m;if(!d(m)||p){if(i(p))c=p;else{if(!s(p))throw new Error(`[useRetry] invalid value received from options.retryDelay '${typeof p}'`);c=p.getTime()}c<f?t.nextRetry.value=f+c:(t.nextRetry.value=c,c-=f),c>0&&await h(c)}if(t[M].value)return null;if(o!==t[E].value)return v}while(a<9e3);return null};const I=()=>0;function L(e,t,n){return k(e,t,n)}function k(e,t=50,n={isImmediate:!1}){let r;return function(...o){const a=this,l=n.isImmediate&&void 0===r;void 0!==r&&clearTimeout(r),r=setTimeout((function(){r=void 0,n.isImmediate||e.apply(a,o)}),t),l&&e.apply(a,o)}}function x(e){const n=e&&e.refreshMs||1e3,r=!e||!u(e.sync)||e.sync,o=e&&a(e.timeFn)&&e.timeFn||Date.now;let l=void 0,s=void 0;const i=t.ref(o()),c=()=>{clearInterval(l),clearTimeout(s)},v=g?()=>l=setInterval(()=>i.value=o(),n):f;if(r){const e=1e3-(i.value-1e3*Math.floor(i.value/1e3));s=setTimeout(v,e)}else v();return t.onUnmounted(c),{now:i,remove:c}}function R(e,r){return t.computed(()=>{const a=n(e);if(!r)return a;const l=t.isRef(r)?t.reactive(r.value):t.reactive(r);return a.replace(/({?{[\w\s]*}?})/g,e=>{const t=e.replace("{","").replace("}","").trim();if(e[0]===e[1]&&"{"===e[0])return`${t}`;const r=o(l)?l[+t]:l[t];return void 0===r?e:`${n(r)}`})})}function O(e,r,o=".",a=f){return t.computed(()=>{const t=n(e),l=n(r);if(void 0===t)return a(l,t,l,t);if(!l)return t;const u=l.split(o);let s=t;for(let e=0;e<u.length;e++){let n=u[e],r=-1;if("]"===n[n.length-1]){const e=n.match(/\[(\d+)\]$/);e&&e[1]&&(r=+e[1],n=n.slice(0,-e[0].length))}if(!c(s))return a(u.slice(0,e).join(o),s,l,t);if(s=s[n],r>=0&&(s=s[r]),!s)return a(u.slice(0,e).join(o),s,l,t)}return s})}function P(e){return void 0!==e.$value}const C=(e,n,r)=>{const{$message:o,$validator:a,...l}=function(e){return c(e)}(n)?n:{$validator:n,$message:""},{$pending:u,$promise:s,$invalid:i,$error:v}=((e,n,r)=>{const o=t.ref(null),a=t.ref(!1),l=t.ref(),u=t.ref(!1);let s=void 0;const i=e=>{o.value=(async()=>{try{a.value=!0;const t=n(e,s);d(t)?u.value=!await t:u.value=!t}catch(e){throw u.value=!0,e}finally{a.value=!1}})().catch(e=>(l.value=e,u.value=!0,e))};return r.push(r=>{s=r,t.watch(()=>{try{n(e.value,s)}catch(e){}return e.value},i,{deep:!0})}),{$promise:o,$pending:a,$invalid:u,$error:l}})(e,a,r);return{$pending:u,$error:v,$promise:s,$invalid:i,$message:o,...l}},T=(e,n)=>{const r={},o=P(e)?e.$value:void 0;for(const a of Object.keys(e))if("$"!==a[0])if(o){const t=C(o,e[a],n);r[a]={...t,$value:o}}else{const o=T(e[a],n);let l,s,i=void 0;if(P(o)){const e=Object.keys(o).filter(e=>"$"!==e[0]).map(e=>o[e]);l=t.computed(()=>e.map(e=>e.$error).filter(e=>Boolean(e)&&Array.isArray(e)?e.some(Boolean):e)),s=t.computed(()=>e.some(e=>!!e.$invalid))}else{const e=Object.keys(o).map(e=>o[e]);l=t.computed(()=>e.map(e=>e.$errors).filter(Boolean).filter(e=>e.some(Boolean))),i=t.computed(()=>e.some(e=>e.$anyDirty&&e.$anyDirty||u(e.$dirty)&&e.$dirty)),s=t.computed(()=>e.some(e=>!!e.$anyInvalid))}r[a]={...o,$errors:l,$anyInvalid:s},i&&(r[a].$anyDirty=i)}else{if("$value"===a){r[a]=o;const e=t.ref(!1),n=t.watch(o,()=>{e.value=!0,n()},{lazy:!0,deep:!0});r.$dirty=e;continue}r[a]=e[a]}return r};const A=Symbol("");function z(e){const n=t.ref(Object.keys(e.messages)),o=t.ref(e.messages),l=t.ref(e.locale),s=t.ref({});let i=t.ref();const c={},v=(e,n)=>{if(c[e])return c[e];const o=n.value[e];return o?a(o)?Promise.resolve(o()).then(t=>c[e]=r(t)):c[e]=t.computed(()=>n.value[e]):t.ref({})},f=!!e.fallback&&(!u(e.notFoundFallback)||e.notFoundFallback);let m=!1;if(f){const t=v(e.fallback,o);d(t)?(t.then(e=>{i=e}),m=!0):i=t}else i.value={};t.watch([l,i],async([t,n])=>{if(t===e.fallback&&f)s.value=n;else{const e=await v(t,o);s.value=w({},n,e.value)}},{lazy:m});return{locale:l,locales:n,i18n:s,$t:(t,n)=>e.resolve?r(e.resolve(s.value,t,n)):R(O(s,t,".",(e,t,n)=>n),n),addLocale:(e,t)=>{n.value.indexOf(e)>=0||n.value.push(e),delete c[e],o.value[e]=t},removeLocale:e=>{const t=n.value.indexOf(e);t>=0&&n.value.splice(t,1),delete o.value[e],delete c[e]}}}function j(e,n,o,a){let l=f;if(e){const u=r(e),s=e=>e.removeEventListener(n,o),i=e=>e.addEventListener(n,o,a);l=()=>{s(u.value)},t.onUnmounted(l),t.onMounted(()=>{t.watch(u,(e,t)=>{t&&s(t),e&&i(e)})})}return l}let D=void 0;let F=void 0,V=void 0;let B=void 0,U=void 0;function H(e,n){const r=g&&"BroadcastChannel"in self,o=t.ref(null),a=t.ref(null),l=t.ref(null),u=t.ref(!1),s=t.ref(!1);let i=f,c=f,v=f;if(r){const r=new BroadcastChannel(e);r.addEventListener("messageerror",e=>{l.value=e,u.value=!0},p),r.addEventListener("message",e=>{a.value=e,o.value=e.data},p),i=e=>r.postMessage(e),c=()=>{r.close(),s.value=!0},v=(e,n)=>{r.addEventListener("message",e,n),t.onUnmounted(()=>r.removeEventListener("message",e))},t.onUnmounted(()=>{n&&n(),c()})}return{supported:r,data:o,messageEvent:a,errorEvent:l,errored:u,isClosed:s,send:i,close:c,addListener:v}}function N(e,t){const n=getComputedStyle(e).getPropertyValue(t);return n?n.trim():null}function K(e,t,n){e.style.setProperty(t,n)}const W={attributes:!0,childList:!0,subtree:!0},_=e=>e.length<=2||"-"!==e[0]||"-"!==e[1]?`--${e}`:e;function q(e){const n=!!g&&"matchMedia"in window;let r=void 0,o=void 0,a=f;if(n){r=t.ref(matchMedia(e)),o=t.ref(r.value.matches);const n=e=>{o.value=e.matches};r.value.addEventListener("change",n,p);const a=()=>r.value.removeEventListener("change",n);t.onUnmounted(a)}else r=t.ref({}),o=t.ref(!1);return{supported:n,mediaQueryList:r,matches:o,remove:a}}function J(e,n){const{addListener:r,send:o,close:a,supported:l}=H(e,()=>w()),u=Date.now(),s=t.ref(!1),i=t.ref(0),v=t.computed(()=>1!==i.value||s.value),d=t.ref([]),f=t.ref(n);let m=!1,h=void 0;o({type:0});const y=()=>o({type:5,id:u}),w=()=>{0!==d.value.length&&(s.value&&o({type:3,mind:1,id:Math.min(...d.value)}),o({type:4,id:u}))};return r(e=>{switch(e.data.type){case 0:o({type:2,value:f.value,mind:i.value});break;case 4:{const t=d.value.indexOf(e.data.id);t>=0&&d.value.splice(t,1),h===e.data.id&&d.value.length>0&&o({type:3,mind:1,id:Math.min(u,...d.value)});break}case 2:m=!0,f.value=e.data.value,i.value=e.data.mind;break;case 3:i.value=e.data.mind,h=1===e.data.mind&&e.data.id||void 0,s.value=h===u,s.value&&(d.value=[],y());break;case 5:d.value=[e.data.id],o({type:6,id:u});break;case 6:d.value.push(e.data.id)}},p),y(),t.watch(f,(e,t)=>{if(m)m=!1;else{if(1===i.value&&!1===s.value)return m=!0,void(f.value=t);o({type:2,mind:i.value,value:c(e)?{...e}:e}),m=!1}},{deep:!0,lazy:!0}),g&&window.addEventListener("unload",w,p),t.onUnmounted(()=>{w(),a()}),{supported:l,id:u,data:f,master:s,mind:i,editable:v,targets:d,ping:y,setMind:e=>{switch(e){case 1:s.value=!0;break;case 0:s.value=!1}i.value=e,o({type:3,id:u,mind:i.value})},addListener:r}}function Q(e){if(e)return i(e)?e:G(e)}const G=e=>{const t=e.match(/^(\d+)px$/);if(t)return+t[1]};function X(e){const n={},r=new Map,o=t.ref();let a=[];const l=[];for(const o in e){const u=e[o],s=Q(u);if(void 0!==s){const e=t.ref(!1);n[o]=e,r.set(s,{name:o,valid:e}),a.push(s)}else{const{matches:e,remove:t}=q(u);n[o]=e,l.push(t)}}a=a.sort((e,t)=>t-e);const u=g?()=>{const e=window.innerWidth;let t=void 0;for(let n=0;n<a.length;n++){const o=a[n],l=r.get(o);l.valid.value=e>=o,e>=o&&void 0===t&&(t=l.name)}o.value=t}:f,s=L(u,10),i=g?()=>window.removeEventListener("resize",s):f;return t.onMounted(()=>{u(),window.addEventListener("resize",s,p)}),t.onUnmounted(()=>{i(),l.forEach(e=>e())}),{...n,remove:i,current:o}}const Y=Symbol(""),Z={sm:640,md:768,lg:1024,xl:1280};function ee(e){return c(e.theme)&&c(e.theme.screen)}function te(e){const t=[];if(o(e)){const n=e.map(te);for(let e=0;e<n.length;e++){const r=n[e];t.push(...r)}}else l(e.raw)?t.push(e.raw):!function(e){return l(e.min)||l(e.max)}(e)?t.push(`min-width: ${e}`):t.push(function(e){return`(${[e.max&&`max-width: ${e.max}`,e.min&&`min-width: ${e.min}`].join(" and ")})`}(e));return t}function ne(e){const n=ee(e)?e.theme.screens:e;if(ee(e))for(const e in n)n.hasOwnProperty(e)&&(n[e]=te(n).join(" or "));const r=X(n);return t.provide(Y,r),r}function re(e,t){return e instanceof DOMException&&(22===e.code||1014===e.code||"QuotaExceededError"===e.name||"NS_ERROR_DOM_QUOTA_REACHED"===e.name)&&(t&&0!==t.length||!1)}function oe(e){try{if(!e)return!1;const t=":$";return e.setItem(t,t),e.removeItem(t),!0}catch(t){return re(t,e)}}function ae(e,t){try{return e.parse(t)}catch{return t}}let le=void 0;function ue(e,n=JSON,o=10){const a=g?window[e]:void 0,u=oe(a);le||(le=new Map,g&&window.addEventListener("storage",e=>{if(e.newValue===e.oldValue)return;let t=le.get("localStorage");t=e.storageArea===window.localStorage?le.get("localStorage"):le.get("sessionStorage"),t&&Object.keys(t.$syncKeys).length>0&&(null===e.key?t.clear():t.$syncKeys[e.key]&&(null===e.newValue?t.removeItem(e.key):t.updateItem(e.key,e.newValue)))}));let s,i=le.get(e);return u&&a?i?s=i.$quotaError:(s=t.ref(!1),i={$refMap:new Map,$watchHandlers:new Map,$syncKeys:{},$quotaError:s,key:a.key,length:a.length,setSync(e,t){t?this.$syncKeys[e]=!0:delete this.$syncKeys[e]},clear(){this.$refMap.forEach((e,t)=>this.removeItem(t))},removeItem(e){const t=this.$refMap.get(e);t&&(t.value=void 0);const n=this.$watchHandlers.get(e);n&&n(),delete this.$syncKeys[e],this.$refMap.delete(e),a.removeItem(e)},getItem(e){const t=a.getItem(e);return t?this.setItem(e,ae(n,t)):null},setItem(e,u){const i=r(u);this.$refMap.set(e,i);const c=(e,t)=>{try{const r=a.getItem(e),o=l(t)?t:n.stringify(t);a.setItem(e,o),r!==o&&g&&this.$syncKeys[e]&&window.dispatchEvent(new StorageEvent(e,{newValue:o,oldValue:r,storageArea:a}))}catch(e){s.value=re(e,a)}};c(e,u);const v=t.watch(i,k(t=>{c(e,t)},o),{lazy:!0,deep:!0});return this.$watchHandlers.set(e,v),i},updateItem(e,t){let r=this.$refMap.get(e);r&&(r.value=ae(n,t))}},le.set(e,i)):(s=t.ref(!1),i={}),{supported:u,quotaError:s,store:i,remove:()=>le.delete(e)}}function se(e,n,r){const{supported:o,store:a}=ue("localStorage");let l=f,u=f,s=f,i=void 0;return o&&a?(s=t=>a.setSync(e,t),l=()=>a.removeItem(e),u=()=>a.clear(),i=a.getItem(e),i||(i=a.setItem(e,n)),!1!==r&&s(!0)):i=t.ref(n),{supported:o,storage:i,clear:u,remove:l,setSync:s}}function ie(e,n,r){const{supported:o,store:a}=ue("sessionStorage");let l=f,u=f,s=m,i=void 0;return o&&a?(l=()=>a.removeItem(e),u=()=>a.clear(),i=a.getItem(e),i||(i=a.setItem(e,n))):i=t.ref(n),{supported:o,storage:i,clear:u,remove:l,setSync:s}}let ce=void 0;return e.FALSE_OP=m,e.NO_OP=f,e.PASSIVE_EV=p,e.buildI18n=z,e.debounce=k,e.deepClone=w,e.exponentialDelay=e=>{const t=100*Math.pow(2,e);return t+.2*t*Math.random()},e.getCssVariableFor=N,e.isArray=o,e.isBoolean=u,e.isClient=g,e.isDate=s,e.isElement=v,e.isFunction=a,e.isNumber=i,e.isObject=c,e.isPromise=d,e.isString=l,e.isSymbol=e=>"symbol"==typeof e,e.minMax=y,e.noDelay=I,e.promisedTimeout=h,e.refShared=function(e,n){const r=t.getCurrentInstance(),o=n||r.$vnode.tag,{data:a,supported:l}=J(o,e);return a},e.setBreakpointTailwindCSS=ne,e.setCssVariableFor=K,e.setI18n=function(e){const n=z(e);return t.provide(A,n),n},e.storageAvailable=oe,e.unwrap=n,e.useArrayPagination=function(e,n){const o=r(e),a=b({currentPage:1,pageSize:10,...n,total:t.computed(()=>o.value.length)}),l=t.computed(()=>{const e=o.value;return Array.isArray(e)?e.slice(a.offset.value,a.offset.value+a.pageSize.value):[]});return{...a,result:l}},e.useBreakpoint=X,e.useBreakpointChrome=function(){return X({mobileS:320,mobileM:375,mobileL:425,tablet:768,laptop:1024,laptopL:1440,desktop4K:2560})},e.useBreakpointTailwindCSS=function(e){const n=t.inject(Y);return n||ne(e||Z)},e.useBroadcastChannel=H,e.useCancellablePromise=function(e,n){const r=t.ref(!1);let o=void 0;return{...$((...t)=>{return n=e(...t),new Promise((e,t)=>{o=e=>{r.value=!0,t(e)},n.then(e).catch(t)});var n},n),cancel:e=>{o&&o(e)},cancelled:r}},e.useCssVariables=function(e,o,a){const u=g&&"MutationObserver"in self,[s,i]=t.isRef(o)||v(o)?[o,a||W]:[u&&document.documentElement||{},o||W],c=t.ref(!0),d={},m=[],p=Object.entries(e).map(e=>{const[t,o]=l(e[1])?[e[1]]:[e[1].name,e[1].value];return o&&(m.push(()=>K(n(s),t,n(o))),d[e[0]]=r(o)),[e[0],_(t)]});for(let e=0;e<p.length;e++){const[o,a]=p[e];d[o]||(d[o]=t.ref(t.isRef(s)&&!s.value||!u?null:N(n(s),a))),u&&t.watch([d[o],r(s)],e=>{c&&e[1]&&e[0]!==N(e[1],a)&&K(e[1],a,e[0])},{lazy:t.isRef(s)})}if(!u)return{...d,stop:f,resume:f,supported:u,observing:c};const h=()=>{for(let e=0;e<p.length;e++){const[t,r]=p[e];d[t].value=N(n(s),r)}},y=new MutationObserver(h),w=()=>{y.disconnect(),c.value=!1},b=()=>{c.value||h(),y.observe(n(s),i),c.value=!0};return t.onUnmounted(w),t.isRef(s)?t.onMounted(()=>{m.forEach(e=>e()),t.watch(s,(e,t)=>{t&&w(),e&&b()})}):(g||s)&&(m.forEach(e=>e()),b()),{...d,supported:u,resume:b,stop:w,observing:c}},e.useDateNow=function(e){return x({refreshMs:e&&e.refreshMs||1e3,sync:!e||!u(e.sync)||e.sync,timeFn:Date.now})},e.useDebounce=L,e.useEvent=j,e.useFetch=function(e,n){const r=t.ref(null),o=t.ref(""),a=t.ref(),s=!!e&&u(e.isJson),i=t.ref(null),c=!s||!1!==e.isJson,v=!s||!1!==e.parseImmediate,d=t.ref(!1),f=t.ref();let m=void 0;const p=$(async(e,t)=>{m=new AbortController;const l=await fetch(e,{signal:m.signal,...n,...t});if(l){const e=[c?l.clone().json().then(e=>r.value=e).catch(e=>{r.value=null,i.value=e}):Promise.resolve(),l.clone().blob().then(e=>{a.value=e}),l.clone().text().then(e=>{o.value=e})];v&&await Promise.all(e)}return l},!0),h=t.computed(()=>p.result.value&&p.result.value.status||null),y=t.computed(()=>p.result.value&&p.result.value.statusText||null);return e&&(!l(e)&&s||p.exec(e,void 0,!1)),{...p,cancel:e=>{m&&(m.abort(),d.value=!0,f.value=e)},isCancelled:d,cancelledMessage:f,text:o,blob:a,json:r,jsonError:i,status:h,statusText:y}},e.useFormat=R,e.useGeolocation=function(e){const n=g&&!!navigator.geolocation,r=t.ref(e?!1===e.immediate:void 0),o=t.ref(null),a=t.ref(null),l=t.ref(null),s=t.ref(e&&e.enableHighAccuracy||null);let i=f;if(n){const n=e=>{a.value=e.timestamp,l.value=e.coords,o.value=null},c=e=>{a.value=Date.now(),l.value=null,o.value=e},v=()=>!0!==r.value&&f&&navigator.geolocation.clearWatch(f);let d=()=>navigator.geolocation.getCurrentPosition(n,c,e);i=r.value?()=>{r.value?r.value=!1:d()}:d;let f=0;t.onMounted(()=>t.watch([s,r],t=>{v();const r=u(t[0])?t[0]:e?e.enableHighAccuracy:void 0;f=navigator.geolocation.watchPosition(n,c,e?{...e,enableHighAccuracy:r}:{enableHighAccuracy:r})},{lazy:r.value})),t.onUnmounted(v)}return{supported:n,refresh:i,error:o,timestamp:a,coords:l,highAccuracy:s}},e.useI18n=function(e){return e?z(e):t.inject(A)},e.useIntersectionObserver=function(e,o){const a=g&&"IntersectionObserver"in window,l=e?r(e):void 0,u=!l||!v(l.value)&&l.value?void 0:l,s=t.computed(()=>o?n(o):u?void 0:n(e)),i=t.ref(u&&u.value?[u.value]:[]),c=t.computed(()=>i.value.length>0&&i.value.every(e=>e.isIntersecting)),d=e=>{i.value=e};let m=t.ref();a&&t.watch(s,e=>{m.value&&m.value.disconnect();const t=e&&e&&{root:n(e.root),rootMargin:n(e.rootMargin),threshold:n(e.threshold)}||void 0;m.value=new IntersectionObserver(d,t),i.value.map(e=>e.target).forEach(m.value.observe)},{deep:!0});const p=a?e=>{const t=n(e);m.value.observe(t)}:f,h=a?e=>{const t=n(e);m.value.unobserve(t)}:f,y=()=>m.value.disconnect();return u&&(u.value||t.onMounted(()=>{u.value&&p(u)}),t.onUnmounted(()=>{y()})),{supported:a,elements:i,observe:p,unobserve:h,disconnect:y,isIntersecting:c}},e.useLanguage=function(){if(B||(B=g?t.ref(navigator.language):t.ref("")),!U)if(g){U=t.ref(navigator.languages);const e=()=>{B.value=navigator.language,U.value=navigator.languages};window.addEventListener("languagechange",e,p)}else U=t.ref([]);return{language:B,languages:U}},e.useLocalStorage=se,e.useMatchMedia=q,e.useNetworkInformation=function(){const e=!!g&&(navigator.connection||navigator.mozConnection||navigator.webkitConnection),n=!!e,r=t.ref(0),o=t.ref(0),a=t.ref("unknown"),l=t.ref(0),u=t.ref(!1),s=t.ref("none");let i=f,c=f;return e&&(i=()=>{r.value=e.downlink,o.value=e.downlinkMax,a.value=e.effectiveType,l.value=e.rtt,u.value=e.saveData,s.value=e.type},c=j(e,"change",i,p),i()),{supported:n,downlink:r,downlinkMax:o,effectiveType:a,rtt:l,saveData:u,type:s,remove:c}},e.useNow=x,e.useOnMouseMove=function(e,n,r){const o=t.ref(0),a=t.ref(0);let l=e=>{o.value=e.x,a.value=e.y};const[u,s]=i(n)?[void 0,n]:[n,r];s&&(l=L(l,r));const c=j(e,"mousemove",l,u);return{mouseX:o,mouseY:a,remove:c}},e.useOnResize=function(e,n,o){const a=r(e),l=t.ref(a.value&&a.value.clientHeight),u=t.ref(a.value&&a.value.clientWidth);let s=()=>{l.value=a.value.clientHeight,u.value=a.value.clientWidth};const[c,v]=i(n)?[void 0,n]:[n,o];v&&(s=L(s,o));const d=g?j(window,"resize",s,c||p):f;return{height:l,width:u,remove:d}},e.useOnScroll=function(e,n,o){const a=e=>!(i(e)||u(e)||!v(e)&&!t.isRef(e)||!e),l=a(e)?r(e):t.ref(g&&window||void 0),s=a(e)?l:t.ref(g&&window.document.scrollingElement||void 0),c=t.ref(s.value&&s.value.scrollTop||0),d=t.ref(s.value&&s.value.scrollLeft||0);let f=()=>{c.value=s.value.scrollTop,d.value=s.value.scrollLeft};const m=(...e)=>s.value&&s.value.scrollTo&&s.value.scrollTo.apply(s.value,e),h=e=>m({top:e}),y=e=>m({left:e}),[w,b]=i(e)||!e?[p,e]:i(n)?[p,n]:[n,o];b&&(f=L(f,o));const $=j(l,"scroll",f,w),E=t.watch(c,h,{lazy:!0}),M=t.watch(d,y,{lazy:!0});return{scrollTop:c,scrollLeft:d,scrollTo:m,remove:()=>{$(),M(),E()},scrollTopTo:h,scrollLeftTo:y}},e.useOnline=function(){const e=g&&"onLine"in navigator;return e||(D=t.ref(!1)),D||(D=t.ref(navigator.onLine),window.addEventListener("offline",()=>D.value=!1,p),window.addEventListener("online",()=>D.value=!0,p)),{supported:e,online:D}},e.usePageVisibility=function(){return V||(V=t.ref(g&&document.hidden)),F||(g?(F=t.ref(document.visibilityState),document.addEventListener("visibilitychange",()=>{F.value=document.visibilityState,V.value=document.hidden},p)):F=t.ref(!1)),{visibility:F,hidden:V}},e.usePagination=b,e.usePath=O,e.usePerformanceNow=function(e){return x({refreshMs:e&&e.refreshMs||1e3,sync:!e||!u(e.sync)||e.sync,timeFn:()=>performance.now()})},e.usePromise=$,e.usePromiseLazy=function(e,t=!1){return $(e,{lazy:!0,throwException:t})},e.useRetry=function(e,n){const r=!e||a(e)?{}:e,o=a(e)?e:n;if(!a(e)&&!c(e))throw new Error("[useRetry] options needs to be 'object'");if(o&&!a(o))throw new Error("[useRetry] factory needs to be 'function'");const l=t.ref(!1),u=t.ref(),s=t.ref([]),i={value:!1},v={isRetrying:l,retryCount:t.computed(()=>s.value.length),nextRetry:u,retryErrors:s,[E]:{value:0},[M]:i},d=o?(...e)=>(++v[E].value,S(r,v,o,e)):e=>(++v[E].value,S(r,v,e,void 0));return{...v,cancel:()=>{v.isRetrying.value=!1,v.retryErrors.value.push(new Error("[useRetry] cancelled")),v.nextRetry.value=void 0,i.value=!0},exec:d}},e.useSessionStorage=ie,e.useSharedRef=J,e.useStorage=function(e,t,n){return void 0===ce&&(ce=ue("localStorage").supported),ce?se(e,t,n):ie(e,t)},e.useValidation=function(e){const n=[],r=T({input:e},n),o=t.reactive(r.input);return n.forEach(e=>e(o)),o},e.useWebSocket=function(e,n){const r=g&&"WebSocket"in window;let o=null;const a=t.ref(null),l=t.ref(),u=t.ref(null),s=t.ref(!1),i=t.ref(!1),c=t.ref(!1);let v=f,d=f;return r&&(o=new WebSocket(e,n),o.addEventListener("message",e=>{a.value=e,u.value=e.data}),o.addEventListener("error",e=>{l.value=e,c.value=!0}),o.addEventListener("close",()=>{s.value=!1,i.value=!0}),o.addEventListener("open",()=>{s.value=!0,i.value=!1}),v=e=>o.send(e),d=(e,t)=>{o.close(e,t)}),{supported:r,ws:o,send:v,close:d,messageEvent:a,errorEvent:l,data:u,isOpen:s,isClosed:i,errored:c}},e.useWebStorage=ue,e.wrap=r,e}({},vueCompositionApi); |
{ | ||
"name": "vue-composable", | ||
"version": "1.0.0-dev.15", | ||
"version": "1.0.0-dev.16", | ||
"description": "vue-composable", | ||
@@ -46,5 +46,5 @@ "main": "index.js", | ||
"dependencies": { | ||
"@vue-composable/core": "1.0.0-dev.15", | ||
"@vue-composable/web": "1.0.0-dev.15" | ||
"@vue-composable/core": "1.0.0-dev.16", | ||
"@vue-composable/web": "1.0.0-dev.16" | ||
} | ||
} |
Sorry, the diff of this file is too big to display
111274
2213
+ Added@vue-composable/core@1.0.0-dev.16(transitive)
+ Added@vue-composable/web@1.0.0-dev.16(transitive)
- Removed@vue-composable/core@1.0.0-dev.15(transitive)
- Removed@vue-composable/web@1.0.0-dev.15(transitive)