@saas-ui/forms 2.6.11 → 2.7.1

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @saas-ui/forms
2
2
 
3
+ ## 2.7.1
4
+
5
+ ### Patch Changes
6
+
7
+ - f0ee3db: Updated to Chakra 2.10
8
+ - Updated dependencies [f0ee3db]
9
+ - @saas-ui/core@2.6.1
10
+
11
+ ## 2.7.0
12
+
13
+ ### Minor Changes
14
+
15
+ - 2ac496a: Upgraded to Chakra UI v2.9.3
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies [2ac496a]
20
+ - @saas-ui/core@2.6.0
21
+
3
22
  ## 2.6.11
4
23
 
5
24
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -878,9 +878,9 @@ declare const useBaseField: (props: BaseFieldProps) => {
878
878
  error: any;
879
879
  touched: any;
880
880
  name: string;
881
- label?: string;
882
- hideLabel?: boolean;
883
- help?: string;
881
+ label?: string | undefined;
882
+ hideLabel?: boolean | undefined;
883
+ help?: string | undefined;
884
884
  };
885
885
  /**
886
886
  * The default BaseField component
package/dist/index.d.ts CHANGED
@@ -878,9 +878,9 @@ declare const useBaseField: (props: BaseFieldProps) => {
878
878
  error: any;
879
879
  touched: any;
880
880
  name: string;
881
- label?: string;
882
- hideLabel?: boolean;
883
- help?: string;
881
+ label?: string | undefined;
882
+ hideLabel?: boolean | undefined;
883
+ help?: string | undefined;
884
884
  };
885
885
  /**
886
886
  * The default BaseField component
@@ -1,7 +1,4 @@
1
- import * as _chakra_ui_button from '@chakra-ui/button';
2
- import * as _saas_ui_modals from '@saas-ui/modals';
3
- import { BaseModalProps, FormDialogFieldOverrides } from '@saas-ui/modals';
4
- import * as _chakra_ui_checkbox from '@chakra-ui/checkbox';
1
+ import * as _chakra_ui_react from '@chakra-ui/react';
5
2
  import * as react_hook_form from 'react-hook-form';
6
3
  import * as React$1 from 'react';
7
4
  import React__default from 'react';
@@ -58,8 +55,6 @@ type YupStepFormType<FieldDefs, ExtraProps = object, ExtraFieldProps extends obj
58
55
  };
59
56
  declare const createYupStepForm: <FieldDefs, TGetBaseField extends GetBaseField = GetBaseField>(options?: CreateYupFormProps<FieldDefs, TGetBaseField>) => YupStepFormType<FieldDefs, object, TGetBaseField extends GetBaseField<infer ExtraFieldProps extends object> ? ExtraFieldProps : object>;
60
57
 
61
- declare function createYupFormDialog<FieldDefs = any, ExtraProps = object, ExtraFieldProps extends object = object, ExtraOverrides = object>(Form: YupFormType<FieldDefs, ExtraProps, ExtraFieldProps, ExtraOverrides>): YupFormType<FieldDefs, ExtraProps & Omit<BaseModalProps, "children">, ExtraFieldProps, ExtraOverrides & FormDialogFieldOverrides>;
62
-
63
58
  declare const Form: YupFormType<unknown, object, any, object, "yup">;
64
59
  declare const StepForm: (<TSteps extends Required<dist.StepsOptions<AnyObjectSchema>> = {
65
60
  name: string;
@@ -189,7 +184,7 @@ declare const StepForm: (<TSteps extends Required<dist.StepsOptions<AnyObjectSch
189
184
  type?: "text" | undefined;
190
185
  } & Omit<Omit<dist.BaseFieldProps<react_hook_form.FieldValues, string>, keyof dist.InputFieldProps> & dist.InputFieldProps, keyof dist.BaseFieldProps<TFieldValues_1, TName>> & dist.BaseFieldProps<TFieldValues, react_hook_form.Path<TFieldValues>> & object) | ({
191
186
  type?: "checkbox" | undefined;
192
- } & Omit<Omit<dist.BaseFieldProps<react_hook_form.FieldValues, string>, keyof _chakra_ui_checkbox.CheckboxProps> & _chakra_ui_checkbox.CheckboxProps, keyof dist.BaseFieldProps<TFieldValues_1, TName>> & dist.BaseFieldProps<TFieldValues, react_hook_form.Path<TFieldValues>> & object) | ({
187
+ } & Omit<Omit<dist.BaseFieldProps<react_hook_form.FieldValues, string>, keyof _chakra_ui_react.CheckboxProps> & _chakra_ui_react.CheckboxProps, keyof dist.BaseFieldProps<TFieldValues_1, TName>> & dist.BaseFieldProps<TFieldValues, react_hook_form.Path<TFieldValues>> & object) | ({
193
188
  type?: "radio" | undefined;
194
189
  } & Omit<Omit<dist.BaseFieldProps<react_hook_form.FieldValues, string>, keyof dist.RadioInputProps> & dist.RadioInputProps, keyof dist.BaseFieldProps<TFieldValues_1, TName>> & dist.BaseFieldProps<TFieldValues, react_hook_form.Path<TFieldValues>> & object) | ({
195
190
  type?: "url" | undefined;
@@ -218,7 +213,7 @@ declare const StepForm: (<TSteps extends Required<dist.StepsOptions<AnyObjectSch
218
213
  type?: "text" | undefined;
219
214
  } & Omit<Omit<Omit<dist.BaseFieldProps<react_hook_form.FieldValues, string>, keyof dist.InputFieldProps> & dist.InputFieldProps, keyof dist.BaseFieldProps<TFieldValues_1, TName>> & dist.BaseFieldProps<TFieldValues, react_hook_form.Path<TFieldValues>>, "name">) | ({
220
215
  type?: "checkbox" | undefined;
221
- } & Omit<Omit<Omit<dist.BaseFieldProps<react_hook_form.FieldValues, string>, keyof _chakra_ui_checkbox.CheckboxProps> & _chakra_ui_checkbox.CheckboxProps, keyof dist.BaseFieldProps<TFieldValues_1, TName>> & dist.BaseFieldProps<TFieldValues, react_hook_form.Path<TFieldValues>>, "name">) | ({
216
+ } & Omit<Omit<Omit<dist.BaseFieldProps<react_hook_form.FieldValues, string>, keyof _chakra_ui_react.CheckboxProps> & _chakra_ui_react.CheckboxProps, keyof dist.BaseFieldProps<TFieldValues_1, TName>> & dist.BaseFieldProps<TFieldValues, react_hook_form.Path<TFieldValues>>, "name">) | ({
222
217
  type?: "radio" | undefined;
223
218
  } & Omit<Omit<Omit<dist.BaseFieldProps<react_hook_form.FieldValues, string>, keyof dist.RadioInputProps> & dist.RadioInputProps, keyof dist.BaseFieldProps<TFieldValues_1, TName>> & dist.BaseFieldProps<TFieldValues, react_hook_form.Path<TFieldValues>>, "name">) | ({
224
219
  type?: "url" | undefined;
@@ -241,13 +236,10 @@ declare const StepForm: (<TSteps extends Required<dist.StepsOptions<AnyObjectSch
241
236
  } & object) | undefined;
242
237
  } & {
243
238
  steps: TSteps;
244
- ref?: React$1.ForwardedRef<HTMLFormElement>;
245
- } & object) => React$1.ReactElement) & {
239
+ ref?: React.ForwardedRef<HTMLFormElement>;
240
+ } & object) => React.ReactElement) & {
246
241
  displayName?: string;
247
242
  id?: string;
248
243
  };
249
- declare const FormDialog: YupFormType<unknown, object & Omit<_saas_ui_modals.BaseModalProps, "children">, any, object & dist.DefaultFieldOverrides & {
250
- cancel?: _chakra_ui_button.ButtonProps;
251
- }>;
252
244
 
253
- export { type AnyObjectSchema, Form, FormDialog, type Options, StepForm, type YupFormType, createYupForm, createYupFormDialog, createYupStepForm, getFieldsFromSchema, getNestedSchema, yupFieldResolver };
245
+ export { type AnyObjectSchema, Form, type Options, StepForm, type YupFormType, createYupForm, createYupStepForm, getFieldsFromSchema, getNestedSchema, yupFieldResolver };
@@ -1,7 +1,4 @@
1
- import * as _chakra_ui_button from '@chakra-ui/button';
2
- import * as _saas_ui_modals from '@saas-ui/modals';
3
- import { BaseModalProps, FormDialogFieldOverrides } from '@saas-ui/modals';
4
- import * as _chakra_ui_checkbox from '@chakra-ui/checkbox';
1
+ import * as _chakra_ui_react from '@chakra-ui/react';
5
2
  import * as react_hook_form from 'react-hook-form';
6
3
  import * as React$1 from 'react';
7
4
  import React__default from 'react';
@@ -58,8 +55,6 @@ type YupStepFormType<FieldDefs, ExtraProps = object, ExtraFieldProps extends obj
58
55
  };
59
56
  declare const createYupStepForm: <FieldDefs, TGetBaseField extends GetBaseField = GetBaseField>(options?: CreateYupFormProps<FieldDefs, TGetBaseField>) => YupStepFormType<FieldDefs, object, TGetBaseField extends GetBaseField<infer ExtraFieldProps extends object> ? ExtraFieldProps : object>;
60
57
 
61
- declare function createYupFormDialog<FieldDefs = any, ExtraProps = object, ExtraFieldProps extends object = object, ExtraOverrides = object>(Form: YupFormType<FieldDefs, ExtraProps, ExtraFieldProps, ExtraOverrides>): YupFormType<FieldDefs, ExtraProps & Omit<BaseModalProps, "children">, ExtraFieldProps, ExtraOverrides & FormDialogFieldOverrides>;
62
-
63
58
  declare const Form: YupFormType<unknown, object, any, object, "yup">;
64
59
  declare const StepForm: (<TSteps extends Required<dist.StepsOptions<AnyObjectSchema>> = {
65
60
  name: string;
@@ -189,7 +184,7 @@ declare const StepForm: (<TSteps extends Required<dist.StepsOptions<AnyObjectSch
189
184
  type?: "text" | undefined;
190
185
  } & Omit<Omit<dist.BaseFieldProps<react_hook_form.FieldValues, string>, keyof dist.InputFieldProps> & dist.InputFieldProps, keyof dist.BaseFieldProps<TFieldValues_1, TName>> & dist.BaseFieldProps<TFieldValues, react_hook_form.Path<TFieldValues>> & object) | ({
191
186
  type?: "checkbox" | undefined;
192
- } & Omit<Omit<dist.BaseFieldProps<react_hook_form.FieldValues, string>, keyof _chakra_ui_checkbox.CheckboxProps> & _chakra_ui_checkbox.CheckboxProps, keyof dist.BaseFieldProps<TFieldValues_1, TName>> & dist.BaseFieldProps<TFieldValues, react_hook_form.Path<TFieldValues>> & object) | ({
187
+ } & Omit<Omit<dist.BaseFieldProps<react_hook_form.FieldValues, string>, keyof _chakra_ui_react.CheckboxProps> & _chakra_ui_react.CheckboxProps, keyof dist.BaseFieldProps<TFieldValues_1, TName>> & dist.BaseFieldProps<TFieldValues, react_hook_form.Path<TFieldValues>> & object) | ({
193
188
  type?: "radio" | undefined;
194
189
  } & Omit<Omit<dist.BaseFieldProps<react_hook_form.FieldValues, string>, keyof dist.RadioInputProps> & dist.RadioInputProps, keyof dist.BaseFieldProps<TFieldValues_1, TName>> & dist.BaseFieldProps<TFieldValues, react_hook_form.Path<TFieldValues>> & object) | ({
195
190
  type?: "url" | undefined;
@@ -218,7 +213,7 @@ declare const StepForm: (<TSteps extends Required<dist.StepsOptions<AnyObjectSch
218
213
  type?: "text" | undefined;
219
214
  } & Omit<Omit<Omit<dist.BaseFieldProps<react_hook_form.FieldValues, string>, keyof dist.InputFieldProps> & dist.InputFieldProps, keyof dist.BaseFieldProps<TFieldValues_1, TName>> & dist.BaseFieldProps<TFieldValues, react_hook_form.Path<TFieldValues>>, "name">) | ({
220
215
  type?: "checkbox" | undefined;
221
- } & Omit<Omit<Omit<dist.BaseFieldProps<react_hook_form.FieldValues, string>, keyof _chakra_ui_checkbox.CheckboxProps> & _chakra_ui_checkbox.CheckboxProps, keyof dist.BaseFieldProps<TFieldValues_1, TName>> & dist.BaseFieldProps<TFieldValues, react_hook_form.Path<TFieldValues>>, "name">) | ({
216
+ } & Omit<Omit<Omit<dist.BaseFieldProps<react_hook_form.FieldValues, string>, keyof _chakra_ui_react.CheckboxProps> & _chakra_ui_react.CheckboxProps, keyof dist.BaseFieldProps<TFieldValues_1, TName>> & dist.BaseFieldProps<TFieldValues, react_hook_form.Path<TFieldValues>>, "name">) | ({
222
217
  type?: "radio" | undefined;
223
218
  } & Omit<Omit<Omit<dist.BaseFieldProps<react_hook_form.FieldValues, string>, keyof dist.RadioInputProps> & dist.RadioInputProps, keyof dist.BaseFieldProps<TFieldValues_1, TName>> & dist.BaseFieldProps<TFieldValues, react_hook_form.Path<TFieldValues>>, "name">) | ({
224
219
  type?: "url" | undefined;
@@ -241,13 +236,10 @@ declare const StepForm: (<TSteps extends Required<dist.StepsOptions<AnyObjectSch
241
236
  } & object) | undefined;
242
237
  } & {
243
238
  steps: TSteps;
244
- ref?: React$1.ForwardedRef<HTMLFormElement>;
245
- } & object) => React$1.ReactElement) & {
239
+ ref?: React.ForwardedRef<HTMLFormElement>;
240
+ } & object) => React.ReactElement) & {
246
241
  displayName?: string;
247
242
  id?: string;
248
243
  };
249
- declare const FormDialog: YupFormType<unknown, object & Omit<_saas_ui_modals.BaseModalProps, "children">, any, object & dist.DefaultFieldOverrides & {
250
- cancel?: _chakra_ui_button.ButtonProps;
251
- }>;
252
244
 
253
- export { type AnyObjectSchema, Form, FormDialog, type Options, StepForm, type YupFormType, createYupForm, createYupFormDialog, createYupStepForm, getFieldsFromSchema, getNestedSchema, yupFieldResolver };
245
+ export { type AnyObjectSchema, Form, type Options, StepForm, type YupFormType, createYupForm, createYupStepForm, getFieldsFromSchema, getNestedSchema, yupFieldResolver };
package/dist/yup/index.js CHANGED
@@ -22,10 +22,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
22
22
  var src_exports = {};
23
23
  __export(src_exports, {
24
24
  Form: () => Form2,
25
- FormDialog: () => FormDialog,
26
25
  StepForm: () => StepForm,
27
26
  createYupForm: () => createYupForm,
28
- createYupFormDialog: () => createYupFormDialog,
29
27
  createYupStepForm: () => createYupStepForm,
30
28
  getFieldsFromSchema: () => getFieldsFromSchema,
31
29
  getNestedSchema: () => getNestedSchema,
@@ -134,23 +132,14 @@ var createYupStepForm = (options) => {
134
132
  return YupStepForm;
135
133
  };
136
134
 
137
- // yup/src/create-yup-dialog.ts
138
- var import_modals = require("@saas-ui/modals");
139
- function createYupFormDialog(Form3) {
140
- return (0, import_modals.createFormDialog)(Form3);
141
- }
142
-
143
135
  // yup/src/index.ts
144
136
  var Form2 = createYupForm();
145
137
  var StepForm = createYupStepForm();
146
- var FormDialog = createYupFormDialog(Form2);
147
138
  // Annotate the CommonJS export names for ESM import in node:
148
139
  0 && (module.exports = {
149
140
  Form,
150
- FormDialog,
151
141
  StepForm,
152
142
  createYupForm,
153
- createYupFormDialog,
154
143
  createYupStepForm,
155
144
  getFieldsFromSchema,
156
145
  getNestedSchema,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../yup/src/index.ts","../../yup/src/yup-resolver.ts","../../yup/src/create-yup-form.ts","../../yup/src/create-yup-step-form.ts","../../yup/src/create-yup-dialog.ts"],"sourcesContent":["export {\n type Options,\n getFieldsFromSchema,\n getNestedSchema,\n yupFieldResolver,\n yupResolver,\n} from './yup-resolver'\nexport { createYupForm, type YupFormType } from './create-yup-form'\nexport { createYupStepForm } from './create-yup-step-form'\nexport { createYupFormDialog } from './create-yup-dialog'\nexport type { AnyObjectSchema } from './types'\n\nimport { createYupForm } from './create-yup-form'\nimport { createYupStepForm } from './create-yup-step-form'\nimport { createYupFormDialog } from './create-yup-dialog'\n\nexport const Form = createYupForm()\n\nexport const StepForm = createYupStepForm()\n\nexport const FormDialog = createYupFormDialog(Form)\n","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 GetBaseField,\n} from '@saas-ui/forms'\nimport { yupFieldResolver, yupResolver } from './yup-resolver'\nimport { InferType, AnyObjectSchema } from 'yup'\nimport React from 'react'\n\ntype ResolverArgs = Parameters<typeof yupResolver>\n\nexport interface CreateYupFormProps<\n FieldDefs,\n TGetBaseField extends GetBaseField = GetBaseField,\n> extends CreateFormProps<FieldDefs, TGetBaseField> {\n schemaOptions?: ResolverArgs[1]\n resolverOptions?: ResolverArgs[2]\n}\n\nexport type YupFormType<\n FieldDefs,\n ExtraProps = object,\n ExtraFieldProps extends object = object,\n ExtraOverrides = object,\n Type extends 'yup' = 'yup',\n> = (<\n TSchema extends AnyObjectSchema = AnyObjectSchema,\n TFieldValues extends Required<InferType<TSchema>> = Required<\n InferType<TSchema>\n >,\n TContext extends object = object,\n>(\n props: WithFields<\n FormProps<TSchema, TFieldValues, TContext, ExtraFieldProps>,\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 = <\n FieldDefs,\n TGetBaseField extends GetBaseField<any> = GetBaseField<any>,\n>(\n options?: CreateYupFormProps<FieldDefs, TGetBaseField>\n) => {\n type ExtraFieldProps =\n TGetBaseField extends GetBaseField<infer ExtraFieldProps>\n ? ExtraFieldProps\n : object\n\n const YupForm = createForm({\n resolver: (schema: any) =>\n yupResolver(\n schema,\n options?.schemaOptions,\n options?.resolverOptions\n ) as any,\n fieldResolver: yupFieldResolver,\n ...options,\n })\n\n YupForm.displayName = 'YupForm'\n YupForm.id = 'YupForm'\n\n return YupForm as YupFormType<FieldDefs, object, ExtraFieldProps>\n}\n","import {\n CreateStepFormProps,\n createStepForm,\n StepsOptions,\n UseStepFormProps,\n Form,\n WithStepFields,\n GetBaseField,\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<\n FieldDefs,\n TGetBaseField extends GetBaseField = GetBaseField,\n> extends CreateStepFormProps<FieldDefs, TGetBaseField> {\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 ExtraFieldProps extends object = 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: WithStepFields<\n UseStepFormProps<TSteps, TFieldValues, TContext>,\n FieldDefs,\n ExtraOverrides\n > & {\n steps: TSteps\n ref?: React.ForwardedRef<HTMLFormElement>\n } & ExtraProps\n) => React.ReactElement) & {\n displayName?: string\n id?: string\n}\n\nexport const createYupStepForm = <\n FieldDefs,\n TGetBaseField extends GetBaseField = GetBaseField,\n>(\n options?: CreateYupFormProps<FieldDefs, TGetBaseField>\n) => {\n type ExtraFieldProps =\n TGetBaseField extends GetBaseField<infer ExtraFieldProps>\n ? ExtraFieldProps\n : object\n\n const YupStepForm = createStepForm<any, any>({\n resolver: (schema: any) =>\n yupResolver(\n schema,\n options?.schemaOptions,\n options?.resolverOptions\n ) as any,\n fieldResolver: yupFieldResolver,\n ...options,\n })\n\n YupStepForm.displayName = 'YupStepForm'\n YupStepForm.id = 'YupStepForm'\n\n return YupStepForm as YupStepFormType<FieldDefs, object, ExtraFieldProps>\n}\n","import {\n BaseModalProps,\n FormDialogFieldOverrides,\n createFormDialog,\n} from '@saas-ui/modals'\nimport { YupFormType } from './create-yup-form'\n\nexport function createYupFormDialog<\n FieldDefs = any,\n ExtraProps = object,\n ExtraFieldProps extends object = object,\n ExtraOverrides = object,\n>(Form: YupFormType<FieldDefs, ExtraProps, ExtraFieldProps, ExtraOverrides>) {\n return createFormDialog(Form) as unknown as YupFormType<\n FieldDefs,\n ExtraProps & Omit<BaseModalProps, 'children'>,\n ExtraFieldProps,\n ExtraOverrides & FormDialogFieldOverrides\n >\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,cAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iBAAsB;AACtB,IAAAC,cAA4B;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,MAAO,QAAO,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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 {"version":3,"sources":["../../yup/src/index.ts","../../yup/src/yup-resolver.ts","../../yup/src/create-yup-form.ts","../../yup/src/create-yup-step-form.ts"],"sourcesContent":["export {\n type Options,\n getFieldsFromSchema,\n getNestedSchema,\n yupFieldResolver,\n yupResolver,\n} from './yup-resolver'\nexport { createYupForm, type YupFormType } from './create-yup-form'\nexport { createYupStepForm } from './create-yup-step-form'\nexport type { AnyObjectSchema } from './types'\n\nimport { createYupForm } from './create-yup-form'\nimport { createYupStepForm } from './create-yup-step-form'\n\nexport const Form = createYupForm()\n\nexport const StepForm = createYupStepForm()\n","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 GetBaseField,\n} from '@saas-ui/forms'\nimport { yupFieldResolver, yupResolver } from './yup-resolver'\nimport { InferType, AnyObjectSchema } from 'yup'\nimport React from 'react'\n\ntype ResolverArgs = Parameters<typeof yupResolver>\n\nexport interface CreateYupFormProps<\n FieldDefs,\n TGetBaseField extends GetBaseField = GetBaseField,\n> extends CreateFormProps<FieldDefs, TGetBaseField> {\n schemaOptions?: ResolverArgs[1]\n resolverOptions?: ResolverArgs[2]\n}\n\nexport type YupFormType<\n FieldDefs,\n ExtraProps = object,\n ExtraFieldProps extends object = object,\n ExtraOverrides = object,\n Type extends 'yup' = 'yup',\n> = (<\n TSchema extends AnyObjectSchema = AnyObjectSchema,\n TFieldValues extends Required<InferType<TSchema>> = Required<\n InferType<TSchema>\n >,\n TContext extends object = object,\n>(\n props: WithFields<\n FormProps<TSchema, TFieldValues, TContext, ExtraFieldProps>,\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 = <\n FieldDefs,\n TGetBaseField extends GetBaseField<any> = GetBaseField<any>,\n>(\n options?: CreateYupFormProps<FieldDefs, TGetBaseField>\n) => {\n type ExtraFieldProps =\n TGetBaseField extends GetBaseField<infer ExtraFieldProps>\n ? ExtraFieldProps\n : object\n\n const YupForm = createForm({\n resolver: (schema: any) =>\n yupResolver(\n schema,\n options?.schemaOptions,\n options?.resolverOptions\n ) as any,\n fieldResolver: yupFieldResolver,\n ...options,\n })\n\n YupForm.displayName = 'YupForm'\n YupForm.id = 'YupForm'\n\n return YupForm as YupFormType<FieldDefs, object, ExtraFieldProps>\n}\n","import {\n CreateStepFormProps,\n createStepForm,\n StepsOptions,\n UseStepFormProps,\n Form,\n WithStepFields,\n GetBaseField,\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<\n FieldDefs,\n TGetBaseField extends GetBaseField = GetBaseField,\n> extends CreateStepFormProps<FieldDefs, TGetBaseField> {\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 ExtraFieldProps extends object = 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: WithStepFields<\n UseStepFormProps<TSteps, TFieldValues, TContext>,\n FieldDefs,\n ExtraOverrides\n > & {\n steps: TSteps\n ref?: React.ForwardedRef<HTMLFormElement>\n } & ExtraProps\n) => React.ReactElement) & {\n displayName?: string\n id?: string\n}\n\nexport const createYupStepForm = <\n FieldDefs,\n TGetBaseField extends GetBaseField = GetBaseField,\n>(\n options?: CreateYupFormProps<FieldDefs, TGetBaseField>\n) => {\n type ExtraFieldProps =\n TGetBaseField extends GetBaseField<infer ExtraFieldProps>\n ? ExtraFieldProps\n : object\n\n const YupStepForm = createStepForm<any, any>({\n resolver: (schema: any) =>\n yupResolver(\n schema,\n options?.schemaOptions,\n options?.resolverOptions\n ) as any,\n fieldResolver: yupFieldResolver,\n ...options,\n })\n\n YupStepForm.displayName = 'YupStepForm'\n YupStepForm.id = 'YupStepForm'\n\n return YupStepForm as YupStepFormType<FieldDefs, object, ExtraFieldProps>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,cAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iBAAsB;AACtB,IAAAC,cAA4B;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,MAAO,QAAO,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,aAAO,kBAAM,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,mBAMO;AAwCA,IAAM,gBAAgB,CAI3B,YACG;AAMH,QAAM,cAAU,yBAAW;AAAA,IACzB,UAAU,CAAC,eACT;AAAA,MACE;AAAA,MACA,mCAAS;AAAA,MACT,mCAAS;AAAA,IACX;AAAA,IACF,eAAe;AAAA,IACf,GAAG;AAAA,EACL,CAAC;AAED,UAAQ,cAAc;AACtB,UAAQ,KAAK;AAEb,SAAO;AACT;;;ACxEA,IAAAC,gBAQO;AAmDA,IAAM,oBAAoB,CAI/B,YACG;AAMH,QAAM,kBAAc,8BAAyB;AAAA,IAC3C,UAAU,CAAC,eACT;AAAA,MACE;AAAA,MACA,mCAAS;AAAA,MACT,mCAAS;AAAA,IACX;AAAA,IACF,eAAe;AAAA,IACf,GAAG;AAAA,EACL,CAAC;AAED,cAAY,cAAc;AAC1B,cAAY,KAAK;AAEjB,SAAO;AACT;;;AHvEO,IAAMC,QAAO,cAAc;AAE3B,IAAM,WAAW,kBAAkB;","names":["Form","import_yup","import_forms","Form"]}
@@ -104,24 +104,13 @@ var createYupStepForm = (options) => {
104
104
  return YupStepForm;
105
105
  };
106
106
 
107
- // yup/src/create-yup-dialog.ts
108
- import {
109
- createFormDialog
110
- } from "@saas-ui/modals";
111
- function createYupFormDialog(Form3) {
112
- return createFormDialog(Form3);
113
- }
114
-
115
107
  // yup/src/index.ts
116
108
  var Form2 = createYupForm();
117
109
  var StepForm = createYupStepForm();
118
- var FormDialog = createYupFormDialog(Form2);
119
110
  export {
120
111
  Form2 as Form,
121
- FormDialog,
122
112
  StepForm,
123
113
  createYupForm,
124
- createYupFormDialog,
125
114
  createYupStepForm,
126
115
  getFieldsFromSchema,
127
116
  getNestedSchema,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../yup/src/yup-resolver.ts","../../yup/src/create-yup-form.ts","../../yup/src/create-yup-step-form.ts","../../yup/src/create-yup-dialog.ts","../../yup/src/index.ts"],"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 GetBaseField,\n} from '@saas-ui/forms'\nimport { yupFieldResolver, yupResolver } from './yup-resolver'\nimport { InferType, AnyObjectSchema } from 'yup'\nimport React from 'react'\n\ntype ResolverArgs = Parameters<typeof yupResolver>\n\nexport interface CreateYupFormProps<\n FieldDefs,\n TGetBaseField extends GetBaseField = GetBaseField,\n> extends CreateFormProps<FieldDefs, TGetBaseField> {\n schemaOptions?: ResolverArgs[1]\n resolverOptions?: ResolverArgs[2]\n}\n\nexport type YupFormType<\n FieldDefs,\n ExtraProps = object,\n ExtraFieldProps extends object = object,\n ExtraOverrides = object,\n Type extends 'yup' = 'yup',\n> = (<\n TSchema extends AnyObjectSchema = AnyObjectSchema,\n TFieldValues extends Required<InferType<TSchema>> = Required<\n InferType<TSchema>\n >,\n TContext extends object = object,\n>(\n props: WithFields<\n FormProps<TSchema, TFieldValues, TContext, ExtraFieldProps>,\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 = <\n FieldDefs,\n TGetBaseField extends GetBaseField<any> = GetBaseField<any>,\n>(\n options?: CreateYupFormProps<FieldDefs, TGetBaseField>\n) => {\n type ExtraFieldProps =\n TGetBaseField extends GetBaseField<infer ExtraFieldProps>\n ? ExtraFieldProps\n : object\n\n const YupForm = createForm({\n resolver: (schema: any) =>\n yupResolver(\n schema,\n options?.schemaOptions,\n options?.resolverOptions\n ) as any,\n fieldResolver: yupFieldResolver,\n ...options,\n })\n\n YupForm.displayName = 'YupForm'\n YupForm.id = 'YupForm'\n\n return YupForm as YupFormType<FieldDefs, object, ExtraFieldProps>\n}\n","import {\n CreateStepFormProps,\n createStepForm,\n StepsOptions,\n UseStepFormProps,\n Form,\n WithStepFields,\n GetBaseField,\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<\n FieldDefs,\n TGetBaseField extends GetBaseField = GetBaseField,\n> extends CreateStepFormProps<FieldDefs, TGetBaseField> {\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 ExtraFieldProps extends object = 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: WithStepFields<\n UseStepFormProps<TSteps, TFieldValues, TContext>,\n FieldDefs,\n ExtraOverrides\n > & {\n steps: TSteps\n ref?: React.ForwardedRef<HTMLFormElement>\n } & ExtraProps\n) => React.ReactElement) & {\n displayName?: string\n id?: string\n}\n\nexport const createYupStepForm = <\n FieldDefs,\n TGetBaseField extends GetBaseField = GetBaseField,\n>(\n options?: CreateYupFormProps<FieldDefs, TGetBaseField>\n) => {\n type ExtraFieldProps =\n TGetBaseField extends GetBaseField<infer ExtraFieldProps>\n ? ExtraFieldProps\n : object\n\n const YupStepForm = createStepForm<any, any>({\n resolver: (schema: any) =>\n yupResolver(\n schema,\n options?.schemaOptions,\n options?.resolverOptions\n ) as any,\n fieldResolver: yupFieldResolver,\n ...options,\n })\n\n YupStepForm.displayName = 'YupStepForm'\n YupStepForm.id = 'YupStepForm'\n\n return YupStepForm as YupStepFormType<FieldDefs, object, ExtraFieldProps>\n}\n","import {\n BaseModalProps,\n FormDialogFieldOverrides,\n createFormDialog,\n} from '@saas-ui/modals'\nimport { YupFormType } from './create-yup-form'\n\nexport function createYupFormDialog<\n FieldDefs = any,\n ExtraProps = object,\n ExtraFieldProps extends object = object,\n ExtraOverrides = object,\n>(Form: YupFormType<FieldDefs, ExtraProps, ExtraFieldProps, ExtraOverrides>) {\n return createFormDialog(Form) as unknown as YupFormType<\n FieldDefs,\n ExtraProps & Omit<BaseModalProps, 'children'>,\n ExtraFieldProps,\n ExtraOverrides & FormDialogFieldOverrides\n >\n}\n","export {\n type Options,\n getFieldsFromSchema,\n getNestedSchema,\n yupFieldResolver,\n yupResolver,\n} from './yup-resolver'\nexport { createYupForm, type YupFormType } from './create-yup-form'\nexport { createYupStepForm } from './create-yup-step-form'\nexport { createYupFormDialog } from './create-yup-dialog'\nexport type { AnyObjectSchema } from './types'\n\nimport { createYupForm } from './create-yup-form'\nimport { createYupStepForm } from './create-yup-step-form'\nimport { createYupFormDialog } from './create-yup-dialog'\n\nexport const Form = createYupForm()\n\nexport const StepForm = createYupStepForm()\n\nexport const FormDialog = createYupFormDialog(Form)\n"],"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,a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S;AAAA,IACX;AAAA,IACF,eAAe;AAAA,IACf,GAAG;AAAA,EACL,CAAC;AAED,UAAQ,cAAc;AACtB,UAAQ,KAAK;AAEb,SAAO;AACT;;;ACxEA;AAAA,EAEE;AAAA,OAMK;AAmDA,IAAM,oBAAoB,CAI/B,YACG;AAMH,QAAM,cAAc,eAAyB;AAAA,IAC3C,UAAU,CAAC,WACT;AAAA,MACE;AAAA,MACA,mCAAS;AAAA,MACT,mCAAS;AAAA,IACX;AAAA,IACF,eAAe;AAAA,IACf,GAAG;AAAA,EACL,CAAC;AAED,cAAY,cAAc;AAC1B,cAAY,KAAK;AAEjB,SAAO;AACT;;;ACrFA;AAAA,EAGE;AAAA,OACK;AAGA,SAAS,oBAKdA,OAA2E;AAC3E,SAAO,iBAAiBA,KAAI;AAM9B;;;ACHO,IAAMC,QAAO,cAAc;AAE3B,IAAM,WAAW,kBAAkB;AAEnC,IAAM,aAAa,oBAAoBA,KAAI;","names":["Form","Form"]}
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"],"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 GetBaseField,\n} from '@saas-ui/forms'\nimport { yupFieldResolver, yupResolver } from './yup-resolver'\nimport { InferType, AnyObjectSchema } from 'yup'\nimport React from 'react'\n\ntype ResolverArgs = Parameters<typeof yupResolver>\n\nexport interface CreateYupFormProps<\n FieldDefs,\n TGetBaseField extends GetBaseField = GetBaseField,\n> extends CreateFormProps<FieldDefs, TGetBaseField> {\n schemaOptions?: ResolverArgs[1]\n resolverOptions?: ResolverArgs[2]\n}\n\nexport type YupFormType<\n FieldDefs,\n ExtraProps = object,\n ExtraFieldProps extends object = object,\n ExtraOverrides = object,\n Type extends 'yup' = 'yup',\n> = (<\n TSchema extends AnyObjectSchema = AnyObjectSchema,\n TFieldValues extends Required<InferType<TSchema>> = Required<\n InferType<TSchema>\n >,\n TContext extends object = object,\n>(\n props: WithFields<\n FormProps<TSchema, TFieldValues, TContext, ExtraFieldProps>,\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 = <\n FieldDefs,\n TGetBaseField extends GetBaseField<any> = GetBaseField<any>,\n>(\n options?: CreateYupFormProps<FieldDefs, TGetBaseField>\n) => {\n type ExtraFieldProps =\n TGetBaseField extends GetBaseField<infer ExtraFieldProps>\n ? ExtraFieldProps\n : object\n\n const YupForm = createForm({\n resolver: (schema: any) =>\n yupResolver(\n schema,\n options?.schemaOptions,\n options?.resolverOptions\n ) as any,\n fieldResolver: yupFieldResolver,\n ...options,\n })\n\n YupForm.displayName = 'YupForm'\n YupForm.id = 'YupForm'\n\n return YupForm as YupFormType<FieldDefs, object, ExtraFieldProps>\n}\n","import {\n CreateStepFormProps,\n createStepForm,\n StepsOptions,\n UseStepFormProps,\n Form,\n WithStepFields,\n GetBaseField,\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<\n FieldDefs,\n TGetBaseField extends GetBaseField = GetBaseField,\n> extends CreateStepFormProps<FieldDefs, TGetBaseField> {\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 ExtraFieldProps extends object = 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: WithStepFields<\n UseStepFormProps<TSteps, TFieldValues, TContext>,\n FieldDefs,\n ExtraOverrides\n > & {\n steps: TSteps\n ref?: React.ForwardedRef<HTMLFormElement>\n } & ExtraProps\n) => React.ReactElement) & {\n displayName?: string\n id?: string\n}\n\nexport const createYupStepForm = <\n FieldDefs,\n TGetBaseField extends GetBaseField = GetBaseField,\n>(\n options?: CreateYupFormProps<FieldDefs, TGetBaseField>\n) => {\n type ExtraFieldProps =\n TGetBaseField extends GetBaseField<infer ExtraFieldProps>\n ? ExtraFieldProps\n : object\n\n const YupStepForm = createStepForm<any, any>({\n resolver: (schema: any) =>\n yupResolver(\n schema,\n options?.schemaOptions,\n options?.resolverOptions\n ) as any,\n fieldResolver: yupFieldResolver,\n ...options,\n })\n\n YupStepForm.displayName = 'YupStepForm'\n YupStepForm.id = 'YupStepForm'\n\n return YupStepForm as YupStepFormType<FieldDefs, object, ExtraFieldProps>\n}\n","export {\n type Options,\n getFieldsFromSchema,\n getNestedSchema,\n yupFieldResolver,\n yupResolver,\n} from './yup-resolver'\nexport { createYupForm, type YupFormType } from './create-yup-form'\nexport { createYupStepForm } from './create-yup-step-form'\nexport type { AnyObjectSchema } from './types'\n\nimport { createYupForm } from './create-yup-form'\nimport { createYupStepForm } from './create-yup-step-form'\n\nexport const Form = createYupForm()\n\nexport const StepForm = createYupStepForm()\n"],"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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;AAAA,EAEE;AAAA,OAMK;AAmDA,IAAM,oBAAoB,CAI/B,YACG;AAMH,QAAM,cAAc,eAAyB;AAAA,IAC3C,UAAU,CAAC,WACT;AAAA,MACE;AAAA,MACA,mCAAS;AAAA,MACT,mCAAS;AAAA,IACX;AAAA,IACF,eAAe;AAAA,IACf,GAAG;AAAA,EACL,CAAC;AAED,cAAY,cAAc;AAC1B,cAAY,KAAK;AAEjB,SAAO;AACT;;;ACvEO,IAAMA,QAAO,cAAc;AAE3B,IAAM,WAAW,kBAAkB;","names":["Form"]}
@@ -1,10 +1,7 @@
1
- import * as _chakra_ui_button from '@chakra-ui/button';
2
- import * as _saas_ui_modals from '@saas-ui/modals';
3
- import { BaseModalProps, FormDialogFieldOverrides } from '@saas-ui/modals';
4
- import * as _chakra_ui_checkbox from '@chakra-ui/checkbox';
1
+ import * as _chakra_ui_react from '@chakra-ui/react';
5
2
  import * as react_hook_form from 'react-hook-form';
6
- import * as react from 'react';
7
- import react__default from 'react';
3
+ import * as React$1 from 'react';
4
+ import React__default from 'react';
8
5
  import * as dist from 'dist';
9
6
  import * as zod from 'zod';
10
7
  import { z, AnyZodObject } from 'zod';
@@ -71,8 +68,6 @@ type ZodFormType<FieldDefs, ExtraProps = object, ExtraFieldProps extends object
71
68
  };
72
69
  declare const createZodForm: <FieldDefs, TGetBaseField extends GetBaseField<any> = GetBaseField<any>>(options?: CreateZodFormProps<FieldDefs, TGetBaseField>) => ZodFormType<FieldDefs, object, TGetBaseField extends GetBaseField<infer ExtraFieldProps extends object> ? ExtraFieldProps : object>;
73
70
 
74
- declare function createZodFormDialog<FieldDefs = any, ExtraProps = object, ExtraFieldProps extends object = object, ExtraOverrides = object>(Form: ZodFormType<FieldDefs, ExtraProps, ExtraFieldProps, ExtraOverrides>): ZodFormType<FieldDefs, ExtraProps & Omit<BaseModalProps, "children">, ExtraFieldProps, ExtraOverrides & FormDialogFieldOverrides>;
75
-
76
71
  type ResolverArgs = Parameters<typeof zodResolver>;
77
72
  interface CreateZodStepFormProps<FieldDefs, TGetBaseField extends GetBaseField = GetBaseField> extends CreateStepFormProps<FieldDefs, TGetBaseField> {
78
73
  schemaOptions?: ResolverArgs[1];
@@ -86,8 +81,8 @@ type InferStepType<T extends Required<StepsOptions<AnyZodObject>>> = T extends [
86
81
  } ? z.infer<Step['schema']> & (Rest extends Required<StepsOptions<AnyZodObject>> ? InferStepType<Rest> : object) : object : object;
87
82
  type ZodStepFormType<FieldDefs, ExtraProps = object, ExtraFieldProps extends object = object, ExtraOverrides = object> = (<TSteps extends Required<StepsOptions<AnyZodObject>> = Required<StepsOptions<AnyZodObject>>, TFieldValues extends InferStepType<TSteps> = InferStepType<TSteps>, TContext extends object = object>(props: WithStepFields<UseStepFormProps<TSteps, TFieldValues, TContext>, FieldDefs, ExtraOverrides> & {
88
83
  steps: TSteps;
89
- ref?: react__default.ForwardedRef<HTMLFormElement>;
90
- } & ExtraProps) => react__default.ReactElement) & {
84
+ ref?: React__default.ForwardedRef<HTMLFormElement>;
85
+ } & ExtraProps) => React__default.ReactElement) & {
91
86
  displayName?: string;
92
87
  id?: string;
93
88
  };
@@ -208,7 +203,7 @@ declare const StepForm: (<TSteps extends Required<dist.StepsOptions<zod.AnyZodOb
208
203
  name: string;
209
204
  schema?: zod.AnyZodObject | undefined;
210
205
  }[] ? 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: Omit<dist.UseStepFormProps<TSteps, TFieldValues, TContext>, "children" | "fields"> & {
211
- children?: react.ReactNode | ((props: dist.StepFormRenderContext<TSteps, TFieldValues, TContext, ({
206
+ children?: React$1.ReactNode | ((props: dist.StepFormRenderContext<TSteps, TFieldValues, TContext, ({
212
207
  type?: "number" | undefined;
213
208
  } & Omit<Omit<dist.BaseFieldProps<react_hook_form.FieldValues, string>, keyof dist.NumberInputFieldProps> & dist.NumberInputFieldProps, keyof dist.BaseFieldProps<TFieldValues_1, TName>> & dist.BaseFieldProps<TFieldValues, react_hook_form.Path<TFieldValues>> & object) | ({
214
209
  type?: "select" | undefined;
@@ -222,7 +217,7 @@ declare const StepForm: (<TSteps extends Required<dist.StepsOptions<zod.AnyZodOb
222
217
  type?: "text" | undefined;
223
218
  } & Omit<Omit<dist.BaseFieldProps<react_hook_form.FieldValues, string>, keyof dist.InputFieldProps> & dist.InputFieldProps, keyof dist.BaseFieldProps<TFieldValues_1, TName>> & dist.BaseFieldProps<TFieldValues, react_hook_form.Path<TFieldValues>> & object) | ({
224
219
  type?: "checkbox" | undefined;
225
- } & Omit<Omit<dist.BaseFieldProps<react_hook_form.FieldValues, string>, keyof _chakra_ui_checkbox.CheckboxProps> & _chakra_ui_checkbox.CheckboxProps, keyof dist.BaseFieldProps<TFieldValues_1, TName>> & dist.BaseFieldProps<TFieldValues, react_hook_form.Path<TFieldValues>> & object) | ({
220
+ } & Omit<Omit<dist.BaseFieldProps<react_hook_form.FieldValues, string>, keyof _chakra_ui_react.CheckboxProps> & _chakra_ui_react.CheckboxProps, keyof dist.BaseFieldProps<TFieldValues_1, TName>> & dist.BaseFieldProps<TFieldValues, react_hook_form.Path<TFieldValues>> & object) | ({
226
221
  type?: "radio" | undefined;
227
222
  } & Omit<Omit<dist.BaseFieldProps<react_hook_form.FieldValues, string>, keyof dist.RadioInputProps> & dist.RadioInputProps, keyof dist.BaseFieldProps<TFieldValues_1, TName>> & dist.BaseFieldProps<TFieldValues, react_hook_form.Path<TFieldValues>> & object) | ({
228
223
  type?: "url" | undefined;
@@ -251,7 +246,7 @@ declare const StepForm: (<TSteps extends Required<dist.StepsOptions<zod.AnyZodOb
251
246
  type?: "text" | undefined;
252
247
  } & Omit<Omit<Omit<dist.BaseFieldProps<react_hook_form.FieldValues, string>, keyof dist.InputFieldProps> & dist.InputFieldProps, keyof dist.BaseFieldProps<TFieldValues_1, TName>> & dist.BaseFieldProps<TFieldValues, react_hook_form.Path<TFieldValues>>, "name">) | ({
253
248
  type?: "checkbox" | undefined;
254
- } & Omit<Omit<Omit<dist.BaseFieldProps<react_hook_form.FieldValues, string>, keyof _chakra_ui_checkbox.CheckboxProps> & _chakra_ui_checkbox.CheckboxProps, keyof dist.BaseFieldProps<TFieldValues_1, TName>> & dist.BaseFieldProps<TFieldValues, react_hook_form.Path<TFieldValues>>, "name">) | ({
249
+ } & Omit<Omit<Omit<dist.BaseFieldProps<react_hook_form.FieldValues, string>, keyof _chakra_ui_react.CheckboxProps> & _chakra_ui_react.CheckboxProps, keyof dist.BaseFieldProps<TFieldValues_1, TName>> & dist.BaseFieldProps<TFieldValues, react_hook_form.Path<TFieldValues>>, "name">) | ({
255
250
  type?: "radio" | undefined;
256
251
  } & Omit<Omit<Omit<dist.BaseFieldProps<react_hook_form.FieldValues, string>, keyof dist.RadioInputProps> & dist.RadioInputProps, keyof dist.BaseFieldProps<TFieldValues_1, TName>> & dist.BaseFieldProps<TFieldValues, react_hook_form.Path<TFieldValues>>, "name">) | ({
257
252
  type?: "url" | undefined;
@@ -274,13 +269,10 @@ declare const StepForm: (<TSteps extends Required<dist.StepsOptions<zod.AnyZodOb
274
269
  } & object) | undefined;
275
270
  } & {
276
271
  steps: TSteps;
277
- ref?: react.ForwardedRef<HTMLFormElement>;
278
- } & object) => react.ReactElement) & {
272
+ ref?: React.ForwardedRef<HTMLFormElement>;
273
+ } & object) => React.ReactElement) & {
279
274
  displayName?: string;
280
275
  id?: string;
281
276
  };
282
- declare const FormDialog: ZodFormType<unknown, object & Omit<_saas_ui_modals.BaseModalProps, "children">, any, object & dist.DefaultFieldOverrides & {
283
- cancel?: _chakra_ui_button.ButtonProps;
284
- }>;
285
277
 
286
- export { Form, FormDialog, StepForm, type ZodFormType, type ZodMeta, createZodForm, createZodFormDialog, createZodStepForm, getFieldsFromSchema, getNestedSchema, zodFieldResolver, zodMeta, zodParseMeta };
278
+ export { Form, StepForm, type ZodFormType, type ZodMeta, createZodForm, createZodStepForm, getFieldsFromSchema, getNestedSchema, zodFieldResolver, zodMeta, zodParseMeta };
@@ -1,10 +1,7 @@
1
- import * as _chakra_ui_button from '@chakra-ui/button';
2
- import * as _saas_ui_modals from '@saas-ui/modals';
3
- import { BaseModalProps, FormDialogFieldOverrides } from '@saas-ui/modals';
4
- import * as _chakra_ui_checkbox from '@chakra-ui/checkbox';
1
+ import * as _chakra_ui_react from '@chakra-ui/react';
5
2
  import * as react_hook_form from 'react-hook-form';
6
- import * as react from 'react';
7
- import react__default from 'react';
3
+ import * as React$1 from 'react';
4
+ import React__default from 'react';
8
5
  import * as dist from 'dist';
9
6
  import * as zod from 'zod';
10
7
  import { z, AnyZodObject } from 'zod';
@@ -71,8 +68,6 @@ type ZodFormType<FieldDefs, ExtraProps = object, ExtraFieldProps extends object
71
68
  };
72
69
  declare const createZodForm: <FieldDefs, TGetBaseField extends GetBaseField<any> = GetBaseField<any>>(options?: CreateZodFormProps<FieldDefs, TGetBaseField>) => ZodFormType<FieldDefs, object, TGetBaseField extends GetBaseField<infer ExtraFieldProps extends object> ? ExtraFieldProps : object>;
73
70
 
74
- declare function createZodFormDialog<FieldDefs = any, ExtraProps = object, ExtraFieldProps extends object = object, ExtraOverrides = object>(Form: ZodFormType<FieldDefs, ExtraProps, ExtraFieldProps, ExtraOverrides>): ZodFormType<FieldDefs, ExtraProps & Omit<BaseModalProps, "children">, ExtraFieldProps, ExtraOverrides & FormDialogFieldOverrides>;
75
-
76
71
  type ResolverArgs = Parameters<typeof zodResolver>;
77
72
  interface CreateZodStepFormProps<FieldDefs, TGetBaseField extends GetBaseField = GetBaseField> extends CreateStepFormProps<FieldDefs, TGetBaseField> {
78
73
  schemaOptions?: ResolverArgs[1];
@@ -86,8 +81,8 @@ type InferStepType<T extends Required<StepsOptions<AnyZodObject>>> = T extends [
86
81
  } ? z.infer<Step['schema']> & (Rest extends Required<StepsOptions<AnyZodObject>> ? InferStepType<Rest> : object) : object : object;
87
82
  type ZodStepFormType<FieldDefs, ExtraProps = object, ExtraFieldProps extends object = object, ExtraOverrides = object> = (<TSteps extends Required<StepsOptions<AnyZodObject>> = Required<StepsOptions<AnyZodObject>>, TFieldValues extends InferStepType<TSteps> = InferStepType<TSteps>, TContext extends object = object>(props: WithStepFields<UseStepFormProps<TSteps, TFieldValues, TContext>, FieldDefs, ExtraOverrides> & {
88
83
  steps: TSteps;
89
- ref?: react__default.ForwardedRef<HTMLFormElement>;
90
- } & ExtraProps) => react__default.ReactElement) & {
84
+ ref?: React__default.ForwardedRef<HTMLFormElement>;
85
+ } & ExtraProps) => React__default.ReactElement) & {
91
86
  displayName?: string;
92
87
  id?: string;
93
88
  };
@@ -208,7 +203,7 @@ declare const StepForm: (<TSteps extends Required<dist.StepsOptions<zod.AnyZodOb
208
203
  name: string;
209
204
  schema?: zod.AnyZodObject | undefined;
210
205
  }[] ? 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: Omit<dist.UseStepFormProps<TSteps, TFieldValues, TContext>, "children" | "fields"> & {
211
- children?: react.ReactNode | ((props: dist.StepFormRenderContext<TSteps, TFieldValues, TContext, ({
206
+ children?: React$1.ReactNode | ((props: dist.StepFormRenderContext<TSteps, TFieldValues, TContext, ({
212
207
  type?: "number" | undefined;
213
208
  } & Omit<Omit<dist.BaseFieldProps<react_hook_form.FieldValues, string>, keyof dist.NumberInputFieldProps> & dist.NumberInputFieldProps, keyof dist.BaseFieldProps<TFieldValues_1, TName>> & dist.BaseFieldProps<TFieldValues, react_hook_form.Path<TFieldValues>> & object) | ({
214
209
  type?: "select" | undefined;
@@ -222,7 +217,7 @@ declare const StepForm: (<TSteps extends Required<dist.StepsOptions<zod.AnyZodOb
222
217
  type?: "text" | undefined;
223
218
  } & Omit<Omit<dist.BaseFieldProps<react_hook_form.FieldValues, string>, keyof dist.InputFieldProps> & dist.InputFieldProps, keyof dist.BaseFieldProps<TFieldValues_1, TName>> & dist.BaseFieldProps<TFieldValues, react_hook_form.Path<TFieldValues>> & object) | ({
224
219
  type?: "checkbox" | undefined;
225
- } & Omit<Omit<dist.BaseFieldProps<react_hook_form.FieldValues, string>, keyof _chakra_ui_checkbox.CheckboxProps> & _chakra_ui_checkbox.CheckboxProps, keyof dist.BaseFieldProps<TFieldValues_1, TName>> & dist.BaseFieldProps<TFieldValues, react_hook_form.Path<TFieldValues>> & object) | ({
220
+ } & Omit<Omit<dist.BaseFieldProps<react_hook_form.FieldValues, string>, keyof _chakra_ui_react.CheckboxProps> & _chakra_ui_react.CheckboxProps, keyof dist.BaseFieldProps<TFieldValues_1, TName>> & dist.BaseFieldProps<TFieldValues, react_hook_form.Path<TFieldValues>> & object) | ({
226
221
  type?: "radio" | undefined;
227
222
  } & Omit<Omit<dist.BaseFieldProps<react_hook_form.FieldValues, string>, keyof dist.RadioInputProps> & dist.RadioInputProps, keyof dist.BaseFieldProps<TFieldValues_1, TName>> & dist.BaseFieldProps<TFieldValues, react_hook_form.Path<TFieldValues>> & object) | ({
228
223
  type?: "url" | undefined;
@@ -251,7 +246,7 @@ declare const StepForm: (<TSteps extends Required<dist.StepsOptions<zod.AnyZodOb
251
246
  type?: "text" | undefined;
252
247
  } & Omit<Omit<Omit<dist.BaseFieldProps<react_hook_form.FieldValues, string>, keyof dist.InputFieldProps> & dist.InputFieldProps, keyof dist.BaseFieldProps<TFieldValues_1, TName>> & dist.BaseFieldProps<TFieldValues, react_hook_form.Path<TFieldValues>>, "name">) | ({
253
248
  type?: "checkbox" | undefined;
254
- } & Omit<Omit<Omit<dist.BaseFieldProps<react_hook_form.FieldValues, string>, keyof _chakra_ui_checkbox.CheckboxProps> & _chakra_ui_checkbox.CheckboxProps, keyof dist.BaseFieldProps<TFieldValues_1, TName>> & dist.BaseFieldProps<TFieldValues, react_hook_form.Path<TFieldValues>>, "name">) | ({
249
+ } & Omit<Omit<Omit<dist.BaseFieldProps<react_hook_form.FieldValues, string>, keyof _chakra_ui_react.CheckboxProps> & _chakra_ui_react.CheckboxProps, keyof dist.BaseFieldProps<TFieldValues_1, TName>> & dist.BaseFieldProps<TFieldValues, react_hook_form.Path<TFieldValues>>, "name">) | ({
255
250
  type?: "radio" | undefined;
256
251
  } & Omit<Omit<Omit<dist.BaseFieldProps<react_hook_form.FieldValues, string>, keyof dist.RadioInputProps> & dist.RadioInputProps, keyof dist.BaseFieldProps<TFieldValues_1, TName>> & dist.BaseFieldProps<TFieldValues, react_hook_form.Path<TFieldValues>>, "name">) | ({
257
252
  type?: "url" | undefined;
@@ -274,13 +269,10 @@ declare const StepForm: (<TSteps extends Required<dist.StepsOptions<zod.AnyZodOb
274
269
  } & object) | undefined;
275
270
  } & {
276
271
  steps: TSteps;
277
- ref?: react.ForwardedRef<HTMLFormElement>;
278
- } & object) => react.ReactElement) & {
272
+ ref?: React.ForwardedRef<HTMLFormElement>;
273
+ } & object) => React.ReactElement) & {
279
274
  displayName?: string;
280
275
  id?: string;
281
276
  };
282
- declare const FormDialog: ZodFormType<unknown, object & Omit<_saas_ui_modals.BaseModalProps, "children">, any, object & dist.DefaultFieldOverrides & {
283
- cancel?: _chakra_ui_button.ButtonProps;
284
- }>;
285
277
 
286
- export { Form, FormDialog, StepForm, type ZodFormType, type ZodMeta, createZodForm, createZodFormDialog, createZodStepForm, getFieldsFromSchema, getNestedSchema, zodFieldResolver, zodMeta, zodParseMeta };
278
+ export { Form, StepForm, type ZodFormType, type ZodMeta, createZodForm, createZodStepForm, getFieldsFromSchema, getNestedSchema, zodFieldResolver, zodMeta, zodParseMeta };
package/dist/zod/index.js CHANGED
@@ -22,10 +22,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
22
22
  var src_exports = {};
23
23
  __export(src_exports, {
24
24
  Form: () => Form,
25
- FormDialog: () => FormDialog,
26
25
  StepForm: () => StepForm,
27
26
  createZodForm: () => createZodForm,
28
- createZodFormDialog: () => createZodFormDialog,
29
27
  createZodStepForm: () => createZodStepForm,
30
28
  getFieldsFromSchema: () => getFieldsFromSchema,
31
29
  getNestedSchema: () => getNestedSchema,
@@ -87,7 +85,10 @@ var getFieldsFromSchema = (schema) => {
87
85
  return { label: value, value };
88
86
  });
89
87
  } else if (def.typeName === "ZodNativeEnum") {
90
- props.options = Object.entries(def.values).map(([label, value]) => ({ label, value }));
88
+ props.options = Object.entries(def.values).map(([label, value]) => ({
89
+ label,
90
+ value
91
+ }));
91
92
  }
92
93
  const meta = field.description && zodParseMeta(field.description);
93
94
  fields.push({
@@ -139,12 +140,6 @@ var createZodForm = (options) => {
139
140
  return ZodForm;
140
141
  };
141
142
 
142
- // zod/src/create-zod-dialog.ts
143
- var import_modals = require("@saas-ui/modals");
144
- function createZodFormDialog(Form2) {
145
- return (0, import_modals.createFormDialog)(Form2);
146
- }
147
-
148
143
  // zod/src/create-zod-step-form.ts
149
144
  var import_forms2 = require("@saas-ui/forms");
150
145
  var createZodStepForm = (options) => {
@@ -161,14 +156,11 @@ var createZodStepForm = (options) => {
161
156
  // zod/src/index.ts
162
157
  var Form = createZodForm();
163
158
  var StepForm = createZodStepForm();
164
- var FormDialog = createZodFormDialog(Form);
165
159
  // Annotate the CommonJS export names for ESM import in node:
166
160
  0 && (module.exports = {
167
161
  Form,
168
- FormDialog,
169
162
  StepForm,
170
163
  createZodForm,
171
- createZodFormDialog,
172
164
  createZodStepForm,
173
165
  getFieldsFromSchema,
174
166
  getNestedSchema,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../zod/src/index.ts","../../zod/src/zod-resolver.ts","../../zod/src/create-zod-form.ts","../../zod/src/create-zod-dialog.ts","../../zod/src/create-zod-step-form.ts"],"sourcesContent":["export {\n zodResolver,\n getFieldsFromSchema,\n getNestedSchema,\n zodFieldResolver,\n zodMeta,\n zodParseMeta,\n} from './zod-resolver'\nexport type { ZodMeta } from './zod-resolver'\nexport { createZodForm, type ZodFormType } from './create-zod-form'\nexport { createZodFormDialog } from './create-zod-dialog'\nexport { createZodStepForm } from './create-zod-step-form'\n\nimport { createZodForm } from './create-zod-form'\nimport { createZodStepForm } from './create-zod-step-form'\nimport { createZodFormDialog } from './create-zod-dialog'\n\nexport const Form = createZodForm()\n\nexport const StepForm = createZodStepForm()\n\nexport const FormDialog = createZodFormDialog(Form)\n","import * as z from 'zod'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { get } from '@chakra-ui/utils'\nimport { FieldProps } from '@saas-ui/forms'\n\nexport { zodResolver }\n\nexport type ExtraProps = {\n min?: number\n max?: number\n options?: { label: string; value: string }[]\n}\n\nconst getType = (\n field: z.ZodTypeAny\n): 'array' | 'object' | 'number' | 'date' | 'select' | 'text' => {\n if (['ZodDefault', 'ZodOptional'].includes(field._def.typeName)) {\n return getType(field._def.innerType)\n }\n\n switch (field._def.typeName) {\n case 'ZodArray':\n return 'array'\n case 'ZodObject':\n return 'object'\n case 'ZodNumber':\n return 'number'\n case 'ZodDate':\n return 'date'\n case 'ZodNativeEnum':\n case 'ZodEnum':\n return 'select'\n case 'ZodString':\n default:\n return 'text'\n }\n}\n\nconst getArrayOption = (field: any, name: string) => {\n return field._def[name]?.value\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: z.ZodTypeAny): FieldProps[] => {\n const fields: FieldProps[] = []\n\n let schemaFields: Record<string, any> = {}\n if (schema._def.typeName === 'ZodArray') {\n schemaFields = schema._def.type.shape\n } else if (schema._def.typeName === 'ZodObject') {\n schemaFields = schema._def.shape()\n } else {\n return fields\n }\n\n for (const name in schemaFields) {\n const field = schemaFields[name]\n\n const def =\n field._def.typeName === 'ZodDefault'\n ? field._def.innerType._def\n : field._def\n\n const props: ExtraProps = {}\n if (def.typeName === 'ZodArray') {\n props.min = getArrayOption(field, 'minLength')\n props.max = getArrayOption(field, 'maxLength')\n } else if (def.typeName === 'ZodEnum') {\n props.options = def.values.map((value: string) => {\n return { label: value, value }\n })\n } else if (def.typeName === 'ZodNativeEnum') {\n props.options = Object.entries(def.values).map(([label, value]) => ({ label, value: value as string }))\n }\n\n const meta = field.description && zodParseMeta(field.description)\n\n fields.push({\n name,\n label: meta?.label || field.description || name,\n type: meta?.type || getType(field),\n help: meta?.help,\n placeholder: meta?.placeholder,\n defaultValue: field._def.defaultValue?.(),\n ...props,\n })\n }\n return fields\n}\n\nexport const getNestedSchema = (schema: z.ZodTypeAny, path: string) => {\n return get(schema._def.shape(), path)\n}\n\nexport const zodFieldResolver = <T extends z.ZodTypeAny>(schema: T) => {\n return {\n getFields() {\n return getFieldsFromSchema(schema)\n },\n getNestedFields(name: string) {\n return getFieldsFromSchema(getNestedSchema(schema, name))\n },\n }\n}\n\nexport interface ZodMeta {\n /**\n * The label of the field\n */\n label: string\n\n /**\n * The type of the field\n */\n type?: string\n\n /**\n * The placeholder of the field\n */\n placeholder?: string\n\n /**\n * The help text of the field\n */\n help?: string\n\n /**\n * Object field column count\n */\n columns?: number\n\n /**\n * Array field min rows\n */\n min?: number\n\n /**\n * Array field max rows\n */\n max?: number\n\n [key: string]: any\n}\n\nexport const zodMeta = (meta: ZodMeta) => {\n return JSON.stringify(meta)\n}\n\nexport const zodParseMeta = (meta: string) => {\n try {\n return JSON.parse(meta)\n } catch (e) {\n return meta\n }\n}\n","import {\n createForm,\n CreateFormProps,\n WithFields,\n FormProps,\n GetBaseField,\n} from '@saas-ui/forms'\nimport { zodFieldResolver, zodResolver } from './zod-resolver'\nimport { z } from 'zod'\n\ntype ResolverArgs = Parameters<typeof zodResolver>\n\nexport interface CreateZodFormProps<\n FieldDefs,\n TGetBaseField extends GetBaseField = GetBaseField,\n> extends CreateFormProps<FieldDefs, TGetBaseField> {\n schemaOptions?: ResolverArgs[1]\n resolverOptions?: ResolverArgs[2]\n}\n\nexport type ZodFormType<\n FieldDefs,\n ExtraProps = object,\n ExtraFieldProps extends object = object,\n ExtraOverrides = object,\n Type extends 'zod' = 'zod',\n> = (<\n TSchema extends z.AnyZodObject = z.AnyZodObject,\n TFieldValues extends z.infer<TSchema> = z.infer<TSchema>,\n TContext extends object = object,\n>(\n props: WithFields<\n FormProps<TSchema, TFieldValues, TContext, ExtraFieldProps>,\n FieldDefs,\n ExtraOverrides\n > & {\n ref?: React.ForwardedRef<HTMLFormElement>\n } & ExtraProps\n) => React.ReactElement) & {\n displayName?: string\n id?: string\n}\n\nexport const createZodForm = <\n FieldDefs,\n TGetBaseField extends GetBaseField<any> = GetBaseField<any>,\n>(\n options?: CreateZodFormProps<FieldDefs, TGetBaseField>\n) => {\n type ExtraFieldProps =\n TGetBaseField extends GetBaseField<infer ExtraFieldProps>\n ? ExtraFieldProps\n : object\n\n const ZodForm = createForm({\n resolver: (schema: any) =>\n zodResolver(schema, options?.schemaOptions, options?.resolverOptions),\n fieldResolver: zodFieldResolver,\n ...options,\n })\n\n ZodForm.displayName = 'ZodForm'\n ZodForm.id = 'ZodForm'\n\n return ZodForm as ZodFormType<FieldDefs, object, ExtraFieldProps>\n}\n","import {\n createFormDialog,\n BaseModalProps,\n FormDialogFieldOverrides,\n} from '@saas-ui/modals'\nimport { ZodFormType } from './create-zod-form'\n\nexport function createZodFormDialog<\n FieldDefs = any,\n ExtraProps = object,\n ExtraFieldProps extends object = object,\n ExtraOverrides = object,\n>(Form: ZodFormType<FieldDefs, ExtraProps, ExtraFieldProps, ExtraOverrides>) {\n return createFormDialog(Form) as unknown as ZodFormType<\n FieldDefs,\n ExtraProps & Omit<BaseModalProps, 'children'>,\n ExtraFieldProps,\n ExtraOverrides & FormDialogFieldOverrides\n >\n}\n","import {\n CreateStepFormProps,\n createStepForm,\n StepsOptions,\n UseStepFormProps,\n WithStepFields,\n GetBaseField,\n} from '@saas-ui/forms'\nimport { zodFieldResolver, zodResolver } from './zod-resolver'\nimport { AnyZodObject, z } from 'zod'\nimport React from 'react'\n\ntype ResolverArgs = Parameters<typeof zodResolver>\n\nexport interface CreateZodStepFormProps<\n FieldDefs,\n TGetBaseField extends GetBaseField = GetBaseField,\n> extends CreateStepFormProps<FieldDefs, TGetBaseField> {\n schemaOptions?: ResolverArgs[1]\n resolverOptions?: ResolverArgs[2]\n}\n\ntype InferStepType<T extends Required<StepsOptions<AnyZodObject>>> = T extends [\n infer Step,\n ...infer Rest,\n]\n ? Step extends { schema: AnyZodObject }\n ? z.infer<Step['schema']> &\n (Rest extends Required<StepsOptions<AnyZodObject>>\n ? InferStepType<Rest>\n : object)\n : object\n : object\n\ntype ZodStepFormType<\n FieldDefs,\n ExtraProps = object,\n ExtraFieldProps extends object = object,\n ExtraOverrides = object,\n> = (<\n TSteps extends Required<StepsOptions<AnyZodObject>> = Required<\n StepsOptions<AnyZodObject>\n >,\n TFieldValues extends InferStepType<TSteps> = InferStepType<TSteps>,\n TContext extends object = object,\n>(\n props: WithStepFields<\n UseStepFormProps<TSteps, TFieldValues, TContext>,\n FieldDefs,\n ExtraOverrides\n > & {\n steps: TSteps\n ref?: React.ForwardedRef<HTMLFormElement>\n } & ExtraProps\n) => React.ReactElement) & {\n displayName?: string\n id?: string\n}\n\nexport const createZodStepForm = <\n FieldDefs,\n TGetBaseField extends GetBaseField = GetBaseField,\n>(\n options?: CreateZodStepFormProps<FieldDefs, TGetBaseField>\n) => {\n type ExtraFieldProps =\n TGetBaseField extends GetBaseField<infer ExtraFieldProps>\n ? ExtraFieldProps\n : object\n\n const ZodStepForm = createStepForm<any, any>({\n resolver: (schema: any) =>\n zodResolver(schema, options?.schemaOptions, options?.resolverOptions),\n fieldResolver: zodFieldResolver,\n ...options,\n })\n\n ZodStepForm.displayName = 'ZodStepForm'\n ZodStepForm.id = 'ZodStepForm'\n\n return ZodStepForm as ZodStepFormType<FieldDefs, object, ExtraFieldProps>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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jEA,oBAIO;AAGA,SAAS,oBAKdA,OAA2E;AAC3E,aAAO,gCAAiBA,KAAI;AAM9B;;;ACnBA,IAAAC,gBAOO;AAoDA,IAAM,oBAAoB,CAI/B,YACG;AAMH,QAAM,kBAAc,8BAAyB;AAAA,IAC3C,UAAU,CAAC,eACT,wBAAY,QAAQ,mCAAS,eAAe,mCAAS,eAAe;AAAA,IACtE,eAAe;AAAA,IACf,GAAG;AAAA,EACL,CAAC;AAED,cAAY,cAAc;AAC1B,cAAY,KAAK;AAEjB,SAAO;AACT;;;AJhEO,IAAM,OAAO,cAAc;AAE3B,IAAM,WAAW,kBAAkB;AAEnC,IAAM,aAAa,oBAAoB,IAAI;","names":["Form","import_forms"]}
1
+ {"version":3,"sources":["../../zod/src/index.ts","../../zod/src/zod-resolver.ts","../../zod/src/create-zod-form.ts","../../zod/src/create-zod-step-form.ts"],"sourcesContent":["export {\n zodResolver,\n getFieldsFromSchema,\n getNestedSchema,\n zodFieldResolver,\n zodMeta,\n zodParseMeta,\n} from './zod-resolver'\nexport type { ZodMeta } from './zod-resolver'\nexport { createZodForm, type ZodFormType } from './create-zod-form'\n\nexport { createZodStepForm } from './create-zod-step-form'\n\nimport { createZodForm } from './create-zod-form'\nimport { createZodStepForm } from './create-zod-step-form'\n\nexport const Form = createZodForm()\n\nexport const StepForm = createZodStepForm()\n","import * as z from 'zod'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { get } from '@chakra-ui/utils'\nimport { FieldProps } from '@saas-ui/forms'\n\nexport { zodResolver }\n\nexport type ExtraProps = {\n min?: number\n max?: number\n options?: { label: string; value: string }[]\n}\n\nconst getType = (\n field: z.ZodTypeAny\n): 'array' | 'object' | 'number' | 'date' | 'select' | 'text' => {\n if (['ZodDefault', 'ZodOptional'].includes(field._def.typeName)) {\n return getType(field._def.innerType)\n }\n\n switch (field._def.typeName) {\n case 'ZodArray':\n return 'array'\n case 'ZodObject':\n return 'object'\n case 'ZodNumber':\n return 'number'\n case 'ZodDate':\n return 'date'\n case 'ZodNativeEnum':\n case 'ZodEnum':\n return 'select'\n case 'ZodString':\n default:\n return 'text'\n }\n}\n\nconst getArrayOption = (field: any, name: string) => {\n return field._def[name]?.value\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: z.ZodTypeAny): FieldProps[] => {\n const fields: FieldProps[] = []\n\n let schemaFields: Record<string, any> = {}\n if (schema._def.typeName === 'ZodArray') {\n schemaFields = schema._def.type.shape\n } else if (schema._def.typeName === 'ZodObject') {\n schemaFields = schema._def.shape()\n } else {\n return fields\n }\n\n for (const name in schemaFields) {\n const field = schemaFields[name]\n\n const def =\n field._def.typeName === 'ZodDefault'\n ? field._def.innerType._def\n : field._def\n\n const props: ExtraProps = {}\n if (def.typeName === 'ZodArray') {\n props.min = getArrayOption(field, 'minLength')\n props.max = getArrayOption(field, 'maxLength')\n } else if (def.typeName === 'ZodEnum') {\n props.options = def.values.map((value: string) => {\n return { label: value, value }\n })\n } else if (def.typeName === 'ZodNativeEnum') {\n props.options = Object.entries(def.values).map(([label, value]) => ({\n label,\n value: value as string,\n }))\n }\n\n const meta = field.description && zodParseMeta(field.description)\n\n fields.push({\n name,\n label: meta?.label || field.description || name,\n type: meta?.type || getType(field),\n help: meta?.help,\n placeholder: meta?.placeholder,\n defaultValue: field._def.defaultValue?.(),\n ...props,\n })\n }\n return fields\n}\n\nexport const getNestedSchema = (schema: z.ZodTypeAny, path: string) => {\n return get(schema._def.shape(), path)\n}\n\nexport const zodFieldResolver = <T extends z.ZodTypeAny>(schema: T) => {\n return {\n getFields() {\n return getFieldsFromSchema(schema)\n },\n getNestedFields(name: string) {\n return getFieldsFromSchema(getNestedSchema(schema, name))\n },\n }\n}\n\nexport interface ZodMeta {\n /**\n * The label of the field\n */\n label: string\n\n /**\n * The type of the field\n */\n type?: string\n\n /**\n * The placeholder of the field\n */\n placeholder?: string\n\n /**\n * The help text of the field\n */\n help?: string\n\n /**\n * Object field column count\n */\n columns?: number\n\n /**\n * Array field min rows\n */\n min?: number\n\n /**\n * Array field max rows\n */\n max?: number\n\n [key: string]: any\n}\n\nexport const zodMeta = (meta: ZodMeta) => {\n return JSON.stringify(meta)\n}\n\nexport const zodParseMeta = (meta: string) => {\n try {\n return JSON.parse(meta)\n } catch (e) {\n return meta\n }\n}\n","import {\n createForm,\n CreateFormProps,\n WithFields,\n FormProps,\n GetBaseField,\n} from '@saas-ui/forms'\nimport { zodFieldResolver, zodResolver } from './zod-resolver'\nimport { z } from 'zod'\n\ntype ResolverArgs = Parameters<typeof zodResolver>\n\nexport interface CreateZodFormProps<\n FieldDefs,\n TGetBaseField extends GetBaseField = GetBaseField,\n> extends CreateFormProps<FieldDefs, TGetBaseField> {\n schemaOptions?: ResolverArgs[1]\n resolverOptions?: ResolverArgs[2]\n}\n\nexport type ZodFormType<\n FieldDefs,\n ExtraProps = object,\n ExtraFieldProps extends object = object,\n ExtraOverrides = object,\n Type extends 'zod' = 'zod',\n> = (<\n TSchema extends z.AnyZodObject = z.AnyZodObject,\n TFieldValues extends z.infer<TSchema> = z.infer<TSchema>,\n TContext extends object = object,\n>(\n props: WithFields<\n FormProps<TSchema, TFieldValues, TContext, ExtraFieldProps>,\n FieldDefs,\n ExtraOverrides\n > & {\n ref?: React.ForwardedRef<HTMLFormElement>\n } & ExtraProps\n) => React.ReactElement) & {\n displayName?: string\n id?: string\n}\n\nexport const createZodForm = <\n FieldDefs,\n TGetBaseField extends GetBaseField<any> = GetBaseField<any>,\n>(\n options?: CreateZodFormProps<FieldDefs, TGetBaseField>\n) => {\n type ExtraFieldProps =\n TGetBaseField extends GetBaseField<infer ExtraFieldProps>\n ? ExtraFieldProps\n : object\n\n const ZodForm = createForm({\n resolver: (schema: any) =>\n zodResolver(schema, options?.schemaOptions, options?.resolverOptions),\n fieldResolver: zodFieldResolver,\n ...options,\n })\n\n ZodForm.displayName = 'ZodForm'\n ZodForm.id = 'ZodForm'\n\n return ZodForm as ZodFormType<FieldDefs, object, ExtraFieldProps>\n}\n","import {\n CreateStepFormProps,\n createStepForm,\n StepsOptions,\n UseStepFormProps,\n WithStepFields,\n GetBaseField,\n} from '@saas-ui/forms'\nimport { zodFieldResolver, zodResolver } from './zod-resolver'\nimport { AnyZodObject, z } from 'zod'\nimport React from 'react'\n\ntype ResolverArgs = Parameters<typeof zodResolver>\n\nexport interface CreateZodStepFormProps<\n FieldDefs,\n TGetBaseField extends GetBaseField = GetBaseField,\n> extends CreateStepFormProps<FieldDefs, TGetBaseField> {\n schemaOptions?: ResolverArgs[1]\n resolverOptions?: ResolverArgs[2]\n}\n\ntype InferStepType<T extends Required<StepsOptions<AnyZodObject>>> = T extends [\n infer Step,\n ...infer Rest,\n]\n ? Step extends { schema: AnyZodObject }\n ? z.infer<Step['schema']> &\n (Rest extends Required<StepsOptions<AnyZodObject>>\n ? InferStepType<Rest>\n : object)\n : object\n : object\n\ntype ZodStepFormType<\n FieldDefs,\n ExtraProps = object,\n ExtraFieldProps extends object = object,\n ExtraOverrides = object,\n> = (<\n TSteps extends Required<StepsOptions<AnyZodObject>> = Required<\n StepsOptions<AnyZodObject>\n >,\n TFieldValues extends InferStepType<TSteps> = InferStepType<TSteps>,\n TContext extends object = object,\n>(\n props: WithStepFields<\n UseStepFormProps<TSteps, TFieldValues, TContext>,\n FieldDefs,\n ExtraOverrides\n > & {\n steps: TSteps\n ref?: React.ForwardedRef<HTMLFormElement>\n } & ExtraProps\n) => React.ReactElement) & {\n displayName?: string\n id?: string\n}\n\nexport const createZodStepForm = <\n FieldDefs,\n TGetBaseField extends GetBaseField = GetBaseField,\n>(\n options?: CreateZodStepFormProps<FieldDefs, TGetBaseField>\n) => {\n type ExtraFieldProps =\n TGetBaseField extends GetBaseField<infer ExtraFieldProps>\n ? ExtraFieldProps\n : object\n\n const ZodStepForm = createStepForm<any, any>({\n resolver: (schema: any) =>\n zodResolver(schema, options?.schemaOptions, options?.resolverOptions),\n fieldResolver: zodFieldResolver,\n ...options,\n })\n\n ZodStepForm.displayName = 'ZodStepForm'\n ZodStepForm.id = 'ZodStepForm'\n\n return ZodStepForm as ZodStepFormType<FieldDefs, object, ExtraFieldProps>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,iBAA4B;AAC5B,mBAAoB;AAWpB,IAAM,UAAU,CACd,UAC+D;AAC/D,MAAI,CAAC,cAAc,aAAa,EAAE,SAAS,MAAM,KAAK,QAAQ,GAAG;AAC/D,WAAO,QAAQ,MAAM,KAAK,SAAS;AAAA,EACrC;AAEA,UAAQ,MAAM,KAAK,UAAU;AAAA,IAC3B,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AAAA,IACL;AACE,aAAO;AAAA,EACX;AACF;AAEA,IAAM,iBAAiB,CAAC,OAAY,SAAiB;AAtCrD;AAuCE,UAAO,WAAM,KAAK,IAAI,MAAf,mBAAkB;AAC3B;AAQO,IAAM,sBAAsB,CAAC,WAAuC;AAhD3E;AAiDE,QAAM,SAAuB,CAAC;AAE9B,MAAI,eAAoC,CAAC;AACzC,MAAI,OAAO,KAAK,aAAa,YAAY;AACvC,mBAAe,OAAO,KAAK,KAAK;AAAA,EAClC,WAAW,OAAO,KAAK,aAAa,aAAa;AAC/C,mBAAe,OAAO,KAAK,MAAM;AAAA,EACnC,OAAO;AACL,WAAO;AAAA,EACT;AAEA,aAAW,QAAQ,cAAc;AAC/B,UAAM,QAAQ,aAAa,IAAI;AAE/B,UAAM,MACJ,MAAM,KAAK,aAAa,eACpB,MAAM,KAAK,UAAU,OACrB,MAAM;AAEZ,UAAM,QAAoB,CAAC;AAC3B,QAAI,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MO;AAqCA,IAAM,gBAAgB,CAI3B,YACG;AAMH,QAAM,cAAU,yBAAW;AAAA,IACzB,UAAU,CAAC,eACT,wBAAY,QAAQ,mCAAS,eAAe,mCAAS,eAAe;AAAA,IACtE,eAAe;AAAA,IACf,GAAG;AAAA,EACL,CAAC;AAED,UAAQ,cAAc;AACtB,UAAQ,KAAK;AAEb,SAAO;AACT;;;ACjEA,IAAAA,gBAOO;AAoDA,IAAM,oBAAoB,CAI/B,YACG;AAMH,QAAM,kBAAc,8BAAyB;AAAA,IAC3C,UAAU,CAAC,eACT,wBAAY,QAAQ,mCAAS,eAAe,mCAAS,eAAe;AAAA,IACtE,eAAe;AAAA,IACf,GAAG;AAAA,EACL,CAAC;AAED,cAAY,cAAc;AAC1B,cAAY,KAAK;AAEjB,SAAO;AACT;;;AHjEO,IAAM,OAAO,cAAc;AAE3B,IAAM,WAAW,kBAAkB;","names":["import_forms"]}
@@ -51,7 +51,10 @@ var getFieldsFromSchema = (schema) => {
51
51
  return { label: value, value };
52
52
  });
53
53
  } else if (def.typeName === "ZodNativeEnum") {
54
- props.options = Object.entries(def.values).map(([label, value]) => ({ label, value }));
54
+ props.options = Object.entries(def.values).map(([label, value]) => ({
55
+ label,
56
+ value
57
+ }));
55
58
  }
