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

Bump React #15255

Merged
merged 30 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
79a0cbf
Bump @types/react to ^18.3.5
renovate[bot] Sep 4, 2024
2c71612
fix Cell and Row props types
cherniavskii Sep 5, 2024
a689d8a
fix type errors in test files
cherniavskii Sep 5, 2024
46a0052
Merge remote-tracking branch 'mui/master' into renovate/react
cherniavskii Sep 5, 2024
9ee51e7
update lockfile
cherniavskii Sep 5, 2024
1c7a7d4
proptypes
cherniavskii Sep 5, 2024
13acded
proptypes
cherniavskii Sep 5, 2024
72d2eb7
lint
cherniavskii Sep 5, 2024
b162a8b
Extract `ExportMenuItem` components separately to have consistent `pr…
LukasTy Sep 6, 2024
e19eb7d
Fix usage and docs
LukasTy Sep 6, 2024
2f94d98
Merge branch 'master' into renovate/react
cherniavskii Sep 6, 2024
842561c
revert toolbar export type change
cherniavskii Sep 6, 2024
174433d
use theme augmentation
cherniavskii Sep 6, 2024
868a335
Merge remote-tracking branch 'upstream/master' into renovate/react
LukasTy Nov 1, 2024
5daff1e
Bump to latest `@types/react` version
LukasTy Nov 1, 2024
8b4fb9d
Possibly more correct children type
LukasTy Nov 1, 2024
4865bf1
Revert exporting
LukasTy Nov 1, 2024
b3dabe1
Fix too loose type causing `proptypes` randomness
LukasTy Nov 1, 2024
b26a822
Revert to a single `GridToolbarExport` file with fixed types to avoid…
LukasTy Nov 1, 2024
65e9d1f
Small tweaks
LukasTy Nov 1, 2024
602cb3a
Bump `@types/react-dom`
LukasTy Nov 4, 2024
ad494f8
Fix eslint
LukasTy Nov 4, 2024
43f59a3
Remove no longer needed as slot casting
LukasTy Nov 4, 2024
50ae593
Fix module augmentation
LukasTy Nov 4, 2024
88e7702
Merge remote-tracking branch 'upstream/master' into renovate/react
LukasTy Nov 11, 2024
f93c892
fix toolbar ts error
cherniavskii Nov 12, 2024
0b1e3cc
proptypes
cherniavskii Nov 12, 2024
00b586f
Merge branch 'master' into renovate/react
cherniavskii Nov 12, 2024
5a1cd23
fix build
cherniavskii Nov 12, 2024
6a86fe4
fix type export
cherniavskii Nov 12, 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
4 changes: 1 addition & 3 deletions docs/data/data-grid/editing/FullFeaturedCrudGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,7 @@ export default function FullFeaturedCrudGrid() {
onRowModesModelChange={handleRowModesModelChange}
onRowEditStop={handleRowEditStop}
processRowUpdate={processRowUpdate}
slots={{
toolbar: EditToolbar,
}}
slots={{ toolbar: EditToolbar }}
slotProps={{
toolbar: { setRows, setRowModesModel },
}}
Expand Down
20 changes: 10 additions & 10 deletions docs/data/data-grid/editing/FullFeaturedCrudGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
GridRowId,
GridRowModel,
GridRowEditStopReasons,
GridSlots,
GridSlotProps,
} from '@mui/x-data-grid';
import {
randomCreatedDate,
Expand Down Expand Up @@ -70,14 +70,16 @@ const initialRows: GridRowsProp = [
},
];

interface EditToolbarProps {
setRows: (newRows: (oldRows: GridRowsProp) => GridRowsProp) => void;
setRowModesModel: (
newModel: (oldModel: GridRowModesModel) => GridRowModesModel,
) => void;
declare module '@mui/x-data-grid' {
interface ToolbarPropsOverrides {
setRows: (newRows: (oldRows: GridRowsProp) => GridRowsProp) => void;
setRowModesModel: (
newModel: (oldModel: GridRowModesModel) => GridRowModesModel,
) => void;
}
}

function EditToolbar(props: EditToolbarProps) {
function EditToolbar(props: GridSlotProps['toolbar']) {
const { setRows, setRowModesModel } = props;

const handleClick = () => {
Expand Down Expand Up @@ -240,9 +242,7 @@ export default function FullFeaturedCrudGrid() {
onRowModesModelChange={handleRowModesModelChange}
onRowEditStop={handleRowEditStop}
processRowUpdate={processRowUpdate}
slots={{
toolbar: EditToolbar as GridSlots['toolbar'],
}}
slots={{ toolbar: EditToolbar }}
slotProps={{
toolbar: { setRows, setRowModesModel },
}}
Expand Down
4 changes: 1 addition & 3 deletions docs/data/data-grid/editing/FullFeaturedCrudGrid.tsx.preview
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
onRowModesModelChange={handleRowModesModelChange}
onRowEditStop={handleRowEditStop}
processRowUpdate={processRowUpdate}
slots={{
toolbar: EditToolbar as GridSlots['toolbar'],
}}
slots={{ toolbar: EditToolbar }}
slotProps={{
toolbar: { setRows, setRowModesModel },
}}
Expand Down
5 changes: 1 addition & 4 deletions docs/data/data-grid/editing/StartEditButtonGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,11 @@ export default function StartEditButtonGrid() {
cellModesModel={cellModesModel}
onCellEditStop={handleCellEditStop}
onCellModesModelChange={(model) => setCellModesModel(model)}
slots={{
toolbar: EditToolbar,
}}
slots={{ toolbar: EditToolbar }}
slotProps={{
toolbar: {
cellMode,
selectedCellParams,
setSelectedCellParams,
cellModesModel,
setCellModesModel,
},
Expand Down
21 changes: 10 additions & 11 deletions docs/data/data-grid/editing/StartEditButtonGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
GridCellModes,
GridEventListener,
GridCellModesModel,
GridSlots,
GridSlotProps,
} from '@mui/x-data-grid';
import {
randomCreatedDate,
Expand All @@ -22,14 +22,16 @@ interface SelectedCellParams {
field: string;
}

interface EditToolbarProps {
selectedCellParams?: SelectedCellParams;
cellModesModel: GridCellModesModel;
setCellModesModel: (value: GridCellModesModel) => void;
cellMode: 'view' | 'edit';
declare module '@mui/x-data-grid' {
interface ToolbarPropsOverrides {
selectedCellParams: SelectedCellParams | null;
cellModesModel: GridCellModesModel;
setCellModesModel: (value: GridCellModesModel) => void;
cellMode: 'view' | 'edit';
}
}

function EditToolbar(props: EditToolbarProps) {
function EditToolbar(props: GridSlotProps['toolbar']) {
const { selectedCellParams, cellMode, cellModesModel, setCellModesModel } = props;

const handleSaveOrEdit = () => {
Expand Down Expand Up @@ -147,14 +149,11 @@ export default function StartEditButtonGrid() {
cellModesModel={cellModesModel}
onCellEditStop={handleCellEditStop}
onCellModesModelChange={(model) => setCellModesModel(model)}
slots={{
toolbar: EditToolbar as GridSlots['toolbar'],
}}
slots={{ toolbar: EditToolbar }}
slotProps={{
toolbar: {
cellMode,
selectedCellParams,
setSelectedCellParams,
cellModesModel,
setCellModesModel,
},
Expand Down
9 changes: 6 additions & 3 deletions docs/data/data-grid/export/ExcelCustomExport.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ const groupingColDef = {
headerName: 'Feature',
};

const exceljsPreProcess = ({ workbook, worksheet }) => {
const exceljsPreProcess = async ({ workbook, worksheet }) => {
// Set document meta data
workbook.creator = 'MUI-X team';
workbook.created = new Date();
Expand Down Expand Up @@ -264,14 +264,17 @@ const exceljsPreProcess = ({ workbook, worksheet }) => {
};
worksheet.addRow([]);
};
const exceljsPostProcess = ({ worksheet }) => {
const exceljsPostProcess = async ({ worksheet }) => {
// add a text after the data
worksheet.addRow({}); // Add empty row

worksheet.addRow(['Those data are for internal use only']);
};

const excelOptions = { exceljsPreProcess, exceljsPostProcess };
const excelOptions = {
exceljsPreProcess,
exceljsPostProcess,
};

const getTreeDataPath = (row) => row.path;

Expand Down
13 changes: 10 additions & 3 deletions docs/data/data-grid/export/ExcelCustomExport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
GridExceljsProcessInput,
GridColDef,
DataGridPremiumProps,
GridExcelExportOptions,
} from '@mui/x-data-grid-premium';

const rows = [
Expand Down Expand Up @@ -243,7 +244,10 @@ const groupingColDef = {
headerName: 'Feature',
};

const exceljsPreProcess = ({ workbook, worksheet }: GridExceljsProcessInput) => {
const exceljsPreProcess = async ({
workbook,
worksheet,
}: GridExceljsProcessInput) => {
// Set document meta data
workbook.creator = 'MUI-X team';
workbook.created = new Date();
Expand Down Expand Up @@ -271,14 +275,17 @@ const exceljsPreProcess = ({ workbook, worksheet }: GridExceljsProcessInput) =>
};
worksheet.addRow([]);
};
const exceljsPostProcess = ({ worksheet }: GridExceljsProcessInput) => {
const exceljsPostProcess = async ({ worksheet }: GridExceljsProcessInput) => {
// add a text after the data
worksheet.addRow({}); // Add empty row

worksheet.addRow(['Those data are for internal use only']);
};

const excelOptions = { exceljsPreProcess, exceljsPostProcess };
const excelOptions: GridExcelExportOptions = {
exceljsPreProcess,
exceljsPostProcess,
};

const getTreeDataPath: DataGridPremiumProps['getTreeDataPath'] = (row) => row.path;

Expand Down
8 changes: 2 additions & 6 deletions docs/data/data-grid/filtering/CustomFilterPanelPosition.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,12 @@ export default function CustomFilterPanelPosition() {
<div style={{ height: 400, width: '100%' }}>
<DataGrid
{...data}
slots={{
toolbar: CustomToolbar,
}}
slots={{ toolbar: CustomToolbar }}
slotProps={{
panel: {
anchorEl: filterButtonEl,
},
toolbar: {
setFilterButtonEl,
},
toolbar: { setFilterButtonEl },
}}
/>
</div>
Expand Down
20 changes: 10 additions & 10 deletions docs/data/data-grid/filtering/CustomFilterPanelPosition.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import * as React from 'react';
import {
DataGrid,
GridSlots,
GridSlotProps,
GridToolbarContainer,
GridToolbarFilterButton,
} from '@mui/x-data-grid';
import { useDemoData } from '@mui/x-data-grid-generator';

const VISIBLE_FIELDS = ['name', 'rating', 'country', 'dateCreated', 'isAdmin'];

interface CustomToolbarProps {
setFilterButtonEl: React.Dispatch<React.SetStateAction<HTMLButtonElement | null>>;
declare module '@mui/x-data-grid' {
interface ToolbarPropsOverrides {
setFilterButtonEl: React.Dispatch<
React.SetStateAction<HTMLButtonElement | null>
>;
}
}

function CustomToolbar({ setFilterButtonEl }: CustomToolbarProps) {
function CustomToolbar({ setFilterButtonEl }: GridSlotProps['toolbar']) {
return (
<GridToolbarContainer>
<GridToolbarFilterButton ref={setFilterButtonEl} />
Expand All @@ -35,16 +39,12 @@ export default function CustomFilterPanelPosition() {
<div style={{ height: 400, width: '100%' }}>
<DataGrid
{...data}
slots={{
toolbar: CustomToolbar as GridSlots['toolbar'],
}}
slots={{ toolbar: CustomToolbar }}
slotProps={{
panel: {
anchorEl: filterButtonEl,
},
toolbar: {
setFilterButtonEl,
},
toolbar: { setFilterButtonEl },
}}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
<DataGrid
{...data}
slots={{
toolbar: CustomToolbar as GridSlots['toolbar'],
}}
slots={{ toolbar: CustomToolbar }}
slotProps={{
panel: {
anchorEl: filterButtonEl,
},
toolbar: {
setFilterButtonEl,
},
toolbar: { setFilterButtonEl },
}}
/>
9 changes: 9 additions & 0 deletions docs/data/data-grid/list-view/ListViewAdvanced.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ import { formatDate, formatSize, stringAvatar } from './utils';
import { ActionDrawer } from './components/ActionDrawer';
import { RenameDialog } from './components/RenameDialog';

declare module '@mui/x-data-grid' {
interface ToolbarPropsOverrides {
listView: boolean;
container: () => HTMLElement;
handleDelete: (ids: GridRowId[]) => void;
handleUpload: (event: React.ChangeEvent<HTMLInputElement>) => void;
}
}

export default function ListViewAdvanced() {
// This is used only for the example - renders the drawer inside the container
const containerRef = React.useRef<HTMLDivElement>(null);
Expand Down
16 changes: 9 additions & 7 deletions docs/data/data-grid/state/RestoreStateInitialState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Stack from '@mui/material/Stack';
import {
DataGridPro,
GridInitialState,
GridSlots,
GridSlotProps,
GridToolbarContainer,
GridToolbarDensitySelector,
GridToolbarFilterButton,
Expand All @@ -14,11 +14,13 @@ import {
} from '@mui/x-data-grid-pro';
import { useDemoData } from '@mui/x-data-grid-generator';

function GridCustomToolbar({
syncState,
}: {
syncState: (stateToSave: GridInitialState) => void;
}) {
declare module '@mui/x-data-grid' {
Copy link
Member Author

@LukasTy LukasTy Nov 4, 2024

Choose a reason for hiding this comment

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

If pro and premium package module augmentation are mixed in a single project—it goes haywire. 🙈

Copy link
Member Author

Choose a reason for hiding this comment

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

After some of this dogfooding—this is my main gripe with module augmentation. 🙈
If users extend the same types for different package versions—they come to experience unexpected behavior. 🤷

interface ToolbarPropsOverrides {
syncState: (stateToSave: GridInitialState) => void;
}
}

function GridCustomToolbar({ syncState }: GridSlotProps['toolbar']) {
const rootProps = useGridRootProps();
const apiRef = useGridApiContext();

Expand Down Expand Up @@ -63,7 +65,7 @@ export default function RestoreStateInitialState() {
<DataGridPro
{...data}
loading={loading}
slots={{ toolbar: GridCustomToolbar as GridSlots['toolbar'] }}
slots={{ toolbar: GridCustomToolbar }}
slotProps={{ toolbar: { syncState } }}
/>
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<DataGridPro
{...data}
loading={loading}
slots={{ toolbar: GridCustomToolbar as GridSlots['toolbar'] }}
slots={{ toolbar: GridCustomToolbar }}
slotProps={{ toolbar: { syncState } }}
/>
</Box>
Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
"@types/moment-hijri": "^2.1.4",
"@types/moment-jalaali": "^0.7.9",
"@types/prop-types": "^15.7.13",
"@types/react-dom": "^18.3.0",
"@types/react-dom": "^18.3.1",
"@types/react-router-dom": "^5.3.3",
"@types/stylis": "^4.2.6",
"@types/webpack-bundle-analyzer": "^4.7.0",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@
"@types/lodash": "^4.17.13",
"@types/mocha": "^10.0.9",
"@types/node": "^20.17.6",
"@types/react": "^18.3.4",
"@types/react-dom": "^18.3.0",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@types/react-test-renderer": "^18.3.0",
"@types/requestidlecallback": "^0.3.7",
"@types/sinon": "^17.0.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import {
GridFileExportOptions,
GridExportFormat as GridExportFormatCommunity,
GridExportExtension as GridExportExtensionCommunity,
GridToolbarExportProps as GridToolbarExportPropsCommunity,
GridExportDisplayOptions,
} from '@mui/x-data-grid-pro';

export type GridExportFormat = GridExportFormatCommunity | 'excel';
Expand Down Expand Up @@ -62,10 +60,6 @@ export interface GridExcelExportOptions extends GridFileExportOptions {
includeColumnGroupsHeaders?: boolean;
}

export interface GridToolbarExportProps extends GridToolbarExportPropsCommunity {
excelOptions: GridExcelExportOptions & GridExportDisplayOptions;
}

/**
* The excel export API interface that is available in the grid [[apiRef]].
*/
Expand Down
Loading
Loading