UNPKG

@firecms/core

Version:

Awesome Firebase/Firestore-based headless open-source CMS

54 lines (53 loc) 2.84 kB
import React from "react"; import { AuthController, Entity, EntityCollection, EntityCustomViewParams, EntityStatus, EntityValues, FormContext, PropertyConfig } 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; fullIdPath?: string; collection: EntityCollection<M>; entityId?: string; entity?: Entity<M>; databaseId?: string; onIdChange?: (id: string) => void; onValuesModified?: (modified: boolean, values: M) => 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 extractTouchedValues(values: any, touched: Record<string, boolean>): Record<string, any>; export declare function getChanges<T extends object>(source: Partial<T>, comparison: Partial<T>): Partial<T>; export declare function EntityForm<M extends Record<string, any>>({ path, fullIdPath, 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 getInitialEntityValues<M extends object>(authController: AuthController, collection: EntityCollection, path: string, status: "new" | "existing" | "copy", entity: Entity<M> | undefined, propertyConfigs?: Record<string, PropertyConfig>): Partial<EntityValues<M>>; export declare function yupToFormErrors(yupError: ValidationError): Record<string, any>;