formstand 0.19.0 → 0.21.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,8 +1,8 @@
1
- import { P as PathDepth, D as DefaultPathDepth, F as Form, C as CreateFormOptions, I as InvalidSubmitHandler, a as FieldValidationResult, S as SettledFieldValidationResult, b as FormState, c as FieldPath, d as FieldValue, E as ErrorMap } from './createForm-B73p1TgL.cjs';
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, I as InvalidSubmitHandler, E as ErrorMap } from './createForm-B73p1TgL.cjs';
2
2
  export { B as BoolMap, e as FieldSnapshot, f as FieldsValidationResult, 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
- import { ReactNode, ChangeEvent } from 'react';
5
+ import { ChangeEvent, ReactNode } from 'react';
6
6
  import { StoreApi } from 'zustand/vanilla';
7
7
 
8
8
  type PathSegment = string | number;
@@ -33,25 +33,6 @@ declare const usePersistForm: <TSchema extends z.ZodType, D extends PathDepth =
33
33
 
34
34
  declare const useForm: <TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth>(schema: TSchema, options: CreateFormOptions<TSchema, D>) => Form<TSchema, D>;
35
35
 
36
- type FormActionHandler<TSchema extends z.ZodType> = (data: z.output<TSchema>, formData: FormData) => void | Promise<void>;
37
- type FormActionStateHandler<TSchema extends z.ZodType, S> = (prevState: S, data: z.output<TSchema>, formData: FormData) => S | Promise<S>;
38
- type FormActionOptions = Readonly<{
39
- onInvalid?: InvalidSubmitHandler;
40
- onError?: (error: unknown) => void;
41
- }>;
42
- declare const useFormAction: <TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, onValid: FormActionHandler<TSchema>, options?: FormActionOptions) => ((formData: FormData) => Promise<void>);
43
- 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];
44
-
45
- type FormProviderProps<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = Readonly<{
46
- form: Form<TSchema, D>;
47
- children: ReactNode;
48
- }>;
49
- type FormContextApi<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = Readonly<{
50
- Provider: (props: FormProviderProps<TSchema, D>) => ReactNode;
51
- useFormContext: () => Form<TSchema, D>;
52
- }>;
53
- declare const createFormContext: <TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth>() => FormContextApi<TSchema, D>;
54
-
55
36
  type ReadonlyStore$2<T> = Pick<StoreApi<T>, "getState" | "getInitialState" | "subscribe">;
56
37
  type FieldFormApi = Readonly<{
57
38
  store: ReadonlyStore$2<FormState<unknown>>;
@@ -101,10 +82,73 @@ declare function useField<TValue = unknown>(form: FieldFormApi & {
101
82
  }, path: FieldPathArg<unknown>, options?: UseFieldOptions): UseFieldReturn<TValue>;
102
83
  declare function useField<TSchema extends z.ZodType, P extends FieldPath<z.input<TSchema>, D>, D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, path: P, options?: UseFieldOptions): UseFieldReturn<FieldValue<z.input<TSchema>, P>>;
103
84
 
