/*!
 *
 * carbon-angular v0.0.5 | datepicker-input.component.js
 *
 * Copyright 2014, 2019 IBM
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0

 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


import { Component, Input, Output, EventEmitter, ElementRef, TemplateRef } from "@angular/core";
import { NG_VALUE_ACCESSOR } from "@angular/forms";
var DatePickerInput = /** @class */ (function () {
    function DatePickerInput(elementRef) {
        this.elementRef = elementRef;
        /**
         * Select a calendar type for the `model`.
         * Internal purposes only.
         */
        this.type = "simple";
        this.id = "datepicker-" + DatePickerInput.datePickerCount++;
        this.hasIcon = false;
        this.placeholder = "mm/dd/yyyy";
        this.pattern = "^\\d{1,2}/\\d{1,2}/\\d{4}$";
        this.valueChange = new EventEmitter();
        this.theme = "dark";
        this.disabled = false;
        this.invalid = false;
        this.skeleton = false;
        this.value = "";
        this.onTouched = function () { };
        this.propagateChange = function (_) { };
    }
    DatePickerInput.prototype.onChange = function (event) {
        this.value = event.target.value;
        this.valueChange.emit(this.value);
        this.propagateChange(this.value);
        this.onTouched();
    };
    DatePickerInput.prototype.writeValue = function (value) {
        this.value = value;
    };
    DatePickerInput.prototype.registerOnChange = function (fn) {
        this.propagateChange = fn;
    };
    DatePickerInput.prototype.registerOnTouched = function (fn) {
        this.onTouched = fn;
    };
    DatePickerInput.prototype.isTemplate = function (value) {
        return value instanceof TemplateRef;
    };
    DatePickerInput.datePickerCount = 0;
    DatePickerInput.decorators = [
        { type: Component, args: [{
                    selector: "ibm-date-picker-input",
                    template: "\n\t<div class=\"bx--form-item\">\n\t\t<div class=\"bx--date-picker\"\n\t\t\t[ngClass]=\"{\n\t\t\t\t'bx--date-picker--single' : type === 'single',\n\t\t\t\t'bx--date-picker--range' : type === 'range',\n\t\t\t\t'bx--date-picker--light' : theme === 'light',\n\t\t\t\t'bx--skeleton' : skeleton\n\t\t\t}\">\n\t\t\t<div class=\"bx--date-picker-container\">\n\t\t\t\t<label *ngIf=\"label\" [for]=\"id\" class=\"bx--label\">\n\t\t\t\t\t<ng-container *ngIf=\"!isTemplate(label)\">{{label}}</ng-container>\n\t\t\t\t\t<ng-template *ngIf=\"isTemplate(label)\" [ngTemplateOutlet]=\"label\"></ng-template>\n\t\t\t\t</label>\n\t\t\t\t<div class=\"bx--date-picker-input__wrapper\">\n\t\t\t\t\t<input\n\t\t\t\t\t\t*ngIf=\"!skeleton\"\n\t\t\t\t\t\tautocomplete=\"off\"\n\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\tclass=\"bx--date-picker__input\"\n\t\t\t\t\t\t[value]=\"value\"\n\t\t\t\t\t\t[pattern]=\"pattern\"\n\t\t\t\t\t\t[placeholder]=\"placeholder\"\n\t\t\t\t\t\t[id]= \"id\"\n\t\t\t\t\t\t[disabled]=\"disabled\"\n\t\t\t\t\t\t(change)=\"onChange($event)\"/>\n\t\t\t\t\t\t<ibm-icon-calendar16\n\t\t\t\t\t\t\tclass=\"bx--date-picker__icon\">\n\t\t\t\t\t\t</ibm-icon-calendar16>\n\t\t\t\t</div>\n\t\t\t\t<div *ngIf=\"invalid\" class=\"bx--form-requirement\">\n\t\t\t\t\t<ng-container *ngIf=\"!isTemplate(invalidText)\">{{invalidText}}</ng-container>\n\t\t\t\t\t<ng-template *ngIf=\"isTemplate(invalidText)\" [ngTemplateOutlet]=\"invalidText\"></ng-template>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n\t",
                    providers: [
                        {
                            provide: NG_VALUE_ACCESSOR,
                            useExisting: DatePickerInput,
                            multi: true
                        }
                    ]
                },] },
    ];
    /** @nocollapse */
    DatePickerInput.ctorParameters = function () { return [
        { type: ElementRef }
    ]; };
    DatePickerInput.propDecorators = {
        type: [{ type: Input }],
        id: [{ type: Input }],
        hasIcon: [{ type: Input }],
        label: [{ type: Input }],
        placeholder: [{ type: Input }],
        pattern: [{ type: Input }],
        valueChange: [{ type: Output }],
        theme: [{ type: Input }],
        disabled: [{ type: Input }],
        invalid: [{ type: Input }],
        invalidText: [{ type: Input }],
        skeleton: [{ type: Input }],
        value: [{ type: Input }]
    };
    return DatePickerInput;
}());
export { DatePickerInput };
//# sourceMappingURL=datepicker-input.component.js.map