@saas-ui/forms 3.0.0-next.19 → 3.0.0-next.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @saas-ui/forms
2
2
 
3
+ ## 3.0.0-next.20
4
+
5
+ ### Minor Changes
6
+
7
+ - f18c762: useForm now supports standard schema, with support for zod, valibot, arktype and more.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [729b57d]
12
+ - @saas-ui/react@3.0.0-next.20
13
+
3
14
  ## 3.0.0-next.19
4
15
 
5
16
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -4,7 +4,7 @@ import { SimpleGridProps, RecipeProps, InputProps, SystemStyleObject, TextareaPr
4
4
  import { MaybeRenderProp } from '@saas-ui/core/utils';
5
5
  import * as react_hook_form from 'react-hook-form';
6
6
  import { FieldValues, FieldPath, UseFormReturn as UseFormReturn$2, UseFieldArrayReturn, UseFormProps as UseFormProps$1, WatchObserver, SubmitHandler, SubmitErrorHandler, ResolverOptions, ResolverResult, RegisterOptions, useForm as useForm$1, DefaultValues, FormProviderProps as FormProviderProps$1 } from 'react-hook-form';
7
- export { ArrayPath, BatchFieldArrayUpdate, BrowserNativeObject, ChangeHandler, Control, Controller, ControllerFieldState, ControllerProps, ControllerRenderProps, CriteriaMode, CustomElement, DeepMap, DeepPartial, DeepPartialSkipArrayKey, DeepRequired, DefaultValues, DelayCallback, EmptyObject, ErrorOption, EventType, ExtractObjects, FieldArray, FieldArrayMethodProps, FieldArrayPath, FieldArrayPathValue, FieldArrayWithId, Field as FieldDef, FieldElement, FieldError, FieldErrors, FieldErrorsImpl, FieldName, FieldNamesMarkedBoolean, FieldPath, FieldPathByValue, FieldPathValue, FieldPathValues, FieldRefs, FieldValue, FieldValues, FormProviderProps, FormState, FormStateProxy, FormStateSubjectRef, GetIsDirty, InternalFieldErrors, InternalFieldName, InternalNameSet, IsAny, IsFlatObject, KeepStateOptions, LiteralUnion, Message, Mode, MultipleFieldErrors, Names, NativeFieldValue, NestedValue, NonUndefined, Noop, Primitive, ReadFormState, Ref, RefCallBack, RegisterOptions, Resolver, ResolverError, ResolverOptions, ResolverResult, ResolverSuccess, SetFieldValue, SetValueConfig, Subjects, SubmitErrorHandler, SubmitHandler, TriggerConfig, UnpackNestedValue, UseControllerProps, UseControllerReturn, UseFieldArrayProps, UseFieldArrayReturn, UseFormClearErrors, UseFormGetValues, UseFormHandleSubmit, UseFormRegister, UseFormRegisterReturn, UseFormReset, UseFormResetField, UseFormSetError, UseFormSetFocus, UseFormSetValue, UseFormStateProps, UseFormStateReturn, UseFormTrigger, UseFormUnregister, UseFormWatch, UseWatchProps, Validate, ValidateResult, ValidationMode, ValidationRule, ValidationValue, ValidationValueMessage, WatchInternal, WatchObserver, appendErrors, useController, useFieldArray, useFormState, useWatch } from 'react-hook-form';
7
+ export { ArrayPath, BatchFieldArrayUpdate, BrowserNativeObject, ChangeHandler, Control, Controller, ControllerFieldState, ControllerProps, ControllerRenderProps, CriteriaMode, CustomElement, DeepMap, DeepPartial, DeepPartialSkipArrayKey, DeepRequired, DefaultValues, DelayCallback, EmptyObject, ErrorOption, EventType, ExtractObjects, FieldArray, FieldArrayMethodProps, FieldArrayPath, FieldArrayPathValue, FieldArrayWithId, Field as FieldDef, FieldElement, FieldError, FieldErrors, FieldErrorsImpl, FieldName, FieldNamesMarkedBoolean, FieldPath, FieldPathByValue, FieldPathValue, FieldPathValues, FieldRefs, FieldValue, FieldValues, FormProviderProps, FormState, FormStateProxy, FormStateSubjectRef, GetIsDirty, InternalFieldErrors, InternalFieldName, InternalNameSet, IsAny, IsFlatObject, KeepStateOptions, LiteralUnion, Message, Mode, MultipleFieldErrors, Names, NativeFieldValue, NestedValue, NonUndefined, Noop, Primitive, ReadFormState, Ref, RefCallBack, RegisterOptions, Resolver, ResolverError, ResolverOptions, ResolverResult, ResolverSuccess, SetFieldValue, SetValueConfig, Subjects, SubmitErrorHandler, SubmitHandler, TriggerConfig, UseControllerProps, UseControllerReturn, UseFieldArrayProps, UseFieldArrayReturn, UseFormClearErrors, UseFormGetValues, UseFormHandleSubmit, UseFormRegister, UseFormRegisterReturn, UseFormReset, UseFormResetField, UseFormSetError, UseFormSetFocus, UseFormSetValue, UseFormStateProps, UseFormStateReturn, UseFormTrigger, UseFormUnregister, UseFormWatch, UseWatchProps, Validate, ValidateResult, ValidationMode, ValidationRule, ValidationValue, ValidationValueMessage, WatchInternal, WatchObserver, appendErrors, useController, useFieldArray, useFormState, useWatch } from 'react-hook-form';
8
8
  import { CheckboxProps } from '@saas-ui/react/checkbox';
9
9
  import { NumberInputProps } from '@saas-ui/react/number-input';
10
10
  import { PasswordInputProps } from '@saas-ui/react/password-input';
@@ -15,6 +15,7 @@ import { SwitchProps } from '@saas-ui/react/switch';
15
15
  import * as react_jsx_runtime from 'react/jsx-runtime';
16
16
  import { UseStepperReturn } from '@saas-ui/core';
17
17
  import { ButtonProps } from '@saas-ui/react/button';
18
+ import { StandardSchemaV1 } from '@standard-schema/spec';
18
19
  import { z } from 'zod';
19
20
 
20
21
  interface FormLayoutOptions {
@@ -386,6 +387,26 @@ interface BaseFieldProps<TFieldValues extends FieldValues = FieldValues, TName e
386
387
  * The input placeholder
387
388
  */
388
389
  placeholder?: string;
390
+ /**
391
+ * Whether the field is invalid
392
+ */
393
+ invalid?: boolean;
394
+ /**
395
+ * Whether the field is required
396
+ */
397
+ required?: boolean;
398
+ /**
399
+ * Whether the field is disabled
400
+ */
401
+ disabled?: boolean;
402
+ /**
403
+ * Whether the field is read-only
404
+ */
405
+ readOnly?: boolean;
406
+ /**
407
+ * Orientation of the field
408
+ */
409
+ orientation?: 'horizontal' | 'vertical';
389
410
  /**
390
411
  * React children
391
412
  */
@@ -554,21 +575,22 @@ type FormType<FieldDefs, ExtraProps = object, ExtraFieldProps extends object = o
554
575
  };
555
576
  declare function createForm<FieldDefs, TGetBaseField extends GetBaseField<any> = GetBaseField<any>>({ resolver, fieldResolver, fields, getBaseField, }?: CreateFormProps<FieldDefs, TGetBaseField>): FormType<FieldDefs, object, TGetBaseField extends GetBaseField<infer ExtraFieldProps extends object> ? ExtraFieldProps : object, object>;
556
577
 
557
- interface UseFormProps<TFieldValues extends FieldValues, TContext extends object> extends UseFormProps$1<TFieldValues, TContext> {
558
- onSubmit: SubmitHandler<TFieldValues>;
578
+ interface UseFormProps<TFieldValues extends FieldValues, TContext = any, TTransformedValues = TFieldValues> extends UseFormProps$1<TFieldValues, TContext, TTransformedValues> {
579
+ schema?: StandardSchemaV1<TFieldValues, TTransformedValues>;
580
+ onSubmit: SubmitHandler<TTransformedValues>;
559
581
  onInvalid?: SubmitErrorHandler<FieldValues>;
560
582
  }
561
- interface UseFormReturn$1<TFieldValues extends FieldValues, TContext extends object> extends UseFormReturn$2<TFieldValues, TContext> {
583
+ interface UseFormReturn$1<TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues = TFieldValues> extends UseFormReturn$2<TFieldValues, TContext, TTransformedValues> {
562
584
  Form: React.FC<Omit<FormProps<TFieldValues, TContext>, 'form'>>;
563
585
  Field: React.FC<FieldProps<TFieldValues>>;
564
586
  DisplayIf: React.FC<DisplayIfProps<TFieldValues>>;
565
587
  ArrayField: React.FC<ArrayFieldProps<TFieldValues> & React.RefAttributes<UseArrayFieldReturn>>;
566
588
  ObjectField: React.FC<ObjectFieldProps<TFieldValues>>;
567
589
  }
568
- declare function useForm<TFieldValues extends FieldValues, TContext extends object>(props: UseFormProps<TFieldValues, TContext>): UseFormReturn$1<TFieldValues, TContext>;
569
- interface FormProps<TFieldValues extends FieldValues = FieldValues, TContext extends object = object> extends HTMLChakraProps<'form'> {
590
+ declare function useForm<TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues = TFieldValues>(props: UseFormProps<TFieldValues, TContext, TTransformedValues>): UseFormReturn$1<TFieldValues, TContext, TTransformedValues>;
591
+ interface FormProps<TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues = TFieldValues> extends HTMLChakraProps<'form'> {
570
592
  children: React.ReactNode;
571
- form: ReturnType<typeof useForm$1<TFieldValues, TContext>>;
593
+ form: ReturnType<typeof useForm$1<TFieldValues, TContext, TTransformedValues>>;
572
594
  }
573
595
  interface UseZodFormProps<TSchema extends z.AnyZodObject | z.ZodEffects<z.AnyZodObject> = z.AnyZodObject, TFieldValues extends InferObjectSchema<TSchema> = InferObjectSchema<TSchema>, TContext extends object = object> extends Omit<UseFormProps$1<TFieldValues, TContext>, 'defaultValues'> {
574
596
  schema: TSchema;
@@ -576,7 +598,10 @@ interface UseZodFormProps<TSchema extends z.AnyZodObject | z.ZodEffects<z.AnyZod
576
598
  onInvalid?: SubmitErrorHandler<FieldValues>;
577
599
  defaultValues?: DefaultValues<TFieldValues> | AsyncDefaultValues<TFieldValues>;
578
600
  }
579
- declare function useZodForm<TSchema extends z.AnyZodObject | z.ZodEffects<z.AnyZodObject> = z.AnyZodObject, TFieldValues extends InferObjectSchema<TSchema> = InferObjectSchema<TSchema>, TContext extends object = object>(props: UseZodFormProps<TSchema, TFieldValues, TContext>): UseFormReturn$1<TFieldValues, TContext>;
601
+ /**
602
+ * @deprecated Use useForm instead, which supports standard schema out of the box.
603
+ */
604
+ declare function useZodForm<TSchema extends z.AnyZodObject | z.ZodEffects<z.AnyZodObject> = z.AnyZodObject, TFieldValues extends InferObjectSchema<TSchema> = InferObjectSchema<TSchema>, TContext extends object = object>(props: UseZodFormProps<TSchema, TFieldValues, TContext>): UseFormReturn$1<TFieldValues, TContext, TFieldValues>;
580
605
  type InferObjectSchema<T extends z.ZodTypeAny | z.ZodEffects<z.ZodTypeAny>> = T extends z.ZodEffects<infer TSchema> ? z.infer<TSchema> : z.infer<T>;
581
606
  type AsyncDefaultValues<TFieldValues> = (payload?: unknown) => Promise<TFieldValues>;
582
607
 
@@ -651,11 +676,12 @@ declare const useFormContext: <TFieldValues extends FieldValues = FieldValues, T
651
676
  formState: react_hook_form.FormState<TFieldValues>;
652
677
  resetField: react_hook_form.UseFormResetField<TFieldValues>;
653
678
  reset: react_hook_form.UseFormReset<TFieldValues>;
654
- handleSubmit: react_hook_form.UseFormHandleSubmit<TFieldValues, undefined>;
679
+ handleSubmit: react_hook_form.UseFormHandleSubmit<TFieldValues, TFieldValues>;
655
680
  unregister: react_hook_form.UseFormUnregister<TFieldValues>;
656
- control: react_hook_form.Control<TFieldValues, TContext>;
681
+ control: react_hook_form.Control<TFieldValues, TContext, TFieldValues>;
657
682
  register: react_hook_form.UseFormRegister<TFieldValues>;
658
683
  setFocus: react_hook_form.UseFormSetFocus<TFieldValues>;
684
+ subscribe: react_hook_form.UseFromSubscribe<TFieldValues>;
659
685
  };
660
686
  type UseFormReturn<TFieldValues extends FieldValues = FieldValues, TContext = any, TSchema = any> = ReturnType<typeof useFormContext<TFieldValues, TContext, TSchema>>;
661
687
  declare const FormProvider: <TFieldValues extends FieldValues = FieldValues, TContext = any, TSchema = any>(props: FormProviderProps<TFieldValues, TContext, TSchema>) => react_jsx_runtime.JSX.Element;
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import { SimpleGridProps, RecipeProps, InputProps, SystemStyleObject, TextareaPr
4
4
  import { MaybeRenderProp } from '@saas-ui/core/utils';
5
5
  import * as react_hook_form from 'react-hook-form';
6
6
  import { FieldValues, FieldPath, UseFormReturn as UseFormReturn$2, UseFieldArrayReturn, UseFormProps as UseFormProps$1, WatchObserver, SubmitHandler, SubmitErrorHandler, ResolverOptions, ResolverResult, RegisterOptions, useForm as useForm$1, DefaultValues, FormProviderProps as FormProviderProps$1 } from 'react-hook-form';
7
- export { ArrayPath, BatchFieldArrayUpdate, BrowserNativeObject, ChangeHandler, Control, Controller, ControllerFieldState, ControllerProps, ControllerRenderProps, CriteriaMode, CustomElement, DeepMap, DeepPartial, DeepPartialSkipArrayKey, DeepRequired, DefaultValues, DelayCallback, EmptyObject, ErrorOption, EventType, ExtractObjects, FieldArray, FieldArrayMethodProps, FieldArrayPath, FieldArrayPathValue, FieldArrayWithId, Field as FieldDef, FieldElement, FieldError, FieldErrors, FieldErrorsImpl, FieldName, FieldNamesMarkedBoolean, FieldPath, FieldPathByValue, FieldPathValue, FieldPathValues, FieldRefs, FieldValue, FieldValues, FormProviderProps, FormState, FormStateProxy, FormStateSubjectRef, GetIsDirty, InternalFieldErrors, InternalFieldName, InternalNameSet, IsAny, IsFlatObject, KeepStateOptions, LiteralUnion, Message, Mode, MultipleFieldErrors, Names, NativeFieldValue, NestedValue, NonUndefined, Noop, Primitive, ReadFormState, Ref, RefCallBack, RegisterOptions, Resolver, ResolverError, ResolverOptions, ResolverResult, ResolverSuccess, SetFieldValue, SetValueConfig, Subjects, SubmitErrorHandler, SubmitHandler, TriggerConfig, UnpackNestedValue, UseControllerProps, UseControllerReturn, UseFieldArrayProps, UseFieldArrayReturn, UseFormClearErrors, UseFormGetValues, UseFormHandleSubmit, UseFormRegister, UseFormRegisterReturn, UseFormReset, UseFormResetField, UseFormSetError, UseFormSetFocus, UseFormSetValue, UseFormStateProps, UseFormStateReturn, UseFormTrigger, UseFormUnregister, UseFormWatch, UseWatchProps, Validate, ValidateResult, ValidationMode, ValidationRule, ValidationValue, ValidationValueMessage, WatchInternal, WatchObserver, appendErrors, useController, useFieldArray, useFormState, useWatch } from 'react-hook-form';
7
+ export { ArrayPath, BatchFieldArrayUpdate, BrowserNativeObject, ChangeHandler, Control, Controller, ControllerFieldState, ControllerProps, ControllerRenderProps, CriteriaMode, CustomElement, DeepMap, DeepPartial, DeepPartialSkipArrayKey, DeepRequired, DefaultValues, DelayCallback, EmptyObject, ErrorOption, EventType, ExtractObjects, FieldArray, FieldArrayMethodProps, FieldArrayPath, FieldArrayPathValue, FieldArrayWithId, Field as FieldDef, FieldElement, FieldError, FieldErrors, FieldErrorsImpl, FieldName, FieldNamesMarkedBoolean, FieldPath, FieldPathByValue, FieldPathValue, FieldPathValues, FieldRefs, FieldValue, FieldValues, FormProviderProps, FormState, FormStateProxy, FormStateSubjectRef, GetIsDirty, InternalFieldErrors, InternalFieldName, InternalNameSet, IsAny, IsFlatObject, KeepStateOptions, LiteralUnion, Message, Mode, MultipleFieldErrors, Names, NativeFieldValue, NestedValue, NonUndefined, Noop, Primitive, ReadFormState, Ref, RefCallBack, RegisterOptions, Resolver, ResolverError, ResolverOptions, ResolverResult, ResolverSuccess, SetFieldValue, SetValueConfig, Subjects, SubmitErrorHandler, SubmitHandler, TriggerConfig, UseControllerProps, UseControllerReturn, UseFieldArrayProps, UseFieldArrayReturn, UseFormClearErrors, UseFormGetValues, UseFormHandleSubmit, UseFormRegister, UseFormRegisterReturn, UseFormReset, UseFormResetField, UseFormSetError, UseFormSetFocus, UseFormSetValue, UseFormStateProps, UseFormStateReturn, UseFormTrigger, UseFormUnregister, UseFormWatch, UseWatchProps, Validate, ValidateResult, ValidationMode, ValidationRule, ValidationValue, ValidationValueMessage, WatchInternal, WatchObserver, appendErrors, useController, useFieldArray, useFormState, useWatch } from 'react-hook-form';
8
8
  import { CheckboxProps } from '@saas-ui/react/checkbox';
9
9
  import { NumberInputProps } from '@saas-ui/react/number-input';
10
10
  import { PasswordInputProps } from '@saas-ui/react/password-input';
@@ -15,6 +15,7 @@ import { SwitchProps } from '@saas-ui/react/switch';
15
15
  import * as react_jsx_runtime from 'react/jsx-runtime';
16
16
  import { UseStepperReturn } from '@saas-ui/core';
17
17
  import { ButtonProps } from '@saas-ui/react/button';
18
+ import { StandardSchemaV1 } from '@standard-schema/spec';
18
19
  import { z } from 'zod';
19
20
 
20
21
  interface FormLayoutOptions {
@@ -386,6 +387,26 @@ interface BaseFieldProps<TFieldValues extends FieldValues = FieldValues, TName e
386
387
  * The input placeholder
387
388
  */
388
389
  placeholder?: string;
390
+ /**
391
+ * Whether the field is invalid
392
+ */
393
+ invalid?: boolean;
394
+ /**
395
+ * Whether the field is required
396
+ */
397
+ required?: boolean;
398
+ /**
399
+ * Whether the field is disabled
400
+ */
401
+ disabled?: boolean;
402
+ /**
403
+ * Whether the field is read-only
404
+ */
405
+ readOnly?: boolean;
406
+ /**
407
+ * Orientation of the field
408
+ */
409
+ orientation?: 'horizontal' | 'vertical';
389
410
  /**
390
411
  * React children
391
412
  */
@@ -554,21 +575,22 @@ type FormType<FieldDefs, ExtraProps = object, ExtraFieldProps extends object = o
554
575
  };
555
576
  declare function createForm<FieldDefs, TGetBaseField extends GetBaseField<any> = GetBaseField<any>>({ resolver, fieldResolver, fields, getBaseField, }?: CreateFormProps<FieldDefs, TGetBaseField>): FormType<FieldDefs, object, TGetBaseField extends GetBaseField<infer ExtraFieldProps extends object> ? ExtraFieldProps : object, object>;
556
577
 
557
- interface UseFormProps<TFieldValues extends FieldValues, TContext extends object> extends UseFormProps$1<TFieldValues, TContext> {
558
- onSubmit: SubmitHandler<TFieldValues>;
578
+ interface UseFormProps<TFieldValues extends FieldValues, TContext = any, TTransformedValues = TFieldValues> extends UseFormProps$1<TFieldValues, TContext, TTransformedValues> {
579
+ schema?: StandardSchemaV1<TFieldValues, TTransformedValues>;
580
+ onSubmit: SubmitHandler<TTransformedValues>;
559
581
  onInvalid?: SubmitErrorHandler<FieldValues>;
560
582
  }
561
- interface UseFormReturn$1<TFieldValues extends FieldValues, TContext extends object> extends UseFormReturn$2<TFieldValues, TContext> {
583
+ interface UseFormReturn$1<TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues = TFieldValues> extends UseFormReturn$2<TFieldValues, TContext, TTransformedValues> {
562
584
  Form: React.FC<Omit<FormProps<TFieldValues, TContext>, 'form'>>;
563
585
  Field: React.FC<FieldProps<TFieldValues>>;
564
586
  DisplayIf: React.FC<DisplayIfProps<TFieldValues>>;
565
587
  ArrayField: React.FC<ArrayFieldProps<TFieldValues> & React.RefAttributes<UseArrayFieldReturn>>;
566
588
  ObjectField: React.FC<ObjectFieldProps<TFieldValues>>;
567
589
  }
568
- declare function useForm<TFieldValues extends FieldValues, TContext extends object>(props: UseFormProps<TFieldValues, TContext>): UseFormReturn$1<TFieldValues, TContext>;
569
- interface FormProps<TFieldValues extends FieldValues = FieldValues, TContext extends object = object> extends HTMLChakraProps<'form'> {
590
+ declare function useForm<TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues = TFieldValues>(props: UseFormProps<TFieldValues, TContext, TTransformedValues>): UseFormReturn$1<TFieldValues, TContext, TTransformedValues>;
591
+ interface FormProps<TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues = TFieldValues> extends HTMLChakraProps<'form'> {
570
592
  children: React.ReactNode;
571
- form: ReturnType<typeof useForm$1<TFieldValues, TContext>>;
593
+ form: ReturnType<typeof useForm$1<TFieldValues, TContext, TTransformedValues>>;
572
594
  }
573
595
  interface UseZodFormProps<TSchema extends z.AnyZodObject | z.ZodEffects<z.AnyZodObject> = z.AnyZodObject, TFieldValues extends InferObjectSchema<TSchema> = InferObjectSchema<TSchema>, TContext extends object = object> extends Omit<UseFormProps$1<TFieldValues, TContext>, 'defaultValues'> {
574
596
  schema: TSchema;
@@ -576,7 +598,10 @@ interface UseZodFormProps<TSchema extends z.AnyZodObject | z.ZodEffects<z.AnyZod
576
598
  onInvalid?: SubmitErrorHandler<FieldValues>;
577
599
  defaultValues?: DefaultValues<TFieldValues> | AsyncDefaultValues<TFieldValues>;
578
600
  }
579
- declare function useZodForm<TSchema extends z.AnyZodObject | z.ZodEffects<z.AnyZodObject> = z.AnyZodObject, TFieldValues extends InferObjectSchema<TSchema> = InferObjectSchema<TSchema>, TContext extends object = object>(props: UseZodFormProps<TSchema, TFieldValues, TContext>): UseFormReturn$1<TFieldValues, TContext>;
601
+ /**
602
+ * @deprecated Use useForm instead, which supports standard schema out of the box.
603
+ */
604
+ declare function useZodForm<TSchema extends z.AnyZodObject | z.ZodEffects<z.AnyZodObject> = z.AnyZodObject, TFieldValues extends InferObjectSchema<TSchema> = InferObjectSchema<TSchema>, TContext extends object = object>(props: UseZodFormProps<TSchema, TFieldValues, TContext>): UseFormReturn$1<TFieldValues, TContext, TFieldValues>;
580
605
  type InferObjectSchema<T extends z.ZodTypeAny | z.ZodEffects<z.ZodTypeAny>> = T extends z.ZodEffects<infer TSchema> ? z.infer<TSchema> : z.infer<T>;
581
606
  type AsyncDefaultValues<TFieldValues> = (payload?: unknown) => Promise<TFieldValues>;
582
607
 
@@ -651,11 +676,12 @@ declare const useFormContext: <TFieldValues extends FieldValues = FieldValues, T
651
676
  formState: react_hook_form.FormState<TFieldValues>;
652
677
  resetField: react_hook_form.UseFormResetField<TFieldValues>;
653
678
  reset: react_hook_form.UseFormReset<TFieldValues>;
654
- handleSubmit: react_hook_form.UseFormHandleSubmit<TFieldValues, undefined>;
679
+ handleSubmit: react_hook_form.UseFormHandleSubmit<TFieldValues, TFieldValues>;
655
680
  unregister: react_hook_form.UseFormUnregister<TFieldValues>;
656
- control: react_hook_form.Control<TFieldValues, TContext>;
681
+ control: react_hook_form.Control<TFieldValues, TContext, TFieldValues>;
657
682
  register: react_hook_form.UseFormRegister<TFieldValues>;
658
683
  setFocus: react_hook_form.UseFormSetFocus<TFieldValues>;
684
+ subscribe: react_hook_form.UseFromSubscribe<TFieldValues>;
659
685
  };
660
686
  type UseFormReturn<TFieldValues extends FieldValues = FieldValues, TContext = any, TSchema = any> = ReturnType<typeof useFormContext<TFieldValues, TContext, TSchema>>;
661
687
  declare const FormProvider: <TFieldValues extends FieldValues = FieldValues, TContext = any, TSchema = any>(props: FormProviderProps<TFieldValues, TContext, TSchema>) => react_jsx_runtime.JSX.Element;
package/dist/index.js CHANGED
@@ -162,8 +162,8 @@ var useBaseField = (props) => {
162
162
  };
163
163
  var BaseField = (props) => {
164
164
  const { rootProps, label, hideLabel, help, error } = useBaseField(props);
165
- const isInvalid = !!error;
166
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react.Field.Root, { invalid: isInvalid, ...rootProps, children: [
165
+ const isInvalid = !!error || rootProps.invalid;
166
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react.Field.Root, { ...rootProps, invalid: isInvalid, children: [
167
167
  label && !hideLabel ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react.Field.Label, { children: [
168
168
  label,
169
169
  " ",
@@ -994,13 +994,19 @@ function createForm({
994
994
  // src/use-form.tsx
995
995
  var import_react15 = require("react");
996
996
  var import_react16 = require("@chakra-ui/react");
997
+ var import_standard_schema = require("@hookform/resolvers/standard-schema");
997
998
  var import_zod = require("@hookform/resolvers/zod");
998
999
  var import_utils10 = require("@saas-ui/core/utils");
999
1000
  var import_react_hook_form8 = require("react-hook-form");
1000
1001
  var import_jsx_runtime14 = require("react/jsx-runtime");
1001
1002
  function useForm2(props) {
1002
- const { onSubmit, onInvalid, ...rest } = props;
1003
- const form = (0, import_react_hook_form8.useForm)(rest);
1003
+ const { onSubmit, onInvalid, resolver, ...rest } = props;
1004
+ const form = (0, import_react_hook_form8.useForm)({
1005
+ ...rest,
1006
+ resolver: props.schema ? (0, import_standard_schema.standardSchemaResolver)(
1007
+ props.schema
1008
+ ) : resolver
1009
+ });
1004
1010
  const FormComponent = (0, import_react15.forwardRef)(
1005
1011
  function FormComponent2(props2, ref) {
1006
1012
  return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(