@form-instant/react-resolver-zod 2.0.0-rc.5 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/FormInstantProvider.d.ts +1 -1
- package/dist/hooks/useSchema.d.ts +4 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +8 -8
- package/dist/utils/zodExtensions.d.ts +4 -0
- package/package.json +5 -5
- package/dist/components/SchemaMapper.d.ts +0 -24
- package/dist/examples/completeExample.d.ts +0 -6
- package/dist/examples/fieldConfigExample.d.ts +0 -158
- package/dist/examples/formInstantExample.d.ts +0 -6
- package/dist/examples/legacyCompatibility.d.ts +0 -30
- package/dist/hooks/useSchemaMapping.d.ts +0 -22
- package/dist/hooks/useSchemaMetadata.d.ts +0 -26
- package/dist/hooks/useSchemaNavigation.d.ts +0 -18
- package/dist/utils/pathResolver.d.ts +0 -26
@@ -1,5 +1,5 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
-
import { zodResolverProps } from 'types';
|
2
|
+
import { zodResolverProps } from '../types';
|
3
3
|
export declare const ZodResolverContext: import("react").Context<any>;
|
4
4
|
export declare const FormInstantProvider: FCC<{
|
5
5
|
schema: zodResolverProps;
|
@@ -1,6 +1,10 @@
|
|
1
1
|
import { z } from 'zod';
|
2
2
|
type Data = z.ZodObject<any, any> | z.ZodTypeAny | z.ZodDiscriminatedUnion<any, any>;
|
3
3
|
type DP = Record<string, any>;
|
4
|
+
/**
|
5
|
+
* Generates initial values from schema and dependencies
|
6
|
+
*/
|
7
|
+
export declare const getInitialValues: <T extends Data>(schema: T, dp?: DP) => z.core.output<T>;
|
4
8
|
/**
|
5
9
|
* Hook that provides reactive schema and initial values
|
6
10
|
*/
|
package/dist/index.d.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
+
import './utils/zodExtensions';
|
1
2
|
export { FormInstantProvider, useFields } from './components/FormInstantProvider';
|
2
|
-
export { useSchema } from './hooks/useSchema';
|
3
|
+
export { useSchema, getInitialValues } from './hooks/useSchema';
|
3
4
|
export { FormInstantElement } from './components/FormInstantElement';
|
4
5
|
export * from './types';
|
5
6
|
export * from './utils/schemaParser';
|
6
|
-
export
|
7
|
+
export { addFieldConfig } from './utils/zodExtensions';
|
package/dist/index.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
import{createContext as y,useContext as
|
1
|
+
import{z as Y}from"zod";function S(A,B){return A._fieldConfig=B,Object.defineProperty(A,"fieldConfig",{value(K){return this._fieldConfig=K,this},writable:!0,configurable:!0}),A}function P(){let A=Object.getPrototypeOf(Y.string());Object.defineProperty(A,"fieldConfig",{value(B){return this._fieldConfig=B,this},writable:!0,configurable:!0});try{let B=Object.getPrototypeOf(Y.string());if(B&&B!==A)Object.defineProperty(B,"fieldConfig",{value(J){return this._fieldConfig=J,this},writable:!0,configurable:!0});let K=Object.getPrototypeOf(Y.email());if(K&&K!==A)Object.defineProperty(K,"fieldConfig",{value(J){return this._fieldConfig=J,this},writable:!0,configurable:!0});let U=Object.getPrototypeOf(Y.string().url());if(U&&U!==A)Object.defineProperty(U,"fieldConfig",{value(J){return this._fieldConfig=J,this},writable:!0,configurable:!0});let L=Object.getPrototypeOf(Y.string().min(1));if(L&&L!==A)Object.defineProperty(L,"fieldConfig",{value(J){return this._fieldConfig=J,this},writable:!0,configurable:!0});let $=Object.getPrototypeOf(Y.string().max(100));if($&&$!==A)Object.defineProperty($,"fieldConfig",{value(J){return this._fieldConfig=J,this},writable:!0,configurable:!0});let W=Object.getPrototypeOf(Y.object({}));if(W&&W!==A)Object.defineProperty(W,"fieldConfig",{value(J){return this._fieldConfig=J,this},writable:!0,configurable:!0});let X=Object.getPrototypeOf(Y.array(Y.string()));if(X&&X!==A)Object.defineProperty(X,"fieldConfig",{value(J){return this._fieldConfig=J,this},writable:!0,configurable:!0});let Q=Object.getPrototypeOf(Y.optional(Y.string()));if(Q&&Q!==A)Object.defineProperty(Q,"fieldConfig",{value(J){return this._fieldConfig=J,this},writable:!0,configurable:!0});let O=Object.getPrototypeOf(Y.nullable(Y.string()));if(O&&O!==A)Object.defineProperty(O,"fieldConfig",{value(J){return this._fieldConfig=J,this},writable:!0,configurable:!0});let D=Object.getPrototypeOf(Y.string().default(""));if(D&&D!==A)Object.defineProperty(D,"fieldConfig",{value(J){return this._fieldConfig=J,this},writable:!0,configurable:!0});let R=Object.getPrototypeOf(Y.boolean());if(R&&R!==A)Object.defineProperty(R,"fieldConfig",{value(J){return this._fieldConfig=J,this},writable:!0,configurable:!0});let q=Object.getPrototypeOf(Y.number());if(q&&q!==A)Object.defineProperty(q,"fieldConfig",{value(J){return this._fieldConfig=J,this},writable:!0,configurable:!0});let Z=Object.getPrototypeOf(Y.string().refine(()=>!0));if(Z&&Z!==A)Object.defineProperty(Z,"fieldConfig",{value(J){return this._fieldConfig=J,this},writable:!0,configurable:!0});let w=Object.getPrototypeOf(Y.string().min(1));if(w&&w!==A)Object.defineProperty(w,"fieldConfig",{value(J){return this._fieldConfig=J,this},writable:!0,configurable:!0})}catch(B){console.warn("Some Zod prototypes could not be extended:",B)}return Y}P();import{createContext as y,useContext as h}from"react";import{z as G}from"zod";function k(A){return A._zod?.def?.type||"unknown"}function u(A){let B=A?._fieldConfig;if(!B)return;return B}function T(A){let B={},K=[],U={};function L(X){if(X instanceof G.ZodObject)return X.shape;if(X instanceof G.ZodDiscriminatedUnion){let Q=X.options;if(Q.length>0)return L(Q[0])}return{}}function $(X,Q,O="",D=U){let R=u(Q),q=O?`${O}.${X}`:X,Z=R?.fieldType||k(Q),w=Q instanceof G.ZodOptional,J=Q instanceof G.ZodDefault,z=!w&&!J,M=void 0;if(J)try{let _=Q.safeParse(void 0);if(_.success)M=_.data}catch{}else try{let _=Q.safeParse(void 0);if(_.success)M=_.data}catch{}let g=(()=>{if(Q instanceof G.ZodEnum)return Q.options.map((_)=>[String(_),String(_)]);if(Q.constructor.name==="ZodNativeEnum")return Q.options.map((H)=>[String(H),String(H)]);return[]})(),C={name:{current:X,history:q},fieldType:Z,required:z,default:M,fieldConfig:R,options:g};if(B[q]=C,K.push(q),D[X]=C,Q instanceof G.ZodObject){let _=Q.shape,H={};D[X]=H,Object.keys(_).forEach((E)=>{$(E,_[E],q,H)}),B[q].schema=D[X]}if(Q instanceof G.ZodArray){let _=Q.element;if(_ instanceof G.ZodObject){let H={};D[X]=H;let E=_.shape;Object.keys(E).forEach((V)=>{$(V,E[V],`${q}[0]`,H)})}}}let W=L(A);return Object.keys(W).forEach((X)=>{$(X,W[X])}),{fields:B}}function i(A){return k(A)}function o(A){let B=A instanceof G.ZodOptional,K=A instanceof G.ZodDefault;return!B&&!K}function a(A){try{let B=A.safeParse(void 0);return B.success?B.data:void 0}catch{return}}import{jsx as s}from"react/jsx-runtime";var F=y(null),f=({children:A,schema:B})=>{return s(F.Provider,{value:B,children:A})},j=(A)=>{let B=h(F);if(!B)throw new Error("useFields must be used within FormInstantProvider");let{fields:K}=T(B);return K[A]};import{useMemo as x}from"react";import{z as d}from"zod";var v=(A,B={})=>{try{let K=(()=>{if(A instanceof d.ZodObject)return A.shape;return{}})(),U={};for(let L of Object.keys(K)){let $=K[L],W=$.safeParse(void 0);if(W.success){U[L]=W.data;continue}if(Object.keys(B).includes(L)){U[L]=B[L];continue}let X={ZodEmail(){U[L]=""},ZodString(){U[L]=""},ZodNumber(){U[L]=0},ZodBoolean(){U[L]=!1},ZodDate(){U[L]=null},ZodArray(){U[L]=[]},ZodObject(){U[L]=v($,B)}},Q=$.constructor.name,O=X[Q];if(O){O();continue}U[L]=""}return U}catch(K){if(console.log("\uD83D\uDD34 initialValues error",K),K instanceof Error)console.log(K.cause),console.log(K.message);return{}}},p=(A,B)=>{let K=x(()=>{let L=A(B);if(L._fieldConfig)return L.fieldConfig({dp:B,...L._fieldConfig});return L},[A,B]),U=x(()=>v(K,B),[K,B]);return{schema:K,initialValues:U}};import{useId as m}from"react";import{ElementMapping as b}from"@form-instant/react-input-mapping";import{jsx as I,Fragment as N}from"react/jsx-runtime";var n=({name:A})=>{let B=j(A),K=m();if(!["object"].includes(B.fieldType))return I(b,{formProps:B});return I(N,{children:Object.values(B.schema||{}).map((U)=>{return I(N,{children:I(b,{formProps:U})},`${K}-${U.name?.history||""}`)})})};export{p as useSchema,j as useFields,T as parseSchema,o as isFieldRequired,v as getInitialValues,i as getFieldType,a as getDefaultValue,S as addFieldConfig,f as FormInstantProvider,n as FormInstantElement};
|
2
2
|
|
3
|
-
//# debugId=
|
3
|
+
//# debugId=DCB54C44B09FF7C464756E2164756E21
|
package/dist/index.js.map
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
|
-
"sources": ["../src/components/FormInstantProvider.tsx", "../src/utils/schemaParser.ts", "../src/hooks/useSchema.ts", "../src/components/FormInstantElement.tsx"
|
3
|
+
"sources": ["../src/utils/zodExtensions.ts", "../src/components/FormInstantProvider.tsx", "../src/utils/schemaParser.ts", "../src/hooks/useSchema.ts", "../src/components/FormInstantElement.tsx"],
|
4
4
|
"sourcesContent": [
|
5
|
-
"import {
|
6
|
-
"
|
7
|
-
"import {
|
8
|
-
"
|
9
|
-
"
|
5
|
+
"import { z } from 'zod';\nimport { FieldConfig } from '../types';\n\n// Extend ZodType interface to include fieldConfig method\ndeclare module 'zod' {\n interface ZodType {\n fieldConfig: <Ob extends Record<string, any>>(config: FieldConfig<Ob, keyof Ob>) => this;\n _fieldConfig?: FieldConfig<any, any>;\n }\n}\n\n// Create a wrapper function that adds fieldConfig to any Zod schema\nfunction addFieldConfig<T extends z.ZodTypeAny>(schema: T, config: FieldConfig<any, any>): T {\n (schema as any)._fieldConfig = config;\n\n // Add fieldConfig method to the schema instance\n Object.defineProperty(schema, 'fieldConfig', {\n value(newConfig: FieldConfig<any, any>) {\n (this as any)._fieldConfig = newConfig;\n return this;\n },\n writable: true,\n configurable: true,\n });\n\n return schema;\n}\n\n// Function to extend Zod globally with fieldConfig method\nexport function extendZodWithFieldConfig() {\n // In Zod v4, we need to extend the base ZodType prototype\n // Get the prototype of a basic Zod schema\n const zodTypePrototype = Object.getPrototypeOf(z.string());\n\n // Add fieldConfig method to all Zod schemas\n Object.defineProperty(zodTypePrototype, 'fieldConfig', {\n value(config: FieldConfig<any, any>) {\n (this as any)._fieldConfig = config;\n return this;\n },\n writable: true,\n configurable: true,\n });\n\n // For Zod v4, we need to be more careful about extending prototypes\n // Let's try to extend the most common ones\n try {\n // Extend string schema prototype\n const stringPrototype = Object.getPrototypeOf(z.string());\n if (stringPrototype && stringPrototype !== zodTypePrototype) {\n Object.defineProperty(stringPrototype, 'fieldConfig', {\n value(config: FieldConfig<any, any>) {\n (this as any)._fieldConfig = config;\n return this;\n },\n writable: true,\n configurable: true,\n });\n }\n\n // Extend email schema prototype (z.string().email())\n const emailPrototype = Object.getPrototypeOf(z.email());\n if (emailPrototype && emailPrototype !== zodTypePrototype) {\n Object.defineProperty(emailPrototype, 'fieldConfig', {\n value(config: FieldConfig<any, any>) {\n (this as any)._fieldConfig = config;\n return this;\n },\n writable: true,\n configurable: true,\n });\n }\n\n // Extend url schema prototype (z.string().url())\n const urlPrototype = Object.getPrototypeOf(z.string().url());\n if (urlPrototype && urlPrototype !== zodTypePrototype) {\n Object.defineProperty(urlPrototype, 'fieldConfig', {\n value(config: FieldConfig<any, any>) {\n (this as any)._fieldConfig = config;\n return this;\n },\n writable: true,\n configurable: true,\n });\n }\n\n // Extend min schema prototype (z.string().min())\n const minPrototype = Object.getPrototypeOf(z.string().min(1));\n if (minPrototype && minPrototype !== zodTypePrototype) {\n Object.defineProperty(minPrototype, 'fieldConfig', {\n value(config: FieldConfig<any, any>) {\n (this as any)._fieldConfig = config;\n return this;\n },\n writable: true,\n configurable: true,\n });\n }\n\n // Extend max schema prototype (z.string().max())\n const maxPrototype = Object.getPrototypeOf(z.string().max(100));\n if (maxPrototype && maxPrototype !== zodTypePrototype) {\n Object.defineProperty(maxPrototype, 'fieldConfig', {\n value(config: FieldConfig<any, any>) {\n (this as any)._fieldConfig = config;\n return this;\n },\n writable: true,\n configurable: true,\n });\n }\n\n // Extend object schema prototype\n const objectPrototype = Object.getPrototypeOf(z.object({}));\n if (objectPrototype && objectPrototype !== zodTypePrototype) {\n Object.defineProperty(objectPrototype, 'fieldConfig', {\n value(config: FieldConfig<any, any>) {\n (this as any)._fieldConfig = config;\n return this;\n },\n writable: true,\n configurable: true,\n });\n }\n\n // Extend array schema prototype\n const arrayPrototype = Object.getPrototypeOf(z.array(z.string()));\n if (arrayPrototype && arrayPrototype !== zodTypePrototype) {\n Object.defineProperty(arrayPrototype, 'fieldConfig', {\n value(config: FieldConfig<any, any>) {\n (this as any)._fieldConfig = config;\n return this;\n },\n writable: true,\n configurable: true,\n });\n }\n\n // Extend optional schema prototype\n const optionalPrototype = Object.getPrototypeOf(z.optional(z.string()));\n if (optionalPrototype && optionalPrototype !== zodTypePrototype) {\n Object.defineProperty(optionalPrototype, 'fieldConfig', {\n value(config: FieldConfig<any, any>) {\n (this as any)._fieldConfig = config;\n return this;\n },\n writable: true,\n configurable: true,\n });\n }\n\n // Extend nullable schema prototype\n const nullablePrototype = Object.getPrototypeOf(z.nullable(z.string()));\n if (nullablePrototype && nullablePrototype !== zodTypePrototype) {\n Object.defineProperty(nullablePrototype, 'fieldConfig', {\n value(config: FieldConfig<any, any>) {\n (this as any)._fieldConfig = config;\n return this;\n },\n writable: true,\n configurable: true,\n });\n }\n\n // Extend default schema prototype\n const defaultPrototype = Object.getPrototypeOf(z.string().default(''));\n if (defaultPrototype && defaultPrototype !== zodTypePrototype) {\n Object.defineProperty(defaultPrototype, 'fieldConfig', {\n value(config: FieldConfig<any, any>) {\n (this as any)._fieldConfig = config;\n return this;\n },\n writable: true,\n configurable: true,\n });\n }\n\n // Extend boolean schema prototype\n const booleanPrototype = Object.getPrototypeOf(z.boolean());\n if (booleanPrototype && booleanPrototype !== zodTypePrototype) {\n Object.defineProperty(booleanPrototype, 'fieldConfig', {\n value(config: FieldConfig<any, any>) {\n (this as any)._fieldConfig = config;\n return this;\n },\n writable: true,\n configurable: true,\n });\n }\n\n // Extend number schema prototype\n const numberPrototype = Object.getPrototypeOf(z.number());\n if (numberPrototype && numberPrototype !== zodTypePrototype) {\n Object.defineProperty(numberPrototype, 'fieldConfig', {\n value(config: FieldConfig<any, any>) {\n (this as any)._fieldConfig = config;\n return this;\n },\n writable: true,\n configurable: true,\n });\n }\n\n // Extend refinement schema prototype (for validations like email, url, etc.)\n const refinementPrototype = Object.getPrototypeOf(z.string().refine(() => true));\n if (refinementPrototype && refinementPrototype !== zodTypePrototype) {\n Object.defineProperty(refinementPrototype, 'fieldConfig', {\n value(config: FieldConfig<any, any>) {\n (this as any)._fieldConfig = config;\n return this;\n },\n writable: true,\n configurable: true,\n });\n }\n\n // Extend validation schema prototype (for validations like min, max, etc.)\n const validationPrototype = Object.getPrototypeOf(z.string().min(1));\n if (validationPrototype && validationPrototype !== zodTypePrototype) {\n Object.defineProperty(validationPrototype, 'fieldConfig', {\n value(config: FieldConfig<any, any>) {\n (this as any)._fieldConfig = config;\n return this;\n },\n writable: true,\n configurable: true,\n });\n }\n } catch (error) {\n console.warn('Some Zod prototypes could not be extended:', error);\n }\n\n return z;\n}\n\n// Execute the extension immediately when this module is imported\nextendZodWithFieldConfig();\n\n// Helper function to get field configuration from a schema\nexport function getFieldConfig<T = FieldConfig<any, any>>(schema: z.ZodTypeAny): T | undefined {\n return (schema as any)._fieldConfig;\n}\n\n// Helper function to set field configuration on an existing schema\nexport function setFieldConfig<T = FieldConfig<any, any>>(\n schema: z.ZodTypeAny,\n config: T,\n): z.ZodTypeAny {\n (schema as any)._fieldConfig = config;\n return schema;\n}\n\n// Export the wrapper function for manual use\nexport { addFieldConfig };\n",
|
6
|
+
"'use client';\n\nimport { createContext, useContext } from 'react';\nimport { zodResolverProps } from '../types';\nimport { parseSchema } from '../utils/schemaParser';\n\nexport const ZodResolverContext = createContext<zodResolverProps | null>(null);\n\nexport const FormInstantProvider: FCC<{\n schema: zodResolverProps;\n}> = ({ children, schema }) => {\n return <ZodResolverContext.Provider value={schema}>{children}</ZodResolverContext.Provider>;\n};\n\n/**\n * Hook to get a specific field by name from the schema\n */\nexport const useFields = <Sc extends Record<string, any>>(key: keyof Sc) => {\n const schema = useContext(ZodResolverContext);\n if (!schema) {\n throw new Error('useFields must be used within FormInstantProvider');\n }\n\n const { fields } = parseSchema(schema);\n return fields[key as string];\n};\n",
|
7
|
+
"import { z } from 'zod';\nimport { FieldConfig, FieldMetadata, SchemaPath } from '../types';\n\n// Schema type detection using the internal type property\nfunction getSchemaType(schema: z.ZodTypeAny): string {\n return schema._zod?.def?.type || 'unknown';\n}\n\n/**\n * Extracts fieldConfig from a Zod schema\n */\nfunction extractFieldConfig(schema: z.ZodTypeAny) {\n const fieldConfig = (schema as any)?._fieldConfig as FieldConfig<Record<string, object>>;\n if (!fieldConfig) return undefined;\n\n return fieldConfig;\n}\n\n/**\n * Parses a Zod schema and extracts metadata for mapping\n */\nexport function parseSchema(schema: z.ZodTypeAny): { fields: Record<string, any> } {\n const fields: Record<string, FieldMetadata> = {};\n const paths: SchemaPath[] = [];\n const structure: Record<string, any> = {};\n\n function extractShape(schema: z.ZodTypeAny): Record<string, any> {\n // Handle ZodObject\n if (schema instanceof z.ZodObject) {\n return schema.shape;\n }\n\n // Handle ZodDiscriminatedUnion\n if (schema instanceof z.ZodDiscriminatedUnion) {\n // For discriminated unions, we'll use the first option as default\n const options = schema.options;\n if (options.length > 0) {\n return extractShape(options[0] as z.ZodTypeAny);\n }\n }\n\n return {};\n }\n\n function processField(\n fieldName: string,\n fieldSchema: z.ZodTypeAny,\n parentPath: string = '',\n parentStructure: Record<string, any> = structure,\n ) {\n // Extract fieldConfig from the schema\n const fieldConfig = extractFieldConfig(fieldSchema);\n const currentPath = parentPath ? `${parentPath}.${fieldName}` : fieldName;\n const fieldType = fieldConfig?.fieldType || getSchemaType(fieldSchema);\n\n // Check if field is required\n const isOptional = fieldSchema instanceof z.ZodOptional;\n const hasDefault = fieldSchema instanceof z.ZodDefault;\n const isRequired = !isOptional && !hasDefault;\n\n // Get default value\n let defaultValue: any = undefined;\n if (hasDefault) {\n // For ZodDefault, try to get the default value\n try {\n const result = fieldSchema.safeParse(undefined);\n if (result.success) {\n defaultValue = result.data;\n }\n } catch {\n // Could not get default value\n }\n } else {\n try {\n const result = fieldSchema.safeParse(undefined);\n if (result.success) {\n defaultValue = result.data;\n }\n } catch {\n // Field is required, no default value\n }\n }\n\n // Extract options for enums\n const options: [string, string][] = (() => {\n if (fieldSchema instanceof z.ZodEnum) {\n return fieldSchema.options.map((value) => [String(value), String(value)]);\n }\n\n if (fieldSchema.constructor.name === 'ZodNativeEnum') {\n const enumValues = (fieldSchema as z.ZodEnum).options;\n return enumValues.map((value) => [String(value), String(value)]);\n }\n return [];\n })();\n\n // Create field metadata\n const fieldMetadata: FieldMetadata = {\n name: {\n current: fieldName,\n history: currentPath,\n },\n fieldType: fieldType as any,\n required: isRequired,\n default: defaultValue,\n fieldConfig,\n options,\n };\n\n // Store field metadata by path\n fields[currentPath] = fieldMetadata;\n paths.push(currentPath);\n parentStructure[fieldName] = fieldMetadata;\n\n // Handle nested objects\n if (fieldSchema instanceof z.ZodObject) {\n const nestedShape = fieldSchema.shape;\n const nestedStructure: Record<string, any> = {};\n parentStructure[fieldName] = nestedStructure;\n\n Object.keys(nestedShape).forEach((nestedFieldName) => {\n processField(\n nestedFieldName,\n nestedShape[nestedFieldName],\n currentPath,\n nestedStructure,\n );\n });\n\n fields[currentPath].schema = parentStructure[fieldName];\n }\n\n // Handle arrays\n if (fieldSchema instanceof z.ZodArray) {\n const elementSchema = fieldSchema.element;\n if (elementSchema instanceof z.ZodObject) {\n const arrayStructure: Record<string, any> = {};\n parentStructure[fieldName] = arrayStructure;\n\n const elementShape = elementSchema.shape;\n Object.keys(elementShape).forEach((elementFieldName) => {\n processField(\n elementFieldName,\n elementShape[elementFieldName],\n `${currentPath}[0]`,\n arrayStructure,\n );\n });\n }\n }\n }\n\n const shape = extractShape(schema);\n Object.keys(shape).forEach((fieldName) => {\n processField(fieldName, shape[fieldName]);\n });\n\n return {\n fields,\n };\n}\n\n/**\n * Gets the field type from a Zod schema\n */\nexport function getFieldType(schema: z.ZodTypeAny): string {\n return getSchemaType(schema);\n}\n\n/**\n * Checks if a field is required\n */\nexport function isFieldRequired(schema: z.ZodTypeAny): boolean {\n const isOptional = schema instanceof z.ZodOptional;\n const hasDefault = schema instanceof z.ZodDefault;\n return !isOptional && !hasDefault;\n}\n\n/**\n * Gets the default value for a field\n */\nexport function getDefaultValue(schema: z.ZodTypeAny): any {\n try {\n const result = schema.safeParse(undefined);\n return result.success ? result.data : undefined;\n } catch {\n return undefined;\n }\n}\n",
|
8
|
+
"import { useMemo } from 'react';\nimport { z } from 'zod';\n\n// Types for useSchema hook\ntype Data = z.ZodObject<any, any> | z.ZodTypeAny | z.ZodDiscriminatedUnion<any, any>;\ntype DP = Record<string, any>;\n\n/**\n * Generates initial values from schema and dependencies\n */\nexport const getInitialValues = <T extends Data>(schema: T, dp: DP = {}): z.infer<T> => {\n try {\n const shape = (() => {\n if (schema instanceof z.ZodObject) return (schema as z.ZodObject<any>).shape;\n return {};\n })();\n\n const initialValues: Record<string, any> = {};\n\n for (const key of Object.keys(shape)) {\n const fieldSchema = shape[key];\n const result = fieldSchema.safeParse(undefined);\n\n // Si tiene valor por defecto\n if (result.success) {\n initialValues[key] = result.data;\n continue;\n }\n\n if (Object.keys(dp).includes(key)) {\n initialValues[key] = dp[key];\n continue;\n }\n\n // Inferir tipo para campos requeridos sin default\n const fieldConfig = {\n ZodEmail() {\n initialValues[key] = '';\n },\n ZodString() {\n initialValues[key] = '';\n },\n ZodNumber() {\n initialValues[key] = 0;\n },\n ZodBoolean() {\n initialValues[key] = false;\n },\n ZodDate() {\n initialValues[key] = null;\n },\n ZodArray() {\n initialValues[key] = [];\n },\n ZodObject() {\n initialValues[key] = getInitialValues(fieldSchema, dp);\n },\n };\n\n const fieldType = fieldSchema.constructor.name;\n const fieldHandler = fieldConfig[fieldType as keyof typeof fieldConfig];\n\n if (fieldHandler) {\n fieldHandler();\n continue;\n }\n\n initialValues[key] = '';\n }\n\n return initialValues as z.infer<T>;\n } catch (error) {\n console.log('🔴 initialValues error', error);\n\n if (error instanceof Error) {\n console.log(error.cause);\n console.log(error.message);\n }\n\n return {} as z.infer<T>;\n }\n};\n\n/**\n * Hook that provides reactive schema and initial values\n */\nexport const useSchema = <T extends Data>(cbP: (dp: DP, preData?: Data) => T, dp: DP) => {\n const schema = useMemo(() => {\n const baseSchema = cbP(dp);\n // Check if fieldConfig exists (for backward compatibility)\n if ((baseSchema as any)._fieldConfig) {\n return (baseSchema as any).fieldConfig({\n dp,\n ...(baseSchema as any)._fieldConfig,\n }) as T;\n }\n return baseSchema as T;\n }, [cbP, dp]);\n\n const initialValues = useMemo(() => getInitialValues<T>(schema, dp), [schema, dp]);\n\n return { schema, initialValues } as const;\n};\n",
|
9
|
+
"'use client';\n\nimport { Fragment, useId } from 'react';\nimport { ElementMapping } from '@form-instant/react-input-mapping';\nimport { useFields } from './FormInstantProvider';\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 id = useId();\n\n if (!['object'].includes(field.fieldType)) return <ElementMapping formProps={field} />;\n\n return (\n <>\n {Object.values(field.schema || {}).map((props: any) => {\n return (\n <Fragment key={`${id}-${props.name?.history || ''}`}>\n <ElementMapping formProps={props} />\n </Fragment>\n );\n })}\n </>\n );\n};\n"
|
10
10
|
],
|
11
|
-
"mappings": "AAAA,wBAAS,gBAAe,
|
12
|
-
"debugId": "
|
11
|
+
"mappings": "AAAA,YAAS,YAYT,SAAS,CAAsC,CAAC,EAAW,EAAkC,CAazF,OAZC,EAAe,aAAe,EAG/B,OAAO,eAAe,EAAQ,cAAe,CACzC,KAAK,CAAC,EAAkC,CAEpC,OADC,KAAa,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SAAS,EAAM,SAAS,EAAG,OAAO,EAAC,EAAD,CAAgB,UAAW,EAAO,EAEpF,OACI,cACK,OAAO,OAAO,EAAM,QAAU,CAAC,CAAC,EAAE,IAAI,CAAC,IAAe,CACnD,OACI,EAEE,EAFF,UACI,EAAC,EAAD,CAAgB,UAAW,EAAO,GADvB,GAAG,KAAM,EAAM,MAAM,SAAW,IAE7C,EAET,EACH",
|
12
|
+
"debugId": "DCB54C44B09FF7C464756E2164756E21",
|
13
13
|
"names": []
|
14
14
|
}
|
@@ -6,4 +6,8 @@ declare module 'zod' {
|
|
6
6
|
_fieldConfig?: FieldConfig<any, any>;
|
7
7
|
}
|
8
8
|
}
|
9
|
+
declare function addFieldConfig<T extends z.ZodTypeAny>(schema: T, config: FieldConfig<any, any>): T;
|
9
10
|
export declare function extendZodWithFieldConfig(): typeof z;
|
11
|
+
export declare function getFieldConfig<T = FieldConfig<any, any>>(schema: z.ZodTypeAny): T | undefined;
|
12
|
+
export declare function setFieldConfig<T = FieldConfig<any, any>>(schema: z.ZodTypeAny, config: T): z.ZodTypeAny;
|
13
|
+
export { addFieldConfig };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@form-instant/react-resolver-zod",
|
3
|
-
"version": "2.0.0
|
3
|
+
"version": "2.0.0",
|
4
4
|
"author": {
|
5
5
|
"name": "leomerida15",
|
6
6
|
"email": "dimasmerida15@gmail.com",
|
@@ -25,10 +25,10 @@
|
|
25
25
|
"test": "bun test",
|
26
26
|
"test:coverage": "bun test --coverage",
|
27
27
|
"test:watch": "bun test --watch",
|
28
|
-
"type-check": "tsc --noEmit",
|
29
28
|
"up": "npm publish --access public",
|
30
29
|
"up:rc": "npm publish --access public --tag rc",
|
31
|
-
"format": "prettier --write ."
|
30
|
+
"format": "prettier --write .",
|
31
|
+
"prepare": "bun run build"
|
32
32
|
},
|
33
33
|
"devDependencies": {
|
34
34
|
"@eslint/js": "^9.33.0",
|
@@ -53,8 +53,8 @@
|
|
53
53
|
},
|
54
54
|
"peerDependencies": {
|
55
55
|
"@form-instant/react-input-mapping": "^1.8.0",
|
56
|
-
"react": "^19
|
57
|
-
"react-dom": "^19
|
56
|
+
"react": "^19",
|
57
|
+
"react-dom": "^19"
|
58
58
|
},
|
59
59
|
"engines": {
|
60
60
|
"node": ">=18",
|
@@ -1,24 +0,0 @@
|
|
1
|
-
import { SchemaMapperProps, ElementProps } from '../types';
|
2
|
-
/**
|
3
|
-
* Main component for mapping Zod schemas to React components
|
4
|
-
* Provides an agnostic way to map schema fields to components
|
5
|
-
*/
|
6
|
-
export declare function SchemaMapper({ schema, componentMapping, defaultComponent, transformProps, children, }: SchemaMapperProps): import("react/jsx-runtime").JSX.Element;
|
7
|
-
/**
|
8
|
-
* Hook to use schema mapping context
|
9
|
-
*/
|
10
|
-
export declare function useSchemaMappingContext(): {
|
11
|
-
metadata: any;
|
12
|
-
mappingConfig: any;
|
13
|
-
};
|
14
|
-
/**
|
15
|
-
* Component for rendering a specific field by name
|
16
|
-
* Maintains backward compatibility with the old Element component
|
17
|
-
*/
|
18
|
-
export declare function FormInstantElement<S extends Record<string, any>>({ name }: ElementProps<S>): import("react/jsx-runtime").JSX.Element | null;
|
19
|
-
/**
|
20
|
-
* Component for rendering a field by path
|
21
|
-
*/
|
22
|
-
export declare function SchemaField({ path }: {
|
23
|
-
path: string;
|
24
|
-
}): import("react/jsx-runtime").JSX.Element | null;
|
@@ -1,6 +0,0 @@
|
|
1
|
-
export declare function UserFormExample1(): import("react/jsx-runtime").JSX.Element;
|
2
|
-
export declare function UserFormExample2(): import("react/jsx-runtime").JSX.Element;
|
3
|
-
export declare function UserFormExample3(): import("react/jsx-runtime").JSX.Element;
|
4
|
-
export declare function CustomUserForm(): import("react/jsx-runtime").JSX.Element;
|
5
|
-
export declare function UserFormWithValidation(): import("react/jsx-runtime").JSX.Element;
|
6
|
-
export declare const styles = "\n.user-form {\n max-width: 600px;\n margin: 0 auto;\n padding: 20px;\n}\n\n.form-section {\n margin-bottom: 30px;\n padding: 20px;\n border: 1px solid #e0e0e0;\n border-radius: 8px;\n}\n\n.form-section h3 {\n margin-top: 0;\n color: #333;\n border-bottom: 2px solid #007bff;\n padding-bottom: 10px;\n}\n\n.form-field {\n margin-bottom: 20px;\n}\n\n.form-label {\n display: block;\n margin-bottom: 5px;\n font-weight: 600;\n color: #333;\n}\n\n.required {\n color: #dc3545;\n margin-left: 4px;\n}\n\n.form-input,\n.form-select,\n.form-textarea {\n width: 100%;\n padding: 10px;\n border: 1px solid #ddd;\n border-radius: 4px;\n font-size: 14px;\n}\n\n.form-input:focus,\n.form-select:focus,\n.form-textarea:focus {\n outline: none;\n border-color: #007bff;\n box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);\n}\n\n.checkbox {\n display: flex;\n align-items: flex-start;\n}\n\n.checkbox-label {\n display: flex;\n align-items: center;\n cursor: pointer;\n}\n\n.form-checkbox {\n margin-right: 8px;\n}\n\n.checkbox-text {\n font-weight: 500;\n}\n\n.field-description {\n margin-top: 5px;\n font-size: 12px;\n color: #666;\n}\n\n.validation-message {\n margin-top: 5px;\n font-size: 12px;\n color: #dc3545;\n}\n\n.async-validation {\n margin-top: 5px;\n font-size: 12px;\n color: #007bff;\n}\n\n.field-info {\n margin-top: 5px;\n font-size: 12px;\n color: #28a745;\n background: #f8f9fa;\n padding: 5px;\n border-radius: 3px;\n}\n\n.field-debug {\n margin-top: 5px;\n padding: 5px;\n background: #f8f9fa;\n border-radius: 3px;\n font-family: monospace;\n}\n\n.form-actions {\n margin-top: 30px;\n text-align: center;\n}\n\n.submit-button {\n background: #007bff;\n color: white;\n border: none;\n padding: 12px 30px;\n border-radius: 4px;\n font-size: 16px;\n cursor: pointer;\n transition: background-color 0.2s;\n}\n\n.submit-button:hover {\n background: #0056b3;\n}\n";
|
@@ -1,158 +0,0 @@
|
|
1
|
-
import { BaseFieldConfigOptions } from '../utils/zodExtensions';
|
2
|
-
interface UserFieldConfig extends BaseFieldConfigOptions {
|
3
|
-
dp?: Record<string, any>;
|
4
|
-
userSpecific?: {
|
5
|
-
minAge?: number;
|
6
|
-
maxAge?: number;
|
7
|
-
};
|
8
|
-
}
|
9
|
-
export declare function createUserSchema(): import("zod").ZodObject<{
|
10
|
-
name: import("zod").ZodString;
|
11
|
-
email: import("zod").ZodString;
|
12
|
-
age: import("zod").ZodOptional<import("zod").ZodNumber>;
|
13
|
-
isActive: import("zod").ZodBoolean;
|
14
|
-
role: import("zod").ZodEnum<{
|
15
|
-
[x: string]: string;
|
16
|
-
}>;
|
17
|
-
}, import("zod/v4/core/schemas.cjs").$strip> & {
|
18
|
-
fieldConfig: <TConfig = BaseFieldConfigOptions>(config: import("../utils/zodExtensions").FieldConfigOptions<TConfig>) => import("zod").ZodObject<{
|
19
|
-
name: import("zod").ZodString;
|
20
|
-
email: import("zod").ZodString;
|
21
|
-
age: import("zod").ZodOptional<import("zod").ZodNumber>;
|
22
|
-
isActive: import("zod").ZodBoolean;
|
23
|
-
role: import("zod").ZodEnum<{
|
24
|
-
[x: string]: string;
|
25
|
-
}>;
|
26
|
-
}, import("zod/v4/core/schemas.cjs").$strip>;
|
27
|
-
};
|
28
|
-
export declare function createProfileSchema(): import("zod").ZodObject<{
|
29
|
-
user: import("zod").ZodObject<{
|
30
|
-
profile: import("zod").ZodObject<{
|
31
|
-
email: import("zod").ZodString;
|
32
|
-
name: import("zod").ZodString;
|
33
|
-
}, import("zod/v4/core/schemas.cjs").$strip> & {
|
34
|
-
fieldConfig: <TConfig = BaseFieldConfigOptions>(config: import("../utils/zodExtensions").FieldConfigOptions<TConfig>) => import("zod").ZodObject<{
|
35
|
-
email: import("zod").ZodString;
|
36
|
-
name: import("zod").ZodString;
|
37
|
-
}, import("zod/v4/core/schemas.cjs").$strip>;
|
38
|
-
};
|
39
|
-
}, import("zod/v4/core/schemas.cjs").$strip> & {
|
40
|
-
fieldConfig: <TConfig_1 = BaseFieldConfigOptions>(config: import("../utils/zodExtensions").FieldConfigOptions<TConfig_1>) => import("zod").ZodObject<{
|
41
|
-
profile: import("zod").ZodObject<{
|
42
|
-
email: import("zod").ZodString;
|
43
|
-
name: import("zod").ZodString;
|
44
|
-
}, import("zod/v4/core/schemas.cjs").$strip> & {
|
45
|
-
fieldConfig: <TConfig = BaseFieldConfigOptions>(config: import("../utils/zodExtensions").FieldConfigOptions<TConfig>) => import("zod").ZodObject<{
|
46
|
-
email: import("zod").ZodString;
|
47
|
-
name: import("zod").ZodString;
|
48
|
-
}, import("zod/v4/core/schemas.cjs").$strip>;
|
49
|
-
};
|
50
|
-
}, import("zod/v4/core/schemas.cjs").$strip>;
|
51
|
-
};
|
52
|
-
}, import("zod/v4/core/schemas.cjs").$strip> & {
|
53
|
-
fieldConfig: <TConfig_2 = BaseFieldConfigOptions>(config: import("../utils/zodExtensions").FieldConfigOptions<TConfig_2>) => import("zod").ZodObject<{
|
54
|
-
user: import("zod").ZodObject<{
|
55
|
-
profile: import("zod").ZodObject<{
|
56
|
-
email: import("zod").ZodString;
|
57
|
-
name: import("zod").ZodString;
|
58
|
-
}, import("zod/v4/core/schemas.cjs").$strip> & {
|
59
|
-
fieldConfig: <TConfig = BaseFieldConfigOptions>(config: import("../utils/zodExtensions").FieldConfigOptions<TConfig>) => import("zod").ZodObject<{
|
60
|
-
email: import("zod").ZodString;
|
61
|
-
name: import("zod").ZodString;
|
62
|
-
}, import("zod/v4/core/schemas.cjs").$strip>;
|
63
|
-
};
|
64
|
-
}, import("zod/v4/core/schemas.cjs").$strip> & {
|
65
|
-
fieldConfig: <TConfig_1 = BaseFieldConfigOptions>(config: import("../utils/zodExtensions").FieldConfigOptions<TConfig_1>) => import("zod").ZodObject<{
|
66
|
-
profile: import("zod").ZodObject<{
|
67
|
-
email: import("zod").ZodString;
|
68
|
-
name: import("zod").ZodString;
|
69
|
-
}, import("zod/v4/core/schemas.cjs").$strip> & {
|
70
|
-
fieldConfig: <TConfig = BaseFieldConfigOptions>(config: import("../utils/zodExtensions").FieldConfigOptions<TConfig>) => import("zod").ZodObject<{
|
71
|
-
email: import("zod").ZodString;
|
72
|
-
name: import("zod").ZodString;
|
73
|
-
}, import("zod/v4/core/schemas.cjs").$strip>;
|
74
|
-
};
|
75
|
-
}, import("zod/v4/core/schemas.cjs").$strip>;
|
76
|
-
};
|
77
|
-
}, import("zod/v4/core/schemas.cjs").$strip>;
|
78
|
-
};
|
79
|
-
export declare function createFormSchema(): import("zod").ZodObject<{
|
80
|
-
step1: import("zod").ZodObject<{
|
81
|
-
firstName: import("zod").ZodString;
|
82
|
-
lastName: import("zod").ZodString;
|
83
|
-
}, import("zod/v4/core/schemas.cjs").$strip> & {
|
84
|
-
fieldConfig: <TConfig = BaseFieldConfigOptions>(config: import("../utils/zodExtensions").FieldConfigOptions<TConfig>) => import("zod").ZodObject<{
|
85
|
-
firstName: import("zod").ZodString;
|
86
|
-
lastName: import("zod").ZodString;
|
87
|
-
}, import("zod/v4/core/schemas.cjs").$strip>;
|
88
|
-
};
|
89
|
-
step2: import("zod").ZodObject<{
|
90
|
-
email: import("zod").ZodString;
|
91
|
-
}, import("zod/v4/core/schemas.cjs").$strip> & {
|
92
|
-
fieldConfig: <TConfig_1 = BaseFieldConfigOptions>(config: import("../utils/zodExtensions").FieldConfigOptions<TConfig_1>) => import("zod").ZodObject<{
|
93
|
-
email: import("zod").ZodString;
|
94
|
-
}, import("zod/v4/core/schemas.cjs").$strip>;
|
95
|
-
};
|
96
|
-
}, import("zod/v4/core/schemas.cjs").$strip> & {
|
97
|
-
fieldConfig: <TConfig_2 = BaseFieldConfigOptions>(config: import("../utils/zodExtensions").FieldConfigOptions<TConfig_2>) => import("zod").ZodObject<{
|
98
|
-
step1: import("zod").ZodObject<{
|
99
|
-
firstName: import("zod").ZodString;
|
100
|
-
lastName: import("zod").ZodString;
|
101
|
-
}, import("zod/v4/core/schemas.cjs").$strip> & {
|
102
|
-
fieldConfig: <TConfig = BaseFieldConfigOptions>(config: import("../utils/zodExtensions").FieldConfigOptions<TConfig>) => import("zod").ZodObject<{
|
103
|
-
firstName: import("zod").ZodString;
|
104
|
-
lastName: import("zod").ZodString;
|
105
|
-
}, import("zod/v4/core/schemas.cjs").$strip>;
|
106
|
-
};
|
107
|
-
step2: import("zod").ZodObject<{
|
108
|
-
email: import("zod").ZodString;
|
109
|
-
}, import("zod/v4/core/schemas.cjs").$strip> & {
|
110
|
-
fieldConfig: <TConfig_1 = BaseFieldConfigOptions>(config: import("../utils/zodExtensions").FieldConfigOptions<TConfig_1>) => import("zod").ZodObject<{
|
111
|
-
email: import("zod").ZodString;
|
112
|
-
}, import("zod/v4/core/schemas.cjs").$strip>;
|
113
|
-
};
|
114
|
-
}, import("zod/v4/core/schemas.cjs").$strip>;
|
115
|
-
};
|
116
|
-
export declare function createUsersArraySchema(): import("zod").ZodObject<{
|
117
|
-
users: import("zod").ZodArray<import("zod").ZodObject<{
|
118
|
-
name: import("zod").ZodString;
|
119
|
-
email: import("zod").ZodString;
|
120
|
-
}, import("zod/v4/core/schemas.cjs").$strip> & {
|
121
|
-
fieldConfig: <TConfig = BaseFieldConfigOptions>(config: import("../utils/zodExtensions").FieldConfigOptions<TConfig>) => import("zod").ZodObject<{
|
122
|
-
name: import("zod").ZodString;
|
123
|
-
email: import("zod").ZodString;
|
124
|
-
}, import("zod/v4/core/schemas.cjs").$strip>;
|
125
|
-
}>;
|
126
|
-
}, import("zod/v4/core/schemas.cjs").$strip> & {
|
127
|
-
fieldConfig: <TConfig_1 = BaseFieldConfigOptions>(config: import("../utils/zodExtensions").FieldConfigOptions<TConfig_1>) => import("zod").ZodObject<{
|
128
|
-
users: import("zod").ZodArray<import("zod").ZodObject<{
|
129
|
-
name: import("zod").ZodString;
|
130
|
-
email: import("zod").ZodString;
|
131
|
-
}, import("zod/v4/core/schemas.cjs").$strip> & {
|
132
|
-
fieldConfig: <TConfig = BaseFieldConfigOptions>(config: import("../utils/zodExtensions").FieldConfigOptions<TConfig>) => import("zod").ZodObject<{
|
133
|
-
name: import("zod").ZodString;
|
134
|
-
email: import("zod").ZodString;
|
135
|
-
}, import("zod/v4/core/schemas.cjs").$strip>;
|
136
|
-
}>;
|
137
|
-
}, import("zod/v4/core/schemas.cjs").$strip>;
|
138
|
-
};
|
139
|
-
export declare function getFieldConfiguration(): {
|
140
|
-
fieldType: "text";
|
141
|
-
} & {
|
142
|
-
label: string;
|
143
|
-
placeholder?: string | undefined;
|
144
|
-
maxLength?: number | undefined;
|
145
|
-
} & UserFieldConfig;
|
146
|
-
export declare function legacyCompatibilityExample(): import("zod").ZodObject<{
|
147
|
-
name: import("zod").ZodString & {
|
148
|
-
fieldConfig: <TConfig = BaseFieldConfigOptions>(config: import("../utils/zodExtensions").FieldConfigOptions<TConfig>) => import("zod").ZodString;
|
149
|
-
};
|
150
|
-
}, import("zod/v4/core/schemas.cjs").$strip>;
|
151
|
-
export declare function defaultTypeExample(): import("zod").ZodObject<{
|
152
|
-
simpleField: import("zod").ZodString;
|
153
|
-
}, import("zod/v4/core/schemas.cjs").$strip> & {
|
154
|
-
fieldConfig: <TConfig = BaseFieldConfigOptions>(config: import("../utils/zodExtensions").FieldConfigOptions<TConfig>) => import("zod").ZodObject<{
|
155
|
-
simpleField: import("zod").ZodString;
|
156
|
-
}, import("zod/v4/core/schemas.cjs").$strip>;
|
157
|
-
};
|
158
|
-
export {};
|
@@ -1,6 +0,0 @@
|
|
1
|
-
export declare function UserFormExample1(): import("react/jsx-runtime").JSX.Element;
|
2
|
-
export declare function UserFormExample2(): import("react/jsx-runtime").JSX.Element;
|
3
|
-
export declare function UserFormExample3(): import("react/jsx-runtime").JSX.Element;
|
4
|
-
export declare function UserFormWithHooks(): import("react/jsx-runtime").JSX.Element;
|
5
|
-
export declare function UserFormWithValidation(): import("react/jsx-runtime").JSX.Element;
|
6
|
-
export declare const styles = "\n.user-form {\n max-width: 600px;\n margin: 0 auto;\n padding: 20px;\n}\n\n.form-section {\n margin-bottom: 30px;\n padding: 20px;\n border: 1px solid #e0e0e0;\n border-radius: 8px;\n}\n\n.form-section h3 {\n margin-top: 0;\n color: #333;\n border-bottom: 2px solid #007bff;\n padding-bottom: 10px;\n}\n\n.form-field {\n margin-bottom: 20px;\n}\n\n.form-label {\n display: block;\n margin-bottom: 5px;\n font-weight: 600;\n color: #333;\n}\n\n.required {\n color: #dc3545;\n margin-left: 4px;\n}\n\n.form-input,\n.form-select,\n.form-textarea {\n width: 100%;\n padding: 10px;\n border: 1px solid #ddd;\n border-radius: 4px;\n font-size: 14px;\n}\n\n.form-input:focus,\n.form-select:focus,\n.form-textarea:focus {\n outline: none;\n border-color: #007bff;\n box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);\n}\n\n.checkbox {\n display: flex;\n align-items: flex-start;\n}\n\n.checkbox-label {\n display: flex;\n align-items: center;\n cursor: pointer;\n}\n\n.form-checkbox {\n margin-right: 8px;\n}\n\n.checkbox-text {\n font-weight: 500;\n}\n\n.field-description {\n margin-top: 5px;\n font-size: 12px;\n color: #666;\n}\n\n.validation-message {\n margin-top: 5px;\n font-size: 12px;\n color: #dc3545;\n}\n\n.async-validation {\n margin-top: 5px;\n font-size: 12px;\n color: #007bff;\n}\n\n.field-info {\n margin-top: 5px;\n font-size: 12px;\n color: #28a745;\n background: #f8f9fa;\n padding: 5px;\n border-radius: 3px;\n}\n\n.form-actions {\n margin-top: 30px;\n text-align: center;\n}\n\n.submit-button {\n background: #007bff;\n color: white;\n border: none;\n padding: 12px 30px;\n border-radius: 4px;\n font-size: 16px;\n cursor: pointer;\n transition: background-color 0.2s;\n}\n\n.submit-button:hover {\n background: #0056b3;\n}\n\n.form-data-display {\n margin-bottom: 30px;\n padding: 20px;\n background: #f8f9fa;\n border-radius: 8px;\n}\n\n.data-section {\n margin-bottom: 20px;\n}\n\n.data-section h5 {\n margin-bottom: 10px;\n color: #333;\n}\n\n.data-section pre {\n background: #fff;\n padding: 10px;\n border-radius: 4px;\n border: 1px solid #ddd;\n font-size: 12px;\n overflow-x: auto;\n}\n";
|
@@ -1,30 +0,0 @@
|
|
1
|
-
export declare function createLegacyCompatibleSchema(): import("zod").ZodObject<{
|
2
|
-
name: import("zod").ZodString & {
|
3
|
-
fieldConfig: <TConfig = import("../utils/zodExtensions").BaseFieldConfigOptions>(config: import("../utils/zodExtensions").FieldConfigOptions<TConfig>) => import("zod").ZodString;
|
4
|
-
};
|
5
|
-
email: import("zod").ZodString & {
|
6
|
-
fieldConfig: <TConfig = import("../utils/zodExtensions").BaseFieldConfigOptions>(config: import("../utils/zodExtensions").FieldConfigOptions<TConfig>) => import("zod").ZodString;
|
7
|
-
};
|
8
|
-
age: import("zod").ZodOptional<import("zod").ZodNumber & {
|
9
|
-
fieldConfig: <TConfig_1 = import("../utils/zodExtensions").BaseFieldConfigOptions>(config: import("../utils/zodExtensions").FieldConfigOptions<TConfig_1>) => import("zod").ZodNumber;
|
10
|
-
}>;
|
11
|
-
}, import("zod/v4/core/schemas.cjs").$strip>;
|
12
|
-
export declare function useLegacySchema(): any;
|
13
|
-
export declare function migrationExample(): {
|
14
|
-
oldSchema: import("zod").ZodObject<{
|
15
|
-
name: import("zod").ZodString & {
|
16
|
-
fieldConfig: <TConfig = import("../utils/zodExtensions").BaseFieldConfigOptions>(config: import("../utils/zodExtensions").FieldConfigOptions<TConfig>) => import("zod").ZodString;
|
17
|
-
};
|
18
|
-
}, import("zod/v4/core/schemas.cjs").$strip>;
|
19
|
-
newSchema: import("zod").ZodObject<{
|
20
|
-
name: import("zod").ZodString & {
|
21
|
-
fieldConfig: <TConfig = import("../utils/zodExtensions").BaseFieldConfigOptions>(config: import("../utils/zodExtensions").FieldConfigOptions<TConfig>) => import("zod").ZodString;
|
22
|
-
};
|
23
|
-
}, import("zod/v4/core/schemas.cjs").$strip> & {
|
24
|
-
fieldConfig: <TConfig_1 = import("../utils/zodExtensions").BaseFieldConfigOptions>(config: import("../utils/zodExtensions").FieldConfigOptions<TConfig_1>) => import("zod").ZodObject<{
|
25
|
-
name: import("zod").ZodString & {
|
26
|
-
fieldConfig: <TConfig = import("../utils/zodExtensions").BaseFieldConfigOptions>(config: import("../utils/zodExtensions").FieldConfigOptions<TConfig>) => import("zod").ZodString;
|
27
|
-
};
|
28
|
-
}, import("zod/v4/core/schemas.cjs").$strip>;
|
29
|
-
};
|
30
|
-
};
|
@@ -1,22 +0,0 @@
|
|
1
|
-
/// <reference types="react" />
|
2
|
-
import { ZodSchema, ComponentMapping, SchemaMappingResult } from '../types';
|
3
|
-
/**
|
4
|
-
* Main hook for schema mapping functionality
|
5
|
-
* Provides schema metadata and mapping configuration for component mapping
|
6
|
-
*/
|
7
|
-
export declare function useSchemaMapping(schema: ZodSchema, componentMapping: ComponentMapping, options?: {
|
8
|
-
defaultComponent?: React.ComponentType<any>;
|
9
|
-
transformProps?: (props: any) => any;
|
10
|
-
}): SchemaMappingResult;
|
11
|
-
/**
|
12
|
-
* Hook for getting field information by path
|
13
|
-
*/
|
14
|
-
export declare function useFieldByPath(schema: ZodSchema, path: string): any;
|
15
|
-
/**
|
16
|
-
* Hook for getting all available paths in a schema
|
17
|
-
*/
|
18
|
-
export declare function useSchemaPaths(schema: ZodSchema): any;
|
19
|
-
/**
|
20
|
-
* Hook for checking if a path exists in a schema
|
21
|
-
*/
|
22
|
-
export declare function useHasPath(schema: ZodSchema, path: string): any;
|
@@ -1,26 +0,0 @@
|
|
1
|
-
import { ZodSchema, FieldMetadata, SchemaMetadataResult } from '../types';
|
2
|
-
/**
|
3
|
-
* Hook for schema metadata functionality
|
4
|
-
* Provides utilities for extracting and working with schema metadata
|
5
|
-
*/
|
6
|
-
export declare function useSchemaMetadata(schema: ZodSchema): SchemaMetadataResult;
|
7
|
-
/**
|
8
|
-
* Hook for getting field metadata by name
|
9
|
-
*/
|
10
|
-
export declare function useFieldMetadata(schema: ZodSchema, fieldName: string): any;
|
11
|
-
/**
|
12
|
-
* Hook for getting all field metadata
|
13
|
-
*/
|
14
|
-
export declare function useAllFields(schema: ZodSchema): Record<string, any>;
|
15
|
-
/**
|
16
|
-
* Hook for getting schema structure
|
17
|
-
*/
|
18
|
-
export declare function useSchemaStructure(schema: ZodSchema): any;
|
19
|
-
/**
|
20
|
-
* Hook for getting required fields
|
21
|
-
*/
|
22
|
-
export declare function useRequiredFields(schema: ZodSchema): Record<string, FieldMetadata>;
|
23
|
-
/**
|
24
|
-
* Hook for getting optional fields
|
25
|
-
*/
|
26
|
-
export declare function useOptionalFields(schema: ZodSchema): Record<string, FieldMetadata>;
|
@@ -1,18 +0,0 @@
|
|
1
|
-
import { ZodSchema, SchemaPath, FieldMetadata, SchemaNavigationResult } from '../types';
|
2
|
-
/**
|
3
|
-
* Hook for schema navigation functionality
|
4
|
-
* Provides utilities for navigating through schema structures using dot notation paths
|
5
|
-
*/
|
6
|
-
export declare function useSchemaNavigation(schema: ZodSchema): SchemaNavigationResult;
|
7
|
-
/**
|
8
|
-
* Hook for getting a specific field by path
|
9
|
-
*/
|
10
|
-
export declare function useField(schema: ZodSchema, path: SchemaPath): FieldMetadata | null;
|
11
|
-
/**
|
12
|
-
* Hook for getting all paths in a schema
|
13
|
-
*/
|
14
|
-
export declare function usePaths(schema: ZodSchema): string[];
|
15
|
-
/**
|
16
|
-
* Hook for checking if a path exists
|
17
|
-
*/
|
18
|
-
export declare function usePathExists(schema: ZodSchema, path: SchemaPath): boolean;
|
@@ -1,26 +0,0 @@
|
|
1
|
-
import { z } from 'zod';
|
2
|
-
import { SchemaPath, PathSegment, FieldMetadata } from '../types';
|
3
|
-
/**
|
4
|
-
* Resolves a path in a Zod schema and returns the field metadata
|
5
|
-
*/
|
6
|
-
export declare function resolvePath(schema: z.ZodTypeAny, path: SchemaPath): FieldMetadata | null;
|
7
|
-
/**
|
8
|
-
* Gets all possible paths in a schema
|
9
|
-
*/
|
10
|
-
export declare function getAllPaths(schema: z.ZodTypeAny): SchemaPath[];
|
11
|
-
/**
|
12
|
-
* Validates if a path exists in the schema
|
13
|
-
*/
|
14
|
-
export declare function hasPath(schema: z.ZodTypeAny, path: SchemaPath): boolean;
|
15
|
-
/**
|
16
|
-
* Gets the schema at a specific path
|
17
|
-
*/
|
18
|
-
export declare function getSchemaAtPath(schema: z.ZodTypeAny, path: SchemaPath): z.ZodTypeAny | null;
|
19
|
-
/**
|
20
|
-
* Splits a path into segments
|
21
|
-
*/
|
22
|
-
export declare function splitPath(path: SchemaPath): PathSegment[];
|
23
|
-
/**
|
24
|
-
* Joins path segments into a path
|
25
|
-
*/
|
26
|
-
export declare function joinPath(segments: PathSegment[]): SchemaPath;
|