@form-instant/react-resolver-zod 1.18.12 → 2.0.0-rc.1

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.
Files changed (34) hide show
  1. package/dist/components/FormInstantProvider.d.ts +10 -0
  2. package/dist/components/SchemaMapper.d.ts +24 -0
  3. package/dist/examples/completeExample.d.ts +6 -0
  4. package/dist/examples/fieldConfigExample.d.ts +158 -0
  5. package/dist/examples/formInstantExample.d.ts +6 -0
  6. package/dist/examples/legacyCompatibility.d.ts +30 -0
  7. package/dist/hooks/useSchemaMapping.d.ts +22 -0
  8. package/dist/hooks/useSchemaMetadata.d.ts +26 -0
  9. package/dist/hooks/useSchemaNavigation.d.ts +18 -0
  10. package/dist/index.d.ts +5 -6
  11. package/dist/index.js +2 -7
  12. package/dist/index.js.map +13 -0
  13. package/dist/types.d.ts +48 -0
  14. package/dist/utils/pathResolver.d.ts +26 -0
  15. package/dist/utils/schemaParser.d.ts +19 -0
  16. package/dist/utils/zodExtensions.d.ts +974 -0
  17. package/package.json +57 -58
  18. package/dist/context.d.ts +0 -2
  19. package/dist/funcs/default-values.d.ts +0 -4
  20. package/dist/funcs/field-config.d.ts +0 -11
  21. package/dist/funcs/field-type-inference.d.ts +0 -3
  22. package/dist/funcs/index.d.ts +0 -5
  23. package/dist/funcs/schema-parser.d.ts +0 -2
  24. package/dist/funcs/types.d.ts +0 -11
  25. package/dist/provider.d.ts +0 -6
  26. package/dist/react-resolver-zod.cjs.development.js +0 -416
  27. package/dist/react-resolver-zod.cjs.development.js.map +0 -1
  28. package/dist/react-resolver-zod.cjs.production.min.js +0 -2
  29. package/dist/react-resolver-zod.cjs.production.min.js.map +0 -1
  30. package/dist/react-resolver-zod.esm.js +0 -401
  31. package/dist/react-resolver-zod.esm.js.map +0 -1
  32. package/dist/type.d.ts +0 -2
  33. package/dist/useSchema.d.ts +0 -14
  34. /package/dist/{element.d.ts → components/FormInstantElement.d.ts} +0 -0
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { zodResolverProps } from 'types';
3
+ export declare const ZodResolverContext: import("react").Context<any>;
4
+ export declare const FormInstantProvider: FCC<{
5
+ schema: zodResolverProps;
6
+ }>;
7
+ /**
8
+ * Hook to get a specific field by name from the schema
9
+ */
10
+ export declare const useFields: <Sc extends Record<string, any>>(key: keyof Sc) => any;
@@ -0,0 +1,24 @@
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;
@@ -0,0 +1,6 @@
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";
@@ -0,0 +1,158 @@
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 {};
@@ -0,0 +1,6 @@
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";
@@ -0,0 +1,30 @@
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
+ };
@@ -0,0 +1,22 @@
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;
@@ -0,0 +1,26 @@
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>;
@@ -0,0 +1,18 @@
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;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- export * from './context';
2
- export * from './element';
3
- export * from './funcs';
4
- export * from './provider';
5
- export * from './type';
6
- export * from './useSchema';
1
+ export { FormInstantProvider, useFields } from './components/FormInstantProvider';
2
+ export { FormInstantElement } from './components/FormInstantElement';
3
+ export * from './types';
4
+ export * from './utils/schemaParser';
5
+ export * from './utils/zodExtensions';
package/dist/index.js CHANGED
@@ -1,8 +1,3 @@
1
+ import{createContext as N,useContext as z}from"react";import{z as Y}from"zod";function T(B){return B._zod?.def?.type||"unknown"}function F(B){let J=B?._fieldConfig;if(!J)return;return J}function E(B){let J={},_=[],w={};function A(U){if(U instanceof Y.ZodObject)return U.shape;if(U instanceof Y.ZodDiscriminatedUnion){let K=U.options;if(K.length>0)return A(K[0])}return{}}function L(U,K,R="",H=w){let V=F(K),q=R?`${R}.${U}`:U,P=V?.fieldType||T(K),v=K instanceof Y.ZodOptional,Z=K instanceof Y.ZodDefault,y=!v&&!Z,O=void 0;if(Z)try{let Q=K.safeParse(void 0);if(Q.success)O=Q.data}catch{}else try{let Q=K.safeParse(void 0);if(Q.success)O=Q.data}catch{}let x=(()=>{if(K instanceof Y.ZodEnum)return K.options.map((Q)=>[String(Q),String(Q)]);if(K.constructor.name==="ZodNativeEnum")return K.options.map(($)=>[String($),String($)]);return[]})(),I={name:{current:U,history:q},fieldType:P,required:y,default:O,fieldConfig:V,options:x};if(J[q]=I,_.push(q),H[U]=I,K instanceof Y.ZodObject){let Q=K.shape,$={};H[U]=$,Object.keys(Q).forEach((G)=>{L(G,Q[G],q,$)})}if(K instanceof Y.ZodArray){let Q=K.element;if(Q instanceof Y.ZodObject){let $={};H[U]=$;let G=Q.shape;Object.keys(G).forEach((M)=>{L(M,G[M],`${q}[0]`,$)})}}}let D=A(B);return Object.keys(D).forEach((U)=>{L(U,D[U])}),{fields:J}}function d(B){return T(B)}function f(B){let J=B instanceof Y.ZodOptional,_=B instanceof Y.ZodDefault;return!J&&!_}function n(B){try{let J=B.safeParse(void 0);return J.success?J.data:void 0}catch{return}}import{jsx as S}from"react/jsx-runtime";var b=N(null),g=({children:B,schema:J})=>{return S(b.Provider,{value:J,children:B})},k=(B)=>{let J=z(b);if(!J)throw new Error("useFields must be used within FormInstantProvider");let{fields:_}=E(J);return _[B]};import{ElementMapping as j}from"@form-instant/react-input-mapping";import{useId as p}from"react";import{jsx as W,Fragment as C}from"react/jsx-runtime";var u=({name:B})=>{let J=k(B),_=p();if(!["object"].includes(J.fieldType))return W(j,{formProps:J});return W(C,{children:Object.values(J.schema||{}).map((w)=>{return W(C,{children:W(j,{formProps:w})},`${_}-${w.name?.history||""}`)})})};import{z as X}from"zod";function o(){let B=Object.getPrototypeOf(X.string());return Object.defineProperty(B,"fieldConfig",{value:function(w){return this._fieldConfig=w,this},writable:!0,configurable:!0}),{...X,...{object:(w)=>{let A=X.object(w);return Object.assign(A,{fieldConfig:(L)=>{return A._fieldConfig=L,A}})},array:(w)=>{let A=X.array(w);return Object.assign(A,{fieldConfig:(L)=>{return A._fieldConfig=L,A}})},string:()=>{let w=X.string();return Object.assign(w,{fieldConfig:(A)=>{return w._fieldConfig=A,w}})},email:()=>{let w=X.string();return Object.assign(w,{fieldConfig:(A)=>{return w._fieldConfig=A,w}})},number:()=>{let w=X.number();return Object.assign(w,{fieldConfig:(A)=>{return w._fieldConfig=A,w}})},boolean:()=>{let w=X.boolean();return Object.assign(w,{fieldConfig:(A)=>{return w._fieldConfig=A,w}})},date:()=>{let w=X.date();return Object.assign(w,{fieldConfig:(A)=>{return w._fieldConfig=A,w}})},enum:(w)=>{let A=X.enum(w);return Object.assign(A,{fieldConfig:(L)=>{return A._fieldConfig=L,A}})},union:(w)=>{let A=X.union(w);return Object.assign(A,{fieldConfig:(L)=>{return A._fieldConfig=L,A}})},optional:(w)=>{let A=X.optional(w);if(w.fieldConfig)Object.assign(A,{fieldConfig:w.fieldConfig,_fieldConfig:w._fieldConfig});else Object.assign(A,{fieldConfig:(L)=>{return A._fieldConfig=L,A}});return A},nullable:(w)=>{let A=X.nullable(w);if(w.fieldConfig)Object.assign(A,{fieldConfig:w.fieldConfig,_fieldConfig:w._fieldConfig});else Object.assign(A,{fieldConfig:(L)=>{return A._fieldConfig=L,A}});return A}}}}var Jw=o();function Kw(B){return B._fieldConfig}function Lw(B,J){return B._fieldConfig=J,B}export{Jw as zExtended,Jw as z,k as useFields,Lw as setFieldConfig,E as parseSchema,f as isFieldRequired,d as getFieldType,Kw as getFieldConfig,n as getDefaultValue,o as extendZodWithFieldConfig,g as FormInstantProvider,u as FormInstantElement};
1
2
 
