@@ -140,6 +140,7 @@ function getNumberInputs(
140140 handleValueChange : ( e : React . ChangeEvent < HTMLInputElement > ) => void ,
141141 handleStartValueChange : ( e : React . ChangeEvent < HTMLInputElement > ) => void ,
142142 handleEndValueChange : ( e : React . ChangeEvent < HTMLInputElement > ) => void ,
143+ isInvalid : boolean ,
143144 conditionValue ?: string ,
144145 startValue ?: string ,
145146 endValue ?: string
@@ -154,7 +155,7 @@ function getNumberInputs(
154155 return (
155156 < input
156157 type = "number"
157- className = " form-control"
158+ className = { ` form-control ${ isInvalid ? 'is-invalid' : '' } ` }
158159 placeholder = "Enter value"
159160 value = { conditionValue ?? '' }
160161 onChange = { handleValueChange }
@@ -165,14 +166,16 @@ function getNumberInputs(
165166 < div className = "d-flex flex-row" >
166167 < input
167168 type = "number"
168- className = "form-control d-flex mr-2"
169+ className = { `form-control d-flex mr-2 ${
170+ isInvalid ? 'is-invalid' : ''
171+ } `}
169172 placeholder = "Start value"
170173 value = { startValue ?? '' }
171174 onChange = { handleStartValueChange }
172175 />
173176 < input
174177 type = "number"
175- className = " form-control d-flex"
178+ className = { ` form-control d-flex ${ isInvalid ? 'is-invalid' : '' } ` }
176179 placeholder = "End value"
177180 value = { endValue ?? '' }
178181 onChange = { handleEndValueChange }
@@ -188,6 +191,7 @@ function getNumberInputs(
188191function getStringInputs (
189192 selectedCondition : StringCondition ,
190193 handleValueChange : ( e : React . ChangeEvent < HTMLInputElement > ) => void ,
194+ isInvalid : boolean ,
191195 conditionValue ?: string
192196) : JSX . Element | null {
193197 switch ( selectedCondition ) {
@@ -198,7 +202,7 @@ function getStringInputs(
198202 return (
199203 < input
200204 type = "text"
201- className = " form-control"
205+ className = { ` form-control ${ isInvalid ? 'is-invalid' : '' } ` }
202206 placeholder = "Enter value"
203207 value = { conditionValue ?? '' }
204208 onChange = { handleValueChange }
@@ -210,6 +214,7 @@ function getStringInputs(
210214function getDateInputs (
211215 selectedCondition : DateCondition ,
212216 handleValueChange : ( e : React . ChangeEvent < HTMLInputElement > ) => void ,
217+ isInvalid : boolean ,
213218 conditionValue ?: string
214219) : JSX . Element | null {
215220 switch ( selectedCondition ) {
@@ -220,7 +225,7 @@ function getDateInputs(
220225 return (
221226 < input
222227 type = "text"
223- className = " form-control"
228+ className = { ` form-control ${ isInvalid ? 'is-invalid' : '' } ` }
224229 placeholder = "Enter value"
225230 value = { conditionValue ?? '' }
226231 onChange = { handleValueChange }
@@ -236,6 +241,7 @@ function getBooleanInputs(): null {
236241function getCharInputs (
237242 selectedCondition : CharCondition ,
238243 handleValueChange : ( e : React . ChangeEvent < HTMLInputElement > ) => void ,
244+ isInvalid : boolean ,
239245 conditionValue ?: string
240246) : JSX . Element | null {
241247 switch ( selectedCondition ) {
@@ -246,7 +252,7 @@ function getCharInputs(
246252 return (
247253 < input
248254 type = "text"
249- className = " form-control"
255+ className = { ` form-control ${ isInvalid ? 'is-invalid' : '' } ` }
250256 maxLength = { 1 }
251257 placeholder = "Enter value"
252258 value = { conditionValue ?? '' }
@@ -264,6 +270,7 @@ function ConditionEditor(props: ConditionEditorProps): JSX.Element {
264270 const [ conditionValue , setValue ] = useState ( config . value ) ;
265271 const [ startValue , setStartValue ] = useState ( config . start ) ;
266272 const [ endValue , setEndValue ] = useState ( config . end ) ;
273+ const [ isValid , setIsValid ] = useState ( true ) ;
267274
268275 if ( selectedColumnType !== prevColumnType ) {
269276 // Column type changed, reset condition and value fields
@@ -329,13 +336,13 @@ function ConditionEditor(props: ConditionEditorProps): JSX.Element {
329336
330337 useEffect (
331338 function changeCondition ( ) {
332- let isValid = true ;
339+ let isConditionValid = true ;
333340
334341 if ( selectedCondition === undefined ) {
335342 log . debug (
336343 'Unable to create formatting rule. Condition is not selected.'
337344 ) ;
338- isValid = false ;
345+ isConditionValid = false ;
339346 } else if (
340347 TableUtils . isNumberType ( column . type ) &&
341348 ! isNumberConditionValid (
@@ -349,7 +356,7 @@ function ConditionEditor(props: ConditionEditorProps): JSX.Element {
349356 'Unable to create formatting rule. Invalid value' ,
350357 conditionValue
351358 ) ;
352- isValid = false ;
359+ isConditionValid = false ;
353360 } else if (
354361 TableUtils . isDateType ( column . type ) &&
355362 ! isDateConditionValid (
@@ -362,17 +369,18 @@ function ConditionEditor(props: ConditionEditorProps): JSX.Element {
362369 'Unable to create formatting rule. Invalid date condition' ,
363370 conditionValue
364371 ) ;
365- isValid = false ;
372+ isConditionValid = false ;
366373 }
367374
375+ setIsValid ( isConditionValid ) ;
368376 onChange (
369377 {
370378 condition : selectedCondition ,
371379 value : conditionValue ,
372380 start : startValue ,
373381 end : endValue ,
374382 } ,
375- isValid
383+ isConditionValid
376384 ) ;
377385 } ,
378386 [
@@ -397,6 +405,7 @@ function ConditionEditor(props: ConditionEditorProps): JSX.Element {
397405 handleValueChange ,
398406 handleStartValueChange ,
399407 handleEndValueChange ,
408+ ! isValid ,
400409 conditionValue ,
401410 startValue ,
402411 endValue
@@ -406,20 +415,23 @@ function ConditionEditor(props: ConditionEditorProps): JSX.Element {
406415 return getCharInputs (
407416 selectedCondition as CharCondition ,
408417 handleValueChange ,
418+ ! isValid ,
409419 conditionValue
410420 ) ;
411421 }
412422 if ( TableUtils . isStringType ( selectedColumnType ) ) {
413423 return getStringInputs (
414424 selectedCondition as StringCondition ,
415425 handleValueChange ,
426+ ! isValid ,
416427 conditionValue
417428 ) ;
418429 }
419430 if ( TableUtils . isDateType ( selectedColumnType ) ) {
420431 return getDateInputs (
421432 selectedCondition as DateCondition ,
422433 handleValueChange ,
434+ ! isValid ,
423435 conditionValue
424436 ) ;
425437 }
@@ -432,6 +444,7 @@ function ConditionEditor(props: ConditionEditorProps): JSX.Element {
432444 conditionValue ,
433445 startValue ,
434446 endValue ,
447+ isValid ,
435448 handleValueChange ,
436449 handleStartValueChange ,
437450 handleEndValueChange ,
0 commit comments