import { FileWithPath as FileWithPath$1 } from 'file-selector'; declare abstract class Validator = UseFilePickerConfig> { protected invokerHookId: string | undefined; /** * This method is called before parsing the selected files. It is called once per selection. * @param config passed to the useFilePicker hook * @param plainFiles files selected by the user */ abstract validateBeforeParsing(config: ConfigType, plainFiles: File[]): Promise; /** * This method is called after parsing the selected files. It is called once per every parsed file. * @param config passed to the useFilePicker hook * @param file parsed file selected by the user * @param reader instance that was used to parse the file */ abstract validateAfterParsing(config: ConfigType, file: FileWithPath$1, reader: FileReader): Promise; /** * lifecycle method called after user selection (regardless of validation result) */ onFilesSelected(_data: SelectedFilesOrErrors, CustomErrors>): Promise | void; /** * lifecycle method called after successful validation */ onFilesSuccessfullySelected(_data: SelectedFiles>): Promise | void; /** * lifecycle method called after failed validation */ onFilesRejected(_data: FileErrors): Promise | void; /** * lifecycle method called after the selection is cleared */ onClear(): Promise | void; /** * This method is called when file is removed from the list of selected files. * Invoked only by the useImperativeFilePicker hook * @param _removedFile removed file * @param _removedIndex index of removed file */ onFileRemoved(_removedFile: File, _removedIndex: number): Promise | void; } /** * Skip evaluating `U` if `T` is `unknown`. */ type EvalIfNotUnknown = unknown extends T ? never : U; /** * Resolve mapped types and show the derived keys and their types when hovering in * VS Code, instead of just showing the names those mapped types are defined with. */ type Prettify = { [K in keyof T]: T[K]; } & {}; /** * Get the keys of T without any keys of U. */ type Without = { [P in Exclude]?: never; }; /** * Restrict using either exclusively the keys of `T` or exclusively the keys of `U`. * * No unique keys of `T` can be used simultaneously with any unique keys of `U`. * * @example * ```ts * const myVar: XOR<{ data: object }, { error: object }> * ``` * * Supports from 2 up to 200 generic parameters. * * More: https://github.com/maninak/ts-xor/tree/master#description * */ type XOR = Prettify<(Without & A) | (Without & B) | EvalIfNotUnknown & C> | EvalIfNotUnknown & D> | EvalIfNotUnknown & E> | EvalIfNotUnknown & F> | EvalIfNotUnknown & G> | EvalIfNotUnknown & H> | EvalIfNotUnknown & I> | EvalIfNotUnknown & J> | EvalIfNotUnknown & K> | EvalIfNotUnknown & L> | EvalIfNotUnknown & M> | EvalIfNotUnknown & N> | EvalIfNotUnknown & O> | EvalIfNotUnknown & P> | EvalIfNotUnknown & Q> | EvalIfNotUnknown & R> | EvalIfNotUnknown & S> | EvalIfNotUnknown & T> | EvalIfNotUnknown & AA> | EvalIfNotUnknown & AB> | EvalIfNotUnknown & AC> | EvalIfNotUnknown & AD> | EvalIfNotUnknown & AE> | EvalIfNotUnknown & AF> | EvalIfNotUnknown & AG> | EvalIfNotUnknown & AH> | EvalIfNotUnknown & AI> | EvalIfNotUnknown & AJ> | EvalIfNotUnknown & AK> | EvalIfNotUnknown & AL> | EvalIfNotUnknown & AM> | EvalIfNotUnknown & AN> | EvalIfNotUnknown & AO> | EvalIfNotUnknown & AP> | EvalIfNotUnknown & AQ> | EvalIfNotUnknown & AR> | EvalIfNotUnknown & AS> | EvalIfNotUnknown & AT> | EvalIfNotUnknown & BA> | EvalIfNotUnknown & BB> | EvalIfNotUnknown & BC> | EvalIfNotUnknown & BD> | EvalIfNotUnknown & BE> | EvalIfNotUnknown & BF> | EvalIfNotUnknown & BG> | EvalIfNotUnknown & BH> | EvalIfNotUnknown & BI> | EvalIfNotUnknown & BJ> | EvalIfNotUnknown & BK> | EvalIfNotUnknown & BL> | EvalIfNotUnknown & BM> | EvalIfNotUnknown & BN> | EvalIfNotUnknown & BO> | EvalIfNotUnknown & BP> | EvalIfNotUnknown & BQ> | EvalIfNotUnknown & BR> | EvalIfNotUnknown & BS> | EvalIfNotUnknown & BT> | EvalIfNotUnknown & CA> | EvalIfNotUnknown & CB> | EvalIfNotUnknown & CC> | EvalIfNotUnknown & CD> | EvalIfNotUnknown & CE> | EvalIfNotUnknown & CF> | EvalIfNotUnknown & CG> | EvalIfNotUnknown & CH> | EvalIfNotUnknown & CI> | EvalIfNotUnknown & CJ> | EvalIfNotUnknown & CK> | EvalIfNotUnknown & CL> | EvalIfNotUnknown & CM> | EvalIfNotUnknown & CN> | EvalIfNotUnknown & CO> | EvalIfNotUnknown & CP> | EvalIfNotUnknown & CQ> | EvalIfNotUnknown & CR> | EvalIfNotUnknown & CS> | EvalIfNotUnknown & CT> | EvalIfNotUnknown & DA> | EvalIfNotUnknown & DB> | EvalIfNotUnknown & DC> | EvalIfNotUnknown & DD> | EvalIfNotUnknown & DE> | EvalIfNotUnknown & DF> | EvalIfNotUnknown & DG> | EvalIfNotUnknown & DH> | EvalIfNotUnknown & DI> | EvalIfNotUnknown & DJ> | EvalIfNotUnknown & DK> | EvalIfNotUnknown & DL> | EvalIfNotUnknown & DM> | EvalIfNotUnknown & DN> | EvalIfNotUnknown & DO> | EvalIfNotUnknown & DP> | EvalIfNotUnknown & DQ> | EvalIfNotUnknown & DR> | EvalIfNotUnknown & DS> | EvalIfNotUnknown & DT> | EvalIfNotUnknown & EA> | EvalIfNotUnknown & EB> | EvalIfNotUnknown & EC> | EvalIfNotUnknown & ED> | EvalIfNotUnknown & EE> | EvalIfNotUnknown & EF> | EvalIfNotUnknown & EG> | EvalIfNotUnknown & EH> | EvalIfNotUnknown & EI> | EvalIfNotUnknown & EJ> | EvalIfNotUnknown & EK> | EvalIfNotUnknown & EL> | EvalIfNotUnknown & EM> | EvalIfNotUnknown & EN> | EvalIfNotUnknown & EO> | EvalIfNotUnknown & EP> | EvalIfNotUnknown & EQ> | EvalIfNotUnknown & ER> | EvalIfNotUnknown & ES> | EvalIfNotUnknown & ET> | EvalIfNotUnknown & FA> | EvalIfNotUnknown & FB> | EvalIfNotUnknown & FC> | EvalIfNotUnknown & FD> | EvalIfNotUnknown & FE> | EvalIfNotUnknown & FF> | EvalIfNotUnknown & FG> | EvalIfNotUnknown & FH> | EvalIfNotUnknown & FI> | EvalIfNotUnknown & FJ> | EvalIfNotUnknown & FK> | EvalIfNotUnknown & FL> | EvalIfNotUnknown & FM> | EvalIfNotUnknown & FN> | EvalIfNotUnknown & FO> | EvalIfNotUnknown & FP> | EvalIfNotUnknown & FQ> | EvalIfNotUnknown & FR> | EvalIfNotUnknown & FS> | EvalIfNotUnknown & FT> | EvalIfNotUnknown & GA> | EvalIfNotUnknown & GB> | EvalIfNotUnknown & GC> | EvalIfNotUnknown & GD> | EvalIfNotUnknown & GE> | EvalIfNotUnknown & GF> | EvalIfNotUnknown & GG> | EvalIfNotUnknown & GH> | EvalIfNotUnknown & GI> | EvalIfNotUnknown & GJ> | EvalIfNotUnknown & GK> | EvalIfNotUnknown & GL> | EvalIfNotUnknown & GM> | EvalIfNotUnknown & GN> | EvalIfNotUnknown & GO> | EvalIfNotUnknown & GP> | EvalIfNotUnknown & GQ> | EvalIfNotUnknown & GR> | EvalIfNotUnknown & GS> | EvalIfNotUnknown & GT> | EvalIfNotUnknown & HA> | EvalIfNotUnknown & HB> | EvalIfNotUnknown & HC> | EvalIfNotUnknown & HD> | EvalIfNotUnknown & HE> | EvalIfNotUnknown & HF> | EvalIfNotUnknown & HG> | EvalIfNotUnknown & HH> | EvalIfNotUnknown & HI> | EvalIfNotUnknown & HJ> | EvalIfNotUnknown & HK> | EvalIfNotUnknown & HL> | EvalIfNotUnknown & HM> | EvalIfNotUnknown & HN> | EvalIfNotUnknown & HO> | EvalIfNotUnknown & HP> | EvalIfNotUnknown & HQ> | EvalIfNotUnknown & HR> | EvalIfNotUnknown & HS> | EvalIfNotUnknown & HT> | EvalIfNotUnknown & IA> | EvalIfNotUnknown & IB> | EvalIfNotUnknown & IC> | EvalIfNotUnknown & ID> | EvalIfNotUnknown & IE> | EvalIfNotUnknown & IF> | EvalIfNotUnknown & IG> | EvalIfNotUnknown & IH> | EvalIfNotUnknown & II> | EvalIfNotUnknown & IJ> | EvalIfNotUnknown & IK> | EvalIfNotUnknown & IL> | EvalIfNotUnknown & IM> | EvalIfNotUnknown & IN> | EvalIfNotUnknown & IO> | EvalIfNotUnknown & IP> | EvalIfNotUnknown & IQ> | EvalIfNotUnknown & IR> | EvalIfNotUnknown & IS> | EvalIfNotUnknown & IT>>; declare const ENCODINGS: readonly [{ readonly encodings: readonly [{ readonly labels: readonly ["unicode-1-1-utf-8", "unicode11utf8", "unicode20utf8", "utf-8", "utf8", "x-unicode20utf8"]; readonly name: "UTF-8"; }]; readonly heading: "The Default Encoding"; }, { readonly encodings: readonly [{ readonly labels: readonly ["866", "cp866", "csibm866", "ibm866"]; readonly name: "IBM866"; }, { readonly labels: readonly ["csisolatin2", "iso-8859-2", "iso-ir-101", "iso8859-2", "iso88592", "iso_8859-2", "iso_8859-2:1987", "l2", "latin2"]; readonly name: "ISO-8859-2"; }, { readonly labels: readonly ["csisolatin3", "iso-8859-3", "iso-ir-109", "iso8859-3", "iso88593", "iso_8859-3", "iso_8859-3:1988", "l3", "latin3"]; readonly name: "ISO-8859-3"; }, { readonly labels: readonly ["csisolatin4", "iso-8859-4", "iso-ir-110", "iso8859-4", "iso88594", "iso_8859-4", "iso_8859-4:1988", "l4", "latin4"]; readonly name: "ISO-8859-4"; }, { readonly labels: readonly ["csisolatincyrillic", "cyrillic", "iso-8859-5", "iso-ir-144", "iso8859-5", "iso88595", "iso_8859-5", "iso_8859-5:1988"]; readonly name: "ISO-8859-5"; }, { readonly labels: readonly ["arabic", "asmo-708", "csiso88596e", "csiso88596i", "csisolatinarabic", "ecma-114", "iso-8859-6", "iso-8859-6-e", "iso-8859-6-i", "iso-ir-127", "iso8859-6", "iso88596", "iso_8859-6", "iso_8859-6:1987"]; readonly name: "ISO-8859-6"; }, { readonly labels: readonly ["csisolatingreek", "ecma-118", "elot_928", "greek", "greek8", "iso-8859-7", "iso-ir-126", "iso8859-7", "iso88597", "iso_8859-7", "iso_8859-7:1987", "sun_eu_greek"]; readonly name: "ISO-8859-7"; }, { readonly labels: readonly ["csiso88598e", "csisolatinhebrew", "hebrew", "iso-8859-8", "iso-8859-8-e", "iso-ir-138", "iso8859-8", "iso88598", "iso_8859-8", "iso_8859-8:1988", "visual"]; readonly name: "ISO-8859-8"; }, { readonly labels: readonly ["csiso88598i", "iso-8859-8-i", "logical"]; readonly name: "ISO-8859-8-I"; }, { readonly labels: readonly ["csisolatin6", "iso-8859-10", "iso-ir-157", "iso8859-10", "iso885910", "l6", "latin6"]; readonly name: "ISO-8859-10"; }, { readonly labels: readonly ["iso-8859-13", "iso8859-13", "iso885913"]; readonly name: "ISO-8859-13"; }, { readonly labels: readonly ["iso-8859-14", "iso8859-14", "iso885914"]; readonly name: "ISO-8859-14"; }, { readonly labels: readonly ["csisolatin9", "iso-8859-15", "iso8859-15", "iso885915", "iso_8859-15", "l9"]; readonly name: "ISO-8859-15"; }, { readonly labels: readonly ["iso-8859-16"]; readonly name: "ISO-8859-16"; }, { readonly labels: readonly ["cskoi8r", "koi", "koi8", "koi8-r", "koi8_r"]; readonly name: "KOI8-R"; }, { readonly labels: readonly ["koi8-ru", "koi8-u"]; readonly name: "KOI8-U"; }, { readonly labels: readonly ["csmacintosh", "mac", "macintosh", "x-mac-roman"]; readonly name: "macintosh"; }, { readonly labels: readonly ["dos-874", "iso-8859-11", "iso8859-11", "iso885911", "tis-620", "windows-874"]; readonly name: "windows-874"; }, { readonly labels: readonly ["cp1250", "windows-1250", "x-cp1250"]; readonly name: "windows-1250"; }, { readonly labels: readonly ["cp1251", "windows-1251", "x-cp1251"]; readonly name: "windows-1251"; }, { readonly labels: readonly ["ansi_x3.4-1968", "ascii", "cp1252", "cp819", "csisolatin1", "ibm819", "iso-8859-1", "iso-ir-100", "iso8859-1", "iso88591", "iso_8859-1", "iso_8859-1:1987", "l1", "latin1", "us-ascii", "windows-1252", "x-cp1252"]; readonly name: "windows-1252"; }, { readonly labels: readonly ["cp1253", "windows-1253", "x-cp1253"]; readonly name: "windows-1253"; }, { readonly labels: readonly ["cp1254", "csisolatin5", "iso-8859-9", "iso-ir-148", "iso8859-9", "iso88599", "iso_8859-9", "iso_8859-9:1989", "l5", "latin5", "windows-1254", "x-cp1254"]; readonly name: "windows-1254"; }, { readonly labels: readonly ["cp1255", "windows-1255", "x-cp1255"]; readonly name: "windows-1255"; }, { readonly labels: readonly ["cp1256", "windows-1256", "x-cp1256"]; readonly name: "windows-1256"; }, { readonly labels: readonly ["cp1257", "windows-1257", "x-cp1257"]; readonly name: "windows-1257"; }, { readonly labels: readonly ["cp1258", "windows-1258", "x-cp1258"]; readonly name: "windows-1258"; }, { readonly labels: readonly ["x-mac-cyrillic", "x-mac-ukrainian"]; readonly name: "x-mac-cyrillic"; }]; readonly heading: "Legacy single-byte encodings"; }, { readonly encodings: readonly [{ readonly labels: readonly ["chinese", "csgb2312", "csiso58gb231280", "gb2312", "gb_2312", "gb_2312-80", "gbk", "iso-ir-58", "x-gbk"]; readonly name: "GBK"; }, { readonly labels: readonly ["gb18030"]; readonly name: "gb18030"; }]; readonly heading: "Legacy multi-byte Chinese (simplified) encodings"; }, { readonly encodings: readonly [{ readonly labels: readonly ["big5", "big5-hkscs", "cn-big5", "csbig5", "x-x-big5"]; readonly name: "Big5"; }]; readonly heading: "Legacy multi-byte Chinese (traditional) encodings"; }, { readonly encodings: readonly [{ readonly labels: readonly ["cseucpkdfmtjapanese", "euc-jp", "x-euc-jp"]; readonly name: "EUC-JP"; }, { readonly labels: readonly ["csiso2022jp", "iso-2022-jp"]; readonly name: "ISO-2022-JP"; }, { readonly labels: readonly ["csshiftjis", "ms932", "ms_kanji", "shift-jis", "shift_jis", "sjis", "windows-31j", "x-sjis"]; readonly name: "Shift_JIS"; }]; readonly heading: "Legacy multi-byte Japanese encodings"; }, { readonly encodings: readonly [{ readonly labels: readonly ["cseuckr", "csksc56011987", "euc-kr", "iso-ir-149", "korean", "ks_c_5601-1987", "ks_c_5601-1989", "ksc5601", "ksc_5601", "windows-949"]; readonly name: "EUC-KR"; }]; readonly heading: "Legacy multi-byte Korean encodings"; }, { readonly encodings: readonly [{ readonly labels: readonly ["csiso2022kr", "hz-gb-2312", "iso-2022-cn", "iso-2022-cn-ext", "iso-2022-kr", "replacement"]; readonly name: "replacement"; }, { readonly labels: readonly ["unicodefffe", "utf-16be"]; readonly name: "UTF-16BE"; }, { readonly labels: readonly ["csunicode", "iso-10646-ucs-2", "ucs-2", "unicode", "unicodefeff", "utf-16", "utf-16le"]; readonly name: "UTF-16LE"; }]; readonly heading: "Legacy miscellaneous encodings"; }]; type FileWithPath = FileWithPath$1; type BaseErrors = FileSizeError | FileReaderError | FileAmountLimitError | ImageDimensionError | FileTypeError; type UseFilePickerError = CustomErrors extends object ? BaseErrors | CustomErrors : BaseErrors; interface FileReaderError { name: 'FileReaderError'; causedByFile: FileWithPath; readerError?: DOMException | null; } interface FileAmountLimitError { name: 'FileAmountLimitError'; reason: 'MIN_AMOUNT_OF_FILES_NOT_REACHED' | 'MAX_AMOUNT_OF_FILES_EXCEEDED'; } interface FileSizeError { name: 'FileSizeError'; causedByFile: FileWithPath; reason: 'FILE_SIZE_TOO_LARGE' | 'FILE_SIZE_TOO_SMALL'; } interface ImageDimensionError { name: 'ImageDimensionError'; causedByFile: FileWithPath; reasons: ('IMAGE_WIDTH_TOO_BIG' | 'IMAGE_WIDTH_TOO_SMALL' | 'IMAGE_HEIGHT_TOO_BIG' | 'IMAGE_HEIGHT_TOO_SMALL' | 'IMAGE_NOT_LOADED')[]; } interface FileTypeError { name: 'FileTypeError'; causedByFile: FileWithPath; reason: 'FILE_TYPE_NOT_ACCEPTED'; } type FileErrors = { errors: UseFilePickerError[]; }; interface ImageDimensionRestrictionsConfig { minWidth?: number; maxWidth?: number; minHeight?: number; maxHeight?: number; } interface FileSizeRestrictions { /**Minimum file size in bytes*/ minFileSize?: number; /**Maximum file size in bytes*/ maxFileSize?: number; } interface FileAmountLimitConfig { min?: number; max?: number; } type ReadType = 'Text' | 'BinaryString' | 'ArrayBuffer' | 'DataURL'; type ReaderMethod = keyof FileReader; type SelectedFiles = { plainFiles: File[]; filesContent: FileContent[]; }; type SelectedFilesOrErrors = XOR, FileErrors>; type KnownEncoding = (typeof ENCODINGS)[number]['encodings'][number]['labels'][number]; /** * Type that represents text encodings supported by the system. * * The encoding standards are organized into the following categories: * * - **The Default Encoding by W3C File API specification**: UTF-8 * - **Legacy single-byte encodings**: IBM866, ISO-8859-2 through ISO-8859-16, KOI8-R, KOI8-U, macintosh, windows-874 through windows-1258, x-mac-cyrillic * - **Legacy multi-byte Chinese (simplified) encodings**: GBK, gb18030 * - **Legacy multi-byte Chinese (traditional) encodings**: Big5 * - **Legacy multi-byte Japanese encodings**: EUC-JP, ISO-2022-JP, Shift_JIS * - **Legacy multi-byte Korean encodings**: EUC-KR * - **Legacy miscellaneous encodings**: replacement, UTF-16BE, UTF-16LE */ type Encoding = KnownEncoding | (string & {}); type UseFilePickerConfigCommon = { multiple?: boolean; accept?: string | string[]; validators?: Validator[]; onFilesRejected?: (data: FileErrors) => void; onClear?: () => void; initializeWithCustomParameters?: (inputElement: HTMLInputElement) => void; }; type ReadFileContentConfig = ({ readFilesContent?: true | undefined | never; } & ({ readAs?: 'ArrayBuffer'; onFilesSelected?: (data: SelectedFilesOrErrors) => void; onFilesSuccessfullySelected?: (data: SelectedFiles) => void; } | { readAs?: 'Text'; encoding?: Encoding; onFilesSelected?: (data: SelectedFilesOrErrors) => void; onFilesSuccessfullySelected?: (data: SelectedFiles) => void; } | { readAs?: Exclude; onFilesSelected?: (data: SelectedFilesOrErrors) => void; onFilesSuccessfullySelected?: (data: SelectedFiles) => void; })) | { readFilesContent: false; readAs?: never; onFilesSelected?: (data: SelectedFilesOrErrors) => void; onFilesSuccessfullySelected?: (data: SelectedFiles) => void; }; type ExtractContentTypeFromConfig = Config extends { readAs: 'ArrayBuffer'; } ? ArrayBuffer : string; type UseFilePickerConfig = UseFilePickerConfigCommon & ReadFileContentConfig; type useImperativeFilePickerConfig = UseFilePickerConfig & { onFileRemoved?: (file: FileWithPath, removedIndex: number) => void | Promise; }; interface FileContent extends Blob { lastModified: number; name: string; content: ContentType; path: string; size: number; type: string; } type FilePickerReturnTypes = { openFilePicker: () => void; filesContent: FileContent[]; errors: UseFilePickerError[]; loading: boolean; plainFiles: File[]; clear: () => void; }; type ImperativeFilePickerReturnTypes = FilePickerReturnTypes & { removeFileByIndex: (index: number) => void; removeFileByReference: (file: File) => void; }; export { type ExtractContentTypeFromConfig as E, type FilePickerReturnTypes as F, type ImperativeFilePickerReturnTypes as I, type ReadType as R, type SelectedFiles as S, type UseFilePickerConfig as U, Validator as V, type FileWithPath as a, type FileAmountLimitConfig as b, type FileSizeRestrictions as c, type ImageDimensionRestrictionsConfig as d, type UseFilePickerError as e, type FileReaderError as f, type FileAmountLimitError as g, type FileSizeError as h, type ImageDimensionError as i, type FileTypeError as j, type FileErrors as k, type ReaderMethod as l, type SelectedFilesOrErrors as m, type Encoding as n, type FileContent as o, type useImperativeFilePickerConfig as u };