@form-instant/react-resolver-zod 1.5.1 → 1.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ export * from './default-values';
2
+ export * from './field-config';
3
+ export * from './field-type-inference';
4
+ export * from './schema-parser';
5
+ export * from './types';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './context';
2
2
  export * from './element';
3
+ export * from './funcs';
3
4
  export * from './provider';
4
5
  export * from './type';
5
6
  export * from './useSchema';
@@ -36,7 +36,39 @@ function getDefaultValueInZodStack(schema) {
36
36
  }
37
37
  return undefined;
38
38
  }
39
+ function getDefaultValues(schema) {
40
+ var objectSchema = schema instanceof zod.z.ZodEffects ? schema.innerType() : schema;
41
+ var shape = objectSchema.shape;
42
+ var defaultValues = {};
43
+ for (var _i = 0, _Object$entries = Object.entries(shape); _i < _Object$entries.length; _i++) {
44
+ var _Object$entries$_i = _Object$entries[_i],
45
+ key = _Object$entries$_i[0],
46
+ field = _Object$entries$_i[1];
47
+ var defaultValue = getDefaultValueInZodStack(field);
48
+ if (defaultValue !== undefined) {
49
+ defaultValues[key] = defaultValue;
50
+ }
51
+ }
52
+ return defaultValues;
53
+ }
39
54
 
55
+ var FIELD_CONFIG_SYMBOL = /*#__PURE__*/Symbol('GetFieldConfig');
56
+ var extendZodWithFieldConfig = function extendZodWithFieldConfig(zod) {
57
+ zod.ZodType.prototype.fieldConfig = function (config) {
58
+ this._def.fieldConfig = config;
59
+ return this;
60
+ };
61
+ };
62
+ var createZodSchemaFieldConfig = function createZodSchemaFieldConfig() {
63
+ return function (config) {
64
+ var refinementFunction = function refinementFunction() {
65
+ // Do nothing.
66
+ };
67
+ // @ts-expect-error This is a symbol and not a real value.
68
+ refinementFunction[FIELD_CONFIG_SYMBOL] = config;
69
+ return refinementFunction;
70
+ };
71
+ };
40
72
  function getFieldConfigInZodStack(schema) {
41
73
  // Verifica si el esquema tiene fieldConfig directamente
42
74
  if (schema._def.fieldConfig) {
@@ -228,9 +260,17 @@ var FormInstantProvider = /*#__PURE__*/react.memo(function (_ref) {
228
260
  });
229
261
  });
230
262
 
263
+ exports.FIELD_CONFIG_SYMBOL = FIELD_CONFIG_SYMBOL;
231
264
  exports.FormInstantElement = FormInstantElement;
232
265
  exports.FormInstantProvider = FormInstantProvider;
233
266
  exports.ZodResolverContext = ZodResolverContext;
267
+ exports.createZodSchemaFieldConfig = createZodSchemaFieldConfig;
268
+ exports.extendZodWithFieldConfig = extendZodWithFieldConfig;
269
+ exports.getDefaultValueInZodStack = getDefaultValueInZodStack;
270
+ exports.getDefaultValues = getDefaultValues;
271
+ exports.getFieldConfigInZodStack = getFieldConfigInZodStack;
272
+ exports.inferFieldType = inferFieldType;
273
+ exports.parseSchema = parseSchema;
234
274
  exports.useFields = useFields;
235
275
  exports.useSchema = useSchema;
236
276
  //# sourceMappingURL=react-resolver-zod.cjs.development.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"react-resolver-zod.cjs.development.js","sources":["../src/context.tsx","../src/funcs/default-values.ts","../src/funcs/field-config.ts","../src/funcs/field-type-inference.ts","../src/funcs/schema-parser.ts","../src/useSchema.tsx","../src/element.tsx","../src/provider.tsx"],"sourcesContent":["import { createContext } from 'use-context-selector';\nimport { zodResolverProps } from './type';\n\nexport const ZodResolverContext = createContext<zodResolverProps>({} as zodResolverProps);\n","import { z } from 'zod';\nimport { ZodObjectOrWrapped } from './types';\n\nexport function getDefaultValueInZodStack(schema: z.ZodTypeAny): any {\n if (schema instanceof z.ZodDefault) {\n return schema._def.defaultValue();\n }\n\n if (schema instanceof z.ZodEffects) {\n return getDefaultValueInZodStack(schema.innerType());\n }\n\n return undefined;\n}\n\nexport function getDefaultValues(schema: ZodObjectOrWrapped): Record<string, any> {\n const objectSchema = schema instanceof z.ZodEffects ? schema.innerType() : schema;\n const shape = objectSchema.shape;\n\n const defaultValues: Record<string, any> = {};\n\n for (const [key, field] of Object.entries(shape)) {\n const defaultValue = getDefaultValueInZodStack(field as z.ZodTypeAny);\n if (defaultValue !== undefined) {\n defaultValues[key] = defaultValue;\n }\n }\n\n return defaultValues;\n}\n","import { z } from 'zod';\nimport { FieldConfig, SuperRefineFunction } from './types';\nexport const FIELD_CONFIG_SYMBOL = Symbol('GetFieldConfig');\n\ndeclare module 'zod' {\n interface ZodType {\n fieldConfig<AdditionalRenderable = null, FieldTypes = string>(\n config: FieldConfig<AdditionalRenderable, FieldTypes>,\n ): this;\n }\n}\n\nexport const extendZodWithFieldConfig = <AdditionalRenderable = null, FieldTypes = string>(\n zod: typeof z,\n) => {\n (zod.ZodType.prototype as any).fieldConfig = function (\n config: FieldConfig<AdditionalRenderable, FieldTypes>,\n ) {\n this._def.fieldConfig = config;\n return this;\n };\n};\n\nexport const createZodSchemaFieldConfig =\n <AdditionalRenderable = null, FieldTypes = string>() =>\n (config: FieldConfig<AdditionalRenderable, FieldTypes>): SuperRefineFunction => {\n const refinementFunction: SuperRefineFunction = () => {\n // Do nothing.\n };\n\n // @ts-expect-error This is a symbol and not a real value.\n refinementFunction[FIELD_CONFIG_SYMBOL] = config;\n\n return refinementFunction;\n };\n\nexport function getFieldConfigInZodStack(schema: z.ZodTypeAny): FieldConfig {\n // Verifica si el esquema tiene fieldConfig directamente\n if (schema._def.fieldConfig) {\n return schema._def.fieldConfig as FieldConfig;\n }\n\n // Si el esquema es un ZodEffects, busca en el innerType\n if ('innerType' in schema._def) {\n return getFieldConfigInZodStack(schema._def.innerType as z.ZodAny);\n }\n\n // Si el esquema es un ZodEffects con un schema interno, busca en el schema\n if ('schema' in schema._def) {\n return getFieldConfigInZodStack(schema._def.schema as z.ZodAny);\n }\n\n // Si no se encuentra fieldConfig, retorna un objeto vacío\n return {} as FieldConfig;\n}\n","import { z } from 'zod';\nimport { FieldConfig } from './types';\n\nexport function inferFieldType(schema: z.ZodTypeAny, fieldType?: FieldConfig['fieldType']): string {\n if (fieldType) {\n return fieldType;\n }\n\n const type = schema._def.typeName;\n\n const zodToInputType = new Map([\n ['ZodObject', 'object'],\n ['ZodString', 'string'],\n ['ZodNumber', 'number'],\n ['ZodBoolean', 'boolean'],\n ['ZodDate', 'date'],\n ['ZodEnum', 'select'],\n ['ZodNativeEnum', 'select'],\n ['ZodArray', 'array'],\n ]);\n\n const match = zodToInputType.get(type);\n\n return match || 'string'; // Default to string for unknown types\n}\n","import { ParsedField } from '@form-instant/react-input-mapping';\nimport { z } from 'zod';\nimport { getDefaultValueInZodStack } from './default-values';\nimport { getFieldConfigInZodStack } from './field-config';\nimport { inferFieldType } from './field-type-inference';\nimport { ParsedSchema, ZodObjectOrWrapped } from './types';\n\nconst typeMapping = {\n ZodDiscriminatedUnion(\n baseSchema: z.ZodTypeAny,\n name: string,\n history: string,\n dependecys: Record<string, any>,\n ) {\n const { optionsMap, discriminator, fieldConfig } = baseSchema._def;\n\n if (!Object.keys(dependecys).length) return [{}] as ParsedField<any, string>[];\n\n const optionKey = dependecys[discriminator];\n const option = optionsMap.get(optionKey);\n\n if (!option) return [{}] as ParsedField<any, string>[];\n\n const entries = Object.entries(option.shape);\n\n const fields = entries\n .filter(([key]) => key !== discriminator)\n .map(([key, field]) => {\n return parseField(\n key,\n field as z.ZodTypeAny,\n [history, name].join('.'),\n dependecys,\n );\n });\n\n fields.unshift({\n name: {\n current: discriminator,\n history: [history, name, discriminator].join('.'),\n },\n type: 'discriminator',\n required: true,\n default: optionKey,\n fieldConfig,\n options: Array.from(optionsMap.keys()).map((key) => [String(key), String(key)]),\n });\n\n return fields;\n },\n\n ZodObject(\n baseSchema: z.ZodTypeAny,\n name: string,\n history: string,\n dependecys: Record<string, any>,\n ) {\n return Object.entries((baseSchema as any).shape).map(([key, field]) =>\n parseField(key, field as z.ZodTypeAny, [history, name].join('.'), dependecys),\n );\n },\n\n ZodArray(\n baseSchema: z.ZodTypeAny,\n name: string,\n history: string,\n dependecys: Record<string, any>,\n ) {\n return [parseField('0', baseSchema._def.type, [history, name].join('.'), dependecys)];\n },\n};\n\nfunction parseField(\n name: string,\n schema: z.ZodTypeAny,\n history: string = '',\n dependecys: Record<string, any> = {},\n): ParsedField<any> {\n const baseSchema = getBaseSchema(schema);\n const { fieldType, ...fieldConfigBase } = getFieldConfigInZodStack(schema);\n const type = inferFieldType(baseSchema, fieldType);\n const defaultValue = getDefaultValueInZodStack(schema);\n\n let fieldConfig = fieldConfigBase;\n\n // Enums\n const options = baseSchema._def.values;\n let optionValues: [string, string][] = [];\n if (options) {\n if (!Array.isArray(options)) {\n optionValues = Object.entries(options);\n } else {\n optionValues = options.map((value) => [value, value]);\n }\n }\n\n // Arrays and objects\n const getSubSchema = typeMapping[baseSchema._def.typeName as keyof typeof typeMapping];\n\n const subSchema = getSubSchema?.(baseSchema, name, history, dependecys);\n\n if (baseSchema._def.typeName === 'ZodArray') {\n fieldConfig = {\n min: baseSchema._def.minLength?.value || 1,\n max: baseSchema._def.maxLength?.value,\n ...fieldConfig,\n };\n }\n\n const resp = {\n name: { current: name, history: [history, name].join('.') },\n type,\n required: !schema.isOptional(),\n default: defaultValue,\n fieldConfig,\n options: optionValues,\n schema: subSchema,\n description: baseSchema.description,\n };\n\n return resp;\n}\n\nfunction getBaseSchema<ChildType extends z.ZodAny | z.ZodTypeAny | z.AnyZodObject = z.ZodAny>(\n schema: ChildType | z.ZodEffects<ChildType>,\n): ChildType {\n if ('innerType' in schema._def) {\n return getBaseSchema(schema._def.innerType as ChildType);\n }\n if ('schema' in schema._def) {\n return getBaseSchema(schema._def.schema as ChildType);\n }\n\n return schema as ChildType;\n}\n\nexport const parseSchema = (S: ZodObjectOrWrapped): ParsedSchema => {\n const objectSchema = S instanceof z.ZodEffects ? S.innerType() : S;\n const shape = objectSchema.shape;\n\n const dependecys = (objectSchema._def as any).fieldConfig;\n\n const fields = Object.fromEntries(\n Object.entries(shape).map(([key, field]) => [\n key,\n parseField(key, field as z.ZodTypeAny, '', dependecys),\n ]),\n );\n\n return { fields };\n};\n","import { useMemo } from 'react';\nimport { useContext } from 'use-context-selector';\nimport { ZodEffects, ZodObject } from 'zod';\nimport { ZodResolverContext } from './context';\nimport { parseSchema } from './funcs/schema-parser';\n\nconst useSchemaBase = () =>\n useContext(ZodResolverContext) as ZodObject<never, never> | ZodEffects<never, never>;\n\nexport const useFields = <Sc extends Record<string, any>>(key: keyof Sc) => {\n const S = useSchemaBase();\n\n const { fields } = parseSchema(S);\n\n return fields[key as string];\n};\n\ntype Data =\n | Zod.AnyZodObject\n | Zod.ZodEffects<Zod.AnyZodObject>\n | Zod.ZodDiscriminatedUnion<any, any>;\n\ntype DP = Record<string, any>;\n\nexport const useSchema = (cbP: (dp: DP, preData?: Data) => Data, dp: DP) => {\n const schema = useMemo(() => cbP(dp).fieldConfig(dp), [dp]);\n\n return { schema };\n};\n","import { ElementMapping } from '@form-instant/react-input-mapping';\nimport { Fragment, useId } from 'react';\nimport { useFields } from './useSchema';\n\nexport interface ElementProps<Schema extends Record<string, any>> {\n name: keyof Schema;\n}\n\nexport const FormInstantElement = <S extends Record<string, any>>({ name }: ElementProps<S>) => {\n const field = useFields(name);\n\n const inputs = Object.values(field.schema || {});\n\n const id = useId();\n\n return (\n <>\n {inputs.map((props) => {\n return (\n <Fragment key={`${id}-${props.name?.history || ''}`}>\n <ElementMapping formProps={props} />\n </Fragment>\n );\n })}\n </>\n );\n};\n","import { FC, memo, ReactNode } from 'react';\nimport { ZodResolverContext } from './context';\nimport { zodResolverProps } from './type';\nexport const FormInstantProvider: FC<{\n schema: zodResolverProps;\n children: ReactNode;\n}> = memo(({ children, schema }) => {\n return <ZodResolverContext.Provider value={schema}>{children}</ZodResolverContext.Provider>;\n});\n"],"names":["ZodResolverContext","createContext","getDefaultValueInZodStack","schema","z","ZodDefault","_def","defaultValue","ZodEffects","innerType","undefined","getFieldConfigInZodStack","fieldConfig","inferFieldType","fieldType","type","typeName","zodToInputType","Map","match","get","typeMapping","ZodDiscriminatedUnion","baseSchema","name","history","dependecys","_baseSchema$_def","optionsMap","discriminator","Object","keys","length","optionKey","option","entries","shape","fields","filter","_ref","key","map","_ref2","field","parseField","join","unshift","current","required","options","Array","from","String","ZodObject","_ref3","ZodArray","getBaseSchema","_getFieldConfigInZodS","fieldConfigBase","_objectWithoutPropertiesLoose","_excluded","values","optionValues","isArray","value","getSubSchema","subSchema","_baseSchema$_def$minL","_baseSchema$_def$maxL","_extends","min","minLength","max","maxLength","resp","isOptional","description","parseSchema","S","objectSchema","fromEntries","_ref4","useSchemaBase","useContext","useFields","_parseSchema","useSchema","cbP","dp","useMemo","FormInstantElement","inputs","id","useId","_jsx","props","_props$name","Fragment","children","ElementMapping","formProps","FormInstantProvider","memo","Provider"],"mappings":";;;;;;;;IAGaA,kBAAkB,gBAAGC,gCAAa,CAAmB,EAAsB;;;;;;;;;;;;;;;;;;;;;ACAlF,SAAUC,yBAAyBA,CAACC,MAAoB,EAAA;AAC1D,EAAA,IAAIA,MAAM,YAAYC,KAAC,CAACC,UAAU,EAAE;AAChC,IAAA,OAAOF,MAAM,CAACG,IAAI,CAACC,YAAY,EAAE,CAAA;AACpC,GAAA;AAED,EAAA,IAAIJ,MAAM,YAAYC,KAAC,CAACI,UAAU,EAAE;AAChC,IAAA,OAAON,yBAAyB,CAACC,MAAM,CAACM,SAAS,EAAE,CAAC,CAAA;AACvD,GAAA;AAED,EAAA,OAAOC,SAAS,CAAA;AACpB;;ACuBM,SAAUC,wBAAwBA,CAACR,MAAoB,EAAA;AACzD;AACA,EAAA,IAAIA,MAAM,CAACG,IAAI,CAACM,WAAW,EAAE;AACzB,IAAA,OAAOT,MAAM,CAACG,IAAI,CAACM,WAA0B,CAAA;AAChD,GAAA;AAED;AACA,EAAA,IAAI,WAAW,IAAIT,MAAM,CAACG,IAAI,EAAE;AAC5B,IAAA,OAAOK,wBAAwB,CAACR,MAAM,CAACG,IAAI,CAACG,SAAqB,CAAC,CAAA;AACrE,GAAA;AAED;AACA,EAAA,IAAI,QAAQ,IAAIN,MAAM,CAACG,IAAI,EAAE;AACzB,IAAA,OAAOK,wBAAwB,CAACR,MAAM,CAACG,IAAI,CAACH,MAAk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,MAAM,CAAA;AACzB,EAAA,OAAO2F,cAAA,CAAC9F,kBAAkB,CAACuG,QAAQ,EAAA;AAACvC,IAAAA,KAAK,EAAE7D,MAAM;AAAA+F,IAAAA,QAAA,EAAGA,QAAAA;AAAQ,GAAA,CAA+B,CAAA;AAC/F,CAAC;;;;;;;;"}
