import { UseStateWithGetterResult } from "use-common-hook"; import { Options, UploaderFunction } from "./types"; export type BaseItemData = Record<"id" | "name", string> & Record<"size", number>; export type HasBaseData = T & BaseItemData; export type HasGuid = T & { guid: string }; export type OptionsProp = Partial>>; type HookSimilarProps = { initialData?: HasBaseData[]; enabled?: boolean; }; export type UploaderProps = { uploader: UploaderFunction; } & OptionsProp & HookSimilarProps; export type ConnectToUploaderProps = { initialData?: HasBaseData[]; storeId: symbol; } & HookSimilarProps; export type InternalDataItem = BaseItemData & ( | { status: "loading"; discard: () => void; } | { status: "error"; } | { status: "loaded"; data: HasBaseData; } ); export type UseUploaderData = { data: UseStateWithGetterResult[]>["state"]; setData: UseStateWithGetterResult[]>["setter"]; getData: UseStateWithGetterResult[]>["getter"]; }; export type GetData = InternalDataItem[]; export type DataForSync = Extract< InternalDataItem, { status: "loaded" } >["data"]; export type HookResult = { readonly dragRef: React.RefCallback; readonly files: { id: string; status: "loading" | "error" | "loaded"; name: string; size: number; remove: null | (() => void); data: HasBaseData | null; }[]; readonly inputProps: Pick< React.ComponentPropsWithoutRef<"input">, "accept" | "onChange" | "multiple" | "disabled" >; readonly enrich: (filesForEnrich: DataForSync[]) => void; } & Readonly>; export type LoadFiles = (files: File[]) => void; export type FilesChecker = (files: FileList) => boolean; export type UseProvideUploaderStore = Omit, "initialData">; export type UseCreateStoreEnabledProps = { id: symbol; options?: Partial; uploader: UploaderFunction; };