1 |
- import{c as L,b as w,m as B,t as C,d as E,r as h,bz as R,w as x,bA as N,y,X as z,Y as _,a as r,z as A,Z as b,bB as F,L as H,k as I}from"./index-74aaacd7.js";import{u as M}from"./use-tab-status-3202cba9.js";const[U,o,V]=L("list"),X={error:Boolean,offset:w(300),loading:Boolean,disabled:Boolean,finished:Boolean,errorText:String,direction:B("down"),loadingText:String,finishedText:String,immediateCheck:C};var Y=E({name:U,props:X,emits:["load","update:error","update:loading"],setup(e,{emit:c,slots:a}){const d=h(e.loading),u=h(),g=h(),s=M(),m=R(u),n=()=>{A(()=>{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(m);if(!i.height||F(u))return;let f=!1;const v=b(g);t==="up"?f=i.top-v.top<=l:f=v.bottom-i.bottom<=l,f&&(d.value=!0,c("update:loading",!0),c("load"))})},T=()=>{if(e.finished){const t=a.finished?a.finished():e.finishedText;if(t)return r("div",{class:o("finished-text")},[t])}},k=()=>{c("update:error",!1),n()},P=()=>{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:k},[t])}},S=()=>{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||V("loading")]})])};return x(()=>[e.loading,e.finished,e.error],n),s&&x(s,t=>{t&&n()}),N(()=>{d.value=e.loading}),y(()=>{e.immediateCheck&&n()}),z({check:n}),_("scroll",n,{target:m,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,S(),T(),P(),e.direction==="up"?l:i])}}});const q=I(Y);export{q as L};
|