/*!
 * Copyright 2020 VMware, Inc.
 * SPDX-License-Identifier: BSD-2-Clause
 */
import { Component, Input, Optional, Self } from '@angular/core';
import { BaseFormControl } from '../base-form-control';
import * as i0 from "@angular/core";
import * as i1 from "@angular/forms";
import * as i2 from "@vcd/i18n";
import * as i3 from "@clr/angular";
import * as i4 from "@angular/common";
import * as i5 from "../../lib/directives/responsive-input/responsive-input.directive";
import * as i6 from "../../lib/directives/alternative-text/alternative-text.directive";
export var CheckBoxStyling;
(function (CheckBoxStyling) {
    CheckBoxStyling["CHECKBOX"] = "checkbox";
    CheckBoxStyling["TOGGLESWITCH"] = "toggle-switch";
})(CheckBoxStyling || (CheckBoxStyling = {}));
/**
 * {@link FormControl} wrapper around a input HTML element of checkbox type. The label input from
 * {@link BaseFormControl} is used for displaying a label on the left of a form field and the text input is used for
 * displaying label on the right of checkbox. Use the 'styling' property with a value of 'checkbox' or 'toggle-switch'
 * to display a checkbox or toggle switch on the UI.
 *
 * Example:
 *      <vcd-form-checkbox [formControlName]="Fields.port" [label]="'enabled'|translate"
 *                         [text]="'feature.enabled'|translate">
 *      </vcd-form-checkbox>
 */
