@get-asset/sdk

Documents

Headless compound that fetches a business's uploaded documents and exposes a slot for every cell — description, file name, date, source, status, and type. Built-in interactions: a drag-and-drop upload zone with per-file queue chips, inline delete confirmation, a per-row actions menu with preview/download/delete actions, and a full-screen lightbox. All four states (loading, error, empty, success) are covered by state-gate wrappers; compose the parts you need and use asChild to hand rendering to your own elements.

Anatomy

Import the primitive and compose the parts you need.

<Documents.Root documentType={type} onDelete={handleDelete} onDownload={handleDownload}>
<Documents.Success>
{/* Drag-and-drop upload + per-file queue chips */}
<Documents.UploadDropzone />
<Documents.UploadItems>
<Documents.UploadItem>
<Documents.UploadItemName />
<Documents.UploadItemMeta />
<Documents.UploadItemUploading></Documents.UploadItemUploading>
<Documents.UploadItemSuccess></Documents.UploadItemSuccess>
<Documents.UploadItemError>
<Documents.UploadItemErrorMessage />
<Documents.UploadItemDismiss />
</Documents.UploadItemError>
</Documents.UploadItem>
</Documents.UploadItems>
<Documents.Rows>
<Documents.Row>
<Documents.Description />
<Documents.FileName />
<Documents.Date />
<Documents.Source />
<Documents.Status />
<Documents.Type />
<Documents.RowActions />
<Documents.PreviewAction />
<Documents.DownloadAction />
<Documents.DeleteAction />
{/* Inline delete confirm */}
<Documents.DeleteConfirm>
<Documents.DeleteTitle />
<Documents.DeleteBody />
<Documents.ConfirmDelete />
<Documents.CancelDelete />
</Documents.DeleteConfirm>
{/* Full-screen lightbox */}
<Documents.Lightbox>
<Documents.PreviewImage>
<Documents.LightboxImage />
</Documents.PreviewImage>
<Documents.PreviewPdf>
<Documents.LightboxFrame />
</Documents.PreviewPdf>
<Documents.LightboxClose />
</Documents.Lightbox>
</Documents.Row>
</Documents.Rows>
</Documents.Success>
<Documents.Loading></Documents.Loading>
<Documents.Empty>No documents yet.</Documents.Empty>
<Documents.Error>
<Documents.ErrorMessage />
<Documents.Retry>Try Again</Documents.Retry>
</Documents.Error>
</Documents.Root>

Required scopes

The access token used by AssetProvider must include these scopes for this primitive to fetch data successfully:

  • document:read
  • document:create
  • document:delete

API reference

Root props

PropTypeDefaultDescription
documentTypeDocumentTypeFilter by type (receipt / statement / payroll / bill / mileage / other). Passed to the API.
transactionIdstringFilter to documents linked to a transaction. Passed to the API.
onUpload(type?: DocumentType) => voidProvide to handle uploads yourself — the built-in dropzone upload + queue is skipped.
onDelete(documentId: string) => voidProvide to handle deletion yourself — the built-in delete mutation is skipped.
onDownload(documentId: string) => voidProvide to handle download yourself — the built-in signed-URL fetch + download is skipped.
maxFileSizenumberPer-file size ceiling in bytes for the dropzone. Defaults to DEFAULT_MAX_FILE_SIZE (25 MB).
documentsDocumentPublic[]Override the fetched list (skips the API call). Storybook/tests.
state"loading" | "error" | "empty"Force a specific state for testing.
uploadItemsUploadItem[]Seed the upload queue (no real uploads run). Storybook/tests.
confirmingRowIdstringSeed the delete-confirm panel for this row's document id. Storybook/tests.
previewRowIdstringSeed the lightbox open for this row's document id. Storybook/tests.
signedUrlOverridestringUse this URL for the preview lightbox, skipping the signed-URL fetch (keeps stories offline).
childrenrequiredReactNodeCompound parts.

Parts

Container

Always rendered. Fetches documents, owns UI state, and provides context.

PartDescription
Documents.RootOwns fetching, filters, upload/delete/download actions, and the open/confirming/preview row state.

Success

Renders when at least one document is available.

PartDescription
Documents.SuccessState wrapper. Compose the list inside.
Documents.UploadDropzone
asChild?
Drag-and-drop surface — wires the drop to addFiles and sets data-dragging. (Browse + hidden input live in the styled layer.)
Documents.UploadItemsIterates the per-file upload queue, providing each item's context.
Documents.UploadItem
asChild?
Chip container for one queued file. Sets data-status.
Documents.UploadItemName
asChild?
The file name.
Documents.UploadItemMeta
asChild?, format?
Extension + size, e.g. "PDF · 84 KB".
Documents.UploadItemUploading / Success / ErrorGates that render while the item is uploading / succeeded / errored.
Documents.UploadItemErrorMessage
asChild?
Error copy (e.g. "File is over size limit", "Already uploaded"). Renders only on error.
Documents.UploadItemDismiss
asChild?
Button that removes the item from the queue.
Documents.RowsIterates each document, providing a per-row context.
Documents.Row
asChild?
Per-row wrapper. Sets data-status and data-type.
Documents.Description
asChild?
The description.
Documents.FileName
asChild?
The uploaded file name.
Documents.Date
asChild?, format?
Created date, "Apr 30, 2026" (UTC).
Documents.Source
asChild?, format?
Source label — Upload / Email forward / Integration.
Documents.Status
asChild?, format?
Status label + data-status tone. The raw API statuses collapse to 5 display states: Processed / Processing / Pending / Needs Attention / Failed.
Documents.Type
asChild?, format?
Type label + data-type (receipt / statement / payroll / bill / mileage / other).
Documents.RowActions
asChild?
Wrapper for the kebab trigger; compose Preview/Download/Delete inside your menu.
Documents.PreviewAction
asChild?
Opens the lightbox preview. Image filenames render as images; extensionless or non-image filenames use the frame preview.
Documents.DownloadAction
asChild?
Downloads the document (signed URL → browser download, or onDownload).
Documents.DeleteAction
asChild?
Opens the inline delete-confirm panel for the row.
Documents.PreviewImage / PreviewPdfGates — render children when the preview is an image / the frame preview.
Documents.DeleteConfirm
asChild?
Gate — renders the inline confirm panel when the row is confirming.
Documents.DeleteTitle / DeleteBody
asChild?
The confirm title (document description) and body copy.
Documents.ConfirmDelete / CancelDelete
asChild?
Buttons that run the delete or cancel it.
Documents.LightboxGate — renders the full-screen preview when the row is the preview row.
Documents.LightboxImage / LightboxFrame
asChild?
Full-size image / PDF, with the signed URL as src.
Documents.LightboxClose
asChild?
Button that closes the lightbox.

Loading

Renders while the fetch is in flight.

PartDescription
Documents.LoadingState wrapper. Render skeleton rows inside.

Empty

Renders when no documents are found.

PartDescription
Documents.EmptyState wrapper. Render an empty-state message inside.

Error

Renders on fetch error.

PartDescription
Documents.ErrorState wrapper. Compose the error UI inside.
Documents.ErrorMessage
asChild?
Renders the error message string.
Documents.Retry
asChild?
Button that re-runs the fetch.

Hooks

PartDescription
useDocuments()Top-level context (documents, state, actions, confirming/preview ids).
useDocumentsRow()The current row context (document, date, source, status, type).
Documents.useUploadItem()The current upload-queue item, inside UploadItems.