forked from Hacker0x01/react-datepicker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweek_number.jsx
36 lines (33 loc) · 823 Bytes
/
week_number.jsx
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
// @flow
import React from "react";
import PropTypes from "prop-types";
import classnames from "classnames";
export default class WeekNumber extends React.Component<{
weekNumber: number,
onClick?: Function
}> {
static propTypes = {
weekNumber: PropTypes.number.isRequired,
onClick: PropTypes.func
};
handleClick = (event: any) => {
if (this.props.onClick) {
this.props.onClick(event);
}
};
render() {
const weekNumberClasses = {
"react-datepicker__week-number": true,
"react-datepicker__week-number--clickable": !!this.props.onClick
};
return (
<div
className={classnames(weekNumberClasses)}
aria-label={`week-${this.props.weekNumber}`}
onClick={this.handleClick}
>
{this.props.weekNumber}
</div>
);
}
}