1
0

toast.pyi 7.5 KB

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