@docsvision/material-ui-pickers 3.2.0-beta.25 → 3.2.0-beta.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.size-snapshot.json +26 -0
- package/9db1cba1a61cb58db53f38425bbd1f95.7z +0 -0
- package/{DatePicker → build/DatePicker}/DatePicker.d.ts +2 -2
- package/{DatePicker → build/DatePicker}/DatePicker.js +1 -1
- package/{DateTimePicker → build/DateTimePicker}/DateTimePicker.js +1 -1
- package/{Picker → build/Picker}/Picker.js +1 -1
- package/{TimePicker → build/TimePicker}/TimePicker.js +1 -1
- package/{_helpers → build/_helpers}/text-field-helper.d.ts +1 -1
- package/{_shared → build/_shared}/KeyboardDateInput.js +1 -1
- package/{_shared → build/_shared}/ModalDialog.d.ts +2 -2
- package/{_shared → build/_shared}/PureDateInput.js +1 -1
- package/{_shared → build/_shared}/ToolbarButton.d.ts +2 -2
- package/{_shared → build/_shared}/hooks/useKeyboardPickerState.js +2 -2
- package/{constants → build/constants}/prop-types.js +2 -2
- package/{dist → build/dist}/material-ui-pickers.esm.js +12 -12
- package/build/dist/material-ui-pickers.esm.js.map +1 -0
- package/{dist → build/dist}/material-ui-pickers.js +62 -62
- package/build/dist/material-ui-pickers.js.map +1 -0
- package/{dist → build/dist}/material-ui-pickers.umd.js +5790 -4511
- package/build/dist/material-ui-pickers.umd.min.js +1 -0
- package/build/package.json +62 -0
- package/{views → build/views}/Calendar/Calendar.js +2 -2
- package/{views → build/views}/Clock/Clock.d.ts +1 -1
- package/{views → build/views}/Clock/ClockPointer.d.ts +1 -1
- package/copy.js +58 -0
- package/package.json +135 -62
- package/remove-prop-types.js +37 -0
- package/rollup.config.js +145 -0
- package/src/DatePicker/DatePicker.tsx +91 -0
- package/src/DatePicker/DatePickerToolbar.tsx +75 -0
- package/src/DatePicker/index.ts +7 -0
- package/src/DateTimePicker/DateTimePicker.tsx +72 -0
- package/src/DateTimePicker/DateTimePickerTabs.tsx +86 -0
- package/src/DateTimePicker/DateTimePickerToolbar.tsx +123 -0
- package/src/DateTimePicker/index.ts +7 -0
- package/src/MuiPickersUtilsProvider.tsx +39 -0
- package/src/Picker/Picker.tsx +275 -0
- package/src/Picker/WrappedKeyboardPicker.tsx +136 -0
- package/src/Picker/WrappedPurePicker.tsx +128 -0
- package/src/Rifm/Rifm.ts +213 -0
- package/src/TimePicker/TimePicker.tsx +67 -0
- package/src/TimePicker/TimePickerToolbar.tsx +180 -0
- package/src/TimePicker/index.tsx +7 -0
- package/src/__tests__/DatePicker/Calendar.test.tsx +51 -0
- package/src/__tests__/DatePicker/Month.test.tsx +36 -0
- package/src/__tests__/DatePicker/MonthSelection.test.tsx +37 -0
- package/src/__tests__/MuiPickersUtilsProvider.test.tsx +21 -0
- package/src/__tests__/TimePicker/Clock.test.tsx +68 -0
- package/src/__tests__/_helpers/date-utils.test.tsx +197 -0
- package/src/__tests__/_helpers/text-field-helper.test.tsx +34 -0
- package/src/__tests__/_shared/ModalDialog.test.tsx +109 -0
- package/src/__tests__/e2e/DatePicker.test.tsx +233 -0
- package/src/__tests__/e2e/DatePickerProps.test.tsx +18 -0
- package/src/__tests__/e2e/DatePickerRoot.test.tsx +154 -0
- package/src/__tests__/e2e/DateTimePicker.test.tsx +86 -0
- package/src/__tests__/e2e/DateTimePickerRoot.test.tsx +72 -0
- package/src/__tests__/e2e/KeyboardDatePicker.test.tsx +140 -0
- package/src/__tests__/e2e/KeyboardDateTimePicker.test.tsx +48 -0
- package/src/__tests__/e2e/Theme.test.tsx +30 -0
- package/src/__tests__/e2e/TimePicker.test.tsx +121 -0
- package/src/__tests__/e2e/commands.tsx +8 -0
- package/src/__tests__/setup.js +26 -0
- package/src/__tests__/test-utils.tsx +45 -0
- package/src/__tests__/tsconfig.json +5 -0
- package/src/_helpers/date-utils.ts +92 -0
- package/src/_helpers/text-field-helper.ts +239 -0
- package/src/_helpers/time-utils.ts +83 -0
- package/src/_helpers/utils.ts +8 -0
- package/src/_shared/KeyboardDateInput.tsx +161 -0
- package/src/_shared/ModalDialog.tsx +114 -0
- package/src/_shared/PickerToolbar.tsx +52 -0
- package/src/_shared/PureDateInput.tsx +45 -0
- package/src/_shared/ToolbarButton.tsx +63 -0
- package/src/_shared/ToolbarText.tsx +49 -0
- package/src/_shared/WithUtils.tsx +19 -0
- package/src/_shared/hooks/useIsLandscape.tsx +27 -0
- package/src/_shared/hooks/useKeyDown.ts +34 -0
- package/src/_shared/hooks/useKeyboardPickerState.ts +72 -0
- package/src/_shared/hooks/useOpenState.ts +22 -0
- package/src/_shared/hooks/usePickerState.ts +134 -0
- package/src/_shared/hooks/useUtils.ts +20 -0
- package/src/_shared/hooks/useViews.tsx +31 -0
- package/src/_shared/icons/ArrowLeftIcon.tsx +11 -0
- package/src/_shared/icons/ArrowRightIcon.tsx +11 -0
- package/src/_shared/icons/DateRangeIcon.tsx +11 -0
- package/src/_shared/icons/KeyboardIcon.tsx +11 -0
- package/src/_shared/icons/TimeIcon.tsx +12 -0
- package/src/constants/ClockType.ts +11 -0
- package/src/constants/dimensions.ts +5 -0
- package/src/constants/prop-types.ts +37 -0
- package/src/index.ts +48 -0
- package/src/typings/BasePicker.tsx +60 -0
- package/src/typings/date.ts +3 -0
- package/src/typings/extendMui.ts +10 -0
- package/src/typings/overrides.ts +44 -0
- package/src/views/Calendar/Calendar.tsx +361 -0
- package/src/views/Calendar/CalendarHeader.tsx +141 -0
- package/src/views/Calendar/Day.tsx +97 -0
- package/src/views/Calendar/DayWrapper.tsx +33 -0
- package/src/views/Calendar/SlideTransition.tsx +100 -0
- package/src/views/Clock/Clock.tsx +172 -0
- package/src/views/Clock/ClockNumber.tsx +91 -0
- package/src/views/Clock/ClockNumbers.tsx +76 -0
- package/src/views/Clock/ClockPointer.tsx +104 -0
- package/src/views/Clock/ClockView.tsx +105 -0
- package/src/views/Month/Month.tsx +76 -0
- package/src/views/Month/MonthView.tsx +94 -0
- package/src/views/Year/Year.tsx +77 -0
- package/src/views/Year/YearView.tsx +91 -0
- package/src/wrappers/InlineWrapper.tsx +80 -0
- package/src/wrappers/ModalWrapper.tsx +113 -0
- package/src/wrappers/StaticWrapper.tsx +22 -0
- package/src/wrappers/Wrapper.tsx +75 -0
- package/tsconfig.json +21 -0
- package/typings.d.ts +6 -0
- package/dist/material-ui-pickers.esm.js.map +0 -1
- package/dist/material-ui-pickers.js.map +0 -1
- package/dist/material-ui-pickers.umd.min.js +0 -1
- /package/{DatePicker → build/DatePicker}/DatePickerToolbar.d.ts +0 -0
- /package/{DatePicker → build/DatePicker}/DatePickerToolbar.js +0 -0
- /package/{DatePicker → build/DatePicker}/index.d.ts +0 -0
- /package/{DatePicker → build/DatePicker}/index.js +0 -0
- /package/{DateTimePicker → build/DateTimePicker}/DateTimePicker.d.ts +0 -0
- /package/{DateTimePicker → build/DateTimePicker}/DateTimePickerTabs.d.ts +0 -0
- /package/{DateTimePicker → build/DateTimePicker}/DateTimePickerTabs.js +0 -0
- /package/{DateTimePicker → build/DateTimePicker}/DateTimePickerToolbar.d.ts +0 -0
- /package/{DateTimePicker → build/DateTimePicker}/DateTimePickerToolbar.js +0 -0
- /package/{DateTimePicker → build/DateTimePicker}/index.d.ts +0 -0
- /package/{DateTimePicker → build/DateTimePicker}/index.js +0 -0
- /package/{MuiPickersUtilsProvider.d.ts → build/MuiPickersUtilsProvider.d.ts} +0 -0
- /package/{MuiPickersUtilsProvider.js → build/MuiPickersUtilsProvider.js} +0 -0
- /package/{Picker → build/Picker}/Picker.d.ts +0 -0
- /package/{Picker → build/Picker}/WrappedKeyboardPicker.d.ts +0 -0
- /package/{Picker → build/Picker}/WrappedKeyboardPicker.js +0 -0
- /package/{Picker → build/Picker}/WrappedPurePicker.d.ts +0 -0
- /package/{Picker → build/Picker}/WrappedPurePicker.js +0 -0
- /package/{README.md → build/README.md} +0 -0
- /package/{Rifm → build/Rifm}/Rifm.d.ts +0 -0
- /package/{Rifm → build/Rifm}/Rifm.js +0 -0
- /package/{TimePicker → build/TimePicker}/TimePicker.d.ts +0 -0
- /package/{TimePicker → build/TimePicker}/TimePickerToolbar.d.ts +0 -0
- /package/{TimePicker → build/TimePicker}/TimePickerToolbar.js +0 -0
- /package/{TimePicker → build/TimePicker}/index.d.ts +0 -0
- /package/{TimePicker → build/TimePicker}/index.js +0 -0
- /package/{_helpers → build/_helpers}/date-utils.d.ts +0 -0
- /package/{_helpers → build/_helpers}/date-utils.js +0 -0
- /package/{_helpers → build/_helpers}/text-field-helper.js +0 -0
- /package/{_helpers → build/_helpers}/time-utils.d.ts +0 -0
- /package/{_helpers → build/_helpers}/time-utils.js +0 -0
- /package/{_helpers → build/_helpers}/utils.d.ts +0 -0
- /package/{_helpers → build/_helpers}/utils.js +0 -0
- /package/{_shared → build/_shared}/KeyboardDateInput.d.ts +0 -0
- /package/{_shared → build/_shared}/ModalDialog.js +0 -0
- /package/{_shared → build/_shared}/PickerToolbar.d.ts +0 -0
- /package/{_shared → build/_shared}/PickerToolbar.js +0 -0
- /package/{_shared → build/_shared}/PureDateInput.d.ts +0 -0
- /package/{_shared → build/_shared}/ToolbarButton.js +0 -0
- /package/{_shared → build/_shared}/ToolbarText.d.ts +0 -0
- /package/{_shared → build/_shared}/ToolbarText.js +0 -0
- /package/{_shared → build/_shared}/WithUtils.d.ts +0 -0
- /package/{_shared → build/_shared}/WithUtils.js +0 -0
- /package/{_shared → build/_shared}/hooks/useIsLandscape.d.ts +0 -0
- /package/{_shared → build/_shared}/hooks/useIsLandscape.js +0 -0
- /package/{_shared → build/_shared}/hooks/useKeyDown.d.ts +0 -0
- /package/{_shared → build/_shared}/hooks/useKeyDown.js +0 -0
- /package/{_shared → build/_shared}/hooks/useKeyboardPickerState.d.ts +0 -0
- /package/{_shared → build/_shared}/hooks/useOpenState.d.ts +0 -0
- /package/{_shared → build/_shared}/hooks/useOpenState.js +0 -0
- /package/{_shared → build/_shared}/hooks/usePickerState.d.ts +0 -0
- /package/{_shared → build/_shared}/hooks/usePickerState.js +0 -0
- /package/{_shared → build/_shared}/hooks/useUtils.d.ts +0 -0
- /package/{_shared → build/_shared}/hooks/useUtils.js +0 -0
- /package/{_shared → build/_shared}/hooks/useViews.d.ts +0 -0
- /package/{_shared → build/_shared}/hooks/useViews.js +0 -0
- /package/{_shared → build/_shared}/icons/ArrowLeftIcon.d.ts +0 -0
- /package/{_shared → build/_shared}/icons/ArrowLeftIcon.js +0 -0
- /package/{_shared → build/_shared}/icons/ArrowRightIcon.d.ts +0 -0
- /package/{_shared → build/_shared}/icons/ArrowRightIcon.js +0 -0
- /package/{_shared → build/_shared}/icons/DateRangeIcon.d.ts +0 -0
- /package/{_shared → build/_shared}/icons/DateRangeIcon.js +0 -0
- /package/{_shared → build/_shared}/icons/KeyboardIcon.d.ts +0 -0
- /package/{_shared → build/_shared}/icons/KeyboardIcon.js +0 -0
- /package/{_shared → build/_shared}/icons/TimeIcon.d.ts +0 -0
- /package/{_shared → build/_shared}/icons/TimeIcon.js +0 -0
- /package/{constants → build/constants}/ClockType.d.ts +0 -0
- /package/{constants → build/constants}/ClockType.js +0 -0
- /package/{constants → build/constants}/dimensions.d.ts +0 -0
- /package/{constants → build/constants}/dimensions.js +0 -0
- /package/{constants → build/constants}/prop-types.d.ts +0 -0
- /package/{index.d.ts → build/index.d.ts} +0 -0
- /package/{index.js → build/index.js} +0 -0
- /package/{typings → build/typings}/BasePicker.d.ts +0 -0
- /package/{typings → build/typings}/BasePicker.js +0 -0
- /package/{typings → build/typings}/date.d.ts +0 -0
- /package/{typings → build/typings}/date.js +0 -0
- /package/{typings → build/typings}/extendMui.d.ts +0 -0
- /package/{typings → build/typings}/extendMui.js +0 -0
- /package/{typings → build/typings}/overrides.d.ts +0 -0
- /package/{typings → build/typings}/overrides.js +0 -0
- /package/{views → build/views}/Calendar/Calendar.d.ts +0 -0
- /package/{views → build/views}/Calendar/CalendarHeader.d.ts +0 -0
- /package/{views → build/views}/Calendar/CalendarHeader.js +0 -0
- /package/{views → build/views}/Calendar/Day.d.ts +0 -0
- /package/{views → build/views}/Calendar/Day.js +0 -0
- /package/{views → build/views}/Calendar/DayWrapper.d.ts +0 -0
- /package/{views → build/views}/Calendar/DayWrapper.js +0 -0
- /package/{views → build/views}/Calendar/SlideTransition.d.ts +0 -0
- /package/{views → build/views}/Calendar/SlideTransition.js +0 -0
- /package/{views → build/views}/Clock/Clock.js +0 -0
- /package/{views → build/views}/Clock/ClockNumber.d.ts +0 -0
- /package/{views → build/views}/Clock/ClockNumber.js +0 -0
- /package/{views → build/views}/Clock/ClockNumbers.d.ts +0 -0
- /package/{views → build/views}/Clock/ClockNumbers.js +0 -0
- /package/{views → build/views}/Clock/ClockPointer.js +0 -0
- /package/{views → build/views}/Clock/ClockView.d.ts +0 -0
- /package/{views → build/views}/Clock/ClockView.js +0 -0
- /package/{views → build/views}/Month/Month.d.ts +0 -0
- /package/{views → build/views}/Month/Month.js +0 -0
- /package/{views → build/views}/Month/MonthView.d.ts +0 -0
- /package/{views → build/views}/Month/MonthView.js +0 -0
- /package/{views → build/views}/Year/Year.d.ts +0 -0
- /package/{views → build/views}/Year/Year.js +0 -0
- /package/{views → build/views}/Year/YearView.d.ts +0 -0
- /package/{views → build/views}/Year/YearView.js +0 -0
- /package/{wrappers → build/wrappers}/InlineWrapper.d.ts +0 -0
- /package/{wrappers → build/wrappers}/InlineWrapper.js +0 -0
- /package/{wrappers → build/wrappers}/ModalWrapper.d.ts +0 -0
- /package/{wrappers → build/wrappers}/ModalWrapper.js +0 -0
- /package/{wrappers → build/wrappers}/StaticWrapper.d.ts +0 -0
- /package/{wrappers → build/wrappers}/StaticWrapper.js +0 -0
- /package/{wrappers → build/wrappers}/Wrapper.d.ts +0 -0
- /package/{wrappers → build/wrappers}/Wrapper.js +0 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { MaterialUiPickersDate } from './date';
|
|
2
|
+
import { WrapperVariant } from '../wrappers/Wrapper';
|
|
3
|
+
import { ParsableDate } from '../constants/prop-types';
|
|
4
|
+
import { ToolbarComponentProps } from '../Picker/Picker';
|
|
5
|
+
|
|
6
|
+
export interface BasePickerProps {
|
|
7
|
+
/** Picker value */
|
|
8
|
+
value: ParsableDate;
|
|
9
|
+
/** onChange callback */
|
|
10
|
+
onChange: (date: MaterialUiPickersDate) => void;
|
|
11
|
+
/**
|
|
12
|
+
* Auto accept date on selection
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
autoOk?: boolean;
|
|
16
|
+
/** Format string */
|
|
17
|
+
format?: string;
|
|
18
|
+
/** Disable datepicker and text field */
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
/** Dynamic formatter of text field value */
|
|
21
|
+
labelFunc?: (date: MaterialUiPickersDate, invalidLabel: string) => string;
|
|
22
|
+
/** Date that will be initially highlighted if null was passed */
|
|
23
|
+
initialFocusedDate?: ParsableDate;
|
|
24
|
+
/**
|
|
25
|
+
* Message displaying in text field if date is invalid (doesn't work in keyboard mode)
|
|
26
|
+
* @default 'unknown'
|
|
27
|
+
*/
|
|
28
|
+
invalidLabel?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Message displaying in text field, if null passed (doesn't work in keyboard mode)
|
|
31
|
+
* @default ' '
|
|
32
|
+
*/
|
|
33
|
+
emptyLabel?: string;
|
|
34
|
+
/** Callback fired when date is accepted */
|
|
35
|
+
onAccept?: (date: MaterialUiPickersDate) => void;
|
|
36
|
+
/** Callback fired when new error should be displayed */
|
|
37
|
+
onError?: (error: React.ReactNode, value: MaterialUiPickersDate | ParsableDate) => void;
|
|
38
|
+
/** On open callback */
|
|
39
|
+
onOpen?: () => void;
|
|
40
|
+
/** On close callback */
|
|
41
|
+
onClose?: () => void;
|
|
42
|
+
/** Controlled picker open state */
|
|
43
|
+
open?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Hide toolbar and show only date/time views
|
|
46
|
+
* @default false
|
|
47
|
+
*/
|
|
48
|
+
disableToolbar?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Force rendering in particular orientation
|
|
51
|
+
* @default "portrait"
|
|
52
|
+
*/
|
|
53
|
+
orientation?: 'portrait' | 'landscape';
|
|
54
|
+
/* Component that will replace default toolbar renderer */
|
|
55
|
+
ToolbarComponent?: React.ComponentType<ToolbarComponentProps>;
|
|
56
|
+
variant?: WrapperVariant;
|
|
57
|
+
showShiftButtons?: boolean;
|
|
58
|
+
setShiftFunction?: (days: number) => Date;
|
|
59
|
+
shiftButtonValues?: Object;
|
|
60
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Omit } from '@material-ui/core';
|
|
2
|
+
/**
|
|
3
|
+
* All standard components exposed by `material-ui` are `StyledComponents` with
|
|
4
|
+
* certain `classes`, on which one can also set a top-level `className` and inline
|
|
5
|
+
* `style`.
|
|
6
|
+
*/
|
|
7
|
+
export type ExtendMui<C, Removals extends keyof C = never> = Omit<
|
|
8
|
+
C,
|
|
9
|
+
'classes' | 'theme' | Removals
|
|
10
|
+
>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { styles as ClockStyles } from '../views/Clock/Clock';
|
|
2
|
+
import { useStyles as DayStyles } from '../views/Calendar/Day';
|
|
3
|
+
import { styles as ModalDialogStyles } from '../_shared/ModalDialog';
|
|
4
|
+
import { styles as CalendarStyles } from '../views/Calendar/Calendar';
|
|
5
|
+
import { useStyles as MuiPickersYearStyles } from '../views/Year/Year';
|
|
6
|
+
import { styles as ToolbarButtonStyles } from '../_shared/ToolbarButton';
|
|
7
|
+
import { useStyles as MuiPickersMonthStyles } from '../views/Month/Month';
|
|
8
|
+
import { styles as ClockPointerStyles } from '../views/Clock/ClockPointer';
|
|
9
|
+
import { useStyles as PickerToolbarStyles } from '../_shared/PickerToolbar';
|
|
10
|
+
import { useStyles as ClockNumberStyles } from '../views/Clock/ClockNumber';
|
|
11
|
+
import { useStyles as DTTabsStyles } from '../DateTimePicker/DateTimePickerTabs';
|
|
12
|
+
import { useStyles as DatePickerRootStyles } from '../DatePicker/DatePickerToolbar';
|
|
13
|
+
import { useStyles as MuiPickersYearSelectionStyles } from '../views/Year/YearView';
|
|
14
|
+
import { StyleRules, StyleRulesCallback } from '@material-ui/core/styles/withStyles';
|
|
15
|
+
import { useStyles as CalendarHeaderStyles } from '../views/Calendar/CalendarHeader';
|
|
16
|
+
import { useStyles as DTHeaderStyles } from '../DateTimePicker/DateTimePickerToolbar';
|
|
17
|
+
import { useStyles as TimePickerToolbarStyles } from '../TimePicker/TimePickerToolbar';
|
|
18
|
+
import { useStyles as SlideTransitionStyles } from '../views/Calendar/SlideTransition';
|
|
19
|
+
import { useStyles as MuiPickersMonthSelectionStyles } from '../views/Month/MonthView';
|
|
20
|
+
import { useStyles as MuiPickerDTToolbarStyles } from '../DateTimePicker/DateTimePickerToolbar';
|
|
21
|
+
|
|
22
|
+
type Classes<T> = Partial<StyleRules<any>>;
|
|
23
|
+
|
|
24
|
+
export interface MuiPickersOverrides {
|
|
25
|
+
MuiPickersDay?: Classes<typeof DayStyles>;
|
|
26
|
+
MuiPickerDTHeader?: Classes<typeof DTHeaderStyles>;
|
|
27
|
+
MuiPickerDTTabs?: Classes<typeof DTTabsStyles>;
|
|
28
|
+
MuiPickersCalendar?: Classes<typeof CalendarStyles>;
|
|
29
|
+
MuiPickersCalendarHeader?: Classes<typeof CalendarHeaderStyles>;
|
|
30
|
+
MuiPickersSlideTransition?: Classes<typeof SlideTransitionStyles>;
|
|
31
|
+
MuiPickersYearSelectionStyles?: Classes<typeof MuiPickersYearSelectionStyles>;
|
|
32
|
+
MuiPickersYear?: Classes<typeof MuiPickersYearStyles>;
|
|
33
|
+
MuiPickersMonthSelection?: Classes<typeof MuiPickersMonthSelectionStyles>;
|
|
34
|
+
MuiPickersMonth?: Classes<typeof MuiPickersMonthStyles>;
|
|
35
|
+
MuiPickersTimePickerToolbar?: Classes<typeof TimePickerToolbarStyles>;
|
|
36
|
+
MuiPickersClock?: Classes<typeof ClockStyles>;
|
|
37
|
+
MuiPickersClockNumber?: Classes<typeof ClockNumberStyles>;
|
|
38
|
+
MuiPickersClockPointer?: Classes<typeof ClockPointerStyles>;
|
|
39
|
+
MuiPickersModal?: Classes<typeof ModalDialogStyles>;
|
|
40
|
+
MuiPickersToolbar?: Classes<typeof PickerToolbarStyles>;
|
|
41
|
+
MuiPickersToolbarButton?: Classes<typeof ToolbarButtonStyles>;
|
|
42
|
+
MuiPickersDatePickerRoot?: Classes<typeof DatePickerRootStyles>;
|
|
43
|
+
MuiPickerDTToolbar?: Classes<typeof MuiPickerDTToolbarStyles>;
|
|
44
|
+
}
|
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as PropTypes from 'prop-types';
|
|
3
|
+
import Day from './Day';
|
|
4
|
+
import DayWrapper from './DayWrapper';
|
|
5
|
+
import CalendarHeader from './CalendarHeader';
|
|
6
|
+
import CircularProgress from '@material-ui/core/CircularProgress';
|
|
7
|
+
import SlideTransition, { SlideDirection } from './SlideTransition';
|
|
8
|
+
import { Theme } from '@material-ui/core';
|
|
9
|
+
import { MaterialUiPickersDate } from '../../typings/date';
|
|
10
|
+
import { runKeyHandler } from '../../_shared/hooks/useKeyDown';
|
|
11
|
+
import { IconButtonProps } from '@material-ui/core/IconButton';
|
|
12
|
+
import { withStyles, WithStyles } from '@material-ui/core/styles';
|
|
13
|
+
import { findClosestEnabledDate } from '../../_helpers/date-utils';
|
|
14
|
+
import { withUtils, WithUtilsProps } from '../../_shared/WithUtils';
|
|
15
|
+
|
|
16
|
+
export interface OutterCalendarProps {
|
|
17
|
+
/** Left arrow icon */
|
|
18
|
+
leftArrowIcon?: React.ReactNode;
|
|
19
|
+
/** Right arrow icon */
|
|
20
|
+
rightArrowIcon?: React.ReactNode;
|
|
21
|
+
/** Custom renderer for day */
|
|
22
|
+
renderDay?: (
|
|
23
|
+
day: MaterialUiPickersDate,
|
|
24
|
+
selectedDate: MaterialUiPickersDate,
|
|
25
|
+
dayInCurrentMonth: boolean,
|
|
26
|
+
dayComponent: JSX.Element
|
|
27
|
+
) => JSX.Element;
|
|
28
|
+
/**
|
|
29
|
+
* Enables keyboard listener for moving between days in calendar
|
|
30
|
+
* @default true
|
|
31
|
+
*/
|
|
32
|
+
allowKeyboardControl?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Props to pass to left arrow button
|
|
35
|
+
* @type {Partial<IconButtonProps>}
|
|
36
|
+
*/
|
|
37
|
+
leftArrowButtonProps?: Partial<IconButtonProps>;
|
|
38
|
+
/**
|
|
39
|
+
* Props to pass to right arrow button
|
|
40
|
+
* @type {Partial<IconButtonProps>}
|
|
41
|
+
*/
|
|
42
|
+
rightArrowButtonProps?: Partial<IconButtonProps>;
|
|
43
|
+
/** Disable specific date */
|
|
44
|
+
shouldDisableDate?: (day: MaterialUiPickersDate) => boolean;
|
|
45
|
+
/** Callback firing on month change. Return promise to render spinner till it will not be resolved */
|
|
46
|
+
onMonthChange?: (date: MaterialUiPickersDate) => void | Promise<void>;
|
|
47
|
+
/** Custom loading indicator */
|
|
48
|
+
loadingIndicator?: JSX.Element;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface CalendarProps
|
|
52
|
+
extends OutterCalendarProps,
|
|
53
|
+
WithUtilsProps,
|
|
54
|
+
WithStyles<typeof styles, true> {
|
|
55
|
+
/** Calendar Date */
|
|
56
|
+
date: MaterialUiPickersDate;
|
|
57
|
+
/** Calendar onChange */
|
|
58
|
+
onChange: (date: MaterialUiPickersDate, isFinish?: boolean) => void;
|
|
59
|
+
/** Min date */
|
|
60
|
+
minDate?: MaterialUiPickersDate;
|
|
61
|
+
/** Max date */
|
|
62
|
+
maxDate?: MaterialUiPickersDate;
|
|
63
|
+
/** Disable past dates */
|
|
64
|
+
disablePast?: boolean;
|
|
65
|
+
/** Disable future dates */
|
|
66
|
+
disableFuture?: boolean;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface CalendarState {
|
|
70
|
+
slideDirection: SlideDirection;
|
|
71
|
+
currentMonth: MaterialUiPickersDate;
|
|
72
|
+
lastDate?: MaterialUiPickersDate;
|
|
73
|
+
loadingQueue: number;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const KeyDownListener = ({ onKeyDown }: { onKeyDown: (e: KeyboardEvent) => void }) => {
|
|
77
|
+
React.useEffect(() => {
|
|
78
|
+
window.addEventListener('keydown', onKeyDown);
|
|
79
|
+
return () => {
|
|
80
|
+
window.removeEventListener('keydown', onKeyDown);
|
|
81
|
+
};
|
|
82
|
+
}, [onKeyDown]);
|
|
83
|
+
|
|
84
|
+
return null;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export class Calendar extends React.Component<CalendarProps, CalendarState> {
|
|
88
|
+
static propTypes: any = {
|
|
89
|
+
renderDay: PropTypes.func,
|
|
90
|
+
shouldDisableDate: PropTypes.func,
|
|
91
|
+
allowKeyboardControl: PropTypes.bool,
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
static defaultProps: Partial<CalendarProps> = {
|
|
95
|
+
minDate: new Date('1900-01-01'),
|
|
96
|
+
maxDate: new Date('2200-01-01'),
|
|
97
|
+
disablePast: false,
|
|
98
|
+
disableFuture: false,
|
|
99
|
+
allowKeyboardControl: true,
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
static getDerivedStateFromProps(nextProps: CalendarProps, state: CalendarState) {
|
|
103
|
+
const { utils, date: nextDate } = nextProps;
|
|
104
|
+
|
|
105
|
+
if (!utils.isEqual(nextDate, state.lastDate)) {
|
|
106
|
+
const nextMonth = utils.getMonth(nextDate);
|
|
107
|
+
const lastDate = state.lastDate || nextDate;
|
|
108
|
+
const lastMonth = utils.getMonth(lastDate);
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
lastDate: nextDate,
|
|
112
|
+
currentMonth: nextProps.utils.startOfMonth(nextDate),
|
|
113
|
+
// prettier-ignore
|
|
114
|
+
slideDirection: nextMonth === lastMonth
|
|
115
|
+
? state.slideDirection
|
|
116
|
+
: utils.isAfterDay(nextDate, lastDate)
|
|
117
|
+
? 'left'
|
|
118
|
+
: 'right'
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
state: CalendarState = {
|
|
126
|
+
slideDirection: 'left',
|
|
127
|
+
currentMonth: this.props.utils.startOfMonth(this.props.date),
|
|
128
|
+
loadingQueue: 0,
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
componentDidMount() {
|
|
132
|
+
const { date, minDate, maxDate, utils, disablePast, disableFuture } = this.props;
|
|
133
|
+
|
|
134
|
+
if (this.shouldDisableDate(date)) {
|
|
135
|
+
const closestEnabledDate = findClosestEnabledDate({
|
|
136
|
+
date,
|
|
137
|
+
utils,
|
|
138
|
+
minDate: utils.date(minDate),
|
|
139
|
+
maxDate: utils.date(maxDate),
|
|
140
|
+
disablePast: Boolean(disablePast),
|
|
141
|
+
disableFuture: Boolean(disableFuture),
|
|
142
|
+
shouldDisableDate: this.shouldDisableDate,
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
this.handleDaySelect(closestEnabledDate, false);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
private pushToLoadingQueue = () => {
|
|
150
|
+
const loadingQueue = this.state.loadingQueue + 1;
|
|
151
|
+
this.setState({ loadingQueue });
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
private popFromLoadingQueue = () => {
|
|
155
|
+
let loadingQueue = this.state.loadingQueue;
|
|
156
|
+
loadingQueue = loadingQueue <= 0 ? 0 : loadingQueue - 1;
|
|
157
|
+
this.setState({ loadingQueue });
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
handleChangeMonth = (newMonth: MaterialUiPickersDate, slideDirection: SlideDirection) => {
|
|
161
|
+
this.setState({ currentMonth: newMonth, slideDirection });
|
|
162
|
+
|
|
163
|
+
if (this.props.onMonthChange) {
|
|
164
|
+
const returnVal = this.props.onMonthChange(newMonth);
|
|
165
|
+
if (returnVal) {
|
|
166
|
+
this.pushToLoadingQueue();
|
|
167
|
+
returnVal.then(() => {
|
|
168
|
+
this.popFromLoadingQueue();
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
validateMinMaxDate = (day: MaterialUiPickersDate) => {
|
|
175
|
+
const { minDate, maxDate, utils, disableFuture, disablePast } = this.props;
|
|
176
|
+
const now = utils.date();
|
|
177
|
+
const moment = utils.moment;
|
|
178
|
+
|
|
179
|
+
return Boolean(
|
|
180
|
+
(disableFuture && utils.isAfterDay(day, now)) ||
|
|
181
|
+
(disablePast && moment(day).isBefore(now, 'second')) ||
|
|
182
|
+
(minDate && utils.isBeforeDay(day, utils.date(minDate))) ||
|
|
183
|
+
(maxDate && utils.isAfterDay(day, utils.date(maxDate)))
|
|
184
|
+
);
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
shouldDisablePrevMonth = () => {
|
|
188
|
+
const { utils, disablePast, minDate } = this.props;
|
|
189
|
+
|
|
190
|
+
const now = utils.date();
|
|
191
|
+
const firstEnabledMonth = utils.startOfMonth(
|
|
192
|
+
disablePast && utils.isAfter(now, utils.date(minDate)) ? now : utils.date(minDate)
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
return !utils.isBefore(firstEnabledMonth, this.state.currentMonth);
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
shouldDisableNextMonth = () => {
|
|
199
|
+
const { utils, disableFuture, maxDate } = this.props;
|
|
200
|
+
|
|
201
|
+
const now = utils.date();
|
|
202
|
+
const lastEnabledMonth = utils.startOfMonth(
|
|
203
|
+
disableFuture && utils.isBefore(now, utils.date(maxDate)) ? now : utils.date(maxDate)
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
return !utils.isAfter(lastEnabledMonth, this.state.currentMonth);
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
shouldDisableDate = (day: MaterialUiPickersDate) => {
|
|
210
|
+
const { shouldDisableDate } = this.props;
|
|
211
|
+
|
|
212
|
+
return this.validateMinMaxDate(day) || Boolean(shouldDisableDate && shouldDisableDate(day));
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
handleDaySelect = (day: MaterialUiPickersDate, isFinish = true) => {
|
|
216
|
+
const { date, utils } = this.props;
|
|
217
|
+
|
|
218
|
+
this.props.onChange(utils.mergeDateAndTime(day, date), isFinish);
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
moveToDay = (day: MaterialUiPickersDate) => {
|
|
222
|
+
const { utils } = this.props;
|
|
223
|
+
|
|
224
|
+
if (day && !this.shouldDisableDate(day)) {
|
|
225
|
+
if (utils.getMonth(day) !== utils.getMonth(this.state.currentMonth)) {
|
|
226
|
+
this.handleChangeMonth(utils.startOfMonth(day), 'left');
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
this.handleDaySelect(day, false);
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
handleKeyDown = (event: KeyboardEvent) => {
|
|
234
|
+
const { theme, date, utils } = this.props;
|
|
235
|
+
|
|
236
|
+
runKeyHandler(event, {
|
|
237
|
+
ArrowUp: () => this.moveToDay(utils.addDays(date, -7)),
|
|
238
|
+
ArrowDown: () => this.moveToDay(utils.addDays(date, 7)),
|
|
239
|
+
ArrowLeft: () => this.moveToDay(utils.addDays(date, theme.direction === 'ltr' ? -1 : 1)),
|
|
240
|
+
ArrowRight: () => this.moveToDay(utils.addDays(date, theme.direction === 'ltr' ? 1 : -1)),
|
|
241
|
+
});
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
private renderWeeks = () => {
|
|
245
|
+
const { utils, classes } = this.props;
|
|
246
|
+
const weeks = utils.getWeekArray(this.state.currentMonth);
|
|
247
|
+
|
|
248
|
+
return weeks.map(week => (
|
|
249
|
+
<div key={`week-${week[0]!.toString()}`} className={classes.week}>
|
|
250
|
+
{this.renderDays(week)}
|
|
251
|
+
</div>
|
|
252
|
+
));
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
private renderDays = (week: MaterialUiPickersDate[]) => {
|
|
256
|
+
const { date, renderDay, utils } = this.props;
|
|
257
|
+
|
|
258
|
+
const now = utils.date();
|
|
259
|
+
const selectedDate = utils.startOfDay(date);
|
|
260
|
+
const currentMonthNumber = utils.getMonth(this.state.currentMonth);
|
|
261
|
+
|
|
262
|
+
return week.map(day => {
|
|
263
|
+
const disabled = this.shouldDisableDate(day);
|
|
264
|
+
const isDayInCurrentMonth = utils.getMonth(day) === currentMonthNumber;
|
|
265
|
+
|
|
266
|
+
let dayComponent = (
|
|
267
|
+
<Day
|
|
268
|
+
disabled={disabled}
|
|
269
|
+
current={utils.isSameDay(day, now)}
|
|
270
|
+
hidden={!isDayInCurrentMonth}
|
|
271
|
+
selected={utils.isSameDay(selectedDate, day)}
|
|
272
|
+
>
|
|
273
|
+
{utils.getDayText(day)}
|
|
274
|
+
</Day>
|
|
275
|
+
);
|
|
276
|
+
|
|
277
|
+
if (renderDay) {
|
|
278
|
+
dayComponent = renderDay(day, selectedDate, isDayInCurrentMonth, dayComponent);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return (
|
|
282
|
+
<DayWrapper
|
|
283
|
+
value={day}
|
|
284
|
+
key={day!.toString()}
|
|
285
|
+
disabled={disabled}
|
|
286
|
+
dayInCurrentMonth={isDayInCurrentMonth}
|
|
287
|
+
onSelect={this.handleDaySelect}
|
|
288
|
+
>
|
|
289
|
+
{dayComponent}
|
|
290
|
+
</DayWrapper>
|
|
291
|
+
);
|
|
292
|
+
});
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
render() {
|
|
296
|
+
const { currentMonth, slideDirection } = this.state;
|
|
297
|
+
const {
|
|
298
|
+
classes,
|
|
299
|
+
allowKeyboardControl,
|
|
300
|
+
leftArrowButtonProps,
|
|
301
|
+
leftArrowIcon,
|
|
302
|
+
rightArrowButtonProps,
|
|
303
|
+
rightArrowIcon,
|
|
304
|
+
loadingIndicator,
|
|
305
|
+
} = this.props;
|
|
306
|
+
const loadingElement = loadingIndicator ? loadingIndicator : <CircularProgress />;
|
|
307
|
+
|
|
308
|
+
return (
|
|
309
|
+
<React.Fragment>
|
|
310
|
+
{allowKeyboardControl && <KeyDownListener onKeyDown={this.handleKeyDown} />}
|
|
311
|
+
|
|
312
|
+
<CalendarHeader
|
|
313
|
+
currentMonth={currentMonth!}
|
|
314
|
+
slideDirection={slideDirection}
|
|
315
|
+
onMonthChange={this.handleChangeMonth}
|
|
316
|
+
leftArrowIcon={leftArrowIcon}
|
|
317
|
+
leftArrowButtonProps={leftArrowButtonProps}
|
|
318
|
+
rightArrowIcon={rightArrowIcon}
|
|
319
|
+
rightArrowButtonProps={rightArrowButtonProps}
|
|
320
|
+
disablePrevMonth={this.shouldDisablePrevMonth()}
|
|
321
|
+
disableNextMonth={this.shouldDisableNextMonth()}
|
|
322
|
+
/>
|
|
323
|
+
|
|
324
|
+
<SlideTransition
|
|
325
|
+
slideDirection={slideDirection}
|
|
326
|
+
transKey={currentMonth!.toString()}
|
|
327
|
+
className={classes.transitionContainer}
|
|
328
|
+
>
|
|
329
|
+
<>
|
|
330
|
+
{(this.state.loadingQueue > 0 && (
|
|
331
|
+
<div className={classes.progressContainer}>{loadingElement}</div>
|
|
332
|
+
)) || <div>{this.renderWeeks()}</div>}
|
|
333
|
+
</>
|
|
334
|
+
</SlideTransition>
|
|
335
|
+
</React.Fragment>
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export const styles = (theme: Theme) => ({
|
|
341
|
+
transitionContainer: {
|
|
342
|
+
minHeight: 36 * 6,
|
|
343
|
+
marginTop: theme.spacing(1.5),
|
|
344
|
+
},
|
|
345
|
+
progressContainer: {
|
|
346
|
+
width: '100%',
|
|
347
|
+
height: '100%',
|
|
348
|
+
display: 'flex',
|
|
349
|
+
justifyContent: 'center',
|
|
350
|
+
alignItems: 'center',
|
|
351
|
+
},
|
|
352
|
+
week: {
|
|
353
|
+
display: 'flex',
|
|
354
|
+
justifyContent: 'center',
|
|
355
|
+
},
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
export default withStyles(styles, {
|
|
359
|
+
name: 'MuiPickersCalendar',
|
|
360
|
+
withTheme: true,
|
|
361
|
+
})(withUtils()(Calendar));
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import * as PropTypes from 'prop-types';
|
|
3
|
+
import Typography from '@material-ui/core/Typography';
|
|
4
|
+
import SlideTransition, { SlideDirection } from './SlideTransition';
|
|
5
|
+
import IconButton, { IconButtonProps } from '@material-ui/core/IconButton';
|
|
6
|
+
import { DateType } from '@date-io/type';
|
|
7
|
+
import { useUtils } from '../../_shared/hooks/useUtils';
|
|
8
|
+
import { MaterialUiPickersDate } from '../../typings/date';
|
|
9
|
+
import { makeStyles, useTheme } from '@material-ui/core/styles';
|
|
10
|
+
import { ArrowLeftIcon } from '../../_shared/icons/ArrowLeftIcon';
|
|
11
|
+
import { ArrowRightIcon } from '../../_shared/icons/ArrowRightIcon';
|
|
12
|
+
|
|
13
|
+
export interface CalendarHeaderProps {
|
|
14
|
+
currentMonth: DateType;
|
|
15
|
+
leftArrowIcon?: React.ReactNode;
|
|
16
|
+
rightArrowIcon?: React.ReactNode;
|
|
17
|
+
leftArrowButtonProps?: Partial<IconButtonProps>;
|
|
18
|
+
rightArrowButtonProps?: Partial<IconButtonProps>;
|
|
19
|
+
disablePrevMonth?: boolean;
|
|
20
|
+
disableNextMonth?: boolean;
|
|
21
|
+
slideDirection: SlideDirection;
|
|
22
|
+
onMonthChange: (date: MaterialUiPickersDate, direction: SlideDirection) => void | Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const useStyles = makeStyles(
|
|
26
|
+
theme => ({
|
|
27
|
+
switchHeader: {
|
|
28
|
+
display: 'flex',
|
|
29
|
+
justifyContent: 'space-between',
|
|
30
|
+
alignItems: 'center',
|
|
31
|
+
marginTop: theme.spacing(0.5),
|
|
32
|
+
marginBottom: theme.spacing(1),
|
|
33
|
+
},
|
|
34
|
+
transitionContainer: {
|
|
35
|
+
width: '100%',
|
|
36
|
+
overflow: 'hidden',
|
|
37
|
+
height: 23,
|
|
38
|
+
},
|
|
39
|
+
iconButton: {
|
|
40
|
+
zIndex: 1,
|
|
41
|
+
backgroundColor: theme.palette.background.paper,
|
|
42
|
+
},
|
|
43
|
+
daysHeader: {
|
|
44
|
+
display: 'flex',
|
|
45
|
+
justifyContent: 'center',
|
|
46
|
+
alignItems: 'center',
|
|
47
|
+
maxHeight: 16,
|
|
48
|
+
},
|
|
49
|
+
dayLabel: {
|
|
50
|
+
width: 36,
|
|
51
|
+
margin: '0 2px',
|
|
52
|
+
textAlign: 'center',
|
|
53
|
+
color: theme.palette.text.hint,
|
|
54
|
+
},
|
|
55
|
+
}),
|
|
56
|
+
{ name: 'MuiPickersCalendarHeader' }
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
export const CalendarHeader: React.SFC<CalendarHeaderProps> = ({
|
|
60
|
+
currentMonth,
|
|
61
|
+
onMonthChange,
|
|
62
|
+
leftArrowIcon,
|
|
63
|
+
rightArrowIcon,
|
|
64
|
+
leftArrowButtonProps,
|
|
65
|
+
rightArrowButtonProps,
|
|
66
|
+
disablePrevMonth,
|
|
67
|
+
disableNextMonth,
|
|
68
|
+
slideDirection,
|
|
69
|
+
}) => {
|
|
70
|
+
const utils = useUtils();
|
|
71
|
+
const classes = useStyles();
|
|
72
|
+
const theme = useTheme();
|
|
73
|
+
const rtl = theme.direction === 'rtl';
|
|
74
|
+
|
|
75
|
+
const selectNextMonth = () => onMonthChange(utils.getNextMonth(currentMonth), 'left');
|
|
76
|
+
const selectPreviousMonth = () => onMonthChange(utils.getPreviousMonth(currentMonth), 'right');
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<div>
|
|
80
|
+
<div className={classes.switchHeader}>
|
|
81
|
+
<IconButton
|
|
82
|
+
{...leftArrowButtonProps}
|
|
83
|
+
disabled={disablePrevMonth}
|
|
84
|
+
onClick={selectPreviousMonth}
|
|
85
|
+
className={classes.iconButton}
|
|
86
|
+
>
|
|
87
|
+
{rtl ? rightArrowIcon : leftArrowIcon}
|
|
88
|
+
</IconButton>
|
|
89
|
+
|
|
90
|
+
<SlideTransition
|
|
91
|
+
slideDirection={slideDirection}
|
|
92
|
+
transKey={currentMonth.toString()}
|
|
93
|
+
className={classes.transitionContainer}
|
|
94
|
+
>
|
|
95
|
+
<Typography align="center" variant="body1">
|
|
96
|
+
{utils.getCalendarHeaderText(currentMonth)}
|
|
97
|
+
</Typography>
|
|
98
|
+
</SlideTransition>
|
|
99
|
+
|
|
100
|
+
<IconButton
|
|
101
|
+
{...rightArrowButtonProps}
|
|
102
|
+
disabled={disableNextMonth}
|
|
103
|
+
onClick={selectNextMonth}
|
|
104
|
+
className={classes.iconButton}
|
|
105
|
+
>
|
|
106
|
+
{rtl ? leftArrowIcon : rightArrowIcon}
|
|
107
|
+
</IconButton>
|
|
108
|
+
</div>
|
|
109
|
+
|
|
110
|
+
<div className={classes.daysHeader}>
|
|
111
|
+
{utils.getWeekdays().map((day, index) => (
|
|
112
|
+
<Typography
|
|
113
|
+
key={index} // eslint-disable-line react/no-array-index-key
|
|
114
|
+
variant="caption"
|
|
115
|
+
className={classes.dayLabel}
|
|
116
|
+
>
|
|
117
|
+
{day}
|
|
118
|
+
</Typography>
|
|
119
|
+
))}
|
|
120
|
+
</div>
|
|
121
|
+
</div>
|
|
122
|
+
);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
CalendarHeader.displayName = 'CalendarHeader';
|
|
126
|
+
|
|
127
|
+
CalendarHeader.propTypes = {
|
|
128
|
+
leftArrowIcon: PropTypes.node,
|
|
129
|
+
rightArrowIcon: PropTypes.node,
|
|
130
|
+
disablePrevMonth: PropTypes.bool,
|
|
131
|
+
disableNextMonth: PropTypes.bool,
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
CalendarHeader.defaultProps = {
|
|
135
|
+
leftArrowIcon: <ArrowLeftIcon />,
|
|
136
|
+
rightArrowIcon: <ArrowRightIcon />,
|
|
137
|
+
disablePrevMonth: false,
|
|
138
|
+
disableNextMonth: false,
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
export default CalendarHeader;
|