This repository was archived by the owner on Sep 15, 2022. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathDatePicker.js
More file actions
110 lines (99 loc) · 2.87 KB
/
Copy pathDatePicker.js
File metadata and controls
110 lines (99 loc) · 2.87 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import "./style.css";
import "./stylemods.css";
/* eslint-disable react/require-default-props */
/* eslint-disable react/static-property-placement */
/* eslint-disable no-unused-expressions */
import * as React from "react";
import PropTypes from "prop-types";
import { addMonths } from "date-fns";
import Calendar from "./Calendar";
class DatePicker extends React.Component {
static propTypes = {
value: PropTypes.arrayOf(PropTypes.instanceOf(Date)),
hoverValue: PropTypes.arrayOf(PropTypes.instanceOf(Date)),
calendarDate: PropTypes.arrayOf(PropTypes.instanceOf(Date)),
index: PropTypes.number,
format: PropTypes.string,
isoWeek: PropTypes.bool,
limitEndYear: PropTypes.number,
classPrefix: PropTypes.string,
disabledDate: PropTypes.func,
onSelect: PropTypes.func,
onMouseMove: PropTypes.func,
onChangeCalendarDate: PropTypes.func
};
static defaultProps = {
value: [],
calendarDate: [new Date(), addMonths(new Date(), 1)],
format: "mm-dd-yyyy",
index: 0
};
constructor(props) {
super(props);
this.state = {
calendarState: undefined
};
}
onMoveForword = nextPageDate => {
const { onChangeCalendarDate, index } = this.props;
onChangeCalendarDate && onChangeCalendarDate(index, nextPageDate);
};
onMoveBackward = nextPageDate => {
const { onChangeCalendarDate, index } = this.props;
onChangeCalendarDate && onChangeCalendarDate(index, nextPageDate);
};
handleChangePageDate = nextPageDate => {
const { onChangeCalendarDate, index } = this.props;
onChangeCalendarDate && onChangeCalendarDate(index, nextPageDate);
this.setState({
calendarState: undefined
});
};
toggleMonthDropdown = () => {
const { calendarState } = this.state;
if (calendarState === "DROP_MONTH") {
this.setState({ calendarState: undefined });
} else {
this.setState({ calendarState: "DROP_MONTH" });
}
};
render() {
const {
format,
value,
hoverValue,
index,
calendarDate,
onSelect,
onMouseMove,
disabledDate,
isoWeek,
limitEndYear,
classPrefix,
showWeekNumbers
} = this.props;
const { calendarState } = this.state;
return (
<Calendar
classPrefix={classPrefix}
disabledDate={disabledDate}
format={format}
value={value}
isoWeek={isoWeek}
hoverValue={hoverValue}
calendarState={calendarState}
calendarDate={calendarDate}
index={index}
onMoveForword={this.onMoveForword}
onMoveBackward={this.onMoveBackward}
onSelect={onSelect}
onMouseMove={onMouseMove}
onToggleMonthDropdown={this.toggleMonthDropdown}
onChangePageDate={this.handleChangePageDate}
limitEndYear={limitEndYear}
showWeekNumbers={showWeekNumbers}
/>
);
}
}
export default DatePicker;