import type { AddressFieldSpec, AddressFormValue, AutocompleteFieldSpec, AutocompleteOption, CurrencyFieldSpec, DateFieldSpec, DateTimeFieldSpec, DurationFieldSpec, FieldSpec, FormLayoutSpec, FormOption, FormSpec, FormValuesFor, NumberFieldSpec, PercentFieldSpec, PhoneFieldSpec, PhoneFormValue, TimeFieldSpec } from '@contractspec/lib.contracts-spec/forms'; import type { AnySchemaModel } from '@contractspec/lib.schema'; import React from 'react'; type NumericFieldSlotProps = React.InputHTMLAttributes & { format?: NumberFieldSpec['format'] | PercentFieldSpec['format'] | CurrencyFieldSpec['format'] | DurationFieldSpec['format']; valueScale?: PercentFieldSpec['valueScale']; valueUnit?: DurationFieldSpec['valueUnit']; }; export interface DriverSlots { FormRoot?: React.ComponentType>; Field: React.ComponentType>; FieldLabel: React.ComponentType>; FieldContent?: React.ComponentType>; FieldDescription: React.ComponentType>; FieldError: React.ComponentType<{ id?: string; errors: { message?: string; }[]; }>; FieldGroup?: React.ComponentType>; FieldSet?: React.ComponentType>; FieldLegend?: React.ComponentType>; FieldSeparator?: React.ComponentType>; FieldArray?: React.ComponentType>; FieldArrayItem?: React.ComponentType>; Actions?: React.ComponentType>; Input: React.ComponentType>; NumberField?: React.ComponentType; PercentField?: React.ComponentType; CurrencyField?: React.ComponentType; DurationField?: React.ComponentType; Textarea: React.ComponentType>; InputGroup?: React.ComponentType>; InputGroupAddon?: React.ComponentType>; InputGroupInput?: React.ComponentType>; InputGroupTextarea?: React.ComponentType>; InputGroupText?: React.ComponentType>; InputGroupIcon?: React.ComponentType<{ iconKey: string; label?: string; }>; PasswordInput?: React.ComponentType & { passwordPurpose?: 'current' | 'new'; visibilityToggle?: boolean; showLabelI18n?: string; hideLabelI18n?: string; }>; Select: React.ComponentType<{ id?: string; name?: string; value?: unknown; onChange?: (value: unknown) => void; disabled?: boolean; 'aria-invalid'?: boolean; 'aria-describedby'?: string; options: FormOption[]; } & Record>; Checkbox: React.ComponentType<{ id?: string; name?: string; checked?: boolean; onCheckedChange?: (value: boolean) => void; disabled?: boolean; 'aria-invalid'?: boolean; 'aria-describedby'?: string; } & Record>; RadioGroup: React.ComponentType<{ id?: string; name?: string; value?: unknown; onValueChange?: (value: unknown) => void; disabled?: boolean; 'aria-invalid'?: boolean; 'aria-describedby'?: string; options: FormOption[]; } & Record>; Switch: React.ComponentType<{ id?: string; name?: string; checked?: boolean; onCheckedChange?: (value: boolean) => void; disabled?: boolean; 'aria-invalid'?: boolean; 'aria-describedby'?: string; } & Record>; Autocomplete: React.ComponentType<{ id?: string; name?: string; disabled?: boolean; readOnly?: boolean; 'aria-invalid'?: boolean; 'aria-describedby'?: string; placeholder?: string; multiple?: boolean; query: string; options: AutocompleteOption[]; selectedOptions: AutocompleteOption[]; loading?: boolean; error?: string | null; emptyText?: string; loadingText?: string; errorText?: string; onQueryChange?: (query: string) => void; onSelectOption?: (option: AutocompleteOption) => void; onRemoveOption?: (option: AutocompleteOption) => void; }>; AddressField: React.ComponentType<{ id?: string; name?: string; value?: AddressFormValue | null; onChange?: (value: AddressFormValue) => void; disabled?: boolean; readOnly?: boolean; 'aria-invalid'?: boolean; 'aria-describedby'?: string; parts?: AddressFieldSpec['parts']; countryOptions?: FormOption[]; }>; PhoneField: React.ComponentType<{ id?: string; name?: string; value?: PhoneFormValue | null; onChange?: (value: PhoneFormValue) => void; disabled?: boolean; readOnly?: boolean; 'aria-invalid'?: boolean; 'aria-describedby'?: string; parts?: PhoneFieldSpec['parts']; countryOptions?: FormOption[]; input?: PhoneFieldSpec['input']; output?: PhoneFieldSpec['output']; country?: PhoneFieldSpec['country']; display?: PhoneFieldSpec['display']; }>; DateField: React.ComponentType<{ id?: string; name?: string; value?: Date | null; onChange?: (value: Date | null) => void; disabled?: boolean; readOnly?: boolean; 'aria-invalid'?: boolean; 'aria-describedby'?: string; placeholder?: string; minDate?: Date | string; maxDate?: Date | string; format?: DateFieldSpec['format']; }>; TimeField: React.ComponentType<{ id?: string; name?: string; value?: Date | null; onChange?: (value: Date | null) => void; disabled?: boolean; readOnly?: boolean; 'aria-invalid'?: boolean; 'aria-describedby'?: string; placeholder?: string; is24Hour?: boolean; format?: TimeFieldSpec['format']; }>; DateTimeField: React.ComponentType<{ id?: string; name?: string; value?: Date | null; onChange?: (value: Date | null) => void; disabled?: boolean; readOnly?: boolean; 'aria-invalid'?: boolean; 'aria-describedby'?: string; datePlaceholder?: string; timePlaceholder?: string; minDate?: Date | string; maxDate?: Date | string; is24Hour?: boolean; format?: DateTimeFieldSpec['format']; }>; Button: React.ComponentType void; disabled?: boolean; }>>; } export type ResolverMap = Record) => Promise | readonly unknown[]>; export type ComputationMap = Record unknown>; export interface PhoneRendererOptions { input?: PhoneFieldSpec['input']; output?: PhoneFieldSpec['output']; country?: PhoneFieldSpec['country']; display?: PhoneFieldSpec['display']; } export interface CreateRendererOptions> { driver: DriverSlots; formOptions?: Record; onSubmitOverride?: (values: TValues, actionKey: string) => Promise | void; activeFlags?: string[]; resolvers?: ResolverMap; computations?: ComputationMap; phone?: PhoneRendererOptions; unmountStrategy?: 'keep' | 'clear'; submitMode?: 'form' | 'button'; } export interface RenderOptions> { defaultValues?: Partial; overrides?: Partial>; } export declare function filterAutocompleteOptions(options: readonly AutocompleteOption[], query: string, searchKeys: string[]): AutocompleteOption[]; export declare function mapAutocompleteValue(option: AutocompleteOption, mapping: AutocompleteFieldSpec['valueMapping']): {}; export declare function createFormRenderer(base: CreateRendererOptions>): { render: (spec: FormSpec, options?: RenderOptions>) => import("react/jsx-runtime").JSX.Element; }; export {};