import { VueConstructor } from 'vue'; declare type Validator = (value: any, props?: Record, ...args: any[]) => string | boolean | Promise; interface RuleSchema { validator?: Validator; name?: N; message?: string; } interface ValidationOptions { bails?: boolean; } declare type ValidationRuleSchema = Validator | (RuleSchema & { for?: string[]; cascade?: boolean; inherit?: boolean; }); declare type SchemaValidation = { valid: boolean; reason?: string; infos?: Record; }; declare type EventHandler = (...args: any[]) => any; declare type EventOptions = { noOff?: boolean; }; declare type EventElement = { handlers: EventHandler[]; options?: EventOptions; }; declare class Evento { events: Record; constructor(); emit(name: string, ...args: any[]): Evento; once(name: string, handler: EventHandler): Evento; on(name: string, handler: EventHandler, options?: EventOptions): Evento; off(name: string, handler?: EventHandler): Evento; } interface Plugs { } declare class Objeto extends Evento { protected _d: Record; protected readonly _config?: Record; readonly plugs?: Plugs; } declare type RuleData = { error: string | null; valid: boolean; }; declare class Rule extends Objeto { readonly name: string; protected _d: RuleData; message: string | null; validator?: Validator | null; constructor(rule: Rule | RuleSchema | Validator); get valid(): boolean; get error(): string; setMessage(message?: string | null): void; reset(): void; validate(value: any, props?: Record, ...args: any[]): Promise; } declare type ValitionRuleSchema = Validator | RuleSchema; declare type Options = { from?: number; }; declare class Validation extends Objeto { rules: Rule[]; constructor(rules?: ValitionRuleSchema[]); get valid(): boolean; get errors(): string[]; addRules(rulesOrSchemas: (Rule | ValitionRuleSchema)[], { from }?: Options): Rule[]; removeRules(removes: (Rule | string)[]): Rule[]; addRule(ruleOrSchema: Rule | ValitionRuleSchema, { from }?: Options): Rule; removeRule(remove: Rule | string): Rule; reset(): void; validate(value: any, options?: { excluded?: string[]; get?: string[]; }, ...args: any[]): Promise; } declare type UnionToIntersection = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never; declare type Primitive = string | number | boolean | bigint | symbol | undefined | null; declare type Builtin = Primitive | FunctionConstructor | Date | Error | RegExp; declare type ElementOptions = { silent?: boolean; }; interface ElementSchema { formId?: I; model?: I; props?: Record; on?: Record; options?: ElementOptions; rules?: ValidationRuleSchema[]; } interface ElementData { ancestors: any[] | null; schema: any; validation: Validation; options: ElementOptions; } declare type ElementsSchemas = FieldSchema | GroupSchema | CollectionSchema; interface GroupSchema extends ElementSchema { fields: ElementsSchemas[]; } interface CollectionSchema extends ElementSchema { group: Omit, 'formId'>; } declare type FormSchema = GroupSchema; declare type FieldType = 'string' | 'number' | 'boolean' | 'date'; declare type FieldValue = string | number | boolean | Date | null; declare type Format = string | ((field: any) => string); interface FieldSchema extends ElementSchema { type?: FieldType; format?: Format; default?: any; value?: any; checkedValue?: any; } declare type ReadonlySchema = T extends Builtin ? T : T extends Array ? Readonly : T extends Record ? { readonly [K in keyof T]: ReadonlySchema; } : Readonly; declare abstract class Element extends Objeto { static register(options: ElementOptions): void; readonly parent: Element | null; readonly model: string; protected _d: ElementData; props: Record; data: WeakMap; shaked: boolean; abstract isValid(): boolean; constructor(schema: ElementSchema, parent?: Element | null); get options(): ElementOptions; get validation(): Validation; get error(): string; getProps(path: string, options?: { up?: boolean; }): any; addProps(props: Record, ...args: any[]): void; get formId(): string; get htmlName(): string; get valid(): boolean; getHtmlName(): string; shake(): void; cleanUp(): void; } declare type GroupData = ElementData & { value: Record | null; pending: boolean; }; declare class Group extends Element { static FORM_TYPE: string; static accept(schema: any): SchemaValidation; static create(schema: GroupSchema, parent?: Element | null): Group; readonly formType: string; readonly type: 'enum'; protected _d: GroupData; fields: Element[]; constructor(schema: GroupSchema, parent?: Element | null); get pending(): boolean; get value(): Record; setValue(obj: Record): Promise>; shake({ cascade }?: { cascade?: boolean; }): void; isValid(): boolean; reset(): void; clear(): Promise; validate({ cascade }?: { cascade?: boolean; }): Promise; } declare class Form extends Group { } declare type FieldData = ElementData & { error: string | null; raw: string; typed: FieldValue; checkedValue: any; formatted: string | null; pending: boolean; }; declare class Field extends Element { static FORM_TYPE: string; static FIELD_TYPE_STRING: string; static FIELD_TYPE_NUMBER: string; static FIELD_TYPE_BOOLEAN: string; static FIELD_TYPE_DATE: string; static accept(schema: any): SchemaValidation; static create(schema: FieldSchema, parent?: Element | null): Field; readonly formType: string; readonly type: FieldType; readonly default: any; protected _d: FieldData; constructor(schema: FieldSchema, parent?: Element | null); get pending(): boolean; get formatted(): string; get raw(): any; set raw(value: any); setRaw(value: any): Promise; get value(): any; set value(value: any); setValue(value: any): Promise; setCheckedValue(checkedValue: any): void; get checked(): any; isValid(): boolean; reset(): void; clear(): Promise; validate(): Promise; } declare class CollectionItem extends Group { get index(): number; get formId(): string; } declare type CollectionData = Omit & { schema: CollectionSchema; value: any[] | null; pending: boolean; }; declare class Collection extends Element { static FORM_TYPE: string; static accept(schema: any): SchemaValidation; static create(schema: CollectionSchema, parent?: Element | null): Collection; readonly formType: string; readonly type: 'set'; protected _d: CollectionData; groups: CollectionItem[] | null; constructor(schema: CollectionSchema, parent?: Element | null); get pending(): boolean; get value(): any[]; setValue(value: any[], { from, autoAdd }?: { from?: number; autoAdd?: boolean; }): Promise; shake({ cascade }?: { cascade?: boolean; }): void; isValid(): boolean; reset(): void; clear(): Promise; addGroup(): CollectionItem; removeGroup(itemOrIndex: CollectionItem | number): void; validate({ cascade }?: { cascade?: boolean; }): Promise; } declare type VueFormilyConfig = { plugs: Plugs; elements: any[]; }; interface VueFormilyPlugin { install(config: VueFormilyConfig, ...args: any[]): any; } declare type Localizer = (value: string, props?: Record, data?: Record) => string; declare type ElementInstance = { readonly parent: ElementInstance | null; readonly model: string; props: Record; data: WeakMap, any>; shaked: boolean; readonly options: ElementOptions; readonly validation: Validation; readonly error: string; getProps(path: string, options?: { up?: boolean; }): any; addProps(props: Record, ...args: any[]): void; readonly formId: string; readonly htmlName: string; readonly valid: boolean; getHtmlName(): string; shake(): void; cleanUp(): void; } & { plugs: Plugs; } & Evento; declare type CustomValidationProperty = R extends Record ? { [key in R['name']]: Rule; } : never; declare type CascadeRule = R extends Record ? R['inherit'] extends false ? R : P extends Record ? P['cascade'] extends true ? R & P : R : R : P extends Record ? P['cascade'] extends true ? P : never : never; declare type CustomVariationProperties = UnionToIntersection : CascadeRule>> & Validation; declare type CustomGroupProperty = F extends Record ? { [key in F['formId']]: F['fields'] extends Readonly ? GroupInstance : F['group'] extends Readonly> ? CollectionInstance : F extends FieldSchema ? FieldInstance : never; } : never; declare type CustomGroupProperties, R extends any[] = T['rules']> = UnionToIntersection>; declare type FieldInstance> = Readonly>, R extends Readonly = T['rules']> = { validation: CustomVariationProperties; readonly formType: string; readonly type: FieldType; readonly default: any; readonly pending: boolean; readonly formatted: string; raw: any; setRaw(value: any): Promise; value: FieldValue; setValue(value: any): Promise; setCheckedValue(checkedValue: any): void; readonly checked: any; isValid(): boolean; reset(): void; clear(): Promise; validate(): Promise; } & ElementInstance; declare type GroupInstance> = Readonly>, R extends Readonly = T['rules']> = UnionToIntersection> & { validation: CustomVariationProperties; fields: T['fields']; readonly formType: string; readonly type: 'enum'; readonly pending: boolean; readonly value: Record; setValue(obj: Record): Promise>; shake(options?: { cascade?: boolean; }): void; isValid(): boolean; reset(): void; clear(): Promise; validate(options?: { cascade?: boolean; }): Promise; } & ElementInstance; declare type FormInstance> = Readonly>, R extends Readonly = T['rules']> = UnionToIntersection> & { validation: CustomVariationProperties; readonly formType: string; fields: T['fields']; readonly type: 'enum'; readonly pending: boolean; readonly value: Record; setValue(obj: Record): Promise>; shake(options?: { cascade?: boolean; }): void; isValid(): boolean; reset(): void; clear(): Promise; validate(options?: { cascade?: boolean; }): Promise; } & ElementInstance; declare type CollectionInstance> = Readonly>, R extends Readonly = T['rules']> = { groups: Array>; validation: CustomVariationProperties; readonly formType: string; readonly type: 'set'; readonly pending: boolean; readonly value: any[]; setValue(value: any[], { from, autoAdd }?: { from?: number; autoAdd?: boolean; }): Promise; shake(options?: { cascade?: boolean; }): void; isValid(): boolean; reset(): void; clear(): Promise; addGroup(): CollectionItemInstance; removeGroup(itemOrIndex: CollectionItemInstance | number): void; validate(options?: { cascade?: boolean; }): Promise; } & ElementInstance; declare type CollectionItemInstance> = T['group'] extends Readonly> ? CustomGroupProperties & { readonly index: number; } & GroupInstance : Exclude extends any[] ? Exclude[number] : never; declare type VueFormilyOptions = ElementOptions & { rules?: ValidationRuleSchema[]; alias?: string; }; declare class Formily { options: VueFormilyOptions; $root: any; constructor(options: VueFormilyOptions, $root: any); addForm>(schema: F): FormInstance; removeForm(formId: string): void; getForm(formId: string): F; } declare function defineSchema | ValidationRuleSchema>>(schema: F): F; declare module 'vue/types/vue' { interface Vue { readonly $formily: Formily; forms: Record; } } declare function createFormily(): { install(app: VueConstructor, options?: VueFormilyOptions): void; plug(plugin: VueFormilyPlugin, ...args: any[]): void; register(F: any, ...args: any[]): void; }; declare const VueFormily: { createFormily: typeof createFormily; }; export default VueFormily; export { CascadeRule, Collection, CollectionInstance, CollectionItemInstance, CollectionSchema, CustomGroupProperties, CustomGroupProperty, CustomValidationProperty, CustomVariationProperties, ElementData, ElementInstance, ElementOptions, ElementSchema, ElementsSchemas, EventElement, EventHandler, EventOptions, Evento, Field, FieldInstance, FieldSchema, FieldType, FieldValue, Form, FormInstance, FormSchema, Format, Formily, Group, GroupInstance, GroupSchema, Localizer, Objeto, ReadonlySchema, Rule, RuleSchema, Validation, ValidationOptions, ValidationRuleSchema, Validator, VueFormily, VueFormilyConfig, VueFormilyOptions, VueFormilyPlugin, createFormily, defineSchema };