react-bootstrap-table-next
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -59,6 +59,7 @@ 'use strict'; | ||
_this.getData = function () { | ||
return _this.visibleRows(); | ||
}; | ||
_this.validateProps(); | ||
if (props.registerExposedAPI) { | ||
props.registerExposedAPI(_this.getData); | ||
} | ||
return _this; | ||
@@ -71,7 +72,2 @@ } | ||
_createClass(BootstrapTable, [{ | ||
key: 'getData', | ||
value: function getData() { | ||
return this.visibleRows(); | ||
} | ||
}, { | ||
key: 'render', | ||
@@ -220,3 +216,4 @@ value: function render() { | ||
expandColumnRenderer: _propTypes2.default.func, | ||
expandHeaderColumnRenderer: _propTypes2.default.func | ||
expandHeaderColumnRenderer: _propTypes2.default.func, | ||
expandColumnPosition: _propTypes2.default.oneOf([_const2.default.INDICATOR_POSITION_LEFT, _const2.default.INDICATOR_POSITION_RIGHT]) | ||
}), | ||
@@ -223,0 +220,0 @@ rowStyle: _propTypes2.default.oneOfType([_propTypes2.default.object, _propTypes2.default.func]), |
@@ -14,3 +14,5 @@ 'use strict'; | ||
CHECKBOX_STATUS_INDETERMINATE: 'indeterminate', | ||
CHECKBOX_STATUS_UNCHECKED: 'unchecked' | ||
CHECKBOX_STATUS_UNCHECKED: 'unchecked', | ||
INDICATOR_POSITION_LEFT: 'left', | ||
INDICATOR_POSITION_RIGHT: 'right' | ||
}; |
@@ -15,2 +15,6 @@ 'use strict'; | ||
var _events = require('events'); | ||
var _events2 = _interopRequireDefault(_events); | ||
var _utils = require('../utils'); | ||
@@ -53,2 +57,3 @@ | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /* eslint no-return-assign: 0 */ | ||
/* eslint no-param-reassign: 0 */ | ||
/* eslint class-methods-use-this: 0 */ | ||
@@ -68,2 +73,13 @@ | ||
if (props.registerExposedAPI) { | ||
var exposedAPIEmitter = new _events2.default(); | ||
exposedAPIEmitter.on('get.table.data', function (payload) { | ||
return payload.result = _this.table.getData(); | ||
}); | ||
exposedAPIEmitter.on('get.selected.rows', function (payload) { | ||
return payload.result = _this.selectionContext.getSelected(); | ||
}); | ||
props.registerExposedAPI(exposedAPIEmitter); | ||
} | ||
if (props.columns.filter(function (col) { | ||
@@ -298,7 +314,5 @@ return col.sort; | ||
columns = _props.columns, | ||
bootstrap4 = _props.bootstrap4, | ||
registerExposedAPI = _props.registerExposedAPI; | ||
bootstrap4 = _props.bootstrap4; | ||
var baseProps = { keyField: keyField, columns: columns }; | ||
if (registerExposedAPI) baseProps.registerExposedAPI = registerExposedAPI; | ||
@@ -305,0 +319,0 @@ var base = this.renderBase(); |
@@ -45,10 +45,14 @@ 'use strict'; | ||
function SelectionProvider(props) { | ||
function SelectionProvider() { | ||
var _ref; | ||
var _temp, _this, _ret; | ||
_classCallCheck(this, SelectionProvider); | ||
var _this = _possibleConstructorReturn(this, (SelectionProvider.__proto__ || Object.getPrototypeOf(SelectionProvider)).call(this, props)); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
_this.state = { selected: _this.props.selectRow.selected || [] }; | ||
_this.handleRowSelect = function (rowKey, checked, rowIndex, e) { | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = SelectionProvider.__proto__ || Object.getPrototypeOf(SelectionProvider)).call.apply(_ref, [this].concat(args))), _this), _this.state = { selected: _this.props.selectRow.selected || [] }, _this.handleRowSelect = function (rowKey, checked, rowIndex, e) { | ||
var _this$props = _this.props, | ||
@@ -87,5 +91,3 @@ data = _this$props.data, | ||
}); | ||
}; | ||
_this.handleAllRowsSelect = function (e, isUnSelect) { | ||
}, _this.handleAllRowsSelect = function (e, isUnSelect) { | ||
var _this$props2 = _this.props, | ||
@@ -122,11 +124,3 @@ data = _this$props2.data, | ||
}); | ||
}; | ||
if (props.registerExposedAPI) { | ||
var getSelected = function getSelected() { | ||
return _this.getSelected(); | ||
}; | ||
props.registerExposedAPI(getSelected); | ||
} | ||
return _this; | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
} | ||
@@ -133,0 +127,0 @@ |
@@ -35,4 +35,9 @@ 'use strict'; | ||
var _const = require('./const'); | ||
var _const2 = _interopRequireDefault(_const); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/* eslint react/require-default-props: 0 */ | ||
var Header = function Header(props) { | ||
@@ -65,2 +70,39 @@ var className = props.className, | ||
var isRenderExpandColumnInLeft = function isRenderExpandColumnInLeft() { | ||
var expandColumnPosition = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _const2.default.INDICATOR_POSITION_LEFT; | ||
return expandColumnPosition === _const2.default.INDICATOR_POSITION_LEFT; | ||
}; | ||
var childrens = [columns.map(function (column, i) { | ||
if (!column.hidden) { | ||
var currSort = column.dataField === sortField; | ||
var isLastSorting = column.dataField === sortField; | ||
return _react2.default.createElement(_headerCell2.default, { | ||
index: i, | ||
key: column.dataField, | ||
column: column, | ||
onSort: onSort, | ||
sorting: currSort, | ||
onFilter: onFilter, | ||
onExternalFilter: onExternalFilter, | ||
sortOrder: sortOrder, | ||
isLastSorting: isLastSorting | ||
}); | ||
} | ||
return false; | ||
})]; | ||
if (!selectRow.hideSelectColumn) { | ||
childrens.unshift(_react2.default.createElement(SelectionHeaderCellComp, { key: 'selection' })); | ||
} | ||
if (expandRow.showExpandColumn) { | ||
if (isRenderExpandColumnInLeft(expandRow.expandColumnPosition)) { | ||
childrens.unshift(_react2.default.createElement(ExpansionHeaderCellComp, { key: 'expansion' })); | ||
} else { | ||
childrens.push(_react2.default.createElement(ExpansionHeaderCellComp, { key: 'expansion' })); | ||
} | ||
} | ||
return _react2.default.createElement( | ||
@@ -72,28 +114,7 @@ 'thead', | ||
{ className: className }, | ||
_react2.default.createElement(ExpansionHeaderCellComp, null), | ||
!selectRow.hideSelectColumn ? _react2.default.createElement(SelectionHeaderCellComp, null) : null, | ||
columns.map(function (column, i) { | ||
if (!column.hidden) { | ||
var currSort = column.dataField === sortField; | ||
var isLastSorting = column.dataField === sortField; | ||
return _react2.default.createElement(_headerCell2.default, { | ||
index: i, | ||
key: column.dataField, | ||
column: column, | ||
onSort: onSort, | ||
sorting: currSort, | ||
onFilter: onFilter, | ||
onExternalFilter: onExternalFilter, | ||
sortOrder: sortOrder, | ||
isLastSorting: isLastSorting | ||
}); | ||
} | ||
return false; | ||
}) | ||
childrens | ||
) | ||
); | ||
}; /* eslint react/require-default-props: 0 */ | ||
}; | ||
Header.propTypes = { | ||
@@ -100,0 +121,0 @@ columns: _propTypes2.default.array.isRequired, |
@@ -43,2 +43,6 @@ 'use strict'; | ||
var _const = require('../const'); | ||
var _const2 = _interopRequireDefault(_const); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -52,3 +56,4 @@ | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /* eslint react/prop-types: 0 */ | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /* eslint class-methods-use-this: 0 */ | ||
/* eslint react/prop-types: 0 */ | ||
/* eslint no-plusplus: 0 */ | ||
@@ -83,2 +88,9 @@ | ||
}, { | ||
key: 'isRenderExpandColumnInLeft', | ||
value: function isRenderExpandColumnInLeft() { | ||
var expandColumnPosition = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _const2.default.INDICATOR_POSITION_LEFT; | ||
return expandColumnPosition === _const2.default.INDICATOR_POSITION_LEFT; | ||
} | ||
}, { | ||
key: 'render', | ||
@@ -107,3 +119,4 @@ value: function render() { | ||
clickToSelect = selectRow.clickToSelect; | ||
var showExpandColumn = expandRow.showExpandColumn; | ||
var showExpandColumn = expandRow.showExpandColumn, | ||
expandColumnPosition = expandRow.expandColumnPosition; | ||
@@ -118,2 +131,39 @@ | ||
var childrens = [_react2.default.createElement(_rowPureContent2.default, _extends({ | ||
key: 'row', | ||
row: row, | ||
columns: columns, | ||
keyField: keyField, | ||
rowIndex: rowIndex, | ||
shouldUpdate: this.shouldUpdateRowContent, | ||
tabIndexStart: tabIndexCell ? tabIndexStart : -1 | ||
}, rest))]; | ||
if (!hideSelectColumn) { | ||
childrens.unshift(_react2.default.createElement(_selectionCell2.default, _extends({}, selectRow, { | ||
key: 'selection-cell', | ||
rowKey: key, | ||
rowIndex: rowIndex, | ||
selected: selected, | ||
disabled: !selectable, | ||
tabIndex: tabIndexCell ? tabIndexStart++ : -1 | ||
}))); | ||
} | ||
if (showExpandColumn) { | ||
var expandCell = _react2.default.createElement(_expandCell2.default, _extends({}, expandRow, { | ||
key: 'expand-cell', | ||
rowKey: key, | ||
rowIndex: rowIndex, | ||
expanded: expanded, | ||
expandable: expandable, | ||
tabIndex: tabIndexCell ? tabIndexStart++ : -1 | ||
})); | ||
if (this.isRenderExpandColumnInLeft(expandColumnPosition)) { | ||
childrens.unshift(expandCell); | ||
} else { | ||
childrens.push(expandCell); | ||
} | ||
} | ||
return _react2.default.createElement( | ||
@@ -125,24 +175,3 @@ 'tr', | ||
}, newAttrs), | ||
showExpandColumn ? _react2.default.createElement(_expandCell2.default, _extends({}, expandRow, { | ||
rowKey: key, | ||
rowIndex: rowIndex, | ||
expanded: expanded, | ||
expandable: expandable, | ||
tabIndex: tabIndexCell ? tabIndexStart++ : -1 | ||
})) : null, | ||
!hideSelectColumn ? _react2.default.createElement(_selectionCell2.default, _extends({}, selectRow, { | ||
rowKey: key, | ||
rowIndex: rowIndex, | ||
selected: selected, | ||
disabled: !selectable, | ||
tabIndex: tabIndexCell ? tabIndexStart++ : -1 | ||
})) : null, | ||
_react2.default.createElement(_rowPureContent2.default, _extends({ | ||
row: row, | ||
columns: columns, | ||
keyField: keyField, | ||
rowIndex: rowIndex, | ||
shouldUpdate: this.shouldUpdateRowContent, | ||
tabIndexStart: tabIndexCell ? tabIndexStart : -1 | ||
}, rest)) | ||
childrens | ||
); | ||
@@ -149,0 +178,0 @@ } |
@@ -43,3 +43,19 @@ 'use strict'; | ||
} | ||
// Only use for simple-row | ||
}, { | ||
key: 'shouldUpdateByColumnsForSimpleCheck', | ||
value: function shouldUpdateByColumnsForSimpleCheck(nextProps) { | ||
if (this.props.columns.length !== nextProps.columns.length) { | ||
return true; | ||
} | ||
for (var i = 0; i < this.props.columns.length; i += 1) { | ||
if (this.props.columns[i].hidden !== nextProps.columns[i].hidden) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
}, { | ||
key: 'shouldUpdatedByNormalProps', | ||
@@ -46,0 +62,0 @@ value: function shouldUpdatedByNormalProps(nextProps) { |
@@ -59,3 +59,3 @@ 'use strict'; | ||
this.shouldUpdateRowContent = false; | ||
this.shouldUpdateRowContent = this.shouldUpdateChild(nextProps); | ||
this.shouldUpdateRowContent = this.shouldUpdateChild(nextProps) || this.shouldUpdateByColumnsForSimpleCheck(nextProps); | ||
if (this.shouldUpdateRowContent) return true; | ||
@@ -62,0 +62,0 @@ |
{ | ||
"name": "react-bootstrap-table-next", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Next generation of react-bootstrap-table", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
845349
9944