From 82bfb0fc5551d368ace019372ba85a4a9f263cf0 Mon Sep 17 00:00:00 2001 From: Matthieu Chaffotte Date: Fri, 22 Sep 2023 09:38:34 +0200 Subject: [PATCH 01/17] feat: add state props in (Create)Button --- .../products/CreateRelatedReviewButton.tsx | 17 +++++ examples/demo/src/products/ProductEdit.tsx | 2 + examples/demo/src/reviews/ReviewCreate.tsx | 71 +++++++++++++++++++ examples/demo/src/reviews/StarRatingInput.tsx | 37 ++++++++++ examples/demo/src/reviews/index.ts | 2 + .../ra-ui-materialui/src/button/Button.tsx | 7 +- .../src/button/CreateButton.tsx | 6 +- 7 files changed, 138 insertions(+), 4 deletions(-) create mode 100644 examples/demo/src/products/CreateRelatedReviewButton.tsx create mode 100644 examples/demo/src/reviews/ReviewCreate.tsx create mode 100644 examples/demo/src/reviews/StarRatingInput.tsx diff --git a/examples/demo/src/products/CreateRelatedReviewButton.tsx b/examples/demo/src/products/CreateRelatedReviewButton.tsx new file mode 100644 index 00000000000..e2c5874ece1 --- /dev/null +++ b/examples/demo/src/products/CreateRelatedReviewButton.tsx @@ -0,0 +1,17 @@ +import * as React from 'react'; +import { CreateButton, useRecordContext } from 'react-admin'; + +const CreateRelatedReviewButton = () => { + const record = useRecordContext(); + + return ( + + ); +}; + +export default CreateRelatedReviewButton; diff --git a/examples/demo/src/products/ProductEdit.tsx b/examples/demo/src/products/ProductEdit.tsx index c35da562fa7..56579b1fa74 100644 --- a/examples/demo/src/products/ProductEdit.tsx +++ b/examples/demo/src/products/ProductEdit.tsx @@ -20,6 +20,7 @@ import CustomerReferenceField from '../visitors/CustomerReferenceField'; import StarRatingField from '../reviews/StarRatingField'; import Poster from './Poster'; import { Product } from '../types'; +import CreateRelatedReviewButton from './CreateRelatedReviewButton'; const ProductTitle = () => { const record = useRecordContext(); @@ -85,6 +86,7 @@ const ProductEdit = () => ( + diff --git a/examples/demo/src/reviews/ReviewCreate.tsx b/examples/demo/src/reviews/ReviewCreate.tsx new file mode 100644 index 00000000000..c7642d04c64 --- /dev/null +++ b/examples/demo/src/reviews/ReviewCreate.tsx @@ -0,0 +1,71 @@ +import * as React from 'react'; +import { + SimpleForm, + Create, + ReferenceInput, + TextInput, + DateInput, + AutocompleteInput, + required, + useNotify, + useRedirect, + getRecordFromLocation, +} from 'react-admin'; + +import StarRatingInput from './StarRatingInput'; +import { useLocation } from 'react-router'; + +const customerOptionRenderer = choice => + `${choice.first_name} ${choice.last_name}`; + +const productOptionRenderer = choice => `${choice.reference}`; + +const ReviewCreate = () => { + const notify = useNotify(); + const redirect = useRedirect(); + const location = useLocation(); + + const onSuccess = data => { + const record = getRecordFromLocation(location); + notify(`Changes saved`); + if (record && record.product_id) { + redirect(`/products/${record.product_id}/reviews`); + } else { + redirect(`/reviews`); + } + }; + + return ( + + + + + + + + + + + + + + ); +}; + +export default ReviewCreate; diff --git a/examples/demo/src/reviews/StarRatingInput.tsx b/examples/demo/src/reviews/StarRatingInput.tsx new file mode 100644 index 00000000000..121b3563579 --- /dev/null +++ b/examples/demo/src/reviews/StarRatingInput.tsx @@ -0,0 +1,37 @@ +import { Box, Rating, Typography, styled } from '@mui/material'; +import Icon from '@mui/icons-material/Stars'; +import { InputProps, useInput, useTranslate } from 'react-admin'; + +const StyledRating = styled(Rating)({ + '& .MuiRating-iconFilled': { + color: '#000', + }, + '& .MuiRating-iconHover': { + color: '#000', + }, +}); + +const StarRatingInput = (props: InputProps) => { + const { name = 'resources.reviews.fields.rating' } = props; + const { field } = useInput(props); + const translate = useTranslate(); + + return ( + + {translate(name)} + } + onChange={(event, value) => field.onChange(value)} + /> + + ); +}; + +export default StarRatingInput; diff --git a/examples/demo/src/reviews/index.ts b/examples/demo/src/reviews/index.ts index 6f6abed029c..810cb14977f 100644 --- a/examples/demo/src/reviews/index.ts +++ b/examples/demo/src/reviews/index.ts @@ -1,7 +1,9 @@ import ReviewIcon from '@mui/icons-material/Comment'; import ReviewList from './ReviewList'; +import ReviewCreate from './ReviewCreate'; export default { icon: ReviewIcon, list: ReviewList, + create: ReviewCreate, }; diff --git a/packages/ra-ui-materialui/src/button/Button.tsx b/packages/ra-ui-materialui/src/button/Button.tsx index 4f60a5d8c71..188ca8cb569 100644 --- a/packages/ra-ui-materialui/src/button/Button.tsx +++ b/packages/ra-ui-materialui/src/button/Button.tsx @@ -12,6 +12,8 @@ import { import { styled } from '@mui/material/styles'; import { useTranslate } from 'ra-core'; import { Path } from 'react-router'; +import { LinkProps } from 'react-router-dom'; +import { merge } from 'lodash'; /** * A generic Button with side icon. Only the icon is displayed on small screens. @@ -36,11 +38,12 @@ export const Button = (props: ButtonProps) => { color = 'primary', size = 'small', to: locationDescriptor, + state = {}, ...rest } = props; const translate = useTranslate(); const translatedLabel = label ? translate(label, { _: label }) : undefined; - const linkParams = getLinkParams(locationDescriptor); + const linkParams = merge(getLinkParams(locationDescriptor), { state }); const isXSmall = useMediaQuery((theme: Theme) => theme.breakpoints.down('sm') @@ -101,7 +104,7 @@ interface Props { variant?: string; } -export type ButtonProps = Props & MuiButtonProps; +export type ButtonProps = Props & Partial & MuiButtonProps; Button.propTypes = { alignIcon: PropTypes.oneOf(['left', 'right']), diff --git a/packages/ra-ui-materialui/src/button/CreateButton.tsx b/packages/ra-ui-materialui/src/button/CreateButton.tsx index 518fa7df7cc..56ae2de8895 100644 --- a/packages/ra-ui-materialui/src/button/CreateButton.tsx +++ b/packages/ra-ui-materialui/src/button/CreateButton.tsx @@ -8,6 +8,7 @@ import clsx from 'clsx'; import { Link } from 'react-router-dom'; import { useTranslate, useResourceContext, useCreatePath } from 'ra-core'; import isEqual from 'lodash/isEqual'; +import merge from 'lodash/merge'; import { Button, ButtonProps } from './Button'; @@ -32,6 +33,7 @@ const CreateButton = (props: CreateButtonProps) => { resource: resourceProp, scrollToTop = true, variant, + state = {}, ...rest } = props; @@ -46,7 +48,7 @@ const CreateButton = (props: CreateButtonProps) => { { Date: Fri, 22 Sep 2023 09:54:02 +0200 Subject: [PATCH 02/17] feat: update documentation --- docs/Create.md | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/docs/Create.md b/docs/Create.md index a5da1680914..21d44b7346f 100644 --- a/docs/Create.md +++ b/docs/Create.md @@ -424,7 +424,7 @@ You can do the same for error notifications, by passing a custom `onError` call ## Prefilling the Form -You sometimes need to pre-populate a record based on a *related* record. For instance, to create a comment related to an existing post. +You sometimes need to pre-populate a record based on a *related* record. For instance, to create a comment related to an existing post. By default, the `` view starts with an empty `record`. However, if the `location` object (injected by [react-router-dom](https://reacttraining.com/react-router/web/api/location)) contains a `record` in its `state`, the `` view uses that `record` instead of the empty object. That's how the `` works under the hood. @@ -433,22 +433,17 @@ That means that if you want to create a link to a creation form, presetting *som {% raw %} ```jsx import * as React from 'react'; -import { Datagrid, useRecordContext } from 'react-admin'; -import { Button } from '@mui/material'; -import { Link } from 'react-router-dom'; +import { CreateButton, Datagrid, useRecordContext } from 'react-admin'; const CreateRelatedCommentButton = () => { const record = useRecordContext(); return ( - + /> ); }; @@ -463,29 +458,22 @@ export default PostList = () => ( ``` {% endraw %} -**Tip**: To style the button with the main color from the Material UI theme, use the `Link` component from the `react-admin` package rather than the one from `react-router-dom`. - **Tip**: The `` component also watches the "source" parameter of `location.search` (the query string in the URL) in addition to `location.state` (a cross-page message hidden in the router memory). So the `CreateRelatedCommentButton` could also be written as: {% raw %} ```jsx import * as React from 'react'; -import { useRecordContext } from 'react-admin'; -import Button from '@mui/material/Button'; -import { Link } from 'react-router-dom'; +import { CreateButton, useRecordContext } from 'react-admin'; const CreateRelatedCommentButton = () => { const record = useRecordContext(); return ( - + /> ); }; ``` From 79cb6b93d7c2dd66315a9692334029f34dcf9e2a Mon Sep 17 00:00:00 2001 From: Matthieu Chaffotte Date: Fri, 22 Sep 2023 11:50:29 +0200 Subject: [PATCH 03/17] feat: ease the usage of the CreateButton --- docs/Create.md | 6 ++---- examples/demo/src/products/CreateRelatedReviewButton.tsx | 4 +--- examples/demo/src/reviews/StarRatingInput.tsx | 8 +------- packages/ra-ui-materialui/src/button/CreateButton.tsx | 7 ++++--- 4 files changed, 8 insertions(+), 17 deletions(-) diff --git a/docs/Create.md b/docs/Create.md index 21d44b7346f..68c643aac6d 100644 --- a/docs/Create.md +++ b/docs/Create.md @@ -439,9 +439,7 @@ const CreateRelatedCommentButton = () => { const record = useRecordContext(); return ( ); @@ -469,8 +467,8 @@ const CreateRelatedCommentButton = () => { const record = useRecordContext(); return ( diff --git a/examples/demo/src/products/CreateRelatedReviewButton.tsx b/examples/demo/src/products/CreateRelatedReviewButton.tsx index e2c5874ece1..1a2d00c98f4 100644 --- a/examples/demo/src/products/CreateRelatedReviewButton.tsx +++ b/examples/demo/src/products/CreateRelatedReviewButton.tsx @@ -6,9 +6,7 @@ const CreateRelatedReviewButton = () => { return ( ); diff --git a/examples/demo/src/reviews/StarRatingInput.tsx b/examples/demo/src/reviews/StarRatingInput.tsx index 121b3563579..3f589e5c7b2 100644 --- a/examples/demo/src/reviews/StarRatingInput.tsx +++ b/examples/demo/src/reviews/StarRatingInput.tsx @@ -17,13 +17,7 @@ const StarRatingInput = (props: InputProps) => { const translate = useTranslate(); return ( - + {translate(name)} { resource: resourceProp, scrollToTop = true, variant, - state = {}, + state: initialState = {}, ...rest } = props; @@ -43,12 +43,13 @@ const CreateButton = (props: CreateButtonProps) => { const isSmall = useMediaQuery((theme: Theme) => theme.breakpoints.down('md') ); + const state = merge(scrollStates[String(scrollToTop)], initialState); return isSmall ? ( { Date: Fri, 22 Sep 2023 14:20:29 +0200 Subject: [PATCH 04/17] feat: fix missing parameter types of the e-commerce demo --- examples/demo/src/reviews/ReviewCreate.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/demo/src/reviews/ReviewCreate.tsx b/examples/demo/src/reviews/ReviewCreate.tsx index c7642d04c64..9dae72bf1dc 100644 --- a/examples/demo/src/reviews/ReviewCreate.tsx +++ b/examples/demo/src/reviews/ReviewCreate.tsx @@ -15,17 +15,17 @@ import { import StarRatingInput from './StarRatingInput'; import { useLocation } from 'react-router'; -const customerOptionRenderer = choice => +const customerOptionRenderer = (choice: any) => `${choice.first_name} ${choice.last_name}`; -const productOptionRenderer = choice => `${choice.reference}`; +const productOptionRenderer = (choice: any) => `${choice.reference}`; const ReviewCreate = () => { const notify = useNotify(); const redirect = useRedirect(); const location = useLocation(); - const onSuccess = data => { + const onSuccess = (_: any) => { const record = getRecordFromLocation(location); notify(`Changes saved`); if (record && record.product_id) { From 828e4098b4b84ea2440e3da0af55cc15b6b753a1 Mon Sep 17 00:00:00 2001 From: Matthieu Chaffotte Date: Mon, 25 Sep 2023 11:10:14 +0200 Subject: [PATCH 05/17] feat: Button does not accept to props by default --- examples/crm/package.json | 2 +- examples/demo/package.json | 2 +- examples/no-code/package.json | 2 +- examples/simple/package.json | 2 +- packages/ra-input-rich-text/package.json | 4 +- packages/ra-no-code/package.json | 2 +- packages/ra-ui-materialui/package.json | 4 +- .../ra-ui-materialui/src/auth/AuthError.tsx | 3 +- .../ra-ui-materialui/src/button/Button.tsx | 54 +-- .../src/button/CloneButton.tsx | 2 +- .../src/button/CreateButton.tsx | 51 ++- .../src/button/ShowButton.tsx | 6 +- packages/react-admin/package.json | 2 +- yarn.lock | 359 ++++++++++++------ 14 files changed, 321 insertions(+), 174 deletions(-) diff --git a/examples/crm/package.json b/examples/crm/package.json index 9d42788d91b..2e1bd5a88a7 100644 --- a/examples/crm/package.json +++ b/examples/crm/package.json @@ -5,7 +5,7 @@ "dependencies": { "@hello-pangea/dnd": "^16.3.0", "@mui/icons-material": "^5.0.1", - "@mui/material": "^5.0.2", + "@mui/material": "^5.14.10", "@nivo/bar": "^0.80.0", "@nivo/core": "^0.80.0", "clsx": "^1.1.1", diff --git a/examples/demo/package.json b/examples/demo/package.json index 31b50cc4f88..5631769bd6c 100644 --- a/examples/demo/package.json +++ b/examples/demo/package.json @@ -5,7 +5,7 @@ "dependencies": { "@apollo/client": "^3.3.19", "@mui/icons-material": "^5.0.1", - "@mui/material": "^5.0.2", + "@mui/material": "^5.14.10", "@types/inflection": "^1.5.28", "@types/recharts": "^1.8.10", "@vitejs/plugin-react": "^2.2.0", diff --git a/examples/no-code/package.json b/examples/no-code/package.json index bee37454663..4edcf7c4704 100644 --- a/examples/no-code/package.json +++ b/examples/no-code/package.json @@ -8,7 +8,7 @@ "serve": "vite preview" }, "dependencies": { - "@mui/material": "^5.0.2", + "@mui/material": "^5.14.10", "ra-data-local-storage": "^4.12.0", "ra-no-code": "^4.12.0", "react": "^17.0.0", diff --git a/examples/simple/package.json b/examples/simple/package.json index e14ea88172c..198e2397893 100644 --- a/examples/simple/package.json +++ b/examples/simple/package.json @@ -12,7 +12,7 @@ "@emotion/react": "^11.7.1", "@emotion/styled": "^11.6.0", "@mui/icons-material": "^5.0.1", - "@mui/material": "^5.0.2", + "@mui/material": "^5.14.10", "jsonexport": "^3.2.0", "lodash": "~4.17.5", "prop-types": "^15.7.2", diff --git a/packages/ra-input-rich-text/package.json b/packages/ra-input-rich-text/package.json index 48dfbfdf909..7f55b826e30 100644 --- a/packages/ra-input-rich-text/package.json +++ b/packages/ra-input-rich-text/package.json @@ -39,7 +39,7 @@ }, "peerDependencies": { "@mui/icons-material": "^5.0.1", - "@mui/material": "^5.0.2", + "@mui/material": "^5.14.10", "ra-core": "^4.0.0", "ra-ui-materialui": "^4.0.0", "react": "^16.9.0 || ^17.0.0 || ^18.0.0", @@ -47,7 +47,7 @@ }, "devDependencies": { "@mui/icons-material": "^5.0.1", - "@mui/material": "^5.0.2", + "@mui/material": "^5.14.10", "@testing-library/react": "^11.2.3", "data-generator-retail": "^4.13.4", "ra-core": "^4.13.4", diff --git a/packages/ra-no-code/package.json b/packages/ra-no-code/package.json index d77ec954e7b..3b405eb1ad9 100644 --- a/packages/ra-no-code/package.json +++ b/packages/ra-no-code/package.json @@ -41,7 +41,7 @@ }, "dependencies": { "@mui/icons-material": "^5.0.1", - "@mui/material": "^5.0.2", + "@mui/material": "^5.14.10", "clsx": "^1.1.1", "date-fns": "^2.19.0", "inflection": "~1.12.0", diff --git a/packages/ra-ui-materialui/package.json b/packages/ra-ui-materialui/package.json index 17c510b76dc..dddac4c34b6 100644 --- a/packages/ra-ui-materialui/package.json +++ b/packages/ra-ui-materialui/package.json @@ -27,7 +27,7 @@ }, "devDependencies": { "@mui/icons-material": "^5.0.1", - "@mui/material": "^5.0.2", + "@mui/material": "^5.14.10", "@testing-library/react": "^11.2.3", "@types/dompurify": "^3.0.2", "cross-env": "^5.2.0", @@ -50,7 +50,7 @@ }, "peerDependencies": { "@mui/icons-material": "^5.0.1", - "@mui/material": "^5.0.2", + "@mui/material": "^5.14.10", "ra-core": "^4.0.0", "react": "^16.9.0 || ^17.0.0 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.0 || ^18.0.0", diff --git a/packages/ra-ui-materialui/src/auth/AuthError.tsx b/packages/ra-ui-materialui/src/auth/AuthError.tsx index fcc9839bdd9..f3a19ff2c28 100644 --- a/packages/ra-ui-materialui/src/auth/AuthError.tsx +++ b/packages/ra-ui-materialui/src/auth/AuthError.tsx @@ -4,6 +4,7 @@ import LockIcon from '@mui/icons-material/Lock'; import PropTypes from 'prop-types'; import { useTranslate } from 'ra-core'; import { Button } from '../button'; +import { Link } from 'react-router-dom'; export const AuthError = (props: AuthErrorProps) => { const { @@ -19,7 +20,7 @@ export const AuthError = (props: AuthErrorProps) => {

{translate(title, { _: title })}

{translate(message, { _: message })}
-
diff --git a/packages/ra-ui-materialui/src/button/Button.tsx b/packages/ra-ui-materialui/src/button/Button.tsx index 188ca8cb569..795233760ee 100644 --- a/packages/ra-ui-materialui/src/button/Button.tsx +++ b/packages/ra-ui-materialui/src/button/Button.tsx @@ -1,6 +1,4 @@ import * as React from 'react'; -import { ReactElement, ElementType } from 'react'; -import PropTypes from 'prop-types'; import { Button as MuiButton, ButtonProps as MuiButtonProps, @@ -9,11 +7,11 @@ import { useMediaQuery, Theme, } from '@mui/material'; +import { PolymorphicProps } from '@mui/base'; + import { styled } from '@mui/material/styles'; +import PropTypes from 'prop-types'; import { useTranslate } from 'ra-core'; -import { Path } from 'react-router'; -import { LinkProps } from 'react-router-dom'; -import { merge } from 'lodash'; /** * A generic Button with side icon. Only the icon is displayed on small screens. @@ -28,7 +26,9 @@ import { merge } from 'lodash'; * * */ -export const Button = (props: ButtonProps) => { +export const Button = ( + props: ButtonProps +) => { const { alignIcon = 'left', children, @@ -37,13 +37,10 @@ export const Button = (props: ButtonProps) => { label, color = 'primary', size = 'small', - to: locationDescriptor, - state = {}, ...rest } = props; const translate = useTranslate(); const translatedLabel = label ? translate(label, { _: label }) : undefined; - const linkParams = merge(getLinkParams(locationDescriptor), { state }); const isXSmall = useMediaQuery((theme: Theme) => theme.breakpoints.down('sm') @@ -58,7 +55,6 @@ export const Button = (props: ButtonProps) => { color={color} size="large" {...rest} - {...linkParams} > {children} @@ -70,7 +66,6 @@ export const Button = (props: ButtonProps) => { disabled={disabled} size="large" {...rest} - {...linkParams} > {children} @@ -85,26 +80,26 @@ export const Button = (props: ButtonProps) => { startIcon={alignIcon === 'left' && children ? children : undefined} endIcon={alignIcon === 'right' && children ? children : undefined} {...rest} - {...linkParams} > {translatedLabel}
); }; -interface Props { +interface Props { alignIcon?: 'left' | 'right'; - children?: ReactElement; + children?: React.ReactElement; className?: string; - component?: ElementType; - to?: string | LocationDescriptor; + component?: RootComponent; disabled?: boolean; label?: string; size?: 'small' | 'medium' | 'large'; variant?: string; } -export type ButtonProps = Props & Partial & MuiButtonProps; +export type ButtonProps< + RootComponent extends React.ElementType = 'button' +> = Props & MuiButtonProps; Button.propTypes = { alignIcon: PropTypes.oneOf(['left', 'right']), @@ -139,28 +134,3 @@ const StyledButton = styled(MuiButton, { lineHeight: 1.5, }, }); - -const getLinkParams = (locationDescriptor?: LocationDescriptor | string) => { - // eslint-disable-next-line eqeqeq - if (locationDescriptor == undefined) { - return undefined; - } - - if (typeof locationDescriptor === 'string') { - return { to: locationDescriptor }; - } - - const { redirect, replace, state, ...to } = locationDescriptor; - return { - to, - redirect, - replace, - state, - }; -}; - -export type LocationDescriptor = Partial & { - redirect?: boolean; - state?: any; - replace?: boolean; -}; diff --git a/packages/ra-ui-materialui/src/button/CloneButton.tsx b/packages/ra-ui-materialui/src/button/CloneButton.tsx index fd68c75ade9..68d8d3d4613 100644 --- a/packages/ra-ui-materialui/src/button/CloneButton.tsx +++ b/packages/ra-ui-materialui/src/button/CloneButton.tsx @@ -61,7 +61,7 @@ interface Props { scrollToTop?: boolean; } -export type CloneButtonProps = Props & ButtonProps; +export type CloneButtonProps = Props & ButtonProps; CloneButton.propTypes = { icon: PropTypes.element, diff --git a/packages/ra-ui-materialui/src/button/CreateButton.tsx b/packages/ra-ui-materialui/src/button/CreateButton.tsx index e1a8033e000..29d3818b449 100644 --- a/packages/ra-ui-materialui/src/button/CreateButton.tsx +++ b/packages/ra-ui-materialui/src/button/CreateButton.tsx @@ -1,14 +1,14 @@ import * as React from 'react'; -import { styled } from '@mui/material/styles'; -import { ReactElement, memo } from 'react'; -import PropTypes from 'prop-types'; -import { Fab, useMediaQuery, Theme } from '@mui/material'; import ContentAdd from '@mui/icons-material/Add'; +import { Fab, useMediaQuery, Theme } from '@mui/material'; +import { styled } from '@mui/material/styles'; import clsx from 'clsx'; -import { Link } from 'react-router-dom'; -import { useTranslate, useResourceContext, useCreatePath } from 'ra-core'; import isEqual from 'lodash/isEqual'; import merge from 'lodash/merge'; +import PropTypes from 'prop-types'; +import { useTranslate, useResourceContext, useCreatePath } from 'ra-core'; +import { Path } from 'react-router'; +import { Link } from 'react-router-dom'; import { Button, ButtonProps } from './Button'; @@ -33,6 +33,7 @@ const CreateButton = (props: CreateButtonProps) => { resource: resourceProp, scrollToTop = true, variant, + to: locationDescriptor, state: initialState = {}, ...rest } = props; @@ -43,7 +44,11 @@ const CreateButton = (props: CreateButtonProps) => { const isSmall = useMediaQuery((theme: Theme) => theme.breakpoints.down('md') ); - const state = merge(scrollStates[String(scrollToTop)], initialState); + const state = merge( + scrollStates[String(scrollToTop)], + getLinkParams(locationDescriptor), + initialState + ); return isSmall ? ( ; interface Props { resource?: string; - icon?: ReactElement; + icon?: React.ReactElement; scrollToTop?: boolean; + to?: string | LocationDescriptor; } -export type CreateButtonProps = Props & ButtonProps; +export type LocationDescriptor = Partial & { + redirect?: boolean; + state?: any; + replace?: boolean; +}; + +export type CreateButtonProps = Props & ButtonProps; CreateButton.propTypes = { resource: PropTypes.string, @@ -124,7 +136,7 @@ const StyledButton = styled(Button, { overridesResolver: (_props, styles) => styles.root, })({}); -export default memo(CreateButton, (prevProps, nextProps) => { +export default React.memo(CreateButton, (prevProps, nextProps) => { return ( prevProps.resource === nextProps.resource && prevProps.label === nextProps.label && @@ -133,3 +145,22 @@ export default memo(CreateButton, (prevProps, nextProps) => { isEqual(prevProps.to, nextProps.to) ); }); + +const getLinkParams = (locationDescriptor?: LocationDescriptor | string) => { + // eslint-disable-next-line eqeqeq + if (locationDescriptor == undefined) { + return undefined; + } + + if (typeof locationDescriptor === 'string') { + return { to: locationDescriptor }; + } + + const { redirect, replace, state, ...to } = locationDescriptor; + return { + to, + redirect, + replace, + state, + }; +}; diff --git a/packages/ra-ui-materialui/src/button/ShowButton.tsx b/packages/ra-ui-materialui/src/button/ShowButton.tsx index 6f85a1dc2aa..5303d67cb5d 100644 --- a/packages/ra-ui-materialui/src/button/ShowButton.tsx +++ b/packages/ra-ui-materialui/src/button/ShowButton.tsx @@ -9,7 +9,6 @@ import { useRecordContext, useCreatePath, } from 'ra-core'; -import isEqual from 'lodash/isEqual'; import { Button, ButtonProps } from './Button'; @@ -77,7 +76,7 @@ interface Props { export type ShowButtonProps = Props< RecordType > & - ButtonProps; + ButtonProps; ShowButton.propTypes = { icon: PropTypes.element, @@ -94,8 +93,7 @@ const PureShowButton = memo( ? prevProps.record.id === nextProps.record.id : prevProps.record == nextProps.record) && // eslint-disable-line eqeqeq prevProps.label === nextProps.label && - prevProps.disabled === nextProps.disabled && - isEqual(prevProps.to, nextProps.to) + prevProps.disabled === nextProps.disabled ); export default PureShowButton; diff --git a/packages/react-admin/package.json b/packages/react-admin/package.json index c075ee07f72..af87819638c 100644 --- a/packages/react-admin/package.json +++ b/packages/react-admin/package.json @@ -39,7 +39,7 @@ "@emotion/react": "^11.4.1", "@emotion/styled": "^11.3.0", "@mui/icons-material": "^5.0.1", - "@mui/material": "^5.0.2", + "@mui/material": "^5.14.10", "history": "^5.1.0", "ra-core": "^4.13.4", "ra-i18n-polyglot": "^4.13.4", diff --git a/yarn.lock b/yarn.lock index 2fdc52a7b76..d1c898fe2a6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1816,6 +1816,15 @@ __metadata: languageName: node linkType: hard +"@babel/runtime@npm:^7.22.15": + version: 7.23.1 + resolution: "@babel/runtime@npm:7.23.1" + dependencies: + regenerator-runtime: ^0.14.0 + checksum: e57ab1436d4845efe67c3f76d578508bb584173690ecfeac105bc4e09d64b2aa6a53c1e03bca3c97cc238e5390a804e5a4ded211e6350243b735905ca45a4822 + languageName: node + linkType: hard + "@babel/template@npm:^7.16.7, @babel/template@npm:^7.22.5": version: 7.22.5 resolution: "@babel/template@npm:7.22.5" @@ -1975,6 +1984,19 @@ __metadata: languageName: node linkType: hard +"@emotion/cache@npm:^11.11.0": + version: 11.11.0 + resolution: "@emotion/cache@npm:11.11.0" + dependencies: + "@emotion/memoize": ^0.8.1 + "@emotion/sheet": ^1.2.2 + "@emotion/utils": ^1.2.1 + "@emotion/weak-memoize": ^0.3.1 + stylis: 4.2.0 + checksum: a23ab5ab2fd08e904698106d58ad3536fed51cc1aa0ef228e95bb640eaf11f560dbd91a395477b0d84e1e3c20150263764b4558517cf6576a89d2d6cc5253688 + languageName: node + linkType: hard + "@emotion/cache@npm:^11.7.1": version: 11.7.1 resolution: "@emotion/cache@npm:11.7.1" @@ -2011,6 +2033,13 @@ __metadata: languageName: node linkType: hard +"@emotion/memoize@npm:^0.8.1": + version: 0.8.1 + resolution: "@emotion/memoize@npm:0.8.1" + checksum: dffed372fc3b9fa2ba411e76af22b6bb686fb0cb07694fdfaa6dd2baeb0d5e4968c1a7caa472bfcf06a5997d5e7c7d16b90e993f9a6ffae79a2c3dbdc76dfe78 + languageName: node + linkType: hard + "@emotion/react@npm:^11.1.5, @emotion/react@npm:^11.4.1, @emotion/react@npm:^11.7.1": version: 11.7.1 resolution: "@emotion/react@npm:11.7.1" @@ -2054,6 +2083,13 @@ __metadata: languageName: node linkType: hard +"@emotion/sheet@npm:^1.2.2": + version: 1.2.2 + resolution: "@emotion/sheet@npm:1.2.2" + checksum: 69827a1bfa43d7b188f1d8cea42163143a36312543fdade5257c459a2b3efd7ce386aac84ba152bc2517a4f7e54384c04800b26adb382bb284ac7e4ad40e584b + languageName: node + linkType: hard + "@emotion/styled@npm:^11.3.0, @emotion/styled@npm:^11.6.0": version: 11.6.0 resolution: "@emotion/styled@npm:11.6.0" @@ -2099,6 +2135,13 @@ __metadata: languageName: node linkType: hard +"@emotion/utils@npm:^1.2.1": + version: 1.2.1 + resolution: "@emotion/utils@npm:1.2.1" + checksum: db43ca803361740c14dfb1cca1464d10d27f4c8b40d3e8864e6932ccf375d1450778ff4e4eadee03fb97f2aeb18de9fae98294905596a12ff7d4cd1910414d8d + languageName: node + linkType: hard + "@emotion/weak-memoize@npm:^0.2.5": version: 0.2.5 resolution: "@emotion/weak-memoize@npm:0.2.5" @@ -2106,6 +2149,13 @@ __metadata: languageName: node linkType: hard +"@emotion/weak-memoize@npm:^0.3.1": + version: 0.3.1 + resolution: "@emotion/weak-memoize@npm:0.3.1" + checksum: ed514b3cb94bbacece4ac2450d98898066c0a0698bdeda256e312405ca53634cb83c75889b25cd8bbbe185c80f4c05a1f0a0091e1875460ba6be61d0334f0b8a + languageName: node + linkType: hard + "@esbuild/android-arm64@npm:0.17.19": version: 0.17.19 resolution: "@esbuild/android-arm64@npm:0.17.19" @@ -2302,6 +2352,44 @@ __metadata: languageName: node linkType: hard +"@floating-ui/core@npm:^1.4.2": + version: 1.5.0 + resolution: "@floating-ui/core@npm:1.5.0" + dependencies: + "@floating-ui/utils": ^0.1.3 + checksum: bca811cefd09c3f56c4cf58c3e94826c1ce4a0b40124e9030ddca2ef1cc68b4ddc5ba5b4d7cc94c9555aea6876d2428a77a2ae261fe5b39c79df247a9518b053 + languageName: node + linkType: hard + +"@floating-ui/dom@npm:^1.5.1": + version: 1.5.3 + resolution: "@floating-ui/dom@npm:1.5.3" + dependencies: + "@floating-ui/core": ^1.4.2 + "@floating-ui/utils": ^0.1.3 + checksum: e5f30b911f939e40003851077bba441f269ae689bdc43c674bee43aa98fc6b7a5f59be432d27b7be599b1e4ab7b15c752875ea777a89cff01d157e593b78b25b + languageName: node + linkType: hard + +"@floating-ui/react-dom@npm:^2.0.2": + version: 2.0.2 + resolution: "@floating-ui/react-dom@npm:2.0.2" + dependencies: + "@floating-ui/dom": ^1.5.1 + peerDependencies: + react: ">=16.8.0" + react-dom: ">=16.8.0" + checksum: bfd07cfc9047a31e92e223dbbe48f2cdb75460126217b35cfbf8555eaf1718ce7c11f4ee4d39bdee89eaf9ad0a5c4dd9af443a552116fc3478a19a9f6283bdf6 + languageName: node + linkType: hard + +"@floating-ui/utils@npm:^0.1.3": + version: 0.1.4 + resolution: "@floating-ui/utils@npm:0.1.4" + checksum: 1183890f1f9868e4a0d300d0496bd204b3277a882c233455033fcba81a715ecbe4535b80bacbf3f7c2d82e7a63136bcccdc10fff297ce07086146afad73b15a0 + languageName: node + linkType: hard + "@gar/promisify@npm:^1.0.1, @gar/promisify@npm:^1.1.3": version: 1.1.3 resolution: "@gar/promisify@npm:1.1.3" @@ -2877,25 +2965,32 @@ __metadata: languageName: node linkType: hard -"@mui/base@npm:5.0.0-alpha.64": - version: 5.0.0-alpha.64 - resolution: "@mui/base@npm:5.0.0-alpha.64" +"@mui/base@npm:5.0.0-beta.16": + version: 5.0.0-beta.16 + resolution: "@mui/base@npm:5.0.0-beta.16" dependencies: - "@babel/runtime": ^7.16.3 - "@emotion/is-prop-valid": ^1.1.1 - "@mui/utils": ^5.2.3 - "@popperjs/core": ^2.4.4 - clsx: ^1.1.1 - prop-types: ^15.7.2 - react-is: ^17.0.2 + "@babel/runtime": ^7.22.15 + "@floating-ui/react-dom": ^2.0.2 + "@mui/types": ^7.2.4 + "@mui/utils": ^5.14.10 + "@popperjs/core": ^2.11.8 + clsx: ^2.0.0 + prop-types: ^15.8.1 peerDependencies: - "@types/react": ^16.8.6 || ^17.0.0 - react: ^17.0.2 - react-dom: ^17.0.2 + "@types/react": ^17.0.0 || ^18.0.0 + react: ^17.0.0 || ^18.0.0 + react-dom: ^17.0.0 || ^18.0.0 peerDependenciesMeta: "@types/react": optional: true - checksum: 5e91036773ecdef831cc1c196843208e19349aba0937d349ef7b53707db5581384609f929b600828610bf7f05964a6dab3d240ab85975ab16f9b6617faadcd60 + checksum: 035cdb9bba59394d2f937d3f17a0a5d5121a269542129cc99f5b82e4e773d5b31dc6b7fbe1fcacf8b744ff7a8ad9640fb30c27e283f89770f802147fd9d50962 + languageName: node + linkType: hard + +"@mui/core-downloads-tracker@npm:^5.14.10": + version: 5.14.10 + resolution: "@mui/core-downloads-tracker@npm:5.14.10" + checksum: 165751152a5fa490cee7d5919030e12a489c4e23ba253ecd14d78dcda07fea49d715ee656976854716f95d37fd89fa68f34e115f73e6bfed872bd1ba153ecd31 languageName: node linkType: hard @@ -2915,28 +3010,28 @@ __metadata: languageName: node linkType: hard -"@mui/material@npm:^5.0.2": - version: 5.2.8 - resolution: "@mui/material@npm:5.2.8" +"@mui/material@npm:^5.14.10": + version: 5.14.10 + resolution: "@mui/material@npm:5.14.10" dependencies: - "@babel/runtime": ^7.16.3 - "@mui/base": 5.0.0-alpha.64 - "@mui/system": ^5.2.8 - "@mui/types": ^7.1.0 - "@mui/utils": ^5.2.3 - "@types/react-transition-group": ^4.4.4 - clsx: ^1.1.1 - csstype: ^3.0.10 - hoist-non-react-statics: ^3.3.2 - prop-types: ^15.7.2 - react-is: ^17.0.2 - react-transition-group: ^4.4.2 + "@babel/runtime": ^7.22.15 + "@mui/base": 5.0.0-beta.16 + "@mui/core-downloads-tracker": ^5.14.10 + "@mui/system": ^5.14.10 + "@mui/types": ^7.2.4 + "@mui/utils": ^5.14.10 + "@types/react-transition-group": ^4.4.6 + clsx: ^2.0.0 + csstype: ^3.1.2 + prop-types: ^15.8.1 + react-is: ^18.2.0 + react-transition-group: ^4.4.5 peerDependencies: "@emotion/react": ^11.5.0 "@emotion/styled": ^11.3.0 - "@types/react": ^16.8.6 || ^17.0.0 - react: ^17.0.2 - react-dom: ^17.0.2 + "@types/react": ^17.0.0 || ^18.0.0 + react: ^17.0.0 || ^18.0.0 + react-dom: ^17.0.0 || ^18.0.0 peerDependenciesMeta: "@emotion/react": optional: true @@ -2944,64 +3039,65 @@ __metadata: optional: true "@types/react": optional: true - checksum: eceb56f752e114aaa53c41c8c1f5fed88f3df8a1fbdd62de8d19131faf1dc5b64b04c5631a1a77468ae928abe11450b866b13647d29dc2d9ceccc4f225c16832 + checksum: 82500d343c71ae22f8e9bfe5632cdf71092d15502574f20c42d44c33828f87dbb864be84f31d0dadc0f304d70fc8854581e2b4779b23cd2d753208e497acfc3d languageName: node linkType: hard -"@mui/private-theming@npm:^5.2.3": - version: 5.2.3 - resolution: "@mui/private-theming@npm:5.2.3" +"@mui/private-theming@npm:^5.14.10": + version: 5.14.10 + resolution: "@mui/private-theming@npm:5.14.10" dependencies: - "@babel/runtime": ^7.16.3 - "@mui/utils": ^5.2.3 - prop-types: ^15.7.2 + "@babel/runtime": ^7.22.15 + "@mui/utils": ^5.14.10 + prop-types: ^15.8.1 peerDependencies: - "@types/react": ^16.8.6 || ^17.0.0 - react: ^17.0.2 + "@types/react": ^17.0.0 || ^18.0.0 + react: ^17.0.0 || ^18.0.0 peerDependenciesMeta: "@types/react": optional: true - checksum: 477da8719479c9b1223adf04e195db9845be6201041e9eea98f670e2baea1ad1651edf778ed4f7ff0aa5bb5444970150d52afe21d3762ad6d39d327504bcd46e + checksum: 0ef27687f575f09d8167db5dbc6bda0a0e19d603a3d00c8ff9d3f2544e5c55292b01be0317782640e0072bb19916015920c01e693bd36bd28068775a05a54b6d languageName: node linkType: hard -"@mui/styled-engine@npm:^5.2.6": - version: 5.2.6 - resolution: "@mui/styled-engine@npm:5.2.6" +"@mui/styled-engine@npm:^5.14.10": + version: 5.14.10 + resolution: "@mui/styled-engine@npm:5.14.10" dependencies: - "@babel/runtime": ^7.16.3 - "@emotion/cache": ^11.7.1 - prop-types: ^15.7.2 + "@babel/runtime": ^7.22.15 + "@emotion/cache": ^11.11.0 + csstype: ^3.1.2 + prop-types: ^15.8.1 peerDependencies: "@emotion/react": ^11.4.1 "@emotion/styled": ^11.3.0 - react: ^17.0.2 + react: ^17.0.0 || ^18.0.0 peerDependenciesMeta: "@emotion/react": optional: true "@emotion/styled": optional: true - checksum: 8fad62e312643ac3cb7bcdabf1b0164f05da71585b85b1d7a38ed27f22c834d54a0e225319796beaf7244820915faecfbd2242944bcdb821a53502c146c8e279 + checksum: 0f7184abfc81ed7a82c2256d3bab3efdf202d4e761e4cd98e67bafc7fe7d96176a6cac3c54b156fc4e161ca830294356eef28970f584b62c1a4d6ec3d6256dfe languageName: node linkType: hard -"@mui/system@npm:^5.2.8": - version: 5.2.8 - resolution: "@mui/system@npm:5.2.8" +"@mui/system@npm:^5.14.10": + version: 5.14.10 + resolution: "@mui/system@npm:5.14.10" dependencies: - "@babel/runtime": ^7.16.3 - "@mui/private-theming": ^5.2.3 - "@mui/styled-engine": ^5.2.6 - "@mui/types": ^7.1.0 - "@mui/utils": ^5.2.3 - clsx: ^1.1.1 - csstype: ^3.0.10 - prop-types: ^15.7.2 + "@babel/runtime": ^7.22.15 + "@mui/private-theming": ^5.14.10 + "@mui/styled-engine": ^5.14.10 + "@mui/types": ^7.2.4 + "@mui/utils": ^5.14.10 + clsx: ^2.0.0 + csstype: ^3.1.2 + prop-types: ^15.8.1 peerDependencies: "@emotion/react": ^11.5.0 "@emotion/styled": ^11.3.0 - "@types/react": ^16.8.6 || ^17.0.0 - react: ^17.0.2 + "@types/react": ^17.0.0 || ^18.0.0 + react: ^17.0.0 || ^18.0.0 peerDependenciesMeta: "@emotion/react": optional: true @@ -3009,34 +3105,37 @@ __metadata: optional: true "@types/react": optional: true - checksum: 72fab31a8071fd3fabb5c90087b8cadf8655cd16d70a8578911173409a0e4ee10564f9fb51e351dbfbb503ec1d5f51958906250869abb458ac2ce6609ced426d + checksum: daf86070f786dbb70b997b0dbe11485634407bb60b18219d2929649e92486f9097c3c17d658ca3cd266d5708b658fc8bead6d6b53d63995c25bf76445d3d4919 languageName: node linkType: hard -"@mui/types@npm:^7.1.0": - version: 7.1.0 - resolution: "@mui/types@npm:7.1.0" +"@mui/types@npm:^7.2.4": + version: 7.2.4 + resolution: "@mui/types@npm:7.2.4" peerDependencies: "@types/react": "*" peerDependenciesMeta: "@types/react": optional: true - checksum: 0027e0092cc4674d971c1218dea6d6ec33c8f98ede0fb793e5bcec27c9d8897343adc2d8e45704ab54841c6792ff9c5df7601ad968da58123551d48c3faa307f + checksum: 17411effd184eff34d6a1a55b2249c7e1ef195bb30c48154f0b16fdce428ff55be4ec5dde8b4a556c01eda2d34e3dcc18d925f8fdee606f5bc15f91167f0ecbc languageName: node linkType: hard -"@mui/utils@npm:^5.2.3": - version: 5.2.3 - resolution: "@mui/utils@npm:5.2.3" +"@mui/utils@npm:^5.14.10": + version: 5.14.10 + resolution: "@mui/utils@npm:5.14.10" dependencies: - "@babel/runtime": ^7.16.3 - "@types/prop-types": ^15.7.4 - "@types/react-is": ^16.7.1 || ^17.0.0 - prop-types: ^15.7.2 - react-is: ^17.0.2 + "@babel/runtime": ^7.22.15 + "@types/prop-types": ^15.7.5 + prop-types: ^15.8.1 + react-is: ^18.2.0 peerDependencies: - react: ^17.0.2 - checksum: 0a8f52dbb8f4f2b6d743c5d419907d6bfcea8648a5b65fefc3ff96f0dc967448867357057c127cb746a762a226c2b1d79481bfc45896ad997a41d75a25a111d2 + "@types/react": ^17.0.0 || ^18.0.0 + react: ^17.0.0 || ^18.0.0 + peerDependenciesMeta: + "@types/react": + optional: true + checksum: fb778e1a5fb97920b9457667d910f6055bb0a22bec26f011b4e269e9646e46f6c4800e00b80feab8f8ec79242afd4c342437671a0389b6ac807e14a32338dd24 languageName: node linkType: hard @@ -3651,7 +3750,14 @@ __metadata: languageName: node linkType: hard -"@popperjs/core@npm:^2.4.4, @popperjs/core@npm:^2.9.0": +"@popperjs/core@npm:^2.11.8": + version: 2.11.8 + resolution: "@popperjs/core@npm:2.11.8" + checksum: 4681e682abc006d25eb380d0cf3efc7557043f53b6aea7a5057d0d1e7df849a00e281cd8ea79c902a35a414d7919621fc2ba293ecec05f413598e0b23d5a1e63 + languageName: node + linkType: hard + +"@popperjs/core@npm:^2.9.0": version: 2.11.2 resolution: "@popperjs/core@npm:2.11.2" checksum: b06f65fcef9dbfe7487fd53e38f12684267e91c8bc667a6c9621c207f42ee97d48059039ee8dae0327df509234b6f09bf5b940b34b71ee453d307f53d84e99b2 @@ -5996,13 +6102,20 @@ __metadata: languageName: node linkType: hard -"@types/prop-types@npm:*, @types/prop-types@npm:^15.6.0, @types/prop-types@npm:^15.7.4": +"@types/prop-types@npm:*, @types/prop-types@npm:^15.6.0": version: 15.7.4 resolution: "@types/prop-types@npm:15.7.4" checksum: 014bb826592fab01499931259969aafc21d5a8ff4ece3e3fb8e2b5186bed17656f7dcdccf9a98c27fee74d7d0697aa3f53ea971a72679597f0ca0c3d5ca585d3 languageName: node linkType: hard +"@types/prop-types@npm:^15.7.5": + version: 15.7.7 + resolution: "@types/prop-types@npm:15.7.7" + checksum: 26d565ebae8c28dede71547d687367ce74eeccc645fdbef2d38478fe293996be24784fa6190586ba303ccd274aa94d8a631d36a5d9b8e0c08f5647ff3244d72c + languageName: node + linkType: hard + "@types/qs@npm:*, @types/qs@npm:^6.9.5": version: 6.9.7 resolution: "@types/qs@npm:6.9.7" @@ -6035,15 +6148,6 @@ __metadata: languageName: node linkType: hard -"@types/react-is@npm:^16.7.1 || ^17.0.0": - version: 17.0.3 - resolution: "@types/react-is@npm:17.0.3" - dependencies: - "@types/react": "*" - checksum: 839382b66b2b2e3023647f5ba0c382ddc6aa01c1bc9f64608f82bbc871a905ba9b988838619914d8348c2a511717c6bd3701cb866bb9e4abfabdbe544efb695b - languageName: node - linkType: hard - "@types/react-test-renderer@npm:>=16.9.0": version: 17.0.1 resolution: "@types/react-test-renderer@npm:17.0.1" @@ -6053,12 +6157,12 @@ __metadata: languageName: node linkType: hard -"@types/react-transition-group@npm:^4.4.4": - version: 4.4.4 - resolution: "@types/react-transition-group@npm:4.4.4" +"@types/react-transition-group@npm:^4.4.6": + version: 4.4.6 + resolution: "@types/react-transition-group@npm:4.4.6" dependencies: "@types/react": "*" - checksum: 0e593863c60550002bb7a5bf60dad719de78580017f87eadf32661d1870345a4ef22e2e37902e05d05955494f2c0cae5ef46510032005e8e969273eee0ae8519 + checksum: 154dc4e94738cff0b2fa183331427c0de3d8daac44a9b79c27aa8a95b78adde44b9f70db8a374399eabe1d44ca50304b1d7bbaeadca0fbdf6f2a91f6f9eb343d languageName: node linkType: hard @@ -8643,6 +8747,13 @@ __metadata: languageName: node linkType: hard +"clsx@npm:^2.0.0": + version: 2.0.0 + resolution: "clsx@npm:2.0.0" + checksum: c09f43b3144a0b7826b6b11b6a111b2c7440831004eecc02d333533c5e58ef0aa5f2dce071d3b25fbb8c8ea97b45df96c74bcc1d51c8c2027eb981931107b0cd + languageName: node + linkType: hard + "cmd-shim@npm:6.0.1": version: 6.0.1 resolution: "cmd-shim@npm:6.0.1" @@ -9389,13 +9500,20 @@ __metadata: languageName: node linkType: hard -"csstype@npm:^3.0.10, csstype@npm:^3.0.2": +"csstype@npm:^3.0.2": version: 3.0.10 resolution: "csstype@npm:3.0.10" checksum: f0fff671ab368a863946859ad96be0be66afeb83566215d6494be840ffedfaef4945b48d1b0ce1a19f9983af772e0ce38c7be91a1ad46fe7ecd641937c5a99f7 languageName: node linkType: hard +"csstype@npm:^3.1.2": + version: 3.1.2 + resolution: "csstype@npm:3.1.2" + checksum: 32c038af259897c807ac738d9eab16b3d86747c72b09d5c740978e06f067f9b7b1737e1b75e407c7ab1fe1543dc95f20e202b4786aeb1b8d3bdf5d5ce655e6c6 + languageName: node + linkType: hard + "cypress-plugin-tab@npm:^1.0.5": version: 1.0.5 resolution: "cypress-plugin-tab@npm:1.0.5" @@ -9832,7 +9950,7 @@ __metadata: dependencies: "@apollo/client": ^3.3.19 "@mui/icons-material": ^5.0.1 - "@mui/material": ^5.0.2 + "@mui/material": ^5.14.10 "@types/fetch-mock": ^7.3.2 "@types/inflection": ^1.5.28 "@types/jest": ^29.5.2 @@ -16197,7 +16315,7 @@ __metadata: version: 0.0.0-use.local resolution: "no-code@workspace:examples/no-code" dependencies: - "@mui/material": ^5.0.2 + "@mui/material": ^5.14.10 "@vitejs/plugin-react": ^2.2.0 ra-data-local-storage: ^4.12.0 ra-no-code: ^4.12.0 @@ -18378,7 +18496,7 @@ __metadata: resolution: "ra-input-rich-text@workspace:packages/ra-input-rich-text" dependencies: "@mui/icons-material": ^5.0.1 - "@mui/material": ^5.0.2 + "@mui/material": ^5.14.10 "@testing-library/react": ^11.2.3 "@tiptap/core": ^2.0.3 "@tiptap/extension-color": ^2.0.3 @@ -18404,7 +18522,7 @@ __metadata: typescript: ^5.1.3 peerDependencies: "@mui/icons-material": ^5.0.1 - "@mui/material": ^5.0.2 + "@mui/material": ^5.14.10 ra-core: ^4.0.0 ra-ui-materialui: ^4.0.0 react: ^16.9.0 || ^17.0.0 || ^18.0.0 @@ -18437,7 +18555,7 @@ __metadata: resolution: "ra-no-code@workspace:packages/ra-no-code" dependencies: "@mui/icons-material": ^5.0.1 - "@mui/material": ^5.0.2 + "@mui/material": ^5.14.10 "@testing-library/react": ^11.2.3 "@testing-library/user-event": ^13.1.5 clsx: ^1.1.1 @@ -18468,7 +18586,7 @@ __metadata: resolution: "ra-ui-materialui@workspace:packages/ra-ui-materialui" dependencies: "@mui/icons-material": ^5.0.1 - "@mui/material": ^5.0.2 + "@mui/material": ^5.14.10 "@testing-library/react": ^11.2.3 "@types/dompurify": ^3.0.2 autosuggest-highlight: ^3.1.1 @@ -18504,7 +18622,7 @@ __metadata: typescript: ^5.1.3 peerDependencies: "@mui/icons-material": ^5.0.1 - "@mui/material": ^5.0.2 + "@mui/material": ^5.14.10 ra-core: ^4.0.0 react: ^16.9.0 || ^17.0.0 || ^18.0.0 react-dom: ^16.9.0 || ^17.0.0 || ^18.0.0 @@ -18596,7 +18714,7 @@ __metadata: dependencies: "@hello-pangea/dnd": ^16.3.0 "@mui/icons-material": ^5.0.1 - "@mui/material": ^5.0.2 + "@mui/material": ^5.14.10 "@nivo/bar": ^0.80.0 "@nivo/core": ^0.80.0 "@testing-library/jest-dom": ^5.11.4 @@ -18684,7 +18802,7 @@ __metadata: "@emotion/react": ^11.4.1 "@emotion/styled": ^11.3.0 "@mui/icons-material": ^5.0.1 - "@mui/material": ^5.0.2 + "@mui/material": ^5.14.10 cross-env: ^5.2.0 expect: ^27.4.6 history: ^5.1.0 @@ -18882,7 +19000,7 @@ __metadata: languageName: node linkType: hard -"react-is@npm:^18.0.0": +"react-is@npm:^18.0.0, react-is@npm:^18.2.0": version: 18.2.0 resolution: "react-is@npm:18.2.0" checksum: 6eb5e4b28028c23e2bfcf73371e72cd4162e4ac7ab445ddae2afe24e347a37d6dc22fae6e1748632cd43c6d4f9b8f86dcf26bf9275e1874f436d129952528ae0 @@ -19103,7 +19221,7 @@ __metadata: languageName: node linkType: hard -"react-transition-group@npm:^4.4.1, react-transition-group@npm:^4.4.2": +"react-transition-group@npm:^4.4.1": version: 4.4.2 resolution: "react-transition-group@npm:4.4.2" dependencies: @@ -19118,6 +19236,21 @@ __metadata: languageName: node linkType: hard +"react-transition-group@npm:^4.4.5": + version: 4.4.5 + resolution: "react-transition-group@npm:4.4.5" + dependencies: + "@babel/runtime": ^7.5.5 + dom-helpers: ^5.0.1 + loose-envify: ^1.4.0 + prop-types: ^15.6.2 + peerDependencies: + react: ">=16.6.0" + react-dom: ">=16.6.0" + checksum: 2ba754ba748faefa15f87c96dfa700d5525054a0141de8c75763aae6734af0740e77e11261a1e8f4ffc08fd9ab78510122e05c21c2d79066c38bb6861a886c82 + languageName: node + linkType: hard + "react@npm:^17.0.0": version: 17.0.2 resolution: "react@npm:17.0.2" @@ -19426,6 +19559,13 @@ __metadata: languageName: node linkType: hard +"regenerator-runtime@npm:^0.14.0": + version: 0.14.0 + resolution: "regenerator-runtime@npm:0.14.0" + checksum: e25f062c1a183f81c99681691a342760e65c55e8d3a4d4fe347ebe72433b123754b942b70b622959894e11f8a9131dc549bd3c9a5234677db06a4af42add8d12 + languageName: node + linkType: hard + "regenerator-transform@npm:^0.15.1": version: 0.15.1 resolution: "regenerator-transform@npm:0.15.1" @@ -20293,7 +20433,7 @@ __metadata: "@emotion/styled": ^11.6.0 "@hookform/devtools": ^4.0.2 "@mui/icons-material": ^5.0.1 - "@mui/material": ^5.0.2 + "@mui/material": ^5.14.10 "@vitejs/plugin-react": ^2.2.0 jsonexport: ^3.2.0 lodash: ~4.17.5 @@ -20931,6 +21071,13 @@ __metadata: languageName: node linkType: hard +"stylis@npm:4.2.0": + version: 4.2.0 + resolution: "stylis@npm:4.2.0" + checksum: a7128ad5a8ed72652c6eba46bed4f416521bc9745a460ef5741edc725252cebf36ee45e33a8615a7057403c93df0866ab9ee955960792db210bb80abd5ac6543 + languageName: node + linkType: hard + "supports-color@npm:^5.3.0": version: 5.5.0 resolution: "supports-color@npm:5.5.0" From 7436f56ed8f3bd806883e179625a0d73863e56f2 Mon Sep 17 00:00:00 2001 From: Gildas Garcia <1122076+djhi@users.noreply.github.com> Date: Tue, 26 Sep 2023 10:07:25 +0200 Subject: [PATCH 06/17] Fix build --- packages/ra-core/package.json | 1 + packages/ra-ui-materialui/src/button/CreateButton.tsx | 2 +- packages/ra-ui-materialui/src/button/ShowButton.tsx | 2 +- yarn.lock | 10 ++++++++++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/ra-core/package.json b/packages/ra-core/package.json index f89495e1e21..09e2919bf30 100644 --- a/packages/ra-core/package.json +++ b/packages/ra-core/package.json @@ -33,6 +33,7 @@ "@types/node": "^17.0.8", "@types/node-polyglot": "^0.4.31", "@types/react": "^17.0.20", + "@types/react-is": "^18.2.1", "cross-env": "^5.2.0", "expect": "^27.4.6", "history": "^5.1.0", diff --git a/packages/ra-ui-materialui/src/button/CreateButton.tsx b/packages/ra-ui-materialui/src/button/CreateButton.tsx index 29d3818b449..004f8f3aad8 100644 --- a/packages/ra-ui-materialui/src/button/CreateButton.tsx +++ b/packages/ra-ui-materialui/src/button/CreateButton.tsx @@ -99,7 +99,7 @@ export type LocationDescriptor = Partial & { replace?: boolean; }; -export type CreateButtonProps = Props & ButtonProps; +export type CreateButtonProps = Props & Omit, 'to'>; CreateButton.propTypes = { resource: PropTypes.string, diff --git a/packages/ra-ui-materialui/src/button/ShowButton.tsx b/packages/ra-ui-materialui/src/button/ShowButton.tsx index 5303d67cb5d..02b87265426 100644 --- a/packages/ra-ui-materialui/src/button/ShowButton.tsx +++ b/packages/ra-ui-materialui/src/button/ShowButton.tsx @@ -76,7 +76,7 @@ interface Props { export type ShowButtonProps = Props< RecordType > & - ButtonProps; + Omit, 'to'>; ShowButton.propTypes = { icon: PropTypes.element, diff --git a/yarn.lock b/yarn.lock index d1c898fe2a6..2c1bbae2900 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6148,6 +6148,15 @@ __metadata: languageName: node linkType: hard +"@types/react-is@npm:^18.2.1": + version: 18.2.1 + resolution: "@types/react-is@npm:18.2.1" + dependencies: + "@types/react": "*" + checksum: 0d426ef34c23383760c718b9902a8262099ff81466685034594bf3b7a183356627806ba19610b16da51358f6389f1d83e6f843b7781c39218cfc7f4da5536e8b + languageName: node + linkType: hard + "@types/react-test-renderer@npm:>=16.9.0": version: 17.0.1 resolution: "@types/react-test-renderer@npm:17.0.1" @@ -18337,6 +18346,7 @@ __metadata: "@types/node": ^17.0.8 "@types/node-polyglot": ^0.4.31 "@types/react": ^17.0.20 + "@types/react-is": ^18.2.1 clsx: ^1.1.1 cross-env: ^5.2.0 date-fns: ^2.19.0 From 466a4f001b0a17253ca4b5fb041ccb032745a779 Mon Sep 17 00:00:00 2001 From: Matthieu Chaffotte Date: Thu, 28 Sep 2023 11:22:49 +0200 Subject: [PATCH 07/17] feat: revert mui upgrade --- examples/crm/package.json | 2 +- examples/demo/package.json | 2 +- examples/no-code/package.json | 2 +- examples/simple/package.json | 2 +- packages/ra-input-rich-text/package.json | 4 +- packages/ra-no-code/package.json | 2 +- packages/ra-ui-materialui/package.json | 4 +- .../ra-ui-materialui/src/button/Button.tsx | 1 - packages/react-admin/package.json | 2 +- yarn.lock | 365 ++++++------------ 10 files changed, 119 insertions(+), 267 deletions(-) diff --git a/examples/crm/package.json b/examples/crm/package.json index 2e1bd5a88a7..9d42788d91b 100644 --- a/examples/crm/package.json +++ b/examples/crm/package.json @@ -5,7 +5,7 @@ "dependencies": { "@hello-pangea/dnd": "^16.3.0", "@mui/icons-material": "^5.0.1", - "@mui/material": "^5.14.10", + "@mui/material": "^5.0.2", "@nivo/bar": "^0.80.0", "@nivo/core": "^0.80.0", "clsx": "^1.1.1", diff --git a/examples/demo/package.json b/examples/demo/package.json index 5631769bd6c..31b50cc4f88 100644 --- a/examples/demo/package.json +++ b/examples/demo/package.json @@ -5,7 +5,7 @@ "dependencies": { "@apollo/client": "^3.3.19", "@mui/icons-material": "^5.0.1", - "@mui/material": "^5.14.10", + "@mui/material": "^5.0.2", "@types/inflection": "^1.5.28", "@types/recharts": "^1.8.10", "@vitejs/plugin-react": "^2.2.0", diff --git a/examples/no-code/package.json b/examples/no-code/package.json index 4edcf7c4704..bee37454663 100644 --- a/examples/no-code/package.json +++ b/examples/no-code/package.json @@ -8,7 +8,7 @@ "serve": "vite preview" }, "dependencies": { - "@mui/material": "^5.14.10", + "@mui/material": "^5.0.2", "ra-data-local-storage": "^4.12.0", "ra-no-code": "^4.12.0", "react": "^17.0.0", diff --git a/examples/simple/package.json b/examples/simple/package.json index 198e2397893..e14ea88172c 100644 --- a/examples/simple/package.json +++ b/examples/simple/package.json @@ -12,7 +12,7 @@ "@emotion/react": "^11.7.1", "@emotion/styled": "^11.6.0", "@mui/icons-material": "^5.0.1", - "@mui/material": "^5.14.10", + "@mui/material": "^5.0.2", "jsonexport": "^3.2.0", "lodash": "~4.17.5", "prop-types": "^15.7.2", diff --git a/packages/ra-input-rich-text/package.json b/packages/ra-input-rich-text/package.json index 7f55b826e30..48dfbfdf909 100644 --- a/packages/ra-input-rich-text/package.json +++ b/packages/ra-input-rich-text/package.json @@ -39,7 +39,7 @@ }, "peerDependencies": { "@mui/icons-material": "^5.0.1", - "@mui/material": "^5.14.10", + "@mui/material": "^5.0.2", "ra-core": "^4.0.0", "ra-ui-materialui": "^4.0.0", "react": "^16.9.0 || ^17.0.0 || ^18.0.0", @@ -47,7 +47,7 @@ }, "devDependencies": { "@mui/icons-material": "^5.0.1", - "@mui/material": "^5.14.10", + "@mui/material": "^5.0.2", "@testing-library/react": "^11.2.3", "data-generator-retail": "^4.13.4", "ra-core": "^4.13.4", diff --git a/packages/ra-no-code/package.json b/packages/ra-no-code/package.json index 3b405eb1ad9..d77ec954e7b 100644 --- a/packages/ra-no-code/package.json +++ b/packages/ra-no-code/package.json @@ -41,7 +41,7 @@ }, "dependencies": { "@mui/icons-material": "^5.0.1", - "@mui/material": "^5.14.10", + "@mui/material": "^5.0.2", "clsx": "^1.1.1", "date-fns": "^2.19.0", "inflection": "~1.12.0", diff --git a/packages/ra-ui-materialui/package.json b/packages/ra-ui-materialui/package.json index dddac4c34b6..17c510b76dc 100644 --- a/packages/ra-ui-materialui/package.json +++ b/packages/ra-ui-materialui/package.json @@ -27,7 +27,7 @@ }, "devDependencies": { "@mui/icons-material": "^5.0.1", - "@mui/material": "^5.14.10", + "@mui/material": "^5.0.2", "@testing-library/react": "^11.2.3", "@types/dompurify": "^3.0.2", "cross-env": "^5.2.0", @@ -50,7 +50,7 @@ }, "peerDependencies": { "@mui/icons-material": "^5.0.1", - "@mui/material": "^5.14.10", + "@mui/material": "^5.0.2", "ra-core": "^4.0.0", "react": "^16.9.0 || ^17.0.0 || ^18.0.0", "react-dom": "^16.9.0 || ^17.0.0 || ^18.0.0", diff --git a/packages/ra-ui-materialui/src/button/Button.tsx b/packages/ra-ui-materialui/src/button/Button.tsx index 795233760ee..a55a541c5c8 100644 --- a/packages/ra-ui-materialui/src/button/Button.tsx +++ b/packages/ra-ui-materialui/src/button/Button.tsx @@ -7,7 +7,6 @@ import { useMediaQuery, Theme, } from '@mui/material'; -import { PolymorphicProps } from '@mui/base'; import { styled } from '@mui/material/styles'; import PropTypes from 'prop-types'; diff --git a/packages/react-admin/package.json b/packages/react-admin/package.json index af87819638c..c075ee07f72 100644 --- a/packages/react-admin/package.json +++ b/packages/react-admin/package.json @@ -39,7 +39,7 @@ "@emotion/react": "^11.4.1", "@emotion/styled": "^11.3.0", "@mui/icons-material": "^5.0.1", - "@mui/material": "^5.14.10", + "@mui/material": "^5.0.2", "history": "^5.1.0", "ra-core": "^4.13.4", "ra-i18n-polyglot": "^4.13.4", diff --git a/yarn.lock b/yarn.lock index 2c1bbae2900..0714db82840 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1816,15 +1816,6 @@ __metadata: languageName: node linkType: hard -"@babel/runtime@npm:^7.22.15": - version: 7.23.1 - resolution: "@babel/runtime@npm:7.23.1" - dependencies: - regenerator-runtime: ^0.14.0 - checksum: e57ab1436d4845efe67c3f76d578508bb584173690ecfeac105bc4e09d64b2aa6a53c1e03bca3c97cc238e5390a804e5a4ded211e6350243b735905ca45a4822 - languageName: node - linkType: hard - "@babel/template@npm:^7.16.7, @babel/template@npm:^7.22.5": version: 7.22.5 resolution: "@babel/template@npm:7.22.5" @@ -1984,19 +1975,6 @@ __metadata: languageName: node linkType: hard -"@emotion/cache@npm:^11.11.0": - version: 11.11.0 - resolution: "@emotion/cache@npm:11.11.0" - dependencies: - "@emotion/memoize": ^0.8.1 - "@emotion/sheet": ^1.2.2 - "@emotion/utils": ^1.2.1 - "@emotion/weak-memoize": ^0.3.1 - stylis: 4.2.0 - checksum: a23ab5ab2fd08e904698106d58ad3536fed51cc1aa0ef228e95bb640eaf11f560dbd91a395477b0d84e1e3c20150263764b4558517cf6576a89d2d6cc5253688 - languageName: node - linkType: hard - "@emotion/cache@npm:^11.7.1": version: 11.7.1 resolution: "@emotion/cache@npm:11.7.1" @@ -2033,13 +2011,6 @@ __metadata: languageName: node linkType: hard -"@emotion/memoize@npm:^0.8.1": - version: 0.8.1 - resolution: "@emotion/memoize@npm:0.8.1" - checksum: dffed372fc3b9fa2ba411e76af22b6bb686fb0cb07694fdfaa6dd2baeb0d5e4968c1a7caa472bfcf06a5997d5e7c7d16b90e993f9a6ffae79a2c3dbdc76dfe78 - languageName: node - linkType: hard - "@emotion/react@npm:^11.1.5, @emotion/react@npm:^11.4.1, @emotion/react@npm:^11.7.1": version: 11.7.1 resolution: "@emotion/react@npm:11.7.1" @@ -2083,13 +2054,6 @@ __metadata: languageName: node linkType: hard -"@emotion/sheet@npm:^1.2.2": - version: 1.2.2 - resolution: "@emotion/sheet@npm:1.2.2" - checksum: 69827a1bfa43d7b188f1d8cea42163143a36312543fdade5257c459a2b3efd7ce386aac84ba152bc2517a4f7e54384c04800b26adb382bb284ac7e4ad40e584b - languageName: node - linkType: hard - "@emotion/styled@npm:^11.3.0, @emotion/styled@npm:^11.6.0": version: 11.6.0 resolution: "@emotion/styled@npm:11.6.0" @@ -2135,13 +2099,6 @@ __metadata: languageName: node linkType: hard -"@emotion/utils@npm:^1.2.1": - version: 1.2.1 - resolution: "@emotion/utils@npm:1.2.1" - checksum: db43ca803361740c14dfb1cca1464d10d27f4c8b40d3e8864e6932ccf375d1450778ff4e4eadee03fb97f2aeb18de9fae98294905596a12ff7d4cd1910414d8d - languageName: node - linkType: hard - "@emotion/weak-memoize@npm:^0.2.5": version: 0.2.5 resolution: "@emotion/weak-memoize@npm:0.2.5" @@ -2149,13 +2106,6 @@ __metadata: languageName: node linkType: hard -"@emotion/weak-memoize@npm:^0.3.1": - version: 0.3.1 - resolution: "@emotion/weak-memoize@npm:0.3.1" - checksum: ed514b3cb94bbacece4ac2450d98898066c0a0698bdeda256e312405ca53634cb83c75889b25cd8bbbe185c80f4c05a1f0a0091e1875460ba6be61d0334f0b8a - languageName: node - linkType: hard - "@esbuild/android-arm64@npm:0.17.19": version: 0.17.19 resolution: "@esbuild/android-arm64@npm:0.17.19" @@ -2352,44 +2302,6 @@ __metadata: languageName: node linkType: hard -"@floating-ui/core@npm:^1.4.2": - version: 1.5.0 - resolution: "@floating-ui/core@npm:1.5.0" - dependencies: - "@floating-ui/utils": ^0.1.3 - checksum: bca811cefd09c3f56c4cf58c3e94826c1ce4a0b40124e9030ddca2ef1cc68b4ddc5ba5b4d7cc94c9555aea6876d2428a77a2ae261fe5b39c79df247a9518b053 - languageName: node - linkType: hard - -"@floating-ui/dom@npm:^1.5.1": - version: 1.5.3 - resolution: "@floating-ui/dom@npm:1.5.3" - dependencies: - "@floating-ui/core": ^1.4.2 - "@floating-ui/utils": ^0.1.3 - checksum: e5f30b911f939e40003851077bba441f269ae689bdc43c674bee43aa98fc6b7a5f59be432d27b7be599b1e4ab7b15c752875ea777a89cff01d157e593b78b25b - languageName: node - linkType: hard - -"@floating-ui/react-dom@npm:^2.0.2": - version: 2.0.2 - resolution: "@floating-ui/react-dom@npm:2.0.2" - dependencies: - "@floating-ui/dom": ^1.5.1 - peerDependencies: - react: ">=16.8.0" - react-dom: ">=16.8.0" - checksum: bfd07cfc9047a31e92e223dbbe48f2cdb75460126217b35cfbf8555eaf1718ce7c11f4ee4d39bdee89eaf9ad0a5c4dd9af443a552116fc3478a19a9f6283bdf6 - languageName: node - linkType: hard - -"@floating-ui/utils@npm:^0.1.3": - version: 0.1.4 - resolution: "@floating-ui/utils@npm:0.1.4" - checksum: 1183890f1f9868e4a0d300d0496bd204b3277a882c233455033fcba81a715ecbe4535b80bacbf3f7c2d82e7a63136bcccdc10fff297ce07086146afad73b15a0 - languageName: node - linkType: hard - "@gar/promisify@npm:^1.0.1, @gar/promisify@npm:^1.1.3": version: 1.1.3 resolution: "@gar/promisify@npm:1.1.3" @@ -2965,32 +2877,25 @@ __metadata: languageName: node linkType: hard -"@mui/base@npm:5.0.0-beta.16": - version: 5.0.0-beta.16 - resolution: "@mui/base@npm:5.0.0-beta.16" +"@mui/base@npm:5.0.0-alpha.64": + version: 5.0.0-alpha.64 + resolution: "@mui/base@npm:5.0.0-alpha.64" dependencies: - "@babel/runtime": ^7.22.15 - "@floating-ui/react-dom": ^2.0.2 - "@mui/types": ^7.2.4 - "@mui/utils": ^5.14.10 - "@popperjs/core": ^2.11.8 - clsx: ^2.0.0 - prop-types: ^15.8.1 + "@babel/runtime": ^7.16.3 + "@emotion/is-prop-valid": ^1.1.1 + "@mui/utils": ^5.2.3 + "@popperjs/core": ^2.4.4 + clsx: ^1.1.1 + prop-types: ^15.7.2 + react-is: ^17.0.2 peerDependencies: - "@types/react": ^17.0.0 || ^18.0.0 - react: ^17.0.0 || ^18.0.0 - react-dom: ^17.0.0 || ^18.0.0 + "@types/react": ^16.8.6 || ^17.0.0 + react: ^17.0.2 + react-dom: ^17.0.2 peerDependenciesMeta: "@types/react": optional: true - checksum: 035cdb9bba59394d2f937d3f17a0a5d5121a269542129cc99f5b82e4e773d5b31dc6b7fbe1fcacf8b744ff7a8ad9640fb30c27e283f89770f802147fd9d50962 - languageName: node - linkType: hard - -"@mui/core-downloads-tracker@npm:^5.14.10": - version: 5.14.10 - resolution: "@mui/core-downloads-tracker@npm:5.14.10" - checksum: 165751152a5fa490cee7d5919030e12a489c4e23ba253ecd14d78dcda07fea49d715ee656976854716f95d37fd89fa68f34e115f73e6bfed872bd1ba153ecd31 + checksum: 5e91036773ecdef831cc1c196843208e19349aba0937d349ef7b53707db5581384609f929b600828610bf7f05964a6dab3d240ab85975ab16f9b6617faadcd60 languageName: node linkType: hard @@ -3010,28 +2915,28 @@ __metadata: languageName: node linkType: hard -"@mui/material@npm:^5.14.10": - version: 5.14.10 - resolution: "@mui/material@npm:5.14.10" +"@mui/material@npm:^5.0.2": + version: 5.2.8 + resolution: "@mui/material@npm:5.2.8" dependencies: - "@babel/runtime": ^7.22.15 - "@mui/base": 5.0.0-beta.16 - "@mui/core-downloads-tracker": ^5.14.10 - "@mui/system": ^5.14.10 - "@mui/types": ^7.2.4 - "@mui/utils": ^5.14.10 - "@types/react-transition-group": ^4.4.6 - clsx: ^2.0.0 - csstype: ^3.1.2 - prop-types: ^15.8.1 - react-is: ^18.2.0 - react-transition-group: ^4.4.5 + "@babel/runtime": ^7.16.3 + "@mui/base": 5.0.0-alpha.64 + "@mui/system": ^5.2.8 + "@mui/types": ^7.1.0 + "@mui/utils": ^5.2.3 + "@types/react-transition-group": ^4.4.4 + clsx: ^1.1.1 + csstype: ^3.0.10 + hoist-non-react-statics: ^3.3.2 + prop-types: ^15.7.2 + react-is: ^17.0.2 + react-transition-group: ^4.4.2 peerDependencies: "@emotion/react": ^11.5.0 "@emotion/styled": ^11.3.0 - "@types/react": ^17.0.0 || ^18.0.0 - react: ^17.0.0 || ^18.0.0 - react-dom: ^17.0.0 || ^18.0.0 + "@types/react": ^16.8.6 || ^17.0.0 + react: ^17.0.2 + react-dom: ^17.0.2 peerDependenciesMeta: "@emotion/react": optional: true @@ -3039,65 +2944,64 @@ __metadata: optional: true "@types/react": optional: true - checksum: 82500d343c71ae22f8e9bfe5632cdf71092d15502574f20c42d44c33828f87dbb864be84f31d0dadc0f304d70fc8854581e2b4779b23cd2d753208e497acfc3d + checksum: eceb56f752e114aaa53c41c8c1f5fed88f3df8a1fbdd62de8d19131faf1dc5b64b04c5631a1a77468ae928abe11450b866b13647d29dc2d9ceccc4f225c16832 languageName: node linkType: hard -"@mui/private-theming@npm:^5.14.10": - version: 5.14.10 - resolution: "@mui/private-theming@npm:5.14.10" +"@mui/private-theming@npm:^5.2.3": + version: 5.2.3 + resolution: "@mui/private-theming@npm:5.2.3" dependencies: - "@babel/runtime": ^7.22.15 - "@mui/utils": ^5.14.10 - prop-types: ^15.8.1 + "@babel/runtime": ^7.16.3 + "@mui/utils": ^5.2.3 + prop-types: ^15.7.2 peerDependencies: - "@types/react": ^17.0.0 || ^18.0.0 - react: ^17.0.0 || ^18.0.0 + "@types/react": ^16.8.6 || ^17.0.0 + react: ^17.0.2 peerDependenciesMeta: "@types/react": optional: true - checksum: 0ef27687f575f09d8167db5dbc6bda0a0e19d603a3d00c8ff9d3f2544e5c55292b01be0317782640e0072bb19916015920c01e693bd36bd28068775a05a54b6d + checksum: 477da8719479c9b1223adf04e195db9845be6201041e9eea98f670e2baea1ad1651edf778ed4f7ff0aa5bb5444970150d52afe21d3762ad6d39d327504bcd46e languageName: node linkType: hard -"@mui/styled-engine@npm:^5.14.10": - version: 5.14.10 - resolution: "@mui/styled-engine@npm:5.14.10" +"@mui/styled-engine@npm:^5.2.6": + version: 5.2.6 + resolution: "@mui/styled-engine@npm:5.2.6" dependencies: - "@babel/runtime": ^7.22.15 - "@emotion/cache": ^11.11.0 - csstype: ^3.1.2 - prop-types: ^15.8.1 + "@babel/runtime": ^7.16.3 + "@emotion/cache": ^11.7.1 + prop-types: ^15.7.2 peerDependencies: "@emotion/react": ^11.4.1 "@emotion/styled": ^11.3.0 - react: ^17.0.0 || ^18.0.0 + react: ^17.0.2 peerDependenciesMeta: "@emotion/react": optional: true "@emotion/styled": optional: true - checksum: 0f7184abfc81ed7a82c2256d3bab3efdf202d4e761e4cd98e67bafc7fe7d96176a6cac3c54b156fc4e161ca830294356eef28970f584b62c1a4d6ec3d6256dfe + checksum: 8fad62e312643ac3cb7bcdabf1b0164f05da71585b85b1d7a38ed27f22c834d54a0e225319796beaf7244820915faecfbd2242944bcdb821a53502c146c8e279 languageName: node linkType: hard -"@mui/system@npm:^5.14.10": - version: 5.14.10 - resolution: "@mui/system@npm:5.14.10" +"@mui/system@npm:^5.2.8": + version: 5.2.8 + resolution: "@mui/system@npm:5.2.8" dependencies: - "@babel/runtime": ^7.22.15 - "@mui/private-theming": ^5.14.10 - "@mui/styled-engine": ^5.14.10 - "@mui/types": ^7.2.4 - "@mui/utils": ^5.14.10 - clsx: ^2.0.0 - csstype: ^3.1.2 - prop-types: ^15.8.1 + "@babel/runtime": ^7.16.3 + "@mui/private-theming": ^5.2.3 + "@mui/styled-engine": ^5.2.6 + "@mui/types": ^7.1.0 + "@mui/utils": ^5.2.3 + clsx: ^1.1.1 + csstype: ^3.0.10 + prop-types: ^15.7.2 peerDependencies: "@emotion/react": ^11.5.0 "@emotion/styled": ^11.3.0 - "@types/react": ^17.0.0 || ^18.0.0 - react: ^17.0.0 || ^18.0.0 + "@types/react": ^16.8.6 || ^17.0.0 + react: ^17.0.2 peerDependenciesMeta: "@emotion/react": optional: true @@ -3105,37 +3009,34 @@ __metadata: optional: true "@types/react": optional: true - checksum: daf86070f786dbb70b997b0dbe11485634407bb60b18219d2929649e92486f9097c3c17d658ca3cd266d5708b658fc8bead6d6b53d63995c25bf76445d3d4919 + checksum: 72fab31a8071fd3fabb5c90087b8cadf8655cd16d70a8578911173409a0e4ee10564f9fb51e351dbfbb503ec1d5f51958906250869abb458ac2ce6609ced426d languageName: node linkType: hard -"@mui/types@npm:^7.2.4": - version: 7.2.4 - resolution: "@mui/types@npm:7.2.4" +"@mui/types@npm:^7.1.0": + version: 7.1.0 + resolution: "@mui/types@npm:7.1.0" peerDependencies: "@types/react": "*" peerDependenciesMeta: "@types/react": optional: true - checksum: 17411effd184eff34d6a1a55b2249c7e1ef195bb30c48154f0b16fdce428ff55be4ec5dde8b4a556c01eda2d34e3dcc18d925f8fdee606f5bc15f91167f0ecbc + checksum: 0027e0092cc4674d971c1218dea6d6ec33c8f98ede0fb793e5bcec27c9d8897343adc2d8e45704ab54841c6792ff9c5df7601ad968da58123551d48c3faa307f languageName: node linkType: hard -"@mui/utils@npm:^5.14.10": - version: 5.14.10 - resolution: "@mui/utils@npm:5.14.10" +"@mui/utils@npm:^5.2.3": + version: 5.2.3 + resolution: "@mui/utils@npm:5.2.3" dependencies: - "@babel/runtime": ^7.22.15 - "@types/prop-types": ^15.7.5 - prop-types: ^15.8.1 - react-is: ^18.2.0 + "@babel/runtime": ^7.16.3 + "@types/prop-types": ^15.7.4 + "@types/react-is": ^16.7.1 || ^17.0.0 + prop-types: ^15.7.2 + react-is: ^17.0.2 peerDependencies: - "@types/react": ^17.0.0 || ^18.0.0 - react: ^17.0.0 || ^18.0.0 - peerDependenciesMeta: - "@types/react": - optional: true - checksum: fb778e1a5fb97920b9457667d910f6055bb0a22bec26f011b4e269e9646e46f6c4800e00b80feab8f8ec79242afd4c342437671a0389b6ac807e14a32338dd24 + react: ^17.0.2 + checksum: 0a8f52dbb8f4f2b6d743c5d419907d6bfcea8648a5b65fefc3ff96f0dc967448867357057c127cb746a762a226c2b1d79481bfc45896ad997a41d75a25a111d2 languageName: node linkType: hard @@ -3750,14 +3651,7 @@ __metadata: languageName: node linkType: hard -"@popperjs/core@npm:^2.11.8": - version: 2.11.8 - resolution: "@popperjs/core@npm:2.11.8" - checksum: 4681e682abc006d25eb380d0cf3efc7557043f53b6aea7a5057d0d1e7df849a00e281cd8ea79c902a35a414d7919621fc2ba293ecec05f413598e0b23d5a1e63 - languageName: node - linkType: hard - -"@popperjs/core@npm:^2.9.0": +"@popperjs/core@npm:^2.4.4, @popperjs/core@npm:^2.9.0": version: 2.11.2 resolution: "@popperjs/core@npm:2.11.2" checksum: b06f65fcef9dbfe7487fd53e38f12684267e91c8bc667a6c9621c207f42ee97d48059039ee8dae0327df509234b6f09bf5b940b34b71ee453d307f53d84e99b2 @@ -6102,20 +5996,13 @@ __metadata: languageName: node linkType: hard -"@types/prop-types@npm:*, @types/prop-types@npm:^15.6.0": +"@types/prop-types@npm:*, @types/prop-types@npm:^15.6.0, @types/prop-types@npm:^15.7.4": version: 15.7.4 resolution: "@types/prop-types@npm:15.7.4" checksum: 014bb826592fab01499931259969aafc21d5a8ff4ece3e3fb8e2b5186bed17656f7dcdccf9a98c27fee74d7d0697aa3f53ea971a72679597f0ca0c3d5ca585d3 languageName: node linkType: hard -"@types/prop-types@npm:^15.7.5": - version: 15.7.7 - resolution: "@types/prop-types@npm:15.7.7" - checksum: 26d565ebae8c28dede71547d687367ce74eeccc645fdbef2d38478fe293996be24784fa6190586ba303ccd274aa94d8a631d36a5d9b8e0c08f5647ff3244d72c - languageName: node - linkType: hard - "@types/qs@npm:*, @types/qs@npm:^6.9.5": version: 6.9.7 resolution: "@types/qs@npm:6.9.7" @@ -6148,12 +6035,21 @@ __metadata: languageName: node linkType: hard +"@types/react-is@npm:^16.7.1 || ^17.0.0": + version: 17.0.3 + resolution: "@types/react-is@npm:17.0.3" + dependencies: + "@types/react": "*" + checksum: 839382b66b2b2e3023647f5ba0c382ddc6aa01c1bc9f64608f82bbc871a905ba9b988838619914d8348c2a511717c6bd3701cb866bb9e4abfabdbe544efb695b + languageName: node + linkType: hard + "@types/react-is@npm:^18.2.1": - version: 18.2.1 - resolution: "@types/react-is@npm:18.2.1" + version: 18.2.2 + resolution: "@types/react-is@npm:18.2.2" dependencies: "@types/react": "*" - checksum: 0d426ef34c23383760c718b9902a8262099ff81466685034594bf3b7a183356627806ba19610b16da51358f6389f1d83e6f843b7781c39218cfc7f4da5536e8b + checksum: c08d1ef3164527a84aa0bcbf2b8c58b9999f44911be24e7733b1325ccd9c53ab4c284a2abaf5a884fc4e672d73fa192775def602ff283022c10cfe589cdfb240 languageName: node linkType: hard @@ -6166,12 +6062,12 @@ __metadata: languageName: node linkType: hard -"@types/react-transition-group@npm:^4.4.6": - version: 4.4.6 - resolution: "@types/react-transition-group@npm:4.4.6" +"@types/react-transition-group@npm:^4.4.4": + version: 4.4.4 + resolution: "@types/react-transition-group@npm:4.4.4" dependencies: "@types/react": "*" - checksum: 154dc4e94738cff0b2fa183331427c0de3d8daac44a9b79c27aa8a95b78adde44b9f70db8a374399eabe1d44ca50304b1d7bbaeadca0fbdf6f2a91f6f9eb343d + checksum: 0e593863c60550002bb7a5bf60dad719de78580017f87eadf32661d1870345a4ef22e2e37902e05d05955494f2c0cae5ef46510032005e8e969273eee0ae8519 languageName: node linkType: hard @@ -8756,13 +8652,6 @@ __metadata: languageName: node linkType: hard -"clsx@npm:^2.0.0": - version: 2.0.0 - resolution: "clsx@npm:2.0.0" - checksum: c09f43b3144a0b7826b6b11b6a111b2c7440831004eecc02d333533c5e58ef0aa5f2dce071d3b25fbb8c8ea97b45df96c74bcc1d51c8c2027eb981931107b0cd - languageName: node - linkType: hard - "cmd-shim@npm:6.0.1": version: 6.0.1 resolution: "cmd-shim@npm:6.0.1" @@ -9509,20 +9398,13 @@ __metadata: languageName: node linkType: hard -"csstype@npm:^3.0.2": +"csstype@npm:^3.0.10, csstype@npm:^3.0.2": version: 3.0.10 resolution: "csstype@npm:3.0.10" checksum: f0fff671ab368a863946859ad96be0be66afeb83566215d6494be840ffedfaef4945b48d1b0ce1a19f9983af772e0ce38c7be91a1ad46fe7ecd641937c5a99f7 languageName: node linkType: hard -"csstype@npm:^3.1.2": - version: 3.1.2 - resolution: "csstype@npm:3.1.2" - checksum: 32c038af259897c807ac738d9eab16b3d86747c72b09d5c740978e06f067f9b7b1737e1b75e407c7ab1fe1543dc95f20e202b4786aeb1b8d3bdf5d5ce655e6c6 - languageName: node - linkType: hard - "cypress-plugin-tab@npm:^1.0.5": version: 1.0.5 resolution: "cypress-plugin-tab@npm:1.0.5" @@ -9959,7 +9841,7 @@ __metadata: dependencies: "@apollo/client": ^3.3.19 "@mui/icons-material": ^5.0.1 - "@mui/material": ^5.14.10 + "@mui/material": ^5.0.2 "@types/fetch-mock": ^7.3.2 "@types/inflection": ^1.5.28 "@types/jest": ^29.5.2 @@ -16324,7 +16206,7 @@ __metadata: version: 0.0.0-use.local resolution: "no-code@workspace:examples/no-code" dependencies: - "@mui/material": ^5.14.10 + "@mui/material": ^5.0.2 "@vitejs/plugin-react": ^2.2.0 ra-data-local-storage: ^4.12.0 ra-no-code: ^4.12.0 @@ -18506,7 +18388,7 @@ __metadata: resolution: "ra-input-rich-text@workspace:packages/ra-input-rich-text" dependencies: "@mui/icons-material": ^5.0.1 - "@mui/material": ^5.14.10 + "@mui/material": ^5.0.2 "@testing-library/react": ^11.2.3 "@tiptap/core": ^2.0.3 "@tiptap/extension-color": ^2.0.3 @@ -18532,7 +18414,7 @@ __metadata: typescript: ^5.1.3 peerDependencies: "@mui/icons-material": ^5.0.1 - "@mui/material": ^5.14.10 + "@mui/material": ^5.0.2 ra-core: ^4.0.0 ra-ui-materialui: ^4.0.0 react: ^16.9.0 || ^17.0.0 || ^18.0.0 @@ -18565,7 +18447,7 @@ __metadata: resolution: "ra-no-code@workspace:packages/ra-no-code" dependencies: "@mui/icons-material": ^5.0.1 - "@mui/material": ^5.14.10 + "@mui/material": ^5.0.2 "@testing-library/react": ^11.2.3 "@testing-library/user-event": ^13.1.5 clsx: ^1.1.1 @@ -18596,7 +18478,7 @@ __metadata: resolution: "ra-ui-materialui@workspace:packages/ra-ui-materialui" dependencies: "@mui/icons-material": ^5.0.1 - "@mui/material": ^5.14.10 + "@mui/material": ^5.0.2 "@testing-library/react": ^11.2.3 "@types/dompurify": ^3.0.2 autosuggest-highlight: ^3.1.1 @@ -18632,7 +18514,7 @@ __metadata: typescript: ^5.1.3 peerDependencies: "@mui/icons-material": ^5.0.1 - "@mui/material": ^5.14.10 + "@mui/material": ^5.0.2 ra-core: ^4.0.0 react: ^16.9.0 || ^17.0.0 || ^18.0.0 react-dom: ^16.9.0 || ^17.0.0 || ^18.0.0 @@ -18724,7 +18606,7 @@ __metadata: dependencies: "@hello-pangea/dnd": ^16.3.0 "@mui/icons-material": ^5.0.1 - "@mui/material": ^5.14.10 + "@mui/material": ^5.0.2 "@nivo/bar": ^0.80.0 "@nivo/core": ^0.80.0 "@testing-library/jest-dom": ^5.11.4 @@ -18812,7 +18694,7 @@ __metadata: "@emotion/react": ^11.4.1 "@emotion/styled": ^11.3.0 "@mui/icons-material": ^5.0.1 - "@mui/material": ^5.14.10 + "@mui/material": ^5.0.2 cross-env: ^5.2.0 expect: ^27.4.6 history: ^5.1.0 @@ -19010,7 +18892,7 @@ __metadata: languageName: node linkType: hard -"react-is@npm:^18.0.0, react-is@npm:^18.2.0": +"react-is@npm:^18.0.0": version: 18.2.0 resolution: "react-is@npm:18.2.0" checksum: 6eb5e4b28028c23e2bfcf73371e72cd4162e4ac7ab445ddae2afe24e347a37d6dc22fae6e1748632cd43c6d4f9b8f86dcf26bf9275e1874f436d129952528ae0 @@ -19231,7 +19113,7 @@ __metadata: languageName: node linkType: hard -"react-transition-group@npm:^4.4.1": +"react-transition-group@npm:^4.4.1, react-transition-group@npm:^4.4.2": version: 4.4.2 resolution: "react-transition-group@npm:4.4.2" dependencies: @@ -19246,21 +19128,6 @@ __metadata: languageName: node linkType: hard -"react-transition-group@npm:^4.4.5": - version: 4.4.5 - resolution: "react-transition-group@npm:4.4.5" - dependencies: - "@babel/runtime": ^7.5.5 - dom-helpers: ^5.0.1 - loose-envify: ^1.4.0 - prop-types: ^15.6.2 - peerDependencies: - react: ">=16.6.0" - react-dom: ">=16.6.0" - checksum: 2ba754ba748faefa15f87c96dfa700d5525054a0141de8c75763aae6734af0740e77e11261a1e8f4ffc08fd9ab78510122e05c21c2d79066c38bb6861a886c82 - languageName: node - linkType: hard - "react@npm:^17.0.0": version: 17.0.2 resolution: "react@npm:17.0.2" @@ -19569,13 +19436,6 @@ __metadata: languageName: node linkType: hard -"regenerator-runtime@npm:^0.14.0": - version: 0.14.0 - resolution: "regenerator-runtime@npm:0.14.0" - checksum: e25f062c1a183f81c99681691a342760e65c55e8d3a4d4fe347ebe72433b123754b942b70b622959894e11f8a9131dc549bd3c9a5234677db06a4af42add8d12 - languageName: node - linkType: hard - "regenerator-transform@npm:^0.15.1": version: 0.15.1 resolution: "regenerator-transform@npm:0.15.1" @@ -20443,7 +20303,7 @@ __metadata: "@emotion/styled": ^11.6.0 "@hookform/devtools": ^4.0.2 "@mui/icons-material": ^5.0.1 - "@mui/material": ^5.14.10 + "@mui/material": ^5.0.2 "@vitejs/plugin-react": ^2.2.0 jsonexport: ^3.2.0 lodash: ~4.17.5 @@ -21081,13 +20941,6 @@ __metadata: languageName: node linkType: hard -"stylis@npm:4.2.0": - version: 4.2.0 - resolution: "stylis@npm:4.2.0" - checksum: a7128ad5a8ed72652c6eba46bed4f416521bc9745a460ef5741edc725252cebf36ee45e33a8615a7057403c93df0866ab9ee955960792db210bb80abd5ac6543 - languageName: node - linkType: hard - "supports-color@npm:^5.3.0": version: 5.5.0 resolution: "supports-color@npm:5.5.0" From 541fce30dc638a31129ba49a73a1aa13d25a10a3 Mon Sep 17 00:00:00 2001 From: Matthieu Chaffotte Date: Thu, 28 Sep 2023 11:33:26 +0200 Subject: [PATCH 08/17] feat: remove react-is dependency --- packages/ra-core/package.json | 1 - yarn.lock | 10 ---------- 2 files changed, 11 deletions(-) diff --git a/packages/ra-core/package.json b/packages/ra-core/package.json index 09e2919bf30..f89495e1e21 100644 --- a/packages/ra-core/package.json +++ b/packages/ra-core/package.json @@ -33,7 +33,6 @@ "@types/node": "^17.0.8", "@types/node-polyglot": "^0.4.31", "@types/react": "^17.0.20", - "@types/react-is": "^18.2.1", "cross-env": "^5.2.0", "expect": "^27.4.6", "history": "^5.1.0", diff --git a/yarn.lock b/yarn.lock index 0714db82840..2fdc52a7b76 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6044,15 +6044,6 @@ __metadata: languageName: node linkType: hard -"@types/react-is@npm:^18.2.1": - version: 18.2.2 - resolution: "@types/react-is@npm:18.2.2" - dependencies: - "@types/react": "*" - checksum: c08d1ef3164527a84aa0bcbf2b8c58b9999f44911be24e7733b1325ccd9c53ab4c284a2abaf5a884fc4e672d73fa192775def602ff283022c10cfe589cdfb240 - languageName: node - linkType: hard - "@types/react-test-renderer@npm:>=16.9.0": version: 17.0.1 resolution: "@types/react-test-renderer@npm:17.0.1" @@ -18228,7 +18219,6 @@ __metadata: "@types/node": ^17.0.8 "@types/node-polyglot": ^0.4.31 "@types/react": ^17.0.20 - "@types/react-is": ^18.2.1 clsx: ^1.1.1 cross-env: ^5.2.0 date-fns: ^2.19.0 From c72c8daa2a0ca08c1ddaa679a799da77e556cdd8 Mon Sep 17 00:00:00 2001 From: Matthieu Chaffotte Date: Thu, 28 Sep 2023 12:11:58 +0200 Subject: [PATCH 09/17] feat: fix CloneButton type --- packages/ra-ui-materialui/src/button/CloneButton.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/ra-ui-materialui/src/button/CloneButton.tsx b/packages/ra-ui-materialui/src/button/CloneButton.tsx index 68d8d3d4613..d2078dbf70e 100644 --- a/packages/ra-ui-materialui/src/button/CloneButton.tsx +++ b/packages/ra-ui-materialui/src/button/CloneButton.tsx @@ -29,10 +29,10 @@ export const CloneButton = (props: CloneButtonProps) => { search: stringify({ source: JSON.stringify(omitId(record)), }), - state: { _scrollToTop: scrollToTop }, } : pathname } + state={{ _scrollToTop: scrollToTop }} label={label} onClick={stopPropagation} {...sanitizeRestProps(rest)} @@ -61,7 +61,7 @@ interface Props { scrollToTop?: boolean; } -export type CloneButtonProps = Props & ButtonProps; +export type CloneButtonProps = Props & Omit, 'to'>; CloneButton.propTypes = { icon: PropTypes.element, From 3d80be8f4cab3db9d52e34ed786fbb84df67fe7e Mon Sep 17 00:00:00 2001 From: Matthieu Chaffotte Date: Thu, 28 Sep 2023 14:41:00 +0200 Subject: [PATCH 10/17] feat: apply review --- docs/Create.md | 4 ++-- examples/demo/src/reviews/ReviewCreate.tsx | 10 ++++------ examples/demo/src/reviews/StarRatingInput.tsx | 18 +++++++++--------- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/docs/Create.md b/docs/Create.md index 68c643aac6d..8502090db21 100644 --- a/docs/Create.md +++ b/docs/Create.md @@ -428,7 +428,7 @@ You sometimes need to pre-populate a record based on a *related* record. For ins By default, the `` view starts with an empty `record`. However, if the `location` object (injected by [react-router-dom](https://reacttraining.com/react-router/web/api/location)) contains a `record` in its `state`, the `` view uses that `record` instead of the empty object. That's how the `` works under the hood. -That means that if you want to create a link to a creation form, presetting *some* values, all you have to do is to set the location `state`. `react-router-dom` provides the `` component for that: +That means that if you want to create a link to a creation form, presetting *some* values, all you have to do is to set the prop `state` of the ``: {% raw %} ```jsx @@ -439,7 +439,7 @@ const CreateRelatedCommentButton = () => { const record = useRecordContext(); return ( ); diff --git a/examples/demo/src/reviews/ReviewCreate.tsx b/examples/demo/src/reviews/ReviewCreate.tsx index 9dae72bf1dc..08b05557355 100644 --- a/examples/demo/src/reviews/ReviewCreate.tsx +++ b/examples/demo/src/reviews/ReviewCreate.tsx @@ -15,11 +15,6 @@ import { import StarRatingInput from './StarRatingInput'; import { useLocation } from 'react-router'; -const customerOptionRenderer = (choice: any) => - `${choice.first_name} ${choice.last_name}`; - -const productOptionRenderer = (choice: any) => `${choice.reference}`; - const ReviewCreate = () => { const notify = useNotify(); const redirect = useRedirect(); @@ -46,7 +41,7 @@ const ReviewCreate = () => { @@ -68,4 +63,7 @@ const ReviewCreate = () => { ); }; +const customerOptionRenderer = (choice: any) => + `${choice.first_name} ${choice.last_name}`; + export default ReviewCreate; diff --git a/examples/demo/src/reviews/StarRatingInput.tsx b/examples/demo/src/reviews/StarRatingInput.tsx index 3f589e5c7b2..1dfbd34c4bc 100644 --- a/examples/demo/src/reviews/StarRatingInput.tsx +++ b/examples/demo/src/reviews/StarRatingInput.tsx @@ -2,15 +2,6 @@ import { Box, Rating, Typography, styled } from '@mui/material'; import Icon from '@mui/icons-material/Stars'; import { InputProps, useInput, useTranslate } from 'react-admin'; -const StyledRating = styled(Rating)({ - '& .MuiRating-iconFilled': { - color: '#000', - }, - '& .MuiRating-iconHover': { - color: '#000', - }, -}); - const StarRatingInput = (props: InputProps) => { const { name = 'resources.reviews.fields.rating' } = props; const { field } = useInput(props); @@ -28,4 +19,13 @@ const StarRatingInput = (props: InputProps) => { ); }; +const StyledRating = styled(Rating)({ + '& .MuiRating-iconFilled': { + color: '#000', + }, + '& .MuiRating-iconHover': { + color: '#000', + }, +}); + export default StarRatingInput; From 33c59551cc086b40b903c392df3fa81a12c91549 Mon Sep 17 00:00:00 2001 From: Matthieu Chaffotte Date: Fri, 29 Sep 2023 10:53:21 +0200 Subject: [PATCH 11/17] feat: use i18n property when creating a review --- examples/demo/src/reviews/ReviewCreate.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/demo/src/reviews/ReviewCreate.tsx b/examples/demo/src/reviews/ReviewCreate.tsx index 08b05557355..9ed8d9bbe04 100644 --- a/examples/demo/src/reviews/ReviewCreate.tsx +++ b/examples/demo/src/reviews/ReviewCreate.tsx @@ -22,7 +22,7 @@ const ReviewCreate = () => { const onSuccess = (_: any) => { const record = getRecordFromLocation(location); - notify(`Changes saved`); + notify('ra.notification.created'); if (record && record.product_id) { redirect(`/products/${record.product_id}/reviews`); } else { From 4cf859c2d5bb9dc6b02c4ccfe019881d9d190429 Mon Sep 17 00:00:00 2001 From: Matthieu Chaffotte Date: Mon, 2 Oct 2023 10:21:03 +0200 Subject: [PATCH 12/17] feat: fix code typo --- docs/CreateInDialogButton.md | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/docs/CreateInDialogButton.md b/docs/CreateInDialogButton.md index 136bcf771f0..965dd13b541 100644 --- a/docs/CreateInDialogButton.md +++ b/docs/CreateInDialogButton.md @@ -41,15 +41,15 @@ const CompanyShow = () => ( - ( - - - - - - - )} /> + ( + + + + + + + )} /> @@ -188,6 +188,3 @@ const EmployerEdit = () => ( ); ``` {% endraw %} - - - From 6ad0f5b955fb79fe84414d2893a757802a00f48f Mon Sep 17 00:00:00 2001 From: Matthieu Chaffotte Date: Mon, 2 Oct 2023 10:22:14 +0200 Subject: [PATCH 13/17] feat: allow legacy behaviour with to prop --- .../ra-ui-materialui/src/button/Button.tsx | 36 +++++++++++++++- .../src/button/CreateButton.tsx | 41 +++---------------- 2 files changed, 40 insertions(+), 37 deletions(-) diff --git a/packages/ra-ui-materialui/src/button/Button.tsx b/packages/ra-ui-materialui/src/button/Button.tsx index a55a541c5c8..28d8ffece10 100644 --- a/packages/ra-ui-materialui/src/button/Button.tsx +++ b/packages/ra-ui-materialui/src/button/Button.tsx @@ -7,10 +7,11 @@ import { useMediaQuery, Theme, } from '@mui/material'; - import { styled } from '@mui/material/styles'; +import { To } from 'history'; import PropTypes from 'prop-types'; import { useTranslate } from 'ra-core'; +import { Path } from 'react-router'; /** * A generic Button with side icon. Only the icon is displayed on small screens. @@ -36,10 +37,12 @@ export const Button = ( label, color = 'primary', size = 'small', + to: locationDescriptor, ...rest } = props; const translate = useTranslate(); const translatedLabel = label ? translate(label, { _: label }) : undefined; + const linkParams = getLinkParams(locationDescriptor); const isXSmall = useMediaQuery((theme: Theme) => theme.breakpoints.down('sm') @@ -53,6 +56,7 @@ export const Button = ( className={className} color={color} size="large" + {...linkParams} {...rest} > {children} @@ -64,6 +68,7 @@ export const Button = ( color={color} disabled={disabled} size="large" + {...linkParams} {...rest} > {children} @@ -78,6 +83,7 @@ export const Button = ( disabled={disabled} startIcon={alignIcon === 'left' && children ? children : undefined} endIcon={alignIcon === 'right' && children ? children : undefined} + {...linkParams} {...rest} > {translatedLabel} @@ -90,6 +96,7 @@ interface Props { children?: React.ReactElement; className?: string; component?: RootComponent; + to?: LocationDescriptor | To; disabled?: boolean; label?: string; size?: 'small' | 'medium' | 'large'; @@ -133,3 +140,30 @@ const StyledButton = styled(MuiButton, { lineHeight: 1.5, }, }); + +export const getLinkParams = ( + locationDescriptor?: LocationDescriptor | string +) => { + // eslint-disable-next-line eqeqeq + if (locationDescriptor == undefined) { + return undefined; + } + + if (typeof locationDescriptor === 'string') { + return { to: locationDescriptor }; + } + + const { redirect, replace, state, ...to } = locationDescriptor; + return { + to, + redirect, + replace, + state, + }; +}; + +export type LocationDescriptor = Partial & { + redirect?: boolean; + state?: any; + replace?: boolean; +}; diff --git a/packages/ra-ui-materialui/src/button/CreateButton.tsx b/packages/ra-ui-materialui/src/button/CreateButton.tsx index 004f8f3aad8..93e14a7ab26 100644 --- a/packages/ra-ui-materialui/src/button/CreateButton.tsx +++ b/packages/ra-ui-materialui/src/button/CreateButton.tsx @@ -3,14 +3,12 @@ import ContentAdd from '@mui/icons-material/Add'; import { Fab, useMediaQuery, Theme } from '@mui/material'; import { styled } from '@mui/material/styles'; import clsx from 'clsx'; -import isEqual from 'lodash/isEqual'; -import merge from 'lodash/merge'; +import { isEqual, merge } from 'lodash'; import PropTypes from 'prop-types'; import { useTranslate, useResourceContext, useCreatePath } from 'ra-core'; -import { Path } from 'react-router'; -import { Link } from 'react-router-dom'; +import { Link, To } from 'react-router-dom'; -import { Button, ButtonProps } from './Button'; +import { Button, ButtonProps, LocationDescriptor } from './Button'; /** * Opens the Create view of a given resource @@ -44,11 +42,7 @@ const CreateButton = (props: CreateButtonProps) => { const isSmall = useMediaQuery((theme: Theme) => theme.breakpoints.down('md') ); - const state = merge( - scrollStates[String(scrollToTop)], - getLinkParams(locationDescriptor), - initialState - ); + const state = merge(scrollStates[String(scrollToTop)], initialState); return isSmall ? ( & { - redirect?: boolean; - state?: any; - replace?: boolean; -}; - export type CreateButtonProps = Props & Omit, 'to'>; CreateButton.propTypes = { @@ -145,22 +133,3 @@ export default React.memo(CreateButton, (prevProps, nextProps) => { isEqual(prevProps.to, nextProps.to) ); }); - -const getLinkParams = (locationDescriptor?: LocationDescriptor | string) => { - // eslint-disable-next-line eqeqeq - if (locationDescriptor == undefined) { - return undefined; - } - - if (typeof locationDescriptor === 'string') { - return { to: locationDescriptor }; - } - - const { redirect, replace, state, ...to } = locationDescriptor; - return { - to, - redirect, - replace, - state, - }; -}; From 5551eab22bd8e79d8181b034550c227f68da9166 Mon Sep 17 00:00:00 2001 From: Matthieu Chaffotte Date: Mon, 2 Oct 2023 14:42:43 +0200 Subject: [PATCH 14/17] feat: use record representation --- docs/Create.md | 4 ++-- examples/demo/src/reviews/ReviewCreate.tsx | 8 +------- examples/demo/src/visitors/index.ts | 2 ++ packages/ra-ui-materialui/src/button/CreateButton.tsx | 11 ++++++++++- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/docs/Create.md b/docs/Create.md index 8502090db21..bbd90646474 100644 --- a/docs/Create.md +++ b/docs/Create.md @@ -428,12 +428,12 @@ You sometimes need to pre-populate a record based on a *related* record. For ins By default, the `` view starts with an empty `record`. However, if the `location` object (injected by [react-router-dom](https://reacttraining.com/react-router/web/api/location)) contains a `record` in its `state`, the `` view uses that `record` instead of the empty object. That's how the `` works under the hood. -That means that if you want to create a link to a creation form, presetting *some* values, all you have to do is to set the prop `state` of the ``: +That means that if you want to create a link to a creation form, presetting *some* values, all you have to do is to set the `state` prop of the ``: {% raw %} ```jsx import * as React from 'react'; -import { CreateButton, Datagrid, useRecordContext } from 'react-admin'; +import { CreateButton, Datagrid, List, useRecordContext } from 'react-admin'; const CreateRelatedCommentButton = () => { const record = useRecordContext(); diff --git a/examples/demo/src/reviews/ReviewCreate.tsx b/examples/demo/src/reviews/ReviewCreate.tsx index 9ed8d9bbe04..88160ccc3f3 100644 --- a/examples/demo/src/reviews/ReviewCreate.tsx +++ b/examples/demo/src/reviews/ReviewCreate.tsx @@ -34,10 +34,7 @@ const ReviewCreate = () => { - + { ); }; -const customerOptionRenderer = (choice: any) => - `${choice.first_name} ${choice.last_name}`; - export default ReviewCreate; diff --git a/examples/demo/src/visitors/index.ts b/examples/demo/src/visitors/index.ts index 510d038769a..5345f0ee500 100644 --- a/examples/demo/src/visitors/index.ts +++ b/examples/demo/src/visitors/index.ts @@ -9,6 +9,8 @@ const resource = { create: VisitorCreate, edit: VisitorEdit, icon: VisitorIcon, + recordRepresentation: (record: any) => + `${record.first_name} ${record.last_name}`, }; export default resource; diff --git a/packages/ra-ui-materialui/src/button/CreateButton.tsx b/packages/ra-ui-materialui/src/button/CreateButton.tsx index 93e14a7ab26..bb862a9254b 100644 --- a/packages/ra-ui-materialui/src/button/CreateButton.tsx +++ b/packages/ra-ui-materialui/src/button/CreateButton.tsx @@ -8,7 +8,12 @@ import PropTypes from 'prop-types'; import { useTranslate, useResourceContext, useCreatePath } from 'ra-core'; import { Link, To } from 'react-router-dom'; -import { Button, ButtonProps, LocationDescriptor } from './Button'; +import { + Button, + ButtonProps, + LocationDescriptor, + getLinkParams, +} from './Button'; /** * Opens the Create view of a given resource @@ -43,6 +48,8 @@ const CreateButton = (props: CreateButtonProps) => { theme.breakpoints.down('md') ); const state = merge(scrollStates[String(scrollToTop)], initialState); + // Duplicated behaviour of Button component (legacy use) which will be removed in v5. + const linkParams = getLinkParams(locationDescriptor); return isSmall ? ( { className={clsx(CreateButtonClasses.floating, className)} aria-label={label && translate(label)} {...rest} + {...linkParams} > {icon} @@ -66,6 +74,7 @@ const CreateButton = (props: CreateButtonProps) => { label={label} variant={variant} {...(rest as any)} + {...linkParams} > {icon}
From 8f483e50879b845103eb9f247265c6638d5dc52b Mon Sep 17 00:00:00 2001 From: Matthieu Chaffotte Date: Tue, 3 Oct 2023 10:11:07 +0200 Subject: [PATCH 15/17] feat: duplicate To feature in order to ease the deletion in v5 --- .../ra-ui-materialui/src/button/Button.tsx | 4 +-- .../src/button/CreateButton.tsx | 26 ++++++++++++++----- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/packages/ra-ui-materialui/src/button/Button.tsx b/packages/ra-ui-materialui/src/button/Button.tsx index 28d8ffece10..eb88caa560f 100644 --- a/packages/ra-ui-materialui/src/button/Button.tsx +++ b/packages/ra-ui-materialui/src/button/Button.tsx @@ -141,9 +141,7 @@ const StyledButton = styled(MuiButton, { }, }); -export const getLinkParams = ( - locationDescriptor?: LocationDescriptor | string -) => { +const getLinkParams = (locationDescriptor?: LocationDescriptor | string) => { // eslint-disable-next-line eqeqeq if (locationDescriptor == undefined) { return undefined; diff --git a/packages/ra-ui-materialui/src/button/CreateButton.tsx b/packages/ra-ui-materialui/src/button/CreateButton.tsx index bb862a9254b..fe27dc97f00 100644 --- a/packages/ra-ui-materialui/src/button/CreateButton.tsx +++ b/packages/ra-ui-materialui/src/button/CreateButton.tsx @@ -8,12 +8,7 @@ import PropTypes from 'prop-types'; import { useTranslate, useResourceContext, useCreatePath } from 'ra-core'; import { Link, To } from 'react-router-dom'; -import { - Button, - ButtonProps, - LocationDescriptor, - getLinkParams, -} from './Button'; +import { Button, ButtonProps, LocationDescriptor } from './Button'; /** * Opens the Create view of a given resource @@ -142,3 +137,22 @@ export default React.memo(CreateButton, (prevProps, nextProps) => { isEqual(prevProps.to, nextProps.to) ); }); + +const getLinkParams = (locationDescriptor?: LocationDescriptor | string) => { + // eslint-disable-next-line eqeqeq + if (locationDescriptor == undefined) { + return undefined; + } + + if (typeof locationDescriptor === 'string') { + return { to: locationDescriptor }; + } + + const { redirect, replace, state, ...to } = locationDescriptor; + return { + to, + redirect, + replace, + state, + }; +}; From 8e33bb45b6506a6ef0c906d7435c2295b54ec561 Mon Sep 17 00:00:00 2001 From: Matthieu Chaffotte Date: Thu, 5 Oct 2023 10:09:22 +0200 Subject: [PATCH 16/17] feat: apply review --- docs/Create.md | 2 +- examples/demo/src/reviews/ReviewCreate.tsx | 4 ++-- packages/ra-ui-materialui/src/button/CreateButton.tsx | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/Create.md b/docs/Create.md index bbd90646474..c49ed6665a1 100644 --- a/docs/Create.md +++ b/docs/Create.md @@ -467,7 +467,7 @@ const CreateRelatedCommentButton = () => { const record = useRecordContext(); return ( { const notify = useNotify(); @@ -32,7 +32,7 @@ const ReviewCreate = () => { return ( - + diff --git a/packages/ra-ui-materialui/src/button/CreateButton.tsx b/packages/ra-ui-materialui/src/button/CreateButton.tsx index fe27dc97f00..a6884db3426 100644 --- a/packages/ra-ui-materialui/src/button/CreateButton.tsx +++ b/packages/ra-ui-materialui/src/button/CreateButton.tsx @@ -77,10 +77,10 @@ const CreateButton = (props: CreateButtonProps) => { }; // avoids using useMemo to get a constant value for the link state -const scrollStates = { - true: { _scrollToTop: true }, - false: {}, -}; +const scrollStates = new Map([ + ['true', { _scrollToTop: true }], + ['false', {}], +]); const defaultIcon = ; From c2956f4037f9d4570ebe562f130bfed6593ca1d6 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Kaiser Date: Thu, 5 Oct 2023 11:23:48 +0200 Subject: [PATCH 17/17] Update packages/ra-ui-materialui/src/button/CreateButton.tsx --- packages/ra-ui-materialui/src/button/CreateButton.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ra-ui-materialui/src/button/CreateButton.tsx b/packages/ra-ui-materialui/src/button/CreateButton.tsx index a6884db3426..cfbe21c0d90 100644 --- a/packages/ra-ui-materialui/src/button/CreateButton.tsx +++ b/packages/ra-ui-materialui/src/button/CreateButton.tsx @@ -42,7 +42,7 @@ const CreateButton = (props: CreateButtonProps) => { const isSmall = useMediaQuery((theme: Theme) => theme.breakpoints.down('md') ); - const state = merge(scrollStates[String(scrollToTop)], initialState); + const state = merge(scrollStates.get(String(scrollToTop)), initialState); // Duplicated behaviour of Button component (legacy use) which will be removed in v5. const linkParams = getLinkParams(locationDescriptor);