File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
frontend/src/components/ui Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -28,9 +28,19 @@ export type PageChangeEvent = CustomEvent<PageChangeDetail>;
28
28
/**
29
29
* Pagination
30
30
*
31
+ * Persists via a search param in the URL. Defaults to `page`, but can be set with the `name` attribute.
32
+ *
31
33
* Usage example:
32
34
* ```ts
33
- * <btrix-pagination totalCount="11" @page-change=${this.console.log}>
35
+ * <btrix-pagination totalCount="11" @page-change=${console.log}>
36
+ * </btrix-pagination>
37
+ * ```
38
+ *
39
+ * You can have multiple paginations on one page by setting different names:
40
+ * ```ts
41
+ * <btrix-pagination name="page-a" totalCount="11" @page-change=${console.log}>
42
+ * </btrix-pagination>
43
+ * <btrix-pagination name="page-b" totalCount="2" @page-change=${console.log}>
34
44
* </btrix-pagination>
35
45
* ```
36
46
*
@@ -139,7 +149,13 @@ export class Pagination extends LitElement {
139
149
140
150
@state ( )
141
151
public get page ( ) {
142
- return parsePage ( this . searchParams . searchParams . get ( this . name ) ) ;
152
+ return Math . min (
153
+ 1 ,
154
+ Math . max (
155
+ this . totalCount ,
156
+ parsePage ( this . searchParams . searchParams . get ( this . name ) ) ,
157
+ ) ,
158
+ ) ;
143
159
}
144
160
145
161
@property ( { type : String } )
You can’t perform that action at this time.
0 commit comments