@anjuna/angular-core
Version: 
<p align="center"> <img src="//cdn.zuora.com/theme/0.6.0/assets/anjuna/anjuna-logo.svg"/> <br/><br/> </p>
1,764 lines (1,747 loc) • 87.4 kB
JavaScript
import { InjectionToken, Optional, Inject, Directive, ElementRef, Input, TemplateRef, ViewContainerRef, NgZone, ContentChildren, HostListener, EventEmitter, Renderer2, Attribute, Output, ChangeDetectorRef, LOCALE_ID, HostBinding, Injector, Self, Pipe, Injectable, ɵɵdefineInjectable, NgModule } from '@angular/core';
import { DragController, DropController, LocalStorage, SessionStorage } from '@anjuna/core';
import { __extends, __awaiter, __generator } from 'tslib';
import { NgControl, NgForm, FormGroupDirective, NG_VALUE_ACCESSOR, NG_VALIDATORS, FormControl } from '@angular/forms';
import { Subject } from 'rxjs';
/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
/** @type {?} */
var LANGUAGE_CODE = new InjectionToken('LanguageCode');
/**
 * @record
 */
function TranslationsMap() { }
if (false) {
    /** @type {?} */
    TranslationsMap.prototype.de;
    /** @type {?} */
    TranslationsMap.prototype.en;
    /** @type {?} */
    TranslationsMap.prototype.fr;
    /** @type {?} */
    TranslationsMap.prototype.ja;
}
/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
/**
 * @abstract
 */
var BaseTranslationPipe = /** @class */ (function () {
    function BaseTranslationPipe(language) {
        this.language = language;
    }
    /**
     * @param {?} value
     * @return {?}
     */
    BaseTranslationPipe.prototype.transform = /**
     * @param {?} value
     * @return {?}
     */
    function (value) {
        if (!this.translations[this.language]) {
            console.warn("Translation file for '" + this.language + "' does not exist.");
            return value;
        }
        return this.translations[this.language][value] || value;
    };
    /** @nocollapse */
    BaseTranslationPipe.ctorParameters = function () { return [
        { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [LANGUAGE_CODE,] }] }
    ]; };
    return BaseTranslationPipe;
}());
if (false) {
    /**
     * @type {?}
     * @protected
     */
    BaseTranslationPipe.prototype.translations;
    /**
     * @type {?}
     * @protected
     */
    BaseTranslationPipe.prototype.language;
}
/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
/**
 * \@description A wrapper around the HTML 5 Drag API.
 */
var DraggableDirective = /** @class */ (function () {
    function DraggableDirective(element) {
        var _this = this;
        this.element = element;
        this.dataFn = (/**
         * @return {?}
         */
        function () { return _this.getData(); });
        this.controller = new DragController(this.element.nativeElement, this.dataFn).connect();
    }
    /**
     * @private
     * @return {?}
     */
    DraggableDirective.prototype.getData = /**
     * @private
     * @return {?}
     */
    function () {
        return this.anjDraggable;
    };
    DraggableDirective.decorators = [
        { type: Directive, args: [{
                    selector: '[anjDraggable]'
                },] }
    ];
    /** @nocollapse */
    DraggableDirective.ctorParameters = function () { return [
        { type: ElementRef }
    ]; };
    DraggableDirective.propDecorators = {
        anjDraggable: [{ type: Input }]
    };
    return DraggableDirective;
}());
if (false) {
    /**
     * \@description Binds to arbitrary data to be passed via anjDroppable's onDrop event emitter.
     * @type {?}
     */
    DraggableDirective.prototype.anjDraggable;
    /**
     * @type {?}
     * @private
     */
    DraggableDirective.prototype.controller;
    /**
     * @type {?}
     * @private
     */
    DraggableDirective.prototype.dataFn;
    /**
     * @type {?}
     * @private
     */
    DraggableDirective.prototype.element;
}
/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
/**
 * \@description A wrapper around the HTML 5 Drop API.
 */
