UNPKG

@navinc/base-react-components

Version:
54 lines 2.93 kB
var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { useDropzone } from 'react-dropzone'; import styled from 'styled-components'; import { objectFilter } from '@navinc/utils'; const Wrapper = styled.div.withConfig({ displayName: "brc-sc-Wrapper", componentId: "brc-sc-1ayt18m" }) ` width: 100%; `; export const Dropzone = (_a) => { var { children, accept, minSize, maxSize, maxFiles, preventDropOnDocument, noClick, noKeyboard, noDrag, noDragEventsBubbling, disabled, onDrop, onDropAccepted, onDropRejected, getFilesFromEvent, onFileDialogCancel, onFileDialogOpen, onError, validator, useFsAccessApi, autoFocus, multiple, onDragEnter, onDragLeave, onDragOver, inputProps, className } = _a, rootProps = __rest(_a, ["children", "accept", "minSize", "maxSize", "maxFiles", "preventDropOnDocument", "noClick", "noKeyboard", "noDrag", "noDragEventsBubbling", "disabled", "onDrop", "onDropAccepted", "onDropRejected", "getFilesFromEvent", "onFileDialogCancel", "onFileDialogOpen", "onError", "validator", "useFsAccessApi", "autoFocus", "multiple", "onDragEnter", "onDragLeave", "onDragOver", "inputProps", "className"]); // useDropzone hook sets default options. // Here using objectFilter to filter out undefined values to avoid overriding the default options const dropzoneOptions = objectFilter((val) => val !== undefined)({ accept, minSize, maxSize, maxFiles, preventDropOnDocument, noClick, noKeyboard, noDrag, noDragEventsBubbling, disabled, onDrop, onDropAccepted, onDropRejected, getFilesFromEvent, onFileDialogCancel, onFileDialogOpen, onError, validator, useFsAccessApi, autoFocus, multiple, onDragEnter, onDragLeave, onDragOver, }); const _b = useDropzone(dropzoneOptions), { getRootProps, getInputProps } = _b, state = __rest(_b, ["getRootProps", "getInputProps"]); return (_jsxs(Wrapper, Object.assign({ "data-testid": "dropzone" }, getRootProps(rootProps), { className: className, children: [_jsx("input", Object.assign({}, getInputProps(inputProps))), children && children(state)] }))); }; const StyledDropzone = styled(Dropzone).withConfig({ displayName: "brc-sc-StyledDropzone", componentId: "brc-sc-1ita3l4" }) ``; export const type = StyledDropzone; //# sourceMappingURL=dropzone.js.map