2 lines
12 KiB
JavaScript
2 lines
12 KiB
JavaScript
import{Q as me}from"./QSpinnerDots.b721c188.js";import{c as re,r as p,a as L,w as B,J as ae,K as oe,o as ne,L as ie,d as pe,h as x,b as ue,M as he,N as I,O as J,P as O,R as V,S as ce,T as Z,V as ge,g as de,W as ye,X as R,Y as be,Z as _e,$ as N,a0 as Y,a1 as G,a2 as z,a3 as W,a4 as Q,a5 as Ce,a6 as Se,a7 as Ee,a8 as we,a9 as qe,s as S,t as Te,v as X,B as ee,aa as $,y as A,C as q,ab as xe,ac as ke,x as Me,F as j,G as M,ad as Pe,A as te}from"./index.7df25f12.js";import{g as le,s as se}from"./touch.70a9dd44.js";import{c as Be}from"./selection.c52745bf.js";import{_ as fe}from"./sorry.e0a2c349.js";const{passive:T}=he;var Le=re({name:"QInfiniteScroll",props:{offset:{type:Number,default:500},debounce:{type:[String,Number],default:100},scrollTarget:{default:void 0},initialIndex:Number,disable:Boolean,reverse:Boolean},emits:["load"],setup(r,{slots:i,emit:n}){const u=p(!1),e=p(!0),t=p(null),a=p(null);let o=r.initialIndex||0,l,s;const y=L(()=>"q-infinite-scroll__loading"+(u.value===!0?"":" invisible"));function c(){if(r.disable===!0||u.value===!0||e.value===!1)return;const d=I(l),m=O(l),w=Z(l);r.reverse===!1?Math.round(m+w+r.offset)>=Math.round(d)&&f():Math.round(m)<=r.offset&&f()}function f(){if(r.disable===!0||u.value===!0||e.value===!1)return;o++,u.value=!0;const d=I(l);n("load",o,m=>{e.value===!0&&(u.value=!1,J(()=>{if(r.reverse===!0){const w=I(l),H=O(l),ve=w-d;V(l,H+ve)}m===!0?_():t.value&&t.value.closest("body")&&s()}))})}function v(){o=0}function h(){e.value===!1&&(e.value=!0,l.addEventListener("scroll",s,T)),c()}function _(){e.value===!0&&(e.value=!1,u.value=!1,l.removeEventListener("scroll",s,T),s!==void 0&&s.cancel!==void 0&&s.cancel())}function D(){if(l&&e.value===!0&&l.removeEventListener("scroll",s,T),l=ce(t.value,r.scrollTarget),e.value===!0){if(l.addEventListener("scroll",s,T),r.reverse===!0){const d=I(l),m=Z(l);V(l,d-m)}c()}}function k(d){o=d}function F(d){d=parseInt(d,10);const m=s;s=d<=0?c:ge(c,isNaN(d)===!0?100:d),l&&e.value===!0&&(m!==void 0&&l.removeEventListener("scroll",m,T),l.addEventListener("scroll",s,T))}function b(d){if(C.value===!0){if(a.value===null){d!==!0&&J(()=>{b(!0)});return}const m=`${u.value===!0?"un":""}pauseAnimations`;Array.from(a.value.getElementsByTagName("svg")).forEach(w=>{w[m]()})}}const C=L(()=>r.disable!==!0&&e.value===!0);B([u,C],()=>{b()}),B(()=>r.disable,d=>{d===!0?_():h()}),B(()=>r.reverse,()=>{u.value===!1&&e.value===!0&&c()}),B(()=>r.scrollTarget,D),B(()=>r.debounce,F);let E=!1;ae(()=>{E!==!1&&l&&V(l,E)}),oe(()=>{E=l?O(l):!1}),ne(()=>{e.value===!0&&l.removeEventListener("scroll",s,T)}),ie(()=>{F(r.debounce),D(),u.value===!1&&b()});const g=de();return Object.assign(g.proxy,{poll:()=>{s!==void 0&&s()},trigger:f,stop:_,reset:v,resume:h,setIndex:k}),()=>{const d=pe(i.default,[]);return C.value===!0&&d[r.reverse===!1?"push":"unshift"](x("div",{ref:a,class:y.value},ue(i.loading))),x("div",{class:"q-infinite-scroll",ref:t},d)}}});function U(r,i,n){const u=W(r);let e,t=u.left-i.event.x,a=u.top-i.event.y,o=Math.abs(t),l=Math.abs(a);const s=i.direction;s.horizontal===!0&&s.vertical!==!0?e=t<0?"left":"right":s.horizontal!==!0&&s.vertical===!0?e=a<0?"up":"down":s.up===!0&&a<0?(e="up",o>l&&(s.left===!0&&t<0?e="left":s.right===!0&&t>0&&(e="right"))):s.down===!0&&a>0?(e="down",o>l&&(s.left===!0&&t<0?e="left":s.right===!0&&t>0&&(e="right"))):s.left===!0&&t<0?(e="left",o<l&&(s.up===!0&&a<0?e="up":s.down===!0&&a>0&&(e="down"))):s.right===!0&&t>0&&(e="right",o<l&&(s.up===!0&&a<0?e="up":s.down===!0&&a>0&&(e="down")));let y=!1;if(e===void 0&&n===!1){if(i.event.isFirst===!0||i.event.lastDir===void 0)return{};e=i.event.lastDir,y=!0,e==="left"||e==="right"?(u.left-=t,o=0,t=0):(u.top-=a,l=0,a=0)}return{synthetic:y,payload:{evt:r,touch:i.event.mouse!==!0,mouse:i.event.mouse===!0,position:u,direction:e,isFirst:i.event.isFirst,isFinal:n===!0,duration:Date.now()-i.event.time,distance:{x:o,y:l},offset:{x:t,y:a},delta:{x:u.left-i.event.lastX,y:u.top-i.event.lastY}}}}let $e=0;var De=ye({name:"touch-pan",beforeMount(r,{value:i,modifiers:n}){if(n.mouse!==!0&&R.has.touch!==!0)return;function u(t,a){n.mouse===!0&&a===!0?Ce(t):(n.stop===!0&&z(t),n.prevent===!0&&G(t))}const e={uid:"qvtp_"+$e++,handler:i,modifiers:n,direction:le(n),noop:be,mouseStart(t){se(t,e)&&_e(t)&&(N(e,"temp",[[document,"mousemove","move","notPassiveCapture"],[document,"mouseup","end","passiveCapture"]]),e.start(t,!0))},touchStart(t){if(se(t,e)){const a=t.target;N(e,"temp",[[a,"touchmove","move","notPassiveCapture"],[a,"touchcancel","end","passiveCapture"],[a,"touchend","end","passiveCapture"]]),e.start(t)}},start(t,a){if(R.is.firefox===!0&&Y(r,!0),e.lastEvt=t,a===!0||n.stop===!0){if(e.direction.all!==!0&&(a!==!0||e.modifiers.mouseAllDir!==!0&&e.modifiers.mousealldir!==!0)){const s=t.type.indexOf("mouse")>-1?new MouseEvent(t.type,t):new TouchEvent(t.type,t);t.defaultPrevented===!0&&G(s),t.cancelBubble===!0&&z(s),Object.assign(s,{qKeyEvent:t.qKeyEvent,qClickOutside:t.qClickOutside,qAnchorHandled:t.qAnchorHandled,qClonedBy:t.qClonedBy===void 0?[e.uid]:t.qClonedBy.concat(e.uid)}),e.initialEvent={target:t.target,event:s}}z(t)}const{left:o,top:l}=W(t);e.event={x:o,y:l,time:Date.now(),mouse:a===!0,detected:!1,isFirst:!0,isFinal:!1,lastX:o,lastY:l}},move(t){if(e.event===void 0)return;const a=W(t),o=a.left-e.event.x,l=a.top-e.event.y;if(o===0&&l===0)return;e.lastEvt=t;const s=e.event.mouse===!0,y=()=>{u(t,s);let v;n.preserveCursor!==!0&&n.preservecursor!==!0&&(v=document.documentElement.style.cursor||"",document.documentElement.style.cursor="grabbing"),s===!0&&document.body.classList.add("no-pointer-events--children"),document.body.classList.add("non-selectable"),Be(),e.styleCleanup=h=>{if(e.styleCleanup=void 0,v!==void 0&&(document.documentElement.style.cursor=v),document.body.classList.remove("non-selectable"),s===!0){const _=()=>{document.body.classList.remove("no-pointer-events--children")};h!==void 0?setTimeout(()=>{_(),h()},50):_()}else h!==void 0&&h()}};if(e.event.detected===!0){e.event.isFirst!==!0&&u(t,e.event.mouse);const{payload:v,synthetic:h}=U(t,e,!1);v!==void 0&&(e.handler(v)===!1?e.end(t):(e.styleCleanup===void 0&&e.event.isFirst===!0&&y(),e.event.lastX=v.position.left,e.event.lastY=v.position.top,e.event.lastDir=h===!0?void 0:v.direction,e.event.isFirst=!1));return}if(e.direction.all===!0||s===!0&&(e.modifiers.mouseAllDir===!0||e.modifiers.mousealldir===!0)){y(),e.event.detected=!0,e.move(t);return}const c=Math.abs(o),f=Math.abs(l);c!==f&&(e.direction.horizontal===!0&&c>f||e.direction.vertical===!0&&c<f||e.direction.up===!0&&c<f&&l<0||e.direction.down===!0&&c<f&&l>0||e.direction.left===!0&&c>f&&o<0||e.direction.right===!0&&c>f&&o>0?(e.event.detected=!0,e.move(t)):e.end(t,!0))},end(t,a){if(e.event!==void 0){if(Q(e,"temp"),R.is.firefox===!0&&Y(r,!1),a===!0)e.styleCleanup!==void 0&&e.styleCleanup(),e.event.detected!==!0&&e.initialEvent!==void 0&&e.initialEvent.target.dispatchEvent(e.initialEvent.event);else if(e.event.detected===!0){e.event.isFirst===!0&&e.handler(U(t===void 0?e.lastEvt:t,e).payload);const{payload:o}=U(t===void 0?e.lastEvt:t,e,!0),l=()=>{e.handler(o)};e.styleCleanup!==void 0?e.styleCleanup(l):l()}e.event=void 0,e.initialEvent=void 0,e.lastEvt=void 0}}};if(r.__qtouchpan=e,n.mouse===!0){const t=n.mouseCapture===!0||n.mousecapture===!0?"Capture":"";N(e,"main",[[r,"mousedown","mouseStart",`passive${t}`]])}R.has.touch===!0&&N(e,"main",[[r,"touchstart","touchStart",`passive${n.capture===!0?"Capture":""}`],[r,"touchmove","noop","notPassiveCapture"]])},updated(r,i){const n=r.__qtouchpan;n!==void 0&&(i.oldValue!==i.value&&(typeof value!="function"&&n.end(),n.handler=i.value),n.direction=le(i.modifiers))},beforeUnmount(r){const i=r.__qtouchpan;i!==void 0&&(i.event!==void 0&&i.end(),Q(i,"main"),Q(i,"temp"),R.is.firefox===!0&&Y(r,!1),i.styleCleanup!==void 0&&i.styleCleanup(),delete r.__qtouchpan)}});const P=40,K=20;var Fe=re({name:"QPullToRefresh",props:{color:String,bgColor:String,icon:String,noMouse:Boolean,disable:Boolean,scrollTarget:{default:void 0}},emits:["refresh"],setup(r,{slots:i,emit:n}){const{proxy:u}=de(),{$q:e}=u,t=p("pull"),a=p(0),o=p(!1),l=p(-P),s=p(!1),y=p({}),c=L(()=>({opacity:a.value,transform:`translateY(${l.value}px) rotate(${a.value*360}deg)`})),f=L(()=>"q-pull-to-refresh__puller row flex-center"+(s.value===!0?" q-pull-to-refresh__puller--animating":"")+(r.bgColor!==void 0?` bg-${r.bgColor}`:""));function v(g){if(g.isFinal===!0){o.value===!0&&(o.value=!1,t.value==="pulled"?(t.value="refreshing",C({pos:K}),D()):t.value==="pull"&&C({pos:-P,ratio:0}));return}if(s.value===!0||t.value==="refreshing")return!1;if(g.isFirst===!0){if(O(F)!==0||g.direction!=="down")return o.value===!0&&(o.value=!1,t.value="pull",C({pos:-P,ratio:0})),!1;o.value=!0;const{top:w,left:H}=k.getBoundingClientRect();y.value={top:w+"px",left:H+"px",width:window.getComputedStyle(k).getPropertyValue("width")}}G(g.evt);const d=Math.min(140,Math.max(0,g.distance.y));l.value=d-P,a.value=qe(d/(K+P),0,1);const m=l.value>K?"pulled":"pull";t.value!==m&&(t.value=m)}const h=L(()=>{const g={down:!0};return r.noMouse!==!0&&(g.mouse=!0),[[De,v,void 0,g]]}),_=L(()=>`q-pull-to-refresh__content${o.value===!0?" no-pointer-events":""}`);function D(){n("refresh",()=>{C({pos:-P,ratio:0},()=>{t.value="pull"})})}let k,F,b=null;function C({pos:g,ratio:d},m){s.value=!0,l.value=g,d!==void 0&&(a.value=d),b!==null&&clearTimeout(b),b=setTimeout(()=>{b=null,s.value=!1,m&&m()},300)}function E(){F=ce(k,r.scrollTarget)}return B(()=>r.scrollTarget,E),ie(()=>{k=u.$el,E()}),ne(()=>{b!==null&&clearTimeout(b)}),Object.assign(u,{trigger:D,updateScrollTarget:E}),()=>{const g=[x("div",{class:_.value},ue(i.default)),x("div",{class:"q-pull-to-refresh__puller-container fixed row flex-center no-pointer-events z-top",style:y.value},[x("div",{class:f.value,style:c.value},[t.value!=="refreshing"?x(Se,{name:r.icon||e.iconSet.pullToRefresh.icon,color:r.color,size:"32px"}):x(Ee,{size:"24px",color:r.color})])])];return we("div",{class:"q-pull-to-refresh"},g,"main",r.disable===!1,()=>h.value)}}});const Re={class:"row justify-center q-my-md"},Ae=["onClick"],Ie=["alt"],Ne=["alt"],Oe={class:"text-caption text-grey q-mt-md text-center"},He=$("br",null,null,-1),Ve={key:1,class:"row justify-center q-my-md text-caption text-grey"},Ye=$("div",{class:"text-center q-pt-lg"},[$("img",{src:fe,width:"60"})],-1),ze={key:0,class:"row justify-center q-mb-md no-more"},Ge={__name:"InfiniteScroll",props:{disable:{type:Boolean},list:{type:[Array],require:!0,default(){return[]}},listClass:{type:String,default:""},load:{type:Function,require:!0,default(){return Promise.resolve([])}},empty:{type:String,default:"\u6682\u65E0\u6570\u636E"},noMore:{type:String,default:"\u6CA1\u6709\u66F4\u591A\u4E86"}},setup(r,{expose:i}){const n=r,u=p(!1),e=p(null),t=p(null);ae(()=>{u.value=!1}),oe(()=>{u.value=!0});const a=p(!1),o=p("");function l(c){a.value=!1,c&&c(),e.value&&(e.value.reset(),e.value.resume(),e.value.trigger())}function s(){e.value&&(e.value.resume(),e.value.trigger())}function y(c,f){if(o.value="",a.value){f&&f(!0);return}n.load(c).then(v=>{a.value=v,f&&f(v)}).catch(v=>{o.value={code:v.code,message:v.message},f&&f(!0)})}return i({refresh:l,reload:s}),(c,f)=>(S(),Te(Fe,{class:"vlist-wrapper",ref_key:"refreshRef",ref:t,onRefresh:l,color:"red","bg-color":"white"},{default:X(()=>[ee(Le,{ref_key:"scrollRef",ref:e,disable:n.disable||u.value,onLoad:y,debounce:300,offset:250},{loading:X(()=>[$("div",Re,[ee(me,{color:"grey",size:"24px"})])]),default:X(()=>[A(c.$slots,"prepend"),$("div",{class:Me(r.listClass)},[(S(!0),q(ke,null,xe(n.list,(v,h)=>A(c.$slots,"default",{key:h,item:v,index:h})),128))],2),o.value&&!n.list.length?(S(),q("div",{key:0,class:"q-pt-lg column items-center",onClick:Pe(s,["stop"])},[o.value.code==-1?(S(),q("img",{key:0,src:"statics/networkErrorimg.png",alt:o.value.message,width:"100"},null,8,Ie)):(S(),q("img",{key:1,src:fe,alt:o.value.message,width:"60"},null,8,Ne)),$("span",Oe,[j(M(o.value.message),1),He,j(" "+M(o.value.code==-1?"\u70B9\u51FB\u91CD\u65B0\u52A0\u8F7D":""),1)])],8,Ae)):a.value&&n.list.length||o.value?(S(),q("div",Ve,[o.value?(S(),q("span",{key:0,onClick:s},M(o.value.message)+" "+M(o.value.code==-1?"\uFF0C\u70B9\u51FB\u91CD\u65B0\u52A0\u8F7D":""),1)):A(c.$slots,"noMore",{key:1},()=>[j(M(n.noMore),1)])])):a.value&&!n.list.length?A(c.$slots,"empty",{key:2},()=>[Ye,n.empty?(S(),q("div",ze,M(n.empty),1)):te("",!0)]):te("",!0),A(c.$slots,"append")]),_:3},8,["disable"])]),_:3},512))}};export{De as T,Ge as _};
|