@nepwork/dashboards
Version:
Dashboards for emergencies and monitoring
210 lines • 10.3 kB
JavaScript
/**
* @license
* Copyright Akveo. All Rights Reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/
import { __decorate, __metadata } from "tslib";
import { Component, EventEmitter, HostBinding, Input, Output, Type } from '@angular/core';
import { NbCalendarYearModelService } from '../calendar-kit/services/calendar-year-model.service';
import { NbCalendarSize, NbCalendarViewMode, } from '../calendar-kit/model';
import { NbDateService } from '../calendar-kit/services/date.service';
import { convertToBoolProperty } from '../helpers';
/**
* The basis for calendar and range calendar components.
* Encapsulates common behavior - store calendar state and perform navigation
* between pickers.
* */
var NbBaseCalendarComponent = /** @class */ (function () {
function NbBaseCalendarComponent(dateService, yearModelService) {
this.dateService = dateService;
this.yearModelService = yearModelService;
/**
* Defines if we should render previous and next months
* in the current month view.
* */
this.boundingMonth = true;
/**
* Defines active view for calendar.
* */
this.activeViewMode = NbCalendarViewMode.DATE;
/**
* Size of the calendar and entire components.
* Can be 'medium' which is default or 'large'.
* */
this.size = NbCalendarSize.MEDIUM;
/**
* Determines whether we should show calendar navigation or not.
* */
this.showNavigation = true;
this._showWeekNumber = false;
/**
* Emits date when selected.
* */
this.dateChange = new EventEmitter();
this.ViewMode = NbCalendarViewMode;
}
Object.defineProperty(NbBaseCalendarComponent.prototype, "showWeekNumber", {
/**
* Determines should we show week numbers column.
* False by default.
* */
get: function () {
return this._showWeekNumber;
},
set: function (value) {
this._showWeekNumber = convertToBoolProperty(value);
},
enumerable: true,
configurable: true
});
NbBaseCalendarComponent.prototype.ngOnInit = function () {
if (!this.visibleDate) {
this.visibleDate = this.dateService.today();
}
};
Object.defineProperty(NbBaseCalendarComponent.prototype, "large", {
get: function () {
return this.size === NbCalendarSize.LARGE;
},
enumerable: true,
configurable: true
});
NbBaseCalendarComponent.prototype.setViewMode = function (viewMode) {
this.activeViewMode = viewMode;
};
NbBaseCalendarComponent.prototype.setVisibleDate = function (visibleDate) {
this.visibleDate = visibleDate;
};
NbBaseCalendarComponent.prototype.prevMonth = function () {
this.changeVisibleMonth(-1);
};
NbBaseCalendarComponent.prototype.nextMonth = function () {
this.changeVisibleMonth(1);
};
NbBaseCalendarComponent.prototype.prevYear = function () {
this.changeVisibleYear(-1);
};
NbBaseCalendarComponent.prototype.nextYear = function () {
this.changeVisibleYear(1);
};
NbBaseCalendarComponent.prototype.prevYears = function () {
this.changeVisibleYears(-1);
};
NbBaseCalendarComponent.prototype.nextYears = function () {
this.changeVisibleYears(1);
};
NbBaseCalendarComponent.prototype.navigatePrev = function () {
switch (this.activeViewMode) {
case NbCalendarViewMode.DATE:
return this.prevMonth();
case NbCalendarViewMode.MONTH:
return this.prevYear();
case NbCalendarViewMode.YEAR:
return this.prevYears();
}
};
NbBaseCalendarComponent.prototype.navigateNext = function () {
switch (this.activeViewMode) {
case NbCalendarViewMode.DATE:
return this.nextMonth();
case NbCalendarViewMode.MONTH:
return this.nextYear();
case NbCalendarViewMode.YEAR:
return this.nextYears();
}
};
NbBaseCalendarComponent.prototype.onChangeViewMode = function () {
if (this.activeViewMode === NbCalendarViewMode.DATE) {
return this.setViewMode(NbCalendarViewMode.YEAR);
}
this.setViewMode(NbCalendarViewMode.DATE);
};
NbBaseCalendarComponent.prototype.changeVisibleMonth = function (direction) {
this.visibleDate = this.dateService.addMonth(this.visibleDate, direction);
};
NbBaseCalendarComponent.prototype.changeVisibleYear = function (direction) {
this.visibleDate = this.dateService.addYear(this.visibleDate, direction);
};
NbBaseCalendarComponent.prototype.changeVisibleYears = function (direction) {
this.visibleDate = this.dateService.addYear(this.visibleDate, direction * this.yearModelService.getYearsInView());
};
__decorate([
Input(),
__metadata("design:type", Boolean)
], NbBaseCalendarComponent.prototype, "boundingMonth", void 0);
__decorate([
Input('startView'),
__metadata("design:type", String)
], NbBaseCalendarComponent.prototype, "activeViewMode", void 0);
__decorate([
Input(),
__metadata("design:type", Object)
], NbBaseCalendarComponent.prototype, "min", void 0);
__decorate([
Input(),
__metadata("design:type", Object)
], NbBaseCalendarComponent.prototype, "max", void 0);
__decorate([
Input(),
__metadata("design:type", Function)
], NbBaseCalendarComponent.prototype, "filter", void 0);
__decorate([
Input(),
__metadata("design:type", Type)
], NbBaseCalendarComponent.prototype, "dayCellComponent", void 0);
__decorate([
Input(),
__metadata("design:type", Type)
], NbBaseCalendarComponent.prototype, "monthCellComponent", void 0);
__decorate([
Input(),
__metadata("design:type", Type)
], NbBaseCalendarComponent.prototype, "yearCellComponent", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], NbBaseCalendarComponent.prototype, "size", void 0);
__decorate([
Input(),
__metadata("design:type", Object)
], NbBaseCalendarComponent.prototype, "visibleDate", void 0);
__decorate([
Input(),
HostBinding('class.has-navigation'),
__metadata("design:type", Boolean)
], NbBaseCalendarComponent.prototype, "showNavigation", void 0);
__decorate([
Input(),
__metadata("design:type", Object)
], NbBaseCalendarComponent.prototype, "date", void 0);
__decorate([
Input(),
HostBinding('class.has-week-number'),
__metadata("design:type", Boolean),
__metadata("design:paramtypes", [Boolean])
], NbBaseCalendarComponent.prototype, "showWeekNumber", null);
__decorate([
Input(),
__metadata("design:type", String)
], NbBaseCalendarComponent.prototype, "weekNumberSymbol", void 0);
__decorate([
Output(),
__metadata("design:type", EventEmitter)
], NbBaseCalendarComponent.prototype, "dateChange", void 0);
__decorate([
HostBinding('class.size-large'),
__metadata("design:type", Object),
__metadata("design:paramtypes", [])
], NbBaseCalendarComponent.prototype, "large", null);
NbBaseCalendarComponent = __decorate([
Component({
selector: 'nb-base-calendar',
template: "<nb-card>\n <nb-card-header *ngIf=\"showNavigation\" class=\"calendar-navigation\">\n <nb-calendar-view-mode [date]=\"visibleDate\"\n [viewMode]=\"activeViewMode\"\n (changeMode)=\"onChangeViewMode()\">\n </nb-calendar-view-mode>\n\n <nb-calendar-pageable-navigation (prev)=\"navigatePrev()\" (next)=\"navigateNext()\">\n </nb-calendar-pageable-navigation>\n </nb-card-header>\n\n <nb-card-body [ngSwitch]=\"activeViewMode\">\n\n <nb-calendar-day-picker *ngSwitchCase=\"ViewMode.DATE\"\n [boundingMonths]=\"boundingMonth\"\n [cellComponent]=\"dayCellComponent\"\n [min]=\"min\"\n [max]=\"max\"\n [filter]=\"filter\"\n [visibleDate]=\"visibleDate\"\n [size]=\"size\"\n [date]=\"date\"\n [showWeekNumber]=\"showWeekNumber\"\n (dateChange)=\"dateChange.emit($any($event))\"\n [weekNumberSymbol]=\"weekNumberSymbol\">\n </nb-calendar-day-picker>\n\n <nb-calendar-year-picker *ngSwitchCase=\"ViewMode.YEAR\"\n [cellComponent]=\"yearCellComponent\"\n [date]=\"$any(date)\"\n [min]=\"min\"\n [max]=\"max\"\n [filter]=\"filter\"\n [size]=\"size\"\n [year]=\"visibleDate\"\n (yearChange)=\"setVisibleDate($event); setViewMode(ViewMode.MONTH)\">\n </nb-calendar-year-picker>\n\n <nb-calendar-month-picker *ngSwitchCase=\"ViewMode.MONTH\"\n [cellComponent]=\"monthCellComponent\"\n [min]=\"min\"\n [max]=\"max\"\n [filter]=\"filter\"\n [size]=\"size\"\n [month]=\"visibleDate\"\n [date]=\"$any(date)\"\n (monthChange)=\"setVisibleDate($event); setViewMode(ViewMode.DATE)\">\n </nb-calendar-month-picker>\n\n </nb-card-body>\n\n</nb-card>\n"
}),
__metadata("design:paramtypes", [NbDateService,
NbCalendarYearModelService])
], NbBaseCalendarComponent);
return NbBaseCalendarComponent;
}());
export { NbBaseCalendarComponent };
//# sourceMappingURL=base-calendar.component.js.map