1.14.0 • Published 1 year ago

paginationbar v1.14.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

paginationbar

A modern pagination bar library for web app. See example here.

Features

  • Built-in themes(material, element) design and more.
  • Does not depend on any third-party library.
  • Support Typescript.

Installation

# pnpm
$ pnpm add paginationbar

# yarn
$ yarn add paginationbar

# npm
$ npm i paginationbar

Usage

  1. Import the style for themes.
// Include all themes (Not recommended)
import 'paginationbar/lib/style.css'

// Alternatively, you can import only a certain theme style (Recommended).
// material theme
import 'paginationbar/lib/themes/material/index.css'
// element theme
import 'paginationbar/lib/themes/element/index.css'
  1. Define a container.
<div id="pagination-bar-container"></div>
  1. Create a pagination bar instance.
import { createPaginationBar } from 'paginationbar'

const paginationBar = createPaginationBar({
  container: '#pagination-bar-container'
  // Some options ...
})

Options

PropTypeDefault valueAvailable valuesDescription
containerstring HTMLElement#pagination-bar-container-Specify this to change the container.
themestringmaterial-Specify this to change the theme.
backgroundbooleanfalse-Specify this to Add a background color to the pagination button.
hideOnSinglePagebooleanfalse-Hide when there is only one page.
prevTextstring''-Replace prev icon with custom text.
nextTextstring''-Replace next icon with custom text.
jumperPrefixTextstring'Go to'-Specify this to change the prefix text of the jumper control.
jumperSuffixTextstring''-Specify this to change the suffix text of the jumper control.
totalPrefixTextstring'Total'-Specify this to change the prefix text of the total control.
totalSuffixTextstring''-Specify this to change the suffix text of the total control.
firstPageNumbernumber1-Specify this to change the minimum page number of pagination bar.
pagerCountnumber7-Specify this to change the number of page number buttons that will collapse when the total number of pages exceeds this value.
currentPagenumber1-Initialize current page number.
pageSizenumber10-Initialize the number of displayed entries per page.
disabledbooleanfalse-Initialize the disabled status of pagination bar.
pageSizesnumber[][10,20,30,40,50,100]-Define options of sizes control.
sizesOptionLabel(size: number) => string--Customize the label content of sizes options.
totalnumber0-Initialize total number of entries.
layoutstring string[]prev,pager,nexttotal prev pager next jumper sizesSpecify this to change the layout of controls.
onCurrentPageChangeFunction--The callback function when the current page changes, passed in the currentPage as a parameter.
onPageSizeChangeFunction--The callback function when the page size changes, passed in the current pageSize as a parameter.

APIs

Instance methods

setCurrentPage

You can use this to change currentPage after pagination bar initialization. and it will return a safty page number.

paginationBar.setCurrentPage(2)

setPageSize

You can use this to change pageSize after pagination bar initialization. and it will also return a safty page size number.

paginationBar.setPageSize(20)

setTotal

You can use this to change total after pagination bar initialization.

paginationBar.setTotal(500)

disabled

Pagination bar can be manually deactivated using the disabled() method.

paginationBar.disabled(true) // deactivated
paginationBar.disabled(false) // activated

destory

Destroys the pagination bar instance. For example, event listeners and so on.

paginationBar.destory()

render

Manually re-render.

paginationBar.render()

CHANGE LOGS

See CHANGE LOG.

1.14.0

1 year ago

1.13.1

2 years ago

1.13.0

2 years ago

1.12.0

2 years ago

1.11.1

2 years ago

1.11.0

2 years ago

1.10.0

2 years ago

1.9.0

2 years ago

1.8.0

2 years ago

1.7.0

2 years ago

1.6.0

2 years ago

1.5.0

2 years ago

1.4.0

2 years ago

1.3.0

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago