UNPKG

@navinc/base-react-components

Version:
58 lines 3.15 kB
"use strict"; 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; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Dropzone = void 0; const jsx_runtime_1 = require("react/jsx-runtime"); const react_dropzone_1 = require("react-dropzone"); const styled_components_1 = __importDefault(require("styled-components")); const utils_1 = require("@navinc/utils"); 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 } = _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"]); // useDropzone hook sets default options. // Here using objectFilter to filter out undefined values to avoid overriding the default options const dropzoneOptions = (0, utils_1.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 = (0, react_dropzone_1.useDropzone)(dropzoneOptions), { getRootProps, getInputProps } = _b, state = __rest(_b, ["getRootProps", "getInputProps"]); return ((0, jsx_runtime_1.jsxs)("div", Object.assign({ "data-testid": "dropzone" }, getRootProps(rootProps), { children: [(0, jsx_runtime_1.jsx)("input", Object.assign({}, getInputProps(inputProps))), children && children(state)] }))); }; exports.Dropzone = Dropzone; const StyledDropzone = (0, styled_components_1.default)(exports.Dropzone).withConfig({ displayName: "brc-sc-StyledDropzone", componentId: "brc-sc-140tf36" }) ``; exports.default = StyledDropzone; //# sourceMappingURL=dropzone.js.map