React-Tabulous 🎉
Installation
To use in your own project, install it via npm package.
npm i @syook/react-tabulous
Or you can clone and build it.
git clone git@github.com:syook/react-tabulous.git
npm run build
The files will be under ./lib
folder.
Options
a. Available Column Options
Option | Description | Type | isRequired | Default |
---|---|---|---|---|
headerName |
Name of Column to be shown in header | String | true | |
field |
field name as in the data | String | true | |
type |
type of the field | String | true | |
cell |
returns the value to be shown in the column cell | Function | true | |
isSortable |
is column sortable | Boolean | false | |
isSearchable |
is column searchable | Boolean | false | |
isFilterable |
is column filterable | Boolean | false | |
omitInHideList |
should the column be omitted in table and show/hide dropdown | Boolean | false | |
options |
array of options if the type is MultiSelect or Single Select | Array | false | [] |
b. Action Config Options : actions will be shown in action column in table
Option | Description | Type |
---|---|---|
isVisible |
Function which returns if the action is visible or not | Function |
isDisabled |
Function which returns if the action is disabled or not | Function |
function |
Function to be executed on action event | Function |
icon |
Icon name to represent the action | Function |
name |
Name of action | string |
color |
color of action component | string |
iconColor |
color of icon | string |
size |
size of icon | string |
inverted |
to enable inverted behaviour of action element | function |
iconInverted |
to enable inverted behaviour of icon | boolean |
className |
any custom classname to be applied for action element | string |
iconClassName |
any custom classname to be applied for icon | string |
hasCustomComponent |
if the action is any custom component other than button | boolean |
customComponent |
the component that needs to returned if the action has custom component | function |
c. Available Types
Type | Filter queries available | Extra props needed |
---|---|---|
String |
contains, does not contains, is, is not, is empty, is not empty | |
Date |
is, is not, is after, is before, is empty, is not empty | |
Number |
=, =/ , < , <=, > , >= , is empty, is not empty | |
SingleSelect |
has any of, has none of, is empty, is not empty | options: [] |
MultiSelect |
is, is not, is empty, is not empty, | options: [] |
Example
... ;; ... { console;}; { console;}; { console;}; { console;}; columnDefs = headerName: 'Name' field: 'name' type: 'String' <Input value=rowObjectname onChange= this /> isSortable: true isSearchable: true isFilterable: true headerName: 'Description' field: 'description' type: 'String' rowObjectdescription isSortable: true isSearchable: true isFilterable: true isResizable: true headerName: 'Category' field: 'category' type: 'SingleSelect' rowObjectcategory options: 'Grocery' 'Electronics' 'Home' 'Shoes' 'Computers' 'Outdoors' 'Clothing' isSortable: true isSearchable: true isFilterable: true headerName: 'Price' field: 'price' type: 'Number' rowObjectprice isSortable: true isSearchable: true isFilterable: true isResizable: true headerName: 'Expertise' field: 'isExpertised' type: 'Boolean' rowObjectisExpertised ? 'Yes' : 'No' isSortable: true isSearchable: false isFilterable: true headerName: 'Availability' field: 'availability' type: 'MultiSelect' rowObjectavailability options: 'Yes' 'No' 'Maybe' isSortable: true isSearchable: false isFilterable: true headerName: 'Started at' field: 'created' type: 'Date' isSortable: true isSearchable: false isFilterable: true isResizable: true ; false; actionDefs = name: 'Show' true thisupdatingObjectId === rowObject'id' || rowObject'_id' thisupdatingObjectId === rowObject'id' || rowObject'_id' function: thisonShow icon: 'eye' color: '#85C1E9' name: 'Delete' !rowObjectisDeleted thisupdatingObjectId === rowObject'id' || rowObject'_id' thisupdatingObjectId === rowObject'id' || rowObject'_id' this icon: 'trash' color: '#E8515D' ; bulkActionDefs = action: 'delete' function: thisonDelete ; <> <Button disabled size="small" onClick= null> Button 1 </Button> <Button onClick= null>Button 2</Button> </>; ... <ReactTabulous actionDefs=thisactionDefs bulkActionDefs=thisbulkActionDefs data=thisstatedata || includeAction=true mandatoryFields='Name' name='Table Name' columnDefs=thiscolumnDefs> thiscustomComponents</ReactTabulous> ...
Contributing Guidelines
Please refer CONTRIBUTING.md