@navikt/ds-react
Version:
React components from the Norwegian Labour and Welfare Administration.
56 lines (55 loc) • 1.85 kB
TypeScript
import React, { MouseEvent } from "react";
import type { OverridableComponent } from "../../../../utils-external/index.js";
import type { ComponentTranslation } from "../../../../utils/i18n/i18n.types.js";
import { FileItem } from "./Item.types.js";
export interface FileUploadItemProps extends React.HTMLAttributes<HTMLDivElement> {
/**
* Overrides html-tag
* @default "div"
*/
as?: ("div" | "li") & React.ElementType;
/**
* Either a native File or file metadata.
*/
file: FileItem;
/**
* onClick on the file name.
*
* If neither this nor `href` is set, and the `file` prop is a native file, onClick will download the file.
*/
onFileClick?: (event: MouseEvent<HTMLAnchorElement>) => void;
/**
* href on the file name.
*
* If neither this nor `onFileClick` is set, and the `file` prop is a native file, onClick will download the file.
*/
href?: string;
/**
* Error message relating to the item.
*/
error?: string;
/**
* Status "downloading" and "uploading" displays a loading indicator.
* @default "idle"
*/
status?: "downloading" | "uploading" | "idle";
/**
* File description. Replaces file size when status is "idle".
* This is useful for displaying upload date. Should not act as a replacement for error messages.
*/
description?: string;
/**
* Props for the action button.
*/
button?: {
action: "delete" | "retry";
onClick: (event: MouseEvent<HTMLButtonElement>) => void;
id?: string;
} | React.ReactNode;
/**
* i18n-API for customizing texts and labels
*/
translations?: ComponentTranslation<"FileUpload">["item"];
}
export declare const Item: OverridableComponent<FileUploadItemProps, HTMLDivElement>;
export default Item;