export class FormCheckboxComponent extends BaseFormControl {
    constructor(controlDirective, translationService) {
        super(controlDirective, translationService);
        this.translationService = translationService;
        /**
         * Styling for the checkbox.
         */
        this.styling = CheckBoxStyling.CHECKBOX;
        /**
         * Put the label text on the right.
         */
        this.rightLabel = false;
        /**
         * The direction for displaying the hint
         */
        this.hintPosition = 'top-left';
    }
    get isCheckbox() {
        return this.styling === CheckBoxStyling.CHECKBOX;
    }
}
/** @nocollapse */ FormCheckboxComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.4", ngImport: i0, type: FormCheckboxComponent, deps: [{ token: i1.NgControl, optional: true, self: true }, { token: i2.TranslationService }], target: i0.ɵɵFactoryTarget.Component });
/** @nocollapse */ FormCheckboxComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.4", type: FormCheckboxComponent, selector: "vcd-form-checkbox", inputs: { text: "text", styling: "styling", rightLabel: "rightLabel", iconShape: "iconShape", hintPosition: "hintPosition", hint: "hint" }, usesInheritance: true, ngImport: i0, template: "<div class=\"form-group\">\n    <div\n        class=\"clr-form-control\"\n        [vcdResponsiveInput]=\"{ disabled: !isResponsive }\"\n        [ngClass]=\"{ 'clr-form-control-disabled': disabled }\"\n    >\n        <label class=\"clr-control-label\" [for]=\"id\" *ngIf=\"label\">{{ label }}</label>\n        <div class=\"clr-control-container\" [ngClass]=\"{ 'clr-error': showErrors }\">\n            <div [ngClass]=\"{ 'clr-checkbox-wrapper': isCheckbox, 'clr-toggle-wrapper': !isCheckbox }\">\n                <input\n                    type=\"checkbox\"\n                    [id]=\"id\"\n                    [attr.aria-describedby]=\"showErrors ? errorsId : descriptionId\"\n                    [ngClass]=\"{ 'clr-checkbox': isCheckbox, 'clr-toggle': !isCheckbox }\"\n                    [formControl]=\"formControl\"\n                />\n                <label class=\"clr-control-label\" [for]=\"id\">\n                    <clr-icon *ngIf=\"iconShape\" [attr.shape]=\"iconShape\"></clr-icon>\n                    {{ text }}\n                </label>\n                <clr-signpost *ngIf=\"hint\">\n                    <clr-signpost-content [clrPosition]=\"hintPosition\" *clrIfOpen>\n                        <p>{{ hint }}</p>\n                    </clr-signpost-content>\n                </clr-signpost>\n            </div>\n            <span class=\"clr-subtext\" *ngIf=\"showErrors\" [id]=\"errorsId\">\n                <div *ngFor=\"let key of errorKeys\">\n                    <div>{{ key | translate: formControl.value }}</div>\n                </div>\n            </span>\n            <span class=\"clr-subtext\" *ngIf=\"!showErrors && description\" [id]=\"descriptionId\">\n                {{ description }}\n            </span>\n        </div>\n    </div>\n    <span class=\"clr-subtext\">\n        <ng-content select=\"footer\"></ng-content>\n    </span>\n</div>\n", styles: [".required-field:after{content:\"*\";color:red;padding-left:5px}.form-group ::ng-deep aside{display:inline-block}clr-signpost-content p:first-child{margin-top:0;white-space:pre-line}\n", "label.clr-control-label{display:inline-block}.clr-checkbox-wrapper,.clr-toggle-wrapper{display:flex;align-items:center}.btn-blank{background-color:transparent;border:none;padding:0;cursor:pointer}\n"], dependencies: [{ kind: "directive", type: i3.ClrIconCustomTag, selector: "clr-icon" }, { kind: "directive", type: i3.ClrIfOpen, selector: "[clrIfOpen]", inputs: ["clrIfOpen"], outputs: ["clrIfOpenChange"] }, { kind: "directive", type: i3.ClrLabel, selector: "label", inputs: ["for"] }, { kind: "component", type: i3.ClrSignpost, selector: "clr-signpost" }, { kind: "component", type: i3.ClrSignpostContent, selector: "clr-signpost-content", inputs: ["clrPosition"] }, { kind: "directive", type: i1.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i4.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i5.ResponsiveInputDirective, selector: ".clr-form-control[vcdResponsiveInput]", inputs: ["vcdResponsiveInput"] }, { kind: "directive", type: i6.AlternativeTextDirective, selector: "clr-icon", inputs: ["vcdAlternativeText"] }, { kind: "pipe", type: i2.TranslationPipe, name: "translate" }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.4", ngImport: i0, type: FormCheckboxComponent, decorators: [{
            type: Component,
            args: [{ selector: 'vcd-form-checkbox', template: "<div class=\"form-group\">\n    <div\n        class=\"clr-form-control\"\n        [vcdResponsiveInput]=\"{ disabled: !isResponsive }\"\n        [ngClass]=\"{ 'clr-form-control-disabled': disabled }\"\n    >\n        <label class=\"clr-control-label\" [for]=\"id\" *ngIf=\"label\">{{ label }}</label>\n        <div class=\"clr-control-container\" [ngClass]=\"{ 'clr-error': showErrors }\">\n            <div [ngClass]=\"{ 'clr-checkbox-wrapper': isCheckbox, 'clr-toggle-wrapper': !isCheckbox }\">\n                <input\n                    type=\"checkbox\"\n                    [id]=\"id\"\n                    [attr.aria-describedby]=\"showErrors ? errorsId : descriptionId\"\n                    [ngClass]=\"{ 'clr-checkbox': isCheckbox, 'clr-toggle': !isCheckbox }\"\n                    [formControl]=\"formControl\"\n                />\n                <label class=\"clr-control-label\" [for]=\"id\">\n                    <clr-icon *ngIf=\"iconShape\" [attr.shape]=\"iconShape\"></clr-icon>\n                    {{ text }}\n                </label>\n                <clr-signpost *ngIf=\"hint\">\n                    <clr-signpost-content [clrPosition]=\"hintPosition\" *clrIfOpen>\n                        <p>{{ hint }}</p>\n                    </clr-signpost-content>\n                </clr-signpost>\n            </div>\n            <span class=\"clr-subtext\" *ngIf=\"showErrors\" [id]=\"errorsId\">\n                <div *ngFor=\"let key of errorKeys\">\n                    <div>{{ key | translate: formControl.value }}</div>\n                </div>\n            </span>\n            <span class=\"clr-subtext\" *ngIf=\"!showErrors && description\" [id]=\"descriptionId\">\n                {{ description }}\n            </span>\n        </div>\n    </div>\n    <span class=\"clr-subtext\">\n        <ng-content select=\"footer\"></ng-content>\n    </span>\n</div>\n", styles: [".required-field:after{content:\"*\";color:red;padding-left:5px}.form-group ::ng-deep aside{display:inline-block}clr-signpost-content p:first-child{margin-top:0;white-space:pre-line}\n", "label.clr-control-label{display:inline-block}.clr-checkbox-wrapper,.clr-toggle-wrapper{display:flex;align-items:center}.btn-blank{background-color:transparent;border:none;padding:0;cursor:pointer}\n"] }]
        }], ctorParameters: function () { return [{ type: i1.NgControl, decorators: [{
                    type: Self
                }, {
                    type: Optional
                }] }, { type: i2.TranslationService }]; }, propDecorators: { text: [{
                type: Input
            }], styling: [{
                type: Input
            }], rightLabel: [{
                type: Input
            }], iconShape: [{
                type: Input
            }], hintPosition: [{
                type: Input
            }], hint: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 