123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- """Stub file for reflex/components/sonner/toast.py"""
- # ------------------- DO NOT EDIT ----------------------
- # This file was generated by `reflex/utils/pyi_generator.py`!
- # ------------------------------------------------------
- from typing import Any, ClassVar, Dict, Literal, Optional, Union, overload
- from reflex.base import Base
- from reflex.components.component import Component, ComponentNamespace
- from reflex.components.lucide.icon import Icon
- from reflex.components.props import NoExtrasAllowedProps, PropsBase
- from reflex.event import BASE_STATE, EventSpec, EventType
- from reflex.style import Style
- from reflex.utils.serializers import serializer
- from reflex.vars.base import Var
- LiteralPosition = Literal[
- "top-left",
- "top-center",
- "top-right",
- "bottom-left",
- "bottom-center",
- "bottom-right",
- ]
- toast_ref = Var(_js_expr="refs['__toast']")
- class ToastAction(Base):
- label: str
- on_click: Any
- @serializer
- def serialize_action(action: ToastAction) -> dict: ...
- class ToastProps(PropsBase, NoExtrasAllowedProps):
- title: Optional[Union[str, Var]]
- description: Optional[Union[str, Var]]
- close_button: Optional[bool]
- invert: Optional[bool]
- important: Optional[bool]
- duration: Optional[int]
- position: Optional[LiteralPosition]
- dismissible: Optional[bool]
- action: Optional[ToastAction]
- cancel: Optional[ToastAction]
- id: Optional[Union[str, Var]]
- unstyled: Optional[bool]
- style: Optional[Style]
- class_name: Optional[str]
- action_button_styles: Optional[Style]
- cancel_button_styles: Optional[Style]
- on_dismiss: Optional[Any]
- on_auto_close: Optional[Any]
- def dict(self, *args: Any, **kwargs: Any) -> dict[str, Any]: ...
- class Toaster(Component):
- is_used: ClassVar[bool] = False
- def add_hooks(self) -> list[Var | str]: ...
- @staticmethod
- def send_toast(
- message: str | Var = "", level: str | None = None, **props
- ) -> EventSpec: ...
- @staticmethod
- def toast_info(message: str | Var = "", **kwargs: Any): ...
- @staticmethod
- def toast_warning(message: str | Var = "", **kwargs: Any): ...
- @staticmethod
- def toast_error(message: str | Var = "", **kwargs: Any): ...
- @staticmethod
- def toast_success(message: str | Var = "", **kwargs: Any): ...
- @staticmethod
- def toast_dismiss(id: Var | str | None = None): ...
- @overload
- @classmethod
- def create( # type: ignore
- cls,
- *children,
- theme: Optional[Union[Var[str], str]] = None,
- rich_colors: Optional[Union[Var[bool], bool]] = None,
- expand: Optional[Union[Var[bool], bool]] = None,
- visible_toasts: Optional[Union[Var[int], int]] = None,
- position: Optional[
- Union[
- Literal[
- "bottom-center",
- "bottom-left",
- "bottom-right",
- "top-center",
- "top-left",
- "top-right",
- ],
- Var[
- Literal[
- "bottom-center",
- "bottom-left",
- "bottom-right",
- "top-center",
- "top-left",
- "top-right",
- ]
- ],
- ]
- ] = None,
- close_button: Optional[Union[Var[bool], bool]] = None,
- offset: Optional[Union[Var[str], str]] = None,
- dir: Optional[Union[Var[str], str]] = None,
- hotkey: Optional[Union[Var[str], str]] = None,
- invert: Optional[Union[Var[bool], bool]] = None,
- toast_options: Optional[Union[ToastProps, Var[ToastProps]]] = None,
- gap: Optional[Union[Var[int], int]] = None,
- loading_icon: Optional[Union[Icon, Var[Icon]]] = None,
- pause_when_page_is_hidden: 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, Any]]] = None,
- on_blur: Optional[EventType[[], BASE_STATE]] = None,
- on_click: Optional[EventType[[], BASE_STATE]] = None,
- on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
- on_double_click: Optional[EventType[[], BASE_STATE]] = None,
- on_focus: Optional[EventType[[], BASE_STATE]] = None,
- on_mount: Optional[EventType[[], BASE_STATE]] = None,
- on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
- on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
- on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
- on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
- on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
- on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
- on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
- on_scroll: Optional[EventType[[], BASE_STATE]] = None,
- on_unmount: Optional[EventType[[], BASE_STATE]] = None,
- **props,
- ) -> "Toaster":
- """Create a toaster component.
- Args:
- *children: The children of the toaster.
- theme: the theme of the toast
- rich_colors: whether to show rich colors
- expand: whether to expand the toast
- visible_toasts: the number of toasts that are currently visible
- position: the position of the toast
- close_button: whether to show the close button
- offset: offset of the toast
- dir: directionality of the toast (default: ltr)
- hotkey: Keyboard shortcut that will move focus to the toaster area.
- invert: Dark toasts in light mode and vice versa.
- toast_options: These will act as default options for all toasts. See toast() for all available options.
- gap: Gap between toasts when expanded
- loading_icon: Changes the default loading icon
- pause_when_page_is_hidden: Pauses toast timers when the page is hidden, e.g., when the tab is backgrounded, the browser is minimized, or the OS is locked.
- 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 properties of the toaster.
- Returns:
- The toaster component.
- """
- ...
- class ToastNamespace(ComponentNamespace):
- provider = staticmethod(Toaster.create)
- options = staticmethod(ToastProps)
- info = staticmethod(Toaster.toast_info)
- warning = staticmethod(Toaster.toast_warning)
- error = staticmethod(Toaster.toast_error)
- success = staticmethod(Toaster.toast_success)
- dismiss = staticmethod(Toaster.toast_dismiss)
- @staticmethod
- def __call__(
- message: Union[str, Var] = "", level: Optional[str] = None, **props
- ) -> "Optional[EventSpec]":
- """Send a toast message.
- Args:
- message: The message to display.
- level: The level of the toast.
- **props: The options for the toast.
- Raises:
- ValueError: If the Toaster component is not created.
- Returns:
- The toast event.
- """
- ...
- toast = ToastNamespace()
|