Skip to content
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

Removing FixedDataTableCell div #687

Open
wants to merge 33 commits into
base: column-virtualization
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
f7b8628
Impl
Jun 10, 2023
c4e8c63
changes
Jun 12, 2023
fde920c
Remove cell group div checking of code for different examples is pending
Archit101967 Jun 14, 2023
f475a20
Final code after removing CellGroup div
Archit101967 Jun 14, 2023
b90f33a
Choice on user whether to use new or old version
Archit101967 Jun 17, 2023
4fe0bc9
added if conditions at some places
Archit101967 Jun 19, 2023
4ff2935
Made legacy components for each component
Archit101967 Jun 21, 2023
51696af
Converted the code to use HOC components
Archit101967 Jun 21, 2023
f4af336
Updated some part of the code
Archit101967 Jun 21, 2023
31fbf7e
after removing unnecessary changes
Archit101967 Jun 21, 2023
5aabef5
Rebuild the node modules
Archit101967 Jun 21, 2023
d10313a
react-fps added
Archit101967 Jun 22, 2023
a7f6949
added CSS
Archit101967 Jun 22, 2023
9006cbd
Resize and reorder cell not fixed
Archit101967 Jun 24, 2023
f46247d
some changes
Archit101967 Jun 25, 2023
02ec021
Fixed resize example
Archit101967 Jun 26, 2023
8c90fec
working on reorder cell
Archit101967 Jun 26, 2023
ec226ff
working on dragging feature of reorder still remaining
Archit101967 Jun 26, 2023
f6dc4a7
container coming to right position
Archit101967 Jun 27, 2023
77b730b
reorder cell resolved
Archit101967 Jun 27, 2023
1fe34ad
HOC components made
Archit101967 Jun 27, 2023
eeef456
updated the auto scroll example
Archit101967 Jun 28, 2023
2cfdf0d
removed extra spaces
Archit101967 Jun 28, 2023
44b9a96
Updated the auto scroll example
Archit101967 Jun 28, 2023
71203f3
removed package-lock.json and tools used for internal testing
Archit101967 Jun 29, 2023
505204a
removed internal testing from autoscrollexample_changed.js
Archit101967 Jun 29, 2023
329a443
changed variable names and will fix autoscroll example
Archit101967 Jun 29, 2023
479796e
fixed auto scroll example
Archit101967 Jun 30, 2023
31dc976
seperated the HOC components into different folder
Archit101967 Jun 30, 2023
c419014
Checking performance
Archit101967 Jul 2, 2023
1e5dfd8
correcting reorder cell
Archit101967 Jul 4, 2023
57cdf03
corrected reorder cell rendering issue
Archit101967 Jul 4, 2023
a813f30
corrected variable names and also fixed reorder cell example in other…
Archit101967 Jul 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion dist/fixed-data-table-base.css
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@

.fixedDataTableCellLayout_columnResizerContainer {
position: absolute;
right: 0px;
width: 6px;
z-index: 1;
}
Expand Down
1 change: 0 additions & 1 deletion dist/fixed-data-table-base.min.css
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@

.fixedDataTableCellLayout_columnResizerContainer {
position: absolute;
right: 0px;
width: 6px;
z-index: 1;
}
Expand Down
1 change: 0 additions & 1 deletion dist/fixed-data-table.css
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@

.fixedDataTableCellLayout_columnResizerContainer {
position: absolute;
right: 0px;
width: 6px;
z-index: 1;
}
Expand Down
184 changes: 162 additions & 22 deletions dist/fixed-data-table.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion dist/fixed-data-table.min.css
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@

.fixedDataTableCellLayout_columnResizerContainer {
position: absolute;
right: 0px;
width: 6px;
z-index: 1;
}
Expand Down
144 changes: 122 additions & 22 deletions dist/fixed-data-table.min.js

Large diffs are not rendered by default.

42 changes: 36 additions & 6 deletions examples/AutoScrollExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
'use strict';

import FakeObjectDataListStore from './helpers/FakeObjectDataListStore';
import { ImageCell, LinkCell } from './helpers/cells';
import { ImageCell, LinkCell, TextCell } from './helpers/cells';
import { Table, Column, DataCell, Plugins } from 'fixed-data-table-2';
import React from 'react';
import cx from '../src/vendor_upstream/stubs/cx';
import joinClasses from '../src/vendor_upstream/core/joinClasses';

