reflex 0.8.0a4__py3-none-any.whl → 0.8.0a6__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.
- reflex/.templates/jinja/web/pages/_app.js.jinja2 +1 -1
- reflex/.templates/jinja/web/styles/styles.css.jinja2 +1 -0
- reflex/.templates/web/app/routes.js +3 -3
- reflex/.templates/web/utils/client_side_routing.js +1 -1
- reflex/.templates/web/utils/state.js +110 -52
- reflex/__init__.pyi +327 -188
- reflex/app.py +50 -48
- reflex/compiler/compiler.py +6 -2
- reflex/compiler/utils.py +32 -14
- reflex/components/__init__.pyi +34 -15
- reflex/components/base/__init__.pyi +30 -19
- reflex/components/base/app_wrap.pyi +2 -3
- reflex/components/base/body.pyi +2 -3
- reflex/components/base/document.pyi +7 -13
- reflex/components/base/error_boundary.pyi +2 -3
- reflex/components/base/fragment.pyi +2 -3
- reflex/components/base/link.pyi +3 -5
- reflex/components/base/meta.py +4 -15
- reflex/components/base/meta.pyi +14 -18
- reflex/components/base/script.pyi +2 -3
- reflex/components/base/strict_mode.pyi +2 -3
- reflex/components/core/__init__.pyi +77 -38
- reflex/components/core/auto_scroll.pyi +2 -3
- reflex/components/core/banner.pyi +8 -14
- reflex/components/core/client_side_routing.pyi +2 -3
- reflex/components/core/clipboard.pyi +2 -3
- reflex/components/core/debounce.pyi +2 -3
- reflex/components/core/foreach.py +2 -2
- reflex/components/core/helmet.pyi +2 -3
- reflex/components/core/html.pyi +2 -3
- reflex/components/core/match.py +3 -3
- reflex/components/core/sticky.pyi +4 -7
- reflex/components/core/upload.py +2 -1
- reflex/components/core/upload.pyi +5 -9
- reflex/components/datadisplay/__init__.pyi +13 -7
- reflex/components/datadisplay/code.py +12 -7
- reflex/components/datadisplay/code.pyi +2 -3
- reflex/components/datadisplay/dataeditor.pyi +33 -11
- reflex/components/datadisplay/shiki_code_block.py +5 -3
- reflex/components/datadisplay/shiki_code_block.pyi +3 -5
- reflex/components/el/__init__.pyi +506 -246
- reflex/components/el/element.pyi +2 -3
- reflex/components/el/elements/__init__.pyi +504 -245
- reflex/components/el/elements/base.pyi +2 -3
- reflex/components/el/elements/forms.pyi +77 -49
- reflex/components/el/elements/inline.pyi +29 -57
- reflex/components/el/elements/media.pyi +26 -51
- reflex/components/el/elements/metadata.pyi +7 -13
- reflex/components/el/elements/other.pyi +8 -15
- reflex/components/el/elements/scripts.pyi +4 -7
- reflex/components/el/elements/sectioning.pyi +16 -31
- reflex/components/el/elements/tables.pyi +11 -21
- reflex/components/el/elements/typography.pyi +16 -31
- reflex/components/gridjs/datatable.pyi +3 -5
- reflex/components/lucide/icon.pyi +4 -7
- reflex/components/markdown/markdown.py +5 -3
- reflex/components/markdown/markdown.pyi +2 -3
- reflex/components/moment/moment.py +1 -1
- reflex/components/moment/moment.pyi +2 -3
- reflex/components/plotly/plotly.py +12 -6
- reflex/components/plotly/plotly.pyi +31 -39
- reflex/components/radix/__init__.pyi +123 -65
- reflex/components/radix/primitives/__init__.pyi +6 -4
- reflex/components/radix/primitives/accordion.pyi +8 -15
- reflex/components/radix/primitives/base.pyi +3 -5
- reflex/components/radix/primitives/drawer.pyi +11 -21
- reflex/components/radix/primitives/form.pyi +22 -22
- reflex/components/radix/primitives/progress.pyi +5 -9
- reflex/components/radix/primitives/slider.pyi +6 -11
- reflex/components/radix/themes/__init__.pyi +5 -6
- reflex/components/radix/themes/base.pyi +9 -17
- reflex/components/radix/themes/color_mode.py +5 -6
- reflex/components/radix/themes/color_mode.pyi +4 -7
- reflex/components/radix/themes/components/__init__.pyi +75 -38
- reflex/components/radix/themes/components/alert_dialog.pyi +8 -15
- reflex/components/radix/themes/components/aspect_ratio.pyi +2 -3
- reflex/components/radix/themes/components/avatar.pyi +2 -3
- reflex/components/radix/themes/components/badge.pyi +2 -3
- reflex/components/radix/themes/components/button.pyi +2 -3
- reflex/components/radix/themes/components/callout.pyi +5 -9
- reflex/components/radix/themes/components/card.pyi +2 -3
- reflex/components/radix/themes/components/checkbox.pyi +3 -5
- reflex/components/radix/themes/components/checkbox_cards.pyi +3 -5
- reflex/components/radix/themes/components/checkbox_group.pyi +3 -5
- reflex/components/radix/themes/components/context_menu.pyi +14 -27
- reflex/components/radix/themes/components/data_list.pyi +5 -9
- reflex/components/radix/themes/components/dialog.pyi +7 -13
- reflex/components/radix/themes/components/dropdown_menu.pyi +9 -17
- reflex/components/radix/themes/components/hover_card.pyi +4 -7
- reflex/components/radix/themes/components/icon_button.pyi +2 -3
- reflex/components/radix/themes/components/inset.pyi +2 -3
- reflex/components/radix/themes/components/popover.pyi +5 -9
- reflex/components/radix/themes/components/progress.pyi +2 -3
- reflex/components/radix/themes/components/radio.pyi +2 -3
- reflex/components/radix/themes/components/radio_cards.pyi +3 -5
- reflex/components/radix/themes/components/radio_group.pyi +4 -7
- reflex/components/radix/themes/components/scroll_area.pyi +2 -3
- reflex/components/radix/themes/components/segmented_control.pyi +3 -5
- reflex/components/radix/themes/components/select.pyi +9 -17
- reflex/components/radix/themes/components/separator.pyi +2 -3
- reflex/components/radix/themes/components/skeleton.pyi +2 -3
- reflex/components/radix/themes/components/slider.pyi +12 -5
- reflex/components/radix/themes/components/spinner.pyi +2 -3
- reflex/components/radix/themes/components/switch.pyi +2 -3
- reflex/components/radix/themes/components/table.pyi +8 -15
- reflex/components/radix/themes/components/tabs.pyi +5 -9
- reflex/components/radix/themes/components/text_area.pyi +10 -5
- reflex/components/radix/themes/components/text_field.pyi +19 -9
- reflex/components/radix/themes/components/tooltip.pyi +2 -3
- reflex/components/radix/themes/layout/__init__.pyi +27 -14
- reflex/components/radix/themes/layout/base.pyi +2 -3
- reflex/components/radix/themes/layout/box.pyi +2 -3
- reflex/components/radix/themes/layout/center.pyi +2 -3
- reflex/components/radix/themes/layout/container.pyi +2 -3
- reflex/components/radix/themes/layout/flex.pyi +2 -3
- reflex/components/radix/themes/layout/grid.pyi +2 -3
- reflex/components/radix/themes/layout/list.pyi +5 -9
- reflex/components/radix/themes/layout/section.pyi +2 -3
- reflex/components/radix/themes/layout/spacer.pyi +2 -3
- reflex/components/radix/themes/layout/stack.pyi +4 -7
- reflex/components/radix/themes/typography/__init__.pyi +7 -5
- reflex/components/radix/themes/typography/blockquote.pyi +2 -3
- reflex/components/radix/themes/typography/code.pyi +2 -3
- reflex/components/radix/themes/typography/heading.pyi +2 -3
- reflex/components/radix/themes/typography/link.pyi +3 -5
- reflex/components/radix/themes/typography/text.pyi +7 -13
- reflex/components/react_player/audio.pyi +5 -4
- reflex/components/react_player/react_player.pyi +2 -3
- reflex/components/react_player/video.pyi +5 -4
- reflex/components/recharts/__init__.pyi +208 -100
- reflex/components/recharts/cartesian.py +8 -7
- reflex/components/recharts/cartesian.pyi +25 -48
- reflex/components/recharts/charts.pyi +13 -25
- reflex/components/recharts/general.pyi +7 -13
- reflex/components/recharts/polar.pyi +7 -13
- reflex/components/recharts/recharts.py +2 -2
- reflex/components/recharts/recharts.pyi +3 -5
- reflex/components/sonner/toast.py +1 -1
- reflex/components/sonner/toast.pyi +2 -3
- reflex/constants/installer.py +7 -8
- reflex/constants/route.py +13 -6
- reflex/istate/__init__.py +69 -0
- reflex/istate/manager.py +1 -0
- reflex/plugins/shared_tailwind.py +58 -1
- reflex/plugins/tailwind_v3.py +4 -4
- reflex/plugins/tailwind_v4.py +6 -5
- reflex/route.py +159 -71
- reflex/state.py +38 -16
- reflex/testing.py +2 -1
- reflex/utils/exec.py +18 -13
- reflex/utils/format.py +1 -5
- reflex/utils/imports.py +5 -12
- reflex/utils/misc.py +40 -0
- reflex/utils/prerequisites.py +7 -12
- reflex/utils/processes.py +8 -41
- reflex/utils/pyi_generator.py +23 -40
- reflex/utils/telemetry.py +0 -15
- reflex/utils/types.py +1 -1
- {reflex-0.8.0a4.dist-info → reflex-0.8.0a6.dist-info}/METADATA +3 -3
- {reflex-0.8.0a4.dist-info → reflex-0.8.0a6.dist-info}/RECORD +163 -163
- {reflex-0.8.0a4.dist-info → reflex-0.8.0a6.dist-info}/WHEEL +0 -0
- {reflex-0.8.0a4.dist-info → reflex-0.8.0a6.dist-info}/entry_points.txt +0 -0
- {reflex-0.8.0a4.dist-info → reflex-0.8.0a6.dist-info}/licenses/LICENSE +0 -0
|
@@ -34,7 +34,7 @@ function AppWrap({children}) {
|
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
export function Layout({children}) {
|
|
37
|
-
|
|
37
|
+
useEffect(() => {
|
|
38
38
|
// Make contexts and state objects available globally for dynamic eval'd components
|
|
39
39
|
let windowImports = {
|
|
40
40
|
{% for library_alias, library_path in window_libraries %}
|
|
@@ -2,9 +2,9 @@ import { route } from "@react-router/dev/routes";
|
|
|
2
2
|
import { flatRoutes } from "@react-router/fs-routes";
|
|
3
3
|
|
|
4
4
|
export default [
|
|
5
|
-
route("404", "routes/[404]
|
|
5
|
+
route("404", "routes/[404]._index.jsx", { id: "404" }),
|
|
6
6
|
...(await flatRoutes({
|
|
7
|
-
ignoredRouteFiles: ["routes/\\[404\\]
|
|
7
|
+
ignoredRouteFiles: ["routes/\\[404\\]._index.jsx"],
|
|
8
8
|
})),
|
|
9
|
-
route("*", "routes/[404]
|
|
9
|
+
route("*", "routes/[404]._index.jsx"),
|
|
10
10
|
];
|
|
@@ -25,7 +25,7 @@ export const useClientSideRouting = () => {
|
|
|
25
25
|
const search = window.location.search;
|
|
26
26
|
|
|
27
27
|
// Use navigate instead of replace
|
|
28
|
-
navigate(path + search, { replace: true })
|
|
28
|
+
navigate(path + search, { replace: true, state: { fromNotFound: true } })
|
|
29
29
|
.then(() => {
|
|
30
30
|
// Check if we're still on a NotFound route
|
|
31
31
|
// Note: This depends on how your routes are set up
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
// State management for Reflex web apps.
|
|
2
|
-
import axios from "axios";
|
|
3
2
|
import io from "socket.io-client";
|
|
4
3
|
import JSON5 from "json5";
|
|
5
4
|
import env from "$/env.json";
|
|
6
5
|
import reflexEnvironment from "$/reflex.json";
|
|
7
6
|
import Cookies from "universal-cookie";
|
|
8
|
-
import { useEffect, useRef, useState } from "react";
|
|
7
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
9
8
|
import {
|
|
10
9
|
useLocation,
|
|
11
10
|
useNavigate,
|
|
@@ -655,17 +654,6 @@ export const uploadFiles = async (
|
|
|
655
654
|
};
|
|
656
655
|
|
|
657
656
|
const controller = new AbortController();
|
|
658
|
-
const config = {
|
|
659
|
-
headers: {
|
|
660
|
-
"Reflex-Client-Token": getToken(),
|
|
661
|
-
"Reflex-Event-Handler": handler,
|
|
662
|
-
},
|
|
663
|
-
signal: controller.signal,
|
|
664
|
-
onDownloadProgress: eventHandler,
|
|
665
|
-
};
|
|
666
|
-
if (on_upload_progress) {
|
|
667
|
-
config["onUploadProgress"] = on_upload_progress;
|
|
668
|
-
}
|
|
669
657
|
const formdata = new FormData();
|
|
670
658
|
|
|
671
659
|
// Add the token and handler to the file name.
|
|
@@ -676,26 +664,85 @@ export const uploadFiles = async (
|
|
|
676
664
|
// Send the file to the server.
|
|
677
665
|
refs[upload_ref_name] = controller;
|
|
678
666
|
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
667
|
+
return new Promise((resolve, reject) => {
|
|
668
|
+
const xhr = new XMLHttpRequest();
|
|
669
|
+
|
|
670
|
+
// Set up event handlers
|
|
671
|
+
xhr.onload = function () {
|
|
672
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
673
|
+
resolve({
|
|
674
|
+
data: xhr.responseText,
|
|
675
|
+
status: xhr.status,
|
|
676
|
+
statusText: xhr.statusText,
|
|
677
|
+
headers: {
|
|
678
|
+
get: (name) => xhr.getResponseHeader(name),
|
|
679
|
+
},
|
|
680
|
+
});
|
|
681
|
+
} else {
|
|
682
|
+
reject(new Error(`HTTP error! status: ${xhr.status}`));
|
|
683
|
+
}
|
|
684
|
+
};
|
|
685
|
+
|
|
686
|
+
xhr.onerror = function () {
|
|
687
|
+
reject(new Error("Network error"));
|
|
688
|
+
};
|
|
689
|
+
|
|
690
|
+
xhr.onabort = function () {
|
|
691
|
+
reject(new Error("Upload aborted"));
|
|
692
|
+
};
|
|
693
|
+
|
|
694
|
+
// Handle upload progress
|
|
695
|
+
if (on_upload_progress) {
|
|
696
|
+
xhr.upload.onprogress = function (event) {
|
|
697
|
+
if (event.lengthComputable) {
|
|
698
|
+
const progressEvent = {
|
|
699
|
+
loaded: event.loaded,
|
|
700
|
+
total: event.total,
|
|
701
|
+
progress: event.loaded / event.total,
|
|
702
|
+
};
|
|
703
|
+
on_upload_progress(progressEvent);
|
|
704
|
+
}
|
|
705
|
+
};
|
|
694
706
|
}
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
707
|
+
|
|
708
|
+
// Handle download progress with streaming response parsing
|
|
709
|
+
xhr.onprogress = function (event) {
|
|
710
|
+
if (eventHandler) {
|
|
711
|
+
const progressEvent = {
|
|
712
|
+
event: {
|
|
713
|
+
target: {
|
|
714
|
+
responseText: xhr.responseText,
|
|
715
|
+
},
|
|
716
|
+
},
|
|
717
|
+
progress: event.lengthComputable ? event.loaded / event.total : 0,
|
|
718
|
+
};
|
|
719
|
+
eventHandler(progressEvent);
|
|
720
|
+
}
|
|
721
|
+
};
|
|
722
|
+
|
|
723
|
+
// Handle abort controller
|
|
724
|
+
controller.signal.addEventListener("abort", () => {
|
|
725
|
+
xhr.abort();
|
|
726
|
+
});
|
|
727
|
+
|
|
728
|
+
// Configure and send request
|
|
729
|
+
xhr.open("POST", getBackendURL(UPLOADURL));
|
|
730
|
+
xhr.setRequestHeader("Reflex-Client-Token", getToken());
|
|
731
|
+
xhr.setRequestHeader("Reflex-Event-Handler", handler);
|
|
732
|
+
|
|
733
|
+
try {
|
|
734
|
+
xhr.send(formdata);
|
|
735
|
+
} catch (error) {
|
|
736
|
+
reject(error);
|
|
737
|
+
}
|
|
738
|
+
})
|
|
739
|
+
.catch((error) => {
|
|
740
|
+
console.log("Upload error:", error.message);
|
|
741
|
+
return false;
|
|
742
|
+
})
|
|
743
|
+
.finally(() => {
|
|
744
|
+
delete refs[upload_ref_name];
|
|
745
|
+
});
|
|
699
746
|
};
|
|
700
747
|
|
|
701
748
|
/**
|
|
@@ -851,7 +898,7 @@ export const useEventLoop = (
|
|
|
851
898
|
}, [paramsR]);
|
|
852
899
|
|
|
853
900
|
// Function to add new events to the event queue.
|
|
854
|
-
const addEvents = (events, args, event_actions) => {
|
|
901
|
+
const addEvents = useCallback((events, args, event_actions) => {
|
|
855
902
|
const _events = events.filter((e) => e !== undefined && e !== null);
|
|
856
903
|
|
|
857
904
|
if (!(args instanceof Array)) {
|
|
@@ -894,7 +941,7 @@ export const useEventLoop = (
|
|
|
894
941
|
} else {
|
|
895
942
|
queueEvents(_events, socket, false, navigate, () => params.current);
|
|
896
943
|
}
|
|
897
|
-
};
|
|
944
|
+
}, []);
|
|
898
945
|
|
|
899
946
|
const sentHydrate = useRef(false); // Avoid double-hydrate due to React strict-mode
|
|
900
947
|
useEffect(() => {
|
|
@@ -1020,31 +1067,42 @@ export const useEventLoop = (
|
|
|
1020
1067
|
return () => window.removeEventListener("storage", handleStorage);
|
|
1021
1068
|
});
|
|
1022
1069
|
|
|
1070
|
+
const handleNavigationEvents = useRef(false);
|
|
1023
1071
|
// Route after the initial page hydration
|
|
1024
1072
|
useEffect(() => {
|
|
1073
|
+
// The first time this effect runs is initial load, so don't handle
|
|
1074
|
+
// any navigation events.
|
|
1075
|
+
if (!handleNavigationEvents.current) {
|
|
1076
|
+
handleNavigationEvents.current = true;
|
|
1077
|
+
return;
|
|
1078
|
+
}
|
|
1079
|
+
if (location.state?.fromNotFound) {
|
|
1080
|
+
// If the redirect is from a 404 page, we skip onLoadInternalEvent,
|
|
1081
|
+
// since it was already run when the 404 page was first rendered.
|
|
1082
|
+
return;
|
|
1083
|
+
}
|
|
1025
1084
|
// This will run when the location changes
|
|
1026
1085
|
if (
|
|
1027
|
-
location.pathname + location.search
|
|
1028
|
-
prevLocationRef.current.pathname +
|
|
1029
|
-
prevLocationRef.current.search +
|
|
1030
|
-
prevLocationRef.current.hash
|
|
1086
|
+
location.pathname + location.search ===
|
|
1087
|
+
prevLocationRef.current.pathname + prevLocationRef.current.search
|
|
1031
1088
|
) {
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
}
|
|
1038
|
-
};
|
|
1039
|
-
change_start();
|
|
1040
|
-
|
|
1041
|
-
// Equivalent to routeChangeComplete - runs after navigation completes
|
|
1042
|
-
const change_complete = () => addEvents(onLoadInternalEvent());
|
|
1043
|
-
change_complete();
|
|
1089
|
+
if (location.hash) {
|
|
1090
|
+
// If the hash is the same, we don't need to do anything.
|
|
1091
|
+
return;
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1044
1094
|
|
|
1045
|
-
|
|
1046
|
-
|
|
1095
|
+
// Equivalent to routeChangeStart - runs when navigation begins
|
|
1096
|
+
const main_state_dispatch = dispatch["reflex___state____state"];
|
|
1097
|
+
if (main_state_dispatch !== undefined) {
|
|
1098
|
+
main_state_dispatch({ is_hydrated_rx_state_: false });
|
|
1047
1099
|
}
|
|
1100
|
+
|
|
1101
|
+
// Equivalent to routeChangeComplete - runs after navigation completes
|
|
1102
|
+
addEvents(onLoadInternalEvent());
|
|
1103
|
+
|
|
1104
|
+
// Update the ref
|
|
1105
|
+
prevLocationRef.current = location;
|
|
1048
1106
|
}, [location, dispatch, onLoadInternalEvent, addEvents]);
|
|
1049
1107
|
|
|
1050
1108
|
return [addEvents, connectErrors];
|