@progress/kendo-angular-scheduler
Version:
Kendo UI Scheduler Angular - Outlook or Google-style angular scheduler calendar. Full-featured and customizable embedded scheduling from the creator developers trust for professional UI components.
208 lines (207 loc) • 10.2 kB
JavaScript
/**-----------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the project root for more information
*-------------------------------------------------------------------------------------------*/
import { Component, forwardRef, Input, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core';
import { LocalizationService } from '@progress/kendo-angular-l10n';
import { SchedulerView } from '../../types';
import { TimelineBase } from './timeline-base';
import { ViewContextService } from '../view-context.service';
import { ViewStateService } from '../view-state.service';
import { firstDayOfMonth, getDate, addMonths } from '@progress/kendo-date-math';
import { WorkHoursFooterDirective } from '../common/work-hours-footer.directive';
import { ViewFooterComponent } from '../common/view-footer.component';
import { TimelineMultiDayViewComponent } from './timeline-multi-day-view.component';
import * as i0 from "@angular/core";
import * as i1 from "@progress/kendo-angular-l10n";
import * as i2 from "../view-context.service";
import * as i3 from "../view-state.service";
/**
* Represents the component that renders the **Timeline Month** view in the Scheduler.
*
* @example
* ```html
* <kendo-scheduler>
* <kendo-scheduler-timeline-month-view></kendo-scheduler-timeline-month-view>
* </kendo-scheduler>
* ```
*/
export class TimelineMonthViewComponent extends TimelineBase {
/**
* @hidden
*/
get title() {
return this.localization.get('timelineMonthViewTitle');
}
/**
* Sets the long-date format for the selected date in the Scheduler toolbar.
* For more information, see [Parsing and Formatting Dates and Numbers](slug:parsingandformatting_intl#date-formatting).
* If `numberOfMonths` is greater than 1, the default format displays a range: `'{0:Y} - {1:Y}'`, where `0` is the start and `1` is the end date.
* @default '{0:Y}'
*/
set selectedDateFormat(format) {
this._selectedDateFormat = format;
}
get selectedDateFormat() {
if (this._selectedDateFormat) {
return this._selectedDateFormat;
}
return this.numberOfMonths && this.numberOfMonths > 1 ? '{0:Y} - {1:Y}' : '{0:Y}';
}
_selectedDateFormat;
/**
* Sets the short-date format for the selected date in the Scheduler toolbar.
* For more information, see [Parsing and Formatting Dates and Numbers](slug:parsingandformatting_intl#date-formatting).
* If `numberOfMonths` is greater than 1, the default format displays a range: `'{0:y} - {1:y}'`, where `0` is the start and `1` is the end date.
* @default '{0:y}'
*/
set selectedShortDateFormat(format) {
this._selectedShortDateFormat = format;
}
get selectedShortDateFormat() {
if (this._selectedShortDateFormat) {
return this._selectedShortDateFormat;
}
return this.numberOfMonths && this.numberOfMonths > 1 ? '{0:y} - {1:y}' : '{0:y}';
}
_selectedShortDateFormat;
/**
* Sets the number of months to render in the view.
* If the value is less than or equal to 0, it defaults to 1.
* @default 1
*/
set numberOfMonths(months) {
this._numberOfMonths = months > 0 ? months : 1;
}
get numberOfMonths() {
return this._numberOfMonths;
}
_numberOfMonths = 1;
/**
* The invariant name for this view.
* @default 'timelineMonth'
*/
name = 'timelineMonth';
/**
* @hidden
*/
getStartDate = (selectedDate) => {
return firstDayOfMonth(getDate(selectedDate));
};
/**
* @hidden
*/
getEndDate = (selectedDate) => {
return addMonths(this.getStartDate(selectedDate), this.numberOfMonths);
};
/**
* @hidden
*/
getNextDate = (date, count) => {
return addMonths(date, count);
};
constructor(localization, changeDetector, viewContext, viewState) {
super(localization, changeDetector, viewContext, viewState);
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: TimelineMonthViewComponent, deps: [{ token: i1.LocalizationService }, { token: i0.ChangeDetectorRef }, { token: i2.ViewContextService }, { token: i3.ViewStateService }], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: TimelineMonthViewComponent, isStandalone: true, selector: "kendo-scheduler-timeline-month-view", inputs: { selectedDateFormat: "selectedDateFormat", selectedShortDateFormat: "selectedShortDateFormat", numberOfMonths: "numberOfMonths" }, providers: [{
provide: SchedulerView,
useExisting: forwardRef(() => TimelineMonthViewComponent)
}], usesInheritance: true, ngImport: i0, template: `
<ng-template
<timeline-multi-day-view
viewName="timeline-month"
[]="name"
[]="getNextDate"
[]="getStartDate"
[]="getEndDate"
[]="viewEventHeight"
[]="viewColumnWidth"
[]="viewCurrentTimeMarker"
[]="viewHighlightOngoingEvents"
[]="shouldShowWorkHours"
[]="viewScrollTime"
[]="viewStartTime"
[]="viewEndTime"
[]="viewWorkDayStart"
[]="viewWorkDayEnd"
[]="viewWorkWeekStart"
[]="viewWorkWeekEnd"
[]="viewSlotDuration"
[]="viewSlotDivisions"
[]="viewSlotClass"
[]="viewEventClass"
[]="viewEventStyles"
[]="eventTemplate?.templateRef"
[]="groupHeaderTemplate?.templateRef"
[]="timeSlotTemplate?.templateRef"
[]="dateHeaderTemplate?.templateRef"
[]="majorTimeHeaderTemplate?.templateRef"
[]="minorTimeHeaderTemplate?.templateRef"
[]="selectedDateFormat"
[]="selectedShortDateFormat">
</timeline-multi-day-view>
@if (viewShowFooter) {
<div viewFooter kendoWorkHoursFooter [showWorkHours]="shouldShowWorkHours" (itemClick)="showWorkHours = !shouldShowWorkHours"></div>
}
</ng-template>
`, isInline: true, dependencies: [{ kind: "component", type: TimelineMultiDayViewComponent, selector: "timeline-multi-day-view", inputs: ["name", "columnWidth", "viewName"] }, { kind: "component", type: ViewFooterComponent, selector: "[viewFooter]", inputs: ["items"], outputs: ["itemClick"] }, { kind: "directive", type: WorkHoursFooterDirective, selector: "[kendoWorkHoursFooter]", inputs: ["showWorkHours"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: TimelineMonthViewComponent, decorators: [{
type: Component,
args: [{
changeDetection: ChangeDetectionStrategy.OnPush,
selector: 'kendo-scheduler-timeline-month-view',
providers: [{
provide: SchedulerView,
useExisting: forwardRef(() => TimelineMonthViewComponent)
}],
template: `
<ng-template
<timeline-multi-day-view
viewName="timeline-month"
[]="name"
[]="getNextDate"
[]="getStartDate"
[]="getEndDate"
[]="viewEventHeight"
[]="viewColumnWidth"
[]="viewCurrentTimeMarker"
[]="viewHighlightOngoingEvents"
[]="shouldShowWorkHours"
[]="viewScrollTime"
[]="viewStartTime"
[]="viewEndTime"
[]="viewWorkDayStart"
[]="viewWorkDayEnd"
[]="viewWorkWeekStart"
[]="viewWorkWeekEnd"
[]="viewSlotDuration"
[]="viewSlotDivisions"
[]="viewSlotClass"
[]="viewEventClass"
[]="viewEventStyles"
[]="eventTemplate?.templateRef"
[]="groupHeaderTemplate?.templateRef"
[]="timeSlotTemplate?.templateRef"
[]="dateHeaderTemplate?.templateRef"
[]="majorTimeHeaderTemplate?.templateRef"
[]="minorTimeHeaderTemplate?.templateRef"
[]="selectedDateFormat"
[]="selectedShortDateFormat">
</timeline-multi-day-view>
@if (viewShowFooter) {
<div viewFooter kendoWorkHoursFooter [showWorkHours]="shouldShowWorkHours" (itemClick)="showWorkHours = !shouldShowWorkHours"></div>
}
</ng-template>
`,
standalone: true,
imports: [TimelineMultiDayViewComponent, ViewFooterComponent, WorkHoursFooterDirective]
}]
}], ctorParameters: () => [{ type: i1.LocalizationService }, { type: i0.ChangeDetectorRef }, { type: i2.ViewContextService }, { type: i3.ViewStateService }], propDecorators: { selectedDateFormat: [{
type: Input
}], selectedShortDateFormat: [{
type: Input
}], numberOfMonths: [{
type: Input
}] } });