diff --git a/docs/pages/_app.js b/docs/pages/_app.js index a2c6078f2a9c6..9eef6adeb19c1 100644 --- a/docs/pages/_app.js +++ b/docs/pages/_app.js @@ -20,6 +20,7 @@ import { create } from 'jss'; import rtl from 'jss-rtl'; import { useRouter } from 'next/router'; import { StylesProvider, jssPreset } from '@material-ui/styles'; +import { ponyfillGlobal } from '@material-ui/utils'; import pages from 'docsx/src/pages'; import initRedux from 'docs/src/modules/redux/initRedux'; import PageContext from 'docs/src/modules/components/PageContext'; @@ -29,6 +30,48 @@ import { ThemeProvider } from 'docs/src/modules/components/ThemeContext'; import { pathnameToLanguage, getCookie } from 'docs/src/modules/utils/helpers'; import { ACTION_TYPES, CODE_VARIANTS } from 'docs/src/modules/constants'; +function getMuiPackageVersion(packageName, commitRef) { + if (commitRef === undefined) { + return 'latest'; + } + const shortSha = commitRef.slice(0, 8); + return `https://pkg.csb.dev/mui-org/material-ui-x/commit/${shortSha}/@material-ui/${packageName}`; +} + +ponyfillGlobal.muiDocConfig = { + csbIncludePeerDependencies: (deps, { versions }) => { + const newDeps = { ...deps }; + + if ( + newDeps['@material-ui/x'] || + newDeps['@material-ui/x-grid'] || + newDeps['@material-ui/data-grid'] + ) { + newDeps['@material-ui/core'] = versions['@material-ui/core']; + } + + if (newDeps['@material-ui/x-grid-data-generator']) { + newDeps['@material-ui/core'] = versions['@material-ui/core']; + newDeps['@material-ui/icons'] = versions['@material-ui/icons']; + newDeps['@material-ui/lab'] = versions['@material-ui/lab']; + } + + return newDeps; + }, + csbGetVersions: (versions, { muiCommitRef }) => { + const output = { + ...versions, + '@material-ui/x-grid': getMuiPackageVersion('x-grid', muiCommitRef), + '@material-ui/x-grid-data-generator': getMuiPackageVersion( + 'x-grid-data-generator', + muiCommitRef, + ), + '@material-ui/data-grid': getMuiPackageVersion('data-grid', muiCommitRef), + }; + return output; + }, +}; + // Configure JSS const jss = create({ plugins: [...jssPreset().plugins, rtl()], diff --git a/yarn.lock b/yarn.lock index f9d6844c5dadf..60b6d063c1dce 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3264,7 +3264,7 @@ "@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#b8092ce09e164a1cb2fec2f3a5b6aa6e2dc6cbbd" + resolved "https://github.com/mui-org/material-ui.git#34be88ec011d91d7f0fe6ddb0ec04e588149bdfe" "@material-ui/monorepo@https://github.com/mui-org/material-ui.git#next": version "5.0.0-alpha.16"