Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Svelte 5 support #304

Open
calvo-jp opened this issue Oct 22, 2024 · 5 comments
Open

Svelte 5 support #304

calvo-jp opened this issue Oct 22, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@calvo-jp
Copy link
Contributor

Tho svelte 5 is backwards compatible, it would be nice if we can have a runes version of this library. I'm a huge fan. Thank you for all the effort you've put in in this lib

@calvo-jp calvo-jp added the enhancement New feature or request label Oct 22, 2024
@pablo-abc
Copy link
Owner

Thanks for using this library! I've sadly not used Svelte for the past year or so :( been working with Vue so I haven't looked that much into how runes are used. Specially on libraries since I understand they only work on .svelte.js files?

Felte heavily relies on stores to handle state internally (even the adapters for other frameworks use observables internally)

Do you have an idea of how you'd expect a runes API to look like for Felte?

@calvo-jp
Copy link
Contributor Author

planning to explore the codebase sometime this week. But what I currently have in mind is to replace stores with runes to align the api more to svelte 5. eg. below

<script>
let schema = $derived(z.object({ ... }));

let form = createForm({ 
  get extend() {
    return validator({schema})
  }
}) // or maybe a function that returns a config
<script>  

<form use:form.action>
  <div>
    <input type="email" name="email" />
    {#if form.errors.email?.length}
      <div>{form.errors.email[0]}</div>
    {/if}
  </div>
  
  <button type="submit" disabled={form.isSubmitting}>Submit</button>
</form>

@paradoxe
Copy link

Actually, the package depends on peer svelte@"^3.31.0 || ^4.0.0" which make it unusable with svelte 5. Bumping the svelte peer versions to include v5 will be much appreciated.
Thanks

@calvo-jp
Copy link
Contributor Author

Opened a PR to add ^5.0.0 to peer dependencies. Thanks!

@pablo-abc
Copy link
Owner

pablo-abc commented Oct 29, 2024

@calvo-jp I've merged and published your PR. I've checked the new docs and I see even <slots> are now replaced by snippets so reporter-svelte will eventually need an update as well.


@paradoxe the internals of Felte are quite framework agnostic and accepting runes as parameters would require mayor framework specific code (and the config object has never been anticipated to be reactive).

For the returned stores I could imagine a wrapper that creates runes for each data store, subscribes to the stores we use internally and updates the values of said runes. I'd imagine that would mean no more destructuring on the returned object to maintain reactivity, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants