|
@@ -7,79 +7,61 @@ from typing import Any, Dict, Literal, Optional, Union, overload
|
|
from reflex.vars import Var, BaseVar, ComputedVar
|
|
from reflex.vars import Var, BaseVar, ComputedVar
|
|
from reflex.event import EventChain, EventHandler, EventSpec
|
|
from reflex.event import EventChain, EventHandler, EventSpec
|
|
from reflex.style import Style
|
|
from reflex.style import Style
|
|
|
|
+from typing import Any, Dict, Literal, Union
|
|
|
|
+from reflex.components.component import Component
|
|
|
|
+from reflex.constants import EventTriggers
|
|
|
|
+from reflex.utils import format
|
|
from reflex.vars import Var
|
|
from reflex.vars import Var
|
|
from ..base import RadixThemesComponent
|
|
from ..base import RadixThemesComponent
|
|
|
|
|
|
|
|
+LiteralSideType = Literal["top", "right", "bottom", "left"]
|
|
|
|
+LiteralAlignType = Literal["start", "center", "end"]
|
|
|
|
+LiteralStickyType = Literal["partial", "always"]
|
|
|
|
+
|
|
class Tooltip(RadixThemesComponent):
|
|
class Tooltip(RadixThemesComponent):
|
|
|
|
+ def get_event_triggers(self) -> Dict[str, Any]: ...
|
|
@overload
|
|
@overload
|
|
@classmethod
|
|
@classmethod
|
|
def create( # type: ignore
|
|
def create( # type: ignore
|
|
cls,
|
|
cls,
|
|
*children,
|
|
*children,
|
|
- color: Optional[Union[Var[str], str]] = None,
|
|
|
|
- color_scheme: Optional[
|
|
|
|
|
|
+ content: Optional[Union[Var[str], str]] = None,
|
|
|
|
+ default_open: Optional[Union[Var[bool], bool]] = None,
|
|
|
|
+ open: Optional[Union[Var[bool], bool]] = None,
|
|
|
|
+ side: Optional[
|
|
Union[
|
|
Union[
|
|
- Var[
|
|
|
|
- Literal[
|
|
|
|
- "tomato",
|
|
|
|
- "red",
|
|
|
|
- "ruby",
|
|
|
|
- "crimson",
|
|
|
|
- "pink",
|
|
|
|
- "plum",
|
|
|
|
- "purple",
|
|
|
|
- "violet",
|
|
|
|
- "iris",
|
|
|
|
- "indigo",
|
|
|
|
- "blue",
|
|
|
|
- "cyan",
|
|
|
|
- "teal",
|
|
|
|
- "jade",
|
|
|
|
- "green",
|
|
|
|
- "grass",
|
|
|
|
- "brown",
|
|
|
|
- "orange",
|
|
|
|
- "sky",
|
|
|
|
- "mint",
|
|
|
|
- "lime",
|
|
|
|
- "yellow",
|
|
|
|
- "amber",
|
|
|
|
- "gold",
|
|
|
|
- "bronze",
|
|
|
|
- "gray",
|
|
|
|
- ]
|
|
|
|
- ],
|
|
|
|
- Literal[
|
|
|
|
- "tomato",
|
|
|
|
- "red",
|
|
|
|
- "ruby",
|
|
|
|
- "crimson",
|
|
|
|
- "pink",
|
|
|
|
- "plum",
|
|
|
|
- "purple",
|
|
|
|
- "violet",
|
|
|
|
- "iris",
|
|
|
|
- "indigo",
|
|
|
|
- "blue",
|
|
|
|
- "cyan",
|
|
|
|
- "teal",
|
|
|
|
- "jade",
|
|
|
|
- "green",
|
|
|
|
- "grass",
|
|
|
|
- "brown",
|
|
|
|
- "orange",
|
|
|
|
- "sky",
|
|
|
|
- "mint",
|
|
|
|
- "lime",
|
|
|
|
- "yellow",
|
|
|
|
- "amber",
|
|
|
|
- "gold",
|
|
|
|
- "bronze",
|
|
|
|
- "gray",
|
|
|
|
- ],
|
|
|
|
|
|
+ Var[Literal["top", "right", "bottom", "left"]],
|
|
|
|
+ Literal["top", "right", "bottom", "left"],
|
|
]
|
|
]
|
|
] = None,
|
|
] = None,
|
|
- content: Optional[Union[Var[str], str]] = None,
|
|
|
|
|
|
+ side_offset: Optional[Union[Var[Union[float, int]], Union[float, int]]] = None,
|
|
|
|
+ align: Optional[
|
|
|
|
+ Union[
|
|
|
|
+ Var[Literal["start", "center", "end"]],
|
|
|
|
+ Literal["start", "center", "end"],
|
|
|
|
+ ]
|
|
|
|
+ ] = None,
|
|
|
|
+ align_offset: Optional[Union[Var[Union[float, int]], Union[float, int]]] = None,
|
|
|
|
+ avoid_collisions: Optional[Union[Var[bool], bool]] = None,
|
|
|
|
+ collision_padding: Optional[
|
|
|
|
+ Union[
|
|
|
|
+ Var[Union[float, int, Dict[str, Union[float, int]]]],
|
|
|
|
+ Union[float, int, Dict[str, Union[float, int]]],
|
|
|
|
+ ]
|
|
|
|
+ ] = None,
|
|
|
|
+ arrow_padding: Optional[
|
|
|
|
+ Union[Var[Union[float, int]], Union[float, int]]
|
|
|
|
+ ] = None,
|
|
|
|
+ sticky: Optional[
|
|
|
|
+ Union[Var[Literal["partial", "always"]], Literal["partial", "always"]]
|
|
|
|
+ ] = None,
|
|
|
|
+ hide_when_detached: Optional[Union[Var[bool], bool]] = None,
|
|
|
|
+ delay_duration: Optional[
|
|
|
|
+ Union[Var[Union[float, int]], Union[float, int]]
|
|
|
|
+ ] = None,
|
|
|
|
+ disable_hoverable_content: Optional[Union[Var[bool], bool]] = None,
|
|
|
|
+ force_mount: Optional[Union[Var[bool], bool]] = None,
|
|
|
|
+ aria_label: Optional[Union[Var[str], str]] = None,
|
|
style: Optional[Style] = None,
|
|
style: Optional[Style] = None,
|
|
key: Optional[Any] = None,
|
|
key: Optional[Any] = None,
|
|
id: Optional[Any] = None,
|
|
id: Optional[Any] = None,
|
|
@@ -98,6 +80,9 @@ class Tooltip(RadixThemesComponent):
|
|
on_double_click: Optional[
|
|
on_double_click: Optional[
|
|
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
] = None,
|
|
] = None,
|
|
|
|
+ on_escape_key_down: Optional[
|
|
|
|
+ Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
|
|
+ ] = None,
|
|
on_focus: Optional[
|
|
on_focus: Optional[
|
|
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
] = None,
|
|
] = None,
|
|
@@ -125,6 +110,12 @@ class Tooltip(RadixThemesComponent):
|
|
on_mouse_up: Optional[
|
|
on_mouse_up: Optional[
|
|
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
] = None,
|
|
] = None,
|
|
|
|
+ on_open_change: Optional[
|
|
|
|
+ Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
|
|
+ ] = None,
|
|
|
|
+ on_pointer_down_outside: Optional[
|
|
|
|
+ Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
|
|
+ ] = None,
|
|
on_scroll: Optional[
|
|
on_scroll: Optional[
|
|
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
Union[EventHandler, EventSpec, list, function, BaseVar]
|
|
] = None,
|
|
] = None,
|
|
@@ -133,25 +124,37 @@ class Tooltip(RadixThemesComponent):
|
|
] = None,
|
|
] = None,
|
|
**props
|
|
**props
|
|
) -> "Tooltip":
|
|
) -> "Tooltip":
|
|
- """Create a new component instance.
|
|
|
|
|
|
+ """Initialize the Tooltip component.
|
|
|
|
|
|
- Will prepend "RadixThemes" to the component tag to avoid conflicts with
|
|
|
|
- other UI libraries for common names, like Text and Button.
|
|
|
|
|
|
+ Run some additional handling on the props.
|
|
|
|
|
|
Args:
|
|
Args:
|
|
- *children: Child components.
|
|
|
|
- color: map to CSS default color property.
|
|
|
|
- color_scheme: map to radix color property.
|
|
|
|
|
|
+ *children: The positional arguments
|
|
content: The content of the tooltip.
|
|
content: The content of the tooltip.
|
|
|
|
+ default_open: The open state of the tooltip when it is initially rendered. Use when you do not need to control its open state.
|
|
|
|
+ open: The controlled open state of the tooltip. Must be used in conjunction with `on_open_change`.
|
|
|
|
+ side: The preferred side of the trigger to render against when open. Will be reversed when collisions occur and `avoid_collisions` is enabled.The position of the tooltip. Defaults to "top".
|
|
|
|
+ side_offset: The distance in pixels from the trigger. Defaults to 0.
|
|
|
|
+ align: The preferred alignment against the trigger. May change when collisions occur. Defaults to "center".
|
|
|
|
+ align_offset: An offset in pixels from the "start" or "end" alignment options.
|
|
|
|
+ avoid_collisions: When true, overrides the side and align preferences to prevent collisions with boundary edges. Defaults to True.
|
|
|
|
+ collision_padding: The distance in pixels from the boundary edges where collision detection should occur. Accepts a number (same for all sides), or a partial padding object, for example: { "top": 20, "left": 20 }. Defaults to 0.
|
|
|
|
+ arrow_padding: The padding between the arrow and the edges of the content. If your content has border-radius, this will prevent it from overflowing the corners. Defaults to 0.
|
|
|
|
+ sticky: The sticky behavior on the align axis. "partial" will keep the content in the boundary as long as the trigger is at least partially in the boundary whilst "always" will keep the content in the boundary regardless. Defaults to "partial".
|
|
|
|
+ hide_when_detached: Whether to hide the content when the trigger becomes fully occluded. Defaults to False.
|
|
|
|
+ delay_duration: Override the duration in milliseconds to customize the open delay for a specific tooltip. Default is 700.
|
|
|
|
+ disable_hoverable_content: Prevents Tooltip content from remaining open when hovering.
|
|
|
|
+ force_mount: Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries.
|
|
|
|
+ aria_label: By default, screenreaders will announce the content inside the component. If this is not descriptive enough, or you have content that cannot be announced, use aria-label as a more descriptive label.
|
|
style: The style of the component.
|
|
style: The style of the component.
|
|
key: A unique key for the component.
|
|
key: A unique key for the component.
|
|
id: The id for the component.
|
|
id: The id for the component.
|
|
class_name: The class name for the component.
|
|
class_name: The class name for the component.
|
|
autofocus: Whether the component should take the focus once the page is loaded
|
|
autofocus: Whether the component should take the focus once the page is loaded
|
|
custom_attrs: custom attribute
|
|
custom_attrs: custom attribute
|
|
- **props: Component properties.
|
|
|
|
|
|
+ **props: The keyword arguments
|
|
|
|
|
|
Returns:
|
|
Returns:
|
|
- A new component instance.
|
|
|
|
|
|
+ The created component.
|
|
"""
|
|
"""
|
|
...
|
|
...
|