"use strict";

exports.__esModule = true;
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _FileUpload = require("./FileUpload.constants");
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/FileUpload/FileUpload.tsx";
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
var FileUpload = _ref => {
  var {
    dataHook,
    className,
    children,
    multiple = false,
    accept = '',
    capture,
    name,
    onChange: _onChange = () => {}
  } = _ref;
  var inputRef = (0, _react.useRef)(null);
  var openFileUploadDialog = event => {
    var _inputRef$current;
    (_inputRef$current = inputRef.current) == null || _inputRef$current.click();
    event.preventDefault();
  };
  return /*#__PURE__*/_react.default.createElement("label", {
    className: className,
    "data-hook": dataHook,
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 23,
      columnNumber: 5
    }
  }, children({
    openFileUploadDialog
  }), /*#__PURE__*/_react.default.createElement("input", {
    type: "file",
    "data-hook": _FileUpload.dataHooks.input,
    style: {
      display: 'none'
    },
    ref: inputRef,
    multiple: multiple,
    accept: accept,
    capture: capture === 'none' ? undefined : capture,
    name: name,
    onChange: e => {
      _onChange(e.target.files);
      // reset the input value to allow re-uploading the same file
      e.target.value = '';
    },
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 28,
      columnNumber: 7
    }
  }));
};
FileUpload.displayName = 'FileUpload';
var _default = exports.default = FileUpload;
//# sourceMappingURL=FileUpload.js.map