import { FormField } from '../form/typeguards.js'; import { Option } from '../../components/form/choicefield/choicefield.js'; import { LoadOptionsFn } from '../../components/form/select/select.js'; /** * The default URL fields, */ declare const DEFAULT_URL_FIELDS: string[]; /** A key in an object. */ type Field = keyof T; /** A key in object annotated with its type and optionally meta information. */ type TypedField = { /** The field name. */ name: keyof T; /** The field's values type. */ type: FieldType; /** Whether the field should be active by default. */ active?: boolean; /** Whether the field should be editable. */ editable?: boolean; /** Whether the field should be filterable. */ filterable?: boolean; /** * The "lookup" (query parameter) to use for this field while filtering (e.g. * "omschrijving__icontains"). */ filterLookup?: string; /** The value for this field's filter. */ filterValue?: string | number; /** Whether a value is required. */ required?: boolean; /** Used by DataGrid to determine whether the field should be sortable. */ sortable?: boolean; /** * The "lookup" (dot separated) to use for this field while filtering (e.g. * "._expand.zaaktype.omschrijving"). */ valueLookup?: string; /** * A function transforming `T` to a value. * This can be used to compute values dynamically. */ valueTransform?: (value: T) => unknown; /** Used by AttributeTable/DataGrid when editable=true. */ options?: Option[] | LoadOptionsFn; /** Whether to fetch options on mount. Used by forms. */ fetchOnMount?: boolean; /** Whether it's a multiple choice field. Used by forms. */ multiple?: boolean; /** The placeholder shown when there's no value */ placeholder?: string; /** Used by DataGrid to set column width. */ width?: string; }; /** Known options for TypedField["type"] */ type FieldType = "boolean" | "date" | "daterange" | "duration" | "null" | "number" | "string" | "text" | "jsx"; /** A Django-admin like field_options definition. */ type FieldOptions = { /** A `string[]` or `TypedField[]` containing the keys in to show data for. */ fields: Array | TypedField>; /** When shown in a Kanban: the component to render. */ component?: React.ComponentType; /** When shown in an AttributeGrid: the number of columns to span for each field. */ colSpan?: number; /** When shown in an AttributeGrid: the span to use for this fieldset. */ span?: number; /** When shown in an ItemGrid: the field to use as title. */ title?: Field; /** When shown in an AttributeGrid: the number of columns to span for title. */ titleSpan?: number; }; /** A Django-admin like fieldset definition. */ type FieldSet = [ string | undefined, FieldOptions ]; /** * Converts an array of `Field` or `TypedField` into an array of `TypedField`. * Each element is normalized by inspecting the optional `objectList` and * extending with the optional `base` properties. * * @template T - The type of the source objects. * @param optionallyTypedFields - An array of field keys or typed field objects. * @param objectList - Optional array of source objects used to infer field types. * @param base - Optional base properties to merge into each resulting `TypedField`. * @returns An array of fully normalized `TypedField` objects. */ declare function fields2TypedFields(optionallyTypedFields: Array | TypedField>, objectList?: T[], base?: Partial>): TypedField[]; /** * Converts a single `Field` or `TypedField` into a `TypedField`. * If a primitive key is provided, its type is inferred from the optional `objectList`. * Any additional properties from `base` are merged into the resulting `TypedField`. * * @template T - The type of the source objects. * @param optionallyTypedField - A field key or a typed field object. * @param objectList - Optional array of source objects used to infer field types. * @param base - Optional base properties to merge into the resulting `TypedField`. * @returns A fully normalized `TypedField` object. */ declare function field2TypedField(optionallyTypedField: Field | TypedField, objectList?: T[], base?: Partial>): TypedField; /** * Converts a `Field` or `TypedField` into a `FormField` suitable for forms. * The field is first normalized to a `TypedField`, then mapped to form-specific properties. * * @template T - The type of the source objects. * @param optionallyTypedField - A field key or a typed field object. * @param objectList - Optional array of source objects used to infer field types. * @returns A `FormField` object with `name`, `type`, `options`, and `required` properties. */ declare function field2FormField(optionallyTypedField: Field | TypedField, objectList?: T[]): FormField; /** * Retrieves the name of a field. * * - If the field is a primitive key (e.g., string, number, or symbol), returns it directly. * - If the field is a `TypedField`, returns its `.name` property. * * @template T - The type of the source object. * @param optionallyTypedField - A field key or a typed field object. * @returns The name of the field as a key. */ declare function getFieldName(optionallyTypedField: Field | TypedField): keyof T; export { DEFAULT_URL_FIELDS, field2FormField, field2TypedField, fields2TypedFields, getFieldName }; export type { Field, FieldOptions, FieldSet, FieldType, TypedField };