1
+ {"version":3,"file":"react-resolver-zod.cjs.development.js","sources":["../src/context.tsx","../src/funcs/default-values.ts","../src/funcs/field-config.ts","../src/funcs/field-type-inference.ts","../src/funcs/schema-parser.ts","../src/useSchema.tsx","../src/element.tsx","../src/provider.tsx"],"sourcesContent":["import { createContext } from 'use-context-selector';\nimport { zodResolverProps } from './type';\n\nexport const ZodResolverContext = createContext<zodResolverProps>({} as zodResolverProps);\n","import { z } from 'zod';\nimport { ZodObjectOrWrapped } from './types';\n\nexport function getDefaultValueInZodStack(schema: z.ZodTypeAny): any {\n if (schema instanceof z.ZodDefault) {\n return schema._def.defaultValue();\n }\n\n if (schema instanceof z.ZodEffects) {\n return getDefaultValueInZodStack(schema.innerType());\n }\n\n return undefined;\n}\n\nexport function getDefaultValues(schema: ZodObjectOrWrapped): Record<string, any> {\n const objectSchema = schema instanceof z.ZodEffects ? schema.innerType() : schema;\n const shape = objectSchema.shape;\n\n const defaultValues: Record<string, any> = {};\n\n for (const [key, field] of Object.entries(shape)) {\n const defaultValue = getDefaultValueInZodStack(field as z.ZodTypeAny);\n if (defaultValue !== undefined) {\n defaultValues[key] = defaultValue;\n }\n }\n\n return defaultValues;\n}\n","import { z } from 'zod';\nimport { FieldConfig, SuperRefineFunction } from './types';\nexport const FIELD_CONFIG_SYMBOL = Symbol('GetFieldConfig');\n\ndeclare module 'zod' {\n interface ZodType {\n fieldConfig<AdditionalRenderable = null, FieldTypes = string>(\n config: FieldConfig<AdditionalRenderable, FieldTypes>,\n ): this;\n }\n}\n\nexport const extendZodWithFieldConfig = <AdditionalRenderable = null, FieldTypes = string>(\n zod: typeof z,\n) => {\n (zod.ZodType.prototype as any).fieldConfig = function (\n config: FieldConfig<AdditionalRenderable, FieldTypes>,\n ) {\n this._def.fieldConfig = config;\n return this;\n };\n};\n\nexport const createZodSchemaFieldConfig =\n <AdditionalRenderable = null, FieldTypes = string>() =>\n (config: FieldConfig<AdditionalRenderable, FieldTypes>): SuperRefineFunction => {\n const refinementFunction: SuperRefineFunction = () => {\n // Do nothing.\n };\n\n // @ts-expect-error This is a symbol and not a real value.\n refinementFunction[FIELD_CONFIG_SYMBOL] = config;\n\n return refinementFunction;\n };\n\nexport function getFieldConfigInZodStack(schema: z.ZodTypeAny): FieldConfig {\n // Verifica si el esquema tiene fieldConfig directamente\n if (schema._def.fieldConfig) {\n return schema._def.fieldConfig as FieldConfig;\n }\n\n // Si el esquema es un ZodEffects, busca en el innerType\n if ('innerType' in schema._def) {\n return getFieldConfigInZodStack(schema._def.innerType as z.ZodAny);\n }\n\n // Si el esquema es un ZodEffects con un schema interno, busca en el schema\n if ('schema' in schema._def) {\n return getFieldConfigInZodStack(schema._def.schema as z.ZodAny);\n }\n\n // Si no se encuentra fieldConfig, retorna un objeto vacío\n return {} as FieldConfig;\n}\n","import { z } from 'zod';\nimport { FieldConfig } from './types';\n\nexport function inferFieldType(schema: z.ZodTypeAny, fieldType?: FieldConfig['fieldType']): string {\n if (fieldType) {\n return fieldType;\n }\n\n const type = schema._def.typeName;\n\n const zodToInputType = new Map([\n ['ZodObject', 'object'],\n ['ZodString', 'string'],\n ['ZodNumber', 'number'],\n ['ZodBoolean', 'boolean'],\n ['ZodDate', 'date'],\n ['ZodEnum', 'select'],\n ['ZodNativeEnum', 'select'],\n ['ZodArray', 'array'],\n ]);\n\n const match = zodToInputType.get(type);\n\n return match || 'string'; // Default to string for unknown types\n}\n","import { ParsedField } from '@form-instant/react-input-mapping';\nimport { z } from 'zod';\nimport { getDefaultValueInZodStack } from './default-values';\nimport { getFieldConfigInZodStack } from './field-config';\nimport { inferFieldType } from './field-type-inference';\nimport { ParsedSchema, ZodObjectOrWrapped } from './types';\n\nconst typeMapping = {\n ZodDiscriminatedUnion(\n baseSchema: z.ZodTypeAny,\n name: string,\n history: string,\n dependecys: Record<string, any>,\n ) {\n const { optionsMap, discriminator, fieldConfig } = baseSchema._def;\n\n if (!Object.keys(dependecys).length) return [{}] as ParsedField<any, string>[];\n\n const optionKey = dependecys[discriminator];\n const option = optionsMap.get(optionKey);\n\n if (!option) return [{}] as ParsedField<any, string>[];\n\n const entries = Object.entries(option.shape);\n\n const fields = entries\n .filter(([key]) => key !== discriminator)\n .map(([key, field]) => {\n return parseField(\n key,\n field as z.ZodTypeAny,\n [history, name].join('.'),\n dependecys,\n );\n });\n\n fields.unshift({\n name: {\n current: discriminator,\n history: [history, name, discriminator].join('.'),\n },\n type: 'discriminator',\n required: true,\n default: optionKey,\n fieldConfig,\n options: Array.from(optionsMap.keys()).map((key) => [String(key), String(key)]),\n });\n\n return fields;\n },\n\n ZodObject(\n baseSchema: z.ZodTypeAny,\n name: string,\n history: string,\n dependecys: Record<string, any>,\n ) {\n return Object.entries((baseSchema as any).shape).map(([key, field]) =>\n parseField(key, field as z.ZodTypeAny, [history, name].join('.'), dependecys),\n );\n },\n\n ZodArray(\n baseSchema: z.ZodTypeAny,\n name: string,\n history: string,\n dependecys: Record<string, any>,\n ) {\n return [parseField('0', baseSchema._def.type, [history, name].join('.'), dependecys)];\n },\n};\n\nfunction parseField(\n name: string,\n schema: z.ZodTypeAny,\n history: string = '',\n dependecys: Record<string, any> = {},\n): ParsedField<any> {\n const baseSchema = getBaseSchema(schema);\n const { fieldType, ...fieldConfigBase } = getFieldConfigInZodStack(schema);\n const type = inferFieldType(baseSchema, fieldType);\n const defaultValue = getDefaultValueInZodStack(schema);\n\n let fieldConfig = fieldConfigBase;\n\n // Enums\n const options = baseSchema._def.values;\n let optionValues: [string, string][] = [];\n if (options) {\n if (!Array.isArray(options)) {\n optionValues = Object.entries(options);\n } else {\n optionValues = options.map((value) => [value, value]);\n }\n }\n\n // Arrays and objects\n const getSubSchema = typeMapping[baseSchema._def.typeName as keyof typeof typeMapping];\n\n const subSchema = getSubSchema?.(baseSchema, name, history, dependecys);\n\n if (baseSchema._def.typeName === 'ZodArray') {\n fieldConfig = {\n min: baseSchema._def.minLength?.value || 1,\n max: baseSchema._def.maxLength?.value,\n ...fieldConfig,\n };\n }\n\n const resp = {\n name: { current: name, history: [history, name].join('.') },\n type,\n required: !schema.isOptional(),\n default: defaultValue,\n fieldConfig,\n options: optionValues,\n schema: subSchema,\n description: baseSchema.description,\n };\n\n return resp;\n}\n\nfunction getBaseSchema<ChildType extends z.ZodAny | z.ZodTypeAny | z.AnyZodObject = z.ZodAny>(\n schema: ChildType | z.ZodEffects<ChildType>,\n): ChildType {\n if ('innerType' in schema._def) {\n return getBaseSchema(schema._def.innerType as ChildType);\n }\n if ('schema' in schema._def) {\n return getBaseSchema(schema._def.schema as ChildType);\n }\n\n return schema as ChildType;\n}\n\nexport const parseSchema = (S: ZodObjectOrWrapped): ParsedSchema => {\n const objectSchema = S instanceof z.ZodEffects ? S.innerType() : S;\n const shape = objectSchema.shape;\n\n const dependecys = (objectSchema._def as any).fieldConfig;\n\n const fields = Object.fromEntries(\n Object.entries(shape).map(([key, field]) => [\n key,\n parseField(key, field as z.ZodTypeAny, '', dependecys),\n ]),\n );\n\n return { fields };\n};\n","import { useMemo } from 'react';\nimport { useContext } from 'use-context-selector';\nimport { ZodEffects, ZodObject } from 'zod';\nimport { ZodResolverContext } from './context';\nimport { parseSchema } from './funcs/schema-parser';\n\nconst useSchemaBase = () =>\n useContext(ZodResolverContext) as ZodObject<never, never> | ZodEffects<never, never>;\n\nexport const useFields = <Sc extends Record<string, any>>(key: keyof Sc) => {\n const S = useSchemaBase();\n\n const { fields } = parseSchema(S);\n\n return fields[key as string];\n};\n\ntype Data =\n | Zod.AnyZodObject\n | Zod.ZodEffects<Zod.AnyZodObject>\n | Zod.ZodDiscriminatedUnion<any, any>;\n\ntype DP = Record<string, any>;\n\nexport const useSchema = (cbP: (dp: DP, preData?: Data) => Data, dp: DP) => {\n const schema = useMemo(() => cbP(dp).fieldConfig(dp), [dp]);\n\n return { schema };\n};\n","import { ElementMapping } from '@form-instant/react-input-mapping';\nimport { Fragment, useId } from 'react';\nimport { useFields } from './useSchema';\n\nexport interface ElementProps<Schema extends Record<string, any>> {\n name: keyof Schema;\n}\n\nexport const FormInstantElement = <S extends Record<string, any>>({ name }: ElementProps<S>) => {\n const field = useFields(name);\n\n const inputs = Object.values(field.schema || {});\n\n const id = useId();\n\n return (\n <>\n {inputs.map((props) => {\n return (\n <Fragment key={`${id}-${props.name?.history || ''}`}>\n <ElementMapping formProps={props} />\n </Fragment>\n );\n })}\n </>\n );\n};\n","import { FC, memo, ReactNode } from 'react';\nimport { ZodResolverContext } from './context';\nimport { zodResolverProps } from './type';\nexport const FormInstantProvider: FC<{\n schema: zodResolverProps;\n children: ReactNode;\n}> = memo(({ children, schema }) => {\n return <ZodResolverContext.Provider value={schema}>{children}</ZodResolverContext.Provider>;\n});\n"],"names":["ZodResolverContext","createContext","getDefaultValueInZodStack","schema","z","ZodDefault","_def","defaultValue","ZodEffects","innerType","undefined","getDefaultValues","objectSchema","shape","defaultValues","_i","_Object$entries","Object","entries","length","_Object$entries$_i","key","field","FIELD_CONFIG_SYMBOL","Symbol","extendZodWithFieldConfig","zod","ZodType","prototype","fieldConfig","config","createZodSchemaFieldConfig","refinementFunction","getFieldConfigInZodStack","inferFieldType","fieldType","type","typeName","zodToInputType","Map","match","get","typeMapping","ZodDiscriminatedUnion","baseSchema","name","history","dependecys","_baseSchema$_def","optionsMap","discriminator","keys","optionKey","option","fields","filter","_ref","map","_ref2","parseField","join","unshift","current","required","options","Array","from","String","ZodObject","_ref3","ZodArray","getBaseSchema","_getFieldConfigInZodS","fieldConfigBase","_objectWithoutPropertiesLoose","_excluded","values","optionValues","isArray","value","getSubSchema","subSchema","_baseSchema$_def$minL","_baseSchema$_def$maxL","_extends","min","minLength","max","maxLength","resp","isOptional","description","parseSchema","S","fromEntries","_ref4","useSchemaBase","useContext","useFields","_parseSchema","useSchema","cbP","dp","useMemo","FormInstantElement","inputs","id","useId","_jsx","props","_props$name","Fragment","children","ElementMapping","formProps","FormInstantProvider","memo","Provider"],"mappings":";;;;;;;;IAGaA,kBAAkB,gBAAGC,gCAAa,CAAmB,EAAsB;;;;;;;;;;;;;;;;;;;;;ACAlF,SAAUC,yBAAyBA,CAACC,MAAoB,EAAA;AAC1D,EAAA,IAAIA,MAAM,YAAYC,KAAC,CAACC,UAAU,EAAE;AAChC,IAAA,OAAOF,MAAM,CAACG,IAAI,CAACC,YAAY,EAAE,CAAA;AACpC,GAAA;AAED,EAAA,IAAIJ,MAAM,YAAYC,KAAC,CAACI,UAAU,EAAE;AAChC,IAAA,OAAON,yBAAyB,CAACC,MAAM,CAACM,SAAS,EAAE,CAAC,CAAA;AACvD,GAAA;AAED,EAAA,OAAOC,SAAS,CAAA;AACpB,CAAA;AAEM,SAAUC,gBAAgBA,CAACR,MAA0B,EAAA;AACvD,EAAA,IAAMS,YAAY,GAAGT,MAAM,YAAYC,KAAC,CAACI,UAAU,GAAGL,MAAM,CAACM,SAAS,EAAE,GAAGN,MAAM,CAAA;AACjF,EAAA,IAAMU,KAAK,GAAGD,YAAY,CAACC,KAAK,CAAA;EAEhC,IAAMC,aAAa,GAAwB,EAAE,CAAA;AAE7C,EAAA,KAAA,IAAAC,EAAA,GAAAC,CAAAA,EAAAA,eAAA,GAA2BC,MAAM,CAACC,OAAO,CAACL,KAAK,CAAC,EAAAE,EAAA,GAAAC,eAAA,CAAAG,MAAA,EAAAJ,EAAA,EAAE,EAAA;AAA7C,IAAA,IAAAK,kBAAA,GAAAJ,eAAA,CAAAD,EAAA,CAAA;AAAOM,MAAAA,GAAG,GAAAD,kBAAA,CAAA,CAAA,CAAA;AAAEE,MAAAA,KAAK,GAAAF,kBAAA,CAAA,CAAA,CAAA,CAAA;AAClB,IAAA,IAAMb,YAAY,GAAGL,yBAAyB,CAACoB,KAAqB,CAAC,CAAA;IACr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GAAAqD,IAAA,CAANrD,MAAM,CAAA;AACzB,EAAA,OAAOyG,cAAA,CAAC5G,kBAAkB,CAACqH,QAAQ,EAAA;AAACtC,IAAAA,KAAK,EAAE5E,MAAM;AAAA6G,IAAAA,QAAA,EAAGA,QAAAA;AAAQ,GAAA,CAA+B,CAAA;AAC/F,CAAC;;;;;;;;;;;;;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("use-context-selector"),n=require("react/jsx-runtime"),r=require("@form-instant/react-input-mapping"),t=require("react"),i=require("zod"),o=e.createContext({});function a(){return a=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)({}).hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},a.apply(null,arguments)}function u(e){return e instanceof i.z.ZodDefault?e._def.defaultValue():e instanceof i.z.ZodEffects?u(e.innerType()):void 0}function f(e){return e._def.fieldConfig?e._def.fieldConfig:"innerType"in e._def?f(e._def.innerType):"schema"in e._def?f(e._def.schema):{}}var s=["fieldType"],d={ZodDiscriminatedUnion:function(e,n,r,t){var i=e._def,o=i.optionsMap,a=i.discriminator,u=i.fieldConfig;if(!Object.keys(t).length)return[{}];var f=t[a],s=o.get(f);if(!s)return[{}];var d=Object.entries(s.shape).filter((function(e){return e[0]!==a})).map((function(e){return c(e[0],e[1],[r,n].join("."),t)}));return d.unshift({name:{current:a,history:[r,n,a].join(".")},type:"discriminator",required:!0,default:f,fieldConfig:u,options:Array.from(o.keys()).map((function(e){return[String(e),String(e)]}))}),d},ZodObject:function(e,n,r,t){return Object.entries(e.shape).map((function(e){return c(e[0],e[1],[r,n].join("."),t)}))},ZodArray:function(e,n,r,t){return[c("0",e._def.type,[r,n].join("."),t)]}};function c(e,n,r,t){void 0===r&&(r=""),void 0===t&&(t={});var i=l(n),o=f(n),c=o.fieldType,m=function(e,n){if(null==e)return{};var r={};for(var t in e)if({}.hasOwnProperty.call(e,t)){if(n.includes(t))continue;r[t]=e[t]}return r}(o,s),p=function(e,n){if(n)return n;var r=e._def.typeName;return new Map([["ZodObject","object"],["ZodString","string"],["ZodNumber","number"],["ZodBoolean","boolean"],["ZodDate","date"],["ZodEnum","select"],["ZodNativeEnum","select"],["ZodArray","array"]]).get(r)||"string"}(i,c),v=u(n),y=m,h=i._def.values,g=[];h&&(g=Array.isArray(h)?h.map((function(e){return[e,e]})):Object.entries(h));var j,_,b=d[i._def.typeName],x=null==b?void 0:b(i,e,r,t);return"ZodArray"===i._def.typeName&&(y=a({min:(null==(j=i._def.minLength)?void 0:j.value)||1,max:null==(_=i._def.maxLength)?void 0:_.value},y)),{name:{current:e,history:[r,e].join(".")},type:p,required:!n.isOptional(),default:v,fieldConfig:y,options:g,schema:x,description:i.description}}function l(e){return"innerType"in e._def?l(e._def.innerType):"schema"in e._def?l(e._def.schema):e}var m=function(n){var r,t,a,u=(t=(r=e.useContext(o))instanceof i.z.ZodEffects?r.innerType():r,a=t._def.fieldConfig,{fields:Object.fromEntries(Object.entries(t.shape).map((function(e){var n=e[0];return[n,c(n,e[1],"",a)]})))});return u.fields[n]},p=t.memo((function(e){return n.jsx(o.Provider,{value:e.schema,children:e.children})}));exports.FormInstantElement=function(e){var i=m(e.name),o=Object.values(i.schema||{}),a=t.useId();return n.jsx(n.Fragment,{children:o.map((function(e){var i;return n.jsx(t.Fragment,{children:n.jsx(r.ElementMapping,{formProps:e})},a+"-"+((null==(i=e.name)?void 0:i.history)||""))}))})},exports.FormInstantProvider=p,exports.ZodResolverContext=o,exports.useFields=m,exports.useSchema=function(e,n){return{schema:t.useMemo((function(){return e(n).fieldConfig(n)}),[n])}};
1
+ "use strict";var e=require("use-context-selector"),n=require("react/jsx-runtime"),r=require("@form-instant/react-input-mapping"),t=require("react"),i=require("zod"),o=e.createContext({});function a(){return a=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)({}).hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},a.apply(null,arguments)}function f(e){return e instanceof i.z.ZodDefault?e._def.defaultValue():e instanceof i.z.ZodEffects?f(e.innerType()):void 0}var u=Symbol("GetFieldConfig");function s(e){return e._def.fieldConfig?e._def.fieldConfig:"innerType"in e._def?s(e._def.innerType):"schema"in e._def?s(e._def.schema):{}}function d(e,n){if(n)return n;var r=e._def.typeName;return new Map([["ZodObject","object"],["ZodString","string"],["ZodNumber","number"],["ZodBoolean","boolean"],["ZodDate","date"],["ZodEnum","select"],["ZodNativeEnum","select"],["ZodArray","array"]]).get(r)||"string"}var c=["fieldType"],l={ZodDiscriminatedUnion:function(e,n,r,t){var i=e._def,o=i.optionsMap,a=i.discriminator,f=i.fieldConfig;if(!Object.keys(t).length)return[{}];var u=t[a],s=o.get(u);if(!s)return[{}];var d=Object.entries(s.shape).filter((function(e){return e[0]!==a})).map((function(e){return p(e[0],e[1],[r,n].join("."),t)}));return d.unshift({name:{current:a,history:[r,n,a].join(".")},type:"discriminator",required:!0,default:u,fieldConfig:f,options:Array.from(o.keys()).map((function(e){return[String(e),String(e)]}))}),d},ZodObject:function(e,n,r,t){return Object.entries(e.shape).map((function(e){return p(e[0],e[1],[r,n].join("."),t)}))},ZodArray:function(e,n,r,t){return[p("0",e._def.type,[r,n].join("."),t)]}};function p(e,n,r,t){void 0===r&&(r=""),void 0===t&&(t={});var i=m(n),o=s(n),u=o.fieldType,p=function(e,n){if(null==e)return{};var r={};for(var t in e)if({}.hasOwnProperty.call(e,t)){if(n.includes(t))continue;r[t]=e[t]}return r}(o,c),v=d(i,u),g=f(n),y=p,h=i._def.values,x=[];h&&(x=Array.isArray(h)?h.map((function(e){return[e,e]})):Object.entries(h));var j,_,Z=l[i._def.typeName],b=null==Z?void 0:Z(i,e,r,t);return"ZodArray"===i._def.typeName&&(y=a({min:(null==(j=i._def.minLength)?void 0:j.value)||1,max:null==(_=i._def.maxLength)?void 0:_.value},y)),{name:{current:e,history:[r,e].join(".")},type:v,required:!n.isOptional(),default:g,fieldConfig:y,options:x,schema:b,description:i.description}}function m(e){return"innerType"in e._def?m(e._def.innerType):"schema"in e._def?m(e._def.schema):e}var v=function(e){var n=e instanceof i.z.ZodEffects?e.innerType():e,r=n._def.fieldConfig;return{fields:Object.fromEntries(Object.entries(n.shape).map((function(e){var n=e[0];return[n,p(n,e[1],"",r)]})))}},g=function(n){var r=e.useContext(o);return v(r).fields[n]},y=t.memo((function(e){return n.jsx(o.Provider,{value:e.schema,children:e.children})}));exports.FIELD_CONFIG_SYMBOL=u,exports.FormInstantElement=function(e){var i=g(e.name),o=Object.values(i.schema||{}),a=t.useId();return n.jsx(n.Fragment,{children:o.map((function(e){var i;return n.jsx(t.Fragment,{children:n.jsx(r.ElementMapping,{formProps:e})},a+"-"+((null==(i=e.name)?void 0:i.history)||""))}))})},exports.FormInstantProvider=y,exports.ZodResolverContext=o,exports.createZodSchemaFieldConfig=function(){return function(e){var n=function(){};return n[u]=e,n}},exports.extendZodWithFieldConfig=function(e){e.ZodType.prototype.fieldConfig=function(e){return this._def.fieldConfig=e,this}},exports.getDefaultValueInZodStack=f,exports.getDefaultValues=function(e){for(var n=e instanceof i.z.ZodEffects?e.innerType():e,r={},t=0,o=Object.entries(n.shape);t<o.length;t++){var a=o[t],u=a[0],s=f(a[1]);void 0!==s&&(r[u]=s)}return r},exports.getFieldConfigInZodStack=s,exports.inferFieldType=d,exports.parseSchema=v,exports.useFields=g,exports.useSchema=function(e,n){return{schema:t.useMemo((function(){return e(n).fieldConfig(n)}),[n])}};
2
2
  //# sourceMappingURL=react-resolver-zod.cjs.production.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"react-resolver-zod.cjs.production.min.js","sources":["../src/context.tsx","../src/funcs/default-values.ts","../src/funcs/field-config.ts","../src/funcs/schema-parser.ts","../src/funcs/field-type-inference.ts","../src/useSchema.tsx","../src/provider.tsx","../src/element.tsx"],"sourcesContent":["import { createContext } from 'use-context-selector';\nimport { zodResolverProps } from './type';\n\nexport const ZodResolverContext = createContext<zodResolverProps>({} as zodResolverProps);\n","import { z } from 'zod';\nimport { ZodObjectOrWrapped } from './types';\n\nexport function getDefaultValueInZodStack(schema: z.ZodTypeAny): any {\n if (schema instanceof z.ZodDefault) {\n return schema._def.defaultValue();\n }\n\n if (schema instanceof z.ZodEffects) {\n return getDefaultValueInZodStack(schema.innerType());\n }\n\n return undefined;\n}\n\nexport function getDefaultValues(schema: ZodObjectOrWrapped): Record<string, any> {\n const objectSchema = schema instanceof z.ZodEffects ? schema.innerType() : schema;\n const shape = objectSchema.shape;\n\n const defaultValues: Record<string, any> = {};\n\n for (const [key, field] of Object.entries(shape)) {\n const defaultValue = getDefaultValueInZodStack(field as z.ZodTypeAny);\n if (defaultValue !== undefined) {\n defaultValues[key] = defaultValue;\n }\n }\n\n return defaultValues;\n}\n","import { z } from 'zod';\nimport { FieldConfig, SuperRefineFunction } from './types';\nexport const FIELD_CONFIG_SYMBOL = Symbol('GetFieldConfig');\n\ndeclare module 'zod' {\n interface ZodType {\n fieldConfig<AdditionalRenderable = null, FieldTypes = string>(\n config: FieldConfig<AdditionalRenderable, FieldTypes>,\n ): this;\n }\n}\n\nexport const extendZodWithFieldConfig = <AdditionalRenderable = null, FieldTypes = string>(\n zod: typeof z,\n) => {\n (zod.ZodType.prototype as any).fieldConfig = function (\n config: FieldConfig<AdditionalRenderable, FieldTypes>,\n ) {\n this._def.fieldConfig = config;\n return this;\n };\n};\n\nexport const createZodSchemaFieldConfig =\n <AdditionalRenderable = null, FieldTypes = string>() =>\n (config: FieldConfig<AdditionalRenderable, FieldTypes>): SuperRefineFunction => {\n const refinementFunction: SuperRefineFunction = () => {\n // Do nothing.\n };\n\n // @ts-expect-error This is a symbol and not a real value.\n refinementFunction[FIELD_CONFIG_SYMBOL] = config;\n\n return refinementFunction;\n };\n\nexport function getFieldConfigInZodStack(schema: z.ZodTypeAny): FieldConfig {\n // Verifica si el esquema tiene fieldConfig directamente\n if (schema._def.fieldConfig) {\n return schema._def.fieldConfig as FieldConfig;\n }\n\n // Si el esquema es un ZodEffects, busca en el innerType\n if ('innerType' in schema._def) {\n return getFieldConfigInZodStack(schema._def.innerType as z.ZodAny);\n }\n\n // Si el esquema es un ZodEffects con un schema interno, busca en el schema\n if ('schema' in schema._def) {\n return getFieldConfigInZodStack(schema._def.schema as z.ZodAny);\n }\n\n // Si no se encuentra fieldConfig, retorna un objeto vacío\n return {} as FieldConfig;\n}\n","import { ParsedField } from '@form-instant/react-input-mapping';\nimport { z } from 'zod';\nimport { getDefaultValueInZodStack } from './default-values';\nimport { getFieldConfigInZodStack } from './field-config';\nimport { inferFieldType } from './field-type-inference';\nimport { ParsedSchema, ZodObjectOrWrapped } from './types';\n\nconst typeMapping = {\n ZodDiscriminatedUnion(\n baseSchema: z.ZodTypeAny,\n name: string,\n history: string,\n dependecys: Record<string, any>,\n ) {\n const { optionsMap, discriminator, fieldConfig } = baseSchema._def;\n\n if (!Object.keys(dependecys).length) return [{}] as ParsedField<any, string>[];\n\n const optionKey = dependecys[discriminator];\n const option = optionsMap.get(optionKey);\n\n if (!option) return [{}] as ParsedField<any, string>[];\n\n const entries = Object.entries(option.shape);\n\n const fields = entries\n .filter(([key]) => key !== discriminator)\n .map(([key, field]) => {\n return parseField(\n key,\n field as z.ZodTypeAny,\n [history, name].join('.'),\n dependecys,\n );\n });\n\n fields.unshift({\n name: {\n current: discriminator,\n history: [history, name, discriminator].join('.'),\n },\n type: 'discriminator',\n required: true,\n default: optionKey,\n fieldConfig,\n options: Array.from(optionsMap.keys()).map((key) => [String(key), String(key)]),\n });\n\n return fields;\n },\n\n ZodObject(\n baseSchema: z.ZodTypeAny,\n name: string,\n history: string,\n dependecys: Record<string, any>,\n ) {\n return Object.entries((baseSchema as any).shape).map(([key, field]) =>\n parseField(key, field as z.ZodTypeAny, [history, name].join('.'), dependecys),\n );\n },\n\n ZodArray(\n baseSchema: z.ZodTypeAny,\n name: string,\n history: string,\n dependecys: Record<string, any>,\n ) {\n return [parseField('0', baseSchema._def.type, [history, name].join('.'), dependecys)];\n },\n};\n\nfunction parseField(\n name: string,\n schema: z.ZodTypeAny,\n history: string = '',\n dependecys: Record<string, any> = {},\n): ParsedField<any> {\n const baseSchema = getBaseSchema(schema);\n const { fieldType, ...fieldConfigBase } = getFieldConfigInZodStack(schema);\n const type = inferFieldType(baseSchema, fieldType);\n const defaultValue = getDefaultValueInZodStack(schema);\n\n let fieldConfig = fieldConfigBase;\n\n // Enums\n const options = baseSchema._def.values;\n let optionValues: [string, string][] = [];\n if (options) {\n if (!Array.isArray(options)) {\n optionValues = Object.entries(options);\n } else {\n optionValues = options.map((value) => [value, value]);\n }\n }\n\n // Arrays and objects\n const getSubSchema = typeMapping[baseSchema._def.typeName as keyof typeof typeMapping];\n\n const subSchema = getSubSchema?.(baseSchema, name, history, dependecys);\n\n if (baseSchema._def.typeName === 'ZodArray') {\n fieldConfig = {\n min: baseSchema._def.minLength?.value || 1,\n max: baseSchema._def.maxLength?.value,\n ...fieldConfig,\n };\n }\n\n const resp = {\n name: { current: name, history: [history, name].join('.') },\n type,\n required: !schema.isOptional(),\n default: defaultValue,\n fieldConfig,\n options: optionValues,\n schema: subSchema,\n description: baseSchema.description,\n };\n\n return resp;\n}\n\nfunction getBaseSchema<ChildType extends z.ZodAny | z.ZodTypeAny | z.AnyZodObject = z.ZodAny>(\n schema: ChildType | z.ZodEffects<ChildType>,\n): ChildType {\n if ('innerType' in schema._def) {\n return getBaseSchema(schema._def.innerType as ChildType);\n }\n if ('schema' in schema._def) {\n return getBaseSchema(schema._def.schema as ChildType);\n }\n\n return schema as ChildType;\n}\n\nexport const parseSchema = (S: ZodObjectOrWrapped): ParsedSchema => {\n const objectSchema = S instanceof z.ZodEffects ? S.innerType() : S;\n const shape = objectSchema.shape;\n\n const dependecys = (objectSchema._def as any).fieldConfig;\n\n const fields = Object.fromEntries(\n Object.entries(shape).map(([key, field]) => [\n key,\n parseField(key, field as z.ZodTypeAny, '', dependecys),\n ]),\n );\n\n return { fields };\n};\n","import { z } from 'zod';\nimport { FieldConfig } from './types';\n\nexport function inferFieldType(schema: z.ZodTypeAny, fieldType?: FieldConfig['fieldType']): string {\n if (fieldType) {\n return fieldType;\n }\n\n const type = schema._def.typeName;\n\n const zodToInputType = new Map([\n ['ZodObject', 'object'],\n ['ZodString', 'string'],\n ['ZodNumber', 'number'],\n ['ZodBoolean', 'boolean'],\n ['ZodDate', 'date'],\n ['ZodEnum', 'select'],\n ['ZodNativeEnum', 'select'],\n ['ZodArray', 'array'],\n ]);\n\n const match = zodToInputType.get(type);\n\n return match || 'string'; // Default to string for unknown types\n}\n","import { useMemo } from 'react';\nimport { useContext } from 'use-context-selector';\nimport { ZodEffects, ZodObject } from 'zod';\nimport { ZodResolverContext } from './context';\nimport { parseSchema } from './funcs/schema-parser';\n\nconst useSchemaBase = () =>\n useContext(ZodResolverContext) as ZodObject<never, never> | ZodEffects<never, never>;\n\nexport const useFields = <Sc extends Record<string, any>>(key: keyof Sc) => {\n const S = useSchemaBase();\n\n const { fields } = parseSchema(S);\n\n return fields[key as string];\n};\n\ntype Data =\n | Zod.AnyZodObject\n | Zod.ZodEffects<Zod.AnyZodObject>\n | Zod.ZodDiscriminatedUnion<any, any>;\n\ntype DP = Record<string, any>;\n\nexport const useSchema = (cbP: (dp: DP, preData?: Data) => Data, dp: DP) => {\n const schema = useMemo(() => cbP(dp).fieldConfig(dp), [dp]);\n\n return { schema };\n};\n","import { FC, memo, ReactNode } from 'react';\nimport { ZodResolverContext } from './context';\nimport { zodResolverProps } from './type';\nexport const FormInstantProvider: FC<{\n schema: zodResolverProps;\n children: ReactNode;\n}> = memo(({ children, schema }) => {\n return <ZodResolverContext.Provider value={schema}>{children}</ZodResolverContext.Provider>;\n});\n","import { ElementMapping } from '@form-instant/react-input-mapping';\nimport { Fragment, useId } from 'react';\nimport { useFields } from './useSchema';\n\nexport interface ElementProps<Schema extends Record<string, any>> {\n name: keyof Schema;\n}\n\nexport const FormInstantElement = <S extends Record<string, any>>({ name }: ElementProps<S>) => {\n const field = useFields(name);\n\n const inputs = Object.values(field.schema || {});\n\n const id = useId();\n\n return (\n <>\n {inputs.map((props) => {\n return (\n <Fragment key={`${id}-${props.name?.history || ''}`}>\n <ElementMapping formProps={props} />\n </Fragment>\n );\n })}\n </>\n );\n};\n"],"names":["ZodResolverContext","createContext","getDefaultValueInZodStack","schema","z","ZodDefault","_def","defaultValue","ZodEffects","innerType","getFieldConfigInZodStack","fieldConfig","typeMapping","ZodDiscriminatedUnion","baseSchema","name","history","dependecys","_baseSchema$_def","optionsMap","discriminator","Object","keys","length","optionKey","option","get","fields","entries","shape","filter","_ref","map","_ref2","parseField","join","unshift","current","type","required","default","options","Array","from","key","String","ZodObject","_ref3","ZodArray","getBaseSchema","_getFieldConfigInZodS","fieldType","fieldConfigBase","_objectWithoutPropertiesLoose","_excluded","typeName","Map","inferFieldType","values","optionValues","isArray","value","_baseSchema$_def$minL","_baseSchema$_def$maxL","getSubSchema","subSchema","_extends","min","minLength","max","maxLength","isOptional","description","useFields","S","objectSchema","_parseSchema","useContext","fromEntries","_ref4","FormInstantProvider","memo","_jsx","jsx","Provider","children","field","inputs","id","useId","props","_props$name","Fragment","ElementMapping","formProps","cbP","dp","useMemo"],"mappings":"qKAGaA,EAAqBC,EAAaA,cAAmB,CAAsB,2NCAlF,SAAUC,EAA0BC,GACtC,OAAIA,aAAkBC,EAACA,EAACC,WACbF,EAAOG,KAAKC,eAGnBJ,aAAkBC,EAACA,EAACI,WACbN,EAA0BC,EAAOM,kBAD5C,CAKJ,CCuBM,SAAUC,EAAyBP,GAErC,OAAIA,EAAOG,KAAKK,YACLR,EAAOG,KAAKK,YAInB,cAAeR,EAAOG,KACfI,EAAyBP,EAAOG,KAAKG,WAI5C,WAAYN,EAAOG,KACZI,EAAyBP,EAAOG,KAAKH,QAIzC,EACX,qBC/CMS,EAAc,CAChBC,sBAAqB,SACjBC,EACAC,EACAC,EACAC,GAEA,IAAAC,EAAmDJ,EAAWR,KAAtDa,EAAUD,EAAVC,WAAYC,EAAaF,EAAbE,cAAeT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,EEhIN2D,GF6HMD,GADkBD,EEjIxBG,EAAAA,WAAW7E,cFkIuBI,EAACA,EAACI,WAAakE,EAAEjE,YAAciE,EAG3DzD,EAAc0D,EAAarE,KAAaK,YASvC,CAAEgB,OAPMN,OAAOyD,YAClBzD,OAAOO,QALG+C,EAAa9C,OAKDG,KAAI,SAAA+C,GAAA,IAAEnC,EAAGmC,EAAA,GAAO,MAAM,CACxCnC,EACAV,EAAWU,EAFuBmC,EAAA,GAEK,GAAI9D,GAC9C,OEpIL,OAFc2D,EAANjD,OAEMiB,EAClB,ECZaoC,EAGRC,EAAAA,MAAK,SAAAlD,GACN,OAAOmD,EAAAC,IAACnF,EAAmBoF,SAAQ,CAACvB,MADX9B,EAAN5B,OAC8BkF,SADhCtD,EAARsD,UAEb,+BCAkC,SAAHtD,GAAgE,IACrFuD,EAAQb,EADsD1C,EAAJhB,MAG1DwE,EAASlE,OAAOqC,OAAO4B,EAAMnF,QAAU,CAAA,GAEvCqF,EAAKC,EAAAA,QAEX,OACIP,EAAAA,yBACKK,EAAOvD,KAAI,SAAC0D,GAAS,IAAAC,EAClB,OACIT,EAAAA,IAACU,EAAAA,SACG,CAAAP,SAAAH,EAAAC,IAACU,iBAAe,CAAAC,UAAWJ,KADbF,EAAE,MAAc,OAAVG,EAAAD,EAAM3E,WAAI,EAAV4E,EAAY3E,UAAW,SAOnE,mGFFyB,SAAC+E,EAAuCC,GAG7D,MAAO,CAAE7F,OAFM8F,EAAAA,SAAQ,WAAA,OAAMF,EAAIC,GAAIrF,YAAYqF,KAAK,CAACA,IAG3D"}
