reflex 0.6.4a2__py3-none-any.whl → 0.6.5__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/custom_component.js.jinja2 +0 -14
- reflex/.templates/jinja/web/pages/utils.js.jinja2 +4 -8
- reflex/.templates/web/components/shiki/code.js +16 -11
- reflex/.templates/web/utils/state.js +29 -21
- reflex/__init__.py +4 -0
- reflex/__init__.pyi +4 -0
- reflex/app.py +148 -154
- reflex/app_mixins/lifespan.py +5 -1
- reflex/app_mixins/middleware.py +3 -1
- reflex/app_mixins/mixin.py +3 -2
- reflex/base.py +2 -4
- reflex/compiler/compiler.py +111 -37
- reflex/components/base/app_wrap.pyi +17 -17
- reflex/components/base/bare.py +72 -3
- reflex/components/base/body.pyi +17 -17
- reflex/components/base/document.pyi +81 -81
- reflex/components/base/error_boundary.pyi +25 -18
- reflex/components/base/fragment.pyi +17 -17
- reflex/components/base/head.pyi +33 -33
- reflex/components/base/link.pyi +33 -33
- reflex/components/base/meta.pyi +65 -65
- reflex/components/base/script.py +4 -4
- reflex/components/base/script.pyi +23 -20
- reflex/components/component.py +250 -31
- reflex/components/core/banner.py +1 -1
- reflex/components/core/banner.pyi +81 -81
- reflex/components/core/client_side_routing.pyi +33 -33
- reflex/components/core/clipboard.py +2 -2
- reflex/components/core/clipboard.pyi +24 -18
- reflex/components/core/debounce.py +2 -2
- reflex/components/core/debounce.pyi +18 -18
- reflex/components/core/html.pyi +17 -17
- reflex/components/core/upload.py +90 -28
- reflex/components/core/upload.pyi +128 -72
- reflex/components/datadisplay/code.py +55 -40
- reflex/components/datadisplay/code.pyi +46 -44
- reflex/components/datadisplay/dataeditor.py +21 -20
- reflex/components/datadisplay/dataeditor.pyi +103 -35
- reflex/components/datadisplay/shiki_code_block.py +60 -27
- reflex/components/datadisplay/shiki_code_block.pyi +86 -65
- reflex/components/dynamic.py +9 -5
- reflex/components/el/element.pyi +17 -17
- reflex/components/el/elements/base.pyi +17 -17
- reflex/components/el/elements/forms.py +12 -3
- reflex/components/el/elements/forms.pyi +293 -233
- reflex/components/el/elements/inline.pyi +449 -449
- reflex/components/el/elements/media.pyi +401 -401
- reflex/components/el/elements/metadata.pyi +97 -97
- reflex/components/el/elements/other.pyi +113 -113
- reflex/components/el/elements/scripts.pyi +49 -49
- reflex/components/el/elements/sectioning.pyi +241 -241
- reflex/components/el/elements/tables.pyi +161 -161
- reflex/components/el/elements/typography.pyi +241 -241
- reflex/components/gridjs/datatable.pyi +33 -33
- reflex/components/lucide/icon.py +1 -1
- reflex/components/lucide/icon.pyi +33 -33
- reflex/components/markdown/markdown.py +180 -49
- reflex/components/markdown/markdown.pyi +36 -19
- reflex/components/moment/moment.py +17 -21
- reflex/components/moment/moment.pyi +26 -21
- reflex/components/next/base.pyi +17 -17
- reflex/components/next/image.py +3 -3
- reflex/components/next/image.pyi +21 -19
- reflex/components/next/link.pyi +17 -17
- reflex/components/next/video.pyi +17 -17
- reflex/components/plotly/plotly.py +79 -78
- reflex/components/plotly/plotly.pyi +91 -41
- reflex/components/props.py +34 -0
- reflex/components/radix/primitives/accordion.py +15 -8
- reflex/components/radix/primitives/accordion.pyi +121 -118
- reflex/components/radix/primitives/base.pyi +33 -33
- reflex/components/radix/primitives/drawer.py +41 -20
- reflex/components/radix/primitives/drawer.pyi +279 -190
- reflex/components/radix/primitives/form.py +2 -2
- reflex/components/radix/primitives/form.pyi +200 -167
- reflex/components/radix/primitives/progress.pyi +81 -81
- reflex/components/radix/primitives/slider.pyi +89 -83
- reflex/components/radix/themes/base.py +30 -1
- reflex/components/radix/themes/base.pyi +286 -113
- reflex/components/radix/themes/color_mode.py +17 -9
- reflex/components/radix/themes/color_mode.pyi +68 -56
- reflex/components/radix/themes/components/alert_dialog.py +8 -5
- reflex/components/radix/themes/components/alert_dialog.pyi +125 -117
- reflex/components/radix/themes/components/aspect_ratio.pyi +17 -17
- reflex/components/radix/themes/components/avatar.py +1 -5
- reflex/components/radix/themes/components/avatar.pyi +17 -17
- reflex/components/radix/themes/components/badge.py +1 -5
- reflex/components/radix/themes/components/badge.pyi +17 -17
- reflex/components/radix/themes/components/button.pyi +18 -21
- reflex/components/radix/themes/components/callout.py +1 -4
- reflex/components/radix/themes/components/callout.pyi +81 -81
- reflex/components/radix/themes/components/card.py +1 -3
- reflex/components/radix/themes/components/card.pyi +17 -17
- reflex/components/radix/themes/components/checkbox.py +4 -8
- reflex/components/radix/themes/components/checkbox.pyi +61 -52
- reflex/components/radix/themes/components/checkbox_cards.pyi +33 -33
- reflex/components/radix/themes/components/checkbox_group.pyi +33 -33
- reflex/components/radix/themes/components/context_menu.py +121 -28
- reflex/components/radix/themes/components/context_menu.pyi +250 -147
- reflex/components/radix/themes/components/data_list.pyi +65 -65
- reflex/components/radix/themes/components/dialog.py +11 -11
- reflex/components/radix/themes/components/dialog.pyi +135 -120
- reflex/components/radix/themes/components/dropdown_menu.py +14 -25
- reflex/components/radix/themes/components/dropdown_menu.pyi +157 -145
- reflex/components/radix/themes/components/hover_card.py +19 -7
- reflex/components/radix/themes/components/hover_card.pyi +102 -67
- reflex/components/radix/themes/components/icon_button.pyi +18 -21
- reflex/components/radix/themes/components/inset.py +1 -3
- reflex/components/radix/themes/components/inset.pyi +17 -17
- reflex/components/radix/themes/components/popover.py +22 -13
- reflex/components/radix/themes/components/popover.pyi +98 -72
- reflex/components/radix/themes/components/progress.pyi +17 -17
- reflex/components/radix/themes/components/radio.pyi +17 -17
- reflex/components/radix/themes/components/radio_cards.py +2 -2
- reflex/components/radix/themes/components/radio_cards.pyi +37 -34
- reflex/components/radix/themes/components/radio_group.py +3 -7
- reflex/components/radix/themes/components/radio_group.pyi +69 -66
- reflex/components/radix/themes/components/scroll_area.py +1 -3
- reflex/components/radix/themes/components/scroll_area.pyi +17 -17
- reflex/components/radix/themes/components/segmented_control.pyi +37 -34
- reflex/components/radix/themes/components/select.py +7 -11
- reflex/components/radix/themes/components/select.pyi +175 -154
- reflex/components/radix/themes/components/separator.py +1 -4
- reflex/components/radix/themes/components/separator.pyi +17 -17
- reflex/components/radix/themes/components/skeleton.pyi +17 -17
- reflex/components/radix/themes/components/slider.py +12 -21
- reflex/components/radix/themes/components/slider.pyi +47 -25
- reflex/components/radix/themes/components/spinner.py +1 -4
- reflex/components/radix/themes/components/spinner.pyi +17 -17
- reflex/components/radix/themes/components/switch.py +3 -6
- reflex/components/radix/themes/components/switch.pyi +21 -18
- reflex/components/radix/themes/components/table.py +21 -5
- reflex/components/radix/themes/components/table.pyi +392 -116
- reflex/components/radix/themes/components/tabs.py +3 -6
- reflex/components/radix/themes/components/tabs.pyi +89 -83
- reflex/components/radix/themes/components/text_area.py +1 -5
- reflex/components/radix/themes/components/text_area.pyi +43 -20
- reflex/components/radix/themes/components/text_field.py +1 -5
- reflex/components/radix/themes/components/text_field.pyi +101 -55
- reflex/components/radix/themes/components/tooltip.py +5 -7
- reflex/components/radix/themes/components/tooltip.pyi +25 -22
- reflex/components/radix/themes/layout/base.py +2 -27
- reflex/components/radix/themes/layout/base.pyi +82 -82
- reflex/components/radix/themes/layout/box.pyi +17 -17
- reflex/components/radix/themes/layout/center.pyi +17 -17
- reflex/components/radix/themes/layout/container.pyi +17 -17
- reflex/components/radix/themes/layout/flex.py +1 -6
- reflex/components/radix/themes/layout/flex.pyi +17 -17
- reflex/components/radix/themes/layout/grid.py +1 -6
- reflex/components/radix/themes/layout/grid.pyi +17 -17
- reflex/components/radix/themes/layout/list.py +20 -15
- reflex/components/radix/themes/layout/list.pyi +175 -92
- reflex/components/radix/themes/layout/section.pyi +17 -17
- reflex/components/radix/themes/layout/spacer.pyi +17 -17
- reflex/components/radix/themes/layout/stack.py +6 -6
- reflex/components/radix/themes/layout/stack.pyi +91 -62
- reflex/components/radix/themes/typography/blockquote.py +2 -8
- reflex/components/radix/themes/typography/blockquote.pyi +17 -17
- reflex/components/radix/themes/typography/code.py +4 -10
- reflex/components/radix/themes/typography/code.pyi +19 -18
- reflex/components/radix/themes/typography/heading.py +4 -11
- reflex/components/radix/themes/typography/heading.pyi +19 -18
- reflex/components/radix/themes/typography/link.py +4 -10
- reflex/components/radix/themes/typography/link.pyi +19 -18
- reflex/components/radix/themes/typography/text.py +4 -11
- reflex/components/radix/themes/typography/text.pyi +115 -114
- reflex/components/react_player/audio.pyi +58 -33
- reflex/components/react_player/react_player.py +17 -17
- reflex/components/react_player/react_player.pyi +55 -33
- reflex/components/react_player/video.pyi +58 -33
- reflex/components/recharts/cartesian.py +45 -45
- reflex/components/recharts/cartesian.pyi +389 -304
- reflex/components/recharts/charts.py +22 -22
- reflex/components/recharts/charts.pyi +226 -179
- reflex/components/recharts/general.py +26 -27
- reflex/components/recharts/general.pyi +106 -99
- reflex/components/recharts/polar.py +33 -33
- reflex/components/recharts/polar.pyi +70 -64
- reflex/components/recharts/recharts.pyi +33 -33
- reflex/components/sonner/toast.py +9 -36
- reflex/components/sonner/toast.pyi +20 -24
- reflex/components/suneditor/editor.py +8 -8
- reflex/components/suneditor/editor.pyi +50 -25
- reflex/components/tags/iter_tag.py +1 -10
- reflex/components/tags/tag.py +1 -4
- reflex/config.py +252 -41
- reflex/constants/__init__.py +4 -16
- reflex/constants/base.py +7 -14
- reflex/constants/colors.py +0 -1
- reflex/constants/installer.py +12 -7
- reflex/constants/state.py +4 -0
- reflex/custom_components/custom_components.py +6 -6
- reflex/event.py +486 -241
- reflex/experimental/client_state.py +9 -9
- reflex/experimental/layout.py +2 -2
- reflex/experimental/layout.pyi +95 -87
- reflex/experimental/misc.py +1 -1
- reflex/istate/__init__.py +1 -0
- reflex/istate/proxy.py +33 -0
- reflex/istate/wrappers.py +27 -0
- reflex/model.py +7 -7
- reflex/page.py +2 -1
- reflex/reflex.py +142 -8
- reflex/state.py +133 -46
- reflex/testing.py +9 -7
- reflex/utils/console.py +0 -1
- reflex/utils/exceptions.py +31 -3
- reflex/utils/exec.py +33 -14
- reflex/utils/format.py +15 -12
- reflex/utils/net.py +1 -1
- reflex/utils/path_ops.py +2 -2
- reflex/utils/prerequisites.py +82 -46
- reflex/utils/pyi_generator.py +63 -20
- reflex/utils/registry.py +1 -1
- reflex/utils/serializers.py +75 -36
- reflex/utils/telemetry.py +3 -2
- reflex/utils/types.py +125 -10
- reflex/vars/base.py +131 -119
- reflex/vars/function.py +59 -12
- reflex/vars/number.py +3 -1
- reflex/vars/object.py +30 -24
- reflex/vars/sequence.py +7 -7
- {reflex-0.6.4a2.dist-info → reflex-0.6.5.dist-info}/METADATA +3 -3
- reflex-0.6.5.dist-info/RECORD +394 -0
- reflex-0.6.4a2.dist-info/RECORD +0 -391
- {reflex-0.6.4a2.dist-info → reflex-0.6.5.dist-info}/LICENSE +0 -0
- {reflex-0.6.4a2.dist-info → reflex-0.6.5.dist-info}/WHEEL +0 -0
- {reflex-0.6.4a2.dist-info → reflex-0.6.5.dist-info}/entry_points.txt +0 -0
|
@@ -8,12 +8,9 @@ import sys
|
|
|
8
8
|
from typing import Any, Callable, Union
|
|
9
9
|
|
|
10
10
|
from reflex import constants
|
|
11
|
-
from reflex.event import EventChain, EventHandler, EventSpec,
|
|
11
|
+
from reflex.event import EventChain, EventHandler, EventSpec, run_script
|
|
12
12
|
from reflex.utils.imports import ImportVar
|
|
13
|
-
from reflex.vars import
|
|
14
|
-
VarData,
|
|
15
|
-
get_unique_variable_name,
|
|
16
|
-
)
|
|
13
|
+
from reflex.vars import VarData, get_unique_variable_name
|
|
17
14
|
from reflex.vars.base import LiteralVar, Var
|
|
18
15
|
from reflex.vars.function import FunctionVar
|
|
19
16
|
|
|
@@ -178,9 +175,12 @@ class ClientStateVar(Var):
|
|
|
178
175
|
if self._global_ref
|
|
179
176
|
else self._setter_name
|
|
180
177
|
)
|
|
178
|
+
_var_data = VarData(imports=_refs_import if self._global_ref else {})
|
|
181
179
|
if value is not NoValue:
|
|
182
180
|
# This is a hack to make it work like an EventSpec taking an arg
|
|
183
|
-
|
|
181
|
+
value_var = LiteralVar.create(value)
|
|
182
|
+
_var_data = VarData.merge(_var_data, value_var._get_all_var_data())
|
|
183
|
+
value_str = str(value_var)
|
|
184
184
|
|
|
185
185
|
if value_str.startswith("_"):
|
|
186
186
|
# remove patterns of ["*"] from the value_str using regex
|
|
@@ -190,7 +190,7 @@ class ClientStateVar(Var):
|
|
|
190
190
|
setter = f"(() => {setter}({value_str}))"
|
|
191
191
|
return Var(
|
|
192
192
|
_js_expr=setter,
|
|
193
|
-
_var_data=
|
|
193
|
+
_var_data=_var_data,
|
|
194
194
|
).to(FunctionVar, EventChain)
|
|
195
195
|
|
|
196
196
|
@property
|
|
@@ -224,7 +224,7 @@ class ClientStateVar(Var):
|
|
|
224
224
|
"""
|
|
225
225
|
if not self._global_ref:
|
|
226
226
|
raise ValueError("ClientStateVar must be global to retrieve the value.")
|
|
227
|
-
return
|
|
227
|
+
return run_script(_client_state_ref(self._getter_name), callback=callback)
|
|
228
228
|
|
|
229
229
|
def push(self, value: Any) -> EventSpec:
|
|
230
230
|
"""Push a value to the client state variable from the backend.
|
|
@@ -242,4 +242,4 @@ class ClientStateVar(Var):
|
|
|
242
242
|
"""
|
|
243
243
|
if not self._global_ref:
|
|
244
244
|
raise ValueError("ClientStateVar must be global to push the value.")
|
|
245
|
-
return
|
|
245
|
+
return run_script(f"{_client_state_ref(self._setter_name)}({value})")
|
reflex/experimental/layout.py
CHANGED
|
@@ -12,7 +12,7 @@ from reflex.components.radix.themes.components.icon_button import IconButton
|
|
|
12
12
|
from reflex.components.radix.themes.layout.box import Box
|
|
13
13
|
from reflex.components.radix.themes.layout.container import Container
|
|
14
14
|
from reflex.components.radix.themes.layout.stack import HStack
|
|
15
|
-
from reflex.event import
|
|
15
|
+
from reflex.event import run_script
|
|
16
16
|
from reflex.experimental import hooks
|
|
17
17
|
from reflex.state import ComponentState
|
|
18
18
|
from reflex.style import Style
|
|
@@ -173,7 +173,7 @@ class SidebarTrigger(Fragment):
|
|
|
173
173
|
else:
|
|
174
174
|
open, toggle = (
|
|
175
175
|
Var(_js_expr="open"),
|
|
176
|
-
|
|
176
|
+
run_script("setOpen(!open)"),
|
|
177
177
|
)
|
|
178
178
|
|
|
179
179
|
trigger_props["left"] = cond(open, f"calc({sidebar_width} - 32px)", "0")
|
reflex/experimental/layout.pyi
CHANGED
|
@@ -10,7 +10,7 @@ from reflex.components.base.fragment import Fragment
|
|
|
10
10
|
from reflex.components.component import Component, ComponentNamespace, MemoizationLeaf
|
|
11
11
|
from reflex.components.radix.primitives.drawer import DrawerRoot
|
|
12
12
|
from reflex.components.radix.themes.layout.box import Box
|
|
13
|
-
from reflex.event import EventType
|
|
13
|
+
from reflex.event import BASE_STATE, EventType
|
|
14
14
|
from reflex.state import ComponentState
|
|
15
15
|
from reflex.style import Style
|
|
16
16
|
from reflex.vars.base import Var
|
|
@@ -50,22 +50,22 @@ class Sidebar(Box, MemoizationLeaf):
|
|
|
50
50
|
id: Optional[Any] = None,
|
|
51
51
|
class_name: Optional[Any] = None,
|
|
52
52
|
autofocus: Optional[bool] = None,
|
|
53
|
-
custom_attrs: Optional[Dict[str, Union[Var,
|
|
54
|
-
on_blur: Optional[EventType[[]]] = None,
|
|
55
|
-
on_click: Optional[EventType[[]]] = None,
|
|
56
|
-
on_context_menu: Optional[EventType[[]]] = None,
|
|
57
|
-
on_double_click: Optional[EventType[[]]] = None,
|
|
58
|
-
on_focus: Optional[EventType[[]]] = None,
|
|
59
|
-
on_mount: Optional[EventType[[]]] = None,
|
|
60
|
-
on_mouse_down: Optional[EventType[[]]] = None,
|
|
61
|
-
on_mouse_enter: Optional[EventType[[]]] = None,
|
|
62
|
-
on_mouse_leave: Optional[EventType[[]]] = None,
|
|
63
|
-
on_mouse_move: Optional[EventType[[]]] = None,
|
|
64
|
-
on_mouse_out: Optional[EventType[[]]] = None,
|
|
65
|
-
on_mouse_over: Optional[EventType[[]]] = None,
|
|
66
|
-
on_mouse_up: Optional[EventType[[]]] = None,
|
|
67
|
-
on_scroll: Optional[EventType[[]]] = None,
|
|
68
|
-
on_unmount: Optional[EventType[[]]] = None,
|
|
53
|
+
custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
|
|
54
|
+
on_blur: Optional[EventType[[], BASE_STATE]] = None,
|
|
55
|
+
on_click: Optional[EventType[[], BASE_STATE]] = None,
|
|
56
|
+
on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
|
|
57
|
+
on_double_click: Optional[EventType[[], BASE_STATE]] = None,
|
|
58
|
+
on_focus: Optional[EventType[[], BASE_STATE]] = None,
|
|
59
|
+
on_mount: Optional[EventType[[], BASE_STATE]] = None,
|
|
60
|
+
on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
|
|
61
|
+
on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
|
|
62
|
+
on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
|
|
63
|
+
on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
|
|
64
|
+
on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
|
|
65
|
+
on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
|
|
66
|
+
on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
|
|
67
|
+
on_scroll: Optional[EventType[[], BASE_STATE]] = None,
|
|
68
|
+
on_unmount: Optional[EventType[[], BASE_STATE]] = None,
|
|
69
69
|
**props,
|
|
70
70
|
) -> "Sidebar":
|
|
71
71
|
"""Create the sidebar component.
|
|
@@ -95,12 +95,8 @@ class DrawerSidebar(DrawerRoot):
|
|
|
95
95
|
def create( # type: ignore
|
|
96
96
|
cls,
|
|
97
97
|
*children,
|
|
98
|
+
default_open: Optional[Union[Var[bool], bool]] = None,
|
|
98
99
|
open: Optional[Union[Var[bool], bool]] = None,
|
|
99
|
-
should_scale_background: Optional[Union[Var[bool], bool]] = None,
|
|
100
|
-
close_threshold: Optional[Union[Var[float], float]] = None,
|
|
101
|
-
snap_points: Optional[List[Union[float, str]]] = None,
|
|
102
|
-
fade_from_index: Optional[Union[Var[int], int]] = None,
|
|
103
|
-
scroll_lock_timeout: Optional[Union[Var[int], int]] = None,
|
|
104
100
|
modal: Optional[Union[Var[bool], bool]] = None,
|
|
105
101
|
direction: Optional[
|
|
106
102
|
Union[
|
|
@@ -108,30 +104,42 @@ class DrawerSidebar(DrawerRoot):
|
|
|
108
104
|
Var[Literal["bottom", "left", "right", "top"]],
|
|
109
105
|
]
|
|
110
106
|
] = None,
|
|
107
|
+
dismissible: Optional[Union[Var[bool], bool]] = None,
|
|
108
|
+
handle_only: Optional[Union[Var[bool], bool]] = None,
|
|
109
|
+
snap_points: Optional[List[Union[float, str]]] = None,
|
|
110
|
+
fade_from_index: Optional[Union[Var[int], int]] = None,
|
|
111
|
+
scroll_lock_timeout: Optional[Union[Var[int], int]] = None,
|
|
111
112
|
preventScrollRestoration: Optional[Union[Var[bool], bool]] = None,
|
|
113
|
+
should_scale_background: Optional[Union[Var[bool], bool]] = None,
|
|
114
|
+
close_threshold: Optional[Union[Var[float], float]] = None,
|
|
112
115
|
as_child: Optional[Union[Var[bool], bool]] = None,
|
|
113
116
|
style: Optional[Style] = None,
|
|
114
117
|
key: Optional[Any] = None,
|
|
115
118
|
id: Optional[Any] = None,
|
|
116
119
|
class_name: Optional[Any] = None,
|
|
117
120
|
autofocus: Optional[bool] = None,
|
|
118
|
-
custom_attrs: Optional[Dict[str, Union[Var,
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
121
|
+
custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
|
|
122
|
+
on_animation_end: Optional[
|
|
123
|
+
Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]]
|
|
124
|
+
] = None,
|
|
125
|
+
on_blur: Optional[EventType[[], BASE_STATE]] = None,
|
|
126
|
+
on_click: Optional[EventType[[], BASE_STATE]] = None,
|
|
127
|
+
on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
|
|
128
|
+
on_double_click: Optional[EventType[[], BASE_STATE]] = None,
|
|
129
|
+
on_focus: Optional[EventType[[], BASE_STATE]] = None,
|
|
130
|
+
on_mount: Optional[EventType[[], BASE_STATE]] = None,
|
|
131
|
+
on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
|
|
132
|
+
on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
|
|
133
|
+
on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
|
|
134
|
+
on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
|
|
135
|
+
on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
|
|
136
|
+
on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
|
|
137
|
+
on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
|
|
138
|
+
on_open_change: Optional[
|
|
139
|
+
Union[EventType[[], BASE_STATE], EventType[[bool], BASE_STATE]]
|
|
140
|
+
] = None,
|
|
141
|
+
on_scroll: Optional[EventType[[], BASE_STATE]] = None,
|
|
142
|
+
on_unmount: Optional[EventType[[], BASE_STATE]] = None,
|
|
135
143
|
**props,
|
|
136
144
|
) -> "DrawerSidebar":
|
|
137
145
|
"""Create the sidebar component.
|
|
@@ -164,22 +172,22 @@ class SidebarTrigger(Fragment):
|
|
|
164
172
|
id: Optional[Any] = None,
|
|
165
173
|
class_name: Optional[Any] = None,
|
|
166
174
|
autofocus: Optional[bool] = None,
|
|
167
|
-
custom_attrs: Optional[Dict[str, Union[Var,
|
|
168
|
-
on_blur: Optional[EventType[[]]] = None,
|
|
169
|
-
on_click: Optional[EventType[[]]] = None,
|
|
170
|
-
on_context_menu: Optional[EventType[[]]] = None,
|
|
171
|
-
on_double_click: Optional[EventType[[]]] = None,
|
|
172
|
-
on_focus: Optional[EventType[[]]] = None,
|
|
173
|
-
on_mount: Optional[EventType[[]]] = None,
|
|
174
|
-
on_mouse_down: Optional[EventType[[]]] = None,
|
|
175
|
-
on_mouse_enter: Optional[EventType[[]]] = None,
|
|
176
|
-
on_mouse_leave: Optional[EventType[[]]] = None,
|
|
177
|
-
on_mouse_move: Optional[EventType[[]]] = None,
|
|
178
|
-
on_mouse_out: Optional[EventType[[]]] = None,
|
|
179
|
-
on_mouse_over: Optional[EventType[[]]] = None,
|
|
180
|
-
on_mouse_up: Optional[EventType[[]]] = None,
|
|
181
|
-
on_scroll: Optional[EventType[[]]] = None,
|
|
182
|
-
on_unmount: Optional[EventType[[]]] = None,
|
|
175
|
+
custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
|
|
176
|
+
on_blur: Optional[EventType[[], BASE_STATE]] = None,
|
|
177
|
+
on_click: Optional[EventType[[], BASE_STATE]] = None,
|
|
178
|
+
on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
|
|
179
|
+
on_double_click: Optional[EventType[[], BASE_STATE]] = None,
|
|
180
|
+
on_focus: Optional[EventType[[], BASE_STATE]] = None,
|
|
181
|
+
on_mount: Optional[EventType[[], BASE_STATE]] = None,
|
|
182
|
+
on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
|
|
183
|
+
on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
|
|
184
|
+
on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
|
|
185
|
+
on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
|
|
186
|
+
on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
|
|
187
|
+
on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
|
|
188
|
+
on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
|
|
189
|
+
on_scroll: Optional[EventType[[], BASE_STATE]] = None,
|
|
190
|
+
on_unmount: Optional[EventType[[], BASE_STATE]] = None,
|
|
183
191
|
**props,
|
|
184
192
|
) -> "SidebarTrigger":
|
|
185
193
|
"""Create the sidebar trigger component.
|
|
@@ -229,22 +237,22 @@ class Layout(Box):
|
|
|
229
237
|
id: Optional[Any] = None,
|
|
230
238
|
class_name: Optional[Any] = None,
|
|
231
239
|
autofocus: Optional[bool] = None,
|
|
232
|
-
custom_attrs: Optional[Dict[str, Union[Var,
|
|
233
|
-
on_blur: Optional[EventType[[]]] = None,
|
|
234
|
-
on_click: Optional[EventType[[]]] = None,
|
|
235
|
-
on_context_menu: Optional[EventType[[]]] = None,
|
|
236
|
-
on_double_click: Optional[EventType[[]]] = None,
|
|
237
|
-
on_focus: Optional[EventType[[]]] = None,
|
|
238
|
-
on_mount: Optional[EventType[[]]] = None,
|
|
239
|
-
on_mouse_down: Optional[EventType[[]]] = None,
|
|
240
|
-
on_mouse_enter: Optional[EventType[[]]] = None,
|
|
241
|
-
on_mouse_leave: Optional[EventType[[]]] = None,
|
|
242
|
-
on_mouse_move: Optional[EventType[[]]] = None,
|
|
243
|
-
on_mouse_out: Optional[EventType[[]]] = None,
|
|
244
|
-
on_mouse_over: Optional[EventType[[]]] = None,
|
|
245
|
-
on_mouse_up: Optional[EventType[[]]] = None,
|
|
246
|
-
on_scroll: Optional[EventType[[]]] = None,
|
|
247
|
-
on_unmount: Optional[EventType[[]]] = None,
|
|
240
|
+
custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
|
|
241
|
+
on_blur: Optional[EventType[[], BASE_STATE]] = None,
|
|
242
|
+
on_click: Optional[EventType[[], BASE_STATE]] = None,
|
|
243
|
+
on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
|
|
244
|
+
on_double_click: Optional[EventType[[], BASE_STATE]] = None,
|
|
245
|
+
on_focus: Optional[EventType[[], BASE_STATE]] = None,
|
|
246
|
+
on_mount: Optional[EventType[[], BASE_STATE]] = None,
|
|
247
|
+
on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
|
|
248
|
+
on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
|
|
249
|
+
on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
|
|
250
|
+
on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
|
|
251
|
+
on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
|
|
252
|
+
on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
|
|
253
|
+
on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
|
|
254
|
+
on_scroll: Optional[EventType[[], BASE_STATE]] = None,
|
|
255
|
+
on_unmount: Optional[EventType[[], BASE_STATE]] = None,
|
|
248
256
|
**props,
|
|
249
257
|
) -> "Layout":
|
|
250
258
|
"""Create the layout component.
|
|
@@ -297,22 +305,22 @@ class LayoutNamespace(ComponentNamespace):
|
|
|
297
305
|
id: Optional[Any] = None,
|
|
298
306
|
class_name: Optional[Any] = None,
|
|
299
307
|
autofocus: Optional[bool] = None,
|
|
300
|
-
custom_attrs: Optional[Dict[str, Union[Var,
|
|
301
|
-
on_blur: Optional[EventType[[]]] = None,
|
|
302
|
-
on_click: Optional[EventType[[]]] = None,
|
|
303
|
-
on_context_menu: Optional[EventType[[]]] = None,
|
|
304
|
-
on_double_click: Optional[EventType[[]]] = None,
|
|
305
|
-
on_focus: Optional[EventType[[]]] = None,
|
|
306
|
-
on_mount: Optional[EventType[[]]] = None,
|
|
307
|
-
on_mouse_down: Optional[EventType[[]]] = None,
|
|
308
|
-
on_mouse_enter: Optional[EventType[[]]] = None,
|
|
309
|
-
on_mouse_leave: Optional[EventType[[]]] = None,
|
|
310
|
-
on_mouse_move: Optional[EventType[[]]] = None,
|
|
311
|
-
on_mouse_out: Optional[EventType[[]]] = None,
|
|
312
|
-
on_mouse_over: Optional[EventType[[]]] = None,
|
|
313
|
-
on_mouse_up: Optional[EventType[[]]] = None,
|
|
314
|
-
on_scroll: Optional[EventType[[]]] = None,
|
|
315
|
-
on_unmount: Optional[EventType[[]]] = None,
|
|
308
|
+
custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
|
|
309
|
+
on_blur: Optional[EventType[[], BASE_STATE]] = None,
|
|
310
|
+
on_click: Optional[EventType[[], BASE_STATE]] = None,
|
|
311
|
+
on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
|
|
312
|
+
on_double_click: Optional[EventType[[], BASE_STATE]] = None,
|
|
313
|
+
on_focus: Optional[EventType[[], BASE_STATE]] = None,
|
|
314
|
+
on_mount: Optional[EventType[[], BASE_STATE]] = None,
|
|
315
|
+
on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
|
|
316
|
+
on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
|
|
317
|
+
on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
|
|
318
|
+
on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
|
|
319
|
+
on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
|
|
320
|
+
on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
|
|
321
|
+
on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
|
|
322
|
+
on_scroll: Optional[EventType[[], BASE_STATE]] = None,
|
|
323
|
+
on_unmount: Optional[EventType[[], BASE_STATE]] = None,
|
|
316
324
|
**props,
|
|
317
325
|
) -> "Layout":
|
|
318
326
|
"""Create the layout component.
|
reflex/experimental/misc.py
CHANGED
|
@@ -7,7 +7,7 @@ from typing import Any
|
|
|
7
7
|
async def run_in_thread(func) -> Any:
|
|
8
8
|
"""Run a function in a separate thread.
|
|
9
9
|
|
|
10
|
-
To not block the UI event queue, run_in_thread must be inside inside a rx.background
|
|
10
|
+
To not block the UI event queue, run_in_thread must be inside inside a rx.event(background=True) decorated method.
|
|
11
11
|
|
|
12
12
|
Args:
|
|
13
13
|
func (callable): The non-async function to run.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""This module will provide interfaces for the state."""
|
reflex/istate/proxy.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""A module to hold state proxy classes."""
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from reflex.state import StateProxy
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class ReadOnlyStateProxy(StateProxy):
|
|
9
|
+
"""A read-only proxy for a state."""
|
|
10
|
+
|
|
11
|
+
def __setattr__(self, name: str, value: Any) -> None:
|
|
12
|
+
"""Prevent setting attributes on the state for read-only proxy.
|
|
13
|
+
|
|
14
|
+
Args:
|
|
15
|
+
name: The attribute name.
|
|
16
|
+
value: The attribute value.
|
|
17
|
+
|
|
18
|
+
Raises:
|
|
19
|
+
NotImplementedError: Always raised when trying to set an attribute on proxied state.
|
|
20
|
+
"""
|
|
21
|
+
if name.startswith("_self_"):
|
|
22
|
+
# Special case attributes of the proxy itself, not applied to the wrapped object.
|
|
23
|
+
super().__setattr__(name, value)
|
|
24
|
+
return
|
|
25
|
+
raise NotImplementedError("This is a read-only state proxy.")
|
|
26
|
+
|
|
27
|
+
def mark_dirty(self):
|
|
28
|
+
"""Mark the state as dirty.
|
|
29
|
+
|
|
30
|
+
Raises:
|
|
31
|
+
NotImplementedError: Always raised when trying to mark the proxied state as dirty.
|
|
32
|
+
"""
|
|
33
|
+
raise NotImplementedError("This is a read-only state proxy.")
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""Wrappers for the state manager."""
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from reflex.istate.proxy import ReadOnlyStateProxy
|
|
6
|
+
from reflex.state import _split_substate_key, _substate_key, get_state_manager
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
async def get_state(token, state_cls: Any | None = None) -> ReadOnlyStateProxy:
|
|
10
|
+
"""Get the instance of a state for a token.
|
|
11
|
+
|
|
12
|
+
Args:
|
|
13
|
+
token: The token for the state.
|
|
14
|
+
state_cls: The class of the state.
|
|
15
|
+
|
|
16
|
+
Returns:
|
|
17
|
+
A read-only proxy of the state instance.
|
|
18
|
+
"""
|
|
19
|
+
mng = get_state_manager()
|
|
20
|
+
if state_cls is not None:
|
|
21
|
+
root_state = await mng.get_state(_substate_key(token, state_cls))
|
|
22
|
+
else:
|
|
23
|
+
root_state = await mng.get_state(token)
|
|
24
|
+
_, state_path = _split_substate_key(token)
|
|
25
|
+
state_cls = root_state.get_class_substate(tuple(state_path.split(".")))
|
|
26
|
+
instance = await root_state.get_state(state_cls)
|
|
27
|
+
return ReadOnlyStateProxy(instance)
|
reflex/model.py
CHANGED
|
@@ -38,12 +38,12 @@ def get_engine(url: str | None = None) -> sqlalchemy.engine.Engine:
|
|
|
38
38
|
url = url or conf.db_url
|
|
39
39
|
if url is None:
|
|
40
40
|
raise ValueError("No database url configured")
|
|
41
|
-
if not environment.ALEMBIC_CONFIG.exists():
|
|
41
|
+
if not environment.ALEMBIC_CONFIG.get().exists():
|
|
42
42
|
console.warn(
|
|
43
43
|
"Database is not initialized, run [bold]reflex db init[/bold] first."
|
|
44
44
|
)
|
|
45
45
|
# Print the SQL queries if the log level is INFO or lower.
|
|
46
|
-
echo_db_query = environment.SQLALCHEMY_ECHO
|
|
46
|
+
echo_db_query = environment.SQLALCHEMY_ECHO.get()
|
|
47
47
|
# Needed for the admin dash on sqlite.
|
|
48
48
|
connect_args = {"check_same_thread": False} if url.startswith("sqlite") else {}
|
|
49
49
|
return sqlmodel.create_engine(url, echo=echo_db_query, connect_args=connect_args)
|
|
@@ -231,7 +231,7 @@ class Model(Base, sqlmodel.SQLModel): # pyright: ignore [reportGeneralTypeIssue
|
|
|
231
231
|
Returns:
|
|
232
232
|
tuple of (config, script_directory)
|
|
233
233
|
"""
|
|
234
|
-
config = alembic.config.Config(environment.ALEMBIC_CONFIG)
|
|
234
|
+
config = alembic.config.Config(environment.ALEMBIC_CONFIG.get())
|
|
235
235
|
return config, alembic.script.ScriptDirectory(
|
|
236
236
|
config.get_main_option("script_location", default="version"),
|
|
237
237
|
)
|
|
@@ -266,8 +266,8 @@ class Model(Base, sqlmodel.SQLModel): # pyright: ignore [reportGeneralTypeIssue
|
|
|
266
266
|
def alembic_init(cls):
|
|
267
267
|
"""Initialize alembic for the project."""
|
|
268
268
|
alembic.command.init(
|
|
269
|
-
config=alembic.config.Config(environment.ALEMBIC_CONFIG),
|
|
270
|
-
directory=str(environment.ALEMBIC_CONFIG.parent / "alembic"),
|
|
269
|
+
config=alembic.config.Config(environment.ALEMBIC_CONFIG.get()),
|
|
270
|
+
directory=str(environment.ALEMBIC_CONFIG.get().parent / "alembic"),
|
|
271
271
|
)
|
|
272
272
|
|
|
273
273
|
@classmethod
|
|
@@ -287,7 +287,7 @@ class Model(Base, sqlmodel.SQLModel): # pyright: ignore [reportGeneralTypeIssue
|
|
|
287
287
|
Returns:
|
|
288
288
|
True when changes have been detected.
|
|
289
289
|
"""
|
|
290
|
-
if not environment.ALEMBIC_CONFIG.exists():
|
|
290
|
+
if not environment.ALEMBIC_CONFIG.get().exists():
|
|
291
291
|
return False
|
|
292
292
|
|
|
293
293
|
config, script_directory = cls._alembic_config()
|
|
@@ -388,7 +388,7 @@ class Model(Base, sqlmodel.SQLModel): # pyright: ignore [reportGeneralTypeIssue
|
|
|
388
388
|
True - indicating the process was successful.
|
|
389
389
|
None - indicating the process was skipped.
|
|
390
390
|
"""
|
|
391
|
-
if not environment.ALEMBIC_CONFIG.exists():
|
|
391
|
+
if not environment.ALEMBIC_CONFIG.get().exists():
|
|
392
392
|
return
|
|
393
393
|
|
|
394
394
|
with cls.get_db_engine().connect() as connection:
|
reflex/page.py
CHANGED
|
@@ -6,6 +6,7 @@ from collections import defaultdict
|
|
|
6
6
|
from typing import Any, Dict, List
|
|
7
7
|
|
|
8
8
|
from reflex.config import get_config
|
|
9
|
+
from reflex.event import BASE_STATE, EventType
|
|
9
10
|
|
|
10
11
|
DECORATED_PAGES: Dict[str, List] = defaultdict(list)
|
|
11
12
|
|
|
@@ -17,7 +18,7 @@ def page(
|
|
|
17
18
|
description: str | None = None,
|
|
18
19
|
meta: list[Any] | None = None,
|
|
19
20
|
script_tags: list[Any] | None = None,
|
|
20
|
-
on_load:
|
|
21
|
+
on_load: EventType[[], BASE_STATE] | None = None,
|
|
21
22
|
):
|
|
22
23
|
"""Decorate a function as a page.
|
|
23
24
|
|