toast.pyi 8.0 KB

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