import type { Meta } from "./steps/ValidationStep/types"; import type { DeepReadonly } from "ts-essentials"; import type { TranslationsRSIProps } from "./translationsRSIProps"; import type { Columns } from "./steps/MatchColumnsStep/MatchColumnsStep"; import type { StepState } from "./steps/UploadFlow"; import { flowTypeChangeYearType } from "./lib/consts"; export type RsiProps = { isOpen: boolean; onClose: () => void; fields: Fields; uploadStepHook?: (data: RawData[]) => Promise; selectHeaderStepHook?: (headerValues: RawData, data: RawData[]) => Promise<{ headerValues: RawData; data: RawData[]; }>; matchColumnsStepHook?: (table: Data[], rawData: RawData[], columns: Columns) => Promise[]>; rowHook?: RowHook; tableHook?: TableHook; onSubmit: (data: Result, file: File) => void | Promise; allowInvalidSubmit?: boolean; isNavigationEnabled?: boolean; showSelectAll?: boolean; translations?: TranslationsRSIProps; customTheme?: object; maxRecords?: number; maxFileSize?: number; autoMapHeaders?: boolean; autoMapSelectValues?: boolean; autoMapDistance?: number; initialStepState?: StepState; dateFormat?: string; parseRaw?: boolean; rtl?: boolean; flowType?: "studentUpload" | flowTypeChangeYearType | string; validationStepInfoMessage?: string; }; export type RawData = Array; export type Data = { [key in T]: string | boolean | undefined; }; export type Fields = DeepReadonly[]>; export type Field = { label: string; key: T; description?: string; alternateMatches?: string[]; validations?: Validation[]; fieldType: Checkbox | Select | Input; example?: string; editable?: boolean | ((row: Data) => boolean); }; export type Checkbox = { type: "checkbox"; booleanMatches?: { [key: string]: boolean; }; }; export type Select = { type: "select"; options: SelectOption[]; }; export type SelectOption = { label: string; value: string; }; export type Input = { type: "input"; }; export type Validation = RequiredValidation | UniqueValidation | RegexValidation | CriticValidation; export type RequiredValidation = { rule: "required"; errorMessage?: string; level?: ErrorLevel; dependentKeys?: string[]; dependentKeysWithValue?: string[]; matchOnly?: boolean; }; export type CriticValidation = { rule: "critics"; errorMessage?: string; level?: ErrorLevel; dependentKeys?: string[]; dependentKeysWithValue?: string[]; }; export type UniqueValidation = { rule: "unique"; allowEmpty?: boolean; errorMessage?: string; level?: ErrorLevel; }; export type RegexValidation = { rule: "regex"; value: string; flags?: string; errorMessage: string; level?: ErrorLevel; dependentKeys?: string[]; dependentKeysWithValue?: string[]; }; export interface RowHookContext { warningShown: { [key: string]: boolean; }; setWarningShown: (key: string, shown: boolean) => void; errorShown: { [key: string]: boolean; }; setErrorShow: (key: string, shown: boolean) => void; } export type RowHook = (row: Data, addError: (fieldKey: T, error: Info) => void, clearError: (key: T) => void, context: RowHookContext, table: Data[]) => Data | Promise>; export type TableHook = (table: Data[], addError: (rowIndex: number, fieldKey: T, error: Info) => void) => Data[] | Promise[]>; export type ErrorLevel = "info" | "warning" | "error"; export type Info = { message: string; level: ErrorLevel; type?: string; }; export declare enum ErrorSources { Table = "table", Row = "row" } export type InfoWithSource = Info & { source: ErrorSources; }; export type Result = { validData: Data[]; invalidData: Data[]; all: (Data & Meta)[]; }; export interface WarningState { key: string; index: number; dismissed: boolean; } export interface WarningInfo extends Info { level: "warning"; dismissed?: boolean; }