import { Host, h } from '@stencil/core';
import { getHostAttrs, genId } from '../../utils/index';
/**
 * A basic radio button component.
 * @docsPage
 */
export class BsRadio {
  constructor() {
    /** Native attributes to pass through to the input element. */
    this.attrs = {};
    this.label = undefined;
    this.checked = false;
    this.disabled = false;
    this.error = undefined;
    this.inputId = undefined;
    this.passAttrs = '';
    this.required = undefined;
    this.size = undefined;
    this.value = undefined;
  }
  get inputIdAttr() {
    return this.inputId || this.inputIdGen;
  }
  componentWillLoad() {
    this.inputIdGen = this.inputId || genId();
    this.attrs = getHostAttrs(this.hostEl, [
      'name',
      ...this.passAttrs.split(',')
    ]);
  }
  render() {
    return (h(Host, { class: 'bs-boolean', "data-size": this.size }, h("input", Object.assign({ checked: this.checked, disabled: this.disabled, id: this.inputIdAttr, required: this.required, type: "radio", value: this.value, "data-error": this.error }, this.attrs)), this.label && (h("bs-label", { for: this.inputIdAttr, disabled: this.disabled, required: this.required }, this.label))));
  }
  static get is() { return "bs-radio"; }
  static get originalStyleUrls() {
    return {
      "$": ["bs-radio.scss"]
    };
  }
  static get styleUrls() {
    return {
      "$": ["bs-radio.css"]
    };
  }
  static get properties() {
    return {
      "label": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": true,
        "docs": {
          "tags": [{
              "name": "ex",
              "text": "Apples"
            }],
          "text": ""
        },
        "attribute": "label",
        "reflect": false
      },
      "checked": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Sets the checked state."
        },
        "attribute": "checked",
        "reflect": false,
        "defaultValue": "false"
      },
      "disabled": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Sets the disabled state on the input."
        },
        "attribute": "disabled",
        "reflect": false,
        "defaultValue": "false"
      },
      "error": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": true,
        "docs": {
          "tags": [],
          "text": "Applies error styles to the input."
        },
        "attribute": "error",
        "reflect": false
      },
      "inputId": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": true,
        "docs": {
          "tags": [],
          "text": "Pass id for the input element.  Will also be applied to label attribute."
        },
        "attribute": "input-id",
        "reflect": false
      },
      "passAttrs": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "List additional attributes by name (comma-separated) to pass through to <input>."
        },
        "attribute": "pass-attrs",
        "reflect": false,
        "defaultValue": "''"
      },
      "required": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": true,
        "docs": {
          "tags": [],
          "text": "Sets the required state on the input."
        },
        "attribute": "required",
        "reflect": false
      },
      "size": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "'sm'",
          "resolved": "\"sm\"",
          "references": {}
        },
        "required": false,
        "optional": true,
        "docs": {
          "tags": [],
          "text": "Sets the size of the input."
        },
        "attribute": "size",
        "reflect": false
      },
      "value": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Sets the value associated with the radio."
        },
        "attribute": "value",
        "reflect": false
      }
    };
  }
  static get elementRef() { return "hostEl"; }
}
//# sourceMappingURL=bs-radio.js.map
