Skip to content

Commit

Permalink
feat(pagination): expose count
Browse files Browse the repository at this point in the history
  • Loading branch information
segunadebayo committed Aug 4, 2024
1 parent 3d4810c commit 4ce5bed
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/stale-fans-jog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zag-js/pagination": minor
---

Expose `api.count` property
2 changes: 2 additions & 0 deletions packages/machines/pagination/src/pagination.connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export function connect<T extends PropTypes>(state: State, send: Send, normalize
const totalPages = state.context.totalPages
const page = state.context.page
const translations = state.context.translations
const count = state.context.count

const previousPage = state.context.previousPage
const nextPage = state.context.nextPage
Expand All @@ -22,6 +23,7 @@ export function connect<T extends PropTypes>(state: State, send: Send, normalize
const pages = getTransformedRange(state.context)

return {
count,
page,
pageSize: state.context.pageSize,
totalPages,
Expand Down
4 changes: 4 additions & 0 deletions packages/machines/pagination/src/pagination.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ export interface MachineApi<T extends PropTypes = PropTypes> {
* The current page.
*/
page: number
/**
* The total number of data items.
*/
count: number
/**
* The number of data items per page.
*/
Expand Down

0 comments on commit 4ce5bed

Please sign in to comment.