@firecms/core
Version:
Awesome Firebase/Firestore-based headless open-source CMS
50 lines (49 loc) • 2.23 kB
TypeScript
import React from "react";
import { Entity, EntityCollection, EntityCustomViewParams, EntityStatus, FormContext } from "../types";
import { FormexController } from "@firecms/formex";
import { ValidationError } from "yup";
import { EntityFormActionsProps } from "./EntityFormActions";
export type OnUpdateParams = {
entity: Entity<any>;
status: EntityStatus;
path: string;
entityId?: string;
selectedTab?: string;
collection: EntityCollection<any>;
};
export type EntityFormProps<M extends Record<string, any>> = {
path: string;
collection: EntityCollection<M>;
entityId?: string;
entity?: Entity<M>;
databaseId?: string;
onIdChange?: (id: string) => void;
onValuesModified?: (modified: boolean) => void;
onSaved?: (params: OnUpdateParams) => void;
initialDirtyValues?: Partial<M>;
onFormContextReady?: (formContext: FormContext) => void;
forceActionsAtTheBottom?: boolean;
className?: string;
initialStatus: EntityStatus;
onStatusChange?: (status: EntityStatus) => void;
onEntityChange?: (entity: Entity<M>) => void;
formex?: FormexController<M>;
openEntityMode?: "side_panel" | "full_screen";
/**
* If true, the form will be disabled and no actions will be available
*/
disabled?: boolean;
/**
* Include the copy and delete actions in the form
*/
showDefaultActions?: boolean;
/**
* Display the entity path in the form
*/
showEntityPath?: boolean;
EntityFormActionsComponent?: React.FC<EntityFormActionsProps>;
Builder?: React.ComponentType<EntityCustomViewParams<M>>;
children?: React.ReactNode;
};
export declare function EntityForm<M extends Record<string, any>>({ path, entityId: entityIdProp, collection, onValuesModified, onIdChange, onSaved, entity, initialDirtyValues, onFormContextReady, forceActionsAtTheBottom, initialStatus, className, onStatusChange, onEntityChange, openEntityMode, formex: formexProp, disabled: disabledProp, Builder, EntityFormActionsComponent, showDefaultActions, showEntityPath, children }: EntityFormProps<M>): import("react/jsx-runtime").JSX.Element;
export declare function yupToFormErrors(yupError: ValidationError): Record<string, any>;