Skip to content

Commit 6050fea

Browse files
feat: solid.js form (#471)
* solid commit -a * fix failing tests and formatting * comments + removed unneeded computed * updated changes * prettierd * chore: add Solid Form to script to be deployed * fix: fix typing of solid's Subscribe data * chore: remove errant createEffect * chore: rename Solid's useForm and useField to createForm and createField * chore: remove old mention of React's memoization * chore: add Solid simple example * chore: add Solid yup example * chore: add Zod Solid example * docs: add initial docs for Solid package --------- Co-authored-by: Corbin Crutchley <git@crutchcorn.dev>
1 parent 1b394a7 commit 6050fea

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+5165
-1868
lines changed

docs/config.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,58 @@
157157
]
158158
}
159159
]
160+
},
161+
{
162+
"framework": "solid",
163+
"menuItems": [
164+
{
165+
"label": "Getting Started",
166+
"children": [
167+
{
168+
"label": "Quick Start",
169+
"to": "framework/solid/quick-start"
170+
}
171+
]
172+
},
173+
{
174+
"label": "API Reference",
175+
"children": [
176+
{
177+
"label": "useForm",
178+
"to": "framework/solid/reference/createForm"
179+
},
180+
{
181+
"label": "useField",
182+
"to": "framework/solid/reference/createField"
183+
},
184+
{
185+
"label": "Field",
186+
"to": "framework/solid/reference/Field"
187+
},
188+
{
189+
"label": "FormApi",
190+
"to": "framework/solid/reference/formApi"
191+
}
192+
]
193+
},
194+
{
195+
"label": "Examples",
196+
"children": [
197+
{
198+
"label": "Simple",
199+
"to": "framework/solid/examples/simple"
200+
},
201+
{
202+
"label": "Yup",
203+
"to": "framework/solid/examples/yup"
204+
},
205+
{
206+
"label": "Zod",
207+
"to": "framework/solid/examples/zod"
208+
}
209+
]
210+
}
211+
]
160212
}
161213
]
162214
}

docs/framework/react/quick-start.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { useForm } from '@tanstack/react-form'
1212

1313
export default function App() {
1414
const form = useForm({
15-
// Memoize your default values to prevent re-renders
1615
defaultValues: {
1716
fullName: '',
1817
},
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
id: quick-start
3+
title: Quick Start
4+
---
5+
6+
The bare minimum to get started with TanStack Form is to create a form and add a field. Keep in mind that this example does not include any validation or error handling... yet.
7+
8+
```tsx
9+
import { createForm } from '@tanstack/solid-form'
10+
11+
function App() {
12+
const form = createForm(() => ({
13+
defaultValues: {
14+
fullName: '',
15+
},
16+
onSubmit: async (values) => {
17+
// Do something with form data
18+
console.log(values)
19+
},
20+
}))
21+
22+
return (
23+
<div>
24+
<h1>Simple Form Example</h1>
25+
<form.Provider>
26+
<form
27+
onSubmit={(e) => {
28+
e.preventDefault()
29+
e.stopPropagation()
30+
void form.handleSubmit()
31+
}}
32+
>
33+
<div>
34+
<form.Field
35+
name="fullName"
36+
children={(field) => (
37+
<input
38+
name={field().name}
39+
value={field().state.value}
40+
onBlur={field().handleBlur}
41+
onInput={(e) => field().handleChange(e.target.value)}
42+
/>
43+
)}
44+
/>
45+
</div>
46+
<button type="submit">Submit</button>
47+
</form>
48+
</form.Provider>
49+
</div>
50+
)
51+
}
52+
```
53+
54+
From here, you'll be ready to explore all of the other features of TanStack Form!
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
id: field
3+
title: Field
4+
---
5+
6+
Please see [/packages/solid-form/src/createField.tsx](https://github.com/TanStack/form/blob/main/packages/solid-form/src/createField.tsx)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
id: createField
3+
title: createField
4+
---
5+
6+
Please see [/packages/solid-form/src/createField.tsx](https://github.com/TanStack/form/blob/main/packages/solid-form/src/createField.tsx)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
id: createForm
3+
title: createForm
4+
---
5+
6+
Please see [/packages/solid-form/src/createForm.tsx](https://github.com/TanStack/form/blob/main/packages/solid-form/src/createForm.tsx)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
id: createFormFactory
3+
title: createFormFactory
4+
---
5+
6+
Please see [/packages/solid-form/src/createFormFactory.ts](https://github.com/TanStack/form/blob/main/packages/solid-form/src/createFormFactory.ts)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
id: fieldApi
3+
title: Field API
4+
---
5+
6+
Please see [/packages/solid-form/src/createField.tsx](https://github.com/TanStack/form/blob/main/packages/solid-form/src/createField.tsx)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
id: formApi
3+
title: Form API
4+
---
5+
6+
Please see [/packages/solid-form/src/createForm.tsx](https://github.com/TanStack/form/blob/main/packages/solid-form/src/createForm.tsx)

docs/framework/vue/quick-start.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ The bare minimum to get started with TanStack Form is to create a form and add a
1111
import { useForm } from '@tanstack/vue-form'
1212
1313
const form = useForm({
14-
// Memoize your default values to prevent re-renders
1514
defaultValues: {
1615
fullName: '',
1716
},

0 commit comments

Comments
 (0)