license import React from 'react' ; import { RenderProp } from '../../devsupport' ; import { styled } from '../../theme' ; import { BaseDatepickerComponent , BaseDatepickerProps , } from './baseDatepicker.component' ; import { Calendar , CalendarElement , CalendarProps , } from '../calendar/calendar.component' ; import { TextProps } from '../text/text.component' ; export interface DatepickerProps < D = Date > extends BaseDatepickerProps < D > , CalendarProps < D > { autoDismiss ? : boolean ; } export type DatepickerElement < D = Date > = React . ReactElement < DatepickerProps < D > > ; extends React . Component method method method method method method property property property property property property property property property property property property property property property property property property property property property property property property property overview-example overview-example overview-example overview-example overview-example overview-example overview-example overview-example overview-example overview-example @ styled ( 'Datepicker' ) export class Datepicker < D = Date > extends BaseDatepickerComponent < DatepickerProps < D > , D > { static defaultProps : DatepickerProps = { ... BaseDatepickerComponent . defaultProps , autoDismiss : true , } ; constructor ( props ) { super ( props ) ; this . clear = this . clear . bind ( this ) ; } private get calendarProps ( ) : CalendarProps < D > { return { min : this . props . min , max : this . props . max , date : this . props . date , dateService : this . props . dateService , boundingMonth : this . props . boundingMonth , startView : this . props . startView , filter : this . props . filter , title : this . props . title , onSelect : this . props . onSelect , renderDay : this . props . renderDay , renderMonth : this . props . renderMonth , renderYear : this . props . renderYear , } ; } public clear = ( ) : void => { if ( this . props . onSelect ) { this . props . onSelect ( null ) ; } } ; protected getComponentTitle ( ) { if ( this . props . date ) { return this . props . dateService . format ( this . props . date , null ) ; } else { return this . props . placeholder ; } } protected onSelect = ( date ) : void => { this . props . onSelect && this . props . onSelect ( date ) ; this . props . autoDismiss && this . blur ( ) ; } ; protected renderCalendar ( ) { return ( < Calendar { ... this . calendarProps } onSelect = { this . onSelect } / > ) ; } }