-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add primitive radix dialog #5848
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| """Interactive components provided by @radix-ui/react-dialog.""" | ||
|
|
||
| from typing import Any | ||
|
|
||
| from reflex.components.component import ComponentNamespace | ||
| from reflex.components.el import elements | ||
| from reflex.constants.compiler import MemoizationMode | ||
| from reflex.event import EventHandler, no_args_event_spec, passthrough_event_spec | ||
| from reflex.vars.base import Var | ||
|
|
||
| from .base import RadixPrimitiveComponent, RadixPrimitiveTriggerComponent | ||
|
|
||
|
|
||
| class DialogElement(RadixPrimitiveComponent): | ||
| """Base class for all @radix-ui/react-dialog components.""" | ||
|
|
||
| library = "@radix-ui/react-dialog@1.1.15" | ||
|
|
||
|
|
||
| class DialogRoot(DialogElement): | ||
| """Root component for Dialog.""" | ||
|
|
||
| tag = "Root" | ||
| alias = "RadixPrimitiveDialogRoot" | ||
|
|
||
| # The controlled open state of the dialog. | ||
| open: Var[bool] | ||
|
|
||
| # Fired when the open state changes. | ||
| on_open_change: EventHandler[passthrough_event_spec(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] | ||
|
|
||
| # The modality of the dialog. When set to true, interaction with outside elements will be disabled and only dialog content will be visible to screen readers. | ||
| modal: Var[bool] | ||
|
|
||
|
|
||
| class DialogPortal(DialogElement): | ||
| """Portal component for Dialog.""" | ||
|
|
||
| tag = "Portal" | ||
| alias = "RadixPrimitiveDialogPortal" | ||
|
|
||
| # Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries. If used on this part, it will be inherited by Dialog.Overlay and Dialog.Content. | ||
| force_mount: Var[bool] | ||
|
|
||
| # Specify a container element to portal the content into. | ||
| container: Var[Any] | ||
|
|
||
|
|
||
| class DialogOverlay(DialogElement): | ||
| """A layer that covers the inert portion of the view when the dialog is open.""" | ||
|
|
||
| tag = "Overlay" | ||
| alias = "RadixPrimitiveDialogOverlay" | ||
|
|
||
| # Change the default rendered element for the one passed as a child, merging their props and behavior. | ||
| as_child: Var[bool] | ||
|
|
||
| # Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries. It inherits from Dialog.Portal. | ||
| force_mount: Var[bool] | ||
|
|
||
|
|
||
| class DialogTrigger(DialogElement, RadixPrimitiveTriggerComponent): | ||
| """Trigger an action or event, to open a Dialog modal.""" | ||
|
|
||
| tag = "Trigger" | ||
| alias = "RadixPrimitiveDialogTrigger" | ||
|
|
||
| # Change the default rendered element for the one passed as a child, merging their props and behavior. | ||
| as_child: Var[bool] | ||
|
|
||
| _memoization_mode = MemoizationMode(recursive=False) | ||
|
|
||
|
|
||
| class DialogContent(elements.Div, DialogElement): | ||
| """Content component to display inside a Dialog modal.""" | ||
|
|
||
| tag = "Content" | ||
| alias = "RadixPrimitiveDialogContent" | ||
|
|
||
| # Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries. It inherits from Dialog.Portal. | ||
| force_mount: Var[bool] | ||
|
|
||
| # Change the default rendered element for the one passed as a child, merging their props and behavior. | ||
| as_child: Var[bool] | ||
|
|
||
| # Fired when the dialog is opened. | ||
| on_open_auto_focus: EventHandler[no_args_event_spec] | ||
|
|
||
| # Fired when the dialog is closed. | ||
| on_close_auto_focus: EventHandler[no_args_event_spec] | ||
|
|
||
| # Fired when the escape key is pressed. | ||
| on_escape_key_down: EventHandler[no_args_event_spec] | ||
|
|
||
| # Fired when the pointer is down outside the dialog. | ||
| on_pointer_down_outside: EventHandler[no_args_event_spec] | ||
|
|
||
| # Fired when the pointer interacts outside the dialog. | ||
| on_interact_outside: EventHandler[no_args_event_spec] | ||
|
|
||
|
|
||
| class DialogTitle(DialogElement): | ||
| """Title component to display inside a Dialog modal.""" | ||
|
|
||
| tag = "Title" | ||
| alias = "RadixPrimitiveDialogTitle" | ||
|
|
||
| # Change the default rendered element for the one passed as a child, merging their props and behavior. | ||
| as_child: Var[bool] | ||
|
|
||
|
|
||
| class DialogDescription(DialogElement): | ||
| """Description component to display inside a Dialog modal.""" | ||
|
|
||
| tag = "Description" | ||
| alias = "RadixPrimitiveDialogDescription" | ||
|
|
||
| # Change the default rendered element for the one passed as a child, merging their props and behavior. | ||
| as_child: Var[bool] | ||
|
|
||
|
|
||
| class DialogClose(DialogElement, RadixPrimitiveTriggerComponent): | ||
| """Close button component to close an open Dialog modal.""" | ||
|
|
||
| tag = "Close" | ||
| alias = "RadixPrimitiveDialogClose" | ||
|
|
||
| # Change the default rendered element for the one passed as a child, merging their props and behavior. | ||
| as_child: Var[bool] | ||
|
|
||
|
|
||
| class Dialog(ComponentNamespace): | ||
| """Dialog components namespace.""" | ||
|
|
||
| root = __call__ = staticmethod(DialogRoot.create) | ||
| portal = staticmethod(DialogPortal.create) | ||
| trigger = staticmethod(DialogTrigger.create) | ||
| title = staticmethod(DialogTitle.create) | ||
| overlay = staticmethod(DialogOverlay.create) | ||
| content = staticmethod(DialogContent.create) | ||
| description = staticmethod(DialogDescription.create) | ||
| close = staticmethod(DialogClose.create) | ||
|
|
||
|
|
||
| dialog = Dialog() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.