astro-reactive-form/packages/astro-reactive-form
2022-10-06 16:10:49 +02:00
..
components feat: Form control placeholder attribute (#48) 2022-10-05 18:30:47 +02:00
core fix: linting errors (#54) 2022-10-06 16:10:49 +02:00
test chore: update project command scripts 2022-10-04 14:30:00 +02:00
.editorconfig chore: clean up monorepo 2022-10-01 15:44:39 +02:00
.eslintignore chore: clean up monorepo 2022-10-01 15:44:39 +02:00
.eslintrc.cjs chore: clean up monorepo 2022-10-01 15:44:39 +02:00
.prettierrc.cjs devops: set up package linting (#53) 2022-10-06 16:01:23 +02:00
Form.astro feat: implement form submit button limit (#47) 2022-10-06 16:07:02 +02:00
index.ts fix: removed default export 2022-10-03 07:56:52 +02:00
package.json Chore project clean up (#42) 2022-10-04 19:18:17 +02:00
README.md Chore project clean up (#42) 2022-10-04 19:18:17 +02:00
RELEASE.md Chore project clean up (#42) 2022-10-04 19:18:17 +02:00
tsconfig.json move astro-reactive-form to separate workspace 2022-10-01 14:18:16 +02:00

package-form-cover

version license downloads dependencies

Astro Reactive Form 🔥

Generate a dynamic form based on your data, and modify programatically.

The Reactive Form component for Astro 🔥

All contributions are welcome.

Installation

In your Astro project:

npm i astro-reactive-form

Usage

Use in an Astro page:

---
import { FormControl, FormGroup } from "astro-reactive-form/core";
import Form from "astro-reactive-form";

// create a form group
const form = new FormGroup([
  {
    name: "username",
    label: "Username",
  },
  {
    name: "password",
    label: "Password",
    type: "password",
  },
]);

// set the name optionally
form.name = "Simple Form";

// you can insert a control at any point
form.controls.push(
  new FormControl({
    type: "checkbox",
    name: "is-awesome",
    label: "is Awesome?",
    labelPosition: "right",
  })
);

// you can get a FormControl object
const userNameControl = form.get("username");

// you can set values dynamically
userNameControl?.setValue("RAMOOOON");
form.get('is-awesome')?.setValue("checked");
---

<!-- the formGroups attribute takes an array of FormGroup-->
<Form formGroups={[form]} />

Screenshots

Result of example above:

Screen Shot 2022-10-01 at 7 29 00 PM

Example of multiple form groups:

Screen Shot 2022-09-27 at 10 44 03 PM

Future Plans

Currently this only supports very basic form creation, but the goal of the project is ambitious:

  1. Validator library for common validation scenarios
    1. Client-side validation
    2. Server-side validation
    3. validation hooks - onFocus, onBlur, onSubmit
  2. Themes - unstyled, light mode, dark mode, compact, large
  3. FormGroup class
    1. statusChanges - observable that emits the form status when it changes
    2. valueChanges - observable that emits the values of all controls when they change
  4. FormControl class
    1. statusChanges - observable that emits the control status when it changes
    2. valueChanges - observable that emits the control value when it changes
    3. value - property that reflects the control value
  5. Documentation website

... and so much more

All contributions are welcome. Let's make the fastest web form component powered by Astro