var DroppableDirective = /** @class */ (function () {
    function DroppableDirective(element) {
        this.element = element;
        this.controller = new DropController(this.element.nativeElement).connect();
    }
    DroppableDirective.decorators = [
        { type: Directive, args: [{
                    selector: '[anjDroppable]'
                },] }
    ];
    /** @nocollapse */
    DroppableDirective.ctorParameters = function () { return [
        { type: ElementRef }
    ]; };
    return DroppableDirective;
}());
if (false) {
    /**
     * @type {?}
     * @private
     */
    DroppableDirective.prototype.controller;
    /**
     * @type {?}
     * @private
     */
    DroppableDirective.prototype.element;
}
/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
var DomOutlet = /** @class */ (function () {
    function DomOutlet(targetElement) {
        this.targetElement = targetElement;
    }
    /**
     * @template C
     * @param {?} template
     * @return {?}
     */
    DomOutlet.prototype.attachTemplate = /**
     * @template C
     * @param {?} template
     * @return {?}
     */
    function (template) {
        var _this = this;
        if (this.template.zone.isStable) {
            this._viewRef = this.template.zone.run((/**
             * @return {?}
             */
            function () {
                return template.viewContainerRef.createEmbeddedView(template.templateRef, template.context);
            }));
        }
        else {
            this._viewRef = template.viewContainerRef.createEmbeddedView(template.templateRef, template.context);
        }
        this._viewRef.rootNodes.forEach((/**
         * @param {?} rootNode
         * @return {?}
         */
        function (rootNode) { return _this.targetElement.appendChild(rootNode); }));
        this._viewRef.detectChanges();
        this.setDisposeFn(((/**
         * @return {?}
         */
        function () {
            /** @type {?} */
            var index = template.viewContainerRef.indexOf(_this._viewRef);
            if (index !== -1) {
                template.viewContainerRef.remove(index);
            }
        })));
        return this._viewRef;
    };
    /**
     * @param {?} context
     * @return {?}
     */
    DomOutlet.prototype.updateContext = /**
     * @param {?} context
     * @return {?}
     */
    function (context) {
        for (var prop in context) {
            if (context.hasOwnProperty(prop)) {
                this._viewRef.context[prop] = context[prop];
            }
        }
        this._viewRef.detectChanges();
    };
    /**
     * @param {?} fn
     * @return {?}
     */
    DomOutlet.prototype.setDisposeFn = /**
     * @param {?} fn
     * @return {?}
     */
    function (fn) {
        this.disposeFn = fn;
    };
    /**
     * @param {?} template
     * @return {?}
     */
    DomOutlet.prototype.attach = /**
     * @param {?} template
     * @return {?}
     */
    function (template) {
        this.template = template;
        return this.attachTemplate(template);
    };
    /**
     * @return {?}
     */
    DomOutlet.prototype.detach = /**
     * @return {?}
     */
    function () {
        if (this.template) {
            this.template.setAttachedHost(null);
            this.template = null;
        }
        this.invokeDisposeFn();
    };
    /**
     * @param {?=} removeParent
     * @return {?}
     */
    DomOutlet.prototype.dispose = /**
     * @param {?=} removeParent
     * @return {?}
     */
    function (removeParent) {
        if (removeParent === void 0) { removeParent = true; }
        this.disposeFn();
        if (removeParent && this.targetElement.parentNode != null) {
            this.targetElement.parentNode.removeChild(this.targetElement);
        }
        return undefined;
    };
    /**
     * @private
     * @return {?}
     */
    DomOutlet.prototype.invokeDisposeFn = /**
     * @private
     * @return {?}
     */
    function () {
        if (this.disposeFn) {
            this.disposeFn();
            this.disposeFn = null;
        }
    };
    return DomOutlet;
}());
if (false) {
    /**
     * @type {?}
     * @private
     */
    DomOutlet.prototype.disposeFn;
    /**
     * @type {?}
     * @private
     */
    DomOutlet.prototype.template;
    /**
     * @type {?}
     * @private
     */
    DomOutlet.prototype._viewRef;
    /** @type {?} */
    DomOutlet.prototype.targetElement;
}
/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
var Template = /** @class */ (function () {
    function Template(templateDirective, context) {
        this.templateDirective = templateDirective;
        this.context = context;
    }
    Object.defineProperty(Template.prototype, "origin", {
        get: /**
         * @return {?}
         */
        function () {
            return this.templateDirective.template.elementRef;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Template.prototype, "templateRef", {
        get: /**
         * @return {?}
         */
        function () {
            return this.templateDirective.template;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Template.prototype, "viewContainerRef", {
        get: /**
         * @return {?}
         */
        function () {
            return this.templateDirective.viewContainerRef;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Template.prototype, "zone", {
        get: /**
         * @return {?}
         */
        function () {
            return this.templateDirective.zone;
        },
        enumerable: true,
        configurable: true
    });
    /**
     * @param {?} host
     * @param {?=} context
     * @return {?}
     */
    Template.prototype.attach = /**
     * @param {?} host
     * @param {?=} context
     * @return {?}
     */
    function (host, context) {
        if (context === void 0) { context = this.context; }
        this.context = context;
        this.host = host;
        return host.attach(this);
    };
    /**
     * @return {?}
     */
    Template.prototype.detach = /**
     * @return {?}
     */
    function () {
        this.context = undefined;
        if (this.host) {
            /** @type {?} */
            var host = this.host;
            this.host = null;
            host.detach();
        }
    };
    /**
     * @param {?} host
     * @return {?}
     */
    Template.prototype.setAttachedHost = /**
     * @param {?} host
     * @return {?}
     */
    function (host) {
        this.host = host;
    };
    return Template;
}());
if (false) {
    /**
     * @type {?}
     * @private
     */
    Template.prototype.host;
    /**
     * @type {?}
     * @private
     */
    Template.prototype.templateDirective;
    /** @type {?} */
    Template.prototype.context;
}
/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
var TemplateDirective = /** @class */ (function () {
    function TemplateDirective(_template, _viewRef, _zone) {
        this._template = _template;
        this._viewRef = _viewRef;
        this._zone = _zone;
    }
    Object.defineProperty(TemplateDirective.prototype, "anjTemplateOf", {
        set: /**
         * @param {?} name
         * @return {?}
         */
        function (name) {
            this._name = name;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(TemplateDirective.prototype, "name", {
        get: /**
         * @return {?}
         */
        function () {
            return this._name;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(TemplateDirective.prototype, "template", {
        get: /**
         * @return {?}
         */
        function () {
            return this._template;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(TemplateDirective.prototype, "viewContainerRef", {
        get: /**
         * @return {?}
         */
        function () {
            return this._viewRef;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(TemplateDirective.prototype, "zone", {
        get: /**
         * @return {?}
         */
        function () {
            return this._zone;
        },
        enumerable: true,
        configurable: true
    });
    TemplateDirective.decorators = [
        { type: Directive, args: [{
                    selector: '[anjTemplate]'
                },] }
    ];
    /** @nocollapse */
    TemplateDirective.ctorParameters = function () { return [
        { type: TemplateRef },
        { type: ViewContainerRef },
        { type: NgZone }
    ]; };
    TemplateDirective.propDecorators = {
        anjTemplateOf: [{ type: Input }]
    };
    return TemplateDirective;
}());
if (false) {
    /**
     * @type {?}
     * @private
     */
    TemplateDirective.prototype._name;
    /**
     * @type {?}
     * @private
     */
    TemplateDirective.prototype._template;
    /**
     * @type {?}
     * @private
     */
    TemplateDirective.prototype._viewRef;
    /**
     * @type {?}
     * @private
     */
    TemplateDirective.prototype._zone;
}
/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
/**
 * @record
 */
function RowContext() { }
if (false) {
    /** @type {?} */
    RowContext.prototype.$implicit;
    /** @type {?|undefined} */
    RowContext.prototype.column;
    /** @type {?} */
    RowContext.prototype.index;
}
/**
 * @record
 */
function OutletMap() { }
/* tslint:disable:directive-selector */
var AnjTable = /** @class */ (function () {
    function AnjTable(elRef) {
        this.outletRows = [];
        this.element = elRef.nativeElement;
        this.element.renderer = this;
    }
    /**
     * @private
     * @param {?} row
     * @param {?} index
     * @param {?=} column
     * @return {?}
     */
    AnjTable.rowContext = /**
     * @private
     * @param {?} row
     * @param {?} index
     * @param {?=} column
     * @return {?}
     */
    function (row, index, column) {
        return {
            $implicit: row,
            column: column,
            index: index
        };
    };
    /**
     * @private
     * @param {?} outlet
     * @param {?} context
     * @return {?}
     */
    AnjTable.updateContext = /**
     * @private
     * @param {?} outlet
     * @param {?} context
     * @return {?}
     */
    function (outlet, context) {
        outlet.updateContext(context);
    };
    /**
     * @return {?}
     */
    AnjTable.prototype.ngOnDestroy = /**
     * @return {?}
     */
    function () {
        this.outletRows.map((/**
         * @param {?} rowMap
         * @return {?}
         */
        function (rowMap) {
            for (var templateName in rowMap) {
                if (rowMap[templateName]) {
                    rowMap[templateName] = rowMap[templateName].dispose();
                }
            }
            return rowMap;
        }));
    };
    /**
     * Fixes https://git.zias.io/ui-foundation/anjuna/issues/876
     * When the columns change, destory all portals without killing the parent node
     */
    /**
     * Fixes https://git.zias.io/ui-foundation/anjuna/issues/876
     * When the columns change, destory all portals without killing the parent node
     * @return {?}
     */
    AnjTable.prototype.onColumnsUpdated = /**
     * Fixes https://git.zias.io/ui-foundation/anjuna/issues/876
     * When the columns change, destory all portals without killing the parent node
     * @return {?}
     */
    function () {
        this.outletRows.map((/**
         * @param {?} rowMap
         * @return {?}
         */
        function (rowMap) {
            for (var templateName in rowMap) {
                if (rowMap[templateName]) {
                    rowMap[templateName] = rowMap[templateName].dispose(false);
                }
            }
            return rowMap;
        }));
    };
    /* These next three methods are a mess of duplicated logic - they will probably stay that way until feature complete, then I'll clean em up */
    /* These next three methods are a mess of duplicated logic - they will probably stay that way until feature complete, then I'll clean em up */
    /**
     * @param {?} cell
     * @param {?} offset
     * @param {?} col
     * @param {?} row
     * @param {?} rowIndex
     * @param {?} template
     * @return {?}
     */
    AnjTable.prototype.cellTemplate = /* These next three methods are a mess of duplicated logic - they will probably stay that way until feature complete, then I'll clean em up */
    /**
     * @param {?} cell
     * @param {?} offset
     * @param {?} col
     * @param {?} row
     * @param {?} rowIndex
     * @param {?} template
     * @return {?}
     */
    function (cell, offset, col, row, rowIndex, template) {
        /** @type {?} */
        var rowMap = this.outletRows[rowIndex] || {};
        /** @type {?} */
        var outlet = rowMap[col.name];
        if (!cell) {
            /**
             * Removing the line:
             * rowMap[col.name] = outlet ? outlet.dispose() : undefined;
             * which fixes https://git.zias.io/ui-foundation/anjuna/issues/850.
             * Like the detail situation, I do not understand why this works..
             */
            return;
        }
        if (outlet) {
            if (cell !== outlet.targetElement) {
                this.updateOutlet(outlet, template, cell, AnjTable.rowContext(row, rowIndex, col));
            }
            else {
                AnjTable.updateContext(outlet, AnjTable.rowContext(row, rowIndex, col));
            }
        }
        else {
            rowMap[col.name] = this.createOutlet(cell, template, AnjTable.rowContext(row, rowIndex, col));
            this.outletRows[rowIndex] = rowMap;
        }
        col.initCell(cell, offset);
    };
    /**
     * @param {?} templateName
     * @param {?} targetEl
     * @param {?} row
     * @param {?} rowIndex
     * @return {?}
     */
    AnjTable.prototype.rowTemplate = /**
     * @param {?} templateName
     * @param {?} targetEl
     * @param {?} row
     * @param {?} rowIndex
     * @return {?}
     */
    function (templateName, targetEl, row, rowIndex) {
        // Dispose row template no longer used for that index
        this.outletRows[rowIndex] = this.filterRowTemplates(this.outletRows[rowIndex], templateName);
        /** @type {?} */
        var outlet = this.outletRows[rowIndex][templateName];
        if (!targetEl) {
            this.outletRows[rowIndex][templateName] = outlet ? outlet.dispose() : undefined;
            return;
        }
        if (outlet) {
            if (targetEl !== outlet.targetElement) {
                this.updateOutlet(outlet, templateName, targetEl, AnjTable.rowContext(row, rowIndex));
            }
            else {
                AnjTable.updateContext(outlet, AnjTable.rowContext(row, rowIndex));
            }
        }
        else {
            this.outletRows[rowIndex][templateName] = this.createOutlet(targetEl, templateName, AnjTable.rowContext(row, rowIndex));
            this.outletRows[rowIndex] = this.outletRows[rowIndex];
        }
    };
    /**
     * @param {?} templateName
     * @param {?} targetEl
     * @param {?} row
     * @param {?} rowIndex
     * @return {?}
     */
    AnjTable.prototype.fromTemplate = /**
     * @param {?} templateName
     * @param {?} targetEl
     * @param {?} row
     * @param {?} rowIndex
     * @return {?}
     */
    function (templateName, targetEl, row, rowIndex) {
        /** @type {?} */
        var rowMap = this.outletRows[rowIndex] || {};
        /** @type {?} */
        var outlet = rowMap[templateName];
        if (!targetEl) {
            /**
             * Removing the line:
             * rowMap[templateName] = outlet ? outlet.dispose() : undefined;
             * is part of the fix for https://git.zias.io/ui-foundation/anjuna/issues/750
             * However, I don't grok at all how/why this works. I don't buy it.
             * So when we eventually get an issue related to master detail, start here.
             * Put that line back, and fix it right.
             */
            return;
        }
        if (outlet) {
            if (targetEl !== outlet.targetElement) {
                this.updateOutlet(outlet, templateName, targetEl, AnjTable.rowContext(row, rowIndex));
            }
            else {
                AnjTable.updateContext(outlet, AnjTable.rowContext(row, rowIndex));
            }
        }
        else {
            rowMap[templateName] = this.createOutlet(targetEl, templateName, AnjTable.rowContext(row, rowIndex));
            this.outletRows[rowIndex] = rowMap;
        }
    };
    /**
     * @private
     * @param {?} target
     * @param {?} templateName
     * @param {?} context
     * @return {?}
     */
    AnjTable.prototype.createOutlet = /**
     * @private
     * @param {?} target
     * @param {?} templateName
     * @param {?} context
     * @return {?}
     */
    function (target, templateName, context) {
        /** @type {?} */
        var outlet = new DomOutlet(target);
        outlet.attach(this.createTemplate(templateName, context));
        return outlet;
    };
    /**
     * @private
     * @param {?} templateName
     * @param {?} context
     * @return {?}
     */
    AnjTable.prototype.createTemplate = /**
     * @private
     * @param {?} templateName
     * @param {?} context
     * @return {?}
     */
    function (templateName, context) {
        /** @type {?} */
        var templateRef = this.templates.find((/**
         * @param {?} t
         * @return {?}
         */
        function (t) { return t.name === templateName; }));
        return new Template(templateRef, context);
    };
    /**
     * @private
     * @param {?} outlet
     * @param {?} templateName
     * @param {?} targetEl
     * @param {?} context
     * @return {?}
     */
    AnjTable.prototype.updateOutlet = /**
     * @private
     * @param {?} outlet
     * @param {?} templateName
     * @param {?} targetEl
     * @param {?} context
     * @return {?}
     */
    function (outlet, templateName, targetEl, context) {
        outlet.targetElement = targetEl;
        outlet.detach();
        outlet.attach(this.createTemplate(templateName, context));
    };
    /**
     * Disposes of row templates no longer used in a given row. This ONLY happens if they have specified more than one
     * Template and the end user sorts or filters or otherwise changes the order. If only one template is specified,
     * the output will always match the input -r
     */
    /**
     * Disposes of row templates no longer used in a given row. This ONLY happens if they have specified more than one
     * Template and the end user sorts or filters or otherwise changes the order. If only one template is specified,
     * the output will always match the input -r
     * @private
     * @param {?=} rowMap
     * @param {?=} templateName
     * @return {?}
     */
    AnjTable.prototype.filterRowTemplates = /**
     * Disposes of row templates no longer used in a given row. This ONLY happens if they have specified more than one
     * Template and the end user sorts or filters or otherwise changes the order. If only one template is specified,
     * the output will always match the input -r
     * @private
     * @param {?=} rowMap
     * @param {?=} templateName
     * @return {?}
     */
    function (rowMap, templateName) {
        if (rowMap === void 0) { rowMap = {}; }
        /** @type {?} */
        var updated = {};
        Object.keys(rowMap).forEach((/**
         * @param {?} k
         * @return {?}
         */
        function (k) {
            if (k === templateName) {
                updated[k] = rowMap[k];
            }
            else {
                rowMap[k].dispose(false);
            }
        }));
        return updated;
    };
    AnjTable.decorators = [
        { type: Directive, args: [{
                    selector: 'anj-table:not([anjIgnore])',
                },] }
    ];
    /** @nocollapse */
    AnjTable.ctorParameters = function () { return [
        { type: ElementRef }
    ]; };
    AnjTable.propDecorators = {
        templates: [{ type: ContentChildren, args: [TemplateDirective,] }],
        onColumnsUpdated: [{ type: HostListener, args: ['anjColumnsDidUpdate',] }]
    };
    return AnjTable;
}());
if (false) {
    /**
     * @type {?}
     * @private
     */
    AnjTable.prototype.templates;
    /** @type {?} */
    AnjTable.prototype.element;
    /**
     * @type {?}
     * @private
     */
    AnjTable.prototype.outletRows;
}
/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
/** @enum {number} */
var TransitionState = {
    Enter: 0,
    Leave: 1,
    EnterTo: 2,
    Inactive: 3,
};
TransitionState[TransitionState.Enter] = 'Enter';
TransitionState[TransitionState.Leave] = 'Leave';
TransitionState[TransitionState.EnterTo] = 'EnterTo';
TransitionState[TransitionState.Inactive] = 'Inactive';
/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
var TransitionDirective = /** @class */ (function () {
    function TransitionDirective(renderer, element, mode, name) {
        this.renderer = renderer;
        this.element = element;
        this.mode = mode;
        this.name = name;
        this.state = TransitionState.EnterTo;
        this.end = new EventEmitter();
        this.mode = this.mode ? this.mode : 'in-out';
        this.name = this.name ? this.name : 'transition';
    }
    /**
     * @param {?} changes
     * @return {?}
     */
    TransitionDirective.prototype.ngOnChanges = /**
     * @param {?} changes
     * @return {?}
     */
    function (changes) {
        this.endTransition();
        if (!changes.anjTransition.previousValue && !changes.anjTransition.currentValue && this.mode !== 'out') {
            this.initEnter();
        }
        else if (!changes.anjTransition.previousValue && changes.anjTransition.currentValue) {
            this.transitionIn();
        }
        else {
            this.transitionOut();
        }
    };
    /**
     * @param {?} event
     * @return {?}
     */
    TransitionDirective.prototype.handleTransition = /**
     * @param {?} event
     * @return {?}
     */
    function (event) {
        if (event.target === this.element.nativeElement && TransitionDirective.supportedTransitions.indexOf(event.propertyName) > -1) {
            event.stopPropagation();
            this.end.emit(this.state);
            if (this.state === TransitionState.Enter) {
                this.endTransition();
            }
            else {
                if (this.mode !== 'out' && this.anjTransition) {
                    this.transitionIn();
                }
                else {
                    this.endTransition();
                }
            }
        }
    };
    /**
     * @private
     * @return {?}
     */
    TransitionDirective.prototype.initEnter = /**
     * @private
     * @return {?}
     */
    function () {
        this.renderer.addClass(this.element.nativeElement, "anj-" + this.name + "-enter-to");
    };
    /**
     * @private
     * @return {?}
     */
    TransitionDirective.prototype.transitionIn = /**
     * @private
     * @return {?}
     */
    function () {
        if (this.mode !== 'out') {
            this.state = TransitionState.Enter;
            this.renderer.removeClass(this.element.nativeElement, "anj-" + this.name + "-enter-to");
            this.renderer.removeClass(this.element.nativeElement, "anj-" + this.name + "-leave");
            this.renderer.removeClass(this.element.nativeElement, "anj-" + this.name + "-leave-active");
            this.renderer.addClass(this.element.nativeElement, "anj-" + this.name + "-enter-active");
            this.renderer.addClass(this.element.nativeElement, "anj-" + this.name + "-enter");
        }
        else {
            this.renderer.removeClass(this.element.nativeElement, "anj-" + this.name + "-enter-to");
            this.endTransition();
        }
    };
    /**
     * @private
     * @return {?}
     */
    TransitionDirective.prototype.transitionOut = /**
     * @private
     * @return {?}
     */
    function () {
        var _this = this;
        this.state = TransitionState.Leave;
        if (this.mode !== 'in') {
            this.renderer.addClass(this.element.nativeElement, "anj-" + this.name + "-leave-active");
            this.renderer.addClass(this.element.nativeElement, "anj-" + this.name + "-leave");
        }
        else {
            this.renderer.addClass(this.element.nativeElement, "anj-" + this.name + "-enter-to");
            this.state = TransitionState.EnterTo;
            if (this.anjTransition) {
                window.setTimeout((/**
                 * @return {?}
                 */
                function () {
                    _this.transitionIn();
                }));
            }
        }
    };
    /**
     * @private
     * @return {?}
     */
    TransitionDirective.prototype.endTransition = /**
     * @private
     * @return {?}
     */
    function () {
        this.state = TransitionState.Inactive;
        this.renderer.removeClass(this.element.nativeElement, "anj-" + this.name + "-enter-active");
        this.renderer.removeClass(this.element.nativeElement, "anj-" + this.name + "-leave-active");
        this.renderer.removeClass(this.element.nativeElement, "anj-" + this.name + "-enter");
        this.renderer.removeClass(this.element.nativeElement, "anj-" + this.name + "-leave");
        if (!this.anjTransition) {
            this.renderer.addClass(this.element.nativeElement, "anj-" + this.name + "-enter-to");
        }
    };
    TransitionDirective.supportedTransitions = ['opacity', 'transform'];
    TransitionDirective.decorators = [
        { type: Directive, args: [{
                    selector: '[anjTransition]'
                },] }
    ];
    /** @nocollapse */
    TransitionDirective.ctorParameters = function () { return [
        { type: Renderer2 },
        { type: ElementRef },
        { type: undefined, decorators: [{ type: Attribute, args: ['mode',] }] },
        { type: String, decorators: [{ type: Attribute, args: ['name',] }] }
    ]; };
    TransitionDirective.propDecorators = {
        anjTransition: [{ type: Input }],
        end: [{ type: Output }],
        handleTransition: [{ type: HostListener, args: ['transitiend', ['$event'],] }]
    };
    return TransitionDirective;
}());
if (false) {
    /**
     * @type {?}
     * @private
     */
    TransitionDirective.supportedTransitions;
    /** @type {?} */
    TransitionDirective.prototype.anjTransition;
    /** @type {?} */
    TransitionDirective.prototype.end;
    /**
     * @type {?}
     * @private
     */
    TransitionDirective.prototype.state;
    /**
     * @type {?}
     * @private
     */
    TransitionDirective.prototype.renderer;
    /**
     * @type {?}
     * @private
     */
    TransitionDirective.prototype.element;
    /** @type {?} */
    TransitionDirective.prototype.mode;
    /** @type {?} */
    TransitionDirective.prototype.name;
}
/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
/** @type {?} */
var TIME_TIMEZONE_STRING = new InjectionToken('TimeTimezoneString');
/** @type {?} */
var TIME_MERIDIEM = new InjectionToken('TimeMeridiem');
/** @type {?} */
var DATE_TIMEZONE_OVERRIDE = new InjectionToken('DateTimezoneOverride');
/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
/* tslint:disable:directive-selector */
var LocaleDirective = /** @class */ (function () {
    function LocaleDirective(changeRef, _locale, _lang, _timezone) {
        this.changeRef = changeRef;
        if (_locale) {
            this._locale = _locale;
            this._lang = _lang ? _lang : this._locale ? this._locale.split('-')[0] : 'en';
        }
        if (_timezone) {
            this._timezone = _timezone;
        }
        this.changeRef.markForCheck();
    }
    LocaleDirective.decorators = [
        { type: Directive, args: [{
                    selector: 'anj-locale',
                },] }
    ];
    /** @nocollapse */
    LocaleDirective.ctorParameters = function () { return [
        { type: ChangeDetectorRef },
        { type: String, decorators: [{ type: Optional }, { type: Inject, args: [LOCALE_ID,] }] },
        { type: String, decorators: [{ type: Optional }, { type: Inject, args: [LANGUAGE_CODE,] }] },
        { type: String, decorators: [{ type: Optional }, { type: Inject, args: [DATE_TIMEZONE_OVERRIDE,] }] }
    ]; };
    LocaleDirective.propDecorators = {
        _locale: [{ type: HostBinding, args: ['attr.locale',] }],
        _lang: [{ type: HostBinding, args: ['attr.lang',] }],
        _timezone: [{ type: HostBinding, args: ['attr.timezone',] }]
    };
    return LocaleDirective;
}());
if (false) {
    /** @type {?} */
    LocaleDirective.prototype._locale;
    /** @type {?} */
    LocaleDirective.prototype._lang;
    /** @type {?} */
    LocaleDirective.prototype._timezone;
    /**
     * @type {?}
     * @private
     */
    LocaleDirective.prototype.changeRef;
}
/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
var ValueAccessor = /** @class */ (function () {
    function ValueAccessor(element, parentForm, parentGroup, injector, changeRef) {
        this.element = element;
        this.injector = injector;
        this.changeRef = changeRef;
        /**
         * Enable two-way binding
         */
        this.valueChange = new EventEmitter();
        this.onChange = (/**
         * @return {?}
         */
        function () { });
        this.onTouched = (/**
         * @return {?}
         */
        function () { });
        this.parent = parentForm ? parentForm : parentGroup ? parentGroup : null;
    }
    Object.defineProperty(ValueAccessor.prototype, "isInvalid", {
        get: /**
         * @return {?}
         */
        function () {
            if (!this.ngControl) {
                return false;
            }
            /** @type {?} */
            var isSubmitted = (this.parent && this.parent.submitted);
            return this.ngControl.invalid && (this.ngControl.touched || isSubmitted);
        },
        enumerable: true,
        configurable: true
    });
    /**
     * @return {?}
     */
    ValueAccessor.prototype.ngAfterViewInit = /**
     * @return {?}
     */
    function () {
        var _this = this;
        /** @type {?} */
        var control = this.injector.get((/** @type {?} */ (NgControl)), null);
        if (control) {
            this.ngControl = (/** @type {?} */ (control.control));
            this.element.nativeElement.validationStrategy = this;
        }
        if (this.parent && this.parent.statusChanges) {
            this.parentSubscription = this.parent.statusChanges.subscribe({
                next: (/**
                 * @return {?}
                 */
                function () {
                    _this.changeRef.markForCheck();
                })
            });
        }
    };
    /**
     * @return {?}
     */
    ValueAccessor.prototype.ngOnDestroy = /**
     * @return {?}
     */
    function () {
        if (this.parentSubscription) {
            this.parentSubscription.unsubscribe();
        }
    };
    /**
     * @return {?}
     */
    ValueAccessor.prototype.onAnjBlur = /**
     * @return {?}
     */
    function () {
        this.onTouched();
    };
    /**
     * @param {?} value
     * @return {?}
     */
    ValueAccessor.prototype.writeValue = /**
     * @param {?} value
     * @return {?}
     */
    function (value) {
        this.element.nativeElement.value = this.lastValue = value == null ? '' : value;
    };
    /**
     * @param {?} value
     * @return {?}
     */
    ValueAccessor.prototype.onChangeEvent = /**
     * @param {?} value
     * @return {?}
     */
    function (value) {
        if (value !== this.lastValue) {
            this.lastValue = value;
            this.onChange(value);
            this.valueChange.emit(value);
        }
    };
    /**
     * @param {?} fn
     * @return {?}
     */
    ValueAccessor.prototype.registerOnChange = /**
     * @param {?} fn
     * @return {?}
     */
    function (fn) {
        this.onChange = fn;
    };
    /**
     * @param {?} fn
     * @return {?}
     */
    ValueAccessor.prototype.registerOnTouched = /**
     * @param {?} fn
     * @return {?}
     */
    function (fn) {
        this.onTouched = fn;
    };
    /**
     * @param {?} isDisabled
     * @return {?}
     */
    ValueAccessor.prototype.setDisabledState = /**
     * @param {?} isDisabled
     * @return {?}
     */
    function (isDisabled) {
        this.element.nativeElement.disabled = isDisabled;
    };
    // Called by Anjuna Element, so needs to exist, but Angular does all the hoof-work
    // Called by Anjuna Element, so needs to exist, but Angular does all the hoof-work
    /**
     * @return {?}
     */
    ValueAccessor.prototype.onValidChange = 
    // Called by Anjuna Element, so needs to exist, but Angular does all the hoof-work
    /**
     * @return {?}
     */
    function () { };
    /** @nocollapse */
    ValueAccessor.ctorParameters = function () { return [
        { type: ElementRef },
        { type: NgForm },
        { type: FormGroupDirective },
        { type: Injector },
        { type: ChangeDetectorRef, decorators: [{ type: Optional }] }
    ]; };
    ValueAccessor.propDecorators = {
        isInvalid: [{ type: HostBinding, args: ['attr.invalid',] }],
        valueChange: [{ type: Output }],
        onAnjBlur: [{ type: HostListener, args: ['anjBlur',] }]
    };
    return ValueAccessor;
}());
if (false) {
    /**
     * Enable two-way binding
     * @type {?}
     */
    ValueAccessor.prototype.valueChange;
    /**
     * @type {?}
     * @protected
     */
    ValueAccessor.prototype.ngControl;
    /**
     * @type {?}
     * @protected
     */
    ValueAccessor.prototype.lastValue;
    /**
     * @type {?}
     * @private
     */
    ValueAccessor.prototype.parent;
    /**
     * @type {?}
     * @private
     */
    ValueAccessor.prototype.parentSubscription;
    /**
     * @type {?}
     * @private
     */
    ValueAccessor.prototype.onChange;
    /** @type {?} */
    ValueAccessor.prototype.onTouched;
    /**
     * @type {?}
     * @protected
     */
    ValueAccessor.prototype.element;
    /**
     * @type {?}
     * @protected
     */
    ValueAccessor.prototype.injector;
    /**
     * @type {?}
     * @protected
     */
    ValueAccessor.prototype.changeRef;
}
/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
/* tslint:disable:directive-selector */
var BooleanValueDirective = /** @class */ (function (_super) {
    __extends(BooleanValueDirective, _super);
    function BooleanValueDirective(parentForm, parentFormGroup, element, injector, changeRef) {
        return _super.call(this, element, parentForm, parentFormGroup, injector, changeRef) || this;
    }
    /**
     * @param {?} value
     * @return {?}
     */
    BooleanValueDirective.prototype.writeValue = /**
     * @param {?} value
     * @return {?}
     */
    function (value) {
        this.element.nativeElement.checked = this.lastValue = value == null ? false : value;
    };
    /**
     * @param {?} value
     * @return {?}
     */
    BooleanValueDirective.prototype.onAnjChange = /**
     * @param {?} value
     * @return {?}
     */
    function (value) {
        this.onChangeEvent(value);
    };
    BooleanValueDirective.decorators = [
        { type: Directive, args: [{
                    selector: 'anj-checkbox, anj-toggle',
                    providers: [
                        {
                            provide: NG_VALUE_ACCESSOR,
                            useExisting: BooleanValueDirective,
                            multi: true
                        }
                    ]
                },] }
    ];
    /** @nocollapse */
    BooleanValueDirective.ctorParameters = function () { return [
        { type: NgForm, decorators: [{ type: Optional }] },
        { type: FormGroupDirective, decorators: [{ type: Optional }] },
        { type: ElementRef },
        { type: Injector },
        { type: ChangeDetectorRef }
    ]; };
    BooleanValueDirective.propDecorators = {
        onAnjChange: [{ type: HostListener, args: ['anjChange', ['$event.target.checked'],] }]
    };
    return BooleanValueDirective;
}(ValueAccessor));
/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
/**
 * \@dynamic
 * @abstract
 */
var AnjunaValidators = /** @class */ (function () {
    function AnjunaValidators() {
    }
    /**
     * @param {?} c
     * @return {?}
     */
    AnjunaValidators.date = /**
     * @param {?} c
     * @return {?}
     */
    function (c) {
        if (!c.value) {
            return;
        }
        /** @type {?} */
        var isValid = true;
        // Handle obvious Invalid Date
        if (c.value.toString() === 'Invalid Date') {
            isValid = false;
            // Handle Moment Date
        }
        else if (typeof c.value._isValid === 'boolean') {
            isValid = c.value._isValid;
            // Handle Native Date
        }
        else {
            isValid = !isNaN(new Date(c.value).getTime());
        }
        if (isValid || c.value === '') {
            return null;
        }
        else {
            return {
                date: {
                    valid: false
                }
            };
        }
    };
    /**
     * @param {?} c
     * @return {?}
     */
    AnjunaValidators.requiredCheck = /**
     * @param {?} c
     * @return {?}
     */
    function (c) {
        if (c.value) {
            return null;
        }
        else {
            return {
                required: {
                    valid: false
                }
            };
        }
    };
    /**
     * @param {?} c
     * @return {?}
     */
    AnjunaValidators.unique = /**
     * @param {?} c
     * @return {?}
     */
    function (c) {
        if (!c.value || !Array.isArray(c.value)) {
            return;
        }
        /** @type {?} */
        var testArray = c.value.filter(Boolean);
        /** @type {?} */
        var isValid = testArray.length === Array.from(new Set(testArray)).length;
        if (isValid) {
            return null;
        }
        else {
            return {
                unique: {
                    valid: false
                }
            };
        }
    };
    AnjunaValidators.minDate = (/**
     * @param {?} min
     * @return {?}
     */
    function (min) {
        return (/**
         * @param {?} c
         * @return {?}
         */
        function (c) {
            if (!c.value) {
                return;
            }
            if (c.value < new Date(min)) {
                return {
                    min: {
                        valid: false
                    }
                };
            }
            else {
                return null;
            }
        });
    });
    AnjunaValidators.maxDate = (/**
     * @param {?} max
     * @return {?}
     */
    function (max) {
        return (/**
         * @param {?} c
         * @return {?}
         */
        function (c) {
            if (!c.value) {
                return;
            }
            if (c.value > new Date(max)) {
                return {
                    max: {
                        valid: false
                    }
                };
            }
            else {
                return null;
            }
        });
    });
    return AnjunaValidators;
}());
if (false) {
    /** @type {?} */
    AnjunaValidators.minDate;
    /** @type {?} */
    AnjunaValidators.maxDate;
}
/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
/* tslint:disable:directive-selector */
var DateValidatorDirective = /** @class */ (function () {
    function DateValidatorDirective() {
    }
    /**
     * @param {?} c
     * @return {?}
     */
    DateValidatorDirective.prototype.validate = /**
     * @param {?} c
     * @return {?}
     */
    function (c) {
        return AnjunaValidators.date(c);
    };
    DateValidatorDirective.decorators = [
        { type: Directive, args: [{
                    selector: '[date][ngModel],[date][formControl]',
                    providers: [
                        { provide: NG_VALIDATORS, useExisting: DateValidatorDirective, multi: true }
                    ]
                },] }
    ];
    return DateValidatorDirective;
}());
/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
var PickerAbstract = /** @class */ (function () {
    function PickerAbstract(_element, changeRef, ngControl) {
        this._element = _element;
        this.changeRef = changeRef;
        this.ngControl = ngControl;
        this.onChange = (/**
         * @return {?}
         */
        function () { });
        this.onTouch = (/**
         * @return {?}
         */
        function () { });
        this.valueChange = new EventEmitter();
        if (this.ngControl) {
            this.ngControl.valueAccessor = this;
        }
    }
    /**
     * @return {?}
     */
    PickerAbstract.prototype.ngAfterViewInit = /**
     * @return {?}
     */
    function () {
        this.picker = this._element.nativeElement.querySelector(this.pickerSelector);
        if (this.picker) {
            this.picker.setInputValue(this.innerDateValue);
            this.outerValue = this._element.nativeElement.value;
        }
    };
    // // Start: ControlValueAccessor requirement
    // // Start: ControlValueAccessor requirement
    /**
     * @param {?} newValue
     * @return {?}
     */
    PickerAbstract.prototype.writeValue = 
    // // Start: ControlValueAccessor requirement
    /**
     * @param {?} newValue
     * @return {?}
     */
    function (newValue) {
        if (this.picker && this.innerDateValue !== newValue) {
            this.picker.setInputValue(newValue);
            this.outerValue = this._element.nativeElement.value;
        }
        this.innerDateValue = newValue;
    };
    /**
     * @param {?} fn
     * @return {?}
     */
    PickerAbstract.prototype.registerOnChange = /**
     * @param {?} fn
     * @return {?}
     */
    function (fn) {
        this.onChange = fn;
    };
    /**
     * @param {?} fn
     * @return {?}
     */
    PickerAbstract.prototype.registerOnTouched = /**
     * @param {?} fn
     * @return {?}
     */
    function (fn) {
        this.onTouch = fn;
    };
    // // End: ControlValueAccessor requirements
    // // End: ControlValueAccessor requirements
    /**
     * @param {?} changedVal
     * @return {?}
     */
    PickerAbstract.prototype.changeHandler = 
    // // End: ControlValueAccessor requirements
    /**
     * @param {?} changedVal
     * @return {?}
     */
    function (changedVal) {
        if (changedVal.refreshOuter) {
            this.outerValue = changedVal.outer;
        }
        this.innerDateValue = changedVal.inner;
        this.propogateInnerValueChange();
        this.changeRef.markForCheck();
        // Handle for keyup
        if (changedVal.inner) {
            this.onTouch();
        }
    };
    /**
     * @private
     * @return {?}
     */
    PickerAbstract.prototype.propogateInnerValueChange = /**
     * @private
     * @return {?}
     */
    function () {
        if (this.ngControl) {
            this.ngControl.control.setValue(this.innerDateValue);
        }
        this.valueChange.emit(this.innerDateValue);
    };
    /** @nocollapse */
    PickerAbstract.ctorParameters = function () { return [
        { type: ElementRef },
        { type: ChangeDetectorRef },
        { type: NgControl, decorators: [{ type: Optional }, { type: Self }] }
    ]; };
    PickerAbstract.propDecorators = {
        ngModel: [{ type: Input }],
        outerValue: [{ type: HostBinding, args: ['value',] }]
    };
    return PickerAbstract;
}());
if (false) {
    /** @type {?} */
    PickerAbstract.prototype.valueChange;
    /** @type {?} */
    PickerAbstract.