@tanstack/react-form 0.0.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.
Files changed (40) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +35 -0
  3. package/build/cjs/Field.js +57 -0
  4. package/build/cjs/Field.js.map +1 -0
  5. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +33 -0
  6. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
  7. package/build/cjs/formContext.js +54 -0
  8. package/build/cjs/formContext.js.map +1 -0
  9. package/build/cjs/index.js +27 -0
  10. package/build/cjs/index.js.map +1 -0
  11. package/build/cjs/useField.js +71 -0
  12. package/build/cjs/useField.js.map +1 -0
  13. package/build/cjs/useForm.js +96 -0
  14. package/build/cjs/useForm.js.map +1 -0
  15. package/build/esm/index.js +160 -0
  16. package/build/esm/index.js.map +1 -0
  17. package/build/stats-html.html +2689 -0
  18. package/build/stats-react.json +367 -0
  19. package/build/types/form-core/src/FieldApi.d.ts +69 -0
  20. package/build/types/form-core/src/FormApi.d.ts +74 -0
  21. package/build/types/form-core/src/index.d.ts +3 -0
  22. package/build/types/form-core/src/utils.d.ts +16 -0
  23. package/build/types/index.d.ts +50 -0
  24. package/build/types/react-form/src/Field.d.ts +9 -0
  25. package/build/types/react-form/src/formContext.d.ts +4 -0
  26. package/build/types/react-form/src/index.d.ts +3 -0
  27. package/build/types/react-form/src/tests/test.test.d.ts +0 -0
  28. package/build/types/react-form/src/useField.d.ts +7 -0
  29. package/build/types/react-form/src/useForm.d.ts +25 -0
  30. package/build/umd/index.development.js +907 -0
  31. package/build/umd/index.development.js.map +1 -0
  32. package/build/umd/index.production.js +42 -0
  33. package/build/umd/index.production.js.map +1 -0
  34. package/package.json +55 -0
  35. package/src/Field.tsx +37 -0
  36. package/src/formContext.ts +18 -0
  37. package/src/index.ts +3 -0
  38. package/src/tests/test.test.tsx +5 -0
  39. package/src/useField.ts +54 -0
  40. package/src/useForm.tsx +125 -0
