11import React , { PureComponent } from 'react' ;
22import PropTypes from 'prop-types' ;
3- import mergeClassNames from 'merge-class-names' ;
43
5- import {
6- getMonth ,
7- getYear ,
8- } from '../shared/dates' ;
9- import { isMaxDate , isMinDate } from '../shared/propTypes' ;
10- import { min , max , updateInputWidth } from '../shared/utils' ;
4+ import Input from './Input' ;
115
12- const select = element => element && element . select ( ) ;
6+ import { getMonth , getYear } from '../shared/dates' ;
7+ import { isMaxDate , isMinDate } from '../shared/propTypes' ;
8+ import { min , max } from '../shared/utils' ;
139
1410export default class MonthInput extends PureComponent {
1511 get maxMonth ( ) {
@@ -25,45 +21,20 @@ export default class MonthInput extends PureComponent {
2521 render ( ) {
2622 const { maxMonth, minMonth } = this ;
2723 const {
28- className, disabled, itemRef, value, onChange, onKeyDown, required, showLeadingZeros,
24+ maxDate,
25+ minDate,
26+ year,
27+ ...otherProps
2928 } = this . props ;
3029
31- const name = 'month' ;
32- const hasLeadingZero = showLeadingZeros && value !== null && value < 10 ;
33-
34- return [
35- ( hasLeadingZero && < span key = "leadingZero" className = { `${ className } __leadingZero` } > 0</ span > ) ,
36- < input
37- key = "month"
38- autoComplete = "off"
39- className = { mergeClassNames (
40- `${ className } __input` ,
41- `${ className } __month` ,
42- hasLeadingZero && `${ className } __input--hasLeadingZero` ,
43- ) }
44- disabled = { disabled }
45- name = { name }
30+ return (
31+ < Input
32+ name = "month"
4633 max = { maxMonth }
4734 min = { minMonth }
48- onChange = { onChange }
49- onFocus = { event => select ( event . target ) }
50- onKeyDown = { onKeyDown }
51- onKeyUp = { event => updateInputWidth ( event . target ) }
52- placeholder = "--"
53- ref = { ( ref ) => {
54- if ( ref ) {
55- updateInputWidth ( ref ) ;
56- }
57-
58- if ( itemRef ) {
59- itemRef ( ref , name ) ;
60- }
61- } }
62- type = "number"
63- required = { required }
64- value = { value !== null ? value : '' }
65- /> ,
66- ] ;
35+ { ...otherProps }
36+ />
37+ ) ;
6738 }
6839}
6940
0 commit comments