0.30.0 • Published 5 years ago

@pndr/attachment-field v0.30.0

Weekly downloads
10
License
MIT
Repository
-
Last release
5 years ago

AttachmentField AttachmentField

npm package

Used for (pre)viewing and organizing a list of attachments.

Features

  • Display an array of attachments
  • Preview overlay
  • Support for following types
    • Images (png, jpeg)
    • Animated images (gif)
    • Video (mp4)
    • Audio (ogg, mp3)
  • Upload progress indicator

Getting started

npm install @cmds/attachment-field --save

Prop Types

PropertyTypeRequired?Description
idStringUnique id for the instance of this field
contextIdContextThe appearance will change depending on context in which the field is displayed. Valid options include: recordDetail or recordGridRow or recordGalleryCard or recordListItem
roleIdRoleThe behaviour changes based on the role. Valid options include editor or readOnly
attachmentsArrayArray of Attachment objects. Learn more
onAttachFunctionCallback invoked whenever one or more files get dropped or selected in the field: ({files: [File]}): void
onRemoveAttachmentFunctionCallback invoked whenever an attachment get's removed: ({id: string, file: File}): void
onRenameAttachmentFunctionCallback invoked whenever an attachment's filename changes: ({id: string, attachmentId: string, filename: string}): void
onClearFunctionCallback invoked whenever all attachments get removed at once: ({id: string}): void
onSortFunctionCallback invoked whenever one of the attachments get's sorted: ({id: string, attachmentId: string, targetIndex: number}): void

Attachment in upload

{
    filename: "Nature.jpg",
    id: "att8NBBKRa8slSrnB",
    typeId: "image/jpeg",
    uploading: true,
    progress: 70
}

Attachment

{
    filename: "Nature.jpg",
    id: "att8NBBKRa8slSrnB",
    size: 1165273,
    typeId: "image/jpeg",
    url: "https://cosmos3.s3.amazonaws.com/att8NBBKRa8slSrnB",
    uploading: false,
    progress: null,
    thumbnails: {
        large: {
            height: 384,
            url: "https://cosmos3.s3.amazonaws.com/att8NBBKRa8slSrnB_large",
            width: 512
        },
        medium: {
            height: 240,
            url: "https://cosmos3.s3.amazonaws.com/att8NBBKRa8slSrnB_medium",
            width: 320
        },
        small: {
            height: 27,
            url: "https://cosmos3.s3.amazonaws.com/att8NBBKRa8slSrnB_small",
            width: 36
        }
    }
}

More information

This component is designed and developed as part of Cosmos Design System.

0.30.0

5 years ago

0.29.0

5 years ago

0.28.0

5 years ago

0.27.0

5 years ago

0.26.0

5 years ago

0.25.0

5 years ago

0.24.0

5 years ago

0.23.0

5 years ago

0.22.0

5 years ago

0.19.0

5 years ago