@connect-soft/form-generator 1.0.0-alpha

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.
@@ -0,0 +1,2 @@
1
+ /* Form Generator - Global Styles */
2
+ /* This file can be imported to include base form styles */
@@ -0,0 +1,12 @@
1
+ import { BaseField, FormItem } from '@/lib';
2
+ export interface FieldRendererProps {
3
+ field: BaseField;
4
+ namePrefix?: string;
5
+ }
6
+ export declare const FieldRenderer: import("react").MemoExoticComponent<({ field, namePrefix }: FieldRendererProps) => import("react/jsx-runtime").JSX.Element | null>;
7
+ export interface FormItemRendererProps {
8
+ item: FormItem;
9
+ namePrefix?: string;
10
+ }
11
+ export declare const FormItemRenderer: import("react").MemoExoticComponent<({ item, namePrefix }: FormItemRendererProps) => import("react/jsx-runtime").JSX.Element | null>;
12
+ //# sourceMappingURL=field-renderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-renderer.d.ts","sourceRoot":"","sources":["../../../../src/components/form/field-renderer.tsx"],"names":[],"mappings":"AAEA,OAAO,EAKH,SAAS,EACT,QAAQ,EAIX,MAAM,OAAO,CAAC;AAMf,MAAM,WAAW,kBAAkB;IAC/B,KAAK,EAAE,SAAS,CAAC;IAEjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,aAAa,8DAAgC,kBAAkB,oDAsF1E,CAAC;AAgFH,MAAM,WAAW,qBAAqB;IAClC,IAAI,EAAE,QAAQ,CAAC;IAEf,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,gBAAgB,6DAA+B,qBAAqB,oDAmB/E,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { z } from 'zod';
2
+ import { FormItem } from '@/lib';
3
+ export interface FormGeneratorProps<TFields extends readonly FormItem[]> {
4
+ fields: TFields;
5
+ onSubmit: (values: Record<string, any>) => void | Promise<void>;
6
+ defaultValues?: Record<string, any>;
7
+ schema?: z.ZodType<any>;
8
+ className?: string;
9
+ submitText?: string;
10
+ disabled?: boolean;
11
+ mode?: 'onChange' | 'onBlur' | 'onSubmit' | 'onTouched' | 'all';
12
+ }
13
+ export declare function FormGenerator<TFields extends readonly FormItem[]>({ fields, onSubmit, defaultValues, schema: userSchema, className, submitText, disabled, mode }: FormGeneratorProps<TFields>): import("react/jsx-runtime").JSX.Element;
14
+ //# sourceMappingURL=form-generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-generator.d.ts","sourceRoot":"","sources":["../../../../src/components/form/form-generator.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAIH,QAAQ,EAIX,MAAM,OAAO,CAAC;AA2Lf,MAAM,WAAW,kBAAkB,CAAC,OAAO,SAAS,SAAS,QAAQ,EAAE;IACnE,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACpC,MAAM,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,UAAU,GAAG,QAAQ,GAAG,UAAU,GAAG,WAAW,GAAG,KAAK,CAAC;CACnE;AAED,wBAAgB,aAAa,CAAC,OAAO,SAAS,SAAS,QAAQ,EAAE,EAAE,EAC/D,MAAM,EACN,QAAQ,EACR,aAAa,EACb,MAAM,EAAE,UAAU,EAClB,SAAS,EACT,UAAqB,EACrB,QAAQ,EACR,IAAiB,EACpB,EAAE,kBAAkB,CAAC,OAAO,CAAC,2CA6C7B"}
@@ -0,0 +1,5 @@
1
+ export { FieldRenderer, FormItemRenderer } from './field-renderer';
2
+ export type { FieldRendererProps, FormItemRendererProps } from './field-renderer';
3
+ export { FormGenerator } from './form-generator';
4
+ export type { FormGeneratorProps } from './form-generator';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/form/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACnE,YAAY,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAElF,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,15 @@
1
+ export { FormGenerator } from './components/form/form-generator';
2
+ export type { FormGeneratorProps } from './components/form/form-generator';
3
+ export { FieldRenderer } from './components/form/field-renderer';
4
+ export type { FieldRendererProps } from './components/form/field-renderer';
5
+ export * from './lib/field-types';
6
+ export { registerField, registerFields, getFieldComponent, hasFieldType, unregisterField, getRegisteredFieldTypes, clearFieldRegistry } from './lib/field-registry';
7
+ export type { FieldComponentProps, FieldComponent, RegistrationConfig } from './lib/field-registry';
8
+ export { registerFormComponents, registerFormComponent, getFormComponent, hasFormComponent, getFormComponents, clearFormComponentRegistry, resetFormComponentRegistry, clearAllRegistries } from './lib/field-registry';
9
+ export type { FormComponents, FormItemProps, FormInputLabelWrapperProps, FormLabelProps, FormDescriptionProps, FormMessageProps, SubmitButtonProps } from './lib/field-registry';
10
+ export { registerLayoutComponents, registerLayoutComponent, getLayoutComponent, hasLayoutComponent, clearLayoutRegistry } from './lib/field-registry';
11
+ export type { LayoutComponents, ColumnsLayoutProps, SectionLayoutProps } from './lib/field-registry';
12
+ export { useForm, useFormContext, useWatch, useFieldArray, Controller, FormProvider } from 'react-hook-form';
13
+ export type { FieldValues, UseFormReturn, FieldPath, ControllerRenderProps } from 'react-hook-form';
14
+ export { z } from 'zod';
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,YAAY,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,YAAY,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAG3E,cAAc,mBAAmB,CAAC;AAGlC,OAAO,EACH,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,uBAAuB,EACvB,kBAAkB,EACrB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,mBAAmB,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAGpG,OAAO,EACH,sBAAsB,EACtB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,0BAA0B,EAC1B,0BAA0B,EAC1B,kBAAkB,EACrB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACR,cAAc,EACd,aAAa,EACb,0BAA0B,EAC1B,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,EACpB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACH,wBAAwB,EACxB,uBAAuB,EACvB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACtB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAGrG,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,aAAa,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC7G,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAGpG,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC"}
@@ -0,0 +1,114 @@
1
+ import { z } from 'zod';
2
+ import type { BaseField, ColumnsLayout, SectionLayout, FormItem } from './field-types';
3
+ import type { ComponentType, ReactNode, Ref } from 'react';
4
+ export type ValidatorFactory<TField extends BaseField = BaseField> = (field: TField) => z.ZodType<any>;
5
+ export interface FieldState {
6
+ invalid: boolean;
7
+ error?: {
8
+ type: string;
9
+ message?: string;
10
+ };
11
+ isDirty: boolean;
12
+ isTouched: boolean;
13
+ }
14
+ export interface FieldComponentProps<TField extends BaseField = BaseField> {
15
+ field: TField;
16
+ formField: {
17
+ value: any;
18
+ onChange: (value: any) => void;
19
+ onBlur: () => void;
20
+ name: string;
21
+ ref: Ref<any>;
22
+ };
23
+ fieldState: FieldState;
24
+ }
25
+ export type FieldComponent<TField extends BaseField = BaseField> = ComponentType<FieldComponentProps<TField>>;
26
+ export interface FieldRegistrationOptions {
27
+ className?: string;
28
+ labelClassName?: string;
29
+ inputLabelWrapper?: string;
30
+ inputLabelWrapperOrientation?: FormInputLabelWrapperProps['orientation'];
31
+ descriptionClassName?: string;
32
+ messageClassName?: string;
33
+ validator?: ValidatorFactory<any>;
34
+ }
35
+ export interface FormItemProps {
36
+ className?: string;
37
+ children: ReactNode;
38
+ }
39
+ export interface FormInputLabelWrapperProps {
40
+ className?: string;
41
+ orientation?: 'horizontal' | 'vertical';
42
+ children: ReactNode;
43
+ }
44
+ export interface FormLabelProps {
45
+ className?: string;
46
+ children: ReactNode;
47
+ required?: boolean;
48
+ htmlFor?: string;
49
+ }
50
+ export interface FormDescriptionProps {
51
+ className?: string;
52
+ children: ReactNode;
53
+ }
54
+ export interface FormMessageProps {
55
+ className?: string;
56
+ name: string;
57
+ }
58
+ export interface SubmitButtonProps {
59
+ className?: string;
60
+ children: ReactNode;
61
+ disabled?: boolean;
62
+ isSubmitting?: boolean;
63
+ }
64
+ export interface FormComponents {
65
+ FormItem: ComponentType<FormItemProps>;
66
+ FormInputLabelWrapper: ComponentType<FormInputLabelWrapperProps>;
67
+ FormLabel: ComponentType<FormLabelProps>;
68
+ FormDescription: ComponentType<FormDescriptionProps>;
69
+ FormMessage: ComponentType<FormMessageProps>;
70
+ SubmitButton: ComponentType<SubmitButtonProps>;
71
+ }
72
+ export interface ColumnsLayoutProps {
73
+ layout: ColumnsLayout;
74
+ renderItem: (item: FormItem, index: number) => ReactNode;
75
+ }
76
+ export interface SectionLayoutProps {
77
+ layout: SectionLayout;
78
+ renderItem: (item: FormItem, index: number) => ReactNode;
79
+ }
80
+ export interface LayoutComponents {
81
+ Columns: ComponentType<ColumnsLayoutProps>;
82
+ Section: ComponentType<SectionLayoutProps>;
83
+ }
84
+ export interface RegistrationConfig {
85
+ override?: boolean | 'only';
86
+ }
87
+ export declare function registerField<TField extends BaseField>(type: TField['type'], component: FieldComponent<TField>, options?: FieldRegistrationOptions, config?: RegistrationConfig): void;
88
+ export type FieldDefinition = FieldComponent<any> | {
89
+ component: FieldComponent<any>;
90
+ options?: FieldRegistrationOptions;
91
+ };
92
+ export declare function registerFields(fields: Record<string, FieldDefinition>, config?: RegistrationConfig): void;
93
+ export declare function getFieldComponent<TField extends BaseField>(type: string): FieldComponent<TField>;
94
+ export declare function getFieldClassName(type: string): string | undefined;
95
+ export declare function getFieldOptions(type: string): FieldRegistrationOptions | undefined;
96
+ export declare function getFieldValidator(type: string): ValidatorFactory<any> | undefined;
97
+ export declare function hasFieldType(type: string): boolean;
98
+ export declare function unregisterField(type: string): boolean;
99
+ export declare function getRegisteredFieldTypes(): string[];
100
+ export declare function registerFormComponents(components: Partial<FormComponents>, config?: RegistrationConfig): void;
101
+ export declare function registerFormComponent<K extends keyof FormComponents>(name: K, component: FormComponents[K], config?: RegistrationConfig): void;
102
+ export declare function getFormComponent<K extends keyof FormComponents>(name: K): FormComponents[K];
103
+ export declare function hasFormComponent(name: keyof FormComponents): boolean;
104
+ export declare function getFormComponents(): Partial<FormComponents>;
105
+ export declare function registerLayoutComponents(components: Partial<LayoutComponents>, config?: RegistrationConfig): void;
106
+ export declare function registerLayoutComponent<K extends keyof LayoutComponents>(name: K, component: LayoutComponents[K], config?: RegistrationConfig): void;
107
+ export declare function getLayoutComponent<K extends keyof LayoutComponents>(name: K): LayoutComponents[K] | undefined;
108
+ export declare function hasLayoutComponent(name: keyof LayoutComponents): boolean;
109
+ export declare function clearLayoutRegistry(): void;
110
+ export declare function clearFieldRegistry(): void;
111
+ export declare function clearFormComponentRegistry(): void;
112
+ export declare function resetFormComponentRegistry(): void;
113
+ export declare function clearAllRegistries(): void;
114
+ //# sourceMappingURL=field-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-registry.d.ts","sourceRoot":"","sources":["../../../src/lib/field-registry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACvF,OAAO,KAAK,EAAe,aAAa,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAKxE,MAAM,MAAM,gBAAgB,CAAC,MAAM,SAAS,SAAS,GAAG,SAAS,IAAI,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AAKvG,MAAM,WAAW,UAAU;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE;QACJ,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;CACtB;AAKD,MAAM,WAAW,mBAAmB,CAAC,MAAM,SAAS,SAAS,GAAG,SAAS;IACrE,KAAK,EAAE,MAA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,CAAC,CAAC,SAAS,MAAM,cAAc,EAAE,IAAI,EAAE,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAE3F;AAKD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,cAAc,GAAG,OAAO,CAEpE;AAKD,wBAAgB,iBAAiB,IAAI,OAAO,CAAC,cAAc,CAAC,CAE3D;AAkCD,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,OAAO,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAE,kBAAuB,GAAG,IAAI,CAYrH;AAKD,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,MAAM,gBAAgB,EACpE,IAAI,EAAE,CAAC,EACP,SAAS,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAC9B,MAAM,GAAE,kBAAuB,GAChC,IAAI,CASN;AAKD,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,MAAM,gBAAgB,EAAE,IAAI,EAAE,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,GAAG,SAAS,CAE7G;AAKD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,gBAAgB,GAAG,OAAO,CAExE;AAKD,wBAAgB,mBAAmB,IAAI,IAAI,CAI1C;AASD,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC;AAKD,wBAAgB,0BAA0B,IAAI,IAAI,CAIjD;AAKD,wBAAgB,0BAA0B,IAAI,IAAI,CAGjD;AAKD,wBAAgB,kBAAkB,IAAI,IAAI,CAIzC"}
@@ -0,0 +1,50 @@
1
+ import { z } from 'zod';
2
+ export interface BaseField<TType extends string = string, TValue = any> {
3
+ type: TType;
4
+ name: string;
5
+ label?: string;
6
+ description?: string;
7
+ required?: boolean;
8
+ disabled?: boolean;
9
+ hidden?: boolean;
10
+ defaultValue?: TValue;
11
+ validation?: z.ZodType<TValue>;
12
+ className?: string;
13
+ }
14
+ export interface FieldOption {
15
+ label: string;
16
+ value: string;
17
+ disabled?: boolean;
18
+ }
19
+ export type CreateFieldType<TType extends string, TValue = any, TProps extends Record<string, any> = Record<string, never>> = BaseField<TType, TValue> & TProps;
20
+ export type Field = BaseField<string, any> & Record<string, any>;
21
+ export interface BaseLayout<TType extends string = string> {
22
+ type: TType;
23
+ name?: string;
24
+ hidden?: boolean;
25
+ className?: string;
26
+ wrapFieldNames?: boolean;
27
+ }
28
+ export interface ColumnConfig {
29
+ title?: string;
30
+ width?: string | number;
31
+ children: FormItem[];
32
+ className?: string;
33
+ }
34
+ export interface ColumnsLayout extends BaseLayout<'columns'> {
35
+ type: 'columns';
36
+ columns: ColumnConfig[];
37
+ gap?: string | number;
38
+ }
39
+ export interface SectionLayout extends BaseLayout<'section'> {
40
+ type: 'section';
41
+ title?: string;
42
+ children: FormItem[];
43
+ }
44
+ export type LayoutBlock = ColumnsLayout | SectionLayout;
45
+ export type FormItem = Field | LayoutBlock;
46
+ export declare function isLayoutBlock(item: FormItem): item is LayoutBlock;
47
+ export type InferFormValues<Fields extends readonly BaseField[]> = {
48
+ [K in Fields[number] as K['name']]: K extends BaseField<any, infer V> ? V : any;
49
+ };
50
+ //# sourceMappingURL=field-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-types.d.ts","sourceRoot":"","sources":["../../../src/lib/field-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,MAAM,WAAW,SAAS,CAAC,KAAK,SAAS,MAAM,GAAG,MAAM,EAAE,MAAM,GAAG,GAAG;IAClE,IAAI,EAAE,KAAK,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,CAAC,C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SAAS,CAAC;IAEhB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,QAAQ,EAAE,QAAQ,EAAE,CAAC;CACxB;AAKD,MAAM,MAAM,WAAW,GAAG,aAAa,GAAG,aAAa,CAAC;AAKxD,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,WAAW,CAAC;AAK3C,wBAAgB,aAAa,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,IAAI,WAAW,CAEjE;AAKD,MAAM,MAAM,eAAe,CAAC,MAAM,SAAS,SAAS,SAAS,EAAE,IAAI;KAC9D,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,GAAG;CAClF,CAAC"}
@@ -0,0 +1,8 @@
1
+ export * from './field-types';
2
+ export { registerField, registerFields, getFieldComponent, getFieldClassName, getFieldOptions, getFieldValidator, hasFieldType, unregisterField, getRegisteredFieldTypes, clearFieldRegistry } from './field-registry';
3
+ export type { FieldComponentProps, FieldComponent, FieldRegistrationOptions, FieldDefinition, ValidatorFactory, FieldState } from './field-registry';
4
+ export { registerFormComponents, registerFormComponent, getFormComponent, hasFormComponent, getFormComponents, clearFormComponentRegistry, clearAllRegistries } from './field-registry';
5
+ export type { FormComponents, FormItemProps, FormLabelProps, FormDescriptionProps, FormMessageProps, SubmitButtonProps } from './field-registry';
6
+ export { registerLayoutComponents, registerLayoutComponent, getLayoutComponent, hasLayoutComponent, clearLayoutRegistry } from './field-registry';
7
+ export type { LayoutComponents, ColumnsLayoutProps, SectionLayoutProps } from './field-registry';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":"AACA,cAAc,eAAe,CAAC;AAG9B,OAAO,EACH,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,uBAAuB,EACvB,kBAAkB,EACrB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACR,mBAAmB,EACnB,cAAc,EACd,wBAAwB,EACxB,eAAe,EACf,gBAAgB,EAChB,UAAU,EACb,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACH,sBAAsB,EACtB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,0BAA0B,EAC1B,kBAAkB,EACrB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACR,cAAc,EACd,aAAa,EACb,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,EACpB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACH,wBAAwB,EACxB,uBAAuB,EACvB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACtB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,2 @@
1
+ import '@testing-library/jest-dom';
2
+ //# sourceMappingURL=setupTests.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setupTests.d.ts","sourceRoot":"","sources":["../../src/setupTests.ts"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC"}
package/package.json ADDED
@@ -0,0 +1,99 @@
1
+ {
2
+ "name": "@connect-soft/form-generator",
3
+ "version": "1.0.0-alpha",
4
+ "description": "Type-safe form generator with Radix UI, Tailwind CSS, and react-hook-form",
5
+ "author": "Lukáš Černý <lukas.cerny@connect-soft.cz>",
6
+ "license": "ISC",
7
+ "main": "dist/index.js",
8
+ "module": "dist/index.m.js",
9
+ "types": "dist/types/index.d.ts",
10
+ "sideEffects": [
11
+ "*.css"
12
+ ],
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/types/index.d.ts",
16
+ "import": "./dist/index.m.js",
17
+ "require": "./dist/index.js"
18
+ },
19
+ "./styles": "./dist/styles/globals.css",
20
+ "./advanced": {
21
+ "types": "./dist/types/components/ui/advanced/index.d.ts",
22
+ "import": "./dist/components/ui/advanced/index.m.js",
23
+ "require": "./dist/components/ui/advanced/index.js"
24
+ },
25
+ "./adapters": {
26
+ "types": "./dist/types/adapters/index.d.ts",
27
+ "import": "./dist/adapters/index.m.js",
28
+ "require": "./dist/adapters/index.js"
29
+ }
30
+ },
31
+ "files": [
32
+ "dist",
33
+ "README.md",
34
+ "MIGRATION.md"
35
+ ],
36
+ "keywords": [
37
+ "react",
38
+ "radix-ui",
39
+ "tailwind",
40
+ "shadcn",
41
+ "form",
42
+ "forms",
43
+ "form-generator",
44
+ "form-validation",
45
+ "validation",
46
+ "typescript",
47
+ "react-hooks",
48
+ "react-hook-form"
49
+ ],
50
+ "peerDependencies": {
51
+ "react": "^19.0.0",
52
+ "react-dom": "^19.0.0",
53
+ "zod": "^4.0.0"
54
+ },
55
+ "dependencies": {
56
+ "@hookform/resolvers": "^5.2.1",
57
+ "react-hook-form": "^7.55.0"
58
+ },
59
+ "devDependencies": {
60
+ "@testing-library/jest-dom": "^6.9.1",
61
+ "@testing-library/react": "^16.3.0",
62
+ "@types/jest": "^29.5.0",
63
+ "@types/react": "^19.0.0",
64
+ "@types/react-dom": "^19.0.0",
65
+ "@typescript-eslint/eslint-plugin": "^6.0.0",
66
+ "@typescript-eslint/parser": "^6.0.0",
67
+ "eslint": "^8.56.0",
68
+ "eslint-config-airbnb-typescript": "^17.1.0",
69
+ "eslint-config-prettier": "^9.1.0",
70
+ "eslint-import-resolver-typescript": "^3.6.1",
71
+ "eslint-plugin-hooks": "^0.4.3",
72
+ "eslint-plugin-import": "^2.29.1",
73
+ "eslint-plugin-jest": "^27.6.2",
74
+ "eslint-plugin-jsx-a11y": "^6.8.0",
75
+ "eslint-plugin-prettier": "^5.1.3",
76
+ "eslint-plugin-react": "^7.33.2",
77
+ "eslint-plugin-react-hooks": "^4.6.0",
78
+ "eslint-plugin-testing-library": "^6.2.0",
79
+ "jest": "^29.7.0",
80
+ "jest-environment-jsdom": "^29.7.0",
81
+ "prettier": "^3.0.0",
82
+ "ts-jest": "^29.1.0",
83
+ "typescript": "^5.8.3"
84
+ },
85
+ "scripts": {
86
+ "clean": "rimraf dist",
87
+ "prebuild": "pnpm clean",
88
+ "build": "rollup --config rollup.config.cjs && tsc -p tsconfig.build.json && mkdir -p dist/styles && cp src/styles/globals.css dist/styles/",
89
+ "type": "tsc --noEmit -p tsconfig.build.json",
90
+ "test": "jest",
91
+ "test:watch": "jest --watch",
92
+ "test:coverage": "jest --coverage",
93
+ "lint": "eslint --ext .ts,.tsx src/",
94
+ "lint:fix": "eslint --ext .ts,.tsx src/ --fix",
95
+ "format": "prettier --check \"src/**/*.{ts,tsx}\"",
96
+ "format:fix": "prettier --write \"src/**/*.{ts,tsx}\"",
97
+ "verify": "pnpm format && pnpm lint && pnpm type"
98
+ }
99
+ }