@banmao/hooks 0.0.6 → 0.0.7

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/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("vue");function ce(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Q={exports:{}},le=Q.exports,re;function de(){return re||(re=1,function(e,s){(function(d,m){e.exports=m()})(le,function(){var d=1e3,m=6e4,g=36e5,w="millisecond",p="second",i="minute",a="hour",v="day",M="week",c="month",S="quarter",b="year",D="date",T="Invalid Date",G=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,X=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,O={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(l){var r=["th","st","nd","rd"],t=l%100;return"["+l+(r[(t-20)%10]||r[t]||r[0])+"]"}},j=function(l,r,t){var o=String(l);return!o||o.length>=r?l:""+Array(r+1-o.length).join(t)+l},R={s:j,z:function(l){var r=-l.utcOffset(),t=Math.abs(r),o=Math.floor(t/60),n=t%60;return(r<=0?"+":"-")+j(o,2,"0")+":"+j(n,2,"0")},m:function l(r,t){if(r.date()<t.date())return-l(t,r);var o=12*(t.year()-r.year())+(t.month()-r.month()),n=r.clone().add(o,c),f=t-n<0,h=r.clone().add(o+(f?-1:1),c);return+(-(o+(t-n)/(f?n-h:h-n))||0)},a:function(l){return l<0?Math.ceil(l)||0:Math.floor(l)},p:function(l){return{M:c,y:b,w:M,d:v,D,h:a,m:i,s:p,ms:w,Q:S}[l]||String(l||"").toLowerCase().replace(/s$/,"")},u:function(l){return l===void 0}},H="en",I={};I[H]=O;var q="$isDayjsObject",P=function(l){return l instanceof K||!(!l||!l[q])},N=function l(r,t,o){var n;if(!r)return H;if(typeof r=="string"){var f=r.toLowerCase();I[f]&&(n=f),t&&(I[f]=t,n=f);var h=r.split("-");if(!n&&h.length>1)return l(h[0])}else{var y=r.name;I[y]=r,n=y}return!o&&n&&(H=n),n||!o&&H},C=function(l,r){if(P(l))return l.clone();var t=typeof r=="object"?r:{};return t.date=l,t.args=arguments,new K(t)},$=R;$.l=N,$.i=P,$.w=function(l,r){return C(l,{locale:r.$L,utc:r.$u,x:r.$x,$offset:r.$offset})};var K=function(){function l(t){this.$L=N(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[q]=!0}var r=l.prototype;return r.parse=function(t){this.$d=function(o){var n=o.date,f=o.utc;if(n===null)return new Date(NaN);if($.u(n))return new Date;if(n instanceof Date)return new Date(n);if(typeof n=="string"&&!/Z$/i.test(n)){var h=n.match(G);if(h){var y=h[2]-1||0,x=(h[7]||"0").substring(0,3);return f?new Date(Date.UTC(h[1],y,h[3]||1,h[4]||0,h[5]||0,h[6]||0,x)):new Date(h[1],y,h[3]||1,h[4]||0,h[5]||0,h[6]||0,x)}}return new Date(n)}(t),this.init()},r.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},r.$utils=function(){return $},r.isValid=function(){return this.$d.toString()!==T},r.isSame=function(t,o){var n=C(t);return this.startOf(o)<=n&&n<=this.endOf(o)},r.isAfter=function(t,o){return C(t)<this.startOf(o)},r.isBefore=function(t,o){return this.endOf(o)<C(t)},r.$g=function(t,o,n){return $.u(t)?this[o]:this.set(n,t)},r.unix=function(){return Math.floor(this.valueOf()/1e3)},r.valueOf=function(){return this.$d.getTime()},r.startOf=function(t,o){var n=this,f=!!$.u(o)||o,h=$.p(t),y=function(V,_){var L=$.w(n.$u?Date.UTC(n.$y,_,V):new Date(n.$y,_,V),n);return f?L:L.endOf(v)},x=function(V,_){return $.w(n.toDate()[V].apply(n.toDate("s"),(f?[0,0,0,0]:[23,59,59,999]).slice(_)),n)},E=this.$W,W=this.$M,k=this.$D,Y="set"+(this.$u?"UTC":"");switch(h){case b:return f?y(1,0):y(31,11);case c:return f?y(1,W):y(0,W+1);case M:var z=this.$locale().weekStart||0,F=(E<z?E+7:E)-z;return y(f?k-F:k+(6-F),W);case v:case D:return x(Y+"Hours",0);case a:return x(Y+"Minutes",1);case i:return x(Y+"Seconds",2);case p:return x(Y+"Milliseconds",3);default:return this.clone()}},r.endOf=function(t){return this.startOf(t,!1)},r.$set=function(t,o){var n,f=$.p(t),h="set"+(this.$u?"UTC":""),y=(n={},n[v]=h+"Date",n[D]=h+"Date",n[c]=h+"Month",n[b]=h+"FullYear",n[a]=h+"Hours",n[i]=h+"Minutes",n[p]=h+"Seconds",n[w]=h+"Milliseconds",n)[f],x=f===v?this.$D+(o-this.$W):o;if(f===c||f===b){var E=this.clone().set(D,1);E.$d[y](x),E.init(),this.$d=E.set(D,Math.min(this.$D,E.daysInMonth())).$d}else y&&this.$d[y](x);return this.init(),this},r.set=function(t,o){return this.clone().$set(t,o)},r.get=function(t){return this[$.p(t)]()},r.add=function(t,o){var n,f=this;t=Number(t);var h=$.p(o),y=function(W){var k=C(f);return $.w(k.date(k.date()+Math.round(W*t)),f)};if(h===c)return this.set(c,this.$M+t);if(h===b)return this.set(b,this.$y+t);if(h===v)return y(1);if(h===M)return y(7);var x=(n={},n[i]=m,n[a]=g,n[p]=d,n)[h]||1,E=this.$d.getTime()+t*x;return $.w(E,this)},r.subtract=function(t,o){return this.add(-1*t,o)},r.format=function(t){var o=this,n=this.$locale();if(!this.isValid())return n.invalidDate||T;var f=t||"YYYY-MM-DDTHH:mm:ssZ",h=$.z(this),y=this.$H,x=this.$m,E=this.$M,W=n.weekdays,k=n.months,Y=n.meridiem,z=function(_,L,U,J){return _&&(_[L]||_(o,f))||U[L].slice(0,J)},F=function(_){return $.s(y%12||12,_,"0")},V=Y||function(_,L,U){var J=_<12?"AM":"PM";return U?J.toLowerCase():J};return f.replace(X,function(_,L){return L||function(U){switch(U){case"YY":return String(o.$y).slice(-2);case"YYYY":return $.s(o.$y,4,"0");case"M":return E+1;case"MM":return $.s(E+1,2,"0");case"MMM":return z(n.monthsShort,E,k,3);case"MMMM":return z(k,E);case"D":return o.$D;case"DD":return $.s(o.$D,2,"0");case"d":return String(o.$W);case"dd":return z(n.weekdaysMin,o.$W,W,2);case"ddd":return z(n.weekdaysShort,o.$W,W,3);case"dddd":return W[o.$W];case"H":return String(y);case"HH":return $.s(y,2,"0");case"h":return F(1);case"hh":return F(2);case"a":return V(y,x,!0);case"A":return V(y,x,!1);case"m":return String(x);case"mm":return $.s(x,2,"0");case"s":return String(o.$s);case"ss":return $.s(o.$s,2,"0");case"SSS":return $.s(o.$ms,3,"0");case"Z":return h}return null}(_)||h.replace(":","")})},r.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},r.diff=function(t,o,n){var f,h=this,y=$.p(o),x=C(t),E=(x.utcOffset()-this.utcOffset())*m,W=this-x,k=function(){return $.m(h,x)};switch(y){case b:f=k()/12;break;case c:f=k();break;case S:f=k()/3;break;case M:f=(W-E)/6048e5;break;case v:f=(W-E)/864e5;break;case a:f=W/g;break;case i:f=W/m;break;case p:f=W/d;break;default:f=W}return n?f:$.a(f)},r.daysInMonth=function(){return this.endOf(c).$D},r.$locale=function(){return I[this.$L]},r.locale=function(t,o){if(!t)return this.$L;var n=this.clone(),f=N(t,o,!0);return f&&(n.$L=f),n},r.clone=function(){return $.w(this.$d,this)},r.toDate=function(){return new Date(this.valueOf())},r.toJSON=function(){return this.isValid()?this.toISOString():null},r.toISOString=function(){return this.$d.toISOString()},r.toString=function(){return this.$d.toUTCString()},l}(),ne=K.prototype;return C.prototype=ne,[["$ms",w],["$s",p],["$m",i],["$H",a],["$W",v],["$M",c],["$y",b],["$D",D]].forEach(function(l){ne[l[1]]=function(r){return this.$g(r,l[0],l[1])}}),C.extend=function(l,r){return l.$i||(l(r,K,C),l.$i=!0),C},C.locale=N,C.isDayjs=P,C.unix=function(l){return C(1e3*l)},C.en=I[H],C.Ls=I,C.p={},C})}(Q)),Q.exports}var fe=de();const he=ce(fe);function ve(e){const s=new Blob([e],{type:"application/vnd.ms-excel"});return window.URL.createObjectURL(s)}function me(){return document.createElement("a")}function oe(e,s){const d=he().format("yyyy-MM-dd hh:mm:ss");function m(){const g=me(),w=ve(e);g.href=w,s?g.download=s||`${s}-${d}.xlsx`:g.download=`${d}.xlsx`,document.body.appendChild(g),g.click(),document.body.removeChild(g),window.URL.revokeObjectURL(w)}m()}function pe(e,s){throw new Error(`[naive/${e}]: ${s}`)}const ge="n-message-api";function we(){const e=u.inject(ge,null);return e===null&&pe("use-message","No outer <n-message-provider /> founded. See prerequisite in https://www.naiveui.com/en-US/os-theme/components/message for more details. If you want to use `useMessage` outside setup, please check https://www.naiveui.com/zh-CN/os-theme/components/message#Q-&-A."),e}function $e(e,s={}){const{exportRequestFn:d,filterOption:m=u.ref(),callback:g,immediate:w=!0,code:p=200}=s,i=u.ref(!1),a=u.ref({page:1,pageSize:10,itemCount:0,showSizePicker:!0,pageSizes:[10,20,30,40],showQuickJumper:!0,prefix:O=>`共 ${O.itemCount} 条`}),v=u.ref([]),M=u.computed(()=>m.value),c=async(O=a.value.page,j)=>{i.value=!0;try{const{status:R,data:H}=await e({pageNum:O,pageSize:a.value.pageSize,...M.value,...j}),{list:I,pageNum:q,total:P,pageSize:N}=g&&g(H)||H;if(R===p&&Array.isArray(I))v.value=I,a.value={...a.value,page:q,itemCount:P,pageSize:N};else throw v.value=[],a.value={...a.value,pageSize:10,itemCount:0,page:1},new Error("list的数据类型错误")}catch(R){throw console.error("Error in loadData:",R),R}finally{i.value=!1}},S=we(),b=async()=>{if(!d||typeof d!="function")throw new Error("当前没有提供exportRequest函数");try{const{data:O,fileName:j}=await d(m.value);oe(O,j),S==null||S.success("成功导出")}catch(O){throw console.error("Error in handleExcelData:",O),O}},D=(O,j)=>{j!==void 0&&(a.value.pageSize=j),c(O)},T=O=>{D(O)},G=O=>{D(1,O)},X=O=>{if(O.sorter){const j=[...v.value].sort((R,H)=>O.order==="ascend"?R[O.columnKey]>H[O.columnKey]?1:-1:O.order==="descend"?R[O.columnKey]<H[O.columnKey]?1:-1:0);v.value=j}};return u.onMounted(()=>w&&c(a.value.page)),{dataSource:v,loading:i,pagination:a,handleExcelData:b,handlePageChange:T,handlePageSizeChange:G,handleSortChange:X,loadData:c}}function ie(e){return u.getCurrentScope()?(u.onScopeDispose(e),!0):!1}const ee=new WeakMap,ye=(...e)=>{var s;const d=e[0],m=(s=u.getCurrentInstance())==null?void 0:s.proxy;if(m==null&&!u.hasInjectionContext())throw new Error("injectLocal must be called in setup");return m&&ee.has(m)&&d in ee.get(m)?ee.get(m)[d]:u.inject(...e)},Me=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const Se=Object.prototype.toString,be=e=>Se.call(e)==="[object Object]";function se(e){return e.endsWith("rem")?Number.parseFloat(e)*16:Number.parseFloat(e)}function Z(e){return Array.isArray(e)?e:[e]}function De(e){return u.getCurrentInstance()}function ue(e,s=!0,d){De()?u.onMounted(e,d):s?e():u.nextTick(e)}function Oe(e,s,d){return u.watch(e,s,{...d,immediate:!0})}const B=Me?window:void 0;function A(e){var s;const d=u.toValue(e);return(s=d==null?void 0:d.$el)!=null?s:d}function te(...e){const s=[],d=()=>{s.forEach(i=>i()),s.length=0},m=(i,a,v,M)=>(i.addEventListener(a,v,M),()=>i.removeEventListener(a,v,M)),g=u.computed(()=>{const i=Z(u.toValue(e[0])).filter(a=>a!=null);return i.every(a=>typeof a!="string")?i:void 0}),w=Oe(()=>{var i,a;return[(a=(i=g.value)==null?void 0:i.map(v=>A(v)))!=null?a:[B].filter(v=>v!=null),Z(u.toValue(g.value?e[1]:e[0])),Z(u.unref(g.value?e[2]:e[1])),u.toValue(g.value?e[3]:e[2])]},([i,a,v,M])=>{if(d(),!(i!=null&&i.length)||!(a!=null&&a.length)||!(v!=null&&v.length))return;const c=be(M)?{...M}:M;s.push(...i.flatMap(S=>a.flatMap(b=>v.map(D=>m(S,b,D,c)))))},{flush:"post"}),p=()=>{w(),d()};return ie(d),p}function xe(){const e=u.shallowRef(!1),s=u.getCurrentInstance();return s&&u.onMounted(()=>{e.value=!0},s),e}function ae(e){const s=xe();return u.computed(()=>(s.value,!!e()))}const Ce=Symbol("vueuse-ssr-width");function Ee(){const e=u.hasInjectionContext()?ye(Ce,null):null;return typeof e=="number"?e:void 0}function We(e,s={}){const{window:d=B,ssrWidth:m=Ee()}=s,g=ae(()=>d&&"matchMedia"in d&&typeof d.matchMedia=="function"),w=u.shallowRef(typeof m=="number"),p=u.shallowRef(),i=u.shallowRef(!1),a=v=>{i.value=v.matches};return u.watchEffect(()=>{if(w.value){w.value=!g.value;const v=u.toValue(e).split(",");i.value=v.some(M=>{const c=M.includes("not all"),S=M.match(/\(\s*min-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/),b=M.match(/\(\s*max-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/);let D=!!(S||b);return S&&D&&(D=m>=se(S[1])),b&&D&&(D=m<=se(b[1])),c?!D:D});return}g.value&&(p.value=d.matchMedia(u.toValue(e)),i.value=p.value.matches)}),te(p,"change",a,{passive:!0}),u.computed(()=>i.value)}function _e(e,s,d={}){const{window:m=B,...g}=d;let w;const p=ae(()=>m&&"ResizeObserver"in m),i=()=>{w&&(w.disconnect(),w=void 0)},a=u.computed(()=>{const c=u.toValue(e);return Array.isArray(c)?c.map(S=>A(S)):[A(c)]}),v=u.watch(a,c=>{if(i(),p.value&&m){w=new ResizeObserver(s);for(const S of c)S&&w.observe(S,g)}},{immediate:!0,flush:"post"}),M=()=>{i(),v()};return ie(M),{isSupported:p,stop:M}}function je(e,s={width:0,height:0},d={}){const{window:m=B,box:g="content-box"}=d,w=u.computed(()=>{var c,S;return(S=(c=A(e))==null?void 0:c.namespaceURI)==null?void 0:S.includes("svg")}),p=u.shallowRef(s.width),i=u.shallowRef(s.height),{stop:a}=_e(e,([c])=>{const S=g==="border-box"?c.borderBoxSize:g==="content-box"?c.contentBoxSize:c.devicePixelContentBoxSize;if(m&&w.value){const b=A(e);if(b){const D=b.getBoundingClientRect();p.value=D.width,i.value=D.height}}else if(S){const b=Z(S);p.value=b.reduce((D,{inlineSize:T})=>D+T,0),i.value=b.reduce((D,{blockSize:T})=>D+T,0)}else p.value=c.contentRect.width,i.value=c.contentRect.height},d);ue(()=>{const c=A(e);c&&(p.value="offsetWidth"in c?c.offsetWidth:s.width,i.value="offsetHeight"in c?c.offsetHeight:s.height)});const v=u.watch(()=>A(e),c=>{p.value=c?s.width:0,i.value=c?s.height:0});function M(){a(),v()}return{width:p,height:i,stop:M}}function ke(e={}){const{window:s=B,initialWidth:d=Number.POSITIVE_INFINITY,initialHeight:m=Number.POSITIVE_INFINITY,listenOrientation:g=!0,includeScrollbar:w=!0,type:p="inner"}=e,i=u.shallowRef(d),a=u.shallowRef(m),v=()=>{if(s)if(p==="outer")i.value=s.outerWidth,a.value=s.outerHeight;else if(p==="visual"&&s.visualViewport){const{width:c,height:S,scale:b}=s.visualViewport;i.value=Math.round(c*b),a.value=Math.round(S*b)}else w?(i.value=s.innerWidth,a.value=s.innerHeight):(i.value=s.document.documentElement.clientWidth,a.value=s.document.documentElement.clientHeight)};v(),ue(v);const M={passive:!0};if(te("resize",v,M),s&&p==="visual"&&s.visualViewport&&te(s.visualViewport,"resize",v,M),g){const c=We("(orientation: portrait)");u.watch(c,()=>v())}return{width:i,height:a}}function He(e,s){if(!e)throw new Error("tableRef are required");const d=u.computed(()=>{var a;return(a=e.value)==null?void 0:a.searchRef}),{height:m}=ke(),{height:g}=je(d),{height:w=0,minHeight:p=600}=s||{};return{height:u.computed(()=>{const a=m.value-g.value-w;return a>p?a:p})}}function Ie(e,s){const{immediate:d=!0}=s||{},m=u.ref(null),g=u.ref(!1),w=u.ref(null),p=async()=>{g.value=!0,w.value=null;try{const i=await e();m.value=i}catch(i){w.value=i}finally{g.value=!1}};return d&&p(),{data:m,loading:g,error:w,fetchData:p}}exports.useAsyncData=Ie;exports.useExportFile=oe;exports.useList=$e;exports.useTableHeight=He;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,o)=>(o=n==null?{}:e(i(n)),s(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));let l=require("vue");var u=c(o(((e,t,n)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self).dayjs=r()})(n,(function(){"use strict";var e=1e3,t=6e4,n=36e5,r=`millisecond`,i=`second`,a=`minute`,o=`hour`,s=`day`,c=`week`,l=`month`,u=`quarter`,d=`year`,f=`date`,p=`Invalid Date`,m=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,h=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,g={name:`en`,weekdays:`Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday`.split(`_`),months:`January_February_March_April_May_June_July_August_September_October_November_December`.split(`_`),ordinal:function(e){var t=[`th`,`st`,`nd`,`rd`],n=e%100;return`[`+e+(t[(n-20)%10]||t[n]||t[0])+`]`}},_=function(e,t,n){var r=String(e);return!r||r.length>=t?e:``+Array(t+1-r.length).join(n)+e},v={s:_,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),r=Math.floor(n/60),i=n%60;return(t<=0?`+`:`-`)+_(r,2,`0`)+`:`+_(i,2,`0`)},m:function e(t,n){if(t.date()<n.date())return-e(n,t);var r=12*(n.year()-t.year())+(n.month()-t.month()),i=t.clone().add(r,l),a=n-i<0,o=t.clone().add(r+(a?-1:1),l);return+(-(r+(n-i)/(a?i-o:o-i))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:l,y:d,w:c,d:s,D:f,h:o,m:a,s:i,ms:r,Q:u}[e]||String(e||``).toLowerCase().replace(/s$/,``)},u:function(e){return e===void 0}},y=`en`,b={};b[y]=g;var x=`$isDayjsObject`,S=function(e){return e instanceof E||!(!e||!e[x])},C=function e(t,n,r){var i;if(!t)return y;if(typeof t==`string`){var a=t.toLowerCase();b[a]&&(i=a),n&&(b[a]=n,i=a);var o=t.split(`-`);if(!i&&o.length>1)return e(o[0])}else{var s=t.name;b[s]=t,i=s}return!r&&i&&(y=i),i||!r&&y},w=function(e,t){if(S(e))return e.clone();var n=typeof t==`object`?t:{};return n.date=e,n.args=arguments,new E(n)},T=v;T.l=C,T.i=S,T.w=function(e,t){return w(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var E=function(){function g(e){this.$L=C(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[x]=!0}var _=g.prototype;return _.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(t===null)return new Date(NaN);if(T.u(t))return new Date;if(t instanceof Date)return new Date(t);if(typeof t==`string`&&!/Z$/i.test(t)){var r=t.match(m);if(r){var i=r[2]-1||0,a=(r[7]||`0`).substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)}}return new Date(t)}(e),this.init()},_.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},_.$utils=function(){return T},_.isValid=function(){return this.$d.toString()!==p},_.isSame=function(e,t){var n=w(e);return this.startOf(t)<=n&&n<=this.endOf(t)},_.isAfter=function(e,t){return w(e)<this.startOf(t)},_.isBefore=function(e,t){return this.endOf(t)<w(e)},_.$g=function(e,t,n){return T.u(e)?this[t]:this.set(n,e)},_.unix=function(){return Math.floor(this.valueOf()/1e3)},_.valueOf=function(){return this.$d.getTime()},_.startOf=function(e,t){var n=this,r=!!T.u(t)||t,u=T.p(e),p=function(e,t){var i=T.w(n.$u?Date.UTC(n.$y,t,e):new Date(n.$y,t,e),n);return r?i:i.endOf(s)},m=function(e,t){return T.w(n.toDate()[e].apply(n.toDate(`s`),(r?[0,0,0,0]:[23,59,59,999]).slice(t)),n)},h=this.$W,g=this.$M,_=this.$D,v=`set`+(this.$u?`UTC`:``);switch(u){case d:return r?p(1,0):p(31,11);case l:return r?p(1,g):p(0,g+1);case c:var y=this.$locale().weekStart||0,b=(h<y?h+7:h)-y;return p(r?_-b:_+(6-b),g);case s:case f:return m(v+`Hours`,0);case o:return m(v+`Minutes`,1);case a:return m(v+`Seconds`,2);case i:return m(v+`Milliseconds`,3);default:return this.clone()}},_.endOf=function(e){return this.startOf(e,!1)},_.$set=function(e,t){var n,c=T.p(e),u=`set`+(this.$u?`UTC`:``),p=(n={},n[s]=u+`Date`,n[f]=u+`Date`,n[l]=u+`Month`,n[d]=u+`FullYear`,n[o]=u+`Hours`,n[a]=u+`Minutes`,n[i]=u+`Seconds`,n[r]=u+`Milliseconds`,n)[c],m=c===s?this.$D+(t-this.$W):t;if(c===l||c===d){var h=this.clone().set(f,1);h.$d[p](m),h.init(),this.$d=h.set(f,Math.min(this.$D,h.daysInMonth())).$d}else p&&this.$d[p](m);return this.init(),this},_.set=function(e,t){return this.clone().$set(e,t)},_.get=function(e){return this[T.p(e)]()},_.add=function(r,u){var f,p=this;r=Number(r);var m=T.p(u),h=function(e){var t=w(p);return T.w(t.date(t.date()+Math.round(e*r)),p)};if(m===l)return this.set(l,this.$M+r);if(m===d)return this.set(d,this.$y+r);if(m===s)return h(1);if(m===c)return h(7);var g=(f={},f[a]=t,f[o]=n,f[i]=e,f)[m]||1,_=this.$d.getTime()+r*g;return T.w(_,this)},_.subtract=function(e,t){return this.add(-1*e,t)},_.format=function(e){var t=this,n=this.$locale();if(!this.isValid())return n.invalidDate||p;var r=e||`YYYY-MM-DDTHH:mm:ssZ`,i=T.z(this),a=this.$H,o=this.$m,s=this.$M,c=n.weekdays,l=n.months,u=n.meridiem,d=function(e,n,i,a){return e&&(e[n]||e(t,r))||i[n].slice(0,a)},f=function(e){return T.s(a%12||12,e,`0`)},m=u||function(e,t,n){var r=e<12?`AM`:`PM`;return n?r.toLowerCase():r};return r.replace(h,(function(e,r){return r||function(e){switch(e){case`YY`:return String(t.$y).slice(-2);case`YYYY`:return T.s(t.$y,4,`0`);case`M`:return s+1;case`MM`:return T.s(s+1,2,`0`);case`MMM`:return d(n.monthsShort,s,l,3);case`MMMM`:return d(l,s);case`D`:return t.$D;case`DD`:return T.s(t.$D,2,`0`);case`d`:return String(t.$W);case`dd`:return d(n.weekdaysMin,t.$W,c,2);case`ddd`:return d(n.weekdaysShort,t.$W,c,3);case`dddd`:return c[t.$W];case`H`:return String(a);case`HH`:return T.s(a,2,`0`);case`h`:return f(1);case`hh`:return f(2);case`a`:return m(a,o,!0);case`A`:return m(a,o,!1);case`m`:return String(o);case`mm`:return T.s(o,2,`0`);case`s`:return String(t.$s);case`ss`:return T.s(t.$s,2,`0`);case`SSS`:return T.s(t.$ms,3,`0`);case`Z`:return i}return null}(e)||i.replace(`:`,``)}))},_.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},_.diff=function(r,f,p){var m,h=this,g=T.p(f),_=w(r),v=(_.utcOffset()-this.utcOffset())*t,y=this-_,b=function(){return T.m(h,_)};switch(g){case d:m=b()/12;break;case l:m=b();break;case u:m=b()/3;break;case c:m=(y-v)/6048e5;break;case s:m=(y-v)/864e5;break;case o:m=y/n;break;case a:m=y/t;break;case i:m=y/e;break;default:m=y}return p?m:T.a(m)},_.daysInMonth=function(){return this.endOf(l).$D},_.$locale=function(){return b[this.$L]},_.locale=function(e,t){if(!e)return this.$L;var n=this.clone(),r=C(e,t,!0);return r&&(n.$L=r),n},_.clone=function(){return T.w(this.$d,this)},_.toDate=function(){return new Date(this.valueOf())},_.toJSON=function(){return this.isValid()?this.toISOString():null},_.toISOString=function(){return this.$d.toISOString()},_.toString=function(){return this.$d.toUTCString()},g}(),D=E.prototype;return w.prototype=D,[[`$ms`,r],[`$s`,i],[`$m`,a],[`$H`,o],[`$W`,s],[`$M`,l],[`$y`,d],[`$D`,f]].forEach((function(e){D[e[1]]=function(t){return this.$g(t,e[0],e[1])}})),w.extend=function(e,t){return e.$i||=(e(t,E,w),!0),w},w.locale=C,w.isDayjs=S,w.unix=function(e){return w(1e3*e)},w.en=b[y],w.Ls=b,w.p={},w}))}))(),1);function d(e){let t=new Blob([e],{type:`application/vnd.ms-excel`});return window.URL.createObjectURL(t)}function f(){return document.createElement(`a`)}function p(e,t){let n=(0,u.default)().format(`yyyy-MM-dd hh:mm:ss`);function r(){let r=f(),i=d(e);r.href=i,r.download=t?t||`${t}-${n}.xlsx`:`${n}.xlsx`,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.URL.revokeObjectURL(i)}r()}function m(e){return e}function h(e,t){throw Error(`[naive/${e}]: ${t}`)}var g=m(`n-message-api`);function _(){let e=(0,l.inject)(g,null);return e===null&&h(`use-message`,"No outer <n-message-provider /> founded. See prerequisite in https://www.naiveui.com/en-US/os-theme/components/message for more details. If you want to use `useMessage` outside setup, please check https://www.naiveui.com/zh-CN/os-theme/components/message#Q-&-A."),e}function v(e,t={}){let{exportRequestFn:n,filterOption:r=(0,l.ref)(),callback:i,immediate:a=!0,code:o=200,pagination:s={displayOrder:[`pages`,`size-picker`,`quick-jumper`],pageSizes:[10,20,50,100],pageSize:10}}=t,c=(0,l.ref)(!1),u=(0,l.ref)({page:1,pageSize:s.pageSize,itemCount:0,showSizePicker:s.displayOrder?.includes(`size-picker`)||!0,pageSizes:s.pageSizes||[],showQuickJumper:s.displayOrder?.includes(`quick-jumper`)||!0,prefix:e=>`共 ${e.itemCount} 条`}),d=(0,l.ref)([]),f=(0,l.computed)(()=>r.value),m=async(t=u.value.page,n)=>{c.value=!0;try{let{status:r,data:a}=await e({pageNum:t,pageSize:u.value.pageSize,...f.value,...n}),{list:s,pageNum:c,total:l,pageSize:p}=i&&i(a)||a;if(r===o&&Array.isArray(s))d.value=s,u.value={...u.value,page:c,itemCount:l,pageSize:p};else throw d.value=[],u.value={...u.value,pageSize:10,itemCount:0,page:1},Error(`list的数据类型错误`)}catch(e){throw console.error(`Error in loadData:`,e),e}finally{c.value=!1}},h=_(),g=async()=>{if(!n||typeof n!=`function`)throw Error(`当前没有提供exportRequest函数`);try{let{data:e,fileName:t}=await n(r.value);p(e,t),h?.success(`成功导出`)}catch(e){throw console.error(`Error in handleExcelData:`,e),e}},v=(e,t)=>{t!==void 0&&(u.value.pageSize=t),m(e)};return(0,l.onMounted)(()=>a&&m(u.value.page)),{dataSource:d,loading:c,pagination:u,handleExcelData:g,handlePageChange:e=>{v(e)},handlePageSizeChange:e=>{v(1,e)},handleSortChange:e=>{if(e.sorter){let t=[...d.value].sort((t,n)=>e.order===`ascend`?t[e.columnKey]>n[e.columnKey]?1:-1:e.order===`descend`?t[e.columnKey]<n[e.columnKey]?1:-1:0);d.value=t}},loadData:m}}function y(e){return(0,l.getCurrentScope)()?((0,l.onScopeDispose)(e),!0):!1}var b=new WeakMap,x=(...e)=>{let t=e[0],n=(0,l.getCurrentInstance)()?.proxy;if(n==null&&!(0,l.hasInjectionContext)())throw Error(`injectLocal must be called in setup`);return n&&b.has(n)&&t in b.get(n)?b.get(n)[t]:(0,l.inject)(...e)},S=typeof window<`u`&&typeof document<`u`;typeof WorkerGlobalScope<`u`&&globalThis instanceof WorkerGlobalScope;var C=Object.prototype.toString,w=e=>C.call(e)===`[object Object]`;function T(e){return e.endsWith(`rem`)?Number.parseFloat(e)*16:Number.parseFloat(e)}function E(e){return Array.isArray(e)?e:[e]}function D(e){return e||(0,l.getCurrentInstance)()}function O(e,t=!0,n){D(n)?(0,l.onMounted)(e,n):t?e():(0,l.nextTick)(e)}function k(e,t,n){return(0,l.watch)(e,t,{...n,immediate:!0})}var A=S?window:void 0;S&&window.document,S&&window.navigator,S&&window.location;function j(e){let t=(0,l.toValue)(e);return t?.$el??t}function M(...e){let t=[],n=()=>{t.forEach(e=>e()),t.length=0},r=(e,t,n,r)=>(e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)),i=(0,l.computed)(()=>{let t=E((0,l.toValue)(e[0])).filter(e=>e!=null);return t.every(e=>typeof e!=`string`)?t:void 0}),a=k(()=>[i.value?.map(e=>j(e))??[A].filter(e=>e!=null),E((0,l.toValue)(i.value?e[1]:e[0])),E((0,l.unref)(i.value?e[2]:e[1])),(0,l.toValue)(i.value?e[3]:e[2])],([e,i,a,o])=>{if(n(),!e?.length||!i?.length||!a?.length)return;let s=w(o)?{...o}:o;t.push(...e.flatMap(e=>i.flatMap(t=>a.map(n=>r(e,t,n,s)))))},{flush:`post`});return y(n),()=>{a(),n()}}function N(){let e=(0,l.shallowRef)(!1),t=(0,l.getCurrentInstance)();return t&&(0,l.onMounted)(()=>{e.value=!0},t),e}function P(e){let t=N();return(0,l.computed)(()=>(t.value,!!e()))}var F=Symbol(`vueuse-ssr-width`);function I(){let e=(0,l.hasInjectionContext)()?x(F,null):null;return typeof e==`number`?e:void 0}function L(e,t={}){let{window:n=A,ssrWidth:r=I()}=t,i=P(()=>n&&`matchMedia`in n&&typeof n.matchMedia==`function`),a=(0,l.shallowRef)(typeof r==`number`),o=(0,l.shallowRef)(),s=(0,l.shallowRef)(!1);return(0,l.watchEffect)(()=>{if(a.value){a.value=!i.value;let t=(0,l.toValue)(e).split(`,`);s.value=t.some(e=>{let t=e.includes(`not all`),n=e.match(/\(\s*min-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/),i=e.match(/\(\s*max-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/),a=!!(n||i);return n&&a&&(a=r>=T(n[1])),i&&a&&(a=r<=T(i[1])),t?!a:a})}else i.value&&(o.value=n.matchMedia((0,l.toValue)(e)),s.value=o.value.matches)}),M(o,`change`,e=>{s.value=e.matches},{passive:!0}),(0,l.computed)(()=>s.value)}function R(e,t,n={}){let{window:r=A,...i}=n,a,o=P(()=>r&&`ResizeObserver`in r),s=()=>{a&&=(a.disconnect(),void 0)},c=(0,l.computed)(()=>{let t=(0,l.toValue)(e);return Array.isArray(t)?t.map(e=>j(e)):[j(t)]}),u=(0,l.watch)(c,e=>{if(s(),o.value&&r){a=new ResizeObserver(t);for(let t of e)t&&a.observe(t,i)}},{immediate:!0,flush:`post`}),d=()=>{s(),u()};return y(d),{isSupported:o,stop:d}}function z(e,t={width:0,height:0},n={}){let{window:r=A,box:i=`content-box`}=n,a=(0,l.computed)(()=>(j(e)?.namespaceURI)?.includes(`svg`)),o=(0,l.shallowRef)(t.width),s=(0,l.shallowRef)(t.height),{stop:c}=R(e,([t])=>{let n=i===`border-box`?t.borderBoxSize:i===`content-box`?t.contentBoxSize:t.devicePixelContentBoxSize;if(r&&a.value){let t=j(e);if(t){let e=t.getBoundingClientRect();o.value=e.width,s.value=e.height}}else if(n){let e=E(n);o.value=e.reduce((e,{inlineSize:t})=>e+t,0),s.value=e.reduce((e,{blockSize:t})=>e+t,0)}else o.value=t.contentRect.width,s.value=t.contentRect.height},n);O(()=>{let n=j(e);n&&(o.value=`offsetWidth`in n?n.offsetWidth:t.width,s.value=`offsetHeight`in n?n.offsetHeight:t.height)});let u=(0,l.watch)(()=>j(e),e=>{o.value=e?t.width:0,s.value=e?t.height:0});function d(){c(),u()}return{width:o,height:s,stop:d}}function B(e={}){let{window:t=A,initialWidth:n=1/0,initialHeight:r=1/0,listenOrientation:i=!0,includeScrollbar:a=!0,type:o=`inner`}=e,s=(0,l.shallowRef)(n),c=(0,l.shallowRef)(r),u=()=>{if(t){if(o===`outer`)s.value=t.outerWidth,c.value=t.outerHeight;else if(o===`visual`&&t.visualViewport){let{width:e,height:n,scale:r}=t.visualViewport;s.value=Math.round(e*r),c.value=Math.round(n*r)}else a?(s.value=t.innerWidth,c.value=t.innerHeight):(s.value=t.document.documentElement.clientWidth,c.value=t.document.documentElement.clientHeight)}};u(),O(u);let d={passive:!0};if(M(`resize`,u,d),t&&o===`visual`&&t.visualViewport&&M(t.visualViewport,`resize`,u,d),i){let e=L(`(orientation: portrait)`);(0,l.watch)(e,()=>u())}return{width:s,height:c}}function V(e,t){if(!e)throw Error(`tableRef are required`);let n=(0,l.computed)(()=>e.value?.searchRef),{height:r}=B(),{height:i}=z(n),{height:a=0,minHeight:o=600}=t||{};return{height:(0,l.computed)(()=>{let e=r.value-i.value-a;return e>o?e:o})}}function H(e,t){let{immediate:n=!0}=t||{},r=(0,l.ref)(null),i=(0,l.ref)(!1),a=(0,l.ref)(null),o=async()=>{i.value=!0,a.value=null;try{let t=await e();r.value=t}catch(e){a.value=e}finally{i.value=!1}};return n&&o(),{data:r,loading:i,error:a,fetchData:o}}exports.useAsyncData=H,exports.useExportFile=p,exports.useList=v,exports.useTableHeight=V;