import { optional, record } from '@synnaxlabs/x'; import { FC, ReactElement } from 'react'; import { RenderProp } from '../component/renderProp'; import { ContextValue } from './Context'; import { FieldState, GetOptions } from './state'; import { UseFieldOptions, UseFieldReturn } from './useField'; import { Input } from '../input'; import { Select } from '../select'; interface FieldChild extends Input.Control, Pick, "preview"> { } /** Props for {@link Field}. */ export type FieldProps = GetOptions & UseFieldOptions & Omit & { /** Dot-separated path into the form values. */ path: string; /** Renders the input. Defaults to a text input. */ children?: RenderProp>; /** Whether to hold room for help text, so the layout does not jump. */ padHelpText?: boolean; /** Hides the field when false, or when the predicate rejects its state. */ visible?: boolean | ((state: FieldState, ctx: ContextValue) => boolean); /** Whether an absent value hides the field instead of throwing. */ hideIfNull?: boolean; }; export type FieldT = (props: FieldProps) => ReactElement | null; /** * One labeled row of a form: its label, its input, and its validation message. The * label falls back to the last path element in sentence case. * * @example * @example {(p) => } */ export declare const Field: ({ path, children, label, padHelpText, visible, hideIfNull, optional, onChange, className, defaultValue, ...rest }: FieldProps) => ReactElement | null; export interface FieldBuilderProps { fieldKey?: string; fieldProps?: Partial>; inputProps: Omit; } export type BuiltFieldProps = never> = FieldProps & { inputProps?: optional.Optional, OptionalFields>; fieldKey?: string; }; /** * Binds an input component to a form field once, so callers write the field instead of * a render prop. Use it for an input the app reaches for often. * * @example * export const RateField = fieldBuilder(Input.Numeric)({ inputProps: { units: "Hz" } }); */ export declare const fieldBuilder: = never>(Component: FC

>) => ({ fieldKey: baseFieldKey, fieldProps, inputProps: baseInputProps, }: FieldBuilderProps) => FC>; export type NumericFieldProps = BuiltFieldProps; export declare const buildNumericField: ({ fieldKey: baseFieldKey, fieldProps, inputProps: baseInputProps, }: FieldBuilderProps) => FC>; export declare const NumericField: FC>; export type TextFieldProps = BuiltFieldProps; export declare const buildTextField: ({ fieldKey: baseFieldKey, fieldProps, inputProps: baseInputProps, }: FieldBuilderProps) => FC>; export declare const TextField: FC>; export type SwitchFieldProps = BuiltFieldProps; export declare const buildSwitchField: ({ fieldKey: baseFieldKey, fieldProps, inputProps: baseInputProps, }: FieldBuilderProps) => FC>; export declare const SwitchField: FC>; export type SelectFieldProps> = BuiltFieldProps, "data" | "resourceName">; export declare const buildSelectField: >(props: FieldBuilderProps>) => FC, "data" | "resourceName">>; export {}; //# sourceMappingURL=Field.d.ts.map