license import React from 'react' ; import { styled , StyledComponentProps , } from '../../theme' ; import { BaseCalendarComponent , BaseCalendarProps , } from './baseCalendar.component' ; import { CalendarPickerCellProps } from './components/picker/calendarPickerCell.component' ; import { DateBatch } from './service/calendarData.service' ; export interface CalendarProps < D = Date > extends StyledComponentProps , BaseCalendarProps < D > { date ? : D ; onSelect ? : ( date : D ) => void ; } export type CalendarElement < D = Date > = React . ReactElement < CalendarProps < D > > ; extends React . Component 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 @ styled ( 'Calendar' ) export class Calendar < D = Date > extends BaseCalendarComponent < CalendarProps < D > , D > { constructor ( props ) { super ( props ) ; this . createDates = this . createDates . bind ( this ) ; this . selectedDate = this . selectedDate . bind ( this ) ; this . onDateSelect = this . onDateSelect . bind ( this ) ; this . isDateSelected = this . isDateSelected . bind ( this ) ; this . shouldUpdateDate = this . shouldUpdateDate . bind ( this ) ; } protected createDates ( date ) { return this . dataService . createDayPickerData ( date ) ; } protected selectedDate ( ) { return this . props . date || this . dateService . today ( ) ; } protected onDateSelect ( date ) { this . props . onSelect && this . props . onSelect ( date ) ; } protected isDateSelected ( date ) { return this . dateService . isSameDaySafe ( date , this . selectedDate ( ) ) ; } protected shouldUpdateDate ( props , nextProps ) { const dateChanged = this . dateService . compareDatesSafe ( props . date . date , nextProps . date . date ) !== 0 ; if ( dateChanged ) { return true ; } const selectionChanged = props . selected !== nextProps . selected ; const disablingChanged = props . disabled !== nextProps . disabled ; const value = selectionChanged || disablingChanged ; if ( value ) { return true ; } return props . eva . theme !== nextProps . eva . theme ; } }