index.f45751d0.js 1.7 KB

1
  1. import{A as C,aa as E,$ as L,G as w,d as N,S as h,ab as R,a2 as m,aT as B,U as j,aj as U,ae as _,j as r,W as y,X as T,af as A,aS as F,N as G}from"./index.cf487d9e.js";import{u as H}from"./use-tab-status.56c677c5.js";const[I,o,M]=C("list"),V={error:Boolean,offset:E(300),loading:Boolean,finished:Boolean,errorText:String,direction:L("down"),loadingText:String,finishedText:String,immediateCheck:w};var W=N({name:I,props:V,emits:["load","update:error","update:loading"],setup(e,{emit:c,slots:a}){const d=h(!1),f=h(),g=h(),s=H(),x=R(f),n=()=>{y(()=>{if(d.value||e.finished||e.error||(s==null?void 0:s.value)===!1)return;const{offset:t,direction:l}=e,i=T(x);if(!i.height||A(f))return;let u=!1;const v=T(g);l==="up"?u=i.top-v.top<=t:u=v.bottom-i.bottom<=t,u&&(d.value=!0,c("update:loading",!0),c("load"))})},b=()=>{if(e.finished){const t=a.finished?a.finished():e.finishedText;if(t)return r("div",{class:o("finished-text")},[t])}},S=()=>{c("update:error",!1),n()},k=()=>{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:S},[t])}},P=()=>{if(d.value&&!e.finished)return r("div",{class:o("loading")},[a.loading?a.loading():r(F,{class:o("loading-icon")},{default:()=>[e.loadingText||M("loading")]})])};return m(()=>[e.loading,e.finished,e.error],n),s&&m(s,t=>{t&&n()}),B(()=>{d.value=e.loading}),j(()=>{e.immediateCheck&&n()}),U({check:n}),_("scroll",n,{target:x}),()=>{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:f,role:"feed",class:o(),"aria-busy":d.value},[e.direction==="down"?l:i,P(),b(),k(),e.direction==="up"?l:i])}}});const q=G(W);export{q as L};