UNPKG

ng2-date-picker-pda-forked

Version:
88 lines 3.48 kB
"use strict"; var __assign = (this && this.__assign) || Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; var core_1 = require("@angular/core"); var moment = require("moment"); var utils_service_1 = require("../common/services/utils/utils.service"); var MonthCalendarService = (function () { function MonthCalendarService(utilsService) { this.utilsService = utilsService; this.DEFAULT_CONFIG = { allowMultiSelect: false, yearFormat: 'YYYY', format: 'MM-YYYY', isNavHeaderBtnClickable: false, monthBtnFormat: 'MMM', locale: 'en', multipleYearsNavigateBy: 10, showMultipleYearsNavigation: false }; } MonthCalendarService.prototype.getConfig = function (config) { var _config = __assign({}, this.DEFAULT_CONFIG, this.utilsService.clearUndefined(config)); moment.locale(_config.locale); return _config; }; MonthCalendarService.prototype.generateYear = function (year, selected) { var _this = this; if (selected === void 0) { selected = null; } var index = year.clone().startOf('year'); return this.utilsService.createArray(3).map(function () { return _this.utilsService.createArray(4).map(function () { var month = { date: index.clone(), selected: !!selected.find(function (s) { return index.isSame(s, 'month'); }), currentMonth: index.isSame(moment(), 'month') }; index.add(1, 'month'); return month; }); }); }; MonthCalendarService.prototype.isMonthDisabled = function (month, config) { if (config.min && month.date.isBefore(config.min, 'month')) { return true; } return !!(config.max && month.date.isAfter(config.max, 'month')); }; MonthCalendarService.prototype.shouldShowLeft = function (min, currentMonthView) { return min ? min.isBefore(currentMonthView, 'year') : true; }; MonthCalendarService.prototype.shouldShowRight = function (max, currentMonthView) { return max ? max.isAfter(currentMonthView, 'year') : true; }; MonthCalendarService.prototype.getHeaderLabel = function (config, year) { if (config.yearFormatter) { return config.yearFormatter(year); } return year.format(config.yearFormat); }; MonthCalendarService.prototype.getMonthBtnText = function (config, month) { if (config.monthBtnFormatter) { return config.monthBtnFormatter(month); } return month.format(config.monthBtnFormat); }; MonthCalendarService.prototype.getMonthBtnCssClass = function (config, month) { if (config.monthBtnCssClassCallback) { return config.monthBtnCssClassCallback(month); } return ''; }; return MonthCalendarService; }()); MonthCalendarService.decorators = [ { type: core_1.Injectable }, ]; /** @nocollapse */ MonthCalendarService.ctorParameters = function () { return [ { type: utils_service_1.UtilsService, }, ]; }; exports.MonthCalendarService = MonthCalendarService; //# sourceMappingURL=month-calendar.service.js.map