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

big-table

v1.2.0

Published

Big Table Component

Downloads

2

Readme

Big Table

Table of Content

Data Structure

Column Definition

Each element within fixedColDataKey and fluidColDataKey should be formed in following format:

Immutable.Map({
  key: String, // required
  label: String, // required
  width: Number, // required
  className: String, // To append Cell class name
  sortable: Boolean,
  adjustable: Boolean,
  render: Function<rowData: Immutable.Map>,
  renderHeader: Function<keyLabelMap: Immutable.Map>,
})

Components

Content

<Table>

Store sort key, and pass sorted data to children

<Table
  metaData: Immutable.Record,
  data: Immutable.List<Immutable.Map>
  // viewable width
  viewWidth: Number
  scrollLeft: Number

  widthPadding: Number // default 0
  rowHeightHeader: Number // default: 28
  rowHeightBody: Number // default: 20
  updateDataKey: Function<updater: Function<dataKey: Immutable.List<String>>>
  updateContentView: Function<param: Object({ height: Number })>

  sortKey: String // the current sorted column key
  sortOrder: Number // 1 or -1, 1 is ASC, -1 is Desc
  updateSort: Function<updater: Function<sortKey, sortOrder>>

  rowHeightFn: Function<rowData: Immutable.List<String>>
  rowModifier: Function<rowData: Immutable.List<String>>: Function<Row: ReactElement>
>

Example


<Table
  data={data}
  viewWidth={800}
  viewHeight={300}
  scrollLeft={0}
  metaData={metaData}
  updateDataKey={handleUpdateDataKey}
  updateContentView={handleContentView}
  rowHeightFn={handleRowHeight}
>

<WindowTable>

WindowTable is like Table, but it will be constraint by props viewHeight, and vertscroll poition will controlled by scrollTop

<WindowTable
  ...
  viewHeight: Number
  scrollTop: Number // between 0 and 1
  updateContentView: Function<updater: Function<height>>
>

Example


<WindowTable
  metaData={metaData}
  data={data}
  viewWidth={800}
  viewHeight={300}
  scrollTop={0}
  scrollLeft={0}
  updateDataKey={handleUpdateDataKey}
  updateContentView={handleContentView}
  sortFn={handleSorting}
  rowHeightFn={handleRowHeight}
>

Scrolling Control

<VerticalScroll>

A vertical scroll that listen parentNode's wheel event.

<VerticalScroll
  enableWheel: Boolean
  viewHeight: Number // viewable height
  contentHeight: Number // total height
  position: Number
  onScroll: Function<position: Number>
/>

Example

<VerticalScroll
  enableWheel={true}
  viewHeight={100}
  contentHeight={1000}
  position={0}
  onScroll={position => console.log(position)}
/>

<HorizontalScroll>

A horizontal scroll that listen parentNode's wheel event.

<HorizontalScroll
  enableWheel: Boolean
  viewWidth: Number // visable width (a.k.a remain viewable width) = viewable width - fixed columns width
  contentWidth: Number //total width (don't count fixed column width)
  position: Number
  onScroll: Function<position: Number>
/>

Example

<HorizontalScroll
  enableWheel={true}
  viewWidth={100}
  contentWidth={1000}
  position={0}
  onScroll={position => console.log(position)}
/>

Low-level Components

<TableHeader>

A component which store how to sort data, adjust width and custom render info.

<TableHeader
  metaData: Immutable.Record

  scrollLeft: Number

  viewWidth: Number // viewable width
  widthPadding: Number

  rowHeight: Number
  sortKey: String
  sortOrder: Number

  updateSort: Function<param: Object({ sortKey: String, sortOrder: Number })>
  updateDataKey: Function<dataKey: Immutable.List<String>>
/>

Example

<TableHeader
  viewWidth={viewWidth}
  metaData={metaData}
  scrollLeft={scrollLeft}
  sortKey={sortKey}
  sortOrder={sortOrder}
  updateSort={this.updateSort}
  updateDataKey={this.updateDataKey}
/>

<Row>

A component which adjust width for each, calculate width for FixedCol, adjust the left offset of Col and redner all cells and pass those data to Col and FixedCol.

<Row
  metaData: Immutable.Record
  data: Immutable.Map
  offset: Number
  width: Number
  widthPadding: Number
  height: Number
  style: Object
  modifier: Function<data: Immutable.List<String>>: Function<Row: ReactElement>
/>

Example

<Row
  width={containerWidth}
  metaData={metaData}
  data={data}
/>

<Rows>

The main difference between Rows and Row is that Rows will wrap all row into a col, which make is horiziontal scroll more efficiently.

In addition, Rows don't have modifier, but it has rowHeightFn to control individual row height.

<Rows
  data: Immutable.List<Immutable.Map>
  metaData: Immutable.Record,
  offset: Number
  width: Number
  widthPadding: Number
  height: Number
  style: Object
  rowHeightFn: Function<data: Immutable.Map>: Number
/>

Example

<Rows
  width={containerWidth}
  metaData={metaData}
  data={data}
/>

<FixedCol>

A component which group all cell which is fixed.

<FixedCol
  left: Number
  width: Number
  height: Number
  addShadow: Boolean
>
  {ReactElement}
</FixedCol>

<Cell>

A component which make all content styled.

Default style:

display: inline-block;
vertical-align: top;
white-space: normal;
position: absolute;
overflow: hidden;
<Cell
  widthPadding: Number
  left: Number
  width: Number
  height: Number
  className: String
>
  {ReactElement}
</Cell>

Miscellaneous

<AutoSizer>

A component which get available width / height.

We copy the implement from https://github.com/bvaughn/react-virtualized/blob/master/source/AutoSizer/AutoSizer.js

<AutoSizer
  onResize: Function<size: Object({ height: Number, width: Number })>
>
  ....
</AutoSizer>

Example

<AutoSizer onResize={this.handleResize}>
  <Table
    viewWidth={viewWidth}
    viewHeight={viewHeight}
    ...
  />
</AutoSizer>

<KeySorter>

<KeySorter
  dataKey: Immutable.List<String>
  onChange: Function<dataKey: String>
/>

Development

Setup:

$ yarn

Run:

$ npm run start

And open storybook with browser: http://localhost:9001/

Publish

$ npm publish

LICENSE

MIT