# File Attachment Panel URL: /docs/web/components/file-attachment-panel File Attachment Panel component. **Demo:** ```tsx 'use client'; // @custom-demo import { useState } from 'react'; import { FileAttachmentPanel } from '@docyrus/ui/components/file-attachment-panel'; import { Button } from '@docyrus/ui/primitives/ui/button'; import { cn } from '@docyrus/ui/primitives/lib/utils'; import { PropControls } from '@/components/prop-controls'; import { useDemoData } from '@/data/file-attachment-panel-data'; export function FileAttachmentPanelDemo() { const { props, controls, actions } = useDemoData(); const [open, setOpen] = useState(false); return (
); } ``` ## Installation ```bash pnpm dlx @docyrus/cli add @docyrus/ui-file-attachment-panel ``` ## Usage ```tsx import { FileAttachmentPanel } from "@docyrus/ui/components/file-attachment-panel"; import type { FileAttachmentPanelProps } from "@docyrus/ui/components/file-attachment-panel"; const files: FileAttachmentPanelProps['files'] = [ { id: "f-1", file_name: "design-review.png", file_type: "image/png", file_size: 120000, signed_url: "https://images.unsplash.com/photo-1581291518857-4e27b48ff24e?w=640&q=80", source: "local", file_data: null, created_on: new Date().toISOString(), record_id: "rec-1" } ]; function Demo() { return ( Promise.resolve({ ...files[0], id: crypto.randomUUID(), file_name: file.name, file_type: file.type, file_size: file.size, signed_url: URL.createObjectURL(file) })} onDeleteFile={(id) => console.log("delete", id)} /> ); } ``` ## API Reference | Prop | Type | Default | |------|------|---------| | `files` | `DocyrusFile[]` | — | | `title` | `string` | `"Attachments"` | | `editable` | `boolean` | `true` | | `isLoading` | `boolean` | `false` | | `maxFileSize` | `number` | `50 * 1024 * 1024` | | `accept` | `string` | — | | `maxFiles` | `number` | — | | `onUploadFile` | `(file: File) => Promise` | — | | `onDeleteFile` | `(fileId: string) => void \| Promise` | — | | `onInsertExternalFiles` | `(files: ExternalFilePayload[]) => void \| Promise` | — | | `onFileOpen` | `(file: DocyrusFile) => void` | — | | `isDeletePending` | `boolean` | `false` | | `className` | `string` | — | | `oneDriveConfig` | `OneDrivePickerConfig` | — | | `googleDriveConfig` | `GoogleDrivePickerConfig` | — | ## Components | Component | Description | |-----------|-------------| | `FileAttachmentPanel` | Public export | | `FileEmptyState` | Internal — `file-empty-state.tsx` | | `FileGrid` | Internal — `file-grid.tsx` | | `FileItem` | Internal — `file-item.tsx` | | `FileList` | Internal — `file-list.tsx` | | `FileSourceMenu` | Internal — `file-source-menu.tsx` | | `FileUploadProgress` | Internal — `file-upload-progress.tsx` | | `FileUploadZone` | Internal — `file-upload-zone.tsx` | | `DocyrusIcon` | Internal — `docyrus-icon.tsx` | ## Type Exports | Type | Description | |------|-------------| | `FileAttachmentPanelProps` | — | | `ViewMode` | — | | `DocyrusFile` | — | | `ExternalFilePayload` | — | | `OneDrivePickerConfig` | Config for OneDrive integration | | `GoogleDrivePickerConfig` | Config for Google Drive integration | ## Type Reference ### ViewMode `"list"` | `"grid"` ### DocyrusFile | Field | Type | |-------|------| | `id` | `string` | | `file_name` | `string` | | `file_type` | `string` | | `file_size` | `number` | | `signed_url` | `string \| null` | | `source` | `"local" \| "microsoft_onedrive" \| "google_drive"` | | `file_data` | `Record \| null` | | `created_on` | `string` | | `record_id` | `string \| null` | ### ExternalFilePayload | Field | Type | |-------|------| | `source` | `"microsoft_onedrive" \| "google_drive"` | | `file_name` | `string` | | `file_type` | `string` | | `signed_url` | `string` | | `file_data` | `Record \| undefined` | | `expire_in` | `number \| undefined` | ### OneDrivePickerConfig | Field | Type | Description | |-------|------|-------------| | `clientId` | `string` | Microsoft OAuth2 Client ID | | `redirectUri` | `string \| undefined` | OAuth2 redirect URI (defaults to `window.location.origin`) | ### GoogleDrivePickerConfig | Field | Type | Description | |-------|------|-------------| | `clientId` | `string` | Google OAuth2 Client ID | | `apiKey` | `string` | Google API key for the Picker API | | `appId` | `string \| undefined` | Google Cloud project / app ID |