diff --git a/src/npm-fastui-bootstrap/src/pagination.tsx b/src/npm-fastui-bootstrap/src/pagination.tsx index fa9e11bb..d57adb07 100644 --- a/src/npm-fastui-bootstrap/src/pagination.tsx +++ b/src/npm-fastui-bootstrap/src/pagination.tsx @@ -7,11 +7,11 @@ interface Link { locked?: boolean active?: boolean page?: number + pageQueryParam?: string } export const Pagination: FC = (props) => { - const { page, pageCount } = props - + const { page, pageCount, pageQueryParam } = props if (pageCount === 1) return null const links: Link[] = [ @@ -20,17 +20,19 @@ export const Pagination: FC = (props) => { ariaLabel: 'Previous', locked: page === 1, page: page - 1, + pageQueryParam, }, { Display: () => <>1, locked: page === 1, active: page === 1, page: 1, + pageQueryParam, }, ] if (page > 4) { - links.push({ Display: () => <>... }) + links.push({ Display: () => <>..., pageQueryParam }) } for (let p = page - 2; p <= page + 2; p++) { @@ -40,17 +42,19 @@ export const Pagination: FC = (props) => { locked: page === p, active: page === p, page: p, + pageQueryParam, }) } if (page < pageCount - 3) { - links.push({ Display: () => <>... }) + links.push({ Display: () => <>..., pageQueryParam }) } links.push({ Display: () => <>{pageCount}, locked: page === pageCount, page: pageCount, + pageQueryParam, }) links.push({ @@ -58,6 +62,7 @@ export const Pagination: FC = (props) => { ariaLabel: 'Next', locked: page === pageCount, page: page + 1, + pageQueryParam, }) return ( @@ -71,7 +76,7 @@ export const Pagination: FC = (props) => { ) } -const PaginationLink: FC = ({ Display, ariaLabel, locked, active, page }) => { +const PaginationLink: FC = ({ Display, ariaLabel, locked, active, page, pageQueryParam }) => { if (!page) { return (
  • @@ -82,7 +87,10 @@ const PaginationLink: FC = ({ Display, ariaLabel, locked, active, page }) ) } const className = renderClassName({ 'page-link': true, disabled: locked && !active, active } as models.ClassName) - const onClick: models.GoToEvent = { type: 'go-to', query: { page } } + const onClick: models.GoToEvent = { + type: 'go-to', + query: { [pageQueryParam !== undefined ? pageQueryParam : 'page']: page }, + } return (
  • diff --git a/src/npm-fastui/src/models.d.ts b/src/npm-fastui/src/models.d.ts index 9877b2ca..e304607f 100644 --- a/src/npm-fastui/src/models.d.ts +++ b/src/npm-fastui/src/models.d.ts @@ -301,6 +301,7 @@ export interface Pagination { total: number className?: ClassName type: 'Pagination' + pageQueryParam?: string pageCount: number } /** diff --git a/src/python-fastui/fastui/components/tables.py b/src/python-fastui/fastui/components/tables.py index d83b4e49..28bfd95f 100644 --- a/src/python-fastui/fastui/components/tables.py +++ b/src/python-fastui/fastui/components/tables.py @@ -59,6 +59,7 @@ class Pagination(pydantic.BaseModel): total: int class_name: _class_name.ClassNameField = None type: _t.Literal['Pagination'] = 'Pagination' + page_query_param: str = pydantic.Field('page', serialization_alias='pageQueryParam') @pydantic.computed_field(alias='pageCount') def page_count(self) -> int: