@flightdev/forms 0.0.2 → 0.0.3
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 +7 -1
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flightdev/forms",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Agnostic full-stack form handling for Flight Framework. Choose your validator: Zod, Yup, Valibot, or custom.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -92,6 +92,12 @@
|
|
|
92
92
|
],
|
|
93
93
|
"author": "Flight Contributors",
|
|
94
94
|
"license": "MIT",
|
|
95
|
+
"homepage": "https://github.com/EliosLT/FlightDev",
|
|
96
|
+
"repository": {
|
|
97
|
+
"url": "https://github.com/EliosLT/FlightDev.git",
|
|
98
|
+
"directory": "packages/forms",
|
|
99
|
+
"type": "git"
|
|
100
|
+
},
|
|
95
101
|
"scripts": {
|
|
96
102
|
"build": "tsup",
|
|
97
103
|
"dev": "tsup --watch",
|