@flightdev/forms 0.0.2 → 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/README.md +12 -12
- package/package.json +107 -101
- package/LICENSE +0 -21
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @flightdev/forms
|
|
2
2
|
|
|
3
3
|
Form handling package for Flight Framework with Zod, Yup, and Valibot validation adapters.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install @
|
|
8
|
+
npm install @flightdev/forms
|
|
9
9
|
|
|
10
10
|
# Install your preferred validator:
|
|
11
11
|
npm install zod # TypeScript-first
|
|
@@ -16,8 +16,8 @@ npm install valibot # Lightweight
|
|
|
16
16
|
## Quick Start
|
|
17
17
|
|
|
18
18
|
```typescript
|
|
19
|
-
import { createForm } from '@
|
|
20
|
-
import { zod } from '@
|
|
19
|
+
import { createForm } from '@flightdev/forms';
|
|
20
|
+
import { zod } from '@flightdev/forms/zod';
|
|
21
21
|
import { z } from 'zod';
|
|
22
22
|
|
|
23
23
|
const contactForm = createForm({
|
|
@@ -37,7 +37,7 @@ const contactForm = createForm({
|
|
|
37
37
|
### Zod
|
|
38
38
|
|
|
39
39
|
```typescript
|
|
40
|
-
import { zod } from '@
|
|
40
|
+
import { zod } from '@flightdev/forms/zod';
|
|
41
41
|
import { z } from 'zod';
|
|
42
42
|
|
|
43
43
|
const validator = zod(z.object({
|
|
@@ -49,7 +49,7 @@ const validator = zod(z.object({
|
|
|
49
49
|
### Yup
|
|
50
50
|
|
|
51
51
|
```typescript
|
|
52
|
-
import { yup } from '@
|
|
52
|
+
import { yup } from '@flightdev/forms/yup';
|
|
53
53
|
import * as y from 'yup';
|
|
54
54
|
|
|
55
55
|
const validator = yup(y.object({
|
|
@@ -61,7 +61,7 @@ const validator = yup(y.object({
|
|
|
61
61
|
### Valibot
|
|
62
62
|
|
|
63
63
|
```typescript
|
|
64
|
-
import { valibot } from '@
|
|
64
|
+
import { valibot } from '@flightdev/forms/valibot';
|
|
65
65
|
import * as v from 'valibot';
|
|
66
66
|
|
|
67
67
|
const validator = valibot(v.object({
|
|
@@ -75,7 +75,7 @@ const validator = valibot(v.object({
|
|
|
75
75
|
### React
|
|
76
76
|
|
|
77
77
|
```tsx
|
|
78
|
-
import { useForm, Form, Field } from '@
|
|
78
|
+
import { useForm, Form, Field } from '@flightdev/forms/react';
|
|
79
79
|
|
|
80
80
|
function ContactPage() {
|
|
81
81
|
const { register, handleSubmit, errors, pending } = useForm(contactForm);
|
|
@@ -98,7 +98,7 @@ function ContactPage() {
|
|
|
98
98
|
|
|
99
99
|
```vue
|
|
100
100
|
<script setup>
|
|
101
|
-
import { useForm } from '@
|
|
101
|
+
import { useForm } from '@flightdev/forms/vue';
|
|
102
102
|
|
|
103
103
|
const { register, handleSubmit, errors, pending } = useForm(contactForm);
|
|
104
104
|
</script>
|
|
@@ -117,7 +117,7 @@ const { register, handleSubmit, errors, pending } = useForm(contactForm);
|
|
|
117
117
|
|
|
118
118
|
```svelte
|
|
119
119
|
<script>
|
|
120
|
-
import { createFormStore } from '@
|
|
120
|
+
import { createFormStore } from '@flightdev/forms/svelte';
|
|
121
121
|
|
|
122
122
|
const { values, errors, pending, register, submit } = createFormStore(contactForm);
|
|
123
123
|
</script>
|
|
@@ -133,7 +133,7 @@ const { register, handleSubmit, errors, pending } = useForm(contactForm);
|
|
|
133
133
|
### Solid
|
|
134
134
|
|
|
135
135
|
```tsx
|
|
136
|
-
import { useForm } from '@
|
|
136
|
+
import { useForm } from '@flightdev/forms/solid';
|
|
137
137
|
import { Show } from 'solid-js';
|
|
138
138
|
|
|
139
139
|
function ContactPage() {
|
|
@@ -186,7 +186,7 @@ export async function POST(request: Request) {
|
|
|
186
186
|
## Creating Custom Validators
|
|
187
187
|
|
|
188
188
|
```typescript
|
|
189
|
-
import type { ValidationAdapter } from '@
|
|
189
|
+
import type { ValidationAdapter } from '@flightdev/forms';
|
|
190
190
|
|
|
191
191
|
export function myValidator<T>(schema: MySchema<T>): ValidationAdapter<unknown, T> {
|
|
192
192
|
return {
|
package/package.json
CHANGED
|
@@ -1,102 +1,108 @@
|
|
|
1
|
-
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
},
|
|
62
|
-
"
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
"
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
"
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
"
|
|
101
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@flightdev/forms",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Agnostic full-stack form handling for Flight Framework. Choose your validator: Zod, Yup, Valibot, or custom.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"import": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"./zod": {
|
|
12
|
+
"types": "./dist/adapters/zod.d.ts",
|
|
13
|
+
"import": "./dist/adapters/zod.js"
|
|
14
|
+
},
|
|
15
|
+
"./yup": {
|
|
16
|
+
"types": "./dist/adapters/yup.d.ts",
|
|
17
|
+
"import": "./dist/adapters/yup.js"
|
|
18
|
+
},
|
|
19
|
+
"./valibot": {
|
|
20
|
+
"types": "./dist/adapters/valibot.d.ts",
|
|
21
|
+
"import": "./dist/adapters/valibot.js"
|
|
22
|
+
},
|
|
23
|
+
"./react": {
|
|
24
|
+
"types": "./dist/frameworks/react.d.ts",
|
|
25
|
+
"import": "./dist/frameworks/react.js"
|
|
26
|
+
},
|
|
27
|
+
"./vue": {
|
|
28
|
+
"types": "./dist/frameworks/vue.d.ts",
|
|
29
|
+
"import": "./dist/frameworks/vue.js"
|
|
30
|
+
},
|
|
31
|
+
"./svelte": {
|
|
32
|
+
"types": "./dist/frameworks/svelte.d.ts",
|
|
33
|
+
"import": "./dist/frameworks/svelte.js"
|
|
34
|
+
},
|
|
35
|
+
"./solid": {
|
|
36
|
+
"types": "./dist/frameworks/solid.d.ts",
|
|
37
|
+
"import": "./dist/frameworks/solid.js"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"main": "./dist/index.js",
|
|
41
|
+
"types": "./dist/index.d.ts",
|
|
42
|
+
"files": [
|
|
43
|
+
"dist"
|
|
44
|
+
],
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "tsup",
|
|
47
|
+
"dev": "tsup --watch",
|
|
48
|
+
"test": "vitest run",
|
|
49
|
+
"test:watch": "vitest",
|
|
50
|
+
"typecheck": "tsc --noEmit"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"zod": "\u003e=3.0.0",
|
|
55
|
+
"yup": "\u003e=1.0.0",
|
|
56
|
+
"valibot": "\u003e=0.30.0",
|
|
57
|
+
"react": "\u003e=18.0.0",
|
|
58
|
+
"vue": "\u003e=3.0.0",
|
|
59
|
+
"svelte": "\u003e=4.0.0",
|
|
60
|
+
"solid-js": "\u003e=1.0.0"
|
|
61
|
+
},
|
|
62
|
+
"peerDependenciesMeta": {
|
|
63
|
+
"zod": {
|
|
64
|
+
"optional": true
|
|
65
|
+
},
|
|
66
|
+
"yup": {
|
|
67
|
+
"optional": true
|
|
68
|
+
},
|
|
69
|
+
"valibot": {
|
|
70
|
+
"optional": true
|
|
71
|
+
},
|
|
72
|
+
"react": {
|
|
73
|
+
"optional": true
|
|
74
|
+
},
|
|
75
|
+
"vue": {
|
|
76
|
+
"optional": true
|
|
77
|
+
},
|
|
78
|
+
"svelte": {
|
|
79
|
+
"optional": true
|
|
80
|
+
},
|
|
81
|
+
"solid-js": {
|
|
82
|
+
"optional": true
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"devDependencies": {
|
|
86
|
+
"@types/node": "^22.0.0",
|
|
87
|
+
"tsup": "^8.0.0",
|
|
88
|
+
"typescript": "^5.7.0",
|
|
89
|
+
"vitest": "^2.0.0"
|
|
90
|
+
},
|
|
91
|
+
"keywords": [
|
|
92
|
+
"flight",
|
|
93
|
+
"forms",
|
|
94
|
+
"validation",
|
|
95
|
+
"zod",
|
|
96
|
+
"yup",
|
|
97
|
+
"valibot",
|
|
98
|
+
"progressive-enhancement"
|
|
99
|
+
],
|
|
100
|
+
"author": "Flight Contributors",
|
|
101
|
+
"license": "MIT",
|
|
102
|
+
"homepage": "https://github.com/EliosLT/FlightDev",
|
|
103
|
+
"repository": {
|
|
104
|
+
"url": "https://github.com/EliosLT/FlightDev.git",
|
|
105
|
+
"directory": "packages/forms",
|
|
106
|
+
"type": "git"
|
|
107
|
+
}
|
|
102
108
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024-2026 Flight Contributors
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|