react-bootstrap-table-next
Version:
Next generation of react-bootstrap-table
80 lines (63 loc) • 4.2 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _utils = require('../utils');
var _utils2 = _interopRequireDefault(_utils);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
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 */
exports.default = function (ExtendBase) {
return function (_ExtendBase) {
_inherits(RowShouldUpdater, _ExtendBase);
function RowShouldUpdater() {
_classCallCheck(this, RowShouldUpdater);
return _possibleConstructorReturn(this, (RowShouldUpdater.__proto__ || Object.getPrototypeOf(RowShouldUpdater)).apply(this, arguments));
}
_createClass(RowShouldUpdater, [{
key: 'shouldUpdateByCellEditing',
value: function shouldUpdateByCellEditing(nextProps) {
if (!(this.props.clickToEdit || this.props.dbclickToEdit)) return false;
return nextProps.editingRowIdx === nextProps.rowIndex || this.props.editingRowIdx === nextProps.rowIndex && nextProps.editingRowIdx === null || this.props.editingRowIdx === nextProps.rowIndex;
}
}, {
key: 'shouldUpdatedBySelfProps',
value: function shouldUpdatedBySelfProps(nextProps) {
return this.props.className !== nextProps.className || !_utils2.default.isEqual(this.props.style, nextProps.style) || !_utils2.default.isEqual(this.props.attrs, nextProps.attrs);
}
// 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 (!_utils2.default.isEqual(this.props.columns[i], nextProps.columns[i])) {
return true;
}
}
return false;
}
}, {
key: 'shouldUpdatedByNormalProps',
value: function shouldUpdatedByNormalProps(nextProps) {
var shouldUpdate = this.props.rowIndex !== nextProps.rowIndex || this.props.editable !== nextProps.editable || !_utils2.default.isEqual(this.props.row, nextProps.row) || this.props.columns.length !== nextProps.columns.length;
return shouldUpdate;
}
}, {
key: 'shouldUpdateChild',
value: function shouldUpdateChild(nextProps) {
return this.shouldUpdateByCellEditing(nextProps) || this.shouldUpdatedByNormalProps(nextProps);
}
}, {
key: 'shouldRowContentUpdate',
value: function shouldRowContentUpdate(nextProps) {
return this.shouldUpdateChild(nextProps) || this.shouldUpdateByColumnsForSimpleCheck(nextProps);
}
}]);
return RowShouldUpdater;
}(ExtendBase);
};
;