iway1 / react-ts-form

https://react-ts-form.com
MIT License
2.01k stars 35 forks source link

enable custom layouts and maybe inter-field conditional display #66

Closed scamden closed 1 year ago

scamden commented 1 year ago

@iway1 This turned out to be pretty easy to do. It's typed properly within the child component. I think a relatively easy follow on to this would be to pass the form values to this child to enable cross field conditional display / disabling etc ala https://github.com/iway1/react-ts-form/issues/34. (Maybe something like useFormContext within the ChildFormComponent could already accomplish this? but would be nice for it to be a bit better typed. Love to hear your thoughts on that)

I considered also passing all the renderedFieldNodes as children to the CustomChildComponent to allow this to work as just a simple body wrapper but i think Object.values(renderedFields) is pretty simple to do if someone really wants that use case. wdyt?

Closes https://github.com/iway1/react-ts-form/issues/54

cc: @gpeal @danielchiu

scamden commented 1 year ago

@iway1 any word here?

scamden commented 1 year ago

@iway1 fyi i would love to collaborate here but after a week of no response i went ahead and published on my fork under the package name zod-form (which fwiw i think is a really great name for this). I'd be more than happy to contribute and help if you're open to it. Maybe you'd be open to making me a maintainer on the project if you don't always have time to respond? Super appreciative of all the work you've done here and would love to combine efforts.

iway1 commented 1 year ago

Hey thanks for this! Sorry for the ultra slow response, I've been busy and have been off the grid temporarily. And thank you for the multiple PRs.

I think this is pretty slick, hadn't thought of that solution. Pretty sure this solves the layout problem more elegantly than I was going to lol.

I'm honestly not the biggest fan of APIs that pass a function as children generally, but in this case it solves a pretty big issue with the library in a easy-enough way. So yeah, pretty sweet! 🙏

Would love to collab on this

scamden commented 1 year ago

Hey thanks for this! Sorry for the ultra slow response, I've been busy and have been off the grid temporarily.

no problem! totally get it. what did you think about making me a maintainer to spread the load? (totally understand if that feels weird barely knowing me, maybe we can see if the collab continues to go well)

I'm honestly not the biggest fan of APIs that pass a function as children generally

feel 100% the same haha.