@formsignals/form-core
TypeScript icon, indicating that this package has built-in type declarations

0.3.1 • Public • Published

Signal Form Banner

form-core-version form-core-bundle

The core library for managing forms with Preact Signals.

Features

  • TypeScript - Written in TypeScript with full type support for optimal DX.
  • Reactivity - Reactivity without abstractions thanks to Preact Signals.
  • Validation - Built-in validation support, including adapters for validation schema libraries.
  • Transformations - Transform values for the specific needs of your input fields.
  • Field Groups - Group fields together to manage parts of a form independently.
  • Async Data - Easily manage async initialisation, validation and submission.
  • Arrays + Dynamic Objects - Utilize arrays and dynamic objects within your forms.

Install

npm install @formsignals/form-core

If you have not installed signals, you will need to install it as well:

npm install @preact/signals-core

Quickstart

Create a new form instance:

const form = new FormLogic({
  defaultValues: {
    name: '',
    email: '',
  },
});

Then get a field instance from the form and configure it:

const nameField = form.getOrCreateField('name', {
  validate: (value) => {
    if (!value) {
      return 'Name is required';
    }
  },
});

Now you can interact with the field:

nameField.handleChange('John Smith');

You can also access the underlying signal directly:

const nameLength = computed(() => nameField.value.length);

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i @formsignals/form-core

      Weekly Downloads

      197

      Version

      0.3.1

      License

      MIT

      Unpacked Size

      1.01 MB

      Total Files

      71

      Last publish

      Collaborators

      • formsignals