Explorar el Código

Updated radio group component (#3474)

Sagar Hedaoo hace 11 meses
padre
commit
6fdc5a84db
Se han modificado 1 ficheros con 20 adiciones y 5 borrados
  1. 20 5
      reflex/components/radix/themes/components/radio_group.py

+ 20 - 5
reflex/components/radix/themes/components/radio_group.py

@@ -25,10 +25,12 @@ class RadioGroupRoot(RadixThemesComponent):
     tag = "RadioGroup.Root"
 
     # The size of the radio group: "1" | "2" | "3"
-    size: Var[Literal["1", "2", "3"]]
+    size: Var[Literal["1", "2", "3"]] = Var.create_safe("2", _var_is_string=True)
 
     # The variant of the radio group
-    variant: Var[Literal["classic", "surface", "soft"]]
+    variant: Var[Literal["classic", "surface", "soft"]] = Var.create_safe(
+        "classic", _var_is_string=True
+    )
 
     # The color of the radio group
     color_scheme: Var[LiteralAccentColor]
@@ -80,7 +82,9 @@ class HighLevelRadioGroup(RadixThemesComponent):
     items: Var[List[str]]
 
     # The direction of the radio group.
-    direction: Var[LiteralFlexDirection]
+    direction: Var[LiteralFlexDirection] = Var.create_safe(
+        "column", _var_is_string=True
+    )
 
     # The gap between the items of the radio group.
     spacing: Var[LiteralSpacing] = Var.create_safe("2", _var_is_string=True)
@@ -89,7 +93,9 @@ class HighLevelRadioGroup(RadixThemesComponent):
     size: Var[Literal["1", "2", "3"]] = Var.create_safe("2", _var_is_string=True)
 
     # The variant of the radio group
-    variant: Var[Literal["classic", "surface", "soft"]]
+    variant: Var[Literal["classic", "surface", "soft"]] = Var.create_safe(
+        "classic", _var_is_string=True
+    )
 
     # The color of the radio group
     color_scheme: Var[LiteralAccentColor]
@@ -133,8 +139,12 @@ class HighLevelRadioGroup(RadixThemesComponent):
         direction = props.pop("direction", "column")
         spacing = props.pop("spacing", "2")
         size = props.pop("size", "2")
+        variant = props.pop("variant", "classic")
+        color_scheme = props.pop("color_scheme", None)
         default_value = props.pop("default_value", "")
 
+        default_value = Var.create(default_value)
+
         # convert only non-strings to json(JSON.stringify) so quotes are not rendered
         # for string literal types.
         if isinstance(default_value, str) or (
@@ -158,7 +168,10 @@ class HighLevelRadioGroup(RadixThemesComponent):
 
             return Text.create(
                 Flex.create(
-                    RadioGroupItem.create(value=item_value),
+                    RadioGroupItem.create(
+                        value=item_value,
+                        disabled=props.get("disabled", Var.create(False)),
+                    ),
                     item_value,
                     spacing="2",
                 ),
@@ -176,6 +189,8 @@ class HighLevelRadioGroup(RadixThemesComponent):
                 spacing=spacing,
             ),
             size=size,
+            variant=variant,
+            color_scheme=color_scheme,
             default_value=default_value,
             **props,
         )