@formisch/solid 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,68 @@
1
+ # Formisch for SolidJS
2
+
3
+ Formisch is a schema-based, headless form library for SolidJS. 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-solid)!
4
+
5
+ ## Highlights
6
+
7
+ - Small bundle size starting at 2.5 kB
8
+ - Schema-based validation with Valibot
9
+ - Type safety with autocompletion in editor
10
+ - It's fast – DOM updates are fine-grained
11
+ - Minimal, readable and well thought out API
12
+ - Supports all native HTML form fields
13
+
14
+ ## Example
15
+
16
+ Every form starts with the `createForm` primitive. 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` primitive or the `<Field />` component to connect your inputs.
17
+
18
+ ```tsx
19
+ import { createForm, Field, Form } from '@formisch/solid';
20
+ import * as v from 'valibot';
21
+
22
+ const LoginSchema = v.object({
23
+ email: v.pipe(v.string(), v.email()),
24
+ password: v.pipe(v.string(), v.minLength(8)),
25
+ });
26
+
27
+ export default function LoginPage() {
28
+ const loginForm = createForm({
29
+ schema: LoginSchema,
30
+ });
31
+
32
+ return (
33
+ <Form of={loginForm} onSubmit={(output) => console.log(output)}>
34
+ <Field
35
+ of={loginForm}
36
+ path={['email']}
37
+ render={(field) => (
38
+ <div>
39
+ <input {...field.props} value={field.input} type="email" />
40
+ {field.errors && <div>{field.errors[0]}</div>}
41
+ </div>
42
+ )}
43
+ />
44
+ <Field
45
+ of={loginForm}
46
+ path={['password']}
47
+ render={(field) => (
48
+ <div>
49
+ <input {...field.props} value={field.input} type="password" />
50
+ {field.errors && <div>{field.errors[0]}</div>}
51
+ </div>
52
+ )}
53
+ />
54
+ <button type="submit">Login</button>
55
+ </Form>
56
+ );
57
+ }
58
+ ```
59
+
60
+ In addition, Formisch offers several functions (we call them "methods") that can be used to manipulate the form state. These include `reset`, `setInput`, and `setErrors`. These methods allow you to control the form programmatically.
61
+
62
+ ## Feedback
63
+
64
+ Find a bug or have an idea how to improve the library? Please fill out an [issue](https://github.com/fabian-hiller/formisch/issues/new). Together we can make forms even better!
65
+
66
+ ## License
67
+
68
+ This project is available free of charge and licensed under the [MIT license](https://github.com/fabian-hiller/formisch/blob/main/LICENSE.md).