-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[core] Rework internal prop management to prepare for bundle split #3487
Conversation
@@ -244,20 +518,6 @@ interface GridComponentOtherProps extends CommonProps { | |||
* @param {GridCallbackDetails} details Additional details for this callback. | |||
*/ | |||
onColumnOrderChange?: GridEventListener<GridEvents.columnOrderChange>; |
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.
Should this also be moved to DataGridProProps.ts
? Users can only reorder columns in DataGridPro.
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.
The event is fired by setColumnIndex
which is in useGridColumns
So technically, users can create a toolbar and use apiRef.current.setColumnIndex
in it.
But we said we wanted to move it to useGridColumnReorder
.
If we confirm that we'll do it, I can move onColumnOrderChange
to the pro interface.
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.
Yes, they can but if they call in a toolbar while using DataGrid it won't work correctly because only DataGridPro listens for this event.
apiRef.current.setColumnIndex
could be understood as part of the column reorder API, so it wouldn't be available in DataGrid.
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.
Indeed
In that case I propose to move the code for setColumnIndex
to useGridColumnReorder
to clarify this buggy scenario and clean the typing
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.
It can be done later.
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Introduction
I started working on #924, but our current prop interfaces are not suited for this split.
All our code, even the one used on the Community Plan uses
GridComponentProps
which includes all the pro-only props.So if we split the bundle without changing this approach, we would need to set all the pro-types inside
x-data-grid
(GridPinnedColumns
,GridGroupingColDefOverride
, etc...).The new approach allows several things:
Don't have to set forced props on
DataGrid
for props which are only used on pro-only hooks. Even if the user setstreeData: true
, he won't have the Tree Data since it's not even bundled => Done in this PRDefine different interfaces for some important props (
initialState
/apiRef
/colDef
for instance) => Not done in this PRNote that this PR is a 1st step, it has some dirty imports / exports because I still have the
_modules_
folder.Current behavior
We have a single interface
GridComponentProps
used in our entire internal codebase.New behavior
Have two interfaces in our internal codebase
DataGridProcessedProps
: used on any code that will be bundled in thex-data-grid
packageDataGridProProcessedProps
: used on any code that will only be bundled inx-data-grid-pro
packageProps removed from
DataGrid
I removed
onColumnResize
andonColumnWidthChange
props fromDataGrid
because they are only fired inuseGridColumnResize
so they were never actually used onDataGrid
.It is not a breaking change, people can still pass them, the only error will be a typing one.
Whats next
GridApi
,GridState
andGridInitialState
into a pro and a community interfaceI did a MVP locally
packages/grid/x-data-grid-pro
At this point we would be sure that the Community Plan do not bundle anything that is in this folder (
packages/grid/x-data-grid
A major thing to clarify here is how to use non-exported elements from the
x-data-grid
package inside thex-data-grid-pro
.For instance how to use all the feature hooks (
useGridFilter
, ...), the internal types (GridColumnRawLookup
, ...), the default options (DATA_GRID_DEFAULT_SIMPLE_OPTIONS
) etc...We can import directly from the other package folder but it's not very clean