formstand 0.25.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/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-CMVALnc3.cjs';
2
- export { B as BoolMap, f as FieldSnapshot, g as FieldsValidationResult, R as ReadonlyStoreApi, h as ResetOptions, i as SettledFieldsValidationResult, j as SettledValidationResult, k as SubmitHandler, l as SubmitOptions, m as SubmitResult, V as ValidationMode, n as ValidationResult, o as ValidationTrigger, p as createForm, q as emptyValueForSchema, r as flattenIssues, s as isAsyncRequiredError, t as isClearableSchema, u as shouldValidateOn, v as validateAsync, w as validateSync } from './createForm-CMVALnc3.cjs';
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';
@@ -26,6 +26,7 @@ type PersistOptions<TSchema extends z.ZodType> = Readonly<{
26
26
  }>;
27
27
  type PersistHandle = Readonly<{
28
28
  load: () => boolean;
29
+ flush: () => void;
29
30
  clear: () => void;
30
31
  dispose: () => void;
31
32
  }>;
@@ -132,6 +133,7 @@ type FormActionStateHandler<TSchema extends z.ZodType, S> = (prevState: S, data:
132
133
  type FormActionOptions = Readonly<{
133
134
  onInvalid?: InvalidSubmitHandler;
134
135
  onError?: (error: unknown) => void;
136
+ force?: boolean;
135
137
  }>;
136
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>);
137
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];
@@ -151,18 +153,24 @@ type CommonKeys<V> = keyof V;
151
153
  type AllKeys<V> = V extends unknown ? keyof V : never;
152
154
  type VariantKeys<V> = Exclude<AllKeys<V>, CommonKeys<V>> & string;
153
155
  type VariantFieldPath<V, D extends PathDepth = DefaultPathDepth> = Exclude<V extends unknown ? FieldPath<V, D> : never, (CommonKeys<V> & string) | `${CommonKeys<V> & string}.${string}`> & string;
154
- 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;
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;
155
163
  declare const inferredCallsOnly$2: unique symbol;
156
164
  interface InferredTypeArg$2 {
157
165
  readonly [inferredCallsOnly$2]: typeof inferredCallsOnly$2;
158
166
  }
