Update bootstrap-table and row-consumer

Add new props to the bootstrap-table, nonSelectableStyle and
nonSelectableClasses

Update row-consume in order to support custom styles and classes
for non selectable rows
This commit is contained in:
Ymbere Xavier 2019-10-27 23:01:05 -03:00
parent 18caf0ac8d
commit defcd04b52
2 changed files with 19 additions and 0 deletions

View File

@ -166,6 +166,8 @@ BootstrapTable.propTypes = {
style: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
classes: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
nonSelectable: PropTypes.array,
nonSelectableStyle: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
nonSelectableClasses: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
bgColor: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
hideSelectColumn: PropTypes.bool,
selectionRenderer: PropTypes.func,

View File

@ -9,6 +9,7 @@ export default (Component) => {
const key = props.value;
const selected = _.contains(selectRow.selected, key);
const selectable = !selectRow.nonSelectable || !_.contains(selectRow.nonSelectable, key);
const notSelectable = _.contains(selectRow.nonSelectable, key);
let {
style,
@ -38,6 +39,22 @@ export default (Component) => {
}
}
if (notSelectable) {
const notSelectableStyle = _.isFunction(selectRow.nonSelectableStyle)
? selectRow.nonSelectableStyle(props.row, props.rowIndex)
: selectRow.nonSelectableStyle;
const notSelectableClasses = _.isFunction(selectRow.nonSelectableClasses)
? selectRow.nonSelectableClasses(props.row, props.rowIndex)
: selectRow.nonSelectableClasses;
style = {
...style,
...notSelectableStyle
};
className = cs(className, notSelectableClasses) || undefined;
}
return (
<Component
{ ...props }