-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[PoC] Headless data grid exploration #20645
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
base: master
Are you sure you want to change the base?
Conversation
|
Deploy preview: https://deploy-preview-20645--material-ui-x.netlify.app/ Bundle size report
|
| private plugins: Map<string, Plugin<any, any, any, any, any>> = new Map(); | ||
| private pluginOrder: Plugin<any, any, any, any, any>[] = []; |
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.
Do we need both?
We can keep the order via the register method.
It will check the dependencies and re-create the map, so when you iterate through plugins, they will be ordered correctly.
| // 1. Create registry with internal + user plugins (order maintained) | ||
| const registry = new PluginRegistry(internalPlugins, options.plugins); | ||
|
|
||
| // 2. Initialize internal plugin states FIRST |
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.
If we have our dependencies set correctly, we don't have to do this
Plugins that don't have any dependencies can be initialized in any order.
| sortable?: boolean; | ||
| filterable?: boolean; |
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.
This needs to come from plugins (they should be able to extend ColumnDef). The same goes for row metadata.
| TState, | ||
| TApi, | ||
| TParams extends Record<string, any> = any, | ||
| TRequiredApi extends Record<string, any> = {}, |
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.
I like the idea that the plugin can require a specific API instead of another plugin. This way, you only need to satisfy the requirement. Another plugin doesn't have to provide exactly the same API (its API can have more optional parameters, but can still be used as a dependency).
For example, I need something that provides selectRow(id), but you give me selectRow(id, propagate = true).
The problem with this is how do you figure out if your requirement is fulfilled, if it comes from another plugin?
| export { useDataGrid } from './hooks/useDataGrid'; | ||
|
|
||
| // Plugins | ||
| export { default as sortingPlugin } from './plugins/sorting'; |
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.
Maybe in the core, we can only re-export everything from the plugin's index, and each plugin should make sure it has the correct exports there
| setColumns(generateColumns()); | ||
| }; | ||
|
|
||
| React.useEffect(() => { |
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.
why do we need this?
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.
I use this for checking the state and methods assigned to the grid instance object.
No description provided.