npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

paginationbar

v1.14.0

Published

A modern pagination bar library for web app.

Downloads

28

Readme

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

| Prop | Type | Default value | Available values | Description | | :---: | :---: | :---: | :---: | :---: | | container | string HTMLElement | #pagination-bar-container | - | Specify this to change the container. | | theme | string | material | - | Specify this to change the theme. | | background | boolean | false | - | Specify this to Add a background color to the pagination button. | | hideOnSinglePage | boolean | false | - | Hide when there is only one page. | | prevText | string | '' | - | Replace prev icon with custom text. | | nextText | string | '' | - | Replace next icon with custom text. | | jumperPrefixText | string | 'Go to' | - | Specify this to change the prefix text of the jumper control. | | jumperSuffixText | string | '' | - | Specify this to change the suffix text of the jumper control. | | totalPrefixText | string | 'Total' | - | Specify this to change the prefix text of the total control. | | totalSuffixText | string | '' | - | Specify this to change the suffix text of the total control. | | firstPageNumber | number | 1 | - | Specify this to change the minimum page number of pagination bar. | | pagerCount | number | 7 | - | Specify this to change the number of page number buttons that will collapse when the total number of pages exceeds this value. | | currentPage | number | 1 | - | Initialize current page number. | | pageSize | number | 10 | - | Initialize the number of displayed entries per page. | | disabled | boolean | false | - | Initialize the disabled status of pagination bar. | | pageSizes | number[] | [10,20,30,40,50,100] | - | Define options of sizes control. | | sizesOptionLabel | (size: number) => string | - | - | Customize the label content of sizes options. | | total | number | 0 | - | Initialize total number of entries. | | layout | string string[] | prev,pager,next | total prev pager next jumper sizes | Specify this to change the layout of controls. | | onCurrentPageChange | Function | - | - | The callback function when the current page changes, passed in the currentPage as a parameter. | | onPageSizeChange | Function | - | - | 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.