/** @jsxImportSource react */ import { TooltipConfig, TooltipOptions, TooltipParentInstance } from "../overlay/tooltip-ops"; import { Instance } from "../../ui/Instance"; import { PureContainerBase, PureContainerConfig } from "../../ui/PureContainer"; import type { RenderingContext } from "../../ui/RenderingContext"; import { WidgetStyleConfig } from "../../ui/Widget"; import { BooleanProp, ClassProp, Config, Prop, StringProp, StructuredProp, StyleProp } from "../../ui/Prop"; import type { TooltipInstance } from "../overlay"; import type { FormRenderingContext } from "./ValidationGroup"; export interface FieldConfig extends PureContainerConfig, WidgetStyleConfig { /** Field label. For advanced use cases. */ label?: StringProp | Config; /** Set to `material` to use custom label placement instruction. Used in Material theme to implement animated labels. */ labelPlacement?: "material"; /** Set to `material` to use custom help placement instruction. Used in Material theme to implement absolutely positioned validation messages. */ helpPlacement?: "material"; /** Either `view` or `edit` (default). In `view` mode, the field is displayed as plain text. */ mode?: Prop<"view" | "edit">; /** Set to `true` to switch to widget view mode. Same as `mode="view"`. Default is false. */ viewMode?: BooleanProp; id?: Prop; /** Used for validation. If error evaluates to non-null, the field is marked in red. */ error?: StringProp; /** Style object applied to the input element. Used for setting visual elements, such as borders and backgrounds. */ inputStyle?: StyleProp; /** Additional CSS class applied to the input element. Used for setting visual elements, such as borders and backgrounds. */ inputClass?: ClassProp; /** Additional attributes that should be rendered on the input element. E.g. inputAttrs={{ autoComplete: "off" }}. */ inputAttrs?: Config; /** Text to be rendered in view mode when the field is empty. */ emptyText?: StringProp; /** Set to `true` to make error indicators visible in pristine state. By default, validation errors are not shown until the user visits the field. */ visited?: BooleanProp; /** Set to `true` to automatically focus the field, after it renders for the first time. */ autoFocus?: BooleanProp; /** Defines how to present validation errors. Default mode is `tooltip`. Other options are `help` and `help-block`. */ validationMode?: "tooltip" | "help" | "help-block"; /** Defaults to `false`. Set to `true` to disable the field. */ disabled?: BooleanProp; /** The opposite of `disabled`. */ enabled?: BooleanProp; /** Defaults to `false`. Used to make the field required. */ required?: BooleanProp; /** Used to indicate that required fields should not be marked as invalid before the user visits them. */ suppressErrorsUntilVisited?: boolean; /** Error message used to indicate that field is required. */ requiredText?: string; /** Append asterisk to the label to indicate a required field. */ asterisk?: BooleanProp; /** Text displayed to the user to indicate that server-side validation is in progress. */ validatingText?: string; /** Text displayed to the user to indicate that server-side validation has thrown an exception. */ validationExceptionText?: string; /** Configuration of the tooltip used to indicate validation errors. */ errorTooltip?: Config; /** Tooltip configuration. */ tooltip?: StringProp | StructuredProp; /** Indicates that `help` should be separated from the input with a whitespace. Default is `true`. */ helpSpacer?: boolean; /** If set to `true` top level element will get additional CSS class indicating that input is focused. Default is `false`. */ trackFocus?: boolean; /** Custom tab index */ tabIndex?: StringProp; /** Additional content to be displayed next to the field. */ help?: string | Config; /** Validation parameters to be passed to the validation function. */ validationParams?: Config; onValidationException?: string | ((error: unknown, instance: FieldInstance) => void); /** Value to be set in the store if the field is empty. Default value is null. */ emptyValue?: unknown; /** Additional CSS style to be passed to the label object. */ labelStyle?: StyleProp; /** Additional CSS class to be passed to the label object. */ labelClass?: ClassProp; } export declare class FieldInstance = Field> extends Instance implements TooltipParentInstance { state: Record; parentDisabled?: boolean; parentReadOnly?: boolean; parentViewMode?: boolean | string; parentTabOnEnterKey?: boolean; parentVisited?: boolean; tooltips: { [key: string]: TooltipInstance; }; } export declare class Field = FieldInstance> extends PureContainerBase { inputStyle?: Record | string; validationMode?: string; errorTooltip?: Record; tooltip?: TooltipConfig; help?: Record | string; label?: Record | string; mod?: Record; disabled?: boolean; required?: boolean; asterisk?: boolean; labelStyle?: Record | string; labelClass?: string; icon?: null | string; visited?: boolean; labelPlacement?: string | boolean; helpPlacement?: string | boolean; emptyValue?: unknown; requiredText?: string; validatingText?: string; onValidate?: string | ((value: unknown, instance: Instance, validationParams: Record) => unknown); validationExceptionText?: string; onValidationException?: string | ((error: unknown, instance: Instance) => void); onKeyDown?: string | ((e: React.KeyboardEvent, instance: Instance) => boolean | void); suppressErrorsUntilVisited?: boolean; autoFocus?: boolean; helpSpacer?: boolean; trackFocus?: boolean; baseClass: string; declareData(...args: Record[]): void; init(): void; initComponents(_context: RenderingContext, instance: Instance): void; initState(_context: RenderingContext, instance: InstanceType): void; prepareData(context: FormRenderingContext, instance: InstanceType, ...args: Record[]): void; protected disableOrValidate(context: FormRenderingContext, instance: Instance): void; explore(context: FormRenderingContext, instance: InstanceType): void; exploreCleanup(context: FormRenderingContext, instance: Instance): void; isEmpty(data: Record): boolean; validateRequired(context: FormRenderingContext, instance: Instance): string | undefined; getValidationValue(data: Record): unknown; validate(context: FormRenderingContext, instance: Instance): void; renderLabel(context: RenderingContext, instance: Instance, key: string): React.ReactNode; renderInput(context: RenderingContext, instance: Instance, key: string): React.ReactNode; renderHelp(context: RenderingContext, instance: Instance, key: string): React.ReactNode; renderIcon(context: RenderingContext, instance: Instance, key: string): React.ReactNode; formatValue(context: RenderingContext, { data }: Instance): string | React.ReactNode; renderValue(context: RenderingContext, instance: FieldInstance, key?: string | number): React.ReactNode; protected renderContent(context: RenderingContext, instance: FieldInstance, key: string): React.ReactNode; protected renderWrap(context: RenderingContext, instance: Instance, key: string, content: React.ReactNode): React.ReactNode; protected renderEmptyText(_context: RenderingContext, { data }: Instance, key: string): React.ReactNode; render(context: RenderingContext, instance: InstanceType, key: string): Record; handleKeyDown(e: React.KeyboardEvent, instance: Instance): boolean | void; } export declare function getFieldTooltip(instance: FieldInstance): [FieldInstance, TooltipConfig, TooltipOptions | undefined]; //# sourceMappingURL=Field.d.ts.map