GitHub

Reference headless

pagination

interface 3 type 1 function 1
interface Interfaces 3

# CalculatePagesInput

Members

boundaryCount?
optional boundaryCount?: number

How many boundary pages at start/end to always show. Default 1.

page
page: number

1-indexed current page.

pageCount
pageCount: number
siblingCount?
optional siblingCount?: number

How many neighbours of the current page to show. Default 1.

# PaginationItemEllipsis

Members

side
side: "start" | "end"

Where the gap is — before the central window ('start') or after ('end').

type
type: "ellipsis"

# PaginationItemPage

@kumiki/headless/pagination — page-list math for the Pagination component.

Pagination has no FSM and no DOM behavior beyond native button clicks. The non-trivial part is computing which page numbers to render given page, pageCount, siblingCount, boundaryCount. That math lives here as a pure function so consumers without Svelte (server renderers, tests) can use it directly.

Members

isCurrent
isCurrent: boolean
page
page: number
type
type: "page"
type Type Aliases 1
function Functions 1

# calculatePages ( )

calculatePages(__namedParameters): PaginationItem[]

Compute the page-list to render. Inserts ellipses where gaps appear.

``ts calculatePages({ page: 5, pageCount: 20 }) // → [1, …, 4, 5, 6, …, 20] ``

Parameters

\_\_namedParameters
CalculatePagesInput

Returns

PaginationItem[]