reflex 0.7.7a2__py3-none-any.whl → 0.7.8__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/web/utils/state.js +26 -16
- reflex/admin.py +1 -1
- reflex/app.py +6 -17
- reflex/app_mixins/lifespan.py +1 -1
- reflex/base.py +2 -2
- reflex/compiler/compiler.py +8 -7
- reflex/compiler/utils.py +6 -5
- reflex/components/base/app_wrap.pyi +18 -17
- reflex/components/base/bare.py +2 -1
- reflex/components/base/body.pyi +18 -17
- reflex/components/base/document.pyi +82 -81
- reflex/components/base/error_boundary.pyi +19 -18
- reflex/components/base/fragment.pyi +18 -17
- reflex/components/base/head.pyi +34 -33
- reflex/components/base/link.pyi +34 -33
- reflex/components/base/meta.pyi +66 -65
- reflex/components/base/script.pyi +21 -20
- reflex/components/base/strict_mode.pyi +18 -17
- reflex/components/component.py +20 -36
- reflex/components/core/auto_scroll.pyi +18 -17
- reflex/components/core/banner.pyi +98 -97
- reflex/components/core/breakpoints.py +1 -1
- reflex/components/core/client_side_routing.pyi +34 -33
- reflex/components/core/clipboard.py +1 -1
- reflex/components/core/clipboard.pyi +19 -18
- reflex/components/core/cond.py +2 -2
- reflex/components/core/debounce.py +3 -3
- reflex/components/core/debounce.pyi +20 -19
- reflex/components/core/foreach.py +2 -1
- reflex/components/core/html.pyi +18 -17
- reflex/components/core/match.py +2 -2
- reflex/components/core/sticky.pyi +66 -65
- reflex/components/core/upload.py +7 -10
- reflex/components/core/upload.pyi +86 -85
- reflex/components/datadisplay/code.pyi +34 -33
- reflex/components/datadisplay/dataeditor.py +3 -2
- reflex/components/datadisplay/dataeditor.pyi +35 -68
- reflex/components/datadisplay/shiki_code_block.pyi +50 -49
- reflex/components/el/element.pyi +18 -17
- reflex/components/el/elements/base.pyi +18 -17
- reflex/components/el/elements/forms.py +2 -1
- reflex/components/el/elements/forms.pyi +290 -332
- reflex/components/el/elements/inline.pyi +450 -449
- reflex/components/el/elements/media.pyi +402 -401
- reflex/components/el/elements/metadata.pyi +98 -97
- reflex/components/el/elements/other.pyi +114 -113
- reflex/components/el/elements/scripts.pyi +50 -49
- reflex/components/el/elements/sectioning.pyi +242 -241
- reflex/components/el/elements/tables.pyi +162 -161
- reflex/components/el/elements/typography.pyi +242 -241
- reflex/components/gridjs/datatable.py +3 -2
- reflex/components/gridjs/datatable.pyi +35 -34
- reflex/components/lucide/icon.pyi +50 -49
- reflex/components/markdown/markdown.py +2 -1
- reflex/components/markdown/markdown.pyi +18 -17
- reflex/components/moment/moment.pyi +19 -18
- reflex/components/next/base.pyi +18 -17
- reflex/components/next/image.pyi +20 -19
- reflex/components/next/link.pyi +18 -17
- reflex/components/next/video.pyi +18 -17
- reflex/components/plotly/plotly.py +3 -3
- reflex/components/plotly/plotly.pyi +326 -325
- reflex/components/radix/primitives/accordion.py +2 -1
- reflex/components/radix/primitives/accordion.pyi +115 -114
- reflex/components/radix/primitives/base.pyi +34 -33
- reflex/components/radix/primitives/drawer.py +2 -1
- reflex/components/radix/primitives/drawer.pyi +187 -186
- reflex/components/radix/primitives/form.pyi +168 -182
- reflex/components/radix/primitives/progress.pyi +82 -81
- reflex/components/radix/primitives/slider.py +2 -1
- reflex/components/radix/primitives/slider.pyi +84 -83
- reflex/components/radix/themes/base.pyi +130 -129
- reflex/components/radix/themes/color_mode.pyi +51 -50
- reflex/components/radix/themes/components/alert_dialog.pyi +118 -117
- reflex/components/radix/themes/components/aspect_ratio.pyi +18 -17
- reflex/components/radix/themes/components/avatar.pyi +18 -17
- reflex/components/radix/themes/components/badge.pyi +18 -17
- reflex/components/radix/themes/components/button.pyi +18 -17
- reflex/components/radix/themes/components/callout.pyi +82 -81
- reflex/components/radix/themes/components/card.pyi +18 -17
- reflex/components/radix/themes/components/checkbox.pyi +53 -52
- reflex/components/radix/themes/components/checkbox_cards.pyi +34 -33
- reflex/components/radix/themes/components/checkbox_group.py +2 -1
- reflex/components/radix/themes/components/checkbox_group.pyi +34 -33
- reflex/components/radix/themes/components/context_menu.pyi +225 -224
- reflex/components/radix/themes/components/data_list.pyi +66 -65
- reflex/components/radix/themes/components/dialog.pyi +121 -120
- reflex/components/radix/themes/components/dropdown_menu.pyi +142 -141
- reflex/components/radix/themes/components/hover_card.pyi +68 -67
- reflex/components/radix/themes/components/icon_button.pyi +18 -17
- reflex/components/radix/themes/components/inset.pyi +18 -17
- reflex/components/radix/themes/components/popover.pyi +73 -72
- reflex/components/radix/themes/components/progress.pyi +18 -17
- reflex/components/radix/themes/components/radio.pyi +18 -17
- reflex/components/radix/themes/components/radio_cards.pyi +35 -34
- reflex/components/radix/themes/components/radio_group.py +2 -1
- reflex/components/radix/themes/components/radio_group.pyi +67 -66
- reflex/components/radix/themes/components/scroll_area.pyi +18 -17
- reflex/components/radix/themes/components/segmented_control.py +2 -1
- reflex/components/radix/themes/components/segmented_control.pyi +35 -34
- reflex/components/radix/themes/components/select.py +2 -1
- reflex/components/radix/themes/components/select.pyi +155 -154
- reflex/components/radix/themes/components/separator.pyi +18 -17
- reflex/components/radix/themes/components/skeleton.pyi +18 -17
- reflex/components/radix/themes/components/slider.py +2 -1
- reflex/components/radix/themes/components/slider.pyi +20 -31
- reflex/components/radix/themes/components/spinner.pyi +18 -17
- reflex/components/radix/themes/components/switch.pyi +19 -18
- reflex/components/radix/themes/components/table.pyi +114 -113
- reflex/components/radix/themes/components/tabs.pyi +84 -83
- reflex/components/radix/themes/components/text_area.pyi +21 -24
- reflex/components/radix/themes/components/text_field.pyi +56 -63
- reflex/components/radix/themes/components/tooltip.py +2 -2
- reflex/components/radix/themes/components/tooltip.pyi +21 -20
- reflex/components/radix/themes/layout/base.pyi +18 -17
- reflex/components/radix/themes/layout/box.pyi +18 -17
- reflex/components/radix/themes/layout/center.pyi +18 -17
- reflex/components/radix/themes/layout/container.pyi +18 -17
- reflex/components/radix/themes/layout/flex.pyi +18 -17
- reflex/components/radix/themes/layout/grid.pyi +18 -17
- reflex/components/radix/themes/layout/list.py +2 -1
- reflex/components/radix/themes/layout/list.pyi +82 -81
- reflex/components/radix/themes/layout/section.pyi +18 -17
- reflex/components/radix/themes/layout/spacer.pyi +18 -17
- reflex/components/radix/themes/layout/stack.pyi +50 -49
- reflex/components/radix/themes/typography/blockquote.pyi +18 -17
- reflex/components/radix/themes/typography/code.pyi +18 -17
- reflex/components/radix/themes/typography/heading.pyi +18 -17
- reflex/components/radix/themes/typography/link.pyi +18 -17
- reflex/components/radix/themes/typography/text.pyi +114 -113
- reflex/components/react_player/audio.pyi +34 -36
- reflex/components/react_player/react_player.pyi +34 -33
- reflex/components/react_player/video.pyi +34 -36
- reflex/components/recharts/cartesian.py +7 -6
- reflex/components/recharts/cartesian.pyi +302 -301
- reflex/components/recharts/charts.py +2 -1
- reflex/components/recharts/charts.pyi +177 -176
- reflex/components/recharts/general.py +3 -2
- reflex/components/recharts/general.pyi +99 -98
- reflex/components/recharts/polar.py +9 -8
- reflex/components/recharts/polar.pyi +62 -61
- reflex/components/recharts/recharts.pyi +34 -33
- reflex/components/sonner/toast.pyi +19 -18
- reflex/components/suneditor/editor.py +22 -24
- reflex/components/suneditor/editor.pyi +27 -28
- reflex/components/tags/cond_tag.py +3 -3
- reflex/components/tags/iter_tag.py +2 -1
- reflex/components/tags/tag.py +3 -2
- reflex/config.py +27 -17
- reflex/constants/installer.py +4 -4
- reflex/constants/route.py +2 -3
- reflex/constants/utils.py +4 -3
- reflex/event.py +56 -28
- reflex/experimental/client_state.py +3 -2
- reflex/experimental/layout.pyi +84 -83
- reflex/istate/data.py +1 -1
- reflex/istate/storage.py +2 -2
- reflex/model.py +3 -3
- reflex/page.py +3 -2
- reflex/state.py +56 -57
- reflex/style.py +3 -2
- reflex/testing.py +12 -21
- reflex/utils/codespaces.py +14 -15
- reflex/utils/decorator.py +2 -1
- reflex/utils/exec.py +1 -1
- reflex/utils/format.py +2 -2
- reflex/utils/imports.py +6 -8
- reflex/utils/misc.py +2 -1
- reflex/utils/net.py +2 -1
- reflex/utils/prerequisites.py +12 -5
- reflex/utils/processes.py +6 -5
- reflex/utils/pyi_generator.py +6 -5
- reflex/utils/serializers.py +13 -25
- reflex/utils/types.py +34 -46
- reflex/vars/base.py +60 -56
- reflex/vars/dep_tracking.py +4 -4
- reflex/vars/function.py +13 -36
- reflex/vars/number.py +5 -17
- reflex/vars/object.py +9 -16
- reflex/vars/sequence.py +11 -23
- {reflex-0.7.7a2.dist-info → reflex-0.7.8.dist-info}/METADATA +1 -1
- {reflex-0.7.7a2.dist-info → reflex-0.7.8.dist-info}/RECORD +185 -185
- {reflex-0.7.7a2.dist-info → reflex-0.7.8.dist-info}/WHEEL +0 -0
- {reflex-0.7.7a2.dist-info → reflex-0.7.8.dist-info}/entry_points.txt +0 -0
- {reflex-0.7.7a2.dist-info → reflex-0.7.8.dist-info}/licenses/LICENSE +0 -0
reflex/experimental/layout.pyi
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
# ------------------- DO NOT EDIT ----------------------
|
|
4
4
|
# This file was generated by `reflex/utils/pyi_generator.py`!
|
|
5
5
|
# ------------------------------------------------------
|
|
6
|
-
from
|
|
6
|
+
from collections.abc import Mapping, Sequence
|
|
7
|
+
from typing import Any, Literal, overload
|
|
7
8
|
|
|
8
9
|
from reflex import color
|
|
9
10
|
from reflex.components.base.fragment import Fragment
|
|
@@ -209,23 +210,23 @@ class Sidebar(Box, MemoizationLeaf):
|
|
|
209
210
|
class_name: Any | None = None,
|
|
210
211
|
autofocus: bool | None = None,
|
|
211
212
|
custom_attrs: dict[str, Var | Any] | None = None,
|
|
212
|
-
on_blur:
|
|
213
|
-
on_click:
|
|
214
|
-
on_context_menu:
|
|
215
|
-
on_double_click:
|
|
216
|
-
on_focus:
|
|
217
|
-
on_mount:
|
|
218
|
-
on_mouse_down:
|
|
219
|
-
on_mouse_enter:
|
|
220
|
-
on_mouse_leave:
|
|
221
|
-
on_mouse_move:
|
|
222
|
-
on_mouse_out:
|
|
223
|
-
on_mouse_over:
|
|
224
|
-
on_mouse_up:
|
|
225
|
-
on_scroll:
|
|
226
|
-
on_unmount:
|
|
213
|
+
on_blur: EventType[()] | None = None,
|
|
214
|
+
on_click: EventType[()] | None = None,
|
|
215
|
+
on_context_menu: EventType[()] | None = None,
|
|
216
|
+
on_double_click: EventType[()] | None = None,
|
|
217
|
+
on_focus: EventType[()] | None = None,
|
|
218
|
+
on_mount: EventType[()] | None = None,
|
|
219
|
+
on_mouse_down: EventType[()] | None = None,
|
|
220
|
+
on_mouse_enter: EventType[()] | None = None,
|
|
221
|
+
on_mouse_leave: EventType[()] | None = None,
|
|
222
|
+
on_mouse_move: EventType[()] | None = None,
|
|
223
|
+
on_mouse_out: EventType[()] | None = None,
|
|
224
|
+
on_mouse_over: EventType[()] | None = None,
|
|
225
|
+
on_mouse_up: EventType[()] | None = None,
|
|
226
|
+
on_scroll: EventType[()] | None = None,
|
|
227
|
+
on_unmount: EventType[()] | None = None,
|
|
227
228
|
**props,
|
|
228
|
-
) ->
|
|
229
|
+
) -> Sidebar:
|
|
229
230
|
"""Create the sidebar component.
|
|
230
231
|
|
|
231
232
|
Args:
|
|
@@ -278,25 +279,25 @@ class DrawerSidebar(DrawerRoot):
|
|
|
278
279
|
class_name: Any | None = None,
|
|
279
280
|
autofocus: bool | None = None,
|
|
280
281
|
custom_attrs: dict[str, Var | Any] | None = None,
|
|
281
|
-
on_animation_end:
|
|
282
|
-
on_blur:
|
|
283
|
-
on_click:
|
|
284
|
-
on_context_menu:
|
|
285
|
-
on_double_click:
|
|
286
|
-
on_focus:
|
|
287
|
-
on_mount:
|
|
288
|
-
on_mouse_down:
|
|
289
|
-
on_mouse_enter:
|
|
290
|
-
on_mouse_leave:
|
|
291
|
-
on_mouse_move:
|
|
292
|
-
on_mouse_out:
|
|
293
|
-
on_mouse_over:
|
|
294
|
-
on_mouse_up:
|
|
295
|
-
on_open_change:
|
|
296
|
-
on_scroll:
|
|
297
|
-
on_unmount:
|
|
282
|
+
on_animation_end: EventType[()] | EventType[bool] | None = None,
|
|
283
|
+
on_blur: EventType[()] | None = None,
|
|
284
|
+
on_click: EventType[()] | None = None,
|
|
285
|
+
on_context_menu: EventType[()] | None = None,
|
|
286
|
+
on_double_click: EventType[()] | None = None,
|
|
287
|
+
on_focus: EventType[()] | None = None,
|
|
288
|
+
on_mount: EventType[()] | None = None,
|
|
289
|
+
on_mouse_down: EventType[()] | None = None,
|
|
290
|
+
on_mouse_enter: EventType[()] | None = None,
|
|
291
|
+
on_mouse_leave: EventType[()] | None = None,
|
|
292
|
+
on_mouse_move: EventType[()] | None = None,
|
|
293
|
+
on_mouse_out: EventType[()] | None = None,
|
|
294
|
+
on_mouse_over: EventType[()] | None = None,
|
|
295
|
+
on_mouse_up: EventType[()] | None = None,
|
|
296
|
+
on_open_change: EventType[()] | EventType[bool] | None = None,
|
|
297
|
+
on_scroll: EventType[()] | None = None,
|
|
298
|
+
on_unmount: EventType[()] | None = None,
|
|
298
299
|
**props,
|
|
299
|
-
) ->
|
|
300
|
+
) -> DrawerSidebar:
|
|
300
301
|
"""Create the sidebar component.
|
|
301
302
|
|
|
302
303
|
Args:
|
|
@@ -332,23 +333,23 @@ class SidebarTrigger(Fragment):
|
|
|
332
333
|
class_name: Any | None = None,
|
|
333
334
|
autofocus: bool | None = None,
|
|
334
335
|
custom_attrs: dict[str, Var | Any] | None = None,
|
|
335
|
-
on_blur:
|
|
336
|
-
on_click:
|
|
337
|
-
on_context_menu:
|
|
338
|
-
on_double_click:
|
|
339
|
-
on_focus:
|
|
340
|
-
on_mount:
|
|
341
|
-
on_mouse_down:
|
|
342
|
-
on_mouse_enter:
|
|
343
|
-
on_mouse_leave:
|
|
344
|
-
on_mouse_move:
|
|
345
|
-
on_mouse_out:
|
|
346
|
-
on_mouse_over:
|
|
347
|
-
on_mouse_up:
|
|
348
|
-
on_scroll:
|
|
349
|
-
on_unmount:
|
|
336
|
+
on_blur: EventType[()] | None = None,
|
|
337
|
+
on_click: EventType[()] | None = None,
|
|
338
|
+
on_context_menu: EventType[()] | None = None,
|
|
339
|
+
on_double_click: EventType[()] | None = None,
|
|
340
|
+
on_focus: EventType[()] | None = None,
|
|
341
|
+
on_mount: EventType[()] | None = None,
|
|
342
|
+
on_mouse_down: EventType[()] | None = None,
|
|
343
|
+
on_mouse_enter: EventType[()] | None = None,
|
|
344
|
+
on_mouse_leave: EventType[()] | None = None,
|
|
345
|
+
on_mouse_move: EventType[()] | None = None,
|
|
346
|
+
on_mouse_out: EventType[()] | None = None,
|
|
347
|
+
on_mouse_over: EventType[()] | None = None,
|
|
348
|
+
on_mouse_up: EventType[()] | None = None,
|
|
349
|
+
on_scroll: EventType[()] | None = None,
|
|
350
|
+
on_unmount: EventType[()] | None = None,
|
|
350
351
|
**props,
|
|
351
|
-
) ->
|
|
352
|
+
) -> SidebarTrigger:
|
|
352
353
|
"""Create the sidebar trigger component.
|
|
353
354
|
|
|
354
355
|
Args:
|
|
@@ -555,23 +556,23 @@ class Layout(Box):
|
|
|
555
556
|
class_name: Any | None = None,
|
|
556
557
|
autofocus: bool | None = None,
|
|
557
558
|
custom_attrs: dict[str, Var | Any] | None = None,
|
|
558
|
-
on_blur:
|
|
559
|
-
on_click:
|
|
560
|
-
on_context_menu:
|
|
561
|
-
on_double_click:
|
|
562
|
-
on_focus:
|
|
563
|
-
on_mount:
|
|
564
|
-
on_mouse_down:
|
|
565
|
-
on_mouse_enter:
|
|
566
|
-
on_mouse_leave:
|
|
567
|
-
on_mouse_move:
|
|
568
|
-
on_mouse_out:
|
|
569
|
-
on_mouse_over:
|
|
570
|
-
on_mouse_up:
|
|
571
|
-
on_scroll:
|
|
572
|
-
on_unmount:
|
|
559
|
+
on_blur: EventType[()] | None = None,
|
|
560
|
+
on_click: EventType[()] | None = None,
|
|
561
|
+
on_context_menu: EventType[()] | None = None,
|
|
562
|
+
on_double_click: EventType[()] | None = None,
|
|
563
|
+
on_focus: EventType[()] | None = None,
|
|
564
|
+
on_mount: EventType[()] | None = None,
|
|
565
|
+
on_mouse_down: EventType[()] | None = None,
|
|
566
|
+
on_mouse_enter: EventType[()] | None = None,
|
|
567
|
+
on_mouse_leave: EventType[()] | None = None,
|
|
568
|
+
on_mouse_move: EventType[()] | None = None,
|
|
569
|
+
on_mouse_out: EventType[()] | None = None,
|
|
570
|
+
on_mouse_over: EventType[()] | None = None,
|
|
571
|
+
on_mouse_up: EventType[()] | None = None,
|
|
572
|
+
on_scroll: EventType[()] | None = None,
|
|
573
|
+
on_unmount: EventType[()] | None = None,
|
|
573
574
|
**props,
|
|
574
|
-
) ->
|
|
575
|
+
) -> Layout:
|
|
575
576
|
"""Create the layout component.
|
|
576
577
|
|
|
577
578
|
Args:
|
|
@@ -781,23 +782,23 @@ class LayoutNamespace(ComponentNamespace):
|
|
|
781
782
|
class_name: Any | None = None,
|
|
782
783
|
autofocus: bool | None = None,
|
|
783
784
|
custom_attrs: dict[str, Var | Any] | None = None,
|
|
784
|
-
on_blur:
|
|
785
|
-
on_click:
|
|
786
|
-
on_context_menu:
|
|
787
|
-
on_double_click:
|
|
788
|
-
on_focus:
|
|
789
|
-
on_mount:
|
|
790
|
-
on_mouse_down:
|
|
791
|
-
on_mouse_enter:
|
|
792
|
-
on_mouse_leave:
|
|
793
|
-
on_mouse_move:
|
|
794
|
-
on_mouse_out:
|
|
795
|
-
on_mouse_over:
|
|
796
|
-
on_mouse_up:
|
|
797
|
-
on_scroll:
|
|
798
|
-
on_unmount:
|
|
785
|
+
on_blur: EventType[()] | None = None,
|
|
786
|
+
on_click: EventType[()] | None = None,
|
|
787
|
+
on_context_menu: EventType[()] | None = None,
|
|
788
|
+
on_double_click: EventType[()] | None = None,
|
|
789
|
+
on_focus: EventType[()] | None = None,
|
|
790
|
+
on_mount: EventType[()] | None = None,
|
|
791
|
+
on_mouse_down: EventType[()] | None = None,
|
|
792
|
+
on_mouse_enter: EventType[()] | None = None,
|
|
793
|
+
on_mouse_leave: EventType[()] | None = None,
|
|
794
|
+
on_mouse_move: EventType[()] | None = None,
|
|
795
|
+
on_mouse_out: EventType[()] | None = None,
|
|
796
|
+
on_mouse_over: EventType[()] | None = None,
|
|
797
|
+
on_mouse_up: EventType[()] | None = None,
|
|
798
|
+
on_scroll: EventType[()] | None = None,
|
|
799
|
+
on_unmount: EventType[()] | None = None,
|
|
799
800
|
**props,
|
|
800
|
-
) ->
|
|
801
|
+
) -> Layout:
|
|
801
802
|
"""Create the layout component.
|
|
802
803
|
|
|
803
804
|
Args:
|
reflex/istate/data.py
CHANGED
reflex/istate/storage.py
CHANGED
|
@@ -90,7 +90,7 @@ class LocalStorage(ClientStorageBase, str):
|
|
|
90
90
|
/,
|
|
91
91
|
name: str | None = None,
|
|
92
92
|
sync: bool = False,
|
|
93
|
-
) ->
|
|
93
|
+
) -> LocalStorage:
|
|
94
94
|
"""Create a client-side localStorage (str).
|
|
95
95
|
|
|
96
96
|
Args:
|
|
@@ -124,7 +124,7 @@ class SessionStorage(ClientStorageBase, str):
|
|
|
124
124
|
errors: str | None = None,
|
|
125
125
|
/,
|
|
126
126
|
name: str | None = None,
|
|
127
|
-
) ->
|
|
127
|
+
) -> SessionStorage:
|
|
128
128
|
"""Create a client-side sessionStorage (str).
|
|
129
129
|
|
|
130
130
|
Args:
|
reflex/model.py
CHANGED
|
@@ -5,7 +5,7 @@ from __future__ import annotations
|
|
|
5
5
|
import re
|
|
6
6
|
from collections import defaultdict
|
|
7
7
|
from contextlib import suppress
|
|
8
|
-
from typing import Any, ClassVar
|
|
8
|
+
from typing import Any, ClassVar
|
|
9
9
|
|
|
10
10
|
import alembic.autogenerate
|
|
11
11
|
import alembic.command
|
|
@@ -161,7 +161,7 @@ async def get_db_status() -> dict[str, bool]:
|
|
|
161
161
|
return {"db": status}
|
|
162
162
|
|
|
163
163
|
|
|
164
|
-
SQLModelOrSqlAlchemy =
|
|
164
|
+
SQLModelOrSqlAlchemy = type[sqlmodel.SQLModel] | type[sqlalchemy.orm.DeclarativeBase]
|
|
165
165
|
|
|
166
166
|
|
|
167
167
|
class ModelRegistry:
|
|
@@ -328,7 +328,7 @@ class Model(Base, sqlmodel.SQLModel): # pyright: ignore [reportGeneralTypeIssue
|
|
|
328
328
|
def _alembic_render_item(
|
|
329
329
|
type_: str,
|
|
330
330
|
obj: Any,
|
|
331
|
-
autogen_context:
|
|
331
|
+
autogen_context: alembic.autogenerate.api.AutogenContext,
|
|
332
332
|
):
|
|
333
333
|
"""Alembic render_item hook call.
|
|
334
334
|
|
reflex/page.py
CHANGED
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
from collections import defaultdict
|
|
6
|
-
from
|
|
6
|
+
from collections.abc import Callable
|
|
7
|
+
from typing import Any
|
|
7
8
|
|
|
8
9
|
from reflex.config import get_config
|
|
9
10
|
from reflex.event import EventType
|
|
10
11
|
|
|
11
|
-
DECORATED_PAGES: dict[str,
|
|
12
|
+
DECORATED_PAGES: dict[str, list] = defaultdict(list)
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
def page(
|
reflex/state.py
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import asyncio
|
|
6
|
+
import builtins
|
|
6
7
|
import contextlib
|
|
7
8
|
import copy
|
|
8
9
|
import dataclasses
|
|
@@ -16,23 +17,16 @@ import typing
|
|
|
16
17
|
import uuid
|
|
17
18
|
import warnings
|
|
18
19
|
from abc import ABC, abstractmethod
|
|
20
|
+
from collections.abc import AsyncIterator, Callable, Sequence
|
|
19
21
|
from hashlib import md5
|
|
20
22
|
from pathlib import Path
|
|
21
23
|
from types import FunctionType, MethodType
|
|
22
24
|
from typing import (
|
|
23
25
|
TYPE_CHECKING,
|
|
24
26
|
Any,
|
|
25
|
-
AsyncIterator,
|
|
26
27
|
BinaryIO,
|
|
27
|
-
Callable,
|
|
28
28
|
ClassVar,
|
|
29
|
-
Dict,
|
|
30
|
-
Optional,
|
|
31
|
-
Sequence,
|
|
32
|
-
Set,
|
|
33
29
|
SupportsIndex,
|
|
34
|
-
Tuple,
|
|
35
|
-
Type,
|
|
36
30
|
TypeVar,
|
|
37
31
|
cast,
|
|
38
32
|
get_args,
|
|
@@ -134,7 +128,7 @@ VAR_TYPE = TypeVar("VAR_TYPE")
|
|
|
134
128
|
|
|
135
129
|
|
|
136
130
|
def _no_chain_background_task(
|
|
137
|
-
state_cls:
|
|
131
|
+
state_cls: type[BaseState], name: str, fn: Callable
|
|
138
132
|
) -> Callable:
|
|
139
133
|
"""Protect against directly chaining a background task from another event handler.
|
|
140
134
|
|
|
@@ -173,7 +167,7 @@ def _no_chain_background_task(
|
|
|
173
167
|
|
|
174
168
|
def _substate_key(
|
|
175
169
|
token: str,
|
|
176
|
-
state_cls_or_name: BaseState |
|
|
170
|
+
state_cls_or_name: BaseState | type[BaseState] | str | Sequence[str],
|
|
177
171
|
) -> str:
|
|
178
172
|
"""Get the substate key.
|
|
179
173
|
|
|
@@ -210,9 +204,9 @@ def _split_substate_key(substate_key: str) -> tuple[str, str]:
|
|
|
210
204
|
class EventHandlerSetVar(EventHandler):
|
|
211
205
|
"""A special event handler to wrap setvar functionality."""
|
|
212
206
|
|
|
213
|
-
state_cls:
|
|
207
|
+
state_cls: type[BaseState] = dataclasses.field(init=False)
|
|
214
208
|
|
|
215
|
-
def __init__(self, state_cls:
|
|
209
|
+
def __init__(self, state_cls: type[BaseState]):
|
|
216
210
|
"""Initialize the EventHandlerSetVar.
|
|
217
211
|
|
|
218
212
|
Args:
|
|
@@ -277,7 +271,7 @@ if TYPE_CHECKING:
|
|
|
277
271
|
from pydantic.v1.fields import ModelField
|
|
278
272
|
|
|
279
273
|
|
|
280
|
-
def _unwrap_field_type(type_: types.GenericType) ->
|
|
274
|
+
def _unwrap_field_type(type_: types.GenericType) -> type:
|
|
281
275
|
"""Unwrap rx.Field type annotations.
|
|
282
276
|
|
|
283
277
|
Args:
|
|
@@ -293,7 +287,7 @@ def _unwrap_field_type(type_: types.GenericType) -> Type:
|
|
|
293
287
|
return type_
|
|
294
288
|
|
|
295
289
|
|
|
296
|
-
def get_var_for_field(cls:
|
|
290
|
+
def get_var_for_field(cls: type[BaseState], f: ModelField):
|
|
297
291
|
"""Get a Var instance for a Pydantic field.
|
|
298
292
|
|
|
299
293
|
Args:
|
|
@@ -338,31 +332,31 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
|
|
|
338
332
|
"""The state of the app."""
|
|
339
333
|
|
|
340
334
|
# A map from the var name to the var.
|
|
341
|
-
vars: ClassVar[
|
|
335
|
+
vars: ClassVar[builtins.dict[str, Var]] = {}
|
|
342
336
|
|
|
343
337
|
# The base vars of the class.
|
|
344
|
-
base_vars: ClassVar[
|
|
338
|
+
base_vars: ClassVar[builtins.dict[str, Var]] = {}
|
|
345
339
|
|
|
346
340
|
# The computed vars of the class.
|
|
347
|
-
computed_vars: ClassVar[
|
|
341
|
+
computed_vars: ClassVar[builtins.dict[str, ComputedVar]] = {}
|
|
348
342
|
|
|
349
343
|
# Vars inherited by the parent state.
|
|
350
|
-
inherited_vars: ClassVar[
|
|
344
|
+
inherited_vars: ClassVar[builtins.dict[str, Var]] = {}
|
|
351
345
|
|
|
352
346
|
# Backend base vars that are never sent to the client.
|
|
353
|
-
backend_vars: ClassVar[
|
|
347
|
+
backend_vars: ClassVar[builtins.dict[str, Any]] = {}
|
|
354
348
|
|
|
355
349
|
# Backend base vars inherited
|
|
356
|
-
inherited_backend_vars: ClassVar[
|
|
350
|
+
inherited_backend_vars: ClassVar[builtins.dict[str, Any]] = {}
|
|
357
351
|
|
|
358
352
|
# The event handlers.
|
|
359
|
-
event_handlers: ClassVar[
|
|
353
|
+
event_handlers: ClassVar[builtins.dict[str, EventHandler]] = {}
|
|
360
354
|
|
|
361
355
|
# A set of subclassses of this class.
|
|
362
|
-
class_subclasses: ClassVar[set[
|
|
356
|
+
class_subclasses: ClassVar[set[type[BaseState]]] = set()
|
|
363
357
|
|
|
364
358
|
# Mapping of var name to set of (state_full_name, var_name) that depend on it.
|
|
365
|
-
_var_dependencies: ClassVar[
|
|
359
|
+
_var_dependencies: ClassVar[builtins.dict[str, set[tuple[str, str]]]] = {}
|
|
366
360
|
|
|
367
361
|
# Set of vars which always need to be recomputed
|
|
368
362
|
_always_dirty_computed_vars: ClassVar[set[str]] = set()
|
|
@@ -377,7 +371,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
|
|
|
377
371
|
parent_state: BaseState | None = None
|
|
378
372
|
|
|
379
373
|
# The substates of the state.
|
|
380
|
-
substates:
|
|
374
|
+
substates: builtins.dict[str, BaseState] = {}
|
|
381
375
|
|
|
382
376
|
# The set of dirty vars.
|
|
383
377
|
dirty_vars: set[str] = set()
|
|
@@ -386,10 +380,10 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
|
|
|
386
380
|
dirty_substates: set[str] = set()
|
|
387
381
|
|
|
388
382
|
# The routing path that triggered the state
|
|
389
|
-
router_data:
|
|
383
|
+
router_data: builtins.dict[str, Any] = {}
|
|
390
384
|
|
|
391
385
|
# Per-instance copy of backend base variable values
|
|
392
|
-
_backend_vars:
|
|
386
|
+
_backend_vars: builtins.dict[str, Any] = {}
|
|
393
387
|
|
|
394
388
|
# The router data for the current page
|
|
395
389
|
router: RouterData = RouterData()
|
|
@@ -714,7 +708,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
|
|
|
714
708
|
return getattr(cls, unique_var_name)
|
|
715
709
|
|
|
716
710
|
@classmethod
|
|
717
|
-
def _mixins(cls) -> list[
|
|
711
|
+
def _mixins(cls) -> list[type]:
|
|
718
712
|
"""Get the mixin classes of the state.
|
|
719
713
|
|
|
720
714
|
Returns:
|
|
@@ -889,8 +883,8 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
|
|
|
889
883
|
)
|
|
890
884
|
|
|
891
885
|
@classmethod
|
|
892
|
-
@functools.lru_cache
|
|
893
|
-
def get_parent_state(cls) ->
|
|
886
|
+
@functools.lru_cache
|
|
887
|
+
def get_parent_state(cls) -> type[BaseState] | None:
|
|
894
888
|
"""Get the parent state.
|
|
895
889
|
|
|
896
890
|
Raises:
|
|
@@ -916,8 +910,8 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
|
|
|
916
910
|
return None # No known parent
|
|
917
911
|
|
|
918
912
|
@classmethod
|
|
919
|
-
@functools.lru_cache
|
|
920
|
-
def get_root_state(cls) ->
|
|
913
|
+
@functools.lru_cache
|
|
914
|
+
def get_root_state(cls) -> type[BaseState]:
|
|
921
915
|
"""Get the root state.
|
|
922
916
|
|
|
923
917
|
Returns:
|
|
@@ -927,7 +921,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
|
|
|
927
921
|
return cls if parent_state is None else parent_state.get_root_state()
|
|
928
922
|
|
|
929
923
|
@classmethod
|
|
930
|
-
def get_substates(cls) -> set[
|
|
924
|
+
def get_substates(cls) -> set[type[BaseState]]:
|
|
931
925
|
"""Get the substates of the state.
|
|
932
926
|
|
|
933
927
|
Returns:
|
|
@@ -936,7 +930,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
|
|
|
936
930
|
return cls.class_subclasses
|
|
937
931
|
|
|
938
932
|
@classmethod
|
|
939
|
-
@functools.lru_cache
|
|
933
|
+
@functools.lru_cache
|
|
940
934
|
def get_name(cls) -> str:
|
|
941
935
|
"""Get the name of the state.
|
|
942
936
|
|
|
@@ -947,7 +941,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
|
|
|
947
941
|
return format.to_snake_case(f"{module}___{cls.__name__}")
|
|
948
942
|
|
|
949
943
|
@classmethod
|
|
950
|
-
@functools.lru_cache
|
|
944
|
+
@functools.lru_cache
|
|
951
945
|
def get_full_name(cls) -> str:
|
|
952
946
|
"""Get the full name of the state.
|
|
953
947
|
|
|
@@ -961,8 +955,8 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
|
|
|
961
955
|
return name
|
|
962
956
|
|
|
963
957
|
@classmethod
|
|
964
|
-
@functools.lru_cache
|
|
965
|
-
def get_class_substate(cls, path: Sequence[str] | str) ->
|
|
958
|
+
@functools.lru_cache
|
|
959
|
+
def get_class_substate(cls, path: Sequence[str] | str) -> type[BaseState]:
|
|
966
960
|
"""Get the class substate.
|
|
967
961
|
|
|
968
962
|
Args:
|
|
@@ -1133,7 +1127,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
|
|
|
1133
1127
|
and not types.is_optional(prop._var_type)
|
|
1134
1128
|
):
|
|
1135
1129
|
# Ensure frontend uses null coalescing when accessing.
|
|
1136
|
-
object.__setattr__(prop, "_var_type",
|
|
1130
|
+
object.__setattr__(prop, "_var_type", prop._var_type | None)
|
|
1137
1131
|
|
|
1138
1132
|
@classmethod
|
|
1139
1133
|
def _get_var_default(cls, name: str, annotation_value: Any) -> Any:
|
|
@@ -1471,7 +1465,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
|
|
|
1471
1465
|
parent_state = parent_state.parent_state
|
|
1472
1466
|
return parent_state
|
|
1473
1467
|
|
|
1474
|
-
async def _get_state_from_redis(self, state_cls:
|
|
1468
|
+
async def _get_state_from_redis(self, state_cls: type[T_STATE]) -> T_STATE:
|
|
1475
1469
|
"""Get a state instance from redis.
|
|
1476
1470
|
|
|
1477
1471
|
Args:
|
|
@@ -1504,7 +1498,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
|
|
|
1504
1498
|
|
|
1505
1499
|
return state_in_redis
|
|
1506
1500
|
|
|
1507
|
-
def _get_state_from_cache(self, state_cls:
|
|
1501
|
+
def _get_state_from_cache(self, state_cls: type[T_STATE]) -> T_STATE:
|
|
1508
1502
|
"""Get a state instance from the cache.
|
|
1509
1503
|
|
|
1510
1504
|
Args:
|
|
@@ -1524,7 +1518,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
|
|
|
1524
1518
|
)
|
|
1525
1519
|
return substate
|
|
1526
1520
|
|
|
1527
|
-
async def get_state(self, state_cls:
|
|
1521
|
+
async def get_state(self, state_cls: type[T_STATE]) -> T_STATE:
|
|
1528
1522
|
"""Get an instance of the state associated with this token.
|
|
1529
1523
|
|
|
1530
1524
|
Allows for arbitrary access to sibling states from within an event handler.
|
|
@@ -1564,7 +1558,9 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
|
|
|
1564
1558
|
unset = object()
|
|
1565
1559
|
|
|
1566
1560
|
# Fast case: this is a literal var and the value is known.
|
|
1567
|
-
if (
|
|
1561
|
+
if (
|
|
1562
|
+
var_value := getattr(var, "_var_value", unset)
|
|
1563
|
+
) is not unset and not isinstance(var_value, Var):
|
|
1568
1564
|
return var_value # pyright: ignore [reportReturnType]
|
|
1569
1565
|
|
|
1570
1566
|
var_data = var._get_all_var_data()
|
|
@@ -1736,7 +1732,10 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
|
|
|
1736
1732
|
)
|
|
1737
1733
|
|
|
1738
1734
|
async def _process_event(
|
|
1739
|
-
self,
|
|
1735
|
+
self,
|
|
1736
|
+
handler: EventHandler,
|
|
1737
|
+
state: BaseState | StateProxy,
|
|
1738
|
+
payload: builtins.dict,
|
|
1740
1739
|
) -> AsyncIterator[StateUpdate]:
|
|
1741
1740
|
"""Process event.
|
|
1742
1741
|
|
|
@@ -1787,10 +1786,10 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
|
|
|
1787
1786
|
hinted_args, (Base, BaseModelV1, BaseModelV2)
|
|
1788
1787
|
):
|
|
1789
1788
|
payload[arg] = hinted_args(**value)
|
|
1790
|
-
elif isinstance(value, list) and (hinted_args is set or hinted_args is
|
|
1789
|
+
elif isinstance(value, list) and (hinted_args is set or hinted_args is set):
|
|
1791
1790
|
payload[arg] = set(value)
|
|
1792
1791
|
elif isinstance(value, list) and (
|
|
1793
|
-
hinted_args is tuple or hinted_args is
|
|
1792
|
+
hinted_args is tuple or hinted_args is tuple
|
|
1794
1793
|
):
|
|
1795
1794
|
payload[arg] = tuple(value)
|
|
1796
1795
|
elif isinstance(value, str) and (
|
|
@@ -2170,7 +2169,7 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
|
|
|
2170
2169
|
_WARNED_ABOUT_STATE_SIZE.add(state_full_name)
|
|
2171
2170
|
|
|
2172
2171
|
@classmethod
|
|
2173
|
-
@functools.lru_cache
|
|
2172
|
+
@functools.lru_cache
|
|
2174
2173
|
def _to_schema(cls) -> str:
|
|
2175
2174
|
"""Convert a state to a schema.
|
|
2176
2175
|
|
|
@@ -2313,7 +2312,7 @@ def dynamic(func: Callable[[T], Component]):
|
|
|
2313
2312
|
"You must provide a type hint for the state class in the function."
|
|
2314
2313
|
)
|
|
2315
2314
|
|
|
2316
|
-
state_class:
|
|
2315
|
+
state_class: type[T] = values[0]
|
|
2317
2316
|
|
|
2318
2317
|
def wrapper() -> Component:
|
|
2319
2318
|
from reflex.components.base.fragment import fragment
|
|
@@ -2465,7 +2464,7 @@ class ComponentState(State, mixin=True):
|
|
|
2465
2464
|
super().__init_subclass__(mixin=mixin, **kwargs)
|
|
2466
2465
|
|
|
2467
2466
|
@classmethod
|
|
2468
|
-
def get_component(cls, *children, **props) ->
|
|
2467
|
+
def get_component(cls, *children, **props) -> Component:
|
|
2469
2468
|
"""Get the component instance.
|
|
2470
2469
|
|
|
2471
2470
|
Args:
|
|
@@ -2480,7 +2479,7 @@ class ComponentState(State, mixin=True):
|
|
|
2480
2479
|
)
|
|
2481
2480
|
|
|
2482
2481
|
@classmethod
|
|
2483
|
-
def create(cls, *children, **props) ->
|
|
2482
|
+
def create(cls, *children, **props) -> Component:
|
|
2484
2483
|
"""Create a new instance of the Component.
|
|
2485
2484
|
|
|
2486
2485
|
Args:
|
|
@@ -2537,7 +2536,7 @@ class StateProxy(wrapt.ObjectProxy):
|
|
|
2537
2536
|
def __init__(
|
|
2538
2537
|
self,
|
|
2539
2538
|
state_instance: BaseState,
|
|
2540
|
-
parent_state_proxy:
|
|
2539
|
+
parent_state_proxy: StateProxy | None = None,
|
|
2541
2540
|
):
|
|
2542
2541
|
"""Create a proxy for a state instance.
|
|
2543
2542
|
|
|
@@ -2741,7 +2740,7 @@ class StateProxy(wrapt.ObjectProxy):
|
|
|
2741
2740
|
)
|
|
2742
2741
|
return self.__wrapped__.get_substate(path)
|
|
2743
2742
|
|
|
2744
|
-
async def get_state(self, state_cls:
|
|
2743
|
+
async def get_state(self, state_cls: type[BaseState]) -> BaseState:
|
|
2745
2744
|
"""Get an instance of the state associated with this token.
|
|
2746
2745
|
|
|
2747
2746
|
Args:
|
|
@@ -2808,10 +2807,10 @@ class StateManager(Base, ABC):
|
|
|
2808
2807
|
"""A class to manage many client states."""
|
|
2809
2808
|
|
|
2810
2809
|
# The state class to use.
|
|
2811
|
-
state:
|
|
2810
|
+
state: type[BaseState]
|
|
2812
2811
|
|
|
2813
2812
|
@classmethod
|
|
2814
|
-
def create(cls, state:
|
|
2813
|
+
def create(cls, state: type[BaseState]):
|
|
2815
2814
|
"""Create a new state manager.
|
|
2816
2815
|
|
|
2817
2816
|
Args:
|
|
@@ -3019,7 +3018,7 @@ class StateManagerDisk(StateManager):
|
|
|
3019
3018
|
}
|
|
3020
3019
|
keep_untouched = (functools.cached_property,)
|
|
3021
3020
|
|
|
3022
|
-
def __init__(self, state:
|
|
3021
|
+
def __init__(self, state: type[BaseState]):
|
|
3023
3022
|
"""Create a new state manager.
|
|
3024
3023
|
|
|
3025
3024
|
Args:
|
|
@@ -3259,10 +3258,10 @@ class StateManagerRedis(StateManager):
|
|
|
3259
3258
|
|
|
3260
3259
|
def _get_required_state_classes(
|
|
3261
3260
|
self,
|
|
3262
|
-
target_state_cls:
|
|
3261
|
+
target_state_cls: type[BaseState],
|
|
3263
3262
|
subclasses: bool = False,
|
|
3264
|
-
required_state_classes: set[
|
|
3265
|
-
) -> set[
|
|
3263
|
+
required_state_classes: set[type[BaseState]] | None = None,
|
|
3264
|
+
) -> set[type[BaseState]]:
|
|
3266
3265
|
"""Recursively determine which states are required to fetch the target state.
|
|
3267
3266
|
|
|
3268
3267
|
This will always include potentially dirty substates that depend on vars
|
|
@@ -4119,7 +4118,7 @@ def code_uses_state_contexts(javascript_code: str) -> bool:
|
|
|
4119
4118
|
|
|
4120
4119
|
def reload_state_module(
|
|
4121
4120
|
module: str,
|
|
4122
|
-
state:
|
|
4121
|
+
state: type[BaseState] = State,
|
|
4123
4122
|
) -> None:
|
|
4124
4123
|
"""Reset rx.State subclasses to avoid conflict when reloading.
|
|
4125
4124
|
|