Skip to content

Commit

Permalink
fix: correct a whole bunch of bad refs/types
Browse files Browse the repository at this point in the history
  • Loading branch information
43081j committed Jan 10, 2025
1 parent 3bd7f33 commit 5b87ca5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/svelte-form/src/Field.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import type { Snippet } from 'svelte';
// TODO (43081j): somehow remove this circular reference
import { createField } from './createField.svelte.js';
import type { FieldOptions } from '@tanstack/form-core';
type Props = {
children: Snippet<[
Expand All @@ -23,8 +24,7 @@
TData
>
]>
[key: string]: unknown;
} & FieldApiOptions<
} & FieldOptions<
TParentData,
TName,
TFieldValidator,
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte-form/src/createField.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,5 @@ export function createField<
api.update(opts())
})

return () => extendedApi
return extendedApi
}
12 changes: 8 additions & 4 deletions packages/svelte-form/tests/simple.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const form = createForm(() => ({

<form.Field
name="firstName"
form={form}
validators={{
onChange: ({ value }) =>
value.length < 3 ? 'Not long enough' : undefined,
Expand All @@ -65,6 +66,7 @@ const form = createForm(() => ({
</form.Field>
<form.Field
name="lastName"
form={form}
validators={{
onChange: ({ value }) =>
value.length < 3 ? 'Not long enough' : undefined,
Expand All @@ -89,6 +91,7 @@ const form = createForm(() => ({
</form.Field>
<form.Field
name="color"
form={form}
>
{#snippet children(field)}
<div>
Expand All @@ -112,6 +115,7 @@ const form = createForm(() => ({
</form.Field>
<form.Field
name="employed"
form={form}
>
{#snippet children(field)}
<div>
Expand Down Expand Up @@ -157,19 +161,19 @@ const form = createForm(() => ({
<div>
<button
type="submit"
disabled={form.api.state.isSubmitting}
disabled={form.state.isSubmitting}
>
{form.api.state.isSubmitting ? html` Submitting` : 'Submit'}
{form.state.isSubmitting ? html` Submitting` : 'Submit'}
</button>
<button
type="button"
id="reset"
on:click={() => {
form.api.reset()
form.reset()
}}
>
Reset
</button>
</div>
</form>
<pre>{JSON.stringify(form.api.state, null, 2)}</pre>
<pre>{JSON.stringify(form.state, null, 2)}</pre>

0 comments on commit 5b87ca5

Please sign in to comment.