Skip to content

Commit

Permalink
Feature/add full month name flag for month picker (#2100)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaraujo6 committed Apr 14, 2020
1 parent 8c0e03c commit 9d6590e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 1 deletion.
5 changes: 5 additions & 0 deletions docs-site/src/components/Examples/index.js
Expand Up @@ -63,6 +63,7 @@ import RenderCustomDay from "../../examples/renderCustomDay";
import TimeInput from "../../examples/timeInput";
import StrictParsing from "../../examples/strictParsing";
import MonthPicker from "../../examples/monthPicker";
import monthPickerFullName from "../../examples/monthPickerFullName";
import RangeMonthPicker from "../../examples/rangeMonthPicker";
import QuarterPicker from "../../examples/quarterPicker";
import RangeQuarterPicker from "../../examples/rangeQuarterPicker";
Expand Down Expand Up @@ -319,6 +320,10 @@ export default class exampleComponents extends React.Component {
title: "Month Picker",
component: MonthPicker
},
{
title: "Month Picker with Full Name",
component: monthPickerFullName
},
{
title: "Range Month Picker",
component: RangeMonthPicker
Expand Down
12 changes: 12 additions & 0 deletions docs-site/src/examples/monthPickerFullName.js
@@ -0,0 +1,12 @@
() => {
const [startDate, setStartDate] = useState(new Date());
return (
<DatePicker
selected={startDate}
onChange={date => setStartDate(date)}
dateFormat="MM/yyyy"
showMonthYearPicker
showFullMonthYearPicker
/>
);
};
2 changes: 2 additions & 0 deletions src/calendar.jsx
Expand Up @@ -110,6 +110,7 @@ export default class Calendar extends React.Component {
showTimeSelect: PropTypes.bool,
showTimeInput: PropTypes.bool,
showMonthYearPicker: PropTypes.bool,
showFullMonthYearPicker: PropTypes.bool,
showQuarterYearPicker: PropTypes.bool,
showTimeSelectOnly: PropTypes.bool,
timeFormat: PropTypes.string,
Expand Down Expand Up @@ -723,6 +724,7 @@ export default class Calendar extends React.Component {
renderDayContents={this.props.renderDayContents}
disabledKeyboardNavigation={this.props.disabledKeyboardNavigation}
showMonthYearPicker={this.props.showMonthYearPicker}
showFullMonthYearPicker={this.props.showFullMonthYearPicker}
showQuarterYearPicker={this.props.showQuarterYearPicker}
isInputFocused={this.props.isInputFocused}
containerRef={this.containerRef}
Expand Down
3 changes: 3 additions & 0 deletions src/index.jsx
Expand Up @@ -89,6 +89,7 @@ export default class DatePicker extends React.Component {
showTimeInput: false,
showPreviousMonths: false,
showMonthYearPicker: false,
showFullMonthYearPicker: false,
showQuarterYearPicker: false,
strictParsing: false,
timeIntervals: 30,
Expand Down Expand Up @@ -208,6 +209,7 @@ export default class DatePicker extends React.Component {
shouldCloseOnSelect: PropTypes.bool,
showTimeInput: PropTypes.bool,
showMonthYearPicker: PropTypes.bool,
showFullMonthYearPicker: PropTypes.bool,
showQuarterYearPicker: PropTypes.bool,
showTimeSelect: PropTypes.bool,
showTimeSelectOnly: PropTypes.bool,
Expand Down Expand Up @@ -793,6 +795,7 @@ export default class DatePicker extends React.Component {
onMonthMouseLeave={this.props.onMonthMouseLeave}
showTimeInput={this.props.showTimeInput}
showMonthYearPicker={this.props.showMonthYearPicker}
showFullMonthYearPicker={this.props.showFullMonthYearPicker}
showQuarterYearPicker={this.props.showQuarterYearPicker}
showPopperArrow={this.props.showPopperArrow}
excludeScrollbar={this.props.excludeScrollbar}
Expand Down
6 changes: 5 additions & 1 deletion src/month.jsx
Expand Up @@ -45,6 +45,7 @@ export default class Month extends React.Component {
shouldCloseOnSelect: PropTypes.bool,
renderDayContents: PropTypes.func,
showMonthYearPicker: PropTypes.bool,
showFullMonthYearPicker: PropTypes.bool,
showQuarterYearPicker: PropTypes.bool,
handleOnKeyDown: PropTypes.func,
isInputFocused: PropTypes.bool,
Expand Down Expand Up @@ -250,6 +251,7 @@ export default class Month extends React.Component {
};

renderMonths = () => {
const { showFullMonthYearPicker, locale } = this.props;
const months = [
[0, 1, 2],
[3, 4, 5],
Expand All @@ -266,7 +268,9 @@ export default class Month extends React.Component {
}}
className={this.getMonthClassNames(m)}
>
{utils.getMonthShortInLocale(m, this.props.locale)}
{showFullMonthYearPicker
? utils.getMonthInLocale(m, locale)
: utils.getMonthShortInLocale(m, locale)}
</div>
))}
</div>
Expand Down

0 comments on commit 9d6590e

Please sign in to comment.