-
-
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] Add new
DigitalClock
desktop time picking experience (#7958)
Signed-off-by: Lukas <[email protected]> Co-authored-by: José Rodolfo Freitas <[email protected]> Co-authored-by: Alexandre Fauquette <[email protected]>
- Loading branch information
1 parent
79efe97
commit 0cb20a0
Showing
150 changed files
with
4,153 additions
and
460 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import * as React from 'react'; | ||
import dayjs from 'dayjs'; | ||
import Typography from '@mui/material/Typography'; | ||
import { DemoContainer, DemoItem } from '@mui/x-date-pickers/internals/demo'; | ||
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider'; | ||
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'; | ||
import { DigitalClock } from '@mui/x-date-pickers/DigitalClock'; | ||
import { MultiSectionDigitalClock } from '@mui/x-date-pickers/MultiSectionDigitalClock'; | ||
|
||
export default function DigitalClockAmPm() { | ||
return ( | ||
<LocalizationProvider dateAdapter={AdapterDayjs}> | ||
<DemoContainer | ||
components={[ | ||
'DigitalClock', | ||
'MultiSectionDigitalClock', | ||
'DigitalClock', | ||
'MultiSectionDigitalClock', | ||
'DigitalClock', | ||
'MultiSectionDigitalClock', | ||
]} | ||
> | ||
<DemoItem> | ||
<Typography variant="body2"> | ||
Locale default behavior (enabled for enUS) | ||
</Typography> | ||
<DemoContainer components={['DigitalClock', 'MultiSectionDigitalClock']}> | ||
<DemoItem> | ||
<DigitalClock defaultValue={dayjs('2022-04-17T15:30')} /> | ||
</DemoItem> | ||
<DemoItem> | ||
<MultiSectionDigitalClock defaultValue={dayjs('2022-04-17T15:30')} /> | ||
</DemoItem> | ||
</DemoContainer> | ||
</DemoItem> | ||
<DemoItem> | ||
<Typography variant="body2">AM PM enabled</Typography> | ||
<DemoContainer components={['DigitalClock', 'MultiSectionDigitalClock']}> | ||
<DemoItem> | ||
<DigitalClock defaultValue={dayjs('2022-04-17T15:30')} ampm /> | ||
</DemoItem> | ||
<DemoItem> | ||
<MultiSectionDigitalClock | ||
defaultValue={dayjs('2022-04-17T15:30')} | ||
ampm | ||
/> | ||
</DemoItem> | ||
</DemoContainer> | ||
</DemoItem> | ||
<DemoItem> | ||
<Typography variant="body2">AM PM disabled</Typography> | ||
<DemoContainer components={['DigitalClock', 'MultiSectionDigitalClock']}> | ||
<DemoItem> | ||
<DigitalClock defaultValue={dayjs('2022-04-17T15:30')} ampm={false} /> | ||
</DemoItem> | ||
<DemoItem> | ||
<MultiSectionDigitalClock | ||
defaultValue={dayjs('2022-04-17T15:30')} | ||
ampm={false} | ||
/> | ||
</DemoItem> | ||
</DemoContainer> | ||
</DemoItem> | ||
</DemoContainer> | ||
</LocalizationProvider> | ||
); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import * as React from 'react'; | ||
import dayjs from 'dayjs'; | ||
import Typography from '@mui/material/Typography'; | ||
import { DemoContainer, DemoItem } from '@mui/x-date-pickers/internals/demo'; | ||
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider'; | ||
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'; | ||
import { DigitalClock } from '@mui/x-date-pickers/DigitalClock'; | ||
import { MultiSectionDigitalClock } from '@mui/x-date-pickers/MultiSectionDigitalClock'; | ||
|
||
export default function DigitalClockAmPm() { | ||
return ( | ||
<LocalizationProvider dateAdapter={AdapterDayjs}> | ||
<DemoContainer | ||
components={[ | ||
'DigitalClock', | ||
'MultiSectionDigitalClock', | ||
'DigitalClock', | ||
'MultiSectionDigitalClock', | ||
'DigitalClock', | ||
'MultiSectionDigitalClock', | ||
]} | ||
> | ||
<DemoItem> | ||
<Typography variant="body2"> | ||
Locale default behavior (enabled for enUS) | ||
</Typography> | ||
<DemoContainer components={['DigitalClock', 'MultiSectionDigitalClock']}> | ||
<DemoItem> | ||
<DigitalClock defaultValue={dayjs('2022-04-17T15:30')} /> | ||
</DemoItem> | ||
<DemoItem> | ||
<MultiSectionDigitalClock defaultValue={dayjs('2022-04-17T15:30')} /> | ||
</DemoItem> | ||
</DemoContainer> | ||
</DemoItem> | ||
<DemoItem> | ||
<Typography variant="body2">AM PM enabled</Typography> | ||
<DemoContainer components={['DigitalClock', 'MultiSectionDigitalClock']}> | ||
<DemoItem> | ||
<DigitalClock defaultValue={dayjs('2022-04-17T15:30')} ampm /> | ||
</DemoItem> | ||
<DemoItem> | ||
<MultiSectionDigitalClock | ||
defaultValue={dayjs('2022-04-17T15:30')} | ||
ampm | ||
/> | ||
</DemoItem> | ||
</DemoContainer> | ||
</DemoItem> | ||
<DemoItem> | ||
<Typography variant="body2">AM PM disabled</Typography> | ||
<DemoContainer components={['DigitalClock', 'MultiSectionDigitalClock']}> | ||
<DemoItem> | ||
<DigitalClock defaultValue={dayjs('2022-04-17T15:30')} ampm={false} /> | ||
</DemoItem> | ||
<DemoItem> | ||
<MultiSectionDigitalClock | ||
defaultValue={dayjs('2022-04-17T15:30')} | ||
ampm={false} | ||
/> | ||
</DemoItem> | ||
</DemoContainer> | ||
</DemoItem> | ||
</DemoContainer> | ||
</LocalizationProvider> | ||
); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import * as React from 'react'; | ||
import { DemoContainer, DemoItem } from '@mui/x-date-pickers/internals/demo'; | ||
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider'; | ||
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'; | ||
import { DigitalClock } from '@mui/x-date-pickers/DigitalClock'; | ||
import { MultiSectionDigitalClock } from '@mui/x-date-pickers/MultiSectionDigitalClock'; | ||
|
||
export default function DigitalClockBasic() { | ||
return ( | ||
<LocalizationProvider dateAdapter={AdapterDayjs}> | ||
<DemoContainer components={['DigitalClock', 'MultiSectionDigitalClock']}> | ||
<DemoItem label="Digital clock"> | ||
<DigitalClock /> | ||
</DemoItem> | ||
<DemoItem label="Multi section digital clock"> | ||
<MultiSectionDigitalClock /> | ||
</DemoItem> | ||
</DemoContainer> | ||
</LocalizationProvider> | ||
); | ||
} |
21 changes: 21 additions & 0 deletions
21
docs/data/date-pickers/digital-clock/DigitalClockBasic.tsx
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import * as React from 'react'; | ||
import { DemoContainer, DemoItem } from '@mui/x-date-pickers/internals/demo'; | ||
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider'; | ||
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'; | ||
import { DigitalClock } from '@mui/x-date-pickers/DigitalClock'; | ||
import { MultiSectionDigitalClock } from '@mui/x-date-pickers/MultiSectionDigitalClock'; | ||
|
||
export default function DigitalClockBasic() { | ||
return ( | ||
<LocalizationProvider dateAdapter={AdapterDayjs}> | ||
<DemoContainer components={['DigitalClock', 'MultiSectionDigitalClock']}> | ||
<DemoItem label="Digital clock"> | ||
<DigitalClock /> | ||
</DemoItem> | ||
<DemoItem label="Multi section digital clock"> | ||
<MultiSectionDigitalClock /> | ||
</DemoItem> | ||
</DemoContainer> | ||
</LocalizationProvider> | ||
); | ||
} |
6 changes: 6 additions & 0 deletions
6
docs/data/date-pickers/digital-clock/DigitalClockBasic.tsx.preview
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<DemoItem label="Digital clock"> | ||
<DigitalClock /> | ||
</DemoItem> | ||
<DemoItem label="Multi section digital clock"> | ||
<MultiSectionDigitalClock /> | ||
</DemoItem> |
47 changes: 47 additions & 0 deletions
47
docs/data/date-pickers/digital-clock/DigitalClockFormProps.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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import * as React from 'react'; | ||
import dayjs from 'dayjs'; | ||
import { DemoContainer, DemoItem } from '@mui/x-date-pickers/internals/demo'; | ||
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'; | ||
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider'; | ||
import { DigitalClock } from '@mui/x-date-pickers/DigitalClock'; | ||
import { MultiSectionDigitalClock } from '@mui/x-date-pickers/MultiSectionDigitalClock'; | ||
|
||
export default function DigitalClockFormProps() { | ||
return ( | ||
<LocalizationProvider dateAdapter={AdapterDayjs}> | ||
<DemoContainer | ||
components={[ | ||
'DigitalClock', | ||
'DigitalClock', | ||
'MultiSectionDigitalClock', | ||
'MultiSectionDigitalClock', | ||
]} | ||
> | ||
<DemoContainer components={['DigitalClock', 'DigitalClock']}> | ||
<DemoItem label="Digital clock disabled"> | ||
<DigitalClock defaultValue={dayjs('2022-04-17T15:30')} disabled /> | ||
</DemoItem> | ||
<DemoItem label="Digital clock readOnly"> | ||
<DigitalClock defaultValue={dayjs('2022-04-17T15:30')} readOnly /> | ||
</DemoItem> | ||
</DemoContainer> | ||
<DemoContainer | ||
components={['MultiSectionDigitalClock', 'MultiSectionDigitalClock']} | ||
> | ||
<DemoItem label="Multi section digital clock disabled"> | ||
<MultiSectionDigitalClock | ||
defaultValue={dayjs('2022-04-17T15:30')} | ||
disabled | ||
/> | ||
</DemoItem> | ||
<DemoItem label="Multi section digital clock readOnly"> | ||
<MultiSectionDigitalClock | ||
defaultValue={dayjs('2022-04-17T15:30')} | ||
readOnly | ||
/> | ||
</DemoItem> | ||
</DemoContainer> | ||
</DemoContainer> | ||
</LocalizationProvider> | ||
); | ||
} |
47 changes: 47 additions & 0 deletions
47
docs/data/date-pickers/digital-clock/DigitalClockFormProps.tsx
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import * as React from 'react'; | ||
import dayjs from 'dayjs'; | ||
import { DemoContainer, DemoItem } from '@mui/x-date-pickers/internals/demo'; | ||
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'; | ||
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider'; | ||
import { DigitalClock } from '@mui/x-date-pickers/DigitalClock'; | ||
import { MultiSectionDigitalClock } from '@mui/x-date-pickers/MultiSectionDigitalClock'; | ||
|
||
export default function DigitalClockFormProps() { | ||
return ( | ||
<LocalizationProvider dateAdapter={AdapterDayjs}> | ||
<DemoContainer | ||
components={[ | ||
'DigitalClock', | ||
'DigitalClock', | ||
'MultiSectionDigitalClock', | ||
'MultiSectionDigitalClock', | ||
]} | ||
> | ||
<DemoContainer components={['DigitalClock', 'DigitalClock']}> | ||
<DemoItem label="Digital clock disabled"> | ||
<DigitalClock defaultValue={dayjs('2022-04-17T15:30')} disabled /> | ||
</DemoItem> | ||
<DemoItem label="Digital clock readOnly"> | ||
<DigitalClock defaultValue={dayjs('2022-04-17T15:30')} readOnly /> | ||
</DemoItem> | ||
</DemoContainer> | ||
<DemoContainer | ||
components={['MultiSectionDigitalClock', 'MultiSectionDigitalClock']} | ||
> | ||
<DemoItem label="Multi section digital clock disabled"> | ||
<MultiSectionDigitalClock | ||
defaultValue={dayjs('2022-04-17T15:30')} | ||
disabled | ||
/> | ||
</DemoItem> | ||
<DemoItem label="Multi section digital clock readOnly"> | ||
<MultiSectionDigitalClock | ||
defaultValue={dayjs('2022-04-17T15:30')} | ||
readOnly | ||
/> | ||
</DemoItem> | ||
</DemoContainer> | ||
</DemoContainer> | ||
</LocalizationProvider> | ||
); | ||
} |
42 changes: 42 additions & 0 deletions
42
docs/data/date-pickers/digital-clock/DigitalClockSkipDisabled.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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import * as React from 'react'; | ||
import dayjs from 'dayjs'; | ||
import { DemoContainer, DemoItem } from '@mui/x-date-pickers/internals/demo'; | ||
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider'; | ||
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'; | ||
import { DigitalClock } from '@mui/x-date-pickers/DigitalClock'; | ||
import { MultiSectionDigitalClock } from '@mui/x-date-pickers/MultiSectionDigitalClock'; | ||
|
||
const shouldDisableTime = (value, view) => { | ||
const hour = value.hour(); | ||
if (view === 'hours') { | ||
return hour < 9 || hour > 13; | ||
} | ||
if (view === 'minutes') { | ||
const minute = value.minute(); | ||
return minute > 20 && hour === 13; | ||
} | ||
return false; | ||
}; | ||
|
||
export default function DigitalClockSkipDisabled() { | ||
return ( | ||
<LocalizationProvider dateAdapter={AdapterDayjs}> | ||
<DemoContainer components={['DigitalClock', 'MultiSectionDigitalClock']}> | ||
<DemoItem label="Digital clock"> | ||
<DigitalClock | ||
skipDisabled | ||
minTime={dayjs('2022-04-17T09:00')} | ||
timeStep={60} | ||
/> | ||
</DemoItem> | ||
<DemoItem label="Multi section digital clock"> | ||
<MultiSectionDigitalClock | ||
skipDisabled | ||
shouldDisableTime={shouldDisableTime} | ||
ampm={false} | ||
/> | ||
</DemoItem> | ||
</DemoContainer> | ||
</LocalizationProvider> | ||
); | ||
} |
43 changes: 43 additions & 0 deletions
43
docs/data/date-pickers/digital-clock/DigitalClockSkipDisabled.tsx
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import * as React from 'react'; | ||
import dayjs, { Dayjs } from 'dayjs'; | ||
import { DemoContainer, DemoItem } from '@mui/x-date-pickers/internals/demo'; | ||
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider'; | ||
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'; | ||
import { DigitalClock } from '@mui/x-date-pickers/DigitalClock'; | ||
import { MultiSectionDigitalClock } from '@mui/x-date-pickers/MultiSectionDigitalClock'; | ||
import { TimeView } from '@mui/x-date-pickers/models'; | ||
|
||
const shouldDisableTime = (value: Dayjs, view: TimeView) => { | ||
const hour = value.hour(); | ||
if (view === 'hours') { | ||
return hour < 9 || hour > 13; | ||
} | ||
if (view === 'minutes') { | ||
const minute = value.minute(); | ||
return minute > 20 && hour === 13; | ||
} | ||
return false; | ||
}; | ||
|
||
export default function DigitalClockSkipDisabled() { | ||
return ( | ||
<LocalizationProvider dateAdapter={AdapterDayjs}> | ||
<DemoContainer components={['DigitalClock', 'MultiSectionDigitalClock']}> | ||
<DemoItem label="Digital clock"> | ||
<DigitalClock | ||
skipDisabled | ||
minTime={dayjs('2022-04-17T09:00')} | ||
timeStep={60} | ||
/> | ||
</DemoItem> | ||
<DemoItem label="Multi section digital clock"> | ||
<MultiSectionDigitalClock | ||
skipDisabled | ||
shouldDisableTime={shouldDisableTime} | ||
ampm={false} | ||
/> | ||
</DemoItem> | ||
</DemoContainer> | ||
</LocalizationProvider> | ||
); | ||
} |
14 changes: 14 additions & 0 deletions
14
docs/data/date-pickers/digital-clock/DigitalClockSkipDisabled.tsx.preview
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<DemoItem label="Digital clock"> | ||
<DigitalClock | ||
skipDisabled | ||
minTime={dayjs('2022-04-17T09:00')} | ||
timeStep={60} | ||
/> | ||
</DemoItem> | ||
<DemoItem label="Multi section digital clock"> | ||
<MultiSectionDigitalClock | ||
skipDisabled | ||
shouldDisableTime={shouldDisableTime} | ||
ampm={false} | ||
/> | ||
</DemoItem> |
Oops, something went wrong.