1
+ {"version":3,"file":"react-resolver-zod.cjs.production.min.js","sources":["../src/context.tsx","../src/funcs/default-values.ts","../src/funcs/field-config.ts","../src/funcs/field-type-inference.ts","../src/funcs/schema-parser.ts","../src/useSchema.tsx","../src/provider.tsx","../src/element.tsx"],"sourcesContent":["import { createContext } from 'use-context-selector';\nimport { zodResolverProps } from './type';\n\nexport const ZodResolverContext = createContext<zodResolverProps>({} as zodResolverProps);\n","import { z } from 'zod';\nimport { ZodObjectOrWrapped } from './types';\n\nexport function getDefaultValueInZodStack(schema: z.ZodTypeAny): any {\n if (schema instanceof z.ZodDefault) {\n return schema._def.defaultValue();\n }\n\n if (schema instanceof z.ZodEffects) {\n return getDefaultValueInZodStack(schema.innerType());\n }\n\n return undefined;\n}\n\nexport function getDefaultValues(schema: ZodObjectOrWrapped): Record<string, any> {\n const objectSchema = schema instanceof z.ZodEffects ? schema.innerType() : schema;\n const shape = objectSchema.shape;\n\n const defaultValues: Record<string, any> = {};\n\n for (const [key, field] of Object.entries(shape)) {\n const defaultValue = getDefaultValueInZodStack(field as z.ZodTypeAny);\n if (defaultValue !== undefined) {\n defaultValues[key] = defaultValue;\n }\n }\n\n return defaultValues;\n}\n","import { z } from 'zod';\nimport { FieldConfig, SuperRefineFunction } from './types';\nexport const FIELD_CONFIG_SYMBOL = Symbol('GetFieldConfig');\n\ndeclare module 'zod' {\n interface ZodType {\n fieldConfig<AdditionalRenderable = null, FieldTypes = string>(\n config: FieldConfig<AdditionalRenderable, FieldTypes>,\n ): this;\n }\n}\n\nexport const extendZodWithFieldConfig = <AdditionalRenderable = null, FieldTypes = string>(\n zod: typeof z,\n) => {\n (zod.ZodType.prototype as any).fieldConfig = function (\n config: FieldConfig<AdditionalRenderable, FieldTypes>,\n ) {\n this._def.fieldConfig = config;\n return this;\n };\n};\n\nexport const createZodSchemaFieldConfig =\n <AdditionalRenderable = null, FieldTypes = string>() =>\n (config: FieldConfig<AdditionalRenderable, FieldTypes>): SuperRefineFunction => {\n const refinementFunction: SuperRefineFunction = () => {\n // Do nothing.\n };\n\n // @ts-expect-error This is a symbol and not a real value.\n refinementFunction[FIELD_CONFIG_SYMBOL] = config;\n\n return refinementFunction;\n };\n\nexport function getFieldConfigInZodStack(schema: z.ZodTypeAny): FieldConfig {\n // Verifica si el esquema tiene fieldConfig directamente\n if (schema._def.fieldConfig) {\n return schema._def.fieldConfig as FieldConfig;\n }\n\n // Si el esquema es un ZodEffects, busca en el innerType\n if ('innerType' in schema._def) {\n return getFieldConfigInZodStack(schema._def.innerType as z.ZodAny);\n }\n\n // Si el esquema es un ZodEffects con un schema interno, busca en el schema\n if ('schema' in schema._def) {\n return getFieldConfigInZodStack(schema._def.schema as z.ZodAny);\n }\n\n // Si no se encuentra fieldConfig, retorna un objeto vacío\n return {} as FieldConfig;\n}\n","import { z } from 'zod';\nimport { FieldConfig } from './types';\n\nexport function inferFieldType(schema: z.ZodTypeAny, fieldType?: FieldConfig['fieldType']): string {\n if (fieldType) {\n return fieldType;\n }\n\n const type = schema._def.typeName;\n\n const zodToInputType = new Map([\n ['ZodObject', 'object'],\n ['ZodString', 'string'],\n ['ZodNumber', 'number'],\n ['ZodBoolean', 'boolean'],\n ['ZodDate', 'date'],\n ['ZodEnum', 'select'],\n ['ZodNativeEnum', 'select'],\n ['ZodArray', 'array'],\n ]);\n\n const match = zodToInputType.get(type);\n\n return match || 'string'; // Default to string for unknown types\n}\n","import { ParsedField } from '@form-instant/react-input-mapping';\nimport { z } from 'zod';\nimport { getDefaultValueInZodStack } from './default-values';\nimport { getFieldConfigInZodStack } from './field-config';\nimport { inferFieldType } from './field-type-inference';\nimport { ParsedSchema, ZodObjectOrWrapped } from './types';\n\nconst typeMapping = {\n ZodDiscriminatedUnion(\n baseSchema: z.ZodTypeAny,\n name: string,\n history: string,\n dependecys: Record<string, any>,\n ) {\n const { optionsMap, discriminator, fieldConfig } = baseSchema._def;\n\n if (!Object.keys(dependecys).length) return [{}] as ParsedField<any, string>[];\n\n const optionKey = dependecys[discriminator];\n const option = optionsMap.get(optionKey);\n\n if (!option) return [{}] as ParsedField<any, string>[];\n\n const entries = Object.entries(option.shape);\n\n const fields = entries\n .filter(([key]) => key !== discriminator)\n .map(([key, field]) => {\n return parseField(\n key,\n field as z.ZodTypeAny,\n [history, name].join('.'),\n dependecys,\n );\n });\n\n fields.unshift({\n name: {\n current: discriminator,\n history: [history, name, discriminator].join('.'),\n },\n type: 'discriminator',\n required: true,\n default: optionKey,\n fieldConfig,\n options: Array.from(optionsMap.keys()).map((key) => [String(key), String(key)]),\n });\n\n return fields;\n },\n\n ZodObject(\n baseSchema: z.ZodTypeAny,\n name: string,\n history: string,\n dependecys: Record<string, any>,\n ) {\n return Object.entries((baseSchema as any).shape).map(([key, field]) =>\n parseField(key, field as z.ZodTypeAny, [history, name].join('.'), dependecys),\n );\n },\n\n ZodArray(\n baseSchema: z.ZodTypeAny,\n name: string,\n history: string,\n dependecys: Record<string, any>,\n ) {\n return [parseField('0', baseSchema._def.type, [history, name].join('.'), dependecys)];\n },\n};\n\nfunction parseField(\n name: string,\n schema: z.ZodTypeAny,\n history: string = '',\n dependecys: Record<string, any> = {},\n): ParsedField<any> {\n const baseSchema = getBaseSchema(schema);\n const { fieldType, ...fieldConfigBase } = getFieldConfigInZodStack(schema);\n const type = inferFieldType(baseSchema, fieldType);\n const defaultValue = getDefaultValueInZodStack(schema);\n\n let fieldConfig = fieldConfigBase;\n\n // Enums\n const options = baseSchema._def.values;\n let optionValues: [string, string][] = [];\n if (options) {\n if (!Array.isArray(options)) {\n optionValues = Object.entries(options);\n } else {\n optionValues = options.map((value) => [value, value]);\n }\n }\n\n // Arrays and objects\n const getSubSchema = typeMapping[baseSchema._def.typeName as keyof typeof typeMapping];\n\n const subSchema = getSubSchema?.(baseSchema, name, history, dependecys);\n\n if (baseSchema._def.typeName === 'ZodArray') {\n fieldConfig = {\n min: baseSchema._def.minLength?.value || 1,\n max: baseSchema._def.maxLength?.value,\n ...fieldConfig,\n };\n }\n\n const resp = {\n name: { current: name, history: [history, name].join('.') },\n type,\n required: !schema.isOptional(),\n default: defaultValue,\n fieldConfig,\n options: optionValues,\n schema: subSchema,\n description: baseSchema.description,\n };\n\n return resp;\n}\n\nfunction getBaseSchema<ChildType extends z.ZodAny | z.ZodTypeAny | z.AnyZodObject = z.ZodAny>(\n schema: ChildType | z.ZodEffects<ChildType>,\n): ChildType {\n if ('innerType' in schema._def) {\n return getBaseSchema(schema._def.innerType as ChildType);\n }\n if ('schema' in schema._def) {\n return getBaseSchema(schema._def.schema as ChildType);\n }\n\n return schema as ChildType;\n}\n\nexport const parseSchema = (S: ZodObjectOrWrapped): ParsedSchema => {\n const objectSchema = S instanceof z.ZodEffects ? S.innerType() : S;\n const shape = objectSchema.shape;\n\n const dependecys = (objectSchema._def as any).fieldConfig;\n\n const fields = Object.fromEntries(\n Object.entries(shape).map(([key, field]) => [\n key,\n parseField(key, field as z.ZodTypeAny, '', dependecys),\n ]),\n );\n\n return { fields };\n};\n","import { useMemo } from 'react';\nimport { useContext } from 'use-context-selector';\nimport { ZodEffects, ZodObject } from 'zod';\nimport { ZodResolverContext } from './context';\nimport { parseSchema } from './funcs/schema-parser';\n\nconst useSchemaBase = () =>\n useContext(ZodResolverContext) as ZodObject<never, never> | ZodEffects<never, never>;\n\nexport const useFields = <Sc extends Record<string, any>>(key: keyof Sc) => {\n const S = useSchemaBase();\n\n const { fields } = parseSchema(S);\n\n return fields[key as string];\n};\n\ntype Data =\n | Zod.AnyZodObject\n | Zod.ZodEffects<Zod.AnyZodObject>\n | Zod.ZodDiscriminatedUnion<any, any>;\n\ntype DP = Record<string, any>;\n\nexport const useSchema = (cbP: (dp: DP, preData?: Data) => Data, dp: DP) => {\n const schema = useMemo(() => cbP(dp).fieldConfig(dp), [dp]);\n\n return { schema };\n};\n","import { FC, memo, ReactNode } from 'react';\nimport { ZodResolverContext } from './context';\nimport { zodResolverProps } from './type';\nexport const FormInstantProvider: FC<{\n schema: zodResolverProps;\n children: ReactNode;\n}> = memo(({ children, schema }) => {\n return <ZodResolverContext.Provider value={schema}>{children}</ZodResolverContext.Provider>;\n});\n","import { ElementMapping } from '@form-instant/react-input-mapping';\nimport { Fragment, useId } from 'react';\nimport { useFields } from './useSchema';\n\nexport interface ElementProps<Schema extends Record<string, any>> {\n name: keyof Schema;\n}\n\nexport const FormInstantElement = <S extends Record<string, any>>({ name }: ElementProps<S>) => {\n const field = useFields(name);\n\n const inputs = Object.values(field.schema || {});\n\n const id = useId();\n\n return (\n <>\n {inputs.map((props) => {\n return (\n <Fragment key={`${id}-${props.name?.history || ''}`}>\n <ElementMapping formProps={props} />\n </Fragment>\n );\n })}\n </>\n );\n};\n"],"names":["ZodResolverContext","createContext","getDefaultValueInZodStack","schema","z","ZodDefault","_def","defaultValue","ZodEffects","innerType","FIELD_CONFIG_SYMBOL","Symbol","getFieldConfigInZodStack","fieldConfig","inferFieldType","fieldType","type","typeName","Map","get","typeMapping","ZodDiscriminatedUnion","baseSchema","name","history","dependecys","_baseSchema$_def","optionsMap","discriminator","Object","keys","length","optionKey","option","fields","entries","shape","filter","_ref","map","_ref2","parseField","join","unshift","current","required","default","options","Array","from","key","String","ZodObject","_ref3","ZodArray","getBaseSchema","_getFieldConfigInZodS","fieldConfigBase","_objectWithoutPropertiesLoose","_excluded","values","optionValues","isArray","value","_baseSchema$_def$minL","_baseSchema$_def$maxL","getSubSchema","subSchema","_extends","min","minLength","max","maxLength","isOptional","description","parseSchema","S","objectSchema","fromEntries","_ref4","useFields","useContext","FormInstantProvider","memo","_jsx","jsx","Provider","children","field","inputs","id","useId","props","_props$name","Fragment","ElementMapping","formProps","config","refinementFunction","zod","ZodType","prototype","this","defaultValues","_i","_Object$entries","_Object$entries$_i","undefined","cbP","dp","useMemo"],"mappings":"qKAGaA,EAAqBC,EAAaA,cAAmB,CAAsB,2NCAlF,SAAUC,EAA0BC,GACtC,OAAIA,aAAkBC,EAACA,EAACC,WACbF,EAAOG,KAAKC,eAGnBJ,aAAkBC,EAACA,EAACI,WACbN,EAA0BC,EAAOM,kBAD5C,CAKJ,KCXaC,EAAsBC,OAAO,kBAkCpC,SAAUC,EAAyBT,GAErC,OAAIA,EAAOG,KAAKO,YACLV,EAAOG,KAAKO,YAInB,cAAeV,EAAOG,KACfM,EAAyBT,EAAOG,KAAKG,WAI5C,WAAYN,EAAOG,KACZM,EAAyBT,EAAOG,KAAKH,QAIzC,EACX,CCnDgB,SA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,aAAkBC,EAACA,EAACI,WAAaL,EAAOM,YAAcN,EAGrEoG,EAAqC,CAAA,EAE3CC,EAAAC,EAAAA,EAA2B5E,OAAOM,QAJpB0C,EAAazC,OAIqBoE,EAAAC,EAAA1E,OAAAyE,IAAE,CAA7C,IAAAE,EAAAD,EAAAD,GAAOtD,EAAGwD,EAAA,GACLnG,EAAeL,EADHwG,EAAA,SAEGC,IAAjBpG,IACAgG,EAAcrD,GAAO3C,EAE5B,CAED,OAAOgG,CACX,0HILyB,SAACK,EAAuCC,GAG7D,MAAO,CAAE1G,OAFM2G,EAAAA,SAAQ,WAAA,OAAMF,EAAIC,GAAIhG,YAAYgG,KAAK,CAACA,IAG3D"}
@@ -34,7 +34,39 @@ function getDefaultValueInZodStack(schema) {
34
34
  }
