@@ -19,6 +19,7 @@ import { isString } from '../utils/is-string.util';
1919import { isStringArray } from '../utils/is-string-array.util' ;
2020import { isStringOrNumberArray } from '../utils/is-string-or-number-array.util' ;
2121import { isUndefined } from '../utils/is-undefined.util' ;
22+ import { operatorRequiresValue } from '../utils/operator-requires-value.util' ;
2223import { QueryRuleValue } from '../utils/query-tree' ;
2324import { removeItem } from '../utils/remove-item.util' ;
2425
@@ -93,6 +94,7 @@ export const Rule: FC<IRuleProps> = ({
9394 value : item ,
9495 label : ( strings . operators && strings . operators [ item ] ) || item ,
9596 } ) ) ;
97+ const shouldRenderValueInput = operatorRequiresValue ( operator ) ;
9698
9799 return (
98100 < RuleContainer
@@ -104,14 +106,24 @@ export const Rule: FC<IRuleProps> = ({
104106 >
105107 < FieldSelect selectedValue = { field } id = { id } />
106108
107- { type === 'BOOLEAN' && isBoolean ( selectedValue ) && (
108- < BooleanContainer >
109- < Boolean id = { id } selectedValue = { selectedValue } />
110- </ BooleanContainer >
109+ { type === 'BOOLEAN' && (
110+ < >
111+ { isOptionList ( operatorsOptionList ) && (
112+ < OperatorSelect
113+ id = { id }
114+ values = { operatorsOptionList }
115+ selectedValue = { operator }
116+ />
117+ ) }
118+ { shouldRenderValueInput && isBoolean ( selectedValue ) && (
119+ < BooleanContainer >
120+ < Boolean id = { id } selectedValue = { selectedValue } />
121+ </ BooleanContainer >
122+ ) }
123+ </ >
111124 ) }
112125
113126 { type === 'LIST' &&
114- isString ( selectedValue ) &&
115127 isOptionList ( fieldValue ) &&
116128 isOptionList ( operatorsOptionList ) && (
117129 < >
@@ -120,7 +132,7 @@ export const Rule: FC<IRuleProps> = ({
120132 values = { operatorsOptionList }
121133 selectedValue = { operator }
122134 />
123- { operator && (
135+ { operator && shouldRenderValueInput && isString ( selectedValue ) && (
124136 < Select
125137 id = { id }
126138 selectedValue = { selectedValue }
@@ -132,15 +144,16 @@ export const Rule: FC<IRuleProps> = ({
132144
133145 { type === 'MULTI_LIST' &&
134146 isOptionList ( fieldValue ) &&
135- isOptionList ( operatorsOptionList ) &&
136- isStringArray ( selectedValue ) && (
147+ isOptionList ( operatorsOptionList ) && (
137148 < >
138149 < OperatorSelect
139150 id = { id }
140151 values = { operatorsOptionList }
141152 selectedValue = { operator }
142153 />
143- { operator && (
154+ { operator &&
155+ shouldRenderValueInput &&
156+ isStringArray ( selectedValue ) && (
144157 < SelectMulti
145158 id = { id }
146159 values = { fieldValue }
@@ -150,49 +163,51 @@ export const Rule: FC<IRuleProps> = ({
150163 </ >
151164 ) }
152165
153- { type === 'TEXT' &&
154- isOptionList ( operatorsOptionList ) &&
155- ( isString ( selectedValue ) || isStringArray ( selectedValue ) ) && (
166+ { type === 'TEXT' && isOptionList ( operatorsOptionList ) && (
156167 < >
157168 < OperatorSelect
158169 id = { id }
159170 values = { operatorsOptionList }
160171 selectedValue = { operator }
161172 />
162- { operator && < Input type = "text" value = { selectedValue } id = { id } /> }
173+ { operator &&
174+ shouldRenderValueInput &&
175+ ( isString ( selectedValue ) || isStringArray ( selectedValue ) ) && (
176+ < Input type = "text" value = { selectedValue } id = { id } />
177+ ) }
163178 </ >
164179 ) }
165180
166- { type === 'NUMBER' &&
167- isOptionList ( operatorsOptionList ) &&
168- ( isString ( selectedValue ) ||
169- isNumber ( selectedValue ) ||
170- isStringOrNumberArray ( selectedValue ) ||
171- isNumberArray ( selectedValue ) ) && (
181+ { type === 'NUMBER' && isOptionList ( operatorsOptionList ) && (
172182 < >
173183 < OperatorSelect
174184 id = { id }
175185 values = { operatorsOptionList }
176186 selectedValue = { operator }
177187 />
178- { operator && (
188+ { operator &&
189+ shouldRenderValueInput &&
190+ ( isString ( selectedValue ) ||
191+ isNumber ( selectedValue ) ||
192+ isStringOrNumberArray ( selectedValue ) ||
193+ isNumberArray ( selectedValue ) ) && (
179194 < Input type = "number" value = { selectedValue } id = { id } />
180- ) }
195+ ) }
181196 </ >
182197 ) }
183198
184- { type === 'DATE' &&
185- isOptionList ( operatorsOptionList ) &&
186- ( isString ( selectedValue ) || isStringArray ( selectedValue ) ) && (
199+ { type === 'DATE' && isOptionList ( operatorsOptionList ) && (
187200 < >
188201 < OperatorSelect
189202 id = { id }
190203 values = { operatorsOptionList }
191204 selectedValue = { operator }
192205 />
193- { ! isUndefined ( operator ) && (
206+ { ! isUndefined ( operator ) &&
207+ shouldRenderValueInput &&
208+ ( isString ( selectedValue ) || isStringArray ( selectedValue ) ) && (
194209 < Input type = "date" value = { selectedValue } id = { id } />
195- ) }
210+ ) }
196211 </ >
197212 ) }
198213 </ RuleContainer >
0 commit comments