@dkx/lit-forms-material
TypeScript icon, indicating that this package has built-in type declarations

0.2.5 • Public • Published

@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.

Package Sidebar

Install

npm i @dkx/lit-forms-material

Weekly Downloads

0

Version

0.2.5

License

MIT

Unpacked Size

37.4 kB

Total Files

39

Last publish

Collaborators

  • davidkcz