-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pickers] Remove orientation, isLandscape, isRtl, wrapperVariant and …
…disabled props from PickersLayout
- Loading branch information
1 parent
c73f6af
commit 6fb5cef
Showing
22 changed files
with
136 additions
and
423 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 10 additions & 94 deletions
104
docs/data/migration/migration-pickers-v5/MobileKeyboardView.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<PickersLayoutRoot ownerState={props}> | ||
{toolbar} | ||
{actionBar} | ||
<PickersLayoutContentWrapper className={pickersLayoutClasses.contentWrapper}> | ||
{tabs} | ||
{showKeyboardView ? ( | ||
<Box sx={{ mx: 3, my: 2, width: 272 }}> | ||
<DateField value={value} onChange={onChange} sx={{ width: '100%' }} /> | ||
</Box> | ||
) : ( | ||
content | ||
)} | ||
</PickersLayoutContentWrapper> | ||
</PickersLayoutRoot> | ||
); | ||
} | ||
|
||
function ToolbarWithKeyboardViewSwitch(props) { | ||
const { showKeyboardViewSwitch, showKeyboardView, setShowKeyboardView, ...other } = | ||
props; | ||
|
||
if (showKeyboardViewSwitch) { | ||
return ( | ||
<Stack | ||
spacing={2} | ||
direction={other.isLandscape ? 'column' : 'row'} | ||
alignItems="center" | ||
sx={ | ||
other.isLandscape | ||
? { | ||
gridColumn: 1, | ||
gridRow: '1 / 3', | ||
} | ||
: { gridColumn: '1 / 4', gridRow: 1, mr: 1 } | ||
} | ||
> | ||
<DatePickerToolbar {...other} sx={{ flex: '1 1 100%' }} /> | ||
<IconButton | ||
color="inherit" | ||
onClick={() => setShowKeyboardView((prev) => !prev)} | ||
> | ||
{showKeyboardView ? <CalendarMonthIcon /> : <ModeEditIcon />} | ||
</IconButton> | ||
</Stack> | ||
); | ||
} | ||
|
||
return <DatePickerToolbar {...other} />; | ||
} | ||
export default function MobileKeyboardView() { | ||
return ( | ||
<LocalizationProvider dateAdapter={AdapterDayjs}> | ||
<MobileDatePicker | ||
slots={{ | ||
layout: LayoutWithKeyboardView, | ||
toolbar: ToolbarWithKeyboardViewSwitch, | ||
}} | ||
/> | ||
</LocalizationProvider> | ||
<iframe | ||
title="codesandbox" | ||
src="https://codesandbox.io/embed/https-mui-com-x-migration-migration-pickers-v7-forked-9fz6f6?hidenavigation=1&fontsize=14&view=preview" | ||
style={{ | ||
width: '100%', | ||
height: 520, | ||
border: 0, | ||
}} | ||
sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin" | ||
/> | ||
); | ||
} |
110 changes: 0 additions & 110 deletions
110
docs/data/migration/migration-pickers-v5/MobileKeyboardView.tsx
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
docs/data/migration/migration-pickers-v5/MobileKeyboardView.tsx.preview
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.