ngx-bootstrap-product-tour
Version:
Angular product tour using ngx-bootstrap popover
16,270 lines • 614 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import { ApplicationRef, ChangeDetectionStrategy, ChangeDetectorRef, Component, ComponentFactoryResolver, ContentChild, Directive, ElementRef, EventEmitter, Host, HostBinding, HostListener, Inject, Injectable, Injector, Input, NgModule, NgZone, Optional, Output, ReflectiveInjector, Renderer2, TemplateRef, ViewChild, ViewChildren, ViewContainerRef, ViewEncapsulation, forwardRef, isDevMode } from '@angular/core';
import { CommonModule } from '@angular/common';
import { NG_VALIDATORS, NG_VALUE_ACCESSOR, NgControl } from '@angular/forms';
import 'rxjs/add/operator/filter';
import 'rxjs/add/operator/map';
import { BehaviorSubject as BehaviorSubject$1 } from 'rxjs/BehaviorSubject';
import { Observable as Observable$1 } from 'rxjs/Observable';
import { distinctUntilChanged as distinctUntilChanged$1 } from 'rxjs/operator/distinctUntilChanged';
import { map as map$2 } from 'rxjs/operator/map';
import { observeOn as observeOn$1 } from 'rxjs/operator/observeOn';
import { scan as scan$1 } from 'rxjs/operator/scan';
import { Subject as Subject$1 } from 'rxjs/Subject';
import 'rxjs/add/observable/timer';
import 'rxjs/add/observable/from';
import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/switchMap';
import 'rxjs/add/operator/mergeMap';
import 'rxjs/add/operator/toArray';
import { mergeStatic } from 'rxjs/operator/merge';
import 'rxjs/add/operator/first';
import { NavigationStart, Router } from '@angular/router';
/**
* Configuration service for the Popover directive.
* 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
* popovers used in the application.
*/
var PopoverConfig = (function () {
function PopoverConfig() {
/**
* Placement of a popover. Accepts: "top", "bottom", "left", "right", "auto"
*/
this.placement = 'top';
/**
* Specifies events that should trigger. Supports a space separated list of
* event names.
*/
this.triggers = 'click';
this.outsideClick = false;
}
PopoverConfig.decorators = [
{ type: Injectable },
];
/** @nocollapse */
PopoverConfig.ctorParameters = function () { return []; };
return PopoverConfig;
}());
/**
* @copyright Valor Software
* @copyright Angular ng-bootstrap team
*/
var Trigger = (function () {
function Trigger(open, close) {
this.open = open;
this.close = close || open;
}
Trigger.prototype.isManual = function () {
return this.open === 'manual' || this.close === 'manual';
};
return Trigger;
}());
var DEFAULT_ALIASES = {
hover: ['mouseover', 'mouseout'],
focus: ['focusin', 'focusout']
};
function parseTriggers(triggers, aliases) {
if (aliases === void 0) {
aliases = DEFAULT_ALIASES;
}
var trimmedTriggers = (triggers || '').trim();
if (trimmedTriggers.length === 0) {
return [];
}
var parsedTriggers = trimmedTriggers
.split(/\s+/)
.map(function (trigger) { return trigger.split(':'); })
.map(function (triggerPair) {
var alias = aliases[triggerPair[0]] || triggerPair;
return new Trigger(alias[0], alias[1]);
});
var manualTriggers = parsedTriggers.filter(function (triggerPair) {
return triggerPair.isManual();
});
if (manualTriggers.length > 1) {
throw new Error('Triggers parse error: only one manual trigger is allowed');
}
if (manualTriggers.length === 1 && parsedTriggers.length > 1) {
throw new Error('Triggers parse error: manual trigger can\'t be mixed with other triggers');
}
return parsedTriggers;
}
function listenToTriggersV2(renderer, options) {
var parsedTriggers = parseTriggers(options.triggers);
var target = options.target;
// do nothing
if (parsedTriggers.length === 1 && parsedTriggers[0].isManual()) {
return Function.prototype;
}
// all listeners
var listeners = [];
// lazy listeners registration
var _registerHide = [];
var registerHide = function () {
// add hide listeners to unregister array
_registerHide.forEach(function (fn) { return listeners.push(fn()); });
// register hide events only once
_registerHide.length = 0;
};
// register open\close\toggle listeners
parsedTriggers.forEach(function (trigger) {
var useToggle = trigger.open === trigger.close;
var showFn = useToggle ? options.toggle : options.show;
if (!useToggle) {
_registerHide.push(function () {
return renderer.listen(target, trigger.close, options.hide);
});
}
listeners.push(renderer.listen(target, trigger.open, function () { return showFn(registerHide); }));
});
return function () {
listeners.forEach(function (unsubscribeFn) { return unsubscribeFn(); });
};
}
function registerOutsideClick(renderer, options) {
if (!options.outsideClick) {
return Function.prototype;
}
return renderer.listen('document', 'click', function (event) {
if (options.target && options.target.contains(event.target)) {
return;
}
if (options.targets &&
options.targets.some(function (target) { return target.contains(event.target); })) {
return;
}
options.hide();
});
}
/**
* @copyright Valor Software
* @copyright Angular ng-bootstrap team
*/
var ContentRef = (function () {
function ContentRef(nodes, viewRef, componentRef) {
this.nodes = nodes;
this.viewRef = viewRef;
this.componentRef = componentRef;
}
return ContentRef;
}());
// tslint:disable:max-file-line-count
// todo: add delay support
// todo: merge events onShow, onShown, etc...
// todo: add global positioning configuration?
var ComponentLoader = (function () {
/**
* Do not use this directly, it should be instanced via
* `ComponentLoadFactory.attach`
* @internal
*/
// tslint:disable-next-line
function ComponentLoader(_viewContainerRef, _renderer, _elementRef, _injector, _componentFactoryResolver, _ngZone, _applicationRef, _posService) {
this._viewContainerRef = _viewContainerRef;
this._renderer = _renderer;
this._elementRef = _elementRef;
this._injector = _injector;
this._componentFactoryResolver = _componentFactoryResolver;
this._ngZone = _ngZone;
this._applicationRef = _applicationRef;
this._posService = _posService;
this.onBeforeShow = new EventEmitter();
this.onShown = new EventEmitter();
this.onBeforeHide = new EventEmitter();
this.onHidden = new EventEmitter();
this._providers = [];
this._isHiding = false;
this._listenOpts = {};
this._globalListener = Function.prototype;
}
Object.defineProperty(ComponentLoader.prototype, "isShown", {
get: function () {
if (this._isHiding) {
return false;
}
return !!this._componentRef;
},
enumerable: true,
configurable: true
});
ComponentLoader.prototype.attach = function (compType) {
this._componentFactory = this._componentFactoryResolver
.resolveComponentFactory(compType);
return this;
};
// todo: add behaviour: to target element, `body`, custom element
ComponentLoader.prototype.to = function (container) {
this.container = container || this.container;
return this;
};
ComponentLoader.prototype.position = function (opts) {
this.attachment = opts.attachment || this.attachment;
this._elementRef = opts.target || this._elementRef;
return this;
};
ComponentLoader.prototype.provide = function (provider) {
this._providers.push(provider);
return this;
};
// todo: appendChild to element or document.querySelector(this.container)
ComponentLoader.prototype.show = function (opts) {
if (opts === void 0) {
opts = {};
}
this._subscribePositioning();
this._innerComponent = null;
if (!this._componentRef) {
this.onBeforeShow.emit();
this._contentRef = this._getContentRef(opts.content, opts.context, opts.initialState);
var injector = ReflectiveInjector.resolveAndCreate(this._providers, this._injector);
this._componentRef = this._componentFactory.create(injector, this._contentRef.nodes);
this._applicationRef.attachView(this._componentRef.hostView);
// this._componentRef = this._viewContainerRef
// .createComponent(this._componentFactory, 0, injector, this._contentRef.nodes);
this.instance = this._componentRef.instance;
Object.assign(this._componentRef.instance, opts);
if (this.container instanceof ElementRef) {
this.container.nativeElement.appendChild(this._componentRef.location.nativeElement);
}
if (this.container === 'body' && typeof document !== 'undefined') {
document
.querySelector(this.container)
.appendChild(this._componentRef.location.nativeElement);
}
if (!this.container &&
this._elementRef &&
this._elementRef.nativeElement.parentElement) {
this._elementRef.nativeElement.parentElement.appendChild(this._componentRef.location.nativeElement);
}
// we need to manually invoke change detection since events registered
// via
// Renderer::listen() are not picked up by change detection with the
// OnPush strategy
if (this._contentRef.componentRef) {
this._innerComponent = this._contentRef.componentRef.instance;
this._contentRef.componentRef.changeDetectorRef.markForCheck();
this._contentRef.componentRef.changeDetectorRef.detectChanges();
}
this._componentRef.changeDetectorRef.markForCheck();
this._componentRef.changeDetectorRef.detectChanges();
this.onShown.emit(this._componentRef.instance);
}
this._registerOutsideClick();
return this._componentRef;
};
ComponentLoader.prototype.hide = function () {
if (!this._componentRef) {
return this;
}
this.onBeforeHide.emit(this._componentRef.instance);
var componentEl = this._componentRef.location.nativeElement;
componentEl.parentNode.removeChild(componentEl);
if (this._contentRef.componentRef) {
this._contentRef.componentRef.destroy();
}
this._componentRef.destroy();
if (this._viewContainerRef && this._contentRef.viewRef) {
this._viewContainerRef.remove(this._viewContainerRef.indexOf(this._contentRef.viewRef));
}
if (this._contentRef.viewRef) {
this._contentRef.viewRef.destroy();
}
// this._viewContainerRef.remove(this._viewContainerRef.indexOf(this._componentRef.hostView));
//
// if (this._contentRef.viewRef && this._viewContainerRef.indexOf(this._contentRef.viewRef) !== -1) {
// this._viewContainerRef.remove(this._viewContainerRef.indexOf(this._contentRef.viewRef));
// }
this._contentRef = null;
this._componentRef = null;
this._removeGlobalListener();
this.onHidden.emit();
return this;
};
ComponentLoader.prototype.toggle = function () {
if (this.isShown) {
this.hide();
return;
}
this.show();
};
ComponentLoader.prototype.dispose = function () {
if (this.isShown) {
this.hide();
}
this._unsubscribePositioning();
if (this._unregisterListenersFn) {
this._unregisterListenersFn();
}
};
ComponentLoader.prototype.listen = function (listenOpts) {
var _this = this;
this.triggers = listenOpts.triggers || this.triggers;
this._listenOpts.outsideClick = listenOpts.outsideClick;
listenOpts.target = listenOpts.target || this._elementRef.nativeElement;
var hide = (this._listenOpts.hide = function () {
return listenOpts.hide ? listenOpts.hide() : void _this.hide();
});
var show = (this._listenOpts.show = function (registerHide) {
listenOpts.show ? listenOpts.show(registerHide) : _this.show(registerHide);
registerHide();
});
var toggle = function (registerHide) {
_this.isShown ? hide() : show(registerHide);
};
this._unregisterListenersFn = listenToTriggersV2(this._renderer, {
target: listenOpts.target,
triggers: listenOpts.triggers,
show: show,
hide: hide,
toggle: toggle
});
return this;
};
ComponentLoader.prototype._removeGlobalListener = function () {
if (this._globalListener) {
this._globalListener();
this._globalListener = null;
}
};
ComponentLoader.prototype.attachInline = function (vRef, template) {
this._inlineViewRef = vRef.createEmbeddedView(template);
return this;
};
ComponentLoader.prototype._registerOutsideClick = function () {
var _this = this;
if (!this._componentRef || !this._componentRef.location) {
return;
}
// why: should run after first event bubble
if (this._listenOpts.outsideClick) {
var target_1 = this._componentRef.location.nativeElement;
setTimeout(function () {
_this._globalListener = registerOutsideClick(_this._renderer, {
targets: [target_1, _this._elementRef.nativeElement],
outsideClick: _this._listenOpts.outsideClick,
hide: function () { return _this._listenOpts.hide(); }
});
});
}
};
ComponentLoader.prototype.getInnerComponent = function () {
return this._innerComponent;
};
ComponentLoader.prototype._subscribePositioning = function () {
var _this = this;
if (this._zoneSubscription || !this.attachment) {
return;
}
this._zoneSubscription = this._ngZone.onStable.subscribe(function () {
if (!_this._componentRef) {
return;
}
_this._posService.position({
element: _this._componentRef.location,
target: _this._elementRef,
attachment: _this.attachment,
appendToBody: _this.container === 'body'
});
});
};
ComponentLoader.prototype._unsubscribePositioning = function () {
if (!this._zoneSubscription) {
return;
}
this._zoneSubscription.unsubscribe();
this._zoneSubscription = null;
};
ComponentLoader.prototype._getContentRef = function (content, context, initialState) {
if (!content) {
return new ContentRef([]);
}
if (content instanceof TemplateRef) {
if (this._viewContainerRef) {
var _viewRef = this._viewContainerRef
.createEmbeddedView(content, context);
_viewRef.markForCheck();
return new ContentRef([_viewRef.rootNodes], _viewRef);
}
var viewRef = content.createEmbeddedView({});
this._applicationRef.attachView(viewRef);
return new ContentRef([viewRef.rootNodes], viewRef);
}
if (typeof content === 'function') {
var contentCmptFactory = this._componentFactoryResolver.resolveComponentFactory(content);
var modalContentInjector = ReflectiveInjector.resolveAndCreate(this._providers.slice(), this._injector);
var componentRef = contentCmptFactory.create(modalContentInjector);
Object.assign(componentRef.instance, initialState);
this._applicationRef.attachView(componentRef.hostView);
return new ContentRef([[componentRef.location.nativeElement]], componentRef.hostView, componentRef);
}
return new ContentRef([[this._renderer.createText("" + content)]]);
};
return ComponentLoader;
}());
/**
* @copyright Valor Software
* @copyright Angular ng-bootstrap team
*/
// previous version:
// https://github.com/angular-ui/bootstrap/blob/07c31d0731f7cb068a1932b8e01d2312b796b4ec/src/position/position.js
// tslint:disable
var Positioning = (function () {
function Positioning() {
}
Positioning.prototype.position = function (element, round) {
if (round === void 0) {
round = true;
}
var elPosition;
var parentOffset = {
width: 0,
height: 0,
top: 0,
bottom: 0,
left: 0,
right: 0
};
if (this.getStyle(element, 'position') === 'fixed') {
var bcRect = element.getBoundingClientRect();
elPosition = {
width: bcRect.width,
height: bcRect.height,
top: bcRect.top,
bottom: bcRect.bottom,
left: bcRect.left,
right: bcRect.right
};
}
else {
var offsetParentEl = this.offsetParent(element);
elPosition = this.offset(element, false);
if (offsetParentEl !== document.documentElement) {
parentOffset = this.offset(offsetParentEl, false);
}
parentOffset.top += offsetParentEl.clientTop;
parentOffset.left += offsetParentEl.clientLeft;
}
elPosition.top -= parentOffset.top;
elPosition.bottom -= parentOffset.top;
elPosition.left -= parentOffset.left;
elPosition.right -= parentOffset.left;
if (round) {
elPosition.top = Math.round(elPosition.top);
elPosition.bottom = Math.round(elPosition.bottom);
elPosition.left = Math.round(elPosition.left);
elPosition.right = Math.round(elPosition.right);
}
return elPosition;
};
Positioning.prototype.offset = function (element, round) {
if (round === void 0) {
round = true;
}
var elBcr = element.getBoundingClientRect();
var viewportOffset = {
top: window.pageYOffset - document.documentElement.clientTop,
left: window.pageXOffset - document.documentElement.clientLeft
};
var elOffset = {
height: elBcr.height || element.offsetHeight,
width: elBcr.width || element.offsetWidth,
top: elBcr.top + viewportOffset.top,
bottom: elBcr.bottom + viewportOffset.top,
left: elBcr.left + viewportOffset.left,
right: elBcr.right + viewportOffset.left
};
if (round) {
elOffset.height = Math.round(elOffset.height);
elOffset.width = Math.round(elOffset.width);
elOffset.top = Math.round(elOffset.top);
elOffset.bottom = Math.round(elOffset.bottom);
elOffset.left = Math.round(elOffset.left);
elOffset.right = Math.round(elOffset.right);
}
return elOffset;
};
Positioning.prototype.positionElements = function (hostElement, targetElement, placement, appendToBody) {
var hostElPosition = appendToBody
? this.offset(hostElement, false)
: this.position(hostElement, false);
var targetElStyles = this.getAllStyles(targetElement);
var shiftWidth = {
left: hostElPosition.left,
center: hostElPosition.left +
hostElPosition.width / 2 -
targetElement.offsetWidth / 2,
right: hostElPosition.left + hostElPosition.width
};
var shiftHeight = {
top: hostElPosition.top,
center: hostElPosition.top +
hostElPosition.height / 2 -
targetElement.offsetHeight / 2,
bottom: hostElPosition.top + hostElPosition.height
};
var targetElBCR = targetElement.getBoundingClientRect();
var placementPrimary = placement.split(' ')[0] || 'top';
var placementSecondary = placement.split(' ')[1] || 'center';
var targetElPosition = {
height: targetElBCR.height || targetElement.offsetHeight,
width: targetElBCR.width || targetElement.offsetWidth,
top: 0,
bottom: targetElBCR.height || targetElement.offsetHeight,
left: 0,
right: targetElBCR.width || targetElement.offsetWidth
};
if (placementPrimary === 'auto') {
var newPlacementPrimary = this.autoPosition(targetElPosition, hostElPosition, targetElement, placementSecondary);
if (!newPlacementPrimary)
newPlacementPrimary = this.autoPosition(targetElPosition, hostElPosition, targetElement);
if (newPlacementPrimary)
placementPrimary = newPlacementPrimary;
targetElement.classList.add(placementPrimary);
}
switch (placementPrimary) {
case 'top':
targetElPosition.top =
hostElPosition.top -
(targetElement.offsetHeight +
parseFloat(targetElStyles.marginBottom));
targetElPosition.bottom +=
hostElPosition.top - targetElement.offsetHeight;
targetElPosition.left = shiftWidth[placementSecondary];
targetElPosition.right += shiftWidth[placementSecondary];
break;
case 'bottom':
targetElPosition.top = shiftHeight[placementPrimary];
targetElPosition.bottom += shiftHeight[placementPrimary];
targetElPosition.left = shiftWidth[placementSecondary];
targetElPosition.right += shiftWidth[placementSecondary];
break;
case 'left':
targetElPosition.top = shiftHeight[placementSecondary];
targetElPosition.bottom += shiftHeight[placementSecondary];
targetElPosition.left =
hostElPosition.left -
(targetElement.offsetWidth + parseFloat(targetElStyles.marginRight));
targetElPosition.right +=
hostElPosition.left - targetElement.offsetWidth;
break;
case 'right':
targetElPosition.top = shiftHeight[placementSecondary];
targetElPosition.bottom += shiftHeight[placementSecondary];
targetElPosition.left = shiftWidth[placementPrimary];
targetElPosition.right += shiftWidth[placementPrimary];
break;
}
targetElPosition.top = Math.round(targetElPosition.top);
targetElPosition.bottom = Math.round(targetElPosition.bottom);
targetElPosition.left = Math.round(targetElPosition.left);
targetElPosition.right = Math.round(targetElPosition.right);
return targetElPosition;
};
Positioning.prototype.autoPosition = function (targetElPosition, hostElPosition, targetElement, preferredPosition) {
if ((!preferredPosition || preferredPosition === 'right') &&
targetElPosition.left + hostElPosition.left - targetElement.offsetWidth <
0) {
return 'right';
}
else if ((!preferredPosition || preferredPosition === 'top') &&
targetElPosition.bottom +
hostElPosition.bottom +
targetElement.offsetHeight >
window.innerHeight) {
return 'top';
}
else if ((!preferredPosition || preferredPosition === 'bottom') &&
targetElPosition.top + hostElPosition.top - targetElement.offsetHeight < 0) {
return 'bottom';
}
else if ((!preferredPosition || preferredPosition === 'left') &&
targetElPosition.right +
hostElPosition.right +
targetElement.offsetWidth >
window.innerWidth) {
return 'left';
}
return null;
};
Positioning.prototype.getAllStyles = function (element) {
return window.getComputedStyle(element);
};
Positioning.prototype.getStyle = function (element, prop) {
return this.getAllStyles(element)[prop];
};
Positioning.prototype.isStaticPositioned = function (element) {
return (this.getStyle(element, 'position') || 'static') === 'static';
};
Positioning.prototype.offsetParent = function (element) {
var offsetParentEl = element.offsetParent || document.documentElement;
while (offsetParentEl &&
offsetParentEl !== document.documentElement &&
this.isStaticPositioned(offsetParentEl)) {
offsetParentEl = offsetParentEl.offsetParent;
}
return offsetParentEl || document.documentElement;
};
return Positioning;
}());
var positionService = new Positioning();
function positionElements(hostElement, targetElement, placement, appendToBody) {
var pos = positionService.positionElements(hostElement, targetElement, placement, appendToBody);
targetElement.style.top = pos.top + "px";
targetElement.style.left = pos.left + "px";
}
var PositioningService = (function () {
function PositioningService() {
}
PositioningService.prototype.position = function (options) {
var element = options.element, target = options.target, attachment = options.attachment, appendToBody = options.appendToBody;
positionElements(_getHtmlElement(target), _getHtmlElement(element), attachment, appendToBody);
};
PositioningService.decorators = [
{ type: Injectable },
];
/** @nocollapse */
PositioningService.ctorParameters = function () { return []; };
return PositioningService;
}());
function _getHtmlElement(element) {
// it means that we got a selector
if (typeof element === 'string') {
return document.querySelector(element);
}
if (element instanceof ElementRef) {
return element.nativeElement;
}
return element;
}
var ComponentLoaderFactory = (function () {
function ComponentLoaderFactory(_componentFactoryResolver, _ngZone, _injector, _posService, _applicationRef) {
this._componentFactoryResolver = _componentFactoryResolver;
this._ngZone = _ngZone;
this._injector = _injector;
this._posService = _posService;
this._applicationRef = _applicationRef;
}
/**
*
* @param _elementRef
* @param _viewContainerRef
* @param _renderer
* @returns {ComponentLoader}
*/
ComponentLoaderFactory.prototype.createLoader = function (_elementRef, _viewContainerRef, _renderer) {
return new ComponentLoader(_viewContainerRef, _renderer, _elementRef, this._injector, this._componentFactoryResolver, this._ngZone, this._applicationRef, this._posService);
};
ComponentLoaderFactory.decorators = [
{ type: Injectable },
];
/** @nocollapse */
ComponentLoaderFactory.ctorParameters = function () {
return [
{ type: ComponentFactoryResolver, },
{ type: NgZone, },
{ type: Injector, },
{ type: PositioningService, },
{ type: ApplicationRef, },
];
};
return ComponentLoaderFactory;
}());
/*tslint:disable */
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* JS version of browser APIs. This library can only run in the browser.
*/
var win = (typeof window !== 'undefined' && window) || {};
var document$1 = win.document;
var location = win.location;
var gc = win['gc'] ? function () { return win['gc'](); } : function () { return null; };
var performance = win['performance'] ? win['performance'] : null;
var Event = win['Event'];
var MouseEvent = win['MouseEvent'];
var KeyboardEvent = win['KeyboardEvent'];
var EventTarget = win['EventTarget'];
var History = win['History'];
var Location = win['Location'];
var EventListener = win['EventListener'];
var guessedVersion;
function _guessBsVersion() {
if (typeof document === 'undefined') {
return null;
}
var spanEl = document.createElement('span');
spanEl.innerText = 'test bs version';
document.body.appendChild(spanEl);
spanEl.classList.add('d-none');
var rect = spanEl.getBoundingClientRect();
document.body.removeChild(spanEl);
if (!rect) {
return 'bs3';
}
return rect.top === 0 ? 'bs4' : 'bs3';
}
// todo: in ngx-bootstrap, bs4 will became a default one
function isBs3() {
if (typeof win === 'undefined') {
return true;
}
if (typeof win.__theme === 'undefined') {
if (guessedVersion) {
return guessedVersion === 'bs3';
}
guessedVersion = _guessBsVersion();
return guessedVersion === 'bs3';
}
return win.__theme !== 'bs4';
}
var PopoverContainerComponent = (function () {
function PopoverContainerComponent(config) {
Object.assign(this, config);
}
Object.defineProperty(PopoverContainerComponent.prototype, "isBs3", {
get: function () {
return isBs3();
},
enumerable: true,
configurable: true
});
PopoverContainerComponent.decorators = [
{ type: Component, args: [{
selector: 'popover-container',
changeDetection: ChangeDetectionStrategy.OnPush,
// tslint:disable-next-line
host: {
'[class]': '"popover in popover-" + placement + " " + "bs-popover-" + placement + " " + placement + " " + containerClass',
'[class.show]': '!isBs3',
role: 'tooltip',
style: 'display:block;'
},
styles: [
"\n :host.bs-popover-top .arrow, :host.bs-popover-bottom .arrow {\n left: 50%;\n margin-left: -8px;\n }\n :host.bs-popover-left .arrow, :host.bs-popover-right .arrow {\n top: 50%;\n margin-top: -8px;\n }\n "
],
template: "<div class=\"popover-arrow arrow\"></div> <h3 class=\"popover-title popover-header\" *ngIf=\"title\">{{ title }}</h3> <div class=\"popover-content popover-body\"> <ng-content></ng-content> </div> "
},] },
];
/** @nocollapse */
PopoverContainerComponent.ctorParameters = function () {
return [
{ type: PopoverConfig, },
];
};
PopoverContainerComponent.propDecorators = {
'placement': [{ type: Input },],
'title': [{ type: Input },],
};
return PopoverContainerComponent;
}());
/**
* A lightweight, extensible directive for fancy popover creation.
*/
var PopoverDirective = (function () {
function PopoverDirective(_elementRef, _renderer, _viewContainerRef, _config, cis) {
/**
* Close popover on outside click
*/
this.outsideClick = false;
/**
* Css class for popover container
*/
this.containerClass = '';
this._isInited = false;
this._popover = cis
.createLoader(_elementRef, _viewContainerRef, _renderer)
.provide({ provide: PopoverConfig, useValue: _config });
Object.assign(this, _config);
this.onShown = this._popover.onShown;
this.onHidden = this._popover.onHidden;
// fix: no focus on button on Mac OS #1795
if (typeof window !== 'undefined') {
_elementRef.nativeElement.addEventListener('click', function () {
try {
_elementRef.nativeElement.focus();
}
catch (err) {
return;
}
});
}
}
Object.defineProperty(PopoverDirective.prototype, "isOpen", {
/**
* Returns whether or not the popover is currently being shown
*/
get: function () {
return this._popover.isShown;
},
set: function (value) {
if (value) {
this.show();
}
else {
this.hide();
}
},
enumerable: true,
configurable: true
});
/**
* Opens an element’s popover. This is considered a “manual” triggering of
* the popover.
*/
PopoverDirective.prototype.show = function () {
if (this._popover.isShown || !this.popover) {
return;
}
this._popover
.attach(PopoverContainerComponent)
.to(this.container)
.position({ attachment: this.placement })
.show({
content: this.popover,
context: this.popoverContext,
placement: this.placement,
title: this.popoverTitle,
containerClass: this.containerClass
});
this.isOpen = true;
};
/**
* Closes an element’s popover. This is considered a “manual” triggering of
* the popover.
*/
PopoverDirective.prototype.hide = function () {
if (this.isOpen) {
this._popover.hide();
this.isOpen = false;
}
};
/**
* Toggles an element’s popover. This is considered a “manual” triggering of
* the popover.
*/
PopoverDirective.prototype.toggle = function () {
if (this.isOpen) {
return this.hide();
}
this.show();
};
PopoverDirective.prototype.ngOnInit = function () {
var _this = this;
// fix: seems there are an issue with `routerLinkActive`
// which result in duplicated call ngOnInit without call to ngOnDestroy
// read more: https://github.com/valor-software/ngx-bootstrap/issues/1885
if (this._isInited) {
return;
}
this._isInited = true;
this._popover.listen({
triggers: this.triggers,
outsideClick: this.outsideClick,
show: function () { return _this.show(); }
});
};
PopoverDirective.prototype.ngOnDestroy = function () {
this._popover.dispose();
};
PopoverDirective.decorators = [
{ type: Directive, args: [{ selector: '[popover]', exportAs: 'bs-popover' },] },
];
/** @nocollapse */
PopoverDirective.ctorParameters = function () {
return [
{ type: ElementRef, },
{ type: Renderer2, },
{ type: ViewContainerRef, },
{ type: PopoverConfig, },
{ type: ComponentLoaderFactory, },
];
};
PopoverDirective.propDecorators = {
'popover': [{ type: Input },],
'popoverContext': [{ type: Input },],
'popoverTitle': [{ type: Input },],
'placement': [{ type: Input },],
'outsideClick': [{ type: Input },],
'triggers': [{ type: Input },],
'container': [{ type: Input },],
'containerClass': [{ type: Input },],
'isOpen': [{ type: Input },],
'onShown': [{ type: Output },],
'onHidden': [{ type: Output },],
};
return PopoverDirective;
}());
var PopoverModule = (function () {
function PopoverModule() {
}
PopoverModule.forRoot = function () {
return {
ngModule: PopoverModule,
providers: [PopoverConfig, ComponentLoaderFactory, PositioningService]
};
};
PopoverModule.decorators = [
{ type: NgModule, args: [{
imports: [CommonModule],
declarations: [PopoverDirective, PopoverContainerComponent],
exports: [PopoverDirective],
entryComponents: [PopoverContainerComponent]
},] },
];
/** @nocollapse */
PopoverModule.ctorParameters = function () { return []; };
return PopoverModule;
}());
function createUTCDate(y, m, d) {
var date = new Date(Date.UTC.apply(null, arguments));
// the Date.UTC function remaps years 0-99 to 1900-1999
if (y < 100 && y >= 0 && isFinite(date.getUTCFullYear())) {
date.setUTCFullYear(y);
}
return date;
}
function createDate(y, m, d, h, M, s, ms) {
if (m === void 0) {
m = 0;
}
if (d === void 0) {
d = 1;
}
if (h === void 0) {
h = 0;
}
if (M === void 0) {
M = 0;
}
if (s === void 0) {
s = 0;
}
if (ms === void 0) {
ms = 0;
}
var date = new Date(y, m, d, h, M, s, ms);
// the date constructor remaps years 0-99 to 1900-1999
if (y < 100 && y >= 0 && isFinite(date.getFullYear())) {
date.setFullYear(y);
}
return date;
}
function zeroFill(num, targetLength, forceSign) {
var absNumber = "" + Math.abs(num);
var zerosToFill = targetLength - absNumber.length;
var sign = num >= 0;
var _sign = sign ? (forceSign ? '+' : '') : '-';
// todo: this is crazy slow
var _zeros = Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1);
return (_sign + _zeros + absNumber);
}
function mod(n, x) {
return (n % x + x) % x;
}
function absFloor(num) {
return num < 0 ? Math.ceil(num) || 0 : Math.floor(num);
}
function isString(str) {
return typeof str === 'string';
}
function isDate(value) {
return value instanceof Date || Object.prototype.toString.call(value) === '[object Date]';
}
function isDateValid(date) {
return date && date.getTime && !isNaN(date.getTime());
}
function isFunction(fn) {
return (fn instanceof Function ||
Object.prototype.toString.call(fn) === '[object Function]');
}
function isNumber(value) {
return typeof value === 'number' || Object.prototype.toString.call(value) === '[object Number]';
}
function isArray(input) {
return (input instanceof Array ||
Object.prototype.toString.call(input) === '[object Array]');
}
function hasOwnProp(a /*object*/, b) {
return Object.prototype.hasOwnProperty.call(a, b);
}
function isObject(input /*object*/) {
// IE8 will treat undefined and null as object if it wasn't for
// input != null
return (input != null && Object.prototype.toString.call(input) === '[object Object]');
}
function isObjectEmpty(obj) {
if (Object.getOwnPropertyNames) {
return (Object.getOwnPropertyNames(obj).length === 0);
}
var k;
for (k in obj) {
if (obj.hasOwnProperty(k)) {
return false;
}
}
return true;
}
function isUndefined(input) {
return input === void 0;
}
function toInt(argumentForCoercion) {
var coercedNumber = +argumentForCoercion;
var value = 0;
if (coercedNumber !== 0 && isFinite(coercedNumber)) {
value = absFloor(coercedNumber);
}
return value;
}
var formatFunctions = {};
var formatTokenFunctions = {};
// tslint:disable-next-line
var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g;
// token: 'M'
// padded: ['MM', 2]
// ordinal: 'Mo'
// callback: function () { this.month() + 1 }
function addFormatToken(token, padded, ordinal, callback) {
if (token) {
formatTokenFunctions[token] = callback;
}
if (padded) {
formatTokenFunctions[padded[0]] = function () {
return zeroFill(callback.apply(null, arguments), padded[1], padded[2]);
};
}
if (ordinal) {
formatTokenFunctions[ordinal] = function (date, opts) {
return opts.locale.ordinal(callback.apply(null, arguments), token);
};
}
}
function makeFormatFunction(format) {
var array = format.match(formattingTokens);
var length = array.length;
var formatArr = new Array(length);
for (var i = 0; i < length; i++) {
formatArr[i] = formatTokenFunctions[array[i]]
? formatTokenFunctions[array[i]]
: removeFormattingTokens(array[i]);
}
return function (date, locale, isUTC, offset) {
if (offset === void 0) {
offset = 0;
}
var output = '';
for (var j = 0; j < length; j++) {
output += isFunction(formatArr[j])
? formatArr[j].call(null, date, { format: format, locale: locale, isUTC: isUTC, offset: offset })
: formatArr[j];
}
return output;
};
}
function removeFormattingTokens(input) {
if (input.match(/\[[\s\S]/)) {
return input.replace(/^\[|\]$/g, '');
}
return input.replace(/\\/g, '');
}
function getHours(date, isUTC) {
if (isUTC === void 0) {
isUTC = false;
}
return isUTC ? date.getUTCHours() : date.getHours();
}
function getMinutes(date, isUTC) {
if (isUTC === void 0) {
isUTC = false;
}
return isUTC ? date.getUTCMinutes() : date.getMinutes();
}
function getSeconds(date, isUTC) {
if (isUTC === void 0) {
isUTC = false;
}
return isUTC ? date.getUTCSeconds() : date.getSeconds();
}
function getMilliseconds(date, isUTC) {
if (isUTC === void 0) {
isUTC = false;
}
return isUTC ? date.getUTCMilliseconds() : date.getMilliseconds();
}
function getTime(date) {
return date.getTime();
}
function getDay(date, isUTC) {
if (isUTC === void 0) {
isUTC = false;
}
return isUTC ? date.getUTCDay() : date.getDay();
}
function getDate(date, isUTC) {
if (isUTC === void 0) {
isUTC = false;
}
return isUTC ? date.getUTCDate() : date.getDate();
}
function getMonth(date, isUTC) {
if (isUTC === void 0) {
isUTC = false;
}
return isUTC ? date.getUTCMonth() : date.getMonth();
}
function getFullYear(date, isUTC) {
if (isUTC === void 0) {
isUTC = false;
}
return isUTC ? date.getUTCFullYear() : date.getFullYear();
}
function unix(date) {
return Math.floor(date.valueOf() / 1000);
}
function getFirstDayOfMonth(date) {
return createDate(date.getFullYear(), date.getMonth(), 1, date.getHours(), date.getMinutes(), date.getSeconds());
}
function isFirstDayOfWeek(date, firstDayOfWeek) {
return date.getDay() === firstDayOfWeek;
}
function isSameMonth(date1, date2) {
if (!date1 || !date2) {
return false;
}
return isSameYear(date1, date2) && getMonth(date1) === getMonth(date2);
}
function isSameYear(date1, date2) {
if (!date1 || !date2) {
return false;
}
return getFullYear(date1) === getFullYear(date2);
}
function isSameDay(date1, date2) {
if (!date1 || !date2) {
return false;
}
return (isSameYear(date1, date2) &&
isSameMonth(date1, date2) &&
getDate(date1) === getDate(date2));
}
var match1 = /\d/; // 0 - 9
var match2 = /\d\d/; // 00 - 99
var match3 = /\d{3}/; // 000 - 999
var match4 = /\d{4}/; // 0000 - 9999
var match6 = /[+-]?\d{6}/; // -999999 - 999999
var match1to2 = /\d\d?/; // 0 - 99
var match3to4 = /\d\d\d\d?/; // 999 - 9999
var match5to6 = /\d\d\d\d\d\d?/; // 99999 - 999999
var match1to3 = /\d{1,3}/; // 0 - 999
var match1to4 = /\d{1,4}/; // 0 - 9999
var match1to6 = /[+-]?\d{1,6}/; // -999999 - 999999
var matchUnsigned = /\d+/; // 0 - inf
var matchSigned = /[+-]?\d+/; // -inf - inf
// +00:00 -00:00 +0000 -0000 or Z
var matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi; // +00 -00 +00:00 -00:00 +0000 -0000 or Z
var matchTimestamp = /[+-]?\d+(\.\d{1,3})?/; // 123456789 123456789.123
// any word (or two) characters or numbers including two/three word month in arabic.
// includes scottish gaelic two word and hyphenated months
// tslint:disable-next-line
var matchWord = /[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i;
var regexes = {};
function addRegexToken(token, regex, strictRegex) {
if (isFunction(regex)) {
regexes[token] = regex;
return;
}
regexes[token] = function (isStrict, locale) {
return (isStrict && strictRegex) ? strictRegex : regex;
};
}
function getParseRegexForToken(token, locale) {
var _strict = false;
if (!hasOwnProp(regexes, token)) {
return new RegExp(unescapeFormat(token));
}
return regexes[token](_strict, locale);
}
// Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
function unescapeFormat(str) {
// tslint:disable-next-line
return regexEscape(str
.replace('\\', '')
.replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) { return p1 || p2 || p3 || p4; }));
}
function regexEscape(str) {
return str.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
}
// tslint:disable:max-line-length
var tokens = {};
function addParseToken(token, callback) {
var _token = isString(token) ? [token] : token;
var func = callback;
if (isNumber(callback)) {
func = function (input, array, config) {
array[callback] = toInt(input);
return config;
};
}
if (isArray(_token) && isFunction(func)) {
var i = void 0;
for (i = 0; i < _token.length; i++) {
tokens[_token[i]] = func;
}
}
}
function addWeekParseToken(token, callback) {
addParseToken(token, function (input, array, config, _token) {
config._w = config._w || {};
return callback(input, config._w, config, _token);
});
}
function addTimeToArrayFromToken(token, input, config) {
if (input != null && hasOwnProp(tokens, token)) {
tokens[token](input, config._a, config, token);
}
return config;
}
// place in new Date([array])
var YEAR = 0;
var MONTH = 1;
var DATE = 2;
var HOUR = 3;
var MINUTE = 4;
var SECOND = 5;
var MILLISECOND = 6;
var WEEK = 7;
var WEEKDAY = 8;
/*
export function getPrioritizedUnits(unitsObj) {
const units = [];
let unit;
for (unit in unitsObj) {
if (unitsObj.hasOwnProperty(unit)) {
units.push({ unit, priority: priorities[unit] });
}
}
units.sort(function (a, b) {
return a.priority - b.priority;
});
return units;
}
*/
var aliases = {};
var _mapUnits = {
date: 'day',
hour: 'hours',
minute: 'minutes',
second: 'seconds',
millisecond: 'milliseconds'
};
function addUnitAlias(unit, shorthand) {
var lowerCase = unit.toLowerCase();
var _unit = unit;
if (lowerCase in _mapUnits) {
_unit = _mapUnits[lowerCase];
}
aliases[lowerCase] = aliases[lowerCase + "s"] = aliases[shorthand] = _unit;
}
function normalizeUnits(units) {
return isString(units) ? aliases[units] || aliases[units.toLowerCase()] : undefined;
}
function normalizeObjectUnits(inputObject) {
var normalizedInput = {};
var normalizedProp;
var prop;
for (prop in inputObject) {
if (hasOwnProp(inputObject, prop)) {
normalizedProp = normalizeUnits(prop);
if (normalizedProp) {
normalizedInput[normalizedProp] = inputObject[prop];
}
}
}
return normalizedInput;
}
// FORMATTING
function getYear(date, opts) {
return getFullYear(date, opts.isUTC).toString();
}
addFormatToken('Y', null, null, function (date, opts) {
var y = getFullYear(date, opts.isUTC);
return y <= 9999 ? y.toString(10) : "+" + y;
});
addFormatToken(null, ['YY', 2, false], null, function (date, opts) {
return (getFullYear(date, opts.isUTC) % 100).toString(10);
});
addFormatToken(null, ['YYYY', 4, false], null, getYear);
addFormatToken(null, ['YYYYY', 5, false], null, getYear);
addFormatToken(null, ['YYYYYY', 6, true], null, getYear);
// ALIASES
addUnitAlias('year', 'y');
// PARSING
addRegexToken('Y', matchSigned);
addRegexToken('YY', match1to2, match2);
addRegexToken('YYYY', match1to4, match4);
addRegexToken('YYYYY', match1to6, match6);
addRegexToken('YYYYYY', match1to6, match6);
addParseToken(['YYYYY', 'YYYYYY'], YEAR);
addParseToken('YYYY', function (input, array, config) {
array[YEAR] = input.length === 2 ? parseTwoDigitYear(input) : toInt(input);
return config;
});
addParseToken('YY', function (input, array, config) {
array[YEAR] = parseTwoDigitYear(input);
return config;
});
addParseToken('Y', function (input, array, config) {
array[YEAR] = parseInt(input, 10);
return config;
});
function parseTwoDigitYear(input) {
return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
}
function daysInYear(year) {
return isLeapYear(year) ? 366 : 365;
}
function isLeapYear(year) {
return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
}
function defaultParsingFlags() {
// We need to deep clone this object.
return {
empty: false,
unusedTokens: [],
unusedInput: [],
overflow: -2,
charsLeftOver: 0,
nullInput: false,
invalidMonth: null,
invalidFormat: false,
userInvalidated: false,
iso: false,
parsedDateParts: [],
meridiem: null,
rfc2822: false,
weekdayMismatch: false
};
}
function getParsingFlags(config) {
if (config._pf == null) {
config._pf = defaultParsingFlags();
}
return config._pf;
}
// todo: this is duplicate, source in date-getters.ts
function daysInMonth$1(year, month) {
if (isNaN(year) || isNaN(month)) {
return NaN;
}
var modMonth = mod(month, 12);
var _year = year + (month - modMonth) / 12;
return modMonth === 1
? isLeapYear(_year) ? 29 : 28
: (31 - modMonth % 7 % 2);
}
// FORMATTING
addFormatToken('M', ['MM', 2, false], 'Mo', function (date, opts) {
return (getMonth(date, opts.isUTC) + 1).toString(10);
});
addFormatToken('MMM', null, null, function (date, opts) {
return opts.locale.monthsShort(date, opts.format, opts.isUTC);
});
addFormatToken('MMMM', null, null, function (date, opts) {
return opts.locale.months(date, opts.format, opts.isUTC);
});
// ALIASES
addUnitAlias('month', 'M');
// PARSING
addRegexToken('M', match1to2);
addRegexToken('MM', match1to2, match2);
addRegexToken('MMM', function (isStrict, locale) {
return locale.monthsShortRegex(isStrict);
});
addRegexToken('MMMM', function (isStrict, locale) {
return locale.monthsRegex(isStrict);
});
addParseToken(['M', 'MM'], function (input, array, config) {
array[MONTH] = toInt(input) - 1;
return config;
});
addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
var month = config._locale.monthsParse(input, token, config._strict);
// if we didn't find a month name, mark the date as invalid.
if (month != null) {
array[MONTH] = month;
}
else {
getParsingFlags(config).invalidMonth = !!input;
}
return config;
});
var defaultTimeUnit = {
year: 0,
month: 0,
day: 0,
hour: 0,
minute: 0,
seconds: 0
};
function shiftDate(date, unit) {
var _unit = Object.assign({}, defaultTimeUnit, unit);
var year = date.getFullYear() + (_unit.year || 0);
var month = date.getMonth() + (_unit.month || 0);
var day = date.getDate() + (_unit.day || 0);
if (_unit.month && !_unit.day) {
day = Math.min(day, daysInMonth$1(year, month));
}
return createDate(year, month, day, date.getHours() + (_unit.hour || 0), date.getMinutes() + (_unit.minute || 0), date.getSeconds() + (_unit.seconds || 0));
}
function setFullDate(date, unit) {
return createDate(getNum(date.getFullYear(), unit.year), getNum(date.getMonth(), unit.month), getNum(date.getDate(), unit.day), getNum(date.getHours(), unit.hour), getNum(date.getMinutes(), unit.minute), getNum(date.getSeconds(), unit.seconds), getNum(date.getMilliseconds(), unit.milliseconds));
}
function getNum(def, num) {
return isNumber(num) ? num : def;
}
function setMonth(date, value, isUTC) {
var dayOfMonth = Math.min(getDate(date), daysInMonth$1(getFullYear(date), value));
isUTC ? date.setUTCMonth(value, dayOfMonth) : date.setMonth(value, dayOfMonth);
return date;
}
function setHours(date, value, isUTC) {
isUTC ? date.setUTCHours(value) : date.setHours(value);
return date;
}
function setMinutes(date, value, isUTC) {
isUTC ? date.setUTCMinutes(value) : date.setMinutes(value);
return date;
}
function setSeconds(date, value, isUTC) {
isUTC ? date.setUTCSeconds(value) : date.setSeconds(value);
return date;
}
function setMilliseconds(date, value, isUTC) {
isUTC ? date.setUTCMilliseconds(value) : date.setMilliseconds(value);
return date;
}
function setDate(date, value, isUTC) {
isUTC ? date.setUTCDate(value) : date.setDate(value);
return date;
}
function setTime(date, value) {
date.setTime(value);
return date;
}
// fastest way to clone date
// https://jsperf.com/clone-date-object2
function cloneDate(date) {
return new Date(date.getTime());
}
var ordering = ['year', 'quarter', 'month', 'week', 'day', 'hours', 'minutes', 'seconds', 'milliseconds'];
var orderingHash = ordering.reduce(function (mem, order) {
mem[order] = true;
return mem;
}, {});
function isDurationValid(duration) {
var durationKeys = Object.keys(duration);
if (durationKeys
.some(function (key) {
return (key in orderingHash)
&& duration[key] === null
|| isNaN(duration[key]);
})) {
return false;
}
// for (let key in duration) {
// if (!(indexOf.call(ordering, key) !== -1 && (duration[key] == null || !isNaN(duration[key])))) {
// return false;
// }
// }
var unitHasDecimal = false;
for (var i = 0; i < ordering.length; ++i) {
if (duration[ordering[i]]) {
// only allow non-integers for smallest unit
if (unitHasDecimal) {
return false;
}
if (duration[ordering[i]] !== toInt(duration[ordering[i]])) {
unitHasDecimal = true;
}
}
}
return true;
}
// export function isValid() {
// return this._isValid;
// }
//
// export function createInvalid(): Duration {
// return createDuration(NaN);
// }
function absCeil(number) {
return number < 0 ? Math.floor(number) : Math.ceil(number);
}
function bubble(dur) {
var milliseconds = dur._milliseconds;
var days = dur._days;
var months = dur._months;
var data = dur._data;
// if we have a mix of positive and negative values, bubble down first
// check: https://github.com/moment/moment/issues/2166
if (!((milliseconds >= 0 && days >= 0 && months >= 0) ||
(milliseconds <= 0 && days <= 0 && months <= 0))) {
milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
days = 0;
months = 0;
}
// The following code bubbles up values, see the tests for
// examples of what that means.
data.milliseconds = milliseconds % 1000;
var seconds = absFloor(milliseconds / 1000);
data.seconds = seconds % 60;
var minutes = absFloor(seconds / 60);
data.minutes = minutes % 60;
var hours = absFloor(minutes / 60);
data.hours = hours % 24;
days += absFloor(hours / 24);
// convert days to months
var monthsFromDays = absFloor(daysToMonths(days));
months += monthsFromDays;
days -= absCeil(monthsToDays(monthsFromDays));
// 12 months -> 1 year
var years = absFloor(months / 12);
months %= 12;
data.day = days;
data.month = months;
data.year = years;
return dur;
}
function daysToMonths(day) {
// 400 years have 146097 days (taking into account leap year rules)
// 400 years have 12 months === 4800
return day * 4800 / 146097;
}
function monthsToDays(month) {
// the reverse of daysToMonths
return month * 146097 / 4800;
}
// tslint:disable:cyclomatic-complexity
var round = Math.round;
var thresholds = {
ss: 44,
s: 45,
m: 45,
h: 22,
d: 26,
M: 11 // months to year
};
// helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
function substituteTimeAgo(str, num, withoutSuffix, isFuture, locale) {
return locale.relativeTime(num || 1, !!withoutSuffix, str, isFuture);
}
function relativeTime(posNegDuration, withoutSuffix, locale) {
var duration = createDuration(posNegDuration).abs();
var seconds = round(duration.as('s'));
var minutes = round(duration.as('m'));
var hours = round(duration.as('h'));
var days = round(duration.as('d'));
var months = round(duration.as('M'));
var years = round(duration.as('y'));
var a = seconds <= thresholds.ss && ['s', seconds] ||
seconds < thresholds.s && ['ss', seconds] ||
minutes <= 1 && ['m'] ||
minutes < thresholds.m && ['mm', minutes] ||
hours <= 1 && ['h'] ||
hours < thresholds.h && ['hh', hours] ||
days <= 1 && ['d'] ||
days < thresholds.d && ['dd', days] ||
months <= 1 && ['M'] ||
months < thresholds.M && ['MM', months] ||
years <= 1 && ['y'] || ['yy', years];
var b = [a[0], a[1], withoutSuffix, +posNegDuration > 0, locale];
// a[2] = withoutSuffix;
// a[3] = +posNegDuration > 0;
// a[4] = locale;
return substituteTimeAgo.apply(null, b);
}
// This function allows you to set the rounding function for relative time strings
// This function allows you to set a threshold for relative time strings
// export function humanize(withSuffix) {
// if (!this.isValid()) {
// return this.localeData().invalidDate();
// }
//
// const locale = this.localeData();
// let output = relativeTime(this, !withSuffix, locale);
//
// if (withSuffix) {
// output = locale.pastFuture(+this, output);
// }
//
// return locale.postformat(output);
// }
var Duration = (function () {
function Duration(duration, config) {
if (config === void 0) {
config = {};
}
this._data = {};
this._locale = getLocale();
this._locale = config && config._locale || getLocale();
// const normalizedInput = normalizeObjectUnits(duration);
var normalizedInput = duration;
var years = normalizedInput.year || 0;
var quarters = normalizedInput.quarter || 0;
var months = normalizedInput.month || 0;
var weeks = normalizedInput.week || 0;
var days = normalizedInput.day || 0;
var hours = normalizedInput.hours || 0;
var minutes = normalizedInput.minutes || 0;
var seconds = normalizedInput.seconds || 0;
var milliseconds = normalizedInput.milliseconds || 0;
this._isValid = isDurationValid(normalizedInput);
// representation for dateAddRemove
this._milliseconds = +milliseconds +
seconds * 1000 +
minutes * 60 * 1000 +
hours * 1000 * 60 * 60; // using 1000 * 60 * 60
// instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978
// Because of dateAddRemove treats 24 hours as different from a
// day when working around DST, we need to store them separately
this._days = +days +
weeks * 7;
// It is impossible to translate months into days without knowing
// which months you are are talking about, so we have to store
// it separately.
this._months = +months +
quarters * 3 +
years * 12;
// this._data = {};
// this._locale = getLocale();
// this._bubble();
return bubble(this);
}
Duration.prototype.isValid = function () {
return this._isValid;
};
Duration.prototype.humanize = function (withSuffix) {
// throw new Error(`TODO: implement`);
if (!this.isValid()) {
return this.localeData().invalidDate;
}
var locale = this.localeData();
var output = relativeTime(this, !withSuffix, locale);
if (withSuffix) {
output = locale.pastFuture(+this, output);
}
return locale.postformat(output);
};
Duration.prototype.localeData = function () {
return this._locale;
};
Duration.prototype.locale = function (localeKey) {
if (!localeKey) {
return this._locale._abbr;
}
this._locale = getLocale(localeKey) || this._locale;
return this;
};
Duration.prototype.abs = function () {
var mathAbs = Math.abs;
var data = this._data;
this._milliseconds = mathAbs(this._milliseconds);
this._days = mathAbs(this._days);
this._months = mathAbs(this._months);
data.milliseconds = mathAbs(data.milliseconds);
data.seconds = mathAbs(data.seconds);
data.minutes = mathAbs(data.minutes);
data.hours = mathAbs(data.hours);
data.month = mathAbs(data.month);
data.year = mathAbs(data.year);
return this;
};
Duration.prototype.as = function (_units) {
if (!this.isValid()) {
return NaN;
}
var days;
var months;
var milliseconds = this._milliseconds;
var units = normalizeUnits(_units);
if (units === 'month' || units === 'year') {
days = this._days + milliseconds / 864e5;
months = this._months + daysToMonths(days);
return units === 'month' ? months : months / 12;
}
// handle milliseconds separately because of floating point math errors (issue #1867)
days = this._days + Math.round(monthsToDays(this._months));
switch (units) {
case 'week':
return days / 7 + milliseconds / 6048e5;
case 'day':
return days + milliseconds / 864e5;
case 'hours':
return days * 24 + milliseconds / 36e5;
case 'minutes':
return days * 1440 + milliseconds / 6e4;
case 'seconds':
return days * 86400 + milliseconds / 1000;
// Math.floor prevents floating point math errors here
case 'milliseconds':
return Math.floor(days * 864e5) + milliseconds;
default:
throw new Error("Unknown unit " + units);
}
};
Duration.prototype.valueOf = function () {
if (!this.isValid()) {
return NaN;
}
return (this._milliseconds +
this._days * 864e5 +
(this._months % 12) * 2592e6 +
toInt(this._months / 12) * 31536e6);
};
return Duration;
}());
function isDuration(obj) {
return obj instanceof Duration;
}
function isValid(config) {
if (config._isValid == null) {
var flags = getParsingFlags(config);
var parsedParts = Array.prototype.some.call(flags.parsedDateParts, function (i) {
return i != null;
});
var isNowValid = !isNaN(config._d && config._d.getTime()) &&
flags.overflow < 0 &&
!flags.empty &&
!flags.invalidMonth &&
!flags.invalidWeekday &&
!flags.weekdayMismatch &&
!flags.nullInput &&
!flags.invalidFormat &&
!flags.userInvalidated &&
(!flags.meridiem || (flags.meridiem && parsedParts));
if (config._strict) {
isNowValid = isNowValid &&
flags.charsLeftOver === 0 &&
flags.unusedTokens.length === 0 &&
flags.bigHour === undefined;
}
if (Object.isFrozen == null || !Object.isFrozen(config)) {
config._isValid = isNowValid;
}
else {
return isNowValid;
}
}
return config._isValid;
}
function createInvalid(config, flags) {
config._d = new Date(NaN);
Object.assign(getParsingFlags(config), flags || { userInvalidated: true });
return config;
}
function markInvalid(config) {
config._isValid = false;
return config;
}
function isDate$1(value) {
return value instanceof Date && !isNaN(+value);
}
var isDate_2 = isDate$1;
// tslint:disable-next-line
// iso 8601 regex
// 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00)
// tslint:disable-next-line
var extendedIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
// tslint:disable-next-line
var basicIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
var tzRegex = /Z|[+-]\d\d(?::?\d\d)?/;
var isoDates = [
['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/, true],
['YYYY-MM-DD', /\d{4}-\d\d-\d\d/, true],
['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/, true],
['GGGG-[W]WW', /\d{4}-W\d\d/, false],
['YYYY-DDD', /\d{4}-\d{3}/, true],
['YYYY-MM', /\d{4}-\d\d/, false],
['YYYYYYMMDD', /[+-]\d{10}/, true],
['YYYYMMDD', /\d{8}/, true],
// YYYYMM is NOT allowed by the standard
['GGGG[W]WWE', /\d{4}W\d{3}/, true],
['GGGG[W]WW', /\d{4}W\d{2}/, false],
['YYYYDDD', /\d{7}/, true]
];
// iso time formats and regexes
var isoTimes = [
['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/],
['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/],
['HH:mm:ss', /\d\d:\d\d:\d\d/],
['HH:mm', /\d\d:\d\d/],
['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/],
['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/],
['HHmmss', /\d\d\d\d\d\d/],
['HHmm', /\d\d\d\d/],
['HH', /\d\d/]
];
var aspNetJsonRegex = /^\/?Date\((\-?\d+)/i;
var obsOffsets = {
UT: 0,
GMT: 0,
EDT: -4 * 60,
EST: -5 * 60,
CDT: -5 * 60,
CST: -6 * 60,
MDT: -6 * 60,
MST: -7 * 60,
PDT: -7 * 60,
PST: -8 * 60
};
// RFC 2822 regex: For details see https://tools.ietf.org/html/rfc2822#section-3.3
// tslint:disable-next-line
var rfc2822 = /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/;
// date from iso format
function configFromISO(config) {
if (!isString(config._i)) {
return config;
}
var input = config._i;
var match = extendedIsoRegex.exec(input) || basicIsoRegex.exec(input);
var allowTime;
var dateFormat;
var timeFormat;
var tzFormat;
if (!match) {
config._isValid = false;
return config;
}
// getParsingFlags(config).iso = true;
var i;
var l;
for (i = 0, l = isoDates.length; i < l; i++) {
if (isoDates[i][1].exec(match[1])) {
dateFormat = isoDates[i][0];
allowTime = isoDates[i][2] !== false;
break;
}
}
if (dateFormat == null) {
config._isValid = false;
return config;
}
if (match[3]) {
for (i = 0, l = isoTimes.length; i < l; i++) {
if (isoTimes[i][1].exec(match[3])) {
// match[2] should be 'T' or space
timeFormat = (match[2] || ' ') + isoTimes[i][0];
break;
}
}
if (timeFormat == null) {
config._isValid = false;
return config;
}
}
if (!allowTime && timeFormat != null) {
config._isValid = false;
return config;
}
if (match[4]) {
if (tzRegex.exec(match[4])) {
tzFormat = 'Z';
}
else {
config._isValid = false;
return config;
}
}
config._f = dateFormat + (timeFormat || '') + (tzFormat || '');
return configFromStringAndFormat(config);
}
// tslint:disable-next-line
function extractFromRFC2822Strings(yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr) {
var result = [
untruncateYear(yearStr),
defaultLocaleMonthsShort.indexOf(monthStr),
parseInt(dayStr, 10),
parseInt(hourStr, 10),
parseInt(minuteStr, 10)
];
if (secondStr) {
result.push(parseInt(secondStr, 10));
}
return result;
}
function untruncateYear(yearStr) {
var year = parseInt(yearStr, 10);
return year <= 49 ? year + 2000 : year;
}
function preprocessRFC2822(str) {
// Remove comments and folding whitespace and replace multiple-spaces with a single space
return str
.replace(/\([^)]*\)|[\n\t]/g, ' ')
.replace(/(\s\s+)/g, ' ').trim();
}
function checkWeekday(weekdayStr, parsedInput, config) {
if (weekdayStr) {
// TODO: Replace the vanilla JS Date object with an indepentent day-of-week check.
var weekdayProvided = defaultLocaleWeekdaysShort.indexOf(weekdayStr);
var weekdayActual = new Date(parsedInput[0], parsedInput[1], parsedInput[2]).getDay();
if (weekdayProvided !== weekdayActual) {
getParsingFlags(config).weekdayMismatch = true;
config._isValid = false;
return false;
}
}
return true;
}
function calculateOffset(obsOffset, militaryOffset, numOffset) {
if (obsOffset) {
return obsOffsets[obsOffset];
}
else if (militaryOffset) {
// the only allowed military tz is Z
return 0;
}
else {
var hm = parseInt(numOffset, 10);
var m = hm % 100;
var h = (hm - m) / 100;
return h * 60 + m;
}
}
// date and time from ref 2822 format
function configFromRFC2822(config) {
if (!isString(config._i)) {
return config;
}
var match = rfc2822.exec(preprocessRFC2822(config._i));
if (!match) {
return markInvalid(config);
}
var parsedArray = extractFromRFC2822Strings(match[4], match[3], match[2], match[5], match[6], match[7]);
if (!checkWeekday(match[1], parsedArray, config)) {
return config;
}
config._a = parsedArray;
config._tzm = calculateOffset(match[8], match[9], match[10]);
config._d = createUTCDate.apply(null, config._a);
config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
getParsingFlags(config).rfc2822 = true;
return config;
}
// date from iso format or fallback
function configFromString(config) {
if (!isString(config._i)) {
return config;
}
var matched = aspNetJsonRegex.exec(config._i);
if (matched !== null) {
config._d = new Date(+matched[1]);
return config;
}
// todo: update logic processing
// isISO -> configFromISO
// isRFC -> configFromRFC
configFromISO(config);
if (config._isValid === false) {
delete config._isValid;
}
else {
return config;
}
configFromRFC2822(config);
if (config._isValid === false) {
delete config._isValid;
}
else {
return config;
}
// Final attempt, use Input Fallback
// hooks.createFromInputFallback(config);
return createInvalid(config);
}
// hooks.createFromInputFallback = deprecate(
// 'value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), ' +
// 'which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are ' +
// 'discouraged and will be removed in an upcoming major release. Please refer to ' +
// 'http://momentjs.com/guides/#/warnings/js-date/ for more info.',
// function (config) {
// config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
// }
// );
// FORMATTING
addFormatToken('D', ['DD', 2, false], 'Do', function (date, opts) {
return getDate(date, opts.isUTC).toString(10);
});
// ALIASES
addUnitAlias('date', 'D');
// PARSING
addRegexToken('D', match1to2);
addRegexToken('DD', match1to2, match2);
addRegexToken('Do', function (isStrict, locale) {
return locale._dayOfMonthOrdinalParse || locale._ordinalParse;
});
addParseToken(['D', 'DD'], DATE);
addParseToken('Do', function (input, array, config) {
array[DATE] = toInt(input.match(match1to2)[0]);
return config;
});
// FORMATTING
function hFormat(date, isUTC) {
return getHours(date, isUTC) % 12 || 12;
}
function kFormat(date, isUTC) {
return getHours(date, isUTC) || 24;
}
addFormatToken('H', ['HH', 2, false], null, function (date, opts) {
return getHours(date, opts.isUTC).toString(10);
});
addFormatToken('h', ['hh', 2, false], null, function (date, opts) {
return hFormat(date, opts.isUTC).toString(10);
});
addFormatToken('k', ['kk', 2, false], null, function (date, opts) {
return kFormat(date, opts.isUTC).toString(10);
});
addFormatToken('hmm', null, null, function (date, opts) {
var _h = hFormat(date, opts.isUTC);
var _mm = zeroFill(getMinutes(date, opts.isUTC), 2);
return "" + _h + _mm;
});
addFormatToken('hmmss', null, null, function (date, opts) {
var _h = hFormat(date, opts.isUTC);
var _mm = zeroFill(getMinutes(date, opts.isUTC), 2);
var _ss = zeroFill(getSeconds(date, opts.isUTC), 2);
return "" + _h + _mm + _ss;
});
addFormatToken('Hmm', null, null, function (date, opts) {
var _H = getHours(date, opts.isUTC);
var _mm = zeroFill(getMinutes(date, opts.isUTC), 2);
return "" + _H + _mm;
});
addFormatToken('Hmmss', null, null, function (date, opts) {
var _H = getHours(date, opts.isUTC);
var _mm = zeroFill(getMinutes(date, opts.isUTC), 2);
var _ss = zeroFill(getSeconds(date, opts.isUTC), 2);
return "" + _H + _mm + _ss;
});
function meridiem(token, lowercase) {
addFormatToken(token, null, null, function (date, opts) {
return opts.locale.meridiem(getHours(date, opts.isUTC), getMinutes(date, opts.isUTC), lowercase);
});
}
meridiem('a', true);
meridiem('A', false);
// ALIASES
addUnitAlias('hour', 'h');
// PARSING
function matchMeridiem(isStrict, locale) {
return locale._meridiemParse;
}
addRegexToken('a', matchMeridiem);
addRegexToken('A', matchMeridiem);
addRegexToken('H', match1to2);
addRegexToken('h', match1to2);
addRegexToken('k', match1to2);
addRegexToken('HH', match1to2, match2);
addRegexToken('hh', match1to2, match2);
addRegexToken('kk', match1to2, match2);
addRegexToken('hmm', match3to4);
addRegexToken('hmmss', match5to6);
addRegexToken('Hmm', match3to4);
addRegexToken('Hmmss', match5to6);
addParseToken(['H', 'HH'], HOUR);
addParseToken(['k', 'kk'], function (input, array, config) {
var kInput = toInt(input);
array[HOUR] = kInput === 24 ? 0 : kInput;
return config;
});
addParseToken(['a', 'A'], function (input, array, config) {
config._isPm = config._locale.isPM(input);
config._meridiem = input;
return config;
});
addParseToken(['h', 'hh'], function (input, array, config) {
array[HOUR] = toInt(input);
getParsingFlags(config).bigHour = true;
return config;
});
addParseToken('hmm', function (input, array, config) {
var pos = input.length - 2;
array[HOUR] = toInt(input.substr(0, pos));
array[MINUTE] = toInt(input.substr(pos));
getParsingFlags(config).bigHour = true;
return config;
});
addParseToken('hmmss', function (input, array, config) {
var pos1 = input.length - 4;
var pos2 = input.length - 2;
array[HOUR] = toInt(input.substr(0, pos1));
array[MINUTE] = toInt(input.substr(pos1, 2));
array[SECOND] = toInt(input.substr(pos2));
getParsingFlags(config).bigHour = true;
return config;
});
addParseToken('Hmm', function (input, array, config) {
var pos = input.length - 2;
array[HOUR] = toInt(input.substr(0, pos));
array[MINUTE] = toInt(input.substr(pos));
return config;
});
addParseToken('Hmmss', function (input, array, config) {
var pos1 = input.length - 4;
var pos2 = input.length - 2;
array[HOUR] = toInt(input.substr(0, pos1));
array[MINUTE] = toInt(input.substr(pos1, 2));
array[SECOND] = toInt(input.substr(pos2));
return config;
});
// tslint:disable:no-bitwise
// FORMATTING
addFormatToken('S', null, null, function (date, opts) {
return (~~(getMilliseconds(date, opts.isUTC) / 100)).toString(10);
});
addFormatToken(null, ['SS', 2, false], null, function (date, opts) {
return (~~(getMilliseconds(date, opts.isUTC) / 10)).toString(10);
});
addFormatToken(null, ['SSS', 3, false], null, function (date, opts) {
return (getMilliseconds(date, opts.isUTC)).toString(10);
});
addFormatToken(null, ['SSSS', 4, false], null, function (date, opts) {
return (getMilliseconds(date, opts.isUTC) * 10).toString(10);
});
addFormatToken(null, ['SSSSS', 5, false], null, function (date, opts) {
return (getMilliseconds(date, opts.isUTC) * 100).toString(10);
});
addFormatToken(null, ['SSSSSS', 6, false], null, function (date, opts) {
return (getMilliseconds(date, opts.isUTC) * 1000).toString(10);
});
addFormatToken(null, ['SSSSSSS', 7, false], null, function (date, opts) {
return (getMilliseconds(date, opts.isUTC) * 10000).toString(10);
});
addFormatToken(null, ['SSSSSSSS', 8, false], null, function (date, opts) {
return (getMilliseconds(date, opts.isUTC) * 100000).toString(10);
});
addFormatToken(null, ['SSSSSSSSS', 9, false], null, function (date, opts) {
return (getMilliseconds(date, opts.isUTC) * 1000000).toString(10);
});
// ALIASES
addUnitAlias('millisecond', 'ms');
// PARSING
addRegexToken('S', match1to3, match1);
addRegexToken('SS', match1to3, match2);
addRegexToken('SSS', match1to3, match3);
var token;
for (token = 'SSSS'; token.length <= 9; token += 'S') {
addRegexToken(token, matchUnsigned);
}
function parseMs(input, array, config) {
array[MILLISECOND] = toInt(parseFloat("0." + input) * 1000);
return config;
}
for (token = 'S'; token.length <= 9; token += 'S') {
addParseToken(token, parseMs);
}
// MOMENTS
// FORMATTING
addFormatToken('m', ['mm', 2, false], null, function (date, opts) {
return getMinutes(date, opts.isUTC).toString(10);
});
// ALIASES
addUnitAlias('minute', 'm');
// PARSING
addRegexToken('m', match1to2);
addRegexToken('mm', match1to2, match2);
addParseToken(['m', 'mm'], MINUTE);
// tslint:disable:no-bitwise max-line-length
// FORMATTING
function addOffsetFormatToken(token, separator) {
addFormatToken(token, null, null, function (date, config) {
var offset = getUTCOffset(date, { _isUTC: config.isUTC, _offset: config.offset });
var sign = '+';
if (offset < 0) {
offset = -offset;
sign = '-';
}
return sign + zeroFill(~~(offset / 60), 2) + separator + zeroFill(~~(offset) % 60, 2);
});
}
addOffsetFormatToken('Z', ':');
addOffsetFormatToken('ZZ', '');
// PARSING
addRegexToken('Z', matchShortOffset);
addRegexToken('ZZ', matchShortOffset);
addParseToken(['Z', 'ZZ'], function (input, array, config) {
config._useUTC = true;
config._tzm = offsetFromString(matchShortOffset, input);
return config;
});
// HELPERS
// timezone chunker
// '+10:00' > ['10', '00']
// '-1530' > ['-15', '30']
var chunkOffset = /([\+\-]|\d\d)/gi;
function offsetFromString(matcher, str) {
var matches = (str || '').match(matcher);
if (matches === null) {
return null;
}
var chunk = matches[matches.length - 1];
var parts = chunk.match(chunkOffset) || ['-', '0', '0'];
var minutes = parseInt(parts[1], 10) * 60 + toInt(parts[2]);
var _min = parts[0] === '+' ? minutes : -minutes;
return minutes === 0 ? 0 : _min;
}
// Return a moment from input, that is local/utc/zone equivalent to model.
function cloneWithOffset(input, date, config) {
if (config === void 0) {
config = {};
}
if (!config._isUTC) {
return input;
}
var res = cloneDate(date);
// todo: input._d - res._d + ((res._offset || 0) - (input._offset || 0))*60000
var offsetDiff = (config._offset || 0) * 60000;
var diff = input.valueOf() - res.valueOf() + offsetDiff;
// Use low-level api, because this fn is low-level api.
res.setTime(res.valueOf() + diff);
// todo: add timezone handling
// hooks.updateOffset(res, false);
return res;
}
function getDateOffset(date) {
// On Firefox.24 Date#getTimezoneOffset returns a floating point.
// https://github.com/moment/moment/pull/1871
return -Math.round(date.getTimezoneOffset() / 15) * 15;
}
// HOOKS
// This function will be called whenever a moment is mutated.
// It is intended to keep the offset in sync with the timezone.
// todo: it's from moment timezones
// hooks.updateOffset = function () {
// };
// MOMENTS
// keepLocalTime = true means only change the timezone, without
// affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
// 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
// +0200, so we adjust the time as needed, to be valid.
//
// Keeping the time actually adds/subtracts (one hour)
// from the actual represented time. That is why we call updateOffset
// a second time. In case it wants us to change the offset again
// _changeInProgress == true case, then we have to adjust, because
// there is no such time in the given timezone.
function getUTCOffset(date, config) {
if (config === void 0) {
config = {};
}
var _offset = config._offset || 0;
return config._isUTC ? _offset : getDateOffset(date);
}
/*
export function getSetZone(input, keepLocalTime) {
if (input != null) {
if (typeof input !== 'string') {
input = -input;
}
this.utcOffset(input, keepLocalTime);
return this;
} else {
return -this.utcOffset();
}
}
*/
/*export function setOffsetToLocal(date: Date, isUTC?: boolean, keepLocalTime?: boolean) {
if (this._isUTC) {
this.utcOffset(0, keepLocalTime);
this._isUTC = false;
if (keepLocalTime) {
this.subtract(getDateOffset(this), 'm');
}
}
return this;
}*/
// DEPRECATED
/*export function isDaylightSavingTimeShifted() {
if (!isUndefined(this._isDSTShifted)) {
return this._isDSTShifted;
}
const c = {};
copyConfig(c, this);
c = prepareConfig(c);
if (c._a) {
const other = c._isUTC ? createUTC(c._a) : createLocal(c._a);
this._isDSTShifted = this.isValid() &&
compareArrays(c._a, other.toArray()) > 0;
} else {
this._isDSTShifted = false;
}
return this._isDSTShifted;
}*/
// in Khronos
/*export function isLocal() {
return this.isValid() ? !this._isUTC : false;
}
export function isUtcOffset() {
return this.isValid() ? this._isUTC : false;
}
export function isUtc() {
return this.isValid() ? this._isUTC && this._offset === 0 : false;
}*/
// FORMATTING
addFormatToken('Q', null, 'Qo', function (date, opts) {
return getQuarter(date, opts.isUTC).toString(10);
});
// ALIASES
addUnitAlias('quarter', 'Q');
// PARSING
addRegexToken('Q', match1);
addParseToken('Q', function (input, array, config) {
array[MONTH] = (toInt(input) - 1) * 3;
return config;
});
// MOMENTS
function getQuarter(date, isUTC) {
if (isUTC === void 0) {
isUTC = false;
}
return Math.ceil((getMonth(date, isUTC) + 1) / 3);
}
// export function getSetQuarter(input) {
// return input == null
// ? Math.ceil((this.month() + 1) / 3)
// : this.month((input - 1) * 3 + this.month() % 3);
// }
// FORMATTING
addFormatToken('s', ['ss', 2, false], null, function (date, opts) {
return getSeconds(date, opts.isUTC).toString(10);
});
// ALIASES
addUnitAlias('second', 's');
// PARSING
addRegexToken('s', match1to2);
addRegexToken('ss', match1to2, match2);
addParseToken(['s', 'ss'], SECOND);
// FORMATTING
addFormatToken('X', null, null, function (date) {
return unix(date).toString(10);
});
addFormatToken('x', null, null, function (date) {
return date.valueOf().toString(10);
});
// PARSING
addRegexToken('x', matchSigned);
addRegexToken('X', matchTimestamp);
addParseToken('X', function (input, array, config) {
config._d = new Date(parseFloat(input) * 1000);
return config;
});
addParseToken('x', function (input, array, config) {
config._d = new Date(toInt(input));
return config;
});
// FORMATTING
addFormatToken('w', ['ww', 2, false], 'wo', function (date, opts) {
return getWeek(date, opts.locale).toString(10);
});
addFormatToken('W', ['WW', 2, false], 'Wo', function (date) {
return getISOWeek(date).toString(10);
});
// ALIASES
addUnitAlias('week', 'w');
addUnitAlias('isoWeek', 'W');
// PARSING
addRegexToken('w', match1to2);
addRegexToken('ww', match1to2, match2);
addRegexToken('W', match1to2);
addRegexToken('WW', match1to2, match2);
addWeekParseToken(['w', 'ww', 'W', 'WW'], function (input, week, config, token) {
week[token.substr(0, 1)] = toInt(input);
return config;
});
// export function getSetWeek (input) {
// var week = this.localeData().week(this);
// return input == null ? week : this.add((input - week) * 7, 'd');
// }
function getWeek(date, locale) {
if (locale === void 0) {
locale = getLocale();
}
return locale.week(date);
}
// export function getSetISOWeek (input) {
// var week = weekOfYear(this, 1, 4).week;
// return input == null ? week : this.add((input - week) * 7, 'd');
// }
function getISOWeek(date) {
return weekOfYear(date, 1, 4).week;
}
// FORMATTING
addFormatToken(null, ['gg', 2, false], null, function (date, opts) {
// return this.weekYear() % 100;
return (getWeekYear(date, opts.locale) % 100).toString();
});
addFormatToken(null, ['GG', 2, false], null, function (date) {
// return this.isoWeekYear() % 100;
return (getISOWeekYear(date) % 100).toString();
});
function addWeekYearFormatToken(token, getter) {
addFormatToken(null, [token, token.length, false], null, getter);
}
function _getWeekYearFormatCb(date, opts) {
return getWeekYear(date, opts.locale).toString();
}
function _getISOWeekYearFormatCb(date) {
return getISOWeekYear(date).toString();
}
addWeekYearFormatToken('gggg', _getWeekYearFormatCb);
addWeekYearFormatToken('ggggg', _getWeekYearFormatCb);
addWeekYearFormatToken('GGGG', _getISOWeekYearFormatCb);
addWeekYearFormatToken('GGGGG', _getISOWeekYearFormatCb);
// ALIASES
addUnitAlias('weekYear', 'gg');
addUnitAlias('isoWeekYear', 'GG');
// PARSING
addRegexToken('G', matchSigned);
addRegexToken('g', matchSigned);
addRegexToken('GG', match1to2, match2);
addRegexToken('gg', match1to2, match2);
addRegexToken('GGGG', match1to4, match4);
addRegexToken('gggg', match1to4, match4);
addRegexToken('GGGGG', match1to6, match6);
addRegexToken('ggggg', match1to6, match6);
addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (input, week, config, token) {
week[token.substr(0, 2)] = toInt(input);
return config;
});
addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
week[token] = parseTwoDigitYear(input);
return config;
});
// MOMENTS
function getWeekYear(date, locale) {
if (locale === void 0) {
locale = getLocale();
}
return weekOfYear(date, locale.firstDayOfWeek(), locale.firstDayOfYear()).year;
}
function getISOWeekYear(date) {
return weekOfYear(date, 1, 4).year;
}
// moment.js
// version : 2.18.1
// authors : Tim Wood, Iskren Chernev, Moment.js contributors
// license : MIT
// momentjs.com
function formatDate(date, format, locale, isUTC, offset) {
if (offset === void 0) {
offset = 0;
}
var _locale = getLocale(locale || 'en');
if (!_locale) {
throw new Error("Locale \"" + locale + "\" is not defined, please add it with \"defineLocale(...)\"");
}
var _format = format || (isUTC ? 'YYYY-MM-DDTHH:mm:ss[Z]' : 'YYYY-MM-DDTHH:mm:ssZ');
var output = formatMoment(date, _format, _locale, isUTC, offset);
if (!output) {
return output;
}
return _locale.postformat(output);
}
// format date using native date object
function formatMoment(date, _format, locale, isUTC, offset) {
if (offset === void 0) {
offset = 0;
}
if (!isDateValid(date)) {
return locale.invalidDate;
}
var format = expandFormat(_format, locale);
formatFunctions[format] = formatFunctions[format] || makeFormatFunction(format);
return formatFunctions[format](date, locale, isUTC, offset);
}
function expandFormat(_format, locale) {
var format = _format;
var i = 5;
var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
var replaceLongDateFormatTokens = function (input) {
return locale.formatLongDate(input) || input;
};
localFormattingTokens.lastIndex = 0;
while (i >= 0 && localFormattingTokens.test(format)) {
format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
localFormattingTokens.lastIndex = 0;
i -= 1;
}
return format;
}
// Pick the first defined of two or three arguments.
function defaults(a, b, c) {
if (a != null) {
return a;
}
if (b != null) {
return b;
}
return c;
}
function currentDateArray(config) {
var nowValue = new Date();
if (config._useUTC) {
return [nowValue.getUTCFullYear(), nowValue.getUTCMonth(), nowValue.getUTCDate()];
}
return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()];
}
// convert an array to a date.
// the array should mirror the parameters below
// note: all values past the year are optional and will default to the lowest possible value.
// [year, month, day , hour, minute, second, millisecond]
function configFromArray(config) {
var input = [];
var i;
var date;
var currentDate;
var expectedWeekday;
var yearToUse;
if (config._d) {
return config;
}
currentDate = currentDateArray(config);
// compute day of the year from weeks and weekdays
if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
dayOfYearFromWeekInfo(config);
}
// if the day of the year is set, figure out what it is
if (config._dayOfYear != null) {
yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
if (config._dayOfYear > daysInYear(yearToUse) || config._dayOfYear === 0) {
getParsingFlags(config)._overflowDayOfYear = true;
}
date = new Date(Date.UTC(yearToUse, 0, config._dayOfYear));
config._a[MONTH] = date.getUTCMonth();
config._a[DATE] = date.getUTCDate();
}
// Default to current date.
// * if no year, month, day of month are given, default to today
// * if day of month is given, default month and year
// * if month is given, default only year
// * if year is given, don't default anything
for (i = 0; i < 3 && config._a[i] == null; ++i) {
config._a[i] = input[i] = currentDate[i];
}
// Zero out whatever was not defaulted, including time
for (; i < 7; i++) {
config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i];
}
// Check for 24:00:00.000
if (config._a[HOUR] === 24 &&
config._a[MINUTE] === 0 &&
config._a[SECOND] === 0 &&
config._a[MILLISECOND] === 0) {
config._nextDay = true;
config._a[HOUR] = 0;
}
config._d = (config._useUTC ? createUTCDate : createDate).apply(null, input);
expectedWeekday = config._useUTC ? config._d.getUTCDay() : config._d.getDay();
// Apply timezone offset from input. The actual utcOffset can be changed
// with parseZone.
if (config._tzm != null) {
config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
}
if (config._nextDay) {
config._a[HOUR] = 24;
}
// check for mismatching day of week
if (config._w && typeof config._w.d !== 'undefined' && config._w.d !== expectedWeekday) {
getParsingFlags(config).weekdayMismatch = true;
}
return config;
}
function dayOfYearFromWeekInfo(config) {
var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow;
w = config._w;
if (w.GG != null || w.W != null || w.E != null) {
dow = 1;
doy = 4;
// TODO: We need to take the current isoWeekYear, but that depends on
// how we interpret now (local, utc, fixed offset). So create
// a now version of current config (take local/utc/offset flags, and
// create now).
weekYear = defaults(w.GG, config._a[YEAR], weekOfYear(new Date(), 1, 4).year);
week = defaults(w.W, 1);
weekday = defaults(w.E, 1);
if (weekday < 1 || weekday > 7) {
weekdayOverflow = true;
}
}
else {
dow = config._locale._week.dow;
doy = config._locale._week.doy;
var curWeek = weekOfYear(new Date(), dow, doy);
weekYear = defaults(w.gg, config._a[YEAR], curWeek.year);
// Default to current week.
week = defaults(w.w, curWeek.week);
if (w.d != null) {
// weekday -- low day numbers are considered next week
weekday = w.d;
if (weekday < 0 || weekday > 6) {
weekdayOverflow = true;
}
}
else if (w.e != null) {
// local weekday -- counting starts from begining of week
weekday = w.e + dow;
if (w.e < 0 || w.e > 6) {
weekdayOverflow = true;
}
}
else {
// default to begining of week
weekday = dow;
}
}
if (week < 1 || week > weeksInYear(weekYear, dow, doy)) {
getParsingFlags(config)._overflowWeeks = true;
}
else if (weekdayOverflow != null) {
getParsingFlags(config)._overflowWeekday = true;
}
else {
temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy);
config._a[YEAR] = temp.year;
config._dayOfYear = temp.dayOfYear;
}
return config;
}
function checkOverflow(config) {
var overflow;
var a = config._a;
if (a && getParsingFlags(config).overflow === -2) {
// todo: fix this sh*t
overflow =
a[MONTH] < 0 || a[MONTH] > 11 ? MONTH :
a[DATE] < 1 || a[DATE] > daysInMonth$1(a[YEAR], a[MONTH]) ? DATE :
a[HOUR] < 0 || a[HOUR] > 24 || (a[HOUR] === 24 && (a[MINUTE] !== 0 || a[SECOND] !== 0 || a[MILLISECOND] !== 0)) ? HOUR :
a[MINUTE] < 0 || a[MINUTE] > 59 ? MINUTE :
a[SECOND] < 0 || a[SECOND] > 59 ? SECOND :
a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND :
-1;
if (getParsingFlags(config)._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
overflow = DATE;
}
if (getParsingFlags(config)._overflowWeeks && overflow === -1) {
overflow = WEEK;
}
if (getParsingFlags(config)._overflowWeekday && overflow === -1) {
overflow = WEEKDAY;
}
getParsingFlags(config).overflow = overflow;
}
return config;
}
// constant that refers to the ISO standard
// hooks.ISO_8601 = function () {};
var ISO_8601 = 'ISO_8601';
// constant that refers to the RFC 2822 form
// hooks.RFC_2822 = function () {};
var RFC_2822 = 'RFC_2822';
// date from string and format string
function configFromStringAndFormat(config) {
// TODO: Move this to another part of the creation flow to prevent circular deps
if (config._f === ISO_8601) {
return configFromISO(config);
}
if (config._f === RFC_2822) {
return configFromRFC2822(config);
}
config._a = [];
getParsingFlags(config).empty = true;
if (isArray(config._f) || (!config._i && config._i !== 0)) {
return config;
}
// This array is used to make a Date, either with `new Date` or `Date.UTC`
var input = config._i.toString();
var totalParsedInputLength = 0;
var inputLength = input.length;
var tokens = expandFormat(config._f, config._locale).match(formattingTokens) || [];
var i;
var token;
var parsedInput;
var skipped;
for (i = 0; i < tokens.length; i++) {
token = tokens[i];
parsedInput = (input.match(getParseRegexForToken(token, config._locale)) || [])[0];
if (parsedInput) {
skipped = input.substr(0, input.indexOf(parsedInput));
if (skipped.length > 0) {
getParsingFlags(config).unusedInput.push(skipped);
}
input = input.slice(input.indexOf(parsedInput) + parsedInput.length);
totalParsedInputLength += parsedInput.length;
}
// don't parse if it's not a known token
if (formatTokenFunctions[token]) {
if (parsedInput) {
getParsingFlags(config).empty = false;
}
else {
getParsingFlags(config).unusedTokens.push(token);
}
addTimeToArrayFromToken(token, parsedInput, config);
}
else if (config._strict && !parsedInput) {
getParsingFlags(config).unusedTokens.push(token);
}
}
// add remaining unparsed input length to the string
getParsingFlags(config).charsLeftOver = inputLength - totalParsedInputLength;
if (input.length > 0) {
getParsingFlags(config).unusedInput.push(input);
}
// clear _12h flag if hour is <= 12
if (config._a[HOUR] <= 12 &&
getParsingFlags(config).bigHour === true &&
config._a[HOUR] > 0) {
getParsingFlags(config).bigHour = void 0;
}
getParsingFlags(config).parsedDateParts = config._a.slice(0);
getParsingFlags(config).meridiem = config._meridiem;
// handle meridiem
config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
configFromArray(config);
return checkOverflow(config);
}
function meridiemFixWrap(locale, _hour, meridiem) {
var hour = _hour;
if (meridiem == null) {
// nothing to do
return hour;
}
if (locale.meridiemHour != null) {
return locale.meridiemHour(hour, meridiem);
}
if (locale.isPM == null) {
// this is not supposed to happen
return hour;
}
// Fallback
var isPm = locale.isPM(meridiem);
if (isPm && hour < 12) {
hour += 12;
}
if (!isPm && hour === 12) {
hour = 0;
}
return hour;
}
// date from string and array of format strings
function configFromStringAndArray(config) {
var tempConfig;
var bestMoment;
var scoreToBeat;
var currentScore;
if (!config._f || config._f.length === 0) {
getParsingFlags(config).invalidFormat = true;
return createInvalid(config);
}
var i;
for (i = 0; i < config._f.length; i++) {
currentScore = 0;
tempConfig = Object.assign({}, config);
if (config._useUTC != null) {
tempConfig._useUTC = config._useUTC;
}
tempConfig._f = config._f[i];
configFromStringAndFormat(tempConfig);
if (!isValid(tempConfig)) {
continue;
}
// if there is any input that was not parsed add a penalty for that format
currentScore += getParsingFlags(tempConfig).charsLeftOver;
// or tokens
currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
getParsingFlags(tempConfig).score = currentScore;
if (scoreToBeat == null || currentScore < scoreToBeat) {
scoreToBeat = currentScore;
bestMoment = tempConfig;
}
}
return Object.assign(config, bestMoment || tempConfig);
}
function configFromObject(config) {
if (config._d) {
return config;
}
var input = config._i;
if (isObject(input)) {
var i = normalizeObjectUnits(input);
config._a = [i.year, i.month, i.day, i.hours, i.minutes, i.seconds, i.milliseconds]
.map(function (obj) { return isString(obj) ? parseInt(obj, 10) : obj; });
}
return configFromArray(config);
}
// tslint:disable:max-line-length
function createFromConfig(config) {
var res = checkOverflow(prepareConfig(config));
// todo: remove, in moment.js it's never called cuz of moment constructor
res._d = new Date(res._d != null ? res._d.getTime() : NaN);
if (!isValid(Object.assign({}, res, { _isValid: null }))) {
res._d = new Date(NaN);
}
// todo: update offset
/*if (res._nextDay) {
// Adding is smart enough around DST
res._d = add(res._d, 1, 'day');
res._nextDay = undefined;
}*/
return res;
}
function prepareConfig(config) {
var input = config._i;
var format = config._f;
config._locale = config._locale || getLocale(config._l);
if (input === null || (format === undefined && input === '')) {
return createInvalid(config, { nullInput: true });
}
if (isString(input)) {
config._i = input = config._locale.preparse(input);
}
if (isDate_2(input)) {
config._d = cloneDate(input);
return config;
}
// todo: add check for recursion
if (isArray(format)) {
configFromStringAndArray(config);
}
else if (format) {
configFromStringAndFormat(config);
}
else {
configFromInput(config);
}
if (!isValid(config)) {
config._d = null;
}
return config;
}
function configFromInput(config) {
var input = config._i;
if (isUndefined(input)) {
config._d = new Date();
}
else if (isDate_2(input)) {
config._d = cloneDate(input);
}
else if (isString(input)) {
configFromString(config);
}
else if (isArray(input) && input.length) {
var _arr = input.slice(0);
config._a = _arr.map(function (obj) { return isString(obj) ? parseInt(obj, 10) : obj; });
configFromArray(config);
}
else if (isObject(input)) {
configFromObject(config);
}
else if (isNumber(input)) {
// from milliseconds
config._d = new Date(input);
}
else {
// hooks.createFromInputFallback(config);
return createInvalid(config);
}
return config;
}
function createLocalOrUTC(input, format, localeKey, strict, isUTC) {
var config = {};
var _input = input;
// params switch -> skip; test it well
// if (localeKey === true || localeKey === false) {
// strict = localeKey;
// localeKey = undefined;
// }
// todo: fail fast and return not valid date
if ((isObject(_input) && isObjectEmpty(_input)) || (isArray(_input) && _input.length === 0)) {
_input = undefined;
}
// object construction must be done this way.
// https://github.com/moment/moment/issues/1423
// config._isAMomentObject = true;
config._useUTC = config._isUTC = isUTC;
config._l = localeKey;
config._i = _input;
config._f = format;
config._strict = strict;
return createFromConfig(config);
}
function parseDate(input, format, localeKey, strict, isUTC) {
if (isDate(input)) {
return input;
}
var config = createLocalOrUTC(input, format, localeKey, strict, isUTC);
return config._d;
}
function absRound(num) {
return num < 0 ? Math.round(num * -1) * -1 : Math.round(num);
}
function isAfter(date1, date2, units) {
if (units === void 0) {
units = 'milliseconds';
}
if (!date1 || !date2) {
return false;
}
if (units === 'milliseconds') {
return date1.valueOf() > date2.valueOf();
}
return date2.valueOf() < startOf(date1, units).valueOf();
}
function isBefore(date1, date2, units) {
if (units === void 0) {
units = 'milliseconds';
}
if (!date1 || !date2) {
return false;
}
if (units === 'milliseconds') {
return date1.valueOf() < date2.valueOf();
}
return endOf(date1, units).valueOf() < date2.valueOf();
}
// ASP.NET json date format regex
var aspNetRegex = /^(\-|\+)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/;
// from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
// somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
// and further modified to allow for strings containing both week and day
// tslint:disable-next-line
var isoRegex = /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;
function createDuration(input, key, config) {
if (config === void 0) {
config = {};
}
var duration = convertDuration(input, key);
// matching against regexp is expensive, do it on demand
return new Duration(duration, config);
}
function convertDuration(input, key) {
// checks for null or undefined
if (input == null) {
return {};
}
if (isDuration(input)) {
return {
milliseconds: input._milliseconds,
day: input._days,
month: input._months
};
}
if (isNumber(input)) {
// duration = {};
return key ? (_a = {}, _a[key] = input, _a) : { milliseconds: input };
}
if (isString(input)) {
var match = aspNetRegex.exec(input);
if (match) {
var sign = (match[1] === '-') ? -1 : 1;
return {
year: 0,
day: toInt(match[DATE]) * sign,
hours: toInt(match[HOUR]) * sign,
minutes: toInt(match[MINUTE]) * sign,
seconds: toInt(match[SECOND]) * sign,
// the millisecond decimal point is included in the match
milliseconds: toInt(absRound(toInt(match[MILLISECOND]) * 1000)) * sign
};
}
match = isoRegex.exec(input);
if (match) {
var sign = (match[1] === '-') ? -1 : (match[1] === '+') ? 1 : 1;
return {
year: parseIso(match[2], sign),
month: parseIso(match[3], sign),
week: parseIso(match[4], sign),
day: parseIso(match[5], sign),
hours: parseIso(match[6], sign),
minutes: parseIso(match[7], sign),
seconds: parseIso(match[8], sign)
};
}
}
if (isObject(input) && ('from' in input || 'to' in input)) {
var diffRes = momentsDifference(parseDate(input.from), parseDate(input.to));
return {
milliseconds: diffRes.milliseconds,
month: diffRes.months
};
}
return input;
var _a;
}
// createDuration.fn = Duration.prototype;
// createDuration.invalid = invalid;
function parseIso(inp, sign) {
// We'd normally use ~~inp for this, but unfortunately it also
// converts floats to ints.
// inp may be undefined, so careful calling replace on it.
var res = inp && parseFloat(inp.replace(',', '.'));
// apply sign while we're at it
return (isNaN(res) ? 0 : res) * sign;
}
function positiveMomentsDifference(base, other) {
var res = { milliseconds: 0, months: 0 };
res.months = getMonth(other) - getMonth(base) +
(getFullYear(other) - getFullYear(base)) * 12;
var _basePlus = add(cloneDate(base), res.months, 'month');
if (isAfter(_basePlus, other)) {
--res.months;
}
res.milliseconds = +other - +(add(cloneDate(base), res.months, 'month'));
return res;
}
function momentsDifference(base, other) {
if (!(isDateValid(base) && isDateValid(other))) {
return { milliseconds: 0, months: 0 };
}
var res;
var _other = cloneWithOffset(other, base, { _offset: base.getTimezoneOffset() });
if (isBefore(base, _other)) {
res = positiveMomentsDifference(base, _other);
}
else {
res = positiveMomentsDifference(_other, base);
res.milliseconds = -res.milliseconds;
res.months = -res.months;
}
return res;
}
function add(date, val, period, isUTC) {
var dur = createDuration(val, period);
return addSubtract(date, dur, 1, isUTC);
}
function subtract(date, val, period, isUTC) {
var dur = createDuration(val, period);
return addSubtract(date, dur, -1, isUTC);
}
function addSubtract(date, duration, isAdding, isUTC) {
var milliseconds = duration._milliseconds;
var days = absRound(duration._days);
var months = absRound(duration._months);
// todo: add timezones support
// const _updateOffset = updateOffset == null ? true : updateOffset;
if (months) {
setMonth(date, getMonth(date, isUTC) + months * isAdding, isUTC);
}
if (days) {
setDate(date, getDate(date, isUTC) + days * isAdding, isUTC);
}
if (milliseconds) {
setTime(date, getTime(date) + milliseconds * isAdding);
}
return cloneDate(date);
// todo: add timezones support
// if (_updateOffset) {
// hooks.updateOffset(date, days || months);
// }
}
// FORMATTING
addFormatToken('d', null, 'do', function (date, opts) {
return getDay(date, opts.isUTC).toString(10);
});
addFormatToken('dd', null, null, function (date, opts) {
return opts.locale.weekdaysMin(date, opts.format, opts.isUTC);
});
addFormatToken('ddd', null, null, function (date, opts) {
return opts.locale.weekdaysShort(date, opts.format, opts.isUTC);
});
addFormatToken('dddd', null, null, function (date, opts) {
return opts.locale.weekdays(date, opts.format, opts.isUTC);
});
addFormatToken('e', null, null, function (date, opts) {
return getLocaleDayOfWeek(date, opts.locale, opts.isUTC).toString(10);
// return getDay(date, opts.isUTC).toString(10);
});
addFormatToken('E', null, null, function (date, opts) {
return getISODayOfWeek(date, opts.isUTC).toString(10);
});
// ALIASES
addUnitAlias('day', 'd');
addUnitAlias('weekday', 'e');
addUnitAlias('isoWeekday', 'E');
// PARSING
addRegexToken('d', match1to2);
addRegexToken('e', match1to2);
addRegexToken('E', match1to2);
addRegexToken('dd', function (isStrict, locale) {
return locale.weekdaysMinRegex(isStrict);
});
addRegexToken('ddd', function (isStrict, locale) {
return locale.weekdaysShortRegex(isStrict);
});
addRegexToken('dddd', function (isStrict, locale) {
return locale.weekdaysRegex(isStrict);
});
addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {
var weekday = config._locale.weekdaysParse(input, token, config._strict);
// if we didn't get a weekday name, mark the date as invalid
if (weekday != null) {
week.d = weekday;
}
else {
getParsingFlags(config).invalidWeekday = !!input;
}
return config;
});
addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
week[token] = toInt(input);
return config;
});
// HELPERS
function parseWeekday(input, locale) {
if (!isString(input)) {
return input;
}
var _num = parseInt(input, 10);
if (!isNaN(_num)) {
return _num;
}
var _weekDay = locale.weekdaysParse(input);
if (isNumber(_weekDay)) {
return _weekDay;
}
return null;
}
function parseIsoWeekday(input, locale) {
if (locale === void 0) {
locale = getLocale();
}
if (isString(input)) {
return locale.weekdaysParse(input) % 7 || 7;
}
return isNumber(input) && isNaN(input) ? null : input;
}
// MOMENTS
function setDayOfWeek(date, input, locale, isUTC) {
if (locale === void 0) {
locale = getLocale();
}
var day = getDay(date, isUTC);
var _input = parseWeekday(input, locale);
return add(date, _input - day, 'day');
}
function getDayOfWeek(date, isUTC) {
return getDay(date, isUTC);
}
/********************************************/
// todo: utc
// getSetLocaleDayOfWeek
function getLocaleDayOfWeek(date, locale, isUTC) {
if (locale === void 0) {
locale = getLocale();
}
return (getDay(date, isUTC) + 7 - locale.firstDayOfWeek()) % 7;
}
function setLocaleDayOfWeek(date, input, opts) {
if (opts === void 0) {
opts = {};
}
var weekday = getLocaleDayOfWeek(date, opts.locale, opts.isUTC);
return add(date, input - weekday, 'day');
}
// getSetISODayOfWeek
function getISODayOfWeek(date, isUTC) {
return getDay(date, isUTC) || 7;
}
function setISODayOfWeek(date, input, opts) {
// behaves the same as moment#day except
// as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
// as a setter, sunday should belong to the previous week.
if (opts === void 0) {
opts = {};
}
var weekday = parseIsoWeekday(input, opts.locale);
return setDayOfWeek(date, getDayOfWeek(date) % 7 ? weekday : weekday - 7);
}
function startOf(date, unit, isUTC) {
var _date = cloneDate(date);
// the following switch intentionally omits break keywords
// to utilize falling through the cases.
switch (unit) {
case 'year':
setMonth(_date, 0, isUTC);
/* falls through */
case 'quarter':
case 'month':
setDate(_date, 1, isUTC);
/* falls through */
case 'week':
case 'isoWeek':
case 'day':
case 'date':
setHours(_date, 0, isUTC);
/* falls through */
case 'hours':
setMinutes(_date, 0, isUTC);
/* falls through */
case 'minutes':
setSeconds(_date, 0, isUTC);
/* falls through */
case 'seconds':
setMilliseconds(_date, 0, isUTC);
}
// weeks are a special case
if (unit === 'week') {
setLocaleDayOfWeek(_date, 0, { isUTC: isUTC });
}
if (unit === 'isoWeek') {
setISODayOfWeek(_date, 1);
}
// quarters are also special
if (unit === 'quarter') {
setMonth(_date, Math.floor(getMonth(_date, isUTC) / 3) * 3, isUTC);
}
return _date;
}
function endOf(date, unit, isUTC) {
var _unit = unit;
// 'date' is an alias for 'day', so it should be considered as such.
if (_unit === 'date') {
_unit = 'day';
}
var start = startOf(date, _unit, isUTC);
var _step = add(start, 1, _unit === 'isoWeek' ? 'week' : _unit, isUTC);
var res = subtract(_step, 1, 'milliseconds', isUTC);
return res;
}
// FORMATTING
addFormatToken('DDD', ['DDDD', 3, false], 'DDDo', function (date) {
return getDayOfYear(date).toString(10);
});
// ALIASES
addUnitAlias('dayOfYear', 'DDD');
addRegexToken('DDD', match1to3);
addRegexToken('DDDD', match3);
addParseToken(['DDD', 'DDDD'], function (input, array, config) {
config._dayOfYear = toInt(input);
return config;
});
function getDayOfYear(date) {
var date1 = +startOf(date, 'day');
var date2 = +startOf(date, 'year');
var someDate = date1 - date2;
var oneDay = 1000 * 60 * 60 * 24;
return Math.round(someDate / oneDay) + 1;
}
/**
*
* @param {number} year
* @param {number} dow - start-of-first-week
* @param {number} doy - start-of-year
* @returns {number}
*/
function firstWeekOffset(year, dow, doy) {
// first-week day -- which january is always in the first week (4 for iso, 1 for other)
var fwd = dow - doy + 7;
// first-week day local weekday -- which local weekday is fwd
var fwdlw = (createUTCDate(year, 0, fwd).getUTCDay() - dow + 7) % 7;
return -fwdlw + fwd - 1;
}
// https://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
var localWeekday = (7 + weekday - dow) % 7;
var weekOffset = firstWeekOffset(year, dow, doy);
var dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset;
var resYear;
var resDayOfYear;
if (dayOfYear <= 0) {
resYear = year - 1;
resDayOfYear = daysInYear(resYear) + dayOfYear;
}
else if (dayOfYear > daysInYear(year)) {
resYear = year + 1;
resDayOfYear = dayOfYear - daysInYear(year);
}
else {
resYear = year;
resDayOfYear = dayOfYear;
}
return {
year: resYear,
dayOfYear: resDayOfYear
};
}
function weekOfYear(date, dow, doy) {
var weekOffset = firstWeekOffset(getFullYear(date), dow, doy);
var week = Math.floor((getDayOfYear(date) - weekOffset - 1) / 7) + 1;
var resWeek;
var resYear;
if (week < 1) {
resYear = getFullYear(date) - 1;
resWeek = week + weeksInYear(resYear, dow, doy);
}
else if (week > weeksInYear(getFullYear(date), dow, doy)) {
resWeek = week - weeksInYear(getFullYear(date), dow, doy);
resYear = getFullYear(date) + 1;
}
else {
resYear = getFullYear(date);
resWeek = week;
}
return {
week: resWeek,
year: resYear
};
}
function weeksInYear(year, dow, doy) {
var weekOffset = firstWeekOffset(year, dow, doy);
var weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
}
// tslint:disable:max-file-line-count max-line-length cyclomatic-complexity
var MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/;
var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_');
var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_');
var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
var defaultLongDateFormat = {
LTS: 'h:mm:ss A',
LT: 'h:mm A',
L: 'MM/DD/YYYY',
LL: 'MMMM D, YYYY',
LLL: 'MMMM D, YYYY h:mm A',
LLLL: 'dddd, MMMM D, YYYY h:mm A'
};
var defaultOrdinal = '%d';
var defaultDayOfMonthOrdinalParse = /\d{1,2}/;
var defaultMonthsShortRegex = matchWord;
var defaultMonthsRegex = matchWord;
var Locale = (function () {
function Locale(config) {
if (!!config) {
this.set(config);
}
}
Locale.prototype.set = function (config) {
var confKey;
for (confKey in config) {
if (!config.hasOwnProperty(confKey)) {
continue;
}
var prop = config[confKey];
var key = (isFunction(prop) ? confKey : "_" + confKey);
this[key] = prop;
}
this._config = config;
};
Locale.prototype.calendar = function (key, date, now) {
var output = this._calendar[key] || this._calendar.sameElse;
return isFunction(output) ? output.call(null, date, now) : output;
};
Locale.prototype.longDateFormat = function (key) {
var format = this._longDateFormat[key];
var formatUpper = this._longDateFormat[key.toUpperCase()];
if (format || !formatUpper) {
return format;
}
this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g, function (val) {
return val.slice(1);
});
return this._longDateFormat[key];
};
Object.defineProperty(Locale.prototype, "invalidDate", {
get: function () {
return this._invalidDate;
},
set: function (val) {
this._invalidDate = val;
},
enumerable: true,
configurable: true
});
Locale.prototype.ordinal = function (num, token) {
return this._ordinal.replace('%d', num.toString(10));
};
Locale.prototype.preparse = function (str) {
return str;
};
Locale.prototype.postformat = function (str) {
return str;
};
Locale.prototype.relativeTime = function (num, withoutSuffix, str, isFuture) {
var output = this._relativeTime[str];
return (isFunction(output)) ?
output(num, withoutSuffix, str, isFuture) :
output.replace(/%d/i, num.toString(10));
};
Locale.prototype.pastFuture = function (diff, output) {
var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
return isFunction(format) ? format(output) : format.replace(/%s/i, output);
};
Locale.prototype.months = function (date, format, isUTC) {
if (isUTC === void 0) {
isUTC = false;
}
if (!date) {
return isArray(this._months)
? this._months
: this._months.standalone;
}
if (isArray(this._months)) {
return this._months[getMonth(date, isUTC)];
}
var key = (this._months.isFormat || MONTHS_IN_FORMAT).test(format)
? 'format'
: 'standalone';
return this._months[key][getMonth(date, isUTC)];
};
Locale.prototype.monthsShort = function (date, format, isUTC) {
if (isUTC === void 0) {
isUTC = false;
}
if (!date) {
return isArray(this._monthsShort)
? this._monthsShort
: this._monthsShort.standalone;
}
if (isArray(this._monthsShort)) {
return this._monthsShort[getMonth(date, isUTC)];
}
var key = MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone';
return this._monthsShort[key][getMonth(date, isUTC)];
};
Locale.prototype.monthsParse = function (monthName, format, strict) {
var date;
var regex;
if (this._monthsParseExact) {
return this.handleMonthStrictParse(monthName, format, strict);
}
if (!this._monthsParse) {
this._monthsParse = [];
this._longMonthsParse = [];
this._shortMonthsParse = [];
}
// TODO: add sorting
// Sorting makes sure if one month (or abbr) is a prefix of another
// see sorting in computeMonthsParse
var i;
for (i = 0; i < 12; i++) {
// make the regex if we don't have it already
date = new Date(Date.UTC(2000, i));
if (strict && !this._longMonthsParse[i]) {
var _months = this.months(date, '').replace('.', '');
var _shortMonths = this.monthsShort(date, '').replace('.', '');
this._longMonthsParse[i] = new RegExp("^" + _months + "$", 'i');
this._shortMonthsParse[i] = new RegExp("^" + _shortMonths + "$", 'i');
}
if (!strict && !this._monthsParse[i]) {
regex = "^" + this.months(date, '') + "|^" + this.monthsShort(date, '');
this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
}
// test the regex
if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) {
return i;
}
if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) {
return i;
}
if (!strict && this._monthsParse[i].test(monthName)) {
return i;
}
}
};
Locale.prototype.monthsRegex = function (isStrict) {
if (this._monthsParseExact) {
if (!hasOwnProp(this, '_monthsRegex')) {
this.computeMonthsParse();
}
if (isStrict) {
return this._monthsStrictRegex;
}
return this._monthsRegex;
}
if (!hasOwnProp(this, '_monthsRegex')) {
this._monthsRegex = defaultMonthsRegex;
}
return this._monthsStrictRegex && isStrict ?
this._monthsStrictRegex : this._monthsRegex;
};
Locale.prototype.monthsShortRegex = function (isStrict) {
if (this._monthsParseExact) {
if (!hasOwnProp(this, '_monthsRegex')) {
this.computeMonthsParse();
}
if (isStrict) {
return this._monthsShortStrictRegex;
}
return this._monthsShortRegex;
}
if (!hasOwnProp(this, '_monthsShortRegex')) {
this._monthsShortRegex = defaultMonthsShortRegex;
}
return this._monthsShortStrictRegex && isStrict ?
this._monthsShortStrictRegex : this._monthsShortRegex;
};
/** Week */
Locale.prototype.week = function (date) {
return weekOfYear(date, this._week.dow, this._week.doy).week;
};
Locale.prototype.firstDayOfWeek = function () {
return this._week.dow;
};
Locale.prototype.firstDayOfYear = function () {
return this._week.doy;
};
Locale.prototype.weekdays = function (date, format, isUTC) {
if (!date) {
return isArray(this._weekdays)
? this._weekdays
: this._weekdays.standalone;
}
if (isArray(this._weekdays)) {
return this._weekdays[getDay(date, isUTC)];
}
var _key = this._weekdays.isFormat.test(format)
? 'format'
: 'standalone';
return this._weekdays[_key][getDay(date, isUTC)];
};
Locale.prototype.weekdaysMin = function (date, format, isUTC) {
return date ? this._weekdaysMin[getDay(date, isUTC)] : this._weekdaysMin;
};
Locale.prototype.weekdaysShort = function (date, format, isUTC) {
return date ? this._weekdaysShort[getDay(date, isUTC)] : this._weekdaysShort;
};
// proto.weekdaysParse = localeWeekdaysParse;
Locale.prototype.weekdaysParse = function (weekdayName, format, strict) {
var i;
var regex;
if (this._weekdaysParseExact) {
return this.handleWeekStrictParse(weekdayName, format, strict);
}
if (!this._weekdaysParse) {
this._weekdaysParse = [];
this._minWeekdaysParse = [];
this._shortWeekdaysParse = [];
this._fullWeekdaysParse = [];
}
for (i = 0; i < 7; i++) {
// make the regex if we don't have it already
// fix: here is the issue
var date = setDayOfWeek(new Date(Date.UTC(2000, 1)), i, null, true);
if (strict && !this._fullWeekdaysParse[i]) {
this._fullWeekdaysParse[i] = new RegExp("^" + this.weekdays(date, '').replace('.', '\.?') + "$", 'i');
this._shortWeekdaysParse[i] = new RegExp("^" + this.weekdaysShort(date).replace('.', '\.?') + "$", 'i');
this._minWeekdaysParse[i] = new RegExp("^" + this.weekdaysMin(date).replace('.', '\.?') + "$", 'i');
}
if (!this._weekdaysParse[i]) {
regex = "^" + this.weekdays(date, '') + "|^" + this.weekdaysShort(date) + "|^" + this.weekdaysMin(date);
this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
}
if (!isArray(this._fullWeekdaysParse)
|| !isArray(this._shortWeekdaysParse)
|| !isArray(this._minWeekdaysParse)
|| !isArray(this._weekdaysParse)) {
return;
}
// test the regex
if (strict && format === 'dddd' && this._fullWeekdaysParse[i].test(weekdayName)) {
return i;
}
else if (strict && format === 'ddd' && this._shortWeekdaysParse[i].test(weekdayName)) {
return i;
}
else if (strict && format === 'dd' && this._minWeekdaysParse[i].test(weekdayName)) {
return i;
}
else if (!strict && this._weekdaysParse[i].test(weekdayName)) {
return i;
}
}
};
// proto.weekdaysRegex = weekdaysRegex;
Locale.prototype.weekdaysRegex = function (isStrict) {
if (this._weekdaysParseExact) {
if (!hasOwnProp(this, '_weekdaysRegex')) {
this.computeWeekdaysParse();
}
if (isStrict) {
return this._weekdaysStrictRegex;
}
else {
return this._weekdaysRegex;
}
}
else {
if (!hasOwnProp(this, '_weekdaysRegex')) {
this._weekdaysRegex = matchWord;
}
return this._weekdaysStrictRegex && isStrict ?
this._weekdaysStrictRegex : this._weekdaysRegex;
}
};
// proto.weekdaysShortRegex = weekdaysShortRegex;
// proto.weekdaysMinRegex = weekdaysMinRegex;
Locale.prototype.weekdaysShortRegex = function (isStrict) {
if (this._weekdaysParseExact) {
if (!hasOwnProp(this, '_weekdaysRegex')) {
this.computeWeekdaysParse();
}
if (isStrict) {
return this._weekdaysShortStrictRegex;
}
else {
return this._weekdaysShortRegex;
}
}
else {
if (!hasOwnProp(this, '_weekdaysShortRegex')) {
this._weekdaysShortRegex = matchWord;
}
return this._weekdaysShortStrictRegex && isStrict ?
this._weekdaysShortStrictRegex : this._weekdaysShortRegex;
}
};
Locale.prototype.weekdaysMinRegex = function (isStrict) {
if (this._weekdaysParseExact) {
if (!hasOwnProp(this, '_weekdaysRegex')) {
this.computeWeekdaysParse();
}
if (isStrict) {
return this._weekdaysMinStrictRegex;
}
else {
return this._weekdaysMinRegex;
}
}
else {
if (!hasOwnProp(this, '_weekdaysMinRegex')) {
this._weekdaysMinRegex = matchWord;
}
return this._weekdaysMinStrictRegex && isStrict ?
this._weekdaysMinStrictRegex : this._weekdaysMinRegex;
}
};
Locale.prototype.isPM = function (input) {
// IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
// Using charAt should be more compatible.
return input.toLowerCase().charAt(0) === 'p';
};
Locale.prototype.meridiem = function (hours, minutes, isLower) {
if (hours > 11) {
return isLower ? 'pm' : 'PM';
}
return isLower ? 'am' : 'AM';
};
Locale.prototype.formatLongDate = function (key) {
this._longDateFormat = this._longDateFormat ? this._longDateFormat : defaultLongDateFormat;
var format = this._longDateFormat[key];
var formatUpper = this._longDateFormat[key.toUpperCase()];
if (format || !formatUpper) {
return format;
}
this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g, function (val) {
return val.slice(1);
});
return this._longDateFormat[key];
};
Locale.prototype.handleMonthStrictParse = function (monthName, format, strict) {
var llc = monthName.toLocaleLowerCase();
var i;
var ii;
var mom;
if (!this._monthsParse) {
// this is not used
this._monthsParse = [];
this._longMonthsParse = [];
this._shortMonthsParse = [];
for (i = 0; i < 12; ++i) {
mom = new Date(2000, i);
this._shortMonthsParse[i] = this.monthsShort(mom, '').toLocaleLowerCase();
this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase();
}
}
if (strict) {
if (format === 'MMM') {
ii = this._shortMonthsParse.indexOf(llc);
return ii !== -1 ? ii : null;
}
ii = this._longMonthsParse.indexOf(llc);
return ii !== -1 ? ii : null;
}
if (format === 'MMM') {
ii = this._shortMonthsParse.indexOf(llc);
if (ii !== -1) {
return ii;
}
ii = this._longMonthsParse.indexOf(llc);
return ii !== -1 ? ii : null;
}
ii = this._longMonthsParse.indexOf(llc);
if (ii !== -1) {
return ii;
}
ii = this._shortMonthsParse.indexOf(llc);
return ii !== -1 ? ii : null;
};
Locale.prototype.handleWeekStrictParse = function (weekdayName, format, strict) {
var ii;
var llc = weekdayName.toLocaleLowerCase();
if (!this._weekdaysParse) {
this._weekdaysParse = [];
this._shortWeekdaysParse = [];
this._minWeekdaysParse = [];
var i = void 0;
for (i = 0; i < 7; ++i) {
var date = setDayOfWeek(new Date(Date.UTC(2000, 1)), i, null, true);
this._minWeekdaysParse[i] = this.weekdaysMin(date).toLocaleLowerCase();
this._shortWeekdaysParse[i] = this.weekdaysShort(date).toLocaleLowerCase();
this._weekdaysParse[i] = this.weekdays(date, '').toLocaleLowerCase();
}
}
if (!isArray(this._weekdaysParse)
|| !isArray(this._shortWeekdaysParse)
|| !isArray(this._minWeekdaysParse)) {
return;
}
if (strict) {
if (format === 'dddd') {
ii = this._weekdaysParse.indexOf(llc);
return ii !== -1 ? ii : null;
}
else if (format === 'ddd') {
ii = this._shortWeekdaysParse.indexOf(llc);
return ii !== -1 ? ii : null;
}
else {
ii = this._minWeekdaysParse.indexOf(llc);
return ii !== -1 ? ii : null;
}
}
else {
if (format === 'dddd') {
ii = this._weekdaysParse.indexOf(llc);
if (ii !== -1) {
return ii;
}
ii = this._shortWeekdaysParse.indexOf(llc);
if (ii !== -1) {
return ii;
}
ii = this._minWeekdaysParse.indexOf(llc);
return ii !== -1 ? ii : null;
}
else if (format === 'ddd') {
ii = this._shortWeekdaysParse.indexOf(llc);
if (ii !== -1) {
return ii;
}
ii = this._weekdaysParse.indexOf(llc);
if (ii !== -1) {
return ii;
}
ii = this._minWeekdaysParse.indexOf(llc);
return ii !== -1 ? ii : null;
}
else {
ii = this._minWeekdaysParse.indexOf(llc);
if (ii !== -1) {
return ii;
}
ii = this._weekdaysParse.indexOf(llc);
if (ii !== -1) {
return ii;
}
ii = this._shortWeekdaysParse.indexOf(llc);
return ii !== -1 ? ii : null;
}
}
};
Locale.prototype.computeMonthsParse = function () {
var shortPieces = [];
var longPieces = [];
var mixedPieces = [];
var date;
var i;
for (i = 0; i < 12; i++) {
// make the regex if we don't have it already
date = new Date(2000, i);
shortPieces.push(this.monthsShort(date, ''));
longPieces.push(this.months(date, ''));
mixedPieces.push(this.months(date, ''));
mixedPieces.push(this.monthsShort(date, ''));
}
// Sorting makes sure if one month (or abbr) is a prefix of another it
// will match the longer piece.
shortPieces.sort(cmpLenRev);
longPieces.sort(cmpLenRev);
mixedPieces.sort(cmpLenRev);
for (i = 0; i < 12; i++) {
shortPieces[i] = regexEscape(shortPieces[i]);
longPieces[i] = regexEscape(longPieces[i]);
}
for (i = 0; i < 24; i++) {
mixedPieces[i] = regexEscape(mixedPieces[i]);
}
this._monthsRegex = new RegExp("^(" + mixedPieces.join('|') + ")", 'i');
this._monthsShortRegex = this._monthsRegex;
this._monthsStrictRegex = new RegExp("^(" + longPieces.join('|') + ")", 'i');
this._monthsShortStrictRegex = new RegExp("^(" + shortPieces.join('|') + ")", 'i');
};
Locale.prototype.computeWeekdaysParse = function () {
var minPieces = [];
var shortPieces = [];
var longPieces = [];
var mixedPieces = [];
var i;
for (i = 0; i < 7; i++) {
// make the regex if we don't have it already
// let mom = createUTC([2000, 1]).day(i);
var date = setDayOfWeek(new Date(Date.UTC(2000, 1)), i, null, true);
var minp = this.weekdaysMin(date);
var shortp = this.weekdaysShort(date);
var longp = this.weekdays(date);
minPieces.push(minp);
shortPieces.push(shortp);
longPieces.push(longp);
mixedPieces.push(minp);
mixedPieces.push(shortp);
mixedPieces.push(longp);
}
// Sorting makes sure if one weekday (or abbr) is a prefix of another it
// will match the longer piece.
minPieces.sort(cmpLenRev);
shortPieces.sort(cmpLenRev);
longPieces.sort(cmpLenRev);
mixedPieces.sort(cmpLenRev);
for (i = 0; i < 7; i++) {
shortPieces[i] = regexEscape(shortPieces[i]);
longPieces[i] = regexEscape(longPieces[i]);
mixedPieces[i] = regexEscape(mixedPieces[i]);
}
this._weekdaysRegex = new RegExp("^(" + mixedPieces.join('|') + ")", 'i');
this._weekdaysShortRegex = this._weekdaysRegex;
this._weekdaysMinRegex = this._weekdaysRegex;
this._weekdaysStrictRegex = new RegExp("^(" + longPieces.join('|') + ")", 'i');
this._weekdaysShortStrictRegex = new RegExp("^(" + shortPieces.join('|') + ")", 'i');
this._weekdaysMinStrictRegex = new RegExp("^(" + minPieces.join('|') + ")", 'i');
};
return Locale;
}());
function cmpLenRev(a, b) {
return b.length - a.length;
}
var defaultCalendar = {
sameDay: '[Today at] LT',
nextDay: '[Tomorrow at] LT',
nextWeek: 'dddd [at] LT',
lastDay: '[Yesterday at] LT',
lastWeek: '[Last] dddd [at] LT',
sameElse: 'L'
};
var defaultInvalidDate = 'Invalid date';
var defaultLocaleWeek = {
dow: 0,
doy: 6 // The week that contains Jan 1st is the first week of the year.
};
var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i;
var defaultRelativeTime = {
future: 'in %s',
past: '%s ago',
s: 'a few seconds',
ss: '%d seconds',
m: 'a minute',
mm: '%d minutes',
h: 'an hour',
hh: '%d hours',
d: 'a day',
dd: '%d days',
M: 'a month',
MM: '%d months',
y: 'a year',
yy: '%d years'
};
var baseConfig = {
calendar: defaultCalendar,
longDateFormat: defaultLongDateFormat,
invalidDate: defaultInvalidDate,
ordinal: defaultOrdinal,
dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse,
relativeTime: defaultRelativeTime,
months: defaultLocaleMonths,
monthsShort: defaultLocaleMonthsShort,
week: defaultLocaleWeek,
weekdays: defaultLocaleWeekdays,
weekdaysMin: defaultLocaleWeekdaysMin,
weekdaysShort: defaultLocaleWeekdaysShort,
meridiemParse: defaultLocaleMeridiemParse
};
// compare two arrays, return the number of differences
function compareArrays(array1, array2, dontConvert) {
var len = Math.min(array1.length, array2.length);
var lengthDiff = Math.abs(array1.length - array2.length);
var diffs = 0;
var i;
for (i = 0; i < len; i++) {
if ((dontConvert && array1[i] !== array2[i])
|| (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) {
diffs++;
}
}
return diffs + lengthDiff;
}
// internal storage for locale config files
var locales = {};
var localeFamilies = {};
var globalLocale;
function normalizeLocale(key) {
return key ? key.toLowerCase().replace('_', '-') : key;
}
// pick the locale from the array
// try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
// substring from most specific to least,
// but move to the next array item if it's a more specific variant than the current root
function chooseLocale(names) {
var next;
var locale;
var i = 0;
while (i < names.length) {
var split = normalizeLocale(names[i]).split('-');
var j = split.length;
next = normalizeLocale(names[i + 1]);
next = next ? next.split('-') : null;
while (j > 0) {
locale = loadLocale(split.slice(0, j).join('-'));
if (locale) {
return locale;
}
if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {
// the next array item is better than a shallower substring of this one
break;
}
j--;
}
i++;
}
return null;
}
function mergeConfigs(parentConfig, childConfig) {
var res = Object.assign({}, parentConfig);
for (var childProp in childConfig) {
if (!hasOwnProp(childConfig, childProp)) {
continue;
}
if (isObject(parentConfig[childProp]) && isObject(childConfig[childProp])) {
res[childProp] = {};
Object.assign(res[childProp], parentConfig[childProp]);
Object.assign(res[childProp], childConfig[childProp]);
}
else if (childConfig[childProp] != null) {
res[childProp] = childConfig[childProp];
}
else {
delete res[childProp];
}
}
var parentProp;
for (parentProp in parentConfig) {
if (hasOwnProp(parentConfig, parentProp) &&
!hasOwnProp(childConfig, parentProp) &&
isObject(parentConfig[parentProp])) {
// make sure changes to properties don't modify parent config
res[parentProp] = Object.assign({}, res[parentProp]);
}
}
return res;
}
function loadLocale(name) {
// no way!
/* var oldLocale = null;
// TODO: Find a better way to register and load all the locales in Node
if (!locales[name] && (typeof module !== 'undefined') &&
module && module.exports) {
try {
oldLocale = globalLocale._abbr;
var aliasedRequire = require;
aliasedRequire('./locale/' + name);
getSetGlobalLocale(oldLocale);
} catch (e) {}
}*/
if (!locales[name]) {
// tslint:disable-next-line
console.error("Khronos locale error: please load locale \"" + name + "\" before using it");
// throw new Error(`Khronos locale error: please load locale "${name}" before using it`);
}
return locales[name];
}
// This function will load locale and then set the global locale. If
// no arguments are passed in, it will simply return the current global
// locale key.
function getSetGlobalLocale(key, values) {
var data;
if (key) {
if (isUndefined(values)) {
data = getLocale(key);
}
else if (isString(key)) {
data = defineLocale(key, values);
}
if (data) {
globalLocale = data;
}
}
return globalLocale && globalLocale._abbr;
}
function defineLocale(name, config) {
if (config === null) {
// useful for testing
delete locales[name];
globalLocale = getLocale('en');
return null;
}
if (!config) {
return;
}
var parentConfig = baseConfig;
config.abbr = name;
if (config.parentLocale != null) {
if (locales[config.parentLocale] != null) {
parentConfig = locales[config.parentLocale]._config;
}
else {
if (!localeFamilies[config.parentLocale]) {
localeFamilies[config.parentLocale] = [];
}
localeFamilies[config.parentLocale].push({ name: name, config: config });
return null;
}
}
locales[name] = new Locale(mergeConfigs(parentConfig, config));
if (localeFamilies[name]) {
localeFamilies[name].forEach(function (x) {
defineLocale(x.name, x.config);
});
}
// backwards compat for now: also set the locale
// make sure we set the locale AFTER all child locales have been
// created, so we won't end up with the child locale set.
getSetGlobalLocale(name);
return locales[name];
}
// returns locale data
function getLocale(key) {
if (!key) {
return globalLocale;
}
// let locale;
var _key = isArray(key) ? key : [key];
return chooseLocale(_key);
}
// define default locale
getSetGlobalLocale('en', {
dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/,
ordinal: function (num) {
var b = num % 10;
var output = toInt((num % 100) / 10) === 1
? 'th'
: b === 1 ? 'st' : b === 2 ? 'nd' : b === 3 ? 'rd' : 'th';
return num + output;
}
});
/**
* Configuration service, provides default values for the AccordionComponent.
*/
var AccordionConfig = (function () {
function AccordionConfig() {
/** Whether the other panels should be closed when a panel is opened */
this.closeOthers = false;
}
AccordionConfig.decorators = [
{ type: Injectable },
];
/** @nocollapse */
AccordionConfig.ctorParameters = function () { return []; };
return AccordionConfig;
}());
/** Displays collapsible content panels for presenting information in a limited amount of space. */
var AccordionComponent = (function () {
function AccordionComponent(config) {
this.groups = [];
Object.assign(this, config);
}
AccordionComponent.prototype.closeOtherPanels = function (openGroup) {
if (!this.closeOthers) {
return;
}
this.groups.forEach(function (group) {
if (group !== openGroup) {
group.isOpen = false;
}
});
};
AccordionComponent.prototype.addGroup = function (group) {
this.groups.push(group);
};
AccordionComponent.prototype.removeGroup = function (group) {
var index = this.groups.indexOf(group);
if (index !== -1) {
this.groups.splice(index, 1);
}
};
AccordionComponent.decorators = [
{ type: Component, args: [{
selector: 'accordion',
template: "<ng-content></ng-content>",
host: {
'[attr.aria-multiselectable]': 'closeOthers',
role: 'tablist',
class: 'panel-group',
style: 'display: block'
}
},] },
];
/** @nocollapse */
AccordionComponent.ctorParameters = function () {
return [
{ type: AccordionConfig, },
];
};
AccordionComponent.propDecorators = {
'closeOthers': [{ type: Input },],
};
return AccordionComponent;
}());
/**
* ### Accordion heading
* Instead of using `heading` attribute on the `accordion-group`, you can use
* an `accordion-heading` attribute on `any` element inside of a group that
* will be used as group's header template.
*/
var AccordionPanelComponent = (function () {
function AccordionPanelComponent(accordion) {
/** Emits when the opened state changes */
this.isOpenChange = new EventEmitter();
this._isOpen = false;
this.accordion = accordion;
}
Object.defineProperty(AccordionPanelComponent.prototype, "isOpen", {
// Questionable, maybe .panel-open should be on child div.panel element?
/** Is accordion group open or closed. This property supports two-way binding */
get: function () {
return this._isOpen;
},
set: function (value) {
var _this = this;
if (value !== this.isOpen) {
if (value) {
this.accordion.closeOtherPanels(this);
}
this._isOpen = value;
Promise.resolve(null).then(function () {
_this.isOpenChange.emit(value);
});
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(AccordionPanelComponent.prototype, "isBs3", {
get: function () {
return isBs3();
},
enumerable: true,
configurable: true
});
AccordionPanelComponent.prototype.ngOnInit = function () {
this.panelClass = this.panelClass || 'panel-default';
this.accordion.addGroup(this);
};
AccordionPanelComponent.prototype.ngOnDestroy = function () {
this.accordion.removeGroup(this);
};
AccordionPanelComponent.prototype.toggleOpen = function (event) {
if (!this.isDisabled) {
this.isOpen = !this.isOpen;
}
};
AccordionPanelComponent.decorators = [
{ type: Component, args: [{
selector: 'accordion-group, accordion-panel',
template: "<div class=\"panel card\" [ngClass]=\"panelClass\"> <div class=\"panel-heading card-header\" role=\"tab\" (click)=\"toggleOpen($event)\"> <div class=\"panel-title\"> <div role=\"button\" class=\"accordion-toggle\" [attr.aria-expanded]=\"isOpen\"> <div *ngIf=\"heading\" [ngClass]=\"{'text-muted': isDisabled}\"> {{ heading }} </div> <ng-content select=\"[accordion-heading]\"></ng-content> </div> </div> </div> <div class=\"panel-collapse collapse\" role=\"tabpanel\" [collapse]=\"!isOpen\"> <div class=\"panel-body card-block card-body\"> <ng-content></ng-content> </div> </div> </div> ",
host: {
class: 'panel',
style: 'display: block'
}
},] },
];
/** @nocollapse */
AccordionPanelComponent.ctorParameters = function () {
return [
{ type: AccordionComponent, decorators: [{ type: Inject, args: [AccordionComponent,] },] },
];
};
AccordionPanelComponent.propDecorators = {
'heading': [{ type: Input },],
'panelClass': [{ type: Input },],
'isDisabled': [{ type: Input },],
'isOpenChange': [{ type: Output },],
'isOpen': [{ type: HostBinding, args: ['class.panel-open',] }, { type: Input },],
};
return AccordionPanelComponent;
}());
// todo: add animations when https://github.com/angular/angular/issues/9947 solved
var CollapseDirective = (function () {
function CollapseDirective(_el, _renderer) {
this._el = _el;
this._renderer = _renderer;
/** This event fires as soon as content collapses */
this.collapsed = new EventEmitter();
/** This event fires as soon as content becomes visible */
this.expanded = new EventEmitter();
// shown
this.isExpanded = true;
// hidden
this.isCollapsed = false;
// stale state
this.isCollapse = true;
// animation state
this.isCollapsing = false;
}
Object.defineProperty(CollapseDirective.prototype, "collapse", {
get: function () {
return this.isExpanded;
},
/** A flag indicating visibility of content (shown or hidden) */
set: function (value) {
this.isExpanded = value;
this.toggle();
},
enumerable: true,
configurable: true
});
/** allows to manually toggle content visibility */
CollapseDirective.prototype.toggle = function () {
if (this.isExpanded) {
this.hide();
}
else {
this.show();
}
};
/** allows to manually hide content */
CollapseDirective.prototype.hide = function () {
this.isCollapse = false;
this.isCollapsing = true;
this.isExpanded = false;
this.isCollapsed = true;
this.isCollapse = true;
this.isCollapsing = false;
this.display = 'none';
this.collapsed.emit(this);
};
/** allows to manually show collapsed content */
CollapseDirective.prototype.show = function () {
this.isCollapse = false;
this.isCollapsing = true;
this.isExpanded = true;
this.isCollapsed = false;
this.display = 'block';
// this.height = 'auto';
this.isCollapse = true;
this.isCollapsing = false;
this._renderer.setStyle(this._el.nativeElement, 'overflow', 'visible');
this._renderer.setStyle(this._el.nativeElement, 'height', 'auto');
this.expanded.emit(this);
};
CollapseDirective.decorators = [
{ type: Directive, args: [{
selector: '[collapse]',
exportAs: 'bs-collapse',
host: {
'[class.collapse]': 'true'
}
},] },
];
/** @nocollapse */
CollapseDirective.ctorParameters = function () {
return [
{ type: ElementRef, },
{ type: Renderer2, },
];
};
CollapseDirective.propDecorators = {
'collapsed': [{ type: Output },],
'expanded': [{ type: Output },],
'display': [{ type: HostBinding, args: ['style.display',] },],
'isExpanded': [{ type: HostBinding, args: ['class.in',] }, { type: HostBinding, args: ['class.show',] }, { type: HostBinding, args: ['attr.aria-expanded',] },],
'isCollapsed': [{ type: HostBinding, args: ['attr.aria-hidden',] },],
'isCollapse': [{ type: HostBinding, args: ['class.collapse',] },],
'isCollapsing': [{ type: HostBinding, args: ['class.collapsing',] },],
'collapse': [{ type: Input },],
};
return CollapseDirective;
}());
var AlertConfig = (function () {
function AlertConfig() {
/** default alert type */
this.type = 'warning';
/** is alerts are dismissible by default */
this.dismissible = false;
/** default time before alert will dismiss */
this.dismissOnTimeout = undefined;
}
AlertConfig.decorators = [
{ type: Injectable },
];
/** @nocollapse */
AlertConfig.ctorParameters = function () { return []; };
return AlertConfig;
}());
/*tslint:disable:no-invalid-this */
function OnChange(defaultValue) {
var sufix = 'Change';
return function OnChangeHandler(target, propertyKey) {
var _key = " __" + propertyKey + "Value";
Object.defineProperty(target, propertyKey, {
get: function () {
return this[_key];
},
set: function (value) {
var prevValue = this[_key];
this[_key] = value;
if (prevValue !== value && this[propertyKey + sufix]) {
this[propertyKey + sufix].emit(value);
}
}
});
};
}
/* tslint:enable */
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r = Reflect.decorate(decorators, target, key, desc);
else
for (var i = decorators.length - 1; i >= 0; i--)
if (d = decorators[i])
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
return Reflect.metadata(k, v);
};
var AlertComponent = (function () {
function AlertComponent(_config, changeDetection) {
var _this = this;
this.changeDetection = changeDetection;
/** Alert type.
* Provides one of four bootstrap supported contextual classes:
* `success`, `info`, `warning` and `danger`
*/
this.type = 'warning';
/** If set, displays an inline "Close" button */
this.dismissible = false;
/** Is alert visible */
this.isOpen = true;
/** This event fires immediately after close instance method is called,
* $event is an instance of Alert component.
*/
this.onClose = new EventEmitter();
/** This event fires when alert closed, $event is an instance of Alert component */
this.onClosed = new EventEmitter();
this.classes = '';
this.dismissibleChange = new EventEmitter();
Object.assign(this, _config);
this.dismissibleChange.subscribe(function (dismissible) {
_this.classes = _this.dismissible ? 'alert-dismissible' : '';
_this.changeDetection.markForCheck();
});
}
AlertComponent.prototype.ngOnInit = function () {
var _this = this;
if (this.dismissOnTimeout) {
// if dismissOnTimeout used as attr without binding, it will be a string
setTimeout(function () { return _this.close(); }, parseInt(this.dismissOnTimeout, 10));
}
};
// todo: animation ` If the .fade and .in classes are present on the element,
// the alert will fade out before it is removed`
/**
* Closes an alert by removing it from the DOM.
*/
AlertComponent.prototype.close = function () {
if (!this.isOpen) {
return;
}
this.onClose.emit(this);
this.isOpen = false;
this.changeDetection.markForCheck();
this.onClosed.emit(this);
};
AlertComponent.decorators = [
{ type: Component, args: [{
selector: 'alert,bs-alert',
template: "<ng-template [ngIf]=\"isOpen\"> <div [class]=\"'alert alert-' + type\" role=\"alert\" [ngClass]=\"classes\"> <ng-template [ngIf]=\"dismissible\"> <button type=\"button\" class=\"close\" aria-label=\"Close\" (click)=\"close()\"> <span aria-hidden=\"true\">×</span> <span class=\"sr-only\">Close</span> </button> </ng-template> <ng-content></ng-content> </div> </ng-template> ",
changeDetection: ChangeDetectionStrategy.OnPush
},] },
];
/** @nocollapse */
AlertComponent.ctorParameters = function () {
return [
{ type: AlertConfig, },
{ type: ChangeDetectorRef, },
];
};
AlertComponent.propDecorators = {
'type': [{ type: Input },],
'dismissible': [{ type: Input },],
'dismissOnTimeout': [{ type: Input },],
'isOpen': [{ type: Input },],
'onClose': [{ type: Output },],
'onClosed': [{ type: Output },],
};
__decorate([
OnChange(),
__metadata("design:type", Object)
], AlertComponent.prototype, "dismissible", void 0);
return AlertComponent;
}());
// tslint:disable:no-use-before-declare
// TODO: config: activeClass - Class to apply to the checked buttons
var CHECKBOX_CONTROL_VALUE_ACCESSOR = {
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(function () { return ButtonCheckboxDirective; }),
multi: true
};
/**
* Add checkbox functionality to any element
*/
var ButtonCheckboxDirective = (function () {
function ButtonCheckboxDirective() {
/** Truthy value, will be set to ngModel */
this.btnCheckboxTrue = true;
/** Falsy value, will be set to ngModel */
this.btnCheckboxFalse = false;
this.state = false;
this.onChange = Function.prototype;
this.onTouched = Function.prototype;
}
// view -> model
ButtonCheckboxDirective.prototype.onClick = function () {
if (this.isDisabled) {
return;
}
this.toggle(!this.state);
this.onChange(this.value);
};
ButtonCheckboxDirective.prototype.ngOnInit = function () {
this.toggle(this.trueValue === this.value);
};
Object.defineProperty(ButtonCheckboxDirective.prototype, "trueValue", {
get: function () {
return typeof this.btnCheckboxTrue !== 'undefined'
? this.btnCheckboxTrue
: true;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ButtonCheckboxDirective.prototype, "falseValue", {
get: function () {
return typeof this.btnCheckboxFalse !== 'undefined'
? this.btnCheckboxFalse
: false;
},
enumerable: true,
configurable: true
});
ButtonCheckboxDirective.prototype.toggle = function (state) {
this.state = state;
this.value = this.state ? this.trueValue : this.falseValue;
};
// ControlValueAccessor
// model -> view
ButtonCheckboxDirective.prototype.writeValue = function (value) {
this.state = this.trueValue === value;
this.value = value ? this.trueValue : this.falseValue;
};
ButtonCheckboxDirective.prototype.setDisabledState = function (isDisabled) {
this.isDisabled = isDisabled;
};
ButtonCheckboxDirective.prototype.registerOnChange = function (fn) {
this.onChange = fn;
};
ButtonCheckboxDirective.prototype.registerOnTouched = function (fn) {
this.onTouched = fn;
};
ButtonCheckboxDirective.decorators = [
{ type: Directive, args: [{
selector: '[btnCheckbox]',
providers: [CHECKBOX_CONTROL_VALUE_ACCESSOR]
},] },
];
/** @nocollapse */
ButtonCheckboxDirective.ctorParameters = function () { return []; };
ButtonCheckboxDirective.propDecorators = {
'btnCheckboxTrue': [{ type: Input },],
'btnCheckboxFalse': [{ type: Input },],
'state': [{ type: HostBinding, args: ['class.active',] },],
'onClick': [{ type: HostListener, args: ['click',] },],
};
return ButtonCheckboxDirective;
}());
// tslint:disable:no-use-before-declare
var RADIO_CONTROL_VALUE_ACCESSOR = {
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(function () { return ButtonRadioGroupDirective; }),
multi: true
};
/**
* A group of radio buttons.
* A value of a selected button is bound to a variable specified via ngModel.
*/
var ButtonRadioGroupDirective = (function () {
function ButtonRadioGroupDirective(el, cdr) {
this.el = el;
this.cdr = cdr;
this.onChange = Function.prototype;
this.onTouched = Function.prototype;
}
Object.defineProperty(ButtonRadioGroupDirective.prototype, "value", {
get: function () {
return this._value;
},
set: function (value) {
this._value = value;
},
enumerable: true,
configurable: true
});
ButtonRadioGroupDirective.prototype.writeValue = function (value) {
this._value = value;
this.cdr.markForCheck();
};
ButtonRadioGroupDirective.prototype.registerOnChange = function (fn) {
this.onChange = fn;
};
ButtonRadioGroupDirective.prototype.registerOnTouched = function (fn) {
this.onTouched = fn;
};
ButtonRadioGroupDirective.decorators = [
{ type: Directive, args: [{
selector: '[btnRadioGroup]',
providers: [RADIO_CONTROL_VALUE_ACCESSOR]
},] },
];
/** @nocollapse */
ButtonRadioGroupDirective.ctorParameters = function () {
return [
{ type: ElementRef, },
{ type: ChangeDetectorRef, },
];
};
return ButtonRadioGroupDirective;
}());
// tslint:disable:no-use-before-declare
var RADIO_CONTROL_VALUE_ACCESSOR$1 = {
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(function () { return ButtonRadioDirective; }),
multi: true
};
/**
* Create radio buttons or groups of buttons.
* A value of a selected button is bound to a variable specified via ngModel.
*/
var ButtonRadioDirective = (function () {
function ButtonRadioDirective(el, cdr, group, renderer) {
this.el = el;
this.cdr = cdr;
this.group = group;
this.renderer = renderer;
this.onChange = Function.prototype;
this.onTouched = Function.prototype;
}
Object.defineProperty(ButtonRadioDirective.prototype, "value", {
/** Current value of radio component or group */
get: function () {
return this.group ? this.group.value : this._value;
},
set: function (value) {
if (this.group) {
this.group.value = value;
return;
}
this._value = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ButtonRadioDirective.prototype, "disabled", {
/** If `true` — radio button is disabled */
get: function () {
return this._disabled;
},
set: function (disabled) {
this._disabled = disabled;
this.setDisabledState(disabled);
},
enumerable: true,
configurable: true
});
Object.defineProperty(ButtonRadioDirective.prototype, "isActive", {
get: function () {
return this.btnRadio === this.value;
},
enumerable: true,
configurable: true
});
ButtonRadioDirective.prototype.onClick = function () {
if (this.el.nativeElement.attributes.disabled || !this.uncheckable && this.btnRadio === this.value) {
return;
}
this.value = this.uncheckable && this.btnRadio === this.value ? undefined : this.btnRadio;
this._onChange(this.value);
};
ButtonRadioDirective.prototype.ngOnInit = function () {
this.uncheckable = typeof this.uncheckable !== 'undefined';
};
ButtonRadioDirective.prototype.onBlur = function () {
this.onTouched();
};
ButtonRadioDirective.prototype._onChange = function (value) {
if (this.group) {
this.group.onTouched();
this.group.onChange(value);
return;
}
this.onTouched();
this.onChange(value);
};
// ControlValueAccessor
// model -> view
ButtonRadioDirective.prototype.writeValue = function (value) {
this.value = value;
this.cdr.markForCheck();
};
ButtonRadioDirective.prototype.registerOnChange = function (fn) {
this.onChange = fn;
};
ButtonRadioDirective.prototype.registerOnTouched = function (fn) {
this.onTouched = fn;
};
ButtonRadioDirective.prototype.setDisabledState = function (disabled) {
if (disabled) {
this.renderer.setAttribute(this.el.nativeElement, 'disabled', 'disabled');
return;
}
this.renderer.removeAttribute(this.el.nativeElement, 'disabled');
};
ButtonRadioDirective.decorators = [
{ type: Directive, args: [{
selector: '[btnRadio]',
providers: [RADIO_CONTROL_VALUE_ACCESSOR$1]
},] },
];
/** @nocollapse */
ButtonRadioDirective.ctorParameters = function () {
return [
{ type: ElementRef, },
{ type: ChangeDetectorRef, },
{ type: ButtonRadioGroupDirective, decorators: [{ type: Optional },] },
{ type: Renderer2, },
];
};
ButtonRadioDirective.propDecorators = {
'btnRadio': [{ type: Input },],
'uncheckable': [{ type: Input },],
'value': [{ type: Input },],
'disabled': [{ type: Input },],
'isActive': [{ type: HostBinding, args: ['class.active',] },],
'onClick': [{ type: HostListener, args: ['click',] },],
};
return ButtonRadioDirective;
}());
var LinkedList = (function () {
function LinkedList() {
this.length = 0;
this.asArray = [];
// Array methods overriding END
}
LinkedList.prototype.get = function (position) {
if (this.length === 0 || position < 0 || position >= this.length) {
return void 0;
}
var current = this.head;
for (var index = 0; index < position; index++) {
current = current.next;
}
return current.value;
};
LinkedList.prototype.add = function (value, position) {
if (position === void 0) {
position = this.length;
}
if (position < 0 || position > this.length) {
throw new Error('Position is out of the list');
}
var node = {
value: value,
next: undefined,
previous: undefined
};
if (this.length === 0) {
this.head = node;
this.tail = node;
this.current = node;
}
else {
if (position === 0) {
// first node
node.next = this.head;
this.head.previous = node;
this.head = node;
}
else if (position === this.length) {
// last node
this.tail.next = node;
node.previous = this.tail;
this.tail = node;
}
else {
// node in middle
var currentPreviousNode = this.getNode(position - 1);
var currentNextNode = currentPreviousNode.next;
currentPreviousNode.next = node;
currentNextNode.previous = node;
node.previous = currentPreviousNode;
node.next = currentNextNode;
}
}
this.length++;
this.createInternalArrayRepresentation();
};
LinkedList.prototype.remove = function (position) {
if (position === void 0) {
position = 0;
}
if (this.length === 0 || position < 0 || position >= this.length) {
throw new Error('Position is out of the list');
}
if (position === 0) {
// first node
this.head = this.head.next;
if (this.head) {
// there is no second node
this.head.previous = undefined;
}
else {
// there is no second node
this.tail = undefined;
}
}
else if (position === this.length - 1) {
// last node
this.tail = this.tail.previous;
this.tail.next = undefined;
}
else {
// middle node
var removedNode = this.getNode(position);
removedNode.next.previous = removedNode.previous;
removedNode.previous.next = removedNode.next;
}
this.length--;
this.createInternalArrayRepresentation();
};
LinkedList.prototype.set = function (position, value) {
if (this.length === 0 || position < 0 || position >= this.length) {
throw new Error('Position is out of the list');
}
var node = this.getNode(position);
node.value = value;
this.createInternalArrayRepresentation();
};
LinkedList.prototype.toArray = function () {
return this.asArray;
};
LinkedList.prototype.findAll = function (fn) {
var current = this.head;
var result = [];
for (var index = 0; index < this.length; index++) {
if (fn(current.value, index)) {
result.push({ index: index, value: current.value });
}
current = current.next;
}
return result;
};
// Array methods overriding start
LinkedList.prototype.push = function () {
var _this = this;
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
args.forEach(function (arg) {
_this.add(arg);
});
return this.length;
};
LinkedList.prototype.pop = function () {
if (this.length === 0) {
return undefined;
}
var last = this.tail;
this.remove(this.length - 1);
return last.value;
};
LinkedList.prototype.unshift = function () {
var _this = this;
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
args.reverse();
args.forEach(function (arg) {
_this.add(arg, 0);
});
return this.length;
};
LinkedList.prototype.shift = function () {
if (this.length === 0) {
return undefined;
}
var lastItem = this.head.value;
this.remove();
return lastItem;
};
LinkedList.prototype.forEach = function (fn) {
var current = this.head;
for (var index = 0; index < this.length; index++) {
fn(current.value, index);
current = current.next;
}
};
LinkedList.prototype.indexOf = function (value) {
var current = this.head;
var position = 0;
for (var index = 0; index < this.length; index++) {
if (current.value === value) {
position = index;
break;
}
current = current.next;
}
return position;
};
LinkedList.prototype.some = function (fn) {
var current = this.head;
var result = false;
while (current && !result) {
if (fn(current.value)) {
result = true;
break;
}
current = current.next;
}
return result;
};
LinkedList.prototype.every = function (fn) {
var current = this.head;
var result = true;
while (current && result) {
if (!fn(current.value)) {
result = false;
}
current = current.next;
}
return result;
};
LinkedList.prototype.toString = function () {
return '[Linked List]';
};
LinkedList.prototype.find = function (fn) {
var current = this.head;
var result;
for (var index = 0; index < this.length; index++) {
if (fn(current.value, index)) {
result = current.value;
break;
}
current = current.next;
}
return result;
};
LinkedList.prototype.findIndex = function (fn) {
var current = this.head;
var result;
for (var index = 0; index < this.length; index++) {
if (fn(current.value, index)) {
result = index;
break;
}
current = current.next;
}
return result;
};
LinkedList.prototype.getNode = function (position) {
if (this.length === 0 || position < 0 || position >= this.length) {
throw new Error('Position is out of the list');
}
var current = this.head;
for (var index = 0; index < position; index++) {
current = current.next;
}
return current;
};
LinkedList.prototype.createInternalArrayRepresentation = function () {
var outArray = [];
var current = this.head;
while (current) {
outArray.push(current.value);
current = current.next;
}
this.asArray = outArray;
};
return LinkedList;
}());
var Utils = (function () {
function Utils() {
}
Utils.reflow = function (element) {
(function (bs) { return bs; })(element.offsetHeight);
};
// source: https://github.com/jquery/jquery/blob/master/src/css/var/getStyles.js
Utils.getStyles = function (elem) {
// Support: IE <=11 only, Firefox <=30 (#15098, #14150)
// IE throws on elements created in popups
// FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
var view = elem.ownerDocument.defaultView;
if (!view || !view.opener) {
view = win;
}
return view.getComputedStyle(elem);
};
return Utils;
}());
var CarouselConfig = (function () {
function CarouselConfig() {
/** Default interval of auto changing of slides */
this.interval = 5000;
/** Is loop of auto changing of slides can be paused */
this.noPause = false;
/** Is slides can wrap from the last to the first slide */
this.noWrap = false;
/** Show carousel-indicators */
this.showIndicators = true;
}
CarouselConfig.decorators = [
{ type: Injectable },
];
/** @nocollapse */
CarouselConfig.ctorParameters = function () { return []; };
return CarouselConfig;
}());
// tslint:disable:max-file-line-count
/***
* pause (not yet supported) (?string='hover') - event group name which pauses
* the cycling of the carousel, if hover pauses on mouseenter and resumes on
* mouseleave keyboard (not yet supported) (?boolean=true) - if false
* carousel will not react to keyboard events
* note: swiping not yet supported
*/
/****
* Problems:
* 1) if we set an active slide via model changes, .active class remains on a
* current slide.
* 2) if we have only one slide, we shouldn't show prev/next nav buttons
* 3) if first or last slide is active and noWrap is true, there should be
* "disabled" class on the nav buttons.
* 4) default interval should be equal 5000
*/
var Direction;
(function (Direction) {
Direction[Direction["UNKNOWN"] = 0] = "UNKNOWN";
Direction[Direction["NEXT"] = 1] = "NEXT";
Direction[Direction["PREV"] = 2] = "PREV";
})(Direction || (Direction = {}));
/**
* Base element to create carousel
*/
var CarouselComponent = (function () {
function CarouselComponent(config, ngZone) {
this.ngZone = ngZone;
/** Will be emitted when active slide has been changed. Part of two-way-bindable [(activeSlide)] property */
this.activeSlideChange = new EventEmitter(false);
this._slides = new LinkedList();
this.destroyed = false;
Object.assign(this, config);
}
Object.defineProperty(CarouselComponent.prototype, "activeSlide", {
get: function () {
return this._currentActiveSlide;
},
/** Index of currently displayed slide(started for 0) */
set: function (index) {
if (this._slides.length && index !== this._currentActiveSlide) {
this._select(index);
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(CarouselComponent.prototype, "interval", {
/**
* Delay of item cycling in milliseconds. If false, carousel won't cycle
* automatically.
*/
get: function () {
return this._interval;
},
set: function (value) {
this._interval = value;
this.restartTimer();
},
enumerable: true,
configurable: true
});
Object.defineProperty(CarouselComponent.prototype, "slides", {
get: function () {
return this._slides.toArray();
},
enumerable: true,
configurable: true
});
Object.defineProperty(CarouselComponent.prototype, "isBs4", {
get: function () {
return !isBs3();
},
enumerable: true,
configurable: true
});
CarouselComponent.prototype.ngOnDestroy = function () {
this.destroyed = true;
};
/**
* Adds new slide. If this slide is first in collection - set it as active
* and starts auto changing
* @param slide
*/
CarouselComponent.prototype.addSlide = function (slide) {
this._slides.add(slide);
if (this._slides.length === 1) {
this._currentActiveSlide = void 0;
this.activeSlide = 0;
this.play();
}
};
/**
* Removes specified slide. If this slide is active - will roll to another
* slide
* @param slide
*/
CarouselComponent.prototype.removeSlide = function (slide) {
var _this = this;
var remIndex = this._slides.indexOf(slide);
if (this._currentActiveSlide === remIndex) {
// removing of active slide
var nextSlideIndex_1 = void 0;
if (this._slides.length > 1) {
// if this slide last - will roll to first slide, if noWrap flag is
// FALSE or to previous, if noWrap is TRUE in case, if this slide in
// middle of collection, index of next slide is same to removed
nextSlideIndex_1 = !this.isLast(remIndex)
? remIndex
: this.noWrap ? remIndex - 1 : 0;
}
this._slides.remove(remIndex);
// prevents exception with changing some value after checking
setTimeout(function () {
_this._select(nextSlideIndex_1);
}, 0);
}
else {
this._slides.remove(remIndex);
var currentSlideIndex_1 = this.getCurrentSlideIndex();
setTimeout(function () {
// after removing, need to actualize index of current active slide
_this._currentActiveSlide = currentSlideIndex_1;
_this.activeSlideChange.emit(_this._currentActiveSlide);
}, 0);
}
};
/**
* Rolling to next slide
* @param force: {boolean} if true - will ignore noWrap flag
*/
CarouselComponent.prototype.nextSlide = function (force) {
if (force === void 0) {
force = false;
}
this.activeSlide = this.findNextSlideIndex(Direction.NEXT, force);
};
/**
* Rolling to previous slide
* @param force: {boolean} if true - will ignore noWrap flag
*/
CarouselComponent.prototype.previousSlide = function (force) {
if (force === void 0) {
force = false;
}
this.activeSlide = this.findNextSlideIndex(Direction.PREV, force);
};
/**
* Rolling to specified slide
* @param index: {number} index of slide, which must be shown
*/
CarouselComponent.prototype.selectSlide = function (index) {
this.activeSlide = index;
};
/**
* Starts a auto changing of slides
*/
CarouselComponent.prototype.play = function () {
if (!this.isPlaying) {
this.isPlaying = true;
this.restartTimer();
}
};
/**
* Stops a auto changing of slides
*/
CarouselComponent.prototype.pause = function () {
if (!this.noPause) {
this.isPlaying = false;
this.resetTimer();
}
};
/**
* Finds and returns index of currently displayed slide
* @returns {number}
*/
CarouselComponent.prototype.getCurrentSlideIndex = function () {
return this._slides.findIndex(function (slide) { return slide.active; });
};
/**
* Defines, whether the specified index is last in collection
* @param index
* @returns {boolean}
*/
CarouselComponent.prototype.isLast = function (index) {
return index + 1 >= this._slides.length;
};
/**
* Defines next slide index, depending of direction
* @param direction: Direction(UNKNOWN|PREV|NEXT)
* @param force: {boolean} if TRUE - will ignore noWrap flag, else will
* return undefined if next slide require wrapping
* @returns {any}
*/
CarouselComponent.prototype.findNextSlideIndex = function (direction, force) {
var nextSlideIndex = 0;
if (!force &&
(this.isLast(this.activeSlide) &&
direction !== Direction.PREV &&
this.noWrap)) {
return void 0;
}
switch (direction) {
case Direction.NEXT:
// if this is last slide, not force, looping is disabled
// and need to going forward - select current slide, as a next
nextSlideIndex = !this.isLast(this._currentActiveSlide)
? this._currentActiveSlide + 1
: !force && this.noWrap ? this._currentActiveSlide : 0;
break;
case Direction.PREV:
// if this is first slide, not force, looping is disabled
// and need to going backward - select current slide, as a next
nextSlideIndex =
this._currentActiveSlide > 0
? this._currentActiveSlide - 1
: !force && this.noWrap
? this._currentActiveSlide
: this._slides.length - 1;
break;
default:
throw new Error('Unknown direction');
}
return nextSlideIndex;
};
/**
* Sets a slide, which specified through index, as active
* @param index
* @private
*/
CarouselComponent.prototype._select = function (index) {
if (isNaN(index)) {
this.pause();
return;
}
var currentSlide = this._slides.get(this._currentActiveSlide);
if (currentSlide) {
currentSlide.active = false;
}
var nextSlide = this._slides.get(index);
if (nextSlide) {
this._currentActiveSlide = index;
nextSlide.active = true;
this.activeSlide = index;
this.activeSlideChange.emit(index);
}
};
/**
* Starts loop of auto changing of slides
*/
CarouselComponent.prototype.restartTimer = function () {
var _this = this;
this.resetTimer();
var interval = +this.interval;
if (!isNaN(interval) && interval > 0) {
this.currentInterval = this.ngZone.runOutsideAngular(function () {
return setInterval(function () {
var nInterval = +_this.interval;
_this.ngZone.run(function () {
if (_this.isPlaying &&
!isNaN(_this.interval) &&
nInterval > 0 &&
_this.slides.length) {
_this.nextSlide();
}
else {
_this.pause();
}
});
}, interval);
});
}
};
/**
* Stops loop of auto changing of slides
*/
CarouselComponent.prototype.resetTimer = function () {
if (this.currentInterval) {
clearInterval(this.currentInterval);
this.currentInterval = void 0;
}
};
CarouselComponent.decorators = [
{ type: Component, args: [{
selector: 'carousel',
template: "<div (mouseenter)=\"pause()\" (mouseleave)=\"play()\" (mouseup)=\"play()\" class=\"carousel slide\"> <ol class=\"carousel-indicators\" *ngIf=\"showIndicators && slides.length > 1\"> <li *ngFor=\"let slidez of slides; let i = index;\" [class.active]=\"slidez.active === true\" (click)=\"selectSlide(i)\"></li> </ol> <div class=\"carousel-inner\"><ng-content></ng-content></div> <a class=\"left carousel-control carousel-control-prev\" [class.disabled]=\"activeSlide === 0 && noWrap\" (click)=\"previousSlide()\" *ngIf=\"slides.length > 1\"> <span class=\"icon-prev carousel-control-prev-icon\" aria-hidden=\"true\"></span> <span *ngIf=\"isBs4\" class=\"sr-only\">Previous</span> </a> <a class=\"right carousel-control carousel-control-next\" (click)=\"nextSlide()\" [class.disabled]=\"isLast(activeSlide) && noWrap\" *ngIf=\"slides.length > 1\"> <span class=\"icon-next carousel-control-next-icon\" aria-hidden=\"true\"></span> <span class=\"sr-only\">Next</span> </a> </div> "
},] },
];
/** @nocollapse */
CarouselComponent.ctorParameters = function () {
return [
{ type: CarouselConfig, },
{ type: NgZone, },
];
};
CarouselComponent.propDecorators = {
'noWrap': [{ type: Input },],
'noPause': [{ type: Input },],
'showIndicators': [{ type: Input },],
'activeSlideChange': [{ type: Output },],
'activeSlide': [{ type: Input },],
'interval': [{ type: Input },],
};
return CarouselComponent;
}());
var DateFormatter = (function () {
function DateFormatter() {
}
DateFormatter.prototype.format = function (date, format, locale) {
return formatDate(date, format, locale);
};
return DateFormatter;
}());
/* tslint:disable:max-file-line-count */
// const MIN_DATE:Date = void 0;
// const MAX_DATE:Date = void 0;
// const DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
/*
const KEYS = {
13: 'enter',
32: 'space',
33: 'pageup',
34: 'pagedown',
35: 'end',
36: 'home',
37: 'left',
38: 'up',
39: 'right',
40: 'down'
};
*/
var DatePickerInnerComponent = (function () {
function DatePickerInnerComponent() {
this.selectionDone = new EventEmitter(undefined);
this.update = new EventEmitter(false);
this.activeDateChange = new EventEmitter(undefined);
this.stepDay = {};
this.stepMonth = {};
this.stepYear = {};
this.modes = ['day', 'month', 'year'];
this.dateFormatter = new DateFormatter();
}
Object.defineProperty(DatePickerInnerComponent.prototype, "activeDate", {
get: function () {
return this._activeDate;
},
set: function (value) {
this._activeDate = value;
},
enumerable: true,
configurable: true
});
// todo: add formatter value to Date object
DatePickerInnerComponent.prototype.ngOnInit = function () {
// todo: use date for unique value
this.uniqueId = "datepicker--" + Math.floor(Math.random() * 10000);
if (this.initDate) {
this.activeDate = this.initDate;
this.selectedDate = new Date(this.activeDate.valueOf());
this.update.emit(this.activeDate);
}
else if (this.activeDate === undefined) {
this.activeDate = new Date();
}
};
// this.refreshView should be called here to reflect the changes on the fly
// tslint:disable-next-line:no-unused-variable
DatePickerInnerComponent.prototype.ngOnChanges = function (changes) {
this.refreshView();
this.checkIfActiveDateGotUpdated(changes.activeDate);
};
// Check if activeDate has been update and then emit the activeDateChange with the new date
DatePickerInnerComponent.prototype.checkIfActiveDateGotUpdated = function (activeDate) {
if (activeDate && !activeDate.firstChange) {
var previousValue = activeDate.previousValue;
if (previousValue &&
previousValue instanceof Date &&
previousValue.getTime() !== activeDate.currentValue.getTime()) {
this.activeDateChange.emit(this.activeDate);
}
}
};
DatePickerInnerComponent.prototype.setCompareHandler = function (handler, type) {
if (type === 'day') {
this.compareHandlerDay = handler;
}
if (type === 'month') {
this.compareHandlerMonth = handler;
}
if (type === 'year') {
this.compareHandlerYear = handler;
}
};
DatePickerInnerComponent.prototype.compare = function (date1, date2) {
if (date1 === undefined || date2 === undefined) {
return undefined;
}
if (this.datepickerMode === 'day' && this.compareHandlerDay) {
return this.compareHandlerDay(date1, date2);
}
if (this.datepickerMode === 'month' && this.compareHandlerMonth) {
return this.compareHandlerMonth(date1, date2);
}
if (this.datepickerMode === 'year' && this.compareHandlerYear) {
return this.compareHandlerYear(date1, date2);
}
return void 0;
};
DatePickerInnerComponent.prototype.setRefreshViewHandler = function (handler, type) {
if (type === 'day') {
this.refreshViewHandlerDay = handler;
}
if (type === 'month') {
this.refreshViewHandlerMonth = handler;
}
if (type === 'year') {
this.refreshViewHandlerYear = handler;
}
};
DatePickerInnerComponent.prototype.refreshView = function () {
if (this.datepickerMode === 'day' && this.refreshViewHandlerDay) {
this.refreshViewHandlerDay();
}
if (this.datepickerMode === 'month' && this.refreshViewHandlerMonth) {
this.refreshViewHandlerMonth();
}
if (this.datepickerMode === 'year' && this.refreshViewHandlerYear) {
this.refreshViewHandlerYear();
}
};
DatePickerInnerComponent.prototype.dateFilter = function (date, format) {
return this.dateFormatter.format(date, format, this.locale);
};
DatePickerInnerComponent.prototype.isActive = function (dateObject) {
if (this.compare(dateObject.date, this.activeDate) === 0) {
this.activeDateId = dateObject.uid;
return true;
}
return false;
};
DatePickerInnerComponent.prototype.createDateObject = function (date, format) {
var dateObject = {};
dateObject.date = new Date(date.getFullYear(), date.getMonth(), date.getDate());
dateObject.date = this.fixTimeZone(dateObject.date);
dateObject.label = this.dateFilter(date, format);
dateObject.selected = this.compare(date, this.selectedDate) === 0;
dateObject.disabled = this.isDisabled(date);
dateObject.current = this.compare(date, new Date()) === 0;
dateObject.customClass = this.getCustomClassForDate(dateObject.date);
return dateObject;
};
DatePickerInnerComponent.prototype.split = function (arr, size) {
var arrays = [];
while (arr.length > 0) {
arrays.push(arr.splice(0, size));
}
return arrays;
};
// Fix a hard-reproducible bug with timezones
// The bug depends on OS, browser, current timezone and current date
// i.e.
// var date = new Date(2014, 0, 1);
// console.log(date.getFullYear(), date.getMonth(), date.getDate(),
// date.getHours()); can result in "2013 11 31 23" because of the bug.
DatePickerInnerComponent.prototype.fixTimeZone = function (date) {
var hours = date.getHours();
return new Date(date.getFullYear(), date.getMonth(), date.getDate(), hours === 23 ? hours + 2 : 0);
};
DatePickerInnerComponent.prototype.select = function (date, isManual) {
if (isManual === void 0) {
isManual = true;
}
if (this.datepickerMode === this.minMode) {
if (!this.activeDate) {
this.activeDate = new Date(0, 0, 0, 0, 0, 0, 0);
}
this.activeDate = new Date(date.getFullYear(), date.getMonth(), date.getDate());
this.activeDate = this.fixTimeZone(this.activeDate);
if (isManual) {
this.selectionDone.emit(this.activeDate);
}
}
else {
this.activeDate = new Date(date.getFullYear(), date.getMonth(), date.getDate());
this.activeDate = this.fixTimeZone(this.activeDate);
if (isManual) {
this.datepickerMode = this.modes[this.modes.indexOf(this.datepickerMode) - 1];
}
}
this.selectedDate = new Date(this.activeDate.valueOf());
this.update.emit(this.activeDate);
this.refreshView();
};
DatePickerInnerComponent.prototype.move = function (direction) {
var expectedStep;
if (this.datepickerMode === 'day') {
expectedStep = this.stepDay;
}
if (this.datepickerMode === 'month') {
expectedStep = this.stepMonth;
}
if (this.datepickerMode === 'year') {
expectedStep = this.stepYear;
}
if (expectedStep) {
var year = this.activeDate.getFullYear() + direction * (expectedStep.years || 0);
var month = this.activeDate.getMonth() + direction * (expectedStep.months || 0);
this.activeDate = new Date(year, month, 1);
this.refreshView();
this.activeDateChange.emit(this.activeDate);
}
};
DatePickerInnerComponent.prototype.toggleMode = function (_direction) {
var direction = _direction || 1;
if ((this.datepickerMode === this.maxMode && direction === 1) ||
(this.datepickerMode === this.minMode && direction === -1)) {
return;
}
this.datepickerMode = this.modes[this.modes.indexOf(this.datepickerMode) + direction];
this.refreshView();
};
DatePickerInnerComponent.prototype.getCustomClassForDate = function (date) {
var _this = this;
if (!this.customClass) {
return '';
}
// todo: build a hash of custom classes, it will work faster
var customClassObject = this.customClass.find(function (customClass) {
return (customClass.date.valueOf() === date.valueOf() &&
customClass.mode === _this.datepickerMode);
}, this);
return customClassObject === undefined ? '' : customClassObject.clazz;
};
DatePickerInnerComponent.prototype.compareDateDisabled = function (date1Disabled, date2) {
if (date1Disabled === undefined || date2 === undefined) {
return undefined;
}
if (date1Disabled.mode === 'day' && this.compareHandlerDay) {
return this.compareHandlerDay(date1Disabled.date, date2);
}
if (date1Disabled.mode === 'month' && this.compareHandlerMonth) {
return this.compareHandlerMonth(date1Disabled.date, date2);
}
if (date1Disabled.mode === 'year' && this.compareHandlerYear) {
return this.compareHandlerYear(date1Disabled.date, date2);
}
return undefined;
};
DatePickerInnerComponent.prototype.isDisabled = function (date) {
var _this = this;
var isDateDisabled = false;
if (this.dateDisabled) {
this.dateDisabled.forEach(function (disabledDate) {
if (_this.compareDateDisabled(disabledDate, date) === 0) {
isDateDisabled = true;
}
});
}
if (this.dayDisabled) {
isDateDisabled =
isDateDisabled ||
this.dayDisabled.indexOf(date.getDay()) > -1;
}
return (isDateDisabled ||
(this.minDate && this.compare(date, this.minDate) < 0) ||
(this.maxDate && this.compare(date, this.maxDate) > 0));
};
DatePickerInnerComponent.decorators = [
{ type: Component, args: [{
selector: 'datepicker-inner',
template: "\n <!--<!–ng-keydown=\"keydown($event)\"–>-->\n <div *ngIf=\"datepickerMode\" class=\"well well-sm bg-faded p-a card\" role=\"application\" >\n <ng-content></ng-content>\n </div>\n "
},] },
];
/** @nocollapse */
DatePickerInnerComponent.ctorParameters = function () { return []; };
DatePickerInnerComponent.propDecorators = {
'locale': [{ type: Input },],
'datepickerMode': [{ type: Input },],
'startingDay': [{ type: Input },],
'yearRange': [{ type: Input },],
'minDate': [{ type: Input },],
'maxDate': [{ type: Input },],
'minMode': [{ type: Input },],
'maxMode': [{ type: Input },],
'showWeeks': [{ type: Input },],
'formatDay': [{ type: Input },],
'formatMonth': [{ type: Input },],
'formatYear': [{ type: Input },],
'formatDayHeader': [{ type: Input },],
'formatDayTitle': [{ type: Input },],
'formatMonthTitle': [{ type: Input },],
'onlyCurrentMonth': [{ type: Input },],
'shortcutPropagation': [{ type: Input },],
'customClass': [{ type: Input },],
'monthColLimit': [{ type: Input },],
'yearColLimit': [{ type: Input },],
'dateDisabled': [{ type: Input },],
'dayDisabled': [{ type: Input },],
'initDate': [{ type: Input },],
'selectionDone': [{ type: Output },],
'update': [{ type: Output },],
'activeDateChange': [{ type: Output },],
'activeDate': [{ type: Input },],
};
return DatePickerInnerComponent;
}());
var DatepickerConfig = (function () {
function DatepickerConfig() {
this.locale = 'en';
this.datepickerMode = 'day';
this.startingDay = 0;
this.yearRange = 20;
this.minMode = 'day';
this.maxMode = 'year';
this.showWeeks = true;
this.formatDay = 'DD';
this.formatMonth = 'MMMM';
this.formatYear = 'YYYY';
this.formatDayHeader = 'dd';
this.formatDayTitle = 'MMMM YYYY';
this.formatMonthTitle = 'YYYY';
this.onlyCurrentMonth = false;
this.monthColLimit = 3;
this.yearColLimit = 5;
this.shortcutPropagation = false;
}
DatepickerConfig.decorators = [
{ type: Injectable },
];
/** @nocollapse */
DatepickerConfig.ctorParameters = function () { return []; };
return DatepickerConfig;
}());
var DATEPICKER_CONTROL_VALUE_ACCESSOR = {
provide: NG_VALUE_ACCESSOR,
// tslint:disable-next-line
useExisting: forwardRef(function () { return DatePickerComponent; }),
multi: true
};
/* tslint:disable:component-selector-name component-selector-type */
/* tslint:enable:component-selector-name component-selector-type */
var DatePickerComponent = (function () {
function DatePickerComponent(config) {
/** sets datepicker mode, supports: `day`, `month`, `year` */
this.datepickerMode = 'day';
/** if false week numbers will be hidden */
this.showWeeks = true;
this.selectionDone = new EventEmitter(undefined);
/** callback to invoke when the activeDate is changed. */
this.activeDateChange = new EventEmitter(undefined);
this.onChange = Function.prototype;
this.onTouched = Function.prototype;
this._now = new Date();
this.config = config;
this.configureOptions();
}
Object.defineProperty(DatePickerComponent.prototype, "activeDate", {
/** currently active date */
get: function () {
return this._activeDate || this._now;
},
set: function (value) {
this._activeDate = value;
},
enumerable: true,
configurable: true
});
DatePickerComponent.prototype.configureOptions = function () {
Object.assign(this, this.config);
};
DatePickerComponent.prototype.onUpdate = function (event) {
this.activeDate = event;
this.onChange(event);
};
DatePickerComponent.prototype.onSelectionDone = function (event) {
this.selectionDone.emit(event);
};
DatePickerComponent.prototype.onActiveDateChange = function (event) {
this.activeDateChange.emit(event);
};
// todo: support null value
DatePickerComponent.prototype.writeValue = function (value) {
if (this._datePicker.compare(value, this._activeDate) === 0) {
return;
}
if (value && value instanceof Date) {
this.activeDate = value;
this._datePicker.select(value, false);
return;
}
this.activeDate = value ? new Date(value) : void 0;
};
DatePickerComponent.prototype.registerOnChange = function (fn) {
this.onChange = fn;
};
DatePickerComponent.prototype.registerOnTouched = function (fn) {
this.onTouched = fn;
};
DatePickerComponent.decorators = [
{ type: Component, args: [{
selector: 'datepicker',
template: "\n <datepicker-inner [activeDate]=\"activeDate\"\n (update)=\"onUpdate($event)\"\n [locale]=\"config.locale\"\n [datepickerMode]=\"datepickerMode\"\n [initDate]=\"initDate\"\n [minDate]=\"minDate\"\n [maxDate]=\"maxDate\"\n [minMode]=\"minMode\"\n [maxMode]=\"maxMode\"\n [showWeeks]=\"showWeeks\"\n [formatDay]=\"formatDay\"\n [formatMonth]=\"formatMonth\"\n [formatYear]=\"formatYear\"\n [formatDayHeader]=\"formatDayHeader\"\n [formatDayTitle]=\"formatDayTitle\"\n [formatMonthTitle]=\"formatMonthTitle\"\n [startingDay]=\"startingDay\"\n [yearRange]=\"yearRange\"\n [customClass]=\"customClass\"\n [dateDisabled]=\"dateDisabled\"\n [dayDisabled]=\"dayDisabled\"\n [onlyCurrentMonth]=\"onlyCurrentMonth\"\n [shortcutPropagation]=\"shortcutPropagation\"\n [monthColLimit]=\"monthColLimit\"\n [yearColLimit]=\"yearColLimit\"\n (selectionDone)=\"onSelectionDone($event)\"\n (activeDateChange)=\"onActiveDateChange($event)\">\n <daypicker tabindex=\"0\"></daypicker>\n <monthpicker tabindex=\"0\"></monthpicker>\n <yearpicker tabindex=\"0\"></yearpicker>\n </datepicker-inner>\n ",
providers: [DATEPICKER_CONTROL_VALUE_ACCESSOR]
},] },
];
/** @nocollapse */
DatePickerComponent.ctorParameters = function () {
return [
{ type: DatepickerConfig, },
];
};
DatePickerComponent.propDecorators = {
'datepickerMode': [{ type: Input },],
'initDate': [{ type: Input },],
'minDate': [{ type: Input },],
'maxDate': [{ type: Input },],
'minMode': [{ type: Input },],
'maxMode': [{ type: Input },],
'showWeeks': [{ type: Input },],
'formatDay': [{ type: Input },],
'formatMonth': [{ type: Input },],
'formatYear': [{ type: Input },],
'formatDayHeader': [{ type: Input },],
'formatDayTitle': [{ type: Input },],
'formatMonthTitle': [{ type: Input },],
'startingDay': [{ type: Input },],
'yearRange': [{ type: Input },],
'onlyCurrentMonth': [{ type: Input },],
'shortcutPropagation': [{ type: Input },],
'monthColLimit': [{ type: Input },],
'yearColLimit': [{ type: Input },],
'customClass': [{ type: Input },],
'dateDisabled': [{ type: Input },],
'dayDisabled': [{ type: Input },],
'activeDate': [{ type: Input },],
'selectionDone': [{ type: Output },],
'activeDateChange': [{ type: Output },],
'_datePicker': [{ type: ViewChild, args: [DatePickerInnerComponent,] },],
};
return DatePickerComponent;
}());
// @deprecated
// tslint:disable
var DayPickerComponent = (function () {
function DayPickerComponent(datePicker) {
this.labels = [];
this.rows = [];
this.weekNumbers = [];
this.datePicker = datePicker;
}
Object.defineProperty(DayPickerComponent.prototype, "isBs4", {
get: function () {
return !isBs3();
},
enumerable: true,
configurable: true
});
/*protected getDaysInMonth(year:number, month:number) {
return ((month === 1) && (year % 4 === 0) &&
((year % 100 !== 0) || (year % 400 === 0))) ? 29 : DAYS_IN_MONTH[month];
}*/
DayPickerComponent.prototype.ngOnInit = function () {
var self = this;
this.datePicker.stepDay = { months: 1 };
this.datePicker.setRefreshViewHandler(function () {
var year = this.activeDate.getFullYear();
var month = this.activeDate.getMonth();
var firstDayOfMonth = new Date(year, month, 1);
var difference = this.startingDay - firstDayOfMonth.getDay();
var numDisplayedFromPreviousMonth = difference > 0 ? 7 - difference : -difference;
var firstDate = new Date(firstDayOfMonth.getTime());
if (numDisplayedFromPreviousMonth > 0) {
firstDate.setDate(-numDisplayedFromPreviousMonth + 1);
}
// 42 is the number of days on a six-week calendar
var _days = self.getDates(firstDate, 42);
var days = [];
for (var i = 0; i < 42; i++) {
var _dateObject = this.createDateObject(_days[i], this.formatDay);
_dateObject.secondary = _days[i].getMonth() !== month;
_dateObject.uid = this.uniqueId + '-' + i;
days[i] = _dateObject;
}
self.labels = [];
for (var j = 0; j < 7; j++) {
self.labels[j] = {};
self.labels[j].abbr = this.dateFilter(days[j].date, this.formatDayHeader);
self.labels[j].full = this.dateFilter(days[j].date, 'EEEE');
}
self.title = this.dateFilter(this.activeDate, this.formatDayTitle);
self.rows = this.split(days, 7);
if (this.showWeeks) {
self.weekNumbers = [];
var thursdayIndex = (4 + 7 - this.startingDay) % 7;
var numWeeks = self.rows.length;
for (var curWeek = 0; curWeek < numWeeks; curWeek++) {
self.weekNumbers.push(self.getISO8601WeekNumber(self.rows[curWeek][thursdayIndex].date));
}
}
}, 'day');
this.datePicker.setCompareHandler(function (date1, date2) {
var d1 = new Date(date1.getFullYear(), date1.getMonth(), date1.getDate());
var d2 = new Date(date2.getFullYear(), date2.getMonth(), date2.getDate());
return d1.getTime() - d2.getTime();
}, 'day');
this.datePicker.refreshView();
};
DayPickerComponent.prototype.getDates = function (startDate, n) {
var dates = new Array(n);
var current = new Date(startDate.getTime());
var i = 0;
var date;
while (i < n) {
date = new Date(current.getTime());
date = this.datePicker.fixTimeZone(date);
dates[i++] = date;
current = new Date(date.getFullYear(), date.getMonth(), date.getDate() + 1);
}
return dates;
};
DayPickerComponent.prototype.getISO8601WeekNumber = function (date) {
var checkDate = new Date(date.getTime());
// Thursday
checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
var time = checkDate.getTime();
// Compare with Jan 1
checkDate.setMonth(0);
checkDate.setDate(1);
return (Math.floor(Math.round((time - checkDate.getTime()) / 86400000) / 7) + 1);
};
// todo: key events implementation
DayPickerComponent.decorators = [
{ type: Component, args: [{
selector: 'daypicker',
template: "\n<table *ngIf=\"datePicker.datepickerMode === 'day'\" role=\"grid\" [attr.aria-labelledby]=\"datePicker.uniqueId + '-title'\" aria-activedescendant=\"activeDateId\">\n <thead>\n <tr>\n <th>\n <button *ngIf=\"!isBs4\"\n type=\"button\"\n class=\"btn btn-default btn-secondary btn-sm pull-left float-left\"\n (click)=\"datePicker.move(-1)\"\n tabindex=\"-1\">\u2039</button>\n <button *ngIf=\"isBs4\"\n type=\"button\"\n class=\"btn btn-default btn-secondary btn-sm pull-left float-left\"\n (click)=\"datePicker.move(-1)\"\n tabindex=\"-1\"><</button>\n </th>\n <th [attr.colspan]=\"5 + (datePicker.showWeeks ? 1 : 0)\">\n <button [id]=\"datePicker.uniqueId + '-title'\"\n type=\"button\" class=\"btn btn-default btn-secondary btn-sm\"\n (click)=\"datePicker.toggleMode(0)\"\n [disabled]=\"datePicker.datepickerMode === datePicker.maxMode\"\n [ngClass]=\"{disabled: datePicker.datepickerMode === datePicker.maxMode}\" tabindex=\"-1\" style=\"width:100%;\">\n <strong>{{ title }}</strong>\n </button>\n </th>\n <th>\n <button *ngIf=\"!isBs4\"\n type=\"button\"\n class=\"btn btn-default btn-secondary btn-sm pull-right float-right\"\n (click)=\"datePicker.move(1)\"\n tabindex=\"-1\">\u203A</button>\n <button *ngIf=\"isBs4\"\n type=\"button\"\n class=\"btn btn-default btn-secondary btn-sm pull-right float-right\"\n (click)=\"datePicker.move(1)\"\n tabindex=\"-1\">>\n </button>\n </th>\n </tr>\n <tr>\n <th *ngIf=\"datePicker.showWeeks\"></th>\n <th *ngFor=\"let labelz of labels\" class=\"text-center\">\n <small aria-label=\"labelz.full\"><b>{{ labelz.abbr }}</b></small>\n </th>\n </tr>\n </thead>\n <tbody>\n <ng-template ngFor [ngForOf]=\"rows\" let-rowz=\"$implicit\" let-index=\"index\">\n <tr *ngIf=\"!(datePicker.onlyCurrentMonth && rowz[0].secondary && rowz[6].secondary)\">\n <td *ngIf=\"datePicker.showWeeks\" class=\"h6\" class=\"text-center\">\n <em>{{ weekNumbers[index] }}</em>\n </td>\n <td *ngFor=\"let dtz of rowz\" class=\"text-center\" role=\"gridcell\" [id]=\"dtz.uid\">\n <button type=\"button\" style=\"min-width:100%;\" class=\"btn btn-sm {{dtz.customClass}}\"\n *ngIf=\"!(datePicker.onlyCurrentMonth && dtz.secondary)\"\n [ngClass]=\"{'btn-secondary': isBs4 && !dtz.selected && !datePicker.isActive(dtz), 'btn-info': dtz.selected, disabled: dtz.disabled, active: !isBs4 && datePicker.isActive(dtz), 'btn-default': !isBs4}\"\n [disabled]=\"dtz.disabled\"\n (click)=\"datePicker.select(dtz.date)\" tabindex=\"-1\">\n <span [ngClass]=\"{'text-muted': dtz.secondary || dtz.current, 'text-info': !isBs4 && dtz.current}\">{{ dtz.label }}</span>\n </button>\n </td>\n </tr>\n </ng-template>\n </tbody>\n</table>\n ",
styles: [
"\n :host .btn-secondary {\n color: #292b2c;\n background-color: #fff;\n border-color: #ccc;\n }\n :host .btn-info .text-muted {\n color: #292b2c !important;\n }\n "
]
},] },
];
/** @nocollapse */
DayPickerComponent.ctorParameters = function () {
return [
{ type: DatePickerInnerComponent, },
];
};
return DayPickerComponent;
}());
// @deprecated
// tslint:disable
var MonthPickerComponent = (function () {
function MonthPickerComponent(datePicker) {
this.rows = [];
this.datePicker = datePicker;
}
Object.defineProperty(MonthPickerComponent.prototype, "isBs4", {
get: function () {
return !isBs3();
},
enumerable: true,
configurable: true
});
MonthPickerComponent.prototype.ngOnInit = function () {
var self = this;
this.datePicker.stepMonth = { years: 1 };
this.datePicker.setRefreshViewHandler(function () {
var months = new Array(12);
var year = this.activeDate.getFullYear();
var date;
for (var i = 0; i < 12; i++) {
date = new Date(year, i, 1);
date = this.fixTimeZone(date);
months[i] = this.createDateObject(date, this.formatMonth);
months[i].uid = this.uniqueId + '-' + i;
}
self.title = this.dateFilter(this.activeDate, this.formatMonthTitle);
self.rows = this.split(months, self.datePicker.monthColLimit);
}, 'month');
this.datePicker.setCompareHandler(function (date1, date2) {
var d1 = new Date(date1.getFullYear(), date1.getMonth());
var d2 = new Date(date2.getFullYear(), date2.getMonth());
return d1.getTime() - d2.getTime();
}, 'month');
this.datePicker.refreshView();
};
// todo: key events implementation
MonthPickerComponent.decorators = [
{ type: Component, args: [{
selector: 'monthpicker',
template: "\n<table *ngIf=\"datePicker.datepickerMode==='month'\" role=\"grid\">\n <thead>\n <tr>\n <th>\n <button type=\"button\" class=\"btn btn-default btn-sm pull-left float-left\"\n (click)=\"datePicker.move(-1)\" tabindex=\"-1\">\u2039</button></th>\n <th [attr.colspan]=\"((datePicker.monthColLimit - 2) <= 0) ? 1 : datePicker.monthColLimit - 2\">\n <button [id]=\"datePicker.uniqueId + '-title'\"\n type=\"button\" class=\"btn btn-default btn-sm\"\n (click)=\"datePicker.toggleMode(0)\"\n [disabled]=\"datePicker.datepickerMode === maxMode\"\n [ngClass]=\"{disabled: datePicker.datepickerMode === maxMode}\" tabindex=\"-1\" style=\"width:100%;\">\n <strong>{{ title }}</strong> \n </button>\n </th>\n <th>\n <button type=\"button\" class=\"btn btn-default btn-sm pull-right float-right\"\n (click)=\"datePicker.move(1)\" tabindex=\"-1\">\u203A</button>\n </th>\n </tr>\n </thead>\n <tbody>\n <tr *ngFor=\"let rowz of rows\">\n <td *ngFor=\"let dtz of rowz\" class=\"text-center\" role=\"gridcell\" [attr.id]=\"dtz.uid\" [ngClass]=\"dtz.customClass\">\n <button type=\"button\" style=\"min-width:100%;\" class=\"btn btn-default\"\n [ngClass]=\"{'btn-link': isBs4 && !dtz.selected && !datePicker.isActive(dtz), 'btn-info': dtz.selected || (isBs4 && !dtz.selected && datePicker.isActive(dtz)), disabled: dtz.disabled, active: !isBs4 && datePicker.isActive(dtz)}\"\n [disabled]=\"dtz.disabled\"\n (click)=\"datePicker.select(dtz.date)\" tabindex=\"-1\">\n <span [ngClass]=\"{'text-success': isBs4 && dtz.current, 'text-info': !isBs4 && dtz.current}\">{{ dtz.label }}</span>\n </button>\n </td>\n </tr>\n </tbody>\n</table>\n ",
styles: [
"\n :host .btn-info .text-success {\n color: #fff !important;\n }\n "
]
},] },
];
/** @nocollapse */
MonthPickerComponent.ctorParameters = function () {
return [
{ type: DatePickerInnerComponent, },
];
};
return MonthPickerComponent;
}());
// @deprecated
// tslint:disable
var YearPickerComponent = (function () {
function YearPickerComponent(datePicker) {
this.rows = [];
this.datePicker = datePicker;
}
Object.defineProperty(YearPickerComponent.prototype, "isBs4", {
get: function () {
return !isBs3();
},
enumerable: true,
configurable: true
});
YearPickerComponent.prototype.ngOnInit = function () {
var self = this;
this.datePicker.stepYear = { years: this.datePicker.yearRange };
this.datePicker.setRefreshViewHandler(function () {
var years = new Array(this.yearRange);
var date;
var start = self.getStartingYear(this.activeDate.getFullYear());
for (var i = 0; i < this.yearRange; i++) {
date = new Date(start + i, 0, 1);
date = this.fixTimeZone(date);
years[i] = this.createDateObject(date, this.formatYear);
years[i].uid = this.uniqueId + '-' + i;
}
self.title = [years[0].label, years[this.yearRange - 1].label].join(' - ');
self.rows = this.split(years, self.datePicker.yearColLimit);
}, 'year');
this.datePicker.setCompareHandler(function (date1, date2) {
return date1.getFullYear() - date2.getFullYear();
}, 'year');
this.datePicker.refreshView();
};
YearPickerComponent.prototype.getStartingYear = function (year) {
// todo: parseInt
return ((year - 1) / this.datePicker.yearRange * this.datePicker.yearRange + 1);
};
YearPickerComponent.decorators = [
{ type: Component, args: [{
selector: 'yearpicker',
template: "\n<table *ngIf=\"datePicker.datepickerMode==='year'\" role=\"grid\">\n <thead>\n <tr>\n <th>\n <button type=\"button\" class=\"btn btn-default btn-sm pull-left float-left\"\n (click)=\"datePicker.move(-1)\" tabindex=\"-1\">\u2039</button>\n </th>\n <th [attr.colspan]=\"((datePicker.yearColLimit - 2) <= 0) ? 1 : datePicker.yearColLimit - 2\">\n <button [id]=\"datePicker.uniqueId + '-title'\" role=\"heading\"\n type=\"button\" class=\"btn btn-default btn-sm\"\n (click)=\"datePicker.toggleMode(0)\"\n [disabled]=\"datePicker.datepickerMode === datePicker.maxMode\"\n [ngClass]=\"{disabled: datePicker.datepickerMode === datePicker.maxMode}\" tabindex=\"-1\" style=\"width:100%;\">\n <strong>{{ title }}</strong>\n </button>\n </th>\n <th>\n <button type=\"button\" class=\"btn btn-default btn-sm pull-right float-right\"\n (click)=\"datePicker.move(1)\" tabindex=\"-1\">\u203A</button>\n </th>\n </tr>\n </thead>\n <tbody>\n <tr *ngFor=\"let rowz of rows\">\n <td *ngFor=\"let dtz of rowz\" class=\"text-center\" role=\"gridcell\" [attr.id]=\"dtz.uid\">\n <button type=\"button\" style=\"min-width:100%;\" class=\"btn btn-default\"\n [ngClass]=\"{'btn-link': isBs4 && !dtz.selected && !datePicker.isActive(dtz), 'btn-info': dtz.selected || (isBs4 && !dtz.selected && datePicker.isActive(dtz)), disabled: dtz.disabled, active: !isBs4 && datePicker.isActive(dtz)}\"\n [disabled]=\"dtz.disabled\"\n (click)=\"datePicker.select(dtz.date)\" tabindex=\"-1\">\n <span [ngClass]=\"{'text-success': isBs4 && dtz.current, 'text-info': !isBs4 && dtz.current}\">{{ dtz.label }}</span>\n </button>\n </td>\n </tr>\n </tbody>\n</table>\n ",
styles: [
"\n :host .btn-info .text-success {\n color: #fff !important;\n }\n "
]
},] },
];
/** @nocollapse */
YearPickerComponent.ctorParameters = function () {
return [
{ type: DatePickerInnerComponent, },
];
};
return YearPickerComponent;
}());
var _messagesHash = {};
var _hideMsg = typeof console === 'undefined' || !('warn' in console);
function warnOnce(msg) {
if (!isDevMode() || _hideMsg || msg in _messagesHash) {
return;
}
_messagesHash[msg] = true;
/*tslint:disable-next-line*/
console.warn(msg);
}
var BsDatepickerAbstractComponent = (function () {
function BsDatepickerAbstractComponent() {
this._customRangesFish = [];
}
Object.defineProperty(BsDatepickerAbstractComponent.prototype, "minDate", {
set: function (value) {
this._effects.setMinDate(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(BsDatepickerAbstractComponent.prototype, "maxDate", {
set: function (value) {
this._effects.setMaxDate(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(BsDatepickerAbstractComponent.prototype, "isDisabled", {
set: function (value) {
this._effects.setDisabled(value);
},
enumerable: true,
configurable: true
});
BsDatepickerAbstractComponent.prototype.setViewMode = function (event) { };
BsDatepickerAbstractComponent.prototype.navigateTo = function (event) { };
BsDatepickerAbstractComponent.prototype.dayHoverHandler = function (event) { };
BsDatepickerAbstractComponent.prototype.monthHoverHandler = function (event) { };
BsDatepickerAbstractComponent.prototype.yearHoverHandler = function (event) { };
BsDatepickerAbstractComponent.prototype.daySelectHandler = function (day) { };
BsDatepickerAbstractComponent.prototype.monthSelectHandler = function (event) { };
BsDatepickerAbstractComponent.prototype.yearSelectHandler = function (event) { };
BsDatepickerAbstractComponent.prototype._stopPropagation = function (event) {
event.stopPropagation();
};
return BsDatepickerAbstractComponent;
}());
/**
* For date range picker there are `BsDaterangepickerConfig` which inherits all properties,
* except `displayMonths`, for range picker it default to `2`
*/
var BsDatepickerConfig = (function () {
function BsDatepickerConfig() {
/** CSS class which will be applied to datepicker container,
* usually used to set color theme
*/
this.containerClass = 'theme-green';
// DatepickerRenderOptions
this.displayMonths = 1;
/**
* Allows to hide week numbers in datepicker
*/
this.showWeekNumbers = true;
this.dateInputFormat = 'L';
// range picker
this.rangeSeparator = ' - ';
/**
* Date format for date range input field
*/
this.rangeInputFormat = 'L';
// DatepickerFormatOptions
this.monthTitle = 'MMMM';
this.yearTitle = 'YYYY';
this.dayLabel = 'D';
this.monthLabel = 'MMMM';
this.yearLabel = 'YYYY';
this.weekNumbers = 'w';
}
BsDatepickerConfig.decorators = [
{ type: Injectable },
];
/** @nocollapse */
BsDatepickerConfig.ctorParameters = function () { return []; };
return BsDatepickerConfig;
}());
var BsDatepickerActions = (function () {
function BsDatepickerActions() {
}
BsDatepickerActions.prototype.calculate = function () {
return { type: BsDatepickerActions.CALCULATE };
};
BsDatepickerActions.prototype.format = function () {
return { type: BsDatepickerActions.FORMAT };
};
BsDatepickerActions.prototype.flag = function () {
return { type: BsDatepickerActions.FLAG };
};
BsDatepickerActions.prototype.select = function (date) {
return {
type: BsDatepickerActions.SELECT,
payload: date
};
};
BsDatepickerActions.prototype.changeViewMode = function (event) {
return {
type: BsDatepickerActions.CHANGE_VIEWMODE,
payload: event
};
};
BsDatepickerActions.prototype.navigateTo = function (event) {
return {
type: BsDatepickerActions.NAVIGATE_TO,
payload: event
};
};
BsDatepickerActions.prototype.navigateStep = function (step) {
return {
type: BsDatepickerActions.NAVIGATE_OFFSET,
payload: step
};
};
BsDatepickerActions.prototype.setOptions = function (options) {
return {
type: BsDatepickerActions.SET_OPTIONS,
payload: options
};
};
// date range picker
BsDatepickerActions.prototype.selectRange = function (value) {
return {
type: BsDatepickerActions.SELECT_RANGE,
payload: value
};
};
BsDatepickerActions.prototype.hoverDay = function (event) {
return {
type: BsDatepickerActions.HOVER,
payload: event.isHovered ? event.cell.date : null
};
};
BsDatepickerActions.prototype.minDate = function (date) {
return {
type: BsDatepickerActions.SET_MIN_DATE,
payload: date
};
};
BsDatepickerActions.prototype.maxDate = function (date) {
return {
type: BsDatepickerActions.SET_MAX_DATE,
payload: date
};
};
BsDatepickerActions.prototype.isDisabled = function (value) {
return {
type: BsDatepickerActions.SET_IS_DISABLED,
payload: value
};
};
BsDatepickerActions.prototype.setLocale = function (locale) {
return {
type: BsDatepickerActions.SET_LOCALE,
payload: locale
};
};
BsDatepickerActions.CALCULATE = '[datepicker] calculate dates matrix';
BsDatepickerActions.FORMAT = '[datepicker] format datepicker values';
BsDatepickerActions.FLAG = '[datepicker] set flags';
BsDatepickerActions.SELECT = '[datepicker] select date';
BsDatepickerActions.NAVIGATE_OFFSET = '[datepicker] shift view date';
BsDatepickerActions.NAVIGATE_TO = '[datepicker] change view date';
BsDatepickerActions.SET_OPTIONS = '[datepicker] update render options';
BsDatepickerActions.HOVER = '[datepicker] hover date';
BsDatepickerActions.CHANGE_VIEWMODE = '[datepicker] switch view mode';
BsDatepickerActions.SET_MIN_DATE = '[datepicker] set min date';
BsDatepickerActions.SET_MAX_DATE = '[datepicker] set max date';
BsDatepickerActions.SET_IS_DISABLED = '[datepicker] set is disabled';
BsDatepickerActions.SET_LOCALE = '[datepicker] set datepicker locale';
BsDatepickerActions.SELECT_RANGE = '[daterangepicker] select dates range';
BsDatepickerActions.decorators = [
{ type: Injectable },
];
/** @nocollapse */
BsDatepickerActions.ctorParameters = function () { return []; };
return BsDatepickerActions;
}());
var BsLocaleService = (function () {
function BsLocaleService() {
this._defaultLocale = 'en';
this._locale = new BehaviorSubject$1(this._defaultLocale);
this._localeChange = this._locale.asObservable();
}
Object.defineProperty(BsLocaleService.prototype, "locale", {
get: function () {
return this._locale;
},
enumerable: true,
configurable: true
});
Object.defineProperty(BsLocaleService.prototype, "localeChange", {
get: function () {
return this._localeChange;
},
enumerable: true,
configurable: true
});
Object.defineProperty(BsLocaleService.prototype, "currentLocale", {
get: function () {
return this._locale.getValue();
},
enumerable: true,
configurable: true
});
BsLocaleService.prototype.use = function (locale) {
if (locale === this.currentLocale) {
return;
}
this._locale.next(locale);
};
BsLocaleService.decorators = [
{ type: Injectable },
];
/** @nocollapse */
BsLocaleService.ctorParameters = function () { return []; };
return BsLocaleService;
}());
var BsDatepickerEffects = (function () {
function BsDatepickerEffects(_actions, _localeService) {
this._actions = _actions;
this._localeService = _localeService;
this._subs = [];
}
BsDatepickerEffects.prototype.init = function (_bsDatepickerStore) {
this._store = _bsDatepickerStore;
return this;
};
/** setters */
BsDatepickerEffects.prototype.setValue = function (value) {
this._store.dispatch(this._actions.select(value));
};
BsDatepickerEffects.prototype.setRangeValue = function (value) {
this._store.dispatch(this._actions.selectRange(value));
};
BsDatepickerEffects.prototype.setMinDate = function (value) {
this._store.dispatch(this._actions.minDate(value));
return this;
};
BsDatepickerEffects.prototype.setMaxDate = function (value) {
this._store.dispatch(this._actions.maxDate(value));
return this;
};
BsDatepickerEffects.prototype.setDisabled = function (value) {
this._store.dispatch(this._actions.isDisabled(value));
return this;
};
/* Set rendering options */
BsDatepickerEffects.prototype.setOptions = function (_config) {
var _options = Object.assign({ locale: this._localeService.currentLocale }, _config);
this._store.dispatch(this._actions.setOptions(_options));
return this;
};
/** view to mode bindings */
BsDatepickerEffects.prototype.setBindings = function (container) {
container.daysCalendar = this._store
.select(function (state) { return state.flaggedMonths; })
.filter(function (months) { return !!months; });
// month calendar
container.monthsCalendar = this._store
.select(function (state) { return state.flaggedMonthsCalendar; })
.filter(function (months) { return !!months; });
// year calendar
container.yearsCalendar = this._store
.select(function (state) { return state.yearsCalendarFlagged; })
.filter(function (years) { return !!years; });
container.viewMode = this._store.select(function (state) { return state.view.mode; });
container.options = this._store
.select(function (state) { return state.showWeekNumbers; })
.map(function (showWeekNumbers) { return ({ showWeekNumbers: showWeekNumbers }); });
return this;
};
/** event handlers */
BsDatepickerEffects.prototype.setEventHandlers = function (container) {
var _this = this;
container.setViewMode = function (event) {
_this._store.dispatch(_this._actions.changeViewMode(event));
};
container.navigateTo = function (event) {
_this._store.dispatch(_this._actions.navigateStep(event.step));
};
container.dayHoverHandler = function (event) {
var _cell = event.cell;
if (_cell.isOtherMonth || _cell.isDisabled) {
return;
}
_this._store.dispatch(_this._actions.hoverDay(event));
_cell.isHovered = event.isHovered;
};
container.monthHoverHandler = function (event) {
event.cell.isHovered = event.isHovered;
};
container.yearHoverHandler = function (event) {
event.cell.isHovered = event.isHovered;
};
/** select handlers */
// container.daySelectHandler = (day: DayViewModel): void => {
// if (day.isOtherMonth || day.isDisabled) {
// return;
// }
// this._store.dispatch(this._actions.select(day.date));
// };
container.monthSelectHandler = function (event) {
if (event.isDisabled) {
return;
}
_this._store.dispatch(_this._actions.navigateTo({
unit: { month: getMonth(event.date) },
viewMode: 'day'
}));
};
container.yearSelectHandler = function (event) {
if (event.isDisabled) {
return;
}
_this._store.dispatch(_this._actions.navigateTo({
unit: { year: getFullYear(event.date) },
viewMode: 'month'
}));
};
return this;
};
BsDatepickerEffects.prototype.registerDatepickerSideEffects = function () {
var _this = this;
this._subs.push(this._store.select(function (state) { return state.view; }).subscribe(function (view) {
_this._store.dispatch(_this._actions.calculate());
}));
// format calendar values on month model change
this._subs.push(this._store
.select(function (state) { return state.monthsModel; })
.filter(function (monthModel) { return !!monthModel; })
.subscribe(function (month) { return _this._store.dispatch(_this._actions.format()); }));
// flag day values
this._subs.push(this._store
.select(function (state) { return state.formattedMonths; })
.filter(function (month) { return !!month; })
.subscribe(function (month) { return _this._store.dispatch(_this._actions.flag()); }));
// flag day values
this._subs.push(this._store
.select(function (state) { return state.selectedDate; })
.filter(function (selectedDate) { return !!selectedDate; })
.subscribe(function (selectedDate) { return _this._store.dispatch(_this._actions.flag()); }));
// flag for date range picker
this._subs.push(this._store
.select(function (state) { return state.selectedRange; })
.filter(function (selectedRange) { return !!selectedRange; })
.subscribe(function (selectedRange) { return _this._store.dispatch(_this._actions.flag()); }));
// monthsCalendar
this._subs.push(this._store
.select(function (state) { return state.monthsCalendar; })
.subscribe(function () { return _this._store.dispatch(_this._actions.flag()); }));
// years calendar
this._subs.push(this._store
.select(function (state) { return state.yearsCalendarModel; })
.filter(function (state) { return !!state; })
.subscribe(function () { return _this._store.dispatch(_this._actions.flag()); }));
// on hover
this._subs.push(this._store
.select(function (state) { return state.hoveredDate; })
.filter(function (hoveredDate) { return !!hoveredDate; })
.subscribe(function (hoveredDate) { return _this._store.dispatch(_this._actions.flag()); }));
// on locale change
this._subs.push(this._localeService.localeChange
.subscribe(function (locale) { return _this._store.dispatch(_this._actions.setLocale(locale)); }));
return this;
};
BsDatepickerEffects.prototype.destroy = function () {
for (var _i = 0, _a = this._subs; _i < _a.length; _i++) {
var sub = _a[_i];
sub.unsubscribe();
}
};
BsDatepickerEffects.decorators = [
{ type: Injectable },
];
/** @nocollapse */
BsDatepickerEffects.ctorParameters = function () {
return [
{ type: BsDatepickerActions, },
{ type: BsLocaleService, },
];
};
return BsDatepickerEffects;
}());
var __extends$2 = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b)
if (b.hasOwnProperty(p))
d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
/**
* @copyright ngrx
*/
var MiniStore = (function (_super) {
__extends$2(MiniStore, _super);
function MiniStore(_dispatcher, _reducer, state$) {
var _this = _super.call(this) || this;
_this._dispatcher = _dispatcher;
_this._reducer = _reducer;
_this.source = state$;
return _this;
}
MiniStore.prototype.select = function (pathOrMapFn) {
var mapped$ = map$2.call(this, pathOrMapFn);
return distinctUntilChanged$1.call(mapped$);
};
MiniStore.prototype.lift = function (operator) {
var store = new MiniStore(this._dispatcher, this._reducer, this);
store.operator = operator;
return store;
};
MiniStore.prototype.dispatch = function (action) {
this._dispatcher.next(action);
};
MiniStore.prototype.next = function (action) {
this._dispatcher.next(action);
};
MiniStore.prototype.error = function (err) {
this._dispatcher.error(err);
};
MiniStore.prototype.complete = function () {
/*noop*/
};
return MiniStore;
}(Observable$1));
var defaultMonthOptions = {
width: 7,
height: 6
};
var _initialView = { date: new Date(), mode: 'day' };
var initialDatepickerState = Object.assign(new BsDatepickerConfig(), {
locale: 'en',
view: _initialView,
selectedRange: [],
monthViewOptions: defaultMonthOptions
});
var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
// CommonJS / Node have global context exposed as "global" variable.
// We don't want to include the whole node.d.ts this this compilation unit so we'll just fake
// the global "global" var for now.
var __window = typeof window !== 'undefined' && window;
var __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' &&
self instanceof WorkerGlobalScope && self;
var __global = typeof commonjsGlobal !== 'undefined' && commonjsGlobal;
var _root = __window || __global || __self;
var root_1 = _root;
// Workaround Closure Compiler restriction: The body of a goog.module cannot use throw.
// This is needed when used with angular/tsickle which inserts a goog.module statement.
// Wrap in IIFE
(function () {
if (!_root) {
throw new Error('RxJS could not find any global context (window, self, global)');
}
})();
var root = {
root: root_1
};
var isArray_1 = Array.isArray || (function (x) { return x && typeof x.length === 'number'; });
var isArray$1 = {
isArray: isArray_1
};
function isObject$1(x) {
return x != null && typeof x === 'object';
}
var isObject_2 = isObject$1;
var isObject_1 = {
isObject: isObject_2
};
function isFunction$1(x) {
return typeof x === 'function';
}
var isFunction_2 = isFunction$1;
var isFunction_1 = {
isFunction: isFunction_2
};
// typeof any so that it we don't have to cast when comparing a result to the error object
var errorObject_1 = { e: {} };
var errorObject = {
errorObject: errorObject_1
};
var tryCatchTarget;
function tryCatcher() {
try {
return tryCatchTarget.apply(this, arguments);
}
catch (e) {
errorObject.errorObject.e = e;
return errorObject.errorObject;
}
}
function tryCatch(fn) {
tryCatchTarget = fn;
return tryCatcher;
}
var tryCatch_2 = tryCatch;
var tryCatch_1 = {
tryCatch: tryCatch_2
};
var __extends$7 = (commonjsGlobal && commonjsGlobal.__extends) || function (d, b) {
for (var p in b)
if (b.hasOwnProperty(p))
d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
/**
* An error thrown when one or more errors have occurred during the
* `unsubscribe` of a {@link Subscription}.
*/
var UnsubscriptionError = (function (_super) {
__extends$7(UnsubscriptionError, _super);
function UnsubscriptionError(errors) {
_super.call(this);
this.errors = errors;
var err = Error.call(this, errors ?
errors.length + " errors occurred during unsubscription:\n " + errors.map(function (err, i) { return ((i + 1) + ") " + err.toString()); }).join('\n ') : '');
this.name = err.name = 'UnsubscriptionError';
this.stack = err.stack;
this.message = err.message;
}
return UnsubscriptionError;
}(Error));
var UnsubscriptionError_2 = UnsubscriptionError;
var UnsubscriptionError_1 = {
UnsubscriptionError: UnsubscriptionError_2
};
/**
* Represents a disposable resource, such as the execution of an Observable. A
* Subscription has one important method, `unsubscribe`, that takes no argument
* and just disposes the resource held by the subscription.
*
* Additionally, subscriptions may be grouped together through the `add()`
* method, which will attach a child Subscription to the current Subscription.
* When a Subscription is unsubscribed, all its children (and its grandchildren)
* will be unsubscribed as well.
*
* @class Subscription
*/
var Subscription = (function () {
/**
* @param {function(): void} [unsubscribe] A function describing how to
* perform the disposal of resources when the `unsubscribe` method is called.
*/
function Subscription(unsubscribe) {
/**
* A flag to indicate whether this Subscription has already been unsubscribed.
* @type {boolean}
*/
this.closed = false;
this._parent = null;
this._parents = null;
this._subscriptions = null;
if (unsubscribe) {
this._unsubscribe = unsubscribe;
}
}
/**
* Disposes the resources held by the subscription. May, for instance, cancel
* an ongoing Observable execution or cancel any other type of work that
* started when the Subscription was created.
* @return {void}
*/
Subscription.prototype.unsubscribe = function () {
var hasErrors = false;
var errors;
if (this.closed) {
return;
}
var _a = this, _parent = _a._parent, _parents = _a._parents, _unsubscribe = _a._unsubscribe, _subscriptions = _a._subscriptions;
this.closed = true;
this._parent = null;
this._parents = null;
// null out _subscriptions first so any child subscriptions that attempt
// to remove themselves from this subscription will noop
this._subscriptions = null;
var index = -1;
var len = _parents ? _parents.length : 0;
// if this._parent is null, then so is this._parents, and we
// don't have to remove ourselves from any parent subscriptions.
while (_parent) {
_parent.remove(this);
// if this._parents is null or index >= len,
// then _parent is set to null, and the loop exits
_parent = ++index < len && _parents[index] || null;
}
if (isFunction_1.isFunction(_unsubscribe)) {
var trial = tryCatch_1.tryCatch(_unsubscribe).call(this);
if (trial === errorObject.errorObject) {
hasErrors = true;
errors = errors || (errorObject.errorObject.e instanceof UnsubscriptionError_1.UnsubscriptionError ?
flattenUnsubscriptionErrors(errorObject.errorObject.e.errors) : [errorObject.errorObject.e]);
}
}
if (isArray$1.isArray(_subscriptions)) {
index = -1;
len = _subscriptions.length;
while (++index < len) {
var sub = _subscriptions[index];
if (isObject_1.isObject(sub)) {
var trial = tryCatch_1.tryCatch(sub.unsubscribe).call(sub);
if (trial === errorObject.errorObject) {
hasErrors = true;
errors = errors || [];
var err = errorObject.errorObject.e;
if (err instanceof UnsubscriptionError_1.UnsubscriptionError) {
errors = errors.concat(flattenUnsubscriptionErrors(err.errors));
}
else {
errors.push(err);
}
}
}
}
}
if (hasErrors) {
throw new UnsubscriptionError_1.UnsubscriptionError(errors);
}
};
/**
* Adds a tear down to be called during the unsubscribe() of this
* Subscription.
*
* If the tear down being added is a subscription that is already
* unsubscribed, is the same reference `add` is being called on, or is
* `Subscription.EMPTY`, it will not be added.
*
* If this subscription is already in an `closed` state, the passed
* tear down logic will be executed immediately.
*
* @param {TeardownLogic} teardown The additional logic to execute on
* teardown.
* @return {Subscription} Returns the Subscription used or created to be
* added to the inner subscriptions list. This Subscription can be used with
* `remove()` to remove the passed teardown logic from the inner subscriptions
* list.
*/
Subscription.prototype.add = function (teardown) {
if (!teardown || (teardown === Subscription.EMPTY)) {
return Subscription.EMPTY;
}
if (teardown === this) {
return this;
}
var subscription = teardown;
switch (typeof teardown) {
case 'function':
subscription = new Subscription(teardown);
case 'object':
if (subscription.closed || typeof subscription.unsubscribe !== 'function') {
return subscription;
}
else if (this.closed) {
subscription.unsubscribe();
return subscription;
}
else if (typeof subscription._addParent !== 'function' /* quack quack */) {
var tmp = subscription;
subscription = new Subscription();
subscription._subscriptions = [tmp];
}
break;
default:
throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.');
}
var subscriptions = this._subscriptions || (this._subscriptions = []);
subscriptions.push(subscription);
subscription._addParent(this);
return subscription;
};
/**
* Removes a Subscription from the internal list of subscriptions that will
* unsubscribe during the unsubscribe process of this Subscription.
* @param {Subscription} subscription The subscription to remove.
* @return {void}
*/
Subscription.prototype.remove = function (subscription) {
var subscriptions = this._subscriptions;
if (subscriptions) {
var subscriptionIndex = subscriptions.indexOf(subscription);
if (subscriptionIndex !== -1) {
subscriptions.splice(subscriptionIndex, 1);
}
}
};
Subscription.prototype._addParent = function (parent) {
var _a = this, _parent = _a._parent, _parents = _a._parents;
if (!_parent || _parent === parent) {
// If we don't have a parent, or the new parent is the same as the
// current parent, then set this._parent to the new parent.
this._parent = parent;
}
else if (!_parents) {
// If there's already one parent, but not multiple, allocate an Array to
// store the rest of the parent Subscriptions.
this._parents = [parent];
}
else if (_parents.indexOf(parent) === -1) {
// Only add the new parent to the _parents list if it's not already there.
_parents.push(parent);
}
};
Subscription.EMPTY = (function (empty) {
empty.closed = true;
return empty;
}(new Subscription()));
return Subscription;
}());
var Subscription_2 = Subscription;
function flattenUnsubscriptionErrors(errors) {
return errors.reduce(function (errs, err) { return errs.concat((err instanceof UnsubscriptionError_1.UnsubscriptionError) ? err.errors : err); }, []);
}
var Subscription_1 = {
Subscription: Subscription_2
};
var __extends$6 = (commonjsGlobal && commonjsGlobal.__extends) || function (d, b) {
for (var p in b)
if (b.hasOwnProperty(p))
d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
/**
* A unit of work to be executed in a {@link Scheduler}. An action is typically
* created from within a Scheduler and an RxJS user does not need to concern
* themselves about creating and manipulating an Action.
*
* ```ts
* class Action<T> extends Subscription {
* new (scheduler: Scheduler, work: (state?: T) => void);
* schedule(state?: T, delay: number = 0): Subscription;
* }
* ```
*
* @class Action<T>
*/
var Action = (function (_super) {
__extends$6(Action, _super);
function Action(scheduler, work) {
_super.call(this);
}
/**
* Schedules this action on its parent Scheduler for execution. May be passed
* some context object, `state`. May happen at some point in the future,
* according to the `delay` parameter, if specified.
* @param {T} [state] Some contextual data that the `work` function uses when
* called by the Scheduler.
* @param {number} [delay] Time to wait before executing the work, where the
* time unit is implicit and defined by the Scheduler.
* @return {void}
*/
Action.prototype.schedule = function (state, delay) {
if (delay === void 0) {
delay = 0;
}
return this;
};
return Action;
}(Subscription_1.Subscription));
var Action_2 = Action;
var Action_1 = {
Action: Action_2
};
var __extends$5 = (commonjsGlobal && commonjsGlobal.__extends) || function (d, b) {
for (var p in b)
if (b.hasOwnProperty(p))
d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
var AsyncAction = (function (_super) {
__extends$5(AsyncAction, _super);
function AsyncAction(scheduler, work) {
_super.call(this, scheduler, work);
this.scheduler = scheduler;
this.work = work;
this.pending = false;
}
AsyncAction.prototype.schedule = function (state, delay) {
if (delay === void 0) {
delay = 0;
}
if (this.closed) {
return this;
}
// Always replace the current state with the new state.
this.state = state;
// Set the pending flag indicating that this action has been scheduled, or
// has recursively rescheduled itself.
this.pending = true;
var id = this.id;
var scheduler = this.scheduler;
//
// Important implementation note:
//
// Actions only execute once by default, unless rescheduled from within the
// scheduled callback. This allows us to implement single and repeat
// actions via the same code path, without adding API surface area, as well
// as mimic traditional recursion but across asynchronous boundaries.
//
// However, JS runtimes and timers distinguish between intervals achieved by
// serial `setTimeout` calls vs. a single `setInterval` call. An interval of
// serial `setTimeout` calls can be individually delayed, which delays
// scheduling the next `setTimeout`, and so on. `setInterval` attempts to
// guarantee the interval callback will be invoked more precisely to the
// interval period, regardless of load.
//
// Therefore, we use `setInterval` to schedule single and repeat actions.
// If the action reschedules itself with the same delay, the interval is not
// canceled. If the action doesn't reschedule, or reschedules with a
// different delay, the interval will be canceled after scheduled callback
// execution.
//
if (id != null) {
this.id = this.recycleAsyncId(scheduler, id, delay);
}
this.delay = delay;
// If this action has already an async Id, don't request a new one.
this.id = this.id || this.requestAsyncId(scheduler, this.id, delay);
return this;
};
AsyncAction.prototype.requestAsyncId = function (scheduler, id, delay) {
if (delay === void 0) {
delay = 0;
}
return root.root.setInterval(scheduler.flush.bind(scheduler, this), delay);
};
AsyncAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
if (delay === void 0) {
delay = 0;
}
// If this action is rescheduled with the same delay time, don't clear the interval id.
if (delay !== null && this.delay === delay && this.pending === false) {
return id;
}
// Otherwise, if the action's delay time is different from the current delay,
// or the action has been rescheduled before it's executed, clear the interval id
return root.root.clearInterval(id) && undefined || undefined;
};
/**
* Immediately executes this action and the `work` it contains.
* @return {any}
*/
AsyncAction.prototype.execute = function (state, delay) {
if (this.closed) {
return new Error('executing a cancelled action');
}
this.pending = false;
var error = this._execute(state, delay);
if (error) {
return error;
}
else if (this.pending === false && this.id != null) {
// Dequeue if the action didn't reschedule itself. Don't call
// unsubscribe(), because the action could reschedule later.
// For example:
// ```
// scheduler.schedule(function doWork(counter) {
// /* ... I'm a busy worker bee ... */
// var originalAction = this;
// /* wait 100ms before rescheduling the action */
// setTimeout(function () {
// originalAction.schedule(counter + 1);
// }, 100);
// }, 1000);
// ```
this.id = this.recycleAsyncId(this.scheduler, this.id, null);
}
};
AsyncAction.prototype._execute = function (state, delay) {
var errored = false;
var errorValue = undefined;
try {
this.work(state);
}
catch (e) {
errored = true;
errorValue = !!e && e || new Error(e);
}
if (errored) {
this.unsubscribe();
return errorValue;
}
};
/** @deprecated internal use only */ AsyncAction.prototype._unsubscribe = function () {
var id = this.id;
var scheduler = this.scheduler;
var actions = scheduler.actions;
var index = actions.indexOf(this);
this.work = null;
this.state = null;
this.pending = false;
this.scheduler = null;
if (index !== -1) {
actions.splice(index, 1);
}
if (id != null) {
this.id = this.recycleAsyncId(scheduler, id, null);
}
this.delay = null;
};
return AsyncAction;
}(Action_1.Action));
var AsyncAction_2 = AsyncAction;
var AsyncAction_1 = {
AsyncAction: AsyncAction_2
};
var __extends$4 = (commonjsGlobal && commonjsGlobal.__extends) || function (d, b) {
for (var p in b)
if (b.hasOwnProperty(p))
d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
/**
* We need this JSDoc comment for affecting ESDoc.
* @ignore
* @extends {Ignored}
*/
var QueueAction = (function (_super) {
__extends$4(QueueAction, _super);
function QueueAction(scheduler, work) {
_super.call(this, scheduler, work);
this.scheduler = scheduler;
this.work = work;
}
QueueAction.prototype.schedule = function (state, delay) {
if (delay === void 0) {
delay = 0;
}
if (delay > 0) {
return _super.prototype.schedule.call(this, state, delay);
}
this.delay = delay;
this.state = state;
this.scheduler.flush(this);
return this;
};
QueueAction.prototype.execute = function (state, delay) {
return (delay > 0 || this.closed) ?
_super.prototype.execute.call(this, state, delay) :
this._execute(state, delay);
};
QueueAction.prototype.requestAsyncId = function (scheduler, id, delay) {
if (delay === void 0) {
delay = 0;
}
// If delay exists and is greater than 0, or if the delay is null (the
// action wasn't rescheduled) but was originally scheduled as an async
// action, then recycle as an async action.
if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
}
// Otherwise flush the scheduler starting with this action.
return scheduler.flush(this);
};
return QueueAction;
}(AsyncAction_1.AsyncAction));
var QueueAction_2 = QueueAction;
var QueueAction_1 = {
QueueAction: QueueAction_2
};
/**
* An execution context and a data structure to order tasks and schedule their
* execution. Provides a notion of (potentially virtual) time, through the
* `now()` getter method.
*
* Each unit of work in a Scheduler is called an {@link Action}.
*
* ```ts
* class Scheduler {
* now(): number;
* schedule(work, delay?, state?): Subscription;
* }
* ```
*
* @class Scheduler
*/
var Scheduler = (function () {
function Scheduler(SchedulerAction, now) {
if (now === void 0) {
now = Scheduler.now;
}
this.SchedulerAction = SchedulerAction;
this.now = now;
}
/**
* Schedules a function, `work`, for execution. May happen at some point in
* the future, according to the `delay` parameter, if specified. May be passed
* some context object, `state`, which will be passed to the `work` function.
*
* The given arguments will be processed an stored as an Action object in a
* queue of actions.
*
* @param {function(state: ?T): ?Subscription} work A function representing a
* task, or some unit of work to be executed by the Scheduler.
* @param {number} [delay] Time to wait before executing the work, where the
* time unit is implicit and defined by the Scheduler itself.
* @param {T} [state] Some contextual data that the `work` function uses when
* called by the Scheduler.
* @return {Subscription} A subscription in order to be able to unsubscribe
* the scheduled work.
*/
Scheduler.prototype.schedule = function (work, delay, state) {
if (delay === void 0) {
delay = 0;
}
return new this.SchedulerAction(this, work).schedule(state, delay);
};
Scheduler.now = Date.now ? Date.now : function () { return +new Date(); };
return Scheduler;
}());
var Scheduler_2 = Scheduler;
var Scheduler_1 = {
Scheduler: Scheduler_2
};
var __extends$9 = (commonjsGlobal && commonjsGlobal.__extends) || function (d, b) {
for (var p in b)
if (b.hasOwnProperty(p))
d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var AsyncScheduler = (function (_super) {
__extends$9(AsyncScheduler, _super);
function AsyncScheduler() {
_super.apply(this, arguments);
this.actions = [];
/**
* A flag to indicate whether the Scheduler is currently executing a batch of
* queued actions.
* @type {boolean}
*/
this.active = false;
/**
* An internal ID used to track the latest asynchronous task such as those
* coming from `setTimeout`, `setInterval`, `requestAnimationFrame`, and
* others.
* @type {any}
*/
this.scheduled = undefined;
}
AsyncScheduler.prototype.flush = function (action) {
var actions = this.actions;
if (this.active) {
actions.push(action);
return;
}
var error;
this.active = true;
do {
if (error = action.execute(action.state, action.delay)) {
break;
}
} while (action = actions.shift()); // exhaust the scheduler queue
this.active = false;
if (error) {
while (action = actions.shift()) {
action.unsubscribe();
}
throw error;
}
};
return AsyncScheduler;
}(Scheduler_1.Scheduler));
var AsyncScheduler_2 = AsyncScheduler;
var AsyncScheduler_1 = {
AsyncScheduler: AsyncScheduler_2
};
var __extends$8 = (commonjsGlobal && commonjsGlobal.__extends) || function (d, b) {
for (var p in b)
if (b.hasOwnProperty(p))
d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var QueueScheduler = (function (_super) {
__extends$8(QueueScheduler, _super);
function QueueScheduler() {
_super.apply(this, arguments);
}
return QueueScheduler;
}(AsyncScheduler_1.AsyncScheduler));
var QueueScheduler_2 = QueueScheduler;
var QueueScheduler_1 = {
QueueScheduler: QueueScheduler_2
};
/**
*
* Queue Scheduler
*
* <span class="informal">Put every next task on a queue, instead of executing it immediately</span>
*
* `queue` scheduler, when used with delay, behaves the same as {@link async} scheduler.
*
* When used without delay, it schedules given task synchronously - executes it right when
* it is scheduled. However when called recursively, that is when inside the scheduled task,
* another task is scheduled with queue scheduler, instead of executing immediately as well,
* that task will be put on a queue and wait for current one to finish.
*
* This means that when you execute task with `queue` scheduler, you are sure it will end
* before any other task scheduled with that scheduler will start.
*
* @examples <caption>Schedule recursively first, then do something</caption>
*
* Rx.Scheduler.queue.schedule(() => {
* Rx.Scheduler.queue.schedule(() => console.log('second')); // will not happen now, but will be put on a queue
*
* console.log('first');
* });
*
* // Logs:
* // "first"
* // "second"
*
*
* @example <caption>Reschedule itself recursively</caption>
*
* Rx.Scheduler.queue.schedule(function(state) {
* if (state !== 0) {
* console.log('before', state);
* this.schedule(state - 1); // `this` references currently executing Action,
* // which we reschedule with new state
* console.log('after', state);
* }
* }, 0, 3);
*
* // In scheduler that runs recursively, you would expect:
* // "before", 3
* // "before", 2
* // "before", 1
* // "after", 1
* // "after", 2
* // "after", 3
*
* // But with queue it logs:
* // "before", 3
* // "after", 3
* // "before", 2
* // "after", 2
* // "before", 1
* // "after", 1
*
*
* @static true
* @name queue
* @owner Scheduler
*/
var queue_1 = new QueueScheduler_1.QueueScheduler(QueueAction_1.QueueAction);
var __extends$3 = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b)
if (b.hasOwnProperty(p))
d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
/**
* @copyright ngrx
*/
var MiniState = (function (_super) {
__extends$3(MiniState, _super);
function MiniState(_initialState, actionsDispatcher$, reducer) {
var _this = _super.call(this, _initialState) || this;
var actionInQueue$ = observeOn$1.call(actionsDispatcher$, queue_1);
var state$ = scan$1.call(actionInQueue$, function (state, action) {
if (!action) {
return state;
}
return reducer(state, action);
}, _initialState);
state$.subscribe(function (value) { return _this.next(value); });
return _this;
}
return MiniState;
}(BehaviorSubject$1));
function getStartingDayOfCalendar(date, options) {
if (isFirstDayOfWeek(date, options.firstDayOfWeek)) {
return date;
}
var weekDay = getDay(date);
var offset = calculateDateOffset(weekDay, options.firstDayOfWeek);
return shiftDate(date, { day: -offset });
}
function calculateDateOffset(weekday, startingDayOffset) {
if (startingDayOffset === 0) {
return weekday;
}
var offset = weekday - startingDayOffset % 7;
return offset < 0 ? offset + 7 : offset;
}
function isMonthDisabled(date, min, max) {
var minBound = min && isBefore(endOf(date, 'month'), min, 'day');
var maxBound = max && isAfter(startOf(date, 'month'), max, 'day');
return minBound || maxBound;
}
function isYearDisabled(date, min, max) {
var minBound = min && isBefore(endOf(date, 'year'), min, 'day');
var maxBound = max && isAfter(startOf(date, 'year'), max, 'day');
return minBound || maxBound;
}
function createMatrix(options, fn) {
var prevValue = options.initialDate;
var matrix = new Array(options.height);
for (var i = 0; i < options.height; i++) {
matrix[i] = new Array(options.width);
for (var j = 0; j < options.width; j++) {
matrix[i][j] = fn(prevValue);
prevValue = shiftDate(prevValue, options.shift);
}
}
return matrix;
}
function calcDaysCalendar(startingDate, options) {
var firstDay = getFirstDayOfMonth(startingDate);
var initialDate = getStartingDayOfCalendar(firstDay, options);
var matrixOptions = {
width: options.width,
height: options.height,
initialDate: initialDate,
shift: { day: 1 }
};
var daysMatrix = createMatrix(matrixOptions, function (date) { return date; });
return {
daysMatrix: daysMatrix,
month: firstDay
};
}
function formatDaysCalendar(daysCalendar, formatOptions, monthIndex) {
return {
month: daysCalendar.month,
monthTitle: formatDate(daysCalendar.month, formatOptions.monthTitle, formatOptions.locale),
yearTitle: formatDate(daysCalendar.month, formatOptions.yearTitle, formatOptions.locale),
weekNumbers: getWeekNumbers(daysCalendar.daysMatrix, formatOptions.weekNumbers, formatOptions.locale),
weekdays: getShiftedWeekdays(formatOptions.locale),
weeks: daysCalendar.daysMatrix.map(function (week, weekIndex) {
return ({
days: week.map(function (date, dayIndex) {
return ({
date: date,
label: formatDate(date, formatOptions.dayLabel, formatOptions.locale),
monthIndex: monthIndex,
weekIndex: weekIndex,
dayIndex: dayIndex
});
})
});
})
};
}
function getWeekNumbers(daysMatrix, format, locale) {
return daysMatrix.map(function (days) { return (days[0] ? formatDate(days[0], format, locale) : ''); });
}
function getShiftedWeekdays(locale) {
var _locale = getLocale(locale);
var weekdays = _locale.weekdaysShort();
var firstDayOfWeek = _locale.firstDayOfWeek();
return weekdays.slice(firstDayOfWeek).concat(weekdays.slice(0, firstDayOfWeek));
}
function flagDaysCalendar(formattedMonth, options) {
formattedMonth.weeks.forEach(function (week, weekIndex) {
week.days.forEach(function (day, dayIndex) {
// datepicker
var isOtherMonth = !isSameMonth(day.date, formattedMonth.month);
var isHovered = !isOtherMonth && isSameDay(day.date, options.hoveredDate);
// date range picker
var isSelectionStart = !isOtherMonth &&
options.selectedRange &&
isSameDay(day.date, options.selectedRange[0]);
var isSelectionEnd = !isOtherMonth &&
options.selectedRange &&
isSameDay(day.date, options.selectedRange[1]);
var isSelected = (!isOtherMonth && isSameDay(day.date, options.selectedDate)) ||
isSelectionStart ||
isSelectionEnd;
var isInRange = !isOtherMonth &&
options.selectedRange &&
isDateInRange(day.date, options.selectedRange, options.hoveredDate);
var isDisabled = options.isDisabled ||
isBefore(day.date, options.minDate, 'day') ||
isAfter(day.date, options.maxDate, 'day');
// decide update or not
var newDay = Object.assign({}, day, {
isOtherMonth: isOtherMonth,
isHovered: isHovered,
isSelected: isSelected,
isSelectionStart: isSelectionStart,
isSelectionEnd: isSelectionEnd,
isInRange: isInRange,
isDisabled: isDisabled
});
if (day.isOtherMonth !== newDay.isOtherMonth ||
day.isHovered !== newDay.isHovered ||
day.isSelected !== newDay.isSelected ||
day.isSelectionStart !== newDay.isSelectionStart ||
day.isSelectionEnd !== newDay.isSelectionEnd ||
day.isDisabled !== newDay.isDisabled ||
day.isInRange !== newDay.isInRange) {
week.days[dayIndex] = newDay;
}
});
});
// todo: add check for linked calendars
formattedMonth.hideLeftArrow =
options.isDisabled ||
(options.monthIndex > 0 && options.monthIndex !== options.displayMonths);
formattedMonth.hideRightArrow =
options.isDisabled ||
(options.monthIndex < options.displayMonths &&
options.monthIndex + 1 !== options.displayMonths);
formattedMonth.disableLeftArrow = isMonthDisabled(shiftDate(formattedMonth.month, { month: -1 }), options.minDate, options.maxDate);
formattedMonth.disableRightArrow = isMonthDisabled(shiftDate(formattedMonth.month, { month: 1 }), options.minDate, options.maxDate);
return formattedMonth;
}
function isDateInRange(date, selectedRange, hoveredDate) {
if (!date || !selectedRange[0]) {
return false;
}
if (selectedRange[1]) {
return date > selectedRange[0] && date <= selectedRange[1];
}
if (hoveredDate) {
return date > selectedRange[0] && date <= hoveredDate;
}
return false;
}
function canSwitchMode(mode) {
return true;
}
var height = 4;
var width = 3;
var shift = { month: 1 };
function formatMonthsCalendar(viewDate, formatOptions) {
var initialDate = startOf(viewDate, 'year');
var matrixOptions = { width: width, height: height, initialDate: initialDate, shift: shift };
var monthMatrix = createMatrix(matrixOptions, function (date) {
return ({
date: date,
label: formatDate(date, formatOptions.monthLabel, formatOptions.locale)
});
});
return {
months: monthMatrix,
monthTitle: '',
yearTitle: formatDate(viewDate, formatOptions.yearTitle, formatOptions.locale)
};
}
function flagMonthsCalendar(monthCalendar, options) {
monthCalendar.months.forEach(function (months, rowIndex) {
months.forEach(function (month, monthIndex) {
var isHovered = isSameMonth(month.date, options.hoveredMonth);
var isDisabled = options.isDisabled ||
isMonthDisabled(month.date, options.minDate, options.maxDate);
var newMonth = Object.assign(/*{},*/ month, {
isHovered: isHovered,
isDisabled: isDisabled
});
if (month.isHovered !== newMonth.isHovered ||
month.isDisabled !== newMonth.isDisabled) {
monthCalendar.months[rowIndex][monthIndex] = newMonth;
}
});
});
// todo: add check for linked calendars
monthCalendar.hideLeftArrow =
options.monthIndex > 0 && options.monthIndex !== options.displayMonths;
monthCalendar.hideRightArrow =
options.monthIndex < options.displayMonths &&
options.monthIndex + 1 !== options.displayMonths;
monthCalendar.disableLeftArrow = isYearDisabled(shiftDate(monthCalendar.months[0][0].date, { year: -1 }), options.minDate, options.maxDate);
monthCalendar.disableRightArrow = isYearDisabled(shiftDate(monthCalendar.months[0][0].date, { year: 1 }), options.minDate, options.maxDate);
return monthCalendar;
}
var height$1 = 4;
var width$1 = 4;
var yearsPerCalendar = height$1 * width$1;
var initialShift = (Math.floor(yearsPerCalendar / 2) - 1) * -1;
var shift$1 = { year: 1 };
function formatYearsCalendar(viewDate, formatOptions) {
var initialDate = shiftDate(viewDate, { year: initialShift });
var matrixOptions = { width: width$1, height: height$1, initialDate: initialDate, shift: shift$1 };
var yearsMatrix = createMatrix(matrixOptions, function (date) {
return ({
date: date,
label: formatDate(date, formatOptions.yearLabel, formatOptions.locale)
});
});
var yearTitle = formatYearRangeTitle(yearsMatrix, formatOptions);
return {
years: yearsMatrix,
monthTitle: '',
yearTitle: yearTitle
};
}
function formatYearRangeTitle(yearsMatrix, formatOptions) {
var from$$1 = formatDate(yearsMatrix[0][0].date, formatOptions.yearTitle, formatOptions.locale);
var to = formatDate(yearsMatrix[height$1 - 1][width$1 - 1].date, formatOptions.yearTitle, formatOptions.locale);
return from$$1 + " - " + to;
}
function flagYearsCalendar(yearsCalendar, options) {
yearsCalendar.years.forEach(function (years, rowIndex) {
years.forEach(function (year, yearIndex) {
var isHovered = isSameYear(year.date, options.hoveredYear);
var isDisabled = options.isDisabled ||
isYearDisabled(year.date, options.minDate, options.maxDate);
var newMonth = Object.assign(/*{},*/ year, { isHovered: isHovered, isDisabled: isDisabled });
if (year.isHovered !== newMonth.isHovered ||
year.isDisabled !== newMonth.isDisabled) {
yearsCalendar.years[rowIndex][yearIndex] = newMonth;
}
});
});
// todo: add check for linked calendars
yearsCalendar.hideLeftArrow =
options.yearIndex > 0 && options.yearIndex !== options.displayMonths;
yearsCalendar.hideRightArrow =
options.yearIndex < options.displayMonths &&
options.yearIndex + 1 !== options.displayMonths;
yearsCalendar.disableLeftArrow = isYearDisabled(shiftDate(yearsCalendar.years[0][0].date, { year: -1 }), options.minDate, options.maxDate);
var i = yearsCalendar.years.length - 1;
var j = yearsCalendar.years[i].length - 1;
yearsCalendar.disableRightArrow = isYearDisabled(shiftDate(yearsCalendar.years[i][j].date, { year: 1 }), options.minDate, options.maxDate);
return yearsCalendar;
}
// tslint:disable:max-file-line-count
function bsDatepickerReducer(state, action) {
if (state === void 0) {
state = initialDatepickerState;
}
switch (action.type) {
case BsDatepickerActions.CALCULATE: {
return calculateReducer(state);
}
case BsDatepickerActions.FORMAT: {
return formatReducer(state, action);
}
case BsDatepickerActions.FLAG: {
return flagReducer(state, action);
}
case BsDatepickerActions.NAVIGATE_OFFSET: {
var date = shiftDate(startOf(state.view.date, 'month'), action.payload);
var newState = {
view: {
mode: state.view.mode,
date: date
}
};
return Object.assign({}, state, newState);
}
case BsDatepickerActions.NAVIGATE_TO: {
var payload = action.payload;
var date = setFullDate(state.view.date, payload.unit);
var mode = payload.viewMode;
var newState = { view: { date: date, mode: mode } };
return Object.assign({}, state, newState);
}
case BsDatepickerActions.CHANGE_VIEWMODE: {
if (!canSwitchMode(action.payload)) {
return state;
}
var date = state.view.date;
var mode = action.payload;
var newState = { view: { date: date, mode: mode } };
return Object.assign({}, state, newState);
}
case BsDatepickerActions.HOVER: {
return Object.assign({}, state, { hoveredDate: action.payload });
}
case BsDatepickerActions.SELECT: {
var newState = {
selectedDate: action.payload,
view: state.view
};
var mode = state.view.mode;
var _date = action.payload || state.view.date;
var date = getViewDate(_date, state.minDate, state.maxDate);
newState.view = { mode: mode, date: date };
return Object.assign({}, state, newState);
}
case BsDatepickerActions.SET_OPTIONS: {
var newState = action.payload;
// preserve view mode
var mode = state.view.mode;
var _viewDate = isDateValid(newState.value) && newState.value
|| isArray(newState.value) && isDateValid(newState.value[0]) && newState.value[0]
|| state.view.date;
var date = getViewDate(_viewDate, newState.minDate, newState.maxDate);
newState.view = { mode: mode, date: date };
// update selected value
if (newState.value) {
// if new value is array we work with date range
if (isArray(newState.value)) {
newState.selectedRange = newState.value;
}
// if new value is a date -> datepicker
if (newState.value instanceof Date) {
newState.selectedDate = newState.value;
}
// provided value is not supported :)
// need to report it somehow
}
return Object.assign({}, state, newState);
}
// date range picker
case BsDatepickerActions.SELECT_RANGE: {
var newState = {
selectedRange: action.payload,
view: state.view
};
var mode = state.view.mode;
var _date = action.payload && action.payload[0] || state.view.date;
var date = getViewDate(_date, state.minDate, state.maxDate);
newState.view = { mode: mode, date: date };
return Object.assign({}, state, newState);
}
case BsDatepickerActions.SET_MIN_DATE: {
return Object.assign({}, state, {
minDate: action.payload
});
}
case BsDatepickerActions.SET_MAX_DATE: {
return Object.assign({}, state, {
maxDate: action.payload
});
}
case BsDatepickerActions.SET_IS_DISABLED: {
return Object.assign({}, state, {
isDisabled: action.payload
});
}
default:
return state;
}
}
function calculateReducer(state) {
// how many calendars
var displayMonths = state.displayMonths;
// use selected date on initial rendering if set
var viewDate = state.view.date;
if (state.view.mode === 'day') {
state.monthViewOptions.firstDayOfWeek = getLocale(state.locale).firstDayOfWeek();
var monthsModel = new Array(displayMonths);
for (var monthIndex = 0; monthIndex < displayMonths; monthIndex++) {
// todo: for unlinked calendars it will be harder
monthsModel[monthIndex] = calcDaysCalendar(viewDate, state.monthViewOptions);
viewDate = shiftDate(viewDate, { month: 1 });
}
return Object.assign({}, state, { monthsModel: monthsModel });
}
if (state.view.mode === 'month') {
var monthsCalendar = new Array(displayMonths);
for (var calendarIndex = 0; calendarIndex < displayMonths; calendarIndex++) {
// todo: for unlinked calendars it will be harder
monthsCalendar[calendarIndex] = formatMonthsCalendar(viewDate, getFormatOptions(state));
viewDate = shiftDate(viewDate, { year: 1 });
}
return Object.assign({}, state, { monthsCalendar: monthsCalendar });
}
if (state.view.mode === 'year') {
var yearsCalendarModel = new Array(displayMonths);
for (var calendarIndex = 0; calendarIndex < displayMonths; calendarIndex++) {
// todo: for unlinked calendars it will be harder
yearsCalendarModel[calendarIndex] = formatYearsCalendar(viewDate, getFormatOptions(state));
viewDate = shiftDate(viewDate, { year: yearsPerCalendar });
}
return Object.assign({}, state, { yearsCalendarModel: yearsCalendarModel });
}
return state;
}
function formatReducer(state, action) {
if (state.view.mode === 'day') {
var formattedMonths = state.monthsModel.map(function (month, monthIndex) {
return formatDaysCalendar(month, getFormatOptions(state), monthIndex);
});
return Object.assign({}, state, { formattedMonths: formattedMonths });
}
// how many calendars
var displayMonths = state.displayMonths;
// check initial rendering
// use selected date on initial rendering if set
var viewDate = state.view.date;
if (state.view.mode === 'month') {
var monthsCalendar = new Array(displayMonths);
for (var calendarIndex = 0; calendarIndex < displayMonths; calendarIndex++) {
// todo: for unlinked calendars it will be harder
monthsCalendar[calendarIndex] = formatMonthsCalendar(viewDate, getFormatOptions(state));
viewDate = shiftDate(viewDate, { year: 1 });
}
return Object.assign({}, state, { monthsCalendar: monthsCalendar });
}
if (state.view.mode === 'year') {
var yearsCalendarModel = new Array(displayMonths);
for (var calendarIndex = 0; calendarIndex < displayMonths; calendarIndex++) {
// todo: for unlinked calendars it will be harder
yearsCalendarModel[calendarIndex] = formatYearsCalendar(viewDate, getFormatOptions(state));
viewDate = shiftDate(viewDate, { year: 16 });
}
return Object.assign({}, state, { yearsCalendarModel: yearsCalendarModel });
}
return state;
}
function flagReducer(state, action) {
if (state.view.mode === 'day') {
var flaggedMonths = state.formattedMonths.map(function (formattedMonth, monthIndex) {
return flagDaysCalendar(formattedMonth, {
isDisabled: state.isDisabled,
minDate: state.minDate,
maxDate: state.maxDate,
hoveredDate: state.hoveredDate,
selectedDate: state.selectedDate,
selectedRange: state.selectedRange,
displayMonths: state.displayMonths,
monthIndex: monthIndex
});
});
return Object.assign({}, state, { flaggedMonths: flaggedMonths });
}
if (state.view.mode === 'month') {
var flaggedMonthsCalendar = state.monthsCalendar.map(function (formattedMonth, monthIndex) {
return flagMonthsCalendar(formattedMonth, {
isDisabled: state.isDisabled,
minDate: state.minDate,
maxDate: state.maxDate,
hoveredMonth: state.hoveredMonth,
displayMonths: state.displayMonths,
monthIndex: monthIndex
});
});
return Object.assign({}, state, { flaggedMonthsCalendar: flaggedMonthsCalendar });
}
if (state.view.mode === 'year') {
var yearsCalendarFlagged = state.yearsCalendarModel.map(function (formattedMonth, yearIndex) {
return flagYearsCalendar(formattedMonth, {
isDisabled: state.isDisabled,
minDate: state.minDate,
maxDate: state.maxDate,
hoveredYear: state.hoveredYear,
displayMonths: state.displayMonths,
yearIndex: yearIndex
});
});
return Object.assign({}, state, { yearsCalendarFlagged: yearsCalendarFlagged });
}
return state;
}
function getFormatOptions(state) {
return {
locale: state.locale,
monthTitle: state.monthTitle,
yearTitle: state.yearTitle,
dayLabel: state.dayLabel,
monthLabel: state.monthLabel,
yearLabel: state.yearLabel,
weekNumbers: state.weekNumbers
};
}
/**
* if view date is provided (bsValue|ngModel) it should be shown
* if view date is not provider:
* if minDate>currentDate (default view value), show minDate
* if maxDate<currentDate(default view value) show maxDate
*/
function getViewDate(viewDate, minDate, maxDate) {
var _date = Array.isArray(viewDate) ? viewDate[0] : viewDate;
if (minDate && isAfter(minDate, _date, 'day')) {
return minDate;
}
if (maxDate && isBefore(maxDate, _date, 'day')) {
return maxDate;
}
return _date;
}
var __extends$1 = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b)
if (b.hasOwnProperty(p))
d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var BsDatepickerStore = (function (_super) {
__extends$1(BsDatepickerStore, _super);
function BsDatepickerStore() {
var _this = this;
var _dispatcher = new BehaviorSubject$1({
type: '[datepicker] dispatcher init'
});
var state = new MiniState(initialDatepickerState, _dispatcher, bsDatepickerReducer);
_this = _super.call(this, _dispatcher, bsDatepickerReducer, state) || this;
return _this;
}
BsDatepickerStore.decorators = [
{ type: Injectable },
];
/** @nocollapse */
BsDatepickerStore.ctorParameters = function () { return []; };
return BsDatepickerStore;
}(MiniStore));
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b)
if (b.hasOwnProperty(p))
d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var BsDatepickerContainerComponent = (function (_super) {
__extends(BsDatepickerContainerComponent, _super);
function BsDatepickerContainerComponent(_config, _store, _actions, _effects) {
var _this = _super.call(this) || this;
_this._config = _config;
_this._store = _store;
_this._actions = _actions;
_this.valueChange = new EventEmitter();
_this._subs = [];
_this._effects = _effects;
return _this;
}
Object.defineProperty(BsDatepickerContainerComponent.prototype, "value", {
set: function (value) {
this._effects.setValue(value);
},
enumerable: true,
configurable: true
});
BsDatepickerContainerComponent.prototype.ngOnInit = function () {
var _this = this;
this.containerClass = this._config.containerClass;
this._effects
.init(this._store)
.setOptions(this._config)
.setBindings(this)
.setEventHandlers(this)
.registerDatepickerSideEffects();
// todo: move it somewhere else
// on selected date change
this._subs.push(this._store
.select(function (state) { return state.selectedDate; })
.subscribe(function (date) { return _this.valueChange.emit(date); }));
};
BsDatepickerContainerComponent.prototype.daySelectHandler = function (day) {
if (day.isOtherMonth || day.isDisabled) {
return;
}
this._store.dispatch(this._actions.select(day.date));
};
BsDatepickerContainerComponent.prototype.ngOnDestroy = function () {
for (var _i = 0, _a = this._subs; _i < _a.length; _i++) {
var sub = _a[_i];
sub.unsubscribe();
}
this._effects.destroy();
};
BsDatepickerContainerComponent.decorators = [
{ type: Component, args: [{
selector: 'bs-datepicker-container',
providers: [BsDatepickerStore, BsDatepickerEffects],
template: "<!-- days calendar view mode --> <div class=\"bs-datepicker\" [ngClass]=\"containerClass\" *ngIf=\"viewMode | async\"> <div class=\"bs-datepicker-container\"> <!--calendars--> <div class=\"bs-calendar-container\" [ngSwitch]=\"viewMode | async\" role=\"application\"> <!--days calendar--> <div *ngSwitchCase=\"'day'\"> <bs-days-calendar-view *ngFor=\"let calendar of (daysCalendar | async)\" [class.bs-datepicker-multiple]=\"(daysCalendar | async)?.length > 1\" [calendar]=\"calendar\" [options]=\"options | async\" (onNavigate)=\"navigateTo($event)\" (onViewMode)=\"setViewMode($event)\" (onHover)=\"dayHoverHandler($event)\" (onSelect)=\"daySelectHandler($event)\" ></bs-days-calendar-view> </div> <!--months calendar--> <div *ngSwitchCase=\"'month'\"> <bs-month-calendar-view *ngFor=\"let calendar of (monthsCalendar | async)\" [class.bs-datepicker-multiple]=\"(daysCalendar | async)?.length > 1\" [calendar]=\"calendar\" (onNavigate)=\"navigateTo($event)\" (onViewMode)=\"setViewMode($event)\" (onHover)=\"monthHoverHandler($event)\" (onSelect)=\"monthSelectHandler($event)\" ></bs-month-calendar-view> </div> <!--years calendar--> <div *ngSwitchCase=\"'year'\"> <bs-years-calendar-view *ngFor=\"let calendar of (yearsCalendar | async)\" [class.bs-datepicker-multiple]=\"(daysCalendar | async)?.length > 1\" [calendar]=\"calendar\" (onNavigate)=\"navigateTo($event)\" (onViewMode)=\"setViewMode($event)\" (onHover)=\"yearHoverHandler($event)\" (onSelect)=\"yearSelectHandler($event)\" ></bs-years-calendar-view> </div> </div> <!--applycancel buttons--> <div class=\"bs-datepicker-buttons\" *ngIf=\"false\"> <button class=\"btn btn-success\">Apply</button> <button class=\"btn btn-default\">Cancel</button> </div> </div> <!--custom dates or date ranges picker--> <div class=\"bs-datepicker-custom-range\" *ngIf=\"false\"> <bs-custom-date-view [ranges]=\"_customRangesFish\"></bs-custom-date-view> </div> </div> ",
host: {
'(click)': '_stopPropagation($event)',
style: 'position: absolute; display: block;',
role: 'dialog',
'aria-label': 'calendar'
}
},] },
];
/** @nocollapse */
BsDatepickerContainerComponent.ctorParameters = function () {
return [
{ type: BsDatepickerConfig, },
{ type: BsDatepickerStore, },
{ type: BsDatepickerActions, },
{ type: BsDatepickerEffects, },
];
};
return BsDatepickerContainerComponent;
}(BsDatepickerAbstractComponent));
var BsDatepickerDirective = (function () {
function BsDatepickerDirective(_config, _elementRef, _renderer, _viewContainerRef, cis) {
this._config = _config;
/**
* Placement of a datepicker. Accepts: "top", "bottom", "left", "right"
*/
this.placement = 'bottom';
/**
* Specifies events that should trigger. Supports a space separated list of
* event names.
*/
this.triggers = 'click';
/**
* Close datepicker on outside click
*/
this.outsideClick = true;
/**
* A selector specifying the element the datepicker should be appended to.
* Currently only supports "body".
*/
this.container = 'body';
/**
* Emits when datepicker value has been changed
*/
this.bsValueChange = new EventEmitter();
this._subs = [];
// todo: assign only subset of fields
Object.assign(this, this._config);
this._datepicker = cis.createLoader(_elementRef, _viewContainerRef, _renderer);
this.onShown = this._datepicker.onShown;
this.onHidden = this._datepicker.onHidden;
}
Object.defineProperty(BsDatepickerDirective.prototype, "isOpen", {
/**
* Returns whether or not the datepicker is currently being shown
*/
get: function () {
return this._datepicker.isShown;
},
set: function (value) {
if (value) {
this.show();
}
else {
this.hide();
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(BsDatepickerDirective.prototype, "bsValue", {
/**
* Initial value of datepicker
*/
set: function (value) {
if (this._bsValue === value) {
return;
}
this._bsValue = value;
this.bsValueChange.emit(value);
},
enumerable: true,
configurable: true
});
BsDatepickerDirective.prototype.ngOnInit = function () {
var _this = this;
this._datepicker.listen({
outsideClick: this.outsideClick,
triggers: this.triggers,
show: function () { return _this.show(); }
});
this.setConfig();
};
BsDatepickerDirective.prototype.ngOnChanges = function (changes) {
if (!this._datepickerRef || !this._datepickerRef.instance) {
return;
}
if (changes.minDate) {
this._datepickerRef.instance.minDate = this.minDate;
}
if (changes.maxDate) {
this._datepickerRef.instance.maxDate = this.maxDate;
}
if (changes.isDisabled) {
this._datepickerRef.instance.isDisabled = this.isDisabled;
}
};
/**
* Opens an element’s datepicker. This is considered a “manual” triggering of
* the datepicker.
*/
BsDatepickerDirective.prototype.show = function () {
var _this = this;
if (this._datepicker.isShown) {
return;
}
this.setConfig();
this._datepickerRef = this._datepicker
.provide({ provide: BsDatepickerConfig, useValue: this._config })
.attach(BsDatepickerContainerComponent)
.to(this.container)
.position({ attachment: this.placement })
.show({ placement: this.placement });
// if date changes from external source (model -> view)
this._subs.push(this.bsValueChange.subscribe(function (value) {
_this._datepickerRef.instance.value = value;
}));
// if date changes from picker (view -> model)
this._subs.push(this._datepickerRef.instance.valueChange.subscribe(function (value) {
_this.bsValue = value;
_this.hide();
}));
};
/**
* Closes an element’s datepicker. This is considered a “manual” triggering of
* the datepicker.
*/
BsDatepickerDirective.prototype.hide = function () {
if (this.isOpen) {
this._datepicker.hide();
}
for (var _i = 0, _a = this._subs; _i < _a.length; _i++) {
var sub = _a[_i];
sub.unsubscribe();
}
};
/**
* Toggles an element’s datepicker. This is considered a “manual” triggering
* of the datepicker.
*/
BsDatepickerDirective.prototype.toggle = function () {
if (this.isOpen) {
return this.hide();
}
this.show();
};
/**
* Set config for datepicker
*/
BsDatepickerDirective.prototype.setConfig = function () {
this._config = Object.assign({}, this._config, this.bsConfig, {
value: this._bsValue,
isDisabled: this.isDisabled,
minDate: this.minDate || this.bsConfig && this.bsConfig.minDate,
maxDate: this.maxDate || this.bsConfig && this.bsConfig.maxDate
});
};
BsDatepickerDirective.prototype.ngOnDestroy = function () {
this._datepicker.dispose();
};
BsDatepickerDirective.decorators = [
{ type: Directive, args: [{
selector: '[bsDatepicker]',
exportAs: 'bsDatepicker'
},] },
];
/** @nocollapse */
BsDatepickerDirective.ctorParameters = function () {
return [
{ type: BsDatepickerConfig, },
{ type: ElementRef, },
{ type: Renderer2, },
{ type: ViewContainerRef, },
{ type: ComponentLoaderFactory, },
];
};
BsDatepickerDirective.propDecorators = {
'placement': [{ type: Input },],
'triggers': [{ type: Input },],
'outsideClick': [{ type: Input },],
'container': [{ type: Input },],
'isOpen': [{ type: Input },],
'onShown': [{ type: Output },],
'onHidden': [{ type: Output },],
'bsValue': [{ type: Input },],
'bsConfig': [{ type: Input },],
'isDisabled': [{ type: Input },],
'minDate': [{ type: Input },],
'maxDate': [{ type: Input },],
'bsValueChange': [{ type: Output },],
};
return BsDatepickerDirective;
}());
var BS_DATEPICKER_VALUE_ACCESSOR = {
provide: NG_VALUE_ACCESSOR,
// tslint:disable-next-line
useExisting: forwardRef(function () { return BsDatepickerInputDirective; }),
multi: true
};
var BS_DATEPICKER_VALIDATOR = {
provide: NG_VALIDATORS,
useExisting: forwardRef(function () { return BsDatepickerInputDirective; }),
multi: true
};
var BsDatepickerInputDirective = (function () {
function BsDatepickerInputDirective(_picker, _localeService, _renderer, _elRef, changeDetection) {
var _this = this;
this._picker = _picker;
this._localeService = _localeService;
this._renderer = _renderer;
this._elRef = _elRef;
this.changeDetection = changeDetection;
this._onChange = Function.prototype;
this._onTouched = Function.prototype;
this._validatorChange = Function.prototype;
// update input value on datepicker value update
this._picker.bsValueChange.subscribe(function (value) {
_this._setInputValue(value);
if (_this._value !== value) {
_this._value = value;
_this._onChange(value);
_this._onTouched();
}
_this.changeDetection.markForCheck();
});
// update input value on locale change
this._localeService.localeChange.subscribe(function () {
_this._setInputValue(_this._value);
});
}
BsDatepickerInputDirective.prototype._setInputValue = function (value) {
var initialDate = !value ? ''
: formatDate(value, this._picker._config.dateInputFormat, this._localeService.currentLocale);
this._renderer.setProperty(this._elRef.nativeElement, 'value', initialDate);
};
BsDatepickerInputDirective.prototype.onChange = function (event) {
this.writeValue(event.target.value);
this._onChange(this._value);
this._onTouched();
};
BsDatepickerInputDirective.prototype.validate = function (c) {
var _value = c.value;
if (_value === null || _value === undefined || _value === '') {
return null;
}
if (isDate(_value)) {
var _isDateValid = isDateValid(_value);
if (!_isDateValid) {
return { bsDate: { invalid: _value } };
}
if (this._picker && this._picker.minDate && isBefore(_value, this._picker.minDate, 'date')) {
return { bsDate: { minDate: this._picker.minDate } };
}
if (this._picker && this._picker.maxDate && isAfter(_value, this._picker.maxDate, 'date')) {
return { bsDate: { maxDate: this._picker.maxDate } };
}
}
};
BsDatepickerInputDirective.prototype.registerOnValidatorChange = function (fn) {
this._validatorChange = fn;
};
BsDatepickerInputDirective.prototype.writeValue = function (value) {
if (!value) {
this._value = null;
}
else {
var _localeKey = this._localeService.currentLocale;
var _locale = getLocale(_localeKey);
if (!_locale) {
throw new Error("Locale \"" + _localeKey + "\" is not defined, please add it with \"defineLocale(...)\"");
}
this._value = parseDate(value, this._picker._config.dateInputFormat, this._localeService.currentLocale);
}
this._picker.bsValue = this._value;
};
BsDatepickerInputDirective.prototype.setDisabledState = function (isDisabled) {
this._picker.isDisabled = isDisabled;
if (isDisabled) {
this._renderer.setAttribute(this._elRef.nativeElement, 'disabled', 'disabled');
return;
}
this._renderer.removeAttribute(this._elRef.nativeElement, 'disabled');
};
BsDatepickerInputDirective.prototype.registerOnChange = function (fn) {
this._onChange = fn;
};
BsDatepickerInputDirective.prototype.registerOnTouched = function (fn) {
this._onTouched = fn;
};
BsDatepickerInputDirective.prototype.onBlur = function () {
this._onTouched();
};
BsDatepickerInputDirective.prototype.hide = function () {
this._picker.hide();
};
BsDatepickerInputDirective.decorators = [
{ type: Directive, args: [{
selector: "input[bsDatepicker]",
host: {
'(change)': 'onChange($event)',
'(keyup.esc)': 'hide()',
'(blur)': 'onBlur()'
},
providers: [BS_DATEPICKER_VALUE_ACCESSOR, BS_DATEPICKER_VALIDATOR]
},] },
];
/** @nocollapse */
BsDatepickerInputDirective.ctorParameters = function () {
return [
{ type: BsDatepickerDirective, decorators: [{ type: Host },] },
{ type: BsLocaleService, },
{ type: Renderer2, },
{ type: ElementRef, },
{ type: ChangeDetectorRef, },
];
};
return BsDatepickerInputDirective;
}());
var __extends$10 = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b)
if (b.hasOwnProperty(p))
d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var BsDaterangepickerConfig = (function (_super) {
__extends$10(BsDaterangepickerConfig, _super);
function BsDaterangepickerConfig() {
var _this = _super !== null && _super.apply(this, arguments) || this;
// DatepickerRenderOptions
_this.displayMonths = 2;
return _this;
}
BsDaterangepickerConfig.decorators = [
{ type: Injectable },
];
/** @nocollapse */
BsDaterangepickerConfig.ctorParameters = function () { return []; };
return BsDaterangepickerConfig;
}(BsDatepickerConfig));
var __extends$11 = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b)
if (b.hasOwnProperty(p))
d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var BsDaterangepickerContainerComponent = (function (_super) {
__extends$11(BsDaterangepickerContainerComponent, _super);
function BsDaterangepickerContainerComponent(_config, _store, _actions, _effects) {
var _this = _super.call(this) || this;
_this._config = _config;
_this._store = _store;
_this._actions = _actions;
_this.valueChange = new EventEmitter();
_this._rangeStack = [];
_this._subs = [];
_this._effects = _effects;
return _this;
}
Object.defineProperty(BsDaterangepickerContainerComponent.prototype, "value", {
set: function (value) {
this._effects.setRangeValue(value);
},
enumerable: true,
configurable: true
});
BsDaterangepickerContainerComponent.prototype.ngOnInit = function () {
var _this = this;
this.containerClass = this._config.containerClass;
this._effects
.init(this._store)
.setOptions(this._config)
.setBindings(this)
.setEventHandlers(this)
.registerDatepickerSideEffects();
// todo: move it somewhere else
// on selected date change
this._subs.push(this._store
.select(function (state) { return state.selectedRange; })
.subscribe(function (date) { return _this.valueChange.emit(date); }));
};
BsDaterangepickerContainerComponent.prototype.daySelectHandler = function (day) {
if (day.isOtherMonth || day.isDisabled) {
return;
}
// if only one date is already selected
// and user clicks on previous date
// start selection from new date
// but if new date is after initial one
// than finish selection
if (this._rangeStack.length === 1) {
this._rangeStack =
day.date >= this._rangeStack[0]
? [this._rangeStack[0], day.date]
: [day.date];
}
if (this._rangeStack.length === 0) {
this._rangeStack = [day.date];
}
this._store.dispatch(this._actions.selectRange(this._rangeStack));
if (this._rangeStack.length === 2) {
this._rangeStack = [];
}
};
BsDaterangepickerContainerComponent.prototype.ngOnDestroy = function () {
for (var _i = 0, _a = this._subs; _i < _a.length; _i++) {
var sub = _a[_i];
sub.unsubscribe();
}
this._effects.destroy();
};
BsDaterangepickerContainerComponent.decorators = [
{ type: Component, args: [{
selector: 'bs-daterangepicker-container',
providers: [BsDatepickerStore, BsDatepickerEffects],
template: "<!-- days calendar view mode --> <div class=\"bs-datepicker\" [ngClass]=\"containerClass\" *ngIf=\"viewMode | async\"> <div class=\"bs-datepicker-container\"> <!--calendars--> <div class=\"bs-calendar-container\" [ngSwitch]=\"viewMode | async\" role=\"application\"> <!--days calendar--> <div *ngSwitchCase=\"'day'\"> <bs-days-calendar-view *ngFor=\"let calendar of (daysCalendar | async)\" [class.bs-datepicker-multiple]=\"(daysCalendar | async)?.length > 1\" [calendar]=\"calendar\" [options]=\"options | async\" (onNavigate)=\"navigateTo($event)\" (onViewMode)=\"setViewMode($event)\" (onHover)=\"dayHoverHandler($event)\" (onSelect)=\"daySelectHandler($event)\" ></bs-days-calendar-view> </div> <!--months calendar--> <div *ngSwitchCase=\"'month'\"> <bs-month-calendar-view *ngFor=\"let calendar of (monthsCalendar | async)\" [class.bs-datepicker-multiple]=\"(daysCalendar | async)?.length > 1\" [calendar]=\"calendar\" (onNavigate)=\"navigateTo($event)\" (onViewMode)=\"setViewMode($event)\" (onHover)=\"monthHoverHandler($event)\" (onSelect)=\"monthSelectHandler($event)\" ></bs-month-calendar-view> </div> <!--years calendar--> <div *ngSwitchCase=\"'year'\"> <bs-years-calendar-view *ngFor=\"let calendar of (yearsCalendar | async)\" [class.bs-datepicker-multiple]=\"(daysCalendar | async)?.length > 1\" [calendar]=\"calendar\" (onNavigate)=\"navigateTo($event)\" (onViewMode)=\"setViewMode($event)\" (onHover)=\"yearHoverHandler($event)\" (onSelect)=\"yearSelectHandler($event)\" ></bs-years-calendar-view> </div> </div> <!--applycancel buttons--> <div class=\"bs-datepicker-buttons\" *ngIf=\"false\"> <button class=\"btn btn-success\">Apply</button> <button class=\"btn btn-default\">Cancel</button> </div> </div> <!--custom dates or date ranges picker--> <div class=\"bs-datepicker-custom-range\" *ngIf=\"false\"> <bs-custom-date-view [ranges]=\"_customRangesFish\"></bs-custom-date-view> </div> </div> ",
host: {
'(click)': '_stopPropagation($event)',
style: 'position: absolute; display: block;',
role: 'dialog',
'aria-label': 'calendar'
}
},] },
];
/** @nocollapse */
BsDaterangepickerContainerComponent.ctorParameters = function () {
return [
{ type: BsDatepickerConfig, },
{ type: BsDatepickerStore, },
{ type: BsDatepickerActions, },
{ type: BsDatepickerEffects, },
];
};
return BsDaterangepickerContainerComponent;
}(BsDatepickerAbstractComponent));
var BsDaterangepickerDirective = (function () {
function BsDaterangepickerDirective(_config, _elementRef, _renderer, _viewContainerRef, cis) {
this._config = _config;
/**
* Placement of a daterangepicker. Accepts: "top", "bottom", "left", "right"
*/
this.placement = 'bottom';
/**
* Specifies events that should trigger. Supports a space separated list of
* event names.
*/
this.triggers = 'click';
/**
* Close daterangepicker on outside click
*/
this.outsideClick = true;
/**
* A selector specifying the element the daterangepicker should be appended
* to. Currently only supports "body".
*/
this.container = 'body';
/**
* Emits when daterangepicker value has been changed
*/
this.bsValueChange = new EventEmitter();
this._subs = [];
this._datepicker = cis.createLoader(_elementRef, _viewContainerRef, _renderer);
Object.assign(this, _config);
this.onShown = this._datepicker.onShown;
this.onHidden = this._datepicker.onHidden;
}
Object.defineProperty(BsDaterangepickerDirective.prototype, "isOpen", {
/**
* Returns whether or not the daterangepicker is currently being shown
*/
get: function () {
return this._datepicker.isShown;
},
set: function (value) {
if (value) {
this.show();
}
else {
this.hide();
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(BsDaterangepickerDirective.prototype, "bsValue", {
/**
* Initial value of daterangepicker
*/
set: function (value) {
if (this._bsValue === value) {
return;
}
this._bsValue = value;
this.bsValueChange.emit(value);
},
enumerable: true,
configurable: true
});
BsDaterangepickerDirective.prototype.ngOnInit = function () {
var _this = this;
this._datepicker.listen({
outsideClick: this.outsideClick,
triggers: this.triggers,
show: function () { return _this.show(); }
});
this.setConfig();
};
BsDaterangepickerDirective.prototype.ngOnChanges = function (changes) {
if (!this._datepickerRef || !this._datepickerRef.instance) {
return;
}
if (changes.minDate) {
this._datepickerRef.instance.minDate = this.minDate;
}
if (changes.maxDate) {
this._datepickerRef.instance.maxDate = this.maxDate;
}
if (changes.isDisabled) {
this._datepickerRef.instance.isDisabled = this.isDisabled;
}
};
/**
* Opens an element’s datepicker. This is considered a “manual” triggering of
* the datepicker.
*/
BsDaterangepickerDirective.prototype.show = function () {
var _this = this;
if (this._datepicker.isShown) {
return;
}
this.setConfig();
this._datepickerRef = this._datepicker
.provide({ provide: BsDatepickerConfig, useValue: this._config })
.attach(BsDaterangepickerContainerComponent)
.to(this.container)
.position({ attachment: this.placement })
.show({ placement: this.placement });
// if date changes from external source (model -> view)
this._subs.push(this.bsValueChange.subscribe(function (value) {
_this._datepickerRef.instance.value = value;
}));
// if date changes from picker (view -> model)
this._subs.push(this._datepickerRef.instance.valueChange
.filter(function (range) { return range && range[0] && !!range[1]; })
.subscribe(function (value) {
_this.bsValue = value;
_this.hide();
}));
};
/**
* Set config for daterangepicker
*/
BsDaterangepickerDirective.prototype.setConfig = function () {
this._config = Object.assign({}, this._config, this.bsConfig, {
value: this._bsValue,
isDisabled: this.isDisabled,
minDate: this.minDate || this.bsConfig && this.bsConfig.minDate,
maxDate: this.maxDate || this.bsConfig && this.bsConfig.maxDate
});
};
/**
* Closes an element’s datepicker. This is considered a “manual” triggering of
* the datepicker.
*/
BsDaterangepickerDirective.prototype.hide = function () {
if (this.isOpen) {
this._datepicker.hide();
}
for (var _i = 0, _a = this._subs; _i < _a.length; _i++) {
var sub = _a[_i];
sub.unsubscribe();
}
};
/**
* Toggles an element’s datepicker. This is considered a “manual” triggering
* of the datepicker.
*/
BsDaterangepickerDirective.prototype.toggle = function () {
if (this.isOpen) {
return this.hide();
}
this.show();
};
BsDaterangepickerDirective.prototype.ngOnDestroy = function () {
this._datepicker.dispose();
};
BsDaterangepickerDirective.decorators = [
{ type: Directive, args: [{
selector: '[bsDaterangepicker]',
exportAs: 'bsDaterangepicker'
},] },
];
/** @nocollapse */
BsDaterangepickerDirective.ctorParameters = function () {
return [
{ type: BsDaterangepickerConfig, },
{ type: ElementRef, },
{ type: Renderer2, },
{ type: ViewContainerRef, },
{ type: ComponentLoaderFactory, },
];
};
BsDaterangepickerDirective.propDecorators = {
'placement': [{ type: Input },],
'triggers': [{ type: Input },],
'outsideClick': [{ type: Input },],
'container': [{ type: Input },],
'isOpen': [{ type: Input },],
'onShown': [{ type: Output },],
'onHidden': [{ type: Output },],
'bsValue': [{ type: Input },],
'bsConfig': [{ type: Input },],
'isDisabled': [{ type: Input },],
'minDate': [{ type: Input },],
'maxDate': [{ type: Input },],
'bsValueChange': [{ type: Output },],
};
return BsDaterangepickerDirective;
}());
var BS_DATERANGEPICKER_VALUE_ACCESSOR = {
provide: NG_VALUE_ACCESSOR,
// tslint:disable-next-line
useExisting: forwardRef(function () { return BsDaterangepickerInputDirective; }),
multi: true
};
var BS_DATERANGEPICKER_VALIDATOR = {
provide: NG_VALIDATORS,
useExisting: forwardRef(function () { return BsDaterangepickerInputDirective; }),
multi: true
};
var BsDaterangepickerInputDirective = (function () {
function BsDaterangepickerInputDirective(_picker, _localeService, _renderer, _elRef, changeDetection) {
var _this = this;
this._picker = _picker;
this._localeService = _localeService;
this._renderer = _renderer;
this._elRef = _elRef;
this.changeDetection = changeDetection;
this._onChange = Function.prototype;
this._onTouched = Function.prototype;
this._validatorChange = Function.prototype;
// update input value on datepicker value update
this._picker.bsValueChange.subscribe(function (value) {
_this._setInputValue(value);
if (_this._value !== value) {
_this._value = value;
_this._onChange(value);
_this._onTouched();
}
_this.changeDetection.markForCheck();
});
// update input value on locale change
this._localeService.localeChange.subscribe(function () {
_this._setInputValue(_this._value);
});
}
BsDaterangepickerInputDirective.prototype._setInputValue = function (date) {
var range = '';
if (date) {
var start = !date[0] ? ''
: formatDate(date[0], this._picker._config.rangeInputFormat, this._localeService.currentLocale);
var end = !date[1] ? ''
: formatDate(date[1], this._picker._config.rangeInputFormat, this._localeService.currentLocale);
range = (start && end) ? start + this._picker._config.rangeSeparator + end : '';
}
this._renderer.setProperty(this._elRef.nativeElement, 'value', range);
};
BsDaterangepickerInputDirective.prototype.onChange = function (event) {
this.writeValue(event.target.value);
this._onChange(this._value);
this._onTouched();
};
BsDaterangepickerInputDirective.prototype.validate = function (c) {
var _value = c.value;
if (_value === null || _value === undefined || !isArray(_value)) {
return null;
}
var _isDateValid = isDateValid(_value[0]) && isDateValid(_value[0]);
if (!_isDateValid) {
return { bsDate: { invalid: _value } };
}
if (this._picker && this._picker.minDate && isBefore(_value[0], this._picker.minDate, 'date')) {
return { bsDate: { minDate: this._picker.minDate } };
}
if (this._picker && this._picker.maxDate && isAfter(_value[1], this._picker.maxDate, 'date')) {
return { bsDate: { maxDate: this._picker.maxDate } };
}
};
BsDaterangepickerInputDirective.prototype.registerOnValidatorChange = function (fn) {
this._validatorChange = fn;
};
BsDaterangepickerInputDirective.prototype.writeValue = function (value) {
var _this = this;
if (!value) {
this._value = null;
}
else {
var _localeKey = this._localeService.currentLocale;
var _locale = getLocale(_localeKey);
if (!_locale) {
throw new Error("Locale \"" + _localeKey + "\" is not defined, please add it with \"defineLocale(...)\"");
}
var _input = [];
if (typeof value === 'string') {
_input = value.split(this._picker._config.rangeSeparator);
}
if (Array.isArray(value)) {
_input = value;
}
this._value = _input
.map(function (_val) {
return parseDate(_val, _this._picker._config.dateInputFormat, _this._localeService.currentLocale);
})
.map(function (date) { return (isNaN(date.valueOf()) ? null : date); });
}
this._picker.bsValue = this._value;
};
BsDaterangepickerInputDirective.prototype.setDisabledState = function (isDisabled) {
this._picker.isDisabled = isDisabled;
if (isDisabled) {
this._renderer.setAttribute(this._elRef.nativeElement, 'disabled', 'disabled');
return;
}
this._renderer.removeAttribute(this._elRef.nativeElement, 'disabled');
};
BsDaterangepickerInputDirective.prototype.registerOnChange = function (fn) {
this._onChange = fn;
};
BsDaterangepickerInputDirective.prototype.registerOnTouched = function (fn) {
this._onTouched = fn;
};
BsDaterangepickerInputDirective.prototype.onBlur = function () {
this._onTouched();
};
BsDaterangepickerInputDirective.prototype.hide = function () {
this._picker.hide();
};
BsDaterangepickerInputDirective.decorators = [
{ type: Directive, args: [{
selector: "input[bsDaterangepicker]",
host: {
'(change)': 'onChange($event)',
'(keyup.esc)': 'hide()',
'(blur)': 'onBlur()'
},
providers: [BS_DATERANGEPICKER_VALUE_ACCESSOR, BS_DATERANGEPICKER_VALIDATOR]
},] },
];
/** @nocollapse */
BsDaterangepickerInputDirective.ctorParameters = function () {
return [
{ type: BsDaterangepickerDirective, decorators: [{ type: Host },] },
{ type: BsLocaleService, },
{ type: Renderer2, },
{ type: ElementRef, },
{ type: ChangeDetectorRef, },
];
};
return BsDaterangepickerInputDirective;
}());
var BsCalendarLayoutComponent = (function () {
function BsCalendarLayoutComponent() {
}
BsCalendarLayoutComponent.decorators = [
{ type: Component, args: [{
selector: 'bs-calendar-layout',
template: "\n <!-- current date, will be added in nearest releases -->\n <bs-current-date title=\"hey there\" *ngIf=\"false\"></bs-current-date>\n\n <!--navigation-->\n <div class=\"bs-datepicker-head\">\n <ng-content select=\"bs-datepicker-navigation-view\"></ng-content>\n </div>\n\n <div class=\"bs-datepicker-body\">\n <ng-content></ng-content>\n </div>\n\n <!--timepicker-->\n <bs-timepicker *ngIf=\"false\"></bs-timepicker>\n "
},] },
];
/** @nocollapse */
BsCalendarLayoutComponent.ctorParameters = function () { return []; };
return BsCalendarLayoutComponent;
}());
var BsCurrentDateViewComponent = (function () {
function BsCurrentDateViewComponent() {
}
BsCurrentDateViewComponent.decorators = [
{ type: Component, args: [{
selector: 'bs-current-date',
template: "<div class=\"current-timedate\"><span>{{ title }}</span></div>"
},] },
];
/** @nocollapse */
BsCurrentDateViewComponent.ctorParameters = function () { return []; };
BsCurrentDateViewComponent.propDecorators = {
'title': [{ type: Input },],
};
return BsCurrentDateViewComponent;
}());
var BsCustomDatesViewComponent = (function () {
function BsCustomDatesViewComponent() {
}
BsCustomDatesViewComponent.decorators = [
{ type: Component, args: [{
selector: 'bs-custom-date-view',
template: "\n <div class=\"bs-datepicker-predefined-btns\">\n <button *ngFor=\"let range of ranges\">{{ range.label }}</button>\n <button *ngIf=\"isCustomRangeShown\">Custom Range</button>\n </div>\n ",
changeDetection: ChangeDetectionStrategy.OnPush
},] },
];
/** @nocollapse */
BsCustomDatesViewComponent.ctorParameters = function () { return []; };
BsCustomDatesViewComponent.propDecorators = {
'isCustomRangeShown': [{ type: Input },],
'ranges': [{ type: Input },],
};
return BsCustomDatesViewComponent;
}());
var BsDatepickerDayDecoratorComponent = (function () {
function BsDatepickerDayDecoratorComponent() {
}
BsDatepickerDayDecoratorComponent.decorators = [
{ type: Component, args: [{
selector: '[bsDatepickerDayDecorator]',
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
'[class.disabled]': 'day.isDisabled',
'[class.is-highlighted]': 'day.isHovered',
'[class.is-other-month]': 'day.isOtherMonth',
'[class.in-range]': 'day.isInRange',
'[class.select-start]': 'day.isSelectionStart',
'[class.select-end]': 'day.isSelectionEnd',
'[class.selected]': 'day.isSelected'
},
template: "{{ day.label }}"
},] },
];
/** @nocollapse */
BsDatepickerDayDecoratorComponent.ctorParameters = function () { return []; };
BsDatepickerDayDecoratorComponent.propDecorators = {
'day': [{ type: Input },],
};
return BsDatepickerDayDecoratorComponent;
}());
/** *************** */
// events
/** *************** */
var BsNavigationDirection;
(function (BsNavigationDirection) {
BsNavigationDirection[BsNavigationDirection["UP"] = 0] = "UP";
BsNavigationDirection[BsNavigationDirection["DOWN"] = 1] = "DOWN";
})(BsNavigationDirection || (BsNavigationDirection = {}));
var BsDatepickerNavigationViewComponent = (function () {
function BsDatepickerNavigationViewComponent() {
this.onNavigate = new EventEmitter();
this.onViewMode = new EventEmitter();
}
BsDatepickerNavigationViewComponent.prototype.navTo = function (down) {
this.onNavigate.emit(down ? BsNavigationDirection.DOWN : BsNavigationDirection.UP);
};
BsDatepickerNavigationViewComponent.prototype.view = function (viewMode) {
this.onViewMode.emit(viewMode);
};
BsDatepickerNavigationViewComponent.decorators = [
{ type: Component, args: [{
selector: 'bs-datepicker-navigation-view',
changeDetection: ChangeDetectionStrategy.OnPush,
template: "\n <button class=\"previous\"\n [disabled]=\"calendar.disableLeftArrow\"\n [style.visibility]=\"calendar.hideLeftArrow ? 'hidden' : 'visible'\"\n (click)=\"navTo(true)\"><span>‹</span>\n </button>\n\n <button class=\"current\"\n *ngIf=\"calendar.monthTitle\"\n (click)=\"view('month')\"\n ><span>{{ calendar.monthTitle }}</span>\n </button>\n\n <button class=\"current\" (click)=\"view('year')\"\n ><span>{{ calendar.yearTitle }}</span></button>\n\n <button class=\"next\"\n [disabled]=\"calendar.disableRightArrow\"\n [style.visibility]=\"calendar.hideRightArrow ? 'hidden' : 'visible'\"\n (click)=\"navTo(false)\"><span>›</span>\n </button>\n "
},] },
];
/** @nocollapse */
BsDatepickerNavigationViewComponent.ctorParameters = function () { return []; };
BsDatepickerNavigationViewComponent.propDecorators = {
'calendar': [{ type: Input },],
'onNavigate': [{ type: Output },],
'onViewMode': [{ type: Output },],
};
return BsDatepickerNavigationViewComponent;
}());
var BsDaysCalendarViewComponent = (function () {
function BsDaysCalendarViewComponent() {
this.onNavigate = new EventEmitter();
this.onViewMode = new EventEmitter();
this.onSelect = new EventEmitter();
this.onHover = new EventEmitter();
}
BsDaysCalendarViewComponent.prototype.navigateTo = function (event) {
var step = BsNavigationDirection.DOWN === event ? -1 : 1;
this.onNavigate.emit({ step: { month: step } });
};
BsDaysCalendarViewComponent.prototype.changeViewMode = function (event) {
this.onViewMode.emit(event);
};
BsDaysCalendarViewComponent.prototype.selectDay = function (event) {
this.onSelect.emit(event);
};
BsDaysCalendarViewComponent.prototype.hoverDay = function (cell, isHovered) {
this.onHover.emit({ cell: cell, isHovered: isHovered });
};
BsDaysCalendarViewComponent.decorators = [
{ type: Component, args: [{
selector: 'bs-days-calendar-view',
// changeDetection: ChangeDetectionStrategy.OnPush,
template: "\n <bs-calendar-layout>\n <bs-datepicker-navigation-view\n [calendar]=\"calendar\"\n (onNavigate)=\"navigateTo($event)\"\n (onViewMode)=\"changeViewMode($event)\"\n ></bs-datepicker-navigation-view>\n\n <!--days matrix-->\n <table role=\"grid\" class=\"days weeks\">\n <thead>\n <tr>\n <!--if show weeks-->\n <th *ngIf=\"options.showWeekNumbers\"></th>\n <th *ngFor=\"let weekday of calendar.weekdays; let i = index\"\n aria-label=\"weekday\">{{ calendar.weekdays[i] }}\n </th>\n </tr>\n </thead>\n <tbody>\n <tr *ngFor=\"let week of calendar.weeks; let i = index\">\n <td class=\"week\" *ngIf=\"options.showWeekNumbers\">\n <span>{{ calendar.weekNumbers[i] }}</span>\n </td>\n <td *ngFor=\"let day of week.days\" role=\"gridcell\">\n <span bsDatepickerDayDecorator\n [day]=\"day\"\n (click)=\"selectDay(day)\"\n (mouseenter)=\"hoverDay(day, true)\"\n (mouseleave)=\"hoverDay(day, false)\">{{ day.label }}</span>\n </td>\n </tr>\n </tbody>\n </table>\n\n </bs-calendar-layout>\n "
},] },
];
/** @nocollapse */
BsDaysCalendarViewComponent.ctorParameters = function () { return []; };
BsDaysCalendarViewComponent.propDecorators = {
'calendar': [{ type: Input },],
'options': [{ type: Input },],
'onNavigate': [{ type: Output },],
'onViewMode': [{ type: Output },],
'onSelect': [{ type: Output },],
'onHover': [{ type: Output },],
};
return BsDaysCalendarViewComponent;
}());
var BsMonthCalendarViewComponent = (function () {
function BsMonthCalendarViewComponent() {
this.onNavigate = new EventEmitter();
this.onViewMode = new EventEmitter();
this.onSelect = new EventEmitter();
this.onHover = new EventEmitter();
}
BsMonthCalendarViewComponent.prototype.navigateTo = function (event) {
var step = BsNavigationDirection.DOWN === event ? -1 : 1;
this.onNavigate.emit({ step: { year: step } });
};
BsMonthCalendarViewComponent.prototype.viewMonth = function (month) {
this.onSelect.emit(month);
};
BsMonthCalendarViewComponent.prototype.hoverMonth = function (cell, isHovered) {
this.onHover.emit({ cell: cell, isHovered: isHovered });
};
BsMonthCalendarViewComponent.prototype.changeViewMode = function (event) {
this.onViewMode.emit(event);
};
BsMonthCalendarViewComponent.decorators = [
{ type: Component, args: [{
selector: 'bs-month-calendar-view',
template: "\n <bs-calendar-layout>\n <bs-datepicker-navigation-view\n [calendar]=\"calendar\"\n (onNavigate)=\"navigateTo($event)\"\n (onViewMode)=\"changeViewMode($event)\"\n ></bs-datepicker-navigation-view>\n\n <table role=\"grid\" class=\"months\">\n <tbody>\n <tr *ngFor=\"let row of calendar.months\">\n <td *ngFor=\"let month of row\" role=\"gridcell\"\n (click)=\"viewMonth(month)\"\n (mouseenter)=\"hoverMonth(month, true)\"\n (mouseleave)=\"hoverMonth(month, false)\"\n [class.disabled]=\"month.isDisabled\"\n [class.is-highlighted]=\"month.isHovered\">\n <span>{{ month.label }}</span>\n </td>\n </tr>\n </tbody>\n </table>\n </bs-calendar-layout>\n "
},] },
];
/** @nocollapse */
BsMonthCalendarViewComponent.ctorParameters = function () { return []; };
BsMonthCalendarViewComponent.propDecorators = {
'calendar': [{ type: Input },],
'onNavigate': [{ type: Output },],
'onViewMode': [{ type: Output },],
'onSelect': [{ type: Output },],
'onHover': [{ type: Output },],
};
return BsMonthCalendarViewComponent;
}());
// tslint:disable:max-line-length
var BsTimepickerViewComponent = (function () {
function BsTimepickerViewComponent() {
this.ampm = 'ok';
this.hours = 0;
this.minutes = 0;
}
BsTimepickerViewComponent.decorators = [
{ type: Component, args: [{
selector: 'bs-timepicker',
template: "\n <div class=\"bs-timepicker-container\">\n <div class=\"bs-timepicker-controls\">\n <button class=\"bs-decrease\">-</button>\n <input type=\"text\" [value]=\"hours\" placeholder=\"00\">\n <button class=\"bs-increase\">+</button>\n </div>\n <div class=\"bs-timepicker-controls\">\n <button class=\"bs-decrease\">-</button>\n <input type=\"text\" [value]=\"minutes\" placeholder=\"00\">\n <button class=\"bs-increase\">+</button>\n </div>\n <button class=\"switch-time-format\">{{ ampm }}\n <img\n src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAAKCAYAAABi8KSDAAABSElEQVQYV3XQPUvDUBQG4HNuagtVqc6KgouCv6GIuIntYBLB9hcIQpLStCAIV7DYmpTcRWcXqZio3Vwc/UCc/QEqfgyKGbr0I7nS1EiHeqYzPO/h5SD0jaxUZjmSLCB+OFb+UFINFwASAEAdpu9gaGXVyAHHFQBkHpKHc6a9dzECvADyY9sqlAMsK9W0jzxDXqeytr3mhQckxSji27TJJ5/rPmIpwJJq3HrtduriYOurv1a4i1p5HnhkG9OFymi0ReoO05cGwb+ayv4dysVygjeFmsP05f8wpZQ8fsdvfmuY9zjWSNqUtgYFVnOVReILYoBFzdQI5/GGFzNHhGbeZnopDGU29sZbscgldmC99w35VOATTycIMMcBXIfpSVGzZhA6C8hh00conln6VQ9TGgV32OEAKQC4DrBq7CJwd0ggR7Vq/rPrfgB+C3sGypY5DAAAAABJRU5ErkJggg==\"\n alt=\"\">\n </button>\n </div>\n "
},] },
];
/** @nocollapse */
BsTimepickerViewComponent.ctorParameters = function () { return []; };
return BsTimepickerViewComponent;
}());
var BsYearsCalendarViewComponent = (function () {
function BsYearsCalendarViewComponent() {
this.onNavigate = new EventEmitter();
this.onViewMode = new EventEmitter();
this.onSelect = new EventEmitter();
this.onHover = new EventEmitter();
}
BsYearsCalendarViewComponent.prototype.navigateTo = function (event) {
var step = BsNavigationDirection.DOWN === event ? -1 : 1;
this.onNavigate.emit({ step: { year: step * yearsPerCalendar } });
};
BsYearsCalendarViewComponent.prototype.viewYear = function (year) {
this.onSelect.emit(year);
};
BsYearsCalendarViewComponent.prototype.hoverYear = function (cell, isHovered) {
this.onHover.emit({ cell: cell, isHovered: isHovered });
};
BsYearsCalendarViewComponent.prototype.changeViewMode = function (event) {
this.onViewMode.emit(event);
};
BsYearsCalendarViewComponent.decorators = [
{ type: Component, args: [{
selector: 'bs-years-calendar-view',
template: "\n <bs-calendar-layout>\n <bs-datepicker-navigation-view\n [calendar]=\"calendar\"\n (onNavigate)=\"navigateTo($event)\"\n (onViewMode)=\"changeViewMode($event)\"\n ></bs-datepicker-navigation-view>\n\n <table role=\"grid\" class=\"years\">\n <tbody>\n <tr *ngFor=\"let row of calendar.years\">\n <td *ngFor=\"let year of row\" role=\"gridcell\"\n (click)=\"viewYear(year)\"\n (mouseenter)=\"hoverYear(year, true)\"\n (mouseleave)=\"hoverYear(year, false)\"\n [class.disabled]=\"year.isDisabled\"\n [class.is-highlighted]=\"year.isHovered\">\n <span>{{ year.label }}</span>\n </td>\n </tr>\n </tbody>\n </table>\n </bs-calendar-layout>\n "
},] },
];
/** @nocollapse */
BsYearsCalendarViewComponent.ctorParameters = function () { return []; };
BsYearsCalendarViewComponent.propDecorators = {
'calendar': [{ type: Input },],
'onNavigate': [{ type: Output },],
'onViewMode': [{ type: Output },],
'onSelect': [{ type: Output },],
'onHover': [{ type: Output },],
};
return BsYearsCalendarViewComponent;
}());
var _exports = [
BsDatepickerContainerComponent,
BsDaterangepickerContainerComponent,
BsDatepickerDirective,
BsDatepickerInputDirective,
BsDaterangepickerInputDirective,
BsDaterangepickerDirective
];
var BsDatepickerModule = (function () {
function BsDatepickerModule() {
warnOnce("BsDatepickerModule is under development,\n BREAKING CHANGES are possible,\n PLEASE, read changelog");
}
BsDatepickerModule.forRoot = function () {
return {
ngModule: BsDatepickerModule,
providers: [
ComponentLoaderFactory,
PositioningService,
BsDatepickerStore,
BsDatepickerActions,
BsDatepickerConfig,
BsDaterangepickerConfig,
BsDatepickerEffects,
BsLocaleService
]
};
};
BsDatepickerModule.decorators = [
{ type: NgModule, args: [{
imports: [CommonModule],
declarations: [
BsDatepickerDayDecoratorComponent,
BsCurrentDateViewComponent,
BsDatepickerNavigationViewComponent,
BsTimepickerViewComponent,
BsCalendarLayoutComponent,
BsDaysCalendarViewComponent,
BsMonthCalendarViewComponent,
BsYearsCalendarViewComponent,
BsCustomDatesViewComponent
].concat(_exports),
entryComponents: [
BsDatepickerContainerComponent,
BsDaterangepickerContainerComponent
],
exports: _exports
},] },
];
/** @nocollapse */
BsDatepickerModule.ctorParameters = function () { return []; };
return BsDatepickerModule;
}());
var modalConfigDefaults = {
backdrop: true,
keyboard: true,
focus: true,
show: false,
ignoreBackdropClick: false,
class: '',
animated: true,
initialState: {}
};
var CLASS_NAME = {
SCROLLBAR_MEASURER: 'modal-scrollbar-measure',
BACKDROP: 'modal-backdrop',
OPEN: 'modal-open',
FADE: 'fade',
IN: 'in',
SHOW: 'show' // bs4
};
var DISMISS_REASONS = {
BACKRDOP: 'backdrop-click',
ESC: 'esc'
};
/** This component will be added as background layout for modals if enabled */
var ModalBackdropComponent = (function () {
function ModalBackdropComponent(element, renderer) {
this._isShown = false;
this.element = element;
this.renderer = renderer;
}
Object.defineProperty(ModalBackdropComponent.prototype, "isAnimated", {
get: function () {
return this._isAnimated;
},
set: function (value) {
this._isAnimated = value;
// this.renderer.setElementClass(this.element.nativeElement, `${ClassName.FADE}`, value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(ModalBackdropComponent.prototype, "isShown", {
get: function () {
return this._isShown;
},
set: function (value) {
this._isShown = value;
if (value) {
this.renderer.addClass(this.element.nativeElement, "" + CLASS_NAME.IN);
}
else {
this.renderer.removeClass(this.element.nativeElement, "" + CLASS_NAME.IN);
}
if (!isBs3()) {
if (value) {
this.renderer.addClass(this.element.nativeElement, "" + CLASS_NAME.SHOW);
}
else {
this.renderer.removeClass(this.element.nativeElement, "" + CLASS_NAME.SHOW);
}
}
},
enumerable: true,
configurable: true
});
ModalBackdropComponent.prototype.ngOnInit = function () {
if (this.isAnimated) {
this.renderer.addClass(this.element.nativeElement, "" + CLASS_NAME.FADE);
Utils.reflow(this.element.nativeElement);
}
this.isShown = true;
};
ModalBackdropComponent.decorators = [
{ type: Component, args: [{
selector: 'bs-modal-backdrop',
template: ' ',
host: { class: CLASS_NAME.BACKDROP }
},] },
];
/** @nocollapse */
ModalBackdropComponent.ctorParameters = function () {
return [
{ type: ElementRef, },
{ type: Renderer2, },
];
};
return ModalBackdropComponent;
}());
/* tslint:disable:max-file-line-count */
// todo: should we support enforce focus in?
// todo: in original bs there are was a way to prevent modal from showing
// todo: original modal had resize events
var TRANSITION_DURATION = 300;
var BACKDROP_TRANSITION_DURATION = 150;
/** Mark any code with directive to show it's content in modal */
var ModalDirective = (function () {
function ModalDirective(_element, _viewContainerRef, _renderer, clf) {
this._element = _element;
this._renderer = _renderer;
/** This event fires immediately when the `show` instance method is called. */
this.onShow = new EventEmitter();
/** This event is fired when the modal has been made visible to the user
* (will wait for CSS transitions to complete)
*/
this.onShown = new EventEmitter();
/** This event is fired immediately when
* the hide instance method has been called.
*/
this.onHide = new EventEmitter();
/** This event is fired when the modal has finished being
* hidden from the user (will wait for CSS transitions to complete).
*/
this.onHidden = new EventEmitter();
this._isShown = false;
this.isBodyOverflowing = false;
this.originalBodyPadding = 0;
this.scrollbarWidth = 0;
this.timerHideModal = 0;
this.timerRmBackDrop = 0;
this.isNested = false;
this._backdrop = clf.createLoader(_element, _viewContainerRef, _renderer);
}
Object.defineProperty(ModalDirective.prototype, "config", {
get: function () {
return this._config;
},
/** allows to set modal configuration via element property */
set: function (conf) {
this._config = this.getConfig(conf);
},
enumerable: true,
configurable: true
});
Object.defineProperty(ModalDirective.prototype, "isShown", {
get: function () {
return this._isShown;
},
enumerable: true,
configurable: true
});
ModalDirective.prototype.onClick = function (event) {
if (this.config.ignoreBackdropClick ||
this.config.backdrop === 'static' ||
event.target !== this._element.nativeElement) {
return;
}
this.dismissReason = DISMISS_REASONS.BACKRDOP;
this.hide(event);
};
// todo: consider preventing default and stopping propagation
ModalDirective.prototype.onEsc = function (event) {
if (!this._isShown) {
return;
}
if (event.keyCode === 27) {
event.preventDefault();
}
if (this.config.keyboard) {
this.dismissReason = DISMISS_REASONS.ESC;
this.hide();
}
};
ModalDirective.prototype.ngOnDestroy = function () {
this.config = void 0;
if (this._isShown) {
this._isShown = false;
this.hideModal();
this._backdrop.dispose();
}
};
ModalDirective.prototype.ngOnInit = function () {
var _this = this;
this._config = this._config || this.getConfig();
setTimeout(function () {
if (_this._config.show) {
_this.show();
}
}, 0);
};
/* Public methods */
/** Allows to manually toggle modal visibility */
ModalDirective.prototype.toggle = function () {
return this._isShown ? this.hide() : this.show();
};
/** Allows to manually open modal */
ModalDirective.prototype.show = function () {
var _this = this;
this.dismissReason = null;
this.onShow.emit(this);
if (this._isShown) {
return;
}
clearTimeout(this.timerHideModal);
clearTimeout(this.timerRmBackDrop);
this._isShown = true;
this.checkScrollbar();
this.setScrollbar();
if (document$1 && document$1.body) {
if (document$1.body.classList.contains(CLASS_NAME.OPEN)) {
this.isNested = true;
}
else {
this._renderer.addClass(document$1.body, CLASS_NAME.OPEN);
}
}
this.showBackdrop(function () {
_this.showElement();
});
};
/** Allows to manually close modal */
ModalDirective.prototype.hide = function (event) {
var _this = this;
if (event) {
event.preventDefault();
}
this.onHide.emit(this);
// todo: add an option to prevent hiding
if (!this._isShown) {
return;
}
clearTimeout(this.timerHideModal);
clearTimeout(this.timerRmBackDrop);
this._isShown = false;
this._renderer.removeClass(this._element.nativeElement, CLASS_NAME.IN);
if (!isBs3()) {
this._renderer.removeClass(this._element.nativeElement, CLASS_NAME.SHOW);
}
// this._addClassIn = false;
if (this._config.animated) {
this.timerHideModal = setTimeout(function () { return _this.hideModal(); }, TRANSITION_DURATION);
}
else {
this.hideModal();
}
};
/** Private methods @internal */
ModalDirective.prototype.getConfig = function (config) {
return Object.assign({}, modalConfigDefaults, config);
};
/**
* Show dialog
* @internal
*/
ModalDirective.prototype.showElement = function () {
var _this = this;
// todo: replace this with component loader usage
if (!this._element.nativeElement.parentNode ||
this._element.nativeElement.parentNode.nodeType !== Node.ELEMENT_NODE) {
// don't move modals dom position
if (document$1 && document$1.body) {
document$1.body.appendChild(this._element.nativeElement);
}
}
this._renderer.setAttribute(this._element.nativeElement, 'aria-hidden', 'false');
this._renderer.setAttribute(this._element.nativeElement, 'aria-modal', 'true');
this._renderer.setStyle(this._element.nativeElement, 'display', 'block');
this._renderer.setProperty(this._element.nativeElement, 'scrollTop', 0);
if (this._config.animated) {
Utils.reflow(this._element.nativeElement);
}
// this._addClassIn = true;
this._renderer.addClass(this._element.nativeElement, CLASS_NAME.IN);
if (!isBs3()) {
this._renderer.addClass(this._element.nativeElement, CLASS_NAME.SHOW);
}
var transitionComplete = function () {
if (_this._config.focus) {
_this._element.nativeElement.focus();
}
_this.onShown.emit(_this);
};
if (this._config.animated) {
setTimeout(transitionComplete, TRANSITION_DURATION);
}
else {
transitionComplete();
}
};
/** @internal */
ModalDirective.prototype.hideModal = function () {
var _this = this;
this._renderer.setAttribute(this._element.nativeElement, 'aria-hidden', 'true');
this._renderer.setStyle(this._element.nativeElement, 'display', 'none');
this.showBackdrop(function () {
if (!_this.isNested) {
if (document$1 && document$1.body) {
_this._renderer.removeClass(document$1.body, CLASS_NAME.OPEN);
}
_this.resetScrollbar();
}
_this.resetAdjustments();
_this.focusOtherModal();
_this.onHidden.emit(_this);
});
};
// todo: original show was calling a callback when done, but we can use
// promise
/** @internal */
ModalDirective.prototype.showBackdrop = function (callback) {
var _this = this;
if (this._isShown &&
this.config.backdrop &&
(!this.backdrop || !this.backdrop.instance.isShown)) {
this.removeBackdrop();
this._backdrop
.attach(ModalBackdropComponent)
.to('body')
.show({ isAnimated: this._config.animated });
this.backdrop = this._backdrop._componentRef;
if (!callback) {
return;
}
if (!this._config.animated) {
callback();
return;
}
setTimeout(callback, BACKDROP_TRANSITION_DURATION);
}
else if (!this._isShown && this.backdrop) {
this.backdrop.instance.isShown = false;
var callbackRemove = function () {
_this.removeBackdrop();
if (callback) {
callback();
}
};
if (this.backdrop.instance.isAnimated) {
this.timerRmBackDrop = setTimeout(callbackRemove, BACKDROP_TRANSITION_DURATION);
}
else {
callbackRemove();
}
}
else if (callback) {
callback();
}
};
/** @internal */
ModalDirective.prototype.removeBackdrop = function () {
this._backdrop.hide();
};
/** Events tricks */
// no need for it
// protected setEscapeEvent():void {
// if (this._isShown && this._config.keyboard) {
// $(this._element).on(Event.KEYDOWN_DISMISS, (event) => {
// if (event.which === 27) {
// this.hide()
// }
// })
//
// } else if (!this._isShown) {
// $(this._element).off(Event.KEYDOWN_DISMISS)
// }
// }
// protected setResizeEvent():void {
// console.log(this.renderer.listenGlobal('', Event.RESIZE));
// if (this._isShown) {
// $(window).on(Event.RESIZE, $.proxy(this._handleUpdate, this))
// } else {
// $(window).off(Event.RESIZE)
// }
// }
ModalDirective.prototype.focusOtherModal = function () {
if (this._element.nativeElement.parentElement == null)
return;
var otherOpenedModals = this._element.nativeElement.parentElement.querySelectorAll('.in[bsModal]');
if (!otherOpenedModals.length) {
return;
}
otherOpenedModals[otherOpenedModals.length - 1].focus();
};
/** @internal */
ModalDirective.prototype.resetAdjustments = function () {
this._renderer.setStyle(this._element.nativeElement, 'paddingLeft', '');
this._renderer.setStyle(this._element.nativeElement, 'paddingRight', '');
};
/** Scroll bar tricks */
/** @internal */
ModalDirective.prototype.checkScrollbar = function () {
this.isBodyOverflowing = document$1.body.clientWidth < win.innerWidth;
this.scrollbarWidth = this.getScrollbarWidth();
};
ModalDirective.prototype.setScrollbar = function () {
if (!document$1) {
return;
}
this.originalBodyPadding = parseInt(win
.getComputedStyle(document$1.body)
.getPropertyValue('padding-right') || 0, 10);
if (this.isBodyOverflowing) {
document$1.body.style.paddingRight = this.originalBodyPadding +
this.scrollbarWidth + "px";
}
};
ModalDirective.prototype.resetScrollbar = function () {
document$1.body.style.paddingRight = this.originalBodyPadding + 'px';
};
// thx d.walsh
ModalDirective.prototype.getScrollbarWidth = function () {
var scrollDiv = this._renderer.createElement('div');
this._renderer.addClass(scrollDiv, CLASS_NAME.SCROLLBAR_MEASURER);
this._renderer.appendChild(document$1.body, scrollDiv);
var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
this._renderer.removeChild(document$1.body, scrollDiv);
return scrollbarWidth;
};
ModalDirective.decorators = [
{ type: Directive, args: [{
selector: '[bsModal]',
exportAs: 'bs-modal'
},] },
];
/** @nocollapse */
ModalDirective.ctorParameters = function () {
return [
{ type: ElementRef, },
{ type: ViewContainerRef, },
{ type: Renderer2, },
{ type: ComponentLoaderFactory, },
];
};
ModalDirective.propDecorators = {
'config': [{ type: Input },],
'onShow': [{ type: Output },],
'onShown': [{ type: Output },],
'onHide': [{ type: Output },],
'onHidden': [{ type: Output },],
'onClick': [{ type: HostListener, args: ['click', ['$event'],] },],
'onEsc': [{ type: HostListener, args: ['keydown.esc', ['$event'],] },],
};
return ModalDirective;
}());
/** Default dropdown configuration */
var BsDropdownConfig = (function () {
function BsDropdownConfig() {
/** default dropdown auto closing behavior */
this.autoClose = true;
}
BsDropdownConfig.decorators = [
{ type: Injectable },
];
/** @nocollapse */
BsDropdownConfig.ctorParameters = function () { return []; };
return BsDropdownConfig;
}());
var BsDropdownState = (function () {
function BsDropdownState() {
var _this = this;
this.direction = 'down';
this.isOpenChange = new EventEmitter();
this.isDisabledChange = new EventEmitter();
this.toggleClick = new EventEmitter();
this.dropdownMenu = new Promise(function (resolve) {
_this.resolveDropdownMenu = resolve;
});
}
BsDropdownState.decorators = [
{ type: Injectable },
];
/** @nocollapse */
BsDropdownState.ctorParameters = function () { return []; };
return BsDropdownState;
}());
var BsDropdownContainerComponent = (function () {
function BsDropdownContainerComponent(_state, cd, _renderer, _element) {
var _this = this;
this._state = _state;
this.cd = cd;
this._renderer = _renderer;
this.isOpen = false;
this._subscription = _state.isOpenChange.subscribe(function (value) {
_this.isOpen = value;
var dropdown = _element.nativeElement.querySelector('.dropdown-menu');
if (dropdown && !isBs3()) {
_this._renderer.addClass(dropdown, 'show');
if (dropdown.classList.contains('dropdown-menu-right')) {
_this._renderer.setStyle(dropdown, 'left', 'auto');
_this._renderer.setStyle(dropdown, 'right', '0');
}
if (_this.direction === 'up') {
_this._renderer.setStyle(dropdown, 'top', 'auto');
_this._renderer.setStyle(dropdown, 'transform', 'translateY(-101%)');
}
}
_this.cd.markForCheck();
_this.cd.detectChanges();
});
}
Object.defineProperty(BsDropdownContainerComponent.prototype, "direction", {
get: function () {
return this._state.direction;
},
enumerable: true,
configurable: true
});
BsDropdownContainerComponent.prototype.ngOnDestroy = function () {
this._subscription.unsubscribe();
};
BsDropdownContainerComponent.decorators = [
{ type: Component, args: [{
selector: 'bs-dropdown-container',
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
style: 'display:block;position: absolute;'
},
template: "\n <div [class.dropup]=\"direction === 'up'\"\n [class.dropdown]=\"direction === 'down'\"\n [class.show]=\"isOpen\"\n [class.open]=\"isOpen\"><ng-content></ng-content></div>\n "
},] },
];
/** @nocollapse */
BsDropdownContainerComponent.ctorParameters = function () {
return [
{ type: BsDropdownState, },
{ type: ChangeDetectorRef, },
{ type: Renderer2, },
{ type: ElementRef, },
];
};
return BsDropdownContainerComponent;
}());
// tslint:disable:max-file-line-count
var BsDropdownDirective = (function () {
function BsDropdownDirective(_elementRef, _renderer, _viewContainerRef, _cis, _config, _state) {
this._elementRef = _elementRef;
this._renderer = _renderer;
this._viewContainerRef = _viewContainerRef;
this._cis = _cis;
this._config = _config;
this._state = _state;
// todo: move to component loader
this._isInlineOpen = false;
this._subscriptions = [];
this._isInited = false;
// set initial dropdown state from config
this._state.autoClose = this._config.autoClose;
// create dropdown component loader
this._dropdown = this._cis
.createLoader(this._elementRef, this._viewContainerRef, this._renderer)
.provide({ provide: BsDropdownState, useValue: this._state });
this.onShown = this._dropdown.onShown;
this.onHidden = this._dropdown.onHidden;
this.isOpenChange = this._state.isOpenChange;
}
Object.defineProperty(BsDropdownDirective.prototype, "autoClose", {
get: function () {
return this._state.autoClose;
},
/**
* Indicates that dropdown will be closed on item or document click,
* and after pressing ESC
*/
set: function (value) {
this._state.autoClose = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(BsDropdownDirective.prototype, "isDisabled", {
get: function () {
return this._isDisabled;
},
/**
* Disables dropdown toggle and hides dropdown menu if opened
*/
set: function (value) {
this._isDisabled = value;
this._state.isDisabledChange.emit(value);
if (value) {
this.hide();
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(BsDropdownDirective.prototype, "isOpen", {
/**
* Returns whether or not the popover is currently being shown
*/
get: function () {
if (this._showInline) {
return this._isInlineOpen;
}
return this._dropdown.isShown;
},
set: function (value) {
if (value) {
this.show();
}
else {
this.hide();
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(BsDropdownDirective.prototype, "isBs4", {
get: function () {
return !isBs3();
},
enumerable: true,
configurable: true
});
Object.defineProperty(BsDropdownDirective.prototype, "_showInline", {
get: function () {
return !this.container;
},
enumerable: true,
configurable: true
});
BsDropdownDirective.prototype.ngOnInit = function () {
var _this = this;
// fix: seems there are an issue with `routerLinkActive`
// which result in duplicated call ngOnInit without call to ngOnDestroy
// read more: https://github.com/valor-software/ngx-bootstrap/issues/1885
if (this._isInited) {
return;
}
this._isInited = true;
// attach DOM listeners
this._dropdown.listen({
// because of dropdown inline mode
outsideClick: false,
triggers: this.triggers,
show: function () { return _this.show(); }
});
// toggle visibility on toggle element click
this._subscriptions.push(this._state.toggleClick.subscribe(function (value) { return _this.toggle(value); }));
// hide dropdown if set disabled while opened
this._subscriptions.push(this._state.isDisabledChange
.filter(function (value) { return value; })
.subscribe(function (value) { return _this.hide(); }));
};
/**
* Opens an element’s popover. This is considered a “manual” triggering of
* the popover.
*/
BsDropdownDirective.prototype.show = function () {
var _this = this;
if (this.isOpen || this.isDisabled) {
return;
}
if (this._showInline) {
if (!this._inlinedMenu) {
this._state.dropdownMenu.then(function (dropdownMenu) {
_this._dropdown.attachInline(dropdownMenu.viewContainer, dropdownMenu.templateRef);
_this._inlinedMenu = _this._dropdown._inlineViewRef;
_this.addBs4Polyfills();
})
.catch();
}
this.addBs4Polyfills();
this._isInlineOpen = true;
this.onShown.emit(true);
this._state.isOpenChange.emit(true);
return;
}
this._state.dropdownMenu.then(function (dropdownMenu) {
// check direction in which dropdown should be opened
var _dropup = _this.dropup ||
(typeof _this.dropup !== 'undefined' && _this.dropup);
_this._state.direction = _dropup ? 'up' : 'down';
var _placement = _this.placement || (_dropup ? 'top left' : 'bottom left');
// show dropdown
_this._dropdown
.attach(BsDropdownContainerComponent)
.to(_this.container)
.position({ attachment: _placement })
.show({
content: dropdownMenu.templateRef,
placement: _placement
});
_this._state.isOpenChange.emit(true);
})
.catch();
};
/**
* Closes an element’s popover. This is considered a “manual” triggering of
* the popover.
*/
BsDropdownDirective.prototype.hide = function () {
if (!this.isOpen) {
return;
}
if (this._showInline) {
this.removeShowClass();
this.removeDropupStyles();
this._isInlineOpen = false;
this.onHidden.emit(true);
}
else {
this._dropdown.hide();
}
this._state.isOpenChange.emit(false);
};
/**
* Toggles an element’s popover. This is considered a “manual” triggering of
* the popover.
*/
BsDropdownDirective.prototype.toggle = function (value) {
if (this.isOpen || !value) {
return this.hide();
}
return this.show();
};
BsDropdownDirective.prototype.ngOnDestroy = function () {
// clean up subscriptions and destroy dropdown
for (var _i = 0, _a = this._subscriptions; _i < _a.length; _i++) {
var sub = _a[_i];
sub.unsubscribe();
}
this._dropdown.dispose();
};
BsDropdownDirective.prototype.addBs4Polyfills = function () {
if (!isBs3()) {
this.addShowClass();
this.checkRightAlignment();
this.addDropupStyles();
}
};
BsDropdownDirective.prototype.addShowClass = function () {
if (this._inlinedMenu && this._inlinedMenu.rootNodes[0]) {
this._renderer.addClass(this._inlinedMenu.rootNodes[0], 'show');
}
};
BsDropdownDirective.prototype.removeShowClass = function () {
if (this._inlinedMenu && this._inlinedMenu.rootNodes[0]) {
this._renderer.removeClass(this._inlinedMenu.rootNodes[0], 'show');
}
};
BsDropdownDirective.prototype.checkRightAlignment = function () {
if (this._inlinedMenu && this._inlinedMenu.rootNodes[0]) {
var isRightAligned = this._inlinedMenu.rootNodes[0].classList.contains('dropdown-menu-right');
this._renderer.setStyle(this._inlinedMenu.rootNodes[0], 'left', isRightAligned ? 'auto' : '0');
this._renderer.setStyle(this._inlinedMenu.rootNodes[0], 'right', isRightAligned ? '0' : 'auto');
}
};
BsDropdownDirective.prototype.addDropupStyles = function () {
if (this._inlinedMenu && this._inlinedMenu.rootNodes[0]) {
// a little hack to not break support of bootstrap 4 beta
this._renderer.setStyle(this._inlinedMenu.rootNodes[0], 'top', this.dropup ? 'auto' : '100%');
this._renderer.setStyle(this._inlinedMenu.rootNodes[0], 'transform', this.dropup ? 'translateY(-101%)' : 'translateY(0)');
}
};
BsDropdownDirective.prototype.removeDropupStyles = function () {
if (this._inlinedMenu && this._inlinedMenu.rootNodes[0]) {
this._renderer.removeStyle(this._inlinedMenu.rootNodes[0], 'top');
this._renderer.removeStyle(this._inlinedMenu.rootNodes[0], 'transform');
}
};
BsDropdownDirective.decorators = [
{ type: Directive, args: [{
selector: '[bsDropdown],[dropdown]',
exportAs: 'bs-dropdown',
providers: [BsDropdownState],
host: {
'[class.dropup]': 'dropup',
'[class.open]': 'isOpen',
'[class.show]': 'isOpen && isBs4'
}
},] },
];
/** @nocollapse */
BsDropdownDirective.ctorParameters = function () {
return [
{ type: ElementRef, },
{ type: Renderer2, },
{ type: ViewContainerRef, },
{ type: ComponentLoaderFactory, },
{ type: BsDropdownConfig, },
{ type: BsDropdownState, },
];
};
BsDropdownDirective.propDecorators = {
'placement': [{ type: Input },],
'triggers': [{ type: Input },],
'container': [{ type: Input },],
'dropup': [{ type: Input },],
'autoClose': [{ type: Input },],
'isDisabled': [{ type: Input },],
'isOpen': [{ type: Input },],
'isOpenChange': [{ type: Output },],
'onShown': [{ type: Output },],
'onHidden': [{ type: Output },],
};
return BsDropdownDirective;
}());
// todo: split
/** Provides default values for Pagination and pager components */
var PaginationConfig = (function () {
function PaginationConfig() {
this.main = {
maxSize: void 0,
itemsPerPage: 10,
boundaryLinks: false,
directionLinks: true,
firstText: 'First',
previousText: 'Previous',
nextText: 'Next',
lastText: 'Last',
pageBtnClass: '',
rotate: true
};
this.pager = {
itemsPerPage: 15,
previousText: '« Previous',
nextText: 'Next »',
pageBtnClass: '',
align: true
};
}
PaginationConfig.decorators = [
{ type: Injectable },
];
/** @nocollapse */
PaginationConfig.ctorParameters = function () { return []; };
return PaginationConfig;
}());
var PAGER_CONTROL_VALUE_ACCESSOR = {
provide: NG_VALUE_ACCESSOR,
// tslint:disable-next-line
useExisting: forwardRef(function () { return PagerComponent; }),
multi: true
};
var PagerComponent = (function () {
function PagerComponent(renderer, elementRef, paginationConfig, changeDetection) {
this.renderer = renderer;
this.elementRef = elementRef;
this.changeDetection = changeDetection;
/** fired when total pages count changes, $event:number equals to total pages count */
this.numPages = new EventEmitter();
/** fired when page was changed, $event:{page, itemsPerPage} equals to
* object with current page index and number of items per page
*/
this.pageChanged = new EventEmitter();
this.onChange = Function.prototype;
this.onTouched = Function.prototype;
this.inited = false;
this._page = 1;
this.renderer = renderer;
this.elementRef = elementRef;
if (!this.config) {
this.configureOptions(Object.assign({}, paginationConfig.main, paginationConfig.pager));
}
}
Object.defineProperty(PagerComponent.prototype, "itemsPerPage", {
/** maximum number of items per page. If value less than 1 will display all items on one page */
get: function () {
return this._itemsPerPage;
},
set: function (v) {
this._itemsPerPage = v;
this.totalPages = this.calculateTotalPages();
},
enumerable: true,
configurable: true
});
Object.defineProperty(PagerComponent.prototype, "totalItems", {
/** total number of items in all pages */
get: function () {
return this._totalItems;
},
set: function (v) {
this._totalItems = v;
this.totalPages = this.calculateTotalPages();
},
enumerable: true,
configurable: true
});
Object.defineProperty(PagerComponent.prototype, "totalPages", {
get: function () {
return this._totalPages;
},
set: function (v) {
this._totalPages = v;
this.numPages.emit(v);
if (this.inited) {
this.selectPage(this.page);
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(PagerComponent.prototype, "page", {
get: function () {
return this._page;
},
set: function (value) {
var _previous = this._page;
this._page = value > this.totalPages ? this.totalPages : value || 1;
this.changeDetection.markForCheck();
if (_previous === this._page || typeof _previous === 'undefined') {
return;
}
this.pageChanged.emit({
page: this._page,
itemsPerPage: this.itemsPerPage
});
},
enumerable: true,
configurable: true
});
PagerComponent.prototype.configureOptions = function (config) {
this.config = Object.assign({}, config);
};
PagerComponent.prototype.ngOnInit = function () {
if (typeof window !== 'undefined') {
this.classMap = this.elementRef.nativeElement.getAttribute('class') || '';
}
// watch for maxSize
this.maxSize =
typeof this.maxSize !== 'undefined' ? this.maxSize : this.config.maxSize;
this.rotate =
typeof this.rotate !== 'undefined' ? this.rotate : this.config.rotate;
this.boundaryLinks =
typeof this.boundaryLinks !== 'undefined'
? this.boundaryLinks
: this.config.boundaryLinks;
this.directionLinks =
typeof this.directionLinks !== 'undefined'
? this.directionLinks
: this.config.directionLinks;
this.pageBtnClass =
typeof this.pageBtnClass !== 'undefined'
? this.pageBtnClass
: this.config.pageBtnClass;
// base class
this.itemsPerPage =
typeof this.itemsPerPage !== 'undefined'
? this.itemsPerPage
: this.config.itemsPerPage;
this.totalPages = this.calculateTotalPages();
// this class
this.pages = this.getPages(this.page, this.totalPages);
this.inited = true;
};
PagerComponent.prototype.writeValue = function (value) {
this.page = value;
this.pages = this.getPages(this.page, this.totalPages);
};
PagerComponent.prototype.getText = function (key) {
return this[key + "Text"] || this.config[key + "Text"];
};
PagerComponent.prototype.noPrevious = function () {
return this.page === 1;
};
PagerComponent.prototype.noNext = function () {
return this.page === this.totalPages;
};
PagerComponent.prototype.registerOnChange = function (fn) {
this.onChange = fn;
};
PagerComponent.prototype.registerOnTouched = function (fn) {
this.onTouched = fn;
};
PagerComponent.prototype.selectPage = function (page, event) {
if (event) {
event.preventDefault();
}
if (!this.disabled) {
if (event && event.target) {
var target = event.target;
target.blur();
}
this.writeValue(page);
this.onChange(this.page);
}
};
// Create page object used in template
PagerComponent.prototype.makePage = function (num, text, active) {
return { text: text, number: num, active: active };
};
PagerComponent.prototype.getPages = function (currentPage, totalPages) {
var pages = [];
// Default page limits
var startPage = 1;
var endPage = totalPages;
var isMaxSized = typeof this.maxSize !== 'undefined' && this.maxSize < totalPages;
// recompute if maxSize
if (isMaxSized) {
if (this.rotate) {
// Current page is displayed in the middle of the visible ones
startPage = Math.max(currentPage - Math.floor(this.maxSize / 2), 1);
endPage = startPage + this.maxSize - 1;
// Adjust if limit is exceeded
if (endPage > totalPages) {
endPage = totalPages;
startPage = endPage - this.maxSize + 1;
}
}
else {
// Visible pages are paginated with maxSize
startPage =
(Math.ceil(currentPage / this.maxSize) - 1) * this.maxSize + 1;
// Adjust last page if limit is exceeded
endPage = Math.min(startPage + this.maxSize - 1, totalPages);
}
}
// Add page number links
for (var num = startPage; num <= endPage; num++) {
var page = this.makePage(num, num.toString(), num === currentPage);
pages.push(page);
}
// Add links to move between page sets
if (isMaxSized && !this.rotate) {
if (startPage > 1) {
var previousPageSet = this.makePage(startPage - 1, '...', false);
pages.unshift(previousPageSet);
}
if (endPage < totalPages) {
var nextPageSet = this.makePage(endPage + 1, '...', false);
pages.push(nextPageSet);
}
}
return pages;
};
// base class
PagerComponent.prototype.calculateTotalPages = function () {
var totalPages = this.itemsPerPage < 1
? 1
: Math.ceil(this.totalItems / this.itemsPerPage);
return Math.max(totalPages || 0, 1);
};
PagerComponent.decorators = [
{ type: Component, args: [{
selector: 'pager',
template: "<ul class=\"pager\"> <li [class.disabled]=\"noPrevious()\" [class.previous]=\"align\" [ngClass]=\"{'pull-right': align, 'float-right': align}\" class=\"{{ pageBtnClass }}\"> <a href (click)=\"selectPage(page - 1, $event)\">{{ getText('previous') }}</a> </li> <li [class.disabled]=\"noNext()\" [class.next]=\"align\" [ngClass]=\"{'pull-right': align, 'float-right': align}\" class=\"{{ pageBtnClass }}\"> <a href (click)=\"selectPage(page + 1, $event)\">{{ getText('next') }}</a> </li> </ul> ",
providers: [PAGER_CONTROL_VALUE_ACCESSOR]
},] },
];
/** @nocollapse */
PagerComponent.ctorParameters = function () {
return [
{ type: Renderer2, },
{ type: ElementRef, },
{ type: PaginationConfig, },
{ type: ChangeDetectorRef, },
];
};
PagerComponent.propDecorators = {
'align': [{ type: Input },],
'maxSize': [{ type: Input },],
'boundaryLinks': [{ type: Input },],
'directionLinks': [{ type: Input },],
'firstText': [{ type: Input },],
'previousText': [{ type: Input },],
'nextText': [{ type: Input },],
'lastText': [{ type: Input },],
'rotate': [{ type: Input },],
'pageBtnClass': [{ type: Input },],
'disabled': [{ type: Input },],
'numPages': [{ type: Output },],
'pageChanged': [{ type: Output },],
'itemsPerPage': [{ type: Input },],
'totalItems': [{ type: Input },],
};
return PagerComponent;
}());
var PAGINATION_CONTROL_VALUE_ACCESSOR = {
provide: NG_VALUE_ACCESSOR,
// tslint:disable-next-line
useExisting: forwardRef(function () { return PaginationComponent; }),
multi: true
};
var PaginationComponent = (function () {
function PaginationComponent(renderer, elementRef, paginationConfig, changeDetection) {
this.renderer = renderer;
this.elementRef = elementRef;
this.changeDetection = changeDetection;
/** fired when total pages count changes, $event:number equals to total pages count */
this.numPages = new EventEmitter();
/** fired when page was changed, $event:{page, itemsPerPage} equals to object
* with current page index and number of items per page
*/
this.pageChanged = new EventEmitter();
this.onChange = Function.prototype;
this.onTouched = Function.prototype;
this.inited = false;
this._page = 1;
this.renderer = renderer;
this.elementRef = elementRef;
if (!this.config) {
this.configureOptions(paginationConfig.main);
}
}
Object.defineProperty(PaginationComponent.prototype, "itemsPerPage", {
/** maximum number of items per page. If value less than 1 will display all items on one page */
get: function () {
return this._itemsPerPage;
},
set: function (v) {
this._itemsPerPage = v;
this.totalPages = this.calculateTotalPages();
},
enumerable: true,
configurable: true
});
Object.defineProperty(PaginationComponent.prototype, "totalItems", {
/** total number of items in all pages */
get: function () {
return this._totalItems;
},
set: function (v) {
this._totalItems = v;
this.totalPages = this.calculateTotalPages();
},
enumerable: true,
configurable: true
});
Object.defineProperty(PaginationComponent.prototype, "totalPages", {
get: function () {
return this._totalPages;
},
set: function (v) {
this._totalPages = v;
this.numPages.emit(v);
if (this.inited) {
this.selectPage(this.page);
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(PaginationComponent.prototype, "page", {
get: function () {
return this._page;
},
set: function (value) {
var _previous = this._page;
this._page = value > this.totalPages ? this.totalPages : value || 1;
this.changeDetection.markForCheck();
if (_previous === this._page || typeof _previous === 'undefined') {
return;
}
this.pageChanged.emit({
page: this._page,
itemsPerPage: this.itemsPerPage
});
},
enumerable: true,
configurable: true
});
PaginationComponent.prototype.configureOptions = function (config) {
this.config = Object.assign({}, config);
};
PaginationComponent.prototype.ngOnInit = function () {
if (typeof window !== 'undefined') {
this.classMap = this.elementRef.nativeElement.getAttribute('class') || '';
}
// watch for maxSize
this.maxSize =
typeof this.maxSize !== 'undefined' ? this.maxSize : this.config.maxSize;
this.rotate =
typeof this.rotate !== 'undefined' ? this.rotate : this.config.rotate;
this.boundaryLinks =
typeof this.boundaryLinks !== 'undefined'
? this.boundaryLinks
: this.config.boundaryLinks;
this.directionLinks =
typeof this.directionLinks !== 'undefined'
? this.directionLinks
: this.config.directionLinks;
this.pageBtnClass =
typeof this.pageBtnClass !== 'undefined'
? this.pageBtnClass
: this.config.pageBtnClass;
// base class
this.itemsPerPage =
typeof this.itemsPerPage !== 'undefined'
? this.itemsPerPage
: this.config.itemsPerPage;
this.totalPages = this.calculateTotalPages();
// this class
this.pages = this.getPages(this.page, this.totalPages);
this.inited = true;
};
PaginationComponent.prototype.writeValue = function (value) {
this.page = value;
this.pages = this.getPages(this.page, this.totalPages);
};
PaginationComponent.prototype.getText = function (key) {
return this[key + "Text"] || this.config[key + "Text"];
};
PaginationComponent.prototype.noPrevious = function () {
return this.page === 1;
};
PaginationComponent.prototype.noNext = function () {
return this.page === this.totalPages;
};
PaginationComponent.prototype.registerOnChange = function (fn) {
this.onChange = fn;
};
PaginationComponent.prototype.registerOnTouched = function (fn) {
this.onTouched = fn;
};
PaginationComponent.prototype.selectPage = function (page, event) {
if (event) {
event.preventDefault();
}
if (!this.disabled) {
if (event && event.target) {
var target = event.target;
target.blur();
}
this.writeValue(page);
this.onChange(this.page);
}
};
// Create page object used in template
PaginationComponent.prototype.makePage = function (num, text, active) {
return { text: text, number: num, active: active };
};
PaginationComponent.prototype.getPages = function (currentPage, totalPages) {
var pages = [];
// Default page limits
var startPage = 1;
var endPage = totalPages;
var isMaxSized = typeof this.maxSize !== 'undefined' && this.maxSize < totalPages;
// recompute if maxSize
if (isMaxSized) {
if (this.rotate) {
// Current page is displayed in the middle of the visible ones
startPage = Math.max(currentPage - Math.floor(this.maxSize / 2), 1);
endPage = startPage + this.maxSize - 1;
// Adjust if limit is exceeded
if (endPage > totalPages) {
endPage = totalPages;
startPage = endPage - this.maxSize + 1;
}
}
else {
// Visible pages are paginated with maxSize
startPage =
(Math.ceil(currentPage / this.maxSize) - 1) * this.maxSize + 1;
// Adjust last page if limit is exceeded
endPage = Math.min(startPage + this.maxSize - 1, totalPages);
}
}
// Add page number links
for (var num = startPage; num <= endPage; num++) {
var page = this.makePage(num, num.toString(), num === currentPage);
pages.push(page);
}
// Add links to move between page sets
if (isMaxSized && !this.rotate) {
if (startPage > 1) {
var previousPageSet = this.makePage(startPage - 1, '...', false);
pages.unshift(previousPageSet);
}
if (endPage < totalPages) {
var nextPageSet = this.makePage(endPage + 1, '...', false);
pages.push(nextPageSet);
}
}
return pages;
};
// base class
PaginationComponent.prototype.calculateTotalPages = function () {
var totalPages = this.itemsPerPage < 1
? 1
: Math.ceil(this.totalItems / this.itemsPerPage);
return Math.max(totalPages || 0, 1);
};
PaginationComponent.decorators = [
{ type: Component, args: [{
selector: 'pagination',
template: "<ul class=\"pagination\" [ngClass]=\"classMap\"> <li class=\"pagination-first page-item\" *ngIf=\"boundaryLinks\" [class.disabled]=\"noPrevious()||disabled\"> <a class=\"page-link\" href (click)=\"selectPage(1, $event)\" [innerHTML]=\"getText('first')\"></a> </li> <li class=\"pagination-prev page-item\" *ngIf=\"directionLinks\" [class.disabled]=\"noPrevious()||disabled\"> <a class=\"page-link\" href (click)=\"selectPage(page - 1, $event)\" [innerHTML]=\"getText('previous')\"></a> </li> <li *ngFor=\"let pg of pages\" [class.active]=\"pg.active\" [class.disabled]=\"disabled&&!pg.active\" class=\"pagination-page page-item\"> <a class=\"page-link\" href (click)=\"selectPage(pg.number, $event)\" [innerHTML]=\"pg.text\"></a> </li> <li class=\"pagination-next page-item\" *ngIf=\"directionLinks\" [class.disabled]=\"noNext()||disabled\"> <a class=\"page-link\" href (click)=\"selectPage(page + 1, $event)\" [innerHTML]=\"getText('next')\"></a></li> <li class=\"pagination-last page-item\" *ngIf=\"boundaryLinks\" [class.disabled]=\"noNext()||disabled\"> <a class=\"page-link\" href (click)=\"selectPage(totalPages, $event)\" [innerHTML]=\"getText('last')\"></a></li> </ul> ",
providers: [PAGINATION_CONTROL_VALUE_ACCESSOR]
},] },
];
/** @nocollapse */
PaginationComponent.ctorParameters = function () {
return [
{ type: Renderer2, },
{ type: ElementRef, },
{ type: PaginationConfig, },
{ type: ChangeDetectorRef, },
];
};
PaginationComponent.propDecorators = {
'align': [{ type: Input },],
'maxSize': [{ type: Input },],
'boundaryLinks': [{ type: Input },],
'directionLinks': [{ type: Input },],
'firstText': [{ type: Input },],
'previousText': [{ type: Input },],
'nextText': [{ type: Input },],
'lastText': [{ type: Input },],
'rotate': [{ type: Input },],
'pageBtnClass': [{ type: Input },],
'disabled': [{ type: Input },],
'numPages': [{ type: Output },],
'pageChanged': [{ type: Output },],
'itemsPerPage': [{ type: Input },],
'totalItems': [{ type: Input },],
};
return PaginationComponent;
}());
var ProgressbarConfig = (function () {
function ProgressbarConfig() {
/** if `true` changing value of progress bar will be animated */
this.animate = false;
/** maximum total value of progress element */
this.max = 100;
}
ProgressbarConfig.decorators = [
{ type: Injectable },
];
/** @nocollapse */
ProgressbarConfig.ctorParameters = function () { return []; };
return ProgressbarConfig;
}());
var ProgressbarComponent = (function () {
function ProgressbarComponent(config) {
this.isStacked = false;
this.addClass = true;
this.bars = [];
this._max = 100;
Object.assign(this, config);
}
Object.defineProperty(ProgressbarComponent.prototype, "value", {
/** current value of progress bar. Could be a number or array of objects
* like {"value":15,"type":"info","label":"15 %"}
*/
set: function (value) {
this.isStacked = Array.isArray(value);
this._value = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ProgressbarComponent.prototype, "isBs3", {
get: function () {
return isBs3();
},
enumerable: true,
configurable: true
});
Object.defineProperty(ProgressbarComponent.prototype, "max", {
/** maximum total value of progress element */
get: function () {
return this._max;
},
set: function (v) {
this._max = v;
this.bars.forEach(function (bar) {
bar.recalculatePercentage();
});
},
enumerable: true,
configurable: true
});
ProgressbarComponent.prototype.addBar = function (bar) {
bar.animate = this.animate;
bar.striped = this.striped;
this.bars.push(bar);
};
ProgressbarComponent.prototype.removeBar = function (bar) {
this.bars.splice(this.bars.indexOf(bar), 1);
};
ProgressbarComponent.decorators = [
{ type: Component, args: [{
selector: 'progressbar',
template: "<bar [type]=\"type\" [value]=\"_value\" *ngIf=\"!isStacked\"> <ng-content></ng-content> </bar> <ng-template [ngIf]=\"isStacked\"> <bar *ngFor=\"let item of _value\" [type]=\"item.type\" [value]=\"item.value\">{{ item.label }}</bar> </ng-template> ",
styles: [
"\n :host {\n width: 100%;\n display: flex;\n }\n "
]
},] },
];
/** @nocollapse */
ProgressbarComponent.ctorParameters = function () {
return [
{ type: ProgressbarConfig, },
];
};
ProgressbarComponent.propDecorators = {
'animate': [{ type: Input },],
'striped': [{ type: Input },],
'type': [{ type: Input },],
'value': [{ type: Input },],
'max': [{ type: HostBinding, args: ['attr.max',] }, { type: Input },],
'addClass': [{ type: HostBinding, args: ['class.progress',] },],
};
return ProgressbarComponent;
}());
// todo: number pipe
// todo: use query from progress?
var BarComponent = (function () {
function BarComponent(progress) {
this.percent = 0;
this.progress = progress;
}
Object.defineProperty(BarComponent.prototype, "value", {
/** current value of progress bar */
get: function () {
return this._value;
},
set: function (v) {
if (!v && v !== 0) {
return;
}
this._value = v;
this.recalculatePercentage();
},
enumerable: true,
configurable: true
});
Object.defineProperty(BarComponent.prototype, "setBarWidth", {
get: function () {
this.recalculatePercentage();
return this.percent;
},
enumerable: true,
configurable: true
});
Object.defineProperty(BarComponent.prototype, "isBs3", {
get: function () {
return isBs3();
},
enumerable: true,
configurable: true
});
BarComponent.prototype.ngOnInit = function () {
this.progress.addBar(this);
};
BarComponent.prototype.ngOnDestroy = function () {
this.progress.removeBar(this);
};
BarComponent.prototype.recalculatePercentage = function () {
this.percent = +(this.value / this.progress.max * 100).toFixed(2);
var totalPercentage = this.progress.bars
.reduce(function (total, bar) {
return total + bar.percent;
}, 0);
if (totalPercentage > 100) {
this.percent -= totalPercentage - 100;
}
};
BarComponent.decorators = [
{ type: Component, args: [{
selector: 'bar',
template: "<ng-content></ng-content> ",
host: {
role: 'progressbar',
'aria-valuemin': '0',
'[class]': '"progress-bar " + (type ? "progress-bar-" + type + " bg-" + type : "")',
'[class.progress-bar-animated]': '!isBs3 && animate',
'[class.progress-bar-striped]': 'striped',
'[class.active]': 'isBs3 && animate',
'[attr.aria-valuenow]': 'value',
'[attr.aria-valuetext]': 'percent ? percent.toFixed(0) + "%" : ""',
'[attr.aria-valuemax]': 'max',
'[style.height.%]': '"100"'
}
},] },
];
/** @nocollapse */
BarComponent.ctorParameters = function () {
return [
{ type: ProgressbarComponent, decorators: [{ type: Host },] },
];
};
BarComponent.propDecorators = {
'type': [{ type: Input },],
'value': [{ type: Input },],
'setBarWidth': [{ type: HostBinding, args: ['style.width.%',] },],
};
return BarComponent;
}());
var RATING_CONTROL_VALUE_ACCESSOR = {
provide: NG_VALUE_ACCESSOR,
// tslint:disable-next-line
useExisting: forwardRef(function () { return RatingComponent; }),
multi: true
};
var RatingComponent = (function () {
function RatingComponent(changeDetection) {
this.changeDetection = changeDetection;
/** number of icons */
this.max = 5;
/** fired when icon selected, $event:number equals to selected rating */
this.onHover = new EventEmitter();
/** fired when icon selected, $event:number equals to previous rating value */
this.onLeave = new EventEmitter();
this.onChange = Function.prototype;
this.onTouched = Function.prototype;
}
RatingComponent.prototype.onKeydown = function (event) {
if ([37, 38, 39, 40].indexOf(event.which) === -1) {
return;
}
event.preventDefault();
event.stopPropagation();
var sign = event.which === 38 || event.which === 39 ? 1 : -1;
this.rate(this.value + sign);
};
RatingComponent.prototype.ngOnInit = function () {
this.max = typeof this.max !== 'undefined' ? this.max : 5;
this.titles =
typeof this.titles !== 'undefined' && this.titles.length > 0
? this.titles
: ['one', 'two', 'three', 'four', 'five'];
this.range = this.buildTemplateObjects(this.max);
};
// model -> view
RatingComponent.prototype.writeValue = function (value) {
if (value % 1 !== value) {
this.value = Math.round(value);
this.preValue = value;
this.changeDetection.markForCheck();
return;
}
this.preValue = value;
this.value = value;
this.changeDetection.markForCheck();
};
RatingComponent.prototype.enter = function (value) {
if (!this.readonly) {
this.value = value;
this.changeDetection.markForCheck();
this.onHover.emit(value);
}
};
RatingComponent.prototype.reset = function () {
this.value = this.preValue;
this.changeDetection.markForCheck();
this.onLeave.emit(this.value);
};
RatingComponent.prototype.registerOnChange = function (fn) {
this.onChange = fn;
};
RatingComponent.prototype.registerOnTouched = function (fn) {
this.onTouched = fn;
};
RatingComponent.prototype.rate = function (value) {
if (!this.readonly && value >= 0 && value <= this.range.length) {
this.writeValue(value);
this.onChange(value);
}
};
RatingComponent.prototype.buildTemplateObjects = function (max) {
var result = [];
for (var i = 0; i < max; i++) {
result.push({
index: i,
title: this.titles[i] || i + 1
});
}
return result;
};
RatingComponent.decorators = [
{ type: Component, args: [{
selector: 'rating',
template: "<span (mouseleave)=\"reset()\" (keydown)=\"onKeydown($event)\" tabindex=\"0\" role=\"slider\" aria-valuemin=\"0\" [attr.aria-valuemax]=\"range.length\" [attr.aria-valuenow]=\"value\"> <ng-template #star let-value=\"value\" let-index=\"index\">{{index < value ? '★' : '☆'}}</ng-template> <ng-template ngFor let-r [ngForOf]=\"range\" let-index=\"index\"> <span class=\"sr-only\">({{ index < value ? '*' : ' ' }})</span> <span class=\"bs-rating-star\" (mouseenter)=\"enter(index + 1)\" (click)=\"rate(index + 1)\" [title]=\"r.title\" [style.cursor]=\"readonly ? 'default' : 'pointer'\" [class.active]=\"index < value\"> <ng-template [ngTemplateOutlet]=\"customTemplate || star\" [ngTemplateOutletContext]=\"{index: index, value: value}\"> </ng-template> </span> </ng-template> </span> ",
providers: [RATING_CONTROL_VALUE_ACCESSOR],
changeDetection: ChangeDetectionStrategy.OnPush
},] },
];
/** @nocollapse */
RatingComponent.ctorParameters = function () {
return [
{ type: ChangeDetectorRef, },
];
};
RatingComponent.propDecorators = {
'max': [{ type: Input },],
'readonly': [{ type: Input },],
'titles': [{ type: Input },],
'customTemplate': [{ type: Input },],
'onHover': [{ type: Output },],
'onLeave': [{ type: Output },],
'onKeydown': [{ type: HostListener, args: ['keydown', ['$event'],] },],
};
return RatingComponent;
}());
var DraggableItemService = (function () {
function DraggableItemService() {
this.onCapture = new Subject$1();
}
DraggableItemService.prototype.dragStart = function (item) {
this.draggableItem = item;
};
DraggableItemService.prototype.getItem = function () {
return this.draggableItem;
};
DraggableItemService.prototype.captureItem = function (overZoneIndex, newIndex) {
if (this.draggableItem.overZoneIndex !== overZoneIndex) {
this.draggableItem.lastZoneIndex = this.draggableItem.overZoneIndex;
this.draggableItem.overZoneIndex = overZoneIndex;
this.onCapture.next(this.draggableItem);
this.draggableItem = Object.assign({}, this.draggableItem, {
overZoneIndex: overZoneIndex,
i: newIndex
});
}
return this.draggableItem;
};
DraggableItemService.prototype.onCaptureItem = function () {
return this.onCapture;
};
DraggableItemService.decorators = [
{ type: Injectable },
];
/** @nocollapse */
DraggableItemService.ctorParameters = function () { return []; };
return DraggableItemService;
}());
/* tslint:disable */
/* tslint:enable */
var SortableComponent = (function () {
function SortableComponent(transfer) {
var _this = this;
/** class name for items wrapper */
this.wrapperClass = '';
/** style object for items wrapper */
this.wrapperStyle = {};
/** class name for item */
this.itemClass = '';
/** style object for item */
this.itemStyle = {};
/** class name for active item */
this.itemActiveClass = '';
/** style object for active item */
this.itemActiveStyle = {};
/** class name for placeholder */
this.placeholderClass = '';
/** style object for placeholder */
this.placeholderStyle = {};
/** placeholder item which will be shown if collection is empty */
this.placeholderItem = '';
/** fired on array change (reordering, insert, remove), same as <code>ngModelChange</code>.
* Returns new items collection as a payload.
*/
this.onChange = new EventEmitter();
this.showPlaceholder = false;
this.activeItem = -1;
this.onTouched = Function.prototype;
this.onChanged = Function.prototype;
this.transfer = transfer;
this.currentZoneIndex = SortableComponent.globalZoneIndex++;
this.transfer
.onCaptureItem()
.subscribe(function (item) { return _this.onDrop(item); });
}
Object.defineProperty(SortableComponent.prototype, "items", {
get: function () {
return this._items;
},
set: function (value) {
this._items = value;
var out = this.items.map(function (x) { return x.initData; });
this.onChanged(out);
this.onChange.emit(out);
},
enumerable: true,
configurable: true
});
SortableComponent.prototype.onItemDragstart = function (event, item, i) {
this.initDragstartEvent(event);
this.onTouched();
this.transfer.dragStart({
event: event,
item: item,
i: i,
initialIndex: i,
lastZoneIndex: this.currentZoneIndex,
overZoneIndex: this.currentZoneIndex
});
};
SortableComponent.prototype.onItemDragover = function (event, i) {
if (!this.transfer.getItem()) {
return;
}
event.preventDefault();
var dragItem = this.transfer.captureItem(this.currentZoneIndex, this.items.length);
var newArray = [];
if (!this.items.length) {
newArray = [dragItem.item];
}
else if (dragItem.i > i) {
newArray = this.items.slice(0, i).concat([
dragItem.item
], this.items.slice(i, dragItem.i), this.items.slice(dragItem.i + 1));
}
else {
// this.draggedItem.i < i
newArray = this.items.slice(0, dragItem.i).concat(this.items.slice(dragItem.i + 1, i + 1), [
dragItem.item
], this.items.slice(i + 1));
}
this.items = newArray;
dragItem.i = i;
this.activeItem = i;
this.updatePlaceholderState();
};
SortableComponent.prototype.cancelEvent = function (event) {
if (!this.transfer.getItem() || !event) {
return;
}
event.preventDefault();
};
SortableComponent.prototype.onDrop = function (item) {
if (item &&
item.overZoneIndex !== this.currentZoneIndex &&
item.lastZoneIndex === this.currentZoneIndex) {
this.items = this.items.filter(function (x, i) { return i !== item.i; });
this.updatePlaceholderState();
}
this.resetActiveItem(undefined);
};
SortableComponent.prototype.resetActiveItem = function (event) {
this.cancelEvent(event);
this.activeItem = -1;
};
SortableComponent.prototype.registerOnChange = function (callback) {
this.onChanged = callback;
};
SortableComponent.prototype.registerOnTouched = function (callback) {
this.onTouched = callback;
};
SortableComponent.prototype.writeValue = function (value) {
var _this = this;
if (value) {
this.items = value.map(function (x, i) {
return ({
id: i,
initData: x,
value: _this.fieldName ? x[_this.fieldName] : x
});
});
}
else {
this.items = [];
}
this.updatePlaceholderState();
};
SortableComponent.prototype.updatePlaceholderState = function () {
this.showPlaceholder = !this._items.length;
};
SortableComponent.prototype.getItemStyle = function (isActive) {
return isActive
? Object.assign({}, this.itemStyle, this.itemActiveStyle)
: this.itemStyle;
};
// tslint:disable-next-line
SortableComponent.prototype.initDragstartEvent = function (event) {
// it is necessary for mozilla
// data type should be 'Text' instead of 'text/plain' to keep compatibility
// with IE
event.dataTransfer.setData('Text', 'placeholder');
};
SortableComponent.globalZoneIndex = 0;
SortableComponent.decorators = [
{ type: Component, args: [{
selector: 'bs-sortable',
exportAs: 'bs-sortable',
template: "\n<div\n [ngClass]=\"wrapperClass\"\n [ngStyle]=\"wrapperStyle\"\n [ngStyle]=\"wrapperStyle\"\n (dragover)=\"cancelEvent($event)\"\n (dragenter)=\"cancelEvent($event)\"\n (drop)=\"resetActiveItem($event)\"\n (mouseleave)=\"resetActiveItem($event)\">\n <div\n *ngIf=\"showPlaceholder\"\n [ngClass]=\"placeholderClass\"\n [ngStyle]=\"placeholderStyle\"\n (dragover)=\"onItemDragover($event, 0)\"\n (dragenter)=\"cancelEvent($event)\"\n >{{placeholderItem}}</div>\n <div\n *ngFor=\"let item of items; let i=index;\"\n [ngClass]=\"[ itemClass, i === activeItem ? itemActiveClass : '' ]\"\n [ngStyle]=\"getItemStyle(i === activeItem)\"\n draggable=\"true\"\n (dragstart)=\"onItemDragstart($event, item, i)\"\n (dragend)=\"resetActiveItem($event)\"\n (dragover)=\"onItemDragover($event, i)\"\n (dragenter)=\"cancelEvent($event)\"\n ><ng-template [ngTemplateOutlet]=\"itemTemplate || defItemTemplate\"\n [ngTemplateOutletContext]=\"{item:item, index: i}\"></ng-template></div>\n</div>\n\n<ng-template #defItemTemplate let-item=\"item\">{{item.value}}</ng-template> \n",
providers: [
{
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(function () { return SortableComponent; }),
multi: true
}
]
},] },
];
/** @nocollapse */
SortableComponent.ctorParameters = function () {
return [
{ type: DraggableItemService, },
];
};
SortableComponent.propDecorators = {
'fieldName': [{ type: Input },],
'wrapperClass': [{ type: Input },],
'wrapperStyle': [{ type: Input },],
'itemClass': [{ type: Input },],
'itemStyle': [{ type: Input },],
'itemActiveClass': [{ type: Input },],
'itemActiveStyle': [{ type: Input },],
'placeholderClass': [{ type: Input },],
'placeholderStyle': [{ type: Input },],
'placeholderItem': [{ type: Input },],
'itemTemplate': [{ type: Input },],
'onChange': [{ type: Output },],
};
return SortableComponent;
}());
var NgTranscludeDirective = (function () {
function NgTranscludeDirective(viewRef) {
this.viewRef = viewRef;
}
Object.defineProperty(NgTranscludeDirective.prototype, "ngTransclude", {
get: function () {
return this._ngTransclude;
},
set: function (templateRef) {
this._ngTransclude = templateRef;
if (templateRef) {
this.viewRef.createEmbeddedView(templateRef);
}
},
enumerable: true,
configurable: true
});
NgTranscludeDirective.decorators = [
{ type: Directive, args: [{
selector: '[ngTransclude]'
},] },
];
/** @nocollapse */
NgTranscludeDirective.ctorParameters = function () {
return [
{ type: ViewContainerRef, },
];
};
NgTranscludeDirective.propDecorators = {
'ngTransclude': [{ type: Input },],
};
return NgTranscludeDirective;
}());
var TabsetConfig = (function () {
function TabsetConfig() {
/** provides default navigation context class: 'tabs' or 'pills' */
this.type = 'tabs';
}
TabsetConfig.decorators = [
{ type: Injectable },
];
/** @nocollapse */
TabsetConfig.ctorParameters = function () { return []; };
return TabsetConfig;
}());
// todo: add active event to tab
// todo: fix? mixing static and dynamic tabs position tabs in order of creation
var TabsetComponent = (function () {
function TabsetComponent(config, renderer) {
this.renderer = renderer;
this.clazz = true;
this.tabs = [];
this.classMap = {};
Object.assign(this, config);
}
Object.defineProperty(TabsetComponent.prototype, "vertical", {
/** if true tabs will be placed vertically */
get: function () {
return this._vertical;
},
set: function (value) {
this._vertical = value;
this.setClassMap();
},
enumerable: true,
configurable: true
});
Object.defineProperty(TabsetComponent.prototype, "justified", {
/** if true tabs fill the container and have a consistent width */
get: function () {
return this._justified;
},
set: function (value) {
this._justified = value;
this.setClassMap();
},
enumerable: true,
configurable: true
});
Object.defineProperty(TabsetComponent.prototype, "type", {
/** navigation context class: 'tabs' or 'pills' */
get: function () {
return this._type;
},
set: function (value) {
this._type = value;
this.setClassMap();
},
enumerable: true,
configurable: true
});
TabsetComponent.prototype.ngOnDestroy = function () {
this.isDestroyed = true;
};
TabsetComponent.prototype.addTab = function (tab) {
this.tabs.push(tab);
tab.active = this.tabs.length === 1 && typeof tab.active === 'undefined';
};
TabsetComponent.prototype.removeTab = function (tab, options) {
if (options === void 0) {
options = { reselect: true, emit: true };
}
var index = this.tabs.indexOf(tab);
if (index === -1 || this.isDestroyed) {
return;
}
// Select a new tab if the tab to be removed is selected and not destroyed
if (options.reselect && tab.active && this.hasAvailableTabs(index)) {
var newActiveIndex = this.getClosestTabIndex(index);
this.tabs[newActiveIndex].active = true;
}
if (options.emit) {
tab.removed.emit(tab);
}
this.tabs.splice(index, 1);
if (tab.elementRef.nativeElement.parentNode) {
this.renderer.removeChild(tab.elementRef.nativeElement.parentNode, tab.elementRef.nativeElement);
}
};
TabsetComponent.prototype.getClosestTabIndex = function (index) {
var tabsLength = this.tabs.length;
if (!tabsLength) {
return -1;
}
for (var step = 1; step <= tabsLength; step += 1) {
var prevIndex = index - step;
var nextIndex = index + step;
if (this.tabs[prevIndex] && !this.tabs[prevIndex].disabled) {
return prevIndex;
}
if (this.tabs[nextIndex] && !this.tabs[nextIndex].disabled) {
return nextIndex;
}
}
return -1;
};
TabsetComponent.prototype.hasAvailableTabs = function (index) {
var tabsLength = this.tabs.length;
if (!tabsLength) {
return false;
}
for (var i = 0; i < tabsLength; i += 1) {
if (!this.tabs[i].disabled && i !== index) {
return true;
}
}
return false;
};
TabsetComponent.prototype.setClassMap = function () {
this.classMap = (_a = {
'nav-stacked': this.vertical,
'flex-column': this.vertical,
'nav-justified': this.justified
}, _a["nav-" + this.type] = true, _a);
var _a;
};
TabsetComponent.decorators = [
{ type: Component, args: [{
selector: 'tabset',
template: "<ul class=\"nav\" [ngClass]=\"classMap\" (click)=\"$event.preventDefault()\"> <li *ngFor=\"let tabz of tabs\" [ngClass]=\"['nav-item', tabz.customClass || '']\" [class.active]=\"tabz.active\" [class.disabled]=\"tabz.disabled\"> <a href=\"javascript:void(0);\" class=\"nav-link\" [attr.id]=\"tabz.id ? tabz.id + '-link' : ''\" [class.active]=\"tabz.active\" [class.disabled]=\"tabz.disabled\" (click)=\"tabz.active = true\"> <span [ngTransclude]=\"tabz.headingRef\">{{ tabz.heading }}</span> <span *ngIf=\"tabz.removable\" (click)=\"$event.preventDefault(); removeTab(tabz);\" class=\"bs-remove-tab\"> ❌</span> </a> </li> </ul> <div class=\"tab-content\"> <ng-content></ng-content> </div> "
},] },
];
/** @nocollapse */
TabsetComponent.ctorParameters = function () {
return [
{ type: TabsetConfig, },
{ type: Renderer2, },
];
};
TabsetComponent.propDecorators = {
'vertical': [{ type: Input },],
'justified': [{ type: Input },],
'type': [{ type: Input },],
'clazz': [{ type: HostBinding, args: ['class.tab-container',] },],
};
return TabsetComponent;
}());
var TabDirective = (function () {
function TabDirective(tabset, elementRef, renderer) {
this.elementRef = elementRef;
this.renderer = renderer;
/** fired when tab became active, $event:Tab equals to selected instance of Tab component */
this.select = new EventEmitter();
/** fired when tab became inactive, $event:Tab equals to deselected instance of Tab component */
this.deselect = new EventEmitter();
/** fired before tab will be removed, $event:Tab equals to instance of removed tab */
this.removed = new EventEmitter();
this.addClass = true;
this.tabset = tabset;
this.tabset.addTab(this);
}
Object.defineProperty(TabDirective.prototype, "customClass", {
/** if set, will be added to the tab's class attribute. Multiple classes are supported. */
get: function () {
return this._customClass;
},
set: function (customClass) {
var _this = this;
if (this.customClass) {
this.customClass.split(' ').forEach(function (cssClass) {
_this.renderer.removeClass(_this.elementRef.nativeElement, cssClass);
});
}
this._customClass = customClass ? customClass.trim() : null;
if (this.customClass) {
this.customClass.split(' ').forEach(function (cssClass) {
_this.renderer.addClass(_this.elementRef.nativeElement, cssClass);
});
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(TabDirective.prototype, "active", {
/** tab active state toggle */
get: function () {
return this._active;
},
set: function (active) {
var _this = this;
if (this._active === active) {
return;
}
if ((this.disabled && active) || !active) {
if (this._active && !active) {
this.deselect.emit(this);
this._active = active;
}
return;
}
this._active = active;
this.select.emit(this);
this.tabset.tabs.forEach(function (tab) {
if (tab !== _this) {
tab.active = false;
}
});
},
enumerable: true,
configurable: true
});
TabDirective.prototype.ngOnInit = function () {
this.removable = this.removable;
};
TabDirective.prototype.ngOnDestroy = function () {
this.tabset.removeTab(this, { reselect: false, emit: false });
};
TabDirective.decorators = [
{ type: Directive, args: [{ selector: 'tab, [tab]' },] },
];
/** @nocollapse */
TabDirective.ctorParameters = function () {
return [
{ type: TabsetComponent, },
{ type: ElementRef, },
{ type: Renderer2, },
];
};
TabDirective.propDecorators = {
'heading': [{ type: Input },],
'id': [{ type: HostBinding, args: ['attr.id',] }, { type: Input },],
'disabled': [{ type: Input },],
'removable': [{ type: Input },],
'customClass': [{ type: Input },],
'active': [{ type: HostBinding, args: ['class.active',] }, { type: Input },],
'select': [{ type: Output },],
'deselect': [{ type: Output },],
'removed': [{ type: Output },],
'addClass': [{ type: HostBinding, args: ['class.tab-pane',] },],
};
return TabDirective;
}());
var TimepickerActions = (function () {
function TimepickerActions() {
}
TimepickerActions.prototype.writeValue = function (value) {
return {
type: TimepickerActions.WRITE_VALUE,
payload: value
};
};
TimepickerActions.prototype.changeHours = function (event) {
return {
type: TimepickerActions.CHANGE_HOURS,
payload: event
};
};
TimepickerActions.prototype.changeMinutes = function (event) {
return {
type: TimepickerActions.CHANGE_MINUTES,
payload: event
};
};
TimepickerActions.prototype.changeSeconds = function (event) {
return {
type: TimepickerActions.CHANGE_SECONDS,
payload: event
};
};
TimepickerActions.prototype.setTime = function (value) {
return {
type: TimepickerActions.SET_TIME_UNIT,
payload: value
};
};
TimepickerActions.prototype.updateControls = function (value) {
return {
type: TimepickerActions.UPDATE_CONTROLS,
payload: value
};
};
TimepickerActions.WRITE_VALUE = '[timepicker] write value from ng model';
TimepickerActions.CHANGE_HOURS = '[timepicker] change hours';
TimepickerActions.CHANGE_MINUTES = '[timepicker] change minutes';
TimepickerActions.CHANGE_SECONDS = '[timepicker] change seconds';
TimepickerActions.SET_TIME_UNIT = '[timepicker] set time unit';
TimepickerActions.UPDATE_CONTROLS = '[timepicker] update controls';
TimepickerActions.decorators = [
{ type: Injectable },
];
/** @nocollapse */
TimepickerActions.ctorParameters = function () { return []; };
return TimepickerActions;
}());
var dex = 10;
var hoursPerDay = 24;
var hoursPerDayHalf = 12;
var minutesPerHour = 60;
var secondsPerMinute = 60;
function isValidDate(value) {
if (!value) {
return false;
}
if (value instanceof Date && isNaN(value.getHours())) {
return false;
}
if (typeof value === 'string') {
return isValidDate(new Date(value));
}
return true;
}
function isValidLimit(controls, newDate) {
if (controls.min && newDate < controls.min) {
return false;
}
if (controls.max && newDate > controls.max) {
return false;
}
return true;
}
function toNumber(value) {
if (typeof value === 'number') {
return value;
}
return parseInt(value, dex);
}
function parseHours(value, isPM) {
if (isPM === void 0) {
isPM = false;
}
var hour = toNumber(value);
if (isNaN(hour) ||
hour < 0 ||
hour > (isPM ? hoursPerDayHalf : hoursPerDay)) {
return NaN;
}
return hour;
}
function parseMinutes(value) {
var minute = toNumber(value);
if (isNaN(minute) || minute < 0 || minute > minutesPerHour) {
return NaN;
}
return minute;
}
function parseSeconds(value) {
var seconds = toNumber(value);
if (isNaN(seconds) || seconds < 0 || seconds > secondsPerMinute) {
return NaN;
}
return seconds;
}
function parseTime(value) {
if (typeof value === 'string') {
return new Date(value);
}
return value;
}
function changeTime(value, diff) {
if (!value) {
return changeTime(createDate$1(new Date(), 0, 0, 0), diff);
}
var hour = value.getHours();
var minutes = value.getMinutes();
var seconds = value.getSeconds();
if (diff.hour) {
hour = (hour + toNumber(diff.hour)) % hoursPerDay;
if (hour < 0) {
hour += hoursPerDay;
}
}
if (diff.minute) {
minutes = minutes + toNumber(diff.minute);
}
if (diff.seconds) {
seconds = seconds + toNumber(diff.seconds);
}
return createDate$1(value, hour, minutes, seconds);
}
function setTime$1(value, opts) {
var hour = parseHours(opts.hour);
var minute = parseMinutes(opts.minute);
var seconds = parseSeconds(opts.seconds) || 0;
if (opts.isPM) {
hour += hoursPerDayHalf;
}
if (!value) {
if (!isNaN(hour) && !isNaN(minute)) {
return createDate$1(new Date(), hour, minute, seconds);
}
return value;
}
if (isNaN(hour) || isNaN(minute)) {
return value;
}
return createDate$1(value, hour, minute, seconds);
}
function createDate$1(value, hours, minutes, seconds) {
return new Date(value.getFullYear(), value.getMonth(), value.getDate(), hours, minutes, seconds, value.getMilliseconds());
}
function padNumber(value) {
var _value = value.toString();
if (_value.length > 1) {
return _value;
}
return "0" + _value;
}
function isHourInputValid(hours, isPM) {
return !isNaN(parseHours(hours, isPM));
}
function isMinuteInputValid(minutes) {
return !isNaN(parseMinutes(minutes));
}
function isSecondInputValid(seconds) {
return !isNaN(parseSeconds(seconds));
}
function isInputLimitValid(diff, max, min) {
var newDate = changeTime(new Date(), diff);
if (max && newDate > max) {
return false;
}
if (min && newDate < min) {
return false;
}
return true;
}
function isInputValid(hours, minutes, seconds, isPM) {
if (minutes === void 0) {
minutes = '0';
}
if (seconds === void 0) {
seconds = '0';
}
return isHourInputValid(hours, isPM)
&& isMinuteInputValid(minutes)
&& isSecondInputValid(seconds);
}
function canChangeValue(state, event) {
if (state.readonlyInput || state.disabled) {
return false;
}
if (event) {
if (event.source === 'wheel' && !state.mousewheel) {
return false;
}
if (event.source === 'key' && !state.arrowkeys) {
return false;
}
}
return true;
}
function canChangeHours(event, controls) {
if (!event.step) {
return false;
}
if (event.step > 0 && !controls.canIncrementHours) {
return false;
}
if (event.step < 0 && !controls.canDecrementHours) {
return false;
}
return true;
}
function canChangeMinutes(event, controls) {
if (!event.step) {
return false;
}
if (event.step > 0 && !controls.canIncrementMinutes) {
return false;
}
if (event.step < 0 && !controls.canDecrementMinutes) {
return false;
}
return true;
}
function canChangeSeconds(event, controls) {
if (!event.step) {
return false;
}
if (event.step > 0 && !controls.canIncrementSeconds) {
return false;
}
if (event.step < 0 && !controls.canDecrementSeconds) {
return false;
}
return true;
}
function getControlsValue(state) {
var hourStep = state.hourStep, minuteStep = state.minuteStep, secondsStep = state.secondsStep, readonlyInput = state.readonlyInput, disabled = state.disabled, mousewheel = state.mousewheel, arrowkeys = state.arrowkeys, showSpinners = state.showSpinners, showMeridian = state.showMeridian, showSeconds = state.showSeconds, meridians = state.meridians, min = state.min, max = state.max;
return {
hourStep: hourStep,
minuteStep: minuteStep,
secondsStep: secondsStep,
readonlyInput: readonlyInput,
disabled: disabled,
mousewheel: mousewheel,
arrowkeys: arrowkeys,
showSpinners: showSpinners,
showMeridian: showMeridian,
showSeconds: showSeconds,
meridians: meridians,
min: min,
max: max
};
}
function timepickerControls(value, state) {
var hoursPerDayHalf = 12;
var min = state.min, max = state.max, hourStep = state.hourStep, minuteStep = state.minuteStep, secondsStep = state.secondsStep, showSeconds = state.showSeconds;
var res = {
canIncrementHours: true,
canIncrementMinutes: true,
canIncrementSeconds: true,
canDecrementHours: true,
canDecrementMinutes: true,
canDecrementSeconds: true,
canToggleMeridian: true
};
if (!value) {
return res;
}
// compare dates
if (max) {
var _newHour = changeTime(value, { hour: hourStep });
res.canIncrementHours = max > _newHour;
if (!res.canIncrementHours) {
var _newMinutes = changeTime(value, { minute: minuteStep });
res.canIncrementMinutes = showSeconds
? max > _newMinutes
: max >= _newMinutes;
}
if (!res.canIncrementMinutes) {
var _newSeconds = changeTime(value, { seconds: secondsStep });
res.canIncrementSeconds = max >= _newSeconds;
}
if (value.getHours() < hoursPerDayHalf) {
res.canToggleMeridian = changeTime(value, { hour: hoursPerDayHalf }) < max;
}
}
if (min) {
var _newHour = changeTime(value, { hour: -hourStep });
res.canDecrementHours = min < _newHour;
if (!res.canDecrementHours) {
var _newMinutes = changeTime(value, { minute: -minuteStep });
res.canDecrementMinutes = showSeconds
? min < _newMinutes
: min <= _newMinutes;
}
if (!res.canDecrementMinutes) {
var _newSeconds = changeTime(value, { seconds: -secondsStep });
res.canDecrementSeconds = min <= _newSeconds;
}
if (value.getHours() >= hoursPerDayHalf) {
res.canToggleMeridian = changeTime(value, { hour: -hoursPerDayHalf }) > min;
}
}
return res;
}
/** Provides default configuration values for timepicker */
var TimepickerConfig = (function () {
function TimepickerConfig() {
/** hours change step */
this.hourStep = 1;
/** hours change step */
this.minuteStep = 5;
/** seconds changes step */
this.secondsStep = 10;
/** if true works in 12H mode and displays AM/PM. If false works in 24H mode and hides AM/PM */
this.showMeridian = true;
/** meridian labels based on locale */
this.meridians = ['AM', 'PM'];
/** if true hours and minutes fields will be readonly */
this.readonlyInput = false;
/** if true hours and minutes fields will be disabled */
this.disabled = false;
/** if true scroll inside hours and minutes inputs will change time */
this.mousewheel = true;
/** if true up/down arrowkeys inside hours and minutes inputs will change time */
this.arrowkeys = true;
/** if true spinner arrows above and below the inputs will be shown */
this.showSpinners = true;
/** show seconds in timepicker */
this.showSeconds = false;
/** show minutes in timepicker */
this.showMinutes = true;
}
TimepickerConfig.decorators = [
{ type: Injectable },
];
/** @nocollapse */
TimepickerConfig.ctorParameters = function () { return []; };
return TimepickerConfig;
}());
var initialState = {
value: null,
config: new TimepickerConfig(),
controls: {
canIncrementHours: true,
canIncrementMinutes: true,
canIncrementSeconds: true,
canDecrementHours: true,
canDecrementMinutes: true,
canDecrementSeconds: true,
canToggleMeridian: true
}
};
function timepickerReducer(state, action) {
if (state === void 0) {
state = initialState;
}
switch (action.type) {
case TimepickerActions.WRITE_VALUE: {
return Object.assign({}, state, { value: action.payload });
}
case TimepickerActions.CHANGE_HOURS: {
if (!canChangeValue(state.config, action.payload) ||
!canChangeHours(action.payload, state.controls)) {
return state;
}
var _newTime = changeTime(state.value, { hour: action.payload.step });
if ((state.config.max || state.config.min) && !isValidLimit(state.config, _newTime)) {
return state;
}
return Object.assign({}, state, { value: _newTime });
}
case TimepickerActions.CHANGE_MINUTES: {
if (!canChangeValue(state.config, action.payload) ||
!canChangeMinutes(action.payload, state.controls)) {
return state;
}
var _newTime = changeTime(state.value, { minute: action.payload.step });
if ((state.config.max || state.config.min) && !isValidLimit(state.config, _newTime)) {
return state;
}
return Object.assign({}, state, { value: _newTime });
}
case TimepickerActions.CHANGE_SECONDS: {
if (!canChangeValue(state.config, action.payload) ||
!canChangeSeconds(action.payload, state.controls)) {
return state;
}
var _newTime = changeTime(state.value, {
seconds: action.payload.step
});
if ((state.config.max || state.config.min) && !isValidLimit(state.config, _newTime)) {
return state;
}
return Object.assign({}, state, { value: _newTime });
}
case TimepickerActions.SET_TIME_UNIT: {
if (!canChangeValue(state.config)) {
return state;
}
var _newTime = setTime$1(state.value, action.payload);
return Object.assign({}, state, { value: _newTime });
}
case TimepickerActions.UPDATE_CONTROLS: {
var _newControlsState = timepickerControls(state.value, action.payload);
var _newState = {
value: state.value,
config: action.payload,
controls: _newControlsState
};
if (state.config.showMeridian !== _newState.config.showMeridian) {
if (state.value) {
_newState.value = new Date(state.value);
}
}
return Object.assign({}, state, _newState);
}
default:
return state;
}
}
var __extends$12 = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b)
if (b.hasOwnProperty(p))
d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var TimepickerStore = (function (_super) {
__extends$12(TimepickerStore, _super);
function TimepickerStore() {
var _this = this;
var _dispatcher = new BehaviorSubject$1({
type: '[mini-ngrx] dispatcher init'
});
var state = new MiniState(initialState, _dispatcher, timepickerReducer);
_this = _super.call(this, _dispatcher, timepickerReducer, state) || this;
return _this;
}
TimepickerStore.decorators = [
{ type: Injectable },
];
/** @nocollapse */
TimepickerStore.ctorParameters = function () { return []; };
return TimepickerStore;
}(MiniStore));
/* tslint:disable:no-forward-ref max-file-line-count */
var TIMEPICKER_CONTROL_VALUE_ACCESSOR = {
provide: NG_VALUE_ACCESSOR,
// tslint:disable-next-line
useExisting: forwardRef(function () { return TimepickerComponent; }),
multi: true
};
var TimepickerComponent = (function () {
function TimepickerComponent(_config, _cd, _store, _timepickerActions) {
var _this = this;
this._store = _store;
this._timepickerActions = _timepickerActions;
/** emits true if value is a valid date */
this.isValid = new EventEmitter();
// min\max validation for input fields
this.invalidHours = false;
this.invalidMinutes = false;
this.invalidSeconds = false;
// control value accessor methods
this.onChange = Function.prototype;
this.onTouched = Function.prototype;
Object.assign(this, _config);
this.timepickerSub = _store.select(function (state) { return state.value; }).subscribe(function (value) {
// update UI values if date changed
_this._renderTime(value);
_this.onChange(value);
_this._store.dispatch(_this._timepickerActions.updateControls(getControlsValue(_this)));
});
_store.select(function (state) { return state.controls; }).subscribe(function (controlsState) {
_this.isValid.emit(isInputValid(_this.hours, _this.minutes, _this.seconds, _this.isPM()));
Object.assign(_this, controlsState);
_cd.markForCheck();
});
}
Object.defineProperty(TimepickerComponent.prototype, "isSpinnersVisible", {
/** @deprecated - please use `isEditable` instead */
get: function () {
return this.showSpinners && !this.readonlyInput;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TimepickerComponent.prototype, "isEditable", {
get: function () {
return !(this.readonlyInput || this.disabled);
},
enumerable: true,
configurable: true
});
TimepickerComponent.prototype.resetValidation = function () {
this.invalidHours = false;
this.invalidMinutes = false;
this.invalidSeconds = false;
};
TimepickerComponent.prototype.isPM = function () {
return this.showMeridian && this.meridian === this.meridians[1];
};
TimepickerComponent.prototype.prevDef = function ($event) {
$event.preventDefault();
};
TimepickerComponent.prototype.wheelSign = function ($event) {
return Math.sign($event.deltaY) * -1;
};
TimepickerComponent.prototype.ngOnChanges = function (changes) {
this._store.dispatch(this._timepickerActions.updateControls(getControlsValue(this)));
};
TimepickerComponent.prototype.changeHours = function (step, source) {
if (source === void 0) {
source = '';
}
this.resetValidation();
this._store.dispatch(this._timepickerActions.changeHours({ step: step, source: source }));
};
TimepickerComponent.prototype.changeMinutes = function (step, source) {
if (source === void 0) {
source = '';
}
this.resetValidation();
this._store.dispatch(this._timepickerActions.changeMinutes({ step: step, source: source }));
};
TimepickerComponent.prototype.changeSeconds = function (step, source) {
if (source === void 0) {
source = '';
}
this.resetValidation();
this._store.dispatch(this._timepickerActions.changeSeconds({ step: step, source: source }));
};
TimepickerComponent.prototype.updateHours = function (hours) {
this.resetValidation();
this.hours = hours;
var isValid = isHourInputValid(this.hours, this.isPM()) && this.isValidLimit();
if (!isValid) {
this.invalidHours = true;
this.isValid.emit(false);
this.onChange(null);
return;
}
this._updateTime();
};
TimepickerComponent.prototype.updateMinutes = function (minutes) {
this.resetValidation();
this.minutes = minutes;
var isValid = isMinuteInputValid(this.minutes) && this.isValidLimit();
if (!isValid) {
this.invalidMinutes = true;
this.isValid.emit(false);
this.onChange(null);
return;
}
this._updateTime();
};
TimepickerComponent.prototype.updateSeconds = function (seconds) {
this.resetValidation();
this.seconds = seconds;
var isValid = isSecondInputValid(this.seconds) && this.isValidLimit();
if (!isValid) {
this.invalidSeconds = true;
this.isValid.emit(false);
this.onChange(null);
return;
}
this._updateTime();
};
TimepickerComponent.prototype.isValidLimit = function () {
return isInputLimitValid({
hour: this.hours,
minute: this.minutes,
seconds: this.seconds,
isPM: this.isPM()
}, this.max, this.min);
};
TimepickerComponent.prototype._updateTime = function () {
var _seconds = this.showSeconds ? this.seconds : void 0;
var _minutes = this.showMinutes ? this.minutes : void 0;
if (!isInputValid(this.hours, _minutes, _seconds, this.isPM())) {
this.isValid.emit(false);
this.onChange(null);
return;
}
this._store.dispatch(this._timepickerActions.setTime({
hour: this.hours,
minute: this.minutes,
seconds: this.seconds,
isPM: this.isPM()
}));
};
TimepickerComponent.prototype.toggleMeridian = function () {
if (!this.showMeridian || !this.isEditable) {
return;
}
var _hoursPerDayHalf = 12;
this._store.dispatch(this._timepickerActions.changeHours({
step: _hoursPerDayHalf,
source: ''
}));
};
/**
* Write a new value to the element.
*/
TimepickerComponent.prototype.writeValue = function (obj) {
if (isValidDate(obj)) {
this._store.dispatch(this._timepickerActions.writeValue(parseTime(obj)));
}
else if (obj == null) {
this._store.dispatch(this._timepickerActions.writeValue(null));
}
};
/**
* Set the function to be called when the control receives a change event.
*/
TimepickerComponent.prototype.registerOnChange = function (fn) {
this.onChange = fn;
};
/**
* Set the function to be called when the control receives a touch event.
*/
TimepickerComponent.prototype.registerOnTouched = function (fn) {
this.onTouched = fn;
};
/**
* This function is called when the control status changes to or from "disabled".
* Depending on the value, it will enable or disable the appropriate DOM element.
*
* @param isDisabled
*/
TimepickerComponent.prototype.setDisabledState = function (isDisabled) {
this.disabled = isDisabled;
};
TimepickerComponent.prototype.ngOnDestroy = function () {
this.timepickerSub.unsubscribe();
};
TimepickerComponent.prototype._renderTime = function (value) {
if (!isValidDate(value)) {
this.hours = '';
this.minutes = '';
this.seconds = '';
this.meridian = this.meridians[0];
return;
}
var _value = parseTime(value);
var _hoursPerDayHalf = 12;
var _hours = _value.getHours();
if (this.showMeridian) {
this.meridian = this.meridians[_hours >= _hoursPerDayHalf ? 1 : 0];
_hours = _hours % _hoursPerDayHalf;
// should be 12 PM, not 00 PM
if (_hours === 0) {
_hours = _hoursPerDayHalf;
}
}
this.hours = padNumber(_hours);
this.minutes = padNumber(_value.getMinutes());
this.seconds = padNumber(_value.getUTCSeconds());
};
TimepickerComponent.decorators = [
{ type: Component, args: [{
selector: 'timepicker',
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [TIMEPICKER_CONTROL_VALUE_ACCESSOR, TimepickerStore],
template: "<table> <tbody> <tr class=\"text-center\" [class.hidden]=\"!showSpinners\"> <!-- increment hours button--> <td> <a class=\"btn btn-link\" [class.disabled]=\"!canIncrementHours || !isEditable\" (click)=\"changeHours(hourStep)\" ><span class=\"bs-chevron bs-chevron-up\"></span></a> </td> <!-- divider --> <td *ngIf=\"showMinutes\"> </td> <!-- increment minutes button --> <td *ngIf=\"showMinutes\"> <a class=\"btn btn-link\" [class.disabled]=\"!canIncrementMinutes || !isEditable\" (click)=\"changeMinutes(minuteStep)\" ><span class=\"bs-chevron bs-chevron-up\"></span></a> </td> <!-- divider --> <td *ngIf=\"showSeconds\"> </td> <!-- increment seconds button --> <td *ngIf=\"showSeconds\"> <a class=\"btn btn-link\" [class.disabled]=\"!canIncrementSeconds || !isEditable\" (click)=\"changeSeconds(secondsStep)\"> <span class=\"bs-chevron bs-chevron-up\"></span> </a> </td> <!-- space between --> <td *ngIf=\"showMeridian\"> </td> <!-- meridian placeholder--> <td *ngIf=\"showMeridian\"></td> </tr> <tr> <!-- hours --> <td class=\"form-group\" [class.has-error]=\"invalidHours\"> <input type=\"text\" [class.is-invalid]=\"invalidHours\" class=\"form-control text-center bs-timepicker-field\" placeholder=\"HH\" maxlength=\"2\" [readonly]=\"readonlyInput\" [disabled]=\"disabled\" [value]=\"hours\" (wheel)=\"prevDef($event);changeHours(hourStep * wheelSign($event), 'wheel')\" (keydown.ArrowUp)=\"changeHours(hourStep, 'key')\" (keydown.ArrowDown)=\"changeHours(-hourStep, 'key')\" (change)=\"updateHours($event.target.value)\"></td> <!-- divider --> <td *ngIf=\"showMinutes\"> : </td> <!-- minutes --> <td class=\"form-group\" *ngIf=\"showMinutes\" [class.has-error]=\"invalidMinutes\"> <input type=\"text\" [class.is-invalid]=\"invalidMinutes\" class=\"form-control text-center bs-timepicker-field\" placeholder=\"MM\" maxlength=\"2\" [readonly]=\"readonlyInput\" [disabled]=\"disabled\" [value]=\"minutes\" (wheel)=\"prevDef($event);changeMinutes(minuteStep * wheelSign($event), 'wheel')\" (keydown.ArrowUp)=\"changeMinutes(minuteStep, 'key')\" (keydown.ArrowDown)=\"changeMinutes(-minuteStep, 'key')\" (change)=\"updateMinutes($event.target.value)\"> </td> <!-- divider --> <td *ngIf=\"showSeconds\"> : </td> <!-- seconds --> <td class=\"form-group\" *ngIf=\"showSeconds\" [class.has-error]=\"invalidSeconds\"> <input type=\"text\" [class.is-invalid]=\"invalidSeconds\" class=\"form-control text-center bs-timepicker-field\" placeholder=\"SS\" maxlength=\"2\" [readonly]=\"readonlyInput\" [disabled]=\"disabled\" [value]=\"seconds\" (wheel)=\"prevDef($event);changeSeconds(secondsStep * wheelSign($event), 'wheel')\" (keydown.ArrowUp)=\"changeSeconds(secondsStep, 'key')\" (keydown.ArrowDown)=\"changeSeconds(-secondsStep, 'key')\" (change)=\"updateSeconds($event.target.value)\"> </td> <!-- space between --> <td *ngIf=\"showMeridian\"> </td> <!-- meridian --> <td *ngIf=\"showMeridian\"> <button type=\"button\" class=\"btn btn-default text-center\" [disabled]=\"!isEditable || !canToggleMeridian\" [class.disabled]=\"!isEditable || !canToggleMeridian\" (click)=\"toggleMeridian()\" >{{ meridian }} </button> </td> </tr> <tr class=\"text-center\" [class.hidden]=\"!showSpinners\"> <!-- decrement hours button--> <td> <a class=\"btn btn-link\" [class.disabled]=\"!canDecrementHours || !isEditable\" (click)=\"changeHours(-hourStep)\"> <span class=\"bs-chevron bs-chevron-down\"></span> </a> </td> <!-- divider --> <td *ngIf=\"showMinutes\"> </td> <!-- decrement minutes button--> <td *ngIf=\"showMinutes\"> <a class=\"btn btn-link\" [class.disabled]=\"!canDecrementMinutes || !isEditable\" (click)=\"changeMinutes(-minuteStep)\"> <span class=\"bs-chevron bs-chevron-down\"></span> </a> </td> <!-- divider --> <td *ngIf=\"showSeconds\"> </td> <!-- decrement seconds button--> <td *ngIf=\"showSeconds\"> <a class=\"btn btn-link\" [class.disabled]=\"!canDecrementSeconds || !isEditable\" (click)=\"changeSeconds(-secondsStep)\"> <span class=\"bs-chevron bs-chevron-down\"></span> </a> </td> <!-- space between --> <td *ngIf=\"showMeridian\"> </td> <!-- meridian placeholder--> <td *ngIf=\"showMeridian\"></td> </tr> </tbody> </table> ",
styles: ["\n .bs-chevron{\n border-style: solid;\n display: block;\n width: 9px;\n height: 9px;\n position: relative;\n border-width: 3px 0px 0 3px;\n }\n .bs-chevron-up{\n -webkit-transform: rotate(45deg);\n transform: rotate(45deg);\n top: 2px;\n }\n .bs-chevron-down{\n -webkit-transform: rotate(-135deg);\n transform: rotate(-135deg);\n top: -2px;\n }\n .bs-timepicker-field{\n width: 50px;\n }\n "],
encapsulation: ViewEncapsulation.None
},] },
];
/** @nocollapse */
TimepickerComponent.ctorParameters = function () {
return [
{ type: TimepickerConfig, },
{ type: ChangeDetectorRef, },
{ type: TimepickerStore, },
{ type: TimepickerActions, },
];
};
TimepickerComponent.propDecorators = {
'hourStep': [{ type: Input },],
'minuteStep': [{ type: Input },],
'secondsStep': [{ type: Input },],
'readonlyInput': [{ type: Input },],
'disabled': [{ type: Input },],
'mousewheel': [{ type: Input },],
'arrowkeys': [{ type: Input },],
'showSpinners': [{ type: Input },],
'showMeridian': [{ type: Input },],
'showMinutes': [{ type: Input },],
'showSeconds': [{ type: Input },],
'meridians': [{ type: Input },],
'min': [{ type: Input },],
'max': [{ type: Input },],
'isValid': [{ type: Output },],
};
return TimepickerComponent;
}());
/** Default values provider for tooltip */
var TooltipConfig = (function () {
function TooltipConfig() {
/** tooltip placement, supported positions: 'top', 'bottom', 'left', 'right' */
this.placement = 'top';
/** array of event names which triggers tooltip opening */
this.triggers = 'hover focus';
}
TooltipConfig.decorators = [
{ type: Injectable },
];
/** @nocollapse */
TooltipConfig.ctorParameters = function () { return []; };
return TooltipConfig;
}());
var TooltipContainerComponent = (function () {
function TooltipContainerComponent(config) {
Object.assign(this, config);
}
Object.defineProperty(TooltipContainerComponent.prototype, "isBs3", {
get: function () {
return isBs3();
},
enumerable: true,
configurable: true
});
TooltipContainerComponent.prototype.ngAfterViewInit = function () {
this.classMap = { in: false, fade: false };
this.classMap[this.placement] = true;
this.classMap["tooltip-" + this.placement] = true;
this.classMap.in = true;
if (this.animation) {
this.classMap.fade = true;
}
if (this.containerClass) {
this.classMap[this.containerClass] = true;
}
};
TooltipContainerComponent.decorators = [
{ type: Component, args: [{
selector: 'bs-tooltip-container',
changeDetection: ChangeDetectionStrategy.OnPush,
// tslint:disable-next-line
host: {
'[class]': '"tooltip in tooltip-" + placement + " " + "bs-tooltip-" + placement + " " + placement + " " + containerClass',
'[class.show]': '!isBs3',
role: 'tooltip'
},
styles: [
"\n :host.tooltip {\n display: block;\n }\n :host.bs-tooltip-top .arrow, :host.bs-tooltip-bottom .arrow {\n left: 50%;\n margin-left: -6px;\n }\n :host.bs-tooltip-left .arrow, :host.bs-tooltip-right .arrow {\n top: 50%;\n margin-top: -6px;\n }\n "
],
template: "\n <div class=\"tooltip-arrow arrow\"></div>\n <div class=\"tooltip-inner\"><ng-content></ng-content></div>\n "
},] },
];
/** @nocollapse */
TooltipContainerComponent.ctorParameters = function () {
return [
{ type: TooltipConfig, },
];
};
return TooltipContainerComponent;
}());
var __decorate$1 = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r = Reflect.decorate(decorators, target, key, desc);
else
for (var i = decorators.length - 1; i >= 0; i--)
if (d = decorators[i])
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata$1 = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
return Reflect.metadata(k, v);
};
// tslint:disable:deprecation
var TooltipDirective = (function () {
function TooltipDirective(_viewContainerRef, _renderer, _elementRef, cis, config) {
this._renderer = _renderer;
this._elementRef = _elementRef;
/** Fired when tooltip content changes */
this.tooltipChange = new EventEmitter();
/**
* Css class for tooltip container
*/
this.containerClass = '';
/** @deprecated - removed, will be added to configuration */
this._animation = true;
/** @deprecated */
this._fadeDuration = 150;
/** @deprecated */
this.tooltipStateChanged = new EventEmitter();
this._tooltip = cis
.createLoader(this._elementRef, _viewContainerRef, this._renderer)
.provide({ provide: TooltipConfig, useValue: config });
Object.assign(this, config);
this.onShown = this._tooltip.onShown;
this.onHidden = this._tooltip.onHidden;
}
Object.defineProperty(TooltipDirective.prototype, "isOpen", {
/**
* Returns whether or not the tooltip is currently being shown
*/
get: function () {
return this._tooltip.isShown;
},
set: function (value) {
if (value) {
this.show();
}
else {
this.hide();
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(TooltipDirective.prototype, "htmlContent", {
/** @deprecated - please use `tooltip` instead */
set: function (value) {
warnOnce('tooltipHtml was deprecated, please use `tooltip` instead');
this.tooltip = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TooltipDirective.prototype, "_placement", {
/** @deprecated - please use `placement` instead */
set: function (value) {
warnOnce('tooltipPlacement was deprecated, please use `placement` instead');
this.placement = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TooltipDirective.prototype, "_isOpen", {
get: function () {
warnOnce('tooltipIsOpen was deprecated, please use `isOpen` instead');
return this.isOpen;
},
/** @deprecated - please use `isOpen` instead*/
set: function (value) {
warnOnce('tooltipIsOpen was deprecated, please use `isOpen` instead');
this.isOpen = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TooltipDirective.prototype, "_enable", {
get: function () {
warnOnce('tooltipEnable was deprecated, please use `isDisabled` instead');
return this.isDisabled;
},
/** @deprecated - please use `isDisabled` instead */
set: function (value) {
warnOnce('tooltipEnable was deprecated, please use `isDisabled` instead');
this.isDisabled = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TooltipDirective.prototype, "_appendToBody", {
get: function () {
warnOnce('tooltipAppendToBody was deprecated, please use `container="body"` instead');
return this.container === 'body';
},
/** @deprecated - please use `container="body"` instead */
set: function (value) {
warnOnce('tooltipAppendToBody was deprecated, please use `container="body"` instead');
this.container = value ? 'body' : this.container;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TooltipDirective.prototype, "_popupClass", {
/** @deprecated - will replaced with customClass */
set: function (value) {
warnOnce('tooltipClass deprecated');
},
enumerable: true,
configurable: true
});
Object.defineProperty(TooltipDirective.prototype, "_tooltipContext", {
/** @deprecated - removed */
set: function (value) {
warnOnce('tooltipContext deprecated');
},
enumerable: true,
configurable: true
});
Object.defineProperty(TooltipDirective.prototype, "_tooltipPopupDelay", {
/** @deprecated */
set: function (value) {
warnOnce('tooltipPopupDelay is deprecated, use `delay` instead');
this.delay = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TooltipDirective.prototype, "_tooltipTrigger", {
/** @deprecated - please use `triggers` instead */
get: function () {
warnOnce('tooltipTrigger was deprecated, please use `triggers` instead');
return this.triggers;
},
set: function (value) {
warnOnce('tooltipTrigger was deprecated, please use `triggers` instead');
this.triggers = (value || '').toString();
},
enumerable: true,
configurable: true
});
TooltipDirective.prototype.ngOnInit = function () {
var _this = this;
this._tooltip.listen({
triggers: this.triggers,
show: function () { return _this.show(); }
});
this.tooltipChange.subscribe(function (value) {
if (!value) {
_this._tooltip.hide();
}
});
};
/**
* Toggles an element’s tooltip. This is considered a “manual” triggering of
* the tooltip.
*/
TooltipDirective.prototype.toggle = function () {
if (this.isOpen) {
return this.hide();
}
this.show();
};
/**
* Opens an element’s tooltip. This is considered a “manual” triggering of
* the tooltip.
*/
TooltipDirective.prototype.show = function () {
var _this = this;
if (this.isOpen ||
this.isDisabled ||
this._delayTimeoutId ||
!this.tooltip) {
return;
}
var showTooltip = function () {
if (_this._delayTimeoutId) {
_this._delayTimeoutId = undefined;
}
_this._tooltip
.attach(TooltipContainerComponent)
.to(_this.container)
.position({ attachment: _this.placement })
.show({
content: _this.tooltip,
placement: _this.placement,
containerClass: _this.containerClass
});
};
var cancelDelayedTooltipShowing = function () {
if (_this._tooltipCancelShowFn) {
_this._tooltipCancelShowFn();
}
};
if (this.delay) {
var timer_1 = Observable$1.timer(this.delay).subscribe(function () {
showTooltip();
cancelDelayedTooltipShowing();
});
if (this.triggers) {
var triggers = parseTriggers(this.triggers);
this._tooltipCancelShowFn = this._renderer.listen(this._elementRef.nativeElement, triggers[0].close, function () {
timer_1.unsubscribe();
cancelDelayedTooltipShowing();
});
}
}
else {
showTooltip();
}
};
/**
* Closes an element’s tooltip. This is considered a “manual” triggering of
* the tooltip.
*/
TooltipDirective.prototype.hide = function () {
var _this = this;
if (this._delayTimeoutId) {
clearTimeout(this._delayTimeoutId);
this._delayTimeoutId = undefined;
}
if (!this._tooltip.isShown) {
return;
}
this._tooltip.instance.classMap.in = false;
setTimeout(function () {
_this._tooltip.hide();
}, this._fadeDuration);
};
TooltipDirective.prototype.ngOnDestroy = function () {
this._tooltip.dispose();
};
TooltipDirective.decorators = [
{ type: Directive, args: [{
selector: '[tooltip], [tooltipHtml]',
exportAs: 'bs-tooltip'
},] },
];
/** @nocollapse */
TooltipDirective.ctorParameters = function () {
return [
{ type: ViewContainerRef, },
{ type: Renderer2, },
{ type: ElementRef, },
{ type: ComponentLoaderFactory, },
{ type: TooltipConfig, },
];
};
TooltipDirective.propDecorators = {
'tooltip': [{ type: Input },],
'tooltipChange': [{ type: Output },],
'placement': [{ type: Input },],
'triggers': [{ type: Input },],
'container': [{ type: Input },],
'isOpen': [{ type: Input },],
'isDisabled': [{ type: Input },],
'containerClass': [{ type: Input },],
'delay': [{ type: Input },],
'onShown': [{ type: Output },],
'onHidden': [{ type: Output },],
'htmlContent': [{ type: Input, args: ['tooltipHtml',] },],
'_placement': [{ type: Input, args: ['tooltipPlacement',] },],
'_isOpen': [{ type: Input, args: ['tooltipIsOpen',] },],
'_enable': [{ type: Input, args: ['tooltipEnable',] },],
'_appendToBody': [{ type: Input, args: ['tooltipAppendToBody',] },],
'_animation': [{ type: Input, args: ['tooltipAnimation',] },],
'_popupClass': [{ type: Input, args: ['tooltipClass',] },],
'_tooltipContext': [{ type: Input, args: ['tooltipContext',] },],
'_tooltipPopupDelay': [{ type: Input, args: ['tooltipPopupDelay',] },],
'_fadeDuration': [{ type: Input, args: ['tooltipFadeDuration',] },],
'_tooltipTrigger': [{ type: Input, args: ['tooltipTrigger',] },],
'tooltipStateChanged': [{ type: Output },],
};
__decorate$1([
OnChange(),
__metadata$1("design:type", Object)
], TooltipDirective.prototype, "tooltip", void 0);
return TooltipDirective;
}());
/* tslint:disable */
var latinMap = {
'Á': 'A',
'Ă': 'A',
'Ắ': 'A',
'Ặ': 'A',
'Ằ': 'A',
'Ẳ': 'A',
'Ẵ': 'A',
'Ǎ': 'A',
'Â': 'A',
'Ấ': 'A',
'Ậ': 'A',
'Ầ': 'A',
'Ẩ': 'A',
'Ẫ': 'A',
'Ä': 'A',
'Ǟ': 'A',
'Ȧ': 'A',
'Ǡ': 'A',
'Ạ': 'A',
'Ȁ': 'A',
'À': 'A',
'Ả': 'A',
'Ȃ': 'A',
'Ā': 'A',
'Ą': 'A',
'Å': 'A',
'Ǻ': 'A',
'Ḁ': 'A',
'Ⱥ': 'A',
'Ã': 'A',
'Ꜳ': 'AA',
'Æ': 'AE',
'Ǽ': 'AE',
'Ǣ': 'AE',
'Ꜵ': 'AO',
'Ꜷ': 'AU',
'Ꜹ': 'AV',
'Ꜻ': 'AV',
'Ꜽ': 'AY',
'Ḃ': 'B',
'Ḅ': 'B',
'Ɓ': 'B',
'Ḇ': 'B',
'Ƀ': 'B',
'Ƃ': 'B',
'Ć': 'C',
'Č': 'C',
'Ç': 'C',
'Ḉ': 'C',
'Ĉ': 'C',
'Ċ': 'C',
'Ƈ': 'C',
'Ȼ': 'C',
'Ď': 'D',
'Ḑ': 'D',
'Ḓ': 'D',
'Ḋ': 'D',
'Ḍ': 'D',
'Ɗ': 'D',
'Ḏ': 'D',
'Dz': 'D',
'Dž': 'D',
'Đ': 'D',
'Ƌ': 'D',
'DZ': 'DZ',
'DŽ': 'DZ',
'É': 'E',
'Ĕ': 'E',
'Ě': 'E',
'Ȩ': 'E',
'Ḝ': 'E',
'Ê': 'E',
'Ế': 'E',
'Ệ': 'E',
'Ề': 'E',
'Ể': 'E',
'Ễ': 'E',
'Ḙ': 'E',
'Ë': 'E',
'Ė': 'E',
'Ẹ': 'E',
'Ȅ': 'E',
'È': 'E',
'Ẻ': 'E',
'Ȇ': 'E',
'Ē': 'E',
'Ḗ': 'E',
'Ḕ': 'E',
'Ę': 'E',
'Ɇ': 'E',
'Ẽ': 'E',
'Ḛ': 'E',
'Ꝫ': 'ET',
'Ḟ': 'F',
'Ƒ': 'F',
'Ǵ': 'G',
'Ğ': 'G',
'Ǧ': 'G',
'Ģ': 'G',
'Ĝ': 'G',
'Ġ': 'G',
'Ɠ': 'G',
'Ḡ': 'G',
'Ǥ': 'G',
'Ḫ': 'H',
'Ȟ': 'H',
'Ḩ': 'H',
'Ĥ': 'H',
'Ⱨ': 'H',
'Ḧ': 'H',
'Ḣ': 'H',
'Ḥ': 'H',
'Ħ': 'H',
'Í': 'I',
'Ĭ': 'I',
'Ǐ': 'I',
'Î': 'I',
'Ï': 'I',
'Ḯ': 'I',
'İ': 'I',
'Ị': 'I',
'Ȉ': 'I',
'Ì': 'I',
'Ỉ': 'I',
'Ȋ': 'I',
'Ī': 'I',
'Į': 'I',
'Ɨ': 'I',
'Ĩ': 'I',
'Ḭ': 'I',
'Ꝺ': 'D',
'Ꝼ': 'F',
'Ᵹ': 'G',
'Ꞃ': 'R',
'Ꞅ': 'S',
'Ꞇ': 'T',
'Ꝭ': 'IS',
'Ĵ': 'J',
'Ɉ': 'J',
'Ḱ': 'K',
'Ǩ': 'K',
'Ķ': 'K',
'Ⱪ': 'K',
'Ꝃ': 'K',
'Ḳ': 'K',
'Ƙ': 'K',
'Ḵ': 'K',
'Ꝁ': 'K',
'Ꝅ': 'K',
'Ĺ': 'L',
'Ƚ': 'L',
'Ľ': 'L',
'Ļ': 'L',
'Ḽ': 'L',
'Ḷ': 'L',
'Ḹ': 'L',
'Ⱡ': 'L',
'Ꝉ': 'L',
'Ḻ': 'L',
'Ŀ': 'L',
'Ɫ': 'L',
'Lj': 'L',
'Ł': 'L',
'LJ': 'LJ',
'Ḿ': 'M',
'Ṁ': 'M',
'Ṃ': 'M',
'Ɱ': 'M',
'Ń': 'N',
'Ň': 'N',
'Ņ': 'N',
'Ṋ': 'N',
'Ṅ': 'N',
'Ṇ': 'N',
'Ǹ': 'N',
'Ɲ': 'N',
'Ṉ': 'N',
'Ƞ': 'N',
'Nj': 'N',
'Ñ': 'N',
'NJ': 'NJ',
'Ó': 'O',
'Ŏ': 'O',
'Ǒ': 'O',
'Ô': 'O',
'Ố': 'O',
'Ộ': 'O',
'Ồ': 'O',
'Ổ': 'O',
'Ỗ': 'O',
'Ö': 'O',
'Ȫ': 'O',
'Ȯ': 'O',
'Ȱ': 'O',
'Ọ': 'O',
'Ő': 'O',
'Ȍ': 'O',
'Ò': 'O',
'Ỏ': 'O',
'Ơ': 'O',
'Ớ': 'O',
'Ợ': 'O',
'Ờ': 'O',
'Ở': 'O',
'Ỡ': 'O',
'Ȏ': 'O',
'Ꝋ': 'O',
'Ꝍ': 'O',
'Ō': 'O',
'Ṓ': 'O',
'Ṑ': 'O',
'Ɵ': 'O',
'Ǫ': 'O',
'Ǭ': 'O',
'Ø': 'O',
'Ǿ': 'O',
'Õ': 'O',
'Ṍ': 'O',
'Ṏ': 'O',
'Ȭ': 'O',
'Ƣ': 'OI',
'Ꝏ': 'OO',
'Ɛ': 'E',
'Ɔ': 'O',
'Ȣ': 'OU',
'Ṕ': 'P',
'Ṗ': 'P',
'Ꝓ': 'P',
'Ƥ': 'P',
'Ꝕ': 'P',
'Ᵽ': 'P',
'Ꝑ': 'P',
'Ꝙ': 'Q',
'Ꝗ': 'Q',
'Ŕ': 'R',
'Ř': 'R',
'Ŗ': 'R',
'Ṙ': 'R',
'Ṛ': 'R',
'Ṝ': 'R',
'Ȑ': 'R',
'Ȓ': 'R',
'Ṟ': 'R',
'Ɍ': 'R',
'Ɽ': 'R',
'Ꜿ': 'C',
'Ǝ': 'E',
'Ś': 'S',
'Ṥ': 'S',
'Š': 'S',
'Ṧ': 'S',
'Ş': 'S',
'Ŝ': 'S',
'Ș': 'S',
'Ṡ': 'S',
'Ṣ': 'S',
'Ṩ': 'S',
'Ť': 'T',
'Ţ': 'T',
'Ṱ': 'T',
'Ț': 'T',
'Ⱦ': 'T',
'Ṫ': 'T',
'Ṭ': 'T',
'Ƭ': 'T',
'Ṯ': 'T',
'Ʈ': 'T',
'Ŧ': 'T',
'Ɐ': 'A',
'Ꞁ': 'L',
'Ɯ': 'M',
'Ʌ': 'V',
'Ꜩ': 'TZ',
'Ú': 'U',
'Ŭ': 'U',
'Ǔ': 'U',
'Û': 'U',
'Ṷ': 'U',
'Ü': 'U',
'Ǘ': 'U',
'Ǚ': 'U',
'Ǜ': 'U',
'Ǖ': 'U',
'Ṳ': 'U',
'Ụ': 'U',
'Ű': 'U',
'Ȕ': 'U',
'Ù': 'U',
'Ủ': 'U',
'Ư': 'U',
'Ứ': 'U',
'Ự': 'U',
'Ừ': 'U',
'Ử': 'U',
'Ữ': 'U',
'Ȗ': 'U',
'Ū': 'U',
'Ṻ': 'U',
'Ų': 'U',
'Ů': 'U',
'Ũ': 'U',
'Ṹ': 'U',
'Ṵ': 'U',
'Ꝟ': 'V',
'Ṿ': 'V',
'Ʋ': 'V',
'Ṽ': 'V',
'Ꝡ': 'VY',
'Ẃ': 'W',
'Ŵ': 'W',
'Ẅ': 'W',
'Ẇ': 'W',
'Ẉ': 'W',
'Ẁ': 'W',
'Ⱳ': 'W',
'Ẍ': 'X',
'Ẋ': 'X',
'Ý': 'Y',
'Ŷ': 'Y',
'Ÿ': 'Y',
'Ẏ': 'Y',
'Ỵ': 'Y',
'Ỳ': 'Y',
'Ƴ': 'Y',
'Ỷ': 'Y',
'Ỿ': 'Y',
'Ȳ': 'Y',
'Ɏ': 'Y',
'Ỹ': 'Y',
'Ź': 'Z',
'Ž': 'Z',
'Ẑ': 'Z',
'Ⱬ': 'Z',
'Ż': 'Z',
'Ẓ': 'Z',
'Ȥ': 'Z',
'Ẕ': 'Z',
'Ƶ': 'Z',
'IJ': 'IJ',
'Œ': 'OE',
'ᴀ': 'A',
'ᴁ': 'AE',
'ʙ': 'B',
'ᴃ': 'B',
'ᴄ': 'C',
'ᴅ': 'D',
'ᴇ': 'E',
'ꜰ': 'F',
'ɢ': 'G',
'ʛ': 'G',
'ʜ': 'H',
'ɪ': 'I',
'ʁ': 'R',
'ᴊ': 'J',
'ᴋ': 'K',
'ʟ': 'L',
'ᴌ': 'L',
'ᴍ': 'M',
'ɴ': 'N',
'ᴏ': 'O',
'ɶ': 'OE',
'ᴐ': 'O',
'ᴕ': 'OU',
'ᴘ': 'P',
'ʀ': 'R',
'ᴎ': 'N',
'ᴙ': 'R',
'ꜱ': 'S',
'ᴛ': 'T',
'ⱻ': 'E',
'ᴚ': 'R',
'ᴜ': 'U',
'ᴠ': 'V',
'ᴡ': 'W',
'ʏ': 'Y',
'ᴢ': 'Z',
'á': 'a',
'ă': 'a',
'ắ': 'a',
'ặ': 'a',
'ằ': 'a',
'ẳ': 'a',
'ẵ': 'a',
'ǎ': 'a',
'â': 'a',
'ấ': 'a',
'ậ': 'a',
'ầ': 'a',
'ẩ': 'a',
'ẫ': 'a',
'ä': 'a',
'ǟ': 'a',
'ȧ': 'a',
'ǡ': 'a',
'ạ': 'a',
'ȁ': 'a',
'à': 'a',
'ả': 'a',
'ȃ': 'a',
'ā': 'a',
'ą': 'a',
'ᶏ': 'a',
'ẚ': 'a',
'å': 'a',
'ǻ': 'a',
'ḁ': 'a',
'ⱥ': 'a',
'ã': 'a',
'ꜳ': 'aa',
'æ': 'ae',
'ǽ': 'ae',
'ǣ': 'ae',
'ꜵ': 'ao',
'ꜷ': 'au',
'ꜹ': 'av',
'ꜻ': 'av',
'ꜽ': 'ay',
'ḃ': 'b',
'ḅ': 'b',
'ɓ': 'b',
'ḇ': 'b',
'ᵬ': 'b',
'ᶀ': 'b',
'ƀ': 'b',
'ƃ': 'b',
'ɵ': 'o',
'ć': 'c',
'č': 'c',
'ç': 'c',
'ḉ': 'c',
'ĉ': 'c',
'ɕ': 'c',
'ċ': 'c',
'ƈ': 'c',
'ȼ': 'c',
'ď': 'd',
'ḑ': 'd',
'ḓ': 'd',
'ȡ': 'd',
'ḋ': 'd',
'ḍ': 'd',
'ɗ': 'd',
'ᶑ': 'd',
'ḏ': 'd',
'ᵭ': 'd',
'ᶁ': 'd',
'đ': 'd',
'ɖ': 'd',
'ƌ': 'd',
'ı': 'i',
'ȷ': 'j',
'ɟ': 'j',
'ʄ': 'j',
'dz': 'dz',
'dž': 'dz',
'é': 'e',
'ĕ': 'e',
'ě': 'e',
'ȩ': 'e',
'ḝ': 'e',
'ê': 'e',
'ế': 'e',
'ệ': 'e',
'ề': 'e',
'ể': 'e',
'ễ': 'e',
'ḙ': 'e',
'ë': 'e',
'ė': 'e',
'ẹ': 'e',
'ȅ': 'e',
'è': 'e',
'ẻ': 'e',
'ȇ': 'e',
'ē': 'e',
'ḗ': 'e',
'ḕ': 'e',
'ⱸ': 'e',
'ę': 'e',
'ᶒ': 'e',
'ɇ': 'e',
'ẽ': 'e',
'ḛ': 'e',
'ꝫ': 'et',
'ḟ': 'f',
'ƒ': 'f',
'ᵮ': 'f',
'ᶂ': 'f',
'ǵ': 'g',
'ğ': 'g',
'ǧ': 'g',
'ģ': 'g',
'ĝ': 'g',
'ġ': 'g',
'ɠ': 'g',
'ḡ': 'g',
'ᶃ': 'g',
'ǥ': 'g',
'ḫ': 'h',
'ȟ': 'h',
'ḩ': 'h',
'ĥ': 'h',
'ⱨ': 'h',
'ḧ': 'h',
'ḣ': 'h',
'ḥ': 'h',
'ɦ': 'h',
'ẖ': 'h',
'ħ': 'h',
'ƕ': 'hv',
'í': 'i',
'ĭ': 'i',
'ǐ': 'i',
'î': 'i',
'ï': 'i',
'ḯ': 'i',
'ị': 'i',
'ȉ': 'i',
'ì': 'i',
'ỉ': 'i',
'ȋ': 'i',
'ī': 'i',
'į': 'i',
'ᶖ': 'i',
'ɨ': 'i',
'ĩ': 'i',
'ḭ': 'i',
'ꝺ': 'd',
'ꝼ': 'f',
'ᵹ': 'g',
'ꞃ': 'r',
'ꞅ': 's',
'ꞇ': 't',
'ꝭ': 'is',
'ǰ': 'j',
'ĵ': 'j',
'ʝ': 'j',
'ɉ': 'j',
'ḱ': 'k',
'ǩ': 'k',
'ķ': 'k',
'ⱪ': 'k',
'ꝃ': 'k',
'ḳ': 'k',
'ƙ': 'k',
'ḵ': 'k',
'ᶄ': 'k',
'ꝁ': 'k',
'ꝅ': 'k',
'ĺ': 'l',
'ƚ': 'l',
'ɬ': 'l',
'ľ': 'l',
'ļ': 'l',
'ḽ': 'l',
'ȴ': 'l',
'ḷ': 'l',
'ḹ': 'l',
'ⱡ': 'l',
'ꝉ': 'l',
'ḻ': 'l',
'ŀ': 'l',
'ɫ': 'l',
'ᶅ': 'l',
'ɭ': 'l',
'ł': 'l',
'lj': 'lj',
'ſ': 's',
'ẜ': 's',
'ẛ': 's',
'ẝ': 's',
'ḿ': 'm',
'ṁ': 'm',
'ṃ': 'm',
'ɱ': 'm',
'ᵯ': 'm',
'ᶆ': 'm',
'ń': 'n',
'ň': 'n',
'ņ': 'n',
'ṋ': 'n',
'ȵ': 'n',
'ṅ': 'n',
'ṇ': 'n',
'ǹ': 'n',
'ɲ': 'n',
'ṉ': 'n',
'ƞ': 'n',
'ᵰ': 'n',
'ᶇ': 'n',
'ɳ': 'n',
'ñ': 'n',
'nj': 'nj',
'ó': 'o',
'ŏ': 'o',
'ǒ': 'o',
'ô': 'o',
'ố': 'o',
'ộ': 'o',
'ồ': 'o',
'ổ': 'o',
'ỗ': 'o',
'ö': 'o',
'ȫ': 'o',
'ȯ': 'o',
'ȱ': 'o',
'ọ': 'o',
'ő': 'o',
'ȍ': 'o',
'ò': 'o',
'ỏ': 'o',
'ơ': 'o',
'ớ': 'o',
'ợ': 'o',
'ờ': 'o',
'ở': 'o',
'ỡ': 'o',
'ȏ': 'o',
'ꝋ': 'o',
'ꝍ': 'o',
'ⱺ': 'o',
'ō': 'o',
'ṓ': 'o',
'ṑ': 'o',
'ǫ': 'o',
'ǭ': 'o',
'ø': 'o',
'ǿ': 'o',
'õ': 'o',
'ṍ': 'o',
'ṏ': 'o',
'ȭ': 'o',
'ƣ': 'oi',
'ꝏ': 'oo',
'ɛ': 'e',
'ᶓ': 'e',
'ɔ': 'o',
'ᶗ': 'o',
'ȣ': 'ou',
'ṕ': 'p',
'ṗ': 'p',
'ꝓ': 'p',
'ƥ': 'p',
'ᵱ': 'p',
'ᶈ': 'p',
'ꝕ': 'p',
'ᵽ': 'p',
'ꝑ': 'p',
'ꝙ': 'q',
'ʠ': 'q',
'ɋ': 'q',
'ꝗ': 'q',
'ŕ': 'r',
'ř': 'r',
'ŗ': 'r',
'ṙ': 'r',
'ṛ': 'r',
'ṝ': 'r',
'ȑ': 'r',
'ɾ': 'r',
'ᵳ': 'r',
'ȓ': 'r',
'ṟ': 'r',
'ɼ': 'r',
'ᵲ': 'r',
'ᶉ': 'r',
'ɍ': 'r',
'ɽ': 'r',
'ↄ': 'c',
'ꜿ': 'c',
'ɘ': 'e',
'ɿ': 'r',
'ś': 's',
'ṥ': 's',
'š': 's',
'ṧ': 's',
'ş': 's',
'ŝ': 's',
'ș': 's',
'ṡ': 's',
'ṣ': 's',
'ṩ': 's',
'ʂ': 's',
'ᵴ': 's',
'ᶊ': 's',
'ȿ': 's',
'ɡ': 'g',
'ᴑ': 'o',
'ᴓ': 'o',
'ᴝ': 'u',
'ť': 't',
'ţ': 't',
'ṱ': 't',
'ț': 't',
'ȶ': 't',
'ẗ': 't',
'ⱦ': 't',
'ṫ': 't',
'ṭ': 't',
'ƭ': 't',
'ṯ': 't',
'ᵵ': 't',
'ƫ': 't',
'ʈ': 't',
'ŧ': 't',
'ᵺ': 'th',
'ɐ': 'a',
'ᴂ': 'ae',
'ǝ': 'e',
'ᵷ': 'g',
'ɥ': 'h',
'ʮ': 'h',
'ʯ': 'h',
'ᴉ': 'i',
'ʞ': 'k',
'ꞁ': 'l',
'ɯ': 'm',
'ɰ': 'm',
'ᴔ': 'oe',
'ɹ': 'r',
'ɻ': 'r',
'ɺ': 'r',
'ⱹ': 'r',
'ʇ': 't',
'ʌ': 'v',
'ʍ': 'w',
'ʎ': 'y',
'ꜩ': 'tz',
'ú': 'u',
'ŭ': 'u',
'ǔ': 'u',
'û': 'u',
'ṷ': 'u',
'ü': 'u',
'ǘ': 'u',
'ǚ': 'u',
'ǜ': 'u',
'ǖ': 'u',
'ṳ': 'u',
'ụ': 'u',
'ű': 'u',
'ȕ': 'u',
'ù': 'u',
'ủ': 'u',
'ư': 'u',
'ứ': 'u',
'ự': 'u',
'ừ': 'u',
'ử': 'u',
'ữ': 'u',
'ȗ': 'u',
'ū': 'u',
'ṻ': 'u',
'ų': 'u',
'ᶙ': 'u',
'ů': 'u',
'ũ': 'u',
'ṹ': 'u',
'ṵ': 'u',
'ᵫ': 'ue',
'ꝸ': 'um',
'ⱴ': 'v',
'ꝟ': 'v',
'ṿ': 'v',
'ʋ': 'v',
'ᶌ': 'v',
'ⱱ': 'v',
'ṽ': 'v',
'ꝡ': 'vy',
'ẃ': 'w',
'ŵ': 'w',
'ẅ': 'w',
'ẇ': 'w',
'ẉ': 'w',
'ẁ': 'w',
'ⱳ': 'w',
'ẘ': 'w',
'ẍ': 'x',
'ẋ': 'x',
'ᶍ': 'x',
'ý': 'y',
'ŷ': 'y',
'ÿ': 'y',
'ẏ': 'y',
'ỵ': 'y',
'ỳ': 'y',
'ƴ': 'y',
'ỷ': 'y',
'ỿ': 'y',
'ȳ': 'y',
'ẙ': 'y',
'ɏ': 'y',
'ỹ': 'y',
'ź': 'z',
'ž': 'z',
'ẑ': 'z',
'ʑ': 'z',
'ⱬ': 'z',
'ż': 'z',
'ẓ': 'z',
'ȥ': 'z',
'ẕ': 'z',
'ᵶ': 'z',
'ᶎ': 'z',
'ʐ': 'z',
'ƶ': 'z',
'ɀ': 'z',
'ff': 'ff',
'ffi': 'ffi',
'ffl': 'ffl',
'fi': 'fi',
'fl': 'fl',
'ij': 'ij',
'œ': 'oe',
'st': 'st',
'ₐ': 'a',
'ₑ': 'e',
'ᵢ': 'i',
'ⱼ': 'j',
'ₒ': 'o',
'ᵣ': 'r',
'ᵤ': 'u',
'ᵥ': 'v',
'ₓ': 'x'
};
var TypeaheadMatch = (function () {
function TypeaheadMatch(item, value, header) {
if (value === void 0) {
value = item;
}
if (header === void 0) {
header = false;
}
this.item = item;
this.value = value;
this.header = header;
}
TypeaheadMatch.prototype.isHeader = function () {
return this.header;
};
TypeaheadMatch.prototype.toString = function () {
return this.value;
};
return TypeaheadMatch;
}());
function latinize(str) {
if (!str) {
return '';
}
return str.replace(/[^A-Za-z0-9\[\] ]/g, function (a) {
return latinMap[a] || a;
});
}
/* tslint:disable */
function tokenize(str, wordRegexDelimiters, phraseRegexDelimiters) {
if (wordRegexDelimiters === void 0) {
wordRegexDelimiters = ' ';
}
if (phraseRegexDelimiters === void 0) {
phraseRegexDelimiters = '';
}
/* tslint:enable */
var regexStr = "(?:[" + phraseRegexDelimiters + "])([^" + phraseRegexDelimiters + "]+)" +
("(?:[" + phraseRegexDelimiters + "])|([^" + wordRegexDelimiters + "]+)");
var preTokenized = str.split(new RegExp(regexStr, 'g'));
var result = [];
var preTokenizedLength = preTokenized.length;
var token;
var replacePhraseDelimiters = new RegExp("[" + phraseRegexDelimiters + "]+", 'g');
for (var i = 0; i < preTokenizedLength; i += 1) {
token = preTokenized[i];
if (token && token.length && token !== wordRegexDelimiters) {
result.push(token.replace(replacePhraseDelimiters, ''));
}
}
return result;
}
function getValueFromObject(object, option) {
if (!option || typeof object !== 'object') {
return object.toString();
}
if (option.endsWith('()')) {
var functionName = option.slice(0, option.length - 2);
return object[functionName]().toString();
}
var properties = option
.replace(/\[(\w+)\]/g, '.$1')
.replace(/^\./, '');
var propertiesArray = properties.split('.');
for (var _i = 0, propertiesArray_1 = propertiesArray; _i < propertiesArray_1.length; _i++) {
var property = propertiesArray_1[_i];
if (property in object) {
// tslint:disable-next-line
object = object[property];
}
}
if (!object) {
return '';
}
return object.toString();
}
var TypeaheadContainerComponent = (function () {
function TypeaheadContainerComponent(element, renderer) {
this.renderer = renderer;
this.isFocused = false;
this._matches = [];
this.isScrolledIntoView = function (elem) {
var containerViewTop = this.ulElement.nativeElement.scrollTop;
var containerViewBottom = containerViewTop + this.ulElement.nativeElement.offsetHeight;
var elemTop = elem.offsetTop;
var elemBottom = elemTop + elem.offsetHeight;
return ((elemBottom <= containerViewBottom) && (elemTop >= containerViewTop));
};
this.element = element;
}
Object.defineProperty(TypeaheadContainerComponent.prototype, "isBs4", {
get: function () {
return !isBs3();
},
enumerable: true,
configurable: true
});
Object.defineProperty(TypeaheadContainerComponent.prototype, "active", {
get: function () {
return this._active;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TypeaheadContainerComponent.prototype, "matches", {
get: function () {
return this._matches;
},
set: function (value) {
var _this = this;
this._matches = value;
this.needScrollbar = this.typeaheadScrollable && this.typeaheadOptionsInScrollableView < this.matches.length;
if (this.typeaheadScrollable) {
setTimeout(function () {
_this.setScrollableMode();
});
}
if (this._matches.length > 0) {
this._active = this._matches[0];
if (this._active.isHeader()) {
this.nextActiveMatch();
}
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(TypeaheadContainerComponent.prototype, "optionsListTemplate", {
get: function () {
return this.parent ? this.parent.optionsListTemplate : undefined;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TypeaheadContainerComponent.prototype, "typeaheadScrollable", {
get: function () {
return this.parent ? this.parent.typeaheadScrollable : false;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TypeaheadContainerComponent.prototype, "typeaheadOptionsInScrollableView", {
get: function () {
return this.parent ? this.parent.typeaheadOptionsInScrollableView : 5;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TypeaheadContainerComponent.prototype, "itemTemplate", {
get: function () {
return this.parent ? this.parent.typeaheadItemTemplate : undefined;
},
enumerable: true,
configurable: true
});
TypeaheadContainerComponent.prototype.selectActiveMatch = function () {
this.selectMatch(this._active);
};
TypeaheadContainerComponent.prototype.prevActiveMatch = function () {
var index = this.matches.indexOf(this._active);
this._active = this.matches[index - 1 < 0 ? this.matches.length - 1 : index - 1];
if (this._active.isHeader()) {
this.prevActiveMatch();
}
if (this.typeaheadScrollable) {
this.scrollPrevious(index);
}
};
TypeaheadContainerComponent.prototype.nextActiveMatch = function () {
var index = this.matches.indexOf(this._active);
this._active = this.matches[index + 1 > this.matches.length - 1 ? 0 : index + 1];
if (this._active.isHeader()) {
this.nextActiveMatch();
}
if (this.typeaheadScrollable) {
this.scrollNext(index);
}
};
TypeaheadContainerComponent.prototype.selectActive = function (value) {
this.isFocused = true;
this._active = value;
};
TypeaheadContainerComponent.prototype.hightlight = function (match, query) {
var itemStr = match.value;
var itemStrHelper = (this.parent && this.parent.typeaheadLatinize
? latinize(itemStr)
: itemStr).toLowerCase();
var startIdx;
var tokenLen;
// Replaces the capture string with the same string inside of a "strong" tag
if (typeof query === 'object') {
var queryLen = query.length;
for (var i = 0; i < queryLen; i += 1) {
// query[i] is already latinized and lower case
startIdx = itemStrHelper.indexOf(query[i]);
tokenLen = query[i].length;
if (startIdx >= 0 && tokenLen > 0) {
itemStr =
itemStr.substring(0, startIdx) + "<strong>" + itemStr.substring(startIdx, startIdx + tokenLen) + "</strong>" +
("" + itemStr.substring(startIdx + tokenLen));
itemStrHelper =
itemStrHelper.substring(0, startIdx) + " " + ' '.repeat(tokenLen) + " " +
("" + itemStrHelper.substring(startIdx + tokenLen));
}
}
}
else if (query) {
// query is already latinized and lower case
startIdx = itemStrHelper.indexOf(query);
tokenLen = query.length;
if (startIdx >= 0 && tokenLen > 0) {
itemStr =
itemStr.substring(0, startIdx) + "<strong>" + itemStr.substring(startIdx, startIdx + tokenLen) + "</strong>" +
("" + itemStr.substring(startIdx + tokenLen));
}
}
return itemStr;
};
TypeaheadContainerComponent.prototype.focusLost = function () {
this.isFocused = false;
};
TypeaheadContainerComponent.prototype.isActive = function (value) {
return this._active === value;
};
TypeaheadContainerComponent.prototype.selectMatch = function (value, e) {
var _this = this;
if (e === void 0) {
e = void 0;
}
if (e) {
e.stopPropagation();
e.preventDefault();
}
this.parent.changeModel(value);
setTimeout(function () { return _this.parent.typeaheadOnSelect.emit(value); }, 0);
return false;
};
TypeaheadContainerComponent.prototype.setScrollableMode = function () {
if (!this.ulElement) {
this.ulElement = this.element;
}
if (this.liElements.first) {
var ulStyles = Utils.getStyles(this.ulElement.nativeElement);
var liStyles = Utils.getStyles(this.liElements.first.nativeElement);
var ulPaddingBottom = parseFloat((ulStyles['padding-bottom'] ? ulStyles['padding-bottom'] : '').replace('px', ''));
var ulPaddingTop = parseFloat((ulStyles['padding-top'] ? ulStyles['padding-top'] : '0').replace('px', ''));
var optionHeight = parseFloat((liStyles['height'] ? liStyles['height'] : '0').replace('px', ''));
var height = this.typeaheadOptionsInScrollableView * optionHeight;
this.guiHeight = height + ulPaddingTop + ulPaddingBottom + "px";
}
this.renderer.setStyle(this.element.nativeElement, 'visibility', 'visible');
};
TypeaheadContainerComponent.prototype.scrollPrevious = function (index) {
if (index === 0) {
this.scrollToBottom();
return;
}
if (this.liElements) {
var liElement = this.liElements.toArray()[index - 1];
if (liElement && !this.isScrolledIntoView(liElement.nativeElement)) {
this.ulElement.nativeElement.scrollTop = liElement.nativeElement.offsetTop;
}
}
};
TypeaheadContainerComponent.prototype.scrollNext = function (index) {
if (index + 1 > this.matches.length - 1) {
this.scrollToTop();
return;
}
if (this.liElements) {
var liElement = this.liElements.toArray()[index + 1];
if (liElement && !this.isScrolledIntoView(liElement.nativeElement)) {
this.ulElement.nativeElement.scrollTop =
liElement.nativeElement.offsetTop -
this.ulElement.nativeElement.offsetHeight +
liElement.nativeElement.offsetHeight;
}
}
};
TypeaheadContainerComponent.prototype.scrollToBottom = function () {
this.ulElement.nativeElement.scrollTop = this.ulElement.nativeElement.scrollHeight;
};
TypeaheadContainerComponent.prototype.scrollToTop = function () {
this.ulElement.nativeElement.scrollTop = 0;
};
TypeaheadContainerComponent.decorators = [
{ type: Component, args: [{
selector: 'typeahead-container',
// tslint:disable-next-line
template: "<!-- inject options list template --> <ng-template [ngTemplateOutlet]=\"optionsListTemplate || (isBs4 ? bs4Template : bs3Template)\" [ngTemplateOutletContext]=\"{matches:matches, itemTemplate:itemTemplate, query:query}\"></ng-template> <!-- default options item template --> <ng-template #bsItemTemplate let-match=\"match\" let-query=\"query\"><span [innerHtml]=\"hightlight(match, query)\"></span> </ng-template> <!-- Bootstrap 3 options list template --> <ng-template #bs3Template> <ul class=\"dropdown-menu\" #ulElement [style.overflow-y]=\"needScrollbar ? 'scroll': 'auto'\" [style.height]=\"needScrollbar ? guiHeight: 'auto'\"> <ng-template ngFor let-match let-i=\"index\" [ngForOf]=\"matches\"> <li #liElements *ngIf=\"match.isHeader()\" class=\"dropdown-header\">{{ match }}</li> <li #liElements *ngIf=\"!match.isHeader()\" [class.active]=\"isActive(match)\" (mouseenter)=\"selectActive(match)\"> <a href=\"#\" (click)=\"selectMatch(match, $event)\" tabindex=\"-1\"> <ng-template [ngTemplateOutlet]=\"itemTemplate || bsItemTemplate\" [ngTemplateOutletContext]=\"{item:match.item, index:i, match:match, query:query}\"></ng-template> </a> </li> </ng-template> </ul> </ng-template> <!-- Bootstrap 4 options list template --> <ng-template #bs4Template> <ng-template ngFor let-match let-i=\"index\" [ngForOf]=\"matches\"> <h6 *ngIf=\"match.isHeader()\" class=\"dropdown-header\">{{ match }}</h6> <ng-template [ngIf]=\"!match.isHeader()\"> <button #liElements class=\"dropdown-item\" (click)=\"selectMatch(match, $event)\" (mouseenter)=\"selectActive(match)\" [class.active]=\"isActive(match)\"> <ng-template [ngTemplateOutlet]=\"itemTemplate || bsItemTemplate\" [ngTemplateOutletContext]=\"{item:match.item, index:i, match:match, query:query}\"></ng-template> </button> </ng-template> </ng-template> </ng-template> ",
host: {
class: 'dropdown open',
'[class.dropdown-menu]': 'isBs4',
'[style.overflow-y]': "isBs4 && needScrollbar ? 'scroll': 'visible'",
'[style.height]': "isBs4 && needScrollbar ? guiHeight: 'auto'",
'[style.visibility]': "typeaheadScrollable ? 'hidden' : 'visible'",
'[class.dropup]': 'dropup',
style: 'position: absolute;display: block;'
}
},] },
];
/** @nocollapse */
TypeaheadContainerComponent.ctorParameters = function () {
return [
{ type: ElementRef, },
{ type: Renderer2, },
];
};
TypeaheadContainerComponent.propDecorators = {
'ulElement': [{ type: ViewChild, args: ['ulElement',] },],
'liElements': [{ type: ViewChildren, args: ['liElements',] },],
'focusLost': [{ type: HostListener, args: ['mouseleave',] }, { type: HostListener, args: ['blur',] },],
};
return TypeaheadContainerComponent;
}());
/* tslint:disable:max-file-line-count */
var TypeaheadDirective = (function () {
function TypeaheadDirective(ngControl, element, viewContainerRef, renderer, cis, changeDetection) {
this.ngControl = ngControl;
this.element = element;
this.renderer = renderer;
this.changeDetection = changeDetection;
/** minimal no of characters that needs to be entered before
* typeahead kicks-in. When set to 0, typeahead shows on focus with full
* list of options (limited as normal by typeaheadOptionsLimit)
*/
this.typeaheadMinLength = void 0;
/** should be used only in case of typeahead attribute is array.
* If true - loading of options will be async, otherwise - sync.
* true make sense if options array is large.
*/
this.typeaheadAsync = void 0;
/** match latin symbols.
* If true the word súper would match super and vice versa.
*/
this.typeaheadLatinize = true;
/** Can be use to search words by inserting a single white space between each characters
* for example 'C a l i f o r n i a' will match 'California'.
*/
this.typeaheadSingleWords = true;
/** should be used only in case typeaheadSingleWords attribute is true.
* Sets the word delimiter to break words. Defaults to space.
*/
this.typeaheadWordDelimiters = ' ';
/** should be used only in case typeaheadSingleWords attribute is true.
* Sets the word delimiter to match exact phrase.
* Defaults to simple and double quotes.
*/
this.typeaheadPhraseDelimiters = '\'"';
/** specifies if typeahead is scrollable */
this.typeaheadScrollable = false;
/** specifies number of options to show in scroll view */
this.typeaheadOptionsInScrollableView = 5;
/** fired when 'busy' state of this component was changed,
* fired on async mode only, returns boolean
*/
this.typeaheadLoading = new EventEmitter();
/** fired on every key event and returns true
* in case of matches are not detected
*/
this.typeaheadNoResults = new EventEmitter();
/** fired when option was selected, return object with data of this option */
this.typeaheadOnSelect = new EventEmitter();
/** fired when blur event occurres. returns the active item */
this.typeaheadOnBlur = new EventEmitter();
/** This attribute indicates that the dropdown should be opened upwards */
this.dropup = false;
this.isTypeaheadOptionsListActive = false;
this.keyUpEventEmitter = new EventEmitter();
this.placement = 'bottom-left';
this._subscriptions = [];
this._typeahead = cis.createLoader(element, viewContainerRef, renderer);
}
TypeaheadDirective.prototype.ngOnInit = function () {
this.typeaheadOptionsLimit = this.typeaheadOptionsLimit || 20;
this.typeaheadMinLength =
this.typeaheadMinLength === void 0 ? 1 : this.typeaheadMinLength;
this.typeaheadWaitMs = this.typeaheadWaitMs || 0;
// async should be false in case of array
if (this.typeaheadAsync === undefined &&
!(this.typeahead instanceof Observable$1)) {
this.typeaheadAsync = false;
}
if (this.typeahead instanceof Observable$1) {
this.typeaheadAsync = true;
}
if (this.typeaheadAsync) {
this.asyncActions();
}
else {
this.syncActions();
}
};
TypeaheadDirective.prototype.onInput = function (e) {
// For `<input>`s, use the `value` property. For others that don't have a
// `value` (such as `<span contenteditable="true">`), use either
// `textContent` or `innerText` (depending on which one is supported, i.e.
// Firefox or IE).
var value = e.target.value !== undefined
? e.target.value
: e.target.textContent !== undefined
? e.target.textContent
: e.target.innerText;
if (value != null && value.trim().length >= this.typeaheadMinLength) {
this.typeaheadLoading.emit(true);
this.keyUpEventEmitter.emit(e.target.value);
}
else {
this.typeaheadLoading.emit(false);
this.typeaheadNoResults.emit(false);
this.hide();
}
};
TypeaheadDirective.prototype.onChange = function (e) {
if (this._container) {
// esc
if (e.keyCode === 27) {
this.hide();
return;
}
// up
if (e.keyCode === 38) {
this._container.prevActiveMatch();
return;
}
// down
if (e.keyCode === 40) {
this._container.nextActiveMatch();
return;
}
// enter, tab
if (e.keyCode === 13) {
this._container.selectActiveMatch();
return;
}
}
};
TypeaheadDirective.prototype.onFocus = function () {
if (this.typeaheadMinLength === 0) {
this.typeaheadLoading.emit(true);
this.keyUpEventEmitter.emit(this.element.nativeElement.value || '');
}
};
TypeaheadDirective.prototype.onBlur = function () {
if (this._container && !this._container.isFocused) {
this.typeaheadOnBlur.emit(this._container.active);
}
};
TypeaheadDirective.prototype.onKeydown = function (e) {
// no container - no problems
if (!this._container) {
return;
}
// if an item is visible - prevent form submission
if (e.keyCode === 13) {
e.preventDefault();
return;
}
// if an item is visible - don't change focus
if (e.keyCode === 9) {
e.preventDefault();
this._container.selectActiveMatch();
return;
}
};
TypeaheadDirective.prototype.changeModel = function (match) {
var valueStr = match.value;
this.ngControl.viewToModelUpdate(valueStr);
(this.ngControl.control).setValue(valueStr);
this.changeDetection.markForCheck();
this.hide();
};
Object.defineProperty(TypeaheadDirective.prototype, "matches", {
get: function () {
return this._matches;
},
enumerable: true,
configurable: true
});
TypeaheadDirective.prototype.show = function () {
var _this = this;
this._typeahead
.attach(TypeaheadContainerComponent)
.to(this.container)
.position({ attachment: (this.dropup ? 'top' : 'bottom') + " left" })
.show({
typeaheadRef: this,
placement: this.placement,
animation: false,
dropup: this.dropup
});
this._outsideClickListener = this.renderer.listen('document', 'click', function (e) {
if (_this.typeaheadMinLength === 0 && _this.element.nativeElement.contains(e.target)) {
return;
}
_this.onOutsideClick();
});
this._container = this._typeahead.instance;
this._container.parent = this;
// This improves the speed as it won't have to be done for each list item
var normalizedQuery = (this.typeaheadLatinize
? latinize(this.ngControl.control.value)
: this.ngControl.control.value)
.toString()
.toLowerCase();
this._container.query = this.typeaheadSingleWords
? tokenize(normalizedQuery, this.typeaheadWordDelimiters, this.typeaheadPhraseDelimiters)
: normalizedQuery;
this._container.matches = this._matches;
this.element.nativeElement.focus();
};
TypeaheadDirective.prototype.hide = function () {
if (this._typeahead.isShown) {
this._typeahead.hide();
this._outsideClickListener();
this._container = null;
}
};
TypeaheadDirective.prototype.onOutsideClick = function () {
if (this._container && !this._container.isFocused) {
this.hide();
}
};
TypeaheadDirective.prototype.ngOnDestroy = function () {
// clean up subscriptions
for (var _i = 0, _a = this._subscriptions; _i < _a.length; _i++) {
var sub = _a[_i];
sub.unsubscribe();
}
this._typeahead.dispose();
};
TypeaheadDirective.prototype.asyncActions = function () {
var _this = this;
this._subscriptions.push(this.keyUpEventEmitter
.debounceTime(this.typeaheadWaitMs)
.switchMap(function () { return _this.typeahead; })
.subscribe(function (matches) {
_this.finalizeAsyncCall(matches);
}));
};
TypeaheadDirective.prototype.syncActions = function () {
var _this = this;
this._subscriptions.push(this.keyUpEventEmitter
.debounceTime(this.typeaheadWaitMs)
.mergeMap(function (value) {
var normalizedQuery = _this.normalizeQuery(value);
return Observable$1.from(_this.typeahead)
.filter(function (option) {
return (option &&
_this.testMatch(_this.normalizeOption(option), normalizedQuery));
})
.toArray();
})
.subscribe(function (matches) {
_this.finalizeAsyncCall(matches);
}));
};
TypeaheadDirective.prototype.normalizeOption = function (option) {
var optionValue = getValueFromObject(option, this.typeaheadOptionField);
var normalizedOption = this.typeaheadLatinize
? latinize(optionValue)
: optionValue;
return normalizedOption.toLowerCase();
};
TypeaheadDirective.prototype.normalizeQuery = function (value) {
// If singleWords, break model here to not be doing extra work on each
// iteration
var normalizedQuery = (this.typeaheadLatinize
? latinize(value)
: value)
.toString()
.toLowerCase();
normalizedQuery = this.typeaheadSingleWords
? tokenize(normalizedQuery, this.typeaheadWordDelimiters, this.typeaheadPhraseDelimiters)
: normalizedQuery;
return normalizedQuery;
};
TypeaheadDirective.prototype.testMatch = function (match, test) {
var spaceLength;
if (typeof test === 'object') {
spaceLength = test.length;
for (var i = 0; i < spaceLength; i += 1) {
if (test[i].length > 0 && match.indexOf(test[i]) < 0) {
return false;
}
}
return true;
}
return match.indexOf(test) >= 0;
};
TypeaheadDirective.prototype.finalizeAsyncCall = function (matches) {
this.prepareMatches(matches);
this.typeaheadLoading.emit(false);
this.typeaheadNoResults.emit(!this.hasMatches());
if (!this.hasMatches()) {
this.hide();
return;
}
if (this._container) {
// This improves the speed as it won't have to be done for each list item
var normalizedQuery = (this.typeaheadLatinize
? latinize(this.ngControl.control.value)
: this.ngControl.control.value)
.toString()
.toLowerCase();
this._container.query = this.typeaheadSingleWords
? tokenize(normalizedQuery, this.typeaheadWordDelimiters, this.typeaheadPhraseDelimiters)
: normalizedQuery;
this._container.matches = this._matches;
}
else {
this.show();
}
};
TypeaheadDirective.prototype.prepareMatches = function (options) {
var _this = this;
var limited = options.slice(0, this.typeaheadOptionsLimit);
if (this.typeaheadGroupField) {
var matches_1 = [];
// extract all group names
var groups = limited
.map(function (option) {
return getValueFromObject(option, _this.typeaheadGroupField);
})
.filter(function (v, i, a) { return a.indexOf(v) === i; });
groups.forEach(function (group) {
// add group header to array of matches
matches_1.push(new TypeaheadMatch(group, group, true));
// add each item of group to array of matches
matches_1 = matches_1.concat(limited
.filter(function (option) {
return getValueFromObject(option, _this.typeaheadGroupField) === group;
})
.map(function (option) {
return new TypeaheadMatch(option, getValueFromObject(option, _this.typeaheadOptionField));
}));
});
this._matches = matches_1;
}
else {
this._matches = limited.map(function (option) {
return new TypeaheadMatch(option, getValueFromObject(option, _this.typeaheadOptionField));
});
}
};
TypeaheadDirective.prototype.hasMatches = function () {
return this._matches.length > 0;
};
TypeaheadDirective.decorators = [
{ type: Directive, args: [{ selector: '[typeahead]', exportAs: 'bs-typeahead' },] },
];
/** @nocollapse */
TypeaheadDirective.ctorParameters = function () {
return [
{ type: NgControl, },
{ type: ElementRef, },
{ type: ViewContainerRef, },
{ type: Renderer2, },
{ type: ComponentLoaderFactory, },
{ type: ChangeDetectorRef, },
];
};
TypeaheadDirective.propDecorators = {
'typeahead': [{ type: Input },],
'typeaheadMinLength': [{ type: Input },],
'typeaheadWaitMs': [{ type: Input },],
'typeaheadOptionsLimit': [{ type: Input },],
'typeaheadOptionField': [{ type: Input },],
'typeaheadGroupField': [{ type: Input },],
'typeaheadAsync': [{ type: Input },],
'typeaheadLatinize': [{ type: Input },],
'typeaheadSingleWords': [{ type: Input },],
'typeaheadWordDelimiters': [{ type: Input },],
'typeaheadPhraseDelimiters': [{ type: Input },],
'typeaheadItemTemplate': [{ type: Input },],
'optionsListTemplate': [{ type: Input },],
'typeaheadScrollable': [{ type: Input },],
'typeaheadOptionsInScrollableView': [{ type: Input },],
'typeaheadLoading': [{ type: Output },],
'typeaheadNoResults': [{ type: Output },],
'typeaheadOnSelect': [{ type: Output },],
'typeaheadOnBlur': [{ type: Output },],
'container': [{ type: Input },],
'dropup': [{ type: Input },],
'onInput': [{ type: HostListener, args: ['input', ['$event'],] },],
'onChange': [{ type: HostListener, args: ['keyup', ['$event'],] },],
'onFocus': [{ type: HostListener, args: ['click',] }, { type: HostListener, args: ['focus',] },],
'onBlur': [{ type: HostListener, args: ['blur',] },],
'onKeydown': [{ type: HostListener, args: ['keydown', ['$event'],] },],
};
return TypeaheadDirective;
}());
// tslint:disable:comment-format binary-expression-operand-order max-line-length
var symbolMap = {
1: '١',
2: '٢',
3: '٣',
4: '٤',
5: '٥',
6: '٦',
7: '٧',
8: '٨',
9: '٩',
0: '٠'
};
var numberMap = {
'١': '1',
'٢': '2',
'٣': '3',
'٤': '4',
'٥': '5',
'٦': '6',
'٧': '7',
'٨': '8',
'٩': '9',
'٠': '0'
};
var pluralForm = function (num) {
return num === 0 ? 0 : num === 1 ? 1 : num === 2 ? 2 : num % 100 >= 3 && num % 100 <= 10 ? 3 : num % 100 >= 11 ? 4 : 5;
};
var plurals = {
s: ['أقل من ثانية', 'ثانية واحدة', ['ثانيتان', 'ثانيتين'], '%d ثوان', '%d ثانية', '%d ثانية'],
m: ['أقل من دقيقة', 'دقيقة واحدة', ['دقيقتان', 'دقيقتين'], '%d دقائق', '%d دقيقة', '%d دقيقة'],
h: ['أقل من ساعة', 'ساعة واحدة', ['ساعتان', 'ساعتين'], '%d ساعات', '%d ساعة', '%d ساعة'],
d: ['أقل من يوم', 'يوم واحد', ['يومان', 'يومين'], '%d أيام', '%d يومًا', '%d يوم'],
M: ['أقل من شهر', 'شهر واحد', ['شهران', 'شهرين'], '%d أشهر', '%d شهرا', '%d شهر'],
y: ['أقل من عام', 'عام واحد', ['عامان', 'عامين'], '%d أعوام', '%d عامًا', '%d عام']
};
var pluralize = function (u) {
return function (num, withoutSuffix) {
var f = pluralForm(num);
var str = plurals[u][pluralForm(num)];
if (f === 2) {
str = str[withoutSuffix ? 0 : 1];
}
return str.replace(/%d/i, num.toString());
};
};
var months = [
'يناير',
'فبراير',
'مارس',
'أبريل',
'مايو',
'يونيو',
'يوليو',
'أغسطس',
'سبتمبر',
'أكتوبر',
'نوفمبر',
'ديسمبر'
];
var arLocale = {
abbr: 'ar',
months: months,
monthsShort: months,
weekdays: 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
weekdaysShort: 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'),
weekdaysMin: 'ح_ن_ث_ر_خ_ج_س'.split('_'),
weekdaysParseExact: true,
longDateFormat: {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
L: 'D/\u200FM/\u200FYYYY',
LL: 'D MMMM YYYY',
LLL: 'D MMMM YYYY HH:mm',
LLLL: 'dddd D MMMM YYYY HH:mm'
},
meridiemParse: /ص|م/,
isPM: function (input) {
return 'م' === input;
},
meridiem: function (hour, minute, isLower) {
if (hour < 12) {
return 'ص';
}
else {
return 'م';
}
},
calendar: {
sameDay: '[اليوم عند الساعة] LT',
nextDay: '[غدًا عند الساعة] LT',
nextWeek: 'dddd [عند الساعة] LT',
lastDay: '[أمس عند الساعة] LT',
lastWeek: 'dddd [عند الساعة] LT',
sameElse: 'L'
},
relativeTime: {
future: 'بعد %s',
past: 'منذ %s',
s: pluralize('s'),
ss: pluralize('s'),
m: pluralize('m'),
mm: pluralize('m'),
h: pluralize('h'),
hh: pluralize('h'),
d: pluralize('d'),
dd: pluralize('d'),
M: pluralize('M'),
MM: pluralize('M'),
y: pluralize('y'),
yy: pluralize('y')
},
preparse: function (str) {
return str.replace(/[١٢٣٤٥٦٧٨٩٠]/g, function (match) {
return numberMap[match];
}).replace(/،/g, ',');
},
postformat: function (str) {
return str.replace(/\d/g, function (match) {
return symbolMap[match];
}).replace(/,/g, '،');
},
week: {
dow: 6,
doy: 12 // The week that contains Jan 1st is the first week of the year.
}
};
// tslint:disable:comment-format binary-expression-operand-order max-line-length
// tslint:disable:no-bitwise prefer-template cyclomatic-complexity
// tslint:disable:no-shadowed-variable switch-default prefer-const
// tslint:disable:one-variable-per-declaration newline-before-return
//! moment.js locale configuration
//! locale : Czech [cs]
//! author : petrbela : https://github.com/petrbela
var months$1 = 'leden_únor_březen_duben_květen_červen_červenec_srpen_září_říjen_listopad_prosinec'.split('_');
var monthsShort = 'led_úno_bře_dub_kvě_čvn_čvc_srp_zář_říj_lis_pro'.split('_');
function plural(num) {
return (num > 1) && (num < 5) && (~~(num / 10) !== 1);
}
function translate(num, withoutSuffix, key, isFuture) {
var result = num + ' ';
switch (key) {
case 's': // a few seconds / in a few seconds / a few seconds ago
return (withoutSuffix || isFuture) ? 'pár sekund' : 'pár sekundami';
case 'ss': // 9 seconds / in 9 seconds / 9 seconds ago
if (withoutSuffix || isFuture) {
return result + (plural(num) ? 'sekundy' : 'sekund');
}
else {
return result + 'sekundami';
}
// break;
case 'm': // a minute / in a minute / a minute ago
return withoutSuffix ? 'minuta' : (isFuture ? 'minutu' : 'minutou');
case 'mm': // 9 minutes / in 9 minutes / 9 minutes ago
if (withoutSuffix || isFuture) {
return result + (plural(num) ? 'minuty' : 'minut');
}
else {
return result + 'minutami';
}
// break;
case 'h': // an hour / in an hour / an hour ago
return withoutSuffix ? 'hodina' : (isFuture ? 'hodinu' : 'hodinou');
case 'hh': // 9 hours / in 9 hours / 9 hours ago
if (withoutSuffix || isFuture) {
return result + (plural(num) ? 'hodiny' : 'hodin');
}
else {
return result + 'hodinami';
}
// break;
case 'd': // a day / in a day / a day ago
return (withoutSuffix || isFuture) ? 'den' : 'dnem';
case 'dd': // 9 days / in 9 days / 9 days ago
if (withoutSuffix || isFuture) {
return result + (plural(num) ? 'dny' : 'dní');
}
else {
return result + 'dny';
}
// break;
case 'M': // a month / in a month / a month ago
return (withoutSuffix || isFuture) ? 'měsíc' : 'měsícem';
case 'MM': // 9 months / in 9 months / 9 months ago
if (withoutSuffix || isFuture) {
return result + (plural(num) ? 'měsíce' : 'měsíců');
}
else {
return result + 'měsíci';
}
// break;
case 'y': // a year / in a year / a year ago
return (withoutSuffix || isFuture) ? 'rok' : 'rokem';
case 'yy': // 9 years / in 9 years / 9 years ago
if (withoutSuffix || isFuture) {
return result + (plural(num) ? 'roky' : 'let');
}
else {
return result + 'lety';
}
}
}
var csLocale = {
abbr: 'cs',
months: months$1,
monthsShort: monthsShort,
monthsParse: (function (months, monthsShort) {
var i, _monthsParse = [];
for (i = 0; i < 12; i++) {
// use custom parser to solve problem with July (červenec)
_monthsParse[i] = new RegExp('^' + months[i] + '$|^' + monthsShort[i] + '$', 'i');
}
return _monthsParse;
}(months$1, monthsShort)),
shortMonthsParse: (function (monthsShort) {
var i, _shortMonthsParse = [];
for (i = 0; i < 12; i++) {
_shortMonthsParse[i] = new RegExp('^' + monthsShort[i] + '$', 'i');
}
return _shortMonthsParse;
}(monthsShort)),
longMonthsParse: (function (months) {
var i, _longMonthsParse = [];
for (i = 0; i < 12; i++) {
_longMonthsParse[i] = new RegExp('^' + months[i] + '$', 'i');
}
return _longMonthsParse;
}(months$1)),
weekdays: 'neděle_pondělí_úterý_středa_čtvrtek_pátek_sobota'.split('_'),
weekdaysShort: 'ne_po_út_st_čt_pá_so'.split('_'),
weekdaysMin: 'ne_po_út_st_čt_pá_so'.split('_'),
longDateFormat: {
LT: 'H:mm',
LTS: 'H:mm:ss',
L: 'DD.MM.YYYY',
LL: 'D. MMMM YYYY',
LLL: 'D. MMMM YYYY H:mm',
LLLL: 'dddd D. MMMM YYYY H:mm',
l: 'D. M. YYYY'
},
calendar: {
sameDay: '[dnes v] LT',
nextDay: '[zítra v] LT',
nextWeek: function (dayOfWeek) {
switch (dayOfWeek) {
case 0:
return '[v neděli v] LT';
case 1:
case 2:
return '[v] dddd [v] LT';
case 3:
return '[ve středu v] LT';
case 4:
return '[ve čtvrtek v] LT';
case 5:
return '[v pátek v] LT';
case 6:
return '[v sobotu v] LT';
}
},
lastDay: '[včera v] LT',
lastWeek: function (dayOfWeek) {
switch (dayOfWeek) {
case 0:
return '[minulou neděli v] LT';
case 1:
case 2:
return '[minulé] dddd [v] LT';
case 3:
return '[minulou středu v] LT';
case 4:
case 5:
return '[minulý] dddd [v] LT';
case 6:
return '[minulou sobotu v] LT';
}
},
sameElse: 'L'
},
relativeTime: {
future: 'za %s',
past: 'před %s',
s: translate,
ss: translate,
m: translate,
mm: translate,
h: translate,
hh: translate,
d: translate,
dd: translate,
M: translate,
MM: translate,
y: translate,
yy: translate
},
dayOfMonthOrdinalParse: /\d{1,2}\./,
ordinal: '%d.',
week: {
dow: 1,
doy: 4 // The week that contains Jan 4th is the first week of the year.
}
};
// tslint:disable:comment-format
//! moment.js locale configuration
//! locale : Danish (Denmark) [da]
//! author : Per Hansen : https://github.com/perhp
var daLocale = {
abbr: 'da',
months: 'Januar_Februar_Marts_April_Maj_Juni_Juli_August_September_Oktober_November_December'.split('_'),
monthsShort: 'Jan_Feb_Mar_Apr_Maj_Jun_Jul_Aug_Sep_Okt_Nov_Dec'.split('_'),
weekdays: 'Søndag_Mandag_Tirsdag_Onsdag_Torsdag_Fredag_Lørdag'.split('_'),
weekdaysShort: 'Søn_Man_Tir_Ons_Tor_Fre_Lør'.split('_'),
weekdaysMin: 'Sø_Ma_Ti_On_To_Fr_Lø'.split('_'),
longDateFormat: {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
L: 'DD/MM/YYYY',
LL: 'D. MMMM YYYY',
LLL: 'D. MMMM YYYY HH:mm',
LLLL: 'dddd [d.] D. MMMM YYYY [kl.] HH:mm'
},
calendar: {
sameDay: '[i dag kl.] LT',
nextDay: '[i morgen kl.] LT',
nextWeek: 'på dddd [kl.] LT',
lastDay: '[i går kl.] LT',
lastWeek: '[i] dddd[s kl.] LT',
sameElse: 'L'
},
relativeTime: {
future: 'om %s',
past: '%s siden',
s: 'få sekunder',
m: 'et minut',
mm: '%d minutter',
h: 'en time',
hh: '%d timer',
d: 'en dag',
dd: '%d dage',
M: 'en måned',
MM: '%d måneder',
y: 'et år',
yy: '%d år'
},
dayOfMonthOrdinalParse: /\d{1,2}\./,
ordinal: '%d.',
week: {
dow: 1,
doy: 4 // The week that contains Jan 4th is the first week of the year.
}
};
// tslint:disable:comment-format binary-expression-operand-order max-line-length
// tslint:disable:no-bitwise prefer-template cyclomatic-complexity
// tslint:disable:no-shadowed-variable switch-default prefer-const
// tslint:disable:one-variable-per-declaration newline-before-return
// tslint:disable:object-literal-key-quotes
//! moment.js locale configuration
//! locale : German [de]
//! author : lluchs : https://github.com/lluchs
//! author: Menelion Elensúle: https://github.com/Oire
//! author : Mikolaj Dadela : https://github.com/mik01aj
function processRelativeTime(num, withoutSuffix, key, isFuture) {
var format = {
'm': ['eine Minute', 'einer Minute'],
'h': ['eine Stunde', 'einer Stunde'],
'd': ['ein Tag', 'einem Tag'],
'dd': [num + ' Tage', num + ' Tagen'],
'M': ['ein Monat', 'einem Monat'],
'MM': [num + ' Monate', num + ' Monaten'],
'y': ['ein Jahr', 'einem Jahr'],
'yy': [num + ' Jahre', num + ' Jahren']
};
return withoutSuffix ? format[key][0] : format[key][1];
}
var deLocale = {
abbr: 'de',
months: 'Januar_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
monthsShort: 'Jan._Feb._März_Apr._Mai_Juni_Juli_Aug._Sep._Okt._Nov._Dez.'.split('_'),
monthsParseExact: true,
weekdays: 'Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag'.split('_'),
weekdaysShort: 'So._Mo._Di._Mi._Do._Fr._Sa.'.split('_'),
weekdaysMin: 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'),
weekdaysParseExact: true,
longDateFormat: {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
L: 'DD.MM.YYYY',
LL: 'D. MMMM YYYY',
LLL: 'D. MMMM YYYY HH:mm',
LLLL: 'dddd, D. MMMM YYYY HH:mm'
},
calendar: {
sameDay: '[heute um] LT [Uhr]',
sameElse: 'L',
nextDay: '[morgen um] LT [Uhr]',
nextWeek: 'dddd [um] LT [Uhr]',
lastDay: '[gestern um] LT [Uhr]',
lastWeek: '[letzten] dddd [um] LT [Uhr]'
},
relativeTime: {
future: 'in %s',
past: 'vor %s',
s: 'ein paar Sekunden',
ss: '%d Sekunden',
m: processRelativeTime,
mm: '%d Minuten',
h: processRelativeTime,
hh: '%d Stunden',
d: processRelativeTime,
dd: processRelativeTime,
M: processRelativeTime,
MM: processRelativeTime,
y: processRelativeTime,
yy: processRelativeTime
},
dayOfMonthOrdinalParse: /\d{1,2}\./,
ordinal: '%d.',
week: {
dow: 1,
doy: 4 // The week that contains Jan 4th is the first week of the year.
}
};
// tslint:disable:comment-format binary-expression-operand-order max-line-length
// tslint:disable:no-bitwise prefer-template cyclomatic-complexity
// tslint:disable:no-shadowed-variable switch-default prefer-const
// tslint:disable:one-variable-per-declaration newline-before-return
//! moment.js locale configuration
//! locale : English (United Kingdom) [en-gb]
//! author : Chris Gedrim : https://github.com/chrisgedrim
var enGbLocale = {
abbr: 'en-gb',
months: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
monthsShort: 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
weekdays: 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
weekdaysShort: 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
weekdaysMin: 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
longDateFormat: {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
L: 'DD/MM/YYYY',
LL: 'D MMMM YYYY',
LLL: 'D MMMM YYYY HH:mm',
LLLL: 'dddd, D MMMM YYYY HH:mm'
},
calendar: {
sameDay: '[Today at] LT',
nextDay: '[Tomorrow at] LT',
nextWeek: 'dddd [at] LT',
lastDay: '[Yesterday at] LT',
lastWeek: '[Last] dddd [at] LT',
sameElse: 'L'
},
relativeTime: {
future: 'in %s',
past: '%s ago',
s: 'a few seconds',
ss: '%d seconds',
m: 'a minute',
mm: '%d minutes',
h: 'an hour',
hh: '%d hours',
d: 'a day',
dd: '%d days',
M: 'a month',
MM: '%d months',
y: 'a year',
yy: '%d years'
},
dayOfMonthOrdinalParse: /\d{1,2}(st|nd|rd|th)/,
ordinal: function (_num) {
var num = Number(_num);
var b = num % 10, output = (~~(num % 100 / 10) === 1) ? 'th' :
(b === 1) ? 'st' :
(b === 2) ? 'nd' :
(b === 3) ? 'rd' : 'th';
return num + output;
},
week: {
dow: 1,
doy: 4 // The week that contains Jan 4th is the first week of the year.
}
};
// tslint:disable:comment-format binary-expression-operand-order max-line-length
// tslint:disable:no-bitwise prefer-template cyclomatic-complexity
// tslint:disable:no-shadowed-variable switch-default prefer-const
// tslint:disable:one-variable-per-declaration newline-before-return
//! moment.js locale configuration
//! locale : Spanish [es]
//! author : Julio Napurí : https://github.com/julionc
var monthsShortDot = 'ene._feb._mar._abr._may._jun._jul._ago._sep._oct._nov._dic.'.split('_');
var monthsShort$1 = 'ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic'.split('_');
var monthsParse = [/^ene/i, /^feb/i, /^mar/i, /^abr/i, /^may/i, /^jun/i, /^jul/i, /^ago/i, /^sep/i, /^oct/i, /^nov/i, /^dic/i];
var monthsRegex = /^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre|ene\.?|feb\.?|mar\.?|abr\.?|may\.?|jun\.?|jul\.?|ago\.?|sep\.?|oct\.?|nov\.?|dic\.?)/i;
var esLocale = {
abbr: 'es',
months: 'enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre'.split('_'),
monthsShort: function (date, format, isUTC) {
if (!date) {
return monthsShortDot;
}
if (/-MMM-/.test(format)) {
return monthsShort$1[getMonth(date, isUTC)];
}
return monthsShortDot[getMonth(date, isUTC)];
},
monthsRegex: monthsRegex,
monthsShortRegex: monthsRegex,
monthsStrictRegex: /^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre)/i,
monthsShortStrictRegex: /^(ene\.?|feb\.?|mar\.?|abr\.?|may\.?|jun\.?|jul\.?|ago\.?|sep\.?|oct\.?|nov\.?|dic\.?)/i,
monthsParse: monthsParse,
longMonthsParse: monthsParse,
shortMonthsParse: monthsParse,
weekdays: 'domingo_lunes_martes_miércoles_jueves_viernes_sábado'.split('_'),
weekdaysShort: 'dom._lun._mar._mié._jue._vie._sáb.'.split('_'),
weekdaysMin: 'do_lu_ma_mi_ju_vi_sá'.split('_'),
weekdaysParseExact: true,
longDateFormat: {
LT: 'H:mm',
LTS: 'H:mm:ss',
L: 'DD/MM/YYYY',
LL: 'D [de] MMMM [de] YYYY',
LLL: 'D [de] MMMM [de] YYYY H:mm',
LLLL: 'dddd, D [de] MMMM [de] YYYY H:mm'
},
calendar: {
sameDay: function (date) {
return '[hoy a la' + ((getHours(date) !== 1) ? 's' : '') + '] LT';
},
nextDay: function (date) {
return '[mañana a la' + ((getHours(date) !== 1) ? 's' : '') + '] LT';
},
nextWeek: function (date) {
return 'dddd [a la' + ((getHours(date) !== 1) ? 's' : '') + '] LT';
},
lastDay: function (date) {
return '[ayer a la' + ((getHours(date) !== 1) ? 's' : '') + '] LT';
},
lastWeek: function (date) {
return '[el] dddd [pasado a la' + ((getHours(date) !== 1) ? 's' : '') + '] LT';
},
sameElse: 'L'
},
relativeTime: {
future: 'en %s',
past: 'hace %s',
s: 'unos segundos',
ss: '%d segundos',
m: 'un minuto',
mm: '%d minutos',
h: 'una hora',
hh: '%d horas',
d: 'un día',
dd: '%d días',
M: 'un mes',
MM: '%d meses',
y: 'un año',
yy: '%d años'
},
dayOfMonthOrdinalParse: /\d{1,2}º/,
ordinal: '%dº',
week: {
dow: 1,
doy: 4 // The week that contains Jan 4th is the first week of the year.
}
};
// tslint:disable:comment-format binary-expression-operand-order max-line-length
// tslint:disable:no-bitwise prefer-template cyclomatic-complexity
// tslint:disable:no-shadowed-variable switch-default prefer-const
// tslint:disable:one-variable-per-declaration newline-before-return
//! moment.js locale configuration
//! locale : Spanish (Dominican Republic) [es-do]
var monthsShortDot$1 = 'ene._feb._mar._abr._may._jun._jul._ago._sep._oct._nov._dic.'.split('_');
var monthsShort$2 = 'ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic'.split('_');
var monthsParse$1 = [/^ene/i, /^feb/i, /^mar/i, /^abr/i, /^may/i, /^jun/i, /^jul/i, /^ago/i, /^sep/i, /^oct/i, /^nov/i, /^dic/i];
var monthsRegex$1 = /^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre|ene\.?|feb\.?|mar\.?|abr\.?|may\.?|jun\.?|jul\.?|ago\.?|sep\.?|oct\.?|nov\.?|dic\.?)/i;
var esDoLocale = {
abbr: 'es-do',
months: 'enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre'.split('_'),
monthsShort: function (date, format, isUTC) {
if (!date) {
return monthsShortDot$1;
}
else if (/-MMM-/.test(format)) {
return monthsShort$2[getMonth(date, isUTC)];
}
else {
return monthsShortDot$1[getMonth(date, isUTC)];
}
},
monthsRegex: monthsRegex$1,
monthsShortRegex: monthsRegex$1,
monthsStrictRegex: /^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre)/i,
monthsShortStrictRegex: /^(ene\.?|feb\.?|mar\.?|abr\.?|may\.?|jun\.?|jul\.?|ago\.?|sep\.?|oct\.?|nov\.?|dic\.?)/i,
monthsParse: monthsParse$1,
longMonthsParse: monthsParse$1,
shortMonthsParse: monthsParse$1,
weekdays: 'domingo_lunes_martes_miércoles_jueves_viernes_sábado'.split('_'),
weekdaysShort: 'dom._lun._mar._mié._jue._vie._sáb.'.split('_'),
weekdaysMin: 'do_lu_ma_mi_ju_vi_sá'.split('_'),
weekdaysParseExact: true,
longDateFormat: {
LT: 'h:mm A',
LTS: 'h:mm:ss A',
L: 'DD/MM/YYYY',
LL: 'D [de] MMMM [de] YYYY',
LLL: 'D [de] MMMM [de] YYYY h:mm A',
LLLL: 'dddd, D [de] MMMM [de] YYYY h:mm A'
},
calendar: {
sameDay: function (date) {
return '[hoy a la' + ((getHours(date) !== 1) ? 's' : '') + '] LT';
},
nextDay: function (date) {
return '[mañana a la' + ((getHours(date) !== 1) ? 's' : '') + '] LT';
},
nextWeek: function (date) {
return 'dddd [a la' + ((getHours(date) !== 1) ? 's' : '') + '] LT';
},
lastDay: function (date) {
return '[ayer a la' + ((getHours(date) !== 1) ? 's' : '') + '] LT';
},
lastWeek: function (date) {
return '[el] dddd [pasado a la' + ((getHours(date) !== 1) ? 's' : '') + '] LT';
},
sameElse: 'L'
},
relativeTime: {
future: 'en %s',
past: 'hace %s',
s: 'unos segundos',
ss: '%d segundos',
m: 'un minuto',
mm: '%d minutos',
h: 'una hora',
hh: '%d horas',
d: 'un día',
dd: '%d días',
M: 'un mes',
MM: '%d meses',
y: 'un año',
yy: '%d años'
},
dayOfMonthOrdinalParse: /\d{1,2}º/,
ordinal: '%dº',
week: {
dow: 1,
doy: 4 // The week that contains Jan 4th is the first week of the year.
}
};
// tslint:disable:comment-format binary-expression-operand-order max-line-length
// tslint:disable:no-bitwise prefer-template cyclomatic-complexity
// tslint:disable:no-shadowed-variable switch-default prefer-const
// tslint:disable:one-variable-per-declaration newline-before-return
//! moment.js locale configuration
//! locale : Spanish (United States) [es-us]
//! author : bustta : https://github.com/bustta
var monthsShortDot$2 = 'ene._feb._mar._abr._may._jun._jul._ago._sep._oct._nov._dic.'.split('_');
var monthsShort$3 = 'ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic'.split('_');
var esUsLocale = {
abbr: 'es-us',
months: 'enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre'.split('_'),
monthsShort: function (date, format, isUTC) {
if (!date) {
return monthsShortDot$2;
}
else if (/-MMM-/.test(format)) {
return monthsShort$3[getMonth(date, isUTC)];
}
else {
return monthsShortDot$2[getMonth(date, isUTC)];
}
},
monthsParseExact: true,
weekdays: 'domingo_lunes_martes_miércoles_jueves_viernes_sábado'.split('_'),
weekdaysShort: 'dom._lun._mar._mié._jue._vie._sáb.'.split('_'),
weekdaysMin: 'do_lu_ma_mi_ju_vi_sá'.split('_'),
weekdaysParseExact: true,
longDateFormat: {
LT: 'h:mm A',
LTS: 'h:mm:ss A',
L: 'MM/DD/YYYY',
LL: 'MMMM [de] D [de] YYYY',
LLL: 'MMMM [de] D [de] YYYY h:mm A',
LLLL: 'dddd, MMMM [de] D [de] YYYY h:mm A'
},
calendar: {
sameDay: function (date) {
return '[hoy a la' + ((getHours(date) !== 1) ? 's' : '') + '] LT';
},
nextDay: function (date) {
return '[mañana a la' + ((getHours(date) !== 1) ? 's' : '') + '] LT';
},
nextWeek: function (date) {
return 'dddd [a la' + ((getHours(date) !== 1) ? 's' : '') + '] LT';
},
lastDay: function (date) {
return '[ayer a la' + ((getHours(date) !== 1) ? 's' : '') + '] LT';
},
lastWeek: function (date) {
return '[el] dddd [pasado a la' + ((getHours(date) !== 1) ? 's' : '') + '] LT';
},
sameElse: 'L'
},
relativeTime: {
future: 'en %s',
past: 'hace %s',
s: 'unos segundos',
ss: '%d segundos',
m: 'un minuto',
mm: '%d minutos',
h: 'una hora',
hh: '%d horas',
d: 'un día',
dd: '%d días',
M: 'un mes',
MM: '%d meses',
y: 'un año',
yy: '%d años'
},
dayOfMonthOrdinalParse: /\d{1,2}º/,
ordinal: '%dº',
week: {
dow: 0,
doy: 6 // The week that contains Jan 1st is the first week of the year.
}
};
// tslint:disable:comment-format binary-expression-operand-order max-line-length
// tslint:disable:no-bitwise prefer-template cyclomatic-complexity
// tslint:disable:no-shadowed-variable switch-default prefer-const
// tslint:disable:one-variable-per-declaration newline-before-return
//! moment.js locale configuration
// https://github.com/moment/moment/blob/develop/locale/fi.js
var numbersPast = 'nolla yksi kaksi kolme neljä viisi kuusi seitsemän kahdeksan yhdeksän'.split(' ');
var numbersFuture = [
'nolla', 'yhden', 'kahden', 'kolmen', 'neljän', 'viiden', 'kuuden',
numbersPast[7], numbersPast[8], numbersPast[9]
];
function translate$1(num, withoutSuffix, key, isFuture) {
var result = '';
switch (key) {
case 's':
return isFuture ? 'muutaman sekunnin' : 'muutama sekunti';
case 'ss':
return isFuture ? 'sekunnin' : 'sekuntia';
case 'm':
return isFuture ? 'minuutin' : 'minuutti';
case 'mm':
result = isFuture ? 'minuutin' : 'minuuttia';
break;
case 'h':
return isFuture ? 'tunnin' : 'tunti';
case 'hh':
result = isFuture ? 'tunnin' : 'tuntia';
break;
case 'd':
return isFuture ? 'päivän' : 'päivä';
case 'dd':
result = isFuture ? 'päivän' : 'päivää';
break;
case 'M':
return isFuture ? 'kuukauden' : 'kuukausi';
case 'MM':
result = isFuture ? 'kuukauden' : 'kuukautta';
break;
case 'y':
return isFuture ? 'vuoden' : 'vuosi';
case 'yy':
result = isFuture ? 'vuoden' : 'vuotta';
break;
}
result = verbalNumber(num, isFuture) + ' ' + result;
return result;
}
function verbalNumber(num, isFuture) {
return num < 10 ? (isFuture ? numbersFuture[num] : numbersPast[num]) : num;
}
var fiLocale = {
abbr: 'fi',
months: 'tammikuu_helmikuu_maaliskuu_huhtikuu_toukokuu_kesäkuu_heinäkuu_elokuu_syyskuu_lokakuu_marraskuu_joulukuu'.split('_'),
monthsShort: 'tammi_helmi_maalis_huhti_touko_kesä_heinä_elo_syys_loka_marras_joulu'.split('_'),
weekdays: 'sunnuntai_maanantai_tiistai_keskiviikko_torstai_perjantai_lauantai'.split('_'),
weekdaysShort: 'su_ma_ti_ke_to_pe_la'.split('_'),
weekdaysMin: 'su_ma_ti_ke_to_pe_la'.split('_'),
longDateFormat: {
LT: 'HH.mm',
LTS: 'HH.mm.ss',
L: 'DD.MM.YYYY',
LL: 'Do MMMM[ta] YYYY',
LLL: 'Do MMMM[ta] YYYY, [klo] HH.mm',
LLLL: 'dddd, Do MMMM[ta] YYYY, [klo] HH.mm',
l: 'D.M.YYYY',
ll: 'Do MMM YYYY',
lll: 'Do MMM YYYY, [klo] HH.mm',
llll: 'ddd, Do MMM YYYY, [klo] HH.mm'
},
calendar: {
sameDay: '[tänään] [klo] LT',
nextDay: '[huomenna] [klo] LT',
nextWeek: 'dddd [klo] LT',
lastDay: '[eilen] [klo] LT',
lastWeek: '[viime] dddd[na] [klo] LT',
sameElse: 'L'
},
relativeTime: {
future: '%s päästä',
past: '%s sitten',
s: translate$1,
ss: translate$1,
m: translate$1,
mm: translate$1,
h: translate$1,
hh: translate$1,
d: translate$1,
dd: translate$1,
M: translate$1,
MM: translate$1,
y: translate$1,
yy: translate$1
},
dayOfMonthOrdinalParse: /\d{1,2}\./,
ordinal: '%d.',
week: {
dow: 1,
doy: 4 // The week that contains Jan 4th is the first week of the year.
}
};
// tslint:disable:comment-format binary-expression-operand-order max-line-length
// tslint:disable:no-bitwise prefer-template cyclomatic-complexity
// tslint:disable:no-shadowed-variable switch-default prefer-const
// tslint:disable:one-variable-per-declaration newline-before-return
//! moment.js locale configuration
//! locale : French [fr]
//! author : John Fischer : https://github.com/jfroffice
var frLocale = {
abbr: 'fr',
months: 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'),
monthsShort: 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'),
monthsParseExact: true,
weekdays: 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
weekdaysShort: 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
weekdaysMin: 'di_lu_ma_me_je_ve_sa'.split('_'),
weekdaysParseExact: true,
longDateFormat: {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
L: 'DD/MM/YYYY',
LL: 'D MMMM YYYY',
LLL: 'D MMMM YYYY HH:mm',
LLLL: 'dddd D MMMM YYYY HH:mm'
},
calendar: {
sameDay: '[Aujourd’hui à] LT',
nextDay: '[Demain à] LT',
nextWeek: 'dddd [à] LT',
lastDay: '[Hier à] LT',
lastWeek: 'dddd [dernier à] LT',
sameElse: 'L'
},
relativeTime: {
future: 'dans %s',
past: 'il y a %s',
s: 'quelques secondes',
ss: '%d secondes',
m: 'une minute',
mm: '%d minutes',
h: 'une heure',
hh: '%d heures',
d: 'un jour',
dd: '%d jours',
M: 'un mois',
MM: '%d mois',
y: 'un an',
yy: '%d ans'
},
dayOfMonthOrdinalParse: /\d{1,2}(er|)/,
ordinal: function (_num, period) {
var num = Number(_num);
switch (period) {
// TODO: Return 'e' when day of month > 1. Move this case inside
// block for masculine words below.
// See https://github.com/moment/moment/issues/3375
case 'D':
return num + (num === 1 ? 'er' : '');
// Words with masculine grammatical gender: mois, trimestre, jour
default:
case 'M':
case 'Q':
case 'DDD':
case 'd':
return num + (num === 1 ? 'er' : 'e');
// Words with feminine grammatical gender: semaine
case 'w':
case 'W':
return num + (num === 1 ? 're' : 'e');
}
},
week: {
dow: 1,
doy: 4 // The week that contains Jan 4th is the first week of the year.
}
};
// tslint:disable:comment-format binary-expression-operand-order max-line-length
// tslint:disable:no-bitwise prefer-template cyclomatic-complexity
// tslint:disable:no-shadowed-variable switch-default prefer-const
// tslint:disable:one-variable-per-declaration newline-before-return
// tslint:disable:no-parameter-reassignment prefer-switch
//! moment.js locale configuration
//! locale : Hindi [hi]
//! author : Mayank Singhal : https://github.com/mayanksinghal
var symbolMap$1 = {
1: '१',
2: '२',
3: '३',
4: '४',
5: '५',
6: '६',
7: '७',
8: '८',
9: '९',
0: '०'
};
var numberMap$1 = {
'१': '1',
'२': '2',
'३': '3',
'४': '4',
'५': '5',
'६': '6',
'७': '7',
'८': '8',
'९': '9',
'०': '0'
};
var hiLocale = {
abbr: 'hi',
months: 'जनवरी_फ़रवरी_मार्च_अप्रैल_मई_जून_जुलाई_अगस्त_सितम्बर_अक्टूबर_नवम्बर_दिसम्बर'.split('_'),
monthsShort: 'जन._फ़र._मार्च_अप्रै._मई_जून_जुल._अग._सित._अक्टू._नव._दिस.'.split('_'),
monthsParseExact: true,
weekdays: 'रविवार_सोमवार_मंगलवार_बुधवार_गुरूवार_शुक्रवार_शनिवार'.split('_'),
weekdaysShort: 'रवि_सोम_मंगल_बुध_गुरू_शुक्र_शनि'.split('_'),
weekdaysMin: 'र_सो_मं_बु_गु_शु_श'.split('_'),
longDateFormat: {
LT: 'A h:mm बजे',
LTS: 'A h:mm:ss बजे',
L: 'DD/MM/YYYY',
LL: 'D MMMM YYYY',
LLL: 'D MMMM YYYY, A h:mm बजे',
LLLL: 'dddd, D MMMM YYYY, A h:mm बजे'
},
calendar: {
sameDay: '[आज] LT',
nextDay: '[कल] LT',
nextWeek: 'dddd, LT',
lastDay: '[कल] LT',
lastWeek: '[पिछले] dddd, LT',
sameElse: 'L'
},
relativeTime: {
future: '%s में',
past: '%s पहले',
s: 'कुछ ही क्षण',
ss: '%d सेकंड',
m: 'एक मिनट',
mm: '%d मिनट',
h: 'एक घंटा',
hh: '%d घंटे',
d: 'एक दिन',
dd: '%d दिन',
M: 'एक महीने',
MM: '%d महीने',
y: 'एक वर्ष',
yy: '%d वर्ष'
},
preparse: function (str) {
return str.replace(/[१२३४५६७८९०]/g, function (match) {
return numberMap$1[match];
});
},
postformat: function (str) {
return str.replace(/\d/g, function (match) {
return symbolMap$1[match];
});
},
// Hindi notation for meridiems are quite fuzzy in practice. While there exists
// a rigid notion of a 'Pahar' it is not used as rigidly in modern Hindi.
meridiemParse: /रात|सुबह|दोपहर|शाम/,
meridiemHour: function (hour, meridiem) {
if (hour === 12) {
hour = 0;
}
if (meridiem === 'रात') {
return hour < 4 ? hour : hour + 12;
}
else if (meridiem === 'सुबह') {
return hour;
}
else if (meridiem === 'दोपहर') {
return hour >= 10 ? hour : hour + 12;
}
else if (meridiem === 'शाम') {
return hour + 12;
}
},
meridiem: function (hour, minute, isLower) {
if (hour < 4) {
return 'रात';
}
else if (hour < 10) {
return 'सुबह';
}
else if (hour < 17) {
return 'दोपहर';
}
else if (hour < 20) {
return 'शाम';
}
else {
return 'रात';
}
},
week: {
dow: 0,
doy: 6 // The week that contains Jan 1st is the first week of the year.
}
};
// tslint:disable:comment-format binary-expression-operand-order max-line-length
// tslint:disable:no-bitwise prefer-template cyclomatic-complexity
// tslint:disable:no-shadowed-variable switch-default prefer-const
// tslint:disable:one-variable-per-declaration newline-before-return
//! moment.js locale configuration
//! locale : Hungarian [hu]
//! author : Adam Brunner : https://github.com/adambrunner
var weekEndings = 'vasárnap hétfőn kedden szerdán csütörtökön pénteken szombaton'.split(' ');
function translate$2(num, withoutSuffix, key, isFuture) {
switch (key) {
case 's':
return (isFuture || withoutSuffix) ? 'néhány másodperc' : 'néhány másodperce';
case 'ss':
return num + ((isFuture || withoutSuffix) ? ' másodperc' : ' másodperce');
case 'm':
return 'egy' + (isFuture || withoutSuffix ? ' perc' : ' perce');
case 'mm':
return num + (isFuture || withoutSuffix ? ' perc' : ' perce');
case 'h':
return 'egy' + (isFuture || withoutSuffix ? ' óra' : ' órája');
case 'hh':
return num + (isFuture || withoutSuffix ? ' óra' : ' órája');
case 'd':
return 'egy' + (isFuture || withoutSuffix ? ' nap' : ' napja');
case 'dd':
return num + (isFuture || withoutSuffix ? ' nap' : ' napja');
case 'M':
return 'egy' + (isFuture || withoutSuffix ? ' hónap' : ' hónapja');
case 'MM':
return num + (isFuture || withoutSuffix ? ' hónap' : ' hónapja');
case 'y':
return 'egy' + (isFuture || withoutSuffix ? ' év' : ' éve');
case 'yy':
return num + (isFuture || withoutSuffix ? ' év' : ' éve');
}
return '';
}
function week(date, isFuture) {
return (isFuture ? '' : '[múlt] ') + '[' + weekEndings[getDayOfWeek(date)] + '] LT[-kor]';
}
var huLocale = {
abbr: 'hu',
months: 'január_február_március_április_május_június_július_augusztus_szeptember_október_november_december'.split('_'),
monthsShort: 'jan_feb_márc_ápr_máj_jún_júl_aug_szept_okt_nov_dec'.split('_'),
weekdays: 'vasárnap_hétfő_kedd_szerda_csütörtök_péntek_szombat'.split('_'),
weekdaysShort: 'vas_hét_kedd_sze_csüt_pén_szo'.split('_'),
weekdaysMin: 'v_h_k_sze_cs_p_szo'.split('_'),
longDateFormat: {
LT: 'H:mm',
LTS: 'H:mm:ss',
L: 'YYYY.MM.DD.',
LL: 'YYYY. MMMM D.',
LLL: 'YYYY. MMMM D. H:mm',
LLLL: 'YYYY. MMMM D., dddd H:mm'
},
meridiemParse: /de|du/i,
isPM: function (input) {
return input.charAt(1).toLowerCase() === 'u';
},
meridiem: function (hours, minutes, isLower) {
if (hours < 12) {
return isLower === true ? 'de' : 'DE';
}
else {
return isLower === true ? 'du' : 'DU';
}
},
calendar: {
sameDay: '[ma] LT[-kor]',
nextDay: '[holnap] LT[-kor]',
nextWeek: function (date) {
return week(date, true);
},
lastDay: '[tegnap] LT[-kor]',
lastWeek: function (date) {
return week(date, false);
},
sameElse: 'L'
},
relativeTime: {
future: '%s múlva',
past: '%s',
s: translate$2,
ss: translate$2,
m: translate$2,
mm: translate$2,
h: translate$2,
hh: translate$2,
d: translate$2,
dd: translate$2,
M: translate$2,
MM: translate$2,
y: translate$2,
yy: translate$2
},
dayOfMonthOrdinalParse: /\d{1,2}\./,
ordinal: '%d.',
week: {
dow: 1,
doy: 4 // The week that contains Jan 4th is the first week of the year.
}
};
// tslint:disable:comment-format binary-expression-operand-order max-line-length
// tslint:disable:no-bitwise prefer-template cyclomatic-complexity
// tslint:disable:no-shadowed-variable switch-default prefer-const
// tslint:disable:one-variable-per-declaration newline-before-return
// tslint:disable:no-parameter-reassignment prefer-switch
//! moment.js locale configuration
//! locale : Indonesia [id]
//! author : Romy Kusuma : https://github.com/rkusuma
//! reference: https://github.com/moment/moment/blob/develop/locale/id.js
var idLocale = {
abbr: 'id',
months: 'Januari_Februari_Maret_April_Mei_Juni_Juli_Agustus_September_Oktober_November_Desember'.split('_'),
monthsShort: 'Jan_Feb_Mar_Apr_Mei_Jun_Jul_Ags_Sep_Okt_Nov_Des'.split('_'),
weekdays: 'Minggu_Senin_Selasa_Rabu_Kamis_Jumat_Sabtu'.split('_'),
weekdaysShort: 'Min_Sen_Sel_Rab_Kam_Jum_Sab'.split('_'),
weekdaysMin: 'Mg_Sn_Sl_Rb_Km_Jm_Sb'.split('_'),
longDateFormat: {
LT: 'HH.mm',
LTS: 'HH.mm.ss',
L: 'DD/MM/YYYY',
LL: 'D MMMM YYYY',
LLL: 'D MMMM YYYY [pukul] HH.mm',
LLLL: 'dddd, D MMMM YYYY [pukul] HH.mm'
},
meridiemParse: /pagi|siang|sore|malam/,
meridiemHour: function (hour, meridiem) {
if (hour === 12) {
hour = 0;
}
if (meridiem === 'pagi') {
return hour;
}
else if (meridiem === 'siang') {
return hour >= 11 ? hour : hour + 12;
}
else if (meridiem === 'sore' || meridiem === 'malam') {
return hour + 12;
}
},
meridiem: function (hours, minutes, isLower) {
if (hours < 11) {
return 'pagi';
}
else if (hours < 15) {
return 'siang';
}
else if (hours < 19) {
return 'sore';
}
else {
return 'malam';
}
},
calendar: {
sameDay: '[Hari ini pukul] LT',
nextDay: '[Besok pukul] LT',
nextWeek: 'dddd [pukul] LT',
lastDay: '[Kemarin pukul] LT',
lastWeek: 'dddd [lalu pukul] LT',
sameElse: 'L'
},
relativeTime: {
future: 'dalam %s',
past: '%s yang lalu',
s: 'beberapa detik',
ss: '%d detik',
m: 'semenit',
mm: '%d menit',
h: 'sejam',
hh: '%d jam',
d: 'sehari',
dd: '%d hari',
M: 'sebulan',
MM: '%d bulan',
y: 'setahun',
yy: '%d tahun'
},
week: {
dow: 1,
doy: 7 // The week that contains Jan 1st is the first week of the year.
}
};
// tslint:disable:comment-format binary-expression-operand-order max-line-length
// tslint:disable:no-bitwise prefer-template cyclomatic-complexity
// tslint:disable:no-shadowed-variable switch-default prefer-const
// tslint:disable:one-variable-per-declaration newline-before-return
//! moment.js locale configuration
//! locale : Italian [it]
//! author : Lorenzo : https://github.com/aliem
//! author: Mattia Larentis: https://github.com/nostalgiaz
var itLocale = {
abbr: 'it',
months: 'gennaio_febbraio_marzo_aprile_maggio_giugno_luglio_agosto_settembre_ottobre_novembre_dicembre'.split('_'),
monthsShort: 'gen_feb_mar_apr_mag_giu_lug_ago_set_ott_nov_dic'.split('_'),
weekdays: 'domenica_lunedì_martedì_mercoledì_giovedì_venerdì_sabato'.split('_'),
weekdaysShort: 'dom_lun_mar_mer_gio_ven_sab'.split('_'),
weekdaysMin: 'do_lu_ma_me_gi_ve_sa'.split('_'),
longDateFormat: {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
L: 'DD/MM/YYYY',
LL: 'D MMMM YYYY',
LLL: 'D MMMM YYYY HH:mm',
LLLL: 'dddd D MMMM YYYY HH:mm'
},
calendar: {
sameDay: '[Oggi alle] LT',
nextDay: '[Domani alle] LT',
nextWeek: 'dddd [alle] LT',
lastDay: '[Ieri alle] LT',
lastWeek: function (date) {
switch (getDayOfWeek(date)) {
case 0:
return '[la scorsa] dddd [alle] LT';
default:
return '[lo scorso] dddd [alle] LT';
}
},
sameElse: 'L'
},
relativeTime: {
future: function (num) {
return ((/^[0-9].+$/).test(num.toString(10)) ? 'tra' : 'in') + ' ' + num;
},
past: '%s fa',
s: 'alcuni secondi',
ss: '%d secondi',
m: 'un minuto',
mm: '%d minuti',
h: 'un\'ora',
hh: '%d ore',
d: 'un giorno',
dd: '%d giorni',
M: 'un mese',
MM: '%d mesi',
y: 'un anno',
yy: '%d anni'
},
dayOfMonthOrdinalParse: /\d{1,2}º/,
ordinal: '%dº',
week: {
dow: 1,
doy: 4 // The week that contains Jan 4th is the first week of the year.
}
};
// tslint:disable:comment-format binary-expression-operand-order max-line-length
// tslint:disable:no-bitwise prefer-template cyclomatic-complexity
// tslint:disable:no-shadowed-variable switch-default prefer-const
// tslint:disable:one-variable-per-declaration newline-before-return
//! moment.js locale configuration
//! locale : Japanese [ja]
//! author : LI Long : https://github.com/baryon
var jaLocale = {
abbr: 'ja',
months: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
weekdays: '日曜日_月曜日_火曜日_水曜日_木曜日_金曜日_土曜日'.split('_'),
weekdaysShort: '日_月_火_水_木_金_土'.split('_'),
weekdaysMin: '日_月_火_水_木_金_土'.split('_'),
longDateFormat: {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
L: 'YYYY/MM/DD',
LL: 'YYYY年M月D日',
LLL: 'YYYY年M月D日 HH:mm',
LLLL: 'YYYY年M月D日 HH:mm dddd',
l: 'YYYY/MM/DD',
ll: 'YYYY年M月D日',
lll: 'YYYY年M月D日 HH:mm',
llll: 'YYYY年M月D日 HH:mm dddd'
},
meridiemParse: /午前|午後/i,
isPM: function (input) {
return input === '午後';
},
meridiem: function (hour, minute, isLower) {
if (hour < 12) {
return '午前';
}
else {
return '午後';
}
},
calendar: {
sameDay: '[今日] LT',
nextDay: '[明日] LT',
nextWeek: '[来週]dddd LT',
lastDay: '[昨日] LT',
lastWeek: '[前週]dddd LT',
sameElse: 'L'
},
dayOfMonthOrdinalParse: /\d{1,2}日/,
ordinal: function (num, period) {
switch (period) {
case 'd':
case 'D':
case 'DDD':
return num + '日';
default:
return num.toString(10);
}
},
relativeTime: {
future: '%s後',
past: '%s前',
s: '数秒',
ss: '%d秒',
m: '1分',
mm: '%d分',
h: '1時間',
hh: '%d時間',
d: '1日',
dd: '%d日',
M: '1ヶ月',
MM: '%dヶ月',
y: '1年',
yy: '%d年'
}
};
// tslint:disable:comment-format binary-expression-operand-order max-line-length
// tslint:disable:no-bitwise prefer-template cyclomatic-complexity
// tslint:disable:no-shadowed-variable switch-default prefer-const
// tslint:disable:one-variable-per-declaration newline-before-return
// tslint:disable:object-literal-shorthand
//! moment.js locale configuration
//! locale : Korean [ko]
//! author : Kyungwook, Park : https://github.com/kyungw00k
//! author : Jeeeyul Lee <jeeeyul@gmail.com>
var koLocale = {
abbr: 'ko',
months: '1월_2월_3월_4월_5월_6월_7월_8월_9월_10월_11월_12월'.split('_'),
monthsShort: '1월_2월_3월_4월_5월_6월_7월_8월_9월_10월_11월_12월'.split('_'),
weekdays: '일요일_월요일_화요일_수요일_목요일_금요일_토요일'.split('_'),
weekdaysShort: '일_월_화_수_목_금_토'.split('_'),
weekdaysMin: '일_월_화_수_목_금_토'.split('_'),
longDateFormat: {
LT: 'A h:mm',
LTS: 'A h:mm:ss',
L: 'YYYY.MM.DD',
LL: 'YYYY년 MMMM D일',
LLL: 'YYYY년 MMMM D일 A h:mm',
LLLL: 'YYYY년 MMMM D일 dddd A h:mm',
l: 'YYYY.MM.DD',
ll: 'YYYY년 MMMM D일',
lll: 'YYYY년 MMMM D일 A h:mm',
llll: 'YYYY년 MMMM D일 dddd A h:mm'
},
calendar: {
sameDay: '오늘 LT',
nextDay: '내일 LT',
nextWeek: 'dddd LT',
lastDay: '어제 LT',
lastWeek: '지난주 dddd LT',
sameElse: 'L'
},
relativeTime: {
future: '%s 후',
past: '%s 전',
s: '몇 초',
ss: '%d초',
m: '1분',
mm: '%d분',
h: '한 시간',
hh: '%d시간',
d: '하루',
dd: '%d일',
M: '한 달',
MM: '%d달',
y: '일 년',
yy: '%d년'
},
dayOfMonthOrdinalParse: /\d{1,2}(일|월|주)/,
ordinal: function (num, period) {
switch (period) {
case 'd':
case 'D':
case 'DDD':
return num + '일';
case 'M':
return num + '월';
case 'w':
case 'W':
return num + '주';
default:
return num.toString(10);
}
},
meridiemParse: /오전|오후/,
isPM: function (token) {
return token === '오후';
},
meridiem: function (hour, minute, isUpper) {
return hour < 12 ? '오전' : '오후';
}
};
// tslint:disable:comment-format binary-expression-operand-order max-line-length
// tslint:disable:no-bitwise prefer-template cyclomatic-complexity
// tslint:disable:no-shadowed-variable switch-default prefer-const
// tslint:disable:one-variable-per-declaration newline-before-return
//! moment.js locale configuration
//! locale : Dutch [nl]
//! author : Joris Röling : https://github.com/jorisroling
//! author : Jacob Middag : https://github.com/middagj
var monthsShortWithDots = 'jan._feb._mrt._apr._mei_jun._jul._aug._sep._okt._nov._dec.'.split('_');
var monthsShortWithoutDots = 'jan_feb_mrt_apr_mei_jun_jul_aug_sep_okt_nov_dec'.split('_');
var monthsParse$2 = [/^jan/i, /^feb/i, /^maart|mrt.?$/i, /^apr/i, /^mei$/i, /^jun[i.]?$/i, /^jul[i.]?$/i, /^aug/i, /^sep/i, /^okt/i, /^nov/i, /^dec/i];
var monthsRegex$2 = /^(januari|februari|maart|april|mei|april|ju[nl]i|augustus|september|oktober|november|december|jan\.?|feb\.?|mrt\.?|apr\.?|ju[nl]\.?|aug\.?|sep\.?|okt\.?|nov\.?|dec\.?)/i;
var nlLocale = {
abbr: 'nl',
months: 'januari_februari_maart_april_mei_juni_juli_augustus_september_oktober_november_december'.split('_'),
monthsShort: function (date, format, isUTC) {
if (!date) {
return monthsShortWithDots;
}
else if (/-MMM-/.test(format)) {
return monthsShortWithoutDots[getMonth(date, isUTC)];
}
else {
return monthsShortWithDots[getMonth(date, isUTC)];
}
},
monthsRegex: monthsRegex$2,
monthsShortRegex: monthsRegex$2,
monthsStrictRegex: /^(januari|februari|maart|mei|ju[nl]i|april|augustus|september|oktober|november|december)/i,
monthsShortStrictRegex: /^(jan\.?|feb\.?|mrt\.?|apr\.?|mei|ju[nl]\.?|aug\.?|sep\.?|okt\.?|nov\.?|dec\.?)/i,
monthsParse: monthsParse$2,
longMonthsParse: monthsParse$2,
shortMonthsParse: monthsParse$2,
weekdays: 'zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag'.split('_'),
weekdaysShort: 'zo._ma._di._wo._do._vr._za.'.split('_'),
weekdaysMin: 'zo_ma_di_wo_do_vr_za'.split('_'),
weekdaysParseExact: true,
longDateFormat: {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
L: 'DD-MM-YYYY',
LL: 'D MMMM YYYY',
LLL: 'D MMMM YYYY HH:mm',
LLLL: 'dddd D MMMM YYYY HH:mm'
},
calendar: {
sameDay: '[vandaag om] LT',
nextDay: '[morgen om] LT',
nextWeek: 'dddd [om] LT',
lastDay: '[gisteren om] LT',
lastWeek: '[afgelopen] dddd [om] LT',
sameElse: 'L'
},
relativeTime: {
future: 'over %s',
past: '%s geleden',
s: 'een paar seconden',
ss: '%d seconden',
m: 'één minuut',
mm: '%d minuten',
h: 'één uur',
hh: '%d uur',
d: 'één dag',
dd: '%d dagen',
M: 'één maand',
MM: '%d maanden',
y: 'één jaar',
yy: '%d jaar'
},
dayOfMonthOrdinalParse: /\d{1,2}(ste|de)/,
ordinal: function (_num) {
var num = Number(_num);
return num + ((num === 1 || num === 8 || num >= 20) ? 'ste' : 'de');
},
week: {
dow: 1,
doy: 4 // The week that contains Jan 4th is the first week of the year.
}
};
// tslint:disable:comment-format binary-expression-operand-order max-line-length
// tslint:disable:no-bitwise prefer-template cyclomatic-complexity
// tslint:disable:no-shadowed-variable switch-default prefer-const
// tslint:disable:one-variable-per-declaration newline-before-return
//! moment.js locale configuration
//! locale : Dutch (Belgium) [nl-be]
//! author : Joris Röling : https://github.com/jorisroling
//! author : Jacob Middag : https://github.com/middagj
var monthsShortWithDots$1 = 'jan._feb._mrt._apr._mei_jun._jul._aug._sep._okt._nov._dec.'.split('_');
var monthsShortWithoutDots$1 = 'jan_feb_mrt_apr_mei_jun_jul_aug_sep_okt_nov_dec'.split('_');
var monthsParse$3 = [/^jan/i, /^feb/i, /^maart|mrt.?$/i, /^apr/i, /^mei$/i, /^jun[i.]?$/i, /^jul[i.]?$/i, /^aug/i, /^sep/i, /^okt/i, /^nov/i, /^dec/i];
var monthsRegex$3 = /^(januari|februari|maart|april|mei|april|ju[nl]i|augustus|september|oktober|november|december|jan\.?|feb\.?|mrt\.?|apr\.?|ju[nl]\.?|aug\.?|sep\.?|okt\.?|nov\.?|dec\.?)/i;
var nlBeLocale = {
abbr: 'nl-be',
months: 'januari_februari_maart_april_mei_juni_juli_augustus_september_oktober_november_december'.split('_'),
monthsShort: function (date, format, isUTC) {
if (!date) {
return monthsShortWithDots$1;
}
else if (/-MMM-/.test(format)) {
return monthsShortWithoutDots$1[getMonth(date, isUTC)];
}
else {
return monthsShortWithDots$1[getMonth(date, isUTC)];
}
},
monthsRegex: monthsRegex$3,
monthsShortRegex: monthsRegex$3,
monthsStrictRegex: /^(januari|februari|maart|mei|ju[nl]i|april|augustus|september|oktober|november|december)/i,
monthsShortStrictRegex: /^(jan\.?|feb\.?|mrt\.?|apr\.?|mei|ju[nl]\.?|aug\.?|sep\.?|okt\.?|nov\.?|dec\.?)/i,
monthsParse: monthsParse$3,
longMonthsParse: monthsParse$3,
shortMonthsParse: monthsParse$3,
weekdays: 'zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag'.split('_'),
weekdaysShort: 'zo._ma._di._wo._do._vr._za.'.split('_'),
weekdaysMin: 'zo_ma_di_wo_do_vr_za'.split('_'),
weekdaysParseExact: true,
longDateFormat: {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
L: 'DD/MM/YYYY',
LL: 'D MMMM YYYY',
LLL: 'D MMMM YYYY HH:mm',
LLLL: 'dddd D MMMM YYYY HH:mm'
},
calendar: {
sameDay: '[vandaag om] LT',
nextDay: '[morgen om] LT',
nextWeek: 'dddd [om] LT',
lastDay: '[gisteren om] LT',
lastWeek: '[afgelopen] dddd [om] LT',
sameElse: 'L'
},
relativeTime: {
future: 'over %s',
past: '%s geleden',
s: 'een paar seconden',
ss: '%d seconden',
m: 'één minuut',
mm: '%d minuten',
h: 'één uur',
hh: '%d uur',
d: 'één dag',
dd: '%d dagen',
M: 'één maand',
MM: '%d maanden',
y: 'één jaar',
yy: '%d jaar'
},
dayOfMonthOrdinalParse: /\d{1,2}(ste|de)/,
ordinal: function (_num) {
var num = Number(_num);
return num + ((num === 1 || num === 8 || num >= 20) ? 'ste' : 'de');
},
week: {
dow: 1,
doy: 4 // The week that contains Jan 4th is the first week of the year.
}
};
// tslint:disable:comment-format binary-expression-operand-order max-line-length
// tslint:disable:no-bitwise prefer-template cyclomatic-complexity
// tslint:disable:no-shadowed-variable switch-default prefer-const
// tslint:disable:one-variable-per-declaration newline-before-return
//! moment.js locale configuration
//! locale : Polish [pl]
//! author : Rafal Hirsz : https://github.com/evoL
var monthsNominative = 'styczeń_luty_marzec_kwiecień_maj_czerwiec_lipiec_sierpień_wrzesień_październik_listopad_grudzień'.split('_');
var monthsSubjective = 'stycznia_lutego_marca_kwietnia_maja_czerwca_lipca_sierpnia_września_października_listopada_grudnia'.split('_');
function plural$1(num) {
return (num % 10 < 5) && (num % 10 > 1) && ((~~(num / 10) % 10) !== 1);
}
function translate$3(num, withoutSuffix, key) {
var result = num + ' ';
switch (key) {
case 'ss':
return result + (plural$1(num) ? 'sekundy' : 'sekund');
case 'm':
return withoutSuffix ? 'minuta' : 'minutę';
case 'mm':
return result + (plural$1(num) ? 'minuty' : 'minut');
case 'h':
return withoutSuffix ? 'godzina' : 'godzinę';
case 'hh':
return result + (plural$1(num) ? 'godziny' : 'godzin');
case 'MM':
return result + (plural$1(num) ? 'miesiące' : 'miesięcy');
case 'yy':
return result + (plural$1(num) ? 'lata' : 'lat');
}
}
var plLocale = {
abbr: 'pl',
months: function (date, format, isUTC) {
if (!date) {
return monthsNominative;
}
else if (format === '') {
// Hack: if format empty we know this is used to generate
// RegExp by moment. Give then back both valid forms of months
// in RegExp ready format.
return '(' + monthsSubjective[getMonth(date, isUTC)] + '|' + monthsNominative[getMonth(date, isUTC)] + ')';
}
else if (/D MMMM/.test(format)) {
return monthsSubjective[getMonth(date, isUTC)];
}
else {
return monthsNominative[getMonth(date, isUTC)];
}
},
monthsShort: 'sty_lut_mar_kwi_maj_cze_lip_sie_wrz_paź_lis_gru'.split('_'),
weekdays: 'niedziela_poniedziałek_wtorek_środa_czwartek_piątek_sobota'.split('_'),
weekdaysShort: 'ndz_pon_wt_śr_czw_pt_sob'.split('_'),
weekdaysMin: 'Nd_Pn_Wt_Śr_Cz_Pt_So'.split('_'),
longDateFormat: {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
L: 'DD.MM.YYYY',
LL: 'D MMMM YYYY',
LLL: 'D MMMM YYYY HH:mm',
LLLL: 'dddd, D MMMM YYYY HH:mm'
},
calendar: {
sameDay: '[Dziś o] LT',
nextDay: '[Jutro o] LT',
nextWeek: function (date) {
switch (getDayOfWeek(date)) {
case 0:
return '[W niedzielę o] LT';
case 2:
return '[We wtorek o] LT';
case 3:
return '[W środę o] LT';
case 6:
return '[W sobotę o] LT';
default:
return '[W] dddd [o] LT';
}
},
lastDay: '[Wczoraj o] LT',
lastWeek: function (date) {
switch (getDayOfWeek(date)) {
case 0:
return '[W zeszłą niedzielę o] LT';
case 3:
return '[W zeszłą środę o] LT';
case 6:
return '[W zeszłą sobotę o] LT';
default:
return '[W zeszły] dddd [o] LT';
}
},
sameElse: 'L'
},
relativeTime: {
future: 'za %s',
past: '%s temu',
s: 'kilka sekund',
ss: translate$3,
m: translate$3,
mm: translate$3,
h: translate$3,
hh: translate$3,
d: '1 dzień',
dd: '%d dni',
M: 'miesiąc',
MM: translate$3,
y: 'rok',
yy: translate$3
},
dayOfMonthOrdinalParse: /\d{1,2}\./,
ordinal: '%d.',
week: {
dow: 1,
doy: 4 // The week that contains Jan 4th is the first week of the year.
}
};
// tslint:disable:comment-format binary-expression-operand-order max-line-length
// tslint:disable:no-bitwise prefer-template cyclomatic-complexity
// tslint:disable:no-shadowed-variable switch-default prefer-const
// tslint:disable:one-variable-per-declaration newline-before-return
//! moment.js locale configuration
//! locale : Portuguese (Brazil) [pt-br]
//! author : Caio Ribeiro Pereira : https://github.com/caio-ribeiro-pereira
var ptBrLocale = {
abbr: 'pt-br',
months: 'janeiro_fevereiro_março_abril_maio_junho_julho_agosto_setembro_outubro_novembro_dezembro'.split('_'),
monthsShort: 'jan_fev_mar_abr_mai_jun_jul_ago_set_out_nov_dez'.split('_'),
weekdays: 'Domingo_Segunda-feira_Terça-feira_Quarta-feira_Quinta-feira_Sexta-feira_Sábado'.split('_'),
weekdaysShort: 'Dom_Seg_Ter_Qua_Qui_Sex_Sáb'.split('_'),
weekdaysMin: 'Do_2ª_3ª_4ª_5ª_6ª_Sá'.split('_'),
weekdaysParseExact: true,
longDateFormat: {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
L: 'DD/MM/YYYY',
LL: 'D [de] MMMM [de] YYYY',
LLL: 'D [de] MMMM [de] YYYY [às] HH:mm',
LLLL: 'dddd, D [de] MMMM [de] YYYY [às] HH:mm'
},
calendar: {
sameDay: '[Hoje às] LT',
nextDay: '[Amanhã às] LT',
nextWeek: 'dddd [às] LT',
lastDay: '[Ontem às] LT',
lastWeek: function (date) {
return (getDayOfWeek(date) === 0 || getDayOfWeek(date) === 6) ?
'[Último] dddd [às] LT' :
'[Última] dddd [às] LT'; // Monday - Friday
},
sameElse: 'L'
},
relativeTime: {
future: 'em %s',
past: '%s atrás',
s: 'poucos segundos',
ss: '%d segundos',
m: 'um minuto',
mm: '%d minutos',
h: 'uma hora',
hh: '%d horas',
d: 'um dia',
dd: '%d dias',
M: 'um mês',
MM: '%d meses',
y: 'um ano',
yy: '%d anos'
},
dayOfMonthOrdinalParse: /\d{1,2}º/,
ordinal: '%dº'
};
// tslint:disable:comment-format binary-expression-operand-order max-line-length
// tslint:disable:no-bitwise prefer-template cyclomatic-complexity
// tslint:disable:no-shadowed-variable switch-default prefer-const
// tslint:disable:one-variable-per-declaration newline-before-return
//! moment.js locale configuration
//! locale : Swedish [sv]
//! author : Jens Alm : https://github.com/ulmus
var svLocale = {
abbr: 'sv',
months: 'januari_februari_mars_april_maj_juni_juli_augusti_september_oktober_november_december'.split('_'),
monthsShort: 'jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec'.split('_'),
weekdays: 'söndag_måndag_tisdag_onsdag_torsdag_fredag_lördag'.split('_'),
weekdaysShort: 'sön_mån_tis_ons_tor_fre_lör'.split('_'),
weekdaysMin: 'sö_må_ti_on_to_fr_lö'.split('_'),
longDateFormat: {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
L: 'YYYY-MM-DD',
LL: 'D MMMM YYYY',
LLL: 'D MMMM YYYY [kl.] HH:mm',
LLLL: 'dddd D MMMM YYYY [kl.] HH:mm',
lll: 'D MMM YYYY HH:mm',
llll: 'ddd D MMM YYYY HH:mm'
},
calendar: {
sameDay: '[Idag] LT',
nextDay: '[Imorgon] LT',
lastDay: '[Igår] LT',
nextWeek: '[På] dddd LT',
lastWeek: '[I] dddd[s] LT',
sameElse: 'L'
},
relativeTime: {
future: 'om %s',
past: 'för %s sedan',
s: 'några sekunder',
ss: '%d sekunder',
m: 'en minut',
mm: '%d minuter',
h: 'en timme',
hh: '%d timmar',
d: 'en dag',
dd: '%d dagar',
M: 'en månad',
MM: '%d månader',
y: 'ett år',
yy: '%d år'
},
dayOfMonthOrdinalParse: /\d{1,2}(e|a)/,
ordinal: function (_num) {
var num = Number(_num);
var b = num % 10, output = (~~(num % 100 / 10) === 1) ? 'e' :
(b === 1) ? 'a' :
(b === 2) ? 'a' :
(b === 3) ? 'e' : 'e';
return num + output;
},
week: {
dow: 1,
doy: 4 // The week that contains Jan 4th is the first week of the year.
}
};
// tslint:disable:comment-format binary-expression-operand-order max-line-length
// tslint:disable:no-bitwise prefer-template cyclomatic-complexity
// tslint:disable:no-shadowed-variable switch-default prefer-const
// tslint:disable:one-variable-per-declaration newline-before-return
//! moment.js locale configuration
//! locale : Russian [ru]
//! author : Viktorminator : https://github.com/Viktorminator
//! Author : Menelion Elensúle : https://github.com/Oire
//! author : Коренберг Марк : https://github.com/socketpair
function plural$2(word, num) {
var forms$$1 = word.split('_');
return num % 10 === 1 && num % 100 !== 11 ? forms$$1[0] : (num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20) ? forms$$1[1] : forms$$1[2]);
}
function relativeTimeWithPlural(num, withoutSuffix, key) {
var format = {
ss: withoutSuffix ? 'секунда_секунды_секунд' : 'секунду_секунды_секунд',
mm: withoutSuffix ? 'минута_минуты_минут' : 'минуту_минуты_минут',
hh: 'час_часа_часов',
dd: 'день_дня_дней',
MM: 'месяц_месяца_месяцев',
yy: 'год_года_лет'
};
if (key === 'm') {
return withoutSuffix ? 'минута' : 'минуту';
}
return num + ' ' + plural$2(format[key], +num);
}
var monthsParse$4 = [/^янв/i, /^фев/i, /^мар/i, /^апр/i, /^ма[йя]/i, /^июн/i, /^июл/i, /^авг/i, /^сен/i, /^окт/i, /^ноя/i, /^дек/i];
// http://new.gramota.ru/spravka/rules/139-prop : § 103
// Сокращения месяцев: http://new.gramota.ru/spravka/buro/search-answer?s=242637
// CLDR data: http://www.unicode.org/cldr/charts/28/summary/ru.html#1753
var ruLocale = {
abbr: 'ru',
months: {
format: 'января_февраля_марта_апреля_мая_июня_июля_августа_сентября_октября_ноября_декабря'.split('_'),
standalone: 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_')
},
monthsShort: {
// по CLDR именно "июл." и "июн.", но какой смысл менять букву на точку ?
format: 'янв._февр._мар._апр._мая_июня_июля_авг._сент._окт._нояб._дек.'.split('_'),
standalone: 'янв._февр._март_апр._май_июнь_июль_авг._сент._окт._нояб._дек.'.split('_')
},
weekdays: {
standalone: 'воскресенье_понедельник_вторник_среда_четверг_пятница_суббота'.split('_'),
format: 'воскресенье_понедельник_вторник_среду_четверг_пятницу_субботу'.split('_'),
isFormat: /\[ ?[Вв] ?(?:прошлую|следующую|эту)? ?\] ?dddd/
},
weekdaysShort: 'вс_пн_вт_ср_чт_пт_сб'.split('_'),
weekdaysMin: 'вс_пн_вт_ср_чт_пт_сб'.split('_'),
monthsParse: monthsParse$4,
longMonthsParse: monthsParse$4,
shortMonthsParse: monthsParse$4,
// полные названия с падежами, по три буквы, для некоторых, по 4 буквы, сокращения с точкой и без точки
monthsRegex: /^(январ[ья]|янв\.?|феврал[ья]|февр?\.?|марта?|мар\.?|апрел[ья]|апр\.?|ма[йя]|июн[ья]|июн\.?|июл[ья]|июл\.?|августа?|авг\.?|сентябр[ья]|сент?\.?|октябр[ья]|окт\.?|ноябр[ья]|нояб?\.?|декабр[ья]|дек\.?)/i,
// копия предыдущего
monthsShortRegex: /^(январ[ья]|янв\.?|феврал[ья]|февр?\.?|марта?|мар\.?|апрел[ья]|апр\.?|ма[йя]|июн[ья]|июн\.?|июл[ья]|июл\.?|августа?|авг\.?|сентябр[ья]|сент?\.?|октябр[ья]|окт\.?|ноябр[ья]|нояб?\.?|декабр[ья]|дек\.?)/i,
// полные названия с падежами
monthsStrictRegex: /^(январ[яь]|феврал[яь]|марта?|апрел[яь]|ма[яй]|июн[яь]|июл[яь]|августа?|сентябр[яь]|октябр[яь]|ноябр[яь]|декабр[яь])/i,
// Выражение, которое соотвествует только сокращённым формам
monthsShortStrictRegex: /^(янв\.|февр?\.|мар[т.]|апр\.|ма[яй]|июн[ья.]|июл[ья.]|авг\.|сент?\.|окт\.|нояб?\.|дек\.)/i,
longDateFormat: {
LT: 'H:mm',
LTS: 'H:mm:ss',
L: 'DD.MM.YYYY',
LL: 'D MMMM YYYY г.',
LLL: 'D MMMM YYYY г., H:mm',
LLLL: 'dddd, D MMMM YYYY г., H:mm'
},
calendar: {
sameDay: '[Сегодня в] LT',
nextDay: '[Завтра в] LT',
lastDay: '[Вчера в] LT',
nextWeek: function (date, now) {
if (getWeek(now) !== getWeek(date)) {
switch (getDayOfWeek(date)) {
case 0:
return '[В следующее] dddd [в] LT';
case 1:
case 2:
case 4:
return '[В следующий] dddd [в] LT';
case 3:
case 5:
case 6:
return '[В следующую] dddd [в] LT';
}
}
else {
if (getDayOfWeek(date) === 2) {
return '[Во] dddd [в] LT';
}
else {
return '[В] dddd [в] LT';
}
}
},
lastWeek: function (date, now) {
if (getWeek(now) !== getWeek(date)) {
switch (getDayOfWeek(date)) {
case 0:
return '[В прошлое] dddd [в] LT';
case 1:
case 2:
case 4:
return '[В прошлый] dddd [в] LT';
case 3:
case 5:
case 6:
return '[В прошлую] dddd [в] LT';
}
}
else {
if (getDayOfWeek(date) === 2) {
return '[Во] dddd [в] LT';
}
else {
return '[В] dddd [в] LT';
}
}
},
sameElse: 'L'
},
relativeTime: {
future: 'через %s',
past: '%s назад',
s: 'несколько секунд',
ss: relativeTimeWithPlural,
m: relativeTimeWithPlural,
mm: relativeTimeWithPlural,
h: 'час',
hh: relativeTimeWithPlural,
d: 'день',
dd: relativeTimeWithPlural,
M: 'месяц',
MM: relativeTimeWithPlural,
y: 'год',
yy: relativeTimeWithPlural
},
meridiemParse: /ночи|утра|дня|вечера/i,
isPM: function (input) {
return /^(дня|вечера)$/.test(input);
},
meridiem: function (hour, minute, isLower) {
if (hour < 4) {
return 'ночи';
}
else if (hour < 12) {
return 'утра';
}
else if (hour < 17) {
return 'дня';
}
else {
return 'вечера';
}
},
dayOfMonthOrdinalParse: /\d{1,2}-(й|го|я)/,
ordinal: function (_num, period) {
var num = Number(_num);
switch (period) {
case 'M':
case 'd':
case 'DDD':
return num + '-й';
case 'D':
return num + '-го';
case 'w':
case 'W':
return num + '-я';
default:
return num.toString(10);
}
},
week: {
dow: 1,
doy: 4 // The week that contains Jan 4th is the first week of the year.
}
};
// tslint:disable:comment-format binary-expression-operand-order max-line-length
// tslint:disable:no-bitwise prefer-template cyclomatic-complexity
// tslint:disable:no-shadowed-variable switch-default prefer-const
// tslint:disable:one-variable-per-declaration newline-before-return
// tslint:disable:no-parameter-reassignment prefer-switch
//! moment.js locale configuration
//! locale : Chinese (China) [zh-cn]
//! author : suupic : https://github.com/suupic
//! author : Zeno Zeng : https://github.com/zenozeng
var zhCnLocale = {
abbr: 'zh-cn',
months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'),
monthsShort: '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
weekdays: '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
weekdaysShort: '周日_周一_周二_周三_周四_周五_周六'.split('_'),
weekdaysMin: '日_一_二_三_四_五_六'.split('_'),
longDateFormat: {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
L: 'YYYY/MM/DD',
LL: 'YYYY年M月D日',
LLL: 'YYYY年M月D日Ah点mm分',
LLLL: 'YYYY年M月D日ddddAh点mm分',
l: 'YYYY/M/D',
ll: 'YYYY年M月D日',
lll: 'YYYY年M月D日 HH:mm',
llll: 'YYYY年M月D日dddd HH:mm'
},
meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
meridiemHour: function (hour, meridiem) {
if (hour === 12) {
hour = 0;
}
if (meridiem === '凌晨' || meridiem === '早上' ||
meridiem === '上午') {
return hour;
}
else if (meridiem === '下午' || meridiem === '晚上') {
return hour + 12;
}
else {
// '中午'
return hour >= 11 ? hour : hour + 12;
}
},
meridiem: function (hour, minute, isLower) {
var hm = hour * 100 + minute;
if (hm < 600) {
return '凌晨';
}
else if (hm < 900) {
return '早上';
}
else if (hm < 1130) {
return '上午';
}
else if (hm < 1230) {
return '中午';
}
else if (hm < 1800) {
return '下午';
}
else {
return '晚上';
}
},
calendar: {
sameDay: '[今天]LT',
nextDay: '[明天]LT',
nextWeek: '[下]ddddLT',
lastDay: '[昨天]LT',
lastWeek: '[上]ddddLT',
sameElse: 'L'
},
dayOfMonthOrdinalParse: /\d{1,2}(日|月|周)/,
ordinal: function (_num, period) {
var num = Number(_num);
switch (period) {
case 'd':
case 'D':
case 'DDD':
return num + '日';
case 'M':
return num + '月';
case 'w':
case 'W':
return num + '周';
default:
return num.toString();
}
},
relativeTime: {
future: '%s内',
past: '%s前',
s: '几秒',
ss: '%d 秒',
m: '1 分钟',
mm: '%d 分钟',
h: '1 小时',
hh: '%d 小时',
d: '1 天',
dd: '%d 天',
M: '1 个月',
MM: '%d 个月',
y: '1 年',
yy: '%d 年'
},
week: {
// GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
dow: 1,
doy: 4 // The week that contains Jan 4th is the first week of the year.
}
};
// tslint:disable:comment-format binary-expression-operand-order max-line-length
// tslint:disable:no-bitwise prefer-template cyclomatic-complexity
// tslint:disable:no-shadowed-variable switch-default prefer-const
// tslint:disable:one-variable-per-declaration newline-before-return
//! moment.js locale configuration
//! locale : Turkish [tr]
//! authors : Erhan Gundogan : https://github.com/erhangundogan,
//! Burak Yiğit Kaya: https://github.com/BYK
var suffixes = {
1: '\'inci',
5: '\'inci',
8: '\'inci',
70: '\'inci',
80: '\'inci',
2: '\'nci',
7: '\'nci',
20: '\'nci',
50: '\'nci',
3: '\'üncü',
4: '\'üncü',
100: '\'üncü',
6: '\'ncı',
9: '\'uncu',
10: '\'uncu',
30: '\'uncu',
60: '\'ıncı',
90: '\'ıncı'
};
var trLocale = {
abbr: 'tr',
months: 'Ocak_Şubat_Mart_Nisan_Mayıs_Haziran_Temmuz_Ağustos_Eylül_Ekim_Kasım_Aralık'.split('_'),
monthsShort: 'Oca_Şub_Mar_Nis_May_Haz_Tem_Ağu_Eyl_Eki_Kas_Ara'.split('_'),
weekdays: 'Pazar_Pazartesi_Salı_Çarşamba_Perşembe_Cuma_Cumartesi'.split('_'),
weekdaysShort: 'Paz_Pts_Sal_Çar_Per_Cum_Cts'.split('_'),
weekdaysMin: 'Pz_Pt_Sa_Ça_Pe_Cu_Ct'.split('_'),
longDateFormat: {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
L: 'DD.MM.YYYY',
LL: 'D MMMM YYYY',
LLL: 'D MMMM YYYY HH:mm',
LLLL: 'dddd, D MMMM YYYY HH:mm'
},
calendar: {
sameDay: '[bugün saat] LT',
nextDay: '[yarın saat] LT',
nextWeek: '[gelecek] dddd [saat] LT',
lastDay: '[dün] LT',
lastWeek: '[geçen] dddd [saat] LT',
sameElse: 'L'
},
relativeTime: {
future: '%s sonra',
past: '%s önce',
s: 'birkaç saniye',
ss: '%d saniye',
m: 'bir dakika',
mm: '%d dakika',
h: 'bir saat',
hh: '%d saat',
d: 'bir gün',
dd: '%d gün',
M: 'bir ay',
MM: '%d ay',
y: 'bir yıl',
yy: '%d yıl'
},
dayOfMonthOrdinalParse: /\d{1,2}'(inci|nci|üncü|ncı|uncu|ıncı)/,
ordinal: function (_num) {
var num = Number(_num);
if (num === 0) {
return num + '\'ıncı';
}
var a = num % 10, b = num % 100 - a, c = num >= 100 ? 100 : null;
return num + (suffixes[a] || suffixes[b] || suffixes[c]);
},
week: {
dow: 1,
doy: 7 // The week that contains Jan 1st is the first week of the year.
}
};
// tslint:disable:comment-format binary-expression-operand-order max-line-length
// tslint:disable:no-bitwise prefer-template cyclomatic-complexity
// tslint:disable:no-shadowed-variable switch-default prefer-const
// tslint:disable:one-variable-per-declaration newline-before-return
//! moment.js locale configuration
//! locale : Hebrew [he]
//! author : Tomer Cohen : https://github.com/tomer
//! author : Moshe Simantov : https://github.com/DevelopmentIL
//! author : Tal Ater : https://github.com/TalAter
var heLocale = {
abbr: 'he',
months: 'ינואר_פברואר_מרץ_אפריל_מאי_יוני_יולי_אוגוסט_ספטמבר_אוקטובר_נובמבר_דצמבר'.split('_'),
monthsShort: 'ינו׳_פבר׳_מרץ_אפר׳_מאי_יוני_יולי_אוג׳_ספט׳_אוק׳_נוב׳_דצמ׳'.split('_'),
weekdays: 'ראשון_שני_שלישי_רביעי_חמישי_שישי_שבת'.split('_'),
weekdaysShort: 'א׳_ב׳_ג׳_ד׳_ה׳_ו׳_ש׳'.split('_'),
weekdaysMin: 'א_ב_ג_ד_ה_ו_ש'.split('_'),
longDateFormat: {
LT: 'HH:mm',
LTS: 'HH:mm:ss',
L: 'DD/MM/YYYY',
LL: 'D [ב]MMMM YYYY',
LLL: 'D [ב]MMMM YYYY HH:mm',
LLLL: 'dddd, D [ב]MMMM YYYY HH:mm',
l: 'D/M/YYYY',
ll: 'D MMM YYYY',
lll: 'D MMM YYYY HH:mm',
llll: 'ddd, D MMM YYYY HH:mm'
},
calendar: {
sameDay: '[היום ב־]LT',
nextDay: '[מחר ב־]LT',
nextWeek: 'dddd [בשעה] LT',
lastDay: '[אתמול ב־]LT',
lastWeek: '[ביום] dddd [האחרון בשעה] LT',
sameElse: 'L'
},
relativeTime: {
future: 'בעוד %s',
past: 'לפני %s',
s: 'מספר שניות',
ss: '%d שניות',
m: 'דקה',
mm: '%d דקות',
h: 'שעה',
hh: function (num) {
if (num === 2) {
return 'שעתיים';
}
return num + ' שעות';
},
d: 'יום',
dd: function (num) {
if (num === 2) {
return 'יומיים';
}
return num + ' ימים';
},
M: 'חודש',
MM: function (num) {
if (num === 2) {
return 'חודשיים';
}
return num + ' חודשים';
},
y: 'שנה',
yy: function (num) {
if (num === 2) {
return 'שנתיים';
}
else if (num % 10 === 0 && num !== 10) {
return num + ' שנה';
}
return num + ' שנים';
}
},
meridiemParse: /אחה"צ|לפנה"צ|אחרי הצהריים|לפני הצהריים|לפנות בוקר|בבוקר|בערב/i,
isPM: function (input) {
return /^(אחה"צ|אחרי הצהריים|בערב)$/.test(input);
},
meridiem: function (hour, minute, isLower) {
if (hour < 5) {
return 'לפנות בוקר';
}
else if (hour < 10) {
return 'בבוקר';
}
else if (hour < 12) {
return isLower ? 'לפנה"צ' : 'לפני הצהריים';
}
else if (hour < 18) {
return isLower ? 'אחה"צ' : 'אחרי הצהריים';
}
else {
return 'בערב';
}
}
};
// tslint:disable:comment-format binary-expression-operand-order max-line-length
// tslint:disable:no-bitwise prefer-template cyclomatic-complexity
// tslint:disable:no-shadowed-variable switch-default prefer-const
// tslint:disable:one-variable-per-declaration newline-before-return
var thLocale = {
abbr: 'th',
months: 'มกราคม_กุมภาพันธ์_มีนาคม_เมษายน_พฤษภาคม_มิถุนายน_กรกฎาคม_สิงหาคม_กันยายน_ตุลาคม_พฤศจิกายน_ธันวาคม'.split('_'),
monthsShort: 'ม.ค._ก.พ._มี.ค._เม.ย._พ.ค._มิ.ย._ก.ค._ส.ค._ก.ย._ต.ค._พ.ย._ธ.ค.'.split('_'),
monthsParseExact: true,
weekdays: 'อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัสบดี_ศุกร์_เสาร์'.split('_'),
weekdaysShort: 'อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัส_ศุกร์_เสาร์'.split('_'),
weekdaysMin: 'อา._จ._อ._พ._พฤ._ศ._ส.'.split('_'),
weekdaysParseExact: true,
longDateFormat: {
LT: 'H:mm',
LTS: 'H:mm:ss',
L: 'DD/MM/YYYY',
LL: 'D MMMM YYYY',
LLL: 'D MMMM YYYY เวลา H:mm',
LLLL: 'วันddddที่ D MMMM YYYY เวลา H:mm'
},
meridiemParse: /ก่อนเที่ยง|หลังเที่ยง/,
isPM: function (input) {
return input === 'หลังเที่ยง';
},
meridiem: function (hour, minute, isLower) {
if (hour < 12) {
return 'ก่อนเที่ยง';
}
else {
return 'หลังเที่ยง';
}
},
calendar: {
sameDay: '[วันนี้ เวลา] LT',
nextDay: '[พรุ่งนี้ เวลา] LT',
nextWeek: 'dddd[หน้า เวลา] LT',
lastDay: '[เมื่อวานนี้ เวลา] LT',
lastWeek: '[วัน]dddd[ที่แล้ว เวลา] LT',
sameElse: 'L'
},
relativeTime: {
future: 'อีก %s',
past: '%sที่แล้ว',
s: 'ไม่กี่วินาที',
ss: '%d วินาที',
m: '1 นาที',
mm: '%d นาที',
h: '1 ชั่วโมง',
hh: '%d ชั่วโมง',
d: '1 วัน',
dd: '%d วัน',
M: '1 เดือน',
MM: '%d เดือน',
y: '1 ปี',
yy: '%d ปี'
}
};
var TourState = {};
TourState.OFF = 0;
TourState.ON = 1;
TourState.PAUSED = 2;
TourState[TourState.OFF] = "OFF";
TourState[TourState.ON] = "ON";
TourState[TourState.PAUSED] = "PAUSED";
var NgxBootstrapProductTourService = /** @class */ (function () {
/**
* @param {?} router
*/
function NgxBootstrapProductTourService(router$$1) {
this.router = router$$1;
this.stepShow$ = new Subject$1();
this.stepHide$ = new Subject$1();
this.initialize$ = new Subject$1();
this.start$ = new Subject$1();
this.end$ = new Subject$1();
this.pause$ = new Subject$1();
this.resume$ = new Subject$1();
this.anchorRegister$ = new Subject$1();
this.anchorUnregister$ = new Subject$1();
this.events$ = mergeStatic(map$2.bind(this.stepShow$)(function (value) { return ({ name: 'stepShow', value: value }); }), map$2.bind(this.stepHide$)(function (value) { return ({ name: 'stepHide', value: value }); }), map$2.bind(this.initialize$)(function (value) { return ({ name: 'initialize', value: value }); }), map$2.bind(this.start$)(function (value) { return ({ name: 'start', value: value }); }), map$2.bind(this.end$)(function (value) { return ({ name: 'end', value: value }); }), map$2.bind(this.pause$)(function (value) { return ({ name: 'pause', value: value }); }), map$2.bind(this.resume$)(function (value) { return ({ name: 'resume', value: value }); }), map$2.bind(this.anchorRegister$)(function (value) { return ({ name: 'anchorRegister', value: value }); }), map$2.bind(this.anchorUnregister$)(function (value) { return ({ name: 'anchorUnregister', value: value }); }));
this.steps = [];
this.anchors = {};
this.status = TourState.OFF;
}
/**
* @param {?} steps
* @param {?=} stepDefaults
* @return {?}
*/
NgxBootstrapProductTourService.prototype.initialize = function (steps, stepDefaults) {
if (steps && steps.length > 0 && this.status === TourState.OFF) {
this.status = TourState.OFF;
this.steps = steps.map(function (step) { return Object.assign({}, stepDefaults, step); });
this.initialize$.next(this.steps);
}
};
/**
* @return {?}
*/
NgxBootstrapProductTourService.prototype.start = function () {
this.startAt(0);
};
/**
* @param {?} stepId
* @return {?}
*/
NgxBootstrapProductTourService.prototype.startAt = function (stepId) {
var _this = this;
this.status = TourState.ON;
this.goToStep(this.loadStep(stepId));
this.start$.next();
this.router.events.filter(function (event) { return event instanceof NavigationStart; }).first().subscribe(function () {
if (_this.currentStep) {
_this.hideStep(_this.currentStep);
}
});
};
/**
* @return {?}
*/
NgxBootstrapProductTourService.prototype.end = function () {
this.status = TourState.OFF;
this.hideStep(this.currentStep);
this.currentStep = undefined;
this.end$.next();
};
/**
* @return {?}
*/
NgxBootstrapProductTourService.prototype.pause = function () {
this.status = TourState.PAUSED;
this.hideStep(this.currentStep);
this.pause$.next();
};
/**
* @return {?}
*/
NgxBootstrapProductTourService.prototype.resume = function () {
this.status = TourState.ON;
this.showStep(this.currentStep);
this.resume$.next();
};
/**
* @param {?=} pause
* @return {?}
*/
NgxBootstrapProductTourService.prototype.toggle = function (pause) {
if (pause) {
if (this.currentStep) {
this.pause();
}
else {
this.resume();
}
}
else {
if (this.currentStep) {
this.end();
}
else {
this.start();
}
}
};
/**
* @return {?}
*/
NgxBootstrapProductTourService.prototype.next = function () {
if (this.hasNext(this.currentStep)) {
this.goToStep(this.loadStep(this.currentStep.nextStep || this.steps.indexOf(this.currentStep) + 1));
}
};
/**
* @param {?} step
* @return {?}
*/
NgxBootstrapProductTourService.prototype.hasNext = function (step) {
if (!step) {
console.warn('Can\'t get next step. No currentStep.');
return false;
}
return step.nextStep !== undefined || this.steps.indexOf(step) < this.steps.length - 1;
};
/**
* @return {?}
*/
NgxBootstrapProductTourService.prototype.prev = function () {
if (this.hasPrev(this.currentStep)) {
this.goToStep(this.loadStep(this.currentStep.prevStep || this.steps.indexOf(this.currentStep) - 1));
}
};
/**
* @param {?} step
* @return {?}
*/
NgxBootstrapProductTourService.prototype.hasPrev = function (step) {
if (!step) {
console.warn('Can\'t get previous step. No currentStep.');
return false;
}
return step.prevStep !== undefined || this.steps.indexOf(step) > 0;
};
/**
* @param {?} stepId
* @return {?}
*/
NgxBootstrapProductTourService.prototype.goto = function (stepId) {
this.goToStep(this.loadStep(stepId));
};
/**
* @param {?} anchorId
* @param {?} anchor
* @return {?}
*/
NgxBootstrapProductTourService.prototype.register = function (anchorId, anchor) {
if (this.anchors[anchorId]) {
throw new Error('anchorId ' + anchorId + ' already registered!');
}
this.anchors[anchorId] = anchor;
this.anchorRegister$.next(anchorId);
};
/**
* @param {?} anchorId
* @return {?}
*/
NgxBootstrapProductTourService.prototype.unregister = function (anchorId) {
delete this.anchors[anchorId];
this.anchorUnregister$.next(anchorId);
};
/**
* @return {?}
*/
NgxBootstrapProductTourService.prototype.getStatus = function () {
return this.status;
};
/**
* @param {?} step
* @return {?}
*/
NgxBootstrapProductTourService.prototype.goToStep = function (step) {
var _this = this;
if (!step) {
console.warn('Can\'t go to non-existent step');
this.end();
return;
}
var /** @type {?} */ navigatePromise = new Promise(function (resolve) { return resolve(true); });
if (step.route !== undefined && typeof (step.route) === 'string') {
navigatePromise = this.router.navigateByUrl(step.route);
}
else if (step.route && Array.isArray(step.route)) {
navigatePromise = this.router.navigate(step.route);
}
navigatePromise.then(function (navigated) {
if (navigated !== false) {
setTimeout(function () { return _this.setCurrentStep(step); });
}
});
};
/**
* @param {?} stepId
* @return {?}
*/
NgxBootstrapProductTourService.prototype.loadStep = function (stepId) {
if (typeof (stepId) === 'number') {
return this.steps[stepId];
}
else {
return this.steps.find(function (step) { return step.stepId === stepId; });
}
};
/**
* @param {?} step
* @return {?}
*/
NgxBootstrapProductTourService.prototype.setCurrentStep = function (step) {
var _this = this;
if (this.currentStep) {
this.hideStep(this.currentStep);
}
this.currentStep = step;
if (step.promise) {
step.promise
.then(function () { return step.delay ? setTimeout(function () { return _this.showStep(_this.currentStep); }, step.delay) : _this.showStep(_this.currentStep); })
.catch(function () { return console.error("Promise for step " + step.anchorId + " has failed!"); });
}
else {
step.delay ? setTimeout(function () { return _this.showStep(_this.currentStep); }, step.delay) : this.showStep(this.currentStep);
}
this.router.events.filter(function (event) { return event instanceof NavigationStart; }).first().subscribe(function () {
if (_this.currentStep) {
_this.hideStep(_this.currentStep);
}
});
};
/**
* @param {?} step
* @return {?}
*/
NgxBootstrapProductTourService.prototype.showStep = function (step) {
var /** @type {?} */ anchor = this.anchors[step && step.anchorId];
if (!anchor) {
this.end();
return;
}
anchor.showTourStep(step);
this.stepShow$.next(step);
};
/**
* @param {?} step
* @return {?}
*/
NgxBootstrapProductTourService.prototype.hideStep = function (step) {
var /** @type {?} */ anchor = this.anchors[step && step.anchorId];
if (!anchor) {
return;
}
anchor.hideTourStep();
this.stepHide$.next(step);
};
/**
* @param {?} step
* @return {?}
*/
NgxBootstrapProductTourService.prototype.isStepOpen = function (step) {
var /** @type {?} */ anchor = this.anchors[step && step.anchorId];
if (!anchor) {
return;
}
return anchor.isOpen;
};
return NgxBootstrapProductTourService;
}());
NgxBootstrapProductTourService.decorators = [
{ type: Injectable },
];
/**
* @nocollapse
*/
NgxBootstrapProductTourService.ctorParameters = function () { return [
{ type: Router, },
]; };
var NgxBootstrapProductTourStepService = /** @class */ (function () {
function NgxBootstrapProductTourStepService() {
}
return NgxBootstrapProductTourStepService;
}());
NgxBootstrapProductTourStepService.decorators = [
{ type: Injectable },
];
/**
* @nocollapse
*/
NgxBootstrapProductTourStepService.ctorParameters = function () { return []; };
var NgxBootstrapPopoverDirective = /** @class */ (function (_super) {
__extends(NgxBootstrapPopoverDirective, _super);
function NgxBootstrapPopoverDirective() {
var _this = _super.apply(this, arguments) || this;
_this.triggers = '';
return _this;
}
return NgxBootstrapPopoverDirective;
}(PopoverDirective));
NgxBootstrapPopoverDirective.decorators = [
{ type: Directive, args: [{
selector: '[tourAnchor]'
},] },
];
/**
* @nocollapse
*/
NgxBootstrapPopoverDirective.ctorParameters = function () { return []; };
var NgxBootstrapProductTourDirective = /** @class */ (function () {
/**
* @param {?} tourService
* @param {?} tourStepTemplate
* @param {?} element
* @param {?} popoverDirective
*/
function NgxBootstrapProductTourDirective(tourService, tourStepTemplate, element, popoverDirective) {
this.tourService = tourService;
this.tourStepTemplate = tourStepTemplate;
this.element = element;
this.popoverDirective = popoverDirective;
this._elementClass = [];
}
/**
* @return {?}
*/
NgxBootstrapProductTourDirective.prototype.ngOnInit = function () {
this.tourService.register(this.tourAnchor, this);
};
/**
* @return {?}
*/
NgxBootstrapProductTourDirective.prototype.ngOnDestroy = function () {
this.tourService.unregister(this.tourAnchor);
};
/**
* @param {?} step
* @return {?}
*/
NgxBootstrapProductTourDirective.prototype.showTourStep = function (step) {
this.popoverDirective.popover = this.tourStepTemplate.template;
this.popoverDirective.popoverTitle = step.title;
this.popoverDirective.containerClass = step.containerClass ? step.containerClass : '';
this.popoverDirective.placement = step.placement ? step.placement : 'top';
this.popoverDirective.container = 'body';
this.popoverDirective.triggers = '';
if (step.orphan) {
this.popoverDirective.containerClass += ' orphan';
}
if (step.backdrop && !step.orphan) {
this.backdropClass = true;
}
this.popoverDirective.show();
if (!step.preventScrolling) {
( /** @type {?} */(this.element.nativeElement)).scrollIntoView({ behavior: 'instant', block: 'center', inline: 'nearest' });
}
};
/**
* @return {?}
*/
NgxBootstrapProductTourDirective.prototype.hideTourStep = function () {
this.backdropClass = false;
this.popoverDirective.hide();
};
/**
* @return {?}
*/
NgxBootstrapProductTourDirective.prototype.isOpen = function () {
return this.popoverDirective.isOpen;
};
return NgxBootstrapProductTourDirective;
}());
NgxBootstrapProductTourDirective.decorators = [
{ type: Directive, args: [{
selector: '[tourAnchor]',
},] },
];
/**
* @nocollapse
*/
NgxBootstrapProductTourDirective.ctorParameters = function () { return [
{ type: NgxBootstrapProductTourService, },
{ type: NgxBootstrapProductTourStepService, },
{ type: ElementRef, },
{ type: NgxBootstrapPopoverDirective, decorators: [{ type: Host },] },
]; };
NgxBootstrapProductTourDirective.propDecorators = {
'tourAnchor': [{ type: Input },],
'backdropClass': [{ type: HostBinding, args: ['class.tour-step-backdrop',] },],
};
var NgxBootstrapProductTourStepComponent = /** @class */ (function () {
/**
* @param {?} ngxBootstrapProductTourStepService
* @param {?} tourService
*/
function NgxBootstrapProductTourStepComponent(ngxBootstrapProductTourStepService, tourService) {
this.ngxBootstrapProductTourStepService = ngxBootstrapProductTourStepService;
this.tourService = tourService;
}
/**
* @return {?}
*/
NgxBootstrapProductTourStepComponent.prototype.ngAfterContentInit = function () {
this.ngxBootstrapProductTourStepService.template = this.stepTemplate || this.defaultTourStepTemplate;
};
return NgxBootstrapProductTourStepComponent;
}());
NgxBootstrapProductTourStepComponent.decorators = [
{ type: Component, args: [{
selector: 'ngx-bootstrap-product-tour',
template: "\n <div *ngIf=\"tourService.currentStep?.backdrop && tourService.isStepOpen(tourService.currentStep)\" class=\"tour-backdrop\"></div>\n <ng-template #tourStep>\n <p class=\"tour-step-content\">{{tourService.currentStep.content}}</p>\n <div class=\"tour-step-navigation\">\n <button *ngIf=\"tourService.hasPrev(tourService.currentStep)\" class=\"btn btn-sm btn-default\" (click)=\"tourService.prev()\">\u00AB Prev</button>\n <button *ngIf=\"tourService.hasNext(tourService.currentStep)\" class=\"btn btn-sm btn-default\" (click)=\"tourService.next()\">Next \u00BB</button>\n <button class=\"btn btn-sm btn-error\" (click)=\"tourService.end()\">End</button>\n </div>\n </ng-template>\n ",
styles: ["\n ::ng-deep .orphan {\n position: fixed;\n top: 50% !important;\n left: 50% !important;\n -webkit-transform: translate(-50%, -50%);\n transform: translate(-50%, -50%);\n }\n\n ::ng-deep .orphan>.popover-arrow {\n display: none;\n }\n\n .tour-backdrop {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n }\n "]
},] },
];
/**
* @nocollapse
*/
NgxBootstrapProductTourStepComponent.ctorParameters = function () { return [
{ type: NgxBootstrapProductTourStepService, },
{ type: NgxBootstrapProductTourService, },
]; };
NgxBootstrapProductTourStepComponent.propDecorators = {
'defaultTourStepTemplate': [{ type: ViewChild, args: ['tourStep', { read: TemplateRef },] },],
'stepTemplate': [{ type: Input }, { type: ContentChild, args: [TemplateRef,] },],
};
var NgxBootstrapProductTourModule = /** @class */ (function () {
function NgxBootstrapProductTourModule() {
}
/**
* @return {?}
*/
NgxBootstrapProductTourModule.forRoot = function () {
return {
ngModule: NgxBootstrapProductTourModule,
providers: [
NgxBootstrapProductTourService,
NgxBootstrapProductTourStepService
],
};
};
return NgxBootstrapProductTourModule;
}());
NgxBootstrapProductTourModule.decorators = [
{ type: NgModule, args: [{
imports: [
CommonModule,
PopoverModule.forRoot(),
],
declarations: [
NgxBootstrapProductTourDirective,
NgxBootstrapPopoverDirective,
NgxBootstrapProductTourStepComponent
],
entryComponents: [
NgxBootstrapProductTourStepComponent
],
exports: [
NgxBootstrapProductTourDirective,
NgxBootstrapPopoverDirective,
NgxBootstrapProductTourStepComponent
]
},] },
];
/**
* @nocollapse
*/
NgxBootstrapProductTourModule.ctorParameters = function () { return []; };
/**
* Generated bundle index. Do not edit.
*/
export { NgxBootstrapProductTourModule, NgxBootstrapProductTourService, NgxBootstrapProductTourStepComponent as ɵd, NgxBootstrapProductTourStepService as ɵc, NgxBootstrapPopoverDirective as ɵa, NgxBootstrapProductTourDirective as ɵb };
//# sourceMappingURL=ngx-bootstrap-product-tour.es5.js.map