Skip to content

Conversation

rdjanuar
Copy link
Contributor

@rdjanuar rdjanuar commented Aug 15, 2025

πŸ”— Linked issue

Resolves #3876

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@rdjanuar rdjanuar marked this pull request as draft August 15, 2025 08:19
Copy link

pkg-pr-new bot commented Aug 15, 2025

npm i https://pkg.pr.new/@nuxt/ui@4755

commit: 1c74a41

@rdjanuar
Copy link
Contributor Author

rdjanuar commented Aug 15, 2025

This PR still mising some task, If there are any additions, they can be added here.:

  • Create Documentation
  • Integrate Unit test
  • generate state base on schema

Maybe i need help to verify my typescript, cc @sandros94

Comment on lines -94 to -95
// @ts-expect-error - 'target' does not exist in type 'EventInit'
const event = new Event('change', { target: { value } })
Copy link
Contributor Author

@rdjanuar rdjanuar Aug 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we cannot modify target because is read-only

https://developer.mozilla.org/en-US/docs/Web/API/Event/target

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@romhml haven't we discussed this before? It does ring a bell in my head πŸ€”

@sandros94
Copy link
Member

This PR still mising some of task, If there are any additions, they can be added here.:

  • Create Documentation
  • Integrate Unit test

Maybe i need help to verify my typescript, cc @sandros94

Will happily take a look in a couple of days, as I'm on vacation and with limited connectivity

@rdjanuar rdjanuar changed the title feat(form): Introduce useForm composable feat(form): Introduce useForm and useFormControl composable Aug 16, 2025
@rdjanuar
Copy link
Contributor Author

rdjanuar commented Aug 19, 2025

I’ve finished handling state generation based on schema.

here how i implement it:
Zod: needs special handling since we have to parse every value. Luckily there’s already a solution β€” I copied the init function from zod-empty

Valibot: users can use the built-in getDefaults()

Yup: supports .getDefault() on schema, so I handle this internally.

Superstruct: no built-in way for defaults, so users will need to provide their own defaultValues.

@rdjanuar rdjanuar marked this pull request as ready for review August 19, 2025 17:29
@sandros94
Copy link
Member

thanks @rdjanuar, I've been following some of the commits, but unfortunately I got buried with work since I came back from vacation. Will hopefully take a look at least at types during the weekend.

Just a small note: while I completely agree on a useForm composable, I'm still not fully convinced to have a built-in parser for validation schemas, because they would all require different adapters and as you noticed not all of them do provide utils for even defaults. But this is more of a personal opinion

@rdjanuar
Copy link
Contributor Author

Thank you @sandros94 for taking the time to review my useForm implementation. you right its' require a lot effort to handle parsing on each library schema but my current implementation is just improve DX especially on zod because every time i interact with Form component i should add every single field on state and i'ts taking a lot of time

@benjamincanac benjamincanac added the v3 #1289 label Aug 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v3 #1289
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Form] Composable to generate state based on a standard schema
3 participants