The date range picker let the user select a range of dates.
-## Basic usage +:::warning +The new date range pickers are unstable. +They might receive breaking changes on their props to have the best component possible by the time of the stable release. + +They will be renamed at the end of the v6 beta phase to have the same name as the current legacy pickers +(`NextDateRangePicker` will become `DateRangePicker`, ...) +::: -Note that you can pass almost any prop from [DatePicker](/x/react-date-pickers/date-picker/). +:::info +You can pass almost any prop from [NextDatePicker](/x/react-date-pickers/date-picker/) to the Date Range Picker. +::: + +## Basic usage {{"demo": "BasicDateRangePicker.js"}} -## Static mode +## Uncontrolled vs. Controlled -It's possible to render any picker inline. This will enable building custom popover/modal containers. +The component can be uncontrolled or controlled -{{"demo": "StaticDateRangePickerDemo.js", "bg": true}} +{{"demo": "DateRangePickerValue.js"}} ## Responsiveness The date range picker component is designed to be optimized for the device it runs on. -- The `MobileDateRangePicker` component works best for touch devices and small screens. -- The `DesktopDateRangePicker` component works best for mouse devices and large screens. +- The `MobileNextDateRangePicker` component works best for touch devices and small screens. +- The `DesktopNextDateRangePicker` component works best for mouse devices and large screens. -By default, the `DateRangePicker` component renders the desktop version if the media query [`@media (pointer: fine)`](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/pointer) matches. +By default, the `NextDateRangePicker` component renders the desktop version if the media query [`@media (pointer: fine)`](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/pointer) matches. This can be customized with the `desktopModeMediaQuery` prop. There are certain caveats when testing pickers, please refer to [this section](/x/react-date-pickers/getting-started/#testing-caveats) for more information. {{"demo": "ResponsiveDateRangePicker.js"}} +## Static mode + +It is also possible to render any date range picker without the modal/popover and text field. +This will enable building custom popover/modal containers. + +{{"demo": "StaticDateRangePickerDemo.js", "bg": true}} + ## Form props The date range picker component can be disabled or read-only. @@ -55,10 +72,10 @@ Note that the `calendars` prop only works in desktop mode. ## Custom input component -You can customize the rendered input with the `renderInput` prop. For `DateRangePicker` it takes **2** parameters – for start and end input respectively. -If you need to render custom inputs make sure to spread `ref` and `inputProps` correctly to the input components. +You can customize the rendering of the input with the `Input` component slot. +Make sure to spread `inputProps` correctly to the custom input component. -{{"demo": "CustomDateRangeInputs.js"}} +{{"demo": "CustomInputs.js"}} ## Customized day rendering diff --git a/docs/data/date-pickers/date-time-picker/BasicDateTimePicker.js b/docs/data/date-pickers/date-time-picker/BasicDateTimePicker.js index 860a91e21005e..8a4ed283fc387 100644 --- a/docs/data/date-pickers/date-time-picker/BasicDateTimePicker.js +++ b/docs/data/date-pickers/date-time-picker/BasicDateTimePicker.js @@ -1,23 +1,12 @@ import * as React from 'react'; -import dayjs from 'dayjs'; -import TextField from '@mui/material/TextField'; import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'; import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider'; -import { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker'; +import { Unstable_NextDateTimePicker as NextDateTimePicker } from '@mui/x-date-pickers/NextDateTimePicker'; export default function BasicDateTimePicker() { - const [value, setValue] = React.useState(dayjs('2022-04-07')); - return (This component combines the date & time pickers.
+:::warning +The new date time pickers are unstable. +They might receive breaking changes on their props to have the best component possible by the time of the stable release. + +They will be renamed at the end of the v6 beta phase to have the same name as the current legacy pickers +(`NextDateTimePicker` will become `DateTimePicker`, ...) +::: + It allows the user to select both date and time with the same control. -Note that this component is the [DatePicker](/x/react-date-pickers/date-picker/) and [TimePicker](/x/react-date-pickers/time-picker/) +Note that this component is the [NextDatePicker](/x/react-date-pickers/date-picker/) and [NextTimePicker](/x/react-date-pickers/time-picker/) component combined, so any of these components' props can be passed to the DateTimePicker. ## Basic usage @@ -22,20 +30,33 @@ Allows choosing date then time. There are 4 steps available (year, date, hour, a {{"demo": "BasicDateTimePicker.js"}} +## Uncontrolled vs. Controlled + +The component can be uncontrolled or controlled + +{{"demo": "DateTimePickerValue.js"}} + ## Responsiveness -The `DateTimePicker` component is designed and optimized for the device it runs on. +The `NextDateTimePicker` component is designed and optimized for the device it runs on. -- The `MobileDateTimePicker` component works best for touch devices and small screens. -- The `DesktopDateTimePicker` component works best for mouse devices and large screens. +- The `MobileNextDateTimePicker` component works best for touch devices and small screens. +- The `DesktopNextDateTimePicker` component works best for mouse devices and large screens. -By default, the `DateTimePicker` component renders the desktop version if the media query [`@media (pointer: fine)`](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/pointer) matches. +By default, the `NextDateTimePicker` component renders the desktop version if the media query [`@media (pointer: fine)`](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/pointer) matches. This can be customized with the `desktopModeMediaQuery` prop. There are certain caveats when testing pickers, please refer to [this section](/x/react-date-pickers/getting-started/#testing-caveats) for more information. {{"demo": "ResponsiveDateTimePickers.js"}} +## Static mode + +It is also possible to render any date time picker without the modal/popover and text field. +This will enable building custom popover/modal containers. + +{{"demo": "StaticDateTimePickerDemo.js", "bg": true}} + ## Form props The date time picker component can be disabled or read-only. @@ -46,12 +67,6 @@ The date time picker component can be disabled or read-only. You can find the documentation in the [Validation page](/x/react-date-pickers/validation/) -## Static mode - -It's possible to render any date & time picker inline. This will enable building custom popover/modal containers. - -{{"demo": "StaticDateTimePickerDemo.js", "bg": true}} - ## Customization Here are some examples of heavily customized date & time pickers: diff --git a/docs/data/date-pickers/legacy-date-range-picker/BasicDateRangePicker.js b/docs/data/date-pickers/legacy-date-range-picker/BasicDateRangePicker.js new file mode 100644 index 0000000000000..65d20083e3bce --- /dev/null +++ b/docs/data/date-pickers/legacy-date-range-picker/BasicDateRangePicker.js @@ -0,0 +1,30 @@ +import * as React from 'react'; + +import TextField from '@mui/material/TextField'; +import Box from '@mui/material/Box'; +import { LocalizationProvider } from '@mui/x-date-pickers-pro'; +import { AdapterDayjs } from '@mui/x-date-pickers-pro/AdapterDayjs'; +import { DateRangePicker } from '@mui/x-date-pickers-pro/DateRangePicker'; + +export default function BasicDateRangePicker() { + const [value, setValue] = React.useState([null, null]); + + return ( +The date range picker let the user select a range of dates.
+ +:::warning +This page describes how the legacy date range pickers work. +If you are already using the v6 alpha or beta, we recommend you to try the [new date range pickers](/x/react-date-pickers/date-range-picker/). + +At the end of the v6 beta phase, the legacy date range pickers will be removed and replaced the new date range pickers +(which will be renamed to match the current name of the legacy pickers). +::: + +## Basic usage + +Note that you can pass almost any prop from [DatePicker](/x/react-date-pickers/legacy-date-picker/). + +{{"demo": "BasicDateRangePicker.js"}} + +## Static mode + +It's possible to render any picker inline. This will enable building custom popover/modal containers. + +{{"demo": "StaticDateRangePickerDemo.js", "bg": true}} + +## Responsiveness + +The date range picker component is designed to be optimized for the device it runs on. + +- The `MobileDateRangePicker` component works best for touch devices and small screens. +- The `DesktopDateRangePicker` component works best for mouse devices and large screens. + +By default, the `DateRangePicker` component renders the desktop version if the media query [`@media (pointer: fine)`](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/pointer) matches. +This can be customized with the `desktopModeMediaQuery` prop. + +There are certain caveats when testing pickers, please refer to [this section](/x/react-date-pickers/getting-started/#testing-caveats) for more information. + +{{"demo": "ResponsiveDateRangePicker.js"}} + +## Form props + +The date range picker component can be disabled or read-only. + +{{"demo": "FormPropsDateRangePickers.js"}} + +## Validation + +You can find the documentation in the [Validation page](/x/react-date-pickers/validation/) + +## Different number of months + +Note that the `calendars` prop only works in desktop mode. + +{{"demo": "CalendarsDateRangePicker.js"}} + +## Custom input component + +You can customize the rendered input with the `renderInput` prop. For `DateRangePicker` it takes **2** parameters – for start and end input respectively. +If you need to render custom inputs make sure to spread `ref` and `inputProps` correctly to the input components. + +{{"demo": "CustomDateRangeInputs.js"}} + +## Customized day rendering + +The displayed days are customizable with the `Day` component slot. +You can take advantage of the internal [DateRangePickerDay](/x/api/date-pickers/date-range-picker-day/) component. + +{{"demo": "CustomDateRangePickerDay.js"}} diff --git a/docs/data/date-pickers/legacy-date-time-picker/BasicDateTimePicker.js b/docs/data/date-pickers/legacy-date-time-picker/BasicDateTimePicker.js new file mode 100644 index 0000000000000..860a91e21005e --- /dev/null +++ b/docs/data/date-pickers/legacy-date-time-picker/BasicDateTimePicker.js @@ -0,0 +1,23 @@ +import * as React from 'react'; +import dayjs from 'dayjs'; +import TextField from '@mui/material/TextField'; +import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'; +import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider'; +import { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker'; + +export default function BasicDateTimePicker() { + const [value, setValue] = React.useState(dayjs('2022-04-07')); + + return ( +This component combines the date & time pickers.
+ +:::warning +This page describes how the legacy date time pickers work. +If you are already using the v6 alpha or beta, we recommend you to try the [new date time pickers](/x/react-date-pickers/date-time-picker/). + +At the end of the v6 beta phase, the legacy date time pickers will be removed and replaced the new date time pickers +(which will be renamed to match the current name of the legacy pickers). +::: + +It allows the user to select both date and time with the same control. + +Note that this component is the [DatePicker](/x/react-date-pickers/legacy-date-picker/) and [TimePicker](/x/react-date-pickers/legacy-time-picker/) +component combined, so any of these components' props can be passed to the DateTimePicker. + +## Basic usage + +Allows choosing date then time. There are 4 steps available (year, date, hour, and minute), so tabs are required to visually distinguish date/time steps. + +{{"demo": "BasicDateTimePicker.js"}} + +## Responsiveness + +The `DateTimePicker` component is designed and optimized for the device it runs on. + +- The `MobileDateTimePicker` component works best for touch devices and small screens. +- The `DesktopDateTimePicker` component works best for mouse devices and large screens. + +By default, the `DateTimePicker` component renders the desktop version if the media query [`@media (pointer: fine)`](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/pointer) matches. +This can be customized with the `desktopModeMediaQuery` prop. + +There are certain caveats when testing pickers, please refer to [this section](/x/react-date-pickers/getting-started/#testing-caveats) for more information. + +{{"demo": "ResponsiveDateTimePickers.js"}} + +## Form props + +The date time picker component can be disabled or read-only. + +{{"demo": "FormPropsDateTimePickers.js"}} + +## Validation + +You can find the documentation in the [Validation page](/x/react-date-pickers/validation/) + +## Static mode + +It's possible to render any date & time picker inline. This will enable building custom popover/modal containers. + +{{"demo": "StaticDateTimePickerDemo.js", "bg": true}} + +## Customization + +Here are some examples of heavily customized date & time pickers: + +{{"demo": "CustomDateTimePicker.js"}} diff --git a/docs/data/date-pickers/legacy-time-picker/BasicTimePicker.js b/docs/data/date-pickers/legacy-time-picker/BasicTimePicker.js new file mode 100644 index 0000000000000..3d4c5c8dd7e89 --- /dev/null +++ b/docs/data/date-pickers/legacy-time-picker/BasicTimePicker.js @@ -0,0 +1,23 @@ +import * as React from 'react'; + +import TextField from '@mui/material/TextField'; +import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'; +import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider'; +import { TimePicker } from '@mui/x-date-pickers/TimePicker'; + +export default function BasicTimePicker() { + const [value, setValue] = React.useState(null); + + return ( +Time pickers allow the user to select a single time.
+ +:::warning +This page describes how the legacy time pickers work. +If you are already using the v6 alpha or beta, we recommend you to try the [new time pickers](/x/react-date-pickers/time-picker/). + +At the end of the v6 beta phase, the legacy time pickers will be removed and replaced the new time pickers +(which will be renamed to match the current name of the legacy pickers). +::: + +The selected time is indicated by the filled circle at the end of the clock hand. + +## Basic usage + +The time picker is rendered as a modal dialog on mobile, and a textbox with a popup on desktop. + +{{"demo": "BasicTimePicker.js"}} + +## Static mode + +It's possible to render any time picker inline. This will enable building custom popover/modal containers. + +{{"demo": "StaticTimePickerDemo.js", "bg": true}} + +## Responsiveness + +The time picker component is designed and optimized for the device it runs on. + +- The `MobileTimePicker` component works best for touch devices and small screens. +- The `DesktopTimePicker` component works best for mouse devices and large screens. + +By default, the `TimePicker` component renders the desktop version if the media query [`@media (pointer: fine)`](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/pointer) matches. +This can be customized with the `desktopModeMediaQuery` prop. + +There are certain caveats when testing pickers, please refer to [this section](/x/react-date-pickers/getting-started/#testing-caveats) for more information. + +{{"demo": "ResponsiveTimePickers.js"}} + +## Form props + +The time picker component can be disabled or read-only. + +{{"demo": "FormPropsTimePickers.js"}} + +## Validation + +You can find the documentation in the [Validation page](/x/react-date-pickers/validation/) + +## Landscape + +{{"demo": "StaticTimePickerLandscape.js", "bg": true}} + +## Sub-components + +Some lower-level sub-components (`ClockPicker`) are also exported. + +{{"demo": "SubComponentsTimeCalendars.js"}} + +## Seconds + +The seconds input can be used for selection of a precise time point. + +{{"demo": "SecondsTimePicker.js"}} diff --git a/docs/data/date-pickers/time-picker/BasicTimePicker.js b/docs/data/date-pickers/time-picker/BasicTimePicker.js index 3d4c5c8dd7e89..0e60ca6f6c0e4 100644 --- a/docs/data/date-pickers/time-picker/BasicTimePicker.js +++ b/docs/data/date-pickers/time-picker/BasicTimePicker.js @@ -1,23 +1,12 @@ import * as React from 'react'; - -import TextField from '@mui/material/TextField'; import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'; import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider'; -import { TimePicker } from '@mui/x-date-pickers/TimePicker'; +import { Unstable_NextTimePicker as NextTimePicker } from '@mui/x-date-pickers/NextTimePicker'; export default function BasicTimePicker() { - const [value, setValue] = React.useState(null); - return (Time pickers allow the user to select a single time.
+:::warning +The new time pickers are unstable. +They might receive breaking changes on their props to have the best component possible by the time of the stable release. + +They will be renamed at the end of the v6 beta phase to have the same name as the current legacy pickers +(`NextTimePicker` will become `TimePicker`, ...) +::: + The selected time is indicated by the filled circle at the end of the clock hand. ## Basic usage -The time picker is rendered as a modal dialog on mobile, and a textbox with a popup on desktop. +The time picker is rendered as a modal dialog on mobile, and in the field on desktop. {{"demo": "BasicTimePicker.js"}} -## Static mode +## Uncontrolled vs. Controlled -It's possible to render any time picker inline. This will enable building custom popover/modal containers. +The component can be uncontrolled or controlled -{{"demo": "StaticTimePickerDemo.js", "bg": true}} +{{"demo": "TimePickerValue.js"}} ## Responsiveness The time picker component is designed and optimized for the device it runs on. -- The `MobileTimePicker` component works best for touch devices and small screens. -- The `DesktopTimePicker` component works best for mouse devices and large screens. +- The `MobileNextTimePicker` component works best for touch devices and small screens. +- The `DesktopNextTimePicker` component works best for mouse devices and large screens. -By default, the `TimePicker` component renders the desktop version if the media query [`@media (pointer: fine)`](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/pointer) matches. +By default, the `NextTimePicker` component renders the desktop version if the media query [`@media (pointer: fine)`](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/pointer) matches. This can be customized with the `desktopModeMediaQuery` prop. There are certain caveats when testing pickers, please refer to [this section](/x/react-date-pickers/getting-started/#testing-caveats) for more information. {{"demo": "ResponsiveTimePickers.js"}} +## Static mode + +It is also possible to render any time picker without the modal/popover and text field. +This will enable building custom popover/modal containers. + +{{"demo": "StaticTimePickerDemo.js", "bg": true}} + ## Form props The time picker component can be disabled or read-only. diff --git a/docs/data/pages.ts b/docs/data/pages.ts index 778fd802ffe1e..1bd7466b9b7b4 100644 --- a/docs/data/pages.ts +++ b/docs/data/pages.ts @@ -165,10 +165,15 @@ const pages: MuiPage[] = [ { pathname: '/x/react-date-pickers/time-picker', title: 'Time components', - scopePathnames: ['/x/react-date-pickers/time-picker', '/x/react-date-pickers/time-field'], + scopePathnames: [ + '/x/react-date-pickers/time-picker', + '/x/react-date-pickers/time-field', + '/x/react-date-pickers/legacy-time-picker', + ], children: [ { pathname: '/x/react-date-pickers/time-picker', title: 'Time Picker' }, { pathname: '/x/react-date-pickers/time-field', title: 'Time Field', newFeature: true }, + { pathname: '/x/react-date-pickers/legacy-time-picker', title: 'Legacy Time Picker' }, ], }, { @@ -177,6 +182,7 @@ const pages: MuiPage[] = [ scopePathnames: [ '/x/react-date-pickers/date-time-picker', '/x/react-date-pickers/date-time-field', + '/x/react-date-pickers/legacy-date-time-picker', ], children: [ { pathname: '/x/react-date-pickers/date-time-picker', title: 'Date Time Picker' }, @@ -185,6 +191,10 @@ const pages: MuiPage[] = [ title: 'Date Time Field', newFeature: true, }, + { + pathname: '/x/react-date-pickers/legacy-date-time-picker', + title: 'Legacy Date Time Picker', + }, ], }, { @@ -194,6 +204,7 @@ const pages: MuiPage[] = [ scopePathnames: [ '/x/react-date-pickers/date-range-picker', '/x/react-date-pickers/date-range-field', + '/x/react-date-pickers/legacy-date-range-picker', ], children: [ { pathname: '/x/react-date-pickers/date-range-picker', title: 'Date Range Picker' }, @@ -202,6 +213,10 @@ const pages: MuiPage[] = [ title: 'Date Range Field', newFeature: true, }, + { + pathname: '/x/react-date-pickers/legacy-date-range-picker', + title: 'Legacy Date Range Picker', + }, ], }, { diff --git a/docs/pages/x/react-date-pickers/legacy-date-range-picker.js b/docs/pages/x/react-date-pickers/legacy-date-range-picker.js new file mode 100644 index 0000000000000..bbcb2672ef661 --- /dev/null +++ b/docs/pages/x/react-date-pickers/legacy-date-range-picker.js @@ -0,0 +1,7 @@ +import * as React from 'react'; +import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs'; +import * as pageProps from 'docsx/data/date-pickers/legacy-date-range-picker/legacy-date-range-picker.md?@mui/markdown'; + +export default function Page() { + return