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

[DataGrid] Experimental toolbar #14611

Draft
wants to merge 74 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 63 commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
658c881
[DataGrid] Experimental toolbar
KenanYusuf Sep 13, 2024
cbf114e
fix build
KenanYusuf Sep 13, 2024
a363c4b
codegen
KenanYusuf Sep 13, 2024
a789cec
Merge branch 'master' into experimental-toolbar
KenanYusuf Sep 13, 2024
94cf2db
fix import
KenanYusuf Sep 13, 2024
dfcae22
anchor grid panel to filter/columns buttons
KenanYusuf Sep 18, 2024
ed540c5
export GridToolbarV8
KenanYusuf Sep 18, 2024
370af60
popover slot
KenanYusuf Sep 18, 2024
0a57490
animate filter and columns panels
KenanYusuf Sep 18, 2024
ef8f266
fix panel animation transform origin
KenanYusuf Sep 18, 2024
a96e5fc
Merge branch 'master' into experimental-toolbar
KenanYusuf Sep 20, 2024
b1d2eb2
improve composition
KenanYusuf Sep 20, 2024
9e84da1
Merge branch 'master' into experimental-toolbar
KenanYusuf Nov 1, 2024
cf939e9
export parts
KenanYusuf Nov 1, 2024
b7c8f44
update column icon
KenanYusuf Nov 4, 2024
76ba05e
update density item
KenanYusuf Nov 4, 2024
e7ed369
Merge branch 'master' into experimental-toolbar
KenanYusuf Nov 5, 2024
206faaa
docs
KenanYusuf Nov 5, 2024
cfee71e
Merge branch 'mui:master' into experimental-toolbar
KenanYusuf Nov 5, 2024
fe3f01d
GridToolbarButton
KenanYusuf Nov 6, 2024
2c7b3c8
docs concept
KenanYusuf Nov 6, 2024
31820e7
Add examples
KenanYusuf Nov 7, 2024
d5048c4
improve demos
KenanYusuf Nov 7, 2024
dbdada0
improve demos
KenanYusuf Nov 7, 2024
5ac669e
undo some changes
KenanYusuf Nov 7, 2024
3718ecb
fix demos
KenanYusuf Nov 7, 2024
0e15924
update description
KenanYusuf Nov 7, 2024
e0bfa62
expanded button styles
KenanYusuf Nov 7, 2024
e7ab35e
use toggle button under the hood for the toolbar button
KenanYusuf Nov 7, 2024
eace306
update docs
KenanYusuf Nov 7, 2024
090ebc2
fix button props
KenanYusuf Nov 7, 2024
3a0cc25
update toggle group example
KenanYusuf Nov 7, 2024
9d74c74
fix typo
KenanYusuf Nov 7, 2024
acb9fac
break sentence onto new line
KenanYusuf Nov 8, 2024
1833e8e
Merge branch 'master' into experimental-toolbar
KenanYusuf Nov 13, 2024
5855682
move v8 toolbar to separate folder
KenanYusuf Nov 13, 2024
1647cda
rename spread
KenanYusuf Nov 14, 2024
1840154
declarative toolbar interactions
KenanYusuf Nov 14, 2024
3801949
update filter bar example
KenanYusuf Nov 14, 2024
06d5c21
Grid components
KenanYusuf Nov 15, 2024
8574d88
Merge branch 'master' into experimental-toolbar
KenanYusuf Nov 18, 2024
b23080a
update basic toolbar demo
KenanYusuf Nov 18, 2024
cf78651
delete density menu
KenanYusuf Nov 19, 2024
0bd0f67
add export options to export trigger
KenanYusuf Nov 22, 2024
831757a
Merge branch 'master' into experimental-toolbar
KenanYusuf Nov 22, 2024
6c46f21
fix onClick prop
KenanYusuf Nov 25, 2024
d03b5cc
style toolbar button
KenanYusuf Nov 25, 2024
5b47719
Merge branch 'master' into experimental-toolbar
KenanYusuf Nov 26, 2024
973e02d
update useGridComonentRenderer to merge certain props
KenanYusuf Nov 27, 2024
2ac3298
various minor updates
KenanYusuf Nov 27, 2024
ae6400e
docs updates
KenanYusuf Nov 27, 2024
2532d3e
Merge branch 'master' into experimental-toolbar
KenanYusuf Nov 28, 2024
afffa0f
add demo container for data grid components
KenanYusuf Nov 28, 2024
7d830b2
Update toolbar docs
KenanYusuf Nov 28, 2024
670fca0
update styles
KenanYusuf Nov 28, 2024
fef5ad5
fix focus styles for toolbar button
KenanYusuf Nov 28, 2024
0fe1a5d
improve default toolbar example
KenanYusuf Nov 28, 2024
f4c9226
update grid classes
KenanYusuf Nov 28, 2024
9d98f2e
normalize icons
KenanYusuf Nov 28, 2024
40a0b51
docs:api
KenanYusuf Nov 28, 2024
f012c29
update toolbar demo
KenanYusuf Nov 28, 2024
1fa341a
pointer-events: none; on quick filter search icon
KenanYusuf Nov 28, 2024
172db4f
use loading state from demo data
KenanYusuf Nov 28, 2024
570b637
reset changes to preferences panel
KenanYusuf Nov 28, 2024
9a299af
update view icons
KenanYusuf Nov 28, 2024
f544cd7
add class to toggle button group
KenanYusuf Nov 28, 2024
5dda068
update quick filter border color
KenanYusuf Nov 29, 2024
f3a46dd
Merge branch 'master' into experimental-toolbar
KenanYusuf Nov 29, 2024
887bf51
limit columns on toolbar demos
KenanYusuf Nov 29, 2024
a47cd74
doc updatse
KenanYusuf Dec 2, 2024
37204a1
changed wording
KenanYusuf Dec 2, 2024
8b1755e
fix demo container
KenanYusuf Dec 2, 2024
b29a245
remove overflow from toolbar
KenanYusuf Dec 2, 2024
824ad70
Merge branch 'master' into experimental-toolbar
KenanYusuf Dec 4, 2024
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: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ module.exports = {
'!@mui/internal-*/**',

// Exceptions (QUESTION: Keep or remove?)
'!@mui/x-data-grid/internals/demo',
'!@mui/x-date-pickers/internals/demo',
'!@mui/x-tree-view/hooks/useTreeViewApiRef',
// TODO: export this from /ButtonBase in core. This will break after we move to package exports
Expand Down
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 />}>
Copy link
Member

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 👍🏻.

<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>
);
}
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>
);
}
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 docs/data/data-grid/components/columns-panel/columns-panel.md
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

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Google.Will] Avoid using 'will'. Raw Output: {"message": "[Google.Will] Avoid using 'will'.", "location": {"path": "docs/data/data-grid/components/columns-panel/columns-panel.md", "range": {"start": {"line": 8, "column": 117}}}, "severity": "WARNING"}
:::

## 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/)
66 changes: 66 additions & 0 deletions docs/data/data-grid/components/export/GridExportMenu.js
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 />}>
Print
</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>
);
}
66 changes: 66 additions & 0 deletions docs/data/data-grid/components/export/GridExportMenu.tsx
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 />}>
Print
</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>
);
}
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 docs/data/data-grid/components/export/GridExportTrigger.js
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" />
Print
</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 docs/data/data-grid/components/export/GridExportTrigger.tsx
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" />
Print
</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>
);
}
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 docs/data/data-grid/components/export/export.md
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/)
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>
);
}
Loading
Loading