From f3fcb12b64bd0f29b17d5764c19cff284d37dce6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Dec 2023 18:58:43 +0530 Subject: [PATCH 01/11] Bump vite from 4.4.11 to 4.4.12 (#40115) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/yarn.lock b/yarn.lock index 20dadc0d2dfe54..94d199257ca112 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5064,9 +5064,9 @@ aws-sign2@~0.7.0: integrity sha512-08kcGqnYf/YmjoRhfxyu+CLxBjUtHLXLXX/vUfx9l2LYzG3c1m61nrpyFUZI6zeS+Li/wWMMidD9KgrqtGq3mA== aws4@^1.8.0: - version "1.11.0" - resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.11.0.tgz#d61f46d83b2519250e2784daf5b09479a8b41c59" - integrity sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA== + version "1.12.0" + resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.12.0.tgz#ce1c9d143389679e253b314241ea9aa5cec980d3" + integrity sha512-NmWvPnx0F1SfrQbYwOi7OeaNGokp9XhzNioJ/CSBs8Qa4vxug81mhJEAVZwxXuBmYB5KDRfMq/F3RR0BIU7sWg== axe-core@^4.6.2: version "4.6.3" @@ -15772,9 +15772,9 @@ sprintf-js@~1.0.2: integrity sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g== sshpk@^1.7.0: - version "1.17.0" - resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.17.0.tgz#578082d92d4fe612b13007496e543fa0fbcbe4c5" - integrity sha512-/9HIEs1ZXGhSPE8X6Ccm7Nam1z8KcoCqPdI7ecm1N33EzAetWahvQWVqLZtaZQ+IDKX4IyA2o0gBzqIMkAagHQ== + version "1.18.0" + resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.18.0.tgz#1663e55cddf4d688b86a46b77f0d5fe363aba028" + integrity sha512-2p2KJZTSqQ/I3+HX42EpYOa2l3f8Erv8MWKsy2I9uf4wA7yFIkXRffYdsx86y6z4vHtV8u7g+pPlr8/4ouAxsQ== dependencies: asn1 "~0.2.3" assert-plus "^1.0.0" @@ -17286,9 +17286,9 @@ victory-vendor@^36.6.8: d3-timer "^3.0.1" vite@^4.4.11: - version "4.4.11" - resolved "https://registry.yarnpkg.com/vite/-/vite-4.4.11.tgz#babdb055b08c69cfc4c468072a2e6c9ca62102b0" - integrity sha512-ksNZJlkcU9b0lBwAGZGGaZHCMqHsc8OpgtoYhsQ4/I2v5cnpmmmqe5pM4nv/4Hn6G/2GhTdj0DhZh2e+Er1q5A== + version "4.4.12" + resolved "https://registry.yarnpkg.com/vite/-/vite-4.4.12.tgz#e9c355d5a0d8a47afa46cb4bad10820da333da5c" + integrity sha512-KtPlUbWfxzGVul8Nut8Gw2Qe8sBzWY+8QVc5SL8iRFnpnrcoCaNlzO40c1R6hPmcdTwIPEDkq0Y9+27a5tVbdQ== dependencies: esbuild "^0.18.10" postcss "^8.4.27" From 802f042d287180dc0edf2ee7edcb3bf4628284ad Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Dec 2023 19:00:18 +0530 Subject: [PATCH 02/11] Bump vite from 4.4.11 to 4.4.12 in /apps/zero-runtime-vite-app (#40122) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- apps/zero-runtime-vite-app/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/zero-runtime-vite-app/package.json b/apps/zero-runtime-vite-app/package.json index a598fe20f00c58..d2d0fc517e6197 100644 --- a/apps/zero-runtime-vite-app/package.json +++ b/apps/zero-runtime-vite-app/package.json @@ -27,7 +27,7 @@ "jest-environment-jsdom": "^29.7.0", "jsdom": "^22.1.0", "local-library": "file:../local-library", - "vite": "4.4.11", + "vite": "4.4.12", "vitest": "^0.34.6", "typescript": "5.3.2" }, From aa9e615b8e5ab7e5e08b04b50c67c5709b335723 Mon Sep 17 00:00:00 2001 From: Siriwat K Date: Mon, 11 Dec 2023 17:29:32 +0700 Subject: [PATCH 03/11] [material-ui] Add new Next.js integration package (#39947) --- .codesandbox/ci.json | 2 + docs/babel.config.js | 1 + .../next-js-app-router/next-js-app-router.md | 227 ------------------ docs/data/material/guides/nextjs/nextjs.md | 142 +++++++++++ docs/data/material/pages.ts | 5 +- docs/next.config.js | 1 + docs/pages/_document.js | 110 ++++----- .../{next-js-app-router.js => nextjs.js} | 2 +- docs/public/_redirects | 1 + docs/src/modules/sandbox/Dependencies.ts | 1 + docs/translations/translations.json | 2 +- package.json | 2 +- packages/mui-material-nextjs/README.md | 3 + packages/mui-material-nextjs/package.json | 66 +++++ .../src/v13-appRouter/appRouterV13.tsx | 102 ++++++++ .../src/v13-appRouter/index.ts | 3 + .../src/v13-pagesRouter/index.ts | 1 + .../src/v13-pagesRouter/pagesRouterV13.tsx | 143 +++++++++++ .../src/v14-appRouter/index.ts | 2 + .../src/v14-pagesRouter/index.ts | 1 + .../mui-material-nextjs/tsconfig.build.json | 15 ++ packages/mui-material-nextjs/tsconfig.json | 7 + scripts/sizeSnapshot/webpack.config.js | 1 + test/karma.conf.js | 1 + tsconfig.json | 2 + webpackBaseConfig.js | 1 + 26 files changed, 545 insertions(+), 299 deletions(-) delete mode 100644 docs/data/material/guides/next-js-app-router/next-js-app-router.md create mode 100644 docs/data/material/guides/nextjs/nextjs.md rename docs/pages/material-ui/guides/{next-js-app-router.js => nextjs.js} (61%) create mode 100644 packages/mui-material-nextjs/README.md create mode 100644 packages/mui-material-nextjs/package.json create mode 100644 packages/mui-material-nextjs/src/v13-appRouter/appRouterV13.tsx create mode 100644 packages/mui-material-nextjs/src/v13-appRouter/index.ts create mode 100644 packages/mui-material-nextjs/src/v13-pagesRouter/index.ts create mode 100644 packages/mui-material-nextjs/src/v13-pagesRouter/pagesRouterV13.tsx create mode 100644 packages/mui-material-nextjs/src/v14-appRouter/index.ts create mode 100644 packages/mui-material-nextjs/src/v14-pagesRouter/index.ts create mode 100644 packages/mui-material-nextjs/tsconfig.build.json create mode 100644 packages/mui-material-nextjs/tsconfig.json diff --git a/.codesandbox/ci.json b/.codesandbox/ci.json index 5c7949333fbc54..d3e8fff59c28fc 100644 --- a/.codesandbox/ci.json +++ b/.codesandbox/ci.json @@ -16,6 +16,7 @@ "packages/mui-styled-engine", "packages/mui-styled-engine-sc", "packages/mui-material-next", + "packages/mui-material-nextjs", "packages/mui-joy" ], "publishDirectory": { @@ -32,6 +33,7 @@ "@mui/utils": "packages/mui-utils/build", "@mui/base": "packages/mui-base/build", "@mui/material-next": "packages/mui-material-next/build", + "@mui/material-nextjs": "packages/mui-material-nextjs/build", "@mui/joy": "packages/mui-joy/build" }, "sandboxes": [ diff --git a/docs/babel.config.js b/docs/babel.config.js index 2ac385186d98eb..8ae8c464ae54e7 100644 --- a/docs/babel.config.js +++ b/docs/babel.config.js @@ -18,6 +18,7 @@ const alias = { '@mui/utils': '../packages/mui-utils/src', '@mui/base': '../packages/mui-base/src', '@mui/material-next': '../packages/mui-material-next/src', + '@mui/material-nextjs': '../packages/mui-material-nextjs/src', '@mui/joy': '../packages/mui-joy/src', docs: './', modules: '../modules', diff --git a/docs/data/material/guides/next-js-app-router/next-js-app-router.md b/docs/data/material/guides/next-js-app-router/next-js-app-router.md deleted file mode 100644 index 1688d35df2197b..00000000000000 --- a/docs/data/material/guides/next-js-app-router/next-js-app-router.md +++ /dev/null @@ -1,227 +0,0 @@ -# Next.js App Router - -

Learn how to use Material UI with the Next.js App Router.

- -## Example - -Starting fresh on a new App Router-based project? - -Jump right into the code with [this example: Material UI - Next.js App Router in TypeScript](https://github.com/mui/material-ui/tree/master/examples/material-ui-nextjs-ts). - -## Next.js and React Server Components - -The Next.js App Router implements React Server Components, [an upcoming feature for React](https://github.com/reactjs/rfcs/blob/main/text/0227-server-module-conventions.md). - -To support the App Router, the components and hooks from Material UI that need access to browser APIs are exported with the `"use client"` directive. - -:::warning -React Server Components is not the same concept as server-side rendering (SSR). -So-called Client Components are still server-rendered to HTML. - -For more details, see [this explanation](https://github.com/reactwg/server-components/discussions/4) of Client Components and SSR from the React Working Group. -::: - -## Using Material UI with the default theme - -If you're using the default theme, you can add Material UI components to Next.js routing files such as `layout.js` or `page.js` (which are Server Components by default) without any additional configuration, as shown below: - - - -```jsx -// app/layout.js - no directives needed -export default function RootLayout(props) { - const { children } = props; - return ( - - {children} - - ) -} - -// app/page.js - no directives needed -import Box from '@mui/material/Box'; -import Card from '@mui/material/Card'; -import Container from '@mui/material/Container'; -import Typography from '@mui/material/Typography'; - -export default function Home() { - return ( -
- - - - Hello World ~ - - - -
- ); -} -``` - -## Using Material UI with a custom theme - -### Theme Registry - -To set up the theme context, create a custom `ThemeRegistry` component that combines the Emotion `CacheProvider`, the Material UI `ThemeProvider`, and the `useServerInsertedHTML` hook from `next/navigation` as follows: - -```tsx -// app/ThemeRegistry.tsx -'use client'; -import createCache from '@emotion/cache'; -import { useServerInsertedHTML } from 'next/navigation'; -import { CacheProvider } from '@emotion/react'; -import { ThemeProvider } from '@mui/material/styles'; -import CssBaseline from '@mui/material/CssBaseline'; -import theme from '/path/to/your/theme'; - -// This implementation is from emotion-js -// https://github.com/emotion-js/emotion/issues/2928#issuecomment-1319747902 -export default function ThemeRegistry(props) { - const { options, children } = props; - - const [{ cache, flush }] = React.useState(() => { - const cache = createCache(options); - cache.compat = true; - const prevInsert = cache.insert; - let inserted: string[] = []; - cache.insert = (...args) => { - const serialized = args[1]; - if (cache.inserted[serialized.name] === undefined) { - inserted.push(serialized.name); - } - return prevInsert(...args); - }; - const flush = () => { - const prevInserted = inserted; - inserted = []; - return prevInserted; - }; - return { cache, flush }; - }); - - useServerInsertedHTML(() => { - const names = flush(); - if (names.length === 0) { - return null; - } - let styles = ''; - for (const name of names) { - styles += cache.inserted[name]; - } - return ( -