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