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

react-common-table

v0.9.5

Published

React Common Table - Pagination, editable cells, formulae, column groups, cells merging, etc.

Downloads

14

Readme

react-common-table

React common table component.

NPM version build status Test coverage npm download

install

react-common-table

Development

npm install
npm run start

Examples

https://kylqin.github.io/react-common-table

Usage

Try it on codesandbox.io

API

Properties

headers

type: array default: required

The table headers, an item for a column. The struct of the column object is:

{
  // [requred] column key
  colName: string
  // [requred] column title
  name: string,
  // [optional] column width, in px
  width: number,
  // [default: 'left'] cell content horizontal align, will be ignored
  // if formatter exists
  alighH: ['left'|'rihgt'|'center'|'justify'],
  // [default: 'top'] cell content vertical align, will be ignored if
  // formatter exists
  formatter: (cell, onChange) => cellElement,
  // [optional] The values of cells of this column is calcuted by this
  // formula if it exists. the params, are the colName's of other
  // columns.
  fomula: ['param1', 'param2', ..., (param1, param2) => cellValue],
  // [optional] if exist, this column is a group and the width and
  // formmater will be ingnored. The sub is an array of columns.
  sub: array
}

rows

type: array default: []

The table rows, an item for a row. the item object has keys which are colName's, and a special key sub, and some special keys starting with _, such as _fommater, etc:

{
  // key is the colName of column defined in headers
  (key: value)...,
  // [optional] If exists, this row will branch out sub rows
  // and some cells of the row will be merged-like or have
  // a spaning-multiple-rows effect (`rowspan > 1`).
  sub: array,
  // [optional] (props, onChange) => cellElement, will
  // replace column formatter if exists.
  _formatter: function
}

pagination

type: Object default: undefined

Pagination of the table. If the property is not set, the table has no pagination.

{
  // [default: false] fetch rows synchronously or asynchronously
  sync: Bool,
  // [default: 0]
  pageIndex: number,
  // [default: 10] how many rows each page
  pageSize: number,
  // [readonly] hwo mny pages
  totalPage: number,
  // [required if sync is false] how may recoreds or total rows
  totalRecord: number,
  // [default: [10, 20, 50, 100]], array of page sizes
  sizeList: array,
  // [({ pageIndex, pageSize, }) => rows }] request rows when
  // sync is false
  requestRows: function
}

frozenLeft

type: _string default: undefined

The colName of the rightmost column of the left frozen columns.

frozenRight

type: _string default: undefined

The colName of the leftmost column of the right frozen columns.

frozenTop

type: integer default: undefined

The index of the bottommost row of the top frozen rows.

frozenBottom

type: integer default: undefined

The index of the topmost row of the bottom frozen rows.

tableHeight

type: number default: undefined

Table heigth in px. When tableHeight is set, the table header is frozen(fixed to top).

enableLineNumber

type: bool default: false

Show line number column.

enableSelectRows

type: bool default: false

Show "select rows" (checkbox) column.

showSelectedRowsCount

type: bool or function default: false

Enable to show selected rows count message. Or use the function the generated the message.

Integer => String

i18nLan

type: string default: 'en_US' i18n language. 语言, 国际化.

onCellChange

type: function default: undefined

Callback called after cells contents changed.

(Cell, UpdatePack|Value) => Promise

onHeaderChange

type: function default: undefined

Callback called after header cells contents changed.

(ColCell, UpdatePack|Value) => Promise

Methods (on ref)

rows

type: () => arrays

Get The rows array of current page.

pagination

type: () => Object

Get The pagination object.

License

react-common-table is released under the ISC license.