1.0.0 • Published 6 years ago

react-keyview v1.0.0

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

react-keyview

npm.io


Installation


via NPM

npm i react-keyview

via Yarn

yarn add react-keyview

via CDN (unpkg)

https://unpkg.com/react-keyview@latest

UMD library exposed as ReactKeyView

const KV = ReactKV;

Note. This package does not provide any stylesheet resources, the components are highly customizable. It is also supports Server-side rendering

Demos

Usage

You can import any component you want as a named export from 'react-keyview', eg.

import { Grid, Table } from "react-keyview";

Or you can directly import only the components you need, like so.

import Grid from "react-keyview/build/Grid";
import Table from "react-keyview/build/Table";

UMD modules has prefix ReactKV, eg.

const Grid = ReactKVGrid;
const List = ReactKVList;

List


function renderRow(rowIndex, currentIndex) {
  return <div>{rowIndex}</div>;
}

<List renderRow={this.renderRow} count={YOUR_DATA.length} visibleCount={5} rowHeight={50} />;
PropTypeDescription
renderRowFunctionRenders a single row
countNumberNumber of elements
rowHeightNumberRow height
visibleCountNumberThe visible elements count
domObjectPass attributes to an HTML element

Table


function renderHeader(item) {
  return item;
}
function renderRowColumn(i, j) {
  var getRowColumn = DATA[i][header[j]];
  return <td key={UNIQUE_KEY}>{getRowColumn}</td>;
}

function renderRow(rowIndex, currentIndex, col) {
  return <tr key={UNIQUE_KEY}>{col}</tr>;
}

<Table
  header={header}
  renderHeader={this.renderHeader}
  renderRow={this.renderRow}
  columnCount={3}
  count={YOUR_DATA.length}
  visibleCount={5}
  rowHeight={50}
  renderRowColumn={this.renderRowColumn}
/>;
PropTypeDescription
visibleCountNumberNumber of visible rows
countNumberNumber of rows
headerArrayMust be an array of strings
renderHeaderFunctionNumber of visible columns
renderRowFunctionRenders row
renderRowColumnFunctionRenders the columns of the row
domObjectPass attributes to an HTML element

Grid


function renderer({ rowIndex, columnIndex, yIndex, xIndex }) {
  return (
    <td key={UNIQUE_KEY}>
      Item {columnIndex},{rowIndex}
    </td>
  );
}

<Grid
  renderer={this.renderer}
  visibleRows={6}
  rowCount={100}
  rowWidth={30}
  columnCount={100}
  visibleColumns={6}
  columnHeight={50}
/>;
PropTypeDescription
columnCountNumberNumber of columns
visibleColumnsNumberNumber of visible columns
rowCountNumberNumber of lines
visibleRowsNumberNumber of visible rows
rendererFunctionDisplays the row and column
domObjectPass attributes to an HTML element