From 5aea8660577113a60af2393ede574f716818470c Mon Sep 17 00:00:00 2001 From: Romain Hamel Date: Mon, 14 Apr 2025 19:50:27 +0200 Subject: [PATCH] fix(Form): handle schema output types --- src/runtime/components/Form.vue | 50 ++++++++++++++++----------------- src/runtime/types/form.ts | 10 +++---- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/runtime/components/Form.vue b/src/runtime/components/Form.vue index ffb6ada2..1ba25abd 100644 --- a/src/runtime/components/Form.vue +++ b/src/runtime/components/Form.vue @@ -7,18 +7,18 @@ import type { ComponentConfig } from '../types/utils' type FormConfig = ComponentConfig -export interface FormProps { +export interface FormProps { id?: string | number /** Schema to validate the form state. Supports Standard Schema objects, Yup, Joi, and Superstructs. */ - schema?: FormSchema + schema?: FormSchema /** An object representing the current state of the form. */ - state: Partial + state: Partial | O /** * 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) => Promise | FormError[] + validate?: (state: Partial | O) => Promise | FormError[] /** * The list of input events that trigger the form validation. * @defaultValue `['blur', 'change', 'input']` @@ -43,11 +43,11 @@ export interface FormProps { */ loadingAuto?: boolean class?: any - onSubmit?: ((event: FormSubmitEvent) => void | Promise) | (() => void | Promise) + onSubmit?: ((event: FormSubmitEvent) => void | Promise) | (() => void | Promise) } -export interface FormEmits { - (e: 'submit', payload: FormSubmitEvent): void +export interface FormEmits { + (e: 'submit', payload: FormSubmitEvent): void (e: 'error', payload: FormErrorEvent): void } @@ -56,7 +56,7 @@ export interface FormSlots { } - diff --git a/src/runtime/types/form.ts b/src/runtime/types/form.ts index 351b6df6..56cda23f 100644 --- a/src/runtime/types/form.ts +++ b/src/runtime/types/form.ts @@ -21,11 +21,11 @@ export interface Form { blurredFields: DeepReadonly> } -export type FormSchema = - | YupObjectSchema - | JoiSchema - | SuperstructSchema - | StandardSchemaV1 +export type FormSchema = + | YupObjectSchema + | JoiSchema + | SuperstructSchema + | StandardSchemaV1 export type FormInputEvents = 'input' | 'blur' | 'change' | 'focus'