35
35
  return undefined;
36
36
  }
37
+ function getDefaultValues(schema) {
38
+ var objectSchema = schema instanceof z.ZodEffects ? schema.innerType() : schema;
39
+ var shape = objectSchema.shape;
40
+ var defaultValues = {};
41
+ for (var _i = 0, _Object$entries = Object.entries(shape); _i < _Object$entries.length; _i++) {
42
+ var _Object$entries$_i = _Object$entries[_i],
43
+ key = _Object$entries$_i[0],
44
+ field = _Object$entries$_i[1];
45
+ var defaultValue = getDefaultValueInZodStack(field);
46
+ if (defaultValue !== undefined) {
47
+ defaultValues[key] = defaultValue;
48
+ }
49
+ }
50
+ return defaultValues;
51
+ }
37
52
 
53
+ var FIELD_CONFIG_SYMBOL = /*#__PURE__*/Symbol('GetFieldConfig');
54
+ var extendZodWithFieldConfig = function extendZodWithFieldConfig(zod) {
55
+ zod.ZodType.prototype.fieldConfig = function (config) {
56
+ this._def.fieldConfig = config;
57
+ return this;
58
+ };
59
+ };
60
+ var createZodSchemaFieldConfig = function createZodSchemaFieldConfig() {
61
+ return function (config) {
62
+ var refinementFunction = function refinementFunction() {
63
+ // Do nothing.
64
+ };
65
+ // @ts-expect-error This is a symbol and not a real value.
66
+ refinementFunction[FIELD_CONFIG_SYMBOL] = config;
67
+ return refinementFunction;
68
+ };
69
+ };
38
70
  function getFieldConfigInZodStack(schema) {
39
71
  // Verifica si el esquema tiene fieldConfig directamente
40
72
  if (schema._def.fieldConfig) {
@@ -226,5 +258,5 @@ var FormInstantProvider = /*#__PURE__*/memo(function (_ref) {
226
258
  });
227
259
  });
