convex-helpers 0.1.91 → 0.1.92
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/bin.cjs +2 -2
- package/package.json +1 -1
- package/react/cache/hooks.d.ts +12 -17
- package/react/cache/hooks.d.ts.map +1 -1
- package/react/cache/hooks.js +13 -18
- package/react/cache/hooks.ts +14 -19
package/bin.cjs
CHANGED
|
@@ -3747,8 +3747,8 @@ function generateApiSpec(functionSpec, includeInternal) {
|
|
|
3747
3747
|
includeInternal ? internalFunctionTree : {}
|
|
3748
3748
|
);
|
|
3749
3749
|
return `
|
|
3750
|
-
import { FunctionReference, anyApi } from "convex/server"
|
|
3751
|
-
import { GenericId as Id } from "convex/values"
|
|
3750
|
+
import { type FunctionReference, anyApi } from "convex/server"
|
|
3751
|
+
import { type GenericId as Id } from "convex/values"
|
|
3752
3752
|
|
|
3753
3753
|
export const api: PublicApiType = anyApi as unknown as PublicApiType;
|
|
3754
3754
|
export const internal: InternalApiType = anyApi as unknown as InternalApiType;
|
package/package.json
CHANGED
package/react/cache/hooks.d.ts
CHANGED
|
@@ -73,6 +73,10 @@ export declare function useQuery<Query extends FunctionReference<"query">>(query
|
|
|
73
73
|
/**
|
|
74
74
|
* Load data reactively from a paginated query to a create a growing list.
|
|
75
75
|
*
|
|
76
|
+
* Note: This is a modified version of the original `usePaginatedQuery` hook.
|
|
77
|
+
* The main difference (aside from subscriptions staying active longer) is that
|
|
78
|
+
* the `latestPageSize` option is "fixed" by default.
|
|
79
|
+
*
|
|
76
80
|
* This can be used to power "infinite scroll" UIs.
|
|
77
81
|
*
|
|
78
82
|
* This hook must be used with public query references that match
|
|
@@ -101,22 +105,13 @@ export declare function useQuery<Query extends FunctionReference<"query">>(query
|
|
|
101
105
|
* @param args - The arguments object for the query function, excluding
|
|
102
106
|
* the `paginationOpts` property. That property is injected by this hook.
|
|
103
107
|
* @param options - An object specifying the `initialNumItems` to be loaded in
|
|
104
|
-
* the first page, and the `
|
|
105
|
-
* @param options.
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
* deprecating this behavior in favor of the new option `setOnLoadMore`.
|
|
112
|
-
* For `setOnLoadMore`, the `endCursor` is not inferred from the first request,
|
|
113
|
-
* instead the first call to `loadMore` will explicitly set the `endCursor` to
|
|
114
|
-
* the `continueCursor` of the last page. In the future this will not use the
|
|
115
|
-
* QueryJournal and will become the default behavior, resulting in the first
|
|
116
|
-
* page staying at the same size as `initialNumItems` until you call `loadMore`.
|
|
117
|
-
* Note: setting the `endCursor` on the request will re-request that page with
|
|
118
|
-
* the new argument, causing an effectively duplicate request per `loadMore`.
|
|
119
|
-
*
|
|
108
|
+
* the first page, and the `latestPageSize` to use.
|
|
109
|
+
* @param options.latestPageSize controls how the latest page (the first page
|
|
110
|
+
* until another page is loaded) size grows. With "fixed", the page size will
|
|
111
|
+
* stay at the size specified by `initialNumItems` / `loadMore`. With "grow",
|
|
112
|
+
* the page size will grow as new items are added within the range of the initial
|
|
113
|
+
* page. Once multiple pages are loaded, all but the last page will grow, in
|
|
114
|
+
* order to provide seamless pagination. See the docs for more details.
|
|
120
115
|
* @returns A {@link UsePaginatedQueryResult} that includes the currently loaded
|
|
121
116
|
* items, the status of the pagination, and a `loadMore` function.
|
|
122
117
|
*
|
|
@@ -124,6 +119,6 @@ export declare function useQuery<Query extends FunctionReference<"query">>(query
|
|
|
124
119
|
*/
|
|
125
120
|
export declare function usePaginatedQuery<Query extends PaginatedQueryReference>(query: Query, args: PaginatedQueryArgs<Query> | "skip", options: {
|
|
126
121
|
initialNumItems: number;
|
|
127
|
-
|
|
122
|
+
latestPageSize?: "grow" | "fixed";
|
|
128
123
|
}): UsePaginatedQueryReturnType<Query>;
|
|
129
124
|
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["hooks.ts"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,CAAC,KAAK,CAAC,GAC1C,kBAAkB,CAAC,KAAK,CAAC,GAAG,SAAS,CAoBvC;AAoHD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,SAAS,uBAAuB,EACrE,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,kBAAkB,CAAC,KAAK,CAAC,GAAG,MAAM,EACxC,OAAO,EAAE;IACP,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACnC,GACA,2BAA2B,CAAC,KAAK,CAAC,CAqPpC"}
|
package/react/cache/hooks.js
CHANGED
|
@@ -202,6 +202,10 @@ const completeSplitQuery = (key) => (prevState) => {
|
|
|
202
202
|
/**
|
|
203
203
|
* Load data reactively from a paginated query to a create a growing list.
|
|
204
204
|
*
|
|
205
|
+
* Note: This is a modified version of the original `usePaginatedQuery` hook.
|
|
206
|
+
* The main difference (aside from subscriptions staying active longer) is that
|
|
207
|
+
* the `latestPageSize` option is "fixed" by default.
|
|
208
|
+
*
|
|
205
209
|
* This can be used to power "infinite scroll" UIs.
|
|
206
210
|
*
|
|
207
211
|
* This hook must be used with public query references that match
|
|
@@ -230,22 +234,13 @@ const completeSplitQuery = (key) => (prevState) => {
|
|
|
230
234
|
* @param args - The arguments object for the query function, excluding
|
|
231
235
|
* the `paginationOpts` property. That property is injected by this hook.
|
|
232
236
|
* @param options - An object specifying the `initialNumItems` to be loaded in
|
|
233
|
-
* the first page, and the `
|
|
234
|
-
* @param options.
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
* deprecating this behavior in favor of the new option `setOnLoadMore`.
|
|
241
|
-
* For `setOnLoadMore`, the `endCursor` is not inferred from the first request,
|
|
242
|
-
* instead the first call to `loadMore` will explicitly set the `endCursor` to
|
|
243
|
-
* the `continueCursor` of the last page. In the future this will not use the
|
|
244
|
-
* QueryJournal and will become the default behavior, resulting in the first
|
|
245
|
-
* page staying at the same size as `initialNumItems` until you call `loadMore`.
|
|
246
|
-
* Note: setting the `endCursor` on the request will re-request that page with
|
|
247
|
-
* the new argument, causing an effectively duplicate request per `loadMore`.
|
|
248
|
-
*
|
|
237
|
+
* the first page, and the `latestPageSize` to use.
|
|
238
|
+
* @param options.latestPageSize controls how the latest page (the first page
|
|
239
|
+
* until another page is loaded) size grows. With "fixed", the page size will
|
|
240
|
+
* stay at the size specified by `initialNumItems` / `loadMore`. With "grow",
|
|
241
|
+
* the page size will grow as new items are added within the range of the initial
|
|
242
|
+
* page. Once multiple pages are loaded, all but the last page will grow, in
|
|
243
|
+
* order to provide seamless pagination. See the docs for more details.
|
|
249
244
|
* @returns A {@link UsePaginatedQueryResult} that includes the currently loaded
|
|
250
245
|
* items, the status of the pagination, and a `loadMore` function.
|
|
251
246
|
*
|
|
@@ -416,7 +411,7 @@ export function usePaginatedQuery(query, args, options) {
|
|
|
416
411
|
const queries = { ...prevState.queries };
|
|
417
412
|
let ongoingSplits = prevState.ongoingSplits;
|
|
418
413
|
let pageKeys = prevState.pageKeys;
|
|
419
|
-
if (options.
|
|
414
|
+
if (options.latestPageSize !== "grow") {
|
|
420
415
|
const lastPageKey = prevState.pageKeys.at(-1);
|
|
421
416
|
const boundLastPageKey = nextPageKey;
|
|
422
417
|
queries[boundLastPageKey] = {
|
|
@@ -462,7 +457,7 @@ export function usePaginatedQuery(query, args, options) {
|
|
|
462
457
|
}
|
|
463
458
|
},
|
|
464
459
|
};
|
|
465
|
-
}, [maybeLastResult, currState.nextPageKey, options.
|
|
460
|
+
}, [maybeLastResult, currState.nextPageKey, options.latestPageSize]);
|
|
466
461
|
return {
|
|
467
462
|
results,
|
|
468
463
|
...statusObject,
|
package/react/cache/hooks.ts
CHANGED
|
@@ -282,6 +282,10 @@ const completeSplitQuery =
|
|
|
282
282
|
/**
|
|
283
283
|
* Load data reactively from a paginated query to a create a growing list.
|
|
284
284
|
*
|
|
285
|
+
* Note: This is a modified version of the original `usePaginatedQuery` hook.
|
|
286
|
+
* The main difference (aside from subscriptions staying active longer) is that
|
|
287
|
+
* the `latestPageSize` option is "fixed" by default.
|
|
288
|
+
*
|
|
285
289
|
* This can be used to power "infinite scroll" UIs.
|
|
286
290
|
*
|
|
287
291
|
* This hook must be used with public query references that match
|
|
@@ -310,22 +314,13 @@ const completeSplitQuery =
|
|
|
310
314
|
* @param args - The arguments object for the query function, excluding
|
|
311
315
|
* the `paginationOpts` property. That property is injected by this hook.
|
|
312
316
|
* @param options - An object specifying the `initialNumItems` to be loaded in
|
|
313
|
-
* the first page, and the `
|
|
314
|
-
* @param options.
|
|
315
|
-
*
|
|
316
|
-
*
|
|
317
|
-
*
|
|
318
|
-
*
|
|
319
|
-
*
|
|
320
|
-
* deprecating this behavior in favor of the new option `setOnLoadMore`.
|
|
321
|
-
* For `setOnLoadMore`, the `endCursor` is not inferred from the first request,
|
|
322
|
-
* instead the first call to `loadMore` will explicitly set the `endCursor` to
|
|
323
|
-
* the `continueCursor` of the last page. In the future this will not use the
|
|
324
|
-
* QueryJournal and will become the default behavior, resulting in the first
|
|
325
|
-
* page staying at the same size as `initialNumItems` until you call `loadMore`.
|
|
326
|
-
* Note: setting the `endCursor` on the request will re-request that page with
|
|
327
|
-
* the new argument, causing an effectively duplicate request per `loadMore`.
|
|
328
|
-
*
|
|
317
|
+
* the first page, and the `latestPageSize` to use.
|
|
318
|
+
* @param options.latestPageSize controls how the latest page (the first page
|
|
319
|
+
* until another page is loaded) size grows. With "fixed", the page size will
|
|
320
|
+
* stay at the size specified by `initialNumItems` / `loadMore`. With "grow",
|
|
321
|
+
* the page size will grow as new items are added within the range of the initial
|
|
322
|
+
* page. Once multiple pages are loaded, all but the last page will grow, in
|
|
323
|
+
* order to provide seamless pagination. See the docs for more details.
|
|
329
324
|
* @returns A {@link UsePaginatedQueryResult} that includes the currently loaded
|
|
330
325
|
* items, the status of the pagination, and a `loadMore` function.
|
|
331
326
|
*
|
|
@@ -336,7 +331,7 @@ export function usePaginatedQuery<Query extends PaginatedQueryReference>(
|
|
|
336
331
|
args: PaginatedQueryArgs<Query> | "skip",
|
|
337
332
|
options: {
|
|
338
333
|
initialNumItems: number;
|
|
339
|
-
|
|
334
|
+
latestPageSize?: "grow" | "fixed";
|
|
340
335
|
},
|
|
341
336
|
): UsePaginatedQueryReturnType<Query> {
|
|
342
337
|
if (
|
|
@@ -532,7 +527,7 @@ export function usePaginatedQuery<Query extends PaginatedQueryReference>(
|
|
|
532
527
|
const queries = { ...prevState.queries };
|
|
533
528
|
let ongoingSplits = prevState.ongoingSplits;
|
|
534
529
|
let pageKeys = prevState.pageKeys;
|
|
535
|
-
if (options.
|
|
530
|
+
if (options.latestPageSize !== "grow") {
|
|
536
531
|
const lastPageKey = prevState.pageKeys.at(-1)!;
|
|
537
532
|
const boundLastPageKey = nextPageKey;
|
|
538
533
|
queries[boundLastPageKey] = {
|
|
@@ -577,7 +572,7 @@ export function usePaginatedQuery<Query extends PaginatedQueryReference>(
|
|
|
577
572
|
}
|
|
578
573
|
},
|
|
579
574
|
} as const;
|
|
580
|
-
}, [maybeLastResult, currState.nextPageKey, options.
|
|
575
|
+
}, [maybeLastResult, currState.nextPageKey, options.latestPageSize]);
|
|
581
576
|
|
|
582
577
|
return {
|
|
583
578
|
results,
|