vscode-elements / elements

Web component library for developing Visual Studio Code extensions
https://vscode-elements.github.io
MIT License
156 stars 27 forks source link

Validation of form elements #105

Closed mikeburgh closed 10 months ago

mikeburgh commented 1 year ago

Looking at ways to add validation to the various form elements.. Wondering if you have come up with anything ?

Best I have got so far, is using https://www.npmjs.com/package/lite-form#examples but haven't gone to the lengths yet of styling the inputs on error states etc. so before I started going down that path wanted to check if you had recommendations for a better approach.

bendera commented 1 year ago

I'm working on implementing the ElementInternals API. That means you will able to use components as the native form controls: https://developer.mozilla.org/en-US/docs/Learn/Forms/Form_validation

The vast majority of work is done. I'm writing tests and finalizing the API. You can install the pre-release version: npm i @vsc-elements/elements@next It isn't up-to-date I will publish a new version as soon as possible. Or you can build it yourself from source using the rel-1.0.0 branch.

bendera commented 1 year ago

Honestly, I am also a bit clueless. Formik seems pretty good, although I never used it. I will create PoC to test how compatible my form components are with Formik (and lite-form).

mikeburgh commented 1 year ago

I see the PR for the ElementInternals, that will work great, and adds the classes to handle styling!

Thanks!