228
260
 
229
- export { FormInstantElement, FormInstantProvider, ZodResolverContext, useFields, useSchema };
261
+ export { FIELD_CONFIG_SYMBOL, FormInstantElement, FormInstantProvider, ZodResolverContext, createZodSchemaFieldConfig, extendZodWithFieldConfig, getDefaultValueInZodStack, getDefaultValues, getFieldConfigInZodStack, inferFieldType, parseSchema, useFields, useSchema };
230
262
  //# sourceMappingURL=react-resolver-zod.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"react-resolver-zod.esm.js","sources":["../src/context.tsx","../src/funcs/default-values.ts","../src/funcs/field-config.ts","../src/funcs/field-type-inference.ts","../src/funcs/schema-parser.ts","../src/useSchema.tsx","../src/element.tsx","../src/provider.tsx"],"sourcesContent":["import { createContext } from 'use-context-selector';\nimport { zodResolverProps } from './type';\n\nexport const ZodResolverContext = createContext<zodResolverProps>({} as zodResolverProps);\n","import { z } from 'zod';\nimport { ZodObjectOrWrapped } from './types';\n\nexport function getDefaultValueInZodStack(schema: z.ZodTypeAny): any {\n if (schema instanceof z.ZodDefault) {\n return schema._def.defaultValue();\n }\n\n if (schema instanceof z.ZodEffects) {\n return getDefaultValueInZodStack(schema.innerType());\n }\n\n return undefined;\n}\n\nexport function getDefaultValues(schema: ZodObjectOrWrapped): Record<string, any> {\n const objectSchema = schema instanceof z.ZodEffects ? schema.innerType() : schema;\n const shape = objectSchema.shape;\n\n const defaultValues: Record<string, any> = {};\n\n for (const [key, field] of Object.entries(shape)) {\n const defaultValue = getDefaultValueInZodStack(field as z.ZodTypeAny);\n if (defaultValue !== undefined) {\n defaultValues[key] = defaultValue;\n }\n }\n\n return defaultValues;\n}\n","import { z } from 'zod';\nimport { FieldConfig, SuperRefineFunction } from './types';\nexport const FIELD_CONFIG_SYMBOL = Symbol('GetFieldConfig');\n\ndeclare module 'zod' {\n interface ZodType {\n fieldConfig<AdditionalRenderable = null, FieldTypes = string>(\n config: FieldConfig<AdditionalRenderable, FieldTypes>,\n ): this;\n }\n}\n\nexport const extendZodWithFieldConfig = <AdditionalRenderable = null, FieldTypes = string>(\n zod: typeof z,\n) => {\n (zod.ZodType.prototype as any).fieldConfig = function (\n config: FieldConfig<AdditionalRenderable, FieldTypes>,\n ) {\n this._def.fieldConfig = config;\n return this;\n };\n};\n\nexport const createZodSchemaFieldConfig =\n <AdditionalRenderable = null, FieldTypes = string>() =>\n (config: FieldConfig<AdditionalRenderable, FieldTypes>): SuperRefineFunction => {\n const refinementFunction: SuperRefineFunction = () => {\n // Do nothing.\n };\n\n // @ts-expect-error This is a symbol and not a real value.\n refinementFunction[FIELD_CONFIG_SYMBOL] = config;\n\n return refinementFunction;\n };\n\nexport function getFieldConfigInZodStack(schema: z.ZodTypeAny): FieldConfig {\n // Verifica si el esquema tiene fieldConfig directamente\n if (schema._def.fieldConfig) {\n return schema._def.fieldConfig as FieldConfig;\n }\n\n // Si el esquema es un ZodEffects, busca en el innerType\n if ('innerType' in schema._def) {\n return getFieldConfigInZodStack(schema._def.innerType as z.ZodAny);\n }\n\n // Si el esquema es un ZodEffects con un schema interno, busca en el schema\n if ('schema' in schema._def) {\n return getFieldConfigInZodStack(schema._def.schema as z.ZodAny);\n }\n\n // Si no se encuentra fieldConfig, retorna un objeto vacío\n return {} as FieldConfig;\n}\n","import { z } from 'zod';\nimport { FieldConfig } from './types';\n\nexport function inferFieldType(schema: z.ZodTypeAny, fieldType?: FieldConfig['fieldType']): string {\n if (fieldType) {\n return fieldType;\n }\n\n const type = schema._def.typeName;\n\n const zodToInputType = new Map([\n ['ZodObject', 'object'],\n ['ZodString', 'string'],\n ['ZodNumber', 'number'],\n ['ZodBoolean', 'boolean'],\n ['ZodDate', 'date'],\n ['ZodEnum', 'select'],\n ['ZodNativeEnum', 'select'],\n ['ZodArray', 'array'],\n ]);\n\n const match = zodToInputType.get(type);\n\n return match || 'string'; // Default to string for unknown types\n}\n","import { ParsedField } from '@form-instant/react-input-mapping';\nimport { z } from 'zod';\nimport { getDefaultValueInZodStack } from './default-values';\nimport { getFieldConfigInZodStack } from './field-config';\nimport { inferFieldType } from './field-type-inference';\nimport { ParsedSchema, ZodObjectOrWrapped } from './types';\n\nconst typeMapping = {\n ZodDiscriminatedUnion(\n baseSchema: z.ZodTypeAny,\n name: string,\n history: string,\n dependecys: Record<string, any>,\n ) {\n const { optionsMap, discriminator, fieldConfig } = baseSchema._def;\n\n if (!Object.keys(dependecys).length) return [{}] as ParsedField<any, string>[];\n\n const optionKey = dependecys[discriminator];\n const option = optionsMap.get(optionKey);\n\n if (!option) return [{}] as ParsedField<any, string>[];\n\n const entries = Object.entries(option.shape);\n\n const fields = entries\n .filter(([key]) => key !== discriminator)\n .map(([key, field]) => {\n return parseField(\n key,\n field as z.ZodTypeAny,\n [history, name].join('.'),\n dependecys,\n );\n });\n\n fields.unshift({\n name: {\n current: discriminator,\n history: [history, name, discriminator].join('.'),\n },\n type: 'discriminator',\n required: true,\n default: optionKey,\n fieldConfig,\n options: Array.from(optionsMap.keys()).map((key) => [String(key), String(key)]),\n });\n\n return fields;\n },\n\n ZodObject(\n baseSchema: z.ZodTypeAny,\n name: string,\n history: string,\n dependecys: Record<string, any>,\n ) {\n return Object.entries((baseSchema as any).shape).map(([key, field]) =>\n parseField(key, field as z.ZodTypeAny, [history, name].join('.'), dependecys),\n );\n },\n\n ZodArray(\n baseSchema: z.ZodTypeAny,\n name: string,\n history: string,\n dependecys: Record<string, any>,\n ) {\n return [parseField('0', baseSchema._def.type, [history, name].join('.'), dependecys)];\n },\n};\n\nfunction parseField(\n name: string,\n schema: z.ZodTypeAny,\n history: string = '',\n dependecys: Record<string, any> = {},\n): ParsedField<any> {\n const baseSchema = getBaseSchema(schema);\n const { fieldType, ...fieldConfigBase } = getFieldConfigInZodStack(schema);\n const type = inferFieldType(baseSchema, fieldType);\n const defaultValue = getDefaultValueInZodStack(schema);\n\n let fieldConfig = fieldConfigBase;\n\n // Enums\n const options = baseSchema._def.values;\n let optionValues: [string, string][] = [];\n if (options) {\n if (!Array.isArray(options)) {\n optionValues = Object.entries(options);\n } else {\n optionValues = options.map((value) => [value, value]);\n }\n }\n\n // Arrays and objects\n const getSubSchema = typeMapping[baseSchema._def.typeName as keyof typeof typeMapping];\n\n const subSchema = getSubSchema?.(baseSchema, name, history, dependecys);\n\n if (baseSchema._def.typeName === 'ZodArray') {\n fieldConfig = {\n min: baseSchema._def.minLength?.value || 1,\n max: baseSchema._def.maxLength?.value,\n ...fieldConfig,\n };\n }\n\n const resp = {\n name: { current: name, history: [history, name].join('.') },\n type,\n required: !schema.isOptional(),\n default: defaultValue,\n fieldConfig,\n options: optionValues,\n schema: subSchema,\n description: baseSchema.description,\n };\n\n return resp;\n}\n\nfunction getBaseSchema<ChildType extends z.ZodAny | z.ZodTypeAny | z.AnyZodObject = z.ZodAny>(\n schema: ChildType | z.ZodEffects<ChildType>,\n): ChildType {\n if ('innerType' in schema._def) {\n return getBaseSchema(schema._def.innerType as ChildType);\n }\n if ('schema' in schema._def) {\n return getBaseSchema(schema._def.schema as ChildType);\n }\n\n return schema as ChildType;\n}\n\nexport const parseSchema = (S: ZodObjectOrWrapped): ParsedSchema => {\n const objectSchema = S instanceof z.ZodEffects ? S.innerType() : S;\n const shape = objectSchema.shape;\n\n const dependecys = (objectSchema._def as any).fieldConfig;\n\n const fields = Object.fromEntries(\n Object.entries(shape).map(([key, field]) => [\n key,\n parseField(key, field as z.ZodTypeAny, '', dependecys),\n ]),\n );\n\n return { fields };\n};\n","import { useMemo } from 'react';\nimport { useContext } from 'use-context-selector';\nimport { ZodEffects, ZodObject } from 'zod';\nimport { ZodResolverContext } from './context';\nimport { parseSchema } from './funcs/schema-parser';\n\nconst useSchemaBase = () =>\n useContext(ZodResolverContext) as ZodObject<never, never> | ZodEffects<never, never>;\n\nexport const useFields = <Sc extends Record<string, any>>(key: keyof Sc) => {\n const S = useSchemaBase();\n\n const { fields } = parseSchema(S);\n\n return fields[key as string];\n};\n\ntype Data =\n | Zod.AnyZodObject\n | Zod.ZodEffects<Zod.AnyZodObject>\n | Zod.ZodDiscriminatedUnion<any, any>;\n\ntype DP = Record<string, any>;\n\nexport const useSchema = (cbP: (dp: DP, preData?: Data) => Data, dp: DP) => {\n const schema = useMemo(() => cbP(dp).fieldConfig(dp), [dp]);\n\n return { schema };\n};\n","import { ElementMapping } from '@form-instant/react-input-mapping';\nimport { Fragment, useId } from 'react';\nimport { useFields } from './useSchema';\n\nexport interface ElementProps<Schema extends Record<string, any>> {\n name: keyof Schema;\n}\n\nexport const FormInstantElement = <S extends Record<string, any>>({ name }: ElementProps<S>) => {\n const field = useFields(name);\n\n const inputs = Object.values(field.schema || {});\n\n const id = useId();\n\n return (\n <>\n {inputs.map((props) => {\n return (\n <Fragment key={`${id}-${props.name?.history || ''}`}>\n <ElementMapping formProps={props} />\n </Fragment>\n );\n })}\n </>\n );\n};\n","import { FC, memo, ReactNode } from 'react';\nimport { ZodResolverContext } from './context';\nimport { zodResolverProps } from './type';\nexport const FormInstantProvider: FC<{\n schema: zodResolverProps;\n children: ReactNode;\n}> = memo(({ children, schema }) => {\n return <ZodResolverContext.Provider value={schema}>{children}</ZodResolverContext.Provider>;\n});\n"],"names":["ZodResolverContext","createContext","getDefaultValueInZodStack","schema","z","ZodDefault","_def","defaultValue","ZodEffects","innerType","undefined","getFieldConfigInZodStack","fieldConfig","inferFieldType","fieldType","type","typeName","zodToInputType","Map","match","get","typeMapping","ZodDiscriminatedUnion","baseSchema","name","history","dependecys","_baseSchema$_def","optionsMap","discriminator","Object","keys","length","optionKey","option","entries","shape","fields","filter","_ref","key","map","_ref2","field","parseField","join","unshift","current","required","options","Array","from","String","ZodObject","_ref3","ZodArray","getBaseSchema","_getFieldConfigInZodS","fieldConfigBase","_objectWithoutPropertiesLoose","_excluded","values","optionValues","isArray","value","getSubSchema","subSchema","_baseSchema$_def$minL","_baseSchema$_def$maxL","_extends","min","minLength","max","maxLength","resp","isOptional","description","parseSchema","S","objectSchema","fromEntries","_ref4","useSchemaBase","useContext","useFields","_parseSchema","useSchema","cbP","dp","useMemo","FormInstantElement","inputs","id","useId","_jsx","props","_props$name","Fragment","children","ElementMapping","formProps","FormInstantProvider","memo","Provider"],"mappings":";;;;;;IAGaA,kBAAkB,gBAAGC,aAAa,CAAmB,EAAsB;;;;;;;;;;;;;;;;;;;;;ACAlF,SAAUC,yBAAyBA,CAACC,MAAoB,EAAA;AAC1D,EAAA,IAAIA,MAAM,YAAYC,CAAC,CAACC,UAAU,EAAE;AAChC,IAAA,OAAOF,MAAM,CAACG,IAAI,CAACC,YAAY,EAAE,CAAA;AACpC,GAAA;AAED,EAAA,IAAIJ,MAAM,YAAYC,CAAC,CAACI,UAAU,EAAE;AAChC,IAAA,OAAON,yBAAyB,CAACC,MAAM,CAACM,SAAS,EAAE,CAAC,CAAA;AACvD,GAAA;AAED,EAAA,OAAOC,SAAS,CAAA;AACpB;;ACuBM,SAAUC,wBAAwBA,CAACR,MAAoB,EAAA;AACzD;AACA,EAAA,IAAIA,MAAM,CAACG,IAAI,CAACM,WAAW,EAAE;AACzB,IAAA,OAAOT,MAAM,CAACG,IAAI,CAACM,WAA0B,CAAA;AAChD,GAAA;AAED;AACA,EAAA,IAAI,WAAW,IAAIT,MAAM,CAACG,IAAI,EAAE;AAC5B,IAAA,OAAOK,wBAAwB,CAACR,MAAM,CAACG,IAAI,CAACG,SAAqB,CAAC,CAAA;AACrE,GAAA;AAED;AACA,EAAA,IAAI,QAAQ,IAAIN,MAAM,CAACG,IAAI,EAAE;AACzB,IAAA,OAAOK,wBAAwB,CAACR,MAAM,CAACG,IAAI,CAACH,MAAkB,CAAC,CAAA;AAClE,GAAA;AAED;AACA,EAAA,OAAO,EAAiB,CAAA;AAC5B;;ACnDgB,SAAAU,cAAcA,CAACV,MAAoB,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AM;AAAA+F,IAAAA,QAAA,EAAGA,QAAAA;AAAQ,GAAA,CAA+B,CAAA;AAC/F,CAAC;;;;"}
