armanbilge / calico

Pure, reactive UI library for Scala.js
https://armanbilge.github.io/calico
Apache License 2.0
116 stars 9 forks source link

Feature request: typed inputs #399

Open kubukoz opened 1 month ago

kubukoz commented 1 month ago

It would be amazing to have typed events for inputs. This is the tweet.

like, maybe type := "file" can carry a singleton type of "file" and this can somehow be used to derive a more specific type in onChange, like in typescript?

faresbouzayen commented 1 month ago

Hey @kubukoz!

Here’s what I’m thinking:

Type Mapping: Create a mapping system that associates input types with their respective TypeScript types, allowing for seamless type inference in onChange events.

Documentation Enhancements: I could also add examples in the documentation to demonstrate how to utilize this feature effectively, making it easier for developers to adopt.

Let me know if you’d like to discuss this further or if there are any specific requirements you have in mind!

kubukoz commented 1 month ago

100% a bot response.

faresbouzayen commented 1 month ago

Haha, I can see why it feels like a bot response! But honestly, what specific input types do you think we should focus on first?

armanbilge commented 1 month ago

I think getting this to work with the generic syntax type := "file" may be more challenging ... but maybe we could add a custom builder to the DSL e.g. input["file"](...). I think we'd also need something like the changes I suggested https://github.com/armanbilge/calico/issues/180, where attributes and events can be typed specifically according to the element type. This will help us better support Web Components.