index.9ef28852.js 1.8 KB

1
  1. import{t as w,w as C,u as E,v as R,d as B,R as h,ap as N,y as _,Z as x,az as y,$ as j,W as z,a0 as A,c as r,_ as D,an as b,aA as F,L as H,D as I}from"./index.5f7ffb46.js";import{u as M}from"./use-tab-status.69b57a37.js";const[O,o,U]=w("list"),V={error:Boolean,offset:C(300),loading:Boolean,disabled:Boolean,finished:Boolean,scroller:Object,errorText:String,direction:E("down"),loadingText:String,finishedText:String,immediateCheck:R};var W=B({name:O,props:V,emits:["load","update:error","update:loading"],setup(e,{emit:c,slots:a}){const d=h(e.loading),u=h(),g=h(),s=M(),T=N(u),v=_(()=>e.scroller||T.value),n=()=>{D(()=>{if(d.value||e.finished||e.disabled||e.error||(s==null?void 0:s.value)===!1)return;const{direction:t}=e,l=+e.offset,i=b(v);if(!i.height||F(u))return;let f=!1;const m=b(g);t==="up"?f=i.top-m.top<=l:f=m.bottom-i.bottom<=l,f&&(d.value=!0,c("update:loading",!0),c("load"))})},k=()=>{if(e.finished){const t=a.finished?a.finished():e.finishedText;if(t)return r("div",{class:o("finished-text")},[t])}},P=()=>{c("update:error",!1),n()},S=()=>{if(e.error){const t=a.error?a.error():e.errorText;if(t)return r("div",{role:"button",class:o("error-text"),tabindex:0,onClick:P},[t])}},L=()=>{if(d.value&&!e.finished&&!e.disabled)return r("div",{class:o("loading")},[a.loading?a.loading():r(H,{class:o("loading-icon")},{default:()=>[e.loadingText||U("loading")]})])};return x(()=>[e.loading,e.finished,e.error],n),s&&x(s,t=>{t&&n()}),y(()=>{d.value=e.loading}),j(()=>{e.immediateCheck&&n()}),z({check:n}),A("scroll",n,{target:v,passive:!0}),()=>{var t;const l=(t=a.default)==null?void 0:t.call(a),i=r("div",{ref:g,class:o("placeholder")},null);return r("div",{ref:u,role:"feed",class:o(),"aria-busy":d.value},[e.direction==="down"?l:i,L(),k(),S(),e.direction==="up"?l:i])}}});const q=I(W);export{q as L};