material-table
Advanced tools
Comparing version 0.8.0 to 0.8.1
@@ -27,5 +27,5 @@ 'use strict'; | ||
var _mTableFilterRow = require('./m-table-filter-row'); | ||
var _mTableBody = require('./m-table-body'); | ||
var _mTableFilterRow2 = _interopRequireDefault(_mTableFilterRow); | ||
var _mTableBody2 = _interopRequireDefault(_mTableBody); | ||
@@ -210,93 +210,5 @@ var _mTableToolbar = require('./m-table-toolbar'); | ||
}, { | ||
key: 'renderBody', | ||
value: function renderBody() { | ||
var _this3 = this; | ||
var props = this.getProps(); | ||
var renderData = this.state.renderData; | ||
var emptyRowCount = 0; | ||
if (props.options.paging) { | ||
var startIndex = this.state.currentPage * this.state.pageSize; | ||
var endIndex = startIndex + this.state.pageSize; | ||
renderData = renderData.slice(startIndex, endIndex); | ||
emptyRowCount = this.state.pageSize - renderData.length; | ||
} | ||
return React.createElement( | ||
_core.TableBody, | ||
null, | ||
props.options.filtering && React.createElement(_mTableFilterRow2.default, { | ||
columns: this.state.columns.filter(function (columnDef) { | ||
return !columnDef.hidden; | ||
}), | ||
emptyCell: props.options.selection || props.actions && props.actions.filter(function (a) { | ||
return !a.isFreeAction; | ||
}).length > 0, | ||
onFilterChanged: function onFilterChanged(columnId, value) { | ||
var columns = _this3.state.columns; | ||
columns[columnId].tableData.filterValue = value; | ||
_this3.setState({ columns: columns }, function () { | ||
_this3.setData(); | ||
}); | ||
} | ||
}), | ||
renderData.map(function (data, index) { | ||
return _this3.renderRow(data, index); | ||
}), | ||
[].concat(_toConsumableArray(Array(emptyRowCount))).map(function () { | ||
return React.createElement(_core.TableRow, { style: { height: 49 } }); | ||
}), | ||
emptyRowCount > 0 && React.createElement('div', { style: { height: 1 } }) | ||
); | ||
} | ||
}, { | ||
key: 'renderRow', | ||
value: function renderRow(data, index) { | ||
var _this4 = this; | ||
var props = this.getProps(); | ||
return React.createElement( | ||
_core.TableRow, | ||
{ selected: index % 2 === 0 }, | ||
props.options.selection ? React.createElement( | ||
_core.TableCell, | ||
{ padding: 'checkbox' }, | ||
React.createElement(_core.Checkbox, { | ||
checked: data.tableData.checked === true, | ||
value: data.tableData.id, | ||
onChange: function onChange(event, checked) { | ||
data = _this4.state.data; | ||
data[event.target.value].tableData.checked = checked; | ||
_this4.setState(function (state) { | ||
return { | ||
data: data, | ||
selectedCount: state.selectedCount + (checked ? 1 : -1) | ||
}; | ||
}); | ||
} | ||
}) | ||
) : props.actions && props.actions.filter(function (a) { | ||
return !a.isFreeAction; | ||
}).length > 0 && React.createElement( | ||
_core.TableCell, | ||
{ style: { paddingTop: 0, paddingBottom: 0 } }, | ||
React.createElement( | ||
'div', | ||
{ style: { display: 'flex' } }, | ||
React.createElement(_mTableActions2.default, { data: data, actions: props.actions.filter(function (a) { | ||
return !a.isFreeAction; | ||
}) }) | ||
) | ||
), | ||
this.state.columns.filter(function (columnDef) { | ||
return !columnDef.hidden; | ||
}).map(function (columnDef) { | ||
var value = _this4.getFieldValue(data, columnDef); | ||
return React.createElement(_mTableCell2.default, { columnDef: columnDef, value: value }); | ||
}) | ||
); | ||
} | ||
}, { | ||
key: 'renderFooter', | ||
value: function renderFooter() { | ||
var _this5 = this; | ||
var _this3 = this; | ||
@@ -319,8 +231,8 @@ var props = this.getProps(); | ||
onChangePage: function onChangePage(event, page) { | ||
_this5.setState({ currentPage: page }, function () { | ||
_this5.setData(); | ||
_this3.setState({ currentPage: page }, function () { | ||
_this3.setData(); | ||
}); | ||
}, | ||
onChangeRowsPerPage: function onChangeRowsPerPage(event) { | ||
_this5.setState(function (state) { | ||
_this3.setState(function (state) { | ||
state.pageSize = event.target.value; | ||
@@ -330,3 +242,3 @@ state.currentPage = 0; | ||
}, function () { | ||
_this5.setData(); | ||
_this3.setData(); | ||
}); | ||
@@ -343,3 +255,3 @@ }, | ||
value: function render() { | ||
var _this6 = this; | ||
var _this4 = this; | ||
@@ -362,8 +274,8 @@ var props = this.getProps(); | ||
onSearchChanged: function onSearchChanged(searchText) { | ||
return _this6.setState({ searchText: searchText }, function () { | ||
return _this6.setData(); | ||
return _this4.setState({ searchText: searchText }, function () { | ||
return _this4.setData(); | ||
}); | ||
}, | ||
onColumnsChanged: function onColumnsChanged(columns) { | ||
return _this6.setState({ columns: columns }); | ||
return _this4.setState({ columns: columns }); | ||
}, | ||
@@ -390,3 +302,3 @@ localization: Object.assign(MaterialTable.defaultProps.localization, this.props.localization) | ||
onAllSelected: function onAllSelected(checked) { | ||
var data = _this6.state.renderData.map(function (row) { | ||
var data = _this4.state.renderData.map(function (row) { | ||
row.tableData.checked = checked; | ||
@@ -396,11 +308,36 @@ return row; | ||
var selectedCount = checked ? data.length : 0; | ||
_this6.setState({ renderData: data, selectedCount: selectedCount }); | ||
_this4.setState({ renderData: data, selectedCount: selectedCount }); | ||
}, | ||
onOrderChanged: function onOrderChanged(orderBy, orderDirection) { | ||
_this6.setState({ orderBy: orderBy, orderDirection: orderDirection, currentPage: 0 }, function () { | ||
_this6.setData(); | ||
_this4.setState({ orderBy: orderBy, orderDirection: orderDirection, currentPage: 0 }, function () { | ||
_this4.setData(); | ||
}); | ||
} | ||
}), | ||
this.renderBody() | ||
React.createElement(_mTableBody2.default, { | ||
actions: props.actions, | ||
renderData: this.state.renderData, | ||
currentPage: this.state.currentPage, | ||
pageSize: this.state.pageSize, | ||
columns: this.state.columns, | ||
options: props.options, | ||
getFieldValue: this.getFieldValue, | ||
onFilterChanged: function onFilterChanged(columnId, value) { | ||
var columns = _this4.state.columns; | ||
columns[columnId].tableData.filterValue = value; | ||
_this4.setState({ columns: columns }, function () { | ||
_this4.setData(); | ||
}); | ||
}, | ||
onRowSelected: function onRowSelected(event, checked) { | ||
var data = _this4.state.data; | ||
data[event.target.value].tableData.checked = checked; | ||
_this4.setState(function (state) { | ||
return { | ||
data: data, | ||
selectedCount: state.selectedCount + (checked ? 1 : -1) | ||
}; | ||
}); | ||
} | ||
}) | ||
) | ||
@@ -407,0 +344,0 @@ ), |
{ | ||
"name": "material-table", | ||
"version": "0.8.0", | ||
"version": "0.8.1", | ||
"description": "Datatable for React based on https://material-ui.com/api/table/ with additional features", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
60321
12
1076