Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/next' into fix-11679
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfauquette committed Feb 6, 2024
2 parents ee001b0 + 88bd47a commit 6ba0e4d
Show file tree
Hide file tree
Showing 129 changed files with 782 additions and 318 deletions.
4 changes: 2 additions & 2 deletions .codesandbox/ci.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"installCommand": "install:codesandbox",
"node": "18",
"packages": [
"packages/x-license-pro",
"packages/x-license",
"packages/grid/x-data-grid",
"packages/grid/x-data-grid-pro",
"packages/grid/x-data-grid-premium",
Expand All @@ -14,7 +14,7 @@
"packages/x-tree-view"
],
"publishDirectory": {
"@mui/x-license-pro": "packages/x-license-pro/build",
"@mui/x-license": "packages/x-license/build",
"@mui/x-data-grid": "packages/grid/x-data-grid/build",
"@mui/x-data-grid-pro": "packages/grid/x-data-grid-pro/build",
"@mui/x-data-grid-premium": "packages/grid/x-data-grid-premium/build",
Expand Down
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,6 @@ module.exports = {
buildPackageRestrictedImports('@mui/x-data-grid-generator', 'grid/x-data-grid-generator'),
buildPackageRestrictedImports('@mui/x-pickers', 'x-pickers'),
buildPackageRestrictedImports('@mui/x-pickers-pro', 'x-pickers-pro'),
buildPackageRestrictedImports('@mui/x-license-pro', 'x-license-pro'),
buildPackageRestrictedImports('@mui/x-license', 'x-license'),
],
};
4 changes: 2 additions & 2 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const path = require('path');
const generateReleaseInfo = require('./packages/x-license-pro/generateReleaseInfo');
const generateReleaseInfo = require('./packages/x-license/generateReleaseInfo');

