UNPKG

@braineet/ui

Version:

Braineet design system

61 lines (59 loc) 2.54 kB
var _excluded = ["icon", "title", "helper", "children", "disabled", "isDragActive", "isFocused"]; function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } /* eslint-disable react/no-array-index-key */ import React from 'react'; import Heading from '../../heading'; import Icon from '../../icon'; import Pane from '../../pane'; import { UploadContainer } from './styles'; import { jsx as _jsx } from "react/jsx-runtime"; import { jsxs as _jsxs } from "react/jsx-runtime"; export var UploadDropzone = /*#__PURE__*/React.forwardRef(function (_ref, ref) { var icon = _ref.icon, title = _ref.title, helper = _ref.helper, children = _ref.children, disabled = _ref.disabled, isDragActive = _ref.isDragActive, isFocused = _ref.isFocused, restProps = _objectWithoutPropertiesLoose(_ref, _excluded); /** constants */ var renderChildren = React.useMemo(function () { if (children && /*#__PURE__*/React.isValidElement(children)) { return /*#__PURE__*/React.cloneElement(children, { className: 'upload-dropzone' }); } return /*#__PURE__*/_jsxs(Pane, { className: "upload-dropzone", children: [/*#__PURE__*/_jsx(Icon, { name: icon, size: 32 }), /*#__PURE__*/_jsxs(Pane, { className: "upload-dropzone-texts", children: [/*#__PURE__*/_jsx(Heading, { sm: "sm", margin: "0.5rem 0 0.25rem 0", children: title }), helper ? /*#__PURE__*/_jsx(Heading, { size: "xs", fontWeight: "500", children: helper }) : null] })] }); }, [children, icon, title, helper]); return /*#__PURE__*/_jsx(UploadContainer, _extends({ isDragActive: isDragActive || isFocused, disabled: disabled, p: "0.5rem", ref: ref }, restProps, { children: renderChildren })); }); UploadDropzone.defaultProps = { icon: 'publish', title: 'Drag and Drop or click to upload' };