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 ;
}
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 (
);
};
return (
{
setValue(newValue);
}}
renderDay={renderWeekPickerDay}
renderInput={(params) => }
inputFormat="'Week of' MMM d"
/>
);
}