@lunora/client 1.0.0-alpha.286 → 1.0.0-alpha.287
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.
|
@@ -29,6 +29,11 @@ interface PaginationResult<T = unknown> {
|
|
|
29
29
|
* adjacent ranges. Absent on legacy (open-ended) pages.
|
|
30
30
|
*/
|
|
31
31
|
splitCursor?: null | string;
|
|
32
|
+
/**
|
|
33
|
+
* Reactive-pagination only: the server's read cut this bounded page short, so it holds only the
|
|
34
|
+
* first rows of its range. Split at `splitCursor` whatever the page's size.
|
|
35
|
+
*/
|
|
36
|
+
splitRequired?: boolean;
|
|
32
37
|
}
|
|
33
38
|
/**
|
|
34
39
|
* Lifecycle of a `usePaginatedQuery` feed.
|
|
@@ -29,6 +29,11 @@ interface PaginationResult<T = unknown> {
|
|
|
29
29
|
* adjacent ranges. Absent on legacy (open-ended) pages.
|
|
30
30
|
*/
|
|
31
31
|
splitCursor?: null | string;
|
|
32
|
+
/**
|
|
33
|
+
* Reactive-pagination only: the server's read cut this bounded page short, so it holds only the
|
|
34
|
+
* first rows of its range. Split at `splitCursor` whatever the page's size.
|
|
35
|
+
*/
|
|
36
|
+
splitRequired?: boolean;
|
|
32
37
|
}
|
|
33
38
|
/**
|
|
34
39
|
* Lifecycle of a `usePaginatedQuery` feed.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const l=2,
|
|
1
|
+
const l=2,p=.5,m=n=>[{lower:null,numItems:n,upper:null}],c=(n,r)=>{for(const[e,t]of n.entries()){if(t.upper===null)continue;const u=r[e];if(!u)continue;const i=u.page.length;if((i>2*t.numItems||u.splitRequired===!0)&&u.splitCursor){const o=u.splitCursor,s=[...n];return s.splice(e,1,{lower:t.lower,numItems:t.numItems,upper:o},{lower:o,numItems:t.numItems,upper:t.upper}),s}if(i<.5*t.numItems&&e+1<n.length&&r[e+1]?.splitRequired!==!0){const o=n[e+1];if(!o)continue;const s=[...n];return s.splice(e,2,{lower:t.lower,numItems:t.numItems,upper:o.upper}),s}}},a=(n,r)=>{if(n||!r[0])return{nextCursor:void 0,status:"LoadingFirstPage"};const e=r.at(-1);return e?e.isDone||e.continueCursor===null?{nextCursor:void 0,status:"Exhausted"}:{nextCursor:e.continueCursor,status:"CanLoadMore"}:{nextCursor:void 0,status:"LoadingMore"}},I=(n,r,e)=>{if(r==null)return;const t=[...n],u=t.at(-1);return u&&(t[t.length-1]={lower:u.lower,numItems:u.numItems,upper:r}),t.push({lower:r,numItems:e,upper:null}),t};export{p as JOIN_FACTOR,l as SPLIT_FACTOR,I as applyLoadMore,a as derivePaginationStatus,m as initialPages,c as rebalance};
|