From 157f92babb475b79b9caf6c762b82420e6e026da Mon Sep 17 00:00:00 2001 From: Rizky Djanuar Date: Thu, 4 Jun 2026 09:36:51 +0700 Subject: [PATCH 1/2] fix(Form): use FormState type to support nullable/custom initial state values --- src/runtime/components/Form.vue | 6 +++--- src/runtime/types/form.ts | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/runtime/components/Form.vue b/src/runtime/components/Form.vue index 8ba83d55c4..c8d9713614 100644 --- a/src/runtime/components/Form.vue +++ b/src/runtime/components/Form.vue @@ -2,7 +2,7 @@ import type { VNode } from 'vue' import type { AppConfig } from '@nuxt/schema' import theme from '#build/ui/form' -import type { FormSchema, FormError, FormInputEvents, FormErrorEvent, FormSubmitEvent, FormEvent, Form, FormErrorWithId, InferInput, InferOutput, FormData } from '../types/form' +import type { FormSchema, FormError, FormInputEvents, FormErrorEvent, FormSubmitEvent, FormEvent, Form, FormErrorWithId, InferInput, InferOutput, FormData, FormState } from '../types/form' import type { FormHTMLAttributes } from '../types/html' import type { ComponentConfig } from '../types/tv' @@ -13,13 +13,13 @@ export type FormProps> : never + state?: N extends false ? FormState : never /** * 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: FormState) => Promise | FormError[] /** * The list of input events that trigger the form validation. diff --git a/src/runtime/types/form.ts b/src/runtime/types/form.ts index 4a2a45b533..c5d6b2ca3b 100644 --- a/src/runtime/types/form.ts +++ b/src/runtime/types/form.ts @@ -34,6 +34,10 @@ export type InferOutput = Schema extends StandardSchemaV1 ? StandardSche : Schema extends SuperstructSchema ? O : never +export type FormState = { + [K in keyof InferInput]?: InferInput[K] | unknown +} + export type FormData = T extends true ? InferOutput : InferInput export type FormInputEvents = 'input' | 'blur' | 'change' | 'focus' From 68789b51c0611ae6d9af5bb2dd8179f850c529da Mon Sep 17 00:00:00 2001 From: Rizky Djanuar Date: Thu, 4 Jun 2026 12:16:59 +0700 Subject: [PATCH 2/2] up --- src/runtime/types/form.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/types/form.ts b/src/runtime/types/form.ts index c5d6b2ca3b..44ee8117c1 100644 --- a/src/runtime/types/form.ts +++ b/src/runtime/types/form.ts @@ -35,7 +35,7 @@ export type InferOutput = Schema extends StandardSchemaV1 ? StandardSche : never export type FormState = { - [K in keyof InferInput]?: InferInput[K] | unknown + [K in keyof InferInput]?: any } export type FormData = T extends true ? InferOutput : InferInput