formstand 0.25.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-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-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
  }>;
@@ -264,6 +265,9 @@ type BoundUseFieldArray<TSchema extends z.ZodType, D extends PathDepth = Default
264
265
  };
265
266
  type BoundUseSelector<TSchema extends z.ZodType> = <U>(selector: (state: FormState<z.input<TSchema>>) => U) => U;
266
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;
267
271
  type FormHooks<TSchema extends z.ZodType, N extends string, D extends PathDepth = DefaultPathDepth> = Readonly<{
268
272
  [K in `use${Capitalize<N>}Field`]: BoundUseField<TSchema, D>;
269
273
  } & {
@@ -294,6 +298,12 @@ type FormHooks<TSchema extends z.ZodType, N extends string, D extends PathDepth
294
298
  [K in `use${Capitalize<N>}Fields`]: BoundUseFields<TSchema, D>;
295
299
  } & {
296
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>;
297
307
  }>;
298
308
  type BoundUseFields<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = <const P extends readonly FieldPath<z.input<TSchema>, D>[]>(paths: P) => UseFieldsReturn<{
299
309
  readonly [K in keyof P]: UseFieldReturn<FieldValue<z.input<TSchema>, P[K] & string>>;
@@ -469,4 +479,4 @@ declare const checkboxProps: <T extends boolean | null | undefined>(field: UseFi
469
479
  declare const selectProps: <T extends string | null | undefined>(field: UseFieldReturn<T>) => SelectProps;
470
480
 
471
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 };
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 };
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-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-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
  }>;
@@ -264,6 +265,9 @@ type BoundUseFieldArray<TSchema extends z.ZodType, D extends PathDepth = Default
264
265
  };
265
266
  type BoundUseSelector<TSchema extends z.ZodType> = <U>(selector: (state: FormState<z.input<TSchema>>) => U) => U;
266
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;
267
271
  type FormHooks<TSchema extends z.ZodType, N extends string, D extends PathDepth = DefaultPathDepth> = Readonly<{
268
272
  [K in `use${Capitalize<N>}Field`]: BoundUseField<TSchema, D>;
269
273
  } & {
@@ -294,6 +298,12 @@ type FormHooks<TSchema extends z.ZodType, N extends string, D extends PathDepth
294
298
  [K in `use${Capitalize<N>}Fields`]: BoundUseFields<TSchema, D>;
295
299
  } & {
296
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>;
297
307
  }>;
298
308
  type BoundUseFields<TSchema extends z.ZodType, D extends PathDepth = DefaultPathDepth> = <const P extends readonly FieldPath<z.input<TSchema>, D>[]>(paths: P) => UseFieldsReturn<{
299
309
  readonly [K in keyof P]: UseFieldReturn<FieldValue<z.input<TSchema>, P[K] & string>>;
@@ -469,4 +479,4 @@ declare const checkboxProps: <T extends boolean | null | undefined>(field: UseFi
469
479
  declare const selectProps: <T extends string | null | undefined>(field: UseFieldReturn<T>) => SelectProps;
470
480
 
471
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 };
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 };
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 };