Compare commits

..
8 Commits
Author SHA1 Message Date
Tanner Linsley a64c6a3a76 5.5.2 2017-04-17 09:29:06 -06:00
Tanner Linsley f502ef4e2b Immutablely decorate with _viewIndex
#203
2017-04-17 09:28:31 -06:00
theCmakerandTanner Linsley c58c96c84f Fixed issue #14 Default CSS overwrites the checkbox appearance if included into a custom cell. (#197) 2017-04-17 09:15:53 -06:00
Tanner Linsley 7202776c86 5.5.1 2017-04-13 10:49:15 -06:00
Mike DeVitaandGitHub 734ba48e9c Update ISSUE_TEMPLATE.md
fix the system information section to use bulleted lists
2017-04-10 10:12:04 -07:00
Alejandro BrozzoandTanner Linsley db84ecf789 Fixed code highlights (#179) 2017-04-10 10:21:31 -06:00
AlejandroandTanner Linsley 50668fe90f Avoid page refresh if same page, set NaN to current page (#178)
* Avoid page refresh if same page, set NaN to current page

* Fixed styling rule errors
2017-04-07 17:07:42 -06:00
Aaron SchwartzandGitHub 52f2c9fdac Fix descending sort being non-deterministic
Descending sort would sort differently for the same data on rerender for items that evaluated to the same value.
2017-04-06 15:25:56 -07:00
10 changed files with 68 additions and 25 deletions
+5 -5
View File
@@ -8,8 +8,8 @@ include a detailed explanation of the problem here...
2. to reproduce the issue
## System Information
**Browser & Browser Version:**
**Node Version:**
**OS Version:**
**NPM Version:**
**Yarn Version:**
* **Browser & Browser Version:**
* **Node Version:**
* **OS Version:**
* **NPM Version:**
* **Yarn Version:**
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "react-table",
"version": "5.5.0",
"version": "5.5.2",
"description": "A fast, lightweight, opinionated table and datagrid built on React",
"license": "MIT",
"homepage": "https://github.com/tannerlinsley/react-table#readme",
+17 -11
View File
@@ -87,25 +87,31 @@ export default React.createClass({
// Pagination
const startRow = pageSize * page
const endRow = startRow + pageSize
const pageRows = manual ? resolvedData : sortedData.slice(startRow, endRow)
let pageRows = manual ? resolvedData : sortedData.slice(startRow, endRow)
const minRows = this.getMinRows()
const padRows = _.range(Math.max(minRows - pageRows.length, 0))
const hasColumnFooter = allVisibleColumns.some(d => d.footer)
const recurseRowsViewIndex = (rows, path = [], index = -1) => {
rows.forEach((row, i) => {
index++
row._viewIndex = index
const newPath = path.concat([i])
if (row[subRowsKey] && _.get(expandedRows, newPath)) {
index = recurseRowsViewIndex(row[subRowsKey], newPath, index)
}
})
return index
return [
rows.map((row, i) => {
index++
const rowWithViewIndex = {
...row,
_viewIndex: index
}
const newPath = path.concat([i])
if (rowWithViewIndex[subRowsKey] && _.get(expandedRows, newPath)) {
[rowWithViewIndex[subRowsKey], index] = recurseRowsViewIndex(rowWithViewIndex[subRowsKey], newPath, index)
}
return rowWithViewIndex
}),
index
]
}
recurseRowsViewIndex(pageRows)
[pageRows] = recurseRowsViewIndex(pageRows)
const canPrevious = page > 0
const canNext = page + 1 < pages
+4 -1
View File
@@ -260,7 +260,6 @@ $expandSize = 7px
input
select
appearance: none
border: 1px solid rgba(0,0,0,0.1)
background: white
padding: 5px 7px
@@ -269,6 +268,10 @@ $expandSize = 7px
font-weight: normal
outline:none
input:not([type="checkbox"]):not([type="radio"])
select
appearance: none
.select-wrap
position:relative
display:inline-block
+6 -1
View File
@@ -17,12 +17,17 @@ export default React.createClass({
this.setState({page: nextProps.page})
},
getSafePage (page) {
if (isNaN(page)) {
page = this.props.page
}
return Math.min(Math.max(page, 0), this.props.pages - 1)
},
changePage (page) {
page = this.getSafePage(page)
this.setState({page})
this.props.onPageChange(page)
if (this.props.page !== page) {
this.props.onPageChange(page)
}
},
applyPage (e) {
e && e.preventDefault()
+1 -1
View File
@@ -80,7 +80,7 @@ function orderBy (arr, funcs, dirs) {
}
return dirs[0]
? a.__index - b.__index
: b.__index - b.__index
: b.__index - a.__index
})
}
+1
View File
@@ -161,6 +161,7 @@ const columns = [{
return (
<ReactTable
className='-striped -highlight'
data={data}
columns={columns}
defaultPageSize={10}
-2
View File
@@ -112,8 +112,6 @@ class ControlledTable extends React.Component {
constructor() {
super()
this.sortChange = this.sortChange.bind(this)
this.pageChange = this.pageChange.bind(this)
this.pageSizeChange = this.pageSizeChange.bind(this)
this.state = {
sorting: [],
page: 0,
+32 -3
View File
@@ -88,23 +88,52 @@ const columns = [{
header: 'Name',
columns: [{
header: 'First Name',
accessor: 'firstName'
accessor: 'firstName',
footer: (
<span><strong>Popular:</strong> {
_.first(
_.reduce(
_.map(
_.groupBy(
data, d => d.firstName
)
),
(a, b) => a.length > b.length ? a : b
)
).firstName}
</span>
)
}, {
header: 'Last Name',
id: 'lastName',
accessor: d => d.lastName
accessor: d => d.lastName,
footer: (
<span><strong>Longest:</strong> {
_.reduce(
_.map(
_.groupBy(
data, d => d.lastName
),
(d, key) => key
),
(a, b) => a.length > b.length ? a : b
)}
</span>
)
}]
}, {
header: 'Info',
columns: [{
header: 'Age',
accessor: 'age'
accessor: 'age',
footer: <span><strong>Average:</strong> {_.round(_.mean(_.map(data, d => d.age)))}</span>
}]
}]
// Display your table!
return (
<ReactTable
className='-striped -highlight'
data={data}
columns={columns}
defaultPageSize={10}
+1
View File
@@ -77,6 +77,7 @@ const columns = [{
// Display your table!
return (
<ReactTable
className='-striped -highlight'
data={data}
columns={columns}
defaultPageSize={10}