-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[DataGrid] Experimental toolbar #14611
Draft
KenanYusuf
wants to merge
74
commits into
mui:master
Choose a base branch
from
KenanYusuf:experimental-toolbar
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,621
−33
Draft
Changes from 63 commits
Commits
Show all changes
74 commits
Select commit
Hold shift + click to select a range
658c881
[DataGrid] Experimental toolbar
KenanYusuf cbf114e
fix build
KenanYusuf a363c4b
codegen
KenanYusuf a789cec
Merge branch 'master' into experimental-toolbar
KenanYusuf 94cf2db
fix import
KenanYusuf dfcae22
anchor grid panel to filter/columns buttons
KenanYusuf ed540c5
export GridToolbarV8
KenanYusuf 370af60
popover slot
KenanYusuf 0a57490
animate filter and columns panels
KenanYusuf ef8f266
fix panel animation transform origin
KenanYusuf a96e5fc
Merge branch 'master' into experimental-toolbar
KenanYusuf b1d2eb2
improve composition
KenanYusuf 9e84da1
Merge branch 'master' into experimental-toolbar
KenanYusuf cf939e9
export parts
KenanYusuf b7c8f44
update column icon
KenanYusuf 76ba05e
update density item
KenanYusuf e7ed369
Merge branch 'master' into experimental-toolbar
KenanYusuf 206faaa
docs
KenanYusuf cfee71e
Merge branch 'mui:master' into experimental-toolbar
KenanYusuf fe3f01d
GridToolbarButton
KenanYusuf 2c7b3c8
docs concept
KenanYusuf 31820e7
Add examples
KenanYusuf d5048c4
improve demos
KenanYusuf dbdada0
improve demos
KenanYusuf 5ac669e
undo some changes
KenanYusuf 3718ecb
fix demos
KenanYusuf 0e15924
update description
KenanYusuf e0bfa62
expanded button styles
KenanYusuf e7ab35e
use toggle button under the hood for the toolbar button
KenanYusuf eace306
update docs
KenanYusuf 090ebc2
fix button props
KenanYusuf 3a0cc25
update toggle group example
KenanYusuf 9d74c74
fix typo
KenanYusuf acb9fac
break sentence onto new line
KenanYusuf 1833e8e
Merge branch 'master' into experimental-toolbar
KenanYusuf 5855682
move v8 toolbar to separate folder
KenanYusuf 1647cda
rename spread
KenanYusuf 1840154
declarative toolbar interactions
KenanYusuf 3801949
update filter bar example
KenanYusuf 06d5c21
Grid components
KenanYusuf 8574d88
Merge branch 'master' into experimental-toolbar
KenanYusuf b23080a
update basic toolbar demo
KenanYusuf cf78651
delete density menu
KenanYusuf 0bd0f67
add export options to export trigger
KenanYusuf 831757a
Merge branch 'master' into experimental-toolbar
KenanYusuf 6c46f21
fix onClick prop
KenanYusuf d03b5cc
style toolbar button
KenanYusuf 5b47719
Merge branch 'master' into experimental-toolbar
KenanYusuf 973e02d
update useGridComonentRenderer to merge certain props
KenanYusuf 2ac3298
various minor updates
KenanYusuf ae6400e
docs updates
KenanYusuf 2532d3e
Merge branch 'master' into experimental-toolbar
KenanYusuf afffa0f
add demo container for data grid components
KenanYusuf 7d830b2
Update toolbar docs
KenanYusuf 670fca0
update styles
KenanYusuf fef5ad5
fix focus styles for toolbar button
KenanYusuf 0fe1a5d
improve default toolbar example
KenanYusuf f4c9226
update grid classes
KenanYusuf 9d98f2e
normalize icons
KenanYusuf 40a0b51
docs:api
KenanYusuf f012c29
update toolbar demo
KenanYusuf 1fa341a
pointer-events: none; on quick filter search icon
KenanYusuf 172db4f
use loading state from demo data
KenanYusuf 570b637
reset changes to preferences panel
KenanYusuf 9a299af
update view icons
KenanYusuf f544cd7
add class to toggle button group
KenanYusuf 5dda068
update quick filter border color
KenanYusuf f3a46dd
Merge branch 'master' into experimental-toolbar
KenanYusuf 887bf51
limit columns on toolbar demos
KenanYusuf a47cd74
doc updatse
KenanYusuf 37204a1
changed wording
KenanYusuf 8b1755e
fix demo container
KenanYusuf b29a245
remove overflow from toolbar
KenanYusuf 824ad70
Merge branch 'master' into experimental-toolbar
KenanYusuf 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
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
28 changes: 28 additions & 0 deletions
28
docs/data/data-grid/components/columns-panel/GridColumnsPanelTrigger.js
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,28 @@ | ||
import * as React from 'react'; | ||
import { DataGrid, Grid } from '@mui/x-data-grid'; | ||
import { useDemoData } from '@mui/x-data-grid-generator'; | ||
import ViewColumnIcon from '@mui/icons-material/ViewColumn'; | ||
|
||
function Toolbar() { | ||
return ( | ||
<Grid.Toolbar.Root> | ||
<Grid.ColumnsPanel.Trigger render={<Grid.Toolbar.Button />}> | ||
<ViewColumnIcon fontSize="small" /> | ||
Columns | ||
</Grid.ColumnsPanel.Trigger> | ||
</Grid.Toolbar.Root> | ||
); | ||
} | ||
|
||
export default function GridColumnsPanelTrigger() { | ||
const { data, loading } = useDemoData({ | ||
dataSet: 'Commodity', | ||
rowLength: 10, | ||
}); | ||
|
||
return ( | ||
<div style={{ height: 400, width: '100%' }}> | ||
<DataGrid {...data} loading={loading} slots={{ toolbar: Toolbar }} /> | ||
</div> | ||
); | ||
} |
28 changes: 28 additions & 0 deletions
28
docs/data/data-grid/components/columns-panel/GridColumnsPanelTrigger.tsx
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,28 @@ | ||
import * as React from 'react'; | ||
import { DataGrid, Grid } from '@mui/x-data-grid'; | ||
import { useDemoData } from '@mui/x-data-grid-generator'; | ||
import ViewColumnIcon from '@mui/icons-material/ViewColumn'; | ||
|
||
function Toolbar() { | ||
return ( | ||
<Grid.Toolbar.Root> | ||
<Grid.ColumnsPanel.Trigger render={<Grid.Toolbar.Button />}> | ||
<ViewColumnIcon fontSize="small" /> | ||
Columns | ||
</Grid.ColumnsPanel.Trigger> | ||
</Grid.Toolbar.Root> | ||
); | ||
} | ||
|
||
export default function GridColumnsPanelTrigger() { | ||
const { data, loading } = useDemoData({ | ||
dataSet: 'Commodity', | ||
rowLength: 10, | ||
}); | ||
|
||
return ( | ||
<div style={{ height: 400, width: '100%' }}> | ||
<DataGrid {...data} loading={loading} slots={{ toolbar: Toolbar }} /> | ||
</div> | ||
); | ||
} |
1 change: 1 addition & 0 deletions
1
docs/data/data-grid/components/columns-panel/GridColumnsPanelTrigger.tsx.preview
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 @@ | ||
<DataGrid {...data} loading={loading} slots={{ toolbar: Toolbar }} /> |
39 changes: 39 additions & 0 deletions
39
docs/data/data-grid/components/columns-panel/columns-panel.md
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,39 @@ | ||
# Data Grid - Columns Panel component 🚧 | ||
|
||
<p class="description">Customize the columns panel UI.</p> | ||
|
||
:::warning | ||
This component is incomplete. | ||
|
||
Currently, the only feature available for the Columns Panel component is the Trigger. In the future, this component will allow you to extend the data grid's columns panel. | ||
Check warning on line 8 in docs/data/data-grid/components/columns-panel/columns-panel.md GitHub Actions / runner / vale
|
||
::: | ||
|
||
## Anatomy | ||
|
||
The `Grid.ColumnsPanel` component is comprised of the following parts. | ||
|
||
```tsx | ||
<Grid.ColumnsPanel.Trigger /> | ||
``` | ||
|
||
### Trigger | ||
|
||
A button that opens the columns panel. | ||
|
||
Renders a [Button](/material-ui/react-button/) component or a custom button provided to `slots.baseButton`. | ||
|
||
## Examples | ||
|
||
Below are some ways the Columns Panel component can be used. | ||
|
||
### Toolbar columns panel trigger | ||
|
||
Toggle the visibility of the columns panel. | ||
|
||
{{"demo": "GridColumnsPanelTrigger.js", "bg": "inline"}} | ||
|
||
## API | ||
|
||
- [Grid](/x/api/data-grid/data-grid/) | ||
- [GridColumnsPanel](/x/api/data-grid/data-grid/) | ||
- [GridColumnsPanelTrigger](/x/api/data-grid/data-grid/) |
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 * as React from 'react'; | ||
import { DataGrid, Grid } from '@mui/x-data-grid'; | ||
import { useDemoData } from '@mui/x-data-grid-generator'; | ||
import Menu from '@mui/material/Menu'; | ||
import MenuItem from '@mui/material/MenuItem'; | ||
import FileDownloadIcon from '@mui/icons-material/FileDownload'; | ||
import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown'; | ||
|
||
function ExportMenu() { | ||
const [open, setOpen] = React.useState(false); | ||
const triggerRef = React.useRef(null); | ||
|
||
return ( | ||
<React.Fragment> | ||
<Grid.Toolbar.Button | ||
ref={triggerRef} | ||
id="export-menu-trigger" | ||
aria-controls="export-menu" | ||
aria-haspopup="true" | ||
aria-expanded={open ? 'true' : undefined} | ||
onClick={() => setOpen(true)} | ||
> | ||
<FileDownloadIcon fontSize="small" /> | ||
Export | ||
<ArrowDropDownIcon fontSize="small" sx={{ mx: -0.5 }} /> | ||
</Grid.Toolbar.Button> | ||
<Menu | ||
id="export-menu" | ||
anchorEl={triggerRef.current} | ||
open={open} | ||
onClose={() => setOpen(false)} | ||
MenuListProps={{ | ||
'aria-labelledby': 'export-menu-trigger', | ||
}} | ||
> | ||
<Grid.Export.Trigger exportType="csv" render={<MenuItem />}> | ||
Download as CSV | ||
</Grid.Export.Trigger> | ||
<Grid.Export.Trigger exportType="print" render={<MenuItem />}> | ||
</Grid.Export.Trigger> | ||
</Menu> | ||
</React.Fragment> | ||
); | ||
} | ||
|
||
function Toolbar() { | ||
return ( | ||
<Grid.Toolbar.Root> | ||
<ExportMenu /> | ||
</Grid.Toolbar.Root> | ||
); | ||
} | ||
|
||
export default function GridExportMenu() { | ||
const { data, loading } = useDemoData({ | ||
dataSet: 'Commodity', | ||
rowLength: 10, | ||
}); | ||
|
||
return ( | ||
<div style={{ height: 400, width: '100%' }}> | ||
<DataGrid {...data} loading={loading} slots={{ toolbar: Toolbar }} /> | ||
</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 * as React from 'react'; | ||
import { DataGrid, Grid } from '@mui/x-data-grid'; | ||
import { useDemoData } from '@mui/x-data-grid-generator'; | ||
import Menu from '@mui/material/Menu'; | ||
import MenuItem from '@mui/material/MenuItem'; | ||
import FileDownloadIcon from '@mui/icons-material/FileDownload'; | ||
import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown'; | ||
|
||
function ExportMenu() { | ||
const [open, setOpen] = React.useState(false); | ||
const triggerRef = React.useRef<HTMLButtonElement>(null); | ||
|
||
return ( | ||
<React.Fragment> | ||
<Grid.Toolbar.Button | ||
ref={triggerRef} | ||
id="export-menu-trigger" | ||
aria-controls="export-menu" | ||
aria-haspopup="true" | ||
aria-expanded={open ? 'true' : undefined} | ||
onClick={() => setOpen(true)} | ||
> | ||
<FileDownloadIcon fontSize="small" /> | ||
Export | ||
<ArrowDropDownIcon fontSize="small" sx={{ mx: -0.5 }} /> | ||
</Grid.Toolbar.Button> | ||
<Menu | ||
id="export-menu" | ||
anchorEl={triggerRef.current} | ||
open={open} | ||
onClose={() => setOpen(false)} | ||
MenuListProps={{ | ||
'aria-labelledby': 'export-menu-trigger', | ||
}} | ||
> | ||
<Grid.Export.Trigger exportType="csv" render={<MenuItem />}> | ||
Download as CSV | ||
</Grid.Export.Trigger> | ||
<Grid.Export.Trigger exportType="print" render={<MenuItem />}> | ||
</Grid.Export.Trigger> | ||
</Menu> | ||
</React.Fragment> | ||
); | ||
} | ||
|
||
function Toolbar() { | ||
return ( | ||
<Grid.Toolbar.Root> | ||
<ExportMenu /> | ||
</Grid.Toolbar.Root> | ||
); | ||
} | ||
|
||
export default function GridExportMenu() { | ||
const { data, loading } = useDemoData({ | ||
dataSet: 'Commodity', | ||
rowLength: 10, | ||
}); | ||
|
||
return ( | ||
<div style={{ height: 400, width: '100%' }}> | ||
<DataGrid {...data} loading={loading} slots={{ toolbar: Toolbar }} /> | ||
</div> | ||
); | ||
} |
1 change: 1 addition & 0 deletions
1
docs/data/data-grid/components/export/GridExportMenu.tsx.preview
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 @@ | ||
<DataGrid {...data} loading={loading} slots={{ toolbar: Toolbar }} /> |
33 changes: 33 additions & 0 deletions
33
docs/data/data-grid/components/export/GridExportTrigger.js
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 { DataGrid, Grid } from '@mui/x-data-grid'; | ||
import { useDemoData } from '@mui/x-data-grid-generator'; | ||
import FileDownloadIcon from '@mui/icons-material/FileDownload'; | ||
import PrintIcon from '@mui/icons-material/Print'; | ||
|
||
function Toolbar() { | ||
return ( | ||
<Grid.Toolbar.Root> | ||
<Grid.Export.Trigger exportType="csv" render={<Grid.Toolbar.Button />}> | ||
<FileDownloadIcon fontSize="small" /> | ||
CSV | ||
</Grid.Export.Trigger> | ||
<Grid.Export.Trigger exportType="print" render={<Grid.Toolbar.Button />}> | ||
<PrintIcon fontSize="small" /> | ||
</Grid.Export.Trigger> | ||
</Grid.Toolbar.Root> | ||
); | ||
} | ||
|
||
export default function GridExportTrigger() { | ||
const { data, loading } = useDemoData({ | ||
dataSet: 'Commodity', | ||
rowLength: 10, | ||
}); | ||
|
||
return ( | ||
<div style={{ height: 400, width: '100%' }}> | ||
<DataGrid {...data} loading={loading} slots={{ toolbar: Toolbar }} /> | ||
</div> | ||
); | ||
} |
33 changes: 33 additions & 0 deletions
33
docs/data/data-grid/components/export/GridExportTrigger.tsx
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 { DataGrid, Grid } from '@mui/x-data-grid'; | ||
import { useDemoData } from '@mui/x-data-grid-generator'; | ||
import FileDownloadIcon from '@mui/icons-material/FileDownload'; | ||
import PrintIcon from '@mui/icons-material/Print'; | ||
|
||
function Toolbar() { | ||
return ( | ||
<Grid.Toolbar.Root> | ||
<Grid.Export.Trigger exportType="csv" render={<Grid.Toolbar.Button />}> | ||
<FileDownloadIcon fontSize="small" /> | ||
CSV | ||
</Grid.Export.Trigger> | ||
<Grid.Export.Trigger exportType="print" render={<Grid.Toolbar.Button />}> | ||
<PrintIcon fontSize="small" /> | ||
</Grid.Export.Trigger> | ||
</Grid.Toolbar.Root> | ||
); | ||
} | ||
|
||
export default function GridExportTrigger() { | ||
const { data, loading } = useDemoData({ | ||
dataSet: 'Commodity', | ||
rowLength: 10, | ||
}); | ||
|
||
return ( | ||
<div style={{ height: 400, width: '100%' }}> | ||
<DataGrid {...data} loading={loading} slots={{ toolbar: Toolbar }} /> | ||
</div> | ||
); | ||
} |
1 change: 1 addition & 0 deletions
1
docs/data/data-grid/components/export/GridExportTrigger.tsx.preview
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 @@ | ||
<DataGrid {...data} loading={loading} slots={{ toolbar: Toolbar }} /> |
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,39 @@ | ||
# Data Grid - Export component | ||
|
||
<p class="description">Components to trigger exports of the Data Grid.</p> | ||
|
||
## Anatomy | ||
|
||
The `Grid.Export` component is comprised of the following parts. | ||
|
||
```tsx | ||
<Grid.Export.Trigger /> | ||
``` | ||
|
||
### Trigger | ||
|
||
A button that triggers an export. | ||
|
||
The `exportType` prop can be set to `print`, `csv` or `excel`[<span class="plan-premium"></span>](/x/introduction/licensing/#premium-plan 'Premium plan'). | ||
|
||
## Examples | ||
|
||
Below are some ways the Export component can be used. | ||
|
||
### Toolbar export buttons | ||
|
||
Display export options as buttons on the toolbar. | ||
|
||
{{"demo": "GridExportTrigger.js", "bg": "inline"}} | ||
|
||
### Toolbar export menu | ||
|
||
Display export options within a menu on the toolbar. | ||
|
||
{{"demo": "GridExportMenu.js", "bg": "inline"}} | ||
|
||
## API | ||
|
||
- [Grid](/x/api/data-grid/data-grid/) | ||
- [GridExport](/x/api/data-grid/data-grid/) | ||
- [GridExportTrigger](/x/api/data-grid/data-grid/) |
28 changes: 28 additions & 0 deletions
28
docs/data/data-grid/components/filter-panel/GridFilterPanelTrigger.js
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,28 @@ | ||
import * as React from 'react'; | ||
import { DataGrid, Grid } from '@mui/x-data-grid'; | ||
import { useDemoData } from '@mui/x-data-grid-generator'; | ||
import FilterListIcon from '@mui/icons-material/FilterList'; | ||
|
||
function Toolbar() { | ||
return ( | ||
<Grid.Toolbar.Root> | ||
<Grid.FilterPanel.Trigger render={<Grid.Toolbar.Button />}> | ||
<FilterListIcon fontSize="small" /> | ||
Filters | ||
</Grid.FilterPanel.Trigger> | ||
</Grid.Toolbar.Root> | ||
); | ||
} | ||
|
||
export default function GridFilterPanelTrigger() { | ||
const { data, loading } = useDemoData({ | ||
dataSet: 'Commodity', | ||
rowLength: 10, | ||
}); | ||
|
||
return ( | ||
<div style={{ height: 400, width: '100%' }}> | ||
<DataGrid {...data} loading={loading} slots={{ toolbar: Toolbar }} /> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.
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.
I expected the
render
prop to accept a function since it's an established pattern. Then I checked Base UI docs and realized that they support both signatures. I like the flexibility of this approach 👍🏻.