0.1.1-alpha1 • Published 6 years ago

@loganasherjones/beer-table v0.1.1-alpha1

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

Beer Table

dependencies Status peerDependencies Status Build Status Coverage Status NPM Status

Beer Table is a simple Material-UI table wrapper for server and client side:

  • filtering
  • sorting
  • pagination

NOTE: This package is currently in alpha and is subject to aggressive API changes.

Install

npm install @loganasherjones/beer-table --save

Demo

TODO: once this is deployed, add a link to CodeSandbox

Usage

For a simple table:

import BeerTable from 'beer-table';

const columns = [
    { name: 'Name', id: 'name' },
    { name: 'Age', id: 'age' },
]

const data = [
    { name: 'Alice', age: 28},
    { name: 'Bob', age: 30},
    { name: 'Charles', age: 21},
]

<BeerTable columns={columns} data={data} />

For a more advanced use-case, checkout the examples.

API

WARNING: The API is likely to change until I am out of alpha. You have been warned.

<BeerTable />

NameTypeRequiredDescription
dataarraytrueData to display, must be an array of objects.
columnsarraytrueColumn description. Must be an array of objects. See the columns below fore more information.
loadingbooleanfalseUsed to display a spinner while data is loading.
totalCountnumberfalseUsed to indicate the total number of rows, default is the data.length
filterCountnumberfalseUsed if filtering happens server-side. Indicates # of rows after filtering.
paginationobjectfalseUsed if pagination happens server-side. See info below.

columns

The columns help you customize a column's behavior. Options:

NameTypeRequiredDefaultDescription
namestringtrueN/AName of the column
idstringfalsecol.nameIdentifies a column, also used as the accessor in data
formatterfuncfalsenullFormat a value before it is displayed.
filterValuestringfalsenullSet a filter value by default.
customSortfuncfalsenullUsed to customize the way sorting works.
sortDirectionstringfalsenullSort direction for this column. Only options are: desc or asc
disableSortbooleanfalsefalseDisable sorting for this column.
defaultSortDirectionstringfalsedescOn the first click to sort, which direction to sort.
customMatchfuncfalsedefaultMatchA match function to use for filtering. See defaultMatch
filterEnumarrayfalsenullA list of possible values for the filter.
disableFilterbooleanfalsefalseDisable filtering on this column.
datetimebooleanfalsefalseDetermine if type of value is datetime.

pagination

The pagination can be used to customize the pagination displays.

NameTypeRequiredDefaultDescription
currentPageNumnumberfalse0What page number to start from.
rowsPerPageOptionsarrayfalse[10, 25, 50, 100]How many options for # of rows.
rowsPerPagenumberfalse10How many rows to show by default. Should be a member of rowsPerPageOptions

License

The files included in this repository are licensed under the MIT license

Road to Beta

I plan on getting all the following working before I make the API more stable.

FeatureClientServerMobile
Filtering:heavy_check_mark::x::x:
Sorting:heavy_check_mark::x::x:
Pagination:heavy_check_mark::x::x:
Loading:heavy_check_mark::heavy_check_mark::x:
Error:heavy_check_mark::heavy_check_mark::x:
Empty:heavy_check_mark::heavy_check_mark::x:
Column Width:x::x::x:
0.1.1-alpha1

6 years ago

0.1.0

6 years ago