Remove dropdown menu sub content extra props (#2582)

This commit is contained in:
Tom Gotsman 2024-02-12 15:19:05 -08:00 committed by GitHub
parent 0da21ea605
commit 71e4d539f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 75 additions and 47 deletions

View File

@ -11,11 +11,11 @@ from reflex.vars import Var
from ..base import ( from ..base import (
LiteralAccentColor, LiteralAccentColor,
LiteralSize, LiteralSize,
LiteralVariant,
RadixThemesComponent, RadixThemesComponent,
) )
LiteralCheckboxSize = Literal["1", "2", "3"] LiteralCheckboxSize = Literal["1", "2", "3"]
LiteralCheckboxVariant = Literal["classic", "surface", "soft"]
class Checkbox(RadixThemesComponent): class Checkbox(RadixThemesComponent):
@ -26,16 +26,16 @@ class Checkbox(RadixThemesComponent):
# Change the default rendered element for the one passed as a child, merging their props and behavior. # Change the default rendered element for the one passed as a child, merging their props and behavior.
as_child: Var[bool] as_child: Var[bool]
# Button size "1" - "3" # Checkbox size "1" - "3"
size: Var[LiteralCheckboxSize] size: Var[LiteralCheckboxSize]
# Variant of button: "solid" | "soft" | "outline" | "ghost" # Variant of checkbox: "classic" | "surface" | "soft"
variant: Var[LiteralVariant] variant: Var[LiteralCheckboxVariant]
# Override theme color for button # Override theme color for checkbox
color_scheme: Var[LiteralAccentColor] color_scheme: Var[LiteralAccentColor]
# Whether to render the button with higher contrast color against background # Whether to render the checkbox with higher contrast color against background
high_contrast: Var[bool] high_contrast: Var[bool]
# Whether the checkbox is checked by default # Whether the checkbox is checked by default
@ -71,18 +71,64 @@ class Checkbox(RadixThemesComponent):
} }
class HighLevelCheckbox(Checkbox): class HighLevelCheckbox(RadixThemesComponent):
"""A checkbox component with a label.""" """A checkbox component with a label."""
tag = "Checkbox"
# The text label for the checkbox. # The text label for the checkbox.
text: Var[str] text: Var[str]
# The gap between the checkbox and the label. # The gap between the checkbox and the label.
gap: Var[LiteralSize] gap: Var[LiteralSize]
# The size of the checkbox. # The size of the checkbox "1" - "3".
size: Var[LiteralCheckboxSize] size: Var[LiteralCheckboxSize]
# Change the default rendered element for the one passed as a child, merging their props and behavior.
as_child: Var[bool]
# Variant of checkbox: "classic" | "surface" | "soft"
variant: Var[LiteralCheckboxVariant]
# Override theme color for checkbox
color_scheme: Var[LiteralAccentColor]
# Whether to render the checkbox with higher contrast color against background
high_contrast: Var[bool]
# Whether the checkbox is checked by default
default_checked: Var[bool]
# Whether the checkbox is checked
checked: Var[bool]
# Whether the checkbox is disabled
disabled: Var[bool]
# Whether the checkbox is required
required: Var[bool]
# The name of the checkbox control when submitting the form.
name: Var[str]
# The value of the checkbox control when submitting the form.
value: Var[str]
# Props to rename
_rename_props = {"onChange": "onCheckedChange"}
def get_event_triggers(self) -> Dict[str, Any]:
"""Get the events triggers signatures for the component.
Returns:
The signatures of the event triggers.
"""
return {
**super().get_event_triggers(),
EventTriggers.ON_CHANGE: lambda e0: [e0],
}
@classmethod @classmethod
def create(cls, text: Var[str] = Var.create_safe(""), **props) -> Component: def create(cls, text: Var[str] = Var.create_safe(""), **props) -> Component:
"""Create a checkbox with a label. """Create a checkbox with a label.

View File

