import { List, Map } from "immutable"; import { BasicFun, Delta, Guid, PredicateValue, SearchableInfiniteStreamState, simpleUpdater, Sum, Unit, Updater, ValueOrErrors, } from "../../../../main"; import { ValueInfiniteStreamState } from "../../../value-infinite-data-stream/state"; import { FormParsingResult, FormsParserState } from "../parser/state"; export type FormRefCreateApiHandlers = { onDefaultSuccess?: (_: Arg) => void; onDefaultError?: (_: Arg) => void; onCreateSuccess?: (_: Arg) => void; onCreateError?: (_: Arg) => void; }; export type FormRefEditApiHandlers = { onGetSuccess?: (_: Arg) => void; onGetError?: (_: Arg) => void; onUpdateSuccess?: (_: Arg) => void; onUpdateError?: (_: Arg) => void; }; export type TableApiSource = BasicFun< BasicFun>, BasicFun, ValueInfiniteStreamState["getChunk"]> >; export type TableApiSources = BasicFun; export type FormRef = { formName: string; } & ( | { kind: "edit"; submitButtonWrapper: any; entityId: Guid; apiHandlers?: FormRefEditApiHandlers; } | { kind: "create"; apiHandlers?: FormRefCreateApiHandlers; submitButtonWrapper: any; } | { kind: "passthrough"; entity: Sum; globalConfiguration: Sum; containerWrapper: any; onEntityChange: (updater: Updater, delta: Delta) => void; } ); export type FormRunnerContext = { extraContext: any; formRef: FormRef; showFormParsingErrors: BasicFun; } & FormsParserState; export type FormRunnerState = { form: Sum< { form: any; formFieldStates: any; entity: any; commonFormState: any; customFormState: any; globalConfiguration: any; }, "not initialized" >; }; export type FormRunnerForeignMutationsExpected = Unit; export const FormRunnerState = { Default: (): FormRunnerState => ({ form: Sum.Default.right("not initialized"), }), Updaters: { ...simpleUpdater()("form"), }, };