From 6fb5cefb0f3f130ad6cc4aee4fa7bd7dae8cbebd Mon Sep 17 00:00:00 2001 From: flavien Date: Tue, 19 Nov 2024 18:28:02 +0100 Subject: [PATCH] [pickers] Remove orientation, isLandscape, isRtl, wrapperVariant and disabled props from PickersLayout --- .../custom-components/custom-components.md | 4 +- .../custom-layout/AddComponent.js | 4 +- .../custom-layout/AddComponent.tsx | 4 +- .../custom-layout/custom-layout.md | 4 +- .../MobileKeyboardView.js | 104 ++--------------- .../MobileKeyboardView.tsx | 110 ------------------ .../MobileKeyboardView.tsx.preview | 6 - .../migration-pickers-v5.md | 2 +- .../migration-pickers-v7.md | 46 ++++++++ .../x/api/date-pickers/pickers-layout.json | 4 - .../components/overview/mainDemo/Clock.tsx | 4 +- .../mainDemo/DateRangeWithShortcuts.tsx | 4 +- .../overview/mainDemo/DigitalClock.tsx | 4 +- .../pickers-layout/pickers-layout.json | 4 - .../DesktopDateTimePickerLayout.tsx | 23 +--- .../src/PickersLayout/PickersLayout.tsx | 53 +++++---- .../src/PickersLayout/PickersLayout.types.ts | 19 +-- .../src/PickersLayout/usePickerLayout.tsx | 31 ++--- .../src/internals/hooks/useIsLandscape.tsx | 48 -------- .../internals/hooks/usePicker/usePicker.ts | 13 +-- .../hooks/usePicker/usePicker.types.ts | 6 +- .../hooks/usePicker/usePickerLayoutProps.ts | 62 ---------- 22 files changed, 136 insertions(+), 423 deletions(-) delete mode 100644 docs/data/migration/migration-pickers-v5/MobileKeyboardView.tsx delete mode 100644 docs/data/migration/migration-pickers-v5/MobileKeyboardView.tsx.preview delete mode 100644 packages/x-date-pickers/src/internals/hooks/useIsLandscape.tsx delete mode 100644 packages/x-date-pickers/src/internals/hooks/usePicker/usePickerLayoutProps.ts diff --git a/docs/data/date-pickers/custom-components/custom-components.md b/docs/data/date-pickers/custom-components/custom-components.md index e05e9c6e808ab..ab573ddf7a56f 100644 --- a/docs/data/date-pickers/custom-components/custom-components.md +++ b/docs/data/date-pickers/custom-components/custom-components.md @@ -34,8 +34,8 @@ You can override the actions displayed by passing the `actions` prop to the `act actions: ['clear'], }, // The actions will be different between desktop and mobile - actionBar: ({ wrapperVariant }) => ({ - actions: wrapperVariant === 'desktop' ? [] : ['clear'], + actionBar: ({ variant }) => ({ + actions: variant === 'desktop' ? [] : ['clear'], }), }} /> diff --git a/docs/data/date-pickers/custom-layout/AddComponent.js b/docs/data/date-pickers/custom-layout/AddComponent.js index d6e0d1db8b6fe..a44d4f0f1895a 100644 --- a/docs/data/date-pickers/custom-layout/AddComponent.js +++ b/docs/data/date-pickers/custom-layout/AddComponent.js @@ -58,11 +58,11 @@ function RestaurantHeader() { } function CustomLayout(props) { - const { toolbar, tabs, content, actionBar } = usePickerLayout(props); + const { toolbar, tabs, content, actionBar, ownerState } = usePickerLayout(props); return ( ) { - const { toolbar, tabs, content, actionBar } = usePickerLayout(props); + const { toolbar, tabs, content, actionBar, ownerState } = usePickerLayout(props); return ( + {toolbar} {actionBar} diff --git a/docs/data/migration/migration-pickers-v5/MobileKeyboardView.js b/docs/data/migration/migration-pickers-v5/MobileKeyboardView.js index 95819b45ed99f..c2810ae4c1e2f 100644 --- a/docs/data/migration/migration-pickers-v5/MobileKeyboardView.js +++ b/docs/data/migration/migration-pickers-v5/MobileKeyboardView.js @@ -1,100 +1,16 @@ import * as React from 'react'; -import Box from '@mui/material/Box'; -import Stack from '@mui/material/Stack'; -import IconButton from '@mui/material/IconButton'; -import ModeEditIcon from '@mui/icons-material/ModeEdit'; -import CalendarMonthIcon from '@mui/icons-material/CalendarMonth'; -import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider'; -import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'; - -import { - pickersLayoutClasses, - PickersLayoutContentWrapper, - PickersLayoutRoot, - usePickerLayout, -} from '@mui/x-date-pickers/PickersLayout'; -import { MobileDatePicker } from '@mui/x-date-pickers/MobileDatePicker'; -import { DateField } from '@mui/x-date-pickers/DateField'; -import { DatePickerToolbar } from '@mui/x-date-pickers/DatePicker'; - -function LayoutWithKeyboardView(props) { - const { value, onChange } = props; - const [showKeyboardView, setShowKeyboardView] = React.useState(false); - - const { toolbar, tabs, content, actionBar } = usePickerLayout({ - ...props, - slotProps: { - ...props.slotProps, - toolbar: { - ...props.slotProps?.toolbar, - // @ts-ignore - showKeyboardViewSwitch: props.wrapperVariant === 'mobile', - showKeyboardView, - setShowKeyboardView, - }, - }, - }); - - return ( - - {toolbar} - {actionBar} - - {tabs} - {showKeyboardView ? ( - - - - ) : ( - content - )} - - - ); -} - -function ToolbarWithKeyboardViewSwitch(props) { - const { showKeyboardViewSwitch, showKeyboardView, setShowKeyboardView, ...other } = - props; - - if (showKeyboardViewSwitch) { - return ( - - - setShowKeyboardView((prev) => !prev)} - > - {showKeyboardView ? : } - - - ); - } - - return ; -} export default function MobileKeyboardView() { return ( - - - +