/**
 * @dyna-grid/core - Advanced Data Grid / Data Table supporting Javascript / Web Components
 * @version v1.1.0
 * @link 
 * @license 
 */
"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
var dyAbstractLabel_1 = require("./dyAbstractLabel");
var dom_1 = require("../utils/dom");
var DyAbstractField = /** @class */ (function (_super) {
    __extends(DyAbstractField, _super);
    function DyAbstractField(config, template, className) {
        var _this = _super.call(this, config, template) || this;
        _this.className = className;
        _this.disabled = false;
        return _this;
    }
    DyAbstractField.prototype.postConstruct = function () {
        _super.prototype.postConstruct.call(this);
        if (this.className) {
            dom_1.addCssClass(this.getGui(), this.className);
        }
    };
    DyAbstractField.prototype.onValueChange = function (callbackFn) {
        var _this = this;
        this.addManagedListener(this, DyAbstractField.EVENT_CHANGED, function () { return callbackFn(_this.getValue()); });
        return this;
    };
    DyAbstractField.prototype.getWidth = function () {
        return this.getGui().clientWidth;
    };
    DyAbstractField.prototype.setWidth = function (width) {
        dom_1.setFixedWidth(this.getGui(), width);
        return this;
    };
    DyAbstractField.prototype.getPreviousValue = function () {
        return this.previousValue;
    };
    DyAbstractField.prototype.getValue = function () {
        return this.value;
    };
    DyAbstractField.prototype.setValue = function (value, silent) {
        if (this.value === value) {
            return this;
        }
        this.previousValue = this.value;
        this.value = value;
        if (!silent) {
            this.dispatchEvent({ type: DyAbstractField.EVENT_CHANGED });
        }
        return this;
    };
    DyAbstractField.prototype.setDisabled = function (disabled) {
        disabled = !!disabled;
        var element = this.getGui();
        dom_1.setDisabled(element, disabled);
        dom_1.addOrRemoveCssClass(element, 'dy-disabled', disabled);
        this.disabled = disabled;
        return this;
    };
    DyAbstractField.prototype.isDisabled = function () {
        return !!this.disabled;
    };
    DyAbstractField.EVENT_CHANGED = 'valueChange';
    return DyAbstractField;
}(dyAbstractLabel_1.DyAbstractLabel));
exports.DyAbstractField = DyAbstractField;

//# sourceMappingURL=dyAbstractField.js.map
