Update overlay props (#4261)

* hover card and one prop for dialog

* add missing props of drawer

* fix context and dropdown menu

* add popover props

* fix hover card and alert dialog final

* fix pyi

* update drawer pyi

* pyi fix again

* fix from masen changes

* fix pyi

* fix pyi again

* ruff fix

---------

Co-authored-by: Tom Gotsman <tomgotsman@Toms-MacBook-Pro.local>
This commit is contained in:
Tom Gotsman 2024-11-01 23:14:46 +00:00 committed by GitHub
parent bcd51779e6
commit b70f33d972
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 422 additions and 73 deletions

View File

@ -33,14 +33,29 @@ class DrawerRoot(DrawerComponent):
alias = "Vaul" + tag
# The open state of the drawer when it is initially rendered. Use when you do not need to control its open state.
default_open: Var[bool]
# Whether the drawer is open or not.
open: Var[bool]
# Enable background scaling, it requires an element with [vaul-drawer-wrapper] data attribute to scale its background.
should_scale_background: Var[bool]
# Fires when the drawer is opened or closed.
on_open_change: EventHandler[identity_event(bool)]
# Number between 0 and 1 that determines when the drawer should be closed.
close_threshold: Var[float]
# When `False`, it allows interaction with elements outside of the drawer without closing it. Defaults to `True`.
modal: Var[bool]
# Direction of the drawer. This adjusts the animations and the drag direction. Defaults to `"bottom"`
direction: Var[LiteralDirectionType]
# Gets triggered after the open or close animation ends, it receives an open argument with the open state of the drawer by the time the function was triggered.
on_animation_end: EventHandler[identity_event(bool)]
# When `False`, dragging, clicking outside, pressing esc, etc. will not close the drawer. Use this in combination with the open prop, otherwise you won't be able to open/close the drawer.
dismissible: Var[bool]
# When `True`, dragging will only be possible by the handle.
handle_only: Var[bool]
# Array of numbers from 0 to 100 that corresponds to % of the screen a given snap point should take up. Should go from least visible. Also Accept px values, which doesn't take screen height into account.
snap_points: Optional[List[Union[str, float]]]
@ -51,17 +66,14 @@ class DrawerRoot(DrawerComponent):
# Duration for which the drawer is not draggable after scrolling content inside of the drawer. Defaults to 500ms
scroll_lock_timeout: Var[int]
# When `False`, it allows to interact with elements outside of the drawer without closing it. Defaults to `True`.
modal: Var[bool]
# Direction of the drawer. Defaults to `"bottom"`
direction: Var[LiteralDirectionType]
# When `True`, it prevents scroll restoration. Defaults to `True`.
preventScrollRestoration: Var[bool]
# Fires when the drawer is opened or closed.
on_open_change: EventHandler[identity_event(bool)]
# Enable background scaling, it requires container element with `vaul-drawer-wrapper` attribute to scale its background.
should_scale_background: Var[bool]
# Number between 0 and 1 that determines when the drawer should be closed.
close_threshold: Var[float]
class DrawerTrigger(DrawerComponent):
@ -263,6 +275,14 @@ class DrawerDescription(DrawerComponent):
return {"css": base_style}
class DrawerHandle(DrawerComponent):
"""A description for the drawer."""
tag = "Drawer.Handle"
alias = "Vaul" + tag
class Drawer(ComponentNamespace):
"""A namespace for Drawer components."""
@ -274,6 +294,7 @@ class Drawer(ComponentNamespace):
close = staticmethod(DrawerClose.create)
title = staticmethod(DrawerTitle.create)
description = staticmethod(DrawerDescription.create)
handle = staticmethod(DrawerHandle.create)
drawer = Drawer()

View File

@ -67,12 +67,8 @@ class DrawerRoot(DrawerComponent):
def create( # type: ignore
cls,
*children,
default_open: Optional[Union[Var[bool], bool]] = None,
open: Optional[Union[Var[bool], bool]] = None,
should_scale_background: Optional[Union[Var[bool], bool]] = None,
close_threshold: Optional[Union[Var[float], float]] = None,
snap_points: Optional[List[Union[float, str]]] = None,
fade_from_index: Optional[Union[Var[int], int]] = None,
scroll_lock_timeout: Optional[Union[Var[int], int]] = None,
modal: Optional[Union[Var[bool], bool]] = None,
direction: Optional[
Union[
@ -80,7 +76,14 @@ class DrawerRoot(DrawerComponent):
Var[Literal["bottom", "left", "right", "top"]],
]
] = None,
dismissible: Optional[Union[Var[bool], bool]] = None,
handle_only: Optional[Union[Var[bool], bool]] = None,
snap_points: Optional[List[Union[float, str]]] = None,
fade_from_index: Optional[Union[Var[int], int]] = None,
scroll_lock_timeout: Optional[Union[Var[int], int]] = None,
preventScrollRestoration: Optional[Union[Var[bool], bool]] = None,
should_scale_background: Optional[Union[Var[bool], bool]] = None,
close_threshold: Optional[Union[Var[float], float]] = None,
as_child: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
@ -88,6 +91,7 @@ class DrawerRoot(DrawerComponent):
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
on_animation_end: Optional[EventType[bool]] = None,
on_blur: Optional[EventType[[]]] = None,
on_click: Optional[EventType[[]]] = None,
on_context_menu: Optional[EventType[[]]] = None,
@ -110,16 +114,20 @@ class DrawerRoot(DrawerComponent):
Args:
*children: The children of the component.
default_open: The open state of the drawer when it is initially rendered. Use when you do not need to control its open state.
open: Whether the drawer is open or not.
should_scale_background: Enable background scaling, it requires an element with [vaul-drawer-wrapper] data attribute to scale its background.
close_threshold: Number between 0 and 1 that determines when the drawer should be closed.
on_open_change: Fires when the drawer is opened or closed.
modal: When `False`, it allows interaction with elements outside of the drawer without closing it. Defaults to `True`.
direction: Direction of the drawer. This adjusts the animations and the drag direction. Defaults to `"bottom"`
on_animation_end: Gets triggered after the open or close animation ends, it receives an open argument with the open state of the drawer by the time the function was triggered.
dismissible: When `False`, dragging, clicking outside, pressing esc, etc. will not close the drawer. Use this in combination with the open prop, otherwise you won't be able to open/close the drawer.
handle_only: When `True`, dragging will only be possible by the handle.
snap_points: Array of numbers from 0 to 100 that corresponds to % of the screen a given snap point should take up. Should go from least visible. Also Accept px values, which doesn't take screen height into account.
fade_from_index: Index of a snapPoint from which the overlay fade should be applied. Defaults to the last snap point.
scroll_lock_timeout: Duration for which the drawer is not draggable after scrolling content inside of the drawer. Defaults to 500ms
modal: When `False`, it allows to interact with elements outside of the drawer without closing it. Defaults to `True`.
direction: Direction of the drawer. Defaults to `"bottom"`
preventScrollRestoration: When `True`, it prevents scroll restoration. Defaults to `True`.
on_open_change: Fires when the drawer is opened or closed.
should_scale_background: Enable background scaling, it requires container element with `vaul-drawer-wrapper` attribute to scale its background.
close_threshold: Number between 0 and 1 that determines when the drawer should be closed.
as_child: Change the default rendered element for the one passed as a child.
style: The style of the component.
key: A unique key for the component.
@ -479,6 +487,54 @@ class DrawerDescription(DrawerComponent):
"""
...
class DrawerHandle(DrawerComponent):
@overload
@classmethod
def create( # type: ignore
cls,
*children,
as_child: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
on_blur: Optional[EventType[[]]] = None,
on_click: Optional[EventType[[]]] = None,
on_context_menu: Optional[EventType[[]]] = None,
on_double_click: Optional[EventType[[]]] = None,
on_focus: Optional[EventType[[]]] = None,
on_mount: Optional[EventType[[]]] = None,
on_mouse_down: Optional[EventType[[]]] = None,
on_mouse_enter: Optional[EventType[[]]] = None,
on_mouse_leave: Optional[EventType[[]]] = None,
on_mouse_move: Optional[EventType[[]]] = None,
on_mouse_out: Optional[EventType[[]]] = None,
on_mouse_over: Optional[EventType[[]]] = None,
on_mouse_up: Optional[EventType[[]]] = None,
on_scroll: Optional[EventType[[]]] = None,
on_unmount: Optional[EventType[[]]] = None,
**props,
) -> "DrawerHandle":
"""Create the component.
Args:
*children: The children of the component.
as_child: Change the default rendered element for the one passed as a child.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
class_name: The class name for the component.
autofocus: Whether the component should take the focus once the page is loaded
custom_attrs: custom attribute
**props: The props of the component.
Returns:
The component.
"""
...
class Drawer(ComponentNamespace):
root = staticmethod(DrawerRoot.create)
trigger = staticmethod(DrawerTrigger.create)
@ -488,16 +544,13 @@ class Drawer(ComponentNamespace):
close = staticmethod(DrawerClose.create)
title = staticmethod(DrawerTitle.create)
description = staticmethod(DrawerDescription.create)
handle = staticmethod(DrawerHandle.create)
@staticmethod
def __call__(
*children,
default_open: Optional[Union[Var[bool], bool]] = None,
open: Optional[Union[Var[bool], bool]] = None,
should_scale_background: Optional[Union[Var[bool], bool]] = None,
close_threshold: Optional[Union[Var[float], float]] = None,
snap_points: Optional[List[Union[float, str]]] = None,
fade_from_index: Optional[Union[Var[int], int]] = None,
scroll_lock_timeout: Optional[Union[Var[int], int]] = None,
modal: Optional[Union[Var[bool], bool]] = None,
direction: Optional[
Union[
@ -505,7 +558,14 @@ class Drawer(ComponentNamespace):
Var[Literal["bottom", "left", "right", "top"]],
]
] = None,
dismissible: Optional[Union[Var[bool], bool]] = None,
handle_only: Optional[Union[Var[bool], bool]] = None,
snap_points: Optional[List[Union[float, str]]] = None,
fade_from_index: Optional[Union[Var[int], int]] = None,
scroll_lock_timeout: Optional[Union[Var[int], int]] = None,
preventScrollRestoration: Optional[Union[Var[bool], bool]] = None,
should_scale_background: Optional[Union[Var[bool], bool]] = None,
close_threshold: Optional[Union[Var[float], float]] = None,
as_child: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
@ -513,6 +573,7 @@ class Drawer(ComponentNamespace):
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
on_animation_end: Optional[EventType[bool]] = None,
on_blur: Optional[EventType[[]]] = None,
on_click: Optional[EventType[[]]] = None,
on_context_menu: Optional[EventType[[]]] = None,
@ -535,16 +596,20 @@ class Drawer(ComponentNamespace):
Args:
*children: The children of the component.
default_open: The open state of the drawer when it is initially rendered. Use when you do not need to control its open state.
open: Whether the drawer is open or not.
should_scale_background: Enable background scaling, it requires an element with [vaul-drawer-wrapper] data attribute to scale its background.
close_threshold: Number between 0 and 1 that determines when the drawer should be closed.
on_open_change: Fires when the drawer is opened or closed.
modal: When `False`, it allows interaction with elements outside of the drawer without closing it. Defaults to `True`.
direction: Direction of the drawer. This adjusts the animations and the drag direction. Defaults to `"bottom"`
on_animation_end: Gets triggered after the open or close animation ends, it receives an open argument with the open state of the drawer by the time the function was triggered.
dismissible: When `False`, dragging, clicking outside, pressing esc, etc. will not close the drawer. Use this in combination with the open prop, otherwise you won't be able to open/close the drawer.
handle_only: When `True`, dragging will only be possible by the handle.
snap_points: Array of numbers from 0 to 100 that corresponds to % of the screen a given snap point should take up. Should go from least visible. Also Accept px values, which doesn't take screen height into account.
fade_from_index: Index of a snapPoint from which the overlay fade should be applied. Defaults to the last snap point.
scroll_lock_timeout: Duration for which the drawer is not draggable after scrolling content inside of the drawer. Defaults to 500ms
modal: When `False`, it allows to interact with elements outside of the drawer without closing it. Defaults to `True`.
direction: Direction of the drawer. Defaults to `"bottom"`
preventScrollRestoration: When `True`, it prevents scroll restoration. Defaults to `True`.
on_open_change: Fires when the drawer is opened or closed.
should_scale_background: Enable background scaling, it requires container element with `vaul-drawer-wrapper` attribute to scale its background.
close_threshold: Number between 0 and 1 that determines when the drawer should be closed.
as_child: Change the default rendered element for the one passed as a child.
style: The style of the component.
key: A unique key for the component.

View File

@ -24,6 +24,9 @@ class AlertDialogRoot(RadixThemesComponent):
# Fired when the open state changes.
on_open_change: EventHandler[identity_event(bool)]
# The open state of the dialog when it is initially rendered. Use when you do not need to control its open state.
default_open: Var[bool]
class AlertDialogTrigger(RadixThemesTriggerComponent):
"""Wraps the control that will open the dialog."""

View File

@ -23,6 +23,7 @@ class AlertDialogRoot(RadixThemesComponent):
cls,
*children,
open: Optional[Union[Var[bool], bool]] = None,
default_open: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
@ -56,6 +57,7 @@ class AlertDialogRoot(RadixThemesComponent):
*children: Child components.
open: The controlled open state of the dialog.
on_open_change: Fired when the open state changes.
default_open: The open state of the dialog when it is initially rendered. Use when you do not need to control its open state.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.

View File

@ -1,6 +1,6 @@
"""Interactive components provided by @radix-ui/themes."""
from typing import List, Literal
from typing import Dict, List, Literal, Union
from reflex.components.component import ComponentNamespace
from reflex.components.core.breakpoints import Responsive
@ -12,6 +12,21 @@ from ..base import (
RadixThemesComponent,
)
LiteralDirType = Literal["ltr", "rtl"]
LiteralSizeType = Literal["1", "2"]
LiteralVariantType = Literal["solid", "soft"]
LiteralSideType = Literal["top", "right", "bottom", "left"]
LiteralAlignType = Literal["start", "center", "end"]
LiteralStickyType = Literal[
"partial",
"always",
]
class ContextMenuRoot(RadixThemesComponent):
"""Menu representing a set of actions, displayed at the origin of a pointer right-click or long-press."""
@ -26,6 +41,9 @@ class ContextMenuRoot(RadixThemesComponent):
# Fired when the open state changes.
on_open_change: EventHandler[identity_event(bool)]
# The reading direction of submenus when applicable. If omitted, inherits globally from DirectionProvider or assumes LTR (left-to-right) reading mode.
dir: Var[LiteralDirType]
class ContextMenuTrigger(RadixThemesComponent):
"""Wraps the element that will open the context menu."""
@ -45,25 +63,52 @@ class ContextMenuContent(RadixThemesComponent):
tag = "ContextMenu.Content"
# Button size "1" - "4"
size: Var[Responsive[Literal["1", "2"]]]
# Dropdown Menu Content size "1" - "2"
size: Var[Responsive[LiteralSizeType]]
# Variant of button: "solid" | "soft" | "outline" | "ghost"
variant: Var[Literal["solid", "soft"]]
# Variant of Dropdown Menu Content: "solid" | "soft"
variant: Var[LiteralVariantType]
# Override theme color for button
# Override theme color for Dropdown Menu Content
color_scheme: Var[LiteralAccentColor]
# Whether to render the button with higher contrast color against background
# Renders the Dropdown Menu Content in higher contrast
high_contrast: Var[bool]
# The vertical distance in pixels from the anchor.
align_offset: Var[int]
# Change the default rendered element for the one passed as a child, merging their props and behavior. Defaults to False.
as_child: Var[bool]
# When true, overrides the side and aligns preferences to prevent collisions with boundary edges.
# When True, keyboard navigation will loop from last item to first, and vice versa. Defaults to False.
loop: Var[bool]
# Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries.
force_mount: Var[bool]
# 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: Var[LiteralSideType]
# The distance in pixels from the trigger. Defaults to 0.
side_offset: Var[Union[float, int]]
# The preferred alignment against the trigger. May change when collisions occur. Defaults to "center".
align: Var[LiteralAlignType]
# An offset in pixels from the "start" or "end" alignment options.
align_offset: Var[Union[float, int]]
# When true, overrides the side and align preferences to prevent collisions with boundary edges. Defaults to True.
avoid_collisions: Var[bool]
# Fired when the context menu is closed.
# 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.
collision_padding: Var[Union[float, int, Dict[str, Union[float, int]]]]
# 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".
sticky: Var[LiteralStickyType]
# Whether to hide the content when the trigger becomes fully occluded. Defaults to False.
hide_when_detached: Var[bool]
# Fired when focus moves back after closing.
on_close_auto_focus: EventHandler[empty_event]
# Fired when the escape key is pressed.
@ -75,7 +120,7 @@ class ContextMenuContent(RadixThemesComponent):
# Fired when focus moves outside the context menu.
on_focus_outside: EventHandler[empty_event]
# Fired when interacting outside the context menu.
# Fired when the pointer interacts outside the context menu.
on_interact_outside: EventHandler[empty_event]
@ -84,15 +129,30 @@ class ContextMenuSub(RadixThemesComponent):
tag = "ContextMenu.Sub"
# The controlled open state of the submenu. Must be used in conjunction with `on_open_change`.
open: Var[bool]
# The open state of the submenu when it is initially rendered. Use when you do not need to control its open state.
default_open: Var[bool]
# Fired when the open state changes.
on_open_change: EventHandler[identity_event(bool)]
class ContextMenuSubTrigger(RadixThemesComponent):
"""An item that opens a submenu."""
tag = "ContextMenu.SubTrigger"
# Change the default rendered element for the one passed as a child, merging their props and behavior. Defaults to False.
as_child: Var[bool]
# Whether the trigger is disabled
disabled: Var[bool]
# Optional text used for typeahead purposes. By default the typeahead behavior will use the .textContent of the item. Use this when the content is complex, or you have non-textual content inside.
text_value: Var[str]
_valid_parents: List[str] = ["ContextMenuContent", "ContextMenuSub"]
@ -101,9 +161,33 @@ class ContextMenuSubContent(RadixThemesComponent):
tag = "ContextMenu.SubContent"
# When true, keyboard navigation will loop from last item to first, and vice versa.
# Change the default rendered element for the one passed as a child, merging their props and behavior. Defaults to False.
as_child: Var[bool]
# When True, keyboard navigation will loop from last item to first, and vice versa. Defaults to False.
loop: Var[bool]
# Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries.
force_mount: Var[bool]
# The distance in pixels from the trigger. Defaults to 0.
side_offset: Var[Union[float, int]]
# An offset in pixels from the "start" or "end" alignment options.
align_offset: Var[Union[float, int]]
# When true, overrides the side and align preferences to prevent collisions with boundary edges. Defaults to True.
avoid_collisions: Var[bool]
# 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.
collision_padding: Var[Union[float, int, Dict[str, Union[float, int]]]]
# 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".
sticky: Var[LiteralStickyType]
# Whether to hide the content when the trigger becomes fully occluded. Defaults to False.
hide_when_detached: Var[bool]
_valid_parents: List[str] = ["ContextMenuSub"]
# Fired when the escape key is pressed.
@ -130,8 +214,20 @@ class ContextMenuItem(RadixThemesComponent):
# Shortcut to render a menu item as a link
shortcut: Var[str]
# Change the default rendered element for the one passed as a child, merging their props and behavior. Defaults to False.
as_child: Var[bool]
# When true, prevents the user from interacting with the item.
disabled: Var[bool]
# Optional text used for typeahead purposes. By default the typeahead behavior will use the content of the item. Use this when the content is complex, or you have non-textual content inside.
text_value: Var[str]
_valid_parents: List[str] = ["ContextMenuContent", "ContextMenuSubContent"]
# Fired when the item is selected.
on_select: EventHandler[empty_event]
class ContextMenuSeparator(RadixThemesComponent):
"""Separates items in a context menu."""

View File

@ -13,6 +13,13 @@ from reflex.vars.base import Var
from ..base import RadixThemesComponent
LiteralDirType = Literal["ltr", "rtl"]
LiteralSizeType = Literal["1", "2"]
LiteralVariantType = Literal["solid", "soft"]
LiteralSideType = Literal["top", "right", "bottom", "left"]
LiteralAlignType = Literal["start", "center", "end"]
LiteralStickyType = Literal["partial", "always"]
class ContextMenuRoot(RadixThemesComponent):
@overload
@classmethod
@ -20,6 +27,7 @@ class ContextMenuRoot(RadixThemesComponent):
cls,
*children,
modal: Optional[Union[Var[bool], bool]] = None,
dir: Optional[Union[Literal["ltr", "rtl"], Var[Literal["ltr", "rtl"]]]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
@ -53,6 +61,7 @@ class ContextMenuRoot(RadixThemesComponent):
*children: Child components.
modal: The modality of the context menu. When set to true, interaction with outside elements will be disabled and only menu content will be visible to screen readers.
on_open_change: Fired when the open state changes.
dir: The reading direction of submenus when applicable. If omitted, inherits globally from DirectionProvider or assumes LTR (left-to-right) reading mode.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@ -196,8 +205,36 @@ class ContextMenuContent(RadixThemesComponent):
]
] = None,
high_contrast: Optional[Union[Var[bool], bool]] = None,
align_offset: Optional[Union[Var[int], int]] = None,
as_child: Optional[Union[Var[bool], bool]] = None,
loop: Optional[Union[Var[bool], bool]] = None,
force_mount: Optional[Union[Var[bool], bool]] = None,
side: Optional[
Union[
Literal["bottom", "left", "right", "top"],
Var[Literal["bottom", "left", "right", "top"]],
]
] = None,
side_offset: Optional[Union[Var[Union[float, int]], float, int]] = None,
align: Optional[
Union[
Literal["center", "end", "start"],
Var[Literal["center", "end", "start"]],
]
] = None,
align_offset: Optional[Union[Var[Union[float, int]], float, int]] = None,
avoid_collisions: Optional[Union[Var[bool], bool]] = None,
collision_padding: Optional[
Union[
Dict[str, Union[float, int]],
Var[Union[Dict[str, Union[float, int]], float, int]],
float,
int,
]
] = None,
sticky: Optional[
Union[Literal["always", "partial"], Var[Literal["always", "partial"]]]
] = None,
hide_when_detached: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
@ -233,17 +270,26 @@ class ContextMenuContent(RadixThemesComponent):
Args:
*children: Child components.
size: Button size "1" - "4"
variant: Variant of button: "solid" | "soft" | "outline" | "ghost"
color_scheme: Override theme color for button
high_contrast: Whether to render the button with higher contrast color against background
align_offset: The vertical distance in pixels from the anchor.
avoid_collisions: When true, overrides the side and aligns preferences to prevent collisions with boundary edges.
on_close_auto_focus: Fired when the context menu is closed.
size: Dropdown Menu Content size "1" - "2"
variant: Variant of Dropdown Menu Content: "solid" | "soft"
color_scheme: Override theme color for Dropdown Menu Content
high_contrast: Renders the Dropdown Menu Content in higher contrast
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.
force_mount: Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries.
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.
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.
on_close_auto_focus: Fired when focus moves back after closing.
on_escape_key_down: Fired when the escape key is pressed.
on_pointer_down_outside: Fired when a pointer down event happens outside the context menu.
on_focus_outside: Fired when focus moves outside the context menu.
on_interact_outside: Fired when interacting outside the context menu.
on_interact_outside: Fired when the pointer interacts outside the context menu.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@ -263,6 +309,8 @@ class ContextMenuSub(RadixThemesComponent):
def create( # type: ignore
cls,
*children,
open: Optional[Union[Var[bool], bool]] = None,
default_open: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
@ -282,6 +330,7 @@ class ContextMenuSub(RadixThemesComponent):
on_mouse_out: Optional[EventType[[]]] = None,
on_mouse_over: Optional[EventType[[]]] = None,
on_mouse_up: Optional[EventType[[]]] = None,
on_open_change: Optional[EventType[bool]] = None,
on_scroll: Optional[EventType[[]]] = None,
on_unmount: Optional[EventType[[]]] = None,
**props,
@ -293,6 +342,9 @@ class ContextMenuSub(RadixThemesComponent):
Args:
*children: Child components.
open: The controlled open state of the submenu. Must be used in conjunction with `on_open_change`.
default_open: The open state of the submenu when it is initially rendered. Use when you do not need to control its open state.
on_open_change: Fired when the open state changes.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@ -312,7 +364,9 @@ class ContextMenuSubTrigger(RadixThemesComponent):
def create( # type: ignore
cls,
*children,
as_child: Optional[Union[Var[bool], bool]] = None,
disabled: Optional[Union[Var[bool], bool]] = None,
text_value: Optional[Union[Var[str], str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
@ -343,7 +397,9 @@ class ContextMenuSubTrigger(RadixThemesComponent):
Args:
*children: Child components.
as_child: Change the default rendered element for the one passed as a child, merging their props and behavior. Defaults to False.
disabled: Whether the trigger is disabled
text_value: Optional text used for typeahead purposes. By default the typeahead behavior will use the .textContent of the item. Use this when the content is complex, or you have non-textual content inside.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@ -363,7 +419,24 @@ class ContextMenuSubContent(RadixThemesComponent):
def create( # type: ignore
cls,
*children,
as_child: Optional[Union[Var[bool], bool]] = None,
loop: Optional[Union[Var[bool], bool]] = None,
force_mount: Optional[Union[Var[bool], bool]] = None,
side_offset: Optional[Union[Var[Union[float, int]], float, int]] = None,
align_offset: Optional[Union[Var[Union[float, int]], float, int]] = None,
avoid_collisions: Optional[Union[Var[bool], bool]] = None,
collision_padding: Optional[
Union[
Dict[str, Union[float, int]],
Var[Union[Dict[str, Union[float, int]], float, int]],
float,
int,
]
] = None,
sticky: Optional[
Union[Literal["always", "partial"], Var[Literal["always", "partial"]]]
] = None,
hide_when_detached: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
@ -398,7 +471,15 @@ class ContextMenuSubContent(RadixThemesComponent):
Args:
*children: Child components.
loop: When true, keyboard navigation will loop from last item to first, and vice versa.
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.
force_mount: Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries.
side_offset: The distance in pixels from the trigger. Defaults to 0.
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.
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.
on_escape_key_down: Fired when the escape key is pressed.
on_pointer_down_outside: Fired when a pointer down event happens outside the context menu.
on_focus_outside: Fired when focus moves outside the context menu.
@ -485,6 +566,9 @@ class ContextMenuItem(RadixThemesComponent):
]
] = None,
shortcut: Optional[Union[Var[str], str]] = None,
as_child: Optional[Union[Var[bool], bool]] = None,
disabled: Optional[Union[Var[bool], bool]] = None,
text_value: Optional[Union[Var[str], str]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
@ -505,6 +589,7 @@ class ContextMenuItem(RadixThemesComponent):
on_mouse_over: Optional[EventType[[]]] = None,
on_mouse_up: Optional[EventType[[]]] = None,
on_scroll: Optional[EventType[[]]] = None,
on_select: Optional[EventType[[]]] = None,
on_unmount: Optional[EventType[[]]] = None,
**props,
) -> "ContextMenuItem":
@ -517,6 +602,10 @@ class ContextMenuItem(RadixThemesComponent):
*children: Child components.
color_scheme: Override theme color for button
shortcut: Shortcut to render a menu item as a link
as_child: Change the default rendered element for the one passed as a child, merging their props and behavior. Defaults to False.
disabled: When true, prevents the user from interacting with the item.
text_value: Optional text used for typeahead purposes. By default the typeahead behavior will use the content of the item. Use this when the content is complex, or you have non-textual content inside.
on_select: Fired when the item is selected.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.

View File

@ -25,6 +25,9 @@ class DialogRoot(RadixThemesComponent):
# Fired when the open state changes.
on_open_change: EventHandler[identity_event(bool)]
# The open state of the dialog when it is initially rendered. Use when you do not need to control its open state.
default_open: Var[bool]
class DialogTrigger(RadixThemesTriggerComponent):
"""Trigger an action or event, to open a Dialog modal."""

View File

@ -21,6 +21,7 @@ class DialogRoot(RadixThemesComponent):
cls,
*children,
open: Optional[Union[Var[bool], bool]] = None,
default_open: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
@ -54,6 +55,7 @@ class DialogRoot(RadixThemesComponent):
*children: Child components.
open: The controlled open state of the dialog.
on_open_change: Fired when the open state changes.
default_open: The open state of the dialog when it is initially rendered. Use when you do not need to control its open state.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@ -369,6 +371,7 @@ class Dialog(ComponentNamespace):
def __call__(
*children,
open: Optional[Union[Var[bool], bool]] = None,
default_open: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
@ -402,6 +405,7 @@ class Dialog(ComponentNamespace):
*children: Child components.
open: The controlled open state of the dialog.
on_open_change: Fired when the open state changes.
default_open: The open state of the dialog when it is initially rendered. Use when you do not need to control its open state.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.

View File

@ -23,7 +23,6 @@ LiteralSideType = Literal["top", "right", "bottom", "left"]
LiteralAlignType = Literal["start", "center", "end"]
LiteralStickyType = Literal[
"partial",
"always",
@ -110,9 +109,6 @@ class DropdownMenuContent(RadixThemesComponent):
# 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.
collision_padding: Var[Union[float, int, Dict[str, Union[float, int]]]]
# 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.
arrow_padding: Var[Union[float, int]]
# 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".
sticky: Var[LiteralStickyType]
@ -193,9 +189,6 @@ class DropdownMenuSubContent(RadixThemesComponent):
# 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.
collision_padding: Var[Union[float, int, Dict[str, Union[float, int]]]]
# 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.
arrow_padding: Var[Union[float, int]]
# 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".
sticky: Var[LiteralStickyType]

View File

@ -225,7 +225,6 @@ class DropdownMenuContent(RadixThemesComponent):
int,
]
] = None,
arrow_padding: Optional[Union[Var[Union[float, int]], float, int]] = None,
sticky: Optional[
Union[Literal["always", "partial"], Var[Literal["always", "partial"]]]
] = None,
@ -278,7 +277,6 @@ class DropdownMenuContent(RadixThemesComponent):
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.
on_close_auto_focus: Fired when the dialog is closed.
@ -417,7 +415,6 @@ class DropdownMenuSubContent(RadixThemesComponent):
int,
]
] = None,
arrow_padding: Optional[Union[Var[Union[float, int]], float, int]] = None,
sticky: Optional[
Union[Literal["always", "partial"], Var[Literal["always", "partial"]]]
] = None,
@ -463,7 +460,6 @@ class DropdownMenuSubContent(RadixThemesComponent):
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.
on_escape_key_down: Fired when the escape key is pressed.

View File

@ -1,6 +1,6 @@
"""Interactive components provided by @radix-ui/themes."""
from typing import Literal
from typing import Dict, Literal, Union
from reflex.components.component import ComponentNamespace
from reflex.components.core.breakpoints import Responsive
@ -55,9 +55,24 @@ class HoverCardContent(elements.Div, RadixThemesComponent):
# The preferred alignment against the trigger. May change when collisions occur.
align: Var[Literal["start", "center", "end"]]
# An offset in pixels from the "start" or "end" alignment options.
align_offset: Var[int]
# Whether or not the hover card should avoid collisions with its trigger.
avoid_collisions: Var[bool]
# 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 }.
collision_padding: Var[Union[float, int, Dict[str, Union[float, int]]]]
# 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
sticky: Var[Literal["partial", "always"]]
# Whether to hide the content when the trigger becomes fully occluded.
hide_when_detached: Var[bool]
# Hovercard size "1" - "3"
size: Var[Responsive[Literal["1", "2", "3"]]]
class HoverCard(ComponentNamespace):
"""For sighted users to preview content available behind a link."""

View File

@ -138,7 +138,31 @@ class HoverCardContent(elements.Div, RadixThemesComponent):
Var[Literal["center", "end", "start"]],
]
] = None,
align_offset: Optional[Union[Var[int], int]] = None,
avoid_collisions: Optional[Union[Var[bool], bool]] = None,
collision_padding: Optional[
Union[
Dict[str, Union[float, int]],
Var[Union[Dict[str, Union[float, int]], float, int]],
float,
int,
]
] = None,
sticky: Optional[
Union[Literal["always", "partial"], Var[Literal["always", "partial"]]]
] = None,
hide_when_detached: Optional[Union[Var[bool], bool]] = None,
size: Optional[
Union[
Breakpoints[str, Literal["1", "2", "3"]],
Literal["1", "2", "3"],
Var[
Union[
Breakpoints[str, Literal["1", "2", "3"]], Literal["1", "2", "3"]
]
],
]
] = None,
access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
Union[Var[Union[bool, int, str]], bool, int, str]
@ -196,7 +220,12 @@ class HoverCardContent(elements.Div, RadixThemesComponent):
side: The preferred side of the trigger to render against when open. Will be reversed when collisions occur and avoidCollisions is enabled.
side_offset: The distance in pixels from the trigger.
align: The preferred alignment against the trigger. May change when collisions occur.
align_offset: An offset in pixels from the "start" or "end" alignment options.
avoid_collisions: Whether or not the hover card should avoid collisions with its trigger.
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 }.
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
hide_when_detached: Whether to hide the content when the trigger becomes fully occluded.
size: Hovercard size "1" - "3"
access_key: Provides a hint for generating a keyboard shortcut for the current element.
auto_capitalize: Controls whether and how text input is automatically capitalized as it is entered/edited by the user.
content_editable: Indicates whether the element's content is editable.

View File

@ -1,6 +1,6 @@
"""Interactive components provided by @radix-ui/themes."""
from typing import Literal
from typing import Dict, Literal, Union
from reflex.components.component import ComponentNamespace
from reflex.components.core.breakpoints import Responsive
@ -28,6 +28,9 @@ class PopoverRoot(RadixThemesComponent):
# Fired when the open state changes.
on_open_change: EventHandler[identity_event(bool)]
# The open state of the popover when it is initially rendered. Use when you do not need to control its open state.
default_open: Var[bool]
class PopoverTrigger(RadixThemesTriggerComponent):
"""Wraps the control that will open the popover."""
@ -58,6 +61,15 @@ class PopoverContent(elements.Div, RadixThemesComponent):
# When true, overrides the side andalign preferences to prevent collisions with boundary edges.
avoid_collisions: Var[bool]
# 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.
collision_padding: Var[Union[float, int, Dict[str, Union[float, int]]]]
# 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".
sticky: Var[Literal["partial", "always"]]
# Whether to hide the content when the trigger becomes fully occluded. Defaults to False.
hide_when_detached: Var[bool]
# Fired when the dialog is opened.
on_open_auto_focus: EventHandler[empty_event]

View File

@ -22,6 +22,7 @@ class PopoverRoot(RadixThemesComponent):
*children,
open: Optional[Union[Var[bool], bool]] = None,
modal: Optional[Union[Var[bool], bool]] = None,
default_open: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
id: Optional[Any] = None,
@ -56,6 +57,7 @@ class PopoverRoot(RadixThemesComponent):
open: The controlled open state of the popover.
modal: The modality of the popover. When set to true, interaction with outside elements will be disabled and only popover content will be visible to screen readers.
on_open_change: Fired when the open state changes.
default_open: The open state of the popover when it is initially rendered. Use when you do not need to control its open state.
style: The style of the component.
key: A unique key for the component.
id: The id for the component.
@ -142,6 +144,18 @@ class PopoverContent(elements.Div, RadixThemesComponent):
] = None,
align_offset: Optional[Union[Var[int], int]] = None,
avoid_collisions: Optional[Union[Var[bool], bool]] = None,
collision_padding: Optional[
Union[
Dict[str, Union[float, int]],
Var[Union[Dict[str, Union[float, int]], float, int]],
float,
int,
]
] = None,
sticky: Optional[
Union[Literal["always", "partial"], Var[Literal["always", "partial"]]]
] = None,
hide_when_detached: Optional[Union[Var[bool], bool]] = None,
access_key: Optional[Union[Var[Union[bool, int, str]], bool, int, str]] = None,
auto_capitalize: Optional[
Union[Var[Union[bool, int, str]], bool, int, str]
@ -208,6 +222,9 @@ class PopoverContent(elements.Div, RadixThemesComponent):
align: The preferred alignment against the anchor. May change when collisions occur.
align_offset: The vertical distance in pixels from the anchor.
avoid_collisions: When true, overrides the side andalign preferences to prevent collisions with boundary edges.
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.
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.
on_open_auto_focus: Fired when the dialog is opened.
on_close_auto_focus: Fired when the dialog is closed.
on_escape_key_down: Fired when the escape key is pressed.

View File

@ -95,12 +95,8 @@ class DrawerSidebar(DrawerRoot):
def create( # type: ignore
cls,
*children,
default_open: Optional[Union[Var[bool], bool]] = None,
open: Optional[Union[Var[bool], bool]] = None,
should_scale_background: Optional[Union[Var[bool], bool]] = None,
close_threshold: Optional[Union[Var[float], float]] = None,
snap_points: Optional[List[Union[float, str]]] = None,
fade_from_index: Optional[Union[Var[int], int]] = None,
scroll_lock_timeout: Optional[Union[Var[int], int]] = None,
modal: Optional[Union[Var[bool], bool]] = None,
direction: Optional[
Union[
@ -108,7 +104,14 @@ class DrawerSidebar(DrawerRoot):
Var[Literal["bottom", "left", "right", "top"]],
]
] = None,
dismissible: Optional[Union[Var[bool], bool]] = None,
handle_only: Optional[Union[Var[bool], bool]] = None,
snap_points: Optional[List[Union[float, str]]] = None,
fade_from_index: Optional[Union[Var[int], int]] = None,
scroll_lock_timeout: Optional[Union[Var[int], int]] = None,
preventScrollRestoration: Optional[Union[Var[bool], bool]] = None,
should_scale_background: Optional[Union[Var[bool], bool]] = None,
close_threshold: Optional[Union[Var[float], float]] = None,
as_child: Optional[Union[Var[bool], bool]] = None,
style: Optional[Style] = None,
key: Optional[Any] = None,
@ -116,6 +119,7 @@ class DrawerSidebar(DrawerRoot):
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
on_animation_end: Optional[EventType[bool]] = None,
on_blur: Optional[EventType[[]]] = None,
on_click: Optional[EventType[[]]] = None,
on_context_menu: Optional[EventType[[]]] = None,