104
- type VariantFieldValue<V, TField extends string> = V extends unknown ? TField extends keyof V ? V[TField] : never : never;
85
+ type MaskedParse<TValue> = Readonly<{
86
+ kind: "value";
87
+ value: TValue;
88
+ }> | Readonly<{
89
+ kind: "empty";
90
+ }> | Readonly<{
91
+ kind: "invalid";
92
+ }>;
93
+ type MaskedInputOptions<TValue> = Readonly<{
94
+ parse: (text: string) => MaskedParse<TValue>;
95
+ format: (value: TValue) => string;
96
+ }>;
97
+ type MaskedInputBinding = Readonly<{
98
+ name: string;
99
+ value: string;
100
+ "aria-invalid": true | undefined;
101
+ onChange: (e: ChangeEvent<HTMLInputElement>) => void;
102
+ onBlur: () => void;
103
+ }>;
104
+ declare const useMaskedInput: <TValue>(field: UseFieldReturn<TValue>, options: MaskedInputOptions<NonNullable<TValue>>) => MaskedInputBinding;
105
+
106
+ type FormStep<TValues, D extends PathDepth = DefaultPathDepth> = Readonly<{
107
+ name?: string;
108
+ fields: readonly FieldPath<TValues, D>[];
109
+ }>;
110
+ type StepStatus = Readonly<{
111
+ name: string | undefined;
112
+ visited: boolean;
113
+ hasErrors: boolean;
114
+ }>;
115
+ type UseFormStepsReturn = Readonly<{
116
+ step: number;
117
+ name: string | undefined;
118
+ count: number;
119
+ isFirst: boolean;
120
+ isLast: boolean;
121
+ next: () => Promise<boolean>;
122
+ back: () => void;
123
+ goTo: (target: number) => Promise<number>;
124
+ steps: readonly StepStatus[];
125
+ }>;
126
+ declare const useFormSteps: <TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, steps: readonly FormStep<z.input<TSchema>, D>[]) => UseFormStepsReturn;
127
+
128
+ type FormActionHandler<TSchema extends z.ZodType> = (data: z.output<TSchema>, formData: FormData) => void | Promise<void>;
129
+ type FormActionStateHandler<TSchema extends z.ZodType, S> = (prevState: S, data: z.output<TSchema>, formData: FormData) => S | Promise<S>;
130
+ type FormActionOptions = Readonly<{
131
+ onInvalid?: InvalidSubmitHandler;
132
+ onError?: (error: unknown) => void;
133
+ }>;
134
+ declare const useFormAction: <TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, onValid: FormActionHandler<TSchema>, options?: FormActionOptions) => ((formData: FormData) => Promise<void>);
135
+ 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];
136
+
137
+ type FormProviderProps<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = Readonly<{
138
+ form: Form<TSchema, D>;
139
+ children: ReactNode;
140
+ }>;
141
+ type FormContextApi<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = Readonly<{
142
+ Provider: (props: FormProviderProps<TSchema, D>) => ReactNode;
143
+ useFormContext: () => Form<TSchema, D>;
144
+ }>;
145
+ declare const createFormContext: <TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth>() => FormContextApi<TSchema, D>;
146
+
147
+ type VariantFieldValue<V, TField extends string> = V extends unknown ? FieldValue<V, TField> : never;
105
148
  type CommonKeys<V> = keyof V;
106
149
  type AllKeys<V> = V extends unknown ? keyof V : never;
107
150
  type VariantKeys<V> = Exclude<AllKeys<V>, CommonKeys<V>> & string;
151
+ type VariantFieldPath<V, D extends PathDepth = DefaultPathDepth> = Exclude<V extends unknown ? FieldPath<V, D> : never, (CommonKeys<V> & string) | `${CommonKeys<V> & string}.${string}`> & string;
108
152
  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;
109
153
  declare const inferredCallsOnly$1: unique symbol;
