All files / src/theme/ui/overrides/components date-picker.jsx

73.68% Statements 14/19
100% Branches 2/2
37.5% Functions 3/8
100% Lines 14/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85              10x                     10x   10x   10x   10x   10x   10x   10x 70x                     70x     10x 40x                   40x       91x                                                
 
import { buttonClasses } from '@mui/material/Button';
 
import Iconify from "@/utils/components/iconify";
 
// ----------------------------------------------------------------------
 
const dateList = [
  'DatePicker',
  'DateTimePicker',
  'StaticDatePicker',
  'DesktopDatePicker',
  'DesktopDateTimePicker',
  //
  'MobileDatePicker',
  'MobileDateTimePicker',
];
 
const timeList = ['TimePicker', 'MobileTimePicker', 'StaticTimePicker', 'DesktopTimePicker'];
 
const switchIcon = () => <Iconify icon="eva:chevron-down-fill" width={24} />;
 
const leftIcon = () => <Iconify icon="eva:arrow-ios-back-fill" width={24} />;
 
const rightIcon = () => <Iconify icon="eva:arrow-ios-forward-fill" width={24} />;
 
const calendarIcon = () => <Iconify icon="solar:calendar-minimalistic-linear" width={24} />;
 
const clockIcon = () => <Iconify icon="solar:clock-circle-outline" width={24} />;
 
const desktopTypes = dateList.reduce((result, currentValue) => {
  result[`Mui${currentValue}`] = {
    defaultProps: {
      slots: {
        openPickerIcon: calendarIcon,
        leftArrowIcon: leftIcon,
        rightArrowIcon: rightIcon,
        switchViewIcon: switchIcon,
      },
    },
  };
 
  return result;
}, {});
 
const timeTypes = timeList.reduce((result, currentValue) => {
  result[`Mui${currentValue}`] = {
    defaultProps: {
      slots: {
        openPickerIcon: clockIcon,
        rightArrowIcon: rightIcon,
        switchViewIcon: switchIcon,
      },
    },
  };
 
  return result;
}, {});
 
export function datePicker(theme) {
  return {
    MuiPickersLayout: {
      styleOverrides: {
        root: {
          '& .MuiPickersLayout-actionBar': {
            [`& .${buttonClasses.root}:last-of-type`]: {
              backgroundColor: theme.palette.text.primary,
              color:
                theme.palette.mode === 'light'
                  ? theme.palette.common.white
                  : theme.palette.grey[800],
            },
          },
        },
      },
    },
 
    // Date
    ...desktopTypes,
 
    // Time
    ...timeTypes,
  };
}