import { h } from './chunks/d4789960.js';
import './chunks/456564be.js';
import { u as useEvent } from './chunks/d4058887.js';
import { b as useState, a as useRef } from './chunks/4ccc6eeb.js';
import { g as getComponentOrDefine } from './chunks/071ed725.js';

var style = ":host {\n}\n";

const KunFileSelect = () => {
  const [name, setName] = useState("");
  const inputRef = useRef();
  const onMyFileChange = useEvent("MyFileChange", {
    composed: true,
    bubbles: true
  });

  const setFile = evt => {
    const fileInput = evt.target.files[0];

    if (fileInput != null) {
      setName(fileInput.name);
      onMyFileChange(fileInput);
    }
  };

  const onSelect = () => {
    inputRef.current.click();
  };

  return h("host", null, h("style", null, style), h("div", {
    onclick: onSelect,
    className: "shadow appearance-none rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline cursor-pointer"
  }, name.length === 0 ? "请选择文件" : name), h("input", {
    className: "shadow appearance-none rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline hidden",
    type: "file",
    ref: inputRef,
    onchange: setFile
  }));
};

var kunFileSelect = getComponentOrDefine("kun-file-select", KunFileSelect);

export default kunFileSelect;
//# sourceMappingURL=kun-file-select.js.map
