(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/forms'), require('rxjs'), require('rxjs/operators')) :
typeof define === 'function' && define.amd ? define('ngb', ['exports', '@angular/core', '@angular/common', '@angular/forms', 'rxjs', 'rxjs/operators'], factory) :
(global = global || self, factory(global.ngb = {}, global.ng.core, global.ng.common, global.ng.forms, global.rxjs, global.rxjs.operators));
}(this, function (exports, core, common, forms, rxjs, operators) { 'use strict';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function(d, b) {
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 extendStatics(d, b);
};
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var __assign = function() {
__assign = Object.assign || function __assign(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;
};
return __assign.apply(this, arguments);
};
function __values(o) {
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
if (m) return m.call(o);
return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
}
function __read(o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @param {?} value
* @return {?}
*/
function toInteger(value) {
return parseInt("" + value, 10);
}
/**
* @param {?} value
* @return {?}
*/
function toString(value) {
return (value !== undefined && value !== null) ? "" + value : '';
}
/**
* @param {?} value
* @param {?} max
* @param {?=} min
* @return {?}
*/
function getValueInRange(value, max, min) {
if (min === void 0) { min = 0; }
return Math.max(Math.min(value, max), min);
}
/**
* @param {?} value
* @return {?}
*/
function isString(value) {
return typeof value === 'string';
}
/**
* @param {?} value
* @return {?}
*/
function isNumber(value) {
return !isNaN(toInteger(value));
}
/**
* @param {?} value
* @return {?}
*/
function isInteger(value) {
return typeof value === 'number' && isFinite(value) && Math.floor(value) === value;
}
/**
* @param {?} value
* @return {?}
*/
function isDefined(value) {
return value !== undefined && value !== null;
}
/**
* @param {?} value
* @return {?}
*/
function padNumber(value) {
if (isNumber(value)) {
return ("0" + value).slice(-2);
}
else {
return '';
}
}
/**
* @param {?} text
* @return {?}
*/
function regExpEscape(text) {
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
}
/**
* @param {?} element
* @param {?} className
* @return {?}
*/
function hasClassName(element, className) {
return element && element.className && element.className.split &&
element.className.split(/\s+/).indexOf(className) >= 0;
}
if (typeof Element !== 'undefined' && !Element.prototype.closest) {
// Polyfill for ie10+
if (!Element.prototype.matches) {
// IE uses the non-standard name: msMatchesSelector
Element.prototype.matches = ((/** @type {?} */ (Element.prototype))).msMatchesSelector || Element.prototype.webkitMatchesSelector;
}
Element.prototype.closest = (/**
* @param {?} s
* @return {?}
*/
function (s) {
/** @type {?} */
var el = this;
if (!document.documentElement.contains(el)) {
return null;
}
do {
if (el.matches(s)) {
return el;
}
el = el.parentElement || el.parentNode;
} while (el !== null && el.nodeType === 1);
return null;
});
}
/**
* @param {?} element
* @param {?} selector
* @return {?}
*/
function closest(element, selector) {
if (!selector) {
return null;
}
return element.closest(selector);
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* A configuration service for the [NgbAccordion](#/components/accordion/api#NgbAccordion) component.
*
* You can inject this service, typically in your root component, and customize its properties
* to provide default values for all accordions used in the application.
*/
var NgbAccordionConfig = /** @class */ (function () {
function NgbAccordionConfig() {
this.closeOthers = false;
}
NgbAccordionConfig.decorators = [
{ type: core.Injectable, args: [{ providedIn: 'root' },] }
];
/** @nocollapse */ NgbAccordionConfig.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function NgbAccordionConfig_Factory() { return new NgbAccordionConfig(); }, token: NgbAccordionConfig, providedIn: "root" });
return NgbAccordionConfig;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var nextId = 0;
/**
* A directive that wraps an accordion panel header with any HTML markup and a toggling button
* marked with [`NgbPanelToggle`](#/components/accordion/api#NgbPanelToggle).
* See the [header customization demo](#/components/accordion/examples#header) for more details.
*
* You can also use [`NgbPanelTitle`](#/components/accordion/api#NgbPanelTitle) to customize only the panel title.
*
* \@since 4.1.0
*/
var NgbPanelHeader = /** @class */ (function () {
function NgbPanelHeader(templateRef) {
this.templateRef = templateRef;
}
NgbPanelHeader.decorators = [
{ type: core.Directive, args: [{ selector: 'ng-template[ngbPanelHeader]' },] }
];
/** @nocollapse */
NgbPanelHeader.ctorParameters = function () { return [
{ type: core.TemplateRef }
]; };
return NgbPanelHeader;
}());
/**
* A directive that wraps only the panel title with HTML markup inside.
*
* You can also use [`NgbPanelHeader`](#/components/accordion/api#NgbPanelHeader) to customize the full panel header.
*/
var NgbPanelTitle = /** @class */ (function () {
function NgbPanelTitle(templateRef) {
this.templateRef = templateRef;
}
NgbPanelTitle.decorators = [
{ type: core.Directive, args: [{ selector: 'ng-template[ngbPanelTitle]' },] }
];
/** @nocollapse */
NgbPanelTitle.ctorParameters = function () { return [
{ type: core.TemplateRef }
]; };
return NgbPanelTitle;
}());
/**
* A directive that wraps the accordion panel content.
*/
var NgbPanelContent = /** @class */ (function () {
function NgbPanelContent(templateRef) {
this.templateRef = templateRef;
}
NgbPanelContent.decorators = [
{ type: core.Directive, args: [{ selector: 'ng-template[ngbPanelContent]' },] }
];
/** @nocollapse */
NgbPanelContent.ctorParameters = function () { return [
{ type: core.TemplateRef }
]; };
return NgbPanelContent;
}());
/**
* A directive that wraps an individual accordion panel with title and collapsible content.
*/
var NgbPanel = /** @class */ (function () {
function NgbPanel() {
/**
* If `true`, the panel is disabled an can't be toggled.
*/
this.disabled = false;
/**
* An optional id for the panel that must be unique on the page.
*
* If not provided, it will be auto-generated in the `ngb-panel-xxx` format.
*/
this.id = "ngb-panel-" + nextId++;
this.isOpen = false;
}
/**
* @return {?}
*/
NgbPanel.prototype.ngAfterContentChecked = /**
* @return {?}
*/
function () {
// We are using @ContentChildren instead of @ContentChild as in the Angular version being used
// only @ContentChildren allows us to specify the {descendants: false} option.
// Without {descendants: false} we are hitting bugs described in:
// https://github.com/ng-bootstrap/ng-bootstrap/issues/2240
this.titleTpl = this.titleTpls.first;
this.headerTpl = this.headerTpls.first;
this.contentTpl = this.contentTpls.first;
};
NgbPanel.decorators = [
{ type: core.Directive, args: [{ selector: 'ngb-panel' },] }
];
NgbPanel.propDecorators = {
disabled: [{ type: core.Input }],
id: [{ type: core.Input }],
title: [{ type: core.Input }],
type: [{ type: core.Input }],
titleTpls: [{ type: core.ContentChildren, args: [NgbPanelTitle, { descendants: false },] }],
headerTpls: [{ type: core.ContentChildren, args: [NgbPanelHeader, { descendants: false },] }],
contentTpls: [{ type: core.ContentChildren, args: [NgbPanelContent, { descendants: false },] }]
};
return NgbPanel;
}());
/**
* Accordion is a collection of collapsible panels (bootstrap cards).
*
* It can ensure only one panel is opened at a time and allows to customize panel
* headers.
*/
var NgbAccordion = /** @class */ (function () {
function NgbAccordion(config) {
/**
* An array or comma separated strings of panel ids that should be opened **initially**.
*
* For subsequent changes use methods like `expand()`, `collapse()`, etc. and
* the `(panelChange)` event.
*/
this.activeIds = [];
/**
* If `true`, panel content will be detached from DOM and not simply hidden when the panel is collapsed.
*/
this.destroyOnHide = true;
/**
* Event emitted right before the panel toggle happens.
*
* See [NgbPanelChangeEvent](#/components/accordion/api#NgbPanelChangeEvent) for payload details.
*/
this.panelChange = new core.EventEmitter();
this.type = config.type;
this.closeOtherPanels = config.closeOthers;
}
/**
* Checks if a panel with a given id is expanded.
*/
/**
* Checks if a panel with a given id is expanded.
* @param {?} panelId
* @return {?}
*/
NgbAccordion.prototype.isExpanded = /**
* Checks if a panel with a given id is expanded.
* @param {?} panelId
* @return {?}
*/
function (panelId) { return this.activeIds.indexOf(panelId) > -1; };
/**
* Expands a panel with a given id.
*
* Has no effect if the panel is already expanded or disabled.
*/
/**
* Expands a panel with a given id.
*
* Has no effect if the panel is already expanded or disabled.
* @param {?} panelId
* @return {?}
*/
NgbAccordion.prototype.expand = /**
* Expands a panel with a given id.
*
* Has no effect if the panel is already expanded or disabled.
* @param {?} panelId
* @return {?}
*/
function (panelId) { this._changeOpenState(this._findPanelById(panelId), true); };
/**
* Expands all panels, if `[closeOthers]` is `false`.
*
* If `[closeOthers]` is `true`, it will expand the first panel, unless there is already a panel opened.
*/
/**
* Expands all panels, if `[closeOthers]` is `false`.
*
* If `[closeOthers]` is `true`, it will expand the first panel, unless there is already a panel opened.
* @return {?}
*/
NgbAccordion.prototype.expandAll = /**
* Expands all panels, if `[closeOthers]` is `false`.
*
* If `[closeOthers]` is `true`, it will expand the first panel, unless there is already a panel opened.
* @return {?}
*/
function () {
var _this = this;
if (this.closeOtherPanels) {
if (this.activeIds.length === 0 && this.panels.length) {
this._changeOpenState(this.panels.first, true);
}
}
else {
this.panels.forEach((/**
* @param {?} panel
* @return {?}
*/
function (panel) { return _this._changeOpenState(panel, true); }));
}
};
/**
* Collapses a panel with the given id.
*
* Has no effect if the panel is already collapsed or disabled.
*/
/**
* Collapses a panel with the given id.
*
* Has no effect if the panel is already collapsed or disabled.
* @param {?} panelId
* @return {?}
*/
NgbAccordion.prototype.collapse = /**
* Collapses a panel with the given id.
*
* Has no effect if the panel is already collapsed or disabled.
* @param {?} panelId
* @return {?}
*/
function (panelId) { this._changeOpenState(this._findPanelById(panelId), false); };
/**
* Collapses all opened panels.
*/
/**
* Collapses all opened panels.
* @return {?}
*/
NgbAccordion.prototype.collapseAll = /**
* Collapses all opened panels.
* @return {?}
*/
function () {
var _this = this;
this.panels.forEach((/**
* @param {?} panel
* @return {?}
*/
function (panel) { _this._changeOpenState(panel, false); }));
};
/**
* Toggles a panel with the given id.
*
* Has no effect if the panel is disabled.
*/
/**
* Toggles a panel with the given id.
*
* Has no effect if the panel is disabled.
* @param {?} panelId
* @return {?}
*/
NgbAccordion.prototype.toggle = /**
* Toggles a panel with the given id.
*
* Has no effect if the panel is disabled.
* @param {?} panelId
* @return {?}
*/
function (panelId) {
/** @type {?} */
var panel = this._findPanelById(panelId);
if (panel) {
this._changeOpenState(panel, !panel.isOpen);
}
};
/**
* @return {?}
*/
NgbAccordion.prototype.ngAfterContentChecked = /**
* @return {?}
*/
function () {
var _this = this;
// active id updates
if (isString(this.activeIds)) {
this.activeIds = this.activeIds.split(/\s*,\s*/);
}
// update panels open states
this.panels.forEach((/**
* @param {?} panel
* @return {?}
*/
function (panel) { return panel.isOpen = !panel.disabled && _this.activeIds.indexOf(panel.id) > -1; }));
// closeOthers updates
if (this.activeIds.length > 1 && this.closeOtherPanels) {
this._closeOthers(this.activeIds[0]);
this._updateActiveIds();
}
};
/**
* @private
* @param {?} panel
* @param {?} nextState
* @return {?}
*/
NgbAccordion.prototype._changeOpenState = /**
* @private
* @param {?} panel
* @param {?} nextState
* @return {?}
*/
function (panel, nextState) {
if (panel && !panel.disabled && panel.isOpen !== nextState) {
/** @type {?} */
var defaultPrevented_1 = false;
this.panelChange.emit({ panelId: panel.id, nextState: nextState, preventDefault: (/**
* @return {?}
*/
function () { defaultPrevented_1 = true; }) });
if (!defaultPrevented_1) {
panel.isOpen = nextState;
if (nextState && this.closeOtherPanels) {
this._closeOthers(panel.id);
}
this._updateActiveIds();
}
}
};
/**
* @private
* @param {?} panelId
* @return {?}
*/
NgbAccordion.prototype._closeOthers = /**
* @private
* @param {?} panelId
* @return {?}
*/
function (panelId) {
this.panels.forEach((/**
* @param {?} panel
* @return {?}
*/
function (panel) {
if (panel.id !== panelId) {
panel.isOpen = false;
}
}));
};
/**
* @private
* @param {?} panelId
* @return {?}
*/
NgbAccordion.prototype._findPanelById = /**
* @private
* @param {?} panelId
* @return {?}
*/
function (panelId) { return this.panels.find((/**
* @param {?} p
* @return {?}
*/
function (p) { return p.id === panelId; })); };
/**
* @private
* @return {?}
*/
NgbAccordion.prototype._updateActiveIds = /**
* @private
* @return {?}
*/
function () {
this.activeIds = this.panels.filter((/**
* @param {?} panel
* @return {?}
*/
function (panel) { return panel.isOpen && !panel.disabled; })).map((/**
* @param {?} panel
* @return {?}
*/
function (panel) { return panel.id; }));
};
NgbAccordion.decorators = [
{ type: core.Component, args: [{
selector: 'ngb-accordion',
exportAs: 'ngbAccordion',
host: { 'class': 'accordion', 'role': 'tablist', '[attr.aria-multiselectable]': '!closeOtherPanels' },
template: "\n \n \n \n \n
\n
\n \n
\n
\n
\n \n
\n
\n
\n \n "
}] }
];
/** @nocollapse */
NgbAccordion.ctorParameters = function () { return [
{ type: NgbAccordionConfig }
]; };
NgbAccordion.propDecorators = {
panels: [{ type: core.ContentChildren, args: [NgbPanel,] }],
activeIds: [{ type: core.Input }],
closeOtherPanels: [{ type: core.Input, args: ['closeOthers',] }],
destroyOnHide: [{ type: core.Input }],
type: [{ type: core.Input }],
panelChange: [{ type: core.Output }]
};
return NgbAccordion;
}());
/**
* A directive to put on a button that toggles panel opening and closing.
*
* To be used inside the [`NgbPanelHeader`](#/components/accordion/api#NgbPanelHeader)
*
* \@since 4.1.0
*/
var NgbPanelToggle = /** @class */ (function () {
function NgbPanelToggle(accordion, panel) {
this.accordion = accordion;
this.panel = panel;
}
Object.defineProperty(NgbPanelToggle.prototype, "ngbPanelToggle", {
set: /**
* @param {?} panel
* @return {?}
*/
function (panel) {
if (panel) {
this.panel = panel;
}
},
enumerable: true,
configurable: true
});
NgbPanelToggle.decorators = [
{ type: core.Directive, args: [{
selector: 'button[ngbPanelToggle]',
host: {
'type': 'button',
'[disabled]': 'panel.disabled',
'[class.collapsed]': '!panel.isOpen',
'[attr.aria-expanded]': 'panel.isOpen',
'[attr.aria-controls]': 'panel.id',
'(click)': 'accordion.toggle(panel.id)'
}
},] }
];
/** @nocollapse */
NgbPanelToggle.ctorParameters = function () { return [
{ type: NgbAccordion },
{ type: NgbPanel, decorators: [{ type: core.Optional }, { type: core.Host }] }
]; };
NgbPanelToggle.propDecorators = {
ngbPanelToggle: [{ type: core.Input }]
};
return NgbPanelToggle;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var NGB_ACCORDION_DIRECTIVES = [NgbAccordion, NgbPanel, NgbPanelTitle, NgbPanelContent, NgbPanelHeader, NgbPanelToggle];
var NgbAccordionModule = /** @class */ (function () {
function NgbAccordionModule() {
}
NgbAccordionModule.decorators = [
{ type: core.NgModule, args: [{ declarations: NGB_ACCORDION_DIRECTIVES, exports: NGB_ACCORDION_DIRECTIVES, imports: [common.CommonModule] },] }
];
return NgbAccordionModule;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* A configuration service for the [NgbAlert](#/components/alert/api#NgbAlert) component.
*
* You can inject this service, typically in your root component, and customize its properties
* to provide default values for all alerts used in the application.
*/
var NgbAlertConfig = /** @class */ (function () {
function NgbAlertConfig() {
this.dismissible = true;
this.type = 'warning';
}
NgbAlertConfig.decorators = [
{ type: core.Injectable, args: [{ providedIn: 'root' },] }
];
/** @nocollapse */ NgbAlertConfig.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function NgbAlertConfig_Factory() { return new NgbAlertConfig(); }, token: NgbAlertConfig, providedIn: "root" });
return NgbAlertConfig;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* Alert is a component to provide contextual feedback messages for user.
*
* It supports several alert types and can be dismissed.
*/
var NgbAlert = /** @class */ (function () {
function NgbAlert(config, _renderer, _element) {
this._renderer = _renderer;
this._element = _element;
/**
* An event emitted when the close button is clicked. It has no payload and only relevant for dismissible alerts.
*/
this.close = new core.EventEmitter();
this.dismissible = config.dismissible;
this.type = config.type;
}
/**
* @return {?}
*/
NgbAlert.prototype.closeHandler = /**
* @return {?}
*/
function () { this.close.emit(null); };
/**
* @param {?} changes
* @return {?}
*/
NgbAlert.prototype.ngOnChanges = /**
* @param {?} changes
* @return {?}
*/
function (changes) {
/** @type {?} */
var typeChange = changes['type'];
if (typeChange && !typeChange.firstChange) {
this._renderer.removeClass(this._element.nativeElement, "alert-" + typeChange.previousValue);
this._renderer.addClass(this._element.nativeElement, "alert-" + typeChange.currentValue);
}
};
/**
* @return {?}
*/
NgbAlert.prototype.ngOnInit = /**
* @return {?}
*/
function () { this._renderer.addClass(this._element.nativeElement, "alert-" + this.type); };
NgbAlert.decorators = [
{ type: core.Component, args: [{
selector: 'ngb-alert',
changeDetection: core.ChangeDetectionStrategy.OnPush,
encapsulation: core.ViewEncapsulation.None,
host: { 'role': 'alert', 'class': 'alert', '[class.alert-dismissible]': 'dismissible' },
template: "\n \n \n ",
styles: ["ngb-alert{display:block}"]
}] }
];
/** @nocollapse */
NgbAlert.ctorParameters = function () { return [
{ type: NgbAlertConfig },
{ type: core.Renderer2 },
{ type: core.ElementRef }
]; };
NgbAlert.propDecorators = {
dismissible: [{ type: core.Input }],
type: [{ type: core.Input }],
close: [{ type: core.Output }]
};
return NgbAlert;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NgbAlertModule = /** @class */ (function () {
function NgbAlertModule() {
}
NgbAlertModule.decorators = [
{ type: core.NgModule, args: [{ declarations: [NgbAlert], exports: [NgbAlert], imports: [common.CommonModule], entryComponents: [NgbAlert] },] }
];
return NgbAlertModule;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NgbButtonLabel = /** @class */ (function () {
function NgbButtonLabel() {
}
NgbButtonLabel.decorators = [
{ type: core.Directive, args: [{
selector: '[ngbButtonLabel]',
host: { '[class.btn]': 'true', '[class.active]': 'active', '[class.disabled]': 'disabled', '[class.focus]': 'focused' }
},] }
];
return NgbButtonLabel;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var NGB_CHECKBOX_VALUE_ACCESSOR = {
provide: forms.NG_VALUE_ACCESSOR,
useExisting: core.forwardRef((/**
* @return {?}
*/
function () { return NgbCheckBox; })),
multi: true
};
/**
* Allows to easily create Bootstrap-style checkbox buttons.
*
* Integrates with forms, so the value of a checked button is bound to the underlying form control
* either in a reactive or template-driven way.
*/
var NgbCheckBox = /** @class */ (function () {
function NgbCheckBox(_label, _cd) {
this._label = _label;
this._cd = _cd;
/**
* If `true`, the checkbox button will be disabled
*/
this.disabled = false;
/**
* The form control value when the checkbox is checked.
*/
this.valueChecked = true;
/**
* The form control value when the checkbox is unchecked.
*/
this.valueUnChecked = false;
this.onChange = (/**
* @param {?} _
* @return {?}
*/
function (_) { });
this.onTouched = (/**
* @return {?}
*/
function () { });
}
Object.defineProperty(NgbCheckBox.prototype, "focused", {
set: /**
* @param {?} isFocused
* @return {?}
*/
function (isFocused) {
this._label.focused = isFocused;
if (!isFocused) {
this.onTouched();
}
},
enumerable: true,
configurable: true
});
/**
* @param {?} $event
* @return {?}
*/
NgbCheckBox.prototype.onInputChange = /**
* @param {?} $event
* @return {?}
*/
function ($event) {
/** @type {?} */
var modelToPropagate = $event.target.checked ? this.valueChecked : this.valueUnChecked;
this.onChange(modelToPropagate);
this.onTouched();
this.writeValue(modelToPropagate);
};
/**
* @param {?} fn
* @return {?}
*/
NgbCheckBox.prototype.registerOnChange = /**
* @param {?} fn
* @return {?}
*/
function (fn) { this.onChange = fn; };
/**
* @param {?} fn
* @return {?}
*/
NgbCheckBox.prototype.registerOnTouched = /**
* @param {?} fn
* @return {?}
*/
function (fn) { this.onTouched = fn; };
/**
* @param {?} isDisabled
* @return {?}
*/
NgbCheckBox.prototype.setDisabledState = /**
* @param {?} isDisabled
* @return {?}
*/
function (isDisabled) {
this.disabled = isDisabled;
this._label.disabled = isDisabled;
};
/**
* @param {?} value
* @return {?}
*/
NgbCheckBox.prototype.writeValue = /**
* @param {?} value
* @return {?}
*/
function (value) {
this.checked = value === this.valueChecked;
this._label.active = this.checked;
// label won't be updated, if it is inside the OnPush component when [ngModel] changes
this._cd.markForCheck();
};
NgbCheckBox.decorators = [
{ type: core.Directive, args: [{
selector: '[ngbButton][type=checkbox]',
host: {
'autocomplete': 'off',
'[checked]': 'checked',
'[disabled]': 'disabled',
'(change)': 'onInputChange($event)',
'(focus)': 'focused = true',
'(blur)': 'focused = false'
},
providers: [NGB_CHECKBOX_VALUE_ACCESSOR]
},] }
];
/** @nocollapse */
NgbCheckBox.ctorParameters = function () { return [
{ type: NgbButtonLabel },
{ type: core.ChangeDetectorRef }
]; };
NgbCheckBox.propDecorators = {
disabled: [{ type: core.Input }],
valueChecked: [{ type: core.Input }],
valueUnChecked: [{ type: core.Input }]
};
return NgbCheckBox;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var NGB_RADIO_VALUE_ACCESSOR = {
provide: forms.NG_VALUE_ACCESSOR,
useExisting: core.forwardRef((/**
* @return {?}
*/
function () { return NgbRadioGroup; })),
multi: true
};
/** @type {?} */
var nextId$1 = 0;
/**
* Allows to easily create Bootstrap-style radio buttons.
*
* Integrates with forms, so the value of a checked button is bound to the underlying form control
* either in a reactive or template-driven way.
*/
var NgbRadioGroup = /** @class */ (function () {
function NgbRadioGroup() {
this._radios = new Set();
this._value = null;
/**
* Name of the radio group applied to radio input elements.
*
* Will be applied to all radio input elements inside the group,
* unless [`NgbRadio`](#/components/buttons/api#NgbRadio)'s specify names themselves.
*
* If not provided, will be generated in the `ngb-radio-xx` format.
*/
this.name = "ngb-radio-" + nextId$1++;
this.onChange = (/**
* @param {?} _
* @return {?}
*/
function (_) { });
this.onTouched = (/**
* @return {?}
*/
function () { });
}
Object.defineProperty(NgbRadioGroup.prototype, "disabled", {
get: /**
* @return {?}
*/
function () { return this._disabled; },
set: /**
* @param {?} isDisabled
* @return {?}
*/
function (isDisabled) { this.setDisabledState(isDisabled); },
enumerable: true,
configurable: true
});
/**
* @param {?} radio
* @return {?}
*/
NgbRadioGroup.prototype.onRadioChange = /**
* @param {?} radio
* @return {?}
*/
function (radio) {
this.writeValue(radio.value);
this.onChange(radio.value);
};
/**
* @return {?}
*/
NgbRadioGroup.prototype.onRadioValueUpdate = /**
* @return {?}
*/
function () { this._updateRadiosValue(); };
/**
* @param {?} radio
* @return {?}
*/
NgbRadioGroup.prototype.register = /**
* @param {?} radio
* @return {?}
*/
function (radio) { this._radios.add(radio); };
/**
* @param {?} fn
* @return {?}
*/
NgbRadioGroup.prototype.registerOnChange = /**
* @param {?} fn
* @return {?}
*/
function (fn) { this.onChange = fn; };
/**
* @param {?} fn
* @return {?}
*/
NgbRadioGroup.prototype.registerOnTouched = /**
* @param {?} fn
* @return {?}
*/
function (fn) { this.onTouched = fn; };
/**
* @param {?} isDisabled
* @return {?}
*/
NgbRadioGroup.prototype.setDisabledState = /**
* @param {?} isDisabled
* @return {?}
*/
function (isDisabled) {
this._disabled = isDisabled;
this._updateRadiosDisabled();
};
/**
* @param {?} radio
* @return {?}
*/
NgbRadioGroup.prototype.unregister = /**
* @param {?} radio
* @return {?}
*/
function (radio) { this._radios.delete(radio); };
/**
* @param {?} value
* @return {?}
*/
NgbRadioGroup.prototype.writeValue = /**
* @param {?} value
* @return {?}
*/
function (value) {
this._value = value;
this._updateRadiosValue();
};
/**
* @private
* @return {?}
*/
NgbRadioGroup.prototype._updateRadiosValue = /**
* @private
* @return {?}
*/
function () {
var _this = this;
this._radios.forEach((/**
* @param {?} radio
* @return {?}
*/
function (radio) { return radio.updateValue(_this._value); }));
};
/**
* @private
* @return {?}
*/
NgbRadioGroup.prototype._updateRadiosDisabled = /**
* @private
* @return {?}
*/
function () { this._radios.forEach((/**
* @param {?} radio
* @return {?}
*/
function (radio) { return radio.updateDisabled(); })); };
NgbRadioGroup.decorators = [
{ type: core.Directive, args: [{ selector: '[ngbRadioGroup]', host: { 'role': 'radiogroup' }, providers: [NGB_RADIO_VALUE_ACCESSOR] },] }
];
NgbRadioGroup.propDecorators = {
name: [{ type: core.Input }]
};
return NgbRadioGroup;
}());
/**
* A directive that marks an input of type "radio" as a part of the
* [`NgbRadioGroup`](#/components/buttons/api#NgbRadioGroup).
*/
var NgbRadio = /** @class */ (function () {
function NgbRadio(_group, _label, _renderer, _element, _cd) {
this._group = _group;
this._label = _label;
this._renderer = _renderer;
this._element = _element;
this._cd = _cd;
this._value = null;
this._group.register(this);
this.updateDisabled();
}
Object.defineProperty(NgbRadio.prototype, "value", {
get: /**
* @return {?}
*/
function () { return this._value; },
/**
* The form control value when current radio button is checked.
*/
set: /**
* The form control value when current radio button is checked.
* @param {?} value
* @return {?}
*/
function (value) {
this._value = value;
/** @type {?} */
var stringValue = value ? value.toString() : '';
this._renderer.setProperty(this._element.nativeElement, 'value', stringValue);
this._group.onRadioValueUpdate();
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgbRadio.prototype, "disabled", {
get: /**
* @return {?}
*/
function () { return this._group.disabled || this._disabled; },
/**
* If `true`, current radio button will be disabled.
*/
set: /**
* If `true`, current radio button will be disabled.
* @param {?} isDisabled
* @return {?}
*/
function (isDisabled) {
this._disabled = isDisabled !== false;
this.updateDisabled();
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgbRadio.prototype, "focused", {
set: /**
* @param {?} isFocused
* @return {?}
*/
function (isFocused) {
if (this._label) {
this._label.focused = isFocused;
}
if (!isFocused) {
this._group.onTouched();
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgbRadio.prototype, "checked", {
get: /**
* @return {?}
*/
function () { return this._checked; },
enumerable: true,
configurable: true
});
Object.defineProperty(NgbRadio.prototype, "nameAttr", {
get: /**
* @return {?}
*/
function () { return this.name || this._group.name; },
enumerable: true,
configurable: true
});
/**
* @return {?}
*/
NgbRadio.prototype.ngOnDestroy = /**
* @return {?}
*/
function () { this._group.unregister(this); };
/**
* @return {?}
*/
NgbRadio.prototype.onChange = /**
* @return {?}
*/
function () { this._group.onRadioChange(this); };
/**
* @param {?} value
* @return {?}
*/
NgbRadio.prototype.updateValue = /**
* @param {?} value
* @return {?}
*/
function (value) {
// label won't be updated, if it is inside the OnPush component when [ngModel] changes
if (this.value !== value) {
this._cd.markForCheck();
}
this._checked = this.value === value;
this._label.active = this._checked;
};
/**
* @return {?}
*/
NgbRadio.prototype.updateDisabled = /**
* @return {?}
*/
function () { this._label.disabled = this.disabled; };
NgbRadio.decorators = [
{ type: core.Directive, args: [{
selector: '[ngbButton][type=radio]',
host: {
'[checked]': 'checked',
'[disabled]': 'disabled',
'[name]': 'nameAttr',
'(change)': 'onChange()',
'(focus)': 'focused = true',
'(blur)': 'focused = false'
}
},] }
];
/** @nocollapse */
NgbRadio.ctorParameters = function () { return [
{ type: NgbRadioGroup },
{ type: NgbButtonLabel },
{ type: core.Renderer2 },
{ type: core.ElementRef },
{ type: core.ChangeDetectorRef }
]; };
NgbRadio.propDecorators = {
name: [{ type: core.Input }],
value: [{ type: core.Input, args: ['value',] }],
disabled: [{ type: core.Input, args: ['disabled',] }]
};
return NgbRadio;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var NGB_BUTTON_DIRECTIVES = [NgbButtonLabel, NgbCheckBox, NgbRadioGroup, NgbRadio];
var NgbButtonsModule = /** @class */ (function () {
function NgbButtonsModule() {
}
NgbButtonsModule.decorators = [
{ type: core.NgModule, args: [{ declarations: NGB_BUTTON_DIRECTIVES, exports: NGB_BUTTON_DIRECTIVES },] }
];
return NgbButtonsModule;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* A configuration service for the [NgbCarousel](#/components/carousel/api#NgbCarousel) component.
*
* You can inject this service, typically in your root component, and customize its properties
* to provide default values for all carousels used in the application.
*/
var NgbCarouselConfig = /** @class */ (function () {
function NgbCarouselConfig() {
this.interval = 5000;
this.wrap = true;
this.keyboard = true;
this.pauseOnHover = true;
this.showNavigationArrows = true;
this.showNavigationIndicators = true;
}
NgbCarouselConfig.decorators = [
{ type: core.Injectable, args: [{ providedIn: 'root' },] }
];
/** @nocollapse */ NgbCarouselConfig.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function NgbCarouselConfig_Factory() { return new NgbCarouselConfig(); }, token: NgbCarouselConfig, providedIn: "root" });
return NgbCarouselConfig;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var nextId$2 = 0;
/**
* A directive that wraps the individual carousel slide.
*/
var NgbSlide = /** @class */ (function () {
function NgbSlide(tplRef) {
this.tplRef = tplRef;
/**
* Slide id that must be unique for the entire document.
*
* If not provided, will be generated in the `ngb-slide-xx` format.
*/
this.id = "ngb-slide-" + nextId$2++;
}
NgbSlide.decorators = [
{ type: core.Directive, args: [{ selector: 'ng-template[ngbSlide]' },] }
];
/** @nocollapse */
NgbSlide.ctorParameters = function () { return [
{ type: core.TemplateRef }
]; };
NgbSlide.propDecorators = {
id: [{ type: core.Input }]
};
return NgbSlide;
}());
/**
* Carousel is a component to easily create and control slideshows.
*
* Allows to set intervals, change the way user interacts with the slides and provides a programmatic API.
*/
var NgbCarousel = /** @class */ (function () {
function NgbCarousel(config, _platformId, _ngZone, _cd) {
this._platformId = _platformId;
this._ngZone = _ngZone;
this._cd = _cd;
this._destroy$ = new rxjs.Subject();
this._start$ = new rxjs.Subject();
this._stop$ = new rxjs.Subject();
/**
* An event emitted right after the slide transition is completed.
*
* See [`NgbSlideEvent`](#/components/carousel/api#NgbSlideEvent) for payload details.
*/
this.slide = new core.EventEmitter();
this.interval = config.interval;
this.wrap = config.wrap;
this.keyboard = config.keyboard;
this.pauseOnHover = config.pauseOnHover;
this.showNavigationArrows = config.showNavigationArrows;
this.showNavigationIndicators = config.showNavigationIndicators;
}
/**
* @return {?}
*/
NgbCarousel.prototype.ngAfterContentInit = /**
* @return {?}
*/
function () {
var _this = this;
// setInterval() doesn't play well with SSR and protractor,
// so we should run it in the browser and outside Angular
if (common.isPlatformBrowser(this._platformId)) {
this._ngZone.runOutsideAngular((/**
* @return {?}
*/
function () {
_this._start$
.pipe(operators.map((/**
* @return {?}
*/
function () { return _this.interval; })), operators.filter((/**
* @param {?} interval
* @return {?}
*/
function (interval) { return interval > 0 && _this.slides.length > 0; })), operators.switchMap((/**
* @param {?} interval
* @return {?}
*/
function (interval) { return rxjs.timer(interval).pipe(operators.takeUntil(rxjs.merge(_this._stop$, _this._destroy$))); })))
.subscribe((/**
* @return {?}
*/
function () { return _this._ngZone.run((/**
* @return {?}
*/
function () { return _this.next(); })); }));
_this._start$.next();
}));
}
this.slides.changes.pipe(operators.takeUntil(this._destroy$)).subscribe((/**
* @return {?}
*/
function () { return _this._cd.markForCheck(); }));
};
/**
* @return {?}
*/
NgbCarousel.prototype.ngAfterContentChecked = /**
* @return {?}
*/
function () {
/** @type {?} */
var activeSlide = this._getSlideById(this.activeId);
this.activeId = activeSlide ? activeSlide.id : (this.slides.length ? this.slides.first.id : null);
};
/**
* @return {?}
*/
NgbCarousel.prototype.ngOnDestroy = /**
* @return {?}
*/
function () { this._destroy$.next(); };
/**
* @param {?} changes
* @return {?}
*/
NgbCarousel.prototype.ngOnChanges = /**
* @param {?} changes
* @return {?}
*/
function (changes) {
if ('interval' in changes && !changes['interval'].isFirstChange()) {
this._start$.next();
}
};
/**
* Navigates to a slide with the specified identifier.
*/
/**
* Navigates to a slide with the specified identifier.
* @param {?} slideId
* @return {?}
*/
NgbCarousel.prototype.select = /**
* Navigates to a slide with the specified identifier.
* @param {?} slideId
* @return {?}
*/
function (slideId) { this._cycleToSelected(slideId, this._getSlideEventDirection(this.activeId, slideId)); };
/**
* Navigates to the previous slide.
*/
/**
* Navigates to the previous slide.
* @return {?}
*/
NgbCarousel.prototype.prev = /**
* Navigates to the previous slide.
* @return {?}
*/
function () { this._cycleToSelected(this._getPrevSlide(this.activeId), NgbSlideEventDirection.RIGHT); };
/**
* Navigates to the next slide.
*/
/**
* Navigates to the next slide.
* @return {?}
*/
NgbCarousel.prototype.next = /**
* Navigates to the next slide.
* @return {?}
*/
function () { this._cycleToSelected(this._getNextSlide(this.activeId), NgbSlideEventDirection.LEFT); };
/**
* Pauses cycling through the slides.
*/
/**
* Pauses cycling through the slides.
* @return {?}
*/
NgbCarousel.prototype.pause = /**
* Pauses cycling through the slides.
* @return {?}
*/
function () { this._stop$.next(); };
/**
* Restarts cycling through the slides from left to right.
*/
/**
* Restarts cycling through the slides from left to right.
* @return {?}
*/
NgbCarousel.prototype.cycle = /**
* Restarts cycling through the slides from left to right.
* @return {?}
*/
function () { this._start$.next(); };
/**
* @private
* @param {?} slideIdx
* @param {?} direction
* @return {?}
*/
NgbCarousel.prototype._cycleToSelected = /**
* @private
* @param {?} slideIdx
* @param {?} direction
* @return {?}
*/
function (slideIdx, direction) {
/** @type {?} */
var selectedSlide = this._getSlideById(slideIdx);
if (selectedSlide && selectedSlide.id !== this.activeId) {
this.slide.emit({ prev: this.activeId, current: selectedSlide.id, direction: direction });
this._start$.next();
this.activeId = selectedSlide.id;
}
// we get here after the interval fires or any external API call like next(), prev() or select()
this._cd.markForCheck();
};
/**
* @private
* @param {?} currentActiveSlideId
* @param {?} nextActiveSlideId
* @return {?}
*/
NgbCarousel.prototype._getSlideEventDirection = /**
* @private
* @param {?} currentActiveSlideId
* @param {?} nextActiveSlideId
* @return {?}
*/
function (currentActiveSlideId, nextActiveSlideId) {
/** @type {?} */
var currentActiveSlideIdx = this._getSlideIdxById(currentActiveSlideId);
/** @type {?} */
var nextActiveSlideIdx = this._getSlideIdxById(nextActiveSlideId);
return currentActiveSlideIdx > nextActiveSlideIdx ? NgbSlideEventDirection.RIGHT : NgbSlideEventDirection.LEFT;
};
/**
* @private
* @param {?} slideId
* @return {?}
*/
NgbCarousel.prototype._getSlideById = /**
* @private
* @param {?} slideId
* @return {?}
*/
function (slideId) { return this.slides.find((/**
* @param {?} slide
* @return {?}
*/
function (slide) { return slide.id === slideId; })); };
/**
* @private
* @param {?} slideId
* @return {?}
*/
NgbCarousel.prototype._getSlideIdxById = /**
* @private
* @param {?} slideId
* @return {?}
*/
function (slideId) {
return this.slides.toArray().indexOf(this._getSlideById(slideId));
};
/**
* @private
* @param {?} currentSlideId
* @return {?}
*/
NgbCarousel.prototype._getNextSlide = /**
* @private
* @param {?} currentSlideId
* @return {?}
*/
function (currentSlideId) {
/** @type {?} */
var slideArr = this.slides.toArray();
/** @type {?} */
var currentSlideIdx = this._getSlideIdxById(currentSlideId);
/** @type {?} */
var isLastSlide = currentSlideIdx === slideArr.length - 1;
return isLastSlide ? (this.wrap ? slideArr[0].id : slideArr[slideArr.length - 1].id) :
slideArr[currentSlideIdx + 1].id;
};
/**
* @private
* @param {?} currentSlideId
* @return {?}
*/
NgbCarousel.prototype._getPrevSlide = /**
* @private
* @param {?} currentSlideId
* @return {?}
*/
function (currentSlideId) {
/** @type {?} */
var slideArr = this.slides.toArray();
/** @type {?} */
var currentSlideIdx = this._getSlideIdxById(currentSlideId);
/** @type {?} */
var isFirstSlide = currentSlideIdx === 0;
return isFirstSlide ? (this.wrap ? slideArr[slideArr.length - 1].id : slideArr[0].id) :
slideArr[currentSlideIdx - 1].id;
};
NgbCarousel.decorators = [
{ type: core.Component, args: [{
selector: 'ngb-carousel',
exportAs: 'ngbCarousel',
changeDetection: core.ChangeDetectionStrategy.OnPush,
host: {
'class': 'carousel slide',
'[style.display]': '"block"',
'tabIndex': '0',
'(mouseenter)': 'pauseOnHover && pause()',
'(mouseleave)': 'pauseOnHover && cycle()',
'(keydown.arrowLeft)': 'keyboard && prev()',
'(keydown.arrowRight)': 'keyboard && next()'
},
template: "\n
\n \n \n
\n
\n \n
\n
\n \n \n Previous\n \n \n \n Next\n \n "
}] }
];
/** @nocollapse */
NgbCarousel.ctorParameters = function () { return [
{ type: NgbCarouselConfig },
{ type: undefined, decorators: [{ type: core.Inject, args: [core.PLATFORM_ID,] }] },
{ type: core.NgZone },
{ type: core.ChangeDetectorRef }
]; };
NgbCarousel.propDecorators = {
slides: [{ type: core.ContentChildren, args: [NgbSlide,] }],
activeId: [{ type: core.Input }],
interval: [{ type: core.Input }],
wrap: [{ type: core.Input }],
keyboard: [{ type: core.Input }],
pauseOnHover: [{ type: core.Input }],
showNavigationArrows: [{ type: core.Input }],
showNavigationIndicators: [{ type: core.Input }],
slide: [{ type: core.Output }]
};
return NgbCarousel;
}());
/** @enum {string} */
var NgbSlideEventDirection = {
LEFT: (/** @type {?} */ ('left')),
RIGHT: (/** @type {?} */ ('right')),
};
/** @type {?} */
var NGB_CAROUSEL_DIRECTIVES = [NgbCarousel, NgbSlide];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NgbCarouselModule = /** @class */ (function () {
function NgbCarouselModule() {
}
NgbCarouselModule.decorators = [
{ type: core.NgModule, args: [{ declarations: NGB_CAROUSEL_DIRECTIVES, exports: NGB_CAROUSEL_DIRECTIVES, imports: [common.CommonModule] },] }
];
return NgbCarouselModule;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* A directive to provide a simple way of hiding and showing elements on the page.
*/
var NgbCollapse = /** @class */ (function () {
function NgbCollapse() {
/**
* If `true`, will collapse the element or show it otherwise.
*/
this.collapsed = false;
}
NgbCollapse.decorators = [
{ type: core.Directive, args: [{
selector: '[ngbCollapse]',
exportAs: 'ngbCollapse',
host: { '[class.collapse]': 'true', '[class.show]': '!collapsed' }
},] }
];
NgbCollapse.propDecorators = {
collapsed: [{ type: core.Input, args: ['ngbCollapse',] }]
};
return NgbCollapse;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NgbCollapseModule = /** @class */ (function () {
function NgbCollapseModule() {
}
NgbCollapseModule.decorators = [
{ type: core.NgModule, args: [{ declarations: [NgbCollapse], exports: [NgbCollapse] },] }
];
return NgbCollapseModule;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* A simple class that represents a date that datepicker also uses internally.
*
* It is the implementation of the `NgbDateStruct` interface that adds some convenience methods,
* like `.equals()`, `.before()`, etc.
*
* All datepicker APIs consume `NgbDateStruct`, but return `NgbDate`.
*
* In many cases it is simpler to manipulate these objects together with
* [`NgbCalendar`](#/components/datepicker/api#NgbCalendar) than native JS Dates.
*
* See the [date format overview](#/components/datepicker/overview#date-model) for more details.
*
* \@since 3.0.0
*/
var /**
* A simple class that represents a date that datepicker also uses internally.
*
* It is the implementation of the `NgbDateStruct` interface that adds some convenience methods,
* like `.equals()`, `.before()`, etc.
*
* All datepicker APIs consume `NgbDateStruct`, but return `NgbDate`.
*
* In many cases it is simpler to manipulate these objects together with
* [`NgbCalendar`](#/components/datepicker/api#NgbCalendar) than native JS Dates.
*
* See the [date format overview](#/components/datepicker/overview#date-model) for more details.
*
* \@since 3.0.0
*/
NgbDate = /** @class */ (function () {
function NgbDate(year, month, day) {
this.year = isInteger(year) ? year : null;
this.month = isInteger(month) ? month : null;
this.day = isInteger(day) ? day : null;
}
/**
* A **static method** that creates a new date object from the `NgbDateStruct`,
*
* ex. `NgbDate.from({year: 2000, month: 5, day: 1})`.
*
* If the `date` is already of `NgbDate` type, the method will return the same object.
*/
/**
* A **static method** that creates a new date object from the `NgbDateStruct`,
*
* ex. `NgbDate.from({year: 2000, month: 5, day: 1})`.
*
* If the `date` is already of `NgbDate` type, the method will return the same object.
* @param {?} date
* @return {?}
*/
NgbDate.from = /**
* A **static method** that creates a new date object from the `NgbDateStruct`,
*
* ex. `NgbDate.from({year: 2000, month: 5, day: 1})`.
*
* If the `date` is already of `NgbDate` type, the method will return the same object.
* @param {?} date
* @return {?}
*/
function (date) {
if (date instanceof NgbDate) {
return date;
}
return date ? new NgbDate(date.year, date.month, date.day) : null;
};
/**
* Checks if the current date is equal to another date.
*/
/**
* Checks if the current date is equal to another date.
* @param {?} other
* @return {?}
*/
NgbDate.prototype.equals = /**
* Checks if the current date is equal to another date.
* @param {?} other
* @return {?}
*/
function (other) {
return other && this.year === other.year && this.month === other.month && this.day === other.day;
};
/**
* Checks if the current date is before another date.
*/
/**
* Checks if the current date is before another date.
* @param {?} other
* @return {?}
*/
NgbDate.prototype.before = /**
* Checks if the current date is before another date.
* @param {?} other
* @return {?}
*/
function (other) {
if (!other) {
return false;
}
if (this.year === other.year) {
if (this.month === other.month) {
return this.day === other.day ? false : this.day < other.day;
}
else {
return this.month < other.month;
}
}
else {
return this.year < other.year;
}
};
/**
* Checks if the current date is after another date.
*/
/**
* Checks if the current date is after another date.
* @param {?} other
* @return {?}
*/
NgbDate.prototype.after = /**
* Checks if the current date is after another date.
* @param {?} other
* @return {?}
*/
function (other) {
if (!other) {
return false;
}
if (this.year === other.year) {
if (this.month === other.month) {
return this.day === other.day ? false : this.day > other.day;
}
else {
return this.month > other.month;
}
}
else {
return this.year > other.year;
}
};
return NgbDate;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @param {?} jsDate
* @return {?}
*/
function fromJSDate(jsDate) {
return new NgbDate(jsDate.getFullYear(), jsDate.getMonth() + 1, jsDate.getDate());
}
/**
* @param {?} date
* @return {?}
*/
function toJSDate(date) {
/** @type {?} */
var jsDate = new Date(date.year, date.month - 1, date.day, 12);
// this is done avoid 30 -> 1930 conversion
if (!isNaN(jsDate.getTime())) {
jsDate.setFullYear(date.year);
}
return jsDate;
}
/**
* @return {?}
*/
function NGB_DATEPICKER_CALENDAR_FACTORY() {
return new NgbCalendarGregorian();
}
/**
* A service that represents the calendar used by the datepicker.
*
* The default implementation uses the Gregorian calendar. You can inject it in your own
* implementations if necessary to simplify `NgbDate` calculations.
* @abstract
*/
var NgbCalendar = /** @class */ (function () {
function NgbCalendar() {
}
NgbCalendar.decorators = [
{ type: core.Injectable, args: [{ providedIn: 'root', useFactory: NGB_DATEPICKER_CALENDAR_FACTORY },] }
];
/** @nocollapse */ NgbCalendar.ngInjectableDef = core.ɵɵdefineInjectable({ factory: NGB_DATEPICKER_CALENDAR_FACTORY, token: NgbCalendar, providedIn: "root" });
return NgbCalendar;
}());
var NgbCalendarGregorian = /** @class */ (function (_super) {
__extends(NgbCalendarGregorian, _super);
function NgbCalendarGregorian() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* @return {?}
*/
NgbCalendarGregorian.prototype.getDaysPerWeek = /**
* @return {?}
*/
function () { return 7; };
/**
* @return {?}
*/
NgbCalendarGregorian.prototype.getMonths = /**
* @return {?}
*/
function () { return [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; };
/**
* @return {?}
*/
NgbCalendarGregorian.prototype.getWeeksPerMonth = /**
* @return {?}
*/
function () { return 6; };
/**
* @param {?} date
* @param {?=} period
* @param {?=} number
* @return {?}
*/
NgbCalendarGregorian.prototype.getNext = /**
* @param {?} date
* @param {?=} period
* @param {?=} number
* @return {?}
*/
function (date, period, number) {
if (period === void 0) { period = 'd'; }
if (number === void 0) { number = 1; }
/** @type {?} */
var jsDate = toJSDate(date);
switch (period) {
case 'y':
return new NgbDate(date.year + number, 1, 1);
case 'm':
jsDate = new Date(date.year, date.month + number - 1, 1, 12);
break;
case 'd':
jsDate.setDate(jsDate.getDate() + number);
break;
default:
return date;
}
return fromJSDate(jsDate);
};
/**
* @param {?} date
* @param {?=} period
* @param {?=} number
* @return {?}
*/
NgbCalendarGregorian.prototype.getPrev = /**
* @param {?} date
* @param {?=} period
* @param {?=} number
* @return {?}
*/
function (date, period, number) {
if (period === void 0) { period = 'd'; }
if (number === void 0) { number = 1; }
return this.getNext(date, period, -number);
};
/**
* @param {?} date
* @return {?}
*/
NgbCalendarGregorian.prototype.getWeekday = /**
* @param {?} date
* @return {?}
*/
function (date) {
/** @type {?} */
var jsDate = toJSDate(date);
/** @type {?} */
var day = jsDate.getDay();
// in JS Date Sun=0, in ISO 8601 Sun=7
return day === 0 ? 7 : day;
};
/**
* @param {?} week
* @param {?} firstDayOfWeek
* @return {?}
*/
NgbCalendarGregorian.prototype.getWeekNumber = /**
* @param {?} week
* @param {?} firstDayOfWeek
* @return {?}
*/
function (week, firstDayOfWeek) {
// in JS Date Sun=0, in ISO 8601 Sun=7
if (firstDayOfWeek === 7) {
firstDayOfWeek = 0;
}
/** @type {?} */
var thursdayIndex = (4 + 7 - firstDayOfWeek) % 7;
/** @type {?} */
var date = week[thursdayIndex];
/** @type {?} */
var jsDate = toJSDate(date);
jsDate.setDate(jsDate.getDate() + 4 - (jsDate.getDay() || 7)); // Thursday
// Thursday
/** @type {?} */
var time = jsDate.getTime();
jsDate.setMonth(0); // Compare with Jan 1
jsDate.setDate(1);
return Math.floor(Math.round((time - jsDate.getTime()) / 86400000) / 7) + 1;
};
/**
* @return {?}
*/
NgbCalendarGregorian.prototype.getToday = /**
* @return {?}
*/
function () { return fromJSDate(new Date()); };
/**
* @param {?} date
* @return {?}
*/
NgbCalendarGregorian.prototype.isValid = /**
* @param {?} date
* @return {?}
*/
function (date) {
if (!date || !isInteger(date.year) || !isInteger(date.month) || !isInteger(date.day)) {
return false;
}
// year 0 doesn't exist in Gregorian calendar
if (date.year === 0) {
return false;
}
/** @type {?} */
var jsDate = toJSDate(date);
return !isNaN(jsDate.getTime()) && jsDate.getFullYear() === date.year && jsDate.getMonth() + 1 === date.month &&
jsDate.getDate() === date.day;
};
NgbCalendarGregorian.decorators = [
{ type: core.Injectable }
];
return NgbCalendarGregorian;
}(NgbCalendar));
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @param {?} prev
* @param {?} next
* @return {?}
*/
function isChangedDate(prev, next) {
return !dateComparator(prev, next);
}
/**
* @param {?} prev
* @param {?} next
* @return {?}
*/
function isChangedMonth(prev, next) {
return !prev && !next ? false : !prev || !next ? true : prev.year !== next.year || prev.month !== next.month;
}
/**
* @param {?} prev
* @param {?} next
* @return {?}
*/
function dateComparator(prev, next) {
return (!prev && !next) || (!!prev && !!next && prev.equals(next));
}
/**
* @param {?} minDate
* @param {?} maxDate
* @return {?}
*/
function checkMinBeforeMax(minDate, maxDate) {
if (maxDate && minDate && maxDate.before(minDate)) {
throw new Error("'maxDate' " + maxDate + " should be greater than 'minDate' " + minDate);
}
}
/**
* @param {?} date
* @param {?} minDate
* @param {?} maxDate
* @return {?}
*/
function checkDateInRange(date, minDate, maxDate) {
if (date && minDate && date.before(minDate)) {
return minDate;
}
if (date && maxDate && date.after(maxDate)) {
return maxDate;
}
return date;
}
/**
* @param {?} date
* @param {?} state
* @return {?}
*/
function isDateSelectable(date, state) {
var minDate = state.minDate, maxDate = state.maxDate, disabled = state.disabled, markDisabled = state.markDisabled;
// clang-format off
return !(!isDefined(date) ||
disabled ||
(markDisabled && markDisabled(date, { year: date.year, month: date.month })) ||
(minDate && date.before(minDate)) ||
(maxDate && date.after(maxDate)));
// clang-format on
}
/**
* @param {?} calendar
* @param {?} date
* @param {?} minDate
* @param {?} maxDate
* @return {?}
*/
function generateSelectBoxMonths(calendar, date, minDate, maxDate) {
if (!date) {
return [];
}
/** @type {?} */
var months = calendar.getMonths(date.year);
if (minDate && date.year === minDate.year) {
/** @type {?} */
var index = months.findIndex((/**
* @param {?} month
* @return {?}
*/
function (month) { return month === minDate.month; }));
months = months.slice(index);
}
if (maxDate && date.year === maxDate.year) {
/** @type {?} */
var index = months.findIndex((/**
* @param {?} month
* @return {?}
*/
function (month) { return month === maxDate.month; }));
months = months.slice(0, index + 1);
}
return months;
}
/**
* @param {?} date
* @param {?} minDate
* @param {?} maxDate
* @return {?}
*/
function generateSelectBoxYears(date, minDate, maxDate) {
if (!date) {
return [];
}
/** @type {?} */
var start = minDate && minDate.year || date.year - 10;
/** @type {?} */
var end = maxDate && maxDate.year || date.year + 10;
return Array.from({ length: end - start + 1 }, (/**
* @param {?} e
* @param {?} i
* @return {?}
*/
function (e, i) { return start + i; }));
}
/**
* @param {?} calendar
* @param {?} date
* @param {?} maxDate
* @return {?}
*/
function nextMonthDisabled(calendar, date, maxDate) {
return maxDate && calendar.getNext(date, 'm').after(maxDate);
}
/**
* @param {?} calendar
* @param {?} date
* @param {?} minDate
* @return {?}
*/
function prevMonthDisabled(calendar, date, minDate) {
/** @type {?} */
var prevDate = calendar.getPrev(date, 'm');
return minDate && (prevDate.year === minDate.year && prevDate.month < minDate.month ||
prevDate.year < minDate.year && minDate.month === 1);
}
/**
* @param {?} calendar
* @param {?} date
* @param {?} state
* @param {?} i18n
* @param {?} force
* @return {?}
*/
function buildMonths(calendar, date, state, i18n, force) {
var displayMonths = state.displayMonths, months = state.months;
// move old months to a temporary array
/** @type {?} */
var monthsToReuse = months.splice(0, months.length);
// generate new first dates, nullify or reuse months
/** @type {?} */
var firstDates = Array.from({ length: displayMonths }, (/**
* @param {?} _
* @param {?} i
* @return {?}
*/
function (_, i) {
/** @type {?} */
var firstDate = calendar.getNext(date, 'm', i);
months[i] = null;
if (!force) {
/** @type {?} */
var reusedIndex = monthsToReuse.findIndex((/**
* @param {?} month
* @return {?}
*/
function (month) { return month.firstDate.equals(firstDate); }));
// move reused month back to months
if (reusedIndex !== -1) {
months[i] = monthsToReuse.splice(reusedIndex, 1)[0];
}
}
return firstDate;
}));
// rebuild nullified months
firstDates.forEach((/**
* @param {?} firstDate
* @param {?} i
* @return {?}
*/
function (firstDate, i) {
if (months[i] === null) {
months[i] = buildMonth(calendar, firstDate, state, i18n, monthsToReuse.shift() || (/** @type {?} */ ({})));
}
}));
return months;
}
/**
* @param {?} calendar
* @param {?} date
* @param {?} state
* @param {?} i18n
* @param {?=} month
* @return {?}
*/
function buildMonth(calendar, date, state, i18n, month) {
if (month === void 0) { month = (/** @type {?} */ ({})); }
var dayTemplateData = state.dayTemplateData, minDate = state.minDate, maxDate = state.maxDate, firstDayOfWeek = state.firstDayOfWeek, markDisabled = state.markDisabled, outsideDays = state.outsideDays;
/** @type {?} */
var calendarToday = calendar.getToday();
month.firstDate = null;
month.lastDate = null;
month.number = date.month;
month.year = date.year;
month.weeks = month.weeks || [];
month.weekdays = month.weekdays || [];
date = getFirstViewDate(calendar, date, firstDayOfWeek);
// month has weeks
for (var week = 0; week < calendar.getWeeksPerMonth(); week++) {
/** @type {?} */
var weekObject = month.weeks[week];
if (!weekObject) {
weekObject = month.weeks[week] = { number: 0, days: [], collapsed: true };
}
/** @type {?} */
var days = weekObject.days;
// week has days
for (var day = 0; day < calendar.getDaysPerWeek(); day++) {
if (week === 0) {
month.weekdays[day] = calendar.getWeekday(date);
}
/** @type {?} */
var newDate = new NgbDate(date.year, date.month, date.day);
/** @type {?} */
var nextDate = calendar.getNext(newDate);
/** @type {?} */
var ariaLabel = i18n.getDayAriaLabel(newDate);
// marking date as disabled
/** @type {?} */
var disabled = !!((minDate && newDate.before(minDate)) || (maxDate && newDate.after(maxDate)));
if (!disabled && markDisabled) {
disabled = markDisabled(newDate, { month: month.number, year: month.year });
}
// today
/** @type {?} */
var today = newDate.equals(calendarToday);
// adding user-provided data to the context
/** @type {?} */
var contextUserData = dayTemplateData ? dayTemplateData(newDate, { month: month.number, year: month.year }) : undefined;
// saving first date of the month
if (month.firstDate === null && newDate.month === month.number) {
month.firstDate = newDate;
}
// saving last date of the month
if (newDate.month === month.number && nextDate.month !== month.number) {
month.lastDate = newDate;
}
/** @type {?} */
var dayObject = days[day];
if (!dayObject) {
dayObject = days[day] = (/** @type {?} */ ({}));
}
dayObject.date = newDate;
dayObject.context = Object.assign(dayObject.context || {}, {
$implicit: newDate,
date: newDate,
data: contextUserData,
currentMonth: month.number, disabled: disabled,
focused: false,
selected: false, today: today
});
dayObject.tabindex = -1;
dayObject.ariaLabel = ariaLabel;
dayObject.hidden = false;
date = nextDate;
}
weekObject.number = calendar.getWeekNumber(days.map((/**
* @param {?} day
* @return {?}
*/
function (day) { return day.date; })), firstDayOfWeek);
// marking week as collapsed
weekObject.collapsed = outsideDays === 'collapsed' && days[0].date.month !== month.number &&
days[days.length - 1].date.month !== month.number;
}
return month;
}
/**
* @param {?} calendar
* @param {?} date
* @param {?} firstDayOfWeek
* @return {?}
*/
function getFirstViewDate(calendar, date, firstDayOfWeek) {
/** @type {?} */
var daysPerWeek = calendar.getDaysPerWeek();
/** @type {?} */
var firstMonthDate = new NgbDate(date.year, date.month, 1);
/** @type {?} */
var dayOfWeek = calendar.getWeekday(firstMonthDate) % daysPerWeek;
return calendar.getPrev(firstMonthDate, 'd', (daysPerWeek + dayOfWeek - firstDayOfWeek) % daysPerWeek);
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @param {?} locale
* @return {?}
*/
function NGB_DATEPICKER_18N_FACTORY(locale) {
return new NgbDatepickerI18nDefault(locale);
}
/**
* A service supplying i18n data to the datepicker component.
*
* The default implementation of this service uses the Angular locale and registered locale data for
* weekdays and month names (as explained in the Angular i18n guide).
*
* It also provides a way to i18n data that depends on calendar calculations, like aria labels, day, week and year
* numerals. For other static labels the datepicker uses the default Angular i18n.
*
* See the [i18n demo](#/components/datepicker/examples#i18n) and
* [Hebrew calendar demo](#/components/datepicker/calendars#hebrew) on how to extend this class and define
* a custom provider for i18n.
* @abstract
*/
var NgbDatepickerI18n = /** @class */ (function () {
function NgbDatepickerI18n() {
}
/**
* Returns the textual representation of a day that is rendered in a day cell.
*
* @since 3.0.0
*/
/**
* Returns the textual representation of a day that is rendered in a day cell.
*
* \@since 3.0.0
* @param {?} date
* @return {?}
*/
NgbDatepickerI18n.prototype.getDayNumerals = /**
* Returns the textual representation of a day that is rendered in a day cell.
*
* \@since 3.0.0
* @param {?} date
* @return {?}
*/
function (date) { return "" + date.day; };
/**
* Returns the textual representation of a week number rendered by datepicker.
*
* @since 3.0.0
*/
/**
* Returns the textual representation of a week number rendered by datepicker.
*
* \@since 3.0.0
* @param {?} weekNumber
* @return {?}
*/
NgbDatepickerI18n.prototype.getWeekNumerals = /**
* Returns the textual representation of a week number rendered by datepicker.
*
* \@since 3.0.0
* @param {?} weekNumber
* @return {?}
*/
function (weekNumber) { return "" + weekNumber; };
/**
* Returns the textual representation of a year that is rendered in the datepicker year select box.
*
* @since 3.0.0
*/
/**
* Returns the textual representation of a year that is rendered in the datepicker year select box.
*
* \@since 3.0.0
* @param {?} year
* @return {?}
*/
NgbDatepickerI18n.prototype.getYearNumerals = /**
* Returns the textual representation of a year that is rendered in the datepicker year select box.
*
* \@since 3.0.0
* @param {?} year
* @return {?}
*/
function (year) { return "" + year; };
NgbDatepickerI18n.decorators = [
{ type: core.Injectable, args: [{ providedIn: 'root', useFactory: NGB_DATEPICKER_18N_FACTORY, deps: [core.LOCALE_ID] },] }
];
/** @nocollapse */ NgbDatepickerI18n.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function NgbDatepickerI18n_Factory() { return NGB_DATEPICKER_18N_FACTORY(core.ɵɵinject(core.LOCALE_ID)); }, token: NgbDatepickerI18n, providedIn: "root" });
return NgbDatepickerI18n;
}());
var NgbDatepickerI18nDefault = /** @class */ (function (_super) {
__extends(NgbDatepickerI18nDefault, _super);
function NgbDatepickerI18nDefault(_locale) {
var _this = _super.call(this) || this;
_this._locale = _locale;
/** @type {?} */
var weekdaysStartingOnSunday = common.getLocaleDayNames(_locale, common.FormStyle.Standalone, common.TranslationWidth.Short);
_this._weekdaysShort = weekdaysStartingOnSunday.map((/**
* @param {?} day
* @param {?} index
* @return {?}
*/
function (day, index) { return weekdaysStartingOnSunday[(index + 1) % 7]; }));
_this._monthsShort = common.getLocaleMonthNames(_locale, common.FormStyle.Standalone, common.TranslationWidth.Abbreviated);
_this._monthsFull = common.getLocaleMonthNames(_locale, common.FormStyle.Standalone, common.TranslationWidth.Wide);
return _this;
}
/**
* @param {?} weekday
* @return {?}
*/
NgbDatepickerI18nDefault.prototype.getWeekdayShortName = /**
* @param {?} weekday
* @return {?}
*/
function (weekday) { return this._weekdaysShort[weekday - 1]; };
/**
* @param {?} month
* @return {?}
*/
NgbDatepickerI18nDefault.prototype.getMonthShortName = /**
* @param {?} month
* @return {?}
*/
function (month) { return this._monthsShort[month - 1]; };
/**
* @param {?} month
* @return {?}
*/
NgbDatepickerI18nDefault.prototype.getMonthFullName = /**
* @param {?} month
* @return {?}
*/
function (month) { return this._monthsFull[month - 1]; };
/**
* @param {?} date
* @return {?}
*/
NgbDatepickerI18nDefault.prototype.getDayAriaLabel = /**
* @param {?} date
* @return {?}
*/
function (date) {
/** @type {?} */
var jsDate = new Date(date.year, date.month - 1, date.day);
return common.formatDate(jsDate, 'fullDate', this._locale);
};
NgbDatepickerI18nDefault.decorators = [
{ type: core.Injectable }
];
/** @nocollapse */
NgbDatepickerI18nDefault.ctorParameters = function () { return [
{ type: String, decorators: [{ type: core.Inject, args: [core.LOCALE_ID,] }] }
]; };
return NgbDatepickerI18nDefault;
}(NgbDatepickerI18n));
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NgbDatepickerService = /** @class */ (function () {
function NgbDatepickerService(_calendar, _i18n) {
this._calendar = _calendar;
this._i18n = _i18n;
this._model$ = new rxjs.Subject();
this._select$ = new rxjs.Subject();
this._state = {
disabled: false,
displayMonths: 1,
firstDayOfWeek: 1,
focusVisible: false,
months: [],
navigation: 'select',
outsideDays: 'visible',
prevDisabled: false,
nextDisabled: false,
selectBoxes: { years: [], months: [] },
selectedDate: null
};
}
Object.defineProperty(NgbDatepickerService.prototype, "model$", {
get: /**
* @return {?}
*/
function () { return this._model$.pipe(operators.filter((/**
* @param {?} model
* @return {?}
*/
function (model) { return model.months.length > 0; }))); },
enumerable: true,
configurable: true
});
Object.defineProperty(NgbDatepickerService.prototype, "select$", {
get: /**
* @return {?}
*/
function () { return this._select$.pipe(operators.filter((/**
* @param {?} date
* @return {?}
*/
function (date) { return date !== null; }))); },
enumerable: true,
configurable: true
});
Object.defineProperty(NgbDatepickerService.prototype, "dayTemplateData", {
set: /**
* @param {?} dayTemplateData
* @return {?}
*/
function (dayTemplateData) {
if (this._state.dayTemplateData !== dayTemplateData) {
this._nextState({ dayTemplateData: dayTemplateData });
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgbDatepickerService.prototype, "disabled", {
set: /**
* @param {?} disabled
* @return {?}
*/
function (disabled) {
if (this._state.disabled !== disabled) {
this._nextState({ disabled: disabled });
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgbDatepickerService.prototype, "displayMonths", {
set: /**
* @param {?} displayMonths
* @return {?}
*/
function (displayMonths) {
displayMonths = toInteger(displayMonths);
if (isInteger(displayMonths) && displayMonths > 0 && this._state.displayMonths !== displayMonths) {
this._nextState({ displayMonths: displayMonths });
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgbDatepickerService.prototype, "firstDayOfWeek", {
set: /**
* @param {?} firstDayOfWeek
* @return {?}
*/
function (firstDayOfWeek) {
firstDayOfWeek = toInteger(firstDayOfWeek);
if (isInteger(firstDayOfWeek) && firstDayOfWeek >= 0 && this._state.firstDayOfWeek !== firstDayOfWeek) {
this._nextState({ firstDayOfWeek: firstDayOfWeek });
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgbDatepickerService.prototype, "focusVisible", {
set: /**
* @param {?} focusVisible
* @return {?}
*/
function (focusVisible) {
if (this._state.focusVisible !== focusVisible && !this._state.disabled) {
this._nextState({ focusVisible: focusVisible });
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgbDatepickerService.prototype, "maxDate", {
set: /**
* @param {?} date
* @return {?}
*/
function (date) {
/** @type {?} */
var maxDate = this.toValidDate(date, null);
if (isChangedDate(this._state.maxDate, maxDate)) {
this._nextState({ maxDate: maxDate });
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgbDatepickerService.prototype, "markDisabled", {
set: /**
* @param {?} markDisabled
* @return {?}
*/
function (markDisabled) {
if (this._state.markDisabled !== markDisabled) {
this._nextState({ markDisabled: markDisabled });
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgbDatepickerService.prototype, "minDate", {
set: /**
* @param {?} date
* @return {?}
*/
function (date) {
/** @type {?} */
var minDate = this.toValidDate(date, null);
if (isChangedDate(this._state.minDate, minDate)) {
this._nextState({ minDate: minDate });
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgbDatepickerService.prototype, "navigation", {
set: /**
* @param {?} navigation
* @return {?}
*/
function (navigation) {
if (this._state.navigation !== navigation) {
this._nextState({ navigation: navigation });
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(NgbDatepickerService.prototype, "outsideDays", {
set: /**
* @param {?} outsideDays
* @return {?}
*/
function (outsideDays) {
if (this._state.outsideDays !== outsideDays) {
this._nextState({ outsideDays: outsideDays });
}
},
enumerable: true,
configurable: true
});
/**
* @param {?} date
* @return {?}
*/
NgbDatepickerService.prototype.focus = /**
* @param {?} date
* @return {?}
*/
function (date) {
if (!this._state.disabled && this._calendar.isValid(date) && isChangedDate(this._state.focusDate, date)) {
this._nextState({ focusDate: date });
}
};
/**
* @param {?=} period
* @param {?=} number
* @return {?}
*/
NgbDatepickerService.prototype.focusMove = /**
* @param {?=} period
* @param {?=} number
* @return {?}
*/
function (period, number) {
this.focus(this._calendar.getNext(this._state.focusDate, period, number));
};
/**
* @return {?}
*/
NgbDatepickerService.prototype.focusSelect = /**
* @return {?}
*/
function () {
if (isDateSelectable(this._state.focusDate, this._state)) {
this.select(this._state.focusDate, { emitEvent: true });
}
};
/**
* @param {?} date
* @return {?}
*/
NgbDatepickerService.prototype.open = /**
* @param {?} date
* @return {?}
*/
function (date) {
/** @type {?} */
var firstDate = this.toValidDate(date, this._calendar.getToday());
if (!this._state.disabled && (!this._state.firstDate || isChangedMonth(this._state.firstDate, date))) {
this._nextState({ firstDate: firstDate });
}
};
/**
* @param {?} date
* @param {?=} options
* @return {?}
*/
NgbDatepickerService.prototype.select = /**
* @param {?} date
* @param {?=} options
* @return {?}
*/
function (date, options) {
if (options === void 0) { options = {}; }
/** @type {?} */
var selectedDate = this.toValidDate(date, null);
if (!this._state.disabled) {
if (isChangedDate(this._state.selectedDate, selectedDate)) {
this._nextState({ selectedDate: selectedDate });
}
if (options.emitEvent && isDateSelectable(selectedDate, this._state)) {
this._select$.next(selectedDate);
}
}
};
/**
* @param {?} date
* @param {?=} defaultValue
* @return {?}
*/
NgbDatepickerService.prototype.toValidDate = /**
* @param {?} date
* @param {?=} defaultValue
* @return {?}
*/
function (date, defaultValue) {
/** @type {?} */
var ngbDate = NgbDate.from(date);
if (defaultValue === undefined) {
defaultValue = this._calendar.getToday();
}
return this._calendar.isValid(ngbDate) ? ngbDate : defaultValue;
};
/**
* @private
* @param {?} patch
* @return {?}
*/
NgbDatepickerService.prototype._nextState = /**
* @private
* @param {?} patch
* @return {?}
*/
function (patch) {
/** @type {?} */
var newState = this._updateState(patch);
this._patchContexts(newState);
this._state = newState;
this._model$.next(this._state);
};
/**
* @private
* @param {?} state
* @return {?}
*/
NgbDatepickerService.prototype._patchContexts = /**
* @private
* @param {?} state
* @return {?}
*/
function (state) {
var months = state.months, displayMonths = state.displayMonths, selectedDate = state.selectedDate, focusDate = state.focusDate, focusVisible = state.focusVisible, disabled = state.disabled, outsideDays = state.outsideDays;
state.months.forEach((/**
* @param {?} month
* @return {?}
*/
function (month) {
month.weeks.forEach((/**
* @param {?} week
* @return {?}
*/
function (week) {
week.days.forEach((/**
* @param {?} day
* @return {?}
*/
function (day) {
// patch focus flag
if (focusDate) {
day.context.focused = focusDate.equals(day.date) && focusVisible;
}
// calculating tabindex
day.tabindex = !disabled && day.date.equals(focusDate) && focusDate.month === month.number ? 0 : -1;
// override context disabled
if (disabled === true) {
day.context.disabled = true;
}
// patch selection flag
if (selectedDate !== undefined) {
day.context.selected = selectedDate !== null && selectedDate.equals(day.date);
}
// visibility
if (month.number !== day.date.month) {
day.hidden = outsideDays === 'hidden' || outsideDays === 'collapsed' ||
(displayMonths > 1 && day.date.after(months[0].firstDate) &&
day.date.before(months[displayMonths - 1].lastDate));
}
}));
}));
}));
};
/**
* @private
* @param {?} patch
* @return {?}
*/
NgbDatepickerService.prototype._updateState = /**
* @private
* @param {?} patch
* @return {?}
*/
function (patch) {
// patching fields
/** @type {?} */
var state = Object.assign({}, this._state, patch);
/** @type {?} */
var startDate = state.firstDate;
// min/max dates changed
if ('minDate' in patch || 'maxDate' in patch) {
checkMinBeforeMax(state.minDate, state.maxDate);
state.focusDate = checkDateInRange(state.focusDate, state.minDate, state.maxDate);
state.firstDate = checkDateInRange(state.firstDate, state.minDate, state.maxDate);
startDate = state.focusDate;
}
// disabled
if ('disabled' in patch) {
state.focusVisible = false;
}
// initial rebuild via 'select()'
if ('selectedDate' in patch && this._state.months.length === 0) {
startDate = state.selectedDate;
}
// terminate early if only focus visibility was changed
if ('focusVisible' in patch) {
return state;
}
// focus date changed
if ('focusDate' in patch) {
state.focusDate = checkDateInRange(state.focusDate, state.minDate, state.maxDate);
startDate = state.focusDate;
// nothing to rebuild if only focus changed and it is still visible
if (state.months.length !== 0 && !state.focusDate.before(state.firstDate) &&
!state.focusDate.after(state.lastDate)) {
return state;
}
}
// first date changed
if ('firstDate' in patch) {
state.firstDate = checkDateInRange(state.firstDate, state.minDate, state.maxDate);
startDate = state.firstDate;
}
// rebuilding months
if (startDate) {
/** @type {?} */
var forceRebuild = 'dayTemplateData' in patch || 'firstDayOfWeek' in patch || 'markDisabled' in patch ||
'minDate' in patch || 'maxDate' in patch || 'disabled' in patch || 'outsideDays' in patch;
/** @type {?} */
var months = buildMonths(this._calendar, startDate, state, this._i18n, forceRebuild);
// updating months and boundary dates
state.months = months;
state.firstDate = months.length > 0 ? months[0].firstDate : undefined;
state.lastDate = months.length > 0 ? months[months.length - 1].lastDate : undefined;
// reset selected date if 'markDisabled' returns true
if ('selectedDate' in patch && !isDateSelectable(state.selectedDate, state)) {
state.selectedDate = null;
}
// adjusting focus after months were built
if ('firstDate' in patch) {
if (state.focusDate === undefined || state.focusDate.before(state.firstDate) ||
state.focusDate.after(state.lastDate)) {
state.focusDate = startDate;
}
}
// adjusting months/years for the select box navigation
/** @type {?} */
var yearChanged = !this._state.firstDate || this._state.firstDate.year !== state.firstDate.year;
/** @type {?} */
var monthChanged = !this._state.firstDate || this._state.firstDate.month !== state.firstDate.month;
if (state.navigation === 'select') {
// years -> boundaries (min/max were changed)
if ('minDate' in patch || 'maxDate' in patch || state.selectBoxes.years.length === 0 || yearChanged) {
state.selectBoxes.years = generateSelectBoxYears(state.firstDate, state.minDate, state.maxDate);
}
// months -> when current year or boundaries change
if ('minDate' in patch || 'maxDate' in patch || state.selectBoxes.months.length === 0 || yearChanged) {
state.selectBoxes.months =
generateSelectBoxMonths(this._calendar, state.firstDate, state.minDate, state.maxDate);
}
}
else {
state.selectBoxes = { years: [], months: [] };
}
// updating navigation arrows -> boundaries change (min/max) or month/year changes
if ((state.navigation === 'arrows' || state.navigation === 'select') &&
(monthChanged || yearChanged || 'minDate' in patch || 'maxDate' in patch || 'disabled' in patch)) {
state.prevDisabled = state.disabled || prevMonthDisabled(this._calendar, state.firstDate, state.minDate);
state.nextDisabled = state.disabled || nextMonthDisabled(this._calendar, state.lastDate, state.maxDate);
}
}
return state;
};
NgbDatepickerService.decorators = [
{ type: core.Injectable }
];
/** @nocollapse */
NgbDatepickerService.ctorParameters = function () { return [
{ type: NgbCalendar },
{ type: NgbDatepickerI18n }
]; };
return NgbDatepickerService;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @enum {number} */
var Key = {
Tab: 9,
Enter: 13,
Escape: 27,
Space: 32,
PageUp: 33,
PageDown: 34,
End: 35,
Home: 36,
ArrowLeft: 37,
ArrowUp: 38,
ArrowRight: 39,
ArrowDown: 40,
};
Key[Key.Tab] = 'Tab';
Key[Key.Enter] = 'Enter';
Key[Key.Escape] = 'Escape';
Key[Key.Space] = 'Space';
Key[Key.PageUp] = 'PageUp';
Key[Key.PageDown] = 'PageDown';
Key[Key.End] = 'End';
Key[Key.Home] = 'Home';
Key[Key.ArrowLeft] = 'ArrowLeft';
Key[Key.ArrowUp] = 'ArrowUp';
Key[Key.ArrowRight] = 'ArrowRight';
Key[Key.ArrowDown] = 'ArrowDown';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NgbDatepickerKeyMapService = /** @class */ (function () {
function NgbDatepickerKeyMapService(_service, _calendar) {
var _this = this;
this._service = _service;
this._calendar = _calendar;
_service.model$.subscribe((/**
* @param {?} model
* @return {?}
*/
function (model) {
_this._minDate = model.minDate;
_this._maxDate = model.maxDate;
_this._firstViewDate = model.firstDate;
_this._lastViewDate = model.lastDate;
}));
}
/**
* @param {?} event
* @return {?}
*/
NgbDatepickerKeyMapService.prototype.processKey = /**
* @param {?} event
* @return {?}
*/
function (event) {
// tslint:disable-next-line:deprecation
switch (event.which) {
case Key.PageUp:
this._service.focusMove(event.shiftKey ? 'y' : 'm', -1);
break;
case Key.PageDown:
this._service.focusMove(event.shiftKey ? 'y' : 'm', 1);
break;
case Key.End:
this._service.focus(event.shiftKey ? this._maxDate : this._lastViewDate);
break;
case Key.Home:
this._service.focus(event.shiftKey ? this._minDate : this._firstViewDate);
break;
case Key.ArrowLeft:
this._service.focusMove('d', -1);
break;
case Key.ArrowUp:
this._service.focusMove('d', -this._calendar.getDaysPerWeek());
break;
case Key.ArrowRight:
this._service.focusMove('d', 1);
break;
case Key.ArrowDown:
this._service.focusMove('d', this._calendar.getDaysPerWeek());
break;
case Key.Enter:
case Key.Space:
this._service.focusSelect();
break;
default:
return;
}
// note 'return' in default case
event.preventDefault();
event.stopPropagation();
};
NgbDatepickerKeyMapService.decorators = [
{ type: core.Injectable }
];
/** @nocollapse */
NgbDatepickerKeyMapService.ctorParameters = function () { return [
{ type: NgbDatepickerService },
{ type: NgbCalendar }
]; };
return NgbDatepickerKeyMapService;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @enum {number} */
var NavigationEvent = {
PREV: 0,
NEXT: 1,
};
NavigationEvent[NavigationEvent.PREV] = 'PREV';
NavigationEvent[NavigationEvent.NEXT] = 'NEXT';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* A configuration service for the [`NgbDatepicker`](#/components/datepicker/api#NgbDatepicker) component.
*
* You can inject this service, typically in your root component, and customize the values of its properties in
* order to provide default values for all the datepickers used in the application.
*/
var NgbDatepickerConfig = /** @class */ (function () {
function NgbDatepickerConfig() {
this.displayMonths = 1;
this.firstDayOfWeek = 1;
this.navigation = 'select';
this.outsideDays = 'visible';
this.showWeekdays = true;
this.showWeekNumbers = false;
}
NgbDatepickerConfig.decorators = [
{ type: core.Injectable, args: [{ providedIn: 'root' },] }
];
/** @nocollapse */ NgbDatepickerConfig.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function NgbDatepickerConfig_Factory() { return new NgbDatepickerConfig(); }, token: NgbDatepickerConfig, providedIn: "root" });
return NgbDatepickerConfig;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @return {?}
*/
function NGB_DATEPICKER_DATE_ADAPTER_FACTORY() {
return new NgbDateStructAdapter();
}
/**
* An abstract service that does the conversion between the internal datepicker `NgbDateStruct` model and
* any provided user date model `D`, ex. a string, a native date, etc.
*
* The adapter is used **only** for conversion when binding datepicker to a form control,
* ex. `[(ngModel)]="userDateModel"`. Here `userDateModel` can be of any type.
*
* The default datepicker implementation assumes we use `NgbDateStruct` as a user model.
*
* See the [date format overview](#/components/datepicker/overview#date-model) for more details
* and the [custom adapter demo](#/components/datepicker/examples#adapter) for an example.
* @abstract
* @template D
*/
var NgbDateAdapter = /** @class */ (function () {
function NgbDateAdapter() {
}
NgbDateAdapter.decorators = [
{ type: core.Injectable, args: [{ providedIn: 'root', useFactory: NGB_DATEPICKER_DATE_ADAPTER_FACTORY },] }
];
/** @nocollapse */ NgbDateAdapter.ngInjectableDef = core.ɵɵdefineInjectable({ factory: NGB_DATEPICKER_DATE_ADAPTER_FACTORY, token: NgbDateAdapter, providedIn: "root" });
return NgbDateAdapter;
}());
var NgbDateStructAdapter = /** @class */ (function (_super) {
__extends(NgbDateStructAdapter, _super);
function NgbDateStructAdapter() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* Converts a NgbDateStruct value into NgbDateStruct value
*/
/**
* Converts a NgbDateStruct value into NgbDateStruct value
* @param {?} date
* @return {?}
*/
NgbDateStructAdapter.prototype.fromModel = /**
* Converts a NgbDateStruct value into NgbDateStruct value
* @param {?} date
* @return {?}
*/
function (date) {
return (date && isInteger(date.year) && isInteger(date.month) && isInteger(date.day)) ?
{ year: date.year, month: date.month, day: date.day } :
null;
};
/**
* Converts a NgbDateStruct value into NgbDateStruct value
*/
/**
* Converts a NgbDateStruct value into NgbDateStruct value
* @param {?} date
* @return {?}
*/
NgbDateStructAdapter.prototype.toModel = /**
* Converts a NgbDateStruct value into NgbDateStruct value
* @param {?} date
* @return {?}
*/
function (date) {
return (date && isInteger(date.year) && isInteger(date.month) && isInteger(date.day)) ?
{ year: date.year, month: date.month, day: date.day } :
null;
};
NgbDateStructAdapter.decorators = [
{ type: core.Injectable }
];
return NgbDateStructAdapter;
}(NgbDateAdapter));
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var NGB_DATEPICKER_VALUE_ACCESSOR = {
provide: forms.NG_VALUE_ACCESSOR,
useExisting: core.forwardRef((/**
* @return {?}
*/
function () { return NgbDatepicker; })),
multi: true
};
/**
* A highly configurable component that helps you with selecting calendar dates.
*
* `NgbDatepicker` is meant to be displayed inline on a page or put inside a popup.
*/
var NgbDatepicker = /** @class */ (function () {
function NgbDatepicker(_keyMapService, _service, _calendar, i18n, config, _cd, _elementRef, _ngbDateAdapter, _ngZone) {
var _this = this;
this._keyMapService = _keyMapService;
this._service = _service;
this._calendar = _calendar;
this.i18n = i18n;
this._cd = _cd;
this._elementRef = _elementRef;
this._ngbDateAdapter = _ngbDateAdapter;
this._ngZone = _ngZone;
this._destroyed$ = new rxjs.Subject();
/**
* An event emitted right before the navigation happens and displayed month changes.
*
* See [`NgbDatepickerNavigateEvent`](#/components/datepicker/api#NgbDatepickerNavigateEvent) for the payload info.
*/
this.navigate = new core.EventEmitter();
/**
* An event emitted when user selects a date using keyboard or mouse.
*
* The payload of the event is currently selected `NgbDate`.
*/
this.select = new core.EventEmitter();
this.onChange = (/**
* @param {?} _
* @return {?}
*/
function (_) { });
this.onTouched = (/**
* @return {?}
*/
function () { });
['dayTemplate', 'dayTemplateData', 'displayMonths', 'firstDayOfWeek', 'footerTemplate', 'markDisabled', 'minDate',
'maxDate', 'navigation', 'outsideDays', 'showWeekdays', 'showWeekNumbers', 'startDate']
.forEach((/**
* @param {?} input
* @return {?}
*/
function (input) { return _this[input] = config[input]; }));
_service.select$.pipe(operators.takeUntil(this._destroyed$)).subscribe((/**
* @param {?} date
* @return {?}
*/
function (date) { _this.select.emit(date); }));
_service.model$.pipe(operators.takeUntil(this._destroyed$)).subscribe((/**
* @param {?} model
* @return {?}
*/
function (model) {
/** @type {?} */
var newDate = model.firstDate;
/** @type {?} */
var oldDate = _this.model ? _this.model.firstDate : null;
/** @type {?} */
var navigationPrevented = false;
// emitting navigation event if the first month changes
if (!newDate.equals(oldDate)) {
_this.navigate.emit({
current: oldDate ? { year: oldDate.year, month: oldDate.month } : null,
next: { year: newDate.year, month: newDate.month },
preventDefault: (/**
* @return {?}
*/
function () { return navigationPrevented = true; })
});
// can't prevent the very first navigation
if (navigationPrevented && oldDate !== null) {
_this._service.open(oldDate);
return;
}
}
/** @type {?} */
var newSelectedDate = model.selectedDate;
/** @type {?} */
var newFocusedDate = model.focusDate;
/** @type {?} */
var oldFocusedDate = _this.model ? _this.model.focusDate : null;
_this.model = model;
// handling selection change
if (isChangedDate(newSelectedDate, _this._controlValue)) {
_this._controlValue = newSelectedDate;
_this.onTouched();
_this.onChange(_this._ngbDateAdapter.toModel(newSelectedDate));
}
// handling focus change
if (isChangedDate(newFocusedDate, oldFocusedDate) && oldFocusedDate && model.focusVisible) {
_this.focus();
}
_cd.markForCheck();
}));
}
/**
* @return {?}
*/
NgbDatepicker.prototype.focus = /**
* @return {?}
*/
function () {
var _this = this;
this._ngZone.onStable.asObservable().pipe(operators.take(1)).subscribe((/**
* @return {?}
*/
function () {
/** @type {?} */
var elementToFocus = _this._elementRef.nativeElement.querySelector('div.ngb-dp-day[tabindex="0"]');
if (elementToFocus) {
elementToFocus.focus();
}
}));
};
/**
* Navigates to the provided date.
*
* With the default calendar we use ISO 8601: 'month' is 1=Jan ... 12=Dec.
* If nothing or invalid date provided calendar will open current month.
*
* Use the `[startDate]` input as an alternative.
*/
/**
* Navigates to the provided date.
*
* With the default calendar we use ISO 8601: 'month' is 1=Jan ... 12=Dec.
* If nothing or invalid date provided calendar will open current month.
*
* Use the `[startDate]` input as an alternative.
* @param {?=} date
* @return {?}
*/
NgbDatepicker.prototype.navigateTo = /**
* Navigates to the provided date.
*
* With the default calendar we use ISO 8601: 'month' is 1=Jan ... 12=Dec.
* If nothing or invalid date provided calendar will open current month.
*
* Use the `[startDate]` input as an alternative.
* @param {?=} date
* @return {?}
*/
function (date) {
this._service.open(NgbDate.from(date ? date.day ? (/** @type {?} */ (date)) : __assign({}, date, { day: 1 }) : null));
};
/**
* @return {?}
*/
NgbDatepicker.prototype.ngAfterViewInit = /**
* @return {?}
*/
function () {
var _this = this;
this._ngZone.runOutsideAngular((/**
* @return {?}
*/
function () {
/** @type {?} */
var focusIns$ = rxjs.fromEvent(_this._monthsEl.nativeElement, 'focusin');
/** @type {?} */
var focusOuts$ = rxjs.fromEvent(_this._monthsEl.nativeElement, 'focusout');
// we're changing 'focusVisible' only when entering or leaving months view
// and ignoring all focus events where both 'target' and 'related' target are day cells
rxjs.merge(focusIns$, focusOuts$)
.pipe(operators.filter((/**
* @param {?} __0
* @return {?}
*/
function (_a) {
var target = _a.target, relatedTarget = _a.relatedTarget;
return !(hasClassName(target, 'ngb-dp-day') && hasClassName(relatedTarget, 'ngb-dp-day'));
})), operators.takeUntil(_this._destroyed$))
.subscribe((/**
* @param {?} __0
* @return {?}
*/
function (_a) {
var type = _a.type;
return _this._ngZone.run((/**
* @return {?}
*/
function () { return _this._service.focusVisible = type === 'focusin'; }));
}));
}));
};
/**
* @return {?}
*/
NgbDatepicker.prototype.ngOnDestroy = /**
* @return {?}
*/
function () { this._destroyed$.next(); };
/**
* @return {?}
*/
NgbDatepicker.prototype.ngOnInit = /**
* @return {?}
*/
function () {
var _this = this;
if (this.model === undefined) {
['dayTemplateData', 'displayMonths', 'markDisabled', 'firstDayOfWeek', 'navigation', 'minDate', 'maxDate',
'outsideDays']
.forEach((/**
* @param {?} input
* @return {?}
*/
function (input) { return _this._service[input] = _this[input]; }));
this.navigateTo(this.startDate);
}
};
/**
* @param {?} changes
* @return {?}
*/
NgbDatepicker.prototype.ngOnChanges = /**
* @param {?} changes
* @return {?}
*/
function (changes) {
var _this = this;
['dayTemplateData', 'displayMonths', 'markDisabled', 'firstDayOfWeek', 'navigation', 'minDate', 'maxDate',
'outsideDays']
.filter((/**
* @param {?} input
* @return {?}
*/
function (input) { return input in changes; }))
.forEach((/**
* @param {?} input
* @return {?}
*/
function (input) { return _this._service[input] = _this[input]; }));
if ('startDate' in changes) {
var _a = changes.startDate, currentValue = _a.currentValue, previousValue = _a.previousValue;
if (isChangedMonth(previousValue, currentValue)) {
this.navigateTo(this.startDate);
}
}
};
/**
* @param {?} date
* @return {?}
*/
NgbDatepicker.prototype.onDateSelect = /**
* @param {?} date
* @return {?}
*/
function (date) {
this._service.focus(date);
this._service.select(date, { emitEvent: true });
};
/**
* @param {?} event
* @return {?}
*/
NgbDatepicker.prototype.onKeyDown = /**
* @param {?} event
* @return {?}
*/
function (event) { this._keyMapService.processKey(event); };
/**
* @param {?} date
* @return {?}
*/
NgbDatepicker.prototype.onNavigateDateSelect = /**
* @param {?} date
* @return {?}
*/
function (date) { this._service.open(date); };
/**
* @param {?} event
* @return {?}
*/
NgbDatepicker.prototype.onNavigateEvent = /**
* @param {?} event
* @return {?}
*/
function (event) {
switch (event) {
case NavigationEvent.PREV:
this._service.open(this._calendar.getPrev(this.model.firstDate, 'm', 1));
break;
case NavigationEvent.NEXT:
this._service.open(this._calendar.getNext(this.model.firstDate, 'm', 1));
break;
}
};
/**
* @param {?} fn
* @return {?}
*/
NgbDatepicker.prototype.registerOnChange = /**
* @param {?} fn
* @return {?}
*/
function (fn) { this.onChange = fn; };
/**
* @param {?} fn
* @return {?}
*/
NgbDatepicker.prototype.registerOnTouched = /**
* @param {?} fn
* @return {?}
*/
function (fn) { this.onTouched = fn; };
/**
* @param {?} isDisabled
* @return {?}
*/
NgbDatepicker.prototype.setDisabledState = /**
* @param {?} isDisabled
* @return {?}
*/
function (isDisabled) { this._service.disabled = isDisabled; };
/**
* @param {?} value
* @return {?}
*/
NgbDatepicker.prototype.writeValue = /**
* @param {?} value
* @return {?}
*/
function (value) {
this._controlValue = NgbDate.from(this._ngbDateAdapter.fromModel(value));
this._service.select(this._controlValue);
};
NgbDatepicker.decorators = [
{ type: core.Component, args: [{
exportAs: 'ngbDatepicker',
selector: 'ngb-datepicker',
changeDetection: core.ChangeDetectionStrategy.OnPush,
encapsulation: core.ViewEncapsulation.None,
template: "\n \n
",
styles: ["ngb-popover-window.bs-popover-bottom .arrow,ngb-popover-window.bs-popover-top .arrow{left:50%;margin-left:-.5rem}ngb-popover-window.bs-popover-bottom-left .arrow,ngb-popover-window.bs-popover-top-left .arrow{left:2em}ngb-popover-window.bs-popover-bottom-right .arrow,ngb-popover-window.bs-popover-top-right .arrow{left:auto;right:2em}ngb-popover-window.bs-popover-left .arrow,ngb-popover-window.bs-popover-right .arrow{top:50%;margin-top:-.5rem}ngb-popover-window.bs-popover-left-top .arrow,ngb-popover-window.bs-popover-right-top .arrow{top:.7em}ngb-popover-window.bs-popover-left-bottom .arrow,ngb-popover-window.bs-popover-right-bottom .arrow{top:auto;bottom:.7em}"]
}] }
];
NgbPopoverWindow.propDecorators = {
title: [{ type: core.Input }],
id: [{ type: core.Input }],
popoverClass: [{ type: core.Input }],
context: [{ type: core.Input }]
};
return NgbPopoverWindow;
}());
/**
* A lightweight and extensible directive for fancy popover creation.
*/
var NgbPopover = /** @class */ (function () {
function NgbPopover(_elementRef, _renderer, injector, componentFactoryResolver, viewContainerRef, config, _ngZone, _document, _changeDetector, _applicationRef) {
var _this = this;
this._elementRef = _elementRef;
this._renderer = _renderer;
this._ngZone = _ngZone;
this._document = _document;
this._changeDetector = _changeDetector;
this._applicationRef = _applicationRef;
/**
* An event emitted when the popover is shown. Contains no payload.
*/
this.shown = new core.EventEmitter();
/**
* An event emitted when the popover is hidden. Contains no payload.
*/
this.hidden = new core.EventEmitter();
this._ngbPopoverWindowId = "ngb-popover-" + nextId$3++;
this.autoClose = config.autoClose;
this.placement = config.placement;
this.triggers = config.triggers;
this.container = config.container;
this.disablePopover = config.disablePopover;
this.popoverClass = config.popoverClass;
this.openDelay = config.openDelay;
this.closeDelay = config.closeDelay;
this._popupService = new PopupService(NgbPopoverWindow, injector, viewContainerRef, _renderer, componentFactoryResolver, _applicationRef);
this._zoneSubscription = _ngZone.onStable.subscribe((/**
* @return {?}
*/
function () {
if (_this._windowRef) {
positionElements(_this._elementRef.nativeElement, _this._windowRef.location.nativeElement, _this.placement, _this.container === 'body', 'bs-popover');
}
}));
}
/**
* @private
* @return {?}
*/
NgbPopover.prototype._isDisabled = /**
* @private
* @return {?}
*/
function () {
if (this.disablePopover) {
return true;
}
if (!this.ngbPopover && !this.popoverTitle) {
return true;
}
return false;
};
/**
* Opens the popover.
*
* This is considered to be a "manual" triggering.
* The `context` is an optional value to be injected into the popover template when it is created.
*/
/**
* Opens the popover.
*
* This is considered to be a "manual" triggering.
* The `context` is an optional value to be injected into the popover template when it is created.
* @param {?=} context
* @return {?}
*/
NgbPopover.prototype.open = /**
* Opens the popover.
*
* This is considered to be a "manual" triggering.
* The `context` is an optional value to be injected into the popover template when it is created.
* @param {?=} context
* @return {?}
*/
function (context) {
var _this = this;
if (!this._windowRef && !this._isDisabled()) {
this._windowRef = this._popupService.open(this.ngbPopover, context);
this._windowRef.instance.title = this.popoverTitle;
this._windowRef.instance.context = context;
this._windowRef.instance.popoverClass = this.popoverClass;
this._windowRef.instance.id = this._ngbPopoverWindowId;
this._renderer.setAttribute(this._elementRef.nativeElement, 'aria-describedby', this._ngbPopoverWindowId);
if (this.container === 'body') {
this._document.querySelector(this.container).appendChild(this._windowRef.location.nativeElement);
}
// We need to detect changes, because we don't know where .open() might be called from.
// Ex. opening popover from one of lifecycle hooks that run after the CD
// (say from ngAfterViewInit) will result in 'ExpressionHasChanged' exception
this._windowRef.changeDetectorRef.detectChanges();
// We need to mark for check, because popover won't work inside the OnPush component.
// Ex. when we use expression like `{{ popover.isOpen() : 'opened' : 'closed' }}`
// inside the template of an OnPush component and we change the popover from
// open -> closed, the expression in question won't be updated unless we explicitly
// mark the parent component to be checked.
this._windowRef.changeDetectorRef.markForCheck();
ngbAutoClose(this._ngZone, this._document, this.autoClose, (/**
* @return {?}
*/
function () { return _this.close(); }), this.hidden, [this._windowRef.location.nativeElement]);
this.shown.emit();
}
};
/**
* Closes the popover.
*
* This is considered to be a "manual" triggering of the popover.
*/
/**
* Closes the popover.
*
* This is considered to be a "manual" triggering of the popover.
* @return {?}
*/
NgbPopover.prototype.close = /**
* Closes the popover.
*
* This is considered to be a "manual" triggering of the popover.
* @return {?}
*/
function () {
if (this._windowRef) {
this._renderer.removeAttribute(this._elementRef.nativeElement, 'aria-describedby');
this._popupService.close();
this._windowRef = null;
this.hidden.emit();
this._changeDetector.markForCheck();
}
};
/**
* Toggles the popover.
*
* This is considered to be a "manual" triggering of the popover.
*/
/**
* Toggles the popover.
*
* This is considered to be a "manual" triggering of the popover.
* @return {?}
*/
NgbPopover.prototype.toggle = /**
* Toggles the popover.
*
* This is considered to be a "manual" triggering of the popover.
* @return {?}
*/
function () {
if (this._windowRef) {
this.close();
}
else {
this.open();
}
};
/**
* Returns `true`, if the popover is currently shown.
*/
/**
* Returns `true`, if the popover is currently shown.
* @return {?}
*/
NgbPopover.prototype.isOpen = /**
* Returns `true`, if the popover is currently shown.
* @return {?}
*/
function () { return this._windowRef != null; };
/**
* @return {?}
*/
NgbPopover.prototype.ngOnInit = /**
* @return {?}
*/
function () {
this._unregisterListenersFn = listenToTriggers(this._renderer, this._elementRef.nativeElement, this.triggers, this.isOpen.bind(this), this.open.bind(this), this.close.bind(this), +this.openDelay, +this.closeDelay);
};
/**
* @param {?} changes
* @return {?}
*/
NgbPopover.prototype.ngOnChanges = /**
* @param {?} changes
* @return {?}
*/
function (changes) {
// close popover if title and content become empty, or disablePopover set to true
if ((changes['ngbPopover'] || changes['popoverTitle'] || changes['disablePopover']) && this._isDisabled()) {
this.close();
}
};
/**
* @return {?}
*/
NgbPopover.prototype.ngOnDestroy = /**
* @return {?}
*/
function () {
this.close();
// This check is needed as it might happen that ngOnDestroy is called before ngOnInit
// under certain conditions, see: https://github.com/ng-bootstrap/ng-bootstrap/issues/2199
if (this._unregisterListenersFn) {
this._unregisterListenersFn();
}
this._zoneSubscription.unsubscribe();
};
NgbPopover.decorators = [
{ type: core.Directive, args: [{ selector: '[ngbPopover]', exportAs: 'ngbPopover' },] }
];
/** @nocollapse */
NgbPopover.ctorParameters = function () { return [
{ type: core.ElementRef },
{ type: core.Renderer2 },
{ type: core.Injector },
{ type: core.ComponentFactoryResolver },
{ type: core.ViewContainerRef },
{ type: NgbPopoverConfig },
{ type: core.NgZone },
{ type: undefined, decorators: [{ type: core.Inject, args: [common.DOCUMENT,] }] },
{ type: core.ChangeDetectorRef },
{ type: core.ApplicationRef }
]; };
NgbPopover.propDecorators = {
autoClose: [{ type: core.Input }],
ngbPopover: [{ type: core.Input }],
popoverTitle: [{ type: core.Input }],
placement: [{ type: core.Input }],
triggers: [{ type: core.Input }],
container: [{ type: core.Input }],
disablePopover: [{ type: core.Input }],
popoverClass: [{ type: core.Input }],
openDelay: [{ type: core.Input }],
closeDelay: [{ type: core.Input }],
shown: [{ type: core.Output }],
hidden: [{ type: core.Output }]
};
return NgbPopover;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NgbPopoverModule = /** @class */ (function () {
function NgbPopoverModule() {
}
NgbPopoverModule.decorators = [
{ type: core.NgModule, args: [{
declarations: [NgbPopover, NgbPopoverWindow],
exports: [NgbPopover],
imports: [common.CommonModule],
entryComponents: [NgbPopoverWindow]
},] }
];
return NgbPopoverModule;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* A configuration service for the [`NgbProgressbar`](#/components/progressbar/api#NgbProgressbar) component.
*
* You can inject this service, typically in your root component, and customize the values of its properties in
* order to provide default values for all the progress bars used in the application.
*/
var NgbProgressbarConfig = /** @class */ (function () {
function NgbProgressbarConfig() {
this.max = 100;
this.animated = false;
this.striped = false;
this.showValue = false;
}
NgbProgressbarConfig.decorators = [
{ type: core.Injectable, args: [{ providedIn: 'root' },] }
];
/** @nocollapse */ NgbProgressbarConfig.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function NgbProgressbarConfig_Factory() { return new NgbProgressbarConfig(); }, token: NgbProgressbarConfig, providedIn: "root" });
return NgbProgressbarConfig;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* A directive that provides feedback on the progress of a workflow or an action.
*/
var NgbProgressbar = /** @class */ (function () {
function NgbProgressbar(config) {
/**
* The current value for the progress bar.
*
* Should be in the `[0, max]` range.
*/
this.value = 0;
this.max = config.max;
this.animated = config.animated;
this.striped = config.striped;
this.type = config.type;
this.showValue = config.showValue;
this.height = config.height;
}
/**
* @return {?}
*/
NgbProgressbar.prototype.getValue = /**
* @return {?}
*/
function () { return getValueInRange(this.value, this.max); };
/**
* @return {?}
*/
NgbProgressbar.prototype.getPercentValue = /**
* @return {?}
*/
function () { return 100 * this.getValue() / this.max; };
NgbProgressbar.decorators = [
{ type: core.Component, args: [{
selector: 'ngb-progressbar',
changeDetection: core.ChangeDetectionStrategy.OnPush,
template: "\n
\n
\n {{getPercentValue()}}%\n
\n
\n "
}] }
];
/** @nocollapse */
NgbProgressbar.ctorParameters = function () { return [
{ type: NgbProgressbarConfig }
]; };
NgbProgressbar.propDecorators = {
max: [{ type: core.Input }],
animated: [{ type: core.Input }],
striped: [{ type: core.Input }],
showValue: [{ type: core.Input }],
type: [{ type: core.Input }],
value: [{ type: core.Input }],
height: [{ type: core.Input }]
};
return NgbProgressbar;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NgbProgressbarModule = /** @class */ (function () {
function NgbProgressbarModule() {
}
NgbProgressbarModule.decorators = [
{ type: core.NgModule, args: [{ declarations: [NgbProgressbar], exports: [NgbProgressbar], imports: [common.CommonModule] },] }
];
return NgbProgressbarModule;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* A configuration service for the [`NgbRating`](#/components/rating/api#NgbRating) component.
*
* You can inject this service, typically in your root component, and customize the values of its properties in
* order to provide default values for all the ratings used in the application.
*/
var NgbRatingConfig = /** @class */ (function () {
function NgbRatingConfig() {
this.max = 10;
this.readonly = false;
this.resettable = false;
}
NgbRatingConfig.decorators = [
{ type: core.Injectable, args: [{ providedIn: 'root' },] }
];
/** @nocollapse */ NgbRatingConfig.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function NgbRatingConfig_Factory() { return new NgbRatingConfig(); }, token: NgbRatingConfig, providedIn: "root" });
return NgbRatingConfig;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var NGB_RATING_VALUE_ACCESSOR = {
provide: forms.NG_VALUE_ACCESSOR,
useExisting: core.forwardRef((/**
* @return {?}
*/
function () { return NgbRating; })),
multi: true
};
/**
* A directive that helps visualising and interacting with a star rating bar.
*/
var NgbRating = /** @class */ (function () {
function NgbRating(config, _changeDetectorRef) {
this._changeDetectorRef = _changeDetectorRef;
this.contexts = [];
this.disabled = false;
/**
* An event emitted when the user is hovering over a given rating.
*
* Event payload equals to the rating being hovered over.
*/
this.hover = new core.EventEmitter();
/**
* An event emitted when the user stops hovering over a given rating.
*
* Event payload equals to the rating of the last item being hovered over.
*/
this.leave = new core.EventEmitter();
/**
* An event emitted when the user selects a new rating.
*
* Event payload equals to the newly selected rating.
*/
this.rateChange = new core.EventEmitter(true);
this.onChange = (/**
* @param {?} _
* @return {?}
*/
function (_) { });
this.onTouched = (/**
* @return {?}
*/
function () { });
this.max = config.max;
this.readonly = config.readonly;
}
/**
* @return {?}
*/
NgbRating.prototype.ariaValueText = /**
* @return {?}
*/
function () { return this.nextRate + " out of " + this.max; };
/**
* @param {?} value
* @return {?}
*/
NgbRating.prototype.enter = /**
* @param {?} value
* @return {?}
*/
function (value) {
if (!this.readonly && !this.disabled) {
this._updateState(value);
}
this.hover.emit(value);
};
/**
* @return {?}
*/
NgbRating.prototype.handleBlur = /**
* @return {?}
*/
function () { this.onTouched(); };
/**
* @param {?} value
* @return {?}
*/
NgbRating.prototype.handleClick = /**
* @param {?} value
* @return {?}
*/
function (value) { this.update(this.resettable && this.rate === value ? 0 : value); };
/**
* @param {?} event
* @return {?}
*/
NgbRating.prototype.handleKeyDown = /**
* @param {?} event
* @return {?}
*/
function (event) {
// tslint:disable-next-line:deprecation
switch (event.which) {
case Key.ArrowDown:
case Key.ArrowLeft:
this.update(this.rate - 1);
break;
case Key.ArrowUp:
case Key.ArrowRight:
this.update(this.rate + 1);
break;
case Key.Home:
this.update(0);
break;
case Key.End:
this.update(this.max);
break;
default:
return;
}
// note 'return' in default case
event.preventDefault();
};
/**
* @param {?} changes
* @return {?}
*/
NgbRating.prototype.ngOnChanges = /**
* @param {?} changes
* @return {?}
*/
function (changes) {
if (changes['rate']) {
this.update(this.rate);
}
};
/**
* @return {?}
*/
NgbRating.prototype.ngOnInit = /**
* @return {?}
*/
function () {
this.contexts = Array.from({ length: this.max }, (/**
* @param {?} v
* @param {?} k
* @return {?}
*/
function (v, k) { return ({ fill: 0, index: k }); }));
this._updateState(this.rate);
};
/**
* @param {?} fn
* @return {?}
*/
NgbRating.prototype.registerOnChange = /**
* @param {?} fn
* @return {?}
*/
function (fn) { this.onChange = fn; };
/**
* @param {?} fn
* @return {?}
*/
NgbRating.prototype.registerOnTouched = /**
* @param {?} fn
* @return {?}
*/
function (fn) { this.onTouched = fn; };
/**
* @return {?}
*/
NgbRating.prototype.reset = /**
* @return {?}
*/
function () {
this.leave.emit(this.nextRate);
this._updateState(this.rate);
};
/**
* @param {?} isDisabled
* @return {?}
*/
NgbRating.prototype.setDisabledState = /**
* @param {?} isDisabled
* @return {?}
*/
function (isDisabled) { this.disabled = isDisabled; };
/**
* @param {?} value
* @param {?=} internalChange
* @return {?}
*/
NgbRating.prototype.update = /**
* @param {?} value
* @param {?=} internalChange
* @return {?}
*/
function (value, internalChange) {
if (internalChange === void 0) { internalChange = true; }
/** @type {?} */
var newRate = getValueInRange(value, this.max, 0);
if (!this.readonly && !this.disabled && this.rate !== newRate) {
this.rate = newRate;
this.rateChange.emit(this.rate);
}
if (internalChange) {
this.onChange(this.rate);
this.onTouched();
}
this._updateState(this.rate);
};
/**
* @param {?} value
* @return {?}
*/
NgbRating.prototype.writeValue = /**
* @param {?} value
* @return {?}
*/
function (value) {
this.update(value, false);
this._changeDetectorRef.markForCheck();
};
/**
* @private
* @param {?} index
* @return {?}
*/
NgbRating.prototype._getFillValue = /**
* @private
* @param {?} index
* @return {?}
*/
function (index) {
/** @type {?} */
var diff = this.nextRate - index;
if (diff >= 1) {
return 100;
}
if (diff < 1 && diff > 0) {
return parseInt((diff * 100).toFixed(2), 10);
}
return 0;
};
/**
* @private
* @param {?} nextValue
* @return {?}
*/
NgbRating.prototype._updateState = /**
* @private
* @param {?} nextValue
* @return {?}
*/
function (nextValue) {
var _this = this;
this.nextRate = nextValue;
this.contexts.forEach((/**
* @param {?} context
* @param {?} index
* @return {?}
*/
function (context, index) { return context.fill = _this._getFillValue(index); }));
};
NgbRating.decorators = [
{ type: core.Component, args: [{
selector: 'ngb-rating',
changeDetection: core.ChangeDetectionStrategy.OnPush,
host: {
'class': 'd-inline-flex',
'tabindex': '0',
'role': 'slider',
'aria-valuemin': '0',
'[attr.aria-valuemax]': 'max',
'[attr.aria-valuenow]': 'nextRate',
'[attr.aria-valuetext]': 'ariaValueText()',
'[attr.aria-disabled]': 'readonly ? true : null',
'(blur)': 'handleBlur()',
'(keydown)': 'handleKeyDown($event)',
'(mouseleave)': 'reset()'
},
template: "\n {{ fill === 100 ? '★' : '☆' }}\n \n ({{ index < nextRate ? '*' : ' ' }})\n \n \n \n \n \n ",
providers: [NGB_RATING_VALUE_ACCESSOR]
}] }
];
/** @nocollapse */
NgbRating.ctorParameters = function () { return [
{ type: NgbRatingConfig },
{ type: core.ChangeDetectorRef }
]; };
NgbRating.propDecorators = {
max: [{ type: core.Input }],
rate: [{ type: core.Input }],
readonly: [{ type: core.Input }],
resettable: [{ type: core.Input }],
starTemplate: [{ type: core.Input }],
starTemplateFromContent: [{ type: core.ContentChild, args: [core.TemplateRef, { static: false },] }],
hover: [{ type: core.Output }],
leave: [{ type: core.Output }],
rateChange: [{ type: core.Output }]
};
return NgbRating;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NgbRatingModule = /** @class */ (function () {
function NgbRatingModule() {
}
NgbRatingModule.decorators = [
{ type: core.NgModule, args: [{ declarations: [NgbRating], exports: [NgbRating], imports: [common.CommonModule] },] }
];
return NgbRatingModule;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* A configuration service for the [`NgbTabset`](#/components/tabset/api#NgbTabset) component.
*
* You can inject this service, typically in your root component, and customize the values of its properties in
* order to provide default values for all the tabsets used in the application.
*/
var NgbTabsetConfig = /** @class */ (function () {
function NgbTabsetConfig() {
this.justify = 'start';
this.orientation = 'horizontal';
this.type = 'tabs';
}
NgbTabsetConfig.decorators = [
{ type: core.Injectable, args: [{ providedIn: 'root' },] }
];
/** @nocollapse */ NgbTabsetConfig.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function NgbTabsetConfig_Factory() { return new NgbTabsetConfig(); }, token: NgbTabsetConfig, providedIn: "root" });
return NgbTabsetConfig;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var nextId$4 = 0;
/**
* A directive to wrap tab titles that need to contain HTML markup or other directives.
*
* Alternatively you could use the `NgbTab.title` input for string titles.
*/
var NgbTabTitle = /** @class */ (function () {
function NgbTabTitle(templateRef) {
this.templateRef = templateRef;
}
NgbTabTitle.decorators = [
{ type: core.Directive, args: [{ selector: 'ng-template[ngbTabTitle]' },] }
];
/** @nocollapse */
NgbTabTitle.ctorParameters = function () { return [
{ type: core.TemplateRef }
]; };
return NgbTabTitle;
}());
/**
* A directive to wrap content to be displayed in a tab.
*/
var NgbTabContent = /** @class */ (function () {
function NgbTabContent(templateRef) {
this.templateRef = templateRef;
}
NgbTabContent.decorators = [
{ type: core.Directive, args: [{ selector: 'ng-template[ngbTabContent]' },] }
];
/** @nocollapse */
NgbTabContent.ctorParameters = function () { return [
{ type: core.TemplateRef }
]; };
return NgbTabContent;
}());
/**
* A directive representing an individual tab.
*/
var NgbTab = /** @class */ (function () {
function NgbTab() {
/**
* The tab identifier.
*
* Must be unique for the entire document for proper accessibility support.
*/
this.id = "ngb-tab-" + nextId$4++;
/**
* If `true`, the current tab is disabled and can't be toggled.
*/
this.disabled = false;
}
/**
* @return {?}
*/
NgbTab.prototype.ngAfterContentChecked = /**
* @return {?}
*/
function () {
// We are using @ContentChildren instead of @ContentChild as in the Angular version being used
// only @ContentChildren allows us to specify the {descendants: false} option.
// Without {descendants: false} we are hitting bugs described in:
// https://github.com/ng-bootstrap/ng-bootstrap/issues/2240
this.titleTpl = this.titleTpls.first;
this.contentTpl = this.contentTpls.first;
};
NgbTab.decorators = [
{ type: core.Directive, args: [{ selector: 'ngb-tab' },] }
];
NgbTab.propDecorators = {
id: [{ type: core.Input }],
title: [{ type: core.Input }],
disabled: [{ type: core.Input }],
titleTpls: [{ type: core.ContentChildren, args: [NgbTabTitle, { descendants: false },] }],
contentTpls: [{ type: core.ContentChildren, args: [NgbTabContent, { descendants: false },] }]
};
return NgbTab;
}());
/**
* A component that makes it easy to create tabbed interface.
*/
var NgbTabset = /** @class */ (function () {
function NgbTabset(config) {
/**
* If `true`, non-visible tabs content will be removed from DOM. Otherwise it will just be hidden.
*/
this.destroyOnHide = true;
/**
* A tab change event emitted right before the tab change happens.
*
* See [`NgbTabChangeEvent`](#/components/tabset/api#NgbTabChangeEvent) for payload details.
*/
this.tabChange = new core.EventEmitter();
this.type = config.type;
this.justify = config.justify;
this.orientation = config.orientation;
}
Object.defineProperty(NgbTabset.prototype, "justify", {
/**
* The horizontal alignment of the tabs with flexbox utilities.
*/
set: /**
* The horizontal alignment of the tabs with flexbox utilities.
* @param {?} className
* @return {?}
*/
function (className) {
if (className === 'fill' || className === 'justified') {
this.justifyClass = "nav-" + className;
}
else {
this.justifyClass = "justify-content-" + className;
}
},
enumerable: true,
configurable: true
});
/**
* Selects the tab with the given id and shows its associated content panel.
*
* Any other tab that was previously selected becomes unselected and its associated pane is removed from DOM or
* hidden depending on the `destroyOnHide` value.
*/
/**
* Selects the tab with the given id and shows its associated content panel.
*
* Any other tab that was previously selected becomes unselected and its associated pane is removed from DOM or
* hidden depending on the `destroyOnHide` value.
* @param {?} tabId
* @return {?}
*/
NgbTabset.prototype.select = /**
* Selects the tab with the given id and shows its associated content panel.
*
* Any other tab that was previously selected becomes unselected and its associated pane is removed from DOM or
* hidden depending on the `destroyOnHide` value.
* @param {?} tabId
* @return {?}
*/
function (tabId) {
/** @type {?} */
var selectedTab = this._getTabById(tabId);
if (selectedTab && !selectedTab.disabled && this.activeId !== selectedTab.id) {
/** @type {?} */
var defaultPrevented_1 = false;
this.tabChange.emit({ activeId: this.activeId, nextId: selectedTab.id, preventDefault: (/**
* @return {?}
*/
function () { defaultPrevented_1 = true; }) });
if (!defaultPrevented_1) {
this.activeId = selectedTab.id;
}
}
};
/**
* @return {?}
*/
NgbTabset.prototype.ngAfterContentChecked = /**
* @return {?}
*/
function () {
// auto-correct activeId that might have been set incorrectly as input
/** @type {?} */
var activeTab = this._getTabById(this.activeId);
this.activeId = activeTab ? activeTab.id : (this.tabs.length ? this.tabs.first.id : null);
};
/**
* @private
* @param {?} id
* @return {?}
*/
NgbTabset.prototype._getTabById = /**
* @private
* @param {?} id
* @return {?}
*/
function (id) {
/** @type {?} */
var tabsWithId = this.tabs.filter((/**
* @param {?} tab
* @return {?}
*/
function (tab) { return tab.id === id; }));
return tabsWithId.length ? tabsWithId[0] : null;
};
NgbTabset.decorators = [
{ type: core.Component, args: [{
selector: 'ngb-tabset',
exportAs: 'ngbTabset',
template: "\n