Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
af5bdf9
refactor: theme => css variables
romgrk Dec 2, 2024
339768b
lint
romgrk Dec 2, 2024
90c1fc2
lint
romgrk Dec 2, 2024
1fc98c6
feat: breakpoints
romgrk Dec 3, 2024
15484db
feat: breakpoints
romgrk Dec 3, 2024
9a5014e
refactor: theme.spacing => vars.spacing
romgrk Dec 3, 2024
bf20ed3
refactor: zIndex
romgrk Dec 3, 2024
71c993f
refactor: finish t.spacing()
romgrk Dec 3, 2024
b1054ec
refactor: finish all but GRS
romgrk Dec 4, 2024
41b1451
lint
romgrk Dec 4, 2024
9d718e2
Merge branch 'master' into feat-agnostic-css-variables
romgrk Dec 4, 2024
4e83cb6
fix: missing variables
romgrk Dec 4, 2024
f0645af
refactor: GridRootStyles
romgrk Dec 4, 2024
07e64a0
refactor: GRS: more colors
romgrk Dec 4, 2024
4670236
refactor: more ergonomic API
romgrk Dec 4, 2024
4bccecc
lint
romgrk Dec 6, 2024
1de35d9
lint
romgrk Dec 6, 2024
4822768
draft: test reverting text color
romgrk Dec 6, 2024
f643319
lint
romgrk Dec 9, 2024
734d8e7
draft: try remove style
romgrk Dec 9, 2024
3dc38ef
Revert "draft: try remove style"
romgrk Dec 9, 2024
cd34948
Revert "refactor: GRS: more colors"
romgrk Dec 9, 2024
cc48bd1
refactor: GRS: main colors
romgrk Dec 9, 2024
8311425
refactor: GRS(2): colors
romgrk Dec 9, 2024
2476462
refactor: GRS(3): colors
romgrk Dec 9, 2024
736948b
refactor: GRS(4): colors
romgrk Dec 9, 2024
2973e5c
refactor: GRS(5): focus color
romgrk Dec 9, 2024
802c642
refactor: GRS: complete
romgrk Dec 9, 2024
e7e253a
Merge branch 'master' into feat-agnostic-css-variables
romgrk Dec 12, 2024
23d3ad4
draft: split CSS variables
romgrk Dec 12, 2024
414f359
Merge branch 'master' into feat-agnostic-css-variables
romgrk Jan 7, 2025
00c953d
Revert "draft: split CSS variables"
romgrk Jan 8, 2025
cf98e2c
Merge branch 'master' into feat-agnostic-css-variables
romgrk Jan 8, 2025
ae48775
fix: conflict marker
romgrk Jan 8, 2025
c3d77de
fix: css variables accessible from root
romgrk Jan 8, 2025
b678c19
lint
romgrk Jan 8, 2025
fb4edf8
lint
romgrk Jan 8, 2025
685e935
ci: run (empty commit)
romgrk Jan 9, 2025
02f2f1c
Update packages/x-data-grid/src/components/panel/GridPanelFooter.tsx
romgrk Jan 9, 2025
dc9b984
Merge branch 'master' into feat-agnostic-css-variables
romgrk Jan 9, 2025
8d21805
Merge branch 'feat-agnostic-css-variables' of github.com:romgrk/mui-x…
romgrk Jan 9, 2025
049a999
ci: run (empty commit)
romgrk Jan 9, 2025
a9c8b65
fix: quickfilter outside of root
romgrk Jan 9, 2025
2d961be
lint
romgrk Jan 9, 2025
249ee63
refactor: useThemeVariablesClassName => useCSSVariablesClass
romgrk Jan 9, 2025
a0b8119
ci: run (empty commit)
romgrk Jan 10, 2025
83655b4
ci: run (empty commit)
romgrk Jan 10, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,21 @@ import * as React from 'react';
import Portal from '@mui/material/Portal';
import Box from '@mui/material/Box';
import Grid from '@mui/material/Grid';
import { DataGrid, GridToolbarQuickFilter, GridToolbar } from '@mui/x-data-grid';
import {
DataGrid,
GridPortalWrapper,
GridToolbarQuickFilter,
GridToolbar,
} from '@mui/x-data-grid';
import { useDemoData } from '@mui/x-data-grid-generator';

