UNPKG

@bitrix24/b24ui-nuxt

Version:

Bitrix24 UI-Kit for developing web applications REST API for NUXT & VUE

56 lines (55 loc) 2.44 kB
import type { FormSchema, FormError, FormInputEvents, FormErrorEvent, FormSubmitEvent, Form } from '../types/form'; export interface FormProps<T extends object> { id?: string | number; /** Schema to validate the form state. Supports Standard Schema objects, Yup, Joi, and Superstructs. */ schema?: FormSchema<T>; /** An object representing the current state of the form. */ state: Partial<T>; /** * Custom validation function to validate the form state. * @param state - The current state of the form. * @returns A promise that resolves to an array of FormError objects, or an array of FormError objects directly. */ validate?: (state: Partial<T>) => Promise<FormError[]> | FormError[]; /** * The list of input events that trigger the form validation. * @defaultValue `['blur', 'change', 'input']` */ validateOn?: FormInputEvents[]; /** Disable all inputs inside the form. */ disabled?: boolean; /** * Delay in milliseconds before validating the form on input events. * @defaultValue `300` */ validateOnInputDelay?: number; /** * If true, schema transformations will be applied to the state on submit. * @defaultValue `true` */ transform?: boolean; class?: any; onSubmit?: ((event: FormSubmitEvent<T>) => void | Promise<void>) | (() => void | Promise<void>); } export interface FormEmits<T extends object> { (e: 'submit', payload: FormSubmitEvent<T>): void; (e: 'error', payload: FormErrorEvent): void; } export interface FormSlots { default(props?: { errors: FormError[]; }): any; } declare const _default: <T extends object>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{ props: __VLS_PrettifyLocal<any & FormProps<T> & Partial<{}>> & (import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps); expose(exposed: import("vue").ShallowUnwrapRef<Form<T>>): void; attrs: any; slots: Readonly<FormSlots> & FormSlots; emit: FormEmits<T>; }>) => import("vue").VNode & { __ctx?: Awaited<typeof __VLS_setup>; }; export default _default; type __VLS_PrettifyLocal<T> = { [K in keyof T]: T[K]; } & {};