Skip to main content

CnFileManager

File-list widget with drag-drop upload, per-file actions, and a click-emit for preview. The widget owns the dropzone UI, the row rendering, the icon-by-extension mapping, and the size/timestamp formatting. Consumers wire actual uploads / downloads / deletes through the @upload, @download, @delete events.

Try it

<CnFileManager
title="Attachments"
:files="attachments"
accept=".pdf,.png,.jpg"
:multiple="true"
:max-size-mb="20"
@upload="onUpload"
@download="onDownload"
@delete="onDelete"
@file-click="openPreview"
@upload-rejected="onUploadRejected" />

Props

PropTypeDefaultDescription
filesArray<{id?,name,size?,type?,url?,uploadedAt?,uploadedBy?}>[]Files to render.
title / descriptionString''Optional header.
readOnlyBooleanfalseHide dropzone + Delete buttons.
acceptString''accept attribute for the file input.
multipleBooleantrueAllow multi-file selection.
maxSizeMbNumber0Per-file max size in MB (0 = no limit).
dropzoneLabelString'Drop files here or click to browse'Dropzone primary label.
dropzoneHintString''Dropzone secondary hint.
emptyLabelString'No files attached.'Empty-state text.
downloadLabelString'Download'Default action label.
deleteLabelString'Delete'Default action label.

Events

EventPayloadDescription
uploadFile[]Files dropped or picked. Consumer persists them then appends to files[].
upload-rejected{reason,file,limitMb}Validation rejection (currently reason: 'size').
downloadfileDownload button clicked.
deletefileDelete button clicked. Button becomes disabled until parent removes the file or calls clearDeleting(id).
file-clickfileRow clicked (not the action buttons). Use for preview / detail.

Public methods

MethodDescription
openFilePicker()Programmatic dropzone open (from a parent button).
clearDeleting(id)Reset the in-flight delete flag for a file (on persist failure).

Slots

  • #header — replaces the title/description header.
  • #item-actions — per-file actions. Scope: { file }. Default renders Download + Delete buttons.

See also

  • For OpenRegister-backed file attachments, convert the _files array into this prop shape and persist deletes via the object store.