solid-hook-form 1.4.1 → 1.4.2
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/README.md +20 -30
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
# Solid Hook Form
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[<img width="1171" alt="Screenshot 2025-04-05 at 15 01 47" src="https://github.com/tatsmaki/solid-hook-form/blob/master/assets/demo.png" />](https://tatsmaki.github.io/solid-hook-form)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://tatsmaki.github.io/solid-hook-form/#/quickstart">Get started</a> |
|
|
7
|
+
<a href="https://solid-hook-form.vercel.app/">Playground</a>
|
|
8
|
+
</p>
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
- Embraces native HTML form [validation](https://tatsmaki.github.io/solid-hook-form/#/quickstart?id=apply-validation)
|
|
13
|
+
- [Small size](https://bundlephobia.com/package/solid-hook-form@latest) and no [dependencies](./package.json)
|
|
14
|
+
- TypeScript [support](https://tatsmaki.github.io/solid-hook-form/#/quickstart?id=typescript)
|
|
6
15
|
|
|
7
16
|
### Install
|
|
8
17
|
|
|
@@ -10,42 +19,23 @@
|
|
|
10
19
|
npm install solid-hook-form
|
|
11
20
|
```
|
|
12
21
|
|
|
13
|
-
###
|
|
22
|
+
### Quick start
|
|
14
23
|
|
|
15
|
-
```
|
|
24
|
+
```jsx
|
|
16
25
|
import { useForm } from "solid-hook-form";
|
|
17
26
|
|
|
18
|
-
const
|
|
19
|
-
const { errors,
|
|
27
|
+
const ExampleForm = () => {
|
|
28
|
+
const { errors, register, onSubmit } = useForm({
|
|
20
29
|
defaultValues: {
|
|
21
|
-
|
|
22
|
-
email: "",
|
|
23
|
-
password: "",
|
|
24
|
-
age: 0,
|
|
25
|
-
remember: false,
|
|
30
|
+
name: "",
|
|
26
31
|
},
|
|
27
32
|
});
|
|
28
33
|
|
|
34
|
+
const submitExample = (values) => console.log(values);
|
|
35
|
+
|
|
29
36
|
return (
|
|
30
|
-
<form onSubmit={onSubmit(
|
|
31
|
-
<input
|
|
32
|
-
<input
|
|
33
|
-
{...register("email", {
|
|
34
|
-
required: "Required",
|
|
35
|
-
pattern: {
|
|
36
|
-
value: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
|
|
37
|
-
message: "Invalid email",
|
|
38
|
-
},
|
|
39
|
-
})}
|
|
40
|
-
/>
|
|
41
|
-
<input
|
|
42
|
-
{...register("password", {
|
|
43
|
-
required: "Required",
|
|
44
|
-
minLength: { value: 8, message: "Min 8" },
|
|
45
|
-
})}
|
|
46
|
-
/>
|
|
47
|
-
<input type="number" {...register("age", { min: 18, max: 100 })} />
|
|
48
|
-
<input type="checkbox" {...register("remember", { required: "Required" })} />
|
|
37
|
+
<form onSubmit={onSubmit(submitExample)}>
|
|
38
|
+
<input {...register("name", { minLength: 2, pattern: /[A-Za-z]/ })} />;
|
|
49
39
|
<button type="submit">Submit</button>
|
|
50
40
|
</form>
|
|
51
41
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solid-hook-form",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/main.umd.cjs",
|
|
6
6
|
"module": "./dist/main.js",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"type": "git",
|
|
45
45
|
"url": "https://github.com/tatsmaki/solid-hook-form.git"
|
|
46
46
|
},
|
|
47
|
+
"homepage": "https://tatsmaki.github.io/solid-hook-form",
|
|
47
48
|
"keywords": [
|
|
48
49
|
"solid",
|
|
49
50
|
"hooks",
|