import { Component, Element, h, Host, Prop, State } from '@stencil/core';
const placementClassMap = {
  'bottomRight': 'bottom-right',
  'bottomLeft': 'bottom-left',
  'topRight': 'top-right',
  'topLeft': 'top-left',
  'rightBottom': 'right-bottom',
  'rightTop': 'right-top',
  'leftBottom': 'left-bottom',
  'leftTop': 'left-top',
};
export class Dropdown {
  constructor() {
    this.scale = 'medium';
    this.placement = 'bottomRight';
    this.leaned = false;
    this.trigger = 'click';
    this.height = '300px';
    this.expanded = false;
  }
  render() {
    return (h(Host, { onClick: () => {
        var _a;
        if (this.trigger === 'click') {
          this.expanded = !this.expanded;
          this.el.focus();
          (_a = this.onExpandChange) === null || _a === void 0 ? void 0 : _a.call(this, this.expanded);
        }
      }, onMouseEnter: () => {
        var _a;
        if (this.trigger === 'hover') {
          this.expanded = !this.expanded;
          (_a = this.onExpandChange) === null || _a === void 0 ? void 0 : _a.call(this, this.expanded);
        }
      }, onMouseLeave: () => {
        var _a;
        if (this.trigger === 'hover') {
          this.expanded = !this.expanded;
          (_a = this.onExpandChange) === null || _a === void 0 ? void 0 : _a.call(this, this.expanded);
        }
      }, onBlur: () => {
        setTimeout(() => {
          var _a;
          if (this.expanded) {
            this.expanded = false;
            (_a = this.onExpandChange) === null || _a === void 0 ? void 0 : _a.call(this, this.expanded);
          }
        }, 50);
      }, tabindex: 0, style: { width: this.width } },
      h("slot", null),
      h("div", { class: {
          'options-container': true,
          leaned: this.leaned,
          [placementClassMap[this.placement]]: true,
          expanded: this.expanded,
        }, style: {
          '--max-height': this.height
        } }, this.expanded && h("slot", { name: "content" }))));
  }
  static get is() { return "dvn-dropdown"; }
  static get encapsulation() { return "shadow"; }
  static get originalStyleUrls() { return {
    "$": ["dvn-dropdown.css"]
  }; }
  static get styleUrls() { return {
    "$": ["dvn-dropdown.css"]
  }; }
  static get properties() { return {
    "scale": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "Scale",
        "resolved": "\"large\" | \"medium\" | \"small\"",
        "references": {
          "Scale": {
            "location": "import",
            "path": "../../theme"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "scale",
      "reflect": false,
      "defaultValue": "'medium'"
    },
    "placement": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "DropdownPlacement",
        "resolved": "\"bottomLeft\" | \"bottomRight\" | \"leftBottom\" | \"leftTop\" | \"rightBottom\" | \"rightTop\" | \"topLeft\" | \"topRight\"",
        "references": {
          "DropdownPlacement": {
            "location": "import",
            "path": "./models"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "placement",
      "reflect": false,
      "defaultValue": "'bottomRight'"
    },
    "leaned": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "leaned",
      "reflect": false,
      "defaultValue": "false"
    },
    "trigger": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "'click' | 'hover'",
        "resolved": "\"click\" | \"hover\"",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "trigger",
      "reflect": false,
      "defaultValue": "'click'"
    },
    "height": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "height",
      "reflect": false,
      "defaultValue": "'300px'"
    },
    "width": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [],
        "text": ""
      },
      "attribute": "width",
      "reflect": false
    },
    "onExpandChange": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "(expanded: boolean) => void",
        "resolved": "(expanded: boolean) => void",
        "references": {}
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [],
        "text": ""
      }
    }
  }; }
  static get states() { return {
    "expanded": {}
  }; }
  static get elementRef() { return "el"; }
}
