@payfit/unity-components
Version:
62 lines (61 loc) • 2.58 kB
TypeScript
import { ComponentPropsWithoutRef } from 'react';
/** The visual status supplied by the application owning the attachment. */
export type AttachmentState = 'enabled' | 'processing' | 'error' | 'completed';
/** The density of an attachment. */
export type AttachmentSize = 'default' | 'small';
/** Props for the attachment surface. */
export interface AttachmentProps extends Omit<ComponentPropsWithoutRef<'div'>, 'className' | 'style'> {
/**
* Presentation status controlled by the caller: `enabled` for a ready file,
* `processing` for work in progress, `error` for a failure, or `completed`
* for a finished file. This prop does not perform state transitions.
*/
state: AttachmentState;
/**
* Selects the standard or compact attachment size.
* @default 'default'
*/
size?: AttachmentSize;
}
/**
* Presents a file and its related controls in one compact surface.
*
* Supply `state` and compose `AttachmentMedia`, `AttachmentContent`, and
* optional trigger and action parts. The application owns the file and updates
* the presentation state as its workflow changes.
* @param props - Surface attributes, presentation state, size, and composed parts.
* @see {@link AttachmentProps} for the supported sizes and states.
* @example
* ```tsx
* import { Icon } from '@payfit/unity-icons'
* import {
* Attachment, AttachmentContent, AttachmentDescription, AttachmentMedia,
* AttachmentTitle, RawAttachmentTrigger,
* } from '@payfit/unity-components'
*
* export function DocumentAttachment() {
* return (
* <Attachment state="completed">
* <AttachmentMedia>
* <Icon src="FileSheetOutlined" size={20} role="presentation" />
* </AttachmentMedia>
* <AttachmentContent>
* <AttachmentTitle>Contract.pdf</AttachmentTitle>
* <AttachmentDescription>PDF · 2 MB</AttachmentDescription>
* </AttachmentContent>
* <RawAttachmentTrigger
* asElement="a"
* href="https://example.com/contract.pdf"
* aria-label="Open Contract.pdf"
* />
* </Attachment>
* )
* }
* ```
* @remarks
* - Give the trigger and each secondary action an accessible name.
* - Explain errors in text and announce status changes when appropriate;
* the component does not announce state transitions automatically.
* - Processing animates the title only when reduced motion is not requested.
*/
export declare const Attachment: import('react').ForwardRefExoticComponent<AttachmentProps & import('react').RefAttributes<HTMLDivElement>>;