function resolveAliasPath(relativeToBabelConf) {
const resolvedPath = path.relative(process.cwd(), path.resolve(__dirname, relativeToBabelConf));
Expand All @@ -11,7 +11,7 @@ const defaultAlias = {
'@mui/x-data-grid-generator': resolveAliasPath('./packages/grid/x-data-grid-generator/src'),
'@mui/x-data-grid-pro': resolveAliasPath('./packages/grid/x-data-grid-pro/src'),
'@mui/x-data-grid-premium': resolveAliasPath('./packages/grid/x-data-grid-premium/src'),
'@mui/x-license-pro': resolveAliasPath('./packages/x-license-pro/src'),
'@mui/x-license': resolveAliasPath('./packages/x-license/src'),
'@mui/x-date-pickers': resolveAliasPath('./packages/x-date-pickers/src'),
'@mui/x-date-pickers-pro': resolveAliasPath('./packages/x-date-pickers-pro/src'),
'@mui/x-charts': resolveAliasPath('./packages/x-charts/src'),
Expand Down
9 changes: 6 additions & 3 deletions bug-reproductions/x-data-grid/public/index.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<title>DataGridProDemo demo — MUI X</title>
<title>DataGrid — MUI X</title>
<!-- Fonts to support Material Design -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap"
href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;600;700&display=swap"
/>
<meta name="viewport" content="initial-scale=1, width=device-width" />
<!-- Icons to support Material Design -->
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
</head>
Expand Down
2 changes: 1 addition & 1 deletion docs/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const alias = {
'@mui/x-date-pickers-pro': '../packages/x-date-pickers-pro/src',
'@mui/x-charts': '../packages/x-charts/src',
'@mui/x-tree-view': '../packages/x-tree-view/src',
'@mui/x-license-pro': '../packages/x-license-pro/src',
'@mui/x-license': '../packages/x-license/src',
'@mui/docs': '../node_modules/@mui/monorepo/packages/mui-docs/src',
'@mui/markdown': '../node_modules/@mui/monorepo/packages/markdown',
'@mui/monorepo': '../node_modules/@mui/monorepo',
Expand Down
100 changes: 100 additions & 0 deletions docs/data/charts/axis/ReverseExampleNoSnap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import * as React from 'react';
import Box from '@mui/material/Box';
import Stack from '@mui/material/Stack';
import FormControlLabel from '@mui/material/FormControlLabel';
import Checkbox from '@mui/material/Checkbox';

import { ResponsiveChartContainer } from '@mui/x-charts/ResponsiveChartContainer';
import { LinePlot, MarkPlot } from '@mui/x-charts/LineChart';
import { BarPlot } from '@mui/x-charts/BarChart';
import { ChartsXAxis } from '@mui/x-charts/ChartsXAxis';
import { ChartsYAxis } from '@mui/x-charts/ChartsYAxis';

const dataset = [
{ min: -12, max: -4, precip: 79, month: 'Jan' },
{ min: -11, max: -3, precip: 66, month: 'Feb' },
{ min: -6, max: 2, precip: 76, month: 'Mar' },
{ min: 1, max: 9, precip: 106, month: 'Apr' },
{ min: 8, max: 17, precip: 105, month: 'Mai' },
{ min: 15, max: 24, precip: 114, month: 'Jun' },
{ min: 18, max: 26, precip: 106, month: 'Jul' },
{ min: 17, max: 26, precip: 105, month: 'Aug' },
{ min: 13, max: 21, precip: 100, month: 'Sept' },
{ min: 6, max: 13, precip: 116, month: 'Oct' },
{ min: 0, max: 6, precip: 93, month: 'Nov' },
{ min: -8, max: -1, precip: 93, month: 'Dec' },
];

const series = [
{ type: 'line', dataKey: 'min', color: '#577399' },
{ type: 'line', dataKey: 'max', color: '#fe5f55' },
{ type: 'bar', dataKey: 'precip', color: '#bfdbf7', yAxisKey: 'rightAxis' },
];

export default function ReverseExampleNoSnap() {
const [reverseX, setReverseX] = React.useState(false);
const [reverseLeft, setReverseLeft] = React.useState(false);
const [reverseRight, setReverseRight] = React.useState(false);

return (
<Stack sx={{ width: '100%' }}>
<Stack direction="row">
<FormControlLabel
checked={reverseX}
control={
<Checkbox onChange={(event) => setReverseX(event.target.checked)} />
}
label="reverse x-axis"
labelPlacement="end"
/>
<FormControlLabel
checked={reverseLeft}
control={
<Checkbox onChange={(event) => setReverseLeft(event.target.checked)} />
}
label="reverse left axis"
labelPlacement="end"
/>
<FormControlLabel
checked={reverseRight}
control={
<Checkbox onChange={(event) => setReverseRight(event.target.checked)} />
}
label="reverse right axis"
labelPlacement="end"
/>
</Stack>
<Box sx={{ width: '100%' }}>
<ResponsiveChartContainer
series={series}
xAxis={[
{
scaleType: 'band',
dataKey: 'month',
label: 'Month',
reverse: reverseX,
},
]}
yAxis={[
{ id: 'leftAxis', reverse: reverseLeft },
{ id: 'rightAxis', reverse: reverseRight },
]}
dataset={dataset}
height={400}
>
<BarPlot />
<LinePlot />
<MarkPlot />

<ChartsXAxis />
<ChartsYAxis axisId="leftAxis" label="temerature (°C)" />
<ChartsYAxis
axisId="rightAxis"
position="right"
label="precipitation (mm)"
/>
</ResponsiveChartContainer>
</Box>
</Stack>
);
}
7 changes: 7 additions & 0 deletions docs/data/charts/axis/axis.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ xAxis={[

{{"demo": "MinMaxExample.js"}}

### Axis direction

By default, the axes' directions are left to right and bottom to top.
You can change this behavior with the property `reverse`.

{{"demo": "ReverseExampleNoSnap.js"}}

## Tick position

### Automatic tick position
Expand Down
92 changes: 92 additions & 0 deletions docs/data/data-grid/column-definition/ActionsWithModalGrid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import * as React from 'react';
import { DataGrid, GridActionsCellItem } from '@mui/x-data-grid';
import DeleteIcon from '@mui/icons-material/Delete';
import { randomUserName } from '@mui/x-data-grid-generator';
import Dialog from '@mui/material/Dialog';
import DialogTitle from '@mui/material/DialogTitle';
import DialogContent from '@mui/material/DialogContent';
import DialogContentText from '@mui/material/DialogContentText';
import DialogActions from '@mui/material/DialogActions';
import Button from '@mui/material/Button';

const initialRows = [
{ id: 1, name: randomUserName() },
{ id: 2, name: randomUserName() },
{ id: 3, name: randomUserName() },
];

function DeleteUserActionItem({ deleteUser, ...props }) {
const [open, setOpen] = React.useState(false);

return (
<React.Fragment>
<GridActionsCellItem {...props} onClick={() => setOpen(true)} />
<Dialog
open={open}
onClose={() => setOpen(false)}
aria-labelledby="alert-dialog-title"
aria-describedby="alert-dialog-description"
>
<DialogTitle id="alert-dialog-title">Delete this user?</DialogTitle>
<DialogContent>
<DialogContentText id="alert-dialog-description">
This action cannot be undone.
</DialogContentText>
</DialogContent>
<DialogActions>
<Button onClick={() => setOpen(false)}>Cancel</Button>
<Button
onClick={() => {
setOpen(false);
deleteUser();
}}
color="warning"
autoFocus
>
Delete
</Button>
</DialogActions>
</Dialog>
</React.Fragment>
);
}

export default function ActionsWithModalGrid() {
const [rows, setRows] = React.useState(initialRows);

const deleteUser = React.useCallback(
(id) => () => {
setTimeout(() => {
setRows((prevRows) => prevRows.filter((row) => row.id !== id));
});
},
[],
);

const columns = React.useMemo(
() => [
{ field: 'name', type: 'string' },
{
field: 'actions',
type: 'actions',
width: 80,
getActions: (params) => [
<DeleteUserActionItem
label="Delete"
showInMenu
icon={<DeleteIcon />}
deleteUser={deleteUser(params.id)}
closeMenuOnClick={false}
/>,
],
},
],
[deleteUser],
);

return (
<div style={{ height: 300, width: '100%' }}>
<DataGrid columns={columns} rows={rows} />
</div>
);
}
103 changes: 103 additions & 0 deletions docs/data/data-grid/column-definition/ActionsWithModalGrid.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import * as React from 'react';
import {
DataGrid,
GridActionsCellItem,
GridRowId,
GridColDef,
GridActionsCellItemProps,
} from '@mui/x-data-grid';
import DeleteIcon from '@mui/icons-material/Delete';
import { randomUserName } from '@mui/x-data-grid-generator';
import Dialog from '@mui/material/Dialog';
import DialogTitle from '@mui/material/DialogTitle';
import DialogContent from '@mui/material/DialogContent';
import DialogContentText from '@mui/material/DialogContentText';
import DialogActions from '@mui/material/DialogActions';
import Button from '@mui/material/Button';

const initialRows = [
{ id: 1, name: randomUserName() },
{ id: 2, name: randomUserName() },
{ id: 3, name: randomUserName() },
];

function DeleteUserActionItem({
deleteUser,
...props
}: GridActionsCellItemProps & { deleteUser: () => void }) {
const [open, setOpen] = React.useState(false);

return (
<React.Fragment>
<GridActionsCellItem {...props} onClick={() => setOpen(true)} />
<Dialog
open={open}
onClose={() => setOpen(false)}
aria-labelledby="alert-dialog-title"
aria-describedby="alert-dialog-description"
>
<DialogTitle id="alert-dialog-title">Delete this user?</DialogTitle>
<DialogContent>
<DialogContentText id="alert-dialog-description">
This action cannot be undone.
</DialogContentText>
</DialogContent>
<DialogActions>
<Button onClick={() => setOpen(false)}>Cancel</Button>
<Button
onClick={() => {
setOpen(false);
deleteUser();
}}
color="warning"
autoFocus
>
Delete
</Button>
</DialogActions>
</Dialog>
</React.Fragment>
);
}

type Row = (typeof initialRows)[number];

export default function ActionsWithModalGrid() {
const [rows, setRows] = React.useState<Row[]>(initialRows);

const deleteUser = React.useCallback(
(id: GridRowId) => () => {
setTimeout(() => {
setRows((prevRows) => prevRows.filter((row) => row.id !== id));
});
},
[],
);

const columns = React.useMemo<GridColDef<Row>[]>(
() => [
{ field: 'name', type: 'string' },
{
field: 'actions',
type: 'actions',
width: 80,
getActions: (params) => [
<DeleteUserActionItem
label="Delete"
showInMenu
icon={<DeleteIcon />}
deleteUser={deleteUser(params.id)}
closeMenuOnClick={false}
/>,
],
},
],
[deleteUser],
);

return (
<div style={{ height: 300, width: '100%' }}>
<DataGrid columns={columns} rows={rows} />
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<DataGrid columns={columns} rows={rows} />
Loading

0 comments on commit 6ba0e4d

Please sign in to comment.