reflex 0.7.13a1__py3-none-any.whl → 0.7.14a1__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/apps/blank/code/blank.py +0 -2
- reflex/app.py +79 -72
- reflex/app_mixins/lifespan.py +2 -3
- reflex/app_mixins/middleware.py +1 -0
- reflex/app_mixins/mixin.py +0 -1
- reflex/assets.py +6 -3
- reflex/base.py +3 -2
- reflex/compiler/compiler.py +77 -64
- reflex/compiler/utils.py +8 -6
- reflex/components/base/app_wrap.pyi +0 -1
- reflex/components/base/bare.py +5 -7
- reflex/components/base/body.pyi +0 -1
- reflex/components/base/document.pyi +0 -5
- reflex/components/base/error_boundary.pyi +0 -1
- reflex/components/base/fragment.pyi +0 -1
- reflex/components/base/head.pyi +0 -2
- reflex/components/base/link.pyi +0 -2
- reflex/components/base/meta.py +2 -1
- reflex/components/base/meta.pyi +0 -4
- reflex/components/base/script.py +2 -1
- reflex/components/base/script.pyi +0 -1
- reflex/components/base/strict_mode.pyi +0 -1
- reflex/components/component.py +38 -40
- reflex/components/core/auto_scroll.pyi +0 -1
- reflex/components/core/banner.pyi +0 -6
- reflex/components/core/breakpoints.py +9 -11
- reflex/components/core/client_side_routing.pyi +0 -2
- reflex/components/core/clipboard.pyi +0 -1
- reflex/components/core/colors.py +10 -7
- reflex/components/core/cond.py +4 -2
- reflex/components/core/debounce.py +5 -3
- reflex/components/core/debounce.pyi +0 -1
- reflex/components/core/foreach.py +8 -6
- reflex/components/core/html.py +3 -3
- reflex/components/core/html.pyi +0 -1
- reflex/components/core/match.py +19 -17
- reflex/components/core/sticky.pyi +0 -4
- reflex/components/core/upload.pyi +0 -5
- reflex/components/datadisplay/code.py +1 -2
- reflex/components/datadisplay/code.pyi +0 -2
- reflex/components/datadisplay/dataeditor.py +7 -10
- reflex/components/datadisplay/dataeditor.pyi +0 -1
- reflex/components/datadisplay/logo.py +3 -4
- reflex/components/datadisplay/shiki_code_block.py +8 -11
- reflex/components/datadisplay/shiki_code_block.pyi +0 -3
- reflex/components/dynamic.py +2 -3
- reflex/components/el/__init__.pyi +2 -0
- reflex/components/el/element.pyi +0 -1
- reflex/components/el/elements/__init__.py +1 -0
- reflex/components/el/elements/__init__.pyi +3 -0
- reflex/components/el/elements/base.pyi +0 -1
- reflex/components/el/elements/forms.py +3 -4
- reflex/components/el/elements/forms.pyi +1 -18
- reflex/components/el/elements/inline.pyi +0 -28
- reflex/components/el/elements/media.py +26 -0
- reflex/components/el/elements/media.pyi +259 -25
- reflex/components/el/elements/metadata.py +0 -1
- reflex/components/el/elements/metadata.pyi +0 -6
- reflex/components/el/elements/other.pyi +0 -7
- reflex/components/el/elements/scripts.pyi +0 -3
- reflex/components/el/elements/sectioning.pyi +0 -15
- reflex/components/el/elements/tables.pyi +0 -10
- reflex/components/el/elements/typography.pyi +0 -15
- reflex/components/gridjs/datatable.py +10 -13
- reflex/components/gridjs/datatable.pyi +0 -2
- reflex/components/lucide/icon.py +10 -9
- reflex/components/lucide/icon.pyi +0 -3
- reflex/components/markdown/markdown.py +6 -8
- reflex/components/markdown/markdown.pyi +0 -1
- reflex/components/moment/moment.pyi +0 -1
- reflex/components/next/base.py +0 -2
- reflex/components/next/base.pyi +0 -3
- reflex/components/next/image.pyi +0 -1
- reflex/components/next/link.pyi +0 -1
- reflex/components/next/video.pyi +0 -1
- reflex/components/plotly/plotly.pyi +0 -9
- reflex/components/props.py +4 -3
- reflex/components/radix/primitives/accordion.py +1 -1
- reflex/components/radix/primitives/accordion.pyi +0 -7
- reflex/components/radix/primitives/base.py +1 -3
- reflex/components/radix/primitives/base.pyi +0 -2
- reflex/components/radix/primitives/drawer.py +1 -1
- reflex/components/radix/primitives/drawer.pyi +0 -11
- reflex/components/radix/primitives/form.py +5 -9
- reflex/components/radix/primitives/form.pyi +0 -12
- reflex/components/radix/primitives/progress.py +1 -1
- reflex/components/radix/primitives/progress.pyi +0 -5
- reflex/components/radix/primitives/slider.py +1 -1
- reflex/components/radix/primitives/slider.pyi +0 -5
- reflex/components/radix/themes/base.pyi +0 -8
- reflex/components/radix/themes/color_mode.pyi +0 -3
- reflex/components/radix/themes/components/alert_dialog.py +4 -2
- reflex/components/radix/themes/components/alert_dialog.pyi +4 -9
- reflex/components/radix/themes/components/aspect_ratio.py +1 -2
- reflex/components/radix/themes/components/aspect_ratio.pyi +1 -3
- reflex/components/radix/themes/components/avatar.py +5 -2
- reflex/components/radix/themes/components/avatar.pyi +1 -3
- reflex/components/radix/themes/components/badge.py +5 -2
- reflex/components/radix/themes/components/badge.pyi +1 -3
- reflex/components/radix/themes/components/button.py +2 -3
- reflex/components/radix/themes/components/button.pyi +1 -3
- reflex/components/radix/themes/components/callout.py +1 -2
- reflex/components/radix/themes/components/callout.pyi +1 -7
- reflex/components/radix/themes/components/card.py +1 -2
- reflex/components/radix/themes/components/card.pyi +1 -3
- reflex/components/radix/themes/components/checkbox.py +7 -4
- reflex/components/radix/themes/components/checkbox.pyi +1 -5
- reflex/components/radix/themes/components/checkbox_cards.py +1 -2
- reflex/components/radix/themes/components/checkbox_cards.pyi +1 -4
- reflex/components/radix/themes/components/checkbox_group.py +1 -2
- reflex/components/radix/themes/components/checkbox_group.pyi +1 -4
- reflex/components/radix/themes/components/context_menu.py +1 -1
- reflex/components/radix/themes/components/context_menu.pyi +1 -14
- reflex/components/radix/themes/components/data_list.py +1 -2
- reflex/components/radix/themes/components/data_list.pyi +1 -6
- reflex/components/radix/themes/components/dialog.py +4 -2
- reflex/components/radix/themes/components/dialog.pyi +4 -9
- reflex/components/radix/themes/components/dropdown_menu.py +5 -2
- reflex/components/radix/themes/components/dropdown_menu.pyi +4 -10
- reflex/components/radix/themes/components/hover_card.py +4 -2
- reflex/components/radix/themes/components/hover_card.pyi +4 -6
- reflex/components/radix/themes/components/icon_button.py +7 -8
- reflex/components/radix/themes/components/icon_button.pyi +1 -3
- reflex/components/radix/themes/components/inset.py +1 -2
- reflex/components/radix/themes/components/inset.pyi +1 -3
- reflex/components/radix/themes/components/popover.py +4 -2
- reflex/components/radix/themes/components/popover.pyi +4 -6
- reflex/components/radix/themes/components/progress.py +1 -2
- reflex/components/radix/themes/components/progress.pyi +1 -3
- reflex/components/radix/themes/components/radio.py +1 -2
- reflex/components/radix/themes/components/radio.pyi +1 -3
- reflex/components/radix/themes/components/radio_cards.py +1 -2
- reflex/components/radix/themes/components/radio_cards.pyi +1 -4
- reflex/components/radix/themes/components/radio_group.py +7 -5
- reflex/components/radix/themes/components/radio_group.pyi +1 -6
- reflex/components/radix/themes/components/scroll_area.py +1 -2
- reflex/components/radix/themes/components/scroll_area.pyi +1 -3
- reflex/components/radix/themes/components/segmented_control.py +1 -2
- reflex/components/radix/themes/components/segmented_control.pyi +1 -4
- reflex/components/radix/themes/components/select.py +5 -2
- reflex/components/radix/themes/components/select.pyi +1 -11
- reflex/components/radix/themes/components/separator.py +1 -2
- reflex/components/radix/themes/components/separator.pyi +1 -3
- reflex/components/radix/themes/components/skeleton.py +1 -2
- reflex/components/radix/themes/components/skeleton.pyi +1 -3
- reflex/components/radix/themes/components/slider.py +1 -2
- reflex/components/radix/themes/components/slider.pyi +1 -3
- reflex/components/radix/themes/components/spinner.py +1 -2
- reflex/components/radix/themes/components/spinner.pyi +1 -3
- reflex/components/radix/themes/components/switch.py +1 -2
- reflex/components/radix/themes/components/switch.pyi +1 -3
- reflex/components/radix/themes/components/table.py +1 -2
- reflex/components/radix/themes/components/table.pyi +1 -9
- reflex/components/radix/themes/components/tabs.py +1 -2
- reflex/components/radix/themes/components/tabs.pyi +1 -7
- reflex/components/radix/themes/components/text_area.py +5 -2
- reflex/components/radix/themes/components/text_area.pyi +1 -3
- reflex/components/radix/themes/components/text_field.py +5 -2
- reflex/components/radix/themes/components/text_field.pyi +1 -5
- reflex/components/radix/themes/components/tooltip.py +1 -2
- reflex/components/radix/themes/components/tooltip.pyi +1 -3
- reflex/components/radix/themes/layout/base.py +5 -2
- reflex/components/radix/themes/layout/base.pyi +5 -3
- reflex/components/radix/themes/layout/box.py +1 -2
- reflex/components/radix/themes/layout/box.pyi +1 -3
- reflex/components/radix/themes/layout/center.pyi +0 -1
- reflex/components/radix/themes/layout/container.py +1 -2
- reflex/components/radix/themes/layout/container.pyi +1 -3
- reflex/components/radix/themes/layout/flex.py +6 -2
- reflex/components/radix/themes/layout/flex.pyi +1 -3
- reflex/components/radix/themes/layout/grid.py +6 -2
- reflex/components/radix/themes/layout/grid.pyi +1 -3
- reflex/components/radix/themes/layout/list.py +2 -1
- reflex/components/radix/themes/layout/list.pyi +0 -5
- reflex/components/radix/themes/layout/section.py +1 -2
- reflex/components/radix/themes/layout/section.pyi +1 -3
- reflex/components/radix/themes/layout/spacer.pyi +0 -1
- reflex/components/radix/themes/layout/stack.py +1 -1
- reflex/components/radix/themes/layout/stack.pyi +0 -3
- reflex/components/radix/themes/typography/blockquote.py +1 -1
- reflex/components/radix/themes/typography/blockquote.pyi +1 -3
- reflex/components/radix/themes/typography/code.py +5 -1
- reflex/components/radix/themes/typography/code.pyi +1 -3
- reflex/components/radix/themes/typography/heading.py +1 -1
- reflex/components/radix/themes/typography/heading.pyi +1 -3
- reflex/components/radix/themes/typography/link.py +3 -2
- reflex/components/radix/themes/typography/link.pyi +1 -3
- reflex/components/radix/themes/typography/text.py +1 -1
- reflex/components/radix/themes/typography/text.pyi +1 -9
- reflex/components/react_player/audio.py +0 -2
- reflex/components/react_player/audio.pyi +0 -3
- reflex/components/react_player/react_player.pyi +0 -1
- reflex/components/react_player/video.py +0 -2
- reflex/components/react_player/video.pyi +0 -3
- reflex/components/recharts/__init__.py +1 -1
- reflex/components/recharts/__init__.pyi +1 -1
- reflex/components/recharts/cartesian.py +20 -25
- reflex/components/recharts/cartesian.pyi +20 -37
- reflex/components/recharts/charts.py +2 -1
- reflex/components/recharts/charts.pyi +0 -12
- reflex/components/recharts/general.pyi +0 -6
- reflex/components/recharts/polar.py +5 -4
- reflex/components/recharts/polar.pyi +4 -10
- reflex/components/recharts/recharts.py +12 -10
- reflex/components/recharts/recharts.pyi +10 -11
- reflex/components/sonner/toast.py +2 -2
- reflex/components/sonner/toast.pyi +0 -2
- reflex/components/suneditor/editor.py +2 -1
- reflex/components/suneditor/editor.pyi +0 -1
- reflex/components/tags/iter_tag.py +4 -2
- reflex/config.py +47 -35
- reflex/constants/base.py +3 -3
- reflex/constants/compiler.py +8 -6
- reflex/constants/installer.py +24 -15
- reflex/custom_components/custom_components.py +1 -2
- reflex/event.py +58 -60
- reflex/experimental/__init__.py +2 -2
- reflex/experimental/client_state.py +9 -4
- reflex/experimental/layout.pyi +0 -5
- reflex/istate/manager.py +15 -19
- reflex/istate/proxy.py +19 -12
- reflex/model.py +6 -4
- reflex/plugins/base.py +8 -0
- reflex/plugins/tailwind_v3.py +8 -0
- reflex/plugins/tailwind_v4.py +9 -0
- reflex/reflex.py +9 -11
- reflex/route.py +7 -9
- reflex/state.py +66 -70
- reflex/style.py +3 -1
- reflex/testing.py +46 -29
- reflex/utils/build.py +2 -1
- reflex/utils/console.py +9 -17
- reflex/utils/exec.py +9 -11
- reflex/utils/format.py +21 -24
- reflex/utils/imports.py +4 -3
- reflex/utils/lazy_loader.py +3 -3
- reflex/utils/misc.py +2 -1
- reflex/utils/net.py +2 -2
- reflex/utils/path_ops.py +2 -1
- reflex/utils/prerequisites.py +67 -38
- reflex/utils/processes.py +4 -6
- reflex/utils/pyi_generator.py +46 -41
- reflex/utils/redir.py +1 -1
- reflex/utils/serializers.py +4 -4
- reflex/utils/telemetry.py +42 -4
- reflex/utils/types.py +16 -13
- reflex/vars/base.py +96 -109
- reflex/vars/datetime.py +2 -1
- reflex/vars/dep_tracking.py +19 -28
- reflex/vars/number.py +6 -7
- reflex/vars/object.py +5 -6
- reflex/vars/sequence.py +11 -11
- {reflex-0.7.13a1.dist-info → reflex-0.7.14a1.dist-info}/METADATA +1 -1
- reflex-0.7.14a1.dist-info/RECORD +407 -0
- reflex-0.7.13a1.dist-info/RECORD +0 -407
- {reflex-0.7.13a1.dist-info → reflex-0.7.14a1.dist-info}/WHEEL +0 -0
- {reflex-0.7.13a1.dist-info → reflex-0.7.14a1.dist-info}/entry_points.txt +0 -0
- {reflex-0.7.13a1.dist-info → reflex-0.7.14a1.dist-info}/licenses/LICENSE +0 -0
|
@@ -93,7 +93,6 @@ class ConnectionToaster(Fragment):
|
|
|
93
93
|
Returns:
|
|
94
94
|
The connection toaster component.
|
|
95
95
|
"""
|
|
96
|
-
...
|
|
97
96
|
|
|
98
97
|
class ConnectionBanner(Component):
|
|
99
98
|
@overload
|
|
@@ -137,7 +136,6 @@ class ConnectionBanner(Component):
|
|
|
137
136
|
Returns:
|
|
138
137
|
The connection banner component.
|
|
139
138
|
"""
|
|
140
|
-
...
|
|
141
139
|
|
|
142
140
|
class ConnectionModal(Component):
|
|
143
141
|
@overload
|
|
@@ -181,7 +179,6 @@ class ConnectionModal(Component):
|
|
|
181
179
|
Returns:
|
|
182
180
|
The connection banner component.
|
|
183
181
|
"""
|
|
184
|
-
...
|
|
185
182
|
|
|
186
183
|
class WifiOffPulse(Icon):
|
|
187
184
|
@overload
|
|
@@ -235,7 +232,6 @@ class WifiOffPulse(Icon):
|
|
|
235
232
|
Returns:
|
|
236
233
|
The icon component with default props applied.
|
|
237
234
|
"""
|
|
238
|
-
...
|
|
239
235
|
|
|
240
236
|
def add_imports(self) -> dict[str, str | ImportVar | list[str | ImportVar]]: ...
|
|
241
237
|
|
|
@@ -482,7 +478,6 @@ class ConnectionPulser(Div):
|
|
|
482
478
|
Returns:
|
|
483
479
|
The connection pulser component.
|
|
484
480
|
"""
|
|
485
|
-
...
|
|
486
481
|
|
|
487
482
|
class BackendDisabled(Div):
|
|
488
483
|
@overload
|
|
@@ -727,7 +722,6 @@ class BackendDisabled(Div):
|
|
|
727
722
|
Returns:
|
|
728
723
|
The backend disabled component.
|
|
729
724
|
"""
|
|
730
|
-
...
|
|
731
725
|
|
|
732
726
|
connection_banner = ConnectionBanner.create
|
|
733
727
|
connection_modal = ConnectionModal.create
|
|
@@ -75,19 +75,17 @@ class Breakpoints(dict[K, V]):
|
|
|
75
75
|
|
|
76
76
|
if custom is not None:
|
|
77
77
|
if any(threshold is not None for threshold in thresholds):
|
|
78
|
-
|
|
78
|
+
msg = "Named props cannot be used with custom thresholds"
|
|
79
|
+
raise ValueError(msg)
|
|
79
80
|
|
|
80
81
|
return Breakpoints(custom)
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if v is not None
|
|
89
|
-
}
|
|
90
|
-
)
|
|
82
|
+
return Breakpoints(
|
|
83
|
+
{
|
|
84
|
+
k: v
|
|
85
|
+
for k, v in zip(["initial", *breakpoint_names], thresholds, strict=True)
|
|
86
|
+
if v is not None
|
|
87
|
+
}
|
|
88
|
+
)
|
|
91
89
|
|
|
92
90
|
|
|
93
91
|
breakpoints = Breakpoints.create
|
|
@@ -65,7 +65,6 @@ class ClientSideRouting(Component):
|
|
|
65
65
|
Returns:
|
|
66
66
|
The component.
|
|
67
67
|
"""
|
|
68
|
-
...
|
|
69
68
|
|
|
70
69
|
def wait_for_client_redirect(component: Component) -> Component: ...
|
|
71
70
|
|
|
@@ -120,4 +119,3 @@ class Default404Page(Component):
|
|
|
120
119
|
Returns:
|
|
121
120
|
The component.
|
|
122
121
|
"""
|
|
123
|
-
...
|
reflex/components/core/colors.py
CHANGED
|
@@ -32,19 +32,22 @@ def color(
|
|
|
32
32
|
"""
|
|
33
33
|
if isinstance(color, str):
|
|
34
34
|
if color not in COLORS and REFLEX_VAR_OPENING_TAG not in color:
|
|
35
|
-
|
|
35
|
+
msg = f"Color must be one of {COLORS}, received {color}"
|
|
36
|
+
raise ValueError(msg)
|
|
36
37
|
elif not isinstance(color, Var):
|
|
37
|
-
|
|
38
|
+
msg = "Color must be a string or a Var"
|
|
39
|
+
raise ValueError(msg)
|
|
38
40
|
|
|
39
41
|
if isinstance(shade, int):
|
|
40
42
|
if shade < MIN_SHADE_VALUE or shade > MAX_SHADE_VALUE:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
)
|
|
43
|
+
msg = f"Shade must be between {MIN_SHADE_VALUE} and {MAX_SHADE_VALUE}"
|
|
44
|
+
raise ValueError(msg)
|
|
44
45
|
elif not isinstance(shade, Var):
|
|
45
|
-
|
|
46
|
+
msg = "Shade must be an integer or a Var"
|
|
47
|
+
raise ValueError(msg)
|
|
46
48
|
|
|
47
49
|
if not isinstance(alpha, (bool, Var)):
|
|
48
|
-
|
|
50
|
+
msg = "Alpha must be a boolean or a Var"
|
|
51
|
+
raise ValueError(msg)
|
|
49
52
|
|
|
50
53
|
return Color(color, shade, alpha)
|
reflex/components/core/cond.py
CHANGED
|
@@ -132,7 +132,8 @@ def cond(condition: Any, c1: Any, c2: Any = types.Unset(), /) -> Component | Var
|
|
|
132
132
|
# Convert the condition to a Var.
|
|
133
133
|
cond_var = LiteralVar.create(condition)
|
|
134
134
|
if cond_var is None:
|
|
135
|
-
|
|
135
|
+
msg = "The condition must be set."
|
|
136
|
+
raise ValueError(msg)
|
|
136
137
|
|
|
137
138
|
# If the first component is a component, create a Cond component.
|
|
138
139
|
if isinstance(c1, BaseComponent):
|
|
@@ -145,7 +146,8 @@ def cond(condition: Any, c1: Any, c2: Any = types.Unset(), /) -> Component | Var
|
|
|
145
146
|
if isinstance(c2, BaseComponent):
|
|
146
147
|
return Cond.create(cond_var.bool(), Fragment.create(c1), c2)
|
|
147
148
|
if isinstance(c2, types.Unset):
|
|
148
|
-
|
|
149
|
+
msg = "For conditional vars, the second argument must be set."
|
|
150
|
+
raise ValueError(msg)
|
|
149
151
|
|
|
150
152
|
# convert the truth and false cond parts into vars so the _var_data can be obtained.
|
|
151
153
|
c1_var = Var.create(c1)
|
|
@@ -70,14 +70,16 @@ class DebounceInput(Component):
|
|
|
70
70
|
ValueError: if the child element does not have an on_change handler.
|
|
71
71
|
"""
|
|
72
72
|
if len(children) != 1:
|
|
73
|
-
|
|
73
|
+
msg = (
|
|
74
74
|
"Provide a single child for DebounceInput, such as rx.input() or "
|
|
75
|
-
"rx.text_area()"
|
|
75
|
+
"rx.text_area()"
|
|
76
76
|
)
|
|
77
|
+
raise RuntimeError(msg)
|
|
77
78
|
|
|
78
79
|
child = children[0]
|
|
79
80
|
if "on_change" not in child.event_triggers:
|
|
80
|
-
|
|
81
|
+
msg = "DebounceInput child requires an on_change handler"
|
|
82
|
+
raise ValueError(msg)
|
|
81
83
|
|
|
82
84
|
# Carry known props and event_triggers from the child.
|
|
83
85
|
props_from_child = {
|
|
@@ -69,19 +69,19 @@ class Foreach(Component):
|
|
|
69
69
|
)
|
|
70
70
|
|
|
71
71
|
if iterable._var_type == Any:
|
|
72
|
-
|
|
72
|
+
msg = (
|
|
73
73
|
f"Could not foreach over var `{iterable!s}` of type Any. "
|
|
74
74
|
"(If you are trying to foreach over a state var, add a type annotation to the var). "
|
|
75
75
|
"See https://reflex.dev/docs/library/dynamic-rendering/foreach/"
|
|
76
76
|
)
|
|
77
|
+
raise ForeachVarError(msg)
|
|
77
78
|
|
|
78
79
|
if (
|
|
79
80
|
hasattr(render_fn, "__qualname__")
|
|
80
81
|
and render_fn.__qualname__ == ComponentState.create.__qualname__
|
|
81
82
|
):
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
)
|
|
83
|
+
msg = "Using a ComponentState as `render_fn` inside `rx.foreach` is not supported yet."
|
|
84
|
+
raise TypeError(msg)
|
|
85
85
|
|
|
86
86
|
if isinstance(iterable, ObjectVar):
|
|
87
87
|
iterable = iterable.entries()
|
|
@@ -90,10 +90,11 @@ class Foreach(Component):
|
|
|
90
90
|
iterable = iterable.split()
|
|
91
91
|
|
|
92
92
|
if not isinstance(iterable, ArrayVar):
|
|
93
|
-
|
|
93
|
+
msg = (
|
|
94
94
|
f"Could not foreach over var `{iterable!s}` of type {iterable._var_type}. "
|
|
95
95
|
"See https://reflex.dev/docs/library/dynamic-rendering/foreach/"
|
|
96
96
|
)
|
|
97
|
+
raise ForeachVarError(msg)
|
|
97
98
|
|
|
98
99
|
if types.is_optional(iterable._var_type):
|
|
99
100
|
iterable = cond(iterable, iterable, [])
|
|
@@ -122,11 +123,12 @@ class Foreach(Component):
|
|
|
122
123
|
|
|
123
124
|
# Validate the render function signature.
|
|
124
125
|
if len(params) == 0 or len(params) > 2:
|
|
125
|
-
|
|
126
|
+
msg = (
|
|
126
127
|
"Expected 1 or 2 parameters in foreach render function, got "
|
|
127
128
|
f"{[p.name for p in params]}. See "
|
|
128
129
|
"https://reflex.dev/docs/library/dynamic-rendering/foreach/"
|
|
129
130
|
)
|
|
131
|
+
raise ForeachRenderError(msg)
|
|
130
132
|
|
|
131
133
|
if len(params) >= 1:
|
|
132
134
|
# Determine the arg var name based on the params accepted by render_fn.
|
reflex/components/core/html.py
CHANGED
|
@@ -30,9 +30,9 @@ class Html(Div):
|
|
|
30
30
|
"""
|
|
31
31
|
# If children are not provided, throw an error.
|
|
32
32
|
if len(children) != 1:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
msg = "Must provide children to the html component."
|
|
34
|
+
raise ValueError(msg)
|
|
35
|
+
props["dangerouslySetInnerHTML"] = {"__html": children[0]}
|
|
36
36
|
|
|
37
37
|
# Apply the default classname
|
|
38
38
|
given_class_name = props.pop("class_name", [])
|
reflex/components/core/html.pyi
CHANGED
reflex/components/core/match.py
CHANGED
|
@@ -47,9 +47,8 @@ class Match(MemoizationLeaf):
|
|
|
47
47
|
cls._validate_return_types(match_cases)
|
|
48
48
|
|
|
49
49
|
if default is None and isinstance(match_cases[0][-1], Var):
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
)
|
|
50
|
+
msg = "For cases with return types as Vars, a default case must be provided"
|
|
51
|
+
raise ValueError(msg)
|
|
53
52
|
|
|
54
53
|
return cls._create_match_cond_var_or_component(
|
|
55
54
|
match_cond_var, match_cases, default
|
|
@@ -71,7 +70,8 @@ class Match(MemoizationLeaf):
|
|
|
71
70
|
match_cond_var = LiteralVar.create(cond)
|
|
72
71
|
|
|
73
72
|
if match_cond_var is None:
|
|
74
|
-
|
|
73
|
+
msg = "The condition must be set"
|
|
74
|
+
raise ValueError(msg)
|
|
75
75
|
return match_cond_var
|
|
76
76
|
|
|
77
77
|
@classmethod
|
|
@@ -90,10 +90,12 @@ class Match(MemoizationLeaf):
|
|
|
90
90
|
default = None
|
|
91
91
|
|
|
92
92
|
if len([case for case in cases if not isinstance(case, tuple)]) > 1:
|
|
93
|
-
|
|
93
|
+
msg = "rx.match can only have one default case."
|
|
94
|
+
raise ValueError(msg)
|
|
94
95
|
|
|
95
96
|
if not cases:
|
|
96
|
-
|
|
97
|
+
msg = "rx.match should have at least one case."
|
|
98
|
+
raise ValueError(msg)
|
|
97
99
|
|
|
98
100
|
# Get the default case which should be the last non-tuple arg
|
|
99
101
|
if not isinstance(cases[-1], tuple):
|
|
@@ -119,8 +121,7 @@ class Match(MemoizationLeaf):
|
|
|
119
121
|
The case element Var.
|
|
120
122
|
"""
|
|
121
123
|
_var_data = case_element._var_data if isinstance(case_element, Style) else None
|
|
122
|
-
|
|
123
|
-
return case_element
|
|
124
|
+
return LiteralVar.create(case_element, _var_data=_var_data)
|
|
124
125
|
|
|
125
126
|
@classmethod
|
|
126
127
|
def _process_match_cases(cls, cases: list) -> list[list[Var]]:
|
|
@@ -138,14 +139,12 @@ class Match(MemoizationLeaf):
|
|
|
138
139
|
match_cases = []
|
|
139
140
|
for case in cases:
|
|
140
141
|
if not isinstance(case, tuple):
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
)
|
|
142
|
+
msg = "rx.match should have tuples of cases and a default case as the last argument."
|
|
143
|
+
raise ValueError(msg)
|
|
144
144
|
# There should be at least two elements in a case tuple(a condition and return value)
|
|
145
145
|
if len(case) < 2:
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
)
|
|
146
|
+
msg = "A case tuple should have at least a match case element and a return value."
|
|
147
|
+
raise ValueError(msg)
|
|
149
148
|
|
|
150
149
|
case_list = []
|
|
151
150
|
for element in case:
|
|
@@ -156,7 +155,8 @@ class Match(MemoizationLeaf):
|
|
|
156
155
|
else element
|
|
157
156
|
)
|
|
158
157
|
if not isinstance(el, (Var, BaseComponent)):
|
|
159
|
-
|
|
158
|
+
msg = "Case element must be a var or component"
|
|
159
|
+
raise ValueError(msg)
|
|
160
160
|
case_list.append(el)
|
|
161
161
|
|
|
162
162
|
match_cases.append(case_list)
|
|
@@ -183,11 +183,12 @@ class Match(MemoizationLeaf):
|
|
|
183
183
|
|
|
184
184
|
for index, case in enumerate(match_cases):
|
|
185
185
|
if not isinstance(case[-1], return_type):
|
|
186
|
-
|
|
186
|
+
msg = (
|
|
187
187
|
f"Match cases should have the same return types. Case {index} with return "
|
|
188
188
|
f"value `{case[-1]._js_expr if isinstance(case[-1], Var) else textwrap.shorten(str(case[-1]), width=250)}`"
|
|
189
189
|
f" of type {type(case[-1])!r} is not {return_type}"
|
|
190
190
|
)
|
|
191
|
+
raise MatchTypeError(msg)
|
|
191
192
|
|
|
192
193
|
@classmethod
|
|
193
194
|
def _create_match_cond_var_or_component(
|
|
@@ -226,7 +227,8 @@ class Match(MemoizationLeaf):
|
|
|
226
227
|
if any(
|
|
227
228
|
case for case in match_cases if not isinstance(case[-1], Var)
|
|
228
229
|
) or not isinstance(default, Var):
|
|
229
|
-
|
|
230
|
+
msg = "Return types of match cases should be Vars."
|
|
231
|
+
raise ValueError(msg)
|
|
230
232
|
|
|
231
233
|
return Var(
|
|
232
234
|
_js_expr=format.format_match(
|
|
@@ -234,7 +234,6 @@ class StickyLogo(Svg):
|
|
|
234
234
|
Returns:
|
|
235
235
|
The simple Reflex logo SVG.
|
|
236
236
|
"""
|
|
237
|
-
...
|
|
238
237
|
|
|
239
238
|
def add_style(self): ...
|
|
240
239
|
|
|
@@ -587,7 +586,6 @@ class StickyLabel(Text):
|
|
|
587
586
|
Returns:
|
|
588
587
|
The sticky label.
|
|
589
588
|
"""
|
|
590
|
-
...
|
|
591
589
|
|
|
592
590
|
def add_style(self): ...
|
|
593
591
|
|
|
@@ -843,7 +841,6 @@ class StickyBadge(A):
|
|
|
843
841
|
Returns:
|
|
844
842
|
The sticky badge.
|
|
845
843
|
"""
|
|
846
|
-
...
|
|
847
844
|
|
|
848
845
|
def add_style(self): ...
|
|
849
846
|
|
|
@@ -1100,6 +1097,5 @@ class StickyNamespace(ComponentNamespace):
|
|
|
1100
1097
|
Returns:
|
|
1101
1098
|
The sticky badge.
|
|
1102
1099
|
"""
|
|
1103
|
-
...
|
|
1104
1100
|
|
|
1105
1101
|
sticky = StickyNamespace()
|
|
@@ -89,7 +89,6 @@ class UploadFilesProvider(Component):
|
|
|
89
89
|
Returns:
|
|
90
90
|
The component.
|
|
91
91
|
"""
|
|
92
|
-
...
|
|
93
92
|
|
|
94
93
|
class GhostUpload(Fragment):
|
|
95
94
|
@overload
|
|
@@ -143,7 +142,6 @@ class GhostUpload(Fragment):
|
|
|
143
142
|
Returns:
|
|
144
143
|
The component.
|
|
145
144
|
"""
|
|
146
|
-
...
|
|
147
145
|
|
|
148
146
|
class Upload(MemoizationLeaf):
|
|
149
147
|
is_used: ClassVar[bool] = False
|
|
@@ -219,7 +217,6 @@ class Upload(MemoizationLeaf):
|
|
|
219
217
|
Returns:
|
|
220
218
|
The upload component.
|
|
221
219
|
"""
|
|
222
|
-
...
|
|
223
220
|
|
|
224
221
|
class StyledUpload(Upload):
|
|
225
222
|
@overload
|
|
@@ -293,7 +290,6 @@ class StyledUpload(Upload):
|
|
|
293
290
|
Returns:
|
|
294
291
|
The styled upload component.
|
|
295
292
|
"""
|
|
296
|
-
...
|
|
297
293
|
|
|
298
294
|
class UploadNamespace(ComponentNamespace):
|
|
299
295
|
root = Upload.create
|
|
@@ -367,6 +363,5 @@ class UploadNamespace(ComponentNamespace):
|
|
|
367
363
|
Returns:
|
|
368
364
|
The styled upload component.
|
|
369
365
|
"""
|
|
370
|
-
...
|
|
371
366
|
|
|
372
367
|
upload = UploadNamespace()
|
|
@@ -482,8 +482,7 @@ class CodeBlock(Component, MarkdownComponentMap):
|
|
|
482
482
|
|
|
483
483
|
if copy_button:
|
|
484
484
|
return Box.create(code_block, copy_button, position="relative")
|
|
485
|
-
|
|
486
|
-
return code_block
|
|
485
|
+
return code_block
|
|
487
486
|
|
|
488
487
|
def add_style(self):
|
|
489
488
|
"""Add style to the component."""
|
|
@@ -984,7 +984,6 @@ class CodeBlock(Component, MarkdownComponentMap):
|
|
|
984
984
|
Returns:
|
|
985
985
|
The text component.
|
|
986
986
|
"""
|
|
987
|
-
...
|
|
988
987
|
|
|
989
988
|
def add_style(self): ...
|
|
990
989
|
@classmethod
|
|
@@ -1625,6 +1624,5 @@ class CodeblockNamespace(ComponentNamespace):
|
|
|
1625
1624
|
Returns:
|
|
1626
1625
|
The text component.
|
|
1627
1626
|
"""
|
|
1628
|
-
...
|
|
1629
1627
|
|
|
1630
1628
|
code_block = CodeblockNamespace()
|
|
@@ -383,9 +383,8 @@ class DataEditor(NoSSRComponent):
|
|
|
383
383
|
# If rows is not provided, determine from data.
|
|
384
384
|
if rows is None:
|
|
385
385
|
if isinstance(data, Var) and not isinstance(data, ArrayVar):
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
)
|
|
386
|
+
msg = "DataEditor data must be an ArrayVar if rows is not provided."
|
|
387
|
+
raise ValueError(msg)
|
|
389
388
|
|
|
390
389
|
props["rows"] = data.length() if isinstance(data, ArrayVar) else len(data)
|
|
391
390
|
|
|
@@ -393,13 +392,11 @@ class DataEditor(NoSSRComponent):
|
|
|
393
392
|
if types.is_dataframe(type(data)) or (
|
|
394
393
|
isinstance(data, Var) and types.is_dataframe(data._var_type)
|
|
395
394
|
):
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
format.format_data_editor_column(col) for col in columns
|
|
402
|
-
]
|
|
395
|
+
msg = "Cannot pass in both a pandas dataframe and columns to the data_editor component."
|
|
396
|
+
raise ValueError(msg)
|
|
397
|
+
props["columns"] = [
|
|
398
|
+
format.format_data_editor_column(col) for col in columns
|
|
399
|
+
]
|
|
403
400
|
|
|
404
401
|
if "theme" in props:
|
|
405
402
|
theme = props.get("theme")
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
import reflex as rx
|
|
4
4
|
|
|
5
|
+
SVG_COLOR = rx.color_mode_cond("#110F1F", "white")
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
**props,
|
|
9
|
-
):
|
|
7
|
+
|
|
8
|
+
def svg_logo(color: str | rx.Var[str] = SVG_COLOR, **props):
|
|
10
9
|
"""A Reflex logo SVG.
|
|
11
10
|
|
|
12
11
|
Args:
|
|
@@ -636,9 +636,8 @@ class ShikiCodeBlock(Component, MarkdownComponentMap):
|
|
|
636
636
|
"""
|
|
637
637
|
imports = defaultdict(list)
|
|
638
638
|
if not isinstance(self.transformers, LiteralVar):
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
)
|
|
639
|
+
msg = f"transformers should be a LiteralVar type. Got {type(self.transformers)} instead."
|
|
640
|
+
raise ValueError(msg)
|
|
642
641
|
for transformer in self.transformers._var_value:
|
|
643
642
|
if isinstance(transformer, ShikiBaseTransformers):
|
|
644
643
|
imports[transformer.library].extend(
|
|
@@ -663,9 +662,8 @@ class ShikiCodeBlock(Component, MarkdownComponentMap):
|
|
|
663
662
|
ValueError: If a supplied function name is not valid str.
|
|
664
663
|
"""
|
|
665
664
|
if any(not isinstance(fn_name, str) for fn_name in fns):
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
)
|
|
665
|
+
msg = f"the function names should be str names of functions in the specified transformer: {library!r}"
|
|
666
|
+
raise ValueError(msg)
|
|
669
667
|
return ShikiBaseTransformers(
|
|
670
668
|
library=library,
|
|
671
669
|
fns=[FunctionStringVar.create(fn) for fn in fns], # pyright: ignore [reportCallIssue]
|
|
@@ -811,8 +809,7 @@ class ShikiHighLevelCodeBlock(ShikiCodeBlock):
|
|
|
811
809
|
return ShikiCodeBlock.create(
|
|
812
810
|
children[0], copy_button, position="relative", **props
|
|
813
811
|
)
|
|
814
|
-
|
|
815
|
-
return ShikiCodeBlock.create(children[0], **props)
|
|
812
|
+
return ShikiCodeBlock.create(children[0], **props)
|
|
816
813
|
|
|
817
814
|
@staticmethod
|
|
818
815
|
def _map_themes(theme: str) -> str:
|
|
@@ -829,9 +826,8 @@ class ShikiHighLevelCodeBlock(ShikiCodeBlock):
|
|
|
829
826
|
@staticmethod
|
|
830
827
|
def _strip_transformer_triggers(code: str | StringVar) -> StringVar | str:
|
|
831
828
|
if not isinstance(code, (StringVar, str)):
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
)
|
|
829
|
+
msg = f"code should be string literal or a StringVar type. Got {type(code)} instead."
|
|
830
|
+
raise VarTypeError(msg)
|
|
835
831
|
regex_pattern = r"[\/#]+ *\[!code.*?\]"
|
|
836
832
|
|
|
837
833
|
if isinstance(code, Var):
|
|
@@ -840,6 +836,7 @@ class ShikiHighLevelCodeBlock(ShikiCodeBlock):
|
|
|
840
836
|
)
|
|
841
837
|
if isinstance(code, str):
|
|
842
838
|
return re.sub(regex_pattern, "", code)
|
|
839
|
+
return None
|
|
843
840
|
|
|
844
841
|
|
|
845
842
|
class TransformerNamespace(ComponentNamespace):
|
|
@@ -962,7 +962,6 @@ class ShikiCodeBlock(Component, MarkdownComponentMap):
|
|
|
962
962
|
Returns:
|
|
963
963
|
The code block component.
|
|
964
964
|
"""
|
|
965
|
-
...
|
|
966
965
|
|
|
967
966
|
def add_imports(self) -> dict[str, list[str]]: ...
|
|
968
967
|
@classmethod
|
|
@@ -1585,7 +1584,6 @@ class ShikiHighLevelCodeBlock(ShikiCodeBlock):
|
|
|
1585
1584
|
Returns:
|
|
1586
1585
|
The code block component.
|
|
1587
1586
|
"""
|
|
1588
|
-
...
|
|
1589
1587
|
|
|
1590
1588
|
class TransformerNamespace(ComponentNamespace):
|
|
1591
1589
|
shikijs = ShikiJsTransformer
|
|
@@ -2207,6 +2205,5 @@ class CodeblockNamespace(ComponentNamespace):
|
|
|
2207
2205
|
Returns:
|
|
2208
2206
|
The code block component.
|
|
2209
2207
|
"""
|
|
2210
|
-
...
|
|
2211
2208
|
|
|
2212
2209
|
code_block = CodeblockNamespace()
|
reflex/components/dynamic.py
CHANGED
|
@@ -50,9 +50,8 @@ def bundle_library(component: Union["Component", str]):
|
|
|
50
50
|
bundled_libraries.add(component)
|
|
51
51
|
return
|
|
52
52
|
if component.library is None:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
)
|
|
53
|
+
msg = "Component must have a library to bundle."
|
|
54
|
+
raise DynamicComponentMissingLibraryError(msg)
|
|
56
55
|
bundled_libraries.add(format_library_name(component.library))
|
|
57
56
|
|
|
58
57
|
|
|
@@ -94,6 +94,7 @@ from .elements.media import Circle as Circle
|
|
|
94
94
|
from .elements.media import Defs as Defs
|
|
95
95
|
from .elements.media import Ellipse as Ellipse
|
|
96
96
|
from .elements.media import Embed as Embed
|
|
97
|
+
from .elements.media import G as G
|
|
97
98
|
from .elements.media import Iframe as Iframe
|
|
98
99
|
from .elements.media import Img as Img
|
|
99
100
|
from .elements.media import Line as Line
|
|
@@ -118,6 +119,7 @@ from .elements.media import circle as circle
|
|
|
118
119
|
from .elements.media import defs as defs
|
|
119
120
|
from .elements.media import ellipse as ellipse
|
|
120
121
|
from .elements.media import embed as embed
|
|
122
|
+
from .elements.media import g as g
|
|
121
123
|
from .elements.media import iframe as iframe
|
|
122
124
|
from .elements.media import image as image
|
|
123
125
|
from .elements.media import img as img
|
reflex/components/el/element.pyi
CHANGED
|
@@ -93,6 +93,7 @@ from .media import Circle as Circle
|
|
|
93
93
|
from .media import Defs as Defs
|
|
94
94
|
from .media import Ellipse as Ellipse
|
|
95
95
|
from .media import Embed as Embed
|
|
96
|
+
from .media import G as G
|
|
96
97
|
from .media import Iframe as Iframe
|
|
97
98
|
from .media import Img as Img
|
|
98
99
|
from .media import Line as Line
|
|
@@ -117,6 +118,7 @@ from .media import circle as circle
|
|
|
117
118
|
from .media import defs as defs
|
|
118
119
|
from .media import ellipse as ellipse
|
|
119
120
|
from .media import embed as embed
|
|
121
|
+
from .media import g as g
|
|
120
122
|
from .media import iframe as iframe
|
|
121
123
|
from .media import image as image
|
|
122
124
|
from .media import img as img
|
|
@@ -312,6 +314,7 @@ _MAPPING = {
|
|
|
312
314
|
"text",
|
|
313
315
|
"line",
|
|
314
316
|
"circle",
|
|
317
|
+
"g",
|
|
315
318
|
"ellipse",
|
|
316
319
|
"rect",
|
|
317
320
|
"polygon",
|