toast.pyi 8.0 KB

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