@wyxos/vibe 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.cjs +1 -1
- package/lib/index.js +331 -313
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),ze={mode:"default",pageSize:20,backfillRequestDelayMs:2e3,page:1,itemWidth:300,prefetchThresholdPx:200,gapX:16,gapY:16,headerHeight:0,footerHeight:0,overscanPx:600};function Ge(l,y){return!l||l<=0||!y||y<=0?1:Math.max(1,Math.floor(l/y))}function Ke(l,y,B,o=0){if(!l||l<=0||!y||y<=0)return B;const i=typeof o=="number"&&o>0?o:0,b=Math.max(0,y-1)*i,w=l-b;return!w||w<=0?B:w/y}function Je(l,y){const B=l?.width,o=l?.height;return typeof B=="number"&&typeof o=="number"&&B>0&&o>0?o/B*y:y}function He(l){return Number.isFinite(l)&&l>0?Math.floor(l):1}function fe(l){return Number.isFinite(l)&&l>0?Math.floor(l):0}function Qe(l){async function y(o){const i=fe(o);if(i<=0)return;l.stats.value={...l.stats.value,cooldownMsTotal:i,cooldownMsRemaining:i};const b=Date.now(),w=100;await new Promise(h=>{const m=setInterval(()=>{const g=Date.now()-b,k=Math.max(0,i-g);l.stats.value={...l.stats.value,cooldownMsTotal:i,cooldownMsRemaining:k},k<=0&&(clearInterval(m),h())},w)})}async function B(o){const i=He(l.getPageSize()),b=l.isEnabled(),w=fe(l.getRequestDelayMs()),h=[];let m=0;l.buffer.value.length&&(m=l.buffer.value.length,h.push(...l.buffer.value),l.buffer.value=[]),l.stats.value={...l.stats.value,enabled:b,isBackfillActive:!1,isRequestInFlight:!1,requestPage:null,cooldownMsTotal:w,cooldownMsRemaining:0,progress:{collected:0,target:0},pageSize:i,bufferSize:0};const g=[];let k=o,F=0,I=!1;for(;h.length<i&&k!=null;){const N=k;I&&(l.stats.value={...l.stats.value,enabled:b,isBackfillActive:!0,isRequestInFlight:!0,requestPage:N,progress:{collected:Math.min(h.length,i),target:i},cooldownMsTotal:w,cooldownMsRemaining:0,pageSize:i});const x=await l.getContent(N);g.push(N),I&&(l.stats.value={...l.stats.value,enabled:b,isBackfillActive:!0,isRequestInFlight:!1,requestPage:null}),F+=x.items.length,l.markEnterFromLeft(x.items),h.push(...x.items),k=x.nextPage,!I&&h.length<i&&k!=null?(I=!0,l.stats.value={...l.stats.value,enabled:b,isBackfillActive:!0,isRequestInFlight:!1,requestPage:null,progress:{collected:Math.min(h.length,i),target:i},cooldownMsTotal:w,cooldownMsRemaining:0,pageSize:i}):I&&(l.stats.value={...l.stats.value,enabled:b,isBackfillActive:!0,progress:{collected:Math.min(h.length,i),target:i}}),I&&h.length<i&&k!=null&&await y(w)}const E=h.slice(0,i),S=h.slice(i);return l.buffer.value=S,l.stats.value={...l.stats.value,enabled:b,isBackfillActive:!1,isRequestInFlight:!1,requestPage:null,progress:{collected:0,target:0},cooldownMsTotal:w,cooldownMsRemaining:0,pageSize:i,bufferSize:S.length,lastBatch:{startPage:o,pages:g,usedFromBuffer:m,fetchedFromNetwork:F,collectedTotal:h.length,emitted:E.length,carried:S.length},totals:{pagesFetched:l.stats.value.totals.pagesFetched+g.length,itemsFetchedFromNetwork:l.stats.value.totals.itemsFetchedFromNetwork+F}},{batchItems:E,pages:g,nextPage:k}}return{loadBackfillBatch:B}}function Ze(l){const y=l.columnCount,B=l.columnWidth,o=l.gapX,i=l.gapY,b=l.headerHeight,w=l.footerHeight,h=l.bucketPx,m=Array.from({length:y},()=>0),g=new Array(l.items.length),k=new Array(l.items.length),F=new Map,I=new Map;let E=0;for(let S=0;S<l.items.length;S+=1){const N=l.items[S];N?.id&&I.set(N.id,S);let x=0;for(let M=1;M<m.length;M+=1)m[M]<m[x]&&(x=M);const z=x*(B+o),H=m[x],C=Je(N,B)+b+w;g[S]={x:z,y:H},k[S]=C,m[x]=H+C+i,E=Math.max(E,H+C);const G=Math.floor(H/h),K=Math.floor((H+C)/h);for(let M=G;M<=K;M+=1){const A=F.get(M);A?A.push(S):F.set(M,[S])}}return{positions:g,heights:k,buckets:F,contentHeight:E,indexById:I}}function et(l){const y=l.itemCount;if(!y)return[];if(l.viewportHeight<=0)return Array.from({length:y},(m,g)=>g);const B=Math.max(0,l.scrollTop-l.overscanPx),o=l.scrollTop+l.viewportHeight+l.overscanPx,i=Math.floor(B/l.bucketPx),b=Math.floor(o/l.bucketPx),w=new Set;for(let m=i;m<=b;m+=1){const g=l.buckets.get(m);if(g)for(const k of g)w.add(k)}const h=Array.from(w);return h.sort((m,g)=>m-g),h}const tt={key:0,class:"flex h-full items-center justify-center"},nt={key:1,class:"text-sm font-medium text-red-700"},lt=["src","width","height","alt"],at=["poster"],ot=["src"],st=["src","width","height","alt"],rt=["poster"],it=["src"],ct={class:"mt-4 pb-2 text-center text-xs text-slate-600"},ut={key:0,class:"inline-flex items-center justify-center gap-2"},ft={key:1},dt={key:2},mt=200,Ne=600,U=300,Ce=e.defineComponent({inheritAttrs:!1,__name:"Masonry",props:e.mergeDefaults({getContent:{},mode:{},pageSize:{},backfillRequestDelayMs:{},items:{},page:{},itemWidth:{},prefetchThresholdPx:{},gapX:{},gapY:{},headerHeight:{},footerHeight:{},overscanPx:{}},ze),emits:["update:items"],setup(l,{expose:y,emit:B}){const o=l,i=B,b=e.useAttrs(),w=e.useSlots(),h=e.computed(()=>{const{class:t,...a}=b;return a}),m=e.ref(null),g=e.ref(0),k=e.ref(0),F=e.ref(0);let I;const E=e.computed(()=>o.gapX),S=e.computed(()=>o.gapY);function N(t){if(!t)return 0;const a=Math.max(0,E.value);return Math.max(0,t.clientWidth-a)}const x=e.computed(()=>o.headerHeight),z=e.computed(()=>o.footerHeight),H=e.computed(()=>!!w.itemHeader),C=e.computed(()=>!!w.itemFooter),G=e.computed(()=>{if(x.value>0)return{height:`${x.value}px`}}),K=e.computed(()=>{if(z.value>0)return{height:`${z.value}px`}}),M=e.ref([]),A=e.ref([]),de=e.ref(new Map),me=e.ref(0),J=e.ref(new Map),q=e.ref(new Set),O=e.ref(new Set),ee=new Set,te=e.ref(new Map),R=e.ref(new Set),V=e.ref([]);function Re(t){const a=te.value.get(t);return a||{dx:0,dy:0}}function Ve(t){return O.value.has(t)||R.value.has(t)?`transform ${U}ms ease-out`:void 0}function _e(t){const n=r.value[t]?.id,s=M.value[t]??{x:0,y:0},c=A.value[t]??0,v=c>0?c:j.value,p=s.x,d=n&&q.value.has(n)?s.y-v:s.y,f=n?Re(n):{dx:0,dy:0};return`translate3d(${p+f.dx}px,${d+f.dy}px,0)`}function L(t){(typeof requestAnimationFrame=="function"?requestAnimationFrame:n=>setTimeout(()=>n(0),0))(()=>t())}function Ae(t){L(()=>L(t))}function ne(t){if(!Array.isArray(t)||t.length===0)return;const a=new Set(q.value);let n=!1;for(const s of t){const c=s?.id;c&&(a.has(c)||(a.add(c),n=!0))}n&&(q.value=a)}function ve(){const t=new Map;for(const a of ce.value){const s=r.value[a]?.id;if(!s)continue;const c=M.value[a];c&&t.set(s,{x:c.x,y:c.y})}return t}function he(t,a){if(!t.size)return;const n=new Map,s=[];for(const[v,p]of t.entries()){if(a?.has(v))continue;const d=J.value.get(v);if(d==null)continue;const f=M.value[d];if(!f)continue;const u=p.x-f.x,P=p.y-f.y;(u||P)&&(n.set(v,{dx:u,dy:P}),s.push(v))}if(!n.size)return;te.value=n;const c=new Set(R.value);for(const v of s)c.delete(v);R.value=c,L(()=>{R.value=new Set([...R.value,...s]),L(()=>{te.value=new Map})}),setTimeout(()=>{const v=new Set(R.value);for(const p of s)v.delete(p);R.value=v},U)}const Q=e.ref(!0),X=e.ref(!1),D=e.ref(""),_=e.ref([]),ge=e.ref([]),le=e.ref([]),T=e.ref(o.page),ae=e.ref([]);let oe=0;function $(t){for(const a of t)!a||typeof a!="object"||a.id&&a.originalIndex==null&&(a.originalIndex=oe,oe+=1)}const Y=new Map,se=[];function Z(t){return typeof t=="number"&&Number.isFinite(t)}function qe(t,a){if(!a.length)return t;const n=new Set;for(const p of t){const d=p?.id;d&&n.add(d)}const s=[];for(const p of a){const d=p?.id;d&&(n.has(d)||(s.push(p),n.add(d)))}if(!s.length)return t;const c=s.slice().sort((p,d)=>{const f=Z(p.originalIndex)?p.originalIndex:Number.POSITIVE_INFINITY,u=Z(d.originalIndex)?d.originalIndex:Number.POSITIVE_INFINITY;return f-u}),v=t.slice();for(const p of c){const d=p.originalIndex;if(!Z(d)){v.push(p);continue}let f=0,u=v.length;for(;f<u;){const P=f+u>>1,W=v[P]?.originalIndex;(Z(W)?W:Number.POSITIVE_INFINITY)<=d?f=P+1:u=P}v.splice(f,0,p)}return v}async function pe(t){if(!t.length)return;ne(t);const a=ve();r.value=qe(r.value,t),await e.nextTick(),he(a)}async function ye(t){const n=(Array.isArray(t)?t:[t]).map(xe).filter(Boolean);if(!n.length)return;const s=[];for(const c of n){const v=Y.get(c);v&&s.push(v)}if(s.length){await pe(s);for(const c of s)c?.id&&Y.delete(c.id)}}async function we(){const t=se.pop();if(!t?.length)return;const a=[];for(const n of t){const s=Y.get(n);s&&a.push(s)}if(a.length){await pe(a);for(const n of a)n?.id&&Y.delete(n.id)}}async function Le(t){return ye(t)}async function De(){return we()}const re=e.shallowRef({enabled:!1,isBackfillActive:!1,isRequestInFlight:!1,requestPage:null,progress:{collected:0,target:0},cooldownMsRemaining:0,cooldownMsTotal:2e3,pageSize:20,bufferSize:0,lastBatch:null,totals:{pagesFetched:0,itemsFetchedFromNetwork:0}}),ke=Qe({getContent:t=>o.getContent(t),markEnterFromLeft:ne,buffer:ae,stats:re,isEnabled:()=>o.mode==="backfill",getPageSize:()=>o.pageSize,getRequestDelayMs:()=>o.backfillRequestDelayMs}),ie=e.computed(()=>o.items!==void 0);e.watch(()=>o.items,t=>{ie.value&&(le.value=Array.isArray(t)?t:[])},{immediate:!0});const r=e.computed({get(){return ie.value?le.value:ge.value},set(t){ie.value?(le.value=t,i("update:items",t)):ge.value=t}});async function be(t){const a=await o.getContent(t);return $(a.items),ne(a.items),{items:a.items,nextPage:a.nextPage}}function xe(t){return t?typeof t=="string"?t:t?.id:null}async function Be(t){const n=(Array.isArray(t)?t:[t]).map(xe).filter(Boolean);if(!n.length)return;const s=new Set(n),c=[];for(const f of s){const u=J.value.get(f);if(u==null)continue;const P=r.value[u];P&&(Y.set(f,P),c.push(f))}c.length&&se.push(c);const v=ve(),p=j.value,d=[];for(const f of s){const u=J.value.get(f);if(u==null)continue;const P=r.value[u];if(!P)continue;const W=M.value[u]??{x:0,y:0},Te=A.value[u]??p;d.push({id:f,item:P,fromX:W.x,fromY:W.y,width:p,height:Te,leaving:!0})}if(d.length&&(V.value=[...V.value,...d]),r.value=r.value.filter(f=>{const u=f?.id;return!u||!s.has(u)}),await e.nextTick(),he(v,s),d.length){const f=new Set(d.map(u=>u.id));L(()=>{V.value=V.value.map(u=>f.has(u.id)?{...u,leaving:!1}:u),setTimeout(()=>{V.value=V.value.filter(u=>!f.has(u.id))},U)})}}async function Se(t){return Be(t)}y({remove:Be,restore:Le,undo:De,restoreRemoved:ye,undoLastRemoval:we,backfillStats:re});function Me(){const t=Ze({items:r.value,columnCount:ue.value,columnWidth:j.value,gapX:E.value,gapY:S.value,headerHeight:x.value,footerHeight:z.value,bucketPx:Ne});M.value=t.positions,A.value=t.heights,de.value=t.buckets,me.value=t.contentHeight,J.value=t.indexById}const Ye=e.computed(()=>Math.max(me.value,k.value)+mt),ce=e.computed(()=>et({itemCount:r.value.length,viewportHeight:k.value,scrollTop:F.value,overscanPx:o.overscanPx,bucketPx:Ne,buckets:de.value}));e.watch(ce,t=>{if(!t?.length)return;const a=[];for(const n of t){const s=r.value[n]?.id;s&&q.value.has(s)&&(ee.has(s)||(ee.add(s),a.push(s)))}a.length&&(L(()=>{const n=new Set(O.value);for(const s of a)n.add(s);O.value=n}),Ae(()=>{const n=new Set(q.value);for(const s of a)n.delete(s);q.value=n,setTimeout(()=>{const s=new Set(O.value);for(const c of a)s.delete(c),ee.delete(c);O.value=s},U)}))},{flush:"post"});async function Oe(){if(!(Q.value||X.value)&&!(o.mode!=="backfill"&&T.value==null)&&!(o.mode==="backfill"&&T.value==null&&ae.value.length===0))try{if(X.value=!0,D.value="",o.mode==="backfill"){const n=await ke.loadBackfillBatch(T.value);n.pages.length&&(_.value=[..._.value,...n.pages]),$(n.batchItems),r.value=[...r.value,...n.batchItems],T.value=n.nextPage;return}const t=T.value;if(t==null)return;const a=await be(t);_.value=[..._.value,t],$(a.items),r.value=[...r.value,...a.items],T.value=a.nextPage}catch(t){D.value=t instanceof Error?t.message:String(t)}finally{X.value=!1}}function Xe(){const t=m.value;if(!t)return;F.value=t.scrollTop,k.value=t.clientHeight,t.scrollHeight-(t.scrollTop+t.clientHeight)<=o.prefetchThresholdPx&&Oe()}function Ie(){return m.value}function Ee(t){g.value=N(t),k.value=t.clientHeight}function $e(){typeof ResizeObserver>"u"||(I=new ResizeObserver(()=>{const t=Ie();t&&Ee(t)}))}function je(){return{enabled:o.mode==="backfill",isBackfillActive:!1,isRequestInFlight:!1,requestPage:null,progress:{collected:0,target:0},cooldownMsRemaining:0,cooldownMsTotal:fe(o.backfillRequestDelayMs),pageSize:He(o.pageSize),bufferSize:0,lastBatch:null,totals:{pagesFetched:0,itemsFetchedFromNetwork:0}}}function Pe(t){oe=0,Y.clear(),se.length=0,_.value=[],r.value=[],T.value=t,ae.value=[],re.value=je(),Q.value=!0,X.value=!1,D.value=""}async function Fe(t){try{if(o.mode==="backfill"){const a=await ke.loadBackfillBatch(t);_.value=a.pages.length?a.pages:[t],$(a.batchItems),r.value=a.batchItems,T.value=a.nextPage}else{const a=await be(t);_.value=[t],$(a.items),r.value=a.items,T.value=a.nextPage}}catch(a){D.value=a instanceof Error?a.message:String(a)}finally{Q.value=!1}}function We(){const t=Ie();t&&(Ee(t),F.value=t.scrollTop,I?.observe(t))}e.onMounted(async()=>{$e(),Pe(o.page),await Fe(o.page),await e.nextTick(),We()}),e.onUnmounted(()=>{I?.disconnect()}),e.watch(()=>o.page,async t=>{Pe(t),await Fe(t)}),e.watch(E,()=>{const t=m.value;t&&(g.value=N(t))},{immediate:!1});const ue=e.computed(()=>Ge(g.value,o.itemWidth)),j=e.computed(()=>Ke(g.value,ue.value,o.itemWidth,E.value));e.watch([ue,j,E,S,x,z],()=>{Me()},{immediate:!0}),e.watch(()=>[r.value,r.value.length],()=>Me(),{immediate:!0});const Ue=e.computed(()=>["mt-8 flex min-h-0 flex-1 flex-col rounded-2xl border border-slate-200/70 bg-white/70 p-5 shadow-sm backdrop-blur",b.class]);return(t,a)=>(e.openBlock(),e.createElementBlock("section",e.mergeProps(h.value,{class:Ue.value}),[e.createElementVNode("div",{ref_key:"scrollViewportRef",ref:m,"data-testid":"items-scroll-container",class:"mt-4 min-h-0 flex-1 overflow-auto",style:e.normalizeStyle({paddingRight:E.value+"px"}),onScroll:Xe},[Q.value?(e.openBlock(),e.createElementBlock("div",tt,a[0]||(a[0]=[e.createElementVNode("div",{class:"inline-flex items-center gap-3 text-sm text-slate-600"},[e.createElementVNode("svg",{class:"h-5 w-5 animate-spin text-slate-500",viewBox:"0 0 24 24","aria-hidden":"true"},[e.createElementVNode("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",fill:"none",stroke:"currentColor","stroke-width":"4"}),e.createElementVNode("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 0 1 8-8v4a4 4 0 0 0-4 4H4z"})]),e.createElementVNode("span",null,"Loading…")],-1)]))):D.value?(e.openBlock(),e.createElementBlock("p",nt,"Error: "+e.toDisplayString(D.value),1)):(e.openBlock(),e.createElementBlock("div",{key:2,class:"relative",style:e.normalizeStyle({height:Ye.value+"px"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(ce.value,n=>(e.openBlock(),e.createElementBlock("article",{key:r.value[n].id,"data-testid":"item-card",class:"absolute overflow-hidden rounded-xl border border-slate-200/60 bg-white shadow-sm",style:e.normalizeStyle({width:j.value+"px",transition:Ve(r.value[n].id),transform:_e(n)})},[H.value||x.value>0?(e.openBlock(),e.createElementBlock("div",{key:0,"data-testid":"item-header-container",class:"w-full",style:e.normalizeStyle(G.value)},[e.renderSlot(t.$slots,"itemHeader",{item:r.value[n],remove:()=>Se(r.value[n])})],4)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"bg-slate-100",style:e.normalizeStyle({aspectRatio:r.value[n].width+" / "+r.value[n].height})},[r.value[n].type==="image"?(e.openBlock(),e.createElementBlock("img",{key:0,class:"h-full w-full object-cover",src:r.value[n].preview,width:r.value[n].width,height:r.value[n].height,loading:"lazy",alt:r.value[n].id},null,8,lt)):(e.openBlock(),e.createElementBlock("video",{key:1,class:"h-full w-full object-cover",poster:r.value[n].preview,controls:"",preload:"metadata"},[e.createElementVNode("source",{src:r.value[n].original,type:"video/mp4"},null,8,ot)],8,at))],4),C.value||z.value>0?(e.openBlock(),e.createElementBlock("div",{key:1,"data-testid":"item-footer-container",class:"w-full",style:e.normalizeStyle(K.value)},[e.renderSlot(t.$slots,"itemFooter",{item:r.value[n],remove:()=>Se(r.value[n])})],4)):e.createCommentVNode("",!0)],4))),128)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(V.value,n=>(e.openBlock(),e.createElementBlock("article",{key:n.id+":leaving","data-testid":"item-card-leaving",class:"pointer-events-none absolute overflow-hidden rounded-xl border border-slate-200/60 bg-white shadow-sm",style:e.normalizeStyle({width:n.width+"px",transition:"transform "+U+"ms ease-out",transform:n.leaving?"translate3d("+n.fromX+"px,"+n.fromY+"px,0)":"translate3d("+n.fromX+"px,"+(n.fromY-n.height)+"px,0)"})},[H.value||x.value>0?(e.openBlock(),e.createElementBlock("div",{key:0,"data-testid":"item-header-container",class:"w-full",style:e.normalizeStyle(G.value)},[e.renderSlot(t.$slots,"itemHeader",{item:n.item,remove:()=>{}})],4)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"bg-slate-100",style:e.normalizeStyle({aspectRatio:n.item.width+" / "+n.item.height})},[n.item.type==="image"?(e.openBlock(),e.createElementBlock("img",{key:0,class:"h-full w-full object-cover",src:n.item.preview,width:n.item.width,height:n.item.height,loading:"lazy",alt:n.item.id},null,8,st)):(e.openBlock(),e.createElementBlock("video",{key:1,class:"h-full w-full object-cover",poster:n.item.preview,controls:"",preload:"metadata"},[e.createElementVNode("source",{src:n.item.original,type:"video/mp4"},null,8,it)],8,rt))],4),C.value||z.value>0?(e.openBlock(),e.createElementBlock("div",{key:1,"data-testid":"item-footer-container",class:"w-full",style:e.normalizeStyle(K.value)},[e.renderSlot(t.$slots,"itemFooter",{item:n.item,remove:()=>{}})],4)):e.createCommentVNode("",!0)],4))),128))],4)),e.createElementVNode("div",ct,[X.value?(e.openBlock(),e.createElementBlock("span",ut,a[1]||(a[1]=[e.createElementVNode("svg",{class:"h-4 w-4 animate-spin text-slate-500",viewBox:"0 0 24 24","aria-hidden":"true"},[e.createElementVNode("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",fill:"none",stroke:"currentColor","stroke-width":"4"}),e.createElementVNode("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 0 1 8-8v4a4 4 0 0 0-4 4H4z"})],-1),e.createElementVNode("span",null,"Loading more…",-1)]))):T.value==null?(e.openBlock(),e.createElementBlock("span",ft,"End of list")):(e.openBlock(),e.createElementBlock("span",dt,"Scroll to load page "+e.toDisplayString(T.value),1))])],36)],16))}}),vt={install(l){l.component("Masonry",Ce)}};exports.Masonry=Ce;exports.VibePlugin=vt;exports.masonryDefaults=ze;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("vue"),Ae={mode:"default",pageSize:20,backfillRequestDelayMs:2e3,page:1,itemWidth:300,prefetchThresholdPx:200,gapX:16,gapY:16,headerHeight:0,footerHeight:0,overscanPx:600};function Ze(l,y){return!l||l<=0||!y||y<=0?1:Math.max(1,Math.floor(l/y))}function et(l,y,B,s=0){if(!l||l<=0||!y||y<=0)return B;const c=typeof s=="number"&&s>0?s:0,b=Math.max(0,y-1)*c,w=l-b;return!w||w<=0?B:w/y}function tt(l,y){const B=l?.width,s=l?.height;return typeof B=="number"&&typeof s=="number"&&B>0&&s>0?s/B*y:y}function Ce(l){return Number.isFinite(l)&&l>0?Math.floor(l):1}function fe(l){return Number.isFinite(l)&&l>0?Math.floor(l):0}function nt(l){async function y(s){const c=fe(s);if(c<=0)return;l.stats.value={...l.stats.value,cooldownMsTotal:c,cooldownMsRemaining:c};const b=Date.now(),w=100;await new Promise(g=>{const h=setInterval(()=>{const p=Date.now()-b,k=Math.max(0,c-p);l.stats.value={...l.stats.value,cooldownMsTotal:c,cooldownMsRemaining:k},k<=0&&(clearInterval(h),g())},w)})}async function B(s){const c=Ce(l.getPageSize()),b=l.isEnabled(),w=fe(l.getRequestDelayMs()),g=[];let h=0;l.buffer.value.length&&(h=l.buffer.value.length,g.push(...l.buffer.value),l.buffer.value=[]),l.stats.value={...l.stats.value,enabled:b,isBackfillActive:!1,isRequestInFlight:!1,requestPage:null,cooldownMsTotal:w,cooldownMsRemaining:0,progress:{collected:0,target:0},pageSize:c,bufferSize:0};const p=[];let k=s,F=0,I=!1;for(;g.length<c&&k!=null;){const T=k;I&&(l.stats.value={...l.stats.value,enabled:b,isBackfillActive:!0,isRequestInFlight:!0,requestPage:T,progress:{collected:Math.min(g.length,c),target:c},cooldownMsTotal:w,cooldownMsRemaining:0,pageSize:c});const x=await l.getContent(T);p.push(T),I&&(l.stats.value={...l.stats.value,enabled:b,isBackfillActive:!0,isRequestInFlight:!1,requestPage:null}),F+=x.items.length,l.markEnterFromLeft(x.items),g.push(...x.items),k=x.nextPage,!I&&g.length<c&&k!=null?(I=!0,l.stats.value={...l.stats.value,enabled:b,isBackfillActive:!0,isRequestInFlight:!1,requestPage:null,progress:{collected:Math.min(g.length,c),target:c},cooldownMsTotal:w,cooldownMsRemaining:0,pageSize:c}):I&&(l.stats.value={...l.stats.value,enabled:b,isBackfillActive:!0,progress:{collected:Math.min(g.length,c),target:c}}),I&&g.length<c&&k!=null&&await y(w)}const E=g.slice(0,c),S=g.slice(c);return l.buffer.value=S,l.stats.value={...l.stats.value,enabled:b,isBackfillActive:!1,isRequestInFlight:!1,requestPage:null,progress:{collected:0,target:0},cooldownMsTotal:w,cooldownMsRemaining:0,pageSize:c,bufferSize:S.length,lastBatch:{startPage:s,pages:p,usedFromBuffer:h,fetchedFromNetwork:F,collectedTotal:g.length,emitted:E.length,carried:S.length},totals:{pagesFetched:l.stats.value.totals.pagesFetched+p.length,itemsFetchedFromNetwork:l.stats.value.totals.itemsFetchedFromNetwork+F}},{batchItems:E,pages:p,nextPage:k}}return{loadBackfillBatch:B}}function lt(l){const y=l.columnCount,B=l.columnWidth,s=l.gapX,c=l.gapY,b=l.headerHeight,w=l.footerHeight,g=l.bucketPx,h=Array.from({length:y},()=>0),p=new Array(l.items.length),k=new Array(l.items.length),F=new Map,I=new Map;let E=0;for(let S=0;S<l.items.length;S+=1){const T=l.items[S];T?.id&&I.set(T.id,S);let x=0;for(let M=1;M<h.length;M+=1)h[M]<h[x]&&(x=M);const z=x*(B+s),_=h[x],H=tt(T,B)+b+w;p[S]={x:z,y:_},k[S]=H,h[x]=_+H+c,E=Math.max(E,_+H);const G=Math.floor(_/g),K=Math.floor((_+H)/g);for(let M=G;M<=K;M+=1){const L=F.get(M);L?L.push(S):F.set(M,[S])}}return{positions:p,heights:k,buckets:F,contentHeight:E,indexById:I}}function ot(l){const y=l.itemCount;if(!y)return[];if(l.viewportHeight<=0)return Array.from({length:y},(h,p)=>p);const B=Math.max(0,l.scrollTop-l.overscanPx),s=l.scrollTop+l.viewportHeight+l.overscanPx,c=Math.floor(B/l.bucketPx),b=Math.floor(s/l.bucketPx),w=new Set;for(let h=c;h<=b;h+=1){const p=l.buckets.get(h);if(p)for(const k of p)w.add(k)}const g=Array.from(w);return g.sort((h,p)=>h-p),g}const at={key:0,class:"flex h-full items-center justify-center"},st={key:1,class:"text-sm font-medium text-red-700"},rt=["src","width","height","alt"],it=["poster"],ct=["src"],ut=["src","width","height","alt"],ft=["poster"],dt=["src"],mt={class:"mt-4 pb-2 text-center text-xs text-slate-600"},vt={key:0,class:"inline-flex items-center justify-center gap-2"},ht={key:1},gt={key:2},pt=200,ze=600,_e=300,He=600,Re=600,Ve=t.defineComponent({inheritAttrs:!1,__name:"Masonry",props:t.mergeDefaults({getContent:{},mode:{},pageSize:{},backfillRequestDelayMs:{},items:{},page:{},itemWidth:{},prefetchThresholdPx:{},gapX:{},gapY:{},headerHeight:{},footerHeight:{},overscanPx:{}},Ae),emits:["update:items"],setup(l,{expose:y,emit:B}){const s=l,c=B,b=t.useAttrs(),w=t.useSlots(),g=t.computed(()=>{const{class:e,...o}=b;return o}),h=t.ref(null),p=t.ref(0),k=t.ref(0),F=t.ref(0);let I;const E=t.computed(()=>s.gapX),S=t.computed(()=>s.gapY);function T(e){if(!e)return 0;const o=Math.max(0,E.value);return Math.max(0,e.clientWidth-o)}const x=t.computed(()=>s.headerHeight),z=t.computed(()=>s.footerHeight),_=t.computed(()=>!!w.itemHeader),H=t.computed(()=>!!w.itemFooter),G=t.computed(()=>{if(x.value>0)return{height:`${x.value}px`}}),K=t.computed(()=>{if(z.value>0)return{height:`${z.value}px`}}),M=t.ref([]),L=t.ref([]),de=t.ref(new Map),me=t.ref(0),J=t.ref(new Map);function ve(e){const o=typeof e=="number"&&Number.isFinite(e)?e:0;return-Math.max(0,o)}const D=t.ref(new Set),X=t.ref(new Set),ee=new Set,te=t.ref(new Map),R=t.ref(new Set),A=t.ref([]);function qe(e){const o=te.value.get(e);return o||{dx:0,dy:0}}function Le(e){if(X.value.has(e))return`transform ${He}ms ease-out`;if(R.value.has(e))return`transform ${_e}ms ease-out`}function De(e){const n=r.value[e]?.id,a=M.value[e]??{x:0,y:0},i=L.value[e]??0,v=i>0?i:W.value,m=a.x,f=n&&D.value.has(n)?ve(v):a.y,d=n?qe(n):{dx:0,dy:0};return`translate3d(${m+d.dx}px,${f+d.dy}px,0)`}function Y(e){(typeof requestAnimationFrame=="function"?requestAnimationFrame:n=>setTimeout(()=>n(0),0))(()=>e())}function Ye(e){Y(()=>Y(e))}function ne(e){if(!Array.isArray(e)||e.length===0)return;const o=new Set(D.value);let n=!1;for(const a of e){const i=a?.id;i&&(o.has(i)||(o.add(i),n=!0))}n&&(D.value=o)}function he(){const e=new Map;for(const o of ce.value){const a=r.value[o]?.id;if(!a)continue;const i=M.value[o];i&&e.set(a,{x:i.x,y:i.y})}return e}function ge(e,o){if(!e.size)return;const n=new Map,a=[];for(const[v,m]of e.entries()){if(o?.has(v))continue;const f=J.value.get(v);if(f==null)continue;const d=M.value[f];if(!d)continue;const u=m.x-d.x,P=m.y-d.y;(u||P)&&(n.set(v,{dx:u,dy:P}),a.push(v))}if(!n.size)return;te.value=n;const i=new Set(R.value);for(const v of a)i.delete(v);R.value=i,Y(()=>{R.value=new Set([...R.value,...a]),Y(()=>{te.value=new Map})}),setTimeout(()=>{const v=new Set(R.value);for(const m of a)v.delete(m);R.value=v},_e)}const Q=t.ref(!0),$=t.ref(!1),O=t.ref(""),C=t.ref([]),pe=t.ref([]),le=t.ref([]),N=t.ref(s.page),oe=t.ref([]);let ae=0;function j(e){for(const o of e)!o||typeof o!="object"||o.id&&o.originalIndex==null&&(o.originalIndex=ae,ae+=1)}const V=new Map,q=[];function Z(e){return typeof e=="number"&&Number.isFinite(e)}function Oe(e,o){if(!o.length)return e;const n=new Set;for(const m of e){const f=m?.id;f&&n.add(f)}const a=[];for(const m of o){const f=m?.id;f&&(n.has(f)||(a.push(m),n.add(f)))}if(!a.length)return e;const i=a.slice().sort((m,f)=>{const d=Z(m.originalIndex)?m.originalIndex:Number.POSITIVE_INFINITY,u=Z(f.originalIndex)?f.originalIndex:Number.POSITIVE_INFINITY;return d-u}),v=e.slice();for(const m of i){const f=m.originalIndex;if(!Z(f)){v.push(m);continue}let d=0,u=v.length;for(;d<u;){const P=d+u>>1,U=v[P]?.originalIndex;(Z(U)?U:Number.POSITIVE_INFINITY)<=f?d=P+1:u=P}v.splice(d,0,m)}return v}async function ye(e){if(!e.length)return;ne(e);const o=he();r.value=Oe(r.value,e),await t.nextTick(),ge(o)}async function we(e){const n=(Array.isArray(e)?e:[e]).map(ie).filter(Boolean);if(!n.length)return;const a=[];for(const i of n){const v=V.get(i);v&&a.push(v)}if(a.length){await ye(a);for(const i of a)i?.id&&V.delete(i.id)}}async function ke(){const e=q.pop();if(!e?.length)return;const o=[];for(const n of e){const a=V.get(n);a&&o.push(a)}if(o.length){await ye(o);for(const n of o)n?.id&&V.delete(n.id)}}async function Xe(e){return we(e)}async function $e(){return ke()}function be(e){const n=(Array.isArray(e)?e:[e]).map(ie).filter(Boolean);if(!n.length)return;const a=new Set(n);for(const i of a)V.delete(i);for(let i=q.length-1;i>=0;i-=1){const m=q[i].filter(f=>!a.has(f));m.length?q[i]=m:q.splice(i,1)}}const se=t.shallowRef({enabled:!1,isBackfillActive:!1,isRequestInFlight:!1,requestPage:null,progress:{collected:0,target:0},cooldownMsRemaining:0,cooldownMsTotal:2e3,pageSize:20,bufferSize:0,lastBatch:null,totals:{pagesFetched:0,itemsFetchedFromNetwork:0}}),xe=nt({getContent:e=>s.getContent(e),markEnterFromLeft:ne,buffer:oe,stats:se,isEnabled:()=>s.mode==="backfill",getPageSize:()=>s.pageSize,getRequestDelayMs:()=>s.backfillRequestDelayMs}),re=t.computed(()=>s.items!==void 0);t.watch(()=>s.items,e=>{re.value&&(le.value=Array.isArray(e)?e:[])},{immediate:!0});const r=t.computed({get(){return re.value?le.value:pe.value},set(e){re.value?(le.value=e,c("update:items",e)):pe.value=e}});async function Be(e){const o=await s.getContent(e);return j(o.items),ne(o.items),{items:o.items,nextPage:o.nextPage}}function ie(e){return e?typeof e=="string"?e:e?.id:null}async function Se(e){const n=(Array.isArray(e)?e:[e]).map(ie).filter(Boolean);if(!n.length)return;const a=new Set(n),i=[];for(const d of a){const u=J.value.get(d);if(u==null)continue;const P=r.value[u];P&&(V.set(d,P),i.push(d))}i.length&&q.push(i);const v=he(),m=W.value,f=[];for(const d of a){const u=J.value.get(d);if(u==null)continue;const P=r.value[u];if(!P)continue;const U=M.value[u]??{x:0,y:0},Te=L.value[u]??m;f.push({id:d,item:P,fromX:U.x,fromY:U.y,width:m,height:Te,leaving:!0})}if(f.length&&(A.value=[...A.value,...f]),r.value=r.value.filter(d=>{const u=d?.id;return!u||!a.has(u)}),await t.nextTick(),ge(v,a),f.length){const d=new Set(f.map(u=>u.id));Y(()=>{A.value=A.value.map(u=>d.has(u.id)?{...u,leaving:!1}:u),setTimeout(()=>{A.value=A.value.filter(u=>!d.has(u.id))},Re)})}}async function Me(e){return Se(e)}y({remove:Se,restore:Xe,undo:$e,forget:be,restoreRemoved:we,undoLastRemoval:ke,forgetRemoved:be,backfillStats:se});function Ie(){const e=lt({items:r.value,columnCount:ue.value,columnWidth:W.value,gapX:E.value,gapY:S.value,headerHeight:x.value,footerHeight:z.value,bucketPx:ze});M.value=e.positions,L.value=e.heights,de.value=e.buckets,me.value=e.contentHeight,J.value=e.indexById}const je=t.computed(()=>Math.max(me.value,k.value)+pt),ce=t.computed(()=>ot({itemCount:r.value.length,viewportHeight:k.value,scrollTop:F.value,overscanPx:s.overscanPx,bucketPx:ze,buckets:de.value}));t.watch(ce,e=>{if(!e?.length)return;const o=[];for(const n of e){const a=r.value[n]?.id;a&&D.value.has(a)&&(ee.has(a)||(ee.add(a),o.push(a)))}o.length&&(Y(()=>{const n=new Set(X.value);for(const a of o)n.add(a);X.value=n}),Ye(()=>{const n=new Set(D.value);for(const a of o)n.delete(a);D.value=n,setTimeout(()=>{const a=new Set(X.value);for(const i of o)a.delete(i),ee.delete(i);X.value=a},He)}))},{flush:"post"});async function We(){if(!(Q.value||$.value)&&!(s.mode!=="backfill"&&N.value==null)&&!(s.mode==="backfill"&&N.value==null&&oe.value.length===0))try{if($.value=!0,O.value="",s.mode==="backfill"){const n=await xe.loadBackfillBatch(N.value);n.pages.length&&(C.value=[...C.value,...n.pages]),j(n.batchItems),r.value=[...r.value,...n.batchItems],N.value=n.nextPage;return}const e=N.value;if(e==null)return;const o=await Be(e);C.value=[...C.value,e],j(o.items),r.value=[...r.value,...o.items],N.value=o.nextPage}catch(e){O.value=e instanceof Error?e.message:String(e)}finally{$.value=!1}}function Ue(){const e=h.value;if(!e)return;F.value=e.scrollTop,k.value=e.clientHeight,e.scrollHeight-(e.scrollTop+e.clientHeight)<=s.prefetchThresholdPx&&We()}function Ee(){return h.value}function Pe(e){p.value=T(e),k.value=e.clientHeight}function Ge(){typeof ResizeObserver>"u"||(I=new ResizeObserver(()=>{const e=Ee();e&&Pe(e)}))}function Ke(){return{enabled:s.mode==="backfill",isBackfillActive:!1,isRequestInFlight:!1,requestPage:null,progress:{collected:0,target:0},cooldownMsRemaining:0,cooldownMsTotal:fe(s.backfillRequestDelayMs),pageSize:Ce(s.pageSize),bufferSize:0,lastBatch:null,totals:{pagesFetched:0,itemsFetchedFromNetwork:0}}}function Fe(e){ae=0,V.clear(),q.length=0,C.value=[],r.value=[],N.value=e,oe.value=[],se.value=Ke(),Q.value=!0,$.value=!1,O.value=""}async function Ne(e){try{if(s.mode==="backfill"){const o=await xe.loadBackfillBatch(e);C.value=o.pages.length?o.pages:[e],j(o.batchItems),r.value=o.batchItems,N.value=o.nextPage}else{const o=await Be(e);C.value=[e],j(o.items),r.value=o.items,N.value=o.nextPage}}catch(o){O.value=o instanceof Error?o.message:String(o)}finally{Q.value=!1}}function Je(){const e=Ee();e&&(Pe(e),F.value=e.scrollTop,I?.observe(e))}t.onMounted(async()=>{Ge(),Je(),Fe(s.page),await Ne(s.page)}),t.onUnmounted(()=>{I?.disconnect()}),t.watch(()=>s.page,async e=>{Fe(e),await Ne(e)}),t.watch(E,()=>{const e=h.value;e&&(p.value=T(e))},{immediate:!1});const ue=t.computed(()=>Ze(p.value,s.itemWidth)),W=t.computed(()=>et(p.value,ue.value,s.itemWidth,E.value));t.watch([ue,W,E,S,x,z],()=>{Ie()},{immediate:!0}),t.watch(()=>[r.value,r.value.length],()=>Ie(),{immediate:!0});const Qe=t.computed(()=>["mt-8 flex min-h-0 flex-1 flex-col rounded-2xl border border-slate-200/70 bg-white/70 p-5 shadow-sm backdrop-blur",b.class]);return(e,o)=>(t.openBlock(),t.createElementBlock("section",t.mergeProps(g.value,{class:Qe.value}),[t.createElementVNode("div",{ref_key:"scrollViewportRef",ref:h,"data-testid":"items-scroll-container",class:"mt-4 min-h-0 flex-1 overflow-auto",style:t.normalizeStyle({paddingRight:E.value+"px"}),onScroll:Ue},[Q.value?(t.openBlock(),t.createElementBlock("div",at,o[0]||(o[0]=[t.createElementVNode("div",{class:"inline-flex items-center gap-3 text-sm text-slate-600"},[t.createElementVNode("svg",{class:"h-5 w-5 animate-spin text-slate-500",viewBox:"0 0 24 24","aria-hidden":"true"},[t.createElementVNode("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",fill:"none",stroke:"currentColor","stroke-width":"4"}),t.createElementVNode("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 0 1 8-8v4a4 4 0 0 0-4 4H4z"})]),t.createElementVNode("span",null,"Loading…")],-1)]))):O.value?(t.openBlock(),t.createElementBlock("p",st,"Error: "+t.toDisplayString(O.value),1)):(t.openBlock(),t.createElementBlock("div",{key:2,class:"relative",style:t.normalizeStyle({height:je.value+"px"})},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(ce.value,n=>(t.openBlock(),t.createElementBlock("article",{key:r.value[n].id,"data-testid":"item-card",class:"absolute overflow-hidden rounded-xl border border-slate-200/60 bg-white shadow-sm",style:t.normalizeStyle({width:W.value+"px",transition:Le(r.value[n].id),transform:De(n)})},[_.value||x.value>0?(t.openBlock(),t.createElementBlock("div",{key:0,"data-testid":"item-header-container",class:"w-full",style:t.normalizeStyle(G.value)},[t.renderSlot(e.$slots,"itemHeader",{item:r.value[n],remove:()=>Me(r.value[n])})],4)):t.createCommentVNode("",!0),t.createElementVNode("div",{class:"bg-slate-100",style:t.normalizeStyle({aspectRatio:r.value[n].width+" / "+r.value[n].height})},[r.value[n].type==="image"?(t.openBlock(),t.createElementBlock("img",{key:0,class:"h-full w-full object-cover",src:r.value[n].preview,width:r.value[n].width,height:r.value[n].height,loading:"lazy",alt:r.value[n].id},null,8,rt)):(t.openBlock(),t.createElementBlock("video",{key:1,class:"h-full w-full object-cover",poster:r.value[n].preview,controls:"",preload:"metadata"},[t.createElementVNode("source",{src:r.value[n].original,type:"video/mp4"},null,8,ct)],8,it))],4),H.value||z.value>0?(t.openBlock(),t.createElementBlock("div",{key:1,"data-testid":"item-footer-container",class:"w-full",style:t.normalizeStyle(K.value)},[t.renderSlot(e.$slots,"itemFooter",{item:r.value[n],remove:()=>Me(r.value[n])})],4)):t.createCommentVNode("",!0)],4))),128)),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(A.value,n=>(t.openBlock(),t.createElementBlock("article",{key:n.id+":leaving","data-testid":"item-card-leaving",class:"pointer-events-none absolute overflow-hidden rounded-xl border border-slate-200/60 bg-white shadow-sm",style:t.normalizeStyle({width:n.width+"px",transition:"transform "+Re+"ms ease-out",transform:n.leaving?"translate3d("+n.fromX+"px,"+n.fromY+"px,0)":"translate3d("+n.fromX+"px,"+ve(n.height)+"px,0)"})},[_.value||x.value>0?(t.openBlock(),t.createElementBlock("div",{key:0,"data-testid":"item-header-container",class:"w-full",style:t.normalizeStyle(G.value)},[t.renderSlot(e.$slots,"itemHeader",{item:n.item,remove:()=>{}})],4)):t.createCommentVNode("",!0),t.createElementVNode("div",{class:"bg-slate-100",style:t.normalizeStyle({aspectRatio:n.item.width+" / "+n.item.height})},[n.item.type==="image"?(t.openBlock(),t.createElementBlock("img",{key:0,class:"h-full w-full object-cover",src:n.item.preview,width:n.item.width,height:n.item.height,loading:"lazy",alt:n.item.id},null,8,ut)):(t.openBlock(),t.createElementBlock("video",{key:1,class:"h-full w-full object-cover",poster:n.item.preview,controls:"",preload:"metadata"},[t.createElementVNode("source",{src:n.item.original,type:"video/mp4"},null,8,dt)],8,ft))],4),H.value||z.value>0?(t.openBlock(),t.createElementBlock("div",{key:1,"data-testid":"item-footer-container",class:"w-full",style:t.normalizeStyle(K.value)},[t.renderSlot(e.$slots,"itemFooter",{item:n.item,remove:()=>{}})],4)):t.createCommentVNode("",!0)],4))),128))],4)),t.createElementVNode("div",mt,[$.value?(t.openBlock(),t.createElementBlock("span",vt,o[1]||(o[1]=[t.createElementVNode("svg",{class:"h-4 w-4 animate-spin text-slate-500",viewBox:"0 0 24 24","aria-hidden":"true"},[t.createElementVNode("circle",{class:"opacity-25",cx:"12",cy:"12",r:"10",fill:"none",stroke:"currentColor","stroke-width":"4"}),t.createElementVNode("path",{class:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 0 1 8-8v4a4 4 0 0 0-4 4H4z"})],-1),t.createElementVNode("span",null,"Loading more…",-1)]))):N.value==null?(t.openBlock(),t.createElementBlock("span",ht,"End of list")):(t.openBlock(),t.createElementBlock("span",gt,"Scroll to load page "+t.toDisplayString(N.value),1))])],36)],16))}}),yt={install(l){l.component("Masonry",Ve)}};exports.Masonry=Ve;exports.VibePlugin=yt;exports.masonryDefaults=Ae;
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
const
|
|
1
|
+
import { defineComponent as ut, mergeDefaults as ct, useAttrs as ft, useSlots as dt, computed as B, ref as g, shallowRef as vt, watch as G, onMounted as ht, onUnmounted as gt, createElementBlock as x, openBlock as k, mergeProps as mt, createElementVNode as T, normalizeStyle as N, toDisplayString as Ve, Fragment as Ye, renderList as De, createCommentVNode as oe, renderSlot as ie, nextTick as Oe } from "vue";
|
|
2
|
+
const pt = {
|
|
3
3
|
mode: "default",
|
|
4
4
|
pageSize: 20,
|
|
5
5
|
backfillRequestDelayMs: 2e3,
|
|
@@ -12,49 +12,49 @@ const vt = {
|
|
|
12
12
|
footerHeight: 0,
|
|
13
13
|
overscanPx: 600
|
|
14
14
|
};
|
|
15
|
-
function
|
|
15
|
+
function yt(n, y) {
|
|
16
16
|
return !n || n <= 0 || !y || y <= 0 ? 1 : Math.max(1, Math.floor(n / y));
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function wt(n, y, S, l = 0) {
|
|
19
19
|
if (!n || n <= 0 || !y || y <= 0) return S;
|
|
20
|
-
const
|
|
20
|
+
const r = typeof l == "number" && l > 0 ? l : 0, M = Math.max(0, y - 1) * r, w = n - M;
|
|
21
21
|
return !w || w <= 0 ? S : w / y;
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function bt(n, y) {
|
|
24
24
|
const S = n?.width, l = n?.height;
|
|
25
25
|
return typeof S == "number" && typeof l == "number" && S > 0 && l > 0 ? l / S * y : y;
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function Ue(n) {
|
|
28
28
|
return Number.isFinite(n) && n > 0 ? Math.floor(n) : 1;
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function we(n) {
|
|
31
31
|
return Number.isFinite(n) && n > 0 ? Math.floor(n) : 0;
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function xt(n) {
|
|
34
34
|
async function y(l) {
|
|
35
|
-
const
|
|
36
|
-
if (
|
|
35
|
+
const r = we(l);
|
|
36
|
+
if (r <= 0) return;
|
|
37
37
|
n.stats.value = {
|
|
38
38
|
...n.stats.value,
|
|
39
|
-
cooldownMsTotal:
|
|
40
|
-
cooldownMsRemaining:
|
|
39
|
+
cooldownMsTotal: r,
|
|
40
|
+
cooldownMsRemaining: r
|
|
41
41
|
};
|
|
42
42
|
const M = Date.now(), w = 100;
|
|
43
|
-
await new Promise((
|
|
44
|
-
const
|
|
45
|
-
const
|
|
43
|
+
await new Promise((m) => {
|
|
44
|
+
const h = setInterval(() => {
|
|
45
|
+
const p = Date.now() - M, b = Math.max(0, r - p);
|
|
46
46
|
n.stats.value = {
|
|
47
47
|
...n.stats.value,
|
|
48
|
-
cooldownMsTotal:
|
|
49
|
-
cooldownMsRemaining:
|
|
50
|
-
},
|
|
48
|
+
cooldownMsTotal: r,
|
|
49
|
+
cooldownMsRemaining: b
|
|
50
|
+
}, b <= 0 && (clearInterval(h), m());
|
|
51
51
|
}, w);
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
async function S(l) {
|
|
55
|
-
const
|
|
56
|
-
let
|
|
57
|
-
n.buffer.value.length && (
|
|
55
|
+
const r = Ue(n.getPageSize()), M = n.isEnabled(), w = we(n.getRequestDelayMs()), m = [];
|
|
56
|
+
let h = 0;
|
|
57
|
+
n.buffer.value.length && (h = n.buffer.value.length, m.push(...n.buffer.value), n.buffer.value = []), n.stats.value = {
|
|
58
58
|
...n.stats.value,
|
|
59
59
|
enabled: M,
|
|
60
60
|
isBackfillActive: !1,
|
|
@@ -66,59 +66,59 @@ function pt(n) {
|
|
|
66
66
|
collected: 0,
|
|
67
67
|
target: 0
|
|
68
68
|
},
|
|
69
|
-
pageSize:
|
|
69
|
+
pageSize: r,
|
|
70
70
|
bufferSize: 0
|
|
71
71
|
};
|
|
72
|
-
const
|
|
73
|
-
let
|
|
74
|
-
for (;
|
|
75
|
-
const z =
|
|
76
|
-
|
|
72
|
+
const p = [];
|
|
73
|
+
let b = l, A = 0, _ = !1;
|
|
74
|
+
for (; m.length < r && b != null; ) {
|
|
75
|
+
const z = b;
|
|
76
|
+
_ && (n.stats.value = {
|
|
77
77
|
...n.stats.value,
|
|
78
78
|
enabled: M,
|
|
79
79
|
isBackfillActive: !0,
|
|
80
80
|
isRequestInFlight: !0,
|
|
81
81
|
requestPage: z,
|
|
82
82
|
progress: {
|
|
83
|
-
collected: Math.min(
|
|
84
|
-
target:
|
|
83
|
+
collected: Math.min(m.length, r),
|
|
84
|
+
target: r
|
|
85
85
|
},
|
|
86
86
|
cooldownMsTotal: w,
|
|
87
87
|
cooldownMsRemaining: 0,
|
|
88
|
-
pageSize:
|
|
88
|
+
pageSize: r
|
|
89
89
|
});
|
|
90
90
|
const I = await n.getContent(z);
|
|
91
|
-
|
|
91
|
+
p.push(z), _ && (n.stats.value = {
|
|
92
92
|
...n.stats.value,
|
|
93
93
|
enabled: M,
|
|
94
94
|
isBackfillActive: !0,
|
|
95
95
|
isRequestInFlight: !1,
|
|
96
96
|
requestPage: null
|
|
97
|
-
}), A += I.items.length, n.markEnterFromLeft(I.items),
|
|
97
|
+
}), A += I.items.length, n.markEnterFromLeft(I.items), m.push(...I.items), b = I.nextPage, !_ && m.length < r && b != null ? (_ = !0, n.stats.value = {
|
|
98
98
|
...n.stats.value,
|
|
99
99
|
enabled: M,
|
|
100
100
|
isBackfillActive: !0,
|
|
101
101
|
isRequestInFlight: !1,
|
|
102
102
|
requestPage: null,
|
|
103
103
|
progress: {
|
|
104
|
-
collected: Math.min(
|
|
105
|
-
target:
|
|
104
|
+
collected: Math.min(m.length, r),
|
|
105
|
+
target: r
|
|
106
106
|
},
|
|
107
107
|
cooldownMsTotal: w,
|
|
108
108
|
cooldownMsRemaining: 0,
|
|
109
|
-
pageSize:
|
|
110
|
-
}) :
|
|
109
|
+
pageSize: r
|
|
110
|
+
}) : _ && (n.stats.value = {
|
|
111
111
|
...n.stats.value,
|
|
112
112
|
enabled: M,
|
|
113
113
|
isBackfillActive: !0,
|
|
114
114
|
progress: {
|
|
115
|
-
collected: Math.min(
|
|
116
|
-
target:
|
|
115
|
+
collected: Math.min(m.length, r),
|
|
116
|
+
target: r
|
|
117
117
|
}
|
|
118
|
-
}),
|
|
118
|
+
}), _ && m.length < r && b != null && await y(w);
|
|
119
119
|
}
|
|
120
|
-
const
|
|
121
|
-
return n.buffer.value =
|
|
120
|
+
const H = m.slice(0, r), F = m.slice(r);
|
|
121
|
+
return n.buffer.value = F, n.stats.value = {
|
|
122
122
|
...n.stats.value,
|
|
123
123
|
enabled: M,
|
|
124
124
|
isBackfillActive: !1,
|
|
@@ -130,70 +130,70 @@ function pt(n) {
|
|
|
130
130
|
},
|
|
131
131
|
cooldownMsTotal: w,
|
|
132
132
|
cooldownMsRemaining: 0,
|
|
133
|
-
pageSize:
|
|
134
|
-
bufferSize:
|
|
133
|
+
pageSize: r,
|
|
134
|
+
bufferSize: F.length,
|
|
135
135
|
lastBatch: {
|
|
136
136
|
startPage: l,
|
|
137
|
-
pages:
|
|
138
|
-
usedFromBuffer:
|
|
137
|
+
pages: p,
|
|
138
|
+
usedFromBuffer: h,
|
|
139
139
|
fetchedFromNetwork: A,
|
|
140
|
-
collectedTotal:
|
|
141
|
-
emitted:
|
|
142
|
-
carried:
|
|
140
|
+
collectedTotal: m.length,
|
|
141
|
+
emitted: H.length,
|
|
142
|
+
carried: F.length
|
|
143
143
|
},
|
|
144
144
|
totals: {
|
|
145
|
-
pagesFetched: n.stats.value.totals.pagesFetched +
|
|
145
|
+
pagesFetched: n.stats.value.totals.pagesFetched + p.length,
|
|
146
146
|
itemsFetchedFromNetwork: n.stats.value.totals.itemsFetchedFromNetwork + A
|
|
147
147
|
}
|
|
148
|
-
}, { batchItems:
|
|
148
|
+
}, { batchItems: H, pages: p, nextPage: b };
|
|
149
149
|
}
|
|
150
150
|
return { loadBackfillBatch: S };
|
|
151
151
|
}
|
|
152
|
-
function
|
|
153
|
-
const y = n.columnCount, S = n.columnWidth, l = n.gapX,
|
|
154
|
-
let
|
|
155
|
-
for (let
|
|
156
|
-
const z = n.items[
|
|
157
|
-
z?.id &&
|
|
152
|
+
function kt(n) {
|
|
153
|
+
const y = n.columnCount, S = n.columnWidth, l = n.gapX, r = n.gapY, M = n.headerHeight, w = n.footerHeight, m = n.bucketPx, h = Array.from({ length: y }, () => 0), p = new Array(n.items.length), b = new Array(n.items.length), A = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Map();
|
|
154
|
+
let H = 0;
|
|
155
|
+
for (let F = 0; F < n.items.length; F += 1) {
|
|
156
|
+
const z = n.items[F];
|
|
157
|
+
z?.id && _.set(z.id, F);
|
|
158
158
|
let I = 0;
|
|
159
|
-
for (let
|
|
160
|
-
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
const te = Math.floor(E /
|
|
164
|
-
for (let
|
|
165
|
-
const
|
|
166
|
-
|
|
159
|
+
for (let P = 1; P < h.length; P += 1)
|
|
160
|
+
h[P] < h[I] && (I = P);
|
|
161
|
+
const q = I * (S + l), E = h[I], L = bt(z, S) + M + w;
|
|
162
|
+
p[F] = { x: q, y: E }, b[F] = L, h[I] = E + L + r, H = Math.max(H, E + L);
|
|
163
|
+
const te = Math.floor(E / m), ne = Math.floor((E + L) / m);
|
|
164
|
+
for (let P = te; P <= ne; P += 1) {
|
|
165
|
+
const $ = A.get(P);
|
|
166
|
+
$ ? $.push(F) : A.set(P, [F]);
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
|
-
return { positions:
|
|
169
|
+
return { positions: p, heights: b, buckets: A, contentHeight: H, indexById: _ };
|
|
170
170
|
}
|
|
171
|
-
function
|
|
171
|
+
function Mt(n) {
|
|
172
172
|
const y = n.itemCount;
|
|
173
173
|
if (!y) return [];
|
|
174
|
-
if (n.viewportHeight <= 0) return Array.from({ length: y }, (
|
|
175
|
-
const S = Math.max(0, n.scrollTop - n.overscanPx), l = n.scrollTop + n.viewportHeight + n.overscanPx,
|
|
176
|
-
for (let
|
|
177
|
-
const
|
|
178
|
-
if (
|
|
179
|
-
for (const
|
|
174
|
+
if (n.viewportHeight <= 0) return Array.from({ length: y }, (h, p) => p);
|
|
175
|
+
const S = Math.max(0, n.scrollTop - n.overscanPx), l = n.scrollTop + n.viewportHeight + n.overscanPx, r = Math.floor(S / n.bucketPx), M = Math.floor(l / n.bucketPx), w = /* @__PURE__ */ new Set();
|
|
176
|
+
for (let h = r; h <= M; h += 1) {
|
|
177
|
+
const p = n.buckets.get(h);
|
|
178
|
+
if (p)
|
|
179
|
+
for (const b of p) w.add(b);
|
|
180
180
|
}
|
|
181
|
-
const
|
|
182
|
-
return
|
|
181
|
+
const m = Array.from(w);
|
|
182
|
+
return m.sort((h, p) => h - p), m;
|
|
183
183
|
}
|
|
184
|
-
const
|
|
184
|
+
const It = {
|
|
185
185
|
key: 0,
|
|
186
186
|
class: "flex h-full items-center justify-center"
|
|
187
|
-
},
|
|
187
|
+
}, St = {
|
|
188
188
|
key: 1,
|
|
189
189
|
class: "text-sm font-medium text-red-700"
|
|
190
|
-
},
|
|
190
|
+
}, Bt = ["src", "width", "height", "alt"], Ft = ["poster"], Pt = ["src"], Tt = ["src", "width", "height", "alt"], _t = ["poster"], Ht = ["src"], Rt = { class: "mt-4 pb-2 text-center text-xs text-slate-600" }, At = {
|
|
191
191
|
key: 0,
|
|
192
192
|
class: "inline-flex items-center justify-center gap-2"
|
|
193
|
-
},
|
|
193
|
+
}, Ct = { key: 1 }, zt = { key: 2 }, Nt = 200, Xe = 600, $e = 300, je = 600, We = 600, qt = /* @__PURE__ */ ut({
|
|
194
194
|
inheritAttrs: !1,
|
|
195
195
|
__name: "Masonry",
|
|
196
|
-
props: /* @__PURE__ */
|
|
196
|
+
props: /* @__PURE__ */ ct({
|
|
197
197
|
getContent: {},
|
|
198
198
|
mode: {},
|
|
199
199
|
pageSize: {},
|
|
@@ -207,127 +207,133 @@ const xt = {
|
|
|
207
207
|
headerHeight: {},
|
|
208
208
|
footerHeight: {},
|
|
209
209
|
overscanPx: {}
|
|
210
|
-
},
|
|
210
|
+
}, pt),
|
|
211
211
|
emits: ["update:items"],
|
|
212
212
|
setup(n, { expose: y, emit: S }) {
|
|
213
|
-
const l = n,
|
|
213
|
+
const l = n, r = S, M = ft(), w = dt(), m = B(() => {
|
|
214
214
|
const { class: e, ...a } = M;
|
|
215
215
|
return a;
|
|
216
|
-
}),
|
|
217
|
-
let
|
|
218
|
-
const
|
|
216
|
+
}), h = g(null), p = g(0), b = g(0), A = g(0);
|
|
217
|
+
let _;
|
|
218
|
+
const H = B(() => l.gapX), F = B(() => l.gapY);
|
|
219
219
|
function z(e) {
|
|
220
220
|
if (!e) return 0;
|
|
221
|
-
const a = Math.max(0,
|
|
221
|
+
const a = Math.max(0, H.value);
|
|
222
222
|
return Math.max(0, e.clientWidth - a);
|
|
223
223
|
}
|
|
224
|
-
const I = B(() => l.headerHeight),
|
|
224
|
+
const I = B(() => l.headerHeight), q = B(() => l.footerHeight), E = B(() => !!w.itemHeader), L = B(() => !!w.itemFooter), te = B(() => {
|
|
225
225
|
if (I.value > 0) return { height: `${I.value}px` };
|
|
226
226
|
}), ne = B(() => {
|
|
227
|
-
if (
|
|
228
|
-
}),
|
|
229
|
-
function
|
|
227
|
+
if (q.value > 0) return { height: `${q.value}px` };
|
|
228
|
+
}), P = g([]), $ = g([]), be = g(/* @__PURE__ */ new Map()), xe = g(0), ae = g(/* @__PURE__ */ new Map());
|
|
229
|
+
function ke(e) {
|
|
230
|
+
const a = typeof e == "number" && Number.isFinite(e) ? e : 0;
|
|
231
|
+
return -Math.max(0, a);
|
|
232
|
+
}
|
|
233
|
+
const j = g(/* @__PURE__ */ new Set()), K = g(/* @__PURE__ */ new Set()), re = /* @__PURE__ */ new Set(), ue = g(/* @__PURE__ */ new Map()), V = g(/* @__PURE__ */ new Set()), Y = g([]);
|
|
234
|
+
function Ge(e) {
|
|
230
235
|
const a = ue.value.get(e);
|
|
231
236
|
return a || { dx: 0, dy: 0 };
|
|
232
237
|
}
|
|
233
|
-
function
|
|
234
|
-
|
|
238
|
+
function Ke(e) {
|
|
239
|
+
if (K.value.has(e)) return `transform ${je}ms ease-out`;
|
|
240
|
+
if (V.value.has(e)) return `transform ${$e}ms ease-out`;
|
|
235
241
|
}
|
|
236
|
-
function
|
|
237
|
-
const t = o.value[e]?.id, s =
|
|
238
|
-
return `translate3d(${
|
|
242
|
+
function Je(e) {
|
|
243
|
+
const t = o.value[e]?.id, s = P.value[e] ?? { x: 0, y: 0 }, i = $.value[e] ?? 0, v = i > 0 ? i : Z.value, d = s.x, c = t && j.value.has(t) ? ke(v) : s.y, f = t ? Ge(t) : { dx: 0, dy: 0 };
|
|
244
|
+
return `translate3d(${d + f.dx}px,${c + f.dy}px,0)`;
|
|
239
245
|
}
|
|
240
|
-
function
|
|
246
|
+
function W(e) {
|
|
241
247
|
(typeof requestAnimationFrame == "function" ? requestAnimationFrame : (t) => setTimeout(() => t(0), 0))(() => e());
|
|
242
248
|
}
|
|
243
|
-
function
|
|
244
|
-
|
|
249
|
+
function Qe(e) {
|
|
250
|
+
W(() => W(e));
|
|
245
251
|
}
|
|
246
252
|
function ce(e) {
|
|
247
253
|
if (!Array.isArray(e) || e.length === 0) return;
|
|
248
|
-
const a = new Set(
|
|
254
|
+
const a = new Set(j.value);
|
|
249
255
|
let t = !1;
|
|
250
256
|
for (const s of e) {
|
|
251
|
-
const
|
|
252
|
-
|
|
257
|
+
const i = s?.id;
|
|
258
|
+
i && (a.has(i) || (a.add(i), t = !0));
|
|
253
259
|
}
|
|
254
|
-
t && (
|
|
260
|
+
t && (j.value = a);
|
|
255
261
|
}
|
|
256
262
|
function Me() {
|
|
257
263
|
const e = /* @__PURE__ */ new Map();
|
|
258
264
|
for (const a of pe.value) {
|
|
259
265
|
const s = o.value[a]?.id;
|
|
260
266
|
if (!s) continue;
|
|
261
|
-
const
|
|
262
|
-
|
|
267
|
+
const i = P.value[a];
|
|
268
|
+
i && e.set(s, { x: i.x, y: i.y });
|
|
263
269
|
}
|
|
264
270
|
return e;
|
|
265
271
|
}
|
|
266
272
|
function Ie(e, a) {
|
|
267
273
|
if (!e.size) return;
|
|
268
274
|
const t = /* @__PURE__ */ new Map(), s = [];
|
|
269
|
-
for (const [v,
|
|
275
|
+
for (const [v, d] of e.entries()) {
|
|
270
276
|
if (a?.has(v)) continue;
|
|
271
|
-
const
|
|
272
|
-
if (
|
|
273
|
-
const
|
|
274
|
-
if (!
|
|
275
|
-
const u =
|
|
276
|
-
(u ||
|
|
277
|
+
const c = ae.value.get(v);
|
|
278
|
+
if (c == null) continue;
|
|
279
|
+
const f = P.value[c];
|
|
280
|
+
if (!f) continue;
|
|
281
|
+
const u = d.x - f.x, R = d.y - f.y;
|
|
282
|
+
(u || R) && (t.set(v, { dx: u, dy: R }), s.push(v));
|
|
277
283
|
}
|
|
278
284
|
if (!t.size) return;
|
|
279
285
|
ue.value = t;
|
|
280
|
-
const
|
|
281
|
-
for (const v of s)
|
|
282
|
-
|
|
283
|
-
|
|
286
|
+
const i = new Set(V.value);
|
|
287
|
+
for (const v of s) i.delete(v);
|
|
288
|
+
V.value = i, W(() => {
|
|
289
|
+
V.value = /* @__PURE__ */ new Set([...V.value, ...s]), W(() => {
|
|
284
290
|
ue.value = /* @__PURE__ */ new Map();
|
|
285
291
|
});
|
|
286
292
|
}), setTimeout(() => {
|
|
287
|
-
const v = new Set(
|
|
288
|
-
for (const
|
|
289
|
-
|
|
290
|
-
},
|
|
293
|
+
const v = new Set(V.value);
|
|
294
|
+
for (const d of s) v.delete(d);
|
|
295
|
+
V.value = v;
|
|
296
|
+
}, $e);
|
|
291
297
|
}
|
|
292
|
-
const
|
|
298
|
+
const se = g(!0), J = g(!1), U = g(""), D = g([]), Se = g([]), fe = g([]), C = g(l.page), de = g([]);
|
|
293
299
|
let ve = 0;
|
|
294
|
-
function
|
|
300
|
+
function Q(e) {
|
|
295
301
|
for (const a of e)
|
|
296
302
|
!a || typeof a != "object" || a.id && a.originalIndex == null && (a.originalIndex = ve, ve += 1);
|
|
297
303
|
}
|
|
298
|
-
const
|
|
299
|
-
function
|
|
304
|
+
const O = /* @__PURE__ */ new Map(), X = [];
|
|
305
|
+
function le(e) {
|
|
300
306
|
return typeof e == "number" && Number.isFinite(e);
|
|
301
307
|
}
|
|
302
|
-
function
|
|
308
|
+
function Ze(e, a) {
|
|
303
309
|
if (!a.length) return e;
|
|
304
310
|
const t = /* @__PURE__ */ new Set();
|
|
305
|
-
for (const
|
|
306
|
-
const
|
|
307
|
-
|
|
311
|
+
for (const d of e) {
|
|
312
|
+
const c = d?.id;
|
|
313
|
+
c && t.add(c);
|
|
308
314
|
}
|
|
309
315
|
const s = [];
|
|
310
|
-
for (const
|
|
311
|
-
const
|
|
312
|
-
|
|
316
|
+
for (const d of a) {
|
|
317
|
+
const c = d?.id;
|
|
318
|
+
c && (t.has(c) || (s.push(d), t.add(c)));
|
|
313
319
|
}
|
|
314
320
|
if (!s.length) return e;
|
|
315
|
-
const
|
|
316
|
-
const
|
|
317
|
-
return
|
|
321
|
+
const i = s.slice().sort((d, c) => {
|
|
322
|
+
const f = le(d.originalIndex) ? d.originalIndex : Number.POSITIVE_INFINITY, u = le(c.originalIndex) ? c.originalIndex : Number.POSITIVE_INFINITY;
|
|
323
|
+
return f - u;
|
|
318
324
|
}), v = e.slice();
|
|
319
|
-
for (const
|
|
320
|
-
const
|
|
321
|
-
if (!
|
|
322
|
-
v.push(
|
|
325
|
+
for (const d of i) {
|
|
326
|
+
const c = d.originalIndex;
|
|
327
|
+
if (!le(c)) {
|
|
328
|
+
v.push(d);
|
|
323
329
|
continue;
|
|
324
330
|
}
|
|
325
|
-
let
|
|
326
|
-
for (;
|
|
327
|
-
const
|
|
328
|
-
(
|
|
331
|
+
let f = 0, u = v.length;
|
|
332
|
+
for (; f < u; ) {
|
|
333
|
+
const R = f + u >> 1, ee = v[R]?.originalIndex;
|
|
334
|
+
(le(ee) ? ee : Number.POSITIVE_INFINITY) <= c ? f = R + 1 : u = R;
|
|
329
335
|
}
|
|
330
|
-
v.splice(
|
|
336
|
+
v.splice(f, 0, d);
|
|
331
337
|
}
|
|
332
338
|
return v;
|
|
333
339
|
}
|
|
@@ -335,43 +341,53 @@ const xt = {
|
|
|
335
341
|
if (!e.length) return;
|
|
336
342
|
ce(e);
|
|
337
343
|
const a = Me();
|
|
338
|
-
o.value =
|
|
344
|
+
o.value = Ze(o.value, e), await Oe(), Ie(a);
|
|
339
345
|
}
|
|
340
|
-
async function
|
|
341
|
-
const t = (Array.isArray(e) ? e : [e]).map(
|
|
346
|
+
async function Fe(e) {
|
|
347
|
+
const t = (Array.isArray(e) ? e : [e]).map(me).filter(Boolean);
|
|
342
348
|
if (!t.length) return;
|
|
343
349
|
const s = [];
|
|
344
|
-
for (const
|
|
345
|
-
const v =
|
|
350
|
+
for (const i of t) {
|
|
351
|
+
const v = O.get(i);
|
|
346
352
|
v && s.push(v);
|
|
347
353
|
}
|
|
348
354
|
if (s.length) {
|
|
349
355
|
await Be(s);
|
|
350
|
-
for (const
|
|
351
|
-
|
|
356
|
+
for (const i of s)
|
|
357
|
+
i?.id && O.delete(i.id);
|
|
352
358
|
}
|
|
353
359
|
}
|
|
354
|
-
async function
|
|
355
|
-
const e =
|
|
360
|
+
async function Pe() {
|
|
361
|
+
const e = X.pop();
|
|
356
362
|
if (!e?.length) return;
|
|
357
363
|
const a = [];
|
|
358
364
|
for (const t of e) {
|
|
359
|
-
const s =
|
|
365
|
+
const s = O.get(t);
|
|
360
366
|
s && a.push(s);
|
|
361
367
|
}
|
|
362
368
|
if (a.length) {
|
|
363
369
|
await Be(a);
|
|
364
370
|
for (const t of a)
|
|
365
|
-
t?.id &&
|
|
371
|
+
t?.id && O.delete(t.id);
|
|
366
372
|
}
|
|
367
373
|
}
|
|
368
|
-
async function
|
|
369
|
-
return
|
|
374
|
+
async function et(e) {
|
|
375
|
+
return Fe(e);
|
|
370
376
|
}
|
|
371
|
-
async function
|
|
372
|
-
return
|
|
377
|
+
async function tt() {
|
|
378
|
+
return Pe();
|
|
373
379
|
}
|
|
374
|
-
|
|
380
|
+
function Te(e) {
|
|
381
|
+
const t = (Array.isArray(e) ? e : [e]).map(me).filter(Boolean);
|
|
382
|
+
if (!t.length) return;
|
|
383
|
+
const s = new Set(t);
|
|
384
|
+
for (const i of s) O.delete(i);
|
|
385
|
+
for (let i = X.length - 1; i >= 0; i -= 1) {
|
|
386
|
+
const d = X[i].filter((c) => !s.has(c));
|
|
387
|
+
d.length ? X[i] = d : X.splice(i, 1);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
const he = vt({
|
|
375
391
|
enabled: !1,
|
|
376
392
|
isBackfillActive: !1,
|
|
377
393
|
isRequestInFlight: !1,
|
|
@@ -389,174 +405,176 @@ const xt = {
|
|
|
389
405
|
pagesFetched: 0,
|
|
390
406
|
itemsFetchedFromNetwork: 0
|
|
391
407
|
}
|
|
392
|
-
}),
|
|
408
|
+
}), _e = xt({
|
|
393
409
|
getContent: (e) => l.getContent(e),
|
|
394
410
|
markEnterFromLeft: ce,
|
|
395
411
|
buffer: de,
|
|
396
|
-
stats:
|
|
412
|
+
stats: he,
|
|
397
413
|
isEnabled: () => l.mode === "backfill",
|
|
398
414
|
getPageSize: () => l.pageSize,
|
|
399
415
|
getRequestDelayMs: () => l.backfillRequestDelayMs
|
|
400
|
-
}),
|
|
401
|
-
|
|
416
|
+
}), ge = B(() => l.items !== void 0);
|
|
417
|
+
G(
|
|
402
418
|
() => l.items,
|
|
403
419
|
(e) => {
|
|
404
|
-
|
|
420
|
+
ge.value && (fe.value = Array.isArray(e) ? e : []);
|
|
405
421
|
},
|
|
406
422
|
{ immediate: !0 }
|
|
407
423
|
);
|
|
408
424
|
const o = B({
|
|
409
425
|
get() {
|
|
410
|
-
return
|
|
426
|
+
return ge.value ? fe.value : Se.value;
|
|
411
427
|
},
|
|
412
428
|
set(e) {
|
|
413
|
-
|
|
429
|
+
ge.value ? (fe.value = e, r("update:items", e)) : Se.value = e;
|
|
414
430
|
}
|
|
415
431
|
});
|
|
416
432
|
async function He(e) {
|
|
417
433
|
const a = await l.getContent(e);
|
|
418
|
-
return
|
|
434
|
+
return Q(a.items), ce(a.items), { items: a.items, nextPage: a.nextPage };
|
|
419
435
|
}
|
|
420
|
-
function
|
|
436
|
+
function me(e) {
|
|
421
437
|
return e ? typeof e == "string" ? e : e?.id : null;
|
|
422
438
|
}
|
|
423
|
-
async function
|
|
424
|
-
const t = (Array.isArray(e) ? e : [e]).map(
|
|
439
|
+
async function Re(e) {
|
|
440
|
+
const t = (Array.isArray(e) ? e : [e]).map(me).filter(Boolean);
|
|
425
441
|
if (!t.length) return;
|
|
426
|
-
const s = new Set(t),
|
|
427
|
-
for (const
|
|
428
|
-
const u = ae.value.get(
|
|
442
|
+
const s = new Set(t), i = [];
|
|
443
|
+
for (const f of s) {
|
|
444
|
+
const u = ae.value.get(f);
|
|
429
445
|
if (u == null) continue;
|
|
430
|
-
const
|
|
431
|
-
|
|
446
|
+
const R = o.value[u];
|
|
447
|
+
R && (O.set(f, R), i.push(f));
|
|
432
448
|
}
|
|
433
|
-
|
|
434
|
-
const v = Me(),
|
|
435
|
-
for (const
|
|
436
|
-
const u = ae.value.get(
|
|
449
|
+
i.length && X.push(i);
|
|
450
|
+
const v = Me(), d = Z.value, c = [];
|
|
451
|
+
for (const f of s) {
|
|
452
|
+
const u = ae.value.get(f);
|
|
437
453
|
if (u == null) continue;
|
|
438
|
-
const
|
|
439
|
-
if (!
|
|
440
|
-
const
|
|
441
|
-
|
|
442
|
-
id:
|
|
443
|
-
item:
|
|
444
|
-
fromX:
|
|
445
|
-
fromY:
|
|
446
|
-
width:
|
|
454
|
+
const R = o.value[u];
|
|
455
|
+
if (!R) continue;
|
|
456
|
+
const ee = P.value[u] ?? { x: 0, y: 0 }, Le = $.value[u] ?? d;
|
|
457
|
+
c.push({
|
|
458
|
+
id: f,
|
|
459
|
+
item: R,
|
|
460
|
+
fromX: ee.x,
|
|
461
|
+
fromY: ee.y,
|
|
462
|
+
width: d,
|
|
447
463
|
height: Le,
|
|
448
464
|
leaving: !0
|
|
449
465
|
});
|
|
450
466
|
}
|
|
451
|
-
if (
|
|
452
|
-
const u =
|
|
467
|
+
if (c.length && (Y.value = [...Y.value, ...c]), o.value = o.value.filter((f) => {
|
|
468
|
+
const u = f?.id;
|
|
453
469
|
return !u || !s.has(u);
|
|
454
|
-
}), await
|
|
455
|
-
const
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
(u) =>
|
|
470
|
+
}), await Oe(), Ie(v, s), c.length) {
|
|
471
|
+
const f = new Set(c.map((u) => u.id));
|
|
472
|
+
W(() => {
|
|
473
|
+
Y.value = Y.value.map(
|
|
474
|
+
(u) => f.has(u.id) ? { ...u, leaving: !1 } : u
|
|
459
475
|
), setTimeout(() => {
|
|
460
|
-
|
|
461
|
-
},
|
|
476
|
+
Y.value = Y.value.filter((u) => !f.has(u.id));
|
|
477
|
+
}, We);
|
|
462
478
|
});
|
|
463
479
|
}
|
|
464
480
|
}
|
|
465
481
|
async function Ae(e) {
|
|
466
|
-
return
|
|
482
|
+
return Re(e);
|
|
467
483
|
}
|
|
468
484
|
y({
|
|
469
|
-
remove:
|
|
470
|
-
restore:
|
|
471
|
-
undo:
|
|
485
|
+
remove: Re,
|
|
486
|
+
restore: et,
|
|
487
|
+
undo: tt,
|
|
488
|
+
forget: Te,
|
|
472
489
|
// Aliases (kept for now; can be removed if you want strictly short API only).
|
|
473
|
-
restoreRemoved:
|
|
474
|
-
undoLastRemoval:
|
|
475
|
-
|
|
490
|
+
restoreRemoved: Fe,
|
|
491
|
+
undoLastRemoval: Pe,
|
|
492
|
+
forgetRemoved: Te,
|
|
493
|
+
backfillStats: he
|
|
476
494
|
});
|
|
477
495
|
function Ce() {
|
|
478
|
-
const e =
|
|
496
|
+
const e = kt({
|
|
479
497
|
items: o.value,
|
|
480
498
|
columnCount: ye.value,
|
|
481
|
-
columnWidth:
|
|
482
|
-
gapX:
|
|
483
|
-
gapY:
|
|
499
|
+
columnWidth: Z.value,
|
|
500
|
+
gapX: H.value,
|
|
501
|
+
gapY: F.value,
|
|
484
502
|
headerHeight: I.value,
|
|
485
|
-
footerHeight:
|
|
486
|
-
bucketPx:
|
|
503
|
+
footerHeight: q.value,
|
|
504
|
+
bucketPx: Xe
|
|
487
505
|
});
|
|
488
|
-
|
|
506
|
+
P.value = e.positions, $.value = e.heights, be.value = e.buckets, xe.value = e.contentHeight, ae.value = e.indexById;
|
|
489
507
|
}
|
|
490
|
-
const
|
|
508
|
+
const nt = B(() => Math.max(xe.value, b.value) + Nt), pe = B(() => Mt({
|
|
491
509
|
itemCount: o.value.length,
|
|
492
|
-
viewportHeight:
|
|
510
|
+
viewportHeight: b.value,
|
|
493
511
|
scrollTop: A.value,
|
|
494
512
|
overscanPx: l.overscanPx,
|
|
495
|
-
bucketPx:
|
|
513
|
+
bucketPx: Xe,
|
|
496
514
|
buckets: be.value
|
|
497
515
|
}));
|
|
498
|
-
|
|
516
|
+
G(
|
|
499
517
|
pe,
|
|
500
518
|
(e) => {
|
|
501
519
|
if (!e?.length) return;
|
|
502
520
|
const a = [];
|
|
503
521
|
for (const t of e) {
|
|
504
522
|
const s = o.value[t]?.id;
|
|
505
|
-
s &&
|
|
523
|
+
s && j.value.has(s) && (re.has(s) || (re.add(s), a.push(s)));
|
|
506
524
|
}
|
|
507
|
-
a.length && (
|
|
508
|
-
const t = new Set(
|
|
525
|
+
a.length && (W(() => {
|
|
526
|
+
const t = new Set(K.value);
|
|
509
527
|
for (const s of a) t.add(s);
|
|
510
|
-
|
|
511
|
-
}),
|
|
512
|
-
const t = new Set(
|
|
528
|
+
K.value = t;
|
|
529
|
+
}), Qe(() => {
|
|
530
|
+
const t = new Set(j.value);
|
|
513
531
|
for (const s of a) t.delete(s);
|
|
514
|
-
|
|
515
|
-
const s = new Set(
|
|
516
|
-
for (const
|
|
517
|
-
s.delete(
|
|
518
|
-
|
|
519
|
-
},
|
|
532
|
+
j.value = t, setTimeout(() => {
|
|
533
|
+
const s = new Set(K.value);
|
|
534
|
+
for (const i of a)
|
|
535
|
+
s.delete(i), re.delete(i);
|
|
536
|
+
K.value = s;
|
|
537
|
+
}, je);
|
|
520
538
|
}));
|
|
521
539
|
},
|
|
522
540
|
{ flush: "post" }
|
|
523
541
|
);
|
|
524
|
-
async function
|
|
525
|
-
if (!(
|
|
542
|
+
async function at() {
|
|
543
|
+
if (!(se.value || J.value) && !(l.mode !== "backfill" && C.value == null) && !(l.mode === "backfill" && C.value == null && de.value.length === 0))
|
|
526
544
|
try {
|
|
527
|
-
if (
|
|
528
|
-
const t = await
|
|
529
|
-
t.pages.length && (D.value = [...D.value, ...t.pages]),
|
|
545
|
+
if (J.value = !0, U.value = "", l.mode === "backfill") {
|
|
546
|
+
const t = await _e.loadBackfillBatch(C.value);
|
|
547
|
+
t.pages.length && (D.value = [...D.value, ...t.pages]), Q(t.batchItems), o.value = [...o.value, ...t.batchItems], C.value = t.nextPage;
|
|
530
548
|
return;
|
|
531
549
|
}
|
|
532
550
|
const e = C.value;
|
|
533
551
|
if (e == null) return;
|
|
534
552
|
const a = await He(e);
|
|
535
|
-
D.value = [...D.value, e],
|
|
553
|
+
D.value = [...D.value, e], Q(a.items), o.value = [...o.value, ...a.items], C.value = a.nextPage;
|
|
536
554
|
} catch (e) {
|
|
537
|
-
|
|
555
|
+
U.value = e instanceof Error ? e.message : String(e);
|
|
538
556
|
} finally {
|
|
539
|
-
|
|
557
|
+
J.value = !1;
|
|
540
558
|
}
|
|
541
559
|
}
|
|
542
|
-
function
|
|
543
|
-
const e =
|
|
560
|
+
function st() {
|
|
561
|
+
const e = h.value;
|
|
544
562
|
if (!e) return;
|
|
545
|
-
A.value = e.scrollTop,
|
|
563
|
+
A.value = e.scrollTop, b.value = e.clientHeight, e.scrollHeight - (e.scrollTop + e.clientHeight) <= l.prefetchThresholdPx && at();
|
|
546
564
|
}
|
|
547
565
|
function ze() {
|
|
548
|
-
return
|
|
566
|
+
return h.value;
|
|
549
567
|
}
|
|
550
|
-
function
|
|
551
|
-
|
|
568
|
+
function Ne(e) {
|
|
569
|
+
p.value = z(e), b.value = e.clientHeight;
|
|
552
570
|
}
|
|
553
|
-
function
|
|
554
|
-
typeof ResizeObserver > "u" || (
|
|
571
|
+
function lt() {
|
|
572
|
+
typeof ResizeObserver > "u" || (_ = new ResizeObserver(() => {
|
|
555
573
|
const e = ze();
|
|
556
|
-
e &&
|
|
574
|
+
e && Ne(e);
|
|
557
575
|
}));
|
|
558
576
|
}
|
|
559
|
-
function
|
|
577
|
+
function ot() {
|
|
560
578
|
return {
|
|
561
579
|
enabled: l.mode === "backfill",
|
|
562
580
|
isBackfillActive: !1,
|
|
@@ -567,8 +585,8 @@ const xt = {
|
|
|
567
585
|
target: 0
|
|
568
586
|
},
|
|
569
587
|
cooldownMsRemaining: 0,
|
|
570
|
-
cooldownMsTotal:
|
|
571
|
-
pageSize:
|
|
588
|
+
cooldownMsTotal: we(l.backfillRequestDelayMs),
|
|
589
|
+
pageSize: Ue(l.pageSize),
|
|
572
590
|
bufferSize: 0,
|
|
573
591
|
lastBatch: null,
|
|
574
592
|
totals: {
|
|
@@ -577,55 +595,55 @@ const xt = {
|
|
|
577
595
|
}
|
|
578
596
|
};
|
|
579
597
|
}
|
|
580
|
-
function
|
|
581
|
-
ve = 0,
|
|
598
|
+
function qe(e) {
|
|
599
|
+
ve = 0, O.clear(), X.length = 0, D.value = [], o.value = [], C.value = e, de.value = [], he.value = ot(), se.value = !0, J.value = !1, U.value = "";
|
|
582
600
|
}
|
|
583
601
|
async function Ee(e) {
|
|
584
602
|
try {
|
|
585
603
|
if (l.mode === "backfill") {
|
|
586
|
-
const a = await
|
|
587
|
-
D.value = a.pages.length ? a.pages : [e],
|
|
604
|
+
const a = await _e.loadBackfillBatch(e);
|
|
605
|
+
D.value = a.pages.length ? a.pages : [e], Q(a.batchItems), o.value = a.batchItems, C.value = a.nextPage;
|
|
588
606
|
} else {
|
|
589
607
|
const a = await He(e);
|
|
590
|
-
D.value = [e],
|
|
608
|
+
D.value = [e], Q(a.items), o.value = a.items, C.value = a.nextPage;
|
|
591
609
|
}
|
|
592
610
|
} catch (a) {
|
|
593
|
-
|
|
611
|
+
U.value = a instanceof Error ? a.message : String(a);
|
|
594
612
|
} finally {
|
|
595
|
-
|
|
613
|
+
se.value = !1;
|
|
596
614
|
}
|
|
597
615
|
}
|
|
598
|
-
function
|
|
616
|
+
function it() {
|
|
599
617
|
const e = ze();
|
|
600
|
-
e && (
|
|
618
|
+
e && (Ne(e), A.value = e.scrollTop, _?.observe(e));
|
|
601
619
|
}
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
}),
|
|
605
|
-
|
|
606
|
-
}),
|
|
620
|
+
ht(async () => {
|
|
621
|
+
lt(), it(), qe(l.page), await Ee(l.page);
|
|
622
|
+
}), gt(() => {
|
|
623
|
+
_?.disconnect();
|
|
624
|
+
}), G(
|
|
607
625
|
() => l.page,
|
|
608
626
|
async (e) => {
|
|
609
|
-
|
|
627
|
+
qe(e), await Ee(e);
|
|
610
628
|
}
|
|
611
|
-
),
|
|
612
|
-
|
|
629
|
+
), G(
|
|
630
|
+
H,
|
|
613
631
|
() => {
|
|
614
|
-
const e =
|
|
615
|
-
e && (
|
|
632
|
+
const e = h.value;
|
|
633
|
+
e && (p.value = z(e));
|
|
616
634
|
},
|
|
617
635
|
{ immediate: !1 }
|
|
618
636
|
);
|
|
619
|
-
const ye = B(() =>
|
|
620
|
-
() =>
|
|
637
|
+
const ye = B(() => yt(p.value, l.itemWidth)), Z = B(
|
|
638
|
+
() => wt(p.value, ye.value, l.itemWidth, H.value)
|
|
621
639
|
);
|
|
622
|
-
|
|
623
|
-
[ye,
|
|
640
|
+
G(
|
|
641
|
+
[ye, Z, H, F, I, q],
|
|
624
642
|
() => {
|
|
625
643
|
Ce();
|
|
626
644
|
},
|
|
627
645
|
{ immediate: !0 }
|
|
628
|
-
),
|
|
646
|
+
), G(
|
|
629
647
|
// Performance note: this component targets very large arrays (e.g. 10k items).
|
|
630
648
|
// Avoid deep watchers over items; rebuild layout only when the list structure
|
|
631
649
|
// changes (new array reference or length change). This keeps metadata-only
|
|
@@ -634,20 +652,20 @@ const xt = {
|
|
|
634
652
|
() => Ce(),
|
|
635
653
|
{ immediate: !0 }
|
|
636
654
|
);
|
|
637
|
-
const
|
|
655
|
+
const rt = B(() => [
|
|
638
656
|
"mt-8 flex min-h-0 flex-1 flex-col rounded-2xl border border-slate-200/70 bg-white/70 p-5 shadow-sm backdrop-blur",
|
|
639
657
|
M.class
|
|
640
658
|
]);
|
|
641
|
-
return (e, a) => (k(),
|
|
659
|
+
return (e, a) => (k(), x("section", mt(m.value, { class: rt.value }), [
|
|
642
660
|
T("div", {
|
|
643
661
|
ref_key: "scrollViewportRef",
|
|
644
|
-
ref:
|
|
662
|
+
ref: h,
|
|
645
663
|
"data-testid": "items-scroll-container",
|
|
646
664
|
class: "mt-4 min-h-0 flex-1 overflow-auto",
|
|
647
|
-
style:
|
|
648
|
-
onScroll:
|
|
665
|
+
style: N({ paddingRight: H.value + "px" }),
|
|
666
|
+
onScroll: st
|
|
649
667
|
}, [
|
|
650
|
-
|
|
668
|
+
se.value ? (k(), x("div", It, a[0] || (a[0] = [
|
|
651
669
|
T("div", { class: "inline-flex items-center gap-3 text-sm text-slate-600" }, [
|
|
652
670
|
T("svg", {
|
|
653
671
|
class: "h-5 w-5 animate-spin text-slate-500",
|
|
@@ -671,26 +689,26 @@ const xt = {
|
|
|
671
689
|
]),
|
|
672
690
|
T("span", null, "Loading…")
|
|
673
691
|
], -1)
|
|
674
|
-
]))) :
|
|
692
|
+
]))) : U.value ? (k(), x("p", St, "Error: " + Ve(U.value), 1)) : (k(), x("div", {
|
|
675
693
|
key: 2,
|
|
676
694
|
class: "relative",
|
|
677
|
-
style:
|
|
695
|
+
style: N({ height: nt.value + "px" })
|
|
678
696
|
}, [
|
|
679
|
-
(k(!0),
|
|
697
|
+
(k(!0), x(Ye, null, De(pe.value, (t) => (k(), x("article", {
|
|
680
698
|
key: o.value[t].id,
|
|
681
699
|
"data-testid": "item-card",
|
|
682
700
|
class: "absolute overflow-hidden rounded-xl border border-slate-200/60 bg-white shadow-sm",
|
|
683
|
-
style:
|
|
684
|
-
width:
|
|
685
|
-
transition:
|
|
686
|
-
transform:
|
|
701
|
+
style: N({
|
|
702
|
+
width: Z.value + "px",
|
|
703
|
+
transition: Ke(o.value[t].id),
|
|
704
|
+
transform: Je(t)
|
|
687
705
|
})
|
|
688
706
|
}, [
|
|
689
|
-
E.value || I.value > 0 ? (k(),
|
|
707
|
+
E.value || I.value > 0 ? (k(), x("div", {
|
|
690
708
|
key: 0,
|
|
691
709
|
"data-testid": "item-header-container",
|
|
692
710
|
class: "w-full",
|
|
693
|
-
style:
|
|
711
|
+
style: N(te.value)
|
|
694
712
|
}, [
|
|
695
713
|
ie(e.$slots, "itemHeader", {
|
|
696
714
|
item: o.value[t],
|
|
@@ -699,9 +717,9 @@ const xt = {
|
|
|
699
717
|
], 4)) : oe("", !0),
|
|
700
718
|
T("div", {
|
|
701
719
|
class: "bg-slate-100",
|
|
702
|
-
style:
|
|
720
|
+
style: N({ aspectRatio: o.value[t].width + " / " + o.value[t].height })
|
|
703
721
|
}, [
|
|
704
|
-
o.value[t].type === "image" ? (k(),
|
|
722
|
+
o.value[t].type === "image" ? (k(), x("img", {
|
|
705
723
|
key: 0,
|
|
706
724
|
class: "h-full w-full object-cover",
|
|
707
725
|
src: o.value[t].preview,
|
|
@@ -709,7 +727,7 @@ const xt = {
|
|
|
709
727
|
height: o.value[t].height,
|
|
710
728
|
loading: "lazy",
|
|
711
729
|
alt: o.value[t].id
|
|
712
|
-
}, null, 8,
|
|
730
|
+
}, null, 8, Bt)) : (k(), x("video", {
|
|
713
731
|
key: 1,
|
|
714
732
|
class: "h-full w-full object-cover",
|
|
715
733
|
poster: o.value[t].preview,
|
|
@@ -719,14 +737,14 @@ const xt = {
|
|
|
719
737
|
T("source", {
|
|
720
738
|
src: o.value[t].original,
|
|
721
739
|
type: "video/mp4"
|
|
722
|
-
}, null, 8,
|
|
723
|
-
], 8,
|
|
740
|
+
}, null, 8, Pt)
|
|
741
|
+
], 8, Ft))
|
|
724
742
|
], 4),
|
|
725
|
-
L.value ||
|
|
743
|
+
L.value || q.value > 0 ? (k(), x("div", {
|
|
726
744
|
key: 1,
|
|
727
745
|
"data-testid": "item-footer-container",
|
|
728
746
|
class: "w-full",
|
|
729
|
-
style:
|
|
747
|
+
style: N(ne.value)
|
|
730
748
|
}, [
|
|
731
749
|
ie(e.$slots, "itemFooter", {
|
|
732
750
|
item: o.value[t],
|
|
@@ -734,21 +752,21 @@ const xt = {
|
|
|
734
752
|
})
|
|
735
753
|
], 4)) : oe("", !0)
|
|
736
754
|
], 4))), 128)),
|
|
737
|
-
(k(!0),
|
|
755
|
+
(k(!0), x(Ye, null, De(Y.value, (t) => (k(), x("article", {
|
|
738
756
|
key: t.id + ":leaving",
|
|
739
757
|
"data-testid": "item-card-leaving",
|
|
740
758
|
class: "pointer-events-none absolute overflow-hidden rounded-xl border border-slate-200/60 bg-white shadow-sm",
|
|
741
|
-
style:
|
|
759
|
+
style: N({
|
|
742
760
|
width: t.width + "px",
|
|
743
|
-
transition: "transform " +
|
|
744
|
-
transform: t.leaving ? "translate3d(" + t.fromX + "px," + t.fromY + "px,0)" : "translate3d(" + t.fromX + "px," + (t.
|
|
761
|
+
transition: "transform " + We + "ms ease-out",
|
|
762
|
+
transform: t.leaving ? "translate3d(" + t.fromX + "px," + t.fromY + "px,0)" : "translate3d(" + t.fromX + "px," + ke(t.height) + "px,0)"
|
|
745
763
|
})
|
|
746
764
|
}, [
|
|
747
|
-
E.value || I.value > 0 ? (k(),
|
|
765
|
+
E.value || I.value > 0 ? (k(), x("div", {
|
|
748
766
|
key: 0,
|
|
749
767
|
"data-testid": "item-header-container",
|
|
750
768
|
class: "w-full",
|
|
751
|
-
style:
|
|
769
|
+
style: N(te.value)
|
|
752
770
|
}, [
|
|
753
771
|
ie(e.$slots, "itemHeader", {
|
|
754
772
|
item: t.item,
|
|
@@ -758,9 +776,9 @@ const xt = {
|
|
|
758
776
|
], 4)) : oe("", !0),
|
|
759
777
|
T("div", {
|
|
760
778
|
class: "bg-slate-100",
|
|
761
|
-
style:
|
|
779
|
+
style: N({ aspectRatio: t.item.width + " / " + t.item.height })
|
|
762
780
|
}, [
|
|
763
|
-
t.item.type === "image" ? (k(),
|
|
781
|
+
t.item.type === "image" ? (k(), x("img", {
|
|
764
782
|
key: 0,
|
|
765
783
|
class: "h-full w-full object-cover",
|
|
766
784
|
src: t.item.preview,
|
|
@@ -768,7 +786,7 @@ const xt = {
|
|
|
768
786
|
height: t.item.height,
|
|
769
787
|
loading: "lazy",
|
|
770
788
|
alt: t.item.id
|
|
771
|
-
}, null, 8,
|
|
789
|
+
}, null, 8, Tt)) : (k(), x("video", {
|
|
772
790
|
key: 1,
|
|
773
791
|
class: "h-full w-full object-cover",
|
|
774
792
|
poster: t.item.preview,
|
|
@@ -778,14 +796,14 @@ const xt = {
|
|
|
778
796
|
T("source", {
|
|
779
797
|
src: t.item.original,
|
|
780
798
|
type: "video/mp4"
|
|
781
|
-
}, null, 8,
|
|
782
|
-
], 8,
|
|
799
|
+
}, null, 8, Ht)
|
|
800
|
+
], 8, _t))
|
|
783
801
|
], 4),
|
|
784
|
-
L.value ||
|
|
802
|
+
L.value || q.value > 0 ? (k(), x("div", {
|
|
785
803
|
key: 1,
|
|
786
804
|
"data-testid": "item-footer-container",
|
|
787
805
|
class: "w-full",
|
|
788
|
-
style:
|
|
806
|
+
style: N(ne.value)
|
|
789
807
|
}, [
|
|
790
808
|
ie(e.$slots, "itemFooter", {
|
|
791
809
|
item: t.item,
|
|
@@ -795,8 +813,8 @@ const xt = {
|
|
|
795
813
|
], 4)) : oe("", !0)
|
|
796
814
|
], 4))), 128))
|
|
797
815
|
], 4)),
|
|
798
|
-
T("div",
|
|
799
|
-
|
|
816
|
+
T("div", Rt, [
|
|
817
|
+
J.value ? (k(), x("span", At, a[1] || (a[1] = [
|
|
800
818
|
T("svg", {
|
|
801
819
|
class: "h-4 w-4 animate-spin text-slate-500",
|
|
802
820
|
viewBox: "0 0 24 24",
|
|
@@ -818,18 +836,18 @@ const xt = {
|
|
|
818
836
|
})
|
|
819
837
|
], -1),
|
|
820
838
|
T("span", null, "Loading more…", -1)
|
|
821
|
-
]))) : C.value == null ? (k(),
|
|
839
|
+
]))) : C.value == null ? (k(), x("span", Ct, "End of list")) : (k(), x("span", zt, "Scroll to load page " + Ve(C.value), 1))
|
|
822
840
|
])
|
|
823
841
|
], 36)
|
|
824
842
|
], 16));
|
|
825
843
|
}
|
|
826
|
-
}),
|
|
844
|
+
}), Lt = {
|
|
827
845
|
install(n) {
|
|
828
|
-
n.component("Masonry",
|
|
846
|
+
n.component("Masonry", qt);
|
|
829
847
|
}
|
|
830
848
|
};
|
|
831
849
|
export {
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
850
|
+
qt as Masonry,
|
|
851
|
+
Lt as VibePlugin,
|
|
852
|
+
pt as masonryDefaults
|
|
835
853
|
};
|