UNPKG

@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.

139 lines (138 loc) 6.15 kB
/**----------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the project root for more information *-------------------------------------------------------------------------------------------*/ import { Directive, Input, ElementRef, HostBinding } from '@angular/core'; import { BaseSlotDirective } from '../view-items/base-slot.directive'; import { addUTCDays, toUTCTime, toUTCDate, dateWithTime, isWorkWeekDay } from '../utils'; import { DayTimeSlotService } from './day-time-slot.service'; import { LocalizationService } from '@progress/kendo-angular-l10n'; import { INVARIANT_END } from '../constants'; import * as i0 from "@angular/core"; import * as i1 from "./day-time-slot.service"; import * as i2 from "@progress/kendo-angular-l10n"; /** * @hidden */ export class TimeSlotDirective extends BaseSlotDirective { invariantStart; invariantEnd; workDayStart; workDayEnd; workWeekStart; workWeekEnd; date; get nonWorkHour() { const date = this.date.getDay(); return this.invariantStart < this.workDayStart || this.workDayEnd < this.invariantEnd || !isWorkWeekDay(date, this.workWeekStart, this.workWeekEnd); } isDaySlot = false; get startLocalTime() { if (!this.date || !this.invariantStart) { return null; } return dateWithTime(this.date, this.invariantStart); } get endLocalTime() { if (!this.date || !this.invariantEnd) { return null; } return dateWithTime(this.date, this.invariantEnd); } get start() { if (!this.date || !this.invariantStart) { return null; } return toUTCTime(this.date, this.invariantStart); } get end() { if (!this.date || !this.invariantEnd) { return null; } const localEnd = toUTCTime(this.date, this.invariantEnd); if (INVARIANT_END.getTime() <= this.invariantEnd.getTime()) { return addUTCDays(localEnd, 1); } return localEnd; } constructor(element, slotService, localization) { super(element, slotService, localization); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TimeSlotDirective, deps: [{ token: i0.ElementRef }, { token: i1.DayTimeSlotService }, { token: i2.LocalizationService }], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: TimeSlotDirective, isStandalone: true, selector: "[timeSlot]", inputs: { invariantStart: "invariantStart", invariantEnd: "invariantEnd", workDayStart: "workDayStart", workDayEnd: "workDayEnd", workWeekStart: "workWeekStart", workWeekEnd: "workWeekEnd", date: "date" }, host: { properties: { "class.k-nonwork-hour": "this.nonWorkHour" } }, exportAs: ["timeSlot"], usesInheritance: true, ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TimeSlotDirective, decorators: [{ type: Directive, args: [{ // eslint-disable-next-line @angular-eslint/directive-selector selector: '[timeSlot]', exportAs: 'timeSlot', standalone: true }] }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i1.DayTimeSlotService }, { type: i2.LocalizationService }]; }, propDecorators: { invariantStart: [{ type: Input }], invariantEnd: [{ type: Input }], workDayStart: [{ type: Input }], workDayEnd: [{ type: Input }], workWeekStart: [{ type: Input }], workWeekEnd: [{ type: Input }], date: [{ type: Input }], nonWorkHour: [{ type: HostBinding, args: ['class.k-nonwork-hour'] }] } }); /** * @hidden */ export class DaySlotDirective extends BaseSlotDirective { set start(value) { this.startDate = value; } get start() { if (!this.startDate) { return null; } return toUTCDate(this.startDate); } set end(value) { this.endDate = value; } get end() { if (!this.endDate) { return null; } return toUTCDate(this.endDate); } get daySlot() { return true; } isDaySlot = true; startDate; endDate; constructor(element, slotService, localization) { super(element, slotService, localization); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DaySlotDirective, deps: [{ token: i0.ElementRef }, { token: i1.DayTimeSlotService }, { token: i2.LocalizationService }], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: DaySlotDirective, isStandalone: true, selector: "[daySlot]", inputs: { start: "start", end: "end" }, host: { properties: { "attr.data-day-slot": "this.daySlot" } }, usesInheritance: true, ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DaySlotDirective, decorators: [{ type: Directive, args: [{ // eslint-disable-next-line @angular-eslint/directive-selector selector: '[daySlot]', standalone: true }] }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i1.DayTimeSlotService }, { type: i2.LocalizationService }]; }, propDecorators: { start: [{ type: Input }], end: [{ type: Input }], daySlot: [{ type: HostBinding, args: ['attr.data-day-slot'] }] } });