/*!
 *
 * carbon-angular v0.0.5 | label.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, ElementRef, HostBinding, TemplateRef, ViewChild } from "@angular/core";
/**
 * [See demo](../../?path=/story/input--label)
 *
 * ```html
 * <ibm-label labelState="success">
 * 	<label label>Field with success</label>
 * 	<input type="text" class="input-field">
 * </ibm-label>
 *
 * <ibm-label labelState="warning">
 * 	<label label>Field with warning</label>
 * 	<input type="text" class="input-field">
 * </ibm-label>
 *
 * <ibm-label labelState="error">
 * 	<label label>Field with error</label>
 * 	<input type="text" class="input-field">
 * </ibm-label>
 * ```
 *
 * <example-url>../../iframe.html?id=input--label</example-url>
 *
 * @export
 * @class Label
 * @implements {AfterContentInit}
 */
var Label = /** @class */ (function () {
    /**
     * Creates an instance of Label.
     * @memberof Label
     */
    function Label() {
        /**
         * The id of the input item associated with the `Label`. This value is also used to associate the `Label` with
         * its input counterpart through the 'for' attribute.
         * @memberof Label
         */
        this.labelInputID = "ibm-label-" + Label.labelCounter;
        /**
         * State of the `Label` will determine the styles applied.
         * @type {("success" | "warning" | "error" | "")}
         * @memberof Label
         */
        this.labelState = "";
        /**
         * Set to `true` for a loading label.
         */
        this.skeleton = false;
        /**
         * Set to `true` for an invalid label component.
         */
        this.invalid = false;
        this.labelClass = true;
        Label.labelCounter++;
    }
    /**
     * Sets the id on the input item associated with the `Label`.
     * @memberof Label
     */
    Label.prototype.ngAfterContentInit = function () {
        this.wrapper.nativeElement.querySelector("input,textarea,div").setAttribute("id", this.labelInputID);
    };
    Label.prototype.isTemplate = function (value) {
        return value instanceof TemplateRef;
    };
    /**
     * Used to build the id of the input item associated with the `Label`.
     * @static
     * @memberof Label
     */
    Label.labelCounter = 0;
    Label.decorators = [
        { type: Component, args: [{
                    selector: "ibm-label",
                    template: "\n\t\t<label\n\t\t\t[for]=\"labelInputID\"\n\t\t\tclass=\"bx--label\"\n\t\t\t[ngClass]=\"{\n\t\t\t\t'bx--skeleton': skeleton\n\t\t\t}\">\n\t\t\t<ng-content></ng-content>\n\t\t</label>\n\t\t<div *ngIf=\"!skeleton\" class=\"bx--form__helper-text\">{{helperText}}</div>\n\t\t<div class=\"bx--text-input__field-wrapper\" [attr.data-invalid]=\"(invalid ? true : null)\" #wrapper>\n\t\t\t<ibm-icon-warning-filled16\n\t\t\t\t*ngIf=\"invalid\"\n\t\t\t\tclass=\"bx--text-input__invalid-icon bx--text-area__invalid-icon\">\n\t\t\t</ibm-icon-warning-filled16>\n\t\t\t<ng-content select=\"input,textarea,div\"></ng-content>\n\t\t</div>\n\t\t<div *ngIf=\"invalid\" class=\"bx--form-requirement\">\n\t\t\t<ng-container *ngIf=\"!isTemplate(invalidText)\">{{invalidText}}</ng-container>\n\t\t\t<ng-template *ngIf=\"isTemplate(invalidText)\" [ngTemplateOutlet]=\"invalidText\"></ng-template>\n\t\t</div>\n\t"
                },] },
    ];
    /** @nocollapse */
    Label.ctorParameters = function () { return []; };
    Label.propDecorators = {
        labelState: [{ type: Input }],
        skeleton: [{ type: Input }],
        helperText: [{ type: Input }],
        invalidText: [{ type: Input }],
        invalid: [{ type: Input }],
        wrapper: [{ type: ViewChild, args: ["wrapper",] }],
        labelClass: [{ type: HostBinding, args: ["class.bx--form-item",] }]
    };
    return Label;
}());
export { Label };
//# sourceMappingURL=label.component.js.map