2
- 'use strict'
3
-
4
- if (process.env.NODE_ENV === 'production') {
5
- module.exports = require('./react-resolver-zod.cjs.production.min.js')
6
- } else {
7
- module.exports = require('./react-resolver-zod.cjs.development.js')
8
- }
3
+ //# debugId=14376D9A28A58F7264756E2164756E21
@@ -0,0 +1,13 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/components/FormInstantProvider.tsx", "../src/utils/schemaParser.ts", "../src/components/FormInstantElement.tsx", "../src/utils/zodExtensions.ts"],
4
+ "sourcesContent": [
5
+ "import { 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",
6
+ "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,\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\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",
7
+ "'use client';\nimport { ElementMapping } from '@form-instant/react-input-mapping';\nimport { Fragment, useId } from 'react';\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",
8
+ "import { z } from 'zod';\n\n// Base field configuration options interface\nexport interface BaseFieldConfigOptions {\n [key: string]: any; // Allow additional custom properties\n}\n\n// Generic field configuration options that extends the base\nexport type FieldConfigOptions<T = BaseFieldConfigOptions> = T & BaseFieldConfigOptions;\n\n// Function to extend Zod globally with fieldConfig method\nexport function extendZodWithFieldConfig() {\n // Extend the base ZodType prototype to add fieldConfig method\n const zodTypePrototype = Object.getPrototypeOf(z.string());\n\n // Add fieldConfig method to all Zod schemas\n Object.defineProperty(zodTypePrototype, 'fieldConfig', {\n value: function <TConfig = BaseFieldConfigOptions>(config: FieldConfigOptions<TConfig>) {\n (this as any)._fieldConfig = config;\n return this;\n },\n writable: true,\n configurable: true,\n });\n\n // Create extended constructors that automatically add fieldConfig\n const extendedConstructors = {\n object: <T extends z.ZodRawShape>(shape: T) => {\n const schema = z.object(shape);\n return Object.assign(schema, {\n fieldConfig: <TConfig = BaseFieldConfigOptions>(\n config: FieldConfigOptions<TConfig>,\n ) => {\n (schema as any)._fieldConfig = config;\n return schema;\n },\n });\n },\n array: <T extends z.ZodTypeAny>(element: T) => {\n const schema = z.array(element);\n return Object.assign(schema, {\n fieldConfig: <TConfig = BaseFieldConfigOptions>(\n config: FieldConfigOptions<TConfig>,\n ) => {\n (schema as any)._fieldConfig = config;\n return schema;\n },\n });\n },\n string: () => {\n const schema = z.string();\n return Object.assign(schema, {\n fieldConfig: <TConfig = BaseFieldConfigOptions>(\n config: FieldConfigOptions<TConfig>,\n ) => {\n (schema as any)._fieldConfig = config;\n return schema;\n },\n });\n },\n email: () => {\n const schema = z.string();\n return Object.assign(schema, {\n fieldConfig: <TConfig = BaseFieldConfigOptions>(\n config: FieldConfigOptions<TConfig>,\n ) => {\n (schema as any)._fieldConfig = config;\n return schema;\n },\n });\n },\n number: () => {\n const schema = z.number();\n return Object.assign(schema, {\n fieldConfig: <TConfig = BaseFieldConfigOptions>(\n config: FieldConfigOptions<TConfig>,\n ) => {\n (schema as any)._fieldConfig = config;\n return schema;\n },\n });\n },\n boolean: () => {\n const schema = z.boolean();\n return Object.assign(schema, {\n fieldConfig: <TConfig = BaseFieldConfigOptions>(\n config: FieldConfigOptions<TConfig>,\n ) => {\n (schema as any)._fieldConfig = config;\n return schema;\n },\n });\n },\n date: () => {\n const schema = z.date();\n return Object.assign(schema, {\n fieldConfig: <TConfig = BaseFieldConfigOptions>(\n config: FieldConfigOptions<TConfig>,\n ) => {\n (schema as any)._fieldConfig = config;\n return schema;\n },\n });\n },\n enum: <T extends [string, ...string[]]>(values: T) => {\n const schema = z.enum(values);\n return Object.assign(schema, {\n fieldConfig: <TConfig = BaseFieldConfigOptions>(\n config: FieldConfigOptions<TConfig>,\n ) => {\n (schema as any)._fieldConfig = config;\n return schema;\n },\n });\n },\n union: <T extends [z.ZodTypeAny, z.ZodTypeAny, ...z.ZodTypeAny[]]>(types: T) => {\n const schema = z.union(types);\n return Object.assign(schema, {\n fieldConfig: <TConfig = BaseFieldConfigOptions>(\n config: FieldConfigOptions<TConfig>,\n ) => {\n (schema as any)._fieldConfig = config;\n return schema;\n },\n });\n },\n optional: <T extends z.ZodTypeAny>(schema: T) => {\n const optionalSchema = z.optional(schema);\n // Preserve fieldConfig from the original schema\n if ((schema as any).fieldConfig) {\n Object.assign(optionalSchema, {\n fieldConfig: (schema as any).fieldConfig,\n _fieldConfig: (schema as any)._fieldConfig,\n });\n } else {\n Object.assign(optionalSchema, {\n fieldConfig: <TConfig = BaseFieldConfigOptions>(\n config: FieldConfigOptions<TConfig>,\n ) => {\n (optionalSchema as any)._fieldConfig = config;\n return optionalSchema;\n },\n });\n }\n return optionalSchema;\n },\n nullable: <T extends z.ZodTypeAny>(schema: T) => {\n const nullableSchema = z.nullable(schema);\n // Preserve fieldConfig from the original schema\n if ((schema as any).fieldConfig) {\n Object.assign(nullableSchema, {\n fieldConfig: (schema as any).fieldConfig,\n _fieldConfig: (schema as any)._fieldConfig,\n });\n } else {\n Object.assign(nullableSchema, {\n fieldConfig: <TConfig = BaseFieldConfigOptions>(\n config: FieldConfigOptions<TConfig>,\n ) => {\n (nullableSchema as any)._fieldConfig = config;\n return nullableSchema;\n },\n });\n }\n return nullableSchema;\n },\n };\n\n // Create extended Zod instance\n const zExtended = {\n ...z,\n ...extendedConstructors,\n };\n\n return zExtended;\n}\n\n// Initialize the extended Zod instance\nexport const zExtended = extendZodWithFieldConfig();\n\n// Export the extended Zod instance as the default\nexport { zExtended as z };\n\n// Helper function to get field configuration from a schema\nexport function getFieldConfig<T = BaseFieldConfigOptions>(\n schema: z.ZodTypeAny,\n): FieldConfigOptions<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 = BaseFieldConfigOptions>(\n schema: z.ZodTypeAny,\n config: FieldConfigOptions<T>,\n): z.ZodTypeAny {\n (schema as any)._fieldConfig = config;\n return schema;\n}\n"
9
+ ],
10
+ "mappings": "AAAA,wBAAS,gBAAe,cCAxB,YAAS,YAIT,SAAS,CAAa,CAAC,EAA8B,CACjD,OAAO,EAAO,MAAM,KAAK,MAAQ,UAMrC,SAAS,CAAkB,CAAC,EAAsB,CAC9C,IAAM,EAAe,GAAgB,aACrC,IAAK,EAAa,OAElB,OAAO,EAMJ,SAAS,CAAW,CAAC,EAAuD,CAC/E,IAAM,EAAwC,CAAC,EACzC,EAAsB,CAAC,EACvB,EAAiC,CAAC,EAExC,SAAS,CAAY,CAAC,EAA2C,CAE7D,GAAI,aAAkB,EAAE,UACpB,OAAO,EAAO,MAIlB,GAAI,aAAkB,EAAE,sBAAuB,CAE3C,IAAM,EAAU,EAAO,QACvB,GAAI,EAAQ,OAAS,EACjB,OAAO,EAAa,EAAQ,EAAkB,EAItD,MAAO,CAAC,EAGZ,SAAS,CAAY,CACjB,EACA,EACA,EAAqB,GACrB,EAAuC,EACzC,CAEE,IAAM,EAAc,EAAmB,CAAW,EAC5C,EAAc,EAAa,GAAG,KAAc,IAAc,EAC1D,EAAY,GAAa,WAAa,EAAc,CAAW,EAG/D,EAAa,aAAuB,EAAE,YACtC,EAAa,aAAuB,EAAE,WACtC,GAAc,IAAe,EAG/B,EAAoB,OACxB,GAAI,EAEA,GAAI,CACA,IAAM,EAAS,EAAY,UAAU,MAAS,EAC9C,GAAI,EAAO,QACP,EAAe,EAAO,KAE5B,KAAM,EAIR,QAAI,CACA,IAAM,EAAS,EAAY,UAAU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AAM,EAAiB,EAAE,SAAS,CAAM,EAExC,GAAK,EAAe,YAChB,OAAO,OAAO,EAAgB,CAC1B,YAAc,EAAe,YAC7B,aAAe,EAAe,YAClC,CAAC,EAED,YAAO,OAAO,EAAgB,CAC1B,YAAa,CACT,IACC,CAED,OADC,EAAuB,aAAe,EAChC,EAEf,CAAC,EAEL,OAAO,GAEX,SAAU,CAAyB,IAAc,CAC7C,IAAM,EAAiB,EAAE,SAAS,CAAM,EAExC,GAAK,EAAe,YAChB,OAAO,OAAO,EAAgB,CAC1B,YAAc,EAAe,YAC7B,aAAe,EAAe,YAClC,CAAC,EAED,YAAO,OAAO,EAAgB,CAC1B,YAAa,CACT,IACC,CAED,OADC,EAAuB,aAAe,EAChC,EAEf,CAAC,EAEL,OAAO,EAEf,CAMA,EAMG,IAAM,GAAY,EAAyB,EAM3C,SAAS,EAA0C,CACtD,EACiC,CACjC,OAAQ,EAAe,aAIpB,SAAS,EAA0C,CACtD,EACA,EACY,CAEZ,OADC,EAAe,aAAe,EACxB",
11
+ "debugId": "14376D9A28A58F7264756E2164756E21",
12
+ "names": []
13
+ }
@@ -0,0 +1,48 @@
1
+ import { ParsedField } from '@form-instant/react-input-mapping';
2
+ import { ReactNode } from 'react';
3
+ export type ZodSchema = any;
4
+ export type ComponentMapping = Record<string, React.ComponentType<any>>;
5
+ export type SchemaPath = string;
6
+ export type PathSegment = string;
7
+ export type FieldConfig<Ob, K extends keyof Ob = keyof Ob> = {
8
+ fieldType: K;
9
+ } & Ob[K];
10
+ export type FieldMetadata = ParsedField<any, string>;
11
+ export interface SchemaMetadata {
12
+ fields: Record<string, FieldMetadata>;
13
+ paths: SchemaPath[];
14
+ structure: Record<string, any>;
15
+ }
16
+ export interface MappingConfig {
17
+ componentMapping: ComponentMapping;
18
+ defaultComponent?: React.ComponentType<any>;
19
+ transformProps?: (props: any) => any;
20
+ }
21
+ export interface SchemaMappingResult {
22
+ schema: ZodSchema;
23
+ metadata: SchemaMetadata;
24
+ mappingConfig: MappingConfig;
25
+ }
26
+ export interface SchemaNavigationResult {
27
+ navigate: (path: SchemaPath) => FieldMetadata | null;
28
+ getField: (path: SchemaPath) => FieldMetadata | null;
29
+ getPaths: () => SchemaPath[];
30
+ hasPath: (path: SchemaPath) => boolean;
31
+ }
32
+ export interface SchemaMetadataResult {
33
+ metadata: SchemaMetadata;
34
+ getField: (path: SchemaPath) => FieldMetadata | null;
35
+ getPaths: () => SchemaPath[];
36
+ getStructure: () => Record<string, any>;
37
+ }
38
+ export type zodResolverProps = ZodSchema;
39
+ export interface SchemaMapperProps {
40
+ schema: ZodSchema;
41
+ componentMapping: ComponentMapping;
42
+ defaultComponent?: React.ComponentType<any>;
43
+ transformProps?: (props: any) => any;
44
+ children?: ReactNode;
45
+ }
46
+ export interface ElementProps<Schema extends Record<string, any>> {
47
+ name: keyof Schema;
48
+ }
@@ -0,0 +1,26 @@
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;
@@ -0,0 +1,19 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Parses a Zod schema and extracts metadata for mapping
4
+ */
5
+ export declare function parseSchema(schema: z.ZodTypeAny): {
6
+ fields: Record<string, any>;
7
+ };
8
+ /**
9
+ * Gets the field type from a Zod schema
10
+ */
11
+ export declare function getFieldType(schema: z.ZodTypeAny): string;
12
+ /**
13
+ * Checks if a field is required
14
+ */
15
+ export declare function isFieldRequired(schema: z.ZodTypeAny): boolean;
16
+ /**
17
+ * Gets the default value for a field
18
+ */
19
+ export declare function getDefaultValue(schema: z.ZodTypeAny): any;