reflex 0.7.11__py3-none-any.whl → 0.7.12__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/app.py +8 -4
- reflex/components/base/app_wrap.pyi +1 -0
- reflex/components/base/body.pyi +2 -0
- reflex/components/base/document.pyi +10 -0
- reflex/components/base/error_boundary.pyi +2 -0
- reflex/components/base/fragment.pyi +2 -0
- reflex/components/base/head.pyi +4 -0
- reflex/components/base/link.pyi +4 -0
- reflex/components/base/meta.pyi +8 -0
- reflex/components/base/script.pyi +2 -0
- reflex/components/base/strict_mode.pyi +2 -0
- reflex/components/component.py +39 -63
- reflex/components/core/auto_scroll.pyi +2 -0
- reflex/components/core/banner.pyi +10 -0
- reflex/components/core/client_side_routing.pyi +4 -0
- reflex/components/core/clipboard.pyi +2 -0
- reflex/components/core/debounce.pyi +1 -0
- reflex/components/core/html.pyi +2 -0
- reflex/components/core/sticky.pyi +4 -0
- reflex/components/core/upload.pyi +10 -0
- reflex/components/datadisplay/code.pyi +4 -0
- reflex/components/datadisplay/dataeditor.py +3 -3
- reflex/components/datadisplay/dataeditor.pyi +2 -0
- reflex/components/datadisplay/shiki_code_block.pyi +6 -0
- reflex/components/el/element.pyi +2 -0
- reflex/components/el/elements/base.pyi +2 -0
- reflex/components/el/elements/forms.pyi +34 -0
- reflex/components/el/elements/inline.pyi +56 -0
- reflex/components/el/elements/media.pyi +50 -0
- reflex/components/el/elements/metadata.pyi +12 -0
- reflex/components/el/elements/other.pyi +14 -0
- reflex/components/el/elements/scripts.pyi +6 -0
- reflex/components/el/elements/sectioning.pyi +30 -0
- reflex/components/el/elements/tables.pyi +20 -0
- reflex/components/el/elements/typography.pyi +30 -0
- reflex/components/gridjs/datatable.pyi +4 -0
- reflex/components/lucide/icon.py +3 -1
- reflex/components/lucide/icon.pyi +8 -0
- reflex/components/markdown/markdown.pyi +2 -0
- reflex/components/moment/moment.pyi +2 -0
- reflex/components/next/base.pyi +2 -0
- reflex/components/next/image.pyi +2 -0
- reflex/components/next/link.pyi +2 -0
- reflex/components/next/video.pyi +2 -0
- reflex/components/plotly/plotly.pyi +18 -0
- reflex/components/radix/primitives/accordion.py +1 -1
- reflex/components/radix/primitives/accordion.pyi +14 -0
- reflex/components/radix/primitives/base.py +0 -2
- reflex/components/radix/primitives/base.pyi +4 -0
- reflex/components/radix/primitives/drawer.py +1 -1
- reflex/components/radix/primitives/drawer.pyi +22 -0
- reflex/components/radix/primitives/form.py +1 -1
- reflex/components/radix/primitives/form.pyi +20 -0
- reflex/components/radix/primitives/progress.py +1 -1
- reflex/components/radix/primitives/progress.pyi +10 -0
- reflex/components/radix/primitives/slider.py +1 -1
- reflex/components/radix/primitives/slider.pyi +10 -0
- reflex/components/radix/themes/base.py +1 -1
- reflex/components/radix/themes/base.pyi +15 -0
- reflex/components/radix/themes/color_mode.pyi +5 -0
- reflex/components/radix/themes/components/alert_dialog.pyi +11 -0
- reflex/components/radix/themes/components/aspect_ratio.pyi +2 -0
- reflex/components/radix/themes/components/avatar.pyi +2 -0
- reflex/components/radix/themes/components/badge.pyi +2 -0
- reflex/components/radix/themes/components/button.pyi +2 -0
- reflex/components/radix/themes/components/callout.pyi +10 -0
- reflex/components/radix/themes/components/card.pyi +2 -0
- reflex/components/radix/themes/components/checkbox.pyi +6 -0
- reflex/components/radix/themes/components/checkbox_cards.pyi +4 -0
- reflex/components/radix/themes/components/checkbox_group.pyi +4 -0
- reflex/components/radix/themes/components/context_menu.pyi +26 -0
- reflex/components/radix/themes/components/data_list.pyi +8 -0
- reflex/components/radix/themes/components/dialog.pyi +12 -0
- reflex/components/radix/themes/components/dropdown_menu.pyi +14 -0
- reflex/components/radix/themes/components/hover_card.pyi +7 -0
- reflex/components/radix/themes/components/icon_button.pyi +2 -0
- reflex/components/radix/themes/components/inset.pyi +2 -0
- reflex/components/radix/themes/components/popover.pyi +6 -0
- reflex/components/radix/themes/components/progress.pyi +2 -0
- reflex/components/radix/themes/components/radio.pyi +2 -0
- reflex/components/radix/themes/components/radio_cards.pyi +4 -0
- reflex/components/radix/themes/components/radio_group.pyi +8 -0
- reflex/components/radix/themes/components/scroll_area.pyi +2 -0
- reflex/components/radix/themes/components/segmented_control.pyi +4 -0
- reflex/components/radix/themes/components/select.pyi +18 -0
- reflex/components/radix/themes/components/separator.pyi +2 -0
- reflex/components/radix/themes/components/skeleton.pyi +2 -0
- reflex/components/radix/themes/components/slider.pyi +2 -0
- reflex/components/radix/themes/components/spinner.pyi +2 -0
- reflex/components/radix/themes/components/switch.pyi +2 -0
- reflex/components/radix/themes/components/table.pyi +14 -0
- reflex/components/radix/themes/components/tabs.pyi +10 -0
- reflex/components/radix/themes/components/text_area.pyi +2 -0
- reflex/components/radix/themes/components/text_field.pyi +6 -0
- reflex/components/radix/themes/components/tooltip.pyi +2 -0
- reflex/components/radix/themes/layout/base.pyi +2 -0
- reflex/components/radix/themes/layout/box.pyi +2 -0
- reflex/components/radix/themes/layout/center.pyi +2 -0
- reflex/components/radix/themes/layout/container.pyi +1 -0
- reflex/components/radix/themes/layout/flex.pyi +2 -0
- reflex/components/radix/themes/layout/grid.pyi +2 -0
- reflex/components/radix/themes/layout/list.pyi +10 -0
- reflex/components/radix/themes/layout/section.pyi +2 -0
- reflex/components/radix/themes/layout/spacer.pyi +2 -0
- reflex/components/radix/themes/layout/stack.py +5 -4
- reflex/components/radix/themes/layout/stack.pyi +70 -16
- reflex/components/radix/themes/typography/blockquote.pyi +2 -0
- reflex/components/radix/themes/typography/code.pyi +2 -0
- reflex/components/radix/themes/typography/heading.pyi +2 -0
- reflex/components/radix/themes/typography/link.pyi +2 -0
- reflex/components/radix/themes/typography/text.pyi +14 -0
- reflex/components/react_player/audio.pyi +2 -0
- reflex/components/react_player/react_player.pyi +2 -0
- reflex/components/react_player/video.pyi +2 -0
- reflex/components/recharts/cartesian.pyi +38 -0
- reflex/components/recharts/charts.pyi +24 -0
- reflex/components/recharts/general.pyi +12 -0
- reflex/components/recharts/polar.pyi +12 -0
- reflex/components/recharts/recharts.pyi +4 -0
- reflex/components/sonner/toast.pyi +2 -0
- reflex/components/suneditor/editor.pyi +2 -0
- reflex/config.py +3 -0
- reflex/constants/compiler.py +12 -6
- reflex/constants/installer.py +1 -1
- reflex/event.py +21 -0
- reflex/experimental/layout.pyi +5 -0
- reflex/reflex.py +24 -0
- reflex/testing.py +2 -1
- reflex/utils/exec.py +5 -0
- reflex/utils/format.py +4 -11
- reflex/utils/net.py +35 -2
- reflex/utils/prerequisites.py +10 -4
- reflex/utils/pyi_generator.py +7 -1
- reflex/utils/types.py +7 -5
- reflex/vars/base.py +7 -8
- reflex/vars/object.py +9 -2
- {reflex-0.7.11.dist-info → reflex-0.7.12.dist-info}/METADATA +4 -4
- {reflex-0.7.11.dist-info → reflex-0.7.12.dist-info}/RECORD +142 -141
- scripts/hatch_build.py +50 -0
- {reflex-0.7.11.dist-info → reflex-0.7.12.dist-info}/WHEEL +0 -0
- {reflex-0.7.11.dist-info → reflex-0.7.12.dist-info}/entry_points.txt +0 -0
- {reflex-0.7.11.dist-info → reflex-0.7.12.dist-info}/licenses/LICENSE +0 -0
reflex/app.py
CHANGED
|
@@ -1157,11 +1157,12 @@ class App(MiddlewareMixin, LifespanMixin):
|
|
|
1157
1157
|
for substate in state.class_subclasses:
|
|
1158
1158
|
self._validate_var_dependencies(substate)
|
|
1159
1159
|
|
|
1160
|
-
def _compile(self, export: bool = False):
|
|
1160
|
+
def _compile(self, export: bool = False, dry_run: bool = False):
|
|
1161
1161
|
"""Compile the app and output it to the pages folder.
|
|
1162
1162
|
|
|
1163
1163
|
Args:
|
|
1164
1164
|
export: Whether to compile the app for export.
|
|
1165
|
+
dry_run: Whether to compile the app without saving it.
|
|
1165
1166
|
|
|
1166
1167
|
Raises:
|
|
1167
1168
|
ReflexRuntimeError: When any page uses state, but no rx.State subclass is defined.
|
|
@@ -1175,7 +1176,7 @@ class App(MiddlewareMixin, LifespanMixin):
|
|
|
1175
1176
|
|
|
1176
1177
|
should_compile = self._should_compile()
|
|
1177
1178
|
backend_dir = prerequisites.get_backend_dir()
|
|
1178
|
-
if not should_compile and backend_dir.exists():
|
|
1179
|
+
if not dry_run and not should_compile and backend_dir.exists():
|
|
1179
1180
|
stateful_pages_marker = backend_dir / constants.Dirs.STATEFUL_PAGES
|
|
1180
1181
|
if stateful_pages_marker.exists():
|
|
1181
1182
|
with stateful_pages_marker.open("r") as f:
|
|
@@ -1210,7 +1211,7 @@ class App(MiddlewareMixin, LifespanMixin):
|
|
|
1210
1211
|
if config.react_strict_mode:
|
|
1211
1212
|
app_wrappers[(200, "StrictMode")] = StrictMode.create()
|
|
1212
1213
|
|
|
1213
|
-
if not should_compile:
|
|
1214
|
+
if not should_compile and not dry_run:
|
|
1214
1215
|
with console.timing("Evaluate Pages (Backend)"):
|
|
1215
1216
|
for route in self._unevaluated_pages:
|
|
1216
1217
|
console.debug(f"Evaluating page: {route}")
|
|
@@ -1363,7 +1364,7 @@ class App(MiddlewareMixin, LifespanMixin):
|
|
|
1363
1364
|
|
|
1364
1365
|
# Copy the assets.
|
|
1365
1366
|
assets_src = Path.cwd() / constants.Dirs.APP_ASSETS
|
|
1366
|
-
if assets_src.is_dir():
|
|
1367
|
+
if assets_src.is_dir() and not dry_run:
|
|
1367
1368
|
with console.timing("Copy assets"):
|
|
1368
1369
|
path_ops.update_directory_tree(
|
|
1369
1370
|
src=assets_src,
|
|
@@ -1449,6 +1450,9 @@ class App(MiddlewareMixin, LifespanMixin):
|
|
|
1449
1450
|
progress.advance(task)
|
|
1450
1451
|
progress.stop()
|
|
1451
1452
|
|
|
1453
|
+
if dry_run:
|
|
1454
|
+
return
|
|
1455
|
+
|
|
1452
1456
|
# Install frontend packages.
|
|
1453
1457
|
with console.timing("Install Frontend Packages"):
|
|
1454
1458
|
self._get_frontend_packages(all_imports)
|
reflex/components/base/body.pyi
CHANGED
|
@@ -202,6 +202,7 @@ class Body(elements.Body):
|
|
|
202
202
|
| None = None,
|
|
203
203
|
key: Any | None = None,
|
|
204
204
|
id: Any | None = None,
|
|
205
|
+
ref: Var | None = None,
|
|
205
206
|
class_name: Any | None = None,
|
|
206
207
|
autofocus: bool | None = None,
|
|
207
208
|
custom_attrs: dict[str, Var | Any] | None = None,
|
|
@@ -245,6 +246,7 @@ class Body(elements.Body):
|
|
|
245
246
|
style: The style of the component.
|
|
246
247
|
key: A unique key for the component.
|
|
247
248
|
id: The id for the component.
|
|
249
|
+
ref: The Var to pass as the ref to the component.
|
|
248
250
|
class_name: The class name for the component.
|
|
249
251
|
autofocus: Whether the component should take the focus once the page is loaded
|
|
250
252
|
custom_attrs: custom attribute
|
|
@@ -24,6 +24,7 @@ class NextDocumentLib(Component):
|
|
|
24
24
|
| None = None,
|
|
25
25
|
key: Any | None = None,
|
|
26
26
|
id: Any | None = None,
|
|
27
|
+
ref: Var | None = None,
|
|
27
28
|
class_name: Any | None = None,
|
|
28
29
|
autofocus: bool | None = None,
|
|
29
30
|
custom_attrs: dict[str, Var | Any] | None = None,
|
|
@@ -51,6 +52,7 @@ class NextDocumentLib(Component):
|
|
|
51
52
|
style: The style of the component.
|
|
52
53
|
key: A unique key for the component.
|
|
53
54
|
id: The id for the component.
|
|
55
|
+
ref: The Var to pass as the ref to the component.
|
|
54
56
|
class_name: The class name for the component.
|
|
55
57
|
autofocus: Whether the component should take the focus once the page is loaded
|
|
56
58
|
custom_attrs: custom attribute
|
|
@@ -75,6 +77,7 @@ class Html(NextDocumentLib):
|
|
|
75
77
|
| None = None,
|
|
76
78
|
key: Any | None = None,
|
|
77
79
|
id: Any | None = None,
|
|
80
|
+
ref: Var | None = None,
|
|
78
81
|
class_name: Any | None = None,
|
|
79
82
|
autofocus: bool | None = None,
|
|
80
83
|
custom_attrs: dict[str, Var | Any] | None = None,
|
|
@@ -102,6 +105,7 @@ class Html(NextDocumentLib):
|
|
|
102
105
|
style: The style of the component.
|
|
103
106
|
key: A unique key for the component.
|
|
104
107
|
id: The id for the component.
|
|
108
|
+
ref: The Var to pass as the ref to the component.
|
|
105
109
|
class_name: The class name for the component.
|
|
106
110
|
autofocus: Whether the component should take the focus once the page is loaded
|
|
107
111
|
custom_attrs: custom attribute
|
|
@@ -125,6 +129,7 @@ class DocumentHead(NextDocumentLib):
|
|
|
125
129
|
| None = None,
|
|
126
130
|
key: Any | None = None,
|
|
127
131
|
id: Any | None = None,
|
|
132
|
+
ref: Var | None = None,
|
|
128
133
|
class_name: Any | None = None,
|
|
129
134
|
autofocus: bool | None = None,
|
|
130
135
|
custom_attrs: dict[str, Var | Any] | None = None,
|
|
@@ -152,6 +157,7 @@ class DocumentHead(NextDocumentLib):
|
|
|
152
157
|
style: The style of the component.
|
|
153
158
|
key: A unique key for the component.
|
|
154
159
|
id: The id for the component.
|
|
160
|
+
ref: The Var to pass as the ref to the component.
|
|
155
161
|
class_name: The class name for the component.
|
|
156
162
|
autofocus: Whether the component should take the focus once the page is loaded
|
|
157
163
|
custom_attrs: custom attribute
|
|
@@ -175,6 +181,7 @@ class Main(NextDocumentLib):
|
|
|
175
181
|
| None = None,
|
|
176
182
|
key: Any | None = None,
|
|
177
183
|
id: Any | None = None,
|
|
184
|
+
ref: Var | None = None,
|
|
178
185
|
class_name: Any | None = None,
|
|
179
186
|
autofocus: bool | None = None,
|
|
180
187
|
custom_attrs: dict[str, Var | Any] | None = None,
|
|
@@ -202,6 +209,7 @@ class Main(NextDocumentLib):
|
|
|
202
209
|
style: The style of the component.
|
|
203
210
|
key: A unique key for the component.
|
|
204
211
|
id: The id for the component.
|
|
212
|
+
ref: The Var to pass as the ref to the component.
|
|
205
213
|
class_name: The class name for the component.
|
|
206
214
|
autofocus: Whether the component should take the focus once the page is loaded
|
|
207
215
|
custom_attrs: custom attribute
|
|
@@ -225,6 +233,7 @@ class NextScript(NextDocumentLib):
|
|
|
225
233
|
| None = None,
|
|
226
234
|
key: Any | None = None,
|
|
227
235
|
id: Any | None = None,
|
|
236
|
+
ref: Var | None = None,
|
|
228
237
|
class_name: Any | None = None,
|
|
229
238
|
autofocus: bool | None = None,
|
|
230
239
|
custom_attrs: dict[str, Var | Any] | None = None,
|
|
@@ -252,6 +261,7 @@ class NextScript(NextDocumentLib):
|
|
|
252
261
|
style: The style of the component.
|
|
253
262
|
key: A unique key for the component.
|
|
254
263
|
id: The id for the component.
|
|
264
|
+
ref: The Var to pass as the ref to the component.
|
|
255
265
|
class_name: The class name for the component.
|
|
256
266
|
autofocus: Whether the component should take the focus once the page is loaded
|
|
257
267
|
custom_attrs: custom attribute
|
|
@@ -30,6 +30,7 @@ class ErrorBoundary(Component):
|
|
|
30
30
|
| None = None,
|
|
31
31
|
key: Any | None = None,
|
|
32
32
|
id: Any | None = None,
|
|
33
|
+
ref: Var | None = None,
|
|
33
34
|
class_name: Any | None = None,
|
|
34
35
|
autofocus: bool | None = None,
|
|
35
36
|
custom_attrs: dict[str, Var | Any] | None = None,
|
|
@@ -60,6 +61,7 @@ class ErrorBoundary(Component):
|
|
|
60
61
|
style: The style of the component.
|
|
61
62
|
key: A unique key for the component.
|
|
62
63
|
id: The id for the component.
|
|
64
|
+
ref: The Var to pass as the ref to the component.
|
|
63
65
|
class_name: The class name for the component.
|
|
64
66
|
autofocus: Whether the component should take the focus once the page is loaded
|
|
65
67
|
custom_attrs: custom attribute
|
|
@@ -24,6 +24,7 @@ class Fragment(Component):
|
|
|
24
24
|
| None = None,
|
|
25
25
|
key: Any | None = None,
|
|
26
26
|
id: Any | None = None,
|
|
27
|
+
ref: Var | None = None,
|
|
27
28
|
class_name: Any | None = None,
|
|
28
29
|
autofocus: bool | None = None,
|
|
29
30
|
custom_attrs: dict[str, Var | Any] | None = None,
|
|
@@ -51,6 +52,7 @@ class Fragment(Component):
|
|
|
51
52
|
style: The style of the component.
|
|
52
53
|
key: A unique key for the component.
|
|
53
54
|
id: The id for the component.
|
|
55
|
+
ref: The Var to pass as the ref to the component.
|
|
54
56
|
class_name: The class name for the component.
|
|
55
57
|
autofocus: Whether the component should take the focus once the page is loaded
|
|
56
58
|
custom_attrs: custom attribute
|
reflex/components/base/head.pyi
CHANGED
|
@@ -24,6 +24,7 @@ class NextHeadLib(Component):
|
|
|
24
24
|
| None = None,
|
|
25
25
|
key: Any | None = None,
|
|
26
26
|
id: Any | None = None,
|
|
27
|
+
ref: Var | None = None,
|
|
27
28
|
class_name: Any | None = None,
|
|
28
29
|
autofocus: bool | None = None,
|
|
29
30
|
custom_attrs: dict[str, Var | Any] | None = None,
|
|
@@ -51,6 +52,7 @@ class NextHeadLib(Component):
|
|
|
51
52
|
style: The style of the component.
|
|
52
53
|
key: A unique key for the component.
|
|
53
54
|
id: The id for the component.
|
|
55
|
+
ref: The Var to pass as the ref to the component.
|
|
54
56
|
class_name: The class name for the component.
|
|
55
57
|
autofocus: Whether the component should take the focus once the page is loaded
|
|
56
58
|
custom_attrs: custom attribute
|
|
@@ -74,6 +76,7 @@ class Head(NextHeadLib, MemoizationLeaf):
|
|
|
74
76
|
| None = None,
|
|
75
77
|
key: Any | None = None,
|
|
76
78
|
id: Any | None = None,
|
|
79
|
+
ref: Var | None = None,
|
|
77
80
|
class_name: Any | None = None,
|
|
78
81
|
autofocus: bool | None = None,
|
|
79
82
|
custom_attrs: dict[str, Var | Any] | None = None,
|
|
@@ -101,6 +104,7 @@ class Head(NextHeadLib, MemoizationLeaf):
|
|
|
101
104
|
style: The style of the component.
|
|
102
105
|
key: A unique key for the component.
|
|
103
106
|
id: The id for the component.
|
|
107
|
+
ref: The Var to pass as the ref to the component.
|
|
104
108
|
class_name: The class name for the component.
|
|
105
109
|
autofocus: Whether the component should take the focus once the page is loaded
|
|
106
110
|
custom_attrs: custom attribute
|
reflex/components/base/link.pyi
CHANGED
|
@@ -204,6 +204,7 @@ class RawLink(BaseHTML):
|
|
|
204
204
|
| None = None,
|
|
205
205
|
key: Any | None = None,
|
|
206
206
|
id: Any | None = None,
|
|
207
|
+
ref: Var | None = None,
|
|
207
208
|
class_name: Any | None = None,
|
|
208
209
|
autofocus: bool | None = None,
|
|
209
210
|
custom_attrs: dict[str, Var | Any] | None = None,
|
|
@@ -249,6 +250,7 @@ class RawLink(BaseHTML):
|
|
|
249
250
|
style: The style of the component.
|
|
250
251
|
key: A unique key for the component.
|
|
251
252
|
id: The id for the component.
|
|
253
|
+
ref: The Var to pass as the ref to the component.
|
|
252
254
|
class_name: The class name for the component.
|
|
253
255
|
autofocus: Whether the component should take the focus once the page is loaded
|
|
254
256
|
custom_attrs: custom attribute
|
|
@@ -457,6 +459,7 @@ class ScriptTag(BaseHTML):
|
|
|
457
459
|
| None = None,
|
|
458
460
|
key: Any | None = None,
|
|
459
461
|
id: Any | None = None,
|
|
462
|
+
ref: Var | None = None,
|
|
460
463
|
class_name: Any | None = None,
|
|
461
464
|
autofocus: bool | None = None,
|
|
462
465
|
custom_attrs: dict[str, Var | Any] | None = None,
|
|
@@ -507,6 +510,7 @@ class ScriptTag(BaseHTML):
|
|
|
507
510
|
style: The style of the component.
|
|
508
511
|
key: A unique key for the component.
|
|
509
512
|
id: The id for the component.
|
|
513
|
+
ref: The Var to pass as the ref to the component.
|
|
510
514
|
class_name: The class name for the component.
|
|
511
515
|
autofocus: Whether the component should take the focus once the page is loaded
|
|
512
516
|
custom_attrs: custom attribute
|
reflex/components/base/meta.pyi
CHANGED
|
@@ -25,6 +25,7 @@ class Title(elements.Title):
|
|
|
25
25
|
| None = None,
|
|
26
26
|
key: Any | None = None,
|
|
27
27
|
id: Any | None = None,
|
|
28
|
+
ref: Var | None = None,
|
|
28
29
|
class_name: Any | None = None,
|
|
29
30
|
autofocus: bool | None = None,
|
|
30
31
|
custom_attrs: dict[str, Var | Any] | None = None,
|
|
@@ -52,6 +53,7 @@ class Title(elements.Title):
|
|
|
52
53
|
style: The style of the component.
|
|
53
54
|
key: A unique key for the component.
|
|
54
55
|
id: The id for the component.
|
|
56
|
+
ref: The Var to pass as the ref to the component.
|
|
55
57
|
class_name: The class name for the component.
|
|
56
58
|
autofocus: Whether the component should take the focus once the page is loaded
|
|
57
59
|
custom_attrs: custom attribute
|
|
@@ -258,6 +260,7 @@ class Meta(elements.Meta):
|
|
|
258
260
|
| None = None,
|
|
259
261
|
key: Any | None = None,
|
|
260
262
|
id: Any | None = None,
|
|
263
|
+
ref: Var | None = None,
|
|
261
264
|
class_name: Any | None = None,
|
|
262
265
|
autofocus: bool | None = None,
|
|
263
266
|
custom_attrs: dict[str, Var | Any] | None = None,
|
|
@@ -306,6 +309,7 @@ class Meta(elements.Meta):
|
|
|
306
309
|
style: The style of the component.
|
|
307
310
|
key: A unique key for the component.
|
|
308
311
|
id: The id for the component.
|
|
312
|
+
ref: The Var to pass as the ref to the component.
|
|
309
313
|
class_name: The class name for the component.
|
|
310
314
|
autofocus: Whether the component should take the focus once the page is loaded
|
|
311
315
|
custom_attrs: custom attribute
|
|
@@ -511,6 +515,7 @@ class Description(elements.Meta):
|
|
|
511
515
|
| None = None,
|
|
512
516
|
key: Any | None = None,
|
|
513
517
|
id: Any | None = None,
|
|
518
|
+
ref: Var | None = None,
|
|
514
519
|
class_name: Any | None = None,
|
|
515
520
|
autofocus: bool | None = None,
|
|
516
521
|
custom_attrs: dict[str, Var | Any] | None = None,
|
|
@@ -558,6 +563,7 @@ class Description(elements.Meta):
|
|
|
558
563
|
style: The style of the component.
|
|
559
564
|
key: A unique key for the component.
|
|
560
565
|
id: The id for the component.
|
|
566
|
+
ref: The Var to pass as the ref to the component.
|
|
561
567
|
class_name: The class name for the component.
|
|
562
568
|
autofocus: Whether the component should take the focus once the page is loaded
|
|
563
569
|
custom_attrs: custom attribute
|
|
@@ -764,6 +770,7 @@ class Image(elements.Meta):
|
|
|
764
770
|
| None = None,
|
|
765
771
|
key: Any | None = None,
|
|
766
772
|
id: Any | None = None,
|
|
773
|
+
ref: Var | None = None,
|
|
767
774
|
class_name: Any | None = None,
|
|
768
775
|
autofocus: bool | None = None,
|
|
769
776
|
custom_attrs: dict[str, Var | Any] | None = None,
|
|
@@ -812,6 +819,7 @@ class Image(elements.Meta):
|
|
|
812
819
|
style: The style of the component.
|
|
813
820
|
key: A unique key for the component.
|
|
814
821
|
id: The id for the component.
|
|
822
|
+
ref: The Var to pass as the ref to the component.
|
|
815
823
|
class_name: The class name for the component.
|
|
816
824
|
autofocus: Whether the component should take the focus once the page is loaded
|
|
817
825
|
custom_attrs: custom attribute
|
|
@@ -28,6 +28,7 @@ class Script(Component):
|
|
|
28
28
|
| None = None,
|
|
29
29
|
key: Any | None = None,
|
|
30
30
|
id: Any | None = None,
|
|
31
|
+
ref: Var | None = None,
|
|
31
32
|
class_name: Any | None = None,
|
|
32
33
|
autofocus: bool | None = None,
|
|
33
34
|
custom_attrs: dict[str, Var | Any] | None = None,
|
|
@@ -73,6 +74,7 @@ class Script(Component):
|
|
|
73
74
|
style: The style of the component.
|
|
74
75
|
key: A unique key for the component.
|
|
75
76
|
id: The id for the component.
|
|
77
|
+
ref: The Var to pass as the ref to the component.
|
|
76
78
|
class_name: The class name for the component.
|
|
77
79
|
autofocus: Whether the component should take the focus once the page is loaded
|
|
78
80
|
custom_attrs: custom attribute
|
|
@@ -24,6 +24,7 @@ class StrictMode(Component):
|
|
|
24
24
|
| None = None,
|
|
25
25
|
key: Any | None = None,
|
|
26
26
|
id: Any | None = None,
|
|
27
|
+
ref: Var | None = None,
|
|
27
28
|
class_name: Any | None = None,
|
|
28
29
|
autofocus: bool | None = None,
|
|
29
30
|
custom_attrs: dict[str, Var | Any] | None = None,
|
|
@@ -51,6 +52,7 @@ class StrictMode(Component):
|
|
|
51
52
|
style: The style of the component.
|
|
52
53
|
key: A unique key for the component.
|
|
53
54
|
id: The id for the component.
|
|
55
|
+
ref: The Var to pass as the ref to the component.
|
|
54
56
|
class_name: The class name for the component.
|
|
55
57
|
autofocus: Whether the component should take the focus once the page is loaded
|
|
56
58
|
custom_attrs: custom attribute
|
reflex/components/component.py
CHANGED
|
@@ -58,7 +58,7 @@ from reflex.vars.base import (
|
|
|
58
58
|
)
|
|
59
59
|
from reflex.vars.function import ArgsFunctionOperation, FunctionStringVar, FunctionVar
|
|
60
60
|
from reflex.vars.number import ternary_operation
|
|
61
|
-
from reflex.vars.object import
|
|
61
|
+
from reflex.vars.object import ObjectVar
|
|
62
62
|
from reflex.vars.sequence import LiteralArrayVar, LiteralStringVar, StringVar
|
|
63
63
|
|
|
64
64
|
|
|
@@ -280,6 +280,9 @@ class Component(BaseComponent, ABC):
|
|
|
280
280
|
# The id for the component.
|
|
281
281
|
id: Any = pydantic.v1.Field(default_factory=lambda: None)
|
|
282
282
|
|
|
283
|
+
# The Var to pass as the ref to the component.
|
|
284
|
+
ref: Var | None = pydantic.v1.Field(default_factory=lambda: None)
|
|
285
|
+
|
|
283
286
|
# The class name for the component.
|
|
284
287
|
class_name: Any = pydantic.v1.Field(default_factory=lambda: None)
|
|
285
288
|
|
|
@@ -497,36 +500,16 @@ class Component(BaseComponent, ABC):
|
|
|
497
500
|
else:
|
|
498
501
|
continue
|
|
499
502
|
|
|
500
|
-
def determine_key(value: Any):
|
|
501
|
-
# Try to create a var from the value
|
|
502
|
-
key = value if isinstance(value, Var) else LiteralVar.create(value)
|
|
503
|
-
|
|
504
|
-
# Check that the var type is not None.
|
|
505
|
-
if key is None:
|
|
506
|
-
raise TypeError
|
|
507
|
-
|
|
508
|
-
return key
|
|
509
|
-
|
|
510
503
|
# Check whether the key is a component prop.
|
|
511
504
|
if is_var:
|
|
512
505
|
try:
|
|
513
|
-
kwargs[key] =
|
|
506
|
+
kwargs[key] = LiteralVar.create(value)
|
|
514
507
|
|
|
508
|
+
# Get the passed type and the var type.
|
|
509
|
+
passed_type = kwargs[key]._var_type
|
|
515
510
|
expected_type = types.get_args(
|
|
516
511
|
types.get_field_type(type(self), key)
|
|
517
512
|
)[0]
|
|
518
|
-
|
|
519
|
-
# validate literal fields.
|
|
520
|
-
types.validate_literal(
|
|
521
|
-
key, value, expected_type, type(self).__name__
|
|
522
|
-
)
|
|
523
|
-
# Get the passed type and the var type.
|
|
524
|
-
passed_type = kwargs[key]._var_type
|
|
525
|
-
expected_type = (
|
|
526
|
-
type(expected_type.__args__[0])
|
|
527
|
-
if types.is_literal(expected_type)
|
|
528
|
-
else expected_type
|
|
529
|
-
)
|
|
530
513
|
except TypeError:
|
|
531
514
|
# If it is not a valid var, check the base types.
|
|
532
515
|
passed_type = type(value)
|
|
@@ -558,15 +541,19 @@ class Component(BaseComponent, ABC):
|
|
|
558
541
|
kwargs.pop(key, None)
|
|
559
542
|
|
|
560
543
|
# Place data_ and aria_ attributes into custom_attrs
|
|
561
|
-
special_attributes =
|
|
544
|
+
special_attributes = [
|
|
562
545
|
key
|
|
563
546
|
for key in kwargs
|
|
564
547
|
if key not in fields and SpecialAttributes.is_special(key)
|
|
565
|
-
|
|
548
|
+
]
|
|
566
549
|
if special_attributes:
|
|
567
550
|
custom_attrs = kwargs.setdefault("custom_attrs", {})
|
|
568
|
-
|
|
569
|
-
|
|
551
|
+
custom_attrs.update(
|
|
552
|
+
{
|
|
553
|
+
format.to_kebab_case(key): kwargs.pop(key)
|
|
554
|
+
for key in special_attributes
|
|
555
|
+
}
|
|
556
|
+
)
|
|
570
557
|
|
|
571
558
|
# Add style props to the component.
|
|
572
559
|
style = kwargs.get("style", {})
|
|
@@ -709,9 +696,10 @@ class Component(BaseComponent, ABC):
|
|
|
709
696
|
attr.removesuffix("_"): getattr(self, attr) for attr in self.get_props()
|
|
710
697
|
}
|
|
711
698
|
|
|
712
|
-
# Add ref to element if `id` is not None.
|
|
713
|
-
ref
|
|
714
|
-
|
|
699
|
+
# Add ref to element if `ref` is None and `id` is not None.
|
|
700
|
+
if self.ref is not None:
|
|
701
|
+
props["ref"] = self.ref
|
|
702
|
+
elif (ref := self.get_ref()) is not None:
|
|
715
703
|
props["ref"] = Var(_js_expr=ref)
|
|
716
704
|
else:
|
|
717
705
|
props = props.copy()
|
|
@@ -801,6 +789,18 @@ class Component(BaseComponent, ABC):
|
|
|
801
789
|
for component in _components_from(value)
|
|
802
790
|
]
|
|
803
791
|
|
|
792
|
+
@classmethod
|
|
793
|
+
def _validate_children(cls, children: tuple | list):
|
|
794
|
+
from reflex.utils.exceptions import ChildrenTypeError
|
|
795
|
+
|
|
796
|
+
for child in children:
|
|
797
|
+
if isinstance(child, (tuple, list)):
|
|
798
|
+
cls._validate_children(child)
|
|
799
|
+
|
|
800
|
+
# Make sure the child is a valid type.
|
|
801
|
+
if isinstance(child, dict) or not isinstance(child, ComponentChildTypes):
|
|
802
|
+
raise ChildrenTypeError(component=cls.__name__, child=child)
|
|
803
|
+
|
|
804
804
|
@classmethod
|
|
805
805
|
def create(cls: type[T], *children, **props) -> T:
|
|
806
806
|
"""Create the component.
|
|
@@ -815,24 +815,12 @@ class Component(BaseComponent, ABC):
|
|
|
815
815
|
# Import here to avoid circular imports.
|
|
816
816
|
from reflex.components.base.bare import Bare
|
|
817
817
|
from reflex.components.base.fragment import Fragment
|
|
818
|
-
from reflex.utils.exceptions import ChildrenTypeError
|
|
819
818
|
|
|
820
819
|
# Filter out None props
|
|
821
820
|
props = {key: value for key, value in props.items() if value is not None}
|
|
822
821
|
|
|
823
|
-
def validate_children(children: tuple | list):
|
|
824
|
-
for child in children:
|
|
825
|
-
if isinstance(child, (tuple, list)):
|
|
826
|
-
validate_children(child)
|
|
827
|
-
|
|
828
|
-
# Make sure the child is a valid type.
|
|
829
|
-
if isinstance(child, dict) or not isinstance(
|
|
830
|
-
child, ComponentChildTypes
|
|
831
|
-
):
|
|
832
|
-
raise ChildrenTypeError(component=cls.__name__, child=child)
|
|
833
|
-
|
|
834
822
|
# Validate all the children.
|
|
835
|
-
|
|
823
|
+
cls._validate_children(children)
|
|
836
824
|
|
|
837
825
|
children_normalized = [
|
|
838
826
|
(
|
|
@@ -2573,25 +2561,7 @@ def render_dict_to_var(tag: dict | Component | str, imported_names: set[str]) ->
|
|
|
2573
2561
|
else LiteralNoneVar.create(),
|
|
2574
2562
|
)
|
|
2575
2563
|
|
|
2576
|
-
props = {}
|
|
2577
|
-
|
|
2578
|
-
special_props = []
|
|
2579
|
-
|
|
2580
|
-
for prop_str in tag["props"]:
|
|
2581
|
-
if ":" not in prop_str:
|
|
2582
|
-
special_props.append(Var(prop_str).to(ObjectVar))
|
|
2583
|
-
continue
|
|
2584
|
-
prop = prop_str.index(":")
|
|
2585
|
-
key = prop_str[:prop]
|
|
2586
|
-
value = prop_str[prop + 1 :]
|
|
2587
|
-
props[key] = value
|
|
2588
|
-
|
|
2589
|
-
props = LiteralObjectVar.create(
|
|
2590
|
-
{LiteralStringVar.create(k): Var(v) for k, v in props.items()}
|
|
2591
|
-
)
|
|
2592
|
-
|
|
2593
|
-
for prop in special_props:
|
|
2594
|
-
props = props.merge(prop)
|
|
2564
|
+
props = Var("({" + ",".join(tag["props"]) + "})")
|
|
2595
2565
|
|
|
2596
2566
|
contents = tag["contents"] if tag["contents"] else None
|
|
2597
2567
|
|
|
@@ -2642,6 +2612,12 @@ class LiteralComponentVar(CachedVarOperation, LiteralVar, ComponentVar):
|
|
|
2642
2612
|
"""
|
|
2643
2613
|
return VarData.merge(
|
|
2644
2614
|
self._var_data,
|
|
2615
|
+
VarData(
|
|
2616
|
+
imports={
|
|
2617
|
+
"@emotion/react": ["jsx"],
|
|
2618
|
+
"react": ["Fragment"],
|
|
2619
|
+
},
|
|
2620
|
+
),
|
|
2645
2621
|
VarData(
|
|
2646
2622
|
imports=self._var_value._get_all_imports(),
|
|
2647
2623
|
),
|
|
@@ -203,6 +203,7 @@ class AutoScroll(Div):
|
|
|
203
203
|
| None = None,
|
|
204
204
|
key: Any | None = None,
|
|
205
205
|
id: Any | None = None,
|
|
206
|
+
ref: Var | None = None,
|
|
206
207
|
class_name: Any | None = None,
|
|
207
208
|
autofocus: bool | None = None,
|
|
208
209
|
custom_attrs: dict[str, Var | Any] | None = None,
|
|
@@ -246,6 +247,7 @@ class AutoScroll(Div):
|
|
|
246
247
|
style: The style of the component.
|
|
247
248
|
key: A unique key for the component.
|
|
248
249
|
id: The id for the component.
|
|
250
|
+
ref: The Var to pass as the ref to the component.
|
|
249
251
|
class_name: The class name for the component.
|
|
250
252
|
autofocus: Whether the component should take the focus once the page is loaded
|
|
251
253
|
custom_attrs: custom attribute
|
|
@@ -56,6 +56,7 @@ class ConnectionToaster(Fragment):
|
|
|
56
56
|
| None = None,
|
|
57
57
|
key: Any | None = None,
|
|
58
58
|
id: Any | None = None,
|
|
59
|
+
ref: Var | None = None,
|
|
59
60
|
class_name: Any | None = None,
|
|
60
61
|
autofocus: bool | None = None,
|
|
61
62
|
custom_attrs: dict[str, Var | Any] | None = None,
|
|
@@ -83,6 +84,7 @@ class ConnectionToaster(Fragment):
|
|
|
83
84
|
style: The style of the component.
|
|
84
85
|
key: A unique key for the component.
|
|
85
86
|
id: The id for the component.
|
|
87
|
+
ref: The Var to pass as the ref to the component.
|
|
86
88
|
class_name: The class name for the component.
|
|
87
89
|
autofocus: Whether the component should take the focus once the page is loaded
|
|
88
90
|
custom_attrs: custom attribute
|
|
@@ -106,6 +108,7 @@ class ConnectionBanner(Component):
|
|
|
106
108
|
| None = None,
|
|
107
109
|
key: Any | None = None,
|
|
108
110
|
id: Any | None = None,
|
|
111
|
+
ref: Var | None = None,
|
|
109
112
|
class_name: Any | None = None,
|
|
110
113
|
autofocus: bool | None = None,
|
|
111
114
|
custom_attrs: dict[str, Var | Any] | None = None,
|
|
@@ -149,6 +152,7 @@ class ConnectionModal(Component):
|
|
|
149
152
|
| None = None,
|
|
150
153
|
key: Any | None = None,
|
|
151
154
|
id: Any | None = None,
|
|
155
|
+
ref: Var | None = None,
|
|
152
156
|
class_name: Any | None = None,
|
|
153
157
|
autofocus: bool | None = None,
|
|
154
158
|
custom_attrs: dict[str, Var | Any] | None = None,
|
|
@@ -193,6 +197,7 @@ class WifiOffPulse(Icon):
|
|
|
193
197
|
| None = None,
|
|
194
198
|
key: Any | None = None,
|
|
195
199
|
id: Any | None = None,
|
|
200
|
+
ref: Var | None = None,
|
|
196
201
|
class_name: Any | None = None,
|
|
197
202
|
autofocus: bool | None = None,
|
|
198
203
|
custom_attrs: dict[str, Var | Any] | None = None,
|
|
@@ -221,6 +226,7 @@ class WifiOffPulse(Icon):
|
|
|
221
226
|
style: The style of the component.
|
|
222
227
|
key: A unique key for the component.
|
|
223
228
|
id: The id for the component.
|
|
229
|
+
ref: The Var to pass as the ref to the component.
|
|
224
230
|
class_name: The class name for the component.
|
|
225
231
|
autofocus: Whether the component should take the focus once the page is loaded
|
|
226
232
|
custom_attrs: custom attribute
|
|
@@ -424,6 +430,7 @@ class ConnectionPulser(Div):
|
|
|
424
430
|
| None = None,
|
|
425
431
|
key: Any | None = None,
|
|
426
432
|
id: Any | None = None,
|
|
433
|
+
ref: Var | None = None,
|
|
427
434
|
class_name: Any | None = None,
|
|
428
435
|
autofocus: bool | None = None,
|
|
429
436
|
custom_attrs: dict[str, Var | Any] | None = None,
|
|
@@ -466,6 +473,7 @@ class ConnectionPulser(Div):
|
|
|
466
473
|
style: The style of the component.
|
|
467
474
|
key: A unique key for the component.
|
|
468
475
|
id: The id for the component.
|
|
476
|
+
ref: The Var to pass as the ref to the component.
|
|
469
477
|
class_name: The class name for the component.
|
|
470
478
|
autofocus: Whether the component should take the focus once the page is loaded
|
|
471
479
|
custom_attrs: custom attribute
|
|
@@ -667,6 +675,7 @@ class BackendDisabled(Div):
|
|
|
667
675
|
| None = None,
|
|
668
676
|
key: Any | None = None,
|
|
669
677
|
id: Any | None = None,
|
|
678
|
+
ref: Var | None = None,
|
|
670
679
|
class_name: Any | None = None,
|
|
671
680
|
autofocus: bool | None = None,
|
|
672
681
|
custom_attrs: dict[str, Var | Any] | None = None,
|
|
@@ -709,6 +718,7 @@ class BackendDisabled(Div):
|
|
|
709
718
|
style: The style of the component.
|
|
710
719
|
key: A unique key for the component.
|
|
711
720
|
id: The id for the component.
|
|
721
|
+
ref: The Var to pass as the ref to the component.
|
|
712
722
|
class_name: The class name for the component.
|
|
713
723
|
autofocus: Whether the component should take the focus once the page is loaded
|
|
714
724
|
custom_attrs: custom attribute
|
|
@@ -28,6 +28,7 @@ class ClientSideRouting(Component):
|
|
|
28
28
|
| None = None,
|
|
29
29
|
key: Any | None = None,
|
|
30
30
|
id: Any | None = None,
|
|
31
|
+
ref: Var | None = None,
|
|
31
32
|
class_name: Any | None = None,
|
|
32
33
|
autofocus: bool | None = None,
|
|
33
34
|
custom_attrs: dict[str, Var | Any] | None = None,
|
|
@@ -55,6 +56,7 @@ class ClientSideRouting(Component):
|
|
|
55
56
|
style: The style of the component.
|
|
56
57
|
key: A unique key for the component.
|
|
57
58
|
id: The id for the component.
|
|
59
|
+
ref: The Var to pass as the ref to the component.
|
|
58
60
|
class_name: The class name for the component.
|
|
59
61
|
autofocus: Whether the component should take the focus once the page is loaded
|
|
60
62
|
custom_attrs: custom attribute
|
|
@@ -81,6 +83,7 @@ class Default404Page(Component):
|
|
|
81
83
|
| None = None,
|
|
82
84
|
key: Any | None = None,
|
|
83
85
|
id: Any | None = None,
|
|
86
|
+
ref: Var | None = None,
|
|
84
87
|
class_name: Any | None = None,
|
|
85
88
|
autofocus: bool | None = None,
|
|
86
89
|
custom_attrs: dict[str, Var | Any] | None = None,
|
|
@@ -108,6 +111,7 @@ class Default404Page(Component):
|
|
|
108
111
|
style: The style of the component.
|
|
109
112
|
key: A unique key for the component.
|
|
110
113
|
id: The id for the component.
|
|
114
|
+
ref: The Var to pass as the ref to the component.
|
|
111
115
|
class_name: The class name for the component.
|
|
112
116
|
autofocus: Whether the component should take the focus once the page is loaded
|
|
113
117
|
custom_attrs: custom attribute
|
|
@@ -29,6 +29,7 @@ class Clipboard(Fragment):
|
|
|
29
29
|
| None = None,
|
|
30
30
|
key: Any | None = None,
|
|
31
31
|
id: Any | None = None,
|
|
32
|
+
ref: Var | None = None,
|
|
32
33
|
class_name: Any | None = None,
|
|
33
34
|
autofocus: bool | None = None,
|
|
34
35
|
custom_attrs: dict[str, Var | Any] | None = None,
|
|
@@ -60,6 +61,7 @@ class Clipboard(Fragment):
|
|
|
60
61
|
style: The style of the component.
|
|
61
62
|
key: A unique key for the component.
|
|
62
63
|
id: The id for the component.
|
|
64
|
+
ref: The Var to pass as the ref to the component.
|
|
63
65
|
class_name: The class name for the component.
|
|
64
66
|
autofocus: Whether the component should take the focus once the page is loaded
|
|
65
67
|
custom_attrs: custom attribute
|