__init__.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. """Namespace for experimental features."""
  2. from types import SimpleNamespace
  3. from reflex.components.props import PropsBase
  4. from reflex.components.radix.themes.components.progress import progress as progress
  5. from reflex.components.sonner.toast import toast as toast
  6. from ..utils.console import warn
  7. from . import hooks as hooks
  8. from .assets import asset as asset
  9. from .client_state import ClientStateVar as ClientStateVar
  10. from .layout import layout as layout
  11. from .misc import run_in_thread as run_in_thread
  12. warn(
  13. "`rx._x` contains experimental features and might be removed at any time in the future .",
  14. )
  15. _EMITTED_PROMOTION_WARNINGS = set()
  16. class ExperimentalNamespace(SimpleNamespace):
  17. """Namespace for experimental features."""
  18. @property
  19. def toast(self):
  20. """Temporary property returning the toast namespace.
  21. Remove this property when toast is fully promoted.
  22. Returns:
  23. The toast namespace.
  24. """
  25. if "toast" not in _EMITTED_PROMOTION_WARNINGS:
  26. _EMITTED_PROMOTION_WARNINGS.add("toast")
  27. warn(f"`rx._x.toast` was promoted to `rx.toast`.")
  28. return toast
  29. _x = ExperimentalNamespace(
  30. asset=asset,
  31. client_state=ClientStateVar.create,
  32. hooks=hooks,
  33. layout=layout,
  34. progress=progress,
  35. PropsBase=PropsBase,
  36. run_in_thread=run_in_thread,
  37. )