reflex 0.4.6a4__py3-none-any.whl → 0.4.7a1__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 +1 -0
- reflex/.templates/jinja/custom_components/pyproject.toml.jinja2 +1 -1
- reflex/.templates/jinja/custom_components/src.py.jinja2 +8 -8
- reflex/.templates/jinja/web/pages/index.js.jinja2 +0 -4
- reflex/.templates/jinja/web/pages/stateful_component.js.jinja2 +2 -6
- reflex/.templates/web/utils/state.js +6 -1
- reflex/__init__.py +2 -0
- reflex/__init__.pyi +2 -0
- reflex/app.py +12 -16
- reflex/app.pyi +2 -0
- reflex/compiler/compiler.py +10 -11
- reflex/compiler/utils.py +3 -3
- reflex/components/chakra/forms/pininput.py +2 -1
- reflex/components/component.py +71 -104
- reflex/components/core/banner.py +1 -1
- reflex/components/core/upload.py +2 -1
- reflex/components/datadisplay/__init__.py +1 -0
- reflex/components/datadisplay/logo.py +49 -0
- reflex/components/el/elements/forms.py +7 -4
- reflex/components/el/elements/forms.pyi +0 -1
- reflex/components/lucide/icon.py +3 -2
- reflex/components/lucide/icon.pyi +2 -2
- reflex/components/markdown/markdown.py +10 -6
- reflex/components/markdown/markdown.pyi +0 -3
- reflex/components/radix/themes/components/select.py +10 -3
- reflex/config.py +1 -1
- reflex/config.pyi +1 -1
- reflex/constants/base.py +4 -5
- reflex/constants/base.pyi +94 -0
- reflex/constants/compiler.py +8 -0
- reflex/custom_components/custom_components.py +1 -1
- reflex/experimental/__init__.py +14 -0
- reflex/experimental/hooks.py +75 -0
- reflex/page.py +1 -1
- reflex/reflex.py +18 -32
- reflex/style.py +4 -4
- reflex/testing.py +1 -1
- reflex/utils/console.py +6 -4
- reflex/utils/exec.py +17 -1
- reflex/utils/export.py +0 -3
- reflex/utils/prerequisites.py +239 -43
- reflex/utils/processes.py +6 -1
- reflex/utils/telemetry.py +14 -2
- reflex/vars.py +6 -6
- reflex/vars.pyi +2 -1
- {reflex-0.4.6a4.dist-info → reflex-0.4.7a1.dist-info}/METADATA +15 -10
- {reflex-0.4.6a4.dist-info → reflex-0.4.7a1.dist-info}/RECORD +50 -64
- {reflex-0.4.6a4.dist-info → reflex-0.4.7a1.dist-info}/WHEEL +1 -1
- reflex/.templates/apps/sidebar/README.md +0 -69
- reflex/.templates/apps/sidebar/assets/favicon.ico +0 -0
- reflex/.templates/apps/sidebar/assets/github.svg +0 -10
- reflex/.templates/apps/sidebar/assets/logo.svg +0 -68
- reflex/.templates/apps/sidebar/assets/paneleft.svg +0 -13
- reflex/.templates/apps/sidebar/assets/reflex_black.svg +0 -37
- reflex/.templates/apps/sidebar/assets/reflex_white.svg +0 -8
- reflex/.templates/apps/sidebar/code/__init__.py +0 -1
- reflex/.templates/apps/sidebar/code/components/__init__.py +0 -0
- reflex/.templates/apps/sidebar/code/components/sidebar.py +0 -152
- reflex/.templates/apps/sidebar/code/pages/__init__.py +0 -3
- reflex/.templates/apps/sidebar/code/pages/dashboard.py +0 -22
- reflex/.templates/apps/sidebar/code/pages/index.py +0 -18
- reflex/.templates/apps/sidebar/code/pages/settings.py +0 -61
- reflex/.templates/apps/sidebar/code/sidebar.py +0 -16
- reflex/.templates/apps/sidebar/code/styles.py +0 -60
- reflex/.templates/apps/sidebar/code/templates/__init__.py +0 -1
- reflex/.templates/apps/sidebar/code/templates/template.py +0 -145
- {reflex-0.4.6a4.dist-info → reflex-0.4.7a1.dist-info}/LICENSE +0 -0
- {reflex-0.4.6a4.dist-info → reflex-0.4.7a1.dist-info}/entry_points.txt +0 -0
|
@@ -10,7 +10,7 @@ readme = "README.md"
|
|
|
10
10
|
license = { text = "Apache-2.0" }
|
|
11
11
|
requires-python = ">=3.8"
|
|
12
12
|
authors = [{ name = "", email = "YOUREMAIL@domain.com" }]
|
|
13
|
-
keywords = ["reflex",
|
|
13
|
+
keywords = ["reflex","reflex-custom-components"]
|
|
14
14
|
|
|
15
15
|
dependencies = ["reflex>=0.4.2"]
|
|
16
16
|
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
import reflex as rx
|
|
6
6
|
|
|
7
|
-
# Some libraries you
|
|
7
|
+
# Some libraries you want to wrap may require dynamic imports.
|
|
8
8
|
# This is because they they may not be compatible with Server-Side Rendering (SSR).
|
|
9
|
-
# To handle this in Reflex all you need to do is subclass NoSSRComponent instead.
|
|
9
|
+
# To handle this in Reflex, all you need to do is subclass `NoSSRComponent` instead.
|
|
10
10
|
# For example:
|
|
11
11
|
# from reflex.components.component import NoSSRComponent
|
|
12
12
|
# class {{ component_class_name }}(NoSSRComponent):
|
|
@@ -42,12 +42,12 @@ class {{ component_class_name }}(rx.Component):
|
|
|
42
42
|
# In this case you can use the lib_dependencies property to specify other libraries to install.
|
|
43
43
|
# lib_dependencies: list[str] = []
|
|
44
44
|
|
|
45
|
-
# Event triggers
|
|
46
|
-
#
|
|
47
|
-
#
|
|
48
|
-
#
|
|
49
|
-
#
|
|
50
|
-
#
|
|
45
|
+
# Event triggers declaration if any.
|
|
46
|
+
# Below is equivalent to merging `{ "on_change": lambda e: [e] }`
|
|
47
|
+
# onto the default event triggers of parent/base Component.
|
|
48
|
+
# The function defined for the `on_change` trigger maps event for the javascript
|
|
49
|
+
# trigger to what will be passed to the backend event handler function.
|
|
50
|
+
# on_change: rx.EventHandler[lambda e: [e]]
|
|
51
51
|
|
|
52
52
|
# To add custom code to your component
|
|
53
53
|
# def _get_custom_code(self) -> str:
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
{% import 'web/pages/utils.js.jinja2' as utils %}
|
|
2
2
|
|
|
3
3
|
export function {{tag_name}} () {
|
|
4
|
-
{% for
|
|
5
|
-
{{ ref_hook }}
|
|
6
|
-
{% endfor %}
|
|
7
|
-
|
|
8
|
-
{% for hook in component.get_hooks_internal() %}
|
|
4
|
+
{% for hook in component._get_all_hooks_internal() %}
|
|
9
5
|
{{ hook }}
|
|
10
6
|
{% endfor %}
|
|
11
7
|
|
|
@@ -13,7 +9,7 @@ export function {{tag_name}} () {
|
|
|
13
9
|
{{ hook }}
|
|
14
10
|
{% endfor %}
|
|
15
11
|
|
|
16
|
-
{% for hook in component.
|
|
12
|
+
{% for hook in component._get_all_hooks() %}
|
|
17
13
|
{{ hook }}
|
|
18
14
|
{% endfor %}
|
|
19
15
|
|
|
@@ -646,7 +646,12 @@ export const useEventLoop = (
|
|
|
646
646
|
|
|
647
647
|
// Route after the initial page hydration.
|
|
648
648
|
useEffect(() => {
|
|
649
|
-
const change_start = () =>
|
|
649
|
+
const change_start = () => {
|
|
650
|
+
const main_state_dispatch = dispatch["state"]
|
|
651
|
+
if (main_state_dispatch !== undefined) {
|
|
652
|
+
main_state_dispatch({is_hydrated: false})
|
|
653
|
+
}
|
|
654
|
+
}
|
|
650
655
|
const change_complete = () => addEvents(onLoadInternalEvent());
|
|
651
656
|
router.events.on("routeChangeStart", change_start);
|
|
652
657
|
router.events.on("routeChangeComplete", change_complete);
|
reflex/__init__.py
CHANGED
|
@@ -109,9 +109,11 @@ _ALL_COMPONENTS = [
|
|
|
109
109
|
"unordered_list",
|
|
110
110
|
"ordered_list",
|
|
111
111
|
"moment",
|
|
112
|
+
"logo",
|
|
112
113
|
]
|
|
113
114
|
|
|
114
115
|
_MAPPING = {
|
|
116
|
+
"reflex.experimental": ["_x"],
|
|
115
117
|
"reflex.admin": ["admin", "AdminDash"],
|
|
116
118
|
"reflex.app": ["app", "App", "UploadFile"],
|
|
117
119
|
"reflex.base": ["base", "Base"],
|
reflex/__init__.pyi
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from reflex.experimental import _x as _x
|
|
1
2
|
from reflex import admin as admin
|
|
2
3
|
from reflex.admin import AdminDash as AdminDash
|
|
3
4
|
from reflex import app as app
|
|
@@ -95,6 +96,7 @@ from reflex.components import list_item as list_item
|
|
|
95
96
|
from reflex.components import unordered_list as unordered_list
|
|
96
97
|
from reflex.components import ordered_list as ordered_list
|
|
97
98
|
from reflex.components import moment as moment
|
|
99
|
+
from reflex.components import logo as logo
|
|
98
100
|
from reflex.components.component import Component as Component
|
|
99
101
|
from reflex.components.component import NoSSRComponent as NoSSRComponent
|
|
100
102
|
from reflex.components.component import memo as memo
|
reflex/app.py
CHANGED
|
@@ -214,12 +214,7 @@ class App(Base):
|
|
|
214
214
|
self.setup_state()
|
|
215
215
|
|
|
216
216
|
def setup_state(self) -> None:
|
|
217
|
-
"""Set up the state for the app.
|
|
218
|
-
|
|
219
|
-
Raises:
|
|
220
|
-
ValueError: If the event namespace is not provided in the config.
|
|
221
|
-
If the state has not been enabled.
|
|
222
|
-
"""
|
|
217
|
+
"""Set up the state for the app."""
|
|
223
218
|
if not self.state:
|
|
224
219
|
return
|
|
225
220
|
|
|
@@ -246,9 +241,6 @@ class App(Base):
|
|
|
246
241
|
self.socket_app = ASGIApp(self.sio, socketio_path="")
|
|
247
242
|
namespace = config.get_event_namespace()
|
|
248
243
|
|
|
249
|
-
if not namespace:
|
|
250
|
-
raise ValueError("event namespace must be provided in the config.")
|
|
251
|
-
|
|
252
244
|
# Create the event namespace and attach the main app. Not related to any paths.
|
|
253
245
|
self.event_namespace = EventNamespace(namespace, self)
|
|
254
246
|
|
|
@@ -457,6 +449,10 @@ class App(Base):
|
|
|
457
449
|
# Generate the component if it is a callable.
|
|
458
450
|
component = self._generate_component(component)
|
|
459
451
|
|
|
452
|
+
# unpack components that return tuples in an rx.fragment.
|
|
453
|
+
if isinstance(component, tuple):
|
|
454
|
+
component = Fragment.create(*component)
|
|
455
|
+
|
|
460
456
|
# Ensure state is enabled if this page uses state.
|
|
461
457
|
if self.state is None:
|
|
462
458
|
if on_load or component._has_event_triggers():
|
|
@@ -657,7 +653,7 @@ class App(Base):
|
|
|
657
653
|
|
|
658
654
|
def _app_root(self, app_wrappers: dict[tuple[int, str], Component]) -> Component:
|
|
659
655
|
for component in tuple(app_wrappers.values()):
|
|
660
|
-
app_wrappers.update(component.
|
|
656
|
+
app_wrappers.update(component._get_all_app_wrap_components())
|
|
661
657
|
order = sorted(app_wrappers, key=lambda k: k[0], reverse=True)
|
|
662
658
|
root = parent = copy.deepcopy(app_wrappers[order[0]])
|
|
663
659
|
for key in order[1:]:
|
|
@@ -795,18 +791,18 @@ class App(Base):
|
|
|
795
791
|
|
|
796
792
|
for _route, component in self.pages.items():
|
|
797
793
|
# Merge the component style with the app style.
|
|
798
|
-
component.
|
|
794
|
+
component._add_style_recursive(self.style)
|
|
799
795
|
|
|
800
796
|
component.apply_theme(self.theme)
|
|
801
797
|
|
|
802
|
-
# Add component.
|
|
803
|
-
all_imports.update(component.
|
|
798
|
+
# Add component._get_all_imports() to all_imports.
|
|
799
|
+
all_imports.update(component._get_all_imports())
|
|
804
800
|
|
|
805
801
|
# Add the app wrappers from this component.
|
|
806
|
-
app_wrappers.update(component.
|
|
802
|
+
app_wrappers.update(component._get_all_app_wrap_components())
|
|
807
803
|
|
|
808
804
|
# Add the custom components from the page to the set.
|
|
809
|
-
custom_components |= component.
|
|
805
|
+
custom_components |= component._get_all_custom_components()
|
|
810
806
|
|
|
811
807
|
progress.advance(task)
|
|
812
808
|
|
|
@@ -928,7 +924,7 @@ class App(Base):
|
|
|
928
924
|
all_imports.update(custom_components_imports)
|
|
929
925
|
|
|
930
926
|
# Get imports from AppWrap components.
|
|
931
|
-
all_imports.update(app_root.
|
|
927
|
+
all_imports.update(app_root._get_all_imports())
|
|
932
928
|
|
|
933
929
|
progress.advance(task)
|
|
934
930
|
|
reflex/app.pyi
CHANGED
|
@@ -94,7 +94,9 @@ class App(Base):
|
|
|
94
94
|
**kwargs
|
|
95
95
|
) -> None: ...
|
|
96
96
|
def __call__(self) -> FastAPI: ...
|
|
97
|
+
def enable_state(self) -> None: ...
|
|
97
98
|
def add_default_endpoints(self) -> None: ...
|
|
99
|
+
def add_optional_endpoints(self): ...
|
|
98
100
|
def add_cors(self) -> None: ...
|
|
99
101
|
async def preprocess(self, state: State, event: Event) -> StateUpdate | None: ...
|
|
100
102
|
async def postprocess(
|
reflex/compiler/compiler.py
CHANGED
|
@@ -33,7 +33,7 @@ def _compile_document_root(root: Component) -> str:
|
|
|
33
33
|
The compiled document root.
|
|
34
34
|
"""
|
|
35
35
|
return templates.DOCUMENT_ROOT.render(
|
|
36
|
-
imports=utils.compile_imports(root.
|
|
36
|
+
imports=utils.compile_imports(root._get_all_imports()),
|
|
37
37
|
document=root.render(),
|
|
38
38
|
)
|
|
39
39
|
|
|
@@ -48,9 +48,9 @@ def _compile_app(app_root: Component) -> str:
|
|
|
48
48
|
The compiled app.
|
|
49
49
|
"""
|
|
50
50
|
return templates.APP_ROOT.render(
|
|
51
|
-
imports=utils.compile_imports(app_root.
|
|
52
|
-
custom_codes=app_root.
|
|
53
|
-
hooks=app_root.
|
|
51
|
+
imports=utils.compile_imports(app_root._get_all_imports()),
|
|
52
|
+
custom_codes=app_root._get_all_custom_code(),
|
|
53
|
+
hooks={**app_root._get_all_hooks_internal(), **app_root._get_all_hooks()},
|
|
54
54
|
render=app_root.render(),
|
|
55
55
|
)
|
|
56
56
|
|
|
@@ -109,7 +109,7 @@ def _compile_page(
|
|
|
109
109
|
Returns:
|
|
110
110
|
The compiled component.
|
|
111
111
|
"""
|
|
112
|
-
imports = component.
|
|
112
|
+
imports = component._get_all_imports()
|
|
113
113
|
imports = utils.compile_imports(imports)
|
|
114
114
|
|
|
115
115
|
# Compile the code to render the component.
|
|
@@ -117,10 +117,9 @@ def _compile_page(
|
|
|
117
117
|
|
|
118
118
|
return templates.PAGE.render(
|
|
119
119
|
imports=imports,
|
|
120
|
-
dynamic_imports=component.
|
|
121
|
-
custom_codes=component.
|
|
122
|
-
|
|
123
|
-
hooks=component.get_hooks_internal() | component.get_hooks(),
|
|
120
|
+
dynamic_imports=component._get_all_dynamic_imports(),
|
|
121
|
+
custom_codes=component._get_all_custom_code(),
|
|
122
|
+
hooks={**component._get_all_hooks_internal(), **component._get_all_hooks()},
|
|
124
123
|
render=component.render(),
|
|
125
124
|
**kwargs,
|
|
126
125
|
)
|
|
@@ -265,9 +264,9 @@ def _compile_stateful_components(
|
|
|
265
264
|
component.rendered_as_shared = False
|
|
266
265
|
|
|
267
266
|
rendered_components.update(
|
|
268
|
-
{code: None for code in component.
|
|
267
|
+
{code: None for code in component._get_all_custom_code()},
|
|
269
268
|
)
|
|
270
|
-
all_import_dicts.append(component.
|
|
269
|
+
all_import_dicts.append(component._get_all_imports())
|
|
271
270
|
|
|
272
271
|
# Indicate that this component now imports from the shared file.
|
|
273
272
|
component.rendered_as_shared = True
|
reflex/compiler/utils.py
CHANGED
|
@@ -252,7 +252,7 @@ def compile_custom_component(
|
|
|
252
252
|
# Get the imports.
|
|
253
253
|
imports = {
|
|
254
254
|
lib: fields
|
|
255
|
-
for lib, fields in render.
|
|
255
|
+
for lib, fields in render._get_all_imports().items()
|
|
256
256
|
if lib != component.library
|
|
257
257
|
}
|
|
258
258
|
|
|
@@ -265,8 +265,8 @@ def compile_custom_component(
|
|
|
265
265
|
"name": component.tag,
|
|
266
266
|
"props": props,
|
|
267
267
|
"render": render.render(),
|
|
268
|
-
"hooks": render.
|
|
269
|
-
"custom_code": render.
|
|
268
|
+
"hooks": {**render._get_all_hooks_internal(), **render._get_all_hooks()},
|
|
269
|
+
"custom_code": render._get_all_custom_code(),
|
|
270
270
|
},
|
|
271
271
|
imports,
|
|
272
272
|
)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""A pin input component."""
|
|
2
|
+
|
|
2
3
|
from __future__ import annotations
|
|
3
4
|
|
|
4
5
|
from typing import Any, Optional, Union
|
|
@@ -71,7 +72,7 @@ class PinInput(ChakraComponent):
|
|
|
71
72
|
range_var = Var.range(0)
|
|
72
73
|
return merge_imports(
|
|
73
74
|
super()._get_imports(),
|
|
74
|
-
PinInputField().
|
|
75
|
+
PinInputField()._get_all_imports(), # type: ignore
|
|
75
76
|
range_var._var_data.imports if range_var._var_data is not None else {},
|
|
76
77
|
)
|
|
77
78
|
|