import _isNil from "lodash/fp/isNil";
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
import React, { useCallback } from 'react';
import PropTypes from 'prop-types';
import { NovaSolidFilesBasicFileLines as FileLinesIcon, NovaCompositionCoorpacademyEye as EyeIcon } from '@coorpacademy/nova-icons';
import DragAndDrop from '../drag-and-drop';
import ButtonLink from '../button-link';
import { FilesPropType } from '../../util/proptypes';
import style from './style.css';
const InputFileDraggable = ({
  title,
  description,
  previewLabel,
  previewContent,
  uploadLabel,
  loading,
  modified,
  disabled = false,
  disableHoverTooltip = false,
  onChange,
  onReset = null,
  name,
  labelLink,
  labelButtonLink,
  hrefLink,
  filesTypes = '',
  error = '',
  buttonAriaLabel,
  errorButtonLabel,
  pdfButtonLabel,
  pdfButtonAriaLabel,
  filesNumber = 0,
  multiple = false,
  required = false,
  onClick
}) => {
  const handleReset = useCallback(e => {
    if (_isNil(onReset)) return;
    e.preventDefault();
    return onReset(e);
  }, [onReset]);
  const linkCustomStyle = {
    width: '40px',
    color: '#FF541F'
  };
  const onClick_ = useCallback(e => {
    e.preventDefault();
    return onClick(e);
  }, [onClick]);
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DragAndDrop, {
    title: title,
    description: description,
    previewLabel: previewLabel,
    previewContent: previewContent,
    uploadLabel: uploadLabel,
    loading: loading,
    modified: modified,
    onReset: handleReset,
    error: error,
    disabled: disabled,
    disableHoverTooltip: disableHoverTooltip,
    buttonAriaLabel: buttonAriaLabel,
    errorButtonLabel: errorButtonLabel,
    pdfButtonLabel: pdfButtonLabel,
    pdfButtonAriaLabel: pdfButtonAriaLabel,
    multiple: multiple
  }, (onDragStart, onDragStop) => /*#__PURE__*/React.createElement("input", _extends({}, disableHoverTooltip ? {
    title: ''
  } : {}, {
    type: "file",
    name: name,
    accept: filesTypes,
    disabled: loading || disabled,
    className: style.input,
    onChange: onChange,
    onDragEnter: onDragStart,
    onDrop: onDragStop,
    onDragLeave: onDragStop,
    multiple: multiple,
    required: required
  }))), labelLink && hrefLink ? /*#__PURE__*/React.createElement("div", {
    className: style.templateLink
  }, labelLink, /*#__PURE__*/React.createElement(ButtonLink, {
    type: "text",
    customStyle: linkCustomStyle,
    link: {
      href: hrefLink,
      download: true
    },
    label: labelButtonLink
  })) : null, multiple && filesNumber > 0 ? /*#__PURE__*/React.createElement("div", {
    className: style.multipleFilesContainer
  }, /*#__PURE__*/React.createElement("div", {
    className: style.filesNumber
  }, /*#__PURE__*/React.createElement(FileLinesIcon, {
    className: style.icon
  }), /*#__PURE__*/React.createElement("div", null, filesNumber, " files")), /*#__PURE__*/React.createElement("div", {
    className: style.seeDetailsButton,
    onClick: onClick_
  }, /*#__PURE__*/React.createElement(EyeIcon, {
    className: style.seeIcon
  }), /*#__PURE__*/React.createElement("div", null, "See details"))) : null);
};
InputFileDraggable.propTypes = process.env.NODE_ENV !== "production" ? {
  ...DragAndDrop.propTypes,
  disableHoverTooltip: PropTypes.bool,
  name: PropTypes.string,
  onChange: PropTypes.func,
  onReset: PropTypes.func,
  filesTypes: FilesPropType,
  error: PropTypes.string,
  buttonAriaLabel: PropTypes.string,
  errorButtonLabel: PropTypes.string,
  labelLink: PropTypes.string,
  hrefLink: PropTypes.string
} : {};
export default InputFileDraggable;
//# sourceMappingURL=index.js.map