eptm_dashboard/.venv/lib/python3.12/site-packages/reflex_components_sonner/toast.pyi

228 lines
9.2 KiB
Python

"""Stub file for reflex_components_sonner/toast.py"""
# ------------------- DO NOT EDIT ----------------------
# This file was generated by `reflex/utils/pyi_generator.py`!
# ------------------------------------------------------
import dataclasses
from collections.abc import Mapping, Sequence
from typing import Any, Literal
from reflex_base.components.component import Component, ComponentNamespace
from reflex_base.components.props import NoExtrasAllowedProps
from reflex_base.constants.base import Dirs
from reflex_base.event import EventSpec, EventType, PointerEventInfo
from reflex_base.style import Style
from reflex_base.utils.imports import ImportVar
from reflex_base.utils.serializers import serializer
from reflex_base.vars import VarData
from reflex_base.vars.base import Var
from reflex_components_core.core.breakpoints import Breakpoints
from reflex_components_lucide.icon import Icon
LiteralPosition = Literal[
"top-left",
"top-center",
"top-right",
"bottom-left",
"bottom-center",
"bottom-right",
]
toast_ref = Var(
_js_expr="refs['__toast']",
_var_data=VarData(imports={f"$/{Dirs.STATE_PATH}": [ImportVar(tag="refs")]}),
)
@dataclasses.dataclass
class ToastAction:
label: str
on_click: Any
@serializer
def serialize_action(action: ToastAction) -> dict: ...
class ToastProps(NoExtrasAllowedProps):
title: str | Var | None
description: str | Var | None
close_button: bool | None
invert: bool | None
important: bool | None
duration: int | None
position: LiteralPosition | None
dismissible: bool | None
action: ToastAction | None
cancel: ToastAction | None
id: str | Var | None
unstyled: bool | None
style: Style | None
class_name: str | None
action_button_styles: Style | None
cancel_button_styles: Style | None
on_dismiss: Any | None
on_auto_close: Any | None
def dict(self, *args: Any, **kwargs: Any) -> dict[str, Any]: ...
class Toaster(Component):
def add_hooks(self) -> list[Var | str]: ...
@staticmethod
def send_toast(
message: str | Var[str] = "",
level: str | None = None,
fallback_to_alert: bool = False,
**props,
) -> EventSpec: ...
@staticmethod
def toast_info(message: str | Var[str] = "", **kwargs: Any) -> EventSpec: ...
@staticmethod
def toast_warning(message: str | Var[str] = "", **kwargs: Any) -> EventSpec: ...
@staticmethod
def toast_error(message: str | Var[str] = "", **kwargs: Any) -> EventSpec: ...
@staticmethod
def toast_success(message: str | Var[str] = "", **kwargs: Any) -> EventSpec: ...
@staticmethod
def toast_loading(message: str | Var[str] = "", **kwargs: Any) -> EventSpec: ...
@staticmethod
def toast_dismiss(id: Var[str] | str | None = None) -> EventSpec: ...
@classmethod
def create(
cls,
*children,
theme: Var[str] | str | None = None,
rich_colors: Var[bool] | bool | None = None,
expand: Var[bool] | bool | None = None,
visible_toasts: Var[int] | int | None = None,
position: 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 = None,
close_button: Var[bool] | bool | None = None,
offset: Var[str] | str | None = None,
dir: Var[str] | str | None = None,
hotkey: Var[str] | str | None = None,
invert: Var[bool] | bool | None = None,
toast_options: ToastProps | Var[ToastProps] | None = None,
gap: Var[int] | int | None = None,
loading_icon: Icon | Var[Icon] | None = None,
pause_when_page_is_hidden: Var[bool] | bool | None = None,
style: Sequence[Mapping[str, Any]]
| Mapping[str, Any]
| Var[Mapping[str, Any]]
| Breakpoints
| None = None,
key: Any | None = None,
id: Any | None = None,
ref: Var | None = None,
class_name: Any | None = None,
custom_attrs: dict[str, Any | Var] | None = None,
on_blur: EventType[()] | None = None,
on_click: EventType[()] | EventType[PointerEventInfo] | None = None,
on_context_menu: EventType[()] | EventType[PointerEventInfo] | None = None,
on_double_click: EventType[()] | EventType[PointerEventInfo] | None = None,
on_focus: EventType[()] | None = None,
on_mount: EventType[()] | None = None,
on_mouse_down: EventType[()] | None = None,
on_mouse_enter: EventType[()] | None = None,
on_mouse_leave: EventType[()] | None = None,
on_mouse_move: EventType[()] | None = None,
on_mouse_out: EventType[()] | None = None,
on_mouse_over: EventType[()] | None = None,
on_mouse_up: EventType[()] | None = None,
on_scroll: EventType[()] | None = None,
on_scroll_end: EventType[()] | None = None,
on_unmount: EventType[()] | None = 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.
ref: The Var to pass as the ref to the component.
class_name: The class name for the component.
custom_attrs: Attributes passed directly to the component.
on_focus: Fired when the element (or some element inside of it) receives focus. For example, it is called when the user clicks on a text input.
on_blur: Fired when focus has left the element (or left some element inside of it). For example, it is called when the user clicks outside of a focused text input.
on_click: Fired when the user clicks on an element. For example, it's called when the user clicks on a button.
on_context_menu: Fired when the user right-clicks on an element.
on_double_click: Fired when the user double-clicks on an element.
on_mouse_down: Fired when the user presses a mouse button on an element.
on_mouse_enter: Fired when the mouse pointer enters the element.
on_mouse_leave: Fired when the mouse pointer leaves the element.
on_mouse_move: Fired when the mouse pointer moves over the element.
on_mouse_out: Fired when the mouse pointer moves out of the element.
on_mouse_over: Fired when the mouse pointer moves onto the element.
on_mouse_up: Fired when the user releases a mouse button on an element.
on_scroll: Fired when the user scrolls the element.
on_scroll_end: Fired when scrolling ends on the element.
on_mount: Fired when the component is mounted to the page.
on_unmount: Fired when the component is removed from the page. Only called during navigation, not on page refresh.
**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)
loading = staticmethod(Toaster.toast_loading)
dismiss = staticmethod(Toaster.toast_dismiss)
@staticmethod
def __call__(
message: str | Var[str] | str = "",
level: str | None = None,
fallback_to_alert: bool = False,
**props,
) -> EventSpec:
"""Send a toast message.
Args:
message: The message to display.
level: The level of the toast.
fallback_to_alert: Whether to fallback to an alert if the toaster is not created.
**props: The options for the toast.
Returns:
The toast event.
Raises:
ValueError: If the Toaster component is not created.
"""
toast = ToastNamespace()