0.5.6 • Published 10 months ago

solid-formlet v0.5.6

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

solid-formlet

Functional combinators for building reactive forms

Quick start

Install it:

npm i solid-formlet
# or
yarn add solid-formlet
# or
pnpm add solid-formlet

Use it:

import { createForm, Form, Formlet } from 'solid-formlet';

const userFullName = (user: User) =>
  Form.Group(
    "fullname",
    Form.lift(
      (name: string, surname: string) => ({ name, surname }),
      Formlet.netext("name", user.fullname.name),
      Formlet.netext("surname", user.fullname.surname),
    ),
  );

const App = (props: { user: User }) => {
  const [value, element] = createForm(userFullName(props.user));

  createEffect(() => console.log("%cchanged", "color:blue", value()));

  return (
    <form
      onInvalid={() => {
        console.log("%cinvalid", "color:red", value());
      }}
      onSubmit={(ev) => {
        ev.preventDefault();
        console.log("%csubmitted", "color:green", value());
      }}
    >
      {element}
      <button type="submit">Submit</button>
    </form>
  );
};
0.5.6

10 months ago

0.5.5

10 months ago

0.5.4

2 years ago

0.5.3

2 years ago

0.5.2

2 years ago

0.5.1

2 years ago

0.5.0

2 years ago

0.4.0

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago

0.0.0

2 years ago