/**
 * @license
 * Copyright 2017 JBoss Inc
 *
 * 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, ViewEncapsulation } from "@angular/core";
import { TextInputEditorComponent } from "./inline-editor.base";
import { SelectionService } from "../../_services/selection.service";
import { KeypressUtils } from "../../_util/keypress.util";
export class PfInlineTextEditorComponent extends TextInputEditorComponent {
    constructor(selectionService) {
        super(selectionService);
    }
    onInputKeypress(event) {
        super.onInputKeypress(event);
        if (KeypressUtils.isEnterKey(event)) {
            this.onSave();
        }
    }
    clearValue() {
        this.evalue = '';
        this.input.first.nativeElement.focus();
    }
}
PfInlineTextEditorComponent.decorators = [
    { type: Component, args: [{
                selector: "pf-inline-text-editor",
                template: "<span *ngIf=\"!editing\" class=\"inline-editor-label inline-text-editor-label {{ labelClass }} pf-inline-text-editor-label\"\n      title=\"Click to edit.\" (click)=\"onStartEditing()\" [class.disabled]=\"!enabled\">\n    <span [class.empty]=\"isEmpty()\" >{{ displayValue() }}</span>\n    <i class=\"glyphicon glyphicon-pencil\" *ngIf=\"enabled\"></i>\n</span>\n<div *ngIf=\"editing\" class=\"inline-editor inline-text-editor pf-inline-text-editor\">\n    <div class=\"form-control-pf-editable form-control-pf-edit\">\n        <div class=\"form-control-pf-textbox\">\n            <input #newvalue type=\"text\" [(ngModel)]=\"evalue\" class=\"form-control form-control-pf-editor\"\n                   autocomplete=\"off\" (keyup)=\"onInputKeypress($event)\">\n            <button *ngIf=\"!isEditedValueEmpty()\" type=\"button\" class=\"form-control-pf-empty\" aria-label=\"Clear Value\" (click)=\"clearValue()\">\n              <span class=\"fa fa-times-circle fa-lg\"></span>\n            </button>\n        </div>\n        <button title=\"Save changes.\" type=\"button\" class=\"btn btn-primary form-control-pf-save\"\n                aria-label=\"Save\" (click)=\"onSave()\"><i class=\"glyphicon glyphicon-ok\"></i></button>\n        <button title=\"Cancel changes.\" type=\"button\" class=\"btn btn-default form-control-pf-cancel\"\n                aria-label=\"Cancel\" (click)=\"onCancel()\"><i class=\"glyphicon glyphicon-remove\"></i></button>\n    </div>\n</div>\n",
                encapsulation: ViewEncapsulation.None,
                styles: [".pf-inline-text-editor-label{border:1px solid transparent;padding:2px 5px;margin-left:-6px;display:inline-block}.pf-inline-text-editor-label:hover{border-color:#bbb;cursor:pointer}.pf-inline-text-editor-label.disabled:hover{border-color:transparent;cursor:default}.pf-inline-text-editor-label .glyphicon{font-size:11px;margin-left:5px}.pf-inline-text-editor-label:hover .glyphicon{color:#669}.pf-inline-text-editor{margin-right:5px}.pf-inline-text-editor .form-control-pf-textbox{width:100%}"]
            },] }
];
PfInlineTextEditorComponent.ctorParameters = () => [
    { type: SelectionService }
];
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGYtaW5saW5lLXRleHQtZWRpdG9yLmNvbXBvbmVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uLy4uLy4uL3NyYy9hcHAvcGFnZXMvYXBpcy97YXBpSWR9L2VkaXRvci9fY29tcG9uZW50cy9jb21tb24vcGYtaW5saW5lLXRleHQtZWRpdG9yLmNvbXBvbmVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7Ozs7Ozs7Ozs7O0dBZUc7QUFFSCxPQUFPLEVBQUMsU0FBUyxFQUFFLGlCQUFpQixFQUFDLE1BQU0sZUFBZSxDQUFDO0FBQzNELE9BQU8sRUFBQyx3QkFBd0IsRUFBQyxNQUFNLHNCQUFzQixDQUFDO0FBQzlELE9BQU8sRUFBQyxnQkFBZ0IsRUFBQyxNQUF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