-
Notifications
You must be signed in to change notification settings - Fork 380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(react-grid): extract the Table plugin components #766
Merged
kvet
merged 21 commits into
DevExpress:master
from
MaximKudriavtsev:extract-table-component
Mar 7, 2018
Merged
Changes from 10 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
efa27b7
Extract the Table Component
MaximKudriavtsev 4ced25a
Fix tests
MaximKudriavtsev dd94fc2
Add support the Table mui and the VirtualTable
MaximKudriavtsev 44754b8
Add docs
MaximKudriavtsev b88350d
Add tests for Table mui
MaximKudriavtsev be0bd06
Change object -> Object
MaximKudriavtsev a08a932
Add docs
MaximKudriavtsev c96d4ac
Add demo
MaximKudriavtsev 6ab1d8a
Refactor
MaximKudriavtsev 8763d55
Fix after review
MaximKudriavtsev 5fcaa65
Extract the Table.Container component
MaximKudriavtsev 31250f1
Extract the VirtualTable.Container component
MaximKudriavtsev 1e41178
Merge branch 'master' into extract-table-component
MaximKudriavtsev 39b6bc1
Add bs4 support
MaximKudriavtsev a3bd54b
Update fundamentals.md
viterobk 88ecc92
Update table.md
viterobk 8a133fb
Update virtual-table.md
viterobk 2f80883
Update fundamentals.md
dirk-pieterse 2977e83
Update table.md
dirk-pieterse 6bd33e1
Update virtual-table.md
dirk-pieterse 38e32bd
Merge branch 'master' into extract-table-component
kvet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
packages/dx-react-demos/src/demo-sources/grid-basic/bootstrap3/table-template.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import * as React from 'react'; | ||
import { | ||
Grid, | ||
Table, | ||
TableHeaderRow, | ||
} from '@devexpress/dx-react-grid-bootstrap3'; | ||
|
||
import { | ||
generateRows, | ||
globalSalesValues, | ||
} from '../../../demo-data/generator'; | ||
|
||
const TableComponent = ({ ...restProps }) => ( | ||
<Table.Container | ||
{...restProps} | ||
className="table-striped" | ||
/> | ||
); | ||
|
||
export default class Demo extends React.PureComponent { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
columns: [ | ||
{ name: 'region', title: 'Region' }, | ||
{ name: 'sector', title: 'Sector' }, | ||
{ name: 'channel', title: 'Channel' }, | ||
{ name: 'customer', title: 'Customer' }, | ||
{ name: 'product', title: 'Product' }, | ||
{ name: 'amount', title: 'Sale Amount' }, | ||
], | ||
rows: generateRows({ columnValues: globalSalesValues, length: 8 }), | ||
}; | ||
} | ||
render() { | ||
const { rows, columns } = this.state; | ||
|
||
return ( | ||
<div> | ||
<Grid | ||
rows={rows} | ||
columns={columns} | ||
> | ||
<Table | ||
tableComponent={TableComponent} | ||
/> | ||
<TableHeaderRow /> | ||
</Grid> | ||
</div> | ||
); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
packages/dx-react-demos/src/demo-sources/grid-basic/material-ui/table-template.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import * as React from 'react'; | ||
import Paper from 'material-ui/Paper'; | ||
import { | ||
Grid, | ||
Table, | ||
TableHeaderRow, | ||
} from '@devexpress/dx-react-grid-material-ui'; | ||
import { withStyles } from 'material-ui/styles'; | ||
import { | ||
generateRows, | ||
globalSalesValues, | ||
} from '../../../demo-data/generator'; | ||
|
||
const styles = theme => ({ | ||
tableStriped: { | ||
'& tbody tr:nth-of-type(odd)': { | ||
backgroundColor: theme.palette.primary[50], | ||
}, | ||
}, | ||
}); | ||
|
||
const TableComponentBase = ({ classes, ...restProps }) => ( | ||
<Table.Container | ||
{...restProps} | ||
className={classes.tableStriped} | ||
/> | ||
); | ||
|
||
export const TableComponent = withStyles(styles, { name: 'TableComponent' })(TableComponentBase); | ||
|
||
export default class Demo extends React.PureComponent { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
columns: [ | ||
{ name: 'region', title: 'Region' }, | ||
{ name: 'sector', title: 'Sector' }, | ||
{ name: 'channel', title: 'Channel' }, | ||
{ name: 'customer', title: 'Customer' }, | ||
{ name: 'product', title: 'Product' }, | ||
{ name: 'amount', title: 'Sale Amount' }, | ||
], | ||
rows: generateRows({ columnValues: globalSalesValues, length: 8 }), | ||
}; | ||
} | ||
render() { | ||
const { rows, columns } = this.state; | ||
|
||
return ( | ||
<Paper> | ||
<Grid | ||
rows={rows} | ||
columns={columns} | ||
> | ||
<Table | ||
tableComponent={TableComponent} | ||
/> | ||
<TableHeaderRow /> | ||
</Grid> | ||
</Paper> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,19 +5,18 @@ import { | |
StaticTableLayout, | ||
} from '@devexpress/dx-react-grid'; | ||
import { TableContainer } from './table-container'; | ||
import { Table } from './table'; | ||
|
||
const MINIMAL_COLUMN_WIDTH = 120; | ||
|
||
const TableHead = props => <thead {...props} />; | ||
const TableBody = props => <tbody {...props} />; | ||
|
||
export const TableLayout = ({ | ||
headerRows, | ||
bodyRows, | ||
columns, | ||
cellComponent, | ||
rowComponent, | ||
tableComponent, | ||
headComponent, | ||
bodyComponent, | ||
}) => ( | ||
<TableLayoutCore | ||
layoutComponent={StaticTableLayout} | ||
|
@@ -26,9 +25,9 @@ export const TableLayout = ({ | |
columns={columns} | ||
minColumnWidth={MINIMAL_COLUMN_WIDTH} | ||
containerComponent={TableContainer} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is the Container/Root component. Should we publish it too? |
||
tableComponent={Table} | ||
headComponent={TableHead} | ||
bodyComponent={TableBody} | ||
tableComponent={tableComponent} | ||
headComponent={headComponent} | ||
bodyComponent={bodyComponent} | ||
rowComponent={rowComponent} | ||
cellComponent={cellComponent} | ||
/> | ||
|
@@ -40,4 +39,7 @@ TableLayout.propTypes = { | |
columns: PropTypes.array.isRequired, | ||
cellComponent: PropTypes.func.isRequired, | ||
rowComponent: PropTypes.func.isRequired, | ||
tableComponent: PropTypes.func.isRequired, | ||
headComponent: PropTypes.func.isRequired, | ||
bodyComponent: PropTypes.func.isRequired, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
packages/dx-react-grid-bootstrap3/src/templates/table.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import * as React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import { Table } from './table'; | ||
|
||
describe('Table', () => { | ||
it('should pass class to the root element', () => { | ||
const tree = mount(( | ||
<div className="panel"> | ||
<Table className="custom-class"> | ||
<tbody /> | ||
</Table> | ||
</div> | ||
)); | ||
|
||
expect(tree.find('table').is('.custom-class')) | ||
.toBeTruthy(); | ||
expect(tree.find('table').is('.table')) | ||
.toBeTruthy(); | ||
}); | ||
|
||
it('should pass rest props to the root element', () => { | ||
const tree = mount(( | ||
<div className="panel"> | ||
<Table data={{ a: 1 }}> | ||
<tbody /> | ||
</Table> | ||
</div> | ||
)); | ||
|
||
expect(tree.find('table').props().data) | ||
.toMatchObject({ a: 1 }); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Container? Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Table
name was better?