56
59
  const meta = field.description && zodParseMeta(field.description);
57
60
  fields.push({
@@ -105,14 +108,6 @@ var createZodForm = (options) => {
105
108
  return ZodForm;
106
109
  };
107
110
 
108
- // zod/src/create-zod-dialog.ts
109
- import {
110
- createFormDialog
111
- } from "@saas-ui/modals";
112
- function createZodFormDialog(Form2) {
113
- return createFormDialog(Form2);
114
- }
115
-
116
111
  // zod/src/create-zod-step-form.ts
117
112
  import {
118
113
  createStepForm
@@ -131,13 +126,10 @@ var createZodStepForm = (options) => {
131
126
  // zod/src/index.ts
132
127
  var Form = createZodForm();
133
128
  var StepForm = createZodStepForm();
134
- var FormDialog = createZodFormDialog(Form);
135
129
  export {
136
130
  Form,
137
- FormDialog,
138
131
  StepForm,
139
132
  createZodForm,
140
- createZodFormDialog,
141
133
  createZodStepForm,
142
134
  getFieldsFromSchema,
143
135
  getNestedSchema,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../zod/src/zod-resolver.ts","../../zod/src/create-zod-form.ts","../../zod/src/create-zod-dialog.ts","../../zod/src/create-zod-step-form.ts","../../zod/src/index.ts"],"sourcesContent":["import * as z from 'zod'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { get } from '@chakra-ui/utils'\nimport { FieldProps } from '@saas-ui/forms'\n\nexport { zodResolver }\n\nexport type ExtraProps = {\n min?: number\n max?: number\n options?: { label: string; value: string }[]\n}\n\nconst getType = (\n field: z.ZodTypeAny\n): 'array' | 'object' | 'number' | 'date' | 'select' | 'text' => {\n if (['ZodDefault', 'ZodOptional'].includes(field._def.typeName)) {\n return getType(field._def.innerType)\n }\n\n switch (field._def.typeName) {\n case 'ZodArray':\n return 'array'\n case 'ZodObject':\n return 'object'\n case 'ZodNumber':\n return 'number'\n case 'ZodDate':\n return 'date'\n case 'ZodNativeEnum':\n case 'ZodEnum':\n return 'select'\n case 'ZodString':\n default:\n return 'text'\n }\n}\n\nconst getArrayOption = (field: any, name: string) => {\n return field._def[name]?.value\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: z.ZodTypeAny): FieldProps[] => {\n const fields: FieldProps[] = []\n\n let schemaFields: Record<string, any> = {}\n if (schema._def.typeName === 'ZodArray') {\n schemaFields = schema._def.type.shape\n } else if (schema._def.typeName === 'ZodObject') {\n schemaFields = schema._def.shape()\n } else {\n return fields\n }\n\n for (const name in schemaFields) {\n const field = schemaFields[name]\n\n const def =\n field._def.typeName === 'ZodDefault'\n ? field._def.innerType._def\n : field._def\n\n const props: ExtraProps = {}\n if (def.typeName === 'ZodArray') {\n props.min = getArrayOption(field, 'minLength')\n props.max = getArrayOption(field, 'maxLength')\n } else if (def.typeName === 'ZodEnum') {\n props.options = def.values.map((value: string) => {\n return { label: value, value }\n })\n } else if (def.typeName === 'ZodNativeEnum') {\n props.options = Object.entries(def.values).map(([label, value]) => ({ label, value: value as string }))\n }\n\n const meta = field.description && zodParseMeta(field.description)\n\n fields.push({\n name,\n label: meta?.label || field.description || name,\n type: meta?.type || getType(field),\n help: meta?.help,\n placeholder: meta?.placeholder,\n defaultValue: field._def.defaultValue?.(),\n ...props,\n })\n }\n return fields\n}\n\nexport const getNestedSchema = (schema: z.ZodTypeAny, path: string) => {\n return get(schema._def.shape(), path)\n}\n\nexport const zodFieldResolver = <T extends z.ZodTypeAny>(schema: T) => {\n return {\n getFields() {\n return getFieldsFromSchema(schema)\n },\n getNestedFields(name: string) {\n return getFieldsFromSchema(getNestedSchema(schema, name))\n },\n }\n}\n\nexport interface ZodMeta {\n /**\n * The label of the field\n */\n label: string\n\n /**\n * The type of the field\n */\n type?: string\n\n /**\n * The placeholder of the field\n */\n placeholder?: string\n\n /**\n * The help text of the field\n */\n help?: string\n\n /**\n * Object field column count\n */\n columns?: number\n\n /**\n * Array field min rows\n */\n min?: number\n\n /**\n * Array field max rows\n */\n max?: number\n\n [key: string]: any\n}\n\nexport const zodMeta = (meta: ZodMeta) => {\n return JSON.stringify(meta)\n}\n\nexport const zodParseMeta = (meta: string) => {\n try {\n return JSON.parse(meta)\n } catch (e) {\n return meta\n }\n}\n","import {\n createForm,\n CreateFormProps,\n WithFields,\n FormProps,\n GetBaseField,\n} from '@saas-ui/forms'\nimport { zodFieldResolver, zodResolver } from './zod-resolver'\nimport { z } from 'zod'\n\ntype ResolverArgs = Parameters<typeof zodResolver>\n\nexport interface CreateZodFormProps<\n FieldDefs,\n TGetBaseField extends GetBaseField = GetBaseField,\n> extends CreateFormProps<FieldDefs, TGetBaseField> {\n schemaOptions?: ResolverArgs[1]\n resolverOptions?: ResolverArgs[2]\n}\n\nexport type ZodFormType<\n FieldDefs,\n ExtraProps = object,\n ExtraFieldProps extends object = object,\n ExtraOverrides = object,\n Type extends 'zod' = 'zod',\n> = (<\n TSchema extends z.AnyZodObject = z.AnyZodObject,\n TFieldValues extends z.infer<TSchema> = z.infer<TSchema>,\n TContext extends object = object,\n>(\n props: WithFields<\n FormProps<TSchema, TFieldValues, TContext, ExtraFieldProps>,\n FieldDefs,\n ExtraOverrides\n > & {\n ref?: React.ForwardedRef<HTMLFormElement>\n } & ExtraProps\n) => React.ReactElement) & {\n displayName?: string\n id?: string\n}\n\nexport const createZodForm = <\n FieldDefs,\n TGetBaseField extends GetBaseField<any> = GetBaseField<any>,\n>(\n options?: CreateZodFormProps<FieldDefs, TGetBaseField>\n) => {\n type ExtraFieldProps =\n TGetBaseField extends GetBaseField<infer ExtraFieldProps>\n ? ExtraFieldProps\n : object\n\n const ZodForm = createForm({\n resolver: (schema: any) =>\n zodResolver(schema, options?.schemaOptions, options?.resolverOptions),\n fieldResolver: zodFieldResolver,\n ...options,\n })\n\n ZodForm.displayName = 'ZodForm'\n ZodForm.id = 'ZodForm'\n\n return ZodForm as ZodFormType<FieldDefs, object, ExtraFieldProps>\n}\n","import {\n createFormDialog,\n BaseModalProps,\n FormDialogFieldOverrides,\n} from '@saas-ui/modals'\nimport { ZodFormType } from './create-zod-form'\n\nexport function createZodFormDialog<\n FieldDefs = any,\n ExtraProps = object,\n ExtraFieldProps extends object = object,\n ExtraOverrides = object,\n>(Form: ZodFormType<FieldDefs, ExtraProps, ExtraFieldProps, ExtraOverrides>) {\n return createFormDialog(Form) as unknown as ZodFormType<\n FieldDefs,\n ExtraProps & Omit<BaseModalProps, 'children'>,\n ExtraFieldProps,\n ExtraOverrides & FormDialogFieldOverrides\n >\n}\n","import {\n CreateStepFormProps,\n createStepForm,\n StepsOptions,\n UseStepFormProps,\n WithStepFields,\n GetBaseField,\n} from '@saas-ui/forms'\nimport { zodFieldResolver, zodResolver } from './zod-resolver'\nimport { AnyZodObject, z } from 'zod'\nimport React from 'react'\n\ntype ResolverArgs = Parameters<typeof zodResolver>\n\nexport interface CreateZodStepFormProps<\n FieldDefs,\n TGetBaseField extends GetBaseField = GetBaseField,\n> extends CreateStepFormProps<FieldDefs, TGetBaseField> {\n schemaOptions?: ResolverArgs[1]\n resolverOptions?: ResolverArgs[2]\n}\n\ntype InferStepType<T extends Required<StepsOptions<AnyZodObject>>> = T extends [\n infer Step,\n ...infer Rest,\n]\n ? Step extends { schema: AnyZodObject }\n ? z.infer<Step['schema']> &\n (Rest extends Required<StepsOptions<AnyZodObject>>\n ? InferStepType<Rest>\n : object)\n : object\n : object\n\ntype ZodStepFormType<\n FieldDefs,\n ExtraProps = object,\n ExtraFieldProps extends object = object,\n ExtraOverrides = object,\n> = (<\n TSteps extends Required<StepsOptions<AnyZodObject>> = Required<\n StepsOptions<AnyZodObject>\n >,\n TFieldValues extends InferStepType<TSteps> = InferStepType<TSteps>,\n TContext extends object = object,\n>(\n props: WithStepFields<\n UseStepFormProps<TSteps, TFieldValues, TContext>,\n FieldDefs,\n ExtraOverrides\n > & {\n steps: TSteps\n ref?: React.ForwardedRef<HTMLFormElement>\n } & ExtraProps\n) => React.ReactElement) & {\n displayName?: string\n id?: string\n}\n\nexport const createZodStepForm = <\n FieldDefs,\n TGetBaseField extends GetBaseField = GetBaseField,\n>(\n options?: CreateZodStepFormProps<FieldDefs, TGetBaseField>\n) => {\n type ExtraFieldProps =\n TGetBaseField extends GetBaseField<infer ExtraFieldProps>\n ? ExtraFieldProps\n : object\n\n const ZodStepForm = createStepForm<any, any>({\n resolver: (schema: any) =>\n zodResolver(schema, options?.schemaOptions, options?.resolverOptions),\n fieldResolver: zodFieldResolver,\n ...options,\n })\n\n ZodStepForm.displayName = 'ZodStepForm'\n ZodStepForm.id = 'ZodStepForm'\n\n return ZodStepForm as ZodStepFormType<FieldDefs, object, ExtraFieldProps>\n}\n","export {\n zodResolver,\n getFieldsFromSchema,\n getNestedSchema,\n zodFieldResolver,\n zodMeta,\n zodParseMeta,\n} from './zod-resolver'\nexport type { ZodMeta } from './zod-resolver'\nexport { createZodForm, type ZodFormType } from './create-zod-form'\nexport { createZodFormDialog } from './create-zod-dialog'\nexport { createZodStepForm } from './create-zod-step-form'\n\nimport { createZodForm } from './create-zod-form'\nimport { createZodStepForm } from './create-zod-step-form'\nimport { createZodFormDialog } from './create-zod-dialog'\n\nexport const Form = createZodForm()\n\nexport const StepForm = createZodStepForm()\n\nexport const FormDialog = createZodFormDialog(Form)\n"],"mappings":";;;AACA,SAAS,mBAAmB;AAC5B,SAAS,WAAW;AAWpB,IAAM,UAAU,CACd,UAC+D;AAC/D,MAAI,CAAC,cAAc,aAAa,EAAE,SAAS,MAAM,KAAK,QAAQ,GAAG;AAC/D,WAAO,QAAQ,MAAM,KAAK,SAAS;AAAA,EACrC;AAEA,UAAQ,MAAM,KAAK,UAAU;AAAA,IAC3B,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AAAA,IACL;AACE,aAAO;AAAA,EACX;AACF;AAEA,IAAM,iBAAiB,CAAC,OAAY,SAAiB;AAtCrD;AAuCE,UAAO,WAAM,KAAK,IAAI,MAAf,mBAAkB;AAC3B;AAQO,IAAM,sBAAsB,CAAC,WAAuC;AAhD3E;AAiDE,QAAM,SAAuB,CAAC;AAE9B,MAAI,eAAoC,CAAC;AACzC,MAAI,OAAO,KAAK,aAAa,YAAY;AACvC,mBAAe,OAAO,KAAK,KAAK;AAAA,EAClC,WAAW,OAAO,KAAK,aAAa,aAAa;AAC/C,mBAAe,OAAO,KAAK,MAAM;AAAA,EACnC,OAAO;AACL,WAAO;AAAA,EACT;AAEA,aAAW,QAAQ,cAAc;AAC/B,UAAM,QAAQ,aAAa,IAAI;AAE/B,UAAM,MACJ,MAAM,KAAK,aAAa,eACpB,MAAM,KAAK,UAAU,OACrB,MAAM;AAEZ,UAAM,QAAoB,CAAC;A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EACE;AAAA,OAKK;AAqCA,IAAM,gBAAgB,CAI3B,YACG;AAMH,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;;;ACjEA;AAAA,EACE;AAAA,OAGK;AAGA,SAAS,oBAKdA,OAA2E;AAC3E,SAAO,iBAAiBA,KAAI;AAM9B;;;ACnBA;AAAA,EAEE;AAAA,OAKK;AAoDA,IAAM,oBAAoB,CAI/B,YACG;AAMH,QAAM,cAAc,eAAyB;AAAA,IAC3C,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;;;AChEO,IAAM,OAAO,cAAc;AAE3B,IAAM,WAAW,kBAAkB;AAEnC,IAAM,aAAa,oBAAoB,IAAI;","names":["Form"]}
1
+ {"version":3,"sources":["../../zod/src/zod-resolver.ts","../../zod/src/create-zod-form.ts","../../zod/src/create-zod-step-form.ts","../../zod/src/index.ts"],"sourcesContent":["import * as z from 'zod'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { get } from '@chakra-ui/utils'\nimport { FieldProps } from '@saas-ui/forms'\n\nexport { zodResolver }\n\nexport type ExtraProps = {\n min?: number\n max?: number\n options?: { label: string; value: string }[]\n}\n\nconst getType = (\n field: z.ZodTypeAny\n): 'array' | 'object' | 'number' | 'date' | 'select' | 'text' => {\n if (['ZodDefault', 'ZodOptional'].includes(field._def.typeName)) {\n return getType(field._def.innerType)\n }\n\n switch (field._def.typeName) {\n case 'ZodArray':\n return 'array'\n case 'ZodObject':\n return 'object'\n case 'ZodNumber':\n return 'number'\n case 'ZodDate':\n return 'date'\n case 'ZodNativeEnum':\n case 'ZodEnum':\n return 'select'\n case 'ZodString':\n default:\n return 'text'\n }\n}\n\nconst getArrayOption = (field: any, name: string) => {\n return field._def[name]?.value\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: z.ZodTypeAny): FieldProps[] => {\n const fields: FieldProps[] = []\n\n let schemaFields: Record<string, any> = {}\n if (schema._def.typeName === 'ZodArray') {\n schemaFields = schema._def.type.shape\n } else if (schema._def.typeName === 'ZodObject') {\n schemaFields = schema._def.shape()\n } else {\n return fields\n }\n\n for (const name in schemaFields) {\n const field = schemaFields[name]\n\n const def =\n field._def.typeName === 'ZodDefault'\n ? field._def.innerType._def\n : field._def\n\n const props: ExtraProps = {}\n if (def.typeName === 'ZodArray') {\n props.min = getArrayOption(field, 'minLength')\n props.max = getArrayOption(field, 'maxLength')\n } else if (def.typeName === 'ZodEnum') {\n props.options = def.values.map((value: string) => {\n return { label: value, value }\n })\n } else if (def.typeName === 'ZodNativeEnum') {\n props.options = Object.entries(def.values).map(([label, value]) => ({\n label,\n value: value as string,\n }))\n }\n\n const meta = field.description && zodParseMeta(field.description)\n\n fields.push({\n name,\n label: meta?.label || field.description || name,\n type: meta?.type || getType(field),\n help: meta?.help,\n placeholder: meta?.placeholder,\n defaultValue: field._def.defaultValue?.(),\n ...props,\n })\n }\n return fields\n}\n\nexport const getNestedSchema = (schema: z.ZodTypeAny, path: string) => {\n return get(schema._def.shape(), path)\n}\n\nexport const zodFieldResolver = <T extends z.ZodTypeAny>(schema: T) => {\n return {\n getFields() {\n return getFieldsFromSchema(schema)\n },\n getNestedFields(name: string) {\n return getFieldsFromSchema(getNestedSchema(schema, name))\n },\n }\n}\n\nexport interface ZodMeta {\n /**\n * The label of the field\n */\n label: string\n\n /**\n * The type of the field\n */\n type?: string\n\n /**\n * The placeholder of the field\n */\n placeholder?: string\n\n /**\n * The help text of the field\n */\n help?: string\n\n /**\n * Object field column count\n */\n columns?: number\n\n /**\n * Array field min rows\n */\n min?: number\n\n /**\n * Array field max rows\n */\n max?: number\n\n [key: string]: any\n}\n\nexport const zodMeta = (meta: ZodMeta) => {\n return JSON.stringify(meta)\n}\n\nexport const zodParseMeta = (meta: string) => {\n try {\n return JSON.parse(meta)\n } catch (e) {\n return meta\n }\n}\n","import {\n createForm,\n CreateFormProps,\n WithFields,\n FormProps,\n GetBaseField,\n} from '@saas-ui/forms'\nimport { zodFieldResolver, zodResolver } from './zod-resolver'\nimport { z } from 'zod'\n\ntype ResolverArgs = Parameters<typeof zodResolver>\n\nexport interface CreateZodFormProps<\n FieldDefs,\n TGetBaseField extends GetBaseField = GetBaseField,\n> extends CreateFormProps<FieldDefs, TGetBaseField> {\n schemaOptions?: ResolverArgs[1]\n resolverOptions?: ResolverArgs[2]\n}\n\nexport type ZodFormType<\n FieldDefs,\n ExtraProps = object,\n ExtraFieldProps extends object = object,\n ExtraOverrides = object,\n Type extends 'zod' = 'zod',\n> = (<\n TSchema extends z.AnyZodObject = z.AnyZodObject,\n TFieldValues extends z.infer<TSchema> = z.infer<TSchema>,\n TContext extends object = object,\n>(\n props: WithFields<\n FormProps<TSchema, TFieldValues, TContext, ExtraFieldProps>,\n FieldDefs,\n ExtraOverrides\n > & {\n ref?: React.ForwardedRef<HTMLFormElement>\n } & ExtraProps\n) => React.ReactElement) & {\n displayName?: string\n id?: string\n}\n\nexport const createZodForm = <\n FieldDefs,\n TGetBaseField extends GetBaseField<any> = GetBaseField<any>,\n>(\n options?: CreateZodFormProps<FieldDefs, TGetBaseField>\n) => {\n type ExtraFieldProps =\n TGetBaseField extends GetBaseField<infer ExtraFieldProps>\n ? ExtraFieldProps\n : object\n\n const ZodForm = createForm({\n resolver: (schema: any) =>\n zodResolver(schema, options?.schemaOptions, options?.resolverOptions),\n fieldResolver: zodFieldResolver,\n ...options,\n })\n\n ZodForm.displayName = 'ZodForm'\n ZodForm.id = 'ZodForm'\n\n return ZodForm as ZodFormType<FieldDefs, object, ExtraFieldProps>\n}\n","import {\n CreateStepFormProps,\n createStepForm,\n StepsOptions,\n UseStepFormProps,\n WithStepFields,\n GetBaseField,\n} from '@saas-ui/forms'\nimport { zodFieldResolver, zodResolver } from './zod-resolver'\nimport { AnyZodObject, z } from 'zod'\nimport React from 'react'\n\ntype ResolverArgs = Parameters<typeof zodResolver>\n\nexport interface CreateZodStepFormProps<\n FieldDefs,\n TGetBaseField extends GetBaseField = GetBaseField,\n> extends CreateStepFormProps<FieldDefs, TGetBaseField> {\n schemaOptions?: ResolverArgs[1]\n resolverOptions?: ResolverArgs[2]\n}\n\ntype InferStepType<T extends Required<StepsOptions<AnyZodObject>>> = T extends [\n infer Step,\n ...infer Rest,\n]\n ? Step extends { schema: AnyZodObject }\n ? z.infer<Step['schema']> &\n (Rest extends Required<StepsOptions<AnyZodObject>>\n ? InferStepType<Rest>\n : object)\n : object\n : object\n\ntype ZodStepFormType<\n FieldDefs,\n ExtraProps = object,\n ExtraFieldProps extends object = object,\n ExtraOverrides = object,\n> = (<\n TSteps extends Required<StepsOptions<AnyZodObject>> = Required<\n StepsOptions<AnyZodObject>\n >,\n TFieldValues extends InferStepType<TSteps> = InferStepType<TSteps>,\n TContext extends object = object,\n>(\n props: WithStepFields<\n UseStepFormProps<TSteps, TFieldValues, TContext>,\n FieldDefs,\n ExtraOverrides\n > & {\n steps: TSteps\n ref?: React.ForwardedRef<HTMLFormElement>\n } & ExtraProps\n) => React.ReactElement) & {\n displayName?: string\n id?: string\n}\n\nexport const createZodStepForm = <\n FieldDefs,\n TGetBaseField extends GetBaseField = GetBaseField,\n>(\n options?: CreateZodStepFormProps<FieldDefs, TGetBaseField>\n) => {\n type ExtraFieldProps =\n TGetBaseField extends GetBaseField<infer ExtraFieldProps>\n ? ExtraFieldProps\n : object\n\n const ZodStepForm = createStepForm<any, any>({\n resolver: (schema: any) =>\n zodResolver(schema, options?.schemaOptions, options?.resolverOptions),\n fieldResolver: zodFieldResolver,\n ...options,\n })\n\n ZodStepForm.displayName = 'ZodStepForm'\n ZodStepForm.id = 'ZodStepForm'\n\n return ZodStepForm as ZodStepFormType<FieldDefs, object, ExtraFieldProps>\n}\n","export {\n zodResolver,\n getFieldsFromSchema,\n getNestedSchema,\n zodFieldResolver,\n zodMeta,\n zodParseMeta,\n} from './zod-resolver'\nexport type { ZodMeta } from './zod-resolver'\nexport { createZodForm, type ZodFormType } from './create-zod-form'\n\nexport { createZodStepForm } from './create-zod-step-form'\n\nimport { createZodForm } from './create-zod-form'\nimport { createZodStepForm } from './create-zod-step-form'\n\nexport const Form = createZodForm()\n\nexport const StepForm = createZodStepForm()\n"],"mappings":";;;AACA,SAAS,mBAAmB;AAC5B,SAAS,WAAW;AAWpB,IAAM,UAAU,CACd,UAC+D;AAC/D,MAAI,CAAC,cAAc,aAAa,EAAE,SAAS,MAAM,KAAK,QAAQ,GAAG;AAC/D,WAAO,QAAQ,MAAM,KAAK,SAAS;AAAA,EACrC;AAEA,UAAQ,MAAM,KAAK,UAAU;AAAA,IAC3B,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AAAA,IACL;AACE,aAAO;AAAA,EACX;AACF;AAEA,IAAM,iBAAiB,CAAC,OAAY,SAAiB;AAtCrD;AAuCE,UAAO,WAAM,KAAK,IAAI,MAAf,mBAAkB;AAC3B;AAQO,IAAM,sBAAsB,CAAC,WAAuC;AAhD3E;AAiDE,QAAM,SAAuB,CAAC;AAE9B,MAAI,eAAoC,CAAC;AACzC,MAAI,OAAO,KAAK,aAAa,YAAY;AACvC,mBAAe,OAAO,KAAK,KAAK;AAAA,EAClC,WAAW,OAAO,KAAK,aAAa,aAAa;AAC/C,mBAAe,OAAO,KAAK,MAAM;AAAA,EACnC,OAAO;AACL,WAAO;AAAA,EACT;AA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SAAO,KAAK,UAAU,IAAI;AAC5B;AAEO,IAAM,eAAe,CAAC,SAAiB;AAC5C,MAAI;AACF,WAAO,KAAK,MAAM,IAAI;AAAA,EACxB,SAAS,GAAG;AACV,WAAO;AAAA,EACT;AACF;;;AClKA;AAAA,EACE;AAAA,OAKK;AAqCA,IAAM,gBAAgB,CAI3B,YACG;AAMH,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;;;ACjEA;AAAA,EAEE;AAAA,OAKK;AAoDA,IAAM,oBAAoB,CAI/B,YACG;AAMH,QAAM,cAAc,eAAyB;AAAA,IAC3C,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;;;ACjEO,IAAM,OAAO,cAAc;AAE3B,IAAM,WAAW,kBAAkB;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saas-ui/forms",
3
- "version": "2.6.11",
3
+ "version": "2.7.1",
4
4
  "description": "Fully functional forms for Chakra UI.",
5
5
  "source": "src/index.ts",
6
6
  "exports": {
@@ -102,10 +102,10 @@
102
102
  },
103
103
  "dependencies": {
104
104
  "@chakra-ui/react-utils": "^2.0.12",
105
- "@chakra-ui/utils": "^2.0.15",
106
- "@hookform/resolvers": "^3.6.0",
107
- "@saas-ui/core": "2.5.6",
108
- "react-hook-form": "^7.52.0"
105
+ "@chakra-ui/utils": "^2.2.1",
106
+ "@hookform/resolvers": "^3.9.0",
107
+ "@saas-ui/core": "2.6.1",
108
+ "react-hook-form": "^7.53.0"
109
109
  },
110
110
  "peerDependencies": {
111
111
  "@chakra-ui/react": ">=2.4.9",
@@ -117,12 +117,12 @@
117
117
  },
118
118
  "devDependencies": {
119
119
  "@types/json-schema": "^7.0.15",
120
- "ajv": "^8.16.0",
120
+ "ajv": "^8.17.1",
121
121
  "ajv-errors": "^3.0.0",
122
122
  "json-schema-to-ts": "^2.12.0",
123
- "tsd": "^0.31.1",
124
- "tsup": "^8.1.0",
125
- "typescript": "^5.5.2",
123
+ "tsd": "^0.31.2",
124
+ "tsup": "^8.3.0",
125
+ "typescript": "^5.6.2",
126
126
  "yup": "^1.4.0",
127
127
  "zod": "^3.23.8"
128
128
  },