@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
package/src/Field.svelte
DELETED
|
@@ -1,341 +0,0 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
type DeepKeys,
|
|
4
|
-
type DeepValue,
|
|
5
|
-
FieldApi,
|
|
6
|
-
type FieldAsyncValidateOrFn,
|
|
7
|
-
type FieldValidateOrFn,
|
|
8
|
-
type FormAsyncValidateOrFn,
|
|
9
|
-
type FormValidateOrFn,
|
|
10
|
-
} from '@tanstack/form-core'
|
|
11
|
-
import { useSelector } from '@tanstack/svelte-store'
|
|
12
|
-
import { onMount, type Snippet } from 'svelte'
|
|
13
|
-
import type { CreateFieldOptions } from './types.js'
|
|
14
|
-
|
|
15
|
-
export function createField<
|
|
16
|
-
TParentData,
|
|
17
|
-
TName extends DeepKeys<TParentData>,
|
|
18
|
-
TData extends DeepValue<TParentData, TName>,
|
|
19
|
-
TOnMount extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
20
|
-
TOnChange extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
21
|
-
TOnChangeAsync extends
|
|
22
|
-
| undefined
|
|
23
|
-
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
24
|
-
TOnBlur extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
25
|
-
TOnBlurAsync extends
|
|
26
|
-
| undefined
|
|
27
|
-
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
28
|
-
TOnSubmit extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
29
|
-
TOnSubmitAsync extends
|
|
30
|
-
| undefined
|
|
31
|
-
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
32
|
-
TOnDynamic extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
33
|
-
TOnDynamicAsync extends
|
|
34
|
-
| undefined
|
|
35
|
-
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
36
|
-
TFormOnMount extends undefined | FormValidateOrFn<TParentData>,
|
|
37
|
-
TFormOnChange extends undefined | FormValidateOrFn<TParentData>,
|
|
38
|
-
TFormOnChangeAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
39
|
-
TFormOnBlur extends undefined | FormValidateOrFn<TParentData>,
|
|
40
|
-
TFormOnBlurAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
41
|
-
TFormOnSubmit extends undefined | FormValidateOrFn<TParentData>,
|
|
42
|
-
TFormOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
43
|
-
TFormOnDynamic extends undefined | FormValidateOrFn<TParentData>,
|
|
44
|
-
TFormOnDynamicAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
45
|
-
TFormOnServer extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
46
|
-
TParentSubmitMeta,
|
|
47
|
-
>(
|
|
48
|
-
opts: () => CreateFieldOptions<
|
|
49
|
-
TParentData,
|
|
50
|
-
TName,
|
|
51
|
-
TData,
|
|
52
|
-
TOnMount,
|
|
53
|
-
TOnChange,
|
|
54
|
-
TOnChangeAsync,
|
|
55
|
-
TOnBlur,
|
|
56
|
-
TOnBlurAsync,
|
|
57
|
-
TOnSubmit,
|
|
58
|
-
TOnSubmitAsync,
|
|
59
|
-
TOnDynamic,
|
|
60
|
-
TOnDynamicAsync,
|
|
61
|
-
TFormOnMount,
|
|
62
|
-
TFormOnChange,
|
|
63
|
-
TFormOnChangeAsync,
|
|
64
|
-
TFormOnBlur,
|
|
65
|
-
TFormOnBlurAsync,
|
|
66
|
-
TFormOnSubmit,
|
|
67
|
-
TFormOnSubmitAsync,
|
|
68
|
-
TFormOnDynamic,
|
|
69
|
-
TFormOnDynamicAsync,
|
|
70
|
-
TFormOnServer,
|
|
71
|
-
TParentSubmitMeta
|
|
72
|
-
>,
|
|
73
|
-
) {
|
|
74
|
-
const options = opts()
|
|
75
|
-
|
|
76
|
-
const api = new FieldApi(options)
|
|
77
|
-
|
|
78
|
-
const extendedApi: typeof api = api as never
|
|
79
|
-
|
|
80
|
-
let mounted = false
|
|
81
|
-
// Instantiates field meta and removes it when unrendered
|
|
82
|
-
onMount(() => {
|
|
83
|
-
const cleanupFn = api.mount()
|
|
84
|
-
mounted = true
|
|
85
|
-
return () => {
|
|
86
|
-
cleanupFn()
|
|
87
|
-
mounted = false
|
|
88
|
-
}
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
$effect.pre(() => {
|
|
92
|
-
// Invoke options function before mounted check, else it wouldn't rerun on changes to options.
|
|
93
|
-
// Changes to options are seen by the effect because signals inside them are picked up.
|
|
94
|
-
const current = opts()
|
|
95
|
-
if (!mounted) return
|
|
96
|
-
api.update(current)
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
const storeSub = useSelector(api.store, (state) =>
|
|
100
|
-
options.mode === 'array'
|
|
101
|
-
? state.meta._arrayVersion || 0
|
|
102
|
-
: state.value,
|
|
103
|
-
)
|
|
104
|
-
const metaIsTouchedSub = useSelector(
|
|
105
|
-
api.store,
|
|
106
|
-
(state) => state.meta.isTouched,
|
|
107
|
-
)
|
|
108
|
-
const metaIsBlurredSub = useSelector(
|
|
109
|
-
api.store,
|
|
110
|
-
(state) => state.meta.isBlurred,
|
|
111
|
-
)
|
|
112
|
-
const metaIsDirtySub = useSelector(api.store, (state) => state.meta.isDirty)
|
|
113
|
-
const metaErrorMapSub = useSelector(api.store, (state) => state.meta.errorMap)
|
|
114
|
-
const metaErrorSourceMapSub = useSelector(
|
|
115
|
-
api.store,
|
|
116
|
-
(state) => state.meta.errorSourceMap,
|
|
117
|
-
)
|
|
118
|
-
const metaIsValidatingSub = useSelector(
|
|
119
|
-
api.store,
|
|
120
|
-
(state) => state.meta.isValidating,
|
|
121
|
-
)
|
|
122
|
-
Object.defineProperty(extendedApi, 'state', {
|
|
123
|
-
get() {
|
|
124
|
-
// Read all reactive sources to track them as dependencies. For array
|
|
125
|
-
// mode, `storeSub.current` is the array length so we still pull the
|
|
126
|
-
// actual value from the underlying api state.
|
|
127
|
-
// See: https://github.com/TanStack/form/issues/1961
|
|
128
|
-
// Note: we read from `api.store.state` (not `api.state`) to avoid
|
|
129
|
-
// infinite recursion since this getter shadows the prototype's `state`
|
|
130
|
-
// getter on the same object.
|
|
131
|
-
const trackedValue = storeSub.current
|
|
132
|
-
const isTouched = metaIsTouchedSub.current
|
|
133
|
-
const isBlurred = metaIsBlurredSub.current
|
|
134
|
-
const isDirty = metaIsDirtySub.current
|
|
135
|
-
const errorMap = metaErrorMapSub.current
|
|
136
|
-
const errorSourceMap = metaErrorSourceMapSub.current
|
|
137
|
-
const isValidating = metaIsValidatingSub.current
|
|
138
|
-
const baseState = api.store.state
|
|
139
|
-
return {
|
|
140
|
-
...baseState,
|
|
141
|
-
value: options.mode === 'array' ? baseState.value : trackedValue,
|
|
142
|
-
meta: {
|
|
143
|
-
...baseState.meta,
|
|
144
|
-
isTouched,
|
|
145
|
-
isBlurred,
|
|
146
|
-
isDirty,
|
|
147
|
-
errorMap,
|
|
148
|
-
errorSourceMap,
|
|
149
|
-
isValidating,
|
|
150
|
-
},
|
|
151
|
-
}
|
|
152
|
-
},
|
|
153
|
-
})
|
|
154
|
-
|
|
155
|
-
return extendedApi
|
|
156
|
-
}
|
|
157
|
-
</script>
|
|
158
|
-
|
|
159
|
-
<script
|
|
160
|
-
lang="ts"
|
|
161
|
-
generics="
|
|
162
|
-
TParentData,
|
|
163
|
-
TName extends DeepKeys<TParentData>,
|
|
164
|
-
TData extends DeepValue<TParentData, TName>,
|
|
165
|
-
TOnMount extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
166
|
-
TOnChange extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
167
|
-
TOnChangeAsync extends
|
|
168
|
-
| undefined
|
|
169
|
-
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
170
|
-
TOnBlur extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
171
|
-
TOnBlurAsync extends
|
|
172
|
-
| undefined
|
|
173
|
-
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
174
|
-
TOnSubmit extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
175
|
-
TOnSubmitAsync extends
|
|
176
|
-
| undefined
|
|
177
|
-
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
178
|
-
TOnDynamic extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
179
|
-
TOnDynamicAsync extends
|
|
180
|
-
| undefined
|
|
181
|
-
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
182
|
-
TFormOnMount extends undefined | FormValidateOrFn<TParentData>,
|
|
183
|
-
TFormOnChange extends undefined | FormValidateOrFn<TParentData>,
|
|
184
|
-
TFormOnChangeAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
185
|
-
TFormOnBlur extends undefined | FormValidateOrFn<TParentData>,
|
|
186
|
-
TFormOnBlurAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
187
|
-
TFormOnSubmit extends undefined | FormValidateOrFn<TParentData>,
|
|
188
|
-
TFormOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
189
|
-
TFormOnDynamic extends undefined | FormValidateOrFn<TParentData>,
|
|
190
|
-
TFormOnDynamicAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
191
|
-
TFormOnServer extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
192
|
-
TParentSubmitMeta,
|
|
193
|
-
"
|
|
194
|
-
>
|
|
195
|
-
type Props<
|
|
196
|
-
TParentData,
|
|
197
|
-
TName extends DeepKeys<TParentData>,
|
|
198
|
-
TData extends DeepValue<TParentData, TName>,
|
|
199
|
-
TOnMount extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
200
|
-
TOnChange extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
201
|
-
TOnChangeAsync extends
|
|
202
|
-
| undefined
|
|
203
|
-
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
204
|
-
TOnBlur extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
205
|
-
TOnBlurAsync extends
|
|
206
|
-
| undefined
|
|
207
|
-
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
208
|
-
TOnSubmit extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
209
|
-
TOnSubmitAsync extends
|
|
210
|
-
| undefined
|
|
211
|
-
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
212
|
-
TOnDynamic extends undefined | FieldValidateOrFn<TParentData, TName, TData>,
|
|
213
|
-
TOnDynamicAsync extends
|
|
214
|
-
| undefined
|
|
215
|
-
| FieldAsyncValidateOrFn<TParentData, TName, TData>,
|
|
216
|
-
TFormOnMount extends undefined | FormValidateOrFn<TParentData>,
|
|
217
|
-
TFormOnChange extends undefined | FormValidateOrFn<TParentData>,
|
|
218
|
-
TFormOnChangeAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
219
|
-
TFormOnBlur extends undefined | FormValidateOrFn<TParentData>,
|
|
220
|
-
TFormOnBlurAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
221
|
-
TFormOnSubmit extends undefined | FormValidateOrFn<TParentData>,
|
|
222
|
-
TFormOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
223
|
-
TFormOnDynamic extends undefined | FormValidateOrFn<TParentData>,
|
|
224
|
-
TFormOnDynamicAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
225
|
-
TFormOnServer extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
226
|
-
TParentSubmitMeta,
|
|
227
|
-
> = {
|
|
228
|
-
children: Snippet<
|
|
229
|
-
[
|
|
230
|
-
FieldApi<
|
|
231
|
-
TParentData,
|
|
232
|
-
TName,
|
|
233
|
-
TData,
|
|
234
|
-
TOnMount,
|
|
235
|
-
TOnChange,
|
|
236
|
-
TOnChangeAsync,
|
|
237
|
-
TOnBlur,
|
|
238
|
-
TOnBlurAsync,
|
|
239
|
-
TOnSubmit,
|
|
240
|
-
TOnSubmitAsync,
|
|
241
|
-
TOnDynamic,
|
|
242
|
-
TOnDynamicAsync,
|
|
243
|
-
TFormOnMount,
|
|
244
|
-
TFormOnChange,
|
|
245
|
-
TFormOnChangeAsync,
|
|
246
|
-
TFormOnBlur,
|
|
247
|
-
TFormOnBlurAsync,
|
|
248
|
-
TFormOnSubmit,
|
|
249
|
-
TFormOnSubmitAsync,
|
|
250
|
-
TFormOnDynamic,
|
|
251
|
-
TFormOnDynamicAsync,
|
|
252
|
-
TFormOnServer,
|
|
253
|
-
TParentSubmitMeta
|
|
254
|
-
>,
|
|
255
|
-
]
|
|
256
|
-
>
|
|
257
|
-
} & CreateFieldOptions<
|
|
258
|
-
TParentData,
|
|
259
|
-
TName,
|
|
260
|
-
TData,
|
|
261
|
-
TOnMount,
|
|
262
|
-
TOnChange,
|
|
263
|
-
TOnChangeAsync,
|
|
264
|
-
TOnBlur,
|
|
265
|
-
TOnBlurAsync,
|
|
266
|
-
TOnSubmit,
|
|
267
|
-
TOnSubmitAsync,
|
|
268
|
-
TOnDynamic,
|
|
269
|
-
TOnDynamicAsync,
|
|
270
|
-
TFormOnMount,
|
|
271
|
-
TFormOnChange,
|
|
272
|
-
TFormOnChangeAsync,
|
|
273
|
-
TFormOnBlur,
|
|
274
|
-
TFormOnBlurAsync,
|
|
275
|
-
TFormOnSubmit,
|
|
276
|
-
TFormOnSubmitAsync,
|
|
277
|
-
TFormOnDynamic,
|
|
278
|
-
TFormOnDynamicAsync,
|
|
279
|
-
TFormOnServer,
|
|
280
|
-
TParentSubmitMeta
|
|
281
|
-
>
|
|
282
|
-
|
|
283
|
-
let {
|
|
284
|
-
children,
|
|
285
|
-
...fieldOptions
|
|
286
|
-
}: Props<
|
|
287
|
-
TParentData,
|
|
288
|
-
TName,
|
|
289
|
-
TData,
|
|
290
|
-
TOnMount,
|
|
291
|
-
TOnChange,
|
|
292
|
-
TOnChangeAsync,
|
|
293
|
-
TOnBlur,
|
|
294
|
-
TOnBlurAsync,
|
|
295
|
-
TOnSubmit,
|
|
296
|
-
TOnSubmitAsync,
|
|
297
|
-
TOnDynamic,
|
|
298
|
-
TOnDynamicAsync,
|
|
299
|
-
TFormOnMount,
|
|
300
|
-
TFormOnChange,
|
|
301
|
-
TFormOnChangeAsync,
|
|
302
|
-
TFormOnBlur,
|
|
303
|
-
TFormOnBlurAsync,
|
|
304
|
-
TFormOnSubmit,
|
|
305
|
-
TFormOnSubmitAsync,
|
|
306
|
-
TFormOnDynamic,
|
|
307
|
-
TFormOnDynamicAsync,
|
|
308
|
-
TFormOnServer,
|
|
309
|
-
TParentSubmitMeta
|
|
310
|
-
> = $props()
|
|
311
|
-
|
|
312
|
-
const fieldApi = createField<
|
|
313
|
-
TParentData,
|
|
314
|
-
TName,
|
|
315
|
-
TData,
|
|
316
|
-
TOnMount,
|
|
317
|
-
TOnChange,
|
|
318
|
-
TOnChangeAsync,
|
|
319
|
-
TOnBlur,
|
|
320
|
-
TOnBlurAsync,
|
|
321
|
-
TOnSubmit,
|
|
322
|
-
TOnSubmitAsync,
|
|
323
|
-
TOnDynamic,
|
|
324
|
-
TOnDynamicAsync,
|
|
325
|
-
TFormOnMount,
|
|
326
|
-
TFormOnChange,
|
|
327
|
-
TFormOnChangeAsync,
|
|
328
|
-
TFormOnBlur,
|
|
329
|
-
TFormOnBlurAsync,
|
|
330
|
-
TFormOnSubmit,
|
|
331
|
-
TFormOnSubmitAsync,
|
|
332
|
-
TFormOnDynamic,
|
|
333
|
-
TFormOnDynamicAsync,
|
|
334
|
-
TFormOnServer,
|
|
335
|
-
TParentSubmitMeta
|
|
336
|
-
>(() => {
|
|
337
|
-
return fieldOptions
|
|
338
|
-
})
|
|
339
|
-
</script>
|
|
340
|
-
|
|
341
|
-
{@render children(fieldApi)}
|
package/src/FormGroup.svelte
DELETED
|
@@ -1,322 +0,0 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
type DeepKeys,
|
|
4
|
-
type DeepValue,
|
|
5
|
-
FormGroupApi,
|
|
6
|
-
type FormGroupApiOptions,
|
|
7
|
-
type FormGroupAsyncValidateOrFn,
|
|
8
|
-
type FormGroupValidateOrFn,
|
|
9
|
-
type FormAsyncValidateOrFn,
|
|
10
|
-
type FormValidateOrFn,
|
|
11
|
-
} from '@tanstack/form-core'
|
|
12
|
-
import { useSelector } from '@tanstack/svelte-store'
|
|
13
|
-
import { onMount, type Snippet } from 'svelte'
|
|
14
|
-
|
|
15
|
-
export function createFormGroup<
|
|
16
|
-
TParentData,
|
|
17
|
-
TName extends DeepKeys<TParentData>,
|
|
18
|
-
TData extends DeepValue<TParentData, TName>,
|
|
19
|
-
TOnMount extends
|
|
20
|
-
| undefined
|
|
21
|
-
| FormGroupValidateOrFn<TParentData, TName, TData>,
|
|
22
|
-
TOnChange extends
|
|
23
|
-
| undefined
|
|
24
|
-
| FormGroupValidateOrFn<TParentData, TName, TData>,
|
|
25
|
-
TOnChangeAsync extends
|
|
26
|
-
| undefined
|
|
27
|
-
| FormGroupAsyncValidateOrFn<TParentData, TName, TData>,
|
|
28
|
-
TOnBlur extends
|
|
29
|
-
| undefined
|
|
30
|
-
| FormGroupValidateOrFn<TParentData, TName, TData>,
|
|
31
|
-
TOnBlurAsync extends
|
|
32
|
-
| undefined
|
|
33
|
-
| FormGroupAsyncValidateOrFn<TParentData, TName, TData>,
|
|
34
|
-
TOnSubmit extends
|
|
35
|
-
| undefined
|
|
36
|
-
| FormGroupValidateOrFn<TParentData, TName, TData>,
|
|
37
|
-
TOnSubmitAsync extends
|
|
38
|
-
| undefined
|
|
39
|
-
| FormGroupAsyncValidateOrFn<TParentData, TName, TData>,
|
|
40
|
-
TOnDynamic extends
|
|
41
|
-
| undefined
|
|
42
|
-
| FormGroupValidateOrFn<TParentData, TName, TData>,
|
|
43
|
-
TOnDynamicAsync extends
|
|
44
|
-
| undefined
|
|
45
|
-
| FormGroupAsyncValidateOrFn<TParentData, TName, TData>,
|
|
46
|
-
TSubmitMeta,
|
|
47
|
-
TFormOnMount extends undefined | FormValidateOrFn<TParentData>,
|
|
48
|
-
TFormOnChange extends undefined | FormValidateOrFn<TParentData>,
|
|
49
|
-
TFormOnChangeAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
50
|
-
TFormOnBlur extends undefined | FormValidateOrFn<TParentData>,
|
|
51
|
-
TFormOnBlurAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
52
|
-
TFormOnSubmit extends undefined | FormValidateOrFn<TParentData>,
|
|
53
|
-
TFormOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
54
|
-
TFormOnDynamic extends undefined | FormValidateOrFn<TParentData>,
|
|
55
|
-
TFormOnDynamicAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
56
|
-
TFormOnServer extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
57
|
-
TParentSubmitMeta,
|
|
58
|
-
>(
|
|
59
|
-
opts: () => FormGroupApiOptions<
|
|
60
|
-
TParentData,
|
|
61
|
-
TName,
|
|
62
|
-
TData,
|
|
63
|
-
TOnMount,
|
|
64
|
-
TOnChange,
|
|
65
|
-
TOnChangeAsync,
|
|
66
|
-
TOnBlur,
|
|
67
|
-
TOnBlurAsync,
|
|
68
|
-
TOnSubmit,
|
|
69
|
-
TOnSubmitAsync,
|
|
70
|
-
TOnDynamic,
|
|
71
|
-
TOnDynamicAsync,
|
|
72
|
-
TSubmitMeta,
|
|
73
|
-
TFormOnMount,
|
|
74
|
-
TFormOnChange,
|
|
75
|
-
TFormOnChangeAsync,
|
|
76
|
-
TFormOnBlur,
|
|
77
|
-
TFormOnBlurAsync,
|
|
78
|
-
TFormOnSubmit,
|
|
79
|
-
TFormOnSubmitAsync,
|
|
80
|
-
TFormOnDynamic,
|
|
81
|
-
TFormOnDynamicAsync,
|
|
82
|
-
TFormOnServer,
|
|
83
|
-
TParentSubmitMeta
|
|
84
|
-
>,
|
|
85
|
-
) {
|
|
86
|
-
const options = opts()
|
|
87
|
-
|
|
88
|
-
const api = new FormGroupApi(options)
|
|
89
|
-
|
|
90
|
-
const extendedApi: typeof api = api as never
|
|
91
|
-
|
|
92
|
-
let mounted = false
|
|
93
|
-
// Instantiates form group meta and removes it when unrendered
|
|
94
|
-
onMount(() => {
|
|
95
|
-
const cleanupFn = api.mount()
|
|
96
|
-
mounted = true
|
|
97
|
-
return () => {
|
|
98
|
-
cleanupFn()
|
|
99
|
-
mounted = false
|
|
100
|
-
}
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
$effect.pre(() => {
|
|
104
|
-
// Invoke options function before mounted check, else it wouldn't rerun on changes to options.
|
|
105
|
-
// Changes to options are seen by the effect because signals inside them are picked up.
|
|
106
|
-
const current = opts()
|
|
107
|
-
if (!mounted) return
|
|
108
|
-
api.update(current)
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
const storeSub = useSelector(api.store)
|
|
112
|
-
Object.defineProperty(extendedApi, 'state', {
|
|
113
|
-
get() {
|
|
114
|
-
return storeSub.current
|
|
115
|
-
},
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
return extendedApi
|
|
119
|
-
}
|
|
120
|
-
</script>
|
|
121
|
-
|
|
122
|
-
<script
|
|
123
|
-
lang="ts"
|
|
124
|
-
generics="
|
|
125
|
-
TParentData,
|
|
126
|
-
TName extends DeepKeys<TParentData>,
|
|
127
|
-
TData extends DeepValue<TParentData, TName>,
|
|
128
|
-
TOnMount extends undefined | FormGroupValidateOrFn<TParentData, TName, TData>,
|
|
129
|
-
TOnChange extends undefined | FormGroupValidateOrFn<TParentData, TName, TData>,
|
|
130
|
-
TOnChangeAsync extends
|
|
131
|
-
| undefined
|
|
132
|
-
| FormGroupAsyncValidateOrFn<TParentData, TName, TData>,
|
|
133
|
-
TOnBlur extends undefined | FormGroupValidateOrFn<TParentData, TName, TData>,
|
|
134
|
-
TOnBlurAsync extends
|
|
135
|
-
| undefined
|
|
136
|
-
| FormGroupAsyncValidateOrFn<TParentData, TName, TData>,
|
|
137
|
-
TOnSubmit extends undefined | FormGroupValidateOrFn<TParentData, TName, TData>,
|
|
138
|
-
TOnSubmitAsync extends
|
|
139
|
-
| undefined
|
|
140
|
-
| FormGroupAsyncValidateOrFn<TParentData, TName, TData>,
|
|
141
|
-
TOnDynamic extends undefined | FormGroupValidateOrFn<TParentData, TName, TData>,
|
|
142
|
-
TOnDynamicAsync extends
|
|
143
|
-
| undefined
|
|
144
|
-
| FormGroupAsyncValidateOrFn<TParentData, TName, TData>,
|
|
145
|
-
TSubmitMeta,
|
|
146
|
-
TFormOnMount extends undefined | FormValidateOrFn<TParentData>,
|
|
147
|
-
TFormOnChange extends undefined | FormValidateOrFn<TParentData>,
|
|
148
|
-
TFormOnChangeAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
149
|
-
TFormOnBlur extends undefined | FormValidateOrFn<TParentData>,
|
|
150
|
-
TFormOnBlurAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
151
|
-
TFormOnSubmit extends undefined | FormValidateOrFn<TParentData>,
|
|
152
|
-
TFormOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
153
|
-
TFormOnDynamic extends undefined | FormValidateOrFn<TParentData>,
|
|
154
|
-
TFormOnDynamicAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
155
|
-
TFormOnServer extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
156
|
-
TParentSubmitMeta,
|
|
157
|
-
"
|
|
158
|
-
>
|
|
159
|
-
import type { FormGroupApi as FormGroupApiType } from '@tanstack/form-core'
|
|
160
|
-
|
|
161
|
-
type Props<
|
|
162
|
-
TParentData,
|
|
163
|
-
TName extends DeepKeys<TParentData>,
|
|
164
|
-
TData extends DeepValue<TParentData, TName>,
|
|
165
|
-
TOnMount extends
|
|
166
|
-
| undefined
|
|
167
|
-
| FormGroupValidateOrFn<TParentData, TName, TData>,
|
|
168
|
-
TOnChange extends
|
|
169
|
-
| undefined
|
|
170
|
-
| FormGroupValidateOrFn<TParentData, TName, TData>,
|
|
171
|
-
TOnChangeAsync extends
|
|
172
|
-
| undefined
|
|
173
|
-
| FormGroupAsyncValidateOrFn<TParentData, TName, TData>,
|
|
174
|
-
TOnBlur extends
|
|
175
|
-
| undefined
|
|
176
|
-
| FormGroupValidateOrFn<TParentData, TName, TData>,
|
|
177
|
-
TOnBlurAsync extends
|
|
178
|
-
| undefined
|
|
179
|
-
| FormGroupAsyncValidateOrFn<TParentData, TName, TData>,
|
|
180
|
-
TOnSubmit extends
|
|
181
|
-
| undefined
|
|
182
|
-
| FormGroupValidateOrFn<TParentData, TName, TData>,
|
|
183
|
-
TOnSubmitAsync extends
|
|
184
|
-
| undefined
|
|
185
|
-
| FormGroupAsyncValidateOrFn<TParentData, TName, TData>,
|
|
186
|
-
TOnDynamic extends
|
|
187
|
-
| undefined
|
|
188
|
-
| FormGroupValidateOrFn<TParentData, TName, TData>,
|
|
189
|
-
TOnDynamicAsync extends
|
|
190
|
-
| undefined
|
|
191
|
-
| FormGroupAsyncValidateOrFn<TParentData, TName, TData>,
|
|
192
|
-
TSubmitMeta,
|
|
193
|
-
TFormOnMount extends undefined | FormValidateOrFn<TParentData>,
|
|
194
|
-
TFormOnChange extends undefined | FormValidateOrFn<TParentData>,
|
|
195
|
-
TFormOnChangeAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
196
|
-
TFormOnBlur extends undefined | FormValidateOrFn<TParentData>,
|
|
197
|
-
TFormOnBlurAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
198
|
-
TFormOnSubmit extends undefined | FormValidateOrFn<TParentData>,
|
|
199
|
-
TFormOnSubmitAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
200
|
-
TFormOnDynamic extends undefined | FormValidateOrFn<TParentData>,
|
|
201
|
-
TFormOnDynamicAsync extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
202
|
-
TFormOnServer extends undefined | FormAsyncValidateOrFn<TParentData>,
|
|
203
|
-
TParentSubmitMeta,
|
|
204
|
-
> = {
|
|
205
|
-
children: Snippet<
|
|
206
|
-
[
|
|
207
|
-
FormGroupApiType<
|
|
208
|
-
TParentData,
|
|
209
|
-
TName,
|
|
210
|
-
TData,
|
|
211
|
-
TOnMount,
|
|
212
|
-
TOnChange,
|
|
213
|
-
TOnChangeAsync,
|
|
214
|
-
TOnBlur,
|
|
215
|
-
TOnBlurAsync,
|
|
216
|
-
TOnSubmit,
|
|
217
|
-
TOnSubmitAsync,
|
|
218
|
-
TOnDynamic,
|
|
219
|
-
TOnDynamicAsync,
|
|
220
|
-
TSubmitMeta,
|
|
221
|
-
TFormOnMount,
|
|
222
|
-
TFormOnChange,
|
|
223
|
-
TFormOnChangeAsync,
|
|
224
|
-
TFormOnBlur,
|
|
225
|
-
TFormOnBlurAsync,
|
|
226
|
-
TFormOnSubmit,
|
|
227
|
-
TFormOnSubmitAsync,
|
|
228
|
-
TFormOnDynamic,
|
|
229
|
-
TFormOnDynamicAsync,
|
|
230
|
-
TFormOnServer,
|
|
231
|
-
TParentSubmitMeta
|
|
232
|
-
>,
|
|
233
|
-
]
|
|
234
|
-
>
|
|
235
|
-
} & FormGroupApiOptions<
|
|
236
|
-
TParentData,
|
|
237
|
-
TName,
|
|
238
|
-
TData,
|
|
239
|
-
TOnMount,
|
|
240
|
-
TOnChange,
|
|
241
|
-
TOnChangeAsync,
|
|
242
|
-
TOnBlur,
|
|
243
|
-
TOnBlurAsync,
|
|
244
|
-
TOnSubmit,
|
|
245
|
-
TOnSubmitAsync,
|
|
246
|
-
TOnDynamic,
|
|
247
|
-
TOnDynamicAsync,
|
|
248
|
-
TSubmitMeta,
|
|
249
|
-
TFormOnMount,
|
|
250
|
-
TFormOnChange,
|
|
251
|
-
TFormOnChangeAsync,
|
|
252
|
-
TFormOnBlur,
|
|
253
|
-
TFormOnBlurAsync,
|
|
254
|
-
TFormOnSubmit,
|
|
255
|
-
TFormOnSubmitAsync,
|
|
256
|
-
TFormOnDynamic,
|
|
257
|
-
TFormOnDynamicAsync,
|
|
258
|
-
TFormOnServer,
|
|
259
|
-
TParentSubmitMeta
|
|
260
|
-
>
|
|
261
|
-
|
|
262
|
-
let {
|
|
263
|
-
children,
|
|
264
|
-
...formGroupOptions
|
|
265
|
-
}: Props<
|
|
266
|
-
TParentData,
|
|
267
|
-
TName,
|
|
268
|
-
TData,
|
|
269
|
-
TOnMount,
|
|
270
|
-
TOnChange,
|
|
271
|
-
TOnChangeAsync,
|
|
272
|
-
TOnBlur,
|
|
273
|
-
TOnBlurAsync,
|
|
274
|
-
TOnSubmit,
|
|
275
|
-
TOnSubmitAsync,
|
|
276
|
-
TOnDynamic,
|
|
277
|
-
TOnDynamicAsync,
|
|
278
|
-
TSubmitMeta,
|
|
279
|
-
TFormOnMount,
|
|
280
|
-
TFormOnChange,
|
|
281
|
-
TFormOnChangeAsync,
|
|
282
|
-
TFormOnBlur,
|
|
283
|
-
TFormOnBlurAsync,
|
|
284
|
-
TFormOnSubmit,
|
|
285
|
-
TFormOnSubmitAsync,
|
|
286
|
-
TFormOnDynamic,
|
|
287
|
-
TFormOnDynamicAsync,
|
|
288
|
-
TFormOnServer,
|
|
289
|
-
TParentSubmitMeta
|
|
290
|
-
> = $props()
|
|
291
|
-
|
|
292
|
-
const formGroupApi = createFormGroup<
|
|
293
|
-
TParentData,
|
|
294
|
-
TName,
|
|
295
|
-
TData,
|
|
296
|
-
TOnMount,
|
|
297
|
-
TOnChange,
|
|
298
|
-
TOnChangeAsync,
|
|
299
|
-
TOnBlur,
|
|
300
|
-
TOnBlurAsync,
|
|
301
|
-
TOnSubmit,
|
|
302
|
-
TOnSubmitAsync,
|
|
303
|
-
TOnDynamic,
|
|
304
|
-
TOnDynamicAsync,
|
|
305
|
-
TSubmitMeta,
|
|
306
|
-
TFormOnMount,
|
|
307
|
-
TFormOnChange,
|
|
308
|
-
TFormOnChangeAsync,
|
|
309
|
-
TFormOnBlur,
|
|
310
|
-
TFormOnBlurAsync,
|
|
311
|
-
TFormOnSubmit,
|
|
312
|
-
TFormOnSubmitAsync,
|
|
313
|
-
TFormOnDynamic,
|
|
314
|
-
TFormOnDynamicAsync,
|
|
315
|
-
TFormOnServer,
|
|
316
|
-
TParentSubmitMeta
|
|
317
|
-
>(() => {
|
|
318
|
-
return formGroupOptions
|
|
319
|
-
})
|
|
320
|
-
</script>
|
|
321
|
-
|
|
322
|
-
{@render children(formGroupApi)}
|
package/src/InnerAppField.svelte
DELETED
|
@@ -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))}
|
package/src/Subscribe.svelte
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { useSelector } from '@tanstack/svelte-store'
|
|
3
|
-
|
|
4
|
-
// Don't bother typing this out, this component is only usable through a wrapper
|
|
5
|
-
interface Props {
|
|
6
|
-
children: any
|
|
7
|
-
store: any
|
|
8
|
-
selector?: (state: any) => any
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
let { children, store, selector = (state) => state }: Props = $props()
|
|
12
|
-
|
|
13
|
-
const value = useSelector(store, selector)
|
|
14
|
-
</script>
|
|
15
|
-
|
|
16
|
-
{@render children(value.current)}
|
package/src/context-keys.ts
DELETED