0.1.23 • Published 6 years ago

sussol-react-table v0.1.23

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

Build Status

sussol-react-table

A wrapper and simple API for using the blueprintjs data table

Installation

yarn add sussol-react-table

or

npm install sussol-react-table

Added Options

PropTypeDescription
cellAutoHeightObject \| BooleanDefaults to false. If true, or an object of options is provided, the table will adjust the <Cell /> height to fit the length of the content. Use with wrapText: true inside coreCellProps for best results with no truncation.
cellDataKeyStringPass a key (object property) from your table data set as a string. The data's key will be used to access a value the unique key. Good for selecting the table row and loading a corresponding component, based on the selected key. e.g. { ... code: 123456789, ...}
columnsArray[{ key: String, title: String, ?sortable: Boolean, ?align: "left\|center\|right" }] Column headers for the table.
coreCellPropsObjectPass any core Blueprint <Table /> props through.
tableDataArray[{ any }] Must contain at least the valid columns keys.
defaultColumnAlignString"left\|center\|right" The CSS text alignment for all table cells. Defaults to "left". A column's align key takes precedence.
defaultSortKeyStringThe default column key for sorting the table data. If no key is set, nothing is done. Be sure your data already exists when the component initialises (i.e. {this.state.data.length && ...).
defaultSortOrderString"asc\|desc" If defaultSortKey is set, determines the default column sort direction on initialisation. Defaults to "asc".
coreEditableCellPropsObjectAn object of Blueprint <EditableCell /> props to pass through. All handler functions will be passed value: String, row: Number, { column:Number, columnKey:String }:Object, which differs slightly from the default implementation options.
loadingRowCountNumberIf set, table will show the core loading state for rows/cells equal to the value of loadingRowCount. Defaults to 0.

NOTE:

  • All other blueprintjs Table props are passed to its root <Table /> component.

Usage

import React from 'react';
import { SussolReactTable } from 'sussol-react-table';

const columns = [
  {
    key: 'name',
    title: 'Name',
    sortable: true,
  },
  {
    key: 'code',
    title: 'Code',
    sortable: true,
  },
  {
    key: 'group',
    title: 'Editable Column',
    editable: true,
  },
];

const data = [];
for (let i = 0; i < 100; i++) {
  data.push({ code: `code${i}`, name: `name${i}`, group: `group${i % 2}` });
}

export class App extends React.Component {
  render() {
    return (
      <div style={{ height: 400 }}>
        <h1>A Beautiful table</h1>
        <SussolReactTable
          columns={columns}
          tableData={data}
          cellDataKey="code"
        />
      </div>
    );
  }
}

Required style dependencies

You will need include the following styles via your index.html (or by bundling them). Make sure the path to styles is correct.

  • path/to/node_modules/@blueprintjs/core/dist/blueprint.css
  • path/to/node_modules/@blueprintjs/table/dist/table.css
  • path/to/node_modules/normalize.css/normalize.css (good for resetting to safe, base styles for most all browsers)

Testing locally via another project

  1. From inside sussol-react-table run yarn build
  2. From your project run yarn add file:path/to/sussol-react-table
  3. Run your project

Additional docs

Read up on the API for the blueprintjs table component.

1.0.0-beta1

6 years ago

1.0.0-beta

6 years ago

0.1.23

6 years ago

0.1.22

6 years ago

0.1.21

6 years ago

0.1.20

6 years ago

0.1.19

6 years ago

0.1.18

6 years ago

0.1.17

6 years ago

0.1.16

6 years ago

0.1.15

6 years ago

0.1.14

6 years ago

0.1.13

6 years ago

0.1.12

6 years ago

0.1.11

6 years ago

0.1.10

7 years ago

0.1.9

7 years ago

0.1.8

7 years ago

0.1.7

7 years ago

0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago