Components
Client Only
Installation
pnpm dlx @docyrus/cli add @docyrus/ui-file-attachment-panelUI Primitives(6 components)
npx shadcn@latest add button dropdown-menu progress scroll-area separator skeletonUsage
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 (
<FileAttachmentPanel
files={files}
onUploadFile={(file) => 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<DocyrusFile> | — |
onDeleteFile | (fileId: string) => void | Promise<void> | — |
onInsertExternalFiles | (files: ExternalFilePayload[]) => void | Promise<void> | — |
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<string, unknown> | 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<string, unknown> | 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 |