110
154
  interface InferredTypeArg$1 {
@@ -116,7 +160,7 @@ declare function useVariantField<TValue = InferredTypeArg$1>(form: FieldFormApi
116
160
  declare function useVariantField<TValue = unknown>(form: FieldFormApi & {
117
161
  readonly schema?: undefined;
118
162
  }, unionPath: string, field: string): UseFieldReturn<TValue | undefined>;
119
- declare function useVariantField<TSchema extends z.ZodType, P extends string, TField extends VariantKeys<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>;
163
+ 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>;
120
164
 
121
165
  type ReadonlyStore$1<T> = Pick<StoreApi<T>, "getState" | "getInitialState" | "subscribe">;
122
166
  type FieldArrayFormApi = Readonly<{
@@ -186,7 +230,7 @@ type BoundUseField<TSchema extends z.ZodType, D extends PathDepth = DefaultPathD
186
230
  (pathSelector: (state: FormState<z.input<TSchema>>) => string, options?: UseFieldOptions): UseFieldReturn<unknown>;
187
231
  <P extends FieldPath<z.input<TSchema>, D>>(path: P, options?: UseFieldOptions): UseFieldReturn<FieldValue<z.input<TSchema>, P>>;
188
232
  };
189
- type BoundUseVariantField<TSchema extends z.ZodType> = <P extends string, TField extends VariantKeys<UnionValueAt<z.input<TSchema>, P>>>(unionPath: P, field: TField) => UseFieldReturn<VariantFieldValue<UnionValueAt<z.input<TSchema>, P>, TField> | undefined>;
233
+ 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>;
190
234
  type BoundUseFieldArray<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = {
191
235
  (pathSelector: (state: FormState<z.input<TSchema>>) => string): UseFieldArrayReturn<unknown>;
192
236
  <P extends FieldPath<z.input<TSchema>, D>>(path: P): UseFieldArrayReturn<ArrayItemOf<FieldValue<z.input<TSchema>, P>>>;
@@ -219,6 +263,8 @@ type FormHooks<TSchema extends z.ZodType, N extends string, D extends PathDepth
219
263
  [K in `use${Capitalize<N>}Values`]: () => z.input<TSchema>;
220
264
  } & {
221
265
  [K in `use${Capitalize<N>}Fields`]: BoundUseFields<TSchema, D>;
266
+ } & {
267
+ [K in `use${Capitalize<N>}Steps`]: (steps: readonly FormStep<z.input<TSchema>, D>[]) => UseFormStepsReturn;
222
268
  }>;
223
269
  type BoundUseFields<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = <const P extends readonly FieldPath<z.input<TSchema>, D>[]>(paths: P) => UseFieldsReturn<{
224
270
  readonly [K in keyof P]: UseFieldReturn<FieldValue<z.input<TSchema>, P[K] & string>>;
@@ -389,4 +435,4 @@ declare const dateInputProps: <T extends Date | null | undefined>(field: UseFiel
389
435
  declare const checkboxProps: <T extends boolean | null | undefined>(field: UseFieldReturn<T>) => CheckboxProps;
390
436
  declare const selectProps: <T extends string | null | undefined>(field: UseFieldReturn<T>) => SelectProps;
391
437
 
392
- 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 FormActionHandler, type FormActionOptions, type FormActionStateHandler, type FormContextApi, type FormHooks, type FormProviderProps, FormState, type FormStateApi, InvalidSubmitHandler, 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, useFormAction, useFormActionState, useFormError, useFormSelector, useFormSelectorShallow, useFormValues, useIsDirty, useIsSubmitting, useIsValid, useIsValidating, useNumberInput, usePersistForm, useSubmitCount, useVariantField };
438
+ 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 FormActionHandler, type FormActionOptions, type FormActionStateHandler, type FormContextApi, type FormHooks, type FormProviderProps, FormState, type FormStateApi, type FormStep, InvalidSubmitHandler, type MaskedInputBinding, type MaskedInputOptions, type MaskedParse, 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, type StepStatus, TextField, type TextFieldProps, type TextInputProps, type UnionValueAt, type UseFieldArrayReturn, type UseFieldOptions, type UseFieldReturn, type UseFieldsReturn, type UseFormStepsReturn, type VariantFieldPath, type VariantFieldValue, type VariantKeys, 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 };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { P as PathDepth, D as DefaultPathDepth, F as Form, C as CreateFormOptions, I as InvalidSubmitHandler, a as FieldValidationResult, S as SettledFieldValidationResult, b as FormState, c as FieldPath, d as FieldValue, E as ErrorMap } from './createForm-B73p1TgL.js';
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, I as InvalidSubmitHandler, E as ErrorMap } from './createForm-B73p1TgL.js';
2
2
  export { B as BoolMap, e as FieldSnapshot, f as FieldsValidationResult, 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
- import { ReactNode, ChangeEvent } from 'react';
5
+ import { ChangeEvent, ReactNode } from 'react';
6
6
  import { StoreApi } from 'zustand/vanilla';
7
7
 
8
8
  type PathSegment = string | number;
@@ -33,25 +33,6 @@ declare const usePersistForm: <TSchema extends z.ZodType, D extends PathDepth =
33
33
 
34
34
  declare const useForm: <TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth>(schema: TSchema, options: CreateFormOptions<TSchema, D>) => Form<TSchema, D>;
35
35
 
36
- type FormActionHandler<TSchema extends z.ZodType> = (data: z.output<TSchema>, formData: FormData) => void | Promise<void>;
37
- type FormActionStateHandler<TSchema extends z.ZodType, S> = (prevState: S, data: z.output<TSchema>, formData: FormData) => S | Promise<S>;
38
- type FormActionOptions = Readonly<{
39
- onInvalid?: InvalidSubmitHandler;
40
- onError?: (error: unknown) => void;
41
- }>;
42
- declare const useFormAction: <TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, onValid: FormActionHandler<TSchema>, options?: FormActionOptions) => ((formData: FormData) => Promise<void>);
43
- 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];
44
-
45
- type FormProviderProps<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = Readonly<{
46
- form: Form<TSchema, D>;
47
- children: ReactNode;
48
- }>;
49
- type FormContextApi<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = Readonly<{
50
- Provider: (props: FormProviderProps<TSchema, D>) => ReactNode;
51
- useFormContext: () => Form<TSchema, D>;
52
- }>;
53
- declare const createFormContext: <TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth>() => FormContextApi<TSchema, D>;
54
-
55
36
  type ReadonlyStore$2<T> = Pick<StoreApi<T>, "getState" | "getInitialState" | "subscribe">;
