0.2.13 • Published 12 months ago

react-table-factory v0.2.13

Weekly downloads
2
License
MIT
Repository
github
Last release
12 months ago

react-table-factory

A set of table factory decorators to easily implement table components inside user projects.

Demo

table HoC

A HoC to implement table components with a set of overridable options.

optiondefaultdescription
rowRendererDefaultRowRenderertable row component
cellRendererDefaultCellRenderertable tbody cell component
dataRowRendererDefaultDataRowRenderertable tbody row implementation
dataCellRendererDefaultDataCellRendererwrapper around tbody cell content
headerCellRendererDefaultHeaderCellRenderertable thead cell component
headerCellContentRendererDefaultHeaderCellRendererwrapper around thead cell content
headerRendererDefaultHeaderRenderertable thead component
columns[]array of column configurations.

columns config

nametypedescription
cell (optional)Component {data, index, rowIndex, table props that are not used for HoC implementation}Component to render a table cell
header (optional)Component {table props that are not used for HoC implementation}Component to render a header cell
name (optional)stringColumn key

Simple example:

import { table } from 'react-table-factory';

...
const Table = table();

const columns = [
	{
		name: "attr1"
	},
	{
		header: (props) => "Attr custom component",
		cell: ({data, ...props}) => (
			<span>Custom output {data["attr2"]}</span>
		)
	},
];
...

const MyComponent = ({data, ...props}) => (
	<Table
		data={data}
		columns={columns}
		{...props} // props that will be propagated to cells.
	/>
)

Decorators

A set of decorators around table factory.

Some components can use css. Corresponding files should have the same base name. (i.e withFixedHeader.css).

name (css) (remarks)options(=defaults)Table props:column configdescription
withFixedHeader (true)Creates 2 Tables to implement a fixed header and a scrollable table content. Since it creates 2 tables, any decorators with context wrappers around table should NOT be wrapped by this component.
withInlineDetailsContext (false){selectionReducer, tabIndex, clearOnDataChange, isSelectable, keyFactory}{detailsRenderer, clearOnDataChange}:{}Wraps Table with selectionContext. Implemented selectionReducers are singeSelectionReducer and multiSelectionReducer.
withClickableRowContext (false){tabIndex, isClickable}{onRowClick}:{}Wraps Table with ClickableRowContext. Provides capabilities for row clicking.
withLazyLoading (false){Loading = ()=>'Loading', threshold=50, NoDataComponent}{fetch, fetching=false, fetchable=true}:{}Decorator around withFixedHeader table decorator. When fetching prop is set to true, show Loading component after table contents. If fetch != null, fetching=false, fetchable=true and the container is scrolled to bottom (taking threshold into account) fetch is called once.
withSortingContext (true){defaultDirection, sortFactory, inMemory = false, sortableContextHoc}{onSort, sortDirection='asc', sortParameter}:{sortable,name}Wraps Table with SortableContext. Provides a Sorter Component to implement custom sorting elements. If a name option of column config is an array, the one from Table props will be used, otherwise the first elem will be used.
withInMemorySortingContext (true){defaultDirection, sortFactory}{ onSort, defaultSortParameter, defaultSortDirection= 'asc'}:{sortable,name}An overload wrapper for withSortingContext to provide in-memory sorting.
withAdaptive (true) (will change){Component}{}:{removeAdaptiveColname, hideAdaptive, hideFullSize}Injects a Component inside each cell. Adaptive layout should be handled using CSS rules.
withHeaderControl (false) (will change){}:{control}Adds 1 to colspan of each cell previous to column with controll. This component is used when you want to create an element in header, but doesn't effect the tbody cell layout.
withHeaderCellOverflow (true){}:{removeOverflowWrapper}Adds a set of wrapper around header cell contents. Overflow should be handled using css.
withEmptyRow (false){isEmpty = (rowProps)=>false, Component, classNameFactory = (dataRowProps)=>'empty-row'}:{}Provides capabilities to implement empty td that spans the whole row

TODO

  • Add ColGroup Component.
  • Add tbody renderer option to table hoc.
  • Create decorator to add virtualization to withFixedHeader.
  • Remove withHeaderControl for a more flexible decorator.
  • Create user guide to create new decorators and use existing.
  • Use react router for more usage examples.
0.2.13

12 months ago

0.2.11

5 years ago

0.2.10

5 years ago

0.2.9

5 years ago

0.2.8

5 years ago

0.2.7

5 years ago

0.2.6

5 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.31

5 years ago

0.1.30

5 years ago

0.1.29

5 years ago

0.1.28

5 years ago

0.1.27

5 years ago

0.1.26

5 years ago

0.1.25

5 years ago

0.1.24

5 years ago

0.1.23

5 years ago

0.1.22

5 years ago

0.1.21

5 years ago

0.1.20

5 years ago

0.1.19

5 years ago

0.1.18

5 years ago

0.1.17

5 years ago

0.1.16

5 years ago

0.1.15

5 years ago

0.1.14

5 years ago

0.1.13

5 years ago

0.1.12

5 years ago

0.1.11

5 years ago

0.1.10

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago