import { Host, h } from '@stencil/core';
export class BsFormFile {
  constructor() {
    this.fileId = undefined;
    this.disabled = undefined;
    this.accept = undefined;
    this.label = 'choose a file';
    this.internalLabel = undefined;
  }
  handleChange(event) {
    if (event.target.files.length > 0) {
      this.internalLabel = event.target.files[0].name;
    }
    else {
      this.internalLabel = "No file chosen";
    }
    this.bsInput.emit(event.target.files);
  }
  componentDidLoad() {
    this.internalLabel = this.label;
  }
  render() {
    return (h(Host, { class: "custom-file" }, h("input", { type: "file", class: "custom-file-input", id: this.fileId, onInput: this.handleChange.bind(this), disabled: this.disabled, accept: this.accept }), h("label", { class: "custom-file-label", htmlFor: this.fileId }, this.internalLabel)));
  }
  static get is() { return "bs-form-file"; }
  static get encapsulation() { return "shadow"; }
  static get originalStyleUrls() {
    return {
      "$": ["bs-form-file.scss"]
    };
  }
  static get styleUrls() {
    return {
      "$": ["bs-form-file.css"]
    };
  }
  static get properties() {
    return {
      "fileId": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "The id of the element"
        },
        "attribute": "file-id",
        "reflect": false
      },
      "disabled": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "the disabled flag for the file input"
        },
        "attribute": "disabled",
        "reflect": false
      },
      "accept": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "The kinds of files accepted constraints"
        },
        "attribute": "accept",
        "reflect": false
      },
      "label": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": true,
        "docs": {
          "tags": [],
          "text": "The label or placeholder of the file"
        },
        "attribute": "label",
        "reflect": false,
        "defaultValue": "'choose a file'"
      }
    };
  }
  static get states() {
    return {
      "internalLabel": {}
    };
  }
  static get events() {
    return [{
        "method": "bsInput",
        "name": "bsInput",
        "bubbles": true,
        "cancelable": true,
        "composed": true,
        "docs": {
          "tags": [],
          "text": "The onInput event emitted on value changed"
        },
        "complexType": {
          "original": "KeyboardEvent",
          "resolved": "KeyboardEvent",
          "references": {
            "KeyboardEvent": {
              "location": "global"
            }
          }
        }
      }];
  }
}
//# sourceMappingURL=bs-form-file.js.map
