reflex 0.8.6a1__py3-none-any.whl → 0.8.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of reflex might be problematic. Click here for more details.

Files changed (37) hide show
  1. reflex/.templates/jinja/web/vite.config.js.jinja2 +4 -1
  2. reflex/.templates/web/app/routes.js +0 -1
  3. reflex/.templates/web/utils/state.js +1 -11
  4. reflex/app.py +15 -23
  5. reflex/components/component.py +6 -4
  6. reflex/components/lucide/icon.py +4 -1
  7. reflex/components/lucide/icon.pyi +4 -1
  8. reflex/components/plotly/plotly.py +9 -9
  9. reflex/components/recharts/recharts.py +2 -2
  10. reflex/components/sonner/toast.py +7 -7
  11. reflex/components/sonner/toast.pyi +8 -8
  12. reflex/config.py +9 -2
  13. reflex/constants/base.py +2 -0
  14. reflex/constants/installer.py +6 -6
  15. reflex/constants/state.py +1 -0
  16. reflex/custom_components/custom_components.py +3 -3
  17. reflex/reflex.py +7 -6
  18. reflex/route.py +4 -0
  19. reflex/state.py +1 -1
  20. reflex/testing.py +3 -5
  21. reflex/utils/build.py +21 -3
  22. reflex/utils/exec.py +11 -11
  23. reflex/utils/frontend_skeleton.py +254 -0
  24. reflex/utils/js_runtimes.py +411 -0
  25. reflex/utils/prerequisites.py +17 -1383
  26. reflex/utils/rename.py +170 -0
  27. reflex/utils/telemetry.py +101 -10
  28. reflex/utils/templates.py +443 -0
  29. reflex/vars/base.py +3 -3
  30. {reflex-0.8.6a1.dist-info → reflex-0.8.7.dist-info}/METADATA +2 -2
  31. {reflex-0.8.6a1.dist-info → reflex-0.8.7.dist-info}/RECORD +34 -33
  32. reflex/.templates/web/utils/client_side_routing.js +0 -45
  33. reflex/components/core/client_side_routing.py +0 -70
  34. reflex/components/core/client_side_routing.pyi +0 -68
  35. {reflex-0.8.6a1.dist-info → reflex-0.8.7.dist-info}/WHEEL +0 -0
  36. {reflex-0.8.6a1.dist-info → reflex-0.8.7.dist-info}/entry_points.txt +0 -0
  37. {reflex-0.8.6a1.dist-info → reflex-0.8.7.dist-info}/licenses/LICENSE +0 -0
