0.2.5 • Published 4 years ago

@dkx/lit-forms-spectrum v0.2.5

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
4 years ago

@dkx/lit-forms

Lit forms inspired by angular reactive forms.

  • Validation
  • Dynamic fields (arrays)
  • Automatic component updates
  • Material components

Installation

$ npm install --save @dkx/lit-forms

Dependencies:

  • lit >=2.0.0-rc.1
  • rxjs >=6.0.0

Example

Define form:

this.form = defaultFormBuilder.create(this, root => [
    root.control('email', ''),
    root.control('password', ''),
]);

Render form:

<form @submit="${this.handleFormSubmit}">
    <div>
        <label for="email">Email</label>
        <input ${this.form.attach('email')} type="email" required>
    </div>
    <div>
        <label for="password">Password</label>
        <input ${this.form.attach('password')} type="password" required>
    </div>
    <input type="submit">Sign in</input>
</form>

Handle submit:

if (!this.form.validate()) {
    return;
}

console.log(this.form.value);

You can find more examples here.

0.2.5

4 years ago

0.2.4

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago