Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
ultimate-pagination
Advanced tools
[![ultimate-pagination logo](https://raw.githubusercontent.com/ultimate-pagination/logo/master/ultimate-pagination-250x250.png)](https://github.com/ultimate-pagination/ultimate-pagination)
Universal pagination model generation algorithm that can be used to build a UI component for any JavaScript based platform/framework. The idea behind this module is to move the logic of creating pagination out of the component and place it in a separate module. It allows reusing the same code across different frameworks like Angular, Angular2, React, Ember, etc. Also, the same code can be used to generate pagination on server-side JavaScript frameworks.
Here is a list of modules that uses ultimate-pagination to implement pagination components with different frameworks:
You can install this module via npm:
npm install ultimate-pagination --save
The main method of ultimate-pagination module is getPaginationModel(options)
. It accepts an object with currentPage
and totalPages
properties:
var ultimatePagination = require('ultimate-pagination');
var paginationModel = ultimatePagination.getPaginationModel({
currentPage: 5,
totalPages: 10
});
As a result getPaginationModel(options)
returns an array of items that can be used to render a pagination component:
[
{
type: ITEM_TYPES.FIRST_PAGE_LINK,
key: ITEM_KEYS.FIRST_PAGE_LINK,
value: 1,
isActive: false
},
{
type: ITEM_TYPES.PREVIOS_PAGE_LINK,
key: ITEM_KEYS.PREVIOS_PAGE_LINK,
value: 4,
isActive: false
},
{
type: ITEM_TYPES.PAGE,
key: 1,
value: 1,
isActive: false
},
{
type: ITEM_TYPES.ELLIPSIS,
key: ITEM_KEYS.FIRST_ELLIPSIS,
value: 3,
isActive: false
},
{
type: ITEM_TYPES.PAGE,
key: 4,
value: 4,
isActive: false
},
{
type: ITEM_TYPES.PAGE,
key: 5,
value: 5,
isActive: true
},
{
type: ITEM_TYPES.PAGE,
key: 6,
value: 6,
isActive: false
},
{
type: ITEM_TYPES.ELLIPSIS,
key: ITEM_KEYS.SECOND_ELLISPIS,
value: 7,
isActive: false
},
{
type: ITEM_TYPES.PAGE,
key: 10,
value: 10,
isActive: false
},
{
type: ITEM_TYPES.NEXT_PAGE_LINK,
key: ITEM_KEYS.NEXT_PAGE_LINK,
value: 6,
isActive: false
},
{
type: ITEM_TYPES.LAST_PAGE_LINK,
key: ITEM_KEYS.LAST_PAGE_LINK,
value: 10,
isActive: false
}
]
In this example ITEM_TYPES
and ITEM_KEYS
can be imported from ultimate-pagination module, and they contain constants used in the output of the pagination model.
All item has the same structure:
ITEM_TYPES
key
in React, track by
in Angular)PAGE
it also can be used as a label in UI)currentPage
if the same as value
of an item (can be used to highlight a current page or disable first, previous, next or last page links when user is already on first/last page)Here is a list that contains all available ITEM_TYPES
:
PAGE
- a link to a pageELLIPSIS
- an item that represents groups of pages that currently are not visible in paginator (can be used to navigate to the page in the group that is the nearest to the current page)FIRST_PAGE_LINK
- a link to the first pagePREVIOS_PAGE_LINK
- a link to the previous pageNEXT_PAGE_LINK
- a link to the next pageLAST_PAGE_LINK
- a link to the last pageFAQs
Universal pagination model generation algorithm that can be used to build a UI component
The npm package ultimate-pagination receives a total of 18,879 weekly downloads. As such, ultimate-pagination popularity was classified as popular.
We found that ultimate-pagination demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.