import type { FieldChangeContext, FieldValidationContext, VisibleFieldConfig } from './field-config.js'; import type { FieldValidationResult } from './field-controller.js'; import type { MaybePromise } from './field-value.js'; import type { AltEditorLiteLanguage } from '../core/alt-editor-lite-language.js'; declare const customFieldConfigMarker: unique symbol; /** Compares two values using field-specific equality semantics. */ export type FieldValueComparator = (left: TValue, right: TValue) => boolean; /** Optional editing surfaces supported by a custom field implementation. */ export interface CustomFieldCapabilities { readonly batch?: boolean; readonly inline?: boolean; } /** Editing surface that owns a custom field controller instance. */ export type CustomFieldPresentation = 'dialog' | 'batch' | 'inline'; /** Stable editor services supplied while a custom field control is created. */ export interface CustomFieldControllerContext { /** Complete resolved language, including the canonical locale. */ readonly language: Readonly; /** Editing surface that created this controller. */ readonly presentation: CustomFieldPresentation; /** Editing operation that created this controller. */ readonly operation: 'create' | 'edit' | 'batchEdit'; /** Signal aborted when the rendered field is cancelled or destroyed. */ readonly signal: AbortSignal; /** Notification that the user changed the widget value. */ readonly onUserChange: () => void; } /** Consumer-owned widget behavior mounted inside the editor-owned field shell. */ export interface CustomFieldAdapter { /** Widget root mounted between the field label and error message. */ readonly control: HTMLElement; /** Focusable control element that receives editor-owned accessibility relations. */ readonly ariaTarget?: HTMLElement; getValue(): MaybePromise; setValue(value: TValue): void; setDisabled(disabled: boolean): void; setReadOnly(readOnly: boolean): void; setRequired(required: boolean): void; focus(): void; /** Validates widget semantics, including required emptiness when applicable. */ validate?(signal: AbortSignal): MaybePromise; /** Reports whether a focus destination remains inside this widget. */ readonly containsFocusTarget?: (target: Node | null) => boolean; destroy(): void; } type CustomFieldOptionsValue = TOptions extends object ? Readonly : undefined; /** Runtime definition retained by each custom field configuration. */ export interface CustomFieldRuntimeDefinition { readonly capabilities?: Readonly; isEqual?(left: TValue, right: TValue): boolean; createController(options: CustomFieldOptionsValue, context: Readonly): CustomFieldAdapter; } /** Definition accepted by {@link defineCustomField}. */ export type CustomFieldDefinitionOptions = CustomFieldRuntimeDefinition; type CustomFieldOptionInput = TOptions extends object ? { readonly options: Readonly; } : { readonly options?: undefined; }; type CustomVisibleFieldConfig = Omit, 'attributes' | 'onChange' | 'validate'> & { onChange?(value: TValue, context: FieldChangeContext): MaybePromise; validate?(value: TValue, context: FieldValidationContext): MaybePromise; }; /** Consumer input accepted by a typed custom field definition. */ export type CustomFieldConfigOptions = CustomVisibleFieldConfig & CustomFieldOptionInput; /** Custom field configuration created by a typed definition. */ export type CustomFieldConfig = CustomVisibleFieldConfig & { readonly type: 'custom'; readonly definition: Readonly>; readonly options?: CustomFieldOptionsValue; readonly [customFieldConfigMarker]: true; }; /** Typed definition with a field builder that preserves form-path checking. */ export interface CustomFieldDefinition extends CustomFieldRuntimeDefinition { field(config: CustomFieldConfigOptions): CustomFieldConfig; } /** Creates an explicit, type-safe custom field definition without global state. */ export declare function defineCustomField(definition: CustomFieldDefinitionOptions): CustomFieldDefinition; export {};