56
37
  type FieldFormApi = Readonly<{
57
38
  store: ReadonlyStore$2<FormState<unknown>>;
@@ -101,10 +82,73 @@ declare function useField<TValue = unknown>(form: FieldFormApi & {
101
82
  }, path: FieldPathArg<unknown>, options?: UseFieldOptions): UseFieldReturn<TValue>;
102
83
  declare function useField<TSchema extends z.ZodType, P extends FieldPath<z.input<TSchema>, D>, D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, path: P, options?: UseFieldOptions): UseFieldReturn<FieldValue<z.input<TSchema>, P>>;
103
84
 
104
- type VariantFieldValue<V, TField extends string> = V extends unknown ? TField extends keyof V ? V[TField] : never : never;
85
+ type MaskedParse<TValue> = Readonly<{
86
+ kind: "value";
87
+ value: TValue;
88
+ }> | Readonly<{
89
+ kind: "empty";
90
+ }> | Readonly<{
91
+ kind: "invalid";
92
+ }>;
93
+ type MaskedInputOptions<TValue> = Readonly<{
94
+ parse: (text: string) => MaskedParse<TValue>;
95
+ format: (value: TValue) => string;
96
+ }>;
97
+ type MaskedInputBinding = Readonly<{
98
+ name: string;
99
+ value: string;
100
+ "aria-invalid": true | undefined;
101
+ onChange: (e: ChangeEvent<HTMLInputElement>) => void;
102
+ onBlur: () => void;
103
+ }>;
104
+ declare const useMaskedInput: <TValue>(field: UseFieldReturn<TValue>, options: MaskedInputOptions<NonNullable<TValue>>) => MaskedInputBinding;
105
+
106
+ type FormStep<TValues, D extends PathDepth = DefaultPathDepth> = Readonly<{
107
+ name?: string;
108
+ fields: readonly FieldPath<TValues, D>[];
109
+ }>;
110
+ type StepStatus = Readonly<{
111
+ name: string | undefined;
112
+ visited: boolean;
113
+ hasErrors: boolean;
114
+ }>;
115
+ type UseFormStepsReturn = Readonly<{
116
+ step: number;
117
+ name: string | undefined;
118
+ count: number;
119
+ isFirst: boolean;
120
+ isLast: boolean;
121
+ next: () => Promise<boolean>;
122
+ back: () => void;
123
+ goTo: (target: number) => Promise<number>;
124
+ steps: readonly StepStatus[];
125
+ }>;
126
+ declare const useFormSteps: <TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, steps: readonly FormStep<z.input<TSchema>, D>[]) => UseFormStepsReturn;
127
+
128
+ type FormActionHandler<TSchema extends z.ZodType> = (data: z.output<TSchema>, formData: FormData) => void | Promise<void>;
129
+ type FormActionStateHandler<TSchema extends z.ZodType, S> = (prevState: S, data: z.output<TSchema>, formData: FormData) => S | Promise<S>;
130
+ type FormActionOptions = Readonly<{
131
+ onInvalid?: InvalidSubmitHandler;
132
+ onError?: (error: unknown) => void;
133
+ }>;
134
+ declare const useFormAction: <TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth>(form: Form<TSchema, D>, onValid: FormActionHandler<TSchema>, options?: FormActionOptions) => ((formData: FormData) => Promise<void>);
135
+ 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];
136
+
137
+ type FormProviderProps<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = Readonly<{
138
+ form: Form<TSchema, D>;
139
+ children: ReactNode;
140
+ }>;
141
+ type FormContextApi<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = Readonly<{
142
+ Provider: (props: FormProviderProps<TSchema, D>) => ReactNode;
143
+ useFormContext: () => Form<TSchema, D>;
144
+ }>;
145
+ declare const createFormContext: <TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth>() => FormContextApi<TSchema, D>;
146
+
147
+ type VariantFieldValue<V, TField extends string> = V extends unknown ? FieldValue<V, TField> : never;
105
148
  type CommonKeys<V> = keyof V;
106
149
  type AllKeys<V> = V extends unknown ? keyof V : never;
107
150
  type VariantKeys<V> = Exclude<AllKeys<V>, CommonKeys<V>> & string;
151
+ type VariantFieldPath<V, D extends PathDepth = DefaultPathDepth> = Exclude<V extends unknown ? FieldPath<V, D> : never, (CommonKeys<V> & string) | `${CommonKeys<V> & string}.${string}`> & string;
108
152
  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;
