formstand 0.24.0 → 0.26.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/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-BexUOCjZ.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-BexUOCjZ.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-RE6Bjnfv.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-RE6Bjnfv.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
  }>;
@@ -33,7 +34,7 @@ declare const persistForm: <TSchema extends z.ZodType, D extends PathDepth = Def
33
34
 
34
35
  declare const usePersistForm: <TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, options: PersistOptions<TSchema>) => PersistHandle;
35
36
 
36
- declare const useForm: <TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth>(schema: TSchema, options: CreateFormOptions<TSchema, D>) => Form<TSchema, D>;
37
+ declare const useForm: <TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth>(schema: TSchema, options: CreateFormOptions<TSchema, D>) => Form<TSchema, NoInfer<D>>;
37
38
 
38
39
  type ReadonlyStore$2<T> = Pick<StoreApi<T>, "getState" | "getInitialState" | "subscribe">;
39
40
  type FieldFormApi = Readonly<{
@@ -68,17 +69,17 @@ type UseFieldReturn<TValue> = Readonly<{
68
69
  validateAsync: () => Promise<SettledFieldValidationResult>;
69
70
  onBlur: () => void;
70
71
  }>;
71
- declare const inferredCallsOnly$2: unique symbol;
72
- interface InferredTypeArg$2 {
73
- readonly [inferredCallsOnly$2]: typeof inferredCallsOnly$2;
72
+ declare const inferredCallsOnly$3: unique symbol;
73
+ interface InferredTypeArg$3 {
74
+ readonly [inferredCallsOnly$3]: typeof inferredCallsOnly$3;
74
75
  }
75
76
  declare function useField<TSchema extends z.ZodType>(form: FieldFormApi & Readonly<{
76
77
  schema: TSchema;
77
78
  store: ReadonlyStore$2<FormState<z.input<TSchema>>>;
78
79
  }>, pathSelector: (state: FormState<z.input<TSchema>>) => string, options?: UseFieldOptions): UseFieldReturn<unknown>;
79
- declare function useField<TValue = InferredTypeArg$2>(form: FieldFormApi & Readonly<{
80
+ declare function useField<TValue = InferredTypeArg$3>(form: FieldFormApi & Readonly<{
80
81
  schema: z.ZodType;
81
- }>, path: TValue extends InferredTypeArg$2 ? never : "Remove the explicit type argument: a schema-typed form infers the value type from the path", options?: UseFieldOptions): UseFieldReturn<TValue>;
82
+ }>, path: TValue extends InferredTypeArg$3 ? never : "Remove the explicit type argument: a schema-typed form infers the value type from the path", options?: UseFieldOptions): UseFieldReturn<TValue>;
82
83
  declare function useField<TValue = unknown>(form: FieldFormApi & {
83
84
  readonly schema?: undefined;
84
85
  }, path: FieldPathArg<unknown>, options?: UseFieldOptions): UseFieldReturn<TValue>;
@@ -152,13 +153,13 @@ type AllKeys<V> = V extends unknown ? keyof V : never;
152
153
  type VariantKeys<V> = Exclude<AllKeys<V>, CommonKeys<V>> & string;
153
154
  type VariantFieldPath<V, D extends PathDepth = DefaultPathDepth> = Exclude<V extends unknown ? FieldPath<V, D> : never, (CommonKeys<V> & string) | `${CommonKeys<V> & string}.${string}`> & string;
154
155
  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;
155
- declare const inferredCallsOnly$1: unique symbol;
156
- interface InferredTypeArg$1 {
157
- readonly [inferredCallsOnly$1]: typeof inferredCallsOnly$1;
156
+ declare const inferredCallsOnly$2: unique symbol;
157
+ interface InferredTypeArg$2 {
158
+ readonly [inferredCallsOnly$2]: typeof inferredCallsOnly$2;
158
159
  }
159
- declare function useVariantField<TValue = InferredTypeArg$1>(form: FieldFormApi & Readonly<{
160
+ declare function useVariantField<TValue = InferredTypeArg$2>(form: FieldFormApi & Readonly<{
160
161
  schema: z.ZodType;
161
- }>, unionPath: TValue extends InferredTypeArg$1 ? 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>;
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>;
162
163
  declare function useVariantField<TValue = unknown>(form: FieldFormApi & {
163
164
  readonly schema?: undefined;
164
165
  }, unionPath: string, field: string): UseFieldReturn<TValue | undefined>;
@@ -207,22 +208,35 @@ type UseFieldArrayReturn<TItem> = Readonly<{
207
208
  prepend: (item: TItem) => void;
208
209
  clear: () => void;
209
210
  }>;
210
- declare const inferredCallsOnly: unique symbol;
211
- interface InferredTypeArg {
212
- readonly [inferredCallsOnly]: typeof inferredCallsOnly;
211
+ declare const inferredCallsOnly$1: unique symbol;
212
+ interface InferredTypeArg$1 {
213
+ readonly [inferredCallsOnly$1]: typeof inferredCallsOnly$1;
213
214
  }
214
215
  declare function useFieldArray<TSchema extends z.ZodType>(form: FieldArrayFormApi & Readonly<{
215
216
  schema: TSchema;
216
217
  store: ReadonlyStore$1<FormState<z.input<TSchema>>>;
217
218
  }>, pathSelector: (state: FormState<z.input<TSchema>>) => string): UseFieldArrayReturn<unknown>;
218
- declare function useFieldArray<TItem = InferredTypeArg>(form: FieldArrayFormApi & Readonly<{
219
+ declare function useFieldArray<TItem = InferredTypeArg$1>(form: FieldArrayFormApi & Readonly<{
219
220
  schema: z.ZodType;
220
- }>, path: TItem extends InferredTypeArg ? never : "Remove the explicit type argument: a schema-typed form infers the item type from the path"): UseFieldArrayReturn<TItem>;
221
+ }>, path: TItem extends InferredTypeArg$1 ? never : "Remove the explicit type argument: a schema-typed form infers the item type from the path"): UseFieldArrayReturn<TItem>;
221
222
  declare function useFieldArray<TItem = unknown>(form: FieldArrayFormApi & {
222
223
  readonly schema?: undefined;
223
224
  }, path: FieldPathArg<unknown>): UseFieldArrayReturn<TItem>;
224
225
  declare function useFieldArray<TSchema extends z.ZodType, P extends ArrayFieldPath<z.input<TSchema>, D> & string, D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, path: P): UseFieldArrayReturn<ArrayItemOf<FieldValue<z.input<TSchema>, P>>>;
225
226
 
227
+ type VariantArrayFieldPath<V, D extends PathDepth = DefaultPathDepth> = Exclude<V extends unknown ? ArrayFieldPath<V, D> : never, (keyof V & string) | `${keyof V & string}.${string}`> & string;
228
+ declare const inferredCallsOnly: unique symbol;
229
+ interface InferredTypeArg {
230
+ readonly [inferredCallsOnly]: typeof inferredCallsOnly;
231
+ }
232
+ declare function useVariantFieldArray<TItem = InferredTypeArg>(form: FieldArrayFormApi & Readonly<{
233
+ schema: z.ZodType;
234
+ }>, unionPath: TItem extends InferredTypeArg ? never : "Remove the explicit type argument: a schema-typed form infers the item type from the union path and field", field: string): UseFieldArrayReturn<TItem>;
235
+ declare function useVariantFieldArray<TItem = unknown>(form: FieldArrayFormApi & {
236
+ readonly schema?: undefined;
237
+ }, unionPath: string, field: string): UseFieldArrayReturn<TItem>;
238
+ declare function useVariantFieldArray<TSchema extends z.ZodType, P extends string, TField extends VariantArrayFieldPath<UnionValueAt<z.input<TSchema>, P>>, D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, unionPath: P, field: TField): UseFieldArrayReturn<ArrayItemOf<VariantFieldValue<UnionValueAt<z.input<TSchema>, P>, TField>>>;
239
+
226
240
  type UseFieldsReturn<TFields extends readonly unknown[]> = Readonly<{
227
241
  fields: TFields;
228
242
  error: readonly string[] | undefined;
@@ -244,18 +258,24 @@ type BoundUseField<TSchema extends z.ZodType, D extends PathDepth = DefaultPathD
244
258
  <P extends FieldPath<z.input<TSchema>, D>>(path: P, options?: UseFieldOptions): UseFieldReturn<FieldValue<z.input<TSchema>, P>>;
245
259
  };
246
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>;
261
+ 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>>>;
247
262
  type BoundUseFieldArray<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = {
248
263
  (pathSelector: (state: FormState<z.input<TSchema>>) => string): UseFieldArrayReturn<unknown>;
249
264
  <P extends ArrayFieldPath<z.input<TSchema>, D>>(path: P): UseFieldArrayReturn<ArrayItemOf<FieldValue<z.input<TSchema>, P>>>;
250
265
  };
251
266
  type BoundUseSelector<TSchema extends z.ZodType> = <U>(selector: (state: FormState<z.input<TSchema>>) => U) => U;
252
267
  type BoundUseFlag<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = (path?: FieldPath<z.input<TSchema>, D>) => boolean;
268
+ type BoundUseAction<TSchema extends z.ZodType> = (onValid: FormActionHandler<TSchema>, options?: FormActionOptions) => (formData: FormData) => Promise<void>;
269
+ type BoundUseActionState<TSchema extends z.ZodType> = <S>(action: FormActionStateHandler<TSchema, S>, initialState: S, options?: FormActionOptions) => [state: S, formAction: (formData: FormData) => void, isPending: boolean];
270
+ type BoundUsePersist<TSchema extends z.ZodType> = (options: PersistOptions<TSchema>) => PersistHandle;
253
271
  type FormHooks<TSchema extends z.ZodType, N extends string, D extends PathDepth = DefaultPathDepth> = Readonly<{
254
272
  [K in `use${Capitalize<N>}Field`]: BoundUseField<TSchema, D>;
255
273
  } & {
256
274
  [K in `use${Capitalize<N>}VariantField`]: BoundUseVariantField<TSchema>;
257
275
  } & {
258
276
  [K in `use${Capitalize<N>}FieldArray`]: BoundUseFieldArray<TSchema, D>;
277
+ } & {
278
+ [K in `use${Capitalize<N>}VariantFieldArray`]: BoundUseVariantFieldArray<TSchema>;
259
279
  } & {
260
280
  [K in `use${Capitalize<N>}Selector`]: BoundUseSelector<TSchema>;
261
281
  } & {
@@ -278,6 +298,12 @@ type FormHooks<TSchema extends z.ZodType, N extends string, D extends PathDepth
278
298
  [K in `use${Capitalize<N>}Fields`]: BoundUseFields<TSchema, D>;
279
299
  } & {
280
300
  [K in `use${Capitalize<N>}Steps`]: (steps: readonly FormStep<z.input<TSchema>, D>[]) => UseFormStepsReturn;
301
+ } & {
302
+ [K in `use${Capitalize<N>}Action`]: BoundUseAction<TSchema>;
303
+ } & {
304
+ [K in `use${Capitalize<N>}ActionState`]: BoundUseActionState<TSchema>;
305
+ } & {
306
+ [K in `use${Capitalize<N>}Persist`]: BoundUsePersist<TSchema>;
281
307
  }>;
282
308
  type BoundUseFields<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = <const P extends readonly FieldPath<z.input<TSchema>, D>[]>(paths: P) => UseFieldsReturn<{
283
309
  readonly [K in keyof P]: UseFieldReturn<FieldValue<z.input<TSchema>, P[K] & string>>;
@@ -452,5 +478,5 @@ declare const dateInputProps: <T extends Date | null | undefined>(field: UseFiel
452
478
  declare const checkboxProps: <T extends boolean | null | undefined>(field: UseFieldReturn<T>) => CheckboxProps;
453
479
  declare const selectProps: <T extends string | null | undefined>(field: UseFieldReturn<T>) => SelectProps;
454
480
 
455
- 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 };
456
- export type { ArrayPathsOf, BoundUseField, BoundUseFieldArray, BoundUseFields, BoundUseFlag, BoundUseSelector, BoundUseVariantField, 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, VariantFieldPath, VariantFieldValue, VariantKeys };
481
+ 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 };
482
+ 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-BexUOCjZ.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-BexUOCjZ.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-RE6Bjnfv.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-RE6Bjnfv.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
  }>;
@@ -33,7 +34,7 @@ declare const persistForm: <TSchema extends z.ZodType, D extends PathDepth = Def
33
34
 
34
35
  declare const usePersistForm: <TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, options: PersistOptions<TSchema>) => PersistHandle;
35
36
 
36
- declare const useForm: <TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth>(schema: TSchema, options: CreateFormOptions<TSchema, D>) => Form<TSchema, D>;
37
+ declare const useForm: <TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth>(schema: TSchema, options: CreateFormOptions<TSchema, D>) => Form<TSchema, NoInfer<D>>;
37
38
 
38
39
  type ReadonlyStore$2<T> = Pick<StoreApi<T>, "getState" | "getInitialState" | "subscribe">;
39
40
  type FieldFormApi = Readonly<{
@@ -68,17 +69,17 @@ type UseFieldReturn<TValue> = Readonly<{
68
69
  validateAsync: () => Promise<SettledFieldValidationResult>;
69
70
  onBlur: () => void;
70
71
  }>;
71
- declare const inferredCallsOnly$2: unique symbol;
72
- interface InferredTypeArg$2 {
73
- readonly [inferredCallsOnly$2]: typeof inferredCallsOnly$2;
72
+ declare const inferredCallsOnly$3: unique symbol;
73
+ interface InferredTypeArg$3 {
74
+ readonly [inferredCallsOnly$3]: typeof inferredCallsOnly$3;
74
75
  }
75
76
  declare function useField<TSchema extends z.ZodType>(form: FieldFormApi & Readonly<{
76
77
  schema: TSchema;
77
78
  store: ReadonlyStore$2<FormState<z.input<TSchema>>>;
78
79
  }>, pathSelector: (state: FormState<z.input<TSchema>>) => string, options?: UseFieldOptions): UseFieldReturn<unknown>;
79
- declare function useField<TValue = InferredTypeArg$2>(form: FieldFormApi & Readonly<{
80
+ declare function useField<TValue = InferredTypeArg$3>(form: FieldFormApi & Readonly<{
80
81
  schema: z.ZodType;
81
- }>, path: TValue extends InferredTypeArg$2 ? never : "Remove the explicit type argument: a schema-typed form infers the value type from the path", options?: UseFieldOptions): UseFieldReturn<TValue>;
82
+ }>, path: TValue extends InferredTypeArg$3 ? never : "Remove the explicit type argument: a schema-typed form infers the value type from the path", options?: UseFieldOptions): UseFieldReturn<TValue>;
82
83
  declare function useField<TValue = unknown>(form: FieldFormApi & {
83
84
  readonly schema?: undefined;
84
85
  }, path: FieldPathArg<unknown>, options?: UseFieldOptions): UseFieldReturn<TValue>;
@@ -152,13 +153,13 @@ type AllKeys<V> = V extends unknown ? keyof V : never;
152
153
  type VariantKeys<V> = Exclude<AllKeys<V>, CommonKeys<V>> & string;
153
154
  type VariantFieldPath<V, D extends PathDepth = DefaultPathDepth> = Exclude<V extends unknown ? FieldPath<V, D> : never, (CommonKeys<V> & string) | `${CommonKeys<V> & string}.${string}`> & string;
154
155
  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;
155
- declare const inferredCallsOnly$1: unique symbol;
156
- interface InferredTypeArg$1 {
157
- readonly [inferredCallsOnly$1]: typeof inferredCallsOnly$1;
156
+ declare const inferredCallsOnly$2: unique symbol;
157
+ interface InferredTypeArg$2 {
158
+ readonly [inferredCallsOnly$2]: typeof inferredCallsOnly$2;
158
159
  }
159
- declare function useVariantField<TValue = InferredTypeArg$1>(form: FieldFormApi & Readonly<{
160
+ declare function useVariantField<TValue = InferredTypeArg$2>(form: FieldFormApi & Readonly<{
160
161
  schema: z.ZodType;
161
- }>, unionPath: TValue extends InferredTypeArg$1 ? 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>;
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>;
162
163
  declare function useVariantField<TValue = unknown>(form: FieldFormApi & {
163
164
  readonly schema?: undefined;
164
165
  }, unionPath: string, field: string): UseFieldReturn<TValue | undefined>;
@@ -207,22 +208,35 @@ type UseFieldArrayReturn<TItem> = Readonly<{
207
208
  prepend: (item: TItem) => void;
208
209
  clear: () => void;
209
210
  }>;
210
- declare const inferredCallsOnly: unique symbol;
211
- interface InferredTypeArg {
212
- readonly [inferredCallsOnly]: typeof inferredCallsOnly;
211
+ declare const inferredCallsOnly$1: unique symbol;
212
+ interface InferredTypeArg$1 {
213
+ readonly [inferredCallsOnly$1]: typeof inferredCallsOnly$1;
213
214
  }
214
215
  declare function useFieldArray<TSchema extends z.ZodType>(form: FieldArrayFormApi & Readonly<{
215
216
  schema: TSchema;
216
217
  store: ReadonlyStore$1<FormState<z.input<TSchema>>>;
217
218
  }>, pathSelector: (state: FormState<z.input<TSchema>>) => string): UseFieldArrayReturn<unknown>;
218
- declare function useFieldArray<TItem = InferredTypeArg>(form: FieldArrayFormApi & Readonly<{
219
+ declare function useFieldArray<TItem = InferredTypeArg$1>(form: FieldArrayFormApi & Readonly<{
219
220
  schema: z.ZodType;
220
- }>, path: TItem extends InferredTypeArg ? never : "Remove the explicit type argument: a schema-typed form infers the item type from the path"): UseFieldArrayReturn<TItem>;
221
+ }>, path: TItem extends InferredTypeArg$1 ? never : "Remove the explicit type argument: a schema-typed form infers the item type from the path"): UseFieldArrayReturn<TItem>;
221
222
  declare function useFieldArray<TItem = unknown>(form: FieldArrayFormApi & {
222
223
  readonly schema?: undefined;
223
224
  }, path: FieldPathArg<unknown>): UseFieldArrayReturn<TItem>;
224
225
  declare function useFieldArray<TSchema extends z.ZodType, P extends ArrayFieldPath<z.input<TSchema>, D> & string, D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, path: P): UseFieldArrayReturn<ArrayItemOf<FieldValue<z.input<TSchema>, P>>>;
225
226
 
227
+ type VariantArrayFieldPath<V, D extends PathDepth = DefaultPathDepth> = Exclude<V extends unknown ? ArrayFieldPath<V, D> : never, (keyof V & string) | `${keyof V & string}.${string}`> & string;
228
+ declare const inferredCallsOnly: unique symbol;
229
+ interface InferredTypeArg {
230
+ readonly [inferredCallsOnly]: typeof inferredCallsOnly;
231
+ }
232
+ declare function useVariantFieldArray<TItem = InferredTypeArg>(form: FieldArrayFormApi & Readonly<{
233
+ schema: z.ZodType;
234
+ }>, unionPath: TItem extends InferredTypeArg ? never : "Remove the explicit type argument: a schema-typed form infers the item type from the union path and field", field: string): UseFieldArrayReturn<TItem>;
235
+ declare function useVariantFieldArray<TItem = unknown>(form: FieldArrayFormApi & {
236
+ readonly schema?: undefined;
237
+ }, unionPath: string, field: string): UseFieldArrayReturn<TItem>;
238
+ declare function useVariantFieldArray<TSchema extends z.ZodType, P extends string, TField extends VariantArrayFieldPath<UnionValueAt<z.input<TSchema>, P>>, D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, unionPath: P, field: TField): UseFieldArrayReturn<ArrayItemOf<VariantFieldValue<UnionValueAt<z.input<TSchema>, P>, TField>>>;
239
+
226
240
  type UseFieldsReturn<TFields extends readonly unknown[]> = Readonly<{
227
241
  fields: TFields;
228
242
  error: readonly string[] | undefined;
@@ -244,18 +258,24 @@ type BoundUseField<TSchema extends z.ZodType, D extends PathDepth = DefaultPathD
244
258
  <P extends FieldPath<z.input<TSchema>, D>>(path: P, options?: UseFieldOptions): UseFieldReturn<FieldValue<z.input<TSchema>, P>>;
245
259
  };
246
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>;
261
+ 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>>>;
247
262
  type BoundUseFieldArray<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = {
248
263
  (pathSelector: (state: FormState<z.input<TSchema>>) => string): UseFieldArrayReturn<unknown>;
249
264
  <P extends ArrayFieldPath<z.input<TSchema>, D>>(path: P): UseFieldArrayReturn<ArrayItemOf<FieldValue<z.input<TSchema>, P>>>;
250
265
  };
251
266
  type BoundUseSelector<TSchema extends z.ZodType> = <U>(selector: (state: FormState<z.input<TSchema>>) => U) => U;
252
267
  type BoundUseFlag<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = (path?: FieldPath<z.input<TSchema>, D>) => boolean;
268
+ type BoundUseAction<TSchema extends z.ZodType> = (onValid: FormActionHandler<TSchema>, options?: FormActionOptions) => (formData: FormData) => Promise<void>;
269
+ type BoundUseActionState<TSchema extends z.ZodType> = <S>(action: FormActionStateHandler<TSchema, S>, initialState: S, options?: FormActionOptions) => [state: S, formAction: (formData: FormData) => void, isPending: boolean];
270
+ type BoundUsePersist<TSchema extends z.ZodType> = (options: PersistOptions<TSchema>) => PersistHandle;
253
271
  type FormHooks<TSchema extends z.ZodType, N extends string, D extends PathDepth = DefaultPathDepth> = Readonly<{
254
272
  [K in `use${Capitalize<N>}Field`]: BoundUseField<TSchema, D>;
255
273
  } & {
256
274
  [K in `use${Capitalize<N>}VariantField`]: BoundUseVariantField<TSchema>;
257
275
  } & {
258
276
  [K in `use${Capitalize<N>}FieldArray`]: BoundUseFieldArray<TSchema, D>;
277
+ } & {
278
+ [K in `use${Capitalize<N>}VariantFieldArray`]: BoundUseVariantFieldArray<TSchema>;
259
279
  } & {
260
280
  [K in `use${Capitalize<N>}Selector`]: BoundUseSelector<TSchema>;
261
281
  } & {
@@ -278,6 +298,12 @@ type FormHooks<TSchema extends z.ZodType, N extends string, D extends PathDepth
278
298
  [K in `use${Capitalize<N>}Fields`]: BoundUseFields<TSchema, D>;
279
299
  } & {
280
300
  [K in `use${Capitalize<N>}Steps`]: (steps: readonly FormStep<z.input<TSchema>, D>[]) => UseFormStepsReturn;
301
+ } & {
302
+ [K in `use${Capitalize<N>}Action`]: BoundUseAction<TSchema>;
303
+ } & {
304
+ [K in `use${Capitalize<N>}ActionState`]: BoundUseActionState<TSchema>;
305
+ } & {
306
+ [K in `use${Capitalize<N>}Persist`]: BoundUsePersist<TSchema>;
281
307
  }>;
282
308
  type BoundUseFields<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = <const P extends readonly FieldPath<z.input<TSchema>, D>[]>(paths: P) => UseFieldsReturn<{
283
309
  readonly [K in keyof P]: UseFieldReturn<FieldValue<z.input<TSchema>, P[K] & string>>;
@@ -452,5 +478,5 @@ declare const dateInputProps: <T extends Date | null | undefined>(field: UseFiel
452
478
  declare const checkboxProps: <T extends boolean | null | undefined>(field: UseFieldReturn<T>) => CheckboxProps;
453
479
  declare const selectProps: <T extends string | null | undefined>(field: UseFieldReturn<T>) => SelectProps;
454
480
 
455
- 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 };
456
- export type { ArrayPathsOf, BoundUseField, BoundUseFieldArray, BoundUseFields, BoundUseFlag, BoundUseSelector, BoundUseVariantField, 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, VariantFieldPath, VariantFieldValue, VariantKeys };
481
+ 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 };
482
+ 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 };