UNPKG

ngx-bootstrap

Version:
87 lines 5.66 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); import { Component, EventEmitter } from '@angular/core'; import { BsDatepickerAbstractComponent } from '../../base/bs-datepicker-container'; import { BsDatepickerConfig } from '../../bs-datepicker.config'; import { BsDatepickerActions } from '../../reducer/bs-datepicker.actions'; import { BsDatepickerEffects } from '../../reducer/bs-datepicker.effects'; import { BsDatepickerStore } from '../../reducer/bs-datepicker.store'; var BsDatepickerContainerComponent = /** @class */ (function (_super) { __extends(BsDatepickerContainerComponent, _super); function BsDatepickerContainerComponent(_config, _store, _actions, _effects) { var _this = _super.call(this) || this; _this._config = _config; _this._store = _store; _this._actions = _actions; _this.valueChange = new EventEmitter(); _this._subs = []; _this._effects = _effects; return _this; } Object.defineProperty(BsDatepickerContainerComponent.prototype, "value", { set: function (value) { this._effects.setValue(value); }, enumerable: true, configurable: true }); BsDatepickerContainerComponent.prototype.ngOnInit = function () { var _this = this; this.containerClass = this._config.containerClass; this._effects .init(this._store) .setOptions(this._config) .setBindings(this) .setEventHandlers(this) .registerDatepickerSideEffects(); // todo: move it somewhere else // on selected date change this._subs.push(this._store .select(function (state) { return state.selectedDate; }) .subscribe(function (date) { return _this.valueChange.emit(date); })); }; BsDatepickerContainerComponent.prototype.daySelectHandler = function (day) { if (day.isOtherMonth || day.isDisabled) { return; } this._store.dispatch(this._actions.select(day.date)); }; BsDatepickerContainerComponent.prototype.ngOnDestroy = function () { for (var _i = 0, _a = this._subs; _i < _a.length; _i++) { var sub = _a[_i]; sub.unsubscribe(); } this._effects.destroy(); }; BsDatepickerContainerComponent.decorators = [ { type: Component, args: [{ selector: 'bs-datepicker-container', providers: [BsDatepickerStore, BsDatepickerEffects], template: "<!-- days calendar view mode --> <div class=\"bs-datepicker\" [ngClass]=\"containerClass\" *ngIf=\"viewMode | async\"> <div class=\"bs-datepicker-container\"> <!--calendars--> <div class=\"bs-calendar-container\" [ngSwitch]=\"viewMode | async\" role=\"application\"> <!--days calendar--> <div *ngSwitchCase=\"'day'\"> <bs-days-calendar-view *ngFor=\"let calendar of (daysCalendar | async)\" [class.bs-datepicker-multiple]=\"(daysCalendar | async)?.length > 1\" [calendar]=\"calendar\" [options]=\"options | async\" (onNavigate)=\"navigateTo($event)\" (onViewMode)=\"setViewMode($event)\" (onHover)=\"dayHoverHandler($event)\" (onSelect)=\"daySelectHandler($event)\" ></bs-days-calendar-view> </div> <!--months calendar--> <div *ngSwitchCase=\"'month'\"> <bs-month-calendar-view *ngFor=\"let calendar of (monthsCalendar | async)\" [class.bs-datepicker-multiple]=\"(daysCalendar | async)?.length > 1\" [calendar]=\"calendar\" (onNavigate)=\"navigateTo($event)\" (onViewMode)=\"setViewMode($event)\" (onHover)=\"monthHoverHandler($event)\" (onSelect)=\"monthSelectHandler($event)\" ></bs-month-calendar-view> </div> <!--years calendar--> <div *ngSwitchCase=\"'year'\"> <bs-years-calendar-view *ngFor=\"let calendar of (yearsCalendar | async)\" [class.bs-datepicker-multiple]=\"(daysCalendar | async)?.length > 1\" [calendar]=\"calendar\" (onNavigate)=\"navigateTo($event)\" (onViewMode)=\"setViewMode($event)\" (onHover)=\"yearHoverHandler($event)\" (onSelect)=\"yearSelectHandler($event)\" ></bs-years-calendar-view> </div> </div> <!--applycancel buttons--> <div class=\"bs-datepicker-buttons\" *ngIf=\"false\"> <button class=\"btn btn-success\">Apply</button> <button class=\"btn btn-default\">Cancel</button> </div> </div> <!--custom dates or date ranges picker--> <div class=\"bs-datepicker-custom-range\" *ngIf=\"false\"> <bs-custom-date-view [ranges]=\"_customRangesFish\"></bs-custom-date-view> </div> </div> ", host: { '(click)': '_stopPropagation($event)', style: 'position: absolute; display: block;', role: 'dialog', 'aria-label': 'calendar' } },] }, ]; /** @nocollapse */ BsDatepickerContainerComponent.ctorParameters = function () { return [ { type: BsDatepickerConfig, }, { type: BsDatepickerStore, }, { type: BsDatepickerActions, }, { type: BsDatepickerEffects, }, ]; }; return BsDatepickerContainerComponent; }(BsDatepickerAbstractComponent)); export { BsDatepickerContainerComponent }; //# sourceMappingURL=bs-datepicker-container.component.js.map