@@ -47,7 +47,7 @@ def __init__(self, *args, **kwargs):
4747
4848 @staticmethod
4949 def format_prop (
50- prop : Union [Var , EventChain , ComponentStyle , PropCond , str ],
50+ prop : Union [Var , EventChain , ComponentStyle , str ],
5151 ) -> Union [int , float , str ]:
5252 """Format a prop.
5353
@@ -71,10 +71,6 @@ def format_prop(
7171 events = "," .join ([utils .format_event (event ) for event in prop .events ])
7272 prop = f"({ local_args } ) => Event([{ events } ])"
7373
74- # Handle conditional props.
75- elif isinstance (prop , PropCond ):
76- return str (prop )
77-
7874 # Handle other types.
7975 elif isinstance (prop , str ):
8076 if utils .is_wrapped (prop , "{" ):
@@ -89,7 +85,7 @@ def format_prop(
8985 if isinstance (prop , dict ):
9086 # Convert any var keys to strings.
9187 prop = {
92- key : str (val ) if isinstance (val , ( Var , PropCond ) ) else val
88+ key : str (val ) if isinstance (val , Var ) else val
9389 for key , val in prop .items ()
9490 }
9591
@@ -188,54 +184,3 @@ def is_valid_prop(prop: Optional[Var]) -> bool:
188184 Whether the prop is valid.
189185 """
190186 return prop is not None and not (isinstance (prop , dict ) and len (prop ) == 0 )
191-
192-
193- class PropCond (Base ):
194- """A conditional prop."""
195-
196- # The condition to determine which prop to render.
197- cond : Var [Any ]
198-
199- # The prop to render if the condition is true.
200- prop1 : Any
201-
202- # The prop to render if the condition is false.
203- prop2 : Any
204-
205- @classmethod
206- def create (cls , cond : Var , prop1 : Any , prop2 : Any ):
207- """Create a conditional Prop.
208-
209- Args:
210- cond: The cond to determine which prop to render.
211- prop1: The prop value to render if the cond is true.
212- prop2: The prop value to render if the cond is false.
213-
214- Returns:
215- The conditional Prop.
216-
217- Raises:
218- ValueError: If the condition or prop values are not set.
219- """
220- if cond is None :
221- raise ValueError ("The condition must be set." )
222- if prop1 is None or prop2 is None :
223- raise ValueError ("Both prop values must be set." )
224- return cls (
225- cond = cond ,
226- prop1 = prop1 ,
227- prop2 = prop2 ,
228- )
229-
230- def __str__ (self ) -> str :
231- """Render the prop as a React string.
232-
233- Returns:
234- The React code to render the prop.
235- """
236- return utils .format_cond (
237- cond = self .cond .full_name ,
238- true_value = self .prop1 ,
239- false_value = self .prop2 ,
240- is_prop = True ,
241- )
0 commit comments