@formisch/react 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) Fabian Hiller
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,82 @@
1
+ # Formisch for React
2
+
3
+ Formisch is a schema-based, headless form library for React. It manages form state and validation. It is type-safe, fast by default and its bundle size is small due to its modular design. Try it out in our [playground](https://stackblitz.com/edit/formisch-playground-react)!
4
+
5
+ Formisch is also available for [Preact][formisch-preact], [Qwik][formisch-qwik], [SolidJS][formisch-solid], [Svelte][formisch-svelte] and [Vue][formisch-vue].
6
+
7
+ ## Highlights
8
+
9
+ - Small bundle size starting at 2.5 kB
10
+ - Schema-based validation with Valibot
11
+ - Type safety with autocompletion in editor
12
+ - It's fast – DOM updates are fine-grained
13
+ - Minimal, readable and well thought out API
14
+ - Supports all native HTML form fields
15
+
16
+ ## Example
17
+
18
+ Every form starts with the `useForm` hook. It initializes your form's store based on the provided Valibot schema and infers its types. Next, wrap your form in the `<Form />` component. It's a thin layer around the native `<form />` element that handles form validation and submission. Then, you can access the state of a field with the `useField` hook or the `<Field />` component to connect your inputs.
19
+
20
+ ```tsx
21
+ import { Field, Form, useForm } from '@formisch/react';
22
+ import * as v from 'valibot';
23
+
24
+ const LoginSchema = v.object({
25
+ email: v.pipe(v.string(), v.email()),
26
+ password: v.pipe(v.string(), v.minLength(8)),
27
+ });
28
+
29
+ export default function LoginPage() {
30
+ const loginForm = useForm({
31
+ schema: LoginSchema,
32
+ });
33
+
34
+ return (
35
+ <Form of={loginForm} onSubmit={(output) => console.log(output)}>
36
+ <Field of={loginForm} path={['email']}>
37
+ {(field) => (
38
+ <div>
39
+ <input {...field.props} value={field.input} type="email" />
40
+ {field.errors && <div>{field.errors[0]}</div>}
41
+ </div>
42
+ )}
43
+ </Field>
44
+ <Field of={loginForm} path={['password']}>
45
+ {(field) => (
46
+ <div>
47
+ <input {...field.props} value={field.input} type="password" />
48
+ {field.errors && <div>{field.errors[0]}</div>}
49
+ </div>
50
+ )}
51
+ </Field>
52
+ <button type="submit">Login</button>
53
+ </Form>
54
+ );
55
+ }
56
+ ```
57
+
58
+ In addition, Formisch offers several functions (we call them "methods") that can be used to read and manipulate the form state. These include `focus`, `getErrors`, `getAllErrors`, `getInput`, `insert`, `move`, `remove`, `replace`, `reset`, `setErrors`, `setInput`, `submit`, `swap` and `validate`. These methods allow you to control the form programmatically.
59
+
60
+ ## Comparison
61
+
62
+ What makes Formisch unique is its framework-agnostic core, which is fully native to the framework you are using. It works by inserting framework-specific reactivity blocks when the core package is built. The result is a small bundle size and native performance for any UI update. This feature, along with a few others, distinguishes Formisch from other form libraries. My vision for Formisch is to create a framework-agnostic platform similar to [Vite](https://vite.dev/), but for forms.
63
+
64
+ ## Partners
65
+
66
+ Thanks to our partners who support the development! [Join them](https://github.com/sponsors/fabian-hiller) and contribute to the sustainability of open source software!
67
+
68
+ ![Partners of Formisch](https://github.com/open-circle/formisch/blob/main/partners.webp?raw=true)
69
+
70
+ ## Feedback
71
+
72
+ Find a bug or have an idea how to improve the library? Please fill out an [issue](https://github.com/open-circle/formisch/issues/new). Together we can make forms even better!
73
+
74
+ ## License
75
+
76
+ This project is available free of charge and licensed under the [MIT license](https://github.com/open-circle/formisch/blob/main/LICENSE.md).
77
+
78
+ [formisch-preact]: https://github.com/open-circle/formisch/tree/main/frameworks/preact
79
+ [formisch-qwik]: https://github.com/open-circle/formisch/tree/main/frameworks/qwik
80
+ [formisch-solid]: https://github.com/open-circle/formisch/tree/main/frameworks/solid
81
+ [formisch-svelte]: https://github.com/open-circle/formisch/tree/main/frameworks/svelte
82
+ [formisch-vue]: https://github.com/open-circle/formisch/tree/main/frameworks/vue