-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from komarovalexander/dev
Decrease ka-table package size and fix row customization
- Loading branch information
Showing
25 changed files
with
162 additions
and
216 deletions.
There are no files selected for viewing
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 was deleted.
Oops, something went wrong.
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
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
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
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,10 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
|
||
import ManyRowsMemoDemo from './ManyRowsMemoDemo'; | ||
|
||
it('renders without crashing', () => { | ||
const div = document.createElement('div'); | ||
ReactDOM.render(<ManyRowsMemoDemo />, div); | ||
ReactDOM.unmountComponentAtNode(div); | ||
}); |
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,66 @@ | ||
import React, { useState } from 'react'; | ||
|
||
import { ITableProps, kaReducer, Table } from '../../lib'; | ||
import DataRowContent from '../../lib/Components/DataRowContent/DataRowContent'; | ||
import { DataType } from '../../lib/enums'; | ||
import { IDataRowProps } from '../../lib/props'; | ||
import { DispatchFunc } from '../../lib/types'; | ||
|
||
let dataArray: any[]; | ||
|
||
const getDataArray = () => { | ||
if (!dataArray){ | ||
dataArray = Array(300000).fill(undefined).map( | ||
(_, index) => ({ | ||
column1: `column:1 row:${index}`, | ||
column2: `column:2 row:${index}`, | ||
column3: `column:3 row:${index}`, | ||
column4: `column:4 row:${index}`, | ||
id: index, | ||
}), | ||
); | ||
} | ||
return dataArray; | ||
}; | ||
|
||
const tablePropsInit: ITableProps = { | ||
columns: [ | ||
{ key: 'column1', title: 'Column 1', dataType: DataType.String }, | ||
{ key: 'column2', title: 'Column 2', dataType: DataType.String }, | ||
{ key: 'column3', title: 'Column 3', dataType: DataType.String }, | ||
{ key: 'column4', title: 'Column 4', dataType: DataType.String }, | ||
], | ||
rowKeyField: 'id', | ||
virtualScrolling: { | ||
enabled: true | ||
}, | ||
}; | ||
|
||
const DataRowContentMemo = React.memo((props: IDataRowProps) => <DataRowContent {...props}/>, () => true); | ||
|
||
const ManyRowsMemoDemo: React.FC = () => { | ||
const [tableProps, changeTableProps] = useState({ ...tablePropsInit, data: getDataArray() }); | ||
const dispatch: DispatchFunc = (action) => { | ||
changeTableProps((prevState: ITableProps) => kaReducer(prevState, action)); | ||
}; | ||
|
||
return ( | ||
<Table | ||
{...tableProps} | ||
dispatch={dispatch} | ||
childComponents={{ | ||
cellText: { | ||
elementAttributes: () => ({ style: {lineHeight: '25px'} }), | ||
}, | ||
dataRow: { | ||
content: (props: IDataRowProps) => <DataRowContentMemo {...props}/> | ||
}, | ||
tableWrapper: { | ||
elementAttributes: () => ({ style: { maxHeight: 600 }}) | ||
} | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
export default ManyRowsMemoDemo; |
Oops, something went wrong.