-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from x0k/schema-analysis
SvelteKit integration
- Loading branch information
Showing
109 changed files
with
4,679 additions
and
823 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json", | ||
"changelog": [ | ||
"@changesets/changelog-github", | ||
"@svitejs/changesets-changelog-github-compact", | ||
{ | ||
"repo": "x0k/svelte-jsonschema-form" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@sjsf/form": minor | ||
--- | ||
|
||
Add `parent` property to the `SchemaTraverserContext` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"playground": minor | ||
--- | ||
|
||
Add entries dumper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@sjsf/form": minor | ||
--- | ||
|
||
Add additional property key validator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@sjsf/ajv8-validator": patch | ||
--- | ||
|
||
Improve error path inference for `propertyNames` error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"docs": minor | ||
--- | ||
|
||
Add multiple forms guide |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"docs": minor | ||
--- | ||
|
||
Add SvelteKit integration page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,31 @@ | ||
import type { ErrorObject } from "ajv"; | ||
import { useForm, type FormAPI, type UseFormOptions } from "@sjsf/form"; | ||
import { useForm2, type FormAPI, type UseFormOptions2 } from "@sjsf/form"; | ||
import { translation } from "@sjsf/form/translations/en"; | ||
import { theme } from "@sjsf/form/basic-theme"; | ||
import { createValidator } from "@sjsf/ajv8-validator"; | ||
|
||
type Defaults = "widgets" | "components" | "validator" | "translation"; | ||
|
||
export type CustomOptions<T, E> = Omit<UseFormOptions<T, E>, Defaults> & | ||
Partial<Pick<UseFormOptions<T, E>, Defaults>>; | ||
export type CustomOptions<T, E> = Omit<UseFormOptions2<T, E>, Defaults> & | ||
Partial<Pick<UseFormOptions2<T, E>, Defaults>>; | ||
|
||
export function useCustomForm<T, E = ErrorObject>(options: CustomOptions<T, E>): FormAPI<T, E> { | ||
export function useCustomForm<T, E = ErrorObject>( | ||
options: CustomOptions<T, E> | ||
): FormAPI<T, E> { | ||
const validator = createValidator(); | ||
return useForm( | ||
Object.setPrototypeOf(options, { | ||
...theme, | ||
validator, | ||
translation, | ||
}) | ||
const defaults: Pick<UseFormOptions2<T, ErrorObject>, Defaults> = { | ||
...theme, | ||
validator, | ||
translation, | ||
}; | ||
return useForm2( | ||
new Proxy(options, { | ||
get(target, p, receiver) { | ||
if (!(p in target)) { | ||
return defaults[p as Defaults]; | ||
} | ||
return Reflect.get(target, p, receiver); | ||
}, | ||
}) as UseFormOptions2<T, E> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
apps/docs/src/content/docs/guides/_multiple-forms-form.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<script lang="ts" generics="T, E"> | ||
import type { HTMLFormAttributes } from "svelte/elements"; | ||
import { FormContent, setFromContext, SubmitButton, type FormAPI, type FormContext } from '@sjsf/form'; | ||
interface Props extends HTMLFormAttributes { | ||
form: FormAPI<T, E>; | ||
ctx: FormContext; | ||
} | ||
const { form, ctx, ...rest }: Props = $props(); | ||
setFromContext(ctx) | ||
</script> | ||
|
||
<form use:form.enhance {...rest}> | ||
<!-- svelte-ignore ownership_invalid_binding --> | ||
<FormContent bind:value={form.formValue} /> | ||
<SubmitButton /> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
import { ShadowHost } from '@/components/shadow'; | ||
import Form from './_multiple-forms.svelte' | ||
--- | ||
|
||
<ShadowHost client:only="svelte"> | ||
<Form client:only="svelte" /> | ||
</ShadowHost> |
Oops, something went wrong.