As an experiment, I have built a standard wrapper of the Flatpickr library.
One of my first goals was to publish a package on NPM (first time… so far from perfect) and also to package in a Stimulus way a standard library.
Overall this wrapper doesn’t bring a lot of magic but makes all Flatpickr options available as HTML tags and hooks available in the Controller. Therefore you can directly enable and configure a DateTime picker in your erb/html view with the data-attributes and extend a standard stimulus-flatpickr controller to add some business logic.
A bit of news here, I started this stimulus-flatpickr wrapper project as an experiment. I used it in several of my personal projects and so far it has proven its value from my point of view.
I recently took the time to move it to v1. which I just released on npm …
This latest version brings a few additional features but mostly it is all the test suits that are now in place to make it a battlefield tested product. thanks, @jwald1 for showing me the way.
Here is an example using the range mode of Flatpickr.
the change event is fired for the first and second selection (see console.log)
the close event is fired for the second selection