109
153
  declare const inferredCallsOnly$1: unique symbol;
110
154
  interface InferredTypeArg$1 {
@@ -116,7 +160,7 @@ declare function useVariantField<TValue = InferredTypeArg$1>(form: FieldFormApi
116
160
  declare function useVariantField<TValue = unknown>(form: FieldFormApi & {
117
161
  readonly schema?: undefined;
118
162
  }, unionPath: string, field: string): UseFieldReturn<TValue | undefined>;
119
- declare function useVariantField<TSchema extends z.ZodType, P extends string, TField extends VariantKeys<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>;
163
+ 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>;
120
164
 
121
165
  type ReadonlyStore$1<T> = Pick<StoreApi<T>, "getState" | "getInitialState" | "subscribe">;
122
166
  type FieldArrayFormApi = Readonly<{
@@ -186,7 +230,7 @@ type BoundUseField<TSchema extends z.ZodType, D extends PathDepth = DefaultPathD
186
230
  (pathSelector: (state: FormState<z.input<TSchema>>) => string, options?: UseFieldOptions): UseFieldReturn<unknown>;
187
231
  <P extends FieldPath<z.input<TSchema>, D>>(path: P, options?: UseFieldOptions): UseFieldReturn<FieldValue<z.input<TSchema>, P>>;
188
232
  };
189
- type BoundUseVariantField<TSchema extends z.ZodType> = <P extends string, TField extends VariantKeys<UnionValueAt<z.input<TSchema>, P>>>(unionPath: P, field: TField) => UseFieldReturn<VariantFieldValue<UnionValueAt<z.input<TSchema>, P>, TField> | undefined>;
233
+ 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>;
190
234
  type BoundUseFieldArray<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = {
191
235
  (pathSelector: (state: FormState<z.input<TSchema>>) => string): UseFieldArrayReturn<unknown>;
192
236
  <P extends FieldPath<z.input<TSchema>, D>>(path: P): UseFieldArrayReturn<ArrayItemOf<FieldValue<z.input<TSchema>, P>>>;
@@ -219,6 +263,8 @@ type FormHooks<TSchema extends z.ZodType, N extends string, D extends PathDepth
219
263
  [K in `use${Capitalize<N>}Values`]: () => z.input<TSchema>;
220
264
  } & {
221
265
  [K in `use${Capitalize<N>}Fields`]: BoundUseFields<TSchema, D>;
266
+ } & {
267
+ [K in `use${Capitalize<N>}Steps`]: (steps: readonly FormStep<z.input<TSchema>, D>[]) => UseFormStepsReturn;
222
268
  }>;
223
269
  type BoundUseFields<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = <const P extends readonly FieldPath<z.input<TSchema>, D>[]>(paths: P) => UseFieldsReturn<{
224
270
  readonly [K in keyof P]: UseFieldReturn<FieldValue<z.input<TSchema>, P[K] & string>>;
@@ -389,4 +435,4 @@ declare const dateInputProps: <T extends Date | null | undefined>(field: UseFiel
389
435
  declare const checkboxProps: <T extends boolean | null | undefined>(field: UseFieldReturn<T>) => CheckboxProps;
390
436
  declare const selectProps: <T extends string | null | undefined>(field: UseFieldReturn<T>) => SelectProps;
391
437
 
392
- 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 FormActionHandler, type FormActionOptions, type FormActionStateHandler, type FormContextApi, type FormHooks, type FormProviderProps, FormState, type FormStateApi, InvalidSubmitHandler, 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, useFormAction, useFormActionState, useFormError, useFormSelector, useFormSelectorShallow, useFormValues, useIsDirty, useIsSubmitting, useIsValid, useIsValidating, useNumberInput, usePersistForm, useSubmitCount, useVariantField };
438
+ 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 FormActionHandler, type FormActionOptions, type FormActionStateHandler, type FormContextApi, type FormHooks, type FormProviderProps, FormState, type FormStateApi, type FormStep, InvalidSubmitHandler, type MaskedInputBinding, type MaskedInputOptions, type MaskedParse, 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, type StepStatus, TextField, type TextFieldProps, type TextInputProps, type UnionValueAt, type UseFieldArrayReturn, type UseFieldOptions, type UseFieldReturn, type UseFieldsReturn, type UseFormStepsReturn, type VariantFieldPath, type VariantFieldValue, type VariantKeys, 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 };