themesberg / flowbite

Open-source UI component library and front-end development framework based on Tailwind CSS
https://flowbite.com
MIT License
7.31k stars 710 forks source link

Datepicker loading mechanism #780

Closed megagames-me closed 1 week ago

megagames-me commented 5 months ago

Is your feature request related to a problem? Please describe. When integrating the datepicker with flowbite-svelte (and I assume must happen with other wrapper libraries too), because the loader uses the DOMContentLoaded event which doesn't get fired when clicking on normal links in SvelteKit, so rel="external" must be added to the link so DOMContentLoaded can be fired and the datepicker script can execute.

Describe the solution you'd like This would be rather easy to fix. We can keep an event listener for DOMContentLoaded, but fire our own synthetic event that is documented when DOMContentLoaded is detected. If we do this, the user can fire the synthetic event when the page is loaded. This would not be a breaking change because it would still listen for DOMContentLoaded.

Describe alternatives you've considered The script could also set a function in the window that can be called to initialize the library/search for input[datepicker]s when the user calls it.

Additional context If this gets approved, I can fix it for you guys.

megagames-me commented 2 months ago

Hi, can I submit a PR for this?

zoltanszogyenyi commented 1 week ago

Hey @megagames-me,

The datepicker is now a core component of Flowbite so it can be initialized just like any other component:

https://flowbite.com/docs/components/datepicker/index.html#javascript-behaviour

Please check it out and see if this will make your example work.

Cheers, Zoltan

megagames-me commented 1 week ago

Looks great, thanks!