-
Hi all, I'm writing a UI independent composable form library on top of xstate. The idea is to solve forms for the masses and allow anyone with custom requirements to be able to roll their own functionality where needed. For this reason, almost everything is an actor that can be composed together to make forms. i.e. text(), select(), checkbox(), submit() all create state machines for those form field types. When used like this, any UI library can consume the same xstate-form library and provide state machine functionality. See Codelibrary: https://github.com/jaetask/xstate-form ExampleHere's a quick example of building a form
Currently, these are the only supported fields, I thought this was a good place to stop and get feedback/input. Context
TouchedEach machine knows when it's ErrorsI am going to integrate Yup and populate ValuesAll values are stored here, in a single level, I suspect I'll need some kind of flattening method for getting/setting arrays of items DevelopmentI am really enjoying this project and would love to donate it to the cause, (happy to move into davidkpiano/repo if required). Also, if this grabs anyones attention and you want to get involved, then ping me. Forms have been on my mind since the first day I saw xstate and after a few iterations, I think this is a good route to go down. In time, most of the action & message creators will accept optionable params to configure the machines as required. FormThe main form looks like this.
React example
TextInputShows how any UI library can send the required events at the correct times
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Text fields now have visibility, fields lose focus when hidden (they do not regain it automatically when making visible), you could chain a visible() action for that. |
Beta Was this translation helpful? Give feedback.
-
I haven't use Formik so I can't draw from that. But I do like your idea. I like the idea of a button showing the status of the form, like MUI's Loading Button. I'm building a Radio Button Group myself, but it is very domain-specific: a quiz form that will show in the Radio Button if the selection is correct or not. (falls in your 20% edge case). |
Beta Was this translation helpful? Give feedback.
-
Hi all, I'm closing this discussion as it's being discussed in the discord and directly in the issues tracker Nice one |
Beta Was this translation helpful? Give feedback.
Hi all,
I'm closing this discussion as it's being discussed in the discord and directly in the issues tracker
Nice one