1.3.0 • Published 1 year ago

react-bootstrap-table-control v1.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

React Bootstrap Table Control

This component facilitates the control and display of tables.

Install

npm install react-bootstrap-table-control

Usage

Component usage example.

TableControl

import 'bootstrap/dist/css/bootstrap.min.css';

import React, { useState, useEffect } from 'react';
import { TableControl } from 'react-bootstrap-table-control';

export default () => {
  return <TableControl
    header={[
      { key: "id", name: "#" },
      { key: "name", name: "Name" },
      { key: "description", name: "Description" }
    ]}
    itens={[
      { id: 1, name: "Name 1", description: "Description 1" },
      { id: 2, name: "Name 2", description: "Description 2" },
      { id: 3, name: "Name 3", description: "Description 3" },
      { id: 4, name: "Name 4", description: "Description 4" },
      { id: 5, name: "Name 5", description: "Description 5" }
    ]}
  />
}

You can see a interative component in Storybook.

Props

TableControl

NameTypeDefaultDescription
headerHeader[]-Required. List of header values
sortablebooleanfalseEnable sort action
onClickHeaderSort => anysort => console.log(sort)Header click function
sortSort{ column: 'id', direction: "ASC" }Sort direction
itensItem[]-Required. List of itens displayed in table
emptyMessageJSX.Element | string"No results"Message displayed when items equals zero
clikcablebooleanfalseShow clickable action
onClickItemItem => anyitem => console.log(item)Item click function
fillEmptyColumnbooleantrueCreate empty td if item is undefined
totalnumber0Total of itens
totalPosition"both" | "top" | "bottom" | "none""both"Total itens number
paginationbooleantrueShow pagination
pagenumber1Active page
limitnumber25Max itens per page, it's minimum value is itens length
betweennumber4Max itens in left and right when page is in center, it's minimum value is 1
ellipsisnumber1Number itens after ellipsis, its maximum value is equal (between - 2)
nextbooleantrueControl if prev and next actions will be displayed
lastbooleanfalseControl if fist and last actions will be displayed
onClickPagenumber => anypage => console.log(page)Pagination click function
isLoadingbooleanfalseLoading status
loadingLinesnumberlimitNumber of lines that will be displayed during loading
tablePropsobject{}table properties
theadPropsobject{}thead properties
trPropsobject{}thead tr properties
tbodyPropsobject{}tbody properties

Types

Sort

NameTypeDefaultDescription
columnstring-Required. Colum name sort
direction"ASC" | "DESC"-Sort direction

Header

NameTypeDefaultDescription
nameJSX.Element | string-Required. Header name
keystring-Required. Key name
sortboolean-Sortable column
thPropsobject-th properties

Item

NameTypeDefaultDescription
trType"default" | "blocked" | "clickable"When used into TableControl, this value is "default" if clickable is false, and "clickable" if clickable is trueType of item action
trPropsobject-tr properties
key: stringany | Td-Column value or Td type for a specific view

Td

NameTypeDefaultDescription
valueany-Required. Column value
tdPropsobject-td properties

Changelog

See full changelog in GitHub.

License

MIT