159
167
  declare function useVariantField<TValue = InferredTypeArg$2>(form: FieldFormApi & Readonly<{
160
168
  schema: z.ZodType;
161
- }>, 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>;
162
170
  declare function useVariantField<TValue = unknown>(form: FieldFormApi & {
163
171
  readonly schema?: undefined;
164
- }, unionPath: string, field: string): UseFieldReturn<TValue | undefined>;
165
- 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>;
166
174
 
167
175
  type ReadonlyStore$1<T> = Pick<StoreApi<T>, "getState" | "getInitialState" | "subscribe">;
168
176
  type FieldArrayFormApi = Readonly<{
@@ -173,6 +181,7 @@ type FieldArrayFormApi = Readonly<{
173
181
  arrayMove(path: string, from: number, to: number): void;
174
182
  arraySwap(path: string, a: number, b: number): void;
175
183
  validateField?(path: string): FieldValidationResult;
184
+ validateFieldAsync?(path: string): Promise<SettledFieldValidationResult>;
176
185
  setError?(path: string, errors: string | readonly string[]): void;
177
186
  clearErrors?(path?: string): void;
178
187
  setTouched?(path: string, touched?: boolean): void;
@@ -197,6 +206,7 @@ type UseFieldArrayReturn<TItem> = Readonly<{
197
206
  setTouched: (touched?: boolean) => void;
198
207
  onBlur: () => void;
199
208
  validate: () => FieldValidationResult;
209
+ validateAsync: () => Promise<SettledFieldValidationResult>;
200
210
  push: (item: TItem) => void;
201
211
  remove: (index: number) => void;
202
212
  insert: (index: number, item: TItem) => void;
@@ -247,8 +257,8 @@ type UseFieldsReturn<TFields extends readonly unknown[]> = Readonly<{
247
257
  }>;
248
258
  declare function useFields(form: FieldFormApi & {
249
259
  readonly schema?: undefined;
250
- }, paths: readonly string[]): UseFieldsReturn<readonly UseFieldReturn<unknown>[]>;
251
- 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<{
252
262
  readonly [K in keyof P]: UseFieldReturn<FieldValue<z.input<TSchema>, P[K] & string>>;
253
263
  }>;
254
264
 
@@ -256,7 +266,7 @@ type BoundUseField<TSchema extends z.ZodType, D extends PathDepth = DefaultPathD
256
266
  (pathSelector: (state: FormState<z.input<TSchema>>) => string, options?: UseFieldOptions): UseFieldReturn<unknown>;
257
267
  <P extends FieldPath<z.input<TSchema>, D>>(path: P, options?: UseFieldOptions): UseFieldReturn<FieldValue<z.input<TSchema>, P>>;
258
268
  };
259
- 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>;
260
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>>>;
261
271
  type BoundUseFieldArray<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = {
262
272
  (pathSelector: (state: FormState<z.input<TSchema>>) => string): UseFieldArrayReturn<unknown>;
@@ -264,6 +274,9 @@ type BoundUseFieldArray<TSchema extends z.ZodType, D extends PathDepth = Default
264
274
  };
265
275
  type BoundUseSelector<TSchema extends z.ZodType> = <U>(selector: (state: FormState<z.input<TSchema>>) => U) => U;
266
276
  type BoundUseFlag<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = (path?: FieldPath<z.input<TSchema>, D>) => boolean;
277
+ type BoundUseAction<TSchema extends z.ZodType> = (onValid: FormActionHandler<TSchema>, options?: FormActionOptions) => (formData: FormData) => Promise<void>;
278
+ type BoundUseActionState<TSchema extends z.ZodType> = <S>(action: FormActionStateHandler<TSchema, S>, initialState: S, options?: FormActionOptions) => [state: S, formAction: (formData: FormData) => void, isPending: boolean];
279
+ type BoundUsePersist<TSchema extends z.ZodType> = (options: PersistOptions<TSchema>) => PersistHandle;
267
280
  type FormHooks<TSchema extends z.ZodType, N extends string, D extends PathDepth = DefaultPathDepth> = Readonly<{
268
281
  [K in `use${Capitalize<N>}Field`]: BoundUseField<TSchema, D>;
269
282
  } & {
@@ -294,8 +307,14 @@ type FormHooks<TSchema extends z.ZodType, N extends string, D extends PathDepth
294
307
  [K in `use${Capitalize<N>}Fields`]: BoundUseFields<TSchema, D>;
295
308
  } & {
296
309
  [K in `use${Capitalize<N>}Steps`]: (steps: readonly FormStep<z.input<TSchema>, D>[]) => UseFormStepsReturn;
310
+ } & {
311
+ [K in `use${Capitalize<N>}Action`]: BoundUseAction<TSchema>;
312
+ } & {
313
+ [K in `use${Capitalize<N>}ActionState`]: BoundUseActionState<TSchema>;
314
+ } & {
315
+ [K in `use${Capitalize<N>}Persist`]: BoundUsePersist<TSchema>;
297
316
  }>;
298
- 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<{
299
318
  readonly [K in keyof P]: UseFieldReturn<FieldValue<z.input<TSchema>, P[K] & string>>;
300
319
  }>;
301
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>;
@@ -469,4 +488,4 @@ declare const checkboxProps: <T extends boolean | null | undefined>(field: UseFi
469
488
  declare const selectProps: <T extends string | null | undefined>(field: UseFieldReturn<T>) => SelectProps;
470
489
 
471
490
  export { ArrayFieldPath, ArrayItemOf, CheckboxField, CreateFormOptions, DateField, DefaultPathDepth, ErrorMap, FieldPath, FieldValidationResult, FieldValue, Form, FormState, InvalidSubmitHandler, NumberField, PathDepth, SelectField, SettledFieldValidationResult, TextField, checkboxProps, createFormContext, createFormHooks, dateInputProps, dateToInputText, focusField, focusFirstError, getAtPath, hasFieldError, numberInputProps, numberToInputText, parseDateText, parseNumberText, parsePath, persistForm, selectProps, setAtPath, textInputProps, useField, useFieldArray, useFields, useForm, useFormAction, useFormActionState, useFormError, useFormSelector, useFormSelectorShallow, useFormSteps, useFormValues, useIsDirty, useIsSubmitting, useIsValid, useIsValidating, useMaskedInput, useNumberInput, usePersistForm, useSubmitCount, useVariantField, useVariantFieldArray };
472
- export type { ArrayPathsOf, BoundUseField, BoundUseFieldArray, BoundUseFields, BoundUseFlag, BoundUseSelector, BoundUseVariantField, BoundUseVariantFieldArray, CheckboxFieldProps, CheckboxProps, DateFieldProps, DateInputProps, FieldArrayEntry, FieldArrayFormApi, FieldFormApi, FieldPathArg, FieldRef, FormActionHandler, FormActionOptions, FormActionStateHandler, FormContextApi, FormHooks, FormProviderProps, FormStateApi, FormStep, MaskedInputBinding, MaskedInputOptions, MaskedParse, NumberFieldProps, NumberInputBinding, NumberInputProps, ParsedDateText, ParsedNumberText, PathSegment, PathsAccepting, PathsOf, PersistHandle, PersistOptions, PersistStorage, SelectFieldOption, SelectFieldProps, SelectProps, SelectValueAt, StepStatus, TextFieldProps, TextInputProps, UnionValueAt, UseFieldArrayReturn, UseFieldOptions, UseFieldReturn, UseFieldsReturn, UseFormStepsReturn, VariantArrayFieldPath, VariantFieldPath, VariantFieldValue, VariantKeys };
491
+ export type { ArrayPathsOf, BoundUseAction, BoundUseActionState, BoundUseField, BoundUseFieldArray, BoundUseFields, BoundUseFlag, BoundUsePersist, BoundUseSelector, BoundUseVariantField, BoundUseVariantFieldArray, CheckboxFieldProps, CheckboxProps, DateFieldProps, DateInputProps, FieldArrayEntry, FieldArrayFormApi, FieldFormApi, FieldPathArg, FieldRef, FormActionHandler, FormActionOptions, FormActionStateHandler, FormContextApi, FormHooks, FormProviderProps, FormStateApi, FormStep, MaskedInputBinding, MaskedInputOptions, MaskedParse, NumberFieldProps, NumberInputBinding, NumberInputProps, ParsedDateText, ParsedNumberText, PathSegment, PathsAccepting, PathsOf, PersistHandle, PersistOptions, PersistStorage, SelectFieldOption, SelectFieldProps, SelectProps, SelectValueAt, StepStatus, TextFieldProps, TextInputProps, UnionValueAt, UseFieldArrayReturn, UseFieldOptions, UseFieldReturn, UseFieldsReturn, UseFormStepsReturn, VariantArrayFieldPath, VariantFieldPath, VariantFieldValue, VariantKeys };
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-CMVALnc3.js';
2
- export { B as BoolMap, f as FieldSnapshot, g as FieldsValidationResult, R as ReadonlyStoreApi, h as ResetOptions, i as SettledFieldsValidationResult, j as SettledValidationResult, k as SubmitHandler, l as SubmitOptions, m as SubmitResult, V as ValidationMode, n as ValidationResult, o as ValidationTrigger, p as createForm, q as emptyValueForSchema, r as flattenIssues, s as isAsyncRequiredError, t as isClearableSchema, u as shouldValidateOn, v as validateAsync, w as validateSync } from './createForm-CMVALnc3.js';
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';
@@ -26,6 +26,7 @@ type PersistOptions<TSchema extends z.ZodType> = Readonly<{
26
26
  }>;
27
27
  type PersistHandle = Readonly<{
28
28
  load: () => boolean;
29
+ flush: () => void;
29
30
  clear: () => void;
30
31
  dispose: () => void;
31
32
  }>;
@@ -132,6 +133,7 @@ type FormActionStateHandler<TSchema extends z.ZodType, S> = (prevState: S, data:
132
133
  type FormActionOptions = Readonly<{
133
134
  onInvalid?: InvalidSubmitHandler;
134
135
  onError?: (error: unknown) => void;
136
+ force?: boolean;
135
137
  }>;
136
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>);
137
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];
@@ -151,18 +153,24 @@ type CommonKeys<V> = keyof V;
151
153
  type AllKeys<V> = V extends unknown ? keyof V : never;
152
154
  type VariantKeys<V> = Exclude<AllKeys<V>, CommonKeys<V>> & string;
153
155
  type VariantFieldPath<V, D extends PathDepth = DefaultPathDepth> = Exclude<V extends unknown ? FieldPath<V, D> : never, (CommonKeys<V> & string) | `${CommonKeys<V> & string}.${string}`> & string;
154
- 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;
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;
155
163
  declare const inferredCallsOnly$2: unique symbol;
156
164
  interface InferredTypeArg$2 {
157
165
  readonly [inferredCallsOnly$2]: typeof inferredCallsOnly$2;
158
166
  }
159
167
  declare function useVariantField<TValue = InferredTypeArg$2>(form: FieldFormApi & Readonly<{
160
168
  schema: z.ZodType;
161
- }>, 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>;
162
170
  declare function useVariantField<TValue = unknown>(form: FieldFormApi & {
163
171
  readonly schema?: undefined;
164
- }, unionPath: string, field: string): UseFieldReturn<TValue | undefined>;
165
- 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>;
166
174
 
167
175
  type ReadonlyStore$1<T> = Pick<StoreApi<T>, "getState" | "getInitialState" | "subscribe">;
168
176
  type FieldArrayFormApi = Readonly<{
@@ -173,6 +181,7 @@ type FieldArrayFormApi = Readonly<{
173
181
  arrayMove(path: string, from: number, to: number): void;
174
182
  arraySwap(path: string, a: number, b: number): void;
175
183
  validateField?(path: string): FieldValidationResult;
184
+ validateFieldAsync?(path: string): Promise<SettledFieldValidationResult>;
176
185
  setError?(path: string, errors: string | readonly string[]): void;
177
186
  clearErrors?(path?: string): void;
178
187
  setTouched?(path: string, touched?: boolean): void;
@@ -197,6 +206,7 @@ type UseFieldArrayReturn<TItem> = Readonly<{
197
206
  setTouched: (touched?: boolean) => void;
198
207
  onBlur: () => void;
199
208
  validate: () => FieldValidationResult;
209
+ validateAsync: () => Promise<SettledFieldValidationResult>;
200
210
  push: (item: TItem) => void;
201
211
  remove: (index: number) => void;
202
212
  insert: (index: number, item: TItem) => void;
@@ -247,8 +257,8 @@ type UseFieldsReturn<TFields extends readonly unknown[]> = Readonly<{
247
257
  }>;
248
258
  declare function useFields(form: FieldFormApi & {
249
259
  readonly schema?: undefined;
250
- }, paths: readonly string[]): UseFieldsReturn<readonly UseFieldReturn<unknown>[]>;
251
- 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<{
252
262
  readonly [K in keyof P]: UseFieldReturn<FieldValue<z.input<TSchema>, P[K] & string>>;
253
263
  }>;
254
264
 
@@ -256,7 +266,7 @@ type BoundUseField<TSchema extends z.ZodType, D extends PathDepth = DefaultPathD
256
266
  (pathSelector: (state: FormState<z.input<TSchema>>) => string, options?: UseFieldOptions): UseFieldReturn<unknown>;
257
267
  <P extends FieldPath<z.input<TSchema>, D>>(path: P, options?: UseFieldOptions): UseFieldReturn<FieldValue<z.input<TSchema>, P>>;
258
268
  };
259
- 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>;
260
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>>>;
261
271
  type BoundUseFieldArray<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = {
262
272
  (pathSelector: (state: FormState<z.input<TSchema>>) => string): UseFieldArrayReturn<unknown>;
@@ -264,6 +274,9 @@ type BoundUseFieldArray<TSchema extends z.ZodType, D extends PathDepth = Default
264
274
  };
265
275
  type BoundUseSelector<TSchema extends z.ZodType> = <U>(selector: (state: FormState<z.input<TSchema>>) => U) => U;
266
276
  type BoundUseFlag<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = (path?: FieldPath<z.input<TSchema>, D>) => boolean;
277
+ type BoundUseAction<TSchema extends z.ZodType> = (onValid: FormActionHandler<TSchema>, options?: FormActionOptions) => (formData: FormData) => Promise<void>;
278
+ type BoundUseActionState<TSchema extends z.ZodType> = <S>(action: FormActionStateHandler<TSchema, S>, initialState: S, options?: FormActionOptions) => [state: S, formAction: (formData: FormData) => void, isPending: boolean];
279
+ type BoundUsePersist<TSchema extends z.ZodType> = (options: PersistOptions<TSchema>) => PersistHandle;
267
280
  type FormHooks<TSchema extends z.ZodType, N extends string, D extends PathDepth = DefaultPathDepth> = Readonly<{
268
281
  [K in `use${Capitalize<N>}Field`]: BoundUseField<TSchema, D>;
269
282
  } & {
@@ -294,8 +307,14 @@ type FormHooks<TSchema extends z.ZodType, N extends string, D extends PathDepth
294
307
  [K in `use${Capitalize<N>}Fields`]: BoundUseFields<TSchema, D>;
295
308
  } & {
296
309
  [K in `use${Capitalize<N>}Steps`]: (steps: readonly FormStep<z.input<TSchema>, D>[]) => UseFormStepsReturn;
310
+ } & {
311
+ [K in `use${Capitalize<N>}Action`]: BoundUseAction<TSchema>;
312
+ } & {
313
+ [K in `use${Capitalize<N>}ActionState`]: BoundUseActionState<TSchema>;
314
+ } & {
315
+ [K in `use${Capitalize<N>}Persist`]: BoundUsePersist<TSchema>;
297
316
  }>;
298
- 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<{
299
318
  readonly [K in keyof P]: UseFieldReturn<FieldValue<z.input<TSchema>, P[K] & string>>;
300
319
  }>;
301
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>;
@@ -469,4 +488,4 @@ declare const checkboxProps: <T extends boolean | null | undefined>(field: UseFi
469
488
  declare const selectProps: <T extends string | null | undefined>(field: UseFieldReturn<T>) => SelectProps;
470
489
 
471
490
  export { ArrayFieldPath, ArrayItemOf, CheckboxField, CreateFormOptions, DateField, DefaultPathDepth, ErrorMap, FieldPath, FieldValidationResult, FieldValue, Form, FormState, InvalidSubmitHandler, NumberField, PathDepth, SelectField, SettledFieldValidationResult, TextField, checkboxProps, createFormContext, createFormHooks, dateInputProps, dateToInputText, focusField, focusFirstError, getAtPath, hasFieldError, numberInputProps, numberToInputText, parseDateText, parseNumberText, parsePath, persistForm, selectProps, setAtPath, textInputProps, useField, useFieldArray, useFields, useForm, useFormAction, useFormActionState, useFormError, useFormSelector, useFormSelectorShallow, useFormSteps, useFormValues, useIsDirty, useIsSubmitting, useIsValid, useIsValidating, useMaskedInput, useNumberInput, usePersistForm, useSubmitCount, useVariantField, useVariantFieldArray };
472
- export type { ArrayPathsOf, BoundUseField, BoundUseFieldArray, BoundUseFields, BoundUseFlag, BoundUseSelector, BoundUseVariantField, BoundUseVariantFieldArray, CheckboxFieldProps, CheckboxProps, DateFieldProps, DateInputProps, FieldArrayEntry, FieldArrayFormApi, FieldFormApi, FieldPathArg, FieldRef, FormActionHandler, FormActionOptions, FormActionStateHandler, FormContextApi, FormHooks, FormProviderProps, FormStateApi, FormStep, MaskedInputBinding, MaskedInputOptions, MaskedParse, NumberFieldProps, NumberInputBinding, NumberInputProps, ParsedDateText, ParsedNumberText, PathSegment, PathsAccepting, PathsOf, PersistHandle, PersistOptions, PersistStorage, SelectFieldOption, SelectFieldProps, SelectProps, SelectValueAt, StepStatus, TextFieldProps, TextInputProps, UnionValueAt, UseFieldArrayReturn, UseFieldOptions, UseFieldReturn, UseFieldsReturn, UseFormStepsReturn, VariantArrayFieldPath, VariantFieldPath, VariantFieldValue, VariantKeys };
491
+ export type { ArrayPathsOf, BoundUseAction, BoundUseActionState, BoundUseField, BoundUseFieldArray, BoundUseFields, BoundUseFlag, BoundUsePersist, BoundUseSelector, BoundUseVariantField, BoundUseVariantFieldArray, CheckboxFieldProps, CheckboxProps, DateFieldProps, DateInputProps, FieldArrayEntry, FieldArrayFormApi, FieldFormApi, FieldPathArg, FieldRef, FormActionHandler, FormActionOptions, FormActionStateHandler, FormContextApi, FormHooks, FormProviderProps, FormStateApi, FormStep, MaskedInputBinding, MaskedInputOptions, MaskedParse, NumberFieldProps, NumberInputBinding, NumberInputProps, ParsedDateText, ParsedNumberText, PathSegment, PathsAccepting, PathsOf, PersistHandle, PersistOptions, PersistStorage, SelectFieldOption, SelectFieldProps, SelectProps, SelectValueAt, StepStatus, TextFieldProps, TextInputProps, UnionValueAt, UseFieldArrayReturn, UseFieldOptions, UseFieldReturn, UseFieldsReturn, UseFormStepsReturn, VariantArrayFieldPath, VariantFieldPath, VariantFieldValue, VariantKeys };