Skip to content

Commit 0a0aea1

Browse files
authored
Merge pull request react-bootstrap-table#1246 from react-bootstrap-table/develop
20200209 release
2 parents ae4f503 + 7b593a7 commit 0a0aea1

File tree

12 files changed

+71
-12
lines changed

12 files changed

+71
-12
lines changed

docs/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
* [classes](#classes)
2222
* [wrapperClasses](#wrapperClasses)
2323
* [headerClasses](#headerClasses)
24+
* [headerWrapperClasses](#headerWrapperClasses)
2425
* [cellEdit](#cellEdit)
2526
* [selectRow](#selectRow)
2627
* [expandRow](#expandRow)
@@ -137,6 +138,9 @@ Customize class on the outer element which wrap up the `table` element.
137138
### <a name='headerClasses'>headerClasses - [String]</a>
138139
Customize class on the header row(`tr`).
139140

141+
### <a name='headerWrapperClasses'>headerWrapperClasses - [String]</a>
142+
Customize class on the `thead`.
143+
140144
### <a name='cellEdit'>cellEdit - [Object]</a>
141145
Makes table cells editable, please see [cellEdit definition](./cell-edit.md) for more detail.
142146

packages/react-bootstrap-table2-example/examples/basic/customized-id-classes.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ const columns = [{
3333
3434
<BootstrapTable id="bar" keyField='id' data={ products } columns={ columns } />
3535
<BootstrapTable classes="foo" keyField='id' data={ products } columns={ columns } />
36+
<BootstrapTable headerWrapperClasses="foo" keyField="id" data={ products } columns={ columns } />
37+
<BootstrapTable bodyClasses="foo" keyField="id" data={ products } columns={ columns } />
3638
<BootstrapTable wrapperClasses="boo" keyField="id" data={ products } columns={ columns } />
3739
`;
3840

@@ -44,6 +46,12 @@ export default () => (
4446
<h4> Customized table className </h4>
4547
<BootstrapTable classes="foo" keyField="id" data={ products } columns={ columns } />
4648

49+
<h4> Customized thead className </h4>
50+
<BootstrapTable headerWrapperClasses="foo" keyField="id" data={ products } columns={ columns } />
51+
52+
<h4> Customized tbody className </h4>
53+
<BootstrapTable bodyClasses="foo" keyField="id" data={ products } columns={ columns } />
54+
4755
<h4> Customized wrapper className </h4>
4856
<BootstrapTable wrapperClasses="boo" keyField="id" data={ products } columns={ columns } />
4957

packages/react-bootstrap-table2-example/examples/csv/export-footer.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,7 @@ const columns = [{
4848
data={ products }
4949
columns={ columns }
5050
exportCSV={ {
51-
fileName: 'custom.csv',
52-
separator: '|',
53-
ignoreHeader: true,
54-
noAutoBOM: false,
55-
blobType: 'text/csv;charset=ansi'
51+
ignoreFooter: false
5652
} }
5753
>
5854
{

packages/react-bootstrap-table2-example/stories/stylesheet/base-table/_index.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
table.foo {
1+
.foo {
22
background-color: $grey-500;
33
}
44

packages/react-bootstrap-table2-toolkit/context.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,24 @@ class ToolkitProvider extends statelessDecorator(React.Component) {
6464
this.state = state;
6565
}
6666

67+
// eslint-disable-next-line camelcase
68+
UNSAFE_componentWillReceiveProps(nextProps) {
69+
let columnToggle = this.state.columnToggle;
70+
if (nextProps.columnToggle) {
71+
columnToggle = nextProps.columns
72+
.reduce((obj, column) => {
73+
obj[column.dataField] = !column.hidden;
74+
return obj;
75+
}, {});
76+
} else {
77+
columnToggle = null;
78+
}
79+
this.setState({
80+
...this.state,
81+
columnToggle
82+
});
83+
}
84+
6785
onSearch(searchText) {
6886
if (searchText !== this.state.searchText) {
6987
this.setState({ searchText });

packages/react-bootstrap-table2/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
}
3737
],
3838
"dependencies": {
39-
"classnames": "2.2.5",
39+
"classnames": "^2.2.5",
4040
"react-transition-group": "2.5.3",
4141
"underscore": "1.9.1"
4242
},

packages/react-bootstrap-table2/src/body.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ class Body extends React.Component {
6060
rowStyle,
6161
rowClasses,
6262
rowEvents,
63-
expandRow
63+
expandRow,
64+
className
6465
} = this.props;
6566

6667
let content;
@@ -110,7 +111,7 @@ class Body extends React.Component {
110111
}
111112

112113
return (
113-
<tbody>{ content }</tbody>
114+
<tbody className={ className }>{ content }</tbody>
114115
);
115116
}
116117
}

packages/react-bootstrap-table2/src/bootstrap-table.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class BootstrapTable extends PropsBaseResolver(Component) {
9494
<Header
9595
columns={ columns }
9696
className={ this.props.headerClasses }
97+
wrapperClasses={ this.props.headerWrapperClasses }
9798
sortField={ this.props.sortField }
9899
sortOrder={ this.props.sortOrder }
99100
onSort={ this.props.onSort }
@@ -119,6 +120,7 @@ class BootstrapTable extends PropsBaseResolver(Component) {
119120
/>
120121
)}
121122
<Body
123+
className={ this.props.bodyClasses }
122124
data={ this.getData() }
123125
keyField={ keyField }
124126
tabIndexCell={ tabIndexCell }
@@ -163,7 +165,10 @@ BootstrapTable.propTypes = {
163165
tabIndexCell: PropTypes.bool,
164166
id: PropTypes.string,
165167
classes: PropTypes.string,
168+
headerClasses: PropTypes.string,
169+
bodyClasses: PropTypes.string,
166170
wrapperClasses: PropTypes.string,
171+
headerWrapperClasses: PropTypes.string,
167172
condensed: PropTypes.bool,
168173
caption: PropTypes.oneOfType([
169174
PropTypes.node,
@@ -221,7 +226,6 @@ BootstrapTable.propTypes = {
221226
rowStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
222227
rowEvents: PropTypes.object,
223228
rowClasses: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
224-
headerClasses: PropTypes.string,
225229
filtersClasses: PropTypes.string,
226230
filterPosition: PropTypes.oneOf([
227231
Const.FILTERS_POSITION_TOP,

packages/react-bootstrap-table2/src/contexts/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ const withContext = Base =>
8585
}
8686

8787
UNSAFE_componentWillReceiveProps(nextProps) {
88+
if (nextProps.columns.filter(col => col.sort).length > 0 && !this.SortContext) {
89+
this.SortContext = createSortContext(
90+
dataOperator, this.isRemoteSort, this.handleRemoteSortChange);
91+
} else {
92+
this.SortContext = null;
93+
}
8894
if (!nextProps.pagination && this.props.pagination) {
8995
this.PaginationContext = null;
9096
}

packages/react-bootstrap-table2/src/header-cell.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ class HeaderCell extends eventDelegater(React.Component) {
7777

7878
if (sort) {
7979
const customClick = cellAttrs.onClick;
80+
cellAttrs.onKeyUp = (e) => {
81+
if (e.key === 'Enter') {
82+
onSort(column);
83+
if (_.isFunction(customClick)) customClick(e);
84+
}
85+
};
8086
cellAttrs.onClick = (e) => {
8187
onSort(column);
8288
if (_.isFunction(customClick)) customClick(e);

0 commit comments

Comments
 (0)