1 |
- import{c as L,b as w,m as C,t as E,d as B,r as h,by as R,w as x,bz as y,y as N,Z as _,_ as z,a as r,z as A,$ as b,bA as F,L as H,k as I}from"./index-869d77fb.js";import{u as M}from"./use-tab-status-0ed30c24.js";const[U,o,V]=L("list"),Z={error:Boolean,offset:w(300),loading:Boolean,disabled:Boolean,finished:Boolean,errorText:String,direction:C("down"),loadingText:String,finishedText:String,immediateCheck:E};var $=B({name:U,props:Z,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()}),y(()=>{d.value=e.loading}),N(()=>{e.immediateCheck&&n()}),_({check:n}),z("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 D=I($);export{D as L};
|