index.ec643df3.js 1.7 KB

1
  1. import{E,ab as C,a0 as L,H as w,d as R,U as h,ac as B,a3 as m,aU as N,V as U,ak as H,af as V,i as r,X as _,Y as T,ag as y,aS as F,O as I}from"./index.7994470a.js";import{u as M}from"./use-tab-status.00d7316c.js";const[O,o,X]=E("list"),Y={error:Boolean,offset:C(300),loading:Boolean,finished:Boolean,errorText:String,direction:L("down"),loadingText:String,finishedText:String,immediateCheck:w};var j=R({name:O,props:Y,emits:["load","update:error","update:loading"],setup(e,{emit:c,slots:a}){const d=h(!1),f=h(),g=h(),s=M(),x=B(f),n=()=>{_(()=>{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||y(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])}},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)return r("div",{class:o("loading")},[a.loading?a.loading():r(F,{class:o("loading-icon")},{default:()=>[e.loadingText||X("loading")]})])};return m(()=>[e.loading,e.finished,e.error],n),s&&m(s,t=>{t&&n()}),N(()=>{d.value=e.loading}),U(()=>{e.immediateCheck&&n()}),H({check:n}),V("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,S(),b(),P(),e.direction==="up"?l:i])}}});const A=I(j);export{A as L};