@ -14,9 +14,10 @@ from reflex.components.radix.themes.layout.flex import Flex
from reflex.components.radix.themes.typography.text import Text from reflex.components.radix.themes.typography.text import Text
from reflex.constants import EventTriggers from reflex.constants import EventTriggers
from reflex.vars import Var from reflex.vars import Var
from ..base import LiteralAccentColor, LiteralSize, LiteralVariant, RadixThemesComponent from ..base import LiteralAccentColor, LiteralSize, RadixThemesComponent
LiteralCheckboxSize = Literal["1", "2", "3"] LiteralCheckboxSize = Literal["1", "2", "3"]
LiteralCheckboxVariant = Literal["classic", "surface", "soft"]
class Checkbox(RadixThemesComponent): class Checkbox(RadixThemesComponent):
def get_event_triggers(self) -> Dict[str, Any]: ... def get_event_triggers(self) -> Dict[str, Any]: ...
@ -94,8 +95,8 @@ class Checkbox(RadixThemesComponent):
] = None, ] = None,
variant: Optional[ variant: Optional[
Union[ Union[
Var[Literal["classic", "solid", "soft", "surface", "outline", "ghost"]], Var[Literal["classic", "surface", "soft"]],
Literal["classic", "solid", "soft", "surface", "outline", "ghost"], Literal["classic", "surface", "soft"],
] ]
] = None, ] = None,
high_contrast: Optional[Union[Var[bool], bool]] = None, high_contrast: Optional[Union[Var[bool], bool]] = None,
@ -172,9 +173,9 @@ class Checkbox(RadixThemesComponent):
color: map to CSS default color property. color: map to CSS default color property.
color_scheme: map to radix color property. color_scheme: map to radix color property.
as_child: Change the default rendered element for the one passed as a child, merging their props and behavior. as_child: Change the default rendered element for the one passed as a child, merging their props and behavior.
size: Button size "1" - "3" size: Checkbox size "1" - "3"
variant: Variant of button: "solid" | "soft" | "outline" | "ghost" variant: Variant of checkbox: "classic" | "surface" | "soft"
high_contrast: Whether to render the button with higher contrast color against background high_contrast: Whether to render the checkbox with higher contrast color against background
default_checked: Whether the checkbox is checked by default default_checked: Whether the checkbox is checked by default
checked: Whether the checkbox is checked checked: Whether the checkbox is checked
disabled: Whether the checkbox is disabled disabled: Whether the checkbox is disabled
@ -195,7 +196,8 @@ class Checkbox(RadixThemesComponent):
""" """
... ...
class HighLevelCheckbox(Checkbox): class HighLevelCheckbox(RadixThemesComponent):
def get_event_triggers(self) -> Dict[str, Any]: ...
@overload @overload
@classmethod @classmethod
def create( # type: ignore def create( # type: ignore
@ -214,8 +216,8 @@ class HighLevelCheckbox(Checkbox):
as_child: Optional[Union[Var[bool], bool]] = None, as_child: Optional[Union[Var[bool], bool]] = None,
variant: Optional[ variant: Optional[
Union[ Union[
Var[Literal["classic", "solid", "soft", "surface", "outline", "ghost"]], Var[Literal["classic", "surface", "soft"]],
Literal["classic", "solid", "soft", "surface", "outline", "ghost"], Literal["classic", "surface", "soft"],
] ]
] = None, ] = None,
color_scheme: Optional[ color_scheme: Optional[
@ -350,11 +352,11 @@ class HighLevelCheckbox(Checkbox):
text: The text of the label. text: The text of the label.
text: The text label for the checkbox. text: The text label for the checkbox.
gap: The gap between the checkbox and the label. gap: The gap between the checkbox and the label.
size: Button size "1" - "3" size: The size of the checkbox "1" - "3".
as_child: Change the default rendered element for the one passed as a child, merging their props and behavior. as_child: Change the default rendered element for the one passed as a child, merging their props and behavior.
variant: Variant of button: "solid" | "soft" | "outline" | "ghost" variant: Variant of checkbox: "classic" | "surface" | "soft"
color_scheme: Override theme color for button color_scheme: Override theme color for checkbox
high_contrast: Whether to render the button with higher contrast color against background high_contrast: Whether to render the checkbox with higher contrast color against background
default_checked: Whether the checkbox is checked by default default_checked: Whether the checkbox is checked by default
checked: Whether the checkbox is checked checked: Whether the checkbox is checked
disabled: Whether the checkbox is disabled disabled: Whether the checkbox is disabled
@ -392,8 +394,8 @@ class CheckboxNamespace(SimpleNamespace):
as_child: Optional[Union[Var[bool], bool]] = None, as_child: Optional[Union[Var[bool], bool]] = None,
variant: Optional[ variant: Optional[
Union[ Union[
Var[Literal["classic", "solid", "soft", "surface", "outline", "ghost"]], Var[Literal["classic", "surface", "soft"]],
Literal["classic", "solid", "soft", "surface", "outline", "ghost"], Literal["classic", "surface", "soft"],
] ]
] = None, ] = None,
color_scheme: Optional[ color_scheme: Optional[
@ -528,11 +530,11 @@ class CheckboxNamespace(SimpleNamespace):
text: The text of the label. text: The text of the label.
text: The text label for the checkbox. text: The text label for the checkbox.
gap: The gap between the checkbox and the label. gap: The gap between the checkbox and the label.
size: Button size "1" - "3" size: The size of the checkbox "1" - "3".
as_child: Change the default rendered element for the one passed as a child, merging their props and behavior. as_child: Change the default rendered element for the one passed as a child, merging their props and behavior.
variant: Variant of button: "solid" | "soft" | "outline" | "ghost" variant: Variant of checkbox: "classic" | "surface" | "soft"
color_scheme: Override theme color for button color_scheme: Override theme color for checkbox
high_contrast: Whether to render the button with higher contrast color against background high_contrast: Whether to render the checkbox with higher contrast color against background
default_checked: Whether the checkbox is checked by default default_checked: Whether the checkbox is checked by default
checked: Whether the checkbox is checked checked: Whether the checkbox is checked
disabled: Whether the checkbox is disabled disabled: Whether the checkbox is disabled

View File

@ -185,18 +185,6 @@ class DropdownMenuSubContent(RadixThemesComponent):
tag = "DropdownMenu.SubContent" tag = "DropdownMenu.SubContent"
# Dropdown Menu Sub Content size "1" - "2"
size: Var[LiteralSizeType]
# Variant of Dropdown Menu Sub Content: "solid" | "soft"
variant: Var[LiteralVariantType]
# Override theme color for Dropdown Menu Sub Content
color_scheme: Var[LiteralAccentColor]
# Whether to render the component with higher contrast color against background
high_contrast: Var[bool]
# Change the default rendered element for the one passed as a child, merging their props and behavior. Defaults to False. # Change the default rendered element for the one passed as a child, merging their props and behavior. Defaults to False.
as_child: Var[bool] as_child: Var[bool]

View File

@ -915,11 +915,6 @@ class DropdownMenuSubContent(RadixThemesComponent):
], ],
] ]
] = None, ] = None,
size: Optional[Union[Var[Literal["1", "2"]], Literal["1", "2"]]] = None,
variant: Optional[
Union[Var[Literal["solid", "soft"]], Literal["solid", "soft"]]
] = None,
high_contrast: Optional[Union[Var[bool], bool]] = None,
as_child: Optional[Union[Var[bool], bool]] = None, as_child: Optional[Union[Var[bool], bool]] = None,
loop: Optional[Union[Var[bool], bool]] = None, loop: Optional[Union[Var[bool], bool]] = None,
force_mount: Optional[Union[Var[bool], bool]] = None, force_mount: Optional[Union[Var[bool], bool]] = None,
@ -1014,9 +1009,6 @@ class DropdownMenuSubContent(RadixThemesComponent):
*children: Child components. *children: Child components.
color: map to CSS default color property. color: map to CSS default color property.
color_scheme: map to radix color property. color_scheme: map to radix color property.
size: Dropdown Menu Sub Content size "1" - "2"
variant: Variant of Dropdown Menu Sub Content: "solid" | "soft"
high_contrast: Whether to render the component with higher contrast color against background
as_child: Change the default rendered element for the one passed as a child, merging their props and behavior. Defaults to False. as_child: Change the default rendered element for the one passed as a child, merging their props and behavior. Defaults to False.
loop: When True, keyboard navigation will loop from last item to first, and vice versa. Defaults to False. loop: When True, keyboard navigation will loop from last item to first, and vice versa. Defaults to False.
force_mount: Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries. force_mount: Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries.