@@ -93,7 +93,14 @@ export const FilterConditionSchema = z
9393 . describe ( FieldOptions . of ( { direction : "row" , special : "column_filter" } ) ) ;
9494export type FilterConditionType = z . infer < typeof FilterConditionSchema > ;
9595
96- export const FilterGroupSchema : z . ZodType = z . lazy ( ( ) =>
96+ export interface FilterGroupType {
97+ type : "group" ;
98+ operator : "and" | "or" ;
99+ children : ( FilterConditionType | FilterGroupType ) [ ] ;
100+ negate : boolean ;
101+ }
102+
103+ export const FilterGroupSchema : z . ZodType < FilterGroupType > = z . lazy ( ( ) =>
97104 z . object ( {
98105 type : z . literal ( "group" ) . default ( "group" ) ,
99106 operator : z . enum ( [ "and" , "or" ] ) . default ( "and" ) ,
@@ -103,7 +110,6 @@ export const FilterGroupSchema: z.ZodType = z.lazy(() =>
103110 negate : z . boolean ( ) . default ( false ) ,
104111 } ) ,
105112) ;
106- export type FilterGroupType = z . infer < typeof FilterGroupSchema > ;
107113
108114const FilterRowsTransformSchema = z . object ( {
109115 type : z . literal ( "filter_rows" ) ,
@@ -115,6 +121,15 @@ const FilterRowsTransformSchema = z.object({
115121 . array ( FilterConditionSchema )
116122 . min ( 1 )
117123 . describe ( FieldOptions . of ( { label : "Value" , minLength : 1 } ) )
124+ . default ( ( ) => [
125+ {
126+ column_id : "" as ColumnId ,
127+ operator : "==" as const ,
128+ value : "" ,
129+ type : "condition" as const ,
130+ negate : false ,
131+ } ,
132+ ] )
118133 . transform ( ( value ) : FilterGroupType => {
119134 const validConditions = value . filter ( ( condition ) => {
120135 return isConditionValueValid ( condition . operator , condition . value ) ;
@@ -125,16 +140,7 @@ const FilterRowsTransformSchema = z.object({
125140 children : validConditions ,
126141 negate : false ,
127142 } ;
128- } )
129- . default ( ( ) => [
130- {
131- column_id : "" as ColumnId ,
132- operator : "==" as const ,
133- value : "" ,
134- type : "condition" as const ,
135- negate : false ,
136- } ,
137- ] ) ,
143+ } ) ,
138144} ) ;
139145
140146const GroupByTransformSchema = z
0 commit comments