toast.pyi 7.4 KB

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