formstand 0.16.0 → 0.18.0
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/CHANGELOG.md +173 -0
- package/dist/{createForm-jlzK2lCG.d.cts → createForm-B73p1TgL.d.cts} +17 -6
- package/dist/{createForm-jlzK2lCG.d.ts → createForm-B73p1TgL.d.ts} +17 -6
- package/dist/devtools/index.d.cts +1 -1
- package/dist/devtools/index.d.ts +1 -1
- package/dist/index.cjs +142 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +45 -23
- package/dist/index.d.ts +45 -23
- package/dist/index.js +141 -50
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as PathDepth, D as DefaultPathDepth, F as Form, C as CreateFormOptions, a as FieldValidationResult, b as FormState, c as FieldPath, d as FieldValue, E as ErrorMap } from './createForm-
|
|
2
|
-
export { B as BoolMap, e as FieldSnapshot, f as FieldsValidationResult, I as InvalidSubmitHandler, R as ReadonlyStoreApi, g as ResetOptions,
|
|
1
|
+
import { P as PathDepth, D as DefaultPathDepth, F as Form, C as CreateFormOptions, a as FieldValidationResult, S as SettledFieldValidationResult, b as FormState, c as FieldPath, d as FieldValue, E as ErrorMap } from './createForm-B73p1TgL.cjs';
|
|
2
|
+
export { B as BoolMap, e as FieldSnapshot, f as FieldsValidationResult, I as InvalidSubmitHandler, R as ReadonlyStoreApi, g as ResetOptions, h as SettledFieldsValidationResult, i as SettledValidationResult, j as SubmitHandler, k as SubmitOptions, l as SubmitResult, V as ValidationMode, m as ValidationResult, n as ValidationTrigger, o as createForm, p as emptyValueForSchema, q as flattenIssues, r as isAsyncRequiredError, s as isClearableSchema, t as shouldValidateOn, v as validateAsync, u as validateSync } from './createForm-B73p1TgL.cjs';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
import { ReactNode, ChangeEvent } from 'react';
|
|
@@ -23,12 +23,14 @@ type PersistOptions<TSchema extends z.ZodType> = Readonly<{
|
|
|
23
23
|
apply?: "adopt" | "restore" | "manual";
|
|
24
24
|
}>;
|
|
25
25
|
type PersistHandle = Readonly<{
|
|
26
|
-
|
|
26
|
+
load: () => boolean;
|
|
27
27
|
clear: () => void;
|
|
28
28
|
dispose: () => void;
|
|
29
29
|
}>;
|
|
30
30
|
declare const persistForm: <TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, options: PersistOptions<TSchema>) => PersistHandle;
|
|
31
31
|
|
|
32
|
+
declare const usePersistForm: <TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, options: PersistOptions<TSchema>) => PersistHandle;
|
|
33
|
+
|
|
32
34
|
declare const useForm: <TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth>(schema: TSchema, options: CreateFormOptions<TSchema, D>) => Form<TSchema, D>;
|
|
33
35
|
|
|
34
36
|
type FormProviderProps<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = Readonly<{
|
|
@@ -49,7 +51,7 @@ type FieldFormApi = Readonly<{
|
|
|
49
51
|
setError(path: string, errors: string | readonly string[]): void;
|
|
50
52
|
clearErrors(path?: string): void;
|
|
51
53
|
validateField(path: string): FieldValidationResult;
|
|
52
|
-
validateFieldAsync(path: string): Promise<
|
|
54
|
+
validateFieldAsync(path: string): Promise<SettledFieldValidationResult>;
|
|
53
55
|
}>;
|
|
54
56
|
type FieldPathArg<TValues> = string | ((state: FormState<TValues>) => string);
|
|
55
57
|
type UseFieldOptions = Readonly<{
|
|
@@ -60,6 +62,7 @@ type UseFieldReturn<TValue> = Readonly<{
|
|
|
60
62
|
value: TValue;
|
|
61
63
|
initialValue: TValue;
|
|
62
64
|
emptyValue: null | undefined;
|
|
65
|
+
clearable: boolean;
|
|
63
66
|
error: readonly string[] | undefined;
|
|
64
67
|
firstError: string | undefined;
|
|
65
68
|
touched: boolean;
|
|
@@ -70,7 +73,7 @@ type UseFieldReturn<TValue> = Readonly<{
|
|
|
70
73
|
setError: (errors: string | readonly string[]) => void;
|
|
71
74
|
clearError: () => void;
|
|
72
75
|
validate: () => FieldValidationResult;
|
|
73
|
-
validateAsync: () => Promise<
|
|
76
|
+
validateAsync: () => Promise<SettledFieldValidationResult>;
|
|
74
77
|
onBlur: () => void;
|
|
75
78
|
}>;
|
|
76
79
|
declare const inferredCallsOnly$2: unique symbol;
|
|
@@ -93,7 +96,7 @@ type VariantFieldValue<V, TField extends string> = V extends unknown ? TField ex
|
|
|
93
96
|
type CommonKeys<V> = keyof V;
|
|
94
97
|
type AllKeys<V> = V extends unknown ? keyof V : never;
|
|
95
98
|
type VariantKeys<V> = Exclude<AllKeys<V>, CommonKeys<V>> & string;
|
|
96
|
-
type UnionValueAt<TValues, P extends string> = P extends keyof TValues ? NonNullable<TValues[P]> : TValues extends readonly (infer Item)[] ? P extends `${number}` ? NonNullable<Item> : P extends `${infer Head}.${infer Tail}` ? Head extends `${number}` ? UnionValueAt<NonNullable<Item>, Tail> : never : never : P extends `${infer Head}.${infer Tail}` ? Head extends keyof TValues ? UnionValueAt<NonNullable<TValues[Head]>, Tail> : never : never;
|
|
99
|
+
type UnionValueAt<TValues, P extends string> = P extends keyof TValues ? NonNullable<TValues[P]> : TValues extends readonly (infer Item)[] ? P extends `${number}` ? NonNullable<Item> : P extends `${infer Head}.${infer Tail}` ? Head extends keyof TValues ? UnionValueAt<NonNullable<TValues[Head]>, Tail> : Head extends `${number}` ? UnionValueAt<NonNullable<Item>, Tail> : never : never : P extends `${infer Head}.${infer Tail}` ? Head extends keyof TValues ? UnionValueAt<NonNullable<TValues[Head]>, Tail> : never : never;
|
|
97
100
|
declare const inferredCallsOnly$1: unique symbol;
|
|
98
101
|
interface InferredTypeArg$1 {
|
|
99
102
|
readonly [inferredCallsOnly$1]: typeof inferredCallsOnly$1;
|
|
@@ -115,16 +118,22 @@ type FieldArrayFormApi = Readonly<{
|
|
|
115
118
|
arrayMove(path: string, from: number, to: number): void;
|
|
116
119
|
arraySwap(path: string, a: number, b: number): void;
|
|
117
120
|
validateField?(path: string): FieldValidationResult;
|
|
121
|
+
setError?(path: string, errors: string | readonly string[]): void;
|
|
122
|
+
clearErrors?(path?: string): void;
|
|
118
123
|
}>;
|
|
119
124
|
type FieldArrayEntry<TItem> = Readonly<{
|
|
120
125
|
id: string;
|
|
121
126
|
value: TItem;
|
|
122
127
|
}>;
|
|
123
128
|
type UseFieldArrayReturn<TItem> = Readonly<{
|
|
129
|
+
path: string;
|
|
124
130
|
fields: readonly FieldArrayEntry<TItem>[];
|
|
125
131
|
items: readonly TItem[];
|
|
126
132
|
length: number;
|
|
127
133
|
error: readonly string[] | undefined;
|
|
134
|
+
firstError: string | undefined;
|
|
135
|
+
setError: (errors: string | readonly string[]) => void;
|
|
136
|
+
clearError: () => void;
|
|
128
137
|
push: (item: TItem) => void;
|
|
129
138
|
remove: (index: number) => void;
|
|
130
139
|
insert: (index: number, item: TItem) => void;
|
|
@@ -148,6 +157,22 @@ declare function useFieldArray<TItem = unknown>(form: FieldArrayFormApi & {
|
|
|
148
157
|
}, path: FieldPathArg<unknown>): UseFieldArrayReturn<TItem>;
|
|
149
158
|
declare function useFieldArray<TSchema extends z.ZodType, P extends FieldPath<z.input<TSchema>, D>, D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, path: P): UseFieldArrayReturn<ArrayItemOf<FieldValue<z.input<TSchema>, P>>>;
|
|
150
159
|
|
|
160
|
+
type UseFieldsReturn<TFields extends readonly unknown[]> = Readonly<{
|
|
161
|
+
fields: TFields;
|
|
162
|
+
error: readonly string[] | undefined;
|
|
163
|
+
firstError: string | undefined;
|
|
164
|
+
touched: boolean;
|
|
165
|
+
dirty: boolean;
|
|
166
|
+
isValidating: boolean;
|
|
167
|
+
onBlur: () => void;
|
|
168
|
+
}>;
|
|
169
|
+
declare function useFields(form: FieldFormApi & {
|
|
170
|
+
readonly schema?: undefined;
|
|
171
|
+
}, paths: readonly string[]): UseFieldsReturn<readonly UseFieldReturn<unknown>[]>;
|
|
172
|
+
declare function useFields<TSchema extends z.ZodType, const P extends readonly FieldPath<z.input<TSchema>, D>[], D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, paths: P): UseFieldsReturn<{
|
|
173
|
+
readonly [K in keyof P]: UseFieldReturn<FieldValue<z.input<TSchema>, P[K] & string>>;
|
|
174
|
+
}>;
|
|
175
|
+
|
|
151
176
|
type BoundUseField<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = {
|
|
152
177
|
(pathSelector: (state: FormState<z.input<TSchema>>) => string, options?: UseFieldOptions): UseFieldReturn<unknown>;
|
|
153
178
|
<P extends FieldPath<z.input<TSchema>, D>>(path: P, options?: UseFieldOptions): UseFieldReturn<FieldValue<z.input<TSchema>, P>>;
|
|
@@ -175,10 +200,19 @@ type FormHooks<TSchema extends z.ZodType, N extends string, D extends PathDepth
|
|
|
175
200
|
[K in `use${Capitalize<N>}IsDirty`]: BoundUseFlag<TSchema, D>;
|
|
176
201
|
} & {
|
|
177
202
|
[K in `use${Capitalize<N>}IsValid`]: BoundUseFlag<TSchema, D>;
|
|
203
|
+
} & {
|
|
204
|
+
[K in `use${Capitalize<N>}IsValidating`]: BoundUseFlag<TSchema, D>;
|
|
178
205
|
} & {
|
|
179
206
|
[K in `use${Capitalize<N>}IsSubmitting`]: () => boolean;
|
|
180
207
|
} & {
|
|
181
208
|
[K in `use${Capitalize<N>}SubmitCount`]: () => number;
|
|
209
|
+
} & {
|
|
210
|
+
[K in `use${Capitalize<N>}Values`]: () => z.input<TSchema>;
|
|
211
|
+
} & {
|
|
212
|
+
[K in `use${Capitalize<N>}Fields`]: BoundUseFields<TSchema, D>;
|
|
213
|
+
}>;
|
|
214
|
+
type BoundUseFields<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = <const P extends readonly FieldPath<z.input<TSchema>, D>[]>(paths: P) => UseFieldsReturn<{
|
|
215
|
+
readonly [K in keyof P]: UseFieldReturn<FieldValue<z.input<TSchema>, P[K] & string>>;
|
|
182
216
|
}>;
|
|
183
217
|
declare const createFormHooks: <TSchema extends z.ZodType, N extends string = "", D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, name?: N) => FormHooks<TSchema, N, D>;
|
|
184
218
|
|
|
@@ -210,25 +244,13 @@ declare function useIsValid(form: FormStateApi & {
|
|
|
210
244
|
readonly schema?: undefined;
|
|
211
245
|
}, path?: string): boolean;
|
|
212
246
|
declare function useIsValid<TSchema extends z.ZodType, P extends FieldPath<z.input<TSchema>, D>, D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, path?: P): boolean;
|
|
247
|
+
declare function useIsValidating(form: FormStateApi & {
|
|
248
|
+
readonly schema?: undefined;
|
|
249
|
+
}, path?: string): boolean;
|
|
250
|
+
declare function useIsValidating<TSchema extends z.ZodType, P extends FieldPath<z.input<TSchema>, D>, D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, path?: P): boolean;
|
|
213
251
|
declare const useIsSubmitting: (form: FormStateApi) => boolean;
|
|
214
252
|
declare const useSubmitCount: (form: FormStateApi) => number;
|
|
215
253
|
|
|
216
|
-
type UseFieldsReturn<TFields extends readonly unknown[]> = Readonly<{
|
|
217
|
-
fields: TFields;
|
|
218
|
-
error: readonly string[] | undefined;
|
|
219
|
-
firstError: string | undefined;
|
|
220
|
-
touched: boolean;
|
|
221
|
-
dirty: boolean;
|
|
222
|
-
isValidating: boolean;
|
|
223
|
-
onBlur: () => void;
|
|
224
|
-
}>;
|
|
225
|
-
declare function useFields(form: FieldFormApi & {
|
|
226
|
-
readonly schema?: undefined;
|
|
227
|
-
}, paths: readonly string[]): UseFieldsReturn<readonly UseFieldReturn<unknown>[]>;
|
|
228
|
-
declare function useFields<TSchema extends z.ZodType, const P extends readonly FieldPath<z.input<TSchema>, D>[], D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, paths: P): UseFieldsReturn<{
|
|
229
|
-
readonly [K in keyof P]: UseFieldReturn<FieldValue<z.input<TSchema>, P[K] & string>>;
|
|
230
|
-
}>;
|
|
231
|
-
|
|
232
254
|
type PathsOf<F extends FieldFormApi> = F extends Form<infer TSchema extends z.ZodType, infer D extends PathDepth> ? FieldPath<z.input<TSchema>, D> : string;
|
|
233
255
|
type FieldRef<T> = ((instance: T | null) => void) | Readonly<{
|
|
234
256
|
current: T | null;
|
|
@@ -358,4 +380,4 @@ declare const dateInputProps: <T extends Date | null | undefined>(field: UseFiel
|
|
|
358
380
|
declare const checkboxProps: <T extends boolean | null | undefined>(field: UseFieldReturn<T>) => CheckboxProps;
|
|
359
381
|
declare const selectProps: <T extends string | null | undefined>(field: UseFieldReturn<T>) => SelectProps;
|
|
360
382
|
|
|
361
|
-
export { type BoundUseField, type BoundUseFieldArray, type BoundUseFlag, type BoundUseSelector, CheckboxField, type CheckboxFieldProps, type CheckboxProps, CreateFormOptions, DateField, type DateFieldProps, type DateInputProps, DefaultPathDepth, ErrorMap, type FieldArrayEntry, type FieldArrayFormApi, type FieldFormApi, FieldPath, type FieldPathArg, type FieldRef, FieldValidationResult, FieldValue, Form, type FormContextApi, type FormHooks, type FormProviderProps, FormState, type FormStateApi, NumberField, type NumberFieldProps, type NumberInputBinding, type NumberInputProps, type ParsedDateText, type ParsedNumberText, PathDepth, type PathSegment, type PathsOf, type PersistHandle, type PersistOptions, type PersistStorage, SelectField, type SelectFieldOption, type SelectFieldProps, type SelectProps, TextField, type TextFieldProps, type TextInputProps, type UseFieldArrayReturn, type UseFieldOptions, type UseFieldReturn, type UseFieldsReturn, checkboxProps, createFormContext, createFormHooks, dateInputProps, dateToInputText, focusField, focusFirstError, getAtPath, hasFieldError, numberInputProps, numberToInputText, parseDateText, parseNumberText, parsePath, persistForm, selectProps, setAtPath, textInputProps, useField, useFieldArray, useFields, useForm, useFormError, useFormSelector, useFormSelectorShallow, useFormValues, useIsDirty, useIsSubmitting, useIsValid, useNumberInput, useSubmitCount, useVariantField };
|
|
383
|
+
export { type BoundUseField, type BoundUseFieldArray, type BoundUseFlag, type BoundUseSelector, CheckboxField, type CheckboxFieldProps, type CheckboxProps, CreateFormOptions, DateField, type DateFieldProps, type DateInputProps, DefaultPathDepth, ErrorMap, type FieldArrayEntry, type FieldArrayFormApi, type FieldFormApi, FieldPath, type FieldPathArg, type FieldRef, FieldValidationResult, FieldValue, Form, type FormContextApi, type FormHooks, type FormProviderProps, FormState, type FormStateApi, NumberField, type NumberFieldProps, type NumberInputBinding, type NumberInputProps, type ParsedDateText, type ParsedNumberText, PathDepth, type PathSegment, type PathsOf, type PersistHandle, type PersistOptions, type PersistStorage, SelectField, type SelectFieldOption, type SelectFieldProps, type SelectProps, SettledFieldValidationResult, TextField, type TextFieldProps, type TextInputProps, type UseFieldArrayReturn, type UseFieldOptions, type UseFieldReturn, type UseFieldsReturn, checkboxProps, createFormContext, createFormHooks, dateInputProps, dateToInputText, focusField, focusFirstError, getAtPath, hasFieldError, numberInputProps, numberToInputText, parseDateText, parseNumberText, parsePath, persistForm, selectProps, setAtPath, textInputProps, useField, useFieldArray, useFields, useForm, useFormError, useFormSelector, useFormSelectorShallow, useFormValues, useIsDirty, useIsSubmitting, useIsValid, useIsValidating, useNumberInput, usePersistForm, useSubmitCount, useVariantField };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as PathDepth, D as DefaultPathDepth, F as Form, C as CreateFormOptions, a as FieldValidationResult, b as FormState, c as FieldPath, d as FieldValue, E as ErrorMap } from './createForm-
|
|
2
|
-
export { B as BoolMap, e as FieldSnapshot, f as FieldsValidationResult, I as InvalidSubmitHandler, R as ReadonlyStoreApi, g as ResetOptions,
|
|
1
|
+
import { P as PathDepth, D as DefaultPathDepth, F as Form, C as CreateFormOptions, a as FieldValidationResult, S as SettledFieldValidationResult, b as FormState, c as FieldPath, d as FieldValue, E as ErrorMap } from './createForm-B73p1TgL.js';
|
|
2
|
+
export { B as BoolMap, e as FieldSnapshot, f as FieldsValidationResult, I as InvalidSubmitHandler, R as ReadonlyStoreApi, g as ResetOptions, h as SettledFieldsValidationResult, i as SettledValidationResult, j as SubmitHandler, k as SubmitOptions, l as SubmitResult, V as ValidationMode, m as ValidationResult, n as ValidationTrigger, o as createForm, p as emptyValueForSchema, q as flattenIssues, r as isAsyncRequiredError, s as isClearableSchema, t as shouldValidateOn, v as validateAsync, u as validateSync } from './createForm-B73p1TgL.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
import { ReactNode, ChangeEvent } from 'react';
|
|
@@ -23,12 +23,14 @@ type PersistOptions<TSchema extends z.ZodType> = Readonly<{
|
|
|
23
23
|
apply?: "adopt" | "restore" | "manual";
|
|
24
24
|
}>;
|
|
25
25
|
type PersistHandle = Readonly<{
|
|
26
|
-
|
|
26
|
+
load: () => boolean;
|
|
27
27
|
clear: () => void;
|
|
28
28
|
dispose: () => void;
|
|
29
29
|
}>;
|
|
30
30
|
declare const persistForm: <TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, options: PersistOptions<TSchema>) => PersistHandle;
|
|
31
31
|
|
|
32
|
+
declare const usePersistForm: <TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, options: PersistOptions<TSchema>) => PersistHandle;
|
|
33
|
+
|
|
32
34
|
declare const useForm: <TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth>(schema: TSchema, options: CreateFormOptions<TSchema, D>) => Form<TSchema, D>;
|
|
33
35
|
|
|
34
36
|
type FormProviderProps<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = Readonly<{
|
|
@@ -49,7 +51,7 @@ type FieldFormApi = Readonly<{
|
|
|
49
51
|
setError(path: string, errors: string | readonly string[]): void;
|
|
50
52
|
clearErrors(path?: string): void;
|
|
51
53
|
validateField(path: string): FieldValidationResult;
|
|
52
|
-
validateFieldAsync(path: string): Promise<
|
|
54
|
+
validateFieldAsync(path: string): Promise<SettledFieldValidationResult>;
|
|
53
55
|
}>;
|
|
54
56
|
type FieldPathArg<TValues> = string | ((state: FormState<TValues>) => string);
|
|
55
57
|
type UseFieldOptions = Readonly<{
|
|
@@ -60,6 +62,7 @@ type UseFieldReturn<TValue> = Readonly<{
|
|
|
60
62
|
value: TValue;
|
|
61
63
|
initialValue: TValue;
|
|
62
64
|
emptyValue: null | undefined;
|
|
65
|
+
clearable: boolean;
|
|
63
66
|
error: readonly string[] | undefined;
|
|
64
67
|
firstError: string | undefined;
|
|
65
68
|
touched: boolean;
|
|
@@ -70,7 +73,7 @@ type UseFieldReturn<TValue> = Readonly<{
|
|
|
70
73
|
setError: (errors: string | readonly string[]) => void;
|
|
71
74
|
clearError: () => void;
|
|
72
75
|
validate: () => FieldValidationResult;
|
|
73
|
-
validateAsync: () => Promise<
|
|
76
|
+
validateAsync: () => Promise<SettledFieldValidationResult>;
|
|
74
77
|
onBlur: () => void;
|
|
75
78
|
}>;
|
|
76
79
|
declare const inferredCallsOnly$2: unique symbol;
|
|
@@ -93,7 +96,7 @@ type VariantFieldValue<V, TField extends string> = V extends unknown ? TField ex
|
|
|
93
96
|
type CommonKeys<V> = keyof V;
|
|
94
97
|
type AllKeys<V> = V extends unknown ? keyof V : never;
|
|
95
98
|
type VariantKeys<V> = Exclude<AllKeys<V>, CommonKeys<V>> & string;
|
|
96
|
-
type UnionValueAt<TValues, P extends string> = P extends keyof TValues ? NonNullable<TValues[P]> : TValues extends readonly (infer Item)[] ? P extends `${number}` ? NonNullable<Item> : P extends `${infer Head}.${infer Tail}` ? Head extends `${number}` ? UnionValueAt<NonNullable<Item>, Tail> : never : never : P extends `${infer Head}.${infer Tail}` ? Head extends keyof TValues ? UnionValueAt<NonNullable<TValues[Head]>, Tail> : never : never;
|
|
99
|
+
type UnionValueAt<TValues, P extends string> = P extends keyof TValues ? NonNullable<TValues[P]> : TValues extends readonly (infer Item)[] ? P extends `${number}` ? NonNullable<Item> : P extends `${infer Head}.${infer Tail}` ? Head extends keyof TValues ? UnionValueAt<NonNullable<TValues[Head]>, Tail> : Head extends `${number}` ? UnionValueAt<NonNullable<Item>, Tail> : never : never : P extends `${infer Head}.${infer Tail}` ? Head extends keyof TValues ? UnionValueAt<NonNullable<TValues[Head]>, Tail> : never : never;
|
|
97
100
|
declare const inferredCallsOnly$1: unique symbol;
|
|
98
101
|
interface InferredTypeArg$1 {
|
|
99
102
|
readonly [inferredCallsOnly$1]: typeof inferredCallsOnly$1;
|
|
@@ -115,16 +118,22 @@ type FieldArrayFormApi = Readonly<{
|
|
|
115
118
|
arrayMove(path: string, from: number, to: number): void;
|
|
116
119
|
arraySwap(path: string, a: number, b: number): void;
|
|
117
120
|
validateField?(path: string): FieldValidationResult;
|
|
121
|
+
setError?(path: string, errors: string | readonly string[]): void;
|
|
122
|
+
clearErrors?(path?: string): void;
|
|
118
123
|
}>;
|
|
119
124
|
type FieldArrayEntry<TItem> = Readonly<{
|
|
120
125
|
id: string;
|
|
121
126
|
value: TItem;
|
|
122
127
|
}>;
|
|
123
128
|
type UseFieldArrayReturn<TItem> = Readonly<{
|
|
129
|
+
path: string;
|
|
124
130
|
fields: readonly FieldArrayEntry<TItem>[];
|
|
125
131
|
items: readonly TItem[];
|
|
126
132
|
length: number;
|
|
127
133
|
error: readonly string[] | undefined;
|
|
134
|
+
firstError: string | undefined;
|
|
135
|
+
setError: (errors: string | readonly string[]) => void;
|
|
136
|
+
clearError: () => void;
|
|
128
137
|
push: (item: TItem) => void;
|
|
129
138
|
remove: (index: number) => void;
|
|
130
139
|
insert: (index: number, item: TItem) => void;
|
|
@@ -148,6 +157,22 @@ declare function useFieldArray<TItem = unknown>(form: FieldArrayFormApi & {
|
|
|
148
157
|
}, path: FieldPathArg<unknown>): UseFieldArrayReturn<TItem>;
|
|
149
158
|
declare function useFieldArray<TSchema extends z.ZodType, P extends FieldPath<z.input<TSchema>, D>, D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, path: P): UseFieldArrayReturn<ArrayItemOf<FieldValue<z.input<TSchema>, P>>>;
|
|
150
159
|
|
|
160
|
+
type UseFieldsReturn<TFields extends readonly unknown[]> = Readonly<{
|
|
161
|
+
fields: TFields;
|
|
162
|
+
error: readonly string[] | undefined;
|
|
163
|
+
firstError: string | undefined;
|
|
164
|
+
touched: boolean;
|
|
165
|
+
dirty: boolean;
|
|
166
|
+
isValidating: boolean;
|
|
167
|
+
onBlur: () => void;
|
|
168
|
+
}>;
|
|
169
|
+
declare function useFields(form: FieldFormApi & {
|
|
170
|
+
readonly schema?: undefined;
|
|
171
|
+
}, paths: readonly string[]): UseFieldsReturn<readonly UseFieldReturn<unknown>[]>;
|
|
172
|
+
declare function useFields<TSchema extends z.ZodType, const P extends readonly FieldPath<z.input<TSchema>, D>[], D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, paths: P): UseFieldsReturn<{
|
|
173
|
+
readonly [K in keyof P]: UseFieldReturn<FieldValue<z.input<TSchema>, P[K] & string>>;
|
|
174
|
+
}>;
|
|
175
|
+
|
|
151
176
|
type BoundUseField<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = {
|
|
152
177
|
(pathSelector: (state: FormState<z.input<TSchema>>) => string, options?: UseFieldOptions): UseFieldReturn<unknown>;
|
|
153
178
|
<P extends FieldPath<z.input<TSchema>, D>>(path: P, options?: UseFieldOptions): UseFieldReturn<FieldValue<z.input<TSchema>, P>>;
|
|
@@ -175,10 +200,19 @@ type FormHooks<TSchema extends z.ZodType, N extends string, D extends PathDepth
|
|
|
175
200
|
[K in `use${Capitalize<N>}IsDirty`]: BoundUseFlag<TSchema, D>;
|
|
176
201
|
} & {
|
|
177
202
|
[K in `use${Capitalize<N>}IsValid`]: BoundUseFlag<TSchema, D>;
|
|
203
|
+
} & {
|
|
204
|
+
[K in `use${Capitalize<N>}IsValidating`]: BoundUseFlag<TSchema, D>;
|
|
178
205
|
} & {
|
|
179
206
|
[K in `use${Capitalize<N>}IsSubmitting`]: () => boolean;
|
|
180
207
|
} & {
|
|
181
208
|
[K in `use${Capitalize<N>}SubmitCount`]: () => number;
|
|
209
|
+
} & {
|
|
210
|
+
[K in `use${Capitalize<N>}Values`]: () => z.input<TSchema>;
|
|
211
|
+
} & {
|
|
212
|
+
[K in `use${Capitalize<N>}Fields`]: BoundUseFields<TSchema, D>;
|
|
213
|
+
}>;
|
|
214
|
+
type BoundUseFields<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = <const P extends readonly FieldPath<z.input<TSchema>, D>[]>(paths: P) => UseFieldsReturn<{
|
|
215
|
+
readonly [K in keyof P]: UseFieldReturn<FieldValue<z.input<TSchema>, P[K] & string>>;
|
|
182
216
|
}>;
|
|
183
217
|
declare const createFormHooks: <TSchema extends z.ZodType, N extends string = "", D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, name?: N) => FormHooks<TSchema, N, D>;
|
|
184
218
|
|
|
@@ -210,25 +244,13 @@ declare function useIsValid(form: FormStateApi & {
|
|
|
210
244
|
readonly schema?: undefined;
|
|
211
245
|
}, path?: string): boolean;
|
|
212
246
|
declare function useIsValid<TSchema extends z.ZodType, P extends FieldPath<z.input<TSchema>, D>, D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, path?: P): boolean;
|
|
247
|
+
declare function useIsValidating(form: FormStateApi & {
|
|
248
|
+
readonly schema?: undefined;
|
|
249
|
+
}, path?: string): boolean;
|
|
250
|
+
declare function useIsValidating<TSchema extends z.ZodType, P extends FieldPath<z.input<TSchema>, D>, D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, path?: P): boolean;
|
|
213
251
|
declare const useIsSubmitting: (form: FormStateApi) => boolean;
|
|
214
252
|
declare const useSubmitCount: (form: FormStateApi) => number;
|
|
215
253
|
|
|
216
|
-
type UseFieldsReturn<TFields extends readonly unknown[]> = Readonly<{
|
|
217
|
-
fields: TFields;
|
|
218
|
-
error: readonly string[] | undefined;
|
|
219
|
-
firstError: string | undefined;
|
|
220
|
-
touched: boolean;
|
|
221
|
-
dirty: boolean;
|
|
222
|
-
isValidating: boolean;
|
|
223
|
-
onBlur: () => void;
|
|
224
|
-
}>;
|
|
225
|
-
declare function useFields(form: FieldFormApi & {
|
|
226
|
-
readonly schema?: undefined;
|
|
227
|
-
}, paths: readonly string[]): UseFieldsReturn<readonly UseFieldReturn<unknown>[]>;
|
|
228
|
-
declare function useFields<TSchema extends z.ZodType, const P extends readonly FieldPath<z.input<TSchema>, D>[], D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, paths: P): UseFieldsReturn<{
|
|
229
|
-
readonly [K in keyof P]: UseFieldReturn<FieldValue<z.input<TSchema>, P[K] & string>>;
|
|
230
|
-
}>;
|
|
231
|
-
|
|
232
254
|
type PathsOf<F extends FieldFormApi> = F extends Form<infer TSchema extends z.ZodType, infer D extends PathDepth> ? FieldPath<z.input<TSchema>, D> : string;
|
|
233
255
|
type FieldRef<T> = ((instance: T | null) => void) | Readonly<{
|
|
234
256
|
current: T | null;
|
|
@@ -358,4 +380,4 @@ declare const dateInputProps: <T extends Date | null | undefined>(field: UseFiel
|
|
|
358
380
|
declare const checkboxProps: <T extends boolean | null | undefined>(field: UseFieldReturn<T>) => CheckboxProps;
|
|
359
381
|
declare const selectProps: <T extends string | null | undefined>(field: UseFieldReturn<T>) => SelectProps;
|
|
360
382
|
|
|
361
|
-
export { type BoundUseField, type BoundUseFieldArray, type BoundUseFlag, type BoundUseSelector, CheckboxField, type CheckboxFieldProps, type CheckboxProps, CreateFormOptions, DateField, type DateFieldProps, type DateInputProps, DefaultPathDepth, ErrorMap, type FieldArrayEntry, type FieldArrayFormApi, type FieldFormApi, FieldPath, type FieldPathArg, type FieldRef, FieldValidationResult, FieldValue, Form, type FormContextApi, type FormHooks, type FormProviderProps, FormState, type FormStateApi, NumberField, type NumberFieldProps, type NumberInputBinding, type NumberInputProps, type ParsedDateText, type ParsedNumberText, PathDepth, type PathSegment, type PathsOf, type PersistHandle, type PersistOptions, type PersistStorage, SelectField, type SelectFieldOption, type SelectFieldProps, type SelectProps, TextField, type TextFieldProps, type TextInputProps, type UseFieldArrayReturn, type UseFieldOptions, type UseFieldReturn, type UseFieldsReturn, checkboxProps, createFormContext, createFormHooks, dateInputProps, dateToInputText, focusField, focusFirstError, getAtPath, hasFieldError, numberInputProps, numberToInputText, parseDateText, parseNumberText, parsePath, persistForm, selectProps, setAtPath, textInputProps, useField, useFieldArray, useFields, useForm, useFormError, useFormSelector, useFormSelectorShallow, useFormValues, useIsDirty, useIsSubmitting, useIsValid, useNumberInput, useSubmitCount, useVariantField };
|
|
383
|
+
export { type BoundUseField, type BoundUseFieldArray, type BoundUseFlag, type BoundUseSelector, CheckboxField, type CheckboxFieldProps, type CheckboxProps, CreateFormOptions, DateField, type DateFieldProps, type DateInputProps, DefaultPathDepth, ErrorMap, type FieldArrayEntry, type FieldArrayFormApi, type FieldFormApi, FieldPath, type FieldPathArg, type FieldRef, FieldValidationResult, FieldValue, Form, type FormContextApi, type FormHooks, type FormProviderProps, FormState, type FormStateApi, NumberField, type NumberFieldProps, type NumberInputBinding, type NumberInputProps, type ParsedDateText, type ParsedNumberText, PathDepth, type PathSegment, type PathsOf, type PersistHandle, type PersistOptions, type PersistStorage, SelectField, type SelectFieldOption, type SelectFieldProps, type SelectProps, SettledFieldValidationResult, TextField, type TextFieldProps, type TextInputProps, type UseFieldArrayReturn, type UseFieldOptions, type UseFieldReturn, type UseFieldsReturn, checkboxProps, createFormContext, createFormHooks, dateInputProps, dateToInputText, focusField, focusFirstError, getAtPath, hasFieldError, numberInputProps, numberToInputText, parseDateText, parseNumberText, parsePath, persistForm, selectProps, setAtPath, textInputProps, useField, useFieldArray, useFields, useForm, useFormError, useFormSelector, useFormSelectorShallow, useFormValues, useIsDirty, useIsSubmitting, useIsValid, useIsValidating, useNumberInput, usePersistForm, useSubmitCount, useVariantField };
|