{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "dropzone-01",
  "type": "registry:item",
  "title": "react-dropzone",
  "description": "Drag and drop file upload zone using react-dropzone",
  "dependencies": [
    "react-dropzone",
    "@mui/icons-material",
    "@mui/material",
    "@emotion/react",
    "@emotion/styled"
  ],
  "registryDependencies": [],
  "files": [
    {
      "path": "components/dropzone-01/dropzone-01.tsx",
      "target": "src/mui-treasury/components/dropzone-01/dropzone-01.tsx",
      "content": "'use client';\nimport * as React from 'react';\nimport { DropzoneOptions, FileRejection, useDropzone } from 'react-dropzone';\n\nimport CloseIcon from '@mui/icons-material/Close';\nimport CloudUploadOutlinedIcon from '@mui/icons-material/CloudUploadOutlined';\nimport InsertDriveFileOutlinedIcon from '@mui/icons-material/InsertDriveFileOutlined';\nimport Box from '@mui/material/Box';\nimport IconButton from '@mui/material/IconButton';\nimport List from '@mui/material/List';\nimport ListItem from '@mui/material/ListItem';\nimport ListItemIcon from '@mui/material/ListItemIcon';\nimport ListItemText from '@mui/material/ListItemText';\nimport Typography from '@mui/material/Typography';\n\nfunction formatFileSize(bytes: number): string {\n  if (bytes === 0) return '0 B';\n  const k = 1024;\n  const sizes = ['B', 'KB', 'MB', 'GB'];\n  const i = Math.floor(Math.log(bytes) / Math.log(k));\n  return `${parseFloat((bytes / Math.pow(k, i)).toFixed(1))} ${sizes[i]}`;\n}\n\nexport interface DropzoneFile extends File {\n  preview?: string;\n}\n\nexport interface Dropzone01Props\n  extends Omit<DropzoneOptions, 'onDrop' | 'onDropAccepted'> {\n  value?: DropzoneFile[];\n  onChange?: (files: DropzoneFile[]) => void;\n  onReject?: (rejections: FileRejection[]) => void;\n  helperText?: React.ReactNode;\n}\n\nexport function Dropzone01({\n  value = [],\n  onChange,\n  onReject,\n  helperText = 'PNG, JPG, PDF up to 10MB',\n  accept,\n  maxSize = 10 * 1024 * 1024,\n  maxFiles,\n  disabled,\n  ...options\n}: Dropzone01Props) {\n  const handleDrop = React.useCallback(\n    (acceptedFiles: File[], rejections: FileRejection[]) => {\n      const newFiles = acceptedFiles.map((file) =>\n        Object.assign(file, {\n          preview: file.type.startsWith('image/')\n            ? URL.createObjectURL(file)\n            : undefined,\n        }),\n      );\n      onChange?.([...value, ...newFiles]);\n      if (rejections.length > 0) {\n        onReject?.(rejections);\n      }\n    },\n    [value, onChange, onReject],\n  );\n\n  const handleRemove = (index: number) => {\n    const newFiles = [...value];\n    const removed = newFiles.splice(index, 1)[0];\n    if (removed.preview) {\n      URL.revokeObjectURL(removed.preview);\n    }\n    onChange?.(newFiles);\n  };\n\n  const {\n    getRootProps,\n    getInputProps,\n    isDragActive,\n    isDragAccept,\n    isDragReject,\n    isFocused,\n  } = useDropzone({\n    onDrop: handleDrop,\n    accept,\n    maxSize,\n    maxFiles,\n    disabled,\n    ...options,\n  });\n\n  return (\n    <Box sx={{ width: '100%' }}>\n      <Box\n        {...getRootProps()}\n        sx={{\n          display: 'flex',\n          flexDirection: 'column',\n          alignItems: 'center',\n          justifyContent: 'center',\n          gap: 1,\n          p: 4,\n          borderRadius: 2,\n          border: '2px dashed',\n          borderColor: 'divider',\n          bgcolor: 'background.paper',\n          cursor: disabled ? 'not-allowed' : 'pointer',\n          opacity: disabled ? 0.6 : 1,\n          transition: 'all 0.2s ease-in-out',\n          outline: 'none',\n          ...(isFocused && {\n            borderColor: 'primary.main',\n            bgcolor: 'action.hover',\n          }),\n          ...(isDragActive && {\n            borderColor: 'primary.main',\n            bgcolor: 'action.hover',\n          }),\n          ...(isDragAccept && {\n            borderColor: 'success.main',\n            bgcolor: 'success.softBg',\n          }),\n          ...(isDragReject && {\n            borderColor: 'error.main',\n            bgcolor: 'error.softBg',\n          }),\n          '@media (hover: hover)': {\n            '&:hover': {\n              borderColor: disabled ? 'divider' : 'primary.main',\n              bgcolor: disabled ? 'background.paper' : 'action.hover',\n            },\n          },\n        }}\n      >\n        <input {...getInputProps()} />\n        <CloudUploadOutlinedIcon\n          sx={{\n            fontSize: 48,\n            color: isDragReject\n              ? 'error.main'\n              : isDragAccept\n                ? 'success.main'\n                : 'text.icon',\n          }}\n        />\n        <Typography\n          variant=\"body1\"\n          sx={{\n            color: 'text.secondary',\n            textAlign: 'center',\n          }}\n        >\n          {isDragActive\n            ? isDragReject\n              ? 'Some files will be rejected'\n              : 'Drop files here'\n            : 'Drag & drop files here, or click to browse'}\n        </Typography>\n        {helperText && (\n          <Typography\n            variant=\"body2\"\n            sx={{\n              color: 'text.disabled',\n            }}\n          >\n            {helperText}\n          </Typography>\n        )}\n      </Box>\n      {value.length > 0 && (\n        <List dense sx={{ mt: 1 }}>\n          {value.map((file, index) => (\n            <ListItem\n              key={`${file.name}-${index}`}\n              secondaryAction={\n                <IconButton\n                  edge=\"end\"\n                  aria-label={`Remove ${file.name}`}\n                  onClick={() => handleRemove(index)}\n                  size=\"small\"\n                >\n                  <CloseIcon fontSize=\"small\" />\n                </IconButton>\n              }\n              sx={{\n                bgcolor: 'action.hover',\n                borderRadius: 1,\n                mb: 0.5,\n                '&:last-child': { mb: 0 },\n              }}\n            >\n              <ListItemIcon sx={{ minWidth: 36 }}>\n                {file.preview ? (\n                  <Box\n                    component=\"img\"\n                    src={file.preview}\n                    alt={file.name}\n                    sx={{\n                      width: 24,\n                      height: 24,\n                      objectFit: 'cover',\n                      borderRadius: 0.5,\n                    }}\n                  />\n                ) : (\n                  <InsertDriveFileOutlinedIcon color=\"action\" />\n                )}\n              </ListItemIcon>\n              <ListItemText\n                primary={file.name}\n                secondary={formatFileSize(file.size)}\n                slotProps={{\n                  primary: {\n                    noWrap: true,\n                    sx: { fontWeight: 500 },\n                  },\n                  secondary: {\n                    sx: { fontSize: '0.75rem' },\n                  },\n                }}\n              />\n            </ListItem>\n          ))}\n        </List>\n      )}\n    </Box>\n  );\n}\n",
      "type": "registry:item"
    },
    {
      "path": "components/dropzone-01/index.ts",
      "target": "src/mui-treasury/components/dropzone-01/index.ts",
      "content": "export * from './dropzone-01';\n",
      "type": "registry:item"
    }
  ],
  "meta": {
    "category": "primitive",
    "subcategory": "dropzone"
  }
}