UNPKG

ng2-bootstrap

Version:
109 lines 5.91 kB
import { Component, EventEmitter, Input, Output, ViewChild, forwardRef } from '@angular/core'; import { NG_VALUE_ACCESSOR } from '@angular/forms'; import { DatePickerInnerComponent } from './datepicker-inner.component'; import { DatepickerConfig } from './datepicker.config'; export var DATEPICKER_CONTROL_VALUE_ACCESSOR = { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(function () { return DatePickerComponent; }), multi: true }; /* tslint:disable:component-selector-name component-selector-type */ /* tslint:enable:component-selector-name component-selector-type */ export var DatePickerComponent = (function () { function DatePickerComponent(config) { /** sets datepicker mode, supports: `day`, `month`, `year` */ this.datepickerMode = 'day'; /** if false week numbers will be hidden */ this.showWeeks = true; this.selectionDone = new EventEmitter(undefined); /** callback to invoke when the activeDate is changed. */ this.activeDateChange = new EventEmitter(undefined); this.onChange = Function.prototype; this.onTouched = Function.prototype; this._now = new Date(); this.config = config; this.configureOptions(); } Object.defineProperty(DatePickerComponent.prototype, "activeDate", { /** currently active date */ get: function () { return this._activeDate || this._now; }, set: function (value) { this._activeDate = value; }, enumerable: true, configurable: true }); DatePickerComponent.prototype.configureOptions = function () { Object.assign(this, this.config); }; DatePickerComponent.prototype.onUpdate = function (event) { this.activeDate = event; this.onChange(event); }; DatePickerComponent.prototype.onSelectionDone = function (event) { this.selectionDone.emit(event); }; DatePickerComponent.prototype.onActiveDateChange = function (event) { this.activeDateChange.emit(event); }; // todo: support null value DatePickerComponent.prototype.writeValue = function (value) { if (this._datePicker.compare(value, this._activeDate) === 0) { return; } if (value && value instanceof Date) { this.activeDate = value; this._datePicker.select(value, false); return; } this.activeDate = value ? new Date(value) : void 0; }; DatePickerComponent.prototype.registerOnChange = function (fn) { this.onChange = fn; }; DatePickerComponent.prototype.registerOnTouched = function (fn) { this.onTouched = fn; }; DatePickerComponent.decorators = [ { type: Component, args: [{ selector: 'datepicker', template: "\n <datepicker-inner [activeDate]=\"activeDate\"\n (update)=\"onUpdate($event)\"\n [datepickerMode]=\"datepickerMode\"\n [initDate]=\"initDate\"\n [minDate]=\"minDate\"\n [maxDate]=\"maxDate\"\n [minMode]=\"minMode\"\n [maxMode]=\"maxMode\"\n [showWeeks]=\"showWeeks\"\n [formatDay]=\"formatDay\"\n [formatMonth]=\"formatMonth\"\n [formatYear]=\"formatYear\"\n [formatDayHeader]=\"formatDayHeader\"\n [formatDayTitle]=\"formatDayTitle\"\n [formatMonthTitle]=\"formatMonthTitle\"\n [startingDay]=\"startingDay\"\n [yearRange]=\"yearRange\"\n [customClass]=\"customClass\"\n [dateDisabled]=\"dateDisabled\"\n [onlyCurrentMonth]=\"onlyCurrentMonth\"\n [shortcutPropagation]=\"shortcutPropagation\"\n [monthColLimit]=\"monthColLimit\"\n [yearColLimit]=\"yearColLimit\"\n (selectionDone)=\"onSelectionDone($event)\"\n (activeDateChange)=\"onActiveDateChange($event)\">\n <daypicker tabindex=\"0\"></daypicker>\n <monthpicker tabindex=\"0\"></monthpicker>\n <yearpicker tabindex=\"0\"></yearpicker>\n </datepicker-inner>\n ", providers: [DATEPICKER_CONTROL_VALUE_ACCESSOR] },] }, ]; /** @nocollapse */ DatePickerComponent.ctorParameters = function () { return [ { type: DatepickerConfig, }, ]; }; DatePickerComponent.propDecorators = { 'datepickerMode': [{ type: Input },], 'initDate': [{ type: Input },], 'minDate': [{ type: Input },], 'maxDate': [{ type: Input },], 'minMode': [{ type: Input },], 'maxMode': [{ type: Input },], 'showWeeks': [{ type: Input },], 'formatDay': [{ type: Input },], 'formatMonth': [{ type: Input },], 'formatYear': [{ type: Input },], 'formatDayHeader': [{ type: Input },], 'formatDayTitle': [{ type: Input },], 'formatMonthTitle': [{ type: Input },], 'startingDay': [{ type: Input },], 'yearRange': [{ type: Input },], 'onlyCurrentMonth': [{ type: Input },], 'shortcutPropagation': [{ type: Input },], 'monthColLimit': [{ type: Input },], 'yearColLimit': [{ type: Input },], 'customClass': [{ type: Input },], 'dateDisabled': [{ type: Input },], 'activeDate': [{ type: Input },], 'selectionDone': [{ type: Output },], 'activeDateChange': [{ type: Output },], '_datePicker': [{ type: ViewChild, args: [DatePickerInnerComponent,] },], }; return DatePickerComponent; }()); //# sourceMappingURL=datepicker.component.js.map