From 6d92fca4a482e438793699f66882eda7a9ef048b Mon Sep 17 00:00:00 2001 From: Lukas Date: Wed, 5 Jun 2024 16:25:36 +0300 Subject: [PATCH] [core] Fixes in preparation for React 18.3 (#13378) --- .../GridFilterInputMultipleSingleSelect.tsx | 20 ++++--- .../x-date-pickers-pro/src/models/fields.ts | 8 +-- .../src/PickersLayout/PickersLayout.types.ts | 17 +++--- .../components/PickersToolbarButton.tsx | 52 ++++++++++--------- 4 files changed, 51 insertions(+), 46 deletions(-) diff --git a/packages/x-data-grid/src/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.tsx b/packages/x-data-grid/src/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.tsx index 1319523e7948..0e1674bb1255 100644 --- a/packages/x-data-grid/src/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.tsx +++ b/packages/x-data-grid/src/components/panel/filterPanel/GridFilterInputMultipleSingleSelect.tsx @@ -108,14 +108,18 @@ function GridFilterInputMultipleSingleSelect(props: GridFilterInputMultipleSingl onChange={handleChange} getOptionLabel={getOptionLabel} renderTags={(value, getTagProps) => - value.map((option, index) => ( - - )) + value.map((option, index) => { + const { key, ...tagProps } = getTagProps({ index }); + return ( + + ); + }) } renderInput={(params) => ( >; textField?: SlotComponentProps< - React.ElementType, + typeof TextField, {}, - { position?: 'start' | 'end' } & Record + { position?: RangePosition } & Record >; }; } diff --git a/packages/x-date-pickers/src/PickersLayout/PickersLayout.types.ts b/packages/x-date-pickers/src/PickersLayout/PickersLayout.types.ts index 32cb59af51f4..c7ea79e908dc 100644 --- a/packages/x-date-pickers/src/PickersLayout/PickersLayout.types.ts +++ b/packages/x-date-pickers/src/PickersLayout/PickersLayout.types.ts @@ -1,14 +1,17 @@ import * as React from 'react'; import { SxProps, Theme } from '@mui/material/styles'; import { SlotComponentProps } from '@mui/base/utils'; -import { PickersActionBarProps } from '../PickersActionBar'; +import { PickersActionBar, PickersActionBarProps } from '../PickersActionBar'; import { BaseToolbarProps, ExportedBaseToolbarProps } from '../internals/models/props/toolbar'; import { BaseTabsProps, ExportedBaseTabsProps } from '../internals/models/props/tabs'; import { UsePickerLayoutPropsResponseLayoutProps } from '../internals/hooks/usePicker/usePickerLayoutProps'; import { PickersLayoutClasses } from './pickersLayoutClasses'; import { DateOrTimeViewWithMeridiem, WrapperVariant } from '../internals/models/common'; import { PickersShortcutsProps } from '../PickersShortcuts'; -import { ExportedPickersShortcutProps } from '../PickersShortcuts/PickersShortcuts'; +import { + ExportedPickersShortcutProps, + PickersShortcuts, +} from '../PickersShortcuts/PickersShortcuts'; import { PickerValidDate } from '../models'; export interface ExportedPickersLayoutSlots< @@ -56,20 +59,14 @@ export interface ExportedPickersLayoutSlotProps< * Props passed down to the action bar component. */ actionBar?: SlotComponentProps< - React.ComponentType< - Omit - >, + typeof PickersActionBar, {}, PickersLayoutActionBarOwnerState >; /** * Props passed down to the shortcuts component. */ - shortcuts?: SlotComponentProps< - React.ComponentType>, - {}, - PickersShortcutsOwnerState - >; + shortcuts?: SlotComponentProps>; /** * Props passed down to the layoutRoot component. */ diff --git a/packages/x-date-pickers/src/internals/components/PickersToolbarButton.tsx b/packages/x-date-pickers/src/internals/components/PickersToolbarButton.tsx index f49ced45e02c..17b44028ca76 100644 --- a/packages/x-date-pickers/src/internals/components/PickersToolbarButton.tsx +++ b/packages/x-date-pickers/src/internals/components/PickersToolbarButton.tsx @@ -38,30 +38,32 @@ const PickersToolbarButtonRoot = styled(Button, { textTransform: 'none', }); -export const PickersToolbarButton: React.FunctionComponent = - React.forwardRef(function PickersToolbarButton(inProps, ref) { - const props = useThemeProps({ props: inProps, name: 'MuiPickersToolbarButton' }); - const { align, className, selected, typographyClassName, value, variant, width, ...other } = - props; +export const PickersToolbarButton = React.forwardRef(function PickersToolbarButton( + inProps: PickersToolbarButtonProps, + ref: React.Ref, +) { + const props = useThemeProps({ props: inProps, name: 'MuiPickersToolbarButton' }); + const { align, className, selected, typographyClassName, value, variant, width, ...other } = + props; - const classes = useUtilityClasses(props); + const classes = useUtilityClasses(props); - return ( - - - - ); - }); + return ( + + + + ); +});