import { Component, Host, h, Event, Prop, Watch } from '@stencil/core';
export class UxplCheckbox {
  constructor() {
    /**
     * If `true`, the checkbox is selected.
     */
    this.checked = false;
    /**
     * If `true`, the checkbox will visually appear as indeterminate.
     */
    this.indeterminate = false;
    /**
     * The value of the toggle does not mean if it's checked or not, use the `checked`
     * property for that.
     *
     * The value of a toggle is analogous to the value of a `<input type="checkbox">`,
     * it's only used when the toggle participates in a native `<form>`.
     */
    this.value = 'on';
    /**
     * If `true`, the checkbox is readonly.
     */
    this.readonly = false;
    this.onClick = (e) => {
      if (e.srcElement['localName'] === 'input') {
        this.checked = !this.checked;
        this.indeterminate = false;
      }
    };
  }
  checkedChanged(isChecked) {
    this.clicked.emit({
      checked: isChecked,
      value: this.value
    });
  }
  render() {
    return (h(Host, null,
      h("div", { class: "pl-form-field pl-form-field--checkbox", onClick: (e) => this.onClick(e) },
        h("input", { class: {
            "pl-form-field__input": true,
            "readonly": this.readonly
          }, type: "checkbox", id: "changeME-checkbox1", "aria-checked": "false", checked: this.checked, disabled: this.readonly }),
        h("label", { htmlFor: "changeME-checkbox1", class: "pl-form-field__label" },
          h("slot", null)))));
  }
  static get is() { return "uxpl-checkbox"; }
  static get encapsulation() { return "shadow"; }
  static get originalStyleUrls() { return {
    "$": ["uxpl-checkbox.css"]
  }; }
  static get styleUrls() { return {
    "$": ["uxpl-checkbox.css"]
  }; }
  static get properties() { return {
    "checked": {
      "type": "boolean",
      "mutable": true,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": "If `true`, the checkbox is selected."
      },
      "attribute": "checked",
      "reflect": false,
      "defaultValue": "false"
    },
    "indeterminate": {
      "type": "boolean",
      "mutable": true,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": "If `true`, the checkbox will visually appear as indeterminate."
      },
      "attribute": "indeterminate",
      "reflect": false,
      "defaultValue": "false"
    },
    "value": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": "The value of the toggle does not mean if it's checked or not, use the `checked`\r\nproperty for that.\r\n\r\nThe value of a toggle is analogous to the value of a `<input type=\"checkbox\">`,\r\nit's only used when the toggle participates in a native `<form>`."
      },
      "attribute": "value",
      "reflect": false,
      "defaultValue": "'on'"
    },
    "readonly": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": "If `true`, the checkbox is readonly."
      },
      "attribute": "readonly",
      "reflect": false,
      "defaultValue": "false"
    }
  }; }
  static get events() { return [{
      "method": "clicked",
      "name": "clicked",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [],
        "text": "Emitted when the checked property has changed."
      },
      "complexType": {
        "original": "any",
        "resolved": "any",
        "references": {}
      }
    }]; }
  static get watchers() { return [{
      "propName": "checked",
      "methodName": "checkedChanged"
    }]; }
}
