@sqlrooms/dropzone 0.8.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/file-dropzone.js +1 -1
- package/dist/file-dropzone.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -51,7 +51,7 @@ function CustomStyledDropzone() {
|
|
|
51
51
|
return (
|
|
52
52
|
<FileDropzone
|
|
53
53
|
onFileDrop={handleFiles}
|
|
54
|
-
className="border-2 border-dashed border-blue-400
|
|
54
|
+
className="rounded-lg border-2 border-dashed border-blue-400 p-8 transition-colors hover:border-blue-600"
|
|
55
55
|
activeClassName="border-green-500 bg-green-50"
|
|
56
56
|
rejectClassName="border-red-500 bg-red-50"
|
|
57
57
|
dragMessage="Drop your files here"
|
|
@@ -73,8 +73,8 @@ function DataFileUploader() {
|
|
|
73
73
|
};
|
|
74
74
|
|
|
75
75
|
return (
|
|
76
|
-
<div className="
|
|
77
|
-
<h2 className="text-xl font-bold
|
|
76
|
+
<div className="rounded-lg border p-4">
|
|
77
|
+
<h2 className="mb-2 text-xl font-bold">Upload Data Files</h2>
|
|
78
78
|
<p className="mb-4 text-gray-600">
|
|
79
79
|
Supported formats: CSV, JSON, Excel, Parquet
|
|
80
80
|
</p>
|
package/dist/file-dropzone.js
CHANGED
|
@@ -59,6 +59,6 @@ export const FileDropzone = (props) => {
|
|
|
59
59
|
noClick: true,
|
|
60
60
|
noKeyboard: true,
|
|
61
61
|
});
|
|
62
|
-
return (_jsx("div", { className: cn('relative flex h-full min-h-[180px] cursor-pointer flex-col overflow-hidden rounded-lg border-2 border-dashed p-2 transition-colors', isDragActive ? 'border-muted bg-muted/50' : 'border-muted', isInvalid && 'border-destructive', !isAddingDropped && 'hover:border-muted', className), ...getRootProps(), onClick: isAddingDropped ? undefined : open, children: isAddingDropped ? (_jsxs("div", { className: "flex h-full w-full items-center justify-center gap-4 text-xs
|
|
62
|
+
return (_jsx("div", { className: cn('relative flex h-full min-h-[180px] cursor-pointer flex-col overflow-hidden rounded-lg border-2 border-dashed p-2 transition-colors', isDragActive ? 'border-muted bg-muted/50' : 'border-muted', isInvalid && 'border-destructive', !isAddingDropped && 'hover:border-muted', className), ...getRootProps(), onClick: isAddingDropped ? undefined : open, children: isAddingDropped ? (_jsxs("div", { className: "text-muted-foreground flex h-full w-full items-center justify-center gap-4 text-xs", children: [_jsx(Spinner, { className: "h-4 w-4" }), "Adding files..."] })) : (_jsxs(_Fragment, { children: [_jsx("input", { ...getInputProps() }), _jsx("div", { className: "relative flex h-full flex-col", children: _jsxs("div", { className: "flex h-full flex-col items-center justify-center gap-2", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Plus, { className: "h-6 w-6" }), _jsx("p", { className: "text-muted-foreground text-sm", children: isDragActive ? 'Drop here ...' : 'Add files' })] }), acceptedFormats && (_jsxs("div", { className: "flex flex-wrap justify-center gap-2", children: [_jsx("p", { className: "text-xs font-bold", children: "Supported formats:" }), _jsx("p", { className: "text-muted-foreground text-xs", children: Object.values(acceptedFormats).flat().join(', ') })] })), children] }) })] })) }));
|
|
63
63
|
};
|
|
64
64
|
//# sourceMappingURL=file-dropzone.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-dropzone.js","sourceRoot":"","sources":["../src/file-dropzone.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAK,QAAQ,EAAC,MAAM,OAAO,CAAC;AACnC,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAC,EAAE,EAAE,OAAO,EAAC,MAAM,cAAc,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,CAAC,MAAM,YAAY,GAOpB,CAAC,KAAK,EAAE,EAAE;IACb,MAAM,EACJ,SAAS,EACT,MAAM,EACN,QA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AC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,WAAW,GAC3C,IACA,EACL,eAAe,IAAI,CAClB,eAAK,SAAS,EAAC,qCAAqC,aAClD,YAAG,SAAS,EAAC,mBAAmB,mCAAuB,EACvD,YAAG,SAAS,EAAC,+BAA+B,YACzC,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAC/C,IACA,CACP,EACA,QAAQ,IACL,GACF,IACL,CACJ,GACG,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {FC, useState} from 'react';\nimport {useDropzone} from 'react-dropzone';\nimport {Plus} from 'lucide-react';\nimport {cn, Spinner} from '@sqlrooms/ui';\n\n/**\n * A customizable file dropzone component that handles file uploads through drag-and-drop or click interactions.\n *\n * @component\n * @example\n * ```tsx\n * // Basic usage\n * <FileDropzone\n * onDrop={async (files) => {\n * console.log('Dropped files:', files);\n * // Handle file upload\n * }}\n * />\n *\n * // With file type restrictions and single file upload\n * <FileDropzone\n * multiple={false}\n * acceptedFormats={{\n * 'text/csv': ['.csv'],\n * 'application/json': ['.json']\n * }}\n * onDrop={async (files) => {\n * const file = files[0];\n * // Handle single file upload\n * }}\n * >\n * <p>Custom dropzone content</p>\n * </FileDropzone>\n * ```\n *\n * @param props - Component props\n * @param props.className - Optional CSS class name for styling\n * @param props.isInvalid - Optional flag to indicate validation error state\n * @param props.onDrop - Async callback function called when files are dropped or selected\n * @param props.multiple - Optional flag to allow multiple file selection (default: true)\n * @param props.acceptedFormats - Optional object defining accepted MIME types and their extensions\n * @param props.children - Optional React nodes to render inside the dropzone\n */\nexport const FileDropzone: FC<{\n className?: string;\n isInvalid?: boolean;\n onDrop: (files: File[]) => Promise<void>;\n multiple?: boolean;\n acceptedFormats?: Record<string, string[]>;\n children?: React.ReactNode;\n}> = (props) => {\n const {\n isInvalid,\n onDrop,\n multiple = true,\n className,\n acceptedFormats,\n children,\n } = props;\n\n const [isAddingDropped, setIsAddingDropped] = useState(false);\n\n const {getRootProps, getInputProps, isDragActive, open} = useDropzone({\n onDrop: async (files) => {\n setIsAddingDropped(true);\n try {\n await onDrop(files);\n } finally {\n setIsAddingDropped(false);\n }\n },\n accept: acceptedFormats,\n multiple,\n noClick: true,\n noKeyboard: true,\n });\n\n return (\n <div\n className={cn(\n 'relative flex h-full min-h-[180px] cursor-pointer flex-col overflow-hidden rounded-lg border-2 border-dashed p-2 transition-colors',\n isDragActive ? 'border-muted bg-muted/50' : 'border-muted',\n isInvalid && 'border-destructive',\n !isAddingDropped && 'hover:border-muted',\n className,\n )}\n {...getRootProps()}\n onClick={isAddingDropped ? undefined : open}\n >\n {isAddingDropped ? (\n <div className=\"flex h-full w-full items-center justify-center gap-4 text-xs
|
|
1
|
+
{"version":3,"file":"file-dropzone.js","sourceRoot":"","sources":["../src/file-dropzone.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAK,QAAQ,EAAC,MAAM,OAAO,CAAC;AACnC,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAC,EAAE,EAAE,OAAO,EAAC,MAAM,cAAc,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,CAAC,MAAM,YAAY,GAOpB,CAAC,KAAK,EAAE,EAAE;IACb,MAAM,EACJ,SAAS,EACT,MAAM,EACN,QAAQ,GAAG,IAAI,EACf,SAAS,EACT,eAAe,EACf,QAAQ,GACT,GAAG,KAAK,CAAC;IAEV,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE9D,MAAM,EAAC,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,IAAI,EAAC,GAAG,WAAW,CAAC;QACpE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;YACtB,kBAAkB,CA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ACF,IACL,CACJ,GACG,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {FC, useState} from 'react';\nimport {useDropzone} from 'react-dropzone';\nimport {Plus} from 'lucide-react';\nimport {cn, Spinner} from '@sqlrooms/ui';\n\n/**\n * A customizable file dropzone component that handles file uploads through drag-and-drop or click interactions.\n *\n * @component\n * @example\n * ```tsx\n * // Basic usage\n * <FileDropzone\n * onDrop={async (files) => {\n * console.log('Dropped files:', files);\n * // Handle file upload\n * }}\n * />\n *\n * // With file type restrictions and single file upload\n * <FileDropzone\n * multiple={false}\n * acceptedFormats={{\n * 'text/csv': ['.csv'],\n * 'application/json': ['.json']\n * }}\n * onDrop={async (files) => {\n * const file = files[0];\n * // Handle single file upload\n * }}\n * >\n * <p>Custom dropzone content</p>\n * </FileDropzone>\n * ```\n *\n * @param props - Component props\n * @param props.className - Optional CSS class name for styling\n * @param props.isInvalid - Optional flag to indicate validation error state\n * @param props.onDrop - Async callback function called when files are dropped or selected\n * @param props.multiple - Optional flag to allow multiple file selection (default: true)\n * @param props.acceptedFormats - Optional object defining accepted MIME types and their extensions\n * @param props.children - Optional React nodes to render inside the dropzone\n */\nexport const FileDropzone: FC<{\n className?: string;\n isInvalid?: boolean;\n onDrop: (files: File[]) => Promise<void>;\n multiple?: boolean;\n acceptedFormats?: Record<string, string[]>;\n children?: React.ReactNode;\n}> = (props) => {\n const {\n isInvalid,\n onDrop,\n multiple = true,\n className,\n acceptedFormats,\n children,\n } = props;\n\n const [isAddingDropped, setIsAddingDropped] = useState(false);\n\n const {getRootProps, getInputProps, isDragActive, open} = useDropzone({\n onDrop: async (files) => {\n setIsAddingDropped(true);\n try {\n await onDrop(files);\n } finally {\n setIsAddingDropped(false);\n }\n },\n accept: acceptedFormats,\n multiple,\n noClick: true,\n noKeyboard: true,\n });\n\n return (\n <div\n className={cn(\n 'relative flex h-full min-h-[180px] cursor-pointer flex-col overflow-hidden rounded-lg border-2 border-dashed p-2 transition-colors',\n isDragActive ? 'border-muted bg-muted/50' : 'border-muted',\n isInvalid && 'border-destructive',\n !isAddingDropped && 'hover:border-muted',\n className,\n )}\n {...getRootProps()}\n onClick={isAddingDropped ? undefined : open}\n >\n {isAddingDropped ? (\n <div className=\"text-muted-foreground flex h-full w-full items-center justify-center gap-4 text-xs\">\n <Spinner className=\"h-4 w-4\" />\n Adding files...\n </div>\n ) : (\n <>\n <input {...getInputProps()} />\n <div className=\"relative flex h-full flex-col\">\n <div className=\"flex h-full flex-col items-center justify-center gap-2\">\n <div className=\"flex items-center gap-2\">\n <Plus className=\"h-6 w-6\" />\n <p className=\"text-muted-foreground text-sm\">\n {isDragActive ? 'Drop here ...' : 'Add files'}\n </p>\n </div>\n {acceptedFormats && (\n <div className=\"flex flex-wrap justify-center gap-2\">\n <p className=\"text-xs font-bold\">Supported formats:</p>\n <p className=\"text-muted-foreground text-xs\">\n {Object.values(acceptedFormats).flat().join(', ')}\n </p>\n </div>\n )}\n {children}\n </div>\n </div>\n </>\n )}\n </div>\n );\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqlrooms/dropzone",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Ilya Boyandin <ilya@boyandin.me>",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"typedoc": "typedoc"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@sqlrooms/ui": "0.8.
|
|
35
|
+
"@sqlrooms/ui": "0.8.1",
|
|
36
36
|
"lucide-react": "^0.474.0",
|
|
37
37
|
"react-dropzone": "^14.3.5"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "7b5e727b79d675c17b93412c109d1ba1b22699c8"
|
|
40
40
|
}
|