1
+ {"version":3,"file":"react-resolver-zod.esm.js","sources":["../src/context.tsx","../src/funcs/default-values.ts","../src/funcs/field-config.ts","../src/funcs/field-type-inference.ts","../src/funcs/schema-parser.ts","../src/useSchema.tsx","../src/element.tsx","../src/provider.tsx"],"sourcesContent":["import { createContext } from 'use-context-selector';\nimport { zodResolverProps } from './type';\n\nexport const ZodResolverContext = createContext<zodResolverProps>({} as zodResolverProps);\n","import { z } from 'zod';\nimport { ZodObjectOrWrapped } from './types';\n\nexport function getDefaultValueInZodStack(schema: z.ZodTypeAny): any {\n if (schema instanceof z.ZodDefault) {\n return schema._def.defaultValue();\n }\n\n if (schema instanceof z.ZodEffects) {\n return getDefaultValueInZodStack(schema.innerType());\n }\n\n return undefined;\n}\n\nexport function getDefaultValues(schema: ZodObjectOrWrapped): Record<string, any> {\n const objectSchema = schema instanceof z.ZodEffects ? schema.innerType() : schema;\n const shape = objectSchema.shape;\n\n const defaultValues: Record<string, any> = {};\n\n for (const [key, field] of Object.entries(shape)) {\n const defaultValue = getDefaultValueInZodStack(field as z.ZodTypeAny);\n if (defaultValue !== undefined) {\n defaultValues[key] = defaultValue;\n }\n }\n\n return defaultValues;\n}\n","import { z } from 'zod';\nimport { FieldConfig, SuperRefineFunction } from './types';\nexport const FIELD_CONFIG_SYMBOL = Symbol('GetFieldConfig');\n\ndeclare module 'zod' {\n interface ZodType {\n fieldConfig<AdditionalRenderable = null, FieldTypes = string>(\n config: FieldConfig<AdditionalRenderable, FieldTypes>,\n ): this;\n }\n}\n\nexport const extendZodWithFieldConfig = <AdditionalRenderable = null, FieldTypes = string>(\n zod: typeof z,\n) => {\n (zod.ZodType.prototype as any).fieldConfig = function (\n config: FieldConfig<AdditionalRenderable, FieldTypes>,\n ) {\n this._def.fieldConfig = config;\n return this;\n };\n};\n\nexport const createZodSchemaFieldConfig =\n <AdditionalRenderable = null, FieldTypes = string>() =>\n (config: FieldConfig<AdditionalRenderable, FieldTypes>): SuperRefineFunction => {\n const refinementFunction: SuperRefineFunction = () => {\n // Do nothing.\n };\n\n // @ts-expect-error This is a symbol and not a real value.\n refinementFunction[FIELD_CONFIG_SYMBOL] = config;\n\n return refinementFunction;\n };\n\nexport function getFieldConfigInZodStack(schema: z.ZodTypeAny): FieldConfig {\n // Verifica si el esquema tiene fieldConfig directamente\n if (schema._def.fieldConfig) {\n return schema._def.fieldConfig as FieldConfig;\n }\n\n // Si el esquema es un ZodEffects, busca en el innerType\n if ('innerType' in schema._def) {\n return getFieldConfigInZodStack(schema._def.innerType as z.ZodAny);\n }\n\n // Si el esquema es un ZodEffects con un schema interno, busca en el schema\n if ('schema' in schema._def) {\n return getFieldConfigInZodStack(schema._def.schema as z.ZodAny);\n }\n\n // Si no se encuentra fieldConfig, retorna un objeto vacío\n return {} as FieldConfig;\n}\n","import { z } from 'zod';\nimport { FieldConfig } from './types';\n\nexport function inferFieldType(schema: z.ZodTypeAny, fieldType?: FieldConfig['fieldType']): string {\n if (fieldType) {\n return fieldType;\n }\n\n const type = schema._def.typeName;\n\n const zodToInputType = new Map([\n ['ZodObject', 'object'],\n ['ZodString', 'string'],\n ['ZodNumber', 'number'],\n ['ZodBoolean', 'boolean'],\n ['ZodDate', 'date'],\n ['ZodEnum', 'select'],\n ['ZodNativeEnum', 'select'],\n ['ZodArray', 'array'],\n ]);\n\n const match = zodToInputType.get(type);\n\n return match || 'string'; // Default to string for unknown types\n}\n","import { ParsedField } from '@form-instant/react-input-mapping';\nimport { z } from 'zod';\nimport { getDefaultValueInZodStack } from './default-values';\nimport { getFieldConfigInZodStack } from './field-config';\nimport { inferFieldType } from './field-type-inference';\nimport { ParsedSchema, ZodObjectOrWrapped } from './types';\n\nconst typeMapping = {\n ZodDiscriminatedUnion(\n baseSchema: z.ZodTypeAny,\n name: string,\n history: string,\n dependecys: Record<string, any>,\n ) {\n const { optionsMap, discriminator, fieldConfig } = baseSchema._def;\n\n if (!Object.keys(dependecys).length) return [{}] as ParsedField<any, string>[];\n\n const optionKey = dependecys[discriminator];\n const option = optionsMap.get(optionKey);\n\n if (!option) return [{}] as ParsedField<any, string>[];\n\n const entries = Object.entries(option.shape);\n\n const fields = entries\n .filter(([key]) => key !== discriminator)\n .map(([key, field]) => {\n return parseField(\n key,\n field as z.ZodTypeAny,\n [history, name].join('.'),\n dependecys,\n );\n });\n\n fields.unshift({\n name: {\n current: discriminator,\n history: [history, name, discriminator].join('.'),\n },\n type: 'discriminator',\n required: true,\n default: optionKey,\n fieldConfig,\n options: Array.from(optionsMap.keys()).map((key) => [String(key), String(key)]),\n });\n\n return fields;\n },\n\n ZodObject(\n baseSchema: z.ZodTypeAny,\n name: string,\n history: string,\n dependecys: Record<string, any>,\n ) {\n return Object.entries((baseSchema as any).shape).map(([key, field]) =>\n parseField(key, field as z.ZodTypeAny, [history, name].join('.'), dependecys),\n );\n },\n\n ZodArray(\n baseSchema: z.ZodTypeAny,\n name: string,\n history: string,\n dependecys: Record<string, any>,\n ) {\n return [parseField('0', baseSchema._def.type, [history, name].join('.'), dependecys)];\n },\n};\n\nfunction parseField(\n name: string,\n schema: z.ZodTypeAny,\n history: string = '',\n dependecys: Record<string, any> = {},\n): ParsedField<any> {\n const baseSchema = getBaseSchema(schema);\n const { fieldType, ...fieldConfigBase } = getFieldConfigInZodStack(schema);\n const type = inferFieldType(baseSchema, fieldType);\n const defaultValue = getDefaultValueInZodStack(schema);\n\n let fieldConfig = fieldConfigBase;\n\n // Enums\n const options = baseSchema._def.values;\n let optionValues: [string, string][] = [];\n if (options) {\n if (!Array.isArray(options)) {\n optionValues = Object.entries(options);\n } else {\n optionValues = options.map((value) => [value, value]);\n }\n }\n\n // Arrays and objects\n const getSubSchema = typeMapping[baseSchema._def.typeName as keyof typeof typeMapping];\n\n const subSchema = getSubSchema?.(baseSchema, name, history, dependecys);\n\n if (baseSchema._def.typeName === 'ZodArray') {\n fieldConfig = {\n min: baseSchema._def.minLength?.value || 1,\n max: baseSchema._def.maxLength?.value,\n ...fieldConfig,\n };\n }\n\n const resp = {\n name: { current: name, history: [history, name].join('.') },\n type,\n required: !schema.isOptional(),\n default: defaultValue,\n fieldConfig,\n options: optionValues,\n schema: subSchema,\n description: baseSchema.description,\n };\n\n return resp;\n}\n\nfunction getBaseSchema<ChildType extends z.ZodAny | z.ZodTypeAny | z.AnyZodObject = z.ZodAny>(\n schema: ChildType | z.ZodEffects<ChildType>,\n): ChildType {\n if ('innerType' in schema._def) {\n return getBaseSchema(schema._def.innerType as ChildType);\n }\n if ('schema' in schema._def) {\n return getBaseSchema(schema._def.schema as ChildType);\n }\n\n return schema as ChildType;\n}\n\nexport const parseSchema = (S: ZodObjectOrWrapped): ParsedSchema => {\n const objectSchema = S instanceof z.ZodEffects ? S.innerType() : S;\n const shape = objectSchema.shape;\n\n const dependecys = (objectSchema._def as any).fieldConfig;\n\n const fields = Object.fromEntries(\n Object.entries(shape).map(([key, field]) => [\n key,\n parseField(key, field as z.ZodTypeAny, '', dependecys),\n ]),\n );\n\n return { fields };\n};\n","import { useMemo } from 'react';\nimport { useContext } from 'use-context-selector';\nimport { ZodEffects, ZodObject } from 'zod';\nimport { ZodResolverContext } from './context';\nimport { parseSchema } from './funcs/schema-parser';\n\nconst useSchemaBase = () =>\n useContext(ZodResolverContext) as ZodObject<never, never> | ZodEffects<never, never>;\n\nexport const useFields = <Sc extends Record<string, any>>(key: keyof Sc) => {\n const S = useSchemaBase();\n\n const { fields } = parseSchema(S);\n\n return fields[key as string];\n};\n\ntype Data =\n | Zod.AnyZodObject\n | Zod.ZodEffects<Zod.AnyZodObject>\n | Zod.ZodDiscriminatedUnion<any, any>;\n\ntype DP = Record<string, any>;\n\nexport const useSchema = (cbP: (dp: DP, preData?: Data) => Data, dp: DP) => {\n const schema = useMemo(() => cbP(dp).fieldConfig(dp), [dp]);\n\n return { schema };\n};\n","import { ElementMapping } from '@form-instant/react-input-mapping';\nimport { Fragment, useId } from 'react';\nimport { useFields } from './useSchema';\n\nexport interface ElementProps<Schema extends Record<string, any>> {\n name: keyof Schema;\n}\n\nexport const FormInstantElement = <S extends Record<string, any>>({ name }: ElementProps<S>) => {\n const field = useFields(name);\n\n const inputs = Object.values(field.schema || {});\n\n const id = useId();\n\n return (\n <>\n {inputs.map((props) => {\n return (\n <Fragment key={`${id}-${props.name?.history || ''}`}>\n <ElementMapping formProps={props} />\n </Fragment>\n );\n })}\n </>\n );\n};\n","import { FC, memo, ReactNode } from 'react';\nimport { ZodResolverContext } from './context';\nimport { zodResolverProps } from './type';\nexport const FormInstantProvider: FC<{\n schema: zodResolverProps;\n children: ReactNode;\n}> = memo(({ children, schema }) => {\n return <ZodResolverContext.Provider value={schema}>{children}</ZodResolverContext.Provider>;\n});\n"],"names":["ZodResolverContext","createContext","getDefaultValueInZodStack","schema","z","ZodDefault","_def","defaultValue","ZodEffects","innerType","undefined","getDefaultValues","objectSchema","shape","defaultValues","_i","_Object$entries","Object","entries","length","_Object$entries$_i","key","field","FIELD_CONFIG_SYMBOL","Symbol","extendZodWithFieldConfig","zod","ZodType","prototype","fieldConfig","config","createZodSchemaFieldConfig","refinementFunction","getFieldConfigInZodStack","inferFieldType","fieldType","type","typeName","zodToInputType","Map","match","get","typeMapping","ZodDiscriminatedUnion","baseSchema","name","history","dependecys","_baseSchema$_def","optionsMap","discriminator","keys","optionKey","option","fields","filter","_ref","map","_ref2","parseField","join","unshift","current","required","options","Array","from","String","ZodObject","_ref3","ZodArray","getBaseSchema","_getFieldConfigInZodS","fieldConfigBase","_objectWithoutPropertiesLoose","_excluded","values","optionValues","isArray","value","getSubSchema","subSchema","_baseSchema$_def$minL","_baseSchema$_def$maxL","_extends","min","minLength","max","maxLength","resp","isOptional","description","parseSchema","S","fromEntries","_ref4","useSchemaBase","useContext","useFields","_parseSchema","useSchema","cbP","dp","useMemo","FormInstantElement","inputs","id","useId","_jsx","props","_props$name","Fragment","children","ElementMapping","formProps","FormInstantProvider","mem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5E,MAAM;AAAA6G,IAAAA,QAAA,EAAGA,QAAAA;AAAQ,GAAA,CAA+B,CAAA;AAC/F,CAAC;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@form-instant/react-resolver-zod",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "leomerida15",