Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@czkoudy/pagination-table

Package Overview
Dependencies
Maintainers
0
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@czkoudy/pagination-table

Pagination for tables

  • 4.14.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
125
increased by76.06%
Maintainers
0
Weekly downloads
 
Created
Source

@czkoudy/pagination-table

React functional component for turning ordinary tables into Pagination Data Tables

NPM JavaScript Style Guide

Downloads

🦸 Looking for contributors

I am looking for contributors who can move this project further.
I would like to work with someone to learn more about Javascript and Typescript, React
and how to work closely with a team.

⚙️Install

npm install --save @czkoudy/pagination-table

📓Usage

import PaginationTable from '@czkoudy/pagination-table';

const data = [{ id: 5 }, { id: 6 }];
const header = [{ label: 'ID' }];
const body = [{ key: 'id' }];

return <PaginationTable data={data} header={header} body={body} />;

🗳️4.3.0-beta Release

🔧Breaking Changes

  • rename sortable to sort in options object

🔥Improvements

  • 🆕 - stayOnPage in options to stay on the same page after data refresh
  • 🆕 - slowly moving to TypeScript
  • 🆕 - table now can have title - options.tableTitle

Changes in 3.7.0

[Fix] - selection has been redone [New] - Added option to select all on a page [New] - Search input is aligned to the right

const options = {
  //rest of options
  selection: {
      key: '_id',
      buttons: [
        {
          component: Button,
          props: {
            onClick: handleOnButtonClick,
            label: 'Delete Selected',
          },
        },
      ],
    },
}

Changes in 3.6.1

[New] - body option useWholeObject - this will return whole object to set function rather than single field - key and function fields are required

Changes from 3.3.0

[Fix] - sorting was ignoring casing [New] - show page length menu

const options = {
    lengthChange:  true, //default false
    lengthMenu:  Array[] // default [5, 10, 15, 20],
}

const options = {
    selection: {
      buttons: [ // Array of object for buttons to be visible
        {
          label: "",
          onClickFunction: () => function() // function will receive an array of keys defined in selection.key
          className: "", // className for button
        }
      ]
    }
}
New option in sortable settings
excludeColumns: Array[] // default [], array of indexes of columns to exclude

Changes from 3.2.5

[New] - debug option in options object, default: false

[Fix] - added fields to search objects

  • colums - array of column indexes to be included in search, default string "all"

Changes from 3.2.0

  • now exports PaginationTable as well as usePaginationTable hook

Breaking changes from 3.0.1

  • PaginationTable now uses hooks

  • onRowClick moved to options object

Additional changes from 3.0.1

  • support for row selection

Breaking changes in 2.0.0

Now there is options object passed in rather then individual properties.

default: false

// Adding CSS class for input field

search: {
    className: ""
}

sortable

default: false

sortable: {
    column: Integer // index of default column order
  direction: String // 'asc' or 'des'
}

info

default: false

emptyRows

default: false

perPage

default: 10

pagination

default: null

className

default: ""

CSS class for the whole table

All constants are arrays with objects.

API

PaginationTable props

NameTypeRequiredDefault
dataArray[]Yes-
headerArray[]Yes-
bodyArray[]Yes-
optionsArray[]Nosee below

options props

| Name | Type | Required | Default | Description | | ------------------------- | ----------------- | -------- | ------------ | -------------------------------------------------- | --- | | perPage | Int | No | 10 | | emptyRows | Boolean | No | false | | lengthChange | Boolean | No | false | | lengthMenu | Array[] | No | [5,10,15,20] | | info | Boolean | No | true | | search | Boolean or Object | No | false | | search.columns | Array or String | No | "all" | Array of indexes of columns to search within | | search.className | String | No | false | ClassName for search input | | sort | Boolean or Object | No | false | | sort.column | Int | No | 0 | Index of default column to sort by | | sort.direction | String | No | "asc" | "asc" or "desc" | | sort.excludeColumns | Array | No | [] | Array of columns indesx to exclude sorting for | | onRowClick | Object | No | {} | | onRowClick.function | Function | No | {} | function to be actioned on click on row | | onRowClick.key | String | No | "id" | Key to be passed to function | v | | onRowClick.excludeColumns | Array | No | null | Array of columns indesx to exclude from onRowClick | | loading | Object | No | {} | | loading.component | React.Component | No | null | | loading.text | String | No | "Loading" | | debug | Boolean | No | false | Logging to console progress of PaginationTable |

header props

NameTypeRequiredDefaultDescription
labelIntNo10
widthBooleanNofalse

header props

NameTypeRequiredDefaultDescription
labelStringYes-
widthStringNo-String with pixel width

body props

NameTypeRequiredDefaultDescription
keyStringYes-
dateStringNo-this is using format() from date-fns module. See more at date-fns
functionFunctionNo-referencing function which will have key as its argument
componentComponentNo-will wrap the key in the Component
useDotBooleanNoTrueallows to dive into objects with dot notation
componentComponentNo-will wrap the key in the Component
componentComponentNo-will wrap the key in the Component

License

MIT © czkoudy

Keywords

FAQs

Package last updated on 23 Oct 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc