import invoke from 'lodash/invoke'; import moment from 'moment'; import * as React from 'react'; import MonthPicker, { MonthPickerOnChangeData, } from '../pickers/monthPicker/MonthPicker'; import InputView from '../views/InputView'; import BaseInput, { BaseInputProps, BaseInputPropTypes, BaseInputState, DateRelatedProps, DateRelatedPropTypes, DisableValuesProps, DisableValuesPropTypes, MinMaxValueProps, MinMaxValuePropTypes, } from './BaseInput'; import { parseArrayOrValue, parseValue, buildValue, dateValueToString, } from './parse'; export type MonthInputProps = & BaseInputProps & DateRelatedProps & DisableValuesProps & MinMaxValueProps; export type MonthInputOnChangeData = MonthInputProps; class MonthInput extends BaseInput { public static readonly defaultProps = { ...BaseInput.defaultProps, dateFormat: 'MMM', icon: 'calendar', }; public static readonly propTypes = { ...BaseInputPropTypes, ...DateRelatedPropTypes, ...DisableValuesPropTypes, ...MinMaxValuePropTypes, }; constructor(props) { super(props); this.state = { popupIsClosed: true, }; } public render() { const { value, dateFormat, initialDate, disable, maxDate, minDate, closable, localization, ...rest } = this.props; return ( ); } private getPicker = () => { const { value, dateFormat, disable, maxDate, minDate, localization, initialDate, } = this.props; return ( undefined} /> ); } private handleSelect = (e: React.SyntheticEvent, { value }: MonthPickerOnChangeData) => { const { localization } = this.props; const date = localization ? moment({ month: value.month }).locale(localization) : moment({ month: value.month }); let output = ''; if (date.isValid()) { output = date.format(this.props.dateFormat); } invoke( this.props, 'onChange', e, { ...this.props, value: output }); if (this.props.closable) { this.closePopup(); } } } export default MonthInput;