Socket
Socket
Sign inDemoInstall

svelte-formula

Package Overview
Dependencies
21
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    svelte-formula

Reactive Forms for Svelte


Version published
Maintainers
1
Created

Changelog

Source

[0.10.0] - 2021-03-12

Added

  • New data-formula-bind attribute for elements - allows the event bindings to be customised. If used the default bindings are not made (so they must be also passed) - more than one event type can be bound to by using the pipe (|) separator.

    <!-- Use other browser event types to bind to -->
    <input type='text' name='myValue' data-formula-bind='mouseover' />
    <!-- Bind to more than one event type, such as including the original event  -->
    <input type='text' name='myValue' data-formula-bind='mouseover|keyup' />
    <!-- You can also emit your own custom events via elements inside custom components -->
    <input type='number' name='myValue' data-formula-bind='customEvent' bind:this='{el}' />
    <button on:click|preventDefault='{()' => el.dispatchEvent(new Event('customEvent'))}>Click Me</button>
    
  • options.preChanges method that is called when a change has been detected, but before any values are read or stores updated

  • options.postChanges method that is called after all changes have been made to the stores, with the most recent form values (this is functionally the same as formValues.subscribe(values => {})))

Fixed

  • options.formValidators now correctly update isFormValid after other validity checks have been carried out instead of before
  • <input type="hidden"> fields now supported, both single and multi-value. Formula can only set the value of this field via default values and cannot set the value ( but for example it can be changed in something like options.preChanges) - hidden fields have no events, so these are a special case where the values are read with each update.
  • Input types number, date, time and week now bind to both keyup and change handlers to handle both valid input cases on these elements

Changed

  • Existing attribute data-beaker-key has been renamed to data-formula-name - this allows a custom name to be used instead of the <input name="..."> value

  • Existing attributes data-beaker-form and data-beaker-row now correctly data-formula-form and data-formula-row

  • All event handlers wrapped in a setTimeout(()=> {}, 0) to defer an update until after DOM tick, this allows elements to ensure value changes have completed before reading

Readme

Source

Formula + Beaker Δ→

Reactive Forms for Svelte

The Svelte Formula Logo

svelte-formula

svelte-formula is a Library for use with Svelte that super-charges your ability to create rich data-driven for applications.

Install Instructions

npm i svelte-formula

Usage

All you need is an element container with the Svelte use directive and form input fields with their name property set.

Visit the documentation for more details API instructions.

Formula

Demo

The Svelte Formula Logo

Formula is a library for creating Zero Configuration reactive form components, and fully data-driven applications.

Zero-Configuration means you need nothing more than a well-defined HTML5 form element to have fully reactive stores of data and form states.

Accessing the input requires only setting the name property, and for validation providing attributes like require or minlength. Formula supports single and multi-value inputs across all widely supported HTML inputs and extends them with checkbox groups and radio groups, and composite fields of values like text or number.

Formula creates a form instance that contains Svelte stores that contain value and validation information, and some additional lifecycle methods that allow your to dynamically add and remove customisations, and reset or destroy the form. It also attempts to apply ARIA attributes to help with accessibility.

Extending Formula

Formula also supports a bunch of powerful options that provide additional validation, enrichment and custom messages.

For example with the enrich option and enrichment store you can provide functions that calculate additional computed values based on user input - for example calculating a password strength, or the length of text a user has entered. These are useful.

Validations can be provided at the form and field level, and integrate with in-built browser validations to provide native messages, which can be customised for localisation.

Beaker

Demo

The Svelte Formula Logo

Beaker take Formula and adds another layer for working with collections of data.

Using row-based input you can create full form instances per row that are also fully reactive and feed into Beaker's collection store.

Beaker also provides methods for setting, adding and removing items from the in-built stores, when can be used with Svelte's {#each}{/each} blocks to create a re-usable template in the component

With this you can build applications such as multi-row editable tables or lists. See the documentation for more details and examples.

Keywords

FAQs

Last updated on 12 Mar 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc