Flop.Phoenix.Pagination (Flop Phoenix v0.25.3)
View SourceDefines a struct that holds the information needed to render a pagination component.
Summary
Types
@type t() :: %Flop.Phoenix.Pagination{ current_page: pos_integer() | nil, ellipsis_end?: boolean(), ellipsis_start?: boolean(), next_cursor: String.t() | nil, next_direction: :previous | :next, next_page: pos_integer() | nil, page_range_end: pos_integer() | nil, page_range_start: pos_integer() | nil, pagination_type: Flop.pagination_type(), path_fun: (pos_integer() | nil -> String.t()) | (String.t() | nil, :previous | :next -> String.t()), previous_cursor: String.t() | nil, previous_direction: :previous | :next, previous_page: pos_integer() | nil, total_pages: pos_integer() | nil }
Describes the data needed to render a pagination component.
For page-based pagination
current_pageellipsis_end?- Whether an ellipsis should be rendered between the middle pagination links and the link to the last page.ellipsis_end?- Whether an ellipsis should be rendered between the link to the first page and the middle pagination links.next_pagepage_range_start,page_range_end- The range for the links for individual pages.pagination_type- In the case of page-based pagination, this is either:pageor:offset.path_fun- 1-arity function that takes a page number and returns a path to that page that also includes query parameters for filters and sorting.previous_pagetotal_pages
For cursor-based pagination
next_cursor- The cursor to be used for the link to the next page. Depending on the value of thereverseoption, this is either the start cursor or the end cursor of theFlop.Metastruct.next_direction- The pagination direction for the link to the next page. If thereverseoption is set totrue, this will be:previous.pagination_type- In the case of cursor-based pagination, this is either:firstor:last.path_fun- 2-arity function that takes a cursor and a direction and returns a path to that page that also includes query parameters for filters and sorting.previous_cursor- The cursor to be used for the link to the previous page. Depending on the value of thereverseoption, this is either the start cursor or the end cursor of theFlop.Metastruct.
Functions
@spec new( Flop.Meta.t(), keyword() ) :: t()
Returns a Pagination struct for the given Flop.Meta struct.
Options
page_links- Defines how many page links to render. Only used for page-based pagination. Default:5.path- The path to the current page in the format as accepted byFlop.Phoenix.build_path/3. Default:nil.reverse- Reverses the position of the previous and next link. Only used for cursor-based pagination. Default:false.