@tanstack/svelte-form 1.33.5 → 2.0.0-alpha.1
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/dist/AppForm/AppForm.svelte +14 -0
- package/dist/AppForm/Components.lib.d.ts +7 -0
- package/dist/AppForm/Components.lib.js +8 -0
- package/dist/AppForm/SvelteAppFormApi.public.d.ts +10 -0
- package/dist/AppForm/appFormOptions.public.d.ts +12 -0
- package/dist/AppForm/appFormOptions.public.js +1 -0
- package/dist/AppForm/componentMap.public.d.ts +7 -0
- package/dist/AppForm/componentMap.public.js +1 -0
- package/dist/AppForm/contexts.lib.d.ts +4 -0
- package/dist/AppForm/contexts.lib.js +16 -0
- package/dist/AppForm/createFormHook.public.d.ts +3 -0
- package/dist/AppForm/createFormHook.public.js +20 -0
- package/dist/AppForm/createFormHookTypes.public.d.ts +12 -0
- package/dist/AppForm/createFormHookTypes.public.js +1 -0
- package/dist/AppForm/fieldComponentHelpers.lib.d.ts +5 -0
- package/dist/AppForm/fieldComponentHelpers.lib.js +10 -0
- package/dist/AppForm/getFormHookHelpers.public.d.ts +31 -0
- package/dist/AppForm/getFormHookHelpers.public.js +13 -0
- package/dist/AppForm/initializeAppForm.lib.d.ts +4 -0
- package/dist/AppForm/initializeAppForm.lib.js +5 -0
- package/dist/Components.public.d.ts +52 -0
- package/dist/Components.public.js +1 -0
- package/dist/Field.svelte +125 -314
- package/dist/Field.svelte.d.ts +14 -30
- package/dist/FieldGroup/FieldGroupApi.public.d.ts +15 -0
- package/dist/FieldGroup/FieldGroupApi.public.js +1 -0
- package/dist/FieldGroup/withFields.lib.d.ts +5 -0
- package/dist/FieldGroup/withFields.lib.js +44 -0
- package/dist/FieldGroup/withFields.public.d.ts +70 -0
- package/dist/FieldGroup/withFields.public.js +3 -0
- package/dist/FormGroup.svelte +81 -302
- package/dist/FormGroup.svelte.d.ts +13 -30
- package/dist/Subscribe.svelte +18 -8
- package/dist/Subscribe.svelte.d.ts +5 -3
- package/dist/createForm.public.d.ts +5 -0
- package/dist/createForm.public.js +5 -0
- package/dist/createForm.svelte.d.ts +11 -27
- package/dist/createForm.svelte.js +29 -19
- package/dist/formApiTypes.public.d.ts +37 -0
- package/dist/formApiTypes.public.js +1 -0
- package/dist/formType.public.d.ts +7 -0
- package/dist/formType.public.js +1 -0
- package/dist/index.d.ts +17 -6
- package/dist/index.js +17 -5
- package/dist/utils.lib.d.ts +1 -0
- package/dist/utils.lib.js +28 -0
- package/package.json +6 -7
- package/dist/AppField.svelte +0 -19
- package/dist/AppField.svelte.d.ts +0 -10
- package/dist/AppForm.svelte +0 -16
- package/dist/InnerAppField.svelte +0 -17
- package/dist/InnerAppField.svelte.d.ts +0 -9
- package/dist/createFormCreator.svelte.d.ts +0 -26
- package/dist/createFormCreator.svelte.js +0 -51
- package/dist/types.d.ts +0 -21
- package/src/AppField.svelte +0 -19
- package/src/AppForm.svelte +0 -16
- package/src/Field.svelte +0 -341
- package/src/FormGroup.svelte +0 -322
- package/src/InnerAppField.svelte +0 -17
- package/src/Subscribe.svelte +0 -16
- package/src/context-keys.ts +0 -2
- package/src/createForm.svelte.ts +0 -350
- package/src/createFormCreator.svelte.ts +0 -321
- package/src/index.ts +0 -16
- package/src/types.ts +0 -567
- /package/dist/{AppForm.svelte.d.ts → AppForm/AppForm.svelte.d.ts} +0 -0
- /package/dist/{types.js → AppForm/SvelteAppFormApi.public.js} +0 -0
|
@@ -1,29 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { Component
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
export interface
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
current: TSelected;
|
|
1
|
+
import type { FormOptions } from '@tanstack/form-core';
|
|
2
|
+
import type { Component } from 'svelte';
|
|
3
|
+
import type { AnyInternalFormApi } from '@tanstack/form-core/internals';
|
|
4
|
+
import type { SvelteTanStackFormComponents } from './Components.public';
|
|
5
|
+
export interface InternalSvelteFormApi extends AnyInternalFormApi, SvelteTanStackFormComponents<any, any, any> {
|
|
6
|
+
_Subscribe: Component<any>;
|
|
7
|
+
useSelector: <TSelected = any>(selector?: (state: any) => TSelected) => {
|
|
8
|
+
readonly current: TSelected;
|
|
10
9
|
};
|
|
11
|
-
/**
|
|
12
|
-
* @deprecated Use `form.useSelector` instead.
|
|
13
|
-
*/
|
|
14
|
-
useStore: <TSelected = NoInfer<FormState<TParentData, TFormOnMount, TFormOnChange, TFormOnChangeAsync, TFormOnBlur, TFormOnBlurAsync, TFormOnSubmit, TFormOnSubmitAsync, TFormOnDynamic, TFormOnDynamicAsync, TFormOnServer>>>(selector?: (state: NoInfer<FormState<TParentData, TFormOnMount, TFormOnChange, TFormOnChangeAsync, TFormOnBlur, TFormOnBlurAsync, TFormOnSubmit, TFormOnSubmitAsync, TFormOnDynamic, TFormOnDynamicAsync, TFormOnServer>>) => TSelected) => {
|
|
15
|
-
current: TSelected;
|
|
16
|
-
};
|
|
17
|
-
Subscribe: (<TSelected = NoInfer<FormState<TParentData, TFormOnMount, TFormOnChange, TFormOnChangeAsync, TFormOnBlur, TFormOnBlurAsync, TFormOnSubmit, TFormOnSubmitAsync, TFormOnDynamic, TFormOnDynamicAsync, TFormOnServer>>>(internal: any, props: {
|
|
18
|
-
selector?: (state: NoInfer<FormState<TParentData, TFormOnMount, TFormOnChange, TFormOnChangeAsync, TFormOnBlur, TFormOnBlurAsync, TFormOnSubmit, TFormOnSubmitAsync, TFormOnDynamic, TFormOnDynamicAsync, TFormOnServer>>) => TSelected;
|
|
19
|
-
children: Snippet<[NoInfer<TSelected>]>;
|
|
20
|
-
}) => {}) & (new <TSelected = NoInfer<FormState<TParentData, TFormOnMount, TFormOnChange, TFormOnChangeAsync, TFormOnBlur, TFormOnBlurAsync, TFormOnSubmit, TFormOnSubmitAsync, TFormOnDynamic, TFormOnDynamicAsync, TFormOnServer>>>(opts: ComponentConstructorOptions<{
|
|
21
|
-
selector?: (state: NoInfer<FormState<TParentData, TFormOnMount, TFormOnChange, TFormOnChangeAsync, TFormOnBlur, TFormOnBlurAsync, TFormOnSubmit, TFormOnSubmitAsync, TFormOnDynamic, TFormOnDynamicAsync, TFormOnServer>>) => TSelected;
|
|
22
|
-
children: Snippet<[NoInfer<TSelected>]>;
|
|
23
|
-
}>) => SvelteComponent) & WithoutFunction<Component>;
|
|
24
10
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
export type SvelteFormExtendedApi<TFormData, TOnMount extends undefined | FormValidateOrFn<TFormData>, TOnChange extends undefined | FormValidateOrFn<TFormData>, TOnChangeAsync extends undefined | FormAsyncValidateOrFn<TFormData>, TOnBlur extends undefined | FormValidateOrFn<TFormData>, TOnBlurAsync extends undefined | FormAsyncValidateOrFn<TFormData>, TOnSubmit extends undefined | FormValidateOrFn<TFormData>, TOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TFormData>, TOnDynamic extends undefined | FormValidateOrFn<TFormData>, TOnDynamicAsync extends undefined | FormAsyncValidateOrFn<TFormData>, TOnServer extends undefined | FormAsyncValidateOrFn<TFormData>, TSubmitMeta> = FormApi<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta> & SvelteFormApi<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta>;
|
|
29
|
-
export declare function createForm<TParentData, TFormOnMount extends undefined | FormValidateOrFn<TParentData>, TFormOnChange extends undefined | FormValidateOrFn<TParentData>, TFormOnChangeAsync extends undefined | FormAsyncValidateOrFn<TParentData>, TFormOnBlur extends undefined | FormValidateOrFn<TParentData>, TFormOnBlurAsync extends undefined | FormAsyncValidateOrFn<TParentData>, TFormOnSubmit extends undefined | FormValidateOrFn<TParentData>, TFormOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TParentData>, TFormOnDynamic extends undefined | FormValidateOrFn<TParentData>, TFormOnDynamicAsync extends undefined | FormAsyncValidateOrFn<TParentData>, TFormOnServer extends undefined | FormAsyncValidateOrFn<TParentData>, TSubmitMeta>(opts?: () => FormOptions<TParentData, TFormOnMount, TFormOnChange, TFormOnChangeAsync, TFormOnBlur, TFormOnBlurAsync, TFormOnSubmit, TFormOnSubmitAsync, TFormOnDynamic, TFormOnDynamicAsync, TFormOnServer, TSubmitMeta>): FormApi<TParentData, TFormOnMount, TFormOnChange, TFormOnChangeAsync, TFormOnBlur, TFormOnBlurAsync, TFormOnSubmit, TFormOnSubmitAsync, TFormOnDynamic, TFormOnDynamicAsync, TFormOnServer, TSubmitMeta> & SvelteFormApi<TParentData, TFormOnMount, TFormOnChange, TFormOnChangeAsync, TFormOnBlur, TFormOnBlurAsync, TFormOnSubmit, TFormOnSubmitAsync, TFormOnDynamic, TFormOnDynamicAsync, TFormOnServer, TSubmitMeta>;
|
|
11
|
+
export declare function attachSvelteFormComponents(form: AnyInternalFormApi, fieldComponents: Record<string, Component<any>> | null): InternalSvelteFormApi;
|
|
12
|
+
export declare function initializeForm(options: FormOptions<any, any, any>): InternalSvelteFormApi;
|
|
13
|
+
export declare function createInternalForm(options: () => FormOptions<any, any, any>, initialize: (options: FormOptions<any, any, any>) => InternalSvelteFormApi): InternalSvelteFormApi;
|
|
@@ -1,25 +1,35 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InternalFormApi } from '@tanstack/form-core/internals';
|
|
2
2
|
import { useSelector } from '@tanstack/svelte-store';
|
|
3
3
|
import { onMount } from 'svelte';
|
|
4
4
|
import Field from './Field.svelte';
|
|
5
5
|
import FormGroup from './FormGroup.svelte';
|
|
6
6
|
import Subscribe from './Subscribe.svelte';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
7
|
+
import { withComponentProps } from './utils.lib.js';
|
|
8
|
+
export function attachSvelteFormComponents(form, fieldComponents) {
|
|
9
|
+
const result = form;
|
|
10
|
+
result.Field = ((internals, props) => Field(internals, withComponentProps(props, {
|
|
11
|
+
form,
|
|
12
|
+
fieldComponents: fieldComponents ?? {},
|
|
13
|
+
})));
|
|
14
|
+
result.ArrayField = ((internals, props) => Field(internals, withComponentProps(props, {
|
|
15
|
+
form,
|
|
16
|
+
array: true,
|
|
17
|
+
fieldComponents: fieldComponents ?? {},
|
|
18
|
+
})));
|
|
19
|
+
result._Subscribe = (internals, props) => Subscribe(internals, props);
|
|
20
|
+
result.Subscribe = ((internals, props) => Subscribe(internals, withComponentProps(props, { source: form.atom })));
|
|
21
|
+
result.FormGroup = ((internals, props) => FormGroup(internals, withComponentProps(props, { form })));
|
|
22
|
+
result.useSelector = ((selector) => useSelector(form.atom, selector));
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
export function initializeForm(options) {
|
|
26
|
+
return attachSvelteFormComponents(new InternalFormApi(options), null);
|
|
27
|
+
}
|
|
28
|
+
export function createInternalForm(options, initialize) {
|
|
29
|
+
const form = initialize(options());
|
|
30
|
+
$effect.pre(() => {
|
|
31
|
+
form._update(options());
|
|
32
|
+
});
|
|
33
|
+
onMount(() => form.mount());
|
|
34
|
+
return form;
|
|
25
35
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { AnyFormApi, FormApi, FormErrorTypes, FormState } from '@tanstack/form-core';
|
|
2
|
+
import type { Component } from 'svelte';
|
|
3
|
+
import type { SvelteTanStackFormComponents } from './Components.public';
|
|
4
|
+
import type { AnySvelteFormComponentMap, DefaultSvelteFormComponentMap } from './AppForm/componentMap.public';
|
|
5
|
+
export interface SvelteFormSelectors<TFormData, TFormErrorTypes extends FormErrorTypes> {
|
|
6
|
+
useSelector: <TSelected = FormState<TFormData, TFormErrorTypes>>(selector?: (state: FormState<TFormData, TFormErrorTypes>) => TSelected) => {
|
|
7
|
+
readonly current: TSelected;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
type ExtendedFormApi<TFormData, TFormErrorTypes extends FormErrorTypes, TFieldComponents extends Record<string, Component<any>>> = FormApi<TFormData, TFormErrorTypes> & SvelteTanStackFormComponents<TFormData, TFormErrorTypes, TFieldComponents> & SvelteFormSelectors<TFormData, TFormErrorTypes>;
|
|
11
|
+
export type SvelteFormApi<TFormData, TFormErrorTypes extends FormErrorTypes, TComponents extends AnySvelteFormComponentMap = DefaultSvelteFormComponentMap> = unknown extends TComponents['formComponents'] ? ExtendedFormApi<TFormData, TFormErrorTypes, TComponents['fieldComponents']> : ExtendedFormApi<TFormData, TFormErrorTypes, TComponents['fieldComponents']> & TComponents['formComponents'];
|
|
12
|
+
/**
|
|
13
|
+
* A Svelte form API whose form data and error types are erased.
|
|
14
|
+
*
|
|
15
|
+
* Use it for reusable Svelte components that only need core form operations,
|
|
16
|
+
* selectors, and the `Field`, `ArrayField`, `Subscribe`, or `FormGroup`
|
|
17
|
+
* components common to every Svelte form. Field paths and values are not
|
|
18
|
+
* checked against a particular form shape; use `SvelteFormType` when a
|
|
19
|
+
* component depends on one known form.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```svelte
|
|
23
|
+
* <script lang="ts">
|
|
24
|
+
* const { form }: { form: AnySvelteFormApi } = $props()
|
|
25
|
+
* </script>
|
|
26
|
+
*
|
|
27
|
+
* <form.Subscribe selector={(state) => state.isSubmitting}>
|
|
28
|
+
* {#snippet children(isSubmitting)}
|
|
29
|
+
* <button type="submit" disabled={isSubmitting}>
|
|
30
|
+
* {isSubmitting ? 'Saving...' : 'Save'}
|
|
31
|
+
* </button>
|
|
32
|
+
* {/snippet}
|
|
33
|
+
* </form.Subscribe>
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export type AnySvelteFormApi = AnyFormApi & SvelteTanStackFormComponents<any, any, any> & SvelteFormSelectors<any, any>;
|
|
37
|
+
export type { SvelteFormComponentMap } from './AppForm/componentMap.public';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AnyFormOptions, FormOptions, FormValidators, ToFormErrorTypes } from '@tanstack/form-core';
|
|
2
|
+
import type { AppFormOptions } from './AppForm/appFormOptions.public';
|
|
3
|
+
import type { AnySvelteFormComponentMap, DefaultSvelteFormComponentMap } from './AppForm/componentMap.public';
|
|
4
|
+
import type { SvelteFormApi } from './formApiTypes.public';
|
|
5
|
+
type SvelteFormTypeErrorTypes<TValidators extends FormValidators<any>, TSubmitReturn> = unknown extends TSubmitReturn ? any : ToFormErrorTypes<TValidators, TSubmitReturn>;
|
|
6
|
+
export type SvelteFormType<TOptions extends AnyFormOptions | AppFormOptions<any, any, any, AnySvelteFormComponentMap>> = TOptions extends AppFormOptions<infer TData, infer TValidators, infer TSubmitReturn, infer TComponents> ? SvelteFormApi<TData, SvelteFormTypeErrorTypes<TValidators, TSubmitReturn>, TComponents> : TOptions extends FormOptions<infer TData, infer TValidators, infer TSubmitReturn> ? SvelteFormApi<TData, SvelteFormTypeErrorTypes<TValidators, TSubmitReturn>, DefaultSvelteFormComponentMap> : never;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
export * from '@tanstack/form-core';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
2
|
+
export * from '@tanstack/svelte-store';
|
|
3
|
+
export * from './createForm.public';
|
|
4
|
+
export * from './formApiTypes.public';
|
|
5
|
+
export * from './formType.public';
|
|
6
|
+
export * from './Components.public';
|
|
7
|
+
export * from './Field.svelte';
|
|
8
|
+
export { default as Field } from './Field.svelte';
|
|
9
|
+
export * from './FormGroup.svelte';
|
|
10
|
+
export { default as FormGroup } from './FormGroup.svelte';
|
|
11
|
+
export * from './FieldGroup/FieldGroupApi.public';
|
|
12
|
+
export * from './FieldGroup/withFields.public';
|
|
13
|
+
export * from './AppForm/SvelteAppFormApi.public';
|
|
14
|
+
export * from './AppForm/appFormOptions.public';
|
|
15
|
+
export * from './AppForm/componentMap.public';
|
|
16
|
+
export * from './AppForm/createFormHook.public';
|
|
17
|
+
export * from './AppForm/createFormHookTypes.public';
|
|
18
|
+
export * from './AppForm/getFormHookHelpers.public';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
export * from '@tanstack/form-core';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
2
|
+
export * from '@tanstack/svelte-store';
|
|
3
|
+
export * from './createForm.public';
|
|
4
|
+
export * from './formApiTypes.public';
|
|
5
|
+
export * from './formType.public';
|
|
6
|
+
export * from './Components.public';
|
|
7
|
+
export * from './Field.svelte';
|
|
8
|
+
export { default as Field } from './Field.svelte';
|
|
9
|
+
export * from './FormGroup.svelte';
|
|
10
|
+
export { default as FormGroup } from './FormGroup.svelte';
|
|
11
|
+
export * from './FieldGroup/FieldGroupApi.public';
|
|
12
|
+
export * from './FieldGroup/withFields.public';
|
|
13
|
+
export * from './AppForm/SvelteAppFormApi.public';
|
|
14
|
+
export * from './AppForm/appFormOptions.public';
|
|
15
|
+
export * from './AppForm/componentMap.public';
|
|
16
|
+
export * from './AppForm/createFormHook.public';
|
|
17
|
+
export * from './AppForm/createFormHookTypes.public';
|
|
18
|
+
export * from './AppForm/getFormHookHelpers.public';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function withComponentProps<TProps extends object, TExtra extends object>(props: TProps, extra: TExtra): TProps & TExtra;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export function withComponentProps(props, extra) {
|
|
2
|
+
return new Proxy(props, {
|
|
3
|
+
get(target, property, receiver) {
|
|
4
|
+
if (Reflect.has(extra, property))
|
|
5
|
+
return Reflect.get(extra, property);
|
|
6
|
+
return Reflect.get(target, property, receiver);
|
|
7
|
+
},
|
|
8
|
+
has(target, property) {
|
|
9
|
+
return Reflect.has(extra, property) || Reflect.has(target, property);
|
|
10
|
+
},
|
|
11
|
+
ownKeys(target) {
|
|
12
|
+
return [
|
|
13
|
+
...new Set([...Reflect.ownKeys(target), ...Reflect.ownKeys(extra)]),
|
|
14
|
+
];
|
|
15
|
+
},
|
|
16
|
+
getOwnPropertyDescriptor(target, property) {
|
|
17
|
+
if (Reflect.has(extra, property)) {
|
|
18
|
+
return {
|
|
19
|
+
configurable: true,
|
|
20
|
+
enumerable: true,
|
|
21
|
+
value: Reflect.get(extra, property),
|
|
22
|
+
writable: false,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return Reflect.getOwnPropertyDescriptor(target, property);
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/svelte-form",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.1",
|
|
4
4
|
"description": "Powerful, type-safe forms for Svelte.",
|
|
5
5
|
"author": "tannerlinsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,19 +27,18 @@
|
|
|
27
27
|
},
|
|
28
28
|
"sideEffects": false,
|
|
29
29
|
"files": [
|
|
30
|
-
"dist"
|
|
31
|
-
"src"
|
|
30
|
+
"dist"
|
|
32
31
|
],
|
|
33
32
|
"dependencies": {
|
|
34
|
-
"@tanstack/svelte-store": "^0.12.
|
|
35
|
-
"@tanstack/form-core": "
|
|
33
|
+
"@tanstack/svelte-store": "^0.12.1",
|
|
34
|
+
"@tanstack/form-core": "2.0.0-alpha.1"
|
|
36
35
|
},
|
|
37
36
|
"devDependencies": {
|
|
38
37
|
"@sveltejs/package": "^2.5.3",
|
|
39
|
-
"@sveltejs/vite-plugin-svelte": "^
|
|
38
|
+
"@sveltejs/vite-plugin-svelte": "^7.2.0",
|
|
40
39
|
"@testing-library/svelte": "^5.2.8",
|
|
41
40
|
"svelte": "^5.39.4",
|
|
42
|
-
"svelte-check": "^4.
|
|
41
|
+
"svelte-check": "^4.7.5"
|
|
43
42
|
},
|
|
44
43
|
"peerDependencies": {
|
|
45
44
|
"svelte": "^5.0.0"
|
package/dist/AppField.svelte
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
<!-- Take "form" as an prop, pass it to context, and render children -->
|
|
2
|
-
<script lang="ts">
|
|
3
|
-
import type { Snippet } from 'svelte'
|
|
4
|
-
import InnerAppField from './InnerAppField.svelte'
|
|
5
|
-
|
|
6
|
-
interface Props {
|
|
7
|
-
form: any
|
|
8
|
-
fieldComponents: any
|
|
9
|
-
children: Snippet
|
|
10
|
-
fieldProps: any
|
|
11
|
-
}
|
|
12
|
-
const { children: childrenProp, form, fieldComponents, fieldProps }: Props = $props()
|
|
13
|
-
</script>
|
|
14
|
-
|
|
15
|
-
<form.Field {...fieldProps}>
|
|
16
|
-
{#snippet children(field: any)}
|
|
17
|
-
<InnerAppField field={field} children={childrenProp} fieldComponents={fieldComponents}/>
|
|
18
|
-
{/snippet}
|
|
19
|
-
</form.Field>
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Snippet } from 'svelte';
|
|
2
|
-
interface Props {
|
|
3
|
-
form: any;
|
|
4
|
-
fieldComponents: any;
|
|
5
|
-
children: Snippet;
|
|
6
|
-
fieldProps: any;
|
|
7
|
-
}
|
|
8
|
-
declare const AppField: import("svelte").Component<Props, {}, "">;
|
|
9
|
-
type AppField = ReturnType<typeof AppField>;
|
|
10
|
-
export default AppField;
|
package/dist/AppForm.svelte
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
<!-- Take "form" as an prop, pass it to context, and render children -->
|
|
2
|
-
<script lang="ts">
|
|
3
|
-
import { setContext, type Snippet } from 'svelte'
|
|
4
|
-
import { formContextKey } from './context-keys.js'
|
|
5
|
-
|
|
6
|
-
interface Props {
|
|
7
|
-
form: any
|
|
8
|
-
children: Snippet
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const { children, form }: Props = $props()
|
|
12
|
-
|
|
13
|
-
setContext(formContextKey, form)
|
|
14
|
-
</script>
|
|
15
|
-
|
|
16
|
-
{@render children?.()}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<!-- Take "form" as an prop, pass it to context, and render children -->
|
|
2
|
-
<script lang="ts">
|
|
3
|
-
import { setContext, type Snippet } from 'svelte'
|
|
4
|
-
import { fieldContextKey } from './context-keys.js'
|
|
5
|
-
|
|
6
|
-
interface Props {
|
|
7
|
-
field: any
|
|
8
|
-
fieldComponents: any
|
|
9
|
-
children: Snippet<[any]>
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const { children, field, fieldComponents }: Props = $props()
|
|
13
|
-
|
|
14
|
-
setContext(fieldContextKey, field)
|
|
15
|
-
</script>
|
|
16
|
-
|
|
17
|
-
{@render children?.(Object.assign(field, fieldComponents))}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type Snippet } from 'svelte';
|
|
2
|
-
interface Props {
|
|
3
|
-
field: any;
|
|
4
|
-
fieldComponents: any;
|
|
5
|
-
children: Snippet<[any]>;
|
|
6
|
-
}
|
|
7
|
-
declare const InnerAppField: import("svelte").Component<Props, {}, "">;
|
|
8
|
-
type InnerAppField = ReturnType<typeof InnerAppField>;
|
|
9
|
-
export default InnerAppField;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { FieldApi, FormAsyncValidateOrFn, FormOptions, FormValidateOrFn } from '@tanstack/form-core';
|
|
2
|
-
import type { FieldComponent } from './types.js';
|
|
3
|
-
import type { SvelteFormExtendedApi } from './createForm.svelte';
|
|
4
|
-
import type { Component, Snippet } from 'svelte';
|
|
5
|
-
export declare function createFormCreatorContexts(): {
|
|
6
|
-
useFieldContext: <TData>() => FieldApi<any, string, TData, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any>;
|
|
7
|
-
useFormContext: () => SvelteFormExtendedApi<Record<string, never>, any, any, any, any, any, any, any, any, any, any, any>;
|
|
8
|
-
};
|
|
9
|
-
interface CreateFormRuneProps<TFieldComponents extends Record<string, Component<any, any>>, TFormComponents extends Record<string, Component<any, any>>> {
|
|
10
|
-
fieldComponents: TFieldComponents;
|
|
11
|
-
formComponents: TFormComponents;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* @private
|
|
15
|
-
*/
|
|
16
|
-
type AppFieldExtendedSvelteFormApi<TFormData, TOnMount extends undefined | FormValidateOrFn<TFormData>, TOnChange extends undefined | FormValidateOrFn<TFormData>, TOnChangeAsync extends undefined | FormAsyncValidateOrFn<TFormData>, TOnBlur extends undefined | FormValidateOrFn<TFormData>, TOnBlurAsync extends undefined | FormAsyncValidateOrFn<TFormData>, TOnSubmit extends undefined | FormValidateOrFn<TFormData>, TOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TFormData>, TOnDynamic extends undefined | FormValidateOrFn<TFormData>, TOnDynamicAsync extends undefined | FormAsyncValidateOrFn<TFormData>, TOnServer extends undefined | FormAsyncValidateOrFn<TFormData>, TSubmitMeta, TFieldComponents extends Record<string, Component<any, any>>, TFormComponents extends Record<string, Component<any, any>>> = SvelteFormExtendedApi<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta> & NoInfer<TFormComponents> & {
|
|
17
|
-
AppField: FieldComponent<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta, NoInfer<TFieldComponents>>;
|
|
18
|
-
AppForm: Component<{
|
|
19
|
-
children: Snippet;
|
|
20
|
-
}>;
|
|
21
|
-
};
|
|
22
|
-
export declare function createFormCreator<const TComponents extends Record<string, Component<any, any>>, const TFormComponents extends Record<string, Component<any, any>>>({ fieldComponents, formComponents, }: CreateFormRuneProps<TComponents, TFormComponents>): {
|
|
23
|
-
createAppForm: <TFormData, TOnMount extends undefined | FormValidateOrFn<TFormData>, TOnChange extends undefined | FormValidateOrFn<TFormData>, TOnChangeAsync extends undefined | FormAsyncValidateOrFn<TFormData>, TOnBlur extends undefined | FormValidateOrFn<TFormData>, TOnBlurAsync extends undefined | FormAsyncValidateOrFn<TFormData>, TOnSubmit extends undefined | FormValidateOrFn<TFormData>, TOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TFormData>, TOnDynamic extends undefined | FormValidateOrFn<TFormData>, TOnDynamicAsync extends undefined | FormAsyncValidateOrFn<TFormData>, TOnServer extends undefined | FormAsyncValidateOrFn<TFormData>, TSubmitMeta>(props: () => FormOptions<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta>) => AppFieldExtendedSvelteFormApi<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta, TComponents, TFormComponents>;
|
|
24
|
-
getFormType: <TFormData, TOnMount extends undefined | FormValidateOrFn<TFormData>, TOnChange extends undefined | FormValidateOrFn<TFormData>, TOnChangeAsync extends undefined | FormAsyncValidateOrFn<TFormData>, TOnBlur extends undefined | FormValidateOrFn<TFormData>, TOnBlurAsync extends undefined | FormAsyncValidateOrFn<TFormData>, TOnSubmit extends undefined | FormValidateOrFn<TFormData>, TOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TFormData>, TOnDynamic extends undefined | FormValidateOrFn<TFormData>, TOnDynamicAsync extends undefined | FormAsyncValidateOrFn<TFormData>, TOnServer extends undefined | FormAsyncValidateOrFn<TFormData>, TSubmitMeta>(_formProps: FormOptions<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta>) => AppFieldExtendedSvelteFormApi<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta, TComponents, TFormComponents>;
|
|
25
|
-
};
|
|
26
|
-
export {};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { getContext } from 'svelte';
|
|
2
|
-
import { createForm } from './createForm.svelte';
|
|
3
|
-
import AppFormSvelte from './AppForm.svelte';
|
|
4
|
-
import AppFieldSvelte from './AppField.svelte';
|
|
5
|
-
import { fieldContextKey, formContextKey } from './context-keys.js';
|
|
6
|
-
export function createFormCreatorContexts() {
|
|
7
|
-
function useFieldContext() {
|
|
8
|
-
const field = getContext(fieldContextKey);
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
10
|
-
if (!field) {
|
|
11
|
-
throw new Error('`fieldContext` only works when within a `fieldComponent` passed to `createFormCreator`');
|
|
12
|
-
}
|
|
13
|
-
return field;
|
|
14
|
-
}
|
|
15
|
-
function useFormContext() {
|
|
16
|
-
const form = getContext(formContextKey);
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
18
|
-
if (!form) {
|
|
19
|
-
throw new Error('`formContext` only works when within a `formComponent` passed to `createFormCreator`');
|
|
20
|
-
}
|
|
21
|
-
return form;
|
|
22
|
-
}
|
|
23
|
-
return { useFieldContext, useFormContext };
|
|
24
|
-
}
|
|
25
|
-
export function createFormCreator({ fieldComponents, formComponents, }) {
|
|
26
|
-
function createAppForm(props) {
|
|
27
|
-
const form = createForm(props);
|
|
28
|
-
const AppForm = ((internal, props) => {
|
|
29
|
-
return AppFormSvelte(internal, { ...props, form });
|
|
30
|
-
});
|
|
31
|
-
const AppField = ((internal, { children, ...fieldProps }) => AppFieldSvelte(internal, {
|
|
32
|
-
fieldProps,
|
|
33
|
-
form,
|
|
34
|
-
fieldComponents,
|
|
35
|
-
children,
|
|
36
|
-
}));
|
|
37
|
-
const extendedForm = Object.assign(form, {
|
|
38
|
-
AppField,
|
|
39
|
-
AppForm,
|
|
40
|
-
...formComponents,
|
|
41
|
-
});
|
|
42
|
-
return extendedForm;
|
|
43
|
-
}
|
|
44
|
-
function getFormType(_formProps) {
|
|
45
|
-
return undefined;
|
|
46
|
-
}
|
|
47
|
-
return {
|
|
48
|
-
createAppForm,
|
|
49
|
-
getFormType,
|
|
50
|
-
};
|
|
51
|
-
}
|
package/dist/types.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { DeepKeys, DeepValue, FieldApi, FieldApiOptions, FieldAsyncValidateOrFn, FieldValidateOrFn, FormAsyncValidateOrFn, FormGroupApi, FormGroupApiOptions, FormGroupAsyncValidateOrFn, FormGroupValidateOrFn, FormValidateOrFn } from '@tanstack/form-core';
|
|
2
|
-
import type { Component, ComponentConstructorOptions, Snippet, SvelteComponent } from 'svelte';
|
|
3
|
-
export type CreateFieldOptions<TParentData, TName extends DeepKeys<TParentData>, TData extends DeepValue<TParentData, TName>, TOnMount extends undefined | FieldValidateOrFn<TParentData, TName, TData>, TOnChange extends undefined | FieldValidateOrFn<TParentData, TName, TData>, TOnChangeAsync extends undefined | FieldAsyncValidateOrFn<TParentData, TName, TData>, TOnBlur extends undefined | FieldValidateOrFn<TParentData, TName, TData>, TOnBlurAsync extends undefined | FieldAsyncValidateOrFn<TParentData, TName, TData>, TOnSubmit extends undefined | FieldValidateOrFn<TParentData, TName, TData>, TOnSubmitAsync extends undefined | FieldAsyncValidateOrFn<TParentData, TName, TData>, TOnDynamic extends undefined | FieldValidateOrFn<TParentData, TName, TData>, TOnDynamicAsync extends undefined | FieldAsyncValidateOrFn<TParentData, TName, TData>, TFormOnMount extends undefined | FormValidateOrFn<TParentData>, TFormOnChange extends undefined | FormValidateOrFn<TParentData>, TFormOnChangeAsync extends undefined | FormAsyncValidateOrFn<TParentData>, TFormOnBlur extends undefined | FormValidateOrFn<TParentData>, TFormOnBlurAsync extends undefined | FormAsyncValidateOrFn<TParentData>, TFormOnSubmit extends undefined | FormValidateOrFn<TParentData>, TFormOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TParentData>, TFormOnDynamic extends undefined | FormValidateOrFn<TParentData>, TFormOnDynamicAsync extends undefined | FormAsyncValidateOrFn<TParentData>, TFormOnServer extends undefined | FormAsyncValidateOrFn<TParentData>, TSubmitMeta> = FieldApiOptions<TParentData, TName, TData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TFormOnMount, TFormOnChange, TFormOnChangeAsync, TFormOnBlur, TFormOnBlurAsync, TFormOnSubmit, TFormOnSubmitAsync, TFormOnDynamic, TFormOnDynamicAsync, TFormOnServer, TSubmitMeta> & {
|
|
4
|
-
mode?: 'value' | 'array';
|
|
5
|
-
};
|
|
6
|
-
export type WithoutFunction<T> = {
|
|
7
|
-
[K in keyof T as T[K] extends Function ? never : K]: T[K];
|
|
8
|
-
};
|
|
9
|
-
export type FieldComponent<TParentData, TFormOnMount extends undefined | FormValidateOrFn<TParentData>, TFormOnChange extends undefined | FormValidateOrFn<TParentData>, TFormOnChangeAsync extends undefined | FormAsyncValidateOrFn<TParentData>, TFormOnBlur extends undefined | FormValidateOrFn<TParentData>, TFormOnBlurAsync extends undefined | FormAsyncValidateOrFn<TParentData>, TFormOnSubmit extends undefined | FormValidateOrFn<TParentData>, TFormOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TParentData>, TFormOnDynamic extends undefined | FormValidateOrFn<TParentData>, TFormOnDynamicAsync extends undefined | FormAsyncValidateOrFn<TParentData>, TFormOnServer extends undefined | FormAsyncValidateOrFn<TParentData>, TParentSubmitMeta, ExtendedApi = {}> = (<TName extends DeepKeys<TParentData>, TData extends DeepValue<TParentData, TName>, TOnMount extends undefined | FieldValidateOrFn<TParentData, TName, TData>, TOnChange extends undefined | FieldValidateOrFn<TParentData, TName, TData>, TOnChangeAsync extends undefined | FieldAsyncValidateOrFn<TParentData, TName, TData>, TOnBlur extends undefined | FieldValidateOrFn<TParentData, TName, TData>, TOnBlurAsync extends undefined | FieldAsyncValidateOrFn<TParentData, TName, TData>, TOnSubmit extends undefined | FieldValidateOrFn<TParentData, TName, TData>, TOnSubmitAsync extends undefined | FieldAsyncValidateOrFn<TParentData, TName, TData>, TOnDynamic extends undefined | FieldValidateOrFn<TParentData, TName, TData>, TOnDynamicAsync extends undefined | FieldAsyncValidateOrFn<TParentData, TName, TData>>(internal: any, { children, ...fieldOptions }: Omit<FieldComponentProps<TParentData, TName, TData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TFormOnMount, TFormOnChange, TFormOnChangeAsync, TFormOnBlur, TFormOnBlurAsync, TFormOnSubmit, TFormOnSubmitAsync, TFormOnDynamic, TFormOnDynamicAsync, TFormOnServer, TParentSubmitMeta, ExtendedApi>, 'form'>) => {}) & (new <TName extends DeepKeys<TParentData>, TData extends DeepValue<TParentData, TName>, TOnMount extends undefined | FieldValidateOrFn<TParentData, TName, TData>, TOnChange extends undefined | FieldValidateOrFn<TParentData, TName, TData>, TOnChangeAsync extends undefined | FieldAsyncValidateOrFn<TParentData, TName, TData>, TOnBlur extends undefined | FieldValidateOrFn<TParentData, TName, TData>, TOnBlurAsync extends undefined | FieldAsyncValidateOrFn<TParentData, TName, TData>, TOnSubmit extends undefined | FieldValidateOrFn<TParentData, TName, TData>, TOnSubmitAsync extends undefined | FieldAsyncValidateOrFn<TParentData, TName, TData>, TOnDynamic extends undefined | FieldValidateOrFn<TParentData, TName, TData>, TOnDynamicAsync extends undefined | FieldAsyncValidateOrFn<TParentData, TName, TData>>(opts: ComponentConstructorOptions<Omit<FieldComponentProps<TParentData, TName, TData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TFormOnMount, TFormOnChange, TFormOnChangeAsync, TFormOnBlur, TFormOnBlurAsync, TFormOnSubmit, TFormOnSubmitAsync, TFormOnDynamic, TFormOnDynamicAsync, TFormOnServer, TParentSubmitMeta, ExtendedApi>, 'form'>>) => SvelteComponent) & WithoutFunction<Component>;
|
|
10
|
-
type FieldComponentProps<TParentData, TName extends DeepKeys<TParentData>, TData extends DeepValue<TParentData, TName>, TOnMount extends undefined | FieldValidateOrFn<TParentData, TName, TData>, TOnChange extends undefined | FieldValidateOrFn<TParentData, TName, TData>, TOnChangeAsync extends undefined | FieldAsyncValidateOrFn<TParentData, TName, TData>, TOnBlur extends undefined | FieldValidateOrFn<TParentData, TName, TData>, TOnBlurAsync extends undefined | FieldAsyncValidateOrFn<TParentData, TName, TData>, TOnSubmit extends undefined | FieldValidateOrFn<TParentData, TName, TData>, TOnSubmitAsync extends undefined | FieldAsyncValidateOrFn<TParentData, TName, TData>, TOnDynamic extends undefined | FieldValidateOrFn<TParentData, TName, TData>, TOnDynamicAsync extends undefined | FieldAsyncValidateOrFn<TParentData, TName, TData>, TFormOnMount extends undefined | FormValidateOrFn<TParentData>, TFormOnChange extends undefined | FormValidateOrFn<TParentData>, TFormOnChangeAsync extends undefined | FormAsyncValidateOrFn<TParentData>, TFormOnBlur extends undefined | FormValidateOrFn<TParentData>, TFormOnBlurAsync extends undefined | FormAsyncValidateOrFn<TParentData>, TFormOnSubmit extends undefined | FormValidateOrFn<TParentData>, TFormOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TParentData>, TFormOnDynamic extends undefined | FormValidateOrFn<TParentData>, TFormOnDynamicAsync extends undefined | FormAsyncValidateOrFn<TParentData>, TFormOnServer extends undefined | FormAsyncValidateOrFn<TParentData>, TParentSubmitMeta, ExtendedApi = {}> = {
|
|
11
|
-
children: Snippet<[
|
|
12
|
-
FieldApi<TParentData, TName, TData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TFormOnMount, TFormOnChange, TFormOnChangeAsync, TFormOnBlur, TFormOnBlurAsync, TFormOnSubmit, TFormOnSubmitAsync, TFormOnDynamic, TFormOnDynamicAsync, TFormOnServer, TParentSubmitMeta> & ExtendedApi
|
|
13
|
-
]>;
|
|
14
|
-
} & Omit<CreateFieldOptions<TParentData, TName, TData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TFormOnMount, TFormOnChange, TFormOnChangeAsync, TFormOnBlur, TFormOnBlurAsync, TFormOnSubmit, TFormOnSubmitAsync, TFormOnDynamic, TFormOnDynamicAsync, TFormOnServer, TParentSubmitMeta>, 'form'>;
|
|
15
|
-
export type FormGroupComponent<TParentData, TFormOnMount extends undefined | FormValidateOrFn<TParentData>, TFormOnChange extends undefined | FormValidateOrFn<TParentData>, TFormOnChangeAsync extends undefined | FormAsyncValidateOrFn<TParentData>, TFormOnBlur extends undefined | FormValidateOrFn<TParentData>, TFormOnBlurAsync extends undefined | FormAsyncValidateOrFn<TParentData>, TFormOnSubmit extends undefined | FormValidateOrFn<TParentData>, TFormOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TParentData>, TFormOnDynamic extends undefined | FormValidateOrFn<TParentData>, TFormOnDynamicAsync extends undefined | FormAsyncValidateOrFn<TParentData>, TFormOnServer extends undefined | FormAsyncValidateOrFn<TParentData>, TParentSubmitMeta, ExtendedApi = {}> = (<TName extends DeepKeys<TParentData>, TData extends DeepValue<TParentData, TName>, TOnMount extends undefined | FormGroupValidateOrFn<TParentData, TName, TData>, TOnChange extends undefined | FormGroupValidateOrFn<TParentData, TName, TData>, TOnChangeAsync extends undefined | FormGroupAsyncValidateOrFn<TParentData, TName, TData>, TOnBlur extends undefined | FormGroupValidateOrFn<TParentData, TName, TData>, TOnBlurAsync extends undefined | FormGroupAsyncValidateOrFn<TParentData, TName, TData>, TOnSubmit extends undefined | FormGroupValidateOrFn<TParentData, TName, TData>, TOnSubmitAsync extends undefined | FormGroupAsyncValidateOrFn<TParentData, TName, TData>, TOnDynamic extends undefined | FormGroupValidateOrFn<TParentData, TName, TData>, TOnDynamicAsync extends undefined | FormGroupAsyncValidateOrFn<TParentData, TName, TData>, TSubmitMeta>(internal: any, { children, ...formGroupOptions }: Omit<FormGroupComponentProps<TParentData, TName, TData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TSubmitMeta, TFormOnMount, TFormOnChange, TFormOnChangeAsync, TFormOnBlur, TFormOnBlurAsync, TFormOnSubmit, TFormOnSubmitAsync, TFormOnDynamic, TFormOnDynamicAsync, TFormOnServer, TParentSubmitMeta, ExtendedApi>, 'form'>) => {}) & (new <TName extends DeepKeys<TParentData>, TData extends DeepValue<TParentData, TName>, TOnMount extends undefined | FormGroupValidateOrFn<TParentData, TName, TData>, TOnChange extends undefined | FormGroupValidateOrFn<TParentData, TName, TData>, TOnChangeAsync extends undefined | FormGroupAsyncValidateOrFn<TParentData, TName, TData>, TOnBlur extends undefined | FormGroupValidateOrFn<TParentData, TName, TData>, TOnBlurAsync extends undefined | FormGroupAsyncValidateOrFn<TParentData, TName, TData>, TOnSubmit extends undefined | FormGroupValidateOrFn<TParentData, TName, TData>, TOnSubmitAsync extends undefined | FormGroupAsyncValidateOrFn<TParentData, TName, TData>, TOnDynamic extends undefined | FormGroupValidateOrFn<TParentData, TName, TData>, TOnDynamicAsync extends undefined | FormGroupAsyncValidateOrFn<TParentData, TName, TData>, TSubmitMeta>(opts: ComponentConstructorOptions<Omit<FormGroupComponentProps<TParentData, TName, TData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TSubmitMeta, TFormOnMount, TFormOnChange, TFormOnChangeAsync, TFormOnBlur, TFormOnBlurAsync, TFormOnSubmit, TFormOnSubmitAsync, TFormOnDynamic, TFormOnDynamicAsync, TFormOnServer, TParentSubmitMeta, ExtendedApi>, 'form'>>) => SvelteComponent) & WithoutFunction<Component>;
|
|
16
|
-
type FormGroupComponentProps<TParentData, TName extends DeepKeys<TParentData>, TData extends DeepValue<TParentData, TName>, TOnMount extends undefined | FormGroupValidateOrFn<TParentData, TName, TData>, TOnChange extends undefined | FormGroupValidateOrFn<TParentData, TName, TData>, TOnChangeAsync extends undefined | FormGroupAsyncValidateOrFn<TParentData, TName, TData>, TOnBlur extends undefined | FormGroupValidateOrFn<TParentData, TName, TData>, TOnBlurAsync extends undefined | FormGroupAsyncValidateOrFn<TParentData, TName, TData>, TOnSubmit extends undefined | FormGroupValidateOrFn<TParentData, TName, TData>, TOnSubmitAsync extends undefined | FormGroupAsyncValidateOrFn<TParentData, TName, TData>, TOnDynamic extends undefined | FormGroupValidateOrFn<TParentData, TName, TData>, TOnDynamicAsync extends undefined | FormGroupAsyncValidateOrFn<TParentData, TName, TData>, TSubmitMeta, TFormOnMount extends undefined | FormValidateOrFn<TParentData>, TFormOnChange extends undefined | FormValidateOrFn<TParentData>, TFormOnChangeAsync extends undefined | FormAsyncValidateOrFn<TParentData>, TFormOnBlur extends undefined | FormValidateOrFn<TParentData>, TFormOnBlurAsync extends undefined | FormAsyncValidateOrFn<TParentData>, TFormOnSubmit extends undefined | FormValidateOrFn<TParentData>, TFormOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TParentData>, TFormOnDynamic extends undefined | FormValidateOrFn<TParentData>, TFormOnDynamicAsync extends undefined | FormAsyncValidateOrFn<TParentData>, TFormOnServer extends undefined | FormAsyncValidateOrFn<TParentData>, TParentSubmitMeta, ExtendedApi = {}> = {
|
|
17
|
-
children: Snippet<[
|
|
18
|
-
FormGroupApi<TParentData, TName, TData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TSubmitMeta, TFormOnMount, TFormOnChange, TFormOnChangeAsync, TFormOnBlur, TFormOnBlurAsync, TFormOnSubmit, TFormOnSubmitAsync, TFormOnDynamic, TFormOnDynamicAsync, TFormOnServer, TParentSubmitMeta> & ExtendedApi
|
|
19
|
-
]>;
|
|
20
|
-
} & FormGroupApiOptions<TParentData, TName, TData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TSubmitMeta, TFormOnMount, TFormOnChange, TFormOnChangeAsync, TFormOnBlur, TFormOnBlurAsync, TFormOnSubmit, TFormOnSubmitAsync, TFormOnDynamic, TFormOnDynamicAsync, TFormOnServer, TParentSubmitMeta>;
|
|
21
|
-
export {};
|
package/src/AppField.svelte
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
<!-- Take "form" as an prop, pass it to context, and render children -->
|
|
2
|
-
<script lang="ts">
|
|
3
|
-
import type { Snippet } from 'svelte'
|
|
4
|
-
import InnerAppField from './InnerAppField.svelte'
|
|
5
|
-
|
|
6
|
-
interface Props {
|
|
7
|
-
form: any
|
|
8
|
-
fieldComponents: any
|
|
9
|
-
children: Snippet
|
|
10
|
-
fieldProps: any
|
|
11
|
-
}
|
|
12
|
-
const { children: childrenProp, form, fieldComponents, fieldProps }: Props = $props()
|
|
13
|
-
</script>
|
|
14
|
-
|
|
15
|
-
<form.Field {...fieldProps}>
|
|
16
|
-
{#snippet children(field: any)}
|
|
17
|
-
<InnerAppField field={field} children={childrenProp} fieldComponents={fieldComponents}/>
|
|
18
|
-
{/snippet}
|
|
19
|
-
</form.Field>
|
package/src/AppForm.svelte
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
<!-- Take "form" as an prop, pass it to context, and render children -->
|
|
2
|
-
<script lang="ts">
|
|
3
|
-
import { setContext, type Snippet } from 'svelte'
|
|
4
|
-
import { formContextKey } from './context-keys.js'
|
|
5
|
-
|
|
6
|
-
interface Props {
|
|
7
|
-
form: any
|
|
8
|
-
children: Snippet
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const { children, form }: Props = $props()
|
|
12
|
-
|
|
13
|
-
setContext(formContextKey, form)
|
|
14
|
-
</script>
|
|
15
|
-
|
|
16
|
-
{@render children?.()}
|