import * as i0 from '@angular/core'; import { Signal, InputSignal, InjectionToken, OnInit, DoCheck, InputSignalWithTransform } from '@angular/core'; import { NgControl, AbstractControl, FormGroupDirective, NgForm } from '@angular/forms'; import { VariantProps } from 'class-variance-authority'; /** * Contract that any control inside a form field must implement. * * This allows the form field to read state from any inner control * (input, textarea, custom controls) without knowing implementation details. * * @example Implementing for a custom phone input * ```ts * @Directive({ * selector: 'com-phone-input', * providers: [{ provide: FormFieldControl, useExisting: PhoneInputComponent }], * }) * export class PhoneInputComponent extends FormFieldControl { * // ... implement all abstract members * } * ``` */ declare abstract class FormFieldControl<_T = unknown> { /** The NgControl bound to this control (if any). */ abstract readonly ngControl: NgControl | null; /** Whether the control is focused. */ abstract readonly focused: Signal; /** Whether the label should float (focused or non-empty). */ abstract readonly shouldLabelFloat: Signal; /** Whether the control is required. */ abstract readonly required: Signal; /** Whether the control is disabled. */ abstract readonly disabled: Signal; /** Whether the control is in an error state. */ abstract readonly errorState: Signal; /** Unique ID for the control element. */ abstract readonly id: Signal; /** Structured validation errors (Signal Forms path). */ readonly errors?: Signal; /** Called when the form field container is clicked. */ abstract onContainerClick(event: MouseEvent): void; } /** * Directive to mark the label element inside a form field. * * The form field automatically associates this label with the inner control * and positions it appropriately based on appearance and float state. * * The label renders as `inline-flex` so it can contain inline content such as * icons with tooltips. Icons inside the label are visually hidden when the * label floats to keep the scaled-down state clean. * * @tokens none * * @example Plain label * ```html * * * * * ``` * * @example Label with help icon and tooltip * ```html * * * * * ``` */ declare class ComLabel { readonly labelId: string; private readonly _forId; readonly forId: Signal; /** Sets the `for` attribute to link to the control. Called by form field. */ setForId(id: string): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } /** Alignment of hint text in the subscript area. */ type HintAlign = 'start' | 'end'; /** * Directive for hint text displayed below the form field. * * The hint provides supplementary information to help users fill out the field. * It is automatically added to the control's `aria-describedby`. * * @tokens `--color-muted-foreground` * * @example Basic hint * ```html * * * * At least 8 characters * * ``` * * @example Right-aligned hint (e.g., character count) * ```html * * * * Keep it brief * {{ bioLength }}/150 * * ``` */ declare class ComHint { readonly id: string; readonly align: InputSignal; protected readonly hostClasses: Signal; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } /** * Directive for error messages displayed below the form field. * * Errors replace hints when the control is in an error state. * Uses `role="alert"` and `aria-live="polite"` for screen reader announcement. * * The optional `match` input allows showing errors only for specific validation errors. * * @tokens `--color-warn` * * @example Basic error * ```html * * * * Please enter a valid email * * ``` * * @example Matching specific errors * ```html * * * * Email is required. * Must be a valid email address. * * ``` */ declare class ComError { readonly id: string; /** Reference to the form control (Reactive Forms path). */ private readonly _control; /** Structured errors from Signal Forms. */ private readonly _signalErrors; /** * Show this error only when a specific validation error key is present. * If empty, the error is always shown when the control is in error state. */ readonly match: InputSignal; protected readonly errorVariants: () => string; /** * Whether this error should be displayed based on the match condition. * Used by the form field to filter which errors to show. */ readonly shouldShow: Signal; /** * Sets the form control reference (Reactive Forms). * Called by the parent form field component. */ setControl(control: AbstractControl | null): void; /** * Sets structured validation errors (Signal Forms). * Called by the parent form field component. */ setSignalErrors(errors: readonly unknown[]): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } /** * Directive to mark content as the prefix slot in a form field. * * Prefix content appears before the input (e.g., currency symbol, icon). * * @tokens `--color-muted-foreground` * * @example Currency prefix * ```html * * * $ * * * ``` * * @example Icon prefix * ```html * * * ... * * * ``` */ declare class ComPrefix { protected readonly prefixVariants: () => string; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } /** * Directive to mark content as the suffix slot in a form field. * * Suffix content appears after the input (e.g., unit, clear button, visibility toggle). * * @tokens `--color-muted-foreground` * * @example Unit suffix * ```html * * * * kg * * ``` * * @example Clear button suffix * ```html * * * * * * ``` * * @example Password visibility toggle * ```html * * * * * * ``` */ declare class ComSuffix { protected readonly suffixVariants: () => string; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } /** * Strategy for determining when to display errors in a form field. * * The default behavior shows errors when the control is invalid AND * either touched OR the parent form has been submitted. * * @remarks * **Reset gotcha:** `FormGroup.reset()` clears control state (dirty, touched, value) * but does NOT reset `FormGroupDirective.submitted`. This means invalid fields * will continue showing errors after reset because `form.submitted` is still `true`. * * To fully reset error display, use `FormGroupDirective.resetForm()` instead, * or call `form.markAsUntouched()` after `form.reset()`. * * @example Override globally with eager error display * ```ts * @Injectable() * export class EagerErrorStateMatcher extends ErrorStateMatcher { * override isErrorState(control: AbstractControl | null): boolean { * return !!(control?.invalid && control.dirty); * } * } * * // In app config * providers: [{ provide: ErrorStateMatcher, useClass: EagerErrorStateMatcher }] * ``` * * @example Per-field override * ```html * * * * ``` */ declare class ErrorStateMatcher { isErrorState(control: AbstractControl | null, form: FormGroupDirective | NgForm | null): boolean; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } type FormFieldAppearance = 'fill' | 'outline'; type FormFieldColor = 'primary' | 'accent' | 'warn'; type FormFieldFloatLabel = 'auto' | 'always'; type FormFieldSubscriptSizing = 'fixed' | 'dynamic'; /** * CVA variants for the form field wrapper. * * @tokens `--color-foreground` */ declare const formFieldVariants: (props?: { disabled?: boolean | null | undefined; }) => string; type FormFieldVariants = VariantProps; /** * CVA variants for the input container (the bordered/filled area). * * @tokens `--color-input-border`, `--color-input-background`, `--color-primary`, * `--color-accent`, `--color-warn`, `--color-ring`, `--color-muted`, * `--color-disabled`, `--radius-input` */ declare const formFieldContainerVariants: (props?: { appearance?: FormFieldAppearance | null | undefined; color?: FormFieldColor | null | undefined; focused?: boolean | null | undefined; error?: boolean | null | undefined; disabled?: boolean | null | undefined; }) => string; type FormFieldContainerVariants = VariantProps; /** * CVA variants for the floating label. * * @tokens `--color-muted-foreground`, `--color-primary`, `--color-accent`, * `--color-warn`, `--color-background` */ declare const formFieldLabelVariants: (props?: { appearance?: FormFieldAppearance | null | undefined; floating?: boolean | null | undefined; color?: FormFieldColor | null | undefined; error?: boolean | null | undefined; focused?: boolean | null | undefined; disabled?: boolean | null | undefined; }) => string; type FormFieldLabelVariants = VariantProps; /** * CVA variants for the subscript area (hints/errors). * * @tokens (inherits from children) */ declare const formFieldSubscriptVariants: (props?: { sizing?: FormFieldSubscriptSizing | null | undefined; }) => string; type FormFieldSubscriptVariants = VariantProps; /** * CVA variants for hint text. * * @tokens `--color-muted-foreground` */ declare const hintVariants: () => string; /** * CVA variants for error messages. * * @tokens `--color-warn` */ declare const errorVariants: () => string; /** * CVA variants for prefix slot. * * @tokens `--color-muted-foreground` */ declare const prefixVariants: () => string; /** * CVA variants for suffix slot. * * @tokens `--color-muted-foreground` */ declare const suffixVariants: () => string; /** * Global configuration defaults for form fields. * * @example Set defaults in app config * ```ts * providers: [ * { * provide: FORM_FIELD_DEFAULTS, * useValue: { * appearance: 'fill', * floatLabel: 'always', * color: 'primary', * } * } * ] * ``` */ interface FormFieldDefaults { appearance?: FormFieldAppearance; color?: FormFieldColor; floatLabel?: FormFieldFloatLabel; hideRequiredMarker?: boolean; subscriptSizing?: FormFieldSubscriptSizing; } declare const FORM_FIELD_DEFAULTS: InjectionToken; /** * Directive applied to native `` and ` * * ``` * * @example Custom error state matcher * ```html * * * * * ``` */ declare class ComInput implements FormFieldControl, OnInit, DoCheck { private readonly elementRef; private readonly destroyRef; private readonly autofillMonitor; private readonly defaultErrorStateMatcher; private readonly parentForm; private readonly parentFormGroup; /** NgControl bound to this input (if using reactive forms). */ readonly ngControl: NgControl | null; readonly inputId: InputSignal; readonly inputDisabled: InputSignalWithTransform; readonly inputRequired: InputSignalWithTransform; readonly userAriaDescribedBy: InputSignal; readonly errorStateMatcher: InputSignal; readonly sfInvalid: InputSignal; readonly sfTouched: InputSignalWithTransform; readonly sfErrors: InputSignal; /** Whether the form system is Signal Forms (no NgControl present). */ private readonly isSignalForms; private readonly _focused; private readonly _autofilled; private readonly _empty; /** Incremented on every `statusChanges` emission to invalidate computeds that read plain control properties. */ private readonly _controlStatusVersion; private readonly _uniqueId; private readonly _appearance; private _previousNativeValue; readonly focused: Signal; readonly id: Signal; readonly shouldLabelFloat: Signal; readonly disabled: Signal; readonly required: Signal; readonly errorState: Signal; /** Structured validation errors from Signal Forms, exposed for the parent form field. */ readonly errors: Signal; /** Combined aria-describedby including user-provided and form-field-generated IDs. */ private readonly _describedByIds; readonly ariaDescribedBy: Signal; /** Computed host classes including appearance-based padding. */ protected readonly hostClasses: Signal; ngOnInit(): void; ngDoCheck(): void; private dirtyCheckNativeValue; protected onFocus(): void; protected onBlur(): void; protected onInput(): void; private updateEmpty; onContainerClick(event: MouseEvent): void; /** * Sets the describedBy IDs from the form field. * Called by the parent form field component. */ setDescribedByIds(ids: string): void; /** * Sets the appearance for styling. * Called by the parent form field component. */ setAppearance(appearance: FormFieldAppearance): void; /** Focus the native element. */ focus(): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } /** * Form field wrapper providing visual structure for form inputs. * * Provides floating labels, borders (outline/fill appearance), hints, errors, * and prefix/suffix slots. Automatically wires ARIA attributes for accessibility. * * The form field reads state from its inner `FormFieldControl` child (typically * a `ComInput` directive) and renders UI accordingly. * * @tokens `--color-foreground`, `--color-input-border`, `--color-input-background`, * `--color-primary`, `--color-accent`, `--color-warn`, `--color-ring`, * `--color-muted`, `--color-muted-foreground`, `--color-disabled`, * `--color-disabled-foreground`, `--color-background`, `--radius-input` * * @example Basic outline field * ```html * * * * We'll never share your email. * Email is required. * * ``` * * @example Fill appearance * ```html * * * * * ``` * * @example With prefix and suffix * ```html * * * $ * * .00 * * ``` * * @example Label with icon and tooltip * ```html * * * * * ``` */ declare class ComFormField { private readonly defaults; readonly control: Signal; readonly inputDirective: Signal; readonly labelChild: Signal; readonly hintChildren: Signal; readonly errorChildren: Signal; readonly prefixChild: Signal; readonly suffixChild: Signal; readonly appearance: InputSignal; readonly color: InputSignal; readonly floatLabel: InputSignal; readonly hideRequiredMarker: InputSignalWithTransform; readonly subscriptSizing: InputSignal; readonly userClass: InputSignal; readonly shouldLabelFloat: Signal; readonly isFocused: Signal; readonly isDisabled: Signal; readonly hasError: Signal; readonly hasPrefix: Signal; readonly hasSuffix: Signal; readonly showRequiredMarker: Signal; readonly showErrors: Signal; protected readonly hostClasses: Signal; protected readonly containerClasses: Signal; protected readonly labelClasses: Signal; protected readonly subscriptClasses: Signal; constructor(); protected onContainerClick(event: MouseEvent): void; protected onContainerActivate(): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } export { ComError, ComFormField, ComHint, ComInput, ComLabel, ComPrefix, ComSuffix, ErrorStateMatcher, FORM_FIELD_DEFAULTS, FormFieldControl, errorVariants, formFieldContainerVariants, formFieldLabelVariants, formFieldSubscriptVariants, formFieldVariants, hintVariants, prefixVariants, suffixVariants }; export type { FormFieldAppearance, FormFieldColor, FormFieldContainerVariants, FormFieldDefaults, FormFieldFloatLabel, FormFieldLabelVariants, FormFieldSubscriptSizing, FormFieldSubscriptVariants, FormFieldVariants, HintAlign };