export type FormControlValue = string | number | boolean | File | File[] | FormData | null | object; interface SchemaBase { type: string; description?: string; format?: string; } export interface StringSchema extends SchemaBase { type: 'string'; minLength?: number; maxLength?: number; pattern?: string; } export interface NumberSchema extends SchemaBase { type: 'number'; minimum?: number; maximum?: number; multipleOf?: number; } export interface BooleanSchema extends SchemaBase { type: 'boolean'; } export interface ArraySchema extends SchemaBase { type: 'array'; items: Schema; minItems?: number; maxItems?: number; } export interface ObjectSchema extends SchemaBase { type: 'object'; properties: Record; required?: string[]; additionalProperties?: boolean | Schema; } export interface EnumSchema extends SchemaBase { type: 'enum'; enum: Array; } export type Schema = StringSchema | NumberSchema | BooleanSchema | ArraySchema | ObjectSchema | EnumSchema; export interface FormControlMetadata { tag: string; valueSchema: Schema; version?: string; validators?: Validator[]; strict?: boolean; } export interface FormControlInstance extends HTMLElement { value: FormControlValue | undefined; defaultValue: string; form: HTMLFormElement | null; readOnly: boolean; disabled: boolean; name: string; noValidate: boolean; willValidate: boolean; validity: ValidityState; validationMessage: string; required: boolean; pattern: string; min: number | null; max: number | null; step: number | null; minLength: number; maxLength: number; labels: NodeList; composedLabel: string; valueAsString: string; valueAsNumber: number; checkValidity(): boolean; reportValidity(): boolean; reset(): void; setCustomValidity(message: string): void; } /** * @event input - Dispatched when the input value changes * @event change - Dispatched when the user commits the value */ export interface FormControl { new (...args: any[]): FormControlInstance; formAssociated: boolean; metadata: FormControlMetadata; localName?: string; } export type ChangeEvent = Event & { type: 'change'; }; export interface ValidatorResult { validity: Partial; message?: string; } export type Validator = (value: unknown, element: FormControlInstance) => ValidatorResult; export {};