/**
 * @dyna-grid/core - Advanced Data Grid / Data Table supporting Javascript / Web Components
 * @version v1.1.0
 * @link 
 * @license 
 */
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;
};
import { RefSelector } from "./componentAnnotations";
import { DyAbstractLabel } from "./dyAbstractLabel";
import { DyAbstractField } from "./dyAbstractField";
import { PostConstruct } from "../context/context";
import { addCssClass } from "../utils/dom";
var DySlider = /** @class */ (function (_super) {
    __extends(DySlider, _super);
    function DySlider(config) {
        var _this = _super.call(this, config, DySlider.TEMPLATE) || this;
        _this.labelAlignment = 'top';
        return _this;
    }
    DySlider.prototype.init = function () {
        addCssClass(this.eSlider.getGui(), 'dy-slider-field');
    };
    DySlider.prototype.onValueChange = function (callbackFn) {
        var _this = this;
        var eventChanged = DyAbstractField.EVENT_CHANGED;
        this.addManagedListener(this.eText, eventChanged, function () {
            var textValue = parseFloat(_this.eText.getValue());
            _this.eSlider.setValue(textValue.toString(), true);
            callbackFn(textValue || 0);
        });
        this.addManagedListener(this.eSlider, eventChanged, function () {
            var sliderValue = _this.eSlider.getValue();
            _this.eText.setValue(sliderValue, true);
            callbackFn(parseFloat(sliderValue));
        });
        return this;
    };
    DySlider.prototype.setSliderWidth = function (width) {
        this.eSlider.setWidth(width);
        return this;
    };
    DySlider.prototype.setTextFieldWidth = function (width) {
        this.eText.setWidth(width);
        return this;
    };
    DySlider.prototype.setMinValue = function (minValue) {
        this.eSlider.setMinValue(minValue);
        this.eText.setMin(minValue);
        return this;
    };
    DySlider.prototype.setMaxValue = function (maxValue) {
        this.eSlider.setMaxValue(maxValue);
        this.eText.setMax(maxValue);
        return this;
    };
    DySlider.prototype.getValue = function () {
        return this.eText.getValue();
    };
    DySlider.prototype.setValue = function (value) {
        if (this.getValue() === value) {
            return this;
        }
        this.eText.setValue(value, true);
        this.eSlider.setValue(value, true);
        this.dispatchEvent({ type: DyAbstractField.EVENT_CHANGED });
        return this;
    };
    DySlider.prototype.setStep = function (step) {
        this.eSlider.setStep(step);
        this.eText.setStep(step);
        return this;
    };
    DySlider.TEMPLATE = "<div class=\"dy-slider\">\n            <label ref=\"eLabel\"></label>\n            <div class=\"dy-wrapper dy-slider-wrapper\">\n                <dy-input-range ref=\"eSlider\"></dy-input-range>\n                <dy-input-number-field ref=\"eText\"></dy-input-number-field>\n            </div>\n        </div>";
    __decorate([
        RefSelector('eLabel')
    ], DySlider.prototype, "eLabel", void 0);
    __decorate([
        RefSelector('eSlider')
    ], DySlider.prototype, "eSlider", void 0);
    __decorate([
        RefSelector('eText')
    ], DySlider.prototype, "eText", void 0);
    __decorate([
        PostConstruct
    ], DySlider.prototype, "init", null);
    return DySlider;
}(DyAbstractLabel));
export { DySlider };
