Compare commits

..
6 Commits
Author SHA1 Message Date
Tanner Linsley dd433f7d9c 3.2.1 2017-01-09 13:44:46 -07:00
Tanner Linsley 0daffaf08d Fixed paginationComponent and paginationClassName
Fixes #24 and fixes #25
2017-01-09 13:44:43 -07:00
Tanner Linsley ecd660ef10 3.2.0 2017-01-09 11:57:51 -07:00
DimitryandTanner Linsley be951a3252 onTrClick (#23)
* README: correct watch command

* Add onTrClick handler

* react soften peerDependency: ^15.x.x
2017-01-09 11:38:22 -07:00
Lukas Gisder-DubéandTanner Linsley f195b3243d added props for more pagination customization (#19) 2016-12-15 07:02:25 -07:00
Tanner LinsleyandGitHub 19a0187720 Update README.md 2016-12-08 11:59:46 -07:00
5 changed files with 31 additions and 14 deletions
+9 -5
View File
@@ -2,13 +2,13 @@
<a href="https://github.com/tannerlinsley/react-table"><img src="https://github.com/tannerlinsley/react-table/raw/master/media/Banner.png" alt="React Table Logo" style="width:450px;"/></a>
<br />
<br />
</div>
# react-table
A fast, lightweight, opinionated table and datagrid built on React
[![Build Status](https://travis-ci.org/tannerlinsley/react-table.svg?branch=master)](https://travis-ci.org/tannerlinsley/react-table) [![npm](https://img.shields.io/npm/dm/react-table.svg)]() [![react-table on Slack](https://img.shields.io/badge/slack-react--table-blue.svg)](https://react-table-slack.herokuapp.com/) [![GitHub stars](https://img.shields.io/github/stars/tannerlinsley/react-table.svg?style=social&label=Star)]() [![Twitter Follow](https://img.shields.io/twitter/follow/tannerlinsley.svg?style=social&label=Follow)](https://twitter.com/tannerlinsley)
[![Build Status](https://travis-ci.org/tannerlinsley/react-table.svg?branch=master)](https://travis-ci.org/tannerlinsley/react-table) [![npm](https://img.shields.io/npm/dm/react-table.svg)](https://npmjs.com/packag/react-table) [![react-table on Slack](https://img.shields.io/badge/slack-react--table-blue.svg)](https://react-table-slack.herokuapp.com/) [![GitHub stars](https://img.shields.io/github/stars/tannerlinsley/react-table.svg?style=social&label=Star)](https://github.com/tannerlinsley/react-table) [![Twitter Follow](https://img.shields.io/twitter/follow/tannerlinsley.svg?style=social&label=Follow)](https://twitter.com/tannerlinsley)
## Features
@@ -96,10 +96,14 @@ These are the default props for the main react component `<ReactTable />`
// Callbacks
onChange: (state, instance) => null, // Anytime the internal state of the table changes, this will fire
onTrClick: (row, event) => null, // Handler for row click events
// Text
previousText: 'Previous',
nextText: 'Next'
nextText: 'Next',
pageText: 'Page',
ofText: 'of',
rowsText: 'rows',
// Classes
className: '-striped -highlight', // The most top level className for the component
@@ -287,7 +291,7 @@ If you would like to help develop a suggested feature follow these steps:
- Fork this repo
- `npm install`
- `npm watch`
- `npm run watch`
- Implement your changes to files in the `src/` directory
- Submit PR for review
@@ -297,7 +301,7 @@ If you would like to preview your changes, you can link and utilize the example
- `cd example`
- `npm install`
- `npm link react-table`
- `npm watch`
- `npm run watch`
- Make changes to the example in `src/screens/index.js` if needed
- View changes at `localhost:8000`
+1 -1
View File
@@ -3,7 +3,7 @@ import _ from 'lodash'
import namor from 'namor'
import CodeHighlight from 'components/codeHighlight'
import ReactTable from 'react-table'
import ReactTable from '../../../lib/index'
export default Component({
render () {
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "react-table",
"version": "3.1.4",
"version": "3.2.1",
"description": "A fast, lightweight, opinionated table and datagrid built on React",
"license": "MIT",
"homepage": "https://github.com/tannerlinsley/react-table#readme",
@@ -35,7 +35,7 @@
"classnames": "^2.2.5"
},
"peerDependencies": {
"react": "^15.3.1"
"react": "^15.x.x"
},
"devDependencies": {
"babel-cli": "6.14.0",
+13 -1
View File
@@ -16,6 +16,7 @@ export const ReactTableDefaults = {
showPageJump: true,
// Callbacks
onChange: () => null,
onTrClick: () => null,
// Classes
className: '-striped -highlight',
tableClassName: '',
@@ -54,6 +55,9 @@ export const ReactTableDefaults = {
previousText: 'Previous',
nextText: 'Next',
loadingText: 'Loading...',
pageText: 'Page',
ofText: 'of',
rowsText: 'rows',
// Components
tableComponent: (props) => <table {...props}>{props.children}</table>,
theadComponent: (props) => <thead {...props}>{props.children}</thead>,
@@ -68,6 +72,7 @@ export const ReactTableDefaults = {
)
},
tdComponent: (props) => <td {...props}>{props.children}</td>,
paginationComponent: Pagination,
previousComponent: null,
nextComponent: null,
loadingComponent: props => (
@@ -242,6 +247,7 @@ export default React.createClass({
const canPrevious = currentPage > 0
const canNext = currentPage + 1 < pagesLength
const PaginationComponent = this.props.paginationComponent
const TableComponent = this.props.tableComponent
const TheadComponent = this.props.theadComponent
const TbodyComponent = this.props.tbodyComponent
@@ -355,6 +361,7 @@ export default React.createClass({
return (
<TrComponent
key={i}
onClick={event => this.props.onTrClick(rowInfo.row, event)}
className={classnames(this.props.trClassName, this.props.trClassCallback(rowInfo))}
style={Object.assign({}, this.props.trStyle, this.props.trStyleCallback(rowInfo))}
>
@@ -417,7 +424,7 @@ export default React.createClass({
</TbodyComponent>
</TableComponent>
{this.props.showPagination && (
<Pagination
<PaginationComponent
currentPage={currentPage}
pagesLength={pagesLength}
pageSize={pageSize}
@@ -428,11 +435,16 @@ export default React.createClass({
canNext={canNext}
previousText={this.props.previousText}
nextText={this.props.nextText}
pageText={this.props.pageText}
ofText={this.props.ofText}
rowsText={this.props.rowsText}
previousComponent={PreviousComponent}
nextComponent={NextComponent}
//
onChange={this.setPage}
onPageSizeChange={this.setPageSize}
//
className={this.props.paginationClassName}
/>
)}
<LoadingComponent {...this.props} />
+6 -5
View File
@@ -39,7 +39,8 @@ export default React.createClass({
showPageJump,
canPrevious,
canNext,
onPageSizeChange
onPageSizeChange,
className
} = this.props
const PreviousComponent = this.props.previousComponent || defaultButton
@@ -47,7 +48,7 @@ export default React.createClass({
return (
<div
className={classnames(this.props.paginationClassName, '-pagination')}
className={classnames(className, '-pagination')}
style={this.props.paginationStyle}
>
<div className='-previous'>
@@ -63,7 +64,7 @@ export default React.createClass({
</div>
<div className='-center'>
<span className='-pageInfo'>
Page {showPageJump ? (
{this.props.pageText} {showPageJump ? (
<form className='-pageJump'
onSubmit={this.applyPage}
>
@@ -83,7 +84,7 @@ export default React.createClass({
</form>
) : (
<span className='-currentPage'>{currentPage + 1}</span>
)} of <span className='-totalPages'>{pagesLength}</span>
)} {this.props.ofText} <span className='-totalPages'>{pagesLength}</span>
</span>
{showPageSizeOptions && (
<span className='select-wrap -pageSizeOptions'>
@@ -96,7 +97,7 @@ export default React.createClass({
<option
key={i}
value={option}>
{option} rows
{option} {this.props.rowsText}
</option>
)
})}