/**
 * @dyna-grid/core - Advanced Data Grid / Data Table supporting Javascript / Web Components
 * @version v1.0.5
 * @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 __());
    };
})();
import { DyAbstractInputField } from "./dyAbstractInputField";
import { isBrowserIE } from "../utils/browser";
var DyInputRange = /** @class */ (function (_super) {
    __extends(DyInputRange, _super);
    function DyInputRange(config) {
        return _super.call(this, config, 'dy-range-field', 'range') || this;
    }
    DyInputRange.prototype.postConstruct = function () {
        _super.prototype.postConstruct.call(this);
        var _a = this.config, min = _a.min, max = _a.max, step = _a.step;
        if (min != null) {
            this.setMinValue(min);
        }
        if (max != null) {
            this.setMaxValue(max);
        }
        this.setStep(step || 1);
    };
    DyInputRange.prototype.addInputListeners = function () {
        var _this = this;
        var isIE = isBrowserIE();
        var eventName = isIE ? 'change' : 'input';
        this.addManagedListener(this.eInput, eventName, function (e) {
            var value = e.target.value;
            _this.setValue(value);
        });
    };
    DyInputRange.prototype.setMinValue = function (value) {
        this.min = value;
        this.eInput.setAttribute('min', value.toString());
        return this;
    };
    DyInputRange.prototype.setMaxValue = function (value) {
        this.max = value;
        this.eInput.setAttribute('max', value.toString());
        return this;
    };
    DyInputRange.prototype.setStep = function (value) {
        this.eInput.setAttribute('step', value.toString());
        return this;
    };
    DyInputRange.prototype.setValue = function (value, silent) {
        if (this.min != null) {
            value = Math.max(parseFloat(value), this.min).toString();
        }
        if (this.max != null) {
            value = Math.min(parseFloat(value), this.max).toString();
        }
        var ret = _super.prototype.setValue.call(this, value, silent);
        this.eInput.value = value;
        return ret;
    };
    return DyInputRange;
}(DyAbstractInputField));
export { DyInputRange };
