import { FragmentFieldConfig, ListFieldConfig, ObjectConfig, ObjectFieldConfig, ValueFieldConfig } from "./config"; import { Fragment, ObjectState } from "./fields/objectField"; import { Rule } from "./rules"; import { Builtin, OmitIf } from "./utils"; /** * Provides a Zod-ish API for building form configs. */ export declare const f: { /** Creates the top-level config for a form, like an author or book. */ config(fields: ObjectConfigBuilderFields): ObjectConfig; /** Creates the config DSL for an object, like an author or book. */ object(fields: ObjectConfigBuilderFields): ObjectConfigBuilder; /** Creates the config DSL for an list of objects, like an author's list of books. */ list(fields: ObjectConfigBuilderFields): ListFieldConfigBuilder; /** Creates the config DSL for a primitive value, like a first name or phone number. */ value(): ValueFieldConfigBuilder; /** A shortcut for creating a child object with a single `id` key. */ reference(fields?: ObjectConfigBuilderFields): ObjectConfigBuilder; /** A shorthand for creating a computed value. */ computed(): ValueFieldConfigBuilder; }; /** * Defines the fields that should be passed into `f.object({ ... })` for fhe form type `T`. * * This is basically a map of `key` in `T` to `f.value()`, `f.list()`, or `f.object()` * DSL objects that define the runtime structure/fields of the form. */ export type ObjectConfigBuilderFields = { [P in keyof OmitIf]: T[P] extends Fragment ? FragmentFieldConfigBuilder : T[P] extends Array | null | undefined ? U extends Builtin ? ValueFieldConfigBuilder : ListFieldConfigBuilder : ValueFieldConfigBuilder | ObjectConfigBuilder; }; export interface FragmentFieldConfigBuilder { build(): FragmentFieldConfig; } /** Provides a fluent DSL for building up an object's config. */ export declare class ObjectConfigBuilder { private config; constructor(fields: ObjectConfigBuilderFields); ref(): this; build(): ObjectFieldConfig; } /** Provides a fluent DSL for building up a value's config. */ export declare class ValueFieldConfigBuilder { private config; /** Marks the field as required. */ req(): this; /** Marks the field as read only. */ readOnly(): this; /** Marks the field as local only. */ localOnly(): this; /** Appends `rules` to the field's validation rules. */ rules(rules: Rule[]): this; /** Marks the field as computed. */ computed(): this; build(): ValueFieldConfig; } /** Provides a fluent DSL for building up a list's config. */ export declare class ListFieldConfigBuilder { private config; constructor(fields: ObjectConfigBuilderFields); /** Appends `rule` to the field's validation rules. */ rule(rule: Rule[]>): this; /** Appends `rules` to the field's validation rules. */ rules(rules: Rule[]>[]): this; build(): ListFieldConfig; }