import { AnyComponentSchema } from '@open-formulieren/types'; import { GetRegistryEntry } from '../types'; import { JSONObject } from '../../types'; export interface MissingFields { /** * The path to the component in the form values dict, used to link the "missing field" * entry to the corresponding form value. * * Each key, from the root to the component, is joined together in a period seperated * string. This is only really noticable for children of `editgrid` components, the * key of the parent editgrid and the index of the edigrid item are included in the * path. As fieldset and columns components are purly presentational, their keys aren't * added. * * Example: * Lets assume you have an editgrid component with the key "cars", which has a * soft-required textfield in its first child with the key "brand". * * In this situation, the `pathToComponent` will be: "cars.0.brand". */ pathToComponent: string; /** * The label to show for the "missing field" entry. This is typically the label of the * empty soft-required component. * * When the missing field is located inside a `editgrid` or `fieldset` component, the * labels of their parent components is also shown. For `editgrid` components, the * groupLabel will also be included. Using the ">" character, we separate the labels to * show the relationship in the form. * * Example: * Lets assume you have a fieldset with the label "Car", which has a soft-required * textfield with the label "Brand". * * In this situation, the `label` will be: "Car > Brand". */ label: string; } /** * A function that validates the values of components, and returns a simplified * representation of the empty components. * * The recommended, and expected, usage is in conjunction with * `getSoftRequiredComponents` to return a list of missing soft-required components. * In theory, this function could also be used with all form components, to quickly get * an overview of all empty components. * * Note: fieldsets and columns can never be part of the returned list, as these are * presentation components. Editgrid components *can* be part of the result, when they * are soft-required and don't have any children. * * @param components A list of form components. * @param values The form values. * @param keyPrefix A list of the keys of parent components. Used in recursion * to easily access the value of the current component. * @param labelPrefix A list of the labels of parent components. Used in * recursion to create a singular label containing references to parent components. * @param getRegistryEntry * * @return The list of missing/empty components. Each item in this list * only contains a `label`, describing the location of the component, and a * `pathToComponent` which points to the exact location of the component data in the * form values. */ export declare const getMissingFields: (components: AnyComponentSchema[], values: JSONObject, getRegistryEntry: GetRegistryEntry, keyPrefix?: string[], labelPrefix?: string[]) => MissingFields[]; /** * Filters the tree of `components` on "softRequired". All components in the resulting * tree are either a parent of a softRequired component, or they are a softRequired * component. * * This function assumes that presentation components, fieldset and columns, cannot * be softRequired themselves. * * The components tree is searched depth-first, meaning that we proces the first * component to its full extent (including its children), before moving on to the next * component. * * @param {AnyComponentSchema[]} components A list of components to check on being * softRequired. * * @return {AnyComponentSchema[]} All softRequired components, or parents of softRequired * components, that were present in the `components` input. */ export declare const getSoftRequiredComponents: (components: AnyComponentSchema[]) => AnyComponentSchema[];