formstand 0.26.0 → 0.26.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/CHANGELOG.md +93 -0
- package/dist/{createForm-RE6Bjnfv.d.cts → createForm-BXDd9Tg4.d.cts} +1 -1
- package/dist/{createForm-RE6Bjnfv.d.ts → createForm-BXDd9Tg4.d.ts} +1 -1
- package/dist/devtools/index.cjs +11 -3
- package/dist/devtools/index.cjs.map +1 -1
- package/dist/devtools/index.js +11 -3
- package/dist/devtools/index.js.map +1 -1
- package/dist/index.cjs +233 -82
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -10
- package/dist/index.d.ts +19 -10
- package/dist/index.js +233 -82
- package/dist/index.js.map +1 -1
- package/dist/testing/index.cjs +2 -2
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.js +2 -2
- package/dist/testing/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 FormState, b as FieldValidationResult, S as SettledFieldValidationResult, c as FieldPath, d as FieldValue, I as InvalidSubmitHandler, A as ArrayFieldPath, e as ArrayItemOf, E as ErrorMap } from './createForm-
|
|
2
|
-
export { B as BoolMap, f as ErrorPath, g as FieldSnapshot, h as FieldsValidationResult, R as ReadonlyStoreApi, i as ResetOptions, j as SettledFieldsValidationResult, k as SettledValidationResult, l as SubmitHandler, m as SubmitOptions, n as SubmitResult, V as ValidationMode, o as ValidationResult, p as ValidationTrigger, q as createForm, r as emptyValueForSchema, s as flattenIssues, t as isAsyncRequiredError, u as isClearableSchema, v as shouldValidateOn, w as validateAsync, x as validateSync } from './createForm-
|
|
1
|
+
import { P as PathDepth, D as DefaultPathDepth, F as Form, C as CreateFormOptions, a as FormState, b as FieldValidationResult, S as SettledFieldValidationResult, c as FieldPath, d as FieldValue, I as InvalidSubmitHandler, A as ArrayFieldPath, e as ArrayItemOf, E as ErrorMap } from './createForm-BXDd9Tg4.cjs';
|
|
2
|
+
export { B as BoolMap, f as ErrorPath, g as FieldSnapshot, h as FieldsValidationResult, R as ReadonlyStoreApi, i as ResetOptions, j as SettledFieldsValidationResult, k as SettledValidationResult, l as SubmitHandler, m as SubmitOptions, n as SubmitResult, V as ValidationMode, o as ValidationResult, p as ValidationTrigger, q as createForm, r as emptyValueForSchema, s as flattenIssues, t as isAsyncRequiredError, u as isClearableSchema, v as shouldValidateOn, w as validateAsync, x as validateSync } from './createForm-BXDd9Tg4.cjs';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
import { ChangeEvent, ReactNode } from 'react';
|
|
@@ -133,6 +133,7 @@ type FormActionStateHandler<TSchema extends z.ZodType, S> = (prevState: S, data:
|
|
|
133
133
|
type FormActionOptions = Readonly<{
|
|
134
134
|
onInvalid?: InvalidSubmitHandler;
|
|
135
135
|
onError?: (error: unknown) => void;
|
|
136
|
+
force?: boolean;
|
|
136
137
|
}>;
|
|
137
138
|
declare const useFormAction: <TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, onValid: FormActionHandler<TSchema>, options?: FormActionOptions) => ((formData: FormData) => Promise<void>);
|
|
138
139
|
declare const useFormActionState: <TSchema extends z.ZodType, S, D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, action: FormActionStateHandler<TSchema, S>, initialState: S, options?: FormActionOptions) => [state: S, formAction: (formData: FormData) => void, isPending: boolean];
|
|
@@ -152,18 +153,24 @@ type CommonKeys<V> = keyof V;
|
|
|
152
153
|
type AllKeys<V> = V extends unknown ? keyof V : never;
|
|
153
154
|
type VariantKeys<V> = Exclude<AllKeys<V>, CommonKeys<V>> & string;
|
|
154
155
|
type VariantFieldPath<V, D extends PathDepth = DefaultPathDepth> = Exclude<V extends unknown ? FieldPath<V, D> : never, (CommonKeys<V> & string) | `${CommonKeys<V> & string}.${string}`> & string;
|
|
155
|
-
type
|
|
156
|
+
type MemberValueAt<TValues, K extends string> = TValues extends unknown ? K extends keyof TValues ? TValues[K] : never : never;
|
|
157
|
+
type UnionValueAt<TValues, P extends string> = [
|
|
158
|
+
MemberValueAt<TValues, P>
|
|
159
|
+
] extends [never] ? UnionValueAtDeep<TValues, P> : NonNullable<MemberValueAt<TValues, P>>;
|
|
160
|
+
type UnionValueAtDeep<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}` ? [
|
|
161
|
+
MemberValueAt<TValues, Head>
|
|
162
|
+
] extends [never] ? Head extends `${number}` ? UnionValueAt<NonNullable<Item>, Tail> : never : UnionValueAt<NonNullable<MemberValueAt<TValues, Head>>, Tail> : never : P extends `${infer Head}.${infer Tail}` ? [MemberValueAt<TValues, Head>] extends [never] ? never : UnionValueAt<NonNullable<MemberValueAt<TValues, Head>>, Tail> : never;
|
|
156
163
|
declare const inferredCallsOnly$2: unique symbol;
|
|
157
164
|
interface InferredTypeArg$2 {
|
|
158
165
|
readonly [inferredCallsOnly$2]: typeof inferredCallsOnly$2;
|
|
159
166
|
}
|
|
160
167
|
declare function useVariantField<TValue = InferredTypeArg$2>(form: FieldFormApi & Readonly<{
|
|
161
168
|
schema: z.ZodType;
|
|
162
|
-
}>, unionPath: TValue extends InferredTypeArg$2 ? never : "Remove the explicit type argument: a schema-typed form infers the variant value from the union path and field", field: string): UseFieldReturn<TValue | undefined>;
|
|
169
|
+
}>, unionPath: TValue extends InferredTypeArg$2 ? never : "Remove the explicit type argument: a schema-typed form infers the variant value from the union path and field", field: string, options?: UseFieldOptions): UseFieldReturn<TValue | undefined>;
|
|
163
170
|
declare function useVariantField<TValue = unknown>(form: FieldFormApi & {
|
|
164
171
|
readonly schema?: undefined;
|
|
165
|
-
}, unionPath: string, field: string): UseFieldReturn<TValue | undefined>;
|
|
166
|
-
declare function useVariantField<TSchema extends z.ZodType, P extends string, TField extends VariantFieldPath<UnionValueAt<z.input<TSchema>, P>>, D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, unionPath: P, field: TField): UseFieldReturn<VariantFieldValue<UnionValueAt<z.input<TSchema>, P>, TField> | undefined>;
|
|
172
|
+
}, unionPath: string, field: string, options?: UseFieldOptions): UseFieldReturn<TValue | undefined>;
|
|
173
|
+
declare function useVariantField<TSchema extends z.ZodType, P extends string, TField extends VariantFieldPath<UnionValueAt<z.input<TSchema>, P>>, D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, unionPath: P, field: TField, options?: UseFieldOptions): UseFieldReturn<VariantFieldValue<UnionValueAt<z.input<TSchema>, P>, TField> | undefined>;
|
|
167
174
|
|
|
168
175
|
type ReadonlyStore$1<T> = Pick<StoreApi<T>, "getState" | "getInitialState" | "subscribe">;
|
|
169
176
|
type FieldArrayFormApi = Readonly<{
|
|
@@ -174,6 +181,7 @@ type FieldArrayFormApi = Readonly<{
|
|
|
174
181
|
arrayMove(path: string, from: number, to: number): void;
|
|
175
182
|
arraySwap(path: string, a: number, b: number): void;
|
|
176
183
|
validateField?(path: string): FieldValidationResult;
|
|
184
|
+
validateFieldAsync?(path: string): Promise<SettledFieldValidationResult>;
|
|
177
185
|
setError?(path: string, errors: string | readonly string[]): void;
|
|
178
186
|
clearErrors?(path?: string): void;
|
|
179
187
|
setTouched?(path: string, touched?: boolean): void;
|
|
@@ -198,6 +206,7 @@ type UseFieldArrayReturn<TItem> = Readonly<{
|
|
|
198
206
|
setTouched: (touched?: boolean) => void;
|
|
199
207
|
onBlur: () => void;
|
|
200
208
|
validate: () => FieldValidationResult;
|
|
209
|
+
validateAsync: () => Promise<SettledFieldValidationResult>;
|
|
201
210
|
push: (item: TItem) => void;
|
|
202
211
|
remove: (index: number) => void;
|
|
203
212
|
insert: (index: number, item: TItem) => void;
|
|
@@ -248,8 +257,8 @@ type UseFieldsReturn<TFields extends readonly unknown[]> = Readonly<{
|
|
|
248
257
|
}>;
|
|
249
258
|
declare function useFields(form: FieldFormApi & {
|
|
250
259
|
readonly schema?: undefined;
|
|
251
|
-
}, paths: readonly string[]): UseFieldsReturn<readonly UseFieldReturn<unknown>[]>;
|
|
252
|
-
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<{
|
|
260
|
+
}, paths: readonly string[], options?: UseFieldOptions): UseFieldsReturn<readonly UseFieldReturn<unknown>[]>;
|
|
261
|
+
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, options?: UseFieldOptions): UseFieldsReturn<{
|
|
253
262
|
readonly [K in keyof P]: UseFieldReturn<FieldValue<z.input<TSchema>, P[K] & string>>;
|
|
254
263
|
}>;
|
|
255
264
|
|
|
@@ -257,7 +266,7 @@ type BoundUseField<TSchema extends z.ZodType, D extends PathDepth = DefaultPathD
|
|
|
257
266
|
(pathSelector: (state: FormState<z.input<TSchema>>) => string, options?: UseFieldOptions): UseFieldReturn<unknown>;
|
|
258
267
|
<P extends FieldPath<z.input<TSchema>, D>>(path: P, options?: UseFieldOptions): UseFieldReturn<FieldValue<z.input<TSchema>, P>>;
|
|
259
268
|
};
|
|
260
|
-
type BoundUseVariantField<TSchema extends z.ZodType> = <P extends string, TField extends VariantFieldPath<UnionValueAt<z.input<TSchema>, P>>>(unionPath: P, field: TField) => UseFieldReturn<VariantFieldValue<UnionValueAt<z.input<TSchema>, P>, TField> | undefined>;
|
|
269
|
+
type BoundUseVariantField<TSchema extends z.ZodType> = <P extends string, TField extends VariantFieldPath<UnionValueAt<z.input<TSchema>, P>>>(unionPath: P, field: TField, options?: UseFieldOptions) => UseFieldReturn<VariantFieldValue<UnionValueAt<z.input<TSchema>, P>, TField> | undefined>;
|
|
261
270
|
type BoundUseVariantFieldArray<TSchema extends z.ZodType> = <P extends string, TField extends VariantArrayFieldPath<UnionValueAt<z.input<TSchema>, P>>>(unionPath: P, field: TField) => UseFieldArrayReturn<ArrayItemOf<VariantFieldValue<UnionValueAt<z.input<TSchema>, P>, TField>>>;
|
|
262
271
|
type BoundUseFieldArray<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = {
|
|
263
272
|
(pathSelector: (state: FormState<z.input<TSchema>>) => string): UseFieldArrayReturn<unknown>;
|
|
@@ -305,7 +314,7 @@ type FormHooks<TSchema extends z.ZodType, N extends string, D extends PathDepth
|
|
|
305
314
|
} & {
|
|
306
315
|
[K in `use${Capitalize<N>}Persist`]: BoundUsePersist<TSchema>;
|
|
307
316
|
}>;
|
|
308
|
-
type BoundUseFields<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = <const P extends readonly FieldPath<z.input<TSchema>, D>[]>(paths: P) => UseFieldsReturn<{
|
|
317
|
+
type BoundUseFields<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = <const P extends readonly FieldPath<z.input<TSchema>, D>[]>(paths: P, options?: UseFieldOptions) => UseFieldsReturn<{
|
|
309
318
|
readonly [K in keyof P]: UseFieldReturn<FieldValue<z.input<TSchema>, P[K] & string>>;
|
|
310
319
|
}>;
|
|
311
320
|
declare const createFormHooks: <TSchema extends z.ZodType, N extends string = "", D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, name?: N) => FormHooks<TSchema, N, D>;
|
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 FormState, b as FieldValidationResult, S as SettledFieldValidationResult, c as FieldPath, d as FieldValue, I as InvalidSubmitHandler, A as ArrayFieldPath, e as ArrayItemOf, E as ErrorMap } from './createForm-
|
|
2
|
-
export { B as BoolMap, f as ErrorPath, g as FieldSnapshot, h as FieldsValidationResult, R as ReadonlyStoreApi, i as ResetOptions, j as SettledFieldsValidationResult, k as SettledValidationResult, l as SubmitHandler, m as SubmitOptions, n as SubmitResult, V as ValidationMode, o as ValidationResult, p as ValidationTrigger, q as createForm, r as emptyValueForSchema, s as flattenIssues, t as isAsyncRequiredError, u as isClearableSchema, v as shouldValidateOn, w as validateAsync, x as validateSync } from './createForm-
|
|
1
|
+
import { P as PathDepth, D as DefaultPathDepth, F as Form, C as CreateFormOptions, a as FormState, b as FieldValidationResult, S as SettledFieldValidationResult, c as FieldPath, d as FieldValue, I as InvalidSubmitHandler, A as ArrayFieldPath, e as ArrayItemOf, E as ErrorMap } from './createForm-BXDd9Tg4.js';
|
|
2
|
+
export { B as BoolMap, f as ErrorPath, g as FieldSnapshot, h as FieldsValidationResult, R as ReadonlyStoreApi, i as ResetOptions, j as SettledFieldsValidationResult, k as SettledValidationResult, l as SubmitHandler, m as SubmitOptions, n as SubmitResult, V as ValidationMode, o as ValidationResult, p as ValidationTrigger, q as createForm, r as emptyValueForSchema, s as flattenIssues, t as isAsyncRequiredError, u as isClearableSchema, v as shouldValidateOn, w as validateAsync, x as validateSync } from './createForm-BXDd9Tg4.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
import { ChangeEvent, ReactNode } from 'react';
|
|
@@ -133,6 +133,7 @@ type FormActionStateHandler<TSchema extends z.ZodType, S> = (prevState: S, data:
|
|
|
133
133
|
type FormActionOptions = Readonly<{
|
|
134
134
|
onInvalid?: InvalidSubmitHandler;
|
|
135
135
|
onError?: (error: unknown) => void;
|
|
136
|
+
force?: boolean;
|
|
136
137
|
}>;
|
|
137
138
|
declare const useFormAction: <TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, onValid: FormActionHandler<TSchema>, options?: FormActionOptions) => ((formData: FormData) => Promise<void>);
|
|
138
139
|
declare const useFormActionState: <TSchema extends z.ZodType, S, D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, action: FormActionStateHandler<TSchema, S>, initialState: S, options?: FormActionOptions) => [state: S, formAction: (formData: FormData) => void, isPending: boolean];
|
|
@@ -152,18 +153,24 @@ type CommonKeys<V> = keyof V;
|
|
|
152
153
|
type AllKeys<V> = V extends unknown ? keyof V : never;
|
|
153
154
|
type VariantKeys<V> = Exclude<AllKeys<V>, CommonKeys<V>> & string;
|
|
154
155
|
type VariantFieldPath<V, D extends PathDepth = DefaultPathDepth> = Exclude<V extends unknown ? FieldPath<V, D> : never, (CommonKeys<V> & string) | `${CommonKeys<V> & string}.${string}`> & string;
|
|
155
|
-
type
|
|
156
|
+
type MemberValueAt<TValues, K extends string> = TValues extends unknown ? K extends keyof TValues ? TValues[K] : never : never;
|
|
157
|
+
type UnionValueAt<TValues, P extends string> = [
|
|
158
|
+
MemberValueAt<TValues, P>
|
|
159
|
+
] extends [never] ? UnionValueAtDeep<TValues, P> : NonNullable<MemberValueAt<TValues, P>>;
|
|
160
|
+
type UnionValueAtDeep<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}` ? [
|
|
161
|
+
MemberValueAt<TValues, Head>
|
|
162
|
+
] extends [never] ? Head extends `${number}` ? UnionValueAt<NonNullable<Item>, Tail> : never : UnionValueAt<NonNullable<MemberValueAt<TValues, Head>>, Tail> : never : P extends `${infer Head}.${infer Tail}` ? [MemberValueAt<TValues, Head>] extends [never] ? never : UnionValueAt<NonNullable<MemberValueAt<TValues, Head>>, Tail> : never;
|
|
156
163
|
declare const inferredCallsOnly$2: unique symbol;
|
|
157
164
|
interface InferredTypeArg$2 {
|
|
158
165
|
readonly [inferredCallsOnly$2]: typeof inferredCallsOnly$2;
|
|
159
166
|
}
|
|
160
167
|
declare function useVariantField<TValue = InferredTypeArg$2>(form: FieldFormApi & Readonly<{
|
|
161
168
|
schema: z.ZodType;
|
|
162
|
-
}>, unionPath: TValue extends InferredTypeArg$2 ? never : "Remove the explicit type argument: a schema-typed form infers the variant value from the union path and field", field: string): UseFieldReturn<TValue | undefined>;
|
|
169
|
+
}>, unionPath: TValue extends InferredTypeArg$2 ? never : "Remove the explicit type argument: a schema-typed form infers the variant value from the union path and field", field: string, options?: UseFieldOptions): UseFieldReturn<TValue | undefined>;
|
|
163
170
|
declare function useVariantField<TValue = unknown>(form: FieldFormApi & {
|
|
164
171
|
readonly schema?: undefined;
|
|
165
|
-
}, unionPath: string, field: string): UseFieldReturn<TValue | undefined>;
|
|
166
|
-
declare function useVariantField<TSchema extends z.ZodType, P extends string, TField extends VariantFieldPath<UnionValueAt<z.input<TSchema>, P>>, D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, unionPath: P, field: TField): UseFieldReturn<VariantFieldValue<UnionValueAt<z.input<TSchema>, P>, TField> | undefined>;
|
|
172
|
+
}, unionPath: string, field: string, options?: UseFieldOptions): UseFieldReturn<TValue | undefined>;
|
|
173
|
+
declare function useVariantField<TSchema extends z.ZodType, P extends string, TField extends VariantFieldPath<UnionValueAt<z.input<TSchema>, P>>, D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, unionPath: P, field: TField, options?: UseFieldOptions): UseFieldReturn<VariantFieldValue<UnionValueAt<z.input<TSchema>, P>, TField> | undefined>;
|
|
167
174
|
|
|
168
175
|
type ReadonlyStore$1<T> = Pick<StoreApi<T>, "getState" | "getInitialState" | "subscribe">;
|
|
169
176
|
type FieldArrayFormApi = Readonly<{
|
|
@@ -174,6 +181,7 @@ type FieldArrayFormApi = Readonly<{
|
|
|
174
181
|
arrayMove(path: string, from: number, to: number): void;
|
|
175
182
|
arraySwap(path: string, a: number, b: number): void;
|
|
176
183
|
validateField?(path: string): FieldValidationResult;
|
|
184
|
+
validateFieldAsync?(path: string): Promise<SettledFieldValidationResult>;
|
|
177
185
|
setError?(path: string, errors: string | readonly string[]): void;
|
|
178
186
|
clearErrors?(path?: string): void;
|
|
179
187
|
setTouched?(path: string, touched?: boolean): void;
|
|
@@ -198,6 +206,7 @@ type UseFieldArrayReturn<TItem> = Readonly<{
|
|
|
198
206
|
setTouched: (touched?: boolean) => void;
|
|
199
207
|
onBlur: () => void;
|
|
200
208
|
validate: () => FieldValidationResult;
|
|
209
|
+
validateAsync: () => Promise<SettledFieldValidationResult>;
|
|
201
210
|
push: (item: TItem) => void;
|
|
202
211
|
remove: (index: number) => void;
|
|
203
212
|
insert: (index: number, item: TItem) => void;
|
|
@@ -248,8 +257,8 @@ type UseFieldsReturn<TFields extends readonly unknown[]> = Readonly<{
|
|
|
248
257
|
}>;
|
|
249
258
|
declare function useFields(form: FieldFormApi & {
|
|
250
259
|
readonly schema?: undefined;
|
|
251
|
-
}, paths: readonly string[]): UseFieldsReturn<readonly UseFieldReturn<unknown>[]>;
|
|
252
|
-
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<{
|
|
260
|
+
}, paths: readonly string[], options?: UseFieldOptions): UseFieldsReturn<readonly UseFieldReturn<unknown>[]>;
|
|
261
|
+
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, options?: UseFieldOptions): UseFieldsReturn<{
|
|
253
262
|
readonly [K in keyof P]: UseFieldReturn<FieldValue<z.input<TSchema>, P[K] & string>>;
|
|
254
263
|
}>;
|
|
255
264
|
|
|
@@ -257,7 +266,7 @@ type BoundUseField<TSchema extends z.ZodType, D extends PathDepth = DefaultPathD
|
|
|
257
266
|
(pathSelector: (state: FormState<z.input<TSchema>>) => string, options?: UseFieldOptions): UseFieldReturn<unknown>;
|
|
258
267
|
<P extends FieldPath<z.input<TSchema>, D>>(path: P, options?: UseFieldOptions): UseFieldReturn<FieldValue<z.input<TSchema>, P>>;
|
|
259
268
|
};
|
|
260
|
-
type BoundUseVariantField<TSchema extends z.ZodType> = <P extends string, TField extends VariantFieldPath<UnionValueAt<z.input<TSchema>, P>>>(unionPath: P, field: TField) => UseFieldReturn<VariantFieldValue<UnionValueAt<z.input<TSchema>, P>, TField> | undefined>;
|
|
269
|
+
type BoundUseVariantField<TSchema extends z.ZodType> = <P extends string, TField extends VariantFieldPath<UnionValueAt<z.input<TSchema>, P>>>(unionPath: P, field: TField, options?: UseFieldOptions) => UseFieldReturn<VariantFieldValue<UnionValueAt<z.input<TSchema>, P>, TField> | undefined>;
|
|
261
270
|
type BoundUseVariantFieldArray<TSchema extends z.ZodType> = <P extends string, TField extends VariantArrayFieldPath<UnionValueAt<z.input<TSchema>, P>>>(unionPath: P, field: TField) => UseFieldArrayReturn<ArrayItemOf<VariantFieldValue<UnionValueAt<z.input<TSchema>, P>, TField>>>;
|
|
262
271
|
type BoundUseFieldArray<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = {
|
|
263
272
|
(pathSelector: (state: FormState<z.input<TSchema>>) => string): UseFieldArrayReturn<unknown>;
|
|
@@ -305,7 +314,7 @@ type FormHooks<TSchema extends z.ZodType, N extends string, D extends PathDepth
|
|
|
305
314
|
} & {
|
|
306
315
|
[K in `use${Capitalize<N>}Persist`]: BoundUsePersist<TSchema>;
|
|
307
316
|
}>;
|
|
308
|
-
type BoundUseFields<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = <const P extends readonly FieldPath<z.input<TSchema>, D>[]>(paths: P) => UseFieldsReturn<{
|
|
317
|
+
type BoundUseFields<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = <const P extends readonly FieldPath<z.input<TSchema>, D>[]>(paths: P, options?: UseFieldOptions) => UseFieldsReturn<{
|
|
309
318
|
readonly [K in keyof P]: UseFieldReturn<FieldValue<z.input<TSchema>, P[K] & string>>;
|
|
310
319
|
}>;
|
|
311
320
|
declare const createFormHooks: <TSchema extends z.ZodType, N extends string = "", D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, name?: N) => FormHooks<TSchema, N, D>;
|