/* eslint-disable @typescript-eslint/naming-convention */
// #region Imports
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;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { CssLength } from '@breadstone/mosaik-themes';
import { Attribute } from '../Decorators/AttributeDecorator';
import { Placement } from '../Types/Placement';
import { Strategy } from '../Types/Strategy';
/**
 * @public
 */
export const DropDownable = (base) => {
    class DropDownableElement extends base {
        // #region Fields
        _dropDownPlacement;
        _dropDownStrategy;
        _dropDownDistance;
        _dropDownSkidding;
        _dropDownStaysOpen;
        _isDropDownOpen;
        _maxDropDownHeight;
        // #endregion
        // #region Ctor
        /**
         * Constructs a new instance of the `DropDownableElement` class.
         *
         * @public
         */
        constructor(...args) {
            super(args);
            this._dropDownPlacement = Placement.Bottom;
            this._dropDownStrategy = Strategy.Fixed;
            this._dropDownDistance = 8;
            this._dropDownSkidding = 0;
            this._dropDownStaysOpen = false;
            this._isDropDownOpen = false;
            this._maxDropDownHeight = '200px';
        }
        // #endregion
        // #region Properties
        /**
         * Gets or sets the `dropDownPlacement` property.
         *
         * @public
         * @attr
         */
        get dropDownPlacement() {
            return this._dropDownPlacement;
        }
        set dropDownPlacement(value) {
            if (this._dropDownPlacement !== value) {
                this._dropDownPlacement = value;
                this.requestUpdate('dropDownPlacement');
            }
        }
        /**
         * Gets or sets the `dropDownStrategy` property.
         *
         * @public
         * @attr
         */
        get dropDownStrategy() {
            return this._dropDownStrategy;
        }
        set dropDownStrategy(value) {
            if (this._dropDownStrategy !== value) {
                this._dropDownStrategy = value;
                this.requestUpdate('dropDownStrategy');
            }
        }
        /**
         * Gets or sets the `dropDownDistance` property.
         *
         * @public
         * @attr
         */
        get dropDownDistance() {
            return this._dropDownDistance;
        }
        set dropDownDistance(value) {
            if (this._dropDownDistance !== value) {
                this._dropDownDistance = value;
                this.requestUpdate('dropDownDistance');
            }
        }
        /**
         * Gets or sets the `dropDownSkidding` property.
         *
         * @public
         * @attr
         */
        get dropDownSkidding() {
            return this._dropDownSkidding;
        }
        set dropDownSkidding(value) {
            if (this._dropDownSkidding !== value) {
                this._dropDownSkidding = value;
                this.requestUpdate('dropDownSkidding');
            }
        }
        /**
         * Gets or sets the `dropDownStaysOpen` property.
         *
         * @public
         * @attr
         */
        get dropDownStaysOpen() {
            return this._dropDownStaysOpen;
        }
        set dropDownStaysOpen(value) {
            if (this._dropDownStaysOpen !== value) {
                this._dropDownStaysOpen = value;
                this.requestUpdate('dropDownStaysOpen');
            }
        }
        /**
           * Gets or sets the `maxDropDownHeight` property.
           *
           * @public
           * @attr
           */
        get maxDropDownHeight() {
            return this._maxDropDownHeight;
        }
        set maxDropDownHeight(value) {
            if (this._maxDropDownHeight !== value) {
                this._maxDropDownHeight = value;
                this.requestUpdate('maxDropDownHeight');
            }
        }
        /**
         * Gets or sets the `isDropDownOpen` property.
         *
         * @public
         * @attr
         */
        get isDropDownOpen() {
            return this._isDropDownOpen;
        }
        set isDropDownOpen(value) {
            if (this._isDropDownOpen !== value) {
                this._isDropDownOpen = value;
                this.requestUpdate('isDropDownOpen');
            }
        }
        // #endregion
        // #region Methods
        /**
         * @public
         */
        open() {
            if (this.disabled && this.isDropDownOpen) {
                return;
            }
            this.isDropDownOpen = true;
        }
        /**
         * @public
         */
        close() {
            if (this._dropDownStaysOpen || (this.disabled && !this.isDropDownOpen)) {
                return;
            }
            this.isDropDownOpen = false;
        }
        /**
         * @public
         */
        toggle() {
            if (this.disabled) {
                this.close();
                return;
            }
            if (this.isDropDownOpen) {
                this.close();
            }
            else {
                this.open();
            }
        }
    }
    __decorate([
        Attribute({ type: Placement }),
        __metadata("design:type", String),
        __metadata("design:paramtypes", [String])
    ], DropDownableElement.prototype, "dropDownPlacement", null);
    __decorate([
        Attribute({ type: Strategy }),
        __metadata("design:type", String),
        __metadata("design:paramtypes", [String])
    ], DropDownableElement.prototype, "dropDownStrategy", null);
    __decorate([
        Attribute({ type: Number }),
        __metadata("design:type", Number),
        __metadata("design:paramtypes", [Number])
    ], DropDownableElement.prototype, "dropDownDistance", null);
    __decorate([
        Attribute({ type: Number }),
        __metadata("design:type", Number),
        __metadata("design:paramtypes", [Number])
    ], DropDownableElement.prototype, "dropDownSkidding", null);
    __decorate([
        Attribute({
            type: Boolean,
            useDefault: true
        }),
        __metadata("design:type", Boolean),
        __metadata("design:paramtypes", [Boolean])
    ], DropDownableElement.prototype, "dropDownStaysOpen", null);
    __decorate([
        Attribute({ type: String }),
        __metadata("design:type", Object),
        __metadata("design:paramtypes", [Object])
    ], DropDownableElement.prototype, "maxDropDownHeight", null);
    __decorate([
        Attribute({
            type: Boolean,
            useDefault: true
        }),
        __metadata("design:type", Boolean),
        __metadata("design:paramtypes", [Boolean])
    ], DropDownableElement.prototype, "isDropDownOpen", null);
    return DropDownableElement;
};
//# sourceMappingURL=DropDownable.js.map