Skip to content

Commit 903402b

Browse files
authored
Feature/add full month name flag for month picker (Hacker0x01#2100)
1 parent 60ef57f commit 903402b

File tree

5 files changed

+27
-1
lines changed

5 files changed

+27
-1
lines changed

docs-site/src/components/Examples/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ import RenderCustomDay from "../../examples/renderCustomDay";
6363
import TimeInput from "../../examples/timeInput";
6464
import StrictParsing from "../../examples/strictParsing";
6565
import MonthPicker from "../../examples/monthPicker";
66+
import monthPickerFullName from "../../examples/monthPickerFullName";
6667
import RangeMonthPicker from "../../examples/rangeMonthPicker";
6768
import QuarterPicker from "../../examples/quarterPicker";
6869
import RangeQuarterPicker from "../../examples/rangeQuarterPicker";
@@ -319,6 +320,10 @@ export default class exampleComponents extends React.Component {
319320
title: "Month Picker",
320321
component: MonthPicker
321322
},
323+
{
324+
title: "Month Picker with Full Name",
325+
component: monthPickerFullName
326+
},
322327
{
323328
title: "Range Month Picker",
324329
component: RangeMonthPicker
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
() => {
2+
const [startDate, setStartDate] = useState(new Date());
3+
return (
4+
<DatePicker
5+
selected={startDate}
6+
onChange={date => setStartDate(date)}
7+
dateFormat="MM/yyyy"
8+
showMonthYearPicker
9+
showFullMonthYearPicker
10+
/>
11+
);
12+
};

src/calendar.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ export default class Calendar extends React.Component {
110110
showTimeSelect: PropTypes.bool,
111111
showTimeInput: PropTypes.bool,
112112
showMonthYearPicker: PropTypes.bool,
113+
showFullMonthYearPicker: PropTypes.bool,
113114
showQuarterYearPicker: PropTypes.bool,
114115
showTimeSelectOnly: PropTypes.bool,
115116
timeFormat: PropTypes.string,
@@ -723,6 +724,7 @@ export default class Calendar extends React.Component {
723724
renderDayContents={this.props.renderDayContents}
724725
disabledKeyboardNavigation={this.props.disabledKeyboardNavigation}
725726
showMonthYearPicker={this.props.showMonthYearPicker}
727+
showFullMonthYearPicker={this.props.showFullMonthYearPicker}
726728
showQuarterYearPicker={this.props.showQuarterYearPicker}
727729
isInputFocused={this.props.isInputFocused}
728730
containerRef={this.containerRef}

src/index.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ export default class DatePicker extends React.Component {
8989
showTimeInput: false,
9090
showPreviousMonths: false,
9191
showMonthYearPicker: false,
92+
showFullMonthYearPicker: false,
9293
showQuarterYearPicker: false,
9394
strictParsing: false,
9495
timeIntervals: 30,
@@ -208,6 +209,7 @@ export default class DatePicker extends React.Component {
208209
shouldCloseOnSelect: PropTypes.bool,
209210
showTimeInput: PropTypes.bool,
210211
showMonthYearPicker: PropTypes.bool,
212+
showFullMonthYearPicker: PropTypes.bool,
211213
showQuarterYearPicker: PropTypes.bool,
212214
showTimeSelect: PropTypes.bool,
213215
showTimeSelectOnly: PropTypes.bool,
@@ -793,6 +795,7 @@ export default class DatePicker extends React.Component {
793795
onMonthMouseLeave={this.props.onMonthMouseLeave}
794796
showTimeInput={this.props.showTimeInput}
795797
showMonthYearPicker={this.props.showMonthYearPicker}
798+
showFullMonthYearPicker={this.props.showFullMonthYearPicker}
796799
showQuarterYearPicker={this.props.showQuarterYearPicker}
797800
showPopperArrow={this.props.showPopperArrow}
798801
excludeScrollbar={this.props.excludeScrollbar}

src/month.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export default class Month extends React.Component {
4545
shouldCloseOnSelect: PropTypes.bool,
4646
renderDayContents: PropTypes.func,
4747
showMonthYearPicker: PropTypes.bool,
48+
showFullMonthYearPicker: PropTypes.bool,
4849
showQuarterYearPicker: PropTypes.bool,
4950
handleOnKeyDown: PropTypes.func,
5051
isInputFocused: PropTypes.bool,
@@ -250,6 +251,7 @@ export default class Month extends React.Component {
250251
};
251252

252253
renderMonths = () => {
254+
const { showFullMonthYearPicker, locale } = this.props;
253255
const months = [
254256
[0, 1, 2],
255257
[3, 4, 5],
@@ -266,7 +268,9 @@ export default class Month extends React.Component {
266268
}}
267269
className={this.getMonthClassNames(m)}
268270
>
269-
{utils.getMonthShortInLocale(m, this.props.locale)}
271+
{showFullMonthYearPicker
272+
? utils.getMonthInLocale(m, locale)
273+
: utils.getMonthShortInLocale(m, locale)}
270274
</div>
271275
))}
272276
</div>

0 commit comments

Comments
 (0)