class AutoScrollExample extends React.Component {
constructor(props) {
super(props);

this.state = {
dataList: new FakeObjectDataListStore(10000),
scrollTop: 0,
Expand All @@ -23,18 +24,46 @@ class AutoScrollExample extends React.Component {
columns: [],
columnGroups: [],
columnsCount: 10000,
shouldUseLegacyComponents: false, //we have to pass this as a prop to FixedDataTableContainer
};
// let shouldUseLegacyComponents=false;
// this.cellRenderer_datacell= this.cellRenderer_datacell(this);
//these are legacy function because we are already providing the styles in FixedDataTableCell for this so there is no need of any div here
const cellRenderer_legacy = (props) =>
`${props.columnKey}, ${props.rowIndex}`;

const headerCellRenderer_legacy = (props) => props.columnKey;

const cellRenderer_datacell = (props) => (
<DataCell {...props}>
{props.columnKey},{props.rowIndex}
</DataCell>
);
const cellRenderer_div = (props) => (
<div style={props.style_default} className={props.className_default}>
{props.columnKey}, {props.rowIndex}
</div>
);
//user can pass any function as here we passed cellRenderer_div
//we have to pass the default styles which we were earlier providing in the FixedDataTableCell div

const cellRenderer = (props) => `${props.columnKey}, ${props.rowIndex}`;
const headerCellRenderer = (props) => props.columnKey;
const headerCellRenderer = (props) => (
<DataCell {...props}>{props.columnKey}</DataCell>
);

for (let i = 0; i < 10000; i++) {
const columnGroupIndex = Math.floor(i / 2);
this.state.columns[i] = {
columnKey: 'Column ' + i,
columnGroupIndex,
header: headerCellRenderer,
cell: cellRenderer,
header: this.state.shouldUseLegacyComponents
? headerCellRenderer_legacy
: headerCellRenderer,
cell: this.state.shouldUseLegacyComponents
? cellRenderer_legacy
: i % 2
? cellRenderer_datacell
: cellRenderer_div,
width: 100,
allowCellsRecycling: true,
fixed: i < 2 ? true : false,
Expand Down Expand Up @@ -123,6 +152,7 @@ class AutoScrollExample extends React.Component {
columnsCount={this.state.columnsCount}
getColumn={(i) => this.state.columns[i]}
getColumnGroup={(i) => this.state.columnGroups[i]}
shouldUseLegacyComponents={this.state.shouldUseLegacyComponents}
{...this.props}
/>
);
Expand Down
6 changes: 6 additions & 0 deletions src/FixedDataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,8 @@ class FixedDataTable extends React.Component {
* ```
*/
rowAttributesGetter: PropTypes.func,

shouldUseLegacyComponents: PropTypes.bool,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also write description for this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

};

static defaultProps = /*object*/ {
Expand Down Expand Up @@ -872,6 +874,7 @@ class FixedDataTable extends React.Component {
fixedColumnsWidth={this.props.fixedColumnsWidth}
fixedRightColumnsWidth={this.props.fixedRightColumnsWidth}
isGroupHeader={true}
shouldUseLegacyComponents={this.props.shouldUseLegacyComponents}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declare proptype for shouldUseLegacyComponents above.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

/>
);
}
Expand Down Expand Up @@ -923,6 +926,7 @@ class FixedDataTable extends React.Component {
endViewportColumnIndex={this.props.endColumnIndex}
fixedColumnsWidth={this.props.fixedColumnsWidth}
fixedRightColumnsWidth={this.props.fixedRightColumnsWidth}
shouldUseLegacyComponents={this.props.shouldUseLegacyComponents}
/>
);
}
Expand Down Expand Up @@ -976,6 +980,7 @@ class FixedDataTable extends React.Component {
fixedRightColumnsWidth={this.props.fixedRightColumnsWidth}
firstViewportColumnIndex={this.props.firstColumnIndex}
endViewportColumnIndex={this.props.endColumnIndex}
shouldUseLegacyComponents={this.props.shouldUseLegacyComponents}
/>
);

Expand Down Expand Up @@ -1123,6 +1128,7 @@ class FixedDataTable extends React.Component {
fixedRightColumnsWidth={this.props.fixedRightColumnsWidth}
scrollbarYWidth={props.scrollbarYWidth}
isRTL={props.isRTL}
shouldUseLegacyComponents={this.props.shouldUseLegacyComponents}
/>
);
};
Expand Down
2 changes: 2 additions & 0 deletions src/FixedDataTableBufferedRows.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,10 @@ class FixedDataTableBufferedRows extends React.Component {
fixedRightColumnsWidth={this.props.fixedRightColumnsWidth}
firstViewportColumnIndex={this.props.firstViewportColumnIndex}
endViewportColumnIndex={this.props.endViewportColumnIndex}
shouldUseLegacyComponents={this.props.shouldUseLegacyComponents}
/>
);
}
}
//}
export default FixedDataTableBufferedRows;
18 changes: 13 additions & 5 deletions src/FixedDataTableCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import { polyfill as lifecycleCompatibilityPolyfill } from 'react-lifecycles-com
import ReorderCell from './plugins/ResizeReorder/ReorderCell';
import ResizeCell from './plugins/ResizeReorder/ResizeCell';
import { CellGroupType } from './enums/CellGroup';
import Cell from './hoc_components/FixedDataTableCellFunction';
import CellLegacy from './hoc_components/FixedDataTableCellLegacyFunction';

class FixedDataTableCell extends React.Component {
/**
Expand Down Expand Up @@ -223,6 +225,9 @@ class FixedDataTableCell extends React.Component {
height: this.props.height,
width: this.props.width,
left: this.props.left,
shouldUseLegacyComponents: this.props.shouldUseLegacyComponents,
style_default: style,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and every other place, use camelcase name.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

className_default: className,
};

if (props.rowIndex >= 0) {
Expand Down Expand Up @@ -286,13 +291,16 @@ class FixedDataTableCell extends React.Component {
</FixedDataTableCellDefaultDeprecated>
);
}

const role = isHeaderOrFooter ? 'columnheader' : 'gridcell';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not remove role. keep it for legacy cell as it is, for new cell this could also be added in props.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

const CellComponent = this.props.shouldUseLegacyComponents
? CellLegacy
: Cell;

return (
<div className={className} style={style} role={role}>
{content}
</div>
<CellComponent
className_default={className}
style_default={style}
content={content}
/>
);
}
}
Expand Down
42 changes: 6 additions & 36 deletions src/FixedDataTableCellDefault.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import PropTypes from 'prop-types';

import cx from './vendor_upstream/stubs/cx';
import joinClasses from './vendor_upstream/core/joinClasses';
import CellDefault from './hoc_components/FixedDataTableCellDefaultFunction';
import CellDefaultLegacy from './hoc_components/FixedDataTableCellDefaultLegacyFunction';

/**
* Component that handles default cell layout and styling.
Expand Down Expand Up @@ -70,44 +72,12 @@ class FixedDataTableCellDefault extends React.Component {

render() {
//Remove some props which we don't pass into div
var {
height,
width,
style,
className,
children,
columnKey,
columnIndex,
rowIndex,
left,
cellGroupType,
isHeader,
isGroupHeader,
maxWidth,
minWidth,
...props
} = this.props;

var innerStyle = {
height,
width,
...style,
};
const CellDefaultComponent = this.props.shouldUseLegacyComponents
? CellDefaultLegacy
: CellDefault;

return (
<div
{...props}
className={joinClasses(
cx('fixedDataTableCellLayout/wrap'),
cx('public/fixedDataTableCell/wrap'),
cx('public/fixedDataTableCell/cellContent'),
className
)}
style={innerStyle}
>
{children}
</div>
);
return <CellDefaultComponent {...this.props} />;
Copy link
Collaborator

@AmanGupta2708 AmanGupta2708 Jun 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FixedDataTableCellDefault, aka DataCell, is essentially a type of cell that clients can utilize as a cell renderer. Clients have the flexibility to use any valid element or function as a cell renderer, and we have no control over the styles they apply to them.

we want to solely apply the necessary styles to the content within the FixedDataTableCell. That content is what the client passes, which can be either a DataCell or any other customized cell, or a function that returns a cell, or simply raw data.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are passing default styles and default classNames as props from FixedDataTableCell which can be used by client if he don't want to provide any styles to it .And if a client wants to add his own styles he can do that also

}
}

Expand Down
7 changes: 6 additions & 1 deletion src/FixedDataTableCellDefaultDeprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ class FixedDataTableCellDefault extends React.Component {
var {
height,
width,
style_default,
className_default,
style,
className,
children,
Expand All @@ -94,16 +96,19 @@ class FixedDataTableCellDefault extends React.Component {
var innerStyle = {
height,
width,
...style_default,
...style,
};
if (props.onColumnReorderEnd !== undefined) innerStyle.left = '3px';

return (
<div
{...props}
className={joinClasses(
cx('fixedDataTableCellLayout/wrap1'),
cx('public/fixedDataTableCell/wrap1'),
className
className,
className_default
)}
style={innerStyle}
>
Expand Down
Loading