Compare commits

...
15 Commits
Author SHA1 Message Date
Tanner Linsley 3334796223 2.2.5 2016-10-27 09:20:21 -06:00
Tanner Linsley 92b70393fa Added rowValues as a prop & Readme Updates 2016-10-27 09:20:16 -06:00
Tanner Linsley efeabe3536 2.2.4 2016-10-27 08:59:34 -06:00
Tanner Linsley f018bac58f Fixed row value prop 2016-10-27 08:59:30 -06:00
Tanner Linsley a8f360a408 Remove Build Files 2016-10-26 19:39:18 -06:00
Tanner Linsley 82f3913034 2.2.3 2016-10-26 19:37:15 -06:00
Tanner Linsley cb3cc05a59 Fixed row references 2016-10-26 19:37:10 -06:00
Tanner Linsley e8146b5d14 2.2.2 2016-10-26 19:25:51 -06:00
Tanner Linsley eef59a559e Added stuff back to umd files array 2016-10-26 19:25:45 -06:00
Tanner Linsley 3b18e8c8c1 2.2.1 2016-10-26 19:18:51 -06:00
Tanner Linsley dd6b8af304 Ignore built files in git 2016-10-26 19:18:45 -06:00
Tanner Linsley f242d2f3f6 Fixed tbodystyle bug 2016-10-26 19:15:36 -06:00
Tanner Linsley 9dd0333571 Readme Update 2016-10-26 19:11:48 -06:00
Tanner Linsley 085616d858 2.2.0 2016-10-26 17:33:32 -06:00
Tanner Linsley 25ef0b2273 Styles, ClassNames & Row Style/ClassName callbacks 2016-10-26 17:33:26 -06:00
8 changed files with 287 additions and 761 deletions
+3 -1
View File
@@ -1,3 +1,5 @@
node_modules/
lib/
react-table.js
react-table.css
*.log
+44 -23
View File
@@ -81,24 +81,32 @@ Every React-Table instance requires you to set the `data` prop. To use client-si
These are the default props for the main react component `<ReactTable />`
```javascript
{
// General
pageSize: 20,
minRows: 0, // Ensure this many rows are always rendered, regardless of rows on page
// Text
previousText: 'Previous',
nextText: 'Next'
// Classes
className: '-striped -highlight', // The most top level className for the component
tableClassName: '', // ClassName for the `table` element
theadClassName: '', // ClassName for the `thead` element
tbodyClassName: '', // ClassName for the `tbody` element
trClassName: '', // ClassName for all `tr` elements
trClassCallback: row => null, // A call back to dynamically add classes (via the classnames module) to a row element
paginationClassName: '' // ClassName for `pagination` element
//
pageSize: 20,
minRows: 0, // Ensure this many rows are always rendered, regardless of rows on page
// Global Column Defaults
column: { // default properties for every column's model
sortable: true,
show: true
},
// Text
previousText: 'Previous',
nextText: 'Next'
// Styles
style: {}, // Main style object for the component
tableStyle: {}, // style object for the `table` component
theadStyle: {}, // style object for the `thead` component
tbodyStyle: {}, // style object for the `tbody` component
trStyle: {}, // style object for the `tr` component
trStyleCallback: row => {}, // A call back to dynamically add styles to a row element
thStyle: {}, // style object for the `th` component
tdStyle: {}, // style object for the `td` component
paginationStyle: {}, // style object for the `paginination` component
}
```
@@ -130,23 +138,36 @@ Every React-Table instance requires a `columns` prop, which is an array of objec
```javascript
[{
// Required
header: 'Header Name' or JSX eg. ({data, column}) => <div>Header Name</div>,
// General
accessor: 'propertyName' or Accessor eg. (row) => row.propertyName,
// A unique ID is required if the accessor is not a string or if you would like to override the column name used in server-side calls
id: 'myProperty',
// Optional
className: '', // Set the classname of the `th/td` element of the column
innerClassName: '', // Set the classname of the `.th-inner/.td-inner` element of the column
columns: [...] // See Header Groups section below
render: JSX eg. ({row, value, index, viewIndex}) => <span>{value}</span>, // Provide a JSX element or stateless function to render whatever you want as the column's cell with access to the entire row
id: 'myProperty', // Conditional - A unique ID is required if the accessor is not a string or if you would like to override the column name used in server-side calls
sortable: true,
sort: 'asc' or 'desc',
show: true,
width: Number, // Locks the column width to this amount
minWidth: Number // Allows the column to flex above this minimum amount
// Cell Options
className: '', // Set the classname of the `td` element of the column
style: {}, // Set the style of the `td` element of the column
innerClassName: '', // Set the classname of the `.-td-inner` element of the column
innerStyle: {}, // Set the style of the `.-td-inner` element of the column
render: JSX eg. ({value, rowValues, row, index, viewIndex}) => <span>{value}</span>, // Provide a JSX element or stateless function to render whatever you want as the column's cell with access to the entire row
// value == the accessed value of the column
// rowValues == an object of all of the accessed values for the row
// row == the original row of data supplied to the table
// index == the original index of the data supplied to the table
// viewIndex == the index of the row in the current page
// Header & HeaderGroup Options
header: 'Header Name' or JSX eg. ({data, column}) => <div>Header Name</div>,
headerClassName: '', // Set the classname of the `th` element of the column
headerStyle: {}, // Set the style of the `th` element of the column
headerInnerClassName: '', // Set the classname of the `.-th-inner` element of the column
headerInnerStyle: {}, // Set the style of the `.th-inner` element of the column
// Header Groups only
columns: [...] // See Header Groups section below
}]
```
+127 -47
View File
File diff suppressed because one or more lines are too long
-643
View File
File diff suppressed because one or more lines are too long
+10 -3
View File
@@ -1,6 +1,6 @@
{
"name": "react-table",
"version": "2.1.3",
"version": "2.2.5",
"description": "A fast, lightweight, opinionated table and datagrid built on React",
"license": "MIT",
"homepage": "https://github.com/tannerlinsley/react-table#readme",
@@ -15,13 +15,20 @@
"datagrid"
],
"main": "lib/index.js",
"files": [
"lib/",
"react-table.js",
"react-table.css",
"media/*.png"
],
"scripts": {
"build:node": "babel src --out-dir lib --source-maps inline",
"build:css": "rm -rf react-table.css && stylus src/index.styl --use ./node_modules/nib/lib/nib.js --compress -o react-table.css",
"watch": "onchange 'src/**' -i -- npm-run-all build:*",
"test": "standard",
"umd": "rm -rf react-table.js && browserify lib/index.js -s reactTable -x react -t babelify -g uglifyify -o react-table.js",
"prepublish": "npm-run-all build:* && npm run umd"
"prepublish": "npm-run-all build:* && npm run umd",
"postpublish": "git push --tags"
},
"dependencies": {
"classnames": "^2.2.5"
@@ -40,7 +47,7 @@
"nib": "^1.1.2",
"npm-run-all": "^3.1.1",
"onchange": "^3.0.2",
"standard": "8.0.0",
"standard": "^8.0.0",
"stylus": "^0.54.5",
"uglifyify": "3.0.3"
},
-1
View File
File diff suppressed because one or more lines are too long
-7
View File
File diff suppressed because one or more lines are too long
+103 -36
View File
@@ -22,14 +22,36 @@ export const ReactTableDefaults = {
theadClassName: '',
tbodyClassName: '',
trClassName: '',
trClassCallback: d => null,
thClassName: '',
thGroupClassName: '',
tdClassName: '',
paginationClassName: '',
// Styles
style: {},
tableStyle: {},
theadStyle: {},
tbodyStyle: {},
trStyle: {},
trStyleCallback: d => {},
thStyle: {},
tdStyle: {},
paginationStyle: {},
//
pageSize: 20,
minRows: 0,
// Global Column Defaults
column: {
sortable: true,
show: true
show: true,
className: '',
style: {},
innerClassName: '',
innerStyle: {},
headerClassName: '',
headerStyle: {},
headerInnerClassName: '',
headerInnerStyle: {}
},
// Text
previousText: 'Previous',
@@ -255,19 +277,35 @@ export default React.createClass({
const NextComponent = this.props.nextComponent || defaultButton
return (
<div className={classnames(this.props.className, 'ReactTable')}>
<TableComponent className={classnames(this.props.tableClassName)}>
<div
className={classnames(this.props.className, 'ReactTable')}
style={this.props.style}
>
<TableComponent
className={classnames(this.props.tableClassName)}
style={this.props.tableStyle}
>
{this.hasHeaderGroups && (
<TheadComponent className={classnames(this.props.theadClassName, '-headerGroups')}>
<TrComponent className={this.props.trClassName}>
<TheadComponent
className={classnames(this.props.theadGroupClassName, '-headerGroups')}
style={this.props.theadStyle}
>
<TrComponent
className={this.props.trClassName}
style={this.props.trStyle}
>
{this.headerGroups.map((column, i) => {
return (
<ThComponent
key={i}
className={classnames(column.className)}
colSpan={column.columns.length}>
colSpan={column.columns.length}
className={classnames(this.props.thClassname, column.headerClassName)}
style={Object.assign({}, this.props.thStyle, column.headerStyle)}
>
<div
className={classnames(column.innerClassName, '-th-inner')}>
className={classnames(column.headerInnerClassName, '-th-inner')}
style={Object.assign({}, this.props.thInnerStyle, column.headerInnerStyle)}
>
{typeof column.header === 'function' ? (
<column.header
data={this.props.data}
@@ -281,8 +319,14 @@ export default React.createClass({
</TrComponent>
</TheadComponent>
)}
<TheadComponent className={classnames(this.props.theadClassName)}>
<TrComponent className={this.props.trClassName}>
<TheadComponent
className={classnames(this.props.theadClassName)}
style={this.props.theadStyle}
>
<TrComponent
className={this.props.trClassName}
style={this.props.trStyle}
>
{this.decoratedColumns.map((column, i) => {
const sort = this.state.sorting.find(d => d.id === column.id)
const show = typeof column.show === 'function' ? column.show() : column.show
@@ -290,22 +334,25 @@ export default React.createClass({
<ThComponent
key={i}
className={classnames(
column.className,
this.props.thClassname,
column.headerClassName,
sort ? (sort.asc ? '-sort-asc' : '-sort-desc') : '',
{
'-cursor-pointer': column.sortable,
'-hidden': !show
}
)}
style={Object.assign({}, this.props.thStyle, column.headerStyle)}
onClick={(e) => {
column.sortable && this.sortColumn(column, e.shiftKey)
}}>
}}
>
<div
className={classnames(column.innerClassName, '-th-inner')}
style={{
width: column.width + 'px',
className={classnames(column.headerInnerClassName, '-th-inner')}
style={Object.assign({}, column.headerInnerStyle, {
minWidth: column.minWidth + 'px'
}}>
})}
>
{typeof column.header === 'function' ? (
<column.header
data={this.props.data}
@@ -318,34 +365,45 @@ export default React.createClass({
})}
</TrComponent>
</TheadComponent>
<TbodyComponent className={classnames(this.props.tbodyClassName)}>
<TbodyComponent
className={classnames(this.props.tbodyClassName)}
style={this.props.tbodyStyle}
>
{pageRows.map((row, i) => {
const rowInfo = {
row: row.__original,
rowValues: row,
index: row.__index,
viewIndex: i
}
return (
<TrComponent
className={classnames(this.props.trClassName)}
key={i}>
key={i}
className={classnames(this.props.trClassName, this.props.trClassCallback(rowInfo))}
style={Object.assign({}, this.props.trStyle, this.props.trStyleCallback(rowInfo))}
>
{this.decoratedColumns.map((column, i2) => {
const Cell = column.render
const show = typeof column.show === 'function' ? column.show() : column.show
return (
<TdComponent
key={i2}
className={classnames(column.className, {hidden: !show})}
key={i2}>
style={Object.assign({}, this.props.tdStyle, column.style)}
>
<div
className={classnames(column.innerClassName, '-td-inner')}
style={{
width: column.width + 'px',
style={Object.assign({}, column.innerStyle, {
minWidth: column.minWidth + 'px'
}}>
})}
>
{typeof Cell === 'function' ? (
<Cell
value={row[column.id]}
row={row.__original}
index={row.__index}
viewIndex={i}
{...rowInfo}
value={rowInfo.rowValues[column.id]}
/>
) : typeof Cell !== 'undefined' ? Cell
: row[column.id]}
: rowInfo.rowValues[column.id]}
</div>
</TdComponent>
)
@@ -356,20 +414,24 @@ export default React.createClass({
{padRows.map((row, i) => {
return (
<TrComponent
key={i}
className={classnames(this.props.trClassName, '-padRow')}
key={i}>
style={this.props.trStyle}
>
{this.decoratedColumns.map((column, i2) => {
const show = typeof column.show === 'function' ? column.show() : column.show
return (
<TdComponent
key={i2}
className={classnames(column.className, {hidden: !show})}
key={i2}>
style={Object.assign({}, this.props.tdStyle, column.style)}
>
<div
className={classnames(column.innerClassName, '-td-inner')}
style={{
width: column.width + 'px',
style={Object.assign({}, column.innerStyle, {
minWidth: column.minWidth + 'px'
}}>&nbsp;</div>
})}
>&nbsp;</div>
</TdComponent>
)
})}
@@ -379,11 +441,15 @@ export default React.createClass({
</TbodyComponent>
</TableComponent>
{pagesLength > 1 && (
<div className={classnames(this.props.paginationClassName, '-pagination')}>
<div
className={classnames(this.props.paginationClassName, '-pagination')}
style={this.props.paginationStyle}
>
<div className='-left'>
<PreviousComponent
onClick={canPrevious && ((e) => this.previousPage(e))}
disabled={!canPrevious}>
disabled={!canPrevious}
>
{this.props.previousText}
</PreviousComponent>
</div>
@@ -393,7 +459,8 @@ export default React.createClass({
<div className='-right'>
<NextComponent
onClick={canNext && ((e) => this.nextPage(e))}
disabled={!canNext}>
disabled={!canNext}
>
{this.props.nextText}
</NextComponent>
</div>