import { Component, HostListener } from '@angular/core';
import { DefaultEditorDirective } from '../../../lib/editor-cell-default';
import * as i0 from "@angular/core";
import * as i1 from "../../../../switch/switch.component";
export class SwitchEditorComponent extends DefaultEditorDirective {
    constructor() {
        super();
    }
    onToggle() {
        if (this.disable) {
            return;
        }
        this.checked = !this.checked;
        this.cell.newValue = this.checked;
        this.editingFormGroup.controls[this.cell.column.id].setValue(this.checked);
    }
    ngOnInit() {
        // If user click on create the cell.getValue() is a instance of string.
        this.checked = (typeof this.cell.getValue() === 'string') ? false : this.cell.getValue();
        this.disable = !this.cell.column.isEditable;
        this.editingFormGroup.controls[this.cell.column.id].setValue(this.checked);
    }
}
SwitchEditorComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: SwitchEditorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
SwitchEditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: SwitchEditorComponent, selector: "switch-editor", host: { listeners: { "click": "onToggle()" } }, usesInheritance: true, ngImport: i0, template: `
        <div class="form-cell form-editor-switch">
            <uno-switch [checked]="checked" [disable]="disable"></uno-switch>
        </div>
    `, isInline: true, styles: [":host input,:host textarea{width:100%;line-height:normal;padding:.375em .75em}:host input.form-control.ng-invalid.ng-touched,:host textarea.form-control.ng-invalid.ng-touched{border:1px solid var(--special-red-2)}:host input.form-control.ng-valid.ng-touched:not(.no-validator),:host textarea.form-control.ng-valid.ng-touched:not(.no-validator){border:none}.line-clamp{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;word-break:normal;overflow:hidden}.view-default-expanded{text-align:justify;word-wrap:break-word}\n"], dependencies: [{ kind: "component", type: i1.SwitchComponent, selector: "uno-switch", inputs: ["checked", "disable", "minWidth", "size", "enabledText", "disabledText"], outputs: ["changed"] }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: SwitchEditorComponent, decorators: [{
            type: Component,
            args: [{ selector: 'switch-editor', template: `
        <div class="form-cell form-editor-switch">
            <uno-switch [checked]="checked" [disable]="disable"></uno-switch>
        </div>
    `, styles: [":host input,:host textarea{width:100%;line-height:normal;padding:.375em .75em}:host input.form-control.ng-invalid.ng-touched,:host textarea.form-control.ng-invalid.ng-touched{border:1px solid var(--special-red-2)}:host input.form-control.ng-valid.ng-touched:not(.no-validator),:host textarea.form-control.ng-valid.ng-touched:not(.no-validator){border:none}.line-clamp{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;word-break:normal;overflow:hidden}.view-default-expanded{text-align:justify;word-wrap:break-word}\n"] }]
        }], ctorParameters: function () { return []; }, propDecorators: { onToggle: [{
                type: HostListener,
                args: ['click']
            }] } });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3dpdGNoLWVkaXRvci5jb21wb25lbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi8uLi9wcm9qZWN0cy91bm8tdWktbGliL3NyYy9saWIvdGFibGUvY29tcG9uZW50cy9jZWxsL2NlbGwtZWRpdG9ycy9zd2l0Y2gtZWRpdG9yLmNvbXBvbmVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsU0FBUyxFQUFFLFlBQVksRUFBVSxNQUFNLGVBQWUsQ0FBQztBQUVoRSxPQUFPLEVBQUUsc0JBQXNCLEVBQUUsTUFBTSxrQ0FBa0MsQ0FBQzs7O0FBVzFFLE1BQU0sT0FBTyxxQkFBc0IsU0FBUSxzQkFBc0I7SUFnQjdEO1FBQ0ksS0FBSyxFQUFFLENBQUM7SUFDWixDQUFDO0lBYnNCLFFBQVE7UUFDM0IsSUFBSSxJQUFJLENBQUMsT0FBTyxFQUFFO1lBQ2QsT0FBTztTQUNWO1FBRUQsSUFBSSxDQUFDLE9BQU8sR0FBRy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