/**
 * @dyna-grid/core - Advanced Data Grid / Data Table supporting Javascript / Web Components
 * @version v1.0.5
 * @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 __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var component_1 = require("./component");
var context_1 = require("../context/context");
var dom_1 = require("../utils/dom");
var DyAbstractLabel = /** @class */ (function (_super) {
    __extends(DyAbstractLabel, _super);
    function DyAbstractLabel(config, template) {
        var _this = _super.call(this, template) || this;
        _this.labelSeparator = '';
        _this.labelAlignment = 'left';
        _this.label = '';
        _this.config = config || {};
        return _this;
    }
    DyAbstractLabel.prototype.postConstruct = function () {
        dom_1.addCssClass(this.getGui(), 'dy-labeled');
        dom_1.addCssClass(this.eLabel, 'dy-label');
        var _a = this.config, labelSeparator = _a.labelSeparator, label = _a.label, labelWidth = _a.labelWidth, labelAlignment = _a.labelAlignment;
        if (labelSeparator != null) {
            this.setLabelSeparator(labelSeparator);
        }
        if (label != null) {
            this.setLabel(label);
        }
        if (labelWidth != null) {
            this.setLabelWidth(labelWidth);
        }
        this.setLabelAlignment(labelAlignment || this.labelAlignment);
        this.refreshLabel();
    };
    DyAbstractLabel.prototype.refreshLabel = function () {
        dom_1.clearElement(this.eLabel);
        if (typeof this.label === 'string') {
            this.eLabel.innerText = this.label + this.labelSeparator;
        }
        else if (this.label) {
            this.eLabel.appendChild(this.label);
        }
        if (this.label === '') {
            dom_1.addCssClass(this.eLabel, 'dy-hidden');
            this.eLabel.setAttribute('role', 'presentation');
        }
        else {
            dom_1.removeCssClass(this.eLabel, 'dy-hidden');
            this.eLabel.removeAttribute('role');
        }
    };
    DyAbstractLabel.prototype.setLabelSeparator = function (labelSeparator) {
        if (this.labelSeparator === labelSeparator) {
            return this;
        }
        this.labelSeparator = labelSeparator;
        if (this.label != null) {
            this.refreshLabel();
        }
        return this;
    };
    DyAbstractLabel.prototype.getLabelId = function () {
        this.eLabel.id = this.eLabel.id || "dy-" + this.getCompId() + "-label";
        return this.eLabel.id;
    };
    DyAbstractLabel.prototype.getLabel = function () {
        return this.label;
    };
    DyAbstractLabel.prototype.setLabel = function (label) {
        if (this.label === label) {
            return this;
        }
        this.label = label;
        this.refreshLabel();
        return this;
    };
    DyAbstractLabel.prototype.setLabelAlignment = function (alignment) {
        var eGui = this.getGui();
        dom_1.addOrRemoveCssClass(eGui, 'dy-label-align-left', alignment === 'left');
        dom_1.addOrRemoveCssClass(eGui, 'dy-label-align-right', alignment === 'right');
        dom_1.addOrRemoveCssClass(eGui, 'dy-label-align-top', alignment === 'top');
        return this;
    };
    DyAbstractLabel.prototype.setLabelWidth = function (width) {
        if (this.label == null) {
            return this;
        }
        dom_1.setElementWidth(this.eLabel, width);
        return this;
    };
    __decorate([
        context_1.PostConstruct
    ], DyAbstractLabel.prototype, "postConstruct", null);
    return DyAbstractLabel;
}(component_1.Component));
exports.DyAbstractLabel = DyAbstractLabel;

//# sourceMappingURL=dyAbstractLabel.js.map