@@ -0,0 +1,367 @@
1
+ {
2
+ "version": 2,
3
+ "tree": {
4
+ "name": "root",
5
+ "children": [
6
+ {
7
+ "name": "index.production.js",
8
+ "children": [
9
+ {
10
+ "uid": "52cd-45",
11
+ "name": "\u0000rollupPluginBabelHelpers.js"
12
+ },
13
+ {
14
+ "name": "node_modules/.pnpm",
15
+ "children": [
16
+ {
17
+ "name": "@tanstack+store@0.0.1-beta.84/node_modules/@tanstack/store/build/esm/index.js",
18
+ "uid": "52cd-47"
19
+ },
20
+ {
21
+ "name": "@tanstack+react-store@0.0.1-beta.84_react-dom@18.2.0_react@18.2.0/node_modules/@tanstack/react-store/build/esm/index.js",
22
+ "uid": "52cd-51"
23
+ }
24
+ ]
25
+ },
26
+ {
27
+ "name": "packages",
28
+ "children": [
29
+ {
30
+ "name": "form-core/build/esm/index.js",
31
+ "uid": "52cd-49"
32
+ },
33
+ {
34
+ "name": "react-form/src",
35
+ "children": [
36
+ {
37
+ "uid": "52cd-53",
38
+ "name": "formContext.ts"
39
+ },
40
+ {
41
+ "uid": "52cd-55",
42
+ "name": "useField.ts"
43
+ },
44
+ {
45
+ "uid": "52cd-57",
46
+ "name": "Field.tsx"
47
+ },
48
+ {
49
+ "uid": "52cd-59",
50
+ "name": "useForm.tsx"
51
+ },
52
+ {
53
+ "uid": "52cd-61",
54
+ "name": "index.ts"
55
+ }
56
+ ]
57
+ }
58
+ ]
59
+ }
60
+ ]
61
+ }
62
+ ],
63
+ "isRoot": true
64
+ },
65
+ "nodeParts": {
66
+ "52cd-45": {
67
+ "renderedLength": 431,
68
+ "gzipLength": 240,
69
+ "brotliLength": 0,
70
+ "mainUid": "52cd-44"
71
+ },
72
+ "52cd-47": {
73
+ "renderedLength": 1288,
74
+ "gzipLength": 497,
75
+ "brotliLength": 0,
76
+ "mainUid": "52cd-46"
77
+ },
78
+ "52cd-49": {
79
+ "renderedLength": 20344,
80
+ "gzipLength": 4529,
81
+ "brotliLength": 0,
82
+ "mainUid": "52cd-48"
83
+ },
84
+ "52cd-51": {
85
+ "renderedLength": 978,
86
+ "gzipLength": 456,
87
+ "brotliLength": 0,
88
+ "mainUid": "52cd-50"
89
+ },
90
+ "52cd-53": {
91
+ "renderedLength": 369,
92
+ "gzipLength": 218,
93
+ "brotliLength": 0,
94
+ "mainUid": "52cd-52"
95
+ },
96
+ "52cd-55": {
97
+ "renderedLength": 850,
98
+ "gzipLength": 417,
99
+ "brotliLength": 0,
100
+ "mainUid": "52cd-54"
101
+ },
102
+ "52cd-57": {
103
+ "renderedLength": 370,
104
+ "gzipLength": 227,
105
+ "brotliLength": 0,
106
+ "mainUid": "52cd-56"
107
+ },
108
+ "52cd-59": {
109
+ "renderedLength": 2160,
110
+ "gzipLength": 767,
111
+ "brotliLength": 0,
112
+ "mainUid": "52cd-58"
113
+ },
114
+ "52cd-61": {
115
+ "renderedLength": 0,
116
+ "gzipLength": 0,
117
+ "brotliLength": 0,
118
+ "mainUid": "52cd-60"
119
+ }
120
+ },
121
+ "nodeMetas": {
122
+ "52cd-44": {
123
+ "id": "\u0000rollupPluginBabelHelpers.js",
124
+ "moduleParts": {
125
+ "index.production.js": "52cd-45"
126
+ },
127
+ "imported": [],
128
+ "importedBy": [
129
+ {
130
+ "uid": "52cd-58"
131
+ },
132
+ {
133
+ "uid": "52cd-56"
134
+ }
135
+ ]
136
+ },
137
+ "52cd-46": {
138
+ "id": "/node_modules/.pnpm/@tanstack+store@0.0.1-beta.84/node_modules/@tanstack/store/build/esm/index.js",
139
+ "moduleParts": {
140
+ "index.production.js": "52cd-47"
141
+ },
142
+ "imported": [],
143
+ "importedBy": [
144
+ {
145
+ "uid": "52cd-48"
146
+ },
147
+ {
148
+ "uid": "52cd-50"
149
+ }
150
+ ]
151
+ },
152
+ "52cd-48": {
153
+ "id": "/packages/form-core/build/esm/index.js",
154
+ "moduleParts": {
155
+ "index.production.js": "52cd-49"
156
+ },
157
+ "imported": [
158
+ {
159
+ "uid": "52cd-46"
160
+ }
161
+ ],
162
+ "importedBy": [
163
+ {
164
+ "uid": "52cd-58"
165
+ },
166
+ {
167
+ "uid": "52cd-56"
168
+ },
169
+ {
170
+ "uid": "52cd-54"
171
+ }
172
+ ]
173
+ },
174
+ "52cd-50": {
175
+ "id": "/node_modules/.pnpm/@tanstack+react-store@0.0.1-beta.84_react-dom@18.2.0_react@18.2.0/node_modules/@tanstack/react-store/build/esm/index.js",
176
+ "moduleParts": {
177
+ "index.production.js": "52cd-51"
178
+ },
179
+ "imported": [
180
+ {
181
+ "uid": "52cd-63"
182
+ },
183
+ {
184
+ "uid": "52cd-46"
185
+ }
186
+ ],
187
+ "importedBy": [
188
+ {
189
+ "uid": "52cd-58"
190
+ },
191
+ {
192
+ "uid": "52cd-54"
193
+ }
194
+ ]
195
+ },
196
+ "52cd-52": {
197
+ "id": "/packages/react-form/src/formContext.ts",
198
+ "moduleParts": {
199
+ "index.production.js": "52cd-53"
200
+ },
201
+ "imported": [
202
+ {
203
+ "uid": "52cd-62"
204
+ }
205
+ ],
206
+ "importedBy": [
207
+ {
208
+ "uid": "52cd-58"
209
+ },
210
+ {
211
+ "uid": "52cd-54"
212
+ }
213
+ ]
214
+ },
215
+ "52cd-54": {
216
+ "id": "/packages/react-form/src/useField.ts",
217
+ "moduleParts": {
218
+ "index.production.js": "52cd-55"
219
+ },
220
+ "imported": [
221
+ {
222
+ "uid": "52cd-62"
223
+ },
224
+ {
225
+ "uid": "52cd-50"
226
+ },
227
+ {
228
+ "uid": "52cd-48"
229
+ },
230
+ {
231
+ "uid": "52cd-52"
232
+ }
233
+ ],
234
+ "importedBy": [
235
+ {
236
+ "uid": "52cd-60"
237
+ },
238
+ {
239
+ "uid": "52cd-58"
240
+ },
241
+ {
242
+ "uid": "52cd-56"
243
+ }
244
+ ]
245
+ },
246
+ "52cd-56": {
247
+ "id": "/packages/react-form/src/Field.tsx",
248
+ "moduleParts": {
249
+ "index.production.js": "52cd-57"
250
+ },
251
+ "imported": [
252
+ {
253
+ "uid": "52cd-44"
254
+ },
255
+ {
256
+ "uid": "52cd-62"
257
+ },
258
+ {
259
+ "uid": "52cd-48"
260
+ },
261
+ {
262
+ "uid": "52cd-54"
263
+ }
264
+ ],
265
+ "importedBy": [
266
+ {
267
+ "uid": "52cd-60"
268
+ },
269
+ {
270
+ "uid": "52cd-58"
271
+ }
272
+ ]
273
+ },
274
+ "52cd-58": {
275
+ "id": "/packages/react-form/src/useForm.tsx",
276
+ "moduleParts": {
277
+ "index.production.js": "52cd-59"
278
+ },
279
+ "imported": [
280
+ {
281
+ "uid": "52cd-44"
282
+ },
283
+ {
284
+ "uid": "52cd-48"
285
+ },
286
+ {
287
+ "uid": "52cd-50"
288
+ },
289
+ {
290
+ "uid": "52cd-62"
291
+ },
292
+ {
293
+ "uid": "52cd-56"
294
+ },
295
+ {
296
+ "uid": "52cd-54"
297
+ },
298
+ {
299
+ "uid": "52cd-52"
300
+ }
301
+ ],
302
+ "importedBy": [
303
+ {
304
+ "uid": "52cd-60"
305
+ }
306
+ ]
307
+ },
308
+ "52cd-60": {
309
+ "id": "/packages/react-form/src/index.ts",
310
+ "moduleParts": {
311
+ "index.production.js": "52cd-61"
312
+ },
313
+ "imported": [
314
+ {
315
+ "uid": "52cd-58"
316
+ },
317
+ {
318
+ "uid": "52cd-56"
319
+ },
320
+ {
321
+ "uid": "52cd-54"
322
+ }
323
+ ],
324
+ "importedBy": [],
325
+ "isEntry": true
326
+ },
327
+ "52cd-62": {
328
+ "id": "react",
329
+ "moduleParts": {},
330
+ "imported": [],
331
+ "importedBy": [
332
+ {
333
+ "uid": "52cd-58"
334
+ },
335
+ {
336
+ "uid": "52cd-56"
337
+ },
338
+ {
339
+ "uid": "52cd-54"
340
+ },
341
+ {
342
+ "uid": "52cd-52"
343
+ }
344
+ ],
345
+ "isExternal": true
346
+ },
347
+ "52cd-63": {
348
+ "id": "use-sync-external-store/shim/with-selector",
349
+ "moduleParts": {},
350
+ "imported": [],
351
+ "importedBy": [
352
+ {
353
+ "uid": "52cd-50"
354
+ }
355
+ ],
356
+ "isExternal": true
357
+ }
358
+ },
359
+ "env": {
360
+ "rollup": "2.78.1"
361
+ },
362
+ "options": {
363
+ "gzip": true,
364
+ "brotli": false,
365
+ "sourcemap": false
366
+ }
367
+ }
@@ -0,0 +1,69 @@
1
+ import type { DeepKeys, DeepValue, RequiredByKey, Updater } from './utils';
2
+ import type { FormApi, ValidationError } from './FormApi';
3
+ import { Store } from '@tanstack/store';
4
+ declare type ValidateOn = 'change' | 'blur' | 'submit';
5
+ export declare type FieldOptions<TData, TFormData> = {
6
+ name: unknown extends TFormData ? string : DeepKeys<TFormData>;
7
+ defaultValue?: TData;
8
+ form?: FormApi<TFormData>;
9
+ validate?: (value: TData, fieldApi: FieldApi<TData, TFormData>) => ValidationError;
10
+ validateAsync?: (value: TData, fieldApi: FieldApi<TData, TFormData>) => ValidationError | Promise<ValidationError>;
11
+ validatePristine?: boolean;
12
+ validateOn?: ValidateOn;
13
+ validateAsyncOn?: ValidateOn;
14
+ validateAsyncDebounceMs?: number;
15
+ filterValue?: (value: TData) => TData;
16
+ defaultMeta?: Partial<FieldMeta>;
17
+ change?: boolean;
18
+ blur?: boolean;
19
+ submit?: boolean;
20
+ };
21
+ export declare type FieldMeta = {
22
+ isTouched: boolean;
23
+ touchedError?: ValidationError;
24
+ error?: ValidationError;
25
+ isValidating: boolean;
26
+ };
27
+ export declare type ChangeProps<TData> = {
28
+ onChange?: (updater: Updater<TData>) => void;
29
+ onBlur?: (event: any) => void;
30
+ };
31
+ export declare type InputProps = {
32
+ onChange?: (event: any) => void;
33
+ onBlur?: (event: any) => void;
34
+ };
35
+ export declare type FieldApiOptions<TData, TFormData> = RequiredByKey<FieldOptions<TData, TFormData>, 'form'>;
36
+ export declare type FieldState<TData> = {
37
+ value: TData;
38
+ meta: FieldMeta;
39
+ };
40
+ export declare class FieldApi<TData, TFormData> {
41
+ #private;
42
+ uid: number;
43
+ form: FormApi<TFormData>;
44
+ name: DeepKeys<TFormData>;
45
+ store: Store<FieldState<TData>>;
46
+ state: FieldState<TData>;
47
+ options: RequiredByKey<FieldOptions<TData, TFormData>, 'validateOn' | 'validateAsyncOn'>;
48
+ constructor(opts: FieldApiOptions<TData, TFormData>);
49
+ mount: () => () => void;
50
+ update: (opts: FieldApiOptions<TData, TFormData>) => void;
51
+ getValue: () => TData;
52
+ setValue: (updater: Updater<TData>, options?: {
53
+ touch?: boolean;
54
+ notify?: boolean;
55
+ }) => void;
56
+ getMeta: () => FieldMeta;
57
+ setMeta: (updater: Updater<FieldMeta>) => void;
58
+ getInfo: () => Record<DeepKeys<TFormData>, import("./FormApi").FieldInfo<TFormData>>[DeepKeys<TFormData>];
59
+ pushValue: (value: TData) => void;
60
+ insertValue: (index: number, value: TData) => void;
61
+ removeValue: (index: number) => void;
62
+ swapValues: (aIndex: number, bIndex: number) => void;
63
+ getSubField: <TName extends DeepKeys<TData>>(name: TName) => FieldApi<DeepValue<TData, TName>, TFormData>;
64
+ validate: () => Promise<ValidationError>;
65
+ validateAsync: () => Promise<ValidationError>;
66
+ getChangeProps: <T extends ChangeProps<any>>(props?: T) => ChangeProps<TData> & Omit<T, keyof ChangeProps<TData>>;
67
+ getInputProps: <T extends InputProps>(props?: T) => InputProps & Omit<T, keyof InputProps>;
68
+ }
69
+ export {};
@@ -0,0 +1,74 @@
1
+ import type { FormEvent } from 'react';
2
+ import { Store } from '@tanstack/store';
3
+ import type { DeepKeys, DeepValue, Updater } from './utils';
4
+ import type { FieldApi, FieldMeta } from './FieldApi';
5
+ export declare type FormOptions<TData> = {
6
+ defaultValues?: TData;
7
+ defaultState?: Partial<FormState<TData>>;
8
+ onSubmit?: (values: TData, formApi: FormApi<TData>) => Promise<any>;
9
+ onInvalidSubmit?: (values: TData, formApi: FormApi<TData>) => void;
10
+ validate?: (values: TData, formApi: FormApi<TData>) => Promise<any>;
11
+ debugForm?: boolean;
12
+ validatePristine?: boolean;
13
+ };
14
+ export declare type FieldInfo<TFormData> = {
15
+ instances: Record<string, FieldApi<any, TFormData>>;
16
+ } & ValidationMeta;
17
+ export declare type ValidationMeta = {
18
+ validationCount?: number;
19
+ validationPromise?: Promise<ValidationError>;
20
+ validationResolve?: (error: ValidationError) => void;
21
+ validationReject?: (error: unknown) => void;
22
+ };
23
+ export declare type ValidationError = undefined | false | null | string;
24
+ export declare type FormState<TData> = {
25
+ values: TData;
26
+ isFormValidating: boolean;
27
+ formValidationCount: number;
28
+ isFormValid: boolean;
29
+ formError?: ValidationError;
30
+ fieldMeta: Record<DeepKeys<TData>, FieldMeta>;
31
+ isFieldsValidating: boolean;
32
+ isFieldsValid: boolean;
33
+ isSubmitting: boolean;
34
+ isTouched: boolean;
35
+ isSubmitted: boolean;
36
+ isValidating: boolean;
37
+ isValid: boolean;
38
+ canSubmit: boolean;
39
+ submissionAttempts: number;
40
+ };
41
+ export declare function getDefaultFormState<TData>(defaultState: Partial<FormState<TData>>): FormState<TData>;
42
+ export declare class FormApi<TFormData> {
43
+ options: FormOptions<TFormData>;
44
+ store: Store<FormState<TFormData>>;
45
+ state: FormState<TFormData>;
46
+ fieldInfo: Record<DeepKeys<TFormData>, FieldInfo<TFormData>>;
47
+ fieldName?: string;
48
+ validationMeta: ValidationMeta;
49
+ constructor(opts?: FormOptions<TFormData>);
50
+ update: (options: FormOptions<TFormData>) => void;
51
+ reset: () => void;
52
+ validateAllFields: () => Promise<ValidationError[]>;
53
+ validateForm: () => Promise<ValidationError>;
54
+ handleSubmit: (e: FormEvent & {
55
+ __handled?: boolean;
56
+ }) => Promise<void>;
57
+ getFieldValue: <TField extends DeepKeys<TFormData>>(field: TField) => DeepValue<TFormData, TField>;
58
+ getFieldMeta: <TField extends DeepKeys<TFormData>>(field: TField) => FieldMeta;
59
+ getFieldInfo: <TField extends DeepKeys<TFormData>>(field: TField) => Record<DeepKeys<TFormData>, FieldInfo<TFormData>>[TField];
60
+ setFieldMeta: <TField extends DeepKeys<TFormData>>(field: TField, updater: Updater<FieldMeta>) => void;
61
+ setFieldValue: <TField extends DeepKeys<TFormData>>(field: TField, updater: Updater<DeepValue<TFormData, TField>, DeepValue<TFormData, TField>>, opts?: {
62
+ touch?: boolean;
63
+ }) => void;
64
+ pushFieldValue: <TField extends DeepKeys<TFormData>>(field: TField, value: DeepValue<TFormData, TField>, opts?: {
65
+ touch?: boolean;
66
+ }) => void;
67
+ insertFieldValue: <TField extends DeepKeys<TFormData>>(field: TField, index: number, value: DeepValue<TFormData, TField>, opts?: {
68
+ touch?: boolean;
69
+ }) => void;
70
+ spliceFieldValue: <TField extends DeepKeys<TFormData>>(field: TField, index: number, opts?: {
71
+ touch?: boolean;
72
+ }) => void;
73
+ swapFieldValues: <TField extends DeepKeys<TFormData>>(field: TField, index1: number, index2: number) => void;
74
+ }
@@ -0,0 +1,3 @@
1
+ export * from './FormApi';
2
+ export * from './FieldApi';
3
+ export * from './utils';
@@ -0,0 +1,16 @@
1
+ export declare type UpdaterFn<TInput, TOutput = TInput> = (input: TInput) => TOutput;
2
+ export declare type Updater<TInput, TOutput = TInput> = TOutput | UpdaterFn<TInput, TOutput>;
3
+ export declare function functionalUpdate<TInput, TOutput = TInput>(updater: Updater<TInput, TOutput>, input: TInput): TOutput;
4
+ export declare function getBy(obj: any, path: any): any;
5
+ export declare function setBy(obj: any, _path: any, updater: Updater<any>): any;
6
+ export declare type RequiredByKey<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
7
+ declare type ComputeRange<N extends number, Result extends Array<unknown> = []> = Result['length'] extends N ? Result : ComputeRange<N, [...Result, Result['length']]>;
8
+ declare type Index40 = ComputeRange<40>[number];
9
+ declare type IsTuple<T> = T extends readonly any[] & {
10
+ length: infer Length;
11
+ } ? Length extends Index40 ? T : never : never;
12
+ declare type AllowedIndexes<Tuple extends ReadonlyArray<any>, Keys extends number = never> = Tuple extends readonly [] ? Keys : Tuple extends readonly [infer _, ...infer Tail] ? AllowedIndexes<Tail, Keys | Tail['length']> : Keys;
13
+ export declare type DeepKeys<T> = unknown extends T ? keyof T : object extends T ? string : T extends readonly any[] & IsTuple<T> ? AllowedIndexes<T> | DeepKeysPrefix<T, AllowedIndexes<T>> : T extends any[] ? never & 'Dynamic length array indexing is not supported' : T extends Date ? never : T extends object ? (keyof T & string) | DeepKeysPrefix<T, keyof T> : never;
14
+ declare type DeepKeysPrefix<T, TPrefix> = TPrefix extends keyof T & (number | string) ? `${TPrefix}.${DeepKeys<T[TPrefix]> & string}` : never;
15
+ export declare type DeepValue<T, TProp> = T extends Record<string | number, any> ? TProp extends `${infer TBranch}.${infer TDeepProp}` ? DeepValue<T[TBranch], TDeepProp> : T[TProp & string] : never;
16
+ export {};
@@ -0,0 +1,50 @@
1
+ /**
2
+ * react-form
3
+ *
4
+ * Copyright (c) TanStack
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE.md file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */
11
+ import { DeepKeys, FieldApi, DeepValue, FieldOptions, FormApi, FormState, FormOptions } from '@tanstack/form-core';
12
+ import { NoInfer } from '@tanstack/react-store';
13
+ import React from 'react';
14
+
15
+ declare type FieldComponent<TFormData> = <TField extends DeepKeys<TFormData>>({ children, ...fieldOptions }: {
16
+ children: (fieldApi: FieldApi<DeepValue<TFormData, TField>, TFormData>) => any;
17
+ name: TField;
18
+ } & Omit<FieldOptions<DeepValue<TFormData, TField>, TFormData>, 'name'>) => any;
19
+ declare function createFieldComponent<TFormData>(formApi: FormApi<TFormData>): FieldComponent<TFormData>;
20
+ declare function Field<TData, TFormData>({ children, ...fieldOptions }: {
21
+ children: (fieldApi: FieldApi<TData, TFormData>) => any;
22
+ } & FieldOptions<TData, TFormData>): any;
23
+
24
+ declare type UseField<TFormData> = <TField extends DeepKeys<TFormData>>(opts?: {
25
+ name: TField;
26
+ } & FieldOptions<DeepValue<TFormData, TField>, TFormData>) => FieldApi<DeepValue<TFormData, TField>, TFormData>;
27
+ declare function createUseField<TFormData>(formApi: FormApi<TFormData>): UseField<TFormData>;
28
+ declare function useField<TData, TFormData>(opts: FieldOptions<TData, TFormData> & {}): FieldApi<TData, TFormData>;
29
+
30
+ declare module '@tanstack/form-core' {
31
+ interface FormApi<TFormData> {
32
+ Form: FormComponent;
33
+ Field: FieldComponent<TFormData>;
34
+ useField: UseField<TFormData>;
35
+ useStore: <TSelected = NoInfer<FormState<TFormData>>>(selector?: (state: NoInfer<FormState<TFormData>>) => TSelected) => TSelected;
36
+ Subscribe: <TSelected = NoInfer<FormState<TFormData>>>(props: {
37
+ selector?: (state: NoInfer<FormState<TFormData>>) => TSelected;
38
+ children: ((state: NoInfer<TSelected>) => React.ReactNode) | React.ReactNode;
39
+ }) => any;
40
+ }
41
+ }
42
+ declare function useForm<TData>(opts?: FormOptions<TData>): FormApi<TData>;
43
+ declare type FormProps = React.HTMLProps<HTMLFormElement> & {
44
+ children: React.ReactNode;
45
+ noFormElement?: boolean;
46
+ };
47
+ declare type FormComponent = (props: FormProps) => any;
48
+ declare function createFormComponent(formApi: FormApi<any>): FormComponent;
49
+
50
+ export { Field, FieldComponent, FormComponent, FormProps, UseField, createFieldComponent, createFormComponent, createUseField, useField, useForm };
@@ -0,0 +1,9 @@
1
+ import { type DeepKeys, type DeepValue, type FieldApi, type FieldOptions, type FormApi } from '@tanstack/form-core';
2
+ export declare type FieldComponent<TFormData> = <TField extends DeepKeys<TFormData>>({ children, ...fieldOptions }: {
3
+ children: (fieldApi: FieldApi<DeepValue<TFormData, TField>, TFormData>) => any;
4
+ name: TField;
5
+ } & Omit<FieldOptions<DeepValue<TFormData, TField>, TFormData>, 'name'>) => any;
6
+ export declare function createFieldComponent<TFormData>(formApi: FormApi<TFormData>): FieldComponent<TFormData>;
7
+ export declare function Field<TData, TFormData>({ children, ...fieldOptions }: {
8
+ children: (fieldApi: FieldApi<TData, TFormData>) => any;
9
+ } & FieldOptions<TData, TFormData>): any;
@@ -0,0 +1,4 @@
1
+ import { FormApi } from '@tanstack/form-core';
2
+ import * as React from 'react';
3
+ export declare const formContext: React.Context<FormApi<any>>;
4
+ export declare function useFormContext(customFormApi?: FormApi<any>): FormApi<any>;
@@ -0,0 +1,3 @@
1
+ export * from './useForm';
2
+ export * from './Field';
3
+ export * from './useField';
@@ -0,0 +1,7 @@
1
+ import type { DeepKeys, DeepValue, FieldOptions, FormApi } from '@tanstack/form-core';
2
+ import { FieldApi } from '@tanstack/form-core';
3
+ export declare type UseField<TFormData> = <TField extends DeepKeys<TFormData>>(opts?: {
4
+ name: TField;
5
+ } & FieldOptions<DeepValue<TFormData, TField>, TFormData>) => FieldApi<DeepValue<TFormData, TField>, TFormData>;
6
+ export declare function createUseField<TFormData>(formApi: FormApi<TFormData>): UseField<TFormData>;
7
+ export declare function useField<TData, TFormData>(opts: FieldOptions<TData, TFormData> & {}): FieldApi<TData, TFormData>;
@@ -0,0 +1,25 @@
1
+ import type { FormState, FormOptions } from '@tanstack/form-core';
2
+ import { FormApi } from '@tanstack/form-core';
3
+ import type { NoInfer } from '@tanstack/react-store';
4
+ import React from 'react';
5
+ import { type FieldComponent } from './Field';
6
+ import { type UseField } from './useField';
7
+ declare module '@tanstack/form-core' {
8
+ interface FormApi<TFormData> {
9
+ Form: FormComponent;
10
+ Field: FieldComponent<TFormData>;
11
+ useField: UseField<TFormData>;
12
+ useStore: <TSelected = NoInfer<FormState<TFormData>>>(selector?: (state: NoInfer<FormState<TFormData>>) => TSelected) => TSelected;
13
+ Subscribe: <TSelected = NoInfer<FormState<TFormData>>>(props: {
14
+ selector?: (state: NoInfer<FormState<TFormData>>) => TSelected;
15
+ children: ((state: NoInfer<TSelected>) => React.ReactNode) | React.ReactNode;
16
+ }) => any;
17
+ }
18
+ }
19
+ export declare function useForm<TData>(opts?: FormOptions<TData>): FormApi<TData>;
20
+ export declare type FormProps = React.HTMLProps<HTMLFormElement> & {
21
+ children: React.ReactNode;
22
+ noFormElement?: boolean;
23
+ };
24
+ export declare type FormComponent = (props: FormProps) => any;
25
+ export declare function createFormComponent(formApi: FormApi<any>): FormComponent;