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