123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- """Interactive components provided by @radix-ui/themes."""
- from typing import Any, Dict, Literal
- from reflex import el
- from reflex.vars import Var
- from ..base import CommonMarginProps, LiteralSize, RadixThemesComponent
- LiteralSwitchSize = Literal["1", "2", "3", "4"]
- class AlertDialogRoot(CommonMarginProps, RadixThemesComponent):
- """Contains all the parts of the dialog."""
- tag = "AlertDialog.Root"
- # The controlled open state of the dialog.
- open: Var[bool]
- # The size of the dialog.
- size: Var[LiteralSize]
- 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(),
- "on_open_change": lambda e0: [e0],
- }
- class AlertDialogTrigger(CommonMarginProps, RadixThemesComponent):
- """Wraps the control that will open the dialog."""
- tag = "AlertDialog.Trigger"
- # The size of the dialog.
- size: Var[LiteralSize]
- class AlertDialogContent(el.Div, CommonMarginProps, RadixThemesComponent):
- """Contains the content of the dialog. This component is based on the div element."""
- tag = "AlertDialog.Content"
- # The size of the content.
- size: Var[LiteralSize]
- # Whether to force mount the content on open.
- force_mount: Var[bool]
- 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(),
- "on_open_auto_focus": lambda e0: [e0],
- "on_close_auto_focus": lambda e0: [e0],
- "on_escape_key_down": lambda e0: [e0],
- }
- class AlertDialogTitle(CommonMarginProps, RadixThemesComponent):
- """An accessible title that is announced when the dialog is opened.
- This part is based on the Heading component with a pre-defined font size and
- leading trim on top.
- """
- tag = "AlertDialog.Title"
- # The size of the dialog.
- size: Var[LiteralSize]
- class AlertDialogDescription(CommonMarginProps, RadixThemesComponent):
- """An optional accessible description that is announced when the dialog is opened.
- This part is based on the Text component with a pre-defined font size.
- """
- tag = "AlertDialog.Description"
- # The size of the dialog.
- size: Var[LiteralSize]
- class AlertDialogAction(CommonMarginProps, RadixThemesComponent):
- """Wraps the control that will close the dialog. This should be distinguished
- visually from the Cancel control.
- """
- tag = "AlertDialog.Action"
- # The size of the dialog.
- size: Var[LiteralSize]
- class AlertDialogCancel(CommonMarginProps, RadixThemesComponent):
- """Wraps the control that will close the dialog. This should be distinguished
- visually from the Action control.
- """
- tag = "AlertDialog.Cancel"
- # The size of the dialog.
- size: Var[LiteralSize]
|