mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2026-06-29 13:40:07 +00:00
Compare commits
10 Commits
react-boot
...
react-boot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
765a49fb07 | ||
|
|
fe2fd93c20 | ||
|
|
a50148fe85 | ||
|
|
c96156503f | ||
|
|
ed2ba2a5c5 | ||
|
|
f87fe3e544 | ||
|
|
43e73313e6 | ||
|
|
888aa1d08b | ||
|
|
028834da8b | ||
|
|
8f3b989b00 |
@@ -17,6 +17,7 @@
|
|||||||
* [condensed](#condensed)
|
* [condensed](#condensed)
|
||||||
* [id](#id)
|
* [id](#id)
|
||||||
* [classes](#classes)
|
* [classes](#classes)
|
||||||
|
* [wrapperClasses](#wrapperClasses)
|
||||||
* [cellEdit](#cellEdit)
|
* [cellEdit](#cellEdit)
|
||||||
* [selectRow](#selectRow)
|
* [selectRow](#selectRow)
|
||||||
* [rowStyle](#rowStyle)
|
* [rowStyle](#rowStyle)
|
||||||
@@ -107,6 +108,9 @@ Same as bootstrap `.table-condensed` class for making a table more compact by cu
|
|||||||
Customize id on `table` element.
|
Customize id on `table` element.
|
||||||
### <a name='classes'>classes - [String]</a>
|
### <a name='classes'>classes - [String]</a>
|
||||||
Customize class on `table` element.
|
Customize class on `table` element.
|
||||||
|
|
||||||
|
### <a name='wrapperClasses'>wrapperClasses - [String]</a>
|
||||||
|
Customize class on the outer element which wrap up the `table` element.
|
||||||
### <a name='cellEdit'>cellEdit - [Object]</a>
|
### <a name='cellEdit'>cellEdit - [Object]</a>
|
||||||
Makes table cells editable, please see [cellEdit definition](./cell-edit.md) for more detail.
|
Makes table cells editable, please see [cellEdit definition](./cell-edit.md) for more detail.
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,8 @@
|
|||||||
"test:watch": "jest --watch",
|
"test:watch": "jest --watch",
|
||||||
"storybook": "cd ./packages/react-bootstrap-table2-example && yarn storybook",
|
"storybook": "cd ./packages/react-bootstrap-table2-example && yarn storybook",
|
||||||
"gh-pages:clean": "cd ./packages/react-bootstrap-table2-example && yarn gh-pages:clean",
|
"gh-pages:clean": "cd ./packages/react-bootstrap-table2-example && yarn gh-pages:clean",
|
||||||
"gh-pages:build": "cd ./packages/react-bootstrap-table2-example && yarn gh-pages:build"
|
"gh-pages:build": "cd ./packages/react-bootstrap-table2-example && yarn gh-pages:build",
|
||||||
|
"release": "yarn install && yarn build && lerna publish"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-bootstrap-table2-editor",
|
"name": "react-bootstrap-table2-editor",
|
||||||
"version": "0.2.0",
|
"version": "0.2.1",
|
||||||
"description": "it's the editor addon for react-bootstrap-table2",
|
"description": "it's the editor addon for react-bootstrap-table2",
|
||||||
"main": "./lib/index.js",
|
"main": "./lib/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ const columns = [{
|
|||||||
|
|
||||||
<BootstrapTable id="bar" keyField='id' data={ products } columns={ columns } />
|
<BootstrapTable id="bar" keyField='id' data={ products } columns={ columns } />
|
||||||
<BootstrapTable classes="foo" keyField='id' data={ products } columns={ columns } />
|
<BootstrapTable classes="foo" keyField='id' data={ products } columns={ columns } />
|
||||||
|
<BootstrapTable wrapperClasses="boo" keyField="id" data={ products } columns={ columns } />
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export default () => (
|
export default () => (
|
||||||
@@ -43,6 +44,9 @@ export default () => (
|
|||||||
<h4> Customized table className </h4>
|
<h4> Customized table className </h4>
|
||||||
<BootstrapTable classes="foo" keyField="id" data={ products } columns={ columns } />
|
<BootstrapTable classes="foo" keyField="id" data={ products } columns={ columns } />
|
||||||
|
|
||||||
|
<h4> Customized wrapper className </h4>
|
||||||
|
<BootstrapTable wrapperClasses="boo" keyField="id" data={ products } columns={ columns } />
|
||||||
|
|
||||||
<Code>{ sourceCode }</Code>
|
<Code>{ sourceCode }</Code>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-bootstrap-table2-example",
|
"name": "react-bootstrap-table2-example",
|
||||||
"version": "0.1.7",
|
"version": "0.1.8",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
|||||||
@@ -5,3 +5,7 @@ table.foo {
|
|||||||
table#bar {
|
table#bar {
|
||||||
background-color: $light-blue;
|
background-color: $light-blue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div.boo {
|
||||||
|
border: 2px solid salmon;
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-bootstrap-table2-filter",
|
"name": "react-bootstrap-table2-filter",
|
||||||
"version": "0.1.6",
|
"version": "0.1.7",
|
||||||
"description": "it's a column filter addon for react-bootstrap-table2",
|
"description": "it's a column filter addon for react-bootstrap-table2",
|
||||||
"main": "./lib/index.js",
|
"main": "./lib/index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
@@ -30,13 +30,11 @@ export default (Base, {
|
|||||||
// I think this condition only isRemoteFilter is enough
|
// I think this condition only isRemoteFilter is enough
|
||||||
store.filteredData = store.getAllData();
|
store.filteredData = store.getAllData();
|
||||||
this.setState(() => ({ isDataChanged: true, currFilters: store.filters }));
|
this.setState(() => ({ isDataChanged: true, currFilters: store.filters }));
|
||||||
} else if (isDataChanged) {
|
} else {
|
||||||
if (!isRemoteFilter && Object.keys(this.state.currFilters).length > 0) {
|
if (Object.keys(this.state.currFilters).length > 0) {
|
||||||
store.filteredData = filters(store, columns, _)(this.state.currFilters);
|
store.filteredData = filters(store, columns, _)(this.state.currFilters);
|
||||||
}
|
}
|
||||||
this.setState(() => ({ isDataChanged }));
|
this.setState(() => ({ isDataChanged }));
|
||||||
} else {
|
|
||||||
this.setState(() => ({ isDataChanged: false }));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +48,8 @@ export default (Base, {
|
|||||||
onFilter(column, filterType) {
|
onFilter(column, filterType) {
|
||||||
return (filterVal) => {
|
return (filterVal) => {
|
||||||
const { store, columns } = this.props;
|
const { store, columns } = this.props;
|
||||||
const currFilters = Object.assign({}, this.state.currFilters);
|
// watch out here if migration to context API, #334
|
||||||
|
const currFilters = Object.assign({}, store.filters);
|
||||||
const { dataField, filter } = column;
|
const { dataField, filter } = column;
|
||||||
|
|
||||||
if (!_.isDefined(filterVal) || filterVal === '') {
|
if (!_.isDefined(filterVal) || filterVal === '') {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-bootstrap-table-next",
|
"name": "react-bootstrap-table-next",
|
||||||
"version": "0.1.10",
|
"version": "0.1.12",
|
||||||
"description": "Next generation of react-bootstrap-table",
|
"description": "Next generation of react-bootstrap-table",
|
||||||
"main": "./lib/index.js",
|
"main": "./lib/index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
@@ -52,9 +52,12 @@ class BootstrapTable extends PropsBaseResolver(Component) {
|
|||||||
caption,
|
caption,
|
||||||
rowStyle,
|
rowStyle,
|
||||||
rowClasses,
|
rowClasses,
|
||||||
|
wrapperClasses,
|
||||||
rowEvents
|
rowEvents
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
|
const tableWrapperClass = cs('react-bootstrap-table', wrapperClasses);
|
||||||
|
|
||||||
const tableClass = cs('table', {
|
const tableClass = cs('table', {
|
||||||
'table-striped': striped,
|
'table-striped': striped,
|
||||||
'table-hover': hover,
|
'table-hover': hover,
|
||||||
@@ -75,7 +78,7 @@ class BootstrapTable extends PropsBaseResolver(Component) {
|
|||||||
const tableCaption = (caption && <Caption>{ caption }</Caption>);
|
const tableCaption = (caption && <Caption>{ caption }</Caption>);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="react-bootstrap-table">
|
<div className={ tableWrapperClass }>
|
||||||
<table id={ id } className={ tableClass }>
|
<table id={ id } className={ tableClass }>
|
||||||
{ tableCaption }
|
{ tableCaption }
|
||||||
<Header
|
<Header
|
||||||
@@ -120,6 +123,7 @@ BootstrapTable.propTypes = {
|
|||||||
hover: PropTypes.bool,
|
hover: PropTypes.bool,
|
||||||
id: PropTypes.string,
|
id: PropTypes.string,
|
||||||
classes: PropTypes.string,
|
classes: PropTypes.string,
|
||||||
|
wrapperClasses: PropTypes.string,
|
||||||
condensed: PropTypes.bool,
|
condensed: PropTypes.bool,
|
||||||
caption: PropTypes.oneOfType([
|
caption: PropTypes.oneOfType([
|
||||||
PropTypes.node,
|
PropTypes.node,
|
||||||
|
|||||||
4
packages/react-bootstrap-table2/src/cell.js
vendored
4
packages/react-bootstrap-table2/src/cell.js
vendored
@@ -88,7 +88,9 @@ class Cell extends Component {
|
|||||||
cellAttrs.onDoubleClick = this.handleEditingCell;
|
cellAttrs.onDoubleClick = this.handleEditingCell;
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<td { ...cellAttrs }>{ content }</td>
|
<td { ...cellAttrs }>
|
||||||
|
{ typeof content === 'boolean' ? `${content}` : content }
|
||||||
|
</td>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,6 +74,25 @@ describe('BootstrapTable', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('when props.wrapperClasses was defined', () => {
|
||||||
|
const classes = 'foo';
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
wrapper = shallow(
|
||||||
|
<BootstrapTable
|
||||||
|
keyField="id"
|
||||||
|
columns={ columns }
|
||||||
|
data={ data }
|
||||||
|
store={ store }
|
||||||
|
wrapperClasses={ classes }
|
||||||
|
/>);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should display customized classes correctly', () => {
|
||||||
|
expect(wrapper.find(`.${classes}`).length).toBe(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('when props.id was defined', () => {
|
describe('when props.id was defined', () => {
|
||||||
const id = 'foo';
|
const id = 'foo';
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,25 @@ describe('Cell', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('when content is bool value', () => {
|
||||||
|
const column = {
|
||||||
|
dataField: 'col1',
|
||||||
|
text: 'column 1'
|
||||||
|
};
|
||||||
|
const aRowWithBoolValue = { col1: true };
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
wrapper = shallow(
|
||||||
|
<Cell row={ aRowWithBoolValue } columnIndex={ 1 } rowIndex={ 1 } column={ column } />
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render successfully', () => {
|
||||||
|
expect(wrapper.length).toBe(1);
|
||||||
|
expect(wrapper.text()).toEqual(aRowWithBoolValue[column.dataField].toString());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('when column.formatter prop is defined', () => {
|
describe('when column.formatter prop is defined', () => {
|
||||||
const rowIndex = 1;
|
const rowIndex = 1;
|
||||||
const column = {
|
const column = {
|
||||||
|
|||||||
Reference in New Issue
Block a user