Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pickers] Add new DigitalClock desktop time picking experience #7958

Merged
merged 164 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
164 commits
Select commit Hold shift + click to select a range
0f424cc
Initial digital-clock commit
LukasTy Feb 9, 2023
4ef05f8
Use separate `digital` view for rendering as `select`
LukasTy Feb 15, 2023
22e01b7
Fix disabled logic
LukasTy Feb 15, 2023
b1846d1
cleanup
LukasTy Feb 15, 2023
50ea025
Clean types
LukasTy Feb 15, 2023
ccc5057
Use `ampm`
LukasTy Feb 15, 2023
7eac0fc
Support `readOnly`
LukasTy Feb 15, 2023
278d59d
Ensure that digital clock is always focused in picker
LukasTy Feb 15, 2023
873cfa0
Handle scrolling selected item into view
LukasTy Feb 16, 2023
710a000
Add `digital` view to DesktopDateTime picker
LukasTy Feb 16, 2023
5ae0b2e
Focus selected item
LukasTy Feb 16, 2023
5309110
Make list and item "augmentable"
LukasTy Feb 16, 2023
5c08fe5
Minor fixes
LukasTy Feb 17, 2023
9b8fcb1
Initial desktop time clock implementation
LukasTy Feb 27, 2023
5d96468
Add meridiem selection
LukasTy Feb 27, 2023
6b1e33b
Use formatted time sections
LukasTy Feb 27, 2023
1939b98
Add renderers to DateTimePicker
LukasTy Feb 27, 2023
2806ffb
Hack a solution to close picker when last section is selected with pr…
LukasTy Feb 27, 2023
2cd6e36
Merge remote-tracking branch 'origin/master' into digital-clock
LukasTy Mar 16, 2023
85b1560
Play with styles
LukasTy Mar 16, 2023
16b5d6c
Fine-tune styling
LukasTy Mar 17, 2023
1465607
Play with digital clock width
LukasTy Mar 17, 2023
89751f0
Fix css warning
LukasTy Mar 17, 2023
0903773
Fix TS errors
LukasTy Mar 17, 2023
ffca62b
Tiny fixes
LukasTy Mar 17, 2023
176cdad
Focus selected item only when `autoFocus` prop is true
LukasTy Mar 17, 2023
cdac5e2
Fix focusing behavior
LukasTy Mar 17, 2023
4552c5a
Styles!
LukasTy Mar 17, 2023
7c1cac5
Allow updating same view multiple times
LukasTy Mar 17, 2023
bcc2867
Merge remote-tracking branch 'origin/master' into digital-clock
LukasTy Mar 24, 2023
f22cd1a
Fix time picker renderers focus management
LukasTy Mar 24, 2023
e1b6934
Set field as `focused` when picker is open
LukasTy Mar 24, 2023
ad9781f
Remove `isDesktop` from defaultized functions
LukasTy Mar 24, 2023
f964091
Remove `digital` view
LukasTy Mar 24, 2023
3f49878
Ensure the new view is focused after view change
LukasTy Mar 24, 2023
0860ee0
Rename variables and fix `timeStep` propagation
LukasTy Mar 24, 2023
83270e4
Merge remote-tracking branch 'origin/master' into digital-clock
LukasTy Mar 24, 2023
12b8cab
Fix after merge
LukasTy Mar 24, 2023
b7c0cac
rebuild exports
LukasTy Mar 24, 2023
04ed07f
Make digital clock props to only be available on desktop time pickers
LukasTy Mar 24, 2023
629b7c7
proptypes
LukasTy Mar 24, 2023
ffbaf1c
docs:api
LukasTy Mar 24, 2023
d1008fc
Use adapter utils for `am/pm` label
LukasTy Mar 29, 2023
7870f54
Implement `meridiem` as last step before closing picker
LukasTy Mar 29, 2023
62587d7
Customize narrower scrollbar
LukasTy Mar 29, 2023
cce73ce
Mark all sections as selected only when value is present
LukasTy Mar 29, 2023
f912dfc
Add scrollbar styling support for dark theme and css vars
LukasTy Mar 29, 2023
7a38d9a
Scroll selected item to the top
LukasTy Mar 30, 2023
04fa136
Fix digital clock selected item behavior and align scrolling behavior
LukasTy Mar 30, 2023
253ebab
Fix to adjust scroll position after every change
LukasTy Mar 30, 2023
9fdcbe1
Fix 12 hour clock midnight displaying
LukasTy Mar 30, 2023
5f5aba9
Increase section width
LukasTy Mar 30, 2023
a367496
Extract `timeStep` type
LukasTy Mar 31, 2023
ce6f20a
Remove pointless types
LukasTy Mar 31, 2023
7e00a9c
Refactor to rely on `closeOnSelect`
LukasTy Mar 31, 2023
30dd06e
prettier
LukasTy Mar 31, 2023
84ddaae
Rename `renderTimeInASingleColumnThreshold`
LukasTy Mar 31, 2023
f70e904
Facilitate free-view selection avoiding `setTimeout`
LukasTy Apr 3, 2023
fa1090a
Extract common section change logic
LukasTy Apr 3, 2023
c9eec1a
Rename `DesktopTimeClock` to `MultiSectionDigitalClock`
LukasTy Apr 3, 2023
f227913
Rename renderers
LukasTy Apr 3, 2023
f0d46ba
Fix unwanted am/pm autofocus
LukasTy Apr 3, 2023
0733aea
Revert unwanted type change
LukasTy Apr 3, 2023
2aa99b5
Code review: Flavien
LukasTy Apr 3, 2023
fd79f10
Cleanup
LukasTy Apr 3, 2023
7487ff4
Fix test failures
LukasTy Apr 3, 2023
563747f
Show actionBar with `accept` action by default on desktop
LukasTy Apr 3, 2023
6d261a7
Enable `DesktopTimePicker` view tests
LukasTy Apr 4, 2023
c843d62
Avoid `setTimeout` in digital clock value setting
LukasTy Apr 4, 2023
a257983
Add `digital-clock` docs
LukasTy Apr 4, 2023
ae2b351
Merge branch 'master' into digital-clock
LukasTy Apr 10, 2023
a758413
Fix import
LukasTy Apr 11, 2023
a0b9dad
Create slots for `MenuItem` components
LukasTy Apr 11, 2023
030d6df
Expose "digital" slots only on desktop
LukasTy Apr 11, 2023
1572f65
Add API pages & run scripts
LukasTy Apr 11, 2023
7dec8fb
Fix props propagation to `ampm` section
LukasTy Apr 12, 2023
33cabbf
Reduce section width
LukasTy Apr 12, 2023
8301be0
Reduce digital clock view height
LukasTy Apr 12, 2023
f414516
Add bottom border
LukasTy Apr 12, 2023
45b526d
Merge remote-tracking branch 'origin/master' into digital-clock
LukasTy Apr 12, 2023
e7288d9
Use smooth scrolling only after initial render
LukasTy Apr 12, 2023
14adeb0
Update migration doc
LukasTy Apr 12, 2023
c8daa44
Align component order with demos showing desktop before mobile
LukasTy Apr 12, 2023
7c86f57
Align `date-time-picker` doc with `time-picker`
LukasTy Apr 12, 2023
8ade83b
Code review: Flavien
LukasTy Apr 12, 2023
8599be7
Fix to produce correct digital clock options given odd ratio
LukasTy Apr 12, 2023
6618fca
proptypes
LukasTy Apr 12, 2023
431983c
docs:api
LukasTy Apr 12, 2023
f089a0a
Code review: Jose
LukasTy Apr 13, 2023
e67be76
Fix digital clock scrolling behavior and scroll to disabled item
LukasTy Apr 13, 2023
bc9eb3b
Fix to scroll to disabled item
LukasTy Apr 13, 2023
cfad1ee
Fix formatting
LukasTy Apr 13, 2023
20de376
Refactor to use `timeSteps`
LukasTy Apr 13, 2023
0371b70
proptypes
LukasTy Apr 13, 2023
56e1712
docs:api
LukasTy Apr 13, 2023
d7b6ebb
Support hours `timeStep` in `MultiSectionDigitalClock`
LukasTy Apr 14, 2023
2501a61
Fix `maxHeight` consistency
LukasTy Apr 14, 2023
59e31bd
Fix `MenuList` variant
LukasTy Apr 14, 2023
4f3b4ee
Merge remote-tracking branch 'origin/master' into digital-clock
LukasTy Apr 14, 2023
33fd8fb
Remove pointless default
LukasTy Apr 14, 2023
7e94167
Fix scrolling to selected item
LukasTy Apr 14, 2023
cfb1463
Remove intrinsic digital clock padding and pass it only in case of be…
LukasTy Apr 14, 2023
d9ccbc1
regen docs
LukasTy Apr 14, 2023
4e2a77c
Add and test themeAugmentation
LukasTy Apr 14, 2023
1855211
docs:api
LukasTy Apr 14, 2023
951bb90
Implement `meridiem` step using a separate view
LukasTy Apr 17, 2023
ebbb469
Exclude `meridiem` view from option possible to pass into `views` list
LukasTy Apr 18, 2023
5a09e0b
Refactor types to include `meridiem` view only when needed
LukasTy Apr 18, 2023
184c6ef
proptypes
LukasTy Apr 18, 2023
f182e80
docs:api
LukasTy Apr 18, 2023
6acb7dd
fix demo
LukasTy Apr 18, 2023
05d2278
Fix tests
LukasTy Apr 18, 2023
c49f9cb
Remove `DigitalClock` from `DesktopDateTimePicker`
LukasTy Apr 18, 2023
35b2a99
Revert test changes
LukasTy Apr 18, 2023
ed2a48a
Revert tabs and toolbar views changes
LukasTy Apr 18, 2023
feec7e2
proptypes
LukasTy Apr 18, 2023
5da60ab
docs:api
LukasTy Apr 18, 2023
07cb433
Revert import move
LukasTy Apr 18, 2023
ee6fdfc
Cleanup and reduce changes
LukasTy Apr 19, 2023
962f2b6
regen docs
LukasTy Apr 19, 2023
b9ba8eb
reorder import
LukasTy Apr 19, 2023
12e5add
Remove `confirmChange` in favour of manually selecting `meridiem` view
LukasTy Apr 19, 2023
a1f1dc1
Add `skipDisabled` prop
LukasTy Apr 19, 2023
f6fce40
Add `skipDisabled` documentation
LukasTy Apr 19, 2023
0f6cb1e
rerun scripts
LukasTy Apr 19, 2023
74e170d
Fix multi section digital clock focusing issues
LukasTy Apr 19, 2023
4550a9b
Add `DigitalClock` describes tests
LukasTy Apr 19, 2023
18e564b
Apply suggestions from code review
LukasTy Apr 20, 2023
01f8571
Fix rule to avoid the change in `TimeClock` test
LukasTy Apr 20, 2023
7aca664
Add `validation` section to time and digital clocks
LukasTy Apr 20, 2023
3f5960f
Remove redundant `| DateOrTimeView` subset typing
LukasTy Apr 20, 2023
d8e27f8
Add `MultiSectionDigitalClock` describes tests
LukasTy Apr 20, 2023
513bd86
Refactor `DigitalClock` `TView` contract to only support `hours`
LukasTy Apr 21, 2023
1e36f44
Apply suggestions from code review
LukasTy Apr 21, 2023
92a6ebc
Merge remote-tracking branch 'origin/master' into digital-clock
LukasTy Apr 21, 2023
717d3e9
Fix to allow out of order section selection
LukasTy Apr 21, 2023
ac300c7
docs:api
LukasTy Apr 21, 2023
a559a95
Provide more meaningful `skipDisabled` demos and description
LukasTy Apr 21, 2023
b992ccb
Avoid the need for `| null` in `focusedView`
LukasTy Apr 24, 2023
cc9a66d
Merge remote-tracking branch 'origin/master' into digital-clock
LukasTy Apr 24, 2023
233c79b
Adjust spacing & dimensions
LukasTy Apr 24, 2023
b49ee55
Adjust colors
LukasTy Apr 25, 2023
c96228a
proptypes
LukasTy Apr 25, 2023
4f14352
Add `a11y` support to `MultiSectionDigitalClock` using a `listbox` role
LukasTy Apr 25, 2023
7c6f436
Improve `DigitalClock` `a11y` using a listbox role
LukasTy Apr 25, 2023
1a91a9a
Add and align translations
LukasTy Apr 25, 2023
f9cfb2c
l10n
LukasTy Apr 25, 2023
6b75f50
Fix tests after a11y changes
LukasTy Apr 26, 2023
2cea15b
Adjust style after increased top margin
LukasTy Apr 26, 2023
bd447e1
Use `role` & `aria-selected` instead of element types and classes
LukasTy Apr 26, 2023
b81eddf
Use hours number without preceding `0`
LukasTy Apr 26, 2023
6e63083
Merge remote-tracking branch 'origin/master' into digital-clock
LukasTy Apr 26, 2023
a00fd38
proptypes
LukasTy Apr 26, 2023
1a9f543
Use relative import
LukasTy Apr 26, 2023
d97255c
Fix test
LukasTy Apr 26, 2023
8678f90
Use more stable method of controlling out of order view selection
LukasTy Apr 26, 2023
4a4230d
Run scripts
LukasTy Apr 26, 2023
72da1ff
Simplify `timeStep` on `DigitalClock` component
LukasTy Apr 26, 2023
a261f3d
Fix tests
LukasTy Apr 26, 2023
37b6b2c
Fix TS
LukasTy Apr 26, 2023
a5ac5a4
Add tests covering new `DesktopTimePicker` behavior
LukasTy Apr 27, 2023
f74d9d0
Merge remote-tracking branch 'origin/master' into digital-clock
LukasTy Apr 27, 2023
d8d76fa
Remove `meridiem` from `views` prop on time pickers
LukasTy Apr 27, 2023
a927e81
Run scripts
LukasTy Apr 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions docs/data/date-pickers/digital-clock/DigitalClockAmPm.js
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>
);
}
67 changes: 67 additions & 0 deletions docs/data/date-pickers/digital-clock/DigitalClockAmPm.tsx
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>
);
}
21 changes: 21 additions & 0 deletions docs/data/date-pickers/digital-clock/DigitalClockBasic.js
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 docs/data/date-pickers/digital-clock/DigitalClockBasic.tsx
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>
);
}
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 docs/data/date-pickers/digital-clock/DigitalClockFormProps.js
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 docs/data/date-pickers/digital-clock/DigitalClockFormProps.tsx
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 docs/data/date-pickers/digital-clock/DigitalClockSkipDisabled.js
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')}
LukasTy marked this conversation as resolved.
Show resolved Hide resolved
timeStep={60}
/>
</DemoItem>
<DemoItem label="Multi section digital clock">
<MultiSectionDigitalClock
skipDisabled
shouldDisableTime={shouldDisableTime}
ampm={false}
/>
</DemoItem>
</DemoContainer>
</LocalizationProvider>
);
}
43 changes: 43 additions & 0 deletions docs/data/date-pickers/digital-clock/DigitalClockSkipDisabled.tsx
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>
);
}
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>
Loading