import { Component, EventEmitter, Input, Output } from '@angular/core'; import { BsDatepickerViewMode, BsNavigationDirection, BsNavigationEvent, CellHoverEvent, DatepickerRenderOptions, DaysCalendarViewModel, DayViewModel } from '../../models/index'; @Component({ selector: 'bs-days-calendar-view', // changeDetection: ChangeDetectionStrategy.OnPush, template: `
{{ calendar.weekdays[i] }}
{{ calendar.weekNumbers[i] }} {{ day.label }}
` }) export class BsDaysCalendarViewComponent { @Input() calendar: DaysCalendarViewModel; @Input() options: DatepickerRenderOptions; @Output() onNavigate = new EventEmitter(); @Output() onViewMode = new EventEmitter(); @Output() onSelect = new EventEmitter(); @Output() onHover = new EventEmitter(); navigateTo(event: BsNavigationDirection): void { const step = BsNavigationDirection.DOWN === event ? -1 : 1; this.onNavigate.emit({ step: { month: step } }); } changeViewMode(event: BsDatepickerViewMode): void { this.onViewMode.emit(event); } selectDay(event: DayViewModel): void { this.onSelect.emit(event); } hoverDay(cell: DayViewModel, isHovered: boolean): void { this.onHover.emit({ cell, isHovered }); } }