0.0.12 • Published 6 months ago

@doboid/form v0.0.12

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

What is @doboid/form?

doboid form is a TINY, zero dependencies*, TYPE-SAFE form state management library for react.

Example

function SimpleForm() {
  const { Fields, ...dorm } = useForm({
    defaultValues: {
      email: '',
      age: 0,
    },
    validators: z.object({
      email: z.string().email().max(11),
      age: z.number().max(3),
    }),
  });

  return (
    <form onSubmit={dorm.onSubmit((values) => console.log('success', values))}>
      <Fields.Email
        children={(field) => (
          <div>
            <input {...field.attr} type="email" />
            {field.errors.map((e) => (<div key={e}>{e}</div>))}
          </div>
        )}
      />

      <Fields.Age
        children={(field) => (
          <div>
            <input {...field.attr} type="number" />
            {field.errors.map((e) => (<div key={e}>{e}</div>))}
          </div>
        )}
      />

      <button type="submit">submit</button>
      <button type="button" onClick={dorm.reset}>reset</button>
    </form>
  );
}
0.0.12

6 months ago

0.0.11

6 months ago

0.0.10

6 months ago

0.0.9

6 months ago

0.0.8

6 months ago

0.0.7

6 months ago

0.0.6

6 months ago

0.0.5

6 months ago

0.0.4

6 months ago

0.0.3

7 months ago

0.0.2

7 months ago

0.0.1

7 months ago