@openstax/ts-utils 1.1.16 → 1.1.18
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/dist/pagination.d.ts
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import { QueryParams, RouteMatchRecord } from './routing';
|
|
2
|
-
export declare type PaginationHandler<Pa> = <R>(queryParams:
|
|
3
|
-
getUnusedQueryParams: () =>
|
|
2
|
+
export declare type PaginationHandler<Pa, Q extends QueryParams> = <R>(queryParams: Q, match: RouteMatchRecord<R>) => Pa & {
|
|
3
|
+
getUnusedQueryParams: () => Q;
|
|
4
4
|
};
|
|
5
|
-
export declare const createPaginationMiddleware: <Ri, R = any>() => <Pa>({ getQueryParams, setUnusedQueryParams, paginator }: {
|
|
6
|
-
getQueryParams: (request: Ri) =>
|
|
7
|
-
setUnusedQueryParams: (request: Ri, query:
|
|
8
|
-
paginator: PaginationHandler<Pa>;
|
|
5
|
+
export declare const createPaginationMiddleware: <Ri, Q extends QueryParams, R = any>() => <Pa>({ getQueryParams, setUnusedQueryParams, paginator }: {
|
|
6
|
+
getQueryParams: (request: Ri) => Q;
|
|
7
|
+
setUnusedQueryParams: (request: Ri, query: Q) => Ri;
|
|
8
|
+
paginator: PaginationHandler<Pa, Q>;
|
|
9
9
|
}) => <M extends {
|
|
10
10
|
request: Ri;
|
|
11
11
|
}>() => (middleware: M, match: RouteMatchRecord<R>) => M & {
|
|
12
12
|
pagination: Pa & {
|
|
13
|
-
getUnusedQueryParams: () =>
|
|
13
|
+
getUnusedQueryParams: () => Q;
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
|
-
export declare const loadMorePagination: <R>(queryParams:
|
|
17
|
-
getUnusedQueryParams: () =>
|
|
18
|
-
[x: string]: string | string[] | null | undefined;
|
|
19
|
-
};
|
|
16
|
+
export declare const loadMorePagination: <R, Q extends QueryParams>(queryParams: Q, { route, params }: RouteMatchRecord<R>) => {
|
|
17
|
+
getUnusedQueryParams: () => Omit<Q, "pageToken">;
|
|
20
18
|
getPageTokenString: () => string | string[] | null | undefined;
|
|
21
19
|
getPageTokenNumber: () => number | undefined;
|
|
22
20
|
getPaginationResponse: <T>({ items, ...meta }: LoadMorePaginationResultInput<T>) => {
|
|
@@ -33,10 +31,8 @@ export interface LoadMorePaginationResultInput<T> {
|
|
|
33
31
|
items: T[];
|
|
34
32
|
nextPageToken: string | number | undefined;
|
|
35
33
|
}
|
|
36
|
-
export declare const pageNumberPagination: <R>(queryParams:
|
|
37
|
-
getUnusedQueryParams: () =>
|
|
38
|
-
[x: string]: string | string[] | null | undefined;
|
|
39
|
-
};
|
|
34
|
+
export declare const pageNumberPagination: <R, Q extends QueryParams>(queryParams: Q, { route, params }: RouteMatchRecord<R>) => {
|
|
35
|
+
getUnusedQueryParams: () => Omit<Q, "page">;
|
|
40
36
|
getPaginationParams: () => {
|
|
41
37
|
page: number | undefined;
|
|
42
38
|
};
|