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

0.1.3 • 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.
  • 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);

Readme

Keywords

Package Sidebar

Install

npm i @formsignals/form-core

Weekly Downloads

3

Version

0.1.3

License

MIT

Unpacked Size

777 kB

Total Files

64

Last publish

Collaborators

  • formsignals