reflex 0.6.8a1__py3-none-any.whl → 0.7.0a1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of reflex might be problematic. Click here for more details.
- reflex/.templates/jinja/custom_components/pyproject.toml.jinja2 +1 -1
- reflex/.templates/jinja/web/pages/_app.js.jinja2 +7 -7
- reflex/.templates/jinja/web/pages/utils.js.jinja2 +2 -2
- reflex/.templates/web/components/reflex/radix_themes_color_mode_provider.js +1 -4
- reflex/.templates/web/utils/state.js +65 -36
- reflex/__init__.py +4 -17
- reflex/__init__.pyi +1 -2
- reflex/app.py +244 -115
- reflex/app_mixins/lifespan.py +9 -9
- reflex/app_mixins/middleware.py +6 -6
- reflex/app_module_for_backend.py +3 -7
- reflex/base.py +7 -7
- reflex/compiler/compiler.py +8 -0
- reflex/compiler/utils.py +35 -6
- reflex/components/base/bare.py +1 -1
- reflex/components/base/error_boundary.py +2 -1
- reflex/components/base/error_boundary.pyi +2 -1
- reflex/components/base/meta.py +2 -2
- reflex/components/base/strict_mode.py +10 -0
- reflex/components/base/strict_mode.pyi +57 -0
- reflex/components/component.py +38 -77
- reflex/components/core/banner.py +83 -4
- reflex/components/core/banner.pyi +86 -0
- reflex/components/core/breakpoints.py +3 -1
- reflex/components/core/client_side_routing.py +1 -1
- reflex/components/core/client_side_routing.pyi +1 -1
- reflex/components/core/cond.py +9 -10
- reflex/components/core/debounce.py +1 -1
- reflex/components/core/foreach.py +23 -3
- reflex/components/core/html.py +1 -1
- reflex/components/core/match.py +5 -5
- reflex/components/core/sticky.py +160 -0
- reflex/components/core/sticky.pyi +449 -0
- reflex/components/core/upload.py +2 -2
- reflex/components/datadisplay/code.py +5 -14
- reflex/components/datadisplay/dataeditor.py +7 -4
- reflex/components/datadisplay/logo.py +13 -8
- reflex/components/datadisplay/shiki_code_block.py +14 -9
- reflex/components/dynamic.py +22 -3
- reflex/components/el/constants/reflex.py +1 -1
- reflex/components/el/element.py +1 -1
- reflex/components/el/elements/forms.py +4 -4
- reflex/components/el/elements/forms.pyi +4 -4
- reflex/components/lucide/icon.py +46 -8
- reflex/components/lucide/icon.pyi +54 -0
- reflex/components/markdown/markdown.py +10 -8
- reflex/components/moment/moment.py +2 -2
- reflex/components/next/image.py +16 -4
- reflex/components/next/image.pyi +4 -2
- reflex/components/next/link.py +1 -1
- reflex/components/plotly/plotly.py +5 -5
- reflex/components/props.py +3 -3
- reflex/components/radix/__init__.pyi +1 -1
- reflex/components/radix/primitives/accordion.py +9 -5
- reflex/components/radix/primitives/accordion.pyi +3 -1
- reflex/components/radix/primitives/drawer.py +5 -2
- reflex/components/radix/primitives/drawer.pyi +4 -4
- reflex/components/radix/primitives/form.pyi +6 -6
- reflex/components/radix/primitives/progress.py +1 -1
- reflex/components/radix/primitives/slider.py +1 -1
- reflex/components/radix/themes/color_mode.py +11 -9
- reflex/components/radix/themes/components/alert_dialog.py +3 -0
- reflex/components/radix/themes/components/card.py +1 -1
- reflex/components/radix/themes/components/card.pyi +1 -1
- reflex/components/radix/themes/components/context_menu.py +5 -0
- reflex/components/radix/themes/components/dialog.py +3 -0
- reflex/components/radix/themes/components/dropdown_menu.py +5 -0
- reflex/components/radix/themes/components/hover_card.py +3 -0
- reflex/components/radix/themes/components/icon_button.py +2 -2
- reflex/components/radix/themes/components/icon_button.pyi +1 -0
- reflex/components/radix/themes/components/popover.py +3 -0
- reflex/components/radix/themes/components/radio_cards.py +2 -0
- reflex/components/radix/themes/components/radio_group.py +1 -1
- reflex/components/radix/themes/components/select.py +3 -0
- reflex/components/radix/themes/components/tabs.py +3 -0
- reflex/components/radix/themes/components/text_area.py +12 -0
- reflex/components/radix/themes/components/text_area.pyi +2 -0
- reflex/components/radix/themes/components/text_field.py +1 -1
- reflex/components/radix/themes/components/tooltip.py +3 -1
- reflex/components/radix/themes/components/tooltip.pyi +1 -0
- reflex/components/radix/themes/layout/__init__.pyi +1 -1
- reflex/components/radix/themes/layout/list.py +2 -2
- reflex/components/radix/themes/layout/stack.py +2 -2
- reflex/components/radix/themes/typography/link.py +1 -1
- reflex/components/radix/themes/typography/text.py +2 -2
- reflex/components/react_player/react_player.py +1 -1
- reflex/components/recharts/__init__.py +2 -0
- reflex/components/recharts/__init__.pyi +2 -0
- reflex/components/recharts/charts.py +15 -15
- reflex/components/recharts/general.py +19 -4
- reflex/components/recharts/general.pyi +55 -4
- reflex/components/recharts/polar.py +2 -2
- reflex/components/recharts/recharts.py +4 -4
- reflex/components/sonner/toast.py +15 -13
- reflex/components/sonner/toast.pyi +6 -6
- reflex/components/suneditor/editor.py +6 -4
- reflex/components/suneditor/editor.pyi +2 -2
- reflex/components/tags/iter_tag.py +3 -3
- reflex/components/tags/tag.py +25 -3
- reflex/config.py +48 -20
- reflex/constants/__init__.py +1 -0
- reflex/constants/base.py +4 -1
- reflex/constants/compiler.py +5 -2
- reflex/constants/config.py +8 -1
- reflex/constants/installer.py +9 -9
- reflex/constants/style.py +1 -1
- reflex/custom_components/custom_components.py +9 -7
- reflex/event.py +137 -163
- reflex/experimental/__init__.py +19 -11
- reflex/experimental/client_state.py +53 -28
- reflex/experimental/hooks.py +5 -5
- reflex/experimental/layout.py +8 -5
- reflex/experimental/layout.pyi +1 -1
- reflex/experimental/misc.py +3 -3
- reflex/istate/wrappers.py +1 -1
- reflex/middleware/hydrate_middleware.py +2 -2
- reflex/model.py +11 -6
- reflex/page.py +3 -3
- reflex/reflex.py +90 -19
- reflex/route.py +1 -1
- reflex/state.py +358 -401
- reflex/style.py +27 -3
- reflex/testing.py +34 -39
- reflex/utils/build.py +6 -2
- reflex/utils/codespaces.py +1 -4
- reflex/utils/compat.py +6 -5
- reflex/utils/console.py +52 -21
- reflex/utils/exceptions.py +76 -26
- reflex/utils/exec.py +69 -74
- reflex/utils/export.py +6 -1
- reflex/utils/format.py +7 -39
- reflex/utils/imports.py +2 -2
- reflex/utils/lazy_loader.py +7 -1
- reflex/utils/path_ops.py +28 -14
- reflex/utils/prerequisites.py +324 -65
- reflex/utils/processes.py +45 -32
- reflex/utils/pyi_generator.py +30 -25
- reflex/utils/registry.py +4 -4
- reflex/utils/serializers.py +1 -1
- reflex/utils/telemetry.py +5 -4
- reflex/utils/types.py +42 -18
- reflex/vars/base.py +650 -333
- reflex/vars/datetime.py +6 -7
- reflex/vars/dep_tracking.py +344 -0
- reflex/vars/function.py +11 -5
- reflex/vars/number.py +31 -43
- reflex/vars/object.py +63 -62
- reflex/vars/sequence.py +79 -67
- {reflex-0.6.8a1.dist-info → reflex-0.7.0a1.dist-info}/METADATA +7 -10
- {reflex-0.6.8a1.dist-info → reflex-0.7.0a1.dist-info}/RECORD +153 -150
- {reflex-0.6.8a1.dist-info → reflex-0.7.0a1.dist-info}/WHEEL +1 -1
- reflex/experimental/assets.py +0 -37
- reflex/proxy.py +0 -119
- {reflex-0.6.8a1.dist-info → reflex-0.7.0a1.dist-info}/LICENSE +0 -0
- {reflex-0.6.8a1.dist-info → reflex-0.7.0a1.dist-info}/entry_points.txt +0 -0
reflex/app_mixins/lifespan.py
CHANGED
|
@@ -12,7 +12,7 @@ from typing import Callable, Coroutine, Set, Union
|
|
|
12
12
|
from fastapi import FastAPI
|
|
13
13
|
|
|
14
14
|
from reflex.utils import console
|
|
15
|
-
from reflex.utils.exceptions import
|
|
15
|
+
from reflex.utils.exceptions import InvalidLifespanTaskTypeError
|
|
16
16
|
|
|
17
17
|
from .mixin import AppMixin
|
|
18
18
|
|
|
@@ -32,7 +32,7 @@ class LifespanMixin(AppMixin):
|
|
|
32
32
|
try:
|
|
33
33
|
async with contextlib.AsyncExitStack() as stack:
|
|
34
34
|
for task in self.lifespan_tasks:
|
|
35
|
-
run_msg = f"Started lifespan task: {task.__name__} as {{type}}" #
|
|
35
|
+
run_msg = f"Started lifespan task: {task.__name__} as {{type}}" # pyright: ignore [reportAttributeAccessIssue]
|
|
36
36
|
if isinstance(task, asyncio.Task):
|
|
37
37
|
running_tasks.append(task)
|
|
38
38
|
else:
|
|
@@ -61,19 +61,19 @@ class LifespanMixin(AppMixin):
|
|
|
61
61
|
|
|
62
62
|
Args:
|
|
63
63
|
task: The task to register.
|
|
64
|
-
task_kwargs: The kwargs of the task.
|
|
64
|
+
**task_kwargs: The kwargs of the task.
|
|
65
65
|
|
|
66
66
|
Raises:
|
|
67
|
-
|
|
67
|
+
InvalidLifespanTaskTypeError: If the task is a generator function.
|
|
68
68
|
"""
|
|
69
69
|
if inspect.isgeneratorfunction(task) or inspect.isasyncgenfunction(task):
|
|
70
|
-
raise
|
|
70
|
+
raise InvalidLifespanTaskTypeError(
|
|
71
71
|
f"Task {task.__name__} of type generator must be decorated with contextlib.asynccontextmanager."
|
|
72
72
|
)
|
|
73
73
|
|
|
74
74
|
if task_kwargs:
|
|
75
75
|
original_task = task
|
|
76
|
-
task = functools.partial(task, **task_kwargs) #
|
|
77
|
-
functools.update_wrapper(task, original_task) #
|
|
78
|
-
self.lifespan_tasks.add(task)
|
|
79
|
-
console.debug(f"Registered lifespan task: {task.__name__}") #
|
|
76
|
+
task = functools.partial(task, **task_kwargs) # pyright: ignore [reportArgumentType]
|
|
77
|
+
functools.update_wrapper(task, original_task) # pyright: ignore [reportArgumentType]
|
|
78
|
+
self.lifespan_tasks.add(task)
|
|
79
|
+
console.debug(f"Registered lifespan task: {task.__name__}") # pyright: ignore [reportAttributeAccessIssue]
|
reflex/app_mixins/middleware.py
CHANGED
|
@@ -53,11 +53,11 @@ class MiddlewareMixin(AppMixin):
|
|
|
53
53
|
"""
|
|
54
54
|
for middleware in self.middleware:
|
|
55
55
|
if asyncio.iscoroutinefunction(middleware.preprocess):
|
|
56
|
-
out = await middleware.preprocess(app=self, state=state, event=event) #
|
|
56
|
+
out = await middleware.preprocess(app=self, state=state, event=event) # pyright: ignore [reportArgumentType]
|
|
57
57
|
else:
|
|
58
|
-
out = middleware.preprocess(app=self, state=state, event=event) #
|
|
58
|
+
out = middleware.preprocess(app=self, state=state, event=event) # pyright: ignore [reportArgumentType]
|
|
59
59
|
if out is not None:
|
|
60
|
-
return out #
|
|
60
|
+
return out # pyright: ignore [reportReturnType]
|
|
61
61
|
|
|
62
62
|
async def _postprocess(
|
|
63
63
|
self, state: BaseState, event: Event, update: StateUpdate
|
|
@@ -78,18 +78,18 @@ class MiddlewareMixin(AppMixin):
|
|
|
78
78
|
for middleware in self.middleware:
|
|
79
79
|
if asyncio.iscoroutinefunction(middleware.postprocess):
|
|
80
80
|
out = await middleware.postprocess(
|
|
81
|
-
app=self, #
|
|
81
|
+
app=self, # pyright: ignore [reportArgumentType]
|
|
82
82
|
state=state,
|
|
83
83
|
event=event,
|
|
84
84
|
update=update,
|
|
85
85
|
)
|
|
86
86
|
else:
|
|
87
87
|
out = middleware.postprocess(
|
|
88
|
-
app=self, #
|
|
88
|
+
app=self, # pyright: ignore [reportArgumentType]
|
|
89
89
|
state=state,
|
|
90
90
|
event=event,
|
|
91
91
|
update=update,
|
|
92
92
|
)
|
|
93
93
|
if out is not None:
|
|
94
|
-
return out #
|
|
94
|
+
return out # pyright: ignore [reportReturnType]
|
|
95
95
|
return update
|
reflex/app_module_for_backend.py
CHANGED
|
@@ -5,16 +5,13 @@ Only the app attribute is explicitly exposed.
|
|
|
5
5
|
from concurrent.futures import ThreadPoolExecutor
|
|
6
6
|
|
|
7
7
|
from reflex import constants
|
|
8
|
-
from reflex.utils import telemetry
|
|
9
8
|
from reflex.utils.exec import is_prod_mode
|
|
10
|
-
from reflex.utils.prerequisites import
|
|
9
|
+
from reflex.utils.prerequisites import get_and_validate_app
|
|
11
10
|
|
|
12
11
|
if constants.CompileVars.APP != "app":
|
|
13
12
|
raise AssertionError("unexpected variable name for 'app'")
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
app_module = get_app(reload=False)
|
|
17
|
-
app = getattr(app_module, constants.CompileVars.APP)
|
|
14
|
+
app, app_module = get_and_validate_app(reload=False)
|
|
18
15
|
# For py3.9 compatibility when redis is used, we MUST add any decorator pages
|
|
19
16
|
# before compiling the app in a thread to avoid event loop error (REF-2172).
|
|
20
17
|
app._apply_decorated_pages()
|
|
@@ -30,8 +27,7 @@ if is_prod_mode():
|
|
|
30
27
|
# ensure only "app" is exposed.
|
|
31
28
|
del app_module
|
|
32
29
|
del compile_future
|
|
33
|
-
del
|
|
30
|
+
del get_and_validate_app
|
|
34
31
|
del is_prod_mode
|
|
35
|
-
del telemetry
|
|
36
32
|
del constants
|
|
37
33
|
del ThreadPoolExecutor
|
reflex/base.py
CHANGED
|
@@ -13,7 +13,7 @@ except ModuleNotFoundError:
|
|
|
13
13
|
if not TYPE_CHECKING:
|
|
14
14
|
import pydantic.main as pydantic_main
|
|
15
15
|
from pydantic import BaseModel
|
|
16
|
-
from pydantic.fields import ModelField
|
|
16
|
+
from pydantic.fields import ModelField
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
def validate_field_name(bases: List[Type["BaseModel"]], field_name: str) -> None:
|
|
@@ -44,13 +44,13 @@ def validate_field_name(bases: List[Type["BaseModel"]], field_name: str) -> None
|
|
|
44
44
|
|
|
45
45
|
# monkeypatch pydantic validate_field_name method to skip validating
|
|
46
46
|
# shadowed state vars when reloading app via utils.prerequisites.get_app(reload=True)
|
|
47
|
-
pydantic_main.validate_field_name = validate_field_name #
|
|
47
|
+
pydantic_main.validate_field_name = validate_field_name # pyright: ignore [reportPossiblyUnboundVariable, reportPrivateImportUsage]
|
|
48
48
|
|
|
49
49
|
if TYPE_CHECKING:
|
|
50
50
|
from reflex.vars import Var
|
|
51
51
|
|
|
52
52
|
|
|
53
|
-
class Base(BaseModel): # pyright: ignore [
|
|
53
|
+
class Base(BaseModel): # pyright: ignore [reportPossiblyUnboundVariable]
|
|
54
54
|
"""The base class subclassed by all Reflex classes.
|
|
55
55
|
|
|
56
56
|
This class wraps Pydantic and provides common methods such as
|
|
@@ -75,12 +75,12 @@ class Base(BaseModel): # pyright: ignore [reportUnboundVariable]
|
|
|
75
75
|
"""
|
|
76
76
|
from reflex.utils.serializers import serialize
|
|
77
77
|
|
|
78
|
-
return self.__config__.json_dumps(
|
|
78
|
+
return self.__config__.json_dumps(
|
|
79
79
|
self.dict(),
|
|
80
80
|
default=serialize,
|
|
81
81
|
)
|
|
82
82
|
|
|
83
|
-
def set(self, **kwargs):
|
|
83
|
+
def set(self, **kwargs: Any):
|
|
84
84
|
"""Set multiple fields and return the object.
|
|
85
85
|
|
|
86
86
|
Args:
|
|
@@ -113,12 +113,12 @@ class Base(BaseModel): # pyright: ignore [reportUnboundVariable]
|
|
|
113
113
|
default_value: The default value of the field
|
|
114
114
|
"""
|
|
115
115
|
var_name = var._var_field_name
|
|
116
|
-
new_field = ModelField.infer(
|
|
116
|
+
new_field = ModelField.infer( # pyright: ignore [reportPossiblyUnboundVariable]
|
|
117
117
|
name=var_name,
|
|
118
118
|
value=default_value,
|
|
119
119
|
annotation=var._var_type,
|
|
120
120
|
class_validators=None,
|
|
121
|
-
config=cls.__config__,
|
|
121
|
+
config=cls.__config__,
|
|
122
122
|
)
|
|
123
123
|
cls.__fields__.update({var_name: new_field})
|
|
124
124
|
|
reflex/compiler/compiler.py
CHANGED
|
@@ -239,11 +239,19 @@ def _compile_components(
|
|
|
239
239
|
component_renders.append(component_render)
|
|
240
240
|
imports = utils.merge_imports(imports, component_imports)
|
|
241
241
|
|
|
242
|
+
dynamic_imports = {
|
|
243
|
+
comp_import: None
|
|
244
|
+
for comp_render in component_renders
|
|
245
|
+
if "dynamic_imports" in comp_render
|
|
246
|
+
for comp_import in comp_render["dynamic_imports"]
|
|
247
|
+
}
|
|
248
|
+
|
|
242
249
|
# Compile the components page.
|
|
243
250
|
return (
|
|
244
251
|
templates.COMPONENTS.render(
|
|
245
252
|
imports=utils.compile_imports(imports),
|
|
246
253
|
components=component_renders,
|
|
254
|
+
dynamic_imports=dynamic_imports,
|
|
247
255
|
),
|
|
248
256
|
imports,
|
|
249
257
|
)
|
reflex/compiler/utils.py
CHANGED
|
@@ -2,17 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
import asyncio
|
|
6
|
+
import concurrent.futures
|
|
7
|
+
import traceback
|
|
8
|
+
from datetime import datetime
|
|
5
9
|
from pathlib import Path
|
|
6
10
|
from typing import Any, Callable, Dict, Optional, Type, Union
|
|
7
11
|
from urllib.parse import urlparse
|
|
8
12
|
|
|
13
|
+
from reflex.utils.exec import is_in_app_harness
|
|
9
14
|
from reflex.utils.prerequisites import get_web_dir
|
|
10
15
|
from reflex.vars.base import Var
|
|
11
16
|
|
|
12
17
|
try:
|
|
13
18
|
from pydantic.v1.fields import ModelField
|
|
14
19
|
except ModuleNotFoundError:
|
|
15
|
-
from pydantic.fields import
|
|
20
|
+
from pydantic.fields import (
|
|
21
|
+
ModelField, # pyright: ignore [reportAttributeAccessIssue]
|
|
22
|
+
)
|
|
16
23
|
|
|
17
24
|
from reflex import constants
|
|
18
25
|
from reflex.components.base import (
|
|
@@ -29,7 +36,7 @@ from reflex.components.base import (
|
|
|
29
36
|
)
|
|
30
37
|
from reflex.components.component import Component, ComponentStyle, CustomComponent
|
|
31
38
|
from reflex.istate.storage import Cookie, LocalStorage, SessionStorage
|
|
32
|
-
from reflex.state import BaseState
|
|
39
|
+
from reflex.state import BaseState, _resolve_delta
|
|
33
40
|
from reflex.style import Style
|
|
34
41
|
from reflex.utils import console, format, imports, path_ops
|
|
35
42
|
from reflex.utils.imports import ImportVar, ParsedImportDict
|
|
@@ -115,7 +122,7 @@ def compile_imports(import_dict: ParsedImportDict) -> list[dict]:
|
|
|
115
122
|
default, rest = compile_import_statement(fields)
|
|
116
123
|
|
|
117
124
|
# prevent lib from being rendered on the page if all imports are non rendered kind
|
|
118
|
-
if not any(f.render for f in fields):
|
|
125
|
+
if not any(f.render for f in fields):
|
|
119
126
|
continue
|
|
120
127
|
|
|
121
128
|
if not lib:
|
|
@@ -163,13 +170,34 @@ def compile_state(state: Type[BaseState]) -> dict:
|
|
|
163
170
|
try:
|
|
164
171
|
initial_state = state(_reflex_internal_init=True).dict(initial=True)
|
|
165
172
|
except Exception as e:
|
|
173
|
+
timestamp = datetime.now().strftime("%Y-%m-%d__%H-%M-%S")
|
|
174
|
+
constants.Reflex.LOGS_DIR.mkdir(parents=True, exist_ok=True)
|
|
175
|
+
log_path = constants.Reflex.LOGS_DIR / f"state_compile_error_{timestamp}.log"
|
|
176
|
+
traceback.TracebackException.from_exception(e).print(file=log_path.open("w+"))
|
|
166
177
|
console.warn(
|
|
167
|
-
f"Failed to compile initial state with computed vars
|
|
178
|
+
f"Failed to compile initial state with computed vars. Error log saved to {log_path}"
|
|
168
179
|
)
|
|
169
180
|
initial_state = state(_reflex_internal_init=True).dict(
|
|
170
181
|
initial=True, include_computed=False
|
|
171
182
|
)
|
|
172
|
-
|
|
183
|
+
try:
|
|
184
|
+
_ = asyncio.get_running_loop()
|
|
185
|
+
except RuntimeError:
|
|
186
|
+
pass
|
|
187
|
+
else:
|
|
188
|
+
if is_in_app_harness():
|
|
189
|
+
# Playwright tests already have an event loop running, so we can't use asyncio.run.
|
|
190
|
+
with concurrent.futures.ThreadPoolExecutor() as pool:
|
|
191
|
+
resolved_initial_state = pool.submit(
|
|
192
|
+
asyncio.run, _resolve_delta(initial_state)
|
|
193
|
+
).result()
|
|
194
|
+
console.warn(
|
|
195
|
+
f"Had to get initial state in a thread 🤮 {resolved_initial_state}",
|
|
196
|
+
)
|
|
197
|
+
return resolved_initial_state
|
|
198
|
+
|
|
199
|
+
# Normally the compile runs before any event loop starts, we asyncio.run is available for calling.
|
|
200
|
+
return asyncio.run(_resolve_delta(initial_state))
|
|
173
201
|
|
|
174
202
|
|
|
175
203
|
def _compile_client_storage_field(
|
|
@@ -292,6 +320,7 @@ def compile_custom_component(
|
|
|
292
320
|
"render": render.render(),
|
|
293
321
|
"hooks": render._get_all_hooks(),
|
|
294
322
|
"custom_code": render._get_all_custom_code(),
|
|
323
|
+
"dynamic_imports": render._get_all_dynamic_imports(),
|
|
295
324
|
},
|
|
296
325
|
imports,
|
|
297
326
|
)
|
|
@@ -494,7 +523,7 @@ def empty_dir(path: str | Path, keep_files: list[str] | None = None):
|
|
|
494
523
|
path_ops.rm(element)
|
|
495
524
|
|
|
496
525
|
|
|
497
|
-
def is_valid_url(url) -> bool:
|
|
526
|
+
def is_valid_url(url: str) -> bool:
|
|
498
527
|
"""Check if a url is valid.
|
|
499
528
|
|
|
500
529
|
Args:
|
reflex/components/base/bare.py
CHANGED
|
@@ -31,7 +31,7 @@ class Bare(Component):
|
|
|
31
31
|
return cls(contents=contents)
|
|
32
32
|
else:
|
|
33
33
|
contents = str(contents) if contents is not None else ""
|
|
34
|
-
return cls(contents=contents)
|
|
34
|
+
return cls(contents=contents)
|
|
35
35
|
|
|
36
36
|
def _get_all_hooks_internal(self) -> dict[str, VarData | None]:
|
|
37
37
|
"""Include the hooks for the component.
|
|
@@ -11,10 +11,11 @@ from reflex.event import EventHandler, set_clipboard
|
|
|
11
11
|
from reflex.state import FrontendEventExceptionState
|
|
12
12
|
from reflex.vars.base import Var
|
|
13
13
|
from reflex.vars.function import ArgsFunctionOperation
|
|
14
|
+
from reflex.vars.object import ObjectVar
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
def on_error_spec(
|
|
17
|
-
error:
|
|
18
|
+
error: ObjectVar[Dict[str, str]], info: ObjectVar[Dict[str, str]]
|
|
18
19
|
) -> Tuple[Var[str], Var[str]]:
|
|
19
20
|
"""The spec for the on_error event handler.
|
|
20
21
|
|
|
@@ -9,9 +9,10 @@ from reflex.components.component import Component
|
|
|
9
9
|
from reflex.event import BASE_STATE, EventType
|
|
10
10
|
from reflex.style import Style
|
|
11
11
|
from reflex.vars.base import Var
|
|
12
|
+
from reflex.vars.object import ObjectVar
|
|
12
13
|
|
|
13
14
|
def on_error_spec(
|
|
14
|
-
error:
|
|
15
|
+
error: ObjectVar[Dict[str, str]], info: ObjectVar[Dict[str, str]]
|
|
15
16
|
) -> Tuple[Var[str], Var[str]]: ...
|
|
16
17
|
|
|
17
18
|
class ErrorBoundary(Component):
|
reflex/components/base/meta.py
CHANGED
|
@@ -53,11 +53,11 @@ class Description(Meta):
|
|
|
53
53
|
"""A component that displays the title of the current page."""
|
|
54
54
|
|
|
55
55
|
# The type of the description.
|
|
56
|
-
name: str = "description"
|
|
56
|
+
name: str | None = "description"
|
|
57
57
|
|
|
58
58
|
|
|
59
59
|
class Image(Meta):
|
|
60
60
|
"""A component that displays the title of the current page."""
|
|
61
61
|
|
|
62
62
|
# The type of the image.
|
|
63
|
-
property: str = "og:image"
|
|
63
|
+
property: str | None = "og:image"
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"""Stub file for reflex/components/base/strict_mode.py"""
|
|
2
|
+
|
|
3
|
+
# ------------------- DO NOT EDIT ----------------------
|
|
4
|
+
# This file was generated by `reflex/utils/pyi_generator.py`!
|
|
5
|
+
# ------------------------------------------------------
|
|
6
|
+
from typing import Any, Dict, Optional, Union, overload
|
|
7
|
+
|
|
8
|
+
from reflex.components.component import Component
|
|
9
|
+
from reflex.event import BASE_STATE, EventType
|
|
10
|
+
from reflex.style import Style
|
|
11
|
+
from reflex.vars.base import Var
|
|
12
|
+
|
|
13
|
+
class StrictMode(Component):
|
|
14
|
+
@overload
|
|
15
|
+
@classmethod
|
|
16
|
+
def create( # type: ignore
|
|
17
|
+
cls,
|
|
18
|
+
*children,
|
|
19
|
+
style: Optional[Style] = None,
|
|
20
|
+
key: Optional[Any] = None,
|
|
21
|
+
id: Optional[Any] = None,
|
|
22
|
+
class_name: Optional[Any] = None,
|
|
23
|
+
autofocus: Optional[bool] = None,
|
|
24
|
+
custom_attrs: Optional[Dict[str, Union[Var, Any]]] = None,
|
|
25
|
+
on_blur: Optional[EventType[[], BASE_STATE]] = None,
|
|
26
|
+
on_click: Optional[EventType[[], BASE_STATE]] = None,
|
|
27
|
+
on_context_menu: Optional[EventType[[], BASE_STATE]] = None,
|
|
28
|
+
on_double_click: Optional[EventType[[], BASE_STATE]] = None,
|
|
29
|
+
on_focus: Optional[EventType[[], BASE_STATE]] = None,
|
|
30
|
+
on_mount: Optional[EventType[[], BASE_STATE]] = None,
|
|
31
|
+
on_mouse_down: Optional[EventType[[], BASE_STATE]] = None,
|
|
32
|
+
on_mouse_enter: Optional[EventType[[], BASE_STATE]] = None,
|
|
33
|
+
on_mouse_leave: Optional[EventType[[], BASE_STATE]] = None,
|
|
34
|
+
on_mouse_move: Optional[EventType[[], BASE_STATE]] = None,
|
|
35
|
+
on_mouse_out: Optional[EventType[[], BASE_STATE]] = None,
|
|
36
|
+
on_mouse_over: Optional[EventType[[], BASE_STATE]] = None,
|
|
37
|
+
on_mouse_up: Optional[EventType[[], BASE_STATE]] = None,
|
|
38
|
+
on_scroll: Optional[EventType[[], BASE_STATE]] = None,
|
|
39
|
+
on_unmount: Optional[EventType[[], BASE_STATE]] = None,
|
|
40
|
+
**props,
|
|
41
|
+
) -> "StrictMode":
|
|
42
|
+
"""Create the component.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
*children: The children of the component.
|
|
46
|
+
style: The style of the component.
|
|
47
|
+
key: A unique key for the component.
|
|
48
|
+
id: The id for the component.
|
|
49
|
+
class_name: The class name for the component.
|
|
50
|
+
autofocus: Whether the component should take the focus once the page is loaded
|
|
51
|
+
custom_attrs: custom attribute
|
|
52
|
+
**props: The props of the component.
|
|
53
|
+
|
|
54
|
+
Returns:
|
|
55
|
+
The component.
|
|
56
|
+
"""
|
|
57
|
+
...
|