import { FormikErrors } from 'formik'; import { JSONObject, JSONValue } from '../../../types'; import { MarkedEditGridItem } from './types'; interface EditGridItemBaseProps { index: number; /** * Heading for the item, will be rendered as a fieldset legend unless a falsy value is * provided. */ heading: React.ReactNode; /** * If true, remove button(s) are rendered. */ canRemove: boolean; /** * Custom label for the remove button. */ removeLabel: string; /** * Callback invoked when deleting the item. */ onRemove: () => void; /** * Any item-level validation error. */ itemError?: string; } interface WithoutIsolation { enableIsolation?: false; /** * Callback to render the main content of a single item. Gets passed options representing * the current UI state. */ getBody: (opts: { expanded: false; }) => React.ReactNode; data?: never; canEdit?: never; saveLabel?: never; onChange?: never; validate?: never; errors?: never; } interface WithIsolation { /** * In isolation mode, fields of an item can be edited without them affecting the * entire form state. Only when the edits are saved/confirmed, is the parent form * state updated. */ enableIsolation: true; /** * Existing item data, passed to the underlying Formik component as initial state. * Note that this is only accepted as *initial* data and changes in props do not change * the form field values. */ data: MarkedEditGridItem; /** * Callback to render the main content of a single item. Gets passed options representing * the current UI state. */ getBody: (opts: { expanded: boolean; }) => React.ReactNode; /** * If true, edit control button(s) are rendered. */ canEdit?: boolean; /** * Custom label for the save/confirm button. */ saveLabel?: string; /** * Callback invoked when confirming the item changes. */ onChange: (newValue: T) => void; /** * Validate hook to pass to Formik's `validationSchema` prop. It must validate the * shape of a single item. * * Must throw zod-formik-adapter's `ValidationError` for invalid data. */ validate?: (obj: JSONObject) => Promise; errors?: FormikErrors; } export type EditGridItemProps = EditGridItemBaseProps & (WithoutIsolation | WithIsolation); declare function EditGridItem({ index, heading, canRemove, removeLabel, onRemove, itemError, ...props }: EditGridItemProps): import("react/jsx-runtime").JSX.Element; export default EditGridItem;