index-5807759e.js 1.7 KB

1
  1. import{j as E,ao as w,n as C,v as L,d as B,i as g,aD as R,w as m,_ as N,o as _,ak as y,g as r,y as D,Y as b,aE as j,a7 as F,ap as H,D as I}from"./index-1d4a9afa.js";import{u as M}from"./use-tab-status-a36febbc.js";const[U,o,V]=E("list"),Y={error:Boolean,offset:w(300),loading:Boolean,disabled:Boolean,finished:Boolean,errorText:String,direction:C("down"),loadingText:String,finishedText:String,immediateCheck:L};var q=B({name:U,props:Y,emits:["load","update:error","update:loading"],setup(e,{emit:c,slots:a}){const d=g(e.loading),u=g(),h=g(),s=M(),v=R(u),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||j(u))return;let f=!1;const x=b(h);t==="up"?f=i.top-x.top<=l:f=x.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(F,{class:o("loading-icon")},{default:()=>[e.loadingText||V("loading")]})])};return m(()=>[e.loading,e.finished,e.error],n),s&&m(s,t=>{t&&n()}),N(()=>{d.value=e.loading}),_(()=>{e.immediateCheck&&n()}),H({check:n}),y("scroll",n,{target:v,passive:!0}),()=>{var t;const l=(t=a.default)==null?void 0:t.call(a),i=r("div",{ref:h,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 G=I(q);export{G as L};