Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

svelte-formula

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svelte-formula

Reactive Forms for Svelte

  • 0.7.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
113
decreased by-25.17%
Maintainers
1
Weekly downloads
 
Created
Source

Svelte Formula

The Svelte Formula Logo

svelte-formula

Formula is a library for Svelte with features for creating Zero Configuration reactive forms and fully data-driven applications.

Out-of-the box it's designed to work with HTML5 forms. Configuring your forms validation is as easy as setting attributes, and doesn't get in the way of things like Accessibility.

Install Instructions

npm i svelte-formula

Usage

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

  <script>
    import { formula } from 'svelte-formula'
    const { form, formIsValid, validity, touched } = formula();

    // Here we can provide a default value
    export let projectname = '';

    // You can calculate values for valid UI states
    $: projectNameInvalid = $touched?.projectName && validity?.projectName?.invalid
  </script>

  <div use:form>
    <label for="project-name">Project Name</label>
    <input type="text" name="projectName" required minlength="8" class:error={projectNameInvalid} bind:value={projectName} />
    <span hidden={!projectNameInvalid}>{validity?.projectName?.message}</span>
    <button disabled={!$formIsValid}>Update Project Name</button>
  </div>

Visit the documentation for more details API instructions.

Roadmap

Field Type Support

  • Support Basic Input fields (text, number, password, email, url) as text values
    • Support multiple named fields with unique id attributes, with an array of results sorted by ID alphabetically
    • Return correct value type for fields (return number as Number value)
  • Support Select Fields
    • Support Multiple Select Fields
  • Support Radio Fields
  • Support Checkbox Fields
    • Support Multiple Checkbox Fields
  • Support the Range input
  • Support the Color input
  • Support the Date / Time inputs
  • Support the File input

Validation

  • Custom field-level validation via formula options
  • Custom form-level validation via formula options
  • Support for localised messages for validation errors

Other Items

  • Add Unit Tests - IN PROGRESS
  • Add full documentation - IN PROGRESS

Icon made by Eucalyp from flaticon.com

Keywords

FAQs

Package last updated on 19 Feb 2021

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc