@saas-ui/forms 2.0.0-next.2 → 2.0.0-next.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. package/CHANGELOG.md +188 -0
  2. package/README.md +53 -6
  3. package/dist/ajv/index.d.ts +24 -11
  4. package/dist/ajv/index.js +7 -9
  5. package/dist/ajv/index.js.map +1 -1
  6. package/dist/ajv/index.mjs +7 -10
  7. package/dist/ajv/index.mjs.map +1 -1
  8. package/dist/index.d.ts +519 -280
  9. package/dist/index.js +777 -696
  10. package/dist/index.js.map +1 -1
  11. package/dist/index.mjs +756 -676
  12. package/dist/index.mjs.map +1 -1
  13. package/dist/yup/index.d.ts +525 -21
  14. package/dist/yup/index.js +21 -9
  15. package/dist/yup/index.js.map +1 -1
  16. package/dist/yup/index.mjs +21 -10
  17. package/dist/yup/index.mjs.map +1 -1
  18. package/dist/zod/index.d.ts +525 -12
  19. package/dist/zod/index.js +21 -1
  20. package/dist/zod/index.js.map +1 -1
  21. package/dist/zod/index.mjs +21 -3
  22. package/dist/zod/index.mjs.map +1 -1
  23. package/package.json +33 -10
  24. package/src/array-field.tsx +88 -48
  25. package/src/auto-form.tsx +7 -3
  26. package/src/base-field.tsx +54 -0
  27. package/src/create-field.tsx +144 -0
  28. package/src/create-form.tsx +68 -0
  29. package/src/create-step-form.tsx +100 -0
  30. package/src/default-fields.tsx +163 -0
  31. package/src/display-field.tsx +9 -11
  32. package/src/display-if.tsx +20 -13
  33. package/src/field-resolver.ts +10 -8
  34. package/src/field.tsx +18 -445
  35. package/src/fields-context.tsx +23 -0
  36. package/src/fields.tsx +34 -21
  37. package/src/form-context.tsx +84 -0
  38. package/src/form.tsx +77 -55
  39. package/src/index.ts +58 -4
  40. package/src/input-right-button/input-right-button.stories.tsx +1 -1
  41. package/src/input-right-button/input-right-button.tsx +0 -2
  42. package/src/layout.tsx +16 -11
  43. package/src/number-input/number-input.tsx +9 -5
  44. package/src/object-field.tsx +35 -13
  45. package/src/password-input/password-input.stories.tsx +23 -2
  46. package/src/password-input/password-input.tsx +6 -6
  47. package/src/pin-input/pin-input.tsx +1 -5
  48. package/src/radio/radio-input.stories.tsx +1 -1
  49. package/src/radio/radio-input.tsx +12 -10
  50. package/src/select/native-select.tsx +1 -4
  51. package/src/select/select-context.tsx +130 -0
  52. package/src/select/select.stories.tsx +116 -85
  53. package/src/select/select.test.tsx +1 -1
  54. package/src/select/select.tsx +162 -146
  55. package/src/step-form.tsx +76 -76
  56. package/src/submit-button.tsx +5 -1
  57. package/src/types.ts +149 -0
  58. package/src/use-array-field.tsx +9 -3
  59. package/src/use-step-form.tsx +54 -9
  60. package/src/utils.ts +23 -1
  61. package/src/watch-field.tsx +2 -6
  62. /package/src/radio/{radio.test.tsx → radio-input.test.tsx} +0 -0
@@ -1,7 +1,7 @@
1
1
  import { reach } from 'yup';
2
2
  import { yupResolver } from '@hookform/resolvers/yup';
3
3
  export { yupResolver } from '@hookform/resolvers/yup';
4
- import { createForm } from '@saas-ui/forms';
4
+ import { createForm, createStepForm } from '@saas-ui/forms';
5
5
 
6
6
  // yup/src/yup-resolver.ts
7
7
  var getType = (field) => {
@@ -67,20 +67,31 @@ var yupFieldResolver = (schema) => {
67
67
  }
68
68
  };
69
69
  };
70
- var yupForm = (schema, schemaOptions = {}, resolverOptions = {}) => {
71
- return {
72
- schema,
73
- resolver: yupResolver(schema, schemaOptions, resolverOptions),
74
- fieldResolver: yupFieldResolver(schema)
75
- };
76
- };
77
70
  var createYupForm = (options) => {
78
- return createForm({
71
+ const YupForm = createForm({
72
+ resolver: (schema) => yupResolver(schema, options == null ? void 0 : options.schemaOptions, options == null ? void 0 : options.resolverOptions),
73
+ fieldResolver: yupFieldResolver,
74
+ ...options
75
+ });
76
+ YupForm.displayName = "YupForm";
77
+ YupForm.id = "YupForm";
78
+ return YupForm;
79
+ };
80
+ var createYupStepForm = (options) => {
81
+ const YupStepForm = createStepForm({
79
82
  resolver: (schema) => yupResolver(schema, options == null ? void 0 : options.schemaOptions, options == null ? void 0 : options.resolverOptions),
83
+ fieldResolver: yupFieldResolver,
80
84
  ...options
81
85
  });
86
+ YupStepForm.displayName = "YupStepForm";
87
+ YupStepForm.id = "YupStepForm";
88
+ return YupStepForm;
82
89
  };
83
90
 
84
- export { createYupForm, getFieldsFromSchema, getNestedSchema, yupFieldResolver, yupForm };
91
+ // yup/src/index.ts
92
+ var Form2 = createYupForm();
93
+ var StepForm = createYupStepForm();
94
+
95
+ export { Form2 as Form, StepForm, createYupForm, getFieldsFromSchema, getNestedSchema, yupFieldResolver };
85
96
  //# sourceMappingURL=out.js.map
86
97
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../yup/src/yup-resolver.ts","../../yup/src/create-yup-form.tsx"],"names":[],"mappings":";AAAA,SAAS,aAA8B;AACvC,SAAS,mBAAmB;AAY5B,IAAM,UAAU,CAAC,UAAe;AAbhC;AAcE,OAAI,WAAM,KAAK,SAAX,mBAAiB,MAAM;AACzB,WAAO,MAAM,KAAK,KAAK;AAAA,EACzB;AAEA,UAAQ,MAAM,MAAM;AAAA,IAClB,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AAAA,IACL;AACE,aAAO;AAAA,EACX;AACF;AAEA,IAAM,iBAAiB,CAAC,OAAY,SAAiB;AAjCrD;AAkCE,aAAW,QAAQ,MAAM,OAAO;AAC9B,SAAI,UAAK,YAAL,mBAAc,OAAO;AAAO,aAAO,KAAK,QAAQ,OAAO;AAAA,EAC7D;AACF;AAQO,IAAM,sBAAsB,CAAC,WAA0C;AAC5E,QAAM,SAAS,CAAC;AAEhB,MAAI,eAAoC,CAAC;AACzC,MAAI,OAAO,SAAS,SAAS;AAE3B,mBAAe,OAAO,UAAU;AAAA,EAClC,OAAO;AACL,mBAAe,OAAO;AAAA,EACxB;AAEA,aAAW,QAAQ,cAAc;AAC/B,UAAM,QAAQ,aAAa;AAE3B,UAAM,UAAmB,CAAC;AAC1B,QAAI,MAAM,SAAS,SAAS;AAC1B,cAAQ,MAAM,eAAe,OAAO,KAAK;AACzC,cAAQ,MAAM,eAAe,OAAO,KAAK;AAAA,IAC3C;AAEA,WAAO,KAAK;AAAA,MACV;AAAA,MACA,OAAO,MAAM,KAAK,SAAS;AAAA,MAC3B,MAAM,QAAQ,KAAK;AAAA,MACnB,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACA,SAAO;AACT;AAEO,IAAM,kBAAkB,CAAC,QAAyB,SAAiB;AACxE,SAAO,MAAM,QAAQ,IAAI;AAC3B;AAEO,IAAM,mBAAmB,CAAC,WAA4B;AAC3D,SAAO;AAAA,IACL,YAAY;AACV,aAAO,oBAAoB,MAAM;AAAA,IACnC;AAAA,IACA,gBAAgB,MAAc;AAC5B,aAAO,oBAAoB,gBAAgB,QAAQ,IAAI,CAAC;AAAA,IAC1D;AAAA,EACF;AACF;AAEO,IAAM,UAAU,CACrB,QACA,gBAAgB,CAAC,GACjB,kBAAkB,CAAC,MAChB;AACH,SAAO;AAAA,IACL;AAAA,IACA,UAAU,YAAY,QAAQ,eAAe,eAAe;AAAA,IAC5D,eAAe,iBAAiB,MAAM;AAAA,EACxC;AACF;;;ACpGA,SAAS,kBAA8C;AAWhD,IAAM,gBAAgB,CAAC,YAAiC;AAC7D,SAAO,WAAW;AAAA,IAChB,UAAU,CAAC,WACT,YAAY,QAAQ,mCAAS,eAAe,mCAAS,eAAe;AAAA,IACtE,GAAG;AAAA,EACL,CAAC;AAMH","sourcesContent":["import { reach, AnyObjectSchema } from 'yup'\nimport { yupResolver } from '@hookform/resolvers/yup'\n\nimport { FieldProps } from '@saas-ui/forms'\n\nexport { yupResolver }\n\nexport type Options = {\n min?: number\n max?: number\n}\n\n// @TODO get proper typings for the schema fields\nconst getType = (field: any) => {\n if (field.spec.meta?.type) {\n return field.spec.meta.type\n }\n\n switch (field.type) {\n case 'array':\n return 'array'\n case 'object':\n return 'object'\n case 'number':\n return 'number'\n case 'date':\n return 'date'\n case 'string':\n default:\n return 'text'\n }\n}\n\nconst getArrayOption = (field: any, name: string) => {\n for (const test of field.tests) {\n if (test.OPTIONS?.params[name]) return test.OPTIONS.params[name]\n }\n}\n\n/**\n * A helper function to render forms automatically based on a Yup schema\n *\n * @param schema The Yup schema\n * @returns {FieldProps[]}\n */\nexport const getFieldsFromSchema = (schema: AnyObjectSchema): FieldProps[] => {\n const fields = []\n\n let schemaFields: Record<string, any> = {}\n if (schema.type === 'array') {\n /* @ts-ignore this is actually valid */\n schemaFields = schema.innerType.fields\n } else {\n schemaFields = schema.fields\n }\n\n for (const name in schemaFields) {\n const field = schemaFields[name]\n\n const options: Options = {}\n if (field.type === 'array') {\n options.min = getArrayOption(field, 'min')\n options.max = getArrayOption(field, 'max')\n }\n\n fields.push({\n name,\n label: field.spec.label || name,\n type: getType(field),\n ...options,\n })\n }\n return fields\n}\n\nexport const getNestedSchema = (schema: AnyObjectSchema, path: string) => {\n return reach(schema, path)\n}\n\nexport const yupFieldResolver = (schema: AnyObjectSchema) => {\n return {\n getFields() {\n return getFieldsFromSchema(schema)\n },\n getNestedFields(name: string) {\n return getFieldsFromSchema(getNestedSchema(schema, name))\n },\n }\n}\n\nexport const yupForm = (\n schema: AnyObjectSchema,\n schemaOptions = {},\n resolverOptions = {}\n) => {\n return {\n schema,\n resolver: yupResolver(schema, schemaOptions, resolverOptions),\n fieldResolver: yupFieldResolver(schema),\n }\n}\n","import { createForm, CreateFormProps, FormProps } from '@saas-ui/forms'\nimport { yupResolver } from './yup-resolver'\nimport * as yup from 'yup'\nimport React from 'react'\ntype ResolverArgs = Parameters<typeof yupResolver>\n\nexport interface CreateYupFormProps extends CreateFormProps {\n schemaOptions?: ResolverArgs[1]\n resolverOptions?: ResolverArgs[2]\n}\n\nexport const createYupForm = (options?: CreateYupFormProps) => {\n return createForm({\n resolver: (schema) =>\n yupResolver(schema, options?.schemaOptions, options?.resolverOptions),\n ...options,\n }) as <\n TSchema extends yup.AnyObjectSchema = yup.AnyObjectSchema,\n TContext extends object = object\n >(\n props: FormProps<yup.InferType<TSchema>, TContext, TSchema>\n ) => React.ReactElement\n}\n"]}
1
+ {"version":3,"sources":["../../yup/src/yup-resolver.ts","../../yup/src/create-yup-form.ts","../../yup/src/create-yup-step-form.ts","../../yup/src/index.ts"],"names":["Form"],"mappings":";AAAA,SAAS,aAAa;AACtB,SAAS,mBAAmB;AAa5B,IAAM,UAAU,CAAC,UAAe;AAdhC;AAeE,OAAI,WAAM,KAAK,SAAX,mBAAiB,MAAM;AACzB,WAAO,MAAM,KAAK,KAAK;AAAA,EACzB;AAEA,UAAQ,MAAM,MAAM;AAAA,IAClB,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AAAA,IACL;AACE,aAAO;AAAA,EACX;AACF;AAEA,IAAM,iBAAiB,CAAC,OAAY,SAAiB;AAlCrD;AAmCE,aAAW,QAAQ,MAAM,OAAO;AAC9B,SAAI,UAAK,YAAL,mBAAc,OAAO;AAAO,aAAO,KAAK,QAAQ,OAAO,IAAI;AAAA,EACjE;AACF;AAQO,IAAM,sBAAsB,CAAC,WAA0C;AAC5E,QAAM,SAAS,CAAC;AAEhB,MAAI,eAAoC,CAAC;AACzC,MAAI,OAAO,SAAS,SAAS;AAE3B,mBAAe,OAAO,UAAU;AAAA,EAClC,OAAO;AACL,mBAAe,OAAO;AAAA,EACxB;AAEA,aAAW,QAAQ,cAAc;AAC/B,UAAM,QAAQ,aAAa,IAAI;AAE/B,UAAM,UAAmB,CAAC;AAC1B,QAAI,MAAM,SAAS,SAAS;AAC1B,cAAQ,MAAM,eAAe,OAAO,KAAK;AACzC,cAAQ,MAAM,eAAe,OAAO,KAAK;AAAA,IAC3C;AAEA,WAAO,KAAK;AAAA,MACV;AAAA,MACA,OAAO,MAAM,KAAK,SAAS;AAAA,MAC3B,MAAM,QAAQ,KAAK;AAAA,MACnB,GAAG;AAAA,IACL,CAAC;AAAA,EACH;AACA,SAAO;AACT;AAEO,IAAM,kBAAkB,CAAC,QAAyB,SAAiB;AACxE,SAAO,MAAM,QAAQ,IAAI;AAC3B;AAEO,IAAM,mBAAqC,CAAC,WAA4B;AAC7E,SAAO;AAAA,IACL,YAAY;AACV,aAAO,oBAAoB,MAAM;AAAA,IACnC;AAAA,IACA,gBAAgB,MAAc;AAC5B,aAAO,oBAAoB,gBAAgB,QAAQ,IAAI,CAAC;AAAA,IAC1D;AAAA,EACF;AACF;;;ACzFA;AAAA,EACE;AAAA,OAKK;AAoCA,IAAM,gBAAgB,CAC3B,YACG;AACH,QAAM,UAAU,WAAW;AAAA,IACzB,UAAU,CAAC,WACT,YAAY,QAAQ,mCAAS,eAAe,mCAAS,eAAe;AAAA,IACtE,eAAe;AAAA,IACf,GAAG;AAAA,EACL,CAAC;AAED,UAAQ,cAAc;AACtB,UAAQ,KAAK;AAEb,SAAO;AACT;;;ACxDA;AAAA,EAME;AAAA,OAIK;AA4CA,IAAM,oBAAoB,CAC/B,YACG;AACH,QAAM,cAAc,eAAmC;AAAA,IACrD,UAAU,CAAC,WACT,YAAY,QAAQ,mCAAS,eAAe,mCAAS,eAAe;AAAA,IACtE,eAAe;AAAA,IACf,GAAG;AAAA,EACL,CAAC;AAED,cAAY,cAAc;AAC1B,cAAY,KAAK;AAEjB,SAAO;AACT;;;AC9DO,IAAMA,QAAO,cAAc;AAE3B,IAAM,WAAW,kBAAkB","sourcesContent":["import { reach } from 'yup'\nimport { yupResolver } from '@hookform/resolvers/yup'\n\nimport { FieldProps, GetFieldResolver } from '@saas-ui/forms'\nimport { AnyObjectSchema } from './types'\n\nexport { yupResolver }\n\nexport type Options = {\n min?: number\n max?: number\n}\n\n// @TODO get proper typings for the schema fields\nconst getType = (field: any) => {\n if (field.spec.meta?.type) {\n return field.spec.meta.type\n }\n\n switch (field.type) {\n case 'array':\n return 'array'\n case 'object':\n return 'object'\n case 'number':\n return 'number'\n case 'date':\n return 'date'\n case 'string':\n default:\n return 'text'\n }\n}\n\nconst getArrayOption = (field: any, name: string) => {\n for (const test of field.tests) {\n if (test.OPTIONS?.params[name]) return test.OPTIONS.params[name]\n }\n}\n\n/**\n * A helper function to render forms automatically based on a Yup schema\n *\n * @param schema The Yup schema\n * @returns {FieldProps[]}\n */\nexport const getFieldsFromSchema = (schema: AnyObjectSchema): FieldProps[] => {\n const fields = []\n\n let schemaFields: Record<string, any> = {}\n if (schema.type === 'array') {\n /* @ts-ignore this is actually valid */\n schemaFields = schema.innerType.fields\n } else {\n schemaFields = schema.fields\n }\n\n for (const name in schemaFields) {\n const field = schemaFields[name]\n\n const options: Options = {}\n if (field.type === 'array') {\n options.min = getArrayOption(field, 'min')\n options.max = getArrayOption(field, 'max')\n }\n\n fields.push({\n name,\n label: field.spec.label || name,\n type: getType(field),\n ...options,\n })\n }\n return fields\n}\n\nexport const getNestedSchema = (schema: AnyObjectSchema, path: string) => {\n return reach(schema, path) as AnyObjectSchema\n}\n\nexport const yupFieldResolver: GetFieldResolver = (schema: AnyObjectSchema) => {\n return {\n getFields() {\n return getFieldsFromSchema(schema)\n },\n getNestedFields(name: string) {\n return getFieldsFromSchema(getNestedSchema(schema, name))\n },\n }\n}\n","import {\n createForm,\n CreateFormProps,\n FormProps,\n WithFields,\n FieldValues,\n} from '@saas-ui/forms'\nimport { yupFieldResolver, yupResolver } from './yup-resolver'\nimport { InferType } from 'yup'\nimport React from 'react'\nimport { AnyObjectSchema } from './types'\n\ntype ResolverArgs = Parameters<typeof yupResolver>\n\nexport interface CreateYupFormProps<FieldDefs>\n extends CreateFormProps<FieldDefs> {\n schemaOptions?: ResolverArgs[1]\n resolverOptions?: ResolverArgs[2]\n}\n\nexport type YupFormType<\n FieldDefs,\n ExtraProps = object,\n ExtraOverrides = object,\n Type extends 'yup' = 'yup'\n> = (<\n TSchema extends AnyObjectSchema = AnyObjectSchema,\n TFieldValues extends InferType<TSchema> = InferType<TSchema>, // placeholder\n TContext extends object = object\n>(\n props: WithFields<\n FormProps<TFieldValues, TContext, TSchema>,\n FieldDefs,\n ExtraOverrides\n > & {\n ref?: React.ForwardedRef<HTMLFormElement>\n } & ExtraProps\n) => React.ReactElement) & {\n displayName?: string\n id?: 'YupForm'\n}\n\nexport const createYupForm = <FieldDefs>(\n options?: CreateYupFormProps<FieldDefs>\n) => {\n const YupForm = createForm({\n resolver: (schema: any) =>\n yupResolver(schema, options?.schemaOptions, options?.resolverOptions),\n fieldResolver: yupFieldResolver,\n ...options,\n })\n\n YupForm.displayName = 'YupForm'\n YupForm.id = 'YupForm'\n\n return YupForm as YupFormType<FieldDefs>\n}\n","import {\n createForm,\n CreateFormProps,\n FormProps,\n WithFields,\n FieldValues,\n createStepForm,\n StepsOptions,\n UseStepFormProps,\n Form,\n} from '@saas-ui/forms'\nimport { yupFieldResolver, yupResolver } from './yup-resolver'\nimport { InferType, object, string } from 'yup'\nimport React from 'react'\nimport { AnyObjectSchema } from './types'\n\ntype ResolverArgs = Parameters<typeof yupResolver>\n\nexport interface CreateYupFormProps<FieldDefs>\n extends CreateFormProps<FieldDefs> {\n schemaOptions?: ResolverArgs[1]\n resolverOptions?: ResolverArgs[2]\n}\n\ntype InferStepType<T extends Required<StepsOptions<AnyObjectSchema>>> =\n T extends [infer Step, ...infer Rest]\n ? Step extends { schema: AnyObjectSchema }\n ? InferType<Step['schema']> &\n (Rest extends Required<StepsOptions<AnyObjectSchema>>\n ? InferStepType<Rest>\n : object)\n : object\n : object\n\ntype YupStepFormType<\n FieldDefs,\n ExtraProps = object,\n ExtraOverrides = object\n> = (<\n TSteps extends Required<StepsOptions<AnyObjectSchema>> = Required<\n StepsOptions<AnyObjectSchema>\n >,\n TFieldValues extends InferStepType<TSteps> = InferStepType<TSteps>,\n TContext extends object = object\n>(\n props: UseStepFormProps<TSteps, TFieldValues, TContext> & {\n steps: TSteps\n ref?: React.ForwardedRef<HTMLFormElement>\n }\n) => React.ReactElement) & {\n displayName?: string\n id?: string\n}\n\nexport const createYupStepForm = <FieldDefs>(\n options?: CreateYupFormProps<FieldDefs>\n) => {\n const YupStepForm = createStepForm<any, any, any, any>({\n resolver: (schema: any) =>\n yupResolver(schema, options?.schemaOptions, options?.resolverOptions),\n fieldResolver: yupFieldResolver,\n ...options,\n })\n\n YupStepForm.displayName = 'YupStepForm'\n YupStepForm.id = 'YupStepForm'\n\n return YupStepForm as YupStepFormType<FieldDefs>\n}\n","export * from './yup-resolver'\nexport { createYupForm, type YupFormType } from './create-yup-form'\nexport type { AnyObjectSchema } from './types'\nimport { createYupForm } from './create-yup-form'\nimport { createYupStepForm } from './create-yup-step-form'\n\nexport const Form = createYupForm()\n\nexport const StepForm = createYupStepForm()\n"]}
@@ -1,10 +1,392 @@
1
- import * as _saas_ui_forms from '@saas-ui/forms';
2
- import { FieldProps, FormProps, CreateFormProps } from '@saas-ui/forms';
3
- import * as z from 'zod';
4
- import { z as z$1 } from 'zod';
1
+ import * as React$1 from 'react';
2
+ import React$1__default from 'react';
3
+ import * as react_hook_form from 'react-hook-form';
4
+ import { FieldValues, FieldPath, UseFormProps, SubmitHandler, RegisterOptions, UseFormReturn, UseFieldArrayReturn, WatchObserver, SubmitErrorHandler } from 'react-hook-form';
5
+ import { MaybeRenderProp } from '@chakra-ui/react-utils';
6
+ import { UseStepperProps, UseStepperReturn } from '@saas-ui/core';
7
+ import { HTMLChakraProps, TextareaProps, SwitchProps, CheckboxProps, FormControlProps, ResponsiveValue, InputProps, RadioGroupProps, MenuProps, SelectProps as SelectProps$1, UsePinInputProps, SystemProps, NumberInputProps as NumberInputProps$1, StackDirection, MenuItemOptionProps, ButtonProps, RadioProps } from '@chakra-ui/react';
8
+ import { FocusableElement } from '@chakra-ui/utils';
9
+ import * as _chakra_ui_system_dist_system_types from '@chakra-ui/system/dist/system.types';
10
+ import * as zod from 'zod';
11
+ import { z } from 'zod';
12
+ import { FieldProps as FieldProps$1, WithFields, FormProps as FormProps$1, CreateFormProps } from '@saas-ui/forms';
5
13
  import { zodResolver } from '@hookform/resolvers/zod';
6
14
  export { zodResolver } from '@hookform/resolvers/zod';
7
15
 
16
+ interface NumberInputOptions {
17
+ /**
18
+ * Hide the stepper.
19
+ */
20
+ hideStepper?: boolean;
21
+ /**
22
+ * Render a custom increment icon.
23
+ */
24
+ incrementIcon?: React$1.ReactNode;
25
+ /**
26
+ * Render a custom decrement icon.
27
+ */
28
+ decrementIcon?: React$1.ReactNode;
29
+ }
30
+ interface NumberInputProps extends NumberInputProps$1, NumberInputOptions {
31
+ }
32
+
33
+ interface PasswordOptions {
34
+ viewIcon?: React$1__default.ReactNode;
35
+ viewOffIcon?: React$1__default.ReactNode;
36
+ leftAddon?: React$1__default.ReactNode;
37
+ }
38
+ interface PasswordInputProps extends InputProps, PasswordOptions {
39
+ }
40
+
41
+ interface RadioOption extends Omit<RadioProps, 'value' | 'label'>, FieldOption {
42
+ }
43
+ type RadioOptions = FieldOptions<RadioOption>;
44
+ interface RadioInputOptions {
45
+ options: RadioOptions;
46
+ spacing?: SystemProps['margin'];
47
+ direction?: StackDirection;
48
+ }
49
+ interface RadioInputProps extends Omit<RadioGroupProps, 'children'>, RadioInputOptions {
50
+ }
51
+
52
+ interface SelectOptions {
53
+ /**
54
+ * The name of the input field in a native form.
55
+ */
56
+ name: string;
57
+ /**
58
+ * The value of the select field.
59
+ */
60
+ value?: string | string[];
61
+ /**
62
+ * The initial value of the select field.
63
+ */
64
+ defaultValue?: string | string[];
65
+ /**
66
+ * The callback invoked when the value of the select field changes.
67
+ * @param value The value of the select field.
68
+ */
69
+ onChange?: (value: string | string[]) => void;
70
+ /**
71
+ * The placeholder text when there's no value.
72
+ */
73
+ placeholder?: string;
74
+ /**
75
+ * If `true`, the select will be disabled.
76
+ */
77
+ isDisabled?: boolean;
78
+ /**
79
+ * An array of options
80
+ * If you leave this empty the children prop will be rendered.
81
+ */
82
+ options?: FieldOptions<SelectOption>;
83
+ /**
84
+ * Enable multiple select.
85
+ */
86
+ multiple?: boolean;
87
+ /**
88
+ * The function used to render the value of the select field.
89
+ * @param value The value of the select field.
90
+ * @returns The rendered value.
91
+ */
92
+ renderValue?: (value: string | string[]) => React$1__default.ReactNode;
93
+ }
94
+
95
+ interface SelectProps extends Omit<MenuProps, 'children'>, SelectOptions {
96
+ }
97
+ interface SelectOption extends Omit<MenuItemOptionProps, 'value'>, FieldOption {
98
+ }
99
+ /**
100
+ * An option in a select list
101
+ *
102
+ * @see https://saas-ui.dev/docs/components/forms/select
103
+ */
104
+ declare const SelectOption: _chakra_ui_system_dist_system_types.ComponentWithAs<"button", MenuItemOptionProps>;
105
+
106
+ interface Option$1 {
107
+ value: string;
108
+ label?: string;
109
+ }
110
+ interface NativeSelectOptions {
111
+ options?: Option$1[];
112
+ }
113
+ interface NativeSelectProps extends SelectProps$1, NativeSelectOptions {
114
+ }
115
+
116
+ interface InputFieldProps extends InputProps {
117
+ type?: string;
118
+ leftAddon?: React$1.ReactNode;
119
+ rightAddon?: React$1.ReactNode;
120
+ }
121
+ interface NumberInputFieldProps extends NumberInputProps {
122
+ type: 'number';
123
+ }
124
+ interface PinFieldProps extends Omit<UsePinInputProps, 'type'> {
125
+ pinLength?: number;
126
+ pinType?: 'alphanumeric' | 'number';
127
+ spacing?: SystemProps['margin'];
128
+ }
129
+ declare const defaultFieldTypes: {
130
+ text: React$1.FC<InputFieldProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
131
+ email: React$1.FC<InputFieldProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
132
+ url: React$1.FC<InputFieldProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
133
+ phone: React$1.FC<InputFieldProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
134
+ number: React$1.FC<NumberInputFieldProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
135
+ password: React$1.FC<PasswordInputProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
136
+ textarea: React$1.FC<TextareaProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
137
+ switch: React$1.FC<SwitchProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
138
+ select: React$1.FC<SelectProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
139
+ checkbox: React$1.FC<CheckboxProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
140
+ radio: React$1.FC<RadioInputProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
141
+ pin: React$1.FC<PinFieldProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
142
+ 'native-select': React$1.FC<NativeSelectProps & BaseFieldProps<react_hook_form.FieldValues, string>>;
143
+ };
144
+ type DefaultFields = typeof defaultFieldTypes;
145
+
146
+ interface SubmitButtonProps extends ButtonProps {
147
+ /**
148
+ * Disable the submit button if the form is untouched.
149
+ *
150
+ * Change the default behavior by updating
151
+ * `SubmitButton.defaultProps.disableIfUntouched`
152
+ */
153
+ disableIfUntouched?: boolean;
154
+ /**
155
+ * Disable the submit button if the form is invalid.
156
+ *
157
+ * Change the default behavior by updating
158
+ * `SubmitButton.defaultProps.disableIfInvalid`
159
+ */
160
+ disableIfInvalid?: boolean;
161
+ }
162
+
163
+ type FieldOption = {
164
+ label?: string;
165
+ value: string;
166
+ };
167
+ type FieldOptions<TOption extends FieldOption = FieldOption> = Array<string> | Array<TOption>;
168
+ type ValueOf<T> = T[keyof T];
169
+ type ShallowMerge<A, B> = Omit<A, keyof B> & B;
170
+ type Split<S extends string, D extends string> = string extends S ? string[] : S extends '' ? [] : S extends `${infer T}${D}${infer U}` ? [T, ...Split<U, D>] : [S];
171
+ type MapPath<T extends string[]> = T extends [infer U, ...infer R] ? U extends string ? `${U extends `${number}` ? '$' : U}${R[0] extends string ? '.' : ''}${R extends string[] ? MapPath<R> : ''}` : '' : '';
172
+ type TransformPath<T extends string> = MapPath<Split<T, '.'>>;
173
+ type ArrayFieldPath<Name extends string> = Name extends string ? TransformPath<Name> : never;
174
+ interface BaseFieldProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> extends Omit<FormControlProps, 'label' | 'type'> {
175
+ /**
176
+ * The field name
177
+ */
178
+ name: TName | ArrayFieldPath<TName>;
179
+ /**
180
+ * The field label
181
+ */
182
+ label?: string;
183
+ /**
184
+ * Hide the field label
185
+ */
186
+ hideLabel?: boolean;
187
+ /**
188
+ * Field help text
189
+ */
190
+ help?: string;
191
+ /**
192
+ * React hook form rules
193
+ */
194
+ rules?: Omit<RegisterOptions<TFieldValues, TName>, 'valueAsNumber' | 'valueAsDate' | 'setValueAs' | 'disabled'>;
195
+ /**
196
+ * Build-in types:
197
+ * text, number, password, textarea, select, native-select, checkbox, radio, switch, pin
198
+ *
199
+ * Will default to a text field if there is no matching type.
200
+ */
201
+ type?: string;
202
+ /**
203
+ * The input placeholder
204
+ */
205
+ placeholder?: string;
206
+ }
207
+ type MergeFieldProps<FieldDefs, TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = ValueOf<{
208
+ [K in keyof FieldDefs]: FieldDefs[K] extends React.FC<infer Props> ? {
209
+ type?: K;
210
+ } & ShallowMerge<Props, BaseFieldProps<TFieldValues, TName>> : never;
211
+ }>;
212
+ type FieldProps<TFieldValues extends FieldValues = FieldValues> = MergeFieldProps<DefaultFields, TFieldValues>;
213
+ type DefaultFieldOverrides = {
214
+ submit?: SubmitButtonProps;
215
+ [key: string]: any;
216
+ };
217
+
218
+ type FieldResolver = {
219
+ getFields(): BaseFieldProps[];
220
+ getNestedFields(name: string): BaseFieldProps[];
221
+ };
222
+
223
+ interface DisplayIfProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> {
224
+ children: React$1.ReactElement;
225
+ name: TName;
226
+ defaultValue?: unknown;
227
+ isDisabled?: boolean;
228
+ isExact?: boolean;
229
+ condition?: (value: unknown, context: UseFormReturn<TFieldValues>) => boolean;
230
+ }
231
+
232
+ interface UseArrayFieldReturn extends UseFieldArrayReturn {
233
+ /**
234
+ * The array field name
235
+ */
236
+ name: string;
237
+ /**
238
+ * The default value for new items
239
+ */
240
+ defaultValue: Record<string, any>;
241
+ /**
242
+ * Min amount of items
243
+ */
244
+ min?: number;
245
+ /**
246
+ * Max amount of items
247
+ */
248
+ max?: number;
249
+ }
250
+ interface ArrayFieldOptions<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> {
251
+ /**
252
+ * The field name
253
+ */
254
+ name: TName;
255
+ /**
256
+ * Default value for new values in the array
257
+ */
258
+ defaultValue?: Record<string, any>;
259
+ /**
260
+ * Default key name for rows, change this if your data uses a different 'id' field
261
+ * @default "id"
262
+ */
263
+ keyName?: string;
264
+ min?: number;
265
+ max?: number;
266
+ }
267
+ interface ArrayFieldProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> extends ArrayFieldOptions<TFieldValues, TName>, Omit<BaseFieldProps<TFieldValues, TName>, 'name' | 'defaultValue' | 'children'> {
268
+ children: MaybeRenderProp<ArrayField[]>;
269
+ }
270
+ interface ArrayField {
271
+ id: string;
272
+ [key: string]: unknown;
273
+ }
274
+ /**
275
+ * The wrapper component that composes the default ArrayField functionality.
276
+ *
277
+ * @see Docs https://saas-ui.dev/docs/components/forms/array-field
278
+ */
279
+ declare const ArrayField: ((props: ArrayFieldProps & {
280
+ ref?: React$1.ForwardedRef<UseArrayFieldReturn>;
281
+ }) => React$1.ReactElement) & {
282
+ displayName: string;
283
+ };
284
+
285
+ interface ObjectFieldProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> extends BaseFieldProps {
286
+ name: TName;
287
+ children: React$1.ReactNode;
288
+ columns?: ResponsiveValue<number>;
289
+ spacing?: ResponsiveValue<string | number>;
290
+ }
291
+
292
+ interface FormRenderContext<TFieldValues extends FieldValues = FieldValues, TContext extends object = object, TFieldTypes = FieldProps<TFieldValues>> extends UseFormReturn<TFieldValues, TContext> {
293
+ Field: React$1.FC<TFieldTypes & React$1.RefAttributes<FocusableElement>>;
294
+ DisplayIf: React$1.FC<DisplayIfProps<TFieldValues>>;
295
+ ArrayField: React$1.FC<ArrayFieldProps<TFieldValues> & React$1.RefAttributes<UseArrayFieldReturn>>;
296
+ ObjectField: React$1.FC<ObjectFieldProps<TFieldValues>>;
297
+ }
298
+ interface FormOptions<TSchema = unknown, TFieldValues extends FieldValues = FieldValues, TContext extends object = object, TFieldTypes = FieldProps<TFieldValues>> {
299
+ /**
300
+ * The form schema.
301
+ */
302
+ schema?: TSchema;
303
+ /**
304
+ * Triggers when any of the field change.
305
+ */
306
+ onChange?: WatchObserver<TFieldValues>;
307
+ /**
308
+ * The submit handler.
309
+ */
310
+ onSubmit: SubmitHandler<TFieldValues>;
311
+ /**
312
+ * Triggers when there are validation errors.
313
+ */
314
+ onError?: SubmitErrorHandler<TFieldValues>;
315
+ /**
316
+ * The Hook Form state ref.
317
+ */
318
+ formRef?: React$1.RefObject<UseFormReturn<TFieldValues, TContext>>;
319
+ /**
320
+ * The form children, can be a render prop or a ReactNode.
321
+ */
322
+ children?: MaybeRenderProp<FormRenderContext<TFieldValues, TContext, TFieldTypes>>;
323
+ /**
324
+ * The field resolver, used to resolve the fields from schemas.
325
+ */
326
+ fieldResolver?: FieldResolver;
327
+ /**
328
+ * Field overrides
329
+ */
330
+ fields?: DefaultFieldOverrides;
331
+ }
332
+ interface FormProps<TSchema = unknown, TFieldValues extends FieldValues = FieldValues, TContext extends object = object, TFieldTypes = FieldProps<TFieldValues>> extends UseFormProps<TFieldValues, TContext>, Omit<HTMLChakraProps<'form'>, 'children' | 'onChange' | 'onSubmit' | 'onError'>, FormOptions<TSchema, TFieldValues, TContext, TFieldTypes> {
333
+ }
334
+
335
+ type StepsOptions<TSchema, TName extends string = string> = {
336
+ /**
337
+ * The step name
338
+ */
339
+ name: TName;
340
+ /**
341
+ * Schema
342
+ */
343
+ schema?: TSchema;
344
+ }[];
345
+ interface FormStepOptions<TName extends string = string> {
346
+ /**
347
+ * The step name
348
+ */
349
+ name: TName;
350
+ /**
351
+ * Schema
352
+ */
353
+ schema?: any;
354
+ /**
355
+ * Hook Form Resolver
356
+ */
357
+ resolver?: any;
358
+ }
359
+ interface FormStepProps<TName extends string = string> extends FormStepOptions<TName>, Omit<HTMLChakraProps<'div'>, 'onSubmit'> {
360
+ onSubmit?: FormStepSubmitHandler;
361
+ }
362
+ type FormStepSubmitHandler<TFieldValues extends FieldValues = FieldValues> = (data: TFieldValues, stepper: UseStepperReturn) => Promise<void>;
363
+
364
+ type StepName<T extends {
365
+ [k: number]: {
366
+ readonly name: string;
367
+ };
368
+ }> = T[number]['name'];
369
+ interface StepFormRenderContext<TSteps extends StepsOptions<any> = StepsOptions<any>, TFieldValues extends FieldValues = FieldValues, TContext extends object = object, TFieldTypes = FieldProps<TFieldValues>> extends UseStepFormReturn<TFieldValues> {
370
+ Field: React$1.FC<TFieldTypes & React$1.RefAttributes<FocusableElement>>;
371
+ FormStep: React$1.FC<FormStepProps<StepName<TSteps>>>;
372
+ DisplayIf: React$1.FC<DisplayIfProps<TFieldValues>>;
373
+ ArrayField: React$1.FC<ArrayFieldProps<TFieldValues> & React$1.RefAttributes<UseArrayFieldReturn>>;
374
+ ObjectField: React$1.FC<ObjectFieldProps<TFieldValues>>;
375
+ }
376
+ interface UseStepFormProps<TSteps extends StepsOptions<any> = StepsOptions<any>, TFieldValues extends FieldValues = FieldValues, TContext extends object = object, TFieldTypes = FieldProps<TFieldValues>> extends Omit<UseStepperProps, 'onChange'>, Omit<FormProps<any, TFieldValues, TContext, TFieldTypes>, 'children'> {
377
+ steps?: TSteps;
378
+ children: MaybeRenderProp<StepFormRenderContext<TSteps, TFieldValues, TContext, TFieldTypes>>;
379
+ }
380
+ interface UseStepFormReturn<TFieldValues extends FieldValues = FieldValues> extends UseStepperReturn {
381
+ getFormProps(): {
382
+ onSubmit: SubmitHandler<TFieldValues>;
383
+ schema?: any;
384
+ resolver?: any;
385
+ };
386
+ updateStep(step: any): void;
387
+ steps: Record<string, any>;
388
+ }
389
+
8
390
  type Options = {
9
391
  min?: number;
10
392
  max?: number;
@@ -15,11 +397,11 @@ type Options = {
15
397
  * @param schema The Yup schema
16
398
  * @returns {FieldProps[]}
17
399
  */
18
- declare const getFieldsFromSchema: (schema: z.ZodTypeAny) => FieldProps[];
19
- declare const getNestedSchema: (schema: z.ZodTypeAny, path: string) => any;
20
- declare const zodFieldResolver: <T extends z.ZodTypeAny>(schema: T) => {
21
- getFields(): FieldProps<_saas_ui_forms.FieldValues, string>[];
22
- getNestedFields(name: string): FieldProps<_saas_ui_forms.FieldValues, string>[];
400
+ declare const getFieldsFromSchema: (schema: zod.ZodTypeAny) => FieldProps$1[];
401
+ declare const getNestedSchema: (schema: zod.ZodTypeAny, path: string) => any;
402
+ declare const zodFieldResolver: <T extends zod.ZodTypeAny>(schema: T) => {
403
+ getFields(): FieldProps$1[];
404
+ getNestedFields(name: string): FieldProps$1[];
23
405
  };
24
406
  interface ZodMeta {
25
407
  label: string;
@@ -29,10 +411,141 @@ declare const zodMeta: (meta: ZodMeta) => string;
29
411
  declare const zodParseMeta: (meta: string) => any;
30
412
 
31
413
  type ResolverArgs = Parameters<typeof zodResolver>;
32
- interface CreateZodFormProps extends CreateFormProps {
414
+ interface CreateZodFormProps<FieldDefs> extends CreateFormProps<FieldDefs> {
33
415
  schemaOptions?: ResolverArgs[1];
34
416
  resolverOptions?: ResolverArgs[2];
35
417
  }
36
- declare const createZodForm: (options?: CreateZodFormProps) => <TSchema extends z$1.AnyZodObject = z$1.AnyZodObject, TContext extends object = object>(props: FormProps<z$1.TypeOf<TSchema>, TContext, TSchema>) => React.ReactElement;
418
+ type ZodFormType<FieldDefs, ExtraProps = object, ExtraOverrides = object, Type extends 'zod' = 'zod'> = (<TSchema extends z.AnyZodObject = z.AnyZodObject, TFieldValues extends z.infer<TSchema> = z.infer<TSchema>, TContext extends object = object>(props: WithFields<FormProps$1<TSchema, TFieldValues, TContext>, FieldDefs, ExtraOverrides> & {
419
+ ref?: React.ForwardedRef<HTMLFormElement>;
420
+ } & ExtraProps) => React.ReactElement) & {
421
+ displayName?: string;
422
+ id?: string;
423
+ };
424
+ declare const createZodForm: <FieldDefs>(options?: CreateZodFormProps<FieldDefs> | undefined) => ZodFormType<FieldDefs, object, object, "zod">;
425
+
426
+ declare const Form: ZodFormType<unknown, object, object, "zod">;
427
+ declare const StepForm: (<TSteps extends {
428
+ name: string;
429
+ schema?: zod.AnyZodObject | undefined;
430
+ }[] = {
431
+ name: string;
432
+ schema?: zod.AnyZodObject | undefined;
433
+ }[], TFieldValues extends TSteps extends [infer Step, ...infer Rest] ? Step extends {
434
+ schema: zod.AnyZodObject;
435
+ } ? zod.TypeOf<Step["schema"]> & (Rest extends {
436
+ name: string;
437
+ schema?: zod.AnyZodObject | undefined;
438
+ }[] ? Rest extends infer T ? T extends Rest ? T extends [infer Step, ...infer Rest] ? Step extends {
439
+ schema: zod.AnyZodObject;
440
+ } ? zod.TypeOf<Step["schema"]> & (Rest extends {
441
+ name: string;
442
+ schema?: zod.AnyZodObject | undefined;
443
+ }[] ? Rest extends infer T_1 ? T_1 extends Rest ? T_1 extends [infer Step, ...infer Rest] ? Step extends {
444
+ schema: zod.AnyZodObject;
445
+ } ? zod.TypeOf<Step["schema"]> & (Rest extends {
446
+ name: string;
447
+ schema?: zod.AnyZodObject | undefined;
448
+ }[] ? Rest extends infer T_2 ? T_2 extends Rest ? T_2 extends [infer Step, ...infer Rest] ? Step extends {
449
+ schema: zod.AnyZodObject;
450
+ } ? zod.TypeOf<Step["schema"]> & (Rest extends {
451
+ name: string;
452
+ schema?: zod.AnyZodObject | undefined;
453
+ }[] ? Rest extends infer T_3 ? T_3 extends Rest ? T_3 extends [infer Step, ...infer Rest] ? Step extends {
454
+ schema: zod.AnyZodObject;
455
+ } ? zod.TypeOf<Step["schema"]> & (Rest extends {
456
+ name: string;
457
+ schema?: zod.AnyZodObject | undefined;
458
+ }[] ? Rest extends infer T_4 ? T_4 extends Rest ? T_4 extends [infer Step, ...infer Rest] ? Step extends {
459
+ schema: zod.AnyZodObject;
460
+ } ? zod.TypeOf<Step["schema"]> & (Rest extends {
461
+ name: string;
462
+ schema?: zod.AnyZodObject | undefined;
463
+ }[] ? Rest extends infer T_5 ? T_5 extends Rest ? T_5 extends [infer Step, ...infer Rest] ? Step extends {
464
+ schema: zod.AnyZodObject;
465
+ } ? zod.TypeOf<Step["schema"]> & (Rest extends {
466
+ name: string;
467
+ schema?: zod.AnyZodObject | undefined;
468
+ }[] ? Rest extends infer T_6 ? T_6 extends Rest ? T_6 extends [infer Step, ...infer Rest] ? Step extends {
469
+ schema: zod.AnyZodObject;
470
+ } ? zod.TypeOf<Step["schema"]> & (Rest extends {
471
+ name: string;
472
+ schema?: zod.AnyZodObject | undefined;
473
+ }[] ? Rest extends infer T_7 ? T_7 extends Rest ? T_7 extends [infer Step, ...infer Rest] ? Step extends {
474
+ schema: zod.AnyZodObject;
475
+ } ? zod.TypeOf<Step["schema"]> & (Rest extends {
476
+ name: string;
477
+ schema?: zod.AnyZodObject | undefined;
478
+ }[] ? Rest extends infer T_8 ? T_8 extends Rest ? T_8 extends [infer Step, ...infer Rest] ? Step extends {
479
+ schema: zod.AnyZodObject;
480
+ } ? zod.TypeOf<Step["schema"]> & (Rest extends {
481
+ name: string;
482
+ schema?: zod.AnyZodObject | undefined;
483
+ }[] ? Rest extends infer T_9 ? T_9 extends Rest ? T_9 extends [infer Step, ...infer Rest] ? Step extends {
484
+ schema: zod.AnyZodObject;
485
+ } ? zod.TypeOf<Step["schema"]> & (Rest extends {
486
+ name: string;
487
+ schema?: zod.AnyZodObject | undefined;
488
+ }[] ? any : object) : object : object : never : never : object) : object : object : never : never : object) : object : object : never : never : object) : object : object : never : never : object) : object : object : never : never : object) : object : object : never : never : object) : object : object : never : never : object) : object : object : never : never : object) : object : object : never : never : object) : object : object : never : never : object) : object : object = TSteps extends [infer Step, ...infer Rest] ? Step extends {
489
+ schema: zod.AnyZodObject;
490
+ } ? zod.TypeOf<Step["schema"]> & (Rest extends {
491
+ name: string;
492
+ schema?: zod.AnyZodObject | undefined;
493
+ }[] ? Rest extends infer T_10 ? T_10 extends Rest ? T_10 extends [infer Step, ...infer Rest] ? Step extends {
494
+ schema: zod.AnyZodObject;
495
+ } ? zod.TypeOf<Step["schema"]> & (Rest extends {
496
+ name: string;
497
+ schema?: zod.AnyZodObject | undefined;
498
+ }[] ? Rest extends infer T_11 ? T_11 extends Rest ? T_11 extends [infer Step, ...infer Rest] ? Step extends {
499
+ schema: zod.AnyZodObject;
500
+ } ? zod.TypeOf<Step["schema"]> & (Rest extends {
501
+ name: string;
502
+ schema?: zod.AnyZodObject | undefined;
503
+ }[] ? Rest extends infer T_12 ? T_12 extends Rest ? T_12 extends [infer Step, ...infer Rest] ? Step extends {
504
+ schema: zod.AnyZodObject;
505
+ } ? zod.TypeOf<Step["schema"]> & (Rest extends {
506
+ name: string;
507
+ schema?: zod.AnyZodObject | undefined;
508
+ }[] ? Rest extends infer T_13 ? T_13 extends Rest ? T_13 extends [infer Step, ...infer Rest] ? Step extends {
509
+ schema: zod.AnyZodObject;
510
+ } ? zod.TypeOf<Step["schema"]> & (Rest extends {
511
+ name: string;
512
+ schema?: zod.AnyZodObject | undefined;
513
+ }[] ? Rest extends infer T_14 ? T_14 extends Rest ? T_14 extends [infer Step, ...infer Rest] ? Step extends {
514
+ schema: zod.AnyZodObject;
515
+ } ? zod.TypeOf<Step["schema"]> & (Rest extends {
516
+ name: string;
517
+ schema?: zod.AnyZodObject | undefined;
518
+ }[] ? Rest extends infer T_15 ? T_15 extends Rest ? T_15 extends [infer Step, ...infer Rest] ? Step extends {
519
+ schema: zod.AnyZodObject;
520
+ } ? zod.TypeOf<Step["schema"]> & (Rest extends {
521
+ name: string;
522
+ schema?: zod.AnyZodObject | undefined;
523
+ }[] ? Rest extends infer T_16 ? T_16 extends Rest ? T_16 extends [infer Step, ...infer Rest] ? Step extends {
524
+ schema: zod.AnyZodObject;
525
+ } ? zod.TypeOf<Step["schema"]> & (Rest extends {
526
+ name: string;
527
+ schema?: zod.AnyZodObject | undefined;
528
+ }[] ? Rest extends infer T_17 ? T_17 extends Rest ? T_17 extends [infer Step, ...infer Rest] ? Step extends {
529
+ schema: zod.AnyZodObject;
530
+ } ? zod.TypeOf<Step["schema"]> & (Rest extends {
531
+ name: string;
532
+ schema?: zod.AnyZodObject | undefined;
533
+ }[] ? Rest extends infer T_18 ? T_18 extends Rest ? T_18 extends [infer Step, ...infer Rest] ? Step extends {
534
+ schema: zod.AnyZodObject;
535
+ } ? zod.TypeOf<Step["schema"]> & (Rest extends {
536
+ name: string;
537
+ schema?: zod.AnyZodObject | undefined;
538
+ }[] ? Rest extends infer T_19 ? T_19 extends Rest ? T_19 extends [infer Step, ...infer Rest] ? Step extends {
539
+ schema: zod.AnyZodObject;
540
+ } ? zod.TypeOf<Step["schema"]> & (Rest extends {
541
+ name: string;
542
+ schema?: zod.AnyZodObject | undefined;
543
+ }[] ? any : object) : object : object : never : never : object) : object : object : never : never : object) : object : object : never : never : object) : object : object : never : never : object) : object : object : never : never : object) : object : object : never : never : object) : object : object : never : never : object) : object : object : never : never : object) : object : object : never : never : object) : object : object : never : never : object) : object : object, TContext extends object = object>(props: UseStepFormProps<TSteps, TFieldValues, TContext, FieldProps<TFieldValues>> & {
544
+ steps: TSteps;
545
+ ref?: React$1.ForwardedRef<HTMLFormElement> | undefined;
546
+ }) => React$1.ReactElement<any, string | React$1.JSXElementConstructor<any>>) & {
547
+ displayName?: string | undefined;
548
+ id?: string | undefined;
549
+ };
37
550
 
38
- export { Options, ZodMeta, createZodForm, getFieldsFromSchema, getNestedSchema, zodFieldResolver, zodMeta, zodParseMeta };
551
+ export { Form, Options, StepForm, ZodFormType, ZodMeta, createZodForm, getFieldsFromSchema, getNestedSchema, zodFieldResolver, zodMeta, zodParseMeta };