import { h, Host } from '@stencil/core';
export class BsButton {
  constructor() {
    this.variant = 'primary';
    this.type = 'button';
    this.size = undefined;
    this.href = undefined;
    this.block = undefined;
    this.disabled = undefined;
    this.active = undefined;
    this.iconLeft = undefined;
    this.iconRight = undefined;
  }
  submitForm(event) {
    if (this.type != 'submit')
      return;
    const form = this.el.closest('form');
    if (!form)
      return;
    // implicit submit of a form won't work since we're inside of Shadow DOM
    // instead we'll create a temporary button inside the form to mimic implicit submit
    event.preventDefault();
    const tempSubmit = document.createElement('button');
    tempSubmit.type = 'submit';
    tempSubmit.style.display = 'none';
    form.appendChild(tempSubmit);
    tempSubmit.click();
    tempSubmit.parentElement.removeChild(tempSubmit);
  }
  render() {
    const TagName = this.href ? 'a' : 'button';
    return (h(Host, { class: `
                    btn-${this.variant}
                    ${this.block ? 'btn-block' : ''}
                    ${this.size ? `btn-${this.size}` : ''}
                ` }, h(TagName, { type: this.type, disabled: this.disabled, href: this.href, "aria-pressed": this.active, "aria-disabled": this.disabled, tabindex: this.disabled ? -1 : null, class: `
                        btn 
                        btn-${this.variant} 
                        ${this.size ? `btn-${this.size}` : ''}
                        ${this.block ? 'btn-block' : ''}
                        ${this.active ? 'active' : ''}
                        ${this.disabled ? 'disabled' : ''}
                    ` }, this.iconLeft && h("bs-icon", { icon: this.iconLeft }), h("slot", null), this.iconRight && h("bs-icon", { icon: this.iconRight }))));
  }
  static get is() { return "bs-button"; }
  static get encapsulation() { return "shadow"; }
  static get originalStyleUrls() {
    return {
      "$": ["bs-button.scss"]
    };
  }
  static get styleUrls() {
    return {
      "$": ["bs-button.css"]
    };
  }
  static get properties() {
    return {
      "variant": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "ButtonVariant",
          "resolved": "string",
          "references": {
            "ButtonVariant": {
              "location": "import",
              "path": "../../shared/types"
            }
          }
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": ""
        },
        "attribute": "variant",
        "reflect": false,
        "defaultValue": "'primary'"
      },
      "type": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "ButtonType",
          "resolved": "string",
          "references": {
            "ButtonType": {
              "location": "local",
              "path": "/Users/aadebayo/Repositories/stenciljs-bootstrap/src/components/bs-button/bs-button.tsx"
            }
          }
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": ""
        },
        "attribute": "type",
        "reflect": false,
        "defaultValue": "'button'"
      },
      "size": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "ButtonSize",
          "resolved": "\"lg\" | \"sm\"",
          "references": {
            "ButtonSize": {
              "location": "local",
              "path": "/Users/aadebayo/Repositories/stenciljs-bootstrap/src/components/bs-button/bs-button.tsx"
            }
          }
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": ""
        },
        "attribute": "size",
        "reflect": false
      },
      "href": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": ""
        },
        "attribute": "href",
        "reflect": false
      },
      "block": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": ""
        },
        "attribute": "block",
        "reflect": false
      },
      "disabled": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": ""
        },
        "attribute": "disabled",
        "reflect": false
      },
      "active": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": ""
        },
        "attribute": "active",
        "reflect": false
      },
      "iconLeft": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": ""
        },
        "attribute": "icon-left",
        "reflect": false
      },
      "iconRight": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": ""
        },
        "attribute": "icon-right",
        "reflect": false
      }
    };
  }
  static get elementRef() { return "el"; }
  static get listeners() {
    return [{
        "name": "click",
        "method": "submitForm",
        "target": undefined,
        "capture": false,
        "passive": false
      }];
  }
}
//# sourceMappingURL=bs-button.js.map
