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

[DatePicker] Initial commit #3451

Merged
merged 351 commits into from
Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
351 commits
Select commit Hold shift + click to select a range
4fda6b6
Work
flaviendelangle Jan 27, 2022
98c00da
Work
flaviendelangle Jan 27, 2022
0e20238
Work
flaviendelangle Jan 27, 2022
05a2d20
Work
flaviendelangle Jan 27, 2022
7d1ffba
Work
flaviendelangle Jan 27, 2022
e93e503
Work
flaviendelangle Jan 27, 2022
35f2d0e
Work
flaviendelangle Jan 27, 2022
b4eb6d7
Merge branch 'state-pro-community' into pro-event-lookup
flaviendelangle Jan 27, 2022
d2e0f56
Work
flaviendelangle Jan 27, 2022
7a7402c
Work
flaviendelangle Jan 27, 2022
c104efd
Work
flaviendelangle Jan 27, 2022
4341a79
Work
flaviendelangle Jan 27, 2022
0cab542
Work
flaviendelangle Jan 27, 2022
b0c1efd
Merge
flaviendelangle Jan 28, 2022
b7086f2
Merge
flaviendelangle Jan 28, 2022
8492cde
Merge
flaviendelangle Jan 28, 2022
a335093
Code review: Matheus
flaviendelangle Jan 28, 2022
2af7f96
Merge
flaviendelangle Jan 28, 2022
dce4270
Work
flaviendelangle Jan 28, 2022
92d3036
Work
flaviendelangle Jan 28, 2022
5d62390
Work
flaviendelangle Jan 28, 2022
b06fdcc
Fix
flaviendelangle Jan 28, 2022
33ea426
Work
flaviendelangle Jan 28, 2022
e17e186
Fix
flaviendelangle Jan 28, 2022
3eba08a
Merge
flaviendelangle Jan 31, 2022
40c25e0
Merge
flaviendelangle Jan 31, 2022
7f52894
Work
flaviendelangle Jan 31, 2022
15c7d5a
[core] Stop using an enum for GridPreProcessingGroup
flaviendelangle Jan 31, 2022
62aa35f
Work
flaviendelangle Jan 31, 2022
3517c3e
Work
flaviendelangle Jan 31, 2022
4e74315
Work
flaviendelangle Jan 31, 2022
55a9d3b
Work
flaviendelangle Jan 31, 2022
c23754f
Work
flaviendelangle Jan 31, 2022
7d4f650
Empty
flaviendelangle Jan 31, 2022
98eaee7
Work
flaviendelangle Jan 31, 2022
a10a1ae
Work
flaviendelangle Jan 31, 2022
c861a26
Work
flaviendelangle Jan 31, 2022
f8ddce9
Merge
flaviendelangle Jan 31, 2022
83ee0fe
Fix
flaviendelangle Jan 31, 2022
08d000e
Merge branch 'state-pro-community' into pro-event-lookup
flaviendelangle Feb 1, 2022
da77134
Merge branch 'master' into state-pro-community
flaviendelangle Feb 1, 2022
4425b38
Merge branch 'master' into pre-processor-enum
flaviendelangle Feb 1, 2022
3b7adf1
Merge branch 'pre-processor-enum' into pro-event-lookup-base
flaviendelangle Feb 1, 2022
964ec90
Merge branch 'state-pro-community' into pro-event-lookup-base
flaviendelangle Feb 1, 2022
b0ab694
Merge branch 'pro-event-lookup-base' into pro-event-lookup
flaviendelangle Feb 1, 2022
b4471ac
Work
flaviendelangle Feb 1, 2022
69cec52
Merge
flaviendelangle Feb 1, 2022
34b2bf3
Merge
flaviendelangle Feb 1, 2022
9f6dd01
Merge
flaviendelangle Feb 2, 2022
4b3ccdd
Work
flaviendelangle Feb 2, 2022
10297c1
Merge branch 'master' into state-pro-community
flaviendelangle Feb 2, 2022
d886de0
Work
flaviendelangle Feb 2, 2022
8bf1126
Merge branch 'master' into state-pro-community
flaviendelangle Feb 2, 2022
cb9497e
Work
flaviendelangle Feb 2, 2022
37646e2
Work
flaviendelangle Feb 2, 2022
702b849
Work
flaviendelangle Feb 2, 2022
88286a2
Fix
flaviendelangle Feb 2, 2022
f4d45a0
Work
flaviendelangle Feb 2, 2022
c3a4493
Work
flaviendelangle Feb 2, 2022
41904ba
Work
flaviendelangle Feb 2, 2022
892eb4b
Work
flaviendelangle Feb 2, 2022
96a0a02
Work
flaviendelangle Feb 2, 2022
13840c7
Work
flaviendelangle Feb 3, 2022
a939de6
Merge
flaviendelangle Feb 3, 2022
c3a00f7
Merge
flaviendelangle Feb 3, 2022
cae8c2a
Work
flaviendelangle Feb 3, 2022
a1a8ccf
Merge
flaviendelangle Feb 3, 2022
1be427c
Work
flaviendelangle Feb 3, 2022
27398f8
Merge branch 'master' into state-pro-community
flaviendelangle Feb 7, 2022
aee8b32
Merge
flaviendelangle Feb 7, 2022
1fc32fd
Work
flaviendelangle Feb 7, 2022
23d759b
Merge branch 'master' into state-pro-community
flaviendelangle Feb 8, 2022
ff455b5
Work
flaviendelangle Feb 8, 2022
2d8b4a2
Merge branch 'state-pro-community' into pro-event-lookup
flaviendelangle Feb 8, 2022
5fabdaf
work
flaviendelangle Feb 9, 2022
cd5ee8a
Work
flaviendelangle Feb 9, 2022
1e093f5
Merge
flaviendelangle Feb 9, 2022
9b536a1
Merge branch 'master' into state-pro-community
flaviendelangle Feb 10, 2022
f3142ea
Merge
flaviendelangle Feb 10, 2022
176cef5
Merge branch 'master' into state-pro-community
flaviendelangle Feb 11, 2022
694bfdc
Merge branch 'master' into state-pro-community
flaviendelangle Feb 14, 2022
c706c9b
Work
flaviendelangle Feb 14, 2022
cf3e54e
Work
flaviendelangle Feb 14, 2022
24a43e3
Work
flaviendelangle Feb 14, 2022
acb5765
Work
flaviendelangle Feb 14, 2022
c7f0681
Merge branch 'master' into state-pro-community
flaviendelangle Feb 14, 2022
6187b36
Merge branch 'state-pro-community' into pro-event-lookup
flaviendelangle Feb 14, 2022
63797e3
Merge branch 'master' into pro-event-lookup
flaviendelangle Feb 15, 2022
7b5a441
[core] Drop _modules_ folder
flaviendelangle Feb 15, 2022
7f7b5bd
Fix proptypes
flaviendelangle Feb 15, 2022
d172132
Fix l10n
flaviendelangle Feb 15, 2022
5230d98
Work
flaviendelangle Feb 15, 2022
965e0cc
Work
flaviendelangle Feb 15, 2022
4914e29
Empty
flaviendelangle Feb 15, 2022
d735fe2
Merge branch 'pro-event-lookup' into drop-modules
flaviendelangle Feb 15, 2022
8c46bdf
Work
flaviendelangle Feb 15, 2022
f52a7f7
Fix
flaviendelangle Feb 15, 2022
8ecf518
Merge
flaviendelangle Feb 15, 2022
38f9b31
Work
flaviendelangle Feb 15, 2022
c46e076
Fix
flaviendelangle Feb 15, 2022
c6f8690
Fix
flaviendelangle Feb 15, 2022
c1e4811
Fix
flaviendelangle Feb 15, 2022
09b367b
Merge
flaviendelangle Feb 15, 2022
1d492b7
Merge branch 'master' into drop-modules
flaviendelangle Feb 16, 2022
5b1e536
Merge
flaviendelangle Feb 16, 2022
e1723f9
[core] Use the same bundling scripts as the core repository
flaviendelangle Feb 16, 2022
af034f9
Work
flaviendelangle Feb 16, 2022
56eabd6
Work
flaviendelangle Feb 16, 2022
944d8dc
Work
flaviendelangle Feb 16, 2022
83c78ae
Work
flaviendelangle Feb 16, 2022
9e49c24
Work
flaviendelangle Feb 16, 2022
7dd67e6
Work
flaviendelangle Feb 16, 2022
8ae7cbf
Work
flaviendelangle Feb 16, 2022
b3dfa14
Fox
flaviendelangle Feb 16, 2022
589aa77
Fox
flaviendelangle Feb 16, 2022
946f67b
Fox
flaviendelangle Feb 16, 2022
5f59acb
Fix
flaviendelangle Feb 16, 2022
73a266d
Fix
flaviendelangle Feb 16, 2022
b695c9e
Code review: Matheus
flaviendelangle Feb 17, 2022
9af6a53
Merge branch 'drop-modules' into bundle
flaviendelangle Feb 17, 2022
e092fde
Fix storybook
flaviendelangle Feb 17, 2022
264e1bb
Merge branch 'master' into drop-modules
flaviendelangle Feb 17, 2022
e26af18
Merge branch 'drop-modules' into bundle
flaviendelangle Feb 17, 2022
72007ca
Work
flaviendelangle Feb 17, 2022
ec7e9b4
Try fixing bundle duplication issue
flaviendelangle Feb 17, 2022
c8bd1f9
Work
flaviendelangle Feb 17, 2022
ed57d16
Work
flaviendelangle Feb 17, 2022
fd41323
Fix doc
flaviendelangle Feb 18, 2022
a2448cb
Fix
flaviendelangle Feb 18, 2022
6931f3e
Fix
flaviendelangle Feb 18, 2022
ec714e8
Merge
flaviendelangle Feb 18, 2022
a2d662d
work
flaviendelangle Feb 18, 2022
438819c
Work
flaviendelangle Feb 18, 2022
4988a9c
Merge branch 'master' into bundle
flaviendelangle Feb 18, 2022
ccb32ab
Fix API
flaviendelangle Feb 18, 2022
99c2023
Ready
flaviendelangle Feb 21, 2022
1aa1c7b
Merge
flaviendelangle Feb 21, 2022
2b70780
Work
flaviendelangle Feb 22, 2022
c743a57
Work
flaviendelangle Feb 22, 2022
ae9f84f
Fix
flaviendelangle Feb 22, 2022
abeda52
Work
flaviendelangle Feb 22, 2022
ea5af2a
Work
flaviendelangle Feb 22, 2022
431d4db
Work
flaviendelangle Feb 22, 2022
4093ac8
Work
flaviendelangle Feb 22, 2022
1f4f9ae
Merge
flaviendelangle Feb 22, 2022
38e37a6
Work
flaviendelangle Feb 22, 2022
8848c64
Work
flaviendelangle Feb 22, 2022
e783c77
Work
flaviendelangle Feb 23, 2022
188afe2
Merge branch 'master' into bundle
flaviendelangle Feb 23, 2022
e0dc9ab
Code review: Matheus (remove internals folder)
flaviendelangle Feb 23, 2022
74c5927
Mere
flaviendelangle Feb 24, 2022
49a7df4
Merge
flaviendelangle Feb 24, 2022
1f079c5
WOrk
flaviendelangle Feb 24, 2022
29cd415
Merge branch 'master' into bundle
flaviendelangle Feb 24, 2022
1961f88
Merge branch 'master' into bundle
flaviendelangle Feb 24, 2022
6ff895b
Fix
flaviendelangle Feb 24, 2022
56dfd9c
Work
flaviendelangle Feb 24, 2022
e53d5de
Work
flaviendelangle Feb 24, 2022
ccec4f9
Fix
flaviendelangle Feb 24, 2022
62bef2a
reset sinon default sandbox
m4theushw Feb 25, 2022
81282b6
it should go out of memory with +100 tests
m4theushw Feb 25, 2022
efb8737
it should be green with the cleanup
m4theushw Feb 25, 2022
dfd4a68
Merge remote-tracking branch 'origin/master' into memory-leak
m4theushw Feb 25, 2022
1efe592
Merge
flaviendelangle Feb 25, 2022
8477566
Work
flaviendelangle Feb 25, 2022
b94fab8
Empty
flaviendelangle Feb 25, 2022
484ba01
Work
flaviendelangle Feb 25, 2022
0d00b5c
Merge branch 'master' into bundle
flaviendelangle Feb 25, 2022
9a034b6
Fix
flaviendelangle Feb 25, 2022
8211aae
Merge
flaviendelangle Feb 25, 2022
7c5bc1d
Merge
flaviendelangle Feb 25, 2022
abd51f3
Merge
flaviendelangle Feb 28, 2022
3abe611
Merge branch 'master' into bundle
flaviendelangle Feb 28, 2022
04ad4b6
Work
flaviendelangle Feb 28, 2022
77e7b48
Empty
flaviendelangle Feb 28, 2022
70c9f2c
Empty
flaviendelangle Feb 28, 2022
754f028
Merge branch 'master' into bundle
flaviendelangle Mar 1, 2022
4ffeca7
Merge
flaviendelangle Mar 1, 2022
ed0e5d8
Merge
flaviendelangle Mar 1, 2022
2fbc2a5
Work
flaviendelangle Mar 1, 2022
4eb8ccf
Work
flaviendelangle Mar 1, 2022
dcf5977
Work
flaviendelangle Mar 3, 2022
01bcb95
Merge branch 'master' into date-picker
flaviendelangle Mar 3, 2022
305a531
Work
flaviendelangle Mar 3, 2022
6a1b5bd
Work
flaviendelangle Mar 3, 2022
d354691
Work
flaviendelangle Mar 3, 2022
4de8379
Work
flaviendelangle Mar 3, 2022
423b187
Work
flaviendelangle Mar 3, 2022
2777168
Work
flaviendelangle Mar 3, 2022
efcf67e
Work
flaviendelangle Mar 3, 2022
bfae59a
Work
flaviendelangle Mar 3, 2022
6875952
Work
flaviendelangle Mar 3, 2022
c3c3c3a
Work
flaviendelangle Mar 3, 2022
5a0d6c7
Work
flaviendelangle Mar 4, 2022
34d5815
Work
flaviendelangle Mar 4, 2022
51d5929
Work
flaviendelangle Mar 4, 2022
33694ac
Work
flaviendelangle Mar 4, 2022
4698eb3
Work
flaviendelangle Mar 7, 2022
d313888
[core] Prepare the api build scripts for multi packages support
flaviendelangle Mar 7, 2022
2da7765
Work
flaviendelangle Mar 7, 2022
6bed5dd
Work
flaviendelangle Mar 7, 2022
ceaa3e8
Work
flaviendelangle Mar 7, 2022
5b2e595
Work
flaviendelangle Mar 7, 2022
dd97f3e
Work
flaviendelangle Mar 7, 2022
ac79309
Work
flaviendelangle Mar 7, 2022
a019569
Work
flaviendelangle Mar 7, 2022
bd8b509
Merge
flaviendelangle Mar 7, 2022
c751a34
Merge branch 'api-multi-packages' into date-picker
flaviendelangle Mar 8, 2022
2e7ae71
Empty
flaviendelangle Mar 8, 2022
48117a6
Merge branch 'master' into api-multi-packages
flaviendelangle Mar 8, 2022
70244f3
Merge branch 'api-multi-packages' into date-picker
flaviendelangle Mar 8, 2022
edeb2ab
Work
flaviendelangle Mar 8, 2022
f0b46a8
Fix
flaviendelangle Mar 8, 2022
987fc79
Empty
flaviendelangle Mar 8, 2022
79805c9
Work
flaviendelangle Mar 8, 2022
a2ecb76
Merge branch 'master' into api-multi-packages
flaviendelangle Mar 8, 2022
9f77780
Merge branch 'api-multi-packages' into date-picker
flaviendelangle Mar 8, 2022
3001991
Work
flaviendelangle Mar 8, 2022
1615bd7
Work
flaviendelangle Mar 8, 2022
4e19a82
Merge
flaviendelangle Mar 9, 2022
3e17e4b
Merge branch 'master' into date-picker
flaviendelangle Mar 9, 2022
eca5269
Merge branch 'master' into date-picker
flaviendelangle Mar 17, 2022
d8aead4
Merge
flaviendelangle Mar 22, 2022
7c0031f
Work
flaviendelangle Mar 22, 2022
fa39ed3
Work
flaviendelangle Mar 22, 2022
f898381
Work
flaviendelangle Mar 22, 2022
34ad570
Work
flaviendelangle Mar 23, 2022
93e4ba7
Work
flaviendelangle Mar 23, 2022
a000cef
Work
flaviendelangle Mar 23, 2022
41a131b
Work
flaviendelangle Mar 23, 2022
af717e5
Work
flaviendelangle Mar 23, 2022
086f33c
Work
flaviendelangle Mar 23, 2022
4cb14da
Work
flaviendelangle Mar 23, 2022
c4ed6e3
Merge
flaviendelangle Mar 24, 2022
7d74bfb
Replace links
flaviendelangle Mar 24, 2022
e22dd20
Code review: Alex
flaviendelangle Mar 24, 2022
92ad5a4
Work
flaviendelangle Mar 24, 2022
cffcfbc
Merge branch 'master' into date-picker
flaviendelangle Mar 25, 2022
72161c7
Work
flaviendelangle Mar 25, 2022
8f4c8b0
Add fixtures
flaviendelangle Mar 25, 2022
57ab291
Work
flaviendelangle Mar 25, 2022
3f0e92a
Fix
flaviendelangle Mar 25, 2022
0a0aa5f
fix docs:api regexp
alexfauquette Mar 25, 2022
83787d1
apply the script
alexfauquette Mar 25, 2022
bfdb2b8
Merge branch 'master' into date-picker
flaviendelangle Mar 28, 2022
2eb2b84
Work
flaviendelangle Mar 28, 2022
3b9d513
Merge branch 'master' into date-picker
flaviendelangle Mar 29, 2022
d43eb84
Work
flaviendelangle Mar 29, 2022
cff1a21
Work
flaviendelangle Mar 29, 2022
5e74568
Work
flaviendelangle Mar 29, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 6 additions & 2 deletions .codesandbox/ci.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
"packages/x-license-pro",
"packages/grid/x-data-grid",
"packages/grid/x-data-grid-pro",
"packages/grid/x-data-grid-generator"
"packages/grid/x-data-grid-generator",
"packages/x-date-pickers",
"packages/x-date-pickers-pro"
],
"publishDirectory": {
"@mui/x-license-pro": "packages/x-license-pro/build",
"@mui/x-data-grid": "packages/grid/x-data-grid/build",
"@mui/x-data-grid-pro": "packages/grid/x-data-grid-pro/build",
"@mui/x-data-grid-generator": "packages/grid/x-data-grid-generator/build"
"@mui/x-data-grid-generator": "packages/grid/x-data-grid-generator/build",
"@mui/x-date-pickers": "packages/x-date-pickers/build",
"@mui/x-date-pickers-pro": "packages/x-date-pickers-pro/build"
},
"sandboxes": [
"new",
Expand Down
12 changes: 6 additions & 6 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,27 +84,27 @@ module.exports = {
},
},
{
files: ['packages/x-pickers/src/**/*{.ts,.tsx,.js}'],
files: ['packages/x-date-pickers/src/**/*{.ts,.tsx,.js}'],
excludedFiles: ['*.d.ts', '*.spec.ts', '*.spec.tsx', '**.test.tx', '**.test.tsx'],
rules: {
'no-restricted-imports': [
'error',
{
paths: ['@mui/x-pickers'],
patterns: ['@mui/x-pickers/*'],
paths: ['@mui/x-date-pickers'],
patterns: ['@mui/x-date-pickers/*'],
},
],
},
},
{
files: ['packages/x-pickers-pro/src/**/*{.ts,.tsx,.js}'],
files: ['packages/x-date-pickers-pro/src/**/*{.ts,.tsx,.js}'],
excludedFiles: ['*.d.ts', '*.spec.ts', '*.spec.tsx', '**.test.tx', '**.test.tsx'],
rules: {
'no-restricted-imports': [
'error',
{
paths: ['@mui/x-pickers-pro'],
patterns: ['@mui/x-pickers-pro/*'],
paths: ['@mui/x-date-pickers-pro'],
patterns: ['@mui/x-date-pickers-pro/*'],
},
],
},
Expand Down
2 changes: 2 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const defaultAlias = {
'@mui/x-data-grid-generator': resolveAliasPath('./packages/grid/x-data-grid-generator/src'),
'@mui/x-data-grid-pro': resolveAliasPath('./packages/grid/x-data-grid-pro/src'),
'@mui/x-license-pro': resolveAliasPath('./packages/x-license-pro/src'),
'@mui/x-date-pickers': resolveAliasPath('./packages/x-date-pickers/src'),
'@mui/x-date-pickers-pro': resolveAliasPath('./packages/x-date-pickers-pro/src'),
'typescript-to-proptypes': '@mui/monorepo/packages/typescript-to-proptypes/src',
docs: resolveAliasPath('./node_modules/@mui/monorepo/docs'),
test: resolveAliasPath('./test'),
Expand Down
2 changes: 2 additions & 0 deletions docs/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const alias = {
'@mui/x-data-grid': '../packages/grid/x-data-grid/src',
'@mui/x-data-grid-generator': '../packages/grid/x-data-grid-generator/src',
'@mui/x-data-grid-pro': '../packages/grid/x-data-grid-pro/src',
'@mui/x-date-pickers': '../packages/x-date-pickers/src',
'@mui/x-date-pickers-pro': '../packages/x-date-pickers-pro/src',
'@mui/x-license-pro': '../packages/x-license-pro/src',
'@mui/docs': '../node_modules/@mui/monorepo/packages/mui-docs/src',
'@mui/markdown': '../node_modules/@mui/monorepo/docs/packages/markdown',
Expand Down
22 changes: 22 additions & 0 deletions docs/data/date-pickers/date-picker/BasicDatePicker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import * as React from 'react';
import TextField from '@mui/material/TextField';
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { DatePicker } from '@mui/x-date-pickers/DatePicker';

export default function BasicDatePicker() {
const [value, setValue] = React.useState(null);

return (
<LocalizationProvider dateAdapter={AdapterDateFns}>
<DatePicker
label="Basic example"
value={value}
onChange={(newValue) => {
setValue(newValue);
}}
renderInput={(params) => <TextField {...params} />}
/>
</LocalizationProvider>
);
}
22 changes: 22 additions & 0 deletions docs/data/date-pickers/date-picker/BasicDatePicker.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import * as React from 'react';
import TextField from '@mui/material/TextField';
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { DatePicker } from '@mui/x-date-pickers/DatePicker';

export default function BasicDatePicker() {
const [value, setValue] = React.useState<Date | null>(null);

return (
<LocalizationProvider dateAdapter={AdapterDateFns}>
<DatePicker
label="Basic example"
value={value}
onChange={(newValue) => {
setValue(newValue);
}}
renderInput={(params) => <TextField {...params} />}
/>
</LocalizationProvider>
);
}
10 changes: 10 additions & 0 deletions docs/data/date-pickers/date-picker/BasicDatePicker.tsx.preview
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<LocalizationProvider dateAdapter={AdapterDateFns}>
<DatePicker
label="Basic example"
value={value}
onChange={(newValue) => {
setValue(newValue);
}}
renderInput={(params) => <TextField {...params} />}
/>
</LocalizationProvider>
76 changes: 76 additions & 0 deletions docs/data/date-pickers/date-picker/CustomDay.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import * as React from 'react';
import { styled } from '@mui/material/styles';
import TextField from '@mui/material/TextField';
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { StaticDatePicker } from '@mui/x-date-pickers/StaticDatePicker';
import { PickersDay } from '@mui/x-date-pickers/PickersDay';
import endOfWeek from 'date-fns/endOfWeek';
import isSameDay from 'date-fns/isSameDay';
import isWithinInterval from 'date-fns/isWithinInterval';
import startOfWeek from 'date-fns/startOfWeek';

const CustomPickersDay = styled(PickersDay, {
shouldForwardProp: (prop) =>
prop !== 'dayIsBetween' && prop !== 'isFirstDay' && prop !== 'isLastDay',
})(({ theme, dayIsBetween, isFirstDay, isLastDay }) => ({
...(dayIsBetween && {
borderRadius: 0,
backgroundColor: theme.palette.primary.main,
color: theme.palette.common.white,
'&:hover, &:focus': {
backgroundColor: theme.palette.primary.dark,
},
}),
...(isFirstDay && {
borderTopLeftRadius: '50%',
borderBottomLeftRadius: '50%',
}),
...(isLastDay && {
borderTopRightRadius: '50%',
borderBottomRightRadius: '50%',
}),
}));

export default function CustomDay() {
const [value, setValue] = React.useState(new Date());

const renderWeekPickerDay = (date, selectedDates, pickersDayProps) => {
if (!value) {
return <PickersDay {...pickersDayProps} />;
}

const start = startOfWeek(value);
const end = endOfWeek(value);

const dayIsBetween = isWithinInterval(date, { start, end });
const isFirstDay = isSameDay(date, start);
const isLastDay = isSameDay(date, end);

return (
<CustomPickersDay
{...pickersDayProps}
disableMargin
dayIsBetween={dayIsBetween}
isFirstDay={isFirstDay}
isLastDay={isLastDay}
/>
);
};

return (
<LocalizationProvider dateAdapter={AdapterDateFns}>
<StaticDatePicker
displayStaticWrapperAs="desktop"
label="Week picker"
value={value}
onChange={(newValue) => {
setValue(newValue);
}}
renderDay={renderWeekPickerDay}
renderInput={(params) => <TextField {...params} />}
inputFormat="'Week of' MMM d"
/>
</LocalizationProvider>
);
}
86 changes: 86 additions & 0 deletions docs/data/date-pickers/date-picker/CustomDay.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import * as React from 'react';
import { styled } from '@mui/material/styles';
import TextField from '@mui/material/TextField';
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { StaticDatePicker } from '@mui/x-date-pickers/StaticDatePicker';
import { PickersDay, PickersDayProps } from '@mui/x-date-pickers/PickersDay';
import endOfWeek from 'date-fns/endOfWeek';
import isSameDay from 'date-fns/isSameDay';
import isWithinInterval from 'date-fns/isWithinInterval';
import startOfWeek from 'date-fns/startOfWeek';

type CustomPickerDayProps = PickersDayProps<Date> & {
dayIsBetween: boolean;
isFirstDay: boolean;
isLastDay: boolean;
};

const CustomPickersDay = styled(PickersDay, {
shouldForwardProp: (prop) =>
prop !== 'dayIsBetween' && prop !== 'isFirstDay' && prop !== 'isLastDay',
})<CustomPickerDayProps>(({ theme, dayIsBetween, isFirstDay, isLastDay }) => ({
...(dayIsBetween && {
borderRadius: 0,
backgroundColor: theme.palette.primary.main,
color: theme.palette.common.white,
'&:hover, &:focus': {
backgroundColor: theme.palette.primary.dark,
},
}),
...(isFirstDay && {
borderTopLeftRadius: '50%',
borderBottomLeftRadius: '50%',
}),
...(isLastDay && {
borderTopRightRadius: '50%',
borderBottomRightRadius: '50%',
}),
})) as React.ComponentType<CustomPickerDayProps>;

export default function CustomDay() {
const [value, setValue] = React.useState<Date | null>(new Date());

const renderWeekPickerDay = (
date: Date,
selectedDates: Array<Date | null>,
pickersDayProps: PickersDayProps<Date>,
) => {
if (!value) {
return <PickersDay {...pickersDayProps} />;
}

const start = startOfWeek(value);
const end = endOfWeek(value);

const dayIsBetween = isWithinInterval(date, { start, end });
const isFirstDay = isSameDay(date, start);
const isLastDay = isSameDay(date, end);

return (
<CustomPickersDay
{...pickersDayProps}
disableMargin
dayIsBetween={dayIsBetween}
isFirstDay={isFirstDay}
isLastDay={isLastDay}
/>
);
};

return (
<LocalizationProvider dateAdapter={AdapterDateFns}>
<StaticDatePicker
displayStaticWrapperAs="desktop"
label="Week picker"
value={value}
onChange={(newValue) => {
setValue(newValue);
}}
renderDay={renderWeekPickerDay}
renderInput={(params) => <TextField {...params} />}
inputFormat="'Week of' MMM d"
/>
</LocalizationProvider>
);
}
13 changes: 13 additions & 0 deletions docs/data/date-pickers/date-picker/CustomDay.tsx.preview
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<LocalizationProvider dateAdapter={AdapterDateFns}>
<StaticDatePicker
displayStaticWrapperAs="desktop"
label="Week picker"
value={value}
onChange={(newValue) => {
setValue(newValue);
}}
renderDay={renderWeekPickerDay}
renderInput={(params) => <TextField {...params} />}
inputFormat="'Week of' MMM d"
/>
</LocalizationProvider>
27 changes: 27 additions & 0 deletions docs/data/date-pickers/date-picker/CustomInput.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import * as React from 'react';
import Box from '@mui/material/Box';
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { DatePicker } from '@mui/x-date-pickers/DatePicker';

export default function CustomInput() {
const [value, setValue] = React.useState(new Date());

return (
<LocalizationProvider dateAdapter={AdapterDateFns}>
<DatePicker
label="Custom input"
value={value}
onChange={(newValue) => {
setValue(newValue);
}}
renderInput={({ inputRef, inputProps, InputProps }) => (
<Box sx={{ display: 'flex', alignItems: 'center' }}>
<input ref={inputRef} {...inputProps} />
{InputProps?.endAdornment}
</Box>
)}
/>
</LocalizationProvider>
);
}
27 changes: 27 additions & 0 deletions docs/data/date-pickers/date-picker/CustomInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import * as React from 'react';
import Box from '@mui/material/Box';
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
import { DatePicker } from '@mui/x-date-pickers/DatePicker';

export default function CustomInput() {
const [value, setValue] = React.useState<Date | null>(new Date());

return (
<LocalizationProvider dateAdapter={AdapterDateFns}>
<DatePicker
label="Custom input"
value={value}
onChange={(newValue) => {
setValue(newValue);
}}
renderInput={({ inputRef, inputProps, InputProps }) => (
<Box sx={{ display: 'flex', alignItems: 'center' }}>
<input ref={inputRef} {...inputProps} />
{InputProps?.endAdornment}
</Box>
)}
/>
</LocalizationProvider>
);
}
15 changes: 15 additions & 0 deletions docs/data/date-pickers/date-picker/CustomInput.tsx.preview
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<LocalizationProvider dateAdapter={AdapterDateFns}>
<DatePicker
label="Custom input"
value={value}
onChange={(newValue) => {
setValue(newValue);
}}
renderInput={({ inputRef, inputProps, InputProps }) => (
<Box sx={{ display: 'flex', alignItems: 'center' }}>
<input ref={inputRef} {...inputProps} />
{InputProps?.endAdornment}
</Box>
)}
/>
</LocalizationProvider>
Loading