From 370722ca45b0414c6d2ce41d5b76be0d4bf5386d Mon Sep 17 00:00:00 2001 From: Alican Erdurmaz Date: Wed, 13 Nov 2024 15:14:26 +0300 Subject: [PATCH 01/30] feat: update material ui to 6 --- documentation/blog/2024-05-22-mui-grid.md | 103 +- .../blog/2024-07-03-mui-autocomplete.md | 69 +- .../docs/getting-started/example/sandpack.tsx | 78 +- .../authentication/auth-pages/mui.tsx | 4 +- .../forms/server-side-validation-mui.tsx | 4 +- .../general-concepts/auth-pages/mui.tsx | 4 +- .../general-concepts/layout/mui.tsx | 4 +- .../notifications/notifications-mui.tsx | 10 +- .../components/basic-views/create/index.md | 8 +- .../components/basic-views/edit/index.md | 24 +- .../introduction/previews/auth-page.tsx | 4 +- .../introduction/previews/basic-views.tsx | 4 +- .../introduction/previews/example.tsx | 4 +- .../introduction/previews/layout-next-js.tsx | 4 +- .../previews/layout-react-router-dom.tsx | 4 +- .../introduction/previews/layout-remix.tsx | 4 +- .../introduction/previews/theming.tsx | 4 +- .../introduction/previews/usage-next-js.tsx | 4 +- .../previews/usage-react-router-dom.tsx | 4 +- .../introduction/previews/usage-remix.tsx | 4 +- .../material-ui/theming/index.md | 20 +- .../material-ui/react-router/sandpack.tsx | 4 +- examples/auth-material-ui/package.json | 4 +- examples/base-material-ui/package.json | 4 +- .../blog-material-ui-datagrid/package.json | 6 +- examples/blog-material-ui/package.json | 6 +- .../blog-react-hook-dynamic-form/package.json | 6 +- examples/blog-refine-mui/package.json | 6 +- .../src/components/header/index.tsx | 6 +- .../src/components/recent-sales/index.tsx | 16 +- .../src/pages/categories/create.tsx | 8 +- .../src/pages/categories/edit.tsx | 8 +- .../src/pages/dashboard/Dashboard.tsx | 8 +- .../src/pages/products/create.tsx | 12 +- .../src/pages/products/edit.tsx | 16 +- .../blog-refine-react-hook-form/package.json | 6 +- .../package.json | 4 +- .../package.json | 4 +- examples/finefoods-material-ui/package.json | 6 +- .../src/components/header/index.tsx | 12 +- .../components/product/drawer-form/index.tsx | 10 +- .../components/product/list-card/index.tsx | 11 +- .../src/components/store/info-card/index.tsx | 33 +- .../src/pages/couriers/edit.tsx | 6 +- .../src/pages/dashboard/index.tsx | 93 +- .../src/pages/orders/show.tsx | 20 +- .../src/pages/stores/create.tsx | 18 +- .../src/pages/stores/edit.tsx | 18 +- .../package.json | 4 +- .../package.json | 6 +- .../form-material-ui-use-form/package.json | 4 +- .../package.json | 4 +- .../package.json | 4 +- .../import-export-material-ui/package.json | 4 +- examples/inferencer-material-ui/package.json | 6 +- .../src/components/header/index.tsx | 6 +- examples/mern-dashboard-client/package.json | 6 +- .../src/components/common/Form.tsx | 6 +- .../src/pages/all-properties.tsx | 12 +- examples/refine-hr-ce/package.json | 5 +- .../src/components/time-offs/leave-cards.tsx | 24 +- .../src/pages/employee/time-offs/list.tsx | 17 +- .../package.json | 4 +- .../table-material-ui-advanced/package.json | 4 +- .../src/pages/dataGrid/index.tsx | 4 +- .../package.json | 4 +- .../package.json | 4 +- .../package.json | 6 +- .../src/pages/posts/list.tsx | 25 +- .../package.json | 4 +- .../package.json | 4 +- .../package.json | 4 +- examples/template-material-ui/package.json | 6 +- examples/theme-material-ui-demo/package.json | 4 +- examples/tutorial-material-ui/package.json | 6 +- .../src/pages/blog-posts/create.tsx | 16 +- .../src/pages/blog-posts/edit.tsx | 20 +- .../upload-material-ui-base64/package.json | 4 +- .../upload-material-ui-multipart/package.json | 4 +- examples/with-material-ui-vite/package.json | 6 +- .../src/pages/blog-posts/create.tsx | 8 +- .../src/pages/blog-posts/edit.tsx | 8 +- .../src/pages/categories/create.tsx | 4 +- .../src/pages/categories/edit.tsx | 4 +- examples/with-remix-material-ui/package.json | 6 +- .../src/definitions/separated-imports/mui.ts | 1 + packages/inferencer/package.json | 6 +- .../__snapshots__/index.test.tsx.snap | 31 +- .../mui/__snapshots__/index.test.tsx.snap | 2984 +++++++++++++---- .../__snapshots__/create.test.tsx.snap | 1030 +++++- .../__snapshots__/edit.test.tsx.snap | 1246 +++++-- .../__snapshots__/list.test.tsx.snap | 103 +- .../__snapshots__/show.test.tsx.snap | 100 +- .../inferencer/src/inferencers/mui/create.tsx | 6 +- .../inferencer/src/inferencers/mui/edit.tsx | 12 +- packages/live-previews/package.json | 6 +- packages/mui/package.json | 12 +- .../mui/src/components/breadcrumb/index.tsx | 2 +- .../mui/src/components/pages/error/index.tsx | 2 +- .../mui/src/components/pages/ready/index.tsx | 11 +- packages/mui/tsup.config.ts | 2 +- pnpm-lock.yaml | 1044 +++--- 102 files changed, 5552 insertions(+), 2032 deletions(-) diff --git a/documentation/blog/2024-05-22-mui-grid.md b/documentation/blog/2024-05-22-mui-grid.md index ecbf3ecc21e7..23397ad7f80c 100644 --- a/documentation/blog/2024-05-22-mui-grid.md +++ b/documentation/blog/2024-05-22-mui-grid.md @@ -78,7 +78,7 @@ When using Material UI Grid: To get started, import the `` component into your project like this: ```tsx -import Grid from "@mui/material/Grid"; +import Grid from "@mui/material/Grid2"; or; import { Grid } from "@mui/material"; ``` @@ -90,7 +90,7 @@ Typically, Material UI Grid provides two types of layouts; `containers` and `ite The items need to be wrapped in a container: ```tsx -import Grid from "@mui/material/Grid"; +import Grid from "@mui/material/Grid2"; return ( <> @@ -98,7 +98,7 @@ return ( Container {/* A Child grid container */} - +
A flex item
{/* A simple flex item */}
@@ -114,7 +114,7 @@ Consider the code below: ```tsx import React, { useState } from "react"; -import Grid from "@mui/material/Grid"; +import Grid from "@mui/material/Grid2"; import FormControlLabel from "@mui/material/FormControlLabel"; import RadioGroup from "@mui/material/RadioGroup"; import Radio from "@mui/material/Radio"; @@ -150,7 +150,7 @@ const MUIspacing = () => { {/*Rethreeder 3 empty black boxes as items of this container*/} {[0, 1, 2].map((value) => ( - + ))} @@ -198,7 +198,7 @@ Here’s the result: ### Fluid Grids -Fluid Grids in Material UI use column widths and breakpoints to scale grid items and resize content within them. We can create layouts for different screen sizes using the breakpoint props (`xs`, `sm`, `md`, `lg`, and `xl`) on the grid items. +Fluid Grids in Material UI use column widths and breakpoints to scale grid items and resize content within them. We can create layouts for different screen sizes using the `size` prop on the grid items. ### Basic Fluid Grids @@ -209,7 +209,7 @@ Here’s a simple illustration of how to use Basic Fluid Grids in Material UI. ```tsx import React from "react"; import Box from "@mui/material/Box"; -import Grid from "@mui/material/Grid"; +import Grid from "@mui/material/Grid2"; import "../App.css"; const BasicGrid = () => { @@ -217,16 +217,32 @@ const BasicGrid = () => { {/* Setting up the Fluid Grid system */} - +
xs=6
- +
xs=6
- +
xs=4
- +
xs=8
@@ -246,14 +262,14 @@ Here’s the result; ### Fluid Grids with multiple breakpoints Components may be defined with multiple widths, causing the layout to change at the defined breakpoint. Width values assigned to larger breakpoints precede those assigned to smaller ones. -For example`xs={12} sm={6}` sizes a component to takes half of the 6 columns when viewport width is minimum 600px or above. The component fills all 12 available columns in smaller viewports. +For example with the prop `size={{ xs: 6, md: 8 }}`, the component will take up half of the 12-column grid (6 columns) when the viewport is 600px or wider, and it will fill all 12 columns on smaller screens. Consider the code below: ```tsx import * as React from "react"; import Box from "@mui/material/Box"; -import Grid from "@mui/material/Grid"; +import Grid from "@mui/material/Grid2"; const ComplexFluidGrid = () => { return ( @@ -305,19 +321,23 @@ Consider the code below: ```tsx import * as React from "react"; import Box from "@mui/material/Box"; -import Grid from "@mui/material/Grid"; +import Grid from "@mui/material/Grid2"; const AutoGrid = () => { return ( - +
xs
- +
xs=6
- +
xs
@@ -338,25 +358,37 @@ The code above depicts three grid elements. The middle element is set to take ha ### Nested Grids -You can combine the `container` and `item` props so that the `` component can act as both a flex container and a child item. This allows us to have another grid set within the grid item. +The `` that renders as a direct child inside another `` is a nested grid that inherits its columns and spacing from the top level. This allows you to create complex layouts with multiple grid items. Consider the code below: ```tsx import * as React from "react"; import Box from "@mui/material/Box"; -import Grid from "@mui/material/Grid"; +import Grid from "@mui/material/Grid2"; function NestedGrid() { return ( - +
Grid Element
- +
Grid Element
- +
Grid Element
@@ -367,13 +399,13 @@ export default function NestedGridGroup() { return ( - + - + - + @@ -404,7 +436,7 @@ Study the code: import * as React from "react"; import Paper from "@mui/material/Paper"; import Typography from "@mui/material/Typography"; -import Grid from "@mui/material/Grid"; +import Grid from "@mui/material/Grid2"; import Box from "@mui/material/Box"; function MainFeaturedPost(props) { @@ -441,7 +473,11 @@ function MainFeaturedPost(props) { }} /> - + + @@ -526,7 +567,7 @@ Here’s the code for the Blog component: ```tsx import * as React from "react"; import CssBaseline from "@mui/material/CssBaseline"; -import Grid from "@mui/material/Grid"; +import Grid from "@mui/material/Grid2"; import Container from "@mui/material/Container"; import { createTheme, ThemeProvider } from "@mui/material/styles"; import Header from "./Header"; @@ -658,7 +699,7 @@ In practice, you can set the `zeroMinWidth` property as follows: ### direction: column | column-reverse -`direction="column"` and `direction="column-reverse"` containers do not support the `xs`, `sm`, `md`, `lg`, and `xl` props. These breakpoints are primarily concerned with controlling width and have no effect on height within column containers. +`direction="column"` and `direction="column-reverse"` containers do not support the `size={{ xs, sm, md , lg ,xl }}` prop. These breakpoints are primarily concerned with controlling width and have no effect on height within column containers. ## Conclusion diff --git a/documentation/blog/2024-07-03-mui-autocomplete.md b/documentation/blog/2024-07-03-mui-autocomplete.md index 7b956c9b040a..283b65af7d01 100644 --- a/documentation/blog/2024-07-03-mui-autocomplete.md +++ b/documentation/blog/2024-07-03-mui-autocomplete.md @@ -513,16 +513,18 @@ export default function Asynchronous() { - {loading ? ( - - ) : null} - {params.InputProps.endAdornment} - - ), + slotProps={{ + input: { + ...params.slotProps, + endAdornment: ( + + {loading ? ( + + ) : null} + {params.slotProps.endAdornment} + + ), + }, }} /> )} @@ -721,11 +723,13 @@ Make the AutoComplete component more accessible by adding in ARIA attributes as )} @@ -743,11 +747,12 @@ Make the AutoComplete component more accessible by adding in ARIA attributes as renderInput={(params) => ( )} @@ -764,10 +769,12 @@ Make the AutoComplete component more accessible by adding in ARIA attributes as renderInput={(params) => ( )} @@ -816,9 +823,11 @@ Below are some code snippets and tips to improve keyboard navigation: renderInput={(params) => ( )} @@ -884,7 +893,11 @@ const Home = () => { freeSolo options={top5Songs.map((option) => option.title)} style={style.root} - inputProps={{ style: { fontFamily: "nunito", color: "white" } }} + slotProps={{ + input: { + style: { backgroundColor: "#333", borderRadius: "24px" }, + }, + }} renderInput={(params) => ( )} diff --git a/documentation/docs/getting-started/example/sandpack.tsx b/documentation/docs/getting-started/example/sandpack.tsx index b3bfb22af081..5b3865bf6451 100644 --- a/documentation/docs/getting-started/example/sandpack.tsx +++ b/documentation/docs/getting-started/example/sandpack.tsx @@ -438,7 +438,11 @@ export const Header: React.FC = ({ - - - ), - }} size="small" placeholder="Keyword Search" + slotProps={{ + input: { + startAdornment: ( + + + + ), + }, + }} /> { helperText={(errors as any)?.title?.message} margin="normal" fullWidth - InputLabelProps={{ shrink: true }} type="text" label={translate("categories.fields.title")} name="title" + slotProps={{ + inputLabel: { shrink: true }, + }} /> { helperText={(errors as any)?.cover?.message} margin="normal" fullWidth - InputLabelProps={{ shrink: true }} multiline label={translate("cover")} name="cover" + slotProps={{ + inputLabel: { shrink: true }, + }} /> diff --git a/examples/blog-refine-mui/src/pages/categories/edit.tsx b/examples/blog-refine-mui/src/pages/categories/edit.tsx index 26ea9192d2ee..d19d2b92f1a6 100644 --- a/examples/blog-refine-mui/src/pages/categories/edit.tsx +++ b/examples/blog-refine-mui/src/pages/categories/edit.tsx @@ -34,11 +34,13 @@ export const CategoryEdit = () => { helperText={(errors as any)?.id?.message} margin="normal" fullWidth - InputLabelProps={{ shrink: true }} type="number" label={translate("categories.fields.id")} name="id" disabled + slotProps={{ + inputLabel: { shrink: true }, + }} /> { helperText={(errors as any)?.title?.message} margin="normal" fullWidth - InputLabelProps={{ shrink: true }} type="text" label={translate("categories.fields.title")} name="title" + slotProps={{ + inputLabel: { shrink: true }, + }} /> - + formatCurrency.format(value)} /> - + - + { helperText={(errors as any)?.name?.message} margin="normal" fullWidth - InputLabelProps={{ shrink: true }} type="text" label={translate("Name")} name="name" + slotProps={{ + inputLabel: { shrink: true }, + }} /> { helperText={(errors as any)?.description?.message} margin="normal" fullWidth - InputLabelProps={{ shrink: true }} multiline label={translate("description")} name="description" + slotProps={{ + inputLabel: { shrink: true }, + }} /> { helperText={(errors as any)?.price?.message} margin="normal" fullWidth - InputLabelProps={{ shrink: true }} type="number" label={translate("Price")} name="price" + slotProps={{ + inputLabel: { shrink: true }, + }} /> { helperText={(errors as any)?.id?.message} margin="normal" fullWidth - InputLabelProps={{ shrink: true }} type="number" label={translate("id")} name="id" disabled + slotProps={{ + inputLabel: { shrink: true }, + }} /> { helperText={(errors as any)?.name?.message} margin="normal" fullWidth - InputLabelProps={{ shrink: true }} type="text" label={translate("Name")} name="name" + slotProps={{ + inputLabel: { shrink: true }, + }} /> { helperText={(errors as any)?.description?.message} margin="normal" fullWidth - InputLabelProps={{ shrink: true }} multiline label={translate("Description")} name="description" + slotProps={{ + inputLabel: { shrink: true }, + }} /> { helperText={(errors as any)?.price?.message} margin="normal" fullWidth - InputLabelProps={{ shrink: true }} type="number" label={translate("Price")} name="price" + slotProps={{ + inputLabel: { shrink: true }, + }} /> = () => { = () => { size="small" disableUnderline defaultValue={currentLocale} - inputProps={{ "aria-label": "Without label" }} + slotProps={{ + input: { + "aria-label": "Without label", + }, + }} variant="outlined" sx={{ width: { diff --git a/examples/finefoods-material-ui/src/components/product/drawer-form/index.tsx b/examples/finefoods-material-ui/src/components/product/drawer-form/index.tsx index d7fd9c24b262..bb532d5e53b7 100644 --- a/examples/finefoods-material-ui/src/components/product/drawer-form/index.tsx +++ b/examples/finefoods-material-ui/src/components/product/drawer-form/index.tsx @@ -232,10 +232,12 @@ export const ProductDrawerForm = (props: Props) => { label={t("products.fields.price")} placeholder={t("products.fields.price")} type="number" - InputProps={{ - startAdornment: ( - $ - ), + slotProps={{ + input: { + startAdornment: ( + $ + ), + }, }} /> ); diff --git a/examples/finefoods-material-ui/src/components/product/list-card/index.tsx b/examples/finefoods-material-ui/src/components/product/list-card/index.tsx index dd0445bcc748..3f3b88e6b558 100644 --- a/examples/finefoods-material-ui/src/components/product/list-card/index.tsx +++ b/examples/finefoods-material-ui/src/components/product/list-card/index.tsx @@ -5,7 +5,7 @@ import Typography from "@mui/material/Typography"; import type { ICategory, IProduct } from "../../../interfaces"; import { useLocation } from "react-router-dom"; import { ProductStatus } from "../status"; -import Grid from "@mui/material/Grid"; +import Grid from "@mui/material/Grid2"; import Card from "@mui/material/Card"; import CardContent from "@mui/material/CardContent"; import CardMedia from "@mui/material/CardMedia"; @@ -125,7 +125,14 @@ export const ProductListCard = (props: Props) => { ); return ( - + { return ( {icon} - + {label} - {value ?? ( )} diff --git a/examples/finefoods-material-ui/src/pages/couriers/edit.tsx b/examples/finefoods-material-ui/src/pages/couriers/edit.tsx index 5bd542cc3790..49eb2f363087 100644 --- a/examples/finefoods-material-ui/src/pages/couriers/edit.tsx +++ b/examples/finefoods-material-ui/src/pages/couriers/edit.tsx @@ -12,7 +12,7 @@ import { Controller } from "react-hook-form"; import Button from "@mui/material/Button"; import FormControl from "@mui/material/FormControl"; import FormHelperText from "@mui/material/FormHelperText"; -import Grid from "@mui/material/Unstable_Grid2"; +import Grid from "@mui/material/Grid2"; import Stack from "@mui/material/Stack"; import TextField from "@mui/material/TextField"; import Autocomplete from "@mui/material/Autocomplete"; @@ -90,7 +90,7 @@ export const CourierEdit = () => { }} /> - +
{
- + diff --git a/examples/finefoods-material-ui/src/pages/dashboard/index.tsx b/examples/finefoods-material-ui/src/pages/dashboard/index.tsx index 63ac2e8d5ab7..96c0c79cbd27 100644 --- a/examples/finefoods-material-ui/src/pages/dashboard/index.tsx +++ b/examples/finefoods-material-ui/src/pages/dashboard/index.tsx @@ -1,7 +1,7 @@ import React, { useMemo, useState } from "react"; import { useApiUrl, useCustom, useTranslate } from "@refinedev/core"; import dayjs from "dayjs"; -import Grid from "@mui/material/Grid"; +import Grid from "@mui/material/Grid2"; import { NumberField } from "@refinedev/mui"; import MonetizationOnOutlinedIcon from "@mui/icons-material/MonetizationOnOutlined"; import ShoppingBagOutlinedIcon from "@mui/icons-material/ShoppingBagOutlined"; @@ -138,12 +138,13 @@ export const DashboardPage: React.FC = () => { > {
{ { { { { { ]} > - + { - + diff --git a/examples/finefoods-material-ui/src/pages/stores/create.tsx b/examples/finefoods-material-ui/src/pages/stores/create.tsx index 3134e3c17803..379ca9a070bc 100644 --- a/examples/finefoods-material-ui/src/pages/stores/create.tsx +++ b/examples/finefoods-material-ui/src/pages/stores/create.tsx @@ -2,7 +2,7 @@ import { useNavigation } from "@refinedev/core"; import { ListButton } from "@refinedev/mui"; import ArrowBack from "@mui/icons-material/ArrowBack"; import Divider from "@mui/material/Divider"; -import Grid from "@mui/material/Grid"; +import Grid from "@mui/material/Grid2"; import { StoreForm, StoreMap, useStoreForm } from "../../components"; export const StoreCreate = () => { @@ -27,7 +27,13 @@ export const StoreCreate = () => { }} /> - + { }} /> - + { )} - + {isFormIsDisabled ? ( @@ -111,7 +117,13 @@ export const StoreEdit = () => { /> )} - + = ({