litestar-vite-plugin 0.15.0-beta.3 → 0.15.0-beta.5
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.
|
@@ -47,3 +47,128 @@ export declare function unwrapPageProps<T extends Record<string, unknown>>(props
|
|
|
47
47
|
* ```
|
|
48
48
|
*/
|
|
49
49
|
export declare function resolvePageComponent<T>(path: string | string[], pages: Record<string, Promise<T> | (() => Promise<T>)>): Promise<T>;
|
|
50
|
+
/**
|
|
51
|
+
* Offset-based pagination props.
|
|
52
|
+
*
|
|
53
|
+
* Returned when a route returns Litestar's `OffsetPagination` type.
|
|
54
|
+
* Contains items plus metadata for offset/limit pagination.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* interface User { id: string; name: string }
|
|
59
|
+
* const { items, total, limit, offset } = props.users as OffsetPaginationProps<User>
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export interface OffsetPaginationProps<T> {
|
|
63
|
+
/** The paginated items for the current page */
|
|
64
|
+
items: T[];
|
|
65
|
+
/** Total number of items across all pages */
|
|
66
|
+
total: number;
|
|
67
|
+
/** Maximum items per page (page size) */
|
|
68
|
+
limit: number;
|
|
69
|
+
/** Number of items skipped (offset from start) */
|
|
70
|
+
offset: number;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Classic page-based pagination props.
|
|
74
|
+
*
|
|
75
|
+
* Returned when a route returns Litestar's `ClassicPagination` type.
|
|
76
|
+
* Contains items plus metadata for page number pagination.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```ts
|
|
80
|
+
* interface Post { id: string; title: string }
|
|
81
|
+
* const { items, currentPage, totalPages, pageSize } = props.posts as ClassicPaginationProps<Post>
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export interface ClassicPaginationProps<T> {
|
|
85
|
+
/** The paginated items for the current page */
|
|
86
|
+
items: T[];
|
|
87
|
+
/** Current page number (1-indexed) */
|
|
88
|
+
currentPage: number;
|
|
89
|
+
/** Total number of pages */
|
|
90
|
+
totalPages: number;
|
|
91
|
+
/** Number of items per page */
|
|
92
|
+
pageSize: number;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Cursor-based pagination props.
|
|
96
|
+
*
|
|
97
|
+
* Used for cursor/keyset pagination, commonly with infinite scroll.
|
|
98
|
+
* Contains items plus cursor tokens for navigation.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```ts
|
|
102
|
+
* interface Message { id: string; content: string }
|
|
103
|
+
* const { items, hasMore, nextCursor } = props.messages as CursorPaginationProps<Message>
|
|
104
|
+
* if (hasMore && nextCursor) {
|
|
105
|
+
* // Fetch more with cursor
|
|
106
|
+
* }
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
export interface CursorPaginationProps<T> {
|
|
110
|
+
/** The paginated items for the current page */
|
|
111
|
+
items: T[];
|
|
112
|
+
/** Total number of items (if known) */
|
|
113
|
+
total?: number;
|
|
114
|
+
/** Whether more items exist after the current page */
|
|
115
|
+
hasMore?: boolean;
|
|
116
|
+
/** Whether a next page exists */
|
|
117
|
+
hasNext?: boolean;
|
|
118
|
+
/** Whether a previous page exists */
|
|
119
|
+
hasPrevious?: boolean;
|
|
120
|
+
/** Cursor token for fetching the next page */
|
|
121
|
+
nextCursor?: string | null;
|
|
122
|
+
/** Cursor token for fetching the previous page */
|
|
123
|
+
previousCursor?: string | null;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Union type for any pagination props.
|
|
127
|
+
*
|
|
128
|
+
* Use when you need to handle multiple pagination styles.
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```ts
|
|
132
|
+
* function renderPagination<T>(data: PaginationProps<T>) {
|
|
133
|
+
* if ('offset' in data) {
|
|
134
|
+
* // Handle offset pagination
|
|
135
|
+
* } else if ('currentPage' in data) {
|
|
136
|
+
* // Handle classic pagination
|
|
137
|
+
* } else {
|
|
138
|
+
* // Handle cursor pagination
|
|
139
|
+
* }
|
|
140
|
+
* }
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
export type PaginationProps<T> = OffsetPaginationProps<T> | ClassicPaginationProps<T> | CursorPaginationProps<T>;
|
|
144
|
+
/**
|
|
145
|
+
* Scroll props configuration for Inertia v2 infinite scroll.
|
|
146
|
+
*
|
|
147
|
+
* Returned in the `scrollProps` field of an Inertia response when
|
|
148
|
+
* `infinite_scroll=True` is set on the route.
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```ts
|
|
152
|
+
* // In your Inertia page component
|
|
153
|
+
* import { usePage } from '@inertiajs/vue3'
|
|
154
|
+
*
|
|
155
|
+
* const page = usePage()
|
|
156
|
+
* const scrollProps = page.props.scrollProps as ScrollProps
|
|
157
|
+
*
|
|
158
|
+
* function loadMore() {
|
|
159
|
+
* if (scrollProps.nextPage) {
|
|
160
|
+
* router.get(url, { [scrollProps.pageName]: scrollProps.nextPage })
|
|
161
|
+
* }
|
|
162
|
+
* }
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
export interface ScrollProps {
|
|
166
|
+
/** Query parameter name for page number (default: "page") */
|
|
167
|
+
pageName: string;
|
|
168
|
+
/** Current page number */
|
|
169
|
+
currentPage: number;
|
|
170
|
+
/** Previous page number, or null if on first page */
|
|
171
|
+
previousPage: number | null;
|
|
172
|
+
/** Next page number, or null if on last page */
|
|
173
|
+
nextPage: number | null;
|
|
174
|
+
}
|