function MyCustomToolbar(props) {
return (
<React.Fragment>
<Portal container={() => document.getElementById('filter-panel')}>
<GridToolbarQuickFilter />
<GridPortalWrapper>
<GridToolbarQuickFilter />
</GridPortalWrapper>
</Portal>
<GridToolbar {...props} />
</React.Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,21 @@ import * as React from 'react';
import Portal from '@mui/material/Portal';
import Box from '@mui/material/Box';
import Grid from '@mui/material/Grid';
import { DataGrid, GridToolbarQuickFilter, GridToolbar } from '@mui/x-data-grid';
import {
DataGrid,
GridPortalWrapper,
GridToolbarQuickFilter,
GridToolbar,
} from '@mui/x-data-grid';
import { useDemoData } from '@mui/x-data-grid-generator';

function MyCustomToolbar(props: any) {
return (
<React.Fragment>
<Portal container={() => document.getElementById('filter-panel')!}>
<GridToolbarQuickFilter />
<GridPortalWrapper>
<GridToolbarQuickFilter />
</GridPortalWrapper>
</Portal>
<GridToolbar {...props} />
</React.Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ Below are described the steps you need to make to migrate from v7 to v8.
### Other exports

- `ariaV8` experimental flag is removed. It's now the default behavior.
- Sub-components that are in a React Portal must now be wrapped with `GridPortalWrapper`

<!-- ### Editing

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
GridColumnHeaderParams,
GridColumnHeaderTitle,
} from '@mui/x-data-grid';
import type { GridBaseColDef } from '@mui/x-data-grid/internals';
import { vars, type GridBaseColDef } from '@mui/x-data-grid/internals';
import { getAggregationFunctionLabel } from '../hooks/features/aggregation/gridAggregationUtils';
import { useGridApiContext } from '../hooks/utils/useGridApiContext';
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
Expand Down Expand Up @@ -37,14 +37,11 @@ const GridAggregationHeaderRoot = styled('div', {
const GridAggregationFunctionLabel = styled('div', {
name: 'MuiDataGrid',
slot: 'AggregationColumnHeaderLabel',
overridesResolver: (_, styles) => styles.aggregationColumnHeaderLabel,
})<{ ownerState: OwnerState }>(({ theme }) => {
return {
fontSize: theme.typography.caption.fontSize,
lineHeight: 'normal',
color: theme.palette.text.secondary,
marginTop: -1,
};
})<{ ownerState: OwnerState }>({
fontSize: vars.typography.small.fontSize,
lineHeight: 'normal',
color: vars.colors.foreground.muted,
marginTop: -1,
});

const useUtilityClasses = (ownerState: OwnerState) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { unstable_composeClasses as composeClasses } from '@mui/utils';
import Box from '@mui/material/Box';
import { useGridPrivateApiContext } from '@mui/x-data-grid-pro/internals';
import { vars, useGridPrivateApiContext } from '@mui/x-data-grid-pro/internals';
import {
useGridSelector,
getDataGridUtilityClass,
Expand Down Expand Up @@ -124,8 +124,7 @@ export function GridDataSourceGroupingCriteriaCell(props: GridGroupingCriteriaCe
ml:
rootProps.rowGroupingColumnMode === 'multiple'
? 0
: (theme) =>
`calc(var(--DataGrid-cellOffsetMultiplier) * ${theme.spacing(rowNode.depth)})`,
: `calc(var(--DataGrid-cellOffsetMultiplier) * ${vars.spacing(rowNode.depth)})`,
}}
>
<div className={classes.toggle}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import { getDataGridUtilityClass, GridRenderCellParams } from '@mui/x-data-grid';
import { vars } from '@mui/x-data-grid/internals';
import { styled, Theme } from '@mui/material/styles';
import { SxProps } from '@mui/system';
import composeClasses from '@mui/utils/composeClasses';
Expand All @@ -10,10 +11,10 @@ const GridFooterCellRoot = styled('div', {
name: 'MuiDataGrid',
slot: 'FooterCell',
overridesResolver: (_, styles) => styles.footerCell,
})<{ ownerState: OwnerState }>(({ theme }) => ({
fontWeight: theme.typography.fontWeightMedium,
color: (theme.vars || theme).palette.primary.dark,
}));
})<{ ownerState: OwnerState }>({
fontWeight: vars.typography.fontWeight.medium,
color: vars.colors.foreground.accent,
});
Comment on lines -13 to +17
Copy link
Copy Markdown
Member

@oliviertassinari oliviertassinari Jan 12, 2025

Choose a reason for hiding this comment

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

I'm confused. Why are we changing this?

What I see:

  • the Data Grid version for Material UI needs to follow the Material UI API and conventions so the data grid deeply integrates with it. So this doesn't work in that case?
  • the unstyled version of the data grid can't force any styles on users to be able to natively integrate with Mantine, Shadcn UI, etc. So this doesn't work in that case?

As I understand it for unstyled:

  • we could have demo with all the slots styled, userland, no style in the npm package.
  • we could do what react-data-grid do, offer a CSS file that the developer can or not import.
  • we can't do what AG Grid do, it doesn't work with SSR, streaming, it can't be tree shake, it makes it impossible to have native integration with other libraries.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the Data Grid version for Material UI needs to follow the Material UI API and conventions so the data grid deeply integrates with it. So this doesn't work in that case?

So do you think we should keep relying on @mui/system? That means we'd still be shipping emotion/styled even for non-mui users like shadcn.

we could have demo with all the slots styled, userland, no style in the npm package.

So this means we'd be writing each style once for each styling solution, right? Once with material-ui, once with tailwind/shadcn, etc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Splitting styles in a separate package is not viable, I have outlined the arguments against it here: https://www.notion.so/mui-org/DataGrid-styling-plan-19acbfe7b6608059bb6dc31608fab53a


interface GridFooterCellProps extends GridRenderCellParams {
sx?: SxProps<Theme>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react';
import { vars } from '@mui/x-data-grid/internals';
import { GridRenderCellParams } from '@mui/x-data-grid-pro';
import { SxProps, Theme } from '@mui/system';
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
Expand All @@ -13,8 +14,7 @@ function GridGroupingColumnFooterCell(props: GridRenderCellParams) {
} else if (rootProps.rowGroupingColumnMode === 'multiple') {
sx.ml = 2;
} else {
sx.ml = (theme) =>
`calc(var(--DataGrid-cellOffsetMultiplier) * ${theme.spacing(props.rowNode.depth)})`;
sx.ml = `calc(var(--DataGrid-cellOffsetMultiplier) * ${vars.spacing(props.rowNode.depth)})`;
}

return <GridFooterCell sx={sx} {...props} />;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import Box from '@mui/material/Box';
import { vars } from '@mui/x-data-grid/internals';
import { GridRenderCellParams } from '@mui/x-data-grid-pro';
import { useGridRootProps } from '../hooks/utils/useGridRootProps';

Expand All @@ -14,9 +15,9 @@ function GridGroupingColumnLeafCell(props: GridRenderCellParams) {
? {
ml: 1,
}
: (theme) => ({
ml: `calc(var(--DataGrid-cellOffsetMultiplier) * var(--depth) * ${theme.spacing(1)})`,
}),
: {
ml: `calc(var(--DataGrid-cellOffsetMultiplier) * var(--depth) * ${vars.spacing(1)})`,
},
]}
style={{ '--depth': rowNode.depth } as any}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import composeClasses from '@mui/utils/composeClasses';
import Box from '@mui/material/Box';
import { vars } from '@mui/x-data-grid/internals';
import {
useGridSelector,
gridFilteredDescendantCountLookupSelector,
Expand Down Expand Up @@ -80,9 +81,9 @@ export function GridGroupingCriteriaCell(props: GridGroupingCriteriaCellProps) {
? {
ml: 0,
}
: (theme) => ({
ml: `calc(var(--DataGrid-cellOffsetMultiplier) * var(--depth) * ${theme.spacing(1)})`,
}),
: {
ml: `calc(var(--DataGrid-cellOffsetMultiplier) * var(--depth) * ${vars.spacing(1)})`,
},
]}
style={{ '--depth': rowNode.depth } as any}
>
Expand Down
4 changes: 2 additions & 2 deletions packages/x-data-grid-pro/src/components/GridColumnHeaders.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import { styled } from '@mui/material/styles';
import { GridBaseColumnHeaders, UseGridColumnHeadersProps } from '@mui/x-data-grid/internals';
import { forwardRef } from '@mui/x-internals/forwardRef';
import { vars, GridBaseColumnHeaders, UseGridColumnHeadersProps } from '@mui/x-data-grid/internals';
import { useGridColumnHeaders } from '../hooks/features/columnHeaders/useGridColumnHeaders';

const Filler = styled('div')({
flex: 1,
backgroundColor: 'var(--DataGrid-containerBackground)',
backgroundColor: vars.colors.background.base,
});

export interface GridColumnHeadersProps
Expand Down
7 changes: 4 additions & 3 deletions packages/x-data-grid-pro/src/components/GridDetailPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import { styled } from '@mui/material/styles';
import { GridRowId } from '@mui/x-data-grid';
import { vars } from '@mui/x-data-grid/internals';
import { useResizeObserver } from '@mui/x-internals/useResizeObserver';
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
import { useGridPrivateApiContext } from '../hooks/utils/useGridPrivateApiContext';
Expand All @@ -12,12 +13,12 @@ const DetailPanel = styled('div', {
name: 'MuiDataGrid',
slot: 'DetailPanel',
overridesResolver: (props, styles) => styles.detailPanel,
})<{ ownerState: OwnerState }>(({ theme }) => ({
})<{ ownerState: OwnerState }>({
width:
'calc(var(--DataGrid-rowWidth) - var(--DataGrid-hasScrollY) * var(--DataGrid-scrollbarSize))',
backgroundColor: (theme.vars || theme).palette.background.default,
backgroundColor: vars.colors.background.base,
overflow: 'auto',
}));
});

interface GridDetailPanelProps
extends Pick<React.HTMLAttributes<HTMLDivElement>, 'className' | 'children'> {
Expand Down
9 changes: 5 additions & 4 deletions packages/x-data-grid/src/components/GridPagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import TablePagination, {
LabelDisplayedRowsArgs,
} from '@mui/material/TablePagination';
import { forwardRef } from '@mui/x-internals/forwardRef';
import { vars } from '../constants/cssVariables';
import { useGridSelector } from '../hooks/utils/useGridSelector';
import { useGridApiContext } from '../hooks/utils/useGridApiContext';
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
Expand All @@ -16,22 +17,22 @@ import {
gridPageCountSelector,
} from '../hooks/features/pagination/gridPaginationSelector';

const GridPaginationRoot = styled(TablePagination)(({ theme }) => ({
const GridPaginationRoot = styled(TablePagination)({
maxHeight: 'calc(100% + 1px)', // border width
flexGrow: 1,
[`& .${tablePaginationClasses.selectLabel}`]: {
display: 'none',
[theme.breakpoints.up('sm')]: {
[vars.breakpoints.up('sm')]: {
display: 'block',
},
},
[`& .${tablePaginationClasses.input}`]: {
display: 'none',
[theme.breakpoints.up('sm')]: {
[vars.breakpoints.up('sm')]: {
display: 'inline-flex',
},
},
})) as typeof TablePagination;
}) as typeof TablePagination;

export type WrappedLabelDisplayedRows = (
args: LabelDisplayedRowsArgs & { estimated?: number },
Expand Down
7 changes: 4 additions & 3 deletions packages/x-data-grid/src/components/GridRowCount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import clsx from 'clsx';
import composeClasses from '@mui/utils/composeClasses';
import { styled, SxProps, Theme } from '@mui/system';
import { forwardRef } from '@mui/x-internals/forwardRef';
import { vars } from '../constants/cssVariables';
import { useGridApiContext } from '../hooks/utils/useGridApiContext';
import { getDataGridUtilityClass } from '../constants/gridClasses';
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
Expand Down Expand Up @@ -35,11 +36,11 @@ const GridRowCountRoot = styled('div', {
name: 'MuiDataGrid',
slot: 'RowCount',
overridesResolver: (props, styles) => styles.rowCount,
})<{ ownerState: OwnerState }>(({ theme }) => ({
})<{ ownerState: OwnerState }>({
alignItems: 'center',
display: 'flex',
margin: theme.spacing(0, 2),
}));
margin: vars.spacing(0, 2),
});

const GridRowCount = forwardRef<HTMLDivElement, GridRowCountProps>(
function GridRowCount(props, ref) {
Expand Down
9 changes: 5 additions & 4 deletions packages/x-data-grid/src/components/GridSelectedRowCount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import clsx from 'clsx';
import composeClasses from '@mui/utils/composeClasses';
import { styled, SxProps, Theme } from '@mui/system';
import { forwardRef } from '@mui/x-internals/forwardRef';
import { vars } from '../constants/cssVariables';
import { useGridApiContext } from '../hooks/utils/useGridApiContext';
import { getDataGridUtilityClass } from '../constants/gridClasses';
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
Expand Down Expand Up @@ -34,19 +35,19 @@ const GridSelectedRowCountRoot = styled('div', {
name: 'MuiDataGrid',
slot: 'SelectedRowCount',
overridesResolver: (props, styles) => styles.selectedRowCount,
})<{ ownerState: OwnerState }>(({ theme }) => ({
})<{ ownerState: OwnerState }>({
alignItems: 'center',
display: 'flex',
margin: theme.spacing(0, 2),
margin: vars.spacing(0, 2),
visibility: 'hidden',
width: 0,
height: 0,
[theme.breakpoints.up('sm')]: {
[vars.breakpoints.up('sm')]: {
visibility: 'visible',
width: 'auto',
height: 'auto',
},
}));
});

const GridSelectedRowCount = forwardRef<HTMLDivElement, GridSelectedRowCountProps>(
function GridSelectedRowCount(props, ref) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
import { styled } from '@mui/material/styles';
import InputBase, { InputBaseProps } from '@mui/material/InputBase';
import { forwardRef } from '@mui/x-internals/forwardRef';
import { vars } from '../../constants/cssVariables';
import { GridRenderEditCellParams } from '../../models/params/gridCellParams';
import { getDataGridUtilityClass } from '../../constants/gridClasses';
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
Expand All @@ -28,15 +29,14 @@ const useUtilityClasses = (ownerState: OwnerState) => {
const GridEditInputCellRoot = styled(InputBase, {
name: 'MuiDataGrid',
slot: 'EditInputCell',
overridesResolver: (props, styles) => styles.editInputCell,
})<{ ownerState: OwnerState }>(({ theme }) => ({
...theme.typography.body2,
})<{ ownerState: OwnerState }>({
...vars.typography.body,
padding: '1px 0',
'& input': {
padding: '0 16px',
height: '100%',
},
}));
});

export interface GridEditInputCellProps
extends GridRenderEditCellParams,
Expand Down
Loading