From 565879ae0993b3ba1a009d838b5859a2bf09f8d4 Mon Sep 17 00:00:00 2001 From: Danail H Date: Fri, 9 Jul 2021 11:57:22 +0300 Subject: [PATCH 1/7] Change isMuiV5 check --- packages/grid/_modules_/grid/utils/utils.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/grid/_modules_/grid/utils/utils.ts b/packages/grid/_modules_/grid/utils/utils.ts index 984fd9bb84d8d..c74a0e44b0896 100644 --- a/packages/grid/_modules_/grid/utils/utils.ts +++ b/packages/grid/_modules_/grid/utils/utils.ts @@ -22,7 +22,8 @@ export function getThemePaletteMode(palette: any): string { } export function isMuiV5(): boolean { - return 'alpha' in styles; + // Changed from `alpha` to 'fade' because mui/core@4.12.0 adds 'alpha' in v4 + return !('fade' in styles); } export function muiStyleAlpha(color: string, value: number): string { From e14c4e8a1522ff12e5462af69b3cd7c2cc88aa1c Mon Sep 17 00:00:00 2001 From: Danail Hadjiatanasov Date: Fri, 9 Jul 2021 14:22:19 +0300 Subject: [PATCH 2/7] Update packages/grid/_modules_/grid/utils/utils.ts Co-authored-by: Olivier Tassinari --- packages/grid/_modules_/grid/utils/utils.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/grid/_modules_/grid/utils/utils.ts b/packages/grid/_modules_/grid/utils/utils.ts index c74a0e44b0896..79cb697dfb421 100644 --- a/packages/grid/_modules_/grid/utils/utils.ts +++ b/packages/grid/_modules_/grid/utils/utils.ts @@ -22,7 +22,6 @@ export function getThemePaletteMode(palette: any): string { } export function isMuiV5(): boolean { - // Changed from `alpha` to 'fade' because mui/core@4.12.0 adds 'alpha' in v4 return !('fade' in styles); } From 09c17422167b261ea9098bbddfe73e9a36a50c45 Mon Sep 17 00:00:00 2001 From: Danail H Date: Fri, 9 Jul 2021 14:51:26 +0300 Subject: [PATCH 3/7] Feature detect --- packages/grid/_modules_/grid/utils/utils.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/grid/_modules_/grid/utils/utils.ts b/packages/grid/_modules_/grid/utils/utils.ts index 79cb697dfb421..d5be7041636ac 100644 --- a/packages/grid/_modules_/grid/utils/utils.ts +++ b/packages/grid/_modules_/grid/utils/utils.ts @@ -26,14 +26,15 @@ export function isMuiV5(): boolean { } export function muiStyleAlpha(color: string, value: number): string { - if (isMuiV5()) { + if (isMuiV5() || !(styles as any)?.fade) { return (styles as any)?.alpha(color, value); } + return (styles as any)?.fade(color, value); } export function createTheme(): styles.Theme { - if (isMuiV5()) { + if (isMuiV5() || !(styles as any)?.createMuiTheme) { return (styles as any)?.createTheme(); } return (styles as any)?.createMuiTheme(); From e75a7c192902643680287099228cf26e28efcb9f Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Fri, 9 Jul 2021 12:30:23 +0200 Subject: [PATCH 4/7] [core] Update the core dependencies --- yarn.lock | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/yarn.lock b/yarn.lock index 472bffd829d36..ffb4ddc5e5bff 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3234,13 +3234,13 @@ write-file-atomic "^3.0.3" "@material-ui/core@^4.9.12": - version "4.11.4" - resolved "https://registry.yarnpkg.com/@material-ui/core/-/core-4.11.4.tgz#4fb9fe5dec5dcf780b687e3a40cff78b2b9640a4" - integrity sha512-oqb+lJ2Dl9HXI9orc6/aN8ZIAMkeThufA5iZELf2LQeBn2NtjVilF5D2w7e9RpntAzDb4jK5DsVhkfOvFY/8fg== + version "4.12.1" + resolved "https://registry.yarnpkg.com/@material-ui/core/-/core-4.12.1.tgz#ac8f081498047aa02bb6ee70b77c5dad6a2a6e73" + integrity sha512-C6hYsjkWCTfBx9FaqxhCZCITBagh7fyCKFtHyvO3tTOcBw6NJaktdhNZ2n82jQdQdgfFvg6OOxi7OOzsAdAcBQ== dependencies: "@babel/runtime" "^7.4.4" "@material-ui/styles" "^4.11.4" - "@material-ui/system" "^4.11.3" + "@material-ui/system" "^4.12.1" "@material-ui/types" "5.1.0" "@material-ui/utils" "^4.11.2" "@types/react-transition-group" "^4.2.0" @@ -3268,9 +3268,9 @@ "@babel/runtime" "^7.4.4" "@material-ui/lab@^4.0.0-alpha.54", "@material-ui/lab@^4.0.0-alpha.56": - version "4.0.0-alpha.58" - resolved "https://registry.yarnpkg.com/@material-ui/lab/-/lab-4.0.0-alpha.58.tgz#c7ebb66f49863c5acbb20817163737caa299fafc" - integrity sha512-GKHlJqLxUeHH3L3dGQ48ZavYrqGOTXkFkiEiuYMAnAvXAZP4rhMIqeHOPXSUQan4Bd8QnafDcpovOSLnadDmKw== + version "4.0.0-alpha.60" + resolved "https://registry.yarnpkg.com/@material-ui/lab/-/lab-4.0.0-alpha.60.tgz#5ad203aed5a8569b0f1753945a21a05efa2234d2" + integrity sha512-fadlYsPJF+0fx2lRuyqAuJj7hAS1tLDdIEEdov5jlrpb5pp4b+mRDUqQTUxi4inRZHS1bEXpU8QWUhO6xX88aA== dependencies: "@babel/runtime" "^7.4.4" "@material-ui/utils" "^4.11.2" @@ -3308,10 +3308,10 @@ jss-plugin-vendor-prefixer "^10.5.1" prop-types "^15.7.2" -"@material-ui/system@^4.11.3": - version "4.11.3" - resolved "https://registry.yarnpkg.com/@material-ui/system/-/system-4.11.3.tgz#466bc14c9986798fd325665927c963eb47cc4143" - integrity sha512-SY7otguNGol41Mu2Sg6KbBP1ZRFIbFLHGK81y4KYbsV2yIcaEPOmsCK6zwWlp+2yTV3J/VwT6oSBARtGIVdXPw== +"@material-ui/system@^4.12.1": + version "4.12.1" + resolved "https://registry.yarnpkg.com/@material-ui/system/-/system-4.12.1.tgz#2dd96c243f8c0a331b2bb6d46efd7771a399707c" + integrity sha512-lUdzs4q9kEXZGhbN7BptyiS1rLNHe6kG9o8Y307HCvF4sQxbCgpL2qi+gUk+yI8a2DNk48gISEQxoxpgph0xIw== dependencies: "@babel/runtime" "^7.4.4" "@material-ui/utils" "^4.11.2" From 196a1dc1511ad5c2269e8a6c776cb34a9d9b62b3 Mon Sep 17 00:00:00 2001 From: Danail H Date: Fri, 9 Jul 2021 15:20:06 +0300 Subject: [PATCH 5/7] update --- packages/grid/_modules_/grid/utils/utils.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/grid/_modules_/grid/utils/utils.ts b/packages/grid/_modules_/grid/utils/utils.ts index d5be7041636ac..6670354d718d5 100644 --- a/packages/grid/_modules_/grid/utils/utils.ts +++ b/packages/grid/_modules_/grid/utils/utils.ts @@ -26,15 +26,14 @@ export function isMuiV5(): boolean { } export function muiStyleAlpha(color: string, value: number): string { - if (isMuiV5() || !(styles as any)?.fade) { + if ((styles as any)?.alpha) { return (styles as any)?.alpha(color, value); } - return (styles as any)?.fade(color, value); } export function createTheme(): styles.Theme { - if (isMuiV5() || !(styles as any)?.createMuiTheme) { + if ((styles as any)?.createTheme) { return (styles as any)?.createTheme(); } return (styles as any)?.createMuiTheme(); From 2fa4e1e9db4a04242b2ae5abb4f36a641c34147d Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Sat, 10 Jul 2021 15:46:20 +0200 Subject: [PATCH 6/7] fix build --- .../_modules_/grid/components/GridPagination.tsx | 8 +++++--- .../_modules_/grid/components/panel/GridPanel.tsx | 4 ++-- .../_modules_/grid/utils/getGridLocalization.ts | 4 ++-- packages/grid/_modules_/grid/utils/utils.ts | 14 ++++++++++++-- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/packages/grid/_modules_/grid/components/GridPagination.tsx b/packages/grid/_modules_/grid/components/GridPagination.tsx index 272ffa4d018bf..eb35ceebf6c5e 100644 --- a/packages/grid/_modules_/grid/components/GridPagination.tsx +++ b/packages/grid/_modules_/grid/components/GridPagination.tsx @@ -6,7 +6,7 @@ import { useGridSelector } from '../hooks/features/core/useGridSelector'; import { gridPaginationSelector } from '../hooks/features/pagination/gridPaginationSelector'; import { optionsSelector } from '../hooks/utils/optionsSelector'; import { useGridApiContext } from '../hooks/root/useGridApiContext'; -import { isMuiV5, createTheme } from '../utils'; +import { getMuiVersion, createTheme } from '../utils'; const defaultTheme = createTheme(); // Used to hide the Rows per page selector on small devices @@ -66,7 +66,7 @@ export const GridPagination = React.forwardRef< ); const getPaginationChangeHandlers = () => { - if (isMuiV5()) { + if (getMuiVersion() !== 'v4') { return { onPageChange: handlePageChange, onRowsPerPageChange: handlePageSizeChange, @@ -84,7 +84,9 @@ export const GridPagination = React.forwardRef< (functi const apiRef = useGridApiContext(); const getPopperModifiers = (): any => { - if (isMuiV5()) { + if (getMuiVersion() === 'v5') { return [ { name: 'flip', diff --git a/packages/grid/_modules_/grid/utils/getGridLocalization.ts b/packages/grid/_modules_/grid/utils/getGridLocalization.ts index ef5507228feb1..bfd75b5fc79ca 100644 --- a/packages/grid/_modules_/grid/utils/getGridLocalization.ts +++ b/packages/grid/_modules_/grid/utils/getGridLocalization.ts @@ -1,6 +1,6 @@ import { GridLocaleText } from '../models/api/gridLocaleTextApi'; import { GridOptions } from '../models/gridOptions'; -import { isMuiV5 } from './utils'; +import { getMuiVersion } from './utils'; export interface LocalizationV4 { props: { @@ -22,7 +22,7 @@ export const getGridLocalization = ( gridTranslations: Partial, coreTranslations?, ): Localization => { - if (isMuiV5()) { + if (getMuiVersion() === 'v5') { return { components: { MuiDataGrid: { diff --git a/packages/grid/_modules_/grid/utils/utils.ts b/packages/grid/_modules_/grid/utils/utils.ts index 6670354d718d5..5d768b1783d5a 100644 --- a/packages/grid/_modules_/grid/utils/utils.ts +++ b/packages/grid/_modules_/grid/utils/utils.ts @@ -21,14 +21,23 @@ export function getThemePaletteMode(palette: any): string { return palette.type || palette.mode; } -export function isMuiV5(): boolean { - return !('fade' in styles); +export function getMuiVersion(): string { + if (!('fade' in styles)) { + return 'v5'; + } + + if ('fade' in styles && 'alpha' in styles) { + return 'v4.12'; + } + + return 'v4'; } export function muiStyleAlpha(color: string, value: number): string { if ((styles as any)?.alpha) { return (styles as any)?.alpha(color, value); } + // deprecated name in v4.12 and v5 return (styles as any)?.fade(color, value); } @@ -36,6 +45,7 @@ export function createTheme(): styles.Theme { if ((styles as any)?.createTheme) { return (styles as any)?.createTheme(); } + // deprecated name in v4.12 and v5 return (styles as any)?.createMuiTheme(); } From 4cf8a7b83f44d651b10975ae7445d855e6d7b432 Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Sat, 10 Jul 2021 17:11:50 +0200 Subject: [PATCH 7/7] update docs too --- yarn.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yarn.lock b/yarn.lock index ffb4ddc5e5bff..57c584e06ae67 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3279,8 +3279,8 @@ react-is "^16.8.0 || ^17.0.0" "@material-ui/monorepo@https://github.com/mui-org/material-ui.git#master": - version "4.11.1" - resolved "https://github.com/mui-org/material-ui.git#c8b7ad499c6573c63ccb7e1fb21eb2124c6e77c8" + version "4.12.1" + resolved "https://github.com/mui-org/material-ui.git#1c5beec4be20eae30e75c69ab513bbfec3e9baaf" "@material-ui/monorepo@https://github.com/mui-org/material-ui.git#next": version "5.0.0-beta.0"