11import React , { useEffect , useImperativeHandle , useState } from "react" ;
22import Validator , { ValidationError } from "fastest-validator" ;
3- import { FormActions , FormItem , FormState , EntryProps , OnChangeFn , RenderProps , CascadeFormProps } from "./CascadeForms.types" ;
3+ import { FormActions , FormItem , FormState , EntryProps , RenderProps , CascadeFormProps } from "./CascadeForms.types" ;
44
55export * from "./CascadeForms.types" ;
66
@@ -26,9 +26,7 @@ const Entry : React.FC<EntryProps> = ({ item,formState,onUpdate,onRender }) => {
2626 const res = check ( { [ item . id ] :value } ) as ValidationError [ ] ;
2727 if ( res . length )
2828 err = res . map ( ( e ) => e . message ) . join ( "," ) ;
29- console . log ( "VALIDATIOM" , res ) ;
3029 }
31- console . log ( { [ id ] :value , state } ) ;
3230 setState ( { ...formState ,
3331 [ id ] :{
3432 value,
@@ -71,7 +69,6 @@ const CascadeForms = React.forwardRef<FormActions,CascadeFormProps>(({ form,form
7169 const getState = ( ) => {
7270 let res = { } ;
7371 const iterate = ( item :FormItem ) => {
74- console . log ( "Processing" , item ?. id ) ;
7572 if ( isVisible ( item , formState ) ) {
7673 res = {
7774 ...res ,
@@ -85,7 +82,6 @@ const CascadeForms = React.forwardRef<FormActions,CascadeFormProps>(({ form,form
8582 iterate ( item ) ;
8683 } ) ;
8784 } ;
88- console . log ( "Gettting state" , formState ) ;
8985 form . forEach ( iterate ) ;
9086 return Object . entries ( res ) . reduce ( ( agg , [ key , val ] ) => {
9187 if ( ! val )
@@ -107,16 +103,5 @@ const CascadeForms = React.forwardRef<FormActions,CascadeFormProps>(({ form,form
107103} ) ;
108104
109105CascadeForms . displayName = "CascadeForms" ;
110- /*
111- function DynaForm<T>(props:CascadeFormProps) {
112- const { form,formState,onRender, onUpdate } = props;
113- const view = React.useMemo(()=>{
114- if ( !form?.length )
115- return <div>empty</div>;
116- return <Render formState={formState} items={form} onUpdate={onUpdate} onRender={onRender} />;
117- },[form,formState]);
118- return <div>{view}</div>;
119- }
120- */
121106
122107export default CascadeForms ;
0 commit comments