toast.pyi 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. """Stub file for reflex/components/sonner/toast.py"""
  2. # ------------------- DO NOT EDIT ----------------------
  3. # This file was generated by `reflex/utils/pyi_generator.py`!
  4. # ------------------------------------------------------
  5. from typing import Any, ClassVar, Dict, Literal, Optional, Union, overload
  6. from reflex.base import Base
  7. from reflex.components.component import Component, ComponentNamespace
  8. from reflex.components.lucide.icon import Icon
  9. from reflex.components.props import NoExtrasAllowedProps, PropsBase
  10. from reflex.event import EventSpec, EventType
  11. from reflex.style import Style
  12. from reflex.utils.serializers import serializer
  13. from reflex.vars.base import Var
  14. LiteralPosition = Literal[
  15. "top-left",
  16. "top-center",
  17. "top-right",
  18. "bottom-left",
  19. "bottom-center",
  20. "bottom-right",
  21. ]
  22. toast_ref = Var(_js_expr="refs['__toast']")
  23. class ToastAction(Base):
  24. label: str
  25. on_click: Any
  26. @serializer
  27. def serialize_action(action: ToastAction) -> dict: ...
  28. class ToastProps(PropsBase, NoExtrasAllowedProps):
  29. title: Optional[Union[str, Var]]
  30. description: Optional[Union[str, Var]]
  31. close_button: Optional[bool]
  32. invert: Optional[bool]
  33. important: Optional[bool]
  34. duration: Optional[int]
  35. position: Optional[LiteralPosition]
  36. dismissible: Optional[bool]
  37. action: Optional[ToastAction]
  38. cancel: Optional[ToastAction]
  39. id: Optional[Union[str, Var]]
  40. unstyled: Optional[bool]
  41. style: Optional[Style]
  42. action_button_styles: Optional[Style]
  43. cancel_button_styles: Optional[Style]
  44. on_dismiss: Optional[Any]
  45. on_auto_close: Optional[Any]
  46. def dict(self, *args, **kwargs) -> dict[str, Any]: ...
  47. class Toaster(Component):
  48. is_used: ClassVar[bool] = False
  49. def add_hooks(self) -> list[Var | str]: ...
  50. @staticmethod
  51. def send_toast(
  52. message: str = "", level: str | None = None, **props
  53. ) -> EventSpec: ...
  54. @staticmethod
  55. def toast_info(message: str = "", **kwargs): ...
  56. @staticmethod
  57. def toast_warning(message: str = "", **kwargs): ...
  58. @staticmethod
  59. def toast_error(message: str = "", **kwargs): ...
  60. @staticmethod
  61. def toast_success(message: str = "", **kwargs): ...
  62. @staticmethod
  63. def toast_dismiss(id: Var | str | None = None): ...
  64. @overload
  65. @classmethod
  66. def create( # type: ignore
  67. cls,
  68. *children,
  69. theme: Optional[Union[Var[str], str]] = None,
  70. rich_colors: Optional[Union[Var[bool], bool]] = None,
  71. expand: Optional[Union[Var[bool], bool]] = None,
  72. visible_toasts: Optional[Union[Var[int], int]] = None,
  73. position: Optional[
  74. Union[
  75. Literal[
  76. "bottom-center",
  77. "bottom-left",
  78. "bottom-right",
  79. "top-center",
  80. "top-left",
  81. "top-right",
  82. ],
  83. Var[
  84. Literal[
  85. "bottom-center",
  86. "bottom-left",
  87. "bottom-right",
  88. "top-center",
  89. "top-left",
  90. "top-right",
  91. ]
  92. ],
  93. ]
  94. ] = None,
  95. close_button: Optional[Union[Var[bool], bool]] = None,
  96. offset: Optional[Union[Var[str], str]] = None,
  97. dir: Optional[Union[Var[str], str]] = None,
  98. hotkey: Optional[Union[Var[str], str]] = None,
  99. invert: Optional[Union[Var[bool], bool]] = None,
  100. toast_options: Optional[Union[ToastProps, Var[ToastProps]]] = None,
  101. gap: Optional[Union[Var[int], int]] = None,
  102. loading_icon: Optional[Union[Icon, Var[Icon]]] = None,
  103. pause_when_page_is_hidden: Optional[Union[Var[bool], bool]] = None,
  104. style: Optional[Style] = None,
  105. key: Optional[Any] = None,
  106. id: Optional[Any] = None,
  107. class_name: Optional[Any] = None,
  108. autofocus: Optional[bool] = None,
  109. custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
  110. on_blur: Optional[EventType[[]]] = None,
  111. on_click: Optional[EventType[[]]] = None,
  112. on_context_menu: Optional[EventType[[]]] = None,
  113. on_double_click: Optional[EventType[[]]] = None,
  114. on_focus: Optional[EventType[[]]] = None,
  115. on_mount: Optional[EventType[[]]] = None,
  116. on_mouse_down: Optional[EventType[[]]] = None,
  117. on_mouse_enter: Optional[EventType[[]]] = None,
  118. on_mouse_leave: Optional[EventType[[]]] = None,
  119. on_mouse_move: Optional[EventType[[]]] = None,
  120. on_mouse_out: Optional[EventType[[]]] = None,
  121. on_mouse_over: Optional[EventType[[]]] = None,
  122. on_mouse_up: Optional[EventType[[]]] = None,
  123. on_scroll: Optional[EventType[[]]] = None,
  124. on_unmount: Optional[EventType[[]]] = None,
  125. **props,
  126. ) -> "Toaster":
  127. """Create a toaster component.
  128. Args:
  129. *children: The children of the toaster.
  130. theme: the theme of the toast
  131. rich_colors: whether to show rich colors
  132. expand: whether to expand the toast
  133. visible_toasts: the number of toasts that are currently visible
  134. position: the position of the toast
  135. close_button: whether to show the close button
  136. offset: offset of the toast
  137. dir: directionality of the toast (default: ltr)
  138. hotkey: Keyboard shortcut that will move focus to the toaster area.
  139. invert: Dark toasts in light mode and vice versa.
  140. toast_options: These will act as default options for all toasts. See toast() for all available options.
  141. gap: Gap between toasts when expanded
  142. loading_icon: Changes the default loading icon
  143. 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.
  144. style: The style of the component.
  145. key: A unique key for the component.
  146. id: The id for the component.
  147. class_name: The class name for the component.
  148. autofocus: Whether the component should take the focus once the page is loaded
  149. custom_attrs: custom attribute
  150. **props: The properties of the toaster.
  151. Returns:
  152. The toaster component.
  153. """
  154. ...
  155. class ToastNamespace(ComponentNamespace):
  156. provider = staticmethod(Toaster.create)
  157. options = staticmethod(ToastProps)
  158. info = staticmethod(Toaster.toast_info)
  159. warning = staticmethod(Toaster.toast_warning)
  160. error = staticmethod(Toaster.toast_error)
  161. success = staticmethod(Toaster.toast_success)
  162. dismiss = staticmethod(Toaster.toast_dismiss)
  163. @staticmethod
  164. def __call__(
  165. message: str = "", level: Optional[str] = None, **props
  166. ) -> "Optional[EventSpec]":
  167. """Send a toast message.
  168. Args:
  169. message: The message to display.
  170. level: The level of the toast.
  171. **props: The options for the toast.
  172. Raises:
  173. ValueError: If the Toaster component is not created.
  174. Returns:
  175. The toast event.
  176. """
  177. ...
  178. toast = ToastNamespace()