import { JSONObject, JSONValue } from '../../../types'; import { MarkedEditGridItem } from './types'; interface EditGridBaseProps { /** * Name of 'form field' in the Formio form data structure. The rendered edit grid items * are based off the value of this field. */ name: string; /** * The (accessible) label for the field - anything that can be rendered. */ label: React.ReactNode; /** * Required fields get additional markup/styling to indicate this validation requirement. */ isRequired?: boolean; /** * Additional description displayed close to the field - use this to document any * validation requirements that are crucial to successfully submit the form. More * information that is contextual/background typically belongs in a tooltip. */ description?: React.ReactNode; /** * Optional tooltip to provide additional information that is not crucial but may * assist users in filling out the field correctly. */ tooltip?: React.ReactNode; /** * Callback to return the heading for a single item. Gets passed the item values and * index in the array of values. */ getItemHeading?: (values: T, index: number) => React.ReactNode; /** * Callback to check if a particular item can be removed. This allows decisions on a * per-item basis. If not provided, item removal is enabled by default. */ canRemoveItem?: (values: T, index: number) => boolean; /** * Custom label for the remove button. */ removeItemLabel?: string; /** * Empty instance, will be added when the 'add another' button is clicked. If `null` is * provided, adding items is disabled. */ emptyItem?: T | null; /** * Custom label for the 'add another' button. */ addButtonLabel?: string; } interface WithoutIsolation { enableIsolation?: false; canEditItem?: never; saveItemLabel?: never; /** * Callback to render the main content of a single item. Gets passed the item values and * index in the array of values. * * When editing inline (so *not* in isolation mode), `opts.expanded` will always be `false`.` */ getItemBody: (values: T, index: number, opts: { expanded: false; }) => React.ReactNode; validate?: never; } interface WithIsolation { enableIsolation: true; /** * Callback to check if a particular item can be edited. This allows decisions on a * per-item basis. If not provided, item editing is enabled by default. */ canEditItem?: (values: T, index: number) => boolean; /** * Custom label for the save/confirm button. */ saveItemLabel?: string; /** * Callback to render the main content of a single item. Gets passed the item values and * index in the array of values. * * When editing inline (so *not* in isolation mode), `opts.expanded` will always be `false`.` */ getItemBody: (values: MarkedEditGridItem, index: number, opts: { expanded: boolean; }) => React.ReactNode; /** * Callback to validate a single item. It receives the item index and the item values. * * Must throw zod-formik-adapter's `ValidationError` for invalid data. */ validate?: (index: number, values: T) => Promise; } export type EditGridProps = EditGridBaseProps & (WithoutIsolation | WithIsolation); declare function EditGrid({ name, label, isRequired, description, tooltip, getItemHeading, canRemoveItem, removeItemLabel, emptyItem, addButtonLabel, ...props }: EditGridProps): import("react/jsx-runtime").JSX.Element; export default EditGrid;