reflex 0.7.8a1__py3-none-any.whl → 0.7.9a2__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/web/tailwind.config.js.jinja2 +65 -31
- reflex/.templates/web/utils/state.js +11 -1
- reflex/app.py +191 -87
- reflex/app_mixins/lifespan.py +2 -2
- reflex/compiler/compiler.py +31 -4
- reflex/components/base/body.pyi +3 -197
- reflex/components/base/link.pyi +4 -392
- reflex/components/base/meta.pyi +28 -608
- reflex/components/component.py +39 -57
- reflex/components/core/upload.py +8 -0
- reflex/components/dynamic.py +9 -1
- reflex/components/el/elements/metadata.pyi +0 -1
- reflex/components/markdown/markdown.py +0 -21
- reflex/components/markdown/markdown.pyi +2 -2
- reflex/components/radix/primitives/accordion.py +1 -1
- reflex/components/radix/primitives/form.py +1 -1
- reflex/components/radix/primitives/progress.py +1 -1
- reflex/components/radix/primitives/slider.py +1 -1
- reflex/components/radix/themes/color_mode.py +1 -1
- reflex/components/radix/themes/color_mode.pyi +1 -1
- reflex/components/radix/themes/layout/list.pyi +2 -391
- reflex/components/recharts/recharts.py +2 -2
- reflex/components/sonner/toast.py +1 -1
- reflex/config.py +4 -7
- reflex/constants/base.py +21 -0
- reflex/constants/installer.py +6 -6
- reflex/custom_components/custom_components.py +67 -64
- reflex/event.py +2 -0
- reflex/page.py +8 -0
- reflex/reflex.py +277 -265
- reflex/testing.py +30 -24
- reflex/utils/codespaces.py +6 -2
- reflex/utils/console.py +4 -3
- reflex/utils/exec.py +60 -24
- reflex/utils/format.py +17 -2
- reflex/utils/prerequisites.py +43 -30
- reflex/utils/processes.py +6 -6
- reflex/utils/types.py +11 -6
- reflex/vars/base.py +19 -1
- {reflex-0.7.8a1.dist-info → reflex-0.7.9a2.dist-info}/METADATA +6 -9
- {reflex-0.7.8a1.dist-info → reflex-0.7.9a2.dist-info}/RECORD +44 -44
- {reflex-0.7.8a1.dist-info → reflex-0.7.9a2.dist-info}/WHEEL +0 -0
- {reflex-0.7.8a1.dist-info → reflex-0.7.9a2.dist-info}/entry_points.txt +0 -0
- {reflex-0.7.8a1.dist-info → reflex-0.7.9a2.dist-info}/licenses/LICENSE +0 -0
reflex/components/component.py
CHANGED
|
@@ -1647,32 +1647,6 @@ class Component(BaseComponent, ABC):
|
|
|
1647
1647
|
|
|
1648
1648
|
return refs
|
|
1649
1649
|
|
|
1650
|
-
def _get_all_custom_components(
|
|
1651
|
-
self, seen: set[str] | None = None
|
|
1652
|
-
) -> set[CustomComponent]:
|
|
1653
|
-
"""Get all the custom components used by the component.
|
|
1654
|
-
|
|
1655
|
-
Args:
|
|
1656
|
-
seen: The tags of the components that have already been seen.
|
|
1657
|
-
|
|
1658
|
-
Returns:
|
|
1659
|
-
The set of custom components.
|
|
1660
|
-
"""
|
|
1661
|
-
custom_components = set()
|
|
1662
|
-
|
|
1663
|
-
# Store the seen components in a set to avoid infinite recursion.
|
|
1664
|
-
if seen is None:
|
|
1665
|
-
seen = set()
|
|
1666
|
-
for child in self.children:
|
|
1667
|
-
# Skip BaseComponent and StatefulComponent children.
|
|
1668
|
-
if not isinstance(child, Component):
|
|
1669
|
-
continue
|
|
1670
|
-
custom_components |= child._get_all_custom_components(seen=seen)
|
|
1671
|
-
for component in self._get_components_in_props():
|
|
1672
|
-
if isinstance(component, Component) and component.tag is not None:
|
|
1673
|
-
custom_components |= component._get_all_custom_components(seen=seen)
|
|
1674
|
-
return custom_components
|
|
1675
|
-
|
|
1676
1650
|
@property
|
|
1677
1651
|
def import_var(self):
|
|
1678
1652
|
"""The tag to import.
|
|
@@ -1857,37 +1831,6 @@ class CustomComponent(Component):
|
|
|
1857
1831
|
"""
|
|
1858
1832
|
return set()
|
|
1859
1833
|
|
|
1860
|
-
def _get_all_custom_components(
|
|
1861
|
-
self, seen: set[str] | None = None
|
|
1862
|
-
) -> set[CustomComponent]:
|
|
1863
|
-
"""Get all the custom components used by the component.
|
|
1864
|
-
|
|
1865
|
-
Args:
|
|
1866
|
-
seen: The tags of the components that have already been seen.
|
|
1867
|
-
|
|
1868
|
-
Raises:
|
|
1869
|
-
ValueError: If the tag is not set.
|
|
1870
|
-
|
|
1871
|
-
Returns:
|
|
1872
|
-
The set of custom components.
|
|
1873
|
-
"""
|
|
1874
|
-
if self.tag is None:
|
|
1875
|
-
raise ValueError("The tag must be set.")
|
|
1876
|
-
|
|
1877
|
-
# Store the seen components in a set to avoid infinite recursion.
|
|
1878
|
-
if seen is None:
|
|
1879
|
-
seen = set()
|
|
1880
|
-
custom_components = {self} | super()._get_all_custom_components(seen=seen)
|
|
1881
|
-
|
|
1882
|
-
# Avoid adding the same component twice.
|
|
1883
|
-
if self.tag not in seen:
|
|
1884
|
-
seen.add(self.tag)
|
|
1885
|
-
custom_components |= self.get_component(self)._get_all_custom_components(
|
|
1886
|
-
seen=seen
|
|
1887
|
-
)
|
|
1888
|
-
|
|
1889
|
-
return custom_components
|
|
1890
|
-
|
|
1891
1834
|
@staticmethod
|
|
1892
1835
|
def _get_event_spec_from_args_spec(name: str, event: EventChain) -> Callable:
|
|
1893
1836
|
"""Get the event spec from the args spec.
|
|
@@ -1951,6 +1894,42 @@ class CustomComponent(Component):
|
|
|
1951
1894
|
return self.component_fn(*self.get_prop_vars())
|
|
1952
1895
|
|
|
1953
1896
|
|
|
1897
|
+
CUSTOM_COMPONENTS: dict[str, CustomComponent] = {}
|
|
1898
|
+
|
|
1899
|
+
|
|
1900
|
+
def _register_custom_component(
|
|
1901
|
+
component_fn: Callable[..., Component],
|
|
1902
|
+
):
|
|
1903
|
+
"""Register a custom component to be compiled.
|
|
1904
|
+
|
|
1905
|
+
Args:
|
|
1906
|
+
component_fn: The function that creates the component.
|
|
1907
|
+
|
|
1908
|
+
Raises:
|
|
1909
|
+
TypeError: If the tag name cannot be determined.
|
|
1910
|
+
"""
|
|
1911
|
+
dummy_props = {
|
|
1912
|
+
prop: (
|
|
1913
|
+
Var(
|
|
1914
|
+
"",
|
|
1915
|
+
_var_type=annotation,
|
|
1916
|
+
)
|
|
1917
|
+
if not types.safe_issubclass(annotation, EventHandler)
|
|
1918
|
+
else EventSpec(handler=EventHandler(fn=lambda: []))
|
|
1919
|
+
)
|
|
1920
|
+
for prop, annotation in typing.get_type_hints(component_fn).items()
|
|
1921
|
+
if prop != "return"
|
|
1922
|
+
}
|
|
1923
|
+
dummy_component = CustomComponent._create(
|
|
1924
|
+
children=[],
|
|
1925
|
+
component_fn=component_fn,
|
|
1926
|
+
**dummy_props,
|
|
1927
|
+
)
|
|
1928
|
+
if dummy_component.tag is None:
|
|
1929
|
+
raise TypeError(f"Could not determine the tag name for {component_fn!r}")
|
|
1930
|
+
CUSTOM_COMPONENTS[dummy_component.tag] = dummy_component
|
|
1931
|
+
|
|
1932
|
+
|
|
1954
1933
|
def custom_component(
|
|
1955
1934
|
component_fn: Callable[..., Component],
|
|
1956
1935
|
) -> Callable[..., CustomComponent]:
|
|
@@ -1971,6 +1950,9 @@ def custom_component(
|
|
|
1971
1950
|
children=list(children), component_fn=component_fn, **props
|
|
1972
1951
|
)
|
|
1973
1952
|
|
|
1953
|
+
# Register this component so it can be compiled.
|
|
1954
|
+
_register_custom_component(component_fn)
|
|
1955
|
+
|
|
1974
1956
|
return wrapper
|
|
1975
1957
|
|
|
1976
1958
|
|
reflex/components/core/upload.py
CHANGED
|
@@ -273,6 +273,14 @@ class Upload(MemoizationLeaf):
|
|
|
273
273
|
elif isinstance(on_drop, Callable):
|
|
274
274
|
# Call the lambda to get the event chain.
|
|
275
275
|
on_drop = call_event_fn(on_drop, _on_drop_spec)
|
|
276
|
+
if isinstance(on_drop, EventSpec):
|
|
277
|
+
# Update the provided args for direct use with on_drop.
|
|
278
|
+
on_drop = on_drop.with_args(
|
|
279
|
+
args=tuple(
|
|
280
|
+
cls._update_arg_tuple_for_on_drop(arg_value)
|
|
281
|
+
for arg_value in on_drop.args
|
|
282
|
+
),
|
|
283
|
+
)
|
|
276
284
|
upload_props["on_drop"] = on_drop
|
|
277
285
|
|
|
278
286
|
input_props_unique_name = get_unique_variable_name()
|
reflex/components/dynamic.py
CHANGED
|
@@ -26,7 +26,15 @@ def get_cdn_url(lib: str) -> str:
|
|
|
26
26
|
return f"https://cdn.jsdelivr.net/npm/{lib}" + "/+esm"
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
bundled_libraries = {
|
|
29
|
+
bundled_libraries = {
|
|
30
|
+
"react",
|
|
31
|
+
"@radix-ui/themes",
|
|
32
|
+
"@emotion/react",
|
|
33
|
+
"next/link",
|
|
34
|
+
f"$/{constants.Dirs.UTILS}/context",
|
|
35
|
+
f"$/{constants.Dirs.UTILS}/state",
|
|
36
|
+
f"$/{constants.Dirs.UTILS}/components",
|
|
37
|
+
}
|
|
30
38
|
|
|
31
39
|
|
|
32
40
|
def bundle_library(component: Union["Component", str]):
|
|
@@ -1100,7 +1100,6 @@ class StyleEl(Element):
|
|
|
1100
1100
|
cls,
|
|
1101
1101
|
*children,
|
|
1102
1102
|
media: Var[str] | str | None = None,
|
|
1103
|
-
suppress_hydration_warning: Var[bool] | bool | None = None,
|
|
1104
1103
|
style: Sequence[Mapping[str, Any]]
|
|
1105
1104
|
| Mapping[str, Any]
|
|
1106
1105
|
| Var[Mapping[str, Any]]
|
|
@@ -192,27 +192,6 @@ class Markdown(Component):
|
|
|
192
192
|
**props,
|
|
193
193
|
)
|
|
194
194
|
|
|
195
|
-
def _get_all_custom_components(
|
|
196
|
-
self, seen: set[str] | None = None
|
|
197
|
-
) -> set[CustomComponent]:
|
|
198
|
-
"""Get all the custom components used by the component.
|
|
199
|
-
|
|
200
|
-
Args:
|
|
201
|
-
seen: The tags of the components that have already been seen.
|
|
202
|
-
|
|
203
|
-
Returns:
|
|
204
|
-
The set of custom components.
|
|
205
|
-
"""
|
|
206
|
-
custom_components = super()._get_all_custom_components(seen=seen)
|
|
207
|
-
|
|
208
|
-
# Get the custom components for each tag.
|
|
209
|
-
for component in self.component_map.values():
|
|
210
|
-
custom_components |= component(_MOCK_ARG)._get_all_custom_components(
|
|
211
|
-
seen=seen
|
|
212
|
-
)
|
|
213
|
-
|
|
214
|
-
return custom_components
|
|
215
|
-
|
|
216
195
|
def add_imports(self) -> ImportDict | list[ImportDict]:
|
|
217
196
|
"""Add imports for the markdown component.
|
|
218
197
|
|
|
@@ -15,8 +15,8 @@ from reflex.utils.imports import ImportDict
|
|
|
15
15
|
from reflex.vars.base import LiteralVar, Var, VarData
|
|
16
16
|
|
|
17
17
|
_CHILDREN = Var(_js_expr="children", _var_type=str)
|
|
18
|
-
_PROPS = Var(_js_expr="props")
|
|
19
|
-
|
|
18
|
+
_PROPS = Var(_js_expr="...props")
|
|
19
|
+
_PROPS_IN_TAG = Var(_js_expr="{...props}")
|
|
20
20
|
_MOCK_ARG = Var(_js_expr="", _var_type=str)
|
|
21
21
|
_LANGUAGE = Var(_js_expr="_language", _var_type=str)
|
|
22
22
|
_REMARK_MATH = Var(_js_expr="remarkMath")
|
|
@@ -54,7 +54,7 @@ def _inherited_variant_selector(
|
|
|
54
54
|
class AccordionComponent(RadixPrimitiveComponent):
|
|
55
55
|
"""Base class for all @radix-ui/accordion components."""
|
|
56
56
|
|
|
57
|
-
library = "@radix-ui/react-accordion@^1.2.
|
|
57
|
+
library = "@radix-ui/react-accordion@^1.2.8"
|
|
58
58
|
|
|
59
59
|
# The color scheme of the component.
|
|
60
60
|
color_scheme: Var[LiteralAccentColor]
|
|
@@ -17,7 +17,7 @@ from .base import RadixPrimitiveComponentWithClassName
|
|
|
17
17
|
class FormComponent(RadixPrimitiveComponentWithClassName):
|
|
18
18
|
"""Base class for all @radix-ui/react-form components."""
|
|
19
19
|
|
|
20
|
-
library = "@radix-ui/react-form@^0.1.
|
|
20
|
+
library = "@radix-ui/react-form@^0.1.4"
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
class FormRoot(FormComponent, HTMLForm):
|
|
@@ -15,7 +15,7 @@ from reflex.vars.base import Var
|
|
|
15
15
|
class ProgressComponent(RadixPrimitiveComponentWithClassName):
|
|
16
16
|
"""A Progress component."""
|
|
17
17
|
|
|
18
|
-
library = "@radix-ui/react-progress@^1.1.
|
|
18
|
+
library = "@radix-ui/react-progress@^1.1.4"
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
class ProgressRoot(ProgressComponent):
|
|
@@ -17,7 +17,7 @@ LiteralSliderDir = Literal["ltr", "rtl"]
|
|
|
17
17
|
class SliderComponent(RadixPrimitiveComponentWithClassName):
|
|
18
18
|
"""Base class for all @radix-ui/react-slider components."""
|
|
19
19
|
|
|
20
|
-
library = "@radix-ui/react-slider@^1.2
|
|
20
|
+
library = "@radix-ui/react-slider@^1.3.2"
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
def on_value_event_spec(
|
|
@@ -205,5 +205,5 @@ class ColorModeNamespace(Var):
|
|
|
205
205
|
color_mode = color_mode_var_and_namespace = ColorModeNamespace(
|
|
206
206
|
_js_expr=color_mode._js_expr,
|
|
207
207
|
_var_type=color_mode._var_type,
|
|
208
|
-
_var_data=color_mode.
|
|
208
|
+
_var_data=color_mode._get_all_var_data(),
|
|
209
209
|
)
|
|
@@ -572,5 +572,5 @@ class ColorModeNamespace(Var):
|
|
|
572
572
|
color_mode = color_mode_var_and_namespace = ColorModeNamespace(
|
|
573
573
|
_js_expr=color_mode._js_expr,
|
|
574
574
|
_var_type=color_mode._var_type,
|
|
575
|
-
_var_data=color_mode.
|
|
575
|
+
_var_data=color_mode._get_all_var_data(),
|
|
576
576
|
)
|