@@ -1,45 +0,0 @@
1
- import { useEffect, useRef, useState } from "react";
2
- import { useLocation, useNavigate } from "react-router-dom";
3
-
4
- /**
5
- * React hook for use in NotFound page to enable client-side routing.
6
- *
7
- * Uses React Router to redirect to the provided URL when loading
8
- * the NotFound page (for example as a fallback in static hosting situations).
9
- *
10
- * @returns {boolean} routeNotFound - true if the current route is an actual 404
11
- */
12
- export const useClientSideRouting = () => {
13
- const [routeNotFound, setRouteNotFound] = useState(false);
14
- const didRedirect = useRef(false);
15
- const location = useLocation();
16
- const navigate = useNavigate();
17
-
18
- useEffect(() => {
19
- if (!didRedirect.current) {
20
- // have not tried redirecting yet
21
- didRedirect.current = true; // never redirect twice to avoid navigation loops
22
-
23
- // attempt to redirect to the route in the browser address bar once
24
- const path = window.location.pathname;
25
- const search = window.location.search;
26
-
27
- // Use navigate instead of replace
28
- navigate(path + search, { replace: true, state: { fromNotFound: true } })
29
- .then(() => {
30
- // Check if we're still on a NotFound route
31
- // Note: This depends on how your routes are set up
32
- if (location.pathname === path) {
33
- setRouteNotFound(true); // Mark as an actual 404
34
- }
35
- })
36
- .catch(() => {
37
- setRouteNotFound(true); // navigation failed, so this is a real 404
38
- });
39
- }
40
- }, [location, navigate]);
41
-
42
- // Return the reactive bool, to avoid flashing 404 page until we know for sure
43
- // the route is not found.
44
- return routeNotFound;
45
- };
@@ -1,70 +0,0 @@
1
- """Handle dynamic routes in static exports via client-side routing.
2
-
3
- Works with /utils/client_side_routing.js to handle the redirect and state.
4
-
5
- When the user hits a 404 accessing a route, redirect them to the same page,
6
- setting a reactive state var "routeNotFound" to true if the redirect fails. The
7
- `wait_for_client_redirect` function will render the component only after
8
- routeNotFound becomes true.
9
- """
10
-
11
- from __future__ import annotations
12
-
13
- from reflex import constants
14
- from reflex.components.component import Component
15
- from reflex.components.core.cond import cond
16
- from reflex.vars.base import Var
17
-
18
- route_not_found: Var = Var(_js_expr=constants.ROUTE_NOT_FOUND)
19
-
20
-
21
- class ClientSideRouting(Component):
22
- """The client-side routing component."""
23
-
24
- library = "$/utils/client_side_routing"
25
- tag = "useClientSideRouting"
26
-
27
- def add_hooks(self) -> list[str | Var]:
28
- """Get the hooks to render.
29
-
30
- Returns:
31
- The useClientSideRouting hook.
32
- """
33
- return [f"const {constants.ROUTE_NOT_FOUND} = {self.tag}()"]
34
-
35
- def render(self) -> str:
36
- """Render the component.
37
-
38
- Returns:
39
- Empty string, because this component is only used for its hooks.
40
- """
41
- return ""
42
-
43
-
44
- def wait_for_client_redirect(component: Component) -> Component:
45
- """Wait for a redirect to occur before rendering a component.
46
-
47
- This prevents the 404 page from flashing while the redirect is happening.
48
-
49
- Args:
50
- component: The component to render after the redirect.
51
-
52
- Returns:
53
- The conditionally rendered component.
54
- """
55
- return cond(
56
- route_not_found,
57
- component,
58
- ClientSideRouting.create(),
59
- )
60
-
61
-
62
- def default_404_page() -> Component:
63
- """Render the default 404 page.
64
-
65
- Returns:
66
- The 404 page component.
67
- """
68
- import reflex as rx
69
-
70
- return rx.el.span("404: Page not found")
@@ -1,68 +0,0 @@
1
- """Stub file for reflex/components/core/client_side_routing.py"""
2
-
3
- # ------------------- DO NOT EDIT ----------------------
4
- # This file was generated by `reflex/utils/pyi_generator.py`!
5
- # ------------------------------------------------------
6
- from collections.abc import Mapping, Sequence
7
- from typing import Any
8
-
9
- from reflex.components.component import Component
10
- from reflex.components.core.breakpoints import Breakpoints
11
- from reflex.event import EventType, PointerEventInfo
12
- from reflex.vars.base import Var
13
-
14
- route_not_found: Var
15
-
16
- class ClientSideRouting(Component):
17
- def add_hooks(self) -> list[str | Var]: ...
18
- def render(self) -> str: ...
19
- @classmethod
20
- def create(
21
- cls,
22
- *children,
23
- style: Sequence[Mapping[str, Any]]
24
- | Mapping[str, Any]
25
- | Var[Mapping[str, Any]]
26
- | Breakpoints
27
- | None = None,
28
- key: Any | None = None,
29
- id: Any | None = None,
30
- ref: Var | None = None,
31
- class_name: Any | None = None,
32
- custom_attrs: dict[str, Var | Any] | None = None,
33
- on_blur: EventType[()] | None = None,
34
- on_click: EventType[()] | EventType[PointerEventInfo] | None = None,
35
- on_context_menu: EventType[()] | EventType[PointerEventInfo] | None = None,
36
- on_double_click: EventType[()] | EventType[PointerEventInfo] | None = None,
37
- on_focus: EventType[()] | None = None,
38
- on_mount: EventType[()] | None = None,
39
- on_mouse_down: EventType[()] | None = None,
40
- on_mouse_enter: EventType[()] | None = None,
41
- on_mouse_leave: EventType[()] | None = None,
42
- on_mouse_move: EventType[()] | None = None,
43
- on_mouse_out: EventType[()] | None = None,
44
- on_mouse_over: EventType[()] | None = None,
45
- on_mouse_up: EventType[()] | None = None,
46
- on_scroll: EventType[()] | None = None,
47
- on_scroll_end: EventType[()] | None = None,
48
- on_unmount: EventType[()] | None = None,
49
- **props,
50
- ) -> ClientSideRouting:
51
- """Create the component.
52
-
53
- Args:
54
- *children: The children of the component.
55
- style: The style of the component.
56
- key: A unique key for the component.
57
- id: The id for the component.
58
- ref: The Var to pass as the ref to the component.
59
- class_name: The class name for the component.
60
- custom_attrs: custom attribute
61
- **props: The props of the component.
62
-
63
- Returns:
64
- The component.
65
- """
66
-
67
- def wait_for_client_redirect(component: Component) -> Component: ...
68
- def default_404_page() -> Component: ...