import type { JSX, ReactElement, ReactNode } from 'react'; import type { ValidationFunc } from '@nfq/react-form'; export type WithOptionalChildren = T & { children?: ReactNode; }; export type WithMultipleChildren = T & { children: ReactElement[]; }; export type WithChildren = T & { children: ReactNode; }; export type WithChild = T & { children: ReactElement; }; export type WithOnlyTextChild = T & { children: (number | string)[] | number[] | string[] | number | string; }; export type WithOptionalOnlyTextChild = T & { children?: (number | string)[] | number[] | string[] | number | string; }; /** * Represents a selectable option used in components like dropdowns, select inputs, or radio buttons. * Each option consists of a `label` that is visible to the user and a `value` that is used internally * to represent the selection in the application's logic. The `value` can be of any data type, making * the interface flexible to work with various kinds of data models. */ export interface Option { /** * Optional color value to customize the visual appearance of the option. * This can be used to provide visual distinction between different options * or to match the option's appearance with a specific design system or theme. */ color?: string; /** * The text displayed to the user in the selection component. * This is the human-readable representation of the option that users will see * when interacting with dropdowns, select inputs, or similar selection components. */ label: string; /** * The internal value associated with the option. * This value is used programmatically to identify the selected option and * should remain consistent regardless of changes to the display label. */ value: string; } export type Hash = `#${string}`; export type TabComponent = ReactElement<{ key: string; [key: string]: any; }>; /** * Represents the progress and error state of file uploads. * This interface is used to track the progress and any errors associated with multiple file uploads. */ export interface FileProgress { /** * An array where each index corresponds to a file, containing an error message if present, * or `null`/`undefined` if no error exists. */ fileErrors: (string | null | undefined)[]; /** * An array where each index corresponds to a file, containing the upload progress * as a number (percentage) or `'done'` when completed. */ fileProgressBars: (number | 'done' | undefined)[]; } /** * Represents the properties for an asset item component within an upload interface. * This interface defines the structure and behavior of individual asset items that are displayed * during file upload processes, providing comprehensive control over their appearance and functionality. */ interface AssetItemProps { /** * The file object representing the uploaded asset. This contains metadata like the file name. */ file: File; /** * The index of the asset in the upload list. This is used to identify the asset in the list. */ index: number; /** * Indicates whether to retain the field value when the component unmounts. * * @default false */ keepOnUnmount?: boolean; /** * The name of the asset being uploaded. This is displayed to the user in the asset item. */ name: string; /** * Callback function triggered when the delete action is performed. * This function is used to remove the uploaded file from the UI or state. */ onDelete?(index: number): void; /** * An object containing the current progress of the asset upload. * This object includes the upload status and progress percentage. */ progressData: FileProgress; /** * The `testId` property represents a unique identifier, usually in the form of a string, assigned to a component for testing purposes. * This property is crucial for uniquely identifying components during testing, allowing for more accurate and reliable tests. * * @default 'AssetItem' */ testId?: string; /** * Optional validation function to validate the input value. */ validation?: ValidationFunc; /** * The asset id for the asset item. */ value: string; } export type AssetUploadItem = (props: